/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./JsEllipsis.css');const e=require("vue"),t=require("@gsc-basic/utils"),i=require("@gsc-basic/hooks"),n=require("../utils/utils.js");;/* empty css                 */const l=require("../../../_virtual/_plugin-vue_export-helper.js"),s=require("../../../node_modules/lodash-es/isString.js"),r=require("../../../node_modules/lodash-es/isRegExp.js"),o="l--ellipsis-js",a={__name:"JsEllipsis",props:{text:{type:String,required:!0},visibleLine:{type:Number,default:1},visibleHeight:{type:Number},maxLine:{type:Number},maxHeight:{type:Number},ellipsis:{type:Boolean},endExcludes:{type:Array,default:()=>[]},useInnerHtml:{type:Boolean},reflowOnResize:{type:Boolean},onReflow:{type:Function},onEllipsisClick:{type:Function}},setup(l){const a=l,u=e.ref(),c=e.ref(),d=e.ref(),p=e.ref(),v=e.ref();function f(e,t){a?.onReflow?.(e,t)}function h(){a?.onEllipsisClick?.()}function g(){if(!u.value||!c.value||!d.value||p.value)return;if(d.value.style.display="none",a.useInnerHtml?c.value.innerHTML=a.text:c.value.innerText=a.text,!a.ellipsis)return;const e=n.getLineHeight(u.value),t=n.registerWordBreak(c.value),i=void 0===a.visibleHeight?e*a.visibleLine:a.visibleHeight,l=void 0===a.maxHeight?void 0===a.maxLine?i:e*a.maxLine:a.maxHeight;if(n.getElementHeight(u.value)<=Math.max(l,i))return f(!1,a.text),void(s.default(t)&&n.setWordBreak(c.value,t));p.value=!0,d.value.style.display="inline",a.useInnerHtml?(n.wrapTextChildNodesWithSpan(c.value),x(u.value,c.value,i)):m(u.value,c.value,i),s.default(t)&&n.setWordBreak(c.value,t),p.value=!1}function m(e,t,i){const l=t.textContent||"";let s="";n.binarySearch(0,l.length,(r,o,a)=>{const u=l.slice(r,a);t.innerText=s+u;const c=n.getElementHeight(e)>i;return c||(s+=u),c},(e,t,i)=>e===i),s=function(e){for(;e.length&&H(e[e.length-1]);)e=e.slice(0,-1);return e}(s),t.innerText=s,f(!0,s)}function x(e,t,i){const l=t.childNodes;if(1===l.length){const s=l[0];if(s.nodeType===Node.TEXT_NODE)m(e,t,i);else{const l=s.innerHTML;s.innerHTML="";if(n.getElementHeight(e)>i)return t.removeChild(s),void f(!0,t.innerHTML);s.innerHTML=l,x(e,s,i)}}else{const s=[].slice.call(l),r=[];let o=0;n.binarySearch(0,s.length,(l,o,a)=>{t.innerHTML="";const u=s.slice(l,a);r.forEach(e=>{t.appendChild(e)}),u.forEach(e=>{t.appendChild(e)});const c=n.getElementHeight(e)>i;return c||u.forEach(e=>{r.push(e)}),c},(l,r,a)=>{if(l===a){const l=n.getElementHeight(e);return o=a,l>i||t.appendChild(s[o]),!0}return!1}),t.childNodes[o]&&x(e,t.childNodes[o],i)}}function H(e){for(const t of a.endExcludes)if(r.default(t)){if(t.test(e))return!0}else if(t===e)return!0;return!1}e.watch(()=>a.text,g),e.watch(()=>a.ellipsis,g),e.watch(()=>a.useInnerHtml,g),e.watch(()=>a.maxLine,g),e.watch(()=>a.visibleLine,g),e.watch(()=>a.maxHeight,g),e.watch(()=>a.visibleHeight,g),e.watch(()=>a.endExcludes,g);const[y,b]=i.useWindowSizeFn(g);return e.onMounted(()=>{g(),u.value&&a.reflowOnResize&&(t.isSupportResizeObserver?(v.value=new ResizeObserver(g),v.value.observe(u.value)):y())}),e.onUnmounted(()=>{t.isSupportResizeObserver&&v.value?v.value?.disconnect?.():b()}),(t,i)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"aref",ref:u,class:e.normalizeClass([o])},[e.createElementVNode("span",{ref_key:"textRef",ref:c,class:e.normalizeClass([`${o}-content`])},null,2),e.createElementVNode("span",{ref_key:"ellipsisRef",ref:d,class:e.normalizeClass([`${o}-ellipsis`]),onClick:h},[e.renderSlot(t.$slots,"ellipsisNode",{},void 0,!0)],2)],2))}},u=l.default(a,[["__scopeId","data-v-6d208c0a"]]);exports.default=u;