| 1 |
- import{R as N,r as o,j as e,L as ot}from"./react-DnK_pEU5.js";import{M as lt,N as ct,B as D,c as ke,Q as it,I as Y,d as v,S as dt,t as w}from"./index-LUV-rsLw.js";import{C as P,d as T,a as H,b as B,c as De}from"./card-CF36l7bR.js";import{L as O}from"./label-CyGXWE6X.js";import{S as ut}from"./switch-BTqCTolc.js";import{S as ie}from"./slider-C6r01RE5.js";import{S as Me,a as Le,b as Pe,c as Te,d as $e}from"./select-B_ypzzK2.js";import{C as ft}from"./ConnectionBanner-BwHQi9kR.js";import"./dnd-Bgdma8TD.js";import"./motion-8nKk6_RD.js";import"./index-CLGWHFf2.js";function Q(){return(Q=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(t[r]=a[r])}return t}).apply(this,arguments)}function Be(t,n){if(t==null)return{};var a,r,i={},c=Object.keys(t);for(r=0;r<c.length;r++)n.indexOf(a=c[r])>=0||(i[a]=t[a]);return i}function W(t){var n=o.useRef(t),a=o.useRef(function(r){n.current&&n.current(r)});return n.current=t,a.current}var z=function(t,n,a){return n===void 0&&(n=0),a===void 0&&(a=1),t>a?a:t<n?n:t},A=function(t){return"touches"in t},ue=function(t){return t&&t.ownerDocument.defaultView||self},Fe=function(t,n,a){var r=t.getBoundingClientRect(),i=A(n)?(function(c,f){for(var u=0;u<c.length;u++)if(c[u].identifier===f)return c[u];return c[0]})(n.touches,a):n;return{left:z((i.pageX-(r.left+ue(t).pageXOffset))/r.width),top:z((i.pageY-(r.top+ue(t).pageYOffset))/r.height)}},Re=function(t){!A(t)&&t.preventDefault()},Oe=N.memo(function(t){var n=t.onMove,a=t.onKey,r=t.onEnd,i=Be(t,["onMove","onKey","onEnd"]),c=o.useRef(null),f=W(n),u=W(a),p=W(r),d=o.useRef(null),x=o.useRef(!1),_=o.useMemo(function(){var V=function(m){Re(m),(A(m)?m.touches.length>0:m.buttons>0)&&c.current?f(Fe(c.current,m,d.current)):(I(!1),p())},$=function(){I(!1),p()};function I(m){var h=x.current,E=ue(c.current),k=m?E.addEventListener:E.removeEventListener;k(h?"touchmove":"mousemove",V),k(h?"touchend":"mouseup",$)}return[function(m){var h=m.nativeEvent,E=c.current;if(E&&(Re(h),!(function(K,q){return q&&!A(K)})(h,x.current)&&E)){if(A(h)){x.current=!0;var k=h.changedTouches||[];k.length&&(d.current=k[0].identifier)}E.focus(),f(Fe(E,h,d.current)),I(!0)}},function(m){var h=m.which||m.keyCode;h<37||h>40||(m.preventDefault(),u({left:h===39?.05:h===37?-.05:0,top:h===40?.05:h===38?-.05:0}))},function(m){var h=m.which||m.keyCode;h>=37&&h<=40&&p()},I]},[u,f,p]),C=_[0],j=_[1],M=_[2],S=_[3];return o.useEffect(function(){return S},[S]),N.createElement("div",Q({},i,{onTouchStart:C,onMouseDown:C,className:"react-colorful__interactive",ref:c,onKeyDown:j,onKeyUp:M,tabIndex:0,role:"slider"}))}),he=function(t){return t.filter(Boolean).join(" ")},We=function(t){var n=t.color,a=t.left,r=t.top,i=r===void 0?.5:r,c=he(["react-colorful__pointer",t.className]);return N.createElement("div",{className:c,style:{top:100*i+"%",left:100*a+"%"}},N.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:n}}))},y=function(t,n,a){return n===void 0&&(n=0),a===void 0&&(a=Math.pow(10,n)),Math.round(a*t)/a},mt=function(t){return vt(fe(t))},fe=function(t){return t[0]==="#"&&(t=t.substring(1)),t.length<6?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?y(parseInt(t[3]+t[3],16)/255,2):1}:{r:parseInt(t.substring(0,2),16),g:parseInt(t.substring(2,4),16),b:parseInt(t.substring(4,6),16),a:t.length===8?y(parseInt(t.substring(6,8),16)/255,2):1}},ht=function(t){return gt(xt(t))},pt=function(t){var n=t.s,a=t.v,r=t.a,i=(200-n)*a/100;return{h:y(t.h),s:y(i>0&&i<200?n*a/100/(i<=100?i:200-i)*100:0),l:y(i/2),a:y(r,2)}},me=function(t){var n=pt(t);return"hsl("+n.h+", "+n.s+"%, "+n.l+"%)"},xt=function(t){var n=t.h,a=t.s,r=t.v,i=t.a;n=n/360*6,a/=100,r/=100;var c=Math.floor(n),f=r*(1-a),u=r*(1-(n-c)*a),p=r*(1-(1-n+c)*a),d=c%6;return{r:y(255*[r,u,f,f,p,r][d]),g:y(255*[p,r,r,u,f,f][d]),b:y(255*[f,f,p,r,r,u][d]),a:y(i,2)}},X=function(t){var n=t.toString(16);return n.length<2?"0"+n:n},gt=function(t){var n=t.r,a=t.g,r=t.b,i=t.a,c=i<1?X(y(255*i)):"";return"#"+X(n)+X(a)+X(r)+c},vt=function(t){var n=t.r,a=t.g,r=t.b,i=t.a,c=Math.max(n,a,r),f=c-Math.min(n,a,r),u=f?c===n?(a-r)/f:c===a?2+(r-n)/f:4+(n-a)/f:0;return{h:y(60*(u<0?u+6:u)),s:y(c?f/c*100:0),v:y(c/255*100),a:i}},jt=N.memo(function(t){var n=t.hue,a=t.onChange,r=t.onChangeEnd,i=he(["react-colorful__hue",t.className]);return N.createElement("div",{className:i},N.createElement(Oe,{onMove:function(c){a({h:360*c.left})},onKey:function(c){a({h:z(n+360*c.left,0,360)})},onEnd:r,"aria-label":"Hue","aria-valuenow":y(n),"aria-valuemax":"360","aria-valuemin":"0"},N.createElement(We,{className:"react-colorful__hue-pointer",left:n/360,color:me({h:n,s:100,v:100,a:1})})))}),bt=N.memo(function(t){var n=t.hsva,a=t.onChange,r=t.onChangeEnd,i={backgroundColor:me({h:n.h,s:100,v:100,a:1})};return N.createElement("div",{className:"react-colorful__saturation",style:i},N.createElement(Oe,{onMove:function(c){a({s:100*c.left,v:100-100*c.top})},onKey:function(c){a({s:z(n.s+100*c.left,0,100),v:z(n.v-100*c.top,0,100)})},onEnd:r,"aria-label":"Color","aria-valuetext":"Saturation "+y(n.s)+"%, Brightness "+y(n.v)+"%"},N.createElement(We,{className:"react-colorful__saturation-pointer",top:1-n.v/100,left:n.s/100,color:me(n)})))}),Ae=function(t,n){if(t===n)return!0;for(var a in t)if(t[a]!==n[a])return!1;return!0},yt=function(t,n){return t.toLowerCase()===n.toLowerCase()||Ae(fe(t),fe(n))};function Nt(t,n,a,r){var i=W(a),c=W(r),f=o.useState(function(){return t.toHsva(n)}),u=f[0],p=f[1],d=o.useRef({color:n,hsva:u}),x=o.useRef(!1);o.useEffect(function(){if(!t.equal(n,d.current.color)){var j=t.toHsva(n);d.current={hsva:j,color:n},p(j),x.current=!1}},[n,t]),o.useEffect(function(){var j;Ae(u,d.current.hsva)||t.equal(j=t.fromHsva(u),d.current.color)||(d.current={hsva:u,color:j},i(j),x.current=!0)},[u,t,i]);var _=o.useCallback(function(j){p(function(M){return Object.assign({},M,j)})},[]),C=o.useCallback(function(){x.current&&(x.current=!1,c(d.current.color))},[c]);return[u,_,C]}var wt=typeof window<"u"?o.useLayoutEffect:o.useEffect,_t=function(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0},He=new Map,Ct=function(t){wt(function(){var n=t.current?t.current.ownerDocument:document;if(n!==void 0&&!He.has(n)){var a=n.createElement("style");a.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`,He.set(n,a);var r=_t();r&&a.setAttribute("nonce",r),n.head.appendChild(a)}},[])},Et=function(t){var n=t.className,a=t.colorModel,r=t.color,i=r===void 0?a.defaultColor:r,c=t.onChange,f=t.onChangeEnd,u=Be(t,["className","colorModel","color","onChange","onChangeEnd"]),p=o.useRef(null);Ct(p);var d=Nt(a,i,c,f),x=d[0],_=d[1],C=d[2],j=he(["react-colorful",n]);return N.createElement("div",Q({},u,{ref:p,className:j}),N.createElement(bt,{hsva:x,onChange:_,onChangeEnd:C}),N.createElement(jt,{hue:x.h,onChange:_,onChangeEnd:C,className:"react-colorful__last-control"}))},St={defaultColor:"000",toHsva:mt,fromHsva:function(t){return ht({h:t.h,s:t.s,v:t.v,a:1})},equal:yt},It=function(t){return N.createElement(Et,Q({},t,{colorModel:St}))};const kt=["#ff0000","#ff8000","#ffff00","#00ff00","#00ffff","#0000ff","#ff00ff","#ffffff","#2a9d8f","#e9c46a","#dc143c","#000000"],Dt=/^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function Mt(t){const n=Dt.exec(t.trim());if(!n)return null;let a=n[1].toLowerCase();return a.length===3&&(a=a.split("").map(r=>r+r).join("")),`#${a}`}function de({value:t,onChange:n,className:a,presets:r=kt}){const[i,c]=o.useState(!1),[f,u]=o.useState(t);o.useEffect(()=>{u(t)},[t]);const p=d=>{const x=Mt(d);x?(n(x),u(x)):u(t)};return e.jsxs(lt,{open:i,onOpenChange:c,children:[e.jsx(ct,{asChild:!0,children:e.jsx(D,{variant:"secondary",className:ke("w-12 h-12 rounded-full p-1 border-2",a),style:{backgroundColor:t},children:e.jsx("span",{className:"sr-only",children:"Pick a color"})})}),e.jsxs(it,{className:"w-auto p-3 space-y-3",align:"start",children:[e.jsx(It,{color:t,onChange:n}),e.jsx(Y,{value:f,onChange:d=>u(d.target.value),onBlur:d=>p(d.target.value),onKeyDown:d=>{d.key==="Enter"&&p(d.currentTarget.value)},spellCheck:!1,autoComplete:"off","aria-label":"Hex color",className:"h-8 font-mono text-sm"}),e.jsx("div",{className:"grid grid-cols-6 gap-1.5",children:r.map(d=>e.jsx("button",{type:"button","aria-label":`Select color ${d}`,className:ke("h-6 w-6 rounded border border-border cursor-pointer transition-transform hover:scale-110",t.toLowerCase()===d.toLowerCase()&&"ring-2 ring-ring ring-offset-1"),style:{backgroundColor:d},onClick:()=>n(d)},d))})]})]})}function zt(){const[t,n]=o.useState(null),[a,r]=o.useState(!0),[i,c]=o.useState(null),[f,u]=o.useState([]),[p,d]=o.useState([]),[x,_]=o.useState(35),[C,j]=o.useState(128),[M,S]=o.useState("128"),[V,$]=o.useState(128),[I,m]=o.useState("128"),[h,E]=o.useState(""),[k,K]=o.useState(""),[q,pe]=o.useState("#ff0000"),[xe,ge]=o.useState("#000000"),[ve,je]=o.useState("#0000ff"),J=o.useRef(null),be=o.useRef(0),[F,Z]=o.useState("automated"),[ze,Ve]=o.useState(null),[Ke,qe]=o.useState(null),[R,ye]=o.useState(!1),[ee,te]=o.useState(30),[se,G]=o.useState("30"),[Ne,ne]=o.useState(null),ae=o.useCallback(async s=>{ne(null);try{await fetch(`http://${s}/json/info`,{signal:AbortSignal.timeout(4e3),mode:"no-cors"}),ne(!0)}catch{ne(!1)}},[]);o.useEffect(()=>{t?.provider==="wled"&&t.wled_ip&&ae(t.wled_ip)},[t?.provider,t?.wled_ip,ae]),o.useEffect(()=>{(async()=>{try{const[l,b]=await Promise.all([v.get("/get_led_config"),v.get("/api/settings")]);n({provider:l.provider||"none",wled_ip:l.wled_ip,num_leds:l.dw_led_num_leds,gpio_pin:l.dw_led_gpio_pin}),b.led?.control_mode&&Z(b.led.control_mode)}catch(l){console.error("Error fetching LED config:",l)}finally{r(!1)}})()},[]),o.useEffect(()=>{t?.provider==="dw_leds"&&(we(),Ge(),re(),Ue())},[t]);const we=async()=>{try{const s=await v.get("/api/dw_leds/status");c(s),s.connected&&(_(s.brightness||35),j(s.speed||128),S(String(s.speed||128)),$(s.intensity||128),m(String(s.intensity||128)),E(String(s.current_effect||0)),K(String(s.current_palette||0)),s.colors&&(pe(s.colors[0]||"#ff0000"),ge(s.colors[1]||"#000000"),je(s.colors[2]||"#0000ff")))}catch(s){console.error("Error fetching DW LEDs status:",s)}},Ge=async()=>{try{const[s,l]=await Promise.all([v.get("/api/dw_leds/effects"),v.get("/api/dw_leds/palettes")]);if(s.effects){const b=[...s.effects].sort((g,L)=>g[1].localeCompare(L[1]));u(b)}if(l.palettes){const b=[...l.palettes].sort((g,L)=>g[1].localeCompare(L[1]));d(b)}}catch(s){console.error("Error fetching effects/palettes:",s)}},re=async()=>{try{const s=await v.get("/api/dw_leds/get_effect_settings");Ve(s.idle_effect||null),qe(s.playing_effect||null)}catch(s){console.error("Error fetching effect settings:",s)}},Ue=async()=>{try{const s=await v.get("/api/dw_leds/idle_timeout");ye(s.enabled||!1),te(s.minutes||30),G(String(s.minutes||30))}catch(s){console.error("Error fetching idle timeout:",s)}},_e=async s=>{const l=F;Z(s);try{await v.patch("/api/settings",{led:{control_mode:s}})}catch{Z(l),w.error("Failed to update control mode")}},Xe=async()=>{try{const s=await v.post("/api/dw_leds/power",{state:2});s.connected?await we():w.error(s.error||"Failed to toggle power")}catch{w.error("Failed to toggle power")}},Ye=o.useCallback(async s=>{_(s[0])},[]),Qe=async s=>{try{await v.post("/api/dw_leds/brightness",{value:s[0]})}catch{w.error("Failed to set brightness")}},Je=o.useCallback(s=>{j(s[0]),S(String(s[0]))},[]),oe=async s=>{try{await v.post("/api/dw_leds/speed",{speed:s[0]})}catch{w.error("Failed to set speed")}},Ze=o.useCallback(s=>{$(s[0]),m(String(s[0]))},[]),le=async s=>{try{await v.post("/api/dw_leds/intensity",{intensity:s[0]})}catch{w.error("Failed to set intensity")}},et=async s=>{E(s);try{const l=await v.post("/api/dw_leds/effect",{effect_id:parseInt(s)});if(l.connected&&l.power_on!==void 0){const b=l.power_on;c(g=>g?{...g,power_on:b}:null)}}catch{w.error("Failed to set effect")}},tt=async s=>{K(s);try{await v.post("/api/dw_leds/palette",{palette_id:parseInt(s)})}catch{w.error("Failed to set palette")}},ce=(s,l)=>{s===1?pe(l):s===2?ge(l):je(l),J.current&&clearTimeout(J.current),J.current=setTimeout(async()=>{try{const b=L=>{const nt=parseInt(L.slice(1,3),16),at=parseInt(L.slice(3,5),16),rt=parseInt(L.slice(5,7),16);return[nt,at,rt]},g={};g[`color${s}`]=b(l),await v.post("/api/dw_leds/colors",g)}catch(b){console.error("Failed to set color:",b);const g=Date.now();g-be.current>3e3&&(be.current=g,w.error("Failed to set LED color"))}},300)},Ce=async s=>{try{const l={type:s,effect_id:parseInt(h)||0,palette_id:parseInt(k)||0,speed:C,intensity:V,color1:q,color2:xe,color3:ve};await v.post("/api/dw_leds/save_effect_settings",l),w.success(`${s.charAt(0).toUpperCase()+s.slice(1)} effect saved`),await re()}catch{w.error(`Failed to save ${s} effect`)}},Ee=async s=>{try{await v.post("/api/dw_leds/clear_effect_settings",{type:s}),w.success(`${s.charAt(0).toUpperCase()+s.slice(1)} effect cleared`),await re()}catch{w.error(`Failed to clear ${s} effect`)}},U=async(s,l)=>{const b=s!==void 0?s:R,g=l!==void 0?l:ee;try{await v.post("/api/dw_leds/idle_timeout",{enabled:b,minutes:g}),w.success(`Idle timeout ${b?"enabled":"disabled"}`)}catch{w.error("Failed to save idle timeout")}},st=async s=>{ye(s),await U(s,ee)},Se=s=>{if(!s)return"Not configured";const l=f.find(g=>g[0]===s.effect_id)?.[1]||s.effect_id,b=p.find(g=>g[0]===s.palette_id)?.[1]||s.palette_id;return`${l} | ${b} | Speed: ${s.speed} | Intensity: ${s.intensity}`};if(a)return e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsx("span",{className:"material-icons-outlined animate-spin text-4xl text-muted-foreground","aria-hidden":"true",children:"sync"})});if(!t||t.provider==="none")return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[60vh] gap-6 text-center px-4",children:[e.jsx("div",{className:"p-4 rounded-full bg-muted",children:e.jsx("span",{className:"material-icons-outlined text-5xl text-muted-foreground","aria-hidden":"true",children:"lightbulb"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold",children:"LED Controller Not Configured"}),e.jsx("p",{className:"text-sm sm:text-base text-muted-foreground max-w-md",children:"Configure your LED controller (WLED or DW LEDs) in the Settings page to control your lights."})]}),e.jsx(D,{asChild:!0,className:"gap-2",children:e.jsxs(ot,{to:"/settings?section=led",children:[e.jsx("span",{className:"material-icons-outlined","aria-hidden":"true",children:"settings"}),"Go to Settings"]})})]});const Ie=e.jsxs(P,{children:[e.jsxs(H,{className:"pb-3",children:[e.jsxs(B,{className:"text-lg flex items-center gap-2",children:[e.jsx("span",{className:"material-icons-outlined text-muted-foreground","aria-hidden":"true",children:"tune"}),"LED Control Mode"]}),e.jsx(De,{children:"Choose how Dune Weaver manages LED effects during playback and idle states"})]}),e.jsx(T,{children:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>_e("manual"),className:`p-4 rounded-lg border-2 text-left transition-all ${F==="manual"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/30"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"material-icons-outlined text-base","aria-hidden":"true",children:"front_hand"}),e.jsx("span",{className:"font-medium text-sm",children:"Manual / Home Assistant"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Effects persist until changed. During scheduled quiet hours (Still Sands), lights turn off only."})]}),e.jsxs("button",{onClick:()=>_e("automated"),className:`p-4 rounded-lg border-2 text-left transition-all ${F==="automated"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/30"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"material-icons-outlined text-base","aria-hidden":"true",children:"smart_toy"}),e.jsx("span",{className:"font-medium text-sm",children:"DW Automated"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Auto-switch effects on play/idle. During quiet hours, lights turn off and back on."})]})]})})]});if(t.provider==="wled"&&t.wled_ip){const s=t.wled_ip;return e.jsxs("div",{className:"flex flex-col w-full max-w-5xl mx-auto gap-4 py-3 sm:py-6 px-0 sm:px-4",children:[Ie,Ne===null?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("span",{className:"material-icons-outlined animate-spin text-3xl text-muted-foreground","aria-hidden":"true",children:"sync"})}):Ne===!1?e.jsx(P,{children:e.jsxs(T,{className:"pt-6 flex flex-col items-center gap-3 text-center",children:[e.jsx("span",{className:"material-icons-outlined text-4xl text-muted-foreground","aria-hidden":"true",children:"wifi_off"}),e.jsxs("p",{className:"font-medium",children:["Can't reach WLED at ",s]}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-md",children:"Check that the WLED controller is powered on and the IP is correct in Settings → LED"}),e.jsxs(D,{onClick:()=>ae(s),className:"gap-2",children:[e.jsx("span",{className:"material-icons-outlined text-base","aria-hidden":"true",children:"refresh"}),"Retry"]})]})}):e.jsx("div",{style:{height:"calc(100vh - 380px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px))"},children:e.jsx("iframe",{src:`http://${s}`,className:"w-full h-full rounded-lg border border-border",title:"WLED Control"})})]})}return e.jsxs("div",{className:"flex flex-col w-full max-w-5xl mx-auto gap-6 py-3 sm:py-6 px-0 sm:px-4",children:[e.jsxs("div",{className:"space-y-0.5 sm:space-y-1 pl-1",children:[e.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"LED Control"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"DW LEDs - GPIO controlled LED strip"})]}),e.jsx(ft,{}),e.jsx(dt,{}),Ie,e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsx(P,{children:e.jsx(T,{className:"pt-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-6",children:[e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("button",{onClick:Xe,className:`w-24 h-24 rounded-full flex items-center justify-center transition-all shadow-lg ${i?.power_on?"bg-green-500 hover:bg-green-600 shadow-green-500/30":"bg-muted hover:bg-muted/80"}`,children:e.jsx("span",{className:`material-icons text-4xl ${i?.power_on?"text-white":"text-muted-foreground"}`,"aria-hidden":"true",children:"power_settings_new"})}),e.jsx("span",{className:`text-sm font-medium ${i?.power_on?"text-green-600":"text-muted-foreground"}`,children:i?.power_on?"ON":"OFF"})]}),e.jsxs("div",{className:"flex-1 w-full space-y-4",children:[e.jsxs("div",{className:`flex items-center gap-2 text-sm ${i?.connected?"text-green-600":"text-destructive"}`,children:[e.jsx("span",{className:"material-icons-outlined text-base","aria-hidden":"true",children:i?.connected?"check_circle":"error"}),i?.connected?`${i.num_leds} LEDs on GPIO ${i.gpio_pin}`:"Not connected"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs(O,{children:[e.jsx("span",{className:"material-icons-outlined text-sm mr-2 align-[-6px] text-muted-foreground","aria-hidden":"true",children:"brightness_6"}),"Brightness"]}),e.jsxs("span",{className:"text-sm font-medium",children:[x,"%"]})]}),e.jsx(ie,{"aria-label":"Brightness",value:[x],onValueChange:Ye,onValueCommit:Qe,max:100,step:1})]})]})]})})}),e.jsxs(P,{children:[e.jsx(H,{className:"pb-3",children:e.jsxs(B,{className:"text-lg flex items-center gap-2",children:[e.jsx("span",{className:"material-icons-outlined text-muted-foreground","aria-hidden":"true",children:"auto_awesome"}),"Effects & Palettes"]})}),e.jsxs(T,{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"led-effect-select",children:"Effect"}),e.jsxs(Me,{value:h,onValueChange:et,children:[e.jsx(Le,{id:"led-effect-select",children:e.jsx(Pe,{placeholder:"Select effect..."})}),e.jsx(Te,{children:f.map(([s,l])=>e.jsx($e,{value:String(s),children:l},s))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"led-palette-select",children:"Palette"}),e.jsxs(Me,{value:k,onValueChange:tt,children:[e.jsx(Le,{id:"led-palette-select",children:e.jsx(Pe,{placeholder:"Select palette..."})}),e.jsx(Te,{children:p.map(([s,l])=>e.jsx($e,{value:String(s),children:l},s))})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-4 rounded-lg border space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs(O,{htmlFor:"led-speed-input",children:[e.jsx("span",{className:"material-icons-outlined text-sm mr-2 align-[-6px] text-muted-foreground","aria-hidden":"true",children:"speed"}),"Speed"]}),e.jsx(Y,{id:"led-speed-input",type:"text",inputMode:"numeric",value:M,onChange:s=>{const l=s.target.value.replace(/[^0-9]/g,"");S(l)},onBlur:()=>{const s=Math.min(255,Math.max(0,parseInt(M)||0));j(s),S(String(s)),oe([s])},onKeyDown:s=>{if(s.key==="Enter"){const l=Math.min(255,Math.max(0,parseInt(M)||0));j(l),S(String(l)),oe([l])}},className:"w-16 h-7 text-center text-sm font-medium px-2"})]}),e.jsx(ie,{"aria-label":"Speed",value:[C],onValueChange:Je,onValueCommit:oe,max:255,step:1})]}),e.jsxs("div",{className:"p-4 rounded-lg border space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs(O,{htmlFor:"led-intensity-input",children:[e.jsx("span",{className:"material-icons-outlined text-sm mr-2 align-[-6px] text-muted-foreground","aria-hidden":"true",children:"tungsten"}),"Intensity"]}),e.jsx(Y,{id:"led-intensity-input",type:"text",inputMode:"numeric",value:I,onChange:s=>{const l=s.target.value.replace(/[^0-9]/g,"");m(l)},onBlur:()=>{const s=Math.min(255,Math.max(0,parseInt(I)||0));$(s),m(String(s)),le([s])},onKeyDown:s=>{if(s.key==="Enter"){const l=Math.min(255,Math.max(0,parseInt(I)||0));$(l),m(String(l)),le([l])}},className:"w-16 h-7 text-center text-sm font-medium px-2"})]}),e.jsx(ie,{"aria-label":"Intensity",value:[V],onValueChange:Ze,onValueCommit:le,max:255,step:1})]})]})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs(P,{className:"flex-1 flex flex-col",children:[e.jsx(H,{className:"pb-3",children:e.jsxs(B,{className:"text-lg flex items-center gap-2",children:[e.jsx("span",{className:"material-icons-outlined text-muted-foreground","aria-hidden":"true",children:"palette"}),"Colors"]})}),e.jsx(T,{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex justify-around w-full",children:[e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(de,{value:q,onChange:s=>ce(1,s)}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Primary"})]}),e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(de,{value:xe,onChange:s=>ce(2,s)}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Secondary"})]}),e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(de,{value:ve,onChange:s=>ce(3,s)}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Accent"})]})]})})]}),F==="automated"&&e.jsxs(P,{className:"flex-1 flex flex-col",children:[e.jsx(H,{className:"pb-3",children:e.jsxs(B,{className:"text-lg flex items-center gap-2",children:[e.jsx("span",{className:"material-icons-outlined text-muted-foreground","aria-hidden":"true",children:"schedule"}),"Auto Turn Off"]})}),e.jsxs(T,{className:"flex-1 flex flex-col justify-center space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Enable timeout"}),e.jsx(ut,{"aria-label":"Enable idle timeout",checked:R,onCheckedChange:st})]}),R&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{"aria-label":"Idle timeout in minutes",type:"text",inputMode:"numeric",value:se,onChange:s=>{const l=s.target.value.replace(/[^0-9]/g,"");G(l)},onBlur:()=>{const s=Math.min(1440,Math.max(1,parseInt(se)||30));te(s),G(String(s)),s!==ee&&U(R,s)},onKeyDown:s=>{if(s.key==="Enter"){const l=Math.min(1440,Math.max(1,parseInt(se)||30));te(l),G(String(l)),U(R,l)}},className:"w-20"}),e.jsx("span",{className:"text-sm text-muted-foreground flex-1",children:"minutes"}),e.jsx(D,{size:"sm",onClick:()=>U(),children:"Save"})]})]})]})]})]}),F==="automated"&&e.jsxs(P,{children:[e.jsxs(H,{className:"pb-3",children:[e.jsxs(B,{className:"text-lg flex items-center gap-2",children:[e.jsx("span",{className:"material-icons-outlined text-muted-foreground","aria-hidden":"true",children:"smart_toy"}),"Effect Automation"]}),e.jsx(De,{children:"Save current settings to automatically apply when table state changes"})]}),e.jsx(T,{children:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-4 rounded-lg border space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"material-icons text-green-600","aria-hidden":"true",children:"play_circle"}),e.jsx("span",{className:"font-medium",children:"While Playing"})]})}),e.jsx("div",{className:"text-xs text-muted-foreground p-2 bg-muted/50 rounded border min-h-[40px]",children:Se(Ke)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(D,{size:"sm",onClick:()=>Ce("playing"),className:"flex-1 gap-1",children:[e.jsx("span",{className:"material-icons text-sm","aria-hidden":"true",children:"save"}),"Save Current"]}),e.jsx(D,{size:"sm",variant:"secondary",onClick:()=>Ee("playing"),children:"Clear"})]})]}),e.jsxs("div",{className:"p-4 rounded-lg border space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"material-icons text-blue-600","aria-hidden":"true",children:"bedtime"}),e.jsx("span",{className:"font-medium",children:"When Idle"})]})}),e.jsx("div",{className:"text-xs text-muted-foreground p-2 bg-muted/50 rounded border min-h-[40px]",children:Se(ze)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(D,{size:"sm",onClick:()=>Ce("idle"),className:"flex-1 gap-1",children:[e.jsx("span",{className:"material-icons text-sm","aria-hidden":"true",children:"save"}),"Save Current"]}),e.jsx(D,{size:"sm",variant:"secondary",onClick:()=>Ee("idle"),children:"Clear"})]})]})]})})]})]})}export{zt as LEDPage};
|