@weatherboard/cms 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -42,10 +42,14 @@ when names match. The host keeps its repository data and chooses how to display
42
42
  the source. `menuQuery`, `parseMenuDocument` and `menuTags` remain the menu API.
43
43
 
44
44
  `openVacanciesQuery`, `parseVacancies` and `parseVacancyDocument` require the
45
- consumer's validator. The consumer can enforce its work-location choices and
46
- the note required for an `Other` choice. The package supplies no site-specific
47
- default. A-2463 will replace those choices with references to the client's
48
- `location` documents.
45
+ consumer's validator, which receives each raw projected entry before display
46
+ fields are derived. The query resolves `workLocation` to `{ _id, name }` and
47
+ depends on both vacancy and location tags. The display label uses the resolved
48
+ name, then a non-`Other` legacy `location`, then `locationNote`; a dangling
49
+ reference falls through to the legacy fields. `locationId` is the resolved
50
+ location's ID or `null`. An entry with no display label is structurally dropped.
51
+ Legacy documents remain readable. Consumers whose validators require the legacy
52
+ string must update them before migrating documents to references.
49
53
 
50
54
  ## Site hero
51
55
 
package/dist/next.cjs CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";var L=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var we=Object.prototype.hasOwnProperty;var _e=(e,n)=>{for(var t in n)L(e,t,{get:n[t],enumerable:!0})},Ce=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of $e(n))!we.call(e,r)&&r!==t&&L(e,r,{get:()=>n[r],enumerable:!(o=Se(n,r))||o.enumerable});return e};var Te=e=>Ce(L({},"__esModule",{value:!0}),e);var Ke={};_e(Ke,{MENU_DECORATIONS:()=>M,MENU_LAYOUTS:()=>D,MENU_LAYOUT_DEFAULTS:()=>v,businessLocationsQuery:()=>ge,createNextCmsReader:()=>te,createRevalidateRoute:()=>le,locationTags:()=>pe,locationsQuery:()=>me,menuQuery:()=>X,menuTags:()=>V,openVacanciesQuery:()=>de,parseBusinessLocation:()=>B,parseLocationDocument:()=>H,parseMenuDocument:()=>I,parseScheduleDocument:()=>z,parseVacancies:()=>F,parseVacancyDocument:()=>U,resolveWithFallback:()=>ue,scheduleQuery:()=>be,scheduleTags:()=>he,vacancyTags:()=>ce});module.exports=Te(Ke);var An=require("server-only");function Q(e){if(!Array.isArray(e))return!1;for(let n=0;n<e.length;n+=1)if(!Object.hasOwn(e,n))return!1;return!0}var D=["stacked","columns"],M=["none","playful"],v={layout:"stacked",decoration:"none"},j=`_type, _id, _rev, _updatedAt, title, locationKeys, note, signOff,
1
+ "use strict";var P=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var we=Object.prototype.hasOwnProperty;var _e=(e,n)=>{for(var t in n)P(e,t,{get:n[t],enumerable:!0})},Ce=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of $e(n))!we.call(e,r)&&r!==t&&P(e,r,{get:()=>n[r],enumerable:!(o=Se(n,r))||o.enumerable});return e};var Te=e=>Ce(P({},"__esModule",{value:!0}),e);var Ke={};_e(Ke,{MENU_DECORATIONS:()=>M,MENU_LAYOUTS:()=>D,MENU_LAYOUT_DEFAULTS:()=>v,businessLocationsQuery:()=>ge,createNextCmsReader:()=>te,createRevalidateRoute:()=>le,locationTags:()=>pe,locationsQuery:()=>me,menuQuery:()=>X,menuTags:()=>V,openVacanciesQuery:()=>de,parseBusinessLocation:()=>B,parseLocationDocument:()=>H,parseMenuDocument:()=>I,parseScheduleDocument:()=>z,parseVacancies:()=>F,parseVacancyDocument:()=>U,resolveWithFallback:()=>ue,scheduleQuery:()=>be,scheduleTags:()=>he,vacancyTags:()=>ce});module.exports=Te(Ke);var An=require("server-only");function Q(e){if(!Array.isArray(e))return!1;for(let n=0;n<e.length;n+=1)if(!Object.hasOwn(e,n))return!1;return!0}var D=["stacked","columns"],M=["none","playful"],v={layout:"stacked",decoration:"none"},L=`_type, _id, _rev, _updatedAt, title, locationKeys, note, signOff,
2
2
  variants[]{_key, label, note, sections[]{_key, title, service, items[]{
3
3
  _key, name, description, priceNote, dietary, allergenNote, availability,
4
4
  prices[]{_key, label, amount{minor, currency}}, extras[]{_key, name, amount{minor, currency}}
5
- }}}`;function V(e,n){return S(e,{types:["menu"],...n===void 0?{}:{ids:[n]}})}function f(e,n){throw new R("menu",[`${e} ${n}`])}function Z(e,n,t=new Set,o){if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))return e;if(typeof e!="object"||e===null)return f(n,"is not plain JSON data");try{if(t.has(e))return f(n,"is not acyclic JSON data");let r=Array.isArray(e),s=Object.getPrototypeOf(e);if(r?s!==Array.prototype:s!==Object.prototype&&s!==null)return f(n,"is not an ordinary saved object");t.add(e);let u=Reflect.ownKeys(e),y=r?[]:{},a=0,p=0;for(let i of u){if(typeof i!="string")return f(n,"has a symbol key");let c=r&&i!=="length"?`${n}[${i}]`:`${n}.${i}`,d;try{d=i==="_id"&&o!==void 0?o:Object.getOwnPropertyDescriptor(e,i)}catch{return f(c,"could not be snapshotted as plain JSON data")}if(!d||!Object.hasOwn(d,"value"))return f(c,"is not a saved data property");if(r&&i==="length"){let k=d.value;if(typeof k!="number"||!Number.isSafeInteger(k)||k<0)return f(c,"is not a saved list length");a=k;continue}if(!d.enumerable||r&&!/^(0|[1-9]\d*)$/.test(i))return f(c,"is not a JSON data property");let l=d.value,m=Z(l,c,t);Object.defineProperty(y,i,{value:m,enumerable:!0,writable:!0,configurable:!0}),p++}return r&&(p!==a||y.length!==a)?f(n,"is not a complete saved list"):y}catch(r){if(r instanceof R)throw r;return f(n,"could not be snapshotted as plain JSON data")}finally{t.delete(e)}}function A(e,n){return e===null||typeof e!="object"||Array.isArray(e)||Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null?f(n,"is not an ordinary saved object"):e}function g(e,n,t=!0){return typeof e!="string"||t&&e.trim()===""?f(n,"is not saved text"):e}function C(e,n,t){return e[n]===void 0||e[n]===null?{}:{[n]:g(e[n],`${t}.${n}`,!1)}}function T(e,n,t){return e==null?[]:Q(e)?e.map((o,r)=>t(o,`${n}[${String(r)}]`)):f(n,"is not a complete saved list")}function J(e,n){let t=A(e,n);if(typeof t.minor!="number"||!Number.isSafeInteger(t.minor)||t.minor<0)return f(`${n}.minor`,"is not a whole non-negative safe amount");let o=g(t.currency,`${n}.currency`);return/^[A-Z]{3}$/.test(o)?{minor:t.minor,currency:o}:f(`${n}.currency`,"is not a three-letter currency code")}function Ae(e,n){let t=A(e,n);return{_key:g(t._key,`${n}._key`),amount:J(t.amount,`${n}.amount`),...C(t,"label",n)}}function Re(e,n){let t=A(e,n);return{_key:g(t._key,`${n}._key`),name:g(t.name,`${n}.name`),amount:J(t.amount,`${n}.amount`)}}function Ee(e,n){let t=A(e,n),o=t.availability??"available";return o!=="available"&&o!=="sold-out"&&o!=="hidden"?f(`${n}.availability`,"is not an availability choice"):{_key:g(t._key,`${n}._key`),name:g(t.name,`${n}.name`),...C(t,"description",n),...C(t,"priceNote",n),...C(t,"allergenNote",n),prices:T(t.prices,`${n}.prices`,Ae),extras:T(t.extras,`${n}.extras`,Re),dietary:T(t.dietary,`${n}.dietary`,g),availability:o}}function xe(e,n){let t=A(e,n);return{_key:g(t._key,`${n}._key`),title:g(t.title,`${n}.title`),...C(t,"service",n),items:T(t.items,`${n}.items`,Ee)}}function Ie(e,n){let t=A(e,n);return{_key:g(t._key,`${n}._key`),label:g(t.label,`${n}.label`),...C(t,"note",n),sections:T(t.sections,`${n}.sections`,xe)}}function Oe(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let n=e._id;return typeof n=="string"&&n.trim()!==""&&!/^(drafts|versions)\./.test(n)}function I(e,n="menu"){return De(Z(e,n),n)}function De(e,n){let t=A(e,n);if(t._type!=="menu")return f(`${n}._type`,"is not menu");if(!Oe(t))return f(`${n}._id`,"is not a published menu identity");let o=g(t._updatedAt,`${n}._updatedAt`);if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(o)||!Number.isFinite(Date.parse(o)))return f(`${n}._updatedAt`,"is not an update date");let r=T(t.variants,`${n}.variants`,Ie);return r.length===0?f(`${n}.variants`,"has no menu choices"):{_type:"menu",_id:g(t._id,`${n}._id`),_rev:g(t._rev,`${n}._rev`),_updatedAt:o,title:g(t.title,`${n}.title`),locationKeys:T(t.locationKeys,`${n}.locationKeys`,g),variants:r,...C(t,"note",n),...Object.hasOwn(t,"signOff")?{signOff:t.signOff}:{}}}function W(e){if(e===null)return!0;try{return I(e),!0}catch{return!1}}var Y="malformed-content",R=class extends Error{code=Y;documentId;problems;constructor(n,t){super(`${Y}: ${n}: ${t.join("; ")}`),this.name="MalformedContentError",this.documentId=n,this.problems=t}};var G=`{..., "sections": coalesce(sections[]{..., _type == "menuBlock" => {menu->{${j}}}, _type == "linkListBlock" => {links[]{..., "page": page->{title, "slug": slug.current}}}}, sections)}`,un=`*[_type == "page" && defined(slug.current)]|order(slug.current asc)${G}`,cn=`*[_type == "page" && slug.current == $slug][0]${G}`;var Me=/^[A-Za-z][A-Za-z0-9_]{0,63}$/,ve=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,je=/^[a-z0-9]{6,12}\.[a-z][a-z0-9_-]{0,63}$/;function K(e){if(!e||!Array.isArray(e.types)||e.types.length===0)throw new TypeError("CMS dependencies require document types");let n=[...e.types];for(let o of n)if(typeof o!="string"||!Me.test(o))throw new TypeError("Invalid CMS document type");if(e.ids!==void 0&&!Array.isArray(e.ids))throw new TypeError("Invalid CMS document IDs");let t=e.ids===void 0?void 0:[...e.ids];for(let o of t??[])if(typeof o!="string"||!ve.test(o)||/^(drafts|versions)\./.test(o))throw new TypeError("Invalid CMS document ID");if(new Set(n).size+new Set(t).size>128)throw new TypeError("Too many CMS tags");return Object.freeze({types:Object.freeze(n),...t===void 0?{}:{ids:Object.freeze(t)}})}function E(e){if(!e||typeof e.name!="string"||!/^[A-Za-z][A-Za-z0-9_.-]{0,127}$/.test(e.name)||typeof e.query!="string"||e.query.trim()===""||typeof e.resolve!="function")throw new TypeError("Invalid CMS query configuration");let n=e.params;if(!n||typeof n!="object"||Object.getPrototypeOf(n)!==Object.prototype&&Object.getPrototypeOf(n)!==null)throw new TypeError("CMS params must be plain JSON scalars");let t={};for(let o of Reflect.ownKeys(n)){let r=Object.getOwnPropertyDescriptor(n,o);if(typeof o!="string"||!r||!Object.hasOwn(r,"value")||!r.enumerable)throw new TypeError("CMS params must be plain JSON scalars");let s=r.value;if(!(s===null||typeof s=="string"||typeof s=="boolean"||typeof s=="number"&&Number.isFinite(s)))throw new TypeError("CMS params must be plain JSON scalars");Object.defineProperty(t,o,{value:s,enumerable:!0})}return Object.freeze({name:e.name,query:e.query,params:Object.freeze(t),dependencies:K(e.dependencies),resolve:e.resolve})}function S(e,n){if(typeof e!="string"||e.length>77||!je.test(e))throw new TypeError("Invalid CMS scope");let t=K(n),o=[...[...new Set(t.types)].sort().map(r=>`cms:${e}:type:${r}`),...[...new Set(t.ids??[])].sort().map(r=>`cms:${e}:id:${r}`)];return Object.freeze(o)}function X(e){return E({name:"menu.v1",query:`*[_type == "menu" && _id == $id && !(_id in path("drafts.**")) && !(_id in path("versions.**"))][0]{${j}}`,params:{id:e},dependencies:{types:["menu"],ids:[e]},resolve:(n,t)=>{if(!W(t)||t!==null&&t._id!==e)throw new TypeError("Invalid CMS menu fallback");if(n==null)return{data:t,fallbackFields:["$"]};let o=I(n);if(o._id!==e)throw new R("menu",["menu._id does not match the requested document"]);return{data:o,fallbackFields:[]}}})}function ee(e){if(!e||!Object.hasOwn(e,"data")||!Array.isArray(e.fallbackFields)||![...e.fallbackFields].every(n=>typeof n=="string"&&(n==="$"||/^[A-Za-z][A-Za-z0-9_.[\]-]{0,127}$/.test(n))))throw new TypeError("Invalid CMS resolution");if(e.warnings!==void 0&&(!Array.isArray(e.warnings)||![...e.warnings].every(n=>n==="siteHero.layout.defaulted"||n==="siteHero.tagline.dropped"||n==="siteHero.taglines.defaulted")))throw new TypeError("Invalid CMS resolution warnings");return{data:e.data,fallbackFields:Object.freeze([...new Set(e.fallbackFields)]),...e.warnings?.length?{warnings:Object.freeze([...new Set(e.warnings)])}:{}}}function ne(e){let n=e?.revalidateSeconds??3600;if(!Number.isSafeInteger(n)||n<3600||!e?.adapter||typeof e.adapter.read!="function"||e.onDiagnostic!==void 0&&typeof e.onDiagnostic!="function")throw new TypeError("Invalid CMS reader configuration");let t=e.adapter;S(t.scope,{types:["ScopeValidation"]});let o=r=>{try{e.onDiagnostic?e.onDiagnostic(r):console.warn(JSON.stringify(r))}catch{}};return{async read(r,s){let u,y,a;try{if(u=E(r),a=S(t.scope,u.dependencies),!s||!Object.hasOwn(s,"fallback"))throw new TypeError;y=ee(u.resolve(null,s.fallback))}catch{throw new TypeError("Invalid CMS query or fallback configuration")}let p=(d,l,m)=>(o({event:"cms.fallback",query:u.name,reason:d,fields:["$"],...l===void 0?{}:{status:l},...m?{warnings:m}:{}}),{data:y.data,source:"fallback",fallbackFields:["$"],reason:d,...m?{warnings:m}:{}}),i;try{i=await t.read({name:u.name,query:u.query,params:u.params},{tags:a,revalidateSeconds:n})}catch{return p("network")}if(!i.ok){let l=["configuration","network","timeout","rate-limit","upstream","plan-limit","permission","malformed"].includes(i.reason)?i.reason:"malformed",m=Number.isInteger(i.status)&&(i.status??0)>=100&&(i.status??0)<=599?i.status:void 0;return p(l,m)}if(i.value===null||i.value===void 0)return p("missing");let c;try{c=ee(u.resolve(i.value,s.fallback))}catch{return p("malformed")}return c.fallbackFields.includes("$")?{...p("invalid-field",void 0,c.warnings),data:c.data}:c.fallbackFields.length>0?(o({event:"cms.partial-fallback",query:u.name,reason:"invalid-field",fields:c.fallbackFields,...c.warnings?{warnings:c.warnings}:{}}),{...c,source:"mixed",reason:"invalid-field"}):{...c,source:"cms"}}}}var te=ne;var ie=require("next/cache.js");var N="sanity-webhook-signature",Pe=/^t=(\d+)[, ]+v1=([^, ]+)$/;var oe=new TextEncoder;function Le(e){return crypto.subtle.importKey("raw",oe.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"])}function Ne(e){if(!/^[A-Za-z0-9_-]+={0,2}$/.test(e))return null;let n=e.replace(/-/g,"+").replace(/_/g,"/");try{let t=atob(n),o=new Uint8Array(t.length);for(let r=0;r<t.length;r+=1)o[r]=t.charCodeAt(r);return o}catch{return null}}async function re(e){let{secret:n,rawBody:t,headers:o}=e,r=e.now??Date.now(),s=e.toleranceMs??3e5;if(!n||n.length===0)return{ok:!1,reason:"no-secret"};let u=o.get(N);if(!u)return{ok:!1,reason:"no-signature"};let y=Pe.exec(u.trim());if(y===null)return{ok:!1,reason:"malformed-signature"};let a=Number(y[1]),p=y[2]??"";if(!Number.isSafeInteger(a))return{ok:!1,reason:"malformed-signature"};if(a<16094592e5)return{ok:!1,reason:"stale-timestamp"};if(Math.abs(r-a)>s)return{ok:!1,reason:"stale-timestamp"};let i=Ne(p);if(i===null)return{ok:!1,reason:"malformed-signature"};let c=await Le(n);return await crypto.subtle.verify("HMAC",c,i,oe.encode(`${a}.${t}`))?{ok:!0}:{ok:!1,reason:"bad-signature"}}var Ue=16*1024,Fe=1500,qe=new TextEncoder;function b(e,n,t={},o=!1){return new Response(o?null:JSON.stringify(n),{status:e,headers:{"Content-Type":"application/json","Cache-Control":"no-store",...t}})}function He(e,n){if(!n||typeof n!="object"||Array.isArray(n)||Object.keys(n).length===0)throw new TypeError("Invalid CMS invalidation mapping");let t=Object.create(null);for(let o of Reflect.ownKeys(n)){let r=Object.getOwnPropertyDescriptor(n,o);if(typeof o!="string"||!r?.enumerable||!Object.hasOwn(r,"value"))throw new TypeError("Invalid CMS invalidation mapping");let s=r.value;if(!Array.isArray(s)||!s.includes(o))throw new TypeError("Invalid CMS invalidation mapping");S(e,{types:s,ids:["validation"]}),t[o]=Object.freeze([...s])}for(let o of Object.values(t))if(o.some(r=>!Object.hasOwn(t,r)))throw new TypeError("Invalid CMS invalidation mapping");return Object.freeze(t)}function se(e){return typeof e=="string"&&e.trim()!==""&&qe.encode(e).byteLength>=32}var O=class extends Error{constructor(t){super("Invalid CMS webhook body");this.status=t}status};async function Be(e){let n=e.body?.getReader();if(!n)return"";let t=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}),o,r=new Promise((s,u)=>{o=setTimeout(()=>u(new O(400)),Fe)});try{let s=0,u="";for(;;){let{done:y,value:a}=await Promise.race([n.read(),r]);if(y)return u+t.decode();if(s+=a.byteLength,s>Ue)throw new O(413);u+=t.decode(a,{stream:!0})}}catch(s){throw n.cancel().catch(()=>{}),s}finally{clearTimeout(o),n.releaseLock()}}function le(e){let n=e.scope,t=He(n,e.typeToTags),o=e.secretEnv??"SANITY_REVALIDATE_SECRET",r=e.previousSecretEnv??"SANITY_REVALIDATE_SECRET_PREVIOUS",s=e.env??(()=>process.env),u=e.now??Date.now,y=async a=>{if(a.method!=="POST")return b(405,{error:"Method not allowed"},{Allow:"POST"},a.method==="HEAD");let p,i;try{let $=s(),P=$[o],_=$[r];if(!se(P)||_!==void 0&&!se(_))throw new Error;p=P,i=_}catch{return b(503,{error:"COULD NOT ANSWER: revalidation configuration unavailable"})}let c=a.headers.get(N);if(!c||c.length>512||!/^t=\d+[, ]+v1=[A-Za-z0-9_-]+={0,2}$/.test(c.trim()))return b(401,{error:"Unauthorized"});let d;try{d=await Be(a)}catch($){return $ instanceof O&&$.status===413?b(413,{error:"Payload too large"}):b(400,{error:"Invalid body"})}try{let $=u();if(!Number.isFinite($))throw new Error;if(!(await Promise.all([p,...i===void 0?[]:[i]].map(_=>re({secret:_,rawBody:d,headers:a.headers,now:$})))).some(_=>_.ok))return b(401,{error:"Unauthorized"})}catch{return b(401,{error:"Unauthorized"})}let l;try{l=JSON.parse(d)}catch{return b(400,{error:"Invalid payload"})}if(!l||typeof l!="object"||Array.isArray(l)||Object.keys(l).length!==2||!Object.hasOwn(l,"_type")||!Object.hasOwn(l,"_id"))return b(400,{error:"Invalid payload"});let{_type:m,_id:k}=l;if(typeof m!="string"||!/^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(m)||typeof k!="string"||!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(k))return b(400,{error:"Invalid payload"});if(!Object.hasOwn(t,m)||/^(drafts|versions)\./.test(k))return b(400,{error:"Unsupported document"});let ke=S(n,{types:t[m],ids:[k]});try{for(let $ of ke)(0,ie.revalidateTag)($,{expire:0})}catch{return b(500,{error:"Could not revalidate"})}return b(200,{revalidated:!0})};return Object.freeze({POST:y,GET:y,HEAD:y,PUT:y,PATCH:y,DELETE:y,OPTIONS:y})}var w=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),h=e=>typeof e=="string"&&e.trim()?e.trim():null,ze=(e,n)=>e._type===n&&typeof e._id=="string"&&e._id.length>0&&!/^(drafts|versions)\./.test(e._id),Qe=/^\d{4}-\d{2}-\d{2}$/,ae=/^([01]\d|2[0-3]):[0-5]\d$/,Ve=["mon","tue","wed","thu","fri","sat","sun"];async function ue(e,n,t){try{let o=await e.read(n,{fallback:t});return{...o,source:o.source==="cms"?"sanity":o.source}}catch{return{data:t,source:"fallback",fallbackFields:["$"],reason:"configuration"}}}var Ze=/^[A-Za-z0-9._+-]{1,64}@[A-Za-z0-9-]{1,63}(?:\.[A-Za-z0-9-]{1,63})*\.[A-Za-z]{2,63}$/;function Je(e){let n=h(e);if(!n)return null;try{let t=new URL(n);return t.protocol==="http:"||t.protocol==="https:"?t.href:null}catch{return null}}function x(e){if(typeof e!="function")throw new TypeError("A client validator is required")}function U(e,n,t){if(x(t),!w(e)||e.status!=="open")return null;let o=h(e.closingDate);if(o!==null&&o<n||t(e)!==null)return null;let r=h(e.title),s=e.location==="Other"?h(e.locationNote):h(e.location);if(!r||!s)return null;let u=h(e.pdfUrl);return{id:String(h(e._id)),title:r,location:s,summary:h(e.summary),pdfUrl:u?.startsWith("https://cdn.sanity.io/files/")?u:null,applyUrl:Je(e.applyUrl),applyEmail:typeof e.applyEmail=="string"&&e.applyEmail.length<=254&&Ze.test(e.applyEmail)?e.applyEmail:null}}function F(e,n,t){if(x(t),!Array.isArray(e))throw new TypeError("Sanity returned vacancies that are not a list");return e.map(o=>({value:U(o,n,t),order:w(o)&&typeof o.order=="number"&&Number.isFinite(o.order)?o.order:1e6})).filter(o=>o.value!==null).sort((o,r)=>o.order-r.order||o.value.title.toLowerCase().localeCompare(r.value.title.toLowerCase())).map(o=>o.value)}function ce(e){return S(e,{types:["vacancy"]})}function de(e,n){if(!Qe.test(e))throw new TypeError("Invalid calendar date");return x(n),E({name:"vacancy.open.v1",query:'*[_type == "vacancy" && status == "open" && !(_id in path("drafts.**")) && !(_id in path("versions.**")) && (!defined(closingDate) || closingDate >= $today)]|order(coalesce(order, 1000000) asc, lower(title) asc){_id, _type, title, location, locationNote, summary, "pdfUrl": jobDescriptionPdf.asset->url, applyUrl, applyEmail, status, closingDate, order}',params:{today:e},dependencies:{types:["vacancy"]},resolve:(t,o)=>({data:t==null?o:F(t,e,n),fallbackFields:t==null?["$"]:[]})})}var We=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Ye=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function q(e){return!w(e)||typeof e._id!="string"||!w(e.slug)||typeof e.slug.current!="string"||!Ye.test(e.slug.current)||h(e.name)===null||e.addressLines!==void 0&&e.addressLines!==null&&(!Array.isArray(e.addressLines)||Array.from(e.addressLines).some(n=>h(n)===null))||e.postcode!==void 0&&e.postcode!==null&&h(e.postcode)===null||e.coordinates!==void 0&&e.coordinates!==null&&(!w(e.coordinates)||typeof e.coordinates.lat!="number"||!Number.isFinite(e.coordinates.lat)||typeof e.coordinates.lng!="number"||!Number.isFinite(e.coordinates.lng))||e.phone!==void 0&&e.phone!==null&&typeof e.phone!="string"||e.email!==void 0&&e.email!==null&&typeof e.email!="string"?null:{name:h(e.name),slug:e.slug.current,addressLines:e.addressLines==null?e.addressLines:e.addressLines.map(n=>n.trim()),postcode:e.postcode==null?e.postcode:String(e.postcode).trim(),coordinates:e.coordinates==null?e.coordinates:{lat:e.coordinates.lat,lng:e.coordinates.lng},phone:e.phone,email:e.email,hours:e.hours}}function ye(e){if(!w(e))return null;let n={};for(let t of We){let o=e[t];if(!Array.isArray(o)||!Array.from(o).every(r=>w(r)&&typeof r.opens=="string"&&typeof r.closes=="string"))return null;n[t]=o.map(r=>({opens:r.opens,closes:r.closes}))}return n}function H(e,n,t){x(t);let o=q(e);if(o===null||o.slug!==n.id)return{data:n,fallbackFields:["$"]};let r=ye(o.hours),s={id:n.id,label:o.name,addressLines:o.addressLines??n.addressLines,postcode:o.postcode??n.postcode,geo:o.coordinates==null?n.geo:{latitude:o.coordinates.lat,longitude:o.coordinates.lng},telephone:o.phone===void 0?n.telephone:o.phone,email:o.email===void 0?n.email:o.email,hours:r??n.hours};try{return{data:t(s),fallbackFields:r===null?["hours"]:[]}}catch{if(r!==null)try{return{data:t({...s,hours:n.hours}),fallbackFields:["hours"]}}catch{}return{data:n,fallbackFields:["$"]}}}function B(e,n,t){x(t);let o=q(e);if(o===null||o.slug!==n.id)return{data:n,fallbackFields:["$"]};let r=ye(o.hours),s={...n,label:o.name,address:n.address===null?null:{...n.address,streetAddress:o.addressLines??n.address.streetAddress,postalCode:o.postcode??n.address.postalCode},telephone:o.phone===void 0?n.telephone:o.phone,email:o.email===void 0?n.email:o.email,geo:o.coordinates==null?n.geo:{latitude:o.coordinates.lat,longitude:o.coordinates.lng},hours:r??n.hours};try{return{data:t(s),fallbackFields:r===null?["hours"]:[]}}catch{if(r!==null)try{return{data:t({...s,hours:n.hours}),fallbackFields:["hours"]}}catch{}return{data:n,fallbackFields:["$"]}}}function pe(e){return S(e,{types:["location"]})}function fe(e,n){return E({name:e,query:'*[_type == "location" && defined(slug.current) && !(_id in path("drafts.**")) && !(_id in path("versions.**"))]{_id, _type, name, slug, addressLines, postcode, coordinates, phone, email, hours}',params:{},dependencies:{types:["location"]},resolve:(t,o)=>{if(!Array.isArray(t))return{data:o,fallbackFields:["$"]};let r=new Map,s=new Set;for(let a of t){let p=q(a);p!==null&&(r.has(p.slug)?s.add(p.slug):r.set(p.slug,a))}let u=[];return{data:o.map((a,p)=>{let i=r.get(a.id),c=i===void 0||s.has(a.id)?{data:a,fallbackFields:["$"]}:n(i,a);return u.push(...c.fallbackFields.map(d=>d==="$"?`locations[${p}]`:`locations[${p}].${d}`)),c.data}),fallbackFields:o.length>0&&u.length===o.length&&u.every(a=>/^locations\[\d+\]$/.test(a))?["$"]:u}}})}function me(e){return x(e),fe("locations.v1",(n,t)=>H(n,t,e))}function ge(e){return x(e),fe("locations.business.v1",(n,t)=>B(n,t,e))}function Ge(e,n,t){let o=`${e}-${n.normalize("NFKD").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"stop"}`,r=o;for(let s=2;t.has(r);s++)r=`${o}-${s}`;return t.add(r),r}function z(e,n){if(!w(e)||!ze(e,"schedule")||e._id!=="schedule"||e.timeZone!==n.timeZone||!Array.isArray(e.days)||e.days.length!==7)throw new TypeError("Invalid schedule document");let t=e.days.map((o,r)=>{if(!w(o)||o.day!==Ve[r]||typeof o.rest!="boolean"||!Array.isArray(o.stops))throw new TypeError("Invalid schedule day");let s=o.day,u=o.rest,y=o.stops,a=n.days.find(d=>d.day===s),p=new Set(a?.stops.map(d=>d.id)??[]),i=new Set,c=y.map(d=>{if(!w(d))throw new TypeError("Invalid schedule stop");let l=d;if(!h(l.name)||!ae.test(String(l.from??""))||!ae.test(String(l.to??""))||!h(l.address))throw new TypeError("Invalid schedule stop");let m=a?.stops.find(k=>k.name===l.name&&!i.has(k.id));return m?(i.add(m.id),{...m,name:String(l.name),from:String(l.from),to:String(l.to),address:String(l.address)}):{id:Ge(s,String(l.name),p),name:String(l.name),from:String(l.from),to:String(l.to),address:String(l.address),place:null,postcode:null,notes:null,lat:null,lng:null,coordinateSource:null,approximate:!1,needsConfirmation:null,captured:`${l.name}
6
- ${l.from}-${l.to}
7
- ${l.address}`}});return{day:s,rest:u,stops:u?[]:c}});return{timeZone:n.timeZone,days:t}}function he(e){return S(e,{types:["schedule"],ids:["schedule"]})}function be(){return E({name:"schedule.v1",query:'*[_type == "schedule" && _id == "schedule" && !(_id in path("drafts.**")) && !(_id in path("versions.**"))][0]{_id, _type, timeZone, days}',params:{},dependencies:{types:["schedule"],ids:["schedule"]},resolve:(e,n)=>({data:e==null?n:z(e,n),fallbackFields:e==null?["$"]:[]})})}0&&(module.exports={MENU_DECORATIONS,MENU_LAYOUTS,MENU_LAYOUT_DEFAULTS,businessLocationsQuery,createNextCmsReader,createRevalidateRoute,locationTags,locationsQuery,menuQuery,menuTags,openVacanciesQuery,parseBusinessLocation,parseLocationDocument,parseMenuDocument,parseScheduleDocument,parseVacancies,parseVacancyDocument,resolveWithFallback,scheduleQuery,scheduleTags,vacancyTags});
5
+ }}}`;function V(e,n){return S(e,{types:["menu"],...n===void 0?{}:{ids:[n]}})}function f(e,n){throw new R("menu",[`${e} ${n}`])}function Z(e,n,t=new Set,o){if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))return e;if(typeof e!="object"||e===null)return f(n,"is not plain JSON data");try{if(t.has(e))return f(n,"is not acyclic JSON data");let r=Array.isArray(e),s=Object.getPrototypeOf(e);if(r?s!==Array.prototype:s!==Object.prototype&&s!==null)return f(n,"is not an ordinary saved object");t.add(e);let u=Reflect.ownKeys(e),d=r?[]:{},i=0,p=0;for(let l of u){if(typeof l!="string")return f(n,"has a symbol key");let c=r&&l!=="length"?`${n}[${l}]`:`${n}.${l}`,y;try{y=l==="_id"&&o!==void 0?o:Object.getOwnPropertyDescriptor(e,l)}catch{return f(c,"could not be snapshotted as plain JSON data")}if(!y||!Object.hasOwn(y,"value"))return f(c,"is not a saved data property");if(r&&l==="length"){let k=y.value;if(typeof k!="number"||!Number.isSafeInteger(k)||k<0)return f(c,"is not a saved list length");i=k;continue}if(!y.enumerable||r&&!/^(0|[1-9]\d*)$/.test(l))return f(c,"is not a JSON data property");let a=y.value,m=Z(a,c,t);Object.defineProperty(d,l,{value:m,enumerable:!0,writable:!0,configurable:!0}),p++}return r&&(p!==i||d.length!==i)?f(n,"is not a complete saved list"):d}catch(r){if(r instanceof R)throw r;return f(n,"could not be snapshotted as plain JSON data")}finally{t.delete(e)}}function A(e,n){return e===null||typeof e!="object"||Array.isArray(e)||Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null?f(n,"is not an ordinary saved object"):e}function g(e,n,t=!0){return typeof e!="string"||t&&e.trim()===""?f(n,"is not saved text"):e}function C(e,n,t){return e[n]===void 0||e[n]===null?{}:{[n]:g(e[n],`${t}.${n}`,!1)}}function T(e,n,t){return e==null?[]:Q(e)?e.map((o,r)=>t(o,`${n}[${String(r)}]`)):f(n,"is not a complete saved list")}function J(e,n){let t=A(e,n);if(typeof t.minor!="number"||!Number.isSafeInteger(t.minor)||t.minor<0)return f(`${n}.minor`,"is not a whole non-negative safe amount");let o=g(t.currency,`${n}.currency`);return/^[A-Z]{3}$/.test(o)?{minor:t.minor,currency:o}:f(`${n}.currency`,"is not a three-letter currency code")}function Ae(e,n){let t=A(e,n);return{_key:g(t._key,`${n}._key`),amount:J(t.amount,`${n}.amount`),...C(t,"label",n)}}function Re(e,n){let t=A(e,n);return{_key:g(t._key,`${n}._key`),name:g(t.name,`${n}.name`),amount:J(t.amount,`${n}.amount`)}}function Ee(e,n){let t=A(e,n),o=t.availability??"available";return o!=="available"&&o!=="sold-out"&&o!=="hidden"?f(`${n}.availability`,"is not an availability choice"):{_key:g(t._key,`${n}._key`),name:g(t.name,`${n}.name`),...C(t,"description",n),...C(t,"priceNote",n),...C(t,"allergenNote",n),prices:T(t.prices,`${n}.prices`,Ae),extras:T(t.extras,`${n}.extras`,Re),dietary:T(t.dietary,`${n}.dietary`,g),availability:o}}function xe(e,n){let t=A(e,n);return{_key:g(t._key,`${n}._key`),title:g(t.title,`${n}.title`),...C(t,"service",n),items:T(t.items,`${n}.items`,Ee)}}function Ie(e,n){let t=A(e,n);return{_key:g(t._key,`${n}._key`),label:g(t.label,`${n}.label`),...C(t,"note",n),sections:T(t.sections,`${n}.sections`,xe)}}function Oe(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let n=e._id;return typeof n=="string"&&n.trim()!==""&&!/^(drafts|versions)\./.test(n)}function I(e,n="menu"){return De(Z(e,n),n)}function De(e,n){let t=A(e,n);if(t._type!=="menu")return f(`${n}._type`,"is not menu");if(!Oe(t))return f(`${n}._id`,"is not a published menu identity");let o=g(t._updatedAt,`${n}._updatedAt`);if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(o)||!Number.isFinite(Date.parse(o)))return f(`${n}._updatedAt`,"is not an update date");let r=T(t.variants,`${n}.variants`,Ie);return r.length===0?f(`${n}.variants`,"has no menu choices"):{_type:"menu",_id:g(t._id,`${n}._id`),_rev:g(t._rev,`${n}._rev`),_updatedAt:o,title:g(t.title,`${n}.title`),locationKeys:T(t.locationKeys,`${n}.locationKeys`,g),variants:r,...C(t,"note",n),...Object.hasOwn(t,"signOff")?{signOff:t.signOff}:{}}}function W(e){if(e===null)return!0;try{return I(e),!0}catch{return!1}}var Y="malformed-content",R=class extends Error{code=Y;documentId;problems;constructor(n,t){super(`${Y}: ${n}: ${t.join("; ")}`),this.name="MalformedContentError",this.documentId=n,this.problems=t}};var G=`{..., "sections": coalesce(sections[]{..., _type == "menuBlock" => {menu->{${L}}}, _type == "linkListBlock" => {links[]{..., "page": page->{title, "slug": slug.current}}}}, sections)}`,un=`*[_type == "page" && defined(slug.current)]|order(slug.current asc)${G}`,cn=`*[_type == "page" && slug.current == $slug][0]${G}`;var Me=/^[A-Za-z][A-Za-z0-9_]{0,63}$/,ve=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,Le=/^[a-z0-9]{6,12}\.[a-z][a-z0-9_-]{0,63}$/;function K(e){if(!e||!Array.isArray(e.types)||e.types.length===0)throw new TypeError("CMS dependencies require document types");let n=[...e.types];for(let o of n)if(typeof o!="string"||!Me.test(o))throw new TypeError("Invalid CMS document type");if(e.ids!==void 0&&!Array.isArray(e.ids))throw new TypeError("Invalid CMS document IDs");let t=e.ids===void 0?void 0:[...e.ids];for(let o of t??[])if(typeof o!="string"||!ve.test(o)||/^(drafts|versions)\./.test(o))throw new TypeError("Invalid CMS document ID");if(new Set(n).size+new Set(t).size>128)throw new TypeError("Too many CMS tags");return Object.freeze({types:Object.freeze(n),...t===void 0?{}:{ids:Object.freeze(t)}})}function E(e){if(!e||typeof e.name!="string"||!/^[A-Za-z][A-Za-z0-9_.-]{0,127}$/.test(e.name)||typeof e.query!="string"||e.query.trim()===""||typeof e.resolve!="function")throw new TypeError("Invalid CMS query configuration");let n=e.params;if(!n||typeof n!="object"||Object.getPrototypeOf(n)!==Object.prototype&&Object.getPrototypeOf(n)!==null)throw new TypeError("CMS params must be plain JSON scalars");let t={};for(let o of Reflect.ownKeys(n)){let r=Object.getOwnPropertyDescriptor(n,o);if(typeof o!="string"||!r||!Object.hasOwn(r,"value")||!r.enumerable)throw new TypeError("CMS params must be plain JSON scalars");let s=r.value;if(!(s===null||typeof s=="string"||typeof s=="boolean"||typeof s=="number"&&Number.isFinite(s)))throw new TypeError("CMS params must be plain JSON scalars");Object.defineProperty(t,o,{value:s,enumerable:!0})}return Object.freeze({name:e.name,query:e.query,params:Object.freeze(t),dependencies:K(e.dependencies),resolve:e.resolve})}function S(e,n){if(typeof e!="string"||e.length>77||!Le.test(e))throw new TypeError("Invalid CMS scope");let t=K(n),o=[...[...new Set(t.types)].sort().map(r=>`cms:${e}:type:${r}`),...[...new Set(t.ids??[])].sort().map(r=>`cms:${e}:id:${r}`)];return Object.freeze(o)}function X(e){return E({name:"menu.v1",query:`*[_type == "menu" && _id == $id && !(_id in path("drafts.**")) && !(_id in path("versions.**"))][0]{${L}}`,params:{id:e},dependencies:{types:["menu"],ids:[e]},resolve:(n,t)=>{if(!W(t)||t!==null&&t._id!==e)throw new TypeError("Invalid CMS menu fallback");if(n==null)return{data:t,fallbackFields:["$"]};let o=I(n);if(o._id!==e)throw new R("menu",["menu._id does not match the requested document"]);return{data:o,fallbackFields:[]}}})}function ee(e){if(!e||!Object.hasOwn(e,"data")||!Array.isArray(e.fallbackFields)||![...e.fallbackFields].every(n=>typeof n=="string"&&(n==="$"||/^[A-Za-z][A-Za-z0-9_.[\]-]{0,127}$/.test(n))))throw new TypeError("Invalid CMS resolution");if(e.warnings!==void 0&&(!Array.isArray(e.warnings)||![...e.warnings].every(n=>n==="siteHero.layout.defaulted"||n==="siteHero.tagline.dropped"||n==="siteHero.taglines.defaulted")))throw new TypeError("Invalid CMS resolution warnings");return{data:e.data,fallbackFields:Object.freeze([...new Set(e.fallbackFields)]),...e.warnings?.length?{warnings:Object.freeze([...new Set(e.warnings)])}:{}}}function ne(e){let n=e?.revalidateSeconds??3600;if(!Number.isSafeInteger(n)||n<3600||!e?.adapter||typeof e.adapter.read!="function"||e.onDiagnostic!==void 0&&typeof e.onDiagnostic!="function")throw new TypeError("Invalid CMS reader configuration");let t=e.adapter;S(t.scope,{types:["ScopeValidation"]});let o=r=>{try{e.onDiagnostic?e.onDiagnostic(r):console.warn(JSON.stringify(r))}catch{}};return{async read(r,s){let u,d,i;try{if(u=E(r),i=S(t.scope,u.dependencies),!s||!Object.hasOwn(s,"fallback"))throw new TypeError;d=ee(u.resolve(null,s.fallback))}catch{throw new TypeError("Invalid CMS query or fallback configuration")}let p=(y,a,m)=>(o({event:"cms.fallback",query:u.name,reason:y,fields:["$"],...a===void 0?{}:{status:a},...m?{warnings:m}:{}}),{data:d.data,source:"fallback",fallbackFields:["$"],reason:y,...m?{warnings:m}:{}}),l;try{l=await t.read({name:u.name,query:u.query,params:u.params},{tags:i,revalidateSeconds:n})}catch{return p("network")}if(!l.ok){let a=["configuration","network","timeout","rate-limit","upstream","plan-limit","permission","malformed"].includes(l.reason)?l.reason:"malformed",m=Number.isInteger(l.status)&&(l.status??0)>=100&&(l.status??0)<=599?l.status:void 0;return p(a,m)}if(l.value===null||l.value===void 0)return p("missing");let c;try{c=ee(u.resolve(l.value,s.fallback))}catch{return p("malformed")}return c.fallbackFields.includes("$")?{...p("invalid-field",void 0,c.warnings),data:c.data}:c.fallbackFields.length>0?(o({event:"cms.partial-fallback",query:u.name,reason:"invalid-field",fields:c.fallbackFields,...c.warnings?{warnings:c.warnings}:{}}),{...c,source:"mixed",reason:"invalid-field"}):{...c,source:"cms"}}}}var te=ne;var ie=require("next/cache.js");var N="sanity-webhook-signature",je=/^t=(\d+)[, ]+v1=([^, ]+)$/;var oe=new TextEncoder;function Pe(e){return crypto.subtle.importKey("raw",oe.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"])}function Ne(e){if(!/^[A-Za-z0-9_-]+={0,2}$/.test(e))return null;let n=e.replace(/-/g,"+").replace(/_/g,"/");try{let t=atob(n),o=new Uint8Array(t.length);for(let r=0;r<t.length;r+=1)o[r]=t.charCodeAt(r);return o}catch{return null}}async function re(e){let{secret:n,rawBody:t,headers:o}=e,r=e.now??Date.now(),s=e.toleranceMs??3e5;if(!n||n.length===0)return{ok:!1,reason:"no-secret"};let u=o.get(N);if(!u)return{ok:!1,reason:"no-signature"};let d=je.exec(u.trim());if(d===null)return{ok:!1,reason:"malformed-signature"};let i=Number(d[1]),p=d[2]??"";if(!Number.isSafeInteger(i))return{ok:!1,reason:"malformed-signature"};if(i<16094592e5)return{ok:!1,reason:"stale-timestamp"};if(Math.abs(r-i)>s)return{ok:!1,reason:"stale-timestamp"};let l=Ne(p);if(l===null)return{ok:!1,reason:"malformed-signature"};let c=await Pe(n);return await crypto.subtle.verify("HMAC",c,l,oe.encode(`${i}.${t}`))?{ok:!0}:{ok:!1,reason:"bad-signature"}}var Ue=16*1024,Fe=1500,qe=new TextEncoder;function b(e,n,t={},o=!1){return new Response(o?null:JSON.stringify(n),{status:e,headers:{"Content-Type":"application/json","Cache-Control":"no-store",...t}})}function He(e,n){if(!n||typeof n!="object"||Array.isArray(n)||Object.keys(n).length===0)throw new TypeError("Invalid CMS invalidation mapping");let t=Object.create(null);for(let o of Reflect.ownKeys(n)){let r=Object.getOwnPropertyDescriptor(n,o);if(typeof o!="string"||!r?.enumerable||!Object.hasOwn(r,"value"))throw new TypeError("Invalid CMS invalidation mapping");let s=r.value;if(!Array.isArray(s)||!s.includes(o))throw new TypeError("Invalid CMS invalidation mapping");S(e,{types:s,ids:["validation"]}),t[o]=Object.freeze([...s])}for(let o of Object.values(t))if(o.some(r=>!Object.hasOwn(t,r)))throw new TypeError("Invalid CMS invalidation mapping");return Object.freeze(t)}function se(e){return typeof e=="string"&&e.trim()!==""&&qe.encode(e).byteLength>=32}var O=class extends Error{constructor(t){super("Invalid CMS webhook body");this.status=t}status};async function Be(e){let n=e.body?.getReader();if(!n)return"";let t=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}),o,r=new Promise((s,u)=>{o=setTimeout(()=>u(new O(400)),Fe)});try{let s=0,u="";for(;;){let{done:d,value:i}=await Promise.race([n.read(),r]);if(d)return u+t.decode();if(s+=i.byteLength,s>Ue)throw new O(413);u+=t.decode(i,{stream:!0})}}catch(s){throw n.cancel().catch(()=>{}),s}finally{clearTimeout(o),n.releaseLock()}}function le(e){let n=e.scope,t=He(n,e.typeToTags),o=e.secretEnv??"SANITY_REVALIDATE_SECRET",r=e.previousSecretEnv??"SANITY_REVALIDATE_SECRET_PREVIOUS",s=e.env??(()=>process.env),u=e.now??Date.now,d=async i=>{if(i.method!=="POST")return b(405,{error:"Method not allowed"},{Allow:"POST"},i.method==="HEAD");let p,l;try{let w=s(),j=w[o],_=w[r];if(!se(j)||_!==void 0&&!se(_))throw new Error;p=j,l=_}catch{return b(503,{error:"COULD NOT ANSWER: revalidation configuration unavailable"})}let c=i.headers.get(N);if(!c||c.length>512||!/^t=\d+[, ]+v1=[A-Za-z0-9_-]+={0,2}$/.test(c.trim()))return b(401,{error:"Unauthorized"});let y;try{y=await Be(i)}catch(w){return w instanceof O&&w.status===413?b(413,{error:"Payload too large"}):b(400,{error:"Invalid body"})}try{let w=u();if(!Number.isFinite(w))throw new Error;if(!(await Promise.all([p,...l===void 0?[]:[l]].map(_=>re({secret:_,rawBody:y,headers:i.headers,now:w})))).some(_=>_.ok))return b(401,{error:"Unauthorized"})}catch{return b(401,{error:"Unauthorized"})}let a;try{a=JSON.parse(y)}catch{return b(400,{error:"Invalid payload"})}if(!a||typeof a!="object"||Array.isArray(a)||Object.keys(a).length!==2||!Object.hasOwn(a,"_type")||!Object.hasOwn(a,"_id"))return b(400,{error:"Invalid payload"});let{_type:m,_id:k}=a;if(typeof m!="string"||!/^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(m)||typeof k!="string"||!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(k))return b(400,{error:"Invalid payload"});if(!Object.hasOwn(t,m)||/^(drafts|versions)\./.test(k))return b(400,{error:"Unsupported document"});let ke=S(n,{types:t[m],ids:[k]});try{for(let w of ke)(0,ie.revalidateTag)(w,{expire:0})}catch{return b(500,{error:"Could not revalidate"})}return b(200,{revalidated:!0})};return Object.freeze({POST:d,GET:d,HEAD:d,PUT:d,PATCH:d,DELETE:d,OPTIONS:d})}var $=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),h=e=>typeof e=="string"&&e.trim()?e.trim():null,ze=(e,n)=>e._type===n&&typeof e._id=="string"&&e._id.length>0&&!/^(drafts|versions)\./.test(e._id),Qe=/^\d{4}-\d{2}-\d{2}$/,ae=/^([01]\d|2[0-3]):[0-5]\d$/,Ve=["mon","tue","wed","thu","fri","sat","sun"];async function ue(e,n,t){try{let o=await e.read(n,{fallback:t});return{...o,source:o.source==="cms"?"sanity":o.source}}catch{return{data:t,source:"fallback",fallbackFields:["$"],reason:"configuration"}}}var Ze=/^[A-Za-z0-9._+-]{1,64}@[A-Za-z0-9-]{1,63}(?:\.[A-Za-z0-9-]{1,63})*\.[A-Za-z]{2,63}$/;function Je(e){let n=h(e);if(!n)return null;try{let t=new URL(n);return t.protocol==="http:"||t.protocol==="https:"?t.href:null}catch{return null}}function x(e){if(typeof e!="function")throw new TypeError("A client validator is required")}function U(e,n,t){if(x(t),!$(e)||e.status!=="open")return null;let o=h(e.closingDate);if(o!==null&&o<n||t(e)!==null)return null;let r=h(e.title),s=$(e.workLocation)?e.workLocation:null,u=h(e.location),d=h(s?.name)??(u==="Other"?null:u)??h(e.locationNote);if(!r||!d)return null;let i=h(e.pdfUrl);return{id:String(h(e._id)),title:r,location:d,locationId:s===null?null:h(s._id),summary:h(e.summary),pdfUrl:i?.startsWith("https://cdn.sanity.io/files/")?i:null,applyUrl:Je(e.applyUrl),applyEmail:typeof e.applyEmail=="string"&&e.applyEmail.length<=254&&Ze.test(e.applyEmail)?e.applyEmail:null}}function F(e,n,t){if(x(t),!Array.isArray(e))throw new TypeError("Sanity returned vacancies that are not a list");return e.map(o=>({value:U(o,n,t),order:$(o)&&typeof o.order=="number"&&Number.isFinite(o.order)?o.order:1e6})).filter(o=>o.value!==null).sort((o,r)=>o.order-r.order||o.value.title.toLowerCase().localeCompare(r.value.title.toLowerCase())).map(o=>o.value)}function ce(e){return S(e,{types:["vacancy","location"]})}function de(e,n){if(!Qe.test(e))throw new TypeError("Invalid calendar date");return x(n),E({name:"vacancy.open.v2",query:'*[_type == "vacancy" && status == "open" && !(_id in path("drafts.**")) && !(_id in path("versions.**")) && (!defined(closingDate) || closingDate >= $today)]|order(coalesce(order, 1000000) asc, lower(title) asc){_id, _type, title, "workLocation": workLocation->{_id, name}, location, locationNote, summary, "pdfUrl": jobDescriptionPdf.asset->url, applyUrl, applyEmail, status, closingDate, order}',params:{today:e},dependencies:{types:["vacancy","location"]},resolve:(t,o)=>({data:t==null?o:F(t,e,n),fallbackFields:t==null?["$"]:[]})})}var We=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Ye=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function q(e){return!$(e)||typeof e._id!="string"||!$(e.slug)||typeof e.slug.current!="string"||!Ye.test(e.slug.current)||h(e.name)===null||e.addressLines!==void 0&&e.addressLines!==null&&(!Array.isArray(e.addressLines)||Array.from(e.addressLines).some(n=>h(n)===null))||e.postcode!==void 0&&e.postcode!==null&&h(e.postcode)===null||e.coordinates!==void 0&&e.coordinates!==null&&(!$(e.coordinates)||typeof e.coordinates.lat!="number"||!Number.isFinite(e.coordinates.lat)||typeof e.coordinates.lng!="number"||!Number.isFinite(e.coordinates.lng))||e.phone!==void 0&&e.phone!==null&&typeof e.phone!="string"||e.email!==void 0&&e.email!==null&&typeof e.email!="string"?null:{name:h(e.name),slug:e.slug.current,addressLines:e.addressLines==null?e.addressLines:e.addressLines.map(n=>n.trim()),postcode:e.postcode==null?e.postcode:String(e.postcode).trim(),coordinates:e.coordinates==null?e.coordinates:{lat:e.coordinates.lat,lng:e.coordinates.lng},phone:e.phone,email:e.email,hours:e.hours}}function ye(e){if(!$(e))return null;let n={};for(let t of We){let o=e[t];if(!Array.isArray(o)||!Array.from(o).every(r=>$(r)&&typeof r.opens=="string"&&typeof r.closes=="string"))return null;n[t]=o.map(r=>({opens:r.opens,closes:r.closes}))}return n}function H(e,n,t){x(t);let o=q(e);if(o===null||o.slug!==n.id)return{data:n,fallbackFields:["$"]};let r=ye(o.hours),s={id:n.id,label:o.name,addressLines:o.addressLines??n.addressLines,postcode:o.postcode??n.postcode,geo:o.coordinates==null?n.geo:{latitude:o.coordinates.lat,longitude:o.coordinates.lng},telephone:o.phone===void 0?n.telephone:o.phone,email:o.email===void 0?n.email:o.email,hours:r??n.hours};try{return{data:t(s),fallbackFields:r===null?["hours"]:[]}}catch{if(r!==null)try{return{data:t({...s,hours:n.hours}),fallbackFields:["hours"]}}catch{}return{data:n,fallbackFields:["$"]}}}function B(e,n,t){x(t);let o=q(e);if(o===null||o.slug!==n.id)return{data:n,fallbackFields:["$"]};let r=ye(o.hours),s={...n,label:o.name,address:n.address===null?null:{...n.address,streetAddress:o.addressLines??n.address.streetAddress,postalCode:o.postcode??n.address.postalCode},telephone:o.phone===void 0?n.telephone:o.phone,email:o.email===void 0?n.email:o.email,geo:o.coordinates==null?n.geo:{latitude:o.coordinates.lat,longitude:o.coordinates.lng},hours:r??n.hours};try{return{data:t(s),fallbackFields:r===null?["hours"]:[]}}catch{if(r!==null)try{return{data:t({...s,hours:n.hours}),fallbackFields:["hours"]}}catch{}return{data:n,fallbackFields:["$"]}}}function pe(e){return S(e,{types:["location"]})}function fe(e,n){return E({name:e,query:'*[_type == "location" && defined(slug.current) && !(_id in path("drafts.**")) && !(_id in path("versions.**"))]{_id, _type, name, slug, addressLines, postcode, coordinates, phone, email, hours}',params:{},dependencies:{types:["location"]},resolve:(t,o)=>{if(!Array.isArray(t))return{data:o,fallbackFields:["$"]};let r=new Map,s=new Set;for(let i of t){let p=q(i);p!==null&&(r.has(p.slug)?s.add(p.slug):r.set(p.slug,i))}let u=[];return{data:o.map((i,p)=>{let l=r.get(i.id),c=l===void 0||s.has(i.id)?{data:i,fallbackFields:["$"]}:n(l,i);return u.push(...c.fallbackFields.map(y=>y==="$"?`locations[${p}]`:`locations[${p}].${y}`)),c.data}),fallbackFields:o.length>0&&u.length===o.length&&u.every(i=>/^locations\[\d+\]$/.test(i))?["$"]:u}}})}function me(e){return x(e),fe("locations.v1",(n,t)=>H(n,t,e))}function ge(e){return x(e),fe("locations.business.v1",(n,t)=>B(n,t,e))}function Ge(e,n,t){let o=`${e}-${n.normalize("NFKD").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"stop"}`,r=o;for(let s=2;t.has(r);s++)r=`${o}-${s}`;return t.add(r),r}function z(e,n){if(!$(e)||!ze(e,"schedule")||e._id!=="schedule"||e.timeZone!==n.timeZone||!Array.isArray(e.days)||e.days.length!==7)throw new TypeError("Invalid schedule document");let t=e.days.map((o,r)=>{if(!$(o)||o.day!==Ve[r]||typeof o.rest!="boolean"||!Array.isArray(o.stops))throw new TypeError("Invalid schedule day");let s=o.day,u=o.rest,d=o.stops,i=n.days.find(y=>y.day===s),p=new Set(i?.stops.map(y=>y.id)??[]),l=new Set,c=d.map(y=>{if(!$(y))throw new TypeError("Invalid schedule stop");let a=y;if(!h(a.name)||!ae.test(String(a.from??""))||!ae.test(String(a.to??""))||!h(a.address))throw new TypeError("Invalid schedule stop");let m=i?.stops.find(k=>k.name===a.name&&!l.has(k.id));return m?(l.add(m.id),{...m,name:String(a.name),from:String(a.from),to:String(a.to),address:String(a.address)}):{id:Ge(s,String(a.name),p),name:String(a.name),from:String(a.from),to:String(a.to),address:String(a.address),place:null,postcode:null,notes:null,lat:null,lng:null,coordinateSource:null,approximate:!1,needsConfirmation:null,captured:`${a.name}
6
+ ${a.from}-${a.to}
7
+ ${a.address}`}});return{day:s,rest:u,stops:u?[]:c}});return{timeZone:n.timeZone,days:t}}function he(e){return S(e,{types:["schedule"],ids:["schedule"]})}function be(){return E({name:"schedule.v1",query:'*[_type == "schedule" && _id == "schedule" && !(_id in path("drafts.**")) && !(_id in path("versions.**"))][0]{_id, _type, timeZone, days}',params:{},dependencies:{types:["schedule"],ids:["schedule"]},resolve:(e,n)=>({data:e==null?n:z(e,n),fallbackFields:e==null?["$"]:[]})})}0&&(module.exports={MENU_DECORATIONS,MENU_LAYOUTS,MENU_LAYOUT_DEFAULTS,businessLocationsQuery,createNextCmsReader,createRevalidateRoute,locationTags,locationsQuery,menuQuery,menuTags,openVacanciesQuery,parseBusinessLocation,parseLocationDocument,parseMenuDocument,parseScheduleDocument,parseVacancies,parseVacancyDocument,resolveWithFallback,scheduleQuery,scheduleTags,vacancyTags});
8
8
  //# sourceMappingURL=next.cjs.map