@weatherboard/cms 0.4.0 → 0.5.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 +6 -1
- package/dist/portable/sections.d.cts +5 -1
- package/dist/portable/sections.d.mts +5 -1
- package/dist/portable/sections.d.ts +5 -1
- package/dist/site-content.cjs +3 -3
- package/dist/site-content.cjs.map +3 -3
- package/dist/site-content.mjs +3 -3
- package/dist/site-content.mjs.map +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -98,7 +98,12 @@ the path in the stored document, never copy:
|
|
|
98
98
|
- `section.layout.defaulted`: missing or unknown `layout`; the composition
|
|
99
99
|
default renders. It never throws and never yields an empty section.
|
|
100
100
|
- `section.type.unknown`: a section `_type` this reader does not know is
|
|
101
|
-
skipped; the rest of the page reads.
|
|
101
|
+
skipped; the rest of the page reads. This warning also requires `type`, the
|
|
102
|
+
schema type name, so a build can log it with `PageContent.slug`. The name is
|
|
103
|
+
truncated to 64 characters; only ASCII letters, digits, `_`, `-` and `.` are
|
|
104
|
+
preserved, and other characters become `?`. Missing or non-string `_type`
|
|
105
|
+
values produce `type: "?"`, without serializing content. `code` and `where`
|
|
106
|
+
stay unchanged; other warning codes have no `type` field.
|
|
102
107
|
- `section.image.missing-alt`: an image without alt text is dropped, never
|
|
103
108
|
returned without it. `text_media.image` is then `null`; a gallery keeps its
|
|
104
109
|
other photos.
|
|
@@ -73,7 +73,11 @@ export declare const SECTION_WARNINGS: {
|
|
|
73
73
|
export type SectionWarningCode = (typeof SECTION_WARNINGS)[keyof typeof SECTION_WARNINGS];
|
|
74
74
|
/** A named warning and the path in the stored document it is about. Never copy. */
|
|
75
75
|
export type SectionWarning = {
|
|
76
|
-
readonly code:
|
|
76
|
+
readonly code: typeof SECTION_WARNINGS.unknownType;
|
|
77
|
+
readonly where: string;
|
|
78
|
+
readonly type: string;
|
|
79
|
+
} | {
|
|
80
|
+
readonly code: Exclude<SectionWarningCode, typeof SECTION_WARNINGS.unknownType>;
|
|
77
81
|
readonly where: string;
|
|
78
82
|
};
|
|
79
83
|
/** A Sanity image as a site needs it. `asset` is the image asset's id; `alt` is never empty. */
|
|
@@ -73,7 +73,11 @@ export declare const SECTION_WARNINGS: {
|
|
|
73
73
|
export type SectionWarningCode = (typeof SECTION_WARNINGS)[keyof typeof SECTION_WARNINGS];
|
|
74
74
|
/** A named warning and the path in the stored document it is about. Never copy. */
|
|
75
75
|
export type SectionWarning = {
|
|
76
|
-
readonly code:
|
|
76
|
+
readonly code: typeof SECTION_WARNINGS.unknownType;
|
|
77
|
+
readonly where: string;
|
|
78
|
+
readonly type: string;
|
|
79
|
+
} | {
|
|
80
|
+
readonly code: Exclude<SectionWarningCode, typeof SECTION_WARNINGS.unknownType>;
|
|
77
81
|
readonly where: string;
|
|
78
82
|
};
|
|
79
83
|
/** A Sanity image as a site needs it. `asset` is the image asset's id; `alt` is never empty. */
|
|
@@ -73,7 +73,11 @@ export declare const SECTION_WARNINGS: {
|
|
|
73
73
|
export type SectionWarningCode = (typeof SECTION_WARNINGS)[keyof typeof SECTION_WARNINGS];
|
|
74
74
|
/** A named warning and the path in the stored document it is about. Never copy. */
|
|
75
75
|
export type SectionWarning = {
|
|
76
|
-
readonly code:
|
|
76
|
+
readonly code: typeof SECTION_WARNINGS.unknownType;
|
|
77
|
+
readonly where: string;
|
|
78
|
+
readonly type: string;
|
|
79
|
+
} | {
|
|
80
|
+
readonly code: Exclude<SectionWarningCode, typeof SECTION_WARNINGS.unknownType>;
|
|
77
81
|
readonly where: string;
|
|
78
82
|
};
|
|
79
83
|
/** A Sanity image as a site needs it. `asset` is the image asset's id; `alt` is never empty. */
|
package/dist/site-content.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var rn=Object.defineProperty;var qn=Object.getOwnPropertyDescriptor;var Mn=Object.getOwnPropertyNames;var Un=Object.prototype.hasOwnProperty;var Yn=(n,e)=>{for(var t in e)rn(n,t,{get:e[t],enumerable:!0})},Bn=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Mn(e))!Un.call(n,i)&&i!==t&&rn(n,i,{get:()=>e[i],enumerable:!(o=qn(e,i))||o.enumerable});return n};var Wn=n=>Bn(rn({},"__esModule",{value:!0}),n);var te={};Yn(te,{CONTENT_PAGES_QUERY:()=>en,CONTENT_PAGE_BY_SLUG_QUERY:()=>tn,HEADING_LIST_LAYOUTS:()=>L,HOME_PAGE_DOCUMENT_QUERY:()=>M,MALFORMED_CONTENT:()=>X,MalformedContentError:()=>b,READER_ACTION_HREF:()=>z,READER_GALLERY_PHOTO_LIMIT:()=>B,READER_GALLERY_PHOTO_MIN:()=>Y,READER_HOME_PAGE_ID:()=>O,READER_JUMP_LINK:()=>D,READER_PHOTO_SLUG:()=>F,READER_SECTION_KINDS:()=>wn,READER_SITE_SETTINGS_ID:()=>x,READER_STORY_LAYOUTS:()=>Q,SECTION_LAYOUT_DEFAULTS:()=>R,SECTION_WARNINGS:()=>_,SITE_HERO_LAYOUTS:()=>dn,SITE_HERO_LAYOUT_WARNING:()=>fn,SITE_HERO_TAGLINES_DEFAULTED_WARNING:()=>hn,SITE_HERO_TAGLINE_DROPPED_WARNING:()=>gn,SITE_HERO_TAGLINE_MAX_LENGTH:()=>yn,SPLIT_LAYOUTS:()=>A,STAGGER_ROW_LAYOUTS:()=>H,campaignState:()=>un,contentPageQuery:()=>Ln,contentPagesQuery:()=>Hn,createSiteContentReader:()=>On,homeContentQuery:()=>xn,parseContentPage:()=>q,parseHomePage:()=>v,parseSiteHero:()=>Sn,parseSiteSettings:()=>nn,portableTextToMarkdown:()=>En,siteHeroQuery:()=>jn,siteSettingsQuery:()=>Nn,validateSiteHeroTaglines:()=>mn});module.exports=Wn(te);function S(n){if(!Array.isArray(n))return!1;for(let e=0;e<n.length;e+=1)if(!Object.hasOwn(n,e))return!1;return!0}var Fn=/^[A-Za-z][A-Za-z0-9_]{0,63}$/,zn=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;function Qn(n){if(!n||!Array.isArray(n.types)||n.types.length===0)throw new TypeError("CMS dependencies require document types");let e=[...n.types];for(let o of e)if(typeof o!="string"||!Fn.test(o))throw new TypeError("Invalid CMS document type");if(n.ids!==void 0&&!Array.isArray(n.ids))throw new TypeError("Invalid CMS document IDs");let t=n.ids===void 0?void 0:[...n.ids];for(let o of t??[])if(typeof o!="string"||!zn.test(o)||/^(drafts|versions)\./.test(o))throw new TypeError("Invalid CMS document ID");if(new Set(e).size+new Set(t).size>128)throw new TypeError("Too many CMS tags");return Object.freeze({types:Object.freeze(e),...t===void 0?{}:{ids:Object.freeze(t)}})}function E(n){if(!n||typeof n.name!="string"||!/^[A-Za-z][A-Za-z0-9_.-]{0,127}$/.test(n.name)||typeof n.query!="string"||n.query.trim()===""||typeof n.resolve!="function")throw new TypeError("Invalid CMS query configuration");let e=n.params;if(!e||typeof e!="object"||Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new TypeError("CMS params must be plain JSON scalars");let t={};for(let o of Reflect.ownKeys(e)){let i=Object.getOwnPropertyDescriptor(e,o);if(typeof o!="string"||!i||!Object.hasOwn(i,"value")||!i.enumerable)throw new TypeError("CMS params must be plain JSON scalars");let r=i.value;if(!(r===null||typeof r=="string"||typeof r=="boolean"||typeof r=="number"&&Number.isFinite(r)))throw new TypeError("CMS params must be plain JSON scalars");Object.defineProperty(t,o,{value:r,enumerable:!0})}return Object.freeze({name:n.name,query:n.query,params:Object.freeze(t),dependencies:Qn(n.dependencies),resolve:n.resolve})}var A=["media-end","media-start","media-below"],L=["beside","stacked"],H=["staggered","aligned"],R={Split:"media-end",HeadingList:"beside",StaggerRow:"staggered"},wn={featureStoriesBlock:"feature_stories",surfaceCardBlock:"cta",accentBandBlock:"accent_band",locationsBlock:"locations",textMediaBlock:"text_media",faqBlock:"faq",galleryBlock:"gallery",contactBlock:"contact"},Y=2,B=4,_={layoutDefaulted:"section.layout.defaulted",unknownType:"section.type.unknown",imageMissingAlt:"section.image.missing-alt",imageMissingAsset:"section.image.missing-asset",emptySkipped:"section.empty.skipped"};var h=n=>n!==null&&typeof n=="object"&&!Array.isArray(n),k=n=>typeof n=="string"&&n.trim()!=="",N=n=>n===null||typeof n=="string",$=n=>n===null||typeof n=="string"&&F.test(n),bn=n=>typeof n=="string"&&z.test(n),w=n=>k(n)||h(n)&&k(n.text)&&(n.copySource==="captured"||n.copySource==="proposed"),C=n=>n===null||w(n),In=n=>h(n)&&w(n.label)&&bn(n.href),P=n=>n===null||In(n),Z=n=>n===null||typeof n=="string"&&D.test(n),W=(n,e)=>n.some(t=>t===e),sn=n=>h(n)&&k(n.asset)&&k(n.alt)&&N(n.caption)&&(n.hotspot===null||h(n.hotspot)&&typeof n.hotspot.x=="number"&&typeof n.hotspot.y=="number");function kn(n){if(!h(n))return!1;switch(n.kind){case"campaign":return P(n.action)&&S(n.images)&&n.images.every(e=>typeof e=="string"&&$(e));case"locations":return(n.anchor===null||typeof n.anchor=="string"&&D.test(n.anchor))&&w(n.heading)&&C(n.tail)&&$(n.image);case"feature_stories":return w(n.heading)&&C(n.tail)&&S(n.items)&&n.items.length>0&&n.items.every(e=>h(e)&&w(e.heading)&&w(e.body)&&In(e.action)&&$(e.image)&&Q.some(t=>t===e.shape)&&typeof e.card=="boolean");case"accent_band":return w(n.heading)&&w(n.body)&&P(n.action)&&$(n.image);case"cta":return k(n.heading)&&N(n.body)&&h(n.link)&&k(n.link.label)&&bn(n.link.href);default:return!1}}function Jn(n){if(!h(n))return!1;switch(n.kind){case"campaign":return!1;case"text_media":return Z(n.anchor)&&W(A,n.layout)&&w(n.heading)&&C(n.tail)&&w(n.body)&&P(n.action)&&(n.image===null||sn(n.image));case"faq":return Z(n.anchor)&&W(L,n.layout)&&w(n.heading)&&C(n.tail)&&C(n.intro)&&S(n.items)&&n.items.length>0&&n.items.every(e=>h(e)&&w(e.question)&&w(e.answer));case"gallery":return Z(n.anchor)&&W(H,n.layout)&&C(n.heading)&&S(n.images)&&n.images.length>0&&n.images.every(sn);case"contact":return Z(n.anchor)&&W(A,n.layout)&&w(n.heading)&&C(n.body)&&typeof n.showEmail=="boolean"&&typeof n.showPhone=="boolean"&&P(n.action)&&(n.image===null||sn(n.image));default:return kn(n)}}function Kn(n,e){if(n===void 0)return e===void 0;if(!S(n)||!n.every(Jn)||!S(e)||!e.every(r=>h(r)&&W(Object.values(_),r.code)&&k(r.where)))return!1;let t=n,o=t.flatMap(r=>"anchor"in r&&r.anchor!==null?[r.anchor]:[]);return new Set(o).size!==o.length?!1:t.flatMap(r=>{switch(r.kind){case"text_media":case"contact":case"accent_band":return[r.action?.href];case"feature_stories":return r.items.map(a=>a.action.href);case"cta":return[r.link.href];default:return[]}}).every(r=>r===void 0||!r.startsWith("#")||o.includes(r.slice(1)))}function _n(n){if(!h(n)||!N(n.intro)||!$(n.photo)||!S(n.blocks))return!1;let e=n.hero;if(e!==null&&(!h(e)||!w(e.heading)||!C(e.subline)||!C(e.intro)||!$(e.image)||!$(e.inset)||!P(e.cta)||!P(e.secondaryCta))||!n.blocks.every(kn))return!1;let t=n,o=t.blocks.flatMap(r=>r.kind==="locations"&&r.anchor!==null?[r.anchor]:[]);return new Set(o).size!==o.length?!1:[t.hero?.cta?.href,t.hero?.secondaryCta?.href,...t.blocks.flatMap(r=>{switch(r.kind){case"campaign":case"accent_band":return[r.action?.href];case"feature_stories":return r.items.map(a=>a.action.href);case"cta":return[r.link.href];default:return[]}})].every(r=>r===void 0||!r.startsWith("#")||o.includes(r.slice(1)))}function Tn(n){return S(n)&&n.every(e=>h(e)&&k(e.where)&&typeof e.text=="string")}function Cn(n){return n===null||h(n)&&_n(n.composition)&&typeof n.body=="string"&&Tn(n.proposedCopy)&&typeof n.campaign=="string"&&["shown","off","not-started","ended","none"].includes(n.campaign)}function an(n){return n===null||h(n)&&k(n.slug)&&k(n.title)&&_n(n.composition)&&typeof n.body=="string"&&typeof n.migrated=="boolean"&&Tn(n.proposedCopy)&&Kn(n.sections,n.warnings)}function An(n){return n===null||h(n)&&k(n.name)&&N(n.description)&&h(n.contact)&&N(n.contact.email)&&N(n.contact.phone)&&S(n.social)&&n.social.every(e=>h(e)&&k(e.network)&&typeof e.url=="string"&&/^https?:\/\//.test(e.url))}var X="malformed-content",b=class extends Error{code=X;documentId;problems;constructor(e,t){super(`${X}: ${e}: ${t.join("; ")}`),this.name="MalformedContentError",this.documentId=e,this.problems=t}},F=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,z=/^(?:\/(?![/\\])[^\s]*|#[a-z][a-z0-9]*(?:-[a-z0-9]+)*|mailto:[^\s@]+@[^\s@]+|tel:\+?[0-9][0-9 ()-]*|https?:\/\/[^\s/]+[^\s]*)$/,D=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,Q=["wide","tall","round","free"],O="homePage",x="siteSettings",j=class{problems=[];proposed=[];fail(e,t){return this.problems.push(`${e} ${t}`),null}object(e,t){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:this.fail(t,"is not an object")}dense(e,t){return S(e)?!0:(this.fail(t,"contains missing entries"),!1)}optionalString(e,t){return e==null?null:typeof e=="string"?e.trim()===""?null:e:this.fail(t,"is not text")}copy(e,t){if(e==null)return null;let o=this.object(e,t);if(o===null)return null;let i=o.text,r=o.copySource;return i!==void 0&&typeof i!="string"?this.fail(`${t}.text`,"is not text"):r!==void 0&&r!=="captured"&&r!=="proposed"?this.fail(`${t}.copySource`,`is ${JSON.stringify(r)}, not captured or proposed`):typeof i!="string"||i.trim()===""?null:r==="proposed"?(this.proposed.push({where:t,text:i}),{text:i,copySource:"proposed"}):r==="captured"?{text:i,copySource:"captured"}:i}requiredCopy(e,t){let o=this.copy(e,t);return o===null&&!this.problems.some(i=>i.startsWith(t))&&this.fail(t,"is missing its words"),o}photo(e,t){return e==null?null:typeof e=="string"&&F.test(e)?e:this.fail(t,`is ${JSON.stringify(e)}, not a photo library slug`)}photos(e,t,o){return e==null?[]:Array.isArray(e)?this.dense(e,t)?(e.length>o&&this.fail(t,`holds ${String(e.length)} photos; at most ${String(o)}`),e.map((i,r)=>this.photo(i,`${t}[${String(r)}]`)).filter(i=>i!==null)):[]:(this.fail(t,"is not a list of photos"),[])}action(e,t){if(e==null)return null;let o=this.object(e,t);if(o===null)return null;let i=this.requiredCopy(o.label,`${t}.label`),r=o.href;return typeof r!="string"||!z.test(r)?this.fail(`${t}.href`,`is ${JSON.stringify(r)}, not a site path, #jump-link, mailto:, tel: or web address`):i===null?null:{label:i,href:r}}requiredAction(e,t){return e==null?this.fail(t,"is missing"):this.action(e,t)}};function K(n){return typeof n=="string"?n:n.text}function En(n){let e=new j,t=cn(n,"body",e);if(e.problems.length>0)throw new b("body",e.problems);return t}function cn(n,e,t){if(n==null)return"";if(!Array.isArray(n))return t.fail(e,"is not rich text"),"";if(!t.dense(n,e))return"";let o=[],i=!1;return n.forEach((r,a)=>{let s=`${e}[${String(a)}]`,u=t.object(r,s);if(u===null)return;if(u._type!=="block"){t.fail(s,`is a ${JSON.stringify(u._type)}; only text is supported in rich text so far`);return}let l=Vn(u,s,t),c=u.listItem,d=u.style??"normal",p;if(c==="bullet"||c==="number"){let f=typeof u.level=="number"&&u.level>1?u.level:1;p=`${" ".repeat(f-1)}${c==="bullet"?"-":"1."} ${l}`}else if(d==="h2")p=`## ${l}`;else if(d==="h3")p=`### ${l}`;else if(d==="blockquote")p=`> ${l}`;else if(d==="normal")p=l;else{t.fail(`${s}.style`,`is ${JSON.stringify(d)}, which the schema does not offer`);return}let y=c==="bullet"||c==="number";o.length>0&&o.push(y&&i?`
|
|
1
|
+
"use strict";var rn=Object.defineProperty;var qn=Object.getOwnPropertyDescriptor;var Mn=Object.getOwnPropertyNames;var Un=Object.prototype.hasOwnProperty;var Yn=(n,e)=>{for(var t in e)rn(n,t,{get:e[t],enumerable:!0})},Bn=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Mn(e))!Un.call(n,i)&&i!==t&&rn(n,i,{get:()=>e[i],enumerable:!(o=qn(e,i))||o.enumerable});return n};var Wn=n=>Bn(rn({},"__esModule",{value:!0}),n);var oe={};Yn(oe,{CONTENT_PAGES_QUERY:()=>en,CONTENT_PAGE_BY_SLUG_QUERY:()=>tn,HEADING_LIST_LAYOUTS:()=>L,HOME_PAGE_DOCUMENT_QUERY:()=>M,MALFORMED_CONTENT:()=>X,MalformedContentError:()=>I,READER_ACTION_HREF:()=>z,READER_GALLERY_PHOTO_LIMIT:()=>B,READER_GALLERY_PHOTO_MIN:()=>Y,READER_HOME_PAGE_ID:()=>O,READER_JUMP_LINK:()=>D,READER_PHOTO_SLUG:()=>F,READER_SECTION_KINDS:()=>wn,READER_SITE_SETTINGS_ID:()=>x,READER_STORY_LAYOUTS:()=>Q,SECTION_LAYOUT_DEFAULTS:()=>R,SECTION_WARNINGS:()=>b,SITE_HERO_LAYOUTS:()=>dn,SITE_HERO_LAYOUT_WARNING:()=>fn,SITE_HERO_TAGLINES_DEFAULTED_WARNING:()=>hn,SITE_HERO_TAGLINE_DROPPED_WARNING:()=>gn,SITE_HERO_TAGLINE_MAX_LENGTH:()=>yn,SPLIT_LAYOUTS:()=>A,STAGGER_ROW_LAYOUTS:()=>H,campaignState:()=>un,contentPageQuery:()=>Ln,contentPagesQuery:()=>Hn,createSiteContentReader:()=>On,homeContentQuery:()=>xn,parseContentPage:()=>q,parseHomePage:()=>v,parseSiteHero:()=>Sn,parseSiteSettings:()=>nn,portableTextToMarkdown:()=>En,siteHeroQuery:()=>jn,siteSettingsQuery:()=>Nn,validateSiteHeroTaglines:()=>mn});module.exports=Wn(oe);function S(n){if(!Array.isArray(n))return!1;for(let e=0;e<n.length;e+=1)if(!Object.hasOwn(n,e))return!1;return!0}var Fn=/^[A-Za-z][A-Za-z0-9_]{0,63}$/,zn=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;function Qn(n){if(!n||!Array.isArray(n.types)||n.types.length===0)throw new TypeError("CMS dependencies require document types");let e=[...n.types];for(let o of e)if(typeof o!="string"||!Fn.test(o))throw new TypeError("Invalid CMS document type");if(n.ids!==void 0&&!Array.isArray(n.ids))throw new TypeError("Invalid CMS document IDs");let t=n.ids===void 0?void 0:[...n.ids];for(let o of t??[])if(typeof o!="string"||!zn.test(o)||/^(drafts|versions)\./.test(o))throw new TypeError("Invalid CMS document ID");if(new Set(e).size+new Set(t).size>128)throw new TypeError("Too many CMS tags");return Object.freeze({types:Object.freeze(e),...t===void 0?{}:{ids:Object.freeze(t)}})}function E(n){if(!n||typeof n.name!="string"||!/^[A-Za-z][A-Za-z0-9_.-]{0,127}$/.test(n.name)||typeof n.query!="string"||n.query.trim()===""||typeof n.resolve!="function")throw new TypeError("Invalid CMS query configuration");let e=n.params;if(!e||typeof e!="object"||Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new TypeError("CMS params must be plain JSON scalars");let t={};for(let o of Reflect.ownKeys(e)){let i=Object.getOwnPropertyDescriptor(e,o);if(typeof o!="string"||!i||!Object.hasOwn(i,"value")||!i.enumerable)throw new TypeError("CMS params must be plain JSON scalars");let r=i.value;if(!(r===null||typeof r=="string"||typeof r=="boolean"||typeof r=="number"&&Number.isFinite(r)))throw new TypeError("CMS params must be plain JSON scalars");Object.defineProperty(t,o,{value:r,enumerable:!0})}return Object.freeze({name:n.name,query:n.query,params:Object.freeze(t),dependencies:Qn(n.dependencies),resolve:n.resolve})}var A=["media-end","media-start","media-below"],L=["beside","stacked"],H=["staggered","aligned"],R={Split:"media-end",HeadingList:"beside",StaggerRow:"staggered"},wn={featureStoriesBlock:"feature_stories",surfaceCardBlock:"cta",accentBandBlock:"accent_band",locationsBlock:"locations",textMediaBlock:"text_media",faqBlock:"faq",galleryBlock:"gallery",contactBlock:"contact"},Y=2,B=4,b={layoutDefaulted:"section.layout.defaulted",unknownType:"section.type.unknown",imageMissingAlt:"section.image.missing-alt",imageMissingAsset:"section.image.missing-asset",emptySkipped:"section.empty.skipped"};var h=n=>n!==null&&typeof n=="object"&&!Array.isArray(n),_=n=>typeof n=="string"&&n.trim()!=="",N=n=>n===null||typeof n=="string",$=n=>n===null||typeof n=="string"&&F.test(n),In=n=>typeof n=="string"&&z.test(n),w=n=>_(n)||h(n)&&_(n.text)&&(n.copySource==="captured"||n.copySource==="proposed"),C=n=>n===null||w(n),kn=n=>h(n)&&w(n.label)&&In(n.href),P=n=>n===null||kn(n),Z=n=>n===null||typeof n=="string"&&D.test(n),W=(n,e)=>n.some(t=>t===e),sn=n=>h(n)&&_(n.asset)&&_(n.alt)&&N(n.caption)&&(n.hotspot===null||h(n.hotspot)&&typeof n.hotspot.x=="number"&&typeof n.hotspot.y=="number");function _n(n){if(!h(n))return!1;switch(n.kind){case"campaign":return P(n.action)&&S(n.images)&&n.images.every(e=>typeof e=="string"&&$(e));case"locations":return(n.anchor===null||typeof n.anchor=="string"&&D.test(n.anchor))&&w(n.heading)&&C(n.tail)&&$(n.image);case"feature_stories":return w(n.heading)&&C(n.tail)&&S(n.items)&&n.items.length>0&&n.items.every(e=>h(e)&&w(e.heading)&&w(e.body)&&kn(e.action)&&$(e.image)&&Q.some(t=>t===e.shape)&&typeof e.card=="boolean");case"accent_band":return w(n.heading)&&w(n.body)&&P(n.action)&&$(n.image);case"cta":return _(n.heading)&&N(n.body)&&h(n.link)&&_(n.link.label)&&In(n.link.href);default:return!1}}function Jn(n){if(!h(n))return!1;switch(n.kind){case"campaign":return!1;case"text_media":return Z(n.anchor)&&W(A,n.layout)&&w(n.heading)&&C(n.tail)&&w(n.body)&&P(n.action)&&(n.image===null||sn(n.image));case"faq":return Z(n.anchor)&&W(L,n.layout)&&w(n.heading)&&C(n.tail)&&C(n.intro)&&S(n.items)&&n.items.length>0&&n.items.every(e=>h(e)&&w(e.question)&&w(e.answer));case"gallery":return Z(n.anchor)&&W(H,n.layout)&&C(n.heading)&&S(n.images)&&n.images.length>0&&n.images.every(sn);case"contact":return Z(n.anchor)&&W(A,n.layout)&&w(n.heading)&&C(n.body)&&typeof n.showEmail=="boolean"&&typeof n.showPhone=="boolean"&&P(n.action)&&(n.image===null||sn(n.image));default:return _n(n)}}function Kn(n,e){if(n===void 0)return e===void 0;if(!S(n)||!n.every(Jn)||!S(e)||!e.every(r=>h(r)&&W(Object.values(b),r.code)&&_(r.where)))return!1;let t=n,o=t.flatMap(r=>"anchor"in r&&r.anchor!==null?[r.anchor]:[]);return new Set(o).size!==o.length?!1:t.flatMap(r=>{switch(r.kind){case"text_media":case"contact":case"accent_band":return[r.action?.href];case"feature_stories":return r.items.map(a=>a.action.href);case"cta":return[r.link.href];default:return[]}}).every(r=>r===void 0||!r.startsWith("#")||o.includes(r.slice(1)))}function bn(n){if(!h(n)||!N(n.intro)||!$(n.photo)||!S(n.blocks))return!1;let e=n.hero;if(e!==null&&(!h(e)||!w(e.heading)||!C(e.subline)||!C(e.intro)||!$(e.image)||!$(e.inset)||!P(e.cta)||!P(e.secondaryCta))||!n.blocks.every(_n))return!1;let t=n,o=t.blocks.flatMap(r=>r.kind==="locations"&&r.anchor!==null?[r.anchor]:[]);return new Set(o).size!==o.length?!1:[t.hero?.cta?.href,t.hero?.secondaryCta?.href,...t.blocks.flatMap(r=>{switch(r.kind){case"campaign":case"accent_band":return[r.action?.href];case"feature_stories":return r.items.map(a=>a.action.href);case"cta":return[r.link.href];default:return[]}})].every(r=>r===void 0||!r.startsWith("#")||o.includes(r.slice(1)))}function Tn(n){return S(n)&&n.every(e=>h(e)&&_(e.where)&&typeof e.text=="string")}function Cn(n){return n===null||h(n)&&bn(n.composition)&&typeof n.body=="string"&&Tn(n.proposedCopy)&&typeof n.campaign=="string"&&["shown","off","not-started","ended","none"].includes(n.campaign)}function an(n){return n===null||h(n)&&_(n.slug)&&_(n.title)&&bn(n.composition)&&typeof n.body=="string"&&typeof n.migrated=="boolean"&&Tn(n.proposedCopy)&&Kn(n.sections,n.warnings)}function An(n){return n===null||h(n)&&_(n.name)&&N(n.description)&&h(n.contact)&&N(n.contact.email)&&N(n.contact.phone)&&S(n.social)&&n.social.every(e=>h(e)&&_(e.network)&&typeof e.url=="string"&&/^https?:\/\//.test(e.url))}var X="malformed-content",I=class extends Error{code=X;documentId;problems;constructor(e,t){super(`${X}: ${e}: ${t.join("; ")}`),this.name="MalformedContentError",this.documentId=e,this.problems=t}},F=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,z=/^(?:\/(?![/\\])[^\s]*|#[a-z][a-z0-9]*(?:-[a-z0-9]+)*|mailto:[^\s@]+@[^\s@]+|tel:\+?[0-9][0-9 ()-]*|https?:\/\/[^\s/]+[^\s]*)$/,D=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,Q=["wide","tall","round","free"],O="homePage",x="siteSettings",j=class{problems=[];proposed=[];fail(e,t){return this.problems.push(`${e} ${t}`),null}object(e,t){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:this.fail(t,"is not an object")}dense(e,t){return S(e)?!0:(this.fail(t,"contains missing entries"),!1)}optionalString(e,t){return e==null?null:typeof e=="string"?e.trim()===""?null:e:this.fail(t,"is not text")}copy(e,t){if(e==null)return null;let o=this.object(e,t);if(o===null)return null;let i=o.text,r=o.copySource;return i!==void 0&&typeof i!="string"?this.fail(`${t}.text`,"is not text"):r!==void 0&&r!=="captured"&&r!=="proposed"?this.fail(`${t}.copySource`,`is ${JSON.stringify(r)}, not captured or proposed`):typeof i!="string"||i.trim()===""?null:r==="proposed"?(this.proposed.push({where:t,text:i}),{text:i,copySource:"proposed"}):r==="captured"?{text:i,copySource:"captured"}:i}requiredCopy(e,t){let o=this.copy(e,t);return o===null&&!this.problems.some(i=>i.startsWith(t))&&this.fail(t,"is missing its words"),o}photo(e,t){return e==null?null:typeof e=="string"&&F.test(e)?e:this.fail(t,`is ${JSON.stringify(e)}, not a photo library slug`)}photos(e,t,o){return e==null?[]:Array.isArray(e)?this.dense(e,t)?(e.length>o&&this.fail(t,`holds ${String(e.length)} photos; at most ${String(o)}`),e.map((i,r)=>this.photo(i,`${t}[${String(r)}]`)).filter(i=>i!==null)):[]:(this.fail(t,"is not a list of photos"),[])}action(e,t){if(e==null)return null;let o=this.object(e,t);if(o===null)return null;let i=this.requiredCopy(o.label,`${t}.label`),r=o.href;return typeof r!="string"||!z.test(r)?this.fail(`${t}.href`,`is ${JSON.stringify(r)}, not a site path, #jump-link, mailto:, tel: or web address`):i===null?null:{label:i,href:r}}requiredAction(e,t){return e==null?this.fail(t,"is missing"):this.action(e,t)}};function K(n){return typeof n=="string"?n:n.text}function En(n){let e=new j,t=cn(n,"body",e);if(e.problems.length>0)throw new I("body",e.problems);return t}function cn(n,e,t){if(n==null)return"";if(!Array.isArray(n))return t.fail(e,"is not rich text"),"";if(!t.dense(n,e))return"";let o=[],i=!1;return n.forEach((r,a)=>{let s=`${e}[${String(a)}]`,u=t.object(r,s);if(u===null)return;if(u._type!=="block"){t.fail(s,`is a ${JSON.stringify(u._type)}; only text is supported in rich text so far`);return}let l=Vn(u,s,t),c=u.listItem,d=u.style??"normal",p;if(c==="bullet"||c==="number"){let f=typeof u.level=="number"&&u.level>1?u.level:1;p=`${" ".repeat(f-1)}${c==="bullet"?"-":"1."} ${l}`}else if(d==="h2")p=`## ${l}`;else if(d==="h3")p=`### ${l}`;else if(d==="blockquote")p=`> ${l}`;else if(d==="normal")p=l;else{t.fail(`${s}.style`,`is ${JSON.stringify(d)}, which the schema does not offer`);return}let y=c==="bullet"||c==="number";o.length>0&&o.push(y&&i?`
|
|
2
2
|
`:`
|
|
3
3
|
|
|
4
|
-
`),o.push(p),i=y}),o.join("")}var Zn={strong:"**",em:"*",code:"`"};function Vn(n,e,t){let o=new Map,i=Array.isArray(n.markDefs)?n.markDefs:[];if(!t.dense(i,`${e}.markDefs`))return"";for(let a of i){let s=a;s._type==="link"&&typeof s._key=="string"&&typeof s.href=="string"&&o.set(s._key,s.href)}let r=Array.isArray(n.children)?n.children:[];return t.dense(r,`${e}.children`)?r.map((a,s)=>{let u=a;if(u._type!=="span"||typeof u.text!="string")return t.fail(`${e}.children[${String(s)}]`,"is not a text span"),"";let l=u.text,c=Array.isArray(u.marks)?u.marks:[];if(!t.dense(c,`${e}.children[${String(s)}].marks`))return"";let d=null;for(let p of c){if(typeof p!="string")continue;let y=Zn[p];y!==void 0?l=`${y}${l}${y}`:o.has(p)?d=o.get(p)??null:t.fail(`${e}.children[${String(s)}].marks`,`names ${JSON.stringify(p)}, which is neither a style nor a link`)}return d===null?l:`[${l}](${d})`}).join(""):""}function un(n,e){if(typeof n!="object"||n===null)return"none";let t=n;if(t.enabled!==!0)return"off";let o=typeof t.startsAt=="string"?Date.parse(t.startsAt):null,i=typeof t.endsAt=="string"?Date.parse(t.endsAt):null;return o!==null&&e.getTime()<o?"not-started":i!==null&&e.getTime()>=i?"ended":"shown"}function G(n,e,t){return typeof e._key=="string"?`${n}[_key=="${e._key}"]`:`${n}[${String(t)}]`}function v(n,e){let t=new j,o=t.object(n,"homePage");if(o===null)throw new
|
|
4
|
+
`),o.push(p),i=y}),o.join("")}var Zn={strong:"**",em:"*",code:"`"};function Vn(n,e,t){let o=new Map,i=Array.isArray(n.markDefs)?n.markDefs:[];if(!t.dense(i,`${e}.markDefs`))return"";for(let a of i){let s=a;s._type==="link"&&typeof s._key=="string"&&typeof s.href=="string"&&o.set(s._key,s.href)}let r=Array.isArray(n.children)?n.children:[];return t.dense(r,`${e}.children`)?r.map((a,s)=>{let u=a;if(u._type!=="span"||typeof u.text!="string")return t.fail(`${e}.children[${String(s)}]`,"is not a text span"),"";let l=u.text,c=Array.isArray(u.marks)?u.marks:[];if(!t.dense(c,`${e}.children[${String(s)}].marks`))return"";let d=null;for(let p of c){if(typeof p!="string")continue;let y=Zn[p];y!==void 0?l=`${y}${l}${y}`:o.has(p)?d=o.get(p)??null:t.fail(`${e}.children[${String(s)}].marks`,`names ${JSON.stringify(p)}, which is neither a style nor a link`)}return d===null?l:`[${l}](${d})`}).join(""):""}function un(n,e){if(typeof n!="object"||n===null)return"none";let t=n;if(t.enabled!==!0)return"off";let o=typeof t.startsAt=="string"?Date.parse(t.startsAt):null,i=typeof t.endsAt=="string"?Date.parse(t.endsAt):null;return o!==null&&e.getTime()<o?"not-started":i!==null&&e.getTime()>=i?"ended":"shown"}function G(n,e,t){return typeof e._key=="string"?`${n}[_key=="${e._key}"]`:`${n}[${String(t)}]`}function v(n,e){let t=new j,o=t.object(n,"homePage");if(o===null)throw new I(O,t.problems);let i=typeof o._id=="string"?o._id:O;o._type!=="homePage"&&t.fail("_type",`is ${JSON.stringify(o._type)}, not homePage`);let r=null,a=o.hero===void 0?t.fail("hero","is missing"):t.object(o.hero,"hero");if(a!==null){let f=t.photos(a.photos,"hero.photos",2),g=t.requiredCopy(a.headline,"hero.headline"),m=t.copy(a.subline,"hero.subline"),T=t.copy(a.lead,"hero.lead"),k=t.action(a.primaryAction,"hero.primaryAction"),Gn=t.action(a.secondaryAction,"hero.secondaryAction");g!==null&&(r={heading:g,subline:m,intro:T,image:f[0]??null,inset:f[1]??null,cta:k,secondaryCta:Gn})}let s=[],u=[],l="",c=un(o.campaign,e.now);if(c==="shown"){let f=t.object(o.campaign,"campaign");if(f!==null){let g=t.requiredCopy(f.title,"campaign.title"),m=t.photos(f.photos,"campaign.photos",3);m.length===0&&t.fail("campaign.photos","is empty; a shown campaign needs at least one photo");let T=cn(f.body,"campaign.body",t);T===""&&t.fail("campaign.body","is empty; a shown campaign needs its text"),f.bodyCopySource==="proposed"&&t.proposed.push({where:"campaign.body",text:T});let k=t.action(f.action,"campaign.action");k!==null&&u.push({where:"campaign.action.href",href:k.href}),g!==null&&(l=`# ${K(g)}
|
|
5
5
|
|
|
6
|
-
${T}`),s.push({kind:"campaign",action:I,images:m})}}let d=[],p=o.blocks??[];Array.isArray(p)?t.dense(p,"blocks")&&p.forEach((f,g)=>{let m=t.object(f,`blocks[${String(g)}]`);if(m===null)return;let T=G("blocks",m,g),I=$n(m,T,t);I!==null&&(u.push(...Rn(I,m,T)),I.kind==="locations"&&I.anchor!==null&&(d.includes(I.anchor)&&t.fail(`${T}.jumpLink`,`repeats "${I.anchor}", already used by another section`),d.push(I.anchor)),s.push(I))}):t.fail("blocks","is not a list");let y=[];r?.cta&&y.push({where:"hero.primaryAction.href",href:r.cta.href}),r?.secondaryCta&&y.push({where:"hero.secondaryAction.href",href:r.secondaryCta.href}),y.push(...u);for(let{where:f,href:g}of y)g.startsWith("#")&&!d.includes(g.slice(1))&&t.fail(f,`jumps to ${g}, which no section on the page is named`);if(t.problems.length>0)throw new b(i,t.problems);return{composition:{intro:null,photo:null,hero:r,blocks:s},body:l,campaign:c,proposedCopy:t.proposed}}function Rn(n,e,t){switch(n.kind){case"feature_stories":{let o=Array.isArray(e.stories)?e.stories:[];return n.items.map((i,r)=>({where:`${G(`${t}.stories`,o[r]??{},r)}.action.href`,href:i.action.href}))}case"accent_band":return n.action===null?[]:[{where:`${t}.action.href`,href:n.action.href}];case"cta":return[{where:`${t}.action.href`,href:n.link.href}];default:return[]}}function J(n,e,t){let o=n.jumpLink;return o==null||o===""?null:typeof o!="string"||!D.test(o)?t.fail(`${e}.jumpLink`,`is ${JSON.stringify(o)}, not lowercase words joined by hyphens`):o}function $n(n,e,t){switch(n._type){case"featureStoriesBlock":{let o=t.requiredCopy(n.heading,`${e}.heading`),i=t.copy(n.tail,`${e}.tail`),r=n.stories;if(!Array.isArray(r)||r.length===0)return t.fail(`${e}.stories`,"has no stories");if(!t.dense(r,`${e}.stories`))return null;let a=[];return r.forEach((s,u)=>{let l=t.object(s,`${e}.stories[${String(u)}]`);if(l===null)return;let c=G(`${e}.stories`,l,u),d=t.requiredCopy(l.heading,`${c}.heading`),p=t.requiredCopy(l.body,`${c}.body`),y=t.requiredAction(l.action,`${c}.action`),f=t.photo(l.photo,`${c}.photo`),g=l.layout??"wide";if(!Q.includes(g)){t.fail(`${c}.layout`,`is ${JSON.stringify(g)}, not wide, tall, round or free`);return}let m=l.onCard??!1;if(typeof m!="boolean"){t.fail(`${c}.onCard`,"is not on or off");return}d===null||p===null||y===null||a.push({heading:d,body:p,action:y,image:f,shape:g,card:m})}),o===null?null:{kind:"feature_stories",heading:o,tail:i,items:a}}case"surfaceCardBlock":{let o=t.requiredCopy(n.heading,`${e}.heading`),i=t.copy(n.body,`${e}.body`),r=t.requiredAction(n.action,`${e}.action`);return o===null||r===null?null:{kind:"cta",heading:K(o),body:i===null?null:K(i),link:{label:K(r.label),href:r.href}}}case"accentBandBlock":{let o=t.requiredCopy(n.heading,`${e}.heading`),i=t.requiredCopy(n.body,`${e}.body`),r=t.action(n.action,`${e}.action`),a=t.photo(n.photo,`${e}.photo`);return o===null||i===null?null:{kind:"accent_band",heading:o,body:i,action:r,image:a}}case"locationsBlock":{let o=J(n,e,t),i=t.requiredCopy(n.heading,`${e}.heading`),r=t.copy(n.tail,`${e}.tail`),a=t.photo(n.photo,`${e}.photo`);return i===null?null:{kind:"locations",anchor:o,heading:i,tail:r,image:a}}default:return t.fail(`${e}._type`,`is ${JSON.stringify(n._type)}, not a section type this reader knows`)}}function V(n,e,t,o,i){let r=n.layout,a=t.find(s=>s===r);return a!==void 0?a:(i.push({code:_.layoutDefaulted,where:`${e}.layout`}),o)}function ln(n,e,t,o){if(n==null)return null;let i=t.object(n,e);if(i===null)return null;let r=i.asset,a=typeof r=="object"&&r!==null?r._ref:void 0;if(typeof a!="string"||a==="")return o.push({code:_.imageMissingAsset,where:`${e}.asset`}),null;let s=i.alt;if(typeof s!="string"||s.trim()==="")return o.push({code:_.imageMissingAlt,where:`${e}.alt`}),null;let u=t.optionalString(i.caption,`${e}.caption`),l=null;if(i.hotspot!==void 0&&i.hotspot!==null){let c=t.object(i.hotspot,`${e}.hotspot`),d=c?.x,p=c?.y;typeof d=="number"&&typeof p=="number"&&d>=0&&d<=1&&p>=0&&p<=1?l={x:d,y:p}:c!==null&&t.fail(`${e}.hotspot`,"is not a point inside the image")}return{asset:a,alt:s,caption:u,hotspot:l}}function Xn(n,e,t,o){switch(n._type){case"featureStoriesBlock":case"surfaceCardBlock":case"accentBandBlock":case"locationsBlock":{let i=$n(n,e,t);return i===null||i.kind==="campaign"?null:i}case"textMediaBlock":{let i=J(n,e,t),r=t.requiredCopy(n.heading,`${e}.heading`),a=t.copy(n.tail,`${e}.tail`),s=t.requiredCopy(n.body,`${e}.body`),u=t.action(n.action,`${e}.action`),l=ln(n.photo,`${e}.photo`,t,o),c=V(n,e,A,R.Split,o);return r===null||s===null?null:{kind:"text_media",anchor:i,layout:c,heading:r,tail:a,body:s,action:u,image:l}}case"faqBlock":{let i=J(n,e,t),r=t.requiredCopy(n.heading,`${e}.heading`),a=t.copy(n.tail,`${e}.tail`),s=t.copy(n.intro,`${e}.intro`),u=V(n,e,L,R.HeadingList,o),l=n.items;if(!Array.isArray(l)||l.length===0)return t.fail(`${e}.items`,"has no questions");if(!t.dense(l,`${e}.items`))return null;let c=[];return l.forEach((d,p)=>{let y=t.object(d,`${e}.items[${String(p)}]`);if(y===null)return;let f=G(`${e}.items`,y,p);if(y._type!==void 0&&y._type!=="faqItem"){t.fail(`${f}._type`,`is ${JSON.stringify(y._type)}, not faqItem`);return}let g=t.requiredCopy(y.question,`${f}.question`),m=t.requiredCopy(y.answer,`${f}.answer`);g!==null&&m!==null&&c.push({question:g,answer:m})}),r===null?null:{kind:"faq",anchor:i,layout:u,heading:r,tail:a,intro:s,items:c}}case"galleryBlock":{let i=J(n,e,t),r=t.copy(n.heading,`${e}.heading`),a=V(n,e,H,R.StaggerRow,o),s=n.photos??[];if(!Array.isArray(s))return t.fail(`${e}.photos`,"is not a list of photos");if(!t.dense(s,`${e}.photos`))return null;if(s.length<Y||s.length>B)return t.fail(`${e}.photos`,`holds ${String(s.length)} photos; a gallery shows ${String(Y)} to ${String(B)}`);let u=s.flatMap((l,c)=>{let d=ln(l,G(`${e}.photos`,typeof l=="object"&&l!==null?l:{},c),t,o);return d===null?[]:[d]});return u.length===0?(o.push({code:_.emptySkipped,where:e}),null):{kind:"gallery",anchor:i,layout:a,heading:r,images:u}}case"contactBlock":{let i=J(n,e,t),r=t.requiredCopy(n.heading,`${e}.heading`),a=t.copy(n.body,`${e}.body`),s=y=>{let f=n[y]??!0;return typeof f=="boolean"?f:(t.fail(`${e}.${y}`,"is not on or off"),!1)},u=s("showEmail"),l=s("showPhone"),c=t.action(n.action,`${e}.action`),d=ln(n.photo,`${e}.photo`,t,o),p=V(n,e,A,R.Split,o);return r===null?null:!u&&!l&&a===null&&c===null?(o.push({code:_.emptySkipped,where:e}),null):{kind:"contact",anchor:i,layout:p,heading:r,body:a,showEmail:u,showPhone:l,action:c,image:d}}default:return o.push({code:_.unknownType,where:`${e}._type`}),null}}function vn(n,e,t){switch(n.kind){case"text_media":case"contact":return n.action===null?[]:[{where:`${t}.action.href`,href:n.action.href}];case"faq":case"gallery":return[];default:return Rn(n,e,t)}}function ne(n,e){let t=[],o=[];if(!Array.isArray(n))return e.fail("sections","is not a list"),{sections:t,warnings:o};if(!e.dense(n,"sections"))return{sections:t,warnings:o};let i=[],r=[];n.forEach((a,s)=>{let u=e.object(a,`sections[${String(s)}]`);if(u===null)return;let l=G("sections",u,s),c=Xn(u,l,e,o);if(c===null)return;r.push(...vn(c,u,l));let d="anchor"in c?c.anchor:null;d!==null&&(i.includes(d)&&e.fail(`${l}.jumpLink`,`repeats "${d}", already used by another section`),i.push(d)),t.push(c)});for(let{where:a,href:s}of r)s.startsWith("#")&&!i.includes(s.slice(1))&&e.fail(a,`jumps to ${s}, which no section on the page is named`);return{sections:t,warnings:o}}function q(n){let e=new j,t=e.object(n,"page");if(t===null)throw new b("page",e.problems);let o=typeof t._id=="string"?t._id:"page";t._type!=="page"&&e.fail("_type",`is ${JSON.stringify(t._type)}, not page`);let i=e.optionalString(t.title,"title");i===null&&e.fail("title","is missing"),t.titleCopySource==="proposed"&&i!==null&&e.proposed.push({where:"title",text:i});let r=t.slug,a=typeof r?.current=="string"&&r.current!==""?r.current:null;a===null&&e.fail("slug.current","is missing");let s=e.copy(t.lead,"lead"),u=e.photo(t.photo,"photo"),l=cn(t.body,"body",e);t.bodyCopySource==="proposed"&&e.proposed.push({where:"body",text:l});let c=t.sections===void 0||t.sections===null?null:ne(t.sections,e);if(e.problems.length>0||i===null||a===null)throw new b(o,e.problems);return{slug:a,title:i,composition:{intro:s===null?null:K(s),photo:u,hero:null,blocks:[]},body:l,migrated:t.migrated===!0,proposedCopy:e.proposed,...c===null?{}:c}}function nn(n){let e=new j,t=e.object(n,"siteSettings");if(t===null)throw new b(x,e.problems);let o=e.optionalString(t.title,"title");o===null&&e.fail("title","is missing; a site needs its name");let i=e.optionalString(t.description,"description"),r=t.contact===void 0?{}:e.object(t.contact,"contact")??{},a=e.optionalString(r.email,"contact.email"),s=e.optionalString(r.phone,"contact.phone"),u=[],l=t.social??[];if(Array.isArray(l)?e.dense(l,"social")&&l.forEach((c,d)=>{let p=e.object(c,`social[${String(d)}]`);if(p===null)return;let y=e.optionalString(p.network,`social[${String(d)}].network`),f=e.optionalString(p.url,`social[${String(d)}].url`);if(y===null||f===null||!/^https?:\/\//.test(f)){e.fail(`social[${String(d)}]`,"needs a network and a web address");return}u.push({network:y,url:f})}):e.fail("social","is not a list"),e.problems.length>0||o===null)throw new b(x,e.problems);return{name:o,description:i,contact:{email:a,phone:s},social:u}}var M="*[_id == $id][0]",en='*[_type == "page" && defined(slug.current)]|order(slug.current asc)',tn='*[_type == "page" && slug.current == $slug][0]';function On(n){return{home:async({now:e})=>{let t=await n.query(M,{params:{id:O}});return t==null?null:v(t,{now:e})},pages:async()=>{let e=await n.query(en);if(!Array.isArray(e))throw new b("page",["the page query did not return a list"]);if(!S(e))throw new b("page",["the page query contains missing entries"]);return e.map(t=>q(t))},pageBySlug:async e=>{let t=await n.query(tn,{params:{slug:e}});return t==null?null:q(t)},siteSettings:async()=>{let e=await n.query(M,{params:{id:x}});return e==null?null:nn(e)}}}function on(n,e,t,o){if(!o(e))throw new TypeError("Invalid CMS content fallback");return n==null?{data:e,fallbackFields:["$"]}:{data:t(n),fallbackFields:[]}}function xn(n){if(!(n instanceof Date)||!Number.isFinite(n.getTime()))throw new TypeError("Invalid CMS campaign date");let e=n.getTime();return E({name:"homePage.v1",query:M,params:{id:O},dependencies:{types:["homePage"],ids:[O]},resolve:(t,o)=>on(t,o,i=>v(i,{now:new Date(e)}),Cn)})}function Ln(n){if(typeof n!="string"||n==="")throw new TypeError("Invalid CMS page slug");return E({name:"page.v1",query:tn,params:{slug:n},dependencies:{types:["page"]},resolve:(e,t)=>on(e,t,q,an)})}function Hn(){return E({name:"pages.v1",query:en,params:{},dependencies:{types:["page"]},resolve:(n,e)=>on(n,e,t=>{if(!Array.isArray(t))throw new b("page",["the page query did not return a list"]);if(!S(t))throw new b("page",["the page query contains missing entries"]);return t.map(o=>q(o))},t=>S(t)&&t.every(o=>o!==null&&an(o)))})}function Nn(){return E({name:"siteSettings.v1",query:M,params:{id:x},dependencies:{types:["siteSettings"],ids:[x]},resolve:(n,e)=>on(n,e,nn,An)})}var dn=["columns","rows"],yn=40,fn="siteHero.layout.defaulted",gn="siteHero.tagline.dropped",hn="siteHero.taglines.defaulted";var U={key:"hero",documentId:"siteHero",documentType:"siteHero",fields:[{name:"heading",label:"Heading",noun:{article:"a",word:"heading"},kind:"single-line",required:!0,minLength:1,maxLength:80,noTrailingFullStop:!0},{name:"intro",label:"Introduction",noun:{article:"an",word:"introduction"},kind:"multi-line",required:!0,minLength:1,maxLength:320}],copy:{currentTitle:"On your site now",editTitle:"Edit and publish",empty:"Your site has no hero text yet. Whatever you publish below becomes its first version."}};function ee(n,e){let{article:t,word:o}=n.noun;if(e.length===0)return n.required?`Enter ${t} ${o}.`:null;let i=[...e].length;return i<n.minLength?`Make the ${o} at least ${String(n.minLength)} characters. It is ${String(i)} now.`:i>n.maxLength?`Keep the ${o} to ${String(n.maxLength)} characters or fewer. It is ${String(i)} now.`:e.includes("\u2014")?`The ${o} contains a long dash. Use a comma, a colon or a short dash instead.`:n.kind==="single-line"&&/[\r\n]/.test(e)?`The ${o} must be a single line.`:n.noTrailingFullStop===!0&&e.endsWith(".")?`${o.charAt(0).toUpperCase()}${o.slice(1)}s on your site do not end with a full stop. Remove the last full stop.`:null}function pn(n,e){let t={},o={};for(let i of n.fields){let r=Object.hasOwn(e,i.name)?e[i.name]:void 0,a=typeof r=="string"?r.trim():"",s=ee(i,a);Object.defineProperty(s===null?t:o,i.name,{value:s??a,enumerable:!0})}return Object.keys(o).length>0?{ok:!1,errors:o}:{ok:!0,value:t}}function Dn(n){if(!Array.isArray(n))return{ok:!1,error:"Enter a list of taglines."};let e=U.fields[0];if(!e)throw new TypeError("Missing siteHero heading definition");let t={...e,name:"text",noun:{article:"a",word:"tagline"},maxLength:yn},o=[],i=[],r=new Set;for(let[a,s]of n.entries()){if(!s||typeof s!="object"||Array.isArray(s)){i.push({index:a,error:"Enter a key and text for each tagline."});continue}let u=s,l=Object.hasOwn(u,"key")?u.key:void 0;if(typeof l!="string"||!/^[a-z][a-z0-9_-]{0,31}$/.test(l)){i.push({index:a,error:"Use a lowercase key of 1 to 32 letters, numbers, short dashes or underscores, starting with a letter."});continue}if(r.has(l)){i.push({index:a,error:"Use each tagline key only once."});continue}let c=pn({...U,fields:[t]},u);if(!c.ok){i.push({index:a,error:c.errors.text??"Invalid tagline."});continue}let d=c.value.text??"";if((d.match(/\p{L}/gu)?.length??0)>=2&&!/\p{Ll}/u.test(d)){i.push({index:a,error:"Use sentence case for the tagline, rather than all capitals."});continue}r.add(l),o.push({key:l,text:d})}return{ok:!0,value:o,dropped:i}}function mn(n){let e=Dn(n);if(!e.ok)return e;let t=e.dropped[0];return t?{ok:!1,error:t.error}:{ok:!0,value:e.value}}function Pn(n){return dn.some(e=>n===e)}function Sn(n,e){let t=pn(U,e),o=mn(e.taglines??[]);if(!t.ok||!o.ok||e.layout!==void 0&&!Pn(e.layout))throw new TypeError("Invalid siteHero fallback");let i={heading:t.value.heading??"",intro:t.value.intro??"",layout:e.layout??"columns",taglines:o.value};if(n===null||typeof n!="object"||Array.isArray(n))return{data:i,fallbackFields:["$"]};let r=n,a=pn(U,r),s=a.ok?[]:Object.keys(a.errors);for(let p of U.fields)if(!s.includes(p.name)){let y=a.ok?a.value[p.name]:r[p.name];typeof y=="string"&&(p.name==="heading"||p.name==="intro")&&(i[p.name]=y.trim())}let u=Object.hasOwn(r,"layout")?r.layout:void 0,l=[];Pn(u)?i.layout=u:(i.layout="columns",s.push("layout"),l.push(fn));let c=Dn(Object.hasOwn(r,"taglines")?r.taglines:void 0);if(c.ok){i.taglines=c.value;for(let{index:p}of c.dropped)s.push(`taglines[${String(p)}]`);c.dropped.length>0&&l.push(gn)}else s.push("taglines"),l.push(hn);let d=[...U.fields.map(p=>p.name),"layout","taglines"].every(p=>s.includes(p));return{data:i,fallbackFields:d?["$"]:s,...l.length>0?{warnings:l}:{}}}function jn(){return E({name:"siteHero.v1",query:'*[_id == $id && _type == "siteHero"][0]{heading,intro,layout,taglines}',params:{id:"siteHero"},dependencies:{types:["siteHero"],ids:["siteHero"]},resolve:Sn})}0&&(module.exports={CONTENT_PAGES_QUERY,CONTENT_PAGE_BY_SLUG_QUERY,HEADING_LIST_LAYOUTS,HOME_PAGE_DOCUMENT_QUERY,MALFORMED_CONTENT,MalformedContentError,READER_ACTION_HREF,READER_GALLERY_PHOTO_LIMIT,READER_GALLERY_PHOTO_MIN,READER_HOME_PAGE_ID,READER_JUMP_LINK,READER_PHOTO_SLUG,READER_SECTION_KINDS,READER_SITE_SETTINGS_ID,READER_STORY_LAYOUTS,SECTION_LAYOUT_DEFAULTS,SECTION_WARNINGS,SITE_HERO_LAYOUTS,SITE_HERO_LAYOUT_WARNING,SITE_HERO_TAGLINES_DEFAULTED_WARNING,SITE_HERO_TAGLINE_DROPPED_WARNING,SITE_HERO_TAGLINE_MAX_LENGTH,SPLIT_LAYOUTS,STAGGER_ROW_LAYOUTS,campaignState,contentPageQuery,contentPagesQuery,createSiteContentReader,homeContentQuery,parseContentPage,parseHomePage,parseSiteHero,parseSiteSettings,portableTextToMarkdown,siteHeroQuery,siteSettingsQuery,validateSiteHeroTaglines});
|
|
6
|
+
${T}`),s.push({kind:"campaign",action:k,images:m})}}let d=[],p=o.blocks??[];Array.isArray(p)?t.dense(p,"blocks")&&p.forEach((f,g)=>{let m=t.object(f,`blocks[${String(g)}]`);if(m===null)return;let T=G("blocks",m,g),k=$n(m,T,t);k!==null&&(u.push(...Rn(k,m,T)),k.kind==="locations"&&k.anchor!==null&&(d.includes(k.anchor)&&t.fail(`${T}.jumpLink`,`repeats "${k.anchor}", already used by another section`),d.push(k.anchor)),s.push(k))}):t.fail("blocks","is not a list");let y=[];r?.cta&&y.push({where:"hero.primaryAction.href",href:r.cta.href}),r?.secondaryCta&&y.push({where:"hero.secondaryAction.href",href:r.secondaryCta.href}),y.push(...u);for(let{where:f,href:g}of y)g.startsWith("#")&&!d.includes(g.slice(1))&&t.fail(f,`jumps to ${g}, which no section on the page is named`);if(t.problems.length>0)throw new I(i,t.problems);return{composition:{intro:null,photo:null,hero:r,blocks:s},body:l,campaign:c,proposedCopy:t.proposed}}function Rn(n,e,t){switch(n.kind){case"feature_stories":{let o=Array.isArray(e.stories)?e.stories:[];return n.items.map((i,r)=>({where:`${G(`${t}.stories`,o[r]??{},r)}.action.href`,href:i.action.href}))}case"accent_band":return n.action===null?[]:[{where:`${t}.action.href`,href:n.action.href}];case"cta":return[{where:`${t}.action.href`,href:n.link.href}];default:return[]}}function J(n,e,t){let o=n.jumpLink;return o==null||o===""?null:typeof o!="string"||!D.test(o)?t.fail(`${e}.jumpLink`,`is ${JSON.stringify(o)}, not lowercase words joined by hyphens`):o}function $n(n,e,t){switch(n._type){case"featureStoriesBlock":{let o=t.requiredCopy(n.heading,`${e}.heading`),i=t.copy(n.tail,`${e}.tail`),r=n.stories;if(!Array.isArray(r)||r.length===0)return t.fail(`${e}.stories`,"has no stories");if(!t.dense(r,`${e}.stories`))return null;let a=[];return r.forEach((s,u)=>{let l=t.object(s,`${e}.stories[${String(u)}]`);if(l===null)return;let c=G(`${e}.stories`,l,u),d=t.requiredCopy(l.heading,`${c}.heading`),p=t.requiredCopy(l.body,`${c}.body`),y=t.requiredAction(l.action,`${c}.action`),f=t.photo(l.photo,`${c}.photo`),g=l.layout??"wide";if(!Q.includes(g)){t.fail(`${c}.layout`,`is ${JSON.stringify(g)}, not wide, tall, round or free`);return}let m=l.onCard??!1;if(typeof m!="boolean"){t.fail(`${c}.onCard`,"is not on or off");return}d===null||p===null||y===null||a.push({heading:d,body:p,action:y,image:f,shape:g,card:m})}),o===null?null:{kind:"feature_stories",heading:o,tail:i,items:a}}case"surfaceCardBlock":{let o=t.requiredCopy(n.heading,`${e}.heading`),i=t.copy(n.body,`${e}.body`),r=t.requiredAction(n.action,`${e}.action`);return o===null||r===null?null:{kind:"cta",heading:K(o),body:i===null?null:K(i),link:{label:K(r.label),href:r.href}}}case"accentBandBlock":{let o=t.requiredCopy(n.heading,`${e}.heading`),i=t.requiredCopy(n.body,`${e}.body`),r=t.action(n.action,`${e}.action`),a=t.photo(n.photo,`${e}.photo`);return o===null||i===null?null:{kind:"accent_band",heading:o,body:i,action:r,image:a}}case"locationsBlock":{let o=J(n,e,t),i=t.requiredCopy(n.heading,`${e}.heading`),r=t.copy(n.tail,`${e}.tail`),a=t.photo(n.photo,`${e}.photo`);return i===null?null:{kind:"locations",anchor:o,heading:i,tail:r,image:a}}default:return t.fail(`${e}._type`,`is ${JSON.stringify(n._type)}, not a section type this reader knows`)}}function V(n,e,t,o,i){let r=n.layout,a=t.find(s=>s===r);return a!==void 0?a:(i.push({code:b.layoutDefaulted,where:`${e}.layout`}),o)}function ln(n,e,t,o){if(n==null)return null;let i=t.object(n,e);if(i===null)return null;let r=i.asset,a=typeof r=="object"&&r!==null?r._ref:void 0;if(typeof a!="string"||a==="")return o.push({code:b.imageMissingAsset,where:`${e}.asset`}),null;let s=i.alt;if(typeof s!="string"||s.trim()==="")return o.push({code:b.imageMissingAlt,where:`${e}.alt`}),null;let u=t.optionalString(i.caption,`${e}.caption`),l=null;if(i.hotspot!==void 0&&i.hotspot!==null){let c=t.object(i.hotspot,`${e}.hotspot`),d=c?.x,p=c?.y;typeof d=="number"&&typeof p=="number"&&d>=0&&d<=1&&p>=0&&p<=1?l={x:d,y:p}:c!==null&&t.fail(`${e}.hotspot`,"is not a point inside the image")}return{asset:a,alt:s,caption:u,hotspot:l}}function Xn(n){return typeof n=="string"?n.slice(0,64).replace(/[^A-Za-z0-9_.-]/g,"?"):"?"}function vn(n,e,t,o){switch(n._type){case"featureStoriesBlock":case"surfaceCardBlock":case"accentBandBlock":case"locationsBlock":{let i=$n(n,e,t);return i===null||i.kind==="campaign"?null:i}case"textMediaBlock":{let i=J(n,e,t),r=t.requiredCopy(n.heading,`${e}.heading`),a=t.copy(n.tail,`${e}.tail`),s=t.requiredCopy(n.body,`${e}.body`),u=t.action(n.action,`${e}.action`),l=ln(n.photo,`${e}.photo`,t,o),c=V(n,e,A,R.Split,o);return r===null||s===null?null:{kind:"text_media",anchor:i,layout:c,heading:r,tail:a,body:s,action:u,image:l}}case"faqBlock":{let i=J(n,e,t),r=t.requiredCopy(n.heading,`${e}.heading`),a=t.copy(n.tail,`${e}.tail`),s=t.copy(n.intro,`${e}.intro`),u=V(n,e,L,R.HeadingList,o),l=n.items;if(!Array.isArray(l)||l.length===0)return t.fail(`${e}.items`,"has no questions");if(!t.dense(l,`${e}.items`))return null;let c=[];return l.forEach((d,p)=>{let y=t.object(d,`${e}.items[${String(p)}]`);if(y===null)return;let f=G(`${e}.items`,y,p);if(y._type!==void 0&&y._type!=="faqItem"){t.fail(`${f}._type`,`is ${JSON.stringify(y._type)}, not faqItem`);return}let g=t.requiredCopy(y.question,`${f}.question`),m=t.requiredCopy(y.answer,`${f}.answer`);g!==null&&m!==null&&c.push({question:g,answer:m})}),r===null?null:{kind:"faq",anchor:i,layout:u,heading:r,tail:a,intro:s,items:c}}case"galleryBlock":{let i=J(n,e,t),r=t.copy(n.heading,`${e}.heading`),a=V(n,e,H,R.StaggerRow,o),s=n.photos??[];if(!Array.isArray(s))return t.fail(`${e}.photos`,"is not a list of photos");if(!t.dense(s,`${e}.photos`))return null;if(s.length<Y||s.length>B)return t.fail(`${e}.photos`,`holds ${String(s.length)} photos; a gallery shows ${String(Y)} to ${String(B)}`);let u=s.flatMap((l,c)=>{let d=ln(l,G(`${e}.photos`,typeof l=="object"&&l!==null?l:{},c),t,o);return d===null?[]:[d]});return u.length===0?(o.push({code:b.emptySkipped,where:e}),null):{kind:"gallery",anchor:i,layout:a,heading:r,images:u}}case"contactBlock":{let i=J(n,e,t),r=t.requiredCopy(n.heading,`${e}.heading`),a=t.copy(n.body,`${e}.body`),s=y=>{let f=n[y]??!0;return typeof f=="boolean"?f:(t.fail(`${e}.${y}`,"is not on or off"),!1)},u=s("showEmail"),l=s("showPhone"),c=t.action(n.action,`${e}.action`),d=ln(n.photo,`${e}.photo`,t,o),p=V(n,e,A,R.Split,o);return r===null?null:!u&&!l&&a===null&&c===null?(o.push({code:b.emptySkipped,where:e}),null):{kind:"contact",anchor:i,layout:p,heading:r,body:a,showEmail:u,showPhone:l,action:c,image:d}}default:return o.push({code:b.unknownType,where:`${e}._type`,type:Xn(n._type)}),null}}function ne(n,e,t){switch(n.kind){case"text_media":case"contact":return n.action===null?[]:[{where:`${t}.action.href`,href:n.action.href}];case"faq":case"gallery":return[];default:return Rn(n,e,t)}}function ee(n,e){let t=[],o=[];if(!Array.isArray(n))return e.fail("sections","is not a list"),{sections:t,warnings:o};if(!e.dense(n,"sections"))return{sections:t,warnings:o};let i=[],r=[];n.forEach((a,s)=>{let u=e.object(a,`sections[${String(s)}]`);if(u===null)return;let l=G("sections",u,s),c=vn(u,l,e,o);if(c===null)return;r.push(...ne(c,u,l));let d="anchor"in c?c.anchor:null;d!==null&&(i.includes(d)&&e.fail(`${l}.jumpLink`,`repeats "${d}", already used by another section`),i.push(d)),t.push(c)});for(let{where:a,href:s}of r)s.startsWith("#")&&!i.includes(s.slice(1))&&e.fail(a,`jumps to ${s}, which no section on the page is named`);return{sections:t,warnings:o}}function q(n){let e=new j,t=e.object(n,"page");if(t===null)throw new I("page",e.problems);let o=typeof t._id=="string"?t._id:"page";t._type!=="page"&&e.fail("_type",`is ${JSON.stringify(t._type)}, not page`);let i=e.optionalString(t.title,"title");i===null&&e.fail("title","is missing"),t.titleCopySource==="proposed"&&i!==null&&e.proposed.push({where:"title",text:i});let r=t.slug,a=typeof r?.current=="string"&&r.current!==""?r.current:null;a===null&&e.fail("slug.current","is missing");let s=e.copy(t.lead,"lead"),u=e.photo(t.photo,"photo"),l=cn(t.body,"body",e);t.bodyCopySource==="proposed"&&e.proposed.push({where:"body",text:l});let c=t.sections===void 0||t.sections===null?null:ee(t.sections,e);if(e.problems.length>0||i===null||a===null)throw new I(o,e.problems);return{slug:a,title:i,composition:{intro:s===null?null:K(s),photo:u,hero:null,blocks:[]},body:l,migrated:t.migrated===!0,proposedCopy:e.proposed,...c===null?{}:c}}function nn(n){let e=new j,t=e.object(n,"siteSettings");if(t===null)throw new I(x,e.problems);let o=e.optionalString(t.title,"title");o===null&&e.fail("title","is missing; a site needs its name");let i=e.optionalString(t.description,"description"),r=t.contact===void 0?{}:e.object(t.contact,"contact")??{},a=e.optionalString(r.email,"contact.email"),s=e.optionalString(r.phone,"contact.phone"),u=[],l=t.social??[];if(Array.isArray(l)?e.dense(l,"social")&&l.forEach((c,d)=>{let p=e.object(c,`social[${String(d)}]`);if(p===null)return;let y=e.optionalString(p.network,`social[${String(d)}].network`),f=e.optionalString(p.url,`social[${String(d)}].url`);if(y===null||f===null||!/^https?:\/\//.test(f)){e.fail(`social[${String(d)}]`,"needs a network and a web address");return}u.push({network:y,url:f})}):e.fail("social","is not a list"),e.problems.length>0||o===null)throw new I(x,e.problems);return{name:o,description:i,contact:{email:a,phone:s},social:u}}var M="*[_id == $id][0]",en='*[_type == "page" && defined(slug.current)]|order(slug.current asc)',tn='*[_type == "page" && slug.current == $slug][0]';function On(n){return{home:async({now:e})=>{let t=await n.query(M,{params:{id:O}});return t==null?null:v(t,{now:e})},pages:async()=>{let e=await n.query(en);if(!Array.isArray(e))throw new I("page",["the page query did not return a list"]);if(!S(e))throw new I("page",["the page query contains missing entries"]);return e.map(t=>q(t))},pageBySlug:async e=>{let t=await n.query(tn,{params:{slug:e}});return t==null?null:q(t)},siteSettings:async()=>{let e=await n.query(M,{params:{id:x}});return e==null?null:nn(e)}}}function on(n,e,t,o){if(!o(e))throw new TypeError("Invalid CMS content fallback");return n==null?{data:e,fallbackFields:["$"]}:{data:t(n),fallbackFields:[]}}function xn(n){if(!(n instanceof Date)||!Number.isFinite(n.getTime()))throw new TypeError("Invalid CMS campaign date");let e=n.getTime();return E({name:"homePage.v1",query:M,params:{id:O},dependencies:{types:["homePage"],ids:[O]},resolve:(t,o)=>on(t,o,i=>v(i,{now:new Date(e)}),Cn)})}function Ln(n){if(typeof n!="string"||n==="")throw new TypeError("Invalid CMS page slug");return E({name:"page.v1",query:tn,params:{slug:n},dependencies:{types:["page"]},resolve:(e,t)=>on(e,t,q,an)})}function Hn(){return E({name:"pages.v1",query:en,params:{},dependencies:{types:["page"]},resolve:(n,e)=>on(n,e,t=>{if(!Array.isArray(t))throw new I("page",["the page query did not return a list"]);if(!S(t))throw new I("page",["the page query contains missing entries"]);return t.map(o=>q(o))},t=>S(t)&&t.every(o=>o!==null&&an(o)))})}function Nn(){return E({name:"siteSettings.v1",query:M,params:{id:x},dependencies:{types:["siteSettings"],ids:[x]},resolve:(n,e)=>on(n,e,nn,An)})}var dn=["columns","rows"],yn=40,fn="siteHero.layout.defaulted",gn="siteHero.tagline.dropped",hn="siteHero.taglines.defaulted";var U={key:"hero",documentId:"siteHero",documentType:"siteHero",fields:[{name:"heading",label:"Heading",noun:{article:"a",word:"heading"},kind:"single-line",required:!0,minLength:1,maxLength:80,noTrailingFullStop:!0},{name:"intro",label:"Introduction",noun:{article:"an",word:"introduction"},kind:"multi-line",required:!0,minLength:1,maxLength:320}],copy:{currentTitle:"On your site now",editTitle:"Edit and publish",empty:"Your site has no hero text yet. Whatever you publish below becomes its first version."}};function te(n,e){let{article:t,word:o}=n.noun;if(e.length===0)return n.required?`Enter ${t} ${o}.`:null;let i=[...e].length;return i<n.minLength?`Make the ${o} at least ${String(n.minLength)} characters. It is ${String(i)} now.`:i>n.maxLength?`Keep the ${o} to ${String(n.maxLength)} characters or fewer. It is ${String(i)} now.`:e.includes("\u2014")?`The ${o} contains a long dash. Use a comma, a colon or a short dash instead.`:n.kind==="single-line"&&/[\r\n]/.test(e)?`The ${o} must be a single line.`:n.noTrailingFullStop===!0&&e.endsWith(".")?`${o.charAt(0).toUpperCase()}${o.slice(1)}s on your site do not end with a full stop. Remove the last full stop.`:null}function pn(n,e){let t={},o={};for(let i of n.fields){let r=Object.hasOwn(e,i.name)?e[i.name]:void 0,a=typeof r=="string"?r.trim():"",s=te(i,a);Object.defineProperty(s===null?t:o,i.name,{value:s??a,enumerable:!0})}return Object.keys(o).length>0?{ok:!1,errors:o}:{ok:!0,value:t}}function Dn(n){if(!Array.isArray(n))return{ok:!1,error:"Enter a list of taglines."};let e=U.fields[0];if(!e)throw new TypeError("Missing siteHero heading definition");let t={...e,name:"text",noun:{article:"a",word:"tagline"},maxLength:yn},o=[],i=[],r=new Set;for(let[a,s]of n.entries()){if(!s||typeof s!="object"||Array.isArray(s)){i.push({index:a,error:"Enter a key and text for each tagline."});continue}let u=s,l=Object.hasOwn(u,"key")?u.key:void 0;if(typeof l!="string"||!/^[a-z][a-z0-9_-]{0,31}$/.test(l)){i.push({index:a,error:"Use a lowercase key of 1 to 32 letters, numbers, short dashes or underscores, starting with a letter."});continue}if(r.has(l)){i.push({index:a,error:"Use each tagline key only once."});continue}let c=pn({...U,fields:[t]},u);if(!c.ok){i.push({index:a,error:c.errors.text??"Invalid tagline."});continue}let d=c.value.text??"";if((d.match(/\p{L}/gu)?.length??0)>=2&&!/\p{Ll}/u.test(d)){i.push({index:a,error:"Use sentence case for the tagline, rather than all capitals."});continue}r.add(l),o.push({key:l,text:d})}return{ok:!0,value:o,dropped:i}}function mn(n){let e=Dn(n);if(!e.ok)return e;let t=e.dropped[0];return t?{ok:!1,error:t.error}:{ok:!0,value:e.value}}function Pn(n){return dn.some(e=>n===e)}function Sn(n,e){let t=pn(U,e),o=mn(e.taglines??[]);if(!t.ok||!o.ok||e.layout!==void 0&&!Pn(e.layout))throw new TypeError("Invalid siteHero fallback");let i={heading:t.value.heading??"",intro:t.value.intro??"",layout:e.layout??"columns",taglines:o.value};if(n===null||typeof n!="object"||Array.isArray(n))return{data:i,fallbackFields:["$"]};let r=n,a=pn(U,r),s=a.ok?[]:Object.keys(a.errors);for(let p of U.fields)if(!s.includes(p.name)){let y=a.ok?a.value[p.name]:r[p.name];typeof y=="string"&&(p.name==="heading"||p.name==="intro")&&(i[p.name]=y.trim())}let u=Object.hasOwn(r,"layout")?r.layout:void 0,l=[];Pn(u)?i.layout=u:(i.layout="columns",s.push("layout"),l.push(fn));let c=Dn(Object.hasOwn(r,"taglines")?r.taglines:void 0);if(c.ok){i.taglines=c.value;for(let{index:p}of c.dropped)s.push(`taglines[${String(p)}]`);c.dropped.length>0&&l.push(gn)}else s.push("taglines"),l.push(hn);let d=[...U.fields.map(p=>p.name),"layout","taglines"].every(p=>s.includes(p));return{data:i,fallbackFields:d?["$"]:s,...l.length>0?{warnings:l}:{}}}function jn(){return E({name:"siteHero.v1",query:'*[_id == $id && _type == "siteHero"][0]{heading,intro,layout,taglines}',params:{id:"siteHero"},dependencies:{types:["siteHero"],ids:["siteHero"]},resolve:Sn})}0&&(module.exports={CONTENT_PAGES_QUERY,CONTENT_PAGE_BY_SLUG_QUERY,HEADING_LIST_LAYOUTS,HOME_PAGE_DOCUMENT_QUERY,MALFORMED_CONTENT,MalformedContentError,READER_ACTION_HREF,READER_GALLERY_PHOTO_LIMIT,READER_GALLERY_PHOTO_MIN,READER_HOME_PAGE_ID,READER_JUMP_LINK,READER_PHOTO_SLUG,READER_SECTION_KINDS,READER_SITE_SETTINGS_ID,READER_STORY_LAYOUTS,SECTION_LAYOUT_DEFAULTS,SECTION_WARNINGS,SITE_HERO_LAYOUTS,SITE_HERO_LAYOUT_WARNING,SITE_HERO_TAGLINES_DEFAULTED_WARNING,SITE_HERO_TAGLINE_DROPPED_WARNING,SITE_HERO_TAGLINE_MAX_LENGTH,SPLIT_LAYOUTS,STAGGER_ROW_LAYOUTS,campaignState,contentPageQuery,contentPagesQuery,createSiteContentReader,homeContentQuery,parseContentPage,parseHomePage,parseSiteHero,parseSiteSettings,portableTextToMarkdown,siteHeroQuery,siteSettingsQuery,validateSiteHeroTaglines});
|
|
7
7
|
//# sourceMappingURL=site-content.cjs.map
|