var O=Object.defineProperty;var b=(a,e,t)=>e in a?O(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var s=(a,e,t)=>b(a,typeof e!="symbol"?e+"":e,t);import{j as i}from"./client-By3tlFYA.js";import{r as M}from"./index-TEHZzOO_.js";import{eU as d,eV as S,bu as k,b as V,ay as P,aM as j,V as I}from"./useSelectableClick-D9BFU7v4.js";import{I as y}from"./hashtag-T8rSpi30.js";import A from"./media_gallery-CqP2N7Nn.js";import{M as E,a as N}from"./media_modal-BBnR1M33.js";import{I as w}from"./intl_provider-Ciqrya3e.js";import"./index-DkCxcZFY.js";import"./message-CVkQtbZv.js";import"./relative_timestamp-BOUL06oe.js";import"./ready-DpOgoWSg.js";import"./short_number-C9zm8Jg6.js";import"./numbers-BLyy7tyF.js";import"./index-DUY7J2K7.js";import"./skeleton-CwYXpOUk.js";import"./api-C8Dh2R2O.js";import"./index-DiPYjm3h.js";import"./load_locale-Dm9dKbU7.js";import"./index-C_3HmjFF.js";import"./alt_text_badge-BrSfP-9I.js";import"./index-C24bpNHV.js";import"./chevron_left-tY77j9LU.js";import"./use-gesture-react.esm-DRqc-06E.js";const J={MediaGallery:A,Video:I,Card:j,Poll:P,Hashtag:y,Audio:V};class rt extends M.PureComponent{constructor(){super(...arguments);s(this,"state",{media:null,index:null,lang:null,time:null,backgroundColor:null,options:null});s(this,"handleOpenMedia",(t,o,r)=>{this.setState({media:t,index:o,lang:r})});s(this,"handleOpenVideo",(t,o)=>{const{components:r}=this.props,{media:n}=JSON.parse(r[o.componentIndex].getAttribute("data-props")),l=d(n);this.setState({media:l,lang:t,options:o})});s(this,"handleCloseMedia",()=>{this.setState({media:null,index:null,time:null,backgroundColor:null,options:null})});s(this,"setBackgroundColor",t=>{this.setState({backgroundColor:t})})}render(){var r,n,l;const{components:t}=this.props;let o;return window.self===window.top&&(o=this.handleOpenVideo),i.jsx(w,{children:i.jsxs(i.Fragment,{children:[Array.from(t).map((m,p)=>{const h=m.getAttribute("data-component"),f=J[h],{media:u,card:c,poll:g,hashtag:C,...x}=JSON.parse(m.getAttribute("data-props"));return Object.assign(x,{...u?{media:d(u)}:{},...c?{card:d(c)}:{},...g?{poll:S(g)}:{},...C?{hashtag:d(C)}:{},...h==="Video"?{componentIndex:p,onOpenVideo:o}:{onOpenMedia:this.handleOpenMedia}}),k.createPortal(M.createElement(f,{...x,key:"media-".concat(p)}),m)}),i.jsx(E,{backgroundColor:this.state.backgroundColor,onClose:this.handleCloseMedia,children:this.state.media&&i.jsx(N,{media:this.state.media,index:this.state.index||0,lang:this.state.lang,currentTime:(r=this.state.options)==null?void 0:r.startTime,autoPlay:(n=this.state.options)==null?void 0:n.autoPlay,volume:(l=this.state.options)==null?void 0:l.defaultVolume,onClose:this.handleCloseMedia,onChangeBackgroundColor:this.setBackgroundColor})})]})})}}export{rt as default};
//# sourceMappingURL=media_container-H7usIGHV.js.map
