@yunlefun-home/air-conditioner-widget 0.4.3 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,6 +23,8 @@ const widget = mountAirConditioner(document.body, {
23
23
  // widget.remove()
24
24
  ```
25
25
 
26
+ Moving the same widget to another container, or removing and reinserting it, preserves its current settings. Removal releases listeners, observers and audio; reinsertion restores them. A newly created widget still initializes from its options and storage.
27
+
26
28
  `cdnAssets` explicitly loads fonts, audio and the logo from jsDelivr, pinned to the exact version of the installed npm package. Your application bundles the JavaScript itself. Omit it and provide `assetsBaseUrl` and `logoUrl` to self-host assets. Importing the package does not automatically mount or fetch anything.
27
29
 
28
30
  You can also call `defineAirConditionerElement({ ...cdnAssets, enableAudio: false })`, then render `<air-conditioner-widget placement="top-right"></air-conditioner-widget>`.
@@ -23,6 +23,8 @@ const widget = mountAirConditioner(document.body, {
23
23
  // widget.remove()
24
24
  ```
25
25
 
26
+ Moving the same widget to another container, or removing and reinserting it, preserves its current settings. Removal releases listeners, observers and audio; reinsertion restores them. A newly created widget still initializes from its options and storage.
27
+
26
28
  `cdnAssets` explicitly loads fonts, audio and the logo from jsDelivr, pinned to the exact version of the installed npm package. Your application bundles the JavaScript itself. Omit it and provide `assetsBaseUrl` and `logoUrl` to self-host assets. Importing the package does not automatically mount or fetch anything.
27
29
 
28
30
  You can also call `defineAirConditionerElement({ ...cdnAssets, enableAudio: false })`, then render `<air-conditioner-widget placement="top-right"></air-conditioner-widget>`.
@@ -1,21 +1,101 @@
1
- (function(){let e={cold:`❄️`,hot:`☀️`},t={beep:`di`,start:`ac-work`,work:`air-extractor-fan`},n={min:16,max:31,step:1},r={mode:`cold`,status:!1,temperature:26,temperatures:{cold:26,hot:26},sound:`normal`,swing:!1,fan:`auto`},i=[`normal`,`sleep`,`mute`],a={cold:`制冷`,hot:`制热`},o={normal:`标准`,sleep:`睡眠`,mute:`静音`},s={normal:1,sleep:.3,mute:0},c=[`auto`,`low`,`medium`,`high`],l={auto:`自动`,low:`低风`,medium:`中风`,high:`高风`},u={low:.45,medium:.7,high:1};function d(e){return c.includes(e)}function f(e){let t=Math.max(c.indexOf(e),0);return c[(t+1)%c.length]}function p(e){return i.includes(e)}function m(e){let t=Math.max(i.indexOf(e),0);return i[(t+1)%i.length]}let h={startDelayMs:8e3,loopCrossfadeMs:1500,stopFadeMs:600,settleAfterMs:9e4,settleRampMs:2e4,settleLevel:.5,surgeLevel:.85,quietDurationMs:[18e4,36e4],surgeDurationMs:[6e4,12e4],surgeRampMs:1e4};function g(e=`/assets/audio`,n=`m4a`){let r=e.replace(/\/$/,``);return{beep:`${r}/${t.beep}.${n}`,start:`${r}/${t.start}.${n}`,work:`${r}/${t.work}.${n}`}}function ee(e){return e?.currentSrc||e?.src||``}async function te(e){let t=await fetch(e);if(!t.ok)throw Error(`Failed to load ${e}: ${t.status}`);return t.arrayBuffer()}function ne(){let e=globalThis,t=e.AudioContext??e.webkitAudioContext;return t?new t:null}function re(e,t){let n=e.currentTime,r=e.createOscillator(),i=e.createGain();r.type=`sine`,r.frequency.setValueAtTime(1500,n),r.frequency.exponentialRampToValueAtTime(520,n+.07),i.gain.setValueAtTime(1e-4,n),i.gain.exponentialRampToValueAtTime(.12,n+.004),i.gain.exponentialRampToValueAtTime(1e-4,n+.16),r.connect(i),i.connect(t),r.start(n),r.stop(n+.18),r.onended=()=>i.disconnect()}function _(e){let t=/* @__PURE__ */ new Float32Array(64);for(let n=0;n<64;n++){let r=n/63*Math.PI/2;t[n]=e===`in`?Math.sin(r):Math.cos(r)}return t}function v(e,t){return e[0]+(e[1]-e[0])*t()}function y(e){e&&(e.load(),Promise.resolve(e.play()).catch(()=>{}))}function b(e){e&&(e.pause?e.pause():e.load())}function x(e,t={}){let n=t.random??Math.random,r=t.soundMode??`normal`,i=t.fanSpeed??`auto`,a=!1,o=0,c,l,d=0,f=/* @__PURE__ */ new Set,p=1,m;function g(e,t){let n=setTimeout(()=>{f.delete(n),e()},t);f.add(n)}function x(){f.forEach(e=>clearTimeout(e)),f.clear()}function S(){return s[r]}function C(e,t=1){e&&(e.volume!==void 0&&(e.volume=Math.min(1,Math.max(0,S()*t))),e.muted!==void 0&&(e.muted=r===`mute`))}function w(){m&&clearInterval(m),m=void 0}function T(t,n,r){w();let i=p,a=Math.max(1,Math.round(n/100)),o=0;m=setInterval(()=>{o++,p=i+(t-i)*(o/a),C(e.work,p),o>=a&&(w(),r?.())},100)}function E(){return c===void 0&&(c=D()),c}function D(){if(t.webAudio===!1)return null;let n;try{n=(t.createAudioContext??ne)()}catch{return null}if(!n)return null;let r=n.createGain();r.gain.value=S(),r.connect(n.destination);let i={},a=t.loadAudioData??te,o=Promise.all([`beep`,`start`,`work`].map(async t=>{let r=ee(e[t]);if(r)try{i[t]=await n.decodeAudioData(await a(r))}catch{}})).then(()=>!!(i.start&&i.work));return{context:n,master:r,buffers:i,ready:o}}function O(e){e.context.state===`suspended`&&Promise.resolve(e.context.resume()).catch(()=>{})}function k(e){return Promise.race([e.ready,new Promise(e=>setTimeout(e,1500,!1))])}function A(e,t,n,r){let i=e.context.createBufferSource();return i.buffer=t,i.connect(n),i.start(r),i}function j(e,t,n){e.sources.add(t),t.onended=()=>{e.sources.delete(t),t.disconnect(),n?.()}}function M(e,t,n){let r=e.buffers.work,i=Math.min(h.loopCrossfadeMs/1e3,r.duration/2),a=e.context.createGain();a.gain.value=0,a.gain.setValueCurveAtTime(_(`in`),n,i),a.gain.setValueCurveAtTime(_(`out`),n+r.duration-i,i),a.connect(t.fan);let o=A(e,r,a,n);o.stop(n+r.duration),j(t,o,()=>a.disconnect());let s=n+r.duration-i;g(()=>{l===t&&M(e,t,s)},Math.max(0,(s-e.context.currentTime-1)*1e3))}function N(e,t){if(l&&c){let n=l.fan.gain,r=c.context.currentTime;n.cancelScheduledValues(r),n.setValueAtTime(n.value,r),n.linearRampToValueAtTime(e,r+t/1e3)}else T(e,t)}function P(){return i===`auto`?1:u[i]}function F(){a=!0;let e=++o;if(i!==`auto`)return;let t=()=>e===o&&i===`auto`,r=()=>{g(()=>{t()&&(N(h.surgeLevel,h.surgeRampMs),g(()=>{t()&&(N(h.settleLevel,h.surgeRampMs),r())},v(h.surgeDurationMs,n)))},v(h.quietDurationMs,n))};g(()=>{t()&&(N(h.settleLevel,h.settleRampMs),r())},h.settleAfterMs)}function I(e){let t=e.context.createGain();t.connect(e.master);let n=e.context.createGain();n.gain.value=P(),n.connect(t);let r={output:t,fan:n,sources:/* @__PURE__ */ new Set};l=r;let i=e.context.currentTime;j(r,A(e,e.buffers.start,t,i)),M(e,r,i+h.startDelayMs/1e3),g(F,h.startDelayMs)}function L(e){let t=l;if(l=void 0,!t||!c)return;let n=c.context.currentTime,r=n+e/1e3,i=t.output.gain;i.cancelScheduledValues(n),i.setValueAtTime(i.value,n),i.linearRampToValueAtTime(0,r),t.sources.forEach(e=>{try{e.stop(r)}catch{}}),setTimeout(()=>t.output.disconnect(),e+100)}function R(){let{start:t,work:n}=e;b(n),C(t),y(t),g(()=>{n&&(p=0,C(n,0),n.loop!==void 0&&(n.loop=!0),y(n),T(P(),h.loopCrossfadeMs),F())},h.startDelayMs)}function z(t){b(e.start),t>0?T(0,t,()=>b(e.work)):b(e.work)}function B(){let e=++d;a=!1,o++,x(),w(),L(0),z(0);let t=E();t?(O(t),k(t).then(n=>{e===d&&(n?I(t):R())})):R()}function V(){d++,a=!1,o++,x(),L(h.stopFadeMs),z(h.stopFadeMs)}return{beep(){if(r===`mute`)return;let t=E();t&&(O(t),t.buffers.beep)?A(t,t.buffers.beep,t.master,t.context.currentTime):(C(e.beep),y(e.beep))},drip(){if(r!==`normal`)return;let e=E();e&&typeof e.context.createOscillator==`function`&&(O(e),re(e.context,e.master))},toggleStatusAudio(e){e?V():B()},setSoundMode(t){r=t,c&&c.master.gain.setTargetAtTime(S(),c.context.currentTime,.08),C(e.beep),C(e.start),C(e.work,p)},setFanSpeed(e){e!==i&&(i=e,a?e===`auto`?(N(1,h.loopCrossfadeMs),F()):(o++,N(u[e],h.loopCrossfadeMs)):l&&(l.fan.gain.value=P()))},dispose(){d++,x(),w(),L(0),z(0),c&&!t.createAudioContext&&Promise.resolve(c.context.close()).catch(()=>{}),c=null}}}let S={auto:.8,low:.55,medium:.8,high:1},C=[9e3,18e3];function w(e){if(!e.status||e.mode!==`cold`)return 0;let t=.2+.8*(31-e.temperature)/15,n=Math.min(1,Math.max(.2,t))*S[e.fan??`auto`];return Math.round(n*100)/100}function T(e){if(!e.status||e.mode!==`cold`||e.temperature>22)return;let[t,n]=C,r=(e.temperature-16)/6,i=t+(n-t)*Math.min(1,Math.max(0,r));return Math.round(i*(e.fan===`high`?.8:1))}function E(e){let t=T(e);return{mist:w(e),dripCycle:t===void 0?void 0:`${t}ms`,drip:t===void 0?`off`:`on`}}let D={compact:{width:360,height:128},wide:{width:600,height:200}};function O(e,t){return!(e>0)||!(t>0)?1:Math.min(1,e/t)}function k(e,t,n){if(typeof ResizeObserver>`u`)return()=>{};let r,i=e=>{let i=O(e,t);i!==r&&(r=i,n(i))};i(e.offsetWidth??e.getBoundingClientRect().width);let a=new ResizeObserver(e=>{for(let t of e)i(t.contentRect.width)});return a.observe(e),()=>a.disconnect()}function A(e,t,n=4){let r=globalThis.matchMedia;if(typeof r!=`function`||!r(`(hover: hover) and (pointer: fine)`).matches||r(`(prefers-reduced-motion: reduce)`).matches)return()=>{};let i=0,a=(e,n)=>{cancelAnimationFrame(i),i=requestAnimationFrame(()=>t(e,n))},o=t=>{let r=e.getBoundingClientRect();if(!r.width||!r.height)return;let i=(t.clientX-r.left)/r.width-.5,o=(t.clientY-r.top)/r.height-.5,s=e=>Math.round(e*100)/100;a(s(-o*2*n),s(i*2*n))},s=()=>a(0,0);return e.addEventListener(`pointermove`,o),e.addEventListener(`pointerleave`,s),()=>{cancelAnimationFrame(i),e.removeEventListener(`pointermove`,o),e.removeEventListener(`pointerleave`,s)}}function j(e,t,n={}){let{delay:r=500,interval:i=200,minInterval:a=100,value:o}=n,s,c=i,l,u=()=>{clearTimeout(s),s=void 0},d=()=>{if(o&&o()===l)return u();l=o?.(),t(),c=Math.max(a,c*.85),s=setTimeout(d,c)},f=e=>{e.button===0&&(u(),l=o?.(),t(),c=i,s=setTimeout(d,r))},p=e=>{e.detail===0&&t()},m=e=>e.preventDefault();return e.addEventListener(`pointerdown`,f),e.addEventListener(`pointerup`,u),e.addEventListener(`pointerleave`,u),e.addEventListener(`pointercancel`,u),e.addEventListener(`click`,p),e.addEventListener(`contextmenu`,m),()=>{u(),e.removeEventListener(`pointerdown`,f),e.removeEventListener(`pointerup`,u),e.removeEventListener(`pointerleave`,u),e.removeEventListener(`pointercancel`,u),e.removeEventListener(`click`,p),e.removeEventListener(`contextmenu`,m)}}function M(e,t){let n=e?.mode===`hot`?`hot`:`cold`,i=P(e?.temperature??r.temperature,t),a=n=>{let r=e?.temperatures?.[n];return typeof r==`number`&&Number.isFinite(r)?P(r,t):i};return{...r,...e,mode:n,temperature:i,temperatures:{cold:n===`cold`?i:a(`cold`),hot:n===`hot`?i:a(`hot`)},sound:p(e?.sound)?e.sound:r.sound,swing:typeof e?.swing==`boolean`?e.swing:r.swing,fan:d(e?.fan)?e.fan:`auto`}}function N(e,t){let n={cold:t,hot:t,...e.temperatures};return n[e.mode]=t,{...e,temperature:t,temperatures:n}}function P(e,t){if(!t)return Math.min(31,Math.max(16,e));let{min:n,max:r,step:i}=t,a=i>0?Math.round((e-n)/i)*i+n:e;return Number(Math.min(r,Math.max(n,a)).toFixed(4))}function F(e,t,r){let i=r?.step??n.step;switch(t.type){case`increment`:return N(e,P(e.temperature+i,r));case`decrement`:return N(e,P(e.temperature-i,r));case`toggleStatus`:return{...e,status:!e.status};case`status`:return{...e,status:t.status};case`mode`:{let n=e.status||t.powerOn===!0;if(t.mode===e.mode)return n===e.status?e:{...e,status:n};let i={cold:e.temperature,hot:e.temperature,...e.temperatures,[e.mode]:e.temperature};return{...e,status:n,mode:t.mode,temperature:P(i[t.mode]??e.temperature,r),temperatures:i}}case`sound`:return{...e,sound:p(t.sound)?t.sound:e.sound};case`cycleSound`:return{...e,sound:m(e.sound)};case`toggleSwing`:return{...e,swing:!e.swing};case`swing`:return{...e,swing:t.swing===!0};case`fan`:return{...e,fan:d(t.fan)?t.fan:e.fan};case`cycleFan`:return{...e,fan:f(e.fan)};case`update`:return M({...e,...t.payload},r);default:throw Error(`Unexpected Ac Action`)}}function I(e,t){return e===`cold`?{message:`制冷调到 ${t}°C 以上更省电`,detail:`少开一度,为节能减排出一份力`}:{message:`制热调到 ${t}°C 以下更省电`,detail:`少开一度,为节能减排出一份力`}}function L(){let e;return(t,n)=>{if(t.kind===`limit`)return`shake`;if(t.kind===`setting`)return`announce`;let r=`${n.mode}:${n.temperature}`;return r===e?`skip`:(e=r,`note`)}}function R(e){return`${o[e]}模式:${{normal:`风声和按键音恢复正常`,sleep:`风声和按键音都调小了,晚安`,mute:`空调不再发出任何声音`}[e]}`}function z(e){return e===`auto`?`风速:自动,由空调根据室温调节`:`风速:${l[e]}`}function B(e){return e?`扫风已开启:导风板上下摆动,出风左右扫`:`扫风已关闭:导风板停在当前位置`}function V(e,t,r,i=n){if(r.type===`increment`&&e.temperature>=i.max)return{message:`已经是最大温度啦!`,severity:`error`,kind:`limit`};if(r.type===`decrement`&&e.temperature<=i.min)return{message:`已经是最小温度啦!`,severity:`error`,kind:`limit`};if((r.type===`sound`||r.type===`cycleSound`)&&t.sound!==e.sound)return{message:R(t.sound),severity:`info`,kind:`setting`};if((r.type===`fan`||r.type===`cycleFan`)&&t.fan&&t.fan!==e.fan)return{message:z(t.fan),severity:`info`,kind:`setting`};if((r.type===`swing`||r.type===`toggleSwing`)&&t.swing!==e.swing)return{message:B(t.swing),severity:`info`,kind:`setting`};if(r.type===`mode`&&t.mode===`cold`&&t.temperature<26)return{...I(`cold`,26),severity:`success`,kind:`tip`};if(r.type===`mode`&&t.mode===`hot`&&t.temperature>20)return{...I(`hot`,20),severity:`success`,kind:`tip`}}function ie(e,t){if(!e)return r;try{let n=e.getItem(t);return n?M(JSON.parse(n)):r}catch{return r}}function ae(e,t,n){if(e)try{e.setItem(t,JSON.stringify(n))}catch{}}function oe(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function se(e={}){let t=e.storageKey??`ac:state`,n=e.storage===void 0?oe():e.storage,i=ie(n,t),a=e.limits,o=M({...r,...i,...e.initialState},a),s=/* @__PURE__ */ new Set;return{getState(){return o},dispatch(r){let i=o,c=F(o,r,a),l=V(i,c,r,a),u={action:r,previousState:i,state:c,notification:l};return o=c,ae(n,t,c),s.forEach(e=>e(u)),l&&e.onNotify?.(l,u),u},subscribe(e){return s.add(e),()=>{s.delete(e)}}}}let ce={cold:`m20.79 13.95l-2.33.62l-2-1.13v-2.88l2-1.13l2.33.62l.52-1.93l-1.77-.47l.46-1.77l-1.93-.52l-.62 2.33l-2 1.13L13 7.38V5.12l1.71-1.71L13.29 2L12 3.29L10.71 2L9.29 3.41L11 5.12v2.26L8.5 8.82l-2-1.13l-.58-2.33L4 5.88l.47 1.77l-1.77.47l.52 1.93l2.33-.62l2 1.13v2.89l-2 1.13l-2.33-.62l-.52 1.93l1.77.47L4 18.12l1.93.52l.62-2.33l2-1.13L11 16.62v2.26l-1.71 1.71L10.71 22L12 20.71L13.29 22l1.41-1.41l-1.7-1.71v-2.26l2.5-1.45l2 1.13l.62 2.33l1.88-.51l-.47-1.77l1.77-.47zM9.5 10.56L12 9.11l2.5 1.45v2.88L12 14.89l-2.5-1.45z`,hot:`m3.55 19.09l1.41 1.41l1.8-1.79l-1.42-1.42M12 6c-3.31 0-6 2.69-6 6s2.69 6 6 6s6-2.69 6-6c0-3.32-2.69-6-6-6m8 7h3v-2h-3m-2.76 7.71l1.8 1.79l1.41-1.41l-1.79-1.8M20.45 5l-1.41-1.4l-1.8 1.79l1.42 1.42M13 1h-2v3h2M6.76 5.39L4.96 3.6L3.55 5l1.79 1.81zM1 13h3v-2H1m12 9h-2v3h2`,power:`m16.56 5.44l-1.45 1.45A5.97 5.97 0 0 1 18 12a6 6 0 0 1-6 6a6 6 0 0 1-6-6c0-2.17 1.16-4.06 2.88-5.12L7.44 5.44A7.96 7.96 0 0 0 4 12a8 8 0 0 0 8 8a8 8 0 0 0 8-8c0-2.72-1.36-5.12-3.44-6.56M13 3h-2v10h2`,plus:`M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z`,minus:`M19 13H5v-2h14z`,increase:`m7 15l5-5l5 5z`,decrease:`m7 10l5 5l5-5z`,fan:`M12 11a1 1 0 0 0-1 1a1 1 0 0 0 1 1a1 1 0 0 0 1-1a1 1 0 0 0-1-1m.5-9c4.5 0 4.61 3.57 2.25 4.75c-.99.49-1.43 1.54-1.62 2.47c.48.2.9.51 1.22.91c3.7-2 7.68-1.21 7.68 2.37c0 4.5-3.57 4.6-4.75 2.23c-.5-.99-1.56-1.43-2.49-1.62c-.2.48-.51.89-.91 1.23c1.99 3.69 1.2 7.66-2.38 7.66c-4.5 0-4.59-3.58-2.23-4.76c.98-.49 1.42-1.53 1.62-2.45c-.49-.2-.92-.52-1.24-.92C5.96 15.85 2 15.07 2 11.5C2 7 5.56 6.89 6.74 9.26c.5.99 1.55 1.42 2.48 1.61c.19-.48.51-.9.92-1.22C8.15 5.96 8.94 2 12.5 2`,swing:`M6 14h3l-4 4l-4-4h3c0-2.7 1.7-7.4 7-7.9v2c-3.4.5-5 3.8-5 5.9m14 0c0-2.7-1.7-7.4-7-7.9v2c3.4.6 5 3.8 5 5.9h-3l4 4l4-4z`,soundNormal:`M14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.84-5 6.7v2.07c4-.91 7-4.49 7-8.77s-3-7.86-7-8.77M16.5 12c0-1.77-1-3.29-2.5-4.03V16c1.5-.71 2.5-2.24 2.5-4M3 9v6h4l5 5V4L7 9z`,soundSleep:`m17.75 4.09l-2.53 1.94l.91 3.06l-2.63-1.81l-2.63 1.81l.91-3.06l-2.53-1.94L12.44 4l1.06-3l1.06 3zm3.5 6.91l-1.64 1.25l.59 1.98l-1.7-1.17l-1.7 1.17l.59-1.98L15.75 11l2.06-.05L18.5 9l.69 1.95zm-2.28 4.95c.83-.08 1.72 1.1 1.19 1.85c-.32.45-.66.87-1.08 1.27C15.17 23 8.84 23 4.94 19.07c-3.91-3.9-3.91-10.24 0-14.14c.4-.4.82-.76 1.27-1.08c.75-.53 1.93.36 1.85 1.19c-.27 2.86.69 5.83 2.89 8.02a9.96 9.96 0 0 0 8.02 2.89m-1.64 2.02a12.08 12.08 0 0 1-7.8-3.47c-2.17-2.19-3.33-5-3.49-7.82c-2.81 3.14-2.7 7.96.31 10.98c3.02 3.01 7.84 3.12 10.98.31`,soundMute:`M12 4L9.91 6.09L12 8.18M4.27 3L3 4.27L7.73 9H3v6h4l5 5v-6.73l4.25 4.26c-.67.51-1.42.93-2.25 1.17v2.07c1.38-.32 2.63-.95 3.68-1.81L19.73 21L21 19.73l-9-9M19 12c0 .94-.2 1.82-.54 2.64l1.51 1.51A8.9 8.9 0 0 0 21 12c0-4.28-3-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71m-2.5 0c0-1.77-1-3.29-2.5-4.03v2.21l2.45 2.45c.05-.2.05-.42.05-.63`,leaf:`M17 8C8 10 5.9 16.17 3.82 21.34l1.89.66l.95-2.3c.48.17.98.3 1.34.3C19 20 22 3 22 3c-1 2-8 2.25-13 3.25S2 11.5 2 13.5s1.75 3.75 1.75 3.75C7 8 17 8 17 8`},H={normal:`soundNormal`,sleep:`soundSleep`,mute:`soundMute`};function le(e){let t=`扫风:${e.swing?`开`:`关`}`,n=`声音:${o[e.sound]}`,r=`风速:${l[e.fan??`auto`]}`;return{display:`${e.status?`运行`:`待机`},${a[e.mode]} ${e.temperature}°C,${r},${t},${n}`,power:`电源:${e.status?`开`:`关`}`,mode:a,fan:r,swing:t,sound:n}}let U={grade:1,grades:5,standard:`GB 21455-2019`,top:[{num:4,size:4,mx:1.5,my:0,color:`white`}],detail:[{num:11,size:2,mx:.8,my:2,color:`black`},{num:9,size:1.5,mx:.8,my:2,color:`black`},{num:10,size:1.2,mx:.8,my:0,color:`black`}],footer:{num:8,size:2,mx:.8,my:0,color:`white`},levels:[{background:`lightgreen`,width:`50%`},{background:`#fdd835`,width:`60%`},{background:`orange`,width:`70%`},{background:`red`,width:`80%`}]};function ue(){return`中国能效标识:能效等级 ${U.grade} 级(共 ${U.grades} 级),依据 ${U.standard}`}function W(e){"@babel/helpers - typeof";return W=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},W(e)}function de(e,t){if(W(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(W(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function fe(e){var t=de(e,`string`);return W(t)==`symbol`?t:t+``}function G(e,t,n){return(t=fe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let K=`air-conditioner-widget`,pe=`acw-digit-font`;function q(e){return e.replace(/[&<>"']/g,e=>`&#${e.charCodeAt(0)};`)}function me(e){if(typeof document>`u`||document.getElementById(pe))return;let t=document.createElement(`style`);t.id=pe,t.textContent=`@font-face {
2
- font-family: "Digital-7 Mono";
3
- src: url("${e.replace(/\/$/,``)}/fonts/digital-7-mono.ttf") format("truetype");
4
- font-display: swap;
5
- }`,document.head.appendChild(t)}function J(e,t,n){return`<svg${n?` class="${n}"`:``} viewBox="0 0 24 24" width="${t}" height="${t}" aria-hidden="true"><path fill="currentColor" d="${ce[e]}" /></svg>`}function Y(e){let t=Array.from({length:e.num}).fill(`<span class="acw-dot" style="width: ${e.size}px; height: ${e.size}px; margin: ${e.my}px ${e.mx}px"></span>`).join(``);return`<div class="acw-dot-row" style="--acw-dot-color: ${e.color}">${t}</div>`}function he(){let e=U.levels.map(e=>`<div class="acw-energy-level" style="background-color: ${e.background}; width: ${e.width}"></div>`).join(``);return`<div class="acw-energy-label" role="img" aria-label="${ue()}">
6
- <div class="acw-energy-header">${U.top.map(e=>Y(e)).join(``)}<span class="acw-energy-qr"></span></div>
7
- <div class="acw-energy-grades">
8
- <div class="acw-energy-arrow"><div class="acw-arrow-bar"></div><div class="acw-arrow-tip"></div><div class="acw-arrow-bar acw-arrow-bar-sm"></div></div>
9
- ${e}
10
- </div>
11
- <div class="acw-energy-detail">
12
- ${U.detail.map((e,t)=>Y(e)+(t===0?`<div class="acw-energy-detail-line"></div>`:``)).join(``)}
13
- </div>
14
- ${Y(U.footer)}
15
- </div>`}function ge(e){let t=e.audio?`<audio data-audio="beep" src="${q(e.audio.beep)}" preload="auto"></audio>
16
- <audio data-audio="start" src="${q(e.audio.start)}" preload="auto"></audio>
17
- <audio data-audio="work" src="${q(e.audio.work)}" preload="auto"></audio>`:``,n=e.logoUrl?`<div class="acw-logo"><a href="${q(e.logoHref)}" target="_blank" rel="noreferrer noopener"${e.title?` title="${q(e.title)}"`:``} aria-label="${q(e.title??`Air Conditioner`)}"><img src="${q(e.logoUrl)}" alt=""></a></div>`:``;return`
18
- <style>:host {
1
+ (function(){let e={cold:`❄️`,hot:`☀️`},t={beep:`di`,start:`ac-work`,work:`air-extractor-fan`},n={min:16,max:31,step:1},r={mode:`cold`,status:!1,temperature:26,temperatures:{cold:26,hot:26},sound:`normal`,swing:!1,fan:`auto`},i=[`normal`,`sleep`,`mute`],a={cold:`制冷`,hot:`制热`},o={normal:`标准`,sleep:`睡眠`,mute:`静音`},s={normal:1,sleep:.3,mute:0},c=[`auto`,`low`,`medium`,`high`],l={auto:`自动`,low:`低风`,medium:`中风`,high:`高风`},u={low:.45,medium:.7,high:1};function d(e){return c.includes(e)}function f(e){let t=Math.max(c.indexOf(e),0);return c[(t+1)%c.length]}function p(e){return i.includes(e)}function m(e){let t=Math.max(i.indexOf(e),0);return i[(t+1)%i.length]}let h={startDelayMs:8e3,loopCrossfadeMs:1500,stopFadeMs:600,settleAfterMs:9e4,settleRampMs:2e4,settleLevel:.5,surgeLevel:.85,quietDurationMs:[18e4,36e4],surgeDurationMs:[6e4,12e4],surgeRampMs:1e4};function g(e=`/assets/audio`,n=`m4a`){let r=e.replace(/\/$/,``);return{beep:`${r}/${t.beep}.${n}`,start:`${r}/${t.start}.${n}`,work:`${r}/${t.work}.${n}`}}let ee=/* @__PURE__ */ new Map;function te(e){return e?.currentSrc||e?.src||``}async function ne(e){let t=await fetch(e);if(!t.ok)throw Error(`Failed to load ${e}: ${t.status}`);return t.arrayBuffer()}function re(){let e=globalThis,t=e.AudioContext??e.webkitAudioContext;if(!t)return null;try{return new t({latencyHint:`interactive`})}catch{return new t}}function ie(e,t){let n=e.currentTime,r=e.createOscillator(),i=e.createGain();r.type=`sine`,r.frequency.setValueAtTime(1500,n),r.frequency.exponentialRampToValueAtTime(520,n+.07),i.gain.setValueAtTime(1e-4,n),i.gain.exponentialRampToValueAtTime(.12,n+.004),i.gain.exponentialRampToValueAtTime(1e-4,n+.16),r.connect(i),i.connect(t),r.start(n),r.stop(n+.18),r.onended=()=>i.disconnect()}function ae(e,t){if(typeof e.createOscillator!=`function`)return!1;try{let n=e.currentTime,r=e.createOscillator(),i=e.createGain();return r.type=`sine`,r.frequency.setValueAtTime(2400,n),r.frequency.exponentialRampToValueAtTime(1400,n+.02),i.gain.setValueAtTime(1e-4,n),i.gain.exponentialRampToValueAtTime(.15,n+.002),i.gain.exponentialRampToValueAtTime(1e-4,n+.045),r.connect(i),i.connect(t),r.start(n),r.stop(n+.05),r.onended=()=>i.disconnect(),!0}catch{return!1}}function _(e){let t=/* @__PURE__ */ new Float32Array(64);for(let n=0;n<64;n++){let r=n/63*Math.PI/2;t[n]=e===`in`?Math.sin(r):Math.cos(r)}return t}function v(e,t){return e[0]+(e[1]-e[0])*t()}function y(e){e&&(e.load(),Promise.resolve(e.play()).catch(()=>{}))}function oe(e){if(e){try{e.currentTime>0&&(e.pause?.(),e.currentTime=0)}catch{}Promise.resolve(e.play()).catch(()=>{})}}function b(e){e&&(e.pause?e.pause():e.load())}function x(e,t={}){let n=t.random??Math.random,r=t.soundMode??`normal`,i=t.fanSpeed??`auto`,a=!1,o=0,c,l,d=0,f=/* @__PURE__ */ new Set,p=t.loadAudioData?/* @__PURE__ */ new Map:ee,m,g=1,x;function S(e,t){let n=setTimeout(()=>{f.delete(n),e()},t);f.add(n)}function C(){f.forEach(e=>clearTimeout(e)),f.clear()}function w(){return s[r]}function T(e,t=1){e&&(e.volume!==void 0&&(e.volume=Math.min(1,Math.max(0,w()*t))),e.muted!==void 0&&(e.muted=r===`mute`))}function E(){x&&clearInterval(x),x=void 0}function D(t,n,r){E();let i=g,a=Math.max(1,Math.round(n/100)),o=0;x=setInterval(()=>{o++,g=i+(t-i)*(o/a),T(e.work,g),o>=a&&(E(),r?.())},100)}function O(){return c===void 0&&(c=j(),c&&(m=N())),c}function k(){let e=O();e&&M(e)}function A(e){let n=p.get(e);if(!n){let r=t.loadAudioData??ne;n=new Promise((t,n)=>{try{t(r(e))}catch(e){n(e)}}).catch(t=>{throw p.delete(e),t}),p.set(e,n)}return n.then(e=>e.slice(0))}function j(){if(t.webAudio===!1)return null;try{let n=(t.createAudioContext??re)();if(!n)return null;let r=n.createGain();r.gain.value=w(),r.connect(n.destination);let i={};return{context:n,master:r,buffers:i,ready:Promise.all([`beep`,`start`,`work`].map(async t=>{let r=te(e[t]);if(r&&!i[t])try{i[t]=await n.decodeAudioData(await A(r))}catch{}})).then(()=>!!(i.start&&i.work))}}catch{return null}}function M(e){e.context.state===`suspended`&&Promise.resolve(e.context.resume()).catch(()=>{})}function N(){if(typeof document>`u`)return()=>{};let e=()=>{k()};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`keydown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`keydown`,e,!0)}}function P(e){return Promise.race([e.ready,new Promise(e=>setTimeout(e,1500,!1))])}function F(e,t,n,r){let i=e.context.createBufferSource();return i.buffer=t,i.connect(n),i.start(r),i}function I(e,t,n){e.sources.add(t),t.onended=()=>{e.sources.delete(t),t.disconnect(),n?.()}}function L(e,t,n){let r=e.buffers.work,i=Math.min(h.loopCrossfadeMs/1e3,r.duration/2),a=e.context.createGain();a.gain.value=0,a.gain.setValueCurveAtTime(_(`in`),n,i),a.gain.setValueCurveAtTime(_(`out`),n+r.duration-i,i),a.connect(t.fan);let o=F(e,r,a,n);o.stop(n+r.duration),I(t,o,()=>a.disconnect());let s=n+r.duration-i;S(()=>{l===t&&L(e,t,s)},Math.max(0,(s-e.context.currentTime-1)*1e3))}function R(e,t){if(l&&c){let n=l.fan.gain,r=c.context.currentTime;n.cancelScheduledValues(r),n.setValueAtTime(n.value,r),n.linearRampToValueAtTime(e,r+t/1e3)}else D(e,t)}function z(){return i===`auto`?1:u[i]}function B(){a=!0;let e=++o;if(i!==`auto`)return;let t=()=>e===o&&i===`auto`,r=()=>{S(()=>{t()&&(R(h.surgeLevel,h.surgeRampMs),S(()=>{t()&&(R(h.settleLevel,h.surgeRampMs),r())},v(h.surgeDurationMs,n)))},v(h.quietDurationMs,n))};S(()=>{t()&&(R(h.settleLevel,h.settleRampMs),r())},h.settleAfterMs)}function V(e,t=!0){let n=e.context.createGain();n.connect(e.master);let r=e.context.createGain();r.gain.value=z(),r.connect(n);let i={output:n,fan:r,sources:/* @__PURE__ */ new Set};l=i;let a=e.context.currentTime;t?(I(i,F(e,e.buffers.start,n,a)),L(e,i,a+h.startDelayMs/1e3),S(B,h.startDelayMs)):(L(e,i,a),B())}function H(e){let t=l;if(l=void 0,!t||!c)return;let n=c.context.currentTime,r=n+e/1e3,i=t.output.gain;i.cancelScheduledValues(n),i.setValueAtTime(i.value,n),i.linearRampToValueAtTime(0,r),t.sources.forEach(e=>{try{e.stop(r)}catch{}}),setTimeout(()=>t.output.disconnect(),e+100)}function U(t=!0){let{start:n,work:r}=e;b(r);let i=()=>{r&&(g=0,T(r,0),r.loop!==void 0&&(r.loop=!0),y(r),D(z(),h.loopCrossfadeMs),B())};t?(T(n),y(n),S(i,h.startDelayMs)):i()}function W(t){b(e.start),t>0?D(0,t,()=>b(e.work)):b(e.work)}function G(e=!0){let t=++d;a=!1,o++,C(),E(),H(0),W(0);let n=O();n?(M(n),P(n).then(r=>{t===d&&(r?V(n,e):U(e))})):U(e)}function se(){d++,a=!1,o++,C(),H(h.stopFadeMs),W(h.stopFadeMs)}return t.webAudio!==!1&&O(),{unlock(){k()},beep(){if(r===`mute`)return;let t=O();if(t){if(M(t),t.buffers.beep){let e=F(t,t.buffers.beep,t.master,t.context.currentTime);e.onended=()=>{try{e.disconnect()}catch{}};return}if(ae(t.context,t.master))return}T(e.beep),oe(e.beep)},drip(){if(r!==`normal`)return;let e=O();e&&e.context.state===`running`&&typeof e.context.createOscillator==`function`&&ie(e.context,e.master)},toggleStatusAudio(e){e?se():G()},resumeFan(){G(!1)},setSoundMode(t){r=t,c&&c.master.gain.setTargetAtTime(w(),c.context.currentTime,.08),T(e.beep),T(e.start),T(e.work,g)},setFanSpeed(e){e!==i&&(i=e,a?e===`auto`?(R(1,h.loopCrossfadeMs),B()):(o++,R(u[e],h.loopCrossfadeMs)):l&&(l.fan.gain.value=z()))},dispose(){d++,C(),E(),H(0),W(0),m?.(),m=void 0,c&&!t.createAudioContext&&Promise.resolve(c.context.close()).catch(()=>{}),c=null}}}let S={auto:.8,low:.55,medium:.8,high:1},C=[9e3,18e3];function w(e){if(!e.status||e.mode!==`cold`)return 0;let t=.2+.8*(31-e.temperature)/15,n=Math.min(1,Math.max(.2,t))*S[e.fan??`auto`];return Math.round(n*100)/100}function T(e){if(!e.status||e.mode!==`cold`||e.temperature>22)return;let[t,n]=C,r=(e.temperature-16)/6,i=t+(n-t)*Math.min(1,Math.max(0,r));return Math.round(i*(e.fan===`high`?.8:1))}function E(e){let t=T(e);return{mist:w(e),dripCycle:t===void 0?void 0:`${t}ms`,drip:t===void 0?`off`:`on`}}let D={compact:{width:360,height:128},wide:{width:600,height:200}};function O(e,t){return!(e>0)||!(t>0)?1:Math.min(1,e/t)}function k(e,t,n){if(typeof ResizeObserver>`u`)return()=>{};let r,i=e=>{let i=O(e,t);i!==r&&(r=i,n(i))};i(e.offsetWidth??e.getBoundingClientRect().width);let a=new ResizeObserver(e=>{for(let t of e)i(t.contentRect.width)});return a.observe(e),()=>a.disconnect()}function A(e,t,n=4){let r=globalThis.matchMedia;if(typeof r!=`function`||!r(`(hover: hover) and (pointer: fine)`).matches||r(`(prefers-reduced-motion: reduce)`).matches)return()=>{};let i=0,a=0,o=0,s=!1,c=(e,n)=>{s=e!==0||n!==0,t(e,n)},l=t=>{a=t.clientX,o=t.clientY,!i&&(i=requestAnimationFrame(()=>{i=0;let t=e.getBoundingClientRect();if(!t.width||!t.height)return;let r=(a-t.left)/t.width-.5,s=(o-t.top)/t.height-.5,l=e=>Math.round(e*100)/100;c(l(-s*2*n),l(r*2*n))}))},u=()=>{i&&(cancelAnimationFrame(i),i=0),s&&c(0,0)};return e.addEventListener(`pointermove`,l,{passive:!0}),e.addEventListener(`pointerleave`,u,{passive:!0}),()=>{u(),e.removeEventListener(`pointermove`,l),e.removeEventListener(`pointerleave`,u)}}function j(e,t,n={}){let{delay:r=500,interval:i=200,minInterval:a=100,value:o}=n,s,c=i,l,u=!1,d=0,f=()=>{d++,clearTimeout(s),s=void 0},p=e=>{if(!(u||e!==d)){if(o&&o()===l)return f();l=o?.(),t(),!(u||e!==d)&&(c=Math.max(a,c*.85),s=setTimeout(p,c,e))}},m=e=>{if(u||e.button!==0)return;f();let n=d;l=o?.(),t(),!(u||n!==d)&&(c=i,s=setTimeout(p,r,n))},h=e=>{!u&&e.detail===0&&t()},g=e=>e.preventDefault();return e.addEventListener(`pointerdown`,m),e.addEventListener(`pointerup`,f),e.addEventListener(`pointerleave`,f),e.addEventListener(`pointercancel`,f),e.addEventListener(`click`,h),e.addEventListener(`contextmenu`,g),()=>{u=!0,f(),e.removeEventListener(`pointerdown`,m),e.removeEventListener(`pointerup`,f),e.removeEventListener(`pointerleave`,f),e.removeEventListener(`pointercancel`,f),e.removeEventListener(`click`,h),e.removeEventListener(`contextmenu`,g)}}function M(e,t){let n=e?.mode===`hot`?`hot`:`cold`,i=P(e?.temperature??r.temperature,t),a=n=>{let r=e?.temperatures?.[n];return typeof r==`number`&&Number.isFinite(r)?P(r,t):i};return{...r,...e,mode:n,temperature:i,temperatures:{cold:n===`cold`?i:a(`cold`),hot:n===`hot`?i:a(`hot`)},sound:p(e?.sound)?e.sound:r.sound,swing:typeof e?.swing==`boolean`?e.swing:r.swing,fan:d(e?.fan)?e.fan:`auto`}}function N(e,t){let n={cold:t,hot:t,...e.temperatures};return n[e.mode]=t,{...e,temperature:t,temperatures:n}}function P(e,t){if(!t)return Math.min(31,Math.max(16,e));let{min:n,max:r,step:i}=t,a=i>0?Math.round((e-n)/i)*i+n:e;return Number(Math.min(r,Math.max(n,a)).toFixed(4))}function F(e,t,r){let i=r?.step??n.step;switch(t.type){case`increment`:return N(e,P(e.temperature+i,r));case`decrement`:return N(e,P(e.temperature-i,r));case`toggleStatus`:return{...e,status:!e.status};case`status`:return{...e,status:t.status};case`mode`:{let n=e.status||t.powerOn===!0;if(t.mode===e.mode)return n===e.status?e:{...e,status:n};let i={cold:e.temperature,hot:e.temperature,...e.temperatures,[e.mode]:e.temperature};return{...e,status:n,mode:t.mode,temperature:P(i[t.mode]??e.temperature,r),temperatures:i}}case`sound`:return{...e,sound:p(t.sound)?t.sound:e.sound};case`cycleSound`:return{...e,sound:m(e.sound)};case`toggleSwing`:return{...e,swing:!e.swing};case`swing`:return{...e,swing:t.swing===!0};case`fan`:return{...e,fan:d(t.fan)?t.fan:e.fan};case`cycleFan`:return{...e,fan:f(e.fan)};case`update`:return M({...e,...t.payload},r);default:throw Error(`Unexpected Ac Action`)}}function I(e,t){return e===`cold`?{message:`制冷调到 ${t}°C 以上更省电`,detail:`少开一度,为节能减排出一份力`}:{message:`制热调到 ${t}°C 以下更省电`,detail:`少开一度,为节能减排出一份力`}}function L(){let e;return(t,n)=>{if(t.kind===`limit`)return`shake`;if(t.kind===`setting`)return`announce`;let r=`${n.mode}:${n.temperature}`;return r===e?`skip`:(e=r,`note`)}}function R(e){return`${o[e]}模式:${{normal:`风声和按键音恢复正常`,sleep:`风声和按键音都调小了,晚安`,mute:`空调不再发出任何声音`}[e]}`}function z(e){return e===`auto`?`风速:自动,由空调根据室温调节`:`风速:${l[e]}`}function B(e){return e?`扫风已开启:导风板上下摆动,出风左右扫`:`扫风已关闭:导风板停在当前位置`}function V(e,t,r,i=n){if(r.type===`increment`&&e.temperature>=i.max)return{message:`已经是最大温度啦!`,severity:`error`,kind:`limit`};if(r.type===`decrement`&&e.temperature<=i.min)return{message:`已经是最小温度啦!`,severity:`error`,kind:`limit`};if((r.type===`sound`||r.type===`cycleSound`)&&t.sound!==e.sound)return{message:R(t.sound),severity:`info`,kind:`setting`};if((r.type===`fan`||r.type===`cycleFan`)&&t.fan&&t.fan!==e.fan)return{message:z(t.fan),severity:`info`,kind:`setting`};if((r.type===`swing`||r.type===`toggleSwing`)&&t.swing!==e.swing)return{message:B(t.swing),severity:`info`,kind:`setting`};if(r.type===`mode`&&t.mode===`cold`&&t.temperature<26)return{...I(`cold`,26),severity:`success`,kind:`tip`};if(r.type===`mode`&&t.mode===`hot`&&t.temperature>20)return{...I(`hot`,20),severity:`success`,kind:`tip`}}function H(e,t){if(!e)return r;try{let n=e.getItem(t);return n?M(JSON.parse(n)):r}catch{return r}}function U(e,t,n){if(e)try{e.setItem(t,JSON.stringify(n))}catch{}}function W(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function G(e={}){let t=e.storageKey??`ac:state`,n=e.storage===void 0?W():e.storage,i=H(n,t),a=e.limits,o=M({...r,...i,...e.initialState},a),s=/* @__PURE__ */ new Map;return{getState(){return o},dispatch(r){let i=o,c=F(o,r,a),l=V(i,c,r,a),u={action:r,previousState:i,state:c,notification:l};o=c,U(n,t,c);for(let[e,t]of[...s])s.get(e)===t&&e(u);return l&&e.onNotify?.(l,u),u},subscribe(e){let t=s.get(e);return t||(t=Symbol(`subscription`),s.set(e,t)),()=>{s.get(e)===t&&s.delete(e)}}}}let se={cold:`m20.79 13.95l-2.33.62l-2-1.13v-2.88l2-1.13l2.33.62l.52-1.93l-1.77-.47l.46-1.77l-1.93-.52l-.62 2.33l-2 1.13L13 7.38V5.12l1.71-1.71L13.29 2L12 3.29L10.71 2L9.29 3.41L11 5.12v2.26L8.5 8.82l-2-1.13l-.58-2.33L4 5.88l.47 1.77l-1.77.47l.52 1.93l2.33-.62l2 1.13v2.89l-2 1.13l-2.33-.62l-.52 1.93l1.77.47L4 18.12l1.93.52l.62-2.33l2-1.13L11 16.62v2.26l-1.71 1.71L10.71 22L12 20.71L13.29 22l1.41-1.41l-1.7-1.71v-2.26l2.5-1.45l2 1.13l.62 2.33l1.88-.51l-.47-1.77l1.77-.47zM9.5 10.56L12 9.11l2.5 1.45v2.88L12 14.89l-2.5-1.45z`,hot:`m3.55 19.09l1.41 1.41l1.8-1.79l-1.42-1.42M12 6c-3.31 0-6 2.69-6 6s2.69 6 6 6s6-2.69 6-6c0-3.32-2.69-6-6-6m8 7h3v-2h-3m-2.76 7.71l1.8 1.79l1.41-1.41l-1.79-1.8M20.45 5l-1.41-1.4l-1.8 1.79l1.42 1.42M13 1h-2v3h2M6.76 5.39L4.96 3.6L3.55 5l1.79 1.81zM1 13h3v-2H1m12 9h-2v3h2`,power:`m16.56 5.44l-1.45 1.45A5.97 5.97 0 0 1 18 12a6 6 0 0 1-6 6a6 6 0 0 1-6-6c0-2.17 1.16-4.06 2.88-5.12L7.44 5.44A7.96 7.96 0 0 0 4 12a8 8 0 0 0 8 8a8 8 0 0 0 8-8c0-2.72-1.36-5.12-3.44-6.56M13 3h-2v10h2`,plus:`M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z`,minus:`M19 13H5v-2h14z`,increase:`m7 15l5-5l5 5z`,decrease:`m7 10l5 5l5-5z`,fan:`M12 11a1 1 0 0 0-1 1a1 1 0 0 0 1 1a1 1 0 0 0 1-1a1 1 0 0 0-1-1m.5-9c4.5 0 4.61 3.57 2.25 4.75c-.99.49-1.43 1.54-1.62 2.47c.48.2.9.51 1.22.91c3.7-2 7.68-1.21 7.68 2.37c0 4.5-3.57 4.6-4.75 2.23c-.5-.99-1.56-1.43-2.49-1.62c-.2.48-.51.89-.91 1.23c1.99 3.69 1.2 7.66-2.38 7.66c-4.5 0-4.59-3.58-2.23-4.76c.98-.49 1.42-1.53 1.62-2.45c-.49-.2-.92-.52-1.24-.92C5.96 15.85 2 15.07 2 11.5C2 7 5.56 6.89 6.74 9.26c.5.99 1.55 1.42 2.48 1.61c.19-.48.51-.9.92-1.22C8.15 5.96 8.94 2 12.5 2`,swing:`M6 14h3l-4 4l-4-4h3c0-2.7 1.7-7.4 7-7.9v2c-3.4.5-5 3.8-5 5.9m14 0c0-2.7-1.7-7.4-7-7.9v2c3.4.6 5 3.8 5 5.9h-3l4 4l4-4z`,soundNormal:`M14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.84-5 6.7v2.07c4-.91 7-4.49 7-8.77s-3-7.86-7-8.77M16.5 12c0-1.77-1-3.29-2.5-4.03V16c1.5-.71 2.5-2.24 2.5-4M3 9v6h4l5 5V4L7 9z`,soundSleep:`m17.75 4.09l-2.53 1.94l.91 3.06l-2.63-1.81l-2.63 1.81l.91-3.06l-2.53-1.94L12.44 4l1.06-3l1.06 3zm3.5 6.91l-1.64 1.25l.59 1.98l-1.7-1.17l-1.7 1.17l.59-1.98L15.75 11l2.06-.05L18.5 9l.69 1.95zm-2.28 4.95c.83-.08 1.72 1.1 1.19 1.85c-.32.45-.66.87-1.08 1.27C15.17 23 8.84 23 4.94 19.07c-3.91-3.9-3.91-10.24 0-14.14c.4-.4.82-.76 1.27-1.08c.75-.53 1.93.36 1.85 1.19c-.27 2.86.69 5.83 2.89 8.02a9.96 9.96 0 0 0 8.02 2.89m-1.64 2.02a12.08 12.08 0 0 1-7.8-3.47c-2.17-2.19-3.33-5-3.49-7.82c-2.81 3.14-2.7 7.96.31 10.98c3.02 3.01 7.84 3.12 10.98.31`,soundMute:`M12 4L9.91 6.09L12 8.18M4.27 3L3 4.27L7.73 9H3v6h4l5 5v-6.73l4.25 4.26c-.67.51-1.42.93-2.25 1.17v2.07c1.38-.32 2.63-.95 3.68-1.81L19.73 21L21 19.73l-9-9M19 12c0 .94-.2 1.82-.54 2.64l1.51 1.51A8.9 8.9 0 0 0 21 12c0-4.28-3-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71m-2.5 0c0-1.77-1-3.29-2.5-4.03v2.21l2.45 2.45c.05-.2.05-.42.05-.63`,leaf:`M17 8C8 10 5.9 16.17 3.82 21.34l1.89.66l.95-2.3c.48.17.98.3 1.34.3C19 20 22 3 22 3c-1 2-8 2.25-13 3.25S2 11.5 2 13.5s1.75 3.75 1.75 3.75C7 8 17 8 17 8`},ce={normal:`soundNormal`,sleep:`soundSleep`,mute:`soundMute`};function le(e){let t=`扫风:${e.swing?`开`:`关`}`,n=`声音:${o[e.sound]}`,r=`风速:${l[e.fan??`auto`]}`;return{display:`${e.status?`运行`:`待机`},${a[e.mode]} ${e.temperature}°C,${r},${t},${n}`,power:`电源:${e.status?`开`:`关`}`,mode:a,fan:r,swing:t,sound:n}}let K={grade:1,grades:5,standard:`GB 21455-2019`,top:[{num:4,size:4,mx:1.5,my:0,color:`white`}],detail:[{num:11,size:2,mx:.8,my:2,color:`black`},{num:9,size:1.5,mx:.8,my:2,color:`black`},{num:10,size:1.2,mx:.8,my:0,color:`black`}],footer:{num:8,size:2,mx:.8,my:0,color:`white`},levels:[{background:`lightgreen`,width:`50%`},{background:`#fdd835`,width:`60%`},{background:`orange`,width:`70%`},{background:`red`,width:`80%`}]};function ue(){return`中国能效标识:能效等级 ${K.grade} 级(共 ${K.grades} 级),依据 ${K.standard}`}let de=`
2
+ .acw-dock, .acw-remote-panel {
3
+ display: contents;
4
+ }
5
+
6
+ .acw-remote-toggle[hidden], .acw-remote-panel[hidden] {
7
+ display: none;
8
+ }
9
+
10
+ :host([data-ac-placement="top-left"]),
11
+ :host([data-ac-placement="top-right"]) {
12
+ position: fixed;
13
+ top: max(16px, env(safe-area-inset-top));
14
+ width: min(320px, calc(100vw - 32px));
15
+ z-index: var(--acw-floating-z-index, 1000);
16
+ pointer-events: none;
17
+ }
18
+
19
+ :host([data-ac-placement="top-left"]) {
20
+ left: max(16px, env(safe-area-inset-left));
21
+ }
22
+
23
+ :host([data-ac-placement="top-right"]) {
24
+ right: max(16px, env(safe-area-inset-right));
25
+ }
26
+
27
+ /* A filter on the root would make the fixed dock follow the unit, not the viewport. */
28
+ :host([data-ac-placement^="top-"]) .acw-root {
29
+ filter: none;
30
+ }
31
+
32
+ :host([data-ac-placement^="top-"]) .acw-shell {
33
+ /* Only the visible housing is interactive; airflow must not cover the page. */
34
+ pointer-events: auto;
35
+ }
36
+
37
+ :host([data-ac-placement^="top-"]) .acw-dock {
38
+ position: fixed;
39
+ bottom: max(16px, env(safe-area-inset-bottom));
40
+ display: flex;
41
+ flex-direction: column-reverse;
42
+ align-items: flex-end;
43
+ gap: 8px;
44
+ max-width: calc(100vw - 32px);
45
+ pointer-events: none;
46
+ }
47
+
48
+ :host([data-ac-placement="top-left"]) .acw-dock {
49
+ left: max(16px, env(safe-area-inset-left));
50
+ align-items: flex-start;
51
+ }
52
+
53
+ :host([data-ac-placement="top-right"]) .acw-dock {
54
+ right: max(16px, env(safe-area-inset-right));
55
+ }
56
+
57
+ :host([data-ac-placement^="top-"]) .acw-remote-panel:not([hidden]) {
58
+ pointer-events: auto;
59
+ display: block;
60
+ max-height: calc(100vh - 96px);
61
+ max-height: calc(100dvh - 96px);
62
+ overflow: auto;
63
+ padding: 8px;
64
+ }
65
+
66
+ :host([data-ac-placement^="top-"]) .acw-remote {
67
+ margin: 0;
68
+ }
69
+
70
+ .acw-remote-toggle {
71
+ display: inline-flex;
72
+ align-items: center;
73
+ justify-content: center;
74
+ gap: 6px;
75
+ pointer-events: auto;
76
+ min-height: 44px;
77
+ padding: 8px 16px;
78
+ border: 1px solid var(--acw-border-color);
79
+ border-radius: 24px;
80
+ background: #fff;
81
+ color: #141414;
82
+ box-shadow: 0 2px 12px #0002;
83
+ font: inherit;
84
+ cursor: pointer;
85
+ }
86
+
87
+ .acw-remote-toggle:focus-visible {
88
+ outline: 2px solid #0284c7;
89
+ outline-offset: 3px;
90
+ }
91
+
92
+ @media (prefers-color-scheme: dark) {
93
+ .acw-remote-toggle {
94
+ background: #252a31;
95
+ color: #fafafa;
96
+ }
97
+ }
98
+ `,fe=`:host {
19
99
  display: inline-block;
20
100
  /* 宽度相对宿主容器确定,避免 inline-block 收缩到遥控器宽度把机身挤窄 */
21
101
  width: min(420px, 100%);
@@ -59,19 +139,21 @@
59
139
  }
60
140
  /* @ac-motion-tokens:end */
61
141
 
62
- html.dark .acw-root,
142
+ :host-context(html.dark) .acw-root,
63
143
  .acw-root.dark {
64
144
  --acw-text-color: #fafafa;
65
145
  }
66
146
 
67
- html.dark .acw-mist,
147
+ :host-context(html.dark) .acw-mist,
68
148
  .acw-root.dark .acw-mist {
69
- --acw-mist-color: rgba(214, 234, 252, 0.5);
149
+ --acw-mist-color: rgba(196, 228, 255, 0.58);
150
+ mix-blend-mode: screen;
70
151
  }
71
152
 
72
153
  @media (prefers-color-scheme: dark) {
73
154
  .acw-root:not(.light) .acw-mist {
74
- --acw-mist-color: rgba(214, 234, 252, 0.5);
155
+ --acw-mist-color: rgba(196, 228, 255, 0.58);
156
+ mix-blend-mode: screen;
75
157
  }
76
158
  }
77
159
 
@@ -81,32 +163,42 @@ html.dark .acw-mist,
81
163
  }
82
164
  }
83
165
 
84
- /* 暗色下换成深色纸,仍按模式着色 */
85
- html.dark .acw-note,
166
+ /* 暗色下保持白色家电一体的柔光浅纸,仅略微压暗底色并加深阴影 */
167
+ :host-context(html.dark) .acw-note,
86
168
  .acw-root.dark .acw-note {
87
- --acw-note-bg: #1d2733;
88
- --acw-note-text: #e3ecf5;
89
- --acw-note-accent: #64b5f6;
169
+ --acw-note-bg: #ecf2f9;
170
+ --acw-note-bg-bottom: #e0e9f3;
171
+ --acw-note-text: #1e293b;
172
+ --acw-note-accent: #2f7fd6;
173
+ --acw-note-shadow:
174
+ 0 10px 24px -8px rgba(0, 0, 0, 0.6),
175
+ 0 2px 4px rgba(0, 0, 0, 0.35);
90
176
  }
91
177
 
92
- html.dark .acw-note[data-mode="hot"],
178
+ :host-context(html.dark) .acw-note[data-mode="hot"],
93
179
  .acw-root.dark .acw-note[data-mode="hot"] {
94
- --acw-note-bg: #2d241d;
95
- --acw-note-text: #f5e9de;
96
- --acw-note-accent: #ffb74d;
180
+ --acw-note-bg: #f6ede3;
181
+ --acw-note-bg-bottom: #ede0d2;
182
+ --acw-note-text: #3b2a1e;
183
+ --acw-note-accent: #d9772b;
97
184
  }
98
185
 
99
186
  @media (prefers-color-scheme: dark) {
100
187
  .acw-root:not(.light) .acw-note {
101
- --acw-note-bg: #1d2733;
102
- --acw-note-text: #e3ecf5;
103
- --acw-note-accent: #64b5f6;
188
+ --acw-note-bg: #ecf2f9;
189
+ --acw-note-bg-bottom: #e0e9f3;
190
+ --acw-note-text: #1e293b;
191
+ --acw-note-accent: #2f7fd6;
192
+ --acw-note-shadow:
193
+ 0 10px 24px -8px rgba(0, 0, 0, 0.6),
194
+ 0 2px 4px rgba(0, 0, 0, 0.35);
104
195
  }
105
196
 
106
197
  .acw-root:not(.light) .acw-note[data-mode="hot"] {
107
- --acw-note-bg: #2d241d;
108
- --acw-note-text: #f5e9de;
109
- --acw-note-accent: #ffb74d;
198
+ --acw-note-bg: #f6ede3;
199
+ --acw-note-bg-bottom: #ede0d2;
200
+ --acw-note-text: #3b2a1e;
201
+ --acw-note-accent: #d9772b;
110
202
  }
111
203
  }
112
204
 
@@ -390,7 +482,7 @@ html.dark .acw-note[data-mode="hot"],
390
482
  animation-play-state: paused;
391
483
  }
392
484
 
393
- .acw-unit[data-status="on"][data-mode="cold"] .acw-mist i {
485
+ .acw-unit[data-status="on"][data-mode="cold"][data-mist="on"] .acw-mist i {
394
486
  animation-play-state: running;
395
487
  }
396
488
 
@@ -554,11 +646,11 @@ html.dark .acw-note[data-mode="hot"],
554
646
  pointer-events: none;
555
647
  }
556
648
 
557
- .acw-unit[data-status="on"] .acw-selftest {
649
+ .acw-unit[data-status="on"]:not([data-skip-selftest]) .acw-selftest {
558
650
  animation: acw-selftest 560ms steps(1, end) both;
559
651
  }
560
652
 
561
- .acw-unit[data-status="on"] .acw-readout {
653
+ .acw-unit[data-status="on"]:not([data-skip-selftest]) .acw-readout {
562
654
  animation: acw-selftest-reveal 560ms steps(1, end) both;
563
655
  }
564
656
 
@@ -822,8 +914,8 @@ html.dark .acw-note[data-mode="hot"],
822
914
  opacity: 1;
823
915
  }
824
916
 
825
- .acw-unit[data-status="on"] .acw-wind-line::before,
826
- .acw-unit[data-status="on"] .acw-wind-line::after {
917
+ .acw-unit[data-status="on"][data-mode="cold"] .acw-wind-line::before,
918
+ .acw-unit[data-status="on"][data-mode="hot"] .acw-wind-line::after {
827
919
  animation-play-state: running;
828
920
  }
829
921
 
@@ -1206,6 +1298,9 @@ html.dark .acw-note[data-mode="hot"],
1206
1298
  --acw-note-bg: #f4f9ff;
1207
1299
  --acw-note-text: #22313f;
1208
1300
  --acw-note-accent: #1e88e5;
1301
+ --acw-note-shadow:
1302
+ 0 1px 0 rgba(0, 0, 0, 0.04),
1303
+ 0 10px 18px -10px rgba(0, 0, 0, 0.45);
1209
1304
  /* 顶边落在出风线的下半截:风线仍在纸条上方,看起来是被风推出来的 */
1210
1305
  position: absolute;
1211
1306
  top: calc(-1 * var(--acw-note-lift, 42px));
@@ -1220,11 +1315,9 @@ html.dark .acw-note[data-mode="hot"],
1220
1315
  max-width: min(300px, 92%);
1221
1316
  padding: 9px 14px 8px 9px;
1222
1317
  border-radius: 3px 3px 10px 10px;
1223
- background: var(--acw-note-bg);
1318
+ background: linear-gradient(to bottom, var(--acw-note-bg), var(--acw-note-bg-bottom, var(--acw-note-bg)));
1224
1319
  color: var(--acw-note-text);
1225
- box-shadow:
1226
- 0 1px 0 rgba(0, 0, 0, 0.04),
1227
- 0 10px 18px -10px rgba(0, 0, 0, 0.45);
1320
+ box-shadow: var(--acw-note-shadow);
1228
1321
  font-size: 13px;
1229
1322
  line-height: 1.35;
1230
1323
  translate: -50% 0;
@@ -1432,109 +1525,29 @@ html.dark .acw-note[data-mode="hot"],
1432
1525
  opacity: 0;
1433
1526
  }
1434
1527
  }
1435
-
1436
- .acw-dock, .acw-remote-panel {
1437
- display: contents;
1438
- }
1439
-
1440
- .acw-remote-toggle[hidden], .acw-remote-panel[hidden] {
1441
- display: none;
1442
- }
1443
-
1444
- :host([data-ac-placement="top-left"]),
1445
- :host([data-ac-placement="top-right"]) {
1446
- position: fixed;
1447
- top: max(16px, env(safe-area-inset-top));
1448
- width: min(320px, calc(100vw - 32px));
1449
- z-index: var(--acw-floating-z-index, 1000);
1450
- pointer-events: none;
1451
- }
1452
-
1453
- :host([data-ac-placement="top-left"]) {
1454
- left: max(16px, env(safe-area-inset-left));
1455
- }
1456
-
1457
- :host([data-ac-placement="top-right"]) {
1458
- right: max(16px, env(safe-area-inset-right));
1459
- }
1460
-
1461
- /* A filter on the root would make the fixed dock follow the unit, not the viewport. */
1462
- :host([data-ac-placement^="top-"]) .acw-root {
1463
- filter: none;
1464
- }
1465
-
1466
- :host([data-ac-placement^="top-"]) .acw-shell {
1467
- /* Only the visible housing is interactive; airflow must not cover the page. */
1468
- pointer-events: auto;
1469
- }
1470
-
1471
- :host([data-ac-placement^="top-"]) .acw-dock {
1472
- position: fixed;
1473
- bottom: max(16px, env(safe-area-inset-bottom));
1474
- display: flex;
1475
- flex-direction: column-reverse;
1476
- align-items: flex-end;
1477
- gap: 8px;
1478
- max-width: calc(100vw - 32px);
1479
- pointer-events: none;
1480
- }
1481
-
1482
- :host([data-ac-placement="top-left"]) .acw-dock {
1483
- left: max(16px, env(safe-area-inset-left));
1484
- align-items: flex-start;
1485
- }
1486
-
1487
- :host([data-ac-placement="top-right"]) .acw-dock {
1488
- right: max(16px, env(safe-area-inset-right));
1489
- }
1490
-
1491
- :host([data-ac-placement^="top-"]) .acw-remote-panel:not([hidden]) {
1492
- pointer-events: auto;
1493
- display: block;
1494
- max-height: calc(100vh - 96px);
1495
- max-height: calc(100dvh - 96px);
1496
- overflow: auto;
1497
- padding: 8px;
1498
- }
1499
-
1500
- :host([data-ac-placement^="top-"]) .acw-remote {
1501
- margin: 0;
1502
- }
1503
-
1504
- .acw-remote-toggle {
1505
- display: inline-flex;
1506
- align-items: center;
1507
- justify-content: center;
1508
- gap: 6px;
1509
- pointer-events: auto;
1510
- min-height: 44px;
1511
- padding: 8px 16px;
1512
- border: 1px solid var(--acw-border-color);
1513
- border-radius: 24px;
1514
- background: #fff;
1515
- color: #141414;
1516
- box-shadow: 0 2px 12px #0002;
1517
- font: inherit;
1518
- cursor: pointer;
1519
- }
1520
-
1521
- .acw-remote-toggle:focus-visible {
1522
- outline: 2px solid #0284c7;
1523
- outline-offset: 3px;
1524
- }
1525
-
1526
- @media (prefers-color-scheme: dark) {
1527
- .acw-remote-toggle {
1528
- background: #252a31;
1529
- color: #fafafa;
1530
- }
1531
- }
1532
- </style>
1528
+ `;function q(e){"@babel/helpers - typeof";return q=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},q(e)}function pe(e,t){if(q(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(q(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function me(e){var t=pe(e,`string`);return q(t)==`symbol`?t:t+``}function J(e,t,n){return(t=me(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let he=`air-conditioner-widget`,ge=`acw-digit-font`;function Y(e){return e.replace(/[&<>"']/g,e=>`&#${e.charCodeAt(0)};`)}function _e(e){if(typeof document>`u`||document.getElementById(ge))return;let t=document.createElement(`style`);t.id=ge,t.textContent=`@font-face {
1529
+ font-family: "Digital-7 Mono";
1530
+ src: url("${e.replace(/\/$/,``)}/fonts/digital-7-mono.ttf") format("truetype");
1531
+ font-display: swap;
1532
+ }`,document.head.appendChild(t)}function X(e,t,n){return`<svg${n?` class="${n}"`:``} viewBox="0 0 24 24" width="${t}" height="${t}" aria-hidden="true"><path fill="currentColor" d="${se[e]}" /></svg>`}function Z(e){let t=Array.from({length:e.num}).fill(`<span class="acw-dot" style="width: ${e.size}px; height: ${e.size}px; margin: ${e.my}px ${e.mx}px"></span>`).join(``);return`<div class="acw-dot-row" style="--acw-dot-color: ${e.color}">${t}</div>`}function ve(){let e=K.levels.map(e=>`<div class="acw-energy-level" style="background-color: ${e.background}; width: ${e.width}"></div>`).join(``);return`<div class="acw-energy-label" role="img" aria-label="${ue()}">
1533
+ <div class="acw-energy-header">${K.top.map(e=>Z(e)).join(``)}<span class="acw-energy-qr"></span></div>
1534
+ <div class="acw-energy-grades">
1535
+ <div class="acw-energy-arrow"><div class="acw-arrow-bar"></div><div class="acw-arrow-tip"></div><div class="acw-arrow-bar acw-arrow-bar-sm"></div></div>
1536
+ ${e}
1537
+ </div>
1538
+ <div class="acw-energy-detail">
1539
+ ${K.detail.map((e,t)=>Z(e)+(t===0?`<div class="acw-energy-detail-line"></div>`:``)).join(``)}
1540
+ </div>
1541
+ ${Z(K.footer)}
1542
+ </div>`}let Q;function ye(){if(Q!==void 0)return Q;try{if(typeof CSSStyleSheet==`function`&&`replaceSync`in CSSStyleSheet.prototype){let e=new CSSStyleSheet;return e.replaceSync(`${fe}${de}`),Q=e,e}}catch{}return Q=null,null}function be(e){let t=e.audio?`<audio data-audio="beep" src="${Y(e.audio.beep)}" preload="none"></audio>
1543
+ <audio data-audio="start" src="${Y(e.audio.start)}" preload="none"></audio>
1544
+ <audio data-audio="work" src="${Y(e.audio.work)}" preload="none"></audio>`:``,n=e.logoUrl?`<div class="acw-logo"><a href="${Y(e.logoHref)}" target="_blank" rel="noreferrer noopener"${e.title?` title="${Y(e.title)}"`:``} aria-label="${Y(e.title??`Air Conditioner`)}"><img src="${Y(e.logoUrl)}" alt=""></a></div>`:``;return`
1545
+ ${e.inlineStyle?`<style>${fe}${de}</style>`:``}
1533
1546
  <div class="acw-root">
1534
1547
  ${t}
1535
1548
  <div class="acw-unit">
1536
1549
  <div class="acw-shell">
1537
- ${e.showEnergyLabel?he():``}
1550
+ ${e.showEnergyLabel?ve():``}
1538
1551
  <div class="acw-display" aria-live="polite">
1539
1552
  <div class="acw-display-mode"><span class="acw-mode-icon"></span></div>
1540
1553
  <div class="acw-display-temp">
@@ -1562,30 +1575,30 @@ html.dark .acw-note[data-mode="hot"],
1562
1575
  <div class="acw-lcd" role="img">
1563
1576
  <div class="acw-lcd-main">
1564
1577
  <span class="acw-lcd-mode-slot"></span>
1565
- <span class="acw-lcd-temp acw-digit"></span>
1578
+ <span class="acw-lcd-temp acw-digit"><span class="acw-lcd-temp-value"></span><small>°C</small></span>
1566
1579
  </div>
1567
1580
  <div class="acw-lcd-status" aria-hidden="true">
1568
1581
  <span class="acw-lcd-wind"><i></i><i></i><i></i><b>自动</b></span>
1569
- ${J(`swing`,14,`acw-lcd-swing`)}
1582
+ ${X(`swing`,14,`acw-lcd-swing`)}
1570
1583
  <span class="acw-lcd-sound-slot"></span>
1571
1584
  </div>
1572
1585
  </div>
1573
- <button type="button" class="acw-button acw-button-power" aria-label="power" data-action="toggleStatus">${J(`power`,24)}</button>
1586
+ <button type="button" class="acw-button acw-button-power" aria-label="power" data-action="toggleStatus">${X(`power`,24)}</button>
1574
1587
  <div class="acw-remote-temp">
1575
- <button type="button" class="acw-button acw-button-temp" aria-label="add" title="温度 +(长按连续调)" data-repeat="increment">${J(`plus`,28)}</button>
1576
- <button type="button" class="acw-button acw-button-temp" aria-label="reduce" title="温度 −(长按连续调)" data-repeat="decrement">${J(`minus`,28)}</button>
1588
+ <button type="button" class="acw-button acw-button-temp" aria-label="add" title="温度 +(长按连续调)" data-repeat="increment">${X(`plus`,28)}</button>
1589
+ <button type="button" class="acw-button acw-button-temp" aria-label="reduce" title="温度 −(长按连续调)" data-repeat="decrement">${X(`minus`,28)}</button>
1577
1590
  </div>
1578
1591
  <div class="acw-remote-row">
1579
1592
  <div class="acw-remote-mode" role="group" aria-label="mode">
1580
- <button type="button" class="acw-button acw-button-cold" aria-label="cold" title="${a.cold}" data-action="cold">${J(`cold`,18)}</button>
1581
- <button type="button" class="acw-button acw-button-hot" aria-label="hot" title="${a.hot}" data-action="hot">${J(`hot`,18)}</button>
1593
+ <button type="button" class="acw-button acw-button-cold" aria-label="cold" title="${a.cold}" data-action="cold">${X(`cold`,18)}</button>
1594
+ <button type="button" class="acw-button acw-button-hot" aria-label="hot" title="${a.hot}" data-action="hot">${X(`hot`,18)}</button>
1582
1595
  </div>
1583
- <button type="button" class="acw-button acw-button-fan" aria-label="fan" data-action="cycleFan">${J(`fan`,20)}</button>
1584
- <button type="button" class="acw-button acw-button-swing" aria-label="swing" data-action="toggleSwing">${J(`swing`,20)}</button>
1596
+ <button type="button" class="acw-button acw-button-fan" aria-label="fan" data-action="cycleFan">${X(`fan`,20)}</button>
1597
+ <button type="button" class="acw-button acw-button-swing" aria-label="swing" data-action="toggleSwing">${X(`swing`,20)}</button>
1585
1598
  <button type="button" class="acw-button acw-button-sound" aria-label="sound" data-action="cycleSound"></button>
1586
1599
  </div>
1587
1600
  </div>
1588
1601
  </div>
1589
1602
  </div>
1590
1603
  </div>
1591
- `}function X(e,t,n){let r=e.cloneNode(!1);r.textContent=t,r.setAttribute(...n),e.replaceWith(r)}function _e(t,n,r){let i=n.status?`on`:`off`;for(let e of t.querySelectorAll(`.acw-root, .acw-unit`))e.dataset.mode=n.mode,e.dataset.status=i,e.dataset.swing=n.swing?`on`:`off`,e.dataset.fan=n.fan??`auto`;let a=t.querySelector(`.acw-mode-icon`);r?r.mode!==n.mode&&X(a,e[n.mode],[`data-animate`,``]):a.textContent=e[n.mode];let o=t.querySelector(`.acw-temperature`);r?r.temperature!==n.temperature&&X(o,String(n.temperature),[`data-dir`,n.temperature>r.temperature?`up`:`down`]):o.textContent=String(n.temperature);let s=t.querySelector(`.acw-unit`),c=E(n);s.dataset.drip=c.drip,s.style.setProperty(`--acw-mist`,String(c.mist)),c.dripCycle?s.style.setProperty(`--acw-drip-cycle`,c.dripCycle):s.style.removeProperty(`--acw-drip-cycle`),t.querySelector(`.acw-led`).setAttribute(`aria-label`,i),t.querySelector(`.acw-wind`).setAttribute(`aria-hidden`,n.status?`false`:`true`),ve(t,n,r)}function ve(e,t,n){let r=le(t),i=e.querySelector(`.acw-lcd`);i.setAttribute(`aria-label`,r.display),i.dataset.status=t.status?`on`:`off`,i.dataset.mode=t.mode,i.dataset.swing=t.swing?`on`:`off`,i.dataset.fan=t.fan??`auto`,e.querySelector(`.acw-lcd-temp`).innerHTML=`${t.temperature}<small>°C</small>`;let a=e.querySelector(`.acw-button-power`);if(a.classList.toggle(`acw-button-on`,t.status),a.setAttribute(`aria-pressed`,String(t.status)),a.title=r.power,n?.mode!==t.mode){e.querySelector(`.acw-lcd-mode-slot`).innerHTML=J(t.mode,22,`acw-lcd-mode`);for(let n of[`cold`,`hot`])e.querySelector(`.acw-button-${n}`).setAttribute(`aria-pressed`,String(t.mode===n))}if(n?.fan!==t.fan){let n=e.querySelector(`.acw-button-fan`);n.dataset.fan=t.fan??`auto`,n.title=r.fan}if(n?.swing!==t.swing){let n=e.querySelector(`.acw-button-swing`);n.setAttribute(`aria-pressed`,String(t.swing)),n.title=r.swing}if(n?.sound!==t.sound){let n=e.querySelector(`.acw-button-sound`);n.dataset.sound=t.sound,n.title=r.sound,n.innerHTML=J(H[t.sound],20),e.querySelector(`.acw-lcd-sound-slot`).innerHTML=J(H[t.sound],14,`acw-lcd-sound`),e.querySelector(`.acw-lcd-sound`).setAttribute(`data-sound`,t.sound)}}function ye(e,t,n,r){if(n===`skip`)return;if(n===`shake`&&be(e),n!==`note`){e.querySelector(`.acw-notification-region .acw-sr-only`).textContent=t.message;return}let i=e.querySelector(`.acw-notification-region`);i.querySelector(`.acw-note`)?.remove();let a=document.createElement(`div`);a.className=`acw-note`,a.dataset.severity=t.severity,a.dataset.mode=r.mode,a.innerHTML=`<span class="acw-note-icon" aria-hidden="true">${J(`leaf`,14)}</span><span class="acw-note-text"><strong></strong>${t.detail?`<small></small>`:``}</span>`,a.querySelector(`strong`).textContent=t.message,t.detail&&(a.querySelector(`small`).textContent=t.detail),i.prepend(a),setTimeout(()=>{a.dataset.leaving=``,setTimeout(()=>a.remove(),460)},3600)}function be(e){let t=e.querySelector(`.acw-lcd`);t.removeAttribute(`data-alert`),t.offsetWidth,t.setAttribute(`data-alert`,``),setTimeout(()=>t.removeAttribute(`data-alert`),400)}function Z(e,t){return e===null?t:e!==`false`}function xe(e){if(e===null)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function Se(e){return e===`cold`||e===`hot`?e:void 0}function Ce(e){return p(e)?e:void 0}function we(e){return d(e)?e:void 0}function Q(e,t){let n={...t,mode:Se(e.getAttribute(`mode`))??t?.mode,status:Z(e.getAttribute(`status`),t?.status),temperature:xe(e.getAttribute(`temperature`))??t?.temperature,sound:Ce(e.getAttribute(`sound`))??t?.sound,swing:Z(e.getAttribute(`swing`),t?.swing),fan:we(e.getAttribute(`fan`))??t?.fan};for(let e of Object.keys(n))n[e]===void 0&&delete n[e];return n}function Te(e={}){let t=e.tagName??K,n=customElements.get(t);if(n)return n;class i extends HTMLElement{constructor(...e){super(...e),G(this,`store`,void 0),G(this,`unsubscribe`,void 0),G(this,`renderedState`,void 0),G(this,`stopObservers`,[]),G(this,`audio`,void 0),G(this,`present`,L()),G(this,`placement`,void 0),G(this,`onDrip`,e=>{e.target?.classList.contains(`acw-drip`)&&this.audio?.drip()}),G(this,`onClick`,e=>{if(e.target?.closest(`.acw-remote-toggle`)){let e=this.shadowRoot?.querySelector(`.acw-remote-panel`);e&&this.setRemoteOpen(!!e.hidden);return}let t=(e.target?.closest(`[data-action]`))?.dataset.action;t&&this.store&&(t===`cold`||t===`hot`?this.store.dispatch({type:`mode`,mode:t,powerOn:!0}):t===`toggleStatus`?this.store.dispatch({type:`toggleStatus`}):(t===`cycleSound`||t===`toggleSwing`||t===`cycleFan`)&&this.store.dispatch({type:t}))}),G(this,`onKeyDown`,e=>{let t=e;if(t.key!==`Escape`||this.placement===`inline`)return;let n=this.shadowRoot?.querySelector(`.acw-remote-panel`);n&&!n.hidden&&(t.preventDefault(),t.stopPropagation(),this.setRemoteOpen(!1),this.shadowRoot?.querySelector(`.acw-remote-toggle`)?.focus())})}static get observedAttributes(){return[`mode`,`status`,`temperature`,`sound`,`swing`,`fan`,`placement`]}connectedCallback(){let t=e.assetsBaseUrl??`/assets`,n=e.enableAudio??!0;me(t),this.shadowRoot||(this.attachShadow({mode:`open`}).innerHTML=ge({title:this.getAttribute(`title`)??e.title,logoUrl:e.logoUrl??`/yun-logo.svg`,logoHref:e.logoHref??`https://github.com/YunYouJun/air-conditioner`,showEnergyLabel:e.showEnergyLabel??!0,audio:n?g(`${t}/audio`,e.audioExt??`m4a`):void 0})),this.store=se({...e,storageKey:this.getAttribute(`storage-key`)??e.storageKey,initialState:Q(this,e.initialState),onNotify:(t,n)=>{this.shadowRoot&&ye(this.shadowRoot,t,this.present(t,n.state),n.state),this.dispatchEvent(new CustomEvent(`ac-notify`,{detail:{notification:t,event:n},bubbles:!0,composed:!0})),e.onNotify?.(t,n)}}),this.unsubscribe=this.store.subscribe(e=>{this.render(),this.playAudio(e),this.dispatchEvent(new CustomEvent(`ac-change`,{detail:e,bubbles:!0,composed:!0}))}),this.shadowRoot?.addEventListener(`click`,this.onClick),this.shadowRoot?.addEventListener(`keydown`,this.onKeyDown),this.shadowRoot?.addEventListener(`animationiteration`,this.onDrip),this.updatePlacement(),this.renderedState=void 0,this.render(),this.stopObservers.forEach(e=>e()),this.stopObservers=[];let r=this.shadowRoot?.querySelector(`.acw-unit`);r&&this.stopObservers.push(k(r,D.compact.width,e=>{r.style.setProperty(`--acw-scale`,String(e))}),A(r,(e,t)=>{r.style.setProperty(`--acw-tilt-x`,`${e}deg`),r.style.setProperty(`--acw-tilt-y`,`${t}deg`)}));let i=()=>this.store?.getState().temperature;for(let e of this.shadowRoot?.querySelectorAll(`[data-repeat]`)??[]){let t=e.dataset.repeat===`increment`?`increment`:`decrement`;this.stopObservers.push(j(e,()=>this.store?.dispatch({type:t}),{value:i}))}}disconnectedCallback(){this.unsubscribe?.(),this.audio?.dispose(),this.audio=void 0,this.stopObservers.forEach(e=>e()),this.stopObservers=[],this.shadowRoot?.removeEventListener(`click`,this.onClick),this.shadowRoot?.removeEventListener(`keydown`,this.onKeyDown),this.shadowRoot?.removeEventListener(`animationiteration`,this.onDrip)}attributeChangedCallback(e){e===`placement`?this.updatePlacement():this.store&&this.store.dispatch({type:`update`,payload:Q(this,this.store.getState())})}updatePlacement(){if(!this.shadowRoot)return;let t=this.getAttribute(`placement`)??e.placement,n=t===`top-left`||t===`top-right`?t:`inline`,r=this.placement&&this.placement!==`inline`;this.placement=n,this.dataset.acPlacement=n;let i=this.shadowRoot.querySelector(`.acw-remote-toggle`),a=n===`inline`&&this.shadowRoot.activeElement===i;i.hidden=n===`inline`,(n===`inline`||!r)&&this.setRemoteOpen(n===`inline`),a&&this.shadowRoot.querySelector(`.acw-button-power`)?.focus()}setRemoteOpen(e){let t=this.shadowRoot?.querySelector(`.acw-remote-panel`),n=this.shadowRoot?.querySelector(`.acw-remote-toggle`);if(!t||!n)return;!e&&this.shadowRoot?.activeElement&&t.contains(this.shadowRoot.activeElement)&&n.focus(),t.hidden=!e,n.setAttribute(`aria-expanded`,String(e));let r=n.querySelector(`.acw-toggle-label`);r&&(r.textContent=e?`收起遥控器`:`打开遥控器`)}playAudio(e){let t=this.shadowRoot;t?.querySelector(`audio`)&&(this.audio||(this.audio=x({beep:t.querySelector(`[data-audio="beep"]`),start:t.querySelector(`[data-audio="start"]`),work:t.querySelector(`[data-audio="work"]`)},{soundMode:e.state.sound,fanSpeed:e.state.fan??`auto`})),e.previousState.sound!==e.state.sound&&this.audio.setSoundMode(e.state.sound),e.previousState.fan!==e.state.fan&&this.audio.setFanSpeed(e.state.fan??`auto`),this.audio.beep(),e.previousState.status!==e.state.status&&this.audio.toggleStatusAudio(e.previousState.status))}render(){let e=this.store?.getState()??r;this.shadowRoot&&_e(this.shadowRoot,e,this.renderedState),this.renderedState=e}}return customElements.define(t,i),i}function Ee(e,t={}){let{placement:n,...r}=t,i=t.tagName??K;Te(r);let a=typeof e==`string`?document.querySelector(e):e;if(!a)throw Error(`Unable to find target: ${String(e)}`);if(a.localName===i)return n&&a.setAttribute(`placement`,n),a;let o=document.createElement(i);return t.storageKey&&o.setAttribute(`storage-key`,t.storageKey),t.title&&o.setAttribute(`title`,t.title),n&&o.setAttribute(`placement`,n),a.appendChild(o),o}let $=document.currentScript;if($?.src){let e=new URL(`./assets`,$.src).href,t=$.dataset.placement===`top-left`?`top-left`:`top-right`,n=$.dataset.audio===`true`,r=$.dataset.storageKey||`ac:embed`,i=()=>{document.querySelector(`air-conditioner-embed`)||Ee(document.body,{tagName:`air-conditioner-embed`,placement:t,assetsBaseUrl:e,logoUrl:new URL(`./yun-logo.svg`,$.src).href,enableAudio:n,storageKey:r})};document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,i,{once:!0}):i()}})();
1604
+ `}function xe(e){return{root:e.querySelector(`.acw-root`),unit:e.querySelector(`.acw-unit`),modeIcon:e.querySelector(`.acw-mode-icon`),temperature:e.querySelector(`.acw-temperature`),led:e.querySelector(`.acw-led`),wind:e.querySelector(`.acw-wind`),lcd:e.querySelector(`.acw-lcd`),lcdTempValue:e.querySelector(`.acw-lcd-temp-value`),lcdModeSlot:e.querySelector(`.acw-lcd-mode-slot`),lcdSoundSlot:e.querySelector(`.acw-lcd-sound-slot`),powerButton:e.querySelector(`.acw-button-power`),coldButton:e.querySelector(`.acw-button-cold`),hotButton:e.querySelector(`.acw-button-hot`),fanButton:e.querySelector(`.acw-button-fan`),swingButton:e.querySelector(`.acw-button-swing`),soundButton:e.querySelector(`.acw-button-sound`),remoteToggle:e.querySelector(`.acw-remote-toggle`),remoteToggleLabel:e.querySelector(`.acw-toggle-label`),remotePanel:e.querySelector(`.acw-remote-panel`)}}function Se(e,t,n){let r=e.cloneNode(!1);return r.textContent=t,r.setAttribute(...n),r.addEventListener(`animationend`,()=>r.removeAttribute(n[0]),{once:!0}),e.replaceWith(r),r}function Ce(t,n,r){let i=n.status?`on`:`off`,a=n.fan??`auto`;for(let e of[t.root,t.unit])e.dataset.mode=n.mode,e.dataset.status=i,e.dataset.swing=n.swing?`on`:`off`,e.dataset.fan=a;(!n.status||r&&r.status!==n.status)&&t.unit.removeAttribute(`data-skip-selftest`),r?r.mode!==n.mode&&(t.modeIcon=Se(t.modeIcon,e[n.mode],[`data-animate`,``])):(t.modeIcon.textContent=e[n.mode],t.modeIcon.removeAttribute(`data-animate`)),r?r.temperature!==n.temperature&&(t.temperature=Se(t.temperature,String(n.temperature),[`data-dir`,n.temperature>r.temperature?`up`:`down`])):(t.temperature.textContent=String(n.temperature),t.temperature.removeAttribute(`data-dir`));let o=E(n);t.unit.dataset.drip=o.drip,t.unit.dataset.mist=o.mist>0?`on`:`off`,t.unit.style.setProperty(`--acw-mist`,String(o.mist)),o.dripCycle?t.unit.style.setProperty(`--acw-drip-cycle`,o.dripCycle):t.unit.style.removeProperty(`--acw-drip-cycle`),t.led.setAttribute(`aria-label`,i),t.wind.setAttribute(`aria-hidden`,n.status?`false`:`true`),we(t,n,r)}function we(e,t,n){let r=le(t);e.lcd.setAttribute(`aria-label`,r.display),e.lcd.dataset.status=t.status?`on`:`off`,e.lcd.dataset.mode=t.mode,e.lcd.dataset.swing=t.swing?`on`:`off`,e.lcd.dataset.fan=t.fan??`auto`,e.lcdTempValue.textContent=String(t.temperature),e.powerButton.classList.toggle(`acw-button-on`,t.status),e.powerButton.setAttribute(`aria-pressed`,String(t.status)),e.powerButton.title=r.power,n?.mode!==t.mode&&(e.lcdModeSlot.innerHTML=X(t.mode,22,`acw-lcd-mode`),e.coldButton.setAttribute(`aria-pressed`,String(t.mode===`cold`)),e.hotButton.setAttribute(`aria-pressed`,String(t.mode===`hot`))),n?.fan!==t.fan&&(e.fanButton.dataset.fan=t.fan??`auto`,e.fanButton.title=r.fan),n?.swing!==t.swing&&(e.swingButton.setAttribute(`aria-pressed`,String(t.swing)),e.swingButton.title=r.swing),n?.sound!==t.sound&&(e.soundButton.dataset.sound=t.sound,e.soundButton.title=r.sound,e.soundButton.innerHTML=X(ce[t.sound],20),e.lcdSoundSlot.innerHTML=X(ce[t.sound],14,`acw-lcd-sound`),e.lcdSoundSlot.querySelector(`.acw-lcd-sound`).setAttribute(`data-sound`,t.sound))}function Te(e){let t=e.querySelector(`.acw-notification-region`),n=e.querySelector(`.acw-lcd`),r=t.querySelector(`.acw-sr-only`),i=L(),a=!1,o,s,c;return{present(e,l){if(a)return;let u=i(e,l);if(u===`skip`)return;if(u===`shake`&&(clearTimeout(c),n.removeAttribute(`data-alert`),n.offsetWidth,n.setAttribute(`data-alert`,``),c=setTimeout(()=>{c=void 0,a||n.removeAttribute(`data-alert`)},400)),u!==`note`){r.textContent=e.message;return}clearTimeout(s),o?.remove();let d=document.createElement(`div`);o=d,d.className=`acw-note`,d.dataset.severity=e.severity,d.dataset.mode=l.mode,d.innerHTML=`<span class="acw-note-icon" aria-hidden="true">${X(`leaf`,14)}</span><span class="acw-note-text"><strong></strong>${e.detail?`<small></small>`:``}</span>`,d.querySelector(`strong`).textContent=e.message,e.detail&&(d.querySelector(`small`).textContent=e.detail),t.prepend(d),s=setTimeout(()=>{a||o!==d||(d.dataset.leaving=``,s=setTimeout(()=>{a||o!==d||(d.remove(),o=void 0,s=void 0)},460))},3600)},dispose(){a=!0,clearTimeout(s),clearTimeout(c),s=c=void 0,o?.remove(),o=void 0,n.removeAttribute(`data-alert`),r.textContent=``}}}function Ee(e,t){return e===null?t:e!==`false`}function De(e){if(e===null)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function Oe(e){return e===`cold`||e===`hot`?e:void 0}function ke(e){return p(e)?e:void 0}function Ae(e){return d(e)?e:void 0}function je(e,t){let n={...t,mode:Oe(e.getAttribute(`mode`))??t?.mode,status:Ee(e.getAttribute(`status`),t?.status),temperature:De(e.getAttribute(`temperature`))??t?.temperature,sound:ke(e.getAttribute(`sound`))??t?.sound,swing:Ee(e.getAttribute(`swing`),t?.swing),fan:Ae(e.getAttribute(`fan`))??t?.fan};for(let e of Object.keys(n))n[e]===void 0&&delete n[e];return n}function Me(e={}){let t=e.tagName??he,n=customElements.get(t);if(n)return n;class i extends HTMLElement{constructor(...e){super(...e),J(this,`store`,void 0),J(this,`unsubscribe`,void 0),J(this,`renderedState`,void 0),J(this,`refs`,void 0),J(this,`stopObservers`,[]),J(this,`audio`,void 0),J(this,`audioRunning`,!1),J(this,`notificationView`,void 0),J(this,`notificationOwners`,/* @__PURE__ */ new WeakMap),J(this,`placement`,void 0),J(this,`onDrip`,e=>{e.target?.classList.contains(`acw-drip`)&&this.audio?.drip()}),J(this,`onWarm`,()=>{let e=this.store?.getState();this.ensureAudio(e?.sound,e?.fan??`auto`)?.unlock()}),J(this,`onClick`,e=>{if(e.target?.closest(`.acw-remote-toggle`)){this.refs&&this.setRemoteOpen(!!this.refs.remotePanel.hidden);return}let t=(e.target?.closest(`[data-action]`))?.dataset.action;t&&this.store&&(t===`cold`||t===`hot`?this.store.dispatch({type:`mode`,mode:t,powerOn:!0}):t===`toggleStatus`?this.store.dispatch({type:`toggleStatus`}):(t===`cycleSound`||t===`toggleSwing`||t===`cycleFan`)&&this.store.dispatch({type:t}))}),J(this,`onKeyDown`,e=>{let t=e;if(t.key!==`Escape`||this.placement===`inline`)return;let n=this.refs?.remotePanel;n&&!n.hidden&&(t.preventDefault(),t.stopPropagation(),this.setRemoteOpen(!1),this.refs?.remoteToggle.focus())})}static get observedAttributes(){return[`mode`,`status`,`temperature`,`sound`,`swing`,`fan`,`placement`]}connectedCallback(){this.teardownConnection();let t=e.assetsBaseUrl??`/assets`,n=e.enableAudio??!0;if(_e(t),!this.shadowRoot){let r=this.attachShadow({mode:`open`}),i=ye(),a=!!(i&&`adoptedStyleSheets`in r);r.innerHTML=be({title:this.getAttribute(`title`)??e.title,logoUrl:e.logoUrl??`/yun-logo.svg`,logoHref:e.logoHref??`https://github.com/YunYouJun/air-conditioner`,showEnergyLabel:e.showEnergyLabel??!0,audio:n?g(`${t}/audio`,e.audioExt??`m4a`):void 0,inlineStyle:!a}),a&&i&&(r.adoptedStyleSheets=[i])}this.refs||(this.refs=xe(this.shadowRoot));let r=Te(this.shadowRoot);this.notificationView=r;let i=!!this.store;this.store||(this.store=G({...e,storageKey:this.getAttribute(`storage-key`)??e.storageKey,initialState:je(this,e.initialState),onNotify:(t,n)=>{let r=this.notificationOwners.get(n);this.notificationOwners.delete(n),r?.present(t,n.state),this.dispatchEvent(new CustomEvent(`ac-notify`,{detail:{notification:t,event:n},bubbles:!0,composed:!0})),e.onNotify?.(t,n)}})),this.unsubscribe=this.store.subscribe(e=>{e.notification&&this.notificationOwners.set(e,r),this.render(),this.playAudio(e),this.dispatchEvent(new CustomEvent(`ac-change`,{detail:e,bubbles:!0,composed:!0}))}),this.shadowRoot?.addEventListener(`pointerdown`,this.onWarm,!0),this.shadowRoot?.addEventListener(`keydown`,this.onWarm,!0),this.shadowRoot?.addEventListener(`click`,this.onClick),this.shadowRoot?.addEventListener(`keydown`,this.onKeyDown),this.shadowRoot?.addEventListener(`animationiteration`,this.onDrip);let a=this.store.getState();a.status||(this.audioRunning=!1),i&&a.status&&this.refs.unit.setAttribute(`data-skip-selftest`,``),i&&this.audioRunning&&a.status&&this.ensureAudio(a.sound,a.fan??`auto`)?.resumeFan(),this.updatePlacement(),this.renderedState=void 0,this.render();let o=this.refs.unit;this.stopObservers.push(k(o,D.compact.width,e=>{o.style.setProperty(`--acw-scale`,String(e))}),A(o,(e,t)=>{o.style.setProperty(`--acw-tilt-x`,`${e}deg`),o.style.setProperty(`--acw-tilt-y`,`${t}deg`)}));let s=()=>this.store?.getState().temperature;for(let e of this.shadowRoot?.querySelectorAll(`[data-repeat]`)??[]){let t=e.dataset.repeat===`increment`?`increment`:`decrement`;this.stopObservers.push(j(e,()=>this.store?.dispatch({type:t}),{value:s}))}}disconnectedCallback(){this.teardownConnection()}teardownConnection(){this.notificationView?.dispose(),this.notificationView=void 0,this.unsubscribe?.(),this.unsubscribe=void 0,this.audio?.dispose(),this.audio=void 0,this.stopObservers.forEach(e=>e()),this.stopObservers=[],this.shadowRoot?.removeEventListener(`pointerdown`,this.onWarm,!0),this.shadowRoot?.removeEventListener(`keydown`,this.onWarm,!0),this.shadowRoot?.removeEventListener(`click`,this.onClick),this.shadowRoot?.removeEventListener(`keydown`,this.onKeyDown),this.shadowRoot?.removeEventListener(`animationiteration`,this.onDrip)}attributeChangedCallback(e){e===`placement`?this.updatePlacement():this.store&&this.store.dispatch({type:`update`,payload:je(this,this.store.getState())})}updatePlacement(){if(!this.shadowRoot||!this.refs)return;let t=this.getAttribute(`placement`)??e.placement,n=t===`top-left`||t===`top-right`?t:`inline`,r=this.placement&&this.placement!==`inline`;this.placement=n,this.dataset.acPlacement=n;let i=this.refs.remoteToggle,a=n===`inline`&&this.shadowRoot.activeElement===i;i.hidden=n===`inline`,(n===`inline`||!r)&&this.setRemoteOpen(n===`inline`),a&&this.refs.powerButton.focus()}setRemoteOpen(e){if(!this.refs)return;let{remotePanel:t,remoteToggle:n,remoteToggleLabel:r}=this.refs;!e&&this.shadowRoot?.activeElement&&t.contains(this.shadowRoot.activeElement)&&n.focus(),t.hidden=!e,n.setAttribute(`aria-expanded`,String(e)),r&&(r.textContent=e?`收起遥控器`:`打开遥控器`)}ensureAudio(e,t){let n=this.shadowRoot;if(n?.querySelector(`audio`))return this.audio||(this.audio=x({beep:n.querySelector(`[data-audio="beep"]`),start:n.querySelector(`[data-audio="start"]`),work:n.querySelector(`[data-audio="work"]`)},{soundMode:e,fanSpeed:t})),this.audio}playAudio(e){let t=this.ensureAudio(e.state.sound,e.state.fan??`auto`);t&&(e.previousState.sound!==e.state.sound&&t.setSoundMode(e.state.sound),e.previousState.fan!==e.state.fan&&t.setFanSpeed(e.state.fan??`auto`),t.beep(),e.previousState.status!==e.state.status&&(this.audioRunning=e.state.status,t.toggleStatusAudio(e.previousState.status)))}render(){let e=this.store?.getState()??r;this.refs&&Ce(this.refs,e,this.renderedState),this.renderedState=e}}return customElements.define(t,i),i}function Ne(e,t={}){let{placement:n,...r}=t,i=t.tagName??he;Me(r);let a=typeof e==`string`?document.querySelector(e):e;if(!a)throw Error(`Unable to find target: ${String(e)}`);if(a.localName===i)return n&&a.setAttribute(`placement`,n),a;let o=document.createElement(i);return t.storageKey&&o.setAttribute(`storage-key`,t.storageKey),t.title&&o.setAttribute(`title`,t.title),n&&o.setAttribute(`placement`,n),a.appendChild(o),o}let $=document.currentScript;if($?.src){let e=new URL(`./assets`,$.src).href,t=$.dataset.placement===`top-left`?`top-left`:`top-right`,n=$.dataset.audio===`true`,r=$.dataset.storageKey||`ac:embed`,i=()=>{document.querySelector(`air-conditioner-embed`)||Ne(document.body,{tagName:`air-conditioner-embed`,placement:t,assetsBaseUrl:e,logoUrl:new URL(`./yun-logo.svg`,$.src).href,enableAudio:n,storageKey:r})};document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,i,{once:!0}):i()}})();
@@ -11,13 +11,13 @@
11
11
  button { font: inherit; padding: 0.4rem 1rem; cursor: pointer; }
12
12
  a { color: light-dark(#056885, #76d6ed); }
13
13
  </style>
14
- <script defer src="https://cdn.jsdelivr.net/npm/@yunlefun-home/air-conditioner-widget@0.4.3/dist/embed/embed.js" data-placement="top-right"></script>
14
+ <script defer src="https://cdn.jsdelivr.net/npm/@yunlefun-home/air-conditioner-widget@0.4.4/dist/embed/embed.js" data-placement="top-right"></script>
15
15
  </head>
16
16
  <body>
17
17
  <h1>给网页装一台小空调</h1>
18
18
  <p>右上角是机身,右下角可以打开遥控器。试试开机、调温,再收起遥控器:空调会继续运行。</p>
19
19
  <h2>推荐:安装 npm 包</h2>
20
- <pre><code>npm install @yunlefun-home/air-conditioner-widget@0.4.3</code></pre>
20
+ <pre><code>npm install @yunlefun-home/air-conditioner-widget@0.4.4</code></pre>
21
21
  <pre><code>import { cdnAssets, mountAirConditioner } from '@yunlefun-home/air-conditioner-widget'
22
22
 
23
23
  // 在客户端、DOM 就绪后挂载;页面组件卸载时调用 widget.remove()。
@@ -35,7 +35,7 @@ const widget = mountAirConditioner(document.body, {
35
35
  <p>改成 <code>data-placement="top-left"</code> 可安装在左侧。键盘用 Tab、Enter / 空格操作,Esc 收起遥控器。手机可直接点按。</p>
36
36
  <p>自托管时将整个 <code>widget</code> 目录一起部署;跨站加载需允许字体和音频的跨域访问。<a href="https://github.com/YunYouJun/air-conditioner/blob/main/docs/guide/floating-widget.md">完整安装说明</a></p>
37
37
  <script>
38
- const code = '<script defer src="https://cdn.jsdelivr.net/npm/@yunlefun-home/air-conditioner-widget@0.4.3/dist/embed/embed.js" data-placement="top-right"><' + '/script>'
38
+ const code = '<script defer src="https://cdn.jsdelivr.net/npm/@yunlefun-home/air-conditioner-widget@0.4.4/dist/embed/embed.js" data-placement="top-right"><' + '/script>'
39
39
  document.getElementById('install').textContent = code
40
40
  document.getElementById('copy').addEventListener('click', async () => {
41
41
  try {