import{a as e,d as t,f as n,p as r,s as i,t as a}from"./hooks.module-BrXTvcfS.js";import{G as o,R as s,xt as c}from"./content_renderer-DOj8g78V.js";import{T as l,U as u,a as d}from"./i18n-BaLR3UdQ.js";import{t as f}from"./jsxRuntime.module-Cao1NCKs.js";import{n as p,r as m}from"./react_utils-Bz0ffU2Y.js";import{J as h,T as g,i as _,k as v,s as y}from"./hooks-ClTXKdUl.js";import{t as b}from"./ActionButton-DqIfNt93.js";import{a as x,r as S}from"./FormList-CnuOJg6b.js";import{t as C}from"./Modal-hBkTa-Ee.js";import{t as w}from"./NoteDetail-k1cc0ILw.js";t();function T({activeNoteId:e}){return f(`nav`,{className:`settings-navigation`,children:O().map(t=>{let n=t.noteId===e;return f(`a`,{href:`#root/_hidden/_options/${t.noteId}`,className:s(`settings-navigation-item no-tooltip-preview`,{active:n}),"aria-current":n?`page`:void 0,children:[f(`span`,{className:t.getIcon()}),f(`span`,{className:`settings-navigation-title`,children:t.title})]},t.noteId)})})}var E=`_optionsAppearance`;function D(){let[e,t]=i(!1),s=r(m),[l,_]=i(()=>new c(`_options-dialog`)),[v,b]=i(null),x=a(null),S=u.isMobile(),{isMasterDetail:T,mobileView:D,switchMobileView:O,resetMobileView:k}=g(x,`options-slide`);return h(`showOptions`,async({section:e})=>{let n=new c(`_options-dialog`);await n.setNote(e??v??E,{keepActiveDialog:!0}),n.triggerEvent=(e,t)=>s?.handleEventInChildren(e,t),_(n),k(e?`page`:`list`),t(!0)}),y(x,n((e,t)=>{e.split(`/`).at(-1)?.startsWith(`_options`)?(l.setNote(e,{viewScope:t,keepActiveDialog:!0}),O(`page`)):o.triggerCommand(`openInPopup`,{noteIdOrPath:e})},[l,O])),f(p.Provider,{value:l,children:f(C,{modalRef:x,title:d(`options.title`),header:T&&(D===`page`?f(N,{onBack:()=>O(`list`)}):f(N,{})),sidebar:T?void 0:f(j,{}),isFullPageOnMobile:!0,customTitleBarButtons:S?void 0:[{iconClassName:`bx-expand-alt`,title:d(`popup-editor.maximize`),onClick:async()=>{if(!l.noteId)return;let{noteId:e,hoistedNoteId:n}=l;await o.tabManager.openInNewTab(e,n,!0),t(!1)}}],className:`options-dialog`,size:`lg`,show:e,onHidden:()=>{l.noteId&&b(l.noteId),t(!1)},children:[T&&f(`div`,{className:`options-mobile-nav`,children:f(M,{onSelect:e=>{l.setNote(e,{keepActiveDialog:!0}),O(`page`)}})}),f(A,{modalRef:x}),f(w,{})]})})}function O(){return _(`_options`).filter(k)}function k(e){return!(!l()&&e.isLabelTruthy(`electronOnly`)||l()&&e.isLabelTruthy(`serverOnly`))}function A({modalRef:t}){let{noteId:n}=v();return e(()=>{let e=t.current;e&&(e.querySelector(`.modal-body`)?.scrollTo({top:0}),e.querySelector(`.note-detail`)?.scrollTo({top:0}))},[t,n]),null}function j(){let{noteId:e}=v();return e?f(T,{activeNoteId:e}):null}function M({onSelect:e}){let t=O(),{noteId:n}=v();return f(S,{onSelect:e,children:t.map(e=>f(x,{icon:e.getIcon(),value:e.noteId,active:e.noteId===n,children:e.title},e.noteId))})}function N({onBack:e}){return e?f(`div`,{className:`options-mobile-page-header`,children:f(b,{icon:`bx bx-chevron-left`,text:d(`options.back`),onClick:e})}):f(`div`,{className:`options-mobile-page-header`,children:[f(`span`,{className:`options-header-icon icon-action bx bx-cog`,"aria-hidden":`true`}),f(`h5`,{className:`options-mobile-page-title`,children:d(`options.title`)})]})}export{D as default,k as isOptionPageVisibleOnPlatform,O as useOptionPages};