@orangelogic/orange-dam-content-browser-sdk 2.2.4 → 2.2.5

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.
@@ -738,7 +738,7 @@
738
738
  .version__item__editor {
739
739
  color: var(--cx-color-primary);
740
740
  }
741
- `;var or=n(3943);const ir=e=>{let{src:t,alt:n}=e;const[r,o]=(0,xt.useState)("horizontal"),i=(0,xt.useRef)(null),a=(0,xt.useCallback)((()=>{if(i.current){const{naturalWidth:e,naturalHeight:t}=i.current;o(e>t?"horizontal":"vertical")}}),[]);return(0,Ut.jsx)("div",{className:`version__item__preview version__item__preview--${r}`,children:(0,Ut.jsx)("img",{ref:i,src:t,alt:n,onLoad:a})})},ar=e=>{let{src:t}=e;const[n,r]=(0,xt.useState)("horizontal"),o=(0,xt.useRef)(null),i=(0,xt.useCallback)((()=>{if(o.current){const{videoWidth:e,videoHeight:t}=o.current;r(e>t?"horizontal":"vertical")}}),[]);return(0,Ut.jsx)("div",{className:`version__item__preview version__item__preview--${n}`,children:(0,Ut.jsx)("video",{ref:o,src:t,onLoadedMetadata:i,controls:!0})})},sr=e=>{var t;let{assetId:n}=e;const{data:r,isFetching:o,isLoading:i}=(0,or.cP)(n?{assetId:n}:jt.hT);return o||i?(0,Ut.jsx)(rr,{children:(0,Ut.jsx)("cx-spinner",{})}):(0,Ut.jsx)(rr,{children:(0,Ut.jsx)("cx-menu",{children:null===r||void 0===r||null===(t=r.versions)||void 0===t?void 0:t.map(((e,t)=>(0,Ut.jsx)("cx-menu-item",{className:"version__item",readonly:!0,children:(0,Ut.jsxs)("cx-grid",{columns:5,spacing:"12px",children:[(0,Ut.jsx)("cx-grid-item",{xs:"2",sm:"2",children:(0,Ut.jsxs)("cx-space",{direction:"horizontal","align-items":"center",wrap:"nowrap",children:[(0,Ut.jsx)("div",{className:"version__item__number",children:(0,Ut.jsx)(Kt,{lines:1,children:e.versionNumberDisplay})}),e.scrubUrl?(0,Ut.jsx)(ar,{src:e.scrubUrl}):(0,Ut.jsx)(ir,{src:e.versionFileUrl,alt:e.versionFileName})]})}),(0,Ut.jsx)("cx-grid-item",{xs:"2",sm:"3",children:(0,Ut.jsxs)("cx-space",{direction:"vertical",spacing:"2x-small",children:[(0,Ut.jsx)(Kt,{lines:1,children:(0,Ut.jsx)("cx-typography",{variant:"body3",className:"version__item__name",children:e.versionFileName})}),(0,Ut.jsx)(Kt,{lines:1,children:(0,Ut.jsx)("cx-typography",{variant:"body3",children:e.createByEmail})}),(0,Ut.jsxs)("cx-typography",{variant:"body3",children:[e.versionCreateDate.split(" ")[0],0===t&&(0,Ut.jsx)("span",{className:"version__item__latest",children:"Current version"})]})]})})]})},e.versionNumber)))})})},lr=CSS.supports("(overlay: auto)")&&"showPopover"in document.createElement("div"),cr={previewLoadable:!1,defaultSize:{width:0,height:0},selectedProxy:"",defaultSelectedProxy:"",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:dn.Nf.Pixel},lastResizeSize:{[dn.Nf.AspectRatio]:{width:0,height:0,unit:dn.Nf.AspectRatio},[dn.Nf.Pixel]:{width:0,height:0,unit:dn.Nf.Pixel}},cropSize:{width:0,height:0,percentageWidth:0,percentageHeight:0,x:0,y:0,unit:dn.Nf.Pixel},lastCropSize:{[dn.Nf.AspectRatio]:{width:0,height:0,percentageWidth:0,percentageHeight:0,x:0,y:0,unit:dn.Nf.AspectRatio},[dn.Nf.Pixel]:{width:0,height:0,percentageWidth:0,percentageHeight:0,x:0,y:0,unit:dn.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},ur=(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&&!t.payload.resetTransformations?e.confirmedTransformations:[],confirmedTransformations:t.payload.resetTransformations?[]:e.confirmedTransformations,showCustomRendition:!1,activeSetting:"format",selectedProxy:t.payload.selectedProxy};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},defaultSelectedProxy:e.selectedProxy};case"SET_DEFAULT_SIZE":return{...e,defaultSize:{...e.defaultSize,...t.payload}};case"RESET_DATA":return cr;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_DEFAULT_SELECTED_FORMAT":return{...e,defaultSelectedFormat:{...e.defaultSelectedFormat,...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_DEFAULT_SELECTED_PROXY":return{...e,defaultSelectedProxy:t.payload};case"SET_SHOW_CUSTOM_RENDITION":return{...e,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}},dr=e=>{let{allowCustomFormat:t,allowFavorites:n,allowProxy:r,allowTracking:o,allowedExtensions:i,appendAutoExtension:a,autoExtension:s,availableExtensions:l,availableProxies:c,ctaText:u="Insert",ctaTextTransform:d="capitalize",extensions:h,isFavorite:p,maxHeight:f,open:g,previewUrl:m,selectedAsset:v,showVersions:b,supportedRepresentativeSubtypes:y,variant:A="dialog",boundary:x,onClose:w,onFavorite:C,onProxyConfirm:E,onFormatConfirm:k,onUnFavorite:S}=e;const[I,B]=(0,xt.useReducer)(ur,cr),[_,T]=(0,xt.useState)(!1),O=(0,xt.useRef)(null),P=(0,xt.useRef)(null),Q=(0,xt.useRef)(null),D=(0,xt.useMemo)((()=>i?c?c.filter((e=>{if(!e.extension&&v){return!!(null===i||void 0===i?void 0:i.some((e=>e===v.extension.replace(/^\./,""))))}return!0})):[]:c),[c,i,v]),z=(0,xt.useCallback)((()=>{if(!v)return;const e=hn(I.defaultSize.width,I.defaultSize.height);B({type:"SET_RESIZE_SIZE",payload:{...cr.resizeSize,width:I.defaultSize.width,height:I.defaultSize.height}}),B({type:"SET_CROP_SIZE",payload:{...cr.cropSize,width:I.defaultSize.width,height:I.defaultSize.height,percentageHeight:100,percentageWidth:100}}),B({type:"SET_ROTATION",payload:0}),B({type:"SET_LAST_CROP_SIZE",payload:{...cr.lastCropSize,[dn.Nf.Pixel]:{width:I.defaultSize.width,height:I.defaultSize.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:dn.Nf.Pixel},[dn.Nf.AspectRatio]:{width:e.width,height:e.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:dn.Nf.AspectRatio}}}),B({type:"SET_LAST_RESIZE_SIZE",payload:{[dn.Nf.Pixel]:{width:I.defaultSize.width,height:I.defaultSize.height,unit:dn.Nf.Pixel},[dn.Nf.AspectRatio]:{width:e.width,height:e.height,unit:dn.Nf.AspectRatio}}});let t=v.extension;if(a)t=s;else if(v.docType){var n,r,o,i;if(null!==l&&void 0!==l&&null!==(n=l[v.docType])&&void 0!==n&&n.map((e=>e.value)).includes(v.extension))t=v.extension;else t=null!==(r=null===l||void 0===l||null===(o=l[v.docType])||void 0===o||null===(i=o[0])||void 0===i?void 0:i.value)&&void 0!==r?r:""}if(D&&D.length>0){var c,u;B({type:"SET_SELECTED_PROXY",payload:null===(c=D[0])||void 0===c?void 0:c.id}),B({type:"SET_DEFAULT_SELECTED_PROXY",payload:null===(u=D[0])||void 0===u?void 0:u.id});const e={...cr.selectedFormat,url:v.imageUrl,originalUrl:v.originalUrl,extension:t,width:D[0].formatWidth||I.defaultSize.width,height:D[0].formatHeight||I.defaultSize.height};B({type:"SET_SELECTED_FORMAT",payload:e}),B({type:"SET_DEFAULT_SELECTED_FORMAT",payload:e})}else B({type:"SET_SELECTED_FORMAT",payload:{...cr.selectedFormat,url:v.imageUrl,originalUrl:v.originalUrl,extension:t,width:I.defaultSize.width,height:I.defaultSize.height}})}),[s,D,v,I.defaultSize.height,I.defaultSize.width,a,l]);(0,xt.useEffect)((()=>{null!==v&&void 0!==v&&v.width&&null!==v&&void 0!==v&&v.height&&B({type:"SET_DEFAULT_SIZE",payload:{width:parseInt(v.width,10),height:parseInt(v.height,10)}})}),[null===v||void 0===v?void 0:v.width,null===v||void 0===v?void 0:v.height]),(0,xt.useEffect)((()=>{Promise.all([customElements.whenDefined("cx-dialog"),customElements.whenDefined("cx-drawer"),customElements.whenDefined("cx-dropdown")]).then((()=>{T(!0)}))}),[]),(0,xt.useEffect)((()=>{const e=e=>{I.isLoadingFavorites?e.preventDefault():I.showVersionHistory?(e.preventDefault(),B({type:"SET_SHOW_VERSION_HISTORY",payload:!1})):(B({type:"SET_PREVIEW_LOADABLE",payload:!1}),B({type:"RESET_DATA"}),w())},t=O.current,n=P.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,_,w,I.isLoadingFavorites,I.showVersionHistory]),(0,xt.useEffect)((()=>{const e=O.current;e&&x&&(e.boundary=x)})),(0,xt.useEffect)((()=>{const e=()=>{B({type:"SET_PREVIEW_LOADABLE",payload:!0})},t=O.current,n=P.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)}}),[_,I.showCustomRendition,A]),(0,xt.useEffect)((()=>{const e=e=>{const t=e.detail.item.value;if("custom"===t)return B({type:"SET_SHOW_CUSTOM_RENDITION",payload:!0}),void(I.useCustomRendition||z());if("tracking"!==t)if("use-representative"!==t){if(t&&D){var n,r,o,i,a;if(!D.map((e=>e.id)).includes(t))return;B({type:"CANCEL_USE_CUSTOM_RENDITION",payload:{url:null!==(n=null===v||void 0===v?void 0:v.imageUrl)&&void 0!==n?n:"",originalUrl:null!==(r=null===v||void 0===v?void 0:v.originalUrl)&&void 0!==r?r:"",width:parseInt(null!==(o=null===v||void 0===v?void 0:v.width)&&void 0!==o?o:"0",10),height:parseInt(null!==(i=null===v||void 0===v?void 0:v.height)&&void 0!==i?i:"0",10),extension:null!==(a=null===v||void 0===v?void 0:v.extension)&&void 0!==a?a:"",useCustomRendition:!1,resetTransformations:!0,selectedProxy:""}}),B({type:"SET_SELECTED_PROXY",payload:t})}}else B({type:"SET_USE_REPRESENTATIVE",payload:!I.useRepresentative});else B({type:"SET_ENABLED_TRACKING",payload:!I.enabledTracking})},t=O.current,n=P.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)}}),[_,I.enabledTracking,I.useCustomRendition,I.useRepresentative,z,D,null===v||void 0===v?void 0:v.width,null===v||void 0===v?void 0:v.height,null===v||void 0===v?void 0:v.imageUrl,null===v||void 0===v?void 0:v.originalUrl,null===v||void 0===v?void 0:v.extension]),(0,xt.useEffect)((()=>{z()}),[z]);const R=(0,xt.useMemo)((()=>{var e;return(null===y||void 0===y?void 0:y.includes(null!==(e=null===v||void 0===v?void 0:v.docSubType)&&void 0!==e?e:""))&&(null===v||void 0===v?void 0:v.imageUrl)}),[v,y]),N=(0,xt.useCallback)((e=>{B({type:"SET_LOADING",payload:e})}),[]),j=(0,xt.useCallback)((async(e,t,n,r)=>{if(!v)return;const o=I.selectedFormat.width||I.defaultSize.width,i=I.selectedFormat.height||I.defaultSize.height;if(B({type:"SET_RESIZE_SIZE",payload:{width:e,height:t,unit:n}}),r){var a;let r=e,s=t;I.resizeSize.unit!==n?(r=o,s=i):n===dn.Nf.AspectRatio&&(r=Math.round(e/t*i),s=i);const l=await(null===(a=Q.current)||void 0===a?void 0:a.applyResize());B({type:"SET_SELECTED_FORMAT",payload:{url:l,width:r,height:s}}),B({type:"SET_TRANSFORMATIONS",payload:{key:dn.YQ.Resize,value:{width:r,height:s,originalWidth:o,originalHeight:i}}}),B({type:"SET_CROP_SIZE",payload:{width:r,height:s}});const c=hn(r,s);B({type:"SET_LAST_RESIZE_SIZE",payload:{[dn.Nf.Pixel]:{width:r,height:s,unit:dn.Nf.Pixel},[dn.Nf.AspectRatio]:{width:n===dn.Nf.AspectRatio?e:c.width,height:n===dn.Nf.AspectRatio?t:c.height,unit:dn.Nf.AspectRatio}}}),B({type:"SET_LAST_CROP_SIZE",payload:{[dn.Nf.Pixel]:{width:r,height:s,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:dn.Nf.Pixel},[dn.Nf.AspectRatio]:{width:n===dn.Nf.AspectRatio?e:c.width,height:n===dn.Nf.AspectRatio?t:c.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:dn.Nf.AspectRatio}}})}}),[v,I.defaultSize.height,I.defaultSize.width,I.resizeSize.unit,I.selectedFormat.height,I.selectedFormat.width]),L=(0,xt.useCallback)((async(e,t,n,r)=>{var o,i;if(!v)return;const a=I.cropSize.unit,s=Q.current;if(s&&null!==(o=I.selectedFormat)&&void 0!==o&&o.width&&null!==(i=I.selectedFormat)&&void 0!==i&&i.height){if(n===a&&n===dn.Nf.Pixel){const n=Math.max(e/I.selectedFormat.width,t/I.selectedFormat.height);s.setZoom(1/n)}n!==a&&s.setZoom(1)}if(B({type:"SET_CROP_SIZE",payload:{width:e,height:t,unit:n}}),r){var l;const r=await(null===(l=Q.current)||void 0===l?void 0:l.applyCrop());let o=e,i=t;n===dn.Nf.AspectRatio&&(o=Math.round(I.cropSize.percentageWidth*I.selectedFormat.width/100),i=Math.round(I.cropSize.percentageHeight*I.selectedFormat.height/100)),null===s||void 0===s||s.setZoom(1);const a=Number((I.cropSize.x/100*I.selectedFormat.width).toFixed(0)),c=Number((I.cropSize.y/100*I.selectedFormat.height).toFixed(0));B({type:"SET_SELECTED_FORMAT",payload:{url:r,width:o,height:i}}),B({type:"SET_RESIZE_SIZE",payload:{width:o,height:i,unit:dn.Nf.Pixel}}),B({type:"SET_TRANSFORMATIONS",payload:{key:dn.YQ.Crop,value:{width:Number(o.toFixed(0)),height:Number(i.toFixed(0)),x:a,y:c,percentageWidth:I.cropSize.percentageWidth,percentageHeight:I.cropSize.percentageHeight,percentageX:I.cropSize.x,percentageY:I.cropSize.y}}});const u=hn(o,i);B({type:"SET_LAST_CROP_SIZE",payload:{[dn.Nf.Pixel]:{width:Math.round(o),height:Math.round(i),percentageHeight:100,percentageWidth:100,x:0,y:0,unit:dn.Nf.Pixel},[dn.Nf.AspectRatio]:{width:n===dn.Nf.AspectRatio?e:u.width,height:n===dn.Nf.AspectRatio?t:u.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:dn.Nf.AspectRatio}}}),B({type:"SET_LAST_RESIZE_SIZE",payload:{[dn.Nf.Pixel]:{width:o,height:i,unit:dn.Nf.Pixel},[dn.Nf.AspectRatio]:{width:n===dn.Nf.AspectRatio?e:u.width,height:n===dn.Nf.AspectRatio?t:u.height,unit:dn.Nf.AspectRatio}}})}}),[v,I.cropSize,I.selectedFormat.height,I.selectedFormat.width]),F=(0,xt.useCallback)((async(e,t)=>{if(t){var n;const{width:t,height:r}=pn(I.selectedFormat.width,I.selectedFormat.height,e),o=await(null===(n=Q.current)||void 0===n?void 0:n.applyRotation());B({type:"SET_SELECTED_FORMAT",payload:{rotation:e,url:o,width:t,height:r}}),B({type:"SET_TRANSFORMATIONS",payload:{key:dn.YQ.Rotate,value:{rotation:e}}}),B({type:"SET_CROP_SIZE",payload:{width:t,height:r}}),B({type:"SET_RESIZE_SIZE",payload:{width:t,height:r,unit:dn.Nf.Pixel}});const i=hn(t,r);B({type:"SET_LAST_CROP_SIZE",payload:{[dn.Nf.Pixel]:{width:t,height:r,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:dn.Nf.Pixel},[dn.Nf.AspectRatio]:{width:i.width,height:i.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:dn.Nf.AspectRatio}}}),B({type:"SET_LAST_RESIZE_SIZE",payload:{[dn.Nf.Pixel]:{width:t,height:r,unit:dn.Nf.Pixel},[dn.Nf.AspectRatio]:{width:i.width,height:i.height,unit:dn.Nf.AspectRatio}}}),B({type:"SET_ROTATION",payload:0})}else B({type:"SET_ROTATION",payload:e})}),[I.selectedFormat]),M=(0,xt.useCallback)((e=>{B({type:"SET_SELECTED_FORMAT",payload:{extension:e}})}),[]),U=(0,xt.useCallback)((e=>{B({type:"SET_CROP_SIZE",payload:{width:I.selectedFormat.width,height:I.selectedFormat.height,unit:dn.Nf.Pixel}}),B({type:"SET_RESIZE_SIZE",payload:{width:I.selectedFormat.width,height:I.selectedFormat.height,unit:dn.Nf.Pixel}}),B({type:"SET_ROTATION",payload:0}),B({type:"SET_ACTIVE_SETTING",payload:e})}),[I.selectedFormat]),H=(0,xt.useCallback)((()=>{B({type:"SET_SHOW_VERSION_HISTORY",payload:!0})}),[]),V=(0,xt.useCallback)((async e=>{var t;let n=e.formatWidth,r=e.formatHeight;"TRX"===e.proxyName&&v&&(n=Number(v.width),r=Number(v.height)),B({type:"SET_SELECTED_PROXY",payload:{proxy:e.id}});const{rotation:o,croppedWidth:i,croppedHeight:a,percentageWidth:s,percentageHeight:l,percentageX:c,percentageY:u,effectiveWidth:d,effectiveHeight:h}=(e=>{let{width:t,height:n,transformations:r}=e,o=0,i=100,a=100,s=0,l=0,c=t,u=n,d=!1;for(const P of r)if(P.key===dn.YQ.Rotate){var h,p;const e=null!==(h=null===(p=P.value)||void 0===p?void 0:p.rotation)&&void 0!==h?h:0;o=(o+e)%360,e%180!==0&&e%90===0&&(d=!d,[c,u]=[u,c])}else if(P.key===dn.YQ.Crop){var f,g,m,v,b,y,A,x;const e=null!==(f=null===(g=P.value)||void 0===g?void 0:g.percentageX)&&void 0!==f?f:0,t=null!==(m=null===(v=P.value)||void 0===v?void 0:v.percentageY)&&void 0!==m?m:0,n=null!==(b=null===(y=P.value)||void 0===y?void 0:y.percentageWidth)&&void 0!==b?b:100,r=null!==(A=null===(x=P.value)||void 0===x?void 0:x.percentageHeight)&&void 0!==A?A:100;let d,h,p,w;switch(o){case 90:d=t,h=100-e-n,p=r,w=n;break;case 180:d=100-e-n,h=100-t-r,p=n,w=r;break;case 270:d=100-t-r,h=e,p=r,w=n;break;default:d=e,h=t,p=n,w=r}s+=d*i/100,l+=h*a/100,i=i*p/100,a=a*w/100,c=c*n/100,u=u*r/100}else if(P.key===dn.YQ.Resize){var w,C,E,k,S,I,B,_;const e=null!==(w=null===(C=P.value)||void 0===C?void 0:C.width)&&void 0!==w?w:c,t=null!==(E=null===(k=P.value)||void 0===k?void 0:k.height)&&void 0!==E?E:u;c*=e/(null!==(S=null===(I=P.value)||void 0===I?void 0:I.originalWidth)&&void 0!==S?S:e),u*=t/(null!==(B=null===(_=P.value)||void 0===_?void 0:_.originalHeight)&&void 0!==B?B:t)}d&&([c,u]=[u,c]);const T=t*(i/100),O=n*(a/100);return{rotation:r.reduce(((e,t)=>{var n,r;return t.key===dn.YQ.Rotate&&(e+=null!==(n=null===(r=t.value)||void 0===r?void 0:r.rotation)&&void 0!==n?n:0),e}),0)%360,croppedWidth:Math.round(T),croppedHeight:Math.round(O),percentageWidth:i,percentageHeight:a,percentageX:s,percentageY:l,effectiveWidth:Math.round(c),effectiveHeight:Math.round(u)}})({width:n,height:r,transformations:I.transformations});B({type:"SET_CROP_SIZE",payload:{width:i,height:a,percentageWidth:s,percentageHeight:l,x:c,y:u,unit:dn.Nf.Pixel}});const p=await On({cropper:{height:a,width:i,percentageHeight:l,percentageWidth:s,x:c,y:u,unit:dn.Nf.Pixel},image:{url:null!==(t=null===v||void 0===v?void 0:v.imageUrl)&&void 0!==t?t:"",width:n,height:r},loadable:I.previewLoadable,onLoadingChange:N,zoom:1}),{width:f,height:g}=pn(d,h,o),m=await Pn({image:{url:p,width:d,height:h},loadable:I.previewLoadable,onLoadingChange:N,rotation:o});B({type:"SET_SELECTED_FORMAT",payload:{url:m,width:f,height:g}}),B({type:"SET_RESIZE_SIZE",payload:{width:f,height:g,unit:dn.Nf.Pixel}});const b=hn(n,r);B({type:"SET_LAST_CROP_SIZE",payload:{[dn.Nf.Pixel]:{width:Math.round(n),height:Math.round(r),percentageHeight:100,percentageWidth:100,x:0,y:0,unit:dn.Nf.Pixel},[dn.Nf.AspectRatio]:{width:b.width,height:b.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:dn.Nf.AspectRatio}}}),B({type:"SET_LAST_RESIZE_SIZE",payload:{[dn.Nf.Pixel]:{width:f,height:g,unit:dn.Nf.Pixel},[dn.Nf.AspectRatio]:{width:b.width,height:b.height,unit:dn.Nf.AspectRatio}}})}),[N,v,I]),W=(0,xt.useCallback)((e=>{B({type:"SET_QUALITY",payload:e}),B({type:"SET_TRANSFORMATIONS",payload:{key:dn.YQ.Quality,value:{quality:e}}})}),[]),q=(0,xt.useCallback)((e=>{B({type:"SET_KEEP_METADATA",payload:e}),B({type:"SET_TRANSFORMATIONS",payload:{key:dn.YQ.KeepMetadata,value:{keepMetadata:e}}})}),[]);(0,xt.useEffect)((()=>{D&&0!==D.length?(B({type:"SET_SELECTED_PROXY",payload:D[0].id}),B({type:"SET_DEFAULT_SELECTED_PROXY",payload:D[0].id})):B({type:"SET_SELECTED_PROXY",payload:""})}),[D,v]);const K=(0,xt.useCallback)((()=>{const e=I.isLoading||!I.selectedProxy&&!I.useCustomRendition&&!I.useRepresentative,i=(l&&null!==v&&void 0!==v&&v.docType?(0,tn.A)([...l[v.docType],{displayName:"Automatic",value:s}],"value"):[{displayName:"Automatic",value:s}]).filter((e=>a||e.value!==s)),c=t&&i.length>0&&h.includes(v?v.extension:""),f=D&&Object.values(D).flat().length>0,g=Boolean(I.selectedFormat.width&&I.selectedFormat.height&&I.useCustomRendition);return(0,Ut.jsxs)(Ut.Fragment,{children:[I.showVersionHistory?(0,Ut.jsx)("cx-space",{slot:"label","justify-content":"space-between","align-items":"center",children:(0,Ut.jsxs)("cx-space",{direction:"vertical",spacing:"2x-small",style:{flex:"1"},children:[(0,Ut.jsx)("cx-typography",{variant:"h4",children:"Version history"}),(0,Ut.jsx)("cx-typography",{variant:"body3",className:"asset-name",children:(0,Ut.jsx)(Kt,{lines:1,children:null===v||void 0===v?void 0:v.name})})]})}):(0,Ut.jsxs)(Ut.Fragment,{children:[(0,Ut.jsx)("cx-space",{slot:"label","justify-content":"space-between","align-items":"center",children:(0,Ut.jsxs)("cx-space",{direction:"vertical",spacing:"2x-small",style:{flex:"1"},children:[(0,Ut.jsx)("cx-typography",{variant:"h4",children:r?"Custom format":"Preview"}),(0,Ut.jsx)("cx-typography",{variant:"body3",className:"asset-name",children:(0,Ut.jsx)(Kt,{lines:1,children:null===v||void 0===v?void 0:v.name})})]})}),n&&(0,Ut.jsx)("cx-tooltip",{slot:"header-actions",content:p?"Unfavorite":"Favorite",placement:"bottom",children:I.isLoadingFavorites?(0,Ut.jsx)("cx-space",{"align-items":"center","justify-content":"center",style:{width:"32px",height:"32px"},children:(0,Ut.jsx)("cx-spinner",{})}):(0,Ut.jsx)("cx-icon-button",{name:p?"star":"star_outline",style:{color:p?"var(--cx-color-warning)":"var(--cx-color-text)"},onClick:async()=>{I.isLoadingFavorites||(B({type:"SET_LOADING_FAVORITES",payload:!0}),p?await S():await C(),B({type:"SET_LOADING_FAVORITES",payload:!1}))}})}),b&&(0,Ut.jsx)("cx-tooltip",{slot:"header-actions",content:"Version history",placement:"bottom",children:(0,Ut.jsx)("cx-icon-button",{name:"history",onClick:H})})]}),(()=>{let e=null,t=null;if(e=I.selectedFormat.width&&I.selectedFormat.height&&(null===v||void 0===v?void 0:v.docType)===Jt.zu.Image?(0,Ut.jsx)(Dn,{ref:Q,loadable:I.previewLoadable,image:I.selectedFormat,selectedProxy:I.selectedProxy,proxies:D,resizer:I.resizeSize,cropper:I.cropSize,rotation:I.rotation,isCustomRenditionEnabled:I.showCustomRendition||I.useCustomRendition,disabled:"crop"!==I.activeSetting||!I.showCustomRendition,onCropComplete:e=>{B({type:"SET_CROP_SIZE",payload:{percentageWidth:e.width,percentageHeight:e.height,x:e.x,y:e.y}})},onLoadingChange:N}):(0,Ut.jsx)($n,{loadable:I.previewLoadable,asset:{docType:null===v||void 0===v?void 0:v.docType,imageUrl:null===v||void 0===v?void 0:v.imageUrl,videoUrl:m,extension:null===v||void 0===v?void 0:v.extension},onLoad:e=>{if(null!==v&&void 0!==v&&v.width&&null!==v&&void 0!==v&&v.height||null===v||void 0===v||!v.imageUrl)return;const t=null!==v&&void 0!==v&&v.width?parseInt(v.width,10):e.width,n=null!==v&&void 0!==v&&v.height?parseInt(v.height,10):e.height;B({type:"SET_DEFAULT_SIZE",payload:{width:t,height:n}})}}),I.showVersionHistory)return(0,Ut.jsx)(sr,{assetId:null===v||void 0===v?void 0:v.id});if(!r)return e;var n;I.showCustomRendition&&D?t=(0,Ut.jsx)(Xn,{activeSetting:I.activeSetting,extensions:i,availableProxies:D,imageSize:{width:I.selectedFormat.width?I.selectedFormat.width:1/0,height:I.selectedFormat.height?I.selectedFormat.height:1/0},resize:{width:I.resizeSize.width,height:I.resizeSize.height,unit:I.resizeSize.unit},crop:I.cropSize,keepMetadata:I.keepMetadata,lastAppliedCrop:I.lastCropSize,lastAppliedResize:I.lastResizeSize,proxy:I.selectedProxy,quality:I.quality,rotation:I.rotation,extension:I.selectedFormat.extension,onCropChange:L,onExtensionChange:M,onFormatChange:V,onKeepMetadataChange:q,onQualityChange:W,onResizeChange:j,onRotateChange:F,onViewChange:U}):t=(0,Ut.jsx)("cx-space",{direction:"vertical",spacing:"small",children:f||c?(0,Ut.jsxs)("div",{style:{width:"100%"},children:[f&&(0,Ut.jsx)(tr,{items:null===D||void 0===D?void 0:D.map((e=>{var t;return"TRX"===e.proxyName&&v?{value:e.id,name:e.proxyLabel,cdnName:e.cdnName,width:v.width,height:v.height,extension:v.extension,docType:v.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===v||void 0===v?void 0:v.docType}})),selectedDisabled:I.useCustomRendition,selectedItem:I.selectedProxy,children:R&&(0,Ut.jsxs)("cx-menu-item",{value:"use-representative",children:[(0,Ut.jsx)("cx-typography",{variant:"body3",className:"proxy__name "+(I.useRepresentative?"selected":""),children:"Representative image"}),(0,Ut.jsx)("cx-icon",{slot:"suffix",name:I.useRepresentative?"check":""})]})}),c&&(0,Ut.jsx)(tr,{items:[],selectedItem:I.selectedProxy,style:{borderTopWidth:"0"},children:(0,Ut.jsxs)("cx-menu-item",{value:"custom","data-cy":"custom-rendition-menu-item",children:[(0,Ut.jsx)("cx-icon",{slot:"prefix",name:"crop_rotate",className:"icon--large"}),(0,Ut.jsxs)("div",{children:[(0,Ut.jsx)("cx-typography",{variant:"body3",className:"proxy__name "+(I.useCustomRendition?"selected":""),children:"Custom format"}),g?(0,Ut.jsxs)("cx-typography",{variant:"body3",className:"proxy__details",children:[I.selectedFormat.width," x"," ",I.selectedFormat.height,I.selectedFormat.extension&&(0,Ut.jsx)("div",{className:"proxy__extension-dot"}),null===(n=I.selectedFormat.extension)||void 0===n?void 0:n.replace(/^\./,"").toUpperCase()]}):null]}),(0,Ut.jsx)("cx-icon",{slot:"suffix",name:I.useCustomRendition?"edit":"",className:"icon--large"}),(0,Ut.jsx)("cx-icon",{slot:"suffix",name:I.useCustomRendition?"check":"",className:"icon--large icon--primary"})]})}),o&&(0,Ut.jsxs)("div",{style:{backgroundColor:"var(--cx-color-neutral-0)",width:"100%"},children:[(0,Ut.jsx)(tr,{children:(0,Ut.jsxs)("cx-menu-item",{value:"tracking",className:"proxy--switch",children:[(0,Ut.jsx)("cx-typography",{variant:"body3",className:"proxy__name",children:"Tracking parameters"}),(0,Ut.jsx)("cx-switch",{checked:I.enabledTracking,onClick:e=>e.preventDefault()})]})}),I.enabledTracking&&(0,Ut.jsx)(nr,{values:I.trackingParameters,onChange:e=>B({type:"SET_TRACKING_PARAMETERS",payload:e})})]})]}):(0,Ut.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,Ut.jsx)("cx-icon",{style:{color:"var(--cx-color-warning)"},name:"warning",className:"ic_warning_amber"}),(0,Ut.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,Ut.jsxs)(Ut.Fragment,{children:[e,t]})})(),(()=>{if(I.showVersionHistory)return null;let t=null;return t=r?I.showCustomRendition?(0,Ut.jsxs)("cx-space",{spacing:"small",style:{width:"fit-content"},children:[(0,Ut.jsx)("cx-button",{variant:"default",onClick:()=>{var e,t,n,r,o;I.useCustomRendition?B({type:"CANCEL_USE_CUSTOM_RENDITION",payload:{url:I.defaultSelectedFormat.url,originalUrl:I.defaultSelectedFormat.originalUrl,width:I.defaultSelectedFormat.width,height:I.defaultSelectedFormat.height,extension:I.defaultSelectedFormat.extension,selectedProxy:I.defaultSelectedProxy,useCustomRendition:!0}}):B({type:"CANCEL_USE_CUSTOM_RENDITION",payload:{url:null!==(e=null===v||void 0===v?void 0:v.imageUrl)&&void 0!==e?e:"",originalUrl:null!==(t=null===v||void 0===v?void 0:v.originalUrl)&&void 0!==t?t:"",width:parseInt(null!==(n=null===v||void 0===v?void 0:v.width)&&void 0!==n?n:"0",10),height:parseInt(null!==(r=null===v||void 0===v?void 0:v.height)&&void 0!==r?r:"0",10),extension:null!==(o=null===v||void 0===v?void 0:v.extension)&&void 0!==o?o:"",useCustomRendition:!1,selectedProxy:""}})},children:"Cancel"}),(0,Ut.jsx)("cx-button",{variant:"primary",onClick:()=>{B({type:"CONFIRM_USE_CUSTOM_RENDITION"})},children:"Done"})]}):(0,Ut.jsx)("cx-button",{className:"dialog__footer__button",disabled:e,loading:I.isLoadingConfirm,variant:"primary",style:{flex:1},onClick:async()=>{const e=null===D||void 0===D?void 0:D.find((e=>e.id===I.selectedProxy));if(I.useCustomRendition){var t,n,r,o,i,a,s,l,c,u,d,h,p,f,g;if(null===v||void 0===v||!v.docType)return;B({type:"SET_LOADING_CONFIRM",payload:!0}),await k({value:I.transformations,parameters:I.enabledTracking?I.trackingParameters:void 0,proxiesPreference:null===e||void 0===e?void 0:e.proxyName,extension:I.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)?v.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=v.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=v.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=I.selectedFormat)||void 0===d?void 0:d.extension)&&void 0!==u?u:null,isCustomFormat:!0,height:null!==(h=null===(p=I.selectedFormat)||void 0===p?void 0:p.height)&&void 0!==h?h:null,width:null!==(f=null===(g=I.selectedFormat)||void 0===g?void 0:g.width)&&void 0!==f?f:null,permanentLink:null}}),B({type:"SET_LOADING_CONFIRM",payload:!1})}else{var m,b,y,A,x,C,S,_,T,O,P,Q;if(null===v||void 0===v||!v.docType)return;if(!e&&!I.useRepresentative)return;B({type:"SET_LOADING_CONFIRM",payload:!0}),await E({extension:null!==(m=null===e||void 0===e?void 0:e.extension)&&void 0!==m?m:v.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:I.enabledTracking?I.trackingParameters:void 0,useRepresentative:I.useRepresentative,selectedProxyMetadata:{cdnName:null!==(A=null===e||void 0===e?void 0:e.cdnName)&&void 0!==A?A:null,extension:"TRX"===(null===e||void 0===e?void 0:e.proxyName)?v.extension:null!==(x=null===e||void 0===e?void 0:e.extension)&&void 0!==x?x:null,isCustomFormat:!1,width:"TRX"===(null===e||void 0===e?void 0:e.proxyName)?parseInt(null!==(C=v.width)&&void 0!==C?C:"0",10):null!==(S=null===e||void 0===e?void 0:e.formatWidth)&&void 0!==S?S:null,height:"TRX"===(null===e||void 0===e?void 0:e.proxyName)?parseInt(null!==(_=v.height)&&void 0!==_?_:"0",10):null!==(T=null===e||void 0===e?void 0:e.formatHeight)&&void 0!==T?T:null,permanentLink:null!==(O=null===e||void 0===e?void 0:e.permanentLink)&&void 0!==O?O:null,proxyLabel:null!==(P=null===e||void 0===e?void 0:e.proxyLabel)&&void 0!==P?P:null,proxyName:null!==(Q=null===e||void 0===e?void 0:e.proxyName)&&void 0!==Q?Q:null}}),B({type:"SET_LOADING_CONFIRM",payload:!1})}B({type:"RESET_DATA"}),w()},children:(0,Ut.jsx)("span",{style:{textTransform:d},children:u})}):(0,Ut.jsxs)("cx-button",{className:"dialog__footer__button",loading:I.isLoadingConfirm,onClick:async()=>{null!==v&&void 0!==v&&v.docType&&(B({type:"SET_LOADING_CONFIRM",payload:!0}),await E({extension:v.extension,useRepresentative:!0,value:""}),B({type:"SET_LOADING_CONFIRM",payload:!1}))},variant:"primary",children:[(0,Ut.jsx)("cx-icon",{slot:"prefix",name:"folder"}),(0,Ut.jsx)("span",{style:{textTransform:d},children:u})]}),(0,Ut.jsx)("div",{slot:"footer",className:"dialog__footer",children:t})})()]})}),[t,n,r,o,a,s,l,u,d,h,D,H,p,m,v,b,I,R,w,L,M,C,V,k,q,N,E,W,j,F,S,U]);return"drawer"===A?(0,Ut.jsx)(Yn,{ref:P,className:"dialog",label:"Drawer",placement:"bottom",contained:!0,open:g,children:K()}):(0,Ut.jsx)(Gn,{ref:O,className:"dialog",open:g,"use-overlay-scrollbar":lr||void 0,"overlay-scrollbar-auto-hide":"never",style:{"--max-height":`${f}px`,"--max-width":I.showVersionHistory?"600px":"520px"},children:K()})};var hr=n(5650);const pr=(0,Lt.Ay)("cx-space")`
741
+ `;var or=n(3943);const ir=e=>{let{src:t,alt:n}=e;const[r,o]=(0,xt.useState)("horizontal"),i=(0,xt.useRef)(null),a=(0,xt.useCallback)((()=>{if(i.current){const{naturalWidth:e,naturalHeight:t}=i.current;o(e>t?"horizontal":"vertical")}}),[]);return(0,Ut.jsx)("div",{className:`version__item__preview version__item__preview--${r}`,children:(0,Ut.jsx)("img",{ref:i,src:t,alt:n,onLoad:a})})},ar=e=>{let{src:t}=e;const[n,r]=(0,xt.useState)("horizontal"),o=(0,xt.useRef)(null),i=(0,xt.useCallback)((()=>{if(o.current){const{videoWidth:e,videoHeight:t}=o.current;r(e>t?"horizontal":"vertical")}}),[]);return(0,Ut.jsx)("div",{className:`version__item__preview version__item__preview--${n}`,children:(0,Ut.jsx)("video",{ref:o,src:t,onLoadedMetadata:i,controls:!0})})},sr=e=>{var t;let{assetId:n}=e;const{data:r,isFetching:o,isLoading:i}=(0,or.cP)(n?{assetId:n}:jt.hT);return o||i?(0,Ut.jsx)(rr,{children:(0,Ut.jsx)("cx-spinner",{})}):(0,Ut.jsx)(rr,{children:(0,Ut.jsx)("cx-menu",{children:null===r||void 0===r||null===(t=r.versions)||void 0===t?void 0:t.map(((e,t)=>(0,Ut.jsx)("cx-menu-item",{className:"version__item",readonly:!0,children:(0,Ut.jsxs)("cx-grid",{columns:5,spacing:"12px",children:[(0,Ut.jsx)("cx-grid-item",{xs:"2",sm:"2",children:(0,Ut.jsxs)("cx-space",{direction:"horizontal","align-items":"center",wrap:"nowrap",children:[(0,Ut.jsx)("div",{className:"version__item__number",children:(0,Ut.jsx)(Kt,{lines:1,children:e.versionNumberDisplay})}),e.scrubUrl?(0,Ut.jsx)(ar,{src:e.scrubUrl}):(0,Ut.jsx)(ir,{src:e.versionFileUrl,alt:e.versionFileName})]})}),(0,Ut.jsx)("cx-grid-item",{xs:"2",sm:"3",children:(0,Ut.jsxs)("cx-space",{direction:"vertical",spacing:"2x-small",children:[(0,Ut.jsx)(Kt,{lines:1,children:(0,Ut.jsx)("cx-typography",{variant:"body3",className:"version__item__name",children:e.versionFileName})}),(0,Ut.jsx)(Kt,{lines:1,children:(0,Ut.jsx)("cx-typography",{variant:"body3",children:e.createByEmail})}),(0,Ut.jsxs)("cx-typography",{variant:"body3",children:[e.versionCreateDate.split(" ")[0],0===t&&(0,Ut.jsx)("span",{className:"version__item__latest",children:"Current version"})]})]})})]})},e.versionNumber)))})})},lr=CSS.supports("(overlay: auto)")&&"showPopover"in document.createElement("div"),cr={previewLoadable:!1,defaultSize:{width:0,height:0},selectedProxy:"",defaultSelectedProxy:"",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:dn.Nf.Pixel},lastResizeSize:{[dn.Nf.AspectRatio]:{width:0,height:0,unit:dn.Nf.AspectRatio},[dn.Nf.Pixel]:{width:0,height:0,unit:dn.Nf.Pixel}},cropSize:{width:0,height:0,percentageWidth:0,percentageHeight:0,x:0,y:0,unit:dn.Nf.Pixel},lastCropSize:{[dn.Nf.AspectRatio]:{width:0,height:0,percentageWidth:0,percentageHeight:0,x:0,y:0,unit:dn.Nf.AspectRatio},[dn.Nf.Pixel]:{width:0,height:0,percentageWidth:0,percentageHeight:0,x:0,y:0,unit:dn.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},ur=(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&&!t.payload.resetTransformations?e.confirmedTransformations:[],confirmedTransformations:t.payload.resetTransformations?[]:e.confirmedTransformations,showCustomRendition:!1,activeSetting:"format",selectedProxy:t.payload.selectedProxy};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},defaultSelectedProxy:e.selectedProxy};case"SET_DEFAULT_SIZE":return{...e,defaultSize:{...e.defaultSize,...t.payload}};case"RESET_DATA":return cr;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_DEFAULT_SELECTED_FORMAT":return{...e,defaultSelectedFormat:{...e.defaultSelectedFormat,...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_DEFAULT_SELECTED_PROXY":return{...e,defaultSelectedProxy:t.payload};case"SET_SHOW_CUSTOM_RENDITION":return{...e,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}},dr=e=>{let{allowCustomFormat:t,allowFavorites:n,allowProxy:r,allowTracking:o,allowedExtensions:i,appendAutoExtension:a,autoExtension:s,availableExtensions:l,availableProxies:c,ctaText:u="Insert",ctaTextTransform:d="capitalize",extensions:h,isFavorite:p,maxHeight:f,open:g,previewUrl:m,selectedAsset:v,showVersions:b,supportedRepresentativeSubtypes:y,variant:A="dialog",boundary:x,onClose:w,onFavorite:C,onProxyConfirm:E,onFormatConfirm:k,onUnFavorite:S}=e;const[I,B]=(0,xt.useReducer)(ur,cr),[_,T]=(0,xt.useState)(!1),O=(0,xt.useRef)(null),P=(0,xt.useRef)(null),Q=(0,xt.useRef)(null),D=(0,xt.useMemo)((()=>i?c?c.filter((e=>{if(!e.extension&&v){return!!(null===i||void 0===i?void 0:i.some((e=>e===v.extension.replace(/^\./,""))))}return!0})):[]:c),[c,i,v]),z=(0,xt.useCallback)((()=>{if(!v)return;const e=hn(I.defaultSize.width,I.defaultSize.height);B({type:"SET_RESIZE_SIZE",payload:{...cr.resizeSize,width:I.defaultSize.width,height:I.defaultSize.height}}),B({type:"SET_CROP_SIZE",payload:{...cr.cropSize,width:I.defaultSize.width,height:I.defaultSize.height,percentageHeight:100,percentageWidth:100}}),B({type:"SET_ROTATION",payload:0}),B({type:"SET_LAST_CROP_SIZE",payload:{...cr.lastCropSize,[dn.Nf.Pixel]:{width:I.defaultSize.width,height:I.defaultSize.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:dn.Nf.Pixel},[dn.Nf.AspectRatio]:{width:e.width,height:e.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:dn.Nf.AspectRatio}}}),B({type:"SET_LAST_RESIZE_SIZE",payload:{[dn.Nf.Pixel]:{width:I.defaultSize.width,height:I.defaultSize.height,unit:dn.Nf.Pixel},[dn.Nf.AspectRatio]:{width:e.width,height:e.height,unit:dn.Nf.AspectRatio}}});let t=v.extension;if(a)t=s;else if(v.docType){var n,r,o,i;if(null!==l&&void 0!==l&&null!==(n=l[v.docType])&&void 0!==n&&n.map((e=>e.value)).includes(v.extension))t=v.extension;else t=null!==(r=null===l||void 0===l||null===(o=l[v.docType])||void 0===o||null===(i=o[0])||void 0===i?void 0:i.value)&&void 0!==r?r:""}if(D&&D.length>0){var c,u;B({type:"SET_SELECTED_PROXY",payload:null===(c=D[0])||void 0===c?void 0:c.id}),B({type:"SET_DEFAULT_SELECTED_PROXY",payload:null===(u=D[0])||void 0===u?void 0:u.id});const e={...cr.selectedFormat,url:v.imageUrl,originalUrl:v.originalUrl,extension:t,width:D[0].formatWidth||I.defaultSize.width,height:D[0].formatHeight||I.defaultSize.height};B({type:"SET_SELECTED_FORMAT",payload:e}),B({type:"SET_DEFAULT_SELECTED_FORMAT",payload:e})}else B({type:"SET_SELECTED_FORMAT",payload:{...cr.selectedFormat,url:v.imageUrl,originalUrl:v.originalUrl,extension:t,width:I.defaultSize.width,height:I.defaultSize.height}})}),[s,D,v,I.defaultSize.height,I.defaultSize.width,a,l]);(0,xt.useEffect)((()=>{null!==v&&void 0!==v&&v.width&&null!==v&&void 0!==v&&v.height&&B({type:"SET_DEFAULT_SIZE",payload:{width:parseInt(v.width,10),height:parseInt(v.height,10)}})}),[null===v||void 0===v?void 0:v.width,null===v||void 0===v?void 0:v.height]),(0,xt.useEffect)((()=>{Promise.all([customElements.whenDefined("cx-dialog"),customElements.whenDefined("cx-drawer"),customElements.whenDefined("cx-dropdown")]).then((()=>{T(!0)}))}),[]),(0,xt.useEffect)((()=>{const e=e=>{I.isLoadingFavorites?e.preventDefault():I.showVersionHistory?(e.preventDefault(),B({type:"SET_SHOW_VERSION_HISTORY",payload:!1})):(B({type:"SET_PREVIEW_LOADABLE",payload:!1}),B({type:"RESET_DATA"}),w())},t=O.current,n=P.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,_,w,I.isLoadingFavorites,I.showVersionHistory,A]),(0,xt.useEffect)((()=>{const e=O.current;e&&x&&(e.boundary=x)})),(0,xt.useEffect)((()=>{const e=()=>{B({type:"SET_PREVIEW_LOADABLE",payload:!0})},t=O.current,n=P.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)}}),[_,I.showCustomRendition,A]),(0,xt.useEffect)((()=>{const e=e=>{const t=e.detail.item.value;if("custom"===t)return B({type:"SET_SHOW_CUSTOM_RENDITION",payload:!0}),void(I.useCustomRendition||z());if("tracking"!==t)if("use-representative"!==t){if(t&&D){var n,r,o,i,a;if(!D.map((e=>e.id)).includes(t))return;B({type:"CANCEL_USE_CUSTOM_RENDITION",payload:{url:null!==(n=null===v||void 0===v?void 0:v.imageUrl)&&void 0!==n?n:"",originalUrl:null!==(r=null===v||void 0===v?void 0:v.originalUrl)&&void 0!==r?r:"",width:parseInt(null!==(o=null===v||void 0===v?void 0:v.width)&&void 0!==o?o:"0",10),height:parseInt(null!==(i=null===v||void 0===v?void 0:v.height)&&void 0!==i?i:"0",10),extension:null!==(a=null===v||void 0===v?void 0:v.extension)&&void 0!==a?a:"",useCustomRendition:!1,resetTransformations:!0,selectedProxy:""}}),B({type:"SET_SELECTED_PROXY",payload:t})}}else B({type:"SET_USE_REPRESENTATIVE",payload:!I.useRepresentative});else B({type:"SET_ENABLED_TRACKING",payload:!I.enabledTracking})},t=O.current,n=P.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)}}),[_,I.enabledTracking,I.useCustomRendition,I.useRepresentative,z,D,null===v||void 0===v?void 0:v.width,null===v||void 0===v?void 0:v.height,null===v||void 0===v?void 0:v.imageUrl,null===v||void 0===v?void 0:v.originalUrl,null===v||void 0===v?void 0:v.extension,A]),(0,xt.useEffect)((()=>{z()}),[z]);const R=(0,xt.useMemo)((()=>{var e;return(null===y||void 0===y?void 0:y.includes(null!==(e=null===v||void 0===v?void 0:v.docSubType)&&void 0!==e?e:""))&&(null===v||void 0===v?void 0:v.imageUrl)}),[v,y]),N=(0,xt.useCallback)((e=>{B({type:"SET_LOADING",payload:e})}),[]),j=(0,xt.useCallback)((async(e,t,n,r)=>{if(!v)return;const o=I.selectedFormat.width||I.defaultSize.width,i=I.selectedFormat.height||I.defaultSize.height;if(B({type:"SET_RESIZE_SIZE",payload:{width:e,height:t,unit:n}}),r){var a;let r=e,s=t;I.resizeSize.unit!==n?(r=o,s=i):n===dn.Nf.AspectRatio&&(r=Math.round(e/t*i),s=i);const l=await(null===(a=Q.current)||void 0===a?void 0:a.applyResize());B({type:"SET_SELECTED_FORMAT",payload:{url:l,width:r,height:s}}),B({type:"SET_TRANSFORMATIONS",payload:{key:dn.YQ.Resize,value:{width:r,height:s,originalWidth:o,originalHeight:i}}}),B({type:"SET_CROP_SIZE",payload:{width:r,height:s}});const c=hn(r,s);B({type:"SET_LAST_RESIZE_SIZE",payload:{[dn.Nf.Pixel]:{width:r,height:s,unit:dn.Nf.Pixel},[dn.Nf.AspectRatio]:{width:n===dn.Nf.AspectRatio?e:c.width,height:n===dn.Nf.AspectRatio?t:c.height,unit:dn.Nf.AspectRatio}}}),B({type:"SET_LAST_CROP_SIZE",payload:{[dn.Nf.Pixel]:{width:r,height:s,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:dn.Nf.Pixel},[dn.Nf.AspectRatio]:{width:n===dn.Nf.AspectRatio?e:c.width,height:n===dn.Nf.AspectRatio?t:c.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:dn.Nf.AspectRatio}}})}}),[v,I.defaultSize.height,I.defaultSize.width,I.resizeSize.unit,I.selectedFormat.height,I.selectedFormat.width]),L=(0,xt.useCallback)((async(e,t,n,r)=>{var o,i;if(!v)return;const a=I.cropSize.unit,s=Q.current;if(s&&null!==(o=I.selectedFormat)&&void 0!==o&&o.width&&null!==(i=I.selectedFormat)&&void 0!==i&&i.height){if(n===a&&n===dn.Nf.Pixel){const n=Math.max(e/I.selectedFormat.width,t/I.selectedFormat.height);s.setZoom(1/n)}n!==a&&s.setZoom(1)}if(B({type:"SET_CROP_SIZE",payload:{width:e,height:t,unit:n}}),r){var l;const r=await(null===(l=Q.current)||void 0===l?void 0:l.applyCrop());let o=e,i=t;n===dn.Nf.AspectRatio&&(o=Math.round(I.cropSize.percentageWidth*I.selectedFormat.width/100),i=Math.round(I.cropSize.percentageHeight*I.selectedFormat.height/100)),null===s||void 0===s||s.setZoom(1);const a=Number((I.cropSize.x/100*I.selectedFormat.width).toFixed(0)),c=Number((I.cropSize.y/100*I.selectedFormat.height).toFixed(0));B({type:"SET_SELECTED_FORMAT",payload:{url:r,width:o,height:i}}),B({type:"SET_RESIZE_SIZE",payload:{width:o,height:i,unit:dn.Nf.Pixel}}),B({type:"SET_TRANSFORMATIONS",payload:{key:dn.YQ.Crop,value:{width:Number(o.toFixed(0)),height:Number(i.toFixed(0)),x:a,y:c,percentageWidth:I.cropSize.percentageWidth,percentageHeight:I.cropSize.percentageHeight,percentageX:I.cropSize.x,percentageY:I.cropSize.y}}});const u=hn(o,i);B({type:"SET_LAST_CROP_SIZE",payload:{[dn.Nf.Pixel]:{width:Math.round(o),height:Math.round(i),percentageHeight:100,percentageWidth:100,x:0,y:0,unit:dn.Nf.Pixel},[dn.Nf.AspectRatio]:{width:n===dn.Nf.AspectRatio?e:u.width,height:n===dn.Nf.AspectRatio?t:u.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:dn.Nf.AspectRatio}}}),B({type:"SET_LAST_RESIZE_SIZE",payload:{[dn.Nf.Pixel]:{width:o,height:i,unit:dn.Nf.Pixel},[dn.Nf.AspectRatio]:{width:n===dn.Nf.AspectRatio?e:u.width,height:n===dn.Nf.AspectRatio?t:u.height,unit:dn.Nf.AspectRatio}}})}}),[v,I.cropSize,I.selectedFormat.height,I.selectedFormat.width]),F=(0,xt.useCallback)((async(e,t)=>{if(t){var n;const{width:t,height:r}=pn(I.selectedFormat.width,I.selectedFormat.height,e),o=await(null===(n=Q.current)||void 0===n?void 0:n.applyRotation());B({type:"SET_SELECTED_FORMAT",payload:{rotation:e,url:o,width:t,height:r}}),B({type:"SET_TRANSFORMATIONS",payload:{key:dn.YQ.Rotate,value:{rotation:e}}}),B({type:"SET_CROP_SIZE",payload:{width:t,height:r}}),B({type:"SET_RESIZE_SIZE",payload:{width:t,height:r,unit:dn.Nf.Pixel}});const i=hn(t,r);B({type:"SET_LAST_CROP_SIZE",payload:{[dn.Nf.Pixel]:{width:t,height:r,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:dn.Nf.Pixel},[dn.Nf.AspectRatio]:{width:i.width,height:i.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:dn.Nf.AspectRatio}}}),B({type:"SET_LAST_RESIZE_SIZE",payload:{[dn.Nf.Pixel]:{width:t,height:r,unit:dn.Nf.Pixel},[dn.Nf.AspectRatio]:{width:i.width,height:i.height,unit:dn.Nf.AspectRatio}}}),B({type:"SET_ROTATION",payload:0})}else B({type:"SET_ROTATION",payload:e})}),[I.selectedFormat]),M=(0,xt.useCallback)((e=>{B({type:"SET_SELECTED_FORMAT",payload:{extension:e}})}),[]),U=(0,xt.useCallback)((e=>{B({type:"SET_CROP_SIZE",payload:{width:I.selectedFormat.width,height:I.selectedFormat.height,unit:dn.Nf.Pixel}}),B({type:"SET_RESIZE_SIZE",payload:{width:I.selectedFormat.width,height:I.selectedFormat.height,unit:dn.Nf.Pixel}}),B({type:"SET_ROTATION",payload:0}),B({type:"SET_ACTIVE_SETTING",payload:e})}),[I.selectedFormat]),H=(0,xt.useCallback)((()=>{B({type:"SET_SHOW_VERSION_HISTORY",payload:!0})}),[]),V=(0,xt.useCallback)((async e=>{var t;let n=e.formatWidth,r=e.formatHeight;"TRX"===e.proxyName&&v&&(n=Number(v.width),r=Number(v.height)),B({type:"SET_SELECTED_PROXY",payload:{proxy:e.id}});const{rotation:o,croppedWidth:i,croppedHeight:a,percentageWidth:s,percentageHeight:l,percentageX:c,percentageY:u,effectiveWidth:d,effectiveHeight:h}=(e=>{let{width:t,height:n,transformations:r}=e,o=0,i=100,a=100,s=0,l=0,c=t,u=n,d=!1;for(const P of r)if(P.key===dn.YQ.Rotate){var h,p;const e=null!==(h=null===(p=P.value)||void 0===p?void 0:p.rotation)&&void 0!==h?h:0;o=(o+e)%360,e%180!==0&&e%90===0&&(d=!d,[c,u]=[u,c])}else if(P.key===dn.YQ.Crop){var f,g,m,v,b,y,A,x;const e=null!==(f=null===(g=P.value)||void 0===g?void 0:g.percentageX)&&void 0!==f?f:0,t=null!==(m=null===(v=P.value)||void 0===v?void 0:v.percentageY)&&void 0!==m?m:0,n=null!==(b=null===(y=P.value)||void 0===y?void 0:y.percentageWidth)&&void 0!==b?b:100,r=null!==(A=null===(x=P.value)||void 0===x?void 0:x.percentageHeight)&&void 0!==A?A:100;let d,h,p,w;switch(o){case 90:d=t,h=100-e-n,p=r,w=n;break;case 180:d=100-e-n,h=100-t-r,p=n,w=r;break;case 270:d=100-t-r,h=e,p=r,w=n;break;default:d=e,h=t,p=n,w=r}s+=d*i/100,l+=h*a/100,i=i*p/100,a=a*w/100,c=c*n/100,u=u*r/100}else if(P.key===dn.YQ.Resize){var w,C,E,k,S,I,B,_;const e=null!==(w=null===(C=P.value)||void 0===C?void 0:C.width)&&void 0!==w?w:c,t=null!==(E=null===(k=P.value)||void 0===k?void 0:k.height)&&void 0!==E?E:u;c*=e/(null!==(S=null===(I=P.value)||void 0===I?void 0:I.originalWidth)&&void 0!==S?S:e),u*=t/(null!==(B=null===(_=P.value)||void 0===_?void 0:_.originalHeight)&&void 0!==B?B:t)}d&&([c,u]=[u,c]);const T=t*(i/100),O=n*(a/100);return{rotation:r.reduce(((e,t)=>{var n,r;return t.key===dn.YQ.Rotate&&(e+=null!==(n=null===(r=t.value)||void 0===r?void 0:r.rotation)&&void 0!==n?n:0),e}),0)%360,croppedWidth:Math.round(T),croppedHeight:Math.round(O),percentageWidth:i,percentageHeight:a,percentageX:s,percentageY:l,effectiveWidth:Math.round(c),effectiveHeight:Math.round(u)}})({width:n,height:r,transformations:I.transformations});B({type:"SET_CROP_SIZE",payload:{width:i,height:a,percentageWidth:s,percentageHeight:l,x:c,y:u,unit:dn.Nf.Pixel}});const p=await On({cropper:{height:a,width:i,percentageHeight:l,percentageWidth:s,x:c,y:u,unit:dn.Nf.Pixel},image:{url:null!==(t=null===v||void 0===v?void 0:v.imageUrl)&&void 0!==t?t:"",width:n,height:r},loadable:I.previewLoadable,onLoadingChange:N,zoom:1}),{width:f,height:g}=pn(d,h,o),m=await Pn({image:{url:p,width:d,height:h},loadable:I.previewLoadable,onLoadingChange:N,rotation:o});B({type:"SET_SELECTED_FORMAT",payload:{url:m,width:f,height:g}}),B({type:"SET_RESIZE_SIZE",payload:{width:f,height:g,unit:dn.Nf.Pixel}});const b=hn(n,r);B({type:"SET_LAST_CROP_SIZE",payload:{[dn.Nf.Pixel]:{width:Math.round(n),height:Math.round(r),percentageHeight:100,percentageWidth:100,x:0,y:0,unit:dn.Nf.Pixel},[dn.Nf.AspectRatio]:{width:b.width,height:b.height,percentageHeight:100,percentageWidth:100,x:0,y:0,unit:dn.Nf.AspectRatio}}}),B({type:"SET_LAST_RESIZE_SIZE",payload:{[dn.Nf.Pixel]:{width:f,height:g,unit:dn.Nf.Pixel},[dn.Nf.AspectRatio]:{width:b.width,height:b.height,unit:dn.Nf.AspectRatio}}})}),[N,v,I]),W=(0,xt.useCallback)((e=>{B({type:"SET_QUALITY",payload:e}),B({type:"SET_TRANSFORMATIONS",payload:{key:dn.YQ.Quality,value:{quality:e}}})}),[]),q=(0,xt.useCallback)((e=>{B({type:"SET_KEEP_METADATA",payload:e}),B({type:"SET_TRANSFORMATIONS",payload:{key:dn.YQ.KeepMetadata,value:{keepMetadata:e}}})}),[]);(0,xt.useEffect)((()=>{D&&0!==D.length?(B({type:"SET_SELECTED_PROXY",payload:D[0].id}),B({type:"SET_DEFAULT_SELECTED_PROXY",payload:D[0].id})):B({type:"SET_SELECTED_PROXY",payload:""})}),[D,v]);const K=(0,xt.useCallback)((()=>{const e=I.isLoading||!I.selectedProxy&&!I.useCustomRendition&&!I.useRepresentative,i=(l&&null!==v&&void 0!==v&&v.docType?(0,tn.A)([...l[v.docType],{displayName:"Automatic",value:s}],"value"):[{displayName:"Automatic",value:s}]).filter((e=>a||e.value!==s)),c=t&&i.length>0&&h.includes(v?v.extension:""),f=D&&Object.values(D).flat().length>0,g=Boolean(I.selectedFormat.width&&I.selectedFormat.height&&I.useCustomRendition);return(0,Ut.jsxs)(Ut.Fragment,{children:[I.showVersionHistory?(0,Ut.jsx)("cx-space",{slot:"label","justify-content":"space-between","align-items":"center",children:(0,Ut.jsxs)("cx-space",{direction:"vertical",spacing:"2x-small",style:{flex:"1"},children:[(0,Ut.jsx)("cx-typography",{variant:"h4",children:"Version history"}),(0,Ut.jsx)("cx-typography",{variant:"body3",className:"asset-name",children:(0,Ut.jsx)(Kt,{lines:1,children:null===v||void 0===v?void 0:v.name})})]})}):(0,Ut.jsxs)(Ut.Fragment,{children:[(0,Ut.jsx)("cx-space",{slot:"label","justify-content":"space-between","align-items":"center",children:(0,Ut.jsxs)("cx-space",{direction:"vertical",spacing:"2x-small",style:{flex:"1"},children:[(0,Ut.jsx)("cx-typography",{variant:"h4",children:r?"Custom format":"Preview"}),(0,Ut.jsx)("cx-typography",{variant:"body3",className:"asset-name",children:(0,Ut.jsx)(Kt,{lines:1,children:null===v||void 0===v?void 0:v.name})})]})}),n&&(0,Ut.jsx)("cx-tooltip",{slot:"header-actions",content:p?"Unfavorite":"Favorite",placement:"bottom",children:I.isLoadingFavorites?(0,Ut.jsx)("cx-space",{"align-items":"center","justify-content":"center",style:{width:"32px",height:"32px"},children:(0,Ut.jsx)("cx-spinner",{})}):(0,Ut.jsx)("cx-icon-button",{name:p?"star":"star_outline",style:{color:p?"var(--cx-color-warning)":"var(--cx-color-text)"},onClick:async()=>{I.isLoadingFavorites||(B({type:"SET_LOADING_FAVORITES",payload:!0}),p?await S():await C(),B({type:"SET_LOADING_FAVORITES",payload:!1}))}})}),b&&(0,Ut.jsx)("cx-tooltip",{slot:"header-actions",content:"Version history",placement:"bottom",children:(0,Ut.jsx)("cx-icon-button",{name:"history",onClick:H})})]}),(()=>{let e=null,t=null;if(e=I.selectedFormat.width&&I.selectedFormat.height&&(null===v||void 0===v?void 0:v.docType)===Jt.zu.Image?(0,Ut.jsx)(Dn,{ref:Q,loadable:I.previewLoadable,image:I.selectedFormat,selectedProxy:I.selectedProxy,proxies:D,resizer:I.resizeSize,cropper:I.cropSize,rotation:I.rotation,isCustomRenditionEnabled:I.showCustomRendition||I.useCustomRendition,disabled:"crop"!==I.activeSetting||!I.showCustomRendition,onCropComplete:e=>{B({type:"SET_CROP_SIZE",payload:{percentageWidth:e.width,percentageHeight:e.height,x:e.x,y:e.y}})},onLoadingChange:N}):(0,Ut.jsx)($n,{loadable:I.previewLoadable,asset:{docType:null===v||void 0===v?void 0:v.docType,imageUrl:null===v||void 0===v?void 0:v.imageUrl,videoUrl:m,extension:null===v||void 0===v?void 0:v.extension},onLoad:e=>{if(null!==v&&void 0!==v&&v.width&&null!==v&&void 0!==v&&v.height||null===v||void 0===v||!v.imageUrl)return;const t=null!==v&&void 0!==v&&v.width?parseInt(v.width,10):e.width,n=null!==v&&void 0!==v&&v.height?parseInt(v.height,10):e.height;B({type:"SET_DEFAULT_SIZE",payload:{width:t,height:n}})}}),I.showVersionHistory)return(0,Ut.jsx)(sr,{assetId:null===v||void 0===v?void 0:v.id});if(!r)return e;var n;I.showCustomRendition&&D?t=(0,Ut.jsx)(Xn,{activeSetting:I.activeSetting,extensions:i,availableProxies:D,imageSize:{width:I.selectedFormat.width?I.selectedFormat.width:1/0,height:I.selectedFormat.height?I.selectedFormat.height:1/0},resize:{width:I.resizeSize.width,height:I.resizeSize.height,unit:I.resizeSize.unit},crop:I.cropSize,keepMetadata:I.keepMetadata,lastAppliedCrop:I.lastCropSize,lastAppliedResize:I.lastResizeSize,proxy:I.selectedProxy,quality:I.quality,rotation:I.rotation,extension:I.selectedFormat.extension,onCropChange:L,onExtensionChange:M,onFormatChange:V,onKeepMetadataChange:q,onQualityChange:W,onResizeChange:j,onRotateChange:F,onViewChange:U}):t=(0,Ut.jsx)("cx-space",{direction:"vertical",spacing:"small",children:f||c?(0,Ut.jsxs)("div",{style:{width:"100%"},children:[f&&(0,Ut.jsx)(tr,{items:null===D||void 0===D?void 0:D.map((e=>{var t;return"TRX"===e.proxyName&&v?{value:e.id,name:e.proxyLabel,cdnName:e.cdnName,width:v.width,height:v.height,extension:v.extension,docType:v.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===v||void 0===v?void 0:v.docType}})),selectedDisabled:I.useCustomRendition,selectedItem:I.selectedProxy,children:R&&(0,Ut.jsxs)("cx-menu-item",{value:"use-representative",children:[(0,Ut.jsx)("cx-typography",{variant:"body3",className:"proxy__name "+(I.useRepresentative?"selected":""),children:"Representative image"}),(0,Ut.jsx)("cx-icon",{slot:"suffix",name:I.useRepresentative?"check":""})]})}),c&&(0,Ut.jsx)(tr,{items:[],selectedItem:I.selectedProxy,style:{borderTopWidth:"0"},children:(0,Ut.jsxs)("cx-menu-item",{value:"custom","data-cy":"custom-rendition-menu-item",children:[(0,Ut.jsx)("cx-icon",{slot:"prefix",name:"crop_rotate",className:"icon--large"}),(0,Ut.jsxs)("div",{children:[(0,Ut.jsx)("cx-typography",{variant:"body3",className:"proxy__name "+(I.useCustomRendition?"selected":""),children:"Custom format"}),g?(0,Ut.jsxs)("cx-typography",{variant:"body3",className:"proxy__details",children:[I.selectedFormat.width," x"," ",I.selectedFormat.height,I.selectedFormat.extension&&(0,Ut.jsx)("div",{className:"proxy__extension-dot"}),null===(n=I.selectedFormat.extension)||void 0===n?void 0:n.replace(/^\./,"").toUpperCase()]}):null]}),(0,Ut.jsx)("cx-icon",{slot:"suffix",name:I.useCustomRendition?"edit":"",className:"icon--large"}),(0,Ut.jsx)("cx-icon",{slot:"suffix",name:I.useCustomRendition?"check":"",className:"icon--large icon--primary"})]})}),o&&(0,Ut.jsxs)("div",{style:{backgroundColor:"var(--cx-color-neutral-0)",width:"100%"},children:[(0,Ut.jsx)(tr,{children:(0,Ut.jsxs)("cx-menu-item",{value:"tracking",className:"proxy--switch",children:[(0,Ut.jsx)("cx-typography",{variant:"body3",className:"proxy__name",children:"Tracking parameters"}),(0,Ut.jsx)("cx-switch",{checked:I.enabledTracking,onClick:e=>e.preventDefault()})]})}),I.enabledTracking&&(0,Ut.jsx)(nr,{values:I.trackingParameters,onChange:e=>B({type:"SET_TRACKING_PARAMETERS",payload:e})})]})]}):(0,Ut.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,Ut.jsx)("cx-icon",{style:{color:"var(--cx-color-warning)"},name:"warning",className:"ic_warning_amber"}),(0,Ut.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,Ut.jsxs)(Ut.Fragment,{children:[e,t]})})(),(()=>{if(I.showVersionHistory)return null;let t=null;return t=r?I.showCustomRendition?(0,Ut.jsxs)("cx-space",{spacing:"small",style:{width:"fit-content"},children:[(0,Ut.jsx)("cx-button",{variant:"default",onClick:()=>{var e,t,n,r,o;I.useCustomRendition?B({type:"CANCEL_USE_CUSTOM_RENDITION",payload:{url:I.defaultSelectedFormat.url,originalUrl:I.defaultSelectedFormat.originalUrl,width:I.defaultSelectedFormat.width,height:I.defaultSelectedFormat.height,extension:I.defaultSelectedFormat.extension,selectedProxy:I.defaultSelectedProxy,useCustomRendition:!0}}):B({type:"CANCEL_USE_CUSTOM_RENDITION",payload:{url:null!==(e=null===v||void 0===v?void 0:v.imageUrl)&&void 0!==e?e:"",originalUrl:null!==(t=null===v||void 0===v?void 0:v.originalUrl)&&void 0!==t?t:"",width:parseInt(null!==(n=null===v||void 0===v?void 0:v.width)&&void 0!==n?n:"0",10),height:parseInt(null!==(r=null===v||void 0===v?void 0:v.height)&&void 0!==r?r:"0",10),extension:null!==(o=null===v||void 0===v?void 0:v.extension)&&void 0!==o?o:"",useCustomRendition:!1,selectedProxy:""}})},children:"Cancel"}),(0,Ut.jsx)("cx-button",{variant:"primary",onClick:()=>{B({type:"CONFIRM_USE_CUSTOM_RENDITION"})},children:"Done"})]}):(0,Ut.jsx)("cx-button",{className:"dialog__footer__button",disabled:e,loading:I.isLoadingConfirm,variant:"primary",style:{flex:1},onClick:async()=>{const e=null===D||void 0===D?void 0:D.find((e=>e.id===I.selectedProxy));if(I.useCustomRendition){var t,n,r,o,i,a,s,l,c,u,d,h,p,f,g;if(null===v||void 0===v||!v.docType)return;B({type:"SET_LOADING_CONFIRM",payload:!0}),await k({value:I.transformations,parameters:I.enabledTracking?I.trackingParameters:void 0,proxiesPreference:null===e||void 0===e?void 0:e.proxyName,extension:I.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)?v.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=v.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=v.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=I.selectedFormat)||void 0===d?void 0:d.extension)&&void 0!==u?u:null,isCustomFormat:!0,height:null!==(h=null===(p=I.selectedFormat)||void 0===p?void 0:p.height)&&void 0!==h?h:null,width:null!==(f=null===(g=I.selectedFormat)||void 0===g?void 0:g.width)&&void 0!==f?f:null,permanentLink:null}}),B({type:"SET_LOADING_CONFIRM",payload:!1})}else{var m,b,y,A,x,C,S,_,T,O,P,Q;if(null===v||void 0===v||!v.docType)return;if(!e&&!I.useRepresentative)return;B({type:"SET_LOADING_CONFIRM",payload:!0}),await E({extension:null!==(m=null===e||void 0===e?void 0:e.extension)&&void 0!==m?m:v.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:I.enabledTracking?I.trackingParameters:void 0,useRepresentative:I.useRepresentative,selectedProxyMetadata:{cdnName:null!==(A=null===e||void 0===e?void 0:e.cdnName)&&void 0!==A?A:null,extension:"TRX"===(null===e||void 0===e?void 0:e.proxyName)?v.extension:null!==(x=null===e||void 0===e?void 0:e.extension)&&void 0!==x?x:null,isCustomFormat:!1,width:"TRX"===(null===e||void 0===e?void 0:e.proxyName)?parseInt(null!==(C=v.width)&&void 0!==C?C:"0",10):null!==(S=null===e||void 0===e?void 0:e.formatWidth)&&void 0!==S?S:null,height:"TRX"===(null===e||void 0===e?void 0:e.proxyName)?parseInt(null!==(_=v.height)&&void 0!==_?_:"0",10):null!==(T=null===e||void 0===e?void 0:e.formatHeight)&&void 0!==T?T:null,permanentLink:null!==(O=null===e||void 0===e?void 0:e.permanentLink)&&void 0!==O?O:null,proxyLabel:null!==(P=null===e||void 0===e?void 0:e.proxyLabel)&&void 0!==P?P:null,proxyName:null!==(Q=null===e||void 0===e?void 0:e.proxyName)&&void 0!==Q?Q:null}}),B({type:"SET_LOADING_CONFIRM",payload:!1})}B({type:"RESET_DATA"}),w()},children:(0,Ut.jsx)("span",{style:{textTransform:d},children:u})}):(0,Ut.jsxs)("cx-button",{className:"dialog__footer__button",loading:I.isLoadingConfirm,onClick:async()=>{null!==v&&void 0!==v&&v.docType&&(B({type:"SET_LOADING_CONFIRM",payload:!0}),await E({extension:v.extension,useRepresentative:!0,value:""}),B({type:"SET_LOADING_CONFIRM",payload:!1}))},variant:"primary",children:[(0,Ut.jsx)("cx-icon",{slot:"prefix",name:"folder"}),(0,Ut.jsx)("span",{style:{textTransform:d},children:u})]}),(0,Ut.jsx)("div",{slot:"footer",className:"dialog__footer",children:t})})()]})}),[t,n,r,o,a,s,l,u,d,h,D,H,p,m,v,b,I,R,w,L,M,C,V,k,q,N,E,W,j,F,S,U]);return"drawer"===A?(0,Ut.jsx)(Yn,{ref:P,className:"dialog",label:"Drawer",placement:"bottom",contained:!0,open:g,children:K()}):(0,Ut.jsx)(Gn,{ref:O,className:"dialog",open:g,"use-overlay-scrollbar":lr||void 0,"overlay-scrollbar-auto-hide":"never",style:{"--max-height":`${f}px`,"--max-width":I.showVersionHistory?"600px":"520px"},children:K()})};var hr=n(5650);const pr=(0,Lt.Ay)("cx-space")`
742
742
  border-bottom: ${e=>{let{bordered:t}=e;return t?"1px solid var(--cx-color-neutral-300)":"none"}};
743
743
  padding: var(--cx-spacing-medium);
744
744