@nent/core
Version:
4 lines • 1.3 kB
JavaScript
/*!
* NENT 2022
*/
import{r as s,h as t,H as i}from"./index-916ca544.js";import{e as a}from"./index-f7016b94.js";import{g as o}from"./factory-acbf0d3d.js";import{c as e}from"./index-4bfabbbd.js";import{b as r}from"./interfaces-32699e3c.js";import"./interfaces-8c5cd1b8.js";import"./values-ddfac998.js";import"./promises-584c4ece.js";import"./logging-5a93c8af.js";const c=e({autoplay:!0}),{state:n,onChange:h}=c,l=class{constructor(t){s(this,t),this.enabledKey="autoplay",this.storage=null,this.autoPlay=!0,this.dataProvider="storage"}async componentWillLoad(){if(this.autoPlay=n.autoplay,this.storage=await o(this.dataProvider),this.storage){const s=await this.storage.get(this.enabledKey);n.autoplay="false"!==s}this.videoSubscription=h("autoplay",(async s=>{var t;this.autoPlay=s,await(null===(t=this.storage)||void 0===t?void 0:t.set(this.enabledKey,s.toString())),null==a||a.emit(r.AutoPlayChanged,s)}))}toggleAutoPlay(){var s;n.autoplay=(null===(s=this.checkbox)||void 0===s?void 0:s.checked)||!1}disconnectedCallback(){var s;null===(s=this.videoSubscription)||void 0===s||s.call(this)}render(){return t(i,null,t("input",{type:"checkbox",class:this.inputClass,id:this.inputId,ref:s=>{this.checkbox=s},onChange:()=>this.toggleAutoPlay(),checked:this.autoPlay}))}};export{l as n_video_switch}