import{h as e,i as t,v as n}from"./utils-BakkG8Vx.js";import{C as r,S as i,d as a,i as o,m as s,p as c,s as l,y as u}from"./hooks.module-5xe-uC6c.js";import{j as d}from"./content_renderer-CoENEE63.js";import{t as f}from"./jsxRuntime.module--xb8gfv5.js";a(),r();var p=i(null);function m({children:r}){if(!e()||!n())return;let[i,a]=l(!1),o=c(d),u=t(`@electron/remote`),m=[],h={TouchBar:u.TouchBar,nativeImage:u.nativeImage,addItem:e=>{m.push(e)}};return s(()=>{let e=o?.$widget[0];if(!e)return;function t(){a(!0)}function n(){a(!1)}return e.addEventListener(`focusin`,t),e.addEventListener(`focusout`,n),()=>{e.removeEventListener(`focusin`,t),e.removeEventListener(`focusout`,n)}},[]),s(()=>{i&&u.getCurrentWindow().setTouchBar(new u.TouchBar({items:m}))}),f(p.Provider,{value:h,children:r})}function h({label:e}){let t=c(p);if(t){let n=new t.TouchBar.TouchBarLabel({label:e});t.addItem(n)}return f(u,{})}function g({label:e,value:t,minValue:n,maxValue:r,onChange:i}){let a=c(p);if(a){let o=new a.TouchBar.TouchBarSlider({label:e,value:t,minValue:n,maxValue:r,change:i});a.addItem(o)}return f(u,{})}function _({label:e,icon:t,click:n,enabled:r,backgroundColor:i}){let a=c(p),s=o(()=>a?new a.TouchBar.TouchBarButton({label:e,click:n,enabled:r,icon:t?x(a.nativeImage,t):void 0,backgroundColor:i}):null,[e,t]);return s&&a&&a.addItem(s),f(u,{})}function v({mode:e,segments:t,selectedIndex:n,onChange:r}){let i=c(p);if(i){let a=t.map(({icon:e,...t})=>({...t,icon:e?x(i.nativeImage,e):void 0})),o=new i.TouchBar.TouchBarSegmentedControl({mode:e,selectedIndex:n,segments:a,change:(e,n)=>{t[e].onClick?t[e].onClick():r&&r(e,n)}});i.addItem(o)}return f(u,{})}function y({children:e}){let n=t(`@electron/remote`),r=[],i={TouchBar:n.TouchBar,nativeImage:n.nativeImage,addItem:e=>{r.push(e)}};if(i){let e=new i.TouchBar.TouchBarGroup({items:new i.TouchBar({items:r})});i.addItem(e)}return f(u,{children:f(p.Provider,{value:i,children:e})})}function b({size:e}){let t=c(p);if(t){let n=new t.TouchBar.TouchBarSpacer({size:e});t.addItem(n)}return f(u,{})}function x(e,t){let n=e.createFromNamedImage(t,[-1,0,1]),{width:r,height:i}=n.getSize(),a=e.createEmpty();return a.addRepresentation({scaleFactor:1,width:r/2,height:i/2,buffer:n.resize({height:i/2}).toBitmap()}),a.addRepresentation({scaleFactor:2,width:r,height:i,buffer:n.toBitmap()}),a}export{v as a,h as i,_ as n,g as o,y as r,b as s,m as t};