@orangelogic/orange-dam-content-browser-sdk 2.1.61 → 2.1.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -216,7 +216,7 @@
216
216
  left: 50%;
217
217
  transform: translate(-50%, -50%);
218
218
  }
219
- `,Tn=(0,wt.forwardRef)(((e,t)=>{var n;let{disabled:r,loadable:o,image:i,resizer:a,cropper:s,rotation:l,selectedProxy:c,onCropComplete:u,onLoadingChange:d}=e;const[h,p]=(0,wt.useState)(!0),[f,m]=(0,wt.useState)({x:0,y:0}),[g,v]=(0,wt.useState)(1),[b,y]=(0,wt.useState)(null!==(n=null===i||void 0===i?void 0:i.url)&&void 0!==n?n:""),x=(0,wt.useRef)(null),[w,S]=(0,wt.useState)({width:0,height:0});(0,wt.useEffect)((()=>{const{url:e,originalUrl:t,extension:n}=i,{width:r,height:s}=a,l=ke((async()=>{if(o){var a,l;d(!0);const{width:o,height:c}=En(i.width,i.height,r,s),{url:u}=await((e,t,n,r,o)=>{const i=new Image;return i.src=e,i.crossOrigin="anonymous",new Promise((a=>{i.onload=()=>{const s=document.createElement("canvas");if(t>r||n>o){const e=r/t,i=o/n,a=Math.min(e,i);a>0?(s.width=t*a,s.height=n*a):(s.width=t,s.height=n)}else s.width=t,s.height=n;const l=s.getContext("2d");l?(l.drawImage(i,0,0,s.width,s.height),a({url:s.toDataURL("image/jpeg"),width:s.width,height:s.height})):a({url:e,width:t,height:n})},i.onerror=()=>{a({url:e,width:t,height:n})}}))})(e,o,c,null!==(a=null===(l=x.current)||void 0===l?void 0:l.clientWidth)&&void 0!==a?a:window.innerWidth,Ut.uS);y("gif"===n?t:u),d(!1)}else y(e)}),300,{leading:!0});l()}),[i,o,d,a,c]),(0,wt.useEffect)((()=>{const e=x.current;if(!e)return;const t=new ResizeObserver((e=>{for(const t of e){const{width:e,height:n}=t.contentRect;S({width:e,height:n})}}));return t.observe(e),()=>{t.disconnect()}}),[]);const k=(0,wt.useCallback)((async()=>b),[b]),_=(0,wt.useCallback)((async()=>{const{width:e,height:t,x:n,y:r,unit:a}=s,l={x:n,y:r,width:e,height:t};if(l.x=n/100*i.width,l.y=r/100*i.height,o){if(d(!0),a===sn.Nf.AspectRatio){const{width:n,height:r}=En(i.width,i.height,e,t);l.width=n/g,l.height=r/g}const n=await((e,t)=>{const n=new Image;return n.src=e.url,n.crossOrigin="anonymous",new Promise((r=>{n.onload=()=>{const o=document.createElement("canvas");o.width=t.width,o.height=t.height;const i=o.getContext("2d");i?(i.drawImage(n,-t.x,-t.y,e.width,e.height),r(o.toDataURL("image/jpeg"))):r(e.url)},n.onerror=()=>{r(e.url)}}))})({url:i.url,width:i.width,height:i.height},l);return d(!1),n}return Promise.resolve(i.url)}),[s,i.width,i.height,i.url,o,d,g]),C=(0,wt.useCallback)((async()=>{if(o){d(!0);const e=await((e,t)=>{const n=new Image;return n.src=e.url,n.crossOrigin="anonymous",new Promise((r=>{n.onload=()=>{const{width:o,height:i}=cn(e.width,e.height,t),a=document.createElement("canvas");a.width=o,a.height=i;const s=a.getContext("2d");s?(s.fillStyle="white",s.fillRect(0,0,o,i),s.translate(o/2,i/2),s.rotate(t*Math.PI/180),s.drawImage(n,-e.width/2,-e.height/2,e.width,e.height),s.rotate(-t*Math.PI/180),s.translate(-o/2,-i/2),r(a.toDataURL("image/jpeg"))):r(e.url)},n.onerror=()=>{r(e.url)}}))})({url:i.url,width:i.width,height:i.height},l);return d(!1),e}return Promise.resolve(i.url)}),[i.height,i.url,i.width,o,d,l]);(0,wt.useImperativeHandle)(t,(()=>({applyResize:k,applyCrop:_,applyRotation:C,setZoom:v})));const E=(0,wt.useCallback)((()=>{m({x:0,y:0}),v(1)}),[]),A=(0,wt.useCallback)((e=>{r||m(e)}),[r]),T=(0,wt.useCallback)((()=>{p(!1)}),[]);(0,wt.useEffect)((()=>{E()}),[r,E]);const O=(0,wt.useMemo)((()=>{if(!x.current||h)return"contain";const e=a.width/a.height,t=w.height||Ut.uS;return e>w.width/t?"horizontal-cover":"vertical-cover"}),[h,a,w]);return(0,Vt.jsxs)(An,{ref:x,style:{height:`${Ut.uS}px`},children:[o&&(0,Vt.jsx)(Cn,{image:b,crop:f,zoom:g,aspect:s.width/s.height,rotation:l,objectFit:O,onCropChange:A,onCropComplete:u,onMediaLoaded:T,onZoomChange:v,zoomWithScroll:s.unit===sn.Nf.AspectRatio,style:{containerStyle:{cursor:r?"default":"move",pointerEvents:r?"none":"auto"},cropAreaStyle:{display:r?"none":"block"},mediaStyle:{opacity:h?0:1}}}),h&&(0,Vt.jsxs)("div",{className:"loading",children:[(0,Vt.jsx)("cx-skeleton",{className:"loading__skeleton"}),(0,Vt.jsx)("cx-spinner",{className:"loading__spinner"})]})]})}));var On=n(7032);const Pn=function(e,t,n){var r=(n="function"==typeof n?n:void 0)?n(e,t):void 0;return void 0===r?(0,On.A)(e,t,void 0,n):!!r},zn=Ft.Ay.div`
219
+ `,Tn=(0,wt.forwardRef)(((e,t)=>{var n;let{disabled:r,loadable:o,image:i,resizer:a,cropper:s,rotation:l,selectedProxy:c,onCropComplete:u,onLoadingChange:d}=e;const[h,p]=(0,wt.useState)(!0),[f,m]=(0,wt.useState)({x:0,y:0}),[g,v]=(0,wt.useState)(1),[b,y]=(0,wt.useState)(null!==(n=null===i||void 0===i?void 0:i.url)&&void 0!==n?n:""),x=(0,wt.useRef)(null),[w,S]=(0,wt.useState)({width:0,height:0});(0,wt.useEffect)((()=>{const{url:e,originalUrl:t,extension:n}=i,{width:r,height:s}=a,l=ke((async()=>{if(o){var a,l;d(!0);const{width:o,height:c}=En(i.width,i.height,r,s),{url:u}=await((e,t,n,r,o)=>{const i=new Image;return i.src=e,i.crossOrigin="anonymous",new Promise((a=>{i.onload=()=>{const s=document.createElement("canvas");if(t>r||n>o){const e=r/t,i=o/n,a=Math.min(e,i);a>0?(s.width=t*a,s.height=n*a):(s.width=t,s.height=n)}else s.width=t,s.height=n;const l=s.getContext("2d");l?(l.drawImage(i,0,0,s.width,s.height),a({url:s.toDataURL("image/jpeg"),width:s.width,height:s.height})):a({url:e,width:t,height:n})},i.onerror=()=>{a({url:e,width:t,height:n})}}))})(e,o,c,null!==(a=null===(l=x.current)||void 0===l?void 0:l.clientWidth)&&void 0!==a?a:window.innerWidth,Ut.uS);y(".gif"===n?t:u),d(!1)}else y(e)}),300,{leading:!0});l()}),[i,o,d,a,c]),(0,wt.useEffect)((()=>{const e=x.current;if(!e)return;const t=new ResizeObserver((e=>{for(const t of e){const{width:e,height:n}=t.contentRect;S({width:e,height:n})}}));return t.observe(e),()=>{t.disconnect()}}),[]);const k=(0,wt.useCallback)((async()=>b),[b]),_=(0,wt.useCallback)((async()=>{const{width:e,height:t,x:n,y:r,unit:a}=s,l={x:n,y:r,width:e,height:t};if(l.x=n/100*i.width,l.y=r/100*i.height,o){if(d(!0),a===sn.Nf.AspectRatio){const{width:n,height:r}=En(i.width,i.height,e,t);l.width=n/g,l.height=r/g}const n=await((e,t)=>{const n=new Image;return n.src=e.url,n.crossOrigin="anonymous",new Promise((r=>{n.onload=()=>{const o=document.createElement("canvas");o.width=t.width,o.height=t.height;const i=o.getContext("2d");i?(i.drawImage(n,-t.x,-t.y,e.width,e.height),r(o.toDataURL("image/jpeg"))):r(e.url)},n.onerror=()=>{r(e.url)}}))})({url:i.url,width:i.width,height:i.height},l);return d(!1),n}return Promise.resolve(i.url)}),[s,i.width,i.height,i.url,o,d,g]),C=(0,wt.useCallback)((async()=>{if(o){d(!0);const e=await((e,t)=>{const n=new Image;return n.src=e.url,n.crossOrigin="anonymous",new Promise((r=>{n.onload=()=>{const{width:o,height:i}=cn(e.width,e.height,t),a=document.createElement("canvas");a.width=o,a.height=i;const s=a.getContext("2d");s?(s.fillStyle="white",s.fillRect(0,0,o,i),s.translate(o/2,i/2),s.rotate(t*Math.PI/180),s.drawImage(n,-e.width/2,-e.height/2,e.width,e.height),s.rotate(-t*Math.PI/180),s.translate(-o/2,-i/2),r(a.toDataURL("image/jpeg"))):r(e.url)},n.onerror=()=>{r(e.url)}}))})({url:i.url,width:i.width,height:i.height},l);return d(!1),e}return Promise.resolve(i.url)}),[i.height,i.url,i.width,o,d,l]);(0,wt.useImperativeHandle)(t,(()=>({applyResize:k,applyCrop:_,applyRotation:C,setZoom:v})));const E=(0,wt.useCallback)((()=>{m({x:0,y:0}),v(1)}),[]),A=(0,wt.useCallback)((e=>{r||m(e)}),[r]),T=(0,wt.useCallback)((()=>{p(!1)}),[]);(0,wt.useEffect)((()=>{E()}),[r,E]);const O=(0,wt.useMemo)((()=>{if(!x.current||h)return"contain";const e=a.width/a.height,t=w.height||Ut.uS;return e>w.width/t?"horizontal-cover":"vertical-cover"}),[h,a,w]);return(0,Vt.jsxs)(An,{ref:x,style:{height:`${Ut.uS}px`},children:[o&&(0,Vt.jsx)(Cn,{image:b,crop:f,zoom:g,aspect:s.width/s.height,rotation:l,objectFit:O,onCropChange:A,onCropComplete:u,onMediaLoaded:T,onZoomChange:v,zoomWithScroll:s.unit===sn.Nf.AspectRatio,style:{containerStyle:{cursor:r?"default":"move",pointerEvents:r?"none":"auto"},cropAreaStyle:{display:r?"none":"block"},mediaStyle:{opacity:h?0:1}}}),h&&(0,Vt.jsxs)("div",{className:"loading",children:[(0,Vt.jsx)("cx-skeleton",{className:"loading__skeleton"}),(0,Vt.jsx)("cx-spinner",{className:"loading__spinner"})]})]})}));var On=n(7032);const Pn=function(e,t,n){var r=(n="function"==typeof n?n:void 0)?n(e,t):void 0;return void 0===r?(0,On.A)(e,t,void 0,n):!!r},zn=Ft.Ay.div`
220
220
  .details__summary__icon {
221
221
  width: var(--cx-font-size-3x-large);
222
222
  height: var(--cx-font-size-3x-large);
@@ -267,6 +267,10 @@
267
267
  }
268
268
  }
269
269
 
270
+ cx-details {
271
+ --details-background-color: var(--cx-color-neutral-0);
272
+ }
273
+
270
274
  cx-details:not(:last-child)::part(base) {
271
275
  border-bottom-width: 0;
272
276
  }
@@ -621,7 +625,7 @@
621
625
  .version__item__editor {
622
626
  color: var(--cx-color-primary);
623
627
  }
624
- `;var Yn=n(3943);const Jn=e=>{let{src:t,alt:n}=e;const[r,o]=(0,wt.useState)("horizontal"),i=(0,wt.useRef)(null),a=(0,wt.useCallback)((()=>{if(i.current){const{naturalWidth:e,naturalHeight:t}=i.current;o(e>t?"horizontal":"vertical")}}),[]);return(0,Vt.jsx)("div",{className:`version__item__preview version__item__preview--${r}`,children:(0,Vt.jsx)("img",{ref:i,src:t,alt:n,onLoad:a})})},er=e=>{let{src:t}=e;const[n,r]=(0,wt.useState)("horizontal"),o=(0,wt.useRef)(null),i=(0,wt.useCallback)((()=>{if(o.current){const{videoWidth:e,videoHeight:t}=o.current;r(e>t?"horizontal":"vertical")}}),[]);return(0,Vt.jsx)("div",{className:`version__item__preview version__item__preview--${n}`,children:(0,Vt.jsx)("video",{ref:o,src:t,onLoadedMetadata:i,controls:!0})})},tr=e=>{var t;let{assetId:n}=e;const{data:r,isFetching:o,isLoading:i}=(0,Yn.cP)(n?{assetId:n}:Lt.hT);return o||i?(0,Vt.jsx)(Zn,{children:(0,Vt.jsx)("cx-spinner",{})}):(0,Vt.jsx)(Zn,{children:(0,Vt.jsx)("cx-menu",{children:null===r||void 0===r||null===(t=r.versions)||void 0===t?void 0:t.map(((e,t)=>(0,Vt.jsx)("cx-menu-item",{className:"version__item",readonly:!0,children:(0,Vt.jsxs)("cx-grid",{columns:5,spacing:"12px",children:[(0,Vt.jsx)("cx-grid-item",{xs:"2",sm:"2",children:(0,Vt.jsxs)("cx-space",{direction:"horizontal","align-items":"center",wrap:"nowrap",children:[(0,Vt.jsx)("div",{className:"version__item__number",children:(0,Vt.jsx)("cx-line-clamp",{lines:1,children:e.versionNumberDisplay})}),e.scrubUrl?(0,Vt.jsx)(er,{src:e.scrubUrl}):(0,Vt.jsx)(Jn,{src:e.versionFileUrl,alt:e.versionFileName})]})}),(0,Vt.jsx)("cx-grid-item",{xs:"2",sm:"3",children:(0,Vt.jsxs)("cx-space",{direction:"vertical",spacing:"2x-small",children:[(0,Vt.jsx)("cx-line-clamp",{lines:1,children:(0,Vt.jsx)("cx-typography",{variant:"body3",className:"version__item__name",children:e.versionFileName})}),(0,Vt.jsx)("cx-line-clamp",{lines:1,children:(0,Vt.jsx)("cx-typography",{variant:"body3",children:e.createByEmail})}),(0,Vt.jsxs)("cx-typography",{variant:"body3",children:[e.versionCreateDate.split(" ")[0],0===t&&(0,Vt.jsx)("span",{className:"version__item__latest",children:"Current version"})]})]})})]})},e.versionNumber)))})})},nr={previewLoadable:!1,defaultSize:{width:0,height:0},selectedProxy:"",selectedFormat:{url:"",originalUrl:"",width:0,height:0,x:0,y:0,extension:"",rotation:0},defaultSelectedFormat:{url:"",originalUrl:"",width:0,height:0,x:0,y:0,extension:"",rotation:0},resizeSize:{width:0,height:0,unit:sn.Nf.Pixel},lastResizeSize:{[sn.Nf.AspectRatio]:{width:0,height:0,unit:sn.Nf.AspectRatio},[sn.Nf.Pixel]:{width:0,height:0,unit:sn.Nf.Pixel}},cropSize:{width:0,height:0,percentageWidth:0,percentageHeight:0,x:0,y:0,unit:sn.Nf.Pixel},lastCropSize:{[sn.Nf.AspectRatio]:{width:0,height:0,percentageWidth:0,percentageHeight:0,x:0,y:0,unit:sn.Nf.AspectRatio},[sn.Nf.Pixel]:{width:0,height:0,percentageWidth:0,percentageHeight:0,x:0,y:0,unit:sn.Nf.Pixel}},isLoadingConfirm:!1,isLoadingFavorites:!1,rotation:0,quality:100,keepMetadata:!1,transformations:[],confirmedTransformations:[],enabledTracking:!1,trackingParameters:[{key:"UTM_source",value:""},{key:"UTM_campaign",value:""},{key:"UTM_description",value:""}],showCustomRendition:!1,showVersionHistory:!1,useCustomRendition:!1,useRepresentative:!1,activeSetting:"format",isLoading:!1},rr=(e,t)=>{switch(t.type){case"CANCEL_USE_CUSTOM_RENDITION":return{...e,cropSize:{...e.cropSize,width:t.payload.width,height:t.payload.height},resizeSize:{...e.resizeSize,width:t.payload.width,height:t.payload.height},selectedFormat:{...e.selectedFormat,...t.payload,rotation:0,x:0,y:0},rotation:0,transformations:e.useCustomRendition?e.confirmedTransformations:[],showCustomRendition:!1,activeSetting:"format"};case"CONFIRM_USE_CUSTOM_RENDITION":return{...e,confirmedTransformations:e.transformations,cropSize:{...e.cropSize,width:e.selectedFormat.width,height:e.selectedFormat.height},resizeSize:{...e.resizeSize,width:e.selectedFormat.width,height:e.selectedFormat.height},rotation:0,activeSetting:"format",showCustomRendition:!1,useCustomRendition:!0,defaultSelectedFormat:{...e.selectedFormat}};case"SET_DEFAULT_SIZE":return{...e,defaultSize:{...e.defaultSize,...t.payload}};case"RESET_DATA":return nr;case"SET_ACTIVE_SETTING":return{...e,activeSetting:t.payload};case"SET_CROP_SIZE":return{...e,cropSize:{...e.cropSize,...t.payload}};case"SET_ENABLED_TRACKING":return{...e,enabledTracking:t.payload};case"SET_KEEP_METADATA":return{...e,keepMetadata:t.payload};case"SET_LAST_CROP_SIZE":return{...e,lastCropSize:{...e.lastCropSize,...t.payload}};case"SET_LAST_RESIZE_SIZE":return{...e,lastResizeSize:{...e.lastResizeSize,...t.payload}};case"SET_LOADING":return{...e,isLoading:t.payload};case"SET_LOADING_CONFIRM":return{...e,isLoadingConfirm:t.payload};case"SET_LOADING_FAVORITES":return{...e,isLoadingFavorites:t.payload};case"SET_PREVIEW_LOADABLE":return{...e,previewLoadable:t.payload};case"SET_QUALITY":return{...e,quality:t.payload};case"SET_RESIZE_SIZE":return{...e,resizeSize:{...e.resizeSize,...t.payload}};case"SET_ROTATION":return{...e,rotation:t.payload};case"SET_SELECTED_FORMAT":return{...e,selectedFormat:{...e.selectedFormat,...t.payload}};case"SET_SELECTED_PROXY":return t.payload?"string"===typeof t.payload?{...e,selectedProxy:t.payload,useCustomRendition:!1,useRepresentative:!1}:{...e,selectedProxy:t.payload.proxy,useCustomRendition:Boolean(t.payload.useCustomRendition),useRepresentative:!1}:{...e,selectedProxy:"",useCustomRendition:!1,useRepresentative:!1};case"SET_SHOW_CUSTOM_RENDITION":return{...e,selectedProxy:"",showCustomRendition:t.payload};case"SET_SHOW_VERSION_HISTORY":return{...e,showVersionHistory:t.payload};case"SET_TRACKING_PARAMETERS":return{...e,trackingParameters:t.payload};case"SET_TRANSFORMATIONS":return{...e,transformations:[...e.transformations,t.payload]};case"SET_USE_REPRESENTATIVE":return{...e,selectedProxy:t.payload?"":e.selectedProxy,useRepresentative:t.payload};default:return e}},or=e=>{let{allowCustomFormat:t,allowFavorites:n,allowProxy:r,allowTracking:o,allowedExtensions:i,appendAutoExtension:a,autoExtension:s,availableExtensions:l,availableProxies:c,ctaText:u="Insert",extensions:d,isFavorite:h,maxHeight:p,open:f,previewUrl:m,selectedAsset:g,showVersions:v,supportedRepresentativeSubtypes:b,variant:y="dialog",boundary:x,onClose:w,onFavorite:S,onProxyConfirm:k,onFormatConfirm:_,onUnFavorite:C}=e;const[E,A]=(0,wt.useReducer)(rr,nr),[T,O]=(0,wt.useState)(!1),P=(0,wt.useRef)(null),z=(0,wt.useRef)(null),D=(0,wt.useRef)(null),R=(0,wt.useMemo)((()=>i?c?c.filter((e=>{if(!e.extension&&g){return!!(null===i||void 0===i?void 0:i.some((e=>e===g.extension.replace(/^\./,""))))}return!0})):[]:c),[c,i,g]),j=(0,wt.useCallback)((()=>{var e,t;if(!g)return;const n=ln(E.defaultSize.width,E.defaultSize.height);A({type:"SET_RESIZE_SIZE",payload:{...nr.resizeSize,width:E.defaultSize.width,height:E.defaultSize.height}}),A({type:"SET_CROP_SIZE",payload:{...nr.cropSize,width:E.defaultSize.width,height:E.defaultSize.height,percentageHeight:100,percentageWidth:100}}),A({type:"SET_ROTATION",payload:0}),A({type:"SET_LAST_CROP_SIZE",payload:{...nr.lastCropSize,[sn.Nf.Pixel]:{width:E.defaultSize.width,height:E.defaultSize.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:sn.Nf.Pixel},[sn.Nf.AspectRatio]:{width:n.width,height:n.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:sn.Nf.AspectRatio}}}),A({type:"SET_LAST_RESIZE_SIZE",payload:{[sn.Nf.Pixel]:{width:E.defaultSize.width,height:E.defaultSize.height,unit:sn.Nf.Pixel},[sn.Nf.AspectRatio]:{width:n.width,height:n.height,unit:sn.Nf.AspectRatio}}});const r=a?s:g.docType?null===l||void 0===l||null===(e=l[g.docType])||void 0===e||null===(t=e[0])||void 0===t?void 0:t.value:g.extension;var o;R&&R.length>0?(A({type:"SET_SELECTED_PROXY",payload:null===(o=R[0])||void 0===o?void 0:o.id}),A({type:"SET_SELECTED_FORMAT",payload:{...nr.selectedFormat,url:g.imageUrl,originalUrl:g.originalUrl,extension:r,width:R[0].formatWidth||E.defaultSize.width,height:R[0].formatHeight||E.defaultSize.height}})):A({type:"SET_SELECTED_FORMAT",payload:{...nr.selectedFormat,url:g.imageUrl,originalUrl:g.originalUrl,extension:r,width:E.defaultSize.width,height:E.defaultSize.height}})}),[s,R,g,E.defaultSize.height,E.defaultSize.width,a,l]);(0,wt.useEffect)((()=>{null!==g&&void 0!==g&&g.width&&null!==g&&void 0!==g&&g.height&&A({type:"SET_DEFAULT_SIZE",payload:{width:parseInt(g.width,10),height:parseInt(g.height,10)}})}),[null===g||void 0===g?void 0:g.width,null===g||void 0===g?void 0:g.height]),(0,wt.useEffect)((()=>{Promise.all([customElements.whenDefined("cx-dialog"),customElements.whenDefined("cx-drawer"),customElements.whenDefined("cx-dropdown")]).then((()=>{O(!0)}))}),[]),(0,wt.useEffect)((()=>{const e=e=>{E.isLoadingFavorites?e.preventDefault():E.showVersionHistory?(e.preventDefault(),A({type:"SET_SHOW_VERSION_HISTORY",payload:!1})):(A({type:"SET_PREVIEW_LOADABLE",payload:!1}),A({type:"RESET_DATA"}),w())},t=P.current,n=z.current;return null===t||void 0===t||t.addEventListener("cx-request-close",e),null===n||void 0===n||n.addEventListener("cx-request-close",e),()=>{null===t||void 0===t||t.removeEventListener("cx-request-close",e),null===n||void 0===n||n.removeEventListener("cx-request-close",e)}}),[x,T,w,E.isLoadingFavorites,E.showVersionHistory]),(0,wt.useEffect)((()=>{const e=P.current;e&&x&&(e.boundary=x)})),(0,wt.useEffect)((()=>{const e=()=>{A({type:"SET_PREVIEW_LOADABLE",payload:!0})},t=P.current,n=z.current;return null===t||void 0===t||t.addEventListener("cx-after-show",e),null===n||void 0===n||n.addEventListener("cx-after-show",e),()=>{null===t||void 0===t||t.removeEventListener("cx-after-show",e),null===n||void 0===n||n.removeEventListener("cx-after-show",e)}}),[T,E.showCustomRendition,y]),(0,wt.useEffect)((()=>{const e=e=>{const t=e.detail.item.value;if("custom"===t)return A({type:"SET_SHOW_CUSTOM_RENDITION",payload:!0}),void(E.useCustomRendition||j());if("tracking"!==t)if("use-representative"!==t){if(t&&R){if(!R.map((e=>e.id)).includes(t))return;A({type:"SET_SELECTED_PROXY",payload:t})}}else A({type:"SET_USE_REPRESENTATIVE",payload:!E.useRepresentative});else A({type:"SET_ENABLED_TRACKING",payload:!E.enabledTracking})},t=P.current,n=z.current;return null===t||void 0===t||t.addEventListener("cx-select",e),null===n||void 0===n||n.addEventListener("cx-select",e),()=>{null===t||void 0===t||t.removeEventListener("cx-select",e),null===n||void 0===n||n.removeEventListener("cx-select",e)}}),[T,E.enabledTracking,E.useCustomRendition,E.useRepresentative,j,R,null===g||void 0===g?void 0:g.extension]),(0,wt.useEffect)((()=>{j()}),[j]);const N=(0,wt.useMemo)((()=>{var e;return(null===b||void 0===b?void 0:b.includes(null!==(e=null===g||void 0===g?void 0:g.docSubType)&&void 0!==e?e:""))&&(null===g||void 0===g?void 0:g.imageUrl)}),[g,b]),I=(0,wt.useCallback)((e=>{A({type:"SET_LOADING",payload:e})}),[]),M=(0,wt.useCallback)((async(e,t,n,r)=>{if(!g)return;const o=E.selectedFormat.width||E.defaultSize.width,i=E.selectedFormat.height||E.defaultSize.height;if(A({type:"SET_RESIZE_SIZE",payload:{width:e,height:t,unit:n}}),r){var a;let r=e,s=t;E.resizeSize.unit!==n?(r=o,s=i):n===sn.Nf.AspectRatio&&(r=Math.round(e/t*i),s=i);const l=await(null===(a=D.current)||void 0===a?void 0:a.applyResize());A({type:"SET_SELECTED_FORMAT",payload:{url:l,width:r,height:s}}),A({type:"SET_TRANSFORMATIONS",payload:{key:sn.YQ.Resize,value:{width:r,height:s}}}),A({type:"SET_CROP_SIZE",payload:{width:r,height:s}});const c=ln(r,s);A({type:"SET_LAST_RESIZE_SIZE",payload:{[sn.Nf.Pixel]:{width:r,height:s,unit:sn.Nf.Pixel},[sn.Nf.AspectRatio]:{width:n===sn.Nf.AspectRatio?e:c.width,height:n===sn.Nf.AspectRatio?t:c.height,unit:sn.Nf.AspectRatio}}}),A({type:"SET_LAST_CROP_SIZE",payload:{[sn.Nf.Pixel]:{width:r,height:s,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:sn.Nf.Pixel},[sn.Nf.AspectRatio]:{width:n===sn.Nf.AspectRatio?e:c.width,height:n===sn.Nf.AspectRatio?t:c.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:sn.Nf.AspectRatio}}})}}),[g,E.defaultSize.height,E.defaultSize.width,E.resizeSize.unit,E.selectedFormat.height,E.selectedFormat.width]),L=(0,wt.useCallback)((async(e,t,n,r)=>{var o,i;if(!g)return;const a=E.cropSize.unit,s=D.current;if(s&&null!==(o=E.selectedFormat)&&void 0!==o&&o.width&&null!==(i=E.selectedFormat)&&void 0!==i&&i.height){if(n===a&&n===sn.Nf.Pixel){const n=Math.max(e/E.selectedFormat.width,t/E.selectedFormat.height);s.setZoom(1/n)}n!==a&&s.setZoom(1)}if(A({type:"SET_CROP_SIZE",payload:{width:e,height:t,unit:n}}),r){var l;const r=await(null===(l=D.current)||void 0===l?void 0:l.applyCrop());let o=e,i=t;n===sn.Nf.AspectRatio&&(o=Math.round(E.cropSize.percentageWidth*E.selectedFormat.width/100),i=Math.round(E.cropSize.percentageHeight*E.selectedFormat.height/100)),null===s||void 0===s||s.setZoom(1);const a=Number((E.cropSize.x/100*E.selectedFormat.width).toFixed(0)),c=Number((E.cropSize.y/100*E.selectedFormat.height).toFixed(0));A({type:"SET_SELECTED_FORMAT",payload:{url:r,width:o,height:i}}),A({type:"SET_RESIZE_SIZE",payload:{width:o,height:i,unit:sn.Nf.Pixel}}),A({type:"SET_TRANSFORMATIONS",payload:{key:sn.YQ.Crop,value:{width:Number(o.toFixed(0)),height:Number(i.toFixed(0)),x:a,y:c}}});const u=ln(o,i);A({type:"SET_LAST_CROP_SIZE",payload:{[sn.Nf.Pixel]:{width:Math.round(o),height:Math.round(i),percentageHeight:100,percentageWidth:100,x:0,y:0,unit:sn.Nf.Pixel},[sn.Nf.AspectRatio]:{width:n===sn.Nf.AspectRatio?e:u.width,height:n===sn.Nf.AspectRatio?t:u.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:sn.Nf.AspectRatio}}}),A({type:"SET_LAST_RESIZE_SIZE",payload:{[sn.Nf.Pixel]:{width:o,height:i,unit:sn.Nf.Pixel},[sn.Nf.AspectRatio]:{width:n===sn.Nf.AspectRatio?e:u.width,height:n===sn.Nf.AspectRatio?t:u.height,unit:sn.Nf.AspectRatio}}})}}),[g,E.cropSize,E.selectedFormat.height,E.selectedFormat.width]),F=(0,wt.useCallback)((async(e,t)=>{if(A({type:"SET_ROTATION",payload:t?0:e}),t){var n;const{width:t,height:r}=cn(E.selectedFormat.width,E.selectedFormat.height,e),o=await(null===(n=D.current)||void 0===n?void 0:n.applyRotation());A({type:"SET_SELECTED_FORMAT",payload:{rotation:e,url:o,width:t,height:r}}),A({type:"SET_TRANSFORMATIONS",payload:{key:sn.YQ.Rotate,value:{rotation:e}}}),A({type:"SET_CROP_SIZE",payload:{width:t,height:r}}),A({type:"SET_RESIZE_SIZE",payload:{width:t,height:r,unit:sn.Nf.Pixel}});const i=ln(t,r);A({type:"SET_LAST_CROP_SIZE",payload:{[sn.Nf.Pixel]:{width:t,height:r,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:sn.Nf.Pixel},[sn.Nf.AspectRatio]:{width:i.width,height:i.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:sn.Nf.AspectRatio}}}),A({type:"SET_LAST_RESIZE_SIZE",payload:{[sn.Nf.Pixel]:{width:t,height:r,unit:sn.Nf.Pixel},[sn.Nf.AspectRatio]:{width:i.width,height:i.height,unit:sn.Nf.AspectRatio}}})}}),[E.selectedFormat]),B=(0,wt.useCallback)((e=>{A({type:"SET_SELECTED_FORMAT",payload:{extension:e}})}),[]),U=(0,wt.useCallback)((e=>{A({type:"SET_CROP_SIZE",payload:{width:E.selectedFormat.width,height:E.selectedFormat.height,unit:sn.Nf.Pixel}}),A({type:"SET_RESIZE_SIZE",payload:{width:E.selectedFormat.width,height:E.selectedFormat.height,unit:sn.Nf.Pixel}}),A({type:"SET_ROTATION",payload:0}),A({type:"SET_ACTIVE_SETTING",payload:e})}),[E.selectedFormat]),V=(0,wt.useCallback)((()=>{A({type:"SET_SHOW_VERSION_HISTORY",payload:!0})}),[]),q=(0,wt.useCallback)((e=>{let t=e.formatWidth,n=e.formatHeight;"TRX"===e.proxyName&&g&&(t=Number(g.width),n=Number(g.height)),A({type:"SET_SELECTED_PROXY",payload:{proxy:e.id,useCustomRendition:!0}}),A({type:"SET_SELECTED_FORMAT",payload:{width:t,height:n}}),A({type:"SET_RESIZE_SIZE",payload:{width:t,height:n,unit:sn.Nf.Pixel}}),A({type:"SET_CROP_SIZE",payload:{width:t,height:n,percentageWidth:100,percentageHeight:100,x:0,y:0,unit:sn.Nf.Pixel}});const r=ln(t,n);A({type:"SET_LAST_CROP_SIZE",payload:{[sn.Nf.Pixel]:{width:Math.round(t),height:Math.round(n),percentageHeight:100,percentageWidth:100,x:0,y:0,unit:sn.Nf.Pixel},[sn.Nf.AspectRatio]:{width:r.width,height:r.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:sn.Nf.AspectRatio}}}),A({type:"SET_LAST_RESIZE_SIZE",payload:{[sn.Nf.Pixel]:{width:t,height:n,unit:sn.Nf.Pixel},[sn.Nf.AspectRatio]:{width:r.width,height:r.height,unit:sn.Nf.AspectRatio}}})}),[g]),H=(0,wt.useCallback)((e=>{A({type:"SET_QUALITY",payload:e}),A({type:"SET_TRANSFORMATIONS",payload:{key:sn.YQ.Quality,value:{quality:e}}})}),[]),W=(0,wt.useCallback)((e=>{A({type:"SET_KEEP_METADATA",payload:e}),A({type:"SET_TRANSFORMATIONS",payload:{key:sn.YQ.KeepMetadata,value:{keepMetadata:e}}})}),[]);(0,wt.useEffect)((()=>{R&&0!==R.length?A({type:"SET_SELECTED_PROXY",payload:R[0].id}):A({type:"SET_SELECTED_PROXY",payload:""})}),[R,g]);const K=(0,wt.useCallback)((()=>{const e=E.isLoading||!E.selectedProxy&&!E.useCustomRendition&&!E.useRepresentative,i=(l&&null!==g&&void 0!==g&&g.docType?(0,an.A)([...l[g.docType],{displayName:"Automatic",value:s}],"value"):[{displayName:"Automatic",value:s}]).filter((e=>a||e.value!==s)),c=t&&i.length>0&&d.includes(g?g.extension:""),p=R&&Object.values(R).flat().length>0,f=Boolean(E.selectedFormat.width&&E.selectedFormat.height&&E.useCustomRendition);return(0,Vt.jsxs)(Vt.Fragment,{children:[E.showVersionHistory?(0,Vt.jsx)("cx-space",{slot:"label","justify-content":"space-between","align-items":"center",children:(0,Vt.jsxs)("cx-space",{direction:"vertical",spacing:"2x-small",style:{flex:"1"},children:[(0,Vt.jsx)("cx-typography",{variant:"h4",children:"Version history"}),(0,Vt.jsx)("cx-typography",{variant:"body3",className:"asset-name",children:(0,Vt.jsx)("cx-line-clamp",{lines:1,children:null===g||void 0===g?void 0:g.name})})]})}):(0,Vt.jsxs)(Vt.Fragment,{children:[(0,Vt.jsx)("cx-space",{slot:"label","justify-content":"space-between","align-items":"center",children:(0,Vt.jsxs)("cx-space",{direction:"vertical",spacing:"2x-small",style:{flex:"1"},children:[(0,Vt.jsx)("cx-typography",{variant:"h4",children:r?"Custom format":"Preview"}),(0,Vt.jsx)("cx-typography",{variant:"body3",className:"asset-name",children:(0,Vt.jsx)("cx-line-clamp",{lines:1,children:null===g||void 0===g?void 0:g.name})})]})}),n&&(0,Vt.jsx)("cx-tooltip",{slot:"header-actions",content:h?"Unfavorite":"Favorite",placement:"bottom",children:E.isLoadingFavorites?(0,Vt.jsx)("cx-space",{"align-items":"center","justify-content":"center",style:{width:"32px",height:"32px"},children:(0,Vt.jsx)("cx-spinner",{})}):(0,Vt.jsx)("cx-icon-button",{name:h?"star":"star_outline",style:{color:h?"var(--cx-color-warning)":"var(--cx-color-text)"},onClick:async()=>{E.isLoadingFavorites||(A({type:"SET_LOADING_FAVORITES",payload:!0}),h?await C():await S(),A({type:"SET_LOADING_FAVORITES",payload:!1}))}})}),v&&(0,Vt.jsx)("cx-tooltip",{slot:"header-actions",content:"Version history",placement:"bottom",children:(0,Vt.jsx)("cx-icon-button",{name:"history",onClick:V})})]}),(()=>{let e=null,t=null;if(e=E.selectedFormat.width&&E.selectedFormat.height&&(null===g||void 0===g?void 0:g.docType)!==Qt.zu.Video?(0,Vt.jsx)(Tn,{ref:D,loadable:E.previewLoadable,image:E.selectedFormat,selectedProxy:E.selectedProxy,resizer:E.resizeSize,cropper:E.cropSize,rotation:E.rotation,disabled:"crop"!==E.activeSetting||!E.showCustomRendition,onCropComplete:e=>{A({type:"SET_CROP_SIZE",payload:{percentageWidth:e.width,percentageHeight:e.height,x:e.x,y:e.y}})},onLoadingChange:I}):(0,Vt.jsx)($n,{loadable:E.previewLoadable,asset:{docType:null===g||void 0===g?void 0:g.docType,imageUrl:null===g||void 0===g?void 0:g.imageUrl,videoUrl:m,extension:null===g||void 0===g?void 0:g.extension},onLoad:e=>{if(null!==g&&void 0!==g&&g.width&&null!==g&&void 0!==g&&g.height||null===g||void 0===g||!g.imageUrl)return;const t=null!==g&&void 0!==g&&g.width?parseInt(g.width,10):e.width,n=null!==g&&void 0!==g&&g.height?parseInt(g.height,10):e.height;A({type:"SET_DEFAULT_SIZE",payload:{width:t,height:n}})}}),E.showVersionHistory)return(0,Vt.jsx)(tr,{assetId:null===g||void 0===g?void 0:g.id});if(!r)return e;var n;E.showCustomRendition&&R?t=(0,Vt.jsx)(Vn,{activeSetting:E.activeSetting,extensions:i,availableProxies:R,imageSize:{width:E.selectedFormat.width?E.selectedFormat.width:1/0,height:E.selectedFormat.height?E.selectedFormat.height:1/0},resize:{width:E.resizeSize.width,height:E.resizeSize.height,unit:E.resizeSize.unit},crop:E.cropSize,keepMetadata:E.keepMetadata,lastAppliedCrop:E.lastCropSize,lastAppliedResize:E.lastResizeSize,proxy:E.selectedProxy,quality:E.quality,rotation:E.rotation,extension:E.selectedFormat.extension,onCropChange:L,onExtensionChange:B,onFormatChange:q,onKeepMetadataChange:W,onQualityChange:H,onResizeChange:M,onRotateChange:F,onViewChange:U}):t=(0,Vt.jsx)("cx-space",{direction:"vertical",spacing:"small",children:p||c?(0,Vt.jsxs)("div",{style:{width:"100%"},children:[p&&(0,Vt.jsx)(Xn,{items:null===R||void 0===R?void 0:R.map((e=>{var t;return"TRX"===e.proxyName&&g?{value:e.id,name:e.proxyLabel,cdnName:e.cdnName,width:g.width,height:g.height,extension:g.extension,docType:g.docType}:{value:e.id,name:e.proxyLabel,cdnName:e.cdnName,width:String(e.formatWidth),height:String(e.formatHeight),extension:null!==(t=e.extension)&&void 0!==t?t:void 0,docType:null===g||void 0===g?void 0:g.docType}})),selectedDisabled:E.useCustomRendition,selectedItem:E.selectedProxy,children:N&&(0,Vt.jsxs)("cx-menu-item",{value:"use-representative",children:[(0,Vt.jsx)("cx-typography",{variant:"body3",className:"proxy__name "+(E.useRepresentative?"selected":""),children:"Representative image"}),(0,Vt.jsx)("cx-icon",{slot:"suffix",name:E.useRepresentative?"check":""})]})}),c&&(0,Vt.jsx)(Xn,{items:[],selectedItem:E.selectedProxy,style:{borderTopWidth:"0"},children:(0,Vt.jsxs)("cx-menu-item",{value:"custom","data-cy":"custom-rendition-menu-item",children:[(0,Vt.jsx)("cx-icon",{slot:"prefix",name:"crop_rotate",className:"icon--large"}),(0,Vt.jsxs)("div",{children:[(0,Vt.jsx)("cx-typography",{variant:"body3",className:"proxy__name "+(E.useCustomRendition?"selected":""),children:"Custom format"}),f?(0,Vt.jsxs)("cx-typography",{variant:"body3",className:"proxy__details",children:[E.selectedFormat.width," x"," ",E.selectedFormat.height,E.selectedFormat.extension&&(0,Vt.jsx)("div",{className:"proxy__extension-dot"}),null===(n=E.selectedFormat.extension)||void 0===n?void 0:n.replace(/^\./,"").toUpperCase()]}):null]}),(0,Vt.jsx)("cx-icon",{slot:"suffix",name:E.useCustomRendition?"edit":"",className:"icon--large"}),(0,Vt.jsx)("cx-icon",{slot:"suffix",name:E.useCustomRendition?"check":"",className:"icon--large icon--primary"})]})}),o&&(0,Vt.jsxs)("div",{style:{backgroundColor:"var(--cx-color-neutral-0)",width:"100%"},children:[(0,Vt.jsx)(Xn,{children:(0,Vt.jsxs)("cx-menu-item",{value:"tracking",className:"proxy--switch",children:[(0,Vt.jsx)("cx-typography",{variant:"body3",className:"proxy__name",children:"Tracking parameters"}),(0,Vt.jsx)("cx-switch",{checked:E.enabledTracking,onClick:e=>e.preventDefault()})]})}),E.enabledTracking&&(0,Vt.jsx)(Gn,{values:E.trackingParameters,onChange:e=>A({type:"SET_TRACKING_PARAMETERS",payload:e})})]})]}):(0,Vt.jsxs)("cx-space",{"align-items":"center",spacing:"large",wrap:"nowrap",style:{backgroundColor:"var(--cx-color-neutral-0)",width:"100%",padding:"var(--cx-spacing-medium)",gap:"20px"},children:[(0,Vt.jsx)("cx-icon",{style:{color:"var(--cx-color-warning)"},name:"warning",className:"ic_warning_amber"}),(0,Vt.jsx)("cx-typography",{variant:"body3",className:"proxy__name",children:"There are no available options for this asset. This might be due to your permissions or the application's settings."})]})});return(0,Vt.jsxs)(Vt.Fragment,{children:[e,t]})})(),(()=>{if(E.showVersionHistory)return null;let t=null;return t=r?E.showCustomRendition?(0,Vt.jsxs)("cx-space",{spacing:"small",style:{width:"fit-content"},children:[(0,Vt.jsx)("cx-button",{variant:"default",onClick:()=>{var e,t,n,r,o;E.useCustomRendition?A({type:"CANCEL_USE_CUSTOM_RENDITION",payload:{url:E.defaultSelectedFormat.url,originalUrl:E.defaultSelectedFormat.originalUrl,width:E.defaultSelectedFormat.width,height:E.defaultSelectedFormat.height,extension:E.defaultSelectedFormat.extension,useCustomRendition:!0}}):A({type:"CANCEL_USE_CUSTOM_RENDITION",payload:{url:null!==(e=null===g||void 0===g?void 0:g.imageUrl)&&void 0!==e?e:"",originalUrl:null!==(t=null===g||void 0===g?void 0:g.originalUrl)&&void 0!==t?t:"",width:parseInt(null!==(n=null===g||void 0===g?void 0:g.width)&&void 0!==n?n:"0",10),height:parseInt(null!==(r=null===g||void 0===g?void 0:g.height)&&void 0!==r?r:"0",10),extension:null!==(o=null===g||void 0===g?void 0:g.extension)&&void 0!==o?o:"",useCustomRendition:!1}})},children:"Cancel"}),(0,Vt.jsx)("cx-button",{variant:"primary",onClick:()=>{A({type:"CONFIRM_USE_CUSTOM_RENDITION"})},children:"Done"})]}):(0,Vt.jsx)("cx-button",{className:"dialog__footer__button",disabled:e,loading:E.isLoadingConfirm,variant:"primary",style:{flex:1},onClick:async()=>{const e=null===R||void 0===R?void 0:R.find((e=>e.id===E.selectedProxy));if(E.useCustomRendition){var t,n,r,o,i,a,s,l,c,u,d,h,p,f,m;if(null===g||void 0===g||!g.docType)return;A({type:"SET_LOADING_CONFIRM",payload:!0}),await _({value:E.transformations,parameters:E.enabledTracking?E.trackingParameters:void 0,proxiesPreference:null===e||void 0===e?void 0:e.proxyName,extension:E.selectedFormat.extension,sourceProxyMetadata:{cdnName:null!==(t=null===e||void 0===e?void 0:e.cdnName)&&void 0!==t?t:null,extension:"TRX"===(null===e||void 0===e?void 0:e.proxyName)?g.extension:null!==(n=null===e||void 0===e?void 0:e.extension)&&void 0!==n?n:null,isCustomFormat:null,width:"TRX"===(null===e||void 0===e?void 0:e.proxyName)?parseInt(null!==(r=g.width)&&void 0!==r?r:"0",10):null!==(o=null===e||void 0===e?void 0:e.formatWidth)&&void 0!==o?o:null,height:"TRX"===(null===e||void 0===e?void 0:e.proxyName)?parseInt(null!==(i=g.height)&&void 0!==i?i:"0",10):null!==(a=null===e||void 0===e?void 0:e.formatHeight)&&void 0!==a?a:null,permanentLink:null!==(s=null===e||void 0===e?void 0:e.permanentLink)&&void 0!==s?s:null,proxyLabel:null!==(l=null===e||void 0===e?void 0:e.proxyLabel)&&void 0!==l?l:null,proxyName:null!==(c=null===e||void 0===e?void 0:e.proxyName)&&void 0!==c?c:null},transformedAssetMetadata:{extension:null!==(u=null===(d=E.selectedFormat)||void 0===d?void 0:d.extension)&&void 0!==u?u:null,isCustomFormat:!0,height:null!==(h=null===(p=E.selectedFormat)||void 0===p?void 0:p.height)&&void 0!==h?h:null,width:null!==(f=null===(m=E.selectedFormat)||void 0===m?void 0:m.width)&&void 0!==f?f:null,permanentLink:null}}),A({type:"SET_LOADING_CONFIRM",payload:!1})}else{var v,b,y,x,S,C,T,O,P,z,D,j;if(null===g||void 0===g||!g.docType)return;if(!e&&!E.useRepresentative)return;A({type:"SET_LOADING_CONFIRM",payload:!0}),await k({extension:null!==(v=null===e||void 0===e?void 0:e.extension)&&void 0!==v?v:g.extension,value:null!==(b=null===e||void 0===e?void 0:e.proxyName)&&void 0!==b?b:"",permanentLink:null!==(y=null===e||void 0===e?void 0:e.permanentLink)&&void 0!==y?y:void 0,parameters:E.enabledTracking?E.trackingParameters:void 0,useRepresentative:E.useRepresentative,selectedProxyMetadata:{cdnName:null!==(x=null===e||void 0===e?void 0:e.cdnName)&&void 0!==x?x:null,extension:"TRX"===(null===e||void 0===e?void 0:e.proxyName)?g.extension:null!==(S=null===e||void 0===e?void 0:e.extension)&&void 0!==S?S:null,isCustomFormat:!1,width:"TRX"===(null===e||void 0===e?void 0:e.proxyName)?parseInt(null!==(C=g.width)&&void 0!==C?C:"0",10):null!==(T=null===e||void 0===e?void 0:e.formatWidth)&&void 0!==T?T:null,height:"TRX"===(null===e||void 0===e?void 0:e.proxyName)?parseInt(null!==(O=g.height)&&void 0!==O?O:"0",10):null!==(P=null===e||void 0===e?void 0:e.formatHeight)&&void 0!==P?P:null,permanentLink:null!==(z=null===e||void 0===e?void 0:e.permanentLink)&&void 0!==z?z:null,proxyLabel:null!==(D=null===e||void 0===e?void 0:e.proxyLabel)&&void 0!==D?D:null,proxyName:null!==(j=null===e||void 0===e?void 0:e.proxyName)&&void 0!==j?j:null}}),A({type:"SET_LOADING_CONFIRM",payload:!1})}A({type:"RESET_DATA"}),w()},children:null!==u&&void 0!==u?u:"Insert"}):(0,Vt.jsxs)("cx-button",{className:"dialog__footer__button",loading:E.isLoadingConfirm,onClick:async()=>{null!==g&&void 0!==g&&g.docType&&(A({type:"SET_LOADING_CONFIRM",payload:!0}),await k({extension:g.extension,useRepresentative:!0,value:""}),A({type:"SET_LOADING_CONFIRM",payload:!1}))},variant:"primary",children:[(0,Vt.jsx)("cx-icon",{slot:"prefix",name:"folder"}),u]}),(0,Vt.jsx)("div",{slot:"footer",className:"dialog__footer",children:t})})()]})}),[t,n,r,o,a,s,l,u,d,R,V,h,m,g,v,E,N,w,L,B,S,q,_,W,I,k,H,M,F,C,U]);return"drawer"===y?(0,Vt.jsx)(Hn,{ref:z,className:"dialog",label:"Drawer",placement:"bottom",contained:!0,open:f,children:K()}):(0,Vt.jsx)(qn,{ref:P,className:"dialog",open:f,"use-overlay-scrollbar":!0,style:{"--max-height":`${p}px`,"--max-width":E.showVersionHistory?"600px":"520px"},children:K()})};var ir=n(5650);const ar=(0,Ft.Ay)("cx-space")`
628
+ `;var Yn=n(3943);const Jn=e=>{let{src:t,alt:n}=e;const[r,o]=(0,wt.useState)("horizontal"),i=(0,wt.useRef)(null),a=(0,wt.useCallback)((()=>{if(i.current){const{naturalWidth:e,naturalHeight:t}=i.current;o(e>t?"horizontal":"vertical")}}),[]);return(0,Vt.jsx)("div",{className:`version__item__preview version__item__preview--${r}`,children:(0,Vt.jsx)("img",{ref:i,src:t,alt:n,onLoad:a})})},er=e=>{let{src:t}=e;const[n,r]=(0,wt.useState)("horizontal"),o=(0,wt.useRef)(null),i=(0,wt.useCallback)((()=>{if(o.current){const{videoWidth:e,videoHeight:t}=o.current;r(e>t?"horizontal":"vertical")}}),[]);return(0,Vt.jsx)("div",{className:`version__item__preview version__item__preview--${n}`,children:(0,Vt.jsx)("video",{ref:o,src:t,onLoadedMetadata:i,controls:!0})})},tr=e=>{var t;let{assetId:n}=e;const{data:r,isFetching:o,isLoading:i}=(0,Yn.cP)(n?{assetId:n}:Lt.hT);return o||i?(0,Vt.jsx)(Zn,{children:(0,Vt.jsx)("cx-spinner",{})}):(0,Vt.jsx)(Zn,{children:(0,Vt.jsx)("cx-menu",{children:null===r||void 0===r||null===(t=r.versions)||void 0===t?void 0:t.map(((e,t)=>(0,Vt.jsx)("cx-menu-item",{className:"version__item",readonly:!0,children:(0,Vt.jsxs)("cx-grid",{columns:5,spacing:"12px",children:[(0,Vt.jsx)("cx-grid-item",{xs:"2",sm:"2",children:(0,Vt.jsxs)("cx-space",{direction:"horizontal","align-items":"center",wrap:"nowrap",children:[(0,Vt.jsx)("div",{className:"version__item__number",children:(0,Vt.jsx)("cx-line-clamp",{lines:1,children:e.versionNumberDisplay})}),e.scrubUrl?(0,Vt.jsx)(er,{src:e.scrubUrl}):(0,Vt.jsx)(Jn,{src:e.versionFileUrl,alt:e.versionFileName})]})}),(0,Vt.jsx)("cx-grid-item",{xs:"2",sm:"3",children:(0,Vt.jsxs)("cx-space",{direction:"vertical",spacing:"2x-small",children:[(0,Vt.jsx)("cx-line-clamp",{lines:1,children:(0,Vt.jsx)("cx-typography",{variant:"body3",className:"version__item__name",children:e.versionFileName})}),(0,Vt.jsx)("cx-line-clamp",{lines:1,children:(0,Vt.jsx)("cx-typography",{variant:"body3",children:e.createByEmail})}),(0,Vt.jsxs)("cx-typography",{variant:"body3",children:[e.versionCreateDate.split(" ")[0],0===t&&(0,Vt.jsx)("span",{className:"version__item__latest",children:"Current version"})]})]})})]})},e.versionNumber)))})})},nr={previewLoadable:!1,defaultSize:{width:0,height:0},selectedProxy:"",selectedFormat:{url:"",originalUrl:"",width:0,height:0,x:0,y:0,extension:"",rotation:0},defaultSelectedFormat:{url:"",originalUrl:"",width:0,height:0,x:0,y:0,extension:"",rotation:0},resizeSize:{width:0,height:0,unit:sn.Nf.Pixel},lastResizeSize:{[sn.Nf.AspectRatio]:{width:0,height:0,unit:sn.Nf.AspectRatio},[sn.Nf.Pixel]:{width:0,height:0,unit:sn.Nf.Pixel}},cropSize:{width:0,height:0,percentageWidth:0,percentageHeight:0,x:0,y:0,unit:sn.Nf.Pixel},lastCropSize:{[sn.Nf.AspectRatio]:{width:0,height:0,percentageWidth:0,percentageHeight:0,x:0,y:0,unit:sn.Nf.AspectRatio},[sn.Nf.Pixel]:{width:0,height:0,percentageWidth:0,percentageHeight:0,x:0,y:0,unit:sn.Nf.Pixel}},isLoadingConfirm:!1,isLoadingFavorites:!1,rotation:0,quality:100,keepMetadata:!1,transformations:[],confirmedTransformations:[],enabledTracking:!1,trackingParameters:[{key:"UTM_source",value:""},{key:"UTM_campaign",value:""},{key:"UTM_description",value:""}],showCustomRendition:!1,showVersionHistory:!1,useCustomRendition:!1,useRepresentative:!1,activeSetting:"format",isLoading:!1},rr=(e,t)=>{switch(t.type){case"CANCEL_USE_CUSTOM_RENDITION":return{...e,cropSize:{...e.cropSize,width:t.payload.width,height:t.payload.height},resizeSize:{...e.resizeSize,width:t.payload.width,height:t.payload.height},selectedFormat:{...e.selectedFormat,...t.payload,rotation:0,x:0,y:0},rotation:0,transformations:e.useCustomRendition?e.confirmedTransformations:[],showCustomRendition:!1,activeSetting:"format"};case"CONFIRM_USE_CUSTOM_RENDITION":return{...e,confirmedTransformations:e.transformations,cropSize:{...e.cropSize,width:e.selectedFormat.width,height:e.selectedFormat.height},resizeSize:{...e.resizeSize,width:e.selectedFormat.width,height:e.selectedFormat.height},rotation:0,activeSetting:"format",showCustomRendition:!1,useCustomRendition:!0,defaultSelectedFormat:{...e.selectedFormat}};case"SET_DEFAULT_SIZE":return{...e,defaultSize:{...e.defaultSize,...t.payload}};case"RESET_DATA":return nr;case"SET_ACTIVE_SETTING":return{...e,activeSetting:t.payload};case"SET_CROP_SIZE":return{...e,cropSize:{...e.cropSize,...t.payload}};case"SET_ENABLED_TRACKING":return{...e,enabledTracking:t.payload};case"SET_KEEP_METADATA":return{...e,keepMetadata:t.payload};case"SET_LAST_CROP_SIZE":return{...e,lastCropSize:{...e.lastCropSize,...t.payload}};case"SET_LAST_RESIZE_SIZE":return{...e,lastResizeSize:{...e.lastResizeSize,...t.payload}};case"SET_LOADING":return{...e,isLoading:t.payload};case"SET_LOADING_CONFIRM":return{...e,isLoadingConfirm:t.payload};case"SET_LOADING_FAVORITES":return{...e,isLoadingFavorites:t.payload};case"SET_PREVIEW_LOADABLE":return{...e,previewLoadable:t.payload};case"SET_QUALITY":return{...e,quality:t.payload};case"SET_RESIZE_SIZE":return{...e,resizeSize:{...e.resizeSize,...t.payload}};case"SET_ROTATION":return{...e,rotation:t.payload};case"SET_SELECTED_FORMAT":return{...e,selectedFormat:{...e.selectedFormat,...t.payload}};case"SET_SELECTED_PROXY":return t.payload?"string"===typeof t.payload?{...e,selectedProxy:t.payload,useCustomRendition:!1,useRepresentative:!1}:{...e,selectedProxy:t.payload.proxy,useCustomRendition:Boolean(t.payload.useCustomRendition),useRepresentative:!1}:{...e,selectedProxy:"",useCustomRendition:!1,useRepresentative:!1};case"SET_SHOW_CUSTOM_RENDITION":return{...e,selectedProxy:"",showCustomRendition:t.payload};case"SET_SHOW_VERSION_HISTORY":return{...e,showVersionHistory:t.payload};case"SET_TRACKING_PARAMETERS":return{...e,trackingParameters:t.payload};case"SET_TRANSFORMATIONS":return{...e,transformations:[...e.transformations,t.payload]};case"SET_USE_REPRESENTATIVE":return{...e,selectedProxy:t.payload?"":e.selectedProxy,useRepresentative:t.payload};default:return e}},or=e=>{let{allowCustomFormat:t,allowFavorites:n,allowProxy:r,allowTracking:o,allowedExtensions:i,appendAutoExtension:a,autoExtension:s,availableExtensions:l,availableProxies:c,ctaText:u="Insert",extensions:d,isFavorite:h,maxHeight:p,open:f,previewUrl:m,selectedAsset:g,showVersions:v,supportedRepresentativeSubtypes:b,variant:y="dialog",boundary:x,onClose:w,onFavorite:S,onProxyConfirm:k,onFormatConfirm:_,onUnFavorite:C}=e;const[E,A]=(0,wt.useReducer)(rr,nr),[T,O]=(0,wt.useState)(!1),P=(0,wt.useRef)(null),z=(0,wt.useRef)(null),D=(0,wt.useRef)(null),R=(0,wt.useMemo)((()=>i?c?c.filter((e=>{if(!e.extension&&g){return!!(null===i||void 0===i?void 0:i.some((e=>e===g.extension.replace(/^\./,""))))}return!0})):[]:c),[c,i,g]),j=(0,wt.useCallback)((()=>{if(!g)return;const e=ln(E.defaultSize.width,E.defaultSize.height);A({type:"SET_RESIZE_SIZE",payload:{...nr.resizeSize,width:E.defaultSize.width,height:E.defaultSize.height}}),A({type:"SET_CROP_SIZE",payload:{...nr.cropSize,width:E.defaultSize.width,height:E.defaultSize.height,percentageHeight:100,percentageWidth:100}}),A({type:"SET_ROTATION",payload:0}),A({type:"SET_LAST_CROP_SIZE",payload:{...nr.lastCropSize,[sn.Nf.Pixel]:{width:E.defaultSize.width,height:E.defaultSize.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:sn.Nf.Pixel},[sn.Nf.AspectRatio]:{width:e.width,height:e.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:sn.Nf.AspectRatio}}}),A({type:"SET_LAST_RESIZE_SIZE",payload:{[sn.Nf.Pixel]:{width:E.defaultSize.width,height:E.defaultSize.height,unit:sn.Nf.Pixel},[sn.Nf.AspectRatio]:{width:e.width,height:e.height,unit:sn.Nf.AspectRatio}}});let t=g.extension;if(a)t=s;else if(g.docType){var n,r,o,i;if(null!==l&&void 0!==l&&null!==(n=l[g.docType])&&void 0!==n&&n.map((e=>e.value)).includes(g.extension))t=g.extension;else t=null!==(r=null===l||void 0===l||null===(o=l[g.docType])||void 0===o||null===(i=o[0])||void 0===i?void 0:i.value)&&void 0!==r?r:""}var c;R&&R.length>0?(A({type:"SET_SELECTED_PROXY",payload:null===(c=R[0])||void 0===c?void 0:c.id}),A({type:"SET_SELECTED_FORMAT",payload:{...nr.selectedFormat,url:g.imageUrl,originalUrl:g.originalUrl,extension:t,width:R[0].formatWidth||E.defaultSize.width,height:R[0].formatHeight||E.defaultSize.height}})):A({type:"SET_SELECTED_FORMAT",payload:{...nr.selectedFormat,url:g.imageUrl,originalUrl:g.originalUrl,extension:t,width:E.defaultSize.width,height:E.defaultSize.height}})}),[s,R,g,E.defaultSize.height,E.defaultSize.width,a,l]);(0,wt.useEffect)((()=>{null!==g&&void 0!==g&&g.width&&null!==g&&void 0!==g&&g.height&&A({type:"SET_DEFAULT_SIZE",payload:{width:parseInt(g.width,10),height:parseInt(g.height,10)}})}),[null===g||void 0===g?void 0:g.width,null===g||void 0===g?void 0:g.height]),(0,wt.useEffect)((()=>{Promise.all([customElements.whenDefined("cx-dialog"),customElements.whenDefined("cx-drawer"),customElements.whenDefined("cx-dropdown")]).then((()=>{O(!0)}))}),[]),(0,wt.useEffect)((()=>{const e=e=>{E.isLoadingFavorites?e.preventDefault():E.showVersionHistory?(e.preventDefault(),A({type:"SET_SHOW_VERSION_HISTORY",payload:!1})):(A({type:"SET_PREVIEW_LOADABLE",payload:!1}),A({type:"RESET_DATA"}),w())},t=P.current,n=z.current;return null===t||void 0===t||t.addEventListener("cx-request-close",e),null===n||void 0===n||n.addEventListener("cx-request-close",e),()=>{null===t||void 0===t||t.removeEventListener("cx-request-close",e),null===n||void 0===n||n.removeEventListener("cx-request-close",e)}}),[x,T,w,E.isLoadingFavorites,E.showVersionHistory]),(0,wt.useEffect)((()=>{const e=P.current;e&&x&&(e.boundary=x)})),(0,wt.useEffect)((()=>{const e=()=>{A({type:"SET_PREVIEW_LOADABLE",payload:!0})},t=P.current,n=z.current;return null===t||void 0===t||t.addEventListener("cx-after-show",e),null===n||void 0===n||n.addEventListener("cx-after-show",e),()=>{null===t||void 0===t||t.removeEventListener("cx-after-show",e),null===n||void 0===n||n.removeEventListener("cx-after-show",e)}}),[T,E.showCustomRendition,y]),(0,wt.useEffect)((()=>{const e=e=>{const t=e.detail.item.value;if("custom"===t)return A({type:"SET_SHOW_CUSTOM_RENDITION",payload:!0}),void(E.useCustomRendition||j());if("tracking"!==t)if("use-representative"!==t){if(t&&R){if(!R.map((e=>e.id)).includes(t))return;A({type:"SET_SELECTED_PROXY",payload:t})}}else A({type:"SET_USE_REPRESENTATIVE",payload:!E.useRepresentative});else A({type:"SET_ENABLED_TRACKING",payload:!E.enabledTracking})},t=P.current,n=z.current;return null===t||void 0===t||t.addEventListener("cx-select",e),null===n||void 0===n||n.addEventListener("cx-select",e),()=>{null===t||void 0===t||t.removeEventListener("cx-select",e),null===n||void 0===n||n.removeEventListener("cx-select",e)}}),[T,E.enabledTracking,E.useCustomRendition,E.useRepresentative,j,R,null===g||void 0===g?void 0:g.extension]),(0,wt.useEffect)((()=>{j()}),[j]);const N=(0,wt.useMemo)((()=>{var e;return(null===b||void 0===b?void 0:b.includes(null!==(e=null===g||void 0===g?void 0:g.docSubType)&&void 0!==e?e:""))&&(null===g||void 0===g?void 0:g.imageUrl)}),[g,b]),I=(0,wt.useCallback)((e=>{A({type:"SET_LOADING",payload:e})}),[]),M=(0,wt.useCallback)((async(e,t,n,r)=>{if(!g)return;const o=E.selectedFormat.width||E.defaultSize.width,i=E.selectedFormat.height||E.defaultSize.height;if(A({type:"SET_RESIZE_SIZE",payload:{width:e,height:t,unit:n}}),r){var a;let r=e,s=t;E.resizeSize.unit!==n?(r=o,s=i):n===sn.Nf.AspectRatio&&(r=Math.round(e/t*i),s=i);const l=await(null===(a=D.current)||void 0===a?void 0:a.applyResize());A({type:"SET_SELECTED_FORMAT",payload:{url:l,width:r,height:s}}),A({type:"SET_TRANSFORMATIONS",payload:{key:sn.YQ.Resize,value:{width:r,height:s}}}),A({type:"SET_CROP_SIZE",payload:{width:r,height:s}});const c=ln(r,s);A({type:"SET_LAST_RESIZE_SIZE",payload:{[sn.Nf.Pixel]:{width:r,height:s,unit:sn.Nf.Pixel},[sn.Nf.AspectRatio]:{width:n===sn.Nf.AspectRatio?e:c.width,height:n===sn.Nf.AspectRatio?t:c.height,unit:sn.Nf.AspectRatio}}}),A({type:"SET_LAST_CROP_SIZE",payload:{[sn.Nf.Pixel]:{width:r,height:s,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:sn.Nf.Pixel},[sn.Nf.AspectRatio]:{width:n===sn.Nf.AspectRatio?e:c.width,height:n===sn.Nf.AspectRatio?t:c.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:sn.Nf.AspectRatio}}})}}),[g,E.defaultSize.height,E.defaultSize.width,E.resizeSize.unit,E.selectedFormat.height,E.selectedFormat.width]),L=(0,wt.useCallback)((async(e,t,n,r)=>{var o,i;if(!g)return;const a=E.cropSize.unit,s=D.current;if(s&&null!==(o=E.selectedFormat)&&void 0!==o&&o.width&&null!==(i=E.selectedFormat)&&void 0!==i&&i.height){if(n===a&&n===sn.Nf.Pixel){const n=Math.max(e/E.selectedFormat.width,t/E.selectedFormat.height);s.setZoom(1/n)}n!==a&&s.setZoom(1)}if(A({type:"SET_CROP_SIZE",payload:{width:e,height:t,unit:n}}),r){var l;const r=await(null===(l=D.current)||void 0===l?void 0:l.applyCrop());let o=e,i=t;n===sn.Nf.AspectRatio&&(o=Math.round(E.cropSize.percentageWidth*E.selectedFormat.width/100),i=Math.round(E.cropSize.percentageHeight*E.selectedFormat.height/100)),null===s||void 0===s||s.setZoom(1);const a=Number((E.cropSize.x/100*E.selectedFormat.width).toFixed(0)),c=Number((E.cropSize.y/100*E.selectedFormat.height).toFixed(0));A({type:"SET_SELECTED_FORMAT",payload:{url:r,width:o,height:i}}),A({type:"SET_RESIZE_SIZE",payload:{width:o,height:i,unit:sn.Nf.Pixel}}),A({type:"SET_TRANSFORMATIONS",payload:{key:sn.YQ.Crop,value:{width:Number(o.toFixed(0)),height:Number(i.toFixed(0)),x:a,y:c}}});const u=ln(o,i);A({type:"SET_LAST_CROP_SIZE",payload:{[sn.Nf.Pixel]:{width:Math.round(o),height:Math.round(i),percentageHeight:100,percentageWidth:100,x:0,y:0,unit:sn.Nf.Pixel},[sn.Nf.AspectRatio]:{width:n===sn.Nf.AspectRatio?e:u.width,height:n===sn.Nf.AspectRatio?t:u.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:sn.Nf.AspectRatio}}}),A({type:"SET_LAST_RESIZE_SIZE",payload:{[sn.Nf.Pixel]:{width:o,height:i,unit:sn.Nf.Pixel},[sn.Nf.AspectRatio]:{width:n===sn.Nf.AspectRatio?e:u.width,height:n===sn.Nf.AspectRatio?t:u.height,unit:sn.Nf.AspectRatio}}})}}),[g,E.cropSize,E.selectedFormat.height,E.selectedFormat.width]),F=(0,wt.useCallback)((async(e,t)=>{if(A({type:"SET_ROTATION",payload:t?0:e}),t){var n;const{width:t,height:r}=cn(E.selectedFormat.width,E.selectedFormat.height,e),o=await(null===(n=D.current)||void 0===n?void 0:n.applyRotation());A({type:"SET_SELECTED_FORMAT",payload:{rotation:e,url:o,width:t,height:r}}),A({type:"SET_TRANSFORMATIONS",payload:{key:sn.YQ.Rotate,value:{rotation:e}}}),A({type:"SET_CROP_SIZE",payload:{width:t,height:r}}),A({type:"SET_RESIZE_SIZE",payload:{width:t,height:r,unit:sn.Nf.Pixel}});const i=ln(t,r);A({type:"SET_LAST_CROP_SIZE",payload:{[sn.Nf.Pixel]:{width:t,height:r,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:sn.Nf.Pixel},[sn.Nf.AspectRatio]:{width:i.width,height:i.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:sn.Nf.AspectRatio}}}),A({type:"SET_LAST_RESIZE_SIZE",payload:{[sn.Nf.Pixel]:{width:t,height:r,unit:sn.Nf.Pixel},[sn.Nf.AspectRatio]:{width:i.width,height:i.height,unit:sn.Nf.AspectRatio}}})}}),[E.selectedFormat]),B=(0,wt.useCallback)((e=>{A({type:"SET_SELECTED_FORMAT",payload:{extension:e}})}),[]),U=(0,wt.useCallback)((e=>{A({type:"SET_CROP_SIZE",payload:{width:E.selectedFormat.width,height:E.selectedFormat.height,unit:sn.Nf.Pixel}}),A({type:"SET_RESIZE_SIZE",payload:{width:E.selectedFormat.width,height:E.selectedFormat.height,unit:sn.Nf.Pixel}}),A({type:"SET_ROTATION",payload:0}),A({type:"SET_ACTIVE_SETTING",payload:e})}),[E.selectedFormat]),V=(0,wt.useCallback)((()=>{A({type:"SET_SHOW_VERSION_HISTORY",payload:!0})}),[]),q=(0,wt.useCallback)((e=>{let t=e.formatWidth,n=e.formatHeight;"TRX"===e.proxyName&&g&&(t=Number(g.width),n=Number(g.height)),A({type:"SET_SELECTED_PROXY",payload:{proxy:e.id,useCustomRendition:!0}}),A({type:"SET_SELECTED_FORMAT",payload:{width:t,height:n}}),A({type:"SET_RESIZE_SIZE",payload:{width:t,height:n,unit:sn.Nf.Pixel}}),A({type:"SET_CROP_SIZE",payload:{width:t,height:n,percentageWidth:100,percentageHeight:100,x:0,y:0,unit:sn.Nf.Pixel}});const r=ln(t,n);A({type:"SET_LAST_CROP_SIZE",payload:{[sn.Nf.Pixel]:{width:Math.round(t),height:Math.round(n),percentageHeight:100,percentageWidth:100,x:0,y:0,unit:sn.Nf.Pixel},[sn.Nf.AspectRatio]:{width:r.width,height:r.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:sn.Nf.AspectRatio}}}),A({type:"SET_LAST_RESIZE_SIZE",payload:{[sn.Nf.Pixel]:{width:t,height:n,unit:sn.Nf.Pixel},[sn.Nf.AspectRatio]:{width:r.width,height:r.height,unit:sn.Nf.AspectRatio}}})}),[g]),H=(0,wt.useCallback)((e=>{A({type:"SET_QUALITY",payload:e}),A({type:"SET_TRANSFORMATIONS",payload:{key:sn.YQ.Quality,value:{quality:e}}})}),[]),W=(0,wt.useCallback)((e=>{A({type:"SET_KEEP_METADATA",payload:e}),A({type:"SET_TRANSFORMATIONS",payload:{key:sn.YQ.KeepMetadata,value:{keepMetadata:e}}})}),[]);(0,wt.useEffect)((()=>{R&&0!==R.length?A({type:"SET_SELECTED_PROXY",payload:R[0].id}):A({type:"SET_SELECTED_PROXY",payload:""})}),[R,g]);const K=(0,wt.useCallback)((()=>{const e=E.isLoading||!E.selectedProxy&&!E.useCustomRendition&&!E.useRepresentative,i=(l&&null!==g&&void 0!==g&&g.docType?(0,an.A)([...l[g.docType],{displayName:"Automatic",value:s}],"value"):[{displayName:"Automatic",value:s}]).filter((e=>a||e.value!==s)),c=t&&i.length>0&&d.includes(g?g.extension:""),p=R&&Object.values(R).flat().length>0,f=Boolean(E.selectedFormat.width&&E.selectedFormat.height&&E.useCustomRendition);return(0,Vt.jsxs)(Vt.Fragment,{children:[E.showVersionHistory?(0,Vt.jsx)("cx-space",{slot:"label","justify-content":"space-between","align-items":"center",children:(0,Vt.jsxs)("cx-space",{direction:"vertical",spacing:"2x-small",style:{flex:"1"},children:[(0,Vt.jsx)("cx-typography",{variant:"h4",children:"Version history"}),(0,Vt.jsx)("cx-typography",{variant:"body3",className:"asset-name",children:(0,Vt.jsx)("cx-line-clamp",{lines:1,children:null===g||void 0===g?void 0:g.name})})]})}):(0,Vt.jsxs)(Vt.Fragment,{children:[(0,Vt.jsx)("cx-space",{slot:"label","justify-content":"space-between","align-items":"center",children:(0,Vt.jsxs)("cx-space",{direction:"vertical",spacing:"2x-small",style:{flex:"1"},children:[(0,Vt.jsx)("cx-typography",{variant:"h4",children:r?"Custom format":"Preview"}),(0,Vt.jsx)("cx-typography",{variant:"body3",className:"asset-name",children:(0,Vt.jsx)("cx-line-clamp",{lines:1,children:null===g||void 0===g?void 0:g.name})})]})}),n&&(0,Vt.jsx)("cx-tooltip",{slot:"header-actions",content:h?"Unfavorite":"Favorite",placement:"bottom",children:E.isLoadingFavorites?(0,Vt.jsx)("cx-space",{"align-items":"center","justify-content":"center",style:{width:"32px",height:"32px"},children:(0,Vt.jsx)("cx-spinner",{})}):(0,Vt.jsx)("cx-icon-button",{name:h?"star":"star_outline",style:{color:h?"var(--cx-color-warning)":"var(--cx-color-text)"},onClick:async()=>{E.isLoadingFavorites||(A({type:"SET_LOADING_FAVORITES",payload:!0}),h?await C():await S(),A({type:"SET_LOADING_FAVORITES",payload:!1}))}})}),v&&(0,Vt.jsx)("cx-tooltip",{slot:"header-actions",content:"Version history",placement:"bottom",children:(0,Vt.jsx)("cx-icon-button",{name:"history",onClick:V})})]}),(()=>{let e=null,t=null;if(e=E.selectedFormat.width&&E.selectedFormat.height&&(null===g||void 0===g?void 0:g.docType)!==Qt.zu.Video?(0,Vt.jsx)(Tn,{ref:D,loadable:E.previewLoadable,image:E.selectedFormat,selectedProxy:E.selectedProxy,resizer:E.resizeSize,cropper:E.cropSize,rotation:E.rotation,disabled:"crop"!==E.activeSetting||!E.showCustomRendition,onCropComplete:e=>{A({type:"SET_CROP_SIZE",payload:{percentageWidth:e.width,percentageHeight:e.height,x:e.x,y:e.y}})},onLoadingChange:I}):(0,Vt.jsx)($n,{loadable:E.previewLoadable,asset:{docType:null===g||void 0===g?void 0:g.docType,imageUrl:null===g||void 0===g?void 0:g.imageUrl,videoUrl:m,extension:null===g||void 0===g?void 0:g.extension},onLoad:e=>{if(null!==g&&void 0!==g&&g.width&&null!==g&&void 0!==g&&g.height||null===g||void 0===g||!g.imageUrl)return;const t=null!==g&&void 0!==g&&g.width?parseInt(g.width,10):e.width,n=null!==g&&void 0!==g&&g.height?parseInt(g.height,10):e.height;A({type:"SET_DEFAULT_SIZE",payload:{width:t,height:n}})}}),E.showVersionHistory)return(0,Vt.jsx)(tr,{assetId:null===g||void 0===g?void 0:g.id});if(!r)return e;var n;E.showCustomRendition&&R?t=(0,Vt.jsx)(Vn,{activeSetting:E.activeSetting,extensions:i,availableProxies:R,imageSize:{width:E.selectedFormat.width?E.selectedFormat.width:1/0,height:E.selectedFormat.height?E.selectedFormat.height:1/0},resize:{width:E.resizeSize.width,height:E.resizeSize.height,unit:E.resizeSize.unit},crop:E.cropSize,keepMetadata:E.keepMetadata,lastAppliedCrop:E.lastCropSize,lastAppliedResize:E.lastResizeSize,proxy:E.selectedProxy,quality:E.quality,rotation:E.rotation,extension:E.selectedFormat.extension,onCropChange:L,onExtensionChange:B,onFormatChange:q,onKeepMetadataChange:W,onQualityChange:H,onResizeChange:M,onRotateChange:F,onViewChange:U}):t=(0,Vt.jsx)("cx-space",{direction:"vertical",spacing:"small",children:p||c?(0,Vt.jsxs)("div",{style:{width:"100%"},children:[p&&(0,Vt.jsx)(Xn,{items:null===R||void 0===R?void 0:R.map((e=>{var t;return"TRX"===e.proxyName&&g?{value:e.id,name:e.proxyLabel,cdnName:e.cdnName,width:g.width,height:g.height,extension:g.extension,docType:g.docType}:{value:e.id,name:e.proxyLabel,cdnName:e.cdnName,width:String(e.formatWidth),height:String(e.formatHeight),extension:null!==(t=e.extension)&&void 0!==t?t:void 0,docType:null===g||void 0===g?void 0:g.docType}})),selectedDisabled:E.useCustomRendition,selectedItem:E.selectedProxy,children:N&&(0,Vt.jsxs)("cx-menu-item",{value:"use-representative",children:[(0,Vt.jsx)("cx-typography",{variant:"body3",className:"proxy__name "+(E.useRepresentative?"selected":""),children:"Representative image"}),(0,Vt.jsx)("cx-icon",{slot:"suffix",name:E.useRepresentative?"check":""})]})}),c&&(0,Vt.jsx)(Xn,{items:[],selectedItem:E.selectedProxy,style:{borderTopWidth:"0"},children:(0,Vt.jsxs)("cx-menu-item",{value:"custom","data-cy":"custom-rendition-menu-item",children:[(0,Vt.jsx)("cx-icon",{slot:"prefix",name:"crop_rotate",className:"icon--large"}),(0,Vt.jsxs)("div",{children:[(0,Vt.jsx)("cx-typography",{variant:"body3",className:"proxy__name "+(E.useCustomRendition?"selected":""),children:"Custom format"}),f?(0,Vt.jsxs)("cx-typography",{variant:"body3",className:"proxy__details",children:[E.selectedFormat.width," x"," ",E.selectedFormat.height,E.selectedFormat.extension&&(0,Vt.jsx)("div",{className:"proxy__extension-dot"}),null===(n=E.selectedFormat.extension)||void 0===n?void 0:n.replace(/^\./,"").toUpperCase()]}):null]}),(0,Vt.jsx)("cx-icon",{slot:"suffix",name:E.useCustomRendition?"edit":"",className:"icon--large"}),(0,Vt.jsx)("cx-icon",{slot:"suffix",name:E.useCustomRendition?"check":"",className:"icon--large icon--primary"})]})}),o&&(0,Vt.jsxs)("div",{style:{backgroundColor:"var(--cx-color-neutral-0)",width:"100%"},children:[(0,Vt.jsx)(Xn,{children:(0,Vt.jsxs)("cx-menu-item",{value:"tracking",className:"proxy--switch",children:[(0,Vt.jsx)("cx-typography",{variant:"body3",className:"proxy__name",children:"Tracking parameters"}),(0,Vt.jsx)("cx-switch",{checked:E.enabledTracking,onClick:e=>e.preventDefault()})]})}),E.enabledTracking&&(0,Vt.jsx)(Gn,{values:E.trackingParameters,onChange:e=>A({type:"SET_TRACKING_PARAMETERS",payload:e})})]})]}):(0,Vt.jsxs)("cx-space",{"align-items":"center",spacing:"large",wrap:"nowrap",style:{backgroundColor:"var(--cx-color-neutral-0)",width:"100%",padding:"var(--cx-spacing-medium)",gap:"20px"},children:[(0,Vt.jsx)("cx-icon",{style:{color:"var(--cx-color-warning)"},name:"warning",className:"ic_warning_amber"}),(0,Vt.jsx)("cx-typography",{variant:"body3",className:"proxy__name",children:"There are no available options for this asset. This might be due to your permissions or the application's settings."})]})});return(0,Vt.jsxs)(Vt.Fragment,{children:[e,t]})})(),(()=>{if(E.showVersionHistory)return null;let t=null;return t=r?E.showCustomRendition?(0,Vt.jsxs)("cx-space",{spacing:"small",style:{width:"fit-content"},children:[(0,Vt.jsx)("cx-button",{variant:"default",onClick:()=>{var e,t,n,r,o;E.useCustomRendition?A({type:"CANCEL_USE_CUSTOM_RENDITION",payload:{url:E.defaultSelectedFormat.url,originalUrl:E.defaultSelectedFormat.originalUrl,width:E.defaultSelectedFormat.width,height:E.defaultSelectedFormat.height,extension:E.defaultSelectedFormat.extension,useCustomRendition:!0}}):A({type:"CANCEL_USE_CUSTOM_RENDITION",payload:{url:null!==(e=null===g||void 0===g?void 0:g.imageUrl)&&void 0!==e?e:"",originalUrl:null!==(t=null===g||void 0===g?void 0:g.originalUrl)&&void 0!==t?t:"",width:parseInt(null!==(n=null===g||void 0===g?void 0:g.width)&&void 0!==n?n:"0",10),height:parseInt(null!==(r=null===g||void 0===g?void 0:g.height)&&void 0!==r?r:"0",10),extension:null!==(o=null===g||void 0===g?void 0:g.extension)&&void 0!==o?o:"",useCustomRendition:!1}})},children:"Cancel"}),(0,Vt.jsx)("cx-button",{variant:"primary",onClick:()=>{A({type:"CONFIRM_USE_CUSTOM_RENDITION"})},children:"Done"})]}):(0,Vt.jsx)("cx-button",{className:"dialog__footer__button",disabled:e,loading:E.isLoadingConfirm,variant:"primary",style:{flex:1},onClick:async()=>{const e=null===R||void 0===R?void 0:R.find((e=>e.id===E.selectedProxy));if(E.useCustomRendition){var t,n,r,o,i,a,s,l,c,u,d,h,p,f,m;if(null===g||void 0===g||!g.docType)return;A({type:"SET_LOADING_CONFIRM",payload:!0}),await _({value:E.transformations,parameters:E.enabledTracking?E.trackingParameters:void 0,proxiesPreference:null===e||void 0===e?void 0:e.proxyName,extension:E.selectedFormat.extension,sourceProxyMetadata:{cdnName:null!==(t=null===e||void 0===e?void 0:e.cdnName)&&void 0!==t?t:null,extension:"TRX"===(null===e||void 0===e?void 0:e.proxyName)?g.extension:null!==(n=null===e||void 0===e?void 0:e.extension)&&void 0!==n?n:null,isCustomFormat:null,width:"TRX"===(null===e||void 0===e?void 0:e.proxyName)?parseInt(null!==(r=g.width)&&void 0!==r?r:"0",10):null!==(o=null===e||void 0===e?void 0:e.formatWidth)&&void 0!==o?o:null,height:"TRX"===(null===e||void 0===e?void 0:e.proxyName)?parseInt(null!==(i=g.height)&&void 0!==i?i:"0",10):null!==(a=null===e||void 0===e?void 0:e.formatHeight)&&void 0!==a?a:null,permanentLink:null!==(s=null===e||void 0===e?void 0:e.permanentLink)&&void 0!==s?s:null,proxyLabel:null!==(l=null===e||void 0===e?void 0:e.proxyLabel)&&void 0!==l?l:null,proxyName:null!==(c=null===e||void 0===e?void 0:e.proxyName)&&void 0!==c?c:null},transformedAssetMetadata:{extension:null!==(u=null===(d=E.selectedFormat)||void 0===d?void 0:d.extension)&&void 0!==u?u:null,isCustomFormat:!0,height:null!==(h=null===(p=E.selectedFormat)||void 0===p?void 0:p.height)&&void 0!==h?h:null,width:null!==(f=null===(m=E.selectedFormat)||void 0===m?void 0:m.width)&&void 0!==f?f:null,permanentLink:null}}),A({type:"SET_LOADING_CONFIRM",payload:!1})}else{var v,b,y,x,S,C,T,O,P,z,D,j;if(null===g||void 0===g||!g.docType)return;if(!e&&!E.useRepresentative)return;A({type:"SET_LOADING_CONFIRM",payload:!0}),await k({extension:null!==(v=null===e||void 0===e?void 0:e.extension)&&void 0!==v?v:g.extension,value:null!==(b=null===e||void 0===e?void 0:e.proxyName)&&void 0!==b?b:"",permanentLink:null!==(y=null===e||void 0===e?void 0:e.permanentLink)&&void 0!==y?y:void 0,parameters:E.enabledTracking?E.trackingParameters:void 0,useRepresentative:E.useRepresentative,selectedProxyMetadata:{cdnName:null!==(x=null===e||void 0===e?void 0:e.cdnName)&&void 0!==x?x:null,extension:"TRX"===(null===e||void 0===e?void 0:e.proxyName)?g.extension:null!==(S=null===e||void 0===e?void 0:e.extension)&&void 0!==S?S:null,isCustomFormat:!1,width:"TRX"===(null===e||void 0===e?void 0:e.proxyName)?parseInt(null!==(C=g.width)&&void 0!==C?C:"0",10):null!==(T=null===e||void 0===e?void 0:e.formatWidth)&&void 0!==T?T:null,height:"TRX"===(null===e||void 0===e?void 0:e.proxyName)?parseInt(null!==(O=g.height)&&void 0!==O?O:"0",10):null!==(P=null===e||void 0===e?void 0:e.formatHeight)&&void 0!==P?P:null,permanentLink:null!==(z=null===e||void 0===e?void 0:e.permanentLink)&&void 0!==z?z:null,proxyLabel:null!==(D=null===e||void 0===e?void 0:e.proxyLabel)&&void 0!==D?D:null,proxyName:null!==(j=null===e||void 0===e?void 0:e.proxyName)&&void 0!==j?j:null}}),A({type:"SET_LOADING_CONFIRM",payload:!1})}A({type:"RESET_DATA"}),w()},children:null!==u&&void 0!==u?u:"Insert"}):(0,Vt.jsxs)("cx-button",{className:"dialog__footer__button",loading:E.isLoadingConfirm,onClick:async()=>{null!==g&&void 0!==g&&g.docType&&(A({type:"SET_LOADING_CONFIRM",payload:!0}),await k({extension:g.extension,useRepresentative:!0,value:""}),A({type:"SET_LOADING_CONFIRM",payload:!1}))},variant:"primary",children:[(0,Vt.jsx)("cx-icon",{slot:"prefix",name:"folder"}),u]}),(0,Vt.jsx)("div",{slot:"footer",className:"dialog__footer",children:t})})()]})}),[t,n,r,o,a,s,l,u,d,R,V,h,m,g,v,E,N,w,L,B,S,q,_,W,I,k,H,M,F,C,U]);return"drawer"===y?(0,Vt.jsx)(Hn,{ref:z,className:"dialog",label:"Drawer",placement:"bottom",contained:!0,open:f,children:K()}):(0,Vt.jsx)(qn,{ref:P,className:"dialog",open:f,"use-overlay-scrollbar":!0,style:{"--max-height":`${p}px`,"--max-width":E.showVersionHistory?"600px":"520px"},children:K()})};var ir=n(5650);const ar=(0,Ft.Ay)("cx-space")`
625
629
  border-bottom: ${e=>{let{bordered:t}=e;return t?"1px solid var(--cx-color-neutral-300)":"none"}};
626
630
  padding: var(--cx-spacing-medium);
627
631
 
@@ -813,7 +817,7 @@
813
817
  transition: none;
814
818
  }
815
819
  }
816
- `,Or=e=>{let{alt:t,url:n,loaded:r,originalUrl:o,onError:i,onLoaded:a}=e;return(0,Vt.jsxs)("div",{className:o&&r?"asset-preview__representative-container":void 0,children:[(0,Vt.jsx)("img",{className:"asset-preview__representative",src:n,alt:t,onLoad:a,onError:i}),o&&(0,Vt.jsx)("img",{className:"asset-preview__representative asset-preview__representative--animated",src:o,alt:t,onLoad:a,onError:i})]})},Pr=e=>{let{url:t,thumbnailOnly:n,thumbnailUrl:r,onError:o,loaded:i,onLoaded:a}=e;const[s,l]=(0,wt.useState)("horizontal"),c=(0,wt.useRef)(null),u=(0,wt.useRef)(null),d=(0,wt.useRef)(null),h=(0,wt.useRef)(null);(0,wt.useEffect)((()=>{var e;if(n)return;const t=null===(e=c.current)||void 0===e?void 0:e.parentElement,r=d.current,o=h.current;if(!t||!r||!o)return;const i=e=>{r.duration&&e.currentTarget===t&&(o.value=e.offsetX/t.offsetWidth*100,r.currentTime=e.offsetX/t.offsetWidth*r.duration)},a=e=>{e.stopImmediatePropagation(),i(e)},s=e=>{e.stopImmediatePropagation(),o.value=0,r.currentTime=0,r.pause()},l=e=>{e.stopImmediatePropagation(),i(e)};return t.addEventListener("mouseenter",a),t.addEventListener("mouseleave",s),t.addEventListener("mousemove",l),()=>{t.removeEventListener("mouseenter",a),t.removeEventListener("mouseleave",s),t.removeEventListener("mousemove",l)}}),[n,r]);const p=(0,wt.useCallback)((()=>{if(a(),d.current){const{videoWidth:e,videoHeight:t}=d.current;l(e>t?"horizontal":"vertical")}if(u.current){const{naturalWidth:e,naturalHeight:t}=u.current;l(e>t?"horizontal":"vertical")}}),[a]);return(0,Vt.jsxs)(Vt.Fragment,{children:[(0,Vt.jsxs)("div",{className:`asset-preview__representative asset-preview__representative--${s}`,children:[t&&!n?(0,Vt.jsx)("video",{ref:d,src:t,poster:r,onLoadedMetadata:p,onError:()=>{o()},children:(0,Vt.jsx)("track",{default:!0,kind:"captions",srcLang:"en"})}):(0,Vt.jsx)("img",{ref:u,src:r,alt:"Asset preview",onLoad:p,onError:o}),(0,Vt.jsx)("div",{className:"asset-preview__video-icon",hidden:!i,children:(0,Vt.jsx)("cx-icon",{name:"play_arrow",variant:"filled"})})]}),!n&&(0,Vt.jsx)("cx-progress-bar",{ref:h,className:"asset-preview__progress-bar"}),(0,Vt.jsx)("div",{ref:c,className:"asset-preview__representative-overlay"})]})},zr=e=>{let{asset:t,imageLoaded:n,slot:r,thumbnailOnly:o,onLoaded:i}=e;const[a,s]=(0,wt.useState)(!1),l=(0,wt.useCallback)((()=>{const e="string"===typeof t.imageUrl&&t.imageUrl.length>0;var r;return a||!e?(0,Vt.jsx)(Kn,{type:t.docType,children:(null===(r=t.extension)||void 0===r?void 0:r.toUpperCase())||t.docType}):t.docType===Qt.zu.Video?(0,Vt.jsx)(Pr,{url:t.scrubUrl,thumbnailOnly:o,thumbnailUrl:t.imageUrl,loaded:n,onLoaded:i,onError:()=>s(!0)}):(0,Vt.jsx)(Or,{alt:t.name,url:t.imageUrl,originalUrl:"gif"===t.extension&&t.originalUrl?t.originalUrl:void 0,loaded:n,onLoaded:i,onError:()=>s(!0)})}),[t,a,i,o,n]);return(0,Vt.jsxs)(Tr,{slot:r,className:"asset-preview",children:[!n&&(0,Vt.jsx)("cx-skeleton",{slot:"image",className:"asset-preview__image-skeleton"}),l()]})},Dr={[Qt.gf.Small]:{minWidth:130,maxWidth:178},[Qt.gf.Medium]:{minWidth:190,maxWidth:292},[Qt.gf.Large]:{minWidth:302,maxWidth:456}},Rr=(0,Ft.Ay)("cx-card")`
820
+ `,Or=e=>{let{alt:t,url:n,loaded:r,originalUrl:o,onError:i,onLoaded:a}=e;return(0,Vt.jsxs)("div",{className:o&&r?"asset-preview__representative-container":void 0,children:[(0,Vt.jsx)("img",{className:"asset-preview__representative",src:n,alt:t,onLoad:a,onError:i}),o&&(0,Vt.jsx)("img",{className:"asset-preview__representative asset-preview__representative--animated",src:o,alt:t,onLoad:a,onError:i})]})},Pr=e=>{let{url:t,thumbnailOnly:n,thumbnailUrl:r,onError:o,loaded:i,onLoaded:a}=e;const[s,l]=(0,wt.useState)("horizontal"),c=(0,wt.useRef)(null),u=(0,wt.useRef)(null),d=(0,wt.useRef)(null),h=(0,wt.useRef)(null);(0,wt.useEffect)((()=>{var e;if(n)return;const t=null===(e=c.current)||void 0===e?void 0:e.parentElement,r=d.current,o=h.current;if(!t||!r||!o)return;const i=e=>{r.duration&&e.currentTarget===t&&(o.value=e.offsetX/t.offsetWidth*100,r.currentTime=e.offsetX/t.offsetWidth*r.duration)},a=e=>{e.stopImmediatePropagation(),i(e)},s=e=>{e.stopImmediatePropagation(),o.value=0,r.currentTime=0,r.pause()},l=e=>{e.stopImmediatePropagation(),i(e)};return t.addEventListener("mouseenter",a),t.addEventListener("mouseleave",s),t.addEventListener("mousemove",l),()=>{t.removeEventListener("mouseenter",a),t.removeEventListener("mouseleave",s),t.removeEventListener("mousemove",l)}}),[n,r]);const p=(0,wt.useCallback)((()=>{if(a(),d.current){const{videoWidth:e,videoHeight:t}=d.current;l(e>t?"horizontal":"vertical")}if(u.current){const{naturalWidth:e,naturalHeight:t}=u.current;l(e>t?"horizontal":"vertical")}}),[a]);return(0,Vt.jsxs)(Vt.Fragment,{children:[(0,Vt.jsxs)("div",{className:`asset-preview__representative asset-preview__representative--${s}`,children:[t&&!n?(0,Vt.jsx)("video",{ref:d,src:t,poster:r,onLoadedMetadata:p,onError:()=>{o()},children:(0,Vt.jsx)("track",{default:!0,kind:"captions",srcLang:"en"})}):(0,Vt.jsx)("img",{ref:u,src:r,alt:"Asset preview",onLoad:p,onError:o}),(0,Vt.jsx)("div",{className:"asset-preview__video-icon",hidden:!i,children:(0,Vt.jsx)("cx-icon",{name:"play_arrow",variant:"filled"})})]}),!n&&(0,Vt.jsx)("cx-progress-bar",{ref:h,className:"asset-preview__progress-bar"}),(0,Vt.jsx)("div",{ref:c,className:"asset-preview__representative-overlay"})]})},zr=e=>{let{asset:t,imageLoaded:n,slot:r,thumbnailOnly:o,onLoaded:i}=e;const[a,s]=(0,wt.useState)(!1),l=(0,wt.useCallback)((()=>{const e="string"===typeof t.imageUrl&&t.imageUrl.length>0;var r;return a||!e?(0,Vt.jsx)(Kn,{type:t.docType,children:(null===(r=t.extension)||void 0===r?void 0:r.toUpperCase())||t.docType}):t.docType===Qt.zu.Video?(0,Vt.jsx)(Pr,{url:t.scrubUrl,thumbnailOnly:o,thumbnailUrl:t.imageUrl,loaded:n,onLoaded:i,onError:()=>s(!0)}):(0,Vt.jsx)(Or,{alt:t.name,url:t.imageUrl,originalUrl:".gif"===t.extension&&t.originalUrl?t.originalUrl:void 0,loaded:n,onLoaded:i,onError:()=>s(!0)})}),[t,a,i,o,n]);return(0,Vt.jsxs)(Tr,{slot:r,className:"asset-preview",children:[!n&&(0,Vt.jsx)("cx-skeleton",{slot:"image",className:"asset-preview__image-skeleton"}),l()]})},Dr={[Qt.gf.Small]:{minWidth:130,maxWidth:178},[Qt.gf.Medium]:{minWidth:190,maxWidth:292},[Qt.gf.Large]:{minWidth:302,maxWidth:456}},Rr=(0,Ft.Ay)("cx-card")`
817
821
  &.asset-card {
818
822
  --border-color: transparent;
819
823
  --border-radius: 0;
@@ -928,7 +932,7 @@
928
932
  visibility: hidden;
929
933
  }
930
934
  }
931
- `,jr=e=>{let{id:t,asset:n,displayInfo:r,isSelected:o,view:i,onItemSelect:a,onMount:s,onLoaded:l}=e;const[c,u]=(0,wt.useState)(!1),[d,h]=(0,wt.useState)(!1),p=(0,wt.useRef)(null),f=c||n.docType!==Qt.zu.Image&&n.docType!==Qt.zu.Video,m=(0,wt.useCallback)((()=>{u(!0),l&&l(t)}),[t,l]);(0,wt.useEffect)((()=>{s&&s(t)}),[s,t]);const g=(0,wt.useMemo)((()=>(null===n||void 0===n?void 0:n.tags.length)>0?null===n||void 0===n?void 0:n.tags.split(",").map((e=>e.trim())):[]),[null===n||void 0===n?void 0:n.tags]),v=(0,wt.useCallback)((e=>r.tags&&g&&g[e]||""),[r.tags,g]),b=(0,wt.useMemo)((()=>{const e={"asset-card":!0,selected:o,"asset-card--small":i===Qt.gf.Small,"asset-card--medium":i===Qt.gf.Medium,"asset-card--large":i===Qt.gf.Large};return Object.keys(e).filter((t=>e[t])).join(" ")}),[o,i]);return(0,wt.useEffect)((()=>{const e=p.current;if(!e)return;const t=new IntersectionObserver((e=>{e.forEach((e=>{e.isIntersecting?h(!0):h(!1)}))}));return t.observe(e),()=>{t.unobserve(e)}}),[]),(0,Vt.jsxs)(Rr,{ref:p,className:b,onClick:()=>{a(n)},children:[(0,Vt.jsx)(zr,{slot:"image",asset:n,imageLoaded:f,thumbnailOnly:i===Qt.gf.Small||!d,onLoaded:m}),o&&(0,Vt.jsx)("div",{slot:"image",className:"asset-card__checkbox",children:(0,Vt.jsx)("cx-checkbox",{checked:!0})}),(0,Vt.jsx)("cx-space",{spacing:"small","align-items":"center",wrap:"nowrap",className:"asset-card__info",children:r.title&&n.name?(0,Vt.jsx)("cx-line-clamp",{lines:1,className:"asset-card__name",children:n.name}):(0,Vt.jsx)("cx-typography",{variant:"small",className:"asset-card__placeholder",children:(0,Vt.jsx)("span",{children:"empty"})})}),r.tags&&g.length>0&&(0,Vt.jsx)(Er,{className:"asset-card__tags",separator:" ",tooltipSeparator:", ",getChildString:v,children:null===g||void 0===g?void 0:g.filter((e=>!(0,Ar.o)(e))).slice(0,5).map((e=>(0,Vt.jsx)("cx-tag",{size:"small",variant:"neutral",pill:!0,children:(0,Vt.jsx)("cx-line-clamp",{lines:1,children:e})},e.toLowerCase())))}),(r.dimension||r.fileSize)&&(0,Vt.jsxs)("cx-space",{spacing:"small","align-items":"center",wrap:"nowrap",className:"asset-card__info",children:[r.dimension&&Boolean(Number(n.width))&&Boolean(Number(n.height))&&(0,Vt.jsx)("cx-line-clamp",{lines:1,className:"asset-card__name",children:(0,Vt.jsxs)("cx-typography",{variant:"small",children:[(0,Vt.jsx)("span",{children:n.width})," x ",(0,Vt.jsx)("span",{children:n.height})]})}),r.fileSize&&(0,Vt.jsx)("cx-line-clamp",{lines:1,className:"asset-card__name asset-card__name--right",children:(0,Vt.jsx)("cx-typography",{variant:"small",children:n.size})}),!(r.dimension&&Boolean(Number(n.width))&&Boolean(Number(n.height))||r.fileSize)&&(0,Vt.jsx)("cx-typography",{variant:"small",className:"asset-card__placeholder",children:(0,Vt.jsx)("span",{children:"empty"})})]}),r.tags&&0===g.length&&(0,Vt.jsx)(Er,{className:"asset-card__tags",separator:" ",tooltipSeparator:", ",getChildString:v,children:(0,Vt.jsx)("span",{})})]})},Nr=Ft.Ay.div`
935
+ `,jr=e=>{let{id:t,asset:n,displayInfo:r,isSelected:o,view:i,onItemSelect:a,onMount:s,onLoaded:l}=e;const[c,u]=(0,wt.useState)(!1),[d,h]=(0,wt.useState)(!1),p=(0,wt.useRef)(null),f=c||n.docType!==Qt.zu.Image&&n.docType!==Qt.zu.Video,m=(0,wt.useCallback)((()=>{u(!0),l&&l(t)}),[t,l]);(0,wt.useEffect)((()=>{s&&s(t)}),[s,t]);const g=(0,wt.useMemo)((()=>(null===n||void 0===n?void 0:n.tags.length)>0?null===n||void 0===n?void 0:n.tags.split(",").map((e=>e.trim())):[]),[null===n||void 0===n?void 0:n.tags]),v=(0,wt.useCallback)((e=>r.tags&&g&&g[e]||""),[r.tags,g]),b=(0,wt.useMemo)((()=>{const e={"asset-card":!0,selected:o,"asset-card--small":i===Qt.gf.Small,"asset-card--medium":i===Qt.gf.Medium,"asset-card--large":i===Qt.gf.Large};return Object.keys(e).filter((t=>e[t])).join(" ")}),[o,i]);return(0,wt.useEffect)((()=>{const e=p.current;if(!e)return;const t=new IntersectionObserver((e=>{e.forEach((e=>{e.isIntersecting?h(!0):h(!1)}))}));return t.observe(e),()=>{t.unobserve(e)}}),[]),(0,Vt.jsxs)(Rr,{ref:p,className:b,onClick:()=>{a(n)},children:[(0,Vt.jsx)(zr,{slot:"image",asset:n,imageLoaded:f,thumbnailOnly:i===Qt.gf.Small||!d,onLoaded:m}),o&&(0,Vt.jsx)("div",{slot:"image",className:"asset-card__checkbox",children:(0,Vt.jsx)("cx-checkbox",{checked:!0})}),(0,Vt.jsx)("cx-space",{spacing:"small","align-items":"center",wrap:"nowrap",className:"asset-card__info",children:r.title&&n.name?(0,Vt.jsx)("cx-line-clamp",{lines:1,className:"asset-card__name",children:(0,Vt.jsx)("cx-typography",{variant:"body3",children:n.name})}):(0,Vt.jsx)("cx-typography",{variant:"small",className:"asset-card__placeholder",children:(0,Vt.jsx)("span",{children:"empty"})})}),r.tags&&g.length>0&&(0,Vt.jsx)(Er,{className:"asset-card__tags",separator:" ",tooltipSeparator:", ",getChildString:v,children:null===g||void 0===g?void 0:g.filter((e=>!(0,Ar.o)(e))).slice(0,5).map((e=>(0,Vt.jsx)("cx-tag",{size:"small",variant:"neutral",pill:!0,children:(0,Vt.jsx)("cx-line-clamp",{lines:1,children:e})},e.toLowerCase())))}),(r.dimension||r.fileSize)&&(0,Vt.jsxs)("cx-space",{spacing:"small","align-items":"center",wrap:"nowrap",className:"asset-card__info",children:[r.dimension&&Boolean(Number(n.width))&&Boolean(Number(n.height))&&(0,Vt.jsx)("cx-line-clamp",{lines:1,className:"asset-card__name",children:(0,Vt.jsxs)("cx-typography",{variant:"small",children:[(0,Vt.jsx)("span",{children:n.width})," x ",(0,Vt.jsx)("span",{children:n.height})]})}),r.fileSize&&(0,Vt.jsx)("cx-line-clamp",{lines:1,className:"asset-card__name asset-card__name--right",children:(0,Vt.jsx)("cx-typography",{variant:"small",children:n.size})}),!(r.dimension&&Boolean(Number(n.width))&&Boolean(Number(n.height))||r.fileSize)&&(0,Vt.jsx)("cx-typography",{variant:"small",className:"asset-card__placeholder",children:(0,Vt.jsx)("span",{children:"empty"})})]}),r.tags&&0===g.length&&(0,Vt.jsx)(Er,{className:"asset-card__tags",separator:" ",tooltipSeparator:", ",getChildString:v,children:(0,Vt.jsx)("span",{})})]})},Nr=Ft.Ay.div`
932
936
  position: relative;
933
937
 
934
938
  .wrapper__progress-bar {