@weatherboard/cms 0.1.0 → 0.3.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 +122 -0
- package/dist/contracts/query.d.cts +1 -0
- package/dist/contracts/query.d.mts +1 -0
- package/dist/contracts/query.d.ts +1 -0
- package/dist/contracts/text.d.cts +26 -1
- package/dist/contracts/text.d.mts +26 -1
- package/dist/contracts/text.d.ts +26 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +3 -3
- package/dist/next.cjs +1 -1
- package/dist/next.cjs.map +3 -3
- package/dist/next.mjs +1 -1
- package/dist/next.mjs.map +3 -3
- package/dist/portable/sections.d.cts +136 -0
- package/dist/portable/sections.d.mts +136 -0
- package/dist/portable/sections.d.ts +136 -0
- package/dist/portable/site-content.d.cts +13 -0
- package/dist/portable/site-content.d.mts +13 -0
- package/dist/portable/site-content.d.ts +13 -0
- package/dist/runtime/reader.d.cts +3 -1
- package/dist/runtime/reader.d.mts +3 -1
- package/dist/runtime/reader.d.ts +3 -1
- package/dist/sanity.cjs +1 -1
- package/dist/sanity.cjs.map +2 -2
- package/dist/sanity.mjs +1 -1
- package/dist/sanity.mjs.map +2 -2
- package/dist/server.cjs +1 -1
- package/dist/server.cjs.map +3 -3
- package/dist/server.mjs +1 -1
- package/dist/server.mjs.map +3 -3
- package/dist/site-content.cjs +3 -3
- package/dist/site-content.cjs.map +4 -4
- package/dist/site-content.d.cts +4 -0
- package/dist/site-content.d.mts +4 -0
- package/dist/site-content.d.ts +4 -0
- package/dist/site-content.mjs +3 -3
- package/dist/site-content.mjs.map +4 -4
- package/package.json +34 -5
package/dist/site-content.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var F=Object.defineProperty;var cn=Object.getOwnPropertyDescriptor;var un=Object.getOwnPropertyNames;var dn=Object.prototype.hasOwnProperty;var yn=(e,n)=>{for(var t in n)F(e,t,{get:n[t],enumerable:!0})},fn=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of un(n))!dn.call(e,r)&&r!==t&&F(e,r,{get:()=>n[r],enumerable:!(o=cn(n,r))||o.enumerable});return e};var gn=e=>fn(F({},"__esModule",{value:!0}),e);var $n={};yn($n,{CONTENT_PAGES_QUERY:()=>U,CONTENT_PAGE_BY_SLUG_QUERY:()=>J,HOME_PAGE_DOCUMENT_QUERY:()=>T,MALFORMED_CONTENT:()=>z,MalformedContentError:()=>h,READER_ACTION_HREF:()=>D,READER_HOME_PAGE_ID:()=>_,READER_JUMP_LINK:()=>j,READER_PHOTO_SLUG:()=>P,READER_SITE_SETTINGS_ID:()=>E,READER_STORY_LAYOUTS:()=>N,campaignState:()=>Z,contentPageQuery:()=>sn,contentPagesQuery:()=>an,createSiteContentReader:()=>on,homeContentQuery:()=>rn,parseContentPage:()=>I,parseHomePage:()=>Q,parseSiteSettings:()=>B,portableTextToMarkdown:()=>tn,siteSettingsQuery:()=>ln});module.exports=gn($n);function b(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 hn=/^[A-Za-z][A-Za-z0-9_]{0,63}$/,mn=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;function wn(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"||!hn.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"||!mn.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 O(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 i=r.value;if(!(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"&&Number.isFinite(i)))throw new TypeError("CMS params must be plain JSON scalars");Object.defineProperty(t,o,{value:i,enumerable:!0})}return Object.freeze({name:e.name,query:e.query,params:Object.freeze(t),dependencies:wn(e.dependencies),resolve:e.resolve})}var w=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),$=e=>typeof e=="string"&&e.trim()!=="",x=e=>e===null||typeof e=="string",A=e=>e===null||typeof e=="string"&&P.test(e),W=e=>typeof e=="string"&&D.test(e),k=e=>$(e)||w(e)&&$(e.text)&&(e.copySource==="captured"||e.copySource==="proposed"),H=e=>e===null||k(e),V=e=>w(e)&&k(e.label)&&W(e.href),q=e=>e===null||V(e);function X(e){if(!w(e)||!x(e.intro)||!A(e.photo)||!b(e.blocks))return!1;let n=e.hero;if(n!==null&&(!w(n)||!k(n.heading)||!H(n.subline)||!H(n.intro)||!A(n.image)||!A(n.inset)||!q(n.cta)||!q(n.secondaryCta))||!e.blocks.every(s=>{if(!w(s))return!1;switch(s.kind){case"campaign":return q(s.action)&&b(s.images)&&s.images.every(a=>typeof a=="string"&&A(a));case"locations":return(s.anchor===null||typeof s.anchor=="string"&&j.test(s.anchor))&&k(s.heading)&&H(s.tail)&&A(s.image);case"feature_stories":return k(s.heading)&&H(s.tail)&&b(s.items)&&s.items.length>0&&s.items.every(a=>w(a)&&k(a.heading)&&k(a.body)&&V(a.action)&&A(a.image)&&N.some(l=>l===a.shape)&&typeof a.card=="boolean");case"accent_band":return k(s.heading)&&k(s.body)&&q(s.action)&&A(s.image);case"cta":return $(s.heading)&&x(s.body)&&w(s.link)&&$(s.link.label)&&W(s.link.href);default:return!1}}))return!1;let o=e,r=o.blocks.flatMap(s=>s.kind==="locations"&&s.anchor!==null?[s.anchor]:[]);return new Set(r).size!==r.length?!1:[o.hero?.cta?.href,o.hero?.secondaryCta?.href,...o.blocks.flatMap(s=>{switch(s.kind){case"campaign":case"accent_band":return[s.action?.href];case"feature_stories":return s.items.map(a=>a.action.href);case"cta":return[s.link.href];default:return[]}})].every(s=>s===void 0||!s.startsWith("#")||r.includes(s.slice(1)))}function v(e){return b(e)&&e.every(n=>w(n)&&$(n.where)&&typeof n.text=="string")}function nn(e){return e===null||w(e)&&X(e.composition)&&typeof e.body=="string"&&v(e.proposedCopy)&&typeof e.campaign=="string"&&["shown","off","not-started","ended","none"].includes(e.campaign)}function G(e){return e===null||w(e)&&$(e.slug)&&$(e.title)&&X(e.composition)&&typeof e.body=="string"&&typeof e.migrated=="boolean"&&v(e.proposedCopy)}function en(e){return e===null||w(e)&&$(e.name)&&x(e.description)&&w(e.contact)&&x(e.contact.email)&&x(e.contact.phone)&&b(e.social)&&e.social.every(n=>w(n)&&$(n.network)&&typeof n.url=="string"&&/^https?:\/\//.test(n.url))}var z="malformed-content",h=class extends Error{code=z;documentId;problems;constructor(n,t){super(`${z}: ${n}: ${t.join("; ")}`),this.name="MalformedContentError",this.documentId=n,this.problems=t}},P=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,D=/^(?:\/(?![/\\])[^\s]*|#[a-z][a-z0-9]*(?:-[a-z0-9]+)*|mailto:[^\s@]+@[^\s@]+|tel:\+?[0-9][0-9 ()-]*|https?:\/\/[^\s/]+[^\s]*)$/,j=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,N=["wide","tall","round","free"],_="homePage",E="siteSettings",R=class{problems=[];proposed=[];fail(n,t){return this.problems.push(`${n} ${t}`),null}object(n,t){return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:this.fail(t,"is not an object")}dense(n,t){return b(n)?!0:(this.fail(t,"contains missing entries"),!1)}optionalString(n,t){return n==null?null:typeof n=="string"?n.trim()===""?null:n:this.fail(t,"is not text")}copy(n,t){if(n==null)return null;let o=this.object(n,t);if(o===null)return null;let r=o.text,i=o.copySource;return r!==void 0&&typeof r!="string"?this.fail(`${t}.text`,"is not text"):i!==void 0&&i!=="captured"&&i!=="proposed"?this.fail(`${t}.copySource`,`is ${JSON.stringify(i)}, not captured or proposed`):typeof r!="string"||r.trim()===""?null:i==="proposed"?(this.proposed.push({where:t,text:r}),{text:r,copySource:"proposed"}):i==="captured"?{text:r,copySource:"captured"}:r}requiredCopy(n,t){let o=this.copy(n,t);return o===null&&!this.problems.some(r=>r.startsWith(t))&&this.fail(t,"is missing its words"),o}photo(n,t){return n==null?null:typeof n=="string"&&P.test(n)?n:this.fail(t,`is ${JSON.stringify(n)}, not a photo library slug`)}photos(n,t,o){return n==null?[]:Array.isArray(n)?this.dense(n,t)?(n.length>o&&this.fail(t,`holds ${String(n.length)} photos; at most ${String(o)}`),n.map((r,i)=>this.photo(r,`${t}[${String(i)}]`)).filter(r=>r!==null)):[]:(this.fail(t,"is not a list of photos"),[])}action(n,t){if(n==null)return null;let o=this.object(n,t);if(o===null)return null;let r=this.requiredCopy(o.label,`${t}.label`),i=o.href;return typeof i!="string"||!D.test(i)?this.fail(`${t}.href`,`is ${JSON.stringify(i)}, not a site path, #jump-link, mailto:, tel: or web address`):r===null?null:{label:r,href:i}}requiredAction(n,t){return n==null?this.fail(t,"is missing"):this.action(n,t)}};function M(e){return typeof e=="string"?e:e.text}function tn(e){let n=new R,t=Y(e,"body",n);if(n.problems.length>0)throw new h("body",n.problems);return t}function Y(e,n,t){if(e==null)return"";if(!Array.isArray(e))return t.fail(n,"is not rich text"),"";if(!t.dense(e,n))return"";let o=[],r=!1;return e.forEach((i,s)=>{let a=`${n}[${String(s)}]`,l=t.object(i,a);if(l===null)return;if(l._type!=="block"){t.fail(a,`is a ${JSON.stringify(l._type)}; only text is supported in rich text so far`);return}let p=bn(l,a,t),y=l.listItem,u=l.style??"normal",c;if(y==="bullet"||y==="number"){let d=typeof l.level=="number"&&l.level>1?l.level:1;c=`${" ".repeat(d-1)}${y==="bullet"?"-":"1."} ${p}`}else if(u==="h2")c=`## ${p}`;else if(u==="h3")c=`### ${p}`;else if(u==="blockquote")c=`> ${p}`;else if(u==="normal")c=p;else{t.fail(`${a}.style`,`is ${JSON.stringify(u)}, which the schema does not offer`);return}let f=y==="bullet"||y==="number";o.length>0&&o.push(f&&r?`
|
|
1
|
+
"use strict";var sn=Object.defineProperty;var Dn=Object.getOwnPropertyDescriptor;var jn=Object.getOwnPropertyNames;var qn=Object.prototype.hasOwnProperty;var Mn=(n,e)=>{for(var t in e)sn(n,t,{get:e[t],enumerable:!0})},Gn=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of jn(e))!qn.call(n,i)&&i!==t&&sn(n,i,{get:()=>e[i],enumerable:!(o=Dn(e,i))||o.enumerable});return n};var Un=n=>Gn(sn({},"__esModule",{value:!0}),n);var vn={};Mn(vn,{CONTENT_PAGES_QUERY:()=>en,CONTENT_PAGE_BY_SLUG_QUERY:()=>tn,HEADING_LIST_LAYOUTS:()=>L,HOME_PAGE_DOCUMENT_QUERY:()=>G,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:()=>mn,READER_SITE_SETTINGS_ID:()=>x,READER_STORY_LAYOUTS:()=>Q,SECTION_LAYOUT_DEFAULTS:()=>R,SECTION_WARNINGS:()=>_,SITE_HERO_LAYOUTS:()=>yn,SITE_HERO_LAYOUT_WARNING:()=>gn,SITE_HERO_TAGLINE_MAX_LENGTH:()=>fn,SPLIT_LAYOUTS:()=>A,STAGGER_ROW_LAYOUTS:()=>H,campaignState:()=>pn,contentPageQuery:()=>On,contentPagesQuery:()=>xn,createSiteContentReader:()=>Rn,homeContentQuery:()=>$n,parseContentPage:()=>M,parseHomePage:()=>v,parseSiteHero:()=>hn,parseSiteSettings:()=>nn,portableTextToMarkdown:()=>Tn,siteHeroQuery:()=>Nn,siteSettingsQuery:()=>Ln,validateSiteHeroTaglines:()=>rn});module.exports=Un(vn);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 Yn=/^[A-Za-z][A-Za-z0-9_]{0,63}$/,Bn=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;function Wn(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"||!Yn.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"||!Bn.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:Wn(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"},mn={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),I=n=>typeof n=="string"&&n.trim()!=="",N=n=>n===null||typeof n=="string",$=n=>n===null||typeof n=="string"&&F.test(n),Sn=n=>typeof n=="string"&&z.test(n),w=n=>I(n)||h(n)&&I(n.text)&&(n.copySource==="captured"||n.copySource==="proposed"),T=n=>n===null||w(n),wn=n=>h(n)&&w(n.label)&&Sn(n.href),P=n=>n===null||wn(n),Z=n=>n===null||typeof n=="string"&&D.test(n),W=(n,e)=>n.some(t=>t===e),an=n=>h(n)&&I(n.asset)&&I(n.alt)&&N(n.caption)&&(n.hotspot===null||h(n.hotspot)&&typeof n.hotspot.x=="number"&&typeof n.hotspot.y=="number");function bn(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)&&T(n.tail)&&$(n.image);case"feature_stories":return w(n.heading)&&T(n.tail)&&S(n.items)&&n.items.length>0&&n.items.every(e=>h(e)&&w(e.heading)&&w(e.body)&&wn(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 I(n.heading)&&N(n.body)&&h(n.link)&&I(n.link.label)&&Sn(n.link.href);default:return!1}}function Fn(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)&&T(n.tail)&&w(n.body)&&P(n.action)&&(n.image===null||an(n.image));case"faq":return Z(n.anchor)&&W(L,n.layout)&&w(n.heading)&&T(n.tail)&&T(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)&&T(n.heading)&&S(n.images)&&n.images.length>0&&n.images.every(an);case"contact":return Z(n.anchor)&&W(A,n.layout)&&w(n.heading)&&T(n.body)&&typeof n.showEmail=="boolean"&&typeof n.showPhone=="boolean"&&P(n.action)&&(n.image===null||an(n.image));default:return bn(n)}}function zn(n,e){if(n===void 0)return e===void 0;if(!S(n)||!n.every(Fn)||!S(e)||!e.every(r=>h(r)&&W(Object.values(_),r.code)&&I(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 kn(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)||!T(e.subline)||!T(e.intro)||!$(e.image)||!$(e.inset)||!P(e.cta)||!P(e.secondaryCta))||!n.blocks.every(bn))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 In(n){return S(n)&&n.every(e=>h(e)&&I(e.where)&&typeof e.text=="string")}function _n(n){return n===null||h(n)&&kn(n.composition)&&typeof n.body=="string"&&In(n.proposedCopy)&&typeof n.campaign=="string"&&["shown","off","not-started","ended","none"].includes(n.campaign)}function ln(n){return n===null||h(n)&&I(n.slug)&&I(n.title)&&kn(n.composition)&&typeof n.body=="string"&&typeof n.migrated=="boolean"&&In(n.proposedCopy)&&zn(n.sections,n.warnings)}function Cn(n){return n===null||h(n)&&I(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)&&I(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 Tn(n){let e=new j,t=un(n,"body",e);if(e.problems.length>0)throw new b("body",e.problems);return t}function un(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)}]`,c=t.object(r,s);if(c===null)return;if(c._type!=="block"){t.fail(s,`is a ${JSON.stringify(c._type)}; only text is supported in rich text so far`);return}let l=Jn(c,s,t),u=c.listItem,p=c.style??"normal",d;if(u==="bullet"||u==="number"){let f=typeof c.level=="number"&&c.level>1?c.level:1;d=`${" ".repeat(f-1)}${u==="bullet"?"-":"1."} ${l}`}else if(p==="h2")d=`## ${l}`;else if(p==="h3")d=`### ${l}`;else if(p==="blockquote")d=`> ${l}`;else if(p==="normal")d=l;else{t.fail(`${s}.style`,`is ${JSON.stringify(p)}, which the schema does not offer`);return}let y=u==="bullet"||u==="number";o.length>0&&o.push(y&&i?`
|
|
2
2
|
`:`
|
|
3
3
|
|
|
4
|
-
`),o.push(
|
|
4
|
+
`),o.push(d),i=y}),o.join("")}var Qn={strong:"**",em:"*",code:"`"};function Jn(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 c=a;if(c._type!=="span"||typeof c.text!="string")return t.fail(`${e}.children[${String(s)}]`,"is not a text span"),"";let l=c.text,u=Array.isArray(c.marks)?c.marks:[];if(!t.dense(u,`${e}.children[${String(s)}].marks`))return"";let p=null;for(let d of u){if(typeof d!="string")continue;let y=Qn[d];y!==void 0?l=`${y}${l}${y}`:o.has(d)?p=o.get(d)??null:t.fail(`${e}.children[${String(s)}].marks`,`names ${JSON.stringify(d)}, which is neither a style nor a link`)}return p===null?l:`[${l}](${p})`}).join(""):""}function pn(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 q(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 b(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"),C=t.copy(a.lead,"hero.lead"),k=t.action(a.primaryAction,"hero.primaryAction"),Pn=t.action(a.secondaryAction,"hero.secondaryAction");g!==null&&(r={heading:g,subline:m,intro:C,image:f[0]??null,inset:f[1]??null,cta:k,secondaryCta:Pn})}let s=[],c=[],l="",u=pn(o.campaign,e.now);if(u==="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 C=un(f.body,"campaign.body",t);C===""&&t.fail("campaign.body","is empty; a shown campaign needs its text"),f.bodyCopySource==="proposed"&&t.proposed.push({where:"campaign.body",text:C});let k=t.action(f.action,"campaign.action");k!==null&&c.push({where:"campaign.action.href",href:k.href}),g!==null&&(l=`# ${K(g)}
|
|
5
5
|
|
|
6
|
-
${S}`),a.push({kind:"campaign",action:m,images:C})}}let u=[],c=o.blocks??[];Array.isArray(c)?t.dense(c,"blocks")&&c.forEach((d,g)=>{let C=t.object(d,`blocks[${String(g)}]`);if(C===null)return;let S=K("blocks",C,g),m=kn(C,S,t);m!==null&&(l.push(...Sn(m,C,S)),m.kind==="locations"&&m.anchor!==null&&(u.includes(m.anchor)&&t.fail(`${S}.jumpLink`,`repeats "${m.anchor}", already used by another section`),u.push(m.anchor)),a.push(m))}):t.fail("blocks","is not a list");let f=[];i?.cta&&f.push({where:"hero.primaryAction.href",href:i.cta.href}),i?.secondaryCta&&f.push({where:"hero.secondaryAction.href",href:i.secondaryCta.href}),f.push(...l);for(let{where:d,href:g}of f)g.startsWith("#")&&!u.includes(g.slice(1))&&t.fail(d,`jumps to ${g}, which no section on the page is named`);if(t.problems.length>0)throw new h(r,t.problems);return{composition:{intro:null,photo:null,hero:i,blocks:a},body:p,campaign:y,proposedCopy:t.proposed}}function Sn(e,n,t){switch(e.kind){case"feature_stories":{let o=Array.isArray(n.stories)?n.stories:[];return e.items.map((r,i)=>({where:`${K(`${t}.stories`,o[i]??{},i)}.action.href`,href:r.action.href}))}case"accent_band":return e.action===null?[]:[{where:`${t}.action.href`,href:e.action.href}];case"cta":return[{where:`${t}.action.href`,href:e.link.href}];default:return[]}}function kn(e,n,t){switch(e._type){case"featureStoriesBlock":{let o=t.requiredCopy(e.heading,`${n}.heading`),r=t.copy(e.tail,`${n}.tail`),i=e.stories;if(!Array.isArray(i)||i.length===0)return t.fail(`${n}.stories`,"has no stories");if(!t.dense(i,`${n}.stories`))return null;let s=[];return i.forEach((a,l)=>{let p=t.object(a,`${n}.stories[${String(l)}]`);if(p===null)return;let y=K(`${n}.stories`,p,l),u=t.requiredCopy(p.heading,`${y}.heading`),c=t.requiredCopy(p.body,`${y}.body`),f=t.requiredAction(p.action,`${y}.action`),d=t.photo(p.photo,`${y}.photo`),g=p.layout??"wide";if(!N.includes(g)){t.fail(`${y}.layout`,`is ${JSON.stringify(g)}, not wide, tall, round or free`);return}let C=p.onCard??!1;if(typeof C!="boolean"){t.fail(`${y}.onCard`,"is not on or off");return}u===null||c===null||f===null||s.push({heading:u,body:c,action:f,image:d,shape:g,card:C})}),o===null?null:{kind:"feature_stories",heading:o,tail:r,items:s}}case"surfaceCardBlock":{let o=t.requiredCopy(e.heading,`${n}.heading`),r=t.copy(e.body,`${n}.body`),i=t.requiredAction(e.action,`${n}.action`);return o===null||i===null?null:{kind:"cta",heading:M(o),body:r===null?null:M(r),link:{label:M(i.label),href:i.href}}}case"accentBandBlock":{let o=t.requiredCopy(e.heading,`${n}.heading`),r=t.requiredCopy(e.body,`${n}.body`),i=t.action(e.action,`${n}.action`),s=t.photo(e.photo,`${n}.photo`);return o===null||r===null?null:{kind:"accent_band",heading:o,body:r,action:i,image:s}}case"locationsBlock":{let o=e.jumpLink,r=null;o!=null&&o!==""&&(typeof o!="string"||!j.test(o)?t.fail(`${n}.jumpLink`,`is ${JSON.stringify(o)}, not lowercase words joined by hyphens`):r=o);let i=t.requiredCopy(e.heading,`${n}.heading`),s=t.copy(e.tail,`${n}.tail`),a=t.photo(e.photo,`${n}.photo`);return i===null?null:{kind:"locations",anchor:r,heading:i,tail:s,image:a}}default:return t.fail(`${n}._type`,`is ${JSON.stringify(e._type)}, not a section type this reader knows`)}}function I(e){let n=new R,t=n.object(e,"page");if(t===null)throw new h("page",n.problems);let o=typeof t._id=="string"?t._id:"page";t._type!=="page"&&n.fail("_type",`is ${JSON.stringify(t._type)}, not page`);let r=n.optionalString(t.title,"title");r===null&&n.fail("title","is missing"),t.titleCopySource==="proposed"&&r!==null&&n.proposed.push({where:"title",text:r});let i=t.slug,s=typeof i?.current=="string"&&i.current!==""?i.current:null;s===null&&n.fail("slug.current","is missing");let a=n.copy(t.lead,"lead"),l=n.photo(t.photo,"photo"),p=Y(t.body,"body",n);if(t.bodyCopySource==="proposed"&&n.proposed.push({where:"body",text:p}),n.problems.length>0||r===null||s===null)throw new h(o,n.problems);return{slug:s,title:r,composition:{intro:a===null?null:M(a),photo:l,hero:null,blocks:[]},body:p,migrated:t.migrated===!0,proposedCopy:n.proposed}}function B(e){let n=new R,t=n.object(e,"siteSettings");if(t===null)throw new h(E,n.problems);let o=n.optionalString(t.title,"title");o===null&&n.fail("title","is missing; a site needs its name");let r=n.optionalString(t.description,"description"),i=t.contact===void 0?{}:n.object(t.contact,"contact")??{},s=n.optionalString(i.email,"contact.email"),a=n.optionalString(i.phone,"contact.phone"),l=[],p=t.social??[];if(Array.isArray(p)?n.dense(p,"social")&&p.forEach((y,u)=>{let c=n.object(y,`social[${String(u)}]`);if(c===null)return;let f=n.optionalString(c.network,`social[${String(u)}].network`),d=n.optionalString(c.url,`social[${String(u)}].url`);if(f===null||d===null||!/^https?:\/\//.test(d)){n.fail(`social[${String(u)}]`,"needs a network and a web address");return}l.push({network:f,url:d})}):n.fail("social","is not a list"),n.problems.length>0||o===null)throw new h(E,n.problems);return{name:o,description:r,contact:{email:s,phone:a},social:l}}var T="*[_id == $id][0]",U='*[_type == "page" && defined(slug.current)]|order(slug.current asc)',J='*[_type == "page" && slug.current == $slug][0]';function on(e){return{home:async({now:n})=>{let t=await e.query(T,{params:{id:_}});return t==null?null:Q(t,{now:n})},pages:async()=>{let n=await e.query(U);if(!Array.isArray(n))throw new h("page",["the page query did not return a list"]);if(!b(n))throw new h("page",["the page query contains missing entries"]);return n.map(t=>I(t))},pageBySlug:async n=>{let t=await e.query(J,{params:{slug:n}});return t==null?null:I(t)},siteSettings:async()=>{let n=await e.query(T,{params:{id:E}});return n==null?null:B(n)}}}function L(e,n,t,o){if(!o(n))throw new TypeError("Invalid CMS content fallback");return e==null?{data:n,fallbackFields:["$"]}:{data:t(e),fallbackFields:[]}}function rn(e){if(!(e instanceof Date)||!Number.isFinite(e.getTime()))throw new TypeError("Invalid CMS campaign date");let n=e.getTime();return O({name:"homePage.v1",query:T,params:{id:_},dependencies:{types:["homePage"],ids:[_]},resolve:(t,o)=>L(t,o,r=>Q(r,{now:new Date(n)}),nn)})}function sn(e){if(typeof e!="string"||e==="")throw new TypeError("Invalid CMS page slug");return O({name:"page.v1",query:J,params:{slug:e},dependencies:{types:["page"]},resolve:(n,t)=>L(n,t,I,G)})}function an(){return O({name:"pages.v1",query:U,params:{},dependencies:{types:["page"]},resolve:(e,n)=>L(e,n,t=>{if(!Array.isArray(t))throw new h("page",["the page query did not return a list"]);if(!b(t))throw new h("page",["the page query contains missing entries"]);return t.map(o=>I(o))},t=>b(t)&&t.every(o=>o!==null&&G(o)))})}function ln(){return O({name:"siteSettings.v1",query:T,params:{id:E},dependencies:{types:["siteSettings"],ids:[E]},resolve:(e,n)=>L(e,n,B,en)})}0&&(module.exports={CONTENT_PAGES_QUERY,CONTENT_PAGE_BY_SLUG_QUERY,HOME_PAGE_DOCUMENT_QUERY,MALFORMED_CONTENT,MalformedContentError,READER_ACTION_HREF,READER_HOME_PAGE_ID,READER_JUMP_LINK,READER_PHOTO_SLUG,READER_SITE_SETTINGS_ID,READER_STORY_LAYOUTS,campaignState,contentPageQuery,contentPagesQuery,createSiteContentReader,homeContentQuery,parseContentPage,parseHomePage,parseSiteSettings,portableTextToMarkdown,siteSettingsQuery});
|
|
6
|
+
${C}`),s.push({kind:"campaign",action:k,images:m})}}let p=[],d=o.blocks??[];Array.isArray(d)?t.dense(d,"blocks")&&d.forEach((f,g)=>{let m=t.object(f,`blocks[${String(g)}]`);if(m===null)return;let C=q("blocks",m,g),k=En(m,C,t);k!==null&&(c.push(...An(k,m,C)),k.kind==="locations"&&k.anchor!==null&&(p.includes(k.anchor)&&t.fail(`${C}.jumpLink`,`repeats "${k.anchor}", already used by another section`),p.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(...c);for(let{where:f,href:g}of y)g.startsWith("#")&&!p.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:u,proposedCopy:t.proposed}}function An(n,e,t){switch(n.kind){case"feature_stories":{let o=Array.isArray(e.stories)?e.stories:[];return n.items.map((i,r)=>({where:`${q(`${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 En(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,c)=>{let l=t.object(s,`${e}.stories[${String(c)}]`);if(l===null)return;let u=q(`${e}.stories`,l,c),p=t.requiredCopy(l.heading,`${u}.heading`),d=t.requiredCopy(l.body,`${u}.body`),y=t.requiredAction(l.action,`${u}.action`),f=t.photo(l.photo,`${u}.photo`),g=l.layout??"wide";if(!Q.includes(g)){t.fail(`${u}.layout`,`is ${JSON.stringify(g)}, not wide, tall, round or free`);return}let m=l.onCard??!1;if(typeof m!="boolean"){t.fail(`${u}.onCard`,"is not on or off");return}p===null||d===null||y===null||a.push({heading:p,body:d,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 cn(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 c=t.optionalString(i.caption,`${e}.caption`),l=null;if(i.hotspot!==void 0&&i.hotspot!==null){let u=t.object(i.hotspot,`${e}.hotspot`),p=u?.x,d=u?.y;typeof p=="number"&&typeof d=="number"&&p>=0&&p<=1&&d>=0&&d<=1?l={x:p,y:d}:u!==null&&t.fail(`${e}.hotspot`,"is not a point inside the image")}return{asset:a,alt:s,caption:c,hotspot:l}}function Kn(n,e,t,o){switch(n._type){case"featureStoriesBlock":case"surfaceCardBlock":case"accentBandBlock":case"locationsBlock":{let i=En(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`),c=t.action(n.action,`${e}.action`),l=cn(n.photo,`${e}.photo`,t,o),u=V(n,e,A,R.Split,o);return r===null||s===null?null:{kind:"text_media",anchor:i,layout:u,heading:r,tail:a,body:s,action:c,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`),c=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 u=[];return l.forEach((p,d)=>{let y=t.object(p,`${e}.items[${String(d)}]`);if(y===null)return;let f=q(`${e}.items`,y,d);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&&u.push({question:g,answer:m})}),r===null?null:{kind:"faq",anchor:i,layout:c,heading:r,tail:a,intro:s,items:u}}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 c=s.flatMap((l,u)=>{let p=cn(l,q(`${e}.photos`,typeof l=="object"&&l!==null?l:{},u),t,o);return p===null?[]:[p]});return c.length===0?(o.push({code:_.emptySkipped,where:e}),null):{kind:"gallery",anchor:i,layout:a,heading:r,images:c}}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)},c=s("showEmail"),l=s("showPhone"),u=t.action(n.action,`${e}.action`),p=cn(n.photo,`${e}.photo`,t,o),d=V(n,e,A,R.Split,o);return r===null?null:!c&&!l&&a===null&&u===null?(o.push({code:_.emptySkipped,where:e}),null):{kind:"contact",anchor:i,layout:d,heading:r,body:a,showEmail:c,showPhone:l,action:u,image:p}}default:return o.push({code:_.unknownType,where:`${e}._type`}),null}}function Zn(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 An(n,e,t)}}function Vn(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 c=e.object(a,`sections[${String(s)}]`);if(c===null)return;let l=q("sections",c,s),u=Kn(c,l,e,o);if(u===null)return;r.push(...Zn(u,c,l));let p="anchor"in u?u.anchor:null;p!==null&&(i.includes(p)&&e.fail(`${l}.jumpLink`,`repeats "${p}", already used by another section`),i.push(p)),t.push(u)});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 M(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"),c=e.photo(t.photo,"photo"),l=un(t.body,"body",e);t.bodyCopySource==="proposed"&&e.proposed.push({where:"body",text:l});let u=t.sections===void 0||t.sections===null?null:Vn(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:c,hero:null,blocks:[]},body:l,migrated:t.migrated===!0,proposedCopy:e.proposed,...u===null?{}:u}}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"),c=[],l=t.social??[];if(Array.isArray(l)?e.dense(l,"social")&&l.forEach((u,p)=>{let d=e.object(u,`social[${String(p)}]`);if(d===null)return;let y=e.optionalString(d.network,`social[${String(p)}].network`),f=e.optionalString(d.url,`social[${String(p)}].url`);if(y===null||f===null||!/^https?:\/\//.test(f)){e.fail(`social[${String(p)}]`,"needs a network and a web address");return}c.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:c}}var G="*[_id == $id][0]",en='*[_type == "page" && defined(slug.current)]|order(slug.current asc)',tn='*[_type == "page" && slug.current == $slug][0]';function Rn(n){return{home:async({now:e})=>{let t=await n.query(G,{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=>M(t))},pageBySlug:async e=>{let t=await n.query(tn,{params:{slug:e}});return t==null?null:M(t)},siteSettings:async()=>{let e=await n.query(G,{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 $n(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:G,params:{id:O},dependencies:{types:["homePage"],ids:[O]},resolve:(t,o)=>on(t,o,i=>v(i,{now:new Date(e)}),_n)})}function On(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,M,ln)})}function xn(){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=>M(o))},t=>S(t)&&t.every(o=>o!==null&&ln(o)))})}function Ln(){return E({name:"siteSettings.v1",query:G,params:{id:x},dependencies:{types:["siteSettings"],ids:[x]},resolve:(n,e)=>on(n,e,nn,Cn)})}var yn=["columns","rows"],fn=36,gn="siteHero.layout.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 Xn(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 dn(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=Xn(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 rn(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:fn},o=[],i=new Set;for(let r of n){if(!r||typeof r!="object"||Array.isArray(r))return{ok:!1,error:"Enter a key and text for each tagline."};let a=r,s=Object.hasOwn(a,"key")?a.key:void 0;if(typeof s!="string"||!/^[a-z][a-z0-9_-]{0,31}$/.test(s))return{ok:!1,error:"Use a lowercase key of 1 to 32 letters, numbers, short dashes or underscores, starting with a letter."};if(i.has(s))return{ok:!1,error:"Use each tagline key only once."};let c=dn({...U,fields:[t]},a);if(!c.ok)return{ok:!1,error:c.errors.text??"Invalid tagline."};i.add(s),o.push({key:s,text:c.value.text??""})}return{ok:!0,value:o}}function Hn(n){return yn.some(e=>n===e)}function hn(n,e){let t=dn(U,e),o=rn(e.taglines??[]);if(!t.ok||!o.ok||e.layout!==void 0&&!Hn(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=dn(U,r),s=a.ok?[]:Object.keys(a.errors);for(let p of U.fields)if(!s.includes(p.name)){let d=a.ok?a.value[p.name]:r[p.name];typeof d=="string"&&(p.name==="heading"||p.name==="intro")&&(i[p.name]=d.trim())}let c=Object.hasOwn(r,"layout")?r.layout:void 0,l=[];Hn(c)?i.layout=c:(i.layout="columns",s.push("layout"),l.push(gn));let u=rn(Object.hasOwn(r,"taglines")?r.taglines:void 0);return u.ok?i.taglines=u.value:s.push("taglines"),{data:i,fallbackFields:s.length===U.fields.length+2?["$"]:s,...l.length>0?{warnings:l}:{}}}function Nn(){return E({name:"siteHero.v1",query:'*[_id == $id && _type == "siteHero"][0]{heading,intro,layout,taglines}',params:{id:"siteHero"},dependencies:{types:["siteHero"],ids:["siteHero"]},resolve:hn})}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_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
|