@jant/core 1.1.0 → 1.3.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 (196) hide show
  1. package/bin/commands/site/import.js +2 -1
  2. package/bin/lib/site-snapshot.js +10 -0
  3. package/dist/{app-CKQ9PqAr.js → app-C8dETvgL.js} +9267 -5697
  4. package/dist/client/.vite/manifest.json +82 -93
  5. package/dist/client/_assets/chunks/{confirm-CMe01lne.js → confirm-BQebcuNB.js} +1 -1
  6. package/dist/client/_assets/chunks/{create-editor-BQkrw8Ax.js → create-editor-B8KuszlS.js} +38 -38
  7. package/dist/client/_assets/chunks/footnote-rail-DUrqz0Py.js +2 -0
  8. package/dist/client/_assets/chunks/{jant-locale-picker-2L4rkDaz.js → jant-locale-picker-CLq0iKDH.js} +1 -1
  9. package/dist/client/_assets/chunks/lit-BN4mrI3j.js +2 -0
  10. package/dist/client/_assets/chunks/{settings-paths-B0bNUaih.js → settings-paths-_fry4yWW.js} +1 -1
  11. package/dist/client/_assets/chunks/{slug-format-CYmQE5ln.js → slug-format-bcJ2ozr4.js} +1 -1
  12. package/dist/client/_assets/chunks/sortable-list-Bz2Na2E9.js +2 -0
  13. package/dist/client/_assets/chunks/types-DrYFqJH2.js +1 -0
  14. package/dist/client/_assets/chunks/{unsafe-html-CWos3v6N.js → unsafe-html-OJ9m154w.js} +1 -1
  15. package/dist/client/_assets/chunks/unsafe-svg-DVJ4NPcb.js +1 -0
  16. package/dist/client/_assets/client-CoNHvipV.css +2 -0
  17. package/dist/client/_assets/{client-auth-CG55rWb5.js → client-auth-CbnZkLJ6.js} +99 -129
  18. package/dist/client/_assets/{client-author-CGVvrNZ8.css → client-author-2WYBkgni.css} +1 -1
  19. package/dist/client/_assets/client-compose-DYtDlYm-.js +2008 -0
  20. package/dist/client/_assets/{client-manage-DnYdQAhf.js → client-manage-BODyYP5Z.js} +157 -157
  21. package/dist/client/_assets/client-pq6sVS7y.js +354 -0
  22. package/dist/client/_assets/{client-settings-CHgsIqXJ.js → client-settings-DDpe_tXJ.js} +166 -166
  23. package/dist/client/_assets/client-share-B9OsXx9p.js +149 -0
  24. package/dist/{constants-DEgyqWDl.js → constants-C2CdWAqt.js} +55 -5
  25. package/dist/index.js +1 -1
  26. package/dist/node.js +3 -2
  27. package/package.json +2 -1
  28. package/src/app.tsx +9 -0
  29. package/src/client/components/compose-types.ts +6 -1
  30. package/src/client/components/jant-compose-dialog.ts +26 -4
  31. package/src/client/components/jant-compose-editor.ts +30 -0
  32. package/src/client/components/jant-compose-fullscreen.ts +1 -0
  33. package/src/client/components/jant-media-lightbox.ts +18 -3
  34. package/src/client/components/jant-nav-manager.ts +2 -0
  35. package/src/client/components/jant-post-menu.ts +42 -89
  36. package/src/client/components/nav-manager-types.ts +2 -0
  37. package/src/client/components/settings-types.ts +1 -1
  38. package/src/client/compose-bridge.ts +61 -1
  39. package/src/client/feed-video-player.ts +6 -0
  40. package/src/client/list-views.ts +382 -0
  41. package/src/client/media-lightbox-events.ts +12 -0
  42. package/src/client/runtime-paths.ts +12 -0
  43. package/src/client/share-capture.ts +63 -0
  44. package/src/client/share-launch.ts +36 -9
  45. package/src/client/tiptap/bubble-menu.ts +25 -2
  46. package/src/client/tiptap/create-editor.ts +6 -0
  47. package/src/client/tiptap/embed-node.ts +3 -1
  48. package/src/client/tiptap/extensions.ts +4 -0
  49. package/src/client/tiptap/html-block-node.ts +3 -1
  50. package/src/client/tiptap/image-node.ts +3 -1
  51. package/src/client/video-processor.ts +106 -52
  52. package/src/client/view-confirm.ts +136 -0
  53. package/src/client.ts +2 -0
  54. package/src/db/migrations/0035_brainy_next_avengers.sql +9 -0
  55. package/src/db/migrations/0036_gorgeous_smasher.sql +7 -0
  56. package/src/db/migrations/0037_round_post.sql +16 -0
  57. package/src/db/migrations/0038_flashy_changeling.sql +15 -0
  58. package/src/db/migrations/0039_mixed_sister_grimm.sql +1 -0
  59. package/src/db/migrations/meta/0035_snapshot.json +2877 -0
  60. package/src/db/migrations/meta/0036_snapshot.json +2924 -0
  61. package/src/db/migrations/meta/0037_snapshot.json +2932 -0
  62. package/src/db/migrations/meta/0038_snapshot.json +2924 -0
  63. package/src/db/migrations/meta/0039_snapshot.json +2931 -0
  64. package/src/db/migrations/meta/_journal.json +35 -0
  65. package/src/db/migrations/pg/0033_cute_magdalene.sql +10 -0
  66. package/src/db/migrations/pg/0034_material_agent_brand.sql +8 -0
  67. package/src/db/migrations/pg/0035_flimsy_outlaw_kid.sql +3 -0
  68. package/src/db/migrations/pg/0036_milky_wolverine.sql +5 -0
  69. package/src/db/migrations/pg/0037_fuzzy_hammerhead.sql +1 -0
  70. package/src/db/migrations/pg/meta/0033_snapshot.json +3719 -0
  71. package/src/db/migrations/pg/meta/0034_snapshot.json +3766 -0
  72. package/src/db/migrations/pg/meta/0035_snapshot.json +3773 -0
  73. package/src/db/migrations/pg/meta/0036_snapshot.json +3766 -0
  74. package/src/db/migrations/pg/meta/0037_snapshot.json +3772 -0
  75. package/src/db/migrations/pg/meta/_journal.json +35 -0
  76. package/src/db/pg/schema.ts +41 -0
  77. package/src/db/post-visibility.ts +37 -6
  78. package/src/db/schema.ts +64 -0
  79. package/src/i18n/locales/glossary.zh-Hans.yml +4 -0
  80. package/src/i18n/locales/glossary.zh-Hant.yml +4 -0
  81. package/src/i18n/locales/public/en.po +26 -7
  82. package/src/i18n/locales/public/en.ts +1 -1
  83. package/src/i18n/locales/public/zh-Hans.po +25 -6
  84. package/src/i18n/locales/public/zh-Hans.ts +1 -1
  85. package/src/i18n/locales/public/zh-Hant.po +25 -6
  86. package/src/i18n/locales/public/zh-Hant.ts +1 -1
  87. package/src/i18n/locales/settings/en.po +159 -0
  88. package/src/i18n/locales/settings/en.ts +1 -1
  89. package/src/i18n/locales/settings/zh-Hans.po +159 -0
  90. package/src/i18n/locales/settings/zh-Hans.ts +1 -1
  91. package/src/i18n/locales/settings/zh-Hant.po +159 -0
  92. package/src/i18n/locales/settings/zh-Hant.ts +1 -1
  93. package/src/lib/api-public-posts.ts +10 -0
  94. package/src/lib/env.ts +20 -0
  95. package/src/lib/feed-policy.ts +2 -2
  96. package/src/lib/filter-dimensions.ts +11 -4
  97. package/src/lib/github-app-state.ts +1 -1
  98. package/src/lib/github-app.ts +183 -1
  99. package/src/lib/hugo-markdown.ts +7 -0
  100. package/src/lib/icons.ts +2 -0
  101. package/src/lib/link-preview.ts +499 -0
  102. package/src/lib/list-views.ts +117 -0
  103. package/src/lib/markdown-manager.ts +169 -2
  104. package/src/lib/navigation.ts +1 -1
  105. package/src/lib/post-meta.ts +13 -3
  106. package/src/lib/referrer-aliases.ts +311 -0
  107. package/src/lib/render.tsx +10 -0
  108. package/src/lib/resolve-config.ts +14 -0
  109. package/src/lib/share-card.ts +4 -3
  110. package/src/lib/summary.ts +152 -54
  111. package/src/lib/thread-query.ts +6 -2
  112. package/src/lib/timeline.ts +12 -11
  113. package/src/lib/tiptap-render.ts +1 -0
  114. package/src/lib/upload.ts +21 -1
  115. package/src/lib/url-fetch.ts +291 -74
  116. package/src/lib/video-playback.ts +55 -0
  117. package/src/lib/view-buffer.ts +201 -0
  118. package/src/lib/view-counting.ts +540 -0
  119. package/src/lib/view-token.ts +199 -0
  120. package/src/lib/view.ts +30 -1
  121. package/src/middleware/view-counter.ts +145 -0
  122. package/src/node/runtime.ts +4 -0
  123. package/src/preset.css +36 -17
  124. package/src/routes/api/media.ts +21 -3
  125. package/src/routes/api/search.ts +1 -1
  126. package/src/routes/dash/settings.tsx +434 -169
  127. package/src/routes/feed/sitemap.ts +1 -1
  128. package/src/routes/pages/archive.tsx +26 -19
  129. package/src/routes/pages/collection.tsx +9 -3
  130. package/src/routes/pages/collections.tsx +1 -0
  131. package/src/routes/pages/featured.tsx +1 -0
  132. package/src/routes/pages/home.tsx +1 -0
  133. package/src/routes/pages/page.tsx +18 -3
  134. package/src/routes/pages/search.tsx +3 -3
  135. package/src/routes/pages/smart-collection.tsx +2 -0
  136. package/src/routes/pages/subscribe.tsx +1 -0
  137. package/src/routes/view-confirm.ts +71 -0
  138. package/src/services/collection.ts +1 -1
  139. package/src/services/export-theme/assets/client-site.js +19 -19
  140. package/src/services/export-theme/layouts/archive/list.html +4 -2
  141. package/src/services/export-theme/layouts/partials/collection-members.html +4 -3
  142. package/src/services/export-theme/layouts/partials/featured-members.html +3 -3
  143. package/src/services/export-theme/layouts/partials/head.html +2 -0
  144. package/src/services/export-theme/layouts/partials/latest-members.html +4 -4
  145. package/src/services/export-theme/layouts/partials/post-card.html +1 -9
  146. package/src/services/export-theme/layouts/partials/reply.html +1 -9
  147. package/src/services/export-theme/layouts/partials/smart-collection-members.html +4 -3
  148. package/src/services/export-theme/layouts/post/list.html +1 -9
  149. package/src/services/export-theme/styles/main.css +41 -47
  150. package/src/services/export.ts +12 -3
  151. package/src/services/index.ts +17 -0
  152. package/src/services/mcp.ts +36 -6
  153. package/src/services/media.ts +63 -0
  154. package/src/services/navigation.ts +9 -4
  155. package/src/services/post.ts +102 -112
  156. package/src/services/search.ts +22 -7
  157. package/src/services/smart-collection.ts +3 -3
  158. package/src/services/stats.ts +1137 -0
  159. package/src/services/thread.ts +6 -2
  160. package/src/styles/components-author.css +242 -3
  161. package/src/styles/components.css +11 -3
  162. package/src/styles/tokens.css +89 -55
  163. package/src/styles/ui-author.css +140 -353
  164. package/src/styles/ui.css +90 -45
  165. package/src/types/app-context.ts +9 -0
  166. package/src/types/bindings.ts +5 -0
  167. package/src/types/config.ts +54 -0
  168. package/src/types/constants.ts +68 -4
  169. package/src/types/entities.ts +1 -0
  170. package/src/types/views.ts +8 -0
  171. package/src/ui/compose/ComposeDialog.tsx +26 -1
  172. package/src/ui/dash/StatusBadge.tsx +11 -0
  173. package/src/ui/dash/appearance/FontThemeContent.tsx +1 -1
  174. package/src/ui/dash/appearance/NavigationContent.tsx +8 -0
  175. package/src/ui/dash/settings/SettingsRootContent.tsx +24 -6
  176. package/src/ui/dash/settings/StatsContent.tsx +855 -0
  177. package/src/ui/feed/LinkCard.tsx +19 -2
  178. package/src/ui/feed/PostStatusBadges.tsx +19 -3
  179. package/src/ui/feed/TimelineFeed.tsx +3 -0
  180. package/src/ui/font-themes.ts +56 -6
  181. package/src/ui/layouts/BaseLayout.tsx +4 -2
  182. package/src/ui/layouts/SiteLayout.tsx +8 -3
  183. package/src/ui/pages/ArchivePage.tsx +1 -0
  184. package/src/ui/shared/MediaGallery.tsx +19 -3
  185. package/src/ui/shared/PostFooter.tsx +1 -22
  186. package/src/ui/shared/custom-icons.ts +5 -5
  187. package/dist/client/_assets/chunks/footnote-rail-B08scyhW.js +0 -2
  188. package/dist/client/_assets/chunks/lit-Bw_voPoW.js +0 -2
  189. package/dist/client/_assets/chunks/runtime-paths-y0_gHowM.js +0 -1
  190. package/dist/client/_assets/chunks/sortable-list-t11Ma1Ek.js +0 -2
  191. package/dist/client/_assets/chunks/types-D5iF3H1a.js +0 -1
  192. package/dist/client/_assets/chunks/unsafe-svg-DZl-yjas.js +0 -1
  193. package/dist/client/_assets/client-B0-s9sqx.css +0 -2
  194. package/dist/client/_assets/client-Dp46QSht.js +0 -354
  195. package/dist/client/_assets/client-compose-DkUTuavR.js +0 -2004
  196. package/dist/client/_assets/client-share-C59mOLJ1.js +0 -149
@@ -1,12 +1,12 @@
1
- import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s as i,t as a}from"./chunks/jant-locale-picker-2L4rkDaz.js";import{i as o,n as s,s as c,t as l,u}from"./chunks/lit-Bw_voPoW.js";import{n as d}from"./chunks/confirm-CMe01lne.js";import{_ as f,d as p,h as m,l as h,m as g,p as _,u as v}from"./chunks/types-D5iF3H1a.js";import{r as y,t as b}from"./chunks/create-editor-BQkrw8Ax.js";var x={ICO_16:16,ICO_32:32,APPLE_TOUCH:512};function S(e){let t=e.length*16,n=6+t,r=new ArrayBuffer(6+t),i=new DataView(r);i.setUint16(0,0,!0),i.setUint16(2,1,!0),i.setUint16(4,e.length,!0);let a=[];for(let t=0;t<e.length;t++){let r=e[t],o=6+t*16;i.setUint8(o+0,r.size<256?r.size:0),i.setUint8(o+1,r.size<256?r.size:0),i.setUint8(o+2,0),i.setUint8(o+3,0),i.setUint16(o+4,1,!0),i.setUint16(o+6,32,!0),i.setUint32(o+8,r.png.byteLength,!0),i.setUint32(o+12,n,!0),n+=r.png.byteLength,a.push(r.png)}return new Blob([r,...a],{type:`image/x-icon`})}var C=180;function w(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>{URL.revokeObjectURL(r.src),t(r)},r.onerror=()=>n(Error(`Failed to load image`)),r.src=URL.createObjectURL(e)})}function T(e,t){let n=document.createElement(`canvas`);n.width=t,n.height=t;let r=n.getContext(`2d`);if(!r)throw Error(`Failed to get canvas context`);r.imageSmoothingEnabled=!0,r.imageSmoothingQuality=`high`;let i=Math.max(t/e.width,t/e.height),a=t/i,o=t/i,s=(e.width-a)/2,c=(e.height-o)/2;return r.drawImage(e,s,c,a,o,0,0,t,t),new Promise((e,t)=>{n.toBlob(n=>{n?e(n):t(Error(`Failed to create PNG blob`))},`image/png`)})}function E(e,t){return e.type===`image/png`&&t.width===t.height&&t.width>=C&&t.height>=C}async function D(t,n){let r=t.closest(`form`)?.querySelector(`label`),i=r?.textContent??``;try{r&&(r.textContent=t.dataset.textProcessing||`Processing...`);let i=await w(n),a=await T(i,512),o=new File([a],n.name.replace(/\.[^.]+$/,`.png`),{type:`image/png`}),s=o.name,c=E(n,i)?Promise.resolve(n):T(i,x.APPLE_TOUCH),[l,u,d]=await Promise.all([T(i,16),T(i,32),c]),[p,m]=await Promise.all([l.arrayBuffer(),u.arrayBuffer()]),h=S([{size:16,png:p},{size:32,png:m}]);r&&(r.textContent=t.dataset.textUploading||`Uploading...`);let g=new FormData;g.append(`file`,o,s),g.append(`favicon`,h,`favicon.ico`),g.append(`appleTouch`,d,`apple-touch-icon.png`);let v=await fetch(e(`/settings/avatar`),{method:`POST`,headers:{Accept:`application/json`},body:g});if(!v.ok){let e=t.dataset.textError||`Upload failed. Please try again.`;try{let t=await f(v);e=_(t,`error`)??_(t,`message`)??e}catch{}throw Error(e)}let y=await f(v),b=_(y,`status`),C=_(y,`url`);if(b===`redirect`&&C){window.location.href=C;return}window.location.href=e(`/settings/avatar?saved`)}catch(e){r&&(r.textContent=i),u(e instanceof Error&&e.message?e.message:t.dataset.textError||`Upload failed. Please try again.`,`error`)}t.value=``}function O(){document.addEventListener(`change`,e=>{let t=e.target.closest(`[data-avatar-upload]`);t?.files?.[0]&&(e.stopPropagation(),D(t,t.files[0]))})}O();var k=[`latest`,`off`];function A(e){let t=e?.trim();return t&&k.includes(t)?t:null}function ee(e){if(e.demoMode||!e.rssFeedsEnabled)return`none`;let t=A(e.storedValue);if(t)return t===`off`?`none`:t;if(e.noindex)return`none`;let n=A(e.defaultValue);return n?n===`off`?`none`:n:`none`}var j={links:`Links`,quotes:`Quotes`};function M(e,t){let n=[],r=t.filter(e=>e.term&&e.href).sort((e,t)=>t.term.length-e.term.length);for(let{term:t,href:i}of r)for(let r=e.indexOf(t);r!==-1;r=e.indexOf(t,r+1)){let e=r+t.length;if(!n.some(t=>r<t.end&&t.start<e)){n.push({start:r,end:e,href:i});break}}n.sort((e,t)=>e.start-t.start);let i=[],a=0;for(let{start:t,end:r,href:o}of n)t>a&&i.push({text:e.slice(a,t)}),i.push({text:e.slice(t,r),href:o}),a=r;return a<e.length&&i.push({text:e.slice(a)}),i}function N(e,t,n){return n?M(e,[{term:t.name,href:n.home},{term:j.links,href:n.links},{term:j.quotes,href:n.quotes},{term:t.rules,href:n.rules}]):[{text:e}]}var P=`flex flex-col py-8 first:pt-0 last:pb-0`,F=class extends l{static properties={labels:{type:Object},timezones:{type:Array},siteNameFallback:{type:String,attribute:`sitename-fallback`},siteDescriptionFallback:{type:String,attribute:`sitedescription-fallback`},demoMode:{type:Boolean,attribute:`demo-mode`},discoverDefault:{type:String,attribute:`discover-default`},discoverPages:{type:Object,attribute:`discover-pages`},discoverStatus:{type:String,attribute:`discover-status`},feedsEnabled:{type:Boolean,attribute:`feeds-enabled`},mainFeedUrl:{type:String,attribute:`main-feed-url`},latestFeedUrl:{type:String,attribute:`latest-feed-url`},featuredFeedUrl:{type:String,attribute:`featured-feed-url`},archiveFeedUrl:{type:String,attribute:`archive-feed-url`},feedsDocsUrl:{type:String,attribute:`feeds-docs-url`},aboutPage:{type:Object,attribute:`about-page`},aboutEditUrl:{type:String,attribute:`about-edit-url`},aboutCreateUrl:{type:String,attribute:`about-create-url`},_siteName:{state:!0},_siteDescription:{state:!0},_siteFooter:{state:!0},_origSite:{state:!0},_siteDirty:{state:!0},_siteLoading:{state:!0},_timeZone:{state:!0},_origLocale:{state:!0},_localeDirty:{state:!0},_localeLoading:{state:!0},_mainRssFeed:{state:!0},_origMainRssFeed:{state:!0},_feedLoading:{state:!0},_showJantBrandingOnHome:{state:!0},_origShowJantBrandingOnHome:{state:!0},_homeLoading:{state:!0},_noindex:{state:!0},_origNoindex:{state:!0},_searchLoading:{state:!0},_discover:{state:!0},_origDiscover:{state:!0},_discoverLoading:{state:!0}};_descEditor=null;_footerEditor=null;createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this.labels={},this.timezones=[],this.siteNameFallback=``,this.siteDescriptionFallback=``,this.demoMode=!1,this.mainFeedUrl=`/feed`,this.latestFeedUrl=`/latest/feed`,this.featuredFeedUrl=`/featured/feed`,this.archiveFeedUrl=`/archive/feed`,this.feedsDocsUrl=``,this.aboutPage={state:`missing`,path:`/about`},this.aboutEditUrl=`/about?edit=1`,this.aboutCreateUrl=`/settings/general/about-page`,this._siteName=``,this._siteDescription=``,this._siteFooter=``,this._origSite={siteName:``,siteDescription:``,siteFooter:``},this._siteDirty=!1,this._siteLoading=!1,this._timeZone=`UTC`,this._origLocale={timeZone:`UTC`},this._localeDirty=!1,this._localeLoading=!1,this._mainRssFeed=`featured`,this._origMainRssFeed=`featured`,this._feedLoading=!1,this._noindex=!1,this._origNoindex=!1,this._showJantBrandingOnHome=!1,this._origShowJantBrandingOnHome=!1,this._homeLoading=!1,this._searchLoading=!1,this.discoverDefault=``,this.discoverPages=null,this.discoverStatus=``,this.feedsEnabled=!1,this._discover=``,this._origDiscover=``,this._discoverLoading=!1}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),this._descEditor?.destroy(),this._descEditor=null,this._footerEditor?.destroy(),this._footerEditor=null}initData(e){this._siteName=e.siteName,this._siteDescription=e.siteDescription,this._siteFooter=e.siteFooter,this._timeZone=e.timeZone,this._origLocale={timeZone:e.timeZone},this._mainRssFeed=e.mainRssFeed,this._origMainRssFeed=e.mainRssFeed,this._showJantBrandingOnHome=e.showJantBrandingOnHome,this._origShowJantBrandingOnHome=e.showJantBrandingOnHome,this._noindex=e.noindex,this._origNoindex=e.noindex,this._discover=e.discover,this._origDiscover=e.discover,this.updateComplete.then(()=>{this._initEditors(),this._origSite={siteName:e.siteName,siteDescription:this._siteDescription,siteFooter:this._siteFooter}})}sectionSaved(e){e===`site`?(this._origSite={siteName:this._siteName,siteDescription:this._siteDescription,siteFooter:this._siteFooter},this._siteDirty=!1,this._siteLoading=!1):e===`time`?(this._origLocale={timeZone:this._timeZone},this._localeDirty=!1,this._localeLoading=!1):e===`feeds`?(this._origMainRssFeed=this._mainRssFeed,this._feedLoading=!1):e===`home`?(this._origShowJantBrandingOnHome=this._showJantBrandingOnHome,this._homeLoading=!1):e===`search`?(this._origNoindex=this._noindex,this._searchLoading=!1):e===`discover`&&(this._origDiscover=this._discover,this._discoverLoading=!1)}sectionError(e){e===`site`?this._siteLoading=!1:e===`time`?this._localeLoading=!1:e===`feeds`?(this._mainRssFeed=this._origMainRssFeed,this._feedLoading=!1):e===`home`?(this._showJantBrandingOnHome=this._origShowJantBrandingOnHome,this._homeLoading=!1):e===`search`?(this._noindex=this._origNoindex,this._searchLoading=!1):e===`discover`&&(this._discover=this._origDiscover,this._discoverLoading=!1)}_initEditors(){this._initDescEditor(),this._initFooterEditor()}_initDescEditor(){let e=this.querySelector(`[data-settings-desc-editor]`);if(!e||this._descEditor)return;this._descEditor=b({element:e,placeholder:this.siteDescriptionFallback,content:this._siteDescription||void 0,onUpdate:e=>{this._siteDescription=e,this._syncSiteDirty()}}),this._siteDescription=y(this._descEditor.getJSON());let t=e.querySelector(`.ProseMirror`);t&&(t.style.outline=`none`,t.style.minHeight=`3rem`)}_initFooterEditor(){let e=this.querySelector(`[data-settings-footer-editor]`);if(!e||this._footerEditor)return;this._footerEditor=b({element:e,content:this._siteFooter||void 0,onUpdate:e=>{this._siteFooter=e,this._syncSiteDirty()}}),this._siteFooter=y(this._footerEditor.getJSON());let t=e.querySelector(`.ProseMirror`);t&&(t.style.outline=`none`,t.style.minHeight=`6rem`)}_syncSiteDirty(){this._siteDirty=this._siteName!==this._origSite.siteName||this._siteDescription!==this._origSite.siteDescription||this._siteFooter!==this._origSite.siteFooter}_saveSite(){!this._siteLoading&&this._siteDirty&&(this._siteLoading=!0,this.dispatchEvent(new CustomEvent(`jant:settings-save`,{bubbles:!0,detail:{endpoint:`/settings/general`,data:{siteName:this._siteName,siteDescription:this._siteDescription,siteFooter:this._siteFooter},section:`site`}})))}_syncLocaleDirty(){this._localeDirty=this._timeZone!==this._origLocale.timeZone}_saveLocale(){!this._localeLoading&&this._localeDirty&&(this._localeLoading=!0,this.dispatchEvent(new CustomEvent(`jant:settings-save`,{bubbles:!0,detail:{endpoint:`/settings/general/time`,data:{timeZone:this._timeZone},section:`time`}})))}_saveMainRssFeed(e){this._feedLoading||e===this._mainRssFeed||(this._mainRssFeed=e,this._feedLoading=!0,this.dispatchEvent(new CustomEvent(`jant:settings-save`,{bubbles:!0,detail:{endpoint:`/settings/general/feeds`,data:{mainRssFeed:e},section:`feeds`}})))}_saveHomeToggle(e){this._homeLoading||(this._showJantBrandingOnHome=e,this._homeLoading=!0,this.dispatchEvent(new CustomEvent(`jant:settings-save`,{bubbles:!0,detail:{endpoint:`/settings/general/home`,data:{showJantBrandingOnHome:e},section:`home`}})))}_saveSearchToggle(e){this.demoMode||this._searchLoading||(this._noindex=!e,this._searchLoading=!0,this.dispatchEvent(new CustomEvent(`jant:settings-save`,{bubbles:!0,detail:{endpoint:`/settings/general/search`,data:{allowIndexing:e},section:`search`}})))}_effectiveDiscoverMode(e={}){return ee({storedValue:this._discover||null,defaultValue:this.discoverDefault||null,demoMode:this.demoMode,noindex:e.noindex??this._noindex,rssFeedsEnabled:this.feedsEnabled})}_onDiscoverToggle(e){this._saveDiscover(e?`latest`:`off`)}_saveDiscover(e){this._discoverLoading||(this._discover=e,this._discoverLoading=!0,this.dispatchEvent(new CustomEvent(`jant:settings-save`,{bubbles:!0,detail:{endpoint:`/settings/general/discover`,data:{discover:e},section:`discover`}})))}_onKeydown(e,t,n,r){e.isComposing||e.keyCode===229||e.key===`Enter`&&!r&&n&&!(e.target instanceof HTMLTextAreaElement)&&(e.preventDefault(),t())}_renderSaveAction(e,t,n){return o`
1
+ import{g as e,i as t,n,s as r,t as i,u as a}from"./chunks/lit-BN4mrI3j.js";import{a as o,i as s,r as c,s as l,t as u}from"./chunks/jant-locale-picker-CLq0iKDH.js";import{n as d}from"./chunks/confirm-BQebcuNB.js";import{_ as f,d as p,h as m,l as h,m as g,p as _,u as v}from"./chunks/types-DrYFqJH2.js";import{r as y,t as b}from"./chunks/create-editor-B8KuszlS.js";var x={ICO_16:16,ICO_32:32,APPLE_TOUCH:512};function S(e){let t=e.length*16,n=6+t,r=new ArrayBuffer(6+t),i=new DataView(r);i.setUint16(0,0,!0),i.setUint16(2,1,!0),i.setUint16(4,e.length,!0);let a=[];for(let t=0;t<e.length;t++){let r=e[t],o=6+t*16;i.setUint8(o+0,r.size<256?r.size:0),i.setUint8(o+1,r.size<256?r.size:0),i.setUint8(o+2,0),i.setUint8(o+3,0),i.setUint16(o+4,1,!0),i.setUint16(o+6,32,!0),i.setUint32(o+8,r.png.byteLength,!0),i.setUint32(o+12,n,!0),n+=r.png.byteLength,a.push(r.png)}return new Blob([r,...a],{type:`image/x-icon`})}var C=180;function w(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>{URL.revokeObjectURL(r.src),t(r)},r.onerror=()=>n(Error(`Failed to load image`)),r.src=URL.createObjectURL(e)})}function T(e,t){let n=document.createElement(`canvas`);n.width=t,n.height=t;let r=n.getContext(`2d`);if(!r)throw Error(`Failed to get canvas context`);r.imageSmoothingEnabled=!0,r.imageSmoothingQuality=`high`;let i=Math.max(t/e.width,t/e.height),a=t/i,o=t/i,s=(e.width-a)/2,c=(e.height-o)/2;return r.drawImage(e,s,c,a,o,0,0,t,t),new Promise((e,t)=>{n.toBlob(n=>{n?e(n):t(Error(`Failed to create PNG blob`))},`image/png`)})}function E(e,t){return e.type===`image/png`&&t.width===t.height&&t.width>=C&&t.height>=C}async function D(t,n){let r=t.closest(`form`)?.querySelector(`label`),i=r?.textContent??``;try{r&&(r.textContent=t.dataset.textProcessing||`Processing...`);let i=await w(n),a=await T(i,512),o=new File([a],n.name.replace(/\.[^.]+$/,`.png`),{type:`image/png`}),s=o.name,c=E(n,i)?Promise.resolve(n):T(i,x.APPLE_TOUCH),[l,u,d]=await Promise.all([T(i,16),T(i,32),c]),[p,m]=await Promise.all([l.arrayBuffer(),u.arrayBuffer()]),h=S([{size:16,png:p},{size:32,png:m}]);r&&(r.textContent=t.dataset.textUploading||`Uploading...`);let g=new FormData;g.append(`file`,o,s),g.append(`favicon`,h,`favicon.ico`),g.append(`appleTouch`,d,`apple-touch-icon.png`);let v=await fetch(e(`/settings/avatar`),{method:`POST`,headers:{Accept:`application/json`},body:g});if(!v.ok){let e=t.dataset.textError||`Upload failed. Please try again.`;try{let t=await f(v);e=_(t,`error`)??_(t,`message`)??e}catch{}throw Error(e)}let y=await f(v),b=_(y,`status`),C=_(y,`url`);if(b===`redirect`&&C){window.location.href=C;return}window.location.href=e(`/settings/avatar?saved`)}catch(e){r&&(r.textContent=i),a(e instanceof Error&&e.message?e.message:t.dataset.textError||`Upload failed. Please try again.`,`error`)}t.value=``}function O(){document.addEventListener(`change`,e=>{let t=e.target.closest(`[data-avatar-upload]`);t?.files?.[0]&&(e.stopPropagation(),D(t,t.files[0]))})}O();var k=[`latest`,`off`];function A(e){let t=e?.trim();return t&&k.includes(t)?t:null}function ee(e){if(e.demoMode||!e.rssFeedsEnabled)return`none`;let t=A(e.storedValue);if(t)return t===`off`?`none`:t;if(e.noindex)return`none`;let n=A(e.defaultValue);return n?n===`off`?`none`:n:`none`}var j={links:`Links`,quotes:`Quotes`};function M(e,t){let n=[],r=t.filter(e=>e.term&&e.href).sort((e,t)=>t.term.length-e.term.length);for(let{term:t,href:i}of r)for(let r=e.indexOf(t);r!==-1;r=e.indexOf(t,r+1)){let e=r+t.length;if(!n.some(t=>r<t.end&&t.start<e)){n.push({start:r,end:e,href:i});break}}n.sort((e,t)=>e.start-t.start);let i=[],a=0;for(let{start:t,end:r,href:o}of n)t>a&&i.push({text:e.slice(a,t)}),i.push({text:e.slice(t,r),href:o}),a=r;return a<e.length&&i.push({text:e.slice(a)}),i}function N(e,t,n){return n?M(e,[{term:t.name,href:n.home},{term:j.links,href:n.links},{term:j.quotes,href:n.quotes},{term:t.rules,href:n.rules}]):[{text:e}]}var P=`flex flex-col py-8 first:pt-0 last:pb-0`,F=class extends i{static properties={labels:{type:Object},timezones:{type:Array},siteNameFallback:{type:String,attribute:`sitename-fallback`},siteDescriptionFallback:{type:String,attribute:`sitedescription-fallback`},demoMode:{type:Boolean,attribute:`demo-mode`},discoverDefault:{type:String,attribute:`discover-default`},discoverPages:{type:Object,attribute:`discover-pages`},discoverStatus:{type:String,attribute:`discover-status`},feedsEnabled:{type:Boolean,attribute:`feeds-enabled`},mainFeedUrl:{type:String,attribute:`main-feed-url`},latestFeedUrl:{type:String,attribute:`latest-feed-url`},featuredFeedUrl:{type:String,attribute:`featured-feed-url`},archiveFeedUrl:{type:String,attribute:`archive-feed-url`},feedsDocsUrl:{type:String,attribute:`feeds-docs-url`},aboutPage:{type:Object,attribute:`about-page`},aboutEditUrl:{type:String,attribute:`about-edit-url`},aboutCreateUrl:{type:String,attribute:`about-create-url`},_siteName:{state:!0},_siteDescription:{state:!0},_siteFooter:{state:!0},_origSite:{state:!0},_siteDirty:{state:!0},_siteLoading:{state:!0},_timeZone:{state:!0},_origLocale:{state:!0},_localeDirty:{state:!0},_localeLoading:{state:!0},_mainRssFeed:{state:!0},_origMainRssFeed:{state:!0},_feedLoading:{state:!0},_showJantBrandingOnHome:{state:!0},_origShowJantBrandingOnHome:{state:!0},_homeLoading:{state:!0},_noindex:{state:!0},_origNoindex:{state:!0},_searchLoading:{state:!0},_discover:{state:!0},_origDiscover:{state:!0},_discoverLoading:{state:!0}};_descEditor=null;_footerEditor=null;createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this.labels={},this.timezones=[],this.siteNameFallback=``,this.siteDescriptionFallback=``,this.demoMode=!1,this.mainFeedUrl=`/feed`,this.latestFeedUrl=`/latest/feed`,this.featuredFeedUrl=`/featured/feed`,this.archiveFeedUrl=`/archive/feed`,this.feedsDocsUrl=``,this.aboutPage={state:`missing`,path:`/about`},this.aboutEditUrl=`/about?edit=1`,this.aboutCreateUrl=`/settings/general/about-page`,this._siteName=``,this._siteDescription=``,this._siteFooter=``,this._origSite={siteName:``,siteDescription:``,siteFooter:``},this._siteDirty=!1,this._siteLoading=!1,this._timeZone=`UTC`,this._origLocale={timeZone:`UTC`},this._localeDirty=!1,this._localeLoading=!1,this._mainRssFeed=`featured`,this._origMainRssFeed=`featured`,this._feedLoading=!1,this._noindex=!1,this._origNoindex=!1,this._showJantBrandingOnHome=!1,this._origShowJantBrandingOnHome=!1,this._homeLoading=!1,this._searchLoading=!1,this.discoverDefault=``,this.discoverPages=null,this.discoverStatus=``,this.feedsEnabled=!1,this._discover=``,this._origDiscover=``,this._discoverLoading=!1}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),this._descEditor?.destroy(),this._descEditor=null,this._footerEditor?.destroy(),this._footerEditor=null}initData(e){this._siteName=e.siteName,this._siteDescription=e.siteDescription,this._siteFooter=e.siteFooter,this._timeZone=e.timeZone,this._origLocale={timeZone:e.timeZone},this._mainRssFeed=e.mainRssFeed,this._origMainRssFeed=e.mainRssFeed,this._showJantBrandingOnHome=e.showJantBrandingOnHome,this._origShowJantBrandingOnHome=e.showJantBrandingOnHome,this._noindex=e.noindex,this._origNoindex=e.noindex,this._discover=e.discover,this._origDiscover=e.discover,this.updateComplete.then(()=>{this._initEditors(),this._origSite={siteName:e.siteName,siteDescription:this._siteDescription,siteFooter:this._siteFooter}})}sectionSaved(e){e===`site`?(this._origSite={siteName:this._siteName,siteDescription:this._siteDescription,siteFooter:this._siteFooter},this._siteDirty=!1,this._siteLoading=!1):e===`time`?(this._origLocale={timeZone:this._timeZone},this._localeDirty=!1,this._localeLoading=!1):e===`feeds`?(this._origMainRssFeed=this._mainRssFeed,this._feedLoading=!1):e===`home`?(this._origShowJantBrandingOnHome=this._showJantBrandingOnHome,this._homeLoading=!1):e===`search`?(this._origNoindex=this._noindex,this._searchLoading=!1):e===`discover`&&(this._origDiscover=this._discover,this._discoverLoading=!1)}sectionError(e){e===`site`?this._siteLoading=!1:e===`time`?this._localeLoading=!1:e===`feeds`?(this._mainRssFeed=this._origMainRssFeed,this._feedLoading=!1):e===`home`?(this._showJantBrandingOnHome=this._origShowJantBrandingOnHome,this._homeLoading=!1):e===`search`?(this._noindex=this._origNoindex,this._searchLoading=!1):e===`discover`&&(this._discover=this._origDiscover,this._discoverLoading=!1)}_initEditors(){this._initDescEditor(),this._initFooterEditor()}_initDescEditor(){let e=this.querySelector(`[data-settings-desc-editor]`);if(!e||this._descEditor)return;this._descEditor=b({element:e,placeholder:this.siteDescriptionFallback,content:this._siteDescription||void 0,onUpdate:e=>{this._siteDescription=e,this._syncSiteDirty()}}),this._siteDescription=y(this._descEditor.getJSON());let t=e.querySelector(`.ProseMirror`);t&&(t.style.outline=`none`,t.style.minHeight=`3rem`)}_initFooterEditor(){let e=this.querySelector(`[data-settings-footer-editor]`);if(!e||this._footerEditor)return;this._footerEditor=b({element:e,content:this._siteFooter||void 0,onUpdate:e=>{this._siteFooter=e,this._syncSiteDirty()}}),this._siteFooter=y(this._footerEditor.getJSON());let t=e.querySelector(`.ProseMirror`);t&&(t.style.outline=`none`,t.style.minHeight=`6rem`)}_syncSiteDirty(){this._siteDirty=this._siteName!==this._origSite.siteName||this._siteDescription!==this._origSite.siteDescription||this._siteFooter!==this._origSite.siteFooter}_saveSite(){!this._siteLoading&&this._siteDirty&&(this._siteLoading=!0,this.dispatchEvent(new CustomEvent(`jant:settings-save`,{bubbles:!0,detail:{endpoint:`/settings/general`,data:{siteName:this._siteName,siteDescription:this._siteDescription,siteFooter:this._siteFooter},section:`site`}})))}_syncLocaleDirty(){this._localeDirty=this._timeZone!==this._origLocale.timeZone}_saveLocale(){!this._localeLoading&&this._localeDirty&&(this._localeLoading=!0,this.dispatchEvent(new CustomEvent(`jant:settings-save`,{bubbles:!0,detail:{endpoint:`/settings/general/time`,data:{timeZone:this._timeZone},section:`time`}})))}_saveMainRssFeed(e){this._feedLoading||e===this._mainRssFeed||(this._mainRssFeed=e,this._feedLoading=!0,this.dispatchEvent(new CustomEvent(`jant:settings-save`,{bubbles:!0,detail:{endpoint:`/settings/general/feeds`,data:{mainRssFeed:e},section:`feeds`}})))}_saveHomeToggle(e){this._homeLoading||(this._showJantBrandingOnHome=e,this._homeLoading=!0,this.dispatchEvent(new CustomEvent(`jant:settings-save`,{bubbles:!0,detail:{endpoint:`/settings/general/home`,data:{showJantBrandingOnHome:e},section:`home`}})))}_saveSearchToggle(e){this.demoMode||this._searchLoading||(this._noindex=!e,this._searchLoading=!0,this.dispatchEvent(new CustomEvent(`jant:settings-save`,{bubbles:!0,detail:{endpoint:`/settings/general/search`,data:{allowIndexing:e},section:`search`}})))}_effectiveDiscoverMode(e={}){return ee({storedValue:this._discover||null,defaultValue:this.discoverDefault||null,demoMode:this.demoMode,noindex:e.noindex??this._noindex,rssFeedsEnabled:this.feedsEnabled})}_onDiscoverToggle(e){this._saveDiscover(e?`latest`:`off`)}_saveDiscover(e){this._discoverLoading||(this._discover=e,this._discoverLoading=!0,this.dispatchEvent(new CustomEvent(`jant:settings-save`,{bubbles:!0,detail:{endpoint:`/settings/general/discover`,data:{discover:e},section:`discover`}})))}_onKeydown(e,t,n,r){e.isComposing||e.keyCode===229||e.key===`Enter`&&!r&&n&&!(e.target instanceof HTMLTextAreaElement)&&(e.preventDefault(),t())}_renderSaveAction(e,r,i){return t`
2
2
  <div class="flex mt-4">
3
3
  <button
4
4
  type="button"
5
5
  class="btn"
6
- ?disabled=${e||!t}
7
- @click=${n}
6
+ ?disabled=${e||!r}
7
+ @click=${i}
8
8
  >
9
- ${e?o`<svg
9
+ ${e?t`<svg
10
10
  class="animate-spin size-4"
11
11
  xmlns="http://www.w3.org/2000/svg"
12
12
  viewBox="0 0 24 24"
@@ -18,46 +18,46 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
18
18
  role="status"
19
19
  >
20
20
  <path d="M21 12a9 9 0 1 1-6.219-8.56" />
21
- </svg>`:s}
21
+ </svg>`:n}
22
22
  ${this.labels.save}
23
23
  </button>
24
24
  </div>
25
- `}_renderSectionTitle(e){return o`<h3 class="text-sm font-semibold tracking-[0.01em]">
25
+ `}_renderSectionTitle(e){return t`<h3 class="text-sm font-semibold tracking-[0.01em]">
26
26
  ${e}
27
- </h3>`}_renderMainRssFeedOption(e,t,n){let r=this._mainRssFeed===e;return o`
27
+ </h3>`}_renderMainRssFeedOption(e,n,r){let i=this._mainRssFeed===e;return t`
28
28
  <label
29
- class=${`flex items-start gap-3 rounded-xl border p-3 cursor-pointer transition-colors ${r?`border-primary`:`border-border`}`}
29
+ class=${`flex items-start gap-3 rounded-xl border p-3 cursor-pointer transition-colors ${i?`border-primary`:`border-border`}`}
30
30
  >
31
31
  <input
32
32
  type="radio"
33
33
  name="main-rss-feed"
34
34
  value=${e}
35
35
  class="mt-1"
36
- .checked=${r}
36
+ .checked=${i}
37
37
  ?disabled=${this._feedLoading}
38
38
  @change=${()=>this._saveMainRssFeed(e)}
39
39
  />
40
40
  <div>
41
- <div class="font-medium">${t}</div>
42
- <div class="text-sm text-muted-foreground">${n}</div>
41
+ <div class="font-medium">${n}</div>
42
+ <div class="text-sm text-muted-foreground">${r}</div>
43
43
  </div>
44
44
  </label>
45
- `}_renderFeedUrl(e,a,s){return o`
46
- <div class=${n} data-copy-field-root>
45
+ `}_renderFeedUrl(e,n,r){return t`
46
+ <div class=${s} data-copy-field-root>
47
47
  <p class="text-sm font-medium">${e}</p>
48
- ${s?o`<p class="text-sm text-muted-foreground">${s}</p>`:``}
49
- <div class=${t}>
48
+ ${r?t`<p class="text-sm text-muted-foreground">${r}</p>`:``}
49
+ <div class=${o}>
50
50
  <input
51
51
  type="text"
52
- class=${i}
53
- .value=${a}
52
+ class=${l}
53
+ .value=${n}
54
54
  readonly
55
55
  aria-label=${e}
56
56
  data-copy-field-value
57
57
  />
58
58
  <button
59
59
  type="button"
60
- class=${r}
60
+ class=${c}
61
61
  data-copy-field=${this.labels.feedUrlCopied}
62
62
  data-copy-field-failed=${this.labels.copyFailed}
63
63
  >
@@ -65,17 +65,17 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
65
65
  </button>
66
66
  </div>
67
67
  </div>
68
- `}_renderAboutPageRow(){let e=this.aboutPage;return o`
68
+ `}_renderAboutPageRow(){let e=this.aboutPage;return t`
69
69
  <div class="mt-2 text-sm text-muted-foreground" data-about-page-row>
70
70
  ${this.labels.aboutPagePrompt}
71
- ${e.state===`ready`?o`
71
+ ${e.state===`ready`?t`
72
72
  <a
73
73
  class="font-medium text-foreground underline-offset-4 hover:underline"
74
74
  href=${this.aboutEditUrl}
75
75
  >
76
76
  ${this.labels.editAboutPage}
77
77
  </a>
78
- `:e.state===`missing`?o`
78
+ `:e.state===`missing`?t`
79
79
  <form
80
80
  class="inline"
81
81
  method="post"
@@ -88,13 +88,13 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
88
88
  ${this.labels.createAboutPage}
89
89
  </button>
90
90
  </form>
91
- `:o`
91
+ `:t`
92
92
  <span class="text-destructive"
93
93
  >${this.labels.aboutPageConflict}</span
94
94
  >
95
95
  `}
96
96
  </div>
97
- `}_renderSiteSection(){return o`
97
+ `}_renderSiteSection(){return t`
98
98
  <section
99
99
  class="${P} gap-4"
100
100
  @keydown=${e=>this._onKeydown(e,()=>this._saveSite(),this._siteDirty,this._siteLoading)}
@@ -131,7 +131,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
131
131
 
132
132
  ${this._renderSaveAction(this._siteLoading,this._siteDirty,()=>this._saveSite())}
133
133
  </section>
134
- `}_renderVisibilitySection(){return o`
134
+ `}_renderVisibilitySection(){return t`
135
135
  <section class="${P} gap-6">
136
136
  ${this._renderSectionTitle(this.labels.siteVisibility)}
137
137
  <div class="flex flex-col gap-2">
@@ -145,13 +145,13 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
145
145
  />
146
146
  <span>${this.labels.allowIndexing}</span>
147
147
  </label>
148
- ${this.demoMode?o`<p class="text-sm text-muted-foreground">
148
+ ${this.demoMode?t`<p class="text-sm text-muted-foreground">
149
149
  ${this.labels.demoSeoLocked}
150
- </p>`:s}
150
+ </p>`:n}
151
151
  </div>
152
152
  ${this._renderDiscoverForm()}
153
153
  </section>
154
- `}_renderFeedsSection(){return o`
154
+ `}_renderFeedsSection(){return t`
155
155
  <section class="${P} gap-4">
156
156
  ${this._renderSectionTitle(this.labels.feeds)}
157
157
  <div class="field">
@@ -176,7 +176,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
176
176
  </p>
177
177
  <p class="text-sm text-muted-foreground">
178
178
  ${this.labels.availableFeedUrlsHelp}
179
- ${this.feedsDocsUrl?o`
179
+ ${this.feedsDocsUrl?t`
180
180
  <a
181
181
  href=${this.feedsDocsUrl}
182
182
  target="_blank"
@@ -195,7 +195,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
195
195
  </div>
196
196
  </div>
197
197
  </section>
198
- `}_renderTimeSection(){return o`
198
+ `}_renderTimeSection(){return t`
199
199
  <section
200
200
  class="${P} gap-4"
201
201
  @keydown=${e=>this._onKeydown(e,()=>this._saveLocale(),this._localeDirty,this._localeLoading)}
@@ -207,7 +207,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
207
207
  class="select"
208
208
  @change=${e=>{this._timeZone=e.target.value,this._syncLocaleDirty()}}
209
209
  >
210
- ${this.timezones.map(e=>o`
210
+ ${this.timezones.map(e=>t`
211
211
  <option
212
212
  value=${e.value}
213
213
  ?selected=${this._timeZone===e.value}
@@ -220,7 +220,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
220
220
 
221
221
  ${this._renderSaveAction(this._localeLoading,this._localeDirty,()=>this._saveLocale())}
222
222
  </section>
223
- `}_renderHomeSection(){return o`
223
+ `}_renderHomeSection(){return t`
224
224
  <section class="${P} gap-4">
225
225
  ${this._renderSectionTitle(this.labels.home)}
226
226
  <label class="flex items-center gap-2 cursor-pointer">
@@ -234,7 +234,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
234
234
  <span>${this.labels.showJantBrandingOnHome}</span>
235
235
  </label>
236
236
  </section>
237
- `}_renderDiscoverForm(){let e=this._effectiveDiscoverMode()!==`none`,t=this.demoMode||!this.feedsEnabled,n=!t&&!e&&this._effectiveDiscoverMode({noindex:!1})!==`none`;return o`
237
+ `}_renderDiscoverForm(){let e=this._effectiveDiscoverMode()!==`none`,r=this.demoMode||!this.feedsEnabled,i=!r&&!e&&this._effectiveDiscoverMode({noindex:!1})!==`none`;return t`
238
238
  <div class="flex flex-col gap-3">
239
239
  <div class="flex flex-col gap-2">
240
240
  <label class="flex items-center gap-2 cursor-pointer">
@@ -242,30 +242,30 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
242
242
  type="checkbox"
243
243
  class="checkbox"
244
244
  .checked=${e}
245
- ?disabled=${t||this._discoverLoading}
245
+ ?disabled=${r||this._discoverLoading}
246
246
  @change=${e=>this._onDiscoverToggle(e.target.checked)}
247
247
  />
248
248
  <span>${this.labels.discoverEnabled}</span>
249
249
  </label>
250
250
  <p class="text-sm text-muted-foreground">
251
- ${this._renderDiscoverHelp(t?this.demoMode?this.labels.discoverDemoLocked:this.labels.discoverFeedsOffLocked:this.labels.discoverIntro)}
251
+ ${this._renderDiscoverHelp(r?this.demoMode?this.labels.discoverDemoLocked:this.labels.discoverFeedsOffLocked:this.labels.discoverIntro)}
252
252
  </p>
253
- ${n?o`<p class="text-sm text-muted-foreground">
253
+ ${i?t`<p class="text-sm text-muted-foreground">
254
254
  ${this.labels.discoverSearchOff}
255
- </p>`:s}
255
+ </p>`:n}
256
256
  </div>
257
- ${t?s:this._renderDiscoverStatus()}
257
+ ${r?n:this._renderDiscoverStatus()}
258
258
  </div>
259
- `}_renderDiscoverHelp(e){return N(e??``,{name:this.labels.discoverName??``,rules:this.labels.discoverRules??``},this.discoverPages).map(e=>e.href?o`<a
259
+ `}_renderDiscoverHelp(e){return N(e??``,{name:this.labels.discoverName??``,rules:this.labels.discoverRules??``},this.discoverPages).map(e=>e.href?t`<a
260
260
  href=${e.href}
261
261
  target="_blank"
262
262
  rel="noopener noreferrer"
263
263
  class="underline hover:text-foreground transition-colors"
264
264
  >${e.text}</a
265
- >`:e.text)}_renderDiscoverStatus(){let e=this._parsedDiscoverStatus();return!e||this._effectiveDiscoverMode()===`none`||e.lines.length===0&&!e.showAnnounce?s:o`
265
+ >`:e.text)}_renderDiscoverStatus(){let e=this._parsedDiscoverStatus();return!e||this._effectiveDiscoverMode()===`none`||e.lines.length===0&&!e.showAnnounce?n:t`
266
266
  <div class="flex flex-col gap-1 border-t pt-3">
267
- ${e.lines.map(e=>o`<p class="text-sm text-muted-foreground">${e}</p>`)}
268
- ${e.showAnnounce?o`
267
+ ${e.lines.map(e=>t`<p class="text-sm text-muted-foreground">${e}</p>`)}
268
+ ${e.showAnnounce?t`
269
269
  <div class="flex flex-wrap items-center gap-3 mt-1">
270
270
  <button
271
271
  type="button"
@@ -275,17 +275,17 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
275
275
  >
276
276
  ${this.labels.discoverAnnounce}
277
277
  </button>
278
- ${e.submitUrl?o`<a
278
+ ${e.submitUrl?t`<a
279
279
  class="text-sm underline hover:text-foreground transition-colors"
280
280
  href=${e.submitUrl}
281
281
  target="_blank"
282
282
  rel="noopener noreferrer"
283
283
  >${this.labels.discoverAnnounceManual}</a
284
- >`:s}
284
+ >`:n}
285
285
  </div>
286
- `:s}
286
+ `:n}
287
287
  </div>
288
- `}_parsedDiscoverStatus(){if(!this.discoverStatus)return null;try{let e=JSON.parse(this.discoverStatus);if(typeof e!=`object`||!e)return null;let t=e;return{lines:Array.isArray(t.lines)?t.lines.filter(e=>typeof e==`string`):[],showAnnounce:t.showAnnounce===!0,submitUrl:typeof t.submitUrl==`string`?t.submitUrl:null}}catch{return null}}_announce(){this._discoverLoading||(this._discoverLoading=!0,this.dispatchEvent(new CustomEvent(`jant:settings-save`,{bubbles:!0,detail:{endpoint:`/settings/general/discover/announce`,data:{},section:`discover`}})))}render(){return o`
288
+ `}_parsedDiscoverStatus(){if(!this.discoverStatus)return null;try{let e=JSON.parse(this.discoverStatus);if(typeof e!=`object`||!e)return null;let t=e;return{lines:Array.isArray(t.lines)?t.lines.filter(e=>typeof e==`string`):[],showAnnounce:t.showAnnounce===!0,submitUrl:typeof t.submitUrl==`string`?t.submitUrl:null}}catch{return null}}_announce(){this._discoverLoading||(this._discoverLoading=!0,this.dispatchEvent(new CustomEvent(`jant:settings-save`,{bubbles:!0,detail:{endpoint:`/settings/general/discover/announce`,data:{},section:`discover`}})))}render(){return t`
289
289
  <div class="flex flex-col gap-8">
290
290
  <h2 class="text-lg font-semibold">${this.labels.general}</h2>
291
291
  <div class="flex flex-col divide-y">
@@ -294,7 +294,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
294
294
  ${this._renderHomeSection()}
295
295
  </div>
296
296
  </div>
297
- `}};customElements.define(`jant-settings-general`,F);var I=`${typeof __JANT_DEV__<`u`&&__JANT_DEV__===!0?`https://jant-cloud.localtest.me`:`https://jant.me`}/docs`;function L(e=``){return e?`${I}/${e}`:I}var R=[``,`en`,`zh-Hans`,`zh-Hant`],z=L(`multilingual`);function B(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??e)}var V=class extends l{static properties={labels:{type:Object},locales:{type:Array},_contentLanguage:{state:!0},_dashboardLanguage:{state:!0},_multilingualEnabled:{state:!0},_additional:{state:!0},_unmarkedPostCount:{state:!0},_sitePathPrefix:{state:!0},_savingSite:{state:!0},_savingDashboard:{state:!0},_removeError:{state:!0},_rowMenuOpen:{state:!0},_enableError:{state:!0},_enableOpen:{state:!0},_enableAdditional:{state:!0},_enablePrimary:{state:!0},_enableBusy:{state:!0}};#e=z;createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this.labels={},this.locales=[],this._contentLanguage=`en`,this._dashboardLanguage=``,this._multilingualEnabled=!1,this._additional=[],this._unmarkedPostCount=0,this._sitePathPrefix=``,this._savingSite=!1,this._savingDashboard=!1,this._removeError=null,this._rowMenuOpen=null,this._enableError=null,this._enableOpen=!1,this._enableAdditional=[],this._enablePrimary=`en`,this._enableBusy=!1}connectedCallback(){super.connectedCallback(),this.#t(),document.addEventListener(`click`,this.#s),document.addEventListener(`keydown`,this.#c)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(`click`,this.#s),document.removeEventListener(`keydown`,this.#c)}#t(){let e=document.getElementById(`language-settings-initial-data`);if(!e?.textContent)return;let t;try{t=JSON.parse(e.textContent)}catch{return}let n=t;this._contentLanguage=n.contentLanguage??`en`,this._dashboardLanguage=n.dashboardLanguage??``,this._multilingualEnabled=n.multilingualEnabled??!1,this._additional=Array.isArray(n.additionalLanguages)?[...n.additionalLanguages]:[],this._unmarkedPostCount=n.unmarkedPostCount??0,this._sitePathPrefix=n.sitePathPrefix??``,this.#e=n.multilingualDocsUrl||z}#n(e){return this.locales.find(t=>t.tag===e)??{tag:e,native:e,english:e,coverage:0}}#r(e){let t=this.#n(e);return t.native||t.tag}#i(e){return`${this._sitePathPrefix}/${e.toLowerCase()}`}#a(e){return`${this._sitePathPrefix}/settings/language${e}`}#o(){return this.querySelector(`jant-locale-picker[open]`)!==null}#s=e=>{if(!this._rowMenuOpen)return;let t=e.target;t&&this.contains(t)&&t.closest?.(`[data-row-menu]`)||(this._rowMenuOpen=null)};#c=e=>{if(e.key===`Escape`){if(this._rowMenuOpen){e.stopPropagation(),this._rowMenuOpen=null;return}this._enableOpen&&(e.stopPropagation(),this.#_())}};#l(e){this._rowMenuOpen=this._rowMenuOpen===e?null:e}async#u(e,t){try{let n=await fetch(this.#a(e),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(t)}),r=await f(n);return n.ok?{ok:!0,message:_(r,`toast`)}:{ok:!1,message:_(r,`error`)??`HTTP ${n.status}`,language:_(r,`language`)}}catch{return{ok:!1,message:`Couldn't reach the server. Try again.`}}}async#d(e){if(this._removeError=null,e===this._contentLanguage)return;if(this._multilingualEnabled){let t=this._contentLanguage;if(!await d({title:this.labels.changePrimaryTitle,message:B(this.labels.changePrimaryBody,{next:this.#r(e),previous:this.#r(t),prefix:this.#i(t)}),confirmLabel:this.labels.changePrimaryConfirm,cancelLabel:this.labels.cancel}))return;this._savingSite=!0;let n=await this.#u(`/primary`,{language:e});if(this._savingSite=!1,!n.ok){u(n.message??``,`error`);return}this._additional=[...this._additional.filter(t=>t!==e),t],this._contentLanguage=e,n.message&&u(n.message);return}this._savingSite=!0;let t=this._contentLanguage;this._contentLanguage=e;let n=await this.#u(``,{contentLanguage:e});if(this._savingSite=!1,!n.ok){this._contentLanguage=t,u(n.message??``,`error`);return}n.message&&u(n.message)}async#f(e){let t=this._dashboardLanguage;this._dashboardLanguage=e,this._savingDashboard=!0;let n=await this.#u(``,{dashboardLanguage:e});if(this._savingDashboard=!1,!n.ok){this._dashboardLanguage=t,u(n.message??``,`error`);return}window.location.reload()}async#p(e){this._removeError=null;let t=await this.#u(`/add`,{language:e});if(!t.ok){u(t.message??``,`error`);return}this._additional=[...this._additional,e],t.message&&u(t.message)}async#m(e){this._removeError=null;let t=this._multilingualEnabled&&this._additional.length===1&&this._additional[0]===e;if(t&&!await d({title:this.labels.removeLastTitle,message:B(this.labels.removeLastBody,{language:this.#r(e),prefix:this.#i(e)}),confirmLabel:this.labels.removeLastConfirm,cancelLabel:this.labels.cancel}))return;let n=await this.#u(`/remove`,{language:e});if(!n.ok){this._removeError={tag:e,message:n.message??``};return}if(this._additional=this._additional.filter(t=>t!==e),t){this._multilingualEnabled=!1,n.message&&c(n.message),window.location.reload();return}n.message&&u(n.message)}async#h(){if(this._removeError=null,!await d({title:this.labels.disableTitle,message:B(this.labels.disableBody,{prefix:this.#i(this._additional[0]??`en`)}),confirmLabel:this.labels.disableConfirm,cancelLabel:this.labels.cancel}))return;let e=await this.#u(`/disable`,{});if(!e.ok){u(e.message??``,`error`);return}this._multilingualEnabled=!1,e.message&&c(e.message),window.location.reload()}#g(){this._removeError=null,this._enableError=null,this._enablePrimary=this._contentLanguage,this._enableAdditional=[...this._additional],this._enableOpen=!0,this.updateComplete.then(()=>{let e=this.querySelector(`[data-enable-dialog]`);e&&!e.open&&e.showModal(),e?.querySelector(`[data-enable-panel]`)?.focus()})}#_(){let e=this.querySelector(`[data-enable-dialog]`);e?.open&&e.close(),this._enableOpen=!1}async#v(){if(this._enableAdditional.length===0||this._enableBusy)return;this._enableBusy=!0,this._enableError=null;let e=await this.#u(`/enable`,{primary:this._enablePrimary,additional:this._enableAdditional});if(this._enableBusy=!1,!e.ok){this._enableError={message:e.message??``,...e.language?{language:e.language}:{}};return}this._contentLanguage=this._enablePrimary,this._additional=[...this._enableAdditional],this._multilingualEnabled=!0,this._unmarkedPostCount=0,this.#_(),e.message&&c(e.message),window.location.reload()}get#y(){return this.#b??={search:this.labels.searchPlaceholder,empty:this.labels.noMatches},this.#b}#b=null;#x(e){return o`
297
+ `}};customElements.define(`jant-settings-general`,F);var I=`${typeof __JANT_DEV__<`u`&&__JANT_DEV__===!0?`https://jant-cloud.localtest.me`:`https://jant.me`}/docs`;function L(e=``){return e?`${I}/${e}`:I}var R=[``,`en`,`zh-Hans`,`zh-Hant`],z=L(`multilingual`);function B(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??e)}var V=class extends i{static properties={labels:{type:Object},locales:{type:Array},_contentLanguage:{state:!0},_dashboardLanguage:{state:!0},_multilingualEnabled:{state:!0},_additional:{state:!0},_unmarkedPostCount:{state:!0},_sitePathPrefix:{state:!0},_savingSite:{state:!0},_savingDashboard:{state:!0},_removeError:{state:!0},_rowMenuOpen:{state:!0},_enableError:{state:!0},_enableOpen:{state:!0},_enableAdditional:{state:!0},_enablePrimary:{state:!0},_enableBusy:{state:!0}};#e=z;createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this.labels={},this.locales=[],this._contentLanguage=`en`,this._dashboardLanguage=``,this._multilingualEnabled=!1,this._additional=[],this._unmarkedPostCount=0,this._sitePathPrefix=``,this._savingSite=!1,this._savingDashboard=!1,this._removeError=null,this._rowMenuOpen=null,this._enableError=null,this._enableOpen=!1,this._enableAdditional=[],this._enablePrimary=`en`,this._enableBusy=!1}connectedCallback(){super.connectedCallback(),this.#t(),document.addEventListener(`click`,this.#s),document.addEventListener(`keydown`,this.#c)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(`click`,this.#s),document.removeEventListener(`keydown`,this.#c)}#t(){let e=document.getElementById(`language-settings-initial-data`);if(!e?.textContent)return;let t;try{t=JSON.parse(e.textContent)}catch{return}let n=t;this._contentLanguage=n.contentLanguage??`en`,this._dashboardLanguage=n.dashboardLanguage??``,this._multilingualEnabled=n.multilingualEnabled??!1,this._additional=Array.isArray(n.additionalLanguages)?[...n.additionalLanguages]:[],this._unmarkedPostCount=n.unmarkedPostCount??0,this._sitePathPrefix=n.sitePathPrefix??``,this.#e=n.multilingualDocsUrl||z}#n(e){return this.locales.find(t=>t.tag===e)??{tag:e,native:e,english:e,coverage:0}}#r(e){let t=this.#n(e);return t.native||t.tag}#i(e){return`${this._sitePathPrefix}/${e.toLowerCase()}`}#a(e){return`${this._sitePathPrefix}/settings/language${e}`}#o(){return this.querySelector(`jant-locale-picker[open]`)!==null}#s=e=>{if(!this._rowMenuOpen)return;let t=e.target;t&&this.contains(t)&&t.closest?.(`[data-row-menu]`)||(this._rowMenuOpen=null)};#c=e=>{if(e.key===`Escape`){if(this._rowMenuOpen){e.stopPropagation(),this._rowMenuOpen=null;return}this._enableOpen&&(e.stopPropagation(),this.#_())}};#l(e){this._rowMenuOpen=this._rowMenuOpen===e?null:e}async#u(e,t){try{let n=await fetch(this.#a(e),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(t)}),r=await f(n);return n.ok?{ok:!0,message:_(r,`toast`)}:{ok:!1,message:_(r,`error`)??`HTTP ${n.status}`,language:_(r,`language`)}}catch{return{ok:!1,message:`Couldn't reach the server. Try again.`}}}async#d(e){if(this._removeError=null,e===this._contentLanguage)return;if(this._multilingualEnabled){let t=this._contentLanguage;if(!await d({title:this.labels.changePrimaryTitle,message:B(this.labels.changePrimaryBody,{next:this.#r(e),previous:this.#r(t),prefix:this.#i(t)}),confirmLabel:this.labels.changePrimaryConfirm,cancelLabel:this.labels.cancel}))return;this._savingSite=!0;let n=await this.#u(`/primary`,{language:e});if(this._savingSite=!1,!n.ok){a(n.message??``,`error`);return}this._additional=[...this._additional.filter(t=>t!==e),t],this._contentLanguage=e,n.message&&a(n.message);return}this._savingSite=!0;let t=this._contentLanguage;this._contentLanguage=e;let n=await this.#u(``,{contentLanguage:e});if(this._savingSite=!1,!n.ok){this._contentLanguage=t,a(n.message??``,`error`);return}n.message&&a(n.message)}async#f(e){let t=this._dashboardLanguage;this._dashboardLanguage=e,this._savingDashboard=!0;let n=await this.#u(``,{dashboardLanguage:e});if(this._savingDashboard=!1,!n.ok){this._dashboardLanguage=t,a(n.message??``,`error`);return}window.location.reload()}async#p(e){this._removeError=null;let t=await this.#u(`/add`,{language:e});if(!t.ok){a(t.message??``,`error`);return}this._additional=[...this._additional,e],t.message&&a(t.message)}async#m(e){this._removeError=null;let t=this._multilingualEnabled&&this._additional.length===1&&this._additional[0]===e;if(t&&!await d({title:this.labels.removeLastTitle,message:B(this.labels.removeLastBody,{language:this.#r(e),prefix:this.#i(e)}),confirmLabel:this.labels.removeLastConfirm,cancelLabel:this.labels.cancel}))return;let n=await this.#u(`/remove`,{language:e});if(!n.ok){this._removeError={tag:e,message:n.message??``};return}if(this._additional=this._additional.filter(t=>t!==e),t){this._multilingualEnabled=!1,n.message&&r(n.message),window.location.reload();return}n.message&&a(n.message)}async#h(){if(this._removeError=null,!await d({title:this.labels.disableTitle,message:B(this.labels.disableBody,{prefix:this.#i(this._additional[0]??`en`)}),confirmLabel:this.labels.disableConfirm,cancelLabel:this.labels.cancel}))return;let e=await this.#u(`/disable`,{});if(!e.ok){a(e.message??``,`error`);return}this._multilingualEnabled=!1,e.message&&r(e.message),window.location.reload()}#g(){this._removeError=null,this._enableError=null,this._enablePrimary=this._contentLanguage,this._enableAdditional=[...this._additional],this._enableOpen=!0,this.updateComplete.then(()=>{let e=this.querySelector(`[data-enable-dialog]`);e&&!e.open&&e.showModal(),e?.querySelector(`[data-enable-panel]`)?.focus()})}#_(){let e=this.querySelector(`[data-enable-dialog]`);e?.open&&e.close(),this._enableOpen=!1}async#v(){if(this._enableAdditional.length===0||this._enableBusy)return;this._enableBusy=!0,this._enableError=null;let e=await this.#u(`/enable`,{primary:this._enablePrimary,additional:this._enableAdditional});if(this._enableBusy=!1,!e.ok){this._enableError={message:e.message??``,...e.language?{language:e.language}:{}};return}this._contentLanguage=this._enablePrimary,this._additional=[...this._enableAdditional],this._multilingualEnabled=!0,this._unmarkedPostCount=0,this.#_(),e.message&&r(e.message),window.location.reload()}get#y(){return this.#b??={search:this.labels.searchPlaceholder,empty:this.labels.noMatches},this.#b}#b=null;#x(e){return t`
298
298
  <jant-locale-picker
299
299
  .locales=${this.locales}
300
300
  .labels=${this.#y}
@@ -305,10 +305,10 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
305
305
  .labelledby=${e.labelId}
306
306
  @locale-select=${t=>e.onSelect(t.detail.tag)}
307
307
  ></jant-locale-picker>
308
- `}#S(e){return o`
308
+ `}#S(e){return t`
309
309
  <div class="flex flex-wrap items-center gap-2" role="alert">
310
310
  <p class="text-sm text-destructive">${e.message}</p>
311
- ${e.language?o`
311
+ ${e.language?t`
312
312
  <button
313
313
  type="button"
314
314
  class="btn-sm-outline"
@@ -317,9 +317,9 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
317
317
  >
318
318
  ${B(this.labels.addMissingLanguage,{language:this.#r(e.language)})}
319
319
  </button>
320
- `:s}
320
+ `:n}
321
321
  </div>
322
- `}#C(e){e&&(this._enableError=null,!(e===this._enablePrimary||this._enableAdditional.includes(e))&&(this._enableAdditional=[...this._enableAdditional,e]))}#w(){if(!this._enableOpen)return s;let e=this._unmarkedPostCount>0?B(this.labels.enableMarkWarning,{language:this.#r(this._enablePrimary)}):null;return o`
322
+ `}#C(e){e&&(this._enableError=null,!(e===this._enablePrimary||this._enableAdditional.includes(e))&&(this._enableAdditional=[...this._enableAdditional,e]))}#w(){if(!this._enableOpen)return n;let e=this._unmarkedPostCount>0?B(this.labels.enableMarkWarning,{language:this.#r(this._enablePrimary)}):null;return t`
323
323
  <dialog
324
324
  class="dialog confirm-dialog"
325
325
  data-enable-dialog
@@ -345,7 +345,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
345
345
  <span id="language-enable-primary-label" class="label"
346
346
  >${this.labels.primaryLanguage}</span
347
347
  >
348
- ${this.#x({labelId:`language-enable-primary-label`,current:this._enablePrimary,exclude:this._enableAdditional,triggerLabel:this.#r(this._enablePrimary),triggerClass:a,onSelect:e=>{this._enablePrimary=e,this._enableAdditional=this._enableAdditional.filter(t=>t!==e)}})}
348
+ ${this.#x({labelId:`language-enable-primary-label`,current:this._enablePrimary,exclude:this._enableAdditional,triggerLabel:this.#r(this._enablePrimary),triggerClass:u,onSelect:e=>{this._enablePrimary=e,this._enableAdditional=this._enableAdditional.filter(t=>t!==e)}})}
349
349
  <p class="text-sm text-muted-foreground mt-1">
350
350
  ${this.labels.primaryLanguageHelp}
351
351
  </p>
@@ -356,7 +356,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
356
356
  >${this.labels.otherLanguages}</span
357
357
  >
358
358
  <div class="flex flex-wrap items-center gap-2">
359
- ${this._enableAdditional.map(e=>o`
359
+ ${this._enableAdditional.map(e=>t`
360
360
  <span class="badge-secondary gap-1">
361
361
  ${this.#r(e)}
362
362
  <button
@@ -373,7 +373,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
373
373
  </div>
374
374
  </div>
375
375
 
376
- ${e?o`
376
+ ${e?t`
377
377
  <div class="alert">
378
378
  <svg
379
379
  xmlns="http://www.w3.org/2000/svg"
@@ -397,16 +397,16 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
397
397
  <p>${this.labels.enableFixHint}</p>
398
398
  </section>
399
399
  </div>
400
- `:s}
400
+ `:n}
401
401
 
402
402
  <p class="text-sm text-muted-foreground">
403
403
  ${this.labels.enableReassurance}
404
404
  </p>
405
405
 
406
- ${this._enableAdditional.length===0?o`<p class="text-sm text-muted-foreground">
406
+ ${this._enableAdditional.length===0?t`<p class="text-sm text-muted-foreground">
407
407
  ${this.labels.enableNeedsLanguage}
408
- </p>`:s}
409
- ${this._enableError?this.#S(this._enableError):s}
408
+ </p>`:n}
409
+ ${this._enableError?this.#S(this._enableError):n}
410
410
  </div>
411
411
 
412
412
  <footer class="confirm-dialog-actions">
@@ -429,20 +429,20 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
429
429
  </footer>
430
430
  </div>
431
431
  </dialog>
432
- `}#T(e){let t=this._rowMenuOpen===e,n=this.#r(e);return o`
432
+ `}#T(e){let r=this._rowMenuOpen===e,i=this.#r(e);return t`
433
433
  <span class="relative ml-auto flex items-center" data-row-menu>
434
434
  <button
435
435
  type="button"
436
436
  class="btn-sm-ghost text-muted-foreground"
437
437
  aria-haspopup="menu"
438
- aria-expanded=${t?`true`:`false`}
439
- aria-label=${B(this.labels.languageMenu,{language:n})}
438
+ aria-expanded=${r?`true`:`false`}
439
+ aria-label=${B(this.labels.languageMenu,{language:i})}
440
440
  data-language-menu
441
441
  @click=${()=>this.#l(e)}
442
442
  >
443
443
  ⋯
444
444
  </button>
445
- ${t?o`
445
+ ${r?t`
446
446
  <div
447
447
  role="menu"
448
448
  class="absolute right-0 top-full z-20 mt-1 min-w-40 rounded-md border bg-popover py-1 text-popover-foreground shadow-md"
@@ -462,12 +462,12 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
462
462
  class="block w-full cursor-pointer px-3 py-2 text-left text-sm text-destructive hover:bg-accent"
463
463
  @click=${()=>{this._rowMenuOpen=null,this.#m(e)}}
464
464
  >
465
- ${B(this.labels.removeLanguage,{language:n})}
465
+ ${B(this.labels.removeLanguage,{language:i})}
466
466
  </button>
467
467
  </div>
468
- `:s}
468
+ `:n}
469
469
  </span>
470
- `}#E(){let e=[this._contentLanguage,...this._additional];return o`
470
+ `}#E(){let e=[this._contentLanguage,...this._additional];return t`
471
471
  <div class="field">
472
472
  <span id="language-list-label" class="label"
473
473
  >${this.labels.languagesLabel}${this._savingSite?` ${this.labels.saving}`:``}</span
@@ -476,30 +476,30 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
476
476
  class="flex flex-col rounded-md border divide-y"
477
477
  aria-labelledby="language-list-label"
478
478
  >
479
- ${e.map(e=>{let t=e===this._contentLanguage,n=t?`${this._sitePathPrefix}/`:this.#i(e);return o`
479
+ ${e.map(e=>{let r=e===this._contentLanguage,i=r?`${this._sitePathPrefix}/`:this.#i(e);return t`
480
480
  <li class="flex flex-col px-3 py-1.5 text-sm">
481
481
  <div class="flex min-h-8 items-center gap-3">
482
482
  <span class="min-w-0 truncate" lang=${e}
483
483
  >${this.#r(e)}</span
484
484
  >
485
485
  <a
486
- href=${n}
486
+ href=${i}
487
487
  target="_blank"
488
488
  rel="noopener noreferrer"
489
489
  class="shrink-0"
490
490
  >
491
491
  <code
492
492
  class="rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
493
- >${n}</code
493
+ >${i}</code
494
494
  >
495
495
  </a>
496
- ${t?o`<span class="badge-secondary ml-auto"
496
+ ${r?t`<span class="badge-secondary ml-auto"
497
497
  >${this.labels.primaryBadge}</span
498
498
  >`:this.#T(e)}
499
499
  </div>
500
- ${this._removeError?.tag===e?o`
500
+ ${this._removeError?.tag===e?t`
501
501
  <p class="pb-1 text-sm text-destructive" role="alert">
502
- ${this._removeError.message}${this._multilingualEnabled?o`
502
+ ${this._removeError.message}${this._multilingualEnabled?t`
503
503
  <a
504
504
  class="underline underline-offset-2"
505
505
  href=${`${this.#i(e)}/archive`}
@@ -507,9 +507,9 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
507
507
  rel="noopener noreferrer"
508
508
  >${this.labels.viewPosts}</a
509
509
  >
510
- `:s}
510
+ `:n}
511
511
  </p>
512
- `:s}
512
+ `:n}
513
513
  </li>
514
514
  `})}
515
515
  </ul>
@@ -517,17 +517,17 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
517
517
  ${this.#x({labelId:`language-list-label`,exclude:[this._contentLanguage,...this._additional],triggerLabel:`+ ${this.labels.addLanguage}`,triggerClass:`btn-sm-outline`,onSelect:e=>void this.#p(e)})}
518
518
  </div>
519
519
  </div>
520
- `}render(){return this.labels.contentLanguage?o`
520
+ `}render(){return this.labels.contentLanguage?t`
521
521
  <div class="flex flex-col gap-8">
522
522
  <section class="flex flex-col gap-4">
523
523
  <h2 class="text-lg font-medium">${this.labels.siteSection}</h2>
524
524
 
525
- ${this._multilingualEnabled?this.#E():o`
525
+ ${this._multilingualEnabled?this.#E():t`
526
526
  <div class="field">
527
527
  <span id="language-primary-label" class="label"
528
528
  >${this.labels.contentLanguage}</span
529
529
  >
530
- ${this.#x({labelId:`language-primary-label`,current:this._contentLanguage,exclude:[],triggerLabel:this.#r(this._contentLanguage),triggerClass:a,onSelect:e=>void this.#d(e)})}
530
+ ${this.#x({labelId:`language-primary-label`,current:this._contentLanguage,exclude:[],triggerLabel:this.#r(this._contentLanguage),triggerClass:u,onSelect:e=>void this.#d(e)})}
531
531
  <p class="text-sm text-muted-foreground mt-1">
532
532
  ${this.labels.contentLanguageHelp}${this._savingSite?` ${this.labels.saving}`:``}
533
533
  </p>
@@ -551,7 +551,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
551
551
  — ${this.labels.multilingualDocsHelp}
552
552
  </p>
553
553
  <div class="flex items-center gap-3">
554
- ${this._multilingualEnabled?o`
554
+ ${this._multilingualEnabled?t`
555
555
  <span class="badge-secondary">${this.labels.statusOn}</span>
556
556
  <button
557
557
  type="button"
@@ -561,7 +561,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
561
561
  >
562
562
  ${this.labels.disableConfirm}
563
563
  </button>
564
- `:o`
564
+ `:t`
565
565
  <button
566
566
  type="button"
567
567
  class="btn-sm-outline"
@@ -587,7 +587,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
587
587
  ?disabled=${this._savingDashboard}
588
588
  @change=${e=>void this.#f(e.target.value)}
589
589
  >
590
- ${R.map(e=>o`
590
+ ${R.map(e=>t`
591
591
  <option
592
592
  value=${e}
593
593
  ?selected=${this._dashboardLanguage===e}
@@ -604,7 +604,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
604
604
  </div>
605
605
 
606
606
  ${this.#w()}
607
- `:s}};customElements.define(`jant-settings-language`,V);var H=class extends l{static properties={avatarUrl:{type:String,attribute:`avatar-url`},showInHeader:{type:Boolean,attribute:`show-in-header`},labels:{type:Object},_showInHeader:{state:!0},_origShowInHeader:{state:!0},_dirty:{state:!0},_loading:{state:!0},_removeLoading:{state:!0}};createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this.avatarUrl=``,this.showInHeader=!1,this.labels={},this._showInHeader=!1,this._origShowInHeader=!1,this._dirty=!1,this._loading=!1,this._removeLoading=!1}connectedCallback(){super.connectedCallback(),this._showInHeader=this.showInHeader,this._origShowInHeader=this.showInHeader}saved(){this._origShowInHeader=this._showInHeader,this._dirty=!1,this._loading=!1}saveError(){this._loading=!1}removeError(){this._removeLoading=!1}_toggleDisplay(){this._showInHeader=!this._showInHeader,this._dirty=this._showInHeader!==this._origShowInHeader}_cancelDisplay(){this._showInHeader=this._origShowInHeader,this._dirty=!1}_saveDisplay(){!this._loading&&this._dirty&&(this._loading=!0,this.dispatchEvent(new CustomEvent(`jant:settings-save`,{bubbles:!0,detail:{endpoint:`/settings/avatar/display`,data:{showHeaderAvatar:this._showInHeader?`true`:``},section:`avatar-display`}})))}async _removeAvatar(){await d({message:this.labels.confirmRemoveAvatar,confirmLabel:this.labels.remove,cancelLabel:this.labels.cancel,tone:`danger`})&&(this._removeLoading||(this._removeLoading=!0,this.dispatchEvent(new CustomEvent(`jant:avatar-remove`,{bubbles:!0,detail:{endpoint:`/settings/avatar/remove`}}))))}_renderPreview(){let e=`rounded-full size-16 overflow-hidden border border-border/70 bg-muted/40 flex items-center justify-center shrink-0`;return this.avatarUrl?o`
607
+ `:n}};customElements.define(`jant-settings-language`,V);var H=class extends i{static properties={avatarUrl:{type:String,attribute:`avatar-url`},showInHeader:{type:Boolean,attribute:`show-in-header`},labels:{type:Object},_showInHeader:{state:!0},_origShowInHeader:{state:!0},_dirty:{state:!0},_loading:{state:!0},_removeLoading:{state:!0}};createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this.avatarUrl=``,this.showInHeader=!1,this.labels={},this._showInHeader=!1,this._origShowInHeader=!1,this._dirty=!1,this._loading=!1,this._removeLoading=!1}connectedCallback(){super.connectedCallback(),this._showInHeader=this.showInHeader,this._origShowInHeader=this.showInHeader}saved(){this._origShowInHeader=this._showInHeader,this._dirty=!1,this._loading=!1}saveError(){this._loading=!1}removeError(){this._removeLoading=!1}_toggleDisplay(){this._showInHeader=!this._showInHeader,this._dirty=this._showInHeader!==this._origShowInHeader}_cancelDisplay(){this._showInHeader=this._origShowInHeader,this._dirty=!1}_saveDisplay(){!this._loading&&this._dirty&&(this._loading=!0,this.dispatchEvent(new CustomEvent(`jant:settings-save`,{bubbles:!0,detail:{endpoint:`/settings/avatar/display`,data:{showHeaderAvatar:this._showInHeader?`true`:``},section:`avatar-display`}})))}async _removeAvatar(){await d({message:this.labels.confirmRemoveAvatar,confirmLabel:this.labels.remove,cancelLabel:this.labels.cancel,tone:`danger`})&&(this._removeLoading||(this._removeLoading=!0,this.dispatchEvent(new CustomEvent(`jant:avatar-remove`,{bubbles:!0,detail:{endpoint:`/settings/avatar/remove`}}))))}_renderPreview(){let e=`rounded-full size-16 overflow-hidden border border-border/70 bg-muted/40 flex items-center justify-center shrink-0`;return this.avatarUrl?t`
608
608
  <div class=${e}>
609
609
  <img
610
610
  src=${this.avatarUrl}
@@ -612,7 +612,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
612
612
  class="w-full h-full object-cover"
613
613
  />
614
614
  </div>
615
- `:o`
615
+ `:t`
616
616
  <div class="${e} text-muted-foreground">
617
617
  <svg
618
618
  xmlns="http://www.w3.org/2000/svg"
@@ -630,7 +630,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
630
630
  <path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" />
631
631
  </svg>
632
632
  </div>
633
- `}render(){return o`
633
+ `}render(){return t`
634
634
  <div>
635
635
  <h2 class="text-lg font-semibold mb-4">${this.labels.blogAvatar}</h2>
636
636
  <div class="flex flex-col gap-4">
@@ -657,7 +657,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
657
657
  />
658
658
  </label>
659
659
  </form>
660
- ${this.avatarUrl?o`
660
+ ${this.avatarUrl?t`
661
661
  <button
662
662
  type="button"
663
663
  class="btn-outline text-sm"
@@ -666,7 +666,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
666
666
  >
667
667
  ${this.labels.remove}
668
668
  </button>
669
- `:s}
669
+ `:n}
670
670
  </div>
671
671
  </div>
672
672
  <p class="text-sm text-muted-foreground">${this.labels.avatarHelp}</p>
@@ -686,7 +686,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
686
686
  ?disabled=${this._loading||!this._dirty}
687
687
  @click=${this._saveDisplay}
688
688
  >
689
- ${this._loading?o`<svg
689
+ ${this._loading?t`<svg
690
690
  class="animate-spin size-4"
691
691
  xmlns="http://www.w3.org/2000/svg"
692
692
  viewBox="0 0 24 24"
@@ -698,7 +698,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
698
698
  role="status"
699
699
  >
700
700
  <path d="M21 12a9 9 0 1 1-6.219-8.56" />
701
- </svg>`:s}
701
+ </svg>`:n}
702
702
  ${this.labels.save}
703
703
  </button>
704
704
  <button
@@ -712,62 +712,62 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
712
712
  </div>
713
713
  </div>
714
714
  </div>
715
- `}};customElements.define(`jant-settings-avatar`,H);var U={search:`Search settings`,modifiedOnly:`Show only modified`,modified:`Modified`,locked:`Locked`,reset:`Reset to default`,saving:`Saving…`,saved:`Saved`,saveError:`This setting wasn't saved. Check the value and try again.`,noMatches:`Nothing matches this search. Try a different name or description.`,countTemplate:`{count} settings shown`,openSetting:`Open setting`,configured:`Configured`,notConfigured:`Not configured`};function W(e){if(!g(e))return;let t={};for(let[n,r]of Object.entries(e)){if(typeof r!=`string`)return;t[n]=r}return t}function G(e){if(!g(e))return null;let t=_(e,`key`),n=_(e,`mode`),r=_(e,`type`),i=_(e,`value`),a=_(e,`fallbackValue`),o=_(e,`description`),s=_(e,`settingsPath`),c=_(e,`display`),l=_(e,`fallbackKey`);if(!t||n!==`edit`&&n!==`link`||r!==`boolean`&&r!==`string`&&r!==`number`&&r!==`enum`||i===void 0||a===void 0||o===void 0||typeof e.modified!=`boolean`||typeof e.locked!=`boolean`||n===`link`&&(!s||c!==`value`&&c!==`configured`))return null;let u=Array.isArray(e.options)?e.options.filter(e=>typeof e==`string`):void 0;if(n===`edit`&&r===`enum`&&(!u||u.length===0))return null;let d=W(e.optionLabels);return{key:t,mode:n,type:r,value:i,fallbackValue:a,modified:e.modified,locked:e.locked,description:o,...typeof e.maxLength==`number`&&{maxLength:e.maxLength},...typeof e.min==`number`&&{min:e.min},...typeof e.max==`number`&&{max:e.max},...typeof e.step==`number`&&{step:e.step},...u&&{options:u},...d&&{optionLabels:d},...s&&{settingsPath:s},...c===`value`||c===`configured`?{display:c}:{},...e.resettable===!0&&{resettable:!0},...l&&{fallbackKey:l}}}function K(e){try{let t=JSON.parse(e);return!g(t)||!Array.isArray(t.fields)?[]:t.fields.map(G).filter(e=>e!==null)}catch{return[]}}function q(e){try{let t=JSON.parse(e);if(!g(t))return U;let n={...U};for(let e of Object.keys(n)){let r=t[e];typeof r==`string`&&r&&(n[e]=r)}return n}catch{return U}}var J=class extends l{static properties={endpoint:{type:String},initialData:{type:String,attribute:`initial-data`},labelsJson:{type:String,attribute:`labels`},_items:{state:!0},_labels:{state:!0},_query:{state:!0},_modifiedOnly:{state:!0},_drafts:{state:!0},_pending:{state:!0},_statuses:{state:!0}};_statusTimeouts=new Map;createRenderRoot(){return this}constructor(){super(),this.endpoint=`/api/settings`,this.initialData=``,this.labelsJson=``,this._items=[],this._labels=U,this._query=``,this._modifiedOnly=!1,this._drafts={},this._pending={},this._statuses={}}connectedCallback(){super.connectedCallback(),this.querySelector(`:scope > .config-editor-fallback`)?.remove();let e=this.getAttribute(`initial-data`)??this.initialData,t=this.getAttribute(`labels`)??this.labelsJson;this._items=K(e),this._labels=q(t),this._drafts=Object.fromEntries(this._items.map(e=>[e.key,e.value]))}disconnectedCallback(){for(let e of this._statusTimeouts.values())window.clearTimeout(e);this._statusTimeouts.clear(),super.disconnectedCallback()}_filteredItems(){let e=v(this._query);return this._items.map((t,n)=>({item:t,index:n,rank:e?h([t.key,t.description,t.type,t.value],e):0})).filter(e=>e.rank!==null&&(!this._modifiedOnly||e.item.modified)).sort((e,t)=>(e.rank??0)-(t.rank??0)||e.index-t.index).map(({item:e})=>e)}_setDraft(e,t){this._drafts={...this._drafts,[e]:t},this._statuses[e]&&this._setStatus(e,void 0)}_setPending(e,t){this._pending={...this._pending,[e]:t}}_setStatus(e,t){let n=this._statusTimeouts.get(e);if(n!==void 0&&(window.clearTimeout(n),this._statusTimeouts.delete(e)),this._statuses={...this._statuses,[e]:t},t?.state===`saved`){let t=window.setTimeout(()=>{this._statuses[e]?.state===`saved`&&(this._statuses={...this._statuses,[e]:void 0}),this._statusTimeouts.delete(e)},2e3);this._statusTimeouts.set(e,t)}}_replaceItem(e,t){this._items=this._items.map(n=>n.key===e?t(n):n)}_commitValue(e,t,n){let r={...this._drafts,[e]:t};this._items=this._items.map(i=>i.key===e?{...i,value:t,modified:n}:i.fallbackKey===e?i.modified?{...i,fallbackValue:t}:(r[i.key]=t,{...i,value:t,fallbackValue:t}):i),this._drafts=r}async _save(e,t){if(e.locked||this._pending[e.key])return;let n=e.type===`boolean`||e.type===`enum`,r=e.value;n&&this._replaceItem(e.key,e=>({...e,value:t})),this._setPending(e.key,!0),this._setStatus(e.key,{state:`saving`});try{let n=await fetch(this.endpoint,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({[e.key]:t})});if(!n.ok)throw Error(await m(n,this._labels.saveError));let r=(await f(n)).settings,i=_(r,e.key)??t;this._commitValue(e.key,i,!0),this._setStatus(e.key,{state:`saved`})}catch(t){n&&this._replaceItem(e.key,e=>({...e,value:r})),this._setStatus(e.key,{state:`error`,message:t instanceof Error?t.message:this._labels.saveError})}finally{this._setPending(e.key,!1)}}async _reset(e){if(!(!e.modified||e.locked||e.mode===`link`&&!e.resettable||this._pending[e.key])){this._setPending(e.key,!0),this._setStatus(e.key,{state:`saving`});try{let t=await fetch(`${this.endpoint}/${encodeURIComponent(e.key)}`,{method:`DELETE`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(await m(t,this._labels.saveError));let n=await f(t),r=_(n.settings,e.key)??e.fallbackValue;this._commitValue(e.key,r,!1),this._setStatus(e.key,{state:`saved`})}catch(t){this._setStatus(e.key,{state:`error`,message:t instanceof Error?t.message:this._labels.saveError})}finally{this._setPending(e.key,!1)}}}_renderStatus(e){let t=this._statuses[e.key];return t?t.state===`saving`?o`<span class="config-editor-status" role="status"
715
+ `}};customElements.define(`jant-settings-avatar`,H);var U={search:`Search settings`,modifiedOnly:`Show only modified`,modified:`Modified`,locked:`Locked`,reset:`Reset to default`,saving:`Saving…`,saved:`Saved`,saveError:`This setting wasn't saved. Check the value and try again.`,noMatches:`Nothing matches this search. Try a different name or description.`,countTemplate:`{count} settings shown`,openSetting:`Open setting`,configured:`Configured`,notConfigured:`Not configured`};function W(e){if(!g(e))return;let t={};for(let[n,r]of Object.entries(e)){if(typeof r!=`string`)return;t[n]=r}return t}function G(e){if(!g(e))return null;let t=_(e,`key`),n=_(e,`mode`),r=_(e,`type`),i=_(e,`value`),a=_(e,`fallbackValue`),o=_(e,`description`),s=_(e,`settingsPath`),c=_(e,`display`),l=_(e,`fallbackKey`);if(!t||n!==`edit`&&n!==`link`||r!==`boolean`&&r!==`string`&&r!==`number`&&r!==`enum`||i===void 0||a===void 0||o===void 0||typeof e.modified!=`boolean`||typeof e.locked!=`boolean`||n===`link`&&(!s||c!==`value`&&c!==`configured`))return null;let u=Array.isArray(e.options)?e.options.filter(e=>typeof e==`string`):void 0;if(n===`edit`&&r===`enum`&&(!u||u.length===0))return null;let d=W(e.optionLabels);return{key:t,mode:n,type:r,value:i,fallbackValue:a,modified:e.modified,locked:e.locked,description:o,...typeof e.maxLength==`number`&&{maxLength:e.maxLength},...typeof e.min==`number`&&{min:e.min},...typeof e.max==`number`&&{max:e.max},...typeof e.step==`number`&&{step:e.step},...u&&{options:u},...d&&{optionLabels:d},...s&&{settingsPath:s},...c===`value`||c===`configured`?{display:c}:{},...e.resettable===!0&&{resettable:!0},...l&&{fallbackKey:l}}}function K(e){try{let t=JSON.parse(e);return!g(t)||!Array.isArray(t.fields)?[]:t.fields.map(G).filter(e=>e!==null)}catch{return[]}}function q(e){try{let t=JSON.parse(e);if(!g(t))return U;let n={...U};for(let e of Object.keys(n)){let r=t[e];typeof r==`string`&&r&&(n[e]=r)}return n}catch{return U}}var J=class extends i{static properties={endpoint:{type:String},initialData:{type:String,attribute:`initial-data`},labelsJson:{type:String,attribute:`labels`},_items:{state:!0},_labels:{state:!0},_query:{state:!0},_modifiedOnly:{state:!0},_drafts:{state:!0},_pending:{state:!0},_statuses:{state:!0}};_statusTimeouts=new Map;createRenderRoot(){return this}constructor(){super(),this.endpoint=`/api/settings`,this.initialData=``,this.labelsJson=``,this._items=[],this._labels=U,this._query=``,this._modifiedOnly=!1,this._drafts={},this._pending={},this._statuses={}}connectedCallback(){super.connectedCallback(),this.querySelector(`:scope > .config-editor-fallback`)?.remove();let e=this.getAttribute(`initial-data`)??this.initialData,t=this.getAttribute(`labels`)??this.labelsJson;this._items=K(e),this._labels=q(t),this._drafts=Object.fromEntries(this._items.map(e=>[e.key,e.value]))}disconnectedCallback(){for(let e of this._statusTimeouts.values())window.clearTimeout(e);this._statusTimeouts.clear(),super.disconnectedCallback()}_filteredItems(){let e=v(this._query);return this._items.map((t,n)=>({item:t,index:n,rank:e?h([t.key,t.description,t.type,t.value],e):0})).filter(e=>e.rank!==null&&(!this._modifiedOnly||e.item.modified)).sort((e,t)=>(e.rank??0)-(t.rank??0)||e.index-t.index).map(({item:e})=>e)}_setDraft(e,t){this._drafts={...this._drafts,[e]:t},this._statuses[e]&&this._setStatus(e,void 0)}_setPending(e,t){this._pending={...this._pending,[e]:t}}_setStatus(e,t){let n=this._statusTimeouts.get(e);if(n!==void 0&&(window.clearTimeout(n),this._statusTimeouts.delete(e)),this._statuses={...this._statuses,[e]:t},t?.state===`saved`){let t=window.setTimeout(()=>{this._statuses[e]?.state===`saved`&&(this._statuses={...this._statuses,[e]:void 0}),this._statusTimeouts.delete(e)},2e3);this._statusTimeouts.set(e,t)}}_replaceItem(e,t){this._items=this._items.map(n=>n.key===e?t(n):n)}_commitValue(e,t,n){let r={...this._drafts,[e]:t};this._items=this._items.map(i=>i.key===e?{...i,value:t,modified:n}:i.fallbackKey===e?i.modified?{...i,fallbackValue:t}:(r[i.key]=t,{...i,value:t,fallbackValue:t}):i),this._drafts=r}async _save(e,t){if(e.locked||this._pending[e.key])return;let n=e.type===`boolean`||e.type===`enum`,r=e.value;n&&this._replaceItem(e.key,e=>({...e,value:t})),this._setPending(e.key,!0),this._setStatus(e.key,{state:`saving`});try{let n=await fetch(this.endpoint,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({[e.key]:t})});if(!n.ok)throw Error(await m(n,this._labels.saveError));let r=(await f(n)).settings,i=_(r,e.key)??t;this._commitValue(e.key,i,!0),this._setStatus(e.key,{state:`saved`})}catch(t){n&&this._replaceItem(e.key,e=>({...e,value:r})),this._setStatus(e.key,{state:`error`,message:t instanceof Error?t.message:this._labels.saveError})}finally{this._setPending(e.key,!1)}}async _reset(e){if(!(!e.modified||e.locked||e.mode===`link`&&!e.resettable||this._pending[e.key])){this._setPending(e.key,!0),this._setStatus(e.key,{state:`saving`});try{let t=await fetch(`${this.endpoint}/${encodeURIComponent(e.key)}`,{method:`DELETE`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(await m(t,this._labels.saveError));let n=await f(t),r=_(n.settings,e.key)??e.fallbackValue;this._commitValue(e.key,r,!1),this._setStatus(e.key,{state:`saved`})}catch(t){this._setStatus(e.key,{state:`error`,message:t instanceof Error?t.message:this._labels.saveError})}finally{this._setPending(e.key,!1)}}}_renderStatus(e){let r=this._statuses[e.key];return r?r.state===`saving`?t`<span class="config-editor-status" role="status"
716
716
  >${this._labels.saving}</span
717
- >`:t.state===`saved`?o`<span
717
+ >`:r.state===`saved`?t`<span
718
718
  class="config-editor-status config-editor-status-saved"
719
719
  role="status"
720
720
  >${this._labels.saved}</span
721
- >`:o`<span
721
+ >`:t`<span
722
722
  class="config-editor-status config-editor-status-error"
723
723
  role="alert"
724
- >${t.message}</span
725
- >`:s}_renderControl(e){let t=`config-editor-${e.key.toLowerCase().replaceAll(`_`,`-`)}`,n=!!this._pending[e.key]||e.locked;if(e.type===`boolean`)return o`<input
726
- id=${t}
724
+ >${r.message}</span
725
+ >`:n}_renderControl(e){let r=`config-editor-${e.key.toLowerCase().replaceAll(`_`,`-`)}`,i=!!this._pending[e.key]||e.locked;if(e.type===`boolean`)return t`<input
726
+ id=${r}
727
727
  name=${e.key}
728
728
  type="checkbox"
729
729
  role="switch"
730
730
  class="input"
731
- aria-describedby=${`${t}-description`}
731
+ aria-describedby=${`${r}-description`}
732
732
  .checked=${e.value===`true`}
733
- ?disabled=${n}
733
+ ?disabled=${i}
734
734
  @change=${t=>void this._save(e,String(t.target.checked))}
735
- />`;if(e.type===`enum`)return o`<select
736
- id=${t}
735
+ />`;if(e.type===`enum`)return t`<select
736
+ id=${r}
737
737
  name=${e.key}
738
738
  class="select config-editor-select"
739
- aria-describedby=${`${t}-description`}
739
+ aria-describedby=${`${r}-description`}
740
740
  .value=${e.value}
741
- ?disabled=${n}
741
+ ?disabled=${i}
742
742
  @change=${t=>void this._save(e,t.target.value)}
743
743
  >
744
- ${(e.options??[]).map(t=>o`<option value=${t} ?selected=${t===e.value}>
745
- ${e.optionLabels?.[t]??t}
744
+ ${(e.options??[]).map(n=>t`<option value=${n} ?selected=${n===e.value}>
745
+ ${e.optionLabels?.[n]??n}
746
746
  </option>`)}
747
- </select>`;let r=this._drafts[e.key]??e.value,i=r!==e.value;return o`<input
748
- id=${t}
747
+ </select>`;let a=this._drafts[e.key]??e.value,o=a!==e.value;return t`<input
748
+ id=${r}
749
749
  name=${e.key}
750
750
  class="input config-editor-value-input"
751
751
  type=${e.type===`number`?`number`:`text`}
752
752
  autocomplete="off"
753
753
  spellcheck="false"
754
- aria-describedby=${`${t}-description`}
755
- .value=${r}
756
- maxlength=${e.maxLength??s}
757
- min=${e.min??s}
758
- max=${e.max??s}
759
- step=${e.step??s}
760
- ?disabled=${n}
754
+ aria-describedby=${`${r}-description`}
755
+ .value=${a}
756
+ maxlength=${e.maxLength??n}
757
+ min=${e.min??n}
758
+ max=${e.max??n}
759
+ step=${e.step??n}
760
+ ?disabled=${i}
761
761
  @input=${t=>this._setDraft(e.key,t.target.value)}
762
762
  @blur=${t=>{let n=t.target.value;n!==e.value&&this._save(e,n)}}
763
- @keydown=${t=>{t.key===`Escape`?(t.preventDefault(),this._setDraft(e.key,e.value)):t.key===`Enter`&&!t.isComposing&&i&&(t.preventDefault(),this._save(e,r))}}
764
- />`}_renderLinkedSetting(e){let t=e.display===`configured`?e.value===`true`?this._labels.configured:this._labels.notConfigured:e.value;return o`
763
+ @keydown=${t=>{t.key===`Escape`?(t.preventDefault(),this._setDraft(e.key,e.value)):t.key===`Enter`&&!t.isComposing&&o&&(t.preventDefault(),this._save(e,a))}}
764
+ />`}_renderLinkedSetting(e){let n=e.display===`configured`?e.value===`true`?this._labels.configured:this._labels.notConfigured:e.value;return t`
765
765
  <a
766
766
  class="config-editor-open-control"
767
767
  href=${e.settingsPath??`/settings`}
768
768
  aria-describedby=${`config-editor-${e.key.toLowerCase().replaceAll(`_`,`-`)}-description`}
769
769
  >
770
- <span class="config-editor-linked-value" translate="no">${t}</span>
770
+ <span class="config-editor-linked-value" translate="no">${n}</span>
771
771
  <span class="config-editor-open-action">
772
772
  ${this._labels.openSetting}
773
773
  <svg
@@ -787,7 +787,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
787
787
  </svg>
788
788
  </span>
789
789
  </a>
790
- `}_canReset(e){return e.modified&&!e.locked&&(e.mode===`edit`||e.resettable===!0)}_renderRow(e){let t=`config-editor-${e.key.toLowerCase().replaceAll(`_`,`-`)}`,n=[`config-editor-control-row`,e.mode===`edit`&&e.type===`enum`?`config-editor-control-row-select`:``,e.mode===`edit`&&e.type===`number`?`config-editor-control-row-number`:``].filter(Boolean).join(` `);return o`
790
+ `}_canReset(e){return e.modified&&!e.locked&&(e.mode===`edit`||e.resettable===!0)}_renderRow(e){let r=`config-editor-${e.key.toLowerCase().replaceAll(`_`,`-`)}`,i=[`config-editor-control-row`,e.mode===`edit`&&e.type===`enum`?`config-editor-control-row-select`:``,e.mode===`edit`&&e.type===`number`?`config-editor-control-row-number`:``].filter(Boolean).join(` `);return t`
791
791
  <li
792
792
  class="config-editor-row"
793
793
  data-modified=${String(e.modified)}
@@ -795,28 +795,28 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
795
795
  >
796
796
  <div class="config-editor-copy">
797
797
  <div class="config-editor-heading">
798
- ${e.mode===`edit`?o`<label for=${t}
798
+ ${e.mode===`edit`?t`<label for=${r}
799
799
  ><code class="config-editor-key" translate="no"
800
800
  >${e.key}</code
801
801
  ></label
802
- >`:o`<code class="config-editor-key" translate="no"
802
+ >`:t`<code class="config-editor-key" translate="no"
803
803
  >${e.key}</code
804
804
  >`}
805
- ${e.modified?o`<span class="config-editor-state config-editor-modified"
805
+ ${e.modified?t`<span class="config-editor-state config-editor-modified"
806
806
  >${this._labels.modified}</span
807
- >`:s}
808
- ${e.locked?o`<span class="config-editor-state config-editor-locked"
807
+ >`:n}
808
+ ${e.locked?t`<span class="config-editor-state config-editor-locked"
809
809
  >${this._labels.locked}</span
810
- >`:s}
810
+ >`:n}
811
811
  </div>
812
- <p class="config-editor-description" id=${`${t}-description`}>
812
+ <p class="config-editor-description" id=${`${r}-description`}>
813
813
  ${e.description}
814
814
  </p>
815
815
  </div>
816
816
  <div class="config-editor-value-column">
817
- <div class=${n}>
817
+ <div class=${i}>
818
818
  ${e.mode===`link`?this._renderLinkedSetting(e):this._renderControl(e)}
819
- ${this._canReset(e)?o`<button
819
+ ${this._canReset(e)?t`<button
820
820
  type="button"
821
821
  class="config-editor-reset"
822
822
  aria-label=${this._labels.reset}
@@ -839,12 +839,12 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
839
839
  <path d="M3 12a9 9 0 1 0 3-6.7L3 8" />
840
840
  <path d="M3 3v5h5" />
841
841
  </svg>
842
- </button>`:s}
842
+ </button>`:n}
843
843
  </div>
844
844
  ${this._renderStatus(e)}
845
845
  </div>
846
846
  </li>
847
- `}render(){let e=this._filteredItems(),t=this._labels.countTemplate.replace(`{count}`,String(e.length));return o`
847
+ `}render(){let e=this._filteredItems(),n=this._labels.countTemplate.replace(`{count}`,String(e.length));return t`
848
848
  <div class="config-editor-toolbar">
849
849
  <div class="config-editor-search">
850
850
  <svg
@@ -877,7 +877,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
877
877
  </div>
878
878
  </div>
879
879
  <div class="config-editor-toolbar-meta">
880
- <p class="config-editor-count" aria-live="polite">${t}</p>
880
+ <p class="config-editor-count" aria-live="polite">${n}</p>
881
881
  <label class="config-editor-modified-filter">
882
882
  <input
883
883
  type="checkbox"
@@ -889,12 +889,12 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
889
889
  <span>${this._labels.modifiedOnly}</span>
890
890
  </label>
891
891
  </div>
892
- ${e.length>0?o`<ul class="config-editor-list">
892
+ ${e.length>0?t`<ul class="config-editor-list">
893
893
  ${e.map(e=>this._renderRow(e))}
894
- </ul>`:o`<div class="config-editor-empty" role="status">
894
+ </ul>`:t`<div class="config-editor-empty" role="status">
895
895
  <p>${this._labels.noMatches}</p>
896
896
  </div>`}
897
- `}};customElements.get(`jant-config-editor`)||customElements.define(`jant-config-editor`,J);var Y=300,X=1,Z=class extends l{static properties={labels:{type:Object},apiBase:{type:String,attribute:`api-base`},connectUrl:{type:String,attribute:`connect-url`},installUrl:{type:String,attribute:`install-url`},cancelUrl:{type:String,attribute:`cancel-url`},createRepoNameHint:{type:String,attribute:`create-repo-name-hint`},_installations:{state:!0},_selectedOwner:{state:!0},_ownerOpen:{state:!0},_repos:{state:!0},_totalCount:{state:!0},_hasMore:{state:!0},_nextPage:{state:!0},_reposMode:{state:!0},_repoOpen:{state:!0},_repoSearch:{state:!0},_loadingRepos:{state:!0},_selectedRepo:{state:!0},_classification:{state:!0},_classifying:{state:!0},_confirmText:{state:!0},_connecting:{state:!0},_error:{state:!0}};#e=null;#t=0;#n=!1;#r=null;createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this.labels={},this.apiBase=``,this.connectUrl=``,this.installUrl=``,this.cancelUrl=``,this.createRepoNameHint=``,this._installations=[],this._selectedOwner=null,this._ownerOpen=!1,this._repos=[],this._totalCount=0,this._hasMore=!1,this._nextPage=null,this._reposMode=`list`,this._repoOpen=!1,this._repoSearch=``,this._loadingRepos=!1,this._selectedRepo=null,this._classification=null,this._classifying=!1,this._confirmText=``,this._connecting=!1,this._error=null}connectedCallback(){super.connectedCallback(),document.addEventListener(`click`,this.#m),document.addEventListener(`keydown`,this.#h),window.addEventListener(`focus`,this.#g),this.#i()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(`click`,this.#m),document.removeEventListener(`keydown`,this.#h),window.removeEventListener(`focus`,this.#g),this.#e&&clearTimeout(this.#e)}async#i(){try{let e=await fetch(`${this.apiBase}/installations`,{headers:{Accept:`application/json`},credentials:`same-origin`});if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();this._installations=t.installations;let n=t.installations.length===1?t.installations[0]:null;n&&this.#u(n)}catch(e){this._error=e instanceof Error?e.message:String(e)}}async#a(e,t={}){let n=++this.#t;this._loadingRepos=!0;try{let r=new URLSearchParams({installationId:e});t.q&&r.set(`q`,t.q);let i=await fetch(`${this.apiBase}/repos?${r.toString()}`,{headers:{Accept:`application/json`},credentials:`same-origin`});if(n!==this.#t)return;if(i.status===410){this._installations=this._installations.filter(t=>t.installationId!==e),this._selectedOwner=null,this._repos=[];return}if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??`HTTP ${i.status}`)}let a=await i.json();this._repos=a.repos,this._totalCount=a.totalCount,this._hasMore=a.hasMore,this._nextPage=a.nextPage,this._reposMode=a.mode}catch(e){n===this.#t&&(this._error=e instanceof Error?e.message:String(e))}finally{n===this.#t&&(this._loadingRepos=!1)}}async#o(e,t){this._classifying=!0,this._classification=null,this._confirmText=``;try{let n=await fetch(`${this.apiBase}/classify`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},credentials:`same-origin`,body:JSON.stringify({installationId:e,repo:t})}),r=await n.json();if(!n.ok||!r.classification)throw Error(r.error??`HTTP ${n.status}`);this._classification=r.classification}catch(e){this._error=e instanceof Error?e.message:String(e)}finally{this._classifying=!1}}async#s(){if(this._selectedOwner&&this._selectedRepo&&this._classification){this._connecting=!0,this._error=null;try{let e=this._classification.kind===`foreign`||this._classification.kind===`owned-by-other-site`,t=await fetch(this.connectUrl,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},credentials:`same-origin`,body:JSON.stringify({installationId:this._selectedOwner.installationId,repo:this._selectedRepo.fullName,confirmForeign:e})}),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok)throw Error(n.error??`HTTP ${t.status}`);window.location.href=n.redirect??this.cancelUrl}catch(e){this._error=e instanceof Error?e.message:String(e),this._connecting=!1}}}#c(){let e=this._selectedOwner;if(!e)return;let t=this.createRepoNameHint||``,n=new URL(`https://github.com/new`);t&&n.searchParams.set(`name`,t),n.searchParams.set(`owner`,e.account.login),n.searchParams.set(`visibility`,`private`),this.#n=!0,this.#r=t||null,window.open(n.toString(),`_blank`,`noopener,noreferrer`),this._repoOpen=!1}#l(){if(!this._selectedOwner)return;let e=this._repoSearch.trim();this.#a(this._selectedOwner.installationId,e?{q:e}:{})}#u(e){if(this._selectedOwner?.installationId===e.installationId){this._ownerOpen=!1;return}this._selectedOwner=e,this._ownerOpen=!1,this._selectedRepo=null,this._classification=null,this._confirmText=``,this._repoSearch=``,this.#a(e.installationId)}#d(e){this._selectedRepo=e,this._repoOpen=!1,this._repoSearch=``,this._selectedOwner&&this.#o(this._selectedOwner.installationId,e.fullName)}#f(e){let t=e.target.value;if(this._repoSearch=t,this.#e&&clearTimeout(this.#e),!this._selectedOwner)return;let n=t.trim();if(n.length<X){this._reposMode===`search`&&this.#a(this._selectedOwner.installationId);return}this.#e=setTimeout(()=>{this._selectedOwner&&this.#a(this._selectedOwner.installationId,{q:n})},Y)}#p(){let e=this._repoSearch.trim().toLowerCase();return!e||this._reposMode===`search`?this._repos:this._repos.filter(t=>t.name.toLowerCase().includes(e)||t.fullName.toLowerCase().includes(e))}#m=e=>{if(!this._ownerOpen&&!this._repoOpen)return;let t=e.target,n=this.querySelector(`.repo-picker-owner`),r=this.querySelector(`.repo-picker-repo`);n&&!n.contains(t)&&(this._ownerOpen=!1),r&&!r.contains(t)&&(this._repoOpen=!1)};#h=e=>{e.key===`Escape`&&(e.isComposing||e.keyCode===229||(this._ownerOpen||this._repoOpen)&&(this._ownerOpen=!1,this._repoOpen=!1))};#g=()=>{if(!this.#n)return;let e=this._selectedOwner;if(!e){this.#n=!1;return}let t=this.#r;this.#n=!1,this.#r=null,(async()=>{if(this._repoSearch=``,await this.#a(e.installationId),t){let e=this._repos.find(e=>e.name===t);e&&this.#d(e)}})()};#_(){this._ownerOpen=!this._ownerOpen,this._repoOpen=!1}#v(){this._selectedOwner&&(this._repoOpen=!this._repoOpen,this._ownerOpen=!1,this._repoOpen&&queueMicrotask(()=>{this.querySelector(`.repo-picker-repo-search`)?.focus()}))}render(){return o`
897
+ `}};customElements.get(`jant-config-editor`)||customElements.define(`jant-config-editor`,J);var Y=300,X=1,Z=class extends i{static properties={labels:{type:Object},apiBase:{type:String,attribute:`api-base`},connectUrl:{type:String,attribute:`connect-url`},installUrl:{type:String,attribute:`install-url`},cancelUrl:{type:String,attribute:`cancel-url`},createRepoNameHint:{type:String,attribute:`create-repo-name-hint`},_installations:{state:!0},_selectedOwner:{state:!0},_ownerOpen:{state:!0},_repos:{state:!0},_totalCount:{state:!0},_hasMore:{state:!0},_nextPage:{state:!0},_reposMode:{state:!0},_repoOpen:{state:!0},_repoSearch:{state:!0},_loadingRepos:{state:!0},_selectedRepo:{state:!0},_classification:{state:!0},_classifying:{state:!0},_confirmText:{state:!0},_connecting:{state:!0},_error:{state:!0}};#e=null;#t=0;#n=!1;#r=null;createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this.labels={},this.apiBase=``,this.connectUrl=``,this.installUrl=``,this.cancelUrl=``,this.createRepoNameHint=``,this._installations=[],this._selectedOwner=null,this._ownerOpen=!1,this._repos=[],this._totalCount=0,this._hasMore=!1,this._nextPage=null,this._reposMode=`list`,this._repoOpen=!1,this._repoSearch=``,this._loadingRepos=!1,this._selectedRepo=null,this._classification=null,this._classifying=!1,this._confirmText=``,this._connecting=!1,this._error=null}connectedCallback(){super.connectedCallback(),document.addEventListener(`click`,this.#m),document.addEventListener(`keydown`,this.#h),window.addEventListener(`focus`,this.#g),this.#i()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(`click`,this.#m),document.removeEventListener(`keydown`,this.#h),window.removeEventListener(`focus`,this.#g),this.#e&&clearTimeout(this.#e)}async#i(){try{let e=await fetch(`${this.apiBase}/installations`,{headers:{Accept:`application/json`},credentials:`same-origin`});if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();this._installations=t.installations;let n=t.installations.length===1?t.installations[0]:null;n&&this.#u(n)}catch(e){this._error=e instanceof Error?e.message:String(e)}}async#a(e,t={}){let n=++this.#t;this._loadingRepos=!0;try{let r=new URLSearchParams({installationId:e});t.q&&r.set(`q`,t.q);let i=await fetch(`${this.apiBase}/repos?${r.toString()}`,{headers:{Accept:`application/json`},credentials:`same-origin`});if(n!==this.#t)return;if(i.status===410){this._installations=this._installations.filter(t=>t.installationId!==e),this._selectedOwner=null,this._repos=[];return}if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??`HTTP ${i.status}`)}let a=await i.json();this._repos=a.repos,this._totalCount=a.totalCount,this._hasMore=a.hasMore,this._nextPage=a.nextPage,this._reposMode=a.mode}catch(e){n===this.#t&&(this._error=e instanceof Error?e.message:String(e))}finally{n===this.#t&&(this._loadingRepos=!1)}}async#o(e,t){this._classifying=!0,this._classification=null,this._confirmText=``;try{let n=await fetch(`${this.apiBase}/classify`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},credentials:`same-origin`,body:JSON.stringify({installationId:e,repo:t})}),r=await n.json();if(!n.ok||!r.classification)throw Error(r.error??`HTTP ${n.status}`);this._classification=r.classification}catch(e){this._error=e instanceof Error?e.message:String(e)}finally{this._classifying=!1}}async#s(){if(this._selectedOwner&&this._selectedRepo&&this._classification){this._connecting=!0,this._error=null;try{let e=this._classification.kind===`foreign`||this._classification.kind===`owned-by-other-site`,t=await fetch(this.connectUrl,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},credentials:`same-origin`,body:JSON.stringify({installationId:this._selectedOwner.installationId,repo:this._selectedRepo.fullName,confirmForeign:e})}),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok)throw Error(n.error??`HTTP ${t.status}`);window.location.href=n.redirect??this.cancelUrl}catch(e){this._error=e instanceof Error?e.message:String(e),this._connecting=!1}}}#c(){let e=this._selectedOwner;if(!e)return;let t=this.createRepoNameHint||``,n=new URL(`https://github.com/new`);t&&n.searchParams.set(`name`,t),n.searchParams.set(`owner`,e.account.login),n.searchParams.set(`visibility`,`private`),this.#n=!0,this.#r=t||null,window.open(n.toString(),`_blank`,`noopener,noreferrer`),this._repoOpen=!1}#l(){if(!this._selectedOwner)return;let e=this._repoSearch.trim();this.#a(this._selectedOwner.installationId,e?{q:e}:{})}#u(e){if(this._selectedOwner?.installationId===e.installationId){this._ownerOpen=!1;return}this._selectedOwner=e,this._ownerOpen=!1,this._selectedRepo=null,this._classification=null,this._confirmText=``,this._repoSearch=``,this.#a(e.installationId)}#d(e){this._selectedRepo=e,this._repoOpen=!1,this._repoSearch=``,this._selectedOwner&&this.#o(this._selectedOwner.installationId,e.fullName)}#f(e){let t=e.target.value;if(this._repoSearch=t,this.#e&&clearTimeout(this.#e),!this._selectedOwner)return;let n=t.trim();if(n.length<X){this._reposMode===`search`&&this.#a(this._selectedOwner.installationId);return}this.#e=setTimeout(()=>{this._selectedOwner&&this.#a(this._selectedOwner.installationId,{q:n})},Y)}#p(){let e=this._repoSearch.trim().toLowerCase();return!e||this._reposMode===`search`?this._repos:this._repos.filter(t=>t.name.toLowerCase().includes(e)||t.fullName.toLowerCase().includes(e))}#m=e=>{if(!this._ownerOpen&&!this._repoOpen)return;let t=e.target,n=this.querySelector(`.repo-picker-owner`),r=this.querySelector(`.repo-picker-repo`);n&&!n.contains(t)&&(this._ownerOpen=!1),r&&!r.contains(t)&&(this._repoOpen=!1)};#h=e=>{e.key===`Escape`&&(e.isComposing||e.keyCode===229||(this._ownerOpen||this._repoOpen)&&(this._ownerOpen=!1,this._repoOpen=!1))};#g=()=>{if(!this.#n)return;let e=this._selectedOwner;if(!e){this.#n=!1;return}let t=this.#r;this.#n=!1,this.#r=null,(async()=>{if(this._repoSearch=``,await this.#a(e.installationId),t){let e=this._repos.find(e=>e.name===t);e&&this.#d(e)}})()};#_(){this._ownerOpen=!this._ownerOpen,this._repoOpen=!1}#v(){this._selectedOwner&&(this._repoOpen=!this._repoOpen,this._ownerOpen=!1,this._repoOpen&&queueMicrotask(()=>{this.querySelector(`.repo-picker-repo-search`)?.focus()}))}render(){return t`
898
898
  <div class="flex flex-col gap-6 max-w-lg">
899
899
  <div>
900
900
  <h2 class="text-lg font-medium mb-1">${this.labels.pageTitle}</h2>
@@ -905,11 +905,11 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
905
905
 
906
906
  ${this.#y()} ${this.#x()}
907
907
  ${this.#C()} ${this.#T()}
908
- ${this._error?o`<div class="alert-destructive text-sm" role="alert">
908
+ ${this._error?t`<div class="alert-destructive text-sm" role="alert">
909
909
  <section><p>${this._error}</p></section>
910
- </div>`:s}
910
+ </div>`:n}
911
911
  </div>
912
- `}#y(){let e=this._selectedOwner;return o`
912
+ `}#y(){let e=this._selectedOwner;return t`
913
913
  <div class="field repo-picker-owner relative">
914
914
  <label class="label">${this.labels.ownerLabel}</label>
915
915
  <button
@@ -920,29 +920,29 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
920
920
  aria-expanded=${this._ownerOpen}
921
921
  >
922
922
  <span class="flex items-center gap-2 truncate">
923
- ${e?o`
924
- ${e.account.avatarUrl?o`<img
923
+ ${e?t`
924
+ ${e.account.avatarUrl?t`<img
925
925
  src=${e.account.avatarUrl}
926
926
  alt=""
927
927
  class="w-5 h-5 rounded-full"
928
928
  loading="lazy"
929
- />`:s}
929
+ />`:n}
930
930
  <span class="truncate">${e.account.login}</span>
931
- `:o`<span class="text-muted-foreground"
931
+ `:t`<span class="text-muted-foreground"
932
932
  >${this._installations.length===0?this.labels.ownerEmpty:this.labels.ownerPlaceholder}</span
933
933
  >`}
934
934
  </span>
935
935
  <span class="text-muted-foreground">▾</span>
936
936
  </button>
937
- ${this._ownerOpen?this.#b():s}
937
+ ${this._ownerOpen?this.#b():n}
938
938
  </div>
939
- `}#b(){return o`
939
+ `}#b(){return t`
940
940
  <div
941
941
  class="absolute z-10 mt-1 w-full rounded-md border bg-background shadow-lg"
942
942
  role="listbox"
943
943
  >
944
944
  <ul class="max-h-64 overflow-y-auto py-1">
945
- ${this._installations.map(e=>o`
945
+ ${this._installations.map(e=>t`
946
946
  <li>
947
947
  <button
948
948
  type="button"
@@ -951,12 +951,12 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
951
951
  role="option"
952
952
  aria-selected=${this._selectedOwner?.installationId===e.installationId}
953
953
  >
954
- ${e.account.avatarUrl?o`<img
954
+ ${e.account.avatarUrl?t`<img
955
955
  src=${e.account.avatarUrl}
956
956
  alt=""
957
957
  class="w-5 h-5 rounded-full"
958
958
  loading="lazy"
959
- />`:s}
959
+ />`:n}
960
960
  <span class="truncate">${e.account.login}</span>
961
961
  <span class="ml-auto text-xs text-muted-foreground">
962
962
  ${e.account.type===`Organization`?`Org`:``}
@@ -964,7 +964,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
964
964
  </button>
965
965
  </li>
966
966
  `)}
967
- ${this.installUrl?o`
967
+ ${this.installUrl?t`
968
968
  <li class="border-t mt-1 pt-1">
969
969
  <a
970
970
  href=${this.installUrl}
@@ -973,10 +973,10 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
973
973
  ${this.labels.installAnother}
974
974
  </a>
975
975
  </li>
976
- `:s}
976
+ `:n}
977
977
  </ul>
978
978
  </div>
979
- `}#x(){let e=this._selectedRepo,t=!this._selectedOwner;return o`
979
+ `}#x(){let e=this._selectedRepo,r=!this._selectedOwner;return t`
980
980
  <div class="field repo-picker-repo relative">
981
981
  <label class="label">${this.labels.repositoryLabel}</label>
982
982
  <button
@@ -985,20 +985,20 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
985
985
  @click=${()=>this.#v()}
986
986
  aria-haspopup="listbox"
987
987
  aria-expanded=${this._repoOpen}
988
- ?disabled=${t}
988
+ ?disabled=${r}
989
989
  >
990
990
  <span class="truncate">
991
- ${e?o`<span>${e.name}</span> ${e.private?o`<span class="text-xs text-muted-foreground ml-1"
991
+ ${e?t`<span>${e.name}</span> ${e.private?t`<span class="text-xs text-muted-foreground ml-1"
992
992
  >${this.labels.privateBadge}</span
993
- >`:s}`:o`<span class="text-muted-foreground"
994
- >${t?this.labels.repoPlaceholderNoOwner:this.labels.repoPlaceholder}</span
993
+ >`:n}`:t`<span class="text-muted-foreground"
994
+ >${r?this.labels.repoPlaceholderNoOwner:this.labels.repoPlaceholder}</span
995
995
  >`}
996
996
  </span>
997
997
  <span class="text-muted-foreground">▾</span>
998
998
  </button>
999
- ${this._repoOpen?this.#S():s}
999
+ ${this._repoOpen?this.#S():n}
1000
1000
  </div>
1001
- `}#S(){let e=this.#p();return o`
1001
+ `}#S(){let e=this.#p();return t`
1002
1002
  <div
1003
1003
  class="absolute z-10 mt-1 w-full rounded-md border bg-background shadow-lg"
1004
1004
  >
@@ -1022,16 +1022,16 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
1022
1022
  <span aria-hidden="true">⟳</span>
1023
1023
  </button>
1024
1024
  </div>
1025
- ${this._hasMore&&this._reposMode===`list`?o`<p class="px-3 pt-2 text-xs text-muted-foreground">
1025
+ ${this._hasMore&&this._reposMode===`list`?t`<p class="px-3 pt-2 text-xs text-muted-foreground">
1026
1026
  ${this.labels.repoShowingOf.replace(`{shown}`,String(this._repos.length)).replace(`{total}`,String(this._totalCount))}
1027
1027
  — ${this.labels.repoSearchHint}
1028
- </p>`:s}
1028
+ </p>`:n}
1029
1029
  <ul class="max-h-64 overflow-y-auto py-1" role="listbox">
1030
- ${this._loadingRepos?o`<li class="px-3 py-2 text-sm text-muted-foreground">
1030
+ ${this._loadingRepos?t`<li class="px-3 py-2 text-sm text-muted-foreground">
1031
1031
  ${this.labels.repoLoading}
1032
- </li>`:e.length===0?o`<li class="px-3 py-2 text-sm text-muted-foreground">
1032
+ </li>`:e.length===0?t`<li class="px-3 py-2 text-sm text-muted-foreground">
1033
1033
  ${this.labels.repoEmpty}
1034
- </li>`:e.map(e=>o`
1034
+ </li>`:e.map(e=>t`
1035
1035
  <li>
1036
1036
  <button
1037
1037
  type="button"
@@ -1041,10 +1041,10 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
1041
1041
  aria-selected=${this._selectedRepo?.fullName===e.fullName}
1042
1042
  >
1043
1043
  <span class="truncate">${e.name}</span>
1044
- ${e.private?o`<span
1044
+ ${e.private?t`<span
1045
1045
  class="ml-auto text-xs text-muted-foreground"
1046
1046
  >${this.labels.privateBadge}</span
1047
- >`:s}
1047
+ >`:n}
1048
1048
  </button>
1049
1049
  </li>
1050
1050
  `)}
@@ -1057,34 +1057,34 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
1057
1057
  >
1058
1058
  <span class="flex flex-col">
1059
1059
  <span class="font-medium">${this.labels.createOnGitHub} →</span>
1060
- ${this.createRepoNameHint?o`<span class="text-xs text-muted-foreground">
1060
+ ${this.createRepoNameHint?t`<span class="text-xs text-muted-foreground">
1061
1061
  ${this.labels.createOnGitHubHint}
1062
- </span>`:s}
1062
+ </span>`:n}
1063
1063
  </span>
1064
1064
  </button>
1065
1065
  </div>
1066
1066
  </div>
1067
- `}#C(){if(this._classifying)return o`<p class="text-sm text-muted-foreground">
1067
+ `}#C(){if(this._classifying)return t`<p class="text-sm text-muted-foreground">
1068
1068
  ${this.labels.classifyLoading}
1069
- </p>`;if(!this._classification||!this._selectedRepo)return s;let e=this._classification;if(e.kind===`empty`)return o`<p class="text-sm text-muted-foreground">
1069
+ </p>`;if(!this._classification||!this._selectedRepo)return n;let e=this._classification;if(e.kind===`empty`)return t`<p class="text-sm text-muted-foreground">
1070
1070
  ${this.labels.classificationEmpty}
1071
- </p>`;if(e.kind===`owned`)return o`<p class="text-sm text-muted-foreground">
1071
+ </p>`;if(e.kind===`owned`)return t`<p class="text-sm text-muted-foreground">
1072
1072
  ${this.labels.classificationOwned}
1073
- </p>`;if(e.kind===`owned-by-other-site`)return o`<div class="alert-destructive text-sm" role="alert">
1073
+ </p>`;if(e.kind===`owned-by-other-site`)return t`<div class="alert-destructive text-sm" role="alert">
1074
1074
  <section>
1075
1075
  <p>
1076
1076
  ${this.labels.classificationOwnedByOther.replace(`{host}`,e.marker.site_host)}
1077
1077
  </p>
1078
1078
  </section>
1079
- </div>`;let t=this._selectedRepo.fullName;return o`
1079
+ </div>`;let r=this._selectedRepo.fullName;return t`
1080
1080
  <div class="alert flex flex-col gap-3 text-sm">
1081
1081
  <div>
1082
1082
  <strong class="block mb-1">${this.labels.confirmHeading}</strong>
1083
- <span>${this.labels.confirmBody.replace(`{repo}`,t)}</span>
1083
+ <span>${this.labels.confirmBody.replace(`{repo}`,r)}</span>
1084
1084
  </div>
1085
1085
  <div class="field">
1086
1086
  <label class="label text-xs">
1087
- ${this.labels.confirmInputLabel.replace(`{repo}`,t)}
1087
+ ${this.labels.confirmInputLabel.replace(`{repo}`,r)}
1088
1088
  </label>
1089
1089
  <input
1090
1090
  type="text"
@@ -1097,7 +1097,7 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
1097
1097
  />
1098
1098
  </div>
1099
1099
  </div>
1100
- `}#w(){if(!this._selectedRepo||!this._classification||this._classifying||this._connecting)return!1;let e=this._classification;return e.kind===`owned-by-other-site`?!1:e.kind!==`foreign`||this._confirmText.trim()===this._selectedRepo.fullName}#T(){return o`
1100
+ `}#w(){if(!this._selectedRepo||!this._classification||this._classifying||this._connecting)return!1;let e=this._classification;return e.kind===`owned-by-other-site`?!1:e.kind!==`foreign`||this._confirmText.trim()===this._selectedRepo.fullName}#T(){return t`
1101
1101
  <div class="flex items-center gap-2">
1102
1102
  <button
1103
1103
  type="button"
@@ -1109,4 +1109,4 @@ import{r as e}from"./chunks/runtime-paths-y0_gHowM.js";import{a as t,i as n,r,s
1109
1109
  </button>
1110
1110
  <a href=${this.cancelUrl} class="btn-ghost">${this.labels.cancel}</a>
1111
1111
  </div>
1112
- `}};customElements.define(`jant-repo-picker`,Z);function Q(e){let t=_(e,`siteName`),n=_(e,`siteDescription`),r=_(e,`mainRssFeed`),i=_(e,`timeZone`),a=_(e,`siteFooter`),o=p(e,`showJantBrandingOnHome`),s=p(e,`noindex`),c=_(e,`discover`);return t===void 0||n===void 0||r===void 0||i===void 0||a===void 0||o===void 0||s===void 0||c===void 0?null:{siteName:t,siteDescription:n,mainRssFeed:r,timeZone:i,siteFooter:a,showJantBrandingOnHome:o,noindex:s,discover:c}}document.addEventListener(`jant:settings-save`,async e=>{let{endpoint:t,data:n,section:r}=e.detail,i=document.querySelector(`jant-settings-general`),a=document.querySelector(`jant-settings-avatar`);try{let e=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(n)});if(!e.ok)throw Error(`HTTP ${e.status}`);let o=await f(e),s=_(o,`status`),c=_(o,`url`),l=_(o,`toast`);if(s===`redirect`&&c){window.location.href=c;return}l&&u(l),r===`avatar-display`?a?.saved():i?.sectionSaved(r)}catch{u(`Failed to save. Please try again.`,`error`),r===`avatar-display`?a?.saveError():i?.sectionError(r)}}),document.addEventListener(`jant:avatar-remove`,async e=>{let{endpoint:t}=e.detail,n=document.querySelector(`jant-settings-avatar`);try{let e=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`}});if(!e.ok)throw Error(`HTTP ${e.status}`);let n=await f(e),r=_(n,`status`),i=_(n,`url`);if(r===`redirect`&&i){window.location.href=i;return}}catch{u(`Failed to remove avatar. Please try again.`,`error`),n?.removeError()}});function $(){let e=document.querySelector(`jant-settings-general`);if(!e)return;let t=document.getElementById(`settings-initial-data`);if(t?.textContent)try{let n=Q(JSON.parse(t.textContent));n&&e.initData(n)}catch{}}document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,$):queueMicrotask($);
1112
+ `}};customElements.define(`jant-repo-picker`,Z);function Q(e){let t=_(e,`siteName`),n=_(e,`siteDescription`),r=_(e,`mainRssFeed`),i=_(e,`timeZone`),a=_(e,`siteFooter`),o=p(e,`showJantBrandingOnHome`),s=p(e,`noindex`),c=_(e,`discover`);return t===void 0||n===void 0||r===void 0||i===void 0||a===void 0||o===void 0||s===void 0||c===void 0?null:{siteName:t,siteDescription:n,mainRssFeed:r,timeZone:i,siteFooter:a,showJantBrandingOnHome:o,noindex:s,discover:c}}document.addEventListener(`jant:settings-save`,async e=>{let{endpoint:t,data:n,section:r}=e.detail,i=document.querySelector(`jant-settings-general`),o=document.querySelector(`jant-settings-avatar`);try{let e=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(n)});if(!e.ok)throw Error(`HTTP ${e.status}`);let s=await f(e),c=_(s,`status`),l=_(s,`url`),u=_(s,`toast`);if(c===`redirect`&&l){window.location.href=l;return}u&&a(u),r===`avatar-display`?o?.saved():i?.sectionSaved(r)}catch{a(`Failed to save. Please try again.`,`error`),r===`avatar-display`?o?.saveError():i?.sectionError(r)}}),document.addEventListener(`jant:avatar-remove`,async e=>{let{endpoint:t}=e.detail,n=document.querySelector(`jant-settings-avatar`);try{let e=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`}});if(!e.ok)throw Error(`HTTP ${e.status}`);let n=await f(e),r=_(n,`status`),i=_(n,`url`);if(r===`redirect`&&i){window.location.href=i;return}}catch{a(`Failed to remove avatar. Please try again.`,`error`),n?.removeError()}});function $(){let e=document.querySelector(`jant-settings-general`);if(!e)return;let t=document.getElementById(`settings-initial-data`);if(t?.textContent)try{let n=Q(JSON.parse(t.textContent));n&&e.initData(n)}catch{}}document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,$):queueMicrotask($);