import"./p-dcc98162.js";import{I as e,c as t}from"./p-3a41fc0a.js";import{g as o}from"./p-8b5d3a52.js";import"./p-9ec80349.js";const a=[{payloadKey:"IS_LOAD_METHOD_CALLED",payloadDescription:"Indicate if the method load of public API VegaSkeletonLoaderController is called",canAccept:(e,t)=>"VegaSkeletonLoaderController"===e&&"load"===t,payloadValue:()=>!0},{payloadKey:"IS_UNLOAD_METHOD_CALLED",payloadDescription:"Indicate if the method unLoad of public API VegaSkeletonLoaderController is called",canAccept:(e,t)=>"VegaSkeletonLoaderController"===e&&"unLoad"===t,payloadValue:()=>!0},{payloadKey:"IS_UNLOADALL_METHOD_CALLED",payloadDescription:"Indicate if the method unLoadAll of public API VegaSkeletonLoaderController is called",canAccept:(e,t)=>"VegaSkeletonLoaderController"===e&&"unLoadAll"===t,payloadValue:()=>!0}];class l{constructor(){this.vegaPublicAPIRuntimeMetricsSlimmer=t(l,["load","unLoad","unLoadAll"],a),this.loaderMap=new Map}load({target:e,type:t="text",width:a,height:n,items:c,layout:i}){const r=Array.from(document.body.querySelectorAll(e)),d=`vega-skeleton-loader-${o()}`,s=[];return r.forEach((e=>{const o=c?c.map(this.createSkeleton):[this.createSkeleton({type:t,width:a,height:n})],r=(i?[this.wrapLayout(o,i)]:o).map((e=>(e.dataset[l.LOADER_DATA_SET_KEY]=d,e)));s.push(...r),e.append(...r)})),this.loaderMap.set(d,s),d}unLoad(e){this.loaderMap.has(e)&&(this.loaderMap.get(e).forEach((e=>e.remove())),this.loaderMap.delete(e))}unLoadAll(){for(const e of this.loaderMap.values())e.forEach((e=>e.remove()));this.loaderMap.clear()}createSkeleton(e){const{type:t,width:o,height:a}=e,l=document.createElement("vega-skeleton");return Object.assign(l,{animated:!0,type:t,width:o,height:a}),l}wrapLayout(e,t){const o=document.createElement("vega-flex");return Object.assign(o,Object.assign({className:"vega-skeleton-loader-template-container"},t.props)),Object.assign(o.style,t.style),o.append(...e),o}}l.LOADER_DATA_SET_KEY="vegaSkeletonLoaderKey",function(e,t,o,a){var l,n=arguments.length,c=n<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,o):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,o,a);else for(var i=e.length-1;i>=0;i--)(l=e[i])&&(c=(n<3?l(c):n>3?l(t,o,c):l(t,o))||c);n>3&&c&&Object.defineProperty(t,o,c)}([e()],l.prototype,"vegaPublicAPIRuntimeMetricsSlimmer",void 0);const n=new l;export{n as VegaSkeletonLoader}