@orangelogic/orange-dam-content-browser-sdk 2.2.0-beta-76 → 2.2.0-beta-77

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.
@@ -111,7 +111,7 @@
111
111
  }
112
112
  `;var Ut=n(4413),Vt=n(579);const qt=e=>{let{loadMore:t,isLoading:n,disabled:r=!1,slot:o,disabledIndentation:i}=e;return(0,Vt.jsxs)("cx-space",{direction:"horizontal",slot:o,children:[!i&&(0,Vt.jsx)("div",{className:"browser__load-more__indentation"}),(0,Vt.jsxs)("cx-button",{variant:"text",size:"small",onClick:t,disabled:r,loading:n,className:"browser__load-more",children:[(0,Vt.jsx)("cx-icon",{name:"add",slot:"prefix"}),"More"]})]})};const Ht=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const r=t.filter(Boolean);if(r.length<=1){return r[0]||null}return function(e){r.forEach((t=>{"function"===typeof t?t(e):t&&(t.current=e)}))}},Wt=(0,Lt.Ay)("cx-line-clamp")`
113
113
  --max-width: min(80vw, 350px);
114
- `,Kt=(0,wt.forwardRef)(((e,t)=>{const{children:n,content:r,...o}=e,i=(0,wt.useRef)(null),[a,s]=(0,wt.useState)(!1);return(0,wt.useEffect)((()=>{customElements.whenDefined("cx-line-clamp").then((()=>{s(!0)}))}),[]),(0,wt.useEffect)((()=>{var e;const t=i.current;if(!t)return;const n=null===(e=i.current)||void 0===e?void 0:e.closest(".cbsdk__home");n&&(t.flipBoundary=n,t.shiftBoundary=n)}),[a]),(0,Vt.jsx)(Wt,{ref:Ht(t,i),content:r,...o,children:n})}));Kt.displayName="LineClamp";const $t=Kt,Qt=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Gt=(e,t)=>{if(!t)return e;const n=t.toLowerCase().split(" ").filter(Boolean),r=n.map(Qt),o=new RegExp(`(${r.join("|")})`,"gi");return e.split(o).map(((e,t)=>n.includes(e.toLowerCase())?(0,Vt.jsx)("strong",{children:e},t):e))},Xt=e=>{var t;let{allowedFolders:n,folder:r,currentFolderID:o,icon:i,searchText:a,useSession:s,damViewSeeThru:l}=e;const[c,u]=(0,wt.useState)(!1),[d,h]=(0,wt.useState)(!1),[p,f]=(0,wt.useState)({start:0,pageSize:Ut.VH}),m=(0,wt.useRef)(null),g=o===r.id,{data:v,isFetching:b,isLoading:y}=(0,Rt.Jz)({allowedFolders:n,folder:r,searchText:"",useSession:s,start:p.start,pageSize:p.pageSize,damViewSeeThru:l},{skip:!d}),x=(0,wt.useMemo)((()=>{var e;return null!==(e=null===v||void 0===v?void 0:v.items)&&void 0!==e?e:void 0}),[v]),w=null!==(t=null===v||void 0===v?void 0:v.totalCount)&&void 0!==t?t:0,S=(0,wt.useCallback)((()=>{const e=(null===x||void 0===x?void 0:x.length)||0;e>=w||f((t=>({...t,start:e})))}),[null===x||void 0===x?void 0:x.length,w]);(0,wt.useEffect)((()=>{Promise.all([customElements.whenDefined("cx-tree-item")]).then((()=>{u(!0)}))}),[c]),(0,wt.useEffect)((()=>{const e=m.current;if(!e)return;const t=()=>{h(!0)},n=e=>{e.detail.target===m.current&&h(!1)};return e.addEventListener("cx-lazy-load",t),e.addEventListener("cx-expand",t),e.addEventListener("cx-collapse",n),()=>{e.removeEventListener("cx-lazy-load",t),e.removeEventListener("cx-expand",t),e.removeEventListener("cx-collapse",n)}}),[c]);const k=(0,wt.useMemo)((()=>{let e,t="outlined";return i?e=i:"Album"===r.docType?e=r.isShared?"share":"folder":(e="folder",t="filled"),{name:e,variant:t}}),[r.docType,r.isShared,i]),_=r.hasChildren&&(void 0===x||b);return(0,Vt.jsxs)(Vt.Fragment,{children:[(0,Vt.jsxs)("cx-tree-item",{ref:m,"data-value":JSON.stringify(r),expanded:d,selected:g,lazy:_,children:[(0,Vt.jsx)("cx-icon",{name:k.name,variant:k.variant}),(0,Vt.jsx)($t,{lines:1,children:Gt(r.title,a)}),null===x||void 0===x?void 0:x.map((e=>(0,Vt.jsx)(Xt,{allowedFolders:n,folder:e,searchText:a,currentFolderID:o,damViewSeeThru:l,useSession:s},e.id)))]}),x&&x.length<w&&!y&&(0,Vt.jsx)(qt,{loadMore:S,isLoading:b,disabled:b})]})},Zt=Xt;var Yt=n(1158);const Jt=e=>{switch(e){case Yt.zu.Audio:return"audio_file";case Yt.zu.Album:return"album";case Yt.zu.Widget:return"widgets";case Yt.zu.Multimedia:return"perm_media";case Yt.zu.Story:return"article";case Yt.zu.Video:return"video_file";case Yt.zu.Image:return"photo";default:return"file"}},en=e=>`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e).replace(/'/g,"%27").replace(/"/g,"%22")}`;var tn=n(7840);const nn={id:"",title:"My Favorites",docType:"Story",path:[],parents:[],fullPath:"My Favorites",hasChildren:!1},rn=e=>{var t,n;let{allowedFolders:r,allowPin:o,collectionPath:i,currentFolder:a,favoriteFolderId:s,focusInput:l,lastLocationMode:c,open:u,showCollections:d,showFavoriteFolder:h,useSession:p,onFolderSelect:f,onClose:m,isPersistent:g,onChangePersistent:v,forceOverlay:b,damViewSeeThru:y}=e;const[x,w]=(0,wt.useState)(""),[S,k]=(0,wt.useState)(!1),[_,C]=(0,wt.useState)(!1),[E,A]=(0,wt.useState)(!1),[T,O]=(0,wt.useState)({start:0,pageSize:Ut.VH}),[P,z]=(0,wt.useState)({start:0,pageSize:Ut.VH}),D=(0,wt.useRef)(null),R=(0,wt.useRef)(null),j=(0,wt.useRef)(null),N=(0,wt.useRef)(null),I=(0,wt.useRef)(!0);(0,wt.useEffect)((()=>{Promise.all([customElements.whenDefined("cx-drawer"),customElements.whenDefined("cx-input"),customElements.whenDefined("cx-tree")]).then((()=>{k(!0)}))}),[]),(0,wt.useEffect)((()=>{const e=j.current;if(!e)return;const t=ke((e=>{const t=e.target.value;x!==t&&(t.length>2||0===t.length)&&(w(t),O((e=>({...e,start:0}))))}),500);return e.addEventListener("cx-input",t),()=>{e.removeEventListener("cx-input",t)}}),[S,x]),(0,wt.useEffect)((()=>{const e=R.current;if(!e)return;const t=()=>{m(),v(!1)};return e.addEventListener("cx-request-close",t),()=>{e.removeEventListener("cx-request-close",t)}}),[S,m,v]);const{data:M,isLoading:F,isFetching:L,isError:B}=(0,Rt.Jz)({allowedFolders:r,folder:Nt,searchText:x,useSession:p,start:T.start,pageSize:T.pageSize,damViewSeeThru:y}),{data:U}=(0,Rt.Jz)({allowedFolders:r,folder:{...nn,id:null!==s&&void 0!==s?s:""},searchText:"",useSession:p,self:!0,includeDirectChild:!1,damViewSeeThru:y},{skip:!s}),V=(0,wt.useMemo)((()=>{var e;return null!==(e=null===M||void 0===M?void 0:M.items)&&void 0!==e?e:void 0}),[M]),q=null!==(t=null===M||void 0===M?void 0:M.totalCount)&&void 0!==t?t:0,H=(0,wt.useCallback)((()=>{if(!V)return;const e=V.length;e>=q||(C(!0),O((t=>({...t,start:e}))))}),[V,q]);(0,wt.useEffect)((()=>{const e=()=>{if(!V)return;if(r&&r.length>0){const e=V.find((e=>r.includes(e.id)));if(e)return void f(e)}const e=V.find((e=>e.title===Dt.mT));f(e||Nt)};I.current&&V&&(I.current=!1,c?(0,Mt.bQ)("lastLocation").then((t=>{if("string"===typeof t)try{const n=JSON.parse(t);if(n.id===s&&!h||r&&r.length>0)return void e();f(n)}catch(n){e()}else e()})).catch((()=>{e()})):e())}),[r,s,V,c,f,h]);const{data:W,isLoading:K,isFetching:$,isError:Q}=(0,Rt.$Y)(i?{folder:i,searchText:x,useSession:p,start:P.start,pageSize:P.pageSize}:Ft.hT),G=(0,wt.useMemo)((()=>{var e;return null!==(e=null===W||void 0===W?void 0:W.items)&&void 0!==e?e:void 0}),[W]),X=null!==(n=null===W||void 0===W?void 0:W.totalCount)&&void 0!==n?n:0,Z=(0,wt.useCallback)((()=>{if(!G)return;A(!0);const e=G.length;e>=X||z((t=>({...t,start:e})))}),[G,X]);(0,wt.useEffect)((()=>{const e=N.current;if(!e)return;const t=e=>{var t;const n=JSON.parse(null!==(t=e.detail.selection[0].dataset.value)&&void 0!==t?t:"{}");null===f||void 0===f||f(n)};return e.addEventListener("cx-selection-change",t),()=>{e.removeEventListener("cx-selection-change",t)}}),[S,f]),(0,wt.useEffect)((()=>{const e=D.current;if(!e)return;const t=e=>{var t;const n=JSON.parse(null!==(t=e.detail.item.value)&&void 0!==t?t:"{}");null===f||void 0===f||f(n)};return e.addEventListener("cx-select",t),()=>{e.removeEventListener("cx-select",t)}}),[S,G,f]),(0,wt.useEffect)((()=>{L||C(!1)}),[L]),(0,wt.useEffect)((()=>{$||A(!1)}),[$]);const Y=(0,wt.useCallback)((()=>{if(F||L&&!_)return Array.from({length:5}).map(((e,t)=>(0,Vt.jsx)("cx-skeleton",{},t)));if(V&&V.length>0){var e;const i=[];var t,n,o;if(s)i.push((0,Vt.jsx)(Zt,{folder:{...nn,id:s,hasChildren:null!==(t=null===U||void 0===U||null===(n=U.items)||void 0===n||null===(o=n[0])||void 0===o?void 0:o.hasChildren)&&void 0!==t&&t},currentFolderID:a.id,icon:"star",useSession:p,damViewSeeThru:y},s));return[...i,...(null!==(e=(0,tn.A)(V,(e=>e.id)))&&void 0!==e?e:[]).map((e=>(0,Vt.jsx)(Zt,{allowedFolders:r,folder:e,currentFolderID:a.id,searchText:x,useSession:p,damViewSeeThru:y},e.id)))]}return B?(0,Vt.jsx)("cx-typography",{variant:"body3",children:"Failed to load folders"}):(0,Vt.jsx)("cx-typography",{variant:"body3",children:"No folders found"})}),[r,a.id,s,V,B,L,F,x,p,_,U,y]),J=(0,wt.useCallback)((()=>K||$&&!E?Array.from({length:5}).map(((e,t)=>(0,Vt.jsx)("cx-skeleton",{},t))):G&&G.length>0?null===G||void 0===G?void 0:G.map((e=>{const t=a.id===e.id;return(0,Vt.jsxs)("cx-menu-item",{value:JSON.stringify(e),className:""+(t?"selected":""),children:[(0,Vt.jsx)("cx-icon",{slot:"prefix",name:"collections"}),(0,Vt.jsx)($t,{lines:1,children:Gt(e.title,x)})]},e.id)})):Q?(0,Vt.jsx)("cx-typography",{variant:"body3",children:"Failed to load collections"}):(0,Vt.jsx)("cx-typography",{variant:"body3",children:"No collections found"})),[K,$,G,Q,a.id,x,E]),ee={persistent:{src:en('<svg\n xmlns="http://www.w3.org/2000/svg"\n height="24px"\n viewBox="0 -960 960 960"\n width="24px"\n fill="#52525B"\n >\n <path d="M660-320v-320L500-480l160 160ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm120-80v-560H200v560h120Zm80 0h360v-560H400v560Zm-80 0H200h120Z" />\n </svg>'),onclick:()=>{m(),v(!1)}},overlay:{src:en('<svg\n xmlns="http://www.w3.org/2000/svg"\n height="24px"\n viewBox="0 -960 960 960"\n width="24px"\n fill="#52525B"\n >\n <path d="M500-640v320l160-160-160-160ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm120-80v-560H200v560h120Zm80 0h360v-560H400v560Zm-80 0H200h120Z" />\n </svg>'),onclick:()=>v(!0)}},te=g?ee.persistent:ee.overlay,ne=b||!g?"overlay":"persistent",re=!b&&g;return(0,Vt.jsxs)(Bt,{ref:R,label:"Browser",placement:"start",contained:!0,open:u,variant:ne,noCloseButton:re,children:[!b&&o?(0,Vt.jsx)("cx-tooltip",{slot:"header-actions",content:g?"Collapse menu":"Expand menu",children:(0,Vt.jsx)("cx-icon-button",{...te})}):null,(0,Vt.jsxs)("cx-space",{direction:"vertical",spacing:"small",wrap:"nowrap",children:[(0,Vt.jsxs)("cx-space",{direction:"vertical",spacing:"small",style:{padding:"var(--body-spacing) var(--body-spacing) 0"},children:[(0,Vt.jsx)("cx-typography",{variant:"body3",children:"Folders"}),(0,Vt.jsx)("cx-input",{ref:j,value:x,placeholder:"Search...",clearable:!0,autoFocus:l,className:"search-input",children:(0,Vt.jsx)("cx-icon",{name:"search",slot:"prefix",className:"icon--large"})}),(0,Vt.jsx)("div",{className:"browser__folders",children:(0,Vt.jsxs)("cx-tree",{ref:N,"force-on-change":!0,children:[Y(),V&&V.length<q&&!F&&(0,Vt.jsx)(qt,{loadMore:H,isLoading:L,disabled:L})]})})]}),d&&(0,Vt.jsx)("div",{className:"browser__collections",children:(0,Vt.jsxs)("cx-details",{children:[(0,Vt.jsx)("cx-typography",{slot:"summary",variant:"body3",children:"Collections"}),(0,Vt.jsxs)("cx-menu",{ref:D,className:"browser__collections__menu",children:[J(),G&&G.length<X&&!K&&(0,Vt.jsx)(qt,{loadMore:Z,isLoading:$,disabled:$,disabledIndentation:!0})]})]})})]})]})},on=[{label:"Ascending",value:"ascending",icon:()=>(0,Vt.jsxs)("svg",{slot:"prefix",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,Vt.jsx)("path",{d:"M3.33333 4.7619L4.25984 5.68841L6.60714 3.33929V11.3095H7.61905V3.33929L9.96627 5.68841L10.8929 4.7619L6.96429 0.833333L3.33333 4.7619Z",fill:"currentColor"}),(0,Vt.jsx)("path",{opacity:"0.3",d:"M17.0833 15.2381L16.1568 14.3116L13.8095 16.6607V8.69048H12.7976V16.6607L10.4504 14.3116L9.52381 15.2381L13.4524 19.1667L17.0833 15.2381Z",fill:"currentColor"})]})},{label:"Descending",value:"descending",icon:()=>(0,Vt.jsxs)("svg",{slot:"prefix",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,Vt.jsx)("path",{opacity:"0.3",d:"M3.33333 4.7619L4.25984 5.68841L6.60714 3.33929V11.3095H7.61905V3.33929L9.96627 5.68841L10.8929 4.7619L6.96429 0.833333L3.33333 4.7619Z",fill:"currentColor"}),(0,Vt.jsx)("path",{d:"M17.0833 15.2381L16.1568 14.3116L13.8095 16.6607V8.69048H12.7976V16.6607L10.4504 14.3116L9.52381 15.2381L13.4524 19.1667L17.0833 15.2381Z",fill:"currentColor"})]})}],an=[{value:Yt.gf.Small,label:"Small labeled"},{value:Yt.gf.Medium,label:"Medium labeled"},{value:Yt.gf.Large,label:"Large labeled"}],sn=Lt.Ay.div`
114
+ `,Kt=(0,wt.forwardRef)(((e,t)=>{const{children:n,content:r,...o}=e,i=(0,wt.useRef)(null),[a,s]=(0,wt.useState)(!1);return(0,wt.useEffect)((()=>{customElements.whenDefined("cx-line-clamp").then((()=>{s(!0)}))}),[]),(0,wt.useEffect)((()=>{var e;const t=i.current;if(!t)return;const n=null===(e=i.current)||void 0===e?void 0:e.closest(".cbsdk__home");n&&(t.flipBoundary=n,t.shiftBoundary=n)}),[a]),(0,Vt.jsx)(Wt,{ref:Ht(t,i),content:r,...o,children:n})}));Kt.displayName="LineClamp";const $t=Kt,Qt=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Gt=(e,t)=>{if(!t)return e;const n=t.toLowerCase().split(" ").filter(Boolean),r=n.map(Qt),o=new RegExp(`(${r.join("|")})`,"gi");return e.split(o).map(((e,t)=>n.includes(e.toLowerCase())?(0,Vt.jsx)("strong",{children:e},t):e))},Xt=e=>{var t;let{allowedFolders:n,folder:r,currentFolderID:o,icon:i,searchText:a,useSession:s,damViewSeeThru:l}=e;const[c,u]=(0,wt.useState)(!1),[d,h]=(0,wt.useState)(!1),[p,f]=(0,wt.useState)({start:0,pageSize:Ut.VH}),m=(0,wt.useRef)(null),g=o===r.id,{data:v,isFetching:b,isLoading:y}=(0,Rt.Jz)({allowedFolders:n,folder:r,searchText:"",useSession:s,start:p.start,pageSize:p.pageSize,damViewSeeThru:l},{skip:!d}),x=(0,wt.useMemo)((()=>{var e;return null!==(e=null===v||void 0===v?void 0:v.items)&&void 0!==e?e:void 0}),[v]),w=null!==(t=null===v||void 0===v?void 0:v.totalCount)&&void 0!==t?t:0,S=(0,wt.useCallback)((()=>{const e=(null===x||void 0===x?void 0:x.length)||0;e>=w||f((t=>({...t,start:e})))}),[null===x||void 0===x?void 0:x.length,w]);(0,wt.useEffect)((()=>{Promise.all([customElements.whenDefined("cx-tree-item")]).then((()=>{u(!0)}))}),[c]),(0,wt.useEffect)((()=>{const e=m.current;if(!e)return;const t=()=>{h(!0)},n=e=>{e.detail.target===m.current&&h(!1)};return e.addEventListener("cx-lazy-load",t),e.addEventListener("cx-expand",t),e.addEventListener("cx-collapse",n),()=>{e.removeEventListener("cx-lazy-load",t),e.removeEventListener("cx-expand",t),e.removeEventListener("cx-collapse",n)}}),[c]);const k=(0,wt.useMemo)((()=>{let e,t="outlined";return i?e=i:"Album"===r.docType?e=r.isShared?"share":"folder":(e="folder",t="filled"),{name:e,variant:t}}),[r.docType,r.isShared,i]),_=r.hasChildren&&(void 0===x||b);return(0,Vt.jsxs)(Vt.Fragment,{children:[(0,Vt.jsxs)("cx-tree-item",{ref:m,"data-value":JSON.stringify(r),expanded:d,selected:g,lazy:_,children:[(0,Vt.jsx)("cx-icon",{name:k.name,variant:k.variant}),(0,Vt.jsx)($t,{lines:1,children:Gt(r.title,a)}),null===x||void 0===x?void 0:x.map((e=>(0,Vt.jsx)(Xt,{allowedFolders:n,folder:e,searchText:a,currentFolderID:o,damViewSeeThru:l,useSession:s},e.id)))]}),x&&x.length<w&&!y&&(0,Vt.jsx)(qt,{loadMore:S,isLoading:b,disabled:b})]})},Zt=Xt;var Yt=n(1158);const Jt=e=>{switch(e){case Yt.zu.Audio:return"audio_file";case Yt.zu.Album:return"album";case Yt.zu.Widget:return"widgets";case Yt.zu.Multimedia:return"perm_media";case Yt.zu.Story:return"article";case Yt.zu.Video:return"video_file";case Yt.zu.Image:return"photo";default:return"file"}},en=e=>`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e).replace(/'/g,"%27").replace(/"/g,"%22")}`;var tn=n(7840);const nn={id:"",title:"My Favorites",docType:"Story",path:[],parents:[],fullPath:"My Favorites",hasChildren:!1},rn=e=>{var t,n;let{allowedFolders:r,allowPin:o,collectionPath:i,currentFolder:a,favoriteFolderId:s,focusInput:l,lastLocationMode:c,open:u,showCollections:d,showFavoriteFolder:h,useSession:p,onFolderSelect:f,onClose:m,isPersistent:g,onChangePersistent:v,forceOverlay:b,damViewSeeThru:y}=e;const[x,w]=(0,wt.useState)(""),[S,k]=(0,wt.useState)(!1),[_,C]=(0,wt.useState)(!1),[E,A]=(0,wt.useState)(!1),[T,O]=(0,wt.useState)({start:0,pageSize:Ut.VH}),[P,z]=(0,wt.useState)({start:0,pageSize:Ut.VH}),D=(0,wt.useRef)(null),R=(0,wt.useRef)(null),j=(0,wt.useRef)(null),N=(0,wt.useRef)(null),I=(0,wt.useRef)(!0);(0,wt.useEffect)((()=>{Promise.all([customElements.whenDefined("cx-drawer"),customElements.whenDefined("cx-input"),customElements.whenDefined("cx-tree")]).then((()=>{k(!0)}))}),[]),(0,wt.useEffect)((()=>{const e=j.current;if(!e)return;const t=ke((e=>{const t=e.target.value;x!==t&&(t.length>2||0===t.length)&&(w(t),O((e=>({...e,start:0}))),z((e=>({...e,start:0}))))}),500);return e.addEventListener("cx-input",t),()=>{e.removeEventListener("cx-input",t)}}),[S,x]),(0,wt.useEffect)((()=>{const e=R.current;if(!e)return;const t=()=>{m(),v(!1)};return e.addEventListener("cx-request-close",t),()=>{e.removeEventListener("cx-request-close",t)}}),[S,m,v]);const{data:M,isLoading:F,isFetching:L,isError:B}=(0,Rt.Jz)({allowedFolders:r,folder:Nt,searchText:x,useSession:p,start:T.start,pageSize:T.pageSize,damViewSeeThru:y}),{data:U}=(0,Rt.Jz)({allowedFolders:r,folder:{...nn,id:null!==s&&void 0!==s?s:""},searchText:"",useSession:p,self:!0,includeDirectChild:!1,damViewSeeThru:y},{skip:!s}),V=(0,wt.useMemo)((()=>{var e;return null!==(e=null===M||void 0===M?void 0:M.items)&&void 0!==e?e:void 0}),[M]),q=null!==(t=null===M||void 0===M?void 0:M.totalCount)&&void 0!==t?t:0,H=(0,wt.useCallback)((()=>{if(!V)return;const e=V.length;e>=q||(C(!0),O((t=>({...t,start:e}))))}),[V,q]);(0,wt.useEffect)((()=>{const e=()=>{if(!V)return;if(r&&r.length>0){const e=V.find((e=>r.includes(e.id)));if(e)return void f(e)}const e=V.find((e=>e.title===Dt.mT));f(e||Nt)};I.current&&V&&(I.current=!1,c?(0,Mt.bQ)("lastLocation").then((t=>{if("string"===typeof t)try{const n=JSON.parse(t);if(n.id===s&&!h||r&&r.length>0)return void e();f(n)}catch(n){e()}else e()})).catch((()=>{e()})):e())}),[r,s,V,c,f,h]);const{data:W,isLoading:K,isFetching:$,isError:Q}=(0,Rt.$Y)(i?{folder:i,searchText:x,useSession:p,start:P.start,pageSize:P.pageSize}:Ft.hT),G=(0,wt.useMemo)((()=>{var e;return null!==(e=null===W||void 0===W?void 0:W.items)&&void 0!==e?e:void 0}),[W]),X=null!==(n=null===W||void 0===W?void 0:W.totalCount)&&void 0!==n?n:0,Z=(0,wt.useCallback)((()=>{if(!G)return;A(!0);const e=G.length;e>=X||z((t=>({...t,start:e})))}),[G,X]);(0,wt.useEffect)((()=>{const e=N.current;if(!e)return;const t=e=>{var t;const n=JSON.parse(null!==(t=e.detail.selection[0].dataset.value)&&void 0!==t?t:"{}");null===f||void 0===f||f(n)};return e.addEventListener("cx-selection-change",t),()=>{e.removeEventListener("cx-selection-change",t)}}),[S,f]),(0,wt.useEffect)((()=>{const e=D.current;if(!e)return;const t=e=>{var t;const n=JSON.parse(null!==(t=e.detail.item.value)&&void 0!==t?t:"{}");null===f||void 0===f||f(n)};return e.addEventListener("cx-select",t),()=>{e.removeEventListener("cx-select",t)}}),[S,G,f]),(0,wt.useEffect)((()=>{L||C(!1)}),[L]),(0,wt.useEffect)((()=>{$||A(!1)}),[$]);const Y=(0,wt.useCallback)((()=>{if(F||L&&!_)return Array.from({length:5}).map(((e,t)=>(0,Vt.jsx)("cx-skeleton",{},t)));if(V&&V.length>0){var e;const i=[];var t,n,o;if(s)i.push((0,Vt.jsx)(Zt,{folder:{...nn,id:s,hasChildren:null!==(t=null===U||void 0===U||null===(n=U.items)||void 0===n||null===(o=n[0])||void 0===o?void 0:o.hasChildren)&&void 0!==t&&t},currentFolderID:a.id,icon:"star",useSession:p,damViewSeeThru:y},s));return[...i,...(null!==(e=(0,tn.A)(V,(e=>e.id)))&&void 0!==e?e:[]).map((e=>(0,Vt.jsx)(Zt,{allowedFolders:r,folder:e,currentFolderID:a.id,searchText:x,useSession:p,damViewSeeThru:y},e.id)))]}return B?(0,Vt.jsx)("cx-typography",{variant:"body3",children:"Failed to load folders"}):(0,Vt.jsx)("cx-typography",{variant:"body3",children:"No folders found"})}),[r,a.id,s,V,B,L,F,x,p,_,U,y]),J=(0,wt.useCallback)((()=>K||$&&!E?Array.from({length:5}).map(((e,t)=>(0,Vt.jsx)("cx-skeleton",{},t))):G&&G.length>0?null===G||void 0===G?void 0:G.map((e=>{const t=a.id===e.id;return(0,Vt.jsxs)("cx-menu-item",{value:JSON.stringify(e),className:""+(t?"selected":""),children:[(0,Vt.jsx)("cx-icon",{slot:"prefix",name:"collections"}),(0,Vt.jsx)($t,{lines:1,children:Gt(e.title,x)})]},e.id)})):Q?(0,Vt.jsx)("cx-typography",{variant:"body3",children:"Failed to load collections"}):(0,Vt.jsx)("cx-typography",{variant:"body3",children:"No collections found"})),[K,$,G,Q,a.id,x,E]),ee={persistent:{src:en('<svg\n xmlns="http://www.w3.org/2000/svg"\n height="24px"\n viewBox="0 -960 960 960"\n width="24px"\n fill="#52525B"\n >\n <path d="M660-320v-320L500-480l160 160ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm120-80v-560H200v560h120Zm80 0h360v-560H400v560Zm-80 0H200h120Z" />\n </svg>'),onclick:()=>{m(),v(!1)}},overlay:{src:en('<svg\n xmlns="http://www.w3.org/2000/svg"\n height="24px"\n viewBox="0 -960 960 960"\n width="24px"\n fill="#52525B"\n >\n <path d="M500-640v320l160-160-160-160ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm120-80v-560H200v560h120Zm80 0h360v-560H400v560Zm-80 0H200h120Z" />\n </svg>'),onclick:()=>v(!0)}},te=g?ee.persistent:ee.overlay,ne=b||!g?"overlay":"persistent",re=!b&&g;return(0,Vt.jsxs)(Bt,{ref:R,label:"Browser",placement:"start",contained:!0,open:u,variant:ne,noCloseButton:re,children:[!b&&o?(0,Vt.jsx)("cx-tooltip",{slot:"header-actions",content:g?"Collapse menu":"Expand menu",children:(0,Vt.jsx)("cx-icon-button",{...te})}):null,(0,Vt.jsxs)("cx-space",{direction:"vertical",spacing:"small",wrap:"nowrap",children:[(0,Vt.jsxs)("cx-space",{direction:"vertical",spacing:"small",style:{padding:"var(--body-spacing) var(--body-spacing) 0"},children:[(0,Vt.jsx)("cx-typography",{variant:"body3",children:"Folders"}),(0,Vt.jsx)("cx-input",{ref:j,value:x,placeholder:"Search...",clearable:!0,autoFocus:l,className:"search-input",children:(0,Vt.jsx)("cx-icon",{name:"search",slot:"prefix",className:"icon--large"})}),(0,Vt.jsx)("div",{className:"browser__folders",children:(0,Vt.jsxs)("cx-tree",{ref:N,"force-on-change":!0,children:[Y(),V&&V.length<q&&!F&&(0,Vt.jsx)(qt,{loadMore:H,isLoading:L,disabled:L})]})})]}),d&&(0,Vt.jsx)("div",{className:"browser__collections",children:(0,Vt.jsxs)("cx-details",{children:[(0,Vt.jsx)("cx-typography",{slot:"summary",variant:"body3",children:"Collections"}),(0,Vt.jsxs)("cx-menu",{ref:D,className:"browser__collections__menu",children:[J(),G&&G.length<X&&!K&&(0,Vt.jsx)(qt,{loadMore:Z,isLoading:$,disabled:$,disabledIndentation:!0})]})]})})]})]})},on=[{label:"Ascending",value:"ascending",icon:()=>(0,Vt.jsxs)("svg",{slot:"prefix",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,Vt.jsx)("path",{d:"M3.33333 4.7619L4.25984 5.68841L6.60714 3.33929V11.3095H7.61905V3.33929L9.96627 5.68841L10.8929 4.7619L6.96429 0.833333L3.33333 4.7619Z",fill:"currentColor"}),(0,Vt.jsx)("path",{opacity:"0.3",d:"M17.0833 15.2381L16.1568 14.3116L13.8095 16.6607V8.69048H12.7976V16.6607L10.4504 14.3116L9.52381 15.2381L13.4524 19.1667L17.0833 15.2381Z",fill:"currentColor"})]})},{label:"Descending",value:"descending",icon:()=>(0,Vt.jsxs)("svg",{slot:"prefix",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,Vt.jsx)("path",{opacity:"0.3",d:"M3.33333 4.7619L4.25984 5.68841L6.60714 3.33929V11.3095H7.61905V3.33929L9.96627 5.68841L10.8929 4.7619L6.96429 0.833333L3.33333 4.7619Z",fill:"currentColor"}),(0,Vt.jsx)("path",{d:"M17.0833 15.2381L16.1568 14.3116L13.8095 16.6607V8.69048H12.7976V16.6607L10.4504 14.3116L9.52381 15.2381L13.4524 19.1667L17.0833 15.2381Z",fill:"currentColor"})]})}],an=[{value:Yt.gf.Small,label:"Small labeled"},{value:Yt.gf.Medium,label:"Medium labeled"},{value:Yt.gf.Large,label:"Large labeled"}],sn=Lt.Ay.div`
115
115
  display: flex;
116
116
  justify-content: space-between;
117
117
  flex-wrap: wrap;
@@ -227,7 +227,7 @@
227
227
  left: 50%;
228
228
  transform: translate(-50%, -50%);
229
229
  }
230
- `,Dn=(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}=Pn(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===dn.Nf.AspectRatio){const{width:n,height:r}=Pn(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}=pn(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)(zn,{ref:x,style:{height:`${Ut.uS}px`},children:[o&&(0,Vt.jsx)(On,{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===dn.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 Rn=n(7032);const jn=function(e,t,n){var r=(n="function"==typeof n?n:void 0)?n(e,t):void 0;return void 0===r?(0,Rn.A)(e,t,void 0,n):!!r},Nn=Lt.Ay.div`
230
+ `,Dn=(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}=i,{width:t,height:n}=a,r=ke((async()=>{if(o){var r,a;d(!0);const{width:o,height:s}=Pn(i.width,i.height,t,n),{url:l}=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,s,null!==(r=null===(a=x.current)||void 0===a?void 0:a.clientWidth)&&void 0!==r?r:window.innerWidth,Ut.uS);y(l),d(!1)}else y(e)}),300,{leading:!0});r()}),[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===dn.Nf.AspectRatio){const{width:n,height:r}=Pn(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}=pn(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)(zn,{ref:x,style:{height:`${Ut.uS}px`},children:[o&&(0,Vt.jsx)(On,{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===dn.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 Rn=n(7032);const jn=function(e,t,n){var r=(n="function"==typeof n?n:void 0)?n(e,t):void 0;return void 0===r?(0,Rn.A)(e,t,void 0,n):!!r},Nn=Lt.Ay.div`
231
231
  container-type: inline-size;
232
232
  container-name: custom-rendition;
233
233