"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),S=require("@aplus-frontend/antdv"),V=require("lodash-unified");require("../render/index.js");require("../config-provider/index.js");require("../hooks/index.js");const q=require("./checked.svg.js"),N=require("./context.js"),P=require("./style/index.js"),_=require("../config-provider/hooks/use-namespace.js"),w=require("../hooks/useControllableValue.js"),m=require("../render/render.js"),E=["src"],T=e.defineComponent({name:"CheckCard",__name:"index",props:{bordered:{type:Boolean,default:!0},disabled:{type:Boolean},loading:{type:Boolean},size:{},stopPropagation:{type:[Boolean,Function],default:!1},indicatorSize:{default:void 0},style:{default:void 0},checked:{type:Boolean,default:void 0},"onUpdate:checked":{},defaultChecked:{type:Boolean},value:{type:[String,Number,Boolean]},title:{},content:{}},emits:["update:checked"],setup(v,{emit:k}){const l=v,{b:g,m:u,e:c,em:d}=_.useNamespace("check-card"),h=P.default("check-card"),b=k,r=N.useInjectCheckCard(),{value:o,updateValue:i}=w.useControllableValue(l,b,{valuePropName:"checked",defaultValuePropName:"defaultChecked"}),a=e.computed(()=>{const t={...l},n=e.unref(r)||{};return n&&(t.disabled=t.disabled??n.disabled,t.bordered=t.bordered??n.bordered,t.loading=t.loading??n.loading,t.size=t.size??n.size??"middle",t.indicatorSize=t.indicatorSize??n.indicatorSize,t.stopPropagation=t.stopPropagation??n.stopPropagation,t.style=t.style?t.style:n.style),t}),y=e.computed(()=>{const t=e.unref(a);return[g(),u(t.size),e.unref(o)?u("checked"):null,t.bordered?u("bordered"):null,t.disabled?u("disabled"):null,h.value]}),C=e.computed(()=>{const t=e.unref(a);return{...t.style||{},"--check-card-indicator-size":`${t.indicatorSize||14}px`}});function s(t,n){return t==null?null:V.isFunction(t)?t(n):e.createVNode(e.Fragment,null,[t])}const f=e.computed(()=>s(l.title,e.unref(o))),p=e.computed(()=>s(l.content,e.unref(o)));function B(t){const n=e.unref(a).stopPropagation;return n?n===!0?t.target!==t.currentTarget:n(t):!1}function z(t){B(t)||a.value.loading||a.value.disabled||(r.value?r.value?.toggleOption?.(l.value):i(!e.unref(o)))}return e.watch(()=>r.value,t=>{if(!t)return;const n=t.multiple?(t.value||[]).includes(l.value):t.value===l.value;i(n)},{immediate:!0}),e.watchEffect(t=>{r.value?.registerValue?.(l.value),t(()=>r.value?.cancelValue?.(l.value))}),(t,n)=>(e.openBlock(),e.createElementBlock("div",{style:e.normalizeStyle(C.value),class:e.normalizeClass(y.value),onClick:e.withModifiers(z,["stop"])},[a.value.loading?(e.openBlock(),e.createBlock(e.unref(S.Skeleton),{key:0,active:""})):e.renderSlot(t.$slots,"default",{key:1,checked:e.unref(o)},()=>[f.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass([e.unref(c)("title"),a.value.disabled?e.unref(d)("title","disabled"):null])},[e.createVNode(e.unref(m.default),{node:f.value},null,8,["node"])],2)):e.createCommentVNode("",!0),p.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass([e.unref(c)("content"),a.value.disabled?e.unref(d)("content","disabled"):null])},[e.createVNode(e.unref(m.default),{node:p.value},null,8,["node"])],2)):e.createCommentVNode("",!0)]),e.unref(o)?(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(e.unref(c)("checked-icon"))},[e.createElementVNode("img",{src:e.unref(q.default),alt:""},null,8,E)],2)):e.createCommentVNode("",!0)],6))}});exports.default=T;
