const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/api-settings-CQWMP6tw.js","assets/rolldown-runtime-FhOqtrmT.js","assets/api-client-bbJLzRVE.js"])))=>i.map(i=>d[i]);
import{t as e}from"./react-9ZmE0_ty.js";import{r as t}from"./api-client-bbJLzRVE.js";import{K as n}from"./vendor-mermaid-v5g7E-EQ.js";var r=`/assets/github-dark-dimmed.min-BrpRStFV.css`,i=`/assets/github.min-D2BCvnWf.css`,a=`ppm-settings`;function o(){try{let e=localStorage.getItem(a);if(e)return JSON.parse(e)}catch{}return{}}function s(e){return typeof e==`string`?[`explorer`,`git`,`settings`,`database`,`search`,`jira`].includes(e)||e.startsWith(`ext:`):!1}function c(e){let t=o();localStorage.setItem(a,JSON.stringify({...t,...e}))}function l(e){let t=e===`system`?window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:e;document.documentElement.classList.toggle(`dark`,t===`dark`),document.documentElement.classList.toggle(`light`,t===`light`),u(t);let n=document.querySelector(`meta[name="theme-color"]`);n&&n.setAttribute(`content`,t===`dark`?`#0f1419`:`#ffffff`)}function u(e){let t=e===`dark`?r:i,n=document.getElementById(`hljs-theme`);n||(n=document.createElement(`link`),n.id=`hljs-theme`,n.rel=`stylesheet`,document.head.appendChild(n)),n.href!==new URL(t,document.baseURI).href&&(n.href=t)}var d=o(),f=e((e,r)=>({theme:d.theme===`light`||d.theme===`dark`||d.theme===`system`?d.theme:`system`,sidebarCollapsed:d.sidebarCollapsed??!1,sidebarWidth:d.sidebarWidth??280,gitStatusViewMode:d.gitStatusViewMode===`flat`?`flat`:`tree`,wordWrap:d.wordWrap??!1,tabWrap:d.tabWrap??!1,sidebarActiveTab:s(d.sidebarActiveTab)?d.sidebarActiveTab:`explorer`,jiraEnabled:d.jiraEnabled??!1,deviceName:null,version:null,setTheme:n=>{c({theme:n}),l(n),e({theme:n});let r=t();fetch(`/api/settings/theme`,{method:`PUT`,headers:{"Content-Type":`application/json`,...r?{Authorization:`Bearer ${r}`}:{}},body:JSON.stringify({theme:n})}).catch(()=>{})},setDeviceName:async t=>{let r=t.trim();e({deviceName:r||null}),r?document.title=`PPM — ${r}`:document.title=`PPM`;try{let{updateDeviceName:e}=await n(async()=>{let{updateDeviceName:e}=await import(`./api-settings-CQWMP6tw.js`).then(e=>e.n);return{updateDeviceName:e}},__vite__mapDeps([0,1,2]));await e(r)}catch{}},setJiraEnabled:t=>{if(c({jiraEnabled:t}),e({jiraEnabled:t}),!t&&r().sidebarActiveTab===`jira`){let t=`explorer`;c({sidebarActiveTab:t}),e({sidebarActiveTab:t})}},toggleSidebar:()=>{let t=!r().sidebarCollapsed;c({sidebarCollapsed:t}),e({sidebarCollapsed:t})},setSidebarWidth:t=>{let n=Math.max(200,Math.min(600,t));c({sidebarWidth:n}),e({sidebarWidth:n})},setGitStatusViewMode:t=>{c({gitStatusViewMode:t}),e({gitStatusViewMode:t})},toggleWordWrap:()=>{let t=!r().wordWrap;c({wordWrap:t}),e({wordWrap:t})},toggleTabWrap:()=>{let t=!r().tabWrap;c({tabWrap:t}),e({tabWrap:t})},setSidebarActiveTab:t=>{c({sidebarActiveTab:t}),e({sidebarActiveTab:t})},fetchServerInfo:async()=>{try{let n=t(),r=n?{headers:{Authorization:`Bearer ${n}`}}:{},[i,a]=await Promise.all([fetch(`/api/info`,r),fetch(`/api/settings/theme`,r)]),o=await i.json();if(o.ok){let{device_name:t,version:n}=o.data;e({deviceName:t||null,version:n||null}),t&&(document.title=`PPM — ${t}`)}let s=await a.json();if(s.ok&&s.data?.theme){let t=s.data.theme;c({theme:t}),l(t),e({theme:t})}}catch{}}}));export{f as n,l as t};