@jant/core 1.0.1 → 1.1.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 (58) hide show
  1. package/dist/{app-Gt7_skt6.js → app-CKQ9PqAr.js} +791 -89
  2. package/dist/client/.vite/manifest.json +115 -75
  3. package/dist/client/_assets/chunks/{confirm-D7GrwsCN.js → confirm-CMe01lne.js} +1 -1
  4. package/dist/client/_assets/chunks/{create-editor-5Y49x7h5.js → create-editor-BQkrw8Ax.js} +4 -4
  5. package/dist/client/_assets/chunks/footnote-rail-B08scyhW.js +2 -0
  6. package/dist/client/_assets/chunks/{jant-locale-picker-DL6mIOT5.js → jant-locale-picker-2L4rkDaz.js} +1 -1
  7. package/dist/client/_assets/chunks/lit-Bw_voPoW.js +2 -0
  8. package/dist/client/_assets/chunks/preload-helper-Czpn1I53.js +1 -0
  9. package/dist/client/_assets/chunks/runtime-paths-y0_gHowM.js +1 -0
  10. package/dist/client/_assets/chunks/{settings-paths-h6RjIe3C.js → settings-paths-B0bNUaih.js} +1 -1
  11. package/dist/client/_assets/chunks/slug-format-CYmQE5ln.js +1 -0
  12. package/dist/client/_assets/chunks/{sortable-list-DWNKv782.js → sortable-list-t11Ma1Ek.js} +1 -1
  13. package/dist/client/_assets/chunks/{unsafe-html-B5ZEXaxg.js → unsafe-html-CWos3v6N.js} +1 -1
  14. package/dist/client/_assets/chunks/unsafe-svg-DZl-yjas.js +1 -0
  15. package/dist/client/_assets/client-B0-s9sqx.css +2 -0
  16. package/dist/client/_assets/client-Dp46QSht.js +354 -0
  17. package/dist/client/_assets/client-auth-CG55rWb5.js +859 -0
  18. package/dist/client/_assets/{client-compose-oxzPb3SS.js → client-compose-DkUTuavR.js} +261 -261
  19. package/dist/client/_assets/{client-manage-C1eDB1Rc.js → client-manage-DnYdQAhf.js} +176 -176
  20. package/dist/client/_assets/{client-settings-DIM44Zqh.js → client-settings-CHgsIqXJ.js} +166 -166
  21. package/dist/client/_assets/client-share-0DICJjAc.css +1 -0
  22. package/dist/client/_assets/client-share-C59mOLJ1.js +149 -0
  23. package/dist/index.js +1 -1
  24. package/dist/node.js +2 -2
  25. package/package.json +2 -1
  26. package/src/client/components/jant-post-menu.ts +80 -13
  27. package/src/client/components/jant-share-dialog.ts +422 -0
  28. package/src/client/components/jant-share-menu.ts +188 -0
  29. package/src/client/lazy-entries.ts +21 -1
  30. package/src/client/post-menu-shared.ts +100 -0
  31. package/src/client/share-capture.ts +443 -0
  32. package/src/client/share-launch.ts +133 -0
  33. package/src/client-share.ts +8 -0
  34. package/src/client.ts +1 -0
  35. package/src/lib/discover.ts +31 -0
  36. package/src/lib/share-card.ts +653 -0
  37. package/src/lib/version.ts +2 -0
  38. package/src/routes/auth/setup.tsx +37 -1
  39. package/src/routes/pages/partials.tsx +23 -0
  40. package/src/style-share.css +16 -0
  41. package/src/styles/components.css +14 -0
  42. package/src/styles/share.css +1103 -0
  43. package/src/styles/ui.css +6 -0
  44. package/src/ui/layouts/BaseLayout.tsx +7 -0
  45. package/src/ui/layouts/SiteLayout.tsx +1 -0
  46. package/src/ui/share/ShareCard.tsx +298 -0
  47. package/src/ui/shared/Icon.tsx +23 -3
  48. package/src/ui/shared/MediaGallery.tsx +12 -1
  49. package/src/ui/shared/PostFooter.tsx +20 -4
  50. package/src/ui/shared/icon-collector.ts +28 -0
  51. package/src/ui/shared/post-article-attributes.ts +3 -0
  52. package/dist/client/_assets/chunks/footnote-rail-BJwswtVQ.js +0 -1
  53. package/dist/client/_assets/chunks/lit-DW8VmJAT.js +0 -2
  54. package/dist/client/_assets/chunks/slug-format-Dsi0e9Xn.js +0 -1
  55. package/dist/client/_assets/chunks/unsafe-svg-DTZZEvLU.js +0 -2
  56. package/dist/client/_assets/client-BaqmpPQ-.css +0 -2
  57. package/dist/client/_assets/client-C6melOtG.js +0 -296
  58. package/dist/client/_assets/client-auth-Ccq8kSqq.js +0 -828
@@ -1,4 +1,4 @@
1
- import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v as u,x as d}from"./chunks/lit-DW8VmJAT.js";import{n as f}from"./chunks/unsafe-html-B5ZEXaxg.js";import{n as p,t as m}from"./chunks/site-header-nav-DzXsFk05.js";import{n as h}from"./chunks/confirm-D7GrwsCN.js";import{n as g,r as _,t as v}from"./chunks/slug-format-Dsi0e9Xn.js";import{_ as ee,a as te,c as ne,i as y,n as re,o as b,p as x,r as ie,s as ae}from"./chunks/types-D5iF3H1a.js";import{a as oe,i as se,n as ce,r as S,t as C}from"./chunks/settings-paths-h6RjIe3C.js";import{a as w,c as le,d as ue,f as T,i as de,l as fe,n as pe,o as E,r as D,s as O,t as me}from"./chunks/sortable-list-DWNKv782.js";import{_ as he,r as k,t as A}from"./chunks/create-editor-5Y49x7h5.js";function j(e){if(!e)return;let t=document.createElement(`template`);t.innerHTML=e.trim();let n=[`[data-site-header-fragment="header"]`,`[data-site-header-fragment="drawer-backdrop"]`,`[data-site-header-fragment="drawer"]`],r=!1;m(document);for(let e of n){let n=document.querySelector(e),i=t.content.querySelector(e);n&&i&&(n.replaceWith(i),r=!0)}r&&p(document)}var M=`<svg class="lucide lucide-funnel icon-fine" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"/></svg>`,ge=250,_e=o`<svg
1
+ import{a as e,i as t,l as n,o as r,p as i,r as a,u as o}from"./chunks/runtime-paths-y0_gHowM.js";import{d as s,i as c,n as l,t as u,u as d}from"./chunks/lit-Bw_voPoW.js";import{n as f}from"./chunks/unsafe-html-CWos3v6N.js";import{n as p,t as m}from"./chunks/site-header-nav-DzXsFk05.js";import{n as h}from"./chunks/confirm-CMe01lne.js";import{_ as g,a as _,c as ee,i as v,n as te,o as y,p as b,r as ne,s as re}from"./chunks/types-D5iF3H1a.js";import{n as ie,r as x,t as S}from"./chunks/slug-format-CYmQE5ln.js";import{a as ae,i as oe,n as C,r as w,t as T}from"./chunks/settings-paths-B0bNUaih.js";import{a as E,c as se,d as ce,f as D,i as le,l as ue,n as de,o as O,r as k,s as A,t as fe}from"./chunks/sortable-list-t11Ma1Ek.js";import{_ as pe,r as j,t as M}from"./chunks/create-editor-BQkrw8Ax.js";function N(e){if(!e)return;let t=document.createElement(`template`);t.innerHTML=e.trim();let n=[`[data-site-header-fragment="header"]`,`[data-site-header-fragment="drawer-backdrop"]`,`[data-site-header-fragment="drawer"]`],r=!1;m(document);for(let e of n){let n=document.querySelector(e),i=t.content.querySelector(e);n&&i&&(n.replaceWith(i),r=!0)}r&&p(document)}var P=`<svg class="lucide lucide-funnel icon-fine" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"/></svg>`,me=250,he=c`<svg
2
2
  viewBox="0 0 24 24"
3
3
  fill="none"
4
4
  stroke="currentColor"
@@ -10,7 +10,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
10
10
  <circle cx="12" cy="12" r="10" />
11
11
  <line x1="12" x2="12" y1="8" y2="12" />
12
12
  <line x1="12" x2="12.01" y1="16" y2="16" />
13
- </svg>`,ve=class extends c{static properties={labels:{type:Object},_open:{state:!0},_mode:{state:!0},_id:{state:!0},_title:{state:!0},_slug:{state:!0},_slugEdited:{state:!0},_slugState:{state:!0},_slugOpen:{state:!0},_sortOrder:{state:!0},_saving:{state:!0},_error:{state:!0}};#e=``;#t=``;#n=``;#r=null;#i=null;#a=null;createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this.labels={},this._open=!1,this._mode=`create`,this._id=null,this._title=``,this._slug=``,this._slugEdited=!1,this._slugState=`unknown`,this._slugOpen=!1,this._sortOrder=`newest`,this._saving=!1,this._error=``}async open(e){return this.#o(),e.collectionId&&!await this.#s(e.collectionId)?{changed:!1}:(this._open=!0,await this.updateComplete,this.#u(),this.#c(),new Promise(e=>{this.#r=e}))}#o(){this._mode=`create`,this._id=null,this._title=``,this._slug=``,this._slugEdited=!1,this._slugState=`unknown`,this._slugOpen=!1,this._sortOrder=`newest`,this._saving=!1,this._error=``,this.#e=``,this.#t=``,this.#n=``}async#s(e){try{let t=await fetch(a(`/api/collections/${e}`));if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();return this._mode=`edit`,this._id=n.id,this._title=n.title??``,this._slug=n.slug??``,this.#t=n.slug??``,this._slugEdited=!0,this.#e=n.description??``,this._sortOrder=n.sortOrder??`newest`,!0}catch{return l(this.labels.loadFailed,`error`),!1}}#c(){let e=this.querySelector(`.collection-dialog`);e&&(e.open||e.showModal(),this.querySelector(`[data-field='title']`)?.focus())}#l(e){let t=this.querySelector(`.collection-dialog`);t?.open&&t.close(),this._open=!1,this.#i&&clearTimeout(this.#i),this.#d();let n=this.#r;this.#r=null,n?.(e)}#u(){let e=this.querySelector(`[data-collection-description]`);!e||this.#a||(this.#a=A({element:e,placeholder:this.labels.descriptionPlaceholder,content:this.#e||void 0,onUpdate:e=>{this.#e=e,this._error&&=``}}),this.#e=k(this.#a.getJSON()))}#d(){this.#a?.destroy(),this.#a=null}#f(e){this._title=e,!this._slugEdited&&this.#p()}async#p(){let e=this._title.trim();if(!e){this.#n=``,this._slug=``,this._slugState=`unknown`;return}let t=g(await ce(e),200);this._slugEdited||this._title.trim()!==e||(this.#n=t,this._slug=t,this.#h())}#m(e){this._slugEdited=!0,this._slug=e.trim().toLowerCase(),this.#h()}#h(){this.#i&&clearTimeout(this.#i),this._slugState=`checking`,this.#i=setTimeout(()=>void this.#g(),ge)}async#g(){let e=this._slug;if(!e){this._slugState=`unknown`;return}if(this.#_()!==null){this._slugState=`taken`;return}try{let t=new URLSearchParams({mode:`check`,slug:e});this._id&&t.set(`collectionId`,this._id);let n=await fetch(a(`/api/collections/slug?${t.toString()}`));if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json();if(e!==this._slug)return;this._slugState=r.available?`available`:`taken`}catch{if(e!==this._slug)return;this._slugState=`unknown`}}#_(){return v(this._slug,{maxLength:200})}#v(){let e=this.#_();return e===`invalid`?this.labels.linkInvalid:e===`reserved`?this.labels.linkReserved:e===`too_long`?this.labels.linkTooLong:this._slugState===`taken`?this.labels.linkTaken:null}#y(){let e=a(S(this._slug)),t=globalThis.location?.origin&&globalThis.location.origin!==`null`?globalThis.location.origin:`http://localhost`;return new URL(e,`${t}/`).toString()}#b(){this._slugOpen||(this._slugOpen=!0,this.updateComplete.then(()=>{let e=this.querySelector(`[data-field='slug']`);e?.focus(),e?.select()}))}#x(){this.#n&&(this._slug=this.#n,this._slugEdited=!1,this.#h())}#S(){if(!this._slug&&!this._slugOpen)return s;let e=this.#v(),t=this._mode===`edit`&&this._slug!==this.#t;if(!this._slugOpen)return o`
13
+ </svg>`,ge=class extends u{static properties={labels:{type:Object},_open:{state:!0},_mode:{state:!0},_id:{state:!0},_title:{state:!0},_slug:{state:!0},_slugEdited:{state:!0},_slugState:{state:!0},_slugOpen:{state:!0},_sortOrder:{state:!0},_saving:{state:!0},_error:{state:!0}};#e=``;#t=``;#n=``;#r=null;#i=null;#a=null;createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this.labels={},this._open=!1,this._mode=`create`,this._id=null,this._title=``,this._slug=``,this._slugEdited=!1,this._slugState=`unknown`,this._slugOpen=!1,this._sortOrder=`newest`,this._saving=!1,this._error=``}async open(e){return this.#o(),e.collectionId&&!await this.#s(e.collectionId)?{changed:!1}:(this._open=!0,await this.updateComplete,this.#u(),this.#c(),new Promise(e=>{this.#r=e}))}#o(){this._mode=`create`,this._id=null,this._title=``,this._slug=``,this._slugEdited=!1,this._slugState=`unknown`,this._slugOpen=!1,this._sortOrder=`newest`,this._saving=!1,this._error=``,this.#e=``,this.#t=``,this.#n=``}async#s(e){try{let t=await fetch(a(`/api/collections/${e}`));if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();return this._mode=`edit`,this._id=n.id,this._title=n.title??``,this._slug=n.slug??``,this.#t=n.slug??``,this._slugEdited=!0,this.#e=n.description??``,this._sortOrder=n.sortOrder??`newest`,!0}catch{return d(this.labels.loadFailed,`error`),!1}}#c(){let e=this.querySelector(`.collection-dialog`);e&&(e.open||e.showModal(),this.querySelector(`[data-field='title']`)?.focus())}#l(e){let t=this.querySelector(`.collection-dialog`);t?.open&&t.close(),this._open=!1,this.#i&&clearTimeout(this.#i),this.#d();let n=this.#r;this.#r=null,n?.(e)}#u(){let e=this.querySelector(`[data-collection-description]`);!e||this.#a||(this.#a=M({element:e,placeholder:this.labels.descriptionPlaceholder,content:this.#e||void 0,onUpdate:e=>{this.#e=e,this._error&&=``}}),this.#e=j(this.#a.getJSON()))}#d(){this.#a?.destroy(),this.#a=null}#f(e){this._title=e,!this._slugEdited&&this.#p()}async#p(){let e=this._title.trim();if(!e){this.#n=``,this._slug=``,this._slugState=`unknown`;return}let t=ie(await C(e),200);this._slugEdited||this._title.trim()!==e||(this.#n=t,this._slug=t,this.#h())}#m(e){this._slugEdited=!0,this._slug=e.trim().toLowerCase(),this.#h()}#h(){this.#i&&clearTimeout(this.#i),this._slugState=`checking`,this.#i=setTimeout(()=>void this.#g(),me)}async#g(){let e=this._slug;if(!e){this._slugState=`unknown`;return}if(this.#_()!==null){this._slugState=`taken`;return}try{let t=new URLSearchParams({mode:`check`,slug:e});this._id&&t.set(`collectionId`,this._id);let n=await fetch(a(`/api/collections/slug?${t.toString()}`));if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json();if(e!==this._slug)return;this._slugState=r.available?`available`:`taken`}catch{if(e!==this._slug)return;this._slugState=`unknown`}}#_(){return S(this._slug,{maxLength:200})}#v(){let e=this.#_();return e===`invalid`?this.labels.linkInvalid:e===`reserved`?this.labels.linkReserved:e===`too_long`?this.labels.linkTooLong:this._slugState===`taken`?this.labels.linkTaken:null}#y(){let e=a(w(this._slug)),t=globalThis.location?.origin&&globalThis.location.origin!==`null`?globalThis.location.origin:`http://localhost`;return new URL(e,`${t}/`).toString()}#b(){this._slugOpen||(this._slugOpen=!0,this.updateComplete.then(()=>{let e=this.querySelector(`[data-field='slug']`);e?.focus(),e?.select()}))}#x(){this.#n&&(this._slug=this.#n,this._slugEdited=!1,this.#h())}#S(){if(!this._slug&&!this._slugOpen)return l;let e=this.#v(),t=this._mode===`edit`&&this._slug!==this.#t;if(!this._slugOpen)return c`
14
14
  <div class="collection-quick-link-box">
15
15
  <div class="collection-quick-link-row">
16
16
  <p
@@ -27,19 +27,19 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
27
27
  ${this.labels.editLink}
28
28
  </button>
29
29
  </div>
30
- ${e?o`<p class="collection-dialog-link-problem">${e}</p>`:s}
31
- ${t?o`<p class="collection-dialog-link-problem">
30
+ ${e?c`<p class="collection-dialog-link-problem">${e}</p>`:l}
31
+ ${t?c`<p class="collection-dialog-link-problem">
32
32
  ${this.labels.linkMovesWarning}
33
- </p>`:s}
33
+ </p>`:l}
34
34
  </div>
35
- `;let n=!!this.#n&&this._slug!==this.#n;return o`
35
+ `;let n=!!this.#n&&this._slug!==this.#n;return c`
36
36
  <div class="collection-quick-link-editor">
37
37
  <div class="field">
38
38
  <div class="collection-quick-link-row">
39
39
  <label class="label mb-0" for="collection-dialog-slug"
40
40
  >${this.labels.link}</label
41
41
  >
42
- ${n?o`
42
+ ${n?c`
43
43
  <button
44
44
  type="button"
45
45
  class="collection-quick-link-action"
@@ -47,7 +47,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
47
47
  >
48
48
  ${this.labels.resetLink}
49
49
  </button>
50
- `:s}
50
+ `:l}
51
51
  </div>
52
52
  <input
53
53
  id="collection-dialog-slug"
@@ -63,17 +63,17 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
63
63
  .value=${this._slug}
64
64
  @input=${e=>this.#m(e.target.value)}
65
65
  />
66
- ${e?o`<p class="collection-dialog-link-problem">${e}</p>`:this._slug?o`<p class="collection-dialog-link-preview">
66
+ ${e?c`<p class="collection-dialog-link-problem">${e}</p>`:this._slug?c`<p class="collection-dialog-link-preview">
67
67
  ${this.#y()}
68
- </p>`:o`<p class="collection-dialog-link-help">
68
+ </p>`:c`<p class="collection-dialog-link-help">
69
69
  ${this.labels.linkHelp}
70
70
  </p>`}
71
- ${t?o`<p class="collection-dialog-link-problem">
71
+ ${t?c`<p class="collection-dialog-link-problem">
72
72
  ${this.labels.linkMovesWarning}
73
- </p>`:s}
73
+ </p>`:l}
74
74
  </div>
75
75
  </div>
76
- `}#C(){return!this._title.trim()||!this._slug?this.labels.titleAndLinkRequired:this.#v()}async#w(){if(this._saving)return;let e=this.#C();if(e){this._error=e;return}this._saving=!0,this._error=``;let t=this._title.trim(),n=this.#e.trim(),r={slug:this._slug,title:t,sortOrder:this._sortOrder};n?r.description=n:this._id&&(r.description=null);try{let e=await fetch(a(this._id?`/api/collections/${this._id}`:`/api/collections`),{method:this._id?`PUT`:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}),n=await e.json().catch(()=>null);if(!e.ok){this._error=n?.error??this.labels.saveFailed;return}l(this.labels.saved),this.#l({changed:!0,collection:{id:n?.id??this._id??``,slug:n?.slug??this._slug,title:n?.title??t}})}catch{this._error=this.labels.saveFailed}finally{this._saving=!1}}#T=e=>{if(this._open){if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this.#l({changed:!1});return}if(e.key===`Enter`){let t=e.target;if(t?.isContentEditable||t?.tagName===`TEXTAREA`)return;e.preventDefault(),this.#w()}}};connectedCallback(){super.connectedCallback(),this.addEventListener(`keydown`,this.#T)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`keydown`,this.#T),this.#i&&clearTimeout(this.#i),this.#d()}render(){if(!this._open)return s;let e=this._mode===`edit`?this.labels.editHeading:this.labels.createHeading;return o`
76
+ `}#C(){return!this._title.trim()||!this._slug?this.labels.titleAndLinkRequired:this.#v()}async#w(){if(this._saving)return;let e=this.#C();if(e){this._error=e;return}this._saving=!0,this._error=``;let t=this._title.trim(),n=this.#e.trim(),r={slug:this._slug,title:t,sortOrder:this._sortOrder};n?r.description=n:this._id&&(r.description=null);try{let e=await fetch(a(this._id?`/api/collections/${this._id}`:`/api/collections`),{method:this._id?`PUT`:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}),n=await e.json().catch(()=>null);if(!e.ok){this._error=n?.error??this.labels.saveFailed;return}d(this.labels.saved),this.#l({changed:!0,collection:{id:n?.id??this._id??``,slug:n?.slug??this._slug,title:n?.title??t}})}catch{this._error=this.labels.saveFailed}finally{this._saving=!1}}#T=e=>{if(this._open){if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this.#l({changed:!1});return}if(e.key===`Enter`){let t=e.target;if(t?.isContentEditable||t?.tagName===`TEXTAREA`)return;e.preventDefault(),this.#w()}}};connectedCallback(){super.connectedCallback(),this.addEventListener(`keydown`,this.#T)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`keydown`,this.#T),this.#i&&clearTimeout(this.#i),this.#d()}render(){if(!this._open)return l;let e=this._mode===`edit`?this.labels.editHeading:this.labels.createHeading;return c`
77
77
  <dialog
78
78
  class="dialog collection-dialog"
79
79
  @cancel=${e=>{e.preventDefault(),this.#l({changed:!1})}}
@@ -108,7 +108,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
108
108
  data-field="title"
109
109
  required
110
110
  maxlength=${120}
111
- placeholder=${this._mode===`edit`?s:this.labels.titlePlaceholder}
111
+ placeholder=${this._mode===`edit`?l:this.labels.titlePlaceholder}
112
112
  .value=${this._title}
113
113
  @input=${e=>this.#f(e.target.value)}
114
114
  />
@@ -135,7 +135,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
135
135
  .value=${this._sortOrder}
136
136
  @change=${e=>{this._sortOrder=e.target.value}}
137
137
  >
138
- ${re.map(e=>o`<option
138
+ ${te.map(e=>c`<option
139
139
  value=${e}
140
140
  ?selected=${e===this._sortOrder}
141
141
  >
@@ -144,10 +144,10 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
144
144
  </select>
145
145
  </div>
146
146
 
147
- ${this._error?o`<div class="alert-destructive" role="alert">
148
- ${_e}
147
+ ${this._error?c`<div class="alert-destructive" role="alert">
148
+ ${he}
149
149
  <section><p>${this._error}</p></section>
150
- </div>`:s}
150
+ </div>`:l}
151
151
  </div>
152
152
 
153
153
  <footer class="collection-dialog-actions">
@@ -169,7 +169,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
169
169
  </footer>
170
170
  </div>
171
171
  </dialog>
172
- `}};customElements.get(`jant-collection-dialog`)||customElements.define(`jant-collection-dialog`,ve);var N=`data-collection-dialog-labels`,P=null,F=null;function ye(){if(P)return P;let e=document.querySelector(`[${N}]`)?.getAttribute(N);if(!e)return null;try{return P=JSON.parse(e),P}catch{return null}}function be(e){return F?.isConnected?(F.labels=e,F):(F=document.createElement(`jant-collection-dialog`),F.labels=e,document.body.appendChild(F),F)}async function I(e={}){let t=ye();return t?be(t).open(e):{changed:!1}}var L=`X-Jant-Site-Header`,R=`include`,xe=class extends c{static properties={items:{type:Array},labels:{type:Object},systemNavItems:{type:Array,attribute:`system-nav-items`},collections:{type:Array},suggestedLinks:{type:Array,attribute:`suggested-links`},siteName:{type:String,attribute:`site-name`},rssFeedsEnabled:{type:Boolean,attribute:`rss-feeds-enabled`},_items:{state:!0},_editingId:{state:!0},_editLabel:{state:!0},_editUrl:{state:!0},_togglingKeys:{state:!0},_showLinkForm:{state:!0},_newLinkLabel:{state:!0},_newLinkUrl:{state:!0},_addingLink:{state:!0},_showPreviewMore:{state:!0},_addingCollectionId:{state:!0},_showCollectionPicker:{state:!0},_collectionDialogOpen:{state:!0},_collectionDialogView:{state:!0},_creatingCollection:{state:!0},_createCollectionError:{state:!0},_createdCollection:{state:!0},_addingSuggestedKey:{state:!0},_pageDialogOpen:{state:!0},_pageDialogView:{state:!0},_pageQuery:{state:!0},_pages:{state:!0},_pageAddress:{state:!0},_pageSearchLoading:{state:!0},_pageSearchError:{state:!0},_selectedPageIndex:{state:!0},_addingPageId:{state:!0},_newPageTitle:{state:!0},_newPageSlug:{state:!0},_slugEdited:{state:!0},_slugCheckLoading:{state:!0},_slugTaken:{state:!0},_creatingPage:{state:!0},_createPageError:{state:!0},_createdPage:{state:!0}};#e=null;#t=null;#n=!1;#r=null;#i=null;#a=0;#o=null;#s=0;#c=null;#l=0;#u=()=>{this._showLinkForm=!1,document.removeEventListener(`click`,this.#u)};#d=()=>{this._showCollectionPicker=!1,document.removeEventListener(`click`,this.#d)};#f=e=>{e.target instanceof Node&&(this.querySelector(`[data-preview-more]`)?.contains(e.target)||this.#se())};#p=e=>{if(!(`key`in e)||e.key!==`Escape`||!this._showPreviewMore)return;let t=e;t.isComposing||t.keyCode===229||(e.preventDefault(),this.#se(),this.querySelector(`[data-preview-more-trigger]`)?.focus())};#m=e=>{e.key===`Escape`&&!e.isComposing&&e.keyCode!==229&&this._showCollectionPicker&&(e.preventDefault(),e.stopPropagation(),this.#d(),this.querySelector(`[data-add-collection-trigger]`)?.focus())};createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this.items=[],this.labels={},this.systemNavItems=[],this.collections=[],this.suggestedLinks=[],this.siteName=``,this.rssFeedsEnabled=!1,this._items=[],this._editingId=null,this._editLabel=``,this._editUrl=``,this._togglingKeys=new Set,this._showLinkForm=!1,this._newLinkLabel=``,this._newLinkUrl=``,this._addingLink=!1,this._showPreviewMore=!1,this._addingCollectionId=null,this._showCollectionPicker=!1,this._collectionDialogOpen=!1,this._collectionDialogView=`create`,this._creatingCollection=!1,this._createCollectionError=``,this._createdCollection=null,this._addingSuggestedKey=null,this._pageDialogOpen=!1,this._pageDialogView=`picker`,this._pageQuery=``,this._pages=[],this._pageAddress=null,this._pageSearchLoading=!1,this._pageSearchError=!1,this._selectedPageIndex=0,this._addingPageId=null,this._newPageTitle=``,this._newPageSlug=``,this._slugEdited=!1,this._slugCheckLoading=!1,this._slugTaken=!1,this._creatingPage=!1,this._createPageError=``,this._createdPage=null}update(e){(!this.#n||e.has(`items`))&&(this._items=[...this.items??[]],this.#n=!0),super.update(e)}updated(){this._showPreviewMore&&this.#oe.length===0&&this.#se(),this.#H()}disconnectedCallback(){super.disconnectedCallback(),this.#e?.destroy(),this.#e=null,this.#t?.destroy(),this.#t=null,document.removeEventListener(`click`,this.#u),document.removeEventListener(`click`,this.#d),this.#se(),this.#y()}#h(){return{"Content-Type":`application/json`,Accept:`application/json`,[L]:R}}#g(){return{Accept:`application/json`,[L]:R}}#_(e){let t={...e};return delete t.headerHtml,t}#v(e){let t=e.type===`system`?this.systemNavItems.find(t=>t.key===e.systemKey)?.label:void 0,n=e.label.trim()||t||e.displayLabel||e.targetTitle?.trim()||e.label;return{...e,displayLabel:n}}#y(){this.#i!==null&&(clearTimeout(this.#i),this.#i=null),this.#o!==null&&(clearTimeout(this.#o),this.#o=null),this.#c!==null&&(clearTimeout(this.#c),this.#c=null),this.#a+=1,this.#s+=1,this.#l+=1}async#b(){if(this._pageDialogOpen)return;this.#y(),this._pageDialogOpen=!0,this._pageDialogView=`picker`,this._pageQuery=``,this._pages=[],this._pageAddress=null,this._pageSearchError=!1,this._selectedPageIndex=0,this._addingPageId=null,this._newPageTitle=``,this._newPageSlug=``,this._slugEdited=!1,this._slugCheckLoading=!1,this._slugTaken=!1,this._creatingPage=!1,this._createPageError=``,this._createdPage=null,await this.updateComplete;let e=this.querySelector(`#nav-page-dialog`);e&&!e.open&&e.showModal(),this.querySelector(`#nav-page-search`)?.focus(),this.#C()}#x(){let e=this.querySelector(`[data-add-page-trigger]`),t=this.querySelector(`#nav-page-dialog`);t?.open&&t.close(),this.#y(),this._pageDialogOpen=!1,this.updateComplete.then(()=>e?.focus())}async#S(e){let t=++this.#a,n=new URLSearchParams({url:e});this._pageSearchLoading=!0,this._pageSearchError=!1;try{let e=await fetch(`/api/nav-items/resolve?${n.toString()}`,{headers:{Accept:`application/json`}});if(!e.ok)throw Error(`HTTP ${e.status}`);let r=await e.json();if(t!==this.#a)return;this._pages=[],this._pageAddress=r.resolution??null,this._selectedPageIndex=0}catch{t===this.#a&&(this._pages=[],this._pageAddress=null,this._pageSearchError=!0)}finally{t===this.#a&&(this._pageSearchLoading=!1)}}async#C(){let e=++this.#a,t=new URLSearchParams({limit:`20`}),n=this._pageQuery.trim();n&&t.set(`q`,n),this._pageSearchLoading=!0,this._pageSearchError=!1,this._pageAddress=null;try{let n=await fetch(`/api/nav-items/pages?${t.toString()}`,{headers:{Accept:`application/json`}});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json();if(e!==this.#a)return;let i=new Set(this._items.flatMap(e=>e.type===`page`&&e.postId?[e.postId]:[]));this._pages=(r.pages??[]).filter(e=>!i.has(e.id)),this._selectedPageIndex=0}catch{e===this.#a&&(this._pages=[],this._pageSearchError=!0)}finally{e===this.#a&&(this._pageSearchLoading=!1)}}#w(){this.#i!==null&&clearTimeout(this.#i),this.#i=setTimeout(()=>{this.#i=null;let e=this._pageQuery.trim();d(e)?this.#S(e):this.#C()},200)}async#T(e){if(!this._addingPageId){this._addingPageId=e.id;try{let t=await fetch(`/api/nav-items`,{method:`POST`,headers:this.#h(),body:JSON.stringify({type:`page`,postId:e.id,placement:`header`})});if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json(),r=this.#v(this.#_(n));this.#V(),this._items=[...this._items,r],this._pages=this._pages.filter(t=>t.id!==e.id),j(n.headerHtml),l(this.labels.pageAdded),this.#x()}catch{l(this.labels.saveFailed,`error`)}finally{this._addingPageId=null}}}#E(){this.#a+=1,this._pageDialogView=`create`,this._newPageTitle=``,this._newPageSlug=``,this._slugEdited=!1,this._slugCheckLoading=!1,this._slugTaken=!1,this._createPageError=``,this.updateComplete.then(()=>{this.querySelector(`#nav-new-page-title`)?.focus()})}#D(){this.#s+=1,this.#l+=1,this._pageDialogView=`picker`,this._createPageError=``,this.updateComplete.then(()=>{this.querySelector(`#nav-page-search`)?.focus()})}#O(){if(this._slugEdited)return;this.#o!==null&&clearTimeout(this.#o);let e=this._newPageTitle.trim();if(!e){this._newPageSlug=``;return}this.#o=setTimeout(()=>{this.#o=null,this.#k(e)},250)}async#k(e){let t=++this.#s,n=new URLSearchParams({mode:`suggest`,title:e});try{let e=await fetch(`/api/posts/slug?${n.toString()}`,{headers:{Accept:`application/json`}});if(!e.ok)return;let r=await e.json();if(t!==this.#s||this._slugEdited||this._pageDialogView!==`create`)return;this._newPageSlug=r.slug?.trim()??``,this._slugTaken=!1}catch{}}#A(){this.#c!==null&&clearTimeout(this.#c),this._slugTaken=!1;let e=this._newPageSlug.trim();if(!e||v(e,{maxLength:200})){this._slugCheckLoading=!1;return}this._slugCheckLoading=!0,this.#c=setTimeout(()=>{this.#c=null,this.#j(e)},250)}async#j(e){let t=++this.#l,n=new URLSearchParams({mode:`check`,slug:e});try{let r=await fetch(`/api/posts/slug?${n.toString()}`,{headers:{Accept:`application/json`}});if(!r.ok)return;let i=await r.json();if(t!==this.#l||this._newPageSlug.trim()!==e)return;this._slugTaken=i.available===!1}catch{}finally{t===this.#l&&(this._slugCheckLoading=!1)}}#M(){let e=v(this._newPageSlug,{maxLength:200});return e===`invalid`?this.labels.slugInvalid:e===`reserved`?this.labels.slugReserved:e===`too_long`?this.labels.slugTooLong:this._slugTaken?this.labels.slugUnavailable:``}async#N(){let e=this._newPageTitle.trim(),t=this._newPageSlug.trim();if(!e){this._createPageError=this.labels.titleRequired;return}let n=this.#M();if(n){this._createPageError=n;return}if(!this._slugCheckLoading){this._creatingPage=!0,this._createPageError=``;try{let n=await fetch(`/api/posts`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({format:`note`,title:e,...t&&{slug:t},status:`published`,visibility:`latest_hidden`})});if(!n.ok){if(n.status===409){this._slugTaken=!0,this._createPageError=this.labels.slugUnavailable;return}throw Error(`HTTP ${n.status}`)}let r=await n.json();this._createdPage={id:r.id,title:r.title||e,slug:r.slug},this._pageDialogView=`created`}catch{this._createPageError=this.labels.createPageFailed}finally{this._creatingPage=!1}}}#P(e){if(!(e.isComposing||e.keyCode===229)){if(e.key===`Escape`){e.preventDefault(),this.#x();return}if(this._pageDialogView===`picker`&&e.target===this.querySelector(`#nav-page-search`)){if(e.key===`ArrowDown`)e.preventDefault(),this._selectedPageIndex=this._pages.length>0?(this._selectedPageIndex+1)%this._pages.length:0,this.#F();else if(e.key===`ArrowUp`)e.preventDefault(),this._selectedPageIndex=this._pages.length>0?(this._selectedPageIndex-1+this._pages.length)%this._pages.length:0,this.#F();else if(e.key===`Enter`&&this._pages.length>0){e.preventDefault();let t=this._pages[this._selectedPageIndex];t&&this.#T(t)}}}}#F(){requestAnimationFrame(()=>{this.querySelector(`.nav-page-result-selected`)?.scrollIntoView({block:`nearest`})})}async#I(){if(this._collectionDialogOpen)return;this.#d(),this._collectionDialogOpen=!0,this._collectionDialogView=`create`,this._creatingCollection=!1,this._createCollectionError=``,this._createdCollection=null,await this.updateComplete;let e=this.querySelector(`#nav-collection-dialog`);e&&!e.open&&e.showModal();let t=this.querySelector(`#nav-collection-dialog [data-collection-title-input]`);t?.focus(),t?.select()}#L(){let e=this.querySelector(`[data-add-collection-trigger]`),t=this.querySelector(`#nav-collection-dialog`);t?.open&&t.close(),this._collectionDialogOpen=!1,this._creatingCollection=!1,this._createCollectionError=``,this.updateComplete.then(()=>e?.focus())}#R(e){e.isComposing||e.keyCode===229||e.key===`Escape`&&(e.preventDefault(),this.#L())}#z(){this.querySelector(`#nav-collection-dialog jant-collection-form form`)?.requestSubmit()}async#B(e){let t=e;if(t.stopPropagation(),!t.detail||this._creatingCollection)return;let n=this.querySelector(`#nav-collection-dialog jant-collection-form`);this._creatingCollection=!0,this._createCollectionError=``,n&&(n.loading=!0);try{let e=await fetch(`/api/collections`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(t.detail.data)}),n=await e.json().catch(()=>null);if(!e.ok||!n?.id||!n.title||!n.slug)throw Error(`Invalid collection response`);let r={id:n.id,title:n.title,slug:n.slug,group:null};this.collections.some(e=>e.id===n.id)||(this.collections=[...this.collections,r]),this._createdCollection=n,this._collectionDialogView=`created`}catch{this._createCollectionError=this.labels.createCollectionFailed}finally{this._creatingCollection=!1,n&&(n.loading=!1)}}#V(){this.#e?.destroy(),this.#e=null,this.#t?.destroy(),this.#t=null}#H(){let e=this.querySelector(`#nav-items-header`),t=this.querySelector(`#nav-items-more`);e&&!this.#e&&(this.#e=O.create(e,this.#U())),t&&!this.#t&&(this.#t=O.create(t,this.#U()))}#U(){return{...de,animation:150,handle:`[data-drag-handle]`,draggable:`[data-nav-id]`,group:`nav-items`,onStart:e=>{this.#r=me(e)},onEnd:e=>{this.#W(e)}}}async#W(e){let t=e.to,n=e.from,r=n!==t,i=t.id===`nav-items-header`?`header`:`more`,a=this.querySelector(`#nav-items-header`),o=this.querySelector(`#nav-items-more`),s=this._items.map(e=>({...e})),c=e.item?.dataset?.navId;if(!c||!a||!o){this.#r=null;return}let u=D(a,`[data-nav-id]`,`navId`),d=D(o,`[data-nav-id]`,`navId`);r?(e.item.parentNode?.removeChild(e.item),this.#r?n.insertBefore(e.item,this.#r):e.oldIndex!=null&&e.oldIndex<n.children.length?n.insertBefore(e.item,n.children[e.oldIndex]??null):n.appendChild(e.item)):w(t,e,this.#r),this.#r=null,this.#V();let f=[...new Set([...u,...d])],p=new Map(this._items.map(e=>[e.id,e.id===c?{...e,placement:i}:{...e}])),m=f.map(e=>p.get(e)).filter(e=>e!==void 0),h=this._items.filter(e=>!f.includes(e.id)).map(e=>e.id===c?{...e,placement:i}:{...e});this._items=[...m,...h];let{movedId:g,afterId:_,beforeId:v}=pe(i===`header`?u:d,e.newIndex);if(g)try{if(r){let e=await fetch(`/api/nav-items/${c}`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({placement:i})});if(!e.ok)throw Error(`HTTP ${e.status}`)}let e=await fetch(`/api/nav-items/${g}/move`,{method:`PUT`,headers:this.#h(),body:JSON.stringify({after:_??null,before:v??null})});if(!e.ok)throw Error(`HTTP ${e.status}`);j((await e.json()).headerHtml),l(r?this.labels.placementSaved:this.labels.orderSaved)}catch{this.#V(),this._items=s,l(this.labels.saveFailed,`error`)}}#G(e){this._editingId===e.id?this._editingId=null:(this._editingId=e.id,this._editLabel=e.label,this._editUrl=e.url)}async#K(e){let t=this._editLabel.trim();if(!t&&e.type===`link`){l(this.labels.labelRequired,`error`);return}try{let n=await fetch(`/api/nav-items/${e.id}`,{method:`PUT`,headers:this.#h(),body:JSON.stringify({label:t,...e.type===`link`&&{url:this._editUrl.trim()}})});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json(),i=this.#v(this.#_(r));this.#V(),this._items=this._items.map(e=>e.id===i.id?i:e),this._editingId=null,j(r.headerHtml)}catch{l(this.labels.saveFailed,`error`)}}async#q(e){let t=e.type===`collection`?this.labels.confirmDeleteCollection:e.type===`page`?this.labels.confirmDeletePage:this.labels.confirmDeleteLink,n=e.type===`collection`||e.type===`page`?this.labels.remove:this.labels.delete;if(await h({message:t,confirmLabel:n,cancelLabel:this.labels.cancel,tone:`danger`}))try{let t=await fetch(`/api/nav-items/${e.id}`,{method:`DELETE`,headers:this.#g()});if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();this.#V(),this._items=this._items.filter(t=>t.id!==e.id),this._editingId=null,j(n.headerHtml)}catch{l(this.labels.deleteFailed,`error`)}}async#J(){let e=this._newLinkLabel.trim(),t=this._newLinkUrl.trim();if(!e||!t){l(this.labels.labelAndUrlRequired,`error`);return}this._addingLink=!0;try{let n=await fetch(`/api/nav-items`,{method:`POST`,headers:this.#h(),body:JSON.stringify({type:`link`,label:e,url:t,placement:`header`})});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json(),i=this.#v(this.#_(r));this.#V(),this._items=[...this._items,i],this._newLinkLabel=``,this._newLinkUrl=``,this._showLinkForm=!1,document.removeEventListener(`click`,this.#u),j(r.headerHtml)}catch{l(this.labels.saveFailed,`error`)}finally{this._addingLink=!1}}async#Y(e,t=!1){if(e&&!this._addingCollectionId){this._addingCollectionId=e;try{let n=await fetch(`/api/nav-items`,{method:`POST`,headers:this.#h(),body:JSON.stringify(t?{type:`smart_collection`,smartCollectionId:e,placement:`header`}:{type:`collection`,collectionId:e,placement:`header`})});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json(),i=this.#v(this.#_(r));this.#V(),this._items=[...this._items,i],this.#d(),j(r.headerHtml),l(this.labels.collectionAdded),this._collectionDialogOpen&&this.#L()}catch{l(this.labels.saveFailed,`error`)}finally{this._addingCollectionId=null}}}#X(n){let r=t(n,{siteOrigins:[window.location.origin],sitePathPrefix:i()});if(r===null)return null;let a=e(r);return a?`/${a}`:`/`}#Z(e){let t=this.#X(e.url);return t!==null&&this._items.some(e=>this.#X(e.url)===t)?!0:!!(e.collectionId&&this._items.some(t=>t.type===`collection`&&t.collectionId===e.collectionId)||e.postId&&this._items.some(t=>t.type===`page`&&t.postId===e.postId))}get#Q(){return(this.suggestedLinks??[]).filter(e=>!this.#Z(e))}async#$(e){if(!this._addingSuggestedKey){this._addingSuggestedKey=e.key;try{let t=e.navItemType===`page`&&e.postId?{type:`page`,postId:e.postId,placement:`header`}:e.navItemType===`collection`&&e.collectionId?{type:`collection`,collectionId:e.collectionId,placement:`header`}:{type:`link`,label:e.label,url:e.url,placement:`header`},n=await fetch(`/api/nav-items`,{method:`POST`,headers:this.#h(),body:JSON.stringify(t)});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json(),i=this.#v(this.#_(r));this.#V(),this._items=[...this._items,i],j(r.headerHtml),l(this.labels.suggestedLinkAdded)}catch{l(this.labels.saveFailed,`error`)}finally{this._addingSuggestedKey=null}}}#ee(e){return this._items.some(t=>t.type===`system`&&t.systemKey===e.key)}async#te(e,t){this._togglingKeys=new Set([...this._togglingKeys,e.key]);try{if(t){let t=await fetch(`/api/nav-items`,{method:`POST`,headers:this.#h(),body:JSON.stringify({type:`system`,systemKey:e.key})});if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json(),r=this.#v(this.#_(n));this.#V(),this._items=[...this._items,r],j(n.headerHtml)}else{let t=this._items.find(t=>t.type===`system`&&t.systemKey===e.key);if(t){let e=await fetch(`/api/nav-items/${t.id}`,{method:`DELETE`,headers:this.#g()});if(!e.ok)throw Error(`HTTP ${e.status}`);let n=await e.json();this.#V(),this._items=this._items.filter(e=>e.id!==t.id),j(n.headerHtml)}}}catch{l(this.labels.saveFailed,`error`),this.requestUpdate()}finally{let t=new Set(this._togglingKeys);t.delete(e.key),this._togglingKeys=t}}get#ne(){return this._items.filter(e=>(e.placement??`header`)===`header`)}get#re(){return this._items.filter(e=>e.placement===`more`)}#ie(e){return this.rssFeedsEnabled||e.type!==`system`||!ne(e.systemKey)}get#ae(){return this.#ne.filter(e=>this.#ie(e))}get#oe(){return this.#re.filter(e=>this.#ie(e))}#se(){this._showPreviewMore=!1,document.removeEventListener(`click`,this.#f),document.removeEventListener(`keydown`,this.#p)}#ce(e){if(e.preventDefault(),e.stopPropagation(),this._showPreviewMore){this.#se();return}this._showPreviewMore=!0,document.addEventListener(`keydown`,this.#p),setTimeout(()=>{document.addEventListener(`click`,this.#f)})}#le(){let e=this.#ae,t=this.#oe;return o`
172
+ `}};customElements.get(`jant-collection-dialog`)||customElements.define(`jant-collection-dialog`,ge);var F=`data-collection-dialog-labels`,I=null,L=null;function _e(){if(I)return I;let e=document.querySelector(`[${F}]`)?.getAttribute(F);if(!e)return null;try{return I=JSON.parse(e),I}catch{return null}}function ve(e){return L?.isConnected?(L.labels=e,L):(L=document.createElement(`jant-collection-dialog`),L.labels=e,document.body.appendChild(L),L)}async function R(e={}){let t=_e();return t?ve(t).open(e):{changed:!1}}var z=`X-Jant-Site-Header`,B=`include`,ye=class extends u{static properties={items:{type:Array},labels:{type:Object},systemNavItems:{type:Array,attribute:`system-nav-items`},collections:{type:Array},suggestedLinks:{type:Array,attribute:`suggested-links`},siteName:{type:String,attribute:`site-name`},rssFeedsEnabled:{type:Boolean,attribute:`rss-feeds-enabled`},_items:{state:!0},_editingId:{state:!0},_editLabel:{state:!0},_editUrl:{state:!0},_togglingKeys:{state:!0},_showLinkForm:{state:!0},_newLinkLabel:{state:!0},_newLinkUrl:{state:!0},_addingLink:{state:!0},_showPreviewMore:{state:!0},_addingCollectionId:{state:!0},_showCollectionPicker:{state:!0},_collectionDialogOpen:{state:!0},_collectionDialogView:{state:!0},_creatingCollection:{state:!0},_createCollectionError:{state:!0},_createdCollection:{state:!0},_addingSuggestedKey:{state:!0},_pageDialogOpen:{state:!0},_pageDialogView:{state:!0},_pageQuery:{state:!0},_pages:{state:!0},_pageAddress:{state:!0},_pageSearchLoading:{state:!0},_pageSearchError:{state:!0},_selectedPageIndex:{state:!0},_addingPageId:{state:!0},_newPageTitle:{state:!0},_newPageSlug:{state:!0},_slugEdited:{state:!0},_slugCheckLoading:{state:!0},_slugTaken:{state:!0},_creatingPage:{state:!0},_createPageError:{state:!0},_createdPage:{state:!0}};#e=null;#t=null;#n=!1;#r=null;#i=null;#a=0;#o=null;#s=0;#c=null;#l=0;#u=()=>{this._showLinkForm=!1,document.removeEventListener(`click`,this.#u)};#d=()=>{this._showCollectionPicker=!1,document.removeEventListener(`click`,this.#d)};#f=e=>{e.target instanceof Node&&(this.querySelector(`[data-preview-more]`)?.contains(e.target)||this.#se())};#p=e=>{if(!(`key`in e)||e.key!==`Escape`||!this._showPreviewMore)return;let t=e;t.isComposing||t.keyCode===229||(e.preventDefault(),this.#se(),this.querySelector(`[data-preview-more-trigger]`)?.focus())};#m=e=>{e.key===`Escape`&&!e.isComposing&&e.keyCode!==229&&this._showCollectionPicker&&(e.preventDefault(),e.stopPropagation(),this.#d(),this.querySelector(`[data-add-collection-trigger]`)?.focus())};createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this.items=[],this.labels={},this.systemNavItems=[],this.collections=[],this.suggestedLinks=[],this.siteName=``,this.rssFeedsEnabled=!1,this._items=[],this._editingId=null,this._editLabel=``,this._editUrl=``,this._togglingKeys=new Set,this._showLinkForm=!1,this._newLinkLabel=``,this._newLinkUrl=``,this._addingLink=!1,this._showPreviewMore=!1,this._addingCollectionId=null,this._showCollectionPicker=!1,this._collectionDialogOpen=!1,this._collectionDialogView=`create`,this._creatingCollection=!1,this._createCollectionError=``,this._createdCollection=null,this._addingSuggestedKey=null,this._pageDialogOpen=!1,this._pageDialogView=`picker`,this._pageQuery=``,this._pages=[],this._pageAddress=null,this._pageSearchLoading=!1,this._pageSearchError=!1,this._selectedPageIndex=0,this._addingPageId=null,this._newPageTitle=``,this._newPageSlug=``,this._slugEdited=!1,this._slugCheckLoading=!1,this._slugTaken=!1,this._creatingPage=!1,this._createPageError=``,this._createdPage=null}update(e){(!this.#n||e.has(`items`))&&(this._items=[...this.items??[]],this.#n=!0),super.update(e)}updated(){this._showPreviewMore&&this.#oe.length===0&&this.#se(),this.#H()}disconnectedCallback(){super.disconnectedCallback(),this.#e?.destroy(),this.#e=null,this.#t?.destroy(),this.#t=null,document.removeEventListener(`click`,this.#u),document.removeEventListener(`click`,this.#d),this.#se(),this.#y()}#h(){return{"Content-Type":`application/json`,Accept:`application/json`,[z]:B}}#g(){return{Accept:`application/json`,[z]:B}}#_(e){let t={...e};return delete t.headerHtml,t}#v(e){let t=e.type===`system`?this.systemNavItems.find(t=>t.key===e.systemKey)?.label:void 0,n=e.label.trim()||t||e.displayLabel||e.targetTitle?.trim()||e.label;return{...e,displayLabel:n}}#y(){this.#i!==null&&(clearTimeout(this.#i),this.#i=null),this.#o!==null&&(clearTimeout(this.#o),this.#o=null),this.#c!==null&&(clearTimeout(this.#c),this.#c=null),this.#a+=1,this.#s+=1,this.#l+=1}async#b(){if(this._pageDialogOpen)return;this.#y(),this._pageDialogOpen=!0,this._pageDialogView=`picker`,this._pageQuery=``,this._pages=[],this._pageAddress=null,this._pageSearchError=!1,this._selectedPageIndex=0,this._addingPageId=null,this._newPageTitle=``,this._newPageSlug=``,this._slugEdited=!1,this._slugCheckLoading=!1,this._slugTaken=!1,this._creatingPage=!1,this._createPageError=``,this._createdPage=null,await this.updateComplete;let e=this.querySelector(`#nav-page-dialog`);e&&!e.open&&e.showModal(),this.querySelector(`#nav-page-search`)?.focus(),this.#C()}#x(){let e=this.querySelector(`[data-add-page-trigger]`),t=this.querySelector(`#nav-page-dialog`);t?.open&&t.close(),this.#y(),this._pageDialogOpen=!1,this.updateComplete.then(()=>e?.focus())}async#S(e){let t=++this.#a,n=new URLSearchParams({url:e});this._pageSearchLoading=!0,this._pageSearchError=!1;try{let e=await fetch(`/api/nav-items/resolve?${n.toString()}`,{headers:{Accept:`application/json`}});if(!e.ok)throw Error(`HTTP ${e.status}`);let r=await e.json();if(t!==this.#a)return;this._pages=[],this._pageAddress=r.resolution??null,this._selectedPageIndex=0}catch{t===this.#a&&(this._pages=[],this._pageAddress=null,this._pageSearchError=!0)}finally{t===this.#a&&(this._pageSearchLoading=!1)}}async#C(){let e=++this.#a,t=new URLSearchParams({limit:`20`}),n=this._pageQuery.trim();n&&t.set(`q`,n),this._pageSearchLoading=!0,this._pageSearchError=!1,this._pageAddress=null;try{let n=await fetch(`/api/nav-items/pages?${t.toString()}`,{headers:{Accept:`application/json`}});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json();if(e!==this.#a)return;let i=new Set(this._items.flatMap(e=>e.type===`page`&&e.postId?[e.postId]:[]));this._pages=(r.pages??[]).filter(e=>!i.has(e.id)),this._selectedPageIndex=0}catch{e===this.#a&&(this._pages=[],this._pageSearchError=!0)}finally{e===this.#a&&(this._pageSearchLoading=!1)}}#w(){this.#i!==null&&clearTimeout(this.#i),this.#i=setTimeout(()=>{this.#i=null;let e=this._pageQuery.trim();n(e)?this.#S(e):this.#C()},200)}async#T(e){if(!this._addingPageId){this._addingPageId=e.id;try{let t=await fetch(`/api/nav-items`,{method:`POST`,headers:this.#h(),body:JSON.stringify({type:`page`,postId:e.id,placement:`header`})});if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json(),r=this.#v(this.#_(n));this.#V(),this._items=[...this._items,r],this._pages=this._pages.filter(t=>t.id!==e.id),N(n.headerHtml),d(this.labels.pageAdded),this.#x()}catch{d(this.labels.saveFailed,`error`)}finally{this._addingPageId=null}}}#E(){this.#a+=1,this._pageDialogView=`create`,this._newPageTitle=``,this._newPageSlug=``,this._slugEdited=!1,this._slugCheckLoading=!1,this._slugTaken=!1,this._createPageError=``,this.updateComplete.then(()=>{this.querySelector(`#nav-new-page-title`)?.focus()})}#D(){this.#s+=1,this.#l+=1,this._pageDialogView=`picker`,this._createPageError=``,this.updateComplete.then(()=>{this.querySelector(`#nav-page-search`)?.focus()})}#O(){if(this._slugEdited)return;this.#o!==null&&clearTimeout(this.#o);let e=this._newPageTitle.trim();if(!e){this._newPageSlug=``;return}this.#o=setTimeout(()=>{this.#o=null,this.#k(e)},250)}async#k(e){let t=++this.#s,n=new URLSearchParams({mode:`suggest`,title:e});try{let e=await fetch(`/api/posts/slug?${n.toString()}`,{headers:{Accept:`application/json`}});if(!e.ok)return;let r=await e.json();if(t!==this.#s||this._slugEdited||this._pageDialogView!==`create`)return;this._newPageSlug=r.slug?.trim()??``,this._slugTaken=!1}catch{}}#A(){this.#c!==null&&clearTimeout(this.#c),this._slugTaken=!1;let e=this._newPageSlug.trim();if(!e||S(e,{maxLength:200})){this._slugCheckLoading=!1;return}this._slugCheckLoading=!0,this.#c=setTimeout(()=>{this.#c=null,this.#j(e)},250)}async#j(e){let t=++this.#l,n=new URLSearchParams({mode:`check`,slug:e});try{let r=await fetch(`/api/posts/slug?${n.toString()}`,{headers:{Accept:`application/json`}});if(!r.ok)return;let i=await r.json();if(t!==this.#l||this._newPageSlug.trim()!==e)return;this._slugTaken=i.available===!1}catch{}finally{t===this.#l&&(this._slugCheckLoading=!1)}}#M(){let e=S(this._newPageSlug,{maxLength:200});return e===`invalid`?this.labels.slugInvalid:e===`reserved`?this.labels.slugReserved:e===`too_long`?this.labels.slugTooLong:this._slugTaken?this.labels.slugUnavailable:``}async#N(){let e=this._newPageTitle.trim(),t=this._newPageSlug.trim();if(!e){this._createPageError=this.labels.titleRequired;return}let n=this.#M();if(n){this._createPageError=n;return}if(!this._slugCheckLoading){this._creatingPage=!0,this._createPageError=``;try{let n=await fetch(`/api/posts`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({format:`note`,title:e,...t&&{slug:t},status:`published`,visibility:`latest_hidden`})});if(!n.ok){if(n.status===409){this._slugTaken=!0,this._createPageError=this.labels.slugUnavailable;return}throw Error(`HTTP ${n.status}`)}let r=await n.json();this._createdPage={id:r.id,title:r.title||e,slug:r.slug},this._pageDialogView=`created`}catch{this._createPageError=this.labels.createPageFailed}finally{this._creatingPage=!1}}}#P(e){if(!(e.isComposing||e.keyCode===229)){if(e.key===`Escape`){e.preventDefault(),this.#x();return}if(this._pageDialogView===`picker`&&e.target===this.querySelector(`#nav-page-search`)){if(e.key===`ArrowDown`)e.preventDefault(),this._selectedPageIndex=this._pages.length>0?(this._selectedPageIndex+1)%this._pages.length:0,this.#F();else if(e.key===`ArrowUp`)e.preventDefault(),this._selectedPageIndex=this._pages.length>0?(this._selectedPageIndex-1+this._pages.length)%this._pages.length:0,this.#F();else if(e.key===`Enter`&&this._pages.length>0){e.preventDefault();let t=this._pages[this._selectedPageIndex];t&&this.#T(t)}}}}#F(){requestAnimationFrame(()=>{this.querySelector(`.nav-page-result-selected`)?.scrollIntoView({block:`nearest`})})}async#I(){if(this._collectionDialogOpen)return;this.#d(),this._collectionDialogOpen=!0,this._collectionDialogView=`create`,this._creatingCollection=!1,this._createCollectionError=``,this._createdCollection=null,await this.updateComplete;let e=this.querySelector(`#nav-collection-dialog`);e&&!e.open&&e.showModal();let t=this.querySelector(`#nav-collection-dialog [data-collection-title-input]`);t?.focus(),t?.select()}#L(){let e=this.querySelector(`[data-add-collection-trigger]`),t=this.querySelector(`#nav-collection-dialog`);t?.open&&t.close(),this._collectionDialogOpen=!1,this._creatingCollection=!1,this._createCollectionError=``,this.updateComplete.then(()=>e?.focus())}#R(e){e.isComposing||e.keyCode===229||e.key===`Escape`&&(e.preventDefault(),this.#L())}#z(){this.querySelector(`#nav-collection-dialog jant-collection-form form`)?.requestSubmit()}async#B(e){let t=e;if(t.stopPropagation(),!t.detail||this._creatingCollection)return;let n=this.querySelector(`#nav-collection-dialog jant-collection-form`);this._creatingCollection=!0,this._createCollectionError=``,n&&(n.loading=!0);try{let e=await fetch(`/api/collections`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(t.detail.data)}),n=await e.json().catch(()=>null);if(!e.ok||!n?.id||!n.title||!n.slug)throw Error(`Invalid collection response`);let r={id:n.id,title:n.title,slug:n.slug,group:null};this.collections.some(e=>e.id===n.id)||(this.collections=[...this.collections,r]),this._createdCollection=n,this._collectionDialogView=`created`}catch{this._createCollectionError=this.labels.createCollectionFailed}finally{this._creatingCollection=!1,n&&(n.loading=!1)}}#V(){this.#e?.destroy(),this.#e=null,this.#t?.destroy(),this.#t=null}#H(){let e=this.querySelector(`#nav-items-header`),t=this.querySelector(`#nav-items-more`);e&&!this.#e&&(this.#e=A.create(e,this.#U())),t&&!this.#t&&(this.#t=A.create(t,this.#U()))}#U(){return{...le,animation:150,handle:`[data-drag-handle]`,draggable:`[data-nav-id]`,group:`nav-items`,onStart:e=>{this.#r=fe(e)},onEnd:e=>{this.#W(e)}}}async#W(e){let t=e.to,n=e.from,r=n!==t,i=t.id===`nav-items-header`?`header`:`more`,a=this.querySelector(`#nav-items-header`),o=this.querySelector(`#nav-items-more`),s=this._items.map(e=>({...e})),c=e.item?.dataset?.navId;if(!c||!a||!o){this.#r=null;return}let l=k(a,`[data-nav-id]`,`navId`),u=k(o,`[data-nav-id]`,`navId`);r?(e.item.parentNode?.removeChild(e.item),this.#r?n.insertBefore(e.item,this.#r):e.oldIndex!=null&&e.oldIndex<n.children.length?n.insertBefore(e.item,n.children[e.oldIndex]??null):n.appendChild(e.item)):E(t,e,this.#r),this.#r=null,this.#V();let f=[...new Set([...l,...u])],p=new Map(this._items.map(e=>[e.id,e.id===c?{...e,placement:i}:{...e}])),m=f.map(e=>p.get(e)).filter(e=>e!==void 0),h=this._items.filter(e=>!f.includes(e.id)).map(e=>e.id===c?{...e,placement:i}:{...e});this._items=[...m,...h];let{movedId:g,afterId:_,beforeId:ee}=de(i===`header`?l:u,e.newIndex);if(g)try{if(r){let e=await fetch(`/api/nav-items/${c}`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({placement:i})});if(!e.ok)throw Error(`HTTP ${e.status}`)}let e=await fetch(`/api/nav-items/${g}/move`,{method:`PUT`,headers:this.#h(),body:JSON.stringify({after:_??null,before:ee??null})});if(!e.ok)throw Error(`HTTP ${e.status}`);N((await e.json()).headerHtml),d(r?this.labels.placementSaved:this.labels.orderSaved)}catch{this.#V(),this._items=s,d(this.labels.saveFailed,`error`)}}#G(e){this._editingId===e.id?this._editingId=null:(this._editingId=e.id,this._editLabel=e.label,this._editUrl=e.url)}async#K(e){let t=this._editLabel.trim();if(!t&&e.type===`link`){d(this.labels.labelRequired,`error`);return}try{let n=await fetch(`/api/nav-items/${e.id}`,{method:`PUT`,headers:this.#h(),body:JSON.stringify({label:t,...e.type===`link`&&{url:this._editUrl.trim()}})});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json(),i=this.#v(this.#_(r));this.#V(),this._items=this._items.map(e=>e.id===i.id?i:e),this._editingId=null,N(r.headerHtml)}catch{d(this.labels.saveFailed,`error`)}}async#q(e){let t=e.type===`collection`?this.labels.confirmDeleteCollection:e.type===`page`?this.labels.confirmDeletePage:this.labels.confirmDeleteLink,n=e.type===`collection`||e.type===`page`?this.labels.remove:this.labels.delete;if(await h({message:t,confirmLabel:n,cancelLabel:this.labels.cancel,tone:`danger`}))try{let t=await fetch(`/api/nav-items/${e.id}`,{method:`DELETE`,headers:this.#g()});if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();this.#V(),this._items=this._items.filter(t=>t.id!==e.id),this._editingId=null,N(n.headerHtml)}catch{d(this.labels.deleteFailed,`error`)}}async#J(){let e=this._newLinkLabel.trim(),t=this._newLinkUrl.trim();if(!e||!t){d(this.labels.labelAndUrlRequired,`error`);return}this._addingLink=!0;try{let n=await fetch(`/api/nav-items`,{method:`POST`,headers:this.#h(),body:JSON.stringify({type:`link`,label:e,url:t,placement:`header`})});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json(),i=this.#v(this.#_(r));this.#V(),this._items=[...this._items,i],this._newLinkLabel=``,this._newLinkUrl=``,this._showLinkForm=!1,document.removeEventListener(`click`,this.#u),N(r.headerHtml)}catch{d(this.labels.saveFailed,`error`)}finally{this._addingLink=!1}}async#Y(e,t=!1){if(e&&!this._addingCollectionId){this._addingCollectionId=e;try{let n=await fetch(`/api/nav-items`,{method:`POST`,headers:this.#h(),body:JSON.stringify(t?{type:`smart_collection`,smartCollectionId:e,placement:`header`}:{type:`collection`,collectionId:e,placement:`header`})});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json(),i=this.#v(this.#_(r));this.#V(),this._items=[...this._items,i],this.#d(),N(r.headerHtml),d(this.labels.collectionAdded),this._collectionDialogOpen&&this.#L()}catch{d(this.labels.saveFailed,`error`)}finally{this._addingCollectionId=null}}}#X(e){let n=i(e,{siteOrigins:[window.location.origin],sitePathPrefix:t()});if(n===null)return null;let r=o(n);return r?`/${r}`:`/`}#Z(e){let t=this.#X(e.url);return t!==null&&this._items.some(e=>this.#X(e.url)===t)?!0:!!(e.collectionId&&this._items.some(t=>t.type===`collection`&&t.collectionId===e.collectionId)||e.postId&&this._items.some(t=>t.type===`page`&&t.postId===e.postId))}get#Q(){return(this.suggestedLinks??[]).filter(e=>!this.#Z(e))}async#$(e){if(!this._addingSuggestedKey){this._addingSuggestedKey=e.key;try{let t=e.navItemType===`page`&&e.postId?{type:`page`,postId:e.postId,placement:`header`}:e.navItemType===`collection`&&e.collectionId?{type:`collection`,collectionId:e.collectionId,placement:`header`}:{type:`link`,label:e.label,url:e.url,placement:`header`},n=await fetch(`/api/nav-items`,{method:`POST`,headers:this.#h(),body:JSON.stringify(t)});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json(),i=this.#v(this.#_(r));this.#V(),this._items=[...this._items,i],N(r.headerHtml),d(this.labels.suggestedLinkAdded)}catch{d(this.labels.saveFailed,`error`)}finally{this._addingSuggestedKey=null}}}#ee(e){return this._items.some(t=>t.type===`system`&&t.systemKey===e.key)}async#te(e,t){this._togglingKeys=new Set([...this._togglingKeys,e.key]);try{if(t){let t=await fetch(`/api/nav-items`,{method:`POST`,headers:this.#h(),body:JSON.stringify({type:`system`,systemKey:e.key})});if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json(),r=this.#v(this.#_(n));this.#V(),this._items=[...this._items,r],N(n.headerHtml)}else{let t=this._items.find(t=>t.type===`system`&&t.systemKey===e.key);if(t){let e=await fetch(`/api/nav-items/${t.id}`,{method:`DELETE`,headers:this.#g()});if(!e.ok)throw Error(`HTTP ${e.status}`);let n=await e.json();this.#V(),this._items=this._items.filter(e=>e.id!==t.id),N(n.headerHtml)}}}catch{d(this.labels.saveFailed,`error`),this.requestUpdate()}finally{let t=new Set(this._togglingKeys);t.delete(e.key),this._togglingKeys=t}}get#ne(){return this._items.filter(e=>(e.placement??`header`)===`header`)}get#re(){return this._items.filter(e=>e.placement===`more`)}#ie(e){return this.rssFeedsEnabled||e.type!==`system`||!ee(e.systemKey)}get#ae(){return this.#ne.filter(e=>this.#ie(e))}get#oe(){return this.#re.filter(e=>this.#ie(e))}#se(){this._showPreviewMore=!1,document.removeEventListener(`click`,this.#f),document.removeEventListener(`keydown`,this.#p)}#ce(e){if(e.preventDefault(),e.stopPropagation(),this._showPreviewMore){this.#se();return}this._showPreviewMore=!0,document.addEventListener(`keydown`,this.#p),setTimeout(()=>{document.addEventListener(`click`,this.#f)})}#le(){let e=this.#ae,t=this.#oe;return c`
173
173
  <div class="nav-preview">
174
174
  <div class="nav-preview-chrome">
175
175
  <div class="nav-preview-dots">
@@ -181,12 +181,12 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
181
181
  <div class="site-header-top">
182
182
  <a href=${a(`/`)} class="site-logo">${this.siteName}</a>
183
183
  <nav class="site-header-nav">
184
- ${T(e,e=>e.id,(e,t)=>o`<a
184
+ ${D(e,e=>e.id,(e,t)=>c`<a
185
185
  class=${t===0?`site-header-link site-header-link-active`:`site-header-link`}
186
186
  >
187
187
  ${e.displayLabel??e.label}
188
188
  </a>`)}
189
- ${t.length>0?o`
189
+ ${t.length>0?c`
190
190
  <div class="site-header-more" data-preview-more>
191
191
  <button
192
192
  type="button"
@@ -217,19 +217,19 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
217
217
  aria-hidden=${this._showPreviewMore?`false`:`true`}
218
218
  @click=${e=>e.stopPropagation()}
219
219
  >
220
- ${T(t,e=>e.id,e=>o`
220
+ ${D(t,e=>e.id,e=>c`
221
221
  <span class="site-header-more-link">
222
222
  ${e.displayLabel??e.label}
223
223
  </span>
224
224
  `)}
225
225
  </div>
226
226
  </div>
227
- `:s}
227
+ `:l}
228
228
  </nav>
229
229
  </div>
230
230
  </div>
231
231
  </div>
232
- `}#ue(e){let t=e===`system`?this.labels.system:e===`collection`?this.labels.collection:e===`page`?this.labels.page:this.labels.link;return o`<span class="badge-secondary">${t}</span>`}#de(e){if(this._editingId!==e.id)return s;if(e.type===`system`)return o`
232
+ `}#ue(e){let t=e===`system`?this.labels.system:e===`collection`?this.labels.collection:e===`page`?this.labels.page:this.labels.link;return c`<span class="badge-secondary">${t}</span>`}#de(e){if(this._editingId!==e.id)return l;if(e.type===`system`)return c`
233
233
  <div class="nav-item-edit">
234
234
  <div class="field">
235
235
  <label class="label">${this.labels.label}</label>
@@ -258,7 +258,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
258
258
  </button>
259
259
  </div>
260
260
  </div>
261
- `;if(e.type===`collection`)return o`
261
+ `;if(e.type===`collection`)return c`
262
262
  <div class="nav-item-edit">
263
263
  <div class="field">
264
264
  <label class="label">${this.labels.label}</label>
@@ -288,7 +288,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
288
288
  </button>
289
289
  </div>
290
290
  </div>
291
- `;if(e.type===`page`){let t=`${a(e.url)}?edit=1`;return o`
291
+ `;if(e.type===`page`){let t=`${a(e.url)}?edit=1`;return c`
292
292
  <div class="nav-item-edit">
293
293
  <div class="field">
294
294
  <label class="label">${this.labels.label}</label>
@@ -329,7 +329,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
329
329
  </div>
330
330
  </div>
331
331
  </div>
332
- `}return e.type===`link`?o`
332
+ `}return e.type===`link`?c`
333
333
  <div class="nav-item-edit">
334
334
  <div class="field">
335
335
  <label class="label">${this.labels.label}</label>
@@ -368,7 +368,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
368
368
  </button>
369
369
  </div>
370
370
  </div>
371
- `:s}#fe(e){let t=this._editingId===e.id;return o`
371
+ `:l}#fe(e){let t=this._editingId===e.id;return c`
372
372
  <div
373
373
  data-nav-id=${e.id}
374
374
  class="nav-item${t?` nav-item-editing`:``}"
@@ -430,7 +430,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
430
430
  </div>
431
431
  ${this.#de(e)}
432
432
  </div>
433
- `}#pe(){let e=this.#Q;return e.length===0?s:o`
433
+ `}#pe(){let e=this.#Q;return e.length===0?l:c`
434
434
  <section class="mt-8">
435
435
  <h2 class="text-lg font-semibold mb-1">
436
436
  ${this.labels.suggestedLinks}
@@ -439,7 +439,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
439
439
  ${this.labels.suggestedLinksDescription}
440
440
  </p>
441
441
  <div class="nav-suggestions-list">
442
- ${e.map(e=>{let t=this._addingSuggestedKey===e.key;return o`
442
+ ${e.map(e=>{let t=this._addingSuggestedKey===e.key;return c`
443
443
  <div class="nav-suggestion-item">
444
444
  <div class="nav-suggestion-info">
445
445
  <span class="nav-suggestion-title">${e.label}</span>
@@ -459,7 +459,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
459
459
  `})}
460
460
  </div>
461
461
  </section>
462
- `}#me(){return o`
462
+ `}#me(){return c`
463
463
  <section class="mt-8">
464
464
  <h2 class="text-lg font-semibold mb-1">
465
465
  ${this.labels.addPageToNavigation}
@@ -476,9 +476,9 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
476
476
  ${this.labels.addPage}
477
477
  </button>
478
478
  </section>
479
- `}#he(e){return e.kind===`page`?this._items.some(t=>t.postId===e.page.id):e.kind===`collection`?this._items.some(t=>t.collectionId===e.collection.id):e.kind===`smart_collection`&&this._items.some(t=>t.smartCollectionId===e.smartCollection.id)}#ge(e){if(this.#he(e))return this.labels.addressAlreadyAdded;switch(e.kind){case`not_found`:return this.labels.addressNotFound.replace(`{address}`,e.address);case`unpublished`:return this.labels.addressUnpublished;case`private`:return this.labels.addressPrivate;case`untitled`:return this.labels.addressUntitled;case`external`:return this.labels.addressExternal;case`link_only`:return this.labels.addressLinkOnly;default:return``}}#_e(e){this._newLinkUrl=e,this.#x(),this._showLinkForm=!0,setTimeout(()=>{document.addEventListener(`click`,this.#u)}),this.updateComplete.then(()=>{this.querySelector(`#nav-link-label`)?.focus()})}#ve(e){let t=this.#he(e);if(e.kind===`page`&&!t){let t=e.page;return this.#ye(t.title,a(`/${t.slug}`),this._addingPageId===t.id,()=>void this.#T(t))}if(e.kind===`collection`&&!t){let t=e.collection;return this.#ye(t.title,a(S(t.slug)),this._addingCollectionId===t.id,()=>{this.#Y(t.id).then(()=>{this.#x()})})}if(e.kind===`smart_collection`&&!t){let t=e.smartCollection;return this.#ye(t.title,a(S(t.slug)),this._addingCollectionId===t.id,()=>{this.#Y(t.id,!0).then(()=>{this.#x()})})}let n=this.#ge(e),r=e.kind===`external`||e.kind===`link_only`;return o`
479
+ `}#he(e){return e.kind===`page`?this._items.some(t=>t.postId===e.page.id):e.kind===`collection`?this._items.some(t=>t.collectionId===e.collection.id):e.kind===`smart_collection`&&this._items.some(t=>t.smartCollectionId===e.smartCollection.id)}#ge(e){if(this.#he(e))return this.labels.addressAlreadyAdded;switch(e.kind){case`not_found`:return this.labels.addressNotFound.replace(`{address}`,e.address);case`unpublished`:return this.labels.addressUnpublished;case`private`:return this.labels.addressPrivate;case`untitled`:return this.labels.addressUntitled;case`external`:return this.labels.addressExternal;case`link_only`:return this.labels.addressLinkOnly;default:return``}}#_e(e){this._newLinkUrl=e,this.#x(),this._showLinkForm=!0,setTimeout(()=>{document.addEventListener(`click`,this.#u)}),this.updateComplete.then(()=>{this.querySelector(`#nav-link-label`)?.focus()})}#ve(e){let t=this.#he(e);if(e.kind===`page`&&!t){let t=e.page;return this.#ye(t.title,a(`/${t.slug}`),this._addingPageId===t.id,()=>void this.#T(t))}if(e.kind===`collection`&&!t){let t=e.collection;return this.#ye(t.title,a(w(t.slug)),this._addingCollectionId===t.id,()=>{this.#Y(t.id).then(()=>{this.#x()})})}if(e.kind===`smart_collection`&&!t){let t=e.smartCollection;return this.#ye(t.title,a(w(t.slug)),this._addingCollectionId===t.id,()=>{this.#Y(t.id,!0).then(()=>{this.#x()})})}let n=this.#ge(e),r=e.kind===`external`||e.kind===`link_only`;return c`
480
480
  <p class="nav-page-status" role="status">${n}</p>
481
- ${r?o`
481
+ ${r?c`
482
482
  <button
483
483
  type="button"
484
484
  class="btn-outline nav-page-address-link"
@@ -486,8 +486,8 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
486
486
  >
487
487
  ${this.labels.addressAddAsLink}
488
488
  </button>
489
- `:s}
490
- `}#ye(e,t,n,r){return o`
489
+ `:l}
490
+ `}#ye(e,t,n,r){return c`
491
491
  <p class="nav-page-results-label">${this.labels.addressMatch}</p>
492
492
  <div class="nav-page-results" role="listbox">
493
493
  <button
@@ -502,7 +502,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
502
502
  <span class="nav-page-result-title">${e}</span>
503
503
  <span class="nav-page-result-path">${t}</span>
504
504
  </span>
505
- ${n?o`<span class="nav-page-spinner" aria-hidden="true"></span>`:o`
505
+ ${n?c`<span class="nav-page-spinner" aria-hidden="true"></span>`:c`
506
506
  <svg
507
507
  xmlns="http://www.w3.org/2000/svg"
508
508
  width="16"
@@ -521,7 +521,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
521
521
  `}
522
522
  </button>
523
523
  </div>
524
- `}#be(){let e=this._pageSearchLoading?this.labels.searchingPages:this._pageSearchError?this.labels.pageSearchFailed:this._pages.length===0?this._pageQuery.trim()?this.labels.noMatchingPages:this.labels.noPages:``;return o`
524
+ `}#be(){let e=this._pageSearchLoading?this.labels.searchingPages:this._pageSearchError?this.labels.pageSearchFailed:this._pages.length===0?this._pageQuery.trim()?this.labels.noMatchingPages:this.labels.noPages:``;return c`
525
525
  <header>
526
526
  <h2 id="nav-page-dialog-title">${this.labels.addPage}</h2>
527
527
  <p>${this.labels.addPageDescription}</p>
@@ -558,7 +558,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
558
558
  />
559
559
  </div>
560
560
 
561
- ${this._pageSearchLoading||this._pageSearchError?o`<p class="nav-page-status" role="status">${e}</p>`:this._pageAddress?this.#ve(this._pageAddress):this._pages.length>0?o`
561
+ ${this._pageSearchLoading||this._pageSearchError?c`<p class="nav-page-status" role="status">${e}</p>`:this._pageAddress?this.#ve(this._pageAddress):this._pages.length>0?c`
562
562
  <p class="nav-page-results-label">
563
563
  ${this._pageQuery.trim()?this.labels.searchPages:this.labels.recentPages}
564
564
  </p>
@@ -567,7 +567,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
567
567
  class="nav-page-results"
568
568
  role="listbox"
569
569
  >
570
- ${this._pages.map((e,t)=>{let n=t===this._selectedPageIndex,r=this._addingPageId===e.id;return o`
570
+ ${this._pages.map((e,t)=>{let n=t===this._selectedPageIndex,r=this._addingPageId===e.id;return c`
571
571
  <button
572
572
  id=${`nav-page-result-${t}`}
573
573
  type="button"
@@ -586,10 +586,10 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
586
586
  >${a(`/${e.slug}`)}</span
587
587
  >
588
588
  </span>
589
- ${r?o`<span
589
+ ${r?c`<span
590
590
  class="nav-page-spinner"
591
591
  aria-hidden="true"
592
- ></span>`:o`
592
+ ></span>`:c`
593
593
  <svg
594
594
  xmlns="http://www.w3.org/2000/svg"
595
595
  width="16"
@@ -609,7 +609,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
609
609
  </button>
610
610
  `})}
611
611
  </div>
612
- `:o`<p class="nav-page-status" role="status">${e}</p>`}
612
+ `:c`<p class="nav-page-status" role="status">${e}</p>`}
613
613
  </section>
614
614
  <footer class="nav-page-dialog-footer">
615
615
  <button
@@ -638,7 +638,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
638
638
  ${this.labels.cancel}
639
639
  </button>
640
640
  </footer>
641
- `}#xe(){let e=this.#M(),t=this._newPageSlug.trim()?a(`/${this._newPageSlug.trim()}`):a(`/`);return o`
641
+ `}#xe(){let e=this.#M(),t=this._newPageSlug.trim()?a(`/${this._newPageSlug.trim()}`):a(`/`);return c`
642
642
  <header>
643
643
  <h2 id="nav-page-dialog-title">${this.labels.createPage}</h2>
644
644
  <p>${this.labels.createPageDescription}</p>
@@ -711,9 +711,9 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
711
711
  </svg>
712
712
  ${this.labels.pageVisibilityHint}
713
713
  </p>
714
- ${this._createPageError?o`<p class="text-sm text-destructive" role="alert">
714
+ ${this._createPageError?c`<p class="text-sm text-destructive" role="alert">
715
715
  ${this._createPageError}
716
- </p>`:s}
716
+ </p>`:l}
717
717
  </form>
718
718
  </section>
719
719
  <footer>
@@ -734,7 +734,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
734
734
  ${this._creatingPage?this.labels.creatingPage:this.labels.createPage}
735
735
  </button>
736
736
  </footer>
737
- `}#Se(){let e=this._createdPage;if(!e)return s;let t=`${a(`/${e.slug}`)}?edit=1`;return o`
737
+ `}#Se(){let e=this._createdPage;if(!e)return l;let t=`${a(`/${e.slug}`)}?edit=1`;return c`
738
738
  <header class="nav-create-success-header">
739
739
  <span class="nav-create-success-icon" aria-hidden="true">
740
740
  <svg
@@ -781,7 +781,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
781
781
  ${this.labels.addToNavigation}
782
782
  </button>
783
783
  </footer>
784
- `}#Ce(){return this._pageDialogOpen?o`
784
+ `}#Ce(){return this._pageDialogOpen?c`
785
785
  <dialog
786
786
  id="nav-page-dialog"
787
787
  class="dialog nav-page-dialog"
@@ -818,7 +818,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
818
818
  ${this._pageDialogView===`picker`?this.#be():this._pageDialogView===`create`?this.#xe():this.#Se()}
819
819
  </div>
820
820
  </dialog>
821
- `:s}#we(){return o`
821
+ `:l}#we(){return c`
822
822
  <section class="mt-8">
823
823
  <h2 class="text-lg font-semibold mb-3">
824
824
  ${this.labels.addCustomLinkToNavigation}
@@ -834,7 +834,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
834
834
  >
835
835
  ${this.labels.addLink}
836
836
  </button>
837
- ${this._showLinkForm?o`
837
+ ${this._showLinkForm?c`
838
838
  <div
839
839
  id="nav-link-popover-content"
840
840
  data-popover
@@ -894,10 +894,10 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
894
894
  </form>
895
895
  </div>
896
896
  </div>
897
- `:s}
897
+ `:l}
898
898
  </div>
899
899
  </section>
900
- `}#Te(){if(!this.collections?.length)return o`
900
+ `}#Te(){if(!this.collections?.length)return c`
901
901
  <section class="mt-8">
902
902
  <h2 class="text-lg font-semibold mb-1">
903
903
  ${this.labels.addCollectionToNavigation}
@@ -914,7 +914,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
914
914
  ${this.labels.createCollection}
915
915
  </button>
916
916
  </section>
917
- `;let e=new Set(this._items.flatMap(e=>e.type===`collection`&&e.collectionId?[e.collectionId]:e.type===`smart_collection`&&e.smartCollectionId?[e.smartCollectionId]:[])),t=this.collections.filter(t=>!e.has(t.id));if(t.length===0)return o`
917
+ `;let e=new Set(this._items.flatMap(e=>e.type===`collection`&&e.collectionId?[e.collectionId]:e.type===`smart_collection`&&e.smartCollectionId?[e.smartCollectionId]:[])),t=this.collections.filter(t=>!e.has(t.id));if(t.length===0)return c`
918
918
  <section class="mt-8">
919
919
  <h2 class="text-lg font-semibold mb-1">
920
920
  ${this.labels.addCollectionToNavigation}
@@ -931,7 +931,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
931
931
  ${this.labels.createCollection}
932
932
  </button>
933
933
  </section>
934
- `;let n=[],r=null;for(let e of t){let t=e.group??null;(!r||r.label!==t)&&(r={label:t,items:[]},n.push(r)),r.items.push(e)}return o`
934
+ `;let n=[],r=null;for(let e of t){let t=e.group??null;(!r||r.label!==t)&&(r={label:t,items:[]},n.push(r)),r.items.push(e)}return c`
935
935
  <section class="mt-8">
936
936
  <h2 class="text-lg font-semibold mb-1">
937
937
  ${this.labels.addCollectionToNavigation}
@@ -969,17 +969,17 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
969
969
  <path d="m6 9 6 6 6-6" />
970
970
  </svg>
971
971
  </button>
972
- ${this._showCollectionPicker?o`
972
+ ${this._showCollectionPicker?c`
973
973
  <div
974
974
  class="collection-picker"
975
975
  role="menu"
976
976
  @click=${e=>e.stopPropagation()}
977
977
  >
978
- ${n.map(e=>o`
979
- ${e.label?o`<div class="collection-picker-group">
978
+ ${n.map(e=>c`
979
+ ${e.label?c`<div class="collection-picker-group">
980
980
  ${e.label}
981
- </div>`:s}
982
- ${e.items.map(e=>{let t=this._addingCollectionId===e.id;return o`
981
+ </div>`:l}
982
+ ${e.items.map(e=>{let t=this._addingCollectionId===e.id;return c`
983
983
  <button
984
984
  type="button"
985
985
  role="menuitem"
@@ -990,14 +990,14 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
990
990
  <span class="collection-picker-title">
991
991
  ${e.title}
992
992
  </span>
993
- ${e.isSmart?o`<span
993
+ ${e.isSmart?c`<span
994
994
  class="collection-directory-smart-icon"
995
995
  role="img"
996
996
  aria-label=${this.labels.smartCollectionLabel??``}
997
997
  title=${this.labels.smartCollectionLabel??``}
998
- >${f(M)}</span
999
- >`:s}
1000
- ${t?o`<svg
998
+ >${f(P)}</span
999
+ >`:l}
1000
+ ${t?c`<svg
1001
1001
  xmlns="http://www.w3.org/2000/svg"
1002
1002
  width="14"
1003
1003
  height="14"
@@ -1010,7 +1010,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1010
1010
  class="animate-spin shrink-0 text-muted-foreground"
1011
1011
  >
1012
1012
  <path d="M21 12a9 9 0 1 1-6.219-8.56" />
1013
- </svg>`:s}
1013
+ </svg>`:l}
1014
1014
  </button>
1015
1015
  `})}
1016
1016
  `)}
@@ -1027,10 +1027,10 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1027
1027
  </button>
1028
1028
  </div>
1029
1029
  </div>
1030
- `:s}
1030
+ `:l}
1031
1031
  </div>
1032
1032
  </section>
1033
- `}#Ee(){return o`
1033
+ `}#Ee(){return c`
1034
1034
  <header>
1035
1035
  <h2 id="nav-collection-dialog-title">
1036
1036
  ${this.labels.createCollection}
@@ -1044,9 +1044,9 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1044
1044
  action=${a(`/api/collections`)}
1045
1045
  @jant:collection-submit=${e=>void this.#B(e)}
1046
1046
  ></jant-collection-form>
1047
- ${this._createCollectionError?o`<p class="mt-3 text-sm text-destructive" role="alert">
1047
+ ${this._createCollectionError?c`<p class="mt-3 text-sm text-destructive" role="alert">
1048
1048
  ${this._createCollectionError}
1049
- </p>`:s}
1049
+ </p>`:l}
1050
1050
  </section>
1051
1051
  <footer>
1052
1052
  <button
@@ -1066,7 +1066,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1066
1066
  ${this._creatingCollection?this.labels.creatingCollection:this.labels.createCollection}
1067
1067
  </button>
1068
1068
  </footer>
1069
- `}async#De(e){let{changed:t,collection:n}=await I({collectionId:e});t&&n&&(this._createdCollection=n,this.collections=this.collections.map(e=>e.id===n.id?{...e,title:n.title,slug:n.slug}:e))}#Oe(){let e=this._createdCollection;return e?o`
1069
+ `}async#De(e){let{changed:t,collection:n}=await R({collectionId:e});t&&n&&(this._createdCollection=n,this.collections=this.collections.map(e=>e.id===n.id?{...e,title:n.title,slug:n.slug}:e))}#Oe(){let e=this._createdCollection;return e?c`
1070
1070
  <header class="nav-create-success-header">
1071
1071
  <span class="nav-create-success-icon" aria-hidden="true">
1072
1072
  <svg
@@ -1092,7 +1092,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1092
1092
  <div class="nav-create-success-card">
1093
1093
  <span class="nav-page-result-title">${e.title}</span>
1094
1094
  <span class="nav-page-result-path">
1095
- ${a(S(e.slug))}
1095
+ ${a(w(e.slug))}
1096
1096
  </span>
1097
1097
  </div>
1098
1098
  </section>
@@ -1116,7 +1116,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1116
1116
  ${this.labels.addToNavigation}
1117
1117
  </button>
1118
1118
  </footer>
1119
- `:s}#ke(){return this._collectionDialogOpen?o`
1119
+ `:l}#ke(){return this._collectionDialogOpen?c`
1120
1120
  <dialog
1121
1121
  id="nav-collection-dialog"
1122
1122
  class="dialog nav-collection-dialog"
@@ -1153,14 +1153,14 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1153
1153
  ${this._collectionDialogView===`create`?this.#Ee():this.#Oe()}
1154
1154
  </div>
1155
1155
  </dialog>
1156
- `:s}#Ae(){return this.systemNavItems?.length?o`
1156
+ `:l}#Ae(){return this.systemNavItems?.length?c`
1157
1157
  <section class="mt-8">
1158
1158
  <h2 class="text-lg font-semibold mb-1">${this.labels.systemLinks}</h2>
1159
1159
  <p class="text-sm text-muted-foreground mb-3">
1160
1160
  ${this.labels.systemLinksDescription}
1161
1161
  </p>
1162
1162
  <div class="flex flex-col divide-y">
1163
- ${this.systemNavItems.map(e=>{let t=this.#ee(e),n=this._togglingKeys.has(e.key);return o`
1163
+ ${this.systemNavItems.map(e=>{let t=this.#ee(e),n=this._togglingKeys.has(e.key);return c`
1164
1164
  <label class=${n?`flex items-center justify-between gap-4 py-3 opacity-60 cursor-not-allowed`:`flex items-center justify-between gap-4 py-3 cursor-pointer`}>
1165
1165
  <div>
1166
1166
  <p class="font-medium">${e.label}</p>
@@ -1180,23 +1180,23 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1180
1180
  `})}
1181
1181
  </div>
1182
1182
  </section>
1183
- `:s}render(){return o`
1183
+ `:l}render(){return c`
1184
1184
  ${this.#le()}
1185
1185
 
1186
1186
  <section class="mt-8">
1187
1187
  <h2 class="text-lg font-semibold mb-3">${this.labels.headerSection}</h2>
1188
- ${this.#ne.length===0?o`<p class="text-sm text-muted-foreground py-4">
1188
+ ${this.#ne.length===0?c`<p class="text-sm text-muted-foreground py-4">
1189
1189
  ${this.labels.emptyState}
1190
- </p>`:s}
1190
+ </p>`:l}
1191
1191
  <div id="nav-items-header" class="nav-items-list">
1192
- ${T(this.#ne,e=>e.id,e=>this.#fe(e))}
1192
+ ${D(this.#ne,e=>e.id,e=>this.#fe(e))}
1193
1193
  </div>
1194
1194
  </section>
1195
1195
 
1196
1196
  <section class="mt-8">
1197
1197
  <h2 class="text-lg font-semibold mb-3">${this.labels.moreSection}</h2>
1198
1198
  <div id="nav-items-more" class="nav-items-list nav-items-list-drop">
1199
- ${this.#re.length>0?T(this.#re,e=>e.id,e=>this.#fe(e)):o`<p class="nav-items-empty-hint">
1199
+ ${this.#re.length>0?D(this.#re,e=>e.id,e=>this.#fe(e)):c`<p class="nav-items-empty-hint">
1200
1200
  ${this.labels.moreEmptyHint}
1201
1201
  </p>`}
1202
1202
  </div>
@@ -1206,29 +1206,29 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1206
1206
  ${this.#Te()} ${this.#we()}
1207
1207
  ${this.#Ae()} ${this.#Ce()}
1208
1208
  ${this.#ke()}
1209
- `}};customElements.define(`jant-nav-manager`,xe);var Se=`X-Jant-Site-Header`,Ce=`include`;async function z(e){let t=await fetch(`/api/nav-items`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,[Se]:Ce},body:JSON.stringify(e)}),n=await ee(t);if(!t.ok)throw Error(x(n,`error`)??`HTTP ${t.status}`);return j(x(n,`headerHtml`)),x(n,`id`)}async function B(e){return z({type:`collection`,collectionId:e,placement:`header`})}async function V(e){return z({type:`smart_collection`,smartCollectionId:e,placement:`header`})}function we(e,t){let n=e[t];if(!n||n.type!==`divider`||!n.label)return null;let r=[];for(let n=t+1;n<e.length;n+=1){let t=e[n];if(!t||t.type===`divider`)break;let i=t.collection?.slug;i&&r.push(i)}return r.length<2?null:{slugExpression:r.join(`+`),collectionCount:r.length}}function H(e,t={}){return e.trim()?ue(he(e),t):``}function Te(){return Math.floor(Date.now()/1e3)}function U(e){return new Date(e*1e3).toISOString()}function Ee(e,t=`UTC`){let n=Te()-e;if(n<60)return`1m`;let r=Math.floor(n/60);if(r<60)return`${r}m`;let i=Math.floor(n/3600);if(i<24)return`${i}h`;let a=Math.floor(n/86400);return a<=7?`${a}d`:new Date(e*1e3).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,timeZone:t})}function De(e,t=`UTC`){let n=Ee(e,t);return/^[0-9]+[mhd]$/.test(n)?`${n} ago`:n}var Oe=new Map;function ke(e,t){let n=Oe.get(t);n||(n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,hourCycle:`h23`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`}),Oe.set(t,n));let r={};for(let t of n.formatToParts(e))t.type!==`literal`&&(r[t.type]=Number(t.value));return Date.UTC(r.year??1970,(r.month??1)-1,r.day??1,r.hour??0,r.minute??0,r.second??0)-Math.floor(e/1e3)*1e3}function Ae(e,t,n){let r=Date.UTC(e,t-1,1),i=r-ke(r,n);return Math.floor((r-ke(i,n))/1e3)}var W=[`collection`,`format`,`title`,`year`,`media`,`replies`,`visibility`];function je(e){return e===`any`||e===`none`||Array.isArray(e)&&e.length>0&&e.every(e=>b.includes(e))}function Me(e){return typeof e==`boolean`?e:e===1||e===0?e===1:null}function Ne(e){if(typeof e!=`string`||e===``)return null;if(e===`any`||e===`none`)return e;let t=e.split(`,`).map(e=>e.trim()).filter(e=>b.includes(e));return t.length>0?t:null}var Pe=/[,+\s]+/;function Fe(e){let t=new Set;for(let n of e.split(Pe)){let e=n.trim();e&&t.add(e)}return[...t]}var Ie={key:`collection`,label:{id:`q-hNag`},url:{param:`collection`,parse(e,t){let n=e(`collection`);if(!n)return{state:`absent`};let r=Fe(n);if(r.length===0)return{state:`absent`};let i=t.collections,a=[];for(let e of r){let t=i?.idBySlug.get(e);if(!t)return{state:`invalid`,message:`No collection named "${e}".`};a.push(t)}return{state:`value`,value:a}},serialize(e,t){let n=e.map(e=>t.collections?.slugById.get(e)).filter(e=>!!e);return n.length>0?n.join(`,`):null}},storage:{column:`collectionId`,isStorable(e){return Array.isArray(e)&&e.length===1&&typeof e[0]==`string`&&fe(e[0],le.collection)},toColumn(e){return e[0]},fromColumn(e){return typeof e==`string`&&e?[e]:null}},control:{kind:`collection`},toPostFilter(e){return{collectionIds:[...e]}},describe(e,t,n){let r=e.map(e=>n.collections?.titleById.get(e)).filter(e=>!!e);return r.length>0?r.join(`, `):null}},Le={note:{id:`1DBGsz`},link:{id:`Rj01Fz`},quote:{id:`eWLklq`}},Re={key:`format`,label:{id:`kI1qVD`},url:{param:`format`,parse(e){let t=e(`format`);return t?y.includes(t)?{state:`value`,value:t}:{state:`invalid`,message:`Invalid format value. Allowed: ${y.join(`, `)}`}:{state:`absent`}},serialize(e){return e}},storage:{column:`format`,isStorable(e){return typeof e==`string`&&y.includes(e)},toColumn(e){return e},fromColumn(e){return y.includes(e)?e:null}},control:{kind:`enum`,options:y,labelOf:e=>Le[e]},toPostFilter(e){return{format:e}},describe(e,t){return t._(Le[e])}},ze={id:`q8RviX`},Be={id:`wja8aL`};function Ve(e,t){let n=e(t);return n===void 0?{state:`absent`}:n===`1`?{state:`value`,value:!0}:n===`0`?{state:`value`,value:!1}:{state:`invalid`,message:`Invalid ${t} value. Allowed: 0, 1`}}function He(e,t,n){let r=e(t);return r!==void 0&&r!==``?r===`any`?{state:`value`,value:!0}:r===`none`?{state:`value`,value:!1}:{state:`invalid`,message:`Invalid ${t} value. Allowed: any, none`}:Ve(e,n)}var Ue={key:`title`,label:{id:`MHrjPM`},url:{param:`title`,legacy:[`hasTitle`],parse(e){return He(e,`title`,`hasTitle`)},serialize(e){return e?`any`:`none`}},storage:{column:`hasTitle`,isStorable(e){return typeof e==`boolean`},toColumn(e){return e},fromColumn:Me},control:{kind:`presence`,yes:ze,no:Be},toPostFilter(e){return{hasTitle:e}},describe(e,t){return t._(e?ze:Be)}},We={key:`year`,label:{id:`3PAU4M`},url:{param:`year`,parse(e){let t=e(`year`);if(!t)return{state:`absent`};let n=Number.parseInt(t,10);return!Number.isFinite(n)||n<1971||n>9999?{state:`invalid`,message:`Invalid year value. Allowed: ${ie} to ${te}`}:{state:`value`,value:n}},serialize(e){return String(e)}},storage:{column:`year`,isStorable(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1971&&e<=9999},toColumn(e){return e},fromColumn(e){return typeof e==`number`&&Number.isInteger(e)?e:null}},control:{kind:`year`},toPostFilter(e,t){let n=Ae(e,1,t.timeZone),r=Ae(e+1,1,t.timeZone);return t.yearAxis===`sort`?{axisAfter:n,axisBefore:r}:{publishedAfter:n,publishedBefore:r}},describe(e){return String(e)}},Ge={image:{id:`an5hVd`},video:{id:`vSJd18`},audio:{id:`_rTz0M`},text:{id:`mKT7g0`},document:{id:`sER-bs`}},Ke={id:`QJAQiR`},qe={id:`P5WtnY`},Je={key:`media`,label:{id:`xYilR2`},url:{param:`media`,legacy:[`hasMedia`],parse(e){let t=e(`media`);if(t===void 0||t===``){let t=Ve(e,`hasMedia`);return t.state===`value`?{state:`value`,value:t.value?`any`:`none`}:t}if(t===`any`||t===`none`)return{state:`value`,value:t};let n=t.split(`,`).map(e=>e.trim()).filter(e=>e.length>0),r=n.filter(e=>b.includes(e));return n.length===0||r.length!==n.length?{state:`invalid`,message:`Invalid media value. Allowed: any, none, or kinds: ${b.join(`, `)}`}:{state:`value`,value:r}},serialize(e){return typeof e==`string`?e:e.length>0?e.join(`,`):null}},storage:{column:`media`,isStorable:je,toColumn(e){return typeof e==`string`?e:e.join(`,`)},fromColumn:Ne},control:{kind:`media`},toPostFilter(e){return e===`any`?{hasMedia:!0}:e===`none`?{hasMedia:!1}:e.length>0?{mediaKinds:[...e]}:{}},describe(e,t){return e===`any`?t._(Ke):e===`none`?t._(qe):e.length===1?t._(Ge[e[0]]):e.length>0?t._(Ke):null}},Ye={id:`FqCHF_`},Xe={id:`hqeXKW`},Ze={key:`replies`,label:{id:`N8UzTV`},url:{param:`replies`,legacy:[`hasReplies`],parse(e){return He(e,`replies`,`hasReplies`)},serialize(e){return e?`any`:`none`}},storage:{column:`hasReplies`,isStorable(e){return typeof e==`boolean`},toColumn(e){return e},fromColumn:Me},control:{kind:`presence`,yes:Ye,no:Xe},toPostFilter(e){return{hasReplies:e}},describe(e,t){return t._(e?Ye:Xe)}},G={public:`public`,featured:`featured`,latest_hidden:`hidden`,private:`private`},Qe=Object.keys(G),$e=new Map(Object.entries(G).map(([e,t])=>[t,e])),et=new Map([[`latest_hidden`,{state:`value`,value:`latest_hidden`}],[`all`,{state:`cleared`}]]),tt={public:{id:`7d1a0d`},latest_hidden:{id:`dYKrp3`},private:{id:`zwBp5t`},featured:{id:`FkMol5`}},K={collection:Ie,format:Re,title:Ue,year:We,media:Je,replies:Ze,visibility:{key:`visibility`,label:{id:`2q_Q7x`},url:{param:`visibility`,parse(e){let t=e(`visibility`);if(!t)return{state:`absent`};let n=et.get(t);if(n)return n;let r=$e.get(t);return r?{state:`value`,value:r}:{state:`invalid`,message:`Invalid visibility value. Allowed: ${[...$e.keys()].join(`, `)}`}},serialize(e){return G[e]}},storage:{column:`visibility`,isStorable(e){return typeof e==`string`&&ae.includes(e)},toColumn(e){return e},fromColumn(e){return Qe.includes(e)?e:null}},control:{kind:`enum`,options:ae,labelOf:e=>tt[e]},toPostFilter(e){return e===`featured`?{featured:!0}:{visibility:e}},describe(e,t){return t._(tt[e])}}};W.flatMap(e=>[K[e].url.param,...K[e].url.legacy??[]]);function nt(e,t){let n={},r=[];for(let i of W){let a=K[i],o=a.url.parse(e,t);o.state===`value`?n[i]=o.value:o.state===`invalid`&&r.push({param:a.url.param,message:o.message})}return{selection:n,issues:r}}function rt(e,t,n=new URLSearchParams){for(let r of W){let i=e[r];if(i===void 0)continue;let a=K[r],o=it(r,i,t);o!==null&&n.set(a.url.param,o)}return n}function it(e,t,n){let r=K[e].url.serialize;return r(t,n)}function q(e,t){return(n,r,i)=>o`
1209
+ `}};customElements.define(`jant-nav-manager`,ye);var be=`X-Jant-Site-Header`,xe=`include`;async function V(e){let t=await fetch(`/api/nav-items`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`,[be]:xe},body:JSON.stringify(e)}),n=await g(t);if(!t.ok)throw Error(b(n,`error`)??`HTTP ${t.status}`);return N(b(n,`headerHtml`)),b(n,`id`)}async function H(e){return V({type:`collection`,collectionId:e,placement:`header`})}async function Se(e){return V({type:`smart_collection`,smartCollectionId:e,placement:`header`})}function Ce(e,t){let n=e[t];if(!n||n.type!==`divider`||!n.label)return null;let r=[];for(let n=t+1;n<e.length;n+=1){let t=e[n];if(!t||t.type===`divider`)break;let i=t.collection?.slug;i&&r.push(i)}return r.length<2?null:{slugExpression:r.join(`+`),collectionCount:r.length}}function U(e,t={}){return e.trim()?ce(pe(e),t):``}function we(){return Math.floor(Date.now()/1e3)}function Te(e){return new Date(e*1e3).toISOString()}function Ee(e,t=`UTC`){let n=we()-e;if(n<60)return`1m`;let r=Math.floor(n/60);if(r<60)return`${r}m`;let i=Math.floor(n/3600);if(i<24)return`${i}h`;let a=Math.floor(n/86400);return a<=7?`${a}d`:new Date(e*1e3).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,timeZone:t})}function De(e,t=`UTC`){let n=Ee(e,t);return/^[0-9]+[mhd]$/.test(n)?`${n} ago`:n}var Oe=new Map;function ke(e,t){let n=Oe.get(t);n||(n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,hourCycle:`h23`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`}),Oe.set(t,n));let r={};for(let t of n.formatToParts(e))t.type!==`literal`&&(r[t.type]=Number(t.value));return Date.UTC(r.year??1970,(r.month??1)-1,r.day??1,r.hour??0,r.minute??0,r.second??0)-Math.floor(e/1e3)*1e3}function Ae(e,t,n){let r=Date.UTC(e,t-1,1),i=r-ke(r,n);return Math.floor((r-ke(i,n))/1e3)}var W=[`collection`,`format`,`title`,`year`,`media`,`replies`,`visibility`];function je(e){return e===`any`||e===`none`||Array.isArray(e)&&e.length>0&&e.every(e=>y.includes(e))}function Me(e){return typeof e==`boolean`?e:e===1||e===0?e===1:null}function Ne(e){if(typeof e!=`string`||e===``)return null;if(e===`any`||e===`none`)return e;let t=e.split(`,`).map(e=>e.trim()).filter(e=>y.includes(e));return t.length>0?t:null}var Pe=/[,+\s]+/;function Fe(e){let t=new Set;for(let n of e.split(Pe)){let e=n.trim();e&&t.add(e)}return[...t]}var Ie={key:`collection`,label:{id:`q-hNag`},url:{param:`collection`,parse(e,t){let n=e(`collection`);if(!n)return{state:`absent`};let r=Fe(n);if(r.length===0)return{state:`absent`};let i=t.collections,a=[];for(let e of r){let t=i?.idBySlug.get(e);if(!t)return{state:`invalid`,message:`No collection named "${e}".`};a.push(t)}return{state:`value`,value:a}},serialize(e,t){let n=e.map(e=>t.collections?.slugById.get(e)).filter(e=>!!e);return n.length>0?n.join(`,`):null}},storage:{column:`collectionId`,isStorable(e){return Array.isArray(e)&&e.length===1&&typeof e[0]==`string`&&ue(e[0],se.collection)},toColumn(e){return e[0]},fromColumn(e){return typeof e==`string`&&e?[e]:null}},control:{kind:`collection`},toPostFilter(e){return{collectionIds:[...e]}},describe(e,t,n){let r=e.map(e=>n.collections?.titleById.get(e)).filter(e=>!!e);return r.length>0?r.join(`, `):null}},Le={note:{id:`1DBGsz`},link:{id:`Rj01Fz`},quote:{id:`eWLklq`}},Re={key:`format`,label:{id:`kI1qVD`},url:{param:`format`,parse(e){let t=e(`format`);return t?v.includes(t)?{state:`value`,value:t}:{state:`invalid`,message:`Invalid format value. Allowed: ${v.join(`, `)}`}:{state:`absent`}},serialize(e){return e}},storage:{column:`format`,isStorable(e){return typeof e==`string`&&v.includes(e)},toColumn(e){return e},fromColumn(e){return v.includes(e)?e:null}},control:{kind:`enum`,options:v,labelOf:e=>Le[e]},toPostFilter(e){return{format:e}},describe(e,t){return t._(Le[e])}},ze={id:`q8RviX`},Be={id:`wja8aL`};function Ve(e,t){let n=e(t);return n===void 0?{state:`absent`}:n===`1`?{state:`value`,value:!0}:n===`0`?{state:`value`,value:!1}:{state:`invalid`,message:`Invalid ${t} value. Allowed: 0, 1`}}function He(e,t,n){let r=e(t);return r!==void 0&&r!==``?r===`any`?{state:`value`,value:!0}:r===`none`?{state:`value`,value:!1}:{state:`invalid`,message:`Invalid ${t} value. Allowed: any, none`}:Ve(e,n)}var Ue={key:`title`,label:{id:`MHrjPM`},url:{param:`title`,legacy:[`hasTitle`],parse(e){return He(e,`title`,`hasTitle`)},serialize(e){return e?`any`:`none`}},storage:{column:`hasTitle`,isStorable(e){return typeof e==`boolean`},toColumn(e){return e},fromColumn:Me},control:{kind:`presence`,yes:ze,no:Be},toPostFilter(e){return{hasTitle:e}},describe(e,t){return t._(e?ze:Be)}},We={key:`year`,label:{id:`3PAU4M`},url:{param:`year`,parse(e){let t=e(`year`);if(!t)return{state:`absent`};let n=Number.parseInt(t,10);return!Number.isFinite(n)||n<1971||n>9999?{state:`invalid`,message:`Invalid year value. Allowed: ${ne} to ${_}`}:{state:`value`,value:n}},serialize(e){return String(e)}},storage:{column:`year`,isStorable(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1971&&e<=9999},toColumn(e){return e},fromColumn(e){return typeof e==`number`&&Number.isInteger(e)?e:null}},control:{kind:`year`},toPostFilter(e,t){let n=Ae(e,1,t.timeZone),r=Ae(e+1,1,t.timeZone);return t.yearAxis===`sort`?{axisAfter:n,axisBefore:r}:{publishedAfter:n,publishedBefore:r}},describe(e){return String(e)}},Ge={image:{id:`an5hVd`},video:{id:`vSJd18`},audio:{id:`_rTz0M`},text:{id:`mKT7g0`},document:{id:`sER-bs`}},Ke={id:`QJAQiR`},qe={id:`P5WtnY`},Je={key:`media`,label:{id:`xYilR2`},url:{param:`media`,legacy:[`hasMedia`],parse(e){let t=e(`media`);if(t===void 0||t===``){let t=Ve(e,`hasMedia`);return t.state===`value`?{state:`value`,value:t.value?`any`:`none`}:t}if(t===`any`||t===`none`)return{state:`value`,value:t};let n=t.split(`,`).map(e=>e.trim()).filter(e=>e.length>0),r=n.filter(e=>y.includes(e));return n.length===0||r.length!==n.length?{state:`invalid`,message:`Invalid media value. Allowed: any, none, or kinds: ${y.join(`, `)}`}:{state:`value`,value:r}},serialize(e){return typeof e==`string`?e:e.length>0?e.join(`,`):null}},storage:{column:`media`,isStorable:je,toColumn(e){return typeof e==`string`?e:e.join(`,`)},fromColumn:Ne},control:{kind:`media`},toPostFilter(e){return e===`any`?{hasMedia:!0}:e===`none`?{hasMedia:!1}:e.length>0?{mediaKinds:[...e]}:{}},describe(e,t){return e===`any`?t._(Ke):e===`none`?t._(qe):e.length===1?t._(Ge[e[0]]):e.length>0?t._(Ke):null}},Ye={id:`FqCHF_`},Xe={id:`hqeXKW`},Ze={key:`replies`,label:{id:`N8UzTV`},url:{param:`replies`,legacy:[`hasReplies`],parse(e){return He(e,`replies`,`hasReplies`)},serialize(e){return e?`any`:`none`}},storage:{column:`hasReplies`,isStorable(e){return typeof e==`boolean`},toColumn(e){return e},fromColumn:Me},control:{kind:`presence`,yes:Ye,no:Xe},toPostFilter(e){return{hasReplies:e}},describe(e,t){return t._(e?Ye:Xe)}},G={public:`public`,featured:`featured`,latest_hidden:`hidden`,private:`private`},Qe=Object.keys(G),$e=new Map(Object.entries(G).map(([e,t])=>[t,e])),et=new Map([[`latest_hidden`,{state:`value`,value:`latest_hidden`}],[`all`,{state:`cleared`}]]),tt={public:{id:`7d1a0d`},latest_hidden:{id:`dYKrp3`},private:{id:`zwBp5t`},featured:{id:`FkMol5`}},K={collection:Ie,format:Re,title:Ue,year:We,media:Je,replies:Ze,visibility:{key:`visibility`,label:{id:`2q_Q7x`},url:{param:`visibility`,parse(e){let t=e(`visibility`);if(!t)return{state:`absent`};let n=et.get(t);if(n)return n;let r=$e.get(t);return r?{state:`value`,value:r}:{state:`invalid`,message:`Invalid visibility value. Allowed: ${[...$e.keys()].join(`, `)}`}},serialize(e){return G[e]}},storage:{column:`visibility`,isStorable(e){return typeof e==`string`&&re.includes(e)},toColumn(e){return e},fromColumn(e){return Qe.includes(e)?e:null}},control:{kind:`enum`,options:re,labelOf:e=>tt[e]},toPostFilter(e){return e===`featured`?{featured:!0}:{visibility:e}},describe(e,t){return t._(tt[e])}}};W.flatMap(e=>[K[e].url.param,...K[e].url.legacy??[]]);function nt(e,t){let n={},r=[];for(let i of W){let a=K[i],o=a.url.parse(e,t);o.state===`value`?n[i]=o.value:o.state===`invalid`&&r.push({param:a.url.param,message:o.message})}return{selection:n,issues:r}}function rt(e,t,n=new URLSearchParams){for(let r of W){let i=e[r];if(i===void 0)continue;let a=K[r],o=it(r,i,t);o!==null&&n.set(a.url.param,o)}return n}function it(e,t,n){let r=K[e].url.serialize;return r(t,n)}function q(e,t){return(n,r,i)=>c`
1210
1210
  <select
1211
1211
  class="select smart-condition-select"
1212
1212
  .value=${n}
1213
1213
  @change=${e=>r(e.target.value)}
1214
1214
  >
1215
- ${t.map(t=>o`
1215
+ ${t.map(t=>c`
1216
1216
  <option value=${t} ?selected=${t===n}>
1217
1217
  ${i.values[`${e}.${t}`]??t}
1218
1218
  </option>
1219
1219
  `)}
1220
1220
  </select>
1221
- `}function at(e){return q(e,[`any`,`none`])}var J={collection:{defaultValue:``,render:(e,t,n)=>{let r=Object.entries(n.values).filter(([e])=>e.startsWith(`collection.`)).map(([e,t])=>[e.slice(11),t]);return o`
1221
+ `}function at(e){return q(e,[`any`,`none`])}var J={collection:{defaultValue:``,render:(e,t,n)=>{let r=Object.entries(n.values).filter(([e])=>e.startsWith(`collection.`)).map(([e,t])=>[e.slice(11),t]);return c`
1222
1222
  <select
1223
1223
  class="select smart-condition-select"
1224
1224
  .value=${e}
1225
1225
  @change=${e=>t(e.target.value)}
1226
1226
  >
1227
- ${r.map(([t,n])=>o`
1227
+ ${r.map(([t,n])=>c`
1228
1228
  <option value=${t} ?selected=${t===e}>${n}</option>
1229
1229
  `)}
1230
1230
  </select>
1231
- `}},format:{defaultValue:y[0],render:q(`format`,y)},title:{defaultValue:`any`,render:at(`title`)},year:{defaultValue:String(new Date().getUTCFullYear()),render:(e,t)=>o`
1231
+ `}},format:{defaultValue:v[0],render:q(`format`,v)},title:{defaultValue:`any`,render:at(`title`)},year:{defaultValue:String(new Date().getUTCFullYear()),render:(e,t)=>c`
1232
1232
  <input
1233
1233
  class="input smart-condition-year"
1234
1234
  type="number"
@@ -1237,7 +1237,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1237
1237
  .value=${e}
1238
1238
  @input=${e=>t(e.target.value)}
1239
1239
  />
1240
- `},media:{defaultValue:`any`,render:(e,t,n)=>{let r=e===`any`||e===`none`?[]:e.split(`,`),i=(e,n)=>{let i=n?[...r,e]:r.filter(t=>t!==e);t(i.length>0?i.join(`,`):`any`)};return o`
1240
+ `},media:{defaultValue:`any`,render:(e,t,n)=>{let r=e===`any`||e===`none`?[]:e.split(`,`),i=(e,n)=>{let i=n?[...r,e]:r.filter(t=>t!==e);t(i.length>0?i.join(`,`):`any`)};return c`
1241
1241
  <div class="smart-condition-media">
1242
1242
  <select
1243
1243
  class="select smart-condition-select"
@@ -1251,9 +1251,9 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1251
1251
  ${n.values[`media.none`]??`none`}
1252
1252
  </option>
1253
1253
  </select>
1254
- ${e===`none`?null:o`
1254
+ ${e===`none`?null:c`
1255
1255
  <div class="smart-condition-media-kinds">
1256
- ${b.map(e=>o`
1256
+ ${y.map(e=>c`
1257
1257
  <label class="smart-condition-kind">
1258
1258
  <input
1259
1259
  class="input"
@@ -1267,7 +1267,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1267
1267
  </div>
1268
1268
  `}
1269
1269
  </div>
1270
- `}},replies:{defaultValue:`any`,render:at(`replies`)},visibility:{defaultValue:`public`,render:q(`visibility`,[`public`,`featured`,`hidden`])}};function ot(e){let t=rt(e,{collections:lt()}),n=[];for(let e of W){let r=t.get(K[e].url.param);r!==null&&n.push({key:e,value:r})}return n}function st(e){let t=new URLSearchParams;for(let n of e){if(!n.value)continue;let e=K[n.key];e&&t.set(e.url.param,n.value)}let{selection:n}=nt(e=>t.get(e)??void 0,{collections:lt()});return n}var ct={idBySlug:new Map,slugById:new Map,titleById:new Map};function Y(e){let t=new Map,n=new Map,r=new Map;for(let i of e)t.set(i.slug,i.id),n.set(i.id,i.slug),r.set(i.id,i.title);ct={idBySlug:t,slugById:n,titleById:r}}function lt(){return ct}var ut=250,dt=o`<svg
1270
+ `}},replies:{defaultValue:`any`,render:at(`replies`)},visibility:{defaultValue:`public`,render:q(`visibility`,[`public`,`featured`,`hidden`])}};function ot(e){let t=rt(e,{collections:lt()}),n=[];for(let e of W){let r=t.get(K[e].url.param);r!==null&&n.push({key:e,value:r})}return n}function st(e){let t=new URLSearchParams;for(let n of e){if(!n.value)continue;let e=K[n.key];e&&t.set(e.url.param,n.value)}let{selection:n}=nt(e=>t.get(e)??void 0,{collections:lt()});return n}var ct={idBySlug:new Map,slugById:new Map,titleById:new Map};function Y(e){let t=new Map,n=new Map,r=new Map;for(let i of e)t.set(i.slug,i.id),n.set(i.id,i.slug),r.set(i.id,i.title);ct={idBySlug:t,slugById:n,titleById:r}}function lt(){return ct}var ut=250,dt=c`<svg
1271
1271
  viewBox="0 0 24 24"
1272
1272
  fill="none"
1273
1273
  stroke="currentColor"
@@ -1278,7 +1278,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1278
1278
  >
1279
1279
  <path d="M5 12h14" />
1280
1280
  <path d="M12 5v14" />
1281
- </svg>`,ft=o`<svg
1281
+ </svg>`,ft=c`<svg
1282
1282
  viewBox="0 0 24 24"
1283
1283
  fill="none"
1284
1284
  stroke="currentColor"
@@ -1290,7 +1290,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1290
1290
  <circle cx="12" cy="12" r="10" />
1291
1291
  <line x1="12" x2="12" y1="8" y2="12" />
1292
1292
  <line x1="12" x2="12.01" y1="16" y2="16" />
1293
- </svg>`,pt=o`<svg
1293
+ </svg>`,pt=c`<svg
1294
1294
  viewBox="0 0 24 24"
1295
1295
  fill="none"
1296
1296
  stroke="currentColor"
@@ -1301,7 +1301,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1301
1301
  >
1302
1302
  <path d="M18 6 6 18" />
1303
1303
  <path d="m6 6 12 12" />
1304
- </svg>`,mt=class extends c{static properties={labels:{type:Object},_open:{state:!0},_mode:{state:!0},_id:{state:!0},_title:{state:!0},_slug:{state:!0},_slugEdited:{state:!0},_slugState:{state:!0},_slugOpen:{state:!0},_description:{state:!0},_rows:{state:!0},_sort:{state:!0},_layout:{state:!0},_preview:{state:!0},_addMenuOpen:{state:!0},_saving:{state:!0},_error:{state:!0}};#e=``;#t=``;#n=null;#r=null;#i=null;#a=0;createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this.labels={},this._open=!1,this._mode=`create`,this._id=null,this._title=``,this._slug=``,this._slugEdited=!1,this._slugState=`unknown`,this._slugOpen=!1,this._description=``,this._rows=[],this._sort=`newest`,this._layout=``,this._preview=null,this._addMenuOpen=!1,this._saving=!1,this._error=``}async open(e){if(this.#o(),e.smartCollectionId){if(!await this.#s(e.smartCollectionId))return!1}else e.prefill&&(this._title=e.prefill.title??``,this._description=e.prefill.description??``,this._rows=ot(e.prefill.selection??{}),this._sort=e.prefill.sortOrder??`newest`,this._layout=e.prefill.layout??``,this._title&&await this.#S());return this._open=!0,await this.updateComplete,this.#c(),this.#y(),new Promise(e=>{this.#n=e})}#o(){this._mode=`create`,this._id=null,this._title=``,this._slug=``,this._slugEdited=!1,this._slugState=`unknown`,this._slugOpen=!1,this._description=``,this._rows=[],this._sort=`newest`,this._layout=``,this._preview=null,this._addMenuOpen=!1,this._saving=!1,this._error=``,this.#e=``}async#s(e){try{let t=await fetch(a(`/api/smart-collections/${e}`));if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();return this._mode=`edit`,this._id=n.id,this._title=n.title??``,this._slug=n.slug??``,this.#e=n.slug??``,this._slugEdited=!0,this._description=n.description??``,this._rows=ot(n.selection??{}),this._sort=n.sortOrder??`newest`,this._layout=n.layout??``,!0}catch{return l(this.labels.loadFailed,`error`),!1}}#c(){let e=this.querySelector(`.collection-dialog`);e&&(e.open||e.showModal(),this.querySelector(`[data-field='title']`)?.focus())}#l(e){let t=this.querySelector(`.collection-dialog`);t?.open&&t.close(),this._open=!1,this._addMenuOpen=!1,this.#r&&clearTimeout(this.#r),this.#i&&clearTimeout(this.#i);let n=this.#n;this.#n=null,n?.(e)}#u(){let e=new Set(this._rows.map(e=>e.key));return Object.keys(J).filter(t=>!e.has(t))}#d(e){this._addMenuOpen=!1,this._rows=[...this._rows,{key:e,value:J[e].defaultValue}],this.#y()}#f(){this._addMenuOpen=!this._addMenuOpen,this._addMenuOpen&&this.updateComplete.then(()=>{this.#m()?.scrollIntoView?.({block:`nearest`}),this.#h()[0]?.focus()})}#p(e){this._addMenuOpen&&(this._addMenuOpen=!1,e&&this.updateComplete.then(()=>{this.querySelector(`[data-add-trigger]`)?.focus()}))}#m(){return this.querySelector(`[data-add-menu]`)}#h(){return[...this.querySelectorAll(`[data-add-menu] [role='menuitem']`)]}#g(e){let t=this.#h();if(t.length===0)return;let n=t.indexOf(document.activeElement);t[n<0?e>0?0:t.length-1:(n+e+t.length)%t.length]?.focus()}#_(e){this._rows=this._rows.filter(t=>t.key!==e),this.#y()}#v(e,t){this._rows=this._rows.map(n=>n.key===e?{...n,value:t}:n),this.#y()}#y(){this.#r&&clearTimeout(this.#r),this.#r=setTimeout(()=>void this.#b(),ut)}async#b(){let e=++this.#a;try{let t=await fetch(a(`/api/smart-collections/preview`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({selection:st(this._rows)})});if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();if(e!==this.#a)return;this._preview=n}catch{if(e!==this.#a)return;this._preview=null}}#x(e){this._title=e,!this._slugEdited&&this.#S()}async#S(){let e=this._title.trim();if(!e){this.#t=``,this._slug=``,this._slugState=`unknown`;return}this.#t=g(await ce(e),200),this._slug=this.#t,this.#w()}#C(e){this._slugEdited=!0,this._slug=e.trim().toLowerCase(),this.#w()}#w(){this.#i&&clearTimeout(this.#i),this._slugState=`checking`,this.#i=setTimeout(()=>void this.#T(),ut)}async#T(){let e=this._slug;if(!e){this._slugState=`unknown`;return}if(this.#E()!==null){this._slugState=`taken`;return}try{let t=new URLSearchParams({mode:`check`,slug:e});this._id&&t.set(`smartCollectionId`,this._id);let n=await fetch(a(`/api/smart-collections/slug?${t.toString()}`));if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json();if(e!==this._slug)return;this._slugState=r.available?`available`:`taken`}catch{if(e!==this._slug)return;this._slugState=`unknown`}}#E(){return v(this._slug,{maxLength:200})}#D(){let e=this.#E();return e===`invalid`?this.labels.linkInvalid:e===`reserved`?this.labels.linkReserved:e===`too_long`?this.labels.linkTooLong:this._slugState===`taken`?this.labels.linkTaken:null}#O(){let e=a(S(this._slug)),t=globalThis.location?.origin&&globalThis.location.origin!==`null`?globalThis.location.origin:`http://localhost`;return new URL(e,`${t}/`).toString()}#k(){this._slugOpen||(this._slugOpen=!0,this.updateComplete.then(()=>{let e=this.querySelector(`[data-field='slug']`);e?.focus(),e?.select()}))}#A(){this.#t&&(this._slug=this.#t,this._slugEdited=!1,this.#w())}#j(){if(!this._slug&&!this._slugOpen)return s;let e=this.#D(),t=this._mode===`edit`&&this._slug!==this.#e;if(!this._slugOpen)return o`
1304
+ </svg>`,mt=class extends u{static properties={labels:{type:Object},_open:{state:!0},_mode:{state:!0},_id:{state:!0},_title:{state:!0},_slug:{state:!0},_slugEdited:{state:!0},_slugState:{state:!0},_slugOpen:{state:!0},_description:{state:!0},_rows:{state:!0},_sort:{state:!0},_layout:{state:!0},_preview:{state:!0},_addMenuOpen:{state:!0},_saving:{state:!0},_error:{state:!0}};#e=``;#t=``;#n=null;#r=null;#i=null;#a=0;createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this.labels={},this._open=!1,this._mode=`create`,this._id=null,this._title=``,this._slug=``,this._slugEdited=!1,this._slugState=`unknown`,this._slugOpen=!1,this._description=``,this._rows=[],this._sort=`newest`,this._layout=``,this._preview=null,this._addMenuOpen=!1,this._saving=!1,this._error=``}async open(e){if(this.#o(),e.smartCollectionId){if(!await this.#s(e.smartCollectionId))return!1}else e.prefill&&(this._title=e.prefill.title??``,this._description=e.prefill.description??``,this._rows=ot(e.prefill.selection??{}),this._sort=e.prefill.sortOrder??`newest`,this._layout=e.prefill.layout??``,this._title&&await this.#S());return this._open=!0,await this.updateComplete,this.#c(),this.#y(),new Promise(e=>{this.#n=e})}#o(){this._mode=`create`,this._id=null,this._title=``,this._slug=``,this._slugEdited=!1,this._slugState=`unknown`,this._slugOpen=!1,this._description=``,this._rows=[],this._sort=`newest`,this._layout=``,this._preview=null,this._addMenuOpen=!1,this._saving=!1,this._error=``,this.#e=``}async#s(e){try{let t=await fetch(a(`/api/smart-collections/${e}`));if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();return this._mode=`edit`,this._id=n.id,this._title=n.title??``,this._slug=n.slug??``,this.#e=n.slug??``,this._slugEdited=!0,this._description=n.description??``,this._rows=ot(n.selection??{}),this._sort=n.sortOrder??`newest`,this._layout=n.layout??``,!0}catch{return d(this.labels.loadFailed,`error`),!1}}#c(){let e=this.querySelector(`.collection-dialog`);e&&(e.open||e.showModal(),this.querySelector(`[data-field='title']`)?.focus())}#l(e){let t=this.querySelector(`.collection-dialog`);t?.open&&t.close(),this._open=!1,this._addMenuOpen=!1,this.#r&&clearTimeout(this.#r),this.#i&&clearTimeout(this.#i);let n=this.#n;this.#n=null,n?.(e)}#u(){let e=new Set(this._rows.map(e=>e.key));return Object.keys(J).filter(t=>!e.has(t))}#d(e){this._addMenuOpen=!1,this._rows=[...this._rows,{key:e,value:J[e].defaultValue}],this.#y()}#f(){this._addMenuOpen=!this._addMenuOpen,this._addMenuOpen&&this.updateComplete.then(()=>{this.#m()?.scrollIntoView?.({block:`nearest`}),this.#h()[0]?.focus()})}#p(e){this._addMenuOpen&&(this._addMenuOpen=!1,e&&this.updateComplete.then(()=>{this.querySelector(`[data-add-trigger]`)?.focus()}))}#m(){return this.querySelector(`[data-add-menu]`)}#h(){return[...this.querySelectorAll(`[data-add-menu] [role='menuitem']`)]}#g(e){let t=this.#h();if(t.length===0)return;let n=t.indexOf(document.activeElement);t[n<0?e>0?0:t.length-1:(n+e+t.length)%t.length]?.focus()}#_(e){this._rows=this._rows.filter(t=>t.key!==e),this.#y()}#v(e,t){this._rows=this._rows.map(n=>n.key===e?{...n,value:t}:n),this.#y()}#y(){this.#r&&clearTimeout(this.#r),this.#r=setTimeout(()=>void this.#b(),ut)}async#b(){let e=++this.#a;try{let t=await fetch(a(`/api/smart-collections/preview`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({selection:st(this._rows)})});if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();if(e!==this.#a)return;this._preview=n}catch{if(e!==this.#a)return;this._preview=null}}#x(e){this._title=e,!this._slugEdited&&this.#S()}async#S(){let e=this._title.trim();if(!e){this.#t=``,this._slug=``,this._slugState=`unknown`;return}this.#t=ie(await C(e),200),this._slug=this.#t,this.#w()}#C(e){this._slugEdited=!0,this._slug=e.trim().toLowerCase(),this.#w()}#w(){this.#i&&clearTimeout(this.#i),this._slugState=`checking`,this.#i=setTimeout(()=>void this.#T(),ut)}async#T(){let e=this._slug;if(!e){this._slugState=`unknown`;return}if(this.#E()!==null){this._slugState=`taken`;return}try{let t=new URLSearchParams({mode:`check`,slug:e});this._id&&t.set(`smartCollectionId`,this._id);let n=await fetch(a(`/api/smart-collections/slug?${t.toString()}`));if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json();if(e!==this._slug)return;this._slugState=r.available?`available`:`taken`}catch{if(e!==this._slug)return;this._slugState=`unknown`}}#E(){return S(this._slug,{maxLength:200})}#D(){let e=this.#E();return e===`invalid`?this.labels.linkInvalid:e===`reserved`?this.labels.linkReserved:e===`too_long`?this.labels.linkTooLong:this._slugState===`taken`?this.labels.linkTaken:null}#O(){let e=a(w(this._slug)),t=globalThis.location?.origin&&globalThis.location.origin!==`null`?globalThis.location.origin:`http://localhost`;return new URL(e,`${t}/`).toString()}#k(){this._slugOpen||(this._slugOpen=!0,this.updateComplete.then(()=>{let e=this.querySelector(`[data-field='slug']`);e?.focus(),e?.select()}))}#A(){this.#t&&(this._slug=this.#t,this._slugEdited=!1,this.#w())}#j(){if(!this._slug&&!this._slugOpen)return l;let e=this.#D(),t=this._mode===`edit`&&this._slug!==this.#e;if(!this._slugOpen)return c`
1305
1305
  <div class="collection-quick-link-box">
1306
1306
  <div class="collection-quick-link-row">
1307
1307
  <p
@@ -1318,16 +1318,16 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1318
1318
  ${this.labels.editLink}
1319
1319
  </button>
1320
1320
  </div>
1321
- ${e?o`<p class="collection-dialog-link-problem">${e}</p>`:s}
1321
+ ${e?c`<p class="collection-dialog-link-problem">${e}</p>`:l}
1322
1322
  </div>
1323
- `;let n=!!this.#t&&this._slug!==this.#t;return o`
1323
+ `;let n=!!this.#t&&this._slug!==this.#t;return c`
1324
1324
  <div class="collection-quick-link-editor">
1325
1325
  <div class="field">
1326
1326
  <div class="collection-quick-link-row">
1327
1327
  <label class="label mb-0" for="smart-collection-slug"
1328
1328
  >${this.labels.link}</label
1329
1329
  >
1330
- ${n?o`
1330
+ ${n?c`
1331
1331
  <button
1332
1332
  type="button"
1333
1333
  class="collection-quick-link-action"
@@ -1335,7 +1335,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1335
1335
  >
1336
1336
  ${this.labels.resetLink}
1337
1337
  </button>
1338
- `:s}
1338
+ `:l}
1339
1339
  </div>
1340
1340
  <input
1341
1341
  id="smart-collection-slug"
@@ -1351,17 +1351,17 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1351
1351
  .value=${this._slug}
1352
1352
  @input=${e=>this.#C(e.target.value)}
1353
1353
  />
1354
- ${e?o`<p class="collection-dialog-link-problem">${e}</p>`:this._slug?o`<p class="collection-dialog-link-preview">
1354
+ ${e?c`<p class="collection-dialog-link-problem">${e}</p>`:this._slug?c`<p class="collection-dialog-link-preview">
1355
1355
  ${this.#O()}
1356
- </p>`:o`<p class="collection-dialog-link-help">
1356
+ </p>`:c`<p class="collection-dialog-link-help">
1357
1357
  ${this.labels.linkHelp}
1358
1358
  </p>`}
1359
- ${t?o`<p class="collection-dialog-link-problem">
1359
+ ${t?c`<p class="collection-dialog-link-problem">
1360
1360
  ${this.labels.linkMovesWarning}
1361
- </p>`:s}
1361
+ </p>`:l}
1362
1362
  </div>
1363
1363
  </div>
1364
- `}#M(){return!this._title.trim()||!this._slug?this.labels.titleAndLinkRequired:this.#D()}async#N(){if(this._saving)return;let e=this.#M();if(e){this._error=e;return}let t=this._title.trim();this._saving=!0,this._error=``;let n={slug:this._slug,title:t,description:this._description.trim()||null,selection:st(this._rows),sortOrder:this._sort,layout:this._layout||null};try{let e=await fetch(a(this._id?`/api/smart-collections/${this._id}`:`/api/smart-collections`),{method:this._id?`PUT`:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!e.ok){let t=await e.json().catch(()=>null);this._error=t?.error??this.labels.saveFailed;return}l(this.labels.saved),this.#l(!0)}catch{this._error=this.labels.saveFailed}finally{this._saving=!1}}#P=e=>{if(this._open){if(e.key===`Escape`){if(e.preventDefault(),e.stopPropagation(),this._addMenuOpen){this.#p(!0);return}this.#l(!1);return}if(this._addMenuOpen&&(e.key===`ArrowDown`||e.key===`ArrowUp`)){e.preventDefault(),this.#g(e.key===`ArrowDown`?1:-1);return}if(e.key===`Enter`){let t=e.target;if(t?.tagName===`TEXTAREA`||t?.getAttribute(`role`)===`menuitem`)return;e.preventDefault(),this.#N()}}};connectedCallback(){super.connectedCallback(),this.addEventListener(`keydown`,this.#P)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`keydown`,this.#P),this.#r&&clearTimeout(this.#r),this.#i&&clearTimeout(this.#i)}#F(e){let t=J[e.key],n=this.labels.dimensions[e.key]??e.key;return o`
1364
+ `}#M(){return!this._title.trim()||!this._slug?this.labels.titleAndLinkRequired:this.#D()}async#N(){if(this._saving)return;let e=this.#M();if(e){this._error=e;return}let t=this._title.trim();this._saving=!0,this._error=``;let n={slug:this._slug,title:t,description:this._description.trim()||null,selection:st(this._rows),sortOrder:this._sort,layout:this._layout||null};try{let e=await fetch(a(this._id?`/api/smart-collections/${this._id}`:`/api/smart-collections`),{method:this._id?`PUT`:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!e.ok){let t=await e.json().catch(()=>null);this._error=t?.error??this.labels.saveFailed;return}d(this.labels.saved),this.#l(!0)}catch{this._error=this.labels.saveFailed}finally{this._saving=!1}}#P=e=>{if(this._open){if(e.key===`Escape`){if(e.preventDefault(),e.stopPropagation(),this._addMenuOpen){this.#p(!0);return}this.#l(!1);return}if(this._addMenuOpen&&(e.key===`ArrowDown`||e.key===`ArrowUp`)){e.preventDefault(),this.#g(e.key===`ArrowDown`?1:-1);return}if(e.key===`Enter`){let t=e.target;if(t?.tagName===`TEXTAREA`||t?.getAttribute(`role`)===`menuitem`)return;e.preventDefault(),this.#N()}}};connectedCallback(){super.connectedCallback(),this.addEventListener(`keydown`,this.#P)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`keydown`,this.#P),this.#r&&clearTimeout(this.#r),this.#i&&clearTimeout(this.#i)}#F(e){let t=J[e.key],n=this.labels.dimensions[e.key]??e.key;return c`
1365
1365
  <div class="smart-condition-row" data-condition=${e.key}>
1366
1366
  <span class="smart-condition-label">${n}</span>
1367
1367
  <div class="smart-condition-control">
@@ -1377,7 +1377,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1377
1377
  ${pt}
1378
1378
  </button>
1379
1379
  </div>
1380
- `}#I(){let e=this.#u(),t=this._rows.length>0;return o`
1380
+ `}#I(){let e=this.#u(),t=this._rows.length>0;return c`
1381
1381
  <section class="smart-collection-section">
1382
1382
  <div class="smart-collection-section-head">
1383
1383
  <h3 class="smart-collection-section-title">
@@ -1394,11 +1394,11 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1394
1394
  ${t?this.labels.matchAllHint:this.labels.noConditions}
1395
1395
  </p>
1396
1396
 
1397
- ${t?o`
1397
+ ${t?c`
1398
1398
  <div class="smart-condition-rows">
1399
1399
  ${this._rows.map(e=>this.#F(e))}
1400
1400
  </div>
1401
- `:s}
1401
+ `:l}
1402
1402
 
1403
1403
  <div class="smart-condition-add">
1404
1404
  <button
@@ -1412,14 +1412,14 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1412
1412
  >
1413
1413
  ${dt}${this.labels.addCondition}
1414
1414
  </button>
1415
- ${this._addMenuOpen?o`
1415
+ ${this._addMenuOpen?c`
1416
1416
  <div
1417
1417
  class="collections-page-menu smart-condition-menu"
1418
1418
  data-add-menu
1419
1419
  role="menu"
1420
1420
  @click=${e=>e.stopPropagation()}
1421
1421
  >
1422
- ${e.map(e=>o`
1422
+ ${e.map(e=>c`
1423
1423
  <button
1424
1424
  type="button"
1425
1425
  class="collections-page-menu-item"
@@ -1430,10 +1430,10 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1430
1430
  </button>
1431
1431
  `)}
1432
1432
  </div>
1433
- `:s}
1433
+ `:l}
1434
1434
  </div>
1435
1435
  </section>
1436
- `}render(){if(!this._open)return s;let e=this._mode===`edit`?this.labels.editHeading:this.labels.createHeading;return o`
1436
+ `}render(){if(!this._open)return l;let e=this._mode===`edit`?this.labels.editHeading:this.labels.createHeading;return c`
1437
1437
  <dialog
1438
1438
  class="dialog collection-dialog"
1439
1439
  @cancel=${e=>{e.preventDefault(),this.#l(!1)}}
@@ -1452,9 +1452,9 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1452
1452
  </h2>
1453
1453
  <!-- Said once, where it is needed: by the time anyone edits one
1454
1454
  they know what it is. -->
1455
- ${this._mode===`create`?o`<p class="collection-dialog-note">
1455
+ ${this._mode===`create`?c`<p class="collection-dialog-note">
1456
1456
  ${this.labels.whatItIs}
1457
- </p>`:s}
1457
+ </p>`:l}
1458
1458
  </header>
1459
1459
 
1460
1460
  <div
@@ -1509,7 +1509,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1509
1509
  .value=${this._sort}
1510
1510
  @change=${e=>{this._sort=e.target.value}}
1511
1511
  >
1512
- ${Object.entries(this.labels.sortOptions).map(([e,t])=>o`<option
1512
+ ${Object.entries(this.labels.sortOptions).map(([e,t])=>c`<option
1513
1513
  value=${e}
1514
1514
  ?selected=${e===this._sort}
1515
1515
  >
@@ -1527,7 +1527,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1527
1527
  .value=${this._layout}
1528
1528
  @change=${e=>{this._layout=e.target.value}}
1529
1529
  >
1530
- ${Object.entries(this.labels.layoutOptions).map(([e,t])=>o`<option
1530
+ ${Object.entries(this.labels.layoutOptions).map(([e,t])=>c`<option
1531
1531
  value=${e}
1532
1532
  ?selected=${e===this._layout}
1533
1533
  >
@@ -1538,10 +1538,10 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1538
1538
  </div>
1539
1539
  </section>
1540
1540
 
1541
- ${this._error?o`<div class="alert-destructive" role="alert">
1541
+ ${this._error?c`<div class="alert-destructive" role="alert">
1542
1542
  ${ft}
1543
1543
  <section><p>${this._error}</p></section>
1544
- </div>`:s}
1544
+ </div>`:l}
1545
1545
  </div>
1546
1546
 
1547
1547
  <footer class="collection-dialog-actions">
@@ -1563,21 +1563,21 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1563
1563
  </footer>
1564
1564
  </div>
1565
1565
  </dialog>
1566
- `}};customElements.get(`jant-smart-collection-dialog`)||customElements.define(`jant-smart-collection-dialog`,mt);var ht=`data-smart-collection-dialog-labels`,X=null,Z=null,gt=null;function _t(){if(X)return X;let e=document.querySelector(`[${ht}]`)?.getAttribute(ht);if(!e)return null;try{return X=JSON.parse(e),X}catch{return null}}async function vt(e){gt??=yt();let t=await gt;Y(t);for(let n of t)e.values[`collection.${n.slug}`]=n.title}async function yt(){try{let e=await fetch(a(`/api/collections`));return e.ok?(await e.json()).collections??[]:[]}catch{return[]}}function bt(e){return Z?.isConnected?(Z.labels=e,Z):(Z=document.createElement(`jant-smart-collection-dialog`),Z.labels=e,document.body.appendChild(Z),Z)}async function Q(e){let t=_t();return t?(await vt(t),bt(t).open(e)):!1}var xt=class extends c{static properties={items:{type:Array},labels:{type:Object},navigationCollectionIds:{type:Array,attribute:`navigation-collection-ids`},_items:{state:!0},_reorderMode:{state:!0},_editingDividerId:{state:!0},_editingLinkId:{state:!0},_editLinkLabel:{state:!0},_editLinkUrl:{state:!0},_editLinkDescription:{state:!0},_showMoreMenu:{state:!0},_showLinkForm:{state:!0},_newLinkLabel:{state:!0},_newLinkUrl:{state:!0},_newLinkDescription:{state:!0},_addingLink:{state:!0},_showItemMenuId:{state:!0},_addingToNavigationId:{state:!0},_createdCollectionId:{state:!0}};#e=null;#t=!1;#n=null;#r=null;#i=null;#a=null;#o=()=>{this._showMoreMenu=!1,document.removeEventListener(`click`,this.#o)};#s=()=>{this._showItemMenuId=null,document.removeEventListener(`click`,this.#s)};#c=e=>{let t=e.target;if(!t)return;t.closest(`[data-collections-more-menu]`)&&e.stopPropagation();let n=t.closest(`[data-collections-action]`);if(!n||!this.#r?.contains(n))return;let r=n.dataset.collectionsAction;if(r)switch(e.preventDefault(),e.stopPropagation(),r!==`toggle-menu`&&this._showMoreMenu&&(this._showMoreMenu=!1,document.removeEventListener(`click`,this.#o)),r){case`done`:this.#x();break;case`toggle-menu`:this._showMoreMenu=!this._showMoreMenu,this._showMoreMenu?setTimeout(()=>{document.addEventListener(`click`,this.#o)}):document.removeEventListener(`click`,this.#o);break;case`organize`:this.#b();break;case`divider`:this.#w();break;case`link`:this.#T();break;case`collection`:this.#l();break;case`smart-collection`:Q({}).then(e=>{e&&this.#v()})}};createRenderRoot(){return this.innerHTML=``,this}connectedCallback(){super.connectedCallback(),this.#p()}async#l(){let e=await I();e.changed&&(await this.#v(),e.collection&&(this._createdCollectionId=e.collection.id))}async#u(e){this._showItemMenuId=null,document.removeEventListener(`click`,this.#s);let{changed:t}=await I({collectionId:e});t&&await this.#v()}constructor(){super(),this.items=[],this.labels={},this.navigationCollectionIds=[],this._items=[],this._reorderMode=!1,this._editingDividerId=null,this._editingLinkId=null,this._editLinkLabel=``,this._editLinkUrl=``,this._editLinkDescription=``,this._showMoreMenu=!1,this._showLinkForm=!1,this._newLinkLabel=``,this._newLinkUrl=``,this._newLinkDescription=``,this._addingLink=!1,this._showItemMenuId=null,this._addingToNavigationId=null,this._createdCollectionId=null}update(e){(!this.#t||e.has(`items`))&&(this._items=[...this.items??[]],this.#t=!0),super.update(e)}disconnectedCallback(){super.disconnectedCallback(),this.#e?.destroy(),this.#e=null,this.#r?.removeEventListener(`click`,this.#c),this.#r=null,this.#i?.destroy(),this.#i=null,this.#a?.destroy(),this.#a=null,document.removeEventListener(`click`,this.#o),document.removeEventListener(`click`,this.#s)}#d(){return this._items.some(e=>e.type===`collection`&&e.collection||e.type===`smart_collection`&&e.smartCollection||e.type===`link`&&e.label&&e.url)}#f(e){return`${e} ${e===1?this.labels.threadSingular:this.labels.threadPlural}`}#p(){let e=this.closest(`[data-collections-manager-root]`);e!==this.#r&&(this.#r?.removeEventListener(`click`,this.#c),this.#r=e,this.#r?.addEventListener(`click`,this.#c))}#m(e){return this.#r?.querySelector(e)??null}#h(){let e=this.#m(`[data-collections-action="done"]`);e&&(e.hidden=!this._reorderMode);let t=this.#m(`[data-collections-reorder-actions]`);t&&(t.hidden=!this._reorderMode);let n=this.#m(`[data-collections-toolbar]`);n&&(n.hidden=this._reorderMode);let r=this.#m(`[data-collections-hint]`);r&&(r.hidden=!this._reorderMode);let i=this.#m(`[data-collections-more-menu]`);i&&(i.hidden=!this._showMoreMenu||this._reorderMode);let a=this.#m(`[data-collections-action="toggle-menu"]`);a&&a.setAttribute(`aria-expanded`,String(this._showMoreMenu&&!this._reorderMode))}#g(){Y(this._items.flatMap(e=>e.collection?[{id:e.collection.id,slug:e.collection.slug,title:e.collection.title}]:[]))}#_(e){let t=e.collections??[],n=e.directoryItems??[],r=new Map;for(let e of t)r.set(e.id,{id:e.id,slug:e.slug,title:e.title,description:e.description,sortOrder:e.sortOrder,threadCount:e.threadCount??0,recentActivityAt:e.recentActivityAt});let i=e.smartCollections??[],a=new Map;for(let e of i)a.set(e.id,{id:e.id,slug:e.slug,title:e.title,description:e.description,selection:e.selection??{},sortOrder:e.sortOrder,layout:e.layout,threadCount:e.threadCount??0,recentActivityAt:e.recentActivityAt});let o=new Set,s=new Set,c=[];for(let e of n){let t=e.collectionId==null?void 0:r.get(e.collectionId),n=e.smartCollectionId==null?void 0:a.get(e.smartCollectionId);(e.type!==`collection`||t)&&(e.type!==`smart_collection`||n)&&(t&&o.add(t.id),n&&s.add(n.id),c.push({id:e.id,type:e.type,collectionId:e.collectionId,smartCollectionId:e.smartCollectionId,label:e.label,url:e.url,description:e.description,position:e.position,collection:t,smartCollection:n}))}for(let e of t)o.has(e.id)||c.push({id:e.id,type:`collection`,collectionId:e.id,label:null,url:null,position:``,collection:r.get(e.id)});for(let e of i)s.has(e.id)||c.push({id:e.id,type:`smart_collection`,smartCollectionId:e.id,label:null,url:null,position:``,smartCollection:a.get(e.id)});return c}async#v(){try{let e=n(),t=await fetch(e?`/api/collections?lang=${encodeURIComponent(e)}`:`/api/collections`);if(!t.ok)return;let r=await t.json();this._items=this.#_(r)}catch{}}#y(){let e=this.querySelector(`#collections-manager-list`);!e||this.#e||(this.#e=O.create(e,{...de,chosenClass:`collection-directory-chosen`,dragClass:`collection-directory-drag`,ghostClass:`collection-directory-ghost`,handle:`[data-drag-handle]`,scroll:!0,onChoose:()=>{E(e,!0)},onStart:e=>{this.#n=me(e)},onUnchoose:()=>{E(e,!1)},onEnd:t=>{let n=D(e,`[data-directory-item]`,`directoryItem`);w(e,t,this.#n),this.#n=null,E(e,!1),this.#e?.destroy(),this.#e=null;let{movedId:r,afterId:i,beforeId:a}=pe(n,t.newIndex);if(!r)return;let o=new Map(this._items.map(e=>[e.id,e]));this._items=n.map(e=>o.get(e)).filter(e=>e!==void 0),fetch(`/api/collections/directory-items/${r}/move`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({after:i??null,before:a??null})}).then(e=>{e.ok?l(this.labels.orderSaved):l(this.labels.saveFailed,`error`)})}}))}#b(){this._reorderMode=!0,this._showLinkForm=!1,this._editingLinkId=null,this._showMoreMenu=!1,document.removeEventListener(`click`,this.#o)}#x(){this._reorderMode=!1,this._editingDividerId=null,this.#e?.destroy(),this.#e=null}updated(e){if(this.#p(),this.#h(),this.#g(),this._reorderMode&&this.#y(),this._editingDividerId){let e=this.querySelector(`[data-divider-input-for="${this._editingDividerId}"]`);e&&(e.focus(),e.select(),e.scrollIntoView({block:`nearest`}),this._editingDividerId=null)}if(e.has(`_showLinkForm`)&&this._showLinkForm){let e=this.querySelector(`[data-link-form-input="label"]`);e&&this.ownerDocument.activeElement!==e&&e.focus(),this.#S()}e.has(`_editingLinkId`)&&this._editingLinkId&&this.#C()}#S(){let e=this.querySelector(`[data-new-link-desc-editor]`);!e||this.#i||(this.#i=A({element:e,placeholder:this.labels.linkDescriptionPlaceholder,content:this._newLinkDescription||void 0,onUpdate:e=>{this._newLinkDescription=e}}),this._newLinkDescription=k(this.#i.getJSON()))}#C(){let e=this.querySelector(`[data-edit-link-desc-editor]`);!e||this.#a||(this.#a=A({element:e,placeholder:this.labels.linkDescriptionPlaceholder,content:this._editLinkDescription||void 0,onUpdate:e=>{this._editLinkDescription=e}}),this._editLinkDescription=k(this.#a.getJSON()))}async#w(){this._showMoreMenu=!1,document.removeEventListener(`click`,this.#o);try{let e=await fetch(`/api/collections/directory-items`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({type:`divider`})});if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();this._reorderMode=!0,await this.#v(),this._editingDividerId=t.id}catch{l(this.labels.saveFailed,`error`)}}#T(){this._showMoreMenu=!1,this._showLinkForm=!0,this._newLinkLabel=``,this._newLinkUrl=``,this._newLinkDescription=``,this.#i?.destroy(),this.#i=null,document.removeEventListener(`click`,this.#o)}async#E(){let e=this._newLinkLabel.trim(),t=this._newLinkUrl.trim();if(!e||!t){l(this.labels.labelAndUrlRequired,`error`);return}this._addingLink=!0;try{let n=this._newLinkDescription.trim()||null,r=await fetch(`/api/collections/directory-items`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({type:`link`,label:e,url:t,description:n})});if(!r.ok)throw Error(`HTTP ${r.status}`);this._showLinkForm=!1,this._newLinkLabel=``,this._newLinkUrl=``,this._newLinkDescription=``,this.#i?.destroy(),this.#i=null,l(this.labels.linkCreated),await this.#v()}catch{l(this.labels.saveFailed,`error`)}finally{this._addingLink=!1}}async#D(e){try{let t=await fetch(`/api/collections/directory-items/${e}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);this._items=this._items.filter(t=>t.id!==e)}catch{l(this.labels.saveFailed,`error`)}}async#O(e,t){let n=t.trim();if(n!==(this._items.find(t=>t.id===e)?.label??``))try{let t=await fetch(`/api/collections/directory-items/${e}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({label:n||null})});if(!t.ok)throw Error(`HTTP ${t.status}`);let r=await t.json();this._items=this._items.map(t=>t.id===e?{...t,label:r.label??null}:t)}catch{l(this.labels.saveFailed,`error`),await this.#v()}}async#k(e){if(await h({message:this.labels.confirmDelete,confirmLabel:this.labels.deleteCollection,cancelLabel:this.labels.cancel,tone:`danger`})){this._showItemMenuId=null,document.removeEventListener(`click`,this.#s);try{let t=await fetch(`/api/collections/${e.id}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);l(this.labels.deleted),await this.#v()}catch{l(this.labels.saveFailed,`error`)}}}async#A(e,t){if(!e||this._addingToNavigationId)return;let n=this._createdCollectionId===e;this._showItemMenuId=null,this._addingToNavigationId=e,document.removeEventListener(`click`,this.#s);try{await t(e),this.navigationCollectionIds=[...new Set([...this.navigationCollectionIds,e])],n||r(this.labels.addedToNavigation,{label:this.labels.editNavigation,href:a(C)})}catch{l(this.labels.addToNavigationFailed,`error`)}finally{this._addingToNavigationId=null}}#j(e){if(e.type===`link`){if(this._editingLinkId===e.id){this._editingLinkId=null,this._editLinkLabel=``,this._editLinkUrl=``,this._editLinkDescription=``,this.#a?.destroy(),this.#a=null;return}this._editingLinkId=e.id,this._editLinkLabel=e.label??``,this._editLinkUrl=e.url??``,this._editLinkDescription=e.description??``,this.#a?.destroy(),this.#a=null}}async#M(e){let t=this._editLinkLabel.trim(),n=this._editLinkUrl.trim();if(!t||!n){l(this.labels.labelAndUrlRequired,`error`);return}try{let r=this._editLinkDescription.trim()||null,i=await fetch(`/api/collections/directory-items/${e.id}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({label:t,url:n,description:r})});if(!i.ok)throw Error(`HTTP ${i.status}`);let a=await i.json();this._items=this._items.map(r=>r.id===e.id?{...r,label:a.label??t,url:a.url??n,description:a.description??null}:r),this._editingLinkId=null,this._editLinkLabel=``,this._editLinkUrl=``,this._editLinkDescription=``,this.#a?.destroy(),this.#a=null,l(this.labels.linkSaved)}catch{l(this.labels.saveFailed,`error`),await this.#v()}}async#N(e){if(await h({message:this.labels.confirmDeleteLink,confirmLabel:this.labels.deleteLink,cancelLabel:this.labels.cancel,tone:`danger`})){this._showItemMenuId=null,document.removeEventListener(`click`,this.#s);try{let t=await fetch(`/api/collections/directory-items/${e.id}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);this._editingLinkId=null,this._editLinkLabel=``,this._editLinkUrl=``,this._editLinkDescription=``,this.#a?.destroy(),this.#a=null,l(this.labels.linkDeleted),this._items=this._items.filter(t=>t.id!==e.id)}catch{l(this.labels.saveFailed,`error`)}}}#P(){let e=e=>e.type===`collection`&&e.collection||e.type===`smart_collection`&&e.smartCollection||e.type===`link`&&e.label&&e.url,t=[],n=!1,r=0;for(let i of this._items)i.type===`divider`?(n=!0,t.push(0)):e(i)&&(n?t[t.length-1]+=1:r+=1);let i=t.length>0,a=Math.max(0,t.length-1),o=i?Math.max(1,a.toString(36).length):0,s=Math.max(2,String(Math.max(0,r-1)).length),c=[],l=-1,u=0;for(let t of this._items)if(t.type===`divider`)l+=1,u=0,c.push(``);else if(e(t)){if(i){let e=Math.max(0,l).toString(36).padStart(o,`0`),t=u.toString(36);c.push(e+t)}else c.push(String(u).padStart(s,`0`));u+=1}else c.push(``);return c}#F(e,t){let n=e.collection;if(!n)return s;let r=u(se(n.slug)),i=o`
1566
+ `}};customElements.get(`jant-smart-collection-dialog`)||customElements.define(`jant-smart-collection-dialog`,mt);var ht=`data-smart-collection-dialog-labels`,X=null,Z=null,gt=null;function _t(){if(X)return X;let e=document.querySelector(`[${ht}]`)?.getAttribute(ht);if(!e)return null;try{return X=JSON.parse(e),X}catch{return null}}async function vt(e){gt??=yt();let t=await gt;Y(t);for(let n of t)e.values[`collection.${n.slug}`]=n.title}async function yt(){try{let e=await fetch(a(`/api/collections`));return e.ok?(await e.json()).collections??[]:[]}catch{return[]}}function bt(e){return Z?.isConnected?(Z.labels=e,Z):(Z=document.createElement(`jant-smart-collection-dialog`),Z.labels=e,document.body.appendChild(Z),Z)}async function Q(e){let t=_t();return t?(await vt(t),bt(t).open(e)):!1}var xt=class extends u{static properties={items:{type:Array},labels:{type:Object},navigationCollectionIds:{type:Array,attribute:`navigation-collection-ids`},_items:{state:!0},_reorderMode:{state:!0},_editingDividerId:{state:!0},_editingLinkId:{state:!0},_editLinkLabel:{state:!0},_editLinkUrl:{state:!0},_editLinkDescription:{state:!0},_showMoreMenu:{state:!0},_showLinkForm:{state:!0},_newLinkLabel:{state:!0},_newLinkUrl:{state:!0},_newLinkDescription:{state:!0},_addingLink:{state:!0},_showItemMenuId:{state:!0},_addingToNavigationId:{state:!0},_createdCollectionId:{state:!0}};#e=null;#t=!1;#n=null;#r=null;#i=null;#a=null;#o=()=>{this._showMoreMenu=!1,document.removeEventListener(`click`,this.#o)};#s=()=>{this._showItemMenuId=null,document.removeEventListener(`click`,this.#s)};#c=e=>{let t=e.target;if(!t)return;t.closest(`[data-collections-more-menu]`)&&e.stopPropagation();let n=t.closest(`[data-collections-action]`);if(!n||!this.#r?.contains(n))return;let r=n.dataset.collectionsAction;if(r)switch(e.preventDefault(),e.stopPropagation(),r!==`toggle-menu`&&this._showMoreMenu&&(this._showMoreMenu=!1,document.removeEventListener(`click`,this.#o)),r){case`done`:this.#x();break;case`toggle-menu`:this._showMoreMenu=!this._showMoreMenu,this._showMoreMenu?setTimeout(()=>{document.addEventListener(`click`,this.#o)}):document.removeEventListener(`click`,this.#o);break;case`organize`:this.#b();break;case`divider`:this.#w();break;case`link`:this.#T();break;case`collection`:this.#l();break;case`smart-collection`:Q({}).then(e=>{e&&this.#v()})}};createRenderRoot(){return this.innerHTML=``,this}connectedCallback(){super.connectedCallback(),this.#p()}async#l(){let e=await R();e.changed&&(await this.#v(),e.collection&&(this._createdCollectionId=e.collection.id))}async#u(e){this._showItemMenuId=null,document.removeEventListener(`click`,this.#s);let{changed:t}=await R({collectionId:e});t&&await this.#v()}constructor(){super(),this.items=[],this.labels={},this.navigationCollectionIds=[],this._items=[],this._reorderMode=!1,this._editingDividerId=null,this._editingLinkId=null,this._editLinkLabel=``,this._editLinkUrl=``,this._editLinkDescription=``,this._showMoreMenu=!1,this._showLinkForm=!1,this._newLinkLabel=``,this._newLinkUrl=``,this._newLinkDescription=``,this._addingLink=!1,this._showItemMenuId=null,this._addingToNavigationId=null,this._createdCollectionId=null}update(e){(!this.#t||e.has(`items`))&&(this._items=[...this.items??[]],this.#t=!0),super.update(e)}disconnectedCallback(){super.disconnectedCallback(),this.#e?.destroy(),this.#e=null,this.#r?.removeEventListener(`click`,this.#c),this.#r=null,this.#i?.destroy(),this.#i=null,this.#a?.destroy(),this.#a=null,document.removeEventListener(`click`,this.#o),document.removeEventListener(`click`,this.#s)}#d(){return this._items.some(e=>e.type===`collection`&&e.collection||e.type===`smart_collection`&&e.smartCollection||e.type===`link`&&e.label&&e.url)}#f(e){return`${e} ${e===1?this.labels.threadSingular:this.labels.threadPlural}`}#p(){let e=this.closest(`[data-collections-manager-root]`);e!==this.#r&&(this.#r?.removeEventListener(`click`,this.#c),this.#r=e,this.#r?.addEventListener(`click`,this.#c))}#m(e){return this.#r?.querySelector(e)??null}#h(){let e=this.#m(`[data-collections-action="done"]`);e&&(e.hidden=!this._reorderMode);let t=this.#m(`[data-collections-reorder-actions]`);t&&(t.hidden=!this._reorderMode);let n=this.#m(`[data-collections-toolbar]`);n&&(n.hidden=this._reorderMode);let r=this.#m(`[data-collections-hint]`);r&&(r.hidden=!this._reorderMode);let i=this.#m(`[data-collections-more-menu]`);i&&(i.hidden=!this._showMoreMenu||this._reorderMode);let a=this.#m(`[data-collections-action="toggle-menu"]`);a&&a.setAttribute(`aria-expanded`,String(this._showMoreMenu&&!this._reorderMode))}#g(){Y(this._items.flatMap(e=>e.collection?[{id:e.collection.id,slug:e.collection.slug,title:e.collection.title}]:[]))}#_(e){let t=e.collections??[],n=e.directoryItems??[],r=new Map;for(let e of t)r.set(e.id,{id:e.id,slug:e.slug,title:e.title,description:e.description,sortOrder:e.sortOrder,threadCount:e.threadCount??0,recentActivityAt:e.recentActivityAt});let i=e.smartCollections??[],a=new Map;for(let e of i)a.set(e.id,{id:e.id,slug:e.slug,title:e.title,description:e.description,selection:e.selection??{},sortOrder:e.sortOrder,layout:e.layout,threadCount:e.threadCount??0,recentActivityAt:e.recentActivityAt});let o=new Set,s=new Set,c=[];for(let e of n){let t=e.collectionId==null?void 0:r.get(e.collectionId),n=e.smartCollectionId==null?void 0:a.get(e.smartCollectionId);(e.type!==`collection`||t)&&(e.type!==`smart_collection`||n)&&(t&&o.add(t.id),n&&s.add(n.id),c.push({id:e.id,type:e.type,collectionId:e.collectionId,smartCollectionId:e.smartCollectionId,label:e.label,url:e.url,description:e.description,position:e.position,collection:t,smartCollection:n}))}for(let e of t)o.has(e.id)||c.push({id:e.id,type:`collection`,collectionId:e.id,label:null,url:null,position:``,collection:r.get(e.id)});for(let e of i)s.has(e.id)||c.push({id:e.id,type:`smart_collection`,smartCollectionId:e.id,label:null,url:null,position:``,smartCollection:a.get(e.id)});return c}async#v(){try{let t=e(),n=await fetch(t?`/api/collections?lang=${encodeURIComponent(t)}`:`/api/collections`);if(!n.ok)return;let r=await n.json();this._items=this.#_(r)}catch{}}#y(){let e=this.querySelector(`#collections-manager-list`);!e||this.#e||(this.#e=A.create(e,{...le,chosenClass:`collection-directory-chosen`,dragClass:`collection-directory-drag`,ghostClass:`collection-directory-ghost`,handle:`[data-drag-handle]`,scroll:!0,onChoose:()=>{O(e,!0)},onStart:e=>{this.#n=fe(e)},onUnchoose:()=>{O(e,!1)},onEnd:t=>{let n=k(e,`[data-directory-item]`,`directoryItem`);E(e,t,this.#n),this.#n=null,O(e,!1),this.#e?.destroy(),this.#e=null;let{movedId:r,afterId:i,beforeId:a}=de(n,t.newIndex);if(!r)return;let o=new Map(this._items.map(e=>[e.id,e]));this._items=n.map(e=>o.get(e)).filter(e=>e!==void 0),fetch(`/api/collections/directory-items/${r}/move`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({after:i??null,before:a??null})}).then(e=>{e.ok?d(this.labels.orderSaved):d(this.labels.saveFailed,`error`)})}}))}#b(){this._reorderMode=!0,this._showLinkForm=!1,this._editingLinkId=null,this._showMoreMenu=!1,document.removeEventListener(`click`,this.#o)}#x(){this._reorderMode=!1,this._editingDividerId=null,this.#e?.destroy(),this.#e=null}updated(e){if(this.#p(),this.#h(),this.#g(),this._reorderMode&&this.#y(),this._editingDividerId){let e=this.querySelector(`[data-divider-input-for="${this._editingDividerId}"]`);e&&(e.focus(),e.select(),e.scrollIntoView({block:`nearest`}),this._editingDividerId=null)}if(e.has(`_showLinkForm`)&&this._showLinkForm){let e=this.querySelector(`[data-link-form-input="label"]`);e&&this.ownerDocument.activeElement!==e&&e.focus(),this.#S()}e.has(`_editingLinkId`)&&this._editingLinkId&&this.#C()}#S(){let e=this.querySelector(`[data-new-link-desc-editor]`);!e||this.#i||(this.#i=M({element:e,placeholder:this.labels.linkDescriptionPlaceholder,content:this._newLinkDescription||void 0,onUpdate:e=>{this._newLinkDescription=e}}),this._newLinkDescription=j(this.#i.getJSON()))}#C(){let e=this.querySelector(`[data-edit-link-desc-editor]`);!e||this.#a||(this.#a=M({element:e,placeholder:this.labels.linkDescriptionPlaceholder,content:this._editLinkDescription||void 0,onUpdate:e=>{this._editLinkDescription=e}}),this._editLinkDescription=j(this.#a.getJSON()))}async#w(){this._showMoreMenu=!1,document.removeEventListener(`click`,this.#o);try{let e=await fetch(`/api/collections/directory-items`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({type:`divider`})});if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();this._reorderMode=!0,await this.#v(),this._editingDividerId=t.id}catch{d(this.labels.saveFailed,`error`)}}#T(){this._showMoreMenu=!1,this._showLinkForm=!0,this._newLinkLabel=``,this._newLinkUrl=``,this._newLinkDescription=``,this.#i?.destroy(),this.#i=null,document.removeEventListener(`click`,this.#o)}async#E(){let e=this._newLinkLabel.trim(),t=this._newLinkUrl.trim();if(!e||!t){d(this.labels.labelAndUrlRequired,`error`);return}this._addingLink=!0;try{let n=this._newLinkDescription.trim()||null,r=await fetch(`/api/collections/directory-items`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({type:`link`,label:e,url:t,description:n})});if(!r.ok)throw Error(`HTTP ${r.status}`);this._showLinkForm=!1,this._newLinkLabel=``,this._newLinkUrl=``,this._newLinkDescription=``,this.#i?.destroy(),this.#i=null,d(this.labels.linkCreated),await this.#v()}catch{d(this.labels.saveFailed,`error`)}finally{this._addingLink=!1}}async#D(e){try{let t=await fetch(`/api/collections/directory-items/${e}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);this._items=this._items.filter(t=>t.id!==e)}catch{d(this.labels.saveFailed,`error`)}}async#O(e,t){let n=t.trim();if(n!==(this._items.find(t=>t.id===e)?.label??``))try{let t=await fetch(`/api/collections/directory-items/${e}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({label:n||null})});if(!t.ok)throw Error(`HTTP ${t.status}`);let r=await t.json();this._items=this._items.map(t=>t.id===e?{...t,label:r.label??null}:t)}catch{d(this.labels.saveFailed,`error`),await this.#v()}}async#k(e){if(await h({message:this.labels.confirmDelete,confirmLabel:this.labels.deleteCollection,cancelLabel:this.labels.cancel,tone:`danger`})){this._showItemMenuId=null,document.removeEventListener(`click`,this.#s);try{let t=await fetch(`/api/collections/${e.id}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);d(this.labels.deleted),await this.#v()}catch{d(this.labels.saveFailed,`error`)}}}async#A(e,t){if(!e||this._addingToNavigationId)return;let n=this._createdCollectionId===e;this._showItemMenuId=null,this._addingToNavigationId=e,document.removeEventListener(`click`,this.#s);try{await t(e),this.navigationCollectionIds=[...new Set([...this.navigationCollectionIds,e])],n||s(this.labels.addedToNavigation,{label:this.labels.editNavigation,href:a(T)})}catch{d(this.labels.addToNavigationFailed,`error`)}finally{this._addingToNavigationId=null}}#j(e){if(e.type===`link`){if(this._editingLinkId===e.id){this._editingLinkId=null,this._editLinkLabel=``,this._editLinkUrl=``,this._editLinkDescription=``,this.#a?.destroy(),this.#a=null;return}this._editingLinkId=e.id,this._editLinkLabel=e.label??``,this._editLinkUrl=e.url??``,this._editLinkDescription=e.description??``,this.#a?.destroy(),this.#a=null}}async#M(e){let t=this._editLinkLabel.trim(),n=this._editLinkUrl.trim();if(!t||!n){d(this.labels.labelAndUrlRequired,`error`);return}try{let r=this._editLinkDescription.trim()||null,i=await fetch(`/api/collections/directory-items/${e.id}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({label:t,url:n,description:r})});if(!i.ok)throw Error(`HTTP ${i.status}`);let a=await i.json();this._items=this._items.map(r=>r.id===e.id?{...r,label:a.label??t,url:a.url??n,description:a.description??null}:r),this._editingLinkId=null,this._editLinkLabel=``,this._editLinkUrl=``,this._editLinkDescription=``,this.#a?.destroy(),this.#a=null,d(this.labels.linkSaved)}catch{d(this.labels.saveFailed,`error`),await this.#v()}}async#N(e){if(await h({message:this.labels.confirmDeleteLink,confirmLabel:this.labels.deleteLink,cancelLabel:this.labels.cancel,tone:`danger`})){this._showItemMenuId=null,document.removeEventListener(`click`,this.#s);try{let t=await fetch(`/api/collections/directory-items/${e.id}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);this._editingLinkId=null,this._editLinkLabel=``,this._editLinkUrl=``,this._editLinkDescription=``,this.#a?.destroy(),this.#a=null,d(this.labels.linkDeleted),this._items=this._items.filter(t=>t.id!==e.id)}catch{d(this.labels.saveFailed,`error`)}}}#P(){let e=e=>e.type===`collection`&&e.collection||e.type===`smart_collection`&&e.smartCollection||e.type===`link`&&e.label&&e.url,t=[],n=!1,r=0;for(let i of this._items)i.type===`divider`?(n=!0,t.push(0)):e(i)&&(n?t[t.length-1]+=1:r+=1);let i=t.length>0,a=Math.max(0,t.length-1),o=i?Math.max(1,a.toString(36).length):0,s=Math.max(2,String(Math.max(0,r-1)).length),c=[],l=-1,u=0;for(let t of this._items)if(t.type===`divider`)l+=1,u=0,c.push(``);else if(e(t)){if(i){let e=Math.max(0,l).toString(36).padStart(o,`0`),t=u.toString(36);c.push(e+t)}else c.push(String(u).padStart(s,`0`));u+=1}else c.push(``);return c}#F(e,t){let n=e.collection;if(!n)return l;let i=r(oe(n.slug)),a=c`
1567
1567
  <div class="collection-directory-main">
1568
1568
  <span class="collection-directory-sequence" aria-hidden="true">
1569
1569
  ${t}
1570
1570
  </span>
1571
1571
  <div class="collection-directory-title-row">
1572
- <a href=${r} class="collection-directory-title-link">
1572
+ <a href=${i} class="collection-directory-title-link">
1573
1573
  <span class="collection-directory-title">${n.title}</span>
1574
1574
  </a>
1575
1575
  </div>
1576
- ${n.description?o`
1576
+ ${n.description?c`
1577
1577
  <div class="collection-directory-description prose">
1578
- ${f(H(n.description,{namespace:n.id}))}
1578
+ ${f(U(n.description,{namespace:n.id}))}
1579
1579
  </div>
1580
- `:s}
1580
+ `:l}
1581
1581
  <p class="collection-directory-summary">
1582
1582
  <span class="collection-directory-meta"
1583
1583
  >${this.#f(n.threadCount)}</span
@@ -1587,13 +1587,13 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1587
1587
  >
1588
1588
  <time
1589
1589
  class="collection-directory-updated"
1590
- datetime=${U(n.recentActivityAt)}
1590
+ datetime=${Te(n.recentActivityAt)}
1591
1591
  >
1592
1592
  ${De(n.recentActivityAt)}
1593
1593
  </time>
1594
1594
  </p>
1595
1595
  </div>
1596
- `;return this._reorderMode?o`
1596
+ `;return this._reorderMode?c`
1597
1597
  <div
1598
1598
  data-directory-item=${e.id}
1599
1599
  class="collection-directory-item collection-directory-item-reorder"
@@ -1618,26 +1618,26 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1618
1618
  <circle cx="15" cy="19" r="1" />
1619
1619
  </svg>
1620
1620
  </div>
1621
- <div class="collection-directory-reorder-main">${i}</div>
1621
+ <div class="collection-directory-reorder-main">${a}</div>
1622
1622
  </div>
1623
- `:o`
1623
+ `:c`
1624
1624
  <div
1625
- class=${_({"group relative":!0,"collection-directory-managed-row":!0,"z-50":this._showItemMenuId===e.id||this._editingLinkId===e.id})}
1625
+ class=${x({"group relative":!0,"collection-directory-managed-row":!0,"z-50":this._showItemMenuId===e.id||this._editingLinkId===e.id})}
1626
1626
  >
1627
1627
  <div
1628
1628
  class="collection-directory-item collection-directory-item-manageable"
1629
1629
  >
1630
- ${i}
1630
+ ${a}
1631
1631
  </div>
1632
1632
  ${this.#B(e)}
1633
1633
  </div>
1634
- `}#I(e,t){let n=e.smartCollection;if(!n)return s;let r=u(S(n.slug)),i=o`
1634
+ `}#I(e,t){let n=e.smartCollection;if(!n)return l;let i=r(w(n.slug)),o=c`
1635
1635
  <div class="collection-directory-main">
1636
1636
  <span class="collection-directory-sequence" aria-hidden="true"
1637
1637
  >${t}</span
1638
1638
  >
1639
1639
  <div class="collection-directory-title-row">
1640
- <a href=${a(r)} class="collection-directory-title-link">
1640
+ <a href=${a(i)} class="collection-directory-title-link">
1641
1641
  <span class="collection-directory-title"
1642
1642
  >${n.title}
1643
1643
  <span
@@ -1645,16 +1645,16 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1645
1645
  role="img"
1646
1646
  aria-label=${this.labels.smartCollectionNoun}
1647
1647
  title=${this.labels.smartCollectionNoun}
1648
- >${f(M)}</span
1648
+ >${f(P)}</span
1649
1649
  ></span
1650
1650
  >
1651
1651
  </a>
1652
1652
  </div>
1653
- ${n.description?o`
1653
+ ${n.description?c`
1654
1654
  <div class="collection-directory-description prose">
1655
- ${f(H(n.description,{namespace:n.id}))}
1655
+ ${f(U(n.description,{namespace:n.id}))}
1656
1656
  </div>
1657
- `:s}
1657
+ `:l}
1658
1658
  <p class="collection-directory-summary">
1659
1659
  <span class="collection-directory-meta"
1660
1660
  >${this.#f(n.threadCount)}</span
@@ -1664,13 +1664,13 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1664
1664
  >
1665
1665
  <time
1666
1666
  class="collection-directory-updated"
1667
- datetime=${U(n.recentActivityAt)}
1667
+ datetime=${Te(n.recentActivityAt)}
1668
1668
  >
1669
1669
  ${De(n.recentActivityAt)}
1670
1670
  </time>
1671
1671
  </p>
1672
1672
  </div>
1673
- `;return this._reorderMode?o`
1673
+ `;return this._reorderMode?c`
1674
1674
  <div
1675
1675
  data-directory-item=${e.id}
1676
1676
  class="collection-directory-item collection-directory-item-reorder"
@@ -1695,20 +1695,20 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1695
1695
  <circle cx="15" cy="19" r="1" />
1696
1696
  </svg>
1697
1697
  </div>
1698
- <div class="collection-directory-reorder-main">${i}</div>
1698
+ <div class="collection-directory-reorder-main">${o}</div>
1699
1699
  </div>
1700
- `:o`
1700
+ `:c`
1701
1701
  <div
1702
- class=${_({"group relative":!0,"collection-directory-managed-row":!0,"z-50":this._showItemMenuId===e.id})}
1702
+ class=${x({"group relative":!0,"collection-directory-managed-row":!0,"z-50":this._showItemMenuId===e.id})}
1703
1703
  >
1704
1704
  <div
1705
1705
  class="collection-directory-item collection-directory-item-manageable"
1706
1706
  >
1707
- ${i}
1707
+ ${o}
1708
1708
  </div>
1709
1709
  ${this.#B(e)}
1710
1710
  </div>
1711
- `}async#L(e){if(this._showItemMenuId=null,document.removeEventListener(`click`,this.#s),await h({message:this.labels.confirmDeleteSmartCollection,confirmLabel:this.labels.deleteSmartCollection,cancelLabel:this.labels.cancel,tone:`danger`}))try{let t=await fetch(`/api/smart-collections/${e.id}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);l(this.labels.smartCollectionDeleted),await this.#v()}catch{l(this.labels.saveFailed,`error`)}}#R(e){return this._editingLinkId===e.id?o`
1711
+ `}async#L(e){if(this._showItemMenuId=null,document.removeEventListener(`click`,this.#s),await h({message:this.labels.confirmDeleteSmartCollection,confirmLabel:this.labels.deleteSmartCollection,cancelLabel:this.labels.cancel,tone:`danger`}))try{let t=await fetch(`/api/smart-collections/${e.id}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);d(this.labels.smartCollectionDeleted),await this.#v()}catch{d(this.labels.saveFailed,`error`)}}#R(e){return this._editingLinkId===e.id?c`
1712
1712
  <div
1713
1713
  class="collections-link-edit card"
1714
1714
  @click=${e=>e.stopPropagation()}
@@ -1760,7 +1760,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1760
1760
  </div>
1761
1761
  </form>
1762
1762
  </div>
1763
- `:s}#z(e,t){if(!e.label||!e.url)return s;let n=a(e.url),r=e.url.startsWith(`http://`)||e.url.startsWith(`https://`),i=o`
1763
+ `:l}#z(e,t){if(!e.label||!e.url)return l;let n=a(e.url),r=e.url.startsWith(`http://`)||e.url.startsWith(`https://`),i=c`
1764
1764
  <div class="collection-directory-main">
1765
1765
  <span class="collection-directory-sequence" aria-hidden="true">
1766
1766
  ${t}
@@ -1769,8 +1769,8 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1769
1769
  <a
1770
1770
  href=${n}
1771
1771
  class="collection-directory-title-link"
1772
- target=${r?`_blank`:s}
1773
- rel=${r?`noopener noreferrer`:s}
1772
+ target=${r?`_blank`:l}
1773
+ rel=${r?`noopener noreferrer`:l}
1774
1774
  >
1775
1775
  <span class="collection-directory-title">
1776
1776
  ${e.label}
@@ -1800,11 +1800,11 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1800
1800
  </span>
1801
1801
  </a>
1802
1802
  </div>
1803
- ${e.description?o`
1803
+ ${e.description?c`
1804
1804
  <div class="collection-directory-description prose">
1805
- ${f(H(e.description,{namespace:e.id}))}
1805
+ ${f(U(e.description,{namespace:e.id}))}
1806
1806
  </div>
1807
- `:o`
1807
+ `:c`
1808
1808
  <p class="collection-directory-summary">
1809
1809
  <span class="collection-directory-meta"
1810
1810
  >${this.labels.linkDescriptionPlaceholder}</span
@@ -1812,7 +1812,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1812
1812
  </p>
1813
1813
  `}
1814
1814
  </div>
1815
- `;return this._reorderMode?o`
1815
+ `;return this._reorderMode?c`
1816
1816
  <div
1817
1817
  data-directory-item=${e.id}
1818
1818
  class="collection-directory-item collection-directory-item-reorder"
@@ -1839,9 +1839,9 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1839
1839
  </div>
1840
1840
  <div class="collection-directory-reorder-main">${i}</div>
1841
1841
  </div>
1842
- `:o`
1842
+ `:c`
1843
1843
  <div
1844
- class=${_({"group relative":!0,"collection-directory-managed-row":!0,"z-50":this._showItemMenuId===e.id||this._editingLinkId===e.id})}
1844
+ class=${x({"group relative":!0,"collection-directory-managed-row":!0,"z-50":this._showItemMenuId===e.id||this._editingLinkId===e.id})}
1845
1845
  >
1846
1846
  <div
1847
1847
  class="collection-directory-item collection-directory-item-link collection-directory-item-manageable"
@@ -1850,7 +1850,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1850
1850
  </div>
1851
1851
  ${this.#B(e)} ${this.#R(e)}
1852
1852
  </div>
1853
- `}#B(e){let t=e.collection,n=e.smartCollection,r=e.type===`link`&&!!e.label&&!!e.url;if(!t&&!n&&!r)return s;let i=this._showItemMenuId===e.id;return o`
1853
+ `}#B(e){let t=e.collection,n=e.smartCollection,r=e.type===`link`&&!!e.label&&!!e.url;if(!t&&!n&&!r)return l;let i=this._showItemMenuId===e.id;return c`
1854
1854
  <div class="collection-directory-item-menu">
1855
1855
  <button
1856
1856
  type="button"
@@ -1870,12 +1870,12 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1870
1870
  <circle cx="19" cy="12" r="2" />
1871
1871
  </svg>
1872
1872
  </button>
1873
- ${i?o`
1873
+ ${i?c`
1874
1874
  <div
1875
1875
  class="collections-page-menu"
1876
1876
  @click=${e=>e.stopPropagation()}
1877
1877
  >
1878
- ${n?o`
1878
+ ${n?c`
1879
1879
  <!-- Opens the dialog, not an editor page: creating and
1880
1880
  editing a smart collection are one surface. There is
1881
1881
  deliberately no "Remove from Collections" — a
@@ -1889,19 +1889,19 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1889
1889
  >
1890
1890
  ${this.labels.edit}
1891
1891
  </button>
1892
- ${this.navigationCollectionIds.includes(n.id)?o`
1892
+ ${this.navigationCollectionIds.includes(n.id)?c`
1893
1893
  <a
1894
- href=${a(C)}
1894
+ href=${a(T)}
1895
1895
  class="collections-page-menu-item"
1896
1896
  >
1897
1897
  ${this.labels.editNavigation}
1898
1898
  </a>
1899
- `:o`
1899
+ `:c`
1900
1900
  <button
1901
1901
  type="button"
1902
1902
  class="collections-page-menu-item"
1903
1903
  ?disabled=${this._addingToNavigationId===n.id}
1904
- @click=${()=>void this.#A(n.id,V)}
1904
+ @click=${()=>void this.#A(n.id,Se)}
1905
1905
  >
1906
1906
  ${this._addingToNavigationId===n.id?this.labels.addingToNavigation:this.labels.addToNavigation}
1907
1907
  </button>
@@ -1913,7 +1913,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1913
1913
  >
1914
1914
  ${this.labels.deleteSmartCollection}
1915
1915
  </button>
1916
- `:t?o`
1916
+ `:t?c`
1917
1917
  <button
1918
1918
  type="button"
1919
1919
  class="collections-page-menu-item"
@@ -1921,19 +1921,19 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1921
1921
  >
1922
1922
  ${this.labels.edit}
1923
1923
  </button>
1924
- ${this.navigationCollectionIds.includes(t.id)?o`
1924
+ ${this.navigationCollectionIds.includes(t.id)?c`
1925
1925
  <a
1926
- href=${a(C)}
1926
+ href=${a(T)}
1927
1927
  class="collections-page-menu-item"
1928
1928
  >
1929
1929
  ${this.labels.editNavigation}
1930
1930
  </a>
1931
- `:o`
1931
+ `:c`
1932
1932
  <button
1933
1933
  type="button"
1934
1934
  class="collections-page-menu-item"
1935
1935
  ?disabled=${this._addingToNavigationId===t.id}
1936
- @click=${()=>void this.#A(t.id,B)}
1936
+ @click=${()=>void this.#A(t.id,H)}
1937
1937
  >
1938
1938
  ${this._addingToNavigationId===t.id?this.labels.addingToNavigation:this.labels.addToNavigation}
1939
1939
  </button>
@@ -1945,7 +1945,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1945
1945
  >
1946
1946
  ${this.labels.deleteCollection}
1947
1947
  </button>
1948
- `:o`
1948
+ `:c`
1949
1949
  <button
1950
1950
  type="button"
1951
1951
  class="collections-page-menu-item"
@@ -1962,9 +1962,9 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
1962
1962
  </button>
1963
1963
  `}
1964
1964
  </div>
1965
- `:s}
1965
+ `:l}
1966
1966
  </div>
1967
- `}#V(e,t){if(this._reorderMode)return o`
1967
+ `}#V(e,t){if(this._reorderMode)return c`
1968
1968
  <div
1969
1969
  data-directory-item=${e.id}
1970
1970
  class="collection-directory-divider-row"
@@ -2025,30 +2025,30 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
2025
2025
  </svg>
2026
2026
  </button>
2027
2027
  </div>
2028
- `;let n=!!e.label,r=we(this._items,t);return o`
2028
+ `;let n=!!e.label,i=Ce(this._items,t);return c`
2029
2029
  <div class="collection-directory-divider">
2030
2030
  <div
2031
2031
  class="collection-directory-divider-row"
2032
- aria-hidden=${n?s:`true`}
2032
+ aria-hidden=${n?l:`true`}
2033
2033
  >
2034
- ${n?o`
2035
- ${r?o`
2034
+ ${n?c`
2035
+ ${i?c`
2036
2036
  <a
2037
- href=${u(se(r.slugExpression))}
2037
+ href=${r(oe(i.slugExpression))}
2038
2038
  class="collection-directory-divider-link collection-directory-divider-text"
2039
2039
  >
2040
2040
  ${e.label}
2041
2041
  </a>
2042
- `:o`
2042
+ `:c`
2043
2043
  <span class="collection-directory-divider-text">
2044
2044
  ${e.label}
2045
2045
  </span>
2046
2046
  `}
2047
2047
  <hr class="collection-directory-divider-line" />
2048
- `:o`<hr class="collection-directory-divider-line" />`}
2048
+ `:c`<hr class="collection-directory-divider-line" />`}
2049
2049
  </div>
2050
2050
  </div>
2051
- `}#H(){return this._showLinkForm?o`
2051
+ `}#H(){return this._showLinkForm?c`
2052
2052
  <div class="collections-link-create card">
2053
2053
  <form
2054
2054
  class="grid gap-4"
@@ -2105,7 +2105,7 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
2105
2105
  </div>
2106
2106
  </form>
2107
2107
  </div>
2108
- `:s}#U(){if(!this._createdCollectionId)return s;let e=this._items.find(e=>e.collection?.id===this._createdCollectionId)?.collection;if(!e)return s;let t=this.navigationCollectionIds.includes(e.id);return o`
2108
+ `:l}#U(){if(!this._createdCollectionId)return l;let e=this._items.find(e=>e.collection?.id===this._createdCollectionId)?.collection;if(!e)return l;let t=this.navigationCollectionIds.includes(e.id);return c`
2109
2109
  <section
2110
2110
  class="collection-created-notice"
2111
2111
  role="status"
@@ -2118,19 +2118,19 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
2118
2118
  ${t?this.labels.addedToNavigation:this.labels.formLabels.createdLabel}
2119
2119
  </p>
2120
2120
  <div class="collection-created-notice-actions">
2121
- ${t?o`
2121
+ ${t?c`
2122
2122
  <a
2123
- href=${a(C)}
2123
+ href=${a(T)}
2124
2124
  class="collection-created-notice-action collection-created-notice-action-primary"
2125
2125
  >
2126
2126
  ${this.labels.editNavigation}
2127
2127
  </a>
2128
- `:o`
2128
+ `:c`
2129
2129
  <button
2130
2130
  type="button"
2131
2131
  class="collection-created-notice-action collection-created-notice-action-primary"
2132
2132
  ?disabled=${this._addingToNavigationId===e.id}
2133
- @click=${()=>void this.#A(e.id,B)}
2133
+ @click=${()=>void this.#A(e.id,H)}
2134
2134
  >
2135
2135
  ${this._addingToNavigationId===e.id?this.labels.addingToNavigation:this.labels.addToNavigation}
2136
2136
  </button>
@@ -2160,11 +2160,11 @@ import{S as e,T as t,_ as n,d as r,g as i,h as a,i as o,n as s,t as c,u as l,v a
2160
2160
  </button>
2161
2161
  </div>
2162
2162
  </section>
2163
- `}render(){return o`
2163
+ `}render(){return c`
2164
2164
  ${this.#U()} ${this.#H()}
2165
- ${this.#d()?o`
2165
+ ${this.#d()?c`
2166
2166
  <div id="collections-manager-list" class="collection-directory">
2167
2167
  ${(()=>{let e=this.#P();return this._items.map((t,n)=>t.type===`collection`?this.#F(t,e[n]):t.type===`smart_collection`?this.#I(t,e[n]):t.type===`link`?this.#z(t,e[n]):this.#V(t,n))})()}
2168
2168
  </div>
2169
- `:o`<p class="text-muted-foreground">${this.labels.emptyState}</p>`}
2170
- `}};customElements.define(`jant-collections-manager`,xt);var St=e=>{if(!e)return{edit:``,addToNavigation:``,addingToNavigation:``,addedToNavigation:``,editNavigation:``,addToNavigationFailed:``,moreActions:``,deleteCollection:``,confirmDelete:``,cancel:``,saveFailed:``,deleted:``};try{return JSON.parse(e)}catch{return{edit:``,addToNavigation:``,addingToNavigation:``,addedToNavigation:``,editNavigation:``,addToNavigationFailed:``,moreActions:``,deleteCollection:``,confirmDelete:``,cancel:``,saveFailed:``,deleted:``}}};document.querySelectorAll(`[data-collection-page-actions]`).forEach(e=>{if(e.dataset.collectionPageActionsInitialized===`true`)return;let t=St(e.dataset.collectionPageLabels),n=e.dataset.collectionId,i=e.dataset.collectionPageRedirectUrl||oe(),a=e.querySelector(`[data-collection-page-action='toggle-menu']`),o=e.querySelector(`[data-collection-page-menu]`),s=e.querySelector(`[data-collection-page-action='add-to-navigation']`),c=e.querySelector(`[data-collection-page-edit-navigation]`);if(!n||!a||!o)return;let u=(e=!1)=>{o.hidden||(o.hidden=!0,a.setAttribute(`aria-expanded`,`false`),e&&a.focus())},d=(e=!1)=>{o.hidden=!1,a.setAttribute(`aria-expanded`,`true`),e&&o.querySelector(`[role='menuitem']`)?.focus()},f=async()=>{u(!1);let{changed:e,collection:t}=await I({collectionId:n});if(!e)return;let r=t?.slug?window.location.pathname.replace(/[^/]*$/,t.slug):null;if(r&&r!==window.location.pathname){window.location.href=`${r}${window.location.search}`;return}window.location.reload()},p=async()=>{if(u(!1),await h({message:t.confirmDelete,confirmLabel:t.deleteCollection,cancelLabel:t.cancel,tone:`danger`}))try{let e=await fetch(`/api/collections/${n}`,{method:`DELETE`});if(!e.ok)throw Error(`HTTP ${e.status}`);l(t.deleted),window.location.href=i}catch{l(t.saveFailed,`error`)}},m=async()=>{if(!s||s.disabled)return;u(!1);let i=s.querySelector(`.collections-page-menu-item-label`);s.disabled=!0,i&&(i.textContent=t.addingToNavigation);try{await B(n),s.hidden=!0,c&&(c.hidden=!1),e.dataset.collectionInNavigation=`true`,r(t.addedToNavigation,{label:t.editNavigation,href:c?.getAttribute(`href`)??`/settings/navigation`})}catch{l(t.addToNavigationFailed,`error`)}finally{s.disabled=!1,i&&(i.textContent=t.addToNavigation)}};a.addEventListener(`click`,e=>{if(e.preventDefault(),e.stopPropagation(),o.hidden){d(!1);return}u(!1)}),a.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `||e.key===`ArrowDown`)&&(e.preventDefault(),o.hidden?d(!0):u(!1)),e.key===`Escape`&&(e.preventDefault(),u(!0))}),o.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),u(!0))}),e.addEventListener(`click`,t=>{let n=t.target;if(!n)return;let r=n.closest(`[data-collection-page-action]`);if(!r||!e.contains(r))return;let i=r.dataset.collectionPageAction;i===`edit`&&(t.preventDefault(),f()),i===`delete`&&(t.preventDefault(),p()),i===`add-to-navigation`&&(t.preventDefault(),m())}),document.addEventListener(`click`,t=>{t.target instanceof Node&&(e.contains(t.target)||u(!1))}),e.dataset.collectionPageActionsInitialized=`true`});var Ct=e=>{let t={addToNavigation:``,addingToNavigation:``,addedToNavigation:``,editNavigation:``,addToNavigationFailed:``,confirmDelete:``,deleteCollection:``,cancel:``,saveFailed:``,deleted:``};if(!e)return t;try{return{...t,...JSON.parse(e)}}catch{return t}};document.querySelectorAll(`[data-smart-collection-page-actions]`).forEach(e=>{if(e.dataset.smartCollectionPageActionsInitialized===`true`)return;let t=Ct(e.dataset.collectionPageLabels),n=e.dataset.smartCollectionId,i=e.dataset.collectionPageRedirectUrl||oe(),a=e.querySelector(`[data-collection-page-action='toggle-menu']`),o=e.querySelector(`[data-collection-page-menu]`),s=e.querySelector(`[data-collection-page-action='add-to-navigation']`),c=e.querySelector(`[data-collection-page-edit-navigation]`);if(!n||!a||!o)return;let u=(e=!1)=>{o.hidden||(o.hidden=!0,a.setAttribute(`aria-expanded`,`false`),e&&a.focus())},d=(e=!1)=>{o.hidden=!1,a.setAttribute(`aria-expanded`,`true`),e&&o.querySelector(`[role='menuitem']`)?.focus()},f=async()=>{u(!1),await Q({smartCollectionId:n})&&window.location.reload()},p=async()=>{if(u(!1),await h({message:t.confirmDelete,confirmLabel:t.deleteCollection,cancelLabel:t.cancel,tone:`danger`}))try{let e=await fetch(`/api/smart-collections/${n}`,{method:`DELETE`});if(!e.ok)throw Error(`HTTP ${e.status}`);l(t.deleted),window.location.href=i}catch{l(t.saveFailed,`error`)}},m=async()=>{if(!s||s.disabled)return;u(!1);let i=s.querySelector(`.collections-page-menu-item-label`);s.disabled=!0,i&&(i.textContent=t.addingToNavigation);try{await V(n),s.hidden=!0,c&&(c.hidden=!1),e.dataset.collectionInNavigation=`true`,r(t.addedToNavigation,{label:t.editNavigation,href:c?.getAttribute(`href`)??`/settings/navigation`})}catch{l(t.addToNavigationFailed,`error`)}finally{s.disabled=!1,i&&(i.textContent=t.addToNavigation)}};a.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),o.hidden?d(!1):u(!1)}),a.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `||e.key===`ArrowDown`)&&(e.preventDefault(),o.hidden?d(!0):u(!1)),e.key===`Escape`&&(e.preventDefault(),u(!0))}),o.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),u(!0))}),e.addEventListener(`click`,t=>{let n=t.target?.closest(`[data-collection-page-action]`);if(!n||!e.contains(n))return;let r=n.dataset.collectionPageAction;r===`edit`&&(t.preventDefault(),f()),r===`delete`&&(t.preventDefault(),p()),r===`add-to-navigation`&&(t.preventDefault(),m())}),document.addEventListener(`click`,t=>{t.target instanceof Node&&(e.contains(t.target)||u(!1))}),e.dataset.smartCollectionPageActionsInitialized=`true`});var wt=6,$=8;function Tt(e=document){e.querySelectorAll(`[data-custom-url-actions]`).forEach(e=>{if(e.dataset.customUrlActionsInitialized===`true`)return;let t=e.querySelector(`[data-custom-url-action='toggle-menu']`),n=e.querySelector(`[data-custom-url-menu]`);if(!(t instanceof HTMLButtonElement)||!n)return;let r=typeof n.showPopover==`function`&&n.hasAttribute(`popover`),i=()=>{let e=t.getBoundingClientRect(),{width:r,height:i}=n.getBoundingClientRect(),a=e.bottom+wt,o=e.top-wt-i,s=a+i<=window.innerHeight-$||o<$?a:o;n.style.top=`${s}px`,n.style.left=`${Math.max($,Math.min(e.right-r,window.innerWidth-$-r))}px`},a=(e=!1)=>{n.hidden||(r&&(window.removeEventListener(`resize`,i),window.removeEventListener(`scroll`,i,!0),n.matches(`:popover-open`)&&n.hidePopover()),n.hidden=!0,t.setAttribute(`aria-expanded`,`false`),e&&t.focus())},o=(a=!1)=>{document.dispatchEvent(new CustomEvent(`jant:custom-url-menu`,{detail:{source:e}})),n.hidden=!1,r&&(n.matches(`:popover-open`)||n.showPopover(),i(),window.addEventListener(`resize`,i),window.addEventListener(`scroll`,i,!0)),t.setAttribute(`aria-expanded`,`true`),a&&n.querySelector(`[role='menuitem']`)?.focus()};t.addEventListener(`click`,e=>{if(e.preventDefault(),e.stopPropagation(),n.hidden){o(!1);return}a(!1)}),t.addEventListener(`keydown`,e=>{if(e.key===`Enter`||e.key===` `||e.key===`ArrowDown`){e.preventDefault(),n.hidden?o(!0):a(!1);return}e.key===`Escape`&&(e.preventDefault(),a(!0))}),n.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),a(!0))}),e.addEventListener(`click`,t=>{let n=t.target;if(!n)return;let r=n.closest(`[data-custom-url-action]`);r&&e.contains(r)&&r.dataset.customUrlAction===`delete`&&a(!1)}),document.addEventListener(`click`,e=>{e.target instanceof Node&&(t.contains(e.target)||n.contains(e.target)||a(!1))}),document.addEventListener(`jant:custom-url-menu`,t=>{t.detail?.source!==e&&a(!1)}),e.dataset.customUrlActionsInitialized=`true`})}Tt();
2169
+ `:c`<p class="text-muted-foreground">${this.labels.emptyState}</p>`}
2170
+ `}};customElements.define(`jant-collections-manager`,xt);var St=e=>{if(!e)return{edit:``,addToNavigation:``,addingToNavigation:``,addedToNavigation:``,editNavigation:``,addToNavigationFailed:``,moreActions:``,deleteCollection:``,confirmDelete:``,cancel:``,saveFailed:``,deleted:``};try{return JSON.parse(e)}catch{return{edit:``,addToNavigation:``,addingToNavigation:``,addedToNavigation:``,editNavigation:``,addToNavigationFailed:``,moreActions:``,deleteCollection:``,confirmDelete:``,cancel:``,saveFailed:``,deleted:``}}};document.querySelectorAll(`[data-collection-page-actions]`).forEach(e=>{if(e.dataset.collectionPageActionsInitialized===`true`)return;let t=St(e.dataset.collectionPageLabels),n=e.dataset.collectionId,r=e.dataset.collectionPageRedirectUrl||ae(),i=e.querySelector(`[data-collection-page-action='toggle-menu']`),a=e.querySelector(`[data-collection-page-menu]`),o=e.querySelector(`[data-collection-page-action='add-to-navigation']`),c=e.querySelector(`[data-collection-page-edit-navigation]`);if(!n||!i||!a)return;let l=(e=!1)=>{a.hidden||(a.hidden=!0,i.setAttribute(`aria-expanded`,`false`),e&&i.focus())},u=(e=!1)=>{a.hidden=!1,i.setAttribute(`aria-expanded`,`true`),e&&a.querySelector(`[role='menuitem']`)?.focus()},f=async()=>{l(!1);let{changed:e,collection:t}=await R({collectionId:n});if(!e)return;let r=t?.slug?window.location.pathname.replace(/[^/]*$/,t.slug):null;if(r&&r!==window.location.pathname){window.location.href=`${r}${window.location.search}`;return}window.location.reload()},p=async()=>{if(l(!1),await h({message:t.confirmDelete,confirmLabel:t.deleteCollection,cancelLabel:t.cancel,tone:`danger`}))try{let e=await fetch(`/api/collections/${n}`,{method:`DELETE`});if(!e.ok)throw Error(`HTTP ${e.status}`);d(t.deleted),window.location.href=r}catch{d(t.saveFailed,`error`)}},m=async()=>{if(!o||o.disabled)return;l(!1);let r=o.querySelector(`.collections-page-menu-item-label`);o.disabled=!0,r&&(r.textContent=t.addingToNavigation);try{await H(n),o.hidden=!0,c&&(c.hidden=!1),e.dataset.collectionInNavigation=`true`,s(t.addedToNavigation,{label:t.editNavigation,href:c?.getAttribute(`href`)??`/settings/navigation`})}catch{d(t.addToNavigationFailed,`error`)}finally{o.disabled=!1,r&&(r.textContent=t.addToNavigation)}};i.addEventListener(`click`,e=>{if(e.preventDefault(),e.stopPropagation(),a.hidden){u(!1);return}l(!1)}),i.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `||e.key===`ArrowDown`)&&(e.preventDefault(),a.hidden?u(!0):l(!1)),e.key===`Escape`&&(e.preventDefault(),l(!0))}),a.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),l(!0))}),e.addEventListener(`click`,t=>{let n=t.target;if(!n)return;let r=n.closest(`[data-collection-page-action]`);if(!r||!e.contains(r))return;let i=r.dataset.collectionPageAction;i===`edit`&&(t.preventDefault(),f()),i===`delete`&&(t.preventDefault(),p()),i===`add-to-navigation`&&(t.preventDefault(),m())}),document.addEventListener(`click`,t=>{t.target instanceof Node&&(e.contains(t.target)||l(!1))}),e.dataset.collectionPageActionsInitialized=`true`});var Ct=e=>{let t={addToNavigation:``,addingToNavigation:``,addedToNavigation:``,editNavigation:``,addToNavigationFailed:``,confirmDelete:``,deleteCollection:``,cancel:``,saveFailed:``,deleted:``};if(!e)return t;try{return{...t,...JSON.parse(e)}}catch{return t}};document.querySelectorAll(`[data-smart-collection-page-actions]`).forEach(e=>{if(e.dataset.smartCollectionPageActionsInitialized===`true`)return;let t=Ct(e.dataset.collectionPageLabels),n=e.dataset.smartCollectionId,r=e.dataset.collectionPageRedirectUrl||ae(),i=e.querySelector(`[data-collection-page-action='toggle-menu']`),a=e.querySelector(`[data-collection-page-menu]`),o=e.querySelector(`[data-collection-page-action='add-to-navigation']`),c=e.querySelector(`[data-collection-page-edit-navigation]`);if(!n||!i||!a)return;let l=(e=!1)=>{a.hidden||(a.hidden=!0,i.setAttribute(`aria-expanded`,`false`),e&&i.focus())},u=(e=!1)=>{a.hidden=!1,i.setAttribute(`aria-expanded`,`true`),e&&a.querySelector(`[role='menuitem']`)?.focus()},f=async()=>{l(!1),await Q({smartCollectionId:n})&&window.location.reload()},p=async()=>{if(l(!1),await h({message:t.confirmDelete,confirmLabel:t.deleteCollection,cancelLabel:t.cancel,tone:`danger`}))try{let e=await fetch(`/api/smart-collections/${n}`,{method:`DELETE`});if(!e.ok)throw Error(`HTTP ${e.status}`);d(t.deleted),window.location.href=r}catch{d(t.saveFailed,`error`)}},m=async()=>{if(!o||o.disabled)return;l(!1);let r=o.querySelector(`.collections-page-menu-item-label`);o.disabled=!0,r&&(r.textContent=t.addingToNavigation);try{await Se(n),o.hidden=!0,c&&(c.hidden=!1),e.dataset.collectionInNavigation=`true`,s(t.addedToNavigation,{label:t.editNavigation,href:c?.getAttribute(`href`)??`/settings/navigation`})}catch{d(t.addToNavigationFailed,`error`)}finally{o.disabled=!1,r&&(r.textContent=t.addToNavigation)}};i.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),a.hidden?u(!1):l(!1)}),i.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `||e.key===`ArrowDown`)&&(e.preventDefault(),a.hidden?u(!0):l(!1)),e.key===`Escape`&&(e.preventDefault(),l(!0))}),a.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),l(!0))}),e.addEventListener(`click`,t=>{let n=t.target?.closest(`[data-collection-page-action]`);if(!n||!e.contains(n))return;let r=n.dataset.collectionPageAction;r===`edit`&&(t.preventDefault(),f()),r===`delete`&&(t.preventDefault(),p()),r===`add-to-navigation`&&(t.preventDefault(),m())}),document.addEventListener(`click`,t=>{t.target instanceof Node&&(e.contains(t.target)||l(!1))}),e.dataset.smartCollectionPageActionsInitialized=`true`});var wt=6,$=8;function Tt(e=document){e.querySelectorAll(`[data-custom-url-actions]`).forEach(e=>{if(e.dataset.customUrlActionsInitialized===`true`)return;let t=e.querySelector(`[data-custom-url-action='toggle-menu']`),n=e.querySelector(`[data-custom-url-menu]`);if(!(t instanceof HTMLButtonElement)||!n)return;let r=typeof n.showPopover==`function`&&n.hasAttribute(`popover`),i=()=>{let e=t.getBoundingClientRect(),{width:r,height:i}=n.getBoundingClientRect(),a=e.bottom+wt,o=e.top-wt-i,s=a+i<=window.innerHeight-$||o<$?a:o;n.style.top=`${s}px`,n.style.left=`${Math.max($,Math.min(e.right-r,window.innerWidth-$-r))}px`},a=(e=!1)=>{n.hidden||(r&&(window.removeEventListener(`resize`,i),window.removeEventListener(`scroll`,i,!0),n.matches(`:popover-open`)&&n.hidePopover()),n.hidden=!0,t.setAttribute(`aria-expanded`,`false`),e&&t.focus())},o=(a=!1)=>{document.dispatchEvent(new CustomEvent(`jant:custom-url-menu`,{detail:{source:e}})),n.hidden=!1,r&&(n.matches(`:popover-open`)||n.showPopover(),i(),window.addEventListener(`resize`,i),window.addEventListener(`scroll`,i,!0)),t.setAttribute(`aria-expanded`,`true`),a&&n.querySelector(`[role='menuitem']`)?.focus()};t.addEventListener(`click`,e=>{if(e.preventDefault(),e.stopPropagation(),n.hidden){o(!1);return}a(!1)}),t.addEventListener(`keydown`,e=>{if(e.key===`Enter`||e.key===` `||e.key===`ArrowDown`){e.preventDefault(),n.hidden?o(!0):a(!1);return}e.key===`Escape`&&(e.preventDefault(),a(!0))}),n.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),a(!0))}),e.addEventListener(`click`,t=>{let n=t.target;if(!n)return;let r=n.closest(`[data-custom-url-action]`);r&&e.contains(r)&&r.dataset.customUrlAction===`delete`&&a(!1)}),document.addEventListener(`click`,e=>{e.target instanceof Node&&(t.contains(e.target)||n.contains(e.target)||a(!1))}),document.addEventListener(`jant:custom-url-menu`,t=>{t.detail?.source!==e&&a(!1)}),e.dataset.customUrlActionsInitialized=`true`})}Tt();