import{j as u,b2 as x,W as e}from"./vendor-mui-core-DnR6WYuU.js";import{$}from"./vendor-ux-DTEmWsko.js";import{C as c}from"./vendor-utils-CxWN1dT3.js";import{Z as l,ai as v,bs as j,c as y,bt as E,bu as P}from"./index-BZxsCCR_.js";function R({blocklet:o,ancestors:d=[]}){const t=l(),{inService:s}=t,a=v(o?.status)||j(o?.status),r=`?v=${o?.meta?.version}${a?"~":""}`;let n=s?`${c(E,y.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo-bundle")}${r}`:c(t.imgPrefix,"blocklet.png");if(o.source==="registry"&&o.deployedFrom&&o.meta.logo)n=`${c(o.deployedFrom,P(o.meta.bundleDid,o.meta.logo))}${r}`;else{const g=window.env?.apiPrefix||"/",i=d.concat(o),p=s?i.slice(1):i;n=`${c(g,`/blocklet/logo-bundle${p.map(m=>`/${m.meta.did}`).join("")}`)}${r}`}return{logoUrl:n,inService:s}}function h({blocklet:o,style:d={},size:t=40,ancestors:s=[],...a}){const r=l(),{logoUrl:n,inService:g}=R({blocklet:o,ancestors:s}),{variant:i}=a,p=g?()=>{}:f=>{f.target.src=`${r.imgPrefix}/blocklet.png`};let m=u.jsx("img",{src:n,onError:p,alt:o.meta.name,style:{width:t}});return o.meta.logo||(m=u.jsx($,{did:o.meta.did||"",responsive:!0})),u.jsx(x,{variant:i||"square",style:Object.assign({backgroundColor:"transparent",width:t,height:t,borderRadius:10},d),...a,children:m})}h.propTypes={blocklet:e.object.isRequired,style:e.object,size:e.oneOfType([e.number,e.string]),ancestors:e.array};export{h as B};
