domma-cms 1.32.0 → 1.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/CLAUDE.md +1 -1
  3. package/admin/js/lib/admin-brand.js +1 -1
  4. package/admin/js/lib/admin-theme.js +1 -1
  5. package/admin/js/lib/shortcode-context-menu.js +2 -2
  6. package/admin/js/lib/shortcode-registry.js +1 -1
  7. package/admin/js/lib/sidebar-frequent.js +1 -1
  8. package/admin/js/lib/sidebar-notify.js +1 -1
  9. package/admin/js/lib/sidebar-renderer.js +4 -4
  10. package/admin/js/lib/site-settings-arrange.js +2 -2
  11. package/admin/js/lib/theme-aware-logo.js +1 -0
  12. package/admin/js/templates/settings.html +7 -1
  13. package/admin/js/views/settings.js +2 -2
  14. package/docs/markdown-shortcodes.md +13 -0
  15. package/docs/starter-blocks.md +37 -1
  16. package/package.json +1 -1
  17. package/plugins/_lib/admin/mail/body-menu.js +1 -1
  18. package/plugins/_lib/admin/mail/cms-host.js +1 -1
  19. package/plugins/_lib/admin/mail/compose-window.js +1 -1
  20. package/plugins/_lib/admin/mail/contacts.js +1 -1
  21. package/plugins/_lib/admin/mail/diagnostics-section.js +1 -1
  22. package/plugins/_lib/admin/mail/drag-drop.js +1 -1
  23. package/plugins/_lib/admin/mail/folder-tree.js +1 -1
  24. package/plugins/_lib/admin/mail/font-controls.js +1 -1
  25. package/plugins/_lib/admin/mail/fonts.js +1 -1
  26. package/plugins/_lib/admin/mail/host-context.js +1 -1
  27. package/plugins/_lib/admin/mail/identity.js +1 -1
  28. package/plugins/_lib/admin/mail/image-senders-section.js +1 -1
  29. package/plugins/_lib/admin/mail/keyboard.js +1 -1
  30. package/plugins/_lib/admin/mail/mail.html +1 -1
  31. package/plugins/_lib/admin/mail/message-actions.js +1 -1
  32. package/plugins/_lib/admin/mail/oauth-panel.js +1 -1
  33. package/plugins/_lib/admin/mail/panes.js +1 -1
  34. package/plugins/_lib/admin/mail/reader-kit.js +1 -1
  35. package/plugins/_lib/admin/mail/reader-runtime.js +2 -1
  36. package/plugins/_lib/admin/mail/reader-view.js +1 -1
  37. package/plugins/_lib/admin/mail/resizable.js +1 -1
  38. package/plugins/_lib/admin/mail/restore-spam.js +1 -1
  39. package/plugins/_lib/admin/mail/rules.js +1 -1
  40. package/plugins/_lib/admin/mail/scheduling.js +1 -1
  41. package/plugins/_lib/admin/mail/section-kit.js +1 -1
  42. package/plugins/_lib/admin/mail/security-note.js +1 -1
  43. package/plugins/_lib/admin/mail/settings-section.js +12 -4
  44. package/plugins/_lib/admin/mail/templates.js +1 -1
  45. package/plugins/_lib/admin/mail/threads.js +1 -1
  46. package/plugins/_lib/admin/mail/vacation.js +1 -1
  47. package/plugins/_lib/admin/mail/when-closed.js +1 -1
  48. package/plugins/_lib/admin/ui/dates.js +1 -1
  49. package/plugins/_lib/admin/ui/resizable.js +1 -1
  50. package/plugins/_lib/domma-mail.lock.json +80 -80
  51. package/plugins/_lib/mail/accountFileStore.js +1 -1
  52. package/plugins/_lib/mail/accountRepository.js +23 -2
  53. package/plugins/_lib/mail/accountRoutes.js +1 -1
  54. package/plugins/_lib/mail/accounts.js +1 -1
  55. package/plugins/_lib/mail/bodyTokenProvider.js +1 -1
  56. package/plugins/_lib/mail/bodyTokens.js +1 -1
  57. package/plugins/_lib/mail/compose.js +1 -1
  58. package/plugins/_lib/mail/defaults.js +1 -1
  59. package/plugins/_lib/mail/envelope.js +1 -1
  60. package/plugins/_lib/mail/folderActions.js +1 -1
  61. package/plugins/_lib/mail/folderRuntime.js +1 -1
  62. package/plugins/_lib/mail/folders.js +1 -1
  63. package/plugins/_lib/mail/imapPoolRuntime.js +1 -1
  64. package/plugins/_lib/mail/mbox.js +1 -1
  65. package/plugins/_lib/mail/message-action.js +1 -1
  66. package/plugins/_lib/mail/messageSecurity.js +1 -1
  67. package/plugins/_lib/mail/messageSecurityProvider.js +1 -1
  68. package/plugins/_lib/mail/networkAddresses.js +1 -1
  69. package/plugins/_lib/mail/networkPolicy.js +1 -1
  70. package/plugins/_lib/mail/oauthAccounts.js +1 -1
  71. package/plugins/_lib/mail/oauthRouteRuntime.js +1 -1
  72. package/plugins/_lib/mail/oauthRuntime.js +1 -1
  73. package/plugins/_lib/mail/pollSchedule.js +1 -1
  74. package/plugins/_lib/mail/poller.js +1 -1
  75. package/plugins/_lib/mail/pollerRuntime.js +1 -1
  76. package/plugins/_lib/mail/priority.js +1 -1
  77. package/plugins/_lib/mail/publicMailbox.js +1 -1
  78. package/plugins/_lib/mail/readRuntime.js +1 -1
  79. package/plugins/_lib/mail/render.js +1 -1
  80. package/plugins/_lib/mail/ruleRunner.js +1 -1
  81. package/plugins/_lib/mail/schedulerRuntime.js +1 -1
  82. package/plugins/_lib/mail/secretProvider.js +1 -1
  83. package/plugins/_lib/mail/secretbox.js +1 -1
  84. package/plugins/_lib/mail/senderAuth.js +1 -1
  85. package/plugins/_lib/mail/sieve.js +1 -1
  86. package/plugins/_lib/mail/smtpService.js +1 -1
  87. package/plugins/_lib/mail/snoozeRuntime.js +1 -1
  88. package/plugins/_lib/mail/store.js +1 -1
  89. package/plugins/_lib/mail/subscriptions.js +1 -1
  90. package/plugins/_lib/mail/syncPlan.js +1 -1
  91. package/plugins/_lib/mail/syncRuntime.js +1 -1
  92. package/plugins/_lib/mail/syncSelection.js +8 -3
  93. package/plugins/_lib/mail/unreadBadge.js +1 -1
  94. package/plugins/_lib/mail/unsubscribe.js +1 -1
  95. package/plugins/_lib/mail/vacationRuntime.js +1 -1
  96. package/plugins/_lib/mail/write.js +1 -1
  97. package/server/blocks/catalog.json +24 -0
  98. package/server/blocks/domma-block-comparison-card.css +20 -0
  99. package/server/blocks/domma-block-comparison-card.html +18 -0
  100. package/server/blocks/domma-block-comparison-card.meta.json +7 -0
  101. package/server/blocks/domma-block-cta-card.css +20 -0
  102. package/server/blocks/domma-block-cta-card.html +15 -0
  103. package/server/blocks/domma-block-cta-card.meta.json +7 -0
  104. package/server/blocks/domma-block-feature-card.css +20 -0
  105. package/server/blocks/domma-block-feature-card.html +15 -0
  106. package/server/blocks/domma-block-feature-card.meta.json +7 -0
  107. package/server/blocks/domma-block-image-card.css +20 -0
  108. package/server/blocks/domma-block-image-card.html +17 -0
  109. package/server/blocks/domma-block-image-card.meta.json +7 -0
  110. package/server/services/adminBrand.js +4 -1
  111. package/server/services/embedCsp.js +1 -1
  112. package/server/services/markdown.js +65 -6
  113. package/server/services/sidebarFrequent.js +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.34.0] - 2026-11-03
4
+
5
+ - Email Pro can notify for all folders or selected folders, with Check all and None controls in Email Settings. Folder choices are saved per mailbox and automatically included in background syncing. The sidebar badge continues to count Inbox unread messages. Folder notification marks are independent, including mailboxes with more than fifty folders.
6
+
7
+ ## [1.33.0] - 2026-11-03
8
+
9
+ - **`[map]`** - a responsive Google Map of one place: `[map postcode="SW1A 2AA" zoom="15" caption="Visit us" /]`, or `address`, `pin="lat,lon"`, `lat` + `lon`. Zoom 1-20, `lng` as well as `lon`, ratio, width, alignment and a caption; malformed coordinates show a notice rather than a broken map. Google's embed host is always allowed to frame, so no `config/embeds.json` entry is needed. In the shortcode menus under Media.
10
+ - **Admin logo for dark themes** (Site Settings > Branding): an optional second logo, shown in the top bar and the sidebar whenever the admin theme has a dark background, switching as the theme changes.
11
+ - **Tracking** in the page editor's shortcode menu: expiry, visitor and IP settings now sit in their own Tracking submenu instead of among each shortcode's options.
12
+ - **Four more free blocks**: feature card, comparison card, image card and call-to-action card (21 in the library). Existing sites receive them when they upgrade.
13
+ - **Frequent holds 16** places in the sidebar, up from 12.
14
+ - **A plugin's shortcode matches its own name only.** `[map-guess]` and `[map-guess-leaderboard]` were caught by any plugin registering `[map]` (Blog Pro), and `[map-guess-leaderboard]` by `[map-guess]` itself; a name now has to end at a space, `/` or `]`. The shortcode context passes `renderMap`, so a plugin with its own `[map]` can hand back the tags it cannot draw (Blog Pro 0.7.2 does).
15
+
3
16
  ## [1.32.0] - 2026-11-03
4
17
 
5
18
  - **Block packs.** Blocks > the package action: make a versioned pack from chosen blocks (with their pictures, schema 2), export it as a `.dmblockpack.json` file, import one, and install it after a preview that lists every block it adds or changes. A block edited here since a pack put it there, or one of the same name the pack did not make, stops the install rather than being overwritten. Each install is kept, so the last one can be rolled back while nothing has been edited since. Two starter packs (Domma Base Block Pack, Domma cards) come with every site. The Manager can preview and install a pack on chosen sites.
package/CLAUDE.md CHANGED
@@ -68,7 +68,7 @@ Processing order (`parseMarkdown()` in `server/services/markdown.js`; earlier st
68
68
  3. `[dconfig]`
69
69
  4. Effects shortcodes, then plugin shortcodes
70
70
  5. `[tabs]`, `[accordion]`, `[carousel]`, `[countdown]`, `[timeline]`, `[listgroup]`, `[spacer]`, `[center]`, `[icon]`,
71
- `[demo]`, `[embed]`, `[image]`, `[form]`, `[hero]`, `[table]`
71
+ `[demo]`, `[embed]`, `[map]`, `[image]`, `[form]`, `[hero]`, `[table]`
72
72
  6. Inline tags: `[badge]`, `[text]`, `[button]`, `[link]`, `[cta]`
73
73
  7. `[grid]` / `[row]` / `[col]`
74
74
  8. `[card]` (and `[box]` - a headerless card, handled at the top of `processCardBlocks`)
@@ -1 +1 @@
1
- export const PRODUCT_NAME="Domma CMS";let t=null,f="",s=null,d=null;export function currentAdminBrand(){return t}export function brandedTabTitle(e,a,r=""){const o=i=>String(i||"").replace(/[ \t\n\f\r]+/g," ").trim(),n=o(a?.title),l=o(e);if(a?.enabled===!1){const i=[n,o(r),PRODUCT_NAME].filter(c=>c&&(l===c||l.endsWith(` - ${c}`))).sort((c,h)=>h.length-c.length)[0];return i?l===i?"Admin":l.slice(0,-i.length-3):String(e||"")}if(!n)return String(e||"");const b=i=>i&&(l===i||l.endsWith(` - ${i}`)),u=[n,o(r),PRODUCT_NAME].filter(b).sort((i,c)=>c.length-i.length)[0];return!u||u===n?String(e||""):l===u?n:l.slice(0,-u.length)+n}export function applyAdminBrand(e){const a=e&&(e.title||e.enabled===!1)?e:{title:PRODUCT_NAME};t?.enabled===!1&&a.enabled!==!1&&document.title===s&&d&&(document.title=d,s=null),t&&(t.title!==a.title||t.enabled===!1!=(a.enabled===!1))&&(f=t.title,s=null),t=a;const r=document.querySelector("#admin-topbar .topbar-brand");if(r&&(r.hidden=t.enabled===!1),r&&t.enabled===!1&&r.replaceChildren(),r&&t.enabled!==!1){const o=String(t.logo||"");let n;/^(?:\/(?!\/)|https?:\/\/)/i.test(o)?(n=document.createElement("img"),n.src=o,n.alt="",n.className="topbar-brand-logo"):(n=document.createElement("span"),n.setAttribute("data-icon",t.icon||"layout"));const l=document.createElement("span");l.className="topbar-brand-text",l.textContent=t.title,r.replaceChildren(n,l);try{I.scan(r)}catch{}}p(),retitleTab()}export function retitleTab(){if(!t||s!==null&&document.title===s)return;const e=brandedTabTitle(document.title,t,f);e!==document.title&&(t.enabled===!1&&(d=document.title),document.title=e,s=document.title)}let m=!1;function p(){if(m||typeof MutationObserver>"u")return;let e=document.querySelector("head > title");e||(e=document.createElement("title"),document.head.appendChild(e)),new MutationObserver(retitleTab).observe(e,{childList:!0,characterData:!0,subtree:!0}),m=!0}
1
+ import{syncThemeAwareLogos as b}from"./theme-aware-logo.js";export const PRODUCT_NAME="Domma CMS";let e=null,m="",d=null,f=null;export function currentAdminBrand(){return e}export function brandedTabTitle(t,c,o=""){const a=n=>String(n||"").replace(/[ \t\n\f\r]+/g," ").trim(),r=a(c?.title),i=a(t);if(c?.enabled===!1){const n=[r,a(o),PRODUCT_NAME].filter(s=>s&&(i===s||i.endsWith(` - ${s}`))).sort((s,h)=>h.length-s.length)[0];return n?i===n?"Admin":i.slice(0,-n.length-3):String(t||"")}if(!r)return String(t||"");const u=n=>n&&(i===n||i.endsWith(` - ${n}`)),l=[r,a(o),PRODUCT_NAME].filter(u).sort((n,s)=>s.length-n.length)[0];return!l||l===r?String(t||""):i===l?r:i.slice(0,-l.length)+r}export function applyAdminBrand(t){const c=t&&(t.title||t.enabled===!1)?t:{title:PRODUCT_NAME};e?.enabled===!1&&c.enabled!==!1&&document.title===d&&f&&(document.title=f,d=null),e&&(e.title!==c.title||e.enabled===!1!=(c.enabled===!1))&&(m=e.title,d=null),e=c;const o=document.querySelector("#admin-topbar .topbar-brand");if(o&&(o.hidden=e.enabled===!1),o&&e.enabled===!1&&o.replaceChildren(),o&&e.enabled!==!1){const a=String(e.logo||""),r=String(e.logoDark||""),i=/^(?:\/(?!\/)|https?:\/\/)/i.test(a),u=/^(?:\/(?!\/)|https?:\/\/)/i.test(r);let l;i||u?(l=document.createElement("img"),l.src=i?a:r,i&&(l.dataset.logoLight=a),u&&(l.dataset.logoDark=r),l.alt="",l.className="topbar-brand-logo"):(l=document.createElement("span"),l.setAttribute("data-icon",e.icon||"layout"));const n=document.createElement("span");n.className="topbar-brand-text",n.textContent=e.title,o.replaceChildren(l,n);try{I.scan(o)}catch{}b(o)}p(),retitleTab()}export function retitleTab(){if(!e||d!==null&&document.title===d)return;const t=brandedTabTitle(document.title,e,m);t!==document.title&&(e.enabled===!1&&(f=document.title),document.title=t,d=document.title)}let g=!1;function p(){if(g||typeof MutationObserver>"u")return;let t=document.querySelector("head > title");t||(t=document.createElement("title"),document.head.appendChild(t)),new MutationObserver(retitleTab).observe(t,{childList:!0,characterData:!0,subtree:!0}),g=!0}
@@ -1 +1 @@
1
- import{fontFamilyValue as i,fontStylesheetHref as r,isFontStylesheet as f}from"../../../public/js/font-families.mjs?v=20261029-cms-fonts";const a="dm-custom-themes";function y(e={}){const s=(c,d)=>{let m=document.getElementById(c);if(!d){m?.remove();return}m||(m=document.createElement("link"),m.id=c,m.rel="stylesheet",document.head.appendChild(m)),m.href=d},t=f(e.stylesheet)?e.stylesheet:"";s("dm-licensed-fonts",t);const o=r(e.family,{stylesheet:t});s("dm-admin-font-link",o===t?"":o);let n=document.getElementById("dm-admin-font");if(!e.family){n?.remove();return}n||(n=document.createElement("style"),n.id="dm-admin-font",document.head.appendChild(n));const l=i(e.family);n.textContent=`body[class] { --dm-font-sans: ${l}; font-family: var(--dm-font-sans); }`}export function applyAdminTheme(e){const s=e?.dommaTheme||"charcoal-dark";Domma.theme.init({theme:s,persist:!1,target:document.body});let t=document.getElementById(a);e?.css?(t||(t=document.createElement("style"),t.id=a,document.head.appendChild(t)),t.textContent=e.css):t&&t.remove();const o=document.body;for(const n of[...o.classList])n.startsWith("dm-custom-")&&o.classList.remove(n);e?.customClass&&o.classList.add(e.customClass),y(e?.font)}export async function refreshAdminTheme(e,s={}){try{applyAdminTheme(await e.theme.admin(),s)}catch{applyAdminTheme({dommaTheme:"charcoal-dark"},s)}}
1
+ import{fontFamilyValue as l,fontStylesheetHref as r,isFontStylesheet as f}from"../../../public/js/font-families.mjs?v=20261029-cms-fonts";import{syncThemeAwareLogos as y}from"./theme-aware-logo.js";const a="dm-custom-themes";function h(e={}){const s=(c,d)=>{let m=document.getElementById(c);if(!d){m?.remove();return}m||(m=document.createElement("link"),m.id=c,m.rel="stylesheet",document.head.appendChild(m)),m.href=d},t=f(e.stylesheet)?e.stylesheet:"";s("dm-licensed-fonts",t);const o=r(e.family,{stylesheet:t});s("dm-admin-font-link",o===t?"":o);let n=document.getElementById("dm-admin-font");if(!e.family){n?.remove();return}n||(n=document.createElement("style"),n.id="dm-admin-font",document.head.appendChild(n));const i=l(e.family);n.textContent=`body[class] { --dm-font-sans: ${i}; font-family: var(--dm-font-sans); }`}export function applyAdminTheme(e){const s=e?.dommaTheme||"charcoal-dark";Domma.theme.init({theme:s,persist:!1,target:document.body});let t=document.getElementById(a);e?.css?(t||(t=document.createElement("style"),t.id=a,document.head.appendChild(t)),t.textContent=e.css):t&&t.remove();const o=document.body;for(const n of[...o.classList])n.startsWith("dm-custom-")&&o.classList.remove(n);e?.customClass&&o.classList.add(e.customClass),y(),h(e?.font)}export async function refreshAdminTheme(e,s={}){try{applyAdminTheme(await e.theme.admin(),s)}catch{applyAdminTheme({dommaTheme:"charcoal-dark"},s)}}
@@ -1,3 +1,3 @@
1
- import{convertSelectionToBlock as Q}from"./selection-to-block.js";import{EDITOR_TOOLS as Z,SHORTCODES as R}from"./shortcode-registry.js";import{EFFECTS as _,CELEBRATION_THEMES as ee,getEffectAttrs as H}from"./effect-defs.js";import{boolState as te,boolValue as ne,findEnclosingShortcode as oe,setAttr as z,setAttrs as W,effectAttrKeys as se}from"./shortcode-tags.js";import{insertAtCursor as O,replaceRange as ie}from"./markdown-toolbar.js";import{clearLookupCache as ce,lookupOptions as ae}from"./shortcode-lookups.js";import{insertMenuGroups as le,insertShortcodeByName as j}from"./shortcode-insert.js";import{openShortcodeForm as M}from"./shortcode-form.js";import{pickMedia as re}from"./media-picker.js";import{blockTagSnippet as de}from"./block-tags.js";import{catalogueNow as pe,dommaHelp as me}from"./domma-catalogue.js";function ue(e){return ae(e,l?.span?.attrs||{})}const fe=R.map(e=>({name:e.name,selfClosing:e.name==="block"?!1:!!e.selfClosing})),F=new Map(R.map(e=>[e.name,e])),B=new Map(_.map(e=>[e.name,e])),he=_.map(e=>({name:e.name,selfClosing:!!e.selfClosing})),be=[...fe,...he],Y=new Set(["card","box","hero","banner","col","button"]);let l=null;const q="position:fixed;z-index:10000;min-width:210px;max-height:70vh;overflow-y:auto;background:var(--dm-surface,#1c1c30);border:1px solid var(--dm-border,#2a2a40);border-radius:6px;box-shadow:var(--dm-shadow-lg);padding:.3rem;font-size:.83rem;color:var(--dm-text,#e5e5e5);",u="display:flex;align-items:center;gap:.5rem;width:100%;text-align:left;padding:.35rem .55rem;border:none;background:transparent;color:inherit;border-radius:4px;cursor:pointer;font-size:.83rem;",k="padding:.3rem .55rem;color:var(--dm-text-muted,#8a8a9a);font-size:.68rem;text-transform:uppercase;letter-spacing:.06em;",P="flex:1;min-width:0;padding:.2rem .4rem;background:var(--dm-input-bg,#12121e);border:1px solid var(--dm-border,#333);border-radius:3px;color:var(--dm-text,#eee);font-size:.8rem;",xe="height:1px;background:var(--dm-border,#2a2a40);margin:.3rem .2rem;";function f(e){return e.addEventListener("mouseenter",()=>{e.style.background="var(--dm-primary,#4338ca)",e.style.color="var(--dm-primary-text,#fff)"}),e.addEventListener("mouseleave",()=>{e.style.background="transparent",e.style.color="inherit"}),e}export function attachContextMenu(e,{blocks:t=()=>[],openBlock:n=null}={}){const o=()=>{const i=t()||[],s=i.filter(a=>a.shortTag&&!F.has(a.name)&&!B.has(a.name));return{defs:i,specs:[...be,...s.map(a=>({name:a.name,selfClosing:a.selfClosing}))]}},c=(i,s)=>{p();const{defs:a,specs:r}=o();G(e,oe(e,r),i,s,a,n)};return typeof Domma>"u"||!Domma.elements?.contextMenu?(e.addEventListener("contextmenu",i=>{i.preventDefault(),c(i.clientX,i.clientY)}),null):Domma.elements.contextMenu(e,{inherit:!1,cursor:!1,render:i=>{c(i.x,i.y)}})}function p(){l&&(L(),l.root.remove(),document.removeEventListener("mousedown",U,!0),document.removeEventListener("keydown",V,!0),window.removeEventListener("scroll",K,!0),l=null)}const U=e=>{l&&!l.root.contains(e.target)&&!(l.submenu&&l.submenu.contains(e.target))&&p()},K=e=>{l&&!l.root.contains(e.target)&&!(l.submenu&&l.submenu.contains(e.target))&&p()},V=e=>{e.key==="Escape"&&p()};function G(e,t,n,o,c=[],i=null){ce();const s=document.createElement("div");s.className="dm-sc-menu",s.style.cssText=q,l={root:s,textarea:e,span:t,submenu:null,blocks:c,openBlock:i,keepEmpty:!1};const a=new Map(c.map(x=>[x.name,x])),r=t&&(F.get(t.name)||B.get(t.name)),d=t&&(r?t.name==="block"?a.get(String(t.attrs.template||"")):null:a.get(t.name)),b=t&&Y.has(t.name)?_.filter(x=>x.name in t.attrs):[];r&&ye(s,r),d&&Ee(s,d,!!r);for(const x of b)_e(s,x);(r||d||b.length)&&s.appendChild(S()),s.appendChild(C("Celebrations\u2026",()=>Se())),s.appendChild(C("Add effect\u2026",()=>$e())),s.appendChild(C("Insert\u2026",()=>Ae()));const m=e.selectionStart!==e.selectionEnd;if(m&&e.value.slice(e.selectionStart,e.selectionEnd).trim()){const x={start:e.selectionStart,end:e.selectionEnd,source:e.value},y=f(document.createElement("button"));y.type="button",y.style.cssText=u,y.textContent="Convert selection to Domma Block\u2026",y.addEventListener("click",()=>{p(),Q(e,x)}),s.appendChild(y)}(t||m)&&s.appendChild(C(m?"Wrap selection in\u2026":"Wrap in\u2026",()=>Ie())),c.length&&(s.appendChild(S()),s.appendChild(C("Add block\u2026",()=>Me()))),document.body.appendChild(s),J(s,n,o),document.addEventListener("mousedown",U,!0),document.addEventListener("keydown",V,!0),window.addEventListener("scroll",K,!0),window.I&&I.scan(s)}function S(){const e=document.createElement("div");return e.style.cssText=xe,e}function w(e){const t=document.createElement("div");return t.style.cssText=k,t.textContent=e,t}function ye(e,t){e.appendChild(w(`${t.label} options`));const n=f(document.createElement("button"));n.type="button",n.style.cssText=u,n.innerHTML='<span data-icon="edit" data-icon-size="13" style="display:inline-flex;align-items:center;"></span>',n.appendChild(document.createTextNode(`Edit ${t.label}\u2026`)),n.addEventListener("click",()=>{const{textarea:i,span:s}=l;p(),M(i,{...t,attrs:H(t,s.attrs)},{span:s})}),e.appendChild(n);for(const i of t.actions||[]){const s=f(document.createElement("button"));s.type="button",s.style.cssText=u,s.innerHTML=`<span data-icon="${i.icon||"zap"}" data-icon-size="13" style="display:inline-flex;align-items:center;"></span>`,s.appendChild(document.createTextNode(i.label)),s.addEventListener("click",()=>{const{textarea:a,span:r}=l;if(i.remove){ie(a,r.openTagStart,r.openTagEnd,""),p();return}l.span=W(a,r,i.set||{}),p()}),e.appendChild(s)}const o=Array.isArray(t.quickAttrs)?new Set(t.quickAttrs):null,c=H(t,l.span.attrs).filter(i=>!o||o.has(i.name));(t.actions||[]).length&&c.length&&e.appendChild(S());for(const i of c)e.appendChild(D(i))}function Ee(e,t,n){const{span:o}=l;if(l.keepEmpty=!0,n&&e.appendChild(S()),e.appendChild(w(n?`${t.name} parameters`:`${t.name} block`)),t.description&&!n){const s=document.createElement("div");s.style.cssText="padding:0 .55rem .3rem;font-size:.75rem;color:var(--dm-text-muted,#9a9aac);max-width:260px;",s.textContent=t.description,e.appendChild(s)}const c=(s,a,r)=>{const d=f(document.createElement("button"));d.type="button",d.style.cssText=u,d.innerHTML=`<span data-icon="${s}" data-icon-size="13" style="display:inline-flex;align-items:center;"></span>`,d.appendChild(document.createTextNode(a)),d.addEventListener("click",r),e.appendChild(d)};t.attrs.length&&c("edit","Edit parameters\u2026",()=>{const{textarea:s}=l;p(),M(s,{...t,name:o.name,label:t.name},{span:o})});const{openBlock:i}=l;c(i?"layout":"external-link",i?"Edit the block":"Open the block",()=>{p(),i?i(t.name):location.hash=`#/blocks/edit/${encodeURIComponent(t.name)}`});for(const s of t.attrs)e.appendChild(D(s));if(!t.attrs.length){const s=document.createElement("div");s.style.cssText=k+"text-transform:none;letter-spacing:0;",s.textContent="This block takes no parameters.",e.appendChild(s)}}function D(e,t=e.name){const n=Ce(e,t),o=e.domma?me(pe(),e):"";return o&&n&&!n.title&&(n.title=o),n}function Ce(e,t){const n=l.span.attrs[t];switch(e.type){case"checkbox":return ge(e,t,te(n,e.default));case"select":return Te(e,t,n);case"lookup":return Le(e,t,n);case"colour":return we(e,t,n);case"icon":return ke(e,t,n);default:return ve(e,t,n)}}function T(e,t){if(l.span=z(l.textarea,l.span,e,l.keepEmpty&&t==null?"":t,{keepEmpty:l.keepEmpty}),e==="theme"){const{textarea:n,span:o,root:c}=l,i=c.getBoundingClientRect(),{blocks:s,openBlock:a}=l;p(),G(n,o,i.left,i.top,s,a)}}function ge(e,t,n){const o=f(document.createElement("label"));o.style.cssText=u;const c=document.createElement("input");return c.type="checkbox",c.checked=n,c.addEventListener("change",()=>T(t,ne(e,c.checked))),o.appendChild(c),o.appendChild(document.createTextNode(e.label)),o}function ve(e,t,n){const o=document.createElement("div");o.style.cssText=u+"cursor:default;";const c=document.createElement("span");c.textContent=e.label,c.style.cssText="white-space:nowrap;color:var(--dm-text-muted,#9a9aac);";const i=document.createElement("input");i.type=e.type==="number"?"number":"text",i.value=n===!0||n==null?"":n,e.default!=null&&e.default!==""&&(i.placeholder=String(e.default)),i.style.cssText=P;let s=null;if(i.addEventListener("input",()=>{clearTimeout(s),s=setTimeout(()=>T(t,i.value.trim()),180)}),i.addEventListener("mousedown",a=>a.stopPropagation()),o.appendChild(c),o.appendChild(i),e.type==="image"){const a=document.createElement("button");a.type="button",a.textContent="Browse",a.title="Choose from Media",a.style.cssText="padding:2px 8px;background:transparent;border:1px solid var(--dm-border,#333);border-radius:4px;color:inherit;cursor:pointer;flex-shrink:0;font:inherit;",a.addEventListener("mousedown",r=>r.stopPropagation()),a.addEventListener("click",async()=>{const{textarea:r,span:d}=l;p();const b=await re({current:i.value.trim()});b&&r.isConnected&&z(r,d,t,b)}),o.appendChild(a)}return o}function we(e,t,n){const o=document.createElement("div");o.style.cssText=u+"cursor:default;";const c=document.createElement("span");c.textContent=e.label,c.style.flex="1";const i=document.createElement("input");return i.type="color",typeof n=="string"&&/^#/.test(n)?i.value=n:typeof e.default=="string"&&/^#/.test(e.default)&&(i.value=e.default),i.addEventListener("input",()=>T(t,i.value)),o.appendChild(c),o.appendChild(i),o}function Te(e,t,n){const o=n==null||n===!0?e.default??"":n;return C(`${e.label}${o!==""?`: ${o}`:""}`,()=>{const c=g();for(const[i,s]of e.options||[]){const a=f(document.createElement("button"));a.type="button",a.style.cssText=u,a.textContent=s,i===o&&(a.style.fontWeight="700"),a.addEventListener("click",()=>{T(t,i),L()}),c.appendChild(a)}return c})}function ke(e,t,n){const o=n==null||n===!0?"":String(n),c=o?`${e.label}: ${o}`:e.label;return C(c,()=>{const i=g();i.style.width="232px";const s=document.createElement("input");s.type="text",s.placeholder="Search icons\u2026",s.style.cssText=P+"margin:6px;width:calc(100% - 12px);",s.addEventListener("mousedown",x=>x.stopPropagation()),i.appendChild(s);const a=f(document.createElement("button"));a.type="button",a.style.cssText=u,a.textContent="- none -",o||(a.style.fontWeight="700"),a.addEventListener("click",()=>{T(t,null),L()}),i.appendChild(a);const r=document.createElement("div");r.style.cssText="display:flex;flex-wrap:wrap;gap:2px;padding:4px 6px;max-height:220px;overflow-y:auto;",i.appendChild(r);const d=96,b=()=>{const x=typeof I<"u"&&typeof I.list=="function"?I.list():[],y=s.value.trim().toLowerCase(),$=y?x.filter(h=>h.toLowerCase().includes(y)):x;r.replaceChildren();for(const h of $.slice(0,d)){const v=f(document.createElement("button"));v.type="button",v.title=h,v.style.cssText="width:26px;height:26px;display:inline-flex;align-items:center;justify-content:center;background:none;border:1px solid transparent;border-radius:4px;cursor:pointer;color:inherit;",h===o&&(v.style.borderColor="var(--dm-primary,#5b8cff)");const A=document.createElement("span");A.setAttribute("data-icon",h),A.setAttribute("data-icon-size","15"),A.style.cssText="display:inline-flex;align-items:center;",v.appendChild(A),v.addEventListener("click",()=>{T(t,h),L()}),r.appendChild(v)}if($.length>d){const h=document.createElement("div");h.style.cssText=k,h.textContent=`${$.length-d} more - refine search`,r.appendChild(h)}if(!$.length){const h=document.createElement("div");h.style.cssText=k,h.textContent="No icons match",r.appendChild(h)}window.I&&I.scan(r)};let m=null;return s.addEventListener("input",()=>{clearTimeout(m),m=setTimeout(b,120)}),b(),setTimeout(()=>s.focus(),0),i})}function Le(e,t,n){const o=n==null||n===!0?e.default??"":n;return C(`${e.label}${o!==""?`: ${o}`:""}`,()=>{const c=g();c.style.minHeight="48px";const i=typeof E<"u"&&E.loader?E.loader(c,{type:"dots"}):null;return ue(e.source).then(s=>{if(i&&i.destroy(),!l||l.submenu!==c)return;if(c.style.minHeight="",!s.length){const d=document.createElement("div");d.style.cssText=k,d.textContent="Nothing found",c.appendChild(d)}const a=s.some(([d])=>d===o),r=[["","- none -"],...s];o!==""&&!a&&r.push([o,`${o} (missing)`]);for(const[d,b]of r){const m=f(document.createElement("button"));m.type="button",m.style.cssText=u,m.textContent=b,d===o&&(m.style.fontWeight="700"),m.addEventListener("click",()=>{T(t,d===""?null:d),L()}),c.appendChild(m)}}),c})}function _e(e,t){e.appendChild(w(`Effect: ${t.label}`));for(const o of t.attrs||[])e.appendChild(D(o,`${t.name}-${o.name}`));const n=f(document.createElement("button"));n.type="button",n.style.cssText=u,n.innerHTML='<span data-icon="trash" data-icon-size="13" style="display:inline-flex;align-items:center;"></span> Remove effect',n.addEventListener("click",()=>{const o={};for(const c of se(l.span.attrs,t.name))o[c]=null;W(l.textarea,l.span,o),p()}),e.appendChild(n)}function Se(){const e=g();e.appendChild(w("Seasonal themes"));for(const[t,n]of[["auto","Auto (date-detected)"],...Object.entries(ee).map(([o,c])=>[o,c.label])]){const o=f(document.createElement("button"));o.type="button",o.style.cssText=u,o.textContent=n,o.addEventListener("click",()=>{O(l.textarea,`[celebrate theme="${t}" /]`),p()}),e.appendChild(o)}e.appendChild(S()),e.appendChild(w("Celebration effects"));for(const t of["butterflies","ticker-tape","firework","fireworks"]){const n=B.get(t),o=f(document.createElement("button"));o.type="button",o.style.cssText=u,o.textContent=n.label,o.addEventListener("click",()=>{const c=l.textarea;p(),M(c,n)}),e.appendChild(o)}return e}function $e(){const e=g(),t=l.span,n=t&&Y.has(t.name)?t.name:null;for(const o of[...new Set(_.map(c=>c.category))]){const c=_.filter(i=>i.category===o);if(c.length){e.appendChild(w(o));for(const i of c){const s=n&&(i.hosts||[]).includes(n)&&!(i.name in t.attrs),a=f(document.createElement("button"));if(a.type="button",a.style.cssText=u+"justify-content:space-between;",a.appendChild(document.createTextNode(i.label)),s){const r=document.createElement("span");r.textContent=`inject \u2192 [${n}]`,r.style.cssText="opacity:.6;font-size:.7rem;",a.appendChild(r)}a.addEventListener("click",()=>{if(s)z(l.textarea,l.span,i.name,!0);else{const r=i.selfClosing?`[${i.name} /]`:`[${i.name}]
1
+ import{convertSelectionToBlock as Z}from"./selection-to-block.js";import{EDITOR_TOOLS as ee,SHORTCODES as z}from"./shortcode-registry.js";import{EFFECTS as S,CELEBRATION_THEMES as te,getEffectAttrs as H}from"./effect-defs.js";import{boolState as ne,boolValue as oe,findEnclosingShortcode as se,setAttr as D,setAttrs as F,effectAttrKeys as ie}from"./shortcode-tags.js";import{insertAtCursor as P,replaceRange as ce}from"./markdown-toolbar.js";import{clearLookupCache as ae,lookupOptions as le}from"./shortcode-lookups.js";import{insertMenuGroups as re,insertShortcodeByName as W}from"./shortcode-insert.js";import{openShortcodeForm as R}from"./shortcode-form.js";import{pickMedia as de}from"./media-picker.js";import{blockTagSnippet as pe}from"./block-tags.js";import{catalogueNow as me,dommaHelp as ue}from"./domma-catalogue.js";import{SHORTCODE_EXPIRY_FIELDS as fe}from"../../../public/js/shortcode-expiry.mjs";const Y=new Set(fe.map(({name:e})=>e));export function splitTrackingAttrs(e=[]){const t=new Set,n=e.filter(o=>!Y.has(o.name)||t.has(o.name)?!1:(t.add(o.name),!0));return{main:e.filter(o=>!Y.has(o.name)),tracking:n}}function he(e){return le(e,r?.span?.attrs||{})}const xe=z.map(e=>({name:e.name,selfClosing:e.name==="block"?!1:!!e.selfClosing})),j=new Map(z.map(e=>[e.name,e])),B=new Map(S.map(e=>[e.name,e])),be=S.map(e=>({name:e.name,selfClosing:!!e.selfClosing})),Ee=[...xe,...be],q=new Set(["card","box","hero","banner","col","button"]);let r=null;const K="position:fixed;z-index:10000;min-width:210px;max-height:70vh;overflow-y:auto;background:var(--dm-surface,#1c1c30);border:1px solid var(--dm-border,#2a2a40);border-radius:6px;box-shadow:var(--dm-shadow-lg);padding:.3rem;font-size:.83rem;color:var(--dm-text,#e5e5e5);",f="display:flex;align-items:center;gap:.5rem;width:100%;text-align:left;padding:.35rem .55rem;border:none;background:transparent;color:inherit;border-radius:4px;cursor:pointer;font-size:.83rem;",k="padding:.3rem .55rem;color:var(--dm-text-muted,#8a8a9a);font-size:.68rem;text-transform:uppercase;letter-spacing:.06em;",M="flex:1;min-width:0;padding:.2rem .4rem;background:var(--dm-input-bg,#12121e);border:1px solid var(--dm-border,#333);border-radius:3px;color:var(--dm-text,#eee);font-size:.8rem;",ye="height:1px;background:var(--dm-border,#2a2a40);margin:.3rem .2rem;";function h(e){return e.addEventListener("mouseenter",()=>{e.style.background="var(--dm-primary,#4338ca)",e.style.color="var(--dm-primary-text,#fff)"}),e.addEventListener("mouseleave",()=>{e.style.background="transparent",e.style.color="inherit"}),e}export function attachContextMenu(e,{blocks:t=()=>[],openBlock:n=null}={}){const o=()=>{const i=t()||[],s=i.filter(a=>a.shortTag&&!j.has(a.name)&&!B.has(a.name));return{defs:i,specs:[...Ee,...s.map(a=>({name:a.name,selfClosing:a.selfClosing}))]}},c=(i,s)=>{p();const{defs:a,specs:l}=o();X(e,se(e,l),i,s,a,n)};return typeof Domma>"u"||!Domma.elements?.contextMenu?(e.addEventListener("contextmenu",i=>{i.preventDefault(),c(i.clientX,i.clientY)}),null):Domma.elements.contextMenu(e,{inherit:!1,cursor:!1,render:i=>{c(i.x,i.y)}})}function p(){r&&(_(),r.root.remove(),document.removeEventListener("mousedown",U,!0),document.removeEventListener("keydown",V,!0),window.removeEventListener("scroll",G,!0),r=null)}const U=e=>{r&&!r.root.contains(e.target)&&!(r.submenu&&r.submenu.contains(e.target))&&p()},G=e=>{r&&!r.root.contains(e.target)&&!(r.submenu&&r.submenu.contains(e.target))&&p()},V=e=>{e.key==="Escape"&&p()};function X(e,t,n,o,c=[],i=null){ae();const s=document.createElement("div");s.className="dm-sc-menu",s.style.cssText=K,r={root:s,textarea:e,span:t,submenu:null,blocks:c,openBlock:i,keepEmpty:!1};const a=new Map(c.map(b=>[b.name,b])),l=t&&(j.get(t.name)||B.get(t.name)),d=t&&(l?t.name==="block"?a.get(String(t.attrs.template||"")):null:a.get(t.name)),m=t&&q.has(t.name)?S.filter(b=>b.name in t.attrs):[];l&&Ce(s,l),d&&ve(s,d,!!l);for(const b of m)$e(s,b);(l||d||m.length)&&s.appendChild(L()),s.appendChild(y("Celebrations\u2026",()=>Ie())),s.appendChild(y("Add effect\u2026",()=>Re())),s.appendChild(y("Insert\u2026",()=>Me()));const u=e.selectionStart!==e.selectionEnd;if(u&&e.value.slice(e.selectionStart,e.selectionEnd).trim()){const b={start:e.selectionStart,end:e.selectionEnd,source:e.value},g=h(document.createElement("button"));g.type="button",g.style.cssText=f,g.textContent="Convert selection to Domma Block\u2026",g.addEventListener("click",()=>{p(),Z(e,b)}),s.appendChild(g)}(t||u)&&s.appendChild(y(u?"Wrap selection in\u2026":"Wrap in\u2026",()=>Oe())),c.length&&(s.appendChild(L()),s.appendChild(y("Add block\u2026",()=>Ne()))),document.body.appendChild(s),Q(s,n,o),document.addEventListener("mousedown",U,!0),document.addEventListener("keydown",V,!0),window.addEventListener("scroll",G,!0),window.I&&I.scan(s)}function L(){const e=document.createElement("div");return e.style.cssText=ye,e}function v(e){const t=document.createElement("div");return t.style.cssText=k,t.textContent=e,t}function Ce(e,t){e.appendChild(v(`${t.label} options`));const n=h(document.createElement("button"));n.type="button",n.style.cssText=f,n.innerHTML='<span data-icon="edit" data-icon-size="13" style="display:inline-flex;align-items:center;"></span>',n.appendChild(document.createTextNode(`Edit ${t.label}\u2026`)),n.addEventListener("click",()=>{const{textarea:a,span:l}=r;p(),R(a,{...t,attrs:H(t,l.attrs)},{span:l})}),e.appendChild(n);for(const a of t.actions||[]){const l=h(document.createElement("button"));l.type="button",l.style.cssText=f,l.innerHTML=`<span data-icon="${a.icon||"zap"}" data-icon-size="13" style="display:inline-flex;align-items:center;"></span>`,l.appendChild(document.createTextNode(a.label)),l.addEventListener("click",()=>{const{textarea:d,span:m}=r;if(a.remove){ce(d,m.openTagStart,m.openTagEnd,""),p();return}r.span=F(d,m,a.set||{}),p()}),e.appendChild(l)}const o=Array.isArray(t.quickAttrs)?new Set(t.quickAttrs):null,{main:c,tracking:i}=splitTrackingAttrs(H(t,r.span.attrs)),s=c.filter(a=>!o||o.has(a.name));(t.actions||[]).length&&s.length&&e.appendChild(L());for(const a of s)e.appendChild(N(a));i.length&&(((t.actions||[]).length||s.length)&&e.appendChild(L()),e.appendChild(y("Tracking",()=>{const a=C();a.appendChild(v("Tracking options"));for(const l of i)a.appendChild(ge(l));return a})))}function ge(e){if(e.type!=="select")return N(e);const t=document.createElement("label");t.style.cssText=f+"cursor:default;";const n=document.createElement("span");n.textContent=e.label,n.style.cssText="white-space:nowrap;color:var(--dm-text-muted,#9a9aac);";const o=document.createElement("select");o.style.cssText=M+"max-width:140px;";const c=r.span.attrs[e.name],i=c==null||c===!0?e.default??"":c;for(const[s,a]of e.options||[]){const l=document.createElement("option");l.value=s,l.textContent=a,l.selected=s===i,o.appendChild(l)}return o.addEventListener("change",()=>w(e.name,o.value)),t.append(n,o),t}function ve(e,t,n){const{span:o}=r;if(r.keepEmpty=!0,n&&e.appendChild(L()),e.appendChild(v(n?`${t.name} parameters`:`${t.name} block`)),t.description&&!n){const s=document.createElement("div");s.style.cssText="padding:0 .55rem .3rem;font-size:.75rem;color:var(--dm-text-muted,#9a9aac);max-width:260px;",s.textContent=t.description,e.appendChild(s)}const c=(s,a,l)=>{const d=h(document.createElement("button"));d.type="button",d.style.cssText=f,d.innerHTML=`<span data-icon="${s}" data-icon-size="13" style="display:inline-flex;align-items:center;"></span>`,d.appendChild(document.createTextNode(a)),d.addEventListener("click",l),e.appendChild(d)};t.attrs.length&&c("edit","Edit parameters\u2026",()=>{const{textarea:s}=r;p(),R(s,{...t,name:o.name,label:t.name},{span:o})});const{openBlock:i}=r;c(i?"layout":"external-link",i?"Edit the block":"Open the block",()=>{p(),i?i(t.name):location.hash=`#/blocks/edit/${encodeURIComponent(t.name)}`});for(const s of t.attrs)e.appendChild(N(s));if(!t.attrs.length){const s=document.createElement("div");s.style.cssText=k+"text-transform:none;letter-spacing:0;",s.textContent="This block takes no parameters.",e.appendChild(s)}}function N(e,t=e.name){const n=we(e,t),o=e.domma?ue(me(),e):"";return o&&n&&!n.title&&(n.title=o),n}function we(e,t){const n=r.span.attrs[t];switch(e.type){case"checkbox":return Te(e,t,ne(n,e.default));case"select":return _e(e,t,n);case"lookup":return Ae(e,t,n);case"colour":return Le(e,t,n);case"icon":return Se(e,t,n);default:return ke(e,t,n)}}function w(e,t){if(r.span=D(r.textarea,r.span,e,r.keepEmpty&&t==null?"":t,{keepEmpty:r.keepEmpty}),e==="theme"){const{textarea:n,span:o,root:c}=r,i=c.getBoundingClientRect(),{blocks:s,openBlock:a}=r;p(),X(n,o,i.left,i.top,s,a)}}function Te(e,t,n){const o=h(document.createElement("label"));o.style.cssText=f;const c=document.createElement("input");return c.type="checkbox",c.checked=n,c.addEventListener("change",()=>w(t,oe(e,c.checked))),o.appendChild(c),o.appendChild(document.createTextNode(e.label)),o}function ke(e,t,n){const o=document.createElement("div");o.style.cssText=f+"cursor:default;";const c=document.createElement("span");c.textContent=e.label,c.style.cssText="white-space:nowrap;color:var(--dm-text-muted,#9a9aac);";const i=document.createElement("input");i.type=e.type==="number"?"number":"text",i.value=n===!0||n==null?"":n,e.default!=null&&e.default!==""&&(i.placeholder=String(e.default)),i.style.cssText=M;let s=null;if(i.addEventListener("input",()=>{clearTimeout(s),s=setTimeout(()=>w(t,i.value.trim()),180)}),i.addEventListener("mousedown",a=>a.stopPropagation()),o.appendChild(c),o.appendChild(i),e.type==="image"){const a=document.createElement("button");a.type="button",a.textContent="Browse",a.title="Choose from Media",a.style.cssText="padding:2px 8px;background:transparent;border:1px solid var(--dm-border,#333);border-radius:4px;color:inherit;cursor:pointer;flex-shrink:0;font:inherit;",a.addEventListener("mousedown",l=>l.stopPropagation()),a.addEventListener("click",async()=>{const{textarea:l,span:d}=r;p();const m=await de({current:i.value.trim()});m&&l.isConnected&&D(l,d,t,m)}),o.appendChild(a)}return o}function Le(e,t,n){const o=document.createElement("div");o.style.cssText=f+"cursor:default;";const c=document.createElement("span");c.textContent=e.label,c.style.flex="1";const i=document.createElement("input");return i.type="color",typeof n=="string"&&/^#/.test(n)?i.value=n:typeof e.default=="string"&&/^#/.test(e.default)&&(i.value=e.default),i.addEventListener("input",()=>w(t,i.value)),o.appendChild(c),o.appendChild(i),o}function _e(e,t,n){const o=n==null||n===!0?e.default??"":n;return y(`${e.label}${o!==""?`: ${o}`:""}`,()=>{const c=C();for(const[i,s]of e.options||[]){const a=h(document.createElement("button"));a.type="button",a.style.cssText=f,a.textContent=s,i===o&&(a.style.fontWeight="700"),a.addEventListener("click",()=>{w(t,i),_()}),c.appendChild(a)}return c})}function Se(e,t,n){const o=n==null||n===!0?"":String(n),c=o?`${e.label}: ${o}`:e.label;return y(c,()=>{const i=C();i.style.width="232px";const s=document.createElement("input");s.type="text",s.placeholder="Search icons\u2026",s.style.cssText=M+"margin:6px;width:calc(100% - 12px);",s.addEventListener("mousedown",b=>b.stopPropagation()),i.appendChild(s);const a=h(document.createElement("button"));a.type="button",a.style.cssText=f,a.textContent="- none -",o||(a.style.fontWeight="700"),a.addEventListener("click",()=>{w(t,null),_()}),i.appendChild(a);const l=document.createElement("div");l.style.cssText="display:flex;flex-wrap:wrap;gap:2px;padding:4px 6px;max-height:220px;overflow-y:auto;",i.appendChild(l);const d=96,m=()=>{const b=typeof I<"u"&&typeof I.list=="function"?I.list():[],g=s.value.trim().toLowerCase(),A=g?b.filter(x=>x.toLowerCase().includes(g)):b;l.replaceChildren();for(const x of A.slice(0,d)){const T=h(document.createElement("button"));T.type="button",T.title=x,T.style.cssText="width:26px;height:26px;display:inline-flex;align-items:center;justify-content:center;background:none;border:1px solid transparent;border-radius:4px;cursor:pointer;color:inherit;",x===o&&(T.style.borderColor="var(--dm-primary,#5b8cff)");const $=document.createElement("span");$.setAttribute("data-icon",x),$.setAttribute("data-icon-size","15"),$.style.cssText="display:inline-flex;align-items:center;",T.appendChild($),T.addEventListener("click",()=>{w(t,x),_()}),l.appendChild(T)}if(A.length>d){const x=document.createElement("div");x.style.cssText=k,x.textContent=`${A.length-d} more - refine search`,l.appendChild(x)}if(!A.length){const x=document.createElement("div");x.style.cssText=k,x.textContent="No icons match",l.appendChild(x)}window.I&&I.scan(l)};let u=null;return s.addEventListener("input",()=>{clearTimeout(u),u=setTimeout(m,120)}),m(),setTimeout(()=>s.focus(),0),i})}function Ae(e,t,n){const o=n==null||n===!0?e.default??"":n;return y(`${e.label}${o!==""?`: ${o}`:""}`,()=>{const c=C();c.style.minHeight="48px";const i=typeof E<"u"&&E.loader?E.loader(c,{type:"dots"}):null;return he(e.source).then(s=>{if(i&&i.destroy(),!r||r.submenu!==c)return;if(c.style.minHeight="",!s.length){const d=document.createElement("div");d.style.cssText=k,d.textContent="Nothing found",c.appendChild(d)}const a=s.some(([d])=>d===o),l=[["","- none -"],...s];o!==""&&!a&&l.push([o,`${o} (missing)`]);for(const[d,m]of l){const u=h(document.createElement("button"));u.type="button",u.style.cssText=f,u.textContent=m,d===o&&(u.style.fontWeight="700"),u.addEventListener("click",()=>{w(t,d===""?null:d),_()}),c.appendChild(u)}}),c})}function $e(e,t){e.appendChild(v(`Effect: ${t.label}`));for(const o of t.attrs||[])e.appendChild(N(o,`${t.name}-${o.name}`));const n=h(document.createElement("button"));n.type="button",n.style.cssText=f,n.innerHTML='<span data-icon="trash" data-icon-size="13" style="display:inline-flex;align-items:center;"></span> Remove effect',n.addEventListener("click",()=>{const o={};for(const c of ie(r.span.attrs,t.name))o[c]=null;F(r.textarea,r.span,o),p()}),e.appendChild(n)}function Ie(){const e=C();e.appendChild(v("Seasonal themes"));for(const[t,n]of[["auto","Auto (date-detected)"],...Object.entries(te).map(([o,c])=>[o,c.label])]){const o=h(document.createElement("button"));o.type="button",o.style.cssText=f,o.textContent=n,o.addEventListener("click",()=>{P(r.textarea,`[celebrate theme="${t}" /]`),p()}),e.appendChild(o)}e.appendChild(L()),e.appendChild(v("Celebration effects"));for(const t of["butterflies","ticker-tape","firework","fireworks"]){const n=B.get(t),o=h(document.createElement("button"));o.type="button",o.style.cssText=f,o.textContent=n.label,o.addEventListener("click",()=>{const c=r.textarea;p(),R(c,n)}),e.appendChild(o)}return e}function Re(){const e=C(),t=r.span,n=t&&q.has(t.name)?t.name:null;for(const o of[...new Set(S.map(c=>c.category))]){const c=S.filter(i=>i.category===o);if(c.length){e.appendChild(v(o));for(const i of c){const s=n&&(i.hosts||[]).includes(n)&&!(i.name in t.attrs),a=h(document.createElement("button"));if(a.type="button",a.style.cssText=f+"justify-content:space-between;",a.appendChild(document.createTextNode(i.label)),s){const l=document.createElement("span");l.textContent=`inject \u2192 [${n}]`,l.style.cssText="opacity:.6;font-size:.7rem;",a.appendChild(l)}a.addEventListener("click",()=>{if(s)D(r.textarea,r.span,i.name,!0);else{const l=i.selfClosing?`[${i.name} /]`:`[${i.name}]
2
2
  Content
3
- [/${i.name}]`;O(l.textarea,r)}p()}),e.appendChild(a)}}}return e}function C(e,t){const n=f(document.createElement("button"));n.type="button",n.style.cssText=u+"justify-content:space-between;",n.appendChild(document.createTextNode(e));const o=document.createElement("span");return o.setAttribute("data-icon","chevron-right"),o.setAttribute("data-icon-size","12"),o.style.cssText="opacity:.6;display:inline-flex;align-items:center;flex-shrink:0;",n.appendChild(o),n.addEventListener("mouseenter",()=>X(n,t)),n.addEventListener("click",c=>{c.stopPropagation(),X(n,t)}),n}function g(){const e=document.createElement("div");return e.className="dm-sc-submenu",e.style.cssText=q,e}function X(e,t){L();const n=t();l.submenu=n,document.body.appendChild(n);const o=e.getBoundingClientRect();J(n,o.right+2,o.top,o.left-2),window.I&&I.scan(n)}function L(){l&&l.submenu&&(l.submenu.remove(),l.submenu=null)}function N(e){const t=f(document.createElement("button"));if(t.type="button",t.style.cssText=u,e.icon){const n=document.createElement("span");n.setAttribute("data-icon",e.icon),n.setAttribute("data-icon-size","14"),n.style.cssText="opacity:.75;display:inline-flex;align-items:center;flex-shrink:0;",t.appendChild(n)}return t.appendChild(document.createTextNode(e.label)),t}function Ae(){const e=g();for(const{category:t,items:n}of le()){e.appendChild(w(t));for(const o of n){const c=N(o);c.addEventListener("click",()=>{const i=l.textarea;p(),j(o.name,i)}),e.appendChild(c)}}return e}function Me(){const e=g();e.style.maxWidth="320px";const t=document.createElement("input");t.type="text",t.placeholder="Find a block\u2026",t.style.cssText=P+"margin:6px;width:calc(100% - 12px);",t.addEventListener("mousedown",c=>c.stopPropagation());const n=document.createElement("div");e.append(t,n);const o=()=>{const c=t.value.trim().toLowerCase(),i=l.blocks.filter(s=>!c||s.name.includes(c)||s.description.toLowerCase().includes(c));n.replaceChildren();for(const s of i){const a=N(s);if(s.description&&(a.title=s.description),!s.shortTag){const r=document.createElement("small");r.style.cssText="margin-left:auto;opacity:.6;",r.textContent="[block]",r.title='A built-in shortcode has this name, so it goes in as [block template="\u2026"]',a.appendChild(r)}a.addEventListener("click",()=>{const r=l.textarea;p();const d=r.selectionStart,b=de(s);O(r,b);const m=b.indexOf('=""');m>=0&&r.setSelectionRange(d+m+2,d+m+2),r.focus()}),n.appendChild(a)}if(!i.length){const s=document.createElement("div");s.style.cssText=k,s.textContent="No blocks match",n.appendChild(s)}window.I&&I.scan(n)};return t.addEventListener("input",o),o(),setTimeout(()=>t.focus(),0),e}function Ie(){const e=g();for(const t of R.filter(n=>n.wrappable||n.container)){const n=N(t);n.addEventListener("click",()=>{const o=l.textarea;p(),M(o,t)}),e.appendChild(n)}for(const t of Z.filter(n=>n.wrappable)){const n=N(t);n.addEventListener("click",()=>{const o=l.textarea;p(),j(t.name,o)}),e.appendChild(n)}return e}function J(e,t,n,o){e.style.left="0px",e.style.top="0px";const c=e.getBoundingClientRect();let i=t;t+c.width>window.innerWidth-8&&(i=o!=null?o-c.width:t-c.width);let s=n;n+c.height>window.innerHeight-8&&(s=Math.max(8,window.innerHeight-c.height-8)),e.style.left=`${Math.max(8,i)}px`,e.style.top=`${Math.max(8,s)}px`}
3
+ [/${i.name}]`;P(r.textarea,l)}p()}),e.appendChild(a)}}}return e}function y(e,t){const n=h(document.createElement("button"));n.type="button",n.style.cssText=f+"justify-content:space-between;",n.appendChild(document.createTextNode(e));const o=document.createElement("span");return o.setAttribute("data-icon","chevron-right"),o.setAttribute("data-icon-size","12"),o.style.cssText="opacity:.6;display:inline-flex;align-items:center;flex-shrink:0;",n.appendChild(o),n.addEventListener("mouseenter",()=>J(n,t)),n.addEventListener("click",c=>{c.stopPropagation(),J(n,t)}),n}function C(){const e=document.createElement("div");return e.className="dm-sc-submenu",e.style.cssText=K,e}function J(e,t){_();const n=t();r.submenu=n,document.body.appendChild(n);const o=e.getBoundingClientRect();Q(n,o.right+2,o.top,o.left-2),window.I&&I.scan(n)}function _(){r&&r.submenu&&(r.submenu.remove(),r.submenu=null)}function O(e){const t=h(document.createElement("button"));if(t.type="button",t.style.cssText=f,e.icon){const n=document.createElement("span");n.setAttribute("data-icon",e.icon),n.setAttribute("data-icon-size","14"),n.style.cssText="opacity:.75;display:inline-flex;align-items:center;flex-shrink:0;",t.appendChild(n)}return t.appendChild(document.createTextNode(e.label)),t}function Me(){const e=C();for(const{category:t,items:n}of re()){e.appendChild(v(t));for(const o of n){const c=O(o);c.addEventListener("click",()=>{const i=r.textarea;p(),W(o.name,i)}),e.appendChild(c)}}return e}function Ne(){const e=C();e.style.maxWidth="320px";const t=document.createElement("input");t.type="text",t.placeholder="Find a block\u2026",t.style.cssText=M+"margin:6px;width:calc(100% - 12px);",t.addEventListener("mousedown",c=>c.stopPropagation());const n=document.createElement("div");e.append(t,n);const o=()=>{const c=t.value.trim().toLowerCase(),i=r.blocks.filter(s=>!c||s.name.includes(c)||s.description.toLowerCase().includes(c));n.replaceChildren();for(const s of i){const a=O(s);if(s.description&&(a.title=s.description),!s.shortTag){const l=document.createElement("small");l.style.cssText="margin-left:auto;opacity:.6;",l.textContent="[block]",l.title='A built-in shortcode has this name, so it goes in as [block template="\u2026"]',a.appendChild(l)}a.addEventListener("click",()=>{const l=r.textarea;p();const d=l.selectionStart,m=pe(s);P(l,m);const u=m.indexOf('=""');u>=0&&l.setSelectionRange(d+u+2,d+u+2),l.focus()}),n.appendChild(a)}if(!i.length){const s=document.createElement("div");s.style.cssText=k,s.textContent="No blocks match",n.appendChild(s)}window.I&&I.scan(n)};return t.addEventListener("input",o),o(),setTimeout(()=>t.focus(),0),e}function Oe(){const e=C();for(const t of z.filter(n=>n.wrappable||n.container)){const n=O(t);n.addEventListener("click",()=>{const o=r.textarea;p(),R(o,t)}),e.appendChild(n)}for(const t of ee.filter(n=>n.wrappable)){const n=O(t);n.addEventListener("click",()=>{const o=r.textarea;p(),W(t.name,o)}),e.appendChild(n)}return e}function Q(e,t,n,o){e.style.left="0px",e.style.top="0px";const c=e.getBoundingClientRect();let i=t;t+c.width>window.innerWidth-8&&(i=o!=null?o-c.width:t-c.width);let s=n;n+c.height>window.innerHeight-8&&(s=Math.max(8,window.innerHeight-c.height-8)),e.style.left=`${Math.max(8,i)}px`,e.style.top=`${Math.max(8,s)}px`}
@@ -44,4 +44,4 @@ Optional body content.
44
44
  [/table]`,attrs:[{name:"striped",type:"checkbox",label:"Striped"},{name:"bordered",type:"checkbox",label:"Bordered"},{name:"compact",type:"checkbox",label:"Compact"},{name:"caption",type:"text",label:"Caption"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"badge",label:"Badge",icon:"badge",category:"Content",selfClosing:!1,container:!1,wrappable:!1,template:'[badge variant="success"]New[/badge]',inline:!0,attrs:[{name:"variant",type:"select",label:"Variant",options:[["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"],["light","Light"],["dark","Dark"]]},{name:"pill",type:"checkbox",label:"Pill"},{name:"outline",type:"checkbox",label:"Outline"},{name:"size",type:"select",label:"Size",options:[["","Default"],["small","Small"],["large","Large"]]}]},{name:"text",label:"Text",icon:"text-style",preview:"text",category:"Content",selfClosing:!1,container:!0,wrappable:!0,template:"[text]Styled text[/text]",inline:!0,actions:[{label:"Highlight - gradient with a shine",icon:"star",set:{gradient:"sunset",shine:"hover"}},{label:"Highlight that sweeps by itself",icon:"star",set:{gradient:"sunset",shine:"sweep"}},{label:"Light up as you read",icon:"eye",set:{"light-up":"true"}},{label:"Rise in word by word",icon:"arrow-up",set:{words:"true"}},{label:"Plain - no highlight or motion",icon:"minimize",set:{gradient:null,shine:null,"light-up":null,words:null}}],quickAttrs:["gradient","shine","align","size","bold","color"],attrs:[{name:"size",type:"select",label:"Size",options:[["xs","XS"],["sm","Small"],["base","Base"],["lg","Large"],["xl","XL"],["2xl","2XL"],["3xl","3XL"],["4xl","4XL"]]},{name:"weight",type:"select",label:"Weight",options:[["thin","Thin"],["light","Light"],["normal","Normal"],["medium","Medium"],["semibold","Semibold"],["bold","Bold"],["extrabold","Extra bold"],["black","Black"]]},{name:"point-size",type:"number",label:"Point size"},{name:"bold",type:"checkbox",label:"Bold"},{name:"italic",type:"checkbox",label:"Italic"},{name:"color",type:"colour",label:"Colour"},{name:"font",type:"select",label:"Font",options:Object.keys(l).map(e=>[e,n(e)?`${e} (licensed)`:e])},{name:"transform",type:"select",label:"Transform",options:[["upper","Uppercase"],["lower","Lowercase"],["capitalize","Capitalise"],["none","None"]]},{name:"decoration",type:"select",label:"Decoration",options:[["underline","Underline"],["line-through","Line through"],["none","None"]]},{name:"spacing",type:"select",label:"Letter spacing",options:[["tight","Tight"],["normal","Normal"],["wide","Wide"],["wider","Wider"]]},{name:"align",type:"select",label:"Align",options:[["","None"],["left","Left"],["center","Centre"],["right","Right"],["justify","Justify"]]},{name:"gradient",type:"select",label:"Gradient",options:[["","None"],["brand","Theme"],["sunset","Sunset"],["ocean","Ocean"],["forest","Forest"],["fire","Fire"],["candy","Candy"],["newspaper","Newspaper"],["grey-fire","Grey-fire"],["ice","Ice"],["summer","Summer"],["autumn","Autumn"],["spring","Spring"],["winter","Winter"],["aurora","Aurora"],["twilight","Twilight"],["rose-gold","Rose-gold"],["copper","Copper"],["amethyst","Amethyst"],["lagoon","Lagoon"],["cherry","Cherry"],["lavender","Lavender"],["midnight","Midnight"]]},{name:"shine",type:"select",label:"Shine (gradient)",options:[["","None"],["hover","Follows the pointer"],["sweep","Sweeps across"]]},{name:"light-up",type:"checkbox",label:"Words light up as you scroll"},{name:"words",type:"checkbox",label:"Rise in word by word"},{name:"style",type:"text",label:"Inline CSS"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"button",label:"Button",icon:"btn-insert",category:"Content",selfClosing:!0,container:!1,wrappable:!1,template:'[button href="/contact" variant="primary" label="Get in touch" /]',attrs:[{name:"href",type:"url",label:"Link"},{name:"label",type:"text",label:"Label"},{name:"variant",type:"select",label:"Variant",options:[["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"],["outline","Outline"],["ghost","Ghost"],["link","Link"],["outline-success","Outline success"],["outline-danger","Outline danger"],["outline-warning","Outline warning"],["outline-info","Outline info"]]},{name:"size",type:"select",label:"Size",options:[["","Default"],["sm","Small"],["lg","Large"]]},{name:"icon",type:"icon",label:"Icon (before)"},{name:"icon-after",type:"icon",label:"Icon (after)"},{name:"target",type:"text",label:"Target"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"link",label:"Link",icon:"link-shortcode",category:"Content",selfClosing:!0,container:!1,wrappable:!1,template:'[link href="/about" label="About us" /]',formats:[{value:"markdown",label:"Markdown link",emit:e=>Object.keys(e).some(t=>t!=="href"&&t!=="label"&&e[t])||!e.href?null:`[${e.label||e.href}](${e.href})`},{value:"shortcode",label:"Link shortcode"}],attrs:[{name:"href",type:"url",label:"Link"},{name:"label",type:"text",label:"Label"},{name:"target",type:"text",label:"Target"},{name:"class",type:"text",label:"CSS class"},{name:"icon",type:"icon",label:"Icon (before)"},{name:"icon-after",type:"icon",label:"Icon (after)"},{name:"id",type:"text",label:"ID"}]},{name:"listgroup",label:"List group",icon:"list",category:"Content",selfClosing:!1,container:!0,wrappable:!1,template:`[listgroup]
45
45
  [item]First item[/item]
46
46
  [item]Second item[/item]
47
- [/listgroup]`,children:{name:"item",min:1,max:20},attrs:[{name:"variant",type:"select",label:"Variant",options:[["","Default"],["flush","Flush"],["numbered","Numbered"],["horizontal","Horizontal"]]},{name:"size",type:"select",label:"Size",options:[["","Default"],["sm","Small"],["lg","Large"]]},{name:"itemvariant",type:"select",label:"Item variant",options:[["","Default"],["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"]]},{name:"action",type:"checkbox",label:"Actionable items"}]},{name:"collection",label:"Collection",icon:"database",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[collection slug="enquiries" display="table" /]',attrs:[{name:"slug",type:"lookup",source:"collections",label:"Collection"},{name:"display",type:"select",label:"Display",options:[["table","Table"],["cards","Cards"],["list","List"],["accordion","Accordion"],["timeline","Timeline"],["carousel","Carousel"],["block","Block"]]},{name:"fields",type:"text",label:"Fields (comma-separated)"},{name:"limit",type:"number",label:"Limit"},{name:"sort",type:"lookup",source:"collection-fields",label:"Sort field"},{name:"order",type:"select",label:"Order",options:[["desc","Descending"],["asc","Ascending"]]},{name:"title-field",type:"lookup",source:"collection-fields",label:"Title field"},{name:"image-field",type:"lookup",source:"collection-fields",label:"Image field"},{name:"body-field",type:"lookup",source:"collection-fields",label:"Body field"},{name:"mobile-popup",type:"checkbox",label:"Open carousel cards in a popup on mobile"},{name:"arrow-position",type:"select",label:"Arrow position",options:[["middle","Middle"],["top","Top"],["bottom","Bottom"]]},{name:"background",type:"colour",label:"Carousel background"},{name:"arrow-background",type:"colour",label:"Arrow background"},{name:"arrow-color",type:"colour",label:"Arrow colour"},{name:"autoplay",type:"checkbox",label:"Autoplay",domma:"carousel.autoplay"},{name:"interval",type:"number",label:"Interval (ms)",domma:"carousel.interval"},{name:"loop",type:"checkbox",label:"Loop",default:!0,domma:"carousel.loop"},{name:"animation",type:"select",label:"Animation",options:[["slide","Slide"],["fade","Fade"],["crossfade","Crossfade"]],domma:"carousel.animation"},{name:"animation-duration",type:"number",label:"Animation duration (ms)",domma:"carousel.animationDuration"},{name:"animation-easing",type:"text",label:"Animation easing",domma:"carousel.animationEasing"},{name:"height-mode",type:"select",label:"Image height",options:[["crop","Top-aligned crop (shortest image)"],["average","Average of shortest and tallest images"]],domma:"carousel.heightMode"},{name:"height",type:"number",label:"Fixed height (px, optional)",domma:"carousel.height"},{name:"columns",type:"number",label:"Card columns"},{name:"search",type:"checkbox",label:"Search (table)",default:!0},{name:"sortable",type:"checkbox",label:"Sortable (table)",default:!0},{name:"exportable",type:"checkbox",label:"CSV export"},{name:"page-size",type:"number",label:"Page size"},{name:"empty",type:"text",label:"Empty message"},{name:"scope",type:"select",label:"Scope",options:[["","All"],["mine","Current user"]]},{name:"cta",type:"lookup",source:"actions",label:"CTA action"},{name:"cta-label",type:"text",label:"CTA label"},{name:"cta-icon",type:"icon",label:"CTA icon"},{name:"cta-style",type:"select",label:"CTA style",options:[["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"]]},{name:"cta-confirm",type:"text",label:"CTA confirm text"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"view",label:"View",icon:"eye",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[view slug="products" display="table" limit="50" /]',attrs:[{name:"slug",type:"lookup",source:"views",label:"View"},{name:"display",type:"select",label:"Display",options:[["table","Table"],["cards","Cards"],["list","List"],["accordion","Accordion"],["timeline","Timeline"],["carousel","Carousel"],["block","Block"]]},{name:"limit",type:"number",label:"Limit"},{name:"fields",type:"text",label:"Fields (comma-separated)"},{name:"title-field",type:"text",label:"Title field"},{name:"image-field",type:"text",label:"Image field"},{name:"body-field",type:"text",label:"Body field"},{name:"mobile-popup",type:"checkbox",label:"Open carousel cards in a popup on mobile"},{name:"arrow-position",type:"select",label:"Arrow position",options:[["middle","Middle"],["top","Top"],["bottom","Bottom"]]},{name:"background",type:"colour",label:"Carousel background"},{name:"arrow-background",type:"colour",label:"Arrow background"},{name:"arrow-color",type:"colour",label:"Arrow colour"},{name:"autoplay",type:"checkbox",label:"Autoplay",domma:"carousel.autoplay"},{name:"interval",type:"number",label:"Interval (ms)",domma:"carousel.interval"},{name:"loop",type:"checkbox",label:"Loop",default:!0,domma:"carousel.loop"},{name:"animation",type:"select",label:"Animation",options:[["slide","Slide"],["fade","Fade"],["crossfade","Crossfade"]],domma:"carousel.animation"},{name:"animation-duration",type:"number",label:"Animation duration (ms)",domma:"carousel.animationDuration"},{name:"animation-easing",type:"text",label:"Animation easing",domma:"carousel.animationEasing"},{name:"height-mode",type:"select",label:"Image height",options:[["crop","Top-aligned crop (shortest image)"],["average","Average of shortest and tallest images"]],domma:"carousel.heightMode"},{name:"height",type:"number",label:"Fixed height (px, optional)",domma:"carousel.height"},{name:"columns",type:"number",label:"Card columns"},{name:"empty",type:"text",label:"Empty message"}]},{name:"block",label:"Block",icon:"layout",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[block template="post-card" title="My Post" /]',attrs:[{name:"template",type:"lookup",source:"blocks",label:"Template"}]},{name:"form",label:"Form",icon:"file-text",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[form name="contact" /]',attrs:[{name:"name",type:"lookup",source:"forms",label:"Form"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"cta",label:"CTA",icon:"mouse-pointer",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[cta action="send-welcome" entry="abc123" style="primary" label="Send" /]',attrs:[{name:"action",type:"lookup",source:"actions",label:"Action"},{name:"entry",type:"text",label:"Entry ID"},{name:"style",type:"select",label:"Style",options:[["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"]]},{name:"icon",type:"icon",label:"Icon"},{name:"size",type:"select",label:"Size",options:[["","Default"],["sm","Small"],["lg","Large"]]},{name:"confirm",type:"text",label:"Confirm text"},{name:"label",type:"text",label:"Label"}]},{name:"menu",label:"Menu",icon:"menu",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[menu slug="legal" /]',attrs:[{name:"slug",type:"lookup",source:"menus",label:"Menu"},{name:"location",type:"lookup",source:"menu-locations",label:"Location slot"},{name:"variant",type:"text",label:"Variant"},{name:"class",type:"text",label:"CSS class"},{name:"depth",type:"number",label:"Max depth"},{name:"orientation",type:"select",label:"Orientation",options:[["","Menu default"],["horizontal","Horizontal"],["vertical","Vertical"]]},{name:"float",type:"select",label:"Floating",options:[["","Menu default"],["no","Render inline here"]]}]},{name:"contents",label:"Page contents (this page)",icon:"list",category:"Layout",selfClosing:!0,container:!1,wrappable:!1,template:'[contents numbered="true" /]',actions:[{label:"Number the contents",icon:"hash",set:{numbered:"true"}},{label:"List H2 and H3 headings",icon:"list",set:{headings:"h2h3"}},{label:"Contents on the right",icon:"sidebar-right",set:{side:"right"}},{label:"Collapse the contents to a button",icon:"minimize",set:{collapsible:"true",collapsed:"true"}},{label:"Float the contents",icon:"move",set:{floating:"true","float-anchor":"TR",movable:"true"}},{label:"No contents on this page",icon:"eye-off",set:{hidden:"true"}},{label:"Remove this override",icon:"trash",remove:!0}],quickAttrs:["side","headings","numbered","title","collapsible","floating","hidden"],attrs:[{name:"side",type:"select",label:"Side",options:[["","Layout default"],["left","Left"],["right","Right"]]},{name:"width",type:"number",label:"Width (px, 160-480)"},{name:"headings",type:"select",label:"Headings",options:[["","Layout default"],["auto","Sections (H2s, else H3s)"],["h2","H2 only"],["h3","H3 only"],["h2h3","H2 and H3"]]},{name:"numbered",type:"select",label:"Numbered",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"title",type:"text",label:"Title above the list"},{name:"exclude",type:"text",label:"Leave out (headings, comma separated)"},{name:"sticky",type:"select",label:"Stays in view",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"scroll-spy",type:"select",label:"Marks the section being read",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"collapsible",type:"select",label:"Collapsible to a button",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"collapsed",type:"select",label:"Start collapsed",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"autohide",type:"select",label:"Autohide off its edge",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"floating",type:"select",label:"Floating panel",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"float-anchor",type:"select",label:"Float anchor",options:[["","Layout default"],["TL","Top left"],["TR","Top right"],["BL","Bottom left"],["BR","Bottom right"],["L","Left"],["R","Right"]]},{name:"movable",type:"select",label:"Visitors can move it",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"hidden",type:"select",label:"No contents on this page",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"hover",type:"text",label:"Hover effect"},{name:"selected",type:"text",label:"When selected"},{name:"accent",type:"colour",label:"Accent"},{name:"font",type:"text",label:"Font family"},{name:"font-size",type:"text",label:"Font size"},{name:"font-weight",type:"text",label:"Font weight"}]},{name:"navbar",label:"Navbar settings (this page)",icon:"sliders",category:"Layout",selfClosing:!0,container:!1,wrappable:!1,template:'[navbar collapsed="true" /]',actions:[{label:"Collapse the rail on this page",icon:"chevrons-right",set:{collapsible:"true",collapsed:"true",autohide:"false"}},{label:"Autohide the rail on this page",icon:"eye-off",set:{autohide:"true",collapsed:null}},{label:"Keep the rail open on this page",icon:"eye",set:{autohide:"false",collapsed:"false"}},{label:"Hide the bar on scroll on this page",icon:"arrow-up",set:{"hide-on-scroll":"true"}},{label:"Remove this override",icon:"trash",remove:!0}],quickAttrs:["position","width","collapsible","collapsed","autohide","hide-on-scroll"],attrs:[{name:"position",type:"select",label:"Position",options:[["","Menu default"],["sticky","Sticky"],["fixed","Fixed"],["static","Static"],["floating","Floating"]]},{name:"orientation",type:"select",label:"Orientation",options:[["","Menu default"],["horizontal","Horizontal"],["vertical","Vertical"]]},{name:"side",type:"select",label:"Rail side",options:[["","Menu default"],["left","Left"],["right","Right"]]},{name:"align",type:"select",label:"Alignment",options:[["","Menu default"],["left","Left"],["centre","Centre"],["right","Right"],["spread","Spread"]]},{name:"width",type:"number",label:"Rail width (px, 160-480)"},{name:"collapsible",type:"select",label:"Collapsible to icons",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"collapsed",type:"select",label:"Start collapsed",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"autohide",type:"select",label:"Autohide off-screen",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"hide-on-scroll",type:"select",label:"Hide on scroll (bar)",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"hover-open",type:"select",label:"Open dropdowns on hover",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"bar",type:"select",label:"Bar shape",options:[["","Menu default"],["pill","Pill"],["segmented","Segmented"],["underline","Underline glide"],["dock","Dock"],["neon","Neon"],["tabs","Tabs"],["tiles","Tiles"],["bubbles","Bubbles"],["brutalist","Brutalist"],["gradient","Gradient band"]]},{name:"shrink",type:"select",label:"Shrink on scroll",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"icons",type:"select",label:"Bar icons",options:[["","Menu default"],["rainbow","Rainbow"],["accent","Accent"]]},{name:"brand",type:"select",label:"Branding shape",options:[["","Menu default"],["pill","Pill"]]},{name:"strip",type:"select",label:"Bar background",options:[["","Menu default"],["none","None - floating pills"],["band","Strip - keep the band"]]},{name:"dropdown",type:"select",label:"Dropdown style",options:[["","Menu default"],["cards","Cards"]]},{name:"tiles",type:"select",label:"Icon tiles (cards)",options:[["","Menu default"],["rainbow","Rainbow"],["accent","Theme colour"],["neutral","Neutral"],["none","No tiles"]]},{name:"morph",type:"select",label:"Slide between cards",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"hover",type:"text",label:"Hover effect"},{name:"selected",type:"text",label:"When selected"},{name:"accent",type:"colour",label:"Highlight colour"},{name:"variant",type:"text",label:"Variant"},{name:"font",type:"text",label:"Font family"},{name:"font-size",type:"text",label:"Font size"},{name:"font-weight",type:"text",label:"Font weight"},{name:"letter-spacing",type:"text",label:"Letter spacing"},{name:"icon-size",type:"text",label:"Icon size"},{name:"float-anchor",type:"select",label:"Float anchor",options:[["","Menu default"],["TL","Top left"],["TR","Top right"],["BL","Bottom left"],["BR","Bottom right"],["L","Left"],["R","Right"]]},{name:"float-x",type:"number",label:"Float offset X (px)"},{name:"float-y",type:"number",label:"Float offset Y (px)"},{name:"float-width",type:"number",label:"Float width (px)"},{name:"float-collapsible",type:"select",label:"Float: collapsible",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"float-movable",type:"select",label:"Float: movable",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"class",type:"text",label:"CSS classes"}]},{name:"theme-switcher",label:"Theme switcher",icon:"palette",category:"Components",selfClosing:!0,container:!1,wrappable:!1,template:"[theme-switcher /]",attrs:[{name:"position",type:"select",label:"Position",options:[["","Inline - where the tag is"],["top-left","Top left"],["top-right","Top right"],["left-center","Left, centred"],["right-center","Right, centred"],["bottom-left","Bottom left"],["bottom-right","Bottom right"]]},{name:"offset-x",type:"number",label:"Offset from the side (px, pinned only)"},{name:"offset-y",type:"number",label:"Offset from the top/bottom (px, pinned only)"},{name:"themes",type:"text",label:"Themes (comma list - blank for the site's)"}]},{name:"icon",label:"Icon",icon:"icon-pick",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[icon name="arrow-right" /]',attrs:[{name:"name",type:"icon",label:"Icon name"},{name:"size",type:"number",label:"Size (px)"},{name:"color",type:"colour",label:"Colour"},{name:"class",type:"text",label:"CSS class"}]},{name:"image",label:"Image",icon:"image-add",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[image src="/media/photo.jpg" alt="" /]',custom:"image",quickAttrs:["zoom","align","width","shadow"],attrs:[{name:"src",type:"image",label:"Image",help:"The picture: choose it from Media, or type a /media/\u2026 path or an https:// address."},{name:"alt",type:"text",label:"Description (alt)",help:"What the picture shows, in a few words. Screen readers and search engines read it. Leave empty only for decoration."},{name:"caption",type:"text",label:"Caption",help:"Shown under the picture, and in the zoom view."},{name:"zoom",type:"checkbox",label:"Click to zoom",help:"Visitors click the picture to see it full size in a viewer: fitted first, then actual size with drag to pan. Best for screenshots with small text. Ignored when the picture has a link."},{name:"width",type:"text",label:"Width (480, 60%, 30rem)",help:"How wide the picture shows. A bare number is pixels. Empty: its own size, never wider than the column."},{name:"align",type:"select",label:"Alignment",options:[["","Default (left)"],["center","Centre"],["right","Right"],["float-left","Float left (text wraps)"],["float-right","Float right (text wraps)"]],help:"Floats let the text run beside the picture; on phones they stack."},{name:"group",type:"text",label:"Zoom group",help:"Give zoomable pictures the same group name and the viewer steps between them with arrows - a gallery or a tour."},{name:"zoom-src",type:"image",label:"Full-size file (zoom)",help:"Optional: a larger file for the zoom view, when the page shows a smaller copy."},{name:"title",type:"text",label:"Hover text (title)"},{name:"max-width",type:"text",label:"Max width (800, 50%)"},{name:"height",type:"text",label:"Height (240, 20rem)",help:"A set height crops the picture to fill the box (see Fit)."},{name:"fit",type:"select",label:"Fit (with a height)",options:[["","Fill and crop (default)"],["contain","Show it all"],["fill","Stretch"],["none","Actual size"],["scale-down","Shrink only"]]},{name:"radius",type:"select",label:"Corners",options:[["","Square"],["sm","Slightly rounded"],["md","Rounded"],["lg","Very rounded"],["full","Circle / pill"]]},{name:"border",type:"checkbox",label:"Border"},{name:"shadow",type:"select",label:"Shadow",options:[["","None"],["sm","Small"],["md","Medium"],["lg","Large"]]},{name:"link",type:"url",label:"Link to",help:"Clicking the picture goes here instead of zooming."},{name:"target",type:"select",label:"Open link in",options:[["","Same tab"],["_blank","New tab"]]},{name:"loading",type:"select",label:"Loading",options:[["","When scrolled near (lazy)"],["eager","Straight away (top of page)"]]},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"embed",label:"Embed",icon:"video",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[embed url="https://youtu.be/dQw4w9WgXcQ" /]',custom:"embed",attrs:[{name:"url",type:"url",label:"URL"},{name:"ratio",type:"select",label:"Aspect ratio",options:[["16:9","16:9"],["4:3","4:3"],["1:1","1:1"],["21:9","21:9"],["9:16","9:16"],["3:4","3:4"]]},{name:"title",type:"text",label:"Title / caption"},{name:"width",type:"text",label:"Width"},{name:"align",type:"select",label:"Alignment",options:[["left","Left"],["center","Centre"],["right","Right"]]},{name:"autoplay",type:"checkbox",label:"Autoplay"},{name:"loop",type:"checkbox",label:"Loop"},{name:"muted",type:"checkbox",label:"Muted"}]}];for(const e of SHORTCODES){e.attrs||(e.attrs=[]);for(const a of o)e.attrs.some(t=>t.name===a.name)||e.attrs.push(a)}export const EDITOR_TOOLS=[{name:"colourpick",label:"Colour picker",icon:"colour-picker",category:"Media",custom:"colourpick"},{name:"component",label:"Component",icon:"component",category:"Components",custom:"component"},{name:"scribe",label:"Scribe",icon:"scribe-insert",category:"Content",custom:"scribe"},{name:"highlight-text",label:"Highlight text",icon:"star",category:"Content",custom:"highlighttext",wrappable:!0}];
47
+ [/listgroup]`,children:{name:"item",min:1,max:20},attrs:[{name:"variant",type:"select",label:"Variant",options:[["","Default"],["flush","Flush"],["numbered","Numbered"],["horizontal","Horizontal"]]},{name:"size",type:"select",label:"Size",options:[["","Default"],["sm","Small"],["lg","Large"]]},{name:"itemvariant",type:"select",label:"Item variant",options:[["","Default"],["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"]]},{name:"action",type:"checkbox",label:"Actionable items"}]},{name:"collection",label:"Collection",icon:"database",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[collection slug="enquiries" display="table" /]',attrs:[{name:"slug",type:"lookup",source:"collections",label:"Collection"},{name:"display",type:"select",label:"Display",options:[["table","Table"],["cards","Cards"],["list","List"],["accordion","Accordion"],["timeline","Timeline"],["carousel","Carousel"],["block","Block"]]},{name:"fields",type:"text",label:"Fields (comma-separated)"},{name:"limit",type:"number",label:"Limit"},{name:"sort",type:"lookup",source:"collection-fields",label:"Sort field"},{name:"order",type:"select",label:"Order",options:[["desc","Descending"],["asc","Ascending"]]},{name:"title-field",type:"lookup",source:"collection-fields",label:"Title field"},{name:"image-field",type:"lookup",source:"collection-fields",label:"Image field"},{name:"body-field",type:"lookup",source:"collection-fields",label:"Body field"},{name:"mobile-popup",type:"checkbox",label:"Open carousel cards in a popup on mobile"},{name:"arrow-position",type:"select",label:"Arrow position",options:[["middle","Middle"],["top","Top"],["bottom","Bottom"]]},{name:"background",type:"colour",label:"Carousel background"},{name:"arrow-background",type:"colour",label:"Arrow background"},{name:"arrow-color",type:"colour",label:"Arrow colour"},{name:"autoplay",type:"checkbox",label:"Autoplay",domma:"carousel.autoplay"},{name:"interval",type:"number",label:"Interval (ms)",domma:"carousel.interval"},{name:"loop",type:"checkbox",label:"Loop",default:!0,domma:"carousel.loop"},{name:"animation",type:"select",label:"Animation",options:[["slide","Slide"],["fade","Fade"],["crossfade","Crossfade"]],domma:"carousel.animation"},{name:"animation-duration",type:"number",label:"Animation duration (ms)",domma:"carousel.animationDuration"},{name:"animation-easing",type:"text",label:"Animation easing",domma:"carousel.animationEasing"},{name:"height-mode",type:"select",label:"Image height",options:[["crop","Top-aligned crop (shortest image)"],["average","Average of shortest and tallest images"]],domma:"carousel.heightMode"},{name:"height",type:"number",label:"Fixed height (px, optional)",domma:"carousel.height"},{name:"columns",type:"number",label:"Card columns"},{name:"search",type:"checkbox",label:"Search (table)",default:!0},{name:"sortable",type:"checkbox",label:"Sortable (table)",default:!0},{name:"exportable",type:"checkbox",label:"CSV export"},{name:"page-size",type:"number",label:"Page size"},{name:"empty",type:"text",label:"Empty message"},{name:"scope",type:"select",label:"Scope",options:[["","All"],["mine","Current user"]]},{name:"cta",type:"lookup",source:"actions",label:"CTA action"},{name:"cta-label",type:"text",label:"CTA label"},{name:"cta-icon",type:"icon",label:"CTA icon"},{name:"cta-style",type:"select",label:"CTA style",options:[["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"]]},{name:"cta-confirm",type:"text",label:"CTA confirm text"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"view",label:"View",icon:"eye",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[view slug="products" display="table" limit="50" /]',attrs:[{name:"slug",type:"lookup",source:"views",label:"View"},{name:"display",type:"select",label:"Display",options:[["table","Table"],["cards","Cards"],["list","List"],["accordion","Accordion"],["timeline","Timeline"],["carousel","Carousel"],["block","Block"]]},{name:"limit",type:"number",label:"Limit"},{name:"fields",type:"text",label:"Fields (comma-separated)"},{name:"title-field",type:"text",label:"Title field"},{name:"image-field",type:"text",label:"Image field"},{name:"body-field",type:"text",label:"Body field"},{name:"mobile-popup",type:"checkbox",label:"Open carousel cards in a popup on mobile"},{name:"arrow-position",type:"select",label:"Arrow position",options:[["middle","Middle"],["top","Top"],["bottom","Bottom"]]},{name:"background",type:"colour",label:"Carousel background"},{name:"arrow-background",type:"colour",label:"Arrow background"},{name:"arrow-color",type:"colour",label:"Arrow colour"},{name:"autoplay",type:"checkbox",label:"Autoplay",domma:"carousel.autoplay"},{name:"interval",type:"number",label:"Interval (ms)",domma:"carousel.interval"},{name:"loop",type:"checkbox",label:"Loop",default:!0,domma:"carousel.loop"},{name:"animation",type:"select",label:"Animation",options:[["slide","Slide"],["fade","Fade"],["crossfade","Crossfade"]],domma:"carousel.animation"},{name:"animation-duration",type:"number",label:"Animation duration (ms)",domma:"carousel.animationDuration"},{name:"animation-easing",type:"text",label:"Animation easing",domma:"carousel.animationEasing"},{name:"height-mode",type:"select",label:"Image height",options:[["crop","Top-aligned crop (shortest image)"],["average","Average of shortest and tallest images"]],domma:"carousel.heightMode"},{name:"height",type:"number",label:"Fixed height (px, optional)",domma:"carousel.height"},{name:"columns",type:"number",label:"Card columns"},{name:"empty",type:"text",label:"Empty message"}]},{name:"block",label:"Block",icon:"layout",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[block template="post-card" title="My Post" /]',attrs:[{name:"template",type:"lookup",source:"blocks",label:"Template"}]},{name:"form",label:"Form",icon:"file-text",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[form name="contact" /]',attrs:[{name:"name",type:"lookup",source:"forms",label:"Form"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"cta",label:"CTA",icon:"mouse-pointer",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[cta action="send-welcome" entry="abc123" style="primary" label="Send" /]',attrs:[{name:"action",type:"lookup",source:"actions",label:"Action"},{name:"entry",type:"text",label:"Entry ID"},{name:"style",type:"select",label:"Style",options:[["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"]]},{name:"icon",type:"icon",label:"Icon"},{name:"size",type:"select",label:"Size",options:[["","Default"],["sm","Small"],["lg","Large"]]},{name:"confirm",type:"text",label:"Confirm text"},{name:"label",type:"text",label:"Label"}]},{name:"menu",label:"Menu",icon:"menu",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[menu slug="legal" /]',attrs:[{name:"slug",type:"lookup",source:"menus",label:"Menu"},{name:"location",type:"lookup",source:"menu-locations",label:"Location slot"},{name:"variant",type:"text",label:"Variant"},{name:"class",type:"text",label:"CSS class"},{name:"depth",type:"number",label:"Max depth"},{name:"orientation",type:"select",label:"Orientation",options:[["","Menu default"],["horizontal","Horizontal"],["vertical","Vertical"]]},{name:"float",type:"select",label:"Floating",options:[["","Menu default"],["no","Render inline here"]]}]},{name:"contents",label:"Page contents (this page)",icon:"list",category:"Layout",selfClosing:!0,container:!1,wrappable:!1,template:'[contents numbered="true" /]',actions:[{label:"Number the contents",icon:"hash",set:{numbered:"true"}},{label:"List H2 and H3 headings",icon:"list",set:{headings:"h2h3"}},{label:"Contents on the right",icon:"sidebar-right",set:{side:"right"}},{label:"Collapse the contents to a button",icon:"minimize",set:{collapsible:"true",collapsed:"true"}},{label:"Float the contents",icon:"move",set:{floating:"true","float-anchor":"TR",movable:"true"}},{label:"No contents on this page",icon:"eye-off",set:{hidden:"true"}},{label:"Remove this override",icon:"trash",remove:!0}],quickAttrs:["side","headings","numbered","title","collapsible","floating","hidden"],attrs:[{name:"side",type:"select",label:"Side",options:[["","Layout default"],["left","Left"],["right","Right"]]},{name:"width",type:"number",label:"Width (px, 160-480)"},{name:"headings",type:"select",label:"Headings",options:[["","Layout default"],["auto","Sections (H2s, else H3s)"],["h2","H2 only"],["h3","H3 only"],["h2h3","H2 and H3"]]},{name:"numbered",type:"select",label:"Numbered",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"title",type:"text",label:"Title above the list"},{name:"exclude",type:"text",label:"Leave out (headings, comma separated)"},{name:"sticky",type:"select",label:"Stays in view",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"scroll-spy",type:"select",label:"Marks the section being read",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"collapsible",type:"select",label:"Collapsible to a button",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"collapsed",type:"select",label:"Start collapsed",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"autohide",type:"select",label:"Autohide off its edge",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"floating",type:"select",label:"Floating panel",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"float-anchor",type:"select",label:"Float anchor",options:[["","Layout default"],["TL","Top left"],["TR","Top right"],["BL","Bottom left"],["BR","Bottom right"],["L","Left"],["R","Right"]]},{name:"movable",type:"select",label:"Visitors can move it",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"hidden",type:"select",label:"No contents on this page",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"hover",type:"text",label:"Hover effect"},{name:"selected",type:"text",label:"When selected"},{name:"accent",type:"colour",label:"Accent"},{name:"font",type:"text",label:"Font family"},{name:"font-size",type:"text",label:"Font size"},{name:"font-weight",type:"text",label:"Font weight"}]},{name:"navbar",label:"Navbar settings (this page)",icon:"sliders",category:"Layout",selfClosing:!0,container:!1,wrappable:!1,template:'[navbar collapsed="true" /]',actions:[{label:"Collapse the rail on this page",icon:"chevrons-right",set:{collapsible:"true",collapsed:"true",autohide:"false"}},{label:"Autohide the rail on this page",icon:"eye-off",set:{autohide:"true",collapsed:null}},{label:"Keep the rail open on this page",icon:"eye",set:{autohide:"false",collapsed:"false"}},{label:"Hide the bar on scroll on this page",icon:"arrow-up",set:{"hide-on-scroll":"true"}},{label:"Remove this override",icon:"trash",remove:!0}],quickAttrs:["position","width","collapsible","collapsed","autohide","hide-on-scroll"],attrs:[{name:"position",type:"select",label:"Position",options:[["","Menu default"],["sticky","Sticky"],["fixed","Fixed"],["static","Static"],["floating","Floating"]]},{name:"orientation",type:"select",label:"Orientation",options:[["","Menu default"],["horizontal","Horizontal"],["vertical","Vertical"]]},{name:"side",type:"select",label:"Rail side",options:[["","Menu default"],["left","Left"],["right","Right"]]},{name:"align",type:"select",label:"Alignment",options:[["","Menu default"],["left","Left"],["centre","Centre"],["right","Right"],["spread","Spread"]]},{name:"width",type:"number",label:"Rail width (px, 160-480)"},{name:"collapsible",type:"select",label:"Collapsible to icons",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"collapsed",type:"select",label:"Start collapsed",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"autohide",type:"select",label:"Autohide off-screen",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"hide-on-scroll",type:"select",label:"Hide on scroll (bar)",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"hover-open",type:"select",label:"Open dropdowns on hover",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"bar",type:"select",label:"Bar shape",options:[["","Menu default"],["pill","Pill"],["segmented","Segmented"],["underline","Underline glide"],["dock","Dock"],["neon","Neon"],["tabs","Tabs"],["tiles","Tiles"],["bubbles","Bubbles"],["brutalist","Brutalist"],["gradient","Gradient band"]]},{name:"shrink",type:"select",label:"Shrink on scroll",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"icons",type:"select",label:"Bar icons",options:[["","Menu default"],["rainbow","Rainbow"],["accent","Accent"]]},{name:"brand",type:"select",label:"Branding shape",options:[["","Menu default"],["pill","Pill"]]},{name:"strip",type:"select",label:"Bar background",options:[["","Menu default"],["none","None - floating pills"],["band","Strip - keep the band"]]},{name:"dropdown",type:"select",label:"Dropdown style",options:[["","Menu default"],["cards","Cards"]]},{name:"tiles",type:"select",label:"Icon tiles (cards)",options:[["","Menu default"],["rainbow","Rainbow"],["accent","Theme colour"],["neutral","Neutral"],["none","No tiles"]]},{name:"morph",type:"select",label:"Slide between cards",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"hover",type:"text",label:"Hover effect"},{name:"selected",type:"text",label:"When selected"},{name:"accent",type:"colour",label:"Highlight colour"},{name:"variant",type:"text",label:"Variant"},{name:"font",type:"text",label:"Font family"},{name:"font-size",type:"text",label:"Font size"},{name:"font-weight",type:"text",label:"Font weight"},{name:"letter-spacing",type:"text",label:"Letter spacing"},{name:"icon-size",type:"text",label:"Icon size"},{name:"float-anchor",type:"select",label:"Float anchor",options:[["","Menu default"],["TL","Top left"],["TR","Top right"],["BL","Bottom left"],["BR","Bottom right"],["L","Left"],["R","Right"]]},{name:"float-x",type:"number",label:"Float offset X (px)"},{name:"float-y",type:"number",label:"Float offset Y (px)"},{name:"float-width",type:"number",label:"Float width (px)"},{name:"float-collapsible",type:"select",label:"Float: collapsible",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"float-movable",type:"select",label:"Float: movable",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"class",type:"text",label:"CSS classes"}]},{name:"theme-switcher",label:"Theme switcher",icon:"palette",category:"Components",selfClosing:!0,container:!1,wrappable:!1,template:"[theme-switcher /]",attrs:[{name:"position",type:"select",label:"Position",options:[["","Inline - where the tag is"],["top-left","Top left"],["top-right","Top right"],["left-center","Left, centred"],["right-center","Right, centred"],["bottom-left","Bottom left"],["bottom-right","Bottom right"]]},{name:"offset-x",type:"number",label:"Offset from the side (px, pinned only)"},{name:"offset-y",type:"number",label:"Offset from the top/bottom (px, pinned only)"},{name:"themes",type:"text",label:"Themes (comma list - blank for the site's)"}]},{name:"icon",label:"Icon",icon:"icon-pick",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[icon name="arrow-right" /]',attrs:[{name:"name",type:"icon",label:"Icon name"},{name:"size",type:"number",label:"Size (px)"},{name:"color",type:"colour",label:"Colour"},{name:"class",type:"text",label:"CSS class"}]},{name:"image",label:"Image",icon:"image-add",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[image src="/media/photo.jpg" alt="" /]',custom:"image",quickAttrs:["zoom","align","width","shadow"],attrs:[{name:"src",type:"image",label:"Image",help:"The picture: choose it from Media, or type a /media/\u2026 path or an https:// address."},{name:"alt",type:"text",label:"Description (alt)",help:"What the picture shows, in a few words. Screen readers and search engines read it. Leave empty only for decoration."},{name:"caption",type:"text",label:"Caption",help:"Shown under the picture, and in the zoom view."},{name:"zoom",type:"checkbox",label:"Click to zoom",help:"Visitors click the picture to see it full size in a viewer: fitted first, then actual size with drag to pan. Best for screenshots with small text. Ignored when the picture has a link."},{name:"width",type:"text",label:"Width (480, 60%, 30rem)",help:"How wide the picture shows. A bare number is pixels. Empty: its own size, never wider than the column."},{name:"align",type:"select",label:"Alignment",options:[["","Default (left)"],["center","Centre"],["right","Right"],["float-left","Float left (text wraps)"],["float-right","Float right (text wraps)"]],help:"Floats let the text run beside the picture; on phones they stack."},{name:"group",type:"text",label:"Zoom group",help:"Give zoomable pictures the same group name and the viewer steps between them with arrows - a gallery or a tour."},{name:"zoom-src",type:"image",label:"Full-size file (zoom)",help:"Optional: a larger file for the zoom view, when the page shows a smaller copy."},{name:"title",type:"text",label:"Hover text (title)"},{name:"max-width",type:"text",label:"Max width (800, 50%)"},{name:"height",type:"text",label:"Height (240, 20rem)",help:"A set height crops the picture to fill the box (see Fit)."},{name:"fit",type:"select",label:"Fit (with a height)",options:[["","Fill and crop (default)"],["contain","Show it all"],["fill","Stretch"],["none","Actual size"],["scale-down","Shrink only"]]},{name:"radius",type:"select",label:"Corners",options:[["","Square"],["sm","Slightly rounded"],["md","Rounded"],["lg","Very rounded"],["full","Circle / pill"]]},{name:"border",type:"checkbox",label:"Border"},{name:"shadow",type:"select",label:"Shadow",options:[["","None"],["sm","Small"],["md","Medium"],["lg","Large"]]},{name:"link",type:"url",label:"Link to",help:"Clicking the picture goes here instead of zooming."},{name:"target",type:"select",label:"Open link in",options:[["","Same tab"],["_blank","New tab"]]},{name:"loading",type:"select",label:"Loading",options:[["","When scrolled near (lazy)"],["eager","Straight away (top of page)"]]},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"map",label:"Map",icon:"map-pin",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[map address="10 Downing Street, London" zoom="15" /]',attrs:[{name:"pin",type:"text",label:"Pin (latitude, longitude)"},{name:"lat",type:"number",label:"Latitude"},{name:"lon",type:"number",label:"Longitude"},{name:"address",type:"text",label:"Address"},{name:"postcode",type:"text",label:"Postcode"},{name:"zoom",type:"number",label:"Zoom (1-20)"},{name:"title",type:"text",label:"Title"},{name:"caption",type:"text",label:"Caption"},{name:"ratio",type:"select",label:"Aspect ratio",options:[["16:9","16:9"],["4:3","4:3"],["1:1","1:1"],["21:9","21:9"]]},{name:"width",type:"text",label:"Width"},{name:"align",type:"select",label:"Alignment",options:[["left","Left"],["center","Centre"],["right","Right"]]}]},{name:"embed",label:"Embed",icon:"video",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[embed url="https://youtu.be/dQw4w9WgXcQ" /]',custom:"embed",attrs:[{name:"url",type:"url",label:"URL"},{name:"ratio",type:"select",label:"Aspect ratio",options:[["16:9","16:9"],["4:3","4:3"],["1:1","1:1"],["21:9","21:9"],["9:16","9:16"],["3:4","3:4"]]},{name:"title",type:"text",label:"Title / caption"},{name:"width",type:"text",label:"Width"},{name:"align",type:"select",label:"Alignment",options:[["left","Left"],["center","Centre"],["right","Right"]]},{name:"autoplay",type:"checkbox",label:"Autoplay"},{name:"loop",type:"checkbox",label:"Loop"},{name:"muted",type:"checkbox",label:"Muted"}]}];for(const e of SHORTCODES){e.attrs||(e.attrs=[]);for(const a of o)e.attrs.some(t=>t.name===a.name)||e.attrs.push(a)}export const EDITOR_TOOLS=[{name:"colourpick",label:"Colour picker",icon:"colour-picker",category:"Media",custom:"colourpick"},{name:"component",label:"Component",icon:"component",category:"Components",custom:"component"},{name:"scribe",label:"Scribe",icon:"scribe-insert",category:"Content",custom:"scribe"},{name:"highlight-text",label:"Highlight text",icon:"star",category:"Content",custom:"highlighttext",wrappable:!0}];
@@ -1 +1 @@
1
- export const FREQUENT_KEY="frequent",FREQUENT_MAX=12;export function findLeaf(e,t){for(const r of e||[])if(!(!r||r.type||r.hidden)){if(Array.isArray(r.items)&&r.items.length){const n=findLeaf(r.items,t);if(n)return n}else if(r.url===t)return r}return null}export function frequentFolder(e,t,{hidden:r=!1}={}){const n=[];for(const o of Array.isArray(t)?t:[]){const i=typeof o=="string"&&o?findLeaf(e,o):null;i&&n.push({text:i.text,url:i.url,...i.icon&&{icon:i.icon},...i.colour&&{colour:i.colour}})}return n.length?{text:"Frequent",key:FREQUENT_KEY,icon:"star",items:n,frequent:!0}:r?null:{text:"Frequent",key:FREQUENT_KEY,icon:"star",items:[],frequent:!0,empty:!0}}export function addFrequent(e,t){const r=(Array.isArray(e)?e:[]).filter(n=>typeof n=="string"&&n);return!t||r.includes(t)||r.length>=12?r:[...r,t]}export function removeFrequent(e,t){return(Array.isArray(e)?e:[]).filter(r=>r!==t)}export function moveFrequent(e,t,r){const n=Array.isArray(e)?[...e]:[],o=n.indexOf(t),i=o+r;return o<0||i<0||i>=n.length||([n[o],n[i]]=[n[i],n[o]]),n}export function storageKey(e){const t=e&&(e.id||e._id||e.email);return`sidebar.frequent.${t?String(t):"anon"}`}export function readFrequent(e){try{const t=S.get(storageKey(e));return Array.isArray(t)?t.filter(r=>typeof r=="string"&&r):[]}catch{return[]}}export function readFrequentHidden(e){try{return S.get(`${storageKey(e)}.hidden`)===!0}catch{return!1}}export function writeFrequentHidden(e,t){try{return S.set(`${storageKey(e)}.hidden`,!!t),!0}catch{return!1}}export function writeFrequent(e,t){try{return S.set(storageKey(e),Array.isArray(t)?t:[]),!0}catch{return!1}}let u=null;export function resetFrequentSync(){u=null}export function saveFrequent(e,t){return e.put("/sidebar/frequent",{urls:readFrequent(t),hidden:readFrequentHidden(t)})}export async function syncFrequent(e,t){const r=t&&(t.id||t._id||t.email);if(!r||u===String(r))return;const n=await e.get("/sidebar/frequent");if(!(!n||typeof n!="object")){if(u=String(r),!n.saved){(readFrequent(t).length||readFrequentHidden(t))&&await saveFrequent(e,t);return}writeFrequent(t,Array.isArray(n.urls)?n.urls:[]),writeFrequentHidden(t,n.hidden===!0)}}
1
+ export const FREQUENT_KEY="frequent",FREQUENT_MAX=16;export function findLeaf(e,t){for(const r of e||[])if(!(!r||r.type||r.hidden)){if(Array.isArray(r.items)&&r.items.length){const n=findLeaf(r.items,t);if(n)return n}else if(r.url===t)return r}return null}export function frequentFolder(e,t,{hidden:r=!1}={}){const n=[];for(const o of Array.isArray(t)?t:[]){const i=typeof o=="string"&&o?findLeaf(e,o):null;i&&n.push({text:i.text,url:i.url,...i.icon&&{icon:i.icon},...i.colour&&{colour:i.colour}})}return n.length?{text:"Frequent",key:FREQUENT_KEY,icon:"star",items:n,frequent:!0}:r?null:{text:"Frequent",key:FREQUENT_KEY,icon:"star",items:[],frequent:!0,empty:!0}}export function addFrequent(e,t){const r=(Array.isArray(e)?e:[]).filter(n=>typeof n=="string"&&n);return!t||r.includes(t)||r.length>=16?r:[...r,t]}export function removeFrequent(e,t){return(Array.isArray(e)?e:[]).filter(r=>r!==t)}export function moveFrequent(e,t,r){const n=Array.isArray(e)?[...e]:[],o=n.indexOf(t),i=o+r;return o<0||i<0||i>=n.length||([n[o],n[i]]=[n[i],n[o]]),n}export function storageKey(e){const t=e&&(e.id||e._id||e.email);return`sidebar.frequent.${t?String(t):"anon"}`}export function readFrequent(e){try{const t=S.get(storageKey(e));return Array.isArray(t)?t.filter(r=>typeof r=="string"&&r):[]}catch{return[]}}export function readFrequentHidden(e){try{return S.get(`${storageKey(e)}.hidden`)===!0}catch{return!1}}export function writeFrequentHidden(e,t){try{return S.set(`${storageKey(e)}.hidden`,!!t),!0}catch{return!1}}export function writeFrequent(e,t){try{return S.set(storageKey(e),Array.isArray(t)?t:[]),!0}catch{return!1}}let u=null;export function resetFrequentSync(){u=null}export function saveFrequent(e,t){return e.put("/sidebar/frequent",{urls:readFrequent(t),hidden:readFrequentHidden(t)})}export async function syncFrequent(e,t){const r=t&&(t.id||t._id||t.email);if(!r||u===String(r))return;const n=await e.get("/sidebar/frequent");if(!(!n||typeof n!="object")){if(u=String(r),!n.saved){(readFrequent(t).length||readFrequentHidden(t))&&await saveFrequent(e,t);return}writeFrequent(t,Array.isArray(n.urls)?n.urls:[]),writeFrequentHidden(t,n.hidden===!0)}}
@@ -1 +1 @@
1
- export const prefsKey=(t,e)=>`dm.notify.${t||"anon"}.${e}`,marksKey=(t,e)=>`dm.notify.seen.${t||"anon"}.${e}`;const y=50,b=200;export function cleanNotify(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const e={};if(t.marks&&typeof t.marks=="object"&&!Array.isArray(t.marks))for(const[o,s]of Object.entries(t.marks).slice(0,50)){const r=Number(s);Number.isFinite(r)&&o.length<=200&&!["__proto__","constructor","prototype"].includes(o)&&(e[o]=r)}if(!Object.keys(e).length)return null;const n=o=>String(o??"").replace(/\s+/g," ").trim().slice(0,200);return{marks:e,title:n(t.title)||"Something new",body:n(t.body)}}export function compareMarks(t,e){const n=t&&typeof t=="object"?t:{},o={...n};let s=!1;for(const[r,c]of Object.entries(e)){const i=Number(n[r]);Number.isFinite(i)?c>i&&(s=!0,o[r]=c):o[r]=c}return{rose:s,next:o}}export function readNotifyPrefs(t,e,n=globalThis.S){try{const o=n?.get(prefsKey(t,e));return{popup:o?.popup===!0,sound:o?.sound===!0}}catch{return{popup:!1,sound:!1}}}export function writeNotifyPrefs(t,e,n,o=globalThis.S){o.set(prefsKey(t,e),{popup:n?.popup===!0,sound:n?.sound===!0})}export function playChime(){try{const t=globalThis.AudioContext||globalThis.webkitAudioContext;if(!t)return;const e=new t,n=e.currentTime;[[880,0],[1318.5,.12]].forEach(([o,s])=>{const r=e.createOscillator(),c=e.createGain();r.type="sine",r.frequency.value=o,c.gain.setValueAtTime(1e-4,n+s),c.gain.exponentialRampToValueAtTime(.18,n+s+.02),c.gain.exponentialRampToValueAtTime(1e-4,n+s+.35),r.connect(c).connect(e.destination),r.start(n+s),r.stop(n+s+.4)}),setTimeout(()=>{try{e.close()}catch{}},1e3)}catch{}}export function noticeFromCount(t,e,n,o={}){const s=o.store??globalThis.S,r=cleanNotify(n);if(!r||!s)return!1;let c=null;try{c=s.get(marksKey(t,e))}catch{c=null}const{rose:i,next:f}=compareMarks(c,r.marks);try{s.set(marksKey(t,e),f)}catch{}if(!i)return!1;const u=readNotifyPrefs(t,e,s);let a=!1;const l=o.Notification??globalThis.Notification;if(u.popup&&l&&l.permission==="granted")try{const p=new l(r.title,{body:r.body,tag:`dm-notify:${e}`});p.onclick=()=>{try{globalThis.focus?.()}catch{}(o.open??(m=>{globalThis.location.hash=m}))(e),p.close?.()},a=!0}catch{}return u.sound&&((o.chime??playChime)(),a=!0),a}
1
+ export const prefsKey=(t,e)=>`dm.notify.${t||"anon"}.${e}`,marksKey=(t,e)=>`dm.notify.seen.${t||"anon"}.${e}`;const y=1e4,b=200;export function cleanNotify(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const e={};if(t.marks&&typeof t.marks=="object"&&!Array.isArray(t.marks))for(const[o,s]of Object.entries(t.marks).slice(0,1e4)){const r=Number(s);Number.isFinite(r)&&o.length<=200&&!["__proto__","constructor","prototype"].includes(o)&&(e[o]=r)}if(!Object.keys(e).length)return null;const n=o=>String(o??"").replace(/\s+/g," ").trim().slice(0,200);return{marks:e,title:n(t.title)||"Something new",body:n(t.body)}}export function compareMarks(t,e){const n=t&&typeof t=="object"?t:{},o={...n};let s=!1;for(const[r,c]of Object.entries(e)){const i=Number(n[r]);Number.isFinite(i)?c>i&&(s=!0,o[r]=c):o[r]=c}return{rose:s,next:o}}export function readNotifyPrefs(t,e,n=globalThis.S){try{const o=n?.get(prefsKey(t,e));return{popup:o?.popup===!0,sound:o?.sound===!0}}catch{return{popup:!1,sound:!1}}}export function writeNotifyPrefs(t,e,n,o=globalThis.S){o.set(prefsKey(t,e),{popup:n?.popup===!0,sound:n?.sound===!0})}export function playChime(){try{const t=globalThis.AudioContext||globalThis.webkitAudioContext;if(!t)return;const e=new t,n=e.currentTime;[[880,0],[1318.5,.12]].forEach(([o,s])=>{const r=e.createOscillator(),c=e.createGain();r.type="sine",r.frequency.value=o,c.gain.setValueAtTime(1e-4,n+s),c.gain.exponentialRampToValueAtTime(.18,n+s+.02),c.gain.exponentialRampToValueAtTime(1e-4,n+s+.35),r.connect(c).connect(e.destination),r.start(n+s),r.stop(n+s+.4)}),setTimeout(()=>{try{e.close()}catch{}},1e3)}catch{}}export function noticeFromCount(t,e,n,o={}){const s=o.store??globalThis.S,r=cleanNotify(n);if(!r||!s)return!1;let c=null;try{c=s.get(marksKey(t,e))}catch{c=null}const{rose:i,next:f}=compareMarks(c,r.marks);try{s.set(marksKey(t,e),f)}catch{}if(!i)return!1;const u=readNotifyPrefs(t,e,s);let a=!1;const l=o.Notification??globalThis.Notification;if(u.popup&&l&&l.permission==="granted")try{const p=new l(r.title,{body:r.body,tag:`dm-notify:${e}`});p.onclick=()=>{try{globalThis.focus?.()}catch{}(o.open??(m=>{globalThis.location.hash=m}))(e),p.close?.()},a=!0}catch{}return u.sound&&((o.chime??playChime)(),a=!0),a}
@@ -1,7 +1,7 @@
1
- import{api as g,getUser as w,isAuthenticated as ke}from"../api.js";import{createRequestQueue as qe}from"./background-requests.js";import{requestSidebarCounts as Ce}from"./sidebar-counts.js";import{beginSidebarCounts as Ae,publishSidebarCount as Fe}from"./sidebar-count-cache.js";import{isPathAllowed as Le}from"./admin-scope.js";import{cleanNotify as Ee,noticeFromCount as je}from"./sidebar-notify.js";import{colourToCss as te,applyFloat as Be,applyHighlight as Oe,itemHighlightAttrs as Me}from"/public/js/menu-decor.mjs?v=20261014-menu-entrance";import{placeTools as Te,ensureLockedTools as Ne,managePluginsItem as He,stripItemByUrl as Re,insertFoldersBeforeSystem as Ie,pruneEmptyToolsFolder as Pe,sidebarStateKey as ne,canAny as W,filterByPermission as _e,MANAGE_PLUGINS_URL as se}from"./sidebar-grouping.js";import{arrangeButtonMarkup as Ue,canArrange as ze,startArrange as We}from"./sidebar-arrange.js";import{collapseButtonMarkup as De,wireSidebarSize as Ge,COLLAPSED_WIDTH as Ke}from"./sidebar-size.js";import{FREQUENT_MAX as oe,addFrequent as Ve,frequentFolder as Xe,moveFrequent as ie,readFrequent as K,readFrequentHidden as Ze,removeFrequent as Je,saveFrequent as Ye,syncFrequent as Qe,writeFrequent as et,writeFrequentHidden as ae}from"./sidebar-frequent.js";import{hotkeyFor as re,hotkeyTitle as tt,setHotkeyTree as nt}from"./hotkeys-ui.js";import{hotkeyLabel as st}from"./hotkeys.js";function m(e){return String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const ot=[{text:"Dashboard",url:"#/",icon:"home"},{text:"Site menus",url:"#/menus",icon:"menu",permission:"menus"}];async function it(e){if(!W(e,"projects"))return[];let n=[];try{n=await g.projects.listWithCounts()}catch{return[]}if(!Array.isArray(n))return[];const t=[{key:"pages",text:"Pages",icon:"file-text",path:"/pages"},{key:"collections",text:"Collections",icon:"database",path:"/collections"},{key:"forms",text:"Forms",icon:"layout",path:"/forms"},{key:"actions",text:"Actions",icon:"zap",path:"/actions"},{key:"menus",text:"Site menus",icon:"menu",path:"/menus"},{key:"blocks",text:"Blocks",icon:"box",path:"/blocks"},{key:"components",text:"Components",icon:"component",path:"/components"},{key:"views",text:"Views",icon:"eye",path:"/views"},{key:"roles",text:"Roles",icon:"shield",path:"/roles"},{key:"users",text:"Users",icon:"users",path:"/users"},{key:"apis",text:"APIs",icon:"code",path:"/apis"}];return n.map(o=>{const r="#/projects/"+encodeURIComponent(o.slug),u=o.counts||{},i=[{text:"Overview",url:r,icon:o.icon||"folder"}];for(const d of t){const l=Number(u[d.key])||0;l<=0||i.push({text:`${d.text} (${l})`,url:r+d.path,icon:d.icon})}i.push({text:"Settings",url:r+"/settings",icon:"settings"});const a=o.enabled===!1;return{text:o.name||o.slug,key:`project.${o.slug}`,icon:o.icon||"folder",items:i,...a&&{colour:"neutral",badge:{text:"off"}}}})}function at(e,n){for(const t of e)if(!t.hidden&&(t.key==="projects"||!t.key&&(t.text||"").toLowerCase()==="projects")){t.items=Array.isArray(t.items)?t.items.slice():[],t.items.push(...n);return}}function le(e,n){const t=de.includes(n.tone)?n.tone:"info",o=n.label||String(n.count);n.details?R.set(e,n.details):R.delete(e);const s=!n.inventory&&j.some(r=>r.url===e&&!r.inventory)?" data-live":"";return`<span class="sidebar-badge sidebar-badge--${t}" data-count-for="${m(e)}"${s} data-badge-label="${m(o)}" aria-label="${m(o)}">${m(String(n.count))}</span>`}function ce(e){for(const n of e.querySelectorAll("details")){const t=n.querySelector(":scope > summary");if(!t)continue;let o=0,s=!1;const r=[];for(const l of n.querySelectorAll(":scope > .sidebar-children .sidebar-badge[data-live]")){const f=Number(l.textContent)||0;f&&(o+=f,s||(s=l.classList.contains("sidebar-badge--danger")),r.push({text:l.closest("a")?.querySelector(".sidebar-text")?.textContent.trim()??"",meta:l.dataset.badgeLabel,tone:l.classList.contains("sidebar-badge--danger")?"danger":void 0}))}const u=`folder:${n.dataset.stateKey||t.textContent.trim()}`;let i=t.querySelector(":scope > .sidebar-badge--sum");if(!o){i?.remove(),R.delete(u);continue}i||(i=document.createElement("span"),t.querySelector(".sidebar-text")?.after(i));const a=t.querySelector(".sidebar-text")?.textContent.trim()||"This folder",d=r.map(l=>`${l.text}: ${l.meta}`).join(" \xB7 ");i.className=`sidebar-badge sidebar-badge--sum sidebar-badge--${s?"danger":"info"}`,i.dataset.countFor=u,i.dataset.badgeLabel=d,i.setAttribute("aria-label",d),i.textContent=String(o),R.set(u,{title:a,items:r})}}const R=new Map;function rt(e,n){if(!e.url||!n)return"";const t=n[e.url];return!t||!(t.count>0)&&!t.showZero?"":le(e.url,t)}const de=["info","attention","danger","live"],lt={"#/pages":["page","pages"],"#/media":["file in the media library","files in the media library"],"#/menus":["menu","menus"],"#/context-menus":["context menu","context menus"],"#/theme":["element override in the theme","element overrides in the theme"],"#/collections":["collection","collections"],"#/forms":["form","forms"],"#/views":["view","views"],"#/actions":["action","actions"],"#/blocks":["block","blocks"],"#/components":["component","components"],"#/users":["user","users"],"#/plugins":["plugin installed","plugins installed"],"#/system/notifications":["unread notification","unread notifications"]};function D(e,{fallbackLabel:n="",tone:t="info"}={}){const o=Number(typeof e=="object"&&e!==null?e.count:e);if(!Number.isFinite(o)||o<0)return null;const s=typeof e?.label=="string"&&e.label||(n?`${o} - ${n}`:String(o)),r={count:Math.round(o),label:s,tone:de.includes(e?.tone)?e.tone:t};e?.details&&typeof e.details=="object"&&(r.details=e.details),e?.inventory===!0&&(r.inventory=!0),e?.showZero===!0&&(r.showZero=!0);const u=Ee(e?.notify);return u&&(r.notify=u),r}function ue(e,n,t=null,{inFrequent:o=!1}={}){if(e&&e.type==="separator")return'<hr class="sidebar-divider">';if(e&&e.type==="theme-switcher")return"";if(e&&e.type==="spacer"){const b=["xs","sm","md","lg","xl","flex"].includes(e.size)?e.size:"md";return`<div class="sidebar-spacer sidebar-spacer--${m(b)}" aria-hidden="true"></div>`}const s=String(e.text||"?").trim().charAt(0).toUpperCase()||"?",r=e.icon?`<span data-icon="${m(e.icon)}"></span>`:`<span class="sidebar-initial" aria-hidden="true">${m(s)}</span>`,u=m(e.text||""),i=e.url?m(e.url):"",a=Array.isArray(e.items)&&e.items.length>0,d=e.colour?te(e.colour):"",l=Me(e),f=[l.hover&&` data-menu-item-hover="${m(l.hover)}"`,l.active&&` data-menu-item-active="${m(l.active)}"`].filter(Boolean).join(""),h=[d&&`color:${m(d)}`,l.accent&&`--dm-menu-highlight:${m(l.accent)}`].filter(Boolean).join(";"),v=h?` style="${h}"`:"",k=e.url?tt(e.url,e.text||"",{inFrequent:o}):"",q=k?` title="${m(k)}"`:"";let F="";if(e.badge&&e.badge.text!=null&&e.badge.text!==""){const b=e.badge.variant?te(e.badge.variant):"";F=`<span class="dm-menu-badge"${b?` style="background:${m(b)};color:var(--dm-text-inverse,#fff)"`:""}>${m(String(e.badge.text))}</span>`}if(e.frequent&&e.empty){const b=ne(e,t),A=S.get(b)!==!1;return`<details data-state-key="${m(b)}"${A?" open":""} data-frequent data-frequent-empty>
1
+ import{syncThemeAwareLogos as qe}from"./theme-aware-logo.js";import{api as g,getUser as k,isAuthenticated as Ce}from"../api.js";import{createRequestQueue as Ae}from"./background-requests.js";import{requestSidebarCounts as Le}from"./sidebar-counts.js";import{beginSidebarCounts as Fe,publishSidebarCount as Ee}from"./sidebar-count-cache.js";import{isPathAllowed as je}from"./admin-scope.js";import{cleanNotify as Be,noticeFromCount as Oe}from"./sidebar-notify.js";import{colourToCss as te,applyFloat as Te,applyHighlight as Me,itemHighlightAttrs as Ne}from"/public/js/menu-decor.mjs?v=20261014-menu-entrance";import{placeTools as He,ensureLockedTools as Re,managePluginsItem as Ie,stripItemByUrl as Pe,insertFoldersBeforeSystem as _e,pruneEmptyToolsFolder as Ue,sidebarStateKey as ne,canAny as G,filterByPermission as ze,MANAGE_PLUGINS_URL as se}from"./sidebar-grouping.js";import{arrangeButtonMarkup as De,canArrange as We,startArrange as Ge}from"./sidebar-arrange.js";import{collapseButtonMarkup as Ke,wireSidebarSize as Ve,COLLAPSED_WIDTH as Xe}from"./sidebar-size.js";import{FREQUENT_MAX as oe,addFrequent as Ze,frequentFolder as Je,moveFrequent as ie,readFrequent as V,readFrequentHidden as Ye,removeFrequent as Qe,saveFrequent as et,syncFrequent as tt,writeFrequent as nt,writeFrequentHidden as ae}from"./sidebar-frequent.js";import{hotkeyFor as re,hotkeyTitle as st,setHotkeyTree as ot}from"./hotkeys-ui.js";import{hotkeyLabel as it}from"./hotkeys.js";function m(e){return String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const at=[{text:"Dashboard",url:"#/",icon:"home"},{text:"Site menus",url:"#/menus",icon:"menu",permission:"menus"}];async function rt(e){if(!G(e,"projects"))return[];let n=[];try{n=await g.projects.listWithCounts()}catch{return[]}if(!Array.isArray(n))return[];const t=[{key:"pages",text:"Pages",icon:"file-text",path:"/pages"},{key:"collections",text:"Collections",icon:"database",path:"/collections"},{key:"forms",text:"Forms",icon:"layout",path:"/forms"},{key:"actions",text:"Actions",icon:"zap",path:"/actions"},{key:"menus",text:"Site menus",icon:"menu",path:"/menus"},{key:"blocks",text:"Blocks",icon:"box",path:"/blocks"},{key:"components",text:"Components",icon:"component",path:"/components"},{key:"views",text:"Views",icon:"eye",path:"/views"},{key:"roles",text:"Roles",icon:"shield",path:"/roles"},{key:"users",text:"Users",icon:"users",path:"/users"},{key:"apis",text:"APIs",icon:"code",path:"/apis"}];return n.map(o=>{const r="#/projects/"+encodeURIComponent(o.slug),u=o.counts||{},i=[{text:"Overview",url:r,icon:o.icon||"folder"}];for(const d of t){const l=Number(u[d.key])||0;l<=0||i.push({text:`${d.text} (${l})`,url:r+d.path,icon:d.icon})}i.push({text:"Settings",url:r+"/settings",icon:"settings"});const a=o.enabled===!1;return{text:o.name||o.slug,key:`project.${o.slug}`,icon:o.icon||"folder",items:i,...a&&{colour:"neutral",badge:{text:"off"}}}})}function lt(e,n){for(const t of e)if(!t.hidden&&(t.key==="projects"||!t.key&&(t.text||"").toLowerCase()==="projects")){t.items=Array.isArray(t.items)?t.items.slice():[],t.items.push(...n);return}}function le(e,n){const t=de.includes(n.tone)?n.tone:"info",o=n.label||String(n.count);n.details?I.set(e,n.details):I.delete(e);const s=!n.inventory&&j.some(r=>r.url===e&&!r.inventory)?" data-live":"";return`<span class="sidebar-badge sidebar-badge--${t}" data-count-for="${m(e)}"${s} data-badge-label="${m(o)}" aria-label="${m(o)}">${m(String(n.count))}</span>`}function ce(e){for(const n of e.querySelectorAll("details")){const t=n.querySelector(":scope > summary");if(!t)continue;let o=0,s=!1;const r=[];for(const l of n.querySelectorAll(":scope > .sidebar-children .sidebar-badge[data-live]")){const f=Number(l.textContent)||0;f&&(o+=f,s||(s=l.classList.contains("sidebar-badge--danger")),r.push({text:l.closest("a")?.querySelector(".sidebar-text")?.textContent.trim()??"",meta:l.dataset.badgeLabel,tone:l.classList.contains("sidebar-badge--danger")?"danger":void 0}))}const u=`folder:${n.dataset.stateKey||t.textContent.trim()}`;let i=t.querySelector(":scope > .sidebar-badge--sum");if(!o){i?.remove(),I.delete(u);continue}i||(i=document.createElement("span"),t.querySelector(".sidebar-text")?.after(i));const a=t.querySelector(".sidebar-text")?.textContent.trim()||"This folder",d=r.map(l=>`${l.text}: ${l.meta}`).join(" \xB7 ");i.className=`sidebar-badge sidebar-badge--sum sidebar-badge--${s?"danger":"info"}`,i.dataset.countFor=u,i.dataset.badgeLabel=d,i.setAttribute("aria-label",d),i.textContent=String(o),I.set(u,{title:a,items:r})}}const I=new Map;function ct(e,n){if(!e.url||!n)return"";const t=n[e.url];return!t||!(t.count>0)&&!t.showZero?"":le(e.url,t)}const de=["info","attention","danger","live"],dt={"#/pages":["page","pages"],"#/media":["file in the media library","files in the media library"],"#/menus":["menu","menus"],"#/context-menus":["context menu","context menus"],"#/theme":["element override in the theme","element overrides in the theme"],"#/collections":["collection","collections"],"#/forms":["form","forms"],"#/views":["view","views"],"#/actions":["action","actions"],"#/blocks":["block","blocks"],"#/components":["component","components"],"#/users":["user","users"],"#/plugins":["plugin installed","plugins installed"],"#/system/notifications":["unread notification","unread notifications"]};function K(e,{fallbackLabel:n="",tone:t="info"}={}){const o=Number(typeof e=="object"&&e!==null?e.count:e);if(!Number.isFinite(o)||o<0)return null;const s=typeof e?.label=="string"&&e.label||(n?`${o} - ${n}`:String(o)),r={count:Math.round(o),label:s,tone:de.includes(e?.tone)?e.tone:t};e?.details&&typeof e.details=="object"&&(r.details=e.details),e?.inventory===!0&&(r.inventory=!0),e?.showZero===!0&&(r.showZero=!0);const u=Be(e?.notify);return u&&(r.notify=u),r}function ue(e,n,t=null,{inFrequent:o=!1}={}){if(e&&e.type==="separator")return'<hr class="sidebar-divider">';if(e&&e.type==="theme-switcher")return"";if(e&&e.type==="spacer"){const b=["xs","sm","md","lg","xl","flex"].includes(e.size)?e.size:"md";return`<div class="sidebar-spacer sidebar-spacer--${m(b)}" aria-hidden="true"></div>`}const s=String(e.text||"?").trim().charAt(0).toUpperCase()||"?",r=e.icon?`<span data-icon="${m(e.icon)}"></span>`:`<span class="sidebar-initial" aria-hidden="true">${m(s)}</span>`,u=m(e.text||""),i=e.url?m(e.url):"",a=Array.isArray(e.items)&&e.items.length>0,d=e.colour?te(e.colour):"",l=Ne(e),f=[l.hover&&` data-menu-item-hover="${m(l.hover)}"`,l.active&&` data-menu-item-active="${m(l.active)}"`].filter(Boolean).join(""),h=[d&&`color:${m(d)}`,l.accent&&`--dm-menu-highlight:${m(l.accent)}`].filter(Boolean).join(";"),v=h?` style="${h}"`:"",q=e.url?st(e.url,e.text||"",{inFrequent:o}):"",C=q?` title="${m(q)}"`:"";let F="";if(e.badge&&e.badge.text!=null&&e.badge.text!==""){const b=e.badge.variant?te(e.badge.variant):"";F=`<span class="dm-menu-badge"${b?` style="background:${m(b)};color:var(--dm-text-inverse,#fff)"`:""}>${m(String(e.badge.text))}</span>`}if(e.frequent&&e.empty){const b=ne(e,t),A=S.get(b)!==!1;return`<details data-state-key="${m(b)}"${A?" open":""} data-frequent data-frequent-empty>
2
2
  <summary${v}>${r} <span class="sidebar-text">${u}</span></summary>
3
3
  <div class="sidebar-children"><p class="sidebar-frequent-empty">Right-click any Tool and choose <strong>Add to Frequent</strong> to keep it here.</p></div>
4
- </details>`}if(a){const b=ne(e,t),A=S.get(b)!==!1,B=e.items.map(I=>ue(I,n,b,{inFrequent:!!e.frequent})).join(""),L=e.frequent?' data-frequent title="Your Frequent Tools - right-click any Tool to add or remove it"':"";return`<details data-state-key="${m(b)}"${A?" open":""}${L}>
5
- <summary${v}${q}>${r} <span class="sidebar-text">${u}</span>${F}</summary>
4
+ </details>`}if(a){const b=ne(e,t),A=S.get(b)!==!1,B=e.items.map(P=>ue(P,n,b,{inFrequent:!!e.frequent})).join(""),L=e.frequent?' data-frequent title="Your Frequent Tools - right-click any Tool to add or remove it"':"";return`<details data-state-key="${m(b)}"${A?" open":""}${L}>
5
+ <summary${v}${C}>${r} <span class="sidebar-text">${u}</span>${F}</summary>
6
6
  <div class="sidebar-children">${B}</div>
7
- </details>`}return`<a href="${i}" class="sidebar-link" data-url="${i}"${v}${f}${q}>${r} <span class="sidebar-text">${u}</span>${rt(e,n)}${F}</a>`}async function ct(e=[],n=[],t=null){const o=y=>y.then(C=>Array.isArray(C)?C.length:Array.isArray(C?.entries)?C.entries.length:0).catch(()=>0),s=fe(e,t),r=new Set(s.map(y=>y.url)),u={pages:"#/pages",media:"#/media",menus:"#/menus","context-menus":"#/context-menus",theme:"#/theme",collections:"#/collections",forms:"#/forms",views:"#/views",actions:"#/actions",blocks:"#/blocks",components:"#/components",users:"#/users",plugins:"#/plugins",notifications:"#/system/notifications"},i=(y,C)=>W(n,y)&&!r.has(u[y])?C():Promise.resolve(0),[a,d,l,f,h,v,k,q,F,b,A,B,L,I]=await Promise.all([i("pages",()=>o(g.pages.list())),i("media",()=>o(g.media.list())),i("menus",()=>o(g.menus.list())),i("context-menus",()=>o(g.contextMenus.list())),i("theme",()=>g.theme.get().then(y=>(y?.overrides||[]).length).catch(()=>0)),i("collections",()=>o(g.collections.list())),i("forms",()=>o(g.forms.list())),i("views",()=>o(g.views.list())),i("actions",()=>o(g.actions.list())),i("blocks",()=>o(g.blocks.list())),i("components",()=>o(g.components.list())),i("users",()=>o(g.users.list())),i("plugins",()=>o(g.plugins.list())),i("notifications",()=>g.system?.notifications?.unreadCount?.().then(y=>y?.count??0).catch(()=>0)??Promise.resolve(0))]),P=await pe(s),U={"#/pages":a,"#/media":d,"#/menus":l,"#/context-menus":f,"#/theme":h,"#/collections":v,"#/forms":k,"#/views":q,"#/actions":F,"#/blocks":b,"#/components":A,"#/users":B,"#/plugins":L,"#/system/notifications":I},z={};for(const[y,C]of Object.entries(U)){if(r.has(y))continue;const[G,Y]=lt[y]??["item","items"],O=D(C);O&&(z[y]={...O,label:`${O.count} ${O.count===1?G:Y}`})}return{...z,...P}}let j=[];const dt="dm:sidebar-count",ut=6e4,ft=qe(4);function fe(e=[],n=null){const t=[],o=s=>{if(s&&!(n&&typeof s.url=="string"&&s.url.startsWith("#/")&&!Le(n,s.url.slice(1)))){s.url&&typeof s.countUrl=="string"&&s.countUrl&&t.push({url:s.url,countUrl:s.countUrl,text:s.text||"",countLabel:s.countLabel||"",inventory:s.inventory===!0});for(const r of[...s.children||[],...s.items||[]])o(r)}};for(const s of e??[])o(s?.item??s);return t}async function me(e,{priority:n=!1}={}){try{const t=new Date,o=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,s=e.countUrl+(e.countUrl.includes("?")?"&":"?")+`today=${o}`,r=w()?.id,u=await ft(()=>!ke()||w()?.id!==r?null:H.get(s,{priority:"low"}),{key:JSON.stringify([r,s]),priority:n});return D(u,{fallbackLabel:e.countLabel||e.text})}catch{return null}}function V(e,n,t){Fe(n,t),t?.notify&&je(w()?.id??null,n,t.notify);const o=[...e.querySelectorAll("a.sidebar-link")].filter(s=>s.dataset.url===n);if(o.length){for(const s of o){const r=s.querySelector(".sidebar-badge[data-count-for]");if(!t||!(t.count>0)&&!t.showZero)r?.remove();else{const u=document.createRange();u.selectNodeContents(s);const i=u.createContextualFragment(le(n,t)).firstElementChild;r?r.replaceWith(i):s.querySelector(".sidebar-text")?.after(i)}}X.set(n,t),ce(e)}}const X=new Map;async function pe(e){const n=await Ce(e,{legacy:async t=>{const o=await Promise.all(t.map(async s=>[s.url,await me(s)]));return Object.fromEntries(o)}});return Object.fromEntries(e.map(t=>[t.url,n[t.url]==null?null:D(n[t.url],{fallbackLabel:t.countLabel||t.text})]))}async function Z(e,n=null){const t=w()?.id,o=j;try{const s=n?{[n]:await me(j.find(r=>r.url===n),{priority:!0})}:await pe(j);if(w()?.id!==t||j!==o)return;for(const[r,u]of Object.entries(s)){const i=X.get(r);JSON.stringify(i??null)!==JSON.stringify(u)&&V(e,r,u)}}catch{}}function mt(e){e.dataset.liveCounts||(e.dataset.liveCounts="1",window.addEventListener(dt,n=>{const t=n.detail||{};if(t.url)if(t.count!==void 0){const o=j.find(s=>s.url===t.url);V(e,t.url,D(t,{fallbackLabel:o?.countLabel||o?.text||""}))}else Z(e,t.url)}),setInterval(()=>{!document.hidden&&document.body.contains(e)&&Z(e)},ut),document.addEventListener("visibilitychange",()=>{document.hidden||Z(e)}),pt(e))}function he(e,n,t){const o=(u,i,a)=>{const d=document.createElement(u);return i&&(d.className=i),a!=null&&(d.textContent=String(a)),d};if(!t){e.textContent=n;return}e.appendChild(o("strong","dm-badge-pop-title",t.title||n)),(t.rows?.length||!t.items?.length)&&e.appendChild(o("p","dm-badge-pop-sub",n));const s=Array.isArray(t.rows)?t.rows.slice(0,6):[];if(s.length){const u=o("dl","dm-badge-pop-rows");for(const i of s)u.appendChild(o("dt",null,i.label)),u.appendChild(o("dd",i.tone==="danger"?"is-danger":null,i.value));e.appendChild(u)}const r=Array.isArray(t.items)?t.items.slice(0,6):[];if(r.length){const u=o("ul","dm-badge-pop-items");for(const i of r){const a=o("li",i.tone==="danger"?"is-danger":null);a.appendChild(o("span","dm-badge-pop-text",i.text)),i.meta&&a.appendChild(o("span","dm-badge-pop-meta",i.meta)),u.appendChild(a)}e.appendChild(u)}else t.empty&&e.appendChild(o("p","dm-badge-pop-empty",t.empty))}function pt(e){let n=null,t=null;const o=()=>e.classList.contains("is-collapsed"),s=()=>{clearTimeout(t),n?.remove(),n=null},r=(d,l)=>{s(),t=setTimeout(()=>{n=document.createElement("div"),n.className="dm-help-pop dm-badge-pop",n.setAttribute("role","tooltip"),l(n),document.body.appendChild(n);const f=d.getBoundingClientRect(),h=n.getBoundingClientRect(),v=Math.min(f.right+10,innerWidth-h.width-8);n.style.left=`${Math.max(8,v)}px`,n.style.top=`${Math.max(8,Math.min(f.top+f.height/2-h.height/2,innerHeight-h.height-8))}px`},150)},u=d=>{const l=d?.dataset.badgeLabel;if(!l)return s();r(d,f=>he(f,l,R.get(d.dataset.countFor)))},i=d=>{const l=d.querySelector(":scope > .sidebar-text")?.textContent.trim()||"",f=d.querySelector(":scope > .sidebar-badge[data-badge-label]:not([hidden])");r(d,h=>{const v=f&&R.get(f.dataset.countFor);if(v)return he(h,f.dataset.badgeLabel,{...v,title:v.title||l});if(!f){h.textContent=l;return}const k=document.createElement("strong");k.className="dm-badge-pop-title",k.textContent=l;const q=document.createElement("p");q.className="dm-badge-pop-sub",q.textContent=f.dataset.badgeLabel,h.append(k,q)})},a=d=>{const l=d.closest?.("a.sidebar-link, summary");return l&&e.contains(l)?l:null};e.addEventListener("mouseover",d=>{if(o()){const f=a(d.target);f&&!f.contains(d.relatedTarget)&&i(f);return}const l=d.target.closest?.(".sidebar-badge[data-badge-label]");l&&u(l)}),e.addEventListener("mouseout",d=>{if(o()){const l=a(d.target);l&&!l.contains(d.relatedTarget)&&s();return}d.target.closest?.(".sidebar-badge[data-badge-label]")&&s()}),e.addEventListener("focusin",d=>{const l=d.target.closest?.("a, summary");if(o()&&l&&e.contains(l)&&l.querySelector(":scope > .sidebar-text"))return i(l);const f=l?.querySelector(":scope > .sidebar-badge[data-badge-label]:not([hidden])");f?u(f):s()}),e.addEventListener("focusout",s),e.addEventListener("click",s),window.addEventListener("scroll",s,!0),window.addEventListener("hashchange",s)}async function ht(e=[],n=null){if(n?.title||n?.enabled===!1)return n;if(!W(e,"settings"))return{title:"Domma CMS"};try{const t=await g.settings.get();return{...t?.adminBrand,title:t?.adminBrand?.title||t?.title||"Domma CMS"}}catch{return{title:"Domma CMS"}}}export async function renderAdminSidebar({mount:e,permissions:n,adminScope:t=null,brand:o=null}){const s=$(e).get(0);if(!s)return;const r=Qe(g,w()).catch(()=>{}),u=Promise.resolve().then(()=>H.get("/api/sidebar/registered-items")).catch(()=>[]),i=it(n);let a,d=null,l=null,f=null,h=null,v=null;try{const c=await g.get("/sidebar/menu");a=Array.isArray(c?.items)?c.items:null,d=c?.variant||null,l=c?.position||null,f=c?.style||null,h=c?.float||null,v=c?.highlight||null}catch{a=null}(!a||!a.some(c=>c&&(!c.hidden||c.restricted)))&&(console.warn("[admin-sidebar] No admin-sidebar menu found; using fallback tree"),a=ot.slice());let k=[];try{k=await u||[]}catch{}a=Re(a,se),a=Te(a,k.filter(c=>(c?.item??c)?.url!==se)),a=Ne(a),a=Ie(a,[He()]);const q=await i;q.length&&at(a,q),a=_e(a,n,t),a=Pe(a),await r;const F=Xe(a,K(w()),{hidden:Ze(w())});F&&(a=[F,...a]),nt(a);const b=k.filter(c=>W(n,c?.item?.permission));j=fe(b,t);const A=Ae({user:w(),permissions:n,adminScope:t,registered:b,tree:a,actions:{linkItems:ye,folderItems:ve},fetcher:()=>ct(b,n,t)}),B=A.counts,L=await ht(n,o),I=d?` dm-admin-sidebar--${m(d)}`:"";function P(c,x="px"){if(c==null)return c;const p=String(c).trim();return/^\d+(\.\d+)?$/.test(p)?`${p}${x}`:p}let U="";if(f){const c=[];f.fontFamily&&c.push(`font-family: ${f.fontFamily}, sans-serif`),f.fontSize&&c.push(`font-size: ${P(f.fontSize)}`),f.fontWeight&&c.push(`font-weight: ${f.fontWeight}`),f.letterSpacing&&c.push(`letter-spacing: ${P(f.letterSpacing,"em")}`);const x=[];if(c.length&&x.push(`#admin-sidebar .dm-admin-sidebar, #admin-sidebar .dm-admin-sidebar .sidebar-link, #admin-sidebar .dm-admin-sidebar summary, #admin-sidebar .dm-admin-sidebar .sidebar-text { ${c.join("; ")} }`),f.iconSize){const p=P(f.iconSize);x.push(`#admin-sidebar .dm-admin-sidebar [data-icon], #admin-sidebar .dm-admin-sidebar [data-icon] svg { width: ${p} !important; height: ${p} !important; }`)}x.length&&(U=`<style data-admin-sidebar-style>${x.join(" ")}</style>`)}const z=ze(n)?Ue():"",y=String(L.logo||"").trim(),C=/^(?:\/(?!\/)|https?:\/\/)/i.test(y)?y:"",G=C?`<img src="${m(C)}" alt="" style="width:28px;height:28px;object-fit:contain;flex-shrink:0;">`:`<span data-icon="${m(L.icon||"layout")}"></span>`,O=`<div class="dm-admin-sidebar-header">${L.enabled===!1?"":`${G}<span class="dm-admin-sidebar-title">${m(L.title)}</span>`}${z}${De()}</div>`,xe=a.some(c=>c&&c.type==="spacer"&&c.size==="flex")?" dm-admin-sidebar--has-flex-spacer":"",$e=`${U}<nav class="dm-admin-sidebar${I}${xe}">${O}${a.map(c=>ue(c,B)).join("")}</nav>`,Q=document.createRange();Q.selectNodeContents(s);const we=Q.createContextualFragment($e);s.replaceChildren(we),Domma.icons.scan(s),s.querySelector(".dm-admin-sidebar-arrange")?.addEventListener("click",()=>We(s));for(const c of j)X.set(c.url,B[c.url]??null);ce(s),mt(s),A.refresh.then(c=>{if(!(!A.isActive()||!s.isConnected))for(const[x,p]of Object.entries(c))V(s,x,p)}),s.removeAttribute("data-menu-hover"),s.removeAttribute("data-menu-active"),s.style.removeProperty("--dm-menu-highlight"),Oe(s,{highlight:v});const T=document.querySelector(".dashboard-wrapper");["position","top","bottom","left","right","zIndex","maxHeight","transform"].forEach(c=>{s.style[c]=""}),s.classList.remove("dm-menu-floating"),T&&(T.style.paddingLeft="",T.style.paddingRight=""),s.__dmGutter=()=>{if(l!=="floating"||!T)return;const c=h&&h.anchor||"TL",x=Number.isFinite(Number(h?.offsetX))?Number(h.offsetX):16,p=s.classList.contains("is-collapsed")?Ke:parseInt(s.style.width,10)||s.getBoundingClientRect().width||260,N=Math.round(p+x*2)+"px";c==="R"||c==="TR"||c==="BR"?T.style.paddingRight=N:T.style.paddingLeft=N},l==="floating"&&Be(s,{position:"floating",float:h||{}}),s.querySelectorAll("details").forEach(c=>{c.addEventListener("toggle",function(){const x=this.getAttribute("data-state-key");x&&S.set(x,this.open);const p=this.querySelector(":scope > .sidebar-children");if(p)if(this.open){const N=p.scrollHeight;p.style.maxHeight="0",requestAnimationFrame(()=>{p.style.maxHeight=N+"px",p.addEventListener("transitionend",function Se(){p.style.maxHeight="none",p.removeEventListener("transitionend",Se)})})}else{const N=p.scrollHeight;p.style.maxHeight=N+"px",requestAnimationFrame(()=>{p.style.maxHeight="0"})}})}),Ge(s),bt(s),s.dataset.routeWired||(s.dataset.routeWired="1",M.subscribe("router:afterChange",()=>s.__dmSetActive?.()));function ee(){const c=/^#\/(dashboards|my-dashboard)\b/.test(location.hash)?"#/":location.hash||"#/";$(s).find(".sidebar-link").removeClass("active"),$(s).find(`.sidebar-link[data-url="${c}"]`).addClass("active")}ee(),s.__dmSetActive=ee}function ge(){try{document.dispatchEvent(new CustomEvent("dm:sidebar-rebuild"))}catch{}}function J(e){return`${location.origin}${location.pathname}${e}`}function _(e,n){const t=w(),o=e(K(t));if(!et(t,o)){E.toast("Frequent could not be saved - this browser is blocking storage.",{type:"error"});return}o.length&&ae(t,!1),be(t),n&&E.toast(n,{type:"success",duration:2500}),ge()}function be(e){Ye(g,e).catch(()=>E.toast("Frequent is saved in this browser only - the server could not keep it.",{type:"warning"}))}function gt(e){if(!ae(w(),e)){E.toast("Frequent could not be saved - this browser is blocking storage.",{type:"error"});return}be(w()),E.toast(e?"Frequent hidden. Add a Tool to it from its right-click menu to bring it back.":"Frequent shown.",{type:"success",duration:3500}),ge()}function ye(e){const n=e.dataset.url;if(!n)return[];const t=e.querySelector(".sidebar-text")?.textContent.trim()||n,o=K(w()),s=o.includes(n),r=!!e.closest("[data-frequent]"),u=o.indexOf(n),i=!s&&o.length>=oe;return[{header:t},{label:"Open",icon:"arrow-right",...re(n)&&{shortcut:st(re(n))},action:()=>{location.hash=n}},{label:"Open in a new tab",icon:"external-link",action:()=>window.open(J(n),"_blank","noopener")},{type:"divider"},s?{label:"Remove from Frequent",icon:"star",action:()=>_(a=>Je(a,n),`${t} removed from Frequent.`)}:{label:i?`Frequent is full (${oe})`:"Add to Frequent",icon:"star",disabled:i,action:()=>_(a=>Ve(a,n),`${t} added to Frequent.`)},...r?[{label:"Move up",icon:"arrow-up",disabled:u<=0,action:()=>_(a=>ie(a,n,-1))},{label:"Move down",icon:"arrow-down",disabled:u<0||u>=o.length-1,action:()=>_(a=>ie(a,n,1))}]:[],{type:"divider"},{label:"Copy link",icon:"link",action:async()=>{try{await navigator.clipboard.writeText(J(n)),E.toast("Link copied.",{type:"success",duration:2e3})}catch{E.toast(J(n),{type:"info",duration:8e3})}}}]}function ve(e,n,t={}){const o=e.closest("details, [data-frequent]"),s=t.isOpen||(()=>!!o?.open),r=t.setOpen||(a=>{o&&(o.open=a)}),u=e.querySelector(".sidebar-text")?.textContent.trim()||"Folder",i=t.setAll||(a=>n.querySelectorAll("details").forEach(d=>{d.open!==a&&(d.open=a)}));return[{header:u},{label:s()?"Close":"Open",icon:s()?"chevron-up":"chevron-down",action:()=>r(!s())},...t.singleBranch?[]:[{label:"Open every folder",icon:"chevrons-down",action:()=>i(!0)}],{label:t.singleBranch?"Close all menus":"Close every folder",icon:"chevrons-up",action:()=>i(!1)},...o?.hasAttribute("data-frequent-empty")?[{type:"divider"},{label:"Hide Frequent until I add a Tool",icon:"eye-off",action:()=>gt(!0)}]:o?.hasAttribute("data-frequent")?[{type:"divider"},{label:"Clear Frequent",icon:"x",action:()=>_(()=>[],"Frequent cleared.")}]:[]]}function bt(e){e.dataset.ctxWired||typeof E>"u"||!E.contextMenu||(e.dataset.ctxWired="1",E.contextMenu(e,{match:"a.sidebar-link, details > summary",inherit:!1,density:"compact",items:n=>n.matches("summary")?ve(n,e):ye(n)}))}
7
+ </details>`}return`<a href="${i}" class="sidebar-link" data-url="${i}"${v}${f}${C}>${r} <span class="sidebar-text">${u}</span>${ct(e,n)}${F}</a>`}async function ut(e=[],n=[],t=null){const o=y=>y.then(x=>Array.isArray(x)?x.length:Array.isArray(x?.entries)?x.entries.length:0).catch(()=>0),s=fe(e,t),r=new Set(s.map(y=>y.url)),u={pages:"#/pages",media:"#/media",menus:"#/menus","context-menus":"#/context-menus",theme:"#/theme",collections:"#/collections",forms:"#/forms",views:"#/views",actions:"#/actions",blocks:"#/blocks",components:"#/components",users:"#/users",plugins:"#/plugins",notifications:"#/system/notifications"},i=(y,x)=>G(n,y)&&!r.has(u[y])?x():Promise.resolve(0),[a,d,l,f,h,v,q,C,F,b,A,B,L,P]=await Promise.all([i("pages",()=>o(g.pages.list())),i("media",()=>o(g.media.list())),i("menus",()=>o(g.menus.list())),i("context-menus",()=>o(g.contextMenus.list())),i("theme",()=>g.theme.get().then(y=>(y?.overrides||[]).length).catch(()=>0)),i("collections",()=>o(g.collections.list())),i("forms",()=>o(g.forms.list())),i("views",()=>o(g.views.list())),i("actions",()=>o(g.actions.list())),i("blocks",()=>o(g.blocks.list())),i("components",()=>o(g.components.list())),i("users",()=>o(g.users.list())),i("plugins",()=>o(g.plugins.list())),i("notifications",()=>g.system?.notifications?.unreadCount?.().then(y=>y?.count??0).catch(()=>0)??Promise.resolve(0))]),_=await pe(s),z={"#/pages":a,"#/media":d,"#/menus":l,"#/context-menus":f,"#/theme":h,"#/collections":v,"#/forms":q,"#/views":C,"#/actions":F,"#/blocks":b,"#/components":A,"#/users":B,"#/plugins":L,"#/system/notifications":P},D={};for(const[y,x]of Object.entries(z)){if(r.has(y))continue;const[W,O]=dt[y]??["item","items"],T=K(x);T&&(D[y]={...T,label:`${T.count} ${T.count===1?W:O}`})}return{...D,..._}}let j=[];const ft="dm:sidebar-count",mt=6e4,pt=Ae(4);function fe(e=[],n=null){const t=[],o=s=>{if(s&&!(n&&typeof s.url=="string"&&s.url.startsWith("#/")&&!je(n,s.url.slice(1)))){s.url&&typeof s.countUrl=="string"&&s.countUrl&&t.push({url:s.url,countUrl:s.countUrl,text:s.text||"",countLabel:s.countLabel||"",inventory:s.inventory===!0});for(const r of[...s.children||[],...s.items||[]])o(r)}};for(const s of e??[])o(s?.item??s);return t}async function me(e,{priority:n=!1}={}){try{const t=new Date,o=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,s=e.countUrl+(e.countUrl.includes("?")?"&":"?")+`today=${o}`,r=k()?.id,u=await pt(()=>!Ce()||k()?.id!==r?null:H.get(s,{priority:"low"}),{key:JSON.stringify([r,s]),priority:n});return K(u,{fallbackLabel:e.countLabel||e.text})}catch{return null}}function X(e,n,t){Ee(n,t),t?.notify&&Oe(k()?.id??null,n,t.notify);const o=[...e.querySelectorAll("a.sidebar-link")].filter(s=>s.dataset.url===n);if(o.length){for(const s of o){const r=s.querySelector(".sidebar-badge[data-count-for]");if(!t||!(t.count>0)&&!t.showZero)r?.remove();else{const u=document.createRange();u.selectNodeContents(s);const i=u.createContextualFragment(le(n,t)).firstElementChild;r?r.replaceWith(i):s.querySelector(".sidebar-text")?.after(i)}}Z.set(n,t),ce(e)}}const Z=new Map;async function pe(e){const n=await Le(e,{legacy:async t=>{const o=await Promise.all(t.map(async s=>[s.url,await me(s)]));return Object.fromEntries(o)}});return Object.fromEntries(e.map(t=>[t.url,n[t.url]==null?null:K(n[t.url],{fallbackLabel:t.countLabel||t.text})]))}async function J(e,n=null){const t=k()?.id,o=j;try{const s=n?{[n]:await me(j.find(r=>r.url===n),{priority:!0})}:await pe(j);if(k()?.id!==t||j!==o)return;for(const[r,u]of Object.entries(s)){const i=Z.get(r);JSON.stringify(i??null)!==JSON.stringify(u)&&X(e,r,u)}}catch{}}function ht(e){e.dataset.liveCounts||(e.dataset.liveCounts="1",window.addEventListener(ft,n=>{const t=n.detail||{};if(t.url)if(t.count!==void 0){const o=j.find(s=>s.url===t.url);X(e,t.url,K(t,{fallbackLabel:o?.countLabel||o?.text||""}))}else J(e,t.url)}),setInterval(()=>{!document.hidden&&document.body.contains(e)&&J(e)},mt),document.addEventListener("visibilitychange",()=>{document.hidden||J(e)}),gt(e))}function he(e,n,t){const o=(u,i,a)=>{const d=document.createElement(u);return i&&(d.className=i),a!=null&&(d.textContent=String(a)),d};if(!t){e.textContent=n;return}e.appendChild(o("strong","dm-badge-pop-title",t.title||n)),(t.rows?.length||!t.items?.length)&&e.appendChild(o("p","dm-badge-pop-sub",n));const s=Array.isArray(t.rows)?t.rows.slice(0,6):[];if(s.length){const u=o("dl","dm-badge-pop-rows");for(const i of s)u.appendChild(o("dt",null,i.label)),u.appendChild(o("dd",i.tone==="danger"?"is-danger":null,i.value));e.appendChild(u)}const r=Array.isArray(t.items)?t.items.slice(0,6):[];if(r.length){const u=o("ul","dm-badge-pop-items");for(const i of r){const a=o("li",i.tone==="danger"?"is-danger":null);a.appendChild(o("span","dm-badge-pop-text",i.text)),i.meta&&a.appendChild(o("span","dm-badge-pop-meta",i.meta)),u.appendChild(a)}e.appendChild(u)}else t.empty&&e.appendChild(o("p","dm-badge-pop-empty",t.empty))}function gt(e){let n=null,t=null;const o=()=>e.classList.contains("is-collapsed"),s=()=>{clearTimeout(t),n?.remove(),n=null},r=(d,l)=>{s(),t=setTimeout(()=>{n=document.createElement("div"),n.className="dm-help-pop dm-badge-pop",n.setAttribute("role","tooltip"),l(n),document.body.appendChild(n);const f=d.getBoundingClientRect(),h=n.getBoundingClientRect(),v=Math.min(f.right+10,innerWidth-h.width-8);n.style.left=`${Math.max(8,v)}px`,n.style.top=`${Math.max(8,Math.min(f.top+f.height/2-h.height/2,innerHeight-h.height-8))}px`},150)},u=d=>{const l=d?.dataset.badgeLabel;if(!l)return s();r(d,f=>he(f,l,I.get(d.dataset.countFor)))},i=d=>{const l=d.querySelector(":scope > .sidebar-text")?.textContent.trim()||"",f=d.querySelector(":scope > .sidebar-badge[data-badge-label]:not([hidden])");r(d,h=>{const v=f&&I.get(f.dataset.countFor);if(v)return he(h,f.dataset.badgeLabel,{...v,title:v.title||l});if(!f){h.textContent=l;return}const q=document.createElement("strong");q.className="dm-badge-pop-title",q.textContent=l;const C=document.createElement("p");C.className="dm-badge-pop-sub",C.textContent=f.dataset.badgeLabel,h.append(q,C)})},a=d=>{const l=d.closest?.("a.sidebar-link, summary");return l&&e.contains(l)?l:null};e.addEventListener("mouseover",d=>{if(o()){const f=a(d.target);f&&!f.contains(d.relatedTarget)&&i(f);return}const l=d.target.closest?.(".sidebar-badge[data-badge-label]");l&&u(l)}),e.addEventListener("mouseout",d=>{if(o()){const l=a(d.target);l&&!l.contains(d.relatedTarget)&&s();return}d.target.closest?.(".sidebar-badge[data-badge-label]")&&s()}),e.addEventListener("focusin",d=>{const l=d.target.closest?.("a, summary");if(o()&&l&&e.contains(l)&&l.querySelector(":scope > .sidebar-text"))return i(l);const f=l?.querySelector(":scope > .sidebar-badge[data-badge-label]:not([hidden])");f?u(f):s()}),e.addEventListener("focusout",s),e.addEventListener("click",s),window.addEventListener("scroll",s,!0),window.addEventListener("hashchange",s)}async function bt(e=[],n=null){if(n?.title||n?.enabled===!1)return n;if(!G(e,"settings"))return{title:"Domma CMS"};try{const t=await g.settings.get();return{...t?.adminBrand,title:t?.adminBrand?.title||t?.title||"Domma CMS"}}catch{return{title:"Domma CMS"}}}export async function renderAdminSidebar({mount:e,permissions:n,adminScope:t=null,brand:o=null}){const s=$(e).get(0);if(!s)return;const r=tt(g,k()).catch(()=>{}),u=Promise.resolve().then(()=>H.get("/api/sidebar/registered-items")).catch(()=>[]),i=rt(n);let a,d=null,l=null,f=null,h=null,v=null;try{const c=await g.get("/sidebar/menu");a=Array.isArray(c?.items)?c.items:null,d=c?.variant||null,l=c?.position||null,f=c?.style||null,h=c?.float||null,v=c?.highlight||null}catch{a=null}(!a||!a.some(c=>c&&(!c.hidden||c.restricted)))&&(console.warn("[admin-sidebar] No admin-sidebar menu found; using fallback tree"),a=at.slice());let q=[];try{q=await u||[]}catch{}a=Pe(a,se),a=He(a,q.filter(c=>(c?.item??c)?.url!==se)),a=Re(a),a=_e(a,[Ie()]);const C=await i;C.length&&lt(a,C),a=ze(a,n,t),a=Ue(a),await r;const F=Je(a,V(k()),{hidden:Ye(k())});F&&(a=[F,...a]),ot(a);const b=q.filter(c=>G(n,c?.item?.permission));j=fe(b,t);const A=Fe({user:k(),permissions:n,adminScope:t,registered:b,tree:a,actions:{linkItems:ye,folderItems:ve},fetcher:()=>ut(b,n,t)}),B=A.counts,L=await bt(n,o),P=d?` dm-admin-sidebar--${m(d)}`:"";function _(c,w="px"){if(c==null)return c;const p=String(c).trim();return/^\d+(\.\d+)?$/.test(p)?`${p}${w}`:p}let z="";if(f){const c=[];f.fontFamily&&c.push(`font-family: ${f.fontFamily}, sans-serif`),f.fontSize&&c.push(`font-size: ${_(f.fontSize)}`),f.fontWeight&&c.push(`font-weight: ${f.fontWeight}`),f.letterSpacing&&c.push(`letter-spacing: ${_(f.letterSpacing,"em")}`);const w=[];if(c.length&&w.push(`#admin-sidebar .dm-admin-sidebar, #admin-sidebar .dm-admin-sidebar .sidebar-link, #admin-sidebar .dm-admin-sidebar summary, #admin-sidebar .dm-admin-sidebar .sidebar-text { ${c.join("; ")} }`),f.iconSize){const p=_(f.iconSize);w.push(`#admin-sidebar .dm-admin-sidebar [data-icon], #admin-sidebar .dm-admin-sidebar [data-icon] svg { width: ${p} !important; height: ${p} !important; }`)}w.length&&(z=`<style data-admin-sidebar-style>${w.join(" ")}</style>`)}const D=We(n)?De():"",y=String(L.logo||"").trim(),x=/^(?:\/(?!\/)|https?:\/\/)/i.test(y)?y:"",W=String(L.logoDark||"").trim(),O=/^(?:\/(?!\/)|https?:\/\/)/i.test(W)?W:"",T=x||O?`<img src="${m(x||O)}"${x?` data-logo-light="${m(x)}"`:""}${O?` data-logo-dark="${m(O)}"`:""} alt="" style="width:28px;height:28px;object-fit:contain;flex-shrink:0;">`:`<span data-icon="${m(L.icon||"layout")}"></span>`,xe=`<div class="dm-admin-sidebar-header">${L.enabled===!1?"":`${T}<span class="dm-admin-sidebar-title">${m(L.title)}</span>`}${D}${Ke()}</div>`,$e=a.some(c=>c&&c.type==="spacer"&&c.size==="flex")?" dm-admin-sidebar--has-flex-spacer":"",we=`${z}<nav class="dm-admin-sidebar${P}${$e}">${xe}${a.map(c=>ue(c,B)).join("")}</nav>`,Q=document.createRange();Q.selectNodeContents(s);const ke=Q.createContextualFragment(we);s.replaceChildren(ke),qe(s),Domma.icons.scan(s),s.querySelector(".dm-admin-sidebar-arrange")?.addEventListener("click",()=>Ge(s));for(const c of j)Z.set(c.url,B[c.url]??null);ce(s),ht(s),A.refresh.then(c=>{if(!(!A.isActive()||!s.isConnected))for(const[w,p]of Object.entries(c))X(s,w,p)}),s.removeAttribute("data-menu-hover"),s.removeAttribute("data-menu-active"),s.style.removeProperty("--dm-menu-highlight"),Me(s,{highlight:v});const N=document.querySelector(".dashboard-wrapper");["position","top","bottom","left","right","zIndex","maxHeight","transform"].forEach(c=>{s.style[c]=""}),s.classList.remove("dm-menu-floating"),N&&(N.style.paddingLeft="",N.style.paddingRight=""),s.__dmGutter=()=>{if(l!=="floating"||!N)return;const c=h&&h.anchor||"TL",w=Number.isFinite(Number(h?.offsetX))?Number(h.offsetX):16,p=s.classList.contains("is-collapsed")?Xe:parseInt(s.style.width,10)||s.getBoundingClientRect().width||260,R=Math.round(p+w*2)+"px";c==="R"||c==="TR"||c==="BR"?N.style.paddingRight=R:N.style.paddingLeft=R},l==="floating"&&Te(s,{position:"floating",float:h||{}}),s.querySelectorAll("details").forEach(c=>{c.addEventListener("toggle",function(){const w=this.getAttribute("data-state-key");w&&S.set(w,this.open);const p=this.querySelector(":scope > .sidebar-children");if(p)if(this.open){const R=p.scrollHeight;p.style.maxHeight="0",requestAnimationFrame(()=>{p.style.maxHeight=R+"px",p.addEventListener("transitionend",function Se(){p.style.maxHeight="none",p.removeEventListener("transitionend",Se)})})}else{const R=p.scrollHeight;p.style.maxHeight=R+"px",requestAnimationFrame(()=>{p.style.maxHeight="0"})}})}),Ve(s),vt(s),s.dataset.routeWired||(s.dataset.routeWired="1",M.subscribe("router:afterChange",()=>s.__dmSetActive?.()));function ee(){const c=/^#\/(dashboards|my-dashboard)\b/.test(location.hash)?"#/":location.hash||"#/";$(s).find(".sidebar-link").removeClass("active"),$(s).find(`.sidebar-link[data-url="${c}"]`).addClass("active")}ee(),s.__dmSetActive=ee}function ge(){try{document.dispatchEvent(new CustomEvent("dm:sidebar-rebuild"))}catch{}}function Y(e){return`${location.origin}${location.pathname}${e}`}function U(e,n){const t=k(),o=e(V(t));if(!nt(t,o)){E.toast("Frequent could not be saved - this browser is blocking storage.",{type:"error"});return}o.length&&ae(t,!1),be(t),n&&E.toast(n,{type:"success",duration:2500}),ge()}function be(e){et(g,e).catch(()=>E.toast("Frequent is saved in this browser only - the server could not keep it.",{type:"warning"}))}function yt(e){if(!ae(k(),e)){E.toast("Frequent could not be saved - this browser is blocking storage.",{type:"error"});return}be(k()),E.toast(e?"Frequent hidden. Add a Tool to it from its right-click menu to bring it back.":"Frequent shown.",{type:"success",duration:3500}),ge()}function ye(e){const n=e.dataset.url;if(!n)return[];const t=e.querySelector(".sidebar-text")?.textContent.trim()||n,o=V(k()),s=o.includes(n),r=!!e.closest("[data-frequent]"),u=o.indexOf(n),i=!s&&o.length>=oe;return[{header:t},{label:"Open",icon:"arrow-right",...re(n)&&{shortcut:it(re(n))},action:()=>{location.hash=n}},{label:"Open in a new tab",icon:"external-link",action:()=>window.open(Y(n),"_blank","noopener")},{type:"divider"},s?{label:"Remove from Frequent",icon:"star",action:()=>U(a=>Qe(a,n),`${t} removed from Frequent.`)}:{label:i?`Frequent is full (${oe})`:"Add to Frequent",icon:"star",disabled:i,action:()=>U(a=>Ze(a,n),`${t} added to Frequent.`)},...r?[{label:"Move up",icon:"arrow-up",disabled:u<=0,action:()=>U(a=>ie(a,n,-1))},{label:"Move down",icon:"arrow-down",disabled:u<0||u>=o.length-1,action:()=>U(a=>ie(a,n,1))}]:[],{type:"divider"},{label:"Copy link",icon:"link",action:async()=>{try{await navigator.clipboard.writeText(Y(n)),E.toast("Link copied.",{type:"success",duration:2e3})}catch{E.toast(Y(n),{type:"info",duration:8e3})}}}]}function ve(e,n,t={}){const o=e.closest("details, [data-frequent]"),s=t.isOpen||(()=>!!o?.open),r=t.setOpen||(a=>{o&&(o.open=a)}),u=e.querySelector(".sidebar-text")?.textContent.trim()||"Folder",i=t.setAll||(a=>n.querySelectorAll("details").forEach(d=>{d.open!==a&&(d.open=a)}));return[{header:u},{label:s()?"Close":"Open",icon:s()?"chevron-up":"chevron-down",action:()=>r(!s())},...t.singleBranch?[]:[{label:"Open every folder",icon:"chevrons-down",action:()=>i(!0)}],{label:t.singleBranch?"Close all menus":"Close every folder",icon:"chevrons-up",action:()=>i(!1)},...o?.hasAttribute("data-frequent-empty")?[{type:"divider"},{label:"Hide Frequent until I add a Tool",icon:"eye-off",action:()=>yt(!0)}]:o?.hasAttribute("data-frequent")?[{type:"divider"},{label:"Clear Frequent",icon:"x",action:()=>U(()=>[],"Frequent cleared.")}]:[]]}function vt(e){e.dataset.ctxWired||typeof E>"u"||!E.contextMenu||(e.dataset.ctxWired="1",E.contextMenu(e,{match:"a.sidebar-link, details > summary",inherit:!1,density:"compact",items:n=>n.matches("summary")?ve(n,e):ye(n)}))}
@@ -1,3 +1,3 @@
1
- export const TAB_FIELDS={general:["title","tagline","siteUrl","adminHome","spacerSize","bodyClass"],branding:["brandEnabled","brandText","brandLogo","brandIcon","brandUrl","adminBrandEnabled","adminBrandTitle","adminBrandLogo","adminBrandIcon"],favicon:["favicon"],footer:["footerCopyright","footerLayout","footerBlurb","footerBlocks","footerClass","footerSocialClass","footerLook","footerCtaText","footerCtaHighlight","footerCtaUrl","footerCtaSub","footerWatermark","footerStatus","footerFacts","footerTagline","footerEmail","footerAddress","footerGradFrom","footerGradTo","socialTwitter","socialFacebook","socialInstagram","socialLinkedin","socialGithub","socialYoutube"],email:["smtpHost","smtpPort","smtpUser","smtpPass","smtpSecure","smtpInsecureTLS","smtpFromAddress","smtpFromName"],pageNavigation:["bttEnabled","bttSmooth","bttLabel","bttThreshold","bttPosition","bttOffset","bttBottomOffset","gtbEnabled","gtbSmooth","gtbLabel","gtbThreshold","gtbPosition","gtbOffset","gtbBottomOffset"],cookies:["ccEnabled","ccMessage","ccAcceptAll","ccRejectAll","ccCustomize","ccSavePrefs","ccPrivacyText","ccPrivacyUrl","ccCookieText","ccCookieUrl","ccPosition","ccLayout","ccTheme","ccShowFunctional","ccShowAnalytics","ccShowMarketing","ccVersion","ccSettingsLink","ccSettingsLinkText"],breadcrumbs:["bcEnabled","bcHomeLabel","bcPosition","bcOffsetX","bcOffsetY"],motion:["mtEnabled","mtLabel","mtDefault","mtControl","mtPlacement","mtTriggerStyle","mtPosition","mtOffsetX","mtOffsetY","mtIconSize","mtIconRadius","mtClass"]},SECRET_FIELDS=["smtpPass"],BREADCRUMB_POSITIONS=["TL","TR","BL","BR"],MOTION_PLACEMENTS=["footer","floating","navbar"],MOTION_LABEL="Reduce motion";const d=["system","off","on"],c=(t,r,n,o)=>{const a=Number.parseInt(t,10);return Number.isFinite(a)?Math.min(o,Math.max(n,a)):r};export function motionFromSettings(t={}){const r=t.motion&&typeof t.motion=="object"?t.motion:{},n=t.footer||{},o=m=>r[m]!==void 0&&r[m]!==null,a=o("default")?r.default:n.motionDefault,i=o("control")?r.control:n.motionControl,l=c(r.iconSize,52,32,96);return{mtEnabled:(o("enabled")?r.enabled:n.showMotionToggle)!==!1,mtLabel:typeof r.label=="string"&&r.label.trim()?r.label.trim():MOTION_LABEL,mtDefault:d.includes(a)?a:"system",mtControl:i==="checkbox"?"checkbox":"switch",mtPlacement:MOTION_PLACEMENTS.includes(r.placement)?r.placement:"footer",mtTriggerStyle:r.triggerStyle==="icon-text"?"icon-text":"icon",mtPosition:BREADCRUMB_POSITIONS.includes(r.position)?r.position:"BL",mtOffsetX:e(c(r.offsetX,32,0,500)),mtOffsetY:e(c(r.offsetY,32,0,500)),mtIconSize:e(l),mtIconRadius:e(c(r.iconRadius,26,0,Math.floor(l/2))),mtClass:e(r.class)}}export function motionFromForm(t){const r=c(t.mtIconSize,52,32,96);return{enabled:t.mtEnabled===!0,default:d.includes(t.mtDefault)?t.mtDefault:"system",placement:MOTION_PLACEMENTS.includes(t.mtPlacement)?t.mtPlacement:"footer",control:t.mtControl==="checkbox"?"checkbox":"switch",triggerStyle:t.mtTriggerStyle==="icon-text"?"icon-text":"icon",label:e(t.mtLabel).trim().replace(/\s+/g," ").slice(0,40)||MOTION_LABEL,position:BREADCRUMB_POSITIONS.includes(t.mtPosition)?t.mtPosition:"BL",offsetX:c(t.mtOffsetX,32,0,500),offsetY:c(t.mtOffsetY,32,0,500),iconSize:r,iconRadius:c(t.mtIconRadius,26,0,Math.floor(r/2)),class:e(t.mtClass).trim()}}export function footerBlockNames(t){return[...new Set(String(t??"").split(/[\s,]+/).map(r=>r.trim().toLowerCase()).filter(Boolean))]}export function gaIdError(t){const r=e(t).trim();return!r||/^G-[A-Z0-9]{4,20}$/i.test(r)?"":"A measurement ID looks like G-XXXXXXXXXX (Google Analytics > Admin > Data streams)."}export const FOOTER_LAYOUTS=["auto","columns","row"],FOOTER_LOOKS=["","showcase"],FOOTER_FACTS_MAX=4;const p=/^(\/|#|https?:\/\/|mailto:)/,g=/^#[0-9a-f]{6}$/i;export function footerShowcaseErrors(t){const r=[],n=e(t.footerCtaUrl).trim();n&&!p.test(n)&&r.push("The footer call to action link must start with /, #, https:// or mailto: (Footer tool).");for(const[o,a]of[["from",t.footerGradFrom],["to",t.footerGradTo]]){const i=e(a).trim();i&&!g.test(i)&&r.push(`The footer gradient "${o}" colour must look like #f26b3a (Footer tool).`)}return r}const e=(t,r="")=>t==null?r:String(t),s=(t,r)=>{const n=Number.parseInt(t,10);return Number.isFinite(n)?n:r};export function homeValue(t){return/^\/[A-Za-z0-9\-_/]*$/.test(t||"")&&String(t).replace(/\/+$/,"")||"/"}export function formFromSettings(t={}){const r=t.backToTop||{},n=t.goToBottom||{},o=t.cookieConsent||{},a=t.breadcrumbs||{};return{title:e(t.title),tagline:e(t.tagline),siteUrl:e(t.baseUrl),adminHome:homeValue(t.adminHome),spacerSize:e(t.layoutOptions?.spacerSize??40),bodyClass:e(t.bodyClass),brandEnabled:t.brand?.enabled!==!1,brandText:e(t.brand?.text),brandLogo:e(t.brand?.logo),brandIcon:e(t.brand?.icon),brandUrl:e(t.brand?.url,"/"),favicon:e(t.favicon),adminBrandEnabled:t.adminBrand?.enabled!==!1,adminBrandTitle:e(t.adminBrand?.title),adminBrandLogo:e(t.adminBrand?.logo),adminBrandIcon:e(t.adminBrand?.icon),footerCopyright:e(t.footer?.copyright),footerLayout:FOOTER_LAYOUTS.includes(t.footer?.layout)?t.footer.layout:"auto",footerBlurb:e(t.footer?.blurb),footerBlocks:Array.isArray(t.footer?.blocks)?t.footer.blocks.filter(i=>typeof i=="string").join(", "):"",footerClass:e(t.footer?.class),footerSocialClass:e(t.footer?.socialClass),footerLook:FOOTER_LOOKS.includes(t.footer?.look)?t.footer.look:"",footerCtaText:e(t.footer?.cta?.text),footerCtaHighlight:e(t.footer?.cta?.highlight),footerCtaUrl:e(t.footer?.cta?.url),footerCtaSub:e(t.footer?.cta?.sub),footerWatermark:e(t.footer?.watermark),footerStatus:e(t.footer?.status),footerFacts:Array.isArray(t.footer?.facts)?t.footer.facts.filter(i=>typeof i=="string").join(`
2
- `):"",footerTagline:e(t.footer?.tagline),footerEmail:e(t.footer?.email),footerAddress:e(t.footer?.address),footerGradFrom:e(t.footer?.gradient?.from),footerGradTo:e(t.footer?.gradient?.to),socialTwitter:e(t.social?.twitter),socialFacebook:e(t.social?.facebook),socialInstagram:e(t.social?.instagram),socialLinkedin:e(t.social?.linkedin),socialGithub:e(t.social?.github),socialYoutube:e(t.social?.youtube),smtpHost:e(t.smtp?.host),smtpPort:e(t.smtp?.port||587),smtpUser:e(t.smtp?.user),smtpPass:"",smtpSecure:t.smtp?.secure===!0,smtpInsecureTLS:t.smtp?.allowInsecureTLS===!0,smtpFromAddress:e(t.smtp?.fromAddress),smtpFromName:e(t.smtp?.fromName),bttEnabled:r.enabled!==!1,bttSmooth:r.smooth!==!1,bttLabel:e(r.label),bttThreshold:e(r.scrollThreshold??300),bttPosition:e(r.position,"bottom-right"),bttOffset:e(r.offset??32),bttBottomOffset:e(r.bottomOffset??r.offset??32),gtbEnabled:n.enabled===!0,gtbSmooth:n.smooth!==!1,gtbLabel:e(n.label),gtbThreshold:e(n.scrollThreshold??300),gtbPosition:e(n.position,"bottom-right"),gtbOffset:e(n.offset??32),gtbBottomOffset:e(n.bottomOffset??n.offset??32),ccEnabled:o.enabled!==!1,ccMessage:e(o.message),ccAcceptAll:e(o.acceptAllText,"Accept All"),ccRejectAll:e(o.rejectAllText,"Reject All"),ccCustomize:e(o.customizeText,"Customize"),ccSavePrefs:e(o.savePreferencesText,"Save Preferences"),ccPrivacyText:e(o.privacyPolicyText,"Privacy Policy"),ccPrivacyUrl:e(o.privacyPolicyUrl),ccCookieText:e(o.cookiePolicyText,"Cookie Policy"),ccCookieUrl:e(o.cookiePolicyUrl),ccPosition:e(o.position,"bottom"),ccLayout:e(o.layout,"bar"),ccTheme:e(o.theme,"dark"),ccShowFunctional:o.showFunctional!==!1,ccShowAnalytics:o.showAnalytics!==!1,ccShowMarketing:o.showMarketing!==!1,ccVersion:e(o.consentVersion,"1.0"),ccSettingsLink:o.showSettingsLink!==!1,ccSettingsLinkText:e(o.settingsLinkText,"Cookie settings"),bcEnabled:a.enabled===!0,bcHomeLabel:e(a.homeLabel,"Home"),bcPosition:BREADCRUMB_POSITIONS.includes(a.position)?a.position:"TL",bcOffsetX:e(a.offsetX??8),bcOffsetY:e(a.offsetY??8),...motionFromSettings(t)}}export function payloadFromForm(t,r={},{adminHomeReady:n=!0}={}){const o=i=>e(i).trim(),a=motionFromForm(t);return{title:o(t.title),tagline:o(t.tagline),baseUrl:o(t.siteUrl).replace(/\/+$/,""),...n&&{adminHome:o(t.adminHome)||"/"},layoutOptions:{spacerSize:s(t.spacerSize,40)||40},bodyClass:o(t.bodyClass),brand:{...r.brand,enabled:t.brandEnabled!==!1,text:o(t.brandText),logo:o(t.brandLogo),icon:o(t.brandIcon),url:o(t.brandUrl)||"/"},favicon:o(t.favicon),adminBrand:{...r.adminBrand,enabled:t.adminBrandEnabled!==!1,title:o(t.adminBrandTitle),logo:o(t.adminBrandLogo),icon:o(t.adminBrandIcon)},footer:{copyright:o(t.footerCopyright),layout:FOOTER_LAYOUTS.includes(t.footerLayout)?t.footerLayout:"auto",blurb:o(t.footerBlurb),blocks:footerBlockNames(t.footerBlocks),links:r.footer?.links||[],showMotionToggle:a.enabled,motionDefault:a.default,motionControl:a.control,class:o(t.footerClass),socialClass:o(t.footerSocialClass),look:FOOTER_LOOKS.includes(t.footerLook)?t.footerLook:"",cta:{text:o(t.footerCtaText),highlight:o(t.footerCtaHighlight),url:o(t.footerCtaUrl),sub:o(t.footerCtaSub)},watermark:o(t.footerWatermark),status:o(t.footerStatus),facts:String(t.footerFacts??"").split(`
1
+ export const TAB_FIELDS={general:["title","tagline","siteUrl","adminHome","spacerSize","bodyClass"],branding:["brandEnabled","brandText","brandLogo","brandIcon","brandUrl","adminBrandEnabled","adminBrandTitle","adminBrandLogo","adminBrandLogoDark","adminBrandIcon"],favicon:["favicon"],footer:["footerCopyright","footerLayout","footerBlurb","footerBlocks","footerClass","footerSocialClass","footerLook","footerCtaText","footerCtaHighlight","footerCtaUrl","footerCtaSub","footerWatermark","footerStatus","footerFacts","footerTagline","footerEmail","footerAddress","footerGradFrom","footerGradTo","socialTwitter","socialFacebook","socialInstagram","socialLinkedin","socialGithub","socialYoutube"],email:["smtpHost","smtpPort","smtpUser","smtpPass","smtpSecure","smtpInsecureTLS","smtpFromAddress","smtpFromName"],pageNavigation:["bttEnabled","bttSmooth","bttLabel","bttThreshold","bttPosition","bttOffset","bttBottomOffset","gtbEnabled","gtbSmooth","gtbLabel","gtbThreshold","gtbPosition","gtbOffset","gtbBottomOffset"],cookies:["ccEnabled","ccMessage","ccAcceptAll","ccRejectAll","ccCustomize","ccSavePrefs","ccPrivacyText","ccPrivacyUrl","ccCookieText","ccCookieUrl","ccPosition","ccLayout","ccTheme","ccShowFunctional","ccShowAnalytics","ccShowMarketing","ccVersion","ccSettingsLink","ccSettingsLinkText"],breadcrumbs:["bcEnabled","bcHomeLabel","bcPosition","bcOffsetX","bcOffsetY"],motion:["mtEnabled","mtLabel","mtDefault","mtControl","mtPlacement","mtTriggerStyle","mtPosition","mtOffsetX","mtOffsetY","mtIconSize","mtIconRadius","mtClass"]},SECRET_FIELDS=["smtpPass"],BREADCRUMB_POSITIONS=["TL","TR","BL","BR"],MOTION_PLACEMENTS=["footer","floating","navbar"],MOTION_LABEL="Reduce motion";const d=["system","off","on"],c=(t,r,n,o)=>{const a=Number.parseInt(t,10);return Number.isFinite(a)?Math.min(o,Math.max(n,a)):r};export function motionFromSettings(t={}){const r=t.motion&&typeof t.motion=="object"?t.motion:{},n=t.footer||{},o=m=>r[m]!==void 0&&r[m]!==null,a=o("default")?r.default:n.motionDefault,i=o("control")?r.control:n.motionControl,l=c(r.iconSize,52,32,96);return{mtEnabled:(o("enabled")?r.enabled:n.showMotionToggle)!==!1,mtLabel:typeof r.label=="string"&&r.label.trim()?r.label.trim():MOTION_LABEL,mtDefault:d.includes(a)?a:"system",mtControl:i==="checkbox"?"checkbox":"switch",mtPlacement:MOTION_PLACEMENTS.includes(r.placement)?r.placement:"footer",mtTriggerStyle:r.triggerStyle==="icon-text"?"icon-text":"icon",mtPosition:BREADCRUMB_POSITIONS.includes(r.position)?r.position:"BL",mtOffsetX:e(c(r.offsetX,32,0,500)),mtOffsetY:e(c(r.offsetY,32,0,500)),mtIconSize:e(l),mtIconRadius:e(c(r.iconRadius,26,0,Math.floor(l/2))),mtClass:e(r.class)}}export function motionFromForm(t){const r=c(t.mtIconSize,52,32,96);return{enabled:t.mtEnabled===!0,default:d.includes(t.mtDefault)?t.mtDefault:"system",placement:MOTION_PLACEMENTS.includes(t.mtPlacement)?t.mtPlacement:"footer",control:t.mtControl==="checkbox"?"checkbox":"switch",triggerStyle:t.mtTriggerStyle==="icon-text"?"icon-text":"icon",label:e(t.mtLabel).trim().replace(/\s+/g," ").slice(0,40)||MOTION_LABEL,position:BREADCRUMB_POSITIONS.includes(t.mtPosition)?t.mtPosition:"BL",offsetX:c(t.mtOffsetX,32,0,500),offsetY:c(t.mtOffsetY,32,0,500),iconSize:r,iconRadius:c(t.mtIconRadius,26,0,Math.floor(r/2)),class:e(t.mtClass).trim()}}export function footerBlockNames(t){return[...new Set(String(t??"").split(/[\s,]+/).map(r=>r.trim().toLowerCase()).filter(Boolean))]}export function gaIdError(t){const r=e(t).trim();return!r||/^G-[A-Z0-9]{4,20}$/i.test(r)?"":"A measurement ID looks like G-XXXXXXXXXX (Google Analytics > Admin > Data streams)."}export const FOOTER_LAYOUTS=["auto","columns","row"],FOOTER_LOOKS=["","showcase"],FOOTER_FACTS_MAX=4;const p=/^(\/|#|https?:\/\/|mailto:)/,g=/^#[0-9a-f]{6}$/i;export function footerShowcaseErrors(t){const r=[],n=e(t.footerCtaUrl).trim();n&&!p.test(n)&&r.push("The footer call to action link must start with /, #, https:// or mailto: (Footer tool).");for(const[o,a]of[["from",t.footerGradFrom],["to",t.footerGradTo]]){const i=e(a).trim();i&&!g.test(i)&&r.push(`The footer gradient "${o}" colour must look like #f26b3a (Footer tool).`)}return r}const e=(t,r="")=>t==null?r:String(t),s=(t,r)=>{const n=Number.parseInt(t,10);return Number.isFinite(n)?n:r};export function homeValue(t){return/^\/[A-Za-z0-9\-_/]*$/.test(t||"")&&String(t).replace(/\/+$/,"")||"/"}export function formFromSettings(t={}){const r=t.backToTop||{},n=t.goToBottom||{},o=t.cookieConsent||{},a=t.breadcrumbs||{};return{title:e(t.title),tagline:e(t.tagline),siteUrl:e(t.baseUrl),adminHome:homeValue(t.adminHome),spacerSize:e(t.layoutOptions?.spacerSize??40),bodyClass:e(t.bodyClass),brandEnabled:t.brand?.enabled!==!1,brandText:e(t.brand?.text),brandLogo:e(t.brand?.logo),brandIcon:e(t.brand?.icon),brandUrl:e(t.brand?.url,"/"),favicon:e(t.favicon),adminBrandEnabled:t.adminBrand?.enabled!==!1,adminBrandTitle:e(t.adminBrand?.title),adminBrandLogo:e(t.adminBrand?.logo),adminBrandLogoDark:e(t.adminBrand?.logoDark),adminBrandIcon:e(t.adminBrand?.icon),footerCopyright:e(t.footer?.copyright),footerLayout:FOOTER_LAYOUTS.includes(t.footer?.layout)?t.footer.layout:"auto",footerBlurb:e(t.footer?.blurb),footerBlocks:Array.isArray(t.footer?.blocks)?t.footer.blocks.filter(i=>typeof i=="string").join(", "):"",footerClass:e(t.footer?.class),footerSocialClass:e(t.footer?.socialClass),footerLook:FOOTER_LOOKS.includes(t.footer?.look)?t.footer.look:"",footerCtaText:e(t.footer?.cta?.text),footerCtaHighlight:e(t.footer?.cta?.highlight),footerCtaUrl:e(t.footer?.cta?.url),footerCtaSub:e(t.footer?.cta?.sub),footerWatermark:e(t.footer?.watermark),footerStatus:e(t.footer?.status),footerFacts:Array.isArray(t.footer?.facts)?t.footer.facts.filter(i=>typeof i=="string").join(`
2
+ `):"",footerTagline:e(t.footer?.tagline),footerEmail:e(t.footer?.email),footerAddress:e(t.footer?.address),footerGradFrom:e(t.footer?.gradient?.from),footerGradTo:e(t.footer?.gradient?.to),socialTwitter:e(t.social?.twitter),socialFacebook:e(t.social?.facebook),socialInstagram:e(t.social?.instagram),socialLinkedin:e(t.social?.linkedin),socialGithub:e(t.social?.github),socialYoutube:e(t.social?.youtube),smtpHost:e(t.smtp?.host),smtpPort:e(t.smtp?.port||587),smtpUser:e(t.smtp?.user),smtpPass:"",smtpSecure:t.smtp?.secure===!0,smtpInsecureTLS:t.smtp?.allowInsecureTLS===!0,smtpFromAddress:e(t.smtp?.fromAddress),smtpFromName:e(t.smtp?.fromName),bttEnabled:r.enabled!==!1,bttSmooth:r.smooth!==!1,bttLabel:e(r.label),bttThreshold:e(r.scrollThreshold??300),bttPosition:e(r.position,"bottom-right"),bttOffset:e(r.offset??32),bttBottomOffset:e(r.bottomOffset??r.offset??32),gtbEnabled:n.enabled===!0,gtbSmooth:n.smooth!==!1,gtbLabel:e(n.label),gtbThreshold:e(n.scrollThreshold??300),gtbPosition:e(n.position,"bottom-right"),gtbOffset:e(n.offset??32),gtbBottomOffset:e(n.bottomOffset??n.offset??32),ccEnabled:o.enabled!==!1,ccMessage:e(o.message),ccAcceptAll:e(o.acceptAllText,"Accept All"),ccRejectAll:e(o.rejectAllText,"Reject All"),ccCustomize:e(o.customizeText,"Customize"),ccSavePrefs:e(o.savePreferencesText,"Save Preferences"),ccPrivacyText:e(o.privacyPolicyText,"Privacy Policy"),ccPrivacyUrl:e(o.privacyPolicyUrl),ccCookieText:e(o.cookiePolicyText,"Cookie Policy"),ccCookieUrl:e(o.cookiePolicyUrl),ccPosition:e(o.position,"bottom"),ccLayout:e(o.layout,"bar"),ccTheme:e(o.theme,"dark"),ccShowFunctional:o.showFunctional!==!1,ccShowAnalytics:o.showAnalytics!==!1,ccShowMarketing:o.showMarketing!==!1,ccVersion:e(o.consentVersion,"1.0"),ccSettingsLink:o.showSettingsLink!==!1,ccSettingsLinkText:e(o.settingsLinkText,"Cookie settings"),bcEnabled:a.enabled===!0,bcHomeLabel:e(a.homeLabel,"Home"),bcPosition:BREADCRUMB_POSITIONS.includes(a.position)?a.position:"TL",bcOffsetX:e(a.offsetX??8),bcOffsetY:e(a.offsetY??8),...motionFromSettings(t)}}export function payloadFromForm(t,r={},{adminHomeReady:n=!0}={}){const o=i=>e(i).trim(),a=motionFromForm(t);return{title:o(t.title),tagline:o(t.tagline),baseUrl:o(t.siteUrl).replace(/\/+$/,""),...n&&{adminHome:o(t.adminHome)||"/"},layoutOptions:{spacerSize:s(t.spacerSize,40)||40},bodyClass:o(t.bodyClass),brand:{...r.brand,enabled:t.brandEnabled!==!1,text:o(t.brandText),logo:o(t.brandLogo),icon:o(t.brandIcon),url:o(t.brandUrl)||"/"},favicon:o(t.favicon),adminBrand:{...r.adminBrand,enabled:t.adminBrandEnabled!==!1,title:o(t.adminBrandTitle),logo:o(t.adminBrandLogo),logoDark:o(t.adminBrandLogoDark),icon:o(t.adminBrandIcon)},footer:{copyright:o(t.footerCopyright),layout:FOOTER_LAYOUTS.includes(t.footerLayout)?t.footerLayout:"auto",blurb:o(t.footerBlurb),blocks:footerBlockNames(t.footerBlocks),links:r.footer?.links||[],showMotionToggle:a.enabled,motionDefault:a.default,motionControl:a.control,class:o(t.footerClass),socialClass:o(t.footerSocialClass),look:FOOTER_LOOKS.includes(t.footerLook)?t.footerLook:"",cta:{text:o(t.footerCtaText),highlight:o(t.footerCtaHighlight),url:o(t.footerCtaUrl),sub:o(t.footerCtaSub)},watermark:o(t.footerWatermark),status:o(t.footerStatus),facts:String(t.footerFacts??"").split(`
3
3
  `).map(i=>i.trim()).filter(Boolean).slice(0,FOOTER_FACTS_MAX),tagline:o(t.footerTagline),email:o(t.footerEmail),address:o(t.footerAddress),gradient:{from:o(t.footerGradFrom),to:o(t.footerGradTo)}},social:{twitter:o(t.socialTwitter),facebook:o(t.socialFacebook),instagram:o(t.socialInstagram),linkedin:o(t.socialLinkedin),github:o(t.socialGithub),youtube:o(t.socialYoutube)},smtp:{host:o(t.smtpHost),port:s(t.smtpPort,587)||587,user:o(t.smtpUser),pass:e(t.smtpPass),secure:t.smtpSecure===!0,allowInsecureTLS:t.smtpInsecureTLS===!0,fromAddress:o(t.smtpFromAddress),fromName:o(t.smtpFromName)},backToTop:{enabled:t.bttEnabled===!0,scrollThreshold:s(t.bttThreshold,300),position:e(t.bttPosition)||"bottom-right",offset:s(t.bttOffset,32),bottomOffset:s(t.bttBottomOffset,32),label:o(t.bttLabel),smooth:t.bttSmooth===!0},goToBottom:{enabled:t.gtbEnabled===!0,scrollThreshold:s(t.gtbThreshold,300),position:e(t.gtbPosition)||"bottom-right",offset:s(t.gtbOffset,32),bottomOffset:s(t.gtbBottomOffset,32),label:o(t.gtbLabel),smooth:t.gtbSmooth===!0},cookieConsent:{enabled:t.ccEnabled===!0,message:o(t.ccMessage),acceptAllText:o(t.ccAcceptAll),rejectAllText:o(t.ccRejectAll),customizeText:o(t.ccCustomize),savePreferencesText:o(t.ccSavePrefs),privacyPolicyText:o(t.ccPrivacyText),privacyPolicyUrl:o(t.ccPrivacyUrl),cookiePolicyText:o(t.ccCookieText),cookiePolicyUrl:o(t.ccCookieUrl),position:e(t.ccPosition)||"bottom",layout:e(t.ccLayout)||"bar",theme:e(t.ccTheme)||"dark",showFunctional:t.ccShowFunctional===!0,showAnalytics:t.ccShowAnalytics===!0,showMarketing:t.ccShowMarketing===!0,consentVersion:o(t.ccVersion)||"1.0",showSettingsLink:t.ccSettingsLink===!0,settingsLinkText:o(t.ccSettingsLinkText)||"Cookie settings"},breadcrumbs:{enabled:t.bcEnabled===!0,homeLabel:o(t.bcHomeLabel)||"Home",position:BREADCRUMB_POSITIONS.includes(t.bcPosition)?t.bcPosition:"TL",offsetX:s(t.bcOffsetX,8),offsetY:s(t.bcOffsetY,8)},motion:a}}export function siteUrlError(t){const r=e(t).trim().replace(/\/+$/,"");return r?/^https?:\/\//i.test(r)?/^https?:\/\/([a-z0-9.\-]+|\[[0-9a-f:.]+\])(:\d{1,5})?$/i.test(r)?"":"Just the address, like https://example.com - no page path after it.":"Start with https:// (or http://).":""}const b=t=>typeof t=="boolean"?t:e(t);export function snapshot(t){return JSON.stringify(Object.keys(t).sort().map(r=>[r,b(t[r])]))}export function changedTabs(t,r){const n=[];for(const[o,a]of Object.entries(TAB_FIELDS))a.some(i=>b(t[i])!==b(r[i]))&&n.push(o);return n}export function draftOf(t){return Object.fromEntries(Object.entries(t).filter(([r])=>!SECRET_FIELDS.includes(r)))}const h={footerMotionToggle:"mtEnabled",footerMotionDefault:"mtDefault",footerMotionControl:"mtControl"};export function formFromDraft(t,r={}){const n={...r};for(const[a,i]of Object.entries(h))a in n&&!(i in n)&&(n[i]=n[a]),delete n[a];const o={...t};for(const[a,i]of Object.entries(n))a in o&&!SECRET_FIELDS.includes(a)&&(o[a]=i);return o}export function settingsProblems(t,r={}){const n=[];return e(t.smtpHost).trim()?e(t.smtpFromAddress).trim()||n.push({tone:"warn",tab:"email",text:"No From address - mail has no sender and many servers refuse it."}):n.push({tone:"danger",tab:"email",text:"No SMTP host - mail goes to a throwaway test inbox and reaches no one (password resets, form notifications)."}),(t.ccEnabled===!0||e(r.googleAnalytics?.measurementId).trim())&&!e(t.ccPrivacyUrl).trim()&&n.push({tone:"warn",tab:"cookies",text:"The cookie banner is on but links to no privacy policy."}),n}export function describeCacheKey(t){const r=/^page:(.*?):m\d+:role([^:]*):/.exec(String(t||""));return r?{path:r[1]||"/",role:r[2]||"anon",page:!0}:{path:String(t||""),role:"",page:!1}}export function expiresIn(t,r=Date.now()){if(t==null)return"no expiry";const n=t-r;return n<=0?"expired":n<6e4?`${Math.round(n/1e3)}s`:n<36e5?`${Math.round(n/6e4)}m`:`${Math.round(n/36e5)}h`}export function footerForm(t={}){const r=formFromSettings(t);return Object.fromEntries(TAB_FIELDS.footer.map(n=>[n,r[n]]))}export function footerPayload(t){const{footer:r,social:n}=payloadFromForm(t);return delete r.links,delete r.showMotionToggle,delete r.motionDefault,delete r.motionControl,{footer:r,social:n}}export function siteSettingsForm(t={}){return Object.fromEntries(Object.entries(formFromSettings(t)).filter(([r])=>!TAB_FIELDS.footer.includes(r)&&!u.includes(r)))}export function siteSettingsPayload(...t){const{footer:r,social:n,favicon:o,backToTop:a,goToBottom:i,breadcrumbs:l,motion:m,...f}=payloadFromForm(...t);return f}export const APPEARANCE_TABS=["favicon","pageNavigation","breadcrumbs","motion","search"];const u=APPEARANCE_TABS.flatMap(t=>TAB_FIELDS[t]||[]);export function appearanceForm(t={}){const r=formFromSettings(t);return Object.fromEntries(u.map(n=>[n,r[n]]))}export function appearancePayload(t){const{favicon:r,backToTop:n,goToBottom:o,breadcrumbs:a,motion:i}=payloadFromForm(t);return{favicon:r,backToTop:n,goToBottom:o,breadcrumbs:a,motion:i}}