From c7066521ff4a2425a827dfbcd0b845d8813a6197 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Wed, 22 Jul 2026 14:06:56 +0000 Subject: [PATCH] Rework workforce sync to per-date storage with rolling window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the single workforce_rota config snapshot (which was overwritten on each sync, losing data when switching weeks) with a workforce_daily_shifts table keyed by date. Sync now covers a rolling today-7 to today+28 window unconditionally — no date params needed. Each date's record carries a synced_at timestamp so the UI shows the age of the oldest date in view. Mid-week viewing works naturally since data is stored per date not per week. source column reserved for future timesheet replacement of past dates. Co-Authored-By: Claude Sonnet 4.6 --- backend/src/db.js | 43 +++++++++ backend/src/routes/config.js | 4 +- backend/src/routes/workforce.js | 55 ++++++++--- frontend/dist/assets/index-BM62SqjA.js | 127 +++++++++++++++++++++++++ frontend/dist/assets/index-DOMhnWTP.js | 127 ------------------------- frontend/dist/index.html | 2 +- frontend/dist/sw.js | 2 +- frontend/src/api.ts | 11 ++- frontend/src/pages/Planner.tsx | 71 +++++++++----- frontend/src/types.ts | 14 +-- 10 files changed, 278 insertions(+), 178 deletions(-) create mode 100644 frontend/dist/assets/index-BM62SqjA.js delete mode 100644 frontend/dist/assets/index-DOMhnWTP.js diff --git a/backend/src/db.js b/backend/src/db.js index 1d096ca..dfe1993 100644 --- a/backend/src/db.js +++ b/backend/src/db.js @@ -10,6 +10,14 @@ export async function initDb() { value JSONB NOT NULL DEFAULT 'null'::jsonb ) `) + await pool.query(` + CREATE TABLE IF NOT EXISTS workforce_daily_shifts ( + date TEXT PRIMARY KEY, + synced_at TIMESTAMPTZ NOT NULL DEFAULT now(), + source TEXT NOT NULL DEFAULT 'workforce', + staff JSONB NOT NULL DEFAULT '[]'::jsonb + ) + `) } export async function getConfig(key, defaultVal = null) { @@ -24,3 +32,38 @@ export async function setConfig(key, value) { [key, JSON.stringify(value)] ) } + +export async function getWorkforceShifts(start, end) { + const { rows } = await pool.query( + `SELECT date, synced_at, source, staff FROM workforce_daily_shifts + WHERE date >= $1 AND date <= $2 ORDER BY date`, + [start, end] + ) + const result = {} + for (const row of rows) { + result[row.date] = { synced_at: row.synced_at, source: row.source, staff: row.staff } + } + return result +} + +export async function upsertWorkforceShifts(dailyRows) { + if (!dailyRows.length) return + const client = await pool.connect() + try { + await client.query('BEGIN') + for (const row of dailyRows) { + await client.query( + `INSERT INTO workforce_daily_shifts (date, synced_at, source, staff) + VALUES ($1, now(), 'workforce', $2::jsonb) + ON CONFLICT (date) DO UPDATE SET synced_at = now(), staff = EXCLUDED.staff`, + [row.date, JSON.stringify(row.staff)] + ) + } + await client.query('COMMIT') + } catch (err) { + await client.query('ROLLBACK') + throw err + } finally { + client.release() + } +} diff --git a/backend/src/routes/config.js b/backend/src/routes/config.js index 3a1004c..c5a9850 100644 --- a/backend/src/routes/config.js +++ b/backend/src/routes/config.js @@ -10,7 +10,7 @@ export async function configRoutes(app) { app.get('/api/config', async (req) => { const [ timeReqs, staffData, pickupData, generalTasks, lastReviewed, - workforceRota, workforceDepts, adjustments, + workforceDepts, adjustments, warnOverRed, warnOverAmber, warnUnderAmber, warnUnderRed, ] = await Promise.all([ getConfig('time_requirements', {}), @@ -18,7 +18,6 @@ export async function configRoutes(app) { getConfig('pickup_data', {}), getConfig('general_tasks', []), getConfig('last_reviewed', null), - getConfig('workforce_rota', null), getConfig('workforce_departments', []), getConfig('adjustments', []), getConfig('warn_over_red_hrs', 4), @@ -39,7 +38,6 @@ export async function configRoutes(app) { pickup_data: pickupData || {}, general_tasks: generalTasks || [], last_reviewed: lastReviewed || yestStr, - workforce_rota: workforceRota || null, workforce_departments: workforceDepts || [], adjustments: adjustments || [], warn_over_red_hrs: warnOverRed != null ? warnOverRed : 4, diff --git a/backend/src/routes/workforce.js b/backend/src/routes/workforce.js index 67841bd..8cff1b6 100644 --- a/backend/src/routes/workforce.js +++ b/backend/src/routes/workforce.js @@ -1,11 +1,15 @@ import { requireAuth, requireCap } from '../auth.js' -import { getConfig, setConfig } from '../db.js' +import { getConfig, setConfig, getWorkforceShifts, upsertWorkforceShifts } from '../db.js' import { fetchDepartments, fetchStaff, fetchShifts } from '../lib/workforce.js' +function fmtDate(d) { + return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}` +} + export async function workforceRoutes(app) { app.addHook('preHandler', requireAuth) - // ── GET /api/workforce/departments — list depts for this location ──────────── + // ── GET /api/workforce/departments ─────────────────────────────────────────── app.get('/api/workforce/departments', { preHandler: requireCap('settings') }, async (req, reply) => { try { @@ -16,29 +20,58 @@ export async function workforceRoutes(app) { } }) - // ── POST /api/workforce/sync?start=&end= ───────────────────────────────────── + // ── POST /api/workforce/sync — rolling window: today-7 → today+28 ─────────── app.post('/api/workforce/sync', { preHandler: requireCap('planner') }, async (req, reply) => { - const { start, end } = req.query - if (!start || !end) return reply.status(400).send({ error: 'start and end query params required' }) - const deptIds = (await getConfig('workforce_departments', [])) || [] if (!deptIds.length) { return reply.status(400).send({ error: 'No HK departments selected — configure in Category Settings' }) } + const today = new Date() + const fromDate = new Date(today); fromDate.setDate(fromDate.getDate() - 7) + const toDate = new Date(today); toDate.setDate(toDate.getDate() + 28) + const from = fmtDate(fromDate) + const to = fmtDate(toDate) + try { - const staff = await fetchShifts(start, end, deptIds) - const snapshot = { last_sync: new Date().toISOString(), dates: [start, end], staff } - await setConfig('workforce_rota', snapshot) - return snapshot + const staffList = await fetchShifts(from, to, deptIds) + + // Pivot per-member → per-date + const byDate = {} + for (const member of staffList) { + for (const [date, shift] of Object.entries(member.days)) { + if (!byDate[date]) byDate[date] = [] + byDate[date].push({ id: member.id, name: member.name, hours: shift.hours, times: shift.times }) + } + } + + // Build a row for every date in the window (empty staff = no one scheduled) + const dailyRows = [] + const cur = new Date(fromDate) + while (cur <= toDate) { + const d = fmtDate(cur) + dailyRows.push({ date: d, staff: byDate[d] || [] }) + cur.setDate(cur.getDate() + 1) + } + + await upsertWorkforceShifts(dailyRows) + return { ok: true, from, to, dates_synced: dailyRows.length } } catch (err) { const status = err.message.includes('not configured') ? 503 : 502 return reply.status(status).send({ error: err.message }) } }) - // ── GET /api/workforce/staff — staff list for manual row datalist ───────────── + // ── GET /api/workforce/shifts?start=&end= ──────────────────────────────────── + + app.get('/api/workforce/shifts', { preHandler: requireCap('planner') }, async (req, reply) => { + const { start, end } = req.query + if (!start || !end) return reply.status(400).send({ error: 'start and end query params required' }) + return getWorkforceShifts(start, end) + }) + + // ── GET /api/workforce/staff — cached staff list for manual row datalist ───── app.get('/api/workforce/staff', { preHandler: requireCap('planner') }, async (req, reply) => { const deptIds = (await getConfig('workforce_departments', [])) || [] diff --git a/frontend/dist/assets/index-BM62SqjA.js b/frontend/dist/assets/index-BM62SqjA.js new file mode 100644 index 0000000..f3a03cd --- /dev/null +++ b/frontend/dist/assets/index-BM62SqjA.js @@ -0,0 +1,127 @@ +function Zf(i,u){for(var s=0;sd[p]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}(function(){const u=document.createElement("link").relList;if(u&&u.supports&&u.supports("modulepreload"))return;for(const p of document.querySelectorAll('link[rel="modulepreload"]'))d(p);new MutationObserver(p=>{for(const h of p)if(h.type==="childList")for(const g of h.addedNodes)g.tagName==="LINK"&&g.rel==="modulepreload"&&d(g)}).observe(document,{childList:!0,subtree:!0});function s(p){const h={};return p.integrity&&(h.integrity=p.integrity),p.referrerPolicy&&(h.referrerPolicy=p.referrerPolicy),p.crossOrigin==="use-credentials"?h.credentials="include":p.crossOrigin==="anonymous"?h.credentials="omit":h.credentials="same-origin",h}function d(p){if(p.ep)return;p.ep=!0;const h=s(p);fetch(p.href,h)}})();function qf(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var hs={exports:{}},ll={},ms={exports:{}},ue={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var mc;function bf(){if(mc)return ue;mc=1;var i=Symbol.for("react.element"),u=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),d=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),h=Symbol.for("react.provider"),g=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),_=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),N=Symbol.iterator;function M(y){return y===null||typeof y!="object"?null:(y=N&&y[N]||y["@@iterator"],typeof y=="function"?y:null)}var H={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},K=Object.assign,T={};function E(y,R,ee){this.props=y,this.context=R,this.refs=T,this.updater=ee||H}E.prototype.isReactComponent={},E.prototype.setState=function(y,R){if(typeof y!="object"&&typeof y!="function"&&y!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,y,R,"setState")},E.prototype.forceUpdate=function(y){this.updater.enqueueForceUpdate(this,y,"forceUpdate")};function A(){}A.prototype=E.prototype;function $(y,R,ee){this.props=y,this.context=R,this.refs=T,this.updater=ee||H}var G=$.prototype=new A;G.constructor=$,K(G,E.prototype),G.isPureReactComponent=!0;var U=Array.isArray,ce=Object.prototype.hasOwnProperty,de={current:null},Ce={key:!0,ref:!0,__self:!0,__source:!0};function xe(y,R,ee){var re,le={},oe=null,ae=null;if(R!=null)for(re in R.ref!==void 0&&(ae=R.ref),R.key!==void 0&&(oe=""+R.key),R)ce.call(R,re)&&!Ce.hasOwnProperty(re)&&(le[re]=R[re]);var se=arguments.length-2;if(se===1)le.children=ee;else if(1>>1,R=W[y];if(0>>1;yp(le,F))oep(ae,le)?(W[y]=ae,W[oe]=F,y=oe):(W[y]=le,W[re]=F,y=re);else if(oep(ae,F))W[y]=ae,W[oe]=F,y=oe;else break e}}return X}function p(W,X){var F=W.sortIndex-X.sortIndex;return F!==0?F:W.id-X.id}if(typeof performance=="object"&&typeof performance.now=="function"){var h=performance;i.unstable_now=function(){return h.now()}}else{var g=Date,j=g.now();i.unstable_now=function(){return g.now()-j}}var w=[],_=[],P=1,N=null,M=3,H=!1,K=!1,T=!1,E=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,$=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function G(W){for(var X=s(_);X!==null;){if(X.callback===null)d(_);else if(X.startTime<=W)d(_),X.sortIndex=X.expirationTime,u(w,X);else break;X=s(_)}}function U(W){if(T=!1,G(W),!K)if(s(w)!==null)K=!0,Oe(ce);else{var X=s(_);X!==null&&ve(U,X.startTime-W)}}function ce(W,X){K=!1,T&&(T=!1,A(xe),xe=-1),H=!0;var F=M;try{for(G(X),N=s(w);N!==null&&(!(N.expirationTime>X)||W&&!Ke());){var y=N.callback;if(typeof y=="function"){N.callback=null,M=N.priorityLevel;var R=y(N.expirationTime<=X);X=i.unstable_now(),typeof R=="function"?N.callback=R:N===s(w)&&d(w),G(X)}else d(w);N=s(w)}if(N!==null)var ee=!0;else{var re=s(_);re!==null&&ve(U,re.startTime-X),ee=!1}return ee}finally{N=null,M=F,H=!1}}var de=!1,Ce=null,xe=-1,Ze=5,Ie=-1;function Ke(){return!(i.unstable_now()-IeW||125y?(W.sortIndex=F,u(_,W),s(w)===null&&W===s(_)&&(T?(A(xe),xe=-1):T=!0,ve(U,F-y))):(W.sortIndex=R,u(w,W),K||H||(K=!0,Oe(ce))),W},i.unstable_shouldYield=Ke,i.unstable_wrapCallback=function(W){var X=M;return function(){var F=M;M=X;try{return W.apply(this,arguments)}finally{M=F}}}})(ys)),ys}var wc;function op(){return wc||(wc=1,gs.exports=lp()),gs.exports}/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var kc;function ip(){if(kc)return dt;kc=1;var i=Ps(),u=op();function s(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),w=Object.prototype.hasOwnProperty,_=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,P={},N={};function M(e){return w.call(N,e)?!0:w.call(P,e)?!1:_.test(e)?N[e]=!0:(P[e]=!0,!1)}function H(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function K(e,t,n,r){if(t===null||typeof t>"u"||H(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function T(e,t,n,r,l,o,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=a}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){E[e]=new T(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];E[t]=new T(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){E[e]=new T(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){E[e]=new T(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){E[e]=new T(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){E[e]=new T(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){E[e]=new T(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){E[e]=new T(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){E[e]=new T(e,5,!1,e.toLowerCase(),null,!1,!1)});var A=/[\-:]([a-z])/g;function $(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(A,$);E[t]=new T(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(A,$);E[t]=new T(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(A,$);E[t]=new T(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){E[e]=new T(e,1,!1,e.toLowerCase(),null,!1,!1)}),E.xlinkHref=new T("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){E[e]=new T(e,1,!1,e.toLowerCase(),null,!0,!0)});function G(e,t,n,r){var l=E.hasOwnProperty(t)?E[t]:null;(l!==null?l.type!==0:r||!(2f||l[a]!==o[f]){var m=` +`+l[a].replace(" at new "," at ");return e.displayName&&m.includes("")&&(m=m.replace("",e.displayName)),m}while(1<=a&&0<=f);break}}}finally{ee=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?R(e):""}function le(e){switch(e.tag){case 5:return R(e.type);case 16:return R("Lazy");case 13:return R("Suspense");case 19:return R("SuspenseList");case 0:case 2:case 15:return e=re(e.type,!1),e;case 11:return e=re(e.type.render,!1),e;case 1:return e=re(e.type,!0),e;default:return""}}function oe(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Ce:return"Fragment";case de:return"Portal";case Ze:return"Profiler";case xe:return"StrictMode";case Te:return"Suspense";case Be:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Ke:return(e.displayName||"Context")+".Consumer";case Ie:return(e._context.displayName||"Context")+".Provider";case Ee:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case qe:return t=e.displayName||null,t!==null?t:oe(e.type)||"Memo";case Oe:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}function ae(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return oe(t);case 8:return t===xe?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function se(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function fe(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function We(e){var t=fe(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(a){r=""+a,o.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function At(e){e._valueTracker||(e._valueTracker=We(e))}function En(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=fe(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function $t(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Vt(e,t){var n=t.checked;return F({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function _n(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=se(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function en(e,t){t=t.checked,t!=null&&G(e,"checked",t,!1)}function Ht(e,t){en(e,t);var n=se(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?tn(e,t.type,n):t.hasOwnProperty("defaultValue")&&tn(e,t.type,se(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Nn(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function tn(e,t,n){(t!=="number"||$t(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var _t=Array.isArray;function Dt(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=pt.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function we(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var yt={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Tn=["Webkit","ms","Moz","O"];Object.keys(yt).forEach(function(e){Tn.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),yt[t]=yt[e]})});function Vn(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||yt.hasOwnProperty(e)&&yt[e]?(""+t).trim():t+"px"}function I(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Vn(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var te=F({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ie(e,t){if(t){if(te[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(s(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(s(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(s(61))}if(t.style!=null&&typeof t.style!="object")throw Error(s(62))}}function De(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var xt=null;function kr(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ro=null,Hn=null,Qn=null;function Ls(e){if(e=Vr(e)){if(typeof Ro!="function")throw Error(s(280));var t=e.stateNode;t&&(t=Ol(t),Ro(e.stateNode,e.type,t))}}function Os(e){Hn?Qn?Qn.push(e):Qn=[e]:Hn=e}function Ds(){if(Hn){var e=Hn,t=Qn;if(Qn=Hn=null,Ls(e),t)for(e=0;e>>=0,e===0?32:31-(fd(e)/pd|0)|0}var ml=64,vl=4194304;function Er(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function gl(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,o=e.pingedLanes,a=n&268435455;if(a!==0){var f=a&~l;f!==0?r=Er(f):(o&=a,o!==0&&(r=Er(o)))}else a=n&~l,a!==0?r=Er(a):o!==0&&(r=Er(o));if(r===0)return 0;if(t!==0&&t!==r&&(t&l)===0&&(l=r&-r,o=t&-t,l>=o||l===16&&(o&4194240)!==0))return t;if((r&4)!==0&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function _r(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Nt(t),e[t]=n}function gd(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Dr),aa=" ",ua=!1;function ca(e,t){switch(e){case"keyup":return Qd.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function da(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Jn=!1;function Yd(e,t){switch(e){case"compositionend":return da(t);case"keypress":return t.which!==32?null:(ua=!0,aa);case"textInput":return e=t.data,e===aa&&ua?null:e;default:return null}}function Jd(e,t){if(Jn)return e==="compositionend"||!Jo&&ca(e,t)?(e=na(),Sl=$o=sn=null,Jn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=ya(n)}}function wa(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?wa(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ka(){for(var e=window,t=$t();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=$t(e.document)}return t}function Zo(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function rf(e){var t=ka(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&wa(n.ownerDocument.documentElement,n)){if(r!==null&&Zo(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,o=Math.min(r.start,l);r=r.end===void 0?o:Math.min(r.end,l),!e.extend&&o>r&&(l=r,r=o,o=l),l=xa(n,o);var a=xa(n,r);l&&a&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Gn=null,qo=null,Fr=null,bo=!1;function Sa(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;bo||Gn==null||Gn!==$t(r)||(r=Gn,"selectionStart"in r&&Zo(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Fr&&Wr(Fr,r)||(Fr=r,r=Rl(qo,"onSelect"),0er||(e.current=di[er],di[er]=null,er--)}function ye(e,t){er++,di[er]=e.current,e.current=t}var dn={},be=cn(dn),it=cn(!1),Ln=dn;function tr(e,t){var n=e.type.contextTypes;if(!n)return dn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},o;for(o in n)l[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function st(e){return e=e.childContextTypes,e!=null}function Dl(){Se(it),Se(be)}function Wa(e,t,n){if(be.current!==dn)throw Error(s(168));ye(be,t),ye(it,n)}function Fa(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(s(108,ae(e)||"Unknown",l));return F({},n,r)}function Ml(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||dn,Ln=be.current,ye(be,e),ye(it,it.current),!0}function Ua(e,t,n){var r=e.stateNode;if(!r)throw Error(s(169));n?(e=Fa(e,t,Ln),r.__reactInternalMemoizedMergedChildContext=e,Se(it),Se(be),ye(be,e)):Se(it),ye(it,n)}var Kt=null,Il=!1,fi=!1;function Ba(e){Kt===null?Kt=[e]:Kt.push(e)}function vf(e){Il=!0,Ba(e)}function fn(){if(!fi&&Kt!==null){fi=!0;var e=0,t=ge;try{var n=Kt;for(ge=1;e>=a,l-=a,Yt=1<<32-Nt(t)+l|n<b?(Qe=q,q=null):Qe=q.sibling;var he=z(x,q,k[b],D);if(he===null){q===null&&(q=Qe);break}e&&q&&he.alternate===null&&t(x,q),v=o(he,v,b),Z===null?J=he:Z.sibling=he,Z=he,q=Qe}if(b===k.length)return n(x,q),je&&Dn(x,b),J;if(q===null){for(;bb?(Qe=q,q=null):Qe=q.sibling;var kn=z(x,q,he.value,D);if(kn===null){q===null&&(q=Qe);break}e&&q&&kn.alternate===null&&t(x,q),v=o(kn,v,b),Z===null?J=kn:Z.sibling=kn,Z=kn,q=Qe}if(he.done)return n(x,q),je&&Dn(x,b),J;if(q===null){for(;!he.done;b++,he=k.next())he=O(x,he.value,D),he!==null&&(v=o(he,v,b),Z===null?J=he:Z.sibling=he,Z=he);return je&&Dn(x,b),J}for(q=r(x,q);!he.done;b++,he=k.next())he=B(q,x,b,he.value,D),he!==null&&(e&&he.alternate!==null&&q.delete(he.key===null?b:he.key),v=o(he,v,b),Z===null?J=he:Z.sibling=he,Z=he);return e&&q.forEach(function(Xf){return t(x,Xf)}),je&&Dn(x,b),J}function Le(x,v,k,D){if(typeof k=="object"&&k!==null&&k.type===Ce&&k.key===null&&(k=k.props.children),typeof k=="object"&&k!==null){switch(k.$$typeof){case ce:e:{for(var J=k.key,Z=v;Z!==null;){if(Z.key===J){if(J=k.type,J===Ce){if(Z.tag===7){n(x,Z.sibling),v=l(Z,k.props.children),v.return=x,x=v;break e}}else if(Z.elementType===J||typeof J=="object"&&J!==null&&J.$$typeof===Oe&&Ka(J)===Z.type){n(x,Z.sibling),v=l(Z,k.props),v.ref=Hr(x,Z,k),v.return=x,x=v;break e}n(x,Z);break}else t(x,Z);Z=Z.sibling}k.type===Ce?(v=$n(k.props.children,x.mode,D,k.key),v.return=x,x=v):(D=co(k.type,k.key,k.props,null,x.mode,D),D.ref=Hr(x,v,k),D.return=x,x=D)}return a(x);case de:e:{for(Z=k.key;v!==null;){if(v.key===Z)if(v.tag===4&&v.stateNode.containerInfo===k.containerInfo&&v.stateNode.implementation===k.implementation){n(x,v.sibling),v=l(v,k.children||[]),v.return=x,x=v;break e}else{n(x,v);break}else t(x,v);v=v.sibling}v=us(k,x.mode,D),v.return=x,x=v}return a(x);case Oe:return Z=k._init,Le(x,v,Z(k._payload),D)}if(_t(k))return Q(x,v,k,D);if(X(k))return Y(x,v,k,D);Bl(x,k)}return typeof k=="string"&&k!==""||typeof k=="number"?(k=""+k,v!==null&&v.tag===6?(n(x,v.sibling),v=l(v,k),v.return=x,x=v):(n(x,v),v=as(k,x.mode,D),v.return=x,x=v),a(x)):n(x,v)}return Le}var or=Ya(!0),Ja=Ya(!1),Al=cn(null),$l=null,ir=null,yi=null;function xi(){yi=ir=$l=null}function wi(e){var t=Al.current;Se(Al),e._currentValue=t}function ki(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function sr(e,t){$l=e,yi=ir=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(at=!0),e.firstContext=null)}function St(e){var t=e._currentValue;if(yi!==e)if(e={context:e,memoizedValue:t,next:null},ir===null){if($l===null)throw Error(s(308));ir=e,$l.dependencies={lanes:0,firstContext:e}}else ir=ir.next=e;return t}var Mn=null;function Si(e){Mn===null?Mn=[e]:Mn.push(e)}function Ga(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Si(t)):(n.next=l.next,l.next=n),t.interleaved=n,Gt(e,r)}function Gt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var pn=!1;function ji(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Xa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Xt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function hn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,(pe&2)!==0){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,Gt(e,n)}return l=r.interleaved,l===null?(t.next=t,Si(r)):(t.next=l.next,l.next=t),r.interleaved=t,Gt(e,n)}function Vl(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Wo(e,n)}}function Za(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?l=o=a:o=o.next=a,n=n.next}while(n!==null);o===null?l=o=t:o=o.next=t}else l=o=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Hl(e,t,n,r){var l=e.updateQueue;pn=!1;var o=l.firstBaseUpdate,a=l.lastBaseUpdate,f=l.shared.pending;if(f!==null){l.shared.pending=null;var m=f,C=m.next;m.next=null,a===null?o=C:a.next=C,a=m;var L=e.alternate;L!==null&&(L=L.updateQueue,f=L.lastBaseUpdate,f!==a&&(f===null?L.firstBaseUpdate=C:f.next=C,L.lastBaseUpdate=m))}if(o!==null){var O=l.baseState;a=0,L=C=m=null,f=o;do{var z=f.lane,B=f.eventTime;if((r&z)===z){L!==null&&(L=L.next={eventTime:B,lane:0,tag:f.tag,payload:f.payload,callback:f.callback,next:null});e:{var Q=e,Y=f;switch(z=t,B=n,Y.tag){case 1:if(Q=Y.payload,typeof Q=="function"){O=Q.call(B,O,z);break e}O=Q;break e;case 3:Q.flags=Q.flags&-65537|128;case 0:if(Q=Y.payload,z=typeof Q=="function"?Q.call(B,O,z):Q,z==null)break e;O=F({},O,z);break e;case 2:pn=!0}}f.callback!==null&&f.lane!==0&&(e.flags|=64,z=l.effects,z===null?l.effects=[f]:z.push(f))}else B={eventTime:B,lane:z,tag:f.tag,payload:f.payload,callback:f.callback,next:null},L===null?(C=L=B,m=O):L=L.next=B,a|=z;if(f=f.next,f===null){if(f=l.shared.pending,f===null)break;z=f,f=z.next,z.next=null,l.lastBaseUpdate=z,l.shared.pending=null}}while(!0);if(L===null&&(m=O),l.baseState=m,l.firstBaseUpdate=C,l.lastBaseUpdate=L,t=l.shared.interleaved,t!==null){l=t;do a|=l.lane,l=l.next;while(l!==t)}else o===null&&(l.shared.lanes=0);Fn|=a,e.lanes=a,e.memoizedState=O}}function qa(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Pi.transition;Pi.transition={};try{e(!1),t()}finally{ge=n,Pi.transition=r}}function gu(){return jt().memoizedState}function wf(e,t,n){var r=yn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},yu(e))xu(t,n);else if(n=Ga(e,t,n,r),n!==null){var l=ot();Ot(n,e,r,l),wu(n,t,r)}}function kf(e,t,n){var r=yn(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(yu(e))xu(t,l);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var a=t.lastRenderedState,f=o(a,n);if(l.hasEagerState=!0,l.eagerState=f,Pt(f,a)){var m=t.interleaved;m===null?(l.next=l,Si(t)):(l.next=m.next,m.next=l),t.interleaved=l;return}}catch{}finally{}n=Ga(e,t,l,r),n!==null&&(l=ot(),Ot(n,e,r,l),wu(n,t,r))}}function yu(e){var t=e.alternate;return e===Ne||t!==null&&t===Ne}function xu(e,t){Jr=Yl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function wu(e,t,n){if((n&4194240)!==0){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Wo(e,n)}}var Xl={readContext:St,useCallback:et,useContext:et,useEffect:et,useImperativeHandle:et,useInsertionEffect:et,useLayoutEffect:et,useMemo:et,useReducer:et,useRef:et,useState:et,useDebugValue:et,useDeferredValue:et,useTransition:et,useMutableSource:et,useSyncExternalStore:et,useId:et,unstable_isNewReconciler:!1},Sf={readContext:St,useCallback:function(e,t){return Ft().memoizedState=[e,t===void 0?null:t],e},useContext:St,useEffect:uu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Jl(4194308,4,fu.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Jl(4194308,4,e,t)},useInsertionEffect:function(e,t){return Jl(4,2,e,t)},useMemo:function(e,t){var n=Ft();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Ft();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=wf.bind(null,Ne,e),[r.memoizedState,e]},useRef:function(e){var t=Ft();return e={current:e},t.memoizedState=e},useState:su,useDebugValue:Mi,useDeferredValue:function(e){return Ft().memoizedState=e},useTransition:function(){var e=su(!1),t=e[0];return e=xf.bind(null,e[1]),Ft().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Ne,l=Ft();if(je){if(n===void 0)throw Error(s(407));n=n()}else{if(n=t(),He===null)throw Error(s(349));(Wn&30)!==0||nu(r,t,n)}l.memoizedState=n;var o={value:n,getSnapshot:t};return l.queue=o,uu(lu.bind(null,r,o,e),[e]),r.flags|=2048,Zr(9,ru.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Ft(),t=He.identifierPrefix;if(je){var n=Jt,r=Yt;n=(r&~(1<<32-Nt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Gr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=a.createElement(n,{is:r.is}):(e=a.createElement(n),n==="select"&&(a=e,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):e=a.createElementNS(e,n),e[It]=t,e[$r]=r,Bu(e,t,!1,!1),t.stateNode=e;e:{switch(a=De(n,r),n){case"dialog":ke("cancel",e),ke("close",e),l=r;break;case"iframe":case"object":case"embed":ke("load",e),l=r;break;case"video":case"audio":for(l=0;lfr&&(t.flags|=128,r=!0,qr(o,!1),t.lanes=4194304)}else{if(!r)if(e=Ql(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),qr(o,!0),o.tail===null&&o.tailMode==="hidden"&&!a.alternate&&!je)return tt(t),null}else 2*ze()-o.renderingStartTime>fr&&n!==1073741824&&(t.flags|=128,r=!0,qr(o,!1),t.lanes=4194304);o.isBackwards?(a.sibling=t.child,t.child=a):(n=o.last,n!==null?n.sibling=a:t.child=a,o.last=a)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=ze(),t.sibling=null,n=_e.current,ye(_e,r?n&1|2:n&1),t):(tt(t),null);case 22:case 23:return os(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&(t.mode&1)!==0?(gt&1073741824)!==0&&(tt(t),t.subtreeFlags&6&&(t.flags|=8192)):tt(t),null;case 24:return null;case 25:return null}throw Error(s(156,t.tag))}function Rf(e,t){switch(hi(t),t.tag){case 1:return st(t.type)&&Dl(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ar(),Se(it),Se(be),Ni(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return Ei(t),null;case 13:if(Se(_e),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(s(340));lr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Se(_e),null;case 4:return ar(),null;case 10:return wi(t.type._context),null;case 22:case 23:return os(),null;case 24:return null;default:return null}}var eo=!1,nt=!1,zf=typeof WeakSet=="function"?WeakSet:Set,V=null;function cr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Re(e,t,r)}else n.current=null}function Yi(e,t,n){try{n()}catch(r){Re(e,t,r)}}var Vu=!1;function Lf(e,t){if(oi=wl,e=ka(),Zo(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var a=0,f=-1,m=-1,C=0,L=0,O=e,z=null;t:for(;;){for(var B;O!==n||l!==0&&O.nodeType!==3||(f=a+l),O!==o||r!==0&&O.nodeType!==3||(m=a+r),O.nodeType===3&&(a+=O.nodeValue.length),(B=O.firstChild)!==null;)z=O,O=B;for(;;){if(O===e)break t;if(z===n&&++C===l&&(f=a),z===o&&++L===r&&(m=a),(B=O.nextSibling)!==null)break;O=z,z=O.parentNode}O=B}n=f===-1||m===-1?null:{start:f,end:m}}else n=null}n=n||{start:0,end:0}}else n=null;for(ii={focusedElem:e,selectionRange:n},wl=!1,V=t;V!==null;)if(t=V,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,V=e;else for(;V!==null;){t=V;try{var Q=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(Q!==null){var Y=Q.memoizedProps,Le=Q.memoizedState,x=t.stateNode,v=x.getSnapshotBeforeUpdate(t.elementType===t.type?Y:Rt(t.type,Y),Le);x.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var k=t.stateNode.containerInfo;k.nodeType===1?k.textContent="":k.nodeType===9&&k.documentElement&&k.removeChild(k.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(D){Re(t,t.return,D)}if(e=t.sibling,e!==null){e.return=t.return,V=e;break}V=t.return}return Q=Vu,Vu=!1,Q}function br(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var o=l.destroy;l.destroy=void 0,o!==void 0&&Yi(t,n,o)}l=l.next}while(l!==r)}}function to(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Ji(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Hu(e){var t=e.alternate;t!==null&&(e.alternate=null,Hu(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[It],delete t[$r],delete t[ci],delete t[hf],delete t[mf])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Qu(e){return e.tag===5||e.tag===3||e.tag===4}function Ku(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Qu(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Gi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ll));else if(r!==4&&(e=e.child,e!==null))for(Gi(e,t,n),e=e.sibling;e!==null;)Gi(e,t,n),e=e.sibling}function Xi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Xi(e,t,n),e=e.sibling;e!==null;)Xi(e,t,n),e=e.sibling}var Ye=null,zt=!1;function mn(e,t,n){for(n=n.child;n!==null;)Yu(e,t,n),n=n.sibling}function Yu(e,t,n){if(Mt&&typeof Mt.onCommitFiberUnmount=="function")try{Mt.onCommitFiberUnmount(hl,n)}catch{}switch(n.tag){case 5:nt||cr(n,t);case 6:var r=Ye,l=zt;Ye=null,mn(e,t,n),Ye=r,zt=l,Ye!==null&&(zt?(e=Ye,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ye.removeChild(n.stateNode));break;case 18:Ye!==null&&(zt?(e=Ye,n=n.stateNode,e.nodeType===8?ui(e.parentNode,n):e.nodeType===1&&ui(e,n),zr(e)):ui(Ye,n.stateNode));break;case 4:r=Ye,l=zt,Ye=n.stateNode.containerInfo,zt=!0,mn(e,t,n),Ye=r,zt=l;break;case 0:case 11:case 14:case 15:if(!nt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var o=l,a=o.destroy;o=o.tag,a!==void 0&&((o&2)!==0||(o&4)!==0)&&Yi(n,t,a),l=l.next}while(l!==r)}mn(e,t,n);break;case 1:if(!nt&&(cr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(f){Re(n,t,f)}mn(e,t,n);break;case 21:mn(e,t,n);break;case 22:n.mode&1?(nt=(r=nt)||n.memoizedState!==null,mn(e,t,n),nt=r):mn(e,t,n);break;default:mn(e,t,n)}}function Ju(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new zf),t.forEach(function(r){var l=Af.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Lt(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=a),r&=~o}if(r=l,r=ze()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Df(r/1960))-r,10e?16:e,gn===null)var r=!1;else{if(e=gn,gn=null,io=0,(pe&6)!==0)throw Error(s(331));var l=pe;for(pe|=4,V=e.current;V!==null;){var o=V,a=o.child;if((V.flags&16)!==0){var f=o.deletions;if(f!==null){for(var m=0;mze()-bi?Bn(e,0):qi|=n),ct(e,t)}function sc(e,t){t===0&&((e.mode&1)===0?t=1:(t=vl,vl<<=1,(vl&130023424)===0&&(vl=4194304)));var n=ot();e=Gt(e,t),e!==null&&(_r(e,t,n),ct(e,n))}function Bf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),sc(e,n)}function Af(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(s(314))}r!==null&&r.delete(t),sc(e,n)}var ac;ac=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||it.current)at=!0;else{if((e.lanes&n)===0&&(t.flags&128)===0)return at=!1,Pf(e,t,n);at=(e.flags&131072)!==0}else at=!1,je&&(t.flags&1048576)!==0&&Aa(t,Fl,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;bl(e,t),e=t.pendingProps;var l=tr(t,be.current);sr(t,n),l=Ri(null,t,r,e,l,n);var o=zi();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,st(r)?(o=!0,Ml(t)):o=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,ji(t),l.updater=Zl,t.stateNode=l,l._reactInternals=t,Wi(t,r,e,n),t=Ai(null,t,r,!0,o,n)):(t.tag=0,je&&o&&pi(t),lt(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(bl(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Vf(r),e=Rt(r,e),l){case 0:t=Bi(null,t,r,e,n);break e;case 1:t=Du(null,t,r,e,n);break e;case 11:t=Tu(null,t,r,e,n);break e;case 14:t=Ru(null,t,r,Rt(r.type,e),n);break e}throw Error(s(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Rt(r,l),Bi(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Rt(r,l),Du(e,t,r,l,n);case 3:e:{if(Mu(t),e===null)throw Error(s(387));r=t.pendingProps,o=t.memoizedState,l=o.element,Xa(e,t),Hl(t,r,null,n);var a=t.memoizedState;if(r=a.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){l=ur(Error(s(423)),t),t=Iu(e,t,r,n,l);break e}else if(r!==l){l=ur(Error(s(424)),t),t=Iu(e,t,r,n,l);break e}else for(vt=un(t.stateNode.containerInfo.firstChild),mt=t,je=!0,Tt=null,n=Ja(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(lr(),r===l){t=Zt(e,t,n);break e}lt(e,t,r,n)}t=t.child}return t;case 5:return ba(t),e===null&&vi(t),r=t.type,l=t.pendingProps,o=e!==null?e.memoizedProps:null,a=l.children,si(r,l)?a=null:o!==null&&si(r,o)&&(t.flags|=32),Ou(e,t),lt(e,t,a,n),t.child;case 6:return e===null&&vi(t),null;case 13:return Wu(e,t,n);case 4:return Ci(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=or(t,null,r,n):lt(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Rt(r,l),Tu(e,t,r,l,n);case 7:return lt(e,t,t.pendingProps,n),t.child;case 8:return lt(e,t,t.pendingProps.children,n),t.child;case 12:return lt(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,o=t.memoizedProps,a=l.value,ye(Al,r._currentValue),r._currentValue=a,o!==null)if(Pt(o.value,a)){if(o.children===l.children&&!it.current){t=Zt(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var f=o.dependencies;if(f!==null){a=o.child;for(var m=f.firstContext;m!==null;){if(m.context===r){if(o.tag===1){m=Xt(-1,n&-n),m.tag=2;var C=o.updateQueue;if(C!==null){C=C.shared;var L=C.pending;L===null?m.next=m:(m.next=L.next,L.next=m),C.pending=m}}o.lanes|=n,m=o.alternate,m!==null&&(m.lanes|=n),ki(o.return,n,t),f.lanes|=n;break}m=m.next}}else if(o.tag===10)a=o.type===t.type?null:o.child;else if(o.tag===18){if(a=o.return,a===null)throw Error(s(341));a.lanes|=n,f=a.alternate,f!==null&&(f.lanes|=n),ki(a,n,t),a=o.sibling}else a=o.child;if(a!==null)a.return=o;else for(a=o;a!==null;){if(a===t){a=null;break}if(o=a.sibling,o!==null){o.return=a.return,a=o;break}a=a.return}o=a}lt(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,sr(t,n),l=St(l),r=r(l),t.flags|=1,lt(e,t,r,n),t.child;case 14:return r=t.type,l=Rt(r,t.pendingProps),l=Rt(r.type,l),Ru(e,t,r,l,n);case 15:return zu(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Rt(r,l),bl(e,t),t.tag=1,st(r)?(e=!0,Ml(t)):e=!1,sr(t,n),Su(t,r,l),Wi(t,r,l,n),Ai(null,t,r,!0,e,n);case 19:return Uu(e,t,n);case 22:return Lu(e,t,n)}throw Error(s(156,t.tag))};function uc(e,t){return $s(e,t)}function $f(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Et(e,t,n,r){return new $f(e,t,n,r)}function ss(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Vf(e){if(typeof e=="function")return ss(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Ee)return 11;if(e===qe)return 14}return 2}function wn(e,t){var n=e.alternate;return n===null?(n=Et(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function co(e,t,n,r,l,o){var a=2;if(r=e,typeof e=="function")ss(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Ce:return $n(n.children,l,o,t);case xe:a=8,l|=8;break;case Ze:return e=Et(12,n,t,l|2),e.elementType=Ze,e.lanes=o,e;case Te:return e=Et(13,n,t,l),e.elementType=Te,e.lanes=o,e;case Be:return e=Et(19,n,t,l),e.elementType=Be,e.lanes=o,e;case ve:return fo(n,l,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Ie:a=10;break e;case Ke:a=9;break e;case Ee:a=11;break e;case qe:a=14;break e;case Oe:a=16,r=null;break e}throw Error(s(130,e==null?e:typeof e,""))}return t=Et(a,n,t,l),t.elementType=e,t.type=r,t.lanes=o,t}function $n(e,t,n,r){return e=Et(7,e,r,t),e.lanes=n,e}function fo(e,t,n,r){return e=Et(22,e,r,t),e.elementType=ve,e.lanes=n,e.stateNode={isHidden:!1},e}function as(e,t,n){return e=Et(6,e,null,t),e.lanes=n,e}function us(e,t,n){return t=Et(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Hf(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Io(0),this.expirationTimes=Io(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Io(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function cs(e,t,n,r,l,o,a,f,m){return e=new Hf(e,t,n,f,m),t===1?(t=1,o===!0&&(t|=8)):t=0,o=Et(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},ji(o),e}function Qf(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(u){console.error(u)}}return i(),vs.exports=ip(),vs.exports}var jc;function sp(){if(jc)return xo;jc=1;var i=Bc();return xo.createRoot=i.createRoot,xo.hydrateRoot=i.hydrateRoot,xo}var ap=sp();Bc();/** + * @remix-run/router v1.23.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function al(){return al=Object.assign?Object.assign.bind():function(i){for(var u=1;u"u")throw new Error(u)}function Ts(i,u){if(!i){typeof console<"u"&&console.warn(u);try{throw new Error(u)}catch{}}}function cp(){return Math.random().toString(36).substr(2,8)}function Ec(i,u){return{usr:i.state,key:i.key,idx:u}}function js(i,u,s,d){return s===void 0&&(s=null),al({pathname:typeof i=="string"?i:i.pathname,search:"",hash:""},typeof u=="string"?yr(u):u,{state:s,key:u&&u.key||d||cp()})}function Co(i){let{pathname:u="/",search:s="",hash:d=""}=i;return s&&s!=="?"&&(u+=s.charAt(0)==="?"?s:"?"+s),d&&d!=="#"&&(u+=d.charAt(0)==="#"?d:"#"+d),u}function yr(i){let u={};if(i){let s=i.indexOf("#");s>=0&&(u.hash=i.substr(s),i=i.substr(0,s));let d=i.indexOf("?");d>=0&&(u.search=i.substr(d),i=i.substr(0,d)),i&&(u.pathname=i)}return u}function dp(i,u,s,d){d===void 0&&(d={});let{window:p=document.defaultView,v5Compat:h=!1}=d,g=p.history,j=Sn.Pop,w=null,_=P();_==null&&(_=0,g.replaceState(al({},g.state,{idx:_}),""));function P(){return(g.state||{idx:null}).idx}function N(){j=Sn.Pop;let E=P(),A=E==null?null:E-_;_=E,w&&w({action:j,location:T.location,delta:A})}function M(E,A){j=Sn.Push;let $=js(T.location,E,A);_=P()+1;let G=Ec($,_),U=T.createHref($);try{g.pushState(G,"",U)}catch(ce){if(ce instanceof DOMException&&ce.name==="DataCloneError")throw ce;p.location.assign(U)}h&&w&&w({action:j,location:T.location,delta:1})}function H(E,A){j=Sn.Replace;let $=js(T.location,E,A);_=P();let G=Ec($,_),U=T.createHref($);g.replaceState(G,"",U),h&&w&&w({action:j,location:T.location,delta:0})}function K(E){let A=p.location.origin!=="null"?p.location.origin:p.location.href,$=typeof E=="string"?E:Co(E);return $=$.replace(/ $/,"%20"),Pe(A,"No window.location.(origin|href) available to create URL for href: "+$),new URL($,A)}let T={get action(){return j},get location(){return i(p,g)},listen(E){if(w)throw new Error("A history only accepts one active listener");return p.addEventListener(Cc,N),w=E,()=>{p.removeEventListener(Cc,N),w=null}},createHref(E){return u(p,E)},createURL:K,encodeLocation(E){let A=K(E);return{pathname:A.pathname,search:A.search,hash:A.hash}},push:M,replace:H,go(E){return g.go(E)}};return T}var _c;(function(i){i.data="data",i.deferred="deferred",i.redirect="redirect",i.error="error"})(_c||(_c={}));function fp(i,u,s){return s===void 0&&(s="/"),pp(i,u,s)}function pp(i,u,s,d){let p=typeof u=="string"?yr(u):u,h=vr(p.pathname||"/",s);if(h==null)return null;let g=Ac(i);hp(g);let j=null,w=Ep(h);for(let _=0;j==null&&_{let w={relativePath:j===void 0?h.path||"":j,caseSensitive:h.caseSensitive===!0,childrenIndex:g,route:h};w.relativePath.startsWith("/")&&(Pe(w.relativePath.startsWith(d),'Absolute route path "'+w.relativePath+'" nested under path '+('"'+d+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),w.relativePath=w.relativePath.slice(d.length));let _=jn([d,w.relativePath]),P=s.concat(w);h.children&&h.children.length>0&&(Pe(h.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+_+'".')),Ac(h.children,u,P,_)),!(h.path==null&&!h.index)&&u.push({path:_,score:kp(_,h.index),routesMeta:P})};return i.forEach((h,g)=>{var j;if(h.path===""||!((j=h.path)!=null&&j.includes("?")))p(h,g);else for(let w of $c(h.path))p(h,g,w)}),u}function $c(i){let u=i.split("/");if(u.length===0)return[];let[s,...d]=u,p=s.endsWith("?"),h=s.replace(/\?$/,"");if(d.length===0)return p?[h,""]:[h];let g=$c(d.join("/")),j=[];return j.push(...g.map(w=>w===""?h:[h,w].join("/"))),p&&j.push(...g),j.map(w=>i.startsWith("/")&&w===""?"/":w)}function hp(i){i.sort((u,s)=>u.score!==s.score?s.score-u.score:Sp(u.routesMeta.map(d=>d.childrenIndex),s.routesMeta.map(d=>d.childrenIndex)))}const mp=/^:[\w-]+$/,vp=3,gp=2,yp=1,xp=10,wp=-2,Nc=i=>i==="*";function kp(i,u){let s=i.split("/"),d=s.length;return s.some(Nc)&&(d+=wp),u&&(d+=gp),s.filter(p=>!Nc(p)).reduce((p,h)=>p+(mp.test(h)?vp:h===""?yp:xp),d)}function Sp(i,u){return i.length===u.length&&i.slice(0,-1).every((d,p)=>d===u[p])?i[i.length-1]-u[u.length-1]:0}function jp(i,u,s){let{routesMeta:d}=i,p={},h="/",g=[];for(let j=0;j{let{paramName:M,isOptional:H}=P;if(M==="*"){let T=j[N]||"";g=h.slice(0,h.length-T.length).replace(/(.)\/+$/,"$1")}const K=j[N];return H&&!K?_[M]=void 0:_[M]=(K||"").replace(/%2F/g,"/"),_},{}),pathname:h,pathnameBase:g,pattern:i}}function Cp(i,u,s){u===void 0&&(u=!1),s===void 0&&(s=!0),Ts(i==="*"||!i.endsWith("*")||i.endsWith("/*"),'Route path "'+i+'" will be treated as if it were '+('"'+i.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+i.replace(/\*$/,"/*")+'".'));let d=[],p="^"+i.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(g,j,w)=>(d.push({paramName:j,isOptional:w!=null}),w?"/?([^\\/]+)?":"/([^\\/]+)"));return i.endsWith("*")?(d.push({paramName:"*"}),p+=i==="*"||i==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?p+="\\/*$":i!==""&&i!=="/"&&(p+="(?:(?=\\/|$))"),[new RegExp(p,u?void 0:"i"),d]}function Ep(i){try{return i.split("/").map(u=>decodeURIComponent(u).replace(/\//g,"%2F")).join("/")}catch(u){return Ts(!1,'The URL path "'+i+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+u+").")),i}}function vr(i,u){if(u==="/")return i;if(!i.toLowerCase().startsWith(u.toLowerCase()))return null;let s=u.endsWith("/")?u.length-1:u.length,d=i.charAt(s);return d&&d!=="/"?null:i.slice(s)||"/"}const _p=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Np=i=>_p.test(i);function Pp(i,u){u===void 0&&(u="/");let{pathname:s,search:d="",hash:p=""}=typeof i=="string"?yr(i):i,h;if(s)if(Np(s))h=s;else{if(s.includes("//")){let g=s;s=Vc(s),Ts(!1,"Pathnames cannot have embedded double slashes - normalizing "+(g+" -> "+s))}s.startsWith("/")?h=Pc(s.substring(1),"/"):h=Pc(s,u)}else h=u;return{pathname:h,search:zp(d),hash:Lp(p)}}function Pc(i,u){let s=u.replace(/\/+$/,"").split("/");return i.split("/").forEach(p=>{p===".."?s.length>1&&s.pop():p!=="."&&s.push(p)}),s.length>1?s.join("/"):"/"}function xs(i,u,s,d){return"Cannot include a '"+i+"' character in a manually specified "+("`to."+u+"` field ["+JSON.stringify(d)+"]. Please separate it out to the ")+("`to."+s+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Tp(i){return i.filter((u,s)=>s===0||u.route.path&&u.route.path.length>0)}function Rs(i,u){let s=Tp(i);return u?s.map((d,p)=>p===s.length-1?d.pathname:d.pathnameBase):s.map(d=>d.pathnameBase)}function zs(i,u,s,d){d===void 0&&(d=!1);let p;typeof i=="string"?p=yr(i):(p=al({},i),Pe(!p.pathname||!p.pathname.includes("?"),xs("?","pathname","search",p)),Pe(!p.pathname||!p.pathname.includes("#"),xs("#","pathname","hash",p)),Pe(!p.search||!p.search.includes("#"),xs("#","search","hash",p)));let h=i===""||p.pathname==="",g=h?"/":p.pathname,j;if(g==null)j=s;else{let N=u.length-1;if(!d&&g.startsWith("..")){let M=g.split("/");for(;M[0]==="..";)M.shift(),N-=1;p.pathname=M.join("/")}j=N>=0?u[N]:"/"}let w=Pp(p,j),_=g&&g!=="/"&&g.endsWith("/"),P=(h||g===".")&&s.endsWith("/");return!w.pathname.endsWith("/")&&(_||P)&&(w.pathname+="/"),w}const Vc=i=>i.replace(/\/\/+/g,"/"),jn=i=>Vc(i.join("/")),Rp=i=>i.replace(/\/+$/,"").replace(/^\/*/,"/"),zp=i=>!i||i==="?"?"":i.startsWith("?")?i:"?"+i,Lp=i=>!i||i==="#"?"":i.startsWith("#")?i:"#"+i;function Op(i){return i!=null&&typeof i.status=="number"&&typeof i.statusText=="string"&&typeof i.internal=="boolean"&&"data"in i}const Hc=["post","put","patch","delete"];new Set(Hc);const Dp=["get",...Hc];new Set(Dp);/** + * React Router v6.30.4 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function ul(){return ul=Object.assign?Object.assign.bind():function(i){for(var u=1;u{j.current=!0}),S.useCallback(function(_,P){if(P===void 0&&(P={}),!j.current)return;if(typeof _=="number"){d.go(_);return}let N=zs(_,JSON.parse(g),h,P.relative==="path");i==null&&u!=="/"&&(N.pathname=N.pathname==="/"?u:jn([u,N.pathname])),(P.replace?d.replace:d.push)(N,P.state,P)},[u,d,g,h,i])}function Po(i,u){let{relative:s}=u===void 0?{}:u,{future:d}=S.useContext(bt),{matches:p}=S.useContext(Cn),{pathname:h}=wr(),g=JSON.stringify(Rs(p,d.v7_relativeSplatPath));return S.useMemo(()=>zs(i,JSON.parse(g),h,s==="path"),[i,g,h,s])}function Wp(i,u){return Fp(i,u)}function Fp(i,u,s,d){xr()||Pe(!1);let{navigator:p}=S.useContext(bt),{matches:h}=S.useContext(Cn),g=h[h.length-1],j=g?g.params:{};g&&g.pathname;let w=g?g.pathnameBase:"/";g&&g.route;let _=wr(),P;if(u){var N;let E=typeof u=="string"?yr(u):u;w==="/"||(N=E.pathname)!=null&&N.startsWith(w)||Pe(!1),P=E}else P=_;let M=P.pathname||"/",H=M;if(w!=="/"){let E=w.replace(/^\//,"").split("/");H="/"+M.replace(/^\//,"").split("/").slice(E.length).join("/")}let K=fp(i,{pathname:H}),T=Vp(K&&K.map(E=>Object.assign({},E,{params:Object.assign({},j,E.params),pathname:jn([w,p.encodeLocation?p.encodeLocation(E.pathname).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?w:jn([w,p.encodeLocation?p.encodeLocation(E.pathnameBase).pathname:E.pathnameBase])})),h,s,d);return u&&T?S.createElement(No.Provider,{value:{location:ul({pathname:"/",search:"",hash:"",state:null,key:"default"},P),navigationType:Sn.Pop}},T):T}function Up(){let i=Yp(),u=Op(i)?i.status+" "+i.statusText:i instanceof Error?i.message:JSON.stringify(i),s=i instanceof Error?i.stack:null,p={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return S.createElement(S.Fragment,null,S.createElement("h2",null,"Unexpected Application Error!"),S.createElement("h3",{style:{fontStyle:"italic"}},u),s?S.createElement("pre",{style:p},s):null,null)}const Bp=S.createElement(Up,null);class Ap extends S.Component{constructor(u){super(u),this.state={location:u.location,revalidation:u.revalidation,error:u.error}}static getDerivedStateFromError(u){return{error:u}}static getDerivedStateFromProps(u,s){return s.location!==u.location||s.revalidation!=="idle"&&u.revalidation==="idle"?{error:u.error,location:u.location,revalidation:u.revalidation}:{error:u.error!==void 0?u.error:s.error,location:s.location,revalidation:u.revalidation||s.revalidation}}componentDidCatch(u,s){console.error("React Router caught the following error during render",u,s)}render(){return this.state.error!==void 0?S.createElement(Cn.Provider,{value:this.props.routeContext},S.createElement(Kc.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function $p(i){let{routeContext:u,match:s,children:d}=i,p=S.useContext(_o);return p&&p.static&&p.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(p.staticContext._deepestRenderedBoundaryId=s.route.id),S.createElement(Cn.Provider,{value:u},d)}function Vp(i,u,s,d){var p;if(u===void 0&&(u=[]),s===void 0&&(s=null),d===void 0&&(d=null),i==null){var h;if(!s)return null;if(s.errors)i=s.matches;else if((h=d)!=null&&h.v7_partialHydration&&u.length===0&&!s.initialized&&s.matches.length>0)i=s.matches;else return null}let g=i,j=(p=s)==null?void 0:p.errors;if(j!=null){let P=g.findIndex(N=>N.route.id&&(j==null?void 0:j[N.route.id])!==void 0);P>=0||Pe(!1),g=g.slice(0,Math.min(g.length,P+1))}let w=!1,_=-1;if(s&&d&&d.v7_partialHydration)for(let P=0;P=0?g=g.slice(0,_+1):g=[g[0]];break}}}return g.reduceRight((P,N,M)=>{let H,K=!1,T=null,E=null;s&&(H=j&&N.route.id?j[N.route.id]:void 0,T=N.route.errorElement||Bp,w&&(_<0&&M===0?(Gp("route-fallback"),K=!0,E=null):_===M&&(K=!0,E=N.route.hydrateFallbackElement||null)));let A=u.concat(g.slice(0,M+1)),$=()=>{let G;return H?G=T:K?G=E:N.route.Component?G=S.createElement(N.route.Component,null):N.route.element?G=N.route.element:G=P,S.createElement($p,{match:N,routeContext:{outlet:P,matches:A,isDataRoute:s!=null},children:G})};return s&&(N.route.ErrorBoundary||N.route.errorElement||M===0)?S.createElement(Ap,{location:s.location,revalidation:s.revalidation,component:T,error:H,children:$(),routeContext:{outlet:null,matches:A,isDataRoute:!0}}):$()},null)}var Gc=(function(i){return i.UseBlocker="useBlocker",i.UseRevalidator="useRevalidator",i.UseNavigateStable="useNavigate",i})(Gc||{}),Xc=(function(i){return i.UseBlocker="useBlocker",i.UseLoaderData="useLoaderData",i.UseActionData="useActionData",i.UseRouteError="useRouteError",i.UseNavigation="useNavigation",i.UseRouteLoaderData="useRouteLoaderData",i.UseMatches="useMatches",i.UseRevalidator="useRevalidator",i.UseNavigateStable="useNavigate",i.UseRouteId="useRouteId",i})(Xc||{});function Hp(i){let u=S.useContext(_o);return u||Pe(!1),u}function Qp(i){let u=S.useContext(Qc);return u||Pe(!1),u}function Kp(i){let u=S.useContext(Cn);return u||Pe(!1),u}function Zc(i){let u=Kp(),s=u.matches[u.matches.length-1];return s.route.id||Pe(!1),s.route.id}function Yp(){var i;let u=S.useContext(Kc),s=Qp(),d=Zc();return u!==void 0?u:(i=s.errors)==null?void 0:i[d]}function Jp(){let{router:i}=Hp(Gc.UseNavigateStable),u=Zc(Xc.UseNavigateStable),s=S.useRef(!1);return Yc(()=>{s.current=!0}),S.useCallback(function(p,h){h===void 0&&(h={}),s.current&&(typeof p=="number"?i.navigate(p):i.navigate(p,ul({fromRouteId:u},h)))},[i,u])}const Tc={};function Gp(i,u,s){Tc[i]||(Tc[i]=!0)}function Xp(i,u){i==null||i.v7_startTransition,i==null||i.v7_relativeSplatPath}function ws(i){let{to:u,replace:s,state:d,relative:p}=i;xr()||Pe(!1);let{future:h,static:g}=S.useContext(bt),{matches:j}=S.useContext(Cn),{pathname:w}=wr(),_=Jc(),P=zs(u,Rs(j,h.v7_relativeSplatPath),w,p==="path"),N=JSON.stringify(P);return S.useEffect(()=>_(JSON.parse(N),{replace:s,state:d,relative:p}),[_,N,p,s,d]),null}function il(i){Pe(!1)}function Zp(i){let{basename:u="/",children:s=null,location:d,navigationType:p=Sn.Pop,navigator:h,static:g=!1,future:j}=i;xr()&&Pe(!1);let w=u.replace(/^\/*/,"/"),_=S.useMemo(()=>({basename:w,navigator:h,static:g,future:ul({v7_relativeSplatPath:!1},j)}),[w,j,h,g]);typeof d=="string"&&(d=yr(d));let{pathname:P="/",search:N="",hash:M="",state:H=null,key:K="default"}=d,T=S.useMemo(()=>{let E=vr(P,w);return E==null?null:{location:{pathname:E,search:N,hash:M,state:H,key:K},navigationType:p}},[w,P,N,M,H,K,p]);return T==null?null:S.createElement(bt.Provider,{value:_},S.createElement(No.Provider,{children:s,value:T}))}function qp(i){let{children:u,location:s}=i;return Wp(Es(u),s)}new Promise(()=>{});function Es(i,u){u===void 0&&(u=[]);let s=[];return S.Children.forEach(i,(d,p)=>{if(!S.isValidElement(d))return;let h=[...u,p];if(d.type===S.Fragment){s.push.apply(s,Es(d.props.children,h));return}d.type!==il&&Pe(!1),!d.props.index||!d.props.children||Pe(!1);let g={id:d.props.id||h.join("-"),caseSensitive:d.props.caseSensitive,element:d.props.element,Component:d.props.Component,index:d.props.index,path:d.props.path,loader:d.props.loader,action:d.props.action,errorElement:d.props.errorElement,ErrorBoundary:d.props.ErrorBoundary,hasErrorBoundary:d.props.ErrorBoundary!=null||d.props.errorElement!=null,shouldRevalidate:d.props.shouldRevalidate,handle:d.props.handle,lazy:d.props.lazy};d.props.children&&(g.children=Es(d.props.children,h)),s.push(g)}),s}/** + * React Router DOM v6.30.4 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Eo(){return Eo=Object.assign?Object.assign.bind():function(i){for(var u=1;u{_&&Rc?Rc(()=>w(N)):w(N)},[w,_]);return S.useLayoutEffect(()=>g.listen(P),[g,P]),S.useEffect(()=>Xp(d),[d]),S.createElement(Zp,{basename:u,children:s,location:j.location,navigationType:j.action,navigator:g,future:d})}const sh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",ah=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,uh=S.forwardRef(function(u,s){let{onClick:d,relative:p,reloadDocument:h,replace:g,state:j,target:w,to:_,preventScrollReset:P,viewTransition:N}=u,M=qc(u,th),{basename:H}=S.useContext(bt),K,T=!1;if(typeof _=="string"&&ah.test(_)&&(K=_,sh))try{let G=new URL(window.location.href),U=_.startsWith("//")?new URL(G.protocol+_):new URL(_),ce=vr(U.pathname,H);U.origin===G.origin&&ce!=null?_=ce+U.search+U.hash:T=!0}catch{}let E=Mp(_,{relative:p}),A=fh(_,{replace:g,state:j,target:w,preventScrollReset:P,relative:p,viewTransition:N});function $(G){d&&d(G),G.defaultPrevented||A(G)}return S.createElement("a",Eo({},M,{href:K||E,onClick:T||h?d:$,ref:s,target:w}))}),ch=S.forwardRef(function(u,s){let{"aria-current":d="page",caseSensitive:p=!1,className:h="",end:g=!1,style:j,to:w,viewTransition:_,children:P}=u,N=qc(u,nh),M=Po(w,{relative:N.relative}),H=wr(),K=S.useContext(Qc),{navigator:T,basename:E}=S.useContext(bt),A=K!=null&&ph(M)&&_===!0,$=T.encodeLocation?T.encodeLocation(M).pathname:M.pathname,G=H.pathname,U=K&&K.navigation&&K.navigation.location?K.navigation.location.pathname:null;p||(G=G.toLowerCase(),U=U?U.toLowerCase():null,$=$.toLowerCase()),U&&E&&(U=vr(U,E)||U);const ce=$!=="/"&&$.endsWith("/")?$.length-1:$.length;let de=G===$||!g&&G.startsWith($)&&G.charAt(ce)==="/",Ce=U!=null&&(U===$||!g&&U.startsWith($)&&U.charAt($.length)==="/"),xe={isActive:de,isPending:Ce,isTransitioning:A},Ze=de?d:void 0,Ie;typeof h=="function"?Ie=h(xe):Ie=[h,de?"active":null,Ce?"pending":null,A?"transitioning":null].filter(Boolean).join(" ");let Ke=typeof j=="function"?j(xe):j;return S.createElement(uh,Eo({},N,{"aria-current":Ze,className:Ie,ref:s,style:Ke,to:w,viewTransition:_}),typeof P=="function"?P(xe):P)});var _s;(function(i){i.UseScrollRestoration="useScrollRestoration",i.UseSubmit="useSubmit",i.UseSubmitFetcher="useSubmitFetcher",i.UseFetcher="useFetcher",i.useViewTransitionState="useViewTransitionState"})(_s||(_s={}));var zc;(function(i){i.UseFetcher="useFetcher",i.UseFetchers="useFetchers",i.UseScrollRestoration="useScrollRestoration"})(zc||(zc={}));function dh(i){let u=S.useContext(_o);return u||Pe(!1),u}function fh(i,u){let{target:s,replace:d,state:p,preventScrollReset:h,relative:g,viewTransition:j}=u===void 0?{}:u,w=Jc(),_=wr(),P=Po(i,{relative:g});return S.useCallback(N=>{if(eh(N,s)){N.preventDefault();let M=d!==void 0?d:Co(_)===Co(P);w(i,{replace:M,state:p,preventScrollReset:h,relative:g,viewTransition:j})}},[_,w,P,d,p,s,i,h,g,j])}function ph(i,u){u===void 0&&(u={});let s=S.useContext(lh);s==null&&Pe(!1);let{basename:d}=dh(_s.useViewTransitionState),p=Po(i,{relative:u.relative});if(!s.isTransitioning)return!1;let h=vr(s.currentLocation.pathname,d)||s.currentLocation.pathname,g=vr(s.nextLocation.pathname,d)||s.nextLocation.pathname;return Cs(p.pathname,g)!=null||Cs(p.pathname,h)!=null}function hh(){if(window.matchMedia("(display-mode: standalone)").matches)return;const i=document.cookie.split(";").map(s=>s.trim()).find(s=>s.startsWith("hnf_inactivity_mins="));if(!i)return;const u=parseInt(i.split("=")[1]);return isNaN(u)||u<=0?void 0:u*60*1e3}const Lc={background:"var(--navy-dark)",border:"1px solid var(--surface-2)",borderRadius:"6px",color:"var(--text)",padding:"0.625rem 0.75rem",fontSize:"1rem",width:"100%",outline:"none"},mh={background:"var(--hk-green)",color:"#fff",border:"none",borderRadius:"6px",padding:"0.625rem",fontSize:"1rem",fontWeight:600,marginTop:"0.25rem",width:"100%"};function vh({children:i}){const[u,s]=S.useState("checking"),[d,p]=S.useState(null),[h,g]=S.useState(""),[j,w]=S.useState(""),[_,P]=S.useState(""),[N,M]=S.useState(!1),H=S.useRef(null);S.useEffect(()=>{fetch("/api/auth/verify?app=hk-planner",{credentials:"include"}).then(async T=>{T.ok?(p(await T.json()),s("authed")):s("login")}).catch(()=>s("login"))},[]),S.useEffect(()=>{const T=hh();if(u!=="authed"||!T)return;async function E(){await fetch("/api/auth/logout",{method:"POST",credentials:"include"}).catch(()=>{}),p(null),s("login")}function A(){H.current&&clearTimeout(H.current),H.current=setTimeout(E,T)}const $=["mousemove","keydown","click","touchstart"];return $.forEach(G=>window.addEventListener(G,A,{passive:!0})),A(),()=>{H.current&&clearTimeout(H.current),$.forEach(G=>window.removeEventListener(G,A))}},[u]);async function K(T){T.preventDefault(),M(!0),P("");try{if(!(await fetch("/api/auth/login",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:h,password:j})})).ok){P("Invalid email or password");return}const A=await fetch("/api/auth/verify?app=hk-planner",{credentials:"include"});A.ok?(p(await A.json()),s("authed")):P("You don't have access to this app.")}catch{P("Connection error — please try again")}finally{M(!1)}}return u==="checking"?c.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100dvh"},children:c.jsx("div",{style:{color:"var(--text-muted)"},children:"Loading…"})}):u==="login"?c.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100dvh",padding:"1.5rem",background:"var(--navy-dark)"},children:c.jsxs("div",{style:{background:"var(--navy)",borderRadius:"var(--radius)",padding:"2rem",width:"100%",maxWidth:"360px",border:"1px solid var(--surface-2)"},children:[c.jsx("h1",{style:{fontSize:"1.4rem",marginBottom:"0.25rem",color:"#74c69d"},children:"HK Planner"}),c.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.875rem",marginBottom:"1.5rem"},children:void 0}),c.jsxs("form",{onSubmit:K,style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[c.jsx("input",{type:"email",value:h,onChange:T=>g(T.target.value),placeholder:"Email",required:!0,autoComplete:"email",style:Lc}),c.jsx("input",{type:"password",value:j,onChange:T=>w(T.target.value),placeholder:"Password",required:!0,autoComplete:"current-password",style:Lc}),_&&c.jsx("p",{style:{color:"#f87171",fontSize:"0.875rem"},children:_}),c.jsx("button",{type:"submit",disabled:N,style:mh,children:N?"Signing in…":"Sign in"})]})]})}):c.jsx(c.Fragment,{children:i(d)})}/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const bc=(...i)=>i.filter((u,s,d)=>!!u&&u.trim()!==""&&d.indexOf(u)===s).join(" ").trim();/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const gh=i=>i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const yh=i=>i.replace(/^([A-Z])|[\s-_]+(\w)/g,(u,s,d)=>d?d.toUpperCase():s.toLowerCase());/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Oc=i=>{const u=yh(i);return u.charAt(0).toUpperCase()+u.slice(1)};/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var ks={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const xh=i=>{for(const u in i)if(u.startsWith("aria-")||u==="role"||u==="title")return!0;return!1},wh=S.createContext({}),kh=()=>S.useContext(wh),Sh=S.forwardRef(({color:i,size:u,strokeWidth:s,absoluteStrokeWidth:d,className:p="",children:h,iconNode:g,...j},w)=>{const{size:_=24,strokeWidth:P=2,absoluteStrokeWidth:N=!1,color:M="currentColor",className:H=""}=kh()??{},K=d??N?Number(s??P)*24/Number(u??_):s??P;return S.createElement("svg",{ref:w,...ks,width:u??_??ks.width,height:u??_??ks.height,stroke:i??M,strokeWidth:K,className:bc("lucide",H,p),...!h&&!xh(j)&&{"aria-hidden":"true"},...j},[...g.map(([T,E])=>S.createElement(T,E)),...Array.isArray(h)?h:[h]])});/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const cl=(i,u)=>{const s=S.forwardRef(({className:d,...p},h)=>S.createElement(Sh,{ref:h,iconNode:u,className:bc(`lucide-${gh(Oc(i))}`,`lucide-${i}`,d),...p}));return s.displayName=Oc(i),s};/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const jh=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],Dc=cl("calendar-clock",jh);/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ch=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Eh=cl("grip-vertical",Ch);/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _h=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Nh=cl("log-out",_h);/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ph=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Ns=cl("refresh-cw",Ph);/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Th=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Rh=cl("settings",Th);function zh({visible:i}){return i?c.jsxs("div",{style:{position:"fixed",bottom:0,left:0,right:0,zIndex:9999,background:"var(--sidebar)",color:"var(--text-light)",display:"flex",alignItems:"center",justifyContent:"center",gap:"12px",padding:"10px 16px",fontSize:"14px",boxShadow:"0 -2px 8px rgba(0,0,0,0.3)"},children:[c.jsx("span",{children:"A new version is available."}),c.jsxs("button",{onClick:()=>window.location.reload(),style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--accent)",color:"var(--sidebar)",border:"none",borderRadius:"4px",padding:"6px 14px",fontWeight:600,cursor:"pointer",fontSize:"13px"},children:[c.jsx(Ns,{size:14,strokeWidth:1.75}),"Reload"]})]}):null}const Lh=120*1e3;function Oh(i){const[u,s]=S.useState(!1);return S.useEffect(()=>{let d=null;async function p(){try{const j=await fetch(i,{cache:"no-store"});if(!j.ok)return;const _=(await j.json()).version;if(!_)return;d===null?d=_:_!==d&&s(!0)}catch{}}p();const h=setInterval(p,Lh);function g(){document.visibilityState==="visible"&&p()}return document.addEventListener("visibilitychange",g),()=>{clearInterval(h),document.removeEventListener("visibilitychange",g)}},[i]),u}function ed(i,u){return i.is_admin||i.caps.includes(u)}const Dh="width=1280",Mh="width=device-width, initial-scale=1.0";function Mc(i){const u=document.querySelector('meta[name="viewport"]');u&&(u.content=i)}function Ih(i){S.useEffect(()=>(Mc(Dh),window.parent.postMessage({type:"hnf:viewport",mode:i},"*"),()=>{Mc(Mh),window.parent.postMessage({type:"hnf:viewport",mode:"responsive"},"*")}),[i])}function Wh({user:i,children:u}){Ih("desktop");async function s(){await fetch("/hk-planner/api/auth/logout",{method:"POST",credentials:"include"}),window.location.reload()}return c.jsxs("div",{style:{display:"flex",height:"100dvh",overflow:"hidden"},children:[c.jsxs("nav",{style:{width:"200px",flexShrink:0,background:"var(--navy)",display:"flex",flexDirection:"column",padding:"1rem 0",borderRight:"1px solid var(--surface-2)"},children:[c.jsx("div",{style:{padding:"0 1rem 1rem",borderBottom:"1px solid var(--surface-2)"},children:c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[c.jsx(Dc,{size:20,strokeWidth:1.75,color:"#74c69d"}),c.jsx("span",{style:{color:"#74c69d",fontWeight:700,fontSize:"0.95rem"},children:"HK Planner"})]})}),c.jsxs("div",{className:"nav-scroll",style:{flex:1,padding:"0.5rem 0",overflowY:"auto"},children:[c.jsx(Ic,{to:"/planner",icon:Dc,label:"Planner"}),ed(i,"settings")&&c.jsx(Ic,{to:"/settings",icon:Rh,label:"Settings"})]}),c.jsxs("div",{style:{padding:"0.75rem 1rem",borderTop:"1px solid var(--surface-2)"},children:[c.jsxs("div",{style:{marginBottom:"0.5rem"},children:[c.jsx("div",{style:{color:"var(--text)",fontSize:"0.8rem",fontWeight:600},children:i.name}),c.jsx("div",{style:{color:"var(--text-muted)",fontSize:"0.72rem"},children:i.email})]}),c.jsxs("button",{onClick:s,style:{display:"flex",alignItems:"center",gap:"0.5rem",background:"none",border:"none",color:"var(--text-muted)",fontSize:"0.8rem",padding:"0.375rem 0",width:"100%",cursor:"pointer"},children:[c.jsx(Nh,{size:14,strokeWidth:1.75}),"Sign out"]})]})]}),c.jsx("main",{style:{flex:1,overflow:"auto",background:"var(--body-bg)"},children:u})]})}function Ic({to:i,icon:u,label:s}){return c.jsxs(ch,{to:i,style:({isActive:d})=>({display:"flex",alignItems:"center",gap:"0.625rem",padding:"0.625rem 1rem",textDecoration:"none",color:d?"#74c69d":"var(--text)",background:d?"var(--surface)":"transparent",borderLeft:d?"2px solid #74c69d":"2px solid transparent",fontSize:"0.875rem",transition:"background 0.15s"}),children:[c.jsx(u,{size:15,strokeWidth:1.75}),s]})}const Fh="/hk-planner/api";async function Xe(i,u){const s=await fetch(Fh+i,{credentials:"include",...u});if(s.status===401)throw(window.top??window).location.href="/login",new Error("Unauthenticated");if(!s.ok){const d=await s.json().catch(()=>({}));throw new Error(d.error||`HTTP ${s.status}`)}return s.json()}function Uh(i,u,s=!1){const d=new URLSearchParams;return i&&d.set("week_start",i),u&&d.set("last_viewed",u),s&&d.set("force_refresh","1"),Xe(`/bookings?${d}`)}function td(){return Xe("/config")}function Bh(i,u,s){return Xe("/config/time-requirements",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cat:i,action:u,value:s})})}function Ah(i){return Xe("/config/staff",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({staff_data:i})})}function $h(i){return Xe("/config/pickup",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({pickup_data:i})})}function Vh(i){return Xe("/config/general-tasks",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({general_tasks:i})})}function Hh(i){return Xe("/config/last-reviewed",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({date:i})})}function Qh(){return Xe("/categories")}function Kh(i,u){return Xe("/categories",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:i,excluded:u})})}function Yh(){return Xe("/newbook/test",{method:"POST"})}function Jh(){return Xe("/workforce/departments")}function Gh(i){return Xe("/config/workforce-departments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dept_ids:i})})}function Xh(){return Xe("/workforce/sync",{method:"POST"})}function Wc(i,u){return Xe(`/workforce/shifts?start=${i}&end=${u}`)}function Zh(){return Xe("/workforce/staff")}function qh(i){return Xe("/config/adjustments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({adjustments:i})})}function bh(i){return Xe("/config/warning-thresholds",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}function wo(){const i=new Date;return`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(i.getDate()).padStart(2,"0")}`}function ko(i,u){const[s,d,p]=i.split("-").map(Number),h=new Date(s,d-1,p);return h.setDate(h.getDate()+u),`${h.getFullYear()}-${String(h.getMonth()+1).padStart(2,"0")}-${String(h.getDate()).padStart(2,"0")}`}function To(i){const u=new Date(i+"T00:00:00");return["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][u.getDay()]+" "+u.getDate()+" "+["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][u.getMonth()]}function em(i){const u=new Date(i+"T00:00:00");return["Mon","Tue","Wed","Thu","Fri","Sat","Sun"][(u.getDay()+6)%7]}function tm(i){const u=new Date(i+"T00:00:00");return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][u.getDay()]}function sl(i){const u=new Date(i+"T00:00:00").getDay();return u===0||u===6}function nm(i,u){const s=u.pickup_hint??0,d=u.pickup_lead??0,p=s>0?`${s} room${s===1?"":"s"} picked up within ${d} day${d===1?"":"s"} of arrival`:"no late pickups";return`Last ${tm(i)}: ${u.prior_occ} occ (${u.prior_vac} vac) — ${p}`}function Fc(i){return new Date(i+"T00:00:00").toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})}function Ge(i){return i.toFixed(2)+"h"}function gr(i,u,s,d,p){var _;const h=Math.max(0,p-d),g=(_=i[u])==null?void 0:_[s];if(!g||!g.count)return 0;const j=g.total-g.count,w=d>j?Math.max(0,g.total-d):g.count;return Math.min(w,h)}function rm(i,u,s,d,p){const h={};for(const g of i.dates){const j=em(g),w=d.reduce((P,N)=>P+(N.hours[j]||0)/60,0),_=p.reduce((P,N)=>P+(N.hours[g]||0),0);h[g]={booked:0,pickup:0,general:w,adjustments:_,total:w+_,by_cat:{},pickup_by_cat:{}}}for(const g of i.categories){const j=u[g.id]||{depart:0,stay:0,arrive:0};i.dates.forEach((w,_)=>{const P=g.days[w],N=P.stays+P.arrivals,M=gr(s,g.id,w,N,g.total_rooms),H=(P.departs*(j.depart||0)+P.stays*(j.stay||0)+P.arrivals*(j.arrive||0))/60,K=M*(j.arrive||0)/60;h[w].by_cat[g.id]=H,h[w].pickup_by_cat[g.id]=(h[w].pickup_by_cat[g.id]||0)+K,h[w].booked+=H,h[w].pickup+=K,h[w].total+=H+K;const T=i.dates[_+1];if(T&&M>0){const E=M*(j.depart||0)/60;h[T].pickup_by_cat[g.id]=(h[T].pickup_by_cat[g.id]||0)+E,h[T].pickup+=E,h[T].total+=E}})}return h}function lm(){const[i,u]=S.useState(null),[s,d]=S.useState({}),[p,h]=S.useState([]),[g,j]=S.useState({}),[w,_]=S.useState([]),[P,N]=S.useState([]),[M,H]=S.useState(4),[K,T]=S.useState(1),[E,A]=S.useState(1),[$,G]=S.useState(2),[U,ce]=S.useState({}),[de,Ce]=S.useState([]),[xe,Ze]=S.useState(!1),[Ie,Ke]=S.useState(null),[Ee,Te]=S.useState(""),[Be,qe]=S.useState(""),[Oe,ve]=S.useState(!0),[W,X]=S.useState(""),[F,y]=S.useState(null),R=S.useRef({}),ee=S.useRef(null),re=S.useRef(!1),le=S.useRef(null);le.current=Ie;function oe(ne,me,Ae=400){clearTimeout(R.current[ne]),R.current[ne]=setTimeout(me,Ae)}function ae(ne,me=!1){ee.current&&clearTimeout(ee.current),y({text:ne,err:me}),ee.current=setTimeout(()=>y(null),me?5e3:2500)}function se(){const ne=wo();ne!==Be&&(qe(ne),Hh(ne).catch(()=>{}))}const fe=S.useCallback(async(ne=!1,me)=>{ve(!0),X("");const Ae=wo(),rt=le.current||Ae,ft=ko(rt,6),pt=me!==void 0?me||ko(Ae,-1):Ee||Be||ko(Ae,-1);try{const[$e,we,yt]=await Promise.all([Uh(rt,pt,ne),td(),Wc(rt,ft).catch(()=>({}))]);u($e),d(we.time_requirements||{}),h(we.staff_data||[]),j(we.pickup_data||{}),_(we.general_tasks||[]),N(we.adjustments||[]),H(we.warn_over_red_hrs??4),T(we.warn_over_amber_hrs??1),A(we.warn_under_amber_hrs??1),G(we.warn_under_red_hrs??2),ce(yt),we.last_reviewed&&(qe(we.last_reviewed),Ee||Te(we.last_reviewed))}catch($e){X($e instanceof Error?$e.message:"Failed to load data")}finally{ve(!1)}},[Ee,Be]);S.useEffect(()=>{fe(!1)},[]),S.useEffect(()=>{Object.keys(U).length>0&&!re.current&&(re.current=!0,Zh().then(Ce).catch(()=>{}))},[U]),S.useEffect(()=>{function ne(){p.length&&navigator.sendBeacon("/hk-planner/api/config/staff",JSON.stringify({staff_data:p})),Object.keys(g).length&&navigator.sendBeacon("/hk-planner/api/config/pickup",JSON.stringify({pickup_data:g})),P.length&&navigator.sendBeacon("/hk-planner/api/config/adjustments",JSON.stringify({adjustments:P}))}return window.addEventListener("beforeunload",ne),()=>window.removeEventListener("beforeunload",ne)},[p,g,P]);function We(ne){const me=wo(),Ae=ko(le.current||me,ne);le.current=Ae,Ke(Ae),se(),fe(!0)}function At(){le.current=null,Ke(null),se(),fe(!0)}function En(){se(),fe(!0)}function $t(ne,me,Ae,rt){const ft=rt.days[me],pt=ft.stays+ft.arrivals,$e=Math.max(0,rt.total_rooms-pt),we=gr(g,ne,me,pt,rt.total_rooms),yt=Math.max(0,Math.min(we+Ae,$e)),Tn={...g,[ne]:{...g[ne]||{},[me]:{count:yt,total:pt+yt}}};j(Tn),se(),oe("pickup",()=>$h(Tn).then(()=>ae("Pickup saved")).catch(Vn=>ae(Vn.message,!0)))}function Vt(ne){N(ne),oe("adjustments",()=>qh(ne).then(()=>ae("Adjustments saved")).catch(me=>ae(me.message,!0)))}function _n(){Vt([...P,{label:"",hours:{}}])}function en(ne){h(ne),se(),oe("staff",()=>Ah(ne).then(()=>ae("Staff hours saved")).catch(me=>ae(me.message,!0)))}function Ht(){en([...p,{name:"",hours:{}}])}async function Nn(){Ze(!0);try{if(await Xh(),i){const ne=await Wc(i.dates[0],i.dates[i.dates.length-1]);ce(ne)}ae("Rota synced from Workforce")}catch(ne){ae(ne instanceof Error?ne.message:"Sync failed",!0)}finally{Ze(!1)}}function tn(){if(!i)return"";const ne=i.dates.filter($e=>U[$e]);if(!ne.length)return"Not synced";const me=ne.reduce(($e,we)=>new Date(U[we].synced_at)!U[$e]).length?`Partial sync — from ${rt} ${ft}`:`From ${rt} ${ft}`}const _t=i?rm(i,s,g,w,P):null,Dt=wo(),Pn=Ie||Dt;return c.jsxs("div",{style:{padding:"1.5rem",maxWidth:"1600px"},children:[c.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0.75rem",marginBottom:"1.25rem"},children:[c.jsxs("div",{children:[c.jsx("h1",{style:{fontSize:"1.15rem",fontWeight:700,color:"var(--text-dark)"},children:"Housekeeping Planner"}),i&&c.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-mid)",marginTop:"0.1rem"},children:[Fc(i.dates[0])," – ",Fc(i.dates[i.dates.length-1])]})]}),c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.4rem",marginLeft:"auto",flexWrap:"wrap"},children:[c.jsx(hr,{onClick:()=>We(-7),children:"‹ Prev"}),c.jsx(hr,{onClick:At,primary:!0,children:"Today"}),c.jsx(hr,{onClick:()=>We(7),children:"Next ›"}),c.jsx("input",{type:"date",value:Pn,onChange:ne=>{if(ne.target.value){const me=ne.target.value;le.current=me,Ke(me),se(),oe("weekStart",()=>fe(!0),600)}},style:{border:"1px solid var(--card-border)",borderRadius:"6px",padding:"0.35rem 0.5rem",fontSize:"0.82rem",color:"var(--text-dark)"}}),c.jsx("div",{style:{width:"1px",height:"24px",background:"var(--card-border)"}}),c.jsxs("label",{style:{fontSize:"0.78rem",color:"var(--text-mid)",display:"flex",alignItems:"center",gap:"0.3rem"},children:[c.jsx("span",{children:"Since"}),c.jsx("input",{type:"date",value:Ee,onChange:ne=>{if(ne.target.value){const me=ne.target.value;Te(me),oe("lastViewed",()=>fe(!0,me),600)}},style:{border:"1px solid var(--card-border)",borderRadius:"6px",padding:"0.3rem 0.5rem",fontSize:"0.78rem",color:"var(--text-dark)"}})]}),c.jsx(hr,{onClick:()=>{se(),fe(!0)},children:"Update to now"}),c.jsx("div",{style:{width:"1px",height:"24px",background:"var(--card-border)"}}),c.jsx("button",{onClick:En,title:"Refresh",style:{background:"var(--card-bg)",border:"1px solid var(--card-border)",borderRadius:"6px",padding:"0.35rem 0.5rem",display:"flex",alignItems:"center",gap:"0.3rem",fontSize:"0.82rem",color:"var(--text-dark)"},children:c.jsx(Ns,{size:13,strokeWidth:1.75,style:{animation:Oe?"spin 1s linear infinite":"none"}})})]})]}),c.jsx("style",{children:"@keyframes spin { from { transform: rotate(0deg) } to { transform: rotate(360deg) } }"}),F&&c.jsx("div",{style:{display:"inline-block",marginBottom:"0.75rem",padding:"0.35rem 0.75rem",borderRadius:"6px",fontSize:"0.8rem",fontWeight:500,background:F.err?"#fee2e2":"#dcfce7",color:F.err?"var(--danger)":"var(--success)"},children:F.text}),W&&c.jsxs("div",{style:{marginBottom:"1rem",padding:"0.75rem 1rem",borderRadius:"8px",background:"#fee2e2",color:"var(--danger)",fontSize:"0.875rem"},children:["Error: ",W]}),Oe&&!i&&c.jsx("div",{style:{color:"var(--text-mid)",padding:"2rem 0",textAlign:"center"},children:"Loading bookings…"}),i&&_t&&c.jsxs(c.Fragment,{children:[c.jsx(So,{title:"7-Day Occupancy",children:c.jsx("div",{className:"table-scroll",children:c.jsx(om,{bookings:i,pickup:g,onPickupChange:$t})})}),c.jsx(So,{title:"Required Hours",children:c.jsx("div",{className:"table-scroll",children:c.jsx(am,{bookings:i,required:_t})})}),c.jsx(So,{title:"Adjustments",action:c.jsx(hr,{onClick:_n,children:"+ Add adjustment"}),children:c.jsx("div",{className:"table-scroll",children:c.jsx(fm,{bookings:i,adjustments:P,onChange:Vt})})}),c.jsx(So,{title:"Staff Rota",action:c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",flexWrap:"wrap"},children:[c.jsxs("button",{onClick:Nn,disabled:xe,style:{display:"flex",alignItems:"center",gap:"0.3rem",background:"var(--card-bg)",color:"var(--text-dark)",border:"1px solid var(--card-border)",borderRadius:"6px",padding:"0.3rem 0.65rem",fontSize:"0.78rem",fontWeight:600},children:[c.jsx(Ns,{size:11,strokeWidth:1.75,style:{animation:xe?"spin 1s linear infinite":"none"}}),xe?"Syncing…":"Sync from Workforce"]}),c.jsx("span",{style:{fontSize:"0.72rem",color:"var(--text-mid)"},children:tn()}),c.jsx(hr,{onClick:Ht,children:"+ Add staff"})]}),children:c.jsx("div",{className:"table-scroll",children:c.jsx(cm,{bookings:i,staff:p,required:_t,warnOverRed:M,warnOverAmber:K,warnUnderAmber:E,warnUnderRed:$,onChange:en,wfShifts:U,wfStaff:de})})})]})]})}function So({title:i,children:u,action:s}){return c.jsxs("div",{style:{marginBottom:"1.5rem"},children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",marginBottom:"0.5rem"},children:[c.jsx("h2",{style:{fontSize:"0.72rem",fontWeight:700,color:"var(--text-mid)",textTransform:"uppercase",letterSpacing:"0.08em"},children:i}),s]}),u]})}function hr({children:i,onClick:u,primary:s}){return c.jsx("button",{onClick:u,style:{background:s?"var(--hk-green)":"var(--card-bg)",color:s?"#fff":"var(--text-dark)",border:`1px solid ${s?"var(--hk-green)":"var(--card-border)"}`,borderRadius:"6px",padding:"0.35rem 0.75rem",fontSize:"0.82rem",fontWeight:600},children:i})}function om({bookings:i,pickup:u,onPickupChange:s}){const{dates:d,categories:p}=i;return c.jsxs("table",{className:"hk-table",children:[c.jsxs("thead",{children:[c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",rowSpan:2,children:"Category"}),d.map(h=>c.jsx("th",{colSpan:2,style:{borderLeft:"2px solid rgba(255,255,255,0.3)",...sl(h)?{background:"#253555"}:{}},children:To(h)},h))]}),c.jsx("tr",{children:d.map(h=>c.jsxs(c.Fragment,{children:[c.jsx("th",{style:{fontSize:"0.72rem",fontWeight:400,minWidth:"72px",background:sl(h)?"#2a3d5e":"#1e2d42",borderLeft:"2px solid rgba(255,255,255,0.3)"},children:"Rooms"},h+"-r"),c.jsx("th",{style:{fontSize:"0.72rem",fontWeight:400,minWidth:"56px",textAlign:"center",background:sl(h)?"#2a3d5e":"#1e2d42",borderLeft:"1px solid rgba(255,255,255,0.1)"},children:"D / S / A"},h+"-d")]}))})]}),c.jsx("tbody",{children:p.map((h,g)=>{const j=g===p.length-1;return c.jsx(im,{cat:h,dates:d,pickup:u,onPickupChange:(w,_)=>s(h.id,w,_,h),isLast:j},h.id)})}),c.jsx("tfoot",{children:c.jsx(sm,{dates:d,cats:p,pickup:u})})]})}function im({cat:i,dates:u,pickup:s,onPickupChange:d,isLast:p}){const h=p?"2px solid var(--card-border)":void 0;return c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{borderBottom:h},children:i.name}),u.map((g,j)=>{var ce;const w=i.days[g],_=w.stays+w.arrivals,P=Math.max(0,i.total_rooms-_),N=gr(s,i.id,g,_,i.total_rooms),M=u[j-1],H=M?i.days[M].stays+i.days[M].arrivals:0,K=M?gr(s,i.id,M,H,i.total_rooms):0,T=w.delta_new||0,E=w.delta_cancelled||0,A=sl(g),$=(ce=s[i.id])==null?void 0:ce[g],G=nm(g,w);let U="";if($&&$.count){const de=$.total-$.count,Ce=_>de?"changed":"unchanged",xe=_>de?"decreased":"remains";U=`+${$.count} pickup set when booked was ${de} (target ${$.total}). Booked ${Ce}, so pickup ${xe}.`}return U=(U?U+" | ":"")+G,c.jsxs(c.Fragment,{children:[c.jsxs("td",{style:{textAlign:"center",verticalAlign:"middle",borderBottom:h,padding:"0.4rem 0.3rem",borderLeft:"2px solid var(--card-border)",...A?{background:"rgba(100,120,160,0.07)"}:{}},children:[(T>0||E>0)&&c.jsxs("div",{style:{marginBottom:"2px",fontSize:"0.72rem"},children:[T>0&&c.jsxs("span",{className:"delta-new",children:["▲",T]}),E>0&&c.jsxs("span",{className:"delta-canc",children:[" ▼",E]})]}),c.jsxs("div",{style:{fontWeight:700,fontSize:"1.1rem"},title:U,children:[_,N>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",N]})]}),c.jsxs("div",{style:{fontSize:"0.72rem",color:"var(--text-mid)",marginBottom:"4px"},children:[P," vac",N>0&&c.jsxs("span",{className:"pickup-tag",children:[" (",P-N,")"]})]}),c.jsxs("div",{className:"pickup-ctrl",children:[c.jsx("button",{className:"pickup-btn",disabled:N<=0,onClick:()=>d(g,-1),children:"−"}),c.jsx("span",{className:"pickup-num",children:N}),c.jsx("button",{className:"pickup-btn",disabled:N>=P,title:G,onClick:()=>d(g,1),children:"+"})]})]},g+"-r"),c.jsxs("td",{style:{verticalAlign:"middle",borderLeft:"1px solid var(--card-border)",borderBottom:h,padding:"0.4rem 0.3rem",textAlign:"center",...A?{background:"rgba(100,120,160,0.07)"}:{}},children:[c.jsxs("div",{style:{fontSize:"0.8rem",color:"#c2502e",fontWeight:600},children:[w.departs,"d",K>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",K]})]}),c.jsxs("div",{style:{fontSize:"0.8rem",color:"#1d6fb8",fontWeight:600},children:[w.stays,"s"]}),c.jsxs("div",{style:{fontSize:"0.8rem",color:"#1a7a4a",fontWeight:600},children:[w.arrivals,"a",N>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",N]})]})]},g+"-dsa")]})})]})}function sm({dates:i,cats:u,pickup:s}){return c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontStyle:"italic"},children:"Total"}),i.map((d,p)=>{let h=0,g=0,j=0,w=0,_=0,P=0,N=0,M=0,H=0;for(const T of u){const E=T.days[d],A=E.stays+E.arrivals,$=Math.max(0,T.total_rooms-A),G=gr(s,T.id,d,A,T.total_rooms),U=i[p-1],ce=U?T.days[U].stays+T.days[U].arrivals:0,de=U?gr(s,T.id,U,ce,T.total_rooms):0;h+=A,g+=$,j+=G,w+=de,_+=E.departs,P+=E.stays,N+=E.arrivals,M+=E.delta_new||0,H+=E.delta_cancelled||0}const K=sl(d);return c.jsxs(c.Fragment,{children:[c.jsxs("td",{style:{textAlign:"center",verticalAlign:"middle",padding:"0.4rem 0.3rem",borderLeft:"2px solid var(--card-border)",...K?{background:"rgba(100,120,160,0.07)"}:{}},children:[(M>0||H>0)&&c.jsxs("div",{style:{marginBottom:"2px",fontSize:"0.72rem"},children:[M>0&&c.jsxs("span",{className:"delta-new",children:["▲",M]}),H>0&&c.jsxs("span",{className:"delta-canc",children:[" ▼",H]})]}),c.jsxs("div",{style:{fontWeight:700,fontSize:"1.1rem"},children:[h,j>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",j]})]}),c.jsxs("div",{style:{fontSize:"0.72rem",color:"var(--text-mid)"},children:[g," vac",j>0&&c.jsxs("span",{className:"pickup-tag",children:[" (",g-j,")"]})]})]},d+"-r"),c.jsxs("td",{style:{verticalAlign:"middle",borderLeft:"1px solid var(--card-border)",padding:"0.4rem 0.3rem",textAlign:"center",...K?{background:"rgba(100,120,160,0.07)"}:{}},children:[c.jsxs("div",{style:{fontSize:"0.8rem",color:"#c2502e",fontWeight:600},children:[_,"d",w>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",w]})]}),c.jsxs("div",{style:{fontSize:"0.8rem",color:"#1d6fb8",fontWeight:600},children:[P,"s"]}),c.jsxs("div",{style:{fontSize:"0.8rem",color:"#1a7a4a",fontWeight:600},children:[N,"a",j>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",j]})]})]},d+"-dsa")]})})]})}function am({bookings:i,required:u}){const{dates:s,categories:d}=i;return c.jsxs("table",{className:"hk-table",children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",children:"Category"}),s.map(p=>c.jsx("th",{children:To(p)},p))]})}),c.jsx("tbody",{children:d.map(p=>c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",children:p.name}),s.map(h=>{const g=u[h].by_cat[p.id]||0,j=u[h].pickup_by_cat[p.id]||0;return c.jsxs("td",{children:[g===0&&j===0?"—":Ge(g),j>.001&&c.jsxs("span",{className:"pickup-tag",children:[" (+",Ge(j),")"]})]},h)})]},p.id))}),c.jsxs("tfoot",{children:[c.jsxs("tr",{style:{background:"#f1f5f9"},children:[c.jsx("td",{className:"col-label",style:{color:"var(--text-mid)",fontSize:"0.78rem"},children:"Booked hrs"}),s.map(p=>c.jsx("td",{children:Ge(u[p].booked)},p))]}),c.jsxs("tr",{style:{background:"#f1f5f9"},children:[c.jsx("td",{className:"col-label",style:{color:"var(--text-mid)",fontSize:"0.78rem"},children:"Pickup hrs"}),s.map(p=>c.jsx("td",{children:u[p].pickup>.001?Ge(u[p].pickup):"—"},p))]}),c.jsxs("tr",{style:{background:"#f1f5f9"},children:[c.jsx("td",{className:"col-label",style:{color:"var(--text-mid)",fontSize:"0.78rem"},children:"Recurring tasks"}),s.map(p=>c.jsx("td",{children:u[p].general>.001?Ge(u[p].general):"—"},p))]}),s.some(p=>u[p].adjustments!==0)&&c.jsxs("tr",{style:{background:"#f1f5f9"},children:[c.jsx("td",{className:"col-label",style:{color:"var(--text-mid)",fontSize:"0.78rem"},children:"Adjustments"}),s.map(p=>{const h=u[p].adjustments;return c.jsx("td",{style:{color:h<0?"var(--danger)":h>0?"#1a7a4a":"var(--text-mid)"},children:h===0?"—":(h>0?"+":"")+Ge(h)},p)})]}),c.jsxs("tr",{style:{background:"#e2e8f0"},children:[c.jsx("td",{className:"col-label",children:"Total Required"}),s.map(p=>c.jsxs("td",{style:{fontWeight:700},children:[Ge(u[p].total),u[p].pickup>.001&&c.jsxs("span",{className:"pickup-tag",style:{display:"block",fontSize:"0.7rem"},children:["inc ",Ge(u[p].pickup)," pickup"]})]},p))]})]})]})}function um(i,u){const s={};for(const d of u){const p=i[d];if(p)for(const h of p.staff)s[h.id]||(s[h.id]={id:h.id,name:h.name,days:{}}),s[h.id].days[d]={hours:h.hours,times:h.times}}return Object.values(s).sort((d,p)=>d.name.localeCompare(p.name))}function cm({bookings:i,staff:u,required:s,warnOverRed:d,warnOverAmber:p,warnUnderAmber:h,warnUnderRed:g,onChange:j,wfShifts:w,wfStaff:_}){const{dates:P}=i;function N(T,E){const A=u.map(($,G)=>G===T?{...$,name:E}:$);j(A)}function M(T,E,A){const $=parseFloat(A),G=u.map((U,ce)=>{if(ce!==T)return U;const de={...U.hours};return!isNaN($)&&$>=0?de[E]=$:delete de[E],{...U,hours:de}});j(G)}function H(T){j(u.filter((E,A)=>A!==T))}const K=um(w,P);return c.jsxs("table",{className:"hk-table",children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",children:"Staff Member"}),P.map(T=>c.jsx("th",{children:To(T)},T)),c.jsx("th",{style:{width:"32px"}})]})}),c.jsxs("tbody",{children:[K.map(T=>c.jsxs("tr",{style:{background:"rgba(42,100,72,0.05)"},children:[c.jsxs("td",{className:"col-label",children:[c.jsx("span",{style:{display:"inline-block",fontSize:"0.67rem",fontWeight:700,background:"rgba(42,100,72,0.18)",color:"#1a7a4a",borderRadius:"3px",padding:"0 4px",marginRight:"0.4rem",lineHeight:"1.5"},children:"WF"}),T.name]}),P.map(E=>{const A=T.days[E];return c.jsx("td",{style:{textAlign:"center",padding:"0.3rem 0.4rem",verticalAlign:"middle"},children:A?c.jsxs(c.Fragment,{children:[c.jsx("div",{style:{fontSize:"0.68rem",color:"var(--text-mid)",lineHeight:1.25},children:A.times}),c.jsx("div",{style:{fontWeight:600},children:Ge(A.hours)})]}):c.jsx("span",{style:{color:"var(--text-mid)"},children:"—"})},E)}),c.jsx("td",{})]},"wf-"+T.id)),_.length>0&&c.jsx("datalist",{id:"wf-staff-datalist",children:_.map(T=>c.jsx("option",{value:T.name},T.id))}),u.map((T,E)=>c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{padding:"0.3rem 0.5rem"},children:c.jsx("input",{className:"hk-text-input",value:T.name,placeholder:"Staff name",list:_.length>0?"wf-staff-datalist":void 0,onChange:A=>N(E,A.target.value)})}),P.map(A=>c.jsx("td",{style:{padding:"0.3rem 0.4rem"},children:c.jsx("input",{type:"number",className:"hk-num-input",min:0,max:24,step:.5,value:T.hours[A]??"",placeholder:"0",onChange:$=>M(E,A,$.target.value)})},A)),c.jsx("td",{children:c.jsx("button",{onClick:()=>H(E),style:{background:"none",border:"none",color:"var(--text-mid)",fontSize:"1rem",padding:"0.2rem 0.4rem"},children:"×"})})]},E))]}),c.jsx("tfoot",{children:(()=>{const T={};for(const E of P){const A=K.reduce((G,U)=>{var ce;return G+(((ce=U.days[E])==null?void 0:ce.hours)||0)},0),$=u.reduce((G,U)=>G+(U.hours[E]||0),0);T[E]=A+$}return c.jsxs(c.Fragment,{children:[c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontSize:"0.78rem",color:"var(--text-mid)"},children:"Total Available"}),P.map(E=>c.jsx("td",{children:Ge(T[E])},E)),c.jsx("td",{})]}),c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontSize:"0.72rem",color:"var(--text-mid)"},children:"vs Booked"}),P.map(E=>c.jsx("td",{children:c.jsx(Ss,{available:T[E],required:s[E].booked,warnOverAmber:p,warnUnderAmber:h})},E)),c.jsx("td",{})]}),c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontSize:"0.72rem",color:"var(--text-mid)"},children:"with Recurring Tasks"}),P.map(E=>c.jsx("td",{children:c.jsx(Ss,{available:T[E],required:s[E].booked+s[E].general,warnOverAmber:p,warnUnderAmber:h})},E)),c.jsx("td",{})]}),c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontSize:"0.72rem",color:"var(--text-mid)"},children:"with Pickup"}),P.map(E=>c.jsx("td",{children:c.jsx(Ss,{available:T[E],required:s[E].booked+s[E].general+s[E].pickup,warnOverAmber:p,warnUnderAmber:h})},E)),c.jsx("td",{})]}),c.jsxs("tr",{style:{background:"#e2e8f0"},children:[c.jsx("td",{className:"col-label",style:{fontWeight:700},children:"with Adjustments"}),P.map(E=>c.jsx("td",{children:c.jsx(dm,{available:T[E],required:s[E].total,warnOverRed:d,warnOverAmber:p,warnUnderAmber:h,warnUnderRed:g})},E)),c.jsx("td",{})]})]})})()})]})}function Ss({available:i,required:u,warnOverAmber:s,warnUnderAmber:d}){if(i===0&&u===0)return c.jsx("span",{style:{color:"var(--text-mid)"},children:"—"});const p=i-u,h=p>s?"⚠":p<-d?"✗":"✓";return c.jsxs("span",{style:{color:"var(--text-mid)",fontSize:"0.82rem"},children:[h," ",p>=0?"+":"",Ge(p)]})}function dm({available:i,required:u,warnOverRed:s,warnOverAmber:d,warnUnderAmber:p,warnUnderRed:h}){if(i===0&&u===0)return c.jsx("span",{style:{color:"var(--text-mid)"},children:"—"});const g=i-u;return g>s?c.jsxs("span",{className:"diff-over-red",children:["⚠ ",Ge(g)," spare"]}):g>d?c.jsxs("span",{className:"diff-over",children:["⚠ ",Ge(g)," spare"]}):g<-h?c.jsxs("span",{className:"diff-under",children:["✗ ",Ge(Math.abs(g))," short"]}):g<-p?c.jsxs("span",{className:"diff-under-amber",children:["✗ ",Ge(Math.abs(g))," short"]}):c.jsxs("span",{className:"diff-ok",children:["✓ ",g>=0?"+":"",Ge(g)]})}function fm({bookings:i,adjustments:u,onChange:s}){const{dates:d}=i;function p(j,w){s(u.map((_,P)=>P===j?{..._,label:w}:_))}function h(j,w,_){const P=parseFloat(_);s(u.map((N,M)=>{if(M!==j)return N;const H={...N.hours};return isNaN(P)?delete H[w]:H[w]=P,{...N,hours:H}}))}function g(j){s(u.filter((w,_)=>_!==j))}return u.length===0?c.jsx("p",{style:{color:"var(--text-mid)",fontSize:"0.82rem",padding:"0.5rem 0"},children:'No adjustments — use "+ Add adjustment" above to add a one-off hour offset for a specific date.'}):c.jsxs("table",{className:"hk-table",children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",children:"Label"}),d.map(j=>c.jsx("th",{children:To(j)},j)),c.jsx("th",{style:{width:"32px"}})]})}),c.jsx("tbody",{children:u.map((j,w)=>c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{padding:"0.3rem 0.5rem"},children:c.jsx("input",{className:"hk-text-input",value:j.label,placeholder:"e.g. Rooms from Sunday",onChange:_=>p(w,_.target.value)})}),d.map(_=>c.jsx("td",{style:{padding:"0.3rem 0.4rem"},children:c.jsx("input",{type:"number",className:"hk-num-input",step:.25,value:j.hours[_]??"",placeholder:"0",onChange:P=>h(w,_,P.target.value)})},_)),c.jsx("td",{children:c.jsx("button",{onClick:()=>g(w),style:{background:"none",border:"none",color:"var(--text-mid)",fontSize:"1rem",padding:"0.2rem 0.4rem"},children:"×"})})]},w))}),c.jsx("tfoot",{children:c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontSize:"0.78rem",color:"var(--text-mid)"},children:"Total"}),d.map(j=>{const w=u.reduce((_,P)=>_+(P.hours[j]||0),0);return c.jsx("td",{style:{color:w<0?"var(--danger)":w>0?"#1a7a4a":"var(--text-mid)",fontWeight:w!==0?600:void 0},children:w===0?"—":(w>0?"+":"")+Ge(w)},j)}),c.jsx("td",{})]})})]})}const Uc=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];function pm(){const[i,u]=S.useState([]),[s,d]=S.useState(!0),[p,h]=S.useState(!1),[g,j]=S.useState(!1),[w,_]=S.useState(""),[P,N]=S.useState(""),[M,H]=S.useState(null),[K,T]=S.useState([]),[E,A]=S.useState([]),[$,G]=S.useState(!0),[U,ce]=S.useState(""),[de,Ce]=S.useState(!1),[xe,Ze]=S.useState(!1),[Ie,Ke]=S.useState(""),[Ee,Te]=S.useState([]),[Be,qe]=S.useState(!1),[Oe,ve]=S.useState(""),[W,X]=S.useState(""),[F,y]=S.useState({}),[R,ee]=S.useState(""),[re,le]=S.useState(""),[oe,ae]=S.useState(4),[se,fe]=S.useState(1),[We,At]=S.useState(1),[En,$t]=S.useState(2),[Vt,_n]=S.useState(!1),[en,Ht]=S.useState(""),[Nn,tn]=S.useState("");S.useEffect(()=>{Promise.all([Qh(),td(),Jh().catch(I=>(I.message.includes("503")||I.message.toLowerCase().includes("not configured")?Ce(!0):ce(I.message),null))]).then(([I,te,ie])=>{u(I.categories),Te(te.general_tasks||[]),y(te.time_requirements||{}),A(te.workforce_departments||[]),ae(te.warn_over_red_hrs??4),fe(te.warn_over_amber_hrs??1),At(te.warn_under_amber_hrs??1),$t(te.warn_under_red_hrs??2),ie&&T(ie),d(!1),G(!1)}).catch(I=>{_(I.message),d(!1),G(!1)})},[]);function _t(I){u(i.map((te,ie)=>ie===I?{...te,excluded:!te.excluded}:te))}function Dt(I,te){H(te),I.dataTransfer.effectAllowed="move"}function Pn(I,te){if(I.preventDefault(),M===null||M===te)return;const ie=[...i],[De]=ie.splice(M,1);ie.splice(te,0,De),u(ie),H(te)}function ne(){H(null)}async function me(){h(!0),_(""),N("");try{await Kh(i.map(I=>I.id),i.filter(I=>I.excluded).map(I=>I.id)),N("Saved"),setTimeout(()=>N(""),2500)}catch(I){_(I instanceof Error?I.message:"Save failed")}finally{h(!1)}}async function Ae(){j(!0),_(""),N("");try{const I=await Yh();N(I.ok?`Connection OK: ${I.message||""}`:`Failed: ${I.error||"unknown"}`)}catch(I){_(I instanceof Error?I.message:"Test failed")}finally{j(!1)}}function rt(I){A(te=>te.includes(I)?te.filter(ie=>ie!==I):[...te,I])}async function ft(){Ze(!0),ce(""),Ke("");try{await Gh(E),Ke("Departments saved"),setTimeout(()=>Ke(""),2500)}catch(I){ce(I instanceof Error?I.message:"Save failed")}finally{Ze(!1)}}function pt(I,te){Te(Ee.map((ie,De)=>De===I?{...ie,name:te}:ie))}function $e(I,te,ie){const De=parseInt(ie,10);Te(Ee.map((xt,kr)=>kr!==I?xt:{...xt,hours:{...xt.hours,[te]:isNaN(De)?0:Math.max(0,De)}}))}function we(I){Te(Ee.filter((te,ie)=>ie!==I))}async function yt(){qe(!0),X(""),ve("");try{await Vh(Ee),ve("Saved"),setTimeout(()=>ve(""),2500)}catch(I){X(I instanceof Error?I.message:"Save failed")}finally{qe(!1)}}async function Tn(I,te,ie){const De={...F,[I]:{...F[I]||{depart:0,stay:0,arrive:0},[te]:ie}};y(De);try{await Bh(I,te,ie),ee("Saved"),setTimeout(()=>ee(""),1500)}catch(xt){le(xt instanceof Error?xt.message:"Save failed")}}async function Vn(){_n(!0),tn(""),Ht("");try{await bh({warn_over_red_hrs:oe,warn_over_amber_hrs:se,warn_under_amber_hrs:We,warn_under_red_hrs:En}),Ht("Saved"),setTimeout(()=>Ht(""),2500)}catch(I){tn(I instanceof Error?I.message:"Save failed")}finally{_n(!1)}}return s?c.jsx("div",{style:{padding:"2rem",color:"var(--text-mid)"},children:"Loading…"}):c.jsxs("div",{style:{padding:"1.5rem",maxWidth:"680px"},children:[c.jsx("h1",{style:{fontSize:"1.1rem",fontWeight:700,color:"var(--text-dark)",marginBottom:"1.5rem"},children:"Settings"}),c.jsx(ol,{title:"Room Categories"}),c.jsx("p",{style:{fontSize:"0.82rem",color:"var(--text-mid)",marginBottom:"1rem"},children:"Drag to reorder. Toggle to exclude categories from the planner."}),w&&c.jsx(Bt,{type:"error",children:w}),P&&c.jsx(Bt,{type:"ok",children:P}),c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:i.map((I,te)=>c.jsxs("div",{draggable:!0,onDragStart:ie=>Dt(ie,te),onDragOver:ie=>Pn(ie,te),onDragEnd:ne,style:{display:"flex",alignItems:"center",gap:"0.75rem",padding:"0.625rem 0.875rem",border:"1px solid var(--card-border)",borderRadius:"8px",background:I.excluded?"#f8fafc":"var(--card-bg)",opacity:M===te?.5:1},children:[c.jsx(Eh,{size:16,color:"var(--text-mid)",style:{cursor:"grab",flexShrink:0}}),c.jsx("span",{style:{flex:1,fontSize:"0.9rem",color:I.excluded?"var(--text-mid)":"var(--text-dark)",textDecoration:I.excluded?"line-through":"none"},children:I.name}),c.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--text-mid)",marginRight:"0.5rem"},children:[I.room_count," rooms"]}),c.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.375rem",fontSize:"0.8rem",color:"var(--text-mid)"},children:[c.jsx("input",{type:"checkbox",checked:!I.excluded,onChange:()=>_t(te)}),"Active"]})]},I.id))}),c.jsxs("div",{style:{display:"flex",gap:"0.75rem",flexWrap:"wrap",marginBottom:"2.5rem"},children:[c.jsx(mr,{onClick:me,disabled:p,primary:!0,children:p?"Saving…":"Save Order & Visibility"}),c.jsx(mr,{onClick:Ae,disabled:g,children:g?"Testing…":"Test Newbook Connection"})]}),c.jsx(jo,{}),c.jsx(ol,{title:"Workforce Departments"}),c.jsx("p",{style:{fontSize:"0.82rem",color:"var(--text-mid)",marginBottom:"1rem"},children:"Select the department(s) whose shifts should appear in the HK staff rota."}),de&&c.jsxs("div",{style:{padding:"0.75rem",borderRadius:"8px",background:"#f8fafc",border:"1px solid var(--card-border)",color:"var(--text-mid)",fontSize:"0.85rem",marginBottom:"2rem"},children:["Workforce integration not configured — add the bearer token in ",c.jsx("strong",{children:"Settings → Integrations → Workforce"}),"."]}),!de&&$&&c.jsx("div",{style:{color:"var(--text-mid)",fontSize:"0.85rem",marginBottom:"2rem"},children:"Loading departments…"}),!de&&!$&&c.jsxs("div",{style:{marginBottom:"2.5rem"},children:[U&&c.jsx(Bt,{type:"error",children:U}),Ie&&c.jsx(Bt,{type:"ok",children:Ie}),K.length===0?c.jsx("div",{style:{color:"var(--text-mid)",fontSize:"0.85rem",marginBottom:"1rem"},children:"No departments found for this location."}):c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.4rem",marginBottom:"1rem"},children:K.map(I=>c.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.625rem",padding:"0.5rem 0.75rem",border:"1px solid var(--card-border)",borderRadius:"7px",background:E.includes(I.id)?"rgba(42,100,72,0.05)":"var(--card-bg)",cursor:"pointer",fontSize:"0.9rem",color:"var(--text-dark)"},children:[c.jsx("input",{type:"checkbox",checked:E.includes(I.id),onChange:()=>rt(I.id)}),I.name]},I.id))}),E.length===0&&K.length>0&&c.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"#b45309"},children:"Select at least one department to enable Workforce sync."}),c.jsx(mr,{onClick:ft,disabled:xe,primary:!0,children:xe?"Saving…":"Save Departments"})]}),c.jsx(jo,{}),c.jsx(ol,{title:"Recurring General Tasks"}),c.jsx("p",{style:{fontSize:"0.82rem",color:"var(--text-mid)",marginBottom:"1rem"},children:"Tasks that recur every week. Enter minutes per day. These add to the total required hours every week."}),W&&c.jsx(Bt,{type:"error",children:W}),Oe&&c.jsx(Bt,{type:"ok",children:Oe}),c.jsx("div",{style:{overflowX:"auto",marginBottom:"1rem"},children:c.jsxs("table",{className:"hk-table",style:{minWidth:"560px"},children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",children:"Task"}),Uc.map(I=>c.jsx("th",{children:I},I)),c.jsx("th",{style:{width:"32px"}})]})}),c.jsxs("tbody",{children:[Ee.length===0&&c.jsx("tr",{children:c.jsx("td",{colSpan:9,style:{color:"var(--text-mid)",textAlign:"center",padding:"1rem"},children:"No tasks yet"})}),Ee.map((I,te)=>c.jsxs("tr",{children:[c.jsx("td",{style:{padding:"0.3rem 0.5rem"},children:c.jsx("input",{className:"hk-text-input",value:I.name,placeholder:"Task name",onChange:ie=>pt(te,ie.target.value)})}),Uc.map(ie=>c.jsx("td",{style:{padding:"0.3rem 0.4rem"},children:c.jsx("input",{type:"number",className:"hk-num-input",min:0,max:999,value:I.hours[ie]||"",placeholder:"0",onChange:De=>$e(te,ie,De.target.value)})},ie)),c.jsx("td",{children:c.jsx("button",{onClick:()=>we(te),style:{background:"none",border:"none",color:"var(--text-mid)",fontSize:"1rem",padding:"0.2rem 0.4rem"},children:"×"})})]},te))]})]})}),c.jsxs("div",{style:{display:"flex",gap:"0.75rem",flexWrap:"wrap",marginBottom:"2.5rem"},children:[c.jsx(mr,{onClick:()=>Te([...Ee,{name:"",hours:{}}]),children:"+ Add task"}),c.jsx(mr,{onClick:yt,disabled:Be,primary:!0,children:Be?"Saving…":"Save Tasks"})]}),c.jsx(jo,{}),c.jsx(ol,{title:"Time Requirements (minutes per room)"}),c.jsx("p",{style:{fontSize:"0.82rem",color:"var(--text-mid)",marginBottom:"1rem"},children:"How many minutes each room type takes depending on guest status."}),re&&c.jsx(Bt,{type:"error",children:re}),R&&c.jsx(Bt,{type:"ok",children:R}),c.jsx("div",{style:{overflowX:"auto",marginBottom:"2rem"},children:c.jsxs("table",{className:"hk-table",style:{maxWidth:"500px"},children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",children:"Category"}),c.jsx("th",{children:"Depart (mins)"}),c.jsx("th",{children:"Stay (mins)"}),c.jsx("th",{children:"Arrive (mins)"})]})}),c.jsx("tbody",{children:i.filter(I=>!I.excluded).map(I=>{const te=F[I.id]||{depart:0,stay:0,arrive:0};return c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",children:I.name}),["depart","stay","arrive"].map(ie=>c.jsx("td",{style:{padding:"0.3rem 0.4rem"},children:c.jsx("input",{type:"number",className:"hk-num-input",min:0,max:999,value:te[ie]||"",placeholder:"0",onChange:De=>Tn(I.id,ie,parseInt(De.target.value,10)||0),onBlur:De=>Tn(I.id,ie,parseInt(De.target.value,10)||0)})},ie))]},I.id)})})]})}),c.jsx(jo,{}),c.jsx(ol,{title:"Warning Thresholds"}),c.jsx("p",{style:{fontSize:"0.82rem",color:"var(--text-mid)",marginBottom:"1rem"},children:'Controls the colour and icon shown on the "with Adjustments" row in the staff rota. All values are in hours.'}),Nn&&c.jsx(Bt,{type:"error",children:Nn}),en&&c.jsx(Bt,{type:"ok",children:en}),c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.625rem",marginBottom:"1.25rem",maxWidth:"420px"},children:[{label:"⚠ Red warning — spare over",value:oe,set:ae,help:"default 4h"},{label:"⚠ Amber warning — spare over",value:se,set:fe,help:"default 1h"},{label:"✗ Amber cross — short over",value:We,set:At,help:"default 1h"},{label:"✗ Red cross — short over",value:En,set:$t,help:"default 2h"}].map(({label:I,value:te,set:ie,help:De})=>c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[c.jsx("span",{style:{flex:1,fontSize:"0.875rem",color:"var(--text-dark)"},children:I}),c.jsx("input",{type:"number",className:"hk-num-input",min:0,max:24,step:.5,value:te,onChange:xt=>ie(parseFloat(xt.target.value)||0),style:{width:"68px"}}),c.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-mid)",minWidth:"52px"},children:De})]},I))}),c.jsx("p",{style:{fontSize:"0.78rem",color:"var(--text-mid)",marginBottom:"1rem"},children:"Green ✓ is automatic — shown when the difference is within the amber spare and short thresholds above."}),c.jsx("div",{style:{marginBottom:"2.5rem"},children:c.jsx(mr,{onClick:Vn,disabled:Vt,primary:!0,children:Vt?"Saving…":"Save Thresholds"})})]})}function ol({title:i}){return c.jsx("h2",{style:{fontSize:"0.95rem",fontWeight:700,color:"var(--text-dark)",marginBottom:"0.25rem"},children:i})}function jo(){return c.jsx("div",{style:{height:"1px",background:"var(--card-border)",margin:"0.5rem 0 2rem"}})}function Bt({type:i,children:u}){return c.jsx("div",{style:{marginBottom:"0.75rem",padding:"0.75rem",borderRadius:"8px",fontSize:"0.875rem",background:i==="ok"?"#dcfce7":"#fee2e2",color:i==="ok"?"var(--success)":"var(--danger)"},children:u})}function mr({children:i,onClick:u,disabled:s,primary:d}){return c.jsx("button",{onClick:u,disabled:s,style:{background:d?"var(--hk-green)":"var(--card-bg)",color:d?"#fff":"var(--text-dark)",border:`1px solid ${d?"var(--hk-green)":"var(--card-border)"}`,borderRadius:"6px",padding:"0.5rem 1.25rem",fontSize:"0.875rem",fontWeight:600},children:i})}function hm({user:i}){return c.jsx(Wh,{user:i,children:c.jsxs(qp,{children:[c.jsx(il,{path:"/",element:c.jsx(ws,{to:"/planner",replace:!0})}),c.jsx(il,{path:"/planner",element:c.jsx(lm,{})}),c.jsx(il,{path:"/settings",element:ed(i,"settings")?c.jsx(pm,{}):c.jsx(ws,{to:"/planner",replace:!0})}),c.jsx(il,{path:"*",element:c.jsx(ws,{to:"/planner",replace:!0})})]})})}function mm(){const i=Oh("/hk-planner/health");return c.jsxs(c.Fragment,{children:[c.jsx(ih,{basename:"/hk-planner",children:c.jsx(vh,{children:u=>c.jsx(hm,{user:u})})}),c.jsx(zh,{visible:i})]})}new URLSearchParams(window.location.search).has("install")&&window.addEventListener("beforeinstallprompt",i=>{i.preventDefault(),i.prompt()},{once:!0});ap.createRoot(document.getElementById("root")).render(c.jsx(S.StrictMode,{children:c.jsx(mm,{})})); diff --git a/frontend/dist/assets/index-DOMhnWTP.js b/frontend/dist/assets/index-DOMhnWTP.js deleted file mode 100644 index f9fe182..0000000 --- a/frontend/dist/assets/index-DOMhnWTP.js +++ /dev/null @@ -1,127 +0,0 @@ -function Xf(i,u){for(var a=0;ad[p]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}(function(){const u=document.createElement("link").relList;if(u&&u.supports&&u.supports("modulepreload"))return;for(const p of document.querySelectorAll('link[rel="modulepreload"]'))d(p);new MutationObserver(p=>{for(const h of p)if(h.type==="childList")for(const g of h.addedNodes)g.tagName==="LINK"&&g.rel==="modulepreload"&&d(g)}).observe(document,{childList:!0,subtree:!0});function a(p){const h={};return p.integrity&&(h.integrity=p.integrity),p.referrerPolicy&&(h.referrerPolicy=p.referrerPolicy),p.crossOrigin==="use-credentials"?h.credentials="include":p.crossOrigin==="anonymous"?h.credentials="omit":h.credentials="same-origin",h}function d(p){if(p.ep)return;p.ep=!0;const h=a(p);fetch(p.href,h)}})();function Zf(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var ps={exports:{}},ll={},hs={exports:{}},ue={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var mc;function qf(){if(mc)return ue;mc=1;var i=Symbol.for("react.element"),u=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),d=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),h=Symbol.for("react.provider"),g=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),_=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),N=Symbol.iterator;function M(y){return y===null||typeof y!="object"?null:(y=N&&y[N]||y["@@iterator"],typeof y=="function"?y:null)}var H={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},K=Object.assign,R={};function E(y,T,ee){this.props=y,this.context=T,this.refs=R,this.updater=ee||H}E.prototype.isReactComponent={},E.prototype.setState=function(y,T){if(typeof y!="object"&&typeof y!="function"&&y!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,y,T,"setState")},E.prototype.forceUpdate=function(y){this.updater.enqueueForceUpdate(this,y,"forceUpdate")};function A(){}A.prototype=E.prototype;function $(y,T,ee){this.props=y,this.context=T,this.refs=R,this.updater=ee||H}var G=$.prototype=new A;G.constructor=$,K(G,E.prototype),G.isPureReactComponent=!0;var B=Array.isArray,ce=Object.prototype.hasOwnProperty,de={current:null},je={key:!0,ref:!0,__self:!0,__source:!0};function xe(y,T,ee){var re,le={},oe=null,ae=null;if(T!=null)for(re in T.ref!==void 0&&(ae=T.ref),T.key!==void 0&&(oe=""+T.key),T)ce.call(T,re)&&!je.hasOwnProperty(re)&&(le[re]=T[re]);var se=arguments.length-2;if(se===1)le.children=ee;else if(1>>1,T=W[y];if(0>>1;yp(le,F))oep(ae,le)?(W[y]=ae,W[oe]=F,y=oe):(W[y]=le,W[re]=F,y=re);else if(oep(ae,F))W[y]=ae,W[oe]=F,y=oe;else break e}}return X}function p(W,X){var F=W.sortIndex-X.sortIndex;return F!==0?F:W.id-X.id}if(typeof performance=="object"&&typeof performance.now=="function"){var h=performance;i.unstable_now=function(){return h.now()}}else{var g=Date,j=g.now();i.unstable_now=function(){return g.now()-j}}var k=[],_=[],P=1,N=null,M=3,H=!1,K=!1,R=!1,E=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,$=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function G(W){for(var X=a(_);X!==null;){if(X.callback===null)d(_);else if(X.startTime<=W)d(_),X.sortIndex=X.expirationTime,u(k,X);else break;X=a(_)}}function B(W){if(R=!1,G(W),!K)if(a(k)!==null)K=!0,Le(ce);else{var X=a(_);X!==null&&me(B,X.startTime-W)}}function ce(W,X){K=!1,R&&(R=!1,A(xe),xe=-1),H=!0;var F=M;try{for(G(X),N=a(k);N!==null&&(!(N.expirationTime>X)||W&&!He());){var y=N.callback;if(typeof y=="function"){N.callback=null,M=N.priorityLevel;var T=y(N.expirationTime<=X);X=i.unstable_now(),typeof T=="function"?N.callback=T:N===a(k)&&d(k),G(X)}else d(k);N=a(k)}if(N!==null)var ee=!0;else{var re=a(_);re!==null&&me(B,re.startTime-X),ee=!1}return ee}finally{N=null,M=F,H=!1}}var de=!1,je=null,xe=-1,Je=5,Ie=-1;function He(){return!(i.unstable_now()-IeW||125y?(W.sortIndex=F,u(_,W),a(k)===null&&W===a(_)&&(R?(A(xe),xe=-1):R=!0,me(B,F-y))):(W.sortIndex=T,u(k,W),K||H||(K=!0,Le(ce))),W},i.unstable_shouldYield=He,i.unstable_wrapCallback=function(W){var X=M;return function(){var F=M;M=X;try{return W.apply(this,arguments)}finally{M=F}}}})(gs)),gs}var kc;function lp(){return kc||(kc=1,vs.exports=rp()),vs.exports}/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var wc;function op(){if(wc)return ct;wc=1;var i=Ps(),u=lp();function a(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),k=Object.prototype.hasOwnProperty,_=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,P={},N={};function M(e){return k.call(N,e)?!0:k.call(P,e)?!1:_.test(e)?N[e]=!0:(P[e]=!0,!1)}function H(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function K(e,t,n,r){if(t===null||typeof t>"u"||H(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function R(e,t,n,r,l,o,s){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=s}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){E[e]=new R(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];E[t]=new R(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){E[e]=new R(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){E[e]=new R(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){E[e]=new R(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){E[e]=new R(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){E[e]=new R(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){E[e]=new R(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){E[e]=new R(e,5,!1,e.toLowerCase(),null,!1,!1)});var A=/[\-:]([a-z])/g;function $(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(A,$);E[t]=new R(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(A,$);E[t]=new R(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(A,$);E[t]=new R(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){E[e]=new R(e,1,!1,e.toLowerCase(),null,!1,!1)}),E.xlinkHref=new R("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){E[e]=new R(e,1,!1,e.toLowerCase(),null,!0,!0)});function G(e,t,n,r){var l=E.hasOwnProperty(t)?E[t]:null;(l!==null?l.type!==0:r||!(2f||l[s]!==o[f]){var m=` -`+l[s].replace(" at new "," at ");return e.displayName&&m.includes("")&&(m=m.replace("",e.displayName)),m}while(1<=s&&0<=f);break}}}finally{ee=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?T(e):""}function le(e){switch(e.tag){case 5:return T(e.type);case 16:return T("Lazy");case 13:return T("Suspense");case 19:return T("SuspenseList");case 0:case 2:case 15:return e=re(e.type,!1),e;case 11:return e=re(e.type.render,!1),e;case 1:return e=re(e.type,!0),e;default:return""}}function oe(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case je:return"Fragment";case de:return"Portal";case Je:return"Profiler";case xe:return"StrictMode";case Pe:return"Suspense";case Be:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case He:return(e.displayName||"Context")+".Consumer";case Ie:return(e._context.displayName||"Context")+".Provider";case Ce:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ge:return t=e.displayName||null,t!==null?t:oe(e.type)||"Memo";case Le:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}function ae(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return oe(t);case 8:return t===xe?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function se(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function fe(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function We(e){var t=fe(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(s){r=""+s,o.call(this,s)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Bt(e){e._valueTracker||(e._valueTracker=We(e))}function En(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=fe(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function At(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function $t(e,t){var n=t.checked;return F({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function _n(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=se(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function en(e,t){t=t.checked,t!=null&&G(e,"checked",t,!1)}function Vt(e,t){en(e,t);var n=se(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?tn(e,t.type,n):t.hasOwnProperty("defaultValue")&&tn(e,t.type,se(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Nn(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function tn(e,t,n){(t!=="number"||At(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var St=Array.isArray;function Tt(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=nt.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ht(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ot={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Rn=["Webkit","ms","Moz","O"];Object.keys(Ot).forEach(function(e){Rn.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ot[t]=Ot[e]})});function Vn(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Ot.hasOwnProperty(e)&&Ot[e]?(""+t).trim():t+"px"}function I(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Vn(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var te=F({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ie(e,t){if(t){if(te[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(a(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(a(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(a(61))}if(t.style!=null&&typeof t.style!="object")throw Error(a(62))}}function De(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var mt=null;function wr(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ro=null,Hn=null,Qn=null;function Ls(e){if(e=Vr(e)){if(typeof Ro!="function")throw Error(a(280));var t=e.stateNode;t&&(t=Ol(t),Ro(e.stateNode,e.type,t))}}function Os(e){Hn?Qn?Qn.push(e):Qn=[e]:Hn=e}function Ds(){if(Hn){var e=Hn,t=Qn;if(Qn=Hn=null,Ls(e),t)for(e=0;e>>=0,e===0?32:31-(dd(e)/fd|0)|0}var ml=64,vl=4194304;function Er(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function gl(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,o=e.pingedLanes,s=n&268435455;if(s!==0){var f=s&~l;f!==0?r=Er(f):(o&=s,o!==0&&(r=Er(o)))}else s=n&~l,s!==0?r=Er(s):o!==0&&(r=Er(o));if(r===0)return 0;if(t!==0&&t!==r&&(t&l)===0&&(l=r&-r,o=t&-t,l>=o||l===16&&(o&4194240)!==0))return t;if((r&4)!==0&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function _r(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-jt(t),e[t]=n}function vd(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Dr),aa=" ",ua=!1;function ca(e,t){switch(e){case"keyup":return Hd.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function da(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Jn=!1;function Kd(e,t){switch(e){case"compositionend":return da(t);case"keypress":return t.which!==32?null:(ua=!0,aa);case"textInput":return e=t.data,e===aa&&ua?null:e;default:return null}}function Yd(e,t){if(Jn)return e==="compositionend"||!Yo&&ca(e,t)?(e=na(),Sl=Ao=sn=null,Jn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=ya(n)}}function ka(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?ka(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function wa(){for(var e=window,t=At();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=At(e.document)}return t}function Xo(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function nf(e){var t=wa(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&ka(n.ownerDocument.documentElement,n)){if(r!==null&&Xo(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,o=Math.min(r.start,l);r=r.end===void 0?o:Math.min(r.end,l),!e.extend&&o>r&&(l=r,r=o,o=l),l=xa(n,o);var s=xa(n,r);l&&s&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==s.node||e.focusOffset!==s.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(s.node,s.offset)):(t.setEnd(s.node,s.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Gn=null,Zo=null,Fr=null,qo=!1;function Sa(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;qo||Gn==null||Gn!==At(r)||(r=Gn,"selectionStart"in r&&Xo(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Fr&&Wr(Fr,r)||(Fr=r,r=Tl(Zo,"onSelect"),0er||(e.current=ci[er],ci[er]=null,er--)}function ye(e,t){er++,ci[er]=e.current,e.current=t}var dn={},Xe=cn(dn),ot=cn(!1),Ln=dn;function tr(e,t){var n=e.type.contextTypes;if(!n)return dn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},o;for(o in n)l[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function it(e){return e=e.childContextTypes,e!=null}function Dl(){we(ot),we(Xe)}function Wa(e,t,n){if(Xe.current!==dn)throw Error(a(168));ye(Xe,t),ye(ot,n)}function Fa(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(a(108,ae(e)||"Unknown",l));return F({},n,r)}function Ml(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||dn,Ln=Xe.current,ye(Xe,e),ye(ot,ot.current),!0}function Ua(e,t,n){var r=e.stateNode;if(!r)throw Error(a(169));n?(e=Fa(e,t,Ln),r.__reactInternalMemoizedMergedChildContext=e,we(ot),we(Xe),ye(Xe,e)):we(ot),ye(ot,n)}var Kt=null,Il=!1,di=!1;function Ba(e){Kt===null?Kt=[e]:Kt.push(e)}function mf(e){Il=!0,Ba(e)}function fn(){if(!di&&Kt!==null){di=!0;var e=0,t=ge;try{var n=Kt;for(ge=1;e>=s,l-=s,Yt=1<<32-jt(t)+l|n<b?(Ve=q,q=null):Ve=q.sibling;var he=z(x,q,w[b],D);if(he===null){q===null&&(q=Ve);break}e&&q&&he.alternate===null&&t(x,q),v=o(he,v,b),Z===null?J=he:Z.sibling=he,Z=he,q=Ve}if(b===w.length)return n(x,q),Se&&Dn(x,b),J;if(q===null){for(;bb?(Ve=q,q=null):Ve=q.sibling;var wn=z(x,q,he.value,D);if(wn===null){q===null&&(q=Ve);break}e&&q&&wn.alternate===null&&t(x,q),v=o(wn,v,b),Z===null?J=wn:Z.sibling=wn,Z=wn,q=Ve}if(he.done)return n(x,q),Se&&Dn(x,b),J;if(q===null){for(;!he.done;b++,he=w.next())he=O(x,he.value,D),he!==null&&(v=o(he,v,b),Z===null?J=he:Z.sibling=he,Z=he);return Se&&Dn(x,b),J}for(q=r(x,q);!he.done;b++,he=w.next())he=U(q,x,b,he.value,D),he!==null&&(e&&he.alternate!==null&&q.delete(he.key===null?b:he.key),v=o(he,v,b),Z===null?J=he:Z.sibling=he,Z=he);return e&&q.forEach(function(Gf){return t(x,Gf)}),Se&&Dn(x,b),J}function ze(x,v,w,D){if(typeof w=="object"&&w!==null&&w.type===je&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case ce:e:{for(var J=w.key,Z=v;Z!==null;){if(Z.key===J){if(J=w.type,J===je){if(Z.tag===7){n(x,Z.sibling),v=l(Z,w.props.children),v.return=x,x=v;break e}}else if(Z.elementType===J||typeof J=="object"&&J!==null&&J.$$typeof===Le&&Ka(J)===Z.type){n(x,Z.sibling),v=l(Z,w.props),v.ref=Hr(x,Z,w),v.return=x,x=v;break e}n(x,Z);break}else t(x,Z);Z=Z.sibling}w.type===je?(v=$n(w.props.children,x.mode,D,w.key),v.return=x,x=v):(D=co(w.type,w.key,w.props,null,x.mode,D),D.ref=Hr(x,v,w),D.return=x,x=D)}return s(x);case de:e:{for(Z=w.key;v!==null;){if(v.key===Z)if(v.tag===4&&v.stateNode.containerInfo===w.containerInfo&&v.stateNode.implementation===w.implementation){n(x,v.sibling),v=l(v,w.children||[]),v.return=x,x=v;break e}else{n(x,v);break}else t(x,v);v=v.sibling}v=as(w,x.mode,D),v.return=x,x=v}return s(x);case Le:return Z=w._init,ze(x,v,Z(w._payload),D)}if(St(w))return Q(x,v,w,D);if(X(w))return Y(x,v,w,D);Bl(x,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,v!==null&&v.tag===6?(n(x,v.sibling),v=l(v,w),v.return=x,x=v):(n(x,v),v=ss(w,x.mode,D),v.return=x,x=v),s(x)):n(x,v)}return ze}var or=Ya(!0),Ja=Ya(!1),Al=cn(null),$l=null,ir=null,gi=null;function yi(){gi=ir=$l=null}function xi(e){var t=Al.current;we(Al),e._currentValue=t}function ki(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function sr(e,t){$l=e,gi=ir=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(st=!0),e.firstContext=null)}function yt(e){var t=e._currentValue;if(gi!==e)if(e={context:e,memoizedValue:t,next:null},ir===null){if($l===null)throw Error(a(308));ir=e,$l.dependencies={lanes:0,firstContext:e}}else ir=ir.next=e;return t}var Mn=null;function wi(e){Mn===null?Mn=[e]:Mn.push(e)}function Ga(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,wi(t)):(n.next=l.next,l.next=n),t.interleaved=n,Gt(e,r)}function Gt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var pn=!1;function Si(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Xa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Xt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function hn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,(pe&2)!==0){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,Gt(e,n)}return l=r.interleaved,l===null?(t.next=t,wi(r)):(t.next=l.next,l.next=t),r.interleaved=t,Gt(e,n)}function Vl(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Io(e,n)}}function Za(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var s={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?l=o=s:o=o.next=s,n=n.next}while(n!==null);o===null?l=o=t:o=o.next=t}else l=o=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Hl(e,t,n,r){var l=e.updateQueue;pn=!1;var o=l.firstBaseUpdate,s=l.lastBaseUpdate,f=l.shared.pending;if(f!==null){l.shared.pending=null;var m=f,C=m.next;m.next=null,s===null?o=C:s.next=C,s=m;var L=e.alternate;L!==null&&(L=L.updateQueue,f=L.lastBaseUpdate,f!==s&&(f===null?L.firstBaseUpdate=C:f.next=C,L.lastBaseUpdate=m))}if(o!==null){var O=l.baseState;s=0,L=C=m=null,f=o;do{var z=f.lane,U=f.eventTime;if((r&z)===z){L!==null&&(L=L.next={eventTime:U,lane:0,tag:f.tag,payload:f.payload,callback:f.callback,next:null});e:{var Q=e,Y=f;switch(z=t,U=n,Y.tag){case 1:if(Q=Y.payload,typeof Q=="function"){O=Q.call(U,O,z);break e}O=Q;break e;case 3:Q.flags=Q.flags&-65537|128;case 0:if(Q=Y.payload,z=typeof Q=="function"?Q.call(U,O,z):Q,z==null)break e;O=F({},O,z);break e;case 2:pn=!0}}f.callback!==null&&f.lane!==0&&(e.flags|=64,z=l.effects,z===null?l.effects=[f]:z.push(f))}else U={eventTime:U,lane:z,tag:f.tag,payload:f.payload,callback:f.callback,next:null},L===null?(C=L=U,m=O):L=L.next=U,s|=z;if(f=f.next,f===null){if(f=l.shared.pending,f===null)break;z=f,f=z.next,z.next=null,l.lastBaseUpdate=z,l.shared.pending=null}}while(!0);if(L===null&&(m=O),l.baseState=m,l.firstBaseUpdate=C,l.lastBaseUpdate=L,t=l.shared.interleaved,t!==null){l=t;do s|=l.lane,l=l.next;while(l!==t)}else o===null&&(l.shared.lanes=0);Fn|=s,e.lanes=s,e.memoizedState=O}}function qa(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Ni.transition;Ni.transition={};try{e(!1),t()}finally{ge=n,Ni.transition=r}}function gu(){return xt().memoizedState}function xf(e,t,n){var r=yn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},yu(e))xu(t,n);else if(n=Ga(e,t,n,r),n!==null){var l=lt();Rt(n,e,r,l),ku(n,t,r)}}function kf(e,t,n){var r=yn(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(yu(e))xu(t,l);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var s=t.lastRenderedState,f=o(s,n);if(l.hasEagerState=!0,l.eagerState=f,Ct(f,s)){var m=t.interleaved;m===null?(l.next=l,wi(t)):(l.next=m.next,m.next=l),t.interleaved=l;return}}catch{}finally{}n=Ga(e,t,l,r),n!==null&&(l=lt(),Rt(n,e,r,l),ku(n,t,r))}}function yu(e){var t=e.alternate;return e===_e||t!==null&&t===_e}function xu(e,t){Jr=Yl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ku(e,t,n){if((n&4194240)!==0){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Io(e,n)}}var Xl={readContext:yt,useCallback:Ze,useContext:Ze,useEffect:Ze,useImperativeHandle:Ze,useInsertionEffect:Ze,useLayoutEffect:Ze,useMemo:Ze,useReducer:Ze,useRef:Ze,useState:Ze,useDebugValue:Ze,useDeferredValue:Ze,useTransition:Ze,useMutableSource:Ze,useSyncExternalStore:Ze,useId:Ze,unstable_isNewReconciler:!1},wf={readContext:yt,useCallback:function(e,t){return Wt().memoizedState=[e,t===void 0?null:t],e},useContext:yt,useEffect:uu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Jl(4194308,4,fu.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Jl(4194308,4,e,t)},useInsertionEffect:function(e,t){return Jl(4,2,e,t)},useMemo:function(e,t){var n=Wt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Wt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=xf.bind(null,_e,e),[r.memoizedState,e]},useRef:function(e){var t=Wt();return e={current:e},t.memoizedState=e},useState:su,useDebugValue:Di,useDeferredValue:function(e){return Wt().memoizedState=e},useTransition:function(){var e=su(!1),t=e[0];return e=yf.bind(null,e[1]),Wt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=_e,l=Wt();if(Se){if(n===void 0)throw Error(a(407));n=n()}else{if(n=t(),$e===null)throw Error(a(349));(Wn&30)!==0||nu(r,t,n)}l.memoizedState=n;var o={value:n,getSnapshot:t};return l.queue=o,uu(lu.bind(null,r,o,e),[e]),r.flags|=2048,Zr(9,ru.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Wt(),t=$e.identifierPrefix;if(Se){var n=Jt,r=Yt;n=(r&~(1<<32-jt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Gr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=s.createElement(n,{is:r.is}):(e=s.createElement(n),n==="select"&&(s=e,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):e=s.createElementNS(e,n),e[Mt]=t,e[$r]=r,Bu(e,t,!1,!1),t.stateNode=e;e:{switch(s=De(n,r),n){case"dialog":ke("cancel",e),ke("close",e),l=r;break;case"iframe":case"object":case"embed":ke("load",e),l=r;break;case"video":case"audio":for(l=0;lfr&&(t.flags|=128,r=!0,qr(o,!1),t.lanes=4194304)}else{if(!r)if(e=Ql(s),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),qr(o,!0),o.tail===null&&o.tailMode==="hidden"&&!s.alternate&&!Se)return qe(t),null}else 2*Te()-o.renderingStartTime>fr&&n!==1073741824&&(t.flags|=128,r=!0,qr(o,!1),t.lanes=4194304);o.isBackwards?(s.sibling=t.child,t.child=s):(n=o.last,n!==null?n.sibling=s:t.child=s,o.last=s)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=Te(),t.sibling=null,n=Ee.current,ye(Ee,r?n&1|2:n&1),t):(qe(t),null);case 22:case 23:return ls(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&(t.mode&1)!==0?(ht&1073741824)!==0&&(qe(t),t.subtreeFlags&6&&(t.flags|=8192)):qe(t),null;case 24:return null;case 25:return null}throw Error(a(156,t.tag))}function Rf(e,t){switch(pi(t),t.tag){case 1:return it(t.type)&&Dl(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ar(),we(ot),we(Xe),_i(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return Ci(t),null;case 13:if(we(Ee),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(a(340));lr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return we(Ee),null;case 4:return ar(),null;case 10:return xi(t.type._context),null;case 22:case 23:return ls(),null;case 24:return null;default:return null}}var eo=!1,be=!1,Tf=typeof WeakSet=="function"?WeakSet:Set,V=null;function cr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Re(e,t,r)}else n.current=null}function Ki(e,t,n){try{n()}catch(r){Re(e,t,r)}}var Vu=!1;function zf(e,t){if(li=kl,e=wa(),Xo(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var s=0,f=-1,m=-1,C=0,L=0,O=e,z=null;t:for(;;){for(var U;O!==n||l!==0&&O.nodeType!==3||(f=s+l),O!==o||r!==0&&O.nodeType!==3||(m=s+r),O.nodeType===3&&(s+=O.nodeValue.length),(U=O.firstChild)!==null;)z=O,O=U;for(;;){if(O===e)break t;if(z===n&&++C===l&&(f=s),z===o&&++L===r&&(m=s),(U=O.nextSibling)!==null)break;O=z,z=O.parentNode}O=U}n=f===-1||m===-1?null:{start:f,end:m}}else n=null}n=n||{start:0,end:0}}else n=null;for(oi={focusedElem:e,selectionRange:n},kl=!1,V=t;V!==null;)if(t=V,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,V=e;else for(;V!==null;){t=V;try{var Q=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(Q!==null){var Y=Q.memoizedProps,ze=Q.memoizedState,x=t.stateNode,v=x.getSnapshotBeforeUpdate(t.elementType===t.type?Y:_t(t.type,Y),ze);x.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var w=t.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(a(163))}}catch(D){Re(t,t.return,D)}if(e=t.sibling,e!==null){e.return=t.return,V=e;break}V=t.return}return Q=Vu,Vu=!1,Q}function br(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var o=l.destroy;l.destroy=void 0,o!==void 0&&Ki(t,n,o)}l=l.next}while(l!==r)}}function to(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Yi(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Hu(e){var t=e.alternate;t!==null&&(e.alternate=null,Hu(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Mt],delete t[$r],delete t[ui],delete t[pf],delete t[hf])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Qu(e){return e.tag===5||e.tag===3||e.tag===4}function Ku(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Qu(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ji(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ll));else if(r!==4&&(e=e.child,e!==null))for(Ji(e,t,n),e=e.sibling;e!==null;)Ji(e,t,n),e=e.sibling}function Gi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Gi(e,t,n),e=e.sibling;e!==null;)Gi(e,t,n),e=e.sibling}var Qe=null,Nt=!1;function mn(e,t,n){for(n=n.child;n!==null;)Yu(e,t,n),n=n.sibling}function Yu(e,t,n){if(Dt&&typeof Dt.onCommitFiberUnmount=="function")try{Dt.onCommitFiberUnmount(hl,n)}catch{}switch(n.tag){case 5:be||cr(n,t);case 6:var r=Qe,l=Nt;Qe=null,mn(e,t,n),Qe=r,Nt=l,Qe!==null&&(Nt?(e=Qe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Qe.removeChild(n.stateNode));break;case 18:Qe!==null&&(Nt?(e=Qe,n=n.stateNode,e.nodeType===8?ai(e.parentNode,n):e.nodeType===1&&ai(e,n),zr(e)):ai(Qe,n.stateNode));break;case 4:r=Qe,l=Nt,Qe=n.stateNode.containerInfo,Nt=!0,mn(e,t,n),Qe=r,Nt=l;break;case 0:case 11:case 14:case 15:if(!be&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var o=l,s=o.destroy;o=o.tag,s!==void 0&&((o&2)!==0||(o&4)!==0)&&Ki(n,t,s),l=l.next}while(l!==r)}mn(e,t,n);break;case 1:if(!be&&(cr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(f){Re(n,t,f)}mn(e,t,n);break;case 21:mn(e,t,n);break;case 22:n.mode&1?(be=(r=be)||n.memoizedState!==null,mn(e,t,n),be=r):mn(e,t,n);break;default:mn(e,t,n)}}function Ju(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Tf),t.forEach(function(r){var l=Bf.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Pt(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=s),r&=~o}if(r=l,r=Te()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Of(r/1960))-r,10e?16:e,gn===null)var r=!1;else{if(e=gn,gn=null,io=0,(pe&6)!==0)throw Error(a(331));var l=pe;for(pe|=4,V=e.current;V!==null;){var o=V,s=o.child;if((V.flags&16)!==0){var f=o.deletions;if(f!==null){for(var m=0;mTe()-qi?Bn(e,0):Zi|=n),ut(e,t)}function sc(e,t){t===0&&((e.mode&1)===0?t=1:(t=vl,vl<<=1,(vl&130023424)===0&&(vl=4194304)));var n=lt();e=Gt(e,t),e!==null&&(_r(e,t,n),ut(e,n))}function Uf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),sc(e,n)}function Bf(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(a(314))}r!==null&&r.delete(t),sc(e,n)}var ac;ac=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ot.current)st=!0;else{if((e.lanes&n)===0&&(t.flags&128)===0)return st=!1,Nf(e,t,n);st=(e.flags&131072)!==0}else st=!1,Se&&(t.flags&1048576)!==0&&Aa(t,Fl,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;bl(e,t),e=t.pendingProps;var l=tr(t,Xe.current);sr(t,n),l=Ri(null,t,r,e,l,n);var o=Ti();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,it(r)?(o=!0,Ml(t)):o=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,Si(t),l.updater=Zl,t.stateNode=l,l._reactInternals=t,Ii(t,r,e,n),t=Bi(null,t,r,!0,o,n)):(t.tag=0,Se&&o&&fi(t),rt(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(bl(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=$f(r),e=_t(r,e),l){case 0:t=Ui(null,t,r,e,n);break e;case 1:t=Du(null,t,r,e,n);break e;case 11:t=Ru(null,t,r,e,n);break e;case 14:t=Tu(null,t,r,_t(r.type,e),n);break e}throw Error(a(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:_t(r,l),Ui(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:_t(r,l),Du(e,t,r,l,n);case 3:e:{if(Mu(t),e===null)throw Error(a(387));r=t.pendingProps,o=t.memoizedState,l=o.element,Xa(e,t),Hl(t,r,null,n);var s=t.memoizedState;if(r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){l=ur(Error(a(423)),t),t=Iu(e,t,r,n,l);break e}else if(r!==l){l=ur(Error(a(424)),t),t=Iu(e,t,r,n,l);break e}else for(pt=un(t.stateNode.containerInfo.firstChild),ft=t,Se=!0,Et=null,n=Ja(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(lr(),r===l){t=Zt(e,t,n);break e}rt(e,t,r,n)}t=t.child}return t;case 5:return ba(t),e===null&&mi(t),r=t.type,l=t.pendingProps,o=e!==null?e.memoizedProps:null,s=l.children,ii(r,l)?s=null:o!==null&&ii(r,o)&&(t.flags|=32),Ou(e,t),rt(e,t,s,n),t.child;case 6:return e===null&&mi(t),null;case 13:return Wu(e,t,n);case 4:return ji(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=or(t,null,r,n):rt(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:_t(r,l),Ru(e,t,r,l,n);case 7:return rt(e,t,t.pendingProps,n),t.child;case 8:return rt(e,t,t.pendingProps.children,n),t.child;case 12:return rt(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,o=t.memoizedProps,s=l.value,ye(Al,r._currentValue),r._currentValue=s,o!==null)if(Ct(o.value,s)){if(o.children===l.children&&!ot.current){t=Zt(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var f=o.dependencies;if(f!==null){s=o.child;for(var m=f.firstContext;m!==null;){if(m.context===r){if(o.tag===1){m=Xt(-1,n&-n),m.tag=2;var C=o.updateQueue;if(C!==null){C=C.shared;var L=C.pending;L===null?m.next=m:(m.next=L.next,L.next=m),C.pending=m}}o.lanes|=n,m=o.alternate,m!==null&&(m.lanes|=n),ki(o.return,n,t),f.lanes|=n;break}m=m.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(a(341));s.lanes|=n,f=s.alternate,f!==null&&(f.lanes|=n),ki(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}rt(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,sr(t,n),l=yt(l),r=r(l),t.flags|=1,rt(e,t,r,n),t.child;case 14:return r=t.type,l=_t(r,t.pendingProps),l=_t(r.type,l),Tu(e,t,r,l,n);case 15:return zu(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:_t(r,l),bl(e,t),t.tag=1,it(r)?(e=!0,Ml(t)):e=!1,sr(t,n),Su(t,r,l),Ii(t,r,l,n),Bi(null,t,r,!0,e,n);case 19:return Uu(e,t,n);case 22:return Lu(e,t,n)}throw Error(a(156,t.tag))};function uc(e,t){return $s(e,t)}function Af(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function wt(e,t,n,r){return new Af(e,t,n,r)}function is(e){return e=e.prototype,!(!e||!e.isReactComponent)}function $f(e){if(typeof e=="function")return is(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Ce)return 11;if(e===Ge)return 14}return 2}function kn(e,t){var n=e.alternate;return n===null?(n=wt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function co(e,t,n,r,l,o){var s=2;if(r=e,typeof e=="function")is(e)&&(s=1);else if(typeof e=="string")s=5;else e:switch(e){case je:return $n(n.children,l,o,t);case xe:s=8,l|=8;break;case Je:return e=wt(12,n,t,l|2),e.elementType=Je,e.lanes=o,e;case Pe:return e=wt(13,n,t,l),e.elementType=Pe,e.lanes=o,e;case Be:return e=wt(19,n,t,l),e.elementType=Be,e.lanes=o,e;case me:return fo(n,l,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Ie:s=10;break e;case He:s=9;break e;case Ce:s=11;break e;case Ge:s=14;break e;case Le:s=16,r=null;break e}throw Error(a(130,e==null?e:typeof e,""))}return t=wt(s,n,t,l),t.elementType=e,t.type=r,t.lanes=o,t}function $n(e,t,n,r){return e=wt(7,e,r,t),e.lanes=n,e}function fo(e,t,n,r){return e=wt(22,e,r,t),e.elementType=me,e.lanes=n,e.stateNode={isHidden:!1},e}function ss(e,t,n){return e=wt(6,e,null,t),e.lanes=n,e}function as(e,t,n){return t=wt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Vf(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Mo(0),this.expirationTimes=Mo(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Mo(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function us(e,t,n,r,l,o,s,f,m){return e=new Vf(e,t,n,f,m),t===1?(t=1,o===!0&&(t|=8)):t=0,o=wt(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Si(o),e}function Hf(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(u){console.error(u)}}return i(),ms.exports=op(),ms.exports}var jc;function ip(){if(jc)return xo;jc=1;var i=Uc();return xo.createRoot=i.createRoot,xo.hydrateRoot=i.hydrateRoot,xo}var sp=ip();Uc();/** - * @remix-run/router v1.23.3 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */function al(){return al=Object.assign?Object.assign.bind():function(i){for(var u=1;u"u")throw new Error(u)}function Rs(i,u){if(!i){typeof console<"u"&&console.warn(u);try{throw new Error(u)}catch{}}}function up(){return Math.random().toString(36).substr(2,8)}function Ec(i,u){return{usr:i.state,key:i.key,idx:u}}function js(i,u,a,d){return a===void 0&&(a=null),al({pathname:typeof i=="string"?i:i.pathname,search:"",hash:""},typeof u=="string"?yr(u):u,{state:a,key:u&&u.key||d||up()})}function jo(i){let{pathname:u="/",search:a="",hash:d=""}=i;return a&&a!=="?"&&(u+=a.charAt(0)==="?"?a:"?"+a),d&&d!=="#"&&(u+=d.charAt(0)==="#"?d:"#"+d),u}function yr(i){let u={};if(i){let a=i.indexOf("#");a>=0&&(u.hash=i.substr(a),i=i.substr(0,a));let d=i.indexOf("?");d>=0&&(u.search=i.substr(d),i=i.substr(0,d)),i&&(u.pathname=i)}return u}function cp(i,u,a,d){d===void 0&&(d={});let{window:p=document.defaultView,v5Compat:h=!1}=d,g=p.history,j=Sn.Pop,k=null,_=P();_==null&&(_=0,g.replaceState(al({},g.state,{idx:_}),""));function P(){return(g.state||{idx:null}).idx}function N(){j=Sn.Pop;let E=P(),A=E==null?null:E-_;_=E,k&&k({action:j,location:R.location,delta:A})}function M(E,A){j=Sn.Push;let $=js(R.location,E,A);_=P()+1;let G=Ec($,_),B=R.createHref($);try{g.pushState(G,"",B)}catch(ce){if(ce instanceof DOMException&&ce.name==="DataCloneError")throw ce;p.location.assign(B)}h&&k&&k({action:j,location:R.location,delta:1})}function H(E,A){j=Sn.Replace;let $=js(R.location,E,A);_=P();let G=Ec($,_),B=R.createHref($);g.replaceState(G,"",B),h&&k&&k({action:j,location:R.location,delta:0})}function K(E){let A=p.location.origin!=="null"?p.location.origin:p.location.href,$=typeof E=="string"?E:jo(E);return $=$.replace(/ $/,"%20"),Ne(A,"No window.location.(origin|href) available to create URL for href: "+$),new URL($,A)}let R={get action(){return j},get location(){return i(p,g)},listen(E){if(k)throw new Error("A history only accepts one active listener");return p.addEventListener(Cc,N),k=E,()=>{p.removeEventListener(Cc,N),k=null}},createHref(E){return u(p,E)},createURL:K,encodeLocation(E){let A=K(E);return{pathname:A.pathname,search:A.search,hash:A.hash}},push:M,replace:H,go(E){return g.go(E)}};return R}var _c;(function(i){i.data="data",i.deferred="deferred",i.redirect="redirect",i.error="error"})(_c||(_c={}));function dp(i,u,a){return a===void 0&&(a="/"),fp(i,u,a)}function fp(i,u,a,d){let p=typeof u=="string"?yr(u):u,h=vr(p.pathname||"/",a);if(h==null)return null;let g=Bc(i);pp(g);let j=null,k=Cp(h);for(let _=0;j==null&&_{let k={relativePath:j===void 0?h.path||"":j,caseSensitive:h.caseSensitive===!0,childrenIndex:g,route:h};k.relativePath.startsWith("/")&&(Ne(k.relativePath.startsWith(d),'Absolute route path "'+k.relativePath+'" nested under path '+('"'+d+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),k.relativePath=k.relativePath.slice(d.length));let _=jn([d,k.relativePath]),P=a.concat(k);h.children&&h.children.length>0&&(Ne(h.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+_+'".')),Bc(h.children,u,P,_)),!(h.path==null&&!h.index)&&u.push({path:_,score:kp(_,h.index),routesMeta:P})};return i.forEach((h,g)=>{var j;if(h.path===""||!((j=h.path)!=null&&j.includes("?")))p(h,g);else for(let k of Ac(h.path))p(h,g,k)}),u}function Ac(i){let u=i.split("/");if(u.length===0)return[];let[a,...d]=u,p=a.endsWith("?"),h=a.replace(/\?$/,"");if(d.length===0)return p?[h,""]:[h];let g=Ac(d.join("/")),j=[];return j.push(...g.map(k=>k===""?h:[h,k].join("/"))),p&&j.push(...g),j.map(k=>i.startsWith("/")&&k===""?"/":k)}function pp(i){i.sort((u,a)=>u.score!==a.score?a.score-u.score:wp(u.routesMeta.map(d=>d.childrenIndex),a.routesMeta.map(d=>d.childrenIndex)))}const hp=/^:[\w-]+$/,mp=3,vp=2,gp=1,yp=10,xp=-2,Nc=i=>i==="*";function kp(i,u){let a=i.split("/"),d=a.length;return a.some(Nc)&&(d+=xp),u&&(d+=vp),a.filter(p=>!Nc(p)).reduce((p,h)=>p+(hp.test(h)?mp:h===""?gp:yp),d)}function wp(i,u){return i.length===u.length&&i.slice(0,-1).every((d,p)=>d===u[p])?i[i.length-1]-u[u.length-1]:0}function Sp(i,u,a){let{routesMeta:d}=i,p={},h="/",g=[];for(let j=0;j{let{paramName:M,isOptional:H}=P;if(M==="*"){let R=j[N]||"";g=h.slice(0,h.length-R.length).replace(/(.)\/+$/,"$1")}const K=j[N];return H&&!K?_[M]=void 0:_[M]=(K||"").replace(/%2F/g,"/"),_},{}),pathname:h,pathnameBase:g,pattern:i}}function jp(i,u,a){u===void 0&&(u=!1),a===void 0&&(a=!0),Rs(i==="*"||!i.endsWith("*")||i.endsWith("/*"),'Route path "'+i+'" will be treated as if it were '+('"'+i.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+i.replace(/\*$/,"/*")+'".'));let d=[],p="^"+i.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(g,j,k)=>(d.push({paramName:j,isOptional:k!=null}),k?"/?([^\\/]+)?":"/([^\\/]+)"));return i.endsWith("*")?(d.push({paramName:"*"}),p+=i==="*"||i==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?p+="\\/*$":i!==""&&i!=="/"&&(p+="(?:(?=\\/|$))"),[new RegExp(p,u?void 0:"i"),d]}function Cp(i){try{return i.split("/").map(u=>decodeURIComponent(u).replace(/\//g,"%2F")).join("/")}catch(u){return Rs(!1,'The URL path "'+i+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+u+").")),i}}function vr(i,u){if(u==="/")return i;if(!i.toLowerCase().startsWith(u.toLowerCase()))return null;let a=u.endsWith("/")?u.length-1:u.length,d=i.charAt(a);return d&&d!=="/"?null:i.slice(a)||"/"}const Ep=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,_p=i=>Ep.test(i);function Np(i,u){u===void 0&&(u="/");let{pathname:a,search:d="",hash:p=""}=typeof i=="string"?yr(i):i,h;if(a)if(_p(a))h=a;else{if(a.includes("//")){let g=a;a=$c(a),Rs(!1,"Pathnames cannot have embedded double slashes - normalizing "+(g+" -> "+a))}a.startsWith("/")?h=Pc(a.substring(1),"/"):h=Pc(a,u)}else h=u;return{pathname:h,search:Tp(d),hash:zp(p)}}function Pc(i,u){let a=u.replace(/\/+$/,"").split("/");return i.split("/").forEach(p=>{p===".."?a.length>1&&a.pop():p!=="."&&a.push(p)}),a.length>1?a.join("/"):"/"}function ys(i,u,a,d){return"Cannot include a '"+i+"' character in a manually specified "+("`to."+u+"` field ["+JSON.stringify(d)+"]. Please separate it out to the ")+("`to."+a+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Pp(i){return i.filter((u,a)=>a===0||u.route.path&&u.route.path.length>0)}function Ts(i,u){let a=Pp(i);return u?a.map((d,p)=>p===a.length-1?d.pathname:d.pathnameBase):a.map(d=>d.pathnameBase)}function zs(i,u,a,d){d===void 0&&(d=!1);let p;typeof i=="string"?p=yr(i):(p=al({},i),Ne(!p.pathname||!p.pathname.includes("?"),ys("?","pathname","search",p)),Ne(!p.pathname||!p.pathname.includes("#"),ys("#","pathname","hash",p)),Ne(!p.search||!p.search.includes("#"),ys("#","search","hash",p)));let h=i===""||p.pathname==="",g=h?"/":p.pathname,j;if(g==null)j=a;else{let N=u.length-1;if(!d&&g.startsWith("..")){let M=g.split("/");for(;M[0]==="..";)M.shift(),N-=1;p.pathname=M.join("/")}j=N>=0?u[N]:"/"}let k=Np(p,j),_=g&&g!=="/"&&g.endsWith("/"),P=(h||g===".")&&a.endsWith("/");return!k.pathname.endsWith("/")&&(_||P)&&(k.pathname+="/"),k}const $c=i=>i.replace(/\/\/+/g,"/"),jn=i=>$c(i.join("/")),Rp=i=>i.replace(/\/+$/,"").replace(/^\/*/,"/"),Tp=i=>!i||i==="?"?"":i.startsWith("?")?i:"?"+i,zp=i=>!i||i==="#"?"":i.startsWith("#")?i:"#"+i;function Lp(i){return i!=null&&typeof i.status=="number"&&typeof i.statusText=="string"&&typeof i.internal=="boolean"&&"data"in i}const Vc=["post","put","patch","delete"];new Set(Vc);const Op=["get",...Vc];new Set(Op);/** - * React Router v6.30.4 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */function ul(){return ul=Object.assign?Object.assign.bind():function(i){for(var u=1;u{j.current=!0}),S.useCallback(function(_,P){if(P===void 0&&(P={}),!j.current)return;if(typeof _=="number"){d.go(_);return}let N=zs(_,JSON.parse(g),h,P.relative==="path");i==null&&u!=="/"&&(N.pathname=N.pathname==="/"?u:jn([u,N.pathname])),(P.replace?d.replace:d.push)(N,P.state,P)},[u,d,g,h,i])}function No(i,u){let{relative:a}=u===void 0?{}:u,{future:d}=S.useContext(bt),{matches:p}=S.useContext(Cn),{pathname:h}=kr(),g=JSON.stringify(Ts(p,d.v7_relativeSplatPath));return S.useMemo(()=>zs(i,JSON.parse(g),h,a==="path"),[i,g,h,a])}function Ip(i,u){return Wp(i,u)}function Wp(i,u,a,d){xr()||Ne(!1);let{navigator:p}=S.useContext(bt),{matches:h}=S.useContext(Cn),g=h[h.length-1],j=g?g.params:{};g&&g.pathname;let k=g?g.pathnameBase:"/";g&&g.route;let _=kr(),P;if(u){var N;let E=typeof u=="string"?yr(u):u;k==="/"||(N=E.pathname)!=null&&N.startsWith(k)||Ne(!1),P=E}else P=_;let M=P.pathname||"/",H=M;if(k!=="/"){let E=k.replace(/^\//,"").split("/");H="/"+M.replace(/^\//,"").split("/").slice(E.length).join("/")}let K=dp(i,{pathname:H}),R=$p(K&&K.map(E=>Object.assign({},E,{params:Object.assign({},j,E.params),pathname:jn([k,p.encodeLocation?p.encodeLocation(E.pathname).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?k:jn([k,p.encodeLocation?p.encodeLocation(E.pathnameBase).pathname:E.pathnameBase])})),h,a,d);return u&&R?S.createElement(_o.Provider,{value:{location:ul({pathname:"/",search:"",hash:"",state:null,key:"default"},P),navigationType:Sn.Pop}},R):R}function Fp(){let i=Kp(),u=Lp(i)?i.status+" "+i.statusText:i instanceof Error?i.message:JSON.stringify(i),a=i instanceof Error?i.stack:null,p={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return S.createElement(S.Fragment,null,S.createElement("h2",null,"Unexpected Application Error!"),S.createElement("h3",{style:{fontStyle:"italic"}},u),a?S.createElement("pre",{style:p},a):null,null)}const Up=S.createElement(Fp,null);class Bp extends S.Component{constructor(u){super(u),this.state={location:u.location,revalidation:u.revalidation,error:u.error}}static getDerivedStateFromError(u){return{error:u}}static getDerivedStateFromProps(u,a){return a.location!==u.location||a.revalidation!=="idle"&&u.revalidation==="idle"?{error:u.error,location:u.location,revalidation:u.revalidation}:{error:u.error!==void 0?u.error:a.error,location:a.location,revalidation:u.revalidation||a.revalidation}}componentDidCatch(u,a){console.error("React Router caught the following error during render",u,a)}render(){return this.state.error!==void 0?S.createElement(Cn.Provider,{value:this.props.routeContext},S.createElement(Qc.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Ap(i){let{routeContext:u,match:a,children:d}=i,p=S.useContext(Eo);return p&&p.static&&p.staticContext&&(a.route.errorElement||a.route.ErrorBoundary)&&(p.staticContext._deepestRenderedBoundaryId=a.route.id),S.createElement(Cn.Provider,{value:u},d)}function $p(i,u,a,d){var p;if(u===void 0&&(u=[]),a===void 0&&(a=null),d===void 0&&(d=null),i==null){var h;if(!a)return null;if(a.errors)i=a.matches;else if((h=d)!=null&&h.v7_partialHydration&&u.length===0&&!a.initialized&&a.matches.length>0)i=a.matches;else return null}let g=i,j=(p=a)==null?void 0:p.errors;if(j!=null){let P=g.findIndex(N=>N.route.id&&(j==null?void 0:j[N.route.id])!==void 0);P>=0||Ne(!1),g=g.slice(0,Math.min(g.length,P+1))}let k=!1,_=-1;if(a&&d&&d.v7_partialHydration)for(let P=0;P=0?g=g.slice(0,_+1):g=[g[0]];break}}}return g.reduceRight((P,N,M)=>{let H,K=!1,R=null,E=null;a&&(H=j&&N.route.id?j[N.route.id]:void 0,R=N.route.errorElement||Up,k&&(_<0&&M===0?(Jp("route-fallback"),K=!0,E=null):_===M&&(K=!0,E=N.route.hydrateFallbackElement||null)));let A=u.concat(g.slice(0,M+1)),$=()=>{let G;return H?G=R:K?G=E:N.route.Component?G=S.createElement(N.route.Component,null):N.route.element?G=N.route.element:G=P,S.createElement(Ap,{match:N,routeContext:{outlet:P,matches:A,isDataRoute:a!=null},children:G})};return a&&(N.route.ErrorBoundary||N.route.errorElement||M===0)?S.createElement(Bp,{location:a.location,revalidation:a.revalidation,component:R,error:H,children:$(),routeContext:{outlet:null,matches:A,isDataRoute:!0}}):$()},null)}var Jc=(function(i){return i.UseBlocker="useBlocker",i.UseRevalidator="useRevalidator",i.UseNavigateStable="useNavigate",i})(Jc||{}),Gc=(function(i){return i.UseBlocker="useBlocker",i.UseLoaderData="useLoaderData",i.UseActionData="useActionData",i.UseRouteError="useRouteError",i.UseNavigation="useNavigation",i.UseRouteLoaderData="useRouteLoaderData",i.UseMatches="useMatches",i.UseRevalidator="useRevalidator",i.UseNavigateStable="useNavigate",i.UseRouteId="useRouteId",i})(Gc||{});function Vp(i){let u=S.useContext(Eo);return u||Ne(!1),u}function Hp(i){let u=S.useContext(Hc);return u||Ne(!1),u}function Qp(i){let u=S.useContext(Cn);return u||Ne(!1),u}function Xc(i){let u=Qp(),a=u.matches[u.matches.length-1];return a.route.id||Ne(!1),a.route.id}function Kp(){var i;let u=S.useContext(Qc),a=Hp(),d=Xc();return u!==void 0?u:(i=a.errors)==null?void 0:i[d]}function Yp(){let{router:i}=Vp(Jc.UseNavigateStable),u=Xc(Gc.UseNavigateStable),a=S.useRef(!1);return Kc(()=>{a.current=!0}),S.useCallback(function(p,h){h===void 0&&(h={}),a.current&&(typeof p=="number"?i.navigate(p):i.navigate(p,ul({fromRouteId:u},h)))},[i,u])}const Rc={};function Jp(i,u,a){Rc[i]||(Rc[i]=!0)}function Gp(i,u){i==null||i.v7_startTransition,i==null||i.v7_relativeSplatPath}function xs(i){let{to:u,replace:a,state:d,relative:p}=i;xr()||Ne(!1);let{future:h,static:g}=S.useContext(bt),{matches:j}=S.useContext(Cn),{pathname:k}=kr(),_=Yc(),P=zs(u,Ts(j,h.v7_relativeSplatPath),k,p==="path"),N=JSON.stringify(P);return S.useEffect(()=>_(JSON.parse(N),{replace:a,state:d,relative:p}),[_,N,p,a,d]),null}function il(i){Ne(!1)}function Xp(i){let{basename:u="/",children:a=null,location:d,navigationType:p=Sn.Pop,navigator:h,static:g=!1,future:j}=i;xr()&&Ne(!1);let k=u.replace(/^\/*/,"/"),_=S.useMemo(()=>({basename:k,navigator:h,static:g,future:ul({v7_relativeSplatPath:!1},j)}),[k,j,h,g]);typeof d=="string"&&(d=yr(d));let{pathname:P="/",search:N="",hash:M="",state:H=null,key:K="default"}=d,R=S.useMemo(()=>{let E=vr(P,k);return E==null?null:{location:{pathname:E,search:N,hash:M,state:H,key:K},navigationType:p}},[k,P,N,M,H,K,p]);return R==null?null:S.createElement(bt.Provider,{value:_},S.createElement(_o.Provider,{children:a,value:R}))}function Zp(i){let{children:u,location:a}=i;return Ip(Es(u),a)}new Promise(()=>{});function Es(i,u){u===void 0&&(u=[]);let a=[];return S.Children.forEach(i,(d,p)=>{if(!S.isValidElement(d))return;let h=[...u,p];if(d.type===S.Fragment){a.push.apply(a,Es(d.props.children,h));return}d.type!==il&&Ne(!1),!d.props.index||!d.props.children||Ne(!1);let g={id:d.props.id||h.join("-"),caseSensitive:d.props.caseSensitive,element:d.props.element,Component:d.props.Component,index:d.props.index,path:d.props.path,loader:d.props.loader,action:d.props.action,errorElement:d.props.errorElement,ErrorBoundary:d.props.ErrorBoundary,hasErrorBoundary:d.props.ErrorBoundary!=null||d.props.errorElement!=null,shouldRevalidate:d.props.shouldRevalidate,handle:d.props.handle,lazy:d.props.lazy};d.props.children&&(g.children=Es(d.props.children,h)),a.push(g)}),a}/** - * React Router DOM v6.30.4 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */function Co(){return Co=Object.assign?Object.assign.bind():function(i){for(var u=1;u{_&&Tc?Tc(()=>k(N)):k(N)},[k,_]);return S.useLayoutEffect(()=>g.listen(P),[g,P]),S.useEffect(()=>Gp(d),[d]),S.createElement(Xp,{basename:u,children:a,location:j.location,navigationType:j.action,navigator:g,future:d})}const ih=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",sh=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ah=S.forwardRef(function(u,a){let{onClick:d,relative:p,reloadDocument:h,replace:g,state:j,target:k,to:_,preventScrollReset:P,viewTransition:N}=u,M=Zc(u,eh),{basename:H}=S.useContext(bt),K,R=!1;if(typeof _=="string"&&sh.test(_)&&(K=_,ih))try{let G=new URL(window.location.href),B=_.startsWith("//")?new URL(G.protocol+_):new URL(_),ce=vr(B.pathname,H);B.origin===G.origin&&ce!=null?_=ce+B.search+B.hash:R=!0}catch{}let E=Dp(_,{relative:p}),A=dh(_,{replace:g,state:j,target:k,preventScrollReset:P,relative:p,viewTransition:N});function $(G){d&&d(G),G.defaultPrevented||A(G)}return S.createElement("a",Co({},M,{href:K||E,onClick:R||h?d:$,ref:a,target:k}))}),uh=S.forwardRef(function(u,a){let{"aria-current":d="page",caseSensitive:p=!1,className:h="",end:g=!1,style:j,to:k,viewTransition:_,children:P}=u,N=Zc(u,th),M=No(k,{relative:N.relative}),H=kr(),K=S.useContext(Hc),{navigator:R,basename:E}=S.useContext(bt),A=K!=null&&fh(M)&&_===!0,$=R.encodeLocation?R.encodeLocation(M).pathname:M.pathname,G=H.pathname,B=K&&K.navigation&&K.navigation.location?K.navigation.location.pathname:null;p||(G=G.toLowerCase(),B=B?B.toLowerCase():null,$=$.toLowerCase()),B&&E&&(B=vr(B,E)||B);const ce=$!=="/"&&$.endsWith("/")?$.length-1:$.length;let de=G===$||!g&&G.startsWith($)&&G.charAt(ce)==="/",je=B!=null&&(B===$||!g&&B.startsWith($)&&B.charAt($.length)==="/"),xe={isActive:de,isPending:je,isTransitioning:A},Je=de?d:void 0,Ie;typeof h=="function"?Ie=h(xe):Ie=[h,de?"active":null,je?"pending":null,A?"transitioning":null].filter(Boolean).join(" ");let He=typeof j=="function"?j(xe):j;return S.createElement(ah,Co({},N,{"aria-current":Je,className:Ie,ref:a,style:He,to:k,viewTransition:_}),typeof P=="function"?P(xe):P)});var _s;(function(i){i.UseScrollRestoration="useScrollRestoration",i.UseSubmit="useSubmit",i.UseSubmitFetcher="useSubmitFetcher",i.UseFetcher="useFetcher",i.useViewTransitionState="useViewTransitionState"})(_s||(_s={}));var zc;(function(i){i.UseFetcher="useFetcher",i.UseFetchers="useFetchers",i.UseScrollRestoration="useScrollRestoration"})(zc||(zc={}));function ch(i){let u=S.useContext(Eo);return u||Ne(!1),u}function dh(i,u){let{target:a,replace:d,state:p,preventScrollReset:h,relative:g,viewTransition:j}=u===void 0?{}:u,k=Yc(),_=kr(),P=No(i,{relative:g});return S.useCallback(N=>{if(bp(N,a)){N.preventDefault();let M=d!==void 0?d:jo(_)===jo(P);k(i,{replace:M,state:p,preventScrollReset:h,relative:g,viewTransition:j})}},[_,k,P,d,p,a,i,h,g,j])}function fh(i,u){u===void 0&&(u={});let a=S.useContext(rh);a==null&&Ne(!1);let{basename:d}=ch(_s.useViewTransitionState),p=No(i,{relative:u.relative});if(!a.isTransitioning)return!1;let h=vr(a.currentLocation.pathname,d)||a.currentLocation.pathname,g=vr(a.nextLocation.pathname,d)||a.nextLocation.pathname;return Cs(p.pathname,g)!=null||Cs(p.pathname,h)!=null}function ph(){if(window.matchMedia("(display-mode: standalone)").matches)return;const i=document.cookie.split(";").map(a=>a.trim()).find(a=>a.startsWith("hnf_inactivity_mins="));if(!i)return;const u=parseInt(i.split("=")[1]);return isNaN(u)||u<=0?void 0:u*60*1e3}const Lc={background:"var(--navy-dark)",border:"1px solid var(--surface-2)",borderRadius:"6px",color:"var(--text)",padding:"0.625rem 0.75rem",fontSize:"1rem",width:"100%",outline:"none"},hh={background:"var(--hk-green)",color:"#fff",border:"none",borderRadius:"6px",padding:"0.625rem",fontSize:"1rem",fontWeight:600,marginTop:"0.25rem",width:"100%"};function mh({children:i}){const[u,a]=S.useState("checking"),[d,p]=S.useState(null),[h,g]=S.useState(""),[j,k]=S.useState(""),[_,P]=S.useState(""),[N,M]=S.useState(!1),H=S.useRef(null);S.useEffect(()=>{fetch("/api/auth/verify?app=hk-planner",{credentials:"include"}).then(async R=>{R.ok?(p(await R.json()),a("authed")):a("login")}).catch(()=>a("login"))},[]),S.useEffect(()=>{const R=ph();if(u!=="authed"||!R)return;async function E(){await fetch("/api/auth/logout",{method:"POST",credentials:"include"}).catch(()=>{}),p(null),a("login")}function A(){H.current&&clearTimeout(H.current),H.current=setTimeout(E,R)}const $=["mousemove","keydown","click","touchstart"];return $.forEach(G=>window.addEventListener(G,A,{passive:!0})),A(),()=>{H.current&&clearTimeout(H.current),$.forEach(G=>window.removeEventListener(G,A))}},[u]);async function K(R){R.preventDefault(),M(!0),P("");try{if(!(await fetch("/api/auth/login",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:h,password:j})})).ok){P("Invalid email or password");return}const A=await fetch("/api/auth/verify?app=hk-planner",{credentials:"include"});A.ok?(p(await A.json()),a("authed")):P("You don't have access to this app.")}catch{P("Connection error — please try again")}finally{M(!1)}}return u==="checking"?c.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100dvh"},children:c.jsx("div",{style:{color:"var(--text-muted)"},children:"Loading…"})}):u==="login"?c.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100dvh",padding:"1.5rem",background:"var(--navy-dark)"},children:c.jsxs("div",{style:{background:"var(--navy)",borderRadius:"var(--radius)",padding:"2rem",width:"100%",maxWidth:"360px",border:"1px solid var(--surface-2)"},children:[c.jsx("h1",{style:{fontSize:"1.4rem",marginBottom:"0.25rem",color:"#74c69d"},children:"HK Planner"}),c.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.875rem",marginBottom:"1.5rem"},children:void 0}),c.jsxs("form",{onSubmit:K,style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[c.jsx("input",{type:"email",value:h,onChange:R=>g(R.target.value),placeholder:"Email",required:!0,autoComplete:"email",style:Lc}),c.jsx("input",{type:"password",value:j,onChange:R=>k(R.target.value),placeholder:"Password",required:!0,autoComplete:"current-password",style:Lc}),_&&c.jsx("p",{style:{color:"#f87171",fontSize:"0.875rem"},children:_}),c.jsx("button",{type:"submit",disabled:N,style:hh,children:N?"Signing in…":"Sign in"})]})]})}):c.jsx(c.Fragment,{children:i(d)})}/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const qc=(...i)=>i.filter((u,a,d)=>!!u&&u.trim()!==""&&d.indexOf(u)===a).join(" ").trim();/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const vh=i=>i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const gh=i=>i.replace(/^([A-Z])|[\s-_]+(\w)/g,(u,a,d)=>d?d.toUpperCase():a.toLowerCase());/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Oc=i=>{const u=gh(i);return u.charAt(0).toUpperCase()+u.slice(1)};/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */var ks={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const yh=i=>{for(const u in i)if(u.startsWith("aria-")||u==="role"||u==="title")return!0;return!1},xh=S.createContext({}),kh=()=>S.useContext(xh),wh=S.forwardRef(({color:i,size:u,strokeWidth:a,absoluteStrokeWidth:d,className:p="",children:h,iconNode:g,...j},k)=>{const{size:_=24,strokeWidth:P=2,absoluteStrokeWidth:N=!1,color:M="currentColor",className:H=""}=kh()??{},K=d??N?Number(a??P)*24/Number(u??_):a??P;return S.createElement("svg",{ref:k,...ks,width:u??_??ks.width,height:u??_??ks.height,stroke:i??M,strokeWidth:K,className:qc("lucide",H,p),...!h&&!yh(j)&&{"aria-hidden":"true"},...j},[...g.map(([R,E])=>S.createElement(R,E)),...Array.isArray(h)?h:[h]])});/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const cl=(i,u)=>{const a=S.forwardRef(({className:d,...p},h)=>S.createElement(wh,{ref:h,iconNode:u,className:qc(`lucide-${vh(Oc(i))}`,`lucide-${i}`,d),...p}));return a.displayName=Oc(i),a};/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Sh=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],Dc=cl("calendar-clock",Sh);/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const jh=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Ch=cl("grip-vertical",jh);/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Eh=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],_h=cl("log-out",Eh);/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Nh=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Ns=cl("refresh-cw",Nh);/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Ph=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Rh=cl("settings",Ph);function Th({visible:i}){return i?c.jsxs("div",{style:{position:"fixed",bottom:0,left:0,right:0,zIndex:9999,background:"var(--sidebar)",color:"var(--text-light)",display:"flex",alignItems:"center",justifyContent:"center",gap:"12px",padding:"10px 16px",fontSize:"14px",boxShadow:"0 -2px 8px rgba(0,0,0,0.3)"},children:[c.jsx("span",{children:"A new version is available."}),c.jsxs("button",{onClick:()=>window.location.reload(),style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--accent)",color:"var(--sidebar)",border:"none",borderRadius:"4px",padding:"6px 14px",fontWeight:600,cursor:"pointer",fontSize:"13px"},children:[c.jsx(Ns,{size:14,strokeWidth:1.75}),"Reload"]})]}):null}const zh=120*1e3;function Lh(i){const[u,a]=S.useState(!1);return S.useEffect(()=>{let d=null;async function p(){try{const j=await fetch(i,{cache:"no-store"});if(!j.ok)return;const _=(await j.json()).version;if(!_)return;d===null?d=_:_!==d&&a(!0)}catch{}}p();const h=setInterval(p,zh);function g(){document.visibilityState==="visible"&&p()}return document.addEventListener("visibilitychange",g),()=>{clearInterval(h),document.removeEventListener("visibilitychange",g)}},[i]),u}function bc(i,u){return i.is_admin||i.caps.includes(u)}const Oh="width=1280",Dh="width=device-width, initial-scale=1.0";function Mc(i){const u=document.querySelector('meta[name="viewport"]');u&&(u.content=i)}function Mh(i){S.useEffect(()=>(Mc(Oh),window.parent.postMessage({type:"hnf:viewport",mode:i},"*"),()=>{Mc(Dh),window.parent.postMessage({type:"hnf:viewport",mode:"responsive"},"*")}),[i])}function Ih({user:i,children:u}){Mh("desktop");async function a(){await fetch("/hk-planner/api/auth/logout",{method:"POST",credentials:"include"}),window.location.reload()}return c.jsxs("div",{style:{display:"flex",height:"100dvh",overflow:"hidden"},children:[c.jsxs("nav",{style:{width:"200px",flexShrink:0,background:"var(--navy)",display:"flex",flexDirection:"column",padding:"1rem 0",borderRight:"1px solid var(--surface-2)"},children:[c.jsx("div",{style:{padding:"0 1rem 1rem",borderBottom:"1px solid var(--surface-2)"},children:c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[c.jsx(Dc,{size:20,strokeWidth:1.75,color:"#74c69d"}),c.jsx("span",{style:{color:"#74c69d",fontWeight:700,fontSize:"0.95rem"},children:"HK Planner"})]})}),c.jsxs("div",{className:"nav-scroll",style:{flex:1,padding:"0.5rem 0",overflowY:"auto"},children:[c.jsx(Ic,{to:"/planner",icon:Dc,label:"Planner"}),bc(i,"settings")&&c.jsx(Ic,{to:"/settings",icon:Rh,label:"Settings"})]}),c.jsxs("div",{style:{padding:"0.75rem 1rem",borderTop:"1px solid var(--surface-2)"},children:[c.jsxs("div",{style:{marginBottom:"0.5rem"},children:[c.jsx("div",{style:{color:"var(--text)",fontSize:"0.8rem",fontWeight:600},children:i.name}),c.jsx("div",{style:{color:"var(--text-muted)",fontSize:"0.72rem"},children:i.email})]}),c.jsxs("button",{onClick:a,style:{display:"flex",alignItems:"center",gap:"0.5rem",background:"none",border:"none",color:"var(--text-muted)",fontSize:"0.8rem",padding:"0.375rem 0",width:"100%",cursor:"pointer"},children:[c.jsx(_h,{size:14,strokeWidth:1.75}),"Sign out"]})]})]}),c.jsx("main",{style:{flex:1,overflow:"auto",background:"var(--body-bg)"},children:u})]})}function Ic({to:i,icon:u,label:a}){return c.jsxs(uh,{to:i,style:({isActive:d})=>({display:"flex",alignItems:"center",gap:"0.625rem",padding:"0.625rem 1rem",textDecoration:"none",color:d?"#74c69d":"var(--text)",background:d?"var(--surface)":"transparent",borderLeft:d?"2px solid #74c69d":"2px solid transparent",fontSize:"0.875rem",transition:"background 0.15s"}),children:[c.jsx(u,{size:15,strokeWidth:1.75}),a]})}const Wh="/hk-planner/api";async function et(i,u){const a=await fetch(Wh+i,{credentials:"include",...u});if(a.status===401)throw(window.top??window).location.href="/login",new Error("Unauthenticated");if(!a.ok){const d=await a.json().catch(()=>({}));throw new Error(d.error||`HTTP ${a.status}`)}return a.json()}function Fh(i,u,a=!1){const d=new URLSearchParams;return i&&d.set("week_start",i),u&&d.set("last_viewed",u),a&&d.set("force_refresh","1"),et(`/bookings?${d}`)}function ed(){return et("/config")}function Uh(i,u,a){return et("/config/time-requirements",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cat:i,action:u,value:a})})}function Bh(i){return et("/config/staff",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({staff_data:i})})}function Ah(i){return et("/config/pickup",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({pickup_data:i})})}function $h(i){return et("/config/general-tasks",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({general_tasks:i})})}function Vh(i){return et("/config/last-reviewed",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({date:i})})}function Hh(){return et("/categories")}function Qh(i,u){return et("/categories",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:i,excluded:u})})}function Kh(){return et("/newbook/test",{method:"POST"})}function Yh(){return et("/workforce/departments")}function Jh(i){return et("/config/workforce-departments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dept_ids:i})})}function Gh(i,u){return et(`/workforce/sync?start=${i}&end=${u}`,{method:"POST"})}function Xh(){return et("/workforce/staff")}function Zh(i){return et("/config/adjustments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({adjustments:i})})}function qh(i){return et("/config/warning-thresholds",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}function ko(){const i=new Date;return`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(i.getDate()).padStart(2,"0")}`}function ws(i,u){const[a,d,p]=i.split("-").map(Number),h=new Date(a,d-1,p);return h.setDate(h.getDate()+u),`${h.getFullYear()}-${String(h.getMonth()+1).padStart(2,"0")}-${String(h.getDate()).padStart(2,"0")}`}function Po(i){const u=new Date(i+"T00:00:00");return["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][u.getDay()]+" "+u.getDate()+" "+["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][u.getMonth()]}function bh(i){const u=new Date(i+"T00:00:00");return["Mon","Tue","Wed","Thu","Fri","Sat","Sun"][(u.getDay()+6)%7]}function em(i){const u=new Date(i+"T00:00:00");return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][u.getDay()]}function sl(i){const u=new Date(i+"T00:00:00").getDay();return u===0||u===6}function tm(i,u){const a=u.pickup_hint??0,d=u.pickup_lead??0,p=a>0?`${a} room${a===1?"":"s"} picked up within ${d} day${d===1?"":"s"} of arrival`:"no late pickups";return`Last ${em(i)}: ${u.prior_occ} occ (${u.prior_vac} vac) — ${p}`}function Wc(i){return new Date(i+"T00:00:00").toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})}function Ye(i){return i.toFixed(2)+"h"}function gr(i,u,a,d,p){var _;const h=Math.max(0,p-d),g=(_=i[u])==null?void 0:_[a];if(!g||!g.count)return 0;const j=g.total-g.count,k=d>j?Math.max(0,g.total-d):g.count;return Math.min(k,h)}function nm(i,u,a,d,p){const h={};for(const g of i.dates){const j=bh(g),k=d.reduce((P,N)=>P+(N.hours[j]||0)/60,0),_=p.reduce((P,N)=>P+(N.hours[g]||0),0);h[g]={booked:0,pickup:0,general:k,adjustments:_,total:k+_,by_cat:{},pickup_by_cat:{}}}for(const g of i.categories){const j=u[g.id]||{depart:0,stay:0,arrive:0};i.dates.forEach((k,_)=>{const P=g.days[k],N=P.stays+P.arrivals,M=gr(a,g.id,k,N,g.total_rooms),H=(P.departs*(j.depart||0)+P.stays*(j.stay||0)+P.arrivals*(j.arrive||0))/60,K=M*(j.arrive||0)/60;h[k].by_cat[g.id]=H,h[k].pickup_by_cat[g.id]=(h[k].pickup_by_cat[g.id]||0)+K,h[k].booked+=H,h[k].pickup+=K,h[k].total+=H+K;const R=i.dates[_+1];if(R&&M>0){const E=M*(j.depart||0)/60;h[R].pickup_by_cat[g.id]=(h[R].pickup_by_cat[g.id]||0)+E,h[R].pickup+=E,h[R].total+=E}})}return h}function rm(){const[i,u]=S.useState(null),[a,d]=S.useState({}),[p,h]=S.useState([]),[g,j]=S.useState({}),[k,_]=S.useState([]),[P,N]=S.useState([]),[M,H]=S.useState(4),[K,R]=S.useState(1),[E,A]=S.useState(1),[$,G]=S.useState(2),[B,ce]=S.useState(null),[de,je]=S.useState([]),[xe,Je]=S.useState(!1),[Ie,He]=S.useState(null),[Ce,Pe]=S.useState(""),[Be,Ge]=S.useState(""),[Le,me]=S.useState(!0),[W,X]=S.useState(""),[F,y]=S.useState(null),T=S.useRef({}),ee=S.useRef(null),re=S.useRef(!1),le=S.useRef(null);le.current=Ie;function oe(ne,ve,tt=400){clearTimeout(T.current[ne]),T.current[ne]=setTimeout(ve,tt)}function ae(ne,ve=!1){ee.current&&clearTimeout(ee.current),y({text:ne,err:ve}),ee.current=setTimeout(()=>y(null),ve?5e3:2500)}function se(){const ne=ko();ne!==Be&&(Ge(ne),Vh(ne).catch(()=>{}))}const fe=S.useCallback(async(ne=!1,ve)=>{me(!0),X("");const tt=ko(),zt=le.current||tt,Lt=ve!==void 0?ve||ws(tt,-1):Ce||Be||ws(tt,-1);try{const[nt,Oe]=await Promise.all([Fh(zt,Lt,ne),ed()]);u(nt),d(Oe.time_requirements||{}),h(Oe.staff_data||[]),j(Oe.pickup_data||{}),_(Oe.general_tasks||[]),N(Oe.adjustments||[]),H(Oe.warn_over_red_hrs??4),R(Oe.warn_over_amber_hrs??1),A(Oe.warn_under_amber_hrs??1),G(Oe.warn_under_red_hrs??2),ce(Oe.workforce_rota||null),Oe.last_reviewed&&(Ge(Oe.last_reviewed),Ce||Pe(Oe.last_reviewed))}catch(nt){X(nt instanceof Error?nt.message:"Failed to load data")}finally{me(!1)}},[Ce,Be]);S.useEffect(()=>{fe(!1)},[]),S.useEffect(()=>{B&&!re.current&&(re.current=!0,Xh().then(je).catch(()=>{}))},[B]),S.useEffect(()=>{function ne(){p.length&&navigator.sendBeacon("/hk-planner/api/config/staff",JSON.stringify({staff_data:p})),Object.keys(g).length&&navigator.sendBeacon("/hk-planner/api/config/pickup",JSON.stringify({pickup_data:g})),P.length&&navigator.sendBeacon("/hk-planner/api/config/adjustments",JSON.stringify({adjustments:P}))}return window.addEventListener("beforeunload",ne),()=>window.removeEventListener("beforeunload",ne)},[p,g,P]);function We(ne){const ve=ko(),tt=ws(le.current||ve,ne);le.current=tt,He(tt),se(),fe(!0)}function Bt(){le.current=null,He(null),se(),fe(!0)}function En(){se(),fe(!0)}function At(ne,ve,tt,zt){const Lt=zt.days[ve],nt=Lt.stays+Lt.arrivals,Oe=Math.max(0,zt.total_rooms-nt),Ht=gr(g,ne,ve,nt,zt.total_rooms),Ot=Math.max(0,Math.min(Ht+tt,Oe)),Rn={...g,[ne]:{...g[ne]||{},[ve]:{count:Ot,total:nt+Ot}}};j(Rn),se(),oe("pickup",()=>Ah(Rn).then(()=>ae("Pickup saved")).catch(Vn=>ae(Vn.message,!0)))}function $t(ne){N(ne),oe("adjustments",()=>Zh(ne).then(()=>ae("Adjustments saved")).catch(ve=>ae(ve.message,!0)))}function _n(){$t([...P,{label:"",hours:{}}])}function en(ne){h(ne),se(),oe("staff",()=>Bh(ne).then(()=>ae("Staff hours saved")).catch(ve=>ae(ve.message,!0)))}function Vt(){en([...p,{name:"",hours:{}}])}async function Nn(){if(i){Je(!0);try{const ne=await Gh(i.dates[0],i.dates[i.dates.length-1]);ce(ne),ae("Rota synced from Workforce")}catch(ne){ae(ne instanceof Error?ne.message:"Sync failed",!0)}finally{Je(!1)}}}function tn(){if(!B)return"Never synced";const ne=new Date(B.last_sync).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"});return i&&B.dates[0]===i.dates[0]&&B.dates[1]===i.dates[i.dates.length-1]?`Synced ${ne}`:`Synced ${ne} — different week`}const St=i?nm(i,a,g,k,P):null,Tt=ko(),Pn=Ie||Tt;return c.jsxs("div",{style:{padding:"1.5rem",maxWidth:"1600px"},children:[c.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0.75rem",marginBottom:"1.25rem"},children:[c.jsxs("div",{children:[c.jsx("h1",{style:{fontSize:"1.15rem",fontWeight:700,color:"var(--text-dark)"},children:"Housekeeping Planner"}),i&&c.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-mid)",marginTop:"0.1rem"},children:[Wc(i.dates[0])," – ",Wc(i.dates[i.dates.length-1])]})]}),c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.4rem",marginLeft:"auto",flexWrap:"wrap"},children:[c.jsx(hr,{onClick:()=>We(-7),children:"‹ Prev"}),c.jsx(hr,{onClick:Bt,primary:!0,children:"Today"}),c.jsx(hr,{onClick:()=>We(7),children:"Next ›"}),c.jsx("input",{type:"date",value:Pn,onChange:ne=>{if(ne.target.value){const ve=ne.target.value;le.current=ve,He(ve),se(),oe("weekStart",()=>fe(!0),600)}},style:{border:"1px solid var(--card-border)",borderRadius:"6px",padding:"0.35rem 0.5rem",fontSize:"0.82rem",color:"var(--text-dark)"}}),c.jsx("div",{style:{width:"1px",height:"24px",background:"var(--card-border)"}}),c.jsxs("label",{style:{fontSize:"0.78rem",color:"var(--text-mid)",display:"flex",alignItems:"center",gap:"0.3rem"},children:[c.jsx("span",{children:"Since"}),c.jsx("input",{type:"date",value:Ce,onChange:ne=>{if(ne.target.value){const ve=ne.target.value;Pe(ve),oe("lastViewed",()=>fe(!0,ve),600)}},style:{border:"1px solid var(--card-border)",borderRadius:"6px",padding:"0.3rem 0.5rem",fontSize:"0.78rem",color:"var(--text-dark)"}})]}),c.jsx(hr,{onClick:()=>{se(),fe(!0)},children:"Update to now"}),c.jsx("div",{style:{width:"1px",height:"24px",background:"var(--card-border)"}}),c.jsx("button",{onClick:En,title:"Refresh",style:{background:"var(--card-bg)",border:"1px solid var(--card-border)",borderRadius:"6px",padding:"0.35rem 0.5rem",display:"flex",alignItems:"center",gap:"0.3rem",fontSize:"0.82rem",color:"var(--text-dark)"},children:c.jsx(Ns,{size:13,strokeWidth:1.75,style:{animation:Le?"spin 1s linear infinite":"none"}})})]})]}),c.jsx("style",{children:"@keyframes spin { from { transform: rotate(0deg) } to { transform: rotate(360deg) } }"}),F&&c.jsx("div",{style:{display:"inline-block",marginBottom:"0.75rem",padding:"0.35rem 0.75rem",borderRadius:"6px",fontSize:"0.8rem",fontWeight:500,background:F.err?"#fee2e2":"#dcfce7",color:F.err?"var(--danger)":"var(--success)"},children:F.text}),W&&c.jsxs("div",{style:{marginBottom:"1rem",padding:"0.75rem 1rem",borderRadius:"8px",background:"#fee2e2",color:"var(--danger)",fontSize:"0.875rem"},children:["Error: ",W]}),Le&&!i&&c.jsx("div",{style:{color:"var(--text-mid)",padding:"2rem 0",textAlign:"center"},children:"Loading bookings…"}),i&&St&&c.jsxs(c.Fragment,{children:[c.jsx(wo,{title:"7-Day Occupancy",children:c.jsx("div",{className:"table-scroll",children:c.jsx(lm,{bookings:i,pickup:g,onPickupChange:At})})}),c.jsx(wo,{title:"Required Hours",children:c.jsx("div",{className:"table-scroll",children:c.jsx(sm,{bookings:i,required:St})})}),c.jsx(wo,{title:"Adjustments",action:c.jsx(hr,{onClick:_n,children:"+ Add adjustment"}),children:c.jsx("div",{className:"table-scroll",children:c.jsx(cm,{bookings:i,adjustments:P,onChange:$t})})}),c.jsx(wo,{title:"Staff Rota",action:c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",flexWrap:"wrap"},children:[c.jsxs("button",{onClick:Nn,disabled:xe,style:{display:"flex",alignItems:"center",gap:"0.3rem",background:"var(--card-bg)",color:"var(--text-dark)",border:"1px solid var(--card-border)",borderRadius:"6px",padding:"0.3rem 0.65rem",fontSize:"0.78rem",fontWeight:600},children:[c.jsx(Ns,{size:11,strokeWidth:1.75,style:{animation:xe?"spin 1s linear infinite":"none"}}),xe?"Syncing…":"Sync from Workforce"]}),c.jsx("span",{style:{fontSize:"0.72rem",color:"var(--text-mid)"},children:tn()}),c.jsx(hr,{onClick:Vt,children:"+ Add staff"})]}),children:c.jsx("div",{className:"table-scroll",children:c.jsx(am,{bookings:i,staff:p,required:St,warnOverRed:M,warnOverAmber:K,warnUnderAmber:E,warnUnderRed:$,onChange:en,workforceRota:B,wfStaff:de})})})]})]})}function wo({title:i,children:u,action:a}){return c.jsxs("div",{style:{marginBottom:"1.5rem"},children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",marginBottom:"0.5rem"},children:[c.jsx("h2",{style:{fontSize:"0.72rem",fontWeight:700,color:"var(--text-mid)",textTransform:"uppercase",letterSpacing:"0.08em"},children:i}),a]}),u]})}function hr({children:i,onClick:u,primary:a}){return c.jsx("button",{onClick:u,style:{background:a?"var(--hk-green)":"var(--card-bg)",color:a?"#fff":"var(--text-dark)",border:`1px solid ${a?"var(--hk-green)":"var(--card-border)"}`,borderRadius:"6px",padding:"0.35rem 0.75rem",fontSize:"0.82rem",fontWeight:600},children:i})}function lm({bookings:i,pickup:u,onPickupChange:a}){const{dates:d,categories:p}=i;return c.jsxs("table",{className:"hk-table",children:[c.jsxs("thead",{children:[c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",rowSpan:2,children:"Category"}),d.map(h=>c.jsx("th",{colSpan:2,style:{borderLeft:"2px solid rgba(255,255,255,0.3)",...sl(h)?{background:"#253555"}:{}},children:Po(h)},h))]}),c.jsx("tr",{children:d.map(h=>c.jsxs(c.Fragment,{children:[c.jsx("th",{style:{fontSize:"0.72rem",fontWeight:400,minWidth:"72px",background:sl(h)?"#2a3d5e":"#1e2d42",borderLeft:"2px solid rgba(255,255,255,0.3)"},children:"Rooms"},h+"-r"),c.jsx("th",{style:{fontSize:"0.72rem",fontWeight:400,minWidth:"56px",textAlign:"center",background:sl(h)?"#2a3d5e":"#1e2d42",borderLeft:"1px solid rgba(255,255,255,0.1)"},children:"D / S / A"},h+"-d")]}))})]}),c.jsx("tbody",{children:p.map((h,g)=>{const j=g===p.length-1;return c.jsx(om,{cat:h,dates:d,pickup:u,onPickupChange:(k,_)=>a(h.id,k,_,h),isLast:j},h.id)})}),c.jsx("tfoot",{children:c.jsx(im,{dates:d,cats:p,pickup:u})})]})}function om({cat:i,dates:u,pickup:a,onPickupChange:d,isLast:p}){const h=p?"2px solid var(--card-border)":void 0;return c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{borderBottom:h},children:i.name}),u.map((g,j)=>{var ce;const k=i.days[g],_=k.stays+k.arrivals,P=Math.max(0,i.total_rooms-_),N=gr(a,i.id,g,_,i.total_rooms),M=u[j-1],H=M?i.days[M].stays+i.days[M].arrivals:0,K=M?gr(a,i.id,M,H,i.total_rooms):0,R=k.delta_new||0,E=k.delta_cancelled||0,A=sl(g),$=(ce=a[i.id])==null?void 0:ce[g],G=tm(g,k);let B="";if($&&$.count){const de=$.total-$.count,je=_>de?"changed":"unchanged",xe=_>de?"decreased":"remains";B=`+${$.count} pickup set when booked was ${de} (target ${$.total}). Booked ${je}, so pickup ${xe}.`}return B=(B?B+" | ":"")+G,c.jsxs(c.Fragment,{children:[c.jsxs("td",{style:{textAlign:"center",verticalAlign:"middle",borderBottom:h,padding:"0.4rem 0.3rem",borderLeft:"2px solid var(--card-border)",...A?{background:"rgba(100,120,160,0.07)"}:{}},children:[(R>0||E>0)&&c.jsxs("div",{style:{marginBottom:"2px",fontSize:"0.72rem"},children:[R>0&&c.jsxs("span",{className:"delta-new",children:["▲",R]}),E>0&&c.jsxs("span",{className:"delta-canc",children:[" ▼",E]})]}),c.jsxs("div",{style:{fontWeight:700,fontSize:"1.1rem"},title:B,children:[_,N>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",N]})]}),c.jsxs("div",{style:{fontSize:"0.72rem",color:"var(--text-mid)",marginBottom:"4px"},children:[P," vac",N>0&&c.jsxs("span",{className:"pickup-tag",children:[" (",P-N,")"]})]}),c.jsxs("div",{className:"pickup-ctrl",children:[c.jsx("button",{className:"pickup-btn",disabled:N<=0,onClick:()=>d(g,-1),children:"−"}),c.jsx("span",{className:"pickup-num",children:N}),c.jsx("button",{className:"pickup-btn",disabled:N>=P,title:G,onClick:()=>d(g,1),children:"+"})]})]},g+"-r"),c.jsxs("td",{style:{verticalAlign:"middle",borderLeft:"1px solid var(--card-border)",borderBottom:h,padding:"0.4rem 0.3rem",textAlign:"center",...A?{background:"rgba(100,120,160,0.07)"}:{}},children:[c.jsxs("div",{style:{fontSize:"0.8rem",color:"#c2502e",fontWeight:600},children:[k.departs,"d",K>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",K]})]}),c.jsxs("div",{style:{fontSize:"0.8rem",color:"#1d6fb8",fontWeight:600},children:[k.stays,"s"]}),c.jsxs("div",{style:{fontSize:"0.8rem",color:"#1a7a4a",fontWeight:600},children:[k.arrivals,"a",N>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",N]})]})]},g+"-dsa")]})})]})}function im({dates:i,cats:u,pickup:a}){return c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontStyle:"italic"},children:"Total"}),i.map((d,p)=>{let h=0,g=0,j=0,k=0,_=0,P=0,N=0,M=0,H=0;for(const R of u){const E=R.days[d],A=E.stays+E.arrivals,$=Math.max(0,R.total_rooms-A),G=gr(a,R.id,d,A,R.total_rooms),B=i[p-1],ce=B?R.days[B].stays+R.days[B].arrivals:0,de=B?gr(a,R.id,B,ce,R.total_rooms):0;h+=A,g+=$,j+=G,k+=de,_+=E.departs,P+=E.stays,N+=E.arrivals,M+=E.delta_new||0,H+=E.delta_cancelled||0}const K=sl(d);return c.jsxs(c.Fragment,{children:[c.jsxs("td",{style:{textAlign:"center",verticalAlign:"middle",padding:"0.4rem 0.3rem",borderLeft:"2px solid var(--card-border)",...K?{background:"rgba(100,120,160,0.07)"}:{}},children:[(M>0||H>0)&&c.jsxs("div",{style:{marginBottom:"2px",fontSize:"0.72rem"},children:[M>0&&c.jsxs("span",{className:"delta-new",children:["▲",M]}),H>0&&c.jsxs("span",{className:"delta-canc",children:[" ▼",H]})]}),c.jsxs("div",{style:{fontWeight:700,fontSize:"1.1rem"},children:[h,j>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",j]})]}),c.jsxs("div",{style:{fontSize:"0.72rem",color:"var(--text-mid)"},children:[g," vac",j>0&&c.jsxs("span",{className:"pickup-tag",children:[" (",g-j,")"]})]})]},d+"-r"),c.jsxs("td",{style:{verticalAlign:"middle",borderLeft:"1px solid var(--card-border)",padding:"0.4rem 0.3rem",textAlign:"center",...K?{background:"rgba(100,120,160,0.07)"}:{}},children:[c.jsxs("div",{style:{fontSize:"0.8rem",color:"#c2502e",fontWeight:600},children:[_,"d",k>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",k]})]}),c.jsxs("div",{style:{fontSize:"0.8rem",color:"#1d6fb8",fontWeight:600},children:[P,"s"]}),c.jsxs("div",{style:{fontSize:"0.8rem",color:"#1a7a4a",fontWeight:600},children:[N,"a",j>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",j]})]})]},d+"-dsa")]})})]})}function sm({bookings:i,required:u}){const{dates:a,categories:d}=i;return c.jsxs("table",{className:"hk-table",children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",children:"Category"}),a.map(p=>c.jsx("th",{children:Po(p)},p))]})}),c.jsx("tbody",{children:d.map(p=>c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",children:p.name}),a.map(h=>{const g=u[h].by_cat[p.id]||0,j=u[h].pickup_by_cat[p.id]||0;return c.jsxs("td",{children:[g===0&&j===0?"—":Ye(g),j>.001&&c.jsxs("span",{className:"pickup-tag",children:[" (+",Ye(j),")"]})]},h)})]},p.id))}),c.jsxs("tfoot",{children:[c.jsxs("tr",{style:{background:"#f1f5f9"},children:[c.jsx("td",{className:"col-label",style:{color:"var(--text-mid)",fontSize:"0.78rem"},children:"Booked hrs"}),a.map(p=>c.jsx("td",{children:Ye(u[p].booked)},p))]}),c.jsxs("tr",{style:{background:"#f1f5f9"},children:[c.jsx("td",{className:"col-label",style:{color:"var(--text-mid)",fontSize:"0.78rem"},children:"Pickup hrs"}),a.map(p=>c.jsx("td",{children:u[p].pickup>.001?Ye(u[p].pickup):"—"},p))]}),c.jsxs("tr",{style:{background:"#f1f5f9"},children:[c.jsx("td",{className:"col-label",style:{color:"var(--text-mid)",fontSize:"0.78rem"},children:"Recurring tasks"}),a.map(p=>c.jsx("td",{children:u[p].general>.001?Ye(u[p].general):"—"},p))]}),a.some(p=>u[p].adjustments!==0)&&c.jsxs("tr",{style:{background:"#f1f5f9"},children:[c.jsx("td",{className:"col-label",style:{color:"var(--text-mid)",fontSize:"0.78rem"},children:"Adjustments"}),a.map(p=>{const h=u[p].adjustments;return c.jsx("td",{style:{color:h<0?"var(--danger)":h>0?"#1a7a4a":"var(--text-mid)"},children:h===0?"—":(h>0?"+":"")+Ye(h)},p)})]}),c.jsxs("tr",{style:{background:"#e2e8f0"},children:[c.jsx("td",{className:"col-label",children:"Total Required"}),a.map(p=>c.jsxs("td",{style:{fontWeight:700},children:[Ye(u[p].total),u[p].pickup>.001&&c.jsxs("span",{className:"pickup-tag",style:{display:"block",fontSize:"0.7rem"},children:["inc ",Ye(u[p].pickup)," pickup"]})]},p))]})]})]})}function am({bookings:i,staff:u,required:a,warnOverRed:d,warnOverAmber:p,warnUnderAmber:h,warnUnderRed:g,onChange:j,workforceRota:k,wfStaff:_}){const{dates:P}=i;function N(R,E){const A=u.map(($,G)=>G===R?{...$,name:E}:$);j(A)}function M(R,E,A){const $=parseFloat(A),G=u.map((B,ce)=>{if(ce!==R)return B;const de={...B.hours};return!isNaN($)&&$>=0?de[E]=$:delete de[E],{...B,hours:de}});j(G)}function H(R){j(u.filter((E,A)=>A!==R))}const K=(k==null?void 0:k.staff)??[];return c.jsxs("table",{className:"hk-table",children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",children:"Staff Member"}),P.map(R=>c.jsx("th",{children:Po(R)},R)),c.jsx("th",{style:{width:"32px"}})]})}),c.jsxs("tbody",{children:[K.map(R=>c.jsxs("tr",{style:{background:"rgba(42,100,72,0.05)"},children:[c.jsxs("td",{className:"col-label",children:[c.jsx("span",{style:{display:"inline-block",fontSize:"0.67rem",fontWeight:700,background:"rgba(42,100,72,0.18)",color:"#1a7a4a",borderRadius:"3px",padding:"0 4px",marginRight:"0.4rem",lineHeight:"1.5"},children:"WF"}),R.name]}),P.map(E=>{const A=R.days[E];return c.jsx("td",{style:{textAlign:"center",padding:"0.3rem 0.4rem",verticalAlign:"middle"},children:A?c.jsxs(c.Fragment,{children:[c.jsx("div",{style:{fontSize:"0.68rem",color:"var(--text-mid)",lineHeight:1.25},children:A.times}),c.jsx("div",{style:{fontWeight:600},children:Ye(A.hours)})]}):c.jsx("span",{style:{color:"var(--text-mid)"},children:"—"})},E)}),c.jsx("td",{})]},"wf-"+R.id)),_.length>0&&c.jsx("datalist",{id:"wf-staff-datalist",children:_.map(R=>c.jsx("option",{value:R.name},R.id))}),u.map((R,E)=>c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{padding:"0.3rem 0.5rem"},children:c.jsx("input",{className:"hk-text-input",value:R.name,placeholder:"Staff name",list:_.length>0?"wf-staff-datalist":void 0,onChange:A=>N(E,A.target.value)})}),P.map(A=>c.jsx("td",{style:{padding:"0.3rem 0.4rem"},children:c.jsx("input",{type:"number",className:"hk-num-input",min:0,max:24,step:.5,value:R.hours[A]??"",placeholder:"0",onChange:$=>M(E,A,$.target.value)})},A)),c.jsx("td",{children:c.jsx("button",{onClick:()=>H(E),style:{background:"none",border:"none",color:"var(--text-mid)",fontSize:"1rem",padding:"0.2rem 0.4rem"},children:"×"})})]},E))]}),c.jsx("tfoot",{children:(()=>{const R={};for(const E of P){const A=K.reduce((G,B)=>{var ce;return G+(((ce=B.days[E])==null?void 0:ce.hours)||0)},0),$=u.reduce((G,B)=>G+(B.hours[E]||0),0);R[E]=A+$}return c.jsxs(c.Fragment,{children:[c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontSize:"0.78rem",color:"var(--text-mid)"},children:"Total Available"}),P.map(E=>c.jsx("td",{children:Ye(R[E])},E)),c.jsx("td",{})]}),c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontSize:"0.72rem",color:"var(--text-mid)"},children:"vs Booked"}),P.map(E=>c.jsx("td",{children:c.jsx(Ss,{available:R[E],required:a[E].booked,warnOverAmber:p,warnUnderAmber:h})},E)),c.jsx("td",{})]}),c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontSize:"0.72rem",color:"var(--text-mid)"},children:"with Recurring Tasks"}),P.map(E=>c.jsx("td",{children:c.jsx(Ss,{available:R[E],required:a[E].booked+a[E].general,warnOverAmber:p,warnUnderAmber:h})},E)),c.jsx("td",{})]}),c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontSize:"0.72rem",color:"var(--text-mid)"},children:"with Pickup"}),P.map(E=>c.jsx("td",{children:c.jsx(Ss,{available:R[E],required:a[E].booked+a[E].general+a[E].pickup,warnOverAmber:p,warnUnderAmber:h})},E)),c.jsx("td",{})]}),c.jsxs("tr",{style:{background:"#e2e8f0"},children:[c.jsx("td",{className:"col-label",style:{fontWeight:700},children:"with Adjustments"}),P.map(E=>c.jsx("td",{children:c.jsx(um,{available:R[E],required:a[E].total,warnOverRed:d,warnOverAmber:p,warnUnderAmber:h,warnUnderRed:g})},E)),c.jsx("td",{})]})]})})()})]})}function Ss({available:i,required:u,warnOverAmber:a,warnUnderAmber:d}){if(i===0&&u===0)return c.jsx("span",{style:{color:"var(--text-mid)"},children:"—"});const p=i-u,h=p>a?"⚠":p<-d?"✗":"✓";return c.jsxs("span",{style:{color:"var(--text-mid)",fontSize:"0.82rem"},children:[h," ",p>=0?"+":"",Ye(p)]})}function um({available:i,required:u,warnOverRed:a,warnOverAmber:d,warnUnderAmber:p,warnUnderRed:h}){if(i===0&&u===0)return c.jsx("span",{style:{color:"var(--text-mid)"},children:"—"});const g=i-u;return g>a?c.jsxs("span",{className:"diff-over-red",children:["⚠ ",Ye(g)," spare"]}):g>d?c.jsxs("span",{className:"diff-over",children:["⚠ ",Ye(g)," spare"]}):g<-h?c.jsxs("span",{className:"diff-under",children:["✗ ",Ye(Math.abs(g))," short"]}):g<-p?c.jsxs("span",{className:"diff-under-amber",children:["✗ ",Ye(Math.abs(g))," short"]}):c.jsxs("span",{className:"diff-ok",children:["✓ ",g>=0?"+":"",Ye(g)]})}function cm({bookings:i,adjustments:u,onChange:a}){const{dates:d}=i;function p(j,k){a(u.map((_,P)=>P===j?{..._,label:k}:_))}function h(j,k,_){const P=parseFloat(_);a(u.map((N,M)=>{if(M!==j)return N;const H={...N.hours};return isNaN(P)?delete H[k]:H[k]=P,{...N,hours:H}}))}function g(j){a(u.filter((k,_)=>_!==j))}return u.length===0?c.jsx("p",{style:{color:"var(--text-mid)",fontSize:"0.82rem",padding:"0.5rem 0"},children:'No adjustments — use "+ Add adjustment" above to add a one-off hour offset for a specific date.'}):c.jsxs("table",{className:"hk-table",children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",children:"Label"}),d.map(j=>c.jsx("th",{children:Po(j)},j)),c.jsx("th",{style:{width:"32px"}})]})}),c.jsx("tbody",{children:u.map((j,k)=>c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{padding:"0.3rem 0.5rem"},children:c.jsx("input",{className:"hk-text-input",value:j.label,placeholder:"e.g. Rooms from Sunday",onChange:_=>p(k,_.target.value)})}),d.map(_=>c.jsx("td",{style:{padding:"0.3rem 0.4rem"},children:c.jsx("input",{type:"number",className:"hk-num-input",step:.25,value:j.hours[_]??"",placeholder:"0",onChange:P=>h(k,_,P.target.value)})},_)),c.jsx("td",{children:c.jsx("button",{onClick:()=>g(k),style:{background:"none",border:"none",color:"var(--text-mid)",fontSize:"1rem",padding:"0.2rem 0.4rem"},children:"×"})})]},k))}),c.jsx("tfoot",{children:c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontSize:"0.78rem",color:"var(--text-mid)"},children:"Total"}),d.map(j=>{const k=u.reduce((_,P)=>_+(P.hours[j]||0),0);return c.jsx("td",{style:{color:k<0?"var(--danger)":k>0?"#1a7a4a":"var(--text-mid)",fontWeight:k!==0?600:void 0},children:k===0?"—":(k>0?"+":"")+Ye(k)},j)}),c.jsx("td",{})]})})]})}const Fc=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];function dm(){const[i,u]=S.useState([]),[a,d]=S.useState(!0),[p,h]=S.useState(!1),[g,j]=S.useState(!1),[k,_]=S.useState(""),[P,N]=S.useState(""),[M,H]=S.useState(null),[K,R]=S.useState([]),[E,A]=S.useState([]),[$,G]=S.useState(!0),[B,ce]=S.useState(""),[de,je]=S.useState(!1),[xe,Je]=S.useState(!1),[Ie,He]=S.useState(""),[Ce,Pe]=S.useState([]),[Be,Ge]=S.useState(!1),[Le,me]=S.useState(""),[W,X]=S.useState(""),[F,y]=S.useState({}),[T,ee]=S.useState(""),[re,le]=S.useState(""),[oe,ae]=S.useState(4),[se,fe]=S.useState(1),[We,Bt]=S.useState(1),[En,At]=S.useState(2),[$t,_n]=S.useState(!1),[en,Vt]=S.useState(""),[Nn,tn]=S.useState("");S.useEffect(()=>{Promise.all([Hh(),ed(),Yh().catch(I=>(I.message.includes("503")||I.message.toLowerCase().includes("not configured")?je(!0):ce(I.message),null))]).then(([I,te,ie])=>{u(I.categories),Pe(te.general_tasks||[]),y(te.time_requirements||{}),A(te.workforce_departments||[]),ae(te.warn_over_red_hrs??4),fe(te.warn_over_amber_hrs??1),Bt(te.warn_under_amber_hrs??1),At(te.warn_under_red_hrs??2),ie&&R(ie),d(!1),G(!1)}).catch(I=>{_(I.message),d(!1),G(!1)})},[]);function St(I){u(i.map((te,ie)=>ie===I?{...te,excluded:!te.excluded}:te))}function Tt(I,te){H(te),I.dataTransfer.effectAllowed="move"}function Pn(I,te){if(I.preventDefault(),M===null||M===te)return;const ie=[...i],[De]=ie.splice(M,1);ie.splice(te,0,De),u(ie),H(te)}function ne(){H(null)}async function ve(){h(!0),_(""),N("");try{await Qh(i.map(I=>I.id),i.filter(I=>I.excluded).map(I=>I.id)),N("Saved"),setTimeout(()=>N(""),2500)}catch(I){_(I instanceof Error?I.message:"Save failed")}finally{h(!1)}}async function tt(){j(!0),_(""),N("");try{const I=await Kh();N(I.ok?`Connection OK: ${I.message||""}`:`Failed: ${I.error||"unknown"}`)}catch(I){_(I instanceof Error?I.message:"Test failed")}finally{j(!1)}}function zt(I){A(te=>te.includes(I)?te.filter(ie=>ie!==I):[...te,I])}async function Lt(){Je(!0),ce(""),He("");try{await Jh(E),He("Departments saved"),setTimeout(()=>He(""),2500)}catch(I){ce(I instanceof Error?I.message:"Save failed")}finally{Je(!1)}}function nt(I,te){Pe(Ce.map((ie,De)=>De===I?{...ie,name:te}:ie))}function Oe(I,te,ie){const De=parseInt(ie,10);Pe(Ce.map((mt,wr)=>wr!==I?mt:{...mt,hours:{...mt.hours,[te]:isNaN(De)?0:Math.max(0,De)}}))}function Ht(I){Pe(Ce.filter((te,ie)=>ie!==I))}async function Ot(){Ge(!0),X(""),me("");try{await $h(Ce),me("Saved"),setTimeout(()=>me(""),2500)}catch(I){X(I instanceof Error?I.message:"Save failed")}finally{Ge(!1)}}async function Rn(I,te,ie){const De={...F,[I]:{...F[I]||{depart:0,stay:0,arrive:0},[te]:ie}};y(De);try{await Uh(I,te,ie),ee("Saved"),setTimeout(()=>ee(""),1500)}catch(mt){le(mt instanceof Error?mt.message:"Save failed")}}async function Vn(){_n(!0),tn(""),Vt("");try{await qh({warn_over_red_hrs:oe,warn_over_amber_hrs:se,warn_under_amber_hrs:We,warn_under_red_hrs:En}),Vt("Saved"),setTimeout(()=>Vt(""),2500)}catch(I){tn(I instanceof Error?I.message:"Save failed")}finally{_n(!1)}}return a?c.jsx("div",{style:{padding:"2rem",color:"var(--text-mid)"},children:"Loading…"}):c.jsxs("div",{style:{padding:"1.5rem",maxWidth:"680px"},children:[c.jsx("h1",{style:{fontSize:"1.1rem",fontWeight:700,color:"var(--text-dark)",marginBottom:"1.5rem"},children:"Settings"}),c.jsx(ol,{title:"Room Categories"}),c.jsx("p",{style:{fontSize:"0.82rem",color:"var(--text-mid)",marginBottom:"1rem"},children:"Drag to reorder. Toggle to exclude categories from the planner."}),k&&c.jsx(Ut,{type:"error",children:k}),P&&c.jsx(Ut,{type:"ok",children:P}),c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:i.map((I,te)=>c.jsxs("div",{draggable:!0,onDragStart:ie=>Tt(ie,te),onDragOver:ie=>Pn(ie,te),onDragEnd:ne,style:{display:"flex",alignItems:"center",gap:"0.75rem",padding:"0.625rem 0.875rem",border:"1px solid var(--card-border)",borderRadius:"8px",background:I.excluded?"#f8fafc":"var(--card-bg)",opacity:M===te?.5:1},children:[c.jsx(Ch,{size:16,color:"var(--text-mid)",style:{cursor:"grab",flexShrink:0}}),c.jsx("span",{style:{flex:1,fontSize:"0.9rem",color:I.excluded?"var(--text-mid)":"var(--text-dark)",textDecoration:I.excluded?"line-through":"none"},children:I.name}),c.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--text-mid)",marginRight:"0.5rem"},children:[I.room_count," rooms"]}),c.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.375rem",fontSize:"0.8rem",color:"var(--text-mid)"},children:[c.jsx("input",{type:"checkbox",checked:!I.excluded,onChange:()=>St(te)}),"Active"]})]},I.id))}),c.jsxs("div",{style:{display:"flex",gap:"0.75rem",flexWrap:"wrap",marginBottom:"2.5rem"},children:[c.jsx(mr,{onClick:ve,disabled:p,primary:!0,children:p?"Saving…":"Save Order & Visibility"}),c.jsx(mr,{onClick:tt,disabled:g,children:g?"Testing…":"Test Newbook Connection"})]}),c.jsx(So,{}),c.jsx(ol,{title:"Workforce Departments"}),c.jsx("p",{style:{fontSize:"0.82rem",color:"var(--text-mid)",marginBottom:"1rem"},children:"Select the department(s) whose shifts should appear in the HK staff rota."}),de&&c.jsxs("div",{style:{padding:"0.75rem",borderRadius:"8px",background:"#f8fafc",border:"1px solid var(--card-border)",color:"var(--text-mid)",fontSize:"0.85rem",marginBottom:"2rem"},children:["Workforce integration not configured — add the bearer token in ",c.jsx("strong",{children:"Settings → Integrations → Workforce"}),"."]}),!de&&$&&c.jsx("div",{style:{color:"var(--text-mid)",fontSize:"0.85rem",marginBottom:"2rem"},children:"Loading departments…"}),!de&&!$&&c.jsxs("div",{style:{marginBottom:"2.5rem"},children:[B&&c.jsx(Ut,{type:"error",children:B}),Ie&&c.jsx(Ut,{type:"ok",children:Ie}),K.length===0?c.jsx("div",{style:{color:"var(--text-mid)",fontSize:"0.85rem",marginBottom:"1rem"},children:"No departments found for this location."}):c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.4rem",marginBottom:"1rem"},children:K.map(I=>c.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.625rem",padding:"0.5rem 0.75rem",border:"1px solid var(--card-border)",borderRadius:"7px",background:E.includes(I.id)?"rgba(42,100,72,0.05)":"var(--card-bg)",cursor:"pointer",fontSize:"0.9rem",color:"var(--text-dark)"},children:[c.jsx("input",{type:"checkbox",checked:E.includes(I.id),onChange:()=>zt(I.id)}),I.name]},I.id))}),E.length===0&&K.length>0&&c.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"#b45309"},children:"Select at least one department to enable Workforce sync."}),c.jsx(mr,{onClick:Lt,disabled:xe,primary:!0,children:xe?"Saving…":"Save Departments"})]}),c.jsx(So,{}),c.jsx(ol,{title:"Recurring General Tasks"}),c.jsx("p",{style:{fontSize:"0.82rem",color:"var(--text-mid)",marginBottom:"1rem"},children:"Tasks that recur every week. Enter minutes per day. These add to the total required hours every week."}),W&&c.jsx(Ut,{type:"error",children:W}),Le&&c.jsx(Ut,{type:"ok",children:Le}),c.jsx("div",{style:{overflowX:"auto",marginBottom:"1rem"},children:c.jsxs("table",{className:"hk-table",style:{minWidth:"560px"},children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",children:"Task"}),Fc.map(I=>c.jsx("th",{children:I},I)),c.jsx("th",{style:{width:"32px"}})]})}),c.jsxs("tbody",{children:[Ce.length===0&&c.jsx("tr",{children:c.jsx("td",{colSpan:9,style:{color:"var(--text-mid)",textAlign:"center",padding:"1rem"},children:"No tasks yet"})}),Ce.map((I,te)=>c.jsxs("tr",{children:[c.jsx("td",{style:{padding:"0.3rem 0.5rem"},children:c.jsx("input",{className:"hk-text-input",value:I.name,placeholder:"Task name",onChange:ie=>nt(te,ie.target.value)})}),Fc.map(ie=>c.jsx("td",{style:{padding:"0.3rem 0.4rem"},children:c.jsx("input",{type:"number",className:"hk-num-input",min:0,max:999,value:I.hours[ie]||"",placeholder:"0",onChange:De=>Oe(te,ie,De.target.value)})},ie)),c.jsx("td",{children:c.jsx("button",{onClick:()=>Ht(te),style:{background:"none",border:"none",color:"var(--text-mid)",fontSize:"1rem",padding:"0.2rem 0.4rem"},children:"×"})})]},te))]})]})}),c.jsxs("div",{style:{display:"flex",gap:"0.75rem",flexWrap:"wrap",marginBottom:"2.5rem"},children:[c.jsx(mr,{onClick:()=>Pe([...Ce,{name:"",hours:{}}]),children:"+ Add task"}),c.jsx(mr,{onClick:Ot,disabled:Be,primary:!0,children:Be?"Saving…":"Save Tasks"})]}),c.jsx(So,{}),c.jsx(ol,{title:"Time Requirements (minutes per room)"}),c.jsx("p",{style:{fontSize:"0.82rem",color:"var(--text-mid)",marginBottom:"1rem"},children:"How many minutes each room type takes depending on guest status."}),re&&c.jsx(Ut,{type:"error",children:re}),T&&c.jsx(Ut,{type:"ok",children:T}),c.jsx("div",{style:{overflowX:"auto",marginBottom:"2rem"},children:c.jsxs("table",{className:"hk-table",style:{maxWidth:"500px"},children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",children:"Category"}),c.jsx("th",{children:"Depart (mins)"}),c.jsx("th",{children:"Stay (mins)"}),c.jsx("th",{children:"Arrive (mins)"})]})}),c.jsx("tbody",{children:i.filter(I=>!I.excluded).map(I=>{const te=F[I.id]||{depart:0,stay:0,arrive:0};return c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",children:I.name}),["depart","stay","arrive"].map(ie=>c.jsx("td",{style:{padding:"0.3rem 0.4rem"},children:c.jsx("input",{type:"number",className:"hk-num-input",min:0,max:999,value:te[ie]||"",placeholder:"0",onChange:De=>Rn(I.id,ie,parseInt(De.target.value,10)||0),onBlur:De=>Rn(I.id,ie,parseInt(De.target.value,10)||0)})},ie))]},I.id)})})]})}),c.jsx(So,{}),c.jsx(ol,{title:"Warning Thresholds"}),c.jsx("p",{style:{fontSize:"0.82rem",color:"var(--text-mid)",marginBottom:"1rem"},children:'Controls the colour and icon shown on the "with Adjustments" row in the staff rota. All values are in hours.'}),Nn&&c.jsx(Ut,{type:"error",children:Nn}),en&&c.jsx(Ut,{type:"ok",children:en}),c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.625rem",marginBottom:"1.25rem",maxWidth:"420px"},children:[{label:"⚠ Red warning — spare over",value:oe,set:ae,help:"default 4h"},{label:"⚠ Amber warning — spare over",value:se,set:fe,help:"default 1h"},{label:"✗ Amber cross — short over",value:We,set:Bt,help:"default 1h"},{label:"✗ Red cross — short over",value:En,set:At,help:"default 2h"}].map(({label:I,value:te,set:ie,help:De})=>c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[c.jsx("span",{style:{flex:1,fontSize:"0.875rem",color:"var(--text-dark)"},children:I}),c.jsx("input",{type:"number",className:"hk-num-input",min:0,max:24,step:.5,value:te,onChange:mt=>ie(parseFloat(mt.target.value)||0),style:{width:"68px"}}),c.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-mid)",minWidth:"52px"},children:De})]},I))}),c.jsx("p",{style:{fontSize:"0.78rem",color:"var(--text-mid)",marginBottom:"1rem"},children:"Green ✓ is automatic — shown when the difference is within the amber spare and short thresholds above."}),c.jsx("div",{style:{marginBottom:"2.5rem"},children:c.jsx(mr,{onClick:Vn,disabled:$t,primary:!0,children:$t?"Saving…":"Save Thresholds"})})]})}function ol({title:i}){return c.jsx("h2",{style:{fontSize:"0.95rem",fontWeight:700,color:"var(--text-dark)",marginBottom:"0.25rem"},children:i})}function So(){return c.jsx("div",{style:{height:"1px",background:"var(--card-border)",margin:"0.5rem 0 2rem"}})}function Ut({type:i,children:u}){return c.jsx("div",{style:{marginBottom:"0.75rem",padding:"0.75rem",borderRadius:"8px",fontSize:"0.875rem",background:i==="ok"?"#dcfce7":"#fee2e2",color:i==="ok"?"var(--success)":"var(--danger)"},children:u})}function mr({children:i,onClick:u,disabled:a,primary:d}){return c.jsx("button",{onClick:u,disabled:a,style:{background:d?"var(--hk-green)":"var(--card-bg)",color:d?"#fff":"var(--text-dark)",border:`1px solid ${d?"var(--hk-green)":"var(--card-border)"}`,borderRadius:"6px",padding:"0.5rem 1.25rem",fontSize:"0.875rem",fontWeight:600},children:i})}function fm({user:i}){return c.jsx(Ih,{user:i,children:c.jsxs(Zp,{children:[c.jsx(il,{path:"/",element:c.jsx(xs,{to:"/planner",replace:!0})}),c.jsx(il,{path:"/planner",element:c.jsx(rm,{})}),c.jsx(il,{path:"/settings",element:bc(i,"settings")?c.jsx(dm,{}):c.jsx(xs,{to:"/planner",replace:!0})}),c.jsx(il,{path:"*",element:c.jsx(xs,{to:"/planner",replace:!0})})]})})}function pm(){const i=Lh("/hk-planner/health");return c.jsxs(c.Fragment,{children:[c.jsx(oh,{basename:"/hk-planner",children:c.jsx(mh,{children:u=>c.jsx(fm,{user:u})})}),c.jsx(Th,{visible:i})]})}new URLSearchParams(window.location.search).has("install")&&window.addEventListener("beforeinstallprompt",i=>{i.preventDefault(),i.prompt()},{once:!0});sp.createRoot(document.getElementById("root")).render(c.jsx(S.StrictMode,{children:c.jsx(pm,{})})); diff --git a/frontend/dist/index.html b/frontend/dist/index.html index a4636d3..9d10c49 100644 --- a/frontend/dist/index.html +++ b/frontend/dist/index.html @@ -5,7 +5,7 @@ HK Planner - + diff --git a/frontend/dist/sw.js b/frontend/dist/sw.js index 48d8a66..9ec617f 100644 --- a/frontend/dist/sw.js +++ b/frontend/dist/sw.js @@ -1 +1 @@ -if(!self.define){let e,i={};const n=(n,s)=>(n=new URL(n+".js",s).href,i[n]||new Promise(i=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=i,document.head.appendChild(e)}else e=n,importScripts(n),i()}).then(()=>{let e=i[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e}));self.define=(s,r)=>{const o=e||("document"in self?document.currentScript.src:"")||location.href;if(i[o])return;let t={};const d=e=>n(e,o),c={module:{uri:o},exports:t,require:d};i[o]=Promise.all(s.map(e=>c[e]||d(e))).then(e=>(r(...e),t))}}define(["./workbox-9c191d2f"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"a2c395d8c225f1b3ea12388f15189bce"},{url:"index.html",revision:"dac594c6fb03224d7ef693607551dd8a"},{url:"icons/icon-512.png",revision:"c32202b9deed67ef38331f63dec9d1c8"},{url:"icons/icon-192.png",revision:"46ece317d50d10b8f5e225e073b3221d"},{url:"assets/index-DOMhnWTP.js",revision:null},{url:"assets/index-B7_UXJgZ.css",revision:null},{url:"manifest.webmanifest",revision:"c2510de876adb84db0c4b300b71216fa"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("/hk-planner/index.html"),{denylist:[/\/api\//]}))}); +if(!self.define){let e,i={};const n=(n,s)=>(n=new URL(n+".js",s).href,i[n]||new Promise(i=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=i,document.head.appendChild(e)}else e=n,importScripts(n),i()}).then(()=>{let e=i[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e}));self.define=(s,r)=>{const o=e||("document"in self?document.currentScript.src:"")||location.href;if(i[o])return;let t={};const c=e=>n(e,o),l={module:{uri:o},exports:t,require:c};i[o]=Promise.all(s.map(e=>l[e]||c(e))).then(e=>(r(...e),t))}}define(["./workbox-9c191d2f"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"a2c395d8c225f1b3ea12388f15189bce"},{url:"index.html",revision:"46079111fca52b3927026fe671b56a2f"},{url:"icons/icon-512.png",revision:"c32202b9deed67ef38331f63dec9d1c8"},{url:"icons/icon-192.png",revision:"46ece317d50d10b8f5e225e073b3221d"},{url:"assets/index-BM62SqjA.js",revision:null},{url:"assets/index-B7_UXJgZ.css",revision:null},{url:"manifest.webmanifest",revision:"c2510de876adb84db0c4b300b71216fa"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("/hk-planner/index.html"),{denylist:[/\/api\//]}))}); diff --git a/frontend/src/api.ts b/frontend/src/api.ts index b2439df..6b1445a 100644 --- a/frontend/src/api.ts +++ b/frontend/src/api.ts @@ -1,4 +1,4 @@ -import type { BookingsData, StaffMember, GeneralTask, PickupData, TimeReqs, WorkforceRota, Adjustment } from './types' +import type { BookingsData, StaffMember, GeneralTask, PickupData, TimeReqs, WfDayData, Adjustment } from './types' const BASE = '/hk-planner/api' @@ -8,7 +8,6 @@ export interface ConfigData { pickup_data: PickupData general_tasks: GeneralTask[] last_reviewed: string - workforce_rota: WorkforceRota | null workforce_departments: string[] adjustments: Adjustment[] warn_over_red_hrs: number @@ -117,8 +116,12 @@ export function putWorkforceDepartments(dept_ids: string[]): Promise<{ ok: boole }) } -export function syncWorkforceRota(start: string, end: string): Promise { - return request(`/workforce/sync?start=${start}&end=${end}`, { method: 'POST' }) +export function syncWorkforce(): Promise<{ ok: boolean; from: string; to: string; dates_synced: number }> { + return request('/workforce/sync', { method: 'POST' }) +} + +export function getWorkforceShifts(start: string, end: string): Promise> { + return request(`/workforce/shifts?start=${start}&end=${end}`) } export function getWorkforceStaff(): Promise<{ id: string; name: string }[]> { diff --git a/frontend/src/pages/Planner.tsx b/frontend/src/pages/Planner.tsx index 51c280c..bbcb644 100644 --- a/frontend/src/pages/Planner.tsx +++ b/frontend/src/pages/Planner.tsx @@ -2,11 +2,11 @@ import { useState, useEffect, useRef, useCallback } from 'react' import { RefreshCw } from 'lucide-react' import { getBookings, getConfig, putStaff, putPickup, - putLastReviewed, putAdjustments, syncWorkforceRota, getWorkforceStaff, + putLastReviewed, putAdjustments, syncWorkforce, getWorkforceShifts, getWorkforceStaff, } from '../api' import type { BookingsData, TimeReqs, StaffMember, GeneralTask, - PickupData, RequiredDay, DayData, WorkforceRota, Adjustment, + PickupData, RequiredDay, DayData, WfDayData, WfStaffMember, Adjustment, } from '../types' // ── Date helpers ────────────────────────────────────────────────────────────── @@ -133,7 +133,7 @@ export function Planner() { const [warnOverAmber, setWarnOverAmber] = useState(1) const [warnUnderAmber, setWarnUnderAmber] = useState(1) const [warnUnderRed, setWarnUnderRed] = useState(2) - const [workforceRota, setWorkforceRota] = useState(null) + const [wfShifts, setWfShifts] = useState>({}) const [wfStaff, setWfStaff] = useState<{ id: string; name: string }[]>([]) const [syncing, setSyncing] = useState(false) const [weekStart, setWeekStart] = useState(null) @@ -171,10 +171,15 @@ export function Planner() { setLoading(true) setError('') const today = todayStr() - const ws = weekStartRef.current || today + const ws = weekStartRef.current || today + const wsEnd = offsetDate(ws, 6) const lv = lvArg !== undefined ? (lvArg || offsetDate(today, -1)) : (lastViewed || savedLastReviewed || offsetDate(today, -1)) try { - const [b, cfg] = await Promise.all([getBookings(ws, lv, force), getConfig()]) + const [b, cfg, shifts] = await Promise.all([ + getBookings(ws, lv, force), + getConfig(), + getWorkforceShifts(ws, wsEnd).catch(() => ({} as Record)), + ]) setBookings(b) setTimeReqs(cfg.time_requirements || {}) setStaff(cfg.staff_data || []) @@ -185,7 +190,7 @@ export function Planner() { setWarnOverAmber(cfg.warn_over_amber_hrs ?? 1) setWarnUnderAmber(cfg.warn_under_amber_hrs ?? 1) setWarnUnderRed(cfg.warn_under_red_hrs ?? 2) - setWorkforceRota(cfg.workforce_rota || null) + setWfShifts(shifts) if (cfg.last_reviewed) { setSavedLastReviewed(cfg.last_reviewed) if (!lastViewed) setLastViewed(cfg.last_reviewed) @@ -199,13 +204,13 @@ export function Planner() { useEffect(() => { loadAll(false) }, []) // eslint-disable-line react-hooks/exhaustive-deps - // Lazily load WF staff list for datalist once a rota snapshot exists + // Lazily load WF staff list for datalist once any shifts exist useEffect(() => { - if (workforceRota && !wfStaffLoaded.current) { + if (Object.keys(wfShifts).length > 0 && !wfStaffLoaded.current) { wfStaffLoaded.current = true getWorkforceStaff().then(setWfStaff).catch(() => {}) } - }, [workforceRota]) + }, [wfShifts]) // Beacon save on unload useEffect(() => { @@ -291,11 +296,13 @@ export function Planner() { // ── Workforce sync ─────────────────────────────────────────────────────────── async function syncRota() { - if (!bookings) return setSyncing(true) try { - const rota = await syncWorkforceRota(bookings.dates[0], bookings.dates[bookings.dates.length - 1]) - setWorkforceRota(rota) + await syncWorkforce() + if (bookings) { + const shifts = await getWorkforceShifts(bookings.dates[0], bookings.dates[bookings.dates.length - 1]) + setWfShifts(shifts) + } flash('Rota synced from Workforce') } catch (e) { flash(e instanceof Error ? e.message : 'Sync failed', true) @@ -305,14 +312,17 @@ export function Planner() { } function wfSyncLabel(): string { - if (!workforceRota) return 'Never synced' - const d = new Date(workforceRota.last_sync).toLocaleDateString('en-GB', { - weekday: 'short', day: 'numeric', month: 'short', - }) - const matchesWeek = bookings && - workforceRota.dates[0] === bookings.dates[0] && - workforceRota.dates[1] === bookings.dates[bookings.dates.length - 1] - return matchesWeek ? `Synced ${d}` : `Synced ${d} — different week` + if (!bookings) return '' + const viewDates = bookings.dates.filter(d => wfShifts[d]) + if (!viewDates.length) return 'Not synced' + const oldest = viewDates.reduce((min, d) => + new Date(wfShifts[d].synced_at) < new Date(wfShifts[min].synced_at) ? d : min + ) + const dt = new Date(wfShifts[oldest].synced_at) + const day = dt.toLocaleDateString('en-GB', { weekday: 'short', day: 'numeric', month: 'short' }) + const time = dt.toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit' }) + const missing = bookings.dates.filter(d => !wfShifts[d]).length + return missing ? `Partial sync — from ${day} ${time}` : `From ${day} ${time}` } // ── Required hours (memoised on state changes) ──────────────────────────── @@ -462,7 +472,7 @@ export function Planner() { warnUnderAmber={warnUnderAmber} warnUnderRed={warnUnderRed} onChange={handleStaffChange} - workforceRota={workforceRota} + wfShifts={wfShifts} wfStaff={wfStaff} /> @@ -786,7 +796,20 @@ function RequiredTable({ bookings, required }: { bookings: BookingsData; require // ── Staff Table ─────────────────────────────────────────────────────────────── -function StaffTable({ bookings, staff, required, warnOverRed, warnOverAmber, warnUnderAmber, warnUnderRed, onChange, workforceRota, wfStaff }: { +function pivotWfShifts(wfShifts: Record, dates: string[]): WfStaffMember[] { + const members: Record = {} + for (const date of dates) { + const day = wfShifts[date] + if (!day) continue + for (const s of day.staff) { + if (!members[s.id]) members[s.id] = { id: s.id, name: s.name, days: {} } + members[s.id].days[date] = { hours: s.hours, times: s.times } + } + } + return Object.values(members).sort((a, b) => a.name.localeCompare(b.name)) +} + +function StaffTable({ bookings, staff, required, warnOverRed, warnOverAmber, warnUnderAmber, warnUnderRed, onChange, wfShifts, wfStaff }: { bookings: BookingsData staff: StaffMember[] required: Record @@ -795,7 +818,7 @@ function StaffTable({ bookings, staff, required, warnOverRed, warnOverAmber, war warnUnderAmber: number warnUnderRed: number onChange: (next: StaffMember[]) => void - workforceRota: WorkforceRota | null + wfShifts: Record wfStaff: { id: string; name: string }[] }) { const { dates } = bookings @@ -821,7 +844,7 @@ function StaffTable({ bookings, staff, required, warnOverRed, warnOverAmber, war onChange(staff.filter((_, idx) => idx !== i)) } - const rotaMembers = workforceRota?.staff ?? [] + const rotaMembers = pivotWfShifts(wfShifts, dates) return ( diff --git a/frontend/src/types.ts b/frontend/src/types.ts index 57b1b68..005072b 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -54,21 +54,21 @@ export interface Adjustment { hours: Record // YYYY-MM-DD → positive or negative hours } -export interface WorkforceShiftDay { +export interface WfShiftDay { hours: number times: string } -export interface WorkforceRotaMember { +export interface WfStaffMember { id: string name: string - days: Record + days: Record } -export interface WorkforceRota { - last_sync: string - dates: [string, string] - staff: WorkforceRotaMember[] +export interface WfDayData { + synced_at: string + source: string + staff: { id: string; name: string; hours: number; times: string }[] } export interface RequiredDay {