"use strict";const e=require("vue"),d=require("../Shared/base-iCmnU-fv.js"),I=require("../Shared/Index.vue_vue_type_script_setup_true_lang-CIdipm_Z.js"),A=require("../Shared/Index.vue_vue_type_script_setup_true_lang-C1ANWb2_.js"),W={class:"card-legend-demo"},$={class:"card-legend-code"},z=e.defineComponent({name:"ClCardLegend",__name:"Index",props:{title:{},className:{}},setup(m){const f=m,h=e.useSlots(),v=e.ref(null),s=e.ref(!1),l=e.ref(!1),i=e.ref("auto"),w=e.computed(()=>typeof h.remark<"u"),C=e.computed(()=>typeof h.code<"u"),E=e.computed(()=>{const t=["card-legend"];return d.CommonBase.isEmpty(f.className)||f.className?.split(" ").forEach(o=>{d.CommonBase.isEmpty(o)||t.push(o)}),t.join(" ")}),y=e.computed(()=>({"card-legend-footer":!0,"card-footer-fixed":l.value})),x=e.computed(()=>({"icon-rotate":!0,"rotate-180":s.value}));let r,c,n;const p=()=>{r&&(clearTimeout(r),r=null),c&&(clearTimeout(c),c=null)},a=()=>{if(s.value){const t=v.value;if(!d.CommonBase.isUndefined(t)){const o=window.pageYOffset||document.documentElement.scrollTop,L=window.innerHeight,_=o+L,V=t.clientHeight,g=t.getBoundingClientRect(),T=t.closest(".card-legend"),q=T.clientWidth,H=T.querySelector(".card-footer").children[0].clientHeight;g.top+H+10<_&&g.top+V>_?(l.value=!0,i.value=q.toString()+"px"):(l.value=!1,i.value="auto")}}else l.value=!1,i.value="auto"},u=()=>{n&&(clearTimeout(n),n=null),n=setTimeout(()=>{a()},200)};e.watch(()=>s.value,(t,o)=>{t!==o&&(p(),t?window.addEventListener("scroll",u):window.removeEventListener("scroll",u))});const S=()=>{s.value=!s.value},k=t=>{t.style.height="auto";const o=window.getComputedStyle(t,null).height;t.style.height="0",r=setTimeout(function(){t.style.height=o},25)},N=t=>{c=setTimeout(function(){t.style.height="0"},25)},F=()=>{e.nextTick(()=>{a()})},B=()=>{e.nextTick(()=>{a()})};return e.onMounted(()=>{}),e.onUnmounted(()=>{window.removeEventListener("scroll",u),p(),n&&(clearTimeout(n),n=null)}),(t,o)=>(e.openBlock(),e.createBlock(I._sfc_main,{theme:"loopline",className:E.value},{headTitle:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(m.title),1)]),headExplain:e.withCtx(()=>[w.value?e.renderSlot(t.$slots,"remark",{key:0}):e.createCommentVNode("",!0)]),default:e.withCtx(()=>[e.createElementVNode("div",W,[e.renderSlot(t.$slots,"demo")]),e.createVNode(e.Transition,{name:"slide-fade",onEnter:k,onAfterEnter:F,onLeave:N,onAfterLeave:B},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{ref_key:"refElCode",ref:v},[e.createElementVNode("div",$,[e.renderSlot(t.$slots,"code")])],512),[[e.vShow,s.value]])]),_:3})]),foot:e.withCtx(()=>[C.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(y.value),onClick:S,style:e.normalizeStyle({width:i.value})},[e.createVNode(A._sfc_main,{name:"caret-down",class:e.normalizeClass(x.value)},null,8,["class"])],6)):e.createCommentVNode("",!0)]),_:3},8,["className"]))}});module.exports=z;
//# sourceMappingURL=ClCardLegend.cjs.map
