import{h}from"@stencil/core";import{TranslationService}from"../../services/translation.service";import{SubscriptionList}from"../../../../api/src/models/common";import{OntoTooltipPlacement}from"../onto-tooltip/models/onto-tooltip-placement";export class OntoToggleSwitch{constructor(){this.subscriptions=new SubscriptionList,this.checked=!1,this.toggle=()=>{this.checked=!this.checked,this.toggleChanged.emit({checked:this.checked,context:this.context})}}subscribeToLanguageChange(){this.tooltipTranslationKey&&this.subscriptions.add(TranslationService.onTranslate(this.tooltipTranslationKey,[],e=>{this.tooltipLabel=e}))}disconnectedCallback(){this.subscriptions.unsubscribeAll()}connectedCallback(){this.subscribeToLanguageChange()}render(){return h("section",{key:"61c2a8a60204ade2a5a9f27cb148f36ac9e848ea"},this.labelKey&&h("label",{key:"02b65da1ac5d2a2731f668839bfde2723381e2be"},h("strong",{key:"f78b74c01809cede4636ffcbbda94c90b5f9d536"},h("translate-label",{key:"d0514892cd0a6541bf028a10b75688f80537fa60",labelKey:this.labelKey})," ")),h("button",{key:"0f3c90d447522a2d3e28a64a79e765aa29e97065",class:"toggle-switch",onClick:this.toggle,"tooltip-append-to":"parent","tooltip-content":this.tooltipLabel,"tooltip-placement":OntoTooltipPlacement.TOP},h("input",{key:"848656fef2448e6b835872028239f9c7e4a6cdc3",type:"checkbox",checked:this.checked}),h("label",{key:"c303d435897989242412b9fde6aa1e94ed86ddad"})))}static get is(){return"onto-toggle-switch"}static get originalStyleUrls(){return{$:["onto-toggle-switch.scss"]}}static get styleUrls(){return{$:["onto-toggle-switch.css"]}}static get properties(){return{checked:{type:"boolean",attribute:"checked",mutable:!0,complexType:{original:"boolean",resolved:"boolean",references:{}},required:!1,optional:!1,docs:{tags:[],text:"Determines whether the toggle switch is checked or not."},getter:!1,setter:!1,reflect:!1,defaultValue:"false"},labelKey:{type:"string",attribute:"label-key",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!0,docs:{tags:[],text:"The key used for translating the label text, if supplied."},getter:!1,setter:!1,reflect:!1},tooltipTranslationKey:{type:"string",attribute:"tooltip-translation-key",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!0,docs:{tags:[],text:"The translation label key for the tooltip message, if supplied."},getter:!1,setter:!1,reflect:!1},context:{type:"string",attribute:"context",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!0,docs:{tags:[],text:"The context for the tooltip, if supplied. This is useful if you have multiple toggle switches, to know which one\nis being toggled."},getter:!1,setter:!1,reflect:!1}}}static get states(){return{tooltipLabel:{}}}static get events(){return[{method:"toggleChanged",name:"toggleChanged",bubbles:!0,cancelable:!0,composed:!0,docs:{tags:[],text:"Event emitted when the toggle switch is clicked, carrying the new checked status."},complexType:{original:"ToggleEventPayload",resolved:"ToggleEventPayload",references:{ToggleEventPayload:{location:"import",path:"../../models/toggle-switch/toggle-event-payload",id:"src/models/toggle-switch/toggle-event-payload.ts::ToggleEventPayload"}}}}]}}