domma-cms 1.68.0 → 1.69.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/CHANGELOG.md +20 -0
- package/docs/markdown-shortcodes.md +1 -1
- package/package.json +1 -1
- package/public/js/collection-browser.js +1 -1
- package/public/js/site.js +1 -1
- package/server/routes/api/collections.js +26 -12
- package/server/services/adapters/FileAdapter.js +4 -3
- package/server/services/adapters/MongoAdapter.js +4 -2
- package/server/services/filterEngine.js +33 -0
- package/server/services/markdown.js +286 -36
- package/server/templates/page.html +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.69.0] - 2026-11-15
|
|
4
|
+
|
|
5
|
+
### Security
|
|
6
|
+
|
|
7
|
+
- **Filtered block displays are cleaned before they are drawn.** When a visitor searches, sorts or pages a `[collection display="block"]`, the browser fetches the redrawn entries from `POST /api/collections/render-fragment` and puts them into the page. That answer was not sanitised, so HTML stored in an entry and printed through a `{{{field}}}` placeholder (or a handler written in the block itself) reached the page with its scripts and event handlers. It is now cleaned the same way as the page and as `scope="mine"` displays.
|
|
8
|
+
- **A read limited to some fields is limited everywhere.** A collection whose public read lists certain fields (`api.read.fields`) returned only those, but could still be filtered, searched and sorted on the others, through `GET /api/collections/<slug>/public`, `/api/v1/<slug>` and `render-fragment` (which could also be asked to draw them). Which rows came back, and in what order, gave the hidden values away, and `resolveRefs` returned a hidden reference field's id and label. A filter, search or sort on a field that is not listed is now ignored on all three, `_refs` is cut to the list, and `render-fragment` draws only the listed fields.
|
|
9
|
+
- **No event handler on a component tag.** The page sanitiser let every attribute through on a registered `<dm-…>` component tag, `onfocus` and the rest included, so HTML in an entry could run a script through one. Event handler attributes are now removed from every tag.
|
|
10
|
+
- **A `<style>` that holds markup is removed.** A `<style>` element whose text contains something that could open a tag is dropped whole; some browsers read such an element differently from the sanitiser. A block's CSS file is unaffected (`width < 600px` in a media query stays as written). A `<style>` written straight into a page or a block's HTML with an SVG `data:` address in it must write `<` as `%3C`.
|
|
11
|
+
- **Entry HTML cannot pass itself off as part of the site.** HTML stored in an entry and shown as HTML (a `{{{field}}}` placeholder, or a body field in the accordion, timeline, carousel and list group displays) is now content only: it loses its `data-` attributes (all but `data-icon` and `data-copy`, which only decorate), `<style>` elements and component tags. `data-` attributes are what the site's scripts act on, and a `<div>` dressed as a collection table ran a script on the page. Text, links, pictures and embeds in the entry read as before. A `{{{field}}}` alone on its line between blank lines is read as Markdown, as before, and one inside the template's HTML is read as HTML.
|
|
12
|
+
- **A value inside an attribute stays inside it.** A value from an entry could close the attribute it was written into and add others, most simply through a blank line followed by a Markdown link. This is closed where a display writes a value itself (a file field's link, a carousel picture, a timeline date) and in block templates: a placeholder inside an attribute value (`<a href="{{{url}}}">`, `title="{{name}}"`) or inside one of the template's own shortcode tags (`[button href="{{url}}"]`) stays in that value; one between a tag's attributes (`<input {{checked}}>`) may write attributes but no `data-` name; one inside a name (`<h{{level}}>`) may write name characters only. A value given by a page author to `[block]` is unchanged, including one that stands for a whole attribute (`<div {{{style}}}>`).
|
|
13
|
+
- **A form's reference options are words.** A form field that offers another collection's entries wrote each entry's title into the page as HTML; angle brackets in one are now shown as look-alike characters.
|
|
14
|
+
- **File and reference links in a searchable display** open only web, mail, phone and on-site addresses.
|
|
15
|
+
- **A collection table's column titles are words.** The browser wrote a sortable column's title as HTML; angle brackets in one are now shown as look-alike characters. An Action's name is also encoded before it is used in a request.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- **A code span in a `[card]` attribute** (``title="Run `npm test`"``) printed an internal marker instead of the words. It now prints the words, as text.
|
|
20
|
+
- **Known edge:** a `[banner]` with one stray backtick in its title and another in its body on the same line is no longer drawn, as with every other container. Pair the backticks or remove one.
|
|
21
|
+
- **A `[banner]` in a code example** (a code span or a fenced block) was drawn as a banner. It is now shown as written.
|
|
22
|
+
|
|
3
23
|
## [1.68.0] - 2026-11-15
|
|
4
24
|
|
|
5
25
|
### Added
|
|
@@ -1445,7 +1445,7 @@ would be unnecessary.
|
|
|
1445
1445
|
| Placeholder | Behaviour |
|
|
1446
1446
|
|---|---|
|
|
1447
1447
|
| `{{field}}` | Value is HTML-escaped before substitution |
|
|
1448
|
-
| `{{{field}}}` | Value is inserted **raw**, without escaping - use only for trusted HTML |
|
|
1448
|
+
| `{{{field}}}` | Value is inserted **raw**, without escaping - use only for trusted HTML. Inside an attribute value (`href="{{{url}}}"`) its quotes, brackets and line breaks are written as entities, so it stays in that attribute. From a collection entry it is content only: no `data-` attributes, `<style>` or component tags |
|
|
1449
1449
|
| `{{field:FORMAT}}` | Formats the value as a date, e.g. `{{date:DD MMM YYYY}}`. Tokens: `YYYY YY MMMM MMM MM M DD D dddd ddd HH H hh h mm m ss s A a`. A value that is not a valid date is output unformatted |
|
|
1450
1450
|
|
|
1451
1451
|
**Notes:**
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __browsers=[];let __keyboardNavInstalled=!1;function bootstrapCollectionBrowsers(l=document){const t=[...l.querySelectorAll(".dm-collection-browser")].filter(e=>!e.__dmCollectionBrowser);t.length&&(t.forEach(e=>{e.__dmCollectionBrowser=!0;try{__browsers.push(new CollectionBrowser(e,__browsers.length))}catch(i){console.error("[collection-browser] hydration failed:",i)}}),!__keyboardNavInstalled&&__browsers.length&&(__keyboardNavInstalled=!0,installGlobalKeyboardNav()))}function installGlobalKeyboardNav(){__browsers.length&&document.addEventListener("keydown",l=>{const t=l.target&&(l.target.tagName==="INPUT"||l.target.tagName==="TEXTAREA"||l.target.isContentEditable||!!l.target.closest?.('[role="slider"]'));if(l.key==="/"&&!t){const i=__browsers[0]?.el.querySelector(".dm-cb-search-input");i&&(l.preventDefault(),i.focus(),i.select());return}if((l.key==="ArrowLeft"||l.key==="ArrowRight")&&!t){const e=__browsers.find(s=>s.el.contains(l.target))||__browsers[0];if(!e)return;const i=Math.max(1,Math.ceil(e.currentTotal/e.config.pageSize)),n=l.key==="ArrowRight"?Math.min(i,e.state.page+1):Math.max(1,e.state.page-1);n!==e.state.page&&(l.preventDefault(),e.setState({page:n}))}})}function decodePayload(l){if(!l)return null;try{const t=atob(l),e=decodeURIComponent(escape(t));return JSON.parse(e)}catch{try{return JSON.parse(atob(l))}catch{return null}}}function clear(l){l&&typeof l.replaceChildren=="function"&&l.replaceChildren()}function distinctValues(l,t){const e=new Set;for(const i of l||[]){const n=i?.data?.[t];n!=null&&(Array.isArray(n)?n.forEach(s=>s!=null&&e.add(String(s))):e.add(String(n)))}return[...e].sort()}class CollectionBrowser{constructor(t,e){this.el=t,this.config=decodePayload(t.dataset.cbConfig)||{},this.schema=decodePayload(t.dataset.cbSchema)||{fields:[]};const i=decodePayload(t.dataset.cbData)||{entries:[],total:0,page:1,pageSize:12},n=(this.config.id||`${this.config.slug}-${e}`).replace(/[^a-z0-9]/gi,"_");let s=n,a=1;for(;__browsers.some(r=>r.idScope===s);)a+=1,s=`${n}_${a}`;this.idScope=s,this.urlPrefix=`cb_${s}_`,this._fragReqId=0,this.entries=i.entries||[],this.total=i.total||0,this.state={search:"",filter:{},sort:this.config.initial?.sort||"createdAt",order:this.config.initial?.order||"desc",page:1},this.readUrlState(),this.buildSkeleton(),this.refresh()}buildSkeleton(){clear(this.el);const t=elt("div","dm-cb-header");this.config.filterable?.length&&t.appendChild(this.buildDrawerToggle()),this.config.searchable&&t.appendChild(this.buildSearchInput()),this.config.sortable&&t.appendChild(this.buildSortControl()),this.config.savedSearches!==!1&&t.appendChild(this.buildSavedSearches()),this.config.exportable&&t.appendChild(this.buildExportButton());const e=elt("div","dm-cb-layout");this.filterRail=elt("aside","dm-cb-filter-rail"),this.bodyEl=elt("div","dm-cb-body"),e.appendChild(this.filterRail),e.appendChild(this.bodyEl),this.config.filterable?.length?this.renderFilterRail():(this.filterRail.style.display="none",e.classList.add("dm-cb-layout--no-rail")),this.pagerEl=elt("div","dm-cb-pagination"),t.childElementCount&&this.el.appendChild(t),this.el.appendChild(e),this.el.appendChild(this.pagerEl),this.el.classList.add("dm-cb-hydrated")}buildSavedSearches(){const t=elt("div","dm-cb-saved"),e=elt("button","dm-cb-saved-toggle btn btn-outline");e.type="button",e.textContent="Saved \u25BE",t.appendChild(e);const i=elt("div","dm-cb-saved-menu");i.hidden=!0,t.appendChild(i);const n=()=>{clear(i);const s=this.loadSavedSearches();if(!s.length){const o=elt("p","dm-cb-saved-empty");o.textContent="No saved views yet.",i.appendChild(o)}for(const o of s){const c=elt("div","dm-cb-saved-item"),d=elt("button","dm-cb-saved-apply");d.type="button",d.textContent=o.name,d.addEventListener("click",()=>{this.state.search=o.search||"",this.state.filter={...o.filter||{}},this.state.sort=o.sort||this.config.initial?.sort||"createdAt",this.state.order=o.order||this.config.initial?.order||"desc",this.state.page=1,this.renderFilterRail();const p=this.el.querySelector(".dm-cb-search-input");p&&(p.value=this.state.search),i.hidden=!0,this.refresh()});const h=elt("button","dm-cb-saved-del");h.type="button",h.textContent="\xD7",h.title="Delete saved view",h.addEventListener("click",p=>{p.stopPropagation(),this.deleteSavedSearch(o.name),n()}),c.appendChild(d),c.appendChild(h),i.appendChild(c)}const a=elt("div","dm-cb-saved-actions"),r=elt("button","dm-cb-saved-create btn btn-primary");r.type="button",r.textContent="Save current view",r.addEventListener("click",async()=>{const o=await this.promptName();o&&(this.addSavedSearch({name:o,search:this.state.search,filter:this.state.filter,sort:this.state.sort,order:this.state.order}),n())}),a.appendChild(r),i.appendChild(a)};return e.addEventListener("click",()=>{i.hidden=!i.hidden,i.hidden||n()}),document.addEventListener("click",s=>{t.contains(s.target)||(i.hidden=!0)}),t}async promptName(){const t=typeof window<"u"&&typeof window.prompt=="function"?window.prompt("Name this saved view:"):null;return t&&t.trim()||null}loadSavedSearches(){try{const t=`cb_saved_${this.idScope}`,e=typeof S<"u"&&S.get?S.get(t):null;return Array.isArray(e)?e:[]}catch{return[]}}addSavedSearch(t){const e=this.loadSavedSearches().filter(i=>i.name!==t.name);e.push(t);try{typeof S<"u"&&S.set&&S.set(`cb_saved_${this.idScope}`,e)}catch{}}deleteSavedSearch(t){const e=this.loadSavedSearches().filter(i=>i.name!==t);try{typeof S<"u"&&S.set&&S.set(`cb_saved_${this.idScope}`,e)}catch{}}buildExportButton(){const t=elt("button","dm-cb-export btn btn-outline");return t.type="button",t.textContent="Export CSV",t.addEventListener("click",()=>this.exportCsv()),t}exportCsv(){if(this.config.mode==="client"){let n=this.entries;if(this.state.search){const o=this.state.search.toLowerCase();n=n.filter(c=>Object.values(c.data||{}).some(d=>String(d).toLowerCase().includes(o)))}const s={...this.state.filter,...this.config.baked||{}};n=applyFilterInMemory(n,s);const a=this.visibleFields(n),r=toCsv(n,a);downloadCsv(`${this.config.slug}-export.csv`,r);return}const t=new URLSearchParams;t.set("format","csv"),this.state.search&&t.set("search",this.state.search);const e={...this.state.filter,...this.config.baked||{}};for(const[n,s]of Object.entries(e))t.set(`filter[${n}]`,s);const i=`/api/collections/${encodeURIComponent(this.config.slug)}/export?${t.toString()}`;window.open(i,"_blank")}buildDrawerToggle(){const t=elt("button","dm-cb-drawer-toggle btn btn-outline");t.type="button",t.setAttribute("aria-label","Toggle filters");const e=elt("span","dm-cb-drawer-label");e.textContent="Filters";const i=elt("span","dm-cb-drawer-count");return t.appendChild(e),t.appendChild(document.createTextNode(" ")),t.appendChild(i),t.addEventListener("click",()=>{this.el.classList.toggle("dm-cb-drawer-open")}),t}buildSearchInput(){const t=elt("div","dm-cb-search"),e=elt("input","dm-cb-search-input");return e.type="search",e.placeholder="Search\u2026",e.value=this.state.search,e.addEventListener("input",debounce(()=>{this.setState({search:e.value,page:1})},200)),t.appendChild(e),t}buildSortControl(){const t=elt("div","dm-cb-sort"),e=elt("label","dm-cb-sort-label");e.textContent="Sort:",t.appendChild(e);const i=elt("select","dm-cb-sort-select"),n=this.sortableFieldList();for(const a of n){const r=elt("option");r.value=a.name,r.textContent=a.label,a.name===this.state.sort&&(r.selected=!0),i.appendChild(r)}i.addEventListener("change",()=>this.setState({sort:i.value,page:1})),t.appendChild(i);const s=elt("button","dm-cb-sort-dir");return s.type="button",s.textContent=this.state.order==="asc"?"\u2191":"\u2193",s.title=this.state.order==="asc"?"Ascending":"Descending",s.addEventListener("click",()=>{this.setState({order:this.state.order==="asc"?"desc":"asc",page:1}),s.textContent=this.state.order==="asc"?"\u2191":"\u2193"}),t.appendChild(s),t}sortableFieldList(){const t=this.config.sortableFields?.length?new Set(this.config.sortableFields):null,e=[{name:"createdAt",label:"Most recent"}];for(const i of this.schema.fields||[])t&&!t.has(i.name)||e.push({name:i.name,label:i.label||i.name});return e}renderFilterRail(){for(const i of this._sliders||[])i.destroy();this._sliders=[],clear(this.filterRail);const t=elt("h4","dm-cb-filter-heading");t.textContent="Filters",this.filterRail.appendChild(t);for(const i of this.config.filterable){const n=(this.schema.fields||[]).find(a=>a.name===i);if(!n)continue;const s=this.buildFilterControl(n);s&&this.filterRail.appendChild(s)}const e=elt("button","dm-cb-filter-reset");e.type="button",e.textContent="Clear filters",e.addEventListener("click",()=>{this.setState({filter:{},search:"",page:1}),this.renderFilterRail();const i=this.el.querySelector(".dm-cb-search-input");i&&(i.value=""),this.filterRail.querySelector(".dm-cb-filter-reset")?.focus()}),this.filterRail.appendChild(e)}buildFilterControl(t){const e=elt("div","dm-cb-filter"),i=elt("label","dm-cb-filter-label");switch(i.textContent=t.label||t.name,e.appendChild(i),t.type){case"reference":e.appendChild(this.buildReferenceFilter(t));break;case"select":case"chooser":e.appendChild(this.buildSelectControl(t,!1));break;case"multiselect":case"tags":case"tag":e.appendChild(this.buildSelectControl(t,!0));break;case"number":e.appendChild(this.buildRangeControl(t,"number"));break;case"date":case"datetime":e.appendChild(this.buildRangeControl(t,"date"));break;case"boolean":case"checkbox":e.appendChild(this.buildBooleanControl(t));break;default:e.appendChild(this.buildTextControl(t));break}return e}buildReferenceFilter(t){const e=new Map;for(const a of this.entries){const r=a._refs?.[t.name];if(!r)continue;const o=Array.isArray(r)?r:[r];for(const c of o)!c||c.missing||e.has(c.id)||e.set(c.id,c.display)}const i=`${t.name}_eq`,n=elt("select","dm-cb-select"),s=elt("option");s.value="",s.textContent=this.config.mode==="server"?"Any (loaded)":"Any",n.appendChild(s);for(const[a,r]of e){const o=elt("option");o.value=a,o.textContent=r,String(this.state.filter[i]??"")===String(a)&&(o.selected=!0),n.appendChild(o)}return n.addEventListener("change",()=>this.updateFilter(i,n.value)),n}buildTextControl(t){const e=`${t.name}_contains`,i=elt("input","dm-cb-text");return i.type="text",i.placeholder="Contains\u2026",i.value=this.state.filter[e]||"",i.addEventListener("input",debounce(()=>{this.updateFilter(e,i.value.trim())},200)),i}buildSelectControl(t,e){const i=Array.isArray(t.options)&&t.options.length?t.options.map(o=>typeof o=="object"?o:{value:o,label:o}):distinctValues(this.entries,t.name).map(o=>({value:o,label:o})),n=this.config.mode==="client"?this.facetCounts(t.name,e?"_in":"_eq",i.map(o=>o.value)):null;if(e){const o=`${t.name}_in`,c=elt("div","dm-cb-chips"),d=new Set((this.state.filter[o]||"").split(",").filter(Boolean));for(const h of i){const p=elt("button","dm-cb-chip");p.type="button",d.has(String(h.value))&&p.classList.add("dm-cb-chip-active");const f=elt("span","dm-cb-chip-label");if(f.textContent=h.label??h.value,p.appendChild(f),n){const u=elt("span","dm-cb-chip-count");u.textContent=n[String(h.value)]??0,p.appendChild(u)}p.addEventListener("click",()=>{d.has(String(h.value))?d.delete(String(h.value)):d.add(String(h.value)),this.updateFilter(o,d.size?[...d].join(","):"")}),c.appendChild(p)}return c}const s=`${t.name}_eq`,a=elt("select","dm-cb-select"),r=elt("option");r.value="",r.textContent="Any",a.appendChild(r);for(const o of i){const c=elt("option");c.value=o.value;const d=n?` (${n[String(o.value)]??0})`:"";c.textContent=(o.label??o.value)+d,String(this.state.filter[s]??"")===String(o.value)&&(c.selected=!0),a.appendChild(c)}return a.addEventListener("change",()=>this.updateFilter(s,a.value)),a}facetCounts(t,e,i){const n={};for(const[o,c]of Object.entries(this.state.filter||{})){const{field:d}=parseFilterKey(o);d!==t&&(n[o]=c)}let s=this.entries;if(this.state.search){const o=this.state.search.toLowerCase();s=s.filter(c=>Object.values(c.data||{}).some(d=>String(d).toLowerCase().includes(o)))}const a={...n,...this.config.baked||{}};s=applyFilterInMemory(s,a);const r={};for(const o of i){const c={...a,[`${t}${e}`]:String(o)};r[String(o)]=applyFilterInMemory(s,c).length}return r}buildRangeControl(t,e){const i=`${t.name}_gte`,n=`${t.name}_lte`,s=elt("div","dm-cb-range"),a=elt("div","dm-cb-range-inputs"),r=elt("input","dm-cb-range-min"),o=elt("input","dm-cb-range-max");r.type=e,o.type=e,r.placeholder="Min",o.placeholder="Max",r.value=this.state.filter[i]||"",o.value=this.state.filter[n]||"",a.appendChild(r),a.appendChild(document.createTextNode(" - ")),a.appendChild(o),s.appendChild(a);let c=null,d=null,h=null;const p=window.DommaCollectionRange;if(e==="number"&&this.config.mode==="client"&&this.entries.length&&p&&typeof E<"u"&&E.rangeSlider&&(d=p.rangeBounds(this.entries.map(u=>u.data?.[t.name]))),d){const u=elt("div","dm-cb-slider");s.appendChild(u);const g=t.label||t.name,m=b=>{const C=p.rangeFilter(d,b);(!h||b[0]!==h[0])&&(r.value=C.gte),(!h||b[1]!==h[1])&&(o.value=C.lte)};c=E.rangeSlider(u,{range:!0,min:d.min,max:d.max,step:d.step,value:p.sliderValue(d,r.value,o.value),labels:p.rangeLabel(t,d.step),ariaLabels:[`${g} from`,`${g} to`],onInput:m,onChange:b=>{m(b),h=b.slice(),this.updateFilter(i,r.value,!0),this.updateFilter(n,o.value)}}),h=c.getValue().slice(),this._sliders.push(c)}const f=debounce(()=>{this.updateFilter(i,r.value,!0),this.updateFilter(n,o.value),c&&(c.setValue(p.sliderValue(d,r.value,o.value),{silent:!0}),h=c.getValue().slice())},250);return r.addEventListener("input",f),o.addEventListener("input",f),s}buildBooleanControl(t){const e=`${t.name}_eq`,i=elt("select","dm-cb-select");for(const[n,s]of[["","Any"],["true","Yes"],["false","No"]]){const a=elt("option");a.value=n,a.textContent=s,String(this.state.filter[e]??"")===n&&(a.selected=!0),i.appendChild(a)}return i.addEventListener("change",()=>this.updateFilter(e,i.value)),i}updateFilter(t,e,i=!1){const n={...this.state.filter};e===""||e==null?delete n[t]:n[t]=e,this.state.filter=n,this.state.page=1,i||this.refresh()}setState(t){Object.assign(this.state,t),this.refresh()}async refresh(){this.config.syncUrl&&this.writeUrlState(),this.config.mode==="server"&&await this.fetchPage(),this.renderBody(),this.renderPagination(),this.updateFacetCounts(),this.updateDrawerBadge()}updateFacetCounts(){if(this.config.mode==="client"&&this.filterRail)for(const t of this.config.filterable||[]){const e=(this.schema.fields||[]).find(r=>r.name===t);if(!e)continue;const i=e.type==="multiselect"||e.type==="tags"||e.type==="tag"?"_in":"_eq",n=Array.isArray(e.options)&&e.options.length?e.options.map(r=>typeof r=="object"?r:{value:r,label:r}):distinctValues(this.entries,t).map(r=>({value:r,label:r})),s=this.facetCounts(t,i,n.map(r=>r.value)),a=this.filterRail.querySelectorAll(".dm-cb-filter");for(const r of a){const o=r.querySelector(".dm-cb-filter-label");if(!o||o.textContent!==(e.label||e.name))continue;r.querySelectorAll(".dm-cb-chip").forEach((h,p)=>{const f=h.querySelector(".dm-cb-chip-count");f&&n[p]&&(f.textContent=s[String(n[p].value)]??0)});const d=r.querySelector("select.dm-cb-select");d&&Array.from(d.options).forEach(h=>{if(!h.value)return;const p=n.find(f=>String(f.value)===h.value)?.label??h.value;h.textContent=`${p} (${s[h.value]??0})`})}}}updateDrawerBadge(){const t=this.el.querySelector(".dm-cb-drawer-toggle");if(!t)return;const e=(this.state.search?1:0)+Object.keys(this.state.filter||{}).length,i=t.querySelector(".dm-cb-drawer-count");i&&(i.textContent=e>0?`(${e})`:"")}async fetchPage(){const t={...this.state.filter,...this.config.baked||{}},e=new URLSearchParams;e.set("page",this.state.page),e.set("limit",this.config.pageSize),e.set("sort",this.state.sort),e.set("order",this.state.order),this.state.search&&e.set("search",this.state.search);for(const[n,s]of Object.entries(t))e.set(`filter[${n}]`,s);this.config.scope==="mine"&&e.set("scope","mine"),this._fetchAbort&&this._fetchAbort.abort(),this._fetchAbort=new AbortController;const i=this.config.sourceKind==="view"?`/api/views/${encodeURIComponent(this.config.slug)}/public?${e.toString()}`:`/api/collections/${encodeURIComponent(this.config.slug)}/public?${e.toString()}`;try{const n=await fetch(i,{headers:this.authHeaders(),signal:this._fetchAbort.signal});if(!n.ok){this.entries=[],this.total=0;return}const s=await n.json(),a=s.entries||s.results||[];this.entries=a.map(r=>r.data?r:{id:r.id||"",data:r.data||r}),this.total=s.total||a.length}catch(n){if(n.name==="AbortError")return;this.entries=[],this.total=0}}authHeaders(){try{const t=typeof S<"u"&&S.get?S.get("auth_token"):null;return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}pipeline(){if(this.config.mode==="server")return{visible:this.entries,total:this.total};let t=this.entries,e=null;if(this.state.search){const c=this.state.search.toLowerCase();e=new Map,t=t.filter(d=>{let h=0;for(const[p,f]of Object.entries(d.data||{})){if(f==null)continue;const u=String(f).toLowerCase();let g=0,m=0;for(;(g=u.indexOf(c,g))!==-1;)m++,g+=c.length;m>0&&(h+=m*(p===this.config.titleField?3:1))}return h>0&&e.set(d.id||d,h),h>0})}if(Object.keys(this.state.filter).length||Object.keys(this.config.baked||{}).length){const c={...this.state.filter,...this.config.baked||{}};t=applyFilterInMemory(t,c)}const i=this.config.initial?.sort||"createdAt",n=this.config.initial?.order||"desc",s=this.state.sort===i&&this.state.order===n;this.state.search&&e&&s?(t=[...t].sort((c,d)=>{const h=e.get(c.id||c)||0;return(e.get(d.id||d)||0)-h}),this._activeSortMode="relevance"):(t=sortEntries(t,this.state.sort,this.state.order),this._activeSortMode=null);const a=t.length,r=(this.state.page-1)*this.config.pageSize;return{visible:t.slice(r,r+this.config.pageSize),total:a}}renderBody(){const{visible:t,total:e}=this.pipeline();if(this.currentTotal=e,clear(this.bodyEl),!t.length){this.bodyEl.appendChild(this.buildEmptyState());return}const i=this.visibleFields(t);this.bodyEl.appendChild(this.renderForDisplay(t,i)),typeof Domma<"u"&&Domma.icons?.scan&&Domma.icons.scan(this.bodyEl),this.config.cta&&typeof wireCTAButtons=="function"&&wireCTAButtons(this.bodyEl)}buildEmptyState(){const t=elt("div","dm-collection-display dm-collection-empty"),e=!!this.state.search||Object.keys(this.state.filter||{}).length>0,i=elt("p");if(e){i.textContent="No results for these filters.",t.appendChild(i);const n=elt("button","btn btn-outline dm-cb-empty-clear");n.type="button",n.textContent="Clear filters",n.addEventListener("click",()=>{this.setState({filter:{},search:"",page:1}),this.renderFilterRail();const s=this.el.querySelector(".dm-cb-search-input");s&&(s.value="")}),t.appendChild(n)}else i.textContent=this.config.emptyMsg,t.appendChild(i);return t}visibleFields(t){let e=this.schema.fields||[];return this.config.fields?.length&&(e=this.config.fields.map(i=>e.find(n=>n.name===i)||{name:i,label:i})),!e.length&&t.length&&(e=Object.keys(t[0].data||{}).map(i=>({name:i,label:i}))),e}renderCards(t,e){const i=elt("div",`dm-collection-cards grid grid-cols-${this.config.columns}`);for(const n of t){const s=elt("div","card dm-collection-card"),a=e.find(c=>c.name===this.config.titleField),r=a?fieldDisplay(n,a):this.config.titleField?formatValue(n.data?.[this.config.titleField]):"";if(r){const c=elt("div","card-header");c.textContent=r,s.appendChild(c)}const o=elt("div","card-body");for(const c of e){if(this.config.titleField===c.name||!fieldDisplay(n,c))continue;const h=elt("div","dm-collection-card-field"),p=elt("strong");p.textContent=(c.label||c.name)+": ",h.appendChild(p),h.appendChild(fieldDisplayNode(n,c)),o.appendChild(h)}this.config.cta&&o.appendChild(this.buildCtaButton(n)),this.config.transitions&&o.appendChild(this.buildTransitionsGroup(n)),s.appendChild(o),i.appendChild(s)}return i}renderList(t,e){const i=elt("ul","dm-collection-list");for(const n of t){const s=elt("li","dm-collection-list-item"),a=e.find(c=>c.name===this.config.titleField),r=a?fieldDisplay(n,a):this.config.titleField?formatValue(n.data?.[this.config.titleField]):"";if(r){const c=elt("div","dm-collection-list-title");c.textContent=r,s.appendChild(c)}const o=e.filter(c=>c.name!==this.config.titleField).map(c=>{const d=fieldDisplay(n,c);return d?`${c.label||c.name}: ${d}`:""}).filter(Boolean).join(" \xB7 ");if(o){const c=elt("div","dm-collection-list-meta");c.textContent=o,s.appendChild(c)}this.config.cta&&s.appendChild(this.buildCtaButton(n)),this.config.transitions&&s.appendChild(this.buildTransitionsGroup(n)),i.appendChild(s)}return i}renderTable(t,e){const i=elt("table","dm-collection-table"),n=elt("thead"),s=elt("tr");for(const r of e){const o=elt("th");o.textContent=r.label||r.name,s.appendChild(o)}this.config.cta&&s.appendChild(elt("th")),this.config.transitions&&s.appendChild(elt("th")),n.appendChild(s),i.appendChild(n);const a=elt("tbody");for(const r of t){const o=elt("tr");for(const c of e){const d=elt("td");d.appendChild(fieldDisplayNode(r,c)),o.appendChild(d)}if(this.config.cta){const c=elt("td");c.appendChild(this.buildCtaButton(r)),o.appendChild(c)}if(this.config.transitions){const c=elt("td");c.appendChild(this.buildTransitionsGroup(r)),o.appendChild(c)}a.appendChild(o)}return i.appendChild(a),i}renderAccordion(t){const e=elt("div","accordion dm-collection-accordion");for(const i of t){const n=elt("div","accordion-item"),s=this.config.titleField&&i.data?.[this.config.titleField]||"Untitled",a=this.config.bodyField&&i.data?.[this.config.bodyField]||"",r=elt("button","accordion-header");r.type="button",r.textContent=String(s);const o=elt("div","accordion-panel");o.textContent=String(a),r.addEventListener("click",()=>n.classList.toggle("open")),n.appendChild(r),n.appendChild(o),e.appendChild(n)}return e}buildCtaButton(t){const e=this.config.cta,i=elt("button",`btn btn-${e.style||"primary"} dm-cta-trigger`);if(i.dataset.action=e.action,i.dataset.entry=t.id||"",this.config.scope&&(i.dataset.scope=this.config.scope),e.confirm&&(i.dataset.confirm=e.confirm),e.icon){const n=elt("span");n.dataset.icon=e.icon,i.appendChild(n),i.appendChild(document.createTextNode(" "))}return i.appendChild(document.createTextNode(e.label||"Run")),i}buildTransitionsGroup(t){const e=elt("div","dm-cb-transitions");return e.dataset.entry=t.id||"",e.textContent="Loading actions\u2026",Promise.resolve().then(()=>this.loadTransitions(t,e)),e}async loadTransitions(t,e){try{const i=new URLSearchParams({collection:this.config.slug,entryId:t.id||""});this.config.scope==="mine"&&i.set("scope","mine");const n=await fetch(`/api/actions/transitions?${i.toString()}`,{headers:this.authHeaders()});if(clear(e),!n.ok)return;const{transitions:s}=await n.json();if(!Array.isArray(s)||!s.length)return;for(const a of s){const r=elt("button",`btn btn-${a.trigger?.style||"outline"} dm-cb-transition-btn dm-cta-trigger`);if(r.dataset.action=a.slug,r.dataset.entry=t.id||"",this.config.scope&&(r.dataset.scope=this.config.scope),a.trigger?.confirmMessage&&(r.dataset.confirm=a.trigger.confirmMessage),a.trigger?.icon){const o=elt("span");o.dataset.icon=a.trigger.icon,r.appendChild(o),r.appendChild(document.createTextNode(" "))}r.appendChild(document.createTextNode(a.trigger?.label||a.title)),e.appendChild(r)}typeof Domma<"u"&&Domma.icons?.scan&&Domma.icons.scan(e),typeof wireCTAButtons=="function"&&wireCTAButtons(e)}catch{clear(e)}}renderPagination(){if(this.config.pagination==="scroll"){this.renderInfiniteSentinel();return}const t=Math.max(1,Math.ceil(this.currentTotal/this.config.pageSize));if(clear(this.pagerEl),t<=1)return;const e=elt("button","dm-cb-page-prev btn btn-outline");e.type="button",e.textContent="\u2039 Prev",e.disabled=this.state.page<=1,e.addEventListener("click",()=>this.setState({page:Math.max(1,this.state.page-1)}));const i=elt("button","dm-cb-page-next btn btn-outline");i.type="button",i.textContent="Next \u203A",i.disabled=this.state.page>=t,i.addEventListener("click",()=>this.setState({page:Math.min(t,this.state.page+1)}));const n=elt("span","dm-cb-page-info");n.textContent=`Page ${this.state.page} of ${t} (${this.currentTotal} entr${this.currentTotal===1?"y":"ies"})`,this.pagerEl.appendChild(e),this.pagerEl.appendChild(n),this.pagerEl.appendChild(i)}renderInfiniteSentinel(){clear(this.pagerEl);const t=Math.max(1,Math.ceil(this.currentTotal/this.config.pageSize));if(this.state.page>=t){const i=elt("p","dm-cb-scroll-end");i.textContent=`All ${this.currentTotal} entries loaded.`,this.pagerEl.appendChild(i);return}const e=elt("div","dm-cb-scroll-sentinel");e.setAttribute("aria-hidden","true"),e.textContent="Loading more\u2026",this.pagerEl.appendChild(e),this._scrollObserver&&this._scrollObserver.disconnect(),this._scrollObserver=new IntersectionObserver(async i=>{i[0].isIntersecting&&(this._scrollObserver.disconnect(),await this.loadMore())},{rootMargin:"200px 0px"}),this._scrollObserver.observe(e)}async loadMore(){const t=this.state.page+1,e=this.currentTotal,i=this.entries,n=this.state.page;this.state.page=t,this.config.syncUrl&&this.writeUrlState();let s;if(this.config.mode==="server")await this.fetchPage(),s=this.entries;else{const{visible:c}=this.pipeline();s=c}if(!s.length){this.state.page=n,this.entries=i,this.currentTotal=e,this.renderPagination();return}const a=this.visibleFields(s),r=this.renderForDisplay(s,a),o=this.bodyEl.firstElementChild;if(o&&o.tagName===r.tagName)for(;r.firstChild;)o.appendChild(r.firstChild);else this.bodyEl.appendChild(r);typeof Domma<"u"&&Domma.icons?.scan&&Domma.icons.scan(this.bodyEl),this.config.cta&&typeof wireCTAButtons=="function"&&wireCTAButtons(this.bodyEl),this.renderPagination()}renderForDisplay(t,e){const i=this.config.display;return i==="list"?this.renderList(t,e):i==="table"?this.renderTable(t,e):i==="accordion"?this.renderAccordion(t):i==="timeline"?this.renderTimeline(t):i==="block"?this.renderBlockPlaceholder(t):this.renderCards(t,e)}renderTimeline(t){const e=["vertical","centred","horizontal"].includes(this.config.layout)?this.config.layout:"vertical",i=["minimal","corporate","modern"].includes(this.config.theme)?this.config.theme:"minimal",n=elt("div",`dm-collection-timeline timeline timeline-${e} timeline-${i}`);for(const s of t){const a=elt("div","timeline-event"),r=this.config.dateField&&s.data?.[this.config.dateField]||"",o=this.config.titleField&&s.data?.[this.config.titleField]||"",c=this.config.bodyField&&s.data?.[this.config.bodyField]||"",d=this.config.statusField&&s.data?.[this.config.statusField]||"",h=this.config.iconField&&s.data?.[this.config.iconField]||"";if(h){const p=elt("span","timeline-icon");p.dataset.icon=String(h),a.appendChild(p)}if(r){const p=elt("div","timeline-date");p.textContent=String(r),a.appendChild(p)}if(o){const p=elt("h4","timeline-title");p.textContent=String(o),a.appendChild(p)}if(d){const p=elt("span",`badge badge-${d}`);p.textContent=String(d),a.appendChild(p)}if(c){const p=elt("div","timeline-body");p.textContent=String(c),a.appendChild(p)}n.appendChild(a)}return n}renderBlockPlaceholder(t){const e=elt("div","dm-collection-display dm-cb-block-loading");return e.textContent="Rendering\u2026",this.fetchBlockFragment(t,e),e}async fetchBlockFragment(t,e){const i=++this._fragReqId,n=t.map(r=>r.id).filter(Boolean),s={slug:this.config.slug,display:"block",block:this.config.block,"title-field":this.config.titleField,"body-field":this.config.bodyField,fields:this.config.fields?this.config.fields.join(","):"",empty:this.config.emptyMsg,limit:String(n.length||1)},a={...this.state.filter,...this.config.baked||{}};for(const[r,o]of Object.entries(a))o!==""&&o!=null&&(s[`where_${r}`]=String(o));s.sort=this.state.sort,s.order=this.state.order,s.limit=String(this.config.pageSize);try{const r=btoa(unescape(encodeURIComponent(JSON.stringify(s)))),o=this.config.scope==="mine"?"/api/collections/render-scope":"/api/collections/render-fragment",c=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({attrs:r,page:this.state.page})});if(i!==this._fragReqId)return;if(!c.ok){e.textContent=this.config.emptyMsg;return}const{html:d}=await c.json(),h=document.createElement("template");h.innerHTML=d||"",e.replaceWith(h.content)}catch{e.textContent="Unable to load block view."}}readUrlState(){if(!this.config.syncUrl)return;const t=new URLSearchParams(window.location.search),e=this.urlPrefix,i=a=>t.get(e+a);i("search")&&(this.state.search=i("search")),i("sort")&&(this.state.sort=i("sort")),i("order")&&(this.state.order=i("order")),i("page")&&(this.state.page=parseInt(i("page"),10)||1);const n={},s=`${e}filter[`;for(const[a,r]of t.entries())if(a.startsWith(s)&&a.endsWith("]")){const o=a.slice(s.length,-1);o&&(n[o]=r)}Object.keys(n).length&&(this.state.filter=n)}writeUrlState(){const t=new URL(window.location.href),e=this.urlPrefix,i=[];for(const s of t.searchParams.keys())s.startsWith(e)&&i.push(s);i.forEach(s=>t.searchParams.delete(s));const n=(s,a)=>{a!==""&&a!=null&&t.searchParams.set(e+s,a)};n("search",this.state.search),this.state.sort!==(this.config.initial?.sort||"createdAt")&&n("sort",this.state.sort),this.state.order!==(this.config.initial?.order||"desc")&&n("order",this.state.order),this.state.page!==1&&n("page",this.state.page);for(const[s,a]of Object.entries(this.state.filter))a!==""&&a!=null&&t.searchParams.set(`${e}filter[${s}]`,a);try{window.history.replaceState({},"",t.toString())}catch{}}}const OPERATORS=["_eq","_ne","_gte","_lte","_gt","_lt","_in","_nin","_contains","_starts","_ends","_exists"];function parseFilterKey(l){for(const t of OPERATORS)if(l.endsWith(t))return{field:l.slice(0,-t.length),op:t};return{field:l,op:"_eq"}}function resolveField(l,t){if(t==="createdBy")return l.meta?.createdBy;if(t==="id")return l.id;const e=t.split(".");let i=l.data;for(const n of e){if(i==null)return;i=i[n]}return i}function maybeNumber(l){if(typeof l=="number"||typeof l!="string")return l;const t=Number(l);return Number.isFinite(t)&&String(t)===l.trim()?t:l}function applyOp(l,t,e){switch(l){case"_eq":{const i=maybeNumber(t),n=maybeNumber(e);return Array.isArray(t)?t.map(maybeNumber).includes(n):i===n||String(i)===String(n)}case"_ne":{const i=maybeNumber(t),n=maybeNumber(e);return Array.isArray(t)?!t.map(maybeNumber).includes(n):!(i===n||String(i)===String(n))}case"_gt":return maybeNumber(t)>maybeNumber(e);case"_gte":return maybeNumber(t)>=maybeNumber(e);case"_lt":return maybeNumber(t)<maybeNumber(e);case"_lte":return maybeNumber(t)<=maybeNumber(e);case"_in":{const i=String(e).split(",").map(n=>maybeNumber(n.trim()));return Array.isArray(t)?t.map(maybeNumber).some(n=>i.includes(n)):i.includes(maybeNumber(t))}case"_nin":{const i=String(e).split(",").map(n=>maybeNumber(n.trim()));return Array.isArray(t)?!t.map(maybeNumber).some(n=>i.includes(n)):!i.includes(maybeNumber(t))}case"_contains":return String(t??"").toLowerCase().includes(String(e).toLowerCase());case"_starts":return String(t??"").toLowerCase().startsWith(String(e).toLowerCase());case"_ends":return String(t??"").toLowerCase().endsWith(String(e).toLowerCase());case"_exists":{const i=t!=null&&t!=="";return e==="true"||e==="1"||e===!0?i:!i}default:return!1}}function applyFilterInMemory(l,t){return!t||!Object.keys(t).length?l:l.filter(e=>{for(const[i,n]of Object.entries(t)){if(n==null||n==="")continue;const{field:s,op:a}=parseFilterKey(i),r=resolveField(e,s);if(!applyOp(a,r,n))return!1}return!0})}function sortEntries(l,t,e){const i=e==="asc"?1:-1;return[...l].sort((n,s)=>{const a=t==="createdAt"?n.meta?.createdAt||"":n.data?.[t]??"",r=t==="createdAt"?s.meta?.createdAt||"":s.data?.[t]??"";return a<r?-i:a>r?i:0})}function elt(l,t){const e=document.createElement(l);return t&&(e.className=t),e}function isFileRef(l){return l&&typeof l=="object"&&typeof l.url=="string"&&typeof l.name=="string"}function formatValue(l){return l==null?"":isFileRef(l)?l.name:Array.isArray(l)?l.join(", "):typeof l=="boolean"?l?"Yes":"No":String(l)}function fieldDisplay(l,t){if(t?.type==="reference"){const e=l?._refs?.[t.name];if(e!=null)return Array.isArray(e)?e.map(i=>i.missing?`${i.id} (missing)`:i.display).join(", "):e.missing?`${e.id} (missing)`:e.display}return formatValue(l?.data?.[t?.name])}function fieldDisplayNode(l,t){if(t?.type==="reference"){const i=l?._refs?.[t.name];if(i!=null){const n=document.createDocumentFragment();return(Array.isArray(i)?i:[i]).forEach((a,r)=>{if(r>0&&n.appendChild(document.createTextNode(", ")),a.missing)n.appendChild(document.createTextNode(`${a.id} (missing)`));else if(a.link){const o=document.createElement("a");o.href=a.link,o.textContent=a.display,n.appendChild(o)}else n.appendChild(document.createTextNode(a.display))}),n}}const e=l?.data?.[t?.name];if(isFileRef(e)){const i=document.createElement("a");if(i.href=e.url,String(e.mime||"").startsWith("image/")){i.target="_blank",i.rel="noopener";const n=document.createElement("img");n.src=e.url,n.alt=e.name,n.loading="lazy",n.className="dm-file-thumb",i.appendChild(n)}else i.download="",i.textContent=e.name;return i}return document.createTextNode(formatValue(e))}function debounce(l,t){let e;return(...i)=>{clearTimeout(e),e=setTimeout(()=>l(...i),t)}}function toCsv(l,t){const e=s=>{if(s==null)return"";let a=Array.isArray(s)?s.join(", "):String(s);return/[",\n\r]/.test(a)&&(a='"'+a.replace(/"/g,'""')+'"'),a},i=t.map(s=>e(s.label||s.name)).join(","),n=l.map(s=>t.map(a=>e(s.data?.[a.name])).join(",")).join(`
|
|
1
|
+
const __browsers=[];let __keyboardNavInstalled=!1;function bootstrapCollectionBrowsers(l=document){const t=[...l.querySelectorAll(".dm-collection-browser")].filter(e=>!e.__dmCollectionBrowser);t.length&&(t.forEach(e=>{e.__dmCollectionBrowser=!0;try{__browsers.push(new CollectionBrowser(e,__browsers.length))}catch(i){console.error("[collection-browser] hydration failed:",i)}}),!__keyboardNavInstalled&&__browsers.length&&(__keyboardNavInstalled=!0,installGlobalKeyboardNav()))}function installGlobalKeyboardNav(){__browsers.length&&document.addEventListener("keydown",l=>{const t=l.target&&(l.target.tagName==="INPUT"||l.target.tagName==="TEXTAREA"||l.target.isContentEditable||!!l.target.closest?.('[role="slider"]'));if(l.key==="/"&&!t){const i=__browsers[0]?.el.querySelector(".dm-cb-search-input");i&&(l.preventDefault(),i.focus(),i.select());return}if((l.key==="ArrowLeft"||l.key==="ArrowRight")&&!t){const e=__browsers.find(s=>s.el.contains(l.target))||__browsers[0];if(!e)return;const i=Math.max(1,Math.ceil(e.currentTotal/e.config.pageSize)),n=l.key==="ArrowRight"?Math.min(i,e.state.page+1):Math.max(1,e.state.page-1);n!==e.state.page&&(l.preventDefault(),e.setState({page:n}))}})}function decodePayload(l){if(!l)return null;try{const t=atob(l),e=decodeURIComponent(escape(t));return JSON.parse(e)}catch{try{return JSON.parse(atob(l))}catch{return null}}}function clear(l){l&&typeof l.replaceChildren=="function"&&l.replaceChildren()}function distinctValues(l,t){const e=new Set;for(const i of l||[]){const n=i?.data?.[t];n!=null&&(Array.isArray(n)?n.forEach(s=>s!=null&&e.add(String(s))):e.add(String(n)))}return[...e].sort()}class CollectionBrowser{constructor(t,e){this.el=t,this.config=decodePayload(t.dataset.cbConfig)||{},this.schema=decodePayload(t.dataset.cbSchema)||{fields:[]};const i=decodePayload(t.dataset.cbData)||{entries:[],total:0,page:1,pageSize:12},n=(this.config.id||`${this.config.slug}-${e}`).replace(/[^a-z0-9]/gi,"_");let s=n,a=1;for(;__browsers.some(r=>r.idScope===s);)a+=1,s=`${n}_${a}`;this.idScope=s,this.urlPrefix=`cb_${s}_`,this._fragReqId=0,this.entries=i.entries||[],this.total=i.total||0,this.state={search:"",filter:{},sort:this.config.initial?.sort||"createdAt",order:this.config.initial?.order||"desc",page:1},this.readUrlState(),this.buildSkeleton(),this.refresh()}buildSkeleton(){clear(this.el);const t=elt("div","dm-cb-header");this.config.filterable?.length&&t.appendChild(this.buildDrawerToggle()),this.config.searchable&&t.appendChild(this.buildSearchInput()),this.config.sortable&&t.appendChild(this.buildSortControl()),this.config.savedSearches!==!1&&t.appendChild(this.buildSavedSearches()),this.config.exportable&&t.appendChild(this.buildExportButton());const e=elt("div","dm-cb-layout");this.filterRail=elt("aside","dm-cb-filter-rail"),this.bodyEl=elt("div","dm-cb-body"),e.appendChild(this.filterRail),e.appendChild(this.bodyEl),this.config.filterable?.length?this.renderFilterRail():(this.filterRail.style.display="none",e.classList.add("dm-cb-layout--no-rail")),this.pagerEl=elt("div","dm-cb-pagination"),t.childElementCount&&this.el.appendChild(t),this.el.appendChild(e),this.el.appendChild(this.pagerEl),this.el.classList.add("dm-cb-hydrated")}buildSavedSearches(){const t=elt("div","dm-cb-saved"),e=elt("button","dm-cb-saved-toggle btn btn-outline");e.type="button",e.textContent="Saved \u25BE",t.appendChild(e);const i=elt("div","dm-cb-saved-menu");i.hidden=!0,t.appendChild(i);const n=()=>{clear(i);const s=this.loadSavedSearches();if(!s.length){const o=elt("p","dm-cb-saved-empty");o.textContent="No saved views yet.",i.appendChild(o)}for(const o of s){const c=elt("div","dm-cb-saved-item"),d=elt("button","dm-cb-saved-apply");d.type="button",d.textContent=o.name,d.addEventListener("click",()=>{this.state.search=o.search||"",this.state.filter={...o.filter||{}},this.state.sort=o.sort||this.config.initial?.sort||"createdAt",this.state.order=o.order||this.config.initial?.order||"desc",this.state.page=1,this.renderFilterRail();const p=this.el.querySelector(".dm-cb-search-input");p&&(p.value=this.state.search),i.hidden=!0,this.refresh()});const h=elt("button","dm-cb-saved-del");h.type="button",h.textContent="\xD7",h.title="Delete saved view",h.addEventListener("click",p=>{p.stopPropagation(),this.deleteSavedSearch(o.name),n()}),c.appendChild(d),c.appendChild(h),i.appendChild(c)}const a=elt("div","dm-cb-saved-actions"),r=elt("button","dm-cb-saved-create btn btn-primary");r.type="button",r.textContent="Save current view",r.addEventListener("click",async()=>{const o=await this.promptName();o&&(this.addSavedSearch({name:o,search:this.state.search,filter:this.state.filter,sort:this.state.sort,order:this.state.order}),n())}),a.appendChild(r),i.appendChild(a)};return e.addEventListener("click",()=>{i.hidden=!i.hidden,i.hidden||n()}),document.addEventListener("click",s=>{t.contains(s.target)||(i.hidden=!0)}),t}async promptName(){const t=typeof window<"u"&&typeof window.prompt=="function"?window.prompt("Name this saved view:"):null;return t&&t.trim()||null}loadSavedSearches(){try{const t=`cb_saved_${this.idScope}`,e=typeof S<"u"&&S.get?S.get(t):null;return Array.isArray(e)?e:[]}catch{return[]}}addSavedSearch(t){const e=this.loadSavedSearches().filter(i=>i.name!==t.name);e.push(t);try{typeof S<"u"&&S.set&&S.set(`cb_saved_${this.idScope}`,e)}catch{}}deleteSavedSearch(t){const e=this.loadSavedSearches().filter(i=>i.name!==t);try{typeof S<"u"&&S.set&&S.set(`cb_saved_${this.idScope}`,e)}catch{}}buildExportButton(){const t=elt("button","dm-cb-export btn btn-outline");return t.type="button",t.textContent="Export CSV",t.addEventListener("click",()=>this.exportCsv()),t}exportCsv(){if(this.config.mode==="client"){let n=this.entries;if(this.state.search){const o=this.state.search.toLowerCase();n=n.filter(c=>Object.values(c.data||{}).some(d=>String(d).toLowerCase().includes(o)))}const s={...this.state.filter,...this.config.baked||{}};n=applyFilterInMemory(n,s);const a=this.visibleFields(n),r=toCsv(n,a);downloadCsv(`${this.config.slug}-export.csv`,r);return}const t=new URLSearchParams;t.set("format","csv"),this.state.search&&t.set("search",this.state.search);const e={...this.state.filter,...this.config.baked||{}};for(const[n,s]of Object.entries(e))t.set(`filter[${n}]`,s);const i=`/api/collections/${encodeURIComponent(this.config.slug)}/export?${t.toString()}`;window.open(i,"_blank")}buildDrawerToggle(){const t=elt("button","dm-cb-drawer-toggle btn btn-outline");t.type="button",t.setAttribute("aria-label","Toggle filters");const e=elt("span","dm-cb-drawer-label");e.textContent="Filters";const i=elt("span","dm-cb-drawer-count");return t.appendChild(e),t.appendChild(document.createTextNode(" ")),t.appendChild(i),t.addEventListener("click",()=>{this.el.classList.toggle("dm-cb-drawer-open")}),t}buildSearchInput(){const t=elt("div","dm-cb-search"),e=elt("input","dm-cb-search-input");return e.type="search",e.placeholder="Search\u2026",e.value=this.state.search,e.addEventListener("input",debounce(()=>{this.setState({search:e.value,page:1})},200)),t.appendChild(e),t}buildSortControl(){const t=elt("div","dm-cb-sort"),e=elt("label","dm-cb-sort-label");e.textContent="Sort:",t.appendChild(e);const i=elt("select","dm-cb-sort-select"),n=this.sortableFieldList();for(const a of n){const r=elt("option");r.value=a.name,r.textContent=a.label,a.name===this.state.sort&&(r.selected=!0),i.appendChild(r)}i.addEventListener("change",()=>this.setState({sort:i.value,page:1})),t.appendChild(i);const s=elt("button","dm-cb-sort-dir");return s.type="button",s.textContent=this.state.order==="asc"?"\u2191":"\u2193",s.title=this.state.order==="asc"?"Ascending":"Descending",s.addEventListener("click",()=>{this.setState({order:this.state.order==="asc"?"desc":"asc",page:1}),s.textContent=this.state.order==="asc"?"\u2191":"\u2193"}),t.appendChild(s),t}sortableFieldList(){const t=this.config.sortableFields?.length?new Set(this.config.sortableFields):null,e=[{name:"createdAt",label:"Most recent"}];for(const i of this.schema.fields||[])t&&!t.has(i.name)||e.push({name:i.name,label:i.label||i.name});return e}renderFilterRail(){for(const i of this._sliders||[])i.destroy();this._sliders=[],clear(this.filterRail);const t=elt("h4","dm-cb-filter-heading");t.textContent="Filters",this.filterRail.appendChild(t);for(const i of this.config.filterable){const n=(this.schema.fields||[]).find(a=>a.name===i);if(!n)continue;const s=this.buildFilterControl(n);s&&this.filterRail.appendChild(s)}const e=elt("button","dm-cb-filter-reset");e.type="button",e.textContent="Clear filters",e.addEventListener("click",()=>{this.setState({filter:{},search:"",page:1}),this.renderFilterRail();const i=this.el.querySelector(".dm-cb-search-input");i&&(i.value=""),this.filterRail.querySelector(".dm-cb-filter-reset")?.focus()}),this.filterRail.appendChild(e)}buildFilterControl(t){const e=elt("div","dm-cb-filter"),i=elt("label","dm-cb-filter-label");switch(i.textContent=t.label||t.name,e.appendChild(i),t.type){case"reference":e.appendChild(this.buildReferenceFilter(t));break;case"select":case"chooser":e.appendChild(this.buildSelectControl(t,!1));break;case"multiselect":case"tags":case"tag":e.appendChild(this.buildSelectControl(t,!0));break;case"number":e.appendChild(this.buildRangeControl(t,"number"));break;case"date":case"datetime":e.appendChild(this.buildRangeControl(t,"date"));break;case"boolean":case"checkbox":e.appendChild(this.buildBooleanControl(t));break;default:e.appendChild(this.buildTextControl(t));break}return e}buildReferenceFilter(t){const e=new Map;for(const a of this.entries){const r=a._refs?.[t.name];if(!r)continue;const o=Array.isArray(r)?r:[r];for(const c of o)!c||c.missing||e.has(c.id)||e.set(c.id,c.display)}const i=`${t.name}_eq`,n=elt("select","dm-cb-select"),s=elt("option");s.value="",s.textContent=this.config.mode==="server"?"Any (loaded)":"Any",n.appendChild(s);for(const[a,r]of e){const o=elt("option");o.value=a,o.textContent=r,String(this.state.filter[i]??"")===String(a)&&(o.selected=!0),n.appendChild(o)}return n.addEventListener("change",()=>this.updateFilter(i,n.value)),n}buildTextControl(t){const e=`${t.name}_contains`,i=elt("input","dm-cb-text");return i.type="text",i.placeholder="Contains\u2026",i.value=this.state.filter[e]||"",i.addEventListener("input",debounce(()=>{this.updateFilter(e,i.value.trim())},200)),i}buildSelectControl(t,e){const i=Array.isArray(t.options)&&t.options.length?t.options.map(o=>typeof o=="object"?o:{value:o,label:o}):distinctValues(this.entries,t.name).map(o=>({value:o,label:o})),n=this.config.mode==="client"?this.facetCounts(t.name,e?"_in":"_eq",i.map(o=>o.value)):null;if(e){const o=`${t.name}_in`,c=elt("div","dm-cb-chips"),d=new Set((this.state.filter[o]||"").split(",").filter(Boolean));for(const h of i){const p=elt("button","dm-cb-chip");p.type="button",d.has(String(h.value))&&p.classList.add("dm-cb-chip-active");const f=elt("span","dm-cb-chip-label");if(f.textContent=h.label??h.value,p.appendChild(f),n){const u=elt("span","dm-cb-chip-count");u.textContent=n[String(h.value)]??0,p.appendChild(u)}p.addEventListener("click",()=>{d.has(String(h.value))?d.delete(String(h.value)):d.add(String(h.value)),this.updateFilter(o,d.size?[...d].join(","):"")}),c.appendChild(p)}return c}const s=`${t.name}_eq`,a=elt("select","dm-cb-select"),r=elt("option");r.value="",r.textContent="Any",a.appendChild(r);for(const o of i){const c=elt("option");c.value=o.value;const d=n?` (${n[String(o.value)]??0})`:"";c.textContent=(o.label??o.value)+d,String(this.state.filter[s]??"")===String(o.value)&&(c.selected=!0),a.appendChild(c)}return a.addEventListener("change",()=>this.updateFilter(s,a.value)),a}facetCounts(t,e,i){const n={};for(const[o,c]of Object.entries(this.state.filter||{})){const{field:d}=parseFilterKey(o);d!==t&&(n[o]=c)}let s=this.entries;if(this.state.search){const o=this.state.search.toLowerCase();s=s.filter(c=>Object.values(c.data||{}).some(d=>String(d).toLowerCase().includes(o)))}const a={...n,...this.config.baked||{}};s=applyFilterInMemory(s,a);const r={};for(const o of i){const c={...a,[`${t}${e}`]:String(o)};r[String(o)]=applyFilterInMemory(s,c).length}return r}buildRangeControl(t,e){const i=`${t.name}_gte`,n=`${t.name}_lte`,s=elt("div","dm-cb-range"),a=elt("div","dm-cb-range-inputs"),r=elt("input","dm-cb-range-min"),o=elt("input","dm-cb-range-max");r.type=e,o.type=e,r.placeholder="Min",o.placeholder="Max",r.value=this.state.filter[i]||"",o.value=this.state.filter[n]||"",a.appendChild(r),a.appendChild(document.createTextNode(" - ")),a.appendChild(o),s.appendChild(a);let c=null,d=null,h=null;const p=window.DommaCollectionRange;if(e==="number"&&this.config.mode==="client"&&this.entries.length&&p&&typeof E<"u"&&E.rangeSlider&&(d=p.rangeBounds(this.entries.map(u=>u.data?.[t.name]))),d){const u=elt("div","dm-cb-slider");s.appendChild(u);const g=t.label||t.name,m=b=>{const C=p.rangeFilter(d,b);(!h||b[0]!==h[0])&&(r.value=C.gte),(!h||b[1]!==h[1])&&(o.value=C.lte)};c=E.rangeSlider(u,{range:!0,min:d.min,max:d.max,step:d.step,value:p.sliderValue(d,r.value,o.value),labels:p.rangeLabel(t,d.step),ariaLabels:[`${g} from`,`${g} to`],onInput:m,onChange:b=>{m(b),h=b.slice(),this.updateFilter(i,r.value,!0),this.updateFilter(n,o.value)}}),h=c.getValue().slice(),this._sliders.push(c)}const f=debounce(()=>{this.updateFilter(i,r.value,!0),this.updateFilter(n,o.value),c&&(c.setValue(p.sliderValue(d,r.value,o.value),{silent:!0}),h=c.getValue().slice())},250);return r.addEventListener("input",f),o.addEventListener("input",f),s}buildBooleanControl(t){const e=`${t.name}_eq`,i=elt("select","dm-cb-select");for(const[n,s]of[["","Any"],["true","Yes"],["false","No"]]){const a=elt("option");a.value=n,a.textContent=s,String(this.state.filter[e]??"")===n&&(a.selected=!0),i.appendChild(a)}return i.addEventListener("change",()=>this.updateFilter(e,i.value)),i}updateFilter(t,e,i=!1){const n={...this.state.filter};e===""||e==null?delete n[t]:n[t]=e,this.state.filter=n,this.state.page=1,i||this.refresh()}setState(t){Object.assign(this.state,t),this.refresh()}async refresh(){this.config.syncUrl&&this.writeUrlState(),this.config.mode==="server"&&await this.fetchPage(),this.renderBody(),this.renderPagination(),this.updateFacetCounts(),this.updateDrawerBadge()}updateFacetCounts(){if(this.config.mode==="client"&&this.filterRail)for(const t of this.config.filterable||[]){const e=(this.schema.fields||[]).find(r=>r.name===t);if(!e)continue;const i=e.type==="multiselect"||e.type==="tags"||e.type==="tag"?"_in":"_eq",n=Array.isArray(e.options)&&e.options.length?e.options.map(r=>typeof r=="object"?r:{value:r,label:r}):distinctValues(this.entries,t).map(r=>({value:r,label:r})),s=this.facetCounts(t,i,n.map(r=>r.value)),a=this.filterRail.querySelectorAll(".dm-cb-filter");for(const r of a){const o=r.querySelector(".dm-cb-filter-label");if(!o||o.textContent!==(e.label||e.name))continue;r.querySelectorAll(".dm-cb-chip").forEach((h,p)=>{const f=h.querySelector(".dm-cb-chip-count");f&&n[p]&&(f.textContent=s[String(n[p].value)]??0)});const d=r.querySelector("select.dm-cb-select");d&&Array.from(d.options).forEach(h=>{if(!h.value)return;const p=n.find(f=>String(f.value)===h.value)?.label??h.value;h.textContent=`${p} (${s[h.value]??0})`})}}}updateDrawerBadge(){const t=this.el.querySelector(".dm-cb-drawer-toggle");if(!t)return;const e=(this.state.search?1:0)+Object.keys(this.state.filter||{}).length,i=t.querySelector(".dm-cb-drawer-count");i&&(i.textContent=e>0?`(${e})`:"")}async fetchPage(){const t={...this.state.filter,...this.config.baked||{}},e=new URLSearchParams;e.set("page",this.state.page),e.set("limit",this.config.pageSize),e.set("sort",this.state.sort),e.set("order",this.state.order),this.state.search&&e.set("search",this.state.search);for(const[n,s]of Object.entries(t))e.set(`filter[${n}]`,s);this.config.scope==="mine"&&e.set("scope","mine"),this._fetchAbort&&this._fetchAbort.abort(),this._fetchAbort=new AbortController;const i=this.config.sourceKind==="view"?`/api/views/${encodeURIComponent(this.config.slug)}/public?${e.toString()}`:`/api/collections/${encodeURIComponent(this.config.slug)}/public?${e.toString()}`;try{const n=await fetch(i,{headers:this.authHeaders(),signal:this._fetchAbort.signal});if(!n.ok){this.entries=[],this.total=0;return}const s=await n.json(),a=s.entries||s.results||[];this.entries=a.map(r=>r.data?r:{id:r.id||"",data:r.data||r}),this.total=s.total||a.length}catch(n){if(n.name==="AbortError")return;this.entries=[],this.total=0}}authHeaders(){try{const t=typeof S<"u"&&S.get?S.get("auth_token"):null;return t?{Authorization:`Bearer ${t}`}:{}}catch{return{}}}pipeline(){if(this.config.mode==="server")return{visible:this.entries,total:this.total};let t=this.entries,e=null;if(this.state.search){const c=this.state.search.toLowerCase();e=new Map,t=t.filter(d=>{let h=0;for(const[p,f]of Object.entries(d.data||{})){if(f==null)continue;const u=String(f).toLowerCase();let g=0,m=0;for(;(g=u.indexOf(c,g))!==-1;)m++,g+=c.length;m>0&&(h+=m*(p===this.config.titleField?3:1))}return h>0&&e.set(d.id||d,h),h>0})}if(Object.keys(this.state.filter).length||Object.keys(this.config.baked||{}).length){const c={...this.state.filter,...this.config.baked||{}};t=applyFilterInMemory(t,c)}const i=this.config.initial?.sort||"createdAt",n=this.config.initial?.order||"desc",s=this.state.sort===i&&this.state.order===n;this.state.search&&e&&s?(t=[...t].sort((c,d)=>{const h=e.get(c.id||c)||0;return(e.get(d.id||d)||0)-h}),this._activeSortMode="relevance"):(t=sortEntries(t,this.state.sort,this.state.order),this._activeSortMode=null);const a=t.length,r=(this.state.page-1)*this.config.pageSize;return{visible:t.slice(r,r+this.config.pageSize),total:a}}renderBody(){const{visible:t,total:e}=this.pipeline();if(this.currentTotal=e,clear(this.bodyEl),!t.length){this.bodyEl.appendChild(this.buildEmptyState());return}const i=this.visibleFields(t);this.bodyEl.appendChild(this.renderForDisplay(t,i)),typeof Domma<"u"&&Domma.icons?.scan&&Domma.icons.scan(this.bodyEl),this.config.cta&&typeof wireCTAButtons=="function"&&wireCTAButtons(this.bodyEl)}buildEmptyState(){const t=elt("div","dm-collection-display dm-collection-empty"),e=!!this.state.search||Object.keys(this.state.filter||{}).length>0,i=elt("p");if(e){i.textContent="No results for these filters.",t.appendChild(i);const n=elt("button","btn btn-outline dm-cb-empty-clear");n.type="button",n.textContent="Clear filters",n.addEventListener("click",()=>{this.setState({filter:{},search:"",page:1}),this.renderFilterRail();const s=this.el.querySelector(".dm-cb-search-input");s&&(s.value="")}),t.appendChild(n)}else i.textContent=this.config.emptyMsg,t.appendChild(i);return t}visibleFields(t){let e=this.schema.fields||[];return this.config.fields?.length&&(e=this.config.fields.map(i=>e.find(n=>n.name===i)||{name:i,label:i})),!e.length&&t.length&&(e=Object.keys(t[0].data||{}).map(i=>({name:i,label:i}))),e}renderCards(t,e){const i=elt("div",`dm-collection-cards grid grid-cols-${this.config.columns}`);for(const n of t){const s=elt("div","card dm-collection-card"),a=e.find(c=>c.name===this.config.titleField),r=a?fieldDisplay(n,a):this.config.titleField?formatValue(n.data?.[this.config.titleField]):"";if(r){const c=elt("div","card-header");c.textContent=r,s.appendChild(c)}const o=elt("div","card-body");for(const c of e){if(this.config.titleField===c.name||!fieldDisplay(n,c))continue;const h=elt("div","dm-collection-card-field"),p=elt("strong");p.textContent=(c.label||c.name)+": ",h.appendChild(p),h.appendChild(fieldDisplayNode(n,c)),o.appendChild(h)}this.config.cta&&o.appendChild(this.buildCtaButton(n)),this.config.transitions&&o.appendChild(this.buildTransitionsGroup(n)),s.appendChild(o),i.appendChild(s)}return i}renderList(t,e){const i=elt("ul","dm-collection-list");for(const n of t){const s=elt("li","dm-collection-list-item"),a=e.find(c=>c.name===this.config.titleField),r=a?fieldDisplay(n,a):this.config.titleField?formatValue(n.data?.[this.config.titleField]):"";if(r){const c=elt("div","dm-collection-list-title");c.textContent=r,s.appendChild(c)}const o=e.filter(c=>c.name!==this.config.titleField).map(c=>{const d=fieldDisplay(n,c);return d?`${c.label||c.name}: ${d}`:""}).filter(Boolean).join(" \xB7 ");if(o){const c=elt("div","dm-collection-list-meta");c.textContent=o,s.appendChild(c)}this.config.cta&&s.appendChild(this.buildCtaButton(n)),this.config.transitions&&s.appendChild(this.buildTransitionsGroup(n)),i.appendChild(s)}return i}renderTable(t,e){const i=elt("table","dm-collection-table"),n=elt("thead"),s=elt("tr");for(const r of e){const o=elt("th");o.textContent=r.label||r.name,s.appendChild(o)}this.config.cta&&s.appendChild(elt("th")),this.config.transitions&&s.appendChild(elt("th")),n.appendChild(s),i.appendChild(n);const a=elt("tbody");for(const r of t){const o=elt("tr");for(const c of e){const d=elt("td");d.appendChild(fieldDisplayNode(r,c)),o.appendChild(d)}if(this.config.cta){const c=elt("td");c.appendChild(this.buildCtaButton(r)),o.appendChild(c)}if(this.config.transitions){const c=elt("td");c.appendChild(this.buildTransitionsGroup(r)),o.appendChild(c)}a.appendChild(o)}return i.appendChild(a),i}renderAccordion(t){const e=elt("div","accordion dm-collection-accordion");for(const i of t){const n=elt("div","accordion-item"),s=this.config.titleField&&i.data?.[this.config.titleField]||"Untitled",a=this.config.bodyField&&i.data?.[this.config.bodyField]||"",r=elt("button","accordion-header");r.type="button",r.textContent=String(s);const o=elt("div","accordion-panel");o.textContent=String(a),r.addEventListener("click",()=>n.classList.toggle("open")),n.appendChild(r),n.appendChild(o),e.appendChild(n)}return e}buildCtaButton(t){const e=this.config.cta,i=elt("button",`btn btn-${e.style||"primary"} dm-cta-trigger`);if(i.dataset.action=e.action,i.dataset.entry=t.id||"",this.config.scope&&(i.dataset.scope=this.config.scope),e.confirm&&(i.dataset.confirm=e.confirm),e.icon){const n=elt("span");n.dataset.icon=e.icon,i.appendChild(n),i.appendChild(document.createTextNode(" "))}return i.appendChild(document.createTextNode(e.label||"Run")),i}buildTransitionsGroup(t){const e=elt("div","dm-cb-transitions");return e.dataset.entry=t.id||"",e.textContent="Loading actions\u2026",Promise.resolve().then(()=>this.loadTransitions(t,e)),e}async loadTransitions(t,e){try{const i=new URLSearchParams({collection:this.config.slug,entryId:t.id||""});this.config.scope==="mine"&&i.set("scope","mine");const n=await fetch(`/api/actions/transitions?${i.toString()}`,{headers:this.authHeaders()});if(clear(e),!n.ok)return;const{transitions:s}=await n.json();if(!Array.isArray(s)||!s.length)return;for(const a of s){const r=elt("button",`btn btn-${a.trigger?.style||"outline"} dm-cb-transition-btn dm-cta-trigger`);if(r.dataset.action=a.slug,r.dataset.entry=t.id||"",this.config.scope&&(r.dataset.scope=this.config.scope),a.trigger?.confirmMessage&&(r.dataset.confirm=a.trigger.confirmMessage),a.trigger?.icon){const o=elt("span");o.dataset.icon=a.trigger.icon,r.appendChild(o),r.appendChild(document.createTextNode(" "))}r.appendChild(document.createTextNode(a.trigger?.label||a.title)),e.appendChild(r)}typeof Domma<"u"&&Domma.icons?.scan&&Domma.icons.scan(e),typeof wireCTAButtons=="function"&&wireCTAButtons(e)}catch{clear(e)}}renderPagination(){if(this.config.pagination==="scroll"){this.renderInfiniteSentinel();return}const t=Math.max(1,Math.ceil(this.currentTotal/this.config.pageSize));if(clear(this.pagerEl),t<=1)return;const e=elt("button","dm-cb-page-prev btn btn-outline");e.type="button",e.textContent="\u2039 Prev",e.disabled=this.state.page<=1,e.addEventListener("click",()=>this.setState({page:Math.max(1,this.state.page-1)}));const i=elt("button","dm-cb-page-next btn btn-outline");i.type="button",i.textContent="Next \u203A",i.disabled=this.state.page>=t,i.addEventListener("click",()=>this.setState({page:Math.min(t,this.state.page+1)}));const n=elt("span","dm-cb-page-info");n.textContent=`Page ${this.state.page} of ${t} (${this.currentTotal} entr${this.currentTotal===1?"y":"ies"})`,this.pagerEl.appendChild(e),this.pagerEl.appendChild(n),this.pagerEl.appendChild(i)}renderInfiniteSentinel(){clear(this.pagerEl);const t=Math.max(1,Math.ceil(this.currentTotal/this.config.pageSize));if(this.state.page>=t){const i=elt("p","dm-cb-scroll-end");i.textContent=`All ${this.currentTotal} entries loaded.`,this.pagerEl.appendChild(i);return}const e=elt("div","dm-cb-scroll-sentinel");e.setAttribute("aria-hidden","true"),e.textContent="Loading more\u2026",this.pagerEl.appendChild(e),this._scrollObserver&&this._scrollObserver.disconnect(),this._scrollObserver=new IntersectionObserver(async i=>{i[0].isIntersecting&&(this._scrollObserver.disconnect(),await this.loadMore())},{rootMargin:"200px 0px"}),this._scrollObserver.observe(e)}async loadMore(){const t=this.state.page+1,e=this.currentTotal,i=this.entries,n=this.state.page;this.state.page=t,this.config.syncUrl&&this.writeUrlState();let s;if(this.config.mode==="server")await this.fetchPage(),s=this.entries;else{const{visible:c}=this.pipeline();s=c}if(!s.length){this.state.page=n,this.entries=i,this.currentTotal=e,this.renderPagination();return}const a=this.visibleFields(s),r=this.renderForDisplay(s,a),o=this.bodyEl.firstElementChild;if(o&&o.tagName===r.tagName)for(;r.firstChild;)o.appendChild(r.firstChild);else this.bodyEl.appendChild(r);typeof Domma<"u"&&Domma.icons?.scan&&Domma.icons.scan(this.bodyEl),this.config.cta&&typeof wireCTAButtons=="function"&&wireCTAButtons(this.bodyEl),this.renderPagination()}renderForDisplay(t,e){const i=this.config.display;return i==="list"?this.renderList(t,e):i==="table"?this.renderTable(t,e):i==="accordion"?this.renderAccordion(t):i==="timeline"?this.renderTimeline(t):i==="block"?this.renderBlockPlaceholder(t):this.renderCards(t,e)}renderTimeline(t){const e=["vertical","centred","horizontal"].includes(this.config.layout)?this.config.layout:"vertical",i=["minimal","corporate","modern"].includes(this.config.theme)?this.config.theme:"minimal",n=elt("div",`dm-collection-timeline timeline timeline-${e} timeline-${i}`);for(const s of t){const a=elt("div","timeline-event"),r=this.config.dateField&&s.data?.[this.config.dateField]||"",o=this.config.titleField&&s.data?.[this.config.titleField]||"",c=this.config.bodyField&&s.data?.[this.config.bodyField]||"",d=this.config.statusField&&s.data?.[this.config.statusField]||"",h=this.config.iconField&&s.data?.[this.config.iconField]||"";if(h){const p=elt("span","timeline-icon");p.dataset.icon=String(h),a.appendChild(p)}if(r){const p=elt("div","timeline-date");p.textContent=String(r),a.appendChild(p)}if(o){const p=elt("h4","timeline-title");p.textContent=String(o),a.appendChild(p)}if(d){const p=elt("span",`badge badge-${d}`);p.textContent=String(d),a.appendChild(p)}if(c){const p=elt("div","timeline-body");p.textContent=String(c),a.appendChild(p)}n.appendChild(a)}return n}renderBlockPlaceholder(t){const e=elt("div","dm-collection-display dm-cb-block-loading");return e.textContent="Rendering\u2026",this.fetchBlockFragment(t,e),e}async fetchBlockFragment(t,e){const i=++this._fragReqId,n=t.map(r=>r.id).filter(Boolean),s={slug:this.config.slug,display:"block",block:this.config.block,"title-field":this.config.titleField,"body-field":this.config.bodyField,fields:this.config.fields?this.config.fields.join(","):"",empty:this.config.emptyMsg,limit:String(n.length||1)},a={...this.state.filter,...this.config.baked||{}};for(const[r,o]of Object.entries(a))o!==""&&o!=null&&(s[`where_${r}`]=String(o));s.sort=this.state.sort,s.order=this.state.order,s.limit=String(this.config.pageSize);try{const r=btoa(unescape(encodeURIComponent(JSON.stringify(s)))),o=this.config.scope==="mine"?"/api/collections/render-scope":"/api/collections/render-fragment",c=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders()},body:JSON.stringify({attrs:r,page:this.state.page})});if(i!==this._fragReqId)return;if(!c.ok){e.textContent=this.config.emptyMsg;return}const{html:d}=await c.json(),h=document.createElement("template");h.innerHTML=d||"",e.replaceWith(h.content)}catch{e.textContent="Unable to load block view."}}readUrlState(){if(!this.config.syncUrl)return;const t=new URLSearchParams(window.location.search),e=this.urlPrefix,i=a=>t.get(e+a);i("search")&&(this.state.search=i("search")),i("sort")&&(this.state.sort=i("sort")),i("order")&&(this.state.order=i("order")),i("page")&&(this.state.page=parseInt(i("page"),10)||1);const n={},s=`${e}filter[`;for(const[a,r]of t.entries())if(a.startsWith(s)&&a.endsWith("]")){const o=a.slice(s.length,-1);o&&(n[o]=r)}Object.keys(n).length&&(this.state.filter=n)}writeUrlState(){const t=new URL(window.location.href),e=this.urlPrefix,i=[];for(const s of t.searchParams.keys())s.startsWith(e)&&i.push(s);i.forEach(s=>t.searchParams.delete(s));const n=(s,a)=>{a!==""&&a!=null&&t.searchParams.set(e+s,a)};n("search",this.state.search),this.state.sort!==(this.config.initial?.sort||"createdAt")&&n("sort",this.state.sort),this.state.order!==(this.config.initial?.order||"desc")&&n("order",this.state.order),this.state.page!==1&&n("page",this.state.page);for(const[s,a]of Object.entries(this.state.filter))a!==""&&a!=null&&t.searchParams.set(`${e}filter[${s}]`,a);try{window.history.replaceState({},"",t.toString())}catch{}}}const OPERATORS=["_eq","_ne","_gte","_lte","_gt","_lt","_in","_nin","_contains","_starts","_ends","_exists"];function parseFilterKey(l){for(const t of OPERATORS)if(l.endsWith(t))return{field:l.slice(0,-t.length),op:t};return{field:l,op:"_eq"}}function resolveField(l,t){if(t==="createdBy")return l.meta?.createdBy;if(t==="id")return l.id;const e=t.split(".");let i=l.data;for(const n of e){if(i==null)return;i=i[n]}return i}function maybeNumber(l){if(typeof l=="number"||typeof l!="string")return l;const t=Number(l);return Number.isFinite(t)&&String(t)===l.trim()?t:l}function applyOp(l,t,e){switch(l){case"_eq":{const i=maybeNumber(t),n=maybeNumber(e);return Array.isArray(t)?t.map(maybeNumber).includes(n):i===n||String(i)===String(n)}case"_ne":{const i=maybeNumber(t),n=maybeNumber(e);return Array.isArray(t)?!t.map(maybeNumber).includes(n):!(i===n||String(i)===String(n))}case"_gt":return maybeNumber(t)>maybeNumber(e);case"_gte":return maybeNumber(t)>=maybeNumber(e);case"_lt":return maybeNumber(t)<maybeNumber(e);case"_lte":return maybeNumber(t)<=maybeNumber(e);case"_in":{const i=String(e).split(",").map(n=>maybeNumber(n.trim()));return Array.isArray(t)?t.map(maybeNumber).some(n=>i.includes(n)):i.includes(maybeNumber(t))}case"_nin":{const i=String(e).split(",").map(n=>maybeNumber(n.trim()));return Array.isArray(t)?!t.map(maybeNumber).some(n=>i.includes(n)):!i.includes(maybeNumber(t))}case"_contains":return String(t??"").toLowerCase().includes(String(e).toLowerCase());case"_starts":return String(t??"").toLowerCase().startsWith(String(e).toLowerCase());case"_ends":return String(t??"").toLowerCase().endsWith(String(e).toLowerCase());case"_exists":{const i=t!=null&&t!=="";return e==="true"||e==="1"||e===!0?i:!i}default:return!1}}function applyFilterInMemory(l,t){return!t||!Object.keys(t).length?l:l.filter(e=>{for(const[i,n]of Object.entries(t)){if(n==null||n==="")continue;const{field:s,op:a}=parseFilterKey(i),r=resolveField(e,s);if(!applyOp(a,r,n))return!1}return!0})}function sortEntries(l,t,e){const i=e==="asc"?1:-1;return[...l].sort((n,s)=>{const a=t==="createdAt"?n.meta?.createdAt||"":n.data?.[t]??"",r=t==="createdAt"?s.meta?.createdAt||"":s.data?.[t]??"";return a<r?-i:a>r?i:0})}function elt(l,t){const e=document.createElement(l);return t&&(e.className=t),e}function safeHref(l){const t=String(l??"").trim();return/^(?:https?:|mailto:|tel:)/i.test(t)?t:/^[a-z][a-z0-9+.-]*:/i.test(t.replace(/[\u0000-\u0020]/g,""))?"#":t||"#"}function isFileRef(l){return l&&typeof l=="object"&&typeof l.url=="string"&&typeof l.name=="string"}function formatValue(l){return l==null?"":isFileRef(l)?l.name:Array.isArray(l)?l.join(", "):typeof l=="boolean"?l?"Yes":"No":String(l)}function fieldDisplay(l,t){if(t?.type==="reference"){const e=l?._refs?.[t.name];if(e!=null)return Array.isArray(e)?e.map(i=>i.missing?`${i.id} (missing)`:i.display).join(", "):e.missing?`${e.id} (missing)`:e.display}return formatValue(l?.data?.[t?.name])}function fieldDisplayNode(l,t){if(t?.type==="reference"){const i=l?._refs?.[t.name];if(i!=null){const n=document.createDocumentFragment();return(Array.isArray(i)?i:[i]).forEach((a,r)=>{if(r>0&&n.appendChild(document.createTextNode(", ")),a.missing)n.appendChild(document.createTextNode(`${a.id} (missing)`));else if(a.link){const o=document.createElement("a");o.href=safeHref(a.link),o.textContent=a.display,n.appendChild(o)}else n.appendChild(document.createTextNode(a.display))}),n}}const e=l?.data?.[t?.name];if(isFileRef(e)){const i=document.createElement("a");if(i.href=safeHref(e.url),String(e.mime||"").startsWith("image/")){i.target="_blank",i.rel="noopener";const n=document.createElement("img");n.src=e.url,n.alt=e.name,n.loading="lazy",n.className="dm-file-thumb",i.appendChild(n)}else i.download="",i.textContent=e.name;return i}return document.createTextNode(formatValue(e))}function debounce(l,t){let e;return(...i)=>{clearTimeout(e),e=setTimeout(()=>l(...i),t)}}function toCsv(l,t){const e=s=>{if(s==null)return"";let a=Array.isArray(s)?s.join(", "):String(s);return/[",\n\r]/.test(a)&&(a='"'+a.replace(/"/g,'""')+'"'),a},i=t.map(s=>e(s.label||s.name)).join(","),n=l.map(s=>t.map(a=>e(s.data?.[a.name])).join(",")).join(`
|
|
2
2
|
`);return i+`
|
|
3
3
|
`+n+`
|
|
4
4
|
`}function downloadCsv(l,t){const e=new Blob([t],{type:"text/csv;charset=utf-8"}),i=URL.createObjectURL(e),n=document.createElement("a");n.href=i,n.download=l,document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(i),1e3)}window.DommaCollectionBrowser={hydrate:bootstrapCollectionBrowsers},bootstrapCollectionBrowsers();
|
package/public/js/site.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{applyMobileMenu as ae,initCarouselPopup as ie}from"/public/js/mobile-ui.mjs?v=20261016-mobile-options";import{installSmoothCarets as re}from"/public/js/smooth-caret.js";import{decodeBase64Json as V}from"/public/js/utf8-base64.mjs";import{makeBadgeEl as U,applyColour as G,applyPill as ce,applyFloat as le,applyHighlight as Y,applyItemHighlight as de,itemHighlightAttrs as me,currentItems as K,menuAlign as ue,applyClasses as P,cssClasses as X,applyEntrance as J}from"/public/js/menu-decor.mjs?v=20261109-current-query";import{applyMenuLook as pe,applyFooterLook as fe}from"/public/js/menu-cards.mjs?v=20261115-rich-captions";import{initPageMotion as he}from"/public/js/page-motion.mjs?v=20261029-page-motion";import{applyFooterShowcase as ge}from"/public/js/footer-showcase.mjs?v=20261029-footer-showcase";import{initFloatingMenus as ye}from"/public/js/menu-float.js?v=20260927-float";import{enhancePickerFields as Q,markInvalidFields as Z,showValidationPopup as ee}from"/public/js/forms.js?v=20261109-form-embed";import{buildWizardSteps as ve}from"/public/js/form-steps.mjs";import{mountMotionControl as be}from"/public/js/motion-control.mjs?v=20261031-launchers";import{applyFormClasses as te,applyFormEntrance as oe,applySubmitButtons as we,applyWizardButtons as Ce}from"/public/js/form-submit.mjs";import{captureFileFields as ne,destroyDropzones as Se,fileBlueprint as xe,restoreFileFields as ke,setFileLimits as Le,splitFiles as $e,submitBody as Ee,totalTooLarge as Ae,wireFileFields as Te}from"/public/js/form-files.mjs";document.addEventListener("click",d=>{const r=d.target?.closest?.(".dm-banner__dismiss");r&&(d.preventDefault(),r.closest(".dm-banner")?.remove())}),$(()=>{re(document);const d=window.__CMS_NAV__||{},r=window.__CMS_SITE__||{},q=r.brandingEnabled!==!1&&d.brand?.enabled!==!1;if(r.autoTheme?.enabled){let o=function(c){const p=(c||"07:00").split(":");return+p[0]*60+(+p[1]||0)},e=function(){const c=new Date,p=c.getHours()*60+c.getMinutes();return p>=o(a.dayStart)&&p<o(a.nightStart)?a.dayTheme:a.nightTheme},t=function(c){if(window.CMSThemeSwitcher?.hasPreference())return;const p=a.apply&&a.apply[c]||{theme:c,custom:""};Domma.theme.set(p.theme);for(const n of[...document.body.classList])n.startsWith("dm-custom-")&&document.body.classList.remove(n);p.custom&&document.body.classList.add(p.custom)};const a=r.autoTheme;t(e()),setInterval(()=>t(e()),6e4)}const x=$("#site-navbar");if(x.length&&d.brand){let e=function(l,v=0){return Array.isArray(l)?l.filter(m=>!(m&&(m.type==="spacer"||m.type==="theme-switcher"))).filter(m=>!(m&&m.type==="separator"&&v===0)).map(m=>m&&m.type==="separator"?{divider:!0}:Array.isArray(m?.items)?{...m,items:e(m.items,v+1)}:m):l};const a={...d.brand},o=a.size&&a.size!=="md"?` navbar-brand-${a.size}`:"";if(a.logo||a.icon||a.tagline){let l="";a.logo?l+=`<img src="${a.logo}" class="navbar-brand-logo" alt="${a.text||""}">`:a.icon&&(l+=`<span data-icon="${a.icon}" style="width:1.1em;height:1.1em;margin-right:.35em;vertical-align:middle;"></span>`),a.text&&(l+=`<span class="navbar-brand-text${o}">${a.text}</span>`),a.tagline&&(l+=`<small class="navbar-brand-tagline">${a.tagline}</small>`),a.html=l}else o&&a.text&&(a.html=`<span class="navbar-brand-text${o}">${a.text}</span>`);const t=e(d.items||[]),c=d.position==="floating",p=d.orientation==="vertical";x.get(0).querySelector(":scope > .cms-nojs-links")?.remove(),Domma.elements.navbar("#site-navbar",{brand:q?a:null,items:t,variant:d.variant||"dark",position:c?"static":d.position||"sticky",collapsible:!0,appearOnHover:!!d.appearOnHover}),Domma.icons.scan("#site-navbar");const n=x.get(0);ae(n,d.mobile);const h=()=>{if(!p)return;const v=n.querySelector('a[aria-current="page"]')?.closest(".navbar-dropdown");v&&!v.classList.contains("open")&&v.querySelector(":scope > .navbar-dropdown-toggle")?.click()};n.classList.add(`dm-nav-align-${ue(d)||"centre"}`),p&&x.get(0).classList.add("dm-nav-vertical",d.side==="right"?"dm-nav-vertical-right":"dm-nav-vertical-left");const f=d.dock||{};p&&!c&&Me(n,d.side==="right"),!p&&f.hideOnScroll&&qe(n),Y(n,d),J(n,d),P(n,d.class),c&&(le(x.get(0),d),ye(x.get(0).parentNode||document));const u=n.querySelector(".navbar-toggle"),y=n.querySelector(".navbar-collapse");if(u&&y){let l=null;const v=()=>{y.classList.contains("show")&&u.click()},m=()=>{l&&(l.remove(),l=null),document.body.classList.remove("dm-drawer-open")},g=()=>{l||(l=document.createElement("div"),l.className="dm-navbar-backdrop",l.addEventListener("click",v),document.body.appendChild(l),document.body.classList.add("dm-drawer-open"))};u.addEventListener("click",()=>{requestAnimationFrame(()=>{y.classList.contains("show")?(h(),g()):m()})}),y.addEventListener("click",C=>{C.target.closest("a")&&requestAnimationFrame(m)}),document.addEventListener("keydown",C=>{C.key==="Escape"&&y.classList.contains("show")&&v()})}const b=n.querySelector(".navbar-nav");if(b){const l=Array.from(b.children);let v=0;for(const m of d.items||[])if(!(m&&m.type==="separator")){if(m&&m.type==="spacer"){const g=document.createElement("li"),C=["xs","sm","md","lg","xl","flex"].includes(m.size)?m.size:"md";g.className=`dm-menu-spacer dm-menu-spacer--${C}`,g.setAttribute("aria-hidden","true"),b.insertBefore(g,l[v]||null);continue}if(m&&m.type==="theme-switcher"){const g=document.createElement("li");g.className="dm-menu-theme-switcher";const C=document.createElement("span");C.dataset.themeSwitcher="menu",C.dataset.position="inline",g.appendChild(C),b.insertBefore(g,l[v]||null);continue}v++}window.CMSThemeSwitcher?.scan(b)}const A=K(t,location.pathname+location.search);n.querySelectorAll("[data-path]").forEach(l=>{const v=l.dataset.path.split(".").map(Number),m=v.length>1,g=v.reduce((I,B)=>I?.items?.[B],{items:t});if(!g)return;g.colour&&G(l,g.colour),g.pill&&!m&&ce(l,g.pill),de(l,g),P(l.closest("li"),g.class);const C=U(g.badge);C&&l.appendChild(C),A.has(g)&&(l.classList.add("active"),l.setAttribute("aria-current","page"))}),pe(n,d,t),h()}let z=null;const w=$("#site-footer");if(w.length){let c=function(i){return String(i??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},p=function(i){return c(i).replace(/'/g,"'")},n=function(i){if(i&&i.type==="separator")return'<li class="footer-sep"><hr></li>';if(i&&i.type==="spacer")return`<li class="dm-menu-spacer dm-menu-spacer--${["xs","sm","md","lg","xl","flex"].includes(i.size)?i.size:"md"}" aria-hidden="true"></li>`;if(i&&i.type==="theme-switcher")return'<li class="dm-menu-theme-switcher"><span data-theme-switcher="menu" data-position="inline"></span></li>';const L=p(i.url||"#"),M=c(i.text||""),D=Array.isArray(i.items)&&i.items.length?`<ul>${i.items.map(n).join("")}</ul>`:"",N=me(i),W=[N.hover&&` data-menu-item-hover="${p(N.hover)}"`,N.active&&` data-menu-item-active="${p(N.active)}"`].filter(Boolean).join(""),j=N.accent?` style="--dm-menu-highlight:${p(N.accent)}"`:"",O=X(i.class).join(" ");return`<li${O?` class="${p(O)}"`:""}><a href="${L}"${W}${j}>${M}</a>${D}</li>`},f=function(){if(!r.footer)return"";const i=Object.keys(o).filter(M=>a[M]);if(!i.length)return"";const L=X(r.footer.socialClass).join(" ");return`<div class="footer-social">${i.map(M=>{const{label:D,svg:N}=o[M];return`<a href="${a[M]}" target="_blank" rel="noopener noreferrer" aria-label="${D}" class="footer-social-link${L?` ${p(L)}`:""}">${N}</a>`}).join("")}</div>`},A=function(i){if(!i||i.type==="separator"||i.type==="spacer")return"";if(i.type==="theme-switcher")return`<li class="cms-footer-col">${n(i).replace(/^<li[^>]*>|<\/li>$/g,"")}</li>`;const L=Array.isArray(i.items)&&i.items.length?`<ul>${i.items.map(n).join("")}</ul>`:"",M=b(i)?`<span class="cms-footer-col-title">${c(i.text||"")}</span>`:`<a class="cms-footer-col-title" href="${p(i.url||"#")}">${c(i.text||"")}</a>`,D=["cms-footer-col",...X(i.class)].join(" ");return`<li class="${p(D)}">${M}${L}</li>`},m=function(i,L,M=!1){return(i||[]).forEach(D=>{D&&(D.type==="separator"||D.type==="spacer"||D.type==="theme-switcher")||(M&&b(D)||L.push(D),Array.isArray(D.items)&&D.items.length&&m(D.items,L))}),L};const a=r.social||{},o={twitter:{label:"X / Twitter",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.742l7.73-8.835L1.254 2.25H8.08l4.259 5.629L18.244 2.25zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>'},facebook:{label:"Facebook",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"/></svg>'},instagram:{label:"Instagram",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z"/></svg>'},linkedin:{label:"LinkedIn",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 01-2.063-2.065 2.064 2.064 0 112.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg>'},github:{label:"GitHub",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg>'},youtube:{label:"YouTube",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M23.495 6.205a3.007 3.007 0 00-2.088-2.088c-1.87-.501-9.396-.501-9.396-.501s-7.507-.01-9.396.501A3.007 3.007 0 00.527 6.205a31.247 31.247 0 00-.522 5.805 31.247 31.247 0 00.522 5.783 3.007 3.007 0 002.088 2.088c1.868.502 9.396.502 9.396.502s7.506 0 9.396-.502a3.007 3.007 0 002.088-2.088 31.247 31.247 0 00.5-5.783 31.247 31.247 0 00-.5-5.805zM9.609 15.601V8.408l6.264 3.602z"/></svg>'}};let e='<div class="footer-inner container">';const t=window.__CMS_FOOTER__||{primary:[],legal:[],copyright:""},h=(()=>{const i=r.cookieConsent;if(!i||i.showSettingsLink===!1)return"";const L=M=>(M||[]).some(D=>D&&(D.url==="#cookie-settings"||L(D.items)));return L(t.primary)||L(t.legal)?"":`<li class="cms-cookie-settings"><a href="#cookie-settings">${c(i.settingsLinkText||"Cookie settings")}</a></li>`})(),u=["columns","row"].includes(r.footer?.layout)?r.footer.layout:"auto",y=r.footer?.look==="showcase"||u==="columns"||u==="auto"&&t.primary.some(i=>Array.isArray(i?.items)&&i.items.length),b=i=>y&&!i.url&&Array.isArray(i.items)&&i.items.length>0;if(y){const i=d.brand||{},L=q&&(i.text||r.title)||"",M=q?i.logo?`<img src="${p(i.logo)}" class="cms-footer-brand-logo" alt="">`:i.icon?'<span class="cms-footer-brand-icon"></span>':"":"",D=String(r.footer?.blurb||"").trim();e='<div class="footer-inner footer-inner--columns container"><div class="cms-footer-top">',e+=`<div class="cms-footer-brand">${L||M?`<a class="cms-footer-brand-name" href="${p(i.url||"/")}">${M}<span>${c(L)}</span></a>`:""}${D?`<p class="cms-footer-blurb">${c(D)}</p>`:""}${f()}</div>`,t.primary.length&&(e+=`<nav class="footer-nav footer-nav--primary footer-nav--columns" aria-label="Footer"><ul>${t.primary.map(A).join("")}</ul></nav>`),e+='</div><div class="cms-footer-bottom">',t.copyright&&(e+=`<p class="cms-footer-copyright">${c(t.copyright)}</p>`),(t.legal.length||h)&&(e+=`<nav class="footer-nav footer-nav--legal" aria-label="Legal"><ul>${t.legal.map(n).join("")}${h}</ul></nav>`),e+="</div>"}else t.copyright&&(e+=`<p>${c(t.copyright)}</p>`),t.primary.length&&(e+=`<nav class="footer-nav footer-nav--primary"><ul>${t.primary.map(n).join("")}</ul></nav>`),(t.legal.length||h)&&(e+=`<nav class="footer-nav footer-nav--legal"><ul>${t.legal.map(n).join("")}${h}</ul></nav>`),e+=f();e+="</div>",w.get(0).querySelector(":scope > .cms-nojs-links")?.remove();const l=w.get(0).querySelector(":scope > .cms-footer-blocks");l?.remove(),w.html(e),l&&w.get(0).prepend(l),window.CMSThemeSwitcher?.scan(w.get(0));const v=w.get(0).querySelector(".cms-footer-brand-icon");v&&d.brand?.icon&&v.setAttribute("data-icon",d.brand.icon),P(w.get(0),r.footer?.class),y&&ge(w.get(0),r);const g=[...m(t.primary,[],!0),...m(t.legal,[])],C=K([...t.primary||[],...t.legal||[]],location.pathname+location.search),I=w.get(0).querySelectorAll(".footer-nav a"),B=[];I.forEach((i,L)=>{const M=g[L];if(!M)return;if(B.push({a:i,item:M}),M.icon){const N=document.createElement("span");N.className="cms-footer-ic",N.setAttribute("data-icon",String(M.icon)),N.setAttribute("data-icon-size","15"),N.setAttribute("aria-hidden","true"),i.prepend(N)}M.colour&&G(i,M.colour);const D=U(M.badge);D&&i.appendChild(D),C.has(M)&&(i.classList.add("is-active"),i.setAttribute("aria-current","page"))}),Y(w.get(0).querySelector(".footer-nav--primary"),{highlight:t.primaryHighlight}),Y(w.get(0).querySelector(".footer-nav--legal"),{highlight:t.legalHighlight}),J(w.get(0).querySelector(".footer-nav--primary"),{entrance:t.primaryEntrance}),J(w.get(0).querySelector(".footer-nav--legal"),{entrance:t.legalEntrance}),P(w.get(0).querySelector(".footer-nav--primary"),t.primaryClass),P(w.get(0).querySelector(".footer-nav--legal"),t.legalClass),fe(w.get(0),t,B),z=w.get(0).querySelector(".cms-footer-bottom")||w.get(0).querySelector(".footer-inner")}be(r.motion||{enabled:r.footer?.showMotionToggle!==!1,default:r.footer?.motionDefault,placement:"footer",control:r.footer?.motionControl,label:"Reduce motion"},{footer:z,navbar:document.querySelector("#site-navbar .navbar-container")?.closest("#site-navbar")||null});const k=document.getElementById("site-sidebar");k&&De(k),Domma.icons.scan(),Domma.syntax?.scan&&Domma.syntax.scan();const s=$(".page-body");if(s.length){s.find(".accordion").each(function(){Domma.elements.accordion(this,{allowMultiple:this.dataset.multi==="true"})}),s.find(".tabs").each(function(){Domma.elements.tabs(this)}),s.find(".carousel").each(function(){const o={primary:"--dm-primary",secondary:"--dm-secondary",accent:"--dm-primary",text:"--dm-text",surface:"--dm-surface",background:"--dm-background",success:"--dm-success",warning:"--dm-warning",danger:"--dm-danger",info:"--dm-info"},e=f=>{const u=String(f||"").trim();return u?o[u.toLowerCase()]?`var(${o[u.toLowerCase()]})`:CSS.supports("color",u)?u:"":""},t=e(this.dataset.background),c=e(this.dataset.arrowBackground),p=e(this.dataset.arrowColor);t&&(this.style.setProperty("--dm-carousel-background",t),this.classList.add("dm-carousel-custom-background")),c&&this.style.setProperty("--dm-carousel-arrow-background",c),p&&this.style.setProperty("--dm-carousel-arrow-color",p);const n=["top","middle","bottom"].includes(this.dataset.arrowPosition)?this.dataset.arrowPosition:"middle";this.classList.add(`dm-carousel-arrows-${n}`);const h={autoplay:this.dataset.autoplay==="true",interval:parseInt(this.dataset.interval,10)||5e3,loop:this.dataset.loop!=="false",animation:this.dataset.animation||"slide",heightMode:this.dataset.heightMode==="average"?"average":"crop"};if(this.dataset.height){const f=Number(this.dataset.height);Number.isFinite(f)&&f>0&&(h.height=f)}if(this.dataset.animationDuration){const f=parseInt(this.dataset.animationDuration,10);Number.isFinite(f)&&(h.animationDuration=f)}this.dataset.animationEasing&&(h.animationEasing=this.dataset.animationEasing),this.dataset.ctx&&(this._dmCtxSlides=Array.from(this.querySelectorAll(".carousel-slide")).map(f=>f.cloneNode(!0)),this._dmCarouselOpts=h),this._dmCarousel=Domma.elements.carousel(this,h),ie(this)}),s.find(".dm-countdown").each(function(){const o={autoStart:!0},e=String(this.dataset.format||"").trim(),t=String(this.dataset.to||"").trim(),c=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t),p=c?new Date(+c[1],+c[2]-1,+c[3]).getTime():t?new Date(t).getTime():NaN;Number.isFinite(p)?o.duration=Math.max(0,p-Date.now()):this.dataset.duration&&(o.duration=(parseInt(this.dataset.duration,10)||0)*1e3);const n=/^dd:/i.test(e);o.format=n?"hh:mm:ss":e||(o.duration>=36e5?"hh:mm:ss":"mm:ss");const h=this,f=y=>String(y).padStart(2,"0"),u=y=>{const b=Math.max(0,Math.floor(y/1e3)),A=h.querySelector(".dm-timer-time");A&&(A.textContent=`${f(Math.floor(b/86400))}:${f(Math.floor(b%86400/3600))}:${f(Math.floor(b%3600/60))}:${f(b%60)}`)};n&&(o.onTick=u),Domma.elements.timer(this,o),n&&u(o.duration||0)}),s.find("[data-tooltip]:not(.dm-range-slider)").each(function(){Domma.elements.tooltip(this,{content:$(this).data("tooltip"),position:$(this).data("tooltip-position")||"top"})}),s.find(".dm-progression").each(function(){const o=Array.from(this.querySelectorAll(".dm-progression-item")).map(c=>{const p={title:c.querySelector(".dm-progression-item-title")?.textContent?.trim()||"",description:c.querySelector(".dm-progression-item-body")?.innerHTML?.trim()||""};return c.dataset.date&&(p.date=c.dataset.date),c.dataset.status&&(p.status=c.dataset.status),c.dataset.eventIcon&&(p.icon=c.dataset.eventIcon),c.dataset.entryId&&(p._entryId=c.dataset.entryId),p}),e=this.dataset.layout==="centred"?"centered":this.dataset.layout||"vertical",t=Domma.elements.progression(this,{layout:e,theme:this.dataset.theme||"minimal",mode:this.dataset.mode||"timeline",statusIcons:!0,allowHtml:!0,...o.length?{items:o}:{}});if((this.dataset.mode||"timeline")==="timeline"){const c={completed:{label:"Completed",icon:"check-circle",tone:"success"},planned:{label:"Planned",icon:"circle",tone:"secondary"},"in-progress":{label:"In progress",icon:"clock",tone:"primary"},blocked:{label:"Blocked",icon:"alert-circle",tone:"danger"}};this.querySelectorAll(".dm-progression-item").forEach((p,n)=>{const h=o[n];if(!h)return;const f=p.querySelector(".dm-progression-title");if(h.icon&&f){const y=document.createElement("span");y.dataset.icon=h.icon,y.style.cssText="display:inline-flex;vertical-align:middle;margin-right:.4em",y.setAttribute("aria-hidden","true"),f.prepend(y)}const u=c[h.status];if(u&&f){const y=document.createElement("span");y.className=`badge badge-${u.tone} cms-timeline-status`,y.style.cssText="display:inline-flex;align-items:center;gap:.35em;margin:.4rem 0";const b=document.createElement("span");b.dataset.icon=u.icon,b.dataset.iconSize="14",b.setAttribute("aria-hidden","true"),y.append(b,document.createTextNode(u.label)),f.after(y)}})}Domma.icons.scan(this),o.length&&(this._dmCtx={instance:t,items:o})});try{Domma.effects.reveal(".page-body .hero",{animation:"slide-up",duration:480,threshold:.06,stagger:60,once:!1})}catch{}const a=matchMedia("(prefers-reduced-motion: reduce)").matches||document.documentElement.classList.contains("dm-reduced-motion");document.querySelectorAll(".page-body .row[data-reveal]").forEach(o=>{const e=o.dataset.revealMode||"stagger",t=o.dataset.revealAnimation||"slide-up",c=parseInt(o.dataset.revealDuration,10)||(t.startsWith("swoosh")?700:400),p=parseInt(o.dataset.revealStagger,10)||(t.startsWith("swoosh")?90:60),n=parseInt(o.dataset.revealDelay,10)||0,h=o.dataset.revealDirection==="rtl",f=o.dataset.revealReplay==="true",u=Array.from(o.children);if(a&&t.startsWith("swoosh"))return;const y={"slide-up":"translateY(30px)","slide-down":"translateY(-30px)","slide-left":"translateX(30px)","slide-right":"translateX(-30px)",zoom:"scale(0.85)",flip:"perspective(600px) rotateX(15deg)",swoosh:"translateY(36px) scale(0.96)"},b=m=>t!=="swoosh-sides"?y[t]||"":u.length>1&&m===0?"translateX(-64px) rotate(-1.5deg)":u.length>1&&m===u.length-1?"translateX(64px) rotate(1.5deg)":"translateY(40px) scale(0.94)",A=t.startsWith("swoosh"),l=A?"cubic-bezier(.2,.8,.2,1)":"ease",v=(m,g)=>{m.style.opacity="0",m.style.transform=b(g),A&&(m.style.filter="blur(10px)")};u.forEach((m,g)=>{m.style.transition="none",v(m,g)}),o.offsetWidth,u.forEach((m,g)=>{m.style.transition=`opacity ${c}ms ${l}, transform ${c}ms ${l}`+(A?`, filter ${c}ms ${l}`:"");const C=h?u.length-1-g:g;m.style.transitionDelay=e==="stagger"?`${n+C*p}ms`:`${n}ms`}),requestAnimationFrame(()=>requestAnimationFrame(()=>{const m=new IntersectionObserver(g=>{g.forEach(C=>{if(C.isIntersecting){if(C.target.offsetWidth,C.target.style.opacity="1",C.target.style.transform="",A&&(C.target.style.filter=""),!f){m.unobserve(C.target);const I=C.target;I.addEventListener("transitionend",function B(i){i.target!==I||i.propertyName!=="opacity"||(I.removeEventListener("transitionend",B),I.style.transition="",I.style.transitionDelay="")})}}else f&&C.boundingClientRect.top>0&&v(C.target,u.indexOf(C.target))})},{threshold:.1,rootMargin:"100000px 0px 0px 0px"});u.forEach(g=>m.observe(g))}))}),he(document.querySelector(".page-body")||document),s.find(".card[data-collapsible]").each(function(){const o=this.querySelector(":scope > .card-header");o&&o.addEventListener("click",()=>this.classList.toggle("is-collapsed"))}),s.find(".dm-so-trigger").each(function(){this.addEventListener("click",()=>{const o=this.dataset.soTarget,e=document.getElementById(o);if(!e)return;const t=E.slideover({title:e.dataset.soTitle||"",size:e.dataset.soSize||"md",position:e.dataset.soPosition||"right"});e.style.display="",t.setContent(e),t.open()})})}if(typeof $.setup=="function"){const a=Object.assign({},window.__CMS_DCONFIG__||{});if(document.querySelectorAll(".dm-page-config[data-config]").forEach(o=>{try{const e=V(o.dataset.config);Object.assign(a,e)}catch{}}),Object.keys(a).length>0){const o={};for(const[e,t]of Object.entries(a)){const c=t?.events?.click,{confirm:p,toast:n,alert:h,prompt:f,...u}=c||{};if(p||n||h||f){$(e).on("click",async function(W){if(W.preventDefault(),p&&!await E.confirm(p))return;let j=null;if(!(f&&(j=await E.prompt(f,{inputPlaceholder:u.promptPlaceholder||"",inputValue:u.promptDefault||""}),j===null))){{const O=$(u.target||this);u.toggleClass&&O.toggleClass(u.toggleClass),u.addClass&&O.addClass(u.addClass),u.removeClass&&O.removeClass(u.removeClass),j!==null&&(u.setText&&O.text(j),u.setVal&&O.val(j),u.setAttr&&O.attr(u.setAttr,j))}u.href&&se(u.href),n&&E.toast(n,{type:u.toastType||"success"}),h&&E.alert(h)}});const{target:b,toggleClass:A,addClass:l,removeClass:v,setText:m,setVal:g,setAttr:C,href:I,toastType:B,promptPlaceholder:i,promptDefault:L,...M}=u,D={...t.events};Object.keys(M).length?D.click=b?{target:b,...M}:M:delete D.click;const N={...t,events:D};Object.keys(D).length||delete N.events,Object.keys(N).length&&(o[e]=N)}else o[e]=t}$.setup(o)}}s.length&&R(s.get(0))}),window.wireCTAButtons=R;function se(d){if(!_e(d)){console.warn("[site] refused to go to",String(d).slice(0,60));return}const r=document.body?.classList.contains("dm-launcher-embed")&&window.top!==window;(r?window.top:window).location.href=d}function _e(d){const r=String(d??"").replace(/[\u0000-\u0020\u007f-\u00a0\u200b-\u200f\ufeff]/g,"").toLowerCase();return!r||r.includes("\\")||r.startsWith("//")?!1:/^(\/|#|\?|\.\.?\/)/.test(r)||/^(https?:\/\/|mailto:|tel:)/.test(r)?!0:!/^[a-z][a-z0-9+.-]*:/.test(r)}function R(d){d.querySelectorAll(".dm-cta-trigger").forEach(r=>{r.__ctaWired||(r.__ctaWired=!0,r.addEventListener("click",async()=>{const q=r.dataset.action,x=r.dataset.entry,z=r.dataset.confirm;let w=S.get("auth_token");if(!w){E.toast("Please log in to perform this action.",{type:"warning"});return}if(z&&!await E.confirm(z))return;const k=Array.from(r.childNodes).map(a=>a.cloneNode(!0));r.disabled=!0,r.textContent="Running\u2026";const s=a=>fetch(`/api/actions/${q}/public`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(r.dataset.scope?{entryId:x,scope:r.dataset.scope}:{entryId:x})});try{let a=await s(w);if(a.status===401){const e=S.get("auth_refresh_token");if(e){const t=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:e})});if(t.ok){const{token:c}=await t.json();S.set("auth_token",c),w=c,a=await s(w)}}}const o=await a.json().catch(()=>({}));if(!a.ok||o.success===!1)throw new Error(o.error||o.message||`Error ${a.status}`);E.toast(o.message||"Action completed.",{type:"success"})}catch(a){E.toast(a.message||"Action failed.",{type:"error"})}finally{r.disabled=!1,r.textContent="",k.forEach(a=>r.appendChild(a)),Domma.icons.scan(r)}}))})}(function(){const r=document.querySelectorAll('.dm-collection-hydrate[data-collection-scope="mine"]');if(!r.length)return;const q=S.get("auth_token");function x(w,k){const s=document.createElement("div");s.className="dm-collection-display dm-collection-empty";const a=document.createElement("p");if(k){a.appendChild(document.createTextNode("Please "));const o=document.createElement("a");o.href="/login",o.textContent="sign in",a.appendChild(o),a.appendChild(document.createTextNode(" to view your entries."))}else a.textContent=w;return s.appendChild(a),s}function z(w,k){const s=document.createElement("template");s.innerHTML=k||"",w.replaceWith(s.content)}r.forEach(async w=>{const k=w.dataset.collectionAttrs;if(!k)return;if(!q){w.replaceChildren(x("",!0));return}const s=a=>fetch("/api/collections/render-scope",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({attrs:k})});try{let a=q,o=await s(a);if(o.status===401){const t=S.get("auth_refresh_token");if(t){const c=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t})});if(c.ok){const{token:p}=await c.json();S.set("auth_token",p),a=p,o=await s(a)}}}if(!o.ok){const{error:t}=await o.json().catch(()=>({}));w.replaceChildren(x(t||"Unable to load entries.",!1));return}const{html:e}=await o.json();z(w,e),window.DommaCollectionBrowser?.hydrate&&window.DommaCollectionBrowser.hydrate(document)}catch{w.replaceChildren(x("Unable to load entries.",!1))}}),setTimeout(()=>{typeof Domma<"u"&&Domma.icons?.scan&&Domma.icons.scan(),typeof Domma<"u"&&Domma.syntax?.scan&&Domma.syntax.scan(),R(document.body)},100)})(),(function(){const r=document.querySelectorAll("[data-collection-table]");!r.length||typeof T>"u"||!T.create||r.forEach(q=>{let x;try{x=V(q.dataset.payload)}catch{return}const{columns:z,rows:w,search:k,sortable:s,exportable:a,pageSize:o,empty:e,ctaConfig:t,slug:c,exportCfg:p}=x;if(!z?.length)return;if(t){const f=z.findIndex(u=>u.key==="_cta");f!==-1&&(z[f]={key:"_cta",title:"",render:(u,y)=>{const b=document.createElement("button");if(b.className=`btn btn-${t.style||"primary"} dm-cta-trigger`,b.dataset.action=t.action||"",t.scope&&(b.dataset.scope=t.scope),b.dataset.entry=y._entryId||"",t.confirm&&(b.dataset.confirm=t.confirm),t.icon){const A=document.createElement("span");A.dataset.icon=t.icon,b.appendChild(A),b.appendChild(document.createTextNode(" "))}return b.appendChild(document.createTextNode(t.label||"Run")),b}})}const n="col-table-"+Math.random().toString(36).slice(2,7),h=document.createElement("div");h.id=n,q.replaceChildren(h),T.create("#"+n,{data:w,columns:z,search:k,sortable:s,exportable:a,pageSize:o,emptyMessage:e}),t&&R(h),q._dmTable={columns:z,rows:w,slug:c,exportCfg:p,render(f){T.create("#"+n,{data:f,columns:z,search:k,sortable:s,exportable:a,pageSize:o,emptyMessage:e}),t&&R(h)}}})})(),(function(){const r=document.querySelectorAll("[data-form-inline]");if(!r.length||typeof F>"u")return;function q(s){const a=s&&s.logic;return!!(a&&(a.visibility||a.requirement))}function x(s,a){const o={};return(s||[]).forEach(e=>{if(e.type==="page-break"||e.type==="spacer"||!e.name)return;const t=e.type==="chooser"||!!(e.variant&&["select","radio","checkbox-group"].includes(e.type)),c=e.type==="checkbox"?"boolean":e.type==="date"||e.type==="icon"||e.type==="image"?"string":t?"chooser":e.type,p={...e.formConfig||{}};p.span==="full"&&a&&(p.span=a);const n={type:c,required:q(e)?!1:e.required,label:e.label,options:e.options,formConfig:{...e.placeholder&&{placeholder:e.placeholder},...e.helper&&{hint:e.helper},...e.tooltip&&{tooltip:e.tooltip},...p}};e.minLength!==void 0&&(n.minLength=e.minLength),e.maxLength!==void 0&&(n.maxLength=e.maxLength),e.min!==void 0&&(n.min=e.min),e.max!==void 0&&(n.max=e.max),t&&(e.variant&&(n.variant=e.variant),(e.multiple||e.type==="checkbox-group")&&(n.multiple=!0),e.density&&(n.density=e.density),e.columns&&(n.columns=e.columns),e.accent&&(n.accent=e.accent),e.accentStyle&&(n.accentStyle=e.accentStyle),e.glow&&(n.glow=!0),e.glowColour&&(n.glowColour=e.glowColour),e.shadow&&(n.shadow=e.shadow),e.shadowColour&&(n.shadowColour=e.shadowColour)),o[e.name]=e.type==="file"?xe(e,n):n}),o}function z(s){const a={};return(s||[]).forEach(o=>{if(!(!o.name||o.type==="page-break"||o.type==="spacer")&&(o.type==="select"||o.type==="multiselect")&&o.required){const e=(o.options||[])[0];e&&(a[o.name]=typeof e=="object"?e.value:e)}}),a}function w(s,a){(a||[]).forEach(o=>{if(o.type!=="date"||!o.name)return;const e=s.querySelector(`[name="${o.name}"]`);e&&e.type!=="date"&&(e.type="date")})}function k(s,a,o){let e=s.querySelector(".cms-form-message");e||(e=document.createElement("p"),e.className="cms-form-message",s.appendChild(e)),e.textContent=a,e.style.cssText=o?"color:var(--dm-danger);margin-top:.75rem;":"color:var(--dm-success);margin-top:.75rem;"}r.forEach(s=>{let a;try{a=V(s.dataset.formInline)}catch{return}s.querySelector(":scope > .cms-form-embed-summary")?.remove();const o=a.fields||[],e=a.settings||{},t=Number(e.columns)===3?3:2,c=e.layout||"grid",p=o.some(A=>A.type==="page-break"),n=new Map;Le(s,a.fileLimits,n),Te(s,o);const h=async A=>{if(s.dataset.triggerBlocked==="true"){const l=s._formLogicRuntime,v=l&&l.submitBlock?l.submitBlock().reasons:[];k(s,v.join(" ")||"This form cannot be submitted yet.",!0);const m=new Error("Blocked by a form trigger");throw m.formSubmitFailed=!0,m}try{const l=s.querySelector(".fb-form-honeypot"),v=l?.querySelector('input[type="text"]')||null,m=l?.querySelector('[name="_t"]')||null,g=Object.assign({},A);delete g._t,l?.dataset.hpName&&delete g[l.dataset.hpName],v!==null&&(g._hp=v.value),m!==null&&(g._t=m.value);const C=new Map(n);ne(s,C);const I=$e(g,o,C),B=Ae(s,I.files);if(B){k(s,B,!0);const L=new Error(B);throw L.formSubmitFailed=!0,L}const i=await H.post(`/api/forms/submit/${a.slug}`,I.files.size?Ee(I.values,I.files).body:I.values);if(i&&i.error){k(s,i.error,!0);const L=new Error(i.error);throw L.formSubmitFailed=!0,L}if(i?.redirect){se(i.redirect);return}for(Se(s);s.firstChild;)s.removeChild(s.firstChild);k(s,i?.message||e.successMessage||"Thank you for your submission.",!1)}catch(l){throw l.formSubmitFailed||k(s,l.message||"Submission failed. Please try again.",!0),l}},f=Date.now();function u(A){const l=A.querySelector("form");if(!l||l.querySelector(".fb-form-honeypot"))return;const v=document.createElement("div");v.className="fb-form-honeypot",v.setAttribute("aria-hidden","true");const m=document.createElement("input");m.name=l.querySelector('[name="website"]')?"_website":"website",v.dataset.hpName=m.name,m.type="text",m.tabIndex=-1,m.autocomplete="url",m.placeholder="https://",v.appendChild(m);const g=document.createElement("input");g.name="_t",g.type="hidden",g.value=f,v.appendChild(g),l.appendChild(v)}function y(A){if(!window.FormLogicEngine||!o.some(v=>v.logic||Array.isArray(v.triggers)&&v.triggers.length))return null;const l=new window.FormLogicEngine.FormLogicRuntime(a,s,A?{baseValues:A}:void 0);if(l.init(),s._formLogicRuntime=l,s._formLogicObserved)return l;if(s._formLogicObserved=!0,s.parentNode&&typeof MutationObserver<"u"){const v=new MutationObserver(function(m){for(const g of m)for(const C of g.removedNodes)if(C===s||C.nodeType===1&&C.contains&&C.contains(s)){s._formLogicRuntime&&s._formLogicRuntime.destroy(),v.disconnect();return}});v.observe(s.parentNode,{childList:!0,subtree:!1}),s._formLogicObserver=v}return l}let b=!1;if(s.addEventListener("dm-form-end",A=>{const l=A.detail?.validation;if(l&&!l.valid){Z(s,l.missing),ee(l);return}b||(b=!0,h(A.detail?.values||{}).catch(()=>{}).finally(()=>{b=!1}))}),p&&F.wizard){const A=ve(o,a.title),l=A.map(i=>({title:i.title,description:i.description,fields:x(i.fields,t)})),v=A.map(i=>i.fields);let m=0,g=null,C=null;const I=i=>{const L=window.FormLogicEngine;if(!L||!L.validateFields)return;const M=L.validateFields(s,v[m]||[]);M.valid||(i.preventDefault(),i.stopImmediatePropagation(),Z(s,M.missing),ee(M))},B=()=>{const i=v[m]||o;Ce(s,e),te(s,e,i),oe(s,e),w(s,i),Q(s,i),ke(s,n),e.honeypot!==!1&&u(s),g&&g.destroy(),g=y(C?.getStepData?C.getStepData():void 0),s.querySelectorAll(".wizard-next, .wizard-submit").forEach(L=>L.addEventListener("click",I,!0))};C=F.wizard(s,{schema:{steps:l},layout:c,columns:t,finishText:e.submitText||"Finish",onSubmit:h,onStepChange:i=>{ne(s,n),m=i,setTimeout(B,0)}}),s.addEventListener("dm-form-trigger",i=>{if(i.detail?.type!=="goto-step"||!C?.goToStep)return;const L=Number(i.detail.action.step);!Number.isFinite(L)||L<0||L>=l.length||L!==m&&C.goToStep(L)}),Promise.resolve(C).then(B)}else if(F.render){const A=F.render(s,x(o,t),z(o),{submitText:e.submitText||"Submit",layout:c,columns:t,onSubmit:h});Promise.resolve(A).then(function(){we(s,e,c),te(s,e,o),oe(s,e),w(s,o),Q(s,o),e.honeypot!==!1&&u(s),y()})}})})();function Me(d,r){const q=document.body,x=q.classList,z=new Set((q.dataset.railSite||"").split(" ").filter(Boolean)),w=()=>window.matchMedia("(min-width: 993px)").matches;d.querySelectorAll(".navbar-link, .navbar-dropdown-toggle").forEach(t=>{const c=t.textContent.trim();c&&(t.setAttribute("title",c),t.querySelector("svg, [data-icon]")||(t.dataset.initial=c.charAt(0).toUpperCase()))});const k=document.createElement("button");k.type="button",k.className="dm-nav-collapse-toggle";const s=()=>{const t=x.contains("dm-vnav-collapsed");k.setAttribute("aria-pressed",String(t)),k.setAttribute("aria-label",t?"Expand menu":"Collapse menu"),k.title=k.getAttribute("aria-label");const c=r?"chevrons-left":"chevrons-right",p=r?"chevrons-right":"chevrons-left";k.innerHTML=`<span data-icon="${t?c:p}"></span>`,window.Domma&&Domma.icons&&Domma.icons.scan(k)},a=t=>{x.toggle("dm-vnav-collapsed",t),S.set("nav_collapsed",t),s()};k.addEventListener("click",()=>a(!x.contains("dm-vnav-collapsed"))),s();const o=d.querySelector(".navbar-container")||d;o.insertBefore(k,o.firstChild?.nextSibling||null);const e=t=>{x.toggle("dm-vnav-autohide",t),x.toggle("dm-vnav-collapsible",!t&&z.has("collapsible")),t?x.remove("dm-vnav-collapsed"):z.has("collapsible")&&S.get("nav_collapsed")===!0&&x.add("dm-vnav-collapsed"),d.classList.remove("dm-nav-revealed"),s()};d.addEventListener("pointerdown",t=>{x.contains("dm-vnav-autohide")&&t.pointerType!=="mouse"&&!d.classList.contains("dm-nav-revealed")&&(d.classList.add("dm-nav-revealed"),t.preventDefault())}),document.addEventListener("pointerdown",t=>{d.contains(t.target)||d.classList.remove("dm-nav-revealed")}),window.E&&typeof E.contextMenu=="function"&&E.contextMenu(d,{items:()=>{const t=x.contains("dm-vnav-autohide"),c=x.contains("dm-vnav-collapsed"),p=S.has("nav_autohide")||S.has("nav_collapsed");return[{header:"Menu"},{label:c?"Expand menu":"Collapse to icons",icon:c?"maximize":"minimize",disabled:!w()||t||!z.has("collapsible"),action:()=>a(!c)},{label:t?"Keep on screen":"Hide when not in use",icon:t?"eye":"eye-off",disabled:!w(),action:()=>{S.set("nav_autohide",!t),e(!t)}},{type:"divider"},{label:"Reset to the site's setting",icon:"refresh",disabled:!p,action:()=>{S.remove("nav_autohide"),S.remove("nav_collapsed"),e(z.has("autohide")),x.toggle("dm-vnav-collapsed",!z.has("autohide")&&z.has("start-collapsed")),s()}}]}})}function qe(d){d.classList.add("dm-nav-scroll-hide");let r=window.scrollY,q=!1;window.addEventListener("scroll",()=>{q||(q=!0,requestAnimationFrame(()=>{q=!1;const x=window.scrollY,z=d.matches(":focus-within")||d.querySelector(".navbar-dropdown.open, .navbar-collapse.show");x>r&&x>d.offsetHeight&&!z?d.classList.add("dm-nav-scrolled-away"):x<r&&d.classList.remove("dm-nav-scrolled-away"),r=x}))},{passive:!0})}function De(d){let r={};try{r=JSON.parse(d.dataset.contents||"{}")}catch{}const q=d.closest(".site-main"),x=document.querySelector(".site-content"),z=new Set(String(r.exclude||"").split(",").map(n=>n.trim().toLowerCase()).filter(Boolean)),w=n=>!n.closest(".hero, .card, .accordion, .tabs, figure, #site-sidebar"),k=n=>(x?[...x.querySelectorAll(n)]:[]).filter(w).filter(h=>!z.has(h.textContent.trim().toLowerCase())),s=r.headings==="h2"?k("h2"):r.headings==="h3"?k("h3"):r.headings==="h2h3"?k("h2, h3"):k("h2").length?k("h2"):k("h3");if(!s.length){q?.classList.add("no-sidebar-items");return}const a=new Set([...document.querySelectorAll("[id]")].map(n=>n.id)),o=document.createElement("nav");o.className="dm-contents",o.setAttribute("aria-label",r.title||"Page contents"),r.hover&&(o.dataset.menuHover=r.hover),r.selected&&(o.dataset.menuActive=r.selected),r.accent&&o.style.setProperty("--dm-menu-highlight",r.accent.startsWith("#")?r.accent:`var(--dm-${r.accent})`),r.font&&(o.style.fontFamily=r.font),r.fontSize&&(o.style.fontSize=r.fontSize),r.fontWeight&&(o.style.fontWeight=r.fontWeight);const e=document.createElement("div");e.className="dm-contents-head";const t=document.createElement("p");t.className="dm-contents-title",t.textContent=r.title||"",e.appendChild(t),o.appendChild(e);const c=document.createElement("ol");c.className="dm-contents-list"+(r.numbered?" is-numbered":"");const p=[];for(const n of s){if(!n.id){const u=(n.textContent||"").toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"section";let y=u;for(let b=2;a.has(y);b++)y=`${u}-${b}`;a.add(y),n.id=y}const h=document.createElement("li");h.className=`dm-contents-item dm-contents-${n.tagName.toLowerCase()}`;const f=document.createElement("a");f.href=`#${n.id}`,f.textContent=n.textContent.trim(),h.appendChild(f),c.appendChild(h),p.push([n,f])}if(o.appendChild(c),d.replaceChildren(o),r.scrollSpy!==!1&&"IntersectionObserver"in window){const n=new Map,h=()=>{const u=p.find(([y])=>n.get(y))||null;p.forEach(([,y])=>{const b=u&&y===u[1];y.classList.toggle("is-active",!!b),b?y.setAttribute("aria-current","location"):y.removeAttribute("aria-current")})},f=new IntersectionObserver(u=>{u.forEach(y=>n.set(y.target,y.isIntersecting)),h()},{rootMargin:"-80px 0px -60% 0px"});p.forEach(([u])=>f.observe(u))}if(q?.classList.contains("contents-collapsible")){const n=document.createElement("button");n.type="button",n.className="dm-contents-toggle";const h=()=>{const f=q.classList.contains("contents-collapsed");n.setAttribute("aria-expanded",String(!f)),n.setAttribute("aria-label",f?"Show the contents":"Hide the contents"),n.title=n.getAttribute("aria-label"),n.innerHTML=`<span data-icon="${f?"list":"x"}"></span>`,window.Domma?.icons&&Domma.icons.scan(n)};n.addEventListener("click",()=>{S.set("contents_collapsed",q.classList.toggle("contents-collapsed")),h()}),h(),e.insertBefore(n,e.firstChild)}if(q?.classList.contains("contents-floating")&&r.movable){o.classList.add("is-movable");const n=S.get("contents_position");n&&Number.isFinite(n.x)&&Object.assign(d.style,{left:`${n.x}px`,top:`${n.y}px`,right:"auto",bottom:"auto"}),e.addEventListener("pointerdown",h=>{if(h.target.closest("button"))return;const f=d.getBoundingClientRect(),u=h.clientX-f.left,y=h.clientY-f.top,b=l=>{const v=Math.max(0,Math.min(window.innerWidth-f.width,l.clientX-u)),m=Math.max(0,Math.min(window.innerHeight-40,l.clientY-y));Object.assign(d.style,{left:`${v}px`,top:`${m}px`,right:"auto",bottom:"auto"})},A=()=>{document.removeEventListener("pointermove",b),S.set("contents_position",{x:parseInt(d.style.left,10),y:parseInt(d.style.top,10)})};document.addEventListener("pointermove",b),document.addEventListener("pointerup",A,{once:!0})})}window.E&&typeof E.contextMenu=="function"&&E.contextMenu(d,{items:()=>{const n=q?.classList.contains("contents-collapsible"),h=q?.classList.contains("contents-collapsed"),f=p.find(([,u])=>u.classList.contains("is-active"));return[{header:"Contents"},...n?[{label:h?"Show the contents":"Collapse to a button",icon:h?"list":"minimize",action:()=>d.querySelector(".dm-contents-toggle")?.click()}]:[],{label:"Copy a link to this section",icon:"link",disabled:!f,action:async()=>{const u=`${location.origin}${location.pathname}#${f[0].id}`;try{await _.copyToClipboard(u),E.toast("Link copied.",{type:"success"})}catch{E.toast("Could not copy the link.",{type:"error"})}}},{label:"Back to the top",icon:"arrow-up",action:()=>window.scrollTo({top:0,behavior:"smooth"})}]}}),q?.classList.contains("contents-autohide")&&(d.addEventListener("pointerdown",n=>{n.pointerType!=="mouse"&&!d.classList.contains("is-revealed")&&(d.classList.add("is-revealed"),n.preventDefault())}),document.addEventListener("pointerdown",n=>{d.contains(n.target)||d.classList.remove("is-revealed")}))}
|
|
1
|
+
import{applyMobileMenu as ae,initCarouselPopup as ie}from"/public/js/mobile-ui.mjs?v=20261016-mobile-options";import{installSmoothCarets as re}from"/public/js/smooth-caret.js";import{decodeBase64Json as V}from"/public/js/utf8-base64.mjs";import{makeBadgeEl as U,applyColour as G,applyPill as ce,applyFloat as le,applyHighlight as Y,applyItemHighlight as de,itemHighlightAttrs as me,currentItems as K,menuAlign as ue,applyClasses as P,cssClasses as X,applyEntrance as J}from"/public/js/menu-decor.mjs?v=20261109-current-query";import{applyMenuLook as pe,applyFooterLook as fe}from"/public/js/menu-cards.mjs?v=20261115-rich-captions";import{initPageMotion as he}from"/public/js/page-motion.mjs?v=20261029-page-motion";import{applyFooterShowcase as ge}from"/public/js/footer-showcase.mjs?v=20261029-footer-showcase";import{initFloatingMenus as ye}from"/public/js/menu-float.js?v=20260927-float";import{enhancePickerFields as Q,markInvalidFields as Z,showValidationPopup as ee}from"/public/js/forms.js?v=20261109-form-embed";import{buildWizardSteps as ve}from"/public/js/form-steps.mjs";import{mountMotionControl as be}from"/public/js/motion-control.mjs?v=20261031-launchers";import{applyFormClasses as te,applyFormEntrance as oe,applySubmitButtons as we,applyWizardButtons as Ce}from"/public/js/form-submit.mjs";import{captureFileFields as ne,destroyDropzones as Se,fileBlueprint as xe,restoreFileFields as ke,setFileLimits as Le,splitFiles as $e,submitBody as Ee,totalTooLarge as Ae,wireFileFields as Te}from"/public/js/form-files.mjs";document.addEventListener("click",m=>{const r=m.target?.closest?.(".dm-banner__dismiss");r&&(m.preventDefault(),r.closest(".dm-banner")?.remove())}),$(()=>{re(document);const m=window.__CMS_NAV__||{},r=window.__CMS_SITE__||{},q=r.brandingEnabled!==!1&&m.brand?.enabled!==!1;if(r.autoTheme?.enabled){let t=function(d){const p=(d||"07:00").split(":");return+p[0]*60+(+p[1]||0)},e=function(){const d=new Date,p=d.getHours()*60+d.getMinutes();return p>=t(a.dayStart)&&p<t(a.nightStart)?a.dayTheme:a.nightTheme},n=function(d){if(window.CMSThemeSwitcher?.hasPreference())return;const p=a.apply&&a.apply[d]||{theme:d,custom:""};Domma.theme.set(p.theme);for(const o of[...document.body.classList])o.startsWith("dm-custom-")&&document.body.classList.remove(o);p.custom&&document.body.classList.add(p.custom)};const a=r.autoTheme;n(e()),setInterval(()=>n(e()),6e4)}const C=$("#site-navbar");if(C.length&&m.brand){let e=function(l,v=0){return Array.isArray(l)?l.filter(u=>!(u&&(u.type==="spacer"||u.type==="theme-switcher"))).filter(u=>!(u&&u.type==="separator"&&v===0)).map(u=>u&&u.type==="separator"?{divider:!0}:Array.isArray(u?.items)?{...u,items:e(u.items,v+1)}:u):l};const a={...m.brand},t=a.size&&a.size!=="md"?` navbar-brand-${a.size}`:"";if(a.logo||a.icon||a.tagline){let l="";a.logo?l+=`<img src="${a.logo}" class="navbar-brand-logo" alt="${a.text||""}">`:a.icon&&(l+=`<span data-icon="${a.icon}" style="width:1.1em;height:1.1em;margin-right:.35em;vertical-align:middle;"></span>`),a.text&&(l+=`<span class="navbar-brand-text${t}">${a.text}</span>`),a.tagline&&(l+=`<small class="navbar-brand-tagline">${a.tagline}</small>`),a.html=l}else t&&a.text&&(a.html=`<span class="navbar-brand-text${t}">${a.text}</span>`);const n=e(m.items||[]),d=m.position==="floating",p=m.orientation==="vertical";C.get(0).querySelector(":scope > .cms-nojs-links")?.remove(),Domma.elements.navbar("#site-navbar",{brand:q?a:null,items:n,variant:m.variant||"dark",position:d?"static":m.position||"sticky",collapsible:!0,appearOnHover:!!m.appearOnHover}),Domma.icons.scan("#site-navbar");const o=C.get(0);ae(o,m.mobile);const h=()=>{if(!p)return;const v=o.querySelector('a[aria-current="page"]')?.closest(".navbar-dropdown");v&&!v.classList.contains("open")&&v.querySelector(":scope > .navbar-dropdown-toggle")?.click()};o.classList.add(`dm-nav-align-${ue(m)||"centre"}`),p&&C.get(0).classList.add("dm-nav-vertical",m.side==="right"?"dm-nav-vertical-right":"dm-nav-vertical-left");const f=m.dock||{};p&&!d&&Me(o,m.side==="right"),!p&&f.hideOnScroll&&qe(o),Y(o,m),J(o,m),P(o,m.class),d&&(le(C.get(0),m),ye(C.get(0).parentNode||document));const c=o.querySelector(".navbar-toggle"),y=o.querySelector(".navbar-collapse");if(c&&y){let l=null;const v=()=>{y.classList.contains("show")&&c.click()},u=()=>{l&&(l.remove(),l=null),document.body.classList.remove("dm-drawer-open")},g=()=>{l||(l=document.createElement("div"),l.className="dm-navbar-backdrop",l.addEventListener("click",v),document.body.appendChild(l),document.body.classList.add("dm-drawer-open"))};c.addEventListener("click",()=>{requestAnimationFrame(()=>{y.classList.contains("show")?(h(),g()):u()})}),y.addEventListener("click",w=>{w.target.closest("a")&&requestAnimationFrame(u)}),document.addEventListener("keydown",w=>{w.key==="Escape"&&y.classList.contains("show")&&v()})}const L=o.querySelector(".navbar-nav");if(L){const l=Array.from(L.children);let v=0;for(const u of m.items||[])if(!(u&&u.type==="separator")){if(u&&u.type==="spacer"){const g=document.createElement("li"),w=["xs","sm","md","lg","xl","flex"].includes(u.size)?u.size:"md";g.className=`dm-menu-spacer dm-menu-spacer--${w}`,g.setAttribute("aria-hidden","true"),L.insertBefore(g,l[v]||null);continue}if(u&&u.type==="theme-switcher"){const g=document.createElement("li");g.className="dm-menu-theme-switcher";const w=document.createElement("span");w.dataset.themeSwitcher="menu",w.dataset.position="inline",g.appendChild(w),L.insertBefore(g,l[v]||null);continue}v++}window.CMSThemeSwitcher?.scan(L)}const x=K(n,location.pathname+location.search);o.querySelectorAll("[data-path]").forEach(l=>{const v=l.dataset.path.split(".").map(Number),u=v.length>1,g=v.reduce((z,B)=>z?.items?.[B],{items:n});if(!g)return;g.colour&&G(l,g.colour),g.pill&&!u&&ce(l,g.pill),de(l,g),P(l.closest("li"),g.class);const w=U(g.badge);w&&l.appendChild(w),x.has(g)&&(l.classList.add("active"),l.setAttribute("aria-current","page"))}),pe(o,m,n),h()}let I=null;const b=$("#site-footer");if(b.length){let d=function(i){return String(i??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},p=function(i){return d(i).replace(/'/g,"'")},o=function(i){if(i&&i.type==="separator")return'<li class="footer-sep"><hr></li>';if(i&&i.type==="spacer")return`<li class="dm-menu-spacer dm-menu-spacer--${["xs","sm","md","lg","xl","flex"].includes(i.size)?i.size:"md"}" aria-hidden="true"></li>`;if(i&&i.type==="theme-switcher")return'<li class="dm-menu-theme-switcher"><span data-theme-switcher="menu" data-position="inline"></span></li>';const A=p(i.url||"#"),M=d(i.text||""),D=Array.isArray(i.items)&&i.items.length?`<ul>${i.items.map(o).join("")}</ul>`:"",N=me(i),W=[N.hover&&` data-menu-item-hover="${p(N.hover)}"`,N.active&&` data-menu-item-active="${p(N.active)}"`].filter(Boolean).join(""),j=N.accent?` style="--dm-menu-highlight:${p(N.accent)}"`:"",O=X(i.class).join(" ");return`<li${O?` class="${p(O)}"`:""}><a href="${A}"${W}${j}>${M}</a>${D}</li>`},f=function(){if(!r.footer)return"";const i=Object.keys(t).filter(M=>a[M]);if(!i.length)return"";const A=X(r.footer.socialClass).join(" ");return`<div class="footer-social">${i.map(M=>{const{label:D,svg:N}=t[M];return`<a href="${a[M]}" target="_blank" rel="noopener noreferrer" aria-label="${D}" class="footer-social-link${A?` ${p(A)}`:""}">${N}</a>`}).join("")}</div>`},x=function(i){if(!i||i.type==="separator"||i.type==="spacer")return"";if(i.type==="theme-switcher")return`<li class="cms-footer-col">${o(i).replace(/^<li[^>]*>|<\/li>$/g,"")}</li>`;const A=Array.isArray(i.items)&&i.items.length?`<ul>${i.items.map(o).join("")}</ul>`:"",M=L(i)?`<span class="cms-footer-col-title">${d(i.text||"")}</span>`:`<a class="cms-footer-col-title" href="${p(i.url||"#")}">${d(i.text||"")}</a>`,D=["cms-footer-col",...X(i.class)].join(" ");return`<li class="${p(D)}">${M}${A}</li>`},u=function(i,A,M=!1){return(i||[]).forEach(D=>{D&&(D.type==="separator"||D.type==="spacer"||D.type==="theme-switcher")||(M&&L(D)||A.push(D),Array.isArray(D.items)&&D.items.length&&u(D.items,A))}),A};const a=r.social||{},t={twitter:{label:"X / Twitter",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.742l7.73-8.835L1.254 2.25H8.08l4.259 5.629L18.244 2.25zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>'},facebook:{label:"Facebook",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"/></svg>'},instagram:{label:"Instagram",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z"/></svg>'},linkedin:{label:"LinkedIn",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 01-2.063-2.065 2.064 2.064 0 112.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg>'},github:{label:"GitHub",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg>'},youtube:{label:"YouTube",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M23.495 6.205a3.007 3.007 0 00-2.088-2.088c-1.87-.501-9.396-.501-9.396-.501s-7.507-.01-9.396.501A3.007 3.007 0 00.527 6.205a31.247 31.247 0 00-.522 5.805 31.247 31.247 0 00.522 5.783 3.007 3.007 0 002.088 2.088c1.868.502 9.396.502 9.396.502s7.506 0 9.396-.502a3.007 3.007 0 002.088-2.088 31.247 31.247 0 00.5-5.783 31.247 31.247 0 00-.5-5.805zM9.609 15.601V8.408l6.264 3.602z"/></svg>'}};let e='<div class="footer-inner container">';const n=window.__CMS_FOOTER__||{primary:[],legal:[],copyright:""},h=(()=>{const i=r.cookieConsent;if(!i||i.showSettingsLink===!1)return"";const A=M=>(M||[]).some(D=>D&&(D.url==="#cookie-settings"||A(D.items)));return A(n.primary)||A(n.legal)?"":`<li class="cms-cookie-settings"><a href="#cookie-settings">${d(i.settingsLinkText||"Cookie settings")}</a></li>`})(),c=["columns","row"].includes(r.footer?.layout)?r.footer.layout:"auto",y=r.footer?.look==="showcase"||c==="columns"||c==="auto"&&n.primary.some(i=>Array.isArray(i?.items)&&i.items.length),L=i=>y&&!i.url&&Array.isArray(i.items)&&i.items.length>0;if(y){const i=m.brand||{},A=q&&(i.text||r.title)||"",M=q?i.logo?`<img src="${p(i.logo)}" class="cms-footer-brand-logo" alt="">`:i.icon?'<span class="cms-footer-brand-icon"></span>':"":"",D=String(r.footer?.blurb||"").trim();e='<div class="footer-inner footer-inner--columns container"><div class="cms-footer-top">',e+=`<div class="cms-footer-brand">${A||M?`<a class="cms-footer-brand-name" href="${p(i.url||"/")}">${M}<span>${d(A)}</span></a>`:""}${D?`<p class="cms-footer-blurb">${d(D)}</p>`:""}${f()}</div>`,n.primary.length&&(e+=`<nav class="footer-nav footer-nav--primary footer-nav--columns" aria-label="Footer"><ul>${n.primary.map(x).join("")}</ul></nav>`),e+='</div><div class="cms-footer-bottom">',n.copyright&&(e+=`<p class="cms-footer-copyright">${d(n.copyright)}</p>`),(n.legal.length||h)&&(e+=`<nav class="footer-nav footer-nav--legal" aria-label="Legal"><ul>${n.legal.map(o).join("")}${h}</ul></nav>`),e+="</div>"}else n.copyright&&(e+=`<p>${d(n.copyright)}</p>`),n.primary.length&&(e+=`<nav class="footer-nav footer-nav--primary"><ul>${n.primary.map(o).join("")}</ul></nav>`),(n.legal.length||h)&&(e+=`<nav class="footer-nav footer-nav--legal"><ul>${n.legal.map(o).join("")}${h}</ul></nav>`),e+=f();e+="</div>",b.get(0).querySelector(":scope > .cms-nojs-links")?.remove();const l=b.get(0).querySelector(":scope > .cms-footer-blocks");l?.remove(),b.html(e),l&&b.get(0).prepend(l),window.CMSThemeSwitcher?.scan(b.get(0));const v=b.get(0).querySelector(".cms-footer-brand-icon");v&&m.brand?.icon&&v.setAttribute("data-icon",m.brand.icon),P(b.get(0),r.footer?.class),y&&ge(b.get(0),r);const g=[...u(n.primary,[],!0),...u(n.legal,[])],w=K([...n.primary||[],...n.legal||[]],location.pathname+location.search),z=b.get(0).querySelectorAll(".footer-nav a"),B=[];z.forEach((i,A)=>{const M=g[A];if(!M)return;if(B.push({a:i,item:M}),M.icon){const N=document.createElement("span");N.className="cms-footer-ic",N.setAttribute("data-icon",String(M.icon)),N.setAttribute("data-icon-size","15"),N.setAttribute("aria-hidden","true"),i.prepend(N)}M.colour&&G(i,M.colour);const D=U(M.badge);D&&i.appendChild(D),w.has(M)&&(i.classList.add("is-active"),i.setAttribute("aria-current","page"))}),Y(b.get(0).querySelector(".footer-nav--primary"),{highlight:n.primaryHighlight}),Y(b.get(0).querySelector(".footer-nav--legal"),{highlight:n.legalHighlight}),J(b.get(0).querySelector(".footer-nav--primary"),{entrance:n.primaryEntrance}),J(b.get(0).querySelector(".footer-nav--legal"),{entrance:n.legalEntrance}),P(b.get(0).querySelector(".footer-nav--primary"),n.primaryClass),P(b.get(0).querySelector(".footer-nav--legal"),n.legalClass),fe(b.get(0),n,B),I=b.get(0).querySelector(".cms-footer-bottom")||b.get(0).querySelector(".footer-inner")}be(r.motion||{enabled:r.footer?.showMotionToggle!==!1,default:r.footer?.motionDefault,placement:"footer",control:r.footer?.motionControl,label:"Reduce motion"},{footer:I,navbar:document.querySelector("#site-navbar .navbar-container")?.closest("#site-navbar")||null});const k=document.getElementById("site-sidebar");k&&De(k),Domma.icons.scan(),Domma.syntax?.scan&&Domma.syntax.scan();const s=$(".page-body");if(s.length){s.find(".accordion").each(function(){Domma.elements.accordion(this,{allowMultiple:this.dataset.multi==="true"})}),s.find(".tabs").each(function(){Domma.elements.tabs(this)}),s.find(".carousel").each(function(){const t={primary:"--dm-primary",secondary:"--dm-secondary",accent:"--dm-primary",text:"--dm-text",surface:"--dm-surface",background:"--dm-background",success:"--dm-success",warning:"--dm-warning",danger:"--dm-danger",info:"--dm-info"},e=f=>{const c=String(f||"").trim();return c?t[c.toLowerCase()]?`var(${t[c.toLowerCase()]})`:CSS.supports("color",c)?c:"":""},n=e(this.dataset.background),d=e(this.dataset.arrowBackground),p=e(this.dataset.arrowColor);n&&(this.style.setProperty("--dm-carousel-background",n),this.classList.add("dm-carousel-custom-background")),d&&this.style.setProperty("--dm-carousel-arrow-background",d),p&&this.style.setProperty("--dm-carousel-arrow-color",p);const o=["top","middle","bottom"].includes(this.dataset.arrowPosition)?this.dataset.arrowPosition:"middle";this.classList.add(`dm-carousel-arrows-${o}`);const h={autoplay:this.dataset.autoplay==="true",interval:parseInt(this.dataset.interval,10)||5e3,loop:this.dataset.loop!=="false",animation:this.dataset.animation||"slide",heightMode:this.dataset.heightMode==="average"?"average":"crop"};if(this.dataset.height){const f=Number(this.dataset.height);Number.isFinite(f)&&f>0&&(h.height=f)}if(this.dataset.animationDuration){const f=parseInt(this.dataset.animationDuration,10);Number.isFinite(f)&&(h.animationDuration=f)}this.dataset.animationEasing&&(h.animationEasing=this.dataset.animationEasing),this.dataset.ctx&&(this._dmCtxSlides=Array.from(this.querySelectorAll(".carousel-slide")).map(f=>f.cloneNode(!0)),this._dmCarouselOpts=h),this._dmCarousel=Domma.elements.carousel(this,h),ie(this)}),s.find(".dm-countdown").each(function(){const t={autoStart:!0},e=String(this.dataset.format||"").trim(),n=String(this.dataset.to||"").trim(),d=/^(\d{4})-(\d{2})-(\d{2})$/.exec(n),p=d?new Date(+d[1],+d[2]-1,+d[3]).getTime():n?new Date(n).getTime():NaN;Number.isFinite(p)?t.duration=Math.max(0,p-Date.now()):this.dataset.duration&&(t.duration=(parseInt(this.dataset.duration,10)||0)*1e3);const o=/^dd:/i.test(e);t.format=o?"hh:mm:ss":e||(t.duration>=36e5?"hh:mm:ss":"mm:ss");const h=this,f=y=>String(y).padStart(2,"0"),c=y=>{const L=Math.max(0,Math.floor(y/1e3)),x=h.querySelector(".dm-timer-time");x&&(x.textContent=`${f(Math.floor(L/86400))}:${f(Math.floor(L%86400/3600))}:${f(Math.floor(L%3600/60))}:${f(L%60)}`)};o&&(t.onTick=c),Domma.elements.timer(this,t),o&&c(t.duration||0)}),s.find("[data-tooltip]:not(.dm-range-slider)").each(function(){Domma.elements.tooltip(this,{content:$(this).data("tooltip"),position:$(this).data("tooltip-position")||"top"})}),s.find(".dm-progression").each(function(){const t=Array.from(this.querySelectorAll(".dm-progression-item")).map(d=>{const p={title:d.querySelector(".dm-progression-item-title")?.textContent?.trim()||"",description:d.querySelector(".dm-progression-item-body")?.innerHTML?.trim()||""};return d.dataset.date&&(p.date=d.dataset.date),d.dataset.status&&(p.status=d.dataset.status),d.dataset.eventIcon&&(p.icon=d.dataset.eventIcon),d.dataset.entryId&&(p._entryId=d.dataset.entryId),p}),e=this.dataset.layout==="centred"?"centered":this.dataset.layout||"vertical",n=Domma.elements.progression(this,{layout:e,theme:this.dataset.theme||"minimal",mode:this.dataset.mode||"timeline",statusIcons:!0,allowHtml:!0,...t.length?{items:t}:{}});if((this.dataset.mode||"timeline")==="timeline"){const d={completed:{label:"Completed",icon:"check-circle",tone:"success"},planned:{label:"Planned",icon:"circle",tone:"secondary"},"in-progress":{label:"In progress",icon:"clock",tone:"primary"},blocked:{label:"Blocked",icon:"alert-circle",tone:"danger"}};this.querySelectorAll(".dm-progression-item").forEach((p,o)=>{const h=t[o];if(!h)return;const f=p.querySelector(".dm-progression-title");if(h.icon&&f){const y=document.createElement("span");y.dataset.icon=h.icon,y.style.cssText="display:inline-flex;vertical-align:middle;margin-right:.4em",y.setAttribute("aria-hidden","true"),f.prepend(y)}const c=d[h.status];if(c&&f){const y=document.createElement("span");y.className=`badge badge-${c.tone} cms-timeline-status`,y.style.cssText="display:inline-flex;align-items:center;gap:.35em;margin:.4rem 0";const L=document.createElement("span");L.dataset.icon=c.icon,L.dataset.iconSize="14",L.setAttribute("aria-hidden","true"),y.append(L,document.createTextNode(c.label)),f.after(y)}})}Domma.icons.scan(this),t.length&&(this._dmCtx={instance:n,items:t})});try{Domma.effects.reveal(".page-body .hero",{animation:"slide-up",duration:480,threshold:.06,stagger:60,once:!1})}catch{}const a=matchMedia("(prefers-reduced-motion: reduce)").matches||document.documentElement.classList.contains("dm-reduced-motion");document.querySelectorAll(".page-body .row[data-reveal]").forEach(t=>{const e=t.dataset.revealMode||"stagger",n=t.dataset.revealAnimation||"slide-up",d=parseInt(t.dataset.revealDuration,10)||(n.startsWith("swoosh")?700:400),p=parseInt(t.dataset.revealStagger,10)||(n.startsWith("swoosh")?90:60),o=parseInt(t.dataset.revealDelay,10)||0,h=t.dataset.revealDirection==="rtl",f=t.dataset.revealReplay==="true",c=Array.from(t.children);if(a&&n.startsWith("swoosh"))return;const y={"slide-up":"translateY(30px)","slide-down":"translateY(-30px)","slide-left":"translateX(30px)","slide-right":"translateX(-30px)",zoom:"scale(0.85)",flip:"perspective(600px) rotateX(15deg)",swoosh:"translateY(36px) scale(0.96)"},L=u=>n!=="swoosh-sides"?y[n]||"":c.length>1&&u===0?"translateX(-64px) rotate(-1.5deg)":c.length>1&&u===c.length-1?"translateX(64px) rotate(1.5deg)":"translateY(40px) scale(0.94)",x=n.startsWith("swoosh"),l=x?"cubic-bezier(.2,.8,.2,1)":"ease",v=(u,g)=>{u.style.opacity="0",u.style.transform=L(g),x&&(u.style.filter="blur(10px)")};c.forEach((u,g)=>{u.style.transition="none",v(u,g)}),t.offsetWidth,c.forEach((u,g)=>{u.style.transition=`opacity ${d}ms ${l}, transform ${d}ms ${l}`+(x?`, filter ${d}ms ${l}`:"");const w=h?c.length-1-g:g;u.style.transitionDelay=e==="stagger"?`${o+w*p}ms`:`${o}ms`}),requestAnimationFrame(()=>requestAnimationFrame(()=>{const u=new IntersectionObserver(g=>{g.forEach(w=>{if(w.isIntersecting){if(w.target.offsetWidth,w.target.style.opacity="1",w.target.style.transform="",x&&(w.target.style.filter=""),!f){u.unobserve(w.target);const z=w.target;z.addEventListener("transitionend",function B(i){i.target!==z||i.propertyName!=="opacity"||(z.removeEventListener("transitionend",B),z.style.transition="",z.style.transitionDelay="")})}}else f&&w.boundingClientRect.top>0&&v(w.target,c.indexOf(w.target))})},{threshold:.1,rootMargin:"100000px 0px 0px 0px"});c.forEach(g=>u.observe(g))}))}),he(document.querySelector(".page-body")||document),s.find(".card[data-collapsible]").each(function(){const t=this.querySelector(":scope > .card-header");t&&t.addEventListener("click",()=>this.classList.toggle("is-collapsed"))}),s.find(".dm-so-trigger").each(function(){this.addEventListener("click",()=>{const t=this.dataset.soTarget,e=document.getElementById(t);if(!e)return;const n=E.slideover({title:e.dataset.soTitle||"",size:e.dataset.soSize||"md",position:e.dataset.soPosition||"right"});e.style.display="",n.setContent(e),n.open()})})}if(typeof $.setup=="function"){const a=Object.assign({},window.__CMS_DCONFIG__||{});if(document.querySelectorAll(".dm-page-config[data-config]").forEach(t=>{try{const e=V(t.dataset.config);Object.assign(a,e)}catch{}}),Object.keys(a).length>0){const t={};for(const[e,n]of Object.entries(a)){const d=n?.events?.click,{confirm:p,toast:o,alert:h,prompt:f,...c}=d||{};if(p||o||h||f){$(e).on("click",async function(W){if(W.preventDefault(),p&&!await E.confirm(p))return;let j=null;if(!(f&&(j=await E.prompt(f,{inputPlaceholder:c.promptPlaceholder||"",inputValue:c.promptDefault||""}),j===null))){{const O=$(c.target||this);c.toggleClass&&O.toggleClass(c.toggleClass),c.addClass&&O.addClass(c.addClass),c.removeClass&&O.removeClass(c.removeClass),j!==null&&(c.setText&&O.text(j),c.setVal&&O.val(j),c.setAttr&&O.attr(c.setAttr,j))}c.href&&se(c.href),o&&E.toast(o,{type:c.toastType||"success"}),h&&E.alert(h)}});const{target:L,toggleClass:x,addClass:l,removeClass:v,setText:u,setVal:g,setAttr:w,href:z,toastType:B,promptPlaceholder:i,promptDefault:A,...M}=c,D={...n.events};Object.keys(M).length?D.click=L?{target:L,...M}:M:delete D.click;const N={...n,events:D};Object.keys(D).length||delete N.events,Object.keys(N).length&&(t[e]=N)}else t[e]=n}$.setup(t)}}s.length&&R(s.get(0))}),window.wireCTAButtons=R;function se(m){if(!_e(m)){console.warn("[site] refused to go to",String(m).slice(0,60));return}const r=document.body?.classList.contains("dm-launcher-embed")&&window.top!==window;(r?window.top:window).location.href=m}function _e(m){const r=String(m??"").replace(/[\u0000-\u0020\u007f-\u00a0\u200b-\u200f\ufeff]/g,"").toLowerCase();return!r||r.includes("\\")||r.startsWith("//")?!1:/^(\/|#|\?|\.\.?\/)/.test(r)||/^(https?:\/\/|mailto:|tel:)/.test(r)?!0:!/^[a-z][a-z0-9+.-]*:/.test(r)}function R(m){m.querySelectorAll(".dm-cta-trigger").forEach(r=>{r.__ctaWired||(r.__ctaWired=!0,r.addEventListener("click",async()=>{const q=r.dataset.action,C=r.dataset.entry,I=r.dataset.confirm;let b=S.get("auth_token");if(!b){E.toast("Please log in to perform this action.",{type:"warning"});return}if(I&&!await E.confirm(I))return;const k=Array.from(r.childNodes).map(a=>a.cloneNode(!0));r.disabled=!0,r.textContent="Running\u2026";const s=a=>fetch(`/api/actions/${encodeURIComponent(q)}/public`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(r.dataset.scope?{entryId:C,scope:r.dataset.scope}:{entryId:C})});try{let a=await s(b);if(a.status===401){const e=S.get("auth_refresh_token");if(e){const n=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:e})});if(n.ok){const{token:d}=await n.json();S.set("auth_token",d),b=d,a=await s(b)}}}const t=await a.json().catch(()=>({}));if(!a.ok||t.success===!1)throw new Error(t.error||t.message||`Error ${a.status}`);E.toast(t.message||"Action completed.",{type:"success"})}catch(a){E.toast(a.message||"Action failed.",{type:"error"})}finally{r.disabled=!1,r.textContent="",k.forEach(a=>r.appendChild(a)),Domma.icons.scan(r)}}))})}(function(){const r=document.querySelectorAll('.dm-collection-hydrate[data-collection-scope="mine"]');if(!r.length)return;const q=S.get("auth_token");function C(b,k){const s=document.createElement("div");s.className="dm-collection-display dm-collection-empty";const a=document.createElement("p");if(k){a.appendChild(document.createTextNode("Please "));const t=document.createElement("a");t.href="/login",t.textContent="sign in",a.appendChild(t),a.appendChild(document.createTextNode(" to view your entries."))}else a.textContent=b;return s.appendChild(a),s}function I(b,k){const s=document.createElement("template");s.innerHTML=k||"",b.replaceWith(s.content)}r.forEach(async b=>{const k=b.dataset.collectionAttrs;if(!k)return;if(!q){b.replaceChildren(C("",!0));return}const s=a=>fetch("/api/collections/render-scope",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({attrs:k})});try{let a=q,t=await s(a);if(t.status===401){const n=S.get("auth_refresh_token");if(n){const d=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:n})});if(d.ok){const{token:p}=await d.json();S.set("auth_token",p),a=p,t=await s(a)}}}if(!t.ok){const{error:n}=await t.json().catch(()=>({}));b.replaceChildren(C(n||"Unable to load entries.",!1));return}const{html:e}=await t.json();I(b,e),window.DommaCollectionBrowser?.hydrate&&window.DommaCollectionBrowser.hydrate(document)}catch{b.replaceChildren(C("Unable to load entries.",!1))}}),setTimeout(()=>{typeof Domma<"u"&&Domma.icons?.scan&&Domma.icons.scan(),typeof Domma<"u"&&Domma.syntax?.scan&&Domma.syntax.scan(),R(document.body)},100)})(),(function(){const r=document.querySelectorAll("[data-collection-table]");!r.length||typeof T>"u"||!T.create||r.forEach(q=>{let C;try{C=V(q.dataset.payload)}catch{return}const{rows:I,search:b,sortable:k,exportable:s,pageSize:a,empty:t,ctaConfig:e,slug:n,exportCfg:d}=C;if(!Array.isArray(C.columns)||!C.columns.length)return;const p=c=>String(c??"").replace(/</g,"\u2039").replace(/>/g,"\u203A"),o=C.columns.map(c=>c&&typeof c=="object"?{key:p(c.key),title:p(c.title||c.key)}:{key:p(c),title:p(c)});if(e){const c=o.findIndex(y=>y.key==="_cta");c!==-1&&(o[c]={key:"_cta",title:"",render:(y,L)=>{const x=document.createElement("button");if(x.className=`btn btn-${e.style||"primary"} dm-cta-trigger`,x.dataset.action=e.action||"",e.scope&&(x.dataset.scope=e.scope),x.dataset.entry=L._entryId||"",e.confirm&&(x.dataset.confirm=e.confirm),e.icon){const l=document.createElement("span");l.dataset.icon=e.icon,x.appendChild(l),x.appendChild(document.createTextNode(" "))}return x.appendChild(document.createTextNode(e.label||"Run")),x}})}const h="col-table-"+Math.random().toString(36).slice(2,7),f=document.createElement("div");f.id=h,q.replaceChildren(f),T.create("#"+h,{data:I,columns:o,search:b,sortable:k,exportable:s,pageSize:a,emptyMessage:t}),e&&R(f),q._dmTable={columns:o,rows:I,slug:n,exportCfg:d,render(c){T.create("#"+h,{data:c,columns:o,search:b,sortable:k,exportable:s,pageSize:a,emptyMessage:t}),e&&R(f)}}})})(),(function(){const r=document.querySelectorAll("[data-form-inline]");if(!r.length||typeof F>"u")return;function q(s){const a=s&&s.logic;return!!(a&&(a.visibility||a.requirement))}function C(s,a){const t={};return(s||[]).forEach(e=>{if(e.type==="page-break"||e.type==="spacer"||!e.name)return;const n=e.type==="chooser"||!!(e.variant&&["select","radio","checkbox-group"].includes(e.type)),d=e.type==="checkbox"?"boolean":e.type==="date"||e.type==="icon"||e.type==="image"?"string":n?"chooser":e.type,p={...e.formConfig||{}};p.span==="full"&&a&&(p.span=a);const o={type:d,required:q(e)?!1:e.required,label:e.label,options:e.options,formConfig:{...e.placeholder&&{placeholder:e.placeholder},...e.helper&&{hint:e.helper},...e.tooltip&&{tooltip:e.tooltip},...p}};e.minLength!==void 0&&(o.minLength=e.minLength),e.maxLength!==void 0&&(o.maxLength=e.maxLength),e.min!==void 0&&(o.min=e.min),e.max!==void 0&&(o.max=e.max),n&&(e.variant&&(o.variant=e.variant),(e.multiple||e.type==="checkbox-group")&&(o.multiple=!0),e.density&&(o.density=e.density),e.columns&&(o.columns=e.columns),e.accent&&(o.accent=e.accent),e.accentStyle&&(o.accentStyle=e.accentStyle),e.glow&&(o.glow=!0),e.glowColour&&(o.glowColour=e.glowColour),e.shadow&&(o.shadow=e.shadow),e.shadowColour&&(o.shadowColour=e.shadowColour)),t[e.name]=e.type==="file"?xe(e,o):o}),t}function I(s){const a={};return(s||[]).forEach(t=>{if(!(!t.name||t.type==="page-break"||t.type==="spacer")&&(t.type==="select"||t.type==="multiselect")&&t.required){const e=(t.options||[])[0];e&&(a[t.name]=typeof e=="object"?e.value:e)}}),a}function b(s,a){(a||[]).forEach(t=>{if(t.type!=="date"||!t.name)return;const e=s.querySelector(`[name="${t.name}"]`);e&&e.type!=="date"&&(e.type="date")})}function k(s,a,t){let e=s.querySelector(".cms-form-message");e||(e=document.createElement("p"),e.className="cms-form-message",s.appendChild(e)),e.textContent=a,e.style.cssText=t?"color:var(--dm-danger);margin-top:.75rem;":"color:var(--dm-success);margin-top:.75rem;"}r.forEach(s=>{let a;try{a=V(s.dataset.formInline)}catch{return}s.querySelector(":scope > .cms-form-embed-summary")?.remove();const t=a.fields||[],e=a.settings||{},n=Number(e.columns)===3?3:2,d=e.layout||"grid",p=t.some(x=>x.type==="page-break"),o=new Map;Le(s,a.fileLimits,o),Te(s,t);const h=async x=>{if(s.dataset.triggerBlocked==="true"){const l=s._formLogicRuntime,v=l&&l.submitBlock?l.submitBlock().reasons:[];k(s,v.join(" ")||"This form cannot be submitted yet.",!0);const u=new Error("Blocked by a form trigger");throw u.formSubmitFailed=!0,u}try{const l=s.querySelector(".fb-form-honeypot"),v=l?.querySelector('input[type="text"]')||null,u=l?.querySelector('[name="_t"]')||null,g=Object.assign({},x);delete g._t,l?.dataset.hpName&&delete g[l.dataset.hpName],v!==null&&(g._hp=v.value),u!==null&&(g._t=u.value);const w=new Map(o);ne(s,w);const z=$e(g,t,w),B=Ae(s,z.files);if(B){k(s,B,!0);const A=new Error(B);throw A.formSubmitFailed=!0,A}const i=await H.post(`/api/forms/submit/${a.slug}`,z.files.size?Ee(z.values,z.files).body:z.values);if(i&&i.error){k(s,i.error,!0);const A=new Error(i.error);throw A.formSubmitFailed=!0,A}if(i?.redirect){se(i.redirect);return}for(Se(s);s.firstChild;)s.removeChild(s.firstChild);k(s,i?.message||e.successMessage||"Thank you for your submission.",!1)}catch(l){throw l.formSubmitFailed||k(s,l.message||"Submission failed. Please try again.",!0),l}},f=Date.now();function c(x){const l=x.querySelector("form");if(!l||l.querySelector(".fb-form-honeypot"))return;const v=document.createElement("div");v.className="fb-form-honeypot",v.setAttribute("aria-hidden","true");const u=document.createElement("input");u.name=l.querySelector('[name="website"]')?"_website":"website",v.dataset.hpName=u.name,u.type="text",u.tabIndex=-1,u.autocomplete="url",u.placeholder="https://",v.appendChild(u);const g=document.createElement("input");g.name="_t",g.type="hidden",g.value=f,v.appendChild(g),l.appendChild(v)}function y(x){if(!window.FormLogicEngine||!t.some(v=>v.logic||Array.isArray(v.triggers)&&v.triggers.length))return null;const l=new window.FormLogicEngine.FormLogicRuntime(a,s,x?{baseValues:x}:void 0);if(l.init(),s._formLogicRuntime=l,s._formLogicObserved)return l;if(s._formLogicObserved=!0,s.parentNode&&typeof MutationObserver<"u"){const v=new MutationObserver(function(u){for(const g of u)for(const w of g.removedNodes)if(w===s||w.nodeType===1&&w.contains&&w.contains(s)){s._formLogicRuntime&&s._formLogicRuntime.destroy(),v.disconnect();return}});v.observe(s.parentNode,{childList:!0,subtree:!1}),s._formLogicObserver=v}return l}let L=!1;if(s.addEventListener("dm-form-end",x=>{const l=x.detail?.validation;if(l&&!l.valid){Z(s,l.missing),ee(l);return}L||(L=!0,h(x.detail?.values||{}).catch(()=>{}).finally(()=>{L=!1}))}),p&&F.wizard){const x=ve(t,a.title),l=x.map(i=>({title:i.title,description:i.description,fields:C(i.fields,n)})),v=x.map(i=>i.fields);let u=0,g=null,w=null;const z=i=>{const A=window.FormLogicEngine;if(!A||!A.validateFields)return;const M=A.validateFields(s,v[u]||[]);M.valid||(i.preventDefault(),i.stopImmediatePropagation(),Z(s,M.missing),ee(M))},B=()=>{const i=v[u]||t;Ce(s,e),te(s,e,i),oe(s,e),b(s,i),Q(s,i),ke(s,o),e.honeypot!==!1&&c(s),g&&g.destroy(),g=y(w?.getStepData?w.getStepData():void 0),s.querySelectorAll(".wizard-next, .wizard-submit").forEach(A=>A.addEventListener("click",z,!0))};w=F.wizard(s,{schema:{steps:l},layout:d,columns:n,finishText:e.submitText||"Finish",onSubmit:h,onStepChange:i=>{ne(s,o),u=i,setTimeout(B,0)}}),s.addEventListener("dm-form-trigger",i=>{if(i.detail?.type!=="goto-step"||!w?.goToStep)return;const A=Number(i.detail.action.step);!Number.isFinite(A)||A<0||A>=l.length||A!==u&&w.goToStep(A)}),Promise.resolve(w).then(B)}else if(F.render){const x=F.render(s,C(t,n),I(t),{submitText:e.submitText||"Submit",layout:d,columns:n,onSubmit:h});Promise.resolve(x).then(function(){we(s,e,d),te(s,e,t),oe(s,e),b(s,t),Q(s,t),e.honeypot!==!1&&c(s),y()})}})})();function Me(m,r){const q=document.body,C=q.classList,I=new Set((q.dataset.railSite||"").split(" ").filter(Boolean)),b=()=>window.matchMedia("(min-width: 993px)").matches;m.querySelectorAll(".navbar-link, .navbar-dropdown-toggle").forEach(n=>{const d=n.textContent.trim();d&&(n.setAttribute("title",d),n.querySelector("svg, [data-icon]")||(n.dataset.initial=d.charAt(0).toUpperCase()))});const k=document.createElement("button");k.type="button",k.className="dm-nav-collapse-toggle";const s=()=>{const n=C.contains("dm-vnav-collapsed");k.setAttribute("aria-pressed",String(n)),k.setAttribute("aria-label",n?"Expand menu":"Collapse menu"),k.title=k.getAttribute("aria-label");const d=r?"chevrons-left":"chevrons-right",p=r?"chevrons-right":"chevrons-left";k.innerHTML=`<span data-icon="${n?d:p}"></span>`,window.Domma&&Domma.icons&&Domma.icons.scan(k)},a=n=>{C.toggle("dm-vnav-collapsed",n),S.set("nav_collapsed",n),s()};k.addEventListener("click",()=>a(!C.contains("dm-vnav-collapsed"))),s();const t=m.querySelector(".navbar-container")||m;t.insertBefore(k,t.firstChild?.nextSibling||null);const e=n=>{C.toggle("dm-vnav-autohide",n),C.toggle("dm-vnav-collapsible",!n&&I.has("collapsible")),n?C.remove("dm-vnav-collapsed"):I.has("collapsible")&&S.get("nav_collapsed")===!0&&C.add("dm-vnav-collapsed"),m.classList.remove("dm-nav-revealed"),s()};m.addEventListener("pointerdown",n=>{C.contains("dm-vnav-autohide")&&n.pointerType!=="mouse"&&!m.classList.contains("dm-nav-revealed")&&(m.classList.add("dm-nav-revealed"),n.preventDefault())}),document.addEventListener("pointerdown",n=>{m.contains(n.target)||m.classList.remove("dm-nav-revealed")}),window.E&&typeof E.contextMenu=="function"&&E.contextMenu(m,{items:()=>{const n=C.contains("dm-vnav-autohide"),d=C.contains("dm-vnav-collapsed"),p=S.has("nav_autohide")||S.has("nav_collapsed");return[{header:"Menu"},{label:d?"Expand menu":"Collapse to icons",icon:d?"maximize":"minimize",disabled:!b()||n||!I.has("collapsible"),action:()=>a(!d)},{label:n?"Keep on screen":"Hide when not in use",icon:n?"eye":"eye-off",disabled:!b(),action:()=>{S.set("nav_autohide",!n),e(!n)}},{type:"divider"},{label:"Reset to the site's setting",icon:"refresh",disabled:!p,action:()=>{S.remove("nav_autohide"),S.remove("nav_collapsed"),e(I.has("autohide")),C.toggle("dm-vnav-collapsed",!I.has("autohide")&&I.has("start-collapsed")),s()}}]}})}function qe(m){m.classList.add("dm-nav-scroll-hide");let r=window.scrollY,q=!1;window.addEventListener("scroll",()=>{q||(q=!0,requestAnimationFrame(()=>{q=!1;const C=window.scrollY,I=m.matches(":focus-within")||m.querySelector(".navbar-dropdown.open, .navbar-collapse.show");C>r&&C>m.offsetHeight&&!I?m.classList.add("dm-nav-scrolled-away"):C<r&&m.classList.remove("dm-nav-scrolled-away"),r=C}))},{passive:!0})}function De(m){let r={};try{r=JSON.parse(m.dataset.contents||"{}")}catch{}const q=m.closest(".site-main"),C=document.querySelector(".site-content"),I=new Set(String(r.exclude||"").split(",").map(o=>o.trim().toLowerCase()).filter(Boolean)),b=o=>!o.closest(".hero, .card, .accordion, .tabs, figure, #site-sidebar"),k=o=>(C?[...C.querySelectorAll(o)]:[]).filter(b).filter(h=>!I.has(h.textContent.trim().toLowerCase())),s=r.headings==="h2"?k("h2"):r.headings==="h3"?k("h3"):r.headings==="h2h3"?k("h2, h3"):k("h2").length?k("h2"):k("h3");if(!s.length){q?.classList.add("no-sidebar-items");return}const a=new Set([...document.querySelectorAll("[id]")].map(o=>o.id)),t=document.createElement("nav");t.className="dm-contents",t.setAttribute("aria-label",r.title||"Page contents"),r.hover&&(t.dataset.menuHover=r.hover),r.selected&&(t.dataset.menuActive=r.selected),r.accent&&t.style.setProperty("--dm-menu-highlight",r.accent.startsWith("#")?r.accent:`var(--dm-${r.accent})`),r.font&&(t.style.fontFamily=r.font),r.fontSize&&(t.style.fontSize=r.fontSize),r.fontWeight&&(t.style.fontWeight=r.fontWeight);const e=document.createElement("div");e.className="dm-contents-head";const n=document.createElement("p");n.className="dm-contents-title",n.textContent=r.title||"",e.appendChild(n),t.appendChild(e);const d=document.createElement("ol");d.className="dm-contents-list"+(r.numbered?" is-numbered":"");const p=[];for(const o of s){if(!o.id){const c=(o.textContent||"").toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"section";let y=c;for(let L=2;a.has(y);L++)y=`${c}-${L}`;a.add(y),o.id=y}const h=document.createElement("li");h.className=`dm-contents-item dm-contents-${o.tagName.toLowerCase()}`;const f=document.createElement("a");f.href=`#${o.id}`,f.textContent=o.textContent.trim(),h.appendChild(f),d.appendChild(h),p.push([o,f])}if(t.appendChild(d),m.replaceChildren(t),r.scrollSpy!==!1&&"IntersectionObserver"in window){const o=new Map,h=()=>{const c=p.find(([y])=>o.get(y))||null;p.forEach(([,y])=>{const L=c&&y===c[1];y.classList.toggle("is-active",!!L),L?y.setAttribute("aria-current","location"):y.removeAttribute("aria-current")})},f=new IntersectionObserver(c=>{c.forEach(y=>o.set(y.target,y.isIntersecting)),h()},{rootMargin:"-80px 0px -60% 0px"});p.forEach(([c])=>f.observe(c))}if(q?.classList.contains("contents-collapsible")){const o=document.createElement("button");o.type="button",o.className="dm-contents-toggle";const h=()=>{const f=q.classList.contains("contents-collapsed");o.setAttribute("aria-expanded",String(!f)),o.setAttribute("aria-label",f?"Show the contents":"Hide the contents"),o.title=o.getAttribute("aria-label"),o.innerHTML=`<span data-icon="${f?"list":"x"}"></span>`,window.Domma?.icons&&Domma.icons.scan(o)};o.addEventListener("click",()=>{S.set("contents_collapsed",q.classList.toggle("contents-collapsed")),h()}),h(),e.insertBefore(o,e.firstChild)}if(q?.classList.contains("contents-floating")&&r.movable){t.classList.add("is-movable");const o=S.get("contents_position");o&&Number.isFinite(o.x)&&Object.assign(m.style,{left:`${o.x}px`,top:`${o.y}px`,right:"auto",bottom:"auto"}),e.addEventListener("pointerdown",h=>{if(h.target.closest("button"))return;const f=m.getBoundingClientRect(),c=h.clientX-f.left,y=h.clientY-f.top,L=l=>{const v=Math.max(0,Math.min(window.innerWidth-f.width,l.clientX-c)),u=Math.max(0,Math.min(window.innerHeight-40,l.clientY-y));Object.assign(m.style,{left:`${v}px`,top:`${u}px`,right:"auto",bottom:"auto"})},x=()=>{document.removeEventListener("pointermove",L),S.set("contents_position",{x:parseInt(m.style.left,10),y:parseInt(m.style.top,10)})};document.addEventListener("pointermove",L),document.addEventListener("pointerup",x,{once:!0})})}window.E&&typeof E.contextMenu=="function"&&E.contextMenu(m,{items:()=>{const o=q?.classList.contains("contents-collapsible"),h=q?.classList.contains("contents-collapsed"),f=p.find(([,c])=>c.classList.contains("is-active"));return[{header:"Contents"},...o?[{label:h?"Show the contents":"Collapse to a button",icon:h?"list":"minimize",action:()=>m.querySelector(".dm-contents-toggle")?.click()}]:[],{label:"Copy a link to this section",icon:"link",disabled:!f,action:async()=>{const c=`${location.origin}${location.pathname}#${f[0].id}`;try{await _.copyToClipboard(c),E.toast("Link copied.",{type:"success"})}catch{E.toast("Could not copy the link.",{type:"error"})}}},{label:"Back to the top",icon:"arrow-up",action:()=>window.scrollTo({top:0,behavior:"smooth"})}]}}),q?.classList.contains("contents-autohide")&&(m.addEventListener("pointerdown",o=>{o.pointerType!=="mouse"&&!m.classList.contains("is-revealed")&&(m.classList.add("is-revealed"),o.preventDefault())}),document.addEventListener("pointerdown",o=>{m.contains(o.target)||m.classList.remove("is-revealed")}))}
|
|
@@ -65,6 +65,7 @@ import {hooks} from '../../services/hooks.js';
|
|
|
65
65
|
import {DRAFT_STATUS, authenticateApiToken, draftsOnlyDecision, scopeAllows} from '../../services/apiTokens.js';
|
|
66
66
|
import {contentRefusal, renderedContentRefusal} from '../../services/tokenContentPolicy.js';
|
|
67
67
|
import {listBlocks} from '../../services/blocks.js';
|
|
68
|
+
import {confineFilter} from '../../services/filterEngine.js';
|
|
68
69
|
|
|
69
70
|
/** Field types whose value is rendered as Markdown on a page (the Blog's post body, a notes field). */
|
|
70
71
|
const RENDERED_TYPES = new Set(['textarea', 'markdown', 'richtext', 'html', 'wysiwyg', 'code']);
|
|
@@ -293,9 +294,8 @@ function redactTokenHash(entry) {
|
|
|
293
294
|
/**
|
|
294
295
|
* Apply the read-field allowlist (`schema.api.read.fields`) to a public read
|
|
295
296
|
* payload. Absent or empty allowlist = all fields. Handles both list payloads
|
|
296
|
-
* ({entries: [...]}) and single entries.
|
|
297
|
-
*
|
|
298
|
-
* documented v1 behaviour).
|
|
297
|
+
* ({entries: [...]}) and single entries. entry.data and `_refs` (resolveRefs)
|
|
298
|
+
* are both cut to the list.
|
|
299
299
|
*
|
|
300
300
|
* @param {object} schema
|
|
301
301
|
* @param {object} payload - listEntries() result or a single entry
|
|
@@ -304,10 +304,9 @@ function redactTokenHash(entry) {
|
|
|
304
304
|
export function applyReadFieldAllowlist(schema, payload) {
|
|
305
305
|
const fields = schema.api?.read?.fields;
|
|
306
306
|
if (!Array.isArray(fields) || fields.length === 0) return payload;
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
});
|
|
307
|
+
const only = (object) => Object.fromEntries(Object.entries(object || {}).filter(([k]) => fields.includes(k)));
|
|
308
|
+
// _refs (resolveRefs) carries a reference field's id and label: a hidden field's go with it.
|
|
309
|
+
const strip = (e) => ({...e, data: only(e.data), ...(e._refs && {_refs: only(e._refs)})});
|
|
311
310
|
if (Array.isArray(payload?.entries)) return { ...payload, entries: payload.entries.map(strip) };
|
|
312
311
|
return strip(payload);
|
|
313
312
|
}
|
|
@@ -813,7 +812,15 @@ export async function collectionsRoutes(fastify) {
|
|
|
813
812
|
if (!schema) return reply.status(404).send({ error: 'Collection not found' });
|
|
814
813
|
|
|
815
814
|
const { page, limit, sort, order, search, scope, resolveRefs } = request.query;
|
|
816
|
-
|
|
815
|
+
// A read limited to some fields (api.read.fields) is filtered, searched
|
|
816
|
+
// and sorted on those only - otherwise which rows come back, and in what
|
|
817
|
+
// order, answers questions about the fields the caller is never shown.
|
|
818
|
+
// The caller's filter is cut down HERE, before the server adds its own
|
|
819
|
+
// conditions (own rows) below, which are not the caller's to lose.
|
|
820
|
+
const listed = Array.isArray(schema.api?.read?.fields) && schema.api.read.fields.length
|
|
821
|
+
? new Set(schema.api.read.fields) : null;
|
|
822
|
+
const asked = extractBracketed(request.query, 'filter');
|
|
823
|
+
const filter = listed ? confineFilter(asked, listed) : asked;
|
|
817
824
|
|
|
818
825
|
// scope=mine has its own security model: it requires auth and scopes
|
|
819
826
|
// results to the caller's own entries via `createdBy = user.id`. Bypasses
|
|
@@ -838,12 +845,15 @@ export async function collectionsRoutes(fastify) {
|
|
|
838
845
|
}
|
|
839
846
|
if (nobodysRows(request, reply, filter)) return;
|
|
840
847
|
|
|
848
|
+
const sortOn = typeof sort === 'string' && sort && (!listed || listed.has(sort) || sort === 'createdAt' || sort === 'updatedAt') ? sort : 'createdAt';
|
|
849
|
+
|
|
841
850
|
const result = await listEntries(request.params.slug, {
|
|
842
851
|
page: parseInt(page, 10) || 1,
|
|
843
852
|
limit: parseInt(limit, 10) || 50,
|
|
844
|
-
sort:
|
|
853
|
+
sort: sortOn,
|
|
845
854
|
order: order || 'desc',
|
|
846
|
-
search: search
|
|
855
|
+
search: typeof search === 'string' && search ? search : undefined,
|
|
856
|
+
...(listed && {searchFields: [...listed]}),
|
|
847
857
|
filter: Object.keys(filter).length ? filter : undefined,
|
|
848
858
|
resolveRefs: resolveRefs === 'true' || resolveRefs === '1'
|
|
849
859
|
});
|
|
@@ -953,8 +963,12 @@ export async function collectionsRoutes(fastify) {
|
|
|
953
963
|
return reply.status(403).send({ error: NOT_YOUR_ROWS });
|
|
954
964
|
}
|
|
955
965
|
|
|
956
|
-
|
|
957
|
-
|
|
966
|
+
// The browser puts this in with innerHTML, after the page itself was
|
|
967
|
+
// sanitised - so it is cleaned here, as render-scope's fragment is.
|
|
968
|
+
const { renderCollectionFragment, sanitizePageHtml } = await import('../../services/markdown.js');
|
|
969
|
+
// These attributes came from the browser, not from a page: the fields
|
|
970
|
+
// public read lists (api.read.fields) are all it may draw, filter or sort on.
|
|
971
|
+
const html = sanitizePageHtml(await renderCollectionFragment(attrs, {readFields: schema.api?.read?.fields}));
|
|
958
972
|
return { html };
|
|
959
973
|
});
|
|
960
974
|
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
import fs from 'fs/promises';
|
|
22
22
|
import path from 'path';
|
|
23
23
|
import { config } from '../../config.js';
|
|
24
|
-
import { applyFilter } from '../filterEngine.js';
|
|
24
|
+
import { applyFilter, searchedValues } from '../filterEngine.js';
|
|
25
25
|
import { withFileLock, writeFileAtomic } from './fileLock.js';
|
|
26
26
|
import {fileIn} from '../safePath.js';
|
|
27
27
|
|
|
@@ -77,16 +77,17 @@ export class FileAdapter {
|
|
|
77
77
|
* @param {string} [opts.sort='createdAt']
|
|
78
78
|
* @param {string} [opts.order='desc'] - 'asc' | 'desc'
|
|
79
79
|
* @param {string} [opts.search] - Free-text substring across all fields
|
|
80
|
+
* @param {string[]} [opts.searchFields] - Search these fields only (a caller who may read only some)
|
|
80
81
|
* @param {Record<string, unknown>} [opts.filter] - Structured filter; see filterEngine.js
|
|
81
82
|
* @returns {Promise<{ entries: object[], total: number, page: number, limit: number }>}
|
|
82
83
|
*/
|
|
83
|
-
async list(slug, { page = 1, limit = 50, sort = 'createdAt', order = 'desc', search, filter } = {}) {
|
|
84
|
+
async list(slug, { page = 1, limit = 50, sort = 'createdAt', order = 'desc', search, searchFields, filter } = {}) {
|
|
84
85
|
let entries = await read(slug);
|
|
85
86
|
|
|
86
87
|
if (search) {
|
|
87
88
|
const term = search.toLowerCase();
|
|
88
89
|
entries = entries.filter(entry =>
|
|
89
|
-
|
|
90
|
+
searchedValues(entry.data, searchFields).some(v => String(v).toLowerCase().includes(term))
|
|
90
91
|
);
|
|
91
92
|
}
|
|
92
93
|
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
* archive(slug) → string|null (set the entries aside after a storage move)
|
|
21
21
|
*/
|
|
22
22
|
import { toSafeMongoQuery } from '../mongoQueryGuard.js';
|
|
23
|
+
import { searchedValues } from '../filterEngine.js';
|
|
23
24
|
|
|
24
25
|
/** Prefix applied to all CMS collection names in MongoDB to avoid collisions. */
|
|
25
26
|
const PREFIX = 'cms_';
|
|
@@ -93,10 +94,11 @@ export class MongoAdapter {
|
|
|
93
94
|
* @param {string} [opts.sort='createdAt']
|
|
94
95
|
* @param {string} [opts.order='desc'] - 'asc' | 'desc'
|
|
95
96
|
* @param {string} [opts.search] - Free-text substring across all fields
|
|
97
|
+
* @param {string[]} [opts.searchFields] - Search these fields only (a caller who may read only some)
|
|
96
98
|
* @param {Record<string, unknown>} [opts.filter] - Structured filter; see filterEngine.js
|
|
97
99
|
* @returns {Promise<{ entries: object[], total: number, page: number, limit: number }>}
|
|
98
100
|
*/
|
|
99
|
-
async list(slug, { page = 1, limit = 50, sort = 'createdAt', order = 'desc', search, filter } = {}) {
|
|
101
|
+
async list(slug, { page = 1, limit = 50, sort = 'createdAt', order = 'desc', search, searchFields, filter } = {}) {
|
|
100
102
|
const col = await this._col(slug);
|
|
101
103
|
|
|
102
104
|
const sortField = sort === 'createdAt' ? 'meta.createdAt' : `data.${sort}`;
|
|
@@ -116,7 +118,7 @@ export class MongoAdapter {
|
|
|
116
118
|
|
|
117
119
|
const term = search.toLowerCase();
|
|
118
120
|
const matched = all.filter(entry =>
|
|
119
|
-
|
|
121
|
+
searchedValues(entry.data, searchFields).some(v => String(v).toLowerCase().includes(term))
|
|
120
122
|
);
|
|
121
123
|
|
|
122
124
|
const total = matched.length;
|
|
@@ -74,6 +74,39 @@ export function parseFilterKey(key) {
|
|
|
74
74
|
return { field: key, op: '_eq' };
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
/**
|
|
78
|
+
* The values a free-text search looks through: every field, or only those named
|
|
79
|
+
* (a caller who may read only some fields must not find rows by the others).
|
|
80
|
+
*
|
|
81
|
+
* @param {object|null|undefined} data
|
|
82
|
+
* @param {string[]|null|undefined} fields
|
|
83
|
+
* @returns {unknown[]}
|
|
84
|
+
*/
|
|
85
|
+
export function searchedValues(data, fields) {
|
|
86
|
+
if (!Array.isArray(fields)) return Object.values(data || {});
|
|
87
|
+
return fields.filter(f => Object.hasOwn(data || {}, f)).map(f => data[f]);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* A filter cut down to a set of field names - for a caller who may read only
|
|
92
|
+
* some fields (`api.read.fields`). A condition on any other field is dropped
|
|
93
|
+
* (meta pseudo-fields included), so the answer cannot be used to ask yes/no
|
|
94
|
+
* questions about a value the caller is never shown. The field is read the
|
|
95
|
+
* way the engine reads it (`parseFilterKey`, first segment of a dot-path).
|
|
96
|
+
*
|
|
97
|
+
* @param {Record<string, unknown>|null|undefined} filter
|
|
98
|
+
* @param {Set<string>} allowed
|
|
99
|
+
* @returns {Record<string, unknown>}
|
|
100
|
+
*/
|
|
101
|
+
export function confineFilter(filter, allowed) {
|
|
102
|
+
const out = {};
|
|
103
|
+
for (const key of Object.keys(filter || {})) {
|
|
104
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') continue;
|
|
105
|
+
if (allowed.has(parseFilterKey(key).field.split('.')[0])) out[key] = filter[key];
|
|
106
|
+
}
|
|
107
|
+
return out;
|
|
108
|
+
}
|
|
109
|
+
|
|
77
110
|
/**
|
|
78
111
|
* Resolve a dot-path against an entry, with two special-cased pseudo-fields.
|
|
79
112
|
*
|
|
@@ -18,6 +18,7 @@ import {applyTransforms, getSanitizeExtensions, getShortcodeProcessors} from './
|
|
|
18
18
|
import {getConfig} from '../config.js';
|
|
19
19
|
import {getCollection, listEntries} from './collections.js';
|
|
20
20
|
import {pagesAllowed} from './collectionAccess.js';
|
|
21
|
+
import {confineFilter} from './filterEngine.js';
|
|
21
22
|
import {getMenu, navbarOverrideFromAttrs, resolveLocation, resolveMenuDecorations} from './menus.js';
|
|
22
23
|
import {contentsOverrideFromAttrs} from './pageContents.js';
|
|
23
24
|
import {buildMenuNav} from './menuRender.js';
|
|
@@ -128,6 +129,37 @@ function escapeHtmlText(str) {
|
|
|
128
129
|
* @param {Record<string, string>} attrs - All parsed shortcode attributes
|
|
129
130
|
* @returns {Record<string, string>} Filter object suitable for filterEngine
|
|
130
131
|
*/
|
|
132
|
+
const FIELD_ATTRS = ['title-field', 'body-field', 'date-field', 'status-field', 'icon-field', 'image-field'];
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Shortcode attributes cut down to a set of field names: `fields` keeps only
|
|
136
|
+
* those (all of them when it named none), a `*-field` naming another goes,
|
|
137
|
+
* a `where_` on another goes (the legacy `where=""` whole), and so does a sort.
|
|
138
|
+
* The result has no prototype, and no `__proto__` key is copied: these
|
|
139
|
+
* attributes are a browser's JSON, and an inherited `where` would be read.
|
|
140
|
+
*
|
|
141
|
+
* @param {Record<string, unknown>} attrs
|
|
142
|
+
* @param {Set<string>} allowed
|
|
143
|
+
* @returns {Record<string, unknown>}
|
|
144
|
+
*/
|
|
145
|
+
function confineAttrsToFields(attrs, allowed) {
|
|
146
|
+
const out = Object.create(null);
|
|
147
|
+
const wheres = {};
|
|
148
|
+
for (const key of Object.keys(attrs)) {
|
|
149
|
+
if (key === 'where' || key === '__proto__' || key === 'constructor' || key === 'prototype') continue;
|
|
150
|
+
const value = attrs[key];
|
|
151
|
+
if (key.startsWith('where_')) { wheres[key.slice('where_'.length)] = value; continue; }
|
|
152
|
+
if (FIELD_ATTRS.includes(key) && !allowed.has(String(value))) continue;
|
|
153
|
+
out[key] = value;
|
|
154
|
+
}
|
|
155
|
+
for (const [inner, value] of Object.entries(confineFilter(wheres, allowed))) out[`where_${inner}`] = value;
|
|
156
|
+
const named = typeof attrs.fields === 'string'
|
|
157
|
+
? attrs.fields.split(',').map(f => f.trim()).filter(f => allowed.has(f)) : [];
|
|
158
|
+
out.fields = (named.length ? named : [...allowed]).join(',');
|
|
159
|
+
if (out.sort !== undefined && !allowed.has(String(out.sort)) && !['createdAt', 'updatedAt'].includes(String(out.sort))) delete out.sort;
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
|
|
131
163
|
function buildShortcodeFilter(attrs) {
|
|
132
164
|
const filter = {};
|
|
133
165
|
|
|
@@ -416,7 +448,9 @@ function blockTemplateFields(tpl) {
|
|
|
416
448
|
export function buildBlockStyleTag(blockName, css) {
|
|
417
449
|
if (!css || !css.trim()) return '';
|
|
418
450
|
const body = String(css)
|
|
419
|
-
|
|
451
|
+
// A "<" that could open a tag, as a CSS escape: the sanitiser drops a <style>
|
|
452
|
+
// that holds one. (`width < 600px` and `<=` in a media query stay as written.)
|
|
453
|
+
.replace(/<(?=[a-zA-Z\/!?])/g, '\\3C ')
|
|
420
454
|
.replace(/\n\s*\n+/g, '\n')
|
|
421
455
|
.trim();
|
|
422
456
|
return `<style>[data-block="${escapeAttr(blockName)}"] {\n${body}\n}</style>\n`;
|
|
@@ -443,24 +477,182 @@ export function buildBlockStyleTag(blockName, css) {
|
|
|
443
477
|
* blank lines stay: they are how a template hands a Markdown value to marked.
|
|
444
478
|
* Each line is filled by itself, in one pass as before.
|
|
445
479
|
*/
|
|
480
|
+
/**
|
|
481
|
+
* A placeholder written inside an attribute VALUE of the template's own tag
|
|
482
|
+
* (`<a href="{{{url}}}">`, `title="{{name}}"`, `width={{w}}`), or inside one of
|
|
483
|
+
* the template's own shortcode tags (`[button href="{{url}}"]`), stays inside
|
|
484
|
+
* that value. Quotes and angle brackets become entities, so a `{{{raw}}}` value
|
|
485
|
+
* cannot close the attribute and add its own; line breaks and square brackets
|
|
486
|
+
* do too, because a blank line would end the HTML block and hand the rest of
|
|
487
|
+
* the value to Markdown, whose link output carries a quote, and a `]` would
|
|
488
|
+
* end the shortcode tag. In an unquoted value, spaces and `=` as well. `&` is
|
|
489
|
+
* left alone (entities stay entities).
|
|
490
|
+
*/
|
|
491
|
+
function keepInAttrValue(value, unquoted) {
|
|
492
|
+
return String(value).replace(unquoted ? /["'<>\[\]`\s=]/g : /["'<>\[\]`\r\n]/g, ch => `&#${ch.charCodeAt(0)};`);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Where each placeholder of one template line sits, read the way a browser
|
|
497
|
+
* reads tags:
|
|
498
|
+
* 'quoted' / 'unquoted' inside an attribute value
|
|
499
|
+
* 'tag' between a tag's attributes (`<input {{checked}}>`)
|
|
500
|
+
* 'name' part of a tag or attribute name (`<h{{level}}>`)
|
|
501
|
+
* 'shortcode' / 'shortcode-bare' inside one of the template's shortcode tags, in a quoted value / not
|
|
502
|
+
* nothing in text.
|
|
503
|
+
* `state` carries over lines (a tag may span several): T text, G inside a tag
|
|
504
|
+
* between attributes, E after `=`, U an unquoted value, S / S" / S' inside a
|
|
505
|
+
* shortcode tag, or the open quote.
|
|
506
|
+
*/
|
|
507
|
+
function placeholderContexts(line, spans, state) {
|
|
508
|
+
const at = new Map();
|
|
509
|
+
let next = 0;
|
|
510
|
+
for (let i = 0; i < line.length; i++) {
|
|
511
|
+
const span = spans[next];
|
|
512
|
+
if (span && i === span.index) {
|
|
513
|
+
if (state === '"' || state === "'") at.set(i, 'quoted');
|
|
514
|
+
else if (state === 'E' || state === 'U') { at.set(i, 'unquoted'); state = 'U'; }
|
|
515
|
+
else if (state === 'G') at.set(i, /[\w<:-]/.test(line[i - 1] ?? ' ') ? 'name' : 'tag');
|
|
516
|
+
else if (state[0] === 'S') at.set(i, state === 'S' ? 'shortcode-bare' : 'shortcode');
|
|
517
|
+
i += span[0].length - 1;
|
|
518
|
+
next++;
|
|
519
|
+
continue;
|
|
520
|
+
}
|
|
521
|
+
const ch = line[i];
|
|
522
|
+
if (state === 'T') {
|
|
523
|
+
if (ch === '<' && (/[a-zA-Z/]/.test(line[i + 1] || '') || line.startsWith('{{', i + 1))) state = 'G';
|
|
524
|
+
else if (ch === '[' && /[a-zA-Z/]/.test(line[i + 1] || '')) {
|
|
525
|
+
// A shortcode tag that closes on this line - and not as a Markdown link, [words](address).
|
|
526
|
+
const close = line.indexOf(']', i);
|
|
527
|
+
if (close !== -1 && line[close + 1] !== '(') state = 'S';
|
|
528
|
+
}
|
|
529
|
+
} else if (state === 'G') {
|
|
530
|
+
if (ch === '>') state = 'T'; else if (ch === '=') state = 'E';
|
|
531
|
+
} else if (state === 'E') {
|
|
532
|
+
if (ch === '"' || ch === "'") state = ch;
|
|
533
|
+
else if (ch === '>') state = 'T';
|
|
534
|
+
else if (!/\s/.test(ch)) state = 'U';
|
|
535
|
+
} else if (state === 'U') {
|
|
536
|
+
if (ch === '>') state = 'T'; else if (/\s/.test(ch)) state = 'G';
|
|
537
|
+
} else if (state === 'S') {
|
|
538
|
+
// A quote opens a value only after "=": [don't miss this] has none.
|
|
539
|
+
if (ch === ']') state = 'T'; else if ((ch === '"' || ch === "'") && line[i - 1] === '=') state = `S${ch}`;
|
|
540
|
+
} else if (state[0] === 'S') {
|
|
541
|
+
if (ch === state[1]) state = 'S';
|
|
542
|
+
} else if (ch === state) state = 'G';
|
|
543
|
+
}
|
|
544
|
+
// A line break ends an unquoted value; a quoted one runs on. A shortcode tag
|
|
545
|
+
// is followed on its own line only.
|
|
546
|
+
if (state === 'U') state = 'G';
|
|
547
|
+
if (state[0] === 'S') state = 'T';
|
|
548
|
+
return {at, state};
|
|
549
|
+
}
|
|
550
|
+
|
|
446
551
|
function fillTemplateLines(template, fill) {
|
|
447
552
|
const PLACEHOLDER = /\{\{\{(\w+)\}\}\}|\{\{([\w_]+)(?::([^{}]+))?\}\}/g;
|
|
448
553
|
const out = [];
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
554
|
+
let state = 'T';
|
|
555
|
+
const lines = template.split('\n');
|
|
556
|
+
lines.forEach((line, n) => {
|
|
557
|
+
const spans = [...line.matchAll(PLACEHOLDER)];
|
|
558
|
+
// Alone on its line with a blank line (or the template's edge) either side,
|
|
559
|
+
// in text: where a template hands a value to Markdown.
|
|
560
|
+
const alone = state === 'T' && spans.length === 1 && line.trim() === spans[0][0]
|
|
561
|
+
&& !(lines[n - 1] ?? '').trim() && !(lines[n + 1] ?? '').trim();
|
|
562
|
+
const where = placeholderContexts(line, spans, state);
|
|
563
|
+
state = where.state;
|
|
564
|
+
const filled = line.replace(PLACEHOLDER, (m, raw, key, fmt, offset) => {
|
|
565
|
+
const context = where.at.get(offset) || (alone ? 'markdown' : undefined);
|
|
566
|
+
const value = fill(m, raw, key, fmt, context);
|
|
567
|
+
return ['quoted', 'unquoted', 'shortcode', 'shortcode-bare'].includes(context)
|
|
568
|
+
? keepInAttrValue(value, context === 'unquoted' || context === 'shortcode-bare') : value;
|
|
569
|
+
});
|
|
570
|
+
if (!filled.trim() && line.trim() && /\{\{/.test(line)) return;
|
|
452
571
|
out.push(filled);
|
|
453
|
-
}
|
|
572
|
+
});
|
|
454
573
|
return out.join('\n');
|
|
455
574
|
}
|
|
456
575
|
|
|
576
|
+
/**
|
|
577
|
+
* Entry HTML that reaches a page as HTML (a `{{{raw}}}` placeholder, a body
|
|
578
|
+
* field read as Markdown) may carry content, never the site's own machinery.
|
|
579
|
+
* `data-` attributes are what site.js and the displays act on (a table payload,
|
|
580
|
+
* an Action button, a slideover target), and a <div> an entry dressed as a
|
|
581
|
+
* collection table ran script. So such HTML is PARSED here and written out
|
|
582
|
+
* again under the entry profile of sanitizePageHtml (no `data-*`, no component
|
|
583
|
+
* tags, no <style>, no plugin extensions) - by the same parser the page's own
|
|
584
|
+
* sanitiser uses, so the two cannot read a tag differently. Rewriting the text
|
|
585
|
+
* instead (an entity for the hyphen) was tried and was got round twice.
|
|
586
|
+
*
|
|
587
|
+
* A value with nothing that could open a tag is returned as it is: it is text
|
|
588
|
+
* or Markdown, and cannot make an element. A `>` that starts a line is put
|
|
589
|
+
* back as `>` after the pass (text there, never inside a tag: attribute values
|
|
590
|
+
* come out on one line) so a Markdown quote beside HTML survives.
|
|
591
|
+
*
|
|
592
|
+
* @param {unknown} value
|
|
593
|
+
* @returns {string}
|
|
594
|
+
*/
|
|
595
|
+
function entryHtml(value) {
|
|
596
|
+
const text = String(value ?? '').replace(/[\x02\x03]/g, '');
|
|
597
|
+
// No tag in it: it is text or Markdown and is left alone, but for a "<" at
|
|
598
|
+
// its very end, which would open a tag with whatever the template puts next.
|
|
599
|
+
if (!/<[a-zA-Z\/!?]/.test(text)) return text.replace(/<(\s*)$/, '<$1');
|
|
600
|
+
return sanitizePageHtml(text, {entry: true}).replace(/^(?:> ?)+/gm, quote => quote.replace(/>/g, '>'));
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* An entry value written between a tag's attributes (`<input {{checked}}>`,
|
|
605
|
+
* `<div {{{extra}}}>`): read as attributes and nothing else, and written back
|
|
606
|
+
* one by one. No `data-` name and no handler; the page sanitiser still decides
|
|
607
|
+
* which of the rest the tag may keep.
|
|
608
|
+
*
|
|
609
|
+
* @param {unknown} value
|
|
610
|
+
* @returns {string}
|
|
611
|
+
*/
|
|
612
|
+
function entryAttrs(value) {
|
|
613
|
+
const text = String(value ?? '').replace(/[\x02\x03<>]/g, ' ');
|
|
614
|
+
const kept = [];
|
|
615
|
+
for (const [, name, dq, sq, bare] of text.matchAll(/([^\s"'=\/]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=`]+)))?/g)) {
|
|
616
|
+
if (!/^[a-zA-Z][\w:.-]*$/.test(name) || /^on/i.test(name) || (/^data-/i.test(name) && !/^data-(?:icon|copy)$/i.test(name))) continue;
|
|
617
|
+
const given = dq ?? sq ?? bare;
|
|
618
|
+
kept.push(given === undefined ? name : `${name}="${escapeAttr(given.replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, '&'))}"`);
|
|
619
|
+
}
|
|
620
|
+
return kept.join(' ');
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* An entry's body read as Markdown and kept as content (the entry profile):
|
|
625
|
+
* the body field of the accordion, timeline, carousel and list group displays,
|
|
626
|
+
* and a `{{{raw}}}` value a template hands to Markdown. No line of the result
|
|
627
|
+
* is blank - a blank line (inside a code block, say) would end the HTML block
|
|
628
|
+
* in a later Markdown pass and the rest would be read as Markdown again.
|
|
629
|
+
*/
|
|
630
|
+
function entryBody(value, inline = false) {
|
|
631
|
+
const text = String(value ?? '').replace(/[\x02\x03]/g, '');
|
|
632
|
+
let html = sanitizePageHtml(inline ? marked.parseInline(text) : marked.parse(text), {entry: true});
|
|
633
|
+
// (An inline body - the list group's - keeps its blank lines: they are its paragraphs.)
|
|
634
|
+
while (!inline && /\n[ \t]*\n/.test(html)) html = html.replace(/\n([ \t]*)\n/g, '\n$1 ');
|
|
635
|
+
return html;
|
|
636
|
+
}
|
|
637
|
+
|
|
457
638
|
function interpolateBlockTemplate(blockTemplate, e) {
|
|
458
639
|
// One pass: a raw value put in (pre-rendered HTML) is never read again for
|
|
459
640
|
// placeholders - text that shows "{{title}}" keeps it.
|
|
460
|
-
return fillTemplateLines(blockTemplate, (_, raw, key, fmt) => {
|
|
641
|
+
return fillTemplateLines(blockTemplate, (_, raw, key, fmt, context) => {
|
|
461
642
|
// Entry values never carry a shortcode into the page (inertShortcodes);
|
|
462
|
-
// the template's own markup is untouched.
|
|
463
|
-
|
|
643
|
+
// the template's own markup is untouched. Where the placeholder sits
|
|
644
|
+
// decides what a value may be: attributes between a tag's attributes,
|
|
645
|
+
// name characters inside a name, content (entryHtml / entryBody) in text.
|
|
646
|
+
// Inside an attribute value fillTemplateLines keeps it there.
|
|
647
|
+
const field = raw ?? key;
|
|
648
|
+
const stored = field === '_id' ? e.id : field === '_createdAt' ? e.meta?.createdAt
|
|
649
|
+
: field === '_updatedAt' ? e.meta?.updatedAt : e.data?.[field];
|
|
650
|
+
if (context === 'tag') return inertShortcodes(entryAttrs(stored));
|
|
651
|
+
if (context === 'name') return String(stored ?? '').replace(/[^\w-]/g, '');
|
|
652
|
+
if (raw !== undefined) {
|
|
653
|
+
if (context === 'markdown') return inertShortcodes(entryBody(stored).trim());
|
|
654
|
+
return inertShortcodes(context ? String(stored ?? '') : entryHtml(stored));
|
|
655
|
+
}
|
|
464
656
|
let value;
|
|
465
657
|
if (key === '_id') value = e.id ?? '';
|
|
466
658
|
else if (key === '_createdAt') value = e.meta?.createdAt ?? '';
|
|
@@ -739,7 +931,8 @@ function fileRefHtml(ref) {
|
|
|
739
931
|
const url = escapeAttr(ref.url);
|
|
740
932
|
const name = escapeHtmlText(ref.name);
|
|
741
933
|
if (String(ref.mime || '').startsWith('image/')) {
|
|
742
|
-
|
|
934
|
+
// alt is an attribute: escapeAttr (line breaks as entities), not the text escaper.
|
|
935
|
+
return `<a href="${url}" target="_blank" rel="noopener"><img src="${url}" alt="${escapeAttr(ref.name ?? '')}" loading="lazy" class="dm-file-thumb"></a>`;
|
|
743
936
|
}
|
|
744
937
|
return `<a href="${url}" download>${name}</a>`;
|
|
745
938
|
}
|
|
@@ -903,7 +1096,7 @@ function renderCollectionAccordion(entries, titleField, bodyField, multiple, emp
|
|
|
903
1096
|
const items = entries.map(e => {
|
|
904
1097
|
const title = escapeHtmlText(String(e.data?.[titleField] ?? e.id ?? '(untitled)'));
|
|
905
1098
|
const bodyVal = String(e.data?.[bodyField] ?? '');
|
|
906
|
-
const bodyHtml =
|
|
1099
|
+
const bodyHtml = entryBody(bodyVal);
|
|
907
1100
|
return (
|
|
908
1101
|
`<div class="accordion-item${entryClassSuffix(ctxOpts)}" data-entry-id="${inertShortcodes(escapeAttr(String(e.id ?? '')))}">\n` +
|
|
909
1102
|
` <h3 class="accordion-header"><button class="accordion-button" type="button">${title}` +
|
|
@@ -949,7 +1142,7 @@ function renderCollectionTimeline(entries, opts, ctxOpts = {}) {
|
|
|
949
1142
|
// icon, replacing its children - which wiped each item's title and body before site.js read them.
|
|
950
1143
|
const icon = iconField && e.data?.[iconField] != null ? ` data-event-icon="${escapeAttr(String(e.data[iconField]))}"` : '';
|
|
951
1144
|
const bodyHtml = bodyField
|
|
952
|
-
?
|
|
1145
|
+
? entryBody(e.data?.[bodyField])
|
|
953
1146
|
: '';
|
|
954
1147
|
return `<div class="dm-progression-item${entryClassSuffix(ctxOpts)}" data-entry-id="${inertShortcodes(escapeAttr(String(e.id ?? '')))}"${date}${status}${icon}><div class="dm-progression-item-title">${title}</div><div class="dm-progression-item-body">${bodyHtml}</div></div>`;
|
|
955
1148
|
}).join('\n');
|
|
@@ -1009,7 +1202,7 @@ function renderCollectionCarousel(entries, opts, ctxOpts = {}) {
|
|
|
1009
1202
|
? `<h2 class="carousel-slide-title">${escapeHtmlText(String(e.data[titleField]))}</h2>`
|
|
1010
1203
|
: '';
|
|
1011
1204
|
const bodyHtml = bodyField && e.data?.[bodyField] != null
|
|
1012
|
-
? `<div class="carousel-slide-description">${
|
|
1205
|
+
? `<div class="carousel-slide-description">${entryBody(e.data[bodyField])}</div>`
|
|
1013
1206
|
: '';
|
|
1014
1207
|
inner = inertShortcodes(img + (title || bodyHtml ? `<div class="carousel-slide-content">${title}${bodyHtml}</div>` : ''));
|
|
1015
1208
|
}
|
|
@@ -1102,7 +1295,7 @@ function renderCollectionListgroup(entries, opts, ctxOpts = {}) {
|
|
|
1102
1295
|
? `<strong>${escapeHtmlText(String(e.data[titleField]))}</strong>`
|
|
1103
1296
|
: '';
|
|
1104
1297
|
const body = bodyField && e.data?.[bodyField] != null
|
|
1105
|
-
? `${title ? ' ' : ''}${
|
|
1298
|
+
? `${title ? ' ' : ''}${entryBody(e.data[bodyField], true)}`
|
|
1106
1299
|
: '';
|
|
1107
1300
|
inner = inertShortcodes((title + body) || escapeHtmlText(String(e.id ?? '')));
|
|
1108
1301
|
}
|
|
@@ -1805,13 +1998,17 @@ export const FALLBACK_MAX = 1000;
|
|
|
1805
1998
|
* @param {Array<object>} [opts.entries] - Entries already fetched (a browser shell's), drawn instead of querying
|
|
1806
1999
|
* @returns {Promise<string>} HTML fragment ready to inject into a page
|
|
1807
2000
|
*/
|
|
1808
|
-
export async function renderCollectionFragment(attrs, { extraFilter = null, scope = '', entries: given = null } = {}) {
|
|
2001
|
+
export async function renderCollectionFragment(attrs, { extraFilter = null, scope = '', entries: given = null, readFields = null } = {}) {
|
|
1809
2002
|
const slug = attrs.slug || '';
|
|
1810
2003
|
if (!slug) return '';
|
|
2004
|
+
// Attributes that came from a browser (render-fragment) see only the fields the
|
|
2005
|
+
// collection's public read lists: nothing else is named, filtered or sorted on.
|
|
2006
|
+
const confined = Array.isArray(readFields) && readFields.length ? new Set(readFields) : null;
|
|
2007
|
+
if (confined) attrs = confineAttrsToFields(attrs, confined);
|
|
1811
2008
|
|
|
1812
2009
|
const display = attrs.display || 'table';
|
|
1813
2010
|
const limitAttr = parseInt(attrs.limit, 10) || 0;
|
|
1814
|
-
const sort = attrs.sort
|
|
2011
|
+
const sort = typeof attrs.sort === 'string' && attrs.sort ? attrs.sort : 'createdAt';
|
|
1815
2012
|
const order = attrs.order || 'desc';
|
|
1816
2013
|
const titleField = attrs['title-field'] || '';
|
|
1817
2014
|
const columns = attrs.columns || '3';
|
|
@@ -1855,9 +2052,12 @@ export async function renderCollectionFragment(attrs, { extraFilter = null, scop
|
|
|
1855
2052
|
if (Object.keys(filter).length) listOpts.filter = filter;
|
|
1856
2053
|
|
|
1857
2054
|
// A browser shell hands over the entries it already fetched (refs resolved).
|
|
1858
|
-
|
|
2055
|
+
let {entries} = Array.isArray(given) ? {entries: given} : await listEntries(slug, listOpts);
|
|
2056
|
+
const only = (object) => Object.fromEntries(Object.entries(object || {}).filter(([k]) => confined.has(k)));
|
|
2057
|
+
if (confined) entries = entries.map(e => ({...e, data: only(e.data), ...(e._refs && {_refs: only(e._refs)})}));
|
|
1859
2058
|
|
|
1860
2059
|
let fields = schema.fields || [];
|
|
2060
|
+
if (confined) fields = fields.filter(f => confined.has(f.name));
|
|
1861
2061
|
if (fieldFilter?.length) {
|
|
1862
2062
|
fields = fieldFilter.map(name => fields.find(f => f.name === name) || { name, label: name });
|
|
1863
2063
|
} else {
|
|
@@ -2713,11 +2913,19 @@ export function classToken(value) {
|
|
|
2713
2913
|
}
|
|
2714
2914
|
|
|
2715
2915
|
export function escapeAttr(str) {
|
|
2916
|
+
// ' and line breaks too. A value is often entry data, and the HTML this makes
|
|
2917
|
+
// is read again by Markdown: a blank line inside an attribute value ended the
|
|
2918
|
+
// HTML block there, the rest of the value was read as Markdown, and the quotes
|
|
2919
|
+
// a Markdown link writes closed the attribute and added others. As entities a
|
|
2920
|
+
// browser reads the same value, and a later pass sees one unbroken line.
|
|
2716
2921
|
return String(str)
|
|
2717
2922
|
.replace(/&/g, '&')
|
|
2718
2923
|
.replace(/"/g, '"')
|
|
2924
|
+
.replace(/'/g, ''')
|
|
2719
2925
|
.replace(/</g, '<')
|
|
2720
|
-
.replace(/>/g, '>')
|
|
2926
|
+
.replace(/>/g, '>')
|
|
2927
|
+
.replace(/\r/g, ' ')
|
|
2928
|
+
.replace(/\n/g, ' ');
|
|
2721
2929
|
}
|
|
2722
2930
|
|
|
2723
2931
|
/**
|
|
@@ -3680,9 +3888,16 @@ function processCardBlocks(markdown) {
|
|
|
3680
3888
|
const body = restore(range.name === 'card' && layout === 'code-snippet'
|
|
3681
3889
|
? rawBody : render(rawBody, true));
|
|
3682
3890
|
const renderer = LAYOUT_RENDERERS[layout] || renderLegacyCard;
|
|
3683
|
-
const
|
|
3891
|
+
const drawn = range.name === 'box'
|
|
3684
3892
|
? renderBox(attrs, body)
|
|
3685
3893
|
: renderer(attrs, body, inertMarked, escapeAttr);
|
|
3894
|
+
// A code span in an attribute (title="Run `npm test`") is still its scrub
|
|
3895
|
+
// placeholder here (the body's were restored above): print it as the words
|
|
3896
|
+
// written - escaped, brackets as entities - so it is never markup or a tag.
|
|
3897
|
+
const html = drawn.replace(SCRUB_PLACEHOLDER, mark => {
|
|
3898
|
+
const written = restore(mark);
|
|
3899
|
+
return written === mark ? mark : bracketSafeAttr(written);
|
|
3900
|
+
});
|
|
3686
3901
|
const token = `<!--cms-card-${nonce}-${held.size}-->`;
|
|
3687
3902
|
held.set(token, html);
|
|
3688
3903
|
const gap = nested ? '\n\n' : '';
|
|
@@ -5022,9 +5237,12 @@ async function expandReferenceFields(form) {
|
|
|
5022
5237
|
const r = await listEntries(targetSlug, {limit: REF_LIMIT, sort: displayField, order: 'asc'});
|
|
5023
5238
|
const options = (r.entries || []).map(e => ({
|
|
5024
5239
|
value: e.id,
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5240
|
+
// Words, never markup: Domma writes an option's label as HTML, and
|
|
5241
|
+
// this one is another collection's entry value. Angle brackets
|
|
5242
|
+
// become their look-alikes (right whether it is read as HTML or text).
|
|
5243
|
+
label: String((e.data?.[displayField] != null && e.data[displayField] !== '')
|
|
5244
|
+
? e.data[displayField]
|
|
5245
|
+
: e.id).replace(/</g, '\u2039').replace(/>/g, '\u203A')
|
|
5028
5246
|
}));
|
|
5029
5247
|
|
|
5030
5248
|
// Replace with a select; preserve label/required/helper from the original.
|
|
@@ -5234,11 +5452,14 @@ function holdBannerTags(markdown) {
|
|
|
5234
5452
|
const held = new Map();
|
|
5235
5453
|
if (!/\[banner/i.test(markdown)) return {text: markdown, held};
|
|
5236
5454
|
const nonce = randomUUID();
|
|
5237
|
-
|
|
5455
|
+
// A [banner] in a code example is an example: it is not held, and not run.
|
|
5456
|
+
const {scrubbed, restore} = scrubCodeRegions(markdown);
|
|
5457
|
+
const text = restore(scrubbed.replace(/\[banner([^\]]*)\]/gi, (_, attrStr) => {
|
|
5238
5458
|
const token = `dmb-${nonce}-${held.size}`;
|
|
5239
|
-
|
|
5459
|
+
// The attributes as written: a code span in one (title="Run `npm test`") goes back in.
|
|
5460
|
+
held.set(token, restore(attrStr));
|
|
5240
5461
|
return `[banner ${token}]`;
|
|
5241
|
-
});
|
|
5462
|
+
}));
|
|
5242
5463
|
return {text, held};
|
|
5243
5464
|
}
|
|
5244
5465
|
|
|
@@ -5261,7 +5482,8 @@ function holdBannerTags(markdown) {
|
|
|
5261
5482
|
* @returns {string}
|
|
5262
5483
|
*/
|
|
5263
5484
|
function processBannerBlocks(markdown, held = null) {
|
|
5264
|
-
|
|
5485
|
+
const {scrubbed, restore} = scrubCodeRegions(markdown);
|
|
5486
|
+
return restore(scrubbed.replace(
|
|
5265
5487
|
/(<p>)?\[banner([^\]]*)\]([\s\S]*?)\[\/banner\](<\/p>)?/gi,
|
|
5266
5488
|
(_, openP, rawAttrStr, rawBody, closeP) => {
|
|
5267
5489
|
// A tag the author wrote carries a held token (holdBannerTags), so its
|
|
@@ -5271,7 +5493,7 @@ function processBannerBlocks(markdown, held = null) {
|
|
|
5271
5493
|
// because the quotes in entry data reach here as entities.
|
|
5272
5494
|
const token = rawAttrStr.trim();
|
|
5273
5495
|
const authored = !!held && held.has(token);
|
|
5274
|
-
const attrStr = authored ? held.get(token) : rawAttrStr;
|
|
5496
|
+
const attrStr = authored ? held.get(token) : restore(rawAttrStr);
|
|
5275
5497
|
const wrapped = authored && !!(openP && closeP);
|
|
5276
5498
|
let body = rawBody;
|
|
5277
5499
|
if (wrapped) {
|
|
@@ -5300,7 +5522,7 @@ function processBannerBlocks(markdown, held = null) {
|
|
|
5300
5522
|
const titleHtml = title
|
|
5301
5523
|
? `<strong class="dm-banner__title">${escapeAttr(title)}</strong>\n `
|
|
5302
5524
|
: '';
|
|
5303
|
-
const bodyHtml = markedBody(body.trim());
|
|
5525
|
+
const bodyHtml = markedBody(restore(body.trim()));
|
|
5304
5526
|
const dismissHtml = dismissible
|
|
5305
5527
|
? `\n <button type="button" class="dm-banner__dismiss" aria-label="Dismiss">×</button>`
|
|
5306
5528
|
: '';
|
|
@@ -5313,7 +5535,7 @@ function processBannerBlocks(markdown, held = null) {
|
|
|
5313
5535
|
`</div>\n${after}`
|
|
5314
5536
|
);
|
|
5315
5537
|
}
|
|
5316
|
-
);
|
|
5538
|
+
));
|
|
5317
5539
|
}
|
|
5318
5540
|
|
|
5319
5541
|
function processSlideoverBlocks(markdown) {
|
|
@@ -5551,8 +5773,12 @@ function processCtaBlocks(markdown) {
|
|
|
5551
5773
|
* @param {string} html
|
|
5552
5774
|
* @returns {string}
|
|
5553
5775
|
*/
|
|
5554
|
-
export function sanitizePageHtml(html) {
|
|
5555
|
-
|
|
5776
|
+
export function sanitizePageHtml(html, {entry = false} = {}) {
|
|
5777
|
+
// The entry profile (entryHtml): content an entry may carry - none of the
|
|
5778
|
+
// site's machinery. No data-* attribute, no component tag, no <style>, and
|
|
5779
|
+
// nothing a plugin added to the lists.
|
|
5780
|
+
const extensions = entry ? {tags: [], attributes: {}} : getSanitizeExtensions();
|
|
5781
|
+
const dmTags = entry ? [] : _dmTagAllowlist;
|
|
5556
5782
|
return sanitizeHtml(html, {
|
|
5557
5783
|
// `style` is intentionally allowed below so per-block custom CSS can
|
|
5558
5784
|
// reach the page. Admins write block templates; same trust model as
|
|
@@ -5572,6 +5798,28 @@ export function sanitizePageHtml(html) {
|
|
|
5572
5798
|
// definition, so the hostname gate has nothing to say about it: the gate
|
|
5573
5799
|
// exists to stop embedding somebody else's site, not your own page.
|
|
5574
5800
|
allowIframeRelativeUrls: true,
|
|
5801
|
+
// No event handler on any tag. The per-tag lists below already leave them
|
|
5802
|
+
// out, but a registered dm-<name> component takes every attribute ('*'),
|
|
5803
|
+
// and a handler on one ran: <dm-counter autofocus onfocus="…">.
|
|
5804
|
+
transformTags: {
|
|
5805
|
+
'*': (tagName, attribs) => {
|
|
5806
|
+
for (const name of Object.keys(attribs)) {
|
|
5807
|
+
if (/^on/i.test(name)) delete attribs[name];
|
|
5808
|
+
// Entry profile: a value on one line. A blank line inside one would end
|
|
5809
|
+
// the HTML block in a later Markdown pass, and what Markdown then wrote
|
|
5810
|
+
// (a link's quotes) would close the attribute and add others.
|
|
5811
|
+
else if (entry) attribs[name] = String(attribs[name]).replace(/\s*[\r\n]+\s*/g, ' ');
|
|
5812
|
+
}
|
|
5813
|
+
return {tagName, attribs};
|
|
5814
|
+
}
|
|
5815
|
+
},
|
|
5816
|
+
// CSS never needs a "<" that could open a tag (buildBlockStyleTag writes it as
|
|
5817
|
+
// an escape). A <style> holding one is markup waiting for a parser that reads
|
|
5818
|
+
// the element another way (<select><style></select><img onerror>), so the
|
|
5819
|
+
// whole element goes. (sanitize-html's textFilter is not run on <style> text,
|
|
5820
|
+
// so it cannot be escaped here instead: an inline <style> with an SVG data:
|
|
5821
|
+
// URI must write its "<" as %3C.)
|
|
5822
|
+
exclusiveFilter: frame => frame.tag === 'style' && /<[a-zA-Z\/!?]/.test(frame.text),
|
|
5575
5823
|
allowedTags: sanitizeHtml.defaults.allowedTags.concat([
|
|
5576
5824
|
'img', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
|
|
5577
5825
|
'form', 'input', 'textarea', 'select', 'option', 'optgroup',
|
|
@@ -5581,11 +5829,11 @@ export function sanitizePageHtml(html) {
|
|
|
5581
5829
|
// <style> tags are emitted by block rendering (buildBlockStyleTag) so
|
|
5582
5830
|
// per-block custom CSS can reach the page. Admin-trust: block authors
|
|
5583
5831
|
// are admins, same security model as site-wide content/custom.css.
|
|
5584
|
-
'style',
|
|
5832
|
+
...(entry ? [] : ['style']),
|
|
5585
5833
|
// dm-<name> custom-element tags - one per registered component. Refreshed
|
|
5586
5834
|
// by refreshComponentTagAllowlist() on startup and after create/delete.
|
|
5587
5835
|
// Component authors are super-admins, same trust model as plugin code.
|
|
5588
|
-
...
|
|
5836
|
+
...dmTags,
|
|
5589
5837
|
...extensions.tags
|
|
5590
5838
|
]),
|
|
5591
5839
|
allowedAttributes: {
|
|
@@ -5594,7 +5842,9 @@ export function sanitizePageHtml(html) {
|
|
|
5594
5842
|
// drag grip) so it isn't announced as an empty item. aria-current marks
|
|
5595
5843
|
// the [menu] item for the page you are on. Both presentational only, no
|
|
5596
5844
|
// script surface - unlike the on* handlers stripped globally.
|
|
5597
|
-
|
|
5845
|
+
// Entry HTML keeps the two data- attributes that only decorate: an icon by
|
|
5846
|
+
// name, and text for a copy button. Nothing that carries a payload or an action.
|
|
5847
|
+
'*': ['class', 'id', 'style', ...(entry ? ['data-icon', 'data-copy'] : ['data-*']), 'aria-hidden', 'aria-current'],
|
|
5598
5848
|
img: ['src', 'alt', 'title', 'width', 'height', 'loading'],
|
|
5599
5849
|
form: ['action', 'method'],
|
|
5600
5850
|
input: ['type', 'name', 'placeholder', 'value', 'required', 'disabled',
|
|
@@ -5605,7 +5855,7 @@ export function sanitizePageHtml(html) {
|
|
|
5605
5855
|
select: ['name', 'required', 'disabled', 'multiple'],
|
|
5606
5856
|
option: ['value', 'selected', 'disabled'],
|
|
5607
5857
|
optgroup: ['label', 'disabled'],
|
|
5608
|
-
button: ['type', 'disabled', 'aria-label', 'data-action', 'data-entry', 'data-confirm'],
|
|
5858
|
+
button: ['type', 'disabled', 'aria-label', ...(entry ? [] : ['data-action', 'data-entry', 'data-confirm'])],
|
|
5609
5859
|
label: ['for'],
|
|
5610
5860
|
fieldset: ['disabled'],
|
|
5611
5861
|
iframe: ['src', 'title', 'width', 'height', 'allow', 'allowfullscreen',
|
|
@@ -5616,8 +5866,8 @@ export function sanitizePageHtml(html) {
|
|
|
5616
5866
|
// Allow any attribute on every registered dm-* tag. Props are
|
|
5617
5867
|
// author-defined and enumerating them at sanitise time has no security
|
|
5618
5868
|
// benefit - custom-element attributes cannot execute JS on their own,
|
|
5619
|
-
// and `on*` handlers
|
|
5620
|
-
...
|
|
5869
|
+
// and `on*` handlers are stripped from every tag by transformTags above.
|
|
5870
|
+
...dmTags.reduce((acc, tag) => { acc[tag] = ['*']; return acc; }, {}),
|
|
5621
5871
|
...extensions.attributes
|
|
5622
5872
|
}
|
|
5623
5873
|
});
|
|
@@ -184,12 +184,12 @@
|
|
|
184
184
|
searchable / filterable / sortable / paginate attributes) -->
|
|
185
185
|
<!-- Its range-filter arithmetic; a module that runs first and sets window.DommaCollectionRange -->
|
|
186
186
|
<script src="/public/js/collection-range.mjs?v=20261025-range-slider" type="module"></script>
|
|
187
|
-
<script src="/public/js/collection-browser.js?v=
|
|
187
|
+
<script src="/public/js/collection-browser.js?v=20261115-safe-links" defer></script>
|
|
188
188
|
<!-- Core Forms logic engine (must run before forms.js and site.js) -->
|
|
189
189
|
<script src="/public/js/form-logic-engine.js?v=20261031-forms-reduce-motion" defer></script>
|
|
190
190
|
|
|
191
191
|
<!-- Site initialisation -->
|
|
192
|
-
<script src="/public/js/site.js?v=20261115-
|
|
192
|
+
<script src="/public/js/site.js?v=20261115-table-titles-2" type="module"></script>
|
|
193
193
|
<script src="/public/js/collection-context.js?v=20261010-utf8-payloads" type="module"></script>
|
|
194
194
|
{{ctxMenusModule}}
|
|
195
195
|
<!-- [image zoom] pictures' full-size view - only on a page that has one -->
|