domma-cms 1.48.3 → 1.49.1
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 +8 -0
- package/CLAUDE.md +5 -0
- package/docs/plugin-development.md +40 -0
- package/package.json +1 -1
- package/public/js/form-embed.js +1 -0
- package/public/js/forms.js +2 -2
- package/public/js/site.js +1 -1
- package/server/routes/api/forms.js +43 -3
- package/server/services/collections.js +3 -2
- package/server/services/formContext.js +166 -0
- package/server/services/markdown.js +3 -3
- package/server/templates/page.html +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.49.1] - 2026-11-09
|
|
4
|
+
|
|
5
|
+
- Plugin shortcodes are told who is viewing: the context passed to a `registerShortcode` handler now carries `user` (the signed-in viewer, or `null` for an anonymous render). Job Board's preview shortcodes use it so a super admin sees them on a page only super admins can open. Each page is rendered for the viewer's own roles and cached under those roles, so one viewer's output is never served to another.
|
|
6
|
+
|
|
7
|
+
## [1.49.0] - 2026-11-09
|
|
8
|
+
|
|
9
|
+
- **A Domma Form can be shown in a plugin's admin panel.** `public/js/form-embed.js` `renderForm(container, slug, {token, contextToken, onSubmitted})` renders it exactly as the public site does and posts with the signed-in user's Bearer token; `onSubmitted` gets the stored entry's id. A plugin's route signs the context the form is filled in for (`server/services/formContext.js` `signFormContext` - HMAC, one form, one user, 30 minutes); the submit route keeps it as the entry's `meta.context` only from a Bearer-signed post by that user, and refuses the submission otherwise. Nothing the browser sends can set `meta.context` (`_context` is dropped). `readFormEntry`, `removeFormEntry` and `formEntriesBy` let a plugin check an entry, and delete a person's when their data is erased.
|
|
10
|
+
|
|
3
11
|
## [1.48.3] - 2026-11-09
|
|
4
12
|
|
|
5
13
|
- **Confined accounts see only their own screens' chrome.** A user whose roles confine them to part of the admin (Roles > Admin area, or a plugin's roles such as the Job Board's) no longer sees the Versions menu, Frequent (side and top), the whole admin's folders (a folder holding one thing gives way to it - Job Board and Notifications, not Tools > Business > Job Board / System > Notifications), Arrange, or the version, date, licence and expiry on plugin banners (the banner's own buttons stay). Admins see no change.
|
package/CLAUDE.md
CHANGED
|
@@ -407,6 +407,11 @@ the collection mirrors the form's `required` - and stamps `meta.outcome`. `notif
|
|
|
407
407
|
forgetting triggers is the obvious failure. `goto-step` is announced as a `dm-form-trigger` DOM event
|
|
408
408
|
rather than performed, since the wizard handle belongs to the embed.
|
|
409
409
|
|
|
410
|
+
**Forms in admin panels** (`public/js/form-embed.js`, `server/services/formContext.js`): a plugin signs a context
|
|
411
|
+
server-side (`signFormContext`), the panel renders the form with it and the user's Bearer token, and the submit route
|
|
412
|
+
stores `meta.context` only for a Bearer-signed post by that user, on that form, in time - otherwise it refuses the
|
|
413
|
+
submission. `_context` from the browser is dropped. forms.js does nothing on import while `__DM_FORMS_EMBED__` is set.
|
|
414
|
+
|
|
410
415
|
## Import from WordPress
|
|
411
416
|
|
|
412
417
|
A built-in Tool (`wordpress-import` in `services/tools.js`, permission `import.wordpress` - level 0, granted once to
|
|
@@ -723,6 +723,46 @@ fields. Optional frontmatter: `title` (the tab label; default from the file name
|
|
|
723
723
|
|
|
724
724
|
---
|
|
725
725
|
|
|
726
|
+
## Domma Forms in an admin panel
|
|
727
|
+
|
|
728
|
+
A plugin can ask its users to fill in a site form (built under Forms) inside one of its own panels, and know
|
|
729
|
+
afterwards that a given entry was made by that user, on that form, for that record of the plugin's.
|
|
730
|
+
|
|
731
|
+
1. **Sign the context on the server** - in your own route, for the signed-in user you are answering:
|
|
732
|
+
|
|
733
|
+
```js
|
|
734
|
+
import {signFormContext} from '../../server/services/formContext.js';
|
|
735
|
+
const contextToken = signFormContext({form: 'right-to-represent', userId: request.user.id, context: {proposal: id}});
|
|
736
|
+
```
|
|
737
|
+
|
|
738
|
+
Up to 20 keys, string / number / boolean values. The token is HMAC-signed and expires after 30 minutes. It is
|
|
739
|
+
signed, not secret - the browser can read the context, so put nothing private in it - and it can be sent more than
|
|
740
|
+
once while it lasts: check the entry you are handed, and accept one.
|
|
741
|
+
|
|
742
|
+
2. **Render it in the panel** (admin JS):
|
|
743
|
+
|
|
744
|
+
```js
|
|
745
|
+
const {renderForm} = await import('/public/js/form-embed.js');
|
|
746
|
+
const form = await renderForm(panel, 'right-to-represent', {token: () => S.get('auth_token'), contextToken,
|
|
747
|
+
onSubmitted: ({entryId}) => { /* send entryId to your route */ }});
|
|
748
|
+
// form.destroy() when the panel closes
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
3. **Check the entry on the server** before acting on it:
|
|
752
|
+
|
|
753
|
+
```js
|
|
754
|
+
import {readFormEntry, removeFormEntry} from '../../server/services/formContext.js';
|
|
755
|
+
const entry = await readFormEntry('right-to-represent', entryId); // null: no such entry on this form
|
|
756
|
+
// entry.meta.createdBy === the user; entry.meta.context === what you signed
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
The submit route keeps `meta.context` only from a post signed in with a Bearer token whose user the context was
|
|
760
|
+
signed for, on that form, before it expires - anything else is refused (401/403, or 400 when it expired) and nothing
|
|
761
|
+
is stored. A context sent any other way (`_context` in the body) is dropped. `onSubmitted` gets `entryId: null` when
|
|
762
|
+
nothing was stored (an end-form set not to record) - treat that as not sent. An entry edited later keeps its meta: compare
|
|
763
|
+
`meta.updatedAt` with `meta.createdAt` if the answers must be as sent. When the person's data is erased, use
|
|
764
|
+
`removeFormEntry`, and `formEntriesBy(form, userId)` for the entries they sent but your plugin never used. Feature-detect an older core: `import('../../server/services/formContext.js').catch(() => null)`.
|
|
765
|
+
|
|
726
766
|
## Dashboard widgets
|
|
727
767
|
|
|
728
768
|
With **Dashboard Pro**, admins build their own Dashboard from widgets the Tools offer. A widget ships
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const FORM_EMBED_VERSION=1;let s=null;function c(r,o){return document.querySelector(r)?Promise.resolve():new Promise(t=>{const n=o();n.addEventListener("load",()=>t(),{once:!0}),n.addEventListener("error",()=>t(),{once:!0}),document.head.appendChild(n)})}function d(){return s||(s=(async()=>(await c('link[data-dm-forms-css], link[href^="/public/css/forms.css"]',()=>{const r=Object.assign(document.createElement("link"),{rel:"stylesheet",href:"/public/css/forms.css?v=20261031-forms-reduce-motion"});return r.setAttribute("data-dm-forms-css","1"),r}),window.FormLogicEngine||await c('script[src^="/public/js/form-logic-engine.js"]',()=>Object.assign(document.createElement("script"),{src:"/public/js/form-logic-engine.js?v=20261031-forms-reduce-motion"})),globalThis.__DM_FORMS_EMBED__=!0,import("/public/js/forms.js?v=20261109-form-embed")))(),s)}export async function renderForm(r,o,{token:t="",contextToken:n="",onSubmitted:i=null}={}){if(!r||!/^[a-z0-9][a-z0-9-]{0,99}$/.test(String(o||"")))throw new Error("renderForm: a container and a form slug are needed");const m=await d(),e=document.createElement("div");return e.className="dm-form-embed",e.setAttribute("data-form",o),e.__dmFormEmbed={token:typeof t=="function"?t:String(t||""),contextToken:String(n||""),onSubmitted:i},r.appendChild(e),m.renderFormTarget(e),{element:e,destroy:()=>{e.__dmFormEmbed=null,e.remove()}}}
|
package/public/js/forms.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{installSmoothCarets as
|
|
2
|
-
`).replace(/<[^>]+>/g,""))}function P(n){return String(n).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function N(n,r){let t=!1;n.addEventListener("dm-form-end",function(e){const i=e.detail&&e.detail.validation;if(i&&!i.valid){markInvalidFields(n,i.missing),showValidationPopup(i);return}t||(t=!0,n.classList.add("fb-form-loading"),Promise.resolve(r(e.detail&&e.detail.values||{})).catch(function(){}).finally(function(){t=!1,n.classList.remove("fb-form-loading")}))})}function x(n,r,t){const e=n.querySelector(".fb-form-success, .fb-form-error");e&&e.remove();const i=document.createElement("div");i.className=t==="success"?"fb-form-success":"fb-form-error",i.textContent=r,n.appendChild(i)}function z(n,r){if(n._formLogicRuntime=r,n._formLogicObserver&&(n._formLogicObserver.disconnect(),n._formLogicObserver=null),!n.parentNode||typeof MutationObserver>"u"||n._formLogicObserved)return;n._formLogicObserved=!0;const t=new MutationObserver(function(e){for(const i of e)for(const o of i.removedNodes)if(o===n||o.nodeType===1&&o.contains&&o.contains(n)){n._formLogicRuntime&&n._formLogicRuntime.destroy(),t.disconnect();return}});t.observe(n.parentNode,{childList:!0,subtree:!1}),n._formLogicObserver=t}function se(n){const r=n&&n.logic;return!!(r&&(r.visibility||r.requirement))}function O(n,r){const t={};return n.forEach(function(e){if(e.type==="page-break"||e.type==="spacer"||!e.name)return;const i=e.type==="chooser"||!!(e.variant&&["select","radio","checkbox-group"].includes(e.type)),o=e.type==="checkbox"?"boolean":e.type==="date"||e.type==="icon"||e.type==="image"?"string":i?"chooser":e.type,d={...e.formConfig||{}};d.span==="full"&&r&&(d.span=r);const s={type:o,label:e.label||e.name,required:se(e)?!1:e.required||!1,options:e.options,formConfig:{...e.placeholder&&{placeholder:e.placeholder},...e.helper&&{helperText:e.helper},...e.tooltip&&{tooltip:e.tooltip},...d}};e.minLength!==void 0&&(s.minLength=e.minLength),e.maxLength!==void 0&&(s.maxLength=e.maxLength),e.min!==void 0&&(s.min=e.min),e.max!==void 0&&(s.max=e.max),i&&(e.variant&&(s.variant=e.variant),(e.multiple||e.type==="checkbox-group")&&(s.multiple=!0),e.density&&(s.density=e.density),e.columns&&(s.columns=e.columns),e.accent&&(s.accent=e.accent),e.accentStyle&&(s.accentStyle=e.accentStyle),e.glow&&(s.glow=!0),e.glowColour&&(s.glowColour=e.glowColour),e.shadow&&(s.shadow=e.shadow),e.shadowColour&&(s.shadowColour=e.shadowColour)),t[e.name]=e.type==="file"?te(e,s):s}),t}function ce(n){const r={};return n.forEach(function(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&&(r[t.name]=typeof e=="object"?e.value:e)}}),r}function D(n,r){(r||[]).forEach(function(t){if(t.type!=="date"||!t.name)return;const e=n.querySelector('[name="'+t.name+'"]');e&&e.type!=="date"&&(e.type="date")})}const M="padding:.45rem .7rem;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md,6px);background:transparent;color:inherit;cursor:pointer;font:inherit;font-size:.85em;flex-shrink:0;line-height:1.2;";function V(n){const r=document.createElement("div");r.style.cssText="position:fixed;inset:0;z-index:9999;background:rgba(0,0,0,.55);display:flex;align-items:center;justify-content:center;padding:20px;";const t=document.createElement("div");t.style.cssText="background:var(--dm-surface-overlay,var(--dm-surface));color:var(--dm-text);border:1px solid var(--dm-border);border-radius:10px;width:100%;max-width:560px;max-height:75vh;display:flex;flex-direction:column;gap:.6rem;padding:1rem;box-shadow:var(--dm-shadow-lg,0 12px 40px rgba(0,0,0,.35));";const e=document.createElement("div");e.style.cssText="display:flex;align-items:center;justify-content:space-between;gap:.5rem;";const i=document.createElement("strong");i.textContent=n;const o=document.createElement("button");o.type="button",o.textContent="\xD7",o.setAttribute("aria-label","Close"),o.style.cssText=M+"font-size:1rem;padding:.15rem .55rem;",e.appendChild(i),e.appendChild(o),t.appendChild(e);const d=document.createElement("div");d.style.cssText="display:flex;flex-direction:column;gap:.6rem;overflow:hidden;min-height:0;",t.appendChild(d),r.appendChild(t);const s=l=>{l.key==="Escape"&&a()};function a(){document.removeEventListener("keydown",s),r.remove()}return o.addEventListener("click",a),r.addEventListener("click",l=>{l.target===r&&a()}),document.addEventListener("keydown",s),document.body.appendChild(r),{body:d,close:a}}function le(n){const{body:r,close:t}=V("Choose an icon"),e=document.createElement("input");e.type="text",e.placeholder="Search icons\u2026",e.className="form-input",e.style.cssText="padding:.45rem .6rem;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md,6px);background:var(--dm-input-bg,transparent);color:var(--dm-text);",r.appendChild(e);const i=document.createElement("div");i.style.cssText="display:grid;grid-template-columns:repeat(auto-fill,minmax(46px,1fr));gap:4px;overflow-y:auto;min-height:0;",r.appendChild(i);const o=window.I&&typeof I.list=="function"?I.list():[],d=o.map(s=>{const a=document.createElement("button");a.type="button",a.title=s,a.dataset.iconName=s,a.style.cssText="display:flex;align-items:center;justify-content:center;padding:.55rem 0;border:1px solid transparent;border-radius:6px;background:transparent;color:inherit;cursor:pointer;";const l=document.createElement("span");return l.setAttribute("data-icon",s),l.setAttribute("data-icon-size","18"),a.appendChild(l),a.addEventListener("mouseenter",()=>{a.style.borderColor="var(--dm-border)"}),a.addEventListener("mouseleave",()=>{a.style.borderColor="transparent"}),a.addEventListener("click",()=>{t(),n(s)}),i.appendChild(a),a});if(!o.length){const s=document.createElement("p");s.textContent="Icon engine unavailable - type an icon name into the field instead.",i.appendChild(s)}window.I?.scan?.(i),e.addEventListener("input",()=>{const s=e.value.trim().toLowerCase();d.forEach(a=>{a.style.display=!s||a.dataset.iconName.includes(s)?"":"none"})}),e.focus()}async function ue(){const n=typeof S<"u"&&S.get?S.get("auth_token"):null;if(!n)return{error:"auth"};const r=i=>fetch("/api/media",{headers:{Authorization:"Bearer "+i}});let t;try{if(t=await r(n),t.status===401&&S.get("auth_refresh_token")){const i=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:S.get("auth_refresh_token")})});if(i.ok){const{token:o}=await i.json();S.set("auth_token",o),t=await r(o)}}}catch{return{error:"load"}}if(!t.ok)return{error:t.status===401||t.status===403?"auth":"load"};const e=await t.json().catch(()=>[]);return{files:(Array.isArray(e)?e:[]).filter(i=>/\.(png|jpe?g|gif|webp|svg|avif)$/i.test(i.name||i.url||""))}}function de(n){const{body:r,close:t}=V("Choose an image"),e=document.createElement("p");e.textContent="Loading media library\u2026",e.style.cssText="margin:0;font-size:.85em;color:var(--dm-text-muted);",r.appendChild(e),ue().then(({files:i,error:o})=>{if(o){e.textContent=o==="auth"?"Sign in with media access to browse the library - or paste an image URL into the field.":"Could not load the media library - paste an image URL into the field instead.";return}if(!i.length){e.textContent="No images in the media library yet.";return}e.remove();const d=document.createElement("div");d.style.cssText="display:grid;grid-template-columns:repeat(auto-fill,minmax(104px,1fr));gap:8px;overflow-y:auto;min-height:0;",i.forEach(s=>{const a=document.createElement("button");a.type="button",a.title=s.name||s.url,a.style.cssText="display:flex;flex-direction:column;gap:.25rem;padding:.35rem;border:1px solid var(--dm-border);border-radius:8px;background:transparent;color:inherit;cursor:pointer;min-width:0;";const l=document.createElement("img");l.src=s.url,l.alt=s.name||"",l.loading="lazy",l.style.cssText="width:100%;height:72px;object-fit:cover;border-radius:5px;";const h=document.createElement("span");h.textContent=s.name||s.url,h.style.cssText="font-size:.68em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",a.appendChild(l),a.appendChild(h),a.addEventListener("click",()=>{t(),n(s.url)}),d.appendChild(a)}),r.appendChild(d)})}function W(n,r){n.value=r,n.dispatchEvent(new Event("input",{bubbles:!0})),n.dispatchEvent(new Event("change",{bubbles:!0}))}function U(n){const r=document.createElement("div");return r.style.cssText="display:flex;align-items:center;gap:.5rem;",n.parentNode.insertBefore(r,n),r.appendChild(n),n.style.flex="1",n.style.minWidth="0",r}function H(n){const r=document.createElement("button");return r.type="button",r.textContent=n,r.style.cssText=M,r}function me(n){if(!window.I||typeof I.list!="function")return;const r=U(n),t=document.createElement("span");t.style.cssText="display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;flex-shrink:0;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md,6px);";const e=()=>{t.textContent="";const o=n.value.trim();if(!o)return;const d=document.createElement("span");d.setAttribute("data-icon",o),d.setAttribute("data-icon-size","16"),t.appendChild(d),window.I?.scan?.(t)};n.addEventListener("input",e),e();const i=H("Browse");i.addEventListener("click",()=>le(o=>{W(n,o),e()})),r.appendChild(t),r.appendChild(i)}function pe(n){const r=U(n),t=document.createElement("img");t.alt="",t.style.cssText="width:2rem;height:2rem;flex-shrink:0;object-fit:cover;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md,6px);display:none;";const e=()=>{const o=n.value.trim();t.style.display=o?"":"none",o&&(t.src=o)};n.addEventListener("input",e),e();const i=H("Browse");i.addEventListener("click",()=>de(o=>{W(n,o),e()})),r.appendChild(t),r.appendChild(i)}export function enhancePickerFields(n,r){const t=typeof n=="string"?document.querySelector(n):n;t&&(r||[]).forEach(function(e){if(!e.name||e.type!=="icon"&&e.type!=="image")return;const i=t.querySelector('[name="'+e.name+'"]');!i||i.dataset.pickerEnhanced||(i.dataset.pickerEnhanced="1",e.type==="icon"?me(i):pe(i))})}function _(n,r){const t=document.createElement("div");t.className="fb-form-honeypot",t.setAttribute("aria-hidden","true");const e=document.createElement("input");e.name=n.querySelector('[name="website"]')?"_website":"website",t.dataset.hpName=e.name,e.type="text",e.tabIndex=-1,e.autocomplete="url",e.placeholder="https://",t.appendChild(e);const i=document.createElement("input");i.name="_t",i.type="hidden",i.value=r||Date.now(),t.appendChild(i),n.appendChild(t)}function K(n,r){const t=n.querySelector("form");if(!t)return;const e=Array.from(t.querySelectorAll(".form-group"));let i=0;r.forEach(function(o){if(o.type==="spacer"){const d=document.createElement("div");d.className="fb-spacer";const s=e[i];if(s)t.insertBefore(d,s);else{const a=t.querySelector('[type="submit"]');a?t.insertBefore(d,a):t.appendChild(d)}}else o.type!=="page-break"&&i++})}function C(n,r,t,e,i,o,d){const s=i||e,a=s.querySelector(".fb-form-honeypot"),l=a?.querySelector('input[type="text"]')?.value||"",h=a?.querySelector('[name="_t"]')?.value||"",u=Object.assign({},r);delete u._t,a?.dataset.hpName&&delete u[a.dataset.hpName];const c=new Map(o||[]);L(s,c);const f=oe(u,d,c),p=ie(e,f.files);if(p)return x(e,p,"error"),Promise.resolve();const{body:w,headers:b}=re(Object.assign(f.values,{_hp:l,_t:h}),f.files);return fetch("/api/forms/submit/"+n,{method:"POST",headers:b,body:w}).then(y=>y.json().then(v=>({ok:y.ok,body:v}))).then(y=>{y.ok&&y.body.ok?(Z(e),e.textContent="",x(e,y.body.message||t.successMessage||"Thank you.","success")):x(e,y.body.error||"Something went wrong.","error")}).catch(()=>{x(e,"Unable to submit. Please check your connection.","error")})}function fe(n,r,t,e,i){const o=document.createElement("form");o.noValidate=!0,r.forEach(function(a){const l=document.createElement("div");l.className="form-group",l.style.marginBottom="1.25rem",a.name&&(l.dataset.field=a.name);const h=document.createElement("label");if(h.className="form-label",h.textContent=a.label||a.name,a.required){const c=document.createElement("span");c.textContent=" *",c.style.color="var(--dm-danger)",h.appendChild(c)}let u;a.type==="textarea"?(u=document.createElement("textarea"),u.rows=a.formConfig?.rows||4,u.className="form-input"):a.type==="select"?(u=document.createElement("select"),u.className="form-input",(a.options||[]).forEach(function(c){const f=document.createElement("option");f.value=typeof c=="string"?c:c.value??"",f.textContent=typeof c=="string"?c:c.label||f.value,u.appendChild(f)})):(u=document.createElement("input"),u.type=a.type==="icon"||a.type==="image"?"text":a.type||"text",u.className="form-input",a.placeholder&&(u.placeholder=a.placeholder),a.type==="file"&&(a.file?.accept&&(u.accept=a.file.accept),a.multiple&&(u.multiple=!0))),u.name=a.name,u.required=a.required||!1,l.appendChild(h),l.appendChild(u),o.appendChild(l)}),t.honeypot&&_(o);const d=document.createElement("button");if(d.type="submit",d.className="btn btn-primary",d.textContent=t.submitText||"Submit",Q(t,"stacked").length||G(t)){const a=document.createElement("div");a.className="form-group form-buttons",a.appendChild(d),o.appendChild(a)}else o.appendChild(d);if(o.addEventListener("submit",function(a){a.preventDefault();const l={};if(r.forEach(function(u){const c=o.querySelector('[name="'+u.name+'"]');c&&(l[u.name]=c.value)}),window.FormLogicEngine&&i){const u=window.FormLogicEngine,c=[],f=[];if(r.forEach(function(p){if(u.evaluateFieldVisibility(p,l)==="hidden"){delete l[p.name];return}const b=u.evaluateFieldRequirement(p,l),y=l[p.name];b&&(!y||!String(y).trim())&&c.push(p.label||p.name);const v=u.validateField(p,y||"",l);v.length&&f.push(v[0].message)}),c.length||f.length){const p=[];c.length&&p.push("Required: "+c.join(", ")),f.length&&p.push(f.join("; ")),x(n,p.join(". "),"error");return}}const h=X(o,r);if(h.length){x(n,h.join(" "),"error");return}if(n.dataset.triggerBlocked==="true"){const u=n._formLogicRuntime,c=u&&u.submitBlock?u.submitBlock().reasons:[];x(n,c.join(" ")||"This form cannot be submitted yet.","error");return}n.classList.add("fb-form-loading"),d.disabled=!0,C(e,l,t,n,o,null,r).finally(function(){n.classList.remove("fb-form-loading"),d.disabled=!1})}),n.appendChild(o),j(o,t,"stacked"),F(o,t,r),T(n,t),enhancePickerFields(n,r),ee(n,r),N(n,function(a){return C(e,a,t,n,o,null,r)}),window.FormLogicEngine&&i&&q(r)){const a=new window.FormLogicEngine.FormLogicRuntime(i,n);a.init(),n._formLogicRuntime=a}}function he(n){const r=n.getAttribute("data-form");r&&fetch("/api/forms/"+r+"/public").then(t=>{if(!t.ok)throw new Error("Form not found: "+r);return t.json()}).then(t=>{const e=t.fields||[],i=t.settings||{},o=document.createElement("div");o.className="fb-form-wrapper",n.appendChild(o),B(o,t.fileLimits);const d=e.some(s=>s.type==="page-break");if(typeof Domma<"u"&&Domma.forms){const s=Number(i.columns)===3?3:2,a=i.layout||"grid";if(d&&Domma.forms.wizard){const l=Y(e,t.title),h=l.map(m=>m.fields),u=l.map(function(m){return{title:m.title,description:m.description,fields:O(m.fields,s)}});let c=0,f=null,p=null;const w=Date.now(),b=new Map;B(o,t.fileLimits,b),R(o,e);const y=function(m){const g=window.FormLogicEngine;if(!g||!g.validateFields)return;const k=g.validateFields(o,h[c]||[]);k.valid||(m.preventDefault(),m.stopImmediatePropagation(),markInvalidFields(o,k.missing),showValidationPopup(k))},v=function(){const m=h[c]||e;if($(o,i),F(o,i,m),T(o,i),D(o,m),enhancePickerFields(o,m),ne(o,b),m.some(g=>g.type==="spacer")&&K(o,m),i.honeypot){const g=o.querySelector("form");g&&_(g,w)}window.FormLogicEngine&&q(e)&&(f&&f.destroy(),f=new window.FormLogicEngine.FormLogicRuntime(t,o,{baseValues:p&&p.getStepData?p.getStepData():{}}),f.init(),z(o,f)),o.querySelectorAll(".wizard-next, .wizard-submit").forEach(g=>g.addEventListener("click",y,!0))};p=Domma.forms.wizard(o,{schema:{steps:u},layout:a,columns:s,finishText:i.submitText||"Finish",onStepChange:function(m){L(o,b),c=m,setTimeout(v,0)},onSubmit:function(m){return L(o,b),C(r,m,i,o,null,b,e)}}),N(o,function(m){return L(o,b),C(r,m,i,o,null,b,e)}),o.addEventListener("dm-form-trigger",function(m){if(!m.detail||m.detail.type!=="goto-step"||!p||!p.goToStep)return;const g=Number(m.detail.action.step);!isFinite(g)||g<0||g>=u.length||g!==c&&p.goToStep(g)}),Promise.resolve(p).then(v)}else if(Domma.forms.render){const l=O(e,s),h=ce(e);R(o,e),N(o,function(c){return C(r,c,i,o,null,null,e)});const u=Domma.forms.render(o,l,h,{submitText:i.submitText||"Submit",layout:a,columns:s,onSubmit:function(c){return C(r,c,i,o,null,null,e)}});Promise.resolve(u).then(function(){if(j(o,i,a),F(o,i,e),T(o,i),D(o,e),enhancePickerFields(o,e),window.FormLogicEngine&&q(e)){const c=new window.FormLogicEngine.FormLogicRuntime(t,o);c.init(),z(o,c)}if(e.some(c=>c.type==="spacer")&&K(o,e),i.honeypot){const c=o.querySelector("form");c&&_(c)}})}}else fe(o,e.filter(s=>s.type!=="page-break"&&s.type!=="spacer"),i,r,t)}).catch(t=>{const e=document.createElement("p");e.textContent="Form unavailable.",e.style.cssText="color:var(--dm-danger);font-style:italic;",n.appendChild(e),console.warn("[forms]",t.message)})}
|
|
1
|
+
import{installSmoothCarets as R}from"/public/js/smooth-caret.js";import{buildWizardSteps as Q}from"/public/js/form-steps.mjs";import{applyFormClasses as _,applyFormEntrance as q,applySubmitButtons as A,applyWizardButtons as X,resolveSecondaryButton as Z,submitWrapperClasses as ee}from"/public/js/form-submit.mjs";import{captureFileFields as F,checkFileInputs as te,destroyDropzones as ne,enhanceFileInputs as oe,fileBlueprint as re,restoreFileFields as ie,setFileLimits as P,splitFiles as se,submitBody as ae,totalTooLarge as ce,wireFileFields as z}from"/public/js/form-files.mjs";if(globalThis.__DM_FORMS_EMBED__!==!0){R(document);const t=document.querySelectorAll("[data-form]");t.length&&t.forEach(G)}const le=t=>t?.closest?.("[data-form]")?.__dmFormEmbed||null;export function renderFormTarget(t){R(t),G(t)}function N(t){return(t||[]).some(r=>r.logic||Array.isArray(r.triggers)&&r.triggers.length)}function ue(t,r){const n=t.querySelector('[name="'+r+'"], [name="'+r+'[]"]')||t.querySelector('[data-chooser-field="'+r+'"]');if(!n)return null;const e=n.closest("form")||t;let i=n;for(;i.parentNode&&i.parentNode!==e;)i=i.parentNode;return i}export function markInvalidFields(t,r){t.querySelectorAll(".fb-field-invalid").forEach(e=>e.classList.remove("fb-field-invalid"));let n=null;(r||[]).forEach(function(e){const i=ue(t,e.name);i&&(i.classList.add("fb-field-invalid"),n||(n=i))}),n&&n.scrollIntoView&&n.scrollIntoView({behavior:"smooth",block:"center"})}export function showValidationPopup(t){const r=(t.missing||[]).map(e=>"<strong>"+D(e.label)+"</strong> is required.").concat((t.errors||[]).map(D)),n=r.join("<br>");if(typeof E<"u"&&E.alert){E.alert(n,{title:"Please complete this step"});return}window.alert(r.join(`
|
|
2
|
+
`).replace(/<[^>]+>/g,""))}function D(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function j(t,r){let n=!1;t.addEventListener("dm-form-end",function(e){const i=e.detail&&e.detail.validation;if(i&&!i.valid){markInvalidFields(t,i.missing),showValidationPopup(i);return}n||(n=!0,t.classList.add("fb-form-loading"),Promise.resolve(r(e.detail&&e.detail.values||{})).catch(function(){}).finally(function(){n=!1,t.classList.remove("fb-form-loading")}))})}function k(t,r,n){const e=t.querySelector(".fb-form-success, .fb-form-error");e&&e.remove();const i=document.createElement("div");i.className=n==="success"?"fb-form-success":"fb-form-error",i.textContent=r,t.appendChild(i)}function M(t,r){if(t._formLogicRuntime=r,t._formLogicObserver&&(t._formLogicObserver.disconnect(),t._formLogicObserver=null),!t.parentNode||typeof MutationObserver>"u"||t._formLogicObserved)return;t._formLogicObserved=!0;const n=new MutationObserver(function(e){for(const i of e)for(const o of i.removedNodes)if(o===t||o.nodeType===1&&o.contains&&o.contains(t)){t._formLogicRuntime&&t._formLogicRuntime.destroy(),n.disconnect();return}});n.observe(t.parentNode,{childList:!0,subtree:!1}),t._formLogicObserver=n}function de(t){const r=t&&t.logic;return!!(r&&(r.visibility||r.requirement))}function V(t,r){const n={};return t.forEach(function(e){if(e.type==="page-break"||e.type==="spacer"||!e.name)return;const i=e.type==="chooser"||!!(e.variant&&["select","radio","checkbox-group"].includes(e.type)),o=e.type==="checkbox"?"boolean":e.type==="date"||e.type==="icon"||e.type==="image"?"string":i?"chooser":e.type,d={...e.formConfig||{}};d.span==="full"&&r&&(d.span=r);const a={type:o,label:e.label||e.name,required:de(e)?!1:e.required||!1,options:e.options,formConfig:{...e.placeholder&&{placeholder:e.placeholder},...e.helper&&{helperText:e.helper},...e.tooltip&&{tooltip:e.tooltip},...d}};e.minLength!==void 0&&(a.minLength=e.minLength),e.maxLength!==void 0&&(a.maxLength=e.maxLength),e.min!==void 0&&(a.min=e.min),e.max!==void 0&&(a.max=e.max),i&&(e.variant&&(a.variant=e.variant),(e.multiple||e.type==="checkbox-group")&&(a.multiple=!0),e.density&&(a.density=e.density),e.columns&&(a.columns=e.columns),e.accent&&(a.accent=e.accent),e.accentStyle&&(a.accentStyle=e.accentStyle),e.glow&&(a.glow=!0),e.glowColour&&(a.glowColour=e.glowColour),e.shadow&&(a.shadow=e.shadow),e.shadowColour&&(a.shadowColour=e.shadowColour)),n[e.name]=e.type==="file"?re(e,a):a}),n}function me(t){const r={};return t.forEach(function(n){if(!(!n.name||n.type==="page-break"||n.type==="spacer")&&(n.type==="select"||n.type==="multiselect")&&n.required){const e=(n.options||[])[0];e&&(r[n.name]=typeof e=="object"?e.value:e)}}),r}function W(t,r){(r||[]).forEach(function(n){if(n.type!=="date"||!n.name)return;const e=t.querySelector('[name="'+n.name+'"]');e&&e.type!=="date"&&(e.type="date")})}const U="padding:.45rem .7rem;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md,6px);background:transparent;color:inherit;cursor:pointer;font:inherit;font-size:.85em;flex-shrink:0;line-height:1.2;";function H(t){const r=document.createElement("div");r.style.cssText="position:fixed;inset:0;z-index:9999;background:rgba(0,0,0,.55);display:flex;align-items:center;justify-content:center;padding:20px;";const n=document.createElement("div");n.style.cssText="background:var(--dm-surface-overlay,var(--dm-surface));color:var(--dm-text);border:1px solid var(--dm-border);border-radius:10px;width:100%;max-width:560px;max-height:75vh;display:flex;flex-direction:column;gap:.6rem;padding:1rem;box-shadow:var(--dm-shadow-lg,0 12px 40px rgba(0,0,0,.35));";const e=document.createElement("div");e.style.cssText="display:flex;align-items:center;justify-content:space-between;gap:.5rem;";const i=document.createElement("strong");i.textContent=t;const o=document.createElement("button");o.type="button",o.textContent="\xD7",o.setAttribute("aria-label","Close"),o.style.cssText=U+"font-size:1rem;padding:.15rem .55rem;",e.appendChild(i),e.appendChild(o),n.appendChild(e);const d=document.createElement("div");d.style.cssText="display:flex;flex-direction:column;gap:.6rem;overflow:hidden;min-height:0;",n.appendChild(d),r.appendChild(n);const a=l=>{l.key==="Escape"&&s()};function s(){document.removeEventListener("keydown",a),r.remove()}return o.addEventListener("click",s),r.addEventListener("click",l=>{l.target===r&&s()}),document.addEventListener("keydown",a),document.body.appendChild(r),{body:d,close:s}}function pe(t){const{body:r,close:n}=H("Choose an icon"),e=document.createElement("input");e.type="text",e.placeholder="Search icons\u2026",e.className="form-input",e.style.cssText="padding:.45rem .6rem;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md,6px);background:var(--dm-input-bg,transparent);color:var(--dm-text);",r.appendChild(e);const i=document.createElement("div");i.style.cssText="display:grid;grid-template-columns:repeat(auto-fill,minmax(46px,1fr));gap:4px;overflow-y:auto;min-height:0;",r.appendChild(i);const o=window.I&&typeof I.list=="function"?I.list():[],d=o.map(a=>{const s=document.createElement("button");s.type="button",s.title=a,s.dataset.iconName=a,s.style.cssText="display:flex;align-items:center;justify-content:center;padding:.55rem 0;border:1px solid transparent;border-radius:6px;background:transparent;color:inherit;cursor:pointer;";const l=document.createElement("span");return l.setAttribute("data-icon",a),l.setAttribute("data-icon-size","18"),s.appendChild(l),s.addEventListener("mouseenter",()=>{s.style.borderColor="var(--dm-border)"}),s.addEventListener("mouseleave",()=>{s.style.borderColor="transparent"}),s.addEventListener("click",()=>{n(),t(a)}),i.appendChild(s),s});if(!o.length){const a=document.createElement("p");a.textContent="Icon engine unavailable - type an icon name into the field instead.",i.appendChild(a)}window.I?.scan?.(i),e.addEventListener("input",()=>{const a=e.value.trim().toLowerCase();d.forEach(s=>{s.style.display=!a||s.dataset.iconName.includes(a)?"":"none"})}),e.focus()}async function fe(){const t=typeof S<"u"&&S.get?S.get("auth_token"):null;if(!t)return{error:"auth"};const r=i=>fetch("/api/media",{headers:{Authorization:"Bearer "+i}});let n;try{if(n=await r(t),n.status===401&&S.get("auth_refresh_token")){const i=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:S.get("auth_refresh_token")})});if(i.ok){const{token:o}=await i.json();S.set("auth_token",o),n=await r(o)}}}catch{return{error:"load"}}if(!n.ok)return{error:n.status===401||n.status===403?"auth":"load"};const e=await n.json().catch(()=>[]);return{files:(Array.isArray(e)?e:[]).filter(i=>/\.(png|jpe?g|gif|webp|svg|avif)$/i.test(i.name||i.url||""))}}function he(t){const{body:r,close:n}=H("Choose an image"),e=document.createElement("p");e.textContent="Loading media library\u2026",e.style.cssText="margin:0;font-size:.85em;color:var(--dm-text-muted);",r.appendChild(e),fe().then(({files:i,error:o})=>{if(o){e.textContent=o==="auth"?"Sign in with media access to browse the library - or paste an image URL into the field.":"Could not load the media library - paste an image URL into the field instead.";return}if(!i.length){e.textContent="No images in the media library yet.";return}e.remove();const d=document.createElement("div");d.style.cssText="display:grid;grid-template-columns:repeat(auto-fill,minmax(104px,1fr));gap:8px;overflow-y:auto;min-height:0;",i.forEach(a=>{const s=document.createElement("button");s.type="button",s.title=a.name||a.url,s.style.cssText="display:flex;flex-direction:column;gap:.25rem;padding:.35rem;border:1px solid var(--dm-border);border-radius:8px;background:transparent;color:inherit;cursor:pointer;min-width:0;";const l=document.createElement("img");l.src=a.url,l.alt=a.name||"",l.loading="lazy",l.style.cssText="width:100%;height:72px;object-fit:cover;border-radius:5px;";const y=document.createElement("span");y.textContent=a.name||a.url,y.style.cssText="font-size:.68em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",s.appendChild(l),s.appendChild(y),s.addEventListener("click",()=>{n(),t(a.url)}),d.appendChild(s)}),r.appendChild(d)})}function J(t,r){t.value=r,t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}function K(t){const r=document.createElement("div");return r.style.cssText="display:flex;align-items:center;gap:.5rem;",t.parentNode.insertBefore(r,t),r.appendChild(t),t.style.flex="1",t.style.minWidth="0",r}function Y(t){const r=document.createElement("button");return r.type="button",r.textContent=t,r.style.cssText=U,r}function ge(t){if(!window.I||typeof I.list!="function")return;const r=K(t),n=document.createElement("span");n.style.cssText="display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;flex-shrink:0;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md,6px);";const e=()=>{n.textContent="";const o=t.value.trim();if(!o)return;const d=document.createElement("span");d.setAttribute("data-icon",o),d.setAttribute("data-icon-size","16"),n.appendChild(d),window.I?.scan?.(n)};t.addEventListener("input",e),e();const i=Y("Browse");i.addEventListener("click",()=>pe(o=>{J(t,o),e()})),r.appendChild(n),r.appendChild(i)}function ye(t){const r=K(t),n=document.createElement("img");n.alt="",n.style.cssText="width:2rem;height:2rem;flex-shrink:0;object-fit:cover;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md,6px);display:none;";const e=()=>{const o=t.value.trim();n.style.display=o?"":"none",o&&(n.src=o)};t.addEventListener("input",e),e();const i=Y("Browse");i.addEventListener("click",()=>he(o=>{J(t,o),e()})),r.appendChild(n),r.appendChild(i)}export function enhancePickerFields(t,r){const n=typeof t=="string"?document.querySelector(t):t;n&&(r||[]).forEach(function(e){if(!e.name||e.type!=="icon"&&e.type!=="image")return;const i=n.querySelector('[name="'+e.name+'"]');!i||i.dataset.pickerEnhanced||(i.dataset.pickerEnhanced="1",e.type==="icon"?ge(i):ye(i))})}function B(t,r){const n=document.createElement("div");n.className="fb-form-honeypot",n.setAttribute("aria-hidden","true");const e=document.createElement("input");e.name=t.querySelector('[name="website"]')?"_website":"website",n.dataset.hpName=e.name,e.type="text",e.tabIndex=-1,e.autocomplete="url",e.placeholder="https://",n.appendChild(e);const i=document.createElement("input");i.name="_t",i.type="hidden",i.value=r||Date.now(),n.appendChild(i),t.appendChild(n)}function $(t,r){const n=t.querySelector("form");if(!n)return;const e=Array.from(n.querySelectorAll(".form-group"));let i=0;r.forEach(function(o){if(o.type==="spacer"){const d=document.createElement("div");d.className="fb-spacer";const a=e[i];if(a)n.insertBefore(d,a);else{const s=n.querySelector('[type="submit"]');s?n.insertBefore(d,s):n.appendChild(d)}}else o.type!=="page-break"&&i++})}function L(t,r,n,e,i,o,d){const a=i||e,s=a.querySelector(".fb-form-honeypot"),l=s?.querySelector('input[type="text"]')?.value||"",y=s?.querySelector('[name="_t"]')?.value||"",u=Object.assign({},r);delete u._t,s?.dataset.hpName&&delete u[s.dataset.hpName];const c=new Map(o||[]);F(a,c);const h=se(u,d,c),p=ce(e,h.files);if(p)return k(e,p,"error"),Promise.resolve();const b=le(e),v=b?.contextToken?{_context_token:b.contextToken}:{},{body:x,headers:C}=ae(Object.assign(h.values,{_hp:l,_t:y},v),h.files),m=()=>(typeof b?.token=="function"?b.token():b?.token)||"",g=f=>fetch("/api/forms/submit/"+t,{method:"POST",body:x,credentials:b?"omit":"same-origin",headers:Object.assign({},C,f?{Authorization:"Bearer "+f}:{})});return g(b?m():"").then(async f=>{const w=typeof S<"u"&&S.get?S.get("auth_refresh_token"):null;if(!(b&&f.status===401&&w))return f;const O=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:w})});if(!O.ok)return f;const{token:T}=await O.json();return T?(S.set("auth_token",T),g(T)):f}).then(f=>f.json().then(w=>({ok:f.ok,body:w}))).then(f=>{if(f.ok&&f.body.ok){if(ne(e),e.textContent="",k(e,f.body.message||n.successMessage||"Thank you.","success"),b?.onSubmitted)try{b.onSubmitted({entryId:f.body.entryId||null,message:f.body.message||""})}catch(w){console.warn("[forms] onSubmitted:",w?.message||w)}}else k(e,f.body.error||"Something went wrong.","error")}).catch(()=>{k(e,"Unable to submit. Please check your connection.","error")})}function be(t,r,n,e,i){const o=document.createElement("form");o.noValidate=!0,r.forEach(function(s){const l=document.createElement("div");l.className="form-group",l.style.marginBottom="1.25rem",s.name&&(l.dataset.field=s.name);const y=document.createElement("label");if(y.className="form-label",y.textContent=s.label||s.name,s.required){const c=document.createElement("span");c.textContent=" *",c.style.color="var(--dm-danger)",y.appendChild(c)}let u;s.type==="textarea"?(u=document.createElement("textarea"),u.rows=s.formConfig?.rows||4,u.className="form-input"):s.type==="select"?(u=document.createElement("select"),u.className="form-input",(s.options||[]).forEach(function(c){const h=document.createElement("option");h.value=typeof c=="string"?c:c.value??"",h.textContent=typeof c=="string"?c:c.label||h.value,u.appendChild(h)})):(u=document.createElement("input"),u.type=s.type==="icon"||s.type==="image"?"text":s.type||"text",u.className="form-input",s.placeholder&&(u.placeholder=s.placeholder),s.type==="file"&&(s.file?.accept&&(u.accept=s.file.accept),s.multiple&&(u.multiple=!0))),u.name=s.name,u.required=s.required||!1,l.appendChild(y),l.appendChild(u),o.appendChild(l)}),n.honeypot&&B(o);const d=document.createElement("button");if(d.type="submit",d.className="btn btn-primary",d.textContent=n.submitText||"Submit",ee(n,"stacked").length||Z(n)){const s=document.createElement("div");s.className="form-group form-buttons",s.appendChild(d),o.appendChild(s)}else o.appendChild(d);if(o.addEventListener("submit",function(s){s.preventDefault();const l={};if(r.forEach(function(u){const c=o.querySelector('[name="'+u.name+'"]');c&&(l[u.name]=c.value)}),window.FormLogicEngine&&i){const u=window.FormLogicEngine,c=[],h=[];if(r.forEach(function(p){if(u.evaluateFieldVisibility(p,l)==="hidden"){delete l[p.name];return}const v=u.evaluateFieldRequirement(p,l),x=l[p.name];v&&(!x||!String(x).trim())&&c.push(p.label||p.name);const C=u.validateField(p,x||"",l);C.length&&h.push(C[0].message)}),c.length||h.length){const p=[];c.length&&p.push("Required: "+c.join(", ")),h.length&&p.push(h.join("; ")),k(t,p.join(". "),"error");return}}const y=te(o,r);if(y.length){k(t,y.join(" "),"error");return}if(t.dataset.triggerBlocked==="true"){const u=t._formLogicRuntime,c=u&&u.submitBlock?u.submitBlock().reasons:[];k(t,c.join(" ")||"This form cannot be submitted yet.","error");return}t.classList.add("fb-form-loading"),d.disabled=!0,L(e,l,n,t,o,null,r).finally(function(){t.classList.remove("fb-form-loading"),d.disabled=!1})}),t.appendChild(o),A(o,n,"stacked"),_(o,n,r),q(t,n),enhancePickerFields(t,r),oe(t,r),j(t,function(s){return L(e,s,n,t,o,null,r)}),window.FormLogicEngine&&i&&N(r)){const s=new window.FormLogicEngine.FormLogicRuntime(i,t);s.init(),t._formLogicRuntime=s}}function G(t){const r=t.getAttribute("data-form");r&&fetch("/api/forms/"+r+"/public").then(n=>{if(!n.ok)throw new Error("Form not found: "+r);return n.json()}).then(n=>{const e=n.fields||[],i=n.settings||{},o=document.createElement("div");o.className="fb-form-wrapper",t.appendChild(o),P(o,n.fileLimits);const d=e.some(a=>a.type==="page-break");if(typeof Domma<"u"&&Domma.forms){const a=Number(i.columns)===3?3:2,s=i.layout||"grid";if(d&&Domma.forms.wizard){const l=Q(e,n.title),y=l.map(m=>m.fields),u=l.map(function(m){return{title:m.title,description:m.description,fields:V(m.fields,a)}});let c=0,h=null,p=null;const b=Date.now(),v=new Map;P(o,n.fileLimits,v),z(o,e);const x=function(m){const g=window.FormLogicEngine;if(!g||!g.validateFields)return;const f=g.validateFields(o,y[c]||[]);f.valid||(m.preventDefault(),m.stopImmediatePropagation(),markInvalidFields(o,f.missing),showValidationPopup(f))},C=function(){const m=y[c]||e;if(X(o,i),_(o,i,m),q(o,i),W(o,m),enhancePickerFields(o,m),ie(o,v),m.some(g=>g.type==="spacer")&&$(o,m),i.honeypot){const g=o.querySelector("form");g&&B(g,b)}window.FormLogicEngine&&N(e)&&(h&&h.destroy(),h=new window.FormLogicEngine.FormLogicRuntime(n,o,{baseValues:p&&p.getStepData?p.getStepData():{}}),h.init(),M(o,h)),o.querySelectorAll(".wizard-next, .wizard-submit").forEach(g=>g.addEventListener("click",x,!0))};p=Domma.forms.wizard(o,{schema:{steps:u},layout:s,columns:a,finishText:i.submitText||"Finish",onStepChange:function(m){F(o,v),c=m,setTimeout(C,0)},onSubmit:function(m){return F(o,v),L(r,m,i,o,null,v,e)}}),j(o,function(m){return F(o,v),L(r,m,i,o,null,v,e)}),o.addEventListener("dm-form-trigger",function(m){if(!m.detail||m.detail.type!=="goto-step"||!p||!p.goToStep)return;const g=Number(m.detail.action.step);!isFinite(g)||g<0||g>=u.length||g!==c&&p.goToStep(g)}),Promise.resolve(p).then(C)}else if(Domma.forms.render){const l=V(e,a),y=me(e);z(o,e),j(o,function(c){return L(r,c,i,o,null,null,e)});const u=Domma.forms.render(o,l,y,{submitText:i.submitText||"Submit",layout:s,columns:a,onSubmit:function(c){return L(r,c,i,o,null,null,e)}});Promise.resolve(u).then(function(){if(A(o,i,s),_(o,i,e),q(o,i),W(o,e),enhancePickerFields(o,e),window.FormLogicEngine&&N(e)){const c=new window.FormLogicEngine.FormLogicRuntime(n,o);c.init(),M(o,c)}if(e.some(c=>c.type==="spacer")&&$(o,e),i.honeypot){const c=o.querySelector("form");c&&B(c)}})}}else be(o,e.filter(a=>a.type!=="page-break"&&a.type!=="spacer"),i,r,n)}).catch(n=>{const e=document.createElement("p");e.textContent="Form unavailable.",e.style.cssText="color:var(--dm-danger);font-style:italic;",t.appendChild(e),console.warn("[forms]",n.message)})}
|
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,isCurrentItem as K,menuAlign as ue,applyClasses as P,cssClasses as X,applyEntrance as J}from"/public/js/menu-decor.mjs?v=20261014-menu-entrance";import{applyMenuLook as pe,applyFooterLook as fe}from"/public/js/menu-cards.mjs?v=20261029-footer-bars";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=20260829-float-panel";import{enhancePickerFields as Q,markInvalidFields as Z,showValidationPopup as ee}from"/public/js/forms.js?v=20261031-form-entrance-forms";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",l=>{const i=l.target?.closest?.(".dm-banner__dismiss");i&&(l.preventDefault(),i.closest(".dm-banner")?.remove())}),$(()=>{re(document);const l=window.__CMS_NAV__||{},i=window.__CMS_SITE__||{},D=i.brandingEnabled!==!1&&l.brand?.enabled!==!1;if(i.autoTheme?.enabled){let o=function(r){const m=(r||"07:00").split(":");return+m[0]*60+(+m[1]||0)},e=function(){const r=new Date,m=r.getHours()*60+r.getMinutes();return m>=o(a.dayStart)&&m<o(a.nightStart)?a.dayTheme:a.nightTheme},t=function(r){const m=a.apply&&a.apply[r]||{theme:r,custom:""};Domma.theme.set(m.theme);for(const n of[...document.body.classList])n.startsWith("dm-custom-")&&document.body.classList.remove(n);m.custom&&document.body.classList.add(m.custom)};const a=i.autoTheme;t(e()),setInterval(()=>t(e()),6e4)}const L=$("#site-navbar");if(L.length&&l.brand){let e=function(u,f=0){return Array.isArray(u)?u.filter(h=>!(h&&(h.type==="spacer"||h.type==="theme-switcher"))).filter(h=>!(h&&h.type==="separator"&&f===0)).map(h=>h&&h.type==="separator"?{divider:!0}:Array.isArray(h?.items)?{...h,items:e(h.items,f+1)}:h):u};const a={...l.brand},o=a.size&&a.size!=="md"?` navbar-brand-${a.size}`:"";if(a.logo||a.icon||a.tagline){let u="";a.logo?u+=`<img src="${a.logo}" class="navbar-brand-logo" alt="${a.text||""}">`:a.icon&&(u+=`<span data-icon="${a.icon}" style="width:1.1em;height:1.1em;margin-right:.35em;vertical-align:middle;"></span>`),a.text&&(u+=`<span class="navbar-brand-text${o}">${a.text}</span>`),a.tagline&&(u+=`<small class="navbar-brand-tagline">${a.tagline}</small>`),a.html=u}else o&&a.text&&(a.html=`<span class="navbar-brand-text${o}">${a.text}</span>`);const t=e(l.items||[]),r=l.position==="floating",m=l.orientation==="vertical";L.get(0).querySelector(":scope > .cms-nojs-links")?.remove(),Domma.elements.navbar("#site-navbar",{brand:D?a:null,items:t,variant:l.variant||"dark",position:r?"static":l.position||"sticky",collapsible:!0,appearOnHover:!!l.appearOnHover}),Domma.icons.scan("#site-navbar");const n=L.get(0);ae(n,l.mobile);const y=()=>{if(!m)return;const f=n.querySelector('a[aria-current="page"]')?.closest(".navbar-dropdown");f&&!f.classList.contains("open")&&f.querySelector(":scope > .navbar-dropdown-toggle")?.click()};n.classList.add(`dm-nav-align-${ue(l)||"centre"}`),m&&L.get(0).classList.add("dm-nav-vertical",l.side==="right"?"dm-nav-vertical-right":"dm-nav-vertical-left");const g=l.dock||{};m&&!r&&qe(n,l.side==="right"),!m&&g.hideOnScroll&&Me(n),Y(n,l),J(n,l),P(n,l.class),r&&(le(L.get(0),l),ye(L.get(0).parentNode||document));const d=n.querySelector(".navbar-toggle"),b=n.querySelector(".navbar-collapse");if(d&&b){let u=null;const f=()=>{b.classList.contains("show")&&d.click()},h=()=>{u&&(u.remove(),u=null),document.body.classList.remove("dm-drawer-open")},p=()=>{u||(u=document.createElement("div"),u.className="dm-navbar-backdrop",u.addEventListener("click",f),document.body.appendChild(u),document.body.classList.add("dm-drawer-open"))};d.addEventListener("click",()=>{requestAnimationFrame(()=>{b.classList.contains("show")?(y(),p()):h()})}),b.addEventListener("click",x=>{x.target.closest("a")&&requestAnimationFrame(h)}),document.addEventListener("keydown",x=>{x.key==="Escape"&&b.classList.contains("show")&&f()})}const w=n.querySelector(".navbar-nav");if(w){const u=Array.from(w.children);let f=0;for(const h of l.items||[])if(!(h&&h.type==="separator")){if(h&&h.type==="spacer"){const p=document.createElement("li"),x=["xs","sm","md","lg","xl","flex"].includes(h.size)?h.size:"md";p.className=`dm-menu-spacer dm-menu-spacer--${x}`,p.setAttribute("aria-hidden","true"),w.insertBefore(p,u[f]||null);continue}if(h&&h.type==="theme-switcher"){const p=document.createElement("li");p.className="dm-menu-theme-switcher";const x=document.createElement("span");x.dataset.themeSwitcher="menu",x.dataset.position="inline",p.appendChild(x),w.insertBefore(p,u[f]||null);continue}f++}window.CMSThemeSwitcher?.scan(w)}n.querySelectorAll("[data-path]").forEach(u=>{const f=u.dataset.path.split(".").map(Number),h=f.length>1,p=f.reduce((M,I)=>M?.items?.[I],{items:t});if(!p)return;p.colour&&G(u,p.colour),p.pill&&!h&&ce(u,p.pill),de(u,p),P(u.closest("li"),p.class);const x=U(p.badge);x&&u.appendChild(x),K(p.url,location.pathname)&&(u.classList.add("active"),u.setAttribute("aria-current","page"))}),pe(n,l,t),y()}let z=null;const C=$("#site-footer");if(C.length){let r=function(c){return String(c??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},m=function(c){return r(c).replace(/'/g,"'")},n=function(c){if(c&&c.type==="separator")return'<li class="footer-sep"><hr></li>';if(c&&c.type==="spacer")return`<li class="dm-menu-spacer dm-menu-spacer--${["xs","sm","md","lg","xl","flex"].includes(c.size)?c.size:"md"}" aria-hidden="true"></li>`;if(c&&c.type==="theme-switcher")return'<li class="dm-menu-theme-switcher"><span data-theme-switcher="menu" data-position="inline"></span></li>';const v=m(c.url||"#"),k=r(c.text||""),q=Array.isArray(c.items)&&c.items.length?`<ul>${c.items.map(n).join("")}</ul>`:"",N=me(c),j=[N.hover&&` data-menu-item-hover="${m(N.hover)}"`,N.active&&` data-menu-item-active="${m(N.active)}"`].filter(Boolean).join(""),W=N.accent?` style="--dm-menu-highlight:${m(N.accent)}"`:"",B=X(c.class).join(" ");return`<li${B?` class="${m(B)}"`:""}><a href="${v}"${j}${W}>${k}</a>${q}</li>`},g=function(){if(!i.footer)return"";const c=Object.keys(o).filter(k=>a[k]);if(!c.length)return"";const v=X(i.footer.socialClass).join(" ");return`<div class="footer-social">${c.map(k=>{const{label:q,svg:N}=o[k];return`<a href="${a[k]}" target="_blank" rel="noopener noreferrer" aria-label="${q}" class="footer-social-link${v?` ${m(v)}`:""}">${N}</a>`}).join("")}</div>`},u=function(c){if(!c||c.type==="separator"||c.type==="spacer")return"";if(c.type==="theme-switcher")return`<li class="cms-footer-col">${n(c).replace(/^<li[^>]*>|<\/li>$/g,"")}</li>`;const v=Array.isArray(c.items)&&c.items.length?`<ul>${c.items.map(n).join("")}</ul>`:"",k=w(c)?`<span class="cms-footer-col-title">${r(c.text||"")}</span>`:`<a class="cms-footer-col-title" href="${m(c.url||"#")}">${r(c.text||"")}</a>`,q=["cms-footer-col",...X(c.class)].join(" ");return`<li class="${m(q)}">${k}${v}</li>`},p=function(c,v,k=!1){return(c||[]).forEach(q=>{q&&(q.type==="separator"||q.type==="spacer"||q.type==="theme-switcher")||(k&&w(q)||v.push(q),Array.isArray(q.items)&&q.items.length&&p(q.items,v))}),v};const a=i.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:""},y=(()=>{const c=i.cookieConsent;if(!c||c.showSettingsLink===!1)return"";const v=k=>(k||[]).some(q=>q&&(q.url==="#cookie-settings"||v(q.items)));return v(t.primary)||v(t.legal)?"":`<li class="cms-cookie-settings"><a href="#cookie-settings">${r(c.settingsLinkText||"Cookie settings")}</a></li>`})(),d=["columns","row"].includes(i.footer?.layout)?i.footer.layout:"auto",b=i.footer?.look==="showcase"||d==="columns"||d==="auto"&&t.primary.some(c=>Array.isArray(c?.items)&&c.items.length),w=c=>b&&!c.url&&Array.isArray(c.items)&&c.items.length>0;if(b){const c=l.brand||{},v=D&&(c.text||i.title)||"",k=D?c.logo?`<img src="${m(c.logo)}" class="cms-footer-brand-logo" alt="">`:c.icon?'<span class="cms-footer-brand-icon"></span>':"":"",q=String(i.footer?.blurb||"").trim();e='<div class="footer-inner footer-inner--columns container"><div class="cms-footer-top">',e+=`<div class="cms-footer-brand">${v||k?`<a class="cms-footer-brand-name" href="${m(c.url||"/")}">${k}<span>${r(v)}</span></a>`:""}${q?`<p class="cms-footer-blurb">${r(q)}</p>`:""}${g()}</div>`,t.primary.length&&(e+=`<nav class="footer-nav footer-nav--primary footer-nav--columns" aria-label="Footer"><ul>${t.primary.map(u).join("")}</ul></nav>`),e+='</div><div class="cms-footer-bottom">',t.copyright&&(e+=`<p class="cms-footer-copyright">${r(t.copyright)}</p>`),(t.legal.length||y)&&(e+=`<nav class="footer-nav footer-nav--legal" aria-label="Legal"><ul>${t.legal.map(n).join("")}${y}</ul></nav>`),e+="</div>"}else t.copyright&&(e+=`<p>${r(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||y)&&(e+=`<nav class="footer-nav footer-nav--legal"><ul>${t.legal.map(n).join("")}${y}</ul></nav>`),e+=g();e+="</div>",C.get(0).querySelector(":scope > .cms-nojs-links")?.remove();const f=C.get(0).querySelector(":scope > .cms-footer-blocks");f?.remove(),C.html(e),f&&C.get(0).prepend(f),window.CMSThemeSwitcher?.scan(C.get(0));const h=C.get(0).querySelector(".cms-footer-brand-icon");h&&l.brand?.icon&&h.setAttribute("data-icon",l.brand.icon),P(C.get(0),i.footer?.class),b&&ge(C.get(0),i);const x=[...p(t.primary,[],!0),...p(t.legal,[])],M=C.get(0).querySelectorAll(".footer-nav a"),I=[];M.forEach((c,v)=>{const k=x[v];if(!k)return;if(I.push({a:c,item:k}),k.icon){const N=document.createElement("span");N.className="cms-footer-ic",N.setAttribute("data-icon",String(k.icon)),N.setAttribute("data-icon-size","15"),N.setAttribute("aria-hidden","true"),c.prepend(N)}k.colour&&G(c,k.colour);const q=U(k.badge);q&&c.appendChild(q),K(k.url,location.pathname)&&(c.classList.add("is-active"),c.setAttribute("aria-current","page"))}),Y(C.get(0).querySelector(".footer-nav--primary"),{highlight:t.primaryHighlight}),Y(C.get(0).querySelector(".footer-nav--legal"),{highlight:t.legalHighlight}),J(C.get(0).querySelector(".footer-nav--primary"),{entrance:t.primaryEntrance}),J(C.get(0).querySelector(".footer-nav--legal"),{entrance:t.legalEntrance}),P(C.get(0).querySelector(".footer-nav--primary"),t.primaryClass),P(C.get(0).querySelector(".footer-nav--legal"),t.legalClass),fe(C.get(0),t,I),z=C.get(0).querySelector(".cms-footer-bottom")||C.get(0).querySelector(".footer-inner")}be(i.motion||{enabled:i.footer?.showMotionToggle!==!1,default:i.footer?.motionDefault,placement:"footer",control:i.footer?.motionControl,label:"Reduce motion"},{footer:z,navbar:document.querySelector("#site-navbar .navbar-container")?.closest("#site-navbar")||null});const A=document.getElementById("site-sidebar");A&&De(A),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=g=>{const d=String(g||"").trim();return d?o[d.toLowerCase()]?`var(${o[d.toLowerCase()]})`:CSS.supports("color",d)?d:"":""},t=e(this.dataset.background),r=e(this.dataset.arrowBackground),m=e(this.dataset.arrowColor);t&&(this.style.setProperty("--dm-carousel-background",t),this.classList.add("dm-carousel-custom-background")),r&&this.style.setProperty("--dm-carousel-arrow-background",r),m&&this.style.setProperty("--dm-carousel-arrow-color",m);const n=["top","middle","bottom"].includes(this.dataset.arrowPosition)?this.dataset.arrowPosition:"middle";this.classList.add(`dm-carousel-arrows-${n}`);const y={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 g=Number(this.dataset.height);Number.isFinite(g)&&g>0&&(y.height=g)}if(this.dataset.animationDuration){const g=parseInt(this.dataset.animationDuration,10);Number.isFinite(g)&&(y.animationDuration=g)}this.dataset.animationEasing&&(y.animationEasing=this.dataset.animationEasing),this.dataset.ctx&&(this._dmCtxSlides=Array.from(this.querySelectorAll(".carousel-slide")).map(g=>g.cloneNode(!0)),this._dmCarouselOpts=y),this._dmCarousel=Domma.elements.carousel(this,y),ie(this)}),s.find(".dm-countdown").each(function(){const o={autoStart:!0},e=String(this.dataset.format||"").trim(),t=String(this.dataset.to||"").trim(),r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t),m=r?new Date(+r[1],+r[2]-1,+r[3]).getTime():t?new Date(t).getTime():NaN;Number.isFinite(m)?o.duration=Math.max(0,m-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 y=this,g=b=>String(b).padStart(2,"0"),d=b=>{const w=Math.max(0,Math.floor(b/1e3)),u=y.querySelector(".dm-timer-time");u&&(u.textContent=`${g(Math.floor(w/86400))}:${g(Math.floor(w%86400/3600))}:${g(Math.floor(w%3600/60))}:${g(w%60)}`)};n&&(o.onTick=d),Domma.elements.timer(this,o),n&&d(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(r=>{const m={title:r.querySelector(".dm-progression-item-title")?.textContent?.trim()||"",description:r.querySelector(".dm-progression-item-body")?.innerHTML?.trim()||""};return r.dataset.date&&(m.date=r.dataset.date),r.dataset.status&&(m.status=r.dataset.status),r.dataset.eventIcon&&(m.icon=r.dataset.eventIcon),r.dataset.entryId&&(m._entryId=r.dataset.entryId),m}),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 r={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((m,n)=>{const y=o[n];if(!y)return;const g=m.querySelector(".dm-progression-title");if(y.icon&&g){const b=document.createElement("span");b.dataset.icon=y.icon,b.style.cssText="display:inline-flex;vertical-align:middle;margin-right:.4em",b.setAttribute("aria-hidden","true"),g.prepend(b)}const d=r[y.status];if(d&&g){const b=document.createElement("span");b.className=`badge badge-${d.tone} cms-timeline-status`,b.style.cssText="display:inline-flex;align-items:center;gap:.35em;margin:.4rem 0";const w=document.createElement("span");w.dataset.icon=d.icon,w.dataset.iconSize="14",w.setAttribute("aria-hidden","true"),b.append(w,document.createTextNode(d.label)),g.after(b)}})}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",r=parseInt(o.dataset.revealDuration,10)||(t.startsWith("swoosh")?700:400),m=parseInt(o.dataset.revealStagger,10)||(t.startsWith("swoosh")?90:60),n=parseInt(o.dataset.revealDelay,10)||0,y=o.dataset.revealDirection==="rtl",g=o.dataset.revealReplay==="true",d=Array.from(o.children);if(a&&t.startsWith("swoosh"))return;const b={"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)"},w=p=>t!=="swoosh-sides"?b[t]||"":d.length>1&&p===0?"translateX(-64px) rotate(-1.5deg)":d.length>1&&p===d.length-1?"translateX(64px) rotate(1.5deg)":"translateY(40px) scale(0.94)",u=t.startsWith("swoosh"),f=u?"cubic-bezier(.2,.8,.2,1)":"ease",h=(p,x)=>{p.style.opacity="0",p.style.transform=w(x),u&&(p.style.filter="blur(10px)")};d.forEach((p,x)=>{p.style.transition="none",h(p,x)}),o.offsetWidth,d.forEach((p,x)=>{p.style.transition=`opacity ${r}ms ${f}, transform ${r}ms ${f}`+(u?`, filter ${r}ms ${f}`:"");const M=y?d.length-1-x:x;p.style.transitionDelay=e==="stagger"?`${n+M*m}ms`:`${n}ms`}),requestAnimationFrame(()=>requestAnimationFrame(()=>{const p=new IntersectionObserver(x=>{x.forEach(M=>{if(M.isIntersecting){if(M.target.offsetWidth,M.target.style.opacity="1",M.target.style.transform="",u&&(M.target.style.filter=""),!g){p.unobserve(M.target);const I=M.target;I.addEventListener("transitionend",function c(v){v.target!==I||v.propertyName!=="opacity"||(I.removeEventListener("transitionend",c),I.style.transition="",I.style.transitionDelay="")})}}else g&&M.boundingClientRect.top>0&&h(M.target,d.indexOf(M.target))})},{threshold:.1,rootMargin:"100000px 0px 0px 0px"});d.forEach(x=>p.observe(x))}))}),he(document.querySelector(".page-body")||document),s.find(".card[data-collapsible]").each(function(){const o=this.querySelector(".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 r=t?.events?.click,{confirm:m,toast:n,alert:y,prompt:g,...d}=r||{};if(m||n||y||g){$(e).on("click",async function(W){if(W.preventDefault(),m&&!await E.confirm(m))return;let B=null;if(!(g&&(B=await E.prompt(g,{inputPlaceholder:d.promptPlaceholder||"",inputValue:d.promptDefault||""}),B===null))){{const O=$(d.target||this);d.toggleClass&&O.toggleClass(d.toggleClass),d.addClass&&O.addClass(d.addClass),d.removeClass&&O.removeClass(d.removeClass),B!==null&&(d.setText&&O.text(B),d.setVal&&O.val(B),d.setAttr&&O.attr(d.setAttr,B))}d.href&&se(d.href),n&&E.toast(n,{type:d.toastType||"success"}),y&&E.alert(y)}});const{target:w,toggleClass:u,addClass:f,removeClass:h,setText:p,setVal:x,setAttr:M,href:I,toastType:c,promptPlaceholder:v,promptDefault:k,...q}=d,N={...t.events};Object.keys(q).length?N.click=w?{target:w,...q}:q:delete N.click;const j={...t,events:N};Object.keys(N).length||delete j.events,Object.keys(j).length&&(o[e]=j)}else o[e]=t}$.setup(o)}}s.length&&R(s.get(0))}),window.wireCTAButtons=R;function se(l){if(!_e(l)){console.warn("[site] refused to go to",String(l).slice(0,60));return}const i=document.body?.classList.contains("dm-launcher-embed")&&window.top!==window;(i?window.top:window).location.href=l}function _e(l){const i=String(l??"").replace(/[\u0000-\u0020\u007f-\u00a0\u200b-\u200f\ufeff]/g,"").toLowerCase();return!i||i.includes("\\")||i.startsWith("//")?!1:/^(\/|#|\?|\.\.?\/)/.test(i)||/^(https?:\/\/|mailto:|tel:)/.test(i)?!0:!/^[a-z][a-z0-9+.-]*:/.test(i)}function R(l){l.querySelectorAll(".dm-cta-trigger").forEach(i=>{i.__ctaWired||(i.__ctaWired=!0,i.addEventListener("click",async()=>{const D=i.dataset.action,L=i.dataset.entry,z=i.dataset.confirm;let C=S.get("auth_token");if(!C){E.toast("Please log in to perform this action.",{type:"warning"});return}if(z&&!await E.confirm(z))return;const A=Array.from(i.childNodes).map(a=>a.cloneNode(!0));i.disabled=!0,i.textContent="Running\u2026";const s=a=>fetch(`/api/actions/${D}/public`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(i.dataset.scope?{entryId:L,scope:i.dataset.scope}:{entryId:L})});try{let a=await s(C);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:r}=await t.json();S.set("auth_token",r),C=r,a=await s(C)}}}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{i.disabled=!1,i.textContent="",A.forEach(a=>i.appendChild(a)),Domma.icons.scan(i)}}))})}(function(){const i=document.querySelectorAll('.dm-collection-hydrate[data-collection-scope="mine"]');if(!i.length)return;const D=S.get("auth_token");function L(C,A){const s=document.createElement("div");s.className="dm-collection-display dm-collection-empty";const a=document.createElement("p");if(A){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=C;return s.appendChild(a),s}function z(C,A){const s=document.createElement("template");s.innerHTML=A||"",C.replaceWith(s.content)}i.forEach(async C=>{const A=C.dataset.collectionAttrs;if(!A)return;if(!D){C.replaceChildren(L("",!0));return}const s=a=>fetch("/api/collections/render-scope",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({attrs:A})});try{let a=D,o=await s(a);if(o.status===401){const t=S.get("auth_refresh_token");if(t){const r=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t})});if(r.ok){const{token:m}=await r.json();S.set("auth_token",m),a=m,o=await s(a)}}}if(!o.ok){const{error:t}=await o.json().catch(()=>({}));C.replaceChildren(L(t||"Unable to load entries.",!1));return}const{html:e}=await o.json();z(C,e),window.DommaCollectionBrowser?.hydrate&&window.DommaCollectionBrowser.hydrate(document)}catch{C.replaceChildren(L("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 i=document.querySelectorAll("[data-collection-table]");!i.length||typeof T>"u"||!T.create||i.forEach(D=>{let L;try{L=V(D.dataset.payload)}catch{return}const{columns:z,rows:C,search:A,sortable:s,exportable:a,pageSize:o,empty:e,ctaConfig:t,slug:r,exportCfg:m}=L;if(!z?.length)return;if(t){const g=z.findIndex(d=>d.key==="_cta");g!==-1&&(z[g]={key:"_cta",title:"",render:(d,b)=>{const w=document.createElement("button");if(w.className=`btn btn-${t.style||"primary"} dm-cta-trigger`,w.dataset.action=t.action||"",t.scope&&(w.dataset.scope=t.scope),w.dataset.entry=b._entryId||"",t.confirm&&(w.dataset.confirm=t.confirm),t.icon){const u=document.createElement("span");u.dataset.icon=t.icon,w.appendChild(u),w.appendChild(document.createTextNode(" "))}return w.appendChild(document.createTextNode(t.label||"Run")),w}})}const n="col-table-"+Math.random().toString(36).slice(2,7),y=document.createElement("div");y.id=n,D.replaceChildren(y),T.create("#"+n,{data:C,columns:z,search:A,sortable:s,exportable:a,pageSize:o,emptyMessage:e}),t&&R(y),D._dmTable={columns:z,rows:C,slug:r,exportCfg:m,render(g){T.create("#"+n,{data:g,columns:z,search:A,sortable:s,exportable:a,pageSize:o,emptyMessage:e}),t&&R(y)}}})})(),(function(){const i=document.querySelectorAll("[data-form-inline]");if(!i.length||typeof F>"u")return;function D(s){const a=s&&s.logic;return!!(a&&(a.visibility||a.requirement))}function L(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)),r=e.type==="checkbox"?"boolean":e.type==="date"||e.type==="icon"||e.type==="image"?"string":t?"chooser":e.type,m={...e.formConfig||{}};m.span==="full"&&a&&(m.span=a);const n={type:r,required:D(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},...m}};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 C(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 A(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;"}i.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,r=e.layout||"grid",m=o.some(u=>u.type==="page-break"),n=new Map;Le(s,a.fileLimits,n),Te(s,o);const y=async u=>{if(s.dataset.triggerBlocked==="true"){const f=s._formLogicRuntime,h=f&&f.submitBlock?f.submitBlock().reasons:[];A(s,h.join(" ")||"This form cannot be submitted yet.",!0);const p=new Error("Blocked by a form trigger");throw p.formSubmitFailed=!0,p}try{const f=s.querySelector(".fb-form-honeypot"),h=f?.querySelector('input[type="text"]')||null,p=f?.querySelector('[name="_t"]')||null,x=Object.assign({},u);delete x._t,f?.dataset.hpName&&delete x[f.dataset.hpName],h!==null&&(x._hp=h.value),p!==null&&(x._t=p.value);const M=new Map(n);ne(s,M);const I=$e(x,o,M),c=Ae(s,I.files);if(c){A(s,c,!0);const k=new Error(c);throw k.formSubmitFailed=!0,k}const v=await H.post(`/api/forms/submit/${a.slug}`,I.files.size?Ee(I.values,I.files).body:I.values);if(v&&v.error){A(s,v.error,!0);const k=new Error(v.error);throw k.formSubmitFailed=!0,k}if(v?.redirect){se(v.redirect);return}for(Se(s);s.firstChild;)s.removeChild(s.firstChild);A(s,v?.message||e.successMessage||"Thank you for your submission.",!1)}catch(f){throw f.formSubmitFailed||A(s,f.message||"Submission failed. Please try again.",!0),f}},g=Date.now();function d(u){const f=u.querySelector("form");if(!f||f.querySelector(".fb-form-honeypot"))return;const h=document.createElement("div");h.className="fb-form-honeypot",h.setAttribute("aria-hidden","true");const p=document.createElement("input");p.name=f.querySelector('[name="website"]')?"_website":"website",h.dataset.hpName=p.name,p.type="text",p.tabIndex=-1,p.autocomplete="url",p.placeholder="https://",h.appendChild(p);const x=document.createElement("input");x.name="_t",x.type="hidden",x.value=g,h.appendChild(x),f.appendChild(h)}function b(u){if(!window.FormLogicEngine||!o.some(h=>h.logic||Array.isArray(h.triggers)&&h.triggers.length))return null;const f=new window.FormLogicEngine.FormLogicRuntime(a,s,u?{baseValues:u}:void 0);if(f.init(),s._formLogicRuntime=f,s._formLogicObserved)return f;if(s._formLogicObserved=!0,s.parentNode&&typeof MutationObserver<"u"){const h=new MutationObserver(function(p){for(const x of p)for(const M of x.removedNodes)if(M===s||M.nodeType===1&&M.contains&&M.contains(s)){s._formLogicRuntime&&s._formLogicRuntime.destroy(),h.disconnect();return}});h.observe(s.parentNode,{childList:!0,subtree:!1}),s._formLogicObserver=h}return f}let w=!1;if(s.addEventListener("dm-form-end",u=>{const f=u.detail?.validation;if(f&&!f.valid){Z(s,f.missing),ee(f);return}w||(w=!0,y(u.detail?.values||{}).catch(()=>{}).finally(()=>{w=!1}))}),m&&F.wizard){const u=ve(o,a.title),f=u.map(v=>({title:v.title,description:v.description,fields:L(v.fields,t)})),h=u.map(v=>v.fields);let p=0,x=null,M=null;const I=v=>{const k=window.FormLogicEngine;if(!k||!k.validateFields)return;const q=k.validateFields(s,h[p]||[]);q.valid||(v.preventDefault(),v.stopImmediatePropagation(),Z(s,q.missing),ee(q))},c=()=>{const v=h[p]||o;Ce(s,e),te(s,e,v),oe(s,e),C(s,v),Q(s,v),ke(s,n),e.honeypot!==!1&&d(s),x&&x.destroy(),x=b(M?.getStepData?M.getStepData():void 0),s.querySelectorAll(".wizard-next, .wizard-submit").forEach(k=>k.addEventListener("click",I,!0))};M=F.wizard(s,{schema:{steps:f},layout:r,columns:t,finishText:e.submitText||"Finish",onSubmit:y,onStepChange:v=>{ne(s,n),p=v,setTimeout(c,0)}}),s.addEventListener("dm-form-trigger",v=>{if(v.detail?.type!=="goto-step"||!M?.goToStep)return;const k=Number(v.detail.action.step);!Number.isFinite(k)||k<0||k>=f.length||k!==p&&M.goToStep(k)}),Promise.resolve(M).then(c)}else if(F.render){const u=F.render(s,L(o,t),z(o),{submitText:e.submitText||"Submit",layout:r,columns:t,onSubmit:y});Promise.resolve(u).then(function(){we(s,e,r),te(s,e,o),oe(s,e),C(s,o),Q(s,o),e.honeypot!==!1&&d(s),b()})}})})();function qe(l,i){const D=document.body,L=D.classList,z=new Set((D.dataset.railSite||"").split(" ").filter(Boolean)),C=()=>window.matchMedia("(min-width: 993px)").matches;l.querySelectorAll(".navbar-link, .navbar-dropdown-toggle").forEach(t=>{const r=t.textContent.trim();r&&(t.setAttribute("title",r),t.querySelector("svg, [data-icon]")||(t.dataset.initial=r.charAt(0).toUpperCase()))});const A=document.createElement("button");A.type="button",A.className="dm-nav-collapse-toggle";const s=()=>{const t=L.contains("dm-vnav-collapsed");A.setAttribute("aria-pressed",String(t)),A.setAttribute("aria-label",t?"Expand menu":"Collapse menu"),A.title=A.getAttribute("aria-label");const r=i?"chevrons-left":"chevrons-right",m=i?"chevrons-right":"chevrons-left";A.innerHTML=`<span data-icon="${t?r:m}"></span>`,window.Domma&&Domma.icons&&Domma.icons.scan(A)},a=t=>{L.toggle("dm-vnav-collapsed",t),S.set("nav_collapsed",t),s()};A.addEventListener("click",()=>a(!L.contains("dm-vnav-collapsed"))),s();const o=l.querySelector(".navbar-container")||l;o.insertBefore(A,o.firstChild?.nextSibling||null);const e=t=>{L.toggle("dm-vnav-autohide",t),L.toggle("dm-vnav-collapsible",!t&&z.has("collapsible")),t?L.remove("dm-vnav-collapsed"):z.has("collapsible")&&S.get("nav_collapsed")===!0&&L.add("dm-vnav-collapsed"),l.classList.remove("dm-nav-revealed"),s()};l.addEventListener("pointerdown",t=>{L.contains("dm-vnav-autohide")&&t.pointerType!=="mouse"&&!l.classList.contains("dm-nav-revealed")&&(l.classList.add("dm-nav-revealed"),t.preventDefault())}),document.addEventListener("pointerdown",t=>{l.contains(t.target)||l.classList.remove("dm-nav-revealed")}),window.E&&typeof E.contextMenu=="function"&&E.contextMenu(l,{items:()=>{const t=L.contains("dm-vnav-autohide"),r=L.contains("dm-vnav-collapsed"),m=S.has("nav_autohide")||S.has("nav_collapsed");return[{header:"Menu"},{label:r?"Expand menu":"Collapse to icons",icon:r?"maximize":"minimize",disabled:!C()||t||!z.has("collapsible"),action:()=>a(!r)},{label:t?"Keep on screen":"Hide when not in use",icon:t?"eye":"eye-off",disabled:!C(),action:()=>{S.set("nav_autohide",!t),e(!t)}},{type:"divider"},{label:"Reset to the site's setting",icon:"refresh",disabled:!m,action:()=>{S.remove("nav_autohide"),S.remove("nav_collapsed"),e(z.has("autohide")),L.toggle("dm-vnav-collapsed",!z.has("autohide")&&z.has("start-collapsed")),s()}}]}})}function Me(l){l.classList.add("dm-nav-scroll-hide");let i=window.scrollY,D=!1;window.addEventListener("scroll",()=>{D||(D=!0,requestAnimationFrame(()=>{D=!1;const L=window.scrollY,z=l.matches(":focus-within")||l.querySelector(".navbar-dropdown.open, .navbar-collapse.show");L>i&&L>l.offsetHeight&&!z?l.classList.add("dm-nav-scrolled-away"):L<i&&l.classList.remove("dm-nav-scrolled-away"),i=L}))},{passive:!0})}function De(l){let i={};try{i=JSON.parse(l.dataset.contents||"{}")}catch{}const D=l.closest(".site-main"),L=document.querySelector(".site-content"),z=new Set(String(i.exclude||"").split(",").map(n=>n.trim().toLowerCase()).filter(Boolean)),C=n=>!n.closest(".hero, .card, .accordion, .tabs, figure, #site-sidebar"),A=n=>(L?[...L.querySelectorAll(n)]:[]).filter(C).filter(y=>!z.has(y.textContent.trim().toLowerCase())),s=i.headings==="h2"?A("h2"):i.headings==="h3"?A("h3"):i.headings==="h2h3"?A("h2, h3"):A("h2").length?A("h2"):A("h3");if(!s.length){D?.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",i.title||"Page contents"),i.hover&&(o.dataset.menuHover=i.hover),i.selected&&(o.dataset.menuActive=i.selected),i.accent&&o.style.setProperty("--dm-menu-highlight",i.accent.startsWith("#")?i.accent:`var(--dm-${i.accent})`),i.font&&(o.style.fontFamily=i.font),i.fontSize&&(o.style.fontSize=i.fontSize),i.fontWeight&&(o.style.fontWeight=i.fontWeight);const e=document.createElement("div");e.className="dm-contents-head";const t=document.createElement("p");t.className="dm-contents-title",t.textContent=i.title||"",e.appendChild(t),o.appendChild(e);const r=document.createElement("ol");r.className="dm-contents-list"+(i.numbered?" is-numbered":"");const m=[];for(const n of s){if(!n.id){const d=(n.textContent||"").toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"section";let b=d;for(let w=2;a.has(b);w++)b=`${d}-${w}`;a.add(b),n.id=b}const y=document.createElement("li");y.className=`dm-contents-item dm-contents-${n.tagName.toLowerCase()}`;const g=document.createElement("a");g.href=`#${n.id}`,g.textContent=n.textContent.trim(),y.appendChild(g),r.appendChild(y),m.push([n,g])}if(o.appendChild(r),l.replaceChildren(o),i.scrollSpy!==!1&&"IntersectionObserver"in window){const n=new Map,y=()=>{const d=m.find(([b])=>n.get(b))||null;m.forEach(([,b])=>{const w=d&&b===d[1];b.classList.toggle("is-active",!!w),w?b.setAttribute("aria-current","location"):b.removeAttribute("aria-current")})},g=new IntersectionObserver(d=>{d.forEach(b=>n.set(b.target,b.isIntersecting)),y()},{rootMargin:"-80px 0px -60% 0px"});m.forEach(([d])=>g.observe(d))}if(D?.classList.contains("contents-collapsible")){const n=document.createElement("button");n.type="button",n.className="dm-contents-toggle";const y=()=>{const g=D.classList.contains("contents-collapsed");n.setAttribute("aria-expanded",String(!g)),n.setAttribute("aria-label",g?"Show the contents":"Hide the contents"),n.title=n.getAttribute("aria-label"),n.innerHTML=`<span data-icon="${g?"list":"x"}"></span>`,window.Domma?.icons&&Domma.icons.scan(n)};n.addEventListener("click",()=>{S.set("contents_collapsed",D.classList.toggle("contents-collapsed")),y()}),y(),e.insertBefore(n,e.firstChild)}if(D?.classList.contains("contents-floating")&&i.movable){o.classList.add("is-movable");const n=S.get("contents_position");n&&Number.isFinite(n.x)&&Object.assign(l.style,{left:`${n.x}px`,top:`${n.y}px`,right:"auto",bottom:"auto"}),e.addEventListener("pointerdown",y=>{if(y.target.closest("button"))return;const g=l.getBoundingClientRect(),d=y.clientX-g.left,b=y.clientY-g.top,w=f=>{const h=Math.max(0,Math.min(window.innerWidth-g.width,f.clientX-d)),p=Math.max(0,Math.min(window.innerHeight-40,f.clientY-b));Object.assign(l.style,{left:`${h}px`,top:`${p}px`,right:"auto",bottom:"auto"})},u=()=>{document.removeEventListener("pointermove",w),S.set("contents_position",{x:parseInt(l.style.left,10),y:parseInt(l.style.top,10)})};document.addEventListener("pointermove",w),document.addEventListener("pointerup",u,{once:!0})})}window.E&&typeof E.contextMenu=="function"&&E.contextMenu(l,{items:()=>{const n=D?.classList.contains("contents-collapsible"),y=D?.classList.contains("contents-collapsed"),g=m.find(([,d])=>d.classList.contains("is-active"));return[{header:"Contents"},...n?[{label:y?"Show the contents":"Collapse to a button",icon:y?"list":"minimize",action:()=>l.querySelector(".dm-contents-toggle")?.click()}]:[],{label:"Copy a link to this section",icon:"link",disabled:!g,action:async()=>{const d=`${location.origin}${location.pathname}#${g[0].id}`;try{await _.copyToClipboard(d),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"})}]}}),D?.classList.contains("contents-autohide")&&(l.addEventListener("pointerdown",n=>{n.pointerType!=="mouse"&&!l.classList.contains("is-revealed")&&(l.classList.add("is-revealed"),n.preventDefault())}),document.addEventListener("pointerdown",n=>{l.contains(n.target)||l.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,isCurrentItem as K,menuAlign as ue,applyClasses as P,cssClasses as X,applyEntrance as J}from"/public/js/menu-decor.mjs?v=20261014-menu-entrance";import{applyMenuLook as pe,applyFooterLook as fe}from"/public/js/menu-cards.mjs?v=20261029-footer-bars";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=20260829-float-panel";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",l=>{const i=l.target?.closest?.(".dm-banner__dismiss");i&&(l.preventDefault(),i.closest(".dm-banner")?.remove())}),$(()=>{re(document);const l=window.__CMS_NAV__||{},i=window.__CMS_SITE__||{},D=i.brandingEnabled!==!1&&l.brand?.enabled!==!1;if(i.autoTheme?.enabled){let o=function(r){const m=(r||"07:00").split(":");return+m[0]*60+(+m[1]||0)},e=function(){const r=new Date,m=r.getHours()*60+r.getMinutes();return m>=o(a.dayStart)&&m<o(a.nightStart)?a.dayTheme:a.nightTheme},t=function(r){const m=a.apply&&a.apply[r]||{theme:r,custom:""};Domma.theme.set(m.theme);for(const n of[...document.body.classList])n.startsWith("dm-custom-")&&document.body.classList.remove(n);m.custom&&document.body.classList.add(m.custom)};const a=i.autoTheme;t(e()),setInterval(()=>t(e()),6e4)}const L=$("#site-navbar");if(L.length&&l.brand){let e=function(u,f=0){return Array.isArray(u)?u.filter(h=>!(h&&(h.type==="spacer"||h.type==="theme-switcher"))).filter(h=>!(h&&h.type==="separator"&&f===0)).map(h=>h&&h.type==="separator"?{divider:!0}:Array.isArray(h?.items)?{...h,items:e(h.items,f+1)}:h):u};const a={...l.brand},o=a.size&&a.size!=="md"?` navbar-brand-${a.size}`:"";if(a.logo||a.icon||a.tagline){let u="";a.logo?u+=`<img src="${a.logo}" class="navbar-brand-logo" alt="${a.text||""}">`:a.icon&&(u+=`<span data-icon="${a.icon}" style="width:1.1em;height:1.1em;margin-right:.35em;vertical-align:middle;"></span>`),a.text&&(u+=`<span class="navbar-brand-text${o}">${a.text}</span>`),a.tagline&&(u+=`<small class="navbar-brand-tagline">${a.tagline}</small>`),a.html=u}else o&&a.text&&(a.html=`<span class="navbar-brand-text${o}">${a.text}</span>`);const t=e(l.items||[]),r=l.position==="floating",m=l.orientation==="vertical";L.get(0).querySelector(":scope > .cms-nojs-links")?.remove(),Domma.elements.navbar("#site-navbar",{brand:D?a:null,items:t,variant:l.variant||"dark",position:r?"static":l.position||"sticky",collapsible:!0,appearOnHover:!!l.appearOnHover}),Domma.icons.scan("#site-navbar");const n=L.get(0);ae(n,l.mobile);const y=()=>{if(!m)return;const f=n.querySelector('a[aria-current="page"]')?.closest(".navbar-dropdown");f&&!f.classList.contains("open")&&f.querySelector(":scope > .navbar-dropdown-toggle")?.click()};n.classList.add(`dm-nav-align-${ue(l)||"centre"}`),m&&L.get(0).classList.add("dm-nav-vertical",l.side==="right"?"dm-nav-vertical-right":"dm-nav-vertical-left");const g=l.dock||{};m&&!r&&qe(n,l.side==="right"),!m&&g.hideOnScroll&&Me(n),Y(n,l),J(n,l),P(n,l.class),r&&(le(L.get(0),l),ye(L.get(0).parentNode||document));const d=n.querySelector(".navbar-toggle"),b=n.querySelector(".navbar-collapse");if(d&&b){let u=null;const f=()=>{b.classList.contains("show")&&d.click()},h=()=>{u&&(u.remove(),u=null),document.body.classList.remove("dm-drawer-open")},p=()=>{u||(u=document.createElement("div"),u.className="dm-navbar-backdrop",u.addEventListener("click",f),document.body.appendChild(u),document.body.classList.add("dm-drawer-open"))};d.addEventListener("click",()=>{requestAnimationFrame(()=>{b.classList.contains("show")?(y(),p()):h()})}),b.addEventListener("click",x=>{x.target.closest("a")&&requestAnimationFrame(h)}),document.addEventListener("keydown",x=>{x.key==="Escape"&&b.classList.contains("show")&&f()})}const w=n.querySelector(".navbar-nav");if(w){const u=Array.from(w.children);let f=0;for(const h of l.items||[])if(!(h&&h.type==="separator")){if(h&&h.type==="spacer"){const p=document.createElement("li"),x=["xs","sm","md","lg","xl","flex"].includes(h.size)?h.size:"md";p.className=`dm-menu-spacer dm-menu-spacer--${x}`,p.setAttribute("aria-hidden","true"),w.insertBefore(p,u[f]||null);continue}if(h&&h.type==="theme-switcher"){const p=document.createElement("li");p.className="dm-menu-theme-switcher";const x=document.createElement("span");x.dataset.themeSwitcher="menu",x.dataset.position="inline",p.appendChild(x),w.insertBefore(p,u[f]||null);continue}f++}window.CMSThemeSwitcher?.scan(w)}n.querySelectorAll("[data-path]").forEach(u=>{const f=u.dataset.path.split(".").map(Number),h=f.length>1,p=f.reduce((M,I)=>M?.items?.[I],{items:t});if(!p)return;p.colour&&G(u,p.colour),p.pill&&!h&&ce(u,p.pill),de(u,p),P(u.closest("li"),p.class);const x=U(p.badge);x&&u.appendChild(x),K(p.url,location.pathname)&&(u.classList.add("active"),u.setAttribute("aria-current","page"))}),pe(n,l,t),y()}let z=null;const C=$("#site-footer");if(C.length){let r=function(c){return String(c??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},m=function(c){return r(c).replace(/'/g,"'")},n=function(c){if(c&&c.type==="separator")return'<li class="footer-sep"><hr></li>';if(c&&c.type==="spacer")return`<li class="dm-menu-spacer dm-menu-spacer--${["xs","sm","md","lg","xl","flex"].includes(c.size)?c.size:"md"}" aria-hidden="true"></li>`;if(c&&c.type==="theme-switcher")return'<li class="dm-menu-theme-switcher"><span data-theme-switcher="menu" data-position="inline"></span></li>';const v=m(c.url||"#"),k=r(c.text||""),q=Array.isArray(c.items)&&c.items.length?`<ul>${c.items.map(n).join("")}</ul>`:"",N=me(c),j=[N.hover&&` data-menu-item-hover="${m(N.hover)}"`,N.active&&` data-menu-item-active="${m(N.active)}"`].filter(Boolean).join(""),W=N.accent?` style="--dm-menu-highlight:${m(N.accent)}"`:"",B=X(c.class).join(" ");return`<li${B?` class="${m(B)}"`:""}><a href="${v}"${j}${W}>${k}</a>${q}</li>`},g=function(){if(!i.footer)return"";const c=Object.keys(o).filter(k=>a[k]);if(!c.length)return"";const v=X(i.footer.socialClass).join(" ");return`<div class="footer-social">${c.map(k=>{const{label:q,svg:N}=o[k];return`<a href="${a[k]}" target="_blank" rel="noopener noreferrer" aria-label="${q}" class="footer-social-link${v?` ${m(v)}`:""}">${N}</a>`}).join("")}</div>`},u=function(c){if(!c||c.type==="separator"||c.type==="spacer")return"";if(c.type==="theme-switcher")return`<li class="cms-footer-col">${n(c).replace(/^<li[^>]*>|<\/li>$/g,"")}</li>`;const v=Array.isArray(c.items)&&c.items.length?`<ul>${c.items.map(n).join("")}</ul>`:"",k=w(c)?`<span class="cms-footer-col-title">${r(c.text||"")}</span>`:`<a class="cms-footer-col-title" href="${m(c.url||"#")}">${r(c.text||"")}</a>`,q=["cms-footer-col",...X(c.class)].join(" ");return`<li class="${m(q)}">${k}${v}</li>`},p=function(c,v,k=!1){return(c||[]).forEach(q=>{q&&(q.type==="separator"||q.type==="spacer"||q.type==="theme-switcher")||(k&&w(q)||v.push(q),Array.isArray(q.items)&&q.items.length&&p(q.items,v))}),v};const a=i.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:""},y=(()=>{const c=i.cookieConsent;if(!c||c.showSettingsLink===!1)return"";const v=k=>(k||[]).some(q=>q&&(q.url==="#cookie-settings"||v(q.items)));return v(t.primary)||v(t.legal)?"":`<li class="cms-cookie-settings"><a href="#cookie-settings">${r(c.settingsLinkText||"Cookie settings")}</a></li>`})(),d=["columns","row"].includes(i.footer?.layout)?i.footer.layout:"auto",b=i.footer?.look==="showcase"||d==="columns"||d==="auto"&&t.primary.some(c=>Array.isArray(c?.items)&&c.items.length),w=c=>b&&!c.url&&Array.isArray(c.items)&&c.items.length>0;if(b){const c=l.brand||{},v=D&&(c.text||i.title)||"",k=D?c.logo?`<img src="${m(c.logo)}" class="cms-footer-brand-logo" alt="">`:c.icon?'<span class="cms-footer-brand-icon"></span>':"":"",q=String(i.footer?.blurb||"").trim();e='<div class="footer-inner footer-inner--columns container"><div class="cms-footer-top">',e+=`<div class="cms-footer-brand">${v||k?`<a class="cms-footer-brand-name" href="${m(c.url||"/")}">${k}<span>${r(v)}</span></a>`:""}${q?`<p class="cms-footer-blurb">${r(q)}</p>`:""}${g()}</div>`,t.primary.length&&(e+=`<nav class="footer-nav footer-nav--primary footer-nav--columns" aria-label="Footer"><ul>${t.primary.map(u).join("")}</ul></nav>`),e+='</div><div class="cms-footer-bottom">',t.copyright&&(e+=`<p class="cms-footer-copyright">${r(t.copyright)}</p>`),(t.legal.length||y)&&(e+=`<nav class="footer-nav footer-nav--legal" aria-label="Legal"><ul>${t.legal.map(n).join("")}${y}</ul></nav>`),e+="</div>"}else t.copyright&&(e+=`<p>${r(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||y)&&(e+=`<nav class="footer-nav footer-nav--legal"><ul>${t.legal.map(n).join("")}${y}</ul></nav>`),e+=g();e+="</div>",C.get(0).querySelector(":scope > .cms-nojs-links")?.remove();const f=C.get(0).querySelector(":scope > .cms-footer-blocks");f?.remove(),C.html(e),f&&C.get(0).prepend(f),window.CMSThemeSwitcher?.scan(C.get(0));const h=C.get(0).querySelector(".cms-footer-brand-icon");h&&l.brand?.icon&&h.setAttribute("data-icon",l.brand.icon),P(C.get(0),i.footer?.class),b&&ge(C.get(0),i);const x=[...p(t.primary,[],!0),...p(t.legal,[])],M=C.get(0).querySelectorAll(".footer-nav a"),I=[];M.forEach((c,v)=>{const k=x[v];if(!k)return;if(I.push({a:c,item:k}),k.icon){const N=document.createElement("span");N.className="cms-footer-ic",N.setAttribute("data-icon",String(k.icon)),N.setAttribute("data-icon-size","15"),N.setAttribute("aria-hidden","true"),c.prepend(N)}k.colour&&G(c,k.colour);const q=U(k.badge);q&&c.appendChild(q),K(k.url,location.pathname)&&(c.classList.add("is-active"),c.setAttribute("aria-current","page"))}),Y(C.get(0).querySelector(".footer-nav--primary"),{highlight:t.primaryHighlight}),Y(C.get(0).querySelector(".footer-nav--legal"),{highlight:t.legalHighlight}),J(C.get(0).querySelector(".footer-nav--primary"),{entrance:t.primaryEntrance}),J(C.get(0).querySelector(".footer-nav--legal"),{entrance:t.legalEntrance}),P(C.get(0).querySelector(".footer-nav--primary"),t.primaryClass),P(C.get(0).querySelector(".footer-nav--legal"),t.legalClass),fe(C.get(0),t,I),z=C.get(0).querySelector(".cms-footer-bottom")||C.get(0).querySelector(".footer-inner")}be(i.motion||{enabled:i.footer?.showMotionToggle!==!1,default:i.footer?.motionDefault,placement:"footer",control:i.footer?.motionControl,label:"Reduce motion"},{footer:z,navbar:document.querySelector("#site-navbar .navbar-container")?.closest("#site-navbar")||null});const A=document.getElementById("site-sidebar");A&&De(A),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=g=>{const d=String(g||"").trim();return d?o[d.toLowerCase()]?`var(${o[d.toLowerCase()]})`:CSS.supports("color",d)?d:"":""},t=e(this.dataset.background),r=e(this.dataset.arrowBackground),m=e(this.dataset.arrowColor);t&&(this.style.setProperty("--dm-carousel-background",t),this.classList.add("dm-carousel-custom-background")),r&&this.style.setProperty("--dm-carousel-arrow-background",r),m&&this.style.setProperty("--dm-carousel-arrow-color",m);const n=["top","middle","bottom"].includes(this.dataset.arrowPosition)?this.dataset.arrowPosition:"middle";this.classList.add(`dm-carousel-arrows-${n}`);const y={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 g=Number(this.dataset.height);Number.isFinite(g)&&g>0&&(y.height=g)}if(this.dataset.animationDuration){const g=parseInt(this.dataset.animationDuration,10);Number.isFinite(g)&&(y.animationDuration=g)}this.dataset.animationEasing&&(y.animationEasing=this.dataset.animationEasing),this.dataset.ctx&&(this._dmCtxSlides=Array.from(this.querySelectorAll(".carousel-slide")).map(g=>g.cloneNode(!0)),this._dmCarouselOpts=y),this._dmCarousel=Domma.elements.carousel(this,y),ie(this)}),s.find(".dm-countdown").each(function(){const o={autoStart:!0},e=String(this.dataset.format||"").trim(),t=String(this.dataset.to||"").trim(),r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t),m=r?new Date(+r[1],+r[2]-1,+r[3]).getTime():t?new Date(t).getTime():NaN;Number.isFinite(m)?o.duration=Math.max(0,m-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 y=this,g=b=>String(b).padStart(2,"0"),d=b=>{const w=Math.max(0,Math.floor(b/1e3)),u=y.querySelector(".dm-timer-time");u&&(u.textContent=`${g(Math.floor(w/86400))}:${g(Math.floor(w%86400/3600))}:${g(Math.floor(w%3600/60))}:${g(w%60)}`)};n&&(o.onTick=d),Domma.elements.timer(this,o),n&&d(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(r=>{const m={title:r.querySelector(".dm-progression-item-title")?.textContent?.trim()||"",description:r.querySelector(".dm-progression-item-body")?.innerHTML?.trim()||""};return r.dataset.date&&(m.date=r.dataset.date),r.dataset.status&&(m.status=r.dataset.status),r.dataset.eventIcon&&(m.icon=r.dataset.eventIcon),r.dataset.entryId&&(m._entryId=r.dataset.entryId),m}),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 r={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((m,n)=>{const y=o[n];if(!y)return;const g=m.querySelector(".dm-progression-title");if(y.icon&&g){const b=document.createElement("span");b.dataset.icon=y.icon,b.style.cssText="display:inline-flex;vertical-align:middle;margin-right:.4em",b.setAttribute("aria-hidden","true"),g.prepend(b)}const d=r[y.status];if(d&&g){const b=document.createElement("span");b.className=`badge badge-${d.tone} cms-timeline-status`,b.style.cssText="display:inline-flex;align-items:center;gap:.35em;margin:.4rem 0";const w=document.createElement("span");w.dataset.icon=d.icon,w.dataset.iconSize="14",w.setAttribute("aria-hidden","true"),b.append(w,document.createTextNode(d.label)),g.after(b)}})}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",r=parseInt(o.dataset.revealDuration,10)||(t.startsWith("swoosh")?700:400),m=parseInt(o.dataset.revealStagger,10)||(t.startsWith("swoosh")?90:60),n=parseInt(o.dataset.revealDelay,10)||0,y=o.dataset.revealDirection==="rtl",g=o.dataset.revealReplay==="true",d=Array.from(o.children);if(a&&t.startsWith("swoosh"))return;const b={"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)"},w=p=>t!=="swoosh-sides"?b[t]||"":d.length>1&&p===0?"translateX(-64px) rotate(-1.5deg)":d.length>1&&p===d.length-1?"translateX(64px) rotate(1.5deg)":"translateY(40px) scale(0.94)",u=t.startsWith("swoosh"),f=u?"cubic-bezier(.2,.8,.2,1)":"ease",h=(p,x)=>{p.style.opacity="0",p.style.transform=w(x),u&&(p.style.filter="blur(10px)")};d.forEach((p,x)=>{p.style.transition="none",h(p,x)}),o.offsetWidth,d.forEach((p,x)=>{p.style.transition=`opacity ${r}ms ${f}, transform ${r}ms ${f}`+(u?`, filter ${r}ms ${f}`:"");const M=y?d.length-1-x:x;p.style.transitionDelay=e==="stagger"?`${n+M*m}ms`:`${n}ms`}),requestAnimationFrame(()=>requestAnimationFrame(()=>{const p=new IntersectionObserver(x=>{x.forEach(M=>{if(M.isIntersecting){if(M.target.offsetWidth,M.target.style.opacity="1",M.target.style.transform="",u&&(M.target.style.filter=""),!g){p.unobserve(M.target);const I=M.target;I.addEventListener("transitionend",function c(v){v.target!==I||v.propertyName!=="opacity"||(I.removeEventListener("transitionend",c),I.style.transition="",I.style.transitionDelay="")})}}else g&&M.boundingClientRect.top>0&&h(M.target,d.indexOf(M.target))})},{threshold:.1,rootMargin:"100000px 0px 0px 0px"});d.forEach(x=>p.observe(x))}))}),he(document.querySelector(".page-body")||document),s.find(".card[data-collapsible]").each(function(){const o=this.querySelector(".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 r=t?.events?.click,{confirm:m,toast:n,alert:y,prompt:g,...d}=r||{};if(m||n||y||g){$(e).on("click",async function(W){if(W.preventDefault(),m&&!await E.confirm(m))return;let B=null;if(!(g&&(B=await E.prompt(g,{inputPlaceholder:d.promptPlaceholder||"",inputValue:d.promptDefault||""}),B===null))){{const O=$(d.target||this);d.toggleClass&&O.toggleClass(d.toggleClass),d.addClass&&O.addClass(d.addClass),d.removeClass&&O.removeClass(d.removeClass),B!==null&&(d.setText&&O.text(B),d.setVal&&O.val(B),d.setAttr&&O.attr(d.setAttr,B))}d.href&&se(d.href),n&&E.toast(n,{type:d.toastType||"success"}),y&&E.alert(y)}});const{target:w,toggleClass:u,addClass:f,removeClass:h,setText:p,setVal:x,setAttr:M,href:I,toastType:c,promptPlaceholder:v,promptDefault:k,...q}=d,N={...t.events};Object.keys(q).length?N.click=w?{target:w,...q}:q:delete N.click;const j={...t,events:N};Object.keys(N).length||delete j.events,Object.keys(j).length&&(o[e]=j)}else o[e]=t}$.setup(o)}}s.length&&R(s.get(0))}),window.wireCTAButtons=R;function se(l){if(!_e(l)){console.warn("[site] refused to go to",String(l).slice(0,60));return}const i=document.body?.classList.contains("dm-launcher-embed")&&window.top!==window;(i?window.top:window).location.href=l}function _e(l){const i=String(l??"").replace(/[\u0000-\u0020\u007f-\u00a0\u200b-\u200f\ufeff]/g,"").toLowerCase();return!i||i.includes("\\")||i.startsWith("//")?!1:/^(\/|#|\?|\.\.?\/)/.test(i)||/^(https?:\/\/|mailto:|tel:)/.test(i)?!0:!/^[a-z][a-z0-9+.-]*:/.test(i)}function R(l){l.querySelectorAll(".dm-cta-trigger").forEach(i=>{i.__ctaWired||(i.__ctaWired=!0,i.addEventListener("click",async()=>{const D=i.dataset.action,L=i.dataset.entry,z=i.dataset.confirm;let C=S.get("auth_token");if(!C){E.toast("Please log in to perform this action.",{type:"warning"});return}if(z&&!await E.confirm(z))return;const A=Array.from(i.childNodes).map(a=>a.cloneNode(!0));i.disabled=!0,i.textContent="Running\u2026";const s=a=>fetch(`/api/actions/${D}/public`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(i.dataset.scope?{entryId:L,scope:i.dataset.scope}:{entryId:L})});try{let a=await s(C);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:r}=await t.json();S.set("auth_token",r),C=r,a=await s(C)}}}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{i.disabled=!1,i.textContent="",A.forEach(a=>i.appendChild(a)),Domma.icons.scan(i)}}))})}(function(){const i=document.querySelectorAll('.dm-collection-hydrate[data-collection-scope="mine"]');if(!i.length)return;const D=S.get("auth_token");function L(C,A){const s=document.createElement("div");s.className="dm-collection-display dm-collection-empty";const a=document.createElement("p");if(A){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=C;return s.appendChild(a),s}function z(C,A){const s=document.createElement("template");s.innerHTML=A||"",C.replaceWith(s.content)}i.forEach(async C=>{const A=C.dataset.collectionAttrs;if(!A)return;if(!D){C.replaceChildren(L("",!0));return}const s=a=>fetch("/api/collections/render-scope",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({attrs:A})});try{let a=D,o=await s(a);if(o.status===401){const t=S.get("auth_refresh_token");if(t){const r=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t})});if(r.ok){const{token:m}=await r.json();S.set("auth_token",m),a=m,o=await s(a)}}}if(!o.ok){const{error:t}=await o.json().catch(()=>({}));C.replaceChildren(L(t||"Unable to load entries.",!1));return}const{html:e}=await o.json();z(C,e),window.DommaCollectionBrowser?.hydrate&&window.DommaCollectionBrowser.hydrate(document)}catch{C.replaceChildren(L("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 i=document.querySelectorAll("[data-collection-table]");!i.length||typeof T>"u"||!T.create||i.forEach(D=>{let L;try{L=V(D.dataset.payload)}catch{return}const{columns:z,rows:C,search:A,sortable:s,exportable:a,pageSize:o,empty:e,ctaConfig:t,slug:r,exportCfg:m}=L;if(!z?.length)return;if(t){const g=z.findIndex(d=>d.key==="_cta");g!==-1&&(z[g]={key:"_cta",title:"",render:(d,b)=>{const w=document.createElement("button");if(w.className=`btn btn-${t.style||"primary"} dm-cta-trigger`,w.dataset.action=t.action||"",t.scope&&(w.dataset.scope=t.scope),w.dataset.entry=b._entryId||"",t.confirm&&(w.dataset.confirm=t.confirm),t.icon){const u=document.createElement("span");u.dataset.icon=t.icon,w.appendChild(u),w.appendChild(document.createTextNode(" "))}return w.appendChild(document.createTextNode(t.label||"Run")),w}})}const n="col-table-"+Math.random().toString(36).slice(2,7),y=document.createElement("div");y.id=n,D.replaceChildren(y),T.create("#"+n,{data:C,columns:z,search:A,sortable:s,exportable:a,pageSize:o,emptyMessage:e}),t&&R(y),D._dmTable={columns:z,rows:C,slug:r,exportCfg:m,render(g){T.create("#"+n,{data:g,columns:z,search:A,sortable:s,exportable:a,pageSize:o,emptyMessage:e}),t&&R(y)}}})})(),(function(){const i=document.querySelectorAll("[data-form-inline]");if(!i.length||typeof F>"u")return;function D(s){const a=s&&s.logic;return!!(a&&(a.visibility||a.requirement))}function L(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)),r=e.type==="checkbox"?"boolean":e.type==="date"||e.type==="icon"||e.type==="image"?"string":t?"chooser":e.type,m={...e.formConfig||{}};m.span==="full"&&a&&(m.span=a);const n={type:r,required:D(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},...m}};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 C(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 A(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;"}i.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,r=e.layout||"grid",m=o.some(u=>u.type==="page-break"),n=new Map;Le(s,a.fileLimits,n),Te(s,o);const y=async u=>{if(s.dataset.triggerBlocked==="true"){const f=s._formLogicRuntime,h=f&&f.submitBlock?f.submitBlock().reasons:[];A(s,h.join(" ")||"This form cannot be submitted yet.",!0);const p=new Error("Blocked by a form trigger");throw p.formSubmitFailed=!0,p}try{const f=s.querySelector(".fb-form-honeypot"),h=f?.querySelector('input[type="text"]')||null,p=f?.querySelector('[name="_t"]')||null,x=Object.assign({},u);delete x._t,f?.dataset.hpName&&delete x[f.dataset.hpName],h!==null&&(x._hp=h.value),p!==null&&(x._t=p.value);const M=new Map(n);ne(s,M);const I=$e(x,o,M),c=Ae(s,I.files);if(c){A(s,c,!0);const k=new Error(c);throw k.formSubmitFailed=!0,k}const v=await H.post(`/api/forms/submit/${a.slug}`,I.files.size?Ee(I.values,I.files).body:I.values);if(v&&v.error){A(s,v.error,!0);const k=new Error(v.error);throw k.formSubmitFailed=!0,k}if(v?.redirect){se(v.redirect);return}for(Se(s);s.firstChild;)s.removeChild(s.firstChild);A(s,v?.message||e.successMessage||"Thank you for your submission.",!1)}catch(f){throw f.formSubmitFailed||A(s,f.message||"Submission failed. Please try again.",!0),f}},g=Date.now();function d(u){const f=u.querySelector("form");if(!f||f.querySelector(".fb-form-honeypot"))return;const h=document.createElement("div");h.className="fb-form-honeypot",h.setAttribute("aria-hidden","true");const p=document.createElement("input");p.name=f.querySelector('[name="website"]')?"_website":"website",h.dataset.hpName=p.name,p.type="text",p.tabIndex=-1,p.autocomplete="url",p.placeholder="https://",h.appendChild(p);const x=document.createElement("input");x.name="_t",x.type="hidden",x.value=g,h.appendChild(x),f.appendChild(h)}function b(u){if(!window.FormLogicEngine||!o.some(h=>h.logic||Array.isArray(h.triggers)&&h.triggers.length))return null;const f=new window.FormLogicEngine.FormLogicRuntime(a,s,u?{baseValues:u}:void 0);if(f.init(),s._formLogicRuntime=f,s._formLogicObserved)return f;if(s._formLogicObserved=!0,s.parentNode&&typeof MutationObserver<"u"){const h=new MutationObserver(function(p){for(const x of p)for(const M of x.removedNodes)if(M===s||M.nodeType===1&&M.contains&&M.contains(s)){s._formLogicRuntime&&s._formLogicRuntime.destroy(),h.disconnect();return}});h.observe(s.parentNode,{childList:!0,subtree:!1}),s._formLogicObserver=h}return f}let w=!1;if(s.addEventListener("dm-form-end",u=>{const f=u.detail?.validation;if(f&&!f.valid){Z(s,f.missing),ee(f);return}w||(w=!0,y(u.detail?.values||{}).catch(()=>{}).finally(()=>{w=!1}))}),m&&F.wizard){const u=ve(o,a.title),f=u.map(v=>({title:v.title,description:v.description,fields:L(v.fields,t)})),h=u.map(v=>v.fields);let p=0,x=null,M=null;const I=v=>{const k=window.FormLogicEngine;if(!k||!k.validateFields)return;const q=k.validateFields(s,h[p]||[]);q.valid||(v.preventDefault(),v.stopImmediatePropagation(),Z(s,q.missing),ee(q))},c=()=>{const v=h[p]||o;Ce(s,e),te(s,e,v),oe(s,e),C(s,v),Q(s,v),ke(s,n),e.honeypot!==!1&&d(s),x&&x.destroy(),x=b(M?.getStepData?M.getStepData():void 0),s.querySelectorAll(".wizard-next, .wizard-submit").forEach(k=>k.addEventListener("click",I,!0))};M=F.wizard(s,{schema:{steps:f},layout:r,columns:t,finishText:e.submitText||"Finish",onSubmit:y,onStepChange:v=>{ne(s,n),p=v,setTimeout(c,0)}}),s.addEventListener("dm-form-trigger",v=>{if(v.detail?.type!=="goto-step"||!M?.goToStep)return;const k=Number(v.detail.action.step);!Number.isFinite(k)||k<0||k>=f.length||k!==p&&M.goToStep(k)}),Promise.resolve(M).then(c)}else if(F.render){const u=F.render(s,L(o,t),z(o),{submitText:e.submitText||"Submit",layout:r,columns:t,onSubmit:y});Promise.resolve(u).then(function(){we(s,e,r),te(s,e,o),oe(s,e),C(s,o),Q(s,o),e.honeypot!==!1&&d(s),b()})}})})();function qe(l,i){const D=document.body,L=D.classList,z=new Set((D.dataset.railSite||"").split(" ").filter(Boolean)),C=()=>window.matchMedia("(min-width: 993px)").matches;l.querySelectorAll(".navbar-link, .navbar-dropdown-toggle").forEach(t=>{const r=t.textContent.trim();r&&(t.setAttribute("title",r),t.querySelector("svg, [data-icon]")||(t.dataset.initial=r.charAt(0).toUpperCase()))});const A=document.createElement("button");A.type="button",A.className="dm-nav-collapse-toggle";const s=()=>{const t=L.contains("dm-vnav-collapsed");A.setAttribute("aria-pressed",String(t)),A.setAttribute("aria-label",t?"Expand menu":"Collapse menu"),A.title=A.getAttribute("aria-label");const r=i?"chevrons-left":"chevrons-right",m=i?"chevrons-right":"chevrons-left";A.innerHTML=`<span data-icon="${t?r:m}"></span>`,window.Domma&&Domma.icons&&Domma.icons.scan(A)},a=t=>{L.toggle("dm-vnav-collapsed",t),S.set("nav_collapsed",t),s()};A.addEventListener("click",()=>a(!L.contains("dm-vnav-collapsed"))),s();const o=l.querySelector(".navbar-container")||l;o.insertBefore(A,o.firstChild?.nextSibling||null);const e=t=>{L.toggle("dm-vnav-autohide",t),L.toggle("dm-vnav-collapsible",!t&&z.has("collapsible")),t?L.remove("dm-vnav-collapsed"):z.has("collapsible")&&S.get("nav_collapsed")===!0&&L.add("dm-vnav-collapsed"),l.classList.remove("dm-nav-revealed"),s()};l.addEventListener("pointerdown",t=>{L.contains("dm-vnav-autohide")&&t.pointerType!=="mouse"&&!l.classList.contains("dm-nav-revealed")&&(l.classList.add("dm-nav-revealed"),t.preventDefault())}),document.addEventListener("pointerdown",t=>{l.contains(t.target)||l.classList.remove("dm-nav-revealed")}),window.E&&typeof E.contextMenu=="function"&&E.contextMenu(l,{items:()=>{const t=L.contains("dm-vnav-autohide"),r=L.contains("dm-vnav-collapsed"),m=S.has("nav_autohide")||S.has("nav_collapsed");return[{header:"Menu"},{label:r?"Expand menu":"Collapse to icons",icon:r?"maximize":"minimize",disabled:!C()||t||!z.has("collapsible"),action:()=>a(!r)},{label:t?"Keep on screen":"Hide when not in use",icon:t?"eye":"eye-off",disabled:!C(),action:()=>{S.set("nav_autohide",!t),e(!t)}},{type:"divider"},{label:"Reset to the site's setting",icon:"refresh",disabled:!m,action:()=>{S.remove("nav_autohide"),S.remove("nav_collapsed"),e(z.has("autohide")),L.toggle("dm-vnav-collapsed",!z.has("autohide")&&z.has("start-collapsed")),s()}}]}})}function Me(l){l.classList.add("dm-nav-scroll-hide");let i=window.scrollY,D=!1;window.addEventListener("scroll",()=>{D||(D=!0,requestAnimationFrame(()=>{D=!1;const L=window.scrollY,z=l.matches(":focus-within")||l.querySelector(".navbar-dropdown.open, .navbar-collapse.show");L>i&&L>l.offsetHeight&&!z?l.classList.add("dm-nav-scrolled-away"):L<i&&l.classList.remove("dm-nav-scrolled-away"),i=L}))},{passive:!0})}function De(l){let i={};try{i=JSON.parse(l.dataset.contents||"{}")}catch{}const D=l.closest(".site-main"),L=document.querySelector(".site-content"),z=new Set(String(i.exclude||"").split(",").map(n=>n.trim().toLowerCase()).filter(Boolean)),C=n=>!n.closest(".hero, .card, .accordion, .tabs, figure, #site-sidebar"),A=n=>(L?[...L.querySelectorAll(n)]:[]).filter(C).filter(y=>!z.has(y.textContent.trim().toLowerCase())),s=i.headings==="h2"?A("h2"):i.headings==="h3"?A("h3"):i.headings==="h2h3"?A("h2, h3"):A("h2").length?A("h2"):A("h3");if(!s.length){D?.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",i.title||"Page contents"),i.hover&&(o.dataset.menuHover=i.hover),i.selected&&(o.dataset.menuActive=i.selected),i.accent&&o.style.setProperty("--dm-menu-highlight",i.accent.startsWith("#")?i.accent:`var(--dm-${i.accent})`),i.font&&(o.style.fontFamily=i.font),i.fontSize&&(o.style.fontSize=i.fontSize),i.fontWeight&&(o.style.fontWeight=i.fontWeight);const e=document.createElement("div");e.className="dm-contents-head";const t=document.createElement("p");t.className="dm-contents-title",t.textContent=i.title||"",e.appendChild(t),o.appendChild(e);const r=document.createElement("ol");r.className="dm-contents-list"+(i.numbered?" is-numbered":"");const m=[];for(const n of s){if(!n.id){const d=(n.textContent||"").toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"section";let b=d;for(let w=2;a.has(b);w++)b=`${d}-${w}`;a.add(b),n.id=b}const y=document.createElement("li");y.className=`dm-contents-item dm-contents-${n.tagName.toLowerCase()}`;const g=document.createElement("a");g.href=`#${n.id}`,g.textContent=n.textContent.trim(),y.appendChild(g),r.appendChild(y),m.push([n,g])}if(o.appendChild(r),l.replaceChildren(o),i.scrollSpy!==!1&&"IntersectionObserver"in window){const n=new Map,y=()=>{const d=m.find(([b])=>n.get(b))||null;m.forEach(([,b])=>{const w=d&&b===d[1];b.classList.toggle("is-active",!!w),w?b.setAttribute("aria-current","location"):b.removeAttribute("aria-current")})},g=new IntersectionObserver(d=>{d.forEach(b=>n.set(b.target,b.isIntersecting)),y()},{rootMargin:"-80px 0px -60% 0px"});m.forEach(([d])=>g.observe(d))}if(D?.classList.contains("contents-collapsible")){const n=document.createElement("button");n.type="button",n.className="dm-contents-toggle";const y=()=>{const g=D.classList.contains("contents-collapsed");n.setAttribute("aria-expanded",String(!g)),n.setAttribute("aria-label",g?"Show the contents":"Hide the contents"),n.title=n.getAttribute("aria-label"),n.innerHTML=`<span data-icon="${g?"list":"x"}"></span>`,window.Domma?.icons&&Domma.icons.scan(n)};n.addEventListener("click",()=>{S.set("contents_collapsed",D.classList.toggle("contents-collapsed")),y()}),y(),e.insertBefore(n,e.firstChild)}if(D?.classList.contains("contents-floating")&&i.movable){o.classList.add("is-movable");const n=S.get("contents_position");n&&Number.isFinite(n.x)&&Object.assign(l.style,{left:`${n.x}px`,top:`${n.y}px`,right:"auto",bottom:"auto"}),e.addEventListener("pointerdown",y=>{if(y.target.closest("button"))return;const g=l.getBoundingClientRect(),d=y.clientX-g.left,b=y.clientY-g.top,w=f=>{const h=Math.max(0,Math.min(window.innerWidth-g.width,f.clientX-d)),p=Math.max(0,Math.min(window.innerHeight-40,f.clientY-b));Object.assign(l.style,{left:`${h}px`,top:`${p}px`,right:"auto",bottom:"auto"})},u=()=>{document.removeEventListener("pointermove",w),S.set("contents_position",{x:parseInt(l.style.left,10),y:parseInt(l.style.top,10)})};document.addEventListener("pointermove",w),document.addEventListener("pointerup",u,{once:!0})})}window.E&&typeof E.contextMenu=="function"&&E.contextMenu(l,{items:()=>{const n=D?.classList.contains("contents-collapsible"),y=D?.classList.contains("contents-collapsed"),g=m.find(([,d])=>d.classList.contains("is-active"));return[{header:"Contents"},...n?[{label:y?"Show the contents":"Collapse to a button",icon:y?"list":"minimize",action:()=>l.querySelector(".dm-contents-toggle")?.click()}]:[],{label:"Copy a link to this section",icon:"link",disabled:!g,action:async()=>{const d=`${location.origin}${location.pathname}#${g[0].id}`;try{await _.copyToClipboard(d),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"})}]}}),D?.classList.contains("contents-autohide")&&(l.addEventListener("pointerdown",n=>{n.pointerType!=="mouse"&&!l.classList.contains("is-revealed")&&(l.classList.add("is-revealed"),n.preventDefault())}),document.addEventListener("pointerdown",n=>{l.contains(n.target)||l.classList.remove("is-revealed")}))}
|
|
@@ -55,6 +55,7 @@ import {formMayCollect, servedType} from '../../services/mediaTypes.js';
|
|
|
55
55
|
import {v4 as uuidv4} from 'uuid';
|
|
56
56
|
import {ago, clip, plural} from '../../services/sidebarBadges.js';
|
|
57
57
|
import {safeFetch} from '../../services/outbound.js';
|
|
58
|
+
import {verifyFormContext} from '../../services/formContext.js';
|
|
58
59
|
|
|
59
60
|
/**
|
|
60
61
|
* Detect form↔collection mismatches at save time so admins know BEFORE
|
|
@@ -538,6 +539,24 @@ async function cachedStats(form, now) {
|
|
|
538
539
|
/** A form's submissions changed (sent, deleted, cleared) or the form went: the next badge reads afresh. */
|
|
539
540
|
const forgetStats = (slug) => { statsCache.delete(slug); };
|
|
540
541
|
|
|
542
|
+
/**
|
|
543
|
+
* Delete one submission as the delete route does - its uploads and the submission counts go with it. For plugins
|
|
544
|
+
* through services/formContext.js removeFormEntry (a person's data being erased). True when it was there.
|
|
545
|
+
*
|
|
546
|
+
* @param {string} slug
|
|
547
|
+
* @param {object} entry - the stored entry (already checked to be this form's)
|
|
548
|
+
* @returns {Promise<boolean>}
|
|
549
|
+
*/
|
|
550
|
+
export async function removeFormSubmission(slug, entry) {
|
|
551
|
+
const form = await readForm(slug);
|
|
552
|
+
const target = submissionsCollectionFor(form);
|
|
553
|
+
if (!isSubmissionOf(form, entry)) return false;
|
|
554
|
+
await deleteEntry(target, entry.id);
|
|
555
|
+
await removeSubmissionUploads(form, [entry]);
|
|
556
|
+
forgetStats(slug);
|
|
557
|
+
return true;
|
|
558
|
+
}
|
|
559
|
+
|
|
541
560
|
export function formsBadge(forms = [], now = Date.now()) {
|
|
542
561
|
const week = forms.reduce((n, f) => n + (f.stats?.week || 0), 0);
|
|
543
562
|
const today = forms.reduce((n, f) => n + (f.stats?.today || 0), 0);
|
|
@@ -1089,13 +1108,33 @@ export async function formsRoutes(fastify) {
|
|
|
1089
1108
|
}
|
|
1090
1109
|
} catch { /* anonymous submission */ }
|
|
1091
1110
|
|
|
1111
|
+
// A form shown in an admin panel (public/js/form-embed.js) carries the context a plugin signed for it
|
|
1112
|
+
// (services/formContext.js). It counts only from a request signed in by a Bearer token whose user the token
|
|
1113
|
+
// was signed for, on this form, before it expires - otherwise the submission is refused, never kept without it.
|
|
1114
|
+
// Nothing else the browser sends reaches the entry's meta: `_context` is not a field and is dropped.
|
|
1115
|
+
let context = null;
|
|
1116
|
+
const hasToken = body._context_token !== undefined && body._context_token !== '';
|
|
1117
|
+
const contextToken = typeof body._context_token === 'string' ? body._context_token : '';
|
|
1118
|
+
delete body._context_token;
|
|
1119
|
+
delete body._context;
|
|
1120
|
+
if (hasToken && !contextToken) return reply.status(400).send({ error: 'This form cannot be sent from here.' });
|
|
1121
|
+
if (contextToken) {
|
|
1122
|
+
const bearer = /^Bearer\s+\S+/i.test(String(request.headers.authorization || ''));
|
|
1123
|
+
if (!bearer || !submittingUser) return reply.status(401).send({ error: 'Sign in again to send this form.' });
|
|
1124
|
+
const checked = verifyFormContext(contextToken, {form: slug, userId: submittingUser.id});
|
|
1125
|
+
if (checked.error === 'expired') return reply.status(400).send({ error: 'This form was open too long - close it and open it again.' });
|
|
1126
|
+
if (checked.error) return reply.status(403).send({ error: 'This form cannot be sent from here.' });
|
|
1127
|
+
context = checked.context;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1092
1130
|
// Honeypot check - silently accept if filled (bot detected)
|
|
1093
1131
|
if (settings.honeypot && body._hp) {
|
|
1094
1132
|
return { ok: true, message: settings.successMessage, redirect: settings.successRedirect || null };
|
|
1095
1133
|
}
|
|
1096
1134
|
|
|
1097
|
-
// Timing check - silently accept if submitted too fast (< 2 s, likely a bot)
|
|
1098
|
-
|
|
1135
|
+
// Timing check - silently accept if submitted too fast (< 2 s, likely a bot). Not for a signed-in admin-panel
|
|
1136
|
+
// post with a verified context: a person who answers quickly must not be told "sent" with nothing stored.
|
|
1137
|
+
if (settings.honeypot && body._t && !context) {
|
|
1099
1138
|
const elapsed = Date.now() - Number(body._t);
|
|
1100
1139
|
if (!Number.isNaN(elapsed) && elapsed < 2000) {
|
|
1101
1140
|
return {ok: true, message: settings.successMessage, redirect: settings.successRedirect || null};
|
|
@@ -1229,7 +1268,8 @@ export async function formsRoutes(fastify) {
|
|
|
1229
1268
|
source: `form:${slug}`,
|
|
1230
1269
|
createdBy: submittingUser?.id || null,
|
|
1231
1270
|
excused,
|
|
1232
|
-
outcome: ended ? {type: 'ended', trigger: ended.key, field: ended.field} : null
|
|
1271
|
+
outcome: ended ? {type: 'ended', trigger: ended.key, field: ended.field} : null,
|
|
1272
|
+
context
|
|
1233
1273
|
});
|
|
1234
1274
|
forgetStats(slug);
|
|
1235
1275
|
// What a visitor sent is theirs, not the site's content: keep it out of the site repo.
|
|
@@ -415,10 +415,11 @@ export async function getEntry(slug, entryId, opts = {}) {
|
|
|
415
415
|
* @param {string} [meta.source] - 'admin' | 'api' | 'import' | 'form:{slug}'
|
|
416
416
|
* @param {string[]} [meta.excused] - required fields this write may leave empty (see validateEntryData)
|
|
417
417
|
* @param {object} [meta.outcome] - how a form submission ended, stored as meta.outcome
|
|
418
|
+
* @param {object} [meta.context] - a form submission's server-verified context (services/formContext.js), stored as meta.context
|
|
418
419
|
* @returns {Promise<object>} Created entry
|
|
419
420
|
* @throws {Error} If validation fails or collection not found
|
|
420
421
|
*/
|
|
421
|
-
export async function createEntry(slug, data, { createdBy = null, source = 'admin', excused = [], outcome = null } = {}) {
|
|
422
|
+
export async function createEntry(slug, data, { createdBy = null, source = 'admin', excused = [], outcome = null, context = null } = {}) {
|
|
422
423
|
const schema = await getCollection(slug);
|
|
423
424
|
if (!schema) throw new Error(`Collection "${slug}" not found`);
|
|
424
425
|
data = typedEntryData(schema, data);
|
|
@@ -433,7 +434,7 @@ export async function createEntry(slug, data, { createdBy = null, source = 'admi
|
|
|
433
434
|
const entry = {
|
|
434
435
|
id: uuidv4(),
|
|
435
436
|
data,
|
|
436
|
-
meta: { createdAt: now, updatedAt: now, createdBy, source, ...(outcome && {outcome}) }
|
|
437
|
+
meta: { createdAt: now, updatedAt: now, createdBy, source, ...(outcome && {outcome}), ...(context && {context}) }
|
|
437
438
|
};
|
|
438
439
|
|
|
439
440
|
const adapter = await getAdapter(slug);
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Forms in admin panels - the context a submission is made in, signed by the server, and the entry read back.
|
|
3
|
+
*
|
|
4
|
+
* A plugin shows a Domma Form inside one of its admin panels (public/js/form-embed.js `renderForm`) - the Job Board's
|
|
5
|
+
* right-to-represent step, for example - and needs to know, afterwards, that a given entry was made by THIS user, on
|
|
6
|
+
* THAT form, for THIS record of its own. The browser cannot be trusted with that, so:
|
|
7
|
+
*
|
|
8
|
+
* 1. The plugin's own route signs the context: `signFormContext({form, userId, context})` -> an opaque token
|
|
9
|
+
* (HMAC-SHA256, keyed from JWT_SECRET, domain-separated; expires after `ttlMs`, 30 minutes by default). Signed, NOT
|
|
10
|
+
* secret: the context is base64 JSON the browser can read - never put anything private in it. It can be used more
|
|
11
|
+
* than once while it lasts (each entry carries the same user and context), so a plugin decides which entry counts
|
|
12
|
+
* (the one it is handed and checks, once).
|
|
13
|
+
* 2. The panel renders the form with that token and posts the answers with the user's Bearer token.
|
|
14
|
+
* 3. POST /api/forms/submit/:slug (routes/api/forms.js) accepts a `_context_token` only from a request signed in
|
|
15
|
+
* by an Authorization: Bearer token (never a cookie) whose user is the token's user, for the token's form, before
|
|
16
|
+
* it expires. The verified context is stored as the entry's `meta.context`; nothing the browser sends otherwise
|
|
17
|
+
* reaches `meta` (`_context` is dropped). A bad token refuses the whole submission (400/401/403).
|
|
18
|
+
* An entry edited afterwards (by someone with update rights on the collection) keeps its meta: a plugin that must
|
|
19
|
+
* know the answers are as sent compares `meta.updatedAt` with `meta.createdAt`, or keeps its own copy.
|
|
20
|
+
* 4. The plugin reads the entry back with `readFormEntry(form, entryId)` and checks `meta.createdBy` and
|
|
21
|
+
* `meta.context` against its own records; `removeFormEntry` deletes one and `formEntriesBy` lists one user's
|
|
22
|
+
* (a person's data being erased - also the entries they sent but never used).
|
|
23
|
+
*
|
|
24
|
+
* Context: up to 20 keys (`/^[a-z][a-z0-9_-]{0,39}$/i`), each a string, number or boolean (strings up to 200
|
|
25
|
+
* characters). Anything else is refused when signing.
|
|
26
|
+
*
|
|
27
|
+
* @module services/formContext
|
|
28
|
+
*/
|
|
29
|
+
import crypto from 'node:crypto';
|
|
30
|
+
import {readForm} from './forms.js';
|
|
31
|
+
import {getEntry, listEntries} from './collections.js';
|
|
32
|
+
// The forms route's own delete (its uploads and the submission counts go with it). A call-time import: the route imports
|
|
33
|
+
// this module too.
|
|
34
|
+
import {removeFormSubmission} from '../routes/api/forms.js';
|
|
35
|
+
|
|
36
|
+
const TTL_MS = 30 * 60_000;
|
|
37
|
+
const KEY_RE = /^[a-z][a-z0-9_-]{0,39}$/i;
|
|
38
|
+
const SLUG_RE = /^[a-z0-9][a-z0-9-]{0,99}$/;
|
|
39
|
+
const MAX_KEYS = 20;
|
|
40
|
+
/** The longest token signing can make (20 keys of 200 characters, JSON-escaped, base64) is well under this. */
|
|
41
|
+
const MAX_TOKEN = 16000;
|
|
42
|
+
|
|
43
|
+
// Keyed from JWT_SECRET (domain-separated: a context token is never a session token), else per process (tests).
|
|
44
|
+
const KEY = process.env.JWT_SECRET ? `domma-form-context:${process.env.JWT_SECRET}` : crypto.randomBytes(32).toString('hex');
|
|
45
|
+
const mac = (s) => crypto.createHmac('sha256', KEY).update(s).digest('base64url');
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A context as it may be stored: plain keys, scalar values. null when anything is out of shape.
|
|
49
|
+
*
|
|
50
|
+
* @param {object} context
|
|
51
|
+
* @returns {object|null}
|
|
52
|
+
*/
|
|
53
|
+
export function cleanContext(context) {
|
|
54
|
+
if (!context || typeof context !== 'object' || Array.isArray(context)) return null;
|
|
55
|
+
const entries = Object.entries(context);
|
|
56
|
+
if (entries.length > MAX_KEYS) return null;
|
|
57
|
+
const out = {};
|
|
58
|
+
for (const [k, v] of entries) {
|
|
59
|
+
if (!KEY_RE.test(k)) return null;
|
|
60
|
+
if (typeof v === 'string') { if (v.length > 200) return null; out[k] = v; }
|
|
61
|
+
else if (typeof v === 'boolean' || (typeof v === 'number' && Number.isFinite(v))) out[k] = v;
|
|
62
|
+
else return null;
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Sign a context for one user submitting one form. Server side only - a plugin's route calls it for the signed-in
|
|
69
|
+
* user it is answering.
|
|
70
|
+
*
|
|
71
|
+
* @param {{form: string, userId: string, context: object, ttlMs?: number, now?: number}} o
|
|
72
|
+
* @returns {string} the token
|
|
73
|
+
* @throws {Error} on a bad form slug, user or context
|
|
74
|
+
*/
|
|
75
|
+
export function signFormContext({form, userId, context, ttlMs = TTL_MS, now = Date.now()}) {
|
|
76
|
+
if (!SLUG_RE.test(String(form || ''))) throw new Error('signFormContext: a form slug is required');
|
|
77
|
+
if (!userId || typeof userId !== 'string') throw new Error('signFormContext: the user is required');
|
|
78
|
+
const ctx = cleanContext(context);
|
|
79
|
+
if (!ctx) throw new Error('signFormContext: the context must be up to 20 plain keys with string, number or boolean values');
|
|
80
|
+
const body = Buffer.from(JSON.stringify({f: form, u: userId, c: ctx, x: now + Math.max(1000, Math.min(Number(ttlMs) || TTL_MS, 24 * 3600_000))}))
|
|
81
|
+
.toString('base64url');
|
|
82
|
+
return `${body}.${mac(body)}`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The context a token carries, if it was signed here, is for this form and this user, and has not expired.
|
|
87
|
+
*
|
|
88
|
+
* @param {string} token
|
|
89
|
+
* @param {{form: string, userId: string, now?: number}} o
|
|
90
|
+
* @returns {{context?: object, error?: string}}
|
|
91
|
+
*/
|
|
92
|
+
export function verifyFormContext(token, {form, userId, now = Date.now()}) {
|
|
93
|
+
const s = String(token || '');
|
|
94
|
+
const dot = s.lastIndexOf('.');
|
|
95
|
+
if (dot < 1 || s.length > MAX_TOKEN) return {error: 'bad'};
|
|
96
|
+
const body = s.slice(0, dot);
|
|
97
|
+
const sig = Buffer.from(s.slice(dot + 1));
|
|
98
|
+
const want = Buffer.from(mac(body));
|
|
99
|
+
if (sig.length !== want.length || !crypto.timingSafeEqual(sig, want)) return {error: 'bad'};
|
|
100
|
+
let p;
|
|
101
|
+
try { p = JSON.parse(Buffer.from(body, 'base64url').toString('utf8')); } catch { return {error: 'bad'}; }
|
|
102
|
+
if (p?.f !== form) return {error: 'form'};
|
|
103
|
+
if (!userId || p?.u !== userId) return {error: 'user'};
|
|
104
|
+
if (!(Number(p?.x) > now)) return {error: 'expired'};
|
|
105
|
+
const context = cleanContext(p.c);
|
|
106
|
+
return context ? {context} : {error: 'bad'};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** The collection a form's submissions are stored in (its own, or the one its collection action names). */
|
|
110
|
+
async function targetOf(form) {
|
|
111
|
+
const def = await readForm(form);
|
|
112
|
+
const action = def?.actions?.collection;
|
|
113
|
+
return action?.enabled && action.slug ? action.slug : form;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* One entry of a form, as stored - for a plugin checking what was submitted. null when the form or entry does not
|
|
118
|
+
* exist, or the entry was not made through this form.
|
|
119
|
+
*
|
|
120
|
+
* @param {string} form
|
|
121
|
+
* @param {string} entryId
|
|
122
|
+
* @returns {Promise<{id: string, data: object, meta: object}|null>}
|
|
123
|
+
*/
|
|
124
|
+
export async function readFormEntry(form, entryId) {
|
|
125
|
+
if (!SLUG_RE.test(String(form || '')) || !/^[\w-]{1,100}$/.test(String(entryId || ''))) return null;
|
|
126
|
+
try {
|
|
127
|
+
const entry = await getEntry(await targetOf(form), entryId);
|
|
128
|
+
return entry && entry.meta?.source === `form:${form}` ? entry : null;
|
|
129
|
+
} catch {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Delete one entry of a form (a person's data being erased). True when it was there and is gone.
|
|
136
|
+
*
|
|
137
|
+
* @param {string} form
|
|
138
|
+
* @param {string} entryId
|
|
139
|
+
* @returns {Promise<boolean>}
|
|
140
|
+
*/
|
|
141
|
+
export async function removeFormEntry(form, entryId) {
|
|
142
|
+
const entry = await readFormEntry(form, entryId);
|
|
143
|
+
if (!entry) return false;
|
|
144
|
+
try {
|
|
145
|
+
return await removeFormSubmission(form, entry);
|
|
146
|
+
} catch {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Every entry one signed-in user made through this form (`meta.createdBy`) - for erasing a person's data.
|
|
153
|
+
*
|
|
154
|
+
* @param {string} form
|
|
155
|
+
* @param {string} userId
|
|
156
|
+
* @returns {Promise<object[]>}
|
|
157
|
+
*/
|
|
158
|
+
export async function formEntriesBy(form, userId) {
|
|
159
|
+
if (!SLUG_RE.test(String(form || '')) || !userId) return [];
|
|
160
|
+
try {
|
|
161
|
+
const {entries = []} = await listEntries(await targetOf(form), {limit: 0});
|
|
162
|
+
return entries.filter(e => e.meta?.createdBy === userId && e.meta?.source === `form:${form}`);
|
|
163
|
+
} catch {
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -2130,7 +2130,7 @@ function markedBody(md) {
|
|
|
2130
2130
|
* @param {string} markdown
|
|
2131
2131
|
* @returns {string}
|
|
2132
2132
|
*/
|
|
2133
|
-
async function processPluginShortcodes(markdown) {
|
|
2133
|
+
async function processPluginShortcodes(markdown, user = null) {
|
|
2134
2134
|
const processors = getShortcodeProcessors();
|
|
2135
2135
|
if (!processors.length) return markdown;
|
|
2136
2136
|
|
|
@@ -2138,7 +2138,7 @@ async function processPluginShortcodes(markdown) {
|
|
|
2138
2138
|
let result = scrubbed;
|
|
2139
2139
|
// renderMap tells a plugin with its own [map] (Blog Pro: OpenStreetMap by lat/lon) that the CMS has one too, so it can
|
|
2140
2140
|
// hand back the tags it cannot draw (an address, a postcode) for processMapBlocks.
|
|
2141
|
-
const context = {parseShortcodeAttrs, scrubCodeRegions, marked, processCardBlocks, processGridBlocks, escapeAttr, renderMap};
|
|
2141
|
+
const context = {parseShortcodeAttrs, scrubCodeRegions, marked, processCardBlocks, processGridBlocks, escapeAttr, renderMap, user};
|
|
2142
2142
|
|
|
2143
2143
|
async function replaceAsync(input, regex, mapMatch) {
|
|
2144
2144
|
const matches = [];
|
|
@@ -5443,7 +5443,7 @@ export async function parseMarkdown(raw, opts = {}) {
|
|
|
5443
5443
|
const withMenu = await processMenuBlocks(withStaticBlock, opts.user || null, menuCtx);
|
|
5444
5444
|
const withDconfig = processDConfigBlocks(withMenu);
|
|
5445
5445
|
const withEffects = processEffectsBlocks(withDconfig);
|
|
5446
|
-
const withPluginShortcodes = await processPluginShortcodes(withEffects);
|
|
5446
|
+
const withPluginShortcodes = await processPluginShortcodes(withEffects, opts.user || null);
|
|
5447
5447
|
const withTabs = processTabsBlocks(withPluginShortcodes);
|
|
5448
5448
|
const withAccordion = processAccordionBlocks(withTabs);
|
|
5449
5449
|
const withCarousel = processCarouselBlocks(withAccordion);
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
<script src="/public/js/form-logic-engine.js?v=20261031-forms-reduce-motion" defer></script>
|
|
189
189
|
|
|
190
190
|
<!-- Site initialisation -->
|
|
191
|
-
<script src="/public/js/site.js?v=
|
|
191
|
+
<script src="/public/js/site.js?v=20261109-form-embed" type="module"></script>
|
|
192
192
|
<script src="/public/js/collection-context.js?v=20261010-utf8-payloads" type="module"></script>
|
|
193
193
|
{{ctxMenusModule}}
|
|
194
194
|
<!-- [image zoom] pictures' full-size view - only on a page that has one -->
|
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
<script src="/public/js/menu-float.js?v=20260927-float" type="module"></script>
|
|
201
201
|
|
|
202
202
|
<!-- Core Forms renderer -->
|
|
203
|
-
<script src="/public/js/forms.js?v=
|
|
203
|
+
<script src="/public/js/forms.js?v=20261109-form-embed" type="module"></script>
|
|
204
204
|
|
|
205
205
|
<!-- Core effects runtime -->
|
|
206
206
|
<script src="/public/js/effects.js?v=20261029-all-cms-fonts" defer></script>
|