@jant/core 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/commands/site/import.js +2 -1
- package/dist/{app-CbOZ2Irh.js → app-BuzORSgm.js} +1441 -686
- package/dist/client/.vite/manifest.json +72 -83
- package/dist/client/_assets/chunks/{confirm-CMe01lne.js → confirm-BQebcuNB.js} +1 -1
- package/dist/client/_assets/chunks/{create-editor-hWapNE40.js → create-editor-B8KuszlS.js} +38 -38
- package/dist/client/_assets/chunks/footnote-rail-DUrqz0Py.js +2 -0
- package/dist/client/_assets/chunks/{jant-locale-picker-2L4rkDaz.js → jant-locale-picker-CLq0iKDH.js} +1 -1
- package/dist/client/_assets/chunks/lit-BN4mrI3j.js +2 -0
- package/dist/client/_assets/chunks/{settings-paths-BBVT8zKj.js → settings-paths-_fry4yWW.js} +1 -1
- package/dist/client/_assets/chunks/{slug-format-BuCPjSrB.js → slug-format-bcJ2ozr4.js} +1 -1
- package/dist/client/_assets/chunks/{sortable-list-DJXwkaOv.js → sortable-list-Bz2Na2E9.js} +2 -2
- package/dist/client/_assets/chunks/{unsafe-html-CWos3v6N.js → unsafe-html-OJ9m154w.js} +1 -1
- package/dist/client/_assets/chunks/unsafe-svg-DVJ4NPcb.js +1 -0
- package/dist/client/_assets/client-CStDm2xD.js +354 -0
- package/dist/client/_assets/{client-D8Rrsd73.css → client-CoNHvipV.css} +1 -1
- package/dist/client/_assets/{client-auth-CsUGM718.js → client-auth-D53R-Wby.js} +99 -129
- package/dist/client/_assets/client-author-2WYBkgni.css +2 -0
- package/dist/client/_assets/{client-compose-BB4U7Wz0.js → client-compose-DYtDlYm-.js} +248 -244
- package/dist/client/_assets/{client-manage-CI9-eh-8.js → client-manage-BODyYP5Z.js} +157 -157
- package/dist/client/_assets/{client-settings-BnGPuqwc.js → client-settings-DDpe_tXJ.js} +166 -166
- package/dist/client/_assets/client-share-B9OsXx9p.js +149 -0
- package/dist/{constants-DEgyqWDl.js → constants-C2CdWAqt.js} +55 -5
- package/dist/index.js +1 -1
- package/dist/node.js +2 -2
- package/package.json +2 -1
- package/src/client/components/compose-types.ts +5 -1
- package/src/client/components/jant-compose-dialog.ts +25 -4
- package/src/client/components/jant-media-lightbox.ts +18 -3
- package/src/client/components/jant-nav-manager.ts +2 -0
- package/src/client/components/jant-post-menu.ts +42 -89
- package/src/client/components/nav-manager-types.ts +2 -0
- package/src/client/components/settings-types.ts +1 -1
- package/src/client/list-views.ts +382 -0
- package/src/client/media-lightbox-events.ts +12 -0
- package/src/client/runtime-paths.ts +12 -0
- package/src/client/share-capture.ts +63 -0
- package/src/client/share-launch.ts +36 -9
- package/src/client/tiptap/create-editor.ts +4 -0
- package/src/client/tiptap/embed-node.ts +3 -1
- package/src/client/tiptap/html-block-node.ts +3 -1
- package/src/client/tiptap/image-node.ts +3 -1
- package/src/client/view-confirm.ts +32 -4
- package/src/client.ts +1 -0
- package/src/db/migrations/0037_round_post.sql +16 -0
- package/src/db/migrations/0038_flashy_changeling.sql +15 -0
- package/src/db/migrations/0039_mixed_sister_grimm.sql +1 -0
- package/src/db/migrations/meta/0037_snapshot.json +2932 -0
- package/src/db/migrations/meta/0038_snapshot.json +2924 -0
- package/src/db/migrations/meta/0039_snapshot.json +2931 -0
- package/src/db/migrations/meta/_journal.json +21 -0
- package/src/db/migrations/pg/0035_flimsy_outlaw_kid.sql +3 -0
- package/src/db/migrations/pg/0036_milky_wolverine.sql +5 -0
- package/src/db/migrations/pg/0037_fuzzy_hammerhead.sql +1 -0
- package/src/db/migrations/pg/meta/0035_snapshot.json +3773 -0
- package/src/db/migrations/pg/meta/0036_snapshot.json +3766 -0
- package/src/db/migrations/pg/meta/0037_snapshot.json +3772 -0
- package/src/db/migrations/pg/meta/_journal.json +21 -0
- package/src/db/pg/schema.ts +1 -0
- package/src/db/post-visibility.ts +37 -6
- package/src/db/schema.ts +5 -2
- package/src/i18n/locales/glossary.zh-Hans.yml +4 -0
- package/src/i18n/locales/glossary.zh-Hant.yml +4 -0
- package/src/i18n/locales/public/en.po +21 -90
- package/src/i18n/locales/public/en.ts +1 -1
- package/src/i18n/locales/public/zh-Hans.po +20 -89
- package/src/i18n/locales/public/zh-Hans.ts +1 -1
- package/src/i18n/locales/public/zh-Hant.po +20 -89
- package/src/i18n/locales/public/zh-Hant.ts +1 -1
- package/src/i18n/locales/settings/en.po +84 -0
- package/src/i18n/locales/settings/en.ts +1 -1
- package/src/i18n/locales/settings/zh-Hans.po +130 -46
- package/src/i18n/locales/settings/zh-Hans.ts +1 -1
- package/src/i18n/locales/settings/zh-Hant.po +124 -40
- package/src/i18n/locales/settings/zh-Hant.ts +1 -1
- package/src/lib/api-public-posts.ts +10 -0
- package/src/lib/feed-policy.ts +2 -2
- package/src/lib/feed.ts +17 -1
- package/src/lib/filter-dimensions.ts +11 -4
- package/src/lib/hugo-markdown.ts +7 -0
- package/src/lib/icons.ts +2 -0
- package/src/lib/link-preview.ts +499 -0
- package/src/lib/list-views.ts +117 -0
- package/src/lib/markdown-manager.ts +40 -1
- package/src/lib/navigation.ts +1 -1
- package/src/lib/share-card.ts +4 -3
- package/src/lib/thread-query.ts +6 -2
- package/src/lib/timeline.ts +12 -11
- package/src/lib/url-fetch.ts +291 -74
- package/src/lib/view-buffer.ts +2 -2
- package/src/lib/view-counting.ts +7 -6
- package/src/lib/view-token.ts +29 -7
- package/src/lib/view.ts +17 -0
- package/src/middleware/view-counter.ts +10 -5
- package/src/preset.css +5 -3
- package/src/routes/api/search.ts +1 -1
- package/src/routes/dash/settings.tsx +1 -1
- package/src/routes/feed/sitemap.ts +1 -1
- package/src/routes/pages/archive.tsx +25 -19
- package/src/routes/pages/collection.tsx +3 -3
- package/src/routes/pages/page.tsx +16 -4
- package/src/routes/pages/search.tsx +3 -3
- package/src/routes/pages/subscribe.tsx +19 -3
- package/src/routes/view-confirm.ts +23 -15
- package/src/services/collection.ts +1 -1
- package/src/services/export-theme/assets/client-site.js +19 -19
- package/src/services/export-theme/layouts/archive/list.html +4 -2
- package/src/services/export-theme/layouts/partials/collection-members.html +4 -3
- package/src/services/export-theme/layouts/partials/featured-members.html +3 -3
- package/src/services/export-theme/layouts/partials/head.html +2 -0
- package/src/services/export-theme/layouts/partials/latest-members.html +4 -4
- package/src/services/export-theme/layouts/partials/post-card.html +1 -9
- package/src/services/export-theme/layouts/partials/reply.html +1 -9
- package/src/services/export-theme/layouts/partials/smart-collection-members.html +4 -3
- package/src/services/export-theme/layouts/post/list.html +1 -9
- package/src/services/export-theme/styles/main.css +2 -26
- package/src/services/export.ts +10 -3
- package/src/services/mcp.ts +5 -5
- package/src/services/navigation.ts +9 -4
- package/src/services/post.ts +102 -112
- package/src/services/search.ts +22 -7
- package/src/services/smart-collection.ts +3 -3
- package/src/services/stats.ts +12 -5
- package/src/services/thread.ts +6 -2
- package/src/styles/components-author.css +69 -7
- package/src/styles/tokens.css +28 -29
- package/src/styles/ui-author.css +140 -353
- package/src/styles/ui.css +34 -32
- package/src/types/constants.ts +68 -4
- package/src/types/entities.ts +1 -0
- package/src/types/views.ts +2 -0
- package/src/ui/compose/ComposeDialog.tsx +20 -1
- package/src/ui/dash/StatusBadge.tsx +11 -0
- package/src/ui/dash/appearance/FontThemeContent.tsx +1 -1
- package/src/ui/dash/appearance/NavigationContent.tsx +8 -0
- package/src/ui/dash/settings/StatsContent.tsx +29 -29
- package/src/ui/feed/LinkCard.tsx +19 -2
- package/src/ui/feed/PostStatusBadges.tsx +19 -3
- package/src/ui/feed/TimelineFeed.tsx +3 -0
- package/src/ui/font-themes.ts +32 -15
- package/src/ui/pages/ArchivePage.tsx +1 -0
- package/src/ui/pages/SubscribePage.tsx +9 -1
- package/src/ui/shared/PostFooter.tsx +1 -22
- package/src/ui/shared/custom-icons.ts +5 -5
- package/dist/client/_assets/chunks/footnote-rail-9zwl6jtV.js +0 -2
- package/dist/client/_assets/chunks/lit-Bw_voPoW.js +0 -2
- package/dist/client/_assets/chunks/runtime-paths-y0_gHowM.js +0 -1
- package/dist/client/_assets/chunks/unsafe-svg-CUrgo4Xg.js +0 -1
- package/dist/client/_assets/client-BO8GOFfT.js +0 -354
- package/dist/client/_assets/client-author-QPm1whbO.css +0 -2
- package/dist/client/_assets/client-share-C59mOLJ1.js +0 -149
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{E as e,S as t,_ as n,b as r,g as i,h as a,i as o,n as s,t as c,u as l}from"./chunks/lit-BN4mrI3j.js";import{a as ee}from"./chunks/footnote-rail-DUrqz0Py.js";import{a as te,i as ne,n as re,o as ie,r as ae,t as oe}from"./client-CStDm2xD.js";import{n as u,t as se}from"./chunks/confirm-BQebcuNB.js";import{_ as d,a as ce,d as f,f as p,g as m,h,i as le,l as g,m as ue,n as de,p as fe,r as pe,t as _,u as me,v}from"./chunks/unsafe-svg-DVJ4NPcb.js";import{h as y,l as he,u as b}from"./chunks/types-DrYFqJH2.js";import{r as x}from"./chunks/slug-format-bcJ2ozr4.js";import{t as ge}from"./chunks/settings-paths-_fry4yWW.js";var S=`M12 3 10.1 10.1 3 12l7.1 1.9L12 21l1.9-7.1L21 12l-7.1-1.9Z`,_e=`M4 4 20 20`,ve=200,ye=class extends c{static properties={_open:{state:!0},_query:{state:!0},_items:{state:!0},_note:{state:!0},_loading:{state:!0},_searched:{state:!0}};#e=null;#t=null;#n=0;createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this._open=!1,this._query=``,this._items=[],this._note=``,this._loading=!1,this._searched=!1}disconnectedCallback(){super.disconnectedCallback();let e=this.#e;this.#e=null,e?.resolve(null)}pick(e){return this.#e?.resolve(null),this._query=``,this._items=[],this._note=``,this._loading=!1,this._searched=!1,this._open=!0,new Promise(t=>{this.#e={...e,resolve:t},this.updateComplete.then(()=>{let e=this.querySelector(`.picker-dialog`);e&&!e.open&&e.showModal(),this.querySelector(`.picker-dialog-input`)?.focus()})})}#r(e){this.#t&&clearTimeout(this.#t),this.#t=null,this.#n+=1;let t=this.querySelector(`.picker-dialog`);t?.open&&t.close();let n=this.#e;this.#e=null,this._open=!1,n?.resolve(e)}#i(e){let t=this.#e;if(!t)return;let n=e.target.value;this._query=n,this.#t&&clearTimeout(this.#t);let r=t.minQueryLength??2;if(n.trim().length<r){this.#n+=1,this._items=[],this._note=``,this._loading=!1,this._searched=!1;return}this._loading=!0,this.#t=setTimeout(()=>{this.#a(n,t)},ve)}async#a(e,t){let n=++this.#n;try{let r=await t.search(e);if(n!==this.#n)return;this._items=r.items,this._note=r.note??``}catch{if(n!==this.#n)return;this._items=[],this._note=``}finally{n===this.#n&&(this._loading=!1,this._searched=!0)}}#o(e){if(e.key===`Escape`){e.preventDefault(),this.#r(null);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=Array.from(this.querySelectorAll(`.picker-dialog-option`));if(t.length===0)return;e.preventDefault();let n=document.activeElement,r=t.findIndex(e=>e===n),i=e.key===`ArrowDown`?r<0?0:Math.min(r+1,t.length-1):r<=0?-1:r-1;if(i<0){this.querySelector(`.picker-dialog-input`)?.focus();return}t[i]?.focus()}#s(e){e.target===e.currentTarget&&this.#r(null)}render(){let e=this.#e;if(!this._open||!e)return s;let t=e.minQueryLength??2,n=this._query.trim().length<t;return o`
|
|
2
2
|
<dialog
|
|
3
3
|
class="dialog picker-dialog"
|
|
4
4
|
@cancel=${e=>{e.preventDefault(),this.#r(null)}}
|
|
@@ -14,7 +14,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
14
14
|
<h2 id="picker-dialog-title" class="picker-dialog-title">
|
|
15
15
|
${e.heading}
|
|
16
16
|
</h2>
|
|
17
|
-
${e.hint?
|
|
17
|
+
${e.hint?o`<p class="picker-dialog-hint">${e.hint}</p>`:s}
|
|
18
18
|
</header>
|
|
19
19
|
|
|
20
20
|
<input
|
|
@@ -28,7 +28,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
28
28
|
/>
|
|
29
29
|
|
|
30
30
|
<div class="picker-dialog-results" role="listbox">
|
|
31
|
-
${this._items.map(e=>
|
|
31
|
+
${this._items.map(e=>o`
|
|
32
32
|
<button
|
|
33
33
|
type="button"
|
|
34
34
|
role="option"
|
|
@@ -37,19 +37,19 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
37
37
|
@click=${()=>this.#r(e.id)}
|
|
38
38
|
>
|
|
39
39
|
<span class="picker-dialog-option-label">${e.label}</span>
|
|
40
|
-
${e.meta?
|
|
40
|
+
${e.meta?o`<span class="picker-dialog-option-meta"
|
|
41
41
|
>${e.meta}</span
|
|
42
|
-
>`:
|
|
42
|
+
>`:s}
|
|
43
43
|
</button>
|
|
44
44
|
`)}
|
|
45
|
-
${this._loading?
|
|
46
|
-
${!this._loading&&this._searched&&this._items.length===0?
|
|
45
|
+
${this._loading?o`<p class="picker-dialog-status">Searching…</p>`:s}
|
|
46
|
+
${!this._loading&&this._searched&&this._items.length===0?o`<p class="picker-dialog-status">
|
|
47
47
|
${this._note||e.emptyHint}
|
|
48
|
-
</p>`:
|
|
48
|
+
</p>`:s}
|
|
49
49
|
</div>
|
|
50
50
|
|
|
51
51
|
<footer
|
|
52
|
-
class=${
|
|
52
|
+
class=${x({"picker-dialog-actions":!0,"picker-dialog-actions-quiet":n})}
|
|
53
53
|
>
|
|
54
54
|
<button
|
|
55
55
|
type="button"
|
|
@@ -61,7 +61,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
61
61
|
</footer>
|
|
62
62
|
</div>
|
|
63
63
|
</dialog>
|
|
64
|
-
`}};customElements.get(`jant-post-picker`)||customElements.define(`jant-post-picker`,ve);var w=`jant-post-picker`;function ye(){let e=document.querySelector(w);if(e)return e;let t=document.createElement(w);return document.body.appendChild(t),t}function be(e){return ye().pick(e)}var T=`[data-post-menu-translation] a, [data-post-menu-translation-first], [data-post-menu-open-language-switch]`,xe=360;function E(e){let t=Array.from(e?.children??[]).find(e=>e instanceof HTMLElement&&e.classList.contains(`feed-item`));Array.from(t?.children??[]).find(e=>e instanceof HTMLElement&&e.classList.contains(`feed-divider`))?.remove()}function D(e){return!e.isDraft&&e.visibility!==`private`}function O(e){return Array.from(document.querySelectorAll(`article[data-post-id]`)).find(t=>t.dataset.postId===e)??null}function k(e){let t=e.dataset.postId;if(!t)return null;let n=e.dataset.threadRootId??t,r=O(n)??e;return{id:t,threadId:n,pinned:e.hasAttribute(`data-post-pinned`),pinnedInCollection:r.hasAttribute(`data-post-pinned-in-collection`),featured:e.hasAttribute(`data-post-featured`),visibility:e.dataset.postVisibility??`public`,isReply:n!==t||e.hasAttribute(`data-post-reply`),isDraft:e.hasAttribute(`data-post-draft`),language:r.dataset.postLanguage??null,permalink:e.dataset.postPermalink??null}}var Se=class extends l{static properties={languages:{type:Array},_open:{state:!0},_data:{state:!0},_x:{state:!0},_y:{state:!0},_openAbove:{state:!0},_view:{state:!0},_collections:{state:!0},_collectionsLoading:{state:!0},_collectionSearch:{state:!0},_threadCollectionIds:{state:!0},_addCollectionPanelOpen:{state:!0},_translations:{state:!0},_translationsLoading:{state:!0},_translationBusy:{state:!0}};#e=!1;#t=[];#n=!0;createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this.languages=[],this._open=!1,this._data=null,this._x=0,this._y=0,this._openAbove=!0,this._view=`menu`,this._collections=null,this._collectionsLoading=!1,this._collectionSearch=``,this._threadCollectionIds=[],this._addCollectionPanelOpen=!1,this._translations=null,this._translationsLoading=!1,this._translationBusy=!1,this._triggerEl=null}connectedCallback(){super.connectedCallback(),document.addEventListener(`click`,this.#o),document.addEventListener(`keydown`,this.#a),window.addEventListener(`resize`,this.#i)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(`click`,this.#o),document.removeEventListener(`keydown`,this.#a),window.removeEventListener(`resize`,this.#i)}#r(){let e=this._triggerEl;if(!e?.isConnected){this._open&&this.#k({restoreFocus:!1});return}let t=e.getBoundingClientRect();this._openAbove=re(t,xe),this._x=window.scrollX+t.right,this._y=window.scrollY+(this._openAbove?t.top-6:t.bottom+6)}#i=()=>{this._open&&!this._addCollectionPanelOpen&&this.#r()};#a=e=>{let t=e;if(!(t.isComposing||t.keyCode===229)&&t.key===`Escape`){if(this._addCollectionPanelOpen){this.#H();return}let e=document.querySelector(`[data-collection-popover].open`);if(e){e.classList.remove(`open`);return}if(this._open){if(this._view===`language-switch`){this.#v();return}if(this._view!==`menu`){this.#p();return}this.#k()}}};#o=e=>{let t=e.target,n=t.closest(`[data-collection-popover-trigger]`);if(n){e.preventDefault(),e.stopPropagation();let t=n.parentElement?.querySelector(`[data-collection-popover]`);t&&t.classList.toggle(`open`);return}if(t.closest(`[data-collection-popover]`)||t.closest(`[data-collection-quick-dialog]`)||t.classList.contains(`collection-quick-dialog-backdrop`))return;let r=document.querySelector(`[data-collection-popover].open`);r&&r.classList.remove(`open`);let i=t.closest(`[data-post-menu-trigger]`);if(i){e.preventDefault(),e.stopPropagation();let t=i.closest(`article[data-post]`);if(!t)return;let n=k(t);if(!n)return;if(this._open&&this._data?.id===n.id){this.#k();return}this._data=n,this._triggerEl=i,this.#n=!0,this.#r(),i.setAttribute(`aria-expanded`,`true`),this._view=`menu`,this._open=!0,this.#s(`[data-post-menu-item-primary]`),D(n)&&ne();return}this._open&&t.closest?.(`.post-menu-view, .post-menu-panel`)||this._open&&this.#k({restoreFocus:!1})};#s(e){this.updateComplete.then(()=>{this.querySelector(e)?.focus()})}#c(){return Array.from(this.querySelectorAll(`.post-menu-picker-option`))}#l=e=>{if(e.defaultPrevented||e.isComposing||e.altKey||e.ctrlKey||e.metaKey)return;if(e.key===`Enter`){e.preventDefault(),this.#k();return}if(e.key!==`ArrowDown`)return;let[t]=this.#c(),n=this.querySelector(`[data-post-menu-add-collection]`),r=t??n;r&&(e.preventDefault(),r.focus())};#u=(e,t)=>{if(e.defaultPrevented||e.isComposing||e.altKey||e.ctrlKey||e.metaKey)return;let n=this.#c(),r=e.currentTarget,i=r?n.indexOf(r):-1;if(e.key===`ArrowDown`){let t=this.querySelector(`[data-post-menu-add-collection]`),r=i>=0?n[i+1]??t:n[0];if(!r)return;e.preventDefault(),r.focus();return}if(e.key===`ArrowUp`){let t=this.querySelector(`.post-menu-picker-search input`),r=i>0?n[i-1]:t;if(!r)return;e.preventDefault(),r.focus();return}if(e.key===` `||e.key===`Spacebar`){e.preventDefault(),this.#B(t);return}e.key===`Enter`&&(e.preventDefault(),this.#k())};#d=(e,t)=>{e.detail!==0&&this.#B(t)};#f=e=>{if(e.defaultPrevented||e.isComposing||e.altKey||e.ctrlKey||e.metaKey||e.key!==`ArrowUp`)return;let t=this.#c(),n=this.querySelector(`.post-menu-picker-search input`),r=t.at(-1)??n;r&&(e.preventDefault(),r.focus())};#p(e=`[data-post-menu-item-primary]`){this._view=`menu`,this.#s(e)}#m(){this._data?.isReply||(this._view=`visibility`,this.#s(`[data-post-menu-visibility-current='true'], [data-post-menu-visibility-option]`))}get#h(){return this.languages.length>1}#g(e){return e?this.languages.find(t=>t.tag===e)?.label??e:`Not set`}async#_(){this._data?.isReply||(this._view=`language`,this.#s(T),await this.#S(),this.contains(document.activeElement)||this.#s(T))}#v(e=`[data-post-menu-open-language-switch]`){this._view=`language`,this.#s(e)}#y(){this._data?.isReply||(this._view=`language-switch`,this.#s(`[data-post-menu-language-current='true'], [data-post-menu-language-option]`))}#b(){let e=this._data?.language??null,t=this._translations??[],n=new Set(t.flatMap(e=>e.language?[e.language]:[]));return{current:e,linked:t,selectable:this.languages.filter(t=>t.tag===e||!n.has(t.tag)),free:this.languages.filter(t=>t.tag!==e&&!n.has(t.tag))}}async#x(e){let t=this._data;if(t&&!this._translationBusy){this._translationBusy=!0;try{let n=await fetch(i(`/api/posts/${t.threadId}/language`),{method:`PUT`,headers:{"Content-Type":`application/json`},credentials:`same-origin`,body:JSON.stringify({language:e})});if(!n.ok){u(await b(n,`Could not change the language. Try again.`),`error`);return}let r=document.querySelector(`article[data-post-id="${t.threadId}"]`);r&&(r.dataset.postLanguage=e),this._data={...t,language:e},u(`Thread is now in ${this.#g(e)}.`),this.#k()}catch{u(`Could not change the language. Try again.`,`error`)}finally{this._translationBusy=!1}}}async#S(){let e=this._data;if(e){this._translationsLoading=!0;try{let t=await fetch(i(`/api/posts/${e.threadId}/translations`),{credentials:`same-origin`});if(!t.ok)return;let n=await t.json();this._translations=n.translations??[]}catch{this._translations=[]}finally{this._translationsLoading=!1}}}async#C(e){let t=this._data;if(!t)return;this.#k({restoreFocus:!1});let n=await _();if(n){await n.openTranslation(t.threadId,e);return}let r=new URLSearchParams({translationOf:t.threadId,lang:e});window.location.assign(i(`/new?${r.toString()}`))}async#w(){let e=this._data;if(!e)return;this.#k({restoreFocus:!1});let n=await be({heading:`Link a translation`,hint:`Only posts you could actually link are listed: published, and in a language this one's group does not already have.`,placeholder:`Search your posts, or paste a URL…`,emptyHint:`Nothing matched that you could link.`,search:async n=>{if(t(n))return this.#T(e.threadId,n);let r=await fetch(i(`/api/posts/${e.threadId}/translations/candidates?q=${encodeURIComponent(n)}`),{credentials:`same-origin`});return r.ok?{items:((await r.json()).candidates??[]).map(e=>({id:e.id,label:e.label,meta:this.#g(e.language)}))}:{items:[]}}});n&&(this._data=e,await this.#D(n),window.location.reload())}async#T(e,t){let n;try{let r=await fetch(i(`/api/posts/${e}/translations/resolve?url=${encodeURIComponent(t)}`),{credentials:`same-origin`});if(!r.ok)throw Error(`HTTP ${r.status}`);({resolution:n}=await r.json())}catch{return{items:[],note:`Could not check that address. Try again in a moment.`}}return n?n.kind===`ok`?{items:[{id:n.candidate.id,label:n.candidate.label,meta:this.#g(n.candidate.language)}]}:{items:[],note:this.#E(n)}:{items:[]}}#E(e){let t=this.#g(`language`in e?e.language:null);switch(e.kind){case`external`:return`That address is somewhere else. Only posts on this site can be linked.`;case`not_found`:return`Nothing at ${e.address}. Check the address, or search by title.`;case`not_a_post`:return`That address is not a post. Translations link posts to posts.`;case`same_thread`:return`That is this post.`;case`unpublished`:return`That post is a draft. Publish it, then link it.`;case`no_language`:return`That post has no language yet. Set one on it first.`;case`same_language`:return`That post is written in ${this.#g(this._data?.language??null)} too. A translation has to be in another language.`;case`language_taken`:return`A ${t} version is already linked here. Unlink that one first.`;case`group_conflict`:return`That post belongs to another translation group. Unlink it first.`;case`group_language_taken`:return`Its translation group already has a ${t} version.`;default:return`That post cannot be linked.`}}async#D(e){let t=this._data;if(t&&!this._translationBusy){this._translationBusy=!0;try{let n=await fetch(i(`/api/posts/${t.threadId}/translations`),{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`same-origin`,body:JSON.stringify({postId:e})});if(!n.ok){u(await b(n,`Could not link those posts. Try again.`),`error`);return}await this.#S(),u(`Posts linked as translations.`)}catch{u(`Could not link those posts. Try again.`,`error`)}finally{this._translationBusy=!1}}}async#O(e){if(!this._data||this._translationBusy)return;let t=this._triggerEl;this.#k({restoreFocus:!1});let n=this.#g(e.language);if(!await d({message:`Unlink the ${n} version, “${e.label}”? Both posts stay published — they just stop pointing at each other.`,confirmLabel:`Unlink`,cancelLabel:`Cancel`,tone:`danger`})){t?.focus();return}this._translationBusy=!0;try{let n=await fetch(i(`/api/posts/${e.id}/translations`),{method:`DELETE`,credentials:`same-origin`});if(!n.ok){u(await b(n,`Could not unlink. Try again.`),`error`),t?.focus();return}u(`Translation link removed.`),window.location.reload()}catch{u(`Could not unlink. Try again.`,`error`),t?.focus()}finally{this._translationBusy=!1}}#k(e={}){let t=e.restoreFocus??this.#n,n=this._triggerEl;if(n?.setAttribute(`aria-expanded`,`false`),this._triggerEl=null,this.#n=!0,this._open=!1,this._view=`menu`,this._addCollectionPanelOpen=!1,this._collectionSearch=``,this._translations=null,this.#e){this.#e=!1,window.location.reload();return}t&&n?.focus()}openCollectionsForPost(e){let t=k(e);if(!t||t.isReply)return;this._data=t;let n=e.querySelector(`[data-post-menu-trigger]`);n&&(this._triggerEl=n,this.#n=!1,this.#r(),n.setAttribute(`aria-expanded`,`true`)),this._open=!0,this.#z()}async#A(){if(!this._data)return;let e=this._data.id;this.#k({restoreFocus:!1});let t=await _();t&&await t.openEdit(e)}#j(){let e=this._data?.permalink;this.#k(),e&&ie(e)}#M(){if(!this._data)return;let e=this._data.id,t=this._triggerEl;this.#k({restoreFocus:!1}),ae(e,t)}async#N(){if(!this._data)return;let e=this._data.id,t=this._triggerEl;this.#k({restoreFocus:!1});let n=document.querySelector(`article[data-post-id="${e}"]`);try{if(!(await fetch(`/api/posts/${e}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({status:`published`})})).ok)throw Error();u(`Draft published.`),(!n||!await se(n))&&globalThis.location.reload()}catch{u(`Could not publish the draft. Try again.`,`error`),t?.focus()}}#P(e){if(!this._data)return;let t=this._data.id,n=this._data.visibility,r=document.querySelector(`article[data-post-id="${t}"]`);r&&(r.dataset.postVisibility=e),this._data={...this._data,visibility:e},u({public:`Post made public.`,latest_hidden:`Hidden from Latest.`,private:`Post made private.`}[e]??`Visibility updated.`),this.#k(),fetch(`/api/posts/${t}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({visibility:e})}).then(e=>{if(!e.ok)throw Error()}).catch(()=>{let e=document.querySelector(`article[data-post-id="${t}"]`);e&&(e.dataset.postVisibility=n),u(`Could not update visibility. Try again.`,`error`)})}#F(e){if(!this._data)return;let t=this._data.id,n=document.querySelector(`article[data-post-id="${t}"]`);n&&(e?n.setAttribute(`data-post-featured`,``):n.removeAttribute(`data-post-featured`)),this._data={...this._data,featured:e},u(e?`Added to Featured.`:`Removed from Featured.`),this.#k(),fetch(`/api/posts/${t}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({featured:e})}).then(e=>{if(!e.ok)throw Error()}).catch(()=>{let n=document.querySelector(`article[data-post-id="${t}"]`);n&&(e?n.removeAttribute(`data-post-featured`):n.setAttribute(`data-post-featured`,``)),u(`Could not update post. Try again.`,`error`)})}#I(){if(!this._data)return;let e=this._data.id,t=!this._data.pinned,n=document.querySelector(`article[data-post-id="${e}"]`);n&&(t?n.setAttribute(`data-post-pinned`,``):n.removeAttribute(`data-post-pinned`)),this._data={...this._data,pinned:t},u(t?`Post pinned.`:`Post unpinned.`),this.#k(),fetch(`/api/posts/${e}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pinned:t})}).then(e=>{if(!e.ok)throw Error()}).catch(()=>{let n=document.querySelector(`article[data-post-id="${e}"]`);n&&(t?n.removeAttribute(`data-post-pinned`):n.setAttribute(`data-post-pinned`,``)),u(`Could not update post. Try again.`,`error`)})}#L(){if(!this._data)return;let e=this._data.threadId,t=document.querySelector(`[data-collection-id]`)?.dataset.collectionId;if(!t)return;let n=!this._data.pinnedInCollection,r=O(e);r&&(n?r.setAttribute(`data-post-pinned-in-collection`,``):r.removeAttribute(`data-post-pinned-in-collection`)),this._data={...this._data,pinnedInCollection:n},u(n?`Pinned in collection.`:`Unpinned from collection.`),this.#k();let i=n?`PUT`:`DELETE`;fetch(`/api/collections/${t}/threads/${e}/pin`,{method:i}).then(e=>{if(!e.ok)throw Error()}).catch(()=>{let t=O(e);t&&(n?t.removeAttribute(`data-post-pinned-in-collection`):t.setAttribute(`data-post-pinned-in-collection`,``)),u(`Could not update pin. Try again.`,`error`)})}async#R(){if(!this._data)return;let e=this._triggerEl;if(this.#k({restoreFocus:!1}),!await d({message:this._data.isDraft?`Discard this draft permanently? This can't be undone.`:`Delete this post permanently? This can't be undone.`,confirmLabel:this._data.isDraft?`Discard`:`Delete`,cancelLabel:`Cancel`,tone:`danger`})){e?.focus();return}try{if(!(await fetch(`/api/posts/${this._data.id}`,{method:`DELETE`})).ok)throw Error();let e=document.querySelector(`article[data-post-id="${this._data.id}"]`),t=e?.closest(`.thread-item`),n=t?.closest(`.thread-group`);if(t&&n){if(t.remove(),n.querySelectorAll(`.thread-item:not(.thread-item-gap)`).length===0){let e=n.closest(`.feed-item`),t=e?.parentElement??null;(e??n).remove(),E(t)}}else{let t=e?.closest(`.feed-item`),n=t?.parentElement??null;(t??e)?.remove(),E(n)}u(`Post deleted.`)}catch{u(`Could not delete post. Try again.`,`error`),e?.focus()}}async#z(){if(!this._data||this._data.isReply)return;let e=this._data.id;this._view=`collections`,this._collectionSearch=``,this._collectionsLoading=!0,this.#s(`.post-menu-picker-search input, .post-menu-picker-option, [data-post-menu-add-collection]`);try{let[t,n]=await Promise.all([fetch(`/api/collections?view=compose`,{cache:`no-store`,headers:{Accept:`application/json`}}),fetch(`/api/posts/${e}`)]);if(!t.ok)throw Error();let r=(await t.json()).collections??[],i=this._threadCollectionIds;n.ok&&(i=(await n.json()).collectionIds??[]),this.#t=ce(r,i),this._collections=r,this._threadCollectionIds=i}catch{this._collections=this._collections??[],u(`Could not load collections.`,`error`)}this._collectionsLoading=!1,this.#s(`.post-menu-picker-search input, .post-menu-picker-option, [data-post-menu-add-collection]`)}#B(e){if(!this._data)return;let t=this._data.threadId,n=this._threadCollectionIds.includes(e);this._threadCollectionIds=n?this._threadCollectionIds.filter(t=>t!==e):[...this._threadCollectionIds,e],this.#e=!0,u(n?`Removed from collection.`:`Added to collection.`),n?fetch(`/api/collections/${e}/threads/${t}`,{method:`DELETE`}).then(e=>{if(!e.ok)throw Error();return this.#K()}).catch(()=>{this._threadCollectionIds.includes(e)||(this._threadCollectionIds=[...this._threadCollectionIds,e]),u(`Could not remove from collection. Try again.`,`error`)}):fetch(`/api/collections/${e}/threads`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({threadId:t})}).then(e=>{if(!e.ok){if(e.status===409)return this.#K();throw Error()}return this.#K()}).catch(()=>{this._threadCollectionIds=this._threadCollectionIds.filter(t=>t!==e),u(`Could not add to collection. Try again.`,`error`)})}#V(){this._addCollectionPanelOpen=!0,this.updateComplete.then(()=>{let e=this.querySelector(`[data-collection-quick-dialog] [data-collection-title-input]`);e?.focus(),e?.select()})}#H(){this._addCollectionPanelOpen=!1,this.#r(),this.updateComplete.then(()=>{(this.querySelector(`[data-post-menu-add-collection]`)??this._triggerEl)?.focus()})}async#U(e){let t=e;t.stopPropagation();let n=t.detail;if(!n)return;let r=this.querySelector(`jant-collection-form`);r&&(r.loading=!0);try{let e=await fetch(`/api/collections`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n.data)}),t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||`Could not create collection. Try again.`);if(!t?.id||!t.title||!t.slug)throw Error(`Could not create collection. Try again.`);let r={id:t.id,title:t.title,slug:t.slug};this._collections=[...this._collections??[],r],this._data&&(await fetch(`/api/collections/${t.id}/threads`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({threadId:this._data.threadId})}),this._threadCollectionIds=[...this._threadCollectionIds,t.id]),await this.#K(),this.#e=!0,this.#H(),u(this.#W()?.createdLabel??`Collection created.`)}catch(e){u(e instanceof Error?e.message:`Could not create collection. Try again.`,`error`)}finally{r&&(r.loading=!1)}}#W(){return y()?.collectionFormLabels??null}#G(){return y()?.addCollection??`Add Collection`}async#K(){await(await _())?.refreshCollections()}#q(e){switch(e){case`private`:return`Private`;case`latest_hidden`:return`Hidden from Latest`;default:return`Public`}}#J(){return s`<svg
|
|
64
|
+
`}};customElements.get(`jant-post-picker`)||customElements.define(`jant-post-picker`,ye);var C=`jant-post-picker`;function be(){let e=document.querySelector(C);if(e)return e;let t=document.createElement(C);return document.body.appendChild(t),t}function xe(e){return be().pick(e)}var w=[{value:`public`,label:`Public`},{value:`latest_hidden`,label:`Hidden from Latest`},{value:`unlisted`,label:`Unlisted`},{value:`private`,label:`Private`}],T=`[data-post-menu-translation] a, [data-post-menu-translation-first], [data-post-menu-open-language-switch]`,Se=360;function E(e){let t=Array.from(e?.children??[]).find(e=>e instanceof HTMLElement&&e.classList.contains(`feed-item`));Array.from(t?.children??[]).find(e=>e instanceof HTMLElement&&e.classList.contains(`feed-divider`))?.remove()}function D(e){return!e.isDraft&&e.visibility!==`private`}function O(e){return Array.from(document.querySelectorAll(`article[data-post-id]`)).find(t=>t.dataset.postId===e)??null}function k(e){let t=e.dataset.postId;if(!t)return null;let n=e.dataset.threadRootId??t,r=O(n)??e;return{id:t,threadId:n,pinned:e.hasAttribute(`data-post-pinned`),pinnedInCollection:r.hasAttribute(`data-post-pinned-in-collection`),featured:e.hasAttribute(`data-post-featured`),visibility:e.dataset.postVisibility??`public`,isReply:n!==t||e.hasAttribute(`data-post-reply`),isDraft:e.hasAttribute(`data-post-draft`),language:r.dataset.postLanguage??null,permalink:e.dataset.postPermalink??null}}var Ce=class extends c{static properties={languages:{type:Array},_open:{state:!0},_data:{state:!0},_x:{state:!0},_y:{state:!0},_openAbove:{state:!0},_view:{state:!0},_collections:{state:!0},_collectionsLoading:{state:!0},_collectionSearch:{state:!0},_threadCollectionIds:{state:!0},_addCollectionPanelOpen:{state:!0},_translations:{state:!0},_translationsLoading:{state:!0},_translationBusy:{state:!0}};#e=!1;#t=[];#n=!0;createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this.languages=[],this._open=!1,this._data=null,this._x=0,this._y=0,this._openAbove=!0,this._view=`menu`,this._collections=null,this._collectionsLoading=!1,this._collectionSearch=``,this._threadCollectionIds=[],this._addCollectionPanelOpen=!1,this._translations=null,this._translationsLoading=!1,this._translationBusy=!1,this._triggerEl=null}connectedCallback(){super.connectedCallback(),document.addEventListener(`click`,this.#o),document.addEventListener(`keydown`,this.#a),window.addEventListener(`resize`,this.#i)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(`click`,this.#o),document.removeEventListener(`keydown`,this.#a),window.removeEventListener(`resize`,this.#i)}#r(){let e=this._triggerEl;if(!e?.isConnected){this._open&&this.#k({restoreFocus:!1});return}let t=e.getBoundingClientRect();this._openAbove=ie(t,Se),this._x=window.scrollX+t.right,this._y=window.scrollY+(this._openAbove?t.top-6:t.bottom+6)}#i=()=>{this._open&&!this._addCollectionPanelOpen&&this.#r()};#a=e=>{let t=e;if(!(t.isComposing||t.keyCode===229)&&t.key===`Escape`){if(this._addCollectionPanelOpen){this.#H();return}let e=document.querySelector(`[data-collection-popover].open`);if(e){e.classList.remove(`open`);return}if(this._open){if(this._view===`language-switch`){this.#v();return}if(this._view!==`menu`){this.#p();return}this.#k()}}};#o=e=>{let t=e.target,n=t.closest(`[data-collection-popover-trigger]`);if(n){e.preventDefault(),e.stopPropagation();let t=n.parentElement?.querySelector(`[data-collection-popover]`);t&&t.classList.toggle(`open`);return}if(t.closest(`[data-collection-popover]`)||t.closest(`[data-collection-quick-dialog]`)||t.classList.contains(`collection-quick-dialog-backdrop`))return;let r=document.querySelector(`[data-collection-popover].open`);r&&r.classList.remove(`open`);let i=t.closest(`[data-post-menu-trigger]`);if(i){e.preventDefault(),e.stopPropagation();let t=i.closest(`article[data-post]`);if(!t)return;let n=k(t);if(!n)return;if(this._open&&this._data?.id===n.id){this.#k();return}this._data=n,this._triggerEl=i,this.#n=!0,this.#r(),i.setAttribute(`aria-expanded`,`true`),this._view=`menu`,this._open=!0,this.#s(`[data-post-menu-item-primary]`),D(n)&&re();return}this._open&&t.closest?.(`.post-menu-view, .post-menu-panel`)||this._open&&this.#k({restoreFocus:!1})};#s(e){this.updateComplete.then(()=>{this.querySelector(e)?.focus()})}#c(){return Array.from(this.querySelectorAll(`.post-menu-picker-option`))}#l=e=>{if(e.defaultPrevented||e.isComposing||e.altKey||e.ctrlKey||e.metaKey)return;if(e.key===`Enter`){e.preventDefault(),this.#k();return}if(e.key!==`ArrowDown`)return;let[t]=this.#c(),n=this.querySelector(`[data-post-menu-add-collection]`),r=t??n;r&&(e.preventDefault(),r.focus())};#u=(e,t)=>{if(e.defaultPrevented||e.isComposing||e.altKey||e.ctrlKey||e.metaKey)return;let n=this.#c(),r=e.currentTarget,i=r?n.indexOf(r):-1;if(e.key===`ArrowDown`){let t=this.querySelector(`[data-post-menu-add-collection]`),r=i>=0?n[i+1]??t:n[0];if(!r)return;e.preventDefault(),r.focus();return}if(e.key===`ArrowUp`){let t=this.querySelector(`.post-menu-picker-search input`),r=i>0?n[i-1]:t;if(!r)return;e.preventDefault(),r.focus();return}if(e.key===` `||e.key===`Spacebar`){e.preventDefault(),this.#B(t);return}e.key===`Enter`&&(e.preventDefault(),this.#k())};#d=(e,t)=>{e.detail!==0&&this.#B(t)};#f=e=>{if(e.defaultPrevented||e.isComposing||e.altKey||e.ctrlKey||e.metaKey||e.key!==`ArrowUp`)return;let t=this.#c(),n=this.querySelector(`.post-menu-picker-search input`),r=t.at(-1)??n;r&&(e.preventDefault(),r.focus())};#p(e=`[data-post-menu-item-primary]`){this._view=`menu`,this.#s(e)}#m(){this._data?.isReply||(this._view=`visibility`,this.#s(`[data-post-menu-visibility-current='true'], [data-post-menu-visibility-option]`))}get#h(){return this.languages.length>1}#g(e){return e?this.languages.find(t=>t.tag===e)?.label??e:`Not set`}async#_(){this._data?.isReply||(this._view=`language`,this.#s(T),await this.#S(),this.contains(document.activeElement)||this.#s(T))}#v(e=`[data-post-menu-open-language-switch]`){this._view=`language`,this.#s(e)}#y(){this._data?.isReply||(this._view=`language-switch`,this.#s(`[data-post-menu-language-current='true'], [data-post-menu-language-option]`))}#b(){let e=this._data?.language??null,t=this._translations??[],n=new Set(t.flatMap(e=>e.language?[e.language]:[]));return{current:e,linked:t,selectable:this.languages.filter(t=>t.tag===e||!n.has(t.tag)),free:this.languages.filter(t=>t.tag!==e&&!n.has(t.tag))}}async#x(e){let t=this._data;if(t&&!this._translationBusy){this._translationBusy=!0;try{let n=await fetch(i(`/api/posts/${t.threadId}/language`),{method:`PUT`,headers:{"Content-Type":`application/json`},credentials:`same-origin`,body:JSON.stringify({language:e})});if(!n.ok){l(await y(n,`Could not change the language. Try again.`),`error`);return}let r=document.querySelector(`article[data-post-id="${t.threadId}"]`);r&&(r.dataset.postLanguage=e),this._data={...t,language:e},l(`Thread is now in ${this.#g(e)}.`),this.#k()}catch{l(`Could not change the language. Try again.`,`error`)}finally{this._translationBusy=!1}}}async#S(){let e=this._data;if(e){this._translationsLoading=!0;try{let t=await fetch(i(`/api/posts/${e.threadId}/translations`),{credentials:`same-origin`});if(!t.ok)return;let n=await t.json();this._translations=n.translations??[]}catch{this._translations=[]}finally{this._translationsLoading=!1}}}async#C(e){let t=this._data;if(!t)return;this.#k({restoreFocus:!1});let n=await g();if(n){await n.openTranslation(t.threadId,e);return}let r=new URLSearchParams({translationOf:t.threadId,lang:e});window.location.assign(i(`/new?${r.toString()}`))}async#w(){let e=this._data;if(!e)return;this.#k({restoreFocus:!1});let n=await xe({heading:`Link a translation`,hint:`Only posts you could actually link are listed: published, and in a language this one's group does not already have.`,placeholder:`Search your posts, or paste a URL…`,emptyHint:`Nothing matched that you could link.`,search:async n=>{if(t(n))return this.#T(e.threadId,n);let r=await fetch(i(`/api/posts/${e.threadId}/translations/candidates?q=${encodeURIComponent(n)}`),{credentials:`same-origin`});return r.ok?{items:((await r.json()).candidates??[]).map(e=>({id:e.id,label:e.label,meta:this.#g(e.language)}))}:{items:[]}}});n&&(this._data=e,await this.#D(n),window.location.reload())}async#T(e,t){let n;try{let r=await fetch(i(`/api/posts/${e}/translations/resolve?url=${encodeURIComponent(t)}`),{credentials:`same-origin`});if(!r.ok)throw Error(`HTTP ${r.status}`);({resolution:n}=await r.json())}catch{return{items:[],note:`Could not check that address. Try again in a moment.`}}return n?n.kind===`ok`?{items:[{id:n.candidate.id,label:n.candidate.label,meta:this.#g(n.candidate.language)}]}:{items:[],note:this.#E(n)}:{items:[]}}#E(e){let t=this.#g(`language`in e?e.language:null);switch(e.kind){case`external`:return`That address is somewhere else. Only posts on this site can be linked.`;case`not_found`:return`Nothing at ${e.address}. Check the address, or search by title.`;case`not_a_post`:return`That address is not a post. Translations link posts to posts.`;case`same_thread`:return`That is this post.`;case`unpublished`:return`That post is a draft. Publish it, then link it.`;case`no_language`:return`That post has no language yet. Set one on it first.`;case`same_language`:return`That post is written in ${this.#g(this._data?.language??null)} too. A translation has to be in another language.`;case`language_taken`:return`A ${t} version is already linked here. Unlink that one first.`;case`group_conflict`:return`That post belongs to another translation group. Unlink it first.`;case`group_language_taken`:return`Its translation group already has a ${t} version.`;default:return`That post cannot be linked.`}}async#D(e){let t=this._data;if(t&&!this._translationBusy){this._translationBusy=!0;try{let n=await fetch(i(`/api/posts/${t.threadId}/translations`),{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`same-origin`,body:JSON.stringify({postId:e})});if(!n.ok){l(await y(n,`Could not link those posts. Try again.`),`error`);return}await this.#S(),l(`Posts linked as translations.`)}catch{l(`Could not link those posts. Try again.`,`error`)}finally{this._translationBusy=!1}}}async#O(e){if(!this._data||this._translationBusy)return;let t=this._triggerEl;this.#k({restoreFocus:!1});let n=this.#g(e.language);if(!await u({message:`Unlink the ${n} version, “${e.label}”? Both posts stay published — they just stop pointing at each other.`,confirmLabel:`Unlink`,cancelLabel:`Cancel`,tone:`danger`})){t?.focus();return}this._translationBusy=!0;try{let n=await fetch(i(`/api/posts/${e.id}/translations`),{method:`DELETE`,credentials:`same-origin`});if(!n.ok){l(await y(n,`Could not unlink. Try again.`),`error`),t?.focus();return}l(`Translation link removed.`),window.location.reload()}catch{l(`Could not unlink. Try again.`,`error`),t?.focus()}finally{this._translationBusy=!1}}#k(e={}){let t=e.restoreFocus??this.#n,n=this._triggerEl;if(n?.setAttribute(`aria-expanded`,`false`),this._triggerEl=null,this.#n=!0,this._open=!1,this._view=`menu`,this._addCollectionPanelOpen=!1,this._collectionSearch=``,this._translations=null,this.#e){this.#e=!1,window.location.reload();return}t&&n?.focus()}openCollectionsForPost(e){let t=k(e);if(!t||t.isReply)return;this._data=t;let n=e.querySelector(`[data-post-menu-trigger]`);n&&(this._triggerEl=n,this.#n=!1,this.#r(),n.setAttribute(`aria-expanded`,`true`)),this._open=!0,this.#z()}async#A(){if(!this._data)return;let e=this._data.id;this.#k({restoreFocus:!1});let t=await g();t&&await t.openEdit(e)}#j(){let e=this._data?.permalink;this.#k(),e&&ae(e)}#M(){if(!this._data)return;let e=this._data.id,t=this._triggerEl;this.#k({restoreFocus:!1}),oe(e,t)}async#N(){if(!this._data)return;let e=this._data.id,t=this._triggerEl;this.#k({restoreFocus:!1});let n=document.querySelector(`article[data-post-id="${e}"]`);try{if(!(await fetch(`/api/posts/${e}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({status:`published`})})).ok)throw Error();l(`Draft published.`),(!n||!await ce(n))&&globalThis.location.reload()}catch{l(`Could not publish the draft. Try again.`,`error`),t?.focus()}}#P(e){if(!this._data)return;let t=this._data.id,n=this._data.visibility,r=document.querySelector(`article[data-post-id="${t}"]`);r&&(r.dataset.postVisibility=e),this._data={...this._data,visibility:e},l({public:`Post made public.`,latest_hidden:`Hidden from Latest.`,unlisted:`Post made unlisted.`,private:`Post made private.`}[e]??`Visibility updated.`),this.#k(),fetch(`/api/posts/${t}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({visibility:e})}).then(e=>{if(!e.ok)throw Error()}).catch(()=>{let e=document.querySelector(`article[data-post-id="${t}"]`);e&&(e.dataset.postVisibility=n),l(`Could not update visibility. Try again.`,`error`)})}#F(e){if(!this._data)return;let t=this._data.id,n=document.querySelector(`article[data-post-id="${t}"]`);n&&(e?n.setAttribute(`data-post-featured`,``):n.removeAttribute(`data-post-featured`)),this._data={...this._data,featured:e},l(e?`Added to Featured.`:`Removed from Featured.`),this.#k(),fetch(`/api/posts/${t}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({featured:e})}).then(e=>{if(!e.ok)throw Error()}).catch(()=>{let n=document.querySelector(`article[data-post-id="${t}"]`);n&&(e?n.removeAttribute(`data-post-featured`):n.setAttribute(`data-post-featured`,``)),l(`Could not update post. Try again.`,`error`)})}#I(){if(!this._data)return;let e=this._data.id,t=!this._data.pinned,n=document.querySelector(`article[data-post-id="${e}"]`);n&&(t?n.setAttribute(`data-post-pinned`,``):n.removeAttribute(`data-post-pinned`)),this._data={...this._data,pinned:t},l(t?`Post pinned.`:`Post unpinned.`),this.#k(),fetch(`/api/posts/${e}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pinned:t})}).then(e=>{if(!e.ok)throw Error()}).catch(()=>{let n=document.querySelector(`article[data-post-id="${e}"]`);n&&(t?n.removeAttribute(`data-post-pinned`):n.setAttribute(`data-post-pinned`,``)),l(`Could not update post. Try again.`,`error`)})}#L(){if(!this._data)return;let e=this._data.threadId,t=document.querySelector(`[data-collection-id]`)?.dataset.collectionId;if(!t)return;let n=!this._data.pinnedInCollection,r=O(e);r&&(n?r.setAttribute(`data-post-pinned-in-collection`,``):r.removeAttribute(`data-post-pinned-in-collection`)),this._data={...this._data,pinnedInCollection:n},l(n?`Pinned in collection.`:`Unpinned from collection.`),this.#k();let i=n?`PUT`:`DELETE`;fetch(`/api/collections/${t}/threads/${e}/pin`,{method:i}).then(e=>{if(!e.ok)throw Error()}).catch(()=>{let t=O(e);t&&(n?t.removeAttribute(`data-post-pinned-in-collection`):t.setAttribute(`data-post-pinned-in-collection`,``)),l(`Could not update pin. Try again.`,`error`)})}async#R(){if(!this._data)return;let e=this._triggerEl;if(this.#k({restoreFocus:!1}),!await u({message:this._data.isDraft?`Discard this draft permanently? This can't be undone.`:`Delete this post permanently? This can't be undone.`,confirmLabel:this._data.isDraft?`Discard`:`Delete`,cancelLabel:`Cancel`,tone:`danger`})){e?.focus();return}try{if(!(await fetch(`/api/posts/${this._data.id}`,{method:`DELETE`})).ok)throw Error();let e=document.querySelector(`article[data-post-id="${this._data.id}"]`),t=e?.closest(`.thread-item`),n=t?.closest(`.thread-group`);if(t&&n){if(t.remove(),n.querySelectorAll(`.thread-item:not(.thread-item-gap)`).length===0){let e=n.closest(`.feed-item`),t=e?.parentElement??null;(e??n).remove(),E(t)}}else{let t=e?.closest(`.feed-item`),n=t?.parentElement??null;(t??e)?.remove(),E(n)}l(`Post deleted.`)}catch{l(`Could not delete post. Try again.`,`error`),e?.focus()}}async#z(){if(!this._data||this._data.isReply)return;let e=this._data.id;this._view=`collections`,this._collectionSearch=``,this._collectionsLoading=!0,this.#s(`.post-menu-picker-search input, .post-menu-picker-option, [data-post-menu-add-collection]`);try{let[t,n]=await Promise.all([fetch(`/api/collections?view=compose`,{cache:`no-store`,headers:{Accept:`application/json`}}),fetch(`/api/posts/${e}`)]);if(!t.ok)throw Error();let r=(await t.json()).collections??[],i=this._threadCollectionIds;n.ok&&(i=(await n.json()).collectionIds??[]),this.#t=le(r,i),this._collections=r,this._threadCollectionIds=i}catch{this._collections=this._collections??[],l(`Could not load collections.`,`error`)}this._collectionsLoading=!1,this.#s(`.post-menu-picker-search input, .post-menu-picker-option, [data-post-menu-add-collection]`)}#B(e){if(!this._data)return;let t=this._data.threadId,n=this._threadCollectionIds.includes(e);this._threadCollectionIds=n?this._threadCollectionIds.filter(t=>t!==e):[...this._threadCollectionIds,e],this.#e=!0,l(n?`Removed from collection.`:`Added to collection.`),n?fetch(`/api/collections/${e}/threads/${t}`,{method:`DELETE`}).then(e=>{if(!e.ok)throw Error();return this.#K()}).catch(()=>{this._threadCollectionIds.includes(e)||(this._threadCollectionIds=[...this._threadCollectionIds,e]),l(`Could not remove from collection. Try again.`,`error`)}):fetch(`/api/collections/${e}/threads`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({threadId:t})}).then(e=>{if(!e.ok){if(e.status===409)return this.#K();throw Error()}return this.#K()}).catch(()=>{this._threadCollectionIds=this._threadCollectionIds.filter(t=>t!==e),l(`Could not add to collection. Try again.`,`error`)})}#V(){this._addCollectionPanelOpen=!0,this.updateComplete.then(()=>{let e=this.querySelector(`[data-collection-quick-dialog] [data-collection-title-input]`);e?.focus(),e?.select()})}#H(){this._addCollectionPanelOpen=!1,this.#r(),this.updateComplete.then(()=>{(this.querySelector(`[data-post-menu-add-collection]`)??this._triggerEl)?.focus()})}async#U(e){let t=e;t.stopPropagation();let n=t.detail;if(!n)return;let r=this.querySelector(`jant-collection-form`);r&&(r.loading=!0);try{let e=await fetch(`/api/collections`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n.data)}),t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||`Could not create collection. Try again.`);if(!t?.id||!t.title||!t.slug)throw Error(`Could not create collection. Try again.`);let r={id:t.id,title:t.title,slug:t.slug};this._collections=[...this._collections??[],r],this._data&&(await fetch(`/api/collections/${t.id}/threads`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({threadId:this._data.threadId})}),this._threadCollectionIds=[...this._threadCollectionIds,t.id]),await this.#K(),this.#e=!0,this.#H(),l(this.#W()?.createdLabel??`Collection created.`)}catch(e){l(e instanceof Error?e.message:`Could not create collection. Try again.`,`error`)}finally{r&&(r.loading=!1)}}#W(){return v()?.collectionFormLabels??null}#G(){return v()?.addCollection??`Add Collection`}async#K(){await(await g())?.refreshCollections()}#q(e){return w.find(t=>t.value===e)?.label??`Public`}#J(){return o`<svg
|
|
65
65
|
xmlns="http://www.w3.org/2000/svg"
|
|
66
66
|
viewBox="0 0 24 24"
|
|
67
67
|
fill="none"
|
|
@@ -72,7 +72,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
72
72
|
>
|
|
73
73
|
<path d="M12 19V5" />
|
|
74
74
|
<path d="m5 12 7-7 7 7" />
|
|
75
|
-
</svg>`}#Y(){return
|
|
75
|
+
</svg>`}#Y(){return o`<svg
|
|
76
76
|
xmlns="http://www.w3.org/2000/svg"
|
|
77
77
|
viewBox="0 0 24 24"
|
|
78
78
|
fill="none"
|
|
@@ -83,7 +83,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
83
83
|
>
|
|
84
84
|
<path d="M12 20h9" />
|
|
85
85
|
<path d="M16.5 3.5a2.12 2.12 0 1 1 3 3L7 19l-4 1 1-4Z" />
|
|
86
|
-
</svg>`}#X(){return
|
|
86
|
+
</svg>`}#X(){return o`<svg
|
|
87
87
|
xmlns="http://www.w3.org/2000/svg"
|
|
88
88
|
viewBox="0 0 24 24"
|
|
89
89
|
fill="none"
|
|
@@ -92,8 +92,8 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
92
92
|
stroke-linecap="round"
|
|
93
93
|
stroke-linejoin="round"
|
|
94
94
|
>
|
|
95
|
-
<path d=${
|
|
96
|
-
</svg>`}#Z(){return
|
|
95
|
+
<path d=${S} />
|
|
96
|
+
</svg>`}#Z(){return o`<svg
|
|
97
97
|
xmlns="http://www.w3.org/2000/svg"
|
|
98
98
|
viewBox="0 0 24 24"
|
|
99
99
|
fill="none"
|
|
@@ -103,9 +103,9 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
103
103
|
stroke-linecap="round"
|
|
104
104
|
stroke-linejoin="round"
|
|
105
105
|
>
|
|
106
|
-
<path d=${
|
|
107
|
-
<path d=${
|
|
108
|
-
</svg>`}#Q(){return
|
|
106
|
+
<path d=${S} />
|
|
107
|
+
<path d=${_e} />
|
|
108
|
+
</svg>`}#Q(){return o`<svg
|
|
109
109
|
xmlns="http://www.w3.org/2000/svg"
|
|
110
110
|
viewBox="0 0 24 24"
|
|
111
111
|
fill="none"
|
|
@@ -118,7 +118,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
118
118
|
<path
|
|
119
119
|
d="M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"
|
|
120
120
|
/>
|
|
121
|
-
</svg>`}#$(){return
|
|
121
|
+
</svg>`}#$(){return o`<svg
|
|
122
122
|
xmlns="http://www.w3.org/2000/svg"
|
|
123
123
|
viewBox="0 0 24 24"
|
|
124
124
|
fill="none"
|
|
@@ -131,7 +131,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
131
131
|
<line x1="12" x2="12" y1="17" y2="22" />
|
|
132
132
|
<path d="M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V17h12" />
|
|
133
133
|
<path d="M15 9.34V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0-1.4.6" />
|
|
134
|
-
</svg>`}#ee(){return
|
|
134
|
+
</svg>`}#ee(){return o`<svg
|
|
135
135
|
xmlns="http://www.w3.org/2000/svg"
|
|
136
136
|
viewBox="0 0 24 24"
|
|
137
137
|
fill="none"
|
|
@@ -143,7 +143,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
143
143
|
<path d="M3 6h18" />
|
|
144
144
|
<path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6" />
|
|
145
145
|
<path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2" />
|
|
146
|
-
</svg>`}#te(){return
|
|
146
|
+
</svg>`}#te(){return o`<svg
|
|
147
147
|
xmlns="http://www.w3.org/2000/svg"
|
|
148
148
|
viewBox="0 0 24 24"
|
|
149
149
|
fill="none"
|
|
@@ -153,7 +153,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
153
153
|
stroke-linejoin="round"
|
|
154
154
|
>
|
|
155
155
|
<path d="m15 18-6-6 6-6" />
|
|
156
|
-
</svg>`}#ne(){return
|
|
156
|
+
</svg>`}#ne(){return o`<svg
|
|
157
157
|
xmlns="http://www.w3.org/2000/svg"
|
|
158
158
|
viewBox="0 0 24 24"
|
|
159
159
|
fill="none"
|
|
@@ -163,7 +163,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
163
163
|
stroke-linejoin="round"
|
|
164
164
|
>
|
|
165
165
|
<path d="m9 18 6-6-6-6" />
|
|
166
|
-
</svg>`}#re(){return
|
|
166
|
+
</svg>`}#re(){return o`<svg
|
|
167
167
|
xmlns="http://www.w3.org/2000/svg"
|
|
168
168
|
viewBox="0 0 24 24"
|
|
169
169
|
fill="none"
|
|
@@ -173,7 +173,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
173
173
|
stroke-linejoin="round"
|
|
174
174
|
>
|
|
175
175
|
<path d="M20 6 9 17l-5-5" />
|
|
176
|
-
</svg>`}#ie(){return
|
|
176
|
+
</svg>`}#ie(){return o`<svg
|
|
177
177
|
xmlns="http://www.w3.org/2000/svg"
|
|
178
178
|
viewBox="0 0 24 24"
|
|
179
179
|
fill="none"
|
|
@@ -185,7 +185,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
185
185
|
<path d="M14 4h6v6" />
|
|
186
186
|
<path d="M20 4 11 13" />
|
|
187
187
|
<path d="M18 14v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4" />
|
|
188
|
-
</svg>`}#ae(){let e=this._collections??[],t=
|
|
188
|
+
</svg>`}#ae(){let e=this._collections??[],t=de(e,this.#t),n=this._collectionSearch.trim().length>0,r=pe(t,this._collectionSearch);return o`
|
|
189
189
|
<div
|
|
190
190
|
data-collection-picker
|
|
191
191
|
class="post-menu-view post-menu-collection-picker"
|
|
@@ -203,7 +203,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
203
203
|
<span>Collections</span>
|
|
204
204
|
</div>
|
|
205
205
|
</div>
|
|
206
|
-
${e.length>0?
|
|
206
|
+
${e.length>0?o`<div class="post-menu-picker-search">
|
|
207
207
|
<svg
|
|
208
208
|
width="14"
|
|
209
209
|
height="14"
|
|
@@ -227,13 +227,13 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
227
227
|
@keydown=${this.#l}
|
|
228
228
|
@input=${e=>{this._collectionSearch=e.target.value}}
|
|
229
229
|
/>
|
|
230
|
-
</div>`:
|
|
230
|
+
</div>`:s}
|
|
231
231
|
<div
|
|
232
232
|
class="post-menu-picker-list"
|
|
233
233
|
role="listbox"
|
|
234
234
|
aria-multiselectable="true"
|
|
235
235
|
>
|
|
236
|
-
${this._collectionsLoading?
|
|
236
|
+
${this._collectionsLoading?o`<div class="post-menu-picker-empty">Loading...</div>`:r.length>0?r.map(e=>{let t=this._threadCollectionIds.includes(e.id);return o`
|
|
237
237
|
<button
|
|
238
238
|
type="button"
|
|
239
239
|
role="option"
|
|
@@ -243,7 +243,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
243
243
|
@click=${t=>this.#d(t,e.id)}
|
|
244
244
|
>
|
|
245
245
|
<span class="post-menu-picker-title">${e.title}</span>
|
|
246
|
-
${t?
|
|
246
|
+
${t?o`<span
|
|
247
247
|
class="post-menu-picker-marker post-menu-picker-marker-selected"
|
|
248
248
|
>
|
|
249
249
|
<svg
|
|
@@ -266,7 +266,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
266
266
|
stroke-linejoin="round"
|
|
267
267
|
/>
|
|
268
268
|
</svg>
|
|
269
|
-
</span>`:
|
|
269
|
+
</span>`:o`<span
|
|
270
270
|
class="post-menu-picker-marker post-menu-picker-marker-add"
|
|
271
271
|
>
|
|
272
272
|
<svg
|
|
@@ -291,7 +291,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
291
291
|
</svg>
|
|
292
292
|
</span>`}
|
|
293
293
|
</button>
|
|
294
|
-
`}):
|
|
294
|
+
`}):o`<div class="post-menu-picker-empty">
|
|
295
295
|
${n?`No matching collections`:`No collections yet`}
|
|
296
296
|
</div>`}
|
|
297
297
|
</div>
|
|
@@ -319,7 +319,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
319
319
|
</button>
|
|
320
320
|
</div>
|
|
321
321
|
</div>
|
|
322
|
-
`}#oe(){if(!this._data||this._data.isReply)return
|
|
322
|
+
`}#oe(){if(!this._data||this._data.isReply)return s;let{current:e,linked:t,free:n}=this.#b();return o`
|
|
323
323
|
<div class="post-menu-view post-menu-language-panel">
|
|
324
324
|
<div class="post-menu-panel-header">
|
|
325
325
|
<button
|
|
@@ -337,7 +337,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
337
337
|
<div role="menu" class="post-menu-list">
|
|
338
338
|
<!-- Both sections stand or fall together: with every other language
|
|
339
339
|
spoken for there is nothing to switch to and nothing to add. -->
|
|
340
|
-
${n.length>0?
|
|
340
|
+
${n.length>0?o`
|
|
341
341
|
<div class="post-menu-section">
|
|
342
342
|
<button
|
|
343
343
|
type="button"
|
|
@@ -358,7 +358,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
358
358
|
</button>
|
|
359
359
|
</div>
|
|
360
360
|
<div class="post-menu-section">
|
|
361
|
-
${n.map((e,t)=>
|
|
361
|
+
${n.map((e,t)=>o`
|
|
362
362
|
<button
|
|
363
363
|
type="button"
|
|
364
364
|
role="menuitem"
|
|
@@ -390,11 +390,11 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
390
390
|
>
|
|
391
391
|
</button>
|
|
392
392
|
</div>
|
|
393
|
-
`:
|
|
394
|
-
${t.length>0?
|
|
393
|
+
`:s}
|
|
394
|
+
${t.length>0?o`
|
|
395
395
|
<div class="post-menu-section">
|
|
396
396
|
<p class="post-menu-section-label">Other versions</p>
|
|
397
|
-
${t.map(e=>{let t=this.#g(e.language);return
|
|
397
|
+
${t.map(e=>{let t=this.#g(e.language);return o`
|
|
398
398
|
<div class="post-menu-row" data-post-menu-translation>
|
|
399
399
|
<a
|
|
400
400
|
role="menuitem"
|
|
@@ -407,7 +407,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
407
407
|
>
|
|
408
408
|
<span
|
|
409
409
|
class="post-menu-item-label"
|
|
410
|
-
lang=${e.language??
|
|
410
|
+
lang=${e.language??s}
|
|
411
411
|
>${t}</span
|
|
412
412
|
>
|
|
413
413
|
<span
|
|
@@ -429,11 +429,11 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
429
429
|
</div>
|
|
430
430
|
`})}
|
|
431
431
|
</div>
|
|
432
|
-
`:
|
|
433
|
-
${this._translationsLoading?
|
|
432
|
+
`:s}
|
|
433
|
+
${this._translationsLoading?o`<p class="post-menu-hint">Loading…</p>`:s}
|
|
434
434
|
</div>
|
|
435
435
|
</div>
|
|
436
|
-
`}#se(){if(!this._data||this._data.isReply)return
|
|
436
|
+
`}#se(){if(!this._data||this._data.isReply)return s;let{current:e,selectable:t}=this.#b();return o`
|
|
437
437
|
<div
|
|
438
438
|
class="post-menu-view post-menu-language-panel post-menu-language-switch-panel"
|
|
439
439
|
>
|
|
@@ -456,7 +456,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
456
456
|
role="radiogroup"
|
|
457
457
|
aria-label="Language"
|
|
458
458
|
>
|
|
459
|
-
${t.map(t=>{let n=t.tag===e;return
|
|
459
|
+
${t.map(t=>{let n=t.tag===e;return o`
|
|
460
460
|
<button
|
|
461
461
|
type="button"
|
|
462
462
|
role="menuitemradio"
|
|
@@ -469,16 +469,16 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
469
469
|
@click=${()=>n?this.#v():this.#x(t.tag)}
|
|
470
470
|
>
|
|
471
471
|
<span class="post-menu-item-label">${t.label}</span>
|
|
472
|
-
${n?
|
|
472
|
+
${n?o`<span
|
|
473
473
|
class="post-menu-item-trailing post-menu-item-check"
|
|
474
474
|
>${this.#re()}</span
|
|
475
|
-
>`:
|
|
475
|
+
>`:s}
|
|
476
476
|
</button>
|
|
477
477
|
`})}
|
|
478
478
|
</div>
|
|
479
479
|
</div>
|
|
480
480
|
</div>
|
|
481
|
-
`}#ce(){if(!this._data||this._data.isReply)return
|
|
481
|
+
`}#ce(){if(!this._data||this._data.isReply)return s;let e=this._data.visibility;return o`
|
|
482
482
|
<div
|
|
483
483
|
data-visibility-panel
|
|
484
484
|
class="post-menu-view post-menu-visibility-panel"
|
|
@@ -498,57 +498,27 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
498
498
|
</div>
|
|
499
499
|
<div role="menu" class="post-menu-list">
|
|
500
500
|
<div class="post-menu-section">
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
type="button"
|
|
519
|
-
role="menuitemradio"
|
|
520
|
-
aria-checked=${e===`latest_hidden`?`true`:`false`}
|
|
521
|
-
data-post-menu-visibility-option
|
|
522
|
-
data-post-menu-visibility-current=${e===`latest_hidden`?`true`:`false`}
|
|
523
|
-
class=${`post-menu-item${e===`latest_hidden`?` post-menu-item-active`:``}`}
|
|
524
|
-
@click=${()=>e===`latest_hidden`?this.#p(`[data-post-menu-open-visibility]`):this.#P(`latest_hidden`)}
|
|
525
|
-
>
|
|
526
|
-
<span class="post-menu-item-label">Hidden from Latest</span>
|
|
527
|
-
${e===`latest_hidden`?s`<span
|
|
528
|
-
class="post-menu-item-trailing post-menu-item-check"
|
|
529
|
-
>${this.#re()}</span
|
|
530
|
-
>`:c}
|
|
531
|
-
</button>
|
|
532
|
-
|
|
533
|
-
<button
|
|
534
|
-
type="button"
|
|
535
|
-
role="menuitemradio"
|
|
536
|
-
aria-checked=${e===`private`?`true`:`false`}
|
|
537
|
-
data-post-menu-visibility-option
|
|
538
|
-
data-post-menu-visibility-current=${e===`private`?`true`:`false`}
|
|
539
|
-
class=${`post-menu-item${e===`private`?` post-menu-item-active`:``}`}
|
|
540
|
-
@click=${()=>e===`private`?this.#p(`[data-post-menu-open-visibility]`):this.#P(`private`)}
|
|
541
|
-
>
|
|
542
|
-
<span class="post-menu-item-label">Private</span>
|
|
543
|
-
${e===`private`?s`<span
|
|
544
|
-
class="post-menu-item-trailing post-menu-item-check"
|
|
545
|
-
>${this.#re()}</span
|
|
546
|
-
>`:c}
|
|
547
|
-
</button>
|
|
501
|
+
${w.map(({value:t,label:n})=>{let r=e===t;return o`
|
|
502
|
+
<button
|
|
503
|
+
type="button"
|
|
504
|
+
role="menuitemradio"
|
|
505
|
+
aria-checked=${r?`true`:`false`}
|
|
506
|
+
data-post-menu-visibility-option
|
|
507
|
+
data-post-menu-visibility-current=${r?`true`:`false`}
|
|
508
|
+
class=${`post-menu-item${r?` post-menu-item-active`:``}`}
|
|
509
|
+
@click=${()=>r?this.#p(`[data-post-menu-open-visibility]`):this.#P(t)}
|
|
510
|
+
>
|
|
511
|
+
<span class="post-menu-item-label">${n}</span>
|
|
512
|
+
${r?o`<span
|
|
513
|
+
class="post-menu-item-trailing post-menu-item-check"
|
|
514
|
+
>${this.#re()}</span
|
|
515
|
+
>`:s}
|
|
516
|
+
</button>
|
|
517
|
+
`})}
|
|
548
518
|
</div>
|
|
549
519
|
</div>
|
|
550
520
|
</div>
|
|
551
|
-
`}#le(){let e=this.#W();return e?
|
|
521
|
+
`}#le(){let e=this.#W();return e?o`
|
|
552
522
|
<div
|
|
553
523
|
class="collection-quick-dialog-backdrop"
|
|
554
524
|
@click=${()=>this.#H()}
|
|
@@ -596,7 +566,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
596
566
|
</button>
|
|
597
567
|
</div>
|
|
598
568
|
</div>
|
|
599
|
-
`:
|
|
569
|
+
`:s}#ue(){if(!this._data)return s;let e=this._data.visibility,t=this._data.pinned,n=this._data.pinnedInCollection,r=document.querySelector(`[data-collection-id]`)?.dataset.collectionId,i=this._data.featured,a=!this._data.isDraft&&!!this._data.permalink,c=D(this._data);return o`
|
|
600
570
|
<div class="post-menu-view post-menu-main">
|
|
601
571
|
<div role="menu" class="post-menu-list">
|
|
602
572
|
<div class="post-menu-section">
|
|
@@ -611,7 +581,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
611
581
|
<span class="post-menu-item-trailing">${this.#Y()}</span>
|
|
612
582
|
</button>
|
|
613
583
|
|
|
614
|
-
${this._data.isDraft?
|
|
584
|
+
${this._data.isDraft?o`
|
|
615
585
|
<button
|
|
616
586
|
type="button"
|
|
617
587
|
role="menuitem"
|
|
@@ -623,8 +593,8 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
623
593
|
>${this.#J()}</span
|
|
624
594
|
>
|
|
625
595
|
</button>
|
|
626
|
-
`:
|
|
627
|
-
${this._data.isReply?
|
|
596
|
+
`:s}
|
|
597
|
+
${this._data.isReply?s:o`
|
|
628
598
|
<button
|
|
629
599
|
type="button"
|
|
630
600
|
role="menuitem"
|
|
@@ -641,7 +611,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
641
611
|
>
|
|
642
612
|
</button>
|
|
643
613
|
`}
|
|
644
|
-
${this._data.isReply?
|
|
614
|
+
${this._data.isReply?s:o`
|
|
645
615
|
<button
|
|
646
616
|
type="button"
|
|
647
617
|
role="menuitem"
|
|
@@ -659,7 +629,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
659
629
|
>
|
|
660
630
|
</button>
|
|
661
631
|
`}
|
|
662
|
-
${this._data.isReply||!this.#h?
|
|
632
|
+
${this._data.isReply||!this.#h?s:o`
|
|
663
633
|
<button
|
|
664
634
|
type="button"
|
|
665
635
|
role="menuitem"
|
|
@@ -680,7 +650,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
680
650
|
</div>
|
|
681
651
|
|
|
682
652
|
<div class="post-menu-section">
|
|
683
|
-
${this._data.isDraft?
|
|
653
|
+
${this._data.isDraft?s:o`
|
|
684
654
|
<button
|
|
685
655
|
type="button"
|
|
686
656
|
role="menuitem"
|
|
@@ -695,7 +665,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
695
665
|
>
|
|
696
666
|
</button>
|
|
697
667
|
`}
|
|
698
|
-
${this._data.isReply?
|
|
668
|
+
${this._data.isReply?s:o`
|
|
699
669
|
<button
|
|
700
670
|
type="button"
|
|
701
671
|
role="menuitem"
|
|
@@ -710,7 +680,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
710
680
|
>
|
|
711
681
|
</button>
|
|
712
682
|
`}
|
|
713
|
-
${r&&!this._data.isReply?
|
|
683
|
+
${r&&!this._data.isReply?o`
|
|
714
684
|
<button
|
|
715
685
|
type="button"
|
|
716
686
|
role="menuitem"
|
|
@@ -724,12 +694,12 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
724
694
|
>${n?this.#$():this.#Q()}</span
|
|
725
695
|
>
|
|
726
696
|
</button>
|
|
727
|
-
`:
|
|
697
|
+
`:s}
|
|
728
698
|
</div>
|
|
729
699
|
|
|
730
|
-
${a||o
|
|
700
|
+
${a||c?o`
|
|
731
701
|
<div class="post-menu-section">
|
|
732
|
-
${a?
|
|
702
|
+
${a?o`<button
|
|
733
703
|
type="button"
|
|
734
704
|
role="menuitem"
|
|
735
705
|
class="post-menu-item"
|
|
@@ -738,10 +708,10 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
738
708
|
>
|
|
739
709
|
<span class="post-menu-item-label">Copy link</span>
|
|
740
710
|
<span class="post-menu-item-trailing"
|
|
741
|
-
>${
|
|
711
|
+
>${te()}</span
|
|
742
712
|
>
|
|
743
|
-
</button>`:
|
|
744
|
-
${o
|
|
713
|
+
</button>`:s}
|
|
714
|
+
${c?o`<button
|
|
745
715
|
type="button"
|
|
746
716
|
role="menuitem"
|
|
747
717
|
class="post-menu-item"
|
|
@@ -752,11 +722,11 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
752
722
|
>Share as image</span
|
|
753
723
|
>
|
|
754
724
|
<span class="post-menu-item-trailing"
|
|
755
|
-
>${
|
|
725
|
+
>${ne()}</span
|
|
756
726
|
>
|
|
757
|
-
</button>`:
|
|
727
|
+
</button>`:s}
|
|
758
728
|
</div>
|
|
759
|
-
`:
|
|
729
|
+
`:s}
|
|
760
730
|
|
|
761
731
|
<div class="post-menu-section post-menu-section-danger">
|
|
762
732
|
<button
|
|
@@ -773,8 +743,8 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
773
743
|
</div>
|
|
774
744
|
</div>
|
|
775
745
|
</div>
|
|
776
|
-
`}render(){if(!this._open||!this._data)return
|
|
777
|
-
${n?
|
|
746
|
+
`}render(){if(!this._open||!this._data)return s;let e=this._openAbove?`transform:translate(-100%, -100%);`:`transform:translateX(-100%);`,t=`position:absolute;z-index:100;left:${Math.round(this._x)}px;top:${Math.round(this._y)}px;${e}`,n=!this._addCollectionPanelOpen;return o`
|
|
747
|
+
${n?o`
|
|
778
748
|
<div
|
|
779
749
|
class="post-menu-backdrop"
|
|
780
750
|
@click=${()=>this.#k({restoreFocus:!1})}
|
|
@@ -788,30 +758,30 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
788
758
|
${this._view===`collections`?this.#ae():this._view===`visibility`?this.#ce():this._view===`language`?this.#oe():this._view===`language-switch`?this.#se():this.#ue()}
|
|
789
759
|
</div>
|
|
790
760
|
</div>
|
|
791
|
-
`:
|
|
792
|
-
${this._addCollectionPanelOpen?this.#le():
|
|
793
|
-
`}};customElements.define(`jant-post-menu`,
|
|
761
|
+
`:s}
|
|
762
|
+
${this._addCollectionPanelOpen?this.#le():s}
|
|
763
|
+
`}};customElements.define(`jant-post-menu`,Ce);var A=`xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"`,j={post:`<svg ${A}><path d="M8 2v4"/><path d="M12 2v4"/><path d="M16 2v4"/><rect width="16" height="18" x="4" y="4" rx="2"/><path d="M8 10h6"/><path d="M8 14h8"/><path d="M8 18h5"/></svg>`,collection:`<svg ${A} viewBox="0 0 16 16" stroke-width="1.35"><rect x="3" y="5.05" width="10" height="8.15" rx="2.2"/><path d="M5.1 5.05V4.2a1.1 1.1 0 0 1 1.1-1.1h3.6a1.1 1.1 0 0 1 1.1 1.1v.85"/></svg>`,smart_collection:`<svg ${A}><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>`,system:`<svg ${A}><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>`,command:`<svg ${A}><path d="M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"/></svg>`,path:`<svg ${A}><polyline points="15 10 20 15 15 20"/><path d="M4 4v7a4 4 0 0 0 4 4h12"/></svg>`,search:`<svg ${A}><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`};function we(e){let t=e.trim().replace(/^[//]+/,``);return t?`/${t}`:`/`}function M(t){let i=t.trim();return r(i)?e(i,{siteOrigins:[window.location.origin],sitePathPrefix:n(),keepQuery:!0}):null}function Te(e){return e.trim().replace(/^[//]+/,``).trim()}var Ee=5;function N(e){try{let t=globalThis.localStorage.getItem(e);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e):[]}catch{return[]}}function P(e,t){let n=N(e).filter(e=>e!==t);n.unshift(t),globalThis.localStorage.setItem(e,JSON.stringify(n.slice(0,Ee)))}var F=`jant:nav-history`,I=`jant:search-history`,De=[{title:`Home`,path:`/`,type:`system`},{title:`Featured`,path:`/featured`,type:`system`},{title:`Latest`,path:`/latest`,type:`system`},{title:`Archive`,path:`/archive`,type:`system`},{title:`Collections`,path:`/collections`,type:`system`},{title:`Settings`,path:`/settings`,type:`system`},{title:`General`,path:`/settings/general`,type:`system`},{title:`Navigation`,path:ge,type:`system`},{title:`Appearance`,path:`/settings/appearance/color-theme`,type:`system`},{title:`Custom URLs`,path:`/settings/custom-urls`,type:`system`},{title:`API Tokens`,path:`/settings/api-tokens`,type:`system`},{title:`Sessions`,path:`/settings/sessions`,type:`system`},{title:`Account`,path:`/settings/account`,type:`system`}],Oe=[{label:`New Post`,icon:j.command,action:()=>void m()}],ke=class extends c{static properties={_open:{state:!0},_query:{state:!0},_selectedIndex:{state:!0},_loading:{state:!0}};#e=null;createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this._open=!1,this._query=``,this._selectedIndex=0,this._loading=!1}connectedCallback(){super.connectedCallback(),this.#t()}async#t(){if(!this.#e)try{let e=await fetch(`/api/palette`);if(e.ok){let t=await e.json();this.#e=t.items}else this.#e=[]}catch{this.#e=[]}}async open(){if(this._open)return;this.#e||(this._loading=!0,await this.#t(),this._loading=!1),this._open=!0,this._query=``,this._selectedIndex=0,await this.updateComplete;let e=this.querySelector(`.command-palette`);e&&!e.open&&e.showModal(),this.querySelector(`.command-palette-input`)?.focus()}close(){let e=this.querySelector(`.command-palette`);e?.open&&e.close(),this._open=!1,this._query=``,this._selectedIndex=0}get#n(){let e=this._query.charAt(0);return e===`>`||e===`>`?`command`:e===`?`||e===`?`?`search`:e===`/`||e===`/`||M(this._query)?`path`:`navigate`}get#r(){let e=b(this._query),t=[...this.#e??[],...De];if(!e){let e=N(F);if(e.length===0)return t;let n=new Set(e),r=[],i=[];for(let e of t)n.has(e.path)?r.push(e):i.push(e);return r.sort((t,n)=>e.indexOf(t.path)-e.indexOf(n.path)),[...r,...i]}return t.map((t,n)=>({item:t,index:n,rank:he([t.title,t.path],e)})).filter(e=>e.rank!==null).sort((e,t)=>e.rank-t.rank||e.index-t.index).map(e=>e.item)}get#i(){let e=b(this._query.slice(1));return Oe.filter(t=>!e||t.label.toLowerCase().includes(e))}get#a(){let e=this.#n;if(e===`command`)return this.#i.map(e=>({label:e.label,icon:e.icon}));if(e===`search`){let e=this._query.slice(1).trim();return e?[{label:`Search for "${e}"`,icon:j.search,searchQuery:e}]:N(I).map(e=>({label:e,icon:j.search,searchQuery:e}))}if(e===`path`){let e=M(this._query),t=e??we(this._query),n=e?``:Te(this._query),r=[{label:`Go to ${t}`,icon:j.path,pathTarget:t}];return n&&r.push({label:`Search for "${n}"`,icon:j.search,searchQuery:n}),r}let t=b(this._query),n=this.#r.map(e=>({label:e.title,secondary:e.status===`draft`?`Draft · ${e.path}`:e.path,icon:j[e.type]}));return t&&n.push({label:`Search all content for "${this._query.trim()}"`,icon:j.search,searchQuery:this._query.trim(),placement:`footer`,...n.length>0?{shortcut:`⌘/Ctrl ↵`}:{}}),n}#o(e){P(I,e),this.close(),window.location.href=a(`/search?q=${encodeURIComponent(e)}`)}#s(e){let t=this.#n;if(t===`command`){let t=this.#i[e];t&&(this.close(),t.action());return}if(t===`search`){let t=this.#a[e]?.searchQuery;t&&this.#o(t);return}if(t===`path`){let t=this.#a[e];if(t?.pathTarget){P(F,t.pathTarget),this.close(),window.location.href=a(t.pathTarget);return}t?.searchQuery&&this.#o(t.searchQuery);return}let n=this.#a[e];if(n?.searchQuery){this.#o(n.searchQuery);return}let r=this.#r[e];r&&(P(F,r.path),this.close(),r.type===`system`?window.location.href=a(r.path):r.type===`collection`?window.location.href=a(`/collections/${r.path}`):r.type===`smart_collection`?window.location.href=a(`/${r.path}`):window.location.href=a(r.status===`draft`?`/preview/${r.path}?edit=1`:`/${r.path}`))}#c=e=>{let t=e.target;this._query=t.value,this._selectedIndex=0};#l=e=>{if(e.isComposing||e.keyCode===229)return;let t=this.#a;if(e.key===`ArrowDown`){e.preventDefault(),this._selectedIndex=t.length>0?(this._selectedIndex+1)%t.length:0,this.#p();return}if(e.key===`ArrowUp`){e.preventDefault(),this._selectedIndex=t.length>0?(this._selectedIndex-1+t.length)%t.length:0,this.#p();return}if(e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&this.#n===`navigate`){let t=this._query.trim();if(t){e.preventDefault(),this.#o(t);return}}if(e.key===`Enter`){e.preventDefault(),this.#s(this._selectedIndex);return}if(e.key===`Tab`){e.preventDefault();return}if(e.key===`Escape`){e.preventDefault(),this.close();return}};#u=e=>{e.preventDefault(),this.close()};#d=e=>{e.target===e.currentTarget&&this.close()};#f(e){return()=>this.#s(e)}#p(){requestAnimationFrame(()=>{this.querySelector(`.command-palette-result-selected`)?.scrollIntoView({block:`nearest`})})}#m(e,t,n=!1){return o`
|
|
794
764
|
<div
|
|
795
765
|
id="command-palette-item-${t}"
|
|
796
|
-
class=${
|
|
766
|
+
class=${x({"command-palette-result":!0,"command-palette-result-selected":t===this._selectedIndex,"command-palette-search-action":n})}
|
|
797
767
|
role="option"
|
|
798
768
|
aria-selected=${t===this._selectedIndex}
|
|
799
769
|
@click=${this.#f(t)}
|
|
800
770
|
>
|
|
801
|
-
<span class="command-palette-result-icon">${
|
|
771
|
+
<span class="command-palette-result-icon">${_(e.icon)}</span>
|
|
802
772
|
<span class="command-palette-result-body">
|
|
803
773
|
<span class="command-palette-result-title">${e.label}</span>
|
|
804
|
-
${e.secondary?
|
|
774
|
+
${e.secondary?o`<span class="command-palette-result-path"
|
|
805
775
|
>${e.secondary}</span
|
|
806
|
-
>`:
|
|
776
|
+
>`:s}
|
|
807
777
|
</span>
|
|
808
|
-
${e.shortcut?
|
|
778
|
+
${e.shortcut?o`<kbd
|
|
809
779
|
class="command-palette-result-shortcut"
|
|
810
780
|
aria-label="Command or Control plus Enter"
|
|
811
781
|
>${e.shortcut}</kbd
|
|
812
|
-
>`:
|
|
782
|
+
>`:s}
|
|
813
783
|
</div>
|
|
814
|
-
`}render(){if(!this._open)return
|
|
784
|
+
`}render(){if(!this._open)return s;let e=this.#a,t=e.map((e,t)=>({item:e,index:t})).filter(({item:e})=>e.placement!==`footer`),n=e.map((e,t)=>({item:e,index:t})).filter(({item:e})=>e.placement===`footer`);return o`
|
|
815
785
|
<dialog
|
|
816
786
|
class="command-palette"
|
|
817
787
|
@cancel=${this.#u}
|
|
@@ -824,7 +794,7 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
824
794
|
>
|
|
825
795
|
<div class="command-palette-input-wrapper">
|
|
826
796
|
<span class="command-palette-search-icon"
|
|
827
|
-
>${
|
|
797
|
+
>${_(j.search)}</span
|
|
828
798
|
>
|
|
829
799
|
<input
|
|
830
800
|
type="text"
|
|
@@ -839,21 +809,21 @@ import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM
|
|
|
839
809
|
autocomplete="off"
|
|
840
810
|
spellcheck="false"
|
|
841
811
|
/>
|
|
842
|
-
${this._loading?
|
|
812
|
+
${this._loading?o`<span class="command-palette-spinner"></span>`:s}
|
|
843
813
|
</div>
|
|
844
814
|
|
|
845
|
-
${e.length>0?
|
|
815
|
+
${e.length>0?o`
|
|
846
816
|
<div
|
|
847
817
|
id="command-palette-results"
|
|
848
818
|
class="command-palette-results-container"
|
|
849
819
|
role="listbox"
|
|
850
820
|
>
|
|
851
|
-
${t.length>0?
|
|
821
|
+
${t.length>0?o`<div class="command-palette-results">
|
|
852
822
|
${t.map(({item:e,index:t})=>this.#m(e,t))}
|
|
853
|
-
</div>`:
|
|
823
|
+
</div>`:s}
|
|
854
824
|
${n.map(({item:e,index:t})=>this.#m(e,t,!0))}
|
|
855
825
|
</div>
|
|
856
|
-
`:this._query.trim()&&!this._loading?
|
|
826
|
+
`:this._query.trim()&&!this._loading?o`<div class="command-palette-empty">No results</div>`:s}
|
|
857
827
|
</div>
|
|
858
828
|
</dialog>
|
|
859
|
-
`}};customElements.get(`jant-command-palette`)||customElements.define(`jant-command-palette`,
|
|
829
|
+
`}};customElements.get(`jant-command-palette`)||customElements.define(`jant-command-palette`,ke),document.addEventListener(`keydown`,e=>{if(e.key.toLowerCase()!==`k`||!(e.metaKey||e.ctrlKey)||e.altKey||e.shiftKey||e.defaultPrevented||e.isComposing)return;e.preventDefault();let t=document.querySelector(`jant-command-palette`);if(t){if(t.querySelector(`dialog[open]`)){t.close();return}document.querySelector(`dialog[open]`)||t.open()}}),document.addEventListener(`click`,e=>{let t=e.target;if(!(t instanceof globalThis.Element)||!t.closest(`.site-header-search-link`)||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0||e.defaultPrevented)return;let n=document.querySelector(`jant-command-palette`);n&&(document.querySelector(`dialog[open]`)||(e.preventDefault(),n.open()))}),document.addEventListener(`click`,e=>{let t=e.target instanceof globalThis.Element?e.target:null;if(!t)return;let n=t.closest(`[data-compose-open]`);if(n){let e=n.dataset.composeCollectionId;m(e?{collectionId:e}:void 0);return}let r=t.closest(`[data-reply-trigger]`);if(r){let e=r.closest(`article[data-post]`);e&&d(e);return}let i=t.closest(`[data-draft-continue]`);if(i){let e=i.dataset.postId??i.closest(`article[data-post]`)?.dataset.postId;e&&h(e)}});var L=`.compose-prompt`,Ae=`.compose-prompt-trigger`,R=`jant.composeOpenShortcutDiscovery`,je=`/api/settings/discovery/compose-open-shortcut`,Me=350,Ne=1800,z=3,B=`compose-prompt-discovery-visible`,V=!1,H=null,U=null,W=null;function G(){try{return globalThis.localStorage!==void 0}catch{return!1}}function K(){if(!G())return{shownCount:0,completed:!1};let e=globalThis.localStorage.getItem(R);if(!e)return{shownCount:0,completed:!1};try{let t=JSON.parse(e);return{shownCount:typeof t.shownCount==`number`&&t.shownCount>=0?t.shownCount:0,completed:t.completed===!0}}catch{return globalThis.localStorage.removeItem(R),{shownCount:0,completed:!1}}}function q(e){if(G())try{globalThis.localStorage.setItem(R,JSON.stringify(e))}catch{}}function J(){H!==null&&(clearTimeout(H),H=null)}function Pe(){U!==null&&(clearTimeout(U),U=null)}function Fe(){return typeof globalThis.matchMedia==`function`&&globalThis.matchMedia(`(min-width: 700px)`).matches}function Ie(e){return K().completed?!0:e?.dataset.composeOpenShortcutDiscovered===`true`}function Le(e){e&&(e.dataset.composeOpenShortcutDiscovered=`true`,e.classList.remove(B)),document.querySelectorAll(L).forEach(e=>{e.dataset.composeOpenShortcutDiscovered=`true`,e.classList.remove(B)})}function Re(){let e=K();e.completed||V||e.shownCount>=z||(V=!0,q({...e,shownCount:e.shownCount+1}))}function Y(e){return!Fe()||Ie(e)?!1:K().shownCount<z||V}function X(e){J(),Pe(),e?e.classList.remove(B):W&&W.classList.remove(B),(!e||e===W)&&(W=null)}function ze(e){Y(e)&&(X(W),W=e,e.classList.add(B),Re(),U=setTimeout(()=>{X(e)},Ne))}function Z(e){Y(e)&&(e.classList.contains(B)||(J(),H=setTimeout(()=>{ze(e)},Me)))}function Be(e){if(e.dataset.composeOpenShortcutDiscoveryBound===`true`)return;let t=e.querySelector(Ae);t&&(e.dataset.composeOpenShortcutDiscoveryBound=`true`,t.addEventListener(`pointerenter`,()=>{Z(e)}),t.addEventListener(`pointerleave`,()=>{X(e)}),t.addEventListener(`focusin`,()=>{Z(e)}),t.addEventListener(`focusout`,()=>{X(e)}))}function Q(e=document){e.querySelectorAll(L).forEach(e=>Be(e))}function Ve(){let e=K();e.completed||q({shownCount:Math.max(e.shownCount,z),completed:!0}),Le(W),X(W),typeof globalThis.fetch==`function`&&globalThis.fetch(je,{method:`POST`,headers:{Accept:`application/json`},credentials:`same-origin`}).catch(()=>{})}var He=[`input`,`textarea`,`select`,`button`,`a[href]`,`[contenteditable='']`,`[contenteditable='true']`,`[role='textbox']`,`.ProseMirror`].join(`, `);function Ue(e){return e instanceof globalThis.Element&&e.closest(He)!==null}function We(e){if(e.defaultPrevented||e.isComposing||e.repeat||e.metaKey||e.ctrlKey||e.altKey||!f()||document.querySelector(`.compose-page`)||document.querySelector(`dialog[open]`))return!0;let t=document.activeElement;return Ue(e.target)||t!==e.target&&Ue(t)}function Ge(){return new URL(window.location.href).searchParams.get(`edit`)===`1`}function Ke(){let e=new URL(window.location.href);e.searchParams.delete(`edit`);let t=e.searchParams.toString();globalThis.history.replaceState(globalThis.history.state,``,`${e.pathname}${t?`?${t}`:``}${e.hash}`)}function $(){if(!document.body?.hasAttribute(`data-authenticated`)||!Ge())return;let e=p()?.dataset.postId;e&&f()&&(Ke(),document.querySelector(`[data-preview-status]`)?ue(e):h(e))}async function qe(e,t,n){try{if(!(await fetch(`/api/posts/${e}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({featured:t})})).ok)throw Error();t?n.setAttribute(`data-post-featured`,``):n.removeAttribute(`data-post-featured`),l(t?`Added to Featured.`:`Removed from Featured.`)}catch{l(`Could not update post. Try again.`,`error`)}}document.addEventListener(`keydown`,e=>{let t=e.key.toLowerCase();if(t!==`n`&&t!==`l`&&t!==`q`&&t!==`r`&&t!==`e`&&t!==`c`&&t!==`f`||We(e))return;if(t===`n`||t===`l`||t===`q`){e.preventDefault(),Ve();let n=me(),r=t===`l`?`link`:t===`q`?`quote`:void 0;m({...n?{collectionId:n}:void 0,...r?{initialFormat:r}:void 0});return}if(t===`r`){let t=fe();if(!t)return;e.preventDefault(),d(t);return}let n=p();if(n){if(t===`e`){let t=n.dataset.postId;if(!t)return;e.preventDefault(),h(t);return}if(t===`c`){e.preventDefault();let t=document.querySelector(`jant-post-menu`);t&&t.openCollectionsForPost(n);return}if(t===`f`){let t=n.dataset.postId;if(!t)return;e.preventDefault(),qe(t,!n.hasAttribute(`data-post-featured`),n);return}}}),document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,$,{once:!0}):$(),document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>{Q()}):Q(),se(),document.querySelector(`jant-command-palette`)||document.body.appendChild(document.createElement(`jant-command-palette`)),ee();
|