"use strict";var q=Object.create;var g=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var P=Object.getPrototypeOf;var V=Object.prototype.hasOwnProperty;var i=(t,e)=>g(t,"name",{value:e,configurable:true});var j=(t,e)=>{for(var r in e)g(t,r,{get:e[r],enumerable:true})};var W=(t,e,r,a)=>{if(e&&typeof e==="object"||typeof e==="function"){for(let n of M(e))if(!V.call(t,n)&&n!==r)g(t,n,{get:()=>e[n],enumerable:!(a=H(e,n))||a.enumerable})}return t};var C=(t,e,r)=>(r=t!=null?q(P(t)):{},W(e||!t||!t.__esModule?g(r,"default",{value:t,enumerable:true}):r,t));var F=t=>W(g({},"__esModule",{value:true}),t);var ot={};j(ot,{default:()=>B});module.exports=F(ot);var D=C(require("color"));var E=require("mobx");var O=C(require("react-topbar-progress-indicator"));var y=require("fs-extra");var m=require("../../config");var $=require("../../environment");var R=require("../../environment-remote");var S=require("../workspaces");const I="custom-appearance-style";const G=i(()=>{const t=document.createElement("style");t.id=I;document.querySelector("head")?.append(t)},"createStyleElement");const U=i(t=>{const e=document.querySelector(`#${I}`);if(e){e.innerHTML=t}},"setAppearance");const L=i((t,e)=>{const r=t.lightness();return t.lightness(r-e)},"darkenAbsolute");const X=i(()=>{const t=(0,R.userDataPath)("config","custom.css");return(0,y.pathExistsSync)(t)?(0,y.readFileSync)(t).toString():""},"generateUserCustomCSS");const J=i((t,e)=>{let r;try{r=(0,D.default)(t)}catch{t=m.DEFAULT_APP_SETTINGS.accentColor;r=(0,D.default)(t)}const a=L(r,5).hex();return`
    .theme__dark .app .sidebar .sidebar__button.is-muted,
    .theme__dark .app .sidebar .sidebar__button.is-active,
    .sidebar .sidebar__button.is-muted,
    .sidebar .sidebar__button.is-active,
    .settings .account .invoices .invoices__action button,
    .settings-navigation .settings-navigation__link.is-active .badge,
    a.link,
    button.link,
    .auth .welcome .button:hover,
    .auth .welcome .button__inverted,
    .franz-form .franz-form__radio.is-selected,
    .theme__dark .franz-form__button.franz-form__button--inverted,
    .franz-form__button.franz-form__button--inverted {
      color: ${t};
    }

    .settings .settings__header,
    .settings .settings__close,
    .settings-navigation .settings-navigation__link.is-active,
    a.button,
    button.button,
    .info-bar,
    .info-bar.info-bar--primary,
    .infobox.infobox--primary,
    .theme__dark .badge.badge--primary,
    .badge.badge--primary,
    .content-tabs .content-tabs__tabs .content-tabs__item.is-active,
    #electron-app-title-bar .toolbar-dropdown:not(.open) > .toolbar-button > button:hover,
    #electron-app-title-bar .list-item.selected .menu-item,
    #electron-app-title-bar .list-item.selected:focus .menu-item,
    .theme__dark .quick-switch .active,
    .franz-form .franz-form__toggle-wrapper .franz-form__toggle.is-active .franz-form__toggle-button,
    .theme__dark .franz-form__button,
    .franz-form__button,
    .ferdium__fab,
    .franz-form .franz-form__slider-wrapper .slider::-webkit-slider-thumb,
    span.loader div > div > div {
      background: ${t};
    }

    .settings .settings__header .separator {
      border-right-color: ${t};
    }

    .franz-form .franz-form__radio.is-selected, .tab-item.is-active {
      box-shadow: inset ${e?"0 4px":"4px 0"} 0 0 ${t};
    }

    a.button:hover, button.button:hover {
      background: ${L(r,10).hex()};
    }

    .franz-form__button:hover,
    .franz-form__button.franz-form__button--inverted:hover,
    .settings .settings__close:hover,
    .theme__dark .franz-form__button:hover,
    .theme__dark .franz-form__button.franz-form__button--inverted:hover,
    .theme__dark .settings .settings__close:hover {
      background: ${a};
    }

    .franz-form__button:active,
    .theme__dark .franz-form__button:active {
      background: ${a};
    }

    .settings__close {
      border-color: ${a}!important;
    }

    .theme__dark .franz-form__button.franz-form__button--inverted,
    .franz-form__button.franz-form__button--inverted {
      background: none;
      border-color: ${t};
    }

    .tab-item.is-active {
      background: ${r.lightness(90).hex()};
    }
  `},"generateAccentStyle");const Q=i((t,e,r,a,n,p,x,z,u)=>{const o=Number(t);const _=Number(e)-m.iconSizeBias;const l=1;const f=29;let c;let d;let s;switch(o){case 35:{c=9;d=25;s=48;break}case 45:{c=10;d=21;s=44;break}case 80:{c=11;d=3;s=27;break}case 90:{c=12;d=0;s=25;break}case 100:{c=13;d=2;s=25;break}default:{c=11;d=13;s=37}}if(!a){s=22;d=-5}if($.isWindows||$.isLinux){s=0}const h=Math.max(o/2+_,2);let b;switch(n){case m.SIDEBAR_SERVICES_LOCATION_TOPLEFT:{b=r?"left":"start";break}case m.SIDEBAR_SERVICES_LOCATION_CENTER:{b=r?"center":"center";break}case m.SIDEBAR_SERVICES_LOCATION_BOTTOMRIGHT:{b=r?"right":"end";break}default:{b=r?"left":"start";break}}const A=`filter: grayscale(1);
  opacity: ${x}%;`;const w=z?f:0;return r?`
    .sidebar {
      height: ${o}px !important;
      overflow: hidden !important;
    }
    .sidebar div {
      justify-content: ${b};
    }
    .tab-item {
      height: ${o-l}px !important;
      width: ${o+_+d}px !important;
      min-height: unset;
      overflow: hidden !important;
    }
    .tab-item .tab-item__icon {
      width: ${h}px !important;
      ${p?A:null},
    }
    .tab-item .tab-item__label {
      font-size: ${c}px !important;
    }
    .tab-item.is-label-enabled {
      padding-top: 6px !important;
      padding-bottom: 2px !important;
    }
    .sidebar__button {
      font-size: ${o/3}px !important;
    }
    .app .app__content {
      padding-top: ${o+s}px !important;
    }
    .workspaces-drawer {
      margin-top: -${o}px !important;
    }
    .darwin .sidebar {
      height: ${u?o:o+f-3-w}px !important;
      ${u?`padding-top: ${2}px !important`:null}
    }
    .darwin .app .app__content {
      padding-top: ${u?o:o+s+(w===0?4:4-w)}px !important;
    }
    .darwin .workspaces-drawer {
      margin-top: -${o+f-5-w}px !important;
    }
    .darwin .sidebar .sidebar__button--workspaces.is-active {
      height: ${o-s}px !important;
    }
    .tab-item div {
      overflow: hidden !important;
    }
  `:`
    .sidebar {
      width: ${o}px !important;
    }
    .tabs {
      justify-content: ${b};
    }
    .tab-item {
      width: ${o}px !important;
      height: ${o-l}px !important;
      min-height: ${o-l}px !important;
    }
    .tab-item .tab-item__icon {
      width: ${h}px !important;
      ${p?A:null},
    }
    .sidebar__button {
      font-size: ${o/3}px !important;
    }
    .todos__todos-panel--expanded {
      width: calc(100% - ${300+o}px) !important;
    }
  `},"generateServiceRibbonWidthStyle");const Y=i(t=>{return`
    .sidebar {
      padding-top: 0px !important;
    }
    .window-draggable {
      position: initial;
      background-color: ${t};
    }
    #root {
      /** Remove 28px from app height, otherwise the page will be too high */
      height: calc(100% - 28px);
    }
  `},"generateShowDragAreaStyle");const K=i((t,e)=>{if(!e){return""}const r=Number(t);const a=1;const n=r-a;return`
  .app--compact-workspace {
    --workspace-drawer-width: ${r}px !important;
  }
  .workspaces-drawer.compact {
    width: ${r}px !important;
  }
  .workspaces-drawer [data-tooltip-id="tooltip-workspaces-drawer"].compact {
    height: ${n}px !important;
    min-height: ${n}px !important;
  }
  .app__service > div[class*="WorkspaceSwitchingIndicator-wrapper"] {
    width: calc(100% - ${r}px) !important;
  }
  `},"generateCompactWorkspaceDrawerStyle");let v=false;let T=null;const Z=i((t,e,r,a)=>{if(r||a){return""}const n=e?Number(t):300;const p=v?"transition: none !important;":"";return`
  .app__content {
    transform: translateX(-${n}px) !important;
    ${p}
  }
  `},"generateWorkspaceDrawerTransform");const tt=i((t,e,r)=>{if(!document.querySelector("#vertical-style")){const p=document.createElement("link");p.id="vertical-style";p.rel="stylesheet";p.type="text/css";p.href="./styles/vertical.css";document.head.append(p)}const a=Number(t);const n=r?a:300;return`
  .sidebar {
  ${e?`
    width: calc(100% - ${n}px) !important;
  `:""}
  }

  .sidebar .sidebar__button {
    width: ${a}px;
  }

  .todos__todos-panel--expanded {
    width: calc(100% - ${n+a}px) !important;
  }
  `},"generateVerticalStyle");const et=i(()=>{return`
  .app .app__content {
    width: 100% !important;
    transform: translateX(0px) !important;
  }
  .sidebar__button--workspaces {
    display: none;
  }
  `},"generateOpenWorkspaceStyle");const rt=i(t=>{const e=window?.matchMedia?.("(prefers-reduced-motion: no-preference)");const r=e?.matches?"width 0.5s ease":"none";if(v){return`
  .app .app__content {
    transition: none !important;
  }
  `}const a=t?`transform 0.5s ease, ${r}`:"transform 0.5s ease";return`
  .app .app__content {
    transition: ${a} !important;
  }
  `},"generateAppContentTransition");const at=i((t,e)=>{let r="";const{accentColor:a,serviceRibbonWidth:n,sidebarServicesLocation:p,useGrayscaleServices:x,grayscaleServicesDim:z,iconSize:u,showDragArea:o,useHorizontalStyle:_,alwaysShowWorkspaces:l,showServiceName:f,useCompactWorkspaceDrawer:c}=t;const{isFullScreen:d}=e;const s=o&&!d;if(a.toLowerCase()!==m.DEFAULT_APP_SETTINGS.accentColor.toLowerCase()){r+=J(a,_)}r+=Q(n,u,_,f,p,x,z,s,d);r+=K(n,c);r+=Z(n,c,S.workspaceStore.isWorkspaceDrawerOpen,l);if(s){r+=Y(a)}if(_){r+=tt(n,l,c)}else if(document.querySelector("#vertical-style")){const h=document.querySelector("#vertical-style");if(h){h.remove()}}if(l){r+=et()}r+=rt(l);r+=X();return r},"generateStyle");const N=i(t=>{O.default.config({barThickness:4,barColors:{"0":t.progressbarAccentColor},shadowBlur:5})},"updateProgressbar");const k=i((t,e)=>{const r=t.all?.app??t;const a=at(r,e);U(a);N(r)},"updateStyle");function B(t){const{settings:e,app:r}=t;G();N(e.all.app);(0,E.reaction)(()=>[e.all.app.serviceRibbonWidth,e.all.app.useCompactWorkspaceDrawer],()=>{const a=!S.workspaceStore.isWorkspaceDrawerOpen&&!e.all.app.alwaysShowWorkspaces;if(a){if(T){clearTimeout(T)}v=true;k(e,r);T=setTimeout(()=>{v=false;k(e,r)},50)}else{k(e,r)}});(0,E.reaction)(()=>[e.all.app.accentColor,e.all.app.progressbarAccentColor,e.all.app.iconSize,e.all.app.showDragArea,e.all.app.sidebarServicesLocation,e.all.app.useGrayscaleServices,e.all.app.grayscaleServicesDim,e.all.app.useHorizontalStyle,e.all.app.alwaysShowWorkspaces,e.all.app.showServiceName,e.all.app.useCompactWorkspaceDrawer,r.isFullScreen,S.workspaceStore.isWorkspaceDrawerOpen],()=>{k(e,r)},{fireImmediately:true})}i(B,"initAppearance");
