import{c as i}from"./vendor-ui-CGT0cG1n.js";import{r as l}from"./index-D88CvPWT.js";import{u}from"./useCacheOssStore-OAoLDVbw.js";import{v as f,ay as m,aM as d,aN as h,ab as p,j as x,X as g,ax as v,af as _}from"./vendor-core-BKehvho7.js";function B(n){const t=document.createElement("canvas"),e=t.getContext("2d");if(!e)return"";t.width=100,t.height=100,e.fillStyle="#fff",e.font="60px serif";const r=e.measureText(n),a=r.width,s=r.actualBoundingBoxAscent+r.actualBoundingBoxDescent,o=(t.width-a)/2,c=(t.height+s)/2-r.actualBoundingBoxDescent;return e.fillText(n,o,c),t.toDataURL()}const S=f({__name:"index",props:{src:{type:String,default:""},text:{type:String,default:""}},setup(n){const t=n,e=u(),r=m(),a=_("");return d(()=>t.text,s=>{!s||t.src||(a.value=B(s))},{immediate:!0}),h(async()=>{if(!t.src)return;const s=e.getCacheUrl(t.src);if(s){a.value=s;return}const o=await l.v1Oss.osscontrollerFilesignurl({objectId:t.src}),{signUrl:c}=o.data;a.value=c,e.setCacheUrl(t.src,c)}),(s,o)=>{const c=i;return p(),x(c,g({class:"border border-gray-400"},v(r),{src:a.value}),null,16,["src"])}}});export{S as _};
