import{a as v}from"./chunk.SAEYIL5V.js";import{a as b}from"./chunk.ERP45OHF.js";import{b as u}from"./chunk.LZRL7OLU.js";import{a as m}from"./chunk.LHSR56PH.js";import{a as p}from"./chunk.CGQ2BPPZ.js";import{a as i}from"./chunk.UFTAQNZB.js";import{a}from"./chunk.NYKJXI3Q.js";import{a as c,b as o,c as h,d as s,h as n}from"./chunk.XJAJO727.js";import{b as d,e as l}from"./chunk.OBAEIKIV.js";import{e as t}from"./chunk.6EV4YU6C.js";var e=class extends n{constructor(){super(...arguments);this.hasSlotController=new p(this,"tooltip");this.formControlController=new u(this,{value:r=>r.checked?r.value||"on":void 0,defaultValue:r=>r.defaultChecked,setValue:(r,f)=>r.checked=f});this.showInvalidStyle=!1;this.title="";this.name="";this.disabled=!1;this.checked=!1;this.defaultChecked=!1;this.form="";this.required=!1}get validity(){return this.input.validity}firstUpdated(){this.formControlController.updateValidity()}handleClick(){this.checked=!this.checked,this.emit("sd-change")}handleBlur(){this.emit("sd-blur")}handleInput(){this.emit("sd-input")}handleInvalid(r){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(r),this.invalidMessage.textContent=r.target.validationMessage}handleFocus(){this.emit("sd-focus")}handleDisabledChange(){this.setAttribute("aria-disabled",this.disabled?"true":"false"),this.formControlController.setValidity(this.disabled)}handleStateChange(){this.input.checked=this.checked,this.formControlController.updateValidity()}click(){this.input.click()}focus(r){this.input.focus(r)}blur(){this.input.blur()}checkValidity(){return this.input.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.input.reportValidity()}setCustomValidity(r){this.input.setCustomValidity(r),this.formControlController.updateValidity()}render(){return l`<div class="flex flex-row items-center gap-2"><label part="base" class="${i("group flex items-center text-base leading-normal text-black cursor-pointer",this.disabled&&"hover:cursor-not-allowed")}"><input id="input" class="peer absolute opacity-0 p-0 m-0 pointer-events-none" type="checkbox" role="switch" title="${this.title}" name="${this.name}" value="${m(this.value)}" .checked="${v(this.checked)}" .disabled="${this.disabled}" .required="${this.required}" aria-checked="${this.checked?"true":"false"}" aria-invalid="${this.showInvalidStyle}" aria-describedby="invalid-message" @click="${this.handleClick}" @input="${this.handleInput}" @invalid="${this.handleInvalid}" @blur="${this.handleBlur}" @focus="${this.handleFocus}"> <span id="control" part="control ${this.checked?" control--checked":"control--unchecked"}" class="${i(`relative flex flex-initial items-center justify-center sd-6-22-0-switch-border-width rounded-full h-4 w-8 transition-colors ease duration-100
            peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2
            peer-focus-visible:outline-primary outline-transparent transition-colors ease-in-out duration-medium hover:duration-fast`,this.disabled&&this.checked?"bg-neutral-500":this.disabled?"border-neutral-500":this.showInvalidStyle?this.checked?"border-error bg-error hover:bg-error-400 hover:border-error-400 group-hover:border-error-400 group-hover:bg-error-400":"border-error bg-white hover:border-error-400 hover:bg-white group-hover:border-error-400 group-hover:bg-white":this.checked?"border-accent hover:sd-6-22-0-switch--checked--hover-color-background bg-accent hover:border-accent-550 group-hover:border-accent-550 group-hover:sd-6-22-0-switch--checked--hover-color-background":"sd-6-22-0-switch--unchecked-color-border bg-white hover:sd-6-22-0-switch--unchecked--hover-color-background group-hover:sd-6-22-0-switch--unchecked--hover-color-background")}"><span id="thumb" part="thumb" class="${i("w-2.5 h-2.5 rounded-full transition[transform,colors] ease-in-out duration-medium",this.disabled&&this.checked?"translate-x-2":this.disabled?"-translate-x-2":this.showInvalidStyle?this.checked?"translate-x-2":"bg-error -translate-x-2 hover:bg-error-400 hover:border-error-400 group-hover:border-error-400 group-hover:bg-error-400":this.checked?"translate-x-2":"-translate-x-2 sd-6-22-0-switch--unchecked__icon-color-background")}"></span> </span><span part="label" id="label" class="${i("select-none inline-block ml-2",this.disabled?"text-neutral-500":"sd-6-22-0-switch-color-text")}"><slot></slot></span></label> ${this.hasSlotController.test("tooltip")?l`<slot name="tooltip"></slot>`:null}</div><div part="invalid-icon-message" class="flex items-center gap-2 mt-2">${this.showInvalidStyle?l`<sd-6-22-0-icon part="invalid-icon" class="${i("text-error")}" library="_internal" name="risk"></sd-6-22-0-icon>`:""} ${this.formControlController.renderInvalidMessage("lg")}</div>`}};e.styles=[...n.styles,d`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */@layer theme,base,components,utilities;
:host{display:block;width:-moz-max-content;width:max-content}:host(:focus-visible){--tw-outline-style:none;outline-style:none}:host([required]) #label::after{content:' *'}:host([disabled][checked]) #control{border-color:rgba(var(--sd-color-background-neutral-500,rgba(var(--sd-color-neutral-500))))}:host([checked]) [part=thumb]{background-color:rgba(var(--sd-color-icon-fill-white,rgba(var(--sd-color-white))))}:host([disabled]:not([checked])) [part=thumb]{background-color:rgba(var(--sd-color-icon-fill-neutral-500,rgba(var(--sd-color-neutral-500))))}`],t([s("input")],e.prototype,"input",2),t([s("#invalid-message")],e.prototype,"invalidMessage",2),t([h()],e.prototype,"showInvalidStyle",2),t([o({type:String,reflect:!0})],e.prototype,"title",2),t([o({type:String,reflect:!0})],e.prototype,"name",2),t([o()],e.prototype,"value",2),t([o({type:Boolean,reflect:!0})],e.prototype,"disabled",2),t([o({type:Boolean,reflect:!0})],e.prototype,"checked",2),t([b("checked")],e.prototype,"defaultChecked",2),t([o({reflect:!0})],e.prototype,"form",2),t([o({type:Boolean,reflect:!0})],e.prototype,"required",2),t([a("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),t([a(["checked"],{waitUntilFirstUpdate:!0})],e.prototype,"handleStateChange",1),e=t([c("sd-6-22-0-switch")],e);export{e as a};
