"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),z=require("@ant-design/icons-vue"),v=require("@aplus-frontend/antdv"),c=require("lodash-unified"),T=require("../../ap-action/index.js");require("../../config-provider/index.js");const $=require("./style/index.js"),q=require("../../config-provider/hooks/use-locale.js"),A=require("../../config-provider/hooks/use-namespace.js"),V=["onClick"],D=e.defineComponent({__name:"ApExpandAlert",props:{type:{default:"warning"},data:{default:()=>[]},prefix:{default:""},tipTitle:{default:""},mapLabel:{},separator:{default:"|"},separatorStyle:{default:()=>({})},contentStyle:{default:()=>({})},prefixStyle:{default:()=>({})},rows:{default:2},defaultExpand:{type:Boolean,default:!0},showIcon:{type:Boolean,default:!0},closable:{type:Boolean},afterClose:{}},emits:["choose","expand","close"],setup(t,{expose:C,emit:g}){const u=g,s=t,{t:y}=q.useLocale(),B=e.computed(()=>{if(s.type!="card")return s.type}),a=e.ref(""),i=e.ref(null),S=e.computed(()=>({fontWeight:"400",wordBreak:"break-all",overflow:"hidden",display:"-webkit-box",webkitLineClamp:a.value,webkitBoxOrient:"vertical",lineHeight:"18px"}));function w(){a.value==="1"?(a.value="",u("expand","expand")):(a.value="1",u("expand","collapse"))}const b=e.computed(()=>a.value==="1"?y("ap.apExpandAlert.expand"):y("ap.apExpandAlert.collapse")),d=e.ref(!0),x=e.computed(()=>a.value!=="1");function f(l){l?a.value="":a.value="1"}const k=e.ref(!1);function E(l){u("close",l),k.value=!0}e.watch(()=>s.data,()=>{a.value="",e.nextTick(()=>{if(i.value){const l=Number(i.value.clientHeight),r=Number(parseInt(i.value.style.lineHeight,10));l<r*Number(s.rows)&&x.value?d.value=!1:d.value=!0}})},{immediate:!0}),e.watch(()=>s.defaultExpand,l=>{l?e.nextTick(()=>{f(l)}):e.nextTick(()=>{f(l)})},{immediate:!0}),e.onMounted(()=>{e.watch(()=>s.contentStyle,l=>{c.isNil(l.lineHeight)||e.nextTick(()=>{const r=document.querySelector(`#${m} .ant-alert-action`),o=document.querySelector(`#${m} .ant-alert-icon`);r&&r.setAttribute("style",`line-height: ${l.lineHeight}`),o&&o.setAttribute("style",`line-height: ${l.lineHeight}`)})},{deep:!0,immediate:!0,flush:"post"})});const{b:h,e:n}=A.useNamespace("ap-expand-alert"),N=$.default("ap-expand-alert"),m=`${h()}-key-${Date.now()}-${(Math.random()*1e6).toFixed(0)}`;return C({setExpand:f}),(l,r)=>k.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,id:m,class:e.normalizeClass([e.unref(h)(),e.unref(N)])},[e.createVNode(e.unref(v.Alert),{type:B.value,"show-icon":t.showIcon,closable:t.closable,class:e.normalizeClass([e.unref(n)("antAlert"),t.type=="card"?"card-alert":""]),"after-close":t.afterClose,onClose:E},{action:e.withCtx(()=>[d.value?(e.openBlock(),e.createBlock(e.unref(T.ApActionItem),{key:0,size:"small",style:{"font-size":"12px","padding-left":"16px"},onClick:r[0]||(r[0]=o=>w())},{default:e.withCtx(()=>[e.createElementVNode("span",{class:e.normalizeClass(e.unref(n)("expandText"))},e.toDisplayString(b.value),3),e.createVNode(e.unref(z.DownOutlined),{class:e.normalizeClass(x.value?e.unref(n)("expandIcon"):e.unref(n)("collapseIcon"))},null,8,["class"])]),_:1})):e.createCommentVNode("",!0)]),message:e.withCtx(()=>[e.createElementVNode("div",{ref_key:"ellipsisBoxRef",ref:i,style:e.normalizeStyle({...S.value,...t.contentStyle}),class:e.normalizeClass(e.unref(n)("alertContent"))},[e.renderSlot(l.$slots,"default",{},()=>[e.unref(c.isString)(t.prefix)?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(e.unref(n)("prefix")),style:e.normalizeStyle(t.prefixStyle)},e.toDisplayString(t.prefix),7)):(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.prefix),{key:1,style:e.normalizeStyle(t.prefixStyle)},null,8,["style"])),e.unref(c.isString)(t.data)?(e.openBlock(),e.createElementBlock("span",{key:2,class:e.normalizeClass(e.unref(n)("text"))},e.toDisplayString(t.data),3)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:3},e.renderList(t.data,(o,p)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:p},[e.createVNode(e.unref(v.Tooltip),{title:t.tipTitle?t.tipTitle:null},{default:e.withCtx(()=>[e.renderSlot(l.$slots,"item",{record:o,index:p},()=>[e.createElementVNode("span",{class:e.normalizeClass(e.unref(n)("showItem")),onClick:I=>l.$emit("choose",o)},e.toDisplayString(t.mapLabel?o[t.mapLabel]:o),11,V)])]),_:2},1032,["title"]),p!==t.data.length-1?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(e.unref(n)("spliter")),style:e.normalizeStyle(t.separatorStyle)},[e.unref(c.isString)(t.separator)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(t.separator),1)],64)):(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.separator),{key:1}))],6)):e.createCommentVNode("",!0)],64))),128))])],6)]),_:3},8,["type","show-icon","closable","class","after-close"])],2))}});exports.default=D;
