"use strict";const k=require("./tslib.es6-C4EgNkz1.js"),e=require("react"),g=require("classnames"),B=require("./utils-C9NL3q0j.js"),N=require("./icon-button-AJ6dtyvc.js"),O=require("./menu-button-tvdOBhp1.js"),C=require("./menu-Bvnencku.js"),j=require("./icons/ebay-icon-close-16/index.js"),U=require("./icons/ebay-icon-delete-16/index.js"),L=require("./progress-spinner-DTmNtD59.js"),R=require("./icons/ebay-icon-file-24/index.js"),A=require("./icons/ebay-icon-play-16/index.js"),D=({status:t,menuActions:n,onMenuAction:l,deleteText:s,onCancel:a,onDelete:i,onAction:p,a11yCancelUploadText:m,action:r})=>{const b=(c,u)=>{var o;if(u){const d=(o=u.checked)===null||o===void 0?void 0:o[0],E=n&&d!==void 0&&d in n?n[d].event:null;E&&l?l(c,Object.assign(Object.assign({},u),{eventName:E})):i&&i(c)}};return t==="uploading"?e.createElement(N.EbayIconButton,{"aria-label":m,onClick:a,className:"file-preview-card__action",icon:e.createElement(j.EbayIconClose16,null)}):n?.length?e.createElement(e.Fragment,null,e.createElement(O.EbayMenuButton,{variant:"overflow",className:"file-preview-card__action",onSelect:b},n.map(c=>e.createElement(C.EbayMenuItem,{value:c.event,key:c.label},c.label)),e.createElement(C.EbayMenuItem,{key:"delete",value:"delete"},s))):r?.props&&r.props.icon&&r.props["aria-label"]?e.createElement(N.EbayIconButton,Object.assign({onClick:p,className:g("file-preview-card__action",r.props.className)},r.props)):s?e.createElement(N.EbayIconButton,{"aria-label":s,className:"file-preview-card__action",icon:e.createElement(U.EbayIconDelete16,null),onClick:i}):e.createElement(e.Fragment,null)},F=({file:t,status:n,seeMore:l})=>{if(n==="uploading")return e.createElement(L.EbayProgressSpinner,{className:"file-preview-card__asset"});switch(t?.type){case"video":return e.createElement("video",{className:"file-preview-card__asset",src:t.src});case"image":return e.createElement("img",{className:g("file-preview-card__asset",{"file-preview-card__asset--fade":l&&l>0}),src:t?.src,alt:t?.name});default:return e.createElement(R.EbayIconFile24,{className:"file-preview-card__asset"})}},W=({file:t,infoText:n})=>t&&t.type!=="image"?e.createElement("div",{className:"file-preview-card__info"},t.type==="video"&&e.createElement(A.EbayIconPlay16,{className:"file-preview-card__video-icon"}),n||t.name.substring(t.name.lastIndexOf(".")+1).toUpperCase()):e.createElement(e.Fragment,null),I=()=>null,z=t=>{var{a11yCancelUploadText:n,status:l,as:s="div",file:a,seeMore:i,deleteText:p,footerTitle:m,footerSubtitle:r,a11ySeeMoreText:b,menuActions:c,infoText:u,href:o,onCancel:d,onDelete:E,onMenuAction:q,onSeeMore:M,onAction:h,className:S,children:x}=t,P=k.__rest(t,["a11yCancelUploadText","status","as","file","seeMore","deleteText","footerTitle","footerSubtitle","a11ySeeMoreText","menuActions","infoText","href","onCancel","onDelete","onMenuAction","onSeeMore","onAction","className","children"]);const T=B.findComponent(x,I),y=e.useMemo(()=>{var f,_;if(!a)return;let w=a,v;return!((f=a?.type)===null||f===void 0)&&f.startsWith("image")?v="image":!((_=a?.type)===null||_===void 0)&&_.startsWith("video")&&(v="video"),a instanceof File&&(w={name:a.name,type:v,src:v?URL.createObjectURL(a):void 0}),w.type=v,w},[a]);return e.createElement(s,Object.assign({className:g("file-preview-card",S)},P),e.createElement("div",{className:"file-preview-card__body"},o?e.createElement("a",{href:o},e.createElement(F,{file:y,status:l,seeMore:i})):e.createElement(F,{file:y,status:l,seeMore:i}),i&&i>0?e.createElement("button",{type:"button",className:"file-preview-card__see-more",onClick:M,"aria-label":b},e.createElement("span",null,"+",i)):e.createElement(D,{a11yCancelUploadText:n,status:l,menuActions:c,onMenuAction:q,deleteText:p,onCancel:d,onDelete:E,onAction:h,action:T}),e.createElement(W,{file:y,infoText:u})),m&&e.createElement("div",{className:"file-preview-card__footer"},e.createElement("span",null,m),r&&e.createElement("span",null,r)))};exports.EbayFilePreviewCard=z;exports.EbayFilePreviewCardAction=I;
