1import{j as f}from"./query-U2Cx38is.js";import{r as C,k as ue,j as Jt,c as er,f as Xe}from"./vendor-GwJQMIA-.js";import{u as tr,T as rr}from"./ToastContainer-BIcs0n28.js";import{L as nr}from"./LoadingState-CpigRoua.js";import{r as le}from"./receiptSettlement-BTbY7Ezd.js";import{g as ae}from"./api-Cm6TCQLV.js";import{e as Je}from"./eventComponents-k_n7C981.js";import{b as ar,r as Ke,a as ir,c as or,e as Ve,f as sr,R as ur}from"./ReceiptDiscrepancyBanner-DLiiZbTa.js";import{c as cr}from"./confirmAndNotifyReceipt-DzSTFLq0.js";import{m as fr}from"./menu-Cekn6z-2.js";import"./index-Z4pnWrZL.js";import"./ui-B-dksMZM.js";import"./utils-y1iingcd.js";function lr(){const[o,h]=C.useState({isOnline:typeof navigator<"u"?navigator.onLine:!0,wasOffline:!1,lastOnlineTime:null}),p=C.useCallback(()=>{h(b=>({isOnline:!0,wasOffline:b.isOnline?b.wasOffline:!0,lastOnlineTime:new Date}))},[]),m=C.useCallback(()=>{h(b=>({...b,isOnline:!1}))},[]);C.useEffect(()=>(window.addEventListener("online",p),window.addEventListener("offline",m),()=>{window.removeEventListener("online",p),window.removeEventListener("offline",m)}),[p,m]);const y=C.useCallback(()=>{h(b=>({...b,wasOffline:!1}))},[]);return{isOnline:o.isOnline,isOffline:!o.isOnline,wasOffline:o.wasOffline,lastOnlineTime:o.lastOnlineTime,clearOfflineFlag:y}}function ce(o){throw new Error('Could not dynamically require "'+o+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var _e={exports:{}};var Ge;function dr(){return Ge||(Ge=1,(function(o,h){(function(p){o.exports=p()})(function(){return(function p(m,y,b){function E(S,I){if(!y[S]){if(!m[S]){var c=typeof ce=="function"&&ce;if(!I&&c)return c(S,!0);if(w)return w(S,!0);var _=new Error("Cannot find module '"+S+"'");throw _.code="MODULE_NOT_FOUND",_}var F=y[S]={exports:{}};m[S][0].call(F.exports,function(k){var D=m[S][1][k];return E(D||k)},F,F.exports,p,m,y,b)}return y[S].exports}for(var w=typeof ce=="function"&&ce,N=0;N<b.length;N++)E(b[N]);return E})({1:[function(p,m,y){(function(b){var E=b.MutationObserver||b.WebKitMutationObserver,w;if(E){var N=0,S=new E(k),I=b.document.createTextNode("");S.observe(I,{characterData:!0}),w=function(){I.data=N=++N%2}}else if(!b.setImmediate&&typeof b.MessageChannel<"u"){var c=new b.MessageChannel;c.port1.onmessage=k,w=function(){c.port2.postMessage(0)}}else"document"in b&&"onreadystatechange"in b.document.createElement("script")?w=function(){var T=b.document.createElement("script");T.onreadystatechange=function(){k(),T.onreadystatechange=null,T.parentNode.removeChild(T),T=null},b.document.documentElement.appendChild(T)}:w=function(){setTimeout(k,0)};var _,F=[];function k(){_=!0;for(var T,P,R=F.length;R;){for(P=F,F=[],T=-1;++T<R;)P[T]();R=F.length}_=!1}m.exports=D;function D(T){F.push(T)===1&&!_&&w()}}).call(this,typeof ue<"u"?ue:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(p,m,y){var b=p(1);function E(){}var w={},N=["REJECTED"],S=["FULFILLED"],I=["PENDING"];m.exports=c;function c(g){if(typeof g!="function")throw new TypeError("resolver must be a function");this.state=I,this.queue=[],this.outcome=void 0,g!==E&&D(this,g)}c.prototype.catch=function(g){return this.then(null,g)},c.prototype.then=function(g,j){if(typeof g!="function"&&this.state===S||typeof j!="function"&&this.state===N)return this;var L=new this.constructor(E);if(this.state!==I){var M=this.state===S?g:j;F(L,M,this.outcome)}else this.queue.push(new _(L,g,j));return L};function _(g,j,L){this.promise=g,typeof j=="function"&&(this.onFulfilled=j,this.callFulfilled=this.otherCallFulfilled),typeof L=="function"&&(this.onRejected=L,this.callRejected=this.otherCallRejected)}_.prototype.callFulfilled=function(g){w.resolve(this.promise,g)},_.prototype.otherCallFulfilled=function(g){F(this.promise,this.onFulfilled,g)},_.prototype.callRejected=function(g){w.reject(this.promise,g)},_.prototype.otherCallRejected=function(g){F(this.promise,this.onRejected,g)};function F(g,j,L){b(function(){var M;try{M=j(L)}catch(Y){return w.reject(g,Y)}M===g?w.reject(g,new TypeError("Cannot resolve promise with itself")):w.resolve(g,M)})}w.resolve=function(g,j){var L=T(k,j);if(L.status==="error")return w.reject(g,L.value);var M=L.value;if(M)D(g,M);else{g.state=S,g.outcome=j;for(var Y=-1,z=g.queue.length;++Y<z;)g.queue[Y].callFulfilled(j)}return g},w.reject=function(g,j){g.state=N,g.outcome=j;for(var L=-1,M=g.queue.length;++L<M;)g.queue[L].callRejected(j);return g};function k(g){var j=g&&g.then;if(g&&(typeof g=="object"||typeof g=="function")&&typeof j=="function")return function(){j.apply(g,arguments)}}function D(g,j){var L=!1;function M(H){L||(L=!0,w.reject(g,H))}function Y(H){L||(L=!0,w.resolve(g,H))}function z(){j(Y,M)}var q=T(z);q.status==="error"&&M(q.value)}function T(g,j){var L={};try{L.value=g(j),L.status="success"}catch(M){L.status="error",L.value=M}return L}c.resolve=P;function P(g){return g instanceof this?g:w.resolve(new this(E),g)}c.reject=R;function R(g){var j=new this(E);return w.reject(j,g)}c.all=K;function K(g){var j=this;if(Object.prototype.toString.call(g)!=="[object Array]")return this.reject(new TypeError("must be an array"));var L=g.length,M=!1;if(!L)return this.resolve([]);for(var Y=new Array(L),z=0,q=-1,H=new this(E);++q<L;)V(g[q],q);return H;function V(te,ie){j.resolve(te).then(de,function(J){M||(M=!0,w.reject(H,J))});function de(J){Y[ie]=J,++z===L&&!M&&(M=!0,w.resolve(H,Y))}}}c.race=W;function W(g){var j=this;if(Object.prototype.toString.call(g)!=="[object Array]")return this.reject(new TypeError("must be an array"));var L=g.length,M=!1;if(!L)return this.resolve([]);for(var Y=-1,z=new this(E);++Y<L;)q(g[Y]);return z;function q(H){j.resolve(H).then(function(V){M||(M=!0,w.resolve(z,V))},function(V){M||(M=!0,w.reject(z,V))})}}},{1:1}],3:[function(p,m,y){(function(b){typeof b.Promise!="function"&&(b.Promise=p(2))}).call(this,typeof ue<"u"?ue:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(p,m,y){var b=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function E(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function w(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var N=w();
vendor: 23,568 bytes, line 1
1function S(){try{if(!N||!N.open)return!1;var e=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),r=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!e||r)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function I(e,r){e=e||[],r=r||{};try{return new Blob(e,r)}catch(n){if(n.name!=="TypeError")throw n;for(var t=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,a=new t,i=0;i<e.length;i+=1)a.append(e[i]);return a.getBlob(r.type)}}typeof Promise>"u"&&p(3);var c=Promise;function _(e,r){r&&e.then(function(t){r(null,t)},function(t){r(t)})}function F(e,r,t){typeof r=="function"&&e.then(r),typeof t=="function"&&e.catch(t)}function k(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function D(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var T="local-forage-detect-blob-support",P=void 0,R={},K=Object.prototype.toString,W="readonly",g="readwrite";function j(e){for(var r=e.length,t=new ArrayBuffer(r),a=new Uint8Array(t),i=0;i<r;i++)a[i]=e.charCodeAt(i);return t}function L(e){return new c(function(r){var t=e.transaction(T,g),a=I([""]);t.objectStore(T).put(a,"key"),t.onabort=function(i){i.preventDefault(),i.stopPropagation(),r(!1)},t.oncomplete=function(){var i=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);r(n||!i||parseInt(i[1],10)>=43)}}).catch(function(){return!1})}function M(e){return typeof P=="boolean"?c.resolve(P):L(e).then(function(r){return P=r,P})}function Y(e){var r=R[e.name],t={};t.promise=new c(function(a,i){t.resolve=a,t.reject=i}),r.deferredOperations.push(t),r.dbReady?r.dbReady=r.dbReady.then(function(){return t.promise}):r.dbReady=t.promise}function z(e){var r=R[e.name],t=r.deferredOperations.pop();if(t)return t.resolve(),t.promise}function q(e,r){var t=R[e.name],a=t.deferredOperations.pop();if(a)return a.reject(r),a.promise}function H(e,r){return new c(function(t,a){if(R[e.name]=R[e.name]||Ie(),e.db)if(r)Y(e),e.db.close();else return t(e.db);var i=[e.name];r&&i.push(e.version);var n=N.open.apply(N,i);r&&(n.onupgradeneeded=function(s){var u=n.result;try{u.createObjectStore(e.storeName),s.oldVersion<=1&&u.createObjectStore(T)}catch(l){if(l.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+s.oldVersion+" to version "+s.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw l}}),n.onerror=function(s){s.preventDefault(),a(n.error)},n.onsuccess=function(){var s=n.result;s.onversionchange=function(u){u.target.close()},t(s),z(e)}})}function V(e){return H(e,!1)}function te(e){return H(e,!0)}function ie(e,r){if(!e.db)return!0;var t=!e.db.objectStoreNames.contains(e.storeName),a=e.version<e.db.version,i=e.version>e.db.version;if(a&&(e.version!==r&&console.warn('The database "'+e.name+`" can't be downgraded from version `+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||t){if(t){var n=e.db.version+1;n>e.version&&(e.version=n)}return!0}return!1}function de(e){return new c(function(r,t){var a=new FileReader;a.onerror=t,a.onloadend=function(i){var n=btoa(i.target.result||"");r({__local_forage_encoded_blob:!0,data:n,type:e.type})},a.readAsBinaryString(e)})}function J(e){var r=j(atob(e.data));return I([r],{type:e.type})}function Ce(e){return e&&e.__local_forage_encoded_blob}function et(e){var r=this,t=r._initReady().then(function(){var a=R[r._dbInfo.name];if(a&&a.dbReady)return a.dbReady});return F(t,e,e),t}function tt(e){Y(e);for(var r=R[e.name],t=r.forages,a=0;a<t.length;a++){var i=t[a];i._dbInfo.db&&(i._dbInfo.db.close(),i._dbInfo.db=null)}return e.db=null,V(e).then(function(n){return e.db=n,ie(e)?te(e):n}).then(function(n){e.db=r.db=n;for(var s=0;s<t.length;s++)t[s]._dbInfo.db=n}).catch(function(n){throw q(e,n),n})}function G(e,r,t,a){a===void 0&&(a=1);try{var i=e.db.transaction(e.storeName,r);t(null,i)}catch(n){if(a>0&&(!e.db||n.name==="InvalidStateError"||n.name==="NotFoundError"))return c.resolve().then(function(){if(!e.db||n.name==="NotFoundError"&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),te(e)}).then(function(){return tt(e).then(function(){G(e,r,t,a-1)})}).catch(t);t(n)}}function Ie(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function rt(e){var r=this,t={db:null};if(e)for(var a in e)t[a]=e[a];var i=R[t.name];i||(i=Ie(),R[t.name]=i),i.forages.push(r),r._initReady||(r._initReady=r.ready,r.ready=et);var n=[];function s(){return c.resolve()}for(var u=0;u<i.forages.length;u++){var l=i.forages[u];l!==r&&n.push(l._initReady().catch(s))}var d=i.forages.slice(0);return c.all(n).then(function(){return t.db=i.db,V(t)}).then(function(v){return t.db=v,ie(t,r._defaultConfig.version)?te(t):v}).then(function(v){t.db=i.db=v,r._dbInfo=t;for(var x=0;x<d.length;x++){var A=d[x];A!==r&&(A._dbInfo.db=t.db,A._dbInfo.version=t.version)}})}function nt(e,r){var t=this;e=k(e);var a=new c(function(i,n){t.ready().then(function(){G(t._dbInfo,W,function(s,u){if(s)return n(s);try{var l=u.objectStore(t._dbInfo.storeName),d=l.get(e);d.onsuccess=function(){var v=d.result;v===void 0&&(v=null),Ce(v)&&(v=J(v)),i(v)},d.onerror=function(){n(d.error)}}catch(v){n(v)}})}).catch(n)});return _(a,r),a}function at(e,r){var t=this,a=new c(function(i,n){t.ready().then(function(){G(t._dbInfo,W,function(s,u){if(s)return n(s);try{var l=u.objectStore(t._dbInfo.storeName),d=l.openCursor(),v=1;d.onsuccess=function(){var x=d.result;if(x){var A=x.value;Ce(A)&&(A=J(A));var B=e(A,x.key,v++);B!==void 0?i(B):x.continue()}else i()},d.onerror=function(){n(d.error)}}catch(x){n(x)}})}).catch(n)});return _(a,r),a}function it(e,r,t){var a=this;e=k(e);var i=new c(function(n,s){var u;a.ready().then(function(){return u=a._dbInfo,K.call(r)==="[object Blob]"?M(u.db).then(function(l){return l?r:de(r)}):r}).then(function(l){G(a._dbInfo,g,function(d,v){if(d)return s(d);try{var x=v.objectStore(a._dbInfo.storeName);l===null&&(l=void 0);var A=x.put(l,e);v.oncomplete=function(){l===void 0&&(l=null),n(l)},v.onabort=v.onerror=function(){var B=A.error?A.error:A.transaction.error;s(B)}}catch(B){s(B)}})}).catch(s)});return _(i,t),i}function ot(e,r){var t=this;e=k(e);var a=new c(function(i,n){t.ready().then(function(){G(t._dbInfo,g,function(s,u){if(s)return n(s);try{var l=u.objectStore(t._dbInfo.storeName),d=l.delete(e);u.oncomplete=function(){i()},u.onerror=function(){n(d.error)},u.onabort=function(){var v=d.error?d.error:d.transaction.error;n(v)}}catch(v){n(v)}})}).catch(n)});return _(a,r),a}function st(e){var r=this,t=new c(function(a,i){r.ready().then(function(){G(r._dbInfo,g,function(n,s){if(n)return i(n);try{var u=s.objectStore(r._dbInfo.storeName),l=u.clear();s.oncomplete=function(){a()},s.onabort=s.onerror=function(){var d=l.error?l.error:l.transaction.error;i(d)}}catch(d){i(d)}})}).catch(i)});return _(t,e),t}function ut(e){var r=this,t=new c(function(a,i){r.ready().then(function(){G(r._dbInfo,W,function(n,s){if(n)return i(n);try{var u=s.objectStore(r._dbInfo.storeName),l=u.count();l.onsuccess=function(){a(l.result)},l.onerror=function(){i(l.error)}}catch(d){i(d)}})}).catch(i)});return _(t,e),t}function ct(e,r){var t=this,a=new c(function(i,n){if(e<0){i(null);return}t.ready().then(function(){G(t._dbInfo,W,function(s,u){if(s)return n(s);try{var l=u.objectStore(t._dbInfo.storeName),d=!1,v=l.openKeyCursor();v.onsuccess=function(){var x=v.result;if(!x){i(null);return}e===0||d?i(x.key):(d=!0,x.advance(e))},v.onerror=function(){n(v.error)}}catch(x){n(x)}})}).catch(n)});return _(a,r),a}function ft(e){var r=this,t=new c(function(a,i){r.ready().then(function(){G(r._dbInfo,W,function(n,s){if(n)return i(n);try{var u=s.objectStore(r._dbInfo.storeName),l=u.openKeyCursor(),d=[];l.onsuccess=function(){var v=l.result;if(!v){a(d);return}d.push(v.key),v.continue()},l.onerror=function(){i(l.error)}}catch(v){i(v)}})}).catch(i)});return _(t,e),t}function lt(e,r){r=D.apply(this,arguments);var t=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||t.name,e.storeName=e.storeName||t.storeName);var a=this,i;if(!e.name)i=c.reject("Invalid arguments");else{var n=e.name===t.name&&a._dbInfo.db,s=n?c.resolve(a._dbInfo.db):V(e).then(function(u){var l=R[e.name],d=l.forages;l.db=u;for(var v=0;v<d.length;v++)d[v]._dbInfo.db=u;return u});e.storeName?i=s.then(function(u){if(u.objectStoreNames.contains(e.storeName)){var l=u.version+1;Y(e);var d=R[e.name],v=d.forages;u.close();for(var x=0;x<v.length;x++){var A=v[x];A._dbInfo.db=null,A._dbInfo.version=l}var B=new c(function(O,$){var U=N.open(e.name,l);U.onerror=function(Q){var ne=U.result;ne.close(),$(Q)},U.onupgradeneeded=function(){var Q=U.result;Q.deleteObjectStore(e.storeName)},U.onsuccess=function(){var Q=U.result;Q.close(),O(Q)}});return B.then(function(O){d.db=O;for(var $=0;$<v.length;$++){var U=v[$];U._dbInfo.db=O,z(U._dbInfo)}}).catch(function(O){throw(q(e,O)||c.resolve()).catch(function(){}),O})}}):i=s.then(function(u){Y(e);var l=R[e.name],d=l.forages;u.close();for(var v=0;v<d.length;v++){var x=d[v];x._dbInfo.db=null}var A=new c(function(B,O){var $=N.deleteDatabase(e.name);$.onerror=function(){var U=$.result;U&&U.close(),O($.error)},$.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},$.onsuccess=function(){var U=$.result;U&&U.close(),B(U)}});return A.then(function(B){l.db=B;for(var O=0;O<d.length;O++){var $=d[O];z($._dbInfo)}}).catch(function(B){throw(q(e,B)||c.resolve()).catch(function(){}),B})})}return _(i,r),i}var dt={_driver:"asyncStorage",_initStorage:rt,_support:S(),iterate:at,getItem:nt,setItem:it,removeItem:ot,clear:st,length:ut,key:ct,keys:ft,dropInstance:lt};function mt(){return typeof openDatabase=="function"}var Z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",vt="~~local_forage_type~",Te=/^~~local_forage_type~([^~]+)~/,oe="__lfsc__:",me=oe.length,ve="arbf",he="blob",Ae="si08",Le="ui08",je="uic8",De="si16",Pe="si32",Be="ur16",Oe="ui32",ke="fl32",Me="fl64",Fe=me+ve.length,Ue=Object.prototype.toString;function $e(e){var r=e.length*.75,t=e.length,a,i=0,n,s,u,l;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);var d=new ArrayBuffer(r),v=new Uint8Array(d);for(a=0;a<t;a+=4)n=Z.indexOf(e[a]),s=Z.indexOf(e[a+1]),u=Z.indexOf(e[a+2]),l=Z.indexOf(e[a+3]),v[i++]=n<<2|s>>4,v[i++]=(s&15)<<4|u>>2,v[i++]=(u&3)<<6|l&63;return d}function pe(e){var r=new Uint8Array(e),t="",a;for(a=0;a<r.length;a+=3)t+=Z[r[a]>>2],t+=Z[(r[a]&3)<<4|r[a+1]>>4],t+=Z[(r[a+1]&15)<<2|r[a+2]>>6],t+=Z[r[a+2]&63];return r.length%3===2?t=t.substring(0,t.length-1)+"=":r.length%3===1&&(t=t.substring(0,t.length-2)+"=="),t}function ht(e,r){var t="";if(e&&(t=Ue.call(e)),e&&(t==="[object ArrayBuffer]"||e.buffer&&Ue.call(e.buffer)==="[object ArrayBuffer]")){var a,i=oe;e instanceof ArrayBuffer?(a=e,i+=ve):(a=e.buffer,t==="[object Int8Array]"?i+=Ae:t==="[object Uint8Array]"?i+=Le:t==="[object Uint8ClampedArray]"?i+=je:t==="[object Int16Array]"?i+=De:t==="[object Uint16Array]"?i+=Be:t==="[object Int32Array]"?i+=Pe:t==="[object Uint32Array]"?i+=Oe:t==="[object Float32Array]"?i+=ke:t==="[object Float64Array]"?i+=Me:r(new Error("Failed to get type for BinaryArray"))),r(i+pe(a))}else if(t==="[object Blob]"){var n=new FileReader;n.onload=function(){var s=vt+e.type+"~"+pe(this.result);r(oe+he+s)},n.readAsArrayBuffer(e)}else try{r(JSON.stringify(e))}catch(s){console.error("Couldn't convert value into a JSON string: ",e),r(null,s)}}function pt(e){if(e.substring(0,me)!==oe)return JSON.parse(e);var r=e.substring(Fe),t=e.substring(me,Fe),a;if(t===he&&Te.test(r)){var i=r.match(Te);a=i[1],r=r.substring(i[0].length)}var n=$e(r);switch(t){case ve:return n;case he:return I([n],{type:a});case Ae:return new Int8Array(n);case Le:return new Uint8Array(n);case je:return new Uint8ClampedArray(n);case De:return new Int16Array(n);case Be:return new Uint16Array(n);case Pe:return new Int32Array(n);case Oe:return new Uint32Array(n);case ke:return new Float32Array(n);case Me:return new Float64Array(n);default:throw new Error("Unkown type: "+t)}}var ge={serialize:ht,deserialize:pt,stringToBuffer:$e,bufferToString:pe};function Ye(e,r,t,a){e.executeSql("CREATE TABLE IF NOT EXISTS "+r.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],t,a)}function gt(e){var r=this,t={db:null};if(e)for(var a in e)t[a]=typeof e[a]!="string"?e[a].toString():e[a];var i=new c(function(n,s){try{t.db=openDatabase(t.name,String(t.version),t.description,t.size)}catch(u){return s(u)}t.db.transaction(function(u){Ye(u,t,function(){r._dbInfo=t,n()},function(l,d){s(d)})},s)});return t.serializer=ge,i}function X(e,r,t,a,i,n){e.executeSql(t,a,i,function(s,u){u.code===u.SYNTAX_ERR?s.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[r.storeName],function(l,d){d.rows.length?n(l,u):Ye(l,r,function(){l.executeSql(t,a,i,n)},n)},n):n(s,u)},n)}function yt(e,r){var t=this;e=k(e);var a=new c(function(i,n){t.ready().then(function(){var s=t._dbInfo;s.db.transaction(function(u){X(u,s,"SELECT * FROM "+s.storeName+" WHERE key = ? LIMIT 1",[e],function(l,d){var v=d.rows.length?d.rows.item(0).value:null;v&&(v=s.serializer.deserialize(v)),i(v)},function(l,d){n(d)})})}).catch(n)});return _(a,r),a}function bt(e,r){var t=this,a=new c(function(i,n){t.ready().then(function(){var s=t._dbInfo;s.db.transaction(function(u){X(u,s,"SELECT * FROM "+s.storeName,[],function(l,d){for(var v=d.rows,x=v.length,A=0;A<x;A++){var B=v.item(A),O=B.value;if(O&&(O=s.serializer.deserialize(O)),O=e(O,B.key,A+1),O!==void 0){i(O);return}}i()},function(l,d){n(d)})})}).catch(n)});return _(a,r),a}function ze(e,r,t,a){var i=this;e=k(e);var n=new c(function(s,u){i.ready().then(function(){r===void 0&&(r=null);var l=r,d=i._dbInfo;d.serializer.serialize(r,function(v,x){x?u(x):d.db.transaction(function(A){X(A,d,"INSERT OR REPLACE INTO "+d.storeName+" (key, value) VALUES (?, ?)",[e,v],function(){s(l)},function(B,O){u(O)})},function(A){if(A.code===A.QUOTA_ERR){if(a>0){s(ze.apply(i,[e,l,t,a-1]));return}u(A)}})})}).catch(u)});return _(n,t),n}function xt(e,r,t){return ze.apply(this,[e,r,t,1])}function wt(e,r){var t=this;e=k(e);var a=new c(function(i,n){t.ready().then(function(){var s=t._dbInfo;s.db.transaction(function(u){X(u,s,"DELETE FROM "+s.storeName+" WHERE key = ?",[e],function(){i()},function(l,d){n(d)})})}).catch(n)});return _(a,r),a}function _t(e){var r=this,t=new c(function(a,i){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(s){X(s,n,"DELETE FROM "+n.storeName,[],function(){a()},function(u,l){i(l)})})}).catch(i)});return _(t,e),t}function Nt(e){var r=this,t=new c(function(a,i){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(s){X(s,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(u,l){var d=l.rows.item(0).c;a(d)},function(u,l){i(l)})})}).catch(i)});return _(t,e),t}function St(e,r){var t=this,a=new c(function(i,n){t.ready().then(function(){var s=t._dbInfo;s.db.transaction(function(u){X(u,s,"SELECT key FROM "+s.storeName+" WHERE id = ? LIMIT 1",[e+1],function(l,d){var v=d.rows.length?d.rows.item(0).key:null;i(v)},function(l,d){n(d)})})}).catch(n)});return _(a,r),a}function Et(e){var r=this,t=new c(function(a,i){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(s){X(s,n,"SELECT key FROM "+n.storeName,[],function(u,l){for(var d=[],v=0;v<l.rows.length;v++)d.push(l.rows.item(v).key);a(d)},function(u,l){i(l)})})}).catch(i)});return _(t,e),t}function Rt(e){return new c(function(r,t){e.transaction(function(a){a.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(i,n){for(var s=[],u=0;u<n.rows.length;u++)s.push(n.rows.item(u).name);r({db:e,storeNames:s})},function(i,n){t(n)})},function(a){t(a)})})}function Ct(e,r){r=D.apply(this,arguments);var t=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||t.name,e.storeName=e.storeName||t.storeName);var a=this,i;return e.name?i=new c(function(n){var s;e.name===t.name?s=a._dbInfo.db:s=openDatabase(e.name,"","",0),e.storeName?n({db:s,storeNames:[e.storeName]}):n(Rt(s))}).then(function(n){return new c(function(s,u){n.db.transaction(function(l){function d(B){return new c(function(O,$){l.executeSql("DROP TABLE IF EXISTS "+B,[],function(){O()},function(U,Q){$(Q)})})}for(var v=[],x=0,A=n.storeNames.length;x<A;x++)v.push(d(n.storeNames[x]));c.all(v).then(function(){s()}).catch(function(B){u(B)})},function(l){u(l)})})}):i=c.reject("Invalid arguments"),_(i,r),i}var It={_driver:"webSQLStorage",_initStorage:gt,_support:mt(),iterate:bt,getItem:yt,setItem:xt,removeItem:wt,clear:_t,length:Nt,key:St,keys:Et,dropInstance:Ct};function Tt(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function We(e,r){var t=e.name+"/";return e.storeName!==r.storeName&&(t+=e.storeName+"/"),t}function At(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}function Lt(){return!At()||localStorage.length>0}function jt(e){var r=this,t={};if(e)for(var a in e)t[a]=e[a];return t.keyPrefix=We(e,r._defaultConfig),Lt()?(r._dbInfo=t,t.serializer=ge,c.resolve()):c.reject()}function Dt(e){var r=this,t=r.ready().then(function(){for(var a=r._dbInfo.keyPrefix,i=localStorage.length-1;i>=0;i--){var n=localStorage.key(i);n.indexOf(a)===0&&localStorage.removeItem(n)}});return _(t,e),t}function Pt(e,r){var t=this;e=k(e);var a=t.ready().then(function(){var i=t._dbInfo,n=localStorage.getItem(i.keyPrefix+e);return n&&(n=i.serializer.deserialize(n)),n});return _(a,r),a}function Bt(e,r){var t=this,a=t.ready().then(function(){for(var i=t._dbInfo,n=i.keyPrefix,s=n.length,u=localStorage.length,l=1,d=0;d<u;d++){var v=localStorage.key(d);if(v.indexOf(n)===0){var x=localStorage.getItem(v);if(x&&(x=i.serializer.deserialize(x)),x=e(x,v.substring(s),l++),x!==void 0)return x}}});return _(a,r),a}function Ot(e,r){var t=this,a=t.ready().then(function(){var i=t._dbInfo,n;try{n=localStorage.key(e)}catch{n=null}return n&&(n=n.substring(i.keyPrefix.length)),n});return _(a,r),a}function kt(e){var r=this,t=r.ready().then(function(){for(var a=r._dbInfo,i=localStorage.length,n=[],s=0;s<i;s++){var u=localStorage.key(s);u.indexOf(a.keyPrefix)===0&&n.push(u.substring(a.keyPrefix.length))}return n});return _(t,e),t}function Mt(e){var r=this,t=r.keys().then(function(a){return a.length});return _(t,e),t}function Ft(e,r){var t=this;e=k(e);var a=t.ready().then(function(){var i=t._dbInfo;localStorage.removeItem(i.keyPrefix+e)});return _(a,r),a}function Ut(e,r,t){var a=this;e=k(e);var i=a.ready().then(function(){r===void 0&&(r=null);var n=r;return new c(function(s,u){var l=a._dbInfo;l.serializer.serialize(r,function(d,v){if(v)u(v);else try{localStorage.setItem(l.keyPrefix+e,d),s(n)}catch(x){(x.name==="QuotaExceededError"||x.name==="NS_ERROR_DOM_QUOTA_REACHED")&&u(x),u(x)}})})});return _(i,t),i}function $t(e,r){if(r=D.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var t=this.config();e.name=e.name||t.name,e.storeName=e.storeName||t.storeName}var a=this,i;return e.name?i=new c(function(n){e.storeName?n(We(e,a._defaultConfig)):n(e.name+"/")}).then(function(n){for(var s=localStorage.length-1;s>=0;s--){var u=localStorage.key(s);u.indexOf(n)===0&&localStorage.removeItem(u)}}):i=c.reject("Invalid arguments"),_(i,r),i}var Yt={_driver:"localStorageWrapper",_initStorage:jt,_support:Tt(),iterate:Bt,getItem:Pt,setItem:Ut,removeItem:Ft,clear:Dt,length:Mt,key:Ot,keys:kt,dropInstance:$t},zt=function(r,t){return r===t||typeof r=="number"&&typeof t=="number"&&isNaN(r)&&isNaN(t)},Wt=function(r,t){for(var a=r.length,i=0;i<a;){if(zt(r[i],t))return!0;i++}return!1},qe=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},re={},He={},ee={INDEXEDDB:dt,WEBSQL:It,LOCALSTORAGE:Yt},qt=[ee.INDEXEDDB._driver,ee.WEBSQL._driver,ee.LOCALSTORAGE._driver],se=["dropInstance"],ye=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(se),Ht={description:"",driver:qt.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Qt(e,r){e[r]=function(){var t=arguments;return e.ready().then(function(){return e[r].apply(e,t)})}}function be(){for(var e=1;e<arguments.length;e++){var r=arguments[e];if(r)for(var t in r)r.hasOwnProperty(t)&&(qe(r[t])?arguments[0][t]=r[t].slice():arguments[0][t]=r[t])}return arguments[0]}var Kt=(function(){function e(r){E(this,e);for(var t in ee)if(ee.hasOwnProperty(t)){var a=ee[t],i=a._driver;this[t]=i,re[i]||this.defineDriver(a)}this._defaultConfig=be({},Ht),this._config=be({},this._defaultConfig,r),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return e.prototype.config=function(t){if((typeof t>"u"?"undefined":b(t))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var a in t){if(a==="storeName"&&(t[a]=t[a].replace(/\W/g,"_")),a==="version"&&typeof t[a]!="number")return new Error("Database version must be a number.");this._config[a]=t[a]}return"driver"in t&&t.driver?this.setDriver(this._config.driver):!0}else return typeof t=="string"?this._config[t]:this._config},e.prototype.defineDriver=function(t,a,i){var n=new c(function(s,u){try{var l=t._driver,d=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!t._driver){u(d);return}for(var v=ye.concat("_initStorage"),x=0,A=v.length;x<A;x++){var B=v[x],O=!Wt(se,B);if((O||t[B])&&typeof t[B]!="function"){u(d);return}}var $=function(){for(var ne=function(Zt){return function(){var Xt=new Error("Method "+Zt+" is not implemented by the current driver"),Qe=c.reject(Xt);return _(Qe,arguments[arguments.length-1]),Qe}},xe=0,Gt=se.length;xe<Gt;xe++){var we=se[xe];t[we]||(t[we]=ne(we))}};$();var U=function(ne){re[l]&&console.info("Redefining LocalForage driver: "+l),re[l]=t,He[l]=ne,s()};"_support"in t?t._support&&typeof t._support=="function"?t._support().then(U,u):U(!!t._support):U(!0)}catch(Q){u(Q)}});return F(n,a,i),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(t,a,i){var n=re[t]?c.resolve(re[t]):c.reject(new Error("Driver not found."));return F(n,a,i),n},e.prototype.getSerializer=function(t){var a=c.resolve(ge);return F(a,t),a},e.prototype.ready=function(t){var a=this,i=a._driverSet.then(function(){return a._ready===null&&(a._ready=a._initDriver()),a._ready});return F(i,t,t),i},e.prototype.setDriver=function(t,a,i){var n=this;qe(t)||(t=[t]);var s=this._getSupportedDrivers(t);function u(){n._config.driver=n.driver()}function l(x){return n._extend(x),u(),n._ready=n._initStorage(n._config),n._ready}function d(x){return function(){var A=0;function B(){for(;A<x.length;){var O=x[A];return A++,n._dbInfo=null,n._ready=null,n.getDriver(O).then(l).catch(B)}u();var $=new Error("No available storage method found.");return n._driverSet=c.reject($),n._driverSet}return B()}}var v=this._driverSet!==null?this._driverSet.catch(function(){return c.resolve()}):c.resolve();return this._driverSet=v.then(function(){var x=s[0];return n._dbInfo=null,n._ready=null,n.getDriver(x).then(function(A){n._driver=A._driver,u(),n._wrapLibraryMethodsWithReady(),n._initDriver=
1d(s)})}).catch(function(){u();var x=new Error("No available storage method found.");return n._driverSet=c.reject(x),n._driverSet}),F(this._driverSet,a,i),this._driverSet},e.prototype.supports=function(t){return!!He[t]},e.prototype._extend=function(t){be(this,t)},e.prototype._getSupportedDrivers=function(t){for(var a=[],i=0,n=t.length;i<n;i++){var s=t[i];this.supports(s)&&a.push(s)}return a},e.prototype._wrapLibraryMethodsWithReady=function(){for(var t=0,a=ye.length;t<a;t++)Qt(this,ye[t])},e.prototype.createInstance=function(t){return new e(t)},e})(),Vt=new Kt;m.exports=Vt},{3:3}]},{},[4])(4)})})(_e)),_e.exports}var mr=dr();const vr=Jt(mr),Ee=vr.createInstance({name:"pce-event-day",storeName:"receipt_photo_queue",description:"Queued meal receipt photos awaiting AI extraction (offline-tolerant upload)."});function Re(o){return`receipt-photo:${o}`}async function hr(o,h){const p={componentId:o,fileName:h.name,fileType:h.type,blob:h,queuedAt:new Date().toISOString(),status:"queued"};await Ee.setItem(Re(o),p)}function Ne(o){return Ee.getItem(Re(o))}async function Ze(o){await Ee.removeItem(Re(o))}function Se(o){return new File([o.blob],o.fileName,{type:o.fileType})}function pr(o,h){const{isOnline:p}=lr(),[m,y]=C.useState("idle"),[b,E]=C.useState(null),[w,N]=C.useState(null),S=C.useRef(!1),I=C.useRef(h);C.useEffect(()=>{I.current=h},[h]);const c=C.useCallback(async(D,T,P)=>{if(!S.current){S.current=!0,y(R=>R==="idle"?"uploading":"retrying"),E(null);try{const R=await le.extractFromFile(P,D);await Ze(P),y("uploaded"),N(T),I.current(R)}catch(R){y("failed"),E(ae(R))}finally{S.current=!1}}},[]);C.useEffect(()=>{if(!o)return;let D=!1;return(async()=>{const T=await Ne(o);!T||D||(N(T.fileName),navigator.onLine?await c(Se(T),T.fileName,o):y("queued"))})(),()=>{D=!0}},[o,c]),C.useEffect(()=>{if(!p||m!=="queued"||S.current||!o)return;const D=o;(async()=>{const T=await Ne(D);T&&await c(Se(T),T.fileName,D)})()},[p,m,o,c]);const _=C.useCallback(D=>{if(!o)return;const T=o;N(D.name),(async()=>(await hr(T,D),navigator.onLine?await c(D,D.name,T):y("queued")))()},[o,c]),F=C.useCallback(()=>{if(!o)return;const D=o;(async()=>{const T=await Ne(D);T&&await c(Se(T),T.fileName,D)})()},[o,c]),k=C.useCallback(()=>{y("idle"),E(null),N(null),o&&Ze(o)},[o]);return{status:m,errorMessage:b,fileName:w,capture:_,retry:F,reset:k}}function gr(o,h){const[p,m]=C.useState(null),[y,b]=C.useState(!0),[E,w]=C.useState(null),N=C.useRef(!1);return C.useEffect(()=>{if(!o||!h){b(!1);return}let S=!1;return(async()=>{b(!0);try{const I=await Je.getById(o,h);if(S)return;m(I),I.runStatus==="NotStarted"&&!N.current&&(N.current=!0,await yr(o,h,S,m))}catch(I){S||w(ae(I))}finally{S||b(!1)}})(),()=>{S=!0}},[o,h]),{component:p,isLoading:y,errorMessage:E}}async function yr(o,h,p,m){try{const y=await Je.updateRunStatus(o,h,"Started");p||m(y)}catch{}}function br(o){const[h,p]=C.useState(void 0),[m,y]=C.useState(Ve(o??"")),[b,E]=C.useState(!0),[w,N]=C.useState(null);return C.useEffect(()=>{if(!o){E(!1);return}let S=!1;return(async()=>{E(!0);try{const I=await le.getByComponent(o);if(S)return;p(I),y(I)}catch(I){if(S)return;p(void 0),y(Ve(o)),I?.status!==404&&N(ae(I))}finally{S||E(!1)}})(),()=>{S=!0}},[o]),{receipt:h,setReceipt:p,form:m,setForm:y,isLoadingReceipt:b,loadErrorMessage:w}}function xr(o){const{receipt:h,setReceipt:p,form:m,setForm:y,isLoadingReceipt:b,loadErrorMessage:E}=br(o),[w,N]=C.useState(!1),S=C.useCallback(P=>{const R=P.extractedReceipt;!R||!o||y(K=>({...R,eventComponentId:o,id:K.id,lines:ar(R.lines)}))},[o,y]),I=C.useCallback(P=>{y(R=>({...R,...P}))},[y]),c=C.useCallback((P,R)=>{y(K=>({...K,lines:K.lines.map((W,g)=>{if(g!==P)return W;const j={...W,...R};return("quantity"in R||"unitPrice"in R)&&(j.lineTotal=Ke(j.quantity*j.unitPrice)),j})}))},[y]),_=C.useCallback(()=>{y(P=>({...P,lines:[...P.lines,ir()]}))},[y]),F=C.useCallback(P=>{y(R=>({...R,lines:R.lines.filter((K,W)=>W!==P)}))},[y]),k=Ke(m.lines.reduce((P,R)=>P+R.lineTotal,0)),D=or(m.total,k),T=C.useCallback(async()=>{if(!o)return{ok:!1,message:"Missing component reference."};N(!0);try{const P={...m,serviceCharge:D.serviceCharge},R=h?.id?await le.update(o,P):await le.create(o,P);return p(R),y(R),{ok:!0,receipt:R}}catch(P){return{ok:!1,message:ae(P)}}finally{N(!1)}},[o,m,h?.id,D.serviceCharge,y,p]);return{form:m,hasExistingReceipt:!!h?.id,isLoadingReceipt:b,isSaving:w,loadErrorMessage:E,computedLineItemsTotal:k,serviceCharge:D.serviceCharge,serviceChargeClampedToZero:D.clampedToZero,applyExtracted:S,updateHeader:I,updateLine:c,addLine:_,removeLine:F,save:T}}function wr(o,h){const p=`/admin/event-day/${o}`;return`/members/events/${o}/components/${h}/tab?returnTo=${encodeURIComponent(p)}`}function _r({eventId:o,componentId:h,receiptForm:p,toast:m,navigate:y,setStep:b}){const[E,w]=C.useState(!1),N=C.useCallback(c=>{for(const _ of c.warnings??[])m.warning("Extraction warning",_);if(!c.extractedReceipt){m.error("Extraction failed","No receipt could be read from the photo.");return}p.applyExtracted(c),b("review")},[p,m,b]),S=C.useCallback(async()=>{const c=await p.save();if(!c.ok){m.error("Save failed",c.message);return}m.success("Receipt saved",c.receipt.serviceChargeClampedToZero?"Service charge was clamped to £0.00.":void 0),o&&y(`/admin/event-day/${o}`)},[p,m,y,o]),I=C.useCallback(async()=>
1{if(!o||!h){m.error("Could not confirm & notify","Missing event or component reference.");return}w(!0);try{const c=await p.save();if(!c.ok){m.error("Save failed",c.message);return}const _=await cr(h);m.success(`Meal confirmed & attendees notified - sent to ${_.sentCount} of ${_.totalEligible}`,_.failedCount>0||_.skippedCount>0?`${_.failedCount} failed, ${_.skippedCount} skipped`:void 0),y(wr(o,h))}catch(c){m.error("Could not confirm & notify",ae(c))}finally{w(!1)}},[o,h,p,m,y]);return{handleExtracted:N,handleSave:S,handleConfirmAndNotify:I,isConfirming:E}}function Nr(o){const[h,p]=C.useState([]);return C.useEffect(()=>{if(!o)return;let m=!1;return(async()=>{try{const y=await fr.getMenu(o);m||p(sr(y))}catch{m||p([])}})(),()=>{m=!0}},[o]),h}const Sr={idle:{tone:"bg-gray-50 text-gray-600 border-gray-200",text:"Take a photo of the venue receipt, or choose an existing one from your device."},uploading:{tone:"bg-blue-50 text-blue-700 border-blue-200",text:"Reading your receipt and extracting the items..."},queued:{tone:"bg-amber-50 text-amber-800 border-amber-200",text:"You're offline â the photo is saved and will upload automatically once you're back online."},retrying:{tone:"bg-blue-50 text-blue-700 border-blue-200",text:"Back online â retrying the upload..."},uploaded:{tone:"bg-green-50 text-green-800 border-green-200",text:"Receipt imported. Continue to review the items."},failed:{tone:"bg-red-50 text-red-800 border-red-200",text:"Could not read the receipt."}};function Er(){return f.jsxs("svg",{className:"h-5 w-5 flex-shrink-0 animate-spin text-blue-600",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[f.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),f.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 0 1 8-8v4a4 4 0 0 0-4 4H4z"})]})}function Rr({status:o,errorMessage:h,fileName:p,onRetry:m}){const y=Sr[o],b=o==="uploading"||o==="retrying";return f.jsxs("div",{className:`rounded-lg border p-4 text-sm ${y.tone}`,"aria-live":"polite","aria-busy":b,children:[f.jsxs("div",{className:"flex items-center gap-2",children:[b&&f.jsx(Er,{}),f.jsx("p",{children:y.text})]}),p&&o!=="idle"&&f.jsx("p",{className:"mt-1 text-xs opacity-75",children:p}),o==="failed"&&h&&f.jsx("p",{className:"mt-1 text-xs",children:h}),o==="failed"&&f.jsx("button",{type:"button",onClick:m,className:"mt-3 min-h-[44px] w-full rounded-lg border border-red-300 bg-white px-4 text-sm font-medium text-red-700 active:bg-red-50",children:"Retry upload"})]})}function Cr({status:o,errorMessage:h,fileName:p,hasExistingReceipt:m,onCapture:y,onRetry:b}){const E=C.useRef(null),w=C.useRef(null),N=o==="uploading"||o==="retrying",S=I=>{const c=I.target.files?.[0];c&&y(c),I.target.value=""};return f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"rounded-lg bg-white p-4 shadow",children:[f.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Photograph Receipt"}),f.jsx("p",{className:"mt-1 text-sm text-gray-600",children:"Capture the venue's itemised receipt, or pick an existing photo from your device. It's read automatically so you can review and edit the items next."})]}),f.jsx(Rr,{status:o,errorMessage:h,fileName:p,onRetry:b}),f.jsx("input",{ref:E,type:"file",accept:"image/*",capture:"environment",className:"hidden",onChange:S}),f.jsx("input",{ref:w,type:"file",accept:"image/*,application/pdf",className:"hidden",onChange:S}),f.jsx("button",{type:"button",onClick:()=>E.current?.click(),disabled:N,className:"min-h-[44px] w-full rounded-lg bg-amber-500 px-4 text-sm font-medium text-white active:bg-amber-600 disabled:opacity-40",children:p?"Retake Photo":"Take Photo"}),f.jsx("button",{type:"button",onClick:()=>w.current?.click(),disabled:N,className:"min-h-[44px] w-full rounded-lg border border-gray-300 bg-white px-4 text-sm font-medium text-gray-700 active:bg-gray-100 disabled:opacity-40",children:"Choose from Device"}),m&&f.jsx("p",{className:"text-center text-xs text-gray-500",children:"A receipt already exists for this meal â use Next below to review it, or replace the photo."})]})}const fe="mt-1 block min-h-[44px] w-full rounded-lg border border-gray-300 px-3 text-sm focus:border-amber-500 focus:ring-amber-500";function Ir(o,h){return o.unitPrice<=0||h&&o.matchConfidence!=="High"}function Tr({line:o,currency:h,onUpdate:p}){return f.jsxs(f.Fragment,{children:[f.jsxs("label",{className:"block text-xs font-medium text-gray-500",children:["Description",f.jsx("input",{type:"text",value:o.description,onChange:m=>{p({description:m.target.value})},className:fe})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("label",{className:"block text-xs font-medium text-gray-500",children:["Quantity",f.jsx("input",{type:"number",min:0,step:1,value:o.quantity,onChange:m=>{p({quantity:parseFloat(m.target.value)||0})},className:fe})]}),f.jsxs("label",{className:"block text-xs font-medium text-gray-500",children:["Unit price (",h,")",f.jsx("input",{type:"number",min:0,step:.
101,value:o.unitPrice,onChange:m=>{p({unitPrice:parseFloat(m.target.value)||0})},className:fe})]})]})]})}function Ar({line:o,menuItems:h,onUpdate:p}){return f.jsxs("label",{className:"block text-xs font-medium text-gray-500",children:["Menu item",f.jsxs("select",{value:o.menuItemId??"",onChange:m=>{const y=m.target.value||null;if(!y){p({menuItemId:null,menuItemName:null,matchConfidence:"None"});return}const b=h.find(E=>E.id===y);p({menuItemId:y,menuItemName:b?.name??null,matchConfidence:"High"})},className:fe,children:[f.jsx("option",{value:"",children:"Unmatched"}),o.menuItemId&&!h.some(m=>m.id===o.menuItemId)&&f.jsx("option",{value:o.menuItemId,children:o.menuItemName??"Current match"}),h.map(m=>f.jsx("option",{value:m.id,children:m.name},m.id))]})]})}function Lr({currency:o,lineTotal:h,onRemove:p}){return f.jsxs("div",{className:"flex items-center justify-between pt-1",children:[f.jsxs("span",{className:"text-sm font-semibold text-gray-900",children:["Line total: ",o," ",h.toFixed(2)]}),f.jsx("button",{type:"button",onClick:p,className:"min-h-[44px] rounded-lg border border-red-300 px-3 text-sm font-medium text-red-600 active:bg-red-50",children:"Remove"})]})}function jr({line:o,currency:h,menuItems:p,onUpdate:m,onRemove:y}){const b=p.length>0,E=Ir(o,b),w=E?"border-2 border-red-700 bg-red-50":"bg-white";return f.jsxs("div",{className:`space-y-3 rounded-lg p-4 shadow ${w}`,children:[E&&f.jsx("p",{className:"text-xs font-semibold text-red-700",children:"â Double-check this item"}),f.jsx(Tr,{line:o,currency:h,onUpdate:m}),b&&f.jsx(Ar,{line:o,menuItems:p,onUpdate:m}),f.jsx(Lr,{currency:h,lineTotal:o.lineTotal,onRemove:y})]})}function Dr({lines:o,currency:h,computedLineItemsTotal:p,menuItems:m,onUpdateLine:y,onRemoveLine:b,onAddLine:E}){return f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"rounded-lg bg-white p-4 shadow",children:[f.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Review Items"}),f.jsx("p",{className:"mt-1 text-sm text-gray-600",children:"Check the imported lines, and edit or add anything that's missing."})]}),o.length===0?f.jsx("div",{className:"rounded-lg border-2 border-dashed border-gray-200 bg-white p-6 text-center text-sm text-gray-500",children:"No line items yet. Add one below."}):f.jsx("div",{className:"space-y-3",children:o.map((w,N)=>f.jsx(jr,{line:w,currency:h,menuItems:m,onUpdate:S=>{y(N,S)},onRemove:()=>{b(N)}},w.id??w._uiKey??N))}),f.jsx("button",{type:"button",onClick:E,className:"min-h-[44px] w-full rounded-lg border border-gray-300 bg-white px-4 text-sm font-medium text-gray-700 active:bg-gray-100",children:"+ Add line"}),f.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-white p-4 shadow",children:[f.jsx("span",{className:"text-sm font-medium text-gray-600",children:"Items subtotal"}),f.jsxs("span",{className:"text-base font-semibold text-gray-900",children:[h," ",p.toFixed(2)]})]})]})}function Pr({currency:o,totalPaid:h,computedLineItemsTotal:p,serviceCharge:m,clampedToZero:y,onChangeTotalPaid:b}){const E=h-(p+m);return f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"rounded-lg bg-white p-4 shadow",children:[f.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Total Paid"}),f.jsx("p",{className:"mt-1 text-sm text-gray-600",children:"Enter what was actually paid at the venue â the service charge is worked out automatically."})]}),f.jsxs("label",{className:"block rounded-lg bg-white p-4 shadow",children:[f.jsxs("span",{className:"text-xs font-medium text-gray-500",children:["Total Paid (",o,")"]}),f.jsx("input",{type:"number",min:0,step:.01,value:h,onChange:w=>{b(parseFloat(w.target.value)||0)},className:"mt-1 block min-h-[44px] w-full rounded-lg border border-gray-300 px-3 text-lg font-semibold focus:border-amber-500 focus:ring-amber-500"})]}),f.jsxs("div",{className:"space-y-2 rounded-lg bg-white p-4 text-sm shadow",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-gray-600",children:"Items subtotal"}),f.jsxs("span",{className:"font-medium text-gray-900",children:[o," ",p.toFixed(2)]})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-gray-600",children:"Service charge (auto)"}),f.jsxs("span",{className:"font-medium text-gray-900",children:[o," ",m.toFixed(2)]})]})]}),y&&f.jsx(ur,{currency:o,computedLineItemsTotal:p,serviceCharge:m,total:h,computedDiscrepancy:E,clampedToZero:!0})]})}function Br({step:o,captureProps:h,reviewProps:p,totalProps:m}){return o==="capture"?f.jsx(Cr,{...h}):o==="review"?f.jsx(Dr,{...p}):f.jsx(Pr,{...m})}function Or(o){const{caption:h,amount:p,currency:m="GBP",primaryLabel:y,onPrimary:b,primaryDisabled:E,secondaryLabel:w,onSecondary:N,tertiaryLabel:S,onTertiary:I,tertiaryDisabled:c}=o;return f.jsx("div",{className:"fixed inset-x-0 bottom-0 z-20 border-t border-gray-200 bg-white shadow-[0_-2px_10px_rgba(0,0,0,0.08)]",children:f.jsxs("div",{className:"mx-auto flex max-w-2xl items-center justify-between gap-4 px-4 py-3",children:[f.jsxs("div",{className:"min-w-0",children:[h&&f.jsx("p",{className:"text-xs text-gray-500",children:h}),typeof p=="number"&&f.jsxs("p",{className:"truncate text-xl font-bold text-gray-900",children:[m," ",p.toFixed(2)]})]}),f.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center justify-end gap-2",children:[w&&N&&f.jsx("button",{type:"button",onClick:N,className:"min-h-[44px] rounded-lg border border-gray-300 px-4 text-sm font-medium text-gray-700 active:bg-gray-100",children:w}
1),S&&I&&f.jsx("button",{type:"button",onClick:I,disabled:c,className:"min-h-[44px] rounded-lg border border-blue-300 bg-blue-50 px-4 text-sm font-medium text-blue-700 active:bg-blue-100 disabled:opacity-40",children:S}),f.jsx("button",{type:"button",onClick:b,disabled:E,className:"min-h-[44px] rounded-lg bg-amber-500 px-5 text-sm font-medium text-white active:bg-amber-600 disabled:opacity-40",children:y})]})]})})}function kr(o){const{step:h,setStep:p,isUploadBusy:m,isSaving:y,currency:b,computedLineItemsTotal:E,totalPaid:w,onSave:N,onConfirmAndNotify:S,isConfirming:I}=o;return h==="capture"?{primaryLabel:"Next",onPrimary:()=>{p("review")},primaryDisabled:m}:h==="review"?{caption:"Items subtotal",amount:E,currency:b,primaryLabel:"Next",onPrimary:()=>{p("total")},secondaryLabel:"Back",onSecondary:()=>{p("capture")}}:{caption:"Total Paid",amount:w,currency:b,primaryLabel:y?"Saving...":"Save",onPrimary:N,primaryDisabled:y||I,secondaryLabel:"Back",onSecondary:()=>{p("review")},tertiaryLabel:I?"Confirming...":"Confirm & Notify",onTertiary:S,tertiaryDisabled:y||I}}function Mr(o,h){return{status:o.status,errorMessage:o.errorMessage,fileName:o.fileName,hasExistingReceipt:h,onCapture:o.capture,onRetry:o.retry}}function Fr(o,h){return{lines:o.form.lines,currency:o.form.currency,computedLineItemsTotal:o.computedLineItemsTotal,menuItems:h,onUpdateLine:o.updateLine,onRemoveLine:o.removeLine,onAddLine:o.addLine}}function Ur(o){return{currency:o.form.currency,totalPaid:o.form.total,computedLineItemsTotal:o.computedLineItemsTotal,serviceCharge:o.serviceCharge,clampedToZero:o.serviceChargeClampedToZero,onChangeTotalPaid:h=>{o.updateHeader({total:h})}}}function $r(){return f.jsx("div",{className:"p-4 text-sm text-gray-600",children:"Missing event or component reference."})}function Yr({eventId:o}){const h=Xe();return f.jsxs("button",{type:"button",onClick:()=>{h(`/admin/event-day/${o}`)},className:"inline-flex items-center gap-1 text-sm text-gray-600 active:text-gray-900",children:[f.jsx("span",{"aria-hidden":!0,children:"â"})," Back to cockpit"]})}function nn(){const{eventId:o,componentId:h}=er(),p=Xe(),m=tr(),[y,b]=C.useState("capture"),{component:E,isLoading:w}=gr(o,h),N=xr(h),S=Nr(h),{handleExtracted:I,handleSave:c,handleConfirmAndNotify:_,isConfirming:F}=_r({eventId:o,componentId:h,receiptForm:N,toast:m,navigate:p,setStep:b}),k=pr(h,I);if(!o||!h)return f.jsx($r,{});if(w||N.isLoadingReceipt)return f.jsx("div",{className:"flex h-full items-center justify-center p-4",children:f.jsx(nr,{message:"Loading receipt..."})});const D=kr({step:y,setStep:b,isUploadBusy:k.status==="uploading"||k.status==="retrying",isSaving:N.isSaving,currency:N.form.currency,computedLineItemsTotal:N.computedLineItemsTotal,totalPaid:N.form.total,onSave:()=>{c()},onConfirmAndNotify:()=>{_()},isConfirming:F});return f.jsxs("div",{className:"flex h-full flex-col bg-gray-50",children:[f.jsx(rr,{toasts:m.toasts,onRemove:m.removeToast}),f.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto p-4 pb-28",children:[f.jsx(Yr,{eventId:o}),E&&f.jsx("p",{className:"text-sm font-medium text-gray-500",children:E.name}),f.jsx(Br,{step:y,captureProps:Mr(k,N.hasExistingReceipt),reviewProps:Fr(N,S),totalProps:Ur(N)})]}),f.jsx(Or,{...D})]})}export{nn as default}; 2//# sourceMappingURL=MealReceiptPage-BoewUDls.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.