@scaleflex/asset-picker 1.0.1 → 1.0.3

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.
@@ -1,4 +1,4 @@
1
- "use strict";var ki=Object.create;var Bs=Object.defineProperty;var Si=Object.getOwnPropertyDescriptor;var Ci=Object.getOwnPropertyNames;var Fi=Object.getPrototypeOf,Ei=Object.prototype.hasOwnProperty;var Ai=(t,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Ci(e))!Ei.call(t,a)&&a!==s&&Bs(t,a,{get:()=>e[a],enumerable:!(i=Si(e,a))||i.enumerable});return t};var Ti=(t,e,s)=>(s=t!=null?ki(Fi(t)):{},Ai(e||!t||!t.__esModule?Bs(s,"default",{value:t,enumerable:!0}):s,t));const r=require("lit"),l=require("lit/decorators.js");class Li{constructor(e){this.listeners=new Set,this._notifying=!1,this._pendingState=null,this.state=e}getState(){return this.state}setState(e){if(this._notifying){this._pendingState={...this._pendingState||{},...e};return}const s=this.state;this.state={...s,...e},this._notifying=!0;try{this.listeners.forEach(i=>i(this.state,s))}finally{this._notifying=!1}if(this._pendingState){const i=this._pendingState;this._pendingState=null,this.setState(i)}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}destroy(){this.listeners.clear()}}function Oi(){return new Li({config:null,projectToken:"",sassKey:"",brandColor:"",isOpen:!1,activeTab:"assets",viewMode:"grid",searchQuery:"",isAISearchActive:!1,sortBy:"modified_at",sortDirection:"desc",previewAsset:null,isPreviewOpen:!1,assets:[],folders:[],folderPreviews:{},labels:[],tags:[],currentFolder:null,currentFolderPath:"/",breadcrumb:[],activeLabelUuid:null,collections:[],activeCollectionUuid:null,activeCollectionFolders:[],activeCollectionFolder:null,isLoadingCollectionFolders:!1,offset:0,limit:100,totalCount:0,totalFolderCount:0,isLoading:!1,isSelectingAll:!1,hasMore:!1,filters:{metadata:{pinned:[],visible:[],applied:{}},pinned:[],visible:[],applied:{}},fileTypes:[],metadataFields:[],regionalVariantGroups:[],regionalFilters:{},selectedAssets:new Map,selectedFolders:new Map,isResolvingFolders:!1})}class Mi{constructor(e,s){this.host=e,this.store=s,e.addController(this)}get state(){return this.store.getState()}setState(e){this.store.setState(e)}hostConnected(){this.unsubscribe=this.store.subscribe(()=>{this.host.requestUpdate()})}hostDisconnected(){var e;(e=this.unsubscribe)==null||e.call(this)}}function Ii(t){return"extension"in t&&!("path"in t)}class Pi{constructor(e,s){this.lastClickedIndex=-1,this.host=e,this.store=s,e.addController(this)}hostConnected(){}hostDisconnected(){}get _folderSelectionEnabled(){var e;return((e=this.store.getState().config)==null?void 0:e.folderSelection)===!0}_getCombinedList(){const e=this.store.getState();return this._folderSelectionEnabled?[...e.folders,...e.assets]:e.assets}_applyRangeSelection(e,s,i,a){const o=this._getCombinedList();for(let n=e;n<=s;n++){const c=o[n];c&&(Ii(c)?i.set(c.uuid,c):a.set(c.uuid,c))}}handleSelect(e,s,i){var c,d,h,u;const a=this.store.getState(),o=new Map(a.selectedAssets);if(!(((c=a.config)==null?void 0:c.multiSelect)??!0)){o.clear(),o.set(e.uuid,e),this.store.setState({selectedAssets:o,selectedFolders:new Map}),this.lastClickedIndex=s;return}if(i.shiftKey&&this.lastClickedIndex>=0)if(this._folderSelectionEnabled){const f=Math.min(this.lastClickedIndex,s),p=Math.max(this.lastClickedIndex,s),g=new Map(a.selectedFolders);this._applyRangeSelection(f,p,o,g);const m=(d=a.config)==null?void 0:d.maxSelections;if(m&&o.size+g.size>m)return;this.store.setState({selectedAssets:o,selectedFolders:g})}else{const f=Math.min(this.lastClickedIndex,s),p=Math.max(this.lastClickedIndex,s),g=a.assets;for(let _=f;_<=p;_++)g[_]&&o.set(g[_].uuid,g[_]);const m=(h=a.config)==null?void 0:h.maxSelections;if(m&&o.size>m)return;this.store.setState({selectedAssets:o})}else if(i.metaKey||i.ctrlKey){o.has(e.uuid)?o.delete(e.uuid):o.set(e.uuid,e);const f=(u=a.config)==null?void 0:u.maxSelections,p=o.size+(this._folderSelectionEnabled?a.selectedFolders.size:0);if(f&&p>f)return;this.store.setState({selectedAssets:o})}else o.clear(),o.set(e.uuid,e),this.store.setState({selectedAssets:o,selectedFolders:new Map});this.lastClickedIndex=s}handleFolderSelect(e,s,i){var c,d,h;if(!this._folderSelectionEnabled)return;const a=this.store.getState(),o=new Map(a.selectedFolders);if(!(((c=a.config)==null?void 0:c.multiSelect)??!0)){o.clear(),o.set(e.uuid,e),this.store.setState({selectedFolders:o,selectedAssets:new Map}),this.lastClickedIndex=s;return}if(i.shiftKey&&this.lastClickedIndex>=0){const u=Math.min(this.lastClickedIndex,s),f=Math.max(this.lastClickedIndex,s),p=new Map(a.selectedAssets);this._applyRangeSelection(u,f,p,o);const g=(d=a.config)==null?void 0:d.maxSelections;if(g&&p.size+o.size>g)return;this.store.setState({selectedAssets:p,selectedFolders:o})}else if(i.metaKey||i.ctrlKey){o.has(e.uuid)?o.delete(e.uuid):o.set(e.uuid,e);const u=(h=a.config)==null?void 0:h.maxSelections,f=o.size+a.selectedAssets.size;if(u&&f>u)return;this.store.setState({selectedFolders:o})}else o.clear(),o.set(e.uuid,e),this.store.setState({selectedFolders:o,selectedAssets:new Map});this.lastClickedIndex=s}isSelected(e){return this.store.getState().selectedAssets.has(e)}isFolderSelected(e){return this.store.getState().selectedFolders.has(e)}resetRange(){this.lastClickedIndex=-1}selectAll(e){var c;const s=this.store.getState(),i=(c=s.config)==null?void 0:c.maxSelections,a=this._folderSelectionEnabled?s.selectedFolders.size:0,o=new Map,n=i?Math.max(0,Math.min(e.length,i-a)):e.length;for(let d=0;d<n;d++)o.set(e[d].uuid,e[d]);return this.store.setState({selectedAssets:o}),this.lastClickedIndex=-1,o.size}selectAllFolders(e){var n;if(!this._folderSelectionEnabled)return;const s=this.store.getState(),i=(n=s.config)==null?void 0:n.maxSelections,a=new Map,o=i?Math.max(0,Math.min(e.length,i-s.selectedAssets.size)):e.length;for(let c=0;c<o;c++)a.set(e[c].uuid,e[c]);this.store.setState({selectedFolders:a})}clearSelection(){this.store.setState({selectedAssets:new Map,selectedFolders:new Map}),this.lastClickedIndex=-1}getSelectedAssets(){return Array.from(this.store.getState().selectedAssets.values())}getSelectedFolders(){return Array.from(this.store.getState().selectedFolders.values())}}class Di{constructor(e,s){this.host=e,this.onLoadMore=s,e.addController(this)}hostConnected(){}hostDisconnected(){this.disconnect()}observe(e,s){this.disconnect(),this.sentinel=e,this.observer=new IntersectionObserver(i=>{var a;(a=i[0])!=null&&a.isIntersecting&&this.onLoadMore()},{root:s??null,rootMargin:"200px"}),this.observer.observe(e)}disconnect(){this.observer&&this.sentinel&&(this.observer.unobserve(this.sentinel),this.observer.disconnect()),this.observer=void 0,this.sentinel=void 0}}const qs=5,Je=40,Vs=15;class zi{constructor(e,s){this.startX=0,this.startY=0,this.startClientX=0,this.startClientY=0,this.preMarqueeSelection=new Map,this.preMarqueeFolderSelection=new Map,this._dragging=!1,this._scrollRAF=null,this._lastMouseEvent=null,this.isActive=!1,this.rect={x:0,y:0,width:0,height:0},this.handleMouseDown=i=>this.onMouseDown(i),this.handleMouseMove=i=>this.onMouseMove(i),this.handleMouseUp=()=>this.onMouseUp(),this.preventSelect=i=>i.preventDefault(),this.host=e,this.store=s,e.addController(this)}hostConnected(){}hostDisconnected(){this.detach()}attach(e){this.detach(),this.container=e,e.addEventListener("mousedown",this.handleMouseDown)}detach(){this.container&&this.container.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("selectstart",this.preventSelect),this.stopAutoScroll(),this._lastMouseEvent=null}isInteractiveTarget(e){return e.composedPath().some(i=>{if(!(i instanceof HTMLElement))return!1;if(i instanceof HTMLButtonElement||i instanceof HTMLInputElement)return!0;const a=i.tagName.toLowerCase();return!!(a.startsWith("ap-asset-")||a.startsWith("ap-folder-")||i.classList.contains("check")||i.classList.contains("check-box"))})}onMouseDown(e){var a;if(e.button!==0||this.isInteractiveTarget(e)||!(((a=this.store.getState().config)==null?void 0:a.multiSelect)??!0))return;const i=this.container.getBoundingClientRect();this.startX=e.clientX-i.left+this.container.scrollLeft,this.startY=e.clientY-i.top+this.container.scrollTop,this.startClientX=e.clientX,this.startClientY=e.clientY,this._dragging=!1,this.isActive=!1,document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}onMouseMove(e){var s;if(this.container){if(!this._dragging){const i=Math.abs(e.clientX-this.startClientX),a=Math.abs(e.clientY-this.startClientY);if(i<qs&&a<qs)return;this._dragging=!0,this.isActive=!0,document.addEventListener("selectstart",this.preventSelect),(s=window.getSelection())==null||s.removeAllRanges(),this.preMarqueeSelection=new Map(this.store.getState().selectedAssets),this.preMarqueeFolderSelection=new Map(this.store.getState().selectedFolders)}this._lastMouseEvent=e,this.updateMarqueeRect(e),this.startAutoScroll(e)}}updateMarqueeRect(e){if(!this.container)return;const s=this.container.getBoundingClientRect(),i=e.clientX-s.left+this.container.scrollLeft,a=e.clientY-s.top+this.container.scrollTop;let o=Math.min(this.startX,i),n=Math.min(this.startY,a),c=Math.abs(i-this.startX),d=Math.abs(a-this.startY);const h=this.container.scrollWidth,u=this.container.scrollHeight;o+c>h&&(c=h-o),n+d>u&&(d=u-n),o<0&&(c+=o,o=0),n<0&&(d+=n,n=0),this.rect={x:o,y:n,width:c,height:d},this.host.requestUpdate(),this.selectIntersecting()}startAutoScroll(e){if(!this.container)return;if(this.container.scrollHeight<=this.container.clientHeight){this.stopAutoScroll();return}const s=this.container.getBoundingClientRect(),i=e.clientY-s.top,a=s.bottom-e.clientY,o=i<Je||a<Je;o&&!this._scrollRAF?this._scrollRAF=requestAnimationFrame(()=>this.autoScrollTick()):o||this.stopAutoScroll()}autoScrollTick(){if(this._scrollRAF=null,!this.container||!this._dragging||!this._lastMouseEvent||this.container.scrollHeight<=this.container.clientHeight)return;const e=this.container.getBoundingClientRect(),s=this._lastMouseEvent,i=s.clientY-e.top,a=e.bottom-s.clientY;let o=0;i<Je?o=-Vs*(1-i/Je):a<Je&&(o=Vs*(1-a/Je)),o!==0&&(this.container.scrollTop+=o,this.updateMarqueeRect(s),this._scrollRAF=requestAnimationFrame(()=>this.autoScrollTick()))}stopAutoScroll(){this._scrollRAF&&(cancelAnimationFrame(this._scrollRAF),this._scrollRAF=null)}onMouseUp(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("selectstart",this.preventSelect),this.stopAutoScroll(),this._lastMouseEvent=null,this._dragging&&(this.isActive=!1,this._dragging=!1,this.rect={x:0,y:0,width:0,height:0},this.host.requestUpdate())}querySelectableElements(){const e=[],s=[];for(const i of Array.from(this.container.children))if(i.shadowRoot){const a=i.shadowRoot.querySelectorAll("[data-asset-uuid]");a.length>0&&e.push(...Array.from(a));const o=i.shadowRoot.querySelectorAll("[data-folder-uuid]");o.length>0&&s.push(...Array.from(o))}return e.length===0&&e.push(...Array.from(this.container.querySelectorAll("[data-asset-uuid]"))),s.length===0&&s.push(...Array.from(this.container.querySelectorAll("[data-folder-uuid]"))),{assetCards:e,folderCards:s}}getCardRelativeRect(e){const s=e.getBoundingClientRect(),i=this.container.getBoundingClientRect();return{x:s.left-i.left+this.container.scrollLeft,y:s.top-i.top+this.container.scrollTop,width:s.width,height:s.height}}intersectsMarquee(e){return this.rect.x<e.x+e.width&&this.rect.x+this.rect.width>e.x&&this.rect.y<e.y+e.height&&this.rect.y+this.rect.height>e.y}selectIntersecting(){var h,u;if(!this.container)return;const e=this.store.getState(),s=((h=e.config)==null?void 0:h.folderSelection)===!0,{assetCards:i,folderCards:a}=this.querySelectableElements(),o=new Map(this.preMarqueeSelection),n=s?new Map(this.preMarqueeFolderSelection):e.selectedFolders;i.forEach(f=>{const p=this.getCardRelativeRect(f),g=f.dataset.assetUuid;if(this.intersectsMarquee(p)){const m=e.assets.find(_=>_.uuid===g);m&&o.set(g,m)}}),s&&a.forEach(f=>{const p=this.getCardRelativeRect(f),g=f.dataset.folderUuid;if(this.intersectsMarquee(p)){const m=e.folders.find(_=>_.uuid===g);m&&n.set(g,m)}});const c=(u=e.config)==null?void 0:u.maxSelections,d=o.size+(s?n.size:0);if(c&&d>c){const f=Array.from(o.entries()).slice(0,Math.max(0,c-n.size));this.store.setState({selectedAssets:new Map(f),...s?{selectedFolders:n}:{}})}else this.store.setState({selectedAssets:o,...s?{selectedFolders:n}:{}})}}class Ri{constructor(e,s){this.auth=e;const i=e.projectToken;this.baseUrl=s||`https://api.filerobot.com/${i}/v5`,e.mode==="sassKey"&&(this.sassKey=e.sassKey)}setSassKey(e){this.sassKey=e}getSecurityTemplateKey(){if(this.auth.mode==="securityTemplate")return this.auth.securityTemplateKey}_applyAuthHeaders(e){this.sassKey?e["X-Filerobot-Key"]=this.sassKey:this.auth.mode==="securityTemplate"&&(e["X-Filerobot-Key"]=this.auth.securityTemplateKey)}async request(e,s){const i=new URL(`${this.baseUrl}${e}`);s&&Object.entries(s).forEach(([c,d])=>{d!=null&&(Array.isArray(d)?i.searchParams.set(c,d.join(",")):i.searchParams.set(c,String(d)))});const a={};this._applyAuthHeaders(a);const o=new AbortController,n=setTimeout(()=>o.abort(),3e4);try{const c=await fetch(i.toString(),{headers:a,signal:o.signal});if(clearTimeout(n),!c.ok){let h=`API error: ${c.status} ${c.statusText}`;try{const u=await c.json();u.msg&&(h=`API error: ${c.status} - ${u.msg}`)}catch{}throw new Error(h)}const d=await c.json();if(d.status==="error")throw new Error(`API error: ${d.msg||"Unknown error"}`);return d}catch(c){throw clearTimeout(n),c instanceof DOMException&&c.name==="AbortError"?new Error("API request timed out"):c}}async post(e,s){const i=new URL(`${this.baseUrl}${e}`),a={"Content-Type":"application/json"};this._applyAuthHeaders(a);const o=new AbortController,n=setTimeout(()=>o.abort(),3e4);try{const c=await fetch(i.toString(),{method:"POST",headers:a,body:JSON.stringify(s),signal:o.signal});if(clearTimeout(n),!c.ok){let h=`API error: ${c.status} ${c.statusText}`;try{const u=await c.json();u.msg&&(h=`API error: ${c.status} - ${u.msg}`)}catch{}throw new Error(h)}const d=await c.json();if(d.status==="error")throw new Error(`API error: ${d.msg||"Unknown error"}`);return d}catch(c){throw clearTimeout(n),c instanceof DOMException&&c.name==="AbortError"?new Error("API request timed out"):c}}}function ji(t){const e={offset:t.offset??0,limit:t.limit??100,format:"json,regvar:api,select:internal",preview:2301,recursive:t.recursive??1},s=t.sort_by??"created_at",i=t.sort_direction??"desc",a={created_at:"created_at",modified_at:"modified_at",name:"name",size:"size",type:"type"};e.sort=`${a[s]||s}:${i}`,t.folder&&(e.folder=t.folder);const o=[];return t.search&&!t.with_ai&&o.push(t.search),t.q&&o.push(t.q),o.length>0&&(e.q=o.join(" ")),t.with_ai&&(e.with_ai=!0,t.ai_query&&(e.ai_query=t.ai_query),t.ai_lang&&(e.ai_lang=t.ai_lang)),t.collection_uuid&&(e.collection_uuid=t.collection_uuid),t.f64&&(e.f64=t.f64),e}async function De(t,e){const s=ji(e);return t.request("/files",s)}async function At(t,e){const s={recursive:e.recursive??1};e.folder&&(s.folder=e.folder);const i=[];return e.search&&!e.with_ai&&i.push(e.search),e.q&&i.push(e.q),i.length>0&&(s.q=i.join(" ")),e.with_ai&&(s.with_ai=!0,e.ai_query&&(s.ai_query=e.ai_query),e.ai_lang&&(s.ai_lang=e.ai_lang)),e.collection_uuid&&(s.collection_uuid=e.collection_uuid),e.f64&&(s.f64=e.f64),t.request("/files/stats",s)}async function Ni(t,e){const s={recursive:(e==null?void 0:e.recursive)??0,folder:(e==null?void 0:e.folderPath)??"/",limit:(e==null?void 0:e.limit)??1e3,offset:(e==null?void 0:e.offset)??0};e!=null&&e.q&&(s.q=e.q);const i=(e==null?void 0:e.sort_by)??"created_at",a=(e==null?void 0:e.sort_direction)??"asc",o={created_at:"created_at",modified_at:"modified_at",name:"name"};return s.sort=`${o[i]||i}:${a}`,await t.request("/folders",s)}async function Ui(t,e){return e.length===0?{}:(await t.post("/folders/previews",{folders:e})).folders||{}}async function Bi(t){return await t.request("/labels")}async function qi(t){return t.request("/collections")}async function Vi(t,e){return t.request(`/collections/${e}/folders`)}function ei(t){return t.filter(e=>!!e.name).map(e=>({...e,children:ei(e.children??[])})).filter(e=>{var s;return!((((s=e.children)==null?void 0:s.length)??0)<1&&!e.filters)})}async function Hi(t){return((await t.request("/tags")).tags||[]).map(i=>({...i,label:i.names.en||Object.values(i.names)[0]||""})).filter(i=>i.label).sort((i,a)=>i.label.localeCompare(a.label))}async function Gi(t){const e=t.getSecurityTemplateKey();if(!e)throw new Error("Security template key is required for SASS key exchange");return(await t.request(`/key/${e}`)).key}function Vt(t){var a,o;const e=(a=t.info)==null?void 0:a.playlists;if(!(e!=null&&e.length))return null;const s=(o=e[0])==null?void 0:o.playlists;return s!=null&&s.length&&s[0]||null}function je(t){return(t.type??"").startsWith("image")}function Ki(t){return(t.type??"").startsWith("video")}function Qi(t){return(t.type??"").startsWith("audio")}function ti(t){var e,s;return((e=t.url)==null?void 0:e.cdn)??((s=t.url)==null?void 0:s.public)??""}function Yi(t,e){const{meta:s,name:i}=t;if(s!=null&&s.alt)return s.alt;const a=s==null?void 0:s.title;if(typeof a=="string"&&a)return a;if(a&&typeof a=="object"){if(e){const n=a[e];if(n)return n}const o=Object.keys(a)[0];if(o){const n=a[o];if(n)return n}}return i.split(".")[0]}function Pt(t){var e,s;return((e=t.info)==null?void 0:e.img_w)??((s=t.info)==null?void 0:s.video_w)??0}function Dt(t){var e,s;return((e=t.info)==null?void 0:e.img_h)??((s=t.info)==null?void 0:s.video_h)??0}function Wi(t){return{width:Pt(t),height:Dt(t)}}function Xi(t){return Vt(t)!==null}function Zi(t){return Vt(t)}function Ji(t){return Vt(t)??ti(t)}const ea={excellent:90,good:75,fair:60},ta=[{label:"WEBP",value:"webp"},{label:"JPEG",value:"jpeg"},{label:"PNG",value:"png"},{label:"GIF",value:"gif"}],sa=[{label:"Excellent",value:"excellent"},{label:"Good",value:"good"},{label:"Fair",value:"fair"}],ia=[{label:"Original",value:"original"},{label:"Full HD",value:"full_hd",width:1920},{label:"Large",value:"large",width:1200},{label:"Medium",value:"medium",width:600},{label:"Small",value:"small",width:300}],aa={webp:"awebp,webp",jpeg:"jpeg",png:"png",gif:"agif,gif"},oa=new Set(["jpg","jpeg","png","gif","webp","svg","bmp","ico","tiff","tif","avif","heic","heif","psd","eps"]),ra=new Set([...oa,"pdf","psd","eps","ai","ttf","otf","woff","woff2","eot"]);function tt(t){if(!t)return"other";const e={image:"image",video:"video",audio:"audio",application:"document",font:"font",text:"document"};return e[t]?e[t]:t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.startsWith("application/pdf")||t.startsWith("text/")||t.startsWith("application/msword")||t.startsWith("application/vnd.")?"document":t.startsWith("application/zip")||t.startsWith("application/x-rar")||t.startsWith("application/x-7z")||t.startsWith("application/gzip")?"archive":t.startsWith("font/")?"font":"other"}function si(t){const e=(t==null?void 0:t.toLowerCase().replace(".",""))||"";return ra.has(e)}const v="https://scaleflex.cloudimg.io/v7/assets/file-types/v3/",cs={_default:v+"GENERIC.svg?vh=9a518a",png:v+"PNG.svg?vh=96cd9a",jpg:v+"JPG.svg?vh=06e819",jpg2:v+"JPG2.svg?vh=f0eb7f",jpeg:v+"JPEG.svg?vh=6a65e9",gif:v+"GIF.svg?vh=c3c2c3",bmp:v+"BMP.svg?vh=d2243a",webp:v+"WEBP.svg?vh=fedd74",svg:v+"SVG.svg?vh=a15e46",tiff:v+"TIFF.svg?vh=1f30c3",tif:v+"TIF.svg?vh=b383c9",heic:v+"HEIC.svg?vh=84adfe",avif:v+"AVIF.svg?vh=536b30",ico:v+"ICO.svg?vh=79063d",psd:v+"PSD.svg?vh=be6140",psb:v+"PSB.svg?vh=678646",ai:v+"AI.svg?vh=84b254",dwg:v+"DWG.svg?vh=971fb3",mp4:v+"MP4.svg?vh=42f175",webm:v+"WEBM.svg?vh=26a84a",avi:v+"AVI.svg?vh=d22ba8",mpeg:v+"MPEG.svg?vh=ba93bb",ogv:v+"OGV.svg?vh=74d453","3gp":v+"3GP.svg?vh=f0d388","3g2":v+"3G2.svg?vh=04c652",swf:v+"SWF.svg?vh=3955e2",fla:v+"FLA.svg?vh=daf585",m3u8:v+"M3U8.svg?vh=7d5e62",mp3:v+"MP3.svg?vh=66bbef",wav:v+"WAV.svg?vh=d7a7d5",aac:v+"AAC.svg?vh=07f3f9",oga:v+"OGA.svg?vh=a5c622",opus:v+"OPUS.svg?vh=9548b1",weba:v+"WEBA.svg?vh=4dcf70",mid:v+"MID.svg?vh=3f0e29",midi:v+"MIDI.svg?vh=9fedec",cda:v+"CDA.svg?vh=85b83b",pdf:v+"PDF.svg?vh=18c5f7",doc:v+"DOC.svg?vh=d1b47c",docx:v+"DOCX.svg?vh=1eb6b0",txt:v+"TXT.svg?vh=307979",rtf:v+"RTF.svg?vh=978c5f",xls:v+"XLS.svg?vh=13b5f7",xlsx:v+"XLSX.svg?vh=79d64a",ppt:v+"PPT.svg?vh=4ee29b",pptx:v+"PPTX.svg?vh=8b1568",csv:v+"CSV.svg?vh=4add78",odt:v+"ODT.svg?vh=940781",ods:v+"ODS.svg?vh=9fbe9a",odp:v+"ODP.svg?vh=bf892d",dbf:v+"DBF.svg?vh=457bd4",vsd:v+"VSD.svg?vh=8a9ccb",abw:v+"ABW.svg?vh=313dc7",epub:v+"EPUB.svg?vh=15263d",azw:v+"AZW.svg?vh=a018b1",ics:v+"ICS.svg?vh=909f63",ogx:v+"OGX.svg?vh=f694d2",zip:v+"ZIP.svg?vh=84f98b",rar:v+"RAR.svg?vh=1d6423","7z":v+"7Z.svg?vh=e007e5",tar:v+"TAR.svg?vh=603aed",gz:v+"GZ.svg?vh=de13f7",bz:v+"BZ.svg?vh=0374ff",bz2:v+"BZ2.svg?vh=e14294",arc:v+"ARC.svg?vh=942fad",jar:v+"JAR.svg?vh=149796",mpkg:v+"MPKG.svg?vh=dea655",ttf:v+"TTF.svg?vh=d2e2c1",otf:v+"OTF.svg?vh=c904fd",woff:v+"WOFF.svg?vh=4b8177",woff2:v+"WOFF2.svg?vh=b532d3",eot:v+"EOT.svg?vh=a54980",js:v+"JS.svg?vh=524691",mjs:v+"MJS.svg?vh=d57921",ts:v+"TS.svg?vh=9af3ae",css:v+"CSS.svg?vh=287863",html:v+"HTML.svg?vh=fa7a87",htm:v+"HTM.svg?vh=21323d",xhtml:v+"XHTML.svg?vh=e6d6a9",xul:v+"XUL.svg?vh=6c9c71",json:v+"JSON.svg?vh=104c9e",jsonld:v+"JSONLD.svg?vh=f30c0f",xml:v+"XML.svg?vh=7f7194",php:v+"PHP.svg?vh=503e36",sh:v+"SH.svg?vh=3b820e",csh:v+"CSH.svg?vh=08c0cc",exe:v+"EXE.svg?vh=ccca53",iso:v+"ISO.svg?vh=064b8f",bin:v+"BIN.svg?vh=1e9618"};function $t(t){const e=(t==null?void 0:t.toLowerCase().replace(".",""))||"";return cs[e]||cs._default}function st(){return cs._default}function Ht(t){if(!t)return"";const e=t.split("/");return e.length>1?e[1]:e[0]}const na=new Set(["png","svg","webp","gif","avif"]);function us(t){const e=(t==null?void 0:t.toLowerCase().replace(".",""))||"";return na.has(e)}const la=new Set(["svg","svg+xml","png","pdf"]);function ii(t){return la.has(Ht(t).toLowerCase())}function zt(t){var i;const e=t.info,s=(e==null?void 0:e.video_thumbnail)||(e==null?void 0:e.image_thumbnail)||(e==null?void 0:e.thumbnail)||(e==null?void 0:e.preview)||((i=t.url)==null?void 0:i.cdn)||"";return Be(s)}function ai(t){const e=t.info,s=(e==null?void 0:e.video_thumbnail)||(e==null?void 0:e.image_thumbnail)||(e==null?void 0:e.thumbnail)||"";return s?Be(s):""}function gs(t){var s,i;let e=Be(((s=t.url)==null?void 0:s.cdn)||((i=t.url)==null?void 0:i.public)||"");return e?(e=e.replace(/([?&])func=proxy&?/,"$1").replace(/[?&]$/,""),xe(e,{w:"200",force_format:"webp,jpeg",doc_page:"1",bypass_process_proxy:"1"})):""}function xe(t,e){try{const s=new URL(t);for(const[i,a]of Object.entries(e))s.searchParams.set(i,a);return s.toString()}catch{return t}}const Hs=/^(https:\/\/)([a-z0-9_-]+)\.filerobot\.com\//i;function Be(t,e){if(!t)return"";const s=a=>a.replace(/(\.filerobot\.com\/[a-z0-9_-]+)\/v\d+\//i,"$1/");if(t.includes("assets.filerobot.com"))return s(t);const i=t.match(Hs);if(i){const a=i[2],o=t.replace(Hs,`$1assets.filerobot.com/${a}/`);return s(o)}if(e)try{const a=new URL(t);return s(`https://assets.filerobot.com/${e}${a.pathname}${a.search}`)}catch{}return t}function oi(t,e){const s=t.file_uri_cdn;if(!s)return"";let i=Be(s);const a=tt(t.file_type),o=String(window.devicePixelRatio||1);return a==="video"?xe(i,{w:e,dpr:o,force_format:"webp,jpeg"}):t.file_type==="application/pdf"||Ht(t.file_type).toLowerCase()==="pdf"?(i=i.replace(/([?&])func=proxy&?/,"$1").replace(/[?&]$/,""),xe(i,{w:e,dpr:o,force_format:"webp,jpeg",doc_page:"1",bypass_process_proxy:"1"})):xe(i,{w:e,dpr:o})}function fs(t,e){const s={};return t.format&&(s.force_format=aa[t.format]),t.quality&&t.format!=="png"&&(s.q=String(ea[t.quality])),t.width&&(s.w=String(t.width)),t.height&&(s.h=String(t.height)),(t.width||t.height)&&(s.org_if_sml="1",e!=null&&e.isMultiSelect?s.func="bound":(e==null?void 0:e.isAspectLocked)===!1&&(s.func="cover")),s}function ca(t,e,s){const i=Be(t);if(!i)return t;const a=fs(e,s);return Object.keys(a).length>0?xe(i,a):i}const b={TYPE:"type",MIME_TYPE:"mimetype",METADATA:"metadata",DATE:"date",APPROVAL:"approval",SIZE:"size",LICENSE_EXPIRY:"asset_expiration",TAGS:"tags",IMAGE:"image",LABELS:"labels",PRODUCT_REF:"product_ref",FACES:"faces",COLOR:"color"},G={STATUS:"approval_status",APPROVER:"task_approver",REQUESTOR:"task_requester",DUE_DATE:"task_duedate"},S={IS:":",RANGE:"..",IS_NOT:":-",IS_EXACT:":=",CONTAINS:"~",CONTAINS_IN_TEXT:"~~~",GREATER_THAN_OR_EQUAL:">=",LESS_THAN_OR_EQUAL:"<="},da={AND:"AND"},w={NUMERIC:"numeric",SELECT_ONE:"select-one",MULTI_SELECT:"multi-select",TEXT_AREA:"textarea",TEXT:"text",SUPERTAGS:"tags",DATE:"date",BOOLEAN:"boolean",ATTACHMENTS_ASSETS:"attachments-assets",ATTACHMENT_URI:"attachment-uri",GEO_POINT:"geopoint",DECIMAL2:"decimal2",INTEGER_LIST:"integer-list"},Gt={[w.DATE]:"date_",[w.BOOLEAN]:"bool_",[w.NUMERIC]:"num_",[w.DECIMAL2]:"dec_",[w.ATTACHMENTS_ASSETS]:"attach_",[w.ATTACHMENT_URI]:"uri_",[w.SELECT_ONE]:"one_",[w.MULTI_SELECT]:"multi_",[w.SUPERTAGS]:"tags_",[w.TEXT]:"text_",[w.TEXT_AREA]:"area_",[w.GEO_POINT]:"geo_",[w.INTEGER_LIST]:"intlist_"};Object.fromEntries(Object.entries(Gt).map(([t,e])=>[e,t]));const ri=Object.values(Gt),pt={PRESET:"preset",AFTER:"after",BEFORE:"before",BETWEEN:"between",SPECIFIC:"specific"},Gs={EMPTY:"empty",NOT_EMPTY:"non-empty"},re="empty",ne="non-empty",ze="specific",Jt=10,es=10,Tt=10,ni="filters:pinned:",li="metadata:pinned:",Ks=[b.DATE,b.TYPE,b.SIZE],ci=S.IS,Ot="20",Mt="1",pa=0,ha=[{key:b.DATE,label:"Date",icon:"calendar",type:"date"},{key:b.TYPE,label:"Format",icon:"file-type",type:"string"},{key:b.SIZE,label:"Size",icon:"scaling",type:"string"},{key:b.LICENSE_EXPIRY,label:"License expiry",icon:"history",type:"date"},{key:b.TAGS,label:"Tags",icon:"hash",type:"string"},{key:b.LABELS,label:"Labels",icon:"tag",type:"string"},{key:b.PRODUCT_REF,label:"Products",icon:"box",type:"string"},{key:b.IMAGE,label:"Image",icon:"image",type:"string"},{key:b.COLOR,label:"Color",icon:"swatch-book",type:"string"}],ua={key:b.METADATA,label:"Metadata",icon:"file-text",type:"string"},ga={key:b.APPROVAL,label:"Approval",icon:"badge-check",type:"string"},ds=[ua,...ha,ga],et={[b.TYPE]:"Format",[b.DATE]:"Date",[b.SIZE]:"Size",[b.LICENSE_EXPIRY]:"License expiry",[b.TAGS]:"Tags",[b.LABELS]:"Labels",[b.PRODUCT_REF]:"Products",[b.IMAGE]:"Image",[b.COLOR]:"Color",[b.METADATA]:"Metadata",[b.APPROVAL]:"Approval"},K={IMAGE:"image",VIDEO:"video",AUDIO:"audio",DOCUMENT:"document",ARCHIVE:"archive",DESIGN_TEMPLATE:"template_fdt",OTHER:"other",FONTS:"font"},Rt=[{value:K.IMAGE,label:"Image",icon:"image"},{value:K.VIDEO,label:"Video",icon:"clapperboard"},{value:K.AUDIO,label:"Audio",icon:"music"},{value:K.DOCUMENT,label:"Document",icon:"document"},{value:K.ARCHIVE,label:"Archive",icon:"archive"},{value:K.DESIGN_TEMPLATE,label:"Design template",icon:"layout-template"},{value:K.FONTS,label:"Fonts",icon:"text"},{value:K.OTHER,label:"Other",icon:"layout-grid"}],fa={[K.IMAGE]:["jpg","jpeg","png","gif","webp","svg","bmp","ico","tiff","tif","avif","heic","heif","psd","eps"],[K.VIDEO]:["mp4","webm","ogg","mov","avi","mkv","flv","wmv","m4v"],[K.AUDIO]:["mp3","wav","ogg","flac","aac","wma","m4a","opus"],[K.DOCUMENT]:["pdf","doc","docx","xls","xlsx","ppt","pptx","txt","csv","rtf","odt","ods","odp","html"],[K.ARCHIVE]:["zip","rar","7z","tar","gz","bz2","xz"],[K.FONTS]:["ttf","otf","woff","woff2","eot"]},ts={RESOLUTION:0,ORIENTATION:1,FACES:2},va=[{value:"small",label:"Small"},{value:"medium",label:"Medium"},{value:"large",label:"Large"}],ma=[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"},{value:"square",label:"Square"},{value:"panorama",label:"Panorama"}],ba=[{value:"none",label:"None"},{value:"1",label:"1"},{value:"2",label:"2"},{value:"3..",label:"3+"}],di=[{value:"created",label:"Created at"},{value:"updated",label:"Updated at"}],vs=[{value:"today",label:"Today"},{value:"before",label:"Before date"},{value:"last_week",label:"Last week"},{value:"after",label:"After date"},{value:"last_month",label:"Last month"},{value:"between",label:"Between dates"},{value:"last_year",label:"Last year"}],pi=[{value:"today",label:"Today"},{value:"before",label:"Before date"},{value:"within_week",label:"Within week"},{value:"after",label:"After date"},{value:"within_month",label:"Within month"},{value:"between",label:"Between dates"},{value:"within_year",label:"Within year"},{value:"specific",label:"Specific date"}],_a=[{value:"today",label:"Today"},{value:"before",label:"Before date"},{value:"within_week",label:"Within week"},{value:"after",label:"After date"},{value:"within_month",label:"Within month"},{value:"between",label:"Between dates"},{value:"within_year",label:"Within year"},{value:"specific",label:"Specific date"}],ya=["#ffffff","#99a1af","#000000","#894b00","#e7000b","#ff8904","#fdc700","#9ae600","#008236","#00bcff","#1447e6","#7f22fe","#e60076"],xa=[{label:"None (Exact)",value:"0"},{label:"Small",value:"1"},{label:"Medium",value:"2"},{label:"Large",value:"4"}],ss=[{label:"Is",value:S.IS},{label:"Contains",value:S.CONTAINS_IN_TEXT}],ye=[{label:"Is",value:S.IS},{label:"Is not",value:S.IS_NOT}],is=[{label:"Is",value:S.IS_EXACT},{label:"Contains",value:S.IS},{label:"Does not contain",value:S.IS_NOT}],as=[{label:"Is",value:S.IS},{label:"Greater than",value:S.GREATER_THAN_OR_EQUAL},{label:"Is not",value:S.IS_NOT},{label:"Less than",value:S.LESS_THAN_OR_EQUAL},{label:"Between",value:S.RANGE}],wa=[{label:"Is",value:S.IS_EXACT},{label:"Is not",value:S.IS_NOT}],Qs=[{label:"Contains",value:S.CONTAINS},{label:"Does not contain",value:S.IS_NOT}],$a=[{value:"APPROVED",label:"Approved",icon:"circle-check-big",iconColor:"var(--ap-success, oklch(0.637 0.17 151.295))"},{value:"PENDING",label:"Pending",icon:"clock",iconColor:"var(--ap-warning, oklch(0.734 0.157 69.419))"},{value:"REJECTED",label:"Rejected",icon:"x-circle",iconColor:"var(--ap-destructive, oklch(0.577 0.215 27.325))"},{value:"CANCELLED",label:"Cancelled",icon:"ban",iconColor:"var(--ap-muted-foreground, oklch(0.685 0.033 249.82))"}],Ne=[{label:"Empty",value:re},{label:"Not empty",value:ne}],os=[...Ne,{label:"Specific",value:ze}],ka=[{label:"Empty",value:re},{label:"Not empty",value:ne},{label:"True",value:"true"},{label:"False",value:"false"}],It={[w.DATE]:"calendar",[w.BOOLEAN]:"toggle-left",[w.NUMERIC]:"file-digit",[w.DECIMAL2]:"decimals-arrow-right",[w.ATTACHMENTS_ASSETS]:"paperclip",[w.ATTACHMENT_URI]:"link-2",[w.SELECT_ONE]:"circle-dot",[w.MULTI_SELECT]:"square-check",[w.SUPERTAGS]:"hash",[w.TEXT]:"text-initial",[w.TEXT_AREA]:"text-align-justify",[w.GEO_POINT]:"locate",[w.INTEGER_LIST]:"list-ordered"},Sa={[w.TEXT]:"text",[w.TEXT_AREA]:"text",[w.NUMERIC]:"number",[w.DECIMAL2]:"number",[w.BOOLEAN]:"boolean",[w.SELECT_ONE]:"select-one",[w.MULTI_SELECT]:"multi-select",[w.SUPERTAGS]:"tags",[w.DATE]:"date",[w.GEO_POINT]:"geo",[w.ATTACHMENTS_ASSETS]:"attachment",[w.ATTACHMENT_URI]:"attachment",[w.INTEGER_LIST]:"attachment"};async function Ca(t){var i;return(((i=(await t.request("/filters",{filter_by:"filetype",format:"list",limit:200})).filters)==null?void 0:i.file_types)??[]).map(a=>({name:a.name,value:a.value,count:a.count,category:a.category??a.value.split("_")[0],label:Fa(a.name)}))}function Fa(t){const e=t.indexOf("›");return(e!==-1?t.slice(e+1).trim():t).toUpperCase()}async function Ea(t){var m,_;const e=await t.request("/settings"),s=e.settings??e,i=(s==null?void 0:s.metadata)??e.metadata,o=((i==null?void 0:i.model)??[])[pa],n=i==null?void 0:i.store,d=((n==null?void 0:n.regional_variants_groups)??[]).map(y=>({uuid:y.uuid,label:y.label??y.name??"",variants:(y.variants??[]).map(C=>({api_value:C.api_value??C.value??"",internal_unique_value:C.internal_unique_value??C.api_value??"",label:C.label??C.name??""}))})).filter(y=>y.variants.length>1),h={};for(const y of d)h[y.uuid]=((m=y.variants[0])==null?void 0:m.api_value)??"";const u=(s==null?void 0:s.project_branding)??((_=e.settings)==null?void 0:_.project_branding),f=u==null?void 0:u.brandColor;if(!o)return{fields:[],regionalVariantGroups:d,regionalFilters:h,brandColor:f};const p=o.groups??[],g=[];for(const y of p){const C=y.name||"Root fields";for(const x of y.fields??[]){const M=x.possible_values,$=M==null?void 0:M.map(k=>({api_value:k.api_value??k.value??"",internal_unique_value:k.internal_unique_value??k.api_value??"",label:k.label??k.name??k.api_value??""}));g.push({key:x.key??x.ckey,label:x.title??x.label??x.key??"",type:x.type??"text",slug:x.slug,ckey:x.ckey,possible_values:$,group:C,regionalVariantsGroupUuid:x.regional_variants_group_uuid})}}return{fields:g,regionalVariantGroups:d,regionalFilters:h,brandColor:f}}function Re(t){return t.toLocaleDateString("en-CA")}function Lt(){return Re(new Date)}function hi(t){const e=new Date;switch(t){case"today":return{from:Lt(),to:null};case"last_week":{const s=new Date(e);return s.setDate(s.getDate()-7),{from:Re(s),to:null}}case"within_week":{const s=new Date(e);return s.setDate(s.getDate()+7),{from:Lt(),to:Re(s)}}case"last_month":{const s=new Date(e);return s.setDate(s.getDate()-30),{from:Re(s),to:null}}case"within_month":{const s=new Date(e);return s.setDate(s.getDate()+30),{from:Lt(),to:Re(s)}}case"last_year":{const s=new Date(e);return s.setDate(s.getDate()-365),{from:Re(s),to:null}}case"within_year":{const s=new Date(e);return s.setDate(s.getDate()+365),{from:Lt(),to:Re(s)}}default:return null}}function Ys(t,e){return e?e.type==="date"?Aa(e):e.type==="string"?Ta(e):!0:!1}function Aa(t){return!(!t.kind&&!t.preset||t.kind==="preset"&&!t.preset||t.kind==="between"&&!t.from&&!t.to||t.kind==="after"&&!t.from||t.kind==="before"&&!t.to||t.kind==="specific"&&!t.from||t.from&&t.to&&new Date(t.from)>new Date(t.to))}function Ta(t){return!t.values||!Array.isArray(t.values)?!1:t.values.filter(Boolean).length>0}function La(t,e={}){const s=[];for(const[i,a]of Object.entries(t)){if(!a||!Ys(i,a))continue;const o=Ma(i,a);s.push(...o)}for(const[i,a]of Object.entries(e)){if(!a||!Ys(i,a))continue;const o=Na(i,a);s.push(...o)}return Oa(s)}function Oa(t){const e=[],s=[],i=[];for(const a of t)a.startsWith("type:")||a.startsWith("type=")?e.push(a):a.startsWith("mimetype:")||a.startsWith("mimetype=")?s.push(a):i.push(a);if(e.length>0&&s.length>0){const a=[...e,...s].join(" , ");i.push(a)}else i.push(...e,...s);return i}function Ma(t,e){if(e.type==="date")return ui(t,e);if(t===b.IMAGE)return ja(e);const s=e,{operator:i=ci,values:a=[],logic:o}=s;if(a.length===0)return[];switch(t){case b.SIZE:return Ia(t,a,"..");case b.FACES:return Pa(t,i,a);case b.TAGS:return Ue(t,i,Ws(a),",",o);case b.LABELS:return Ue(t,i,Ws(a),",",o);case b.COLOR:return Da(i,a,o);case b.TYPE:return za(a,i);case b.MIME_TYPE:return Ra(t,a,i);case b.PRODUCT_REF:return Ue(t,"=%",a,",",o);default:return Ue(t,i,a,",",o)}}function ui(t,e){const s=e.field||"created";if(e.kind===pt.PRESET&&e.preset){if(e.preset===Gs.EMPTY)return[`${s}:"empty"`];if(e.preset===Gs.NOT_EMPTY)return[`${s}:"non-empty"`];const i=hi(e.preset);return i?i.to===null?[`${s}>"${i.from}"`]:[`${s}:"${i.from}..${i.to}"`]:[]}if(e.kind===pt.AFTER&&e.from)return[`${s}:>"${e.from}"`];if(e.kind===pt.BEFORE&&e.to)return[`${s}:<"${e.to}"`];if(e.kind===pt.BETWEEN){if(e.from&&e.to)return[`${s}:"${e.from}..${e.to}"`];if(e.from&&!e.to)return[`${s}:>"${e.from}"`];if(!e.from&&e.to)return[`${s}:<"${e.to}"`]}return e.kind===pt.SPECIFIC&&e.from?[`${s}:"${e.from}"`]:[]}function Ia(t,e,s){return e.length===0?[]:[`${t}:"${e.join(s)}"`]}function Pa(t,e,s){return s.length===0?[]:[`${t}${e}"${s.join(",")}"`]}function Ue(t,e,s,i,a){if(s.length===0)return[];if(a===da.AND)return s.map(n=>`${t}${e}"${n}"`);const o=s.map(n=>`"${n}"`).join(i);return[`${t}${e}${o}`]}function Da(t,e,s){const i=[],a=Ue("color_search",t,e,",",s);return i.push(...a),i.push('color_operator:"AND"'),i}function za(t,e){if(t.length===0)return[];const s=new Set,i=[];for(const o of t){const n=fa[o];if(n)for(const c of n){const d=`${o}_${c}`;s.has(d)||(s.add(d),i.push(d))}else s.has(o)||(s.add(o),i.push(o))}const a=i.map(o=>`"${o}"`).join(",");return[`type${e}${a}`]}function Ra(t,e,s,i){if(e.length===0)return[];const a=e.map(o=>`"${o}"`).join(",");return[`${t}${s}${a}`]}function ja(t){const e=[];if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const n=t,c=n.resolution,d=n.orientation,h=n.faces;return c!=null&&c.length&&e.push(`resolution:"${c.join(",")}"`),d!=null&&d.length&&e.push(`orientation:"${d.join(",")}"`),h!=null&&h.length&&e.push(`faces:"${h.join(",")}"`),e}const s=t,i=s[ts.RESOLUTION],a=s[ts.ORIENTATION],o=s[ts.FACES];return i&&e.push(`resolution:"${i}"`),a&&e.push(`orientation:"${a}"`),o&&e.push(`faces:"${o}"`),e}function Na(t,e){const s=qa(t),i=Ba(t);if(e.type==="date")return Ua(s,e,i);const a=e,{operator:o=ci,values:n=[],logic:c,metadataType:d}=a;if(n.length===0)return[];if(n.length===1&&(n[0]===re||n[0]===ne)){const h=d===w.GEO_POINT?S.IS+"~":S.IS;return[`${s}${h}"${n[0]}"`]}if((d===w.NUMERIC||d===w.DECIMAL2)&&o===S.RANGE)return[`${s}${S.IS}"${n.join('","')}"`];if(d===w.GEO_POINT){const h=n.map(u=>{const f=u.indexOf("..");if(f===-1)return`(${u})`;const p=u.slice(0,f),g=u.slice(f);return`(${p})${g}`});return Ue(s,o+"~",h,",",c)}return Ue(s,o,n,",",c)}function Ua(t,e,s){const i=ui(t,e);return!s||i.length===0?i:i.map(a=>{const o=a.search(/[^a-zA-Z0-9_]/);if(o===-1)return`"${a}"`;const n=a.slice(0,o),d=a.slice(o).replace(/"/g,"");return`"${n}${d}"`})}function Ba(t){return t.startsWith("date_")}function qa(t){for(const e of ri)if(t.startsWith(e))return t.slice(e.length);return t}function Ws(t){return t.map(e=>e.replace(/#/g,""))}const Va=new Set([b.DATE,b.LICENSE_EXPIRY,G.DUE_DATE]);function ps(t){if(!t)return{};const e={};for(const[s,i]of Object.entries(t))i&&(e[s]=Ha(s,i));return e}function Ha(t,e){return e.type==="string"||e.type==="date"?e:Va.has(t)?{type:"date",field:e.field??"created",kind:e.kind??null,preset:e.preset??null,from:e.from??null,to:e.to??null}:{type:"string",values:e.values,...e.operator!==void 0&&{operator:e.operator},...e.logic!==void 0&&{logic:e.logic}}}function Ga(t){const e=localStorage.getItem(ni+t),s=localStorage.getItem(li+t);let i;try{i=e?JSON.parse(e):[...Ks]}catch{i=[...Ks]}let a;try{a=s?JSON.parse(s):[]}catch{a=[]}return{pinnedFilters:i,pinnedMetadata:a}}function Ka(t,e){localStorage.setItem(ni+t,JSON.stringify(e))}function Qa(t,e){localStorage.setItem(li+t,JSON.stringify(e))}const gi="sort-by",fi="sort-order";function Xs(t,e){try{localStorage.setItem(gi,t),localStorage.setItem(fi,e)}catch{}}function Ya(){try{const t=localStorage.getItem(gi),e=localStorage.getItem(fi);return{sortBy:t,sortDirection:e}}catch{return{sortBy:null,sortDirection:null}}}const vi="ap-last-folder",mi="ap-last-view",bi="ap-last-tab";function nt(t,e){return e?`${t}:${e}`:t}function Zs(t,e){try{localStorage.setItem(nt(vi,e),t)}catch{}}function Wa(t){try{return localStorage.getItem(nt(vi,t))}catch{return null}}function Xa(t,e){try{localStorage.setItem(nt(mi,e),t)}catch{}}function Za(t){try{return localStorage.getItem(nt(mi,t))}catch{return null}}function Ja(t,e){try{localStorage.setItem(nt(bi,e),t)}catch{}}function eo(t){try{const e=localStorage.getItem(nt(bi,t));return e==="assets"||e==="folders"||e==="labels"||e==="collections"?e:null}catch{return null}}function to(t){const e=t.replace("#",""),s=e.length===3?e[0]+e[0]+e[1]+e[1]+e[2]+e[2]:e,i=parseInt(s.slice(0,2),16)/255,a=parseInt(s.slice(2,4),16)/255,o=parseInt(s.slice(4,6),16)/255;return[i,a,o]}function rs(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function so(t,e,s){const i=rs(t),a=rs(e),o=rs(s),n=.4122214708*i+.5363325363*a+.0514459929*o,c=.2119034982*i+.6806995451*a+.1073969566*o,d=.0883024619*i+.2817188376*a+.6299787005*o,h=Math.cbrt(n),u=Math.cbrt(c),f=Math.cbrt(d),p=.2104542553*h+.793617785*u-.0040720468*f,g=1.9779984951*h-2.428592205*u+.4505937099*f,m=.0259040371*h+.7827717662*u-.808675766*f,_=Math.sqrt(g*g+m*m);let y=Math.atan2(m,g)*(180/Math.PI);return y<0&&(y+=360),[p,_,y]}function io(t){return t>.7}function ao(t,e){const s=["--ap-primary","--ap-primary-foreground","--ap-primary-10","--ap-primary-20","--ap-accent","--ap-accent-foreground","--ap-ring","--ap-selection-bg"];if(!e){for(const f of s)t.style.removeProperty(f);return}const[i,a,o]=to(e),[n,c,d]=so(i,a,o),h=`oklch(${n.toFixed(3)} ${c.toFixed(3)} ${d.toFixed(1)})`,u=io(n)?"#000":"#fff";t.style.setProperty("--ap-primary",h),t.style.setProperty("--ap-primary-foreground",u),t.style.setProperty("--ap-primary-10",`oklch(${n.toFixed(3)} ${c.toFixed(3)} ${d.toFixed(1)} / 0.1)`),t.style.setProperty("--ap-primary-20",`oklch(${n.toFixed(3)} ${c.toFixed(3)} ${d.toFixed(1)} / 0.2)`),t.style.setProperty("--ap-accent",`oklch(${n.toFixed(3)} ${c.toFixed(3)} ${d.toFixed(1)} / 0.07)`),t.style.setProperty("--ap-accent-foreground",h),t.style.setProperty("--ap-ring",`oklch(${n.toFixed(3)} ${c.toFixed(3)} ${d.toFixed(1)} / 0.7)`),t.style.setProperty("--ap-selection-bg",`oklch(${n.toFixed(3)} ${c.toFixed(3)} ${d.toFixed(1)} / 0.08)`)}const ms=[{value:"name",label:"Name"},{value:"created_at",label:"Uploaded"},{value:"modified_at",label:"Modified"},{value:"size",label:"Size"},{value:"type",label:"Format"}],oo=[{value:"relevance",label:"Relevance"},...ms],ro=[{value:"name",label:"Name"},{value:"created_at",label:"Uploaded"},{value:"modified_at",label:"Modified"},{value:"files_count_recursive",label:"Assets count"},{value:"files_size_recursive",label:"Assets size"}],no=[{value:"name",label:"Name"}],lo=[{value:"name",label:"Name"},{value:"created_at",label:"Uploaded"},{value:"updated_at",label:"Modified"}],co=[{value:"name",label:"Name"}];var po=Object.defineProperty,ho=Object.getOwnPropertyDescriptor,bs=(t,e,s,i)=>{for(var a=i>1?void 0:i?ho(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&po(e,s,a),a};let ht=class extends r.LitElement{constructor(){super(...arguments),this.open=!1}updated(t){var e;super.updated(t),t.has("open")&&(this.open?this.dialog&&!this.dialog.open&&this.dialog.showModal():(e=this.dialog)!=null&&e.open&&this._animateClose())}_animateClose(){const t=this.dialog;if(t){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){t.close();return}t.classList.add("closing"),t.addEventListener("animationend",()=>{t.classList.remove("closing"),t.close()},{once:!0})}}_handleBackdropClick(t){t.target===this.dialog&&this.dispatchEvent(new CustomEvent("ap-cancel",{detail:{reason:"backdrop"},bubbles:!0,composed:!0}))}_handleCancel(t){t.preventDefault(),this.dispatchEvent(new CustomEvent("ap-cancel",{detail:{reason:"escape"},bubbles:!0,composed:!0}))}render(){return r.html`
1
+ "use strict";var ki=Object.create;var Bs=Object.defineProperty;var Si=Object.getOwnPropertyDescriptor;var Ci=Object.getOwnPropertyNames;var Fi=Object.getPrototypeOf,Ei=Object.prototype.hasOwnProperty;var Ai=(t,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Ci(e))!Ei.call(t,a)&&a!==s&&Bs(t,a,{get:()=>e[a],enumerable:!(i=Si(e,a))||i.enumerable});return t};var Ti=(t,e,s)=>(s=t!=null?ki(Fi(t)):{},Ai(e||!t||!t.__esModule?Bs(s,"default",{value:t,enumerable:!0}):s,t));const r=require("lit"),l=require("lit/decorators.js");class Li{constructor(e){this.listeners=new Set,this._notifying=!1,this._pendingState=null,this.state=e}getState(){return this.state}setState(e){if(this._notifying){this._pendingState={...this._pendingState||{},...e};return}const s=this.state;this.state={...s,...e},this._notifying=!0;try{this.listeners.forEach(i=>i(this.state,s))}finally{this._notifying=!1}if(this._pendingState){const i=this._pendingState;this._pendingState=null,this.setState(i)}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}destroy(){this.listeners.clear()}}function Oi(){return new Li({config:null,projectToken:"",sassKey:"",brandColor:"",isOpen:!1,activeTab:"assets",viewMode:"grid",searchQuery:"",isAISearchActive:!1,sortBy:"modified_at",sortDirection:"desc",previewAsset:null,isPreviewOpen:!1,assets:[],folders:[],folderPreviews:{},labels:[],tags:[],currentFolder:null,currentFolderPath:"/",breadcrumb:[],activeLabelUuid:null,collections:[],activeCollectionUuid:null,activeCollectionFolders:[],activeCollectionFolder:null,isLoadingCollectionFolders:!1,offset:0,limit:100,totalCount:0,totalFolderCount:0,isLoading:!1,isSelectingAll:!1,hasMore:!1,filters:{metadata:{pinned:[],visible:[],applied:{}},pinned:[],visible:[],applied:{}},fileTypes:[],metadataFields:[],regionalVariantGroups:[],regionalFilters:{},selectedAssets:new Map,selectedFolders:new Map,isResolvingFolders:!1})}class Mi{constructor(e,s){this.host=e,this.store=s,e.addController(this)}get state(){return this.store.getState()}setState(e){this.store.setState(e)}hostConnected(){this.unsubscribe=this.store.subscribe(()=>{this.host.requestUpdate()})}hostDisconnected(){var e;(e=this.unsubscribe)==null||e.call(this)}}function Ii(t){return"extension"in t&&!("path"in t)}class Pi{constructor(e,s){this.lastClickedIndex=-1,this.host=e,this.store=s,e.addController(this)}hostConnected(){}hostDisconnected(){}get _folderSelectionEnabled(){var e;return((e=this.store.getState().config)==null?void 0:e.folderSelection)===!0}_getCombinedList(){const e=this.store.getState();return this._folderSelectionEnabled?[...e.folders,...e.assets]:e.assets}_applyRangeSelection(e,s,i,a){const o=this._getCombinedList();for(let n=e;n<=s;n++){const c=o[n];c&&(Ii(c)?i.set(c.uuid,c):a.set(c.uuid,c))}}handleSelect(e,s,i){var c,d,h,u;const a=this.store.getState(),o=new Map(a.selectedAssets);if(!(((c=a.config)==null?void 0:c.multiSelect)??!0)){o.clear(),o.set(e.uuid,e),this.store.setState({selectedAssets:o,selectedFolders:new Map}),this.lastClickedIndex=s;return}if(i.shiftKey&&this.lastClickedIndex>=0)if(this._folderSelectionEnabled){const g=Math.min(this.lastClickedIndex,s),p=Math.max(this.lastClickedIndex,s),f=new Map(a.selectedFolders);this._applyRangeSelection(g,p,o,f);const m=(d=a.config)==null?void 0:d.maxSelections;if(m&&o.size+f.size>m)return;this.store.setState({selectedAssets:o,selectedFolders:f})}else{const g=Math.min(this.lastClickedIndex,s),p=Math.max(this.lastClickedIndex,s),f=a.assets;for(let x=g;x<=p;x++)f[x]&&o.set(f[x].uuid,f[x]);const m=(h=a.config)==null?void 0:h.maxSelections;if(m&&o.size>m)return;this.store.setState({selectedAssets:o})}else if(i.metaKey||i.ctrlKey){o.has(e.uuid)?o.delete(e.uuid):o.set(e.uuid,e);const g=(u=a.config)==null?void 0:u.maxSelections,p=o.size+(this._folderSelectionEnabled?a.selectedFolders.size:0);if(g&&p>g)return;this.store.setState({selectedAssets:o})}else o.clear(),o.set(e.uuid,e),this.store.setState({selectedAssets:o,selectedFolders:new Map});this.lastClickedIndex=s}handleFolderSelect(e,s,i){var c,d,h;if(!this._folderSelectionEnabled)return;const a=this.store.getState(),o=new Map(a.selectedFolders);if(!(((c=a.config)==null?void 0:c.multiSelect)??!0)){o.clear(),o.set(e.uuid,e),this.store.setState({selectedFolders:o,selectedAssets:new Map}),this.lastClickedIndex=s;return}if(i.shiftKey&&this.lastClickedIndex>=0){const u=Math.min(this.lastClickedIndex,s),g=Math.max(this.lastClickedIndex,s),p=new Map(a.selectedAssets);this._applyRangeSelection(u,g,p,o);const f=(d=a.config)==null?void 0:d.maxSelections;if(f&&p.size+o.size>f)return;this.store.setState({selectedAssets:p,selectedFolders:o})}else if(i.metaKey||i.ctrlKey){o.has(e.uuid)?o.delete(e.uuid):o.set(e.uuid,e);const u=(h=a.config)==null?void 0:h.maxSelections,g=o.size+a.selectedAssets.size;if(u&&g>u)return;this.store.setState({selectedFolders:o})}else o.clear(),o.set(e.uuid,e),this.store.setState({selectedFolders:o,selectedAssets:new Map});this.lastClickedIndex=s}isSelected(e){return this.store.getState().selectedAssets.has(e)}isFolderSelected(e){return this.store.getState().selectedFolders.has(e)}resetRange(){this.lastClickedIndex=-1}selectAll(e){var c;const s=this.store.getState(),i=(c=s.config)==null?void 0:c.maxSelections,a=this._folderSelectionEnabled?s.selectedFolders.size:0,o=new Map,n=i?Math.max(0,Math.min(e.length,i-a)):e.length;for(let d=0;d<n;d++)o.set(e[d].uuid,e[d]);return this.store.setState({selectedAssets:o}),this.lastClickedIndex=-1,o.size}selectAllFolders(e){var n;if(!this._folderSelectionEnabled)return;const s=this.store.getState(),i=(n=s.config)==null?void 0:n.maxSelections,a=new Map,o=i?Math.max(0,Math.min(e.length,i-s.selectedAssets.size)):e.length;for(let c=0;c<o;c++)a.set(e[c].uuid,e[c]);this.store.setState({selectedFolders:a})}clearSelection(){this.store.setState({selectedAssets:new Map,selectedFolders:new Map}),this.lastClickedIndex=-1}getSelectedAssets(){return Array.from(this.store.getState().selectedAssets.values())}getSelectedFolders(){return Array.from(this.store.getState().selectedFolders.values())}}class Di{constructor(e,s){this.host=e,this.onLoadMore=s,e.addController(this)}hostConnected(){}hostDisconnected(){this.disconnect()}observe(e,s){this.disconnect(),this.sentinel=e,this.observer=new IntersectionObserver(i=>{var a;(a=i[0])!=null&&a.isIntersecting&&this.onLoadMore()},{root:s??null,rootMargin:"200px"}),this.observer.observe(e)}disconnect(){this.observer&&this.sentinel&&(this.observer.unobserve(this.sentinel),this.observer.disconnect()),this.observer=void 0,this.sentinel=void 0}}const qs=5,Je=40,Vs=15;class zi{constructor(e,s){this.startX=0,this.startY=0,this.startClientX=0,this.startClientY=0,this.preMarqueeSelection=new Map,this.preMarqueeFolderSelection=new Map,this._dragging=!1,this._scrollRAF=null,this._lastMouseEvent=null,this.isActive=!1,this.rect={x:0,y:0,width:0,height:0},this.handleMouseDown=i=>this.onMouseDown(i),this.handleMouseMove=i=>this.onMouseMove(i),this.handleMouseUp=()=>this.onMouseUp(),this.preventSelect=i=>i.preventDefault(),this.host=e,this.store=s,e.addController(this)}hostConnected(){}hostDisconnected(){this.detach()}attach(e){this.detach(),this.container=e,e.addEventListener("mousedown",this.handleMouseDown)}detach(){this.container&&this.container.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("selectstart",this.preventSelect),this.stopAutoScroll(),this._lastMouseEvent=null}isInteractiveTarget(e){return e.composedPath().some(i=>{if(!(i instanceof HTMLElement))return!1;if(i instanceof HTMLButtonElement||i instanceof HTMLInputElement)return!0;const a=i.tagName.toLowerCase();return!!(a.startsWith("ap-asset-")||a.startsWith("ap-folder-")||i.classList.contains("check")||i.classList.contains("check-box"))})}onMouseDown(e){var a;if(e.button!==0||this.isInteractiveTarget(e)||!(((a=this.store.getState().config)==null?void 0:a.multiSelect)??!0))return;const i=this.container.getBoundingClientRect();this.startX=e.clientX-i.left+this.container.scrollLeft,this.startY=e.clientY-i.top+this.container.scrollTop,this.startClientX=e.clientX,this.startClientY=e.clientY,this._dragging=!1,this.isActive=!1,document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}onMouseMove(e){var s;if(this.container){if(!this._dragging){const i=Math.abs(e.clientX-this.startClientX),a=Math.abs(e.clientY-this.startClientY);if(i<qs&&a<qs)return;this._dragging=!0,this.isActive=!0,document.addEventListener("selectstart",this.preventSelect),(s=window.getSelection())==null||s.removeAllRanges(),this.preMarqueeSelection=new Map(this.store.getState().selectedAssets),this.preMarqueeFolderSelection=new Map(this.store.getState().selectedFolders)}this._lastMouseEvent=e,this.updateMarqueeRect(e),this.startAutoScroll(e)}}updateMarqueeRect(e){if(!this.container)return;const s=this.container.getBoundingClientRect(),i=e.clientX-s.left+this.container.scrollLeft,a=e.clientY-s.top+this.container.scrollTop;let o=Math.min(this.startX,i),n=Math.min(this.startY,a),c=Math.abs(i-this.startX),d=Math.abs(a-this.startY);const h=this.container.scrollWidth,u=this.container.scrollHeight;o+c>h&&(c=h-o),n+d>u&&(d=u-n),o<0&&(c+=o,o=0),n<0&&(d+=n,n=0),this.rect={x:o,y:n,width:c,height:d},this.host.requestUpdate(),this.selectIntersecting()}startAutoScroll(e){if(!this.container)return;if(this.container.scrollHeight<=this.container.clientHeight){this.stopAutoScroll();return}const s=this.container.getBoundingClientRect(),i=e.clientY-s.top,a=s.bottom-e.clientY,o=i<Je||a<Je;o&&!this._scrollRAF?this._scrollRAF=requestAnimationFrame(()=>this.autoScrollTick()):o||this.stopAutoScroll()}autoScrollTick(){if(this._scrollRAF=null,!this.container||!this._dragging||!this._lastMouseEvent||this.container.scrollHeight<=this.container.clientHeight)return;const e=this.container.getBoundingClientRect(),s=this._lastMouseEvent,i=s.clientY-e.top,a=e.bottom-s.clientY;let o=0;i<Je?o=-Vs*(1-i/Je):a<Je&&(o=Vs*(1-a/Je)),o!==0&&(this.container.scrollTop+=o,this.updateMarqueeRect(s),this._scrollRAF=requestAnimationFrame(()=>this.autoScrollTick()))}stopAutoScroll(){this._scrollRAF&&(cancelAnimationFrame(this._scrollRAF),this._scrollRAF=null)}onMouseUp(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("selectstart",this.preventSelect),this.stopAutoScroll(),this._lastMouseEvent=null,this._dragging&&(this.isActive=!1,this._dragging=!1,this.rect={x:0,y:0,width:0,height:0},this.host.requestUpdate())}querySelectableElements(){const e=[],s=[];for(const i of Array.from(this.container.children))if(i.shadowRoot){const a=i.shadowRoot.querySelectorAll("[data-asset-uuid]");a.length>0&&e.push(...Array.from(a));const o=i.shadowRoot.querySelectorAll("[data-folder-uuid]");o.length>0&&s.push(...Array.from(o))}return e.length===0&&e.push(...Array.from(this.container.querySelectorAll("[data-asset-uuid]"))),s.length===0&&s.push(...Array.from(this.container.querySelectorAll("[data-folder-uuid]"))),{assetCards:e,folderCards:s}}getCardRelativeRect(e){const s=e.getBoundingClientRect(),i=this.container.getBoundingClientRect();return{x:s.left-i.left+this.container.scrollLeft,y:s.top-i.top+this.container.scrollTop,width:s.width,height:s.height}}intersectsMarquee(e){return this.rect.x<e.x+e.width&&this.rect.x+this.rect.width>e.x&&this.rect.y<e.y+e.height&&this.rect.y+this.rect.height>e.y}selectIntersecting(){var h,u;if(!this.container)return;const e=this.store.getState(),s=((h=e.config)==null?void 0:h.folderSelection)===!0,{assetCards:i,folderCards:a}=this.querySelectableElements(),o=new Map(this.preMarqueeSelection),n=s?new Map(this.preMarqueeFolderSelection):e.selectedFolders;i.forEach(g=>{const p=this.getCardRelativeRect(g),f=g.dataset.assetUuid;if(this.intersectsMarquee(p)){const m=e.assets.find(x=>x.uuid===f);m&&o.set(f,m)}}),s&&a.forEach(g=>{const p=this.getCardRelativeRect(g),f=g.dataset.folderUuid;if(this.intersectsMarquee(p)){const m=e.folders.find(x=>x.uuid===f);m&&n.set(f,m)}});const c=(u=e.config)==null?void 0:u.maxSelections,d=o.size+(s?n.size:0);if(c&&d>c){const g=Array.from(o.entries()).slice(0,Math.max(0,c-n.size));this.store.setState({selectedAssets:new Map(g),...s?{selectedFolders:n}:{}})}else this.store.setState({selectedAssets:o,...s?{selectedFolders:n}:{}})}}class Ri{constructor(e,s){this.auth=e;const i=e.projectToken;this.baseUrl=s||`https://api.filerobot.com/${i}/v5`,e.mode==="sassKey"&&(this.sassKey=e.sassKey)}setSassKey(e){this.sassKey=e}getSecurityTemplateKey(){if(this.auth.mode==="securityTemplate")return this.auth.securityTemplateKey}_applyAuthHeaders(e){this.sassKey?e["X-Filerobot-Key"]=this.sassKey:this.auth.mode==="securityTemplate"&&(e["X-Filerobot-Key"]=this.auth.securityTemplateKey)}async request(e,s){const i=new URL(`${this.baseUrl}${e}`);s&&Object.entries(s).forEach(([c,d])=>{d!=null&&(Array.isArray(d)?i.searchParams.set(c,d.join(",")):i.searchParams.set(c,String(d)))});const a={};this._applyAuthHeaders(a);const o=new AbortController,n=setTimeout(()=>o.abort(),3e4);try{const c=await fetch(i.toString(),{headers:a,signal:o.signal});if(clearTimeout(n),!c.ok){let h=`API error: ${c.status} ${c.statusText}`;try{const u=await c.json();u.msg&&(h=`API error: ${c.status} - ${u.msg}`)}catch{}throw new Error(h)}const d=await c.json();if(d.status==="error")throw new Error(`API error: ${d.msg||"Unknown error"}`);return d}catch(c){throw clearTimeout(n),c instanceof DOMException&&c.name==="AbortError"?new Error("API request timed out"):c}}async post(e,s){const i=new URL(`${this.baseUrl}${e}`),a={"Content-Type":"application/json"};this._applyAuthHeaders(a);const o=new AbortController,n=setTimeout(()=>o.abort(),3e4);try{const c=await fetch(i.toString(),{method:"POST",headers:a,body:JSON.stringify(s),signal:o.signal});if(clearTimeout(n),!c.ok){let h=`API error: ${c.status} ${c.statusText}`;try{const u=await c.json();u.msg&&(h=`API error: ${c.status} - ${u.msg}`)}catch{}throw new Error(h)}const d=await c.json();if(d.status==="error")throw new Error(`API error: ${d.msg||"Unknown error"}`);return d}catch(c){throw clearTimeout(n),c instanceof DOMException&&c.name==="AbortError"?new Error("API request timed out"):c}}}function ji(t){const e={offset:t.offset??0,limit:t.limit??100,format:"json,regvar:api,select:internal",preview:2301,recursive:t.recursive??1},s=t.sort_by??"created_at",i=t.sort_direction??"desc",a={created_at:"created_at",modified_at:"modified_at",name:"name",size:"size",type:"type"};e.sort=`${a[s]||s}:${i}`,t.folder&&(e.folder=t.folder);const o=[];return t.search&&!t.with_ai&&o.push(t.search),t.q&&o.push(t.q),o.length>0&&(e.q=o.join(" ")),t.with_ai&&(e.with_ai=!0,t.ai_query&&(e.ai_query=t.ai_query),t.ai_lang&&(e.ai_lang=t.ai_lang)),t.collection_uuid&&(e.collection_uuid=t.collection_uuid),t.f64&&(e.f64=t.f64),e}async function De(t,e){const s=ji(e);return t.request("/files",s)}async function At(t,e){const s={recursive:e.recursive??1};e.folder&&(s.folder=e.folder);const i=[];return e.search&&!e.with_ai&&i.push(e.search),e.q&&i.push(e.q),i.length>0&&(s.q=i.join(" ")),e.with_ai&&(s.with_ai=!0,e.ai_query&&(s.ai_query=e.ai_query),e.ai_lang&&(s.ai_lang=e.ai_lang)),e.collection_uuid&&(s.collection_uuid=e.collection_uuid),e.f64&&(s.f64=e.f64),t.request("/files/stats",s)}async function Ni(t,e){const s={recursive:(e==null?void 0:e.recursive)??0,folder:(e==null?void 0:e.folderPath)??"/",limit:(e==null?void 0:e.limit)??1e3,offset:(e==null?void 0:e.offset)??0};e!=null&&e.q&&(s.q=e.q);const i=(e==null?void 0:e.sort_by)??"created_at",a=(e==null?void 0:e.sort_direction)??"asc",o={created_at:"created_at",modified_at:"modified_at",name:"name"};return s.sort=`${o[i]||i}:${a}`,await t.request("/folders",s)}async function Ui(t,e){return e.length===0?{}:(await t.post("/folders/previews",{folders:e})).folders||{}}async function Bi(t){return await t.request("/labels")}async function qi(t){return t.request("/collections")}async function Vi(t,e){return t.request(`/collections/${e}/folders`)}function ei(t){return t.filter(e=>!!e.name).map(e=>({...e,children:ei(e.children??[])})).filter(e=>{var s;return!((((s=e.children)==null?void 0:s.length)??0)<1&&!e.filters)})}async function Hi(t){return((await t.request("/tags")).tags||[]).map(i=>({...i,label:i.names.en||Object.values(i.names)[0]||""})).filter(i=>i.label).sort((i,a)=>i.label.localeCompare(a.label))}async function Gi(t){const e=t.getSecurityTemplateKey();if(!e)throw new Error("Security template key is required for SASS key exchange");return(await t.request(`/key/${e}`)).key}function Vt(t){var a,o;const e=(a=t.info)==null?void 0:a.playlists;if(!(e!=null&&e.length))return null;const s=(o=e[0])==null?void 0:o.playlists;return s!=null&&s.length&&s[0]||null}function je(t){return(t.type??"").startsWith("image")}function Ki(t){return(t.type??"").startsWith("video")}function Qi(t){return(t.type??"").startsWith("audio")}function ti(t){var e,s;return((e=t.url)==null?void 0:e.cdn)??((s=t.url)==null?void 0:s.public)??""}function Yi(t,e){const{meta:s,name:i}=t;if(s!=null&&s.alt)return s.alt;const a=s==null?void 0:s.title;if(typeof a=="string"&&a)return a;if(a&&typeof a=="object"){if(e){const n=a[e];if(n)return n}const o=Object.keys(a)[0];if(o){const n=a[o];if(n)return n}}return i.split(".")[0]}function Pt(t){var e,s;return((e=t.info)==null?void 0:e.img_w)??((s=t.info)==null?void 0:s.video_w)??0}function Dt(t){var e,s;return((e=t.info)==null?void 0:e.img_h)??((s=t.info)==null?void 0:s.video_h)??0}function Wi(t){return{width:Pt(t),height:Dt(t)}}function Xi(t){return Vt(t)!==null}function Zi(t){return Vt(t)}function Ji(t){return Vt(t)??ti(t)}const ea={excellent:90,good:75,fair:60},ta=[{label:"WEBP",value:"webp"},{label:"JPEG",value:"jpeg"},{label:"PNG",value:"png"},{label:"GIF",value:"gif"}],sa=[{label:"Excellent",value:"excellent"},{label:"Good",value:"good"},{label:"Fair",value:"fair"}],ia=[{label:"Original",value:"original"},{label:"Full HD",value:"full_hd",width:1920},{label:"Large",value:"large",width:1200},{label:"Medium",value:"medium",width:600},{label:"Small",value:"small",width:300}],aa={webp:"awebp,webp",jpeg:"jpeg",png:"png",gif:"agif,gif"},oa=new Set(["jpg","jpeg","png","gif","webp","svg","bmp","ico","tiff","tif","avif","heic","heif","psd","eps"]),ra=new Set([...oa,"pdf","psd","eps","ai","ttf","otf","woff","woff2","eot"]);function tt(t){if(!t)return"other";const e={image:"image",video:"video",audio:"audio",application:"document",font:"font",text:"document"};return e[t]?e[t]:t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.startsWith("application/pdf")||t.startsWith("text/")||t.startsWith("application/msword")||t.startsWith("application/vnd.")?"document":t.startsWith("application/zip")||t.startsWith("application/x-rar")||t.startsWith("application/x-7z")||t.startsWith("application/gzip")?"archive":t.startsWith("font/")?"font":"other"}function si(t){const e=(t==null?void 0:t.toLowerCase().replace(".",""))||"";return ra.has(e)}const v="https://scaleflex.cloudimg.io/v7/assets/file-types/v3/",cs={_default:v+"GENERIC.svg?vh=9a518a",png:v+"PNG.svg?vh=96cd9a",jpg:v+"JPG.svg?vh=06e819",jpg2:v+"JPG2.svg?vh=f0eb7f",jpeg:v+"JPEG.svg?vh=6a65e9",gif:v+"GIF.svg?vh=c3c2c3",bmp:v+"BMP.svg?vh=d2243a",webp:v+"WEBP.svg?vh=fedd74",svg:v+"SVG.svg?vh=a15e46",tiff:v+"TIFF.svg?vh=1f30c3",tif:v+"TIF.svg?vh=b383c9",heic:v+"HEIC.svg?vh=84adfe",avif:v+"AVIF.svg?vh=536b30",ico:v+"ICO.svg?vh=79063d",psd:v+"PSD.svg?vh=be6140",psb:v+"PSB.svg?vh=678646",ai:v+"AI.svg?vh=84b254",dwg:v+"DWG.svg?vh=971fb3",mp4:v+"MP4.svg?vh=42f175",webm:v+"WEBM.svg?vh=26a84a",avi:v+"AVI.svg?vh=d22ba8",mpeg:v+"MPEG.svg?vh=ba93bb",ogv:v+"OGV.svg?vh=74d453","3gp":v+"3GP.svg?vh=f0d388","3g2":v+"3G2.svg?vh=04c652",swf:v+"SWF.svg?vh=3955e2",fla:v+"FLA.svg?vh=daf585",m3u8:v+"M3U8.svg?vh=7d5e62",mp3:v+"MP3.svg?vh=66bbef",wav:v+"WAV.svg?vh=d7a7d5",aac:v+"AAC.svg?vh=07f3f9",oga:v+"OGA.svg?vh=a5c622",opus:v+"OPUS.svg?vh=9548b1",weba:v+"WEBA.svg?vh=4dcf70",mid:v+"MID.svg?vh=3f0e29",midi:v+"MIDI.svg?vh=9fedec",cda:v+"CDA.svg?vh=85b83b",pdf:v+"PDF.svg?vh=18c5f7",doc:v+"DOC.svg?vh=d1b47c",docx:v+"DOCX.svg?vh=1eb6b0",txt:v+"TXT.svg?vh=307979",rtf:v+"RTF.svg?vh=978c5f",xls:v+"XLS.svg?vh=13b5f7",xlsx:v+"XLSX.svg?vh=79d64a",ppt:v+"PPT.svg?vh=4ee29b",pptx:v+"PPTX.svg?vh=8b1568",csv:v+"CSV.svg?vh=4add78",odt:v+"ODT.svg?vh=940781",ods:v+"ODS.svg?vh=9fbe9a",odp:v+"ODP.svg?vh=bf892d",dbf:v+"DBF.svg?vh=457bd4",vsd:v+"VSD.svg?vh=8a9ccb",abw:v+"ABW.svg?vh=313dc7",epub:v+"EPUB.svg?vh=15263d",azw:v+"AZW.svg?vh=a018b1",ics:v+"ICS.svg?vh=909f63",ogx:v+"OGX.svg?vh=f694d2",zip:v+"ZIP.svg?vh=84f98b",rar:v+"RAR.svg?vh=1d6423","7z":v+"7Z.svg?vh=e007e5",tar:v+"TAR.svg?vh=603aed",gz:v+"GZ.svg?vh=de13f7",bz:v+"BZ.svg?vh=0374ff",bz2:v+"BZ2.svg?vh=e14294",arc:v+"ARC.svg?vh=942fad",jar:v+"JAR.svg?vh=149796",mpkg:v+"MPKG.svg?vh=dea655",ttf:v+"TTF.svg?vh=d2e2c1",otf:v+"OTF.svg?vh=c904fd",woff:v+"WOFF.svg?vh=4b8177",woff2:v+"WOFF2.svg?vh=b532d3",eot:v+"EOT.svg?vh=a54980",js:v+"JS.svg?vh=524691",mjs:v+"MJS.svg?vh=d57921",ts:v+"TS.svg?vh=9af3ae",css:v+"CSS.svg?vh=287863",html:v+"HTML.svg?vh=fa7a87",htm:v+"HTM.svg?vh=21323d",xhtml:v+"XHTML.svg?vh=e6d6a9",xul:v+"XUL.svg?vh=6c9c71",json:v+"JSON.svg?vh=104c9e",jsonld:v+"JSONLD.svg?vh=f30c0f",xml:v+"XML.svg?vh=7f7194",php:v+"PHP.svg?vh=503e36",sh:v+"SH.svg?vh=3b820e",csh:v+"CSH.svg?vh=08c0cc",exe:v+"EXE.svg?vh=ccca53",iso:v+"ISO.svg?vh=064b8f",bin:v+"BIN.svg?vh=1e9618"};function $t(t){const e=(t==null?void 0:t.toLowerCase().replace(".",""))||"";return cs[e]||cs._default}function st(){return cs._default}function Ht(t){if(!t)return"";const e=t.split("/");return e.length>1?e[1]:e[0]}const na=new Set(["png","svg","webp","gif","avif"]);function us(t){const e=(t==null?void 0:t.toLowerCase().replace(".",""))||"";return na.has(e)}const la=new Set(["svg","svg+xml","png","pdf"]);function ii(t){return la.has(Ht(t).toLowerCase())}function zt(t){var i;const e=t.info,s=(e==null?void 0:e.video_thumbnail)||(e==null?void 0:e.image_thumbnail)||(e==null?void 0:e.thumbnail)||(e==null?void 0:e.preview)||((i=t.url)==null?void 0:i.cdn)||"";return Be(s)}function ai(t){const e=t.info,s=(e==null?void 0:e.video_thumbnail)||(e==null?void 0:e.image_thumbnail)||(e==null?void 0:e.thumbnail)||"";return s?Be(s):""}function gs(t){var s,i;let e=Be(((s=t.url)==null?void 0:s.cdn)||((i=t.url)==null?void 0:i.public)||"");return e?(e=e.replace(/([?&])func=proxy&?/,"$1").replace(/[?&]$/,""),xe(e,{w:"200",force_format:"webp,jpeg",doc_page:"1",bypass_process_proxy:"1"})):""}function xe(t,e){try{const s=new URL(t);for(const[i,a]of Object.entries(e))s.searchParams.set(i,a);return s.toString()}catch{return t}}const Hs=/^(https:\/\/)([a-z0-9_-]+)\.filerobot\.com\//i;function Be(t,e){if(!t)return"";const s=a=>a.replace(/(\.filerobot\.com\/[a-z0-9_-]+)\/v\d+\//i,"$1/");if(t.includes("assets.filerobot.com"))return s(t);const i=t.match(Hs);if(i){const a=i[2],o=t.replace(Hs,`$1assets.filerobot.com/${a}/`);return s(o)}if(e)try{const a=new URL(t);return s(`https://assets.filerobot.com/${e}${a.pathname}${a.search}`)}catch{}return t}function oi(t,e){const s=t.file_uri_cdn;if(!s)return"";let i=Be(s);const a=tt(t.file_type),o=String(window.devicePixelRatio||1);return a==="video"?xe(i,{w:e,dpr:o,force_format:"webp,jpeg"}):t.file_type==="application/pdf"||Ht(t.file_type).toLowerCase()==="pdf"?(i=i.replace(/([?&])func=proxy&?/,"$1").replace(/[?&]$/,""),xe(i,{w:e,dpr:o,force_format:"webp,jpeg",doc_page:"1",bypass_process_proxy:"1"})):xe(i,{w:e,dpr:o})}function fs(t,e){const s={};return t.format&&(s.force_format=aa[t.format]),t.quality&&t.format!=="png"&&(s.q=String(ea[t.quality])),t.width&&(s.w=String(t.width)),t.height&&(s.h=String(t.height)),(t.width||t.height)&&(s.org_if_sml="1",e!=null&&e.isMultiSelect?s.func="bound":(e==null?void 0:e.isAspectLocked)===!1&&(s.func="cover")),s}function ca(t,e,s){const i=Be(t);if(!i)return t;const a=fs(e,s);return Object.keys(a).length>0?xe(i,a):i}const b={TYPE:"type",MIME_TYPE:"mimetype",METADATA:"metadata",DATE:"date",APPROVAL:"approval",SIZE:"size",LICENSE_EXPIRY:"asset_expiration",TAGS:"tags",IMAGE:"image",LABELS:"labels",PRODUCT_REF:"product_ref",FACES:"faces",COLOR:"color"},G={STATUS:"approval_status",APPROVER:"task_approver",REQUESTOR:"task_requester",DUE_DATE:"task_duedate"},C={IS:":",RANGE:"..",IS_NOT:":-",IS_EXACT:":=",CONTAINS:"~",CONTAINS_IN_TEXT:"~~~",GREATER_THAN_OR_EQUAL:">=",LESS_THAN_OR_EQUAL:"<="},da={AND:"AND"},$={NUMERIC:"numeric",SELECT_ONE:"select-one",MULTI_SELECT:"multi-select",TEXT_AREA:"textarea",TEXT:"text",SUPERTAGS:"tags",DATE:"date",BOOLEAN:"boolean",ATTACHMENTS_ASSETS:"attachments-assets",ATTACHMENT_URI:"attachment-uri",GEO_POINT:"geopoint",DECIMAL2:"decimal2",INTEGER_LIST:"integer-list"},Gt={[$.DATE]:"date_",[$.BOOLEAN]:"bool_",[$.NUMERIC]:"num_",[$.DECIMAL2]:"dec_",[$.ATTACHMENTS_ASSETS]:"attach_",[$.ATTACHMENT_URI]:"uri_",[$.SELECT_ONE]:"one_",[$.MULTI_SELECT]:"multi_",[$.SUPERTAGS]:"tags_",[$.TEXT]:"text_",[$.TEXT_AREA]:"area_",[$.GEO_POINT]:"geo_",[$.INTEGER_LIST]:"intlist_"};Object.fromEntries(Object.entries(Gt).map(([t,e])=>[e,t]));const ri=Object.values(Gt),pt={PRESET:"preset",AFTER:"after",BEFORE:"before",BETWEEN:"between",SPECIFIC:"specific"},Gs={EMPTY:"empty",NOT_EMPTY:"non-empty"},re="empty",ne="non-empty",ze="specific",Jt=10,es=10,Tt=10,ni="filters:pinned:",li="metadata:pinned:",Ks=[b.DATE,b.TYPE,b.SIZE],ci=C.IS,Ot="20",Mt="1",pa=0,ha=[{key:b.DATE,label:"Date",icon:"calendar",type:"date"},{key:b.TYPE,label:"Format",icon:"file-type",type:"string"},{key:b.SIZE,label:"Size",icon:"scaling",type:"string"},{key:b.LICENSE_EXPIRY,label:"License expiry",icon:"history",type:"date"},{key:b.TAGS,label:"Tags",icon:"hash",type:"string"},{key:b.LABELS,label:"Labels",icon:"tag",type:"string"},{key:b.PRODUCT_REF,label:"Products",icon:"box",type:"string"},{key:b.IMAGE,label:"Image",icon:"image",type:"string"},{key:b.COLOR,label:"Color",icon:"swatch-book",type:"string"}],ua={key:b.METADATA,label:"Metadata",icon:"file-text",type:"string"},ga={key:b.APPROVAL,label:"Approval",icon:"badge-check",type:"string"},ds=[ua,...ha,ga],et={[b.TYPE]:"Format",[b.DATE]:"Date",[b.SIZE]:"Size",[b.LICENSE_EXPIRY]:"License expiry",[b.TAGS]:"Tags",[b.LABELS]:"Labels",[b.PRODUCT_REF]:"Products",[b.IMAGE]:"Image",[b.COLOR]:"Color",[b.METADATA]:"Metadata",[b.APPROVAL]:"Approval"},K={IMAGE:"image",VIDEO:"video",AUDIO:"audio",DOCUMENT:"document",ARCHIVE:"archive",DESIGN_TEMPLATE:"template_fdt",OTHER:"other",FONTS:"font"},Rt=[{value:K.IMAGE,label:"Image",icon:"image"},{value:K.VIDEO,label:"Video",icon:"clapperboard"},{value:K.AUDIO,label:"Audio",icon:"music"},{value:K.DOCUMENT,label:"Document",icon:"document"},{value:K.ARCHIVE,label:"Archive",icon:"archive"},{value:K.DESIGN_TEMPLATE,label:"Design template",icon:"layout-template"},{value:K.FONTS,label:"Fonts",icon:"text"},{value:K.OTHER,label:"Other",icon:"layout-grid"}],fa={[K.IMAGE]:["jpg","jpeg","png","gif","webp","svg","bmp","ico","tiff","tif","avif","heic","heif","psd","eps"],[K.VIDEO]:["mp4","webm","ogg","mov","avi","mkv","flv","wmv","m4v"],[K.AUDIO]:["mp3","wav","ogg","flac","aac","wma","m4a","opus"],[K.DOCUMENT]:["pdf","doc","docx","xls","xlsx","ppt","pptx","txt","csv","rtf","odt","ods","odp","html"],[K.ARCHIVE]:["zip","rar","7z","tar","gz","bz2","xz"],[K.FONTS]:["ttf","otf","woff","woff2","eot"]},ts={RESOLUTION:0,ORIENTATION:1,FACES:2},va=[{value:"small",label:"Small"},{value:"medium",label:"Medium"},{value:"large",label:"Large"}],ma=[{value:"portrait",label:"Portrait"},{value:"landscape",label:"Landscape"},{value:"square",label:"Square"},{value:"panorama",label:"Panorama"}],ba=[{value:"none",label:"None"},{value:"1",label:"1"},{value:"2",label:"2"},{value:"3..",label:"3+"}],di=[{value:"created",label:"Created at"},{value:"updated",label:"Updated at"}],vs=[{value:"today",label:"Today"},{value:"before",label:"Before date"},{value:"last_week",label:"Last week"},{value:"after",label:"After date"},{value:"last_month",label:"Last month"},{value:"between",label:"Between dates"},{value:"last_year",label:"Last year"}],pi=[{value:"today",label:"Today"},{value:"before",label:"Before date"},{value:"within_week",label:"Within week"},{value:"after",label:"After date"},{value:"within_month",label:"Within month"},{value:"between",label:"Between dates"},{value:"within_year",label:"Within year"},{value:"specific",label:"Specific date"}],_a=[{value:"today",label:"Today"},{value:"before",label:"Before date"},{value:"within_week",label:"Within week"},{value:"after",label:"After date"},{value:"within_month",label:"Within month"},{value:"between",label:"Between dates"},{value:"within_year",label:"Within year"},{value:"specific",label:"Specific date"}],ya=["#ffffff","#99a1af","#000000","#894b00","#e7000b","#ff8904","#fdc700","#9ae600","#008236","#00bcff","#1447e6","#7f22fe","#e60076"],xa=[{label:"None (Exact)",value:"0"},{label:"Small",value:"1"},{label:"Medium",value:"2"},{label:"Large",value:"4"}],ss=[{label:"Is",value:C.IS},{label:"Contains",value:C.CONTAINS_IN_TEXT}],ye=[{label:"Is",value:C.IS},{label:"Is not",value:C.IS_NOT}],is=[{label:"Is",value:C.IS_EXACT},{label:"Contains",value:C.IS},{label:"Does not contain",value:C.IS_NOT}],as=[{label:"Is",value:C.IS},{label:"Greater than",value:C.GREATER_THAN_OR_EQUAL},{label:"Is not",value:C.IS_NOT},{label:"Less than",value:C.LESS_THAN_OR_EQUAL},{label:"Between",value:C.RANGE}],wa=[{label:"Is",value:C.IS_EXACT},{label:"Is not",value:C.IS_NOT}],Qs=[{label:"Contains",value:C.CONTAINS},{label:"Does not contain",value:C.IS_NOT}],$a=[{value:"APPROVED",label:"Approved",icon:"circle-check-big",iconColor:"var(--ap-success, oklch(0.637 0.17 151.295))"},{value:"PENDING",label:"Pending",icon:"clock",iconColor:"var(--ap-warning, oklch(0.734 0.157 69.419))"},{value:"REJECTED",label:"Rejected",icon:"x-circle",iconColor:"var(--ap-destructive, oklch(0.577 0.215 27.325))"},{value:"CANCELLED",label:"Cancelled",icon:"ban",iconColor:"var(--ap-muted-foreground, oklch(0.685 0.033 249.82))"}],Ne=[{label:"Empty",value:re},{label:"Not empty",value:ne}],os=[...Ne,{label:"Specific",value:ze}],ka=[{label:"Empty",value:re},{label:"Not empty",value:ne},{label:"True",value:"true"},{label:"False",value:"false"}],It={[$.DATE]:"calendar",[$.BOOLEAN]:"toggle-left",[$.NUMERIC]:"file-digit",[$.DECIMAL2]:"decimals-arrow-right",[$.ATTACHMENTS_ASSETS]:"paperclip",[$.ATTACHMENT_URI]:"link-2",[$.SELECT_ONE]:"circle-dot",[$.MULTI_SELECT]:"square-check",[$.SUPERTAGS]:"hash",[$.TEXT]:"text-initial",[$.TEXT_AREA]:"text-align-justify",[$.GEO_POINT]:"locate",[$.INTEGER_LIST]:"list-ordered"},Sa={[$.TEXT]:"text",[$.TEXT_AREA]:"text",[$.NUMERIC]:"number",[$.DECIMAL2]:"number",[$.BOOLEAN]:"boolean",[$.SELECT_ONE]:"select-one",[$.MULTI_SELECT]:"multi-select",[$.SUPERTAGS]:"tags",[$.DATE]:"date",[$.GEO_POINT]:"geo",[$.ATTACHMENTS_ASSETS]:"attachment",[$.ATTACHMENT_URI]:"attachment",[$.INTEGER_LIST]:"attachment"};async function Ca(t){var i;return(((i=(await t.request("/filters",{filter_by:"filetype",format:"list",limit:200})).filters)==null?void 0:i.file_types)??[]).map(a=>({name:a.name,value:a.value,count:a.count,category:a.category??a.value.split("_")[0],label:Fa(a.name)}))}function Fa(t){const e=t.indexOf("›");return(e!==-1?t.slice(e+1).trim():t).toUpperCase()}async function Ea(t){var m,x;const e=await t.request("/settings"),s=e.settings??e,i=(s==null?void 0:s.metadata)??e.metadata,o=((i==null?void 0:i.model)??[])[pa],n=i==null?void 0:i.store,d=((n==null?void 0:n.regional_variants_groups)??[]).map(_=>({uuid:_.uuid,label:_.label??_.name??"",variants:(_.variants??[]).map(w=>({api_value:w.api_value??w.value??"",internal_unique_value:w.internal_unique_value??w.api_value??"",label:w.label??w.name??""}))})).filter(_=>_.variants.length>1),h={};for(const _ of d)h[_.uuid]=((m=_.variants[0])==null?void 0:m.api_value)??"";const u=(s==null?void 0:s.project_branding)??((x=e.settings)==null?void 0:x.project_branding),g=u==null?void 0:u.brandColor;if(!o)return{fields:[],regionalVariantGroups:d,regionalFilters:h,brandColor:g};const p=o.groups??[],f=[];for(const _ of p){const w=_.name||"Root fields";for(const y of _.fields??[]){const T=y.possible_values,k=T==null?void 0:T.map(S=>({api_value:S.api_value??S.value??"",internal_unique_value:S.internal_unique_value??S.api_value??"",label:S.label??S.name??S.api_value??""}));f.push({key:y.key??y.ckey,label:y.title??y.label??y.key??"",type:y.type??"text",slug:y.slug,ckey:y.ckey,possible_values:k,group:w,regionalVariantsGroupUuid:y.regional_variants_group_uuid})}}return{fields:f,regionalVariantGroups:d,regionalFilters:h,brandColor:g}}function Re(t){return t.toLocaleDateString("en-CA")}function Lt(){return Re(new Date)}function hi(t){const e=new Date;switch(t){case"today":return{from:Lt(),to:null};case"last_week":{const s=new Date(e);return s.setDate(s.getDate()-7),{from:Re(s),to:null}}case"within_week":{const s=new Date(e);return s.setDate(s.getDate()+7),{from:Lt(),to:Re(s)}}case"last_month":{const s=new Date(e);return s.setDate(s.getDate()-30),{from:Re(s),to:null}}case"within_month":{const s=new Date(e);return s.setDate(s.getDate()+30),{from:Lt(),to:Re(s)}}case"last_year":{const s=new Date(e);return s.setDate(s.getDate()-365),{from:Re(s),to:null}}case"within_year":{const s=new Date(e);return s.setDate(s.getDate()+365),{from:Lt(),to:Re(s)}}default:return null}}function Ys(t,e){return e?e.type==="date"?Aa(e):e.type==="string"?Ta(e):!0:!1}function Aa(t){return!(!t.kind&&!t.preset||t.kind==="preset"&&!t.preset||t.kind==="between"&&!t.from&&!t.to||t.kind==="after"&&!t.from||t.kind==="before"&&!t.to||t.kind==="specific"&&!t.from||t.from&&t.to&&new Date(t.from)>new Date(t.to))}function Ta(t){return!t.values||!Array.isArray(t.values)?!1:t.values.filter(Boolean).length>0}function La(t,e={}){const s=[];for(const[i,a]of Object.entries(t)){if(!a||!Ys(i,a))continue;const o=Ma(i,a);s.push(...o)}for(const[i,a]of Object.entries(e)){if(!a||!Ys(i,a))continue;const o=Na(i,a);s.push(...o)}return Oa(s)}function Oa(t){const e=[],s=[],i=[];for(const a of t)a.startsWith("type:")||a.startsWith("type=")?e.push(a):a.startsWith("mimetype:")||a.startsWith("mimetype=")?s.push(a):i.push(a);if(e.length>0&&s.length>0){const a=[...e,...s].join(" , ");i.push(a)}else i.push(...e,...s);return i}function Ma(t,e){if(e.type==="date")return ui(t,e);if(t===b.IMAGE)return ja(e);const s=e,{operator:i=ci,values:a=[],logic:o}=s;if(a.length===0)return[];switch(t){case b.SIZE:return Ia(t,a,"..");case b.FACES:return Pa(t,i,a);case b.TAGS:return Ue(t,i,Ws(a),",",o);case b.LABELS:return Ue(t,i,Ws(a),",",o);case b.COLOR:return Da(i,a,o);case b.TYPE:return za(a,i);case b.MIME_TYPE:return Ra(t,a,i);case b.PRODUCT_REF:return Ue(t,"=%",a,",",o);default:return Ue(t,i,a,",",o)}}function ui(t,e){const s=e.field||"created";if(e.kind===pt.PRESET&&e.preset){if(e.preset===Gs.EMPTY)return[`${s}:"empty"`];if(e.preset===Gs.NOT_EMPTY)return[`${s}:"non-empty"`];const i=hi(e.preset);return i?i.to===null?[`${s}>"${i.from}"`]:[`${s}:"${i.from}..${i.to}"`]:[]}if(e.kind===pt.AFTER&&e.from)return[`${s}:>"${e.from}"`];if(e.kind===pt.BEFORE&&e.to)return[`${s}:<"${e.to}"`];if(e.kind===pt.BETWEEN){if(e.from&&e.to)return[`${s}:"${e.from}..${e.to}"`];if(e.from&&!e.to)return[`${s}:>"${e.from}"`];if(!e.from&&e.to)return[`${s}:<"${e.to}"`]}return e.kind===pt.SPECIFIC&&e.from?[`${s}:"${e.from}"`]:[]}function Ia(t,e,s){return e.length===0?[]:[`${t}:"${e.join(s)}"`]}function Pa(t,e,s){return s.length===0?[]:[`${t}${e}"${s.join(",")}"`]}function Ue(t,e,s,i,a){if(s.length===0)return[];if(a===da.AND)return s.map(n=>`${t}${e}"${n}"`);const o=s.map(n=>`"${n}"`).join(i);return[`${t}${e}${o}`]}function Da(t,e,s){const i=[],a=Ue("color_search",t,e,",",s);return i.push(...a),i.push('color_operator:"AND"'),i}function za(t,e){if(t.length===0)return[];const s=new Set,i=[];for(const o of t){const n=fa[o];if(n)for(const c of n){const d=`${o}_${c}`;s.has(d)||(s.add(d),i.push(d))}else s.has(o)||(s.add(o),i.push(o))}const a=i.map(o=>`"${o}"`).join(",");return[`type${e}${a}`]}function Ra(t,e,s,i){if(e.length===0)return[];const a=e.map(o=>`"${o}"`).join(",");return[`${t}${s}${a}`]}function ja(t){const e=[];if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const n=t,c=n.resolution,d=n.orientation,h=n.faces;return c!=null&&c.length&&e.push(`resolution:"${c.join(",")}"`),d!=null&&d.length&&e.push(`orientation:"${d.join(",")}"`),h!=null&&h.length&&e.push(`faces:"${h.join(",")}"`),e}const s=t,i=s[ts.RESOLUTION],a=s[ts.ORIENTATION],o=s[ts.FACES];return i&&e.push(`resolution:"${i}"`),a&&e.push(`orientation:"${a}"`),o&&e.push(`faces:"${o}"`),e}function Na(t,e){const s=qa(t),i=Ba(t);if(e.type==="date")return Ua(s,e,i);const a=e,{operator:o=ci,values:n=[],logic:c,metadataType:d}=a;if(n.length===0)return[];if(n.length===1&&(n[0]===re||n[0]===ne)){const h=d===$.GEO_POINT?C.IS+"~":C.IS;return[`${s}${h}"${n[0]}"`]}if((d===$.NUMERIC||d===$.DECIMAL2)&&o===C.RANGE)return[`${s}${C.IS}"${n.join('","')}"`];if(d===$.GEO_POINT){const h=n.map(u=>{const g=u.indexOf("..");if(g===-1)return`(${u})`;const p=u.slice(0,g),f=u.slice(g);return`(${p})${f}`});return Ue(s,o+"~",h,",",c)}return Ue(s,o,n,",",c)}function Ua(t,e,s){const i=ui(t,e);return!s||i.length===0?i:i.map(a=>{const o=a.search(/[^a-zA-Z0-9_]/);if(o===-1)return`"${a}"`;const n=a.slice(0,o),d=a.slice(o).replace(/"/g,"");return`"${n}${d}"`})}function Ba(t){return t.startsWith("date_")}function qa(t){for(const e of ri)if(t.startsWith(e))return t.slice(e.length);return t}function Ws(t){return t.map(e=>e.replace(/#/g,""))}const Va=new Set([b.DATE,b.LICENSE_EXPIRY,G.DUE_DATE]);function ps(t){if(!t)return{};const e={};for(const[s,i]of Object.entries(t))i&&(e[s]=Ha(s,i));return e}function Ha(t,e){return e.type==="string"||e.type==="date"?e:Va.has(t)?{type:"date",field:e.field??"created",kind:e.kind??null,preset:e.preset??null,from:e.from??null,to:e.to??null}:{type:"string",values:e.values,...e.operator!==void 0&&{operator:e.operator},...e.logic!==void 0&&{logic:e.logic}}}function Ga(t){const e=localStorage.getItem(ni+t),s=localStorage.getItem(li+t);let i;try{i=e?JSON.parse(e):[...Ks]}catch{i=[...Ks]}let a;try{a=s?JSON.parse(s):[]}catch{a=[]}return{pinnedFilters:i,pinnedMetadata:a}}function Ka(t,e){localStorage.setItem(ni+t,JSON.stringify(e))}function Qa(t,e){localStorage.setItem(li+t,JSON.stringify(e))}const gi="sort-by",fi="sort-order";function Xs(t,e){try{localStorage.setItem(gi,t),localStorage.setItem(fi,e)}catch{}}function Ya(){try{const t=localStorage.getItem(gi),e=localStorage.getItem(fi);return{sortBy:t,sortDirection:e}}catch{return{sortBy:null,sortDirection:null}}}const vi="ap-last-folder",mi="ap-last-view",bi="ap-last-tab";function nt(t,e){return e?`${t}:${e}`:t}function Zs(t,e){try{localStorage.setItem(nt(vi,e),t)}catch{}}function Wa(t){try{return localStorage.getItem(nt(vi,t))}catch{return null}}function Xa(t,e){try{localStorage.setItem(nt(mi,e),t)}catch{}}function Za(t){try{return localStorage.getItem(nt(mi,t))}catch{return null}}function Ja(t,e){try{localStorage.setItem(nt(bi,e),t)}catch{}}function eo(t){try{const e=localStorage.getItem(nt(bi,t));return e==="assets"||e==="folders"||e==="labels"||e==="collections"?e:null}catch{return null}}function to(t){const e=t.replace("#",""),s=e.length===3?e[0]+e[0]+e[1]+e[1]+e[2]+e[2]:e,i=parseInt(s.slice(0,2),16)/255,a=parseInt(s.slice(2,4),16)/255,o=parseInt(s.slice(4,6),16)/255;return[i,a,o]}function rs(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function so(t,e,s){const i=rs(t),a=rs(e),o=rs(s),n=.4122214708*i+.5363325363*a+.0514459929*o,c=.2119034982*i+.6806995451*a+.1073969566*o,d=.0883024619*i+.2817188376*a+.6299787005*o,h=Math.cbrt(n),u=Math.cbrt(c),g=Math.cbrt(d),p=.2104542553*h+.793617785*u-.0040720468*g,f=1.9779984951*h-2.428592205*u+.4505937099*g,m=.0259040371*h+.7827717662*u-.808675766*g,x=Math.sqrt(f*f+m*m);let _=Math.atan2(m,f)*(180/Math.PI);return _<0&&(_+=360),[p,x,_]}function io(t){return t>.7}function ao(t,e){const s=["--ap-primary","--ap-primary-foreground","--ap-primary-10","--ap-primary-20","--ap-accent","--ap-accent-foreground","--ap-ring","--ap-selection-bg"];if(!e){for(const g of s)t.style.removeProperty(g);return}const[i,a,o]=to(e),[n,c,d]=so(i,a,o),h=`oklch(${n.toFixed(3)} ${c.toFixed(3)} ${d.toFixed(1)})`,u=io(n)?"#000":"#fff";t.style.setProperty("--ap-primary",h),t.style.setProperty("--ap-primary-foreground",u),t.style.setProperty("--ap-primary-10",`oklch(${n.toFixed(3)} ${c.toFixed(3)} ${d.toFixed(1)} / 0.1)`),t.style.setProperty("--ap-primary-20",`oklch(${n.toFixed(3)} ${c.toFixed(3)} ${d.toFixed(1)} / 0.2)`),t.style.setProperty("--ap-accent",`oklch(${n.toFixed(3)} ${c.toFixed(3)} ${d.toFixed(1)} / 0.07)`),t.style.setProperty("--ap-accent-foreground",h),t.style.setProperty("--ap-ring",`oklch(${n.toFixed(3)} ${c.toFixed(3)} ${d.toFixed(1)} / 0.7)`),t.style.setProperty("--ap-selection-bg",`oklch(${n.toFixed(3)} ${c.toFixed(3)} ${d.toFixed(1)} / 0.08)`)}const ms=[{value:"name",label:"Name"},{value:"created_at",label:"Uploaded"},{value:"modified_at",label:"Modified"},{value:"size",label:"Size"},{value:"type",label:"Format"}],oo=[{value:"relevance",label:"Relevance"},...ms],ro=[{value:"name",label:"Name"},{value:"created_at",label:"Uploaded"},{value:"modified_at",label:"Modified"},{value:"files_count_recursive",label:"Assets count"},{value:"files_size_recursive",label:"Assets size"}],no=[{value:"name",label:"Name"}],lo=[{value:"name",label:"Name"},{value:"created_at",label:"Uploaded"},{value:"updated_at",label:"Modified"}],co=[{value:"name",label:"Name"}];var po=Object.defineProperty,ho=Object.getOwnPropertyDescriptor,bs=(t,e,s,i)=>{for(var a=i>1?void 0:i?ho(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&po(e,s,a),a};let ht=class extends r.LitElement{constructor(){super(...arguments),this.open=!1}updated(t){var e;super.updated(t),t.has("open")&&(this.open?this.dialog&&!this.dialog.open&&this.dialog.showModal():(e=this.dialog)!=null&&e.open&&this._animateClose())}_animateClose(){const t=this.dialog;if(t){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){t.close();return}t.classList.add("closing"),t.addEventListener("animationend",()=>{t.classList.remove("closing"),t.close()},{once:!0})}}_handleBackdropClick(t){t.target===this.dialog&&this.dispatchEvent(new CustomEvent("ap-cancel",{detail:{reason:"backdrop"},bubbles:!0,composed:!0}))}_handleCancel(t){t.preventDefault(),this.dispatchEvent(new CustomEvent("ap-cancel",{detail:{reason:"escape"},bubbles:!0,composed:!0}))}render(){return r.html`
2
2
  <dialog
3
3
  @click=${this._handleBackdropClick}
4
4
  @cancel=${this._handleCancel}
@@ -67,8 +67,8 @@
67
67
  display: flex;
68
68
  flex-direction: column;
69
69
  height: 100%;
70
- height: 100%;
71
70
  max-height: var(--ap-modal-max-height, 85vh);
71
+ overflow: hidden;
72
72
  }
73
73
  .modal-header {
74
74
  flex-shrink: 0;
@@ -489,7 +489,7 @@
489
489
  color: var(--ap-foreground, oklch(0.37 0.022 248.413));
490
490
  margin-bottom: 12px;
491
491
  }
492
- `;ys([l.property()],gt.prototype,"title",2);ys([l.property({type:Boolean})],gt.prototype,"open",2);gt=ys([l.customElement("ap-filter-popover")],gt);var $o=Object.defineProperty,ko=Object.getOwnPropertyDescriptor,kt=(t,e,s,i)=>{for(var a=i>1?void 0:i?ko(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&$o(e,s,a),a};function Js(t){var i;const e=new Map;for(const a of t){const o=a.category||a.value.split("_")[0];if(!e.has(o)){const c=Rt.find(d=>d.value===o);e.set(o,{key:o,label:(c==null?void 0:c.label)||o.charAt(0).toUpperCase()+o.slice(1),icon:(c==null?void 0:c.icon)||"file",extensions:[],totalCount:0})}const n=e.get(o);n.extensions.push({value:a.value,label:a.label||((i=a.value.split("_").pop())==null?void 0:i.toUpperCase())||a.value,count:a.count}),n.totalCount+=a.count}const s=Rt.map(a=>a.value);return[...e.values()].sort((a,o)=>{const n=s.indexOf(a.key),c=s.indexOf(o.key);return(n===-1?999:n)-(c===-1?999:c)})}let qe=class extends r.LitElement{constructor(){super(...arguments),this.selected=[],this.fileTypes=[],this._search="",this._expanded=new Set}_extValues(t){return t.extensions.map(e=>e.value)}_isGroupFullySelected(t){if(this.selected.includes(t.key))return!0;const e=this._extValues(t);return e.length>0&&e.every(s=>this.selected.includes(s))}_isGroupPartial(t){if(this.selected.includes(t.key))return!1;const e=this._extValues(t),s=e.filter(i=>this.selected.includes(i)).length;return s>0&&s<e.length}_isExtSelected(t,e){return this.selected.includes(e)||this.selected.includes(t)}_toggleGroup(t){const e=this._extValues(t),s=this._isGroupFullySelected(t);let i;if(s){const a=new Set([t.key,...e]);i=this.selected.filter(o=>!a.has(o))}else{const a=new Set(e);i=this.selected.filter(o=>!a.has(o)),i.push(t.key)}this._emit(i)}_toggleExt(t,e){const s=this._extValues(e);let i=[...this.selected];i.includes(e.key)&&(i=i.filter(a=>a!==e.key),i.push(...s)),i.includes(t)?i=i.filter(a=>a!==t):(i.push(t),s.every(a=>i.includes(a))&&(i=i.filter(a=>!s.includes(a)),i.push(e.key))),this._emit(i)}_clearAll(){this._emit([])}_emit(t){this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:b.TYPE,values:t,operator:S.IS},bubbles:!0,composed:!0}))}_toggleExpand(t){const e=new Set(this._expanded);e.has(t)?e.delete(t):e.add(t),this._expanded=e}_filteredGroups(t){const e=this._search.toLowerCase().trim();return e?t.map(s=>{if(s.label.toLowerCase().includes(e)||s.key.toLowerCase().includes(e))return s;const a=s.extensions.filter(o=>o.label.toLowerCase().includes(e)||o.value.toLowerCase().includes(e));return a.length===0?null:{...s,extensions:a}}).filter(s=>s!==null):t}_toggleCategory(t){const e=this.selected.includes(t)?this.selected.filter(s=>s!==t):[...this.selected,t];this._emit(e)}updated(t){if(t.has("fileTypes")&&this.fileTypes.length>0){const e=Js(this.fileTypes),s=new Set(this._expanded);for(const i of e)(this._isGroupFullySelected(i)||this._isGroupPartial(i))&&s.add(i.key);this._expanded=s}}render(){if(this.fileTypes.length===0)return this._renderFallback();const t=Js(this.fileTypes),e=this._filteredGroups(t),s=this.selected.length>0;return r.html`
492
+ `;ys([l.property()],gt.prototype,"title",2);ys([l.property({type:Boolean})],gt.prototype,"open",2);gt=ys([l.customElement("ap-filter-popover")],gt);var $o=Object.defineProperty,ko=Object.getOwnPropertyDescriptor,kt=(t,e,s,i)=>{for(var a=i>1?void 0:i?ko(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&$o(e,s,a),a};function Js(t){var i;const e=new Map;for(const a of t){const o=a.category||a.value.split("_")[0];if(!e.has(o)){const c=Rt.find(d=>d.value===o);e.set(o,{key:o,label:(c==null?void 0:c.label)||o.charAt(0).toUpperCase()+o.slice(1),icon:(c==null?void 0:c.icon)||"file",extensions:[],totalCount:0})}const n=e.get(o);n.extensions.push({value:a.value,label:a.label||((i=a.value.split("_").pop())==null?void 0:i.toUpperCase())||a.value,count:a.count}),n.totalCount+=a.count}const s=Rt.map(a=>a.value);return[...e.values()].sort((a,o)=>{const n=s.indexOf(a.key),c=s.indexOf(o.key);return(n===-1?999:n)-(c===-1?999:c)})}let qe=class extends r.LitElement{constructor(){super(...arguments),this.selected=[],this.fileTypes=[],this._search="",this._expanded=new Set}_extValues(t){return t.extensions.map(e=>e.value)}_isGroupFullySelected(t){if(this.selected.includes(t.key))return!0;const e=this._extValues(t);return e.length>0&&e.every(s=>this.selected.includes(s))}_isGroupPartial(t){if(this.selected.includes(t.key))return!1;const e=this._extValues(t),s=e.filter(i=>this.selected.includes(i)).length;return s>0&&s<e.length}_isExtSelected(t,e){return this.selected.includes(e)||this.selected.includes(t)}_toggleGroup(t){const e=this._extValues(t),s=this._isGroupFullySelected(t);let i;if(s){const a=new Set([t.key,...e]);i=this.selected.filter(o=>!a.has(o))}else{const a=new Set(e);i=this.selected.filter(o=>!a.has(o)),i.push(t.key)}this._emit(i)}_toggleExt(t,e){const s=this._extValues(e);let i=[...this.selected];i.includes(e.key)&&(i=i.filter(a=>a!==e.key),i.push(...s)),i.includes(t)?i=i.filter(a=>a!==t):(i.push(t),s.every(a=>i.includes(a))&&(i=i.filter(a=>!s.includes(a)),i.push(e.key))),this._emit(i)}_clearAll(){this._emit([])}_emit(t){this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:b.TYPE,values:t,operator:C.IS},bubbles:!0,composed:!0}))}_toggleExpand(t){const e=new Set(this._expanded);e.has(t)?e.delete(t):e.add(t),this._expanded=e}_filteredGroups(t){const e=this._search.toLowerCase().trim();return e?t.map(s=>{if(s.label.toLowerCase().includes(e)||s.key.toLowerCase().includes(e))return s;const a=s.extensions.filter(o=>o.label.toLowerCase().includes(e)||o.value.toLowerCase().includes(e));return a.length===0?null:{...s,extensions:a}}).filter(s=>s!==null):t}_toggleCategory(t){const e=this.selected.includes(t)?this.selected.filter(s=>s!==t):[...this.selected,t];this._emit(e)}updated(t){if(t.has("fileTypes")&&this.fileTypes.length>0){const e=Js(this.fileTypes),s=new Set(this._expanded);for(const i of e)(this._isGroupFullySelected(i)||this._isGroupPartial(i))&&s.add(i.key);this._expanded=s}}render(){if(this.fileTypes.length===0)return this._renderFallback();const t=Js(this.fileTypes),e=this._filteredGroups(t),s=this.selected.length>0;return r.html`
493
493
  <input
494
494
  class="search-input"
495
495
  type="text"
@@ -1089,7 +1089,7 @@
1089
1089
  .date-inputs {
1090
1090
  margin-top: 4px;
1091
1091
  }
1092
- `];Ke([l.property()],we.prototype,"filterKey",2);Ke([l.property()],we.prototype,"field",2);Ke([l.property()],we.prototype,"kind",2);Ke([l.property()],we.prototype,"preset",2);Ke([l.property()],we.prototype,"from",2);Ke([l.property()],we.prototype,"to",2);we=Ke([l.customElement("ap-filter-date")],we);var Fo=Object.defineProperty,Eo=Object.getOwnPropertyDescriptor,lt=(t,e,s,i)=>{for(var a=i>1?void 0:i?Eo(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Fo(e,s,a),a};let Te=class extends r.LitElement{constructor(){super(...arguments),this.tags=[],this.selected=[],this.filterKey=b.TAGS,this._search=""}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{var t;return(t=this._searchInput)==null?void 0:t.focus()})}get _suggestedTags(){return this.tags.filter(t=>t.primary)}get _otherTags(){return this.tags.filter(t=>!t.primary)}get _atLimit(){return this.selected.length>=Jt}get _isSearching(){return this._search.trim().length>0}_toggle(t){const e=this.selected.includes(t);if(!e&&this._atLimit)return;const s=e?this.selected.filter(i=>i!==t):[...this.selected,t];this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:this.filterKey,values:s,operator:S.IS},bubbles:!0,composed:!0}))}_remove(t){const e=this.selected.filter(s=>s!==t);this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:this.filterKey,values:e,operator:S.IS},bubbles:!0,composed:!0}))}_clearAll(){this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:this.filterKey,values:[],operator:S.IS},bubbles:!0,composed:!0}))}_onSearchInput(t){this._search=t.target.value}_clearSearch(){this._search=""}_getTagBySid(t){return this.tags.find(e=>e.sid===t)}_renderTagItem(t){const e=this.selected.includes(t.sid),s=!e&&this._atLimit;return r.html`
1092
+ `];Ke([l.property()],we.prototype,"filterKey",2);Ke([l.property()],we.prototype,"field",2);Ke([l.property()],we.prototype,"kind",2);Ke([l.property()],we.prototype,"preset",2);Ke([l.property()],we.prototype,"from",2);Ke([l.property()],we.prototype,"to",2);we=Ke([l.customElement("ap-filter-date")],we);var Fo=Object.defineProperty,Eo=Object.getOwnPropertyDescriptor,lt=(t,e,s,i)=>{for(var a=i>1?void 0:i?Eo(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Fo(e,s,a),a};let Te=class extends r.LitElement{constructor(){super(...arguments),this.tags=[],this.selected=[],this.filterKey=b.TAGS,this._search=""}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{var t;return(t=this._searchInput)==null?void 0:t.focus()})}get _suggestedTags(){return this.tags.filter(t=>t.primary)}get _otherTags(){return this.tags.filter(t=>!t.primary)}get _atLimit(){return this.selected.length>=Jt}get _isSearching(){return this._search.trim().length>0}_toggle(t){const e=this.selected.includes(t);if(!e&&this._atLimit)return;const s=e?this.selected.filter(i=>i!==t):[...this.selected,t];this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:this.filterKey,values:s,operator:C.IS},bubbles:!0,composed:!0}))}_remove(t){const e=this.selected.filter(s=>s!==t);this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:this.filterKey,values:e,operator:C.IS},bubbles:!0,composed:!0}))}_clearAll(){this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:this.filterKey,values:[],operator:C.IS},bubbles:!0,composed:!0}))}_onSearchInput(t){this._search=t.target.value}_clearSearch(){this._search=""}_getTagBySid(t){return this.tags.find(e=>e.sid===t)}_renderTagItem(t){const e=this.selected.includes(t.sid),s=!e&&this._atLimit;return r.html`
1093
1093
  <div
1094
1094
  class="tag-item ${s?"disabled":""}"
1095
1095
  title=${s?`You can select up to ${Jt} tags`:r.nothing}
@@ -1279,7 +1279,7 @@
1279
1279
  max-height: none;
1280
1280
  overflow-y: visible;
1281
1281
  }
1282
- `];lt([l.property({type:Array})],Te.prototype,"tags",2);lt([l.property({type:Array})],Te.prototype,"selected",2);lt([l.property()],Te.prototype,"filterKey",2);lt([l.query(".tag-search")],Te.prototype,"_searchInput",2);lt([l.state()],Te.prototype,"_search",2);Te=lt([l.customElement("ap-filter-tags")],Te);var Ao=Object.defineProperty,To=Object.getOwnPropertyDescriptor,St=(t,e,s,i)=>{for(var a=i>1?void 0:i?To(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Ao(e,s,a),a};let Ve=class extends r.LitElement{constructor(){super(...arguments),this.labels=[],this.selected=[],this._search=""}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{var t;return(t=this._searchInput)==null?void 0:t.focus()})}get _atLimit(){return this.selected.length>=es}get _isSearching(){return this._search.trim().length>0}_toggle(t){const e=this.selected.includes(t);if(!e&&this._atLimit)return;const s=e?this.selected.filter(i=>i!==t):[...this.selected,t];this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:b.LABELS,values:s,operator:S.IS},bubbles:!0,composed:!0}))}_remove(t){const e=this.selected.filter(s=>s!==t);this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:b.LABELS,values:e,operator:S.IS},bubbles:!0,composed:!0}))}_clearAll(){this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:b.LABELS,values:[],operator:S.IS},bubbles:!0,composed:!0}))}_onSearchInput(t){this._search=t.target.value}_clearSearch(){this._search=""}_getLabelBySid(t){return this.labels.find(e=>e.sid===t)}_renderLabelItem(t){const e=this.selected.includes(t.sid),s=!e&&this._atLimit;return r.html`
1282
+ `];lt([l.property({type:Array})],Te.prototype,"tags",2);lt([l.property({type:Array})],Te.prototype,"selected",2);lt([l.property()],Te.prototype,"filterKey",2);lt([l.query(".tag-search")],Te.prototype,"_searchInput",2);lt([l.state()],Te.prototype,"_search",2);Te=lt([l.customElement("ap-filter-tags")],Te);var Ao=Object.defineProperty,To=Object.getOwnPropertyDescriptor,St=(t,e,s,i)=>{for(var a=i>1?void 0:i?To(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Ao(e,s,a),a};let Ve=class extends r.LitElement{constructor(){super(...arguments),this.labels=[],this.selected=[],this._search=""}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{var t;return(t=this._searchInput)==null?void 0:t.focus()})}get _atLimit(){return this.selected.length>=es}get _isSearching(){return this._search.trim().length>0}_toggle(t){const e=this.selected.includes(t);if(!e&&this._atLimit)return;const s=e?this.selected.filter(i=>i!==t):[...this.selected,t];this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:b.LABELS,values:s,operator:C.IS},bubbles:!0,composed:!0}))}_remove(t){const e=this.selected.filter(s=>s!==t);this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:b.LABELS,values:e,operator:C.IS},bubbles:!0,composed:!0}))}_clearAll(){this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:b.LABELS,values:[],operator:C.IS},bubbles:!0,composed:!0}))}_onSearchInput(t){this._search=t.target.value}_clearSearch(){this._search=""}_getLabelBySid(t){return this.labels.find(e=>e.sid===t)}_renderLabelItem(t){const e=this.selected.includes(t.sid),s=!e&&this._atLimit;return r.html`
1283
1283
  <div
1284
1284
  class="label-item ${s?"disabled":""}"
1285
1285
  title=${s?`You can select up to ${es} labels`:r.nothing}
@@ -1758,7 +1758,7 @@
1758
1758
  .add-color-btn:hover {
1759
1759
  opacity: 0.8;
1760
1760
  }
1761
- `];ct([l.property({type:Array})],Le.prototype,"values",2);ct([l.state()],Le.prototype,"_colors",2);ct([l.state()],Le.prototype,"_advanced",2);ct([l.state()],Le.prototype,"_showPalette",2);ct([l.state()],Le.prototype,"_initialized",2);Le=ct([l.customElement("ap-filter-color")],Le);var Io=Object.defineProperty,Po=Object.getOwnPropertyDescriptor,Qe=(t,e,s,i)=>{for(var a=i>1?void 0:i?Po(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Io(e,s,a),a};const Do={KB:1/1e3,MB:1,GB:1e3},zo=[{value:"MB",label:"MB"},{value:"GB",label:"GB"}];let $e=class extends r.LitElement{constructor(){super(...arguments),this.min=0,this.max=0,this._minVal="",this._maxVal="",this._unit="MB",this._initialized=!1}willUpdate(t){!this._initialized&&(t.has("min")||t.has("max"))&&(this._initialized=!0,this.min>0&&(this._minVal=String(this.min)),this.max>0&&(this._maxVal=String(this.max)))}get _hasFilter(){return this._minVal!==""||this._maxVal!==""}_clearAll(){this._minVal="",this._maxVal="",this._emitChange()}_setUnit(t){this._unit=t.detail.value,this._emitChange()}_emitChange(){const t=Do[this._unit],e=this._minVal!==""?parseFloat((parseFloat(this._minVal)*t).toFixed(2)).toString():null,s=this._maxVal!==""?parseFloat((parseFloat(this._maxVal)*t).toFixed(2)).toString():null;let i;if(e!==null&&s!==null)i=`${e}..${s}`;else if(e!==null)i=`${e}..`;else if(s!==null)i=`..${s}`;else{this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:b.SIZE,values:[],operator:S.RANGE},bubbles:!0,composed:!0}));return}this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:b.SIZE,values:[i],operator:S.RANGE},bubbles:!0,composed:!0}))}_onMinInput(t){this._minVal=t.target.value,this._emitChange()}_onMaxInput(t){this._maxVal=t.target.value,this._emitChange()}render(){return r.html`
1761
+ `];ct([l.property({type:Array})],Le.prototype,"values",2);ct([l.state()],Le.prototype,"_colors",2);ct([l.state()],Le.prototype,"_advanced",2);ct([l.state()],Le.prototype,"_showPalette",2);ct([l.state()],Le.prototype,"_initialized",2);Le=ct([l.customElement("ap-filter-color")],Le);var Io=Object.defineProperty,Po=Object.getOwnPropertyDescriptor,Qe=(t,e,s,i)=>{for(var a=i>1?void 0:i?Po(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Io(e,s,a),a};const Do={KB:1/1e3,MB:1,GB:1e3},zo=[{value:"MB",label:"MB"},{value:"GB",label:"GB"}];let $e=class extends r.LitElement{constructor(){super(...arguments),this.min=0,this.max=0,this._minVal="",this._maxVal="",this._unit="MB",this._initialized=!1}willUpdate(t){!this._initialized&&(t.has("min")||t.has("max"))&&(this._initialized=!0,this.min>0&&(this._minVal=String(this.min)),this.max>0&&(this._maxVal=String(this.max)))}get _hasFilter(){return this._minVal!==""||this._maxVal!==""}_clearAll(){this._minVal="",this._maxVal="",this._emitChange()}_setUnit(t){this._unit=t.detail.value,this._emitChange()}_emitChange(){const t=Do[this._unit],e=this._minVal!==""?parseFloat((parseFloat(this._minVal)*t).toFixed(2)).toString():null,s=this._maxVal!==""?parseFloat((parseFloat(this._maxVal)*t).toFixed(2)).toString():null;let i;if(e!==null&&s!==null)i=`${e}..${s}`;else if(e!==null)i=`${e}..`;else if(s!==null)i=`..${s}`;else{this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:b.SIZE,values:[],operator:C.RANGE},bubbles:!0,composed:!0}));return}this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:b.SIZE,values:[i],operator:C.RANGE},bubbles:!0,composed:!0}))}_onMinInput(t){this._minVal=t.target.value,this._emitChange()}_onMaxInput(t){this._maxVal=t.target.value,this._emitChange()}render(){return r.html`
1762
1762
  <div class="filter-content">
1763
1763
  <span class="section-label">Size</span>
1764
1764
  <button
@@ -1917,9 +1917,9 @@
1917
1917
  .orientation-label svg {
1918
1918
  flex-shrink: 0;
1919
1919
  }
1920
- `];Qt([l.property({type:Array})],at.prototype,"selectedResolution",2);Qt([l.property({type:Array})],at.prototype,"selectedOrientation",2);Qt([l.property({type:Array})],at.prototype,"selectedFaces",2);at=Qt([l.customElement("ap-filter-image")],at);var Ho=Object.defineProperty,Go=Object.getOwnPropertyDescriptor,P=(t,e,s,i)=>{for(var a=i>1?void 0:i?Go(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Ho(e,s,a),a};function F(t){return`${Gt[t.type]||""}${t.key}`}let I=class extends r.LitElement{constructor(){super(...arguments),this.fields=[],this.appliedFilters={},this.visibleFields=[],this.mode="full",this.activeFieldKey="",this.pinnedFields=[],this.appliedMetadata={},this._showFieldSelection=!1,this._fieldSearch="",this._collapsedFields=new Set,this._tagInputs={},this._tagSuggestions={},this._tagLoading={},this._datePresets={},this._dateFroms={},this._dateTos={},this._specificModeFields=new Set,this._selectSearches={},this._tagDebounceTimers={}}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>this._focusSearch())}disconnectedCallback(){super.disconnectedCallback();for(const t of Object.values(this._tagDebounceTimers))clearTimeout(t)}_focusSearch(){const t=this.renderRoot.querySelector(".field-search, .search-input");t==null||t.focus()}get _atFieldLimit(){return this.visibleFields.length>=Tt}_getField(t){return this.fields.find(e=>F(e)===t)}_getUIType(t){return Sa[t.type]}_getApplied(t){return this.appliedMetadata[t]||this.appliedFilters[t]||{}}_isSpecialValue(t){return!t||t.length!==1?!1:t[0]===re||t[0]===ne}_getContentMode(t){var s,i;const e=this._getApplied(t);return((s=e.values)==null?void 0:s[0])===re?re:((i=e.values)==null?void 0:i[0])===ne?ne:this._specificModeFields.has(t)||e.values&&e.values.length>0?ze:""}_emitFilterChange(t,e,s){const i=F(t);this.dispatchEvent(new CustomEvent("metadata-filter-change",{detail:{fieldKey:i,operator:e,values:s,metadataType:t.type},bubbles:!0,composed:!0}))}_emitFieldToggle(t,e){const s=F(t);this.dispatchEvent(new CustomEvent("metadata-field-toggle",{detail:{fieldKey:s,visible:e},bubbles:!0,composed:!0}))}_emitFieldSelect(t){const e=F(t);!this.visibleFields.includes(e)&&this._atFieldLimit||(this.visibleFields.includes(e)||this._emitFieldToggle(t,!0),this.dispatchEvent(new CustomEvent("metadata-field-select",{detail:{fieldKey:e},bubbles:!0,composed:!0})))}_emitPin(t,e){this.dispatchEvent(new CustomEvent("metadata-pin",{detail:{fieldKey:t,pinned:e},bubbles:!0,composed:!0}))}_openFieldSelection(){this._showFieldSelection=!0,this._fieldSearch=""}_closeFieldSelection(){this._showFieldSelection=!1,this._fieldSearch=""}_addField(t){if(this._atFieldLimit)return;const e=F(t);this.visibleFields.includes(e)||this._emitFieldToggle(t,!0)}_removeField(t){this._emitFieldToggle(t,!1),this._emitFilterChange(t,void 0,[])}_toggleCollapse(t){const e=new Set(this._collapsedFields);e.has(t)?e.delete(t):e.add(t),this._collapsedFields=e}_onOperatorChange(t,e){const i=this._getApplied(F(t)).values||[];this._emitFilterChange(t,e,i)}_onContentModeChange(t,e){const s=F(t);if(e===ze){const i=new Set(this._specificModeFields);i.add(s),this._specificModeFields=i;const a=this._getApplied(s);this._isSpecialValue(a.values)&&this._emitFilterChange(t,a.operator,[])}else{if(this._specificModeFields.has(s)){const i=new Set(this._specificModeFields);i.delete(s),this._specificModeFields=i}if(e)this._onEmptyOption(t,e);else{const i=this._getApplied(s);this._emitFilterChange(t,i.operator,[])}}}_clearFieldFilter(t){const e=F(t);if(this._specificModeFields.has(e)){const p=new Set(this._specificModeFields);p.delete(e),this._specificModeFields=p}const{[e]:s,...i}=this._datePresets;this._datePresets=i;const{[e]:a,...o}=this._dateFroms;this._dateFroms=o;const{[e]:n,...c}=this._dateTos;this._dateTos=c;const{[e]:d,...h}=this._selectSearches;this._selectSearches=h;const{[e]:u,...f}=this._tagInputs;this._tagInputs=f,this._emitFilterChange(t,void 0,[])}_onTextInput(t,e){const s=e.target.value,a=this._getApplied(F(t)).operator||ss[0].value;this._emitFilterChange(t,a,s?[s]:[])}_onNumberInput(t,e,s){const i=e.target.value,a=F(t),o=this._getApplied(a),n=o.operator||as[0].value,c=[...o.values||[]];s===0?c[0]=i:c[1]=i;const d=c.filter(h=>h!==""&&h!==void 0);if(d.length>0){const h=t.type===w.DECIMAL2;if(!d.every(f=>h?!isNaN(parseFloat(f)):/^-?\d+$/.test(f)))return}this._emitFilterChange(t,n,c)}_onBooleanSelect(t,e){var a;const s=this._getApplied(F(t)),i=(a=s.values)==null?void 0:a[0];!e||i===e?this._emitFilterChange(t,void 0,[]):this._emitFilterChange(t,s.operator,[e])}_onSelectOneToggle(t,e){const s=F(t),i=this._getApplied(s),a=i.operator||ye[0].value,o=i.values||[];o.length===1&&o[0]===e?this._emitFilterChange(t,a,[]):this._emitFilterChange(t,a,[e])}_onMultiSelectToggle(t,e){const s=F(t),i=this._getApplied(s),a=i.operator||is[0].value,o=i.values||[],n=o.includes(e)?o.filter(c=>c!==e):[...o,e];this._emitFilterChange(t,a,n)}_onTagKeydown(t,e){const s=F(t);(e.key==="Enter"||e.key===",")&&(e.preventDefault(),this._commitTagInput(t,s))}_onTagInput(t,e,s){const i=s.target.value;if(i.includes(",")){const a=i.replace(/,/g,"").trim();a&&(this._tagInputs={...this._tagInputs,[e]:a},this._commitTagInput(t,e));return}this._tagInputs={...this._tagInputs,[e]:i},this._fetchTagSuggestions(t,e,i.trim())}_selectTagSuggestion(t,e){const s=F(t),i=this._getApplied(s),a=i.operator||ye[0].value,o=i.values||[];o.includes(e)||this._emitFilterChange(t,a,[...o,e]),this._tagInputs={...this._tagInputs,[s]:""},this._tagSuggestions={...this._tagSuggestions,[s]:[]}}_fetchTagSuggestions(t,e,s){if(this._tagDebounceTimers[e]&&clearTimeout(this._tagDebounceTimers[e]),!s||!this.apiClient){this._tagSuggestions={...this._tagSuggestions,[e]:[]},this._tagLoading={...this._tagLoading,[e]:!1};return}this._tagDebounceTimers[e]=setTimeout(async()=>{this._tagLoading={...this._tagLoading,[e]:!0};try{const i=`_${t.ckey||t.key}`,a=await this.apiClient.request("/metadata/autocomplete",{q:s,meta_key:i});(this._tagInputs[e]||"").trim()===s&&(this._tagSuggestions={...this._tagSuggestions,[e]:(a.tags||[]).map(o=>o.tag)})}catch{this._tagSuggestions={...this._tagSuggestions,[e]:[]}}finally{this._tagLoading={...this._tagLoading,[e]:!1}}},300)}_commitTagInput(t,e){const s=(this._tagInputs[e]||"").trim();if(!s)return;const i=this._getApplied(e),a=i.operator||ye[0].value,o=i.values||[];o.includes(s)||this._emitFilterChange(t,a,[...o,s]),this._tagInputs={...this._tagInputs,[e]:""},this._tagSuggestions={...this._tagSuggestions,[e]:[]}}_removeTag(t,e){const s=F(t),i=this._getApplied(s),a=i.operator||ye[0].value,o=i.values||[];this._emitFilterChange(t,a,o.filter(n=>n!==e))}_onTagOperatorChange(t,e){const s=F(t),a=this._getApplied(s).values||[];this._emitFilterChange(t,e,a)}_onDatePreset(t,e){const s=F(t);if(!e){this._clearFieldFilter(t);return}if(this._datePresets={...this._datePresets,[s]:e},["before","after","between"].includes(e)){this._dateFroms={...this._dateFroms,[s]:""},this._dateTos={...this._dateTos,[s]:""};return}if(e==="empty"||e==="non-empty"){this._emitFilterChange(t,void 0,[e]);return}const i=new Date;let a="",o="";switch(e){case"today":{const n=new Date(i);n.setHours(0,0,0,0),a=n.toISOString(),o=i.toISOString();break}case"last_week":{const n=new Date(i),c=n.getDay();n.setDate(n.getDate()-(c===0?6:c-1)),n.setHours(0,0,0,0);const d=new Date(n);d.setDate(d.getDate()-7),a=d.toISOString(),o=n.toISOString();break}case"last_month":{const n=new Date(i.getFullYear(),i.getMonth(),1),c=new Date(n);c.setMonth(c.getMonth()-1),a=c.toISOString(),o=n.toISOString();break}case"last_year":{const n=new Date(i.getFullYear(),0,1),c=new Date(n);c.setFullYear(c.getFullYear()-1),a=c.toISOString(),o=n.toISOString();break}}a&&o&&(this._dateFroms={...this._dateFroms,[s]:a},this._dateTos={...this._dateTos,[s]:o},this._emitFilterChange(t,"..",[a,o]))}_onDateInput(t,e,s){const i=s.target.value,a=F(t),o=this._datePresets[a]||"",n=i?new Date(i+"T00:00:00").toISOString():"";e==="from"?this._dateFroms={...this._dateFroms,[a]:n}:this._dateTos={...this._dateTos,[a]:n};let c=this._dateFroms[a]||"",d=this._dateTos[a]||"";o==="after"&&c&&(d=new Date().toISOString(),this._dateTos={...this._dateTos,[a]:d}),o==="before"&&d&&(c=new Date(0).toISOString(),this._dateFroms={...this._dateFroms,[a]:c}),c&&d&&this._emitFilterChange(t,"..",[c,d])}_onGeoLocationInput(t,e){var f;const s=e.target.value.trim(),i=F(t),a=(f=this.shadowRoot)==null?void 0:f.querySelector(`[data-geo-radius="${i}"]`),o=(a==null?void 0:a.value)||"";if(!s){this._emitFilterChange(t,void 0,[]);return}const n=s.split(",").map(p=>p.trim());if(n.length!==2||n.some(p=>isNaN(Number(p))||p===""))return;const[c,d]=n;let u=`${c},${d}..${o||"0"}`;this._emitFilterChange(t,S.IS,[u])}_onGeoRadiusInput(t,e){var d;const s=e.target.value,i=F(t),a=this._getApplied(i);if(!((d=a.values)!=null&&d[0]))return;const o=a.values[0],[n]=o.split("..");let c=n;s&&(c+=`..${s}`),this._emitFilterChange(t,S.IS,[c])}_onEmptyOption(t,e){var a;const s=this._getApplied(F(t)),i=(a=s.values)==null?void 0:a[0];!e||i===e?this._emitFilterChange(t,s.operator,[]):this._emitFilterChange(t,s.operator,[e])}_getGroupedFields(t){const e=new Map;for(const s of t){const i=s.group||"Root fields";e.has(i)||e.set(i,[]),e.get(i).push(s)}return e}_renderFieldSelection(){const t=this._fieldSearch.toLowerCase(),e=this.fields.filter(a=>a.label.toLowerCase().includes(t)),s=this._getGroupedFields(e),i=(a,o)=>o.length===0?r.nothing:r.html`
1920
+ `];Qt([l.property({type:Array})],at.prototype,"selectedResolution",2);Qt([l.property({type:Array})],at.prototype,"selectedOrientation",2);Qt([l.property({type:Array})],at.prototype,"selectedFaces",2);at=Qt([l.customElement("ap-filter-image")],at);var Ho=Object.defineProperty,Go=Object.getOwnPropertyDescriptor,P=(t,e,s,i)=>{for(var a=i>1?void 0:i?Go(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Ho(e,s,a),a};function A(t){return`${Gt[t.type]||""}${t.key}`}let I=class extends r.LitElement{constructor(){super(...arguments),this.fields=[],this.appliedFilters={},this.visibleFields=[],this.mode="full",this.activeFieldKey="",this.pinnedFields=[],this.appliedMetadata={},this._showFieldSelection=!1,this._fieldSearch="",this._collapsedFields=new Set,this._tagInputs={},this._tagSuggestions={},this._tagLoading={},this._datePresets={},this._dateFroms={},this._dateTos={},this._specificModeFields=new Set,this._selectSearches={},this._tagDebounceTimers={}}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>this._focusSearch())}disconnectedCallback(){super.disconnectedCallback();for(const t of Object.values(this._tagDebounceTimers))clearTimeout(t)}_focusSearch(){const t=this.renderRoot.querySelector(".field-search, .search-input");t==null||t.focus()}get _atFieldLimit(){return this.visibleFields.length>=Tt}_getField(t){return this.fields.find(e=>A(e)===t)}_getUIType(t){return Sa[t.type]}_getApplied(t){return this.appliedMetadata[t]||this.appliedFilters[t]||{}}_isSpecialValue(t){return!t||t.length!==1?!1:t[0]===re||t[0]===ne}_getContentMode(t){var s,i;const e=this._getApplied(t);return((s=e.values)==null?void 0:s[0])===re?re:((i=e.values)==null?void 0:i[0])===ne?ne:this._specificModeFields.has(t)||e.values&&e.values.length>0?ze:""}_emitFilterChange(t,e,s){const i=A(t);this.dispatchEvent(new CustomEvent("metadata-filter-change",{detail:{fieldKey:i,operator:e,values:s,metadataType:t.type},bubbles:!0,composed:!0}))}_emitFieldToggle(t,e){const s=A(t);this.dispatchEvent(new CustomEvent("metadata-field-toggle",{detail:{fieldKey:s,visible:e},bubbles:!0,composed:!0}))}_emitFieldSelect(t){const e=A(t);!this.visibleFields.includes(e)&&this._atFieldLimit||(this.visibleFields.includes(e)||this._emitFieldToggle(t,!0),this.dispatchEvent(new CustomEvent("metadata-field-select",{detail:{fieldKey:e},bubbles:!0,composed:!0})))}_emitPin(t,e){this.dispatchEvent(new CustomEvent("metadata-pin",{detail:{fieldKey:t,pinned:e},bubbles:!0,composed:!0}))}_openFieldSelection(){this._showFieldSelection=!0,this._fieldSearch=""}_closeFieldSelection(){this._showFieldSelection=!1,this._fieldSearch=""}_addField(t){if(this._atFieldLimit)return;const e=A(t);this.visibleFields.includes(e)||this._emitFieldToggle(t,!0)}_removeField(t){this._emitFieldToggle(t,!1),this._emitFilterChange(t,void 0,[])}_toggleCollapse(t){const e=new Set(this._collapsedFields);e.has(t)?e.delete(t):e.add(t),this._collapsedFields=e}_onOperatorChange(t,e){const i=this._getApplied(A(t)).values||[];this._emitFilterChange(t,e,i)}_onContentModeChange(t,e){const s=A(t);if(e===ze){const i=new Set(this._specificModeFields);i.add(s),this._specificModeFields=i;const a=this._getApplied(s);this._isSpecialValue(a.values)&&this._emitFilterChange(t,a.operator,[])}else{if(this._specificModeFields.has(s)){const i=new Set(this._specificModeFields);i.delete(s),this._specificModeFields=i}if(e)this._onEmptyOption(t,e);else{const i=this._getApplied(s);this._emitFilterChange(t,i.operator,[])}}}_clearFieldFilter(t){const e=A(t);if(this._specificModeFields.has(e)){const p=new Set(this._specificModeFields);p.delete(e),this._specificModeFields=p}const{[e]:s,...i}=this._datePresets;this._datePresets=i;const{[e]:a,...o}=this._dateFroms;this._dateFroms=o;const{[e]:n,...c}=this._dateTos;this._dateTos=c;const{[e]:d,...h}=this._selectSearches;this._selectSearches=h;const{[e]:u,...g}=this._tagInputs;this._tagInputs=g,this._emitFilterChange(t,void 0,[])}_onTextInput(t,e){const s=e.target.value,a=this._getApplied(A(t)).operator||ss[0].value;this._emitFilterChange(t,a,s?[s]:[])}_onNumberInput(t,e,s){const i=e.target.value,a=A(t),o=this._getApplied(a),n=o.operator||as[0].value,c=[...o.values||[]];s===0?c[0]=i:c[1]=i;const d=c.filter(h=>h!==""&&h!==void 0);if(d.length>0){const h=t.type===$.DECIMAL2;if(!d.every(g=>h?!isNaN(parseFloat(g)):/^-?\d+$/.test(g)))return}this._emitFilterChange(t,n,c)}_onBooleanSelect(t,e){var a;const s=this._getApplied(A(t)),i=(a=s.values)==null?void 0:a[0];!e||i===e?this._emitFilterChange(t,void 0,[]):this._emitFilterChange(t,s.operator,[e])}_onSelectOneToggle(t,e){const s=A(t),i=this._getApplied(s),a=i.operator||ye[0].value,o=i.values||[];o.length===1&&o[0]===e?this._emitFilterChange(t,a,[]):this._emitFilterChange(t,a,[e])}_onMultiSelectToggle(t,e){const s=A(t),i=this._getApplied(s),a=i.operator||is[0].value,o=i.values||[],n=o.includes(e)?o.filter(c=>c!==e):[...o,e];this._emitFilterChange(t,a,n)}_onTagKeydown(t,e){const s=A(t);(e.key==="Enter"||e.key===",")&&(e.preventDefault(),this._commitTagInput(t,s))}_onTagInput(t,e,s){const i=s.target.value;if(i.includes(",")){const a=i.replace(/,/g,"").trim();a&&(this._tagInputs={...this._tagInputs,[e]:a},this._commitTagInput(t,e));return}this._tagInputs={...this._tagInputs,[e]:i},this._fetchTagSuggestions(t,e,i.trim())}_selectTagSuggestion(t,e){const s=A(t),i=this._getApplied(s),a=i.operator||ye[0].value,o=i.values||[];o.includes(e)||this._emitFilterChange(t,a,[...o,e]),this._tagInputs={...this._tagInputs,[s]:""},this._tagSuggestions={...this._tagSuggestions,[s]:[]}}_fetchTagSuggestions(t,e,s){if(this._tagDebounceTimers[e]&&clearTimeout(this._tagDebounceTimers[e]),!s||!this.apiClient){this._tagSuggestions={...this._tagSuggestions,[e]:[]},this._tagLoading={...this._tagLoading,[e]:!1};return}this._tagDebounceTimers[e]=setTimeout(async()=>{this._tagLoading={...this._tagLoading,[e]:!0};try{const i=`_${t.ckey||t.key}`,a=await this.apiClient.request("/metadata/autocomplete",{q:s,meta_key:i});(this._tagInputs[e]||"").trim()===s&&(this._tagSuggestions={...this._tagSuggestions,[e]:(a.tags||[]).map(o=>o.tag)})}catch{this._tagSuggestions={...this._tagSuggestions,[e]:[]}}finally{this._tagLoading={...this._tagLoading,[e]:!1}}},300)}_commitTagInput(t,e){const s=(this._tagInputs[e]||"").trim();if(!s)return;const i=this._getApplied(e),a=i.operator||ye[0].value,o=i.values||[];o.includes(s)||this._emitFilterChange(t,a,[...o,s]),this._tagInputs={...this._tagInputs,[e]:""},this._tagSuggestions={...this._tagSuggestions,[e]:[]}}_removeTag(t,e){const s=A(t),i=this._getApplied(s),a=i.operator||ye[0].value,o=i.values||[];this._emitFilterChange(t,a,o.filter(n=>n!==e))}_onTagOperatorChange(t,e){const s=A(t),a=this._getApplied(s).values||[];this._emitFilterChange(t,e,a)}_onDatePreset(t,e){const s=A(t);if(!e){this._clearFieldFilter(t);return}if(this._datePresets={...this._datePresets,[s]:e},["before","after","between"].includes(e)){this._dateFroms={...this._dateFroms,[s]:""},this._dateTos={...this._dateTos,[s]:""};return}if(e==="empty"||e==="non-empty"){this._emitFilterChange(t,void 0,[e]);return}const i=new Date;let a="",o="";switch(e){case"today":{const n=new Date(i);n.setHours(0,0,0,0),a=n.toISOString(),o=i.toISOString();break}case"last_week":{const n=new Date(i),c=n.getDay();n.setDate(n.getDate()-(c===0?6:c-1)),n.setHours(0,0,0,0);const d=new Date(n);d.setDate(d.getDate()-7),a=d.toISOString(),o=n.toISOString();break}case"last_month":{const n=new Date(i.getFullYear(),i.getMonth(),1),c=new Date(n);c.setMonth(c.getMonth()-1),a=c.toISOString(),o=n.toISOString();break}case"last_year":{const n=new Date(i.getFullYear(),0,1),c=new Date(n);c.setFullYear(c.getFullYear()-1),a=c.toISOString(),o=n.toISOString();break}}a&&o&&(this._dateFroms={...this._dateFroms,[s]:a},this._dateTos={...this._dateTos,[s]:o},this._emitFilterChange(t,"..",[a,o]))}_onDateInput(t,e,s){const i=s.target.value,a=A(t),o=this._datePresets[a]||"",n=i?new Date(i+"T00:00:00").toISOString():"";e==="from"?this._dateFroms={...this._dateFroms,[a]:n}:this._dateTos={...this._dateTos,[a]:n};let c=this._dateFroms[a]||"",d=this._dateTos[a]||"";o==="after"&&c&&(d=new Date().toISOString(),this._dateTos={...this._dateTos,[a]:d}),o==="before"&&d&&(c=new Date(0).toISOString(),this._dateFroms={...this._dateFroms,[a]:c}),c&&d&&this._emitFilterChange(t,"..",[c,d])}_onGeoLocationInput(t,e){var g;const s=e.target.value.trim(),i=A(t),a=(g=this.shadowRoot)==null?void 0:g.querySelector(`[data-geo-radius="${i}"]`),o=(a==null?void 0:a.value)||"";if(!s){this._emitFilterChange(t,void 0,[]);return}const n=s.split(",").map(p=>p.trim());if(n.length!==2||n.some(p=>isNaN(Number(p))||p===""))return;const[c,d]=n;let u=`${c},${d}..${o||"0"}`;this._emitFilterChange(t,C.IS,[u])}_onGeoRadiusInput(t,e){var d;const s=e.target.value,i=A(t),a=this._getApplied(i);if(!((d=a.values)!=null&&d[0]))return;const o=a.values[0],[n]=o.split("..");let c=n;s&&(c+=`..${s}`),this._emitFilterChange(t,C.IS,[c])}_onEmptyOption(t,e){var a;const s=this._getApplied(A(t)),i=(a=s.values)==null?void 0:a[0];!e||i===e?this._emitFilterChange(t,s.operator,[]):this._emitFilterChange(t,s.operator,[e])}_getGroupedFields(t){const e=new Map;for(const s of t){const i=s.group||"Root fields";e.has(i)||e.set(i,[]),e.get(i).push(s)}return e}_renderFieldSelection(){const t=this._fieldSearch.toLowerCase(),e=this.fields.filter(a=>a.label.toLowerCase().includes(t)),s=this._getGroupedFields(e),i=(a,o)=>o.length===0?r.nothing:r.html`
1921
1921
  <div class="field-group-label">${a}</div>
1922
- ${o.map(n=>{const c=F(n),d=this.visibleFields.includes(c),h=!d&&this._atFieldLimit;return r.html`
1922
+ ${o.map(n=>{const c=A(n),d=this.visibleFields.includes(c),h=!d&&this._atFieldLimit;return r.html`
1923
1923
  <div
1924
1924
  class="field-item ${d?"selected":""} ${h?"disabled":""}"
1925
1925
  @click=${()=>!h&&!d&&this._addField(n)}
@@ -1953,7 +1953,7 @@
1953
1953
  ${e.length===0?r.html`<div class="empty-msg">No fields found</div>`:r.html`${[...s.entries()].map(([a,o])=>i(a,o))}`}
1954
1954
  </div>
1955
1955
  </div>
1956
- `}_renderTextFilter(t){var h,u;const e=F(t),s=this._getApplied(e),a=this._isSpecialValue(s.values)?"":((h=s.values)==null?void 0:h[0])||"",o=this._getContentMode(e),n=o===re||o===ne,c=s.operator||ss[0].value,d=t.type===w.TEXT_AREA;return r.html`
1956
+ `}_renderTextFilter(t){var h,u;const e=A(t),s=this._getApplied(e),a=this._isSpecialValue(s.values)?"":((h=s.values)==null?void 0:h[0])||"",o=this._getContentMode(e),n=o===re||o===ne,c=s.operator||ss[0].value,d=t.type===$.TEXT_AREA;return r.html`
1957
1957
  <div class="filter-content" style="position: relative;">
1958
1958
  <button
1959
1959
  class="clear-btn"
@@ -1968,7 +1968,7 @@
1968
1968
  .options=${ss}
1969
1969
  .value=${c}
1970
1970
  ?disabled=${n}
1971
- @ap-change=${f=>this._onOperatorChange(t,f.detail.value)}
1971
+ @ap-change=${g=>this._onOperatorChange(t,g.detail.value)}
1972
1972
  ></ap-radio-group>
1973
1973
  </div>
1974
1974
 
@@ -1978,7 +1978,7 @@
1978
1978
  clearable
1979
1979
  .options=${os}
1980
1980
  .value=${o}
1981
- @ap-change=${f=>this._onContentModeChange(t,f.detail.value)}
1981
+ @ap-change=${g=>this._onContentModeChange(t,g.detail.value)}
1982
1982
  ></ap-radio-group>
1983
1983
  </div>
1984
1984
 
@@ -1990,7 +1990,7 @@
1990
1990
  class="filter-input"
1991
1991
  placeholder="Enter value"
1992
1992
  .value=${a}
1993
- @change=${f=>this._onTextInput(t,f)}
1993
+ @change=${g=>this._onTextInput(t,g)}
1994
1994
  ></textarea>
1995
1995
  `:r.html`
1996
1996
  <input
@@ -1998,18 +1998,18 @@
1998
1998
  type="text"
1999
1999
  placeholder="Enter value"
2000
2000
  .value=${a}
2001
- @change=${f=>this._onTextInput(t,f)}
2002
- @keydown=${f=>{f.key==="Enter"&&f.preventDefault()}}
2001
+ @change=${g=>this._onTextInput(t,g)}
2002
+ @keydown=${g=>{g.key==="Enter"&&g.preventDefault()}}
2003
2003
  />
2004
2004
  `}
2005
2005
  </div>
2006
2006
  `:r.nothing}
2007
2007
  </div>
2008
- `}_renderNumberFilter(t){var x,M,$;const e=F(t),s=this._getApplied(e),i=s.operator||as[0].value,a=this._isSpecialValue(s.values),o=this._getContentMode(e),n=o===re||o===ne,c=i===S.RANGE,d=i===S.GREATER_THAN_OR_EQUAL,h=i===S.LESS_THAN_OR_EQUAL,u=t.type===w.DECIMAL2,f=u?"0.01":"1",p=u?"0.00":"0",g=a?"":((x=s.values)==null?void 0:x[0])||"",m=a?"":((M=s.values)==null?void 0:M[1])||"",_=c||d||h,y=c||d||h?"Min":"Value";return r.html`
2008
+ `}_renderNumberFilter(t){var y,T,k;const e=A(t),s=this._getApplied(e),i=s.operator||as[0].value,a=this._isSpecialValue(s.values),o=this._getContentMode(e),n=o===re||o===ne,c=i===C.RANGE,d=i===C.GREATER_THAN_OR_EQUAL,h=i===C.LESS_THAN_OR_EQUAL,u=t.type===$.DECIMAL2,g=u?"0.01":"1",p=u?"0.00":"0",f=a?"":((y=s.values)==null?void 0:y[0])||"",m=a?"":((T=s.values)==null?void 0:T[1])||"",x=c||d||h,_=c||d||h?"Min":"Value";return r.html`
2009
2009
  <div class="filter-content" style="position: relative;">
2010
2010
  <button
2011
2011
  class="clear-btn"
2012
- ?disabled=${!(($=s.values)!=null&&$.length)&&!s.operator}
2012
+ ?disabled=${!((k=s.values)!=null&&k.length)&&!s.operator}
2013
2013
  @click=${()=>this._clearFieldFilter(t)}
2014
2014
  >Clear all</button>
2015
2015
 
@@ -2020,7 +2020,7 @@
2020
2020
  .options=${as}
2021
2021
  .value=${i}
2022
2022
  ?disabled=${n}
2023
- @ap-change=${k=>this._onOperatorChange(t,k.detail.value)}
2023
+ @ap-change=${S=>this._onOperatorChange(t,S.detail.value)}
2024
2024
  ></ap-radio-group>
2025
2025
  </div>
2026
2026
 
@@ -2030,7 +2030,7 @@
2030
2030
  clearable
2031
2031
  .options=${os}
2032
2032
  .value=${o}
2033
- @ap-change=${k=>this._onContentModeChange(t,k.detail.value)}
2033
+ @ap-change=${S=>this._onContentModeChange(t,S.detail.value)}
2034
2034
  ></ap-radio-group>
2035
2035
  </div>
2036
2036
 
@@ -2038,28 +2038,28 @@
2038
2038
  <div class="filter-section">
2039
2039
  <div class="grid-2">
2040
2040
  <div>
2041
- <span class="input-label" aria-disabled=${h?"true":r.nothing}>${y}</span>
2041
+ <span class="input-label" aria-disabled=${h?"true":r.nothing}>${_}</span>
2042
2042
  <input
2043
2043
  class="filter-input"
2044
2044
  type="number"
2045
- step=${f}
2045
+ step=${g}
2046
2046
  placeholder=${p}
2047
- .value=${g}
2047
+ .value=${f}
2048
2048
  ?disabled=${h}
2049
- @change=${k=>this._onNumberInput(t,k,0)}
2049
+ @change=${S=>this._onNumberInput(t,S,0)}
2050
2050
  />
2051
2051
  </div>
2052
- ${_?r.html`
2052
+ ${x?r.html`
2053
2053
  <div>
2054
2054
  <span class="input-label" aria-disabled=${d?"true":r.nothing}>${"Max"}</span>
2055
2055
  <input
2056
2056
  class="filter-input"
2057
2057
  type="number"
2058
- step=${f}
2058
+ step=${g}
2059
2059
  placeholder=${p}
2060
2060
  .value=${m}
2061
2061
  ?disabled=${d}
2062
- @change=${k=>this._onNumberInput(t,k,1)}
2062
+ @change=${S=>this._onNumberInput(t,S,1)}
2063
2063
  />
2064
2064
  </div>
2065
2065
  `:r.nothing}
@@ -2067,7 +2067,7 @@
2067
2067
  </div>
2068
2068
  `:r.nothing}
2069
2069
  </div>
2070
- `}_renderBooleanFilter(t){var i,a;const e=this._getApplied(F(t)),s=((i=e.values)==null?void 0:i[0])||"";return r.html`
2070
+ `}_renderBooleanFilter(t){var i,a;const e=this._getApplied(A(t)),s=((i=e.values)==null?void 0:i[0])||"";return r.html`
2071
2071
  <div class="filter-content" style="position: relative;">
2072
2072
  <button
2073
2073
  class="clear-btn"
@@ -2085,7 +2085,7 @@
2085
2085
  ></ap-radio-group>
2086
2086
  </div>
2087
2087
  </div>
2088
- `}_renderSelectOneFilter(t){const e=F(t),s=this._getApplied(e),i=this._isSpecialValue(s.values),a=i?[]:s.values||[],o=t.possible_values||[],n=s.operator||ye[0].value,c=(this._selectSearches[e]||"").toLowerCase(),d=c.length>0,h=a.length>0||i,u=c?o.filter(p=>p.label.toLowerCase().includes(c)):o,f=a.length>=Tt;return r.html`
2088
+ `}_renderSelectOneFilter(t){const e=A(t),s=this._getApplied(e),i=this._isSpecialValue(s.values),a=i?[]:s.values||[],o=t.possible_values||[],n=s.operator||ye[0].value,c=(this._selectSearches[e]||"").toLowerCase(),d=c.length>0,h=a.length>0||i,u=c?o.filter(p=>p.label.toLowerCase().includes(c)):o,g=a.length>=Tt;return r.html`
2089
2089
  <div class="filter-content">
2090
2090
  <!-- Search input -->
2091
2091
  <div class="search-wrapper">
@@ -2143,9 +2143,9 @@
2143
2143
  >Clear all</button>
2144
2144
  </div>
2145
2145
  <div class="chips-wrap">
2146
- ${a.map(p=>{const g=o.find(m=>m.api_value===p);return r.html`
2146
+ ${a.map(p=>{const f=o.find(m=>m.api_value===p);return r.html`
2147
2147
  <div class="chip">
2148
- <span class="chip-label">${(g==null?void 0:g.label)||p}</span>
2148
+ <span class="chip-label">${(f==null?void 0:f.label)||p}</span>
2149
2149
  <button class="chip-remove" @click=${()=>this._onSelectOneToggle(t,p)}>
2150
2150
  <ap-icon name="close" .size=${10}></ap-icon>
2151
2151
  </button>
@@ -2162,12 +2162,12 @@
2162
2162
 
2163
2163
  <!-- Empty/Not empty checkboxes -->
2164
2164
  <div class="options-list short">
2165
- ${Ne.map(p=>{var g;return r.html`
2165
+ ${Ne.map(p=>{var f;return r.html`
2166
2166
  <div
2167
2167
  class="option-item"
2168
2168
  @click=${()=>this._onEmptyOption(t,p.value)}
2169
2169
  >
2170
- <ap-checkbox ?checked=${((g=s.values)==null?void 0:g[0])===p.value}></ap-checkbox>
2170
+ <ap-checkbox ?checked=${((f=s.values)==null?void 0:f[0])===p.value}></ap-checkbox>
2171
2171
  <span>${p.label}</span>
2172
2172
  </div>
2173
2173
  `})}
@@ -2177,19 +2177,19 @@
2177
2177
 
2178
2178
  <!-- Regular options -->
2179
2179
  <div class="options-list">
2180
- ${u.length===0?r.html`<div class="no-results">No options found</div>`:u.map(p=>{const g=a.includes(p.api_value),m=!g&&f;return r.html`
2180
+ ${u.length===0?r.html`<div class="no-results">No options found</div>`:u.map(p=>{const f=a.includes(p.api_value),m=!f&&g;return r.html`
2181
2181
  <div
2182
2182
  class="option-item ${m?"disabled":""}"
2183
2183
  @click=${()=>!m&&this._onSelectOneToggle(t,p.api_value)}
2184
2184
  >
2185
- <ap-checkbox ?checked=${g}></ap-checkbox>
2185
+ <ap-checkbox ?checked=${f}></ap-checkbox>
2186
2186
  <span>${p.label}</span>
2187
2187
  </div>
2188
2188
  `})}
2189
2189
  </div>
2190
2190
  </div>
2191
2191
  </div>
2192
- `}_renderMultiSelectFilter(t){const e=F(t),s=this._getApplied(e),i=this._isSpecialValue(s.values),a=i?[]:s.values||[],o=t.possible_values||[],n=s.operator||is[0].value,c=(this._selectSearches[e]||"").toLowerCase(),d=c.length>0,h=a.length>0||i,u=c?o.filter(p=>p.label.toLowerCase().includes(c)):o,f=a.length>=Tt;return r.html`
2192
+ `}_renderMultiSelectFilter(t){const e=A(t),s=this._getApplied(e),i=this._isSpecialValue(s.values),a=i?[]:s.values||[],o=t.possible_values||[],n=s.operator||is[0].value,c=(this._selectSearches[e]||"").toLowerCase(),d=c.length>0,h=a.length>0||i,u=c?o.filter(p=>p.label.toLowerCase().includes(c)):o,g=a.length>=Tt;return r.html`
2193
2193
  <div class="filter-content">
2194
2194
  <!-- Search input -->
2195
2195
  <div class="search-wrapper">
@@ -2247,9 +2247,9 @@
2247
2247
  >Clear all</button>
2248
2248
  </div>
2249
2249
  <div class="chips-wrap">
2250
- ${a.map(p=>{const g=o.find(m=>m.api_value===p);return r.html`
2250
+ ${a.map(p=>{const f=o.find(m=>m.api_value===p);return r.html`
2251
2251
  <div class="chip">
2252
- <span class="chip-label">${(g==null?void 0:g.label)||p}</span>
2252
+ <span class="chip-label">${(f==null?void 0:f.label)||p}</span>
2253
2253
  <button class="chip-remove" @click=${()=>this._onMultiSelectToggle(t,p)}>
2254
2254
  <ap-icon name="close" .size=${10}></ap-icon>
2255
2255
  </button>
@@ -2266,12 +2266,12 @@
2266
2266
 
2267
2267
  <!-- Empty/Not empty checkboxes -->
2268
2268
  <div class="options-list short">
2269
- ${Ne.map(p=>{var g;return r.html`
2269
+ ${Ne.map(p=>{var f;return r.html`
2270
2270
  <div
2271
2271
  class="option-item"
2272
2272
  @click=${()=>this._onEmptyOption(t,p.value)}
2273
2273
  >
2274
- <ap-checkbox ?checked=${((g=s.values)==null?void 0:g[0])===p.value}></ap-checkbox>
2274
+ <ap-checkbox ?checked=${((f=s.values)==null?void 0:f[0])===p.value}></ap-checkbox>
2275
2275
  <span>${p.label}</span>
2276
2276
  </div>
2277
2277
  `})}
@@ -2281,19 +2281,19 @@
2281
2281
 
2282
2282
  <!-- Regular options -->
2283
2283
  <div class="options-list">
2284
- ${u.length===0?r.html`<div class="no-results">No options found</div>`:u.map(p=>{const g=a.includes(p.api_value),m=!g&&f;return r.html`
2284
+ ${u.length===0?r.html`<div class="no-results">No options found</div>`:u.map(p=>{const f=a.includes(p.api_value),m=!f&&g;return r.html`
2285
2285
  <div
2286
2286
  class="option-item ${m?"disabled":""}"
2287
2287
  @click=${()=>!m&&this._onMultiSelectToggle(t,p.api_value)}
2288
2288
  >
2289
- <ap-checkbox ?checked=${g}></ap-checkbox>
2289
+ <ap-checkbox ?checked=${f}></ap-checkbox>
2290
2290
  <span>${p.label}</span>
2291
2291
  </div>
2292
2292
  `})}
2293
2293
  </div>
2294
2294
  </div>
2295
2295
  </div>
2296
- `}_renderTagsFilter(t){const e=F(t),s=this._getApplied(e),i=this._isSpecialValue(s.values),a=i?[]:s.values||[],o=this._tagInputs[e]||"",n=s.operator||ye[0].value,c=a.length>0||i,d=this._tagSuggestions[e]||[],h=this._tagLoading[e]||!1,u=o.trim().length>0,f=a.length>=Tt;return r.html`
2296
+ `}_renderTagsFilter(t){const e=A(t),s=this._getApplied(e),i=this._isSpecialValue(s.values),a=i?[]:s.values||[],o=this._tagInputs[e]||"",n=s.operator||ye[0].value,c=a.length>0||i,d=this._tagSuggestions[e]||[],h=this._tagLoading[e]||!1,u=o.trim().length>0,g=a.length>=Tt;return r.html`
2297
2297
  <div class="filter-content">
2298
2298
  <!-- Search input -->
2299
2299
  <div class="search-wrapper">
@@ -2369,12 +2369,12 @@
2369
2369
  <div class="filter-section">
2370
2370
  <span class="section-label">All options</span>
2371
2371
  <div class="options-list short">
2372
- ${Ne.map(p=>{var g;return r.html`
2372
+ ${Ne.map(p=>{var f;return r.html`
2373
2373
  <div
2374
2374
  class="option-item"
2375
2375
  @click=${()=>this._onEmptyOption(t,p.value)}
2376
2376
  >
2377
- <ap-checkbox ?checked=${((g=s.values)==null?void 0:g[0])===p.value}></ap-checkbox>
2377
+ <ap-checkbox ?checked=${((f=s.values)==null?void 0:f[0])===p.value}></ap-checkbox>
2378
2378
  <span>${p.label}</span>
2379
2379
  </div>
2380
2380
  `})}
@@ -2386,12 +2386,12 @@
2386
2386
  ${u?r.html`
2387
2387
  <div class="filter-section">
2388
2388
  <div class="options-list">
2389
- ${h?r.html`<div class="option-item disabled"><span>Loading...</span></div>`:d.length>0?d.map(p=>{const g=a.includes(p),m=!g&&f;return r.html`
2389
+ ${h?r.html`<div class="option-item disabled"><span>Loading...</span></div>`:d.length>0?d.map(p=>{const f=a.includes(p),m=!f&&g;return r.html`
2390
2390
  <div
2391
2391
  class="option-item ${m?"disabled":""}"
2392
- @click=${()=>!m&&(g?this._removeTag(t,p):this._selectTagSuggestion(t,p))}
2392
+ @click=${()=>!m&&(f?this._removeTag(t,p):this._selectTagSuggestion(t,p))}
2393
2393
  >
2394
- <ap-checkbox ?checked=${g}></ap-checkbox>
2394
+ <ap-checkbox ?checked=${f}></ap-checkbox>
2395
2395
  <span>${p}</span>
2396
2396
  </div>
2397
2397
  `}):r.html`<div class="option-item disabled"><span>No results</span></div>`}
@@ -2399,11 +2399,11 @@
2399
2399
  </div>
2400
2400
  `:r.nothing}
2401
2401
  </div>
2402
- `}_renderDateFilter(t){var u,f;const e=F(t),s=this._datePresets[e]||"",i=this._getApplied(e),o=this._isSpecialValue(i.values)?((u=i.values)==null?void 0:u[0])||"":s,n=[{value:"empty",label:"Empty"},{value:"non-empty",label:"Not empty"}],c=this._dateFroms[e]?new Date(this._dateFroms[e]).toISOString().split("T")[0]:"",d=this._dateTos[e]?new Date(this._dateTos[e]).toISOString().split("T")[0]:"",h=["before","after","between"].includes(o);return r.html`
2402
+ `}_renderDateFilter(t){var u,g;const e=A(t),s=this._datePresets[e]||"",i=this._getApplied(e),o=this._isSpecialValue(i.values)?((u=i.values)==null?void 0:u[0])||"":s,n=[{value:"empty",label:"Empty"},{value:"non-empty",label:"Not empty"}],c=this._dateFroms[e]?new Date(this._dateFroms[e]).toISOString().split("T")[0]:"",d=this._dateTos[e]?new Date(this._dateTos[e]).toISOString().split("T")[0]:"",h=["before","after","between"].includes(o);return r.html`
2403
2403
  <div class="filter-content" style="position: relative;">
2404
2404
  <button
2405
2405
  class="clear-btn"
2406
- ?disabled=${!o&&!((f=i.values)!=null&&f.length)}
2406
+ ?disabled=${!o&&!((g=i.values)!=null&&g.length)}
2407
2407
  @click=${()=>this._clearFieldFilter(t)}
2408
2408
  >Clear all</button>
2409
2409
 
@@ -2473,11 +2473,11 @@
2473
2473
  </div>
2474
2474
  `:r.nothing}
2475
2475
  </div>
2476
- `}_renderGeoFilter(t){var u,f;const e=F(t),s=this._getApplied(e),i=this._isSpecialValue(s.values),a=this._getContentMode(e);let o="",n="";if(!i&&((u=s.values)!=null&&u[0])){const p=s.values[0],[g,m]=p.split("..");o=g||"",n=m||""}const c=o.length>0,d=o.split(",").map(p=>p.trim()),h=!c||d.length===2&&d.every(p=>!isNaN(Number(p))&&p!=="");return r.html`
2476
+ `}_renderGeoFilter(t){var u,g;const e=A(t),s=this._getApplied(e),i=this._isSpecialValue(s.values),a=this._getContentMode(e);let o="",n="";if(!i&&((u=s.values)!=null&&u[0])){const p=s.values[0],[f,m]=p.split("..");o=f||"",n=m||""}const c=o.length>0,d=o.split(",").map(p=>p.trim()),h=!c||d.length===2&&d.every(p=>!isNaN(Number(p))&&p!=="");return r.html`
2477
2477
  <div class="filter-content" style="position: relative;">
2478
2478
  <button
2479
2479
  class="clear-btn"
2480
- ?disabled=${!((f=s.values)!=null&&f.length)}
2480
+ ?disabled=${!((g=s.values)!=null&&g.length)}
2481
2481
  @click=${()=>this._clearFieldFilter(t)}
2482
2482
  >Clear all</button>
2483
2483
 
@@ -2520,7 +2520,7 @@
2520
2520
  </div>
2521
2521
  `:r.nothing}
2522
2522
  </div>
2523
- `}_renderAttachmentFilter(t){var i,a;const e=this._getApplied(F(t)),s=((i=e.values)==null?void 0:i[0])||"";return r.html`
2523
+ `}_renderAttachmentFilter(t){var i,a;const e=this._getApplied(A(t)),s=((i=e.values)==null?void 0:i[0])||"";return r.html`
2524
2524
  <div class="filter-content" style="position: relative;">
2525
2525
  <button
2526
2526
  class="clear-btn"
@@ -2537,7 +2537,7 @@
2537
2537
  ></ap-radio-group>
2538
2538
  </div>
2539
2539
  </div>
2540
- `}_renderFaceMatcherFilter(t){const e=F(t),s=this._getApplied(e),i=s.values||[],a=s.operator||S.IS;return r.html`
2540
+ `}_renderFaceMatcherFilter(t){const e=A(t),s=this._getApplied(e),i=s.values||[],a=s.operator||C.IS;return r.html`
2541
2541
  <div class="filter-content" style="position: relative;">
2542
2542
  <button
2543
2543
  class="clear-btn"
@@ -2562,7 +2562,7 @@
2562
2562
  />
2563
2563
  </div>
2564
2564
  </div>
2565
- `}_renderFieldControl(t){switch(this._getUIType(t)){case"text":return this._renderTextFilter(t);case"number":return this._renderNumberFilter(t);case"boolean":return this._renderBooleanFilter(t);case"select-one":return this._renderSelectOneFilter(t);case"multi-select":return this._renderMultiSelectFilter(t);case"tags":return this._renderTagsFilter(t);case"date":return this._renderDateFilter(t);case"geo":return this._renderGeoFilter(t);case"attachment":return t.type===w.INTEGER_LIST&&t.slug==="face_matcher"?this._renderFaceMatcherFilter(t):this._renderAttachmentFilter(t);default:return r.nothing}}_renderFieldSection(t){const e=this._getField(t);if(!e)return r.nothing;const s=this._collapsedFields.has(t);return r.html`
2565
+ `}_renderFieldControl(t){switch(this._getUIType(t)){case"text":return this._renderTextFilter(t);case"number":return this._renderNumberFilter(t);case"boolean":return this._renderBooleanFilter(t);case"select-one":return this._renderSelectOneFilter(t);case"multi-select":return this._renderMultiSelectFilter(t);case"tags":return this._renderTagsFilter(t);case"date":return this._renderDateFilter(t);case"geo":return this._renderGeoFilter(t);case"attachment":return t.type===$.INTEGER_LIST&&t.slug==="face_matcher"?this._renderFaceMatcherFilter(t):this._renderAttachmentFilter(t);default:return r.nothing}}_renderFieldSection(t){const e=this._getField(t);if(!e)return r.nothing;const s=this._collapsedFields.has(t);return r.html`
2566
2566
  <div class="field-section">
2567
2567
  <div
2568
2568
  class="field-header"
@@ -2593,10 +2593,10 @@
2593
2593
  </div>
2594
2594
  `}_renderSelectorMode(){const t=this._fieldSearch.toLowerCase(),e=this.fields.filter(a=>a.label.toLowerCase().includes(t)),s=this._getGroupedFields(e),i=(a,o)=>o.length===0?r.nothing:r.html`
2595
2595
  <div class="field-group-label">${a}</div>
2596
- ${o.map(n=>{const c=F(n),d=this.visibleFields.includes(c),h=!!this.appliedMetadata[c]||!!this.appliedFilters[c],u=this.pinnedFields.includes(c),f=!d&&this._atFieldLimit;return r.html`
2596
+ ${o.map(n=>{const c=A(n),d=this.visibleFields.includes(c),h=!!this.appliedMetadata[c]||!!this.appliedFilters[c],u=this.pinnedFields.includes(c),g=!d&&this._atFieldLimit;return r.html`
2597
2597
  <div
2598
- class="field-item ${h?"has-filter":""} ${f?"disabled":""}"
2599
- @click=${()=>!f&&this._emitFieldSelect(n)}
2598
+ class="field-item ${h?"has-filter":""} ${g?"disabled":""}"
2599
+ @click=${()=>!g&&this._emitFieldSelect(n)}
2600
2600
  >
2601
2601
  <ap-icon name=${It[n.type]||"file-text"} .size=${14} style="color: var(--ap-muted-foreground, oklch(0.685 0.033 249.82))"></ap-icon>
2602
2602
  <span class="field-item-label">${n.label}</span>
@@ -3209,7 +3209,7 @@
3209
3209
  .mt-12 {
3210
3210
  margin-top: 12px;
3211
3211
  }
3212
- `];me([l.property({type:Array})],le.prototype,"selectedStatus",2);me([l.property()],le.prototype,"statusOperator",2);me([l.property()],le.prototype,"approverValue",2);me([l.property()],le.prototype,"approverOperator",2);me([l.property()],le.prototype,"requesterValue",2);me([l.property()],le.prototype,"requesterOperator",2);me([l.property()],le.prototype,"dueDatePreset",2);me([l.property()],le.prototype,"dueDateFrom",2);me([l.property()],le.prototype,"dueDateTo",2);le=me([l.customElement("ap-filter-approval")],le);var Yo=Object.defineProperty,Wo=Object.getOwnPropertyDescriptor,be=(t,e,s,i)=>{for(var a=i>1?void 0:i?Wo(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Yo(e,s,a),a};const Xo=300;function Zo(t){return t.filter(e=>e.toLowerCase().includes("*")||!t.some(s=>s.toLowerCase().includes("*")&&e.toLowerCase().startsWith(s.slice(0,-1).toLowerCase())))}let ce=class extends r.LitElement{constructor(){super(...arguments),this.selected=[],this._search="",this._debouncedSearch="",this._products=[],this._isLoading=!1,this._showAddList=!1,this._addListText=""}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{var t;return(t=this._searchInput)==null?void 0:t.focus()})}disconnectedCallback(){super.disconnectedCallback(),this._debounceTimer&&clearTimeout(this._debounceTimer)}get _isSearching(){return this._debouncedSearch.length>0}_emit(t){const e=Zo(t);this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:b.PRODUCT_REF,values:e,operator:S.IS},bubbles:!0,composed:!0}))}_toggle(t){const s=this.selected.includes(t)?this.selected.filter(i=>i!==t):[...this.selected,t];this._emit(s)}_remove(t){this._emit(this.selected.filter(e=>e!==t))}_clearAll(){this._emit([]),this._search="",this._debouncedSearch="",this._products=[]}_onSearchInput(t){const e=t.target.value;this._search=e,this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{const s=e.trim().toLowerCase();this._debouncedSearch=s,s?this._fetchProducts(s):(this._products=[],this._isLoading=!1)},Xo)}_clearSearch(){this._search="",this._debouncedSearch="",this._products=[],this._isLoading=!1,this._debounceTimer&&clearTimeout(this._debounceTimer)}async _fetchProducts(t){if(this.apiClient){this._isLoading=!0;try{const e=await this.apiClient.request("/products",{q:`reference~^${t}`});this._debouncedSearch===t&&(this._products=e.products??[])}catch{this._debouncedSearch===t&&(this._products=[])}finally{this._debouncedSearch===t&&(this._isLoading=!1)}}}_openAddList(){this._showAddList=!0,this._addListText=""}_closeAddList(){this._showAddList=!1,this._addListText=""}_onAddListInput(t){this._addListText=t.target.value}_onAddListKeydown(t){t.key==="Enter"&&!t.shiftKey&&t.stopPropagation()}_submitAddList(){const t=this._addListText.split(`
3212
+ `];me([l.property({type:Array})],le.prototype,"selectedStatus",2);me([l.property()],le.prototype,"statusOperator",2);me([l.property()],le.prototype,"approverValue",2);me([l.property()],le.prototype,"approverOperator",2);me([l.property()],le.prototype,"requesterValue",2);me([l.property()],le.prototype,"requesterOperator",2);me([l.property()],le.prototype,"dueDatePreset",2);me([l.property()],le.prototype,"dueDateFrom",2);me([l.property()],le.prototype,"dueDateTo",2);le=me([l.customElement("ap-filter-approval")],le);var Yo=Object.defineProperty,Wo=Object.getOwnPropertyDescriptor,be=(t,e,s,i)=>{for(var a=i>1?void 0:i?Wo(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Yo(e,s,a),a};const Xo=300;function Zo(t){return t.filter(e=>e.toLowerCase().includes("*")||!t.some(s=>s.toLowerCase().includes("*")&&e.toLowerCase().startsWith(s.slice(0,-1).toLowerCase())))}let ce=class extends r.LitElement{constructor(){super(...arguments),this.selected=[],this._search="",this._debouncedSearch="",this._products=[],this._isLoading=!1,this._showAddList=!1,this._addListText=""}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{var t;return(t=this._searchInput)==null?void 0:t.focus()})}disconnectedCallback(){super.disconnectedCallback(),this._debounceTimer&&clearTimeout(this._debounceTimer)}get _isSearching(){return this._debouncedSearch.length>0}_emit(t){const e=Zo(t);this.dispatchEvent(new CustomEvent("filter-change",{detail:{key:b.PRODUCT_REF,values:e,operator:C.IS},bubbles:!0,composed:!0}))}_toggle(t){const s=this.selected.includes(t)?this.selected.filter(i=>i!==t):[...this.selected,t];this._emit(s)}_remove(t){this._emit(this.selected.filter(e=>e!==t))}_clearAll(){this._emit([]),this._search="",this._debouncedSearch="",this._products=[]}_onSearchInput(t){const e=t.target.value;this._search=e,this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{const s=e.trim().toLowerCase();this._debouncedSearch=s,s?this._fetchProducts(s):(this._products=[],this._isLoading=!1)},Xo)}_clearSearch(){this._search="",this._debouncedSearch="",this._products=[],this._isLoading=!1,this._debounceTimer&&clearTimeout(this._debounceTimer)}async _fetchProducts(t){if(this.apiClient){this._isLoading=!0;try{const e=await this.apiClient.request("/products",{q:`reference~^${t}`});this._debouncedSearch===t&&(this._products=e.products??[])}catch{this._debouncedSearch===t&&(this._products=[])}finally{this._debouncedSearch===t&&(this._isLoading=!1)}}}_openAddList(){this._showAddList=!0,this._addListText=""}_closeAddList(){this._showAddList=!1,this._addListText=""}_onAddListInput(t){this._addListText=t.target.value}_onAddListKeydown(t){t.key==="Enter"&&!t.shiftKey&&t.stopPropagation()}_submitAddList(){const t=this._addListText.split(`
3213
3213
  `).map(e=>e.trim()).filter(e=>e!=="");if(t.length>0){const e=new Set(this.selected),s=[...this.selected,...t.filter(i=>!e.has(i))];this._emit(s)}this._closeAddList()}_renderProductItem(t){const e=this.selected.includes(t);return r.html`
3214
3214
  <div
3215
3215
  class="product-item"
@@ -3575,7 +3575,7 @@
3575
3575
  color: var(--ap-muted-foreground, oklch(0.685 0.033 249.82));
3576
3576
  margin-left: 4px;
3577
3577
  }
3578
- `];be([l.property({type:Array})],ce.prototype,"selected",2);be([l.property({attribute:!1})],ce.prototype,"apiClient",2);be([l.query(".product-search")],ce.prototype,"_searchInput",2);be([l.state()],ce.prototype,"_search",2);be([l.state()],ce.prototype,"_debouncedSearch",2);be([l.state()],ce.prototype,"_products",2);be([l.state()],ce.prototype,"_isLoading",2);be([l.state()],ce.prototype,"_showAddList",2);be([l.state()],ce.prototype,"_addListText",2);ce=be([l.customElement("ap-filter-product-ref")],ce);var Jo=Object.defineProperty,er=Object.getOwnPropertyDescriptor,L=(t,e,s,i)=>{for(var a=i>1?void 0:i?er(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Jo(e,s,a),a};let T=class extends r.LitElement{constructor(){super(...arguments),this.totalCount=0,this.totalFolderCount=0,this.isLoading=!1,this.showUpload=!1,this.showFilters=!0,this.countLabel="",this.sortBy="created_at",this.sortDirection="desc",this.sortOptions=ms,this.filters={metadata:{pinned:[],visible:[],applied:{}},pinned:[],visible:[],applied:{}},this.labels=[],this.tags=[],this.fileTypes=[],this.metadataFields=[],this.pinnedFilters=[],this.forcedFilterKeys=[],this._showDropdown=!1,this._showMetadataSelector=!1,this._openFilter=null,this._openMetadataField=null,this._externalTrigger=!1,this._externalLeft=null,this._externalTop=null,this._outsideClickHandler=t=>{const e=t.composedPath();if(this._externalTrigger&&e.some(o=>{var n;return o instanceof HTMLElement&&o.classList.contains("chip")&&((n=o.closest)==null?void 0:n.call(o,"ap-filters-bar"))}))return;const s=this._openFilter&&e.some(a=>a instanceof HTMLElement?a.classList.contains("popover-anchor")||a.classList.contains("popover-panel"):!1),i=(this._showDropdown||this._showMetadataSelector)&&e.some(a=>a instanceof HTMLElement&&(a.classList.contains("dropdown-menu")||a.classList.contains("filter-dropdown")||a.classList.contains("metadata-selector-overlay")));s||i||(this._openFilter&&(this._openFilter=null,this._openMetadataField=null,this._externalTrigger=!1,this._externalLeft=null,this._externalTop=null),(this._showDropdown||this._showMetadataSelector)&&(this._showDropdown=!1,this._showMetadataSelector=!1))}}connectedCallback(){super.connectedCallback(),document.addEventListener("mousedown",this._outsideClickHandler)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("mousedown",this._outsideClickHandler)}updated(t){if((t.has("_openFilter")||t.has("_externalTrigger")||t.has("_openMetadataField"))&&this.dispatchEvent(new CustomEvent("filter-panel-change",{detail:{key:this._externalTrigger?this._openFilter:null,metadataFieldKey:this._externalTrigger?this._openMetadataField:null},bubbles:!0,composed:!0})),this._externalTrigger&&this._externalLeft!=null&&(t.has("_openFilter")||t.has("_externalLeft")||t.has("_openMetadataField"))){const e=this.renderRoot.querySelector(".popover-panel");if(e){const s=e.closest(".popover-anchor"),i=s?s.offsetWidth:this.offsetWidth,a=e.offsetWidth;this._externalLeft+a>i-8&&(e.style.left=`${Math.max(8,i-a-8)}px`)}}}_closeAllDropdowns(){var t;this._showDropdown=!1,this._showMetadataSelector=!1,this._openFilter=null,this._openMetadataField=null,this._externalTrigger=!1,this._externalLeft=null,this._externalTop=null,(t=this._sortDropdown)==null||t.close()}_handleUploadClick(){this.dispatchEvent(new CustomEvent("upload-click",{bubbles:!0,composed:!0}))}_toggleDropdown(){const t=this._showDropdown;this._closeAllDropdowns(),this._showDropdown=!t}_toggleMetadataSelector(){this._showMetadataSelector=!this._showMetadataSelector}closeFilterPanel(){this._openFilter=null,this._openMetadataField=null,this._externalTrigger=!1,this._externalLeft=null,this._externalTop=null}openFilterPanel(t,e=!1,s,i){if(e&&this._externalTrigger&&this._openFilter===t&&!this._openMetadataField){this.closeFilterPanel();return}if(!e&&!this._isFilterActive(t)){this._showDropdown=!1,this._showMetadataSelector=!1,this.dispatchEvent(new CustomEvent("filter-pending",{detail:{key:t},bubbles:!0,composed:!0}));return}this._showDropdown=!1,this._showMetadataSelector=!1,this._openFilter=t,this._openMetadataField=null,this._externalTrigger=e,this._externalLeft=s??null,this._externalTop=i??null}_handleSortOpen(){this._showDropdown=!1,this._showMetadataSelector=!1,this._openFilter=null,this._openMetadataField=null,this._externalTrigger=!1,this._externalLeft=null,this._externalTop=null}_handleSort(t){this.dispatchEvent(new CustomEvent("sort-change",{detail:t.detail,bubbles:!0,composed:!0}))}_toggleSortDirection(){const t=this.sortDirection==="asc"?"desc":"asc";this.dispatchEvent(new CustomEvent("sort-direction-change",{detail:{value:t},bubbles:!0,composed:!0}))}_isFilterActive(t){return t in this.filters.applied&&this.filters.applied[t]!==void 0}_handleFilterChange(t){t.stopPropagation();const{key:e,values:s,operator:i}=t.detail;this.dispatchEvent(new CustomEvent("filter-update",{detail:{key:e,values:s,operator:i},bubbles:!0,composed:!0}))}_handleMetadataFilterChange(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("metadata-filter-change",{detail:t.detail,bubbles:!0,composed:!0}))}_handleMetadataFieldToggle(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("metadata-field-toggle",{detail:t.detail,bubbles:!0,composed:!0}))}_handleMetadataFieldSelect(t){t.stopPropagation(),this._openMetadataField=t.detail.fieldKey}_handleMetadataSelectorFieldSelect(t){var s;t.stopPropagation();const e=t.detail.fieldKey;if(this._showMetadataSelector=!1,this._showDropdown=!1,!(e in(((s=this.filters.metadata)==null?void 0:s.applied)||{}))){this.dispatchEvent(new CustomEvent("filter-pending",{detail:{metadataFieldKey:e},bubbles:!0,composed:!0}));return}this._openFilter="metadata",this._openMetadataField=e}_handleMetadataPin(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("metadata-pin",{detail:t.detail,bubbles:!0,composed:!0}))}openMetadataFieldPanel(t,e=!1,s,i){if(e&&this._externalTrigger&&this._openMetadataField===t){this.closeFilterPanel();return}this._showDropdown=!1,this._showMetadataSelector=!1,this._openFilter="metadata",this._openMetadataField=t,this._externalTrigger=e,this._externalLeft=s??null,this._externalTop=i??null}_getMetadataFieldLabel(t){for(const e of this.metadataFields)if(`${Gt[e.type]||""}${e.key}`===t)return e.label;return t}_togglePin(t,e){e.stopPropagation();const s=this.pinnedFilters.includes(t);this.dispatchEvent(new CustomEvent("filter-pin",{detail:{key:t,pinned:!s},bubbles:!0,composed:!0}))}_getFilterIcon(t){const e=ds.find(s=>s.key===t);return(e==null?void 0:e.icon)||"filter"}_renderFilterContent(t){var s,i,a;const e=this.filters.applied;switch(t){case"type":{const o=e.type;return r.html`<ap-filter-type
3578
+ `];be([l.property({type:Array})],ce.prototype,"selected",2);be([l.property({attribute:!1})],ce.prototype,"apiClient",2);be([l.query(".product-search")],ce.prototype,"_searchInput",2);be([l.state()],ce.prototype,"_search",2);be([l.state()],ce.prototype,"_debouncedSearch",2);be([l.state()],ce.prototype,"_products",2);be([l.state()],ce.prototype,"_isLoading",2);be([l.state()],ce.prototype,"_showAddList",2);be([l.state()],ce.prototype,"_addListText",2);ce=be([l.customElement("ap-filter-product-ref")],ce);var Jo=Object.defineProperty,er=Object.getOwnPropertyDescriptor,O=(t,e,s,i)=>{for(var a=i>1?void 0:i?er(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Jo(e,s,a),a};let L=class extends r.LitElement{constructor(){super(...arguments),this.totalCount=0,this.totalFolderCount=0,this.isLoading=!1,this.showUpload=!1,this.showFilters=!0,this.countLabel="",this.sortBy="created_at",this.sortDirection="desc",this.sortOptions=ms,this.filters={metadata:{pinned:[],visible:[],applied:{}},pinned:[],visible:[],applied:{}},this.labels=[],this.tags=[],this.fileTypes=[],this.metadataFields=[],this.pinnedFilters=[],this.forcedFilterKeys=[],this._showDropdown=!1,this._showMetadataSelector=!1,this._openFilter=null,this._openMetadataField=null,this._externalTrigger=!1,this._externalLeft=null,this._externalTop=null,this._outsideClickHandler=t=>{const e=t.composedPath();if(this._externalTrigger&&e.some(o=>{var n;return o instanceof HTMLElement&&o.classList.contains("chip")&&((n=o.closest)==null?void 0:n.call(o,"ap-filters-bar"))}))return;const s=this._openFilter&&e.some(a=>a instanceof HTMLElement?a.classList.contains("popover-anchor")||a.classList.contains("popover-panel"):!1),i=(this._showDropdown||this._showMetadataSelector)&&e.some(a=>a instanceof HTMLElement&&(a.classList.contains("dropdown-menu")||a.classList.contains("filter-dropdown")||a.classList.contains("metadata-selector-overlay")));s||i||(this._openFilter&&(this._openFilter=null,this._openMetadataField=null,this._externalTrigger=!1,this._externalLeft=null,this._externalTop=null),(this._showDropdown||this._showMetadataSelector)&&(this._showDropdown=!1,this._showMetadataSelector=!1))}}connectedCallback(){super.connectedCallback(),document.addEventListener("mousedown",this._outsideClickHandler)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("mousedown",this._outsideClickHandler)}updated(t){if((t.has("_openFilter")||t.has("_externalTrigger")||t.has("_openMetadataField"))&&this.dispatchEvent(new CustomEvent("filter-panel-change",{detail:{key:this._externalTrigger?this._openFilter:null,metadataFieldKey:this._externalTrigger?this._openMetadataField:null},bubbles:!0,composed:!0})),this._externalTrigger&&this._externalLeft!=null&&(t.has("_openFilter")||t.has("_externalLeft")||t.has("_openMetadataField"))){const e=this.renderRoot.querySelector(".popover-panel");if(e){const s=e.closest(".popover-anchor"),i=s?s.offsetWidth:this.offsetWidth,a=e.offsetWidth;this._externalLeft+a>i-8&&(e.style.left=`${Math.max(8,i-a-8)}px`)}}}_closeAllDropdowns(){var t;this._showDropdown=!1,this._showMetadataSelector=!1,this._openFilter=null,this._openMetadataField=null,this._externalTrigger=!1,this._externalLeft=null,this._externalTop=null,(t=this._sortDropdown)==null||t.close()}_handleUploadClick(){this.dispatchEvent(new CustomEvent("upload-click",{bubbles:!0,composed:!0}))}_toggleDropdown(){const t=this._showDropdown;this._closeAllDropdowns(),this._showDropdown=!t}_toggleMetadataSelector(){this._showMetadataSelector=!this._showMetadataSelector}closeFilterPanel(){this._openFilter=null,this._openMetadataField=null,this._externalTrigger=!1,this._externalLeft=null,this._externalTop=null}openFilterPanel(t,e=!1,s,i){if(e&&this._externalTrigger&&this._openFilter===t&&!this._openMetadataField){this.closeFilterPanel();return}if(!e&&!this._isFilterActive(t)){this._showDropdown=!1,this._showMetadataSelector=!1,this.dispatchEvent(new CustomEvent("filter-pending",{detail:{key:t},bubbles:!0,composed:!0}));return}this._showDropdown=!1,this._showMetadataSelector=!1,this._openFilter=t,this._openMetadataField=null,this._externalTrigger=e,this._externalLeft=s??null,this._externalTop=i??null}_handleSortOpen(){this._showDropdown=!1,this._showMetadataSelector=!1,this._openFilter=null,this._openMetadataField=null,this._externalTrigger=!1,this._externalLeft=null,this._externalTop=null}_handleSort(t){this.dispatchEvent(new CustomEvent("sort-change",{detail:t.detail,bubbles:!0,composed:!0}))}_toggleSortDirection(){const t=this.sortDirection==="asc"?"desc":"asc";this.dispatchEvent(new CustomEvent("sort-direction-change",{detail:{value:t},bubbles:!0,composed:!0}))}_isFilterActive(t){return t in this.filters.applied&&this.filters.applied[t]!==void 0}_handleFilterChange(t){t.stopPropagation();const{key:e,values:s,operator:i}=t.detail;this.dispatchEvent(new CustomEvent("filter-update",{detail:{key:e,values:s,operator:i},bubbles:!0,composed:!0}))}_handleMetadataFilterChange(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("metadata-filter-change",{detail:t.detail,bubbles:!0,composed:!0}))}_handleMetadataFieldToggle(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("metadata-field-toggle",{detail:t.detail,bubbles:!0,composed:!0}))}_handleMetadataFieldSelect(t){t.stopPropagation(),this._openMetadataField=t.detail.fieldKey}_handleMetadataSelectorFieldSelect(t){var s;t.stopPropagation();const e=t.detail.fieldKey;if(this._showMetadataSelector=!1,this._showDropdown=!1,!(e in(((s=this.filters.metadata)==null?void 0:s.applied)||{}))){this.dispatchEvent(new CustomEvent("filter-pending",{detail:{metadataFieldKey:e},bubbles:!0,composed:!0}));return}this._openFilter="metadata",this._openMetadataField=e}_handleMetadataPin(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("metadata-pin",{detail:t.detail,bubbles:!0,composed:!0}))}openMetadataFieldPanel(t,e=!1,s,i){if(e&&this._externalTrigger&&this._openMetadataField===t){this.closeFilterPanel();return}this._showDropdown=!1,this._showMetadataSelector=!1,this._openFilter="metadata",this._openMetadataField=t,this._externalTrigger=e,this._externalLeft=s??null,this._externalTop=i??null}_getMetadataFieldLabel(t){for(const e of this.metadataFields)if(`${Gt[e.type]||""}${e.key}`===t)return e.label;return t}_togglePin(t,e){e.stopPropagation();const s=this.pinnedFilters.includes(t);this.dispatchEvent(new CustomEvent("filter-pin",{detail:{key:t,pinned:!s},bubbles:!0,composed:!0}))}_getFilterIcon(t){const e=ds.find(s=>s.key===t);return(e==null?void 0:e.icon)||"filter"}_renderFilterContent(t){var s,i,a;const e=this.filters.applied;switch(t){case"type":{const o=e.type;return r.html`<ap-filter-type
3579
3579
  .selected=${(o==null?void 0:o.values)||[]}
3580
3580
  .fileTypes=${this.fileTypes}
3581
3581
  @filter-change=${this._handleFilterChange}
@@ -3756,7 +3756,7 @@
3756
3756
  </div>
3757
3757
  </div>
3758
3758
  `:r.nothing}
3759
- `}};T.styles=r.css`
3759
+ `}};L.styles=r.css`
3760
3760
  :host {
3761
3761
  display: block;
3762
3762
  padding: 8px 20px 6px;
@@ -4094,7 +4094,7 @@
4094
4094
  border-radius: 8px;
4095
4095
  top: 0;
4096
4096
  }
4097
- `;L([l.property({type:Number})],T.prototype,"totalCount",2);L([l.property({type:Number})],T.prototype,"totalFolderCount",2);L([l.property({type:Boolean})],T.prototype,"isLoading",2);L([l.property({type:Boolean})],T.prototype,"showUpload",2);L([l.property({type:Boolean})],T.prototype,"showFilters",2);L([l.property()],T.prototype,"countLabel",2);L([l.property()],T.prototype,"sortBy",2);L([l.property()],T.prototype,"sortDirection",2);L([l.property({type:Array})],T.prototype,"sortOptions",2);L([l.property({type:Object})],T.prototype,"filters",2);L([l.property({type:Array})],T.prototype,"labels",2);L([l.property({type:Array})],T.prototype,"tags",2);L([l.property({type:Array})],T.prototype,"fileTypes",2);L([l.property({type:Array})],T.prototype,"metadataFields",2);L([l.property({type:Array})],T.prototype,"pinnedFilters",2);L([l.property({type:Array})],T.prototype,"forcedFilterKeys",2);L([l.property({attribute:!1})],T.prototype,"apiClient",2);L([l.query("ap-dropdown")],T.prototype,"_sortDropdown",2);L([l.state()],T.prototype,"_showDropdown",2);L([l.state()],T.prototype,"_showMetadataSelector",2);L([l.state()],T.prototype,"_openFilter",2);L([l.state()],T.prototype,"_openMetadataField",2);L([l.state()],T.prototype,"_externalTrigger",2);L([l.state()],T.prototype,"_externalLeft",2);L([l.state()],T.prototype,"_externalTop",2);T=L([l.customElement("ap-content-toolbar")],T);var tr=Object.defineProperty,sr=Object.getOwnPropertyDescriptor,se=(t,e,s,i)=>{for(var a=i>1?void 0:i?sr(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&tr(e,s,a),a};let q=class extends r.LitElement{constructor(){super(...arguments),this.appliedFilters={},this.appliedMetadata={},this.forcedFilters={},this.metadataFields=[],this.pinnedFilters=[],this.pinnedMetadataFields=[],this.tags=[],this.labels=[],this.activeFilter=null,this.activeMetadataField=null,this.pendingFilter=null,this.pendingMetadataField=null}_mapTypeLabel(t){var i;const e=(i=Rt.find(a=>a.value===t))==null?void 0:i.label;if(e)return e;const s=t.indexOf("_");return s!==-1?t.slice(s+1).toUpperCase():t}_getSizeSummary(t){if(t.values.length===0)return"";const e=t.values[0],[s,i]=e.split(".."),a=s?parseFloat(s):null,o=i?parseFloat(i):null,n=c=>c>=1e3?`${(c/1e3).toFixed(c%1e3===0?0:1)} GB`:`${c} MB`;return a!==null&&o!==null?`${n(a)} – ${n(o)}`:a!==null?`> ${n(a)}`:o!==null?`< ${n(o)}`:""}_getFilterSummary(t,e){if(t.type==="string"){const s=t;if(s.values.length===0)return"";if(e===b.SIZE)return this._getSizeSummary(s);if(e===b.COLOR){const a=s.values.map(o=>o.split(" ")[0]).filter(Boolean);return a.length===0?"":a.length===1?a[0]:`${a[0]} +${a.length-1}`}const i=e===b.TYPE?a=>this._mapTypeLabel(a):e===b.TAGS?a=>{var o;return((o=this.tags.find(n=>n.sid===a))==null?void 0:o.label)||a}:e===b.LABELS?a=>{var o;return((o=this.labels.find(n=>n.sid===a))==null?void 0:o.name)||a}:a=>a;return s.values.length===1?i(s.values[0]):`${i(s.values[0])} +${s.values.length-1}`}if(t.type==="date")return this._getDateSummary(t);if(typeof t=="object"&&"resolution"in t){const s=t,i=[...s.resolution,...s.orientation,...s.faces];return i.length===0?"":i.length===1?i[0]:`${i[0]} +${i.length-1}`}return""}_getDateSummary(t){var n,c;const e=((n=di.find(d=>d.value===t.field))==null?void 0:n.label)||t.field,s=[...vs,...pi],i=t.preset?((c=s.find(d=>d.value===t.preset))==null?void 0:c.label)||t.preset:"",a=d=>{try{return d.split("T")[0]}catch{return d}};let o="";switch(t.kind){case"preset":o=i;break;case"before":o=t.to?`Before ${a(t.to)}`:i;break;case"after":o=t.from?`After ${a(t.from)}`:i;break;case"between":t.from&&t.to?o=`${a(t.from)} – ${a(t.to)}`:t.from?o=`After ${a(t.from)}`:t.to&&(o=`Before ${a(t.to)}`);break;case"specific":o=t.from?a(t.from):"";break;default:o=i}return o?`${e}: ${o}`:""}_getFilterIcon(t){var e;return((e=ds.find(s=>s.key===t))==null?void 0:e.icon)||"filter"}_getMetadataLabel(t){const e=this._stripMetadataPrefix(t),s=this.metadataFields.find(i=>i.key===e);return(s==null?void 0:s.label)||e}_getMetadataIcon(t){const e=this._stripMetadataPrefix(t),s=this.metadataFields.find(i=>i.key===e);return s&&It[s.type]||"file-text"}_stripMetadataPrefix(t){for(const e of ri)if(t.startsWith(e))return t.slice(e.length);return t}_removeFilter(t){this.dispatchEvent(new CustomEvent("filter-remove",{detail:{key:t},bubbles:!0,composed:!0}))}_removeMetadataFilter(t){this.dispatchEvent(new CustomEvent("metadata-filter-remove",{detail:{fieldKey:t},bubbles:!0,composed:!0}))}_clearAll(){this.dispatchEvent(new CustomEvent("filters-clear-all",{bubbles:!0,composed:!0}))}_openFilter(t,e){const i=e.currentTarget.getBoundingClientRect();this.dispatchEvent(new CustomEvent("filter-open",{detail:{key:t,chipRect:{left:i.left,right:i.right,bottom:i.bottom,width:i.width}},bubbles:!0,composed:!0}))}_openMetadataFilter(t,e){const i=e.currentTarget.getBoundingClientRect();this.dispatchEvent(new CustomEvent("metadata-filter-open",{detail:{fieldKey:t,chipRect:{left:i.left,right:i.right,bottom:i.bottom,width:i.width}},bubbles:!0,composed:!0}))}_renderForcedChip(t,e){const s=this._getFilterSummary(e,t),i=e.type==="date";return r.html`
4097
+ `;O([l.property({type:Number})],L.prototype,"totalCount",2);O([l.property({type:Number})],L.prototype,"totalFolderCount",2);O([l.property({type:Boolean})],L.prototype,"isLoading",2);O([l.property({type:Boolean})],L.prototype,"showUpload",2);O([l.property({type:Boolean})],L.prototype,"showFilters",2);O([l.property()],L.prototype,"countLabel",2);O([l.property()],L.prototype,"sortBy",2);O([l.property()],L.prototype,"sortDirection",2);O([l.property({type:Array})],L.prototype,"sortOptions",2);O([l.property({type:Object})],L.prototype,"filters",2);O([l.property({type:Array})],L.prototype,"labels",2);O([l.property({type:Array})],L.prototype,"tags",2);O([l.property({type:Array})],L.prototype,"fileTypes",2);O([l.property({type:Array})],L.prototype,"metadataFields",2);O([l.property({type:Array})],L.prototype,"pinnedFilters",2);O([l.property({type:Array})],L.prototype,"forcedFilterKeys",2);O([l.property({attribute:!1})],L.prototype,"apiClient",2);O([l.query("ap-dropdown")],L.prototype,"_sortDropdown",2);O([l.state()],L.prototype,"_showDropdown",2);O([l.state()],L.prototype,"_showMetadataSelector",2);O([l.state()],L.prototype,"_openFilter",2);O([l.state()],L.prototype,"_openMetadataField",2);O([l.state()],L.prototype,"_externalTrigger",2);O([l.state()],L.prototype,"_externalLeft",2);O([l.state()],L.prototype,"_externalTop",2);L=O([l.customElement("ap-content-toolbar")],L);var tr=Object.defineProperty,sr=Object.getOwnPropertyDescriptor,se=(t,e,s,i)=>{for(var a=i>1?void 0:i?sr(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&tr(e,s,a),a};let q=class extends r.LitElement{constructor(){super(...arguments),this.appliedFilters={},this.appliedMetadata={},this.forcedFilters={},this.metadataFields=[],this.pinnedFilters=[],this.pinnedMetadataFields=[],this.tags=[],this.labels=[],this.activeFilter=null,this.activeMetadataField=null,this.pendingFilter=null,this.pendingMetadataField=null}_mapTypeLabel(t){var i;const e=(i=Rt.find(a=>a.value===t))==null?void 0:i.label;if(e)return e;const s=t.indexOf("_");return s!==-1?t.slice(s+1).toUpperCase():t}_getSizeSummary(t){if(t.values.length===0)return"";const e=t.values[0],[s,i]=e.split(".."),a=s?parseFloat(s):null,o=i?parseFloat(i):null,n=c=>c>=1e3?`${(c/1e3).toFixed(c%1e3===0?0:1)} GB`:`${c} MB`;return a!==null&&o!==null?`${n(a)} – ${n(o)}`:a!==null?`> ${n(a)}`:o!==null?`< ${n(o)}`:""}_getFilterSummary(t,e){if(t.type==="string"){const s=t;if(s.values.length===0)return"";if(e===b.SIZE)return this._getSizeSummary(s);if(e===b.COLOR){const a=s.values.map(o=>o.split(" ")[0]).filter(Boolean);return a.length===0?"":a.length===1?a[0]:`${a[0]} +${a.length-1}`}const i=e===b.TYPE?a=>this._mapTypeLabel(a):e===b.TAGS?a=>{var o;return((o=this.tags.find(n=>n.sid===a))==null?void 0:o.label)||a}:e===b.LABELS?a=>{var o;return((o=this.labels.find(n=>n.sid===a))==null?void 0:o.name)||a}:a=>a;return s.values.length===1?i(s.values[0]):`${i(s.values[0])} +${s.values.length-1}`}if(t.type==="date")return this._getDateSummary(t);if(typeof t=="object"&&"resolution"in t){const s=t,i=[...s.resolution,...s.orientation,...s.faces];return i.length===0?"":i.length===1?i[0]:`${i[0]} +${i.length-1}`}return""}_getDateSummary(t){var n,c;const e=((n=di.find(d=>d.value===t.field))==null?void 0:n.label)||t.field,s=[...vs,...pi],i=t.preset?((c=s.find(d=>d.value===t.preset))==null?void 0:c.label)||t.preset:"",a=d=>{try{return d.split("T")[0]}catch{return d}};let o="";switch(t.kind){case"preset":o=i;break;case"before":o=t.to?`Before ${a(t.to)}`:i;break;case"after":o=t.from?`After ${a(t.from)}`:i;break;case"between":t.from&&t.to?o=`${a(t.from)} – ${a(t.to)}`:t.from?o=`After ${a(t.from)}`:t.to&&(o=`Before ${a(t.to)}`);break;case"specific":o=t.from?a(t.from):"";break;default:o=i}return o?`${e}: ${o}`:""}_getFilterIcon(t){var e;return((e=ds.find(s=>s.key===t))==null?void 0:e.icon)||"filter"}_getMetadataLabel(t){const e=this._stripMetadataPrefix(t),s=this.metadataFields.find(i=>i.key===e);return(s==null?void 0:s.label)||e}_getMetadataIcon(t){const e=this._stripMetadataPrefix(t),s=this.metadataFields.find(i=>i.key===e);return s&&It[s.type]||"file-text"}_stripMetadataPrefix(t){for(const e of ri)if(t.startsWith(e))return t.slice(e.length);return t}_removeFilter(t){this.dispatchEvent(new CustomEvent("filter-remove",{detail:{key:t},bubbles:!0,composed:!0}))}_removeMetadataFilter(t){this.dispatchEvent(new CustomEvent("metadata-filter-remove",{detail:{fieldKey:t},bubbles:!0,composed:!0}))}_clearAll(){this.dispatchEvent(new CustomEvent("filters-clear-all",{bubbles:!0,composed:!0}))}_openFilter(t,e){const i=e.currentTarget.getBoundingClientRect();this.dispatchEvent(new CustomEvent("filter-open",{detail:{key:t,chipRect:{left:i.left,right:i.right,bottom:i.bottom,width:i.width}},bubbles:!0,composed:!0}))}_openMetadataFilter(t,e){const i=e.currentTarget.getBoundingClientRect();this.dispatchEvent(new CustomEvent("metadata-filter-open",{detail:{fieldKey:t,chipRect:{left:i.left,right:i.right,bottom:i.bottom,width:i.width}},bubbles:!0,composed:!0}))}_renderForcedChip(t,e){const s=this._getFilterSummary(e,t),i=e.type==="date";return r.html`
4098
4098
  <span class="chip forced">
4099
4099
  ${(i||t===b.TYPE||t===b.SIZE)&&s?r.html`<span class="chip-label">${s}</span>`:r.html`
4100
4100
  <span class="chip-label">${et[t]||t}</span>
@@ -4137,29 +4137,29 @@
4137
4137
  <ap-icon name="close" .size=${12}></ap-icon>
4138
4138
  </button>
4139
4139
  </span>
4140
- `}render(){const t=ps(this.forcedFilters),e=new Set(Object.keys(t)),s=Object.keys(this.appliedFilters).filter(g=>!e.has(g)),i=Object.keys(this.appliedMetadata),a=new Set(this.pinnedFilters),o=new Set(this.pinnedMetadataFields),n=this.pinnedFilters.filter(g=>!e.has(g)),c=s.filter(g=>!a.has(g)),d=i.filter(g=>!o.has(g)),h=this.pendingFilter&&!a.has(this.pendingFilter)&&!(this.pendingFilter in this.appliedFilters),u=this.pendingMetadataField&&!o.has(this.pendingMetadataField)&&!(this.pendingMetadataField in this.appliedMetadata),f=s.length+i.length>0;return e.size+n.length+this.pinnedMetadataFields.length+c.length+d.length+(h?1:0)+(u?1:0)===0?r.nothing:r.html`
4140
+ `}render(){const t=ps(this.forcedFilters),e=new Set(Object.keys(t)),s=Object.keys(this.appliedFilters).filter(f=>!e.has(f)),i=Object.keys(this.appliedMetadata),a=new Set(this.pinnedFilters),o=new Set(this.pinnedMetadataFields),n=this.pinnedFilters.filter(f=>!e.has(f)),c=s.filter(f=>!a.has(f)),d=i.filter(f=>!o.has(f)),h=this.pendingFilter&&!a.has(this.pendingFilter)&&!(this.pendingFilter in this.appliedFilters),u=this.pendingMetadataField&&!o.has(this.pendingMetadataField)&&!(this.pendingMetadataField in this.appliedMetadata),g=s.length+i.length>0;return e.size+n.length+this.pinnedMetadataFields.length+c.length+d.length+(h?1:0)+(u?1:0)===0?r.nothing:r.html`
4141
4141
  <div class="chips-row">
4142
4142
  <div class="chips">
4143
- ${[...e].map(g=>this._renderForcedChip(g,t[g]))}
4144
- ${n.map(g=>this._renderFilterChip(g,this.appliedFilters[g]))}
4145
- ${this.pinnedMetadataFields.map(g=>this._renderMetadataChip(g,this.appliedMetadata[g]))}
4146
- ${c.map(g=>this._renderFilterChip(g,this.appliedFilters[g]))}
4143
+ ${[...e].map(f=>this._renderForcedChip(f,t[f]))}
4144
+ ${n.map(f=>this._renderFilterChip(f,this.appliedFilters[f]))}
4145
+ ${this.pinnedMetadataFields.map(f=>this._renderMetadataChip(f,this.appliedMetadata[f]))}
4146
+ ${c.map(f=>this._renderFilterChip(f,this.appliedFilters[f]))}
4147
4147
  ${h?r.html`
4148
- <span class="chip pinned-empty active pending" @click=${g=>this._openFilter(this.pendingFilter,g)}>
4148
+ <span class="chip pinned-empty active pending" @click=${f=>this._openFilter(this.pendingFilter,f)}>
4149
4149
  <span class="chip-icon"><ap-icon name=${this._getFilterIcon(this.pendingFilter)} .size=${16}></ap-icon></span>
4150
4150
  <span class="chip-label">${et[this.pendingFilter]||this.pendingFilter}</span>
4151
4151
  <span class="chip-chevron"><ap-icon name="chevron-down" .size=${14}></ap-icon></span>
4152
4152
  </span>
4153
4153
  `:r.nothing}
4154
- ${d.map(g=>this._renderMetadataChip(g,this.appliedMetadata[g]))}
4154
+ ${d.map(f=>this._renderMetadataChip(f,this.appliedMetadata[f]))}
4155
4155
  ${u?r.html`
4156
- <span class="chip pinned-empty active pending" @click=${g=>this._openMetadataFilter(this.pendingMetadataField,g)}>
4156
+ <span class="chip pinned-empty active pending" @click=${f=>this._openMetadataFilter(this.pendingMetadataField,f)}>
4157
4157
  <span class="chip-icon"><ap-icon name=${this._getMetadataIcon(this.pendingMetadataField)} .size=${16}></ap-icon></span>
4158
4158
  <span class="chip-label">${this._getMetadataLabel(this.pendingMetadataField)}</span>
4159
4159
  <span class="chip-chevron"><ap-icon name="chevron-down" .size=${14}></ap-icon></span>
4160
4160
  </span>
4161
4161
  `:r.nothing}
4162
- ${f?r.html`<button class="clear-all" @click=${this._clearAll}>Clear filters</button>`:r.nothing}
4162
+ ${g?r.html`<button class="clear-all" @click=${this._clearAll}>Clear filters</button>`:r.nothing}
4163
4163
  </div>
4164
4164
  </div>
4165
4165
  `}};q.styles=r.css`
@@ -4546,22 +4546,22 @@
4546
4546
  @media (prefers-reduced-motion: reduce) {
4547
4547
  .ghost-el { animation: none; }
4548
4548
  }
4549
- `;pe([l.property({type:Array})],Q.prototype,"assets",2);pe([l.property({type:Array})],Q.prototype,"folders",2);pe([l.property({type:Array})],Q.prototype,"selectedIds",2);pe([l.property({type:Array})],Q.prototype,"selectedFolderIds",2);pe([l.property({type:Boolean})],Q.prototype,"isLoading",2);pe([l.property({type:Boolean})],Q.prototype,"multiSelect",2);pe([l.property({type:Boolean})],Q.prototype,"folderSelectable",2);pe([l.property({type:Number})],Q.prototype,"totalCount",2);pe([l.property({type:Boolean})],Q.prototype,"isSelectingAll",2);pe([l.property({type:Object})],Q.prototype,"folderPreviews",2);pe([l.state()],Q.prototype,"_compactLevel",2);Q=pe([l.customElement("ap-list-view")],Q);function xs(t){if(t===0)return"0 B";const e=["B","KB","MB","GB","TB"],s=1024,i=Math.floor(Math.log(t)/Math.log(s));return`${(t/Math.pow(s,i)).toFixed(i===0?0:1)} ${e[i]}`}function jt(t){if(!t)return"—";const e=new Date(t);return isNaN(e.getTime())?"—":e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function _i(t,e){return!t||!e?"":`${t} x ${e}`}var cr=Object.defineProperty,dr=Object.getOwnPropertyDescriptor,Ct=(t,e,s,i)=>{for(var a=i>1?void 0:i?dr(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&cr(e,s,a),a};let He=class extends r.LitElement{constructor(){super(...arguments),this.index=0,this.selected=!1,this.multiSelect=!0}_handleSelect(t){if(t.stopPropagation(),t.composedPath().some(i=>i instanceof HTMLElement&&(i.classList.contains("check")||i.classList.contains("check-box")))){this.dispatchEvent(new CustomEvent("asset-select",{detail:{asset:this.asset,index:this.index,event:new MouseEvent("click",{ctrlKey:!0,metaKey:!0,shiftKey:t.shiftKey})},bubbles:!0}));return}this.dispatchEvent(new CustomEvent("asset-select",{detail:{asset:this.asset,index:this.index,event:t},bubbles:!0}))}_handlePreview(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("asset-preview",{detail:{asset:this.asset},bubbles:!0}))}_formatDuration(t){const e=Math.floor(t/3600),s=Math.floor(t%3600/60),i=Math.floor(t%60),a=o=>String(o).padStart(2,"0");return e>0?`${e}:${a(s)}:${a(i)}`:`${a(s)}:${a(i)}`}_handleQuickSelect(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("asset-quick-select",{detail:{asset:this.asset},bubbles:!0}))}render(){var d,h,u,f,p;const t=this.asset;if(!t)return r.html``;const s=tt(t.type)==="video",i=((d=t.extension)==null?void 0:d.toLowerCase())==="pdf",a=si(t.extension||"");let o="";s?o=ai(t):i?o=gs(t):a&&(o=zt(t));const n=$t(t.extension||""),c=us(t.extension||"");return r.html`
4549
+ `;pe([l.property({type:Array})],Q.prototype,"assets",2);pe([l.property({type:Array})],Q.prototype,"folders",2);pe([l.property({type:Array})],Q.prototype,"selectedIds",2);pe([l.property({type:Array})],Q.prototype,"selectedFolderIds",2);pe([l.property({type:Boolean})],Q.prototype,"isLoading",2);pe([l.property({type:Boolean})],Q.prototype,"multiSelect",2);pe([l.property({type:Boolean})],Q.prototype,"folderSelectable",2);pe([l.property({type:Number})],Q.prototype,"totalCount",2);pe([l.property({type:Boolean})],Q.prototype,"isSelectingAll",2);pe([l.property({type:Object})],Q.prototype,"folderPreviews",2);pe([l.state()],Q.prototype,"_compactLevel",2);Q=pe([l.customElement("ap-list-view")],Q);function xs(t){if(t===0)return"0 B";const e=["B","KB","MB","GB","TB"],s=1024,i=Math.floor(Math.log(t)/Math.log(s));return`${(t/Math.pow(s,i)).toFixed(i===0?0:1)} ${e[i]}`}function jt(t){if(!t)return"—";const e=new Date(t);return isNaN(e.getTime())?"—":e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function _i(t,e){return!t||!e?"":`${t} x ${e}`}var cr=Object.defineProperty,dr=Object.getOwnPropertyDescriptor,Ct=(t,e,s,i)=>{for(var a=i>1?void 0:i?dr(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&cr(e,s,a),a};let He=class extends r.LitElement{constructor(){super(...arguments),this.index=0,this.selected=!1,this.multiSelect=!0}_handleSelect(t){if(t.stopPropagation(),t.composedPath().some(i=>i instanceof HTMLElement&&(i.classList.contains("check")||i.classList.contains("check-box")))){this.dispatchEvent(new CustomEvent("asset-select",{detail:{asset:this.asset,index:this.index,event:new MouseEvent("click",{ctrlKey:!0,metaKey:!0,shiftKey:t.shiftKey})},bubbles:!0}));return}this.dispatchEvent(new CustomEvent("asset-select",{detail:{asset:this.asset,index:this.index,event:t},bubbles:!0}))}_handlePreview(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("asset-preview",{detail:{asset:this.asset},bubbles:!0}))}_formatDuration(t){const e=Math.floor(t/3600),s=Math.floor(t%3600/60),i=Math.floor(t%60),a=o=>String(o).padStart(2,"0");return e>0?`${e}:${a(s)}:${a(i)}`:`${a(s)}:${a(i)}`}_handleQuickSelect(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("asset-quick-select",{detail:{asset:this.asset},bubbles:!0}))}render(){var h,u,g,p,f,m,x,_;const t=this.asset;if(!t)return r.html``;const s=tt(t.type)==="video",i=((h=t.extension)==null?void 0:h.toLowerCase())==="pdf",a=!!((u=t.info)!=null&&u.thumbnail||(g=t.info)!=null&&g.image_thumbnail||(p=t.info)!=null&&p.preview),o=si(t.extension||"")||a;let n="";s?n=ai(t):i?n=gs(t):o&&(n=zt(t));const c=$t(t.extension||""),d=us(t.extension||"");return r.html`
4550
4550
  <div class="card" @click=${this._handleSelect}>
4551
- <div class="thumbnail ${c&&o?"chess":""}">
4552
- ${o?r.html`<img
4553
- src=${o}
4551
+ <div class="thumbnail ${d&&n?"chess":""}">
4552
+ ${n?r.html`<img
4553
+ src=${n}
4554
4554
  alt=${t.name}
4555
4555
  loading="lazy"
4556
- class="thumb-img ${c?"transparent-asset":""}"
4557
- @error=${g=>{const m=g.target,_=st();m.src!==n&&m.src!==_?(m.src=n,m.classList.add("icon-fallback")):m.src!==_&&(m.src=_)}}
4556
+ class="thumb-img ${d?"transparent-asset":""}"
4557
+ @error=${w=>{const y=w.target,T=st();y.src!==c&&y.src!==T?(y.src=c,y.classList.add("icon-fallback")):y.src!==T&&(y.src=T)}}
4558
4558
  />`:r.html`<img
4559
- src=${n}
4559
+ src=${c}
4560
4560
  alt=${t.name}
4561
4561
  class="thumb-img icon-fallback"
4562
- @error=${g=>{const m=g.target,_=st();m.src!==_&&(m.src=_)}}
4562
+ @error=${w=>{const y=w.target,T=st();y.src!==T&&(y.src=T)}}
4563
4563
  />`}
4564
- ${s&&(((h=t.info)==null?void 0:h.video_duration)??((u=t.info)==null?void 0:u.duration))!=null?r.html`<span class="duration">${this._formatDuration(t.info.video_duration??t.info.duration)}</span>`:r.nothing}
4564
+ ${s&&(((f=t.info)==null?void 0:f.video_duration)??((m=t.info)==null?void 0:m.duration))!=null?r.html`<span class="duration">${this._formatDuration(t.info.video_duration??t.info.duration)}</span>`:r.nothing}
4565
4565
  <div class="overlay">
4566
4566
  <button class="overlay-btn" @click=${this._handlePreview} aria-label="Preview">
4567
4567
  <ap-icon name="preview" .size=${16}></ap-icon>
@@ -4584,7 +4584,7 @@
4584
4584
  </div>
4585
4585
  <div class="info">
4586
4586
  <div class="name" title=${t.name}>${t.name}</div>
4587
- <div class="meta">${(f=t.extension)==null?void 0:f.toUpperCase()}${(()=>{var y,C,x,M;const g=((y=t.info)==null?void 0:y.img_w)||((C=t.info)==null?void 0:C.video_w),m=((x=t.info)==null?void 0:x.img_h)||((M=t.info)==null?void 0:M.video_h),_=_i(g,m);return _?` · ${_}`:""})()} · ${xs(((p=t.size)==null?void 0:p.bytes)||0)}</div>
4587
+ <div class="meta">${(x=t.extension)==null?void 0:x.toUpperCase()}${(()=>{var k,S,F,E;const w=((k=t.info)==null?void 0:k.img_w)||((S=t.info)==null?void 0:S.video_w),y=((F=t.info)==null?void 0:F.img_h)||((E=t.info)==null?void 0:E.video_h),T=_i(w,y);return T?` · ${T}`:""})()} · ${xs(((_=t.size)==null?void 0:_.bytes)||0)}</div>
4588
4588
  </div>
4589
4589
  </div>
4590
4590
  `}};He.styles=r.css`
@@ -4766,7 +4766,7 @@
4766
4766
  :host { animation: none; }
4767
4767
  .overlay { transition: none; }
4768
4768
  }
4769
- `;Ct([l.property({type:Object})],He.prototype,"asset",2);Ct([l.property({type:Number})],He.prototype,"index",2);Ct([l.property({type:Boolean,reflect:!0})],He.prototype,"selected",2);Ct([l.property({type:Boolean})],He.prototype,"multiSelect",2);He=Ct([l.customElement("ap-asset-card")],He);var pr=Object.defineProperty,hr=Object.getOwnPropertyDescriptor,dt=(t,e,s,i)=>{for(var a=i>1?void 0:i?hr(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&pr(e,s,a),a};let Oe=class extends r.LitElement{constructor(){super(...arguments),this.index=0,this.selected=!1,this.multiSelect=!0,this.compactLevel=0}_getGridColumns(){const t=[];return this.multiSelect&&t.push("32px"),t.push("48px"),t.push("minmax(120px, 1fr)"),t.push("72px"),this.compactLevel<2&&t.push("100px"),this.compactLevel<1&&t.push("120px"),t.push("64px"),t.join(" ")}_handleSelect(t){if(t.composedPath().some(i=>i instanceof HTMLElement&&(i.classList.contains("check")||i.classList.contains("check-box")))){this.dispatchEvent(new CustomEvent("asset-select",{detail:{asset:this.asset,index:this.index,event:new MouseEvent("click",{ctrlKey:!0,metaKey:!0,shiftKey:t.shiftKey})},bubbles:!0}));return}this.dispatchEvent(new CustomEvent("asset-select",{detail:{asset:this.asset,index:this.index,event:t},bubbles:!0}))}_handlePreview(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("asset-preview",{detail:{asset:this.asset},bubbles:!0}))}_handleQuickSelect(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("asset-quick-select",{detail:{asset:this.asset},bubbles:!0}))}render(){var d,h,u;const t=this.asset;if(!t)return r.html``;const s=tt(t.type)==="video",i=((d=t.extension)==null?void 0:d.toLowerCase())==="pdf",a=si(t.extension||"");let o="";s?o=ai(t):i?o=gs(t):a&&(o=zt(t));const n=$t(t.extension||""),c=us(t.extension||"");return r.html`
4769
+ `;Ct([l.property({type:Object})],He.prototype,"asset",2);Ct([l.property({type:Number})],He.prototype,"index",2);Ct([l.property({type:Boolean,reflect:!0})],He.prototype,"selected",2);Ct([l.property({type:Boolean})],He.prototype,"multiSelect",2);He=Ct([l.customElement("ap-asset-card")],He);var pr=Object.defineProperty,hr=Object.getOwnPropertyDescriptor,dt=(t,e,s,i)=>{for(var a=i>1?void 0:i?hr(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&pr(e,s,a),a};let Oe=class extends r.LitElement{constructor(){super(...arguments),this.index=0,this.selected=!1,this.multiSelect=!0,this.compactLevel=0}_getGridColumns(){const t=[];return this.multiSelect&&t.push("32px"),t.push("48px"),t.push("minmax(120px, 1fr)"),t.push("72px"),this.compactLevel<2&&t.push("100px"),this.compactLevel<1&&t.push("120px"),t.push("64px"),t.join(" ")}_handleSelect(t){if(t.composedPath().some(i=>i instanceof HTMLElement&&(i.classList.contains("check")||i.classList.contains("check-box")))){this.dispatchEvent(new CustomEvent("asset-select",{detail:{asset:this.asset,index:this.index,event:new MouseEvent("click",{ctrlKey:!0,metaKey:!0,shiftKey:t.shiftKey})},bubbles:!0}));return}this.dispatchEvent(new CustomEvent("asset-select",{detail:{asset:this.asset,index:this.index,event:t},bubbles:!0}))}_handlePreview(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("asset-preview",{detail:{asset:this.asset},bubbles:!0}))}_handleQuickSelect(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("asset-quick-select",{detail:{asset:this.asset},bubbles:!0}))}render(){var h,u,g,p,f,m;const t=this.asset;if(!t)return r.html``;const s=tt(t.type)==="video",i=((h=t.extension)==null?void 0:h.toLowerCase())==="pdf",a=!!((u=t.info)!=null&&u.thumbnail||(g=t.info)!=null&&g.image_thumbnail||(p=t.info)!=null&&p.preview),o=si(t.extension||"")||a;let n="";s?n=ai(t):i?n=gs(t):o&&(n=zt(t));const c=$t(t.extension||""),d=us(t.extension||"");return r.html`
4770
4770
  <div class="row" style="grid-template-columns: ${this._getGridColumns()}" @click=${this._handleSelect}>
4771
4771
  ${this.multiSelect?r.html`
4772
4772
  <div class="check">
@@ -4777,23 +4777,23 @@
4777
4777
  </div>
4778
4778
  </div>
4779
4779
  `:r.nothing}
4780
- <div class="thumb ${c&&o?"chess":""}">
4781
- ${o?r.html`<img
4782
- src=${o}
4780
+ <div class="thumb ${d&&n?"chess":""}">
4781
+ ${n?r.html`<img
4782
+ src=${n}
4783
4783
  alt=${t.name}
4784
- class="${c?"transparent-asset":""}"
4784
+ class="${d?"transparent-asset":""}"
4785
4785
  loading="lazy"
4786
- @error=${f=>{const p=f.target,g=st();p.src!==n&&p.src!==g?(p.src=n,p.classList.add("icon-fallback")):p.src!==g&&(p.src=g)}}
4786
+ @error=${x=>{const _=x.target,w=st();_.src!==c&&_.src!==w?(_.src=c,_.classList.add("icon-fallback")):_.src!==w&&(_.src=w)}}
4787
4787
  />`:r.html`<img
4788
- src=${n}
4788
+ src=${c}
4789
4789
  alt=${t.name}
4790
4790
  class="icon-fallback"
4791
- @error=${f=>{const p=f.target,g=st();p.src!==g&&(p.src=g)}}
4791
+ @error=${x=>{const _=x.target,w=st();_.src!==w&&(_.src=w)}}
4792
4792
  />`}
4793
4793
  </div>
4794
4794
  <div class="name" title=${t.name}>${t.name}</div>
4795
- <div class="type">${(h=t.extension)==null?void 0:h.toUpperCase()}</div>
4796
- ${this.compactLevel<2?r.html`<div class="desc">${xs(((u=t.size)==null?void 0:u.bytes)||0)}</div>`:r.nothing}
4795
+ <div class="type">${(f=t.extension)==null?void 0:f.toUpperCase()}</div>
4796
+ ${this.compactLevel<2?r.html`<div class="desc">${xs(((m=t.size)==null?void 0:m.bytes)||0)}</div>`:r.nothing}
4797
4797
  ${this.compactLevel<1?r.html`<div class="date">${jt(t.created_at||"")}</div>`:r.nothing}
4798
4798
  <div class="actions">
4799
4799
  <button class="icon-btn select-btn" @click=${this._handleQuickSelect} aria-label="Select" title="Select">
@@ -5854,7 +5854,7 @@
5854
5854
  @media (prefers-reduced-motion: reduce) {
5855
5855
  .skeleton { animation: none; }
5856
5856
  }
5857
- `;Ft([l.property({reflect:!0})],Ge.prototype,"variant",2);Ft([l.property({type:String})],Ge.prototype,"gridSize",2);Ft([l.property({type:Boolean})],Ge.prototype,"multiSelect",2);Ft([l.property({type:Number})],Ge.prototype,"folderCount",2);Ge=Ft([l.customElement("ap-skeleton")],Ge);var Lr=Object.defineProperty,Or=Object.getOwnPropertyDescriptor,U=(t,e,s,i)=>{for(var a=i>1?void 0:i?Or(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Lr(e,s,a),a};let z=class extends r.LitElement{constructor(){super(...arguments),this.asset=null,this.assets=[],this.selectedIds=[],this.containerToken="",this.showMetadata=!0,this.metadataFields=[],this.labels=[],this.regionalFilters={},this.multiSelect=!0,this._isFullscreen=!1,this._fsImageLoaded=!1,this._previewLoading=!1,this._openSections=new Set(["file-info","metadata"]),this._hls=null}connectedCallback(){super.connectedCallback(),this._onFullscreenChange=this._onFullscreenChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),document.addEventListener("fullscreenchange",this._onFullscreenChange),document.addEventListener("keydown",this._onKeyDown)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("fullscreenchange",this._onFullscreenChange),document.removeEventListener("keydown",this._onKeyDown),this._destroyHls()}_onKeyDown(t){if(t.key!=="ArrowLeft"&&t.key!=="ArrowRight")return;const e=t.composedPath()[0];if(!e)return;const s=e.tagName;s==="INPUT"||s==="TEXTAREA"||s==="SELECT"||e.getAttribute("role")==="radio"||e.getAttribute("role")==="listbox"||e.isContentEditable||(t.preventDefault(),t.key==="ArrowLeft"?this._prev():this._next())}_destroyHls(){this._hls&&(this._hls.destroy(),this._hls=null)}updated(t){if(super.updated(t),t.has("asset")&&(this._destroyHls(),this._previewLoading=!0,this.asset)){const e=tt(this.asset.type);e==="video"&&this._setupHls(this.asset),e!=="image"&&e!=="video"&&(this._previewLoading=!1)}}async _setupHls(t){var i,a;const e=Vt(t);if(!e||(await this.updateComplete,((i=this.asset)==null?void 0:i.uuid)!==t.uuid))return;const s=this._videoEl;if(s){if(s.canPlayType("application/vnd.apple.mpegurl")){s.src=e;return}try{const{default:o}=await Promise.resolve().then(()=>require("./hls.light-C3NKRmfw.cjs"));if(!o.isSupported()||((a=this.asset)==null?void 0:a.uuid)!==t.uuid||!this.isConnected)return;const n=new o;this._hls=n,n.loadSource(e),n.attachMedia(s),n.on(o.Events.ERROR,(c,d)=>{var h;d.fatal&&(this._destroyHls(),s.src=((h=t.url)==null?void 0:h.cdn)||"")})}catch{}}}_onFullscreenChange(){this._isFullscreen=!!document.fullscreenElement,this._isFullscreen&&(this._fsImageLoaded=!1)}_close(){this.dispatchEvent(new CustomEvent("preview-close",{bubbles:!0,composed:!0}))}_exitFullscreen(){var t;(t=document.exitFullscreen)==null||t.call(document)}_fullscreen(){var e,s,i,a,o,n;if(((s=(e=this.asset)==null?void 0:e.extension)==null?void 0:s.toLowerCase())==="pdf"&&((a=(i=this.asset)==null?void 0:i.url)!=null&&a.cdn)){window.open(this.asset.url.cdn,"_blank","noopener");return}this._fsImageLoaded=!1,(n=(o=this.previewArea)==null?void 0:o.requestFullscreen)==null||n.call(o)}_select(){if(!this.asset)return;if(!this.multiSelect){this.dispatchEvent(new CustomEvent("asset-quick-select",{detail:{asset:this.asset},bubbles:!0,composed:!0}));return}const t=this._getCurrentIndex();this.dispatchEvent(new CustomEvent("asset-select",{detail:{asset:this.asset,index:t,event:new MouseEvent("click",{ctrlKey:!0,metaKey:!0})},bubbles:!0,composed:!0}))}_getCurrentIndex(){return!this.asset||this.assets.length===0?-1:this.assets.findIndex(t=>t.uuid===this.asset.uuid)}_navigateTo(t){this._fsImageLoaded=!1,this.dispatchEvent(new CustomEvent("preview-navigate",{detail:{asset:t},bubbles:!0,composed:!0}))}_supportsFullscreen(t){const e=tt(t.type);return e==="image"||e==="video"||e==="audio"}_findNavTarget(t,e){const s=e===1?this.assets.length:-1;for(let i=t+e;i!==s;i+=e)if(!this._isFullscreen||this._supportsFullscreen(this.assets[i]))return i;return-1}_prev(){const t=this._getCurrentIndex();if(t<=0)return;const e=this._findNavTarget(t,-1);e>=0&&this._navigateTo(this.assets[e])}_next(){const t=this._getCurrentIndex();if(t<0||t>=this.assets.length-1)return;const e=this._findNavTarget(t,1);e>=0&&this._navigateTo(this.assets[e])}_getFullscreenImageUrl(t){var i,a;const e=(i=t.url)==null?void 0:i.cdn;if(!e)return zt(t)||"";if(((a=t.extension)==null?void 0:a.toLowerCase())==="svg")return e;const s=Be(e,this.containerToken);return xe(s,{w:String(window.screen.width),dpr:String(window.devicePixelRatio||1),org_if_sml:"1"})}_getBlurDimensions(t){var n,c;const e=(n=t.info)==null?void 0:n.img_w,s=(c=t.info)==null?void 0:c.img_h;if(!e||!s)return{width:"100vw",height:"100vh"};const i=window.innerWidth,a=window.innerHeight,o=Math.min(i/e,a/s,1);return{width:`${Math.round(e*o)}px`,height:`${Math.round(s*o)}px`}}_onFsImageLoad(){this._fsImageLoaded=!0}_getTagEntries(t){if(!t)return[];if(Array.isArray(t))return this._parseTagArray(t);const e=Object.values(t);if(e.length>0&&Array.isArray(e[0])){const s=e.flat(),i=new Set;return s.filter(a=>!a.label||i.has(a.sid)?!1:(i.add(a.sid),!0))}return e.map(s=>({label:s.label,sid:s.sid})).filter(s=>s.label)}_parseTagArray(t){return t.map(e=>{if(typeof e=="string")return{label:e,sid:e};const s=e;return{label:s.label||Object.values(s.names||{})[0]||"",sid:s.sid||""}}).filter(e=>e.label)}_applyTagFilter(t){this.dispatchEvent(new CustomEvent("filter-update",{detail:{key:b.TAGS,values:[t],operator:S.IS},bubbles:!0,composed:!0}))}_applyLabelFilter(t){this.dispatchEvent(new CustomEvent("filter-update",{detail:{key:b.LABELS,values:[t],operator:S.IS},bubbles:!0,composed:!0}))}_toggleSection(t){const e=new Set(this._openSections);e.has(t)?e.delete(t):e.add(t),this._openSections=e}_renderFileInfoSection(t){const e=this._getFileInfoRows(t);if(e.length===0)return r.nothing;const s=this._openSections.has("file-info");return r.html`
5857
+ `;Ft([l.property({reflect:!0})],Ge.prototype,"variant",2);Ft([l.property({type:String})],Ge.prototype,"gridSize",2);Ft([l.property({type:Boolean})],Ge.prototype,"multiSelect",2);Ft([l.property({type:Number})],Ge.prototype,"folderCount",2);Ge=Ft([l.customElement("ap-skeleton")],Ge);var Lr=Object.defineProperty,Or=Object.getOwnPropertyDescriptor,U=(t,e,s,i)=>{for(var a=i>1?void 0:i?Or(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&Lr(e,s,a),a};let z=class extends r.LitElement{constructor(){super(...arguments),this.asset=null,this.assets=[],this.selectedIds=[],this.containerToken="",this.showMetadata=!0,this.metadataFields=[],this.labels=[],this.regionalFilters={},this.multiSelect=!0,this._isFullscreen=!1,this._fsImageLoaded=!1,this._previewLoading=!1,this._openSections=new Set(["file-info","metadata"]),this._hls=null}connectedCallback(){super.connectedCallback(),this._onFullscreenChange=this._onFullscreenChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),document.addEventListener("fullscreenchange",this._onFullscreenChange),document.addEventListener("keydown",this._onKeyDown)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("fullscreenchange",this._onFullscreenChange),document.removeEventListener("keydown",this._onKeyDown),this._destroyHls()}_onKeyDown(t){if(t.key!=="ArrowLeft"&&t.key!=="ArrowRight")return;const e=t.composedPath()[0];if(!e)return;const s=e.tagName;s==="INPUT"||s==="TEXTAREA"||s==="SELECT"||e.getAttribute("role")==="radio"||e.getAttribute("role")==="listbox"||e.isContentEditable||(t.preventDefault(),t.key==="ArrowLeft"?this._prev():this._next())}_destroyHls(){this._hls&&(this._hls.destroy(),this._hls=null)}updated(t){if(super.updated(t),t.has("asset")&&(this._destroyHls(),this._previewLoading=!0,this.asset)){const e=tt(this.asset.type);e==="video"&&this._setupHls(this.asset),e!=="image"&&e!=="video"&&(this._previewLoading=!1)}}async _setupHls(t){var i,a;const e=Vt(t);if(!e||(await this.updateComplete,((i=this.asset)==null?void 0:i.uuid)!==t.uuid))return;const s=this._videoEl;if(s){if(s.canPlayType("application/vnd.apple.mpegurl")){s.src=e;return}try{const{default:o}=await Promise.resolve().then(()=>require("./hls.light-C3NKRmfw.cjs"));if(!o.isSupported()||((a=this.asset)==null?void 0:a.uuid)!==t.uuid||!this.isConnected)return;const n=new o;this._hls=n,n.loadSource(e),n.attachMedia(s),n.on(o.Events.ERROR,(c,d)=>{var h;d.fatal&&(this._destroyHls(),s.src=((h=t.url)==null?void 0:h.cdn)||"")})}catch{}}}_onFullscreenChange(){this._isFullscreen=!!document.fullscreenElement,this._isFullscreen&&(this._fsImageLoaded=!1)}_close(){this.dispatchEvent(new CustomEvent("preview-close",{bubbles:!0,composed:!0}))}_exitFullscreen(){var t;(t=document.exitFullscreen)==null||t.call(document)}_fullscreen(){var e,s,i,a,o,n;if(((s=(e=this.asset)==null?void 0:e.extension)==null?void 0:s.toLowerCase())==="pdf"&&((a=(i=this.asset)==null?void 0:i.url)!=null&&a.cdn)){window.open(this.asset.url.cdn,"_blank","noopener");return}this._fsImageLoaded=!1,(n=(o=this.previewArea)==null?void 0:o.requestFullscreen)==null||n.call(o)}_select(){if(!this.asset)return;if(!this.multiSelect){this.dispatchEvent(new CustomEvent("asset-quick-select",{detail:{asset:this.asset},bubbles:!0,composed:!0}));return}const t=this._getCurrentIndex();this.dispatchEvent(new CustomEvent("asset-select",{detail:{asset:this.asset,index:t,event:new MouseEvent("click",{ctrlKey:!0,metaKey:!0})},bubbles:!0,composed:!0}))}_getCurrentIndex(){return!this.asset||this.assets.length===0?-1:this.assets.findIndex(t=>t.uuid===this.asset.uuid)}_navigateTo(t){this._fsImageLoaded=!1,this.dispatchEvent(new CustomEvent("preview-navigate",{detail:{asset:t},bubbles:!0,composed:!0}))}_supportsFullscreen(t){const e=tt(t.type);return e==="image"||e==="video"||e==="audio"}_findNavTarget(t,e){const s=e===1?this.assets.length:-1;for(let i=t+e;i!==s;i+=e)if(!this._isFullscreen||this._supportsFullscreen(this.assets[i]))return i;return-1}_prev(){const t=this._getCurrentIndex();if(t<=0)return;const e=this._findNavTarget(t,-1);e>=0&&this._navigateTo(this.assets[e])}_next(){const t=this._getCurrentIndex();if(t<0||t>=this.assets.length-1)return;const e=this._findNavTarget(t,1);e>=0&&this._navigateTo(this.assets[e])}_getFullscreenImageUrl(t){var i,a;const e=(i=t.url)==null?void 0:i.cdn;if(!e)return zt(t)||"";if(((a=t.extension)==null?void 0:a.toLowerCase())==="svg")return e;const s=Be(e,this.containerToken);return xe(s,{w:String(window.screen.width),dpr:String(window.devicePixelRatio||1),org_if_sml:"1"})}_getBlurDimensions(t){var n,c;const e=(n=t.info)==null?void 0:n.img_w,s=(c=t.info)==null?void 0:c.img_h;if(!e||!s)return{width:"100vw",height:"100vh"};const i=window.innerWidth,a=window.innerHeight,o=Math.min(i/e,a/s,1);return{width:`${Math.round(e*o)}px`,height:`${Math.round(s*o)}px`}}_onFsImageLoad(){this._fsImageLoaded=!0}_getTagEntries(t){if(!t)return[];if(Array.isArray(t))return this._parseTagArray(t);const e=Object.values(t);if(e.length>0&&Array.isArray(e[0])){const s=e.flat(),i=new Set;return s.filter(a=>!a.label||i.has(a.sid)?!1:(i.add(a.sid),!0))}return e.map(s=>({label:s.label,sid:s.sid})).filter(s=>s.label)}_parseTagArray(t){return t.map(e=>{if(typeof e=="string")return{label:e,sid:e};const s=e;return{label:s.label||Object.values(s.names||{})[0]||"",sid:s.sid||""}}).filter(e=>e.label)}_applyTagFilter(t){this.dispatchEvent(new CustomEvent("filter-update",{detail:{key:b.TAGS,values:[t],operator:C.IS},bubbles:!0,composed:!0}))}_applyLabelFilter(t){this.dispatchEvent(new CustomEvent("filter-update",{detail:{key:b.LABELS,values:[t],operator:C.IS},bubbles:!0,composed:!0}))}_toggleSection(t){const e=new Set(this._openSections);e.has(t)?e.delete(t):e.add(t),this._openSections=e}_renderFileInfoSection(t){const e=this._getFileInfoRows(t);if(e.length===0)return r.nothing;const s=this._openSections.has("file-info");return r.html`
5858
5858
  <div class="accordion">
5859
5859
  <button
5860
5860
  class="accordion-trigger"
@@ -5898,7 +5898,7 @@
5898
5898
  `)}
5899
5899
  </div>
5900
5900
  </div>
5901
- `}_getFileInfoRows(t){var s,i,a,o,n,c;const e=[];return e.push({label:"File name",value:t.name}),t.extension&&e.push({label:"Type",value:t.extension.toUpperCase()}),(s=t.size)!=null&&s.bytes&&e.push({label:"Size",value:xs(t.size.bytes)}),(i=t.info)!=null&&i.img_w&&e.push({label:"Dimensions",value:_i(t.info.img_w,t.info.img_h)}),(a=t.info)!=null&&a.video_w&&e.push({label:"Video resolution",value:`${t.info.video_w} x ${t.info.video_h}`}),(((o=t.info)==null?void 0:o.video_duration)??((n=t.info)==null?void 0:n.duration))!=null&&e.push({label:"Duration",value:`${Math.round(t.info.video_duration??t.info.duration)}s`}),(c=t.info)!=null&&c.color_space&&e.push({label:"Color space",value:t.info.color_space}),t.created_at&&e.push({label:"Created",value:jt(t.created_at)}),t.modified_at&&e.push({label:"Modified",value:jt(t.modified_at)}),e}_buildFieldMap(){const t=new Map;for(const e of this.metadataFields)t.set(e.key,e),e.ckey&&t.set(e.ckey,e),e.slug&&t.set(e.slug,e);return t}_resolveSlug(t,e){var i;if(!((i=e.possible_values)!=null&&i.length)||!t.startsWith("@"))return t;const s=e.possible_values.find(a=>a.internal_unique_value===t||a.api_value===t);return(s==null?void 0:s.label)??t}_resolveFieldValue(t,e){var s;if(t==null||t==="")return"";if(e.regionalVariantsGroupUuid&&typeof t=="object"&&t!==null&&!Array.isArray(t)){const i=this.regionalFilters[e.regionalVariantsGroupUuid];if(i){const a=t[i];if(a!=null&&a!=="")return this._resolveFieldValue(a,{...e,regionalVariantsGroupUuid:void 0})}return""}if((s=e.possible_values)!=null&&s.length)return Array.isArray(t)?t.map(a=>this._resolveSlug(String(a),e)).filter(Boolean).join(", "):this._resolveSlug(String(t),e);if(Array.isArray(t))return t.join(", ");if(typeof t=="object"){const i=JSON.stringify(t);return i==="{}"||i==="[]"?"":i}return String(t)}_getAllMetadataRows(t){var o,n,c,d;const e=[],s=this._buildFieldMap(),i=new Set;if(this.metadataFields.length>0){const h=t;for(const u of this.metadataFields){const f=h[u.key]??((n=(o=t.info)==null?void 0:o.metadata)==null?void 0:n[u.key])??((c=t.meta)==null?void 0:c[u.key]),p=this._resolveFieldValue(f,u);if(!p)continue;i.add(u.key),u.slug&&i.add(u.slug);const g=p.length>50;e.push({label:u.label,value:p,wrap:g})}}if(t.meta)for(const[h,u]of Object.entries(t.meta)){if(i.has(h)||u==null||u==="")continue;const f=s.get(h);if(f){const p=this._resolveFieldValue(u,f);if(!p)continue;i.add(h);const g=p.length>50;e.push({label:f.label,value:p,wrap:g})}else{const p=typeof u=="object"?JSON.stringify(u):String(u);if(!p||p==="{}"||p==="[]")continue;i.add(h);const g=h.charAt(0).toUpperCase()+h.slice(1).replace(/_/g," "),m=p.length>50;e.push({label:g,value:p,wrap:m})}}const a=(d=t.info)==null?void 0:d.metadata;if(a&&typeof a=="object")for(const[h,u]of Object.entries(a)){if(i.has(h)||u==null||u==="")continue;const f=s.get(h);if(f){const p=this._resolveFieldValue(u,f);if(!p)continue;i.add(h);const g=p.length>50;e.push({label:f.label,value:p,wrap:g})}else{const p=typeof u=="object"?JSON.stringify(u):String(u);if(!p||p==="{}"||p==="[]")continue;i.add(h);const g=h.charAt(0).toUpperCase()+h.slice(1).replace(/_/g," "),m=p.length>50;e.push({label:g,value:p,wrap:m})}}return e}_getAssetLabels(t){return!t.labels||t.labels.length===0?[]:t.labels.map(e=>this.labels.find(s=>s.sid===e||s.uuid===e)).filter(e=>!!e)}_renderLabelsRow(t){const e=this._getAssetLabels(t);return e.length===0?r.nothing:r.html`
5901
+ `}_getFileInfoRows(t){var s,i,a,o,n,c;const e=[];return e.push({label:"File name",value:t.name}),t.extension&&e.push({label:"Type",value:t.extension.toUpperCase()}),(s=t.size)!=null&&s.bytes&&e.push({label:"Size",value:xs(t.size.bytes)}),(i=t.info)!=null&&i.img_w&&e.push({label:"Dimensions",value:_i(t.info.img_w,t.info.img_h)}),(a=t.info)!=null&&a.video_w&&e.push({label:"Video resolution",value:`${t.info.video_w} x ${t.info.video_h}`}),(((o=t.info)==null?void 0:o.video_duration)??((n=t.info)==null?void 0:n.duration))!=null&&e.push({label:"Duration",value:`${Math.round(t.info.video_duration??t.info.duration)}s`}),(c=t.info)!=null&&c.color_space&&e.push({label:"Color space",value:t.info.color_space}),t.created_at&&e.push({label:"Created",value:jt(t.created_at)}),t.modified_at&&e.push({label:"Modified",value:jt(t.modified_at)}),e}_buildFieldMap(){const t=new Map;for(const e of this.metadataFields)t.set(e.key,e),e.ckey&&t.set(e.ckey,e),e.slug&&t.set(e.slug,e);return t}_resolveSlug(t,e){var i;if(!((i=e.possible_values)!=null&&i.length)||!t.startsWith("@"))return t;const s=e.possible_values.find(a=>a.internal_unique_value===t||a.api_value===t);return(s==null?void 0:s.label)??t}_resolveFieldValue(t,e){var s;if(t==null||t==="")return"";if(e.regionalVariantsGroupUuid&&typeof t=="object"&&t!==null&&!Array.isArray(t)){const i=this.regionalFilters[e.regionalVariantsGroupUuid];if(i){const a=t[i];if(a!=null&&a!=="")return this._resolveFieldValue(a,{...e,regionalVariantsGroupUuid:void 0})}return""}if((s=e.possible_values)!=null&&s.length)return Array.isArray(t)?t.map(a=>this._resolveSlug(String(a),e)).filter(Boolean).join(", "):this._resolveSlug(String(t),e);if(Array.isArray(t))return t.join(", ");if(typeof t=="object"){const i=JSON.stringify(t);return i==="{}"||i==="[]"?"":i}return String(t)}_getAllMetadataRows(t){var o,n,c,d;const e=[],s=this._buildFieldMap(),i=new Set;if(this.metadataFields.length>0){const h=t;for(const u of this.metadataFields){const g=h[u.key]??((n=(o=t.info)==null?void 0:o.metadata)==null?void 0:n[u.key])??((c=t.meta)==null?void 0:c[u.key]),p=this._resolveFieldValue(g,u);if(!p)continue;i.add(u.key),u.slug&&i.add(u.slug);const f=p.length>50;e.push({label:u.label,value:p,wrap:f})}}if(t.meta)for(const[h,u]of Object.entries(t.meta)){if(i.has(h)||u==null||u==="")continue;const g=s.get(h);if(g){const p=this._resolveFieldValue(u,g);if(!p)continue;i.add(h);const f=p.length>50;e.push({label:g.label,value:p,wrap:f})}else{const p=typeof u=="object"?JSON.stringify(u):String(u);if(!p||p==="{}"||p==="[]")continue;i.add(h);const f=h.charAt(0).toUpperCase()+h.slice(1).replace(/_/g," "),m=p.length>50;e.push({label:f,value:p,wrap:m})}}const a=(d=t.info)==null?void 0:d.metadata;if(a&&typeof a=="object")for(const[h,u]of Object.entries(a)){if(i.has(h)||u==null||u==="")continue;const g=s.get(h);if(g){const p=this._resolveFieldValue(u,g);if(!p)continue;i.add(h);const f=p.length>50;e.push({label:g.label,value:p,wrap:f})}else{const p=typeof u=="object"?JSON.stringify(u):String(u);if(!p||p==="{}"||p==="[]")continue;i.add(h);const f=h.charAt(0).toUpperCase()+h.slice(1).replace(/_/g," "),m=p.length>50;e.push({label:f,value:p,wrap:m})}}return e}_getAssetLabels(t){return!t.labels||t.labels.length===0?[]:t.labels.map(e=>this.labels.find(s=>s.sid===e||s.uuid===e)).filter(e=>!!e)}_renderLabelsRow(t){const e=this._getAssetLabels(t);return e.length===0?r.nothing:r.html`
5902
5902
  <div class="meta-row" style="flex-direction:column;gap:6px">
5903
5903
  <span class="meta-label">Labels</span>
5904
5904
  <div class="tags-list">
@@ -5921,7 +5921,7 @@
5921
5921
  `)}
5922
5922
  </div>
5923
5923
  </div>
5924
- `}render(){var $,k,E,A,fe,ie,O,X;const t=this.asset;if(!t)return r.nothing;const e=tt(t.type),s=e==="image",i=e==="video",a=e==="audio",o=(($=t.extension)==null?void 0:$.toLowerCase())==="pdf",n=$t(t.extension||""),c=us(t.extension||""),d=((k=t.extension)==null?void 0:k.toLowerCase())==="svg",h=zt(t),u=s?d?((E=t.url)==null?void 0:E.cdn)||"":h||Be(((A=t.url)==null?void 0:A.cdn)||"",this.containerToken):"",f=s?this._getFullscreenImageUrl(t):"",p=s&&!d?this._getBlurDimensions(t):null,g=i&&((fe=t.url)==null?void 0:fe.cdn)||"",m=i&&(((ie=t.info)==null?void 0:ie.video_thumbnail)||((O=t.info)==null?void 0:O.preview))||"",_=o&&!s?gs(t):"",y=this._getCurrentIndex(),C=y>0&&this._findNavTarget(y,-1)>=0,x=y>=0&&this._findNavTarget(y,1)>=0,M=this.assets.length>1;return r.html`
5924
+ `}render(){var k,S,F,E,fe,ie,M,X;const t=this.asset;if(!t)return r.nothing;const e=tt(t.type),s=e==="image",i=e==="video",a=e==="audio",o=((k=t.extension)==null?void 0:k.toLowerCase())==="pdf",n=$t(t.extension||""),c=us(t.extension||""),d=((S=t.extension)==null?void 0:S.toLowerCase())==="svg",h=zt(t),u=s?d?((F=t.url)==null?void 0:F.cdn)||"":h||Be(((E=t.url)==null?void 0:E.cdn)||"",this.containerToken):"",g=s?this._getFullscreenImageUrl(t):"",p=s&&!d?this._getBlurDimensions(t):null,f=i&&((fe=t.url)==null?void 0:fe.cdn)||"",m=i&&(((ie=t.info)==null?void 0:ie.video_thumbnail)||((M=t.info)==null?void 0:M.preview))||"",x=o&&!s?gs(t):"",_=this._getCurrentIndex(),w=_>0&&this._findNavTarget(_,-1)>=0,y=_>=0&&this._findNavTarget(_,1)>=0,T=this.assets.length>1;return r.html`
5925
5925
  <div class="panel">
5926
5926
  <div class="panel-header">
5927
5927
  <span class="panel-title" title=${t.name}>${t.name}</span>
@@ -5940,11 +5940,11 @@
5940
5940
  </div>
5941
5941
 
5942
5942
  <div class="preview-area ${s&&c?"chess":""}">
5943
- ${M?r.html`
5944
- <button class="nav-btn prev" @click=${this._prev} ?disabled=${!C} aria-label="Previous">
5943
+ ${T?r.html`
5944
+ <button class="nav-btn prev" @click=${this._prev} ?disabled=${!w} aria-label="Previous">
5945
5945
  <ap-icon name="chevron-left" .size=${16}></ap-icon>
5946
5946
  </button>
5947
- <button class="nav-btn next" @click=${this._next} ?disabled=${!x} aria-label="Next">
5947
+ <button class="nav-btn next" @click=${this._next} ?disabled=${!y} aria-label="Next">
5948
5948
  <ap-icon name="chevron-right" .size=${16}></ap-icon>
5949
5949
  </button>
5950
5950
  `:r.nothing}
@@ -5972,20 +5972,20 @@
5972
5972
  `}
5973
5973
  <img
5974
5974
  class="fs-full ${d||this._fsImageLoaded?"loaded":""}"
5975
- src=${this._isFullscreen?f:""}
5975
+ src=${this._isFullscreen?g:""}
5976
5976
  alt=${t.name}
5977
5977
  style=${d?"width:100vw;height:100vh":""}
5978
5978
  @load=${this._onFsImageLoad}
5979
5979
  />
5980
5980
  </div>
5981
5981
  `:r.nothing}
5982
- ${i?r.html`<video src=${g} poster=${m||r.nothing} controls controlsList="nofullscreen" @loadeddata=${()=>{this._previewLoading=!1}} @error=${()=>{this._previewLoading=!1}}></video>`:r.nothing}
5982
+ ${i?r.html`<video src=${f} poster=${m||r.nothing} controls controlsList="nofullscreen" @loadeddata=${()=>{this._previewLoading=!1}} @error=${()=>{this._previewLoading=!1}}></video>`:r.nothing}
5983
5983
  ${a?r.html`<audio src=${((X=t.url)==null?void 0:X.cdn)||""} controls></audio>`:r.nothing}
5984
5984
  ${o&&!s?r.html`
5985
5985
  <img
5986
- src=${_||n}
5986
+ src=${x||n}
5987
5987
  alt=${t.name}
5988
- class=${_?"":"icon-fallback"}
5988
+ class=${x?"":"icon-fallback"}
5989
5989
  @error=${Z=>{const D=Z.target;D.src!==n&&(D.src=n,D.classList.add("icon-fallback"))}}
5990
5990
  />
5991
5991
  `:r.nothing}
@@ -7240,16 +7240,16 @@
7240
7240
  :host(:hover) .tip {
7241
7241
  display: block;
7242
7242
  }
7243
- `];$i([l.property()],qt.prototype,"text",2);qt=$i([l.customElement("ap-tooltip")],qt);var nn=Object.defineProperty,Et=(t,e,s,i)=>{for(var a=void 0,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=n(e,s,a)||a);return a&&nn(e,s,a),a};const Ts=class Ts extends r.LitElement{constructor(){super(),this._initFailed=!1,this._loadId=0,this._loadMoreId=0,this._selectAllId=0,this._loadDataTimer=null,this._pendingFilter=null,this._pendingMetadataField=null,this._normalizedForcedFilters={},this._uploaderEl=null,this._uploaderImportPromise=null,this._dragCounter=0,this._isDragOver=!1,this._isUploaderOpen=!1,this._folderResolveOpen=!1,this._transformOpen=!1,this._transformAssets=[],this._transformFolders=[],this._transformAfterResolve=!1,this._onDragEnter=e=>{var s;!((s=this.config)!=null&&s.uploader)||!this._hasFileTransfer(e)||(e.preventDefault(),this._dragCounter++,this._dragCounter===1&&(this._isDragOver=!0))},this._onDragOver=e=>{var s;!((s=this.config)!=null&&s.uploader)||!this._hasFileTransfer(e)||(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"))},this._onDragLeave=e=>{var s;!((s=this.config)!=null&&s.uploader)||!this._hasFileTransfer(e)||(e.preventDefault(),this._dragCounter--,this._dragCounter<=0&&(this._dragCounter=0,this._isDragOver=!1))},this._onDrop=e=>{var i,a;if(!((i=this.config)!=null&&i.uploader)||!this._hasFileTransfer(e))return;e.preventDefault(),this._dragCounter=0,this._isDragOver=!1;const s=Array.from(((a=e.dataTransfer)==null?void 0:a.files)??[]);s.length>0&&this._openUploader(s)},this.store=Oi(),this.storeCtrl=new Mi(this,this.store),this.selectionCtrl=new Pi(this,this.store),this.infiniteScrollCtrl=new Di(this,()=>this._loadMore()),this.marqueeCtrl=new zi(this,this.store)}get _isInline(){var e;return((e=this.config)==null?void 0:e.displayMode)==="inline"}disconnectedCallback(){super.disconnectedCallback(),this._uploaderEl&&(this._uploaderEl.remove(),this._uploaderEl=null),this._uploaderImportPromise=null,this._dragCounter=0,this._isDragOver=!1,this._isUploaderOpen=!1}updated(e){super.updated(e),e.has("config")&&this.config&&this._initConfig(this.config);const s=this.renderRoot.querySelector("#sentinel");if(s&&s!==this._lastSentinel){this._lastSentinel=s;const a=this.renderRoot.querySelector(".main-content");this.infiniteScrollCtrl.observe(s,a)}const i=this.renderRoot.querySelector(".main-content");i&&i!==this._lastMarqueeContainer&&(this._lastMarqueeContainer=i,this.marqueeCtrl.attach(i))}_initConfig(e){const s={folderSelection:!0,...e};this._initFailed=!1,this._normalizedForcedFilters=ps(s.forcedFilters),this._initPromise=this._doInit(s).catch(()=>{this._initFailed=!0}),this.toggleAttribute("inline",s.displayMode==="inline"),s.displayMode==="inline"&&!this.store.getState().isOpen&&this.open()}async _doInit(e){const s=Ya(),i=s.sortBy??e.defaultSortBy??"created_at",a=s.sortDirection??e.defaultSortDirection??"desc";this.store.setState({config:e,projectToken:e.auth.projectToken,viewMode:e.rememberLastView&&Za(e.auth.projectToken)||e.defaultViewMode||"grid",sortBy:i,sortDirection:a}),this.apiClient=new Ri(e.auth,e.apiBase);try{if(e.auth.mode==="securityTemplate"){const _=await Gi(this.apiClient);this.apiClient.setSassKey(_),this.store.setState({sassKey:_})}const[o,n,c,d,h]=await Promise.allSettled([Ea(this.apiClient),Bi(this.apiClient),Hi(this.apiClient),Ca(this.apiClient),qi(this.apiClient)]),u={};if(o.status==="fulfilled"){const{fields:_,regionalVariantGroups:y,regionalFilters:C,brandColor:x}=o.value;u.metadataFields=_,u.regionalVariantGroups=y,u.regionalFilters=C,x&&(u.brandColor=x)}n.status==="fulfilled"&&(u.labels=n.value.labels||[]),c.status==="fulfilled"&&(u.tags=c.value),h.status==="fulfilled"&&(u.collections=h.value.collections||[]),d.status==="fulfilled"&&(u.fileTypes=d.value);const{pinnedFilters:f,pinnedMetadata:p}=Ga(e.auth.projectToken??null),g=this.store.getState().filters;u.filters={...g,pinned:f,visible:[...f],metadata:{...g.metadata,pinned:p,visible:[...p]}},this.store.setState(u);const m=e.brandColor||u.brandColor||this.store.getState().brandColor;m&&(u.brandColor||this.store.setState({brandColor:m}),ao(this,m))}catch(o){throw this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:o,context:"init"},bubbles:!0,composed:!0})),o}}_ensureUploaderImport(){return customElements.get("sfx-uploader")?Promise.resolve():this._uploaderImportPromise?this._uploaderImportPromise:(this._uploaderImportPromise=import("@scaleflex/uploader/define").then(()=>{},e=>{throw this._uploaderImportPromise=null,e}),this._uploaderImportPromise)}_buildUploaderConfig(){const e=this.config,s=e.uploader,i=this.store.getState();let a;return e.auth.mode==="securityTemplate"?a={mode:"security-template",container:e.auth.projectToken,securityTemplateId:e.auth.securityTemplateKey}:a={mode:"sass-key",container:e.auth.projectToken,sassKey:e.auth.sassKey},{auth:a,targetFolder:i.currentFolderPath||"/",mode:"inline",restrictions:s.restrictions,concurrency:s.concurrency,autoProceed:s.autoProceed,showFillMetadata:s.showFillMetadata,connectors:s.connectors,sourcesLayout:s.sourcesLayout,header:s.header??"back",clearOnClose:s.clearOnClose,clearOnComplete:s.clearOnComplete,rejectedFileAutoRemoveDelay:s.rejectedFileAutoRemoveDelay}}async _openUploader(e){var i;if(!((i=this.config)!=null&&i.uploader)||this._isUploaderOpen)return;try{await this._ensureUploaderImport()}catch(a){this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:a instanceof Error?a:new Error(String(a)),context:"uploader-load"},bubbles:!0,composed:!0}));return}this._uploaderEl=document.createElement("sfx-uploader");const s=this._uploaderEl;s.addEventListener("sfx-all-complete",()=>{this.store.getState().isOpen&&this._loadData()}),s.addEventListener("sfx-complete-action",()=>{this._closeUploader()}),s.addEventListener("sfx-cancel",()=>{this._closeUploader()}),this._isUploaderOpen=!0,await this.updateComplete,s.config=this._buildUploaderConfig(),await s.updateComplete,e!=null&&e.length&&s.addFiles(e)}_closeUploader(){this._isUploaderOpen=!1,this._uploaderEl&&(this._uploaderEl.remove(),this._uploaderEl=null)}_handleUploadClick(){this._openUploader()}_hasFileTransfer(e){var s,i;return!!((i=(s=e.dataTransfer)==null?void 0:s.types)!=null&&i.includes("Files"))}async open(){var h,u,f,p,g,m,_;const e=this.store.getState(),s=new Set(Object.keys(this._normalizedForcedFilters)),i={},a=ps((h=this.config)==null?void 0:h.defaultFilters);for(const[y,C]of Object.entries(a))s.has(y)||(i[y]=C);const o=Object.keys(i),n=((u=this.config)==null?void 0:u.tabs)??["assets","folders"],c=(f=this.config)!=null&&f.rememberLastTab?eo(this.config.auth.projectToken):null,d=(c&&n.includes(c)?c:null)??((p=this.config)!=null&&p.defaultTab&&n.includes(this.config.defaultTab)?this.config.defaultTab:null)??n[0]??"assets";this.store.setState({isOpen:!0,activeTab:d,searchQuery:"",isAISearchActive:!!((g=this.config)!=null&&g.enableAISearch&&((m=this.config)!=null&&m.defaultAISearch)),filters:{metadata:{pinned:e.filters.metadata.pinned,visible:[...e.filters.metadata.pinned],applied:{}},pinned:e.filters.pinned,visible:[...new Set([...e.filters.pinned,...o])],applied:i},offset:0,assets:[],folders:[],currentFolder:null,currentFolderPath:this._resolveInitialFolderPath(d),activeLabelUuid:null,activeCollectionUuid:null,activeCollectionFolders:[],activeCollectionFolder:null,isLoadingCollectionFolders:!1,breadcrumb:this._buildBreadcrumbFromPath(this._resolveInitialFolderPath(d),((_=this.config)==null?void 0:_.rootFolderPath)||"/"),selectedAssets:new Map,selectedFolders:new Map,isResolvingFolders:!1,folderPreviews:{},isPreviewOpen:!1,previewAsset:null,isLoading:!0,isSelectingAll:!1}),this._dragCounter=0,this._isDragOver=!1,this.dispatchEvent(new CustomEvent("ap-open",{detail:{timestamp:Date.now()},bubbles:!0,composed:!0})),await this.updateComplete,!this._initPromise&&this.config&&this._initConfig(this.config),!(this._initPromise&&(await this._initPromise,this._initFailed))&&this._loadData()}close(){this.store.setState({isOpen:!1}),this._dragCounter=0,this._isDragOver=!1,this._isUploaderOpen=!1,this._folderResolveOpen=!1,this._transformOpen=!1,this._transformAssets=[],this._transformFolders=[],this._transformAfterResolve=!1,this._selectAllId++}_scrollToTop(){var e;(e=this.renderRoot.querySelector(".main-content"))==null||e.scrollTo({top:0})}async _loadData(){var i,a,o,n,c,d,h,u,f,p,g,m,_,y,C,x,M,$,k,E,A,fe,ie,O,X,Z,D,Pe,Ls,Os,Ms,Is,Ps,Ds,zs,Rs,js,Ns,Us;if(!this.apiClient)return;const e=++this._loadId,s=this.store.getState();this._scrollToTop(),this.store.setState({isLoading:!0});try{const Xe=s.activeTab;if(Xe==="assets"){const ae=this._buildSearchNotation(),Ae=s.currentFolderPath||"/",he=s.isAISearchActive&&!!s.searchQuery,oe=De(this.apiClient,{folder:Ae,offset:0,limit:s.limit,sort_by:s.sortBy,sort_direction:s.sortDirection,search:s.searchQuery||void 0,q:ae||void 0,recursive:1,...he&&{with_ai:!0,ai_query:s.searchQuery,ai_lang:((i=s.config)==null?void 0:i.locale)??"en"}}),H=At(this.apiClient,{folder:Ae,q:ae||void 0,search:s.searchQuery||void 0,recursive:1,...he&&{with_ai:!0,ai_query:s.searchQuery,ai_lang:((a=s.config)==null?void 0:a.locale)??"en"}}).catch(()=>null),[B,J]=await Promise.all([oe,H]);if(e!==this._loadId)return;const ee=((o=B.files)==null?void 0:o.length)??0,j=ee>=s.limit,te=((n=J==null?void 0:J.stats)==null?void 0:n.approx_files_count)??((c=J==null?void 0:J.info)==null?void 0:c.total_files_count)??((d=B.info)==null?void 0:d.total_files_count)??((u=(h=B.base)==null?void 0:h.count)==null?void 0:u.files_recursive)??((p=(f=B.base)==null?void 0:f.count)==null?void 0:p.files_direct)??ee;this.store.setState({assets:B.files||[],folders:[],totalCount:te,totalFolderCount:0,offset:0,hasMore:j,isLoading:!1})}else if(Xe==="folders"){const ae=this._buildSearchNotation(),Ae=s.currentFolderPath||"/",[he,oe,H]=await Promise.all([Ni(this.apiClient,{folderPath:s.currentFolderPath,q:s.searchQuery||void 0,recursive:s.searchQuery?1:0,sort_by:s.sortBy,sort_direction:s.sortDirection}),De(this.apiClient,{folder:Ae,offset:0,limit:s.limit,sort_by:s.sortBy,sort_direction:s.sortDirection,search:s.searchQuery||void 0,q:ae||void 0,recursive:0,...s.isAISearchActive&&s.searchQuery&&{with_ai:!0,ai_query:s.searchQuery,ai_lang:((g=s.config)==null?void 0:g.locale)??"en"}}),At(this.apiClient,{folder:Ae,q:ae||void 0,search:s.searchQuery||void 0,recursive:0,...s.isAISearchActive&&s.searchQuery&&{with_ai:!0,ai_query:s.searchQuery,ai_lang:((m=s.config)==null?void 0:m.locale)??"en"}}).catch(()=>null)]);if(e!==this._loadId)return;const B=he.folders||[];let J={};if(B.length>0)try{J=await Ui(this.apiClient,B.map(Ze=>Ze.uuid))}catch{}if(e!==this._loadId)return;const ee=((_=oe.files)==null?void 0:_.length)??0,j=ee>=s.limit,te=((y=H==null?void 0:H.stats)==null?void 0:y.approx_files_count)??((C=H==null?void 0:H.info)==null?void 0:C.total_files_count)??((x=oe.info)==null?void 0:x.total_files_count)??(($=(M=oe.base)==null?void 0:M.count)==null?void 0:$.files_direct)??ee;this.store.setState({assets:oe.files||[],folders:B,folderPreviews:J,totalCount:te,totalFolderCount:he.total??B.length,offset:0,hasMore:j,isLoading:!1})}else if(Xe==="labels"){if(!s.activeLabelUuid){this.store.setState({assets:[],folders:[],totalCount:s.labels.length,totalFolderCount:0,offset:0,hasMore:!1,isLoading:!1});return}const ae=s.labels.find(Zt=>Zt.uuid===s.activeLabelUuid);if(!ae){this.store.setState({isLoading:!1});return}const Ae=ae.sid.replace("#",""),he=this._buildSearchNotation(),oe=`labels:${Ae}${he?" "+he:""}`,H=s.isAISearchActive&&!!s.searchQuery,B=De(this.apiClient,{folder:"/",offset:0,limit:s.limit,sort_by:s.sortBy,sort_direction:s.sortDirection,search:s.searchQuery||void 0,q:oe,recursive:1,...H&&{with_ai:!0,ai_query:s.searchQuery,ai_lang:((k=s.config)==null?void 0:k.locale)??"en"}}),J=At(this.apiClient,{folder:"/",q:oe,search:s.searchQuery||void 0,recursive:1,...H&&{with_ai:!0,ai_query:s.searchQuery,ai_lang:((E=s.config)==null?void 0:E.locale)??"en"}}).catch(()=>null),[ee,j]=await Promise.all([B,J]);if(e!==this._loadId)return;const te=((A=ee.files)==null?void 0:A.length)??0,Ze=te>=s.limit,Xt=((fe=j==null?void 0:j.stats)==null?void 0:fe.approx_files_count)??((ie=j==null?void 0:j.info)==null?void 0:ie.total_files_count)??((O=ee.info)==null?void 0:O.total_files_count)??((Z=(X=ee.base)==null?void 0:X.count)==null?void 0:Z.files_recursive)??((Pe=(D=ee.base)==null?void 0:D.count)==null?void 0:Pe.files_direct)??te;this.store.setState({assets:ee.files||[],folders:[],totalCount:Xt,totalFolderCount:0,offset:0,hasMore:Ze,isLoading:!1})}else if(Xe==="collections"){if(!s.activeCollectionUuid){this.store.setState({assets:[],folders:[],totalCount:0,totalFolderCount:0,offset:0,hasMore:!1,isLoading:!1});return}const ae=s.activeCollectionFolder;if(!(ae&&!((Ls=ae.children)!=null&&Ls.length))){this.store.setState({assets:[],folders:[],totalCount:0,totalFolderCount:0,offset:0,hasMore:!1,isLoading:!1});return}const he=s.activeCollectionUuid,oe=ae.filters||void 0,H=this._buildSearchNotation(),B=s.isAISearchActive&&!!s.searchQuery,J=De(this.apiClient,{offset:0,limit:s.limit,sort_by:s.sortBy,sort_direction:s.sortDirection,search:s.searchQuery||void 0,q:H||void 0,recursive:1,collection_uuid:he,f64:oe,...B&&{with_ai:!0,ai_query:s.searchQuery,ai_lang:((Os=s.config)==null?void 0:Os.locale)??"en"}}),ee=At(this.apiClient,{q:H||void 0,search:s.searchQuery||void 0,recursive:1,collection_uuid:he,f64:oe,...B&&{with_ai:!0,ai_query:s.searchQuery,ai_lang:((Ms=s.config)==null?void 0:Ms.locale)??"en"}}).catch(()=>null),[j,te]=await Promise.all([J,ee]);if(e!==this._loadId)return;const Ze=((Is=j.files)==null?void 0:Is.length)??0,Xt=Ze>=s.limit,Zt=((Ps=te==null?void 0:te.stats)==null?void 0:Ps.approx_files_count)??((Ds=te==null?void 0:te.info)==null?void 0:Ds.total_files_count)??((zs=j.info)==null?void 0:zs.total_files_count)??((js=(Rs=j.base)==null?void 0:Rs.count)==null?void 0:js.files_recursive)??((Us=(Ns=j.base)==null?void 0:Ns.count)==null?void 0:Us.files_direct)??Ze;this.store.setState({assets:j.files||[],folders:[],totalCount:Zt,totalFolderCount:0,offset:0,hasMore:Xt,isLoading:!1})}}catch(Xe){if(e!==this._loadId)return;this.store.setState({isLoading:!1}),this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:Xe,context:"loadData"},bubbles:!0,composed:!0}))}}async _loadMore(){var a,o;const e=this.store.getState();if(e.isLoading||!e.hasMore||!this.apiClient||e.activeTab==="labels"&&!e.activeLabelUuid||e.activeTab==="collections"&&!(e.activeCollectionFolder&&!((a=e.activeCollectionFolder.children)!=null&&a.length)))return;const s=++this._loadMoreId,i=e.offset+e.limit;this.store.setState({isLoading:!0});try{const n=this._buildSearchNotation();let c=n||void 0,d=e.currentFolderPath||"/",h=e.activeTab==="folders"?0:1;if(e.activeTab==="labels"&&e.activeLabelUuid){const C=e.labels.find(x=>x.uuid===e.activeLabelUuid);C&&(c=`labels:${C.sid.replace("#","")}${n?" "+n:""}`),d="/",h=1}let u,f;e.activeTab==="collections"&&e.activeCollectionFolder&&(u=e.activeCollectionUuid||void 0,f=e.activeCollectionFolder.filters||void 0,d="",h=1);const p=await De(this.apiClient,{...d?{folder:d}:{},offset:i,limit:e.limit,sort_by:e.sortBy,sort_direction:e.sortDirection,search:e.searchQuery||void 0,q:c,recursive:h,...u&&{collection_uuid:u},...f&&{f64:f},...e.isAISearchActive&&e.searchQuery&&{with_ai:!0,ai_query:e.searchQuery,ai_lang:((o=e.config)==null?void 0:o.locale)??"en"}});if(s!==this._loadMoreId)return;const g=this.store.getState().assets,m=p.files||[],_=m.length>=e.limit,y=[...g,...m];this.store.setState({assets:y,offset:i,hasMore:_,isLoading:!1})}catch{if(s!==this._loadMoreId)return;this.store.setState({isLoading:!1})}}_debouncedLoadData(e=120){this._loadDataTimer&&clearTimeout(this._loadDataTimer),this._loadDataTimer=setTimeout(()=>{this._loadDataTimer=null,this._loadData()},e)}_handleCancel(e){var s,i;this.close(),(i=(s=this.config)==null?void 0:s.onCancel)==null||i.call(s),this.dispatchEvent(new CustomEvent("ap-cancel",{detail:{reason:e},bubbles:!0,composed:!0}))}_handleSearchChange(e){var a;const s=this.store.getState();if(s.activeTab==="labels"&&!s.activeLabelUuid){this.store.setState({searchQuery:e.detail.value});return}if(s.activeTab==="collections"&&!(s.activeCollectionFolder&&!((a=s.activeCollectionFolder.children)!=null&&a.length))){this.store.setState({searchQuery:e.detail.value});return}const i={searchQuery:e.detail.value,offset:0,assets:[],folders:[],isLoading:!0};s.isAISearchActive&&e.detail.value&&(i.sortBy="relevance"),this.store.setState(i),this.selectionCtrl.resetRange(),this._debouncedLoadData()}_handleAISearchToggle(e){var o;const s=e.detail.active,i=this.store.getState(),a={isAISearchActive:s};i.searchQuery&&(s?a.sortBy="relevance":i.sortBy==="relevance"&&(a.sortBy=((o=this.config)==null?void 0:o.defaultSortBy)??"created_at"),a.offset=0,a.assets=[],a.folders=[],a.isLoading=!0),this.store.setState(a),i.searchQuery&&this._debouncedLoadData()}_handleViewChange(e){var i;const s=e.detail.mode;this.store.setState({viewMode:s}),(i=this.config)!=null&&i.rememberLastView&&Xa(s,this.config.auth.projectToken),this._scrollToTop()}_handleRegionalChange(e){const{groupUuid:s,value:i}=e.detail,a=this.store.getState().regionalFilters;this.store.setState({regionalFilters:{...a,[s]:i}})}_handleSortChange(e){const s=e.detail.value,i=this.store.getState();this.store.setState({sortBy:s,offset:0,assets:[],folders:[]}),Xs(s,i.sortDirection),this.selectionCtrl.resetRange(),this._loadData()}_handleSortDirectionChange(e){const s=e.detail.value,i=this.store.getState();this.store.setState({sortDirection:s,offset:0,assets:[],folders:[]}),Xs(i.sortBy,s),this.selectionCtrl.resetRange(),this._loadData()}_handleTabChange(e){var i,a;const s=e.detail.tab;(i=this.config)!=null&&i.rememberLastTab&&Ja(s,this.config.auth.projectToken),this._selectAllId++,this.store.setState({activeTab:s,activeLabelUuid:null,activeCollectionUuid:null,activeCollectionFolders:[],activeCollectionFolder:null,isLoadingCollectionFolders:!1,currentFolder:null,currentFolderPath:((a=this.config)==null?void 0:a.rootFolderPath)??"/",breadcrumb:[],offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData()}_handleAssetSelect(e){this.selectionCtrl.handleSelect(e.detail.asset,e.detail.index,e.detail.event)}_handleFolderSelect(e){this.selectionCtrl.handleFolderSelect(e.detail.folder,e.detail.index,e.detail.event)}_handleAssetPreview(e){this.store.setState({previewAsset:e.detail.asset,isPreviewOpen:!0})}_handleQuickSelect(e){var i;const s=e.detail.asset;if((i=this.config)!=null&&i.transformations&&je(s)){this._transformAssets=[s],this._transformFolders=[],this._transformOpen=!0;return}this._emitSelect([s])}_emitSelect(e,s){var a,o;const i={assets:e};s!=null&&s.length&&(i.folders=s),(o=(a=this.config)==null?void 0:a.onSelect)==null||o.call(a,e,s!=null&&s.length?s:void 0),this.dispatchEvent(new CustomEvent("ap-select",{detail:i,bubbles:!0,composed:!0})),this._isInline||this.close()}_handleFolderOpen(e){var o;const s=e.detail.folder,i=this.store.getState(),a=s.path||`${i.currentFolderPath}${s.name}/`;(o=this.config)!=null&&o.rememberLastFolder&&Zs(a,this.config.auth.projectToken),this._selectAllId++,this.store.setState({currentFolder:s.uuid,currentFolderPath:a,breadcrumb:[...i.breadcrumb,{uuid:s.uuid,name:s.name,path:a}],searchQuery:"",offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData()}_handleBreadcrumbNavigate(e){var c,d;const s=e.detail.uuid,i=this.store.getState();if(i.activeTab==="labels"){this._selectAllId++,this.store.setState({activeLabelUuid:null,breadcrumb:[],searchQuery:"",offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData();return}if(i.activeTab==="collections"){if(this._selectAllId++,!s){this.store.setState({activeCollectionUuid:null,activeCollectionFolder:null,activeCollectionFolders:[],breadcrumb:[],searchQuery:"",offset:0,assets:[],folders:[],isLoading:!1}),this.selectionCtrl.resetRange();return}if(s===i.activeCollectionUuid){this.store.setState({activeCollectionFolder:null,breadcrumb:[i.breadcrumb[0]],searchQuery:"",offset:0,assets:[],folders:[],isLoading:!1}),this.selectionCtrl.resetRange();return}const h=this._findCollectionFolder(i.activeCollectionFolders,s);if(h){const u=i.breadcrumb.findIndex(p=>p.uuid===s),f=i.breadcrumb.slice(0,u+1);this.store.setState({activeCollectionFolder:h,breadcrumb:f,searchQuery:"",offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData()}return}const a=s?i.breadcrumb.findIndex(h=>h.uuid===s):-1,o=s?i.breadcrumb.slice(0,a+1):[],n=o.length>0?o[o.length-1].path:((c=this.config)==null?void 0:c.rootFolderPath)||"/";(d=this.config)!=null&&d.rememberLastFolder&&Zs(n,this.config.auth.projectToken),this._selectAllId++,this.store.setState({currentFolder:s||null,currentFolderPath:n,breadcrumb:o,offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData()}_handleLabelOpen(e){const s=e.detail.label;this._selectAllId++,this.store.setState({activeLabelUuid:s.uuid,breadcrumb:[{uuid:s.uuid,name:s.name,path:""}],searchQuery:"",offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData()}async _handleCollectionOpen(e){const s=e.detail.collection;if(this.apiClient){this._selectAllId++,this.store.setState({activeCollectionUuid:s.uuid,activeCollectionFolder:null,activeCollectionFolders:[],isLoadingCollectionFolders:!0,breadcrumb:[{uuid:s.uuid,name:s.title,path:""}],searchQuery:"",offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange();try{const i=await Vi(this.apiClient,s.uuid),a=ei(i.folders||[]);this.store.setState({activeCollectionFolders:a,isLoadingCollectionFolders:!1,isLoading:!1})}catch(i){this.store.setState({isLoadingCollectionFolders:!1,isLoading:!1}),this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:i,context:"loadCollectionFolders"},bubbles:!0,composed:!0}))}}}_handleCollectionFolderOpen(e){var c;const s=e.detail.folder,i=this.store.getState(),a=s.path.split(" -> ").filter(Boolean),o=[{uuid:i.activeCollectionUuid,name:((c=i.breadcrumb[0])==null?void 0:c.name)||"Collection",path:""}];let n="";for(const d of a)n=n?`${n} -> ${d}`:d,o.push({uuid:n,name:d,path:n});this._selectAllId++,this.store.setState({activeCollectionFolder:s,breadcrumb:o,searchQuery:"",offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData()}_findCollectionFolder(e,s){for(const i of e){if(i.path===s)return i;if(i.children){const a=this._findCollectionFolder(i.children,s);if(a)return a}}return null}_getVisibleCollectionFolders(){const e=this.store.getState();return e.activeCollectionUuid?e.activeCollectionFolder?e.activeCollectionFolder.children??[]:e.activeCollectionFolders:[]}_resolveInitialFolderPath(e){var s,i;return e==="folders"&&((s=this.config)==null?void 0:s.rememberLastFolder)&&Wa(this.config.auth.projectToken)||((i=this.config)==null?void 0:i.rootFolderPath)||"/"}_buildBreadcrumbFromPath(e,s){if(!e||e===s||e==="/")return[];const a=(e.startsWith(s)?e.slice(s.length):e.replace(/^\//,"")).split("/").filter(Boolean),o=[];let n=s.endsWith("/")?s:s+"/";for(const c of a)n+=c+"/",o.push({uuid:n,name:c,path:n});return o}_handlePreviewClose(){this.store.setState({isPreviewOpen:!1,previewAsset:null})}_handlePreviewNavigate(e){this.store.setState({previewAsset:e.detail.asset})}_handleSelectionConfirm(e){var a,o;const s=e.detail.assets,i=e.detail.folders||[];if(i.length>0&&((a=this.config)==null?void 0:a.folderSelection)!==!1&&((o=this.config)==null?void 0:o.folderSelectionMode)==="assets"){this._folderResolveOpen=!0;return}this._emitSelect(s,i.length?i:void 0)}_handleSelectionTransform(e){var o,n;const s=e.detail.assets,i=e.detail.folders||[];if(i.length>0&&((o=this.config)==null?void 0:o.folderSelection)!==!1&&((n=this.config)==null?void 0:n.folderSelectionMode)==="assets"){this._transformAfterResolve=!0,this._folderResolveOpen=!0;return}if(s.filter(je).length===0){this._emitSelect(s,i.length?i:void 0);return}this._transformAssets=s,this._transformFolders=i,this._transformOpen=!0}async _handleFolderResolveConfirm(e){var o;const s=e.detail.mode,i=this.selectionCtrl.getSelectedFolders(),a=this.selectionCtrl.getSelectedAssets();this.store.setState({isResolvingFolders:!0});try{const n=await Promise.all(i.map(p=>De(this.apiClient,{folder:p.path,recursive:s==="recursive"?1:0,limit:1e4}))),c=[];for(const p of n)c.push(...p.files);const d=[...a],h=new Set(d.map(p=>p.uuid));for(const p of c)h.has(p.uuid)||(d.push(p),h.add(p.uuid));const u=(o=this.config)==null?void 0:o.maxSelections,f=u?d.slice(0,u):d;if(this._folderResolveOpen=!1,this.store.setState({isResolvingFolders:!1}),this._transformAfterResolve){this._transformAfterResolve=!1,this._transformAssets=f,this._transformFolders=[],this._transformOpen=!0;return}this._emitSelect(f)}catch(n){this.store.setState({isResolvingFolders:!1}),this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:n,context:"folderResolve"},bubbles:!0,composed:!0}))}}_handleFolderResolveCancel(){this._folderResolveOpen=!1,this._transformAfterResolve=!1}_handleTransformConfirm(e){const s=e.detail.params,i=e.detail.isAspectLocked??!0,a=this._transformAssets,o=this._transformFolders,n=a.length>1,c=fs(s,{isMultiSelect:n,isAspectLocked:i}),d=a.map(h=>{var g,m;if(!je(h))return h;const u=(g=h.url)==null?void 0:g.cdn,f=(m=h.url)==null?void 0:m.permalink,p={cdn:u?xe(u,c):""};return f&&(p.permalink_cdn=xe(f,c)),{...h,transformation:{params:s,url:p}}});this._transformOpen=!1,this._transformAssets=[],this._transformFolders=[],this._emitSelect(d,o.length?o:void 0)}_handleTransformSkip(){const e=this._transformAssets,s=this._transformFolders;this._transformOpen=!1,this._transformAssets=[],this._transformFolders=[],this._emitSelect(e,s.length?s:void 0)}_handleTransformCancel(){this._transformOpen=!1,this._transformAssets=[],this._transformFolders=[]}async _handleSelectAll(e){var d,h,u;const s=this.store.getState();if(s.isSelectingAll||!this.apiClient||!(((d=s.config)==null?void 0:d.multiSelect)??!0))return;const a=((h=e==null?void 0:e.detail)==null?void 0:h.scope)??"all",o=a!=="assets"&&((u=this.config)==null?void 0:u.folderSelection)!==!1&&s.folders.length>0;if(!(a!=="folders")){o&&this.selectionCtrl.selectAllFolders(s.folders);return}if(s.assets.length>=s.totalCount){o&&this.selectionCtrl.selectAllFolders(s.folders),this.selectionCtrl.selectAll(s.assets);return}const c=++this._selectAllId;this.store.setState({isSelectingAll:!0});try{const f=this._buildSearchNotation();let p=s.currentFolderPath||"/";const g=s.limit,m=s.assets,_=s.totalCount;let y=s.activeTab==="folders"?0:1,C=f||void 0;if(s.activeTab==="labels"&&s.activeLabelUuid){const O=s.labels.find(X=>X.uuid===s.activeLabelUuid);O&&(C=`labels:${O.sid.replace("#","")}${f?" "+f:""}`),p="/",y=1}let x,M;s.activeTab==="collections"&&s.activeCollectionFolder&&(x=s.activeCollectionUuid||void 0,M=s.activeCollectionFolder.filters||void 0,p="",y=1);const $=[];for(let O=m.length;O<_;O+=g)$.push(O);const k=4,E=[];for(let O=0;O<$.length;O+=k){if(c!==this._selectAllId)return;const X=$.slice(O,O+k),Z=await Promise.all(X.map(D=>{var Pe;return De(this.apiClient,{...p?{folder:p}:{},offset:D,limit:g,sort_by:s.sortBy,sort_direction:s.sortDirection,search:s.searchQuery||void 0,q:C,recursive:y,...x&&{collection_uuid:x},...M&&{f64:M},...s.isAISearchActive&&s.searchQuery&&{with_ai:!0,ai_query:s.searchQuery,ai_lang:((Pe=s.config)==null?void 0:Pe.locale)??"en"}})}));if(c!==this._selectAllId)return;for(const D of Z)D.files&&E.push(...D.files)}if(c!==this._selectAllId)return;const A=new Set(m.map(O=>O.uuid)),fe=E.filter(O=>A.has(O.uuid)?!1:(A.add(O.uuid),!0)),ie=[...m,...fe];this.store.setState({assets:ie,offset:Math.max(0,ie.length-g),hasMore:!1,isSelectingAll:!1}),o&&this.selectionCtrl.selectAllFolders(s.folders),this.selectionCtrl.selectAll(ie)}catch(f){if(c!==this._selectAllId)return;this.store.setState({isSelectingAll:!1}),this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:f,context:"selectAll"},bubbles:!0,composed:!0}))}}_handleSelectionClear(){this.selectionCtrl.clearSelection()}_handleSelectionDeselect(e){const s=new Map(this.store.getState().selectedAssets);s.delete(e.detail.uuid),this.store.setState({selectedAssets:s})}_isDateFilterKey(e){return e===b.DATE||e===b.LICENSE_EXPIRY||e===G.DUE_DATE}_handleFilterUpdate(e){const{key:s,values:i,operator:a}=e.detail,n={...this.store.getState().filters};let c=i===""||i===null||i===void 0||Array.isArray(i)&&i.length===0||typeof i=="object"&&!Array.isArray(i)&&Object.values(i).every(d=>d==null||d===""||Array.isArray(d)&&d.length===0);if(!c&&this._isDateFilterKey(s)&&typeof i=="object"&&!Array.isArray(i)){const{kind:d,preset:h,from:u,to:f}=i;c=!d&&!h&&!u&&!f}if(c){const d={...n.applied};delete d[s],n.applied=d,n.pinned.includes(s)||(n.visible=n.visible.filter(h=>h!==s))}else{const d={...n.applied};this._isDateFilterKey(s)&&typeof i=="object"&&!Array.isArray(i)?d[s]={type:"date",field:i.field||"created",kind:i.kind||null,preset:i.preset||null,from:i.from||null,to:i.to||null}:s===b.IMAGE&&typeof i=="object"&&!Array.isArray(i)?d[s]=i:d[s]={type:"string",values:Array.isArray(i)?i:[i],operator:a||":"},n.applied=d,n.visible.includes(s)||(n.visible=[...n.visible,s])}if(this.store.setState({filters:n,offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange(),this._debouncedLoadData(),this._pendingFilter===s){this._pendingFilter=null;const d=this.renderRoot.querySelector("ap-filters-bar");d&&(d.pendingFilter=null)}}_handleFilterOpen(e){const s=e.detail.key,i=e.detail.chipRect,a=this.renderRoot.querySelector("ap-content-toolbar");let o,n;if(i){const c=this.renderRoot.querySelector(".toolbar-filters-wrapper");if(c){const d=c.getBoundingClientRect();o=i.left-d.left,n=i.bottom-d.top}}a==null||a.openFilterPanel(s,!0,o,n)}_handleMetadataFilterOpen(e){const{fieldKey:s,chipRect:i}=e.detail,a=this.renderRoot.querySelector("ap-content-toolbar");let o,n;if(i){const c=this.renderRoot.querySelector(".toolbar-filters-wrapper");if(c){const d=c.getBoundingClientRect();o=i.left-d.left,n=i.bottom-d.top}}a==null||a.openMetadataFieldPanel(s,!0,o,n)}_handleFilterPanelChange(e){const s=this.renderRoot.querySelector("ap-filters-bar");s&&(s.activeFilter=e.detail.key,s.activeMetadataField=e.detail.metadataFieldKey||null),!e.detail.key&&!e.detail.metadataFieldKey&&(this._pendingFilter||this._pendingMetadataField)&&(this._pendingFilter=null,this._pendingMetadataField=null,s&&(s.pendingFilter=null,s.pendingMetadataField=null))}async _handleFilterPending(e){var p,g,m;const{key:s,metadataFieldKey:i}=e.detail,a=this.renderRoot.querySelector("ap-filters-bar"),o=this.renderRoot.querySelector("ap-content-toolbar");if(!a||!o)return;i?(this._pendingMetadataField=i,a.pendingMetadataField=i):s&&(this._pendingFilter=s,a.pendingFilter=s),await a.updateComplete;let n=a.renderRoot.querySelector(".chip.pending");if(!n){const _=a.renderRoot.querySelectorAll(".chip.pinned-empty"),y=i?(p=a._getMetadataLabel)==null?void 0:p.call(a,i):void 0;for(const C of _){const x=(m=(g=C.querySelector(".chip-label"))==null?void 0:g.textContent)==null?void 0:m.trim();if(i&&x===y){n=C;break}if(s&&x===(et[s]||s)){n=C;break}}}if(!n)return;const c=n.getBoundingClientRect(),d=this.renderRoot.querySelector(".toolbar-filters-wrapper"),h=d==null?void 0:d.getBoundingClientRect(),u=h?c.left-h.left:c.left,f=h?c.bottom-h.top:void 0;i?o.openMetadataFieldPanel(i,!0,u,f):s&&o.openFilterPanel(s,!0,u,f)}_handleFilterRemove(e){var n;const s=e.detail.key;if(s in(((n=this.config)==null?void 0:n.forcedFilters)??{}))return;const a={...this.store.getState().filters},o={...a.applied};delete o[s],a.applied=o,a.pinned.includes(s)||(a.visible=a.visible.filter(c=>c!==s)),this.store.setState({filters:a,offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange(),this._debouncedLoadData()}_handleMetadataFilterChange(e){const{fieldKey:s,operator:i,values:a,metadataType:o}=e.detail,c={...this.store.getState().filters},d={...c.metadata},h={...d.applied};if(!a||Array.isArray(a)&&a.length===0?(delete h[s],d.applied=h,d.pinned.includes(s)||(d.visible=d.visible.filter(f=>f!==s))):(h[s]={type:"string",values:Array.isArray(a)?a:[a],operator:i||":",metadataType:o},d.applied=h,d.visible.includes(s)||(d.visible=[...d.visible,s])),c.metadata=d,this.store.setState({filters:c,offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange(),this._debouncedLoadData(),this._pendingMetadataField===s){this._pendingMetadataField=null;const f=this.renderRoot.querySelector("ap-filters-bar");f&&(f.pendingMetadataField=null)}}_handleMetadataFieldToggle(e){const{fieldKey:s,visible:i}=e.detail,o={...this.store.getState().filters},n={...o.metadata};i?n.visible.includes(s)||(n.visible=[...n.visible,s]):n.visible=n.visible.filter(c=>c!==s),o.metadata=n,this.store.setState({filters:o})}_handleMetadataFilterRemove(e){const{fieldKey:s}=e.detail,a={...this.store.getState().filters},o={...a.metadata},n={...o.applied};delete n[s],o.applied=n,o.pinned.includes(s)||(o.visible=o.visible.filter(c=>c!==s)),a.metadata=o,this.store.setState({filters:a,offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange(),this._debouncedLoadData()}_handleFilterPin(e){var c,d;const{key:s,pinned:i}=e.detail,o={...this.store.getState().filters};i?o.pinned.includes(s)||(o.pinned=[...o.pinned,s]):(o.pinned=o.pinned.filter(h=>h!==s),s in o.applied||(o.visible=o.visible.filter(h=>h!==s))),this.store.setState({filters:o});const n=((d=(c=this.store.getState().config)==null?void 0:c.auth)==null?void 0:d.projectToken)??null;Ka(n,o.pinned)}_handleMetadataPin(e){var d,h;const{fieldKey:s,pinned:i}=e.detail,o={...this.store.getState().filters},n={...o.metadata};i?n.pinned.includes(s)||(n.pinned=[...n.pinned,s]):(n.pinned=n.pinned.filter(u=>u!==s),s in n.applied||(n.visible=n.visible.filter(u=>u!==s))),o.metadata=n,this.store.setState({filters:o});const c=((h=(d=this.store.getState().config)==null?void 0:d.auth)==null?void 0:h.projectToken)??null;Qa(c,n.pinned)}_handleFiltersClearAll(){const e=this.store.getState();this.store.setState({filters:{...e.filters,applied:{},visible:[...e.filters.pinned],metadata:{...e.filters.metadata,applied:{},visible:[...e.filters.metadata.pinned]}},offset:0,assets:[],folders:[],isLoading:!0});const s=this.renderRoot.querySelector("ap-filters-bar");s&&(s.activeFilter=null),this.selectionCtrl.resetRange(),this._debouncedLoadData()}_handleFilterDeactivate(e){const s=e.detail.key,a={...this.store.getState().filters};a.visible=a.visible.filter(o=>o!==s),this.store.setState({filters:a})}_handleMetadataFieldDeactivate(e){const{fieldKey:s}=e.detail,a={...this.store.getState().filters},o={...a.metadata};o.visible=o.visible.filter(n=>n!==s),a.metadata=o,this.store.setState({filters:a})}_handleFiltersSet(e){var h;const{applied:s,metadata:i}=e.detail,o={...this.store.getState().filters},n=new Set(Object.keys(((h=this.config)==null?void 0:h.forcedFilters)??{})),c={...s};for(const u of n)delete c[u];o.applied=c;const d=Object.keys(s);if(o.visible=[...new Set([...o.pinned,...d])],i){const u={...o.metadata};u.applied=i.applied;const f=Object.keys(i.applied);u.visible=[...new Set([...u.pinned,...f])],o.metadata=u}this.store.setState({filters:o,offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange(),this._debouncedLoadData()}_getSortOptions(){var s;const e=this.storeCtrl.state;if(e.activeTab==="labels"&&!e.activeLabelUuid)return no;if(e.activeTab==="collections"){if(!e.activeCollectionUuid)return lo;if(!(e.activeCollectionFolder&&!((s=e.activeCollectionFolder.children)!=null&&s.length)))return co}return e.searchQuery?oo:e.activeTab==="folders"?ro:ms}_buildSearchNotation(){const e=this.store.getState(),s={...this._normalizedForcedFilters,...e.filters.applied};return La(s,e.filters.metadata.applied).join(" ")}render(){var p,g,m,_,y,C,x,M,$,k,E,A,fe,ie,O,X,Z,D;const e=this.storeCtrl.state,s=Array.from(e.selectedAssets.keys()),i=Array.from(e.selectedFolders.keys()),a=this.selectionCtrl.getSelectedAssets(),o=this.selectionCtrl.getSelectedFolders(),n=((p=this.config)==null?void 0:p.folderSelection)!==!1,c=r.html`
7243
+ `];$i([l.property()],qt.prototype,"text",2);qt=$i([l.customElement("ap-tooltip")],qt);var nn=Object.defineProperty,Et=(t,e,s,i)=>{for(var a=void 0,o=t.length-1,n;o>=0;o--)(n=t[o])&&(a=n(e,s,a)||a);return a&&nn(e,s,a),a};const Ts=class Ts extends r.LitElement{constructor(){super(),this._initFailed=!1,this._loadId=0,this._loadMoreId=0,this._selectAllId=0,this._loadDataTimer=null,this._pendingFilter=null,this._pendingMetadataField=null,this._normalizedForcedFilters={},this._uploaderEl=null,this._uploaderImportPromise=null,this._dragCounter=0,this._isDragOver=!1,this._isUploaderOpen=!1,this._folderResolveOpen=!1,this._transformOpen=!1,this._transformAssets=[],this._transformFolders=[],this._transformAfterResolve=!1,this._onDragEnter=e=>{var s;!((s=this.config)!=null&&s.uploader)||!this._hasFileTransfer(e)||(e.preventDefault(),this._dragCounter++,this._dragCounter===1&&(this._isDragOver=!0))},this._onDragOver=e=>{var s;!((s=this.config)!=null&&s.uploader)||!this._hasFileTransfer(e)||(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"))},this._onDragLeave=e=>{var s;!((s=this.config)!=null&&s.uploader)||!this._hasFileTransfer(e)||(e.preventDefault(),this._dragCounter--,this._dragCounter<=0&&(this._dragCounter=0,this._isDragOver=!1))},this._onDrop=e=>{var i,a;if(!((i=this.config)!=null&&i.uploader)||!this._hasFileTransfer(e))return;e.preventDefault(),this._dragCounter=0,this._isDragOver=!1;const s=Array.from(((a=e.dataTransfer)==null?void 0:a.files)??[]);s.length>0&&this._openUploader(s)},this.store=Oi(),this.storeCtrl=new Mi(this,this.store),this.selectionCtrl=new Pi(this,this.store),this.infiniteScrollCtrl=new Di(this,()=>this._loadMore()),this.marqueeCtrl=new zi(this,this.store)}get _isInline(){var e;return((e=this.config)==null?void 0:e.displayMode)==="inline"}disconnectedCallback(){super.disconnectedCallback(),this._uploaderEl&&(this._uploaderEl.remove(),this._uploaderEl=null),this._uploaderImportPromise=null,this._dragCounter=0,this._isDragOver=!1,this._isUploaderOpen=!1}updated(e){super.updated(e),e.has("config")&&this.config&&this._initConfig(this.config);const s=this.renderRoot.querySelector("#sentinel");if(s&&s!==this._lastSentinel){this._lastSentinel=s;const a=this.renderRoot.querySelector(".main-content");this.infiniteScrollCtrl.observe(s,a)}const i=this.renderRoot.querySelector(".main-content");i&&i!==this._lastMarqueeContainer&&(this._lastMarqueeContainer=i,this.marqueeCtrl.attach(i))}_initConfig(e){const s={folderSelection:!0,...e};this._initFailed=!1,this._normalizedForcedFilters=ps(s.forcedFilters),this._initPromise=this._doInit(s).catch(()=>{this._initFailed=!0}),this.toggleAttribute("inline",s.displayMode==="inline"),s.displayMode==="inline"&&!this.store.getState().isOpen&&this.open()}async _doInit(e){const s=Ya(),i=s.sortBy??e.defaultSortBy??"created_at",a=s.sortDirection??e.defaultSortDirection??"desc";this.store.setState({config:e,projectToken:e.auth.projectToken,viewMode:e.rememberLastView&&Za(e.auth.projectToken)||e.defaultViewMode||"grid",sortBy:i,sortDirection:a}),this.apiClient=new Ri(e.auth,e.apiBase);try{if(e.auth.mode==="securityTemplate"){const x=await Gi(this.apiClient);this.apiClient.setSassKey(x),this.store.setState({sassKey:x})}const[o,n,c,d,h]=await Promise.allSettled([Ea(this.apiClient),Bi(this.apiClient),Hi(this.apiClient),Ca(this.apiClient),qi(this.apiClient)]),u={};if(o.status==="fulfilled"){const{fields:x,regionalVariantGroups:_,regionalFilters:w,brandColor:y}=o.value;u.metadataFields=x,u.regionalVariantGroups=_,u.regionalFilters=w,y&&(u.brandColor=y)}n.status==="fulfilled"&&(u.labels=n.value.labels||[]),c.status==="fulfilled"&&(u.tags=c.value),h.status==="fulfilled"&&(u.collections=h.value.collections||[]),d.status==="fulfilled"&&(u.fileTypes=d.value);const{pinnedFilters:g,pinnedMetadata:p}=Ga(e.auth.projectToken??null),f=this.store.getState().filters;u.filters={...f,pinned:g,visible:[...g],metadata:{...f.metadata,pinned:p,visible:[...p]}},this.store.setState(u);const m=e.brandColor||u.brandColor||this.store.getState().brandColor;m&&(u.brandColor||this.store.setState({brandColor:m}),ao(this,m))}catch(o){throw this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:o,context:"init"},bubbles:!0,composed:!0})),o}}_ensureUploaderImport(){return customElements.get("sfx-uploader")?Promise.resolve():this._uploaderImportPromise?this._uploaderImportPromise:(this._uploaderImportPromise=import("@scaleflex/uploader/define").then(()=>{},e=>{throw this._uploaderImportPromise=null,e}),this._uploaderImportPromise)}_buildUploaderConfig(){const e=this.config,s=e.uploader,i=this.store.getState();let a;return e.auth.mode==="securityTemplate"?a={mode:"security-template",container:e.auth.projectToken,securityTemplateId:e.auth.securityTemplateKey}:a={mode:"sass-key",container:e.auth.projectToken,sassKey:e.auth.sassKey},{auth:a,targetFolder:i.currentFolderPath||"/",mode:"inline",restrictions:s.restrictions,concurrency:s.concurrency,autoProceed:s.autoProceed,showFillMetadata:s.showFillMetadata,connectors:s.connectors,sourcesLayout:s.sourcesLayout,header:s.header??"back",clearOnClose:s.clearOnClose,clearOnComplete:s.clearOnComplete,closeOnComplete:s.closeOnComplete,rejectedFileAutoRemoveDelay:s.rejectedFileAutoRemoveDelay,lastUploadReview:s.lastUploadReview,showLocateButton:s.showLocateButton,showCopyCdnButton:s.showCopyCdnButton,getLocateUrl:s.getLocateUrl,minimizeOnUpload:s.minimizeOnUpload,metadataConfig:s.metadataConfig,tusConfig:s.tusConfig}}async _openUploader(e){var i;if(!((i=this.config)!=null&&i.uploader)||this._isUploaderOpen)return;try{await this._ensureUploaderImport()}catch(a){this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:a instanceof Error?a:new Error(String(a)),context:"uploader-load"},bubbles:!0,composed:!0}));return}this._uploaderEl=document.createElement("sfx-uploader");const s=this._uploaderEl;s.addEventListener("sfx-all-complete",()=>{this.store.getState().isOpen&&this._loadData()}),s.addEventListener("sfx-complete-action",()=>{this._closeUploader()}),s.addEventListener("sfx-cancel",()=>{this._closeUploader()}),this._isUploaderOpen=!0,await this.updateComplete,s.config=this._buildUploaderConfig(),await s.updateComplete,e!=null&&e.length&&s.addFiles(e)}_closeUploader(){this._isUploaderOpen=!1,this._uploaderEl&&(this._uploaderEl.remove(),this._uploaderEl=null)}_handleUploadClick(){this._openUploader()}_hasFileTransfer(e){var s,i;return!!((i=(s=e.dataTransfer)==null?void 0:s.types)!=null&&i.includes("Files"))}async open(){var h,u,g,p,f,m,x;const e=this.store.getState(),s=new Set(Object.keys(this._normalizedForcedFilters)),i={},a=ps((h=this.config)==null?void 0:h.defaultFilters);for(const[_,w]of Object.entries(a))s.has(_)||(i[_]=w);const o=Object.keys(i),n=((u=this.config)==null?void 0:u.tabs)??["assets","folders"],c=(g=this.config)!=null&&g.rememberLastTab?eo(this.config.auth.projectToken):null,d=(c&&n.includes(c)?c:null)??((p=this.config)!=null&&p.defaultTab&&n.includes(this.config.defaultTab)?this.config.defaultTab:null)??n[0]??"assets";this.store.setState({isOpen:!0,activeTab:d,searchQuery:"",isAISearchActive:!!((f=this.config)!=null&&f.enableAISearch&&((m=this.config)!=null&&m.defaultAISearch)),filters:{metadata:{pinned:e.filters.metadata.pinned,visible:[...e.filters.metadata.pinned],applied:{}},pinned:e.filters.pinned,visible:[...new Set([...e.filters.pinned,...o])],applied:i},offset:0,assets:[],folders:[],currentFolder:null,currentFolderPath:this._resolveInitialFolderPath(d),activeLabelUuid:null,activeCollectionUuid:null,activeCollectionFolders:[],activeCollectionFolder:null,isLoadingCollectionFolders:!1,breadcrumb:this._buildBreadcrumbFromPath(this._resolveInitialFolderPath(d),((x=this.config)==null?void 0:x.rootFolderPath)||"/"),selectedAssets:new Map,selectedFolders:new Map,isResolvingFolders:!1,folderPreviews:{},isPreviewOpen:!1,previewAsset:null,isLoading:!0,isSelectingAll:!1}),this._dragCounter=0,this._isDragOver=!1,this.dispatchEvent(new CustomEvent("ap-open",{detail:{timestamp:Date.now()},bubbles:!0,composed:!0})),await this.updateComplete,!this._initPromise&&this.config&&this._initConfig(this.config),!(this._initPromise&&(await this._initPromise,this._initFailed))&&this._loadData()}close(){this.store.setState({isOpen:!1}),this._dragCounter=0,this._isDragOver=!1,this._isUploaderOpen=!1,this._folderResolveOpen=!1,this._transformOpen=!1,this._transformAssets=[],this._transformFolders=[],this._transformAfterResolve=!1,this._selectAllId++}_scrollToTop(){var e;(e=this.renderRoot.querySelector(".main-content"))==null||e.scrollTo({top:0})}async _loadData(){var i,a,o,n,c,d,h,u,g,p,f,m,x,_,w,y,T,k,S,F,E,fe,ie,M,X,Z,D,Pe,Ls,Os,Ms,Is,Ps,Ds,zs,Rs,js,Ns,Us;if(!this.apiClient)return;const e=++this._loadId,s=this.store.getState();this._scrollToTop(),this.store.setState({isLoading:!0});try{const Xe=s.activeTab;if(Xe==="assets"){const ae=this._buildSearchNotation(),Ae=s.currentFolderPath||"/",he=s.isAISearchActive&&!!s.searchQuery,oe=De(this.apiClient,{folder:Ae,offset:0,limit:s.limit,sort_by:s.sortBy,sort_direction:s.sortDirection,search:s.searchQuery||void 0,q:ae||void 0,recursive:1,...he&&{with_ai:!0,ai_query:s.searchQuery,ai_lang:((i=s.config)==null?void 0:i.locale)??"en"}}),H=At(this.apiClient,{folder:Ae,q:ae||void 0,search:s.searchQuery||void 0,recursive:1,...he&&{with_ai:!0,ai_query:s.searchQuery,ai_lang:((a=s.config)==null?void 0:a.locale)??"en"}}).catch(()=>null),[B,J]=await Promise.all([oe,H]);if(e!==this._loadId)return;const ee=((o=B.files)==null?void 0:o.length)??0,j=ee>=s.limit,te=((n=J==null?void 0:J.stats)==null?void 0:n.approx_files_count)??((c=J==null?void 0:J.info)==null?void 0:c.total_files_count)??((d=B.info)==null?void 0:d.total_files_count)??((u=(h=B.base)==null?void 0:h.count)==null?void 0:u.files_recursive)??((p=(g=B.base)==null?void 0:g.count)==null?void 0:p.files_direct)??ee;this.store.setState({assets:B.files||[],folders:[],totalCount:te,totalFolderCount:0,offset:0,hasMore:j,isLoading:!1})}else if(Xe==="folders"){const ae=this._buildSearchNotation(),Ae=s.currentFolderPath||"/",[he,oe,H]=await Promise.all([Ni(this.apiClient,{folderPath:s.currentFolderPath,q:s.searchQuery||void 0,recursive:s.searchQuery?1:0,sort_by:s.sortBy,sort_direction:s.sortDirection}),De(this.apiClient,{folder:Ae,offset:0,limit:s.limit,sort_by:s.sortBy,sort_direction:s.sortDirection,search:s.searchQuery||void 0,q:ae||void 0,recursive:0,...s.isAISearchActive&&s.searchQuery&&{with_ai:!0,ai_query:s.searchQuery,ai_lang:((f=s.config)==null?void 0:f.locale)??"en"}}),At(this.apiClient,{folder:Ae,q:ae||void 0,search:s.searchQuery||void 0,recursive:0,...s.isAISearchActive&&s.searchQuery&&{with_ai:!0,ai_query:s.searchQuery,ai_lang:((m=s.config)==null?void 0:m.locale)??"en"}}).catch(()=>null)]);if(e!==this._loadId)return;const B=he.folders||[];let J={};if(B.length>0)try{J=await Ui(this.apiClient,B.map(Ze=>Ze.uuid))}catch{}if(e!==this._loadId)return;const ee=((x=oe.files)==null?void 0:x.length)??0,j=ee>=s.limit,te=((_=H==null?void 0:H.stats)==null?void 0:_.approx_files_count)??((w=H==null?void 0:H.info)==null?void 0:w.total_files_count)??((y=oe.info)==null?void 0:y.total_files_count)??((k=(T=oe.base)==null?void 0:T.count)==null?void 0:k.files_direct)??ee;this.store.setState({assets:oe.files||[],folders:B,folderPreviews:J,totalCount:te,totalFolderCount:he.total??B.length,offset:0,hasMore:j,isLoading:!1})}else if(Xe==="labels"){if(!s.activeLabelUuid){this.store.setState({assets:[],folders:[],totalCount:s.labels.length,totalFolderCount:0,offset:0,hasMore:!1,isLoading:!1});return}const ae=s.labels.find(Zt=>Zt.uuid===s.activeLabelUuid);if(!ae){this.store.setState({isLoading:!1});return}const Ae=ae.sid.replace("#",""),he=this._buildSearchNotation(),oe=`labels:${Ae}${he?" "+he:""}`,H=s.isAISearchActive&&!!s.searchQuery,B=De(this.apiClient,{folder:"/",offset:0,limit:s.limit,sort_by:s.sortBy,sort_direction:s.sortDirection,search:s.searchQuery||void 0,q:oe,recursive:1,...H&&{with_ai:!0,ai_query:s.searchQuery,ai_lang:((S=s.config)==null?void 0:S.locale)??"en"}}),J=At(this.apiClient,{folder:"/",q:oe,search:s.searchQuery||void 0,recursive:1,...H&&{with_ai:!0,ai_query:s.searchQuery,ai_lang:((F=s.config)==null?void 0:F.locale)??"en"}}).catch(()=>null),[ee,j]=await Promise.all([B,J]);if(e!==this._loadId)return;const te=((E=ee.files)==null?void 0:E.length)??0,Ze=te>=s.limit,Xt=((fe=j==null?void 0:j.stats)==null?void 0:fe.approx_files_count)??((ie=j==null?void 0:j.info)==null?void 0:ie.total_files_count)??((M=ee.info)==null?void 0:M.total_files_count)??((Z=(X=ee.base)==null?void 0:X.count)==null?void 0:Z.files_recursive)??((Pe=(D=ee.base)==null?void 0:D.count)==null?void 0:Pe.files_direct)??te;this.store.setState({assets:ee.files||[],folders:[],totalCount:Xt,totalFolderCount:0,offset:0,hasMore:Ze,isLoading:!1})}else if(Xe==="collections"){if(!s.activeCollectionUuid){this.store.setState({assets:[],folders:[],totalCount:0,totalFolderCount:0,offset:0,hasMore:!1,isLoading:!1});return}const ae=s.activeCollectionFolder;if(!(ae&&!((Ls=ae.children)!=null&&Ls.length))){this.store.setState({assets:[],folders:[],totalCount:0,totalFolderCount:0,offset:0,hasMore:!1,isLoading:!1});return}const he=s.activeCollectionUuid,oe=ae.filters||void 0,H=this._buildSearchNotation(),B=s.isAISearchActive&&!!s.searchQuery,J=De(this.apiClient,{offset:0,limit:s.limit,sort_by:s.sortBy,sort_direction:s.sortDirection,search:s.searchQuery||void 0,q:H||void 0,recursive:1,collection_uuid:he,f64:oe,...B&&{with_ai:!0,ai_query:s.searchQuery,ai_lang:((Os=s.config)==null?void 0:Os.locale)??"en"}}),ee=At(this.apiClient,{q:H||void 0,search:s.searchQuery||void 0,recursive:1,collection_uuid:he,f64:oe,...B&&{with_ai:!0,ai_query:s.searchQuery,ai_lang:((Ms=s.config)==null?void 0:Ms.locale)??"en"}}).catch(()=>null),[j,te]=await Promise.all([J,ee]);if(e!==this._loadId)return;const Ze=((Is=j.files)==null?void 0:Is.length)??0,Xt=Ze>=s.limit,Zt=((Ps=te==null?void 0:te.stats)==null?void 0:Ps.approx_files_count)??((Ds=te==null?void 0:te.info)==null?void 0:Ds.total_files_count)??((zs=j.info)==null?void 0:zs.total_files_count)??((js=(Rs=j.base)==null?void 0:Rs.count)==null?void 0:js.files_recursive)??((Us=(Ns=j.base)==null?void 0:Ns.count)==null?void 0:Us.files_direct)??Ze;this.store.setState({assets:j.files||[],folders:[],totalCount:Zt,totalFolderCount:0,offset:0,hasMore:Xt,isLoading:!1})}}catch(Xe){if(e!==this._loadId)return;this.store.setState({isLoading:!1}),this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:Xe,context:"loadData"},bubbles:!0,composed:!0}))}}async _loadMore(){var a,o;const e=this.store.getState();if(e.isLoading||!e.hasMore||!this.apiClient||e.activeTab==="labels"&&!e.activeLabelUuid||e.activeTab==="collections"&&!(e.activeCollectionFolder&&!((a=e.activeCollectionFolder.children)!=null&&a.length)))return;const s=++this._loadMoreId,i=e.offset+e.limit;this.store.setState({isLoading:!0});try{const n=this._buildSearchNotation();let c=n||void 0,d=e.currentFolderPath||"/",h=e.activeTab==="folders"?0:1;if(e.activeTab==="labels"&&e.activeLabelUuid){const w=e.labels.find(y=>y.uuid===e.activeLabelUuid);w&&(c=`labels:${w.sid.replace("#","")}${n?" "+n:""}`),d="/",h=1}let u,g;e.activeTab==="collections"&&e.activeCollectionFolder&&(u=e.activeCollectionUuid||void 0,g=e.activeCollectionFolder.filters||void 0,d="",h=1);const p=await De(this.apiClient,{...d?{folder:d}:{},offset:i,limit:e.limit,sort_by:e.sortBy,sort_direction:e.sortDirection,search:e.searchQuery||void 0,q:c,recursive:h,...u&&{collection_uuid:u},...g&&{f64:g},...e.isAISearchActive&&e.searchQuery&&{with_ai:!0,ai_query:e.searchQuery,ai_lang:((o=e.config)==null?void 0:o.locale)??"en"}});if(s!==this._loadMoreId)return;const f=this.store.getState().assets,m=p.files||[],x=m.length>=e.limit,_=[...f,...m];this.store.setState({assets:_,offset:i,hasMore:x,isLoading:!1})}catch{if(s!==this._loadMoreId)return;this.store.setState({isLoading:!1})}}_debouncedLoadData(e=120){this._loadDataTimer&&clearTimeout(this._loadDataTimer),this._loadDataTimer=setTimeout(()=>{this._loadDataTimer=null,this._loadData()},e)}_handleCancel(e){var s,i;this.close(),(i=(s=this.config)==null?void 0:s.onCancel)==null||i.call(s),this.dispatchEvent(new CustomEvent("ap-cancel",{detail:{reason:e},bubbles:!0,composed:!0}))}_handleSearchChange(e){var a;const s=this.store.getState();if(s.activeTab==="labels"&&!s.activeLabelUuid){this.store.setState({searchQuery:e.detail.value});return}if(s.activeTab==="collections"&&!(s.activeCollectionFolder&&!((a=s.activeCollectionFolder.children)!=null&&a.length))){this.store.setState({searchQuery:e.detail.value});return}const i={searchQuery:e.detail.value,offset:0,assets:[],folders:[],isLoading:!0};s.isAISearchActive&&e.detail.value&&(i.sortBy="relevance"),this.store.setState(i),this.selectionCtrl.resetRange(),this._debouncedLoadData()}_handleAISearchToggle(e){var o;const s=e.detail.active,i=this.store.getState(),a={isAISearchActive:s};i.searchQuery&&(s?a.sortBy="relevance":i.sortBy==="relevance"&&(a.sortBy=((o=this.config)==null?void 0:o.defaultSortBy)??"created_at"),a.offset=0,a.assets=[],a.folders=[],a.isLoading=!0),this.store.setState(a),i.searchQuery&&this._debouncedLoadData()}_handleViewChange(e){var i;const s=e.detail.mode;this.store.setState({viewMode:s}),(i=this.config)!=null&&i.rememberLastView&&Xa(s,this.config.auth.projectToken),this._scrollToTop()}_handleRegionalChange(e){const{groupUuid:s,value:i}=e.detail,a=this.store.getState().regionalFilters;this.store.setState({regionalFilters:{...a,[s]:i}})}_handleSortChange(e){const s=e.detail.value,i=this.store.getState();this.store.setState({sortBy:s,offset:0,assets:[],folders:[]}),Xs(s,i.sortDirection),this.selectionCtrl.resetRange(),this._loadData()}_handleSortDirectionChange(e){const s=e.detail.value,i=this.store.getState();this.store.setState({sortDirection:s,offset:0,assets:[],folders:[]}),Xs(i.sortBy,s),this.selectionCtrl.resetRange(),this._loadData()}_handleTabChange(e){var i,a;const s=e.detail.tab;(i=this.config)!=null&&i.rememberLastTab&&Ja(s,this.config.auth.projectToken),this._selectAllId++,this.store.setState({activeTab:s,activeLabelUuid:null,activeCollectionUuid:null,activeCollectionFolders:[],activeCollectionFolder:null,isLoadingCollectionFolders:!1,currentFolder:null,currentFolderPath:((a=this.config)==null?void 0:a.rootFolderPath)??"/",breadcrumb:[],offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData()}_handleAssetSelect(e){this.selectionCtrl.handleSelect(e.detail.asset,e.detail.index,e.detail.event)}_handleFolderSelect(e){this.selectionCtrl.handleFolderSelect(e.detail.folder,e.detail.index,e.detail.event)}_handleAssetPreview(e){this.store.setState({previewAsset:e.detail.asset,isPreviewOpen:!0})}_handleQuickSelect(e){var i;const s=e.detail.asset;if((i=this.config)!=null&&i.transformations&&je(s)){this._transformAssets=[s],this._transformFolders=[],this._transformOpen=!0;return}this._emitSelect([s])}_emitSelect(e,s){var a,o;const i={assets:e};s!=null&&s.length&&(i.folders=s),(o=(a=this.config)==null?void 0:a.onSelect)==null||o.call(a,e,s!=null&&s.length?s:void 0),this.dispatchEvent(new CustomEvent("ap-select",{detail:i,bubbles:!0,composed:!0})),this._isInline||this.close()}_handleFolderOpen(e){var o;const s=e.detail.folder,i=this.store.getState(),a=s.path||`${i.currentFolderPath}${s.name}/`;(o=this.config)!=null&&o.rememberLastFolder&&Zs(a,this.config.auth.projectToken),this._selectAllId++,this.store.setState({currentFolder:s.uuid,currentFolderPath:a,breadcrumb:[...i.breadcrumb,{uuid:s.uuid,name:s.name,path:a}],searchQuery:"",offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData()}_handleBreadcrumbNavigate(e){var c,d;const s=e.detail.uuid,i=this.store.getState();if(i.activeTab==="labels"){this._selectAllId++,this.store.setState({activeLabelUuid:null,breadcrumb:[],searchQuery:"",offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData();return}if(i.activeTab==="collections"){if(this._selectAllId++,!s){this.store.setState({activeCollectionUuid:null,activeCollectionFolder:null,activeCollectionFolders:[],breadcrumb:[],searchQuery:"",offset:0,assets:[],folders:[],isLoading:!1}),this.selectionCtrl.resetRange();return}if(s===i.activeCollectionUuid){this.store.setState({activeCollectionFolder:null,breadcrumb:[i.breadcrumb[0]],searchQuery:"",offset:0,assets:[],folders:[],isLoading:!1}),this.selectionCtrl.resetRange();return}const h=this._findCollectionFolder(i.activeCollectionFolders,s);if(h){const u=i.breadcrumb.findIndex(p=>p.uuid===s),g=i.breadcrumb.slice(0,u+1);this.store.setState({activeCollectionFolder:h,breadcrumb:g,searchQuery:"",offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData()}return}const a=s?i.breadcrumb.findIndex(h=>h.uuid===s):-1,o=s?i.breadcrumb.slice(0,a+1):[],n=o.length>0?o[o.length-1].path:((c=this.config)==null?void 0:c.rootFolderPath)||"/";(d=this.config)!=null&&d.rememberLastFolder&&Zs(n,this.config.auth.projectToken),this._selectAllId++,this.store.setState({currentFolder:s||null,currentFolderPath:n,breadcrumb:o,offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData()}_handleLabelOpen(e){const s=e.detail.label;this._selectAllId++,this.store.setState({activeLabelUuid:s.uuid,breadcrumb:[{uuid:s.uuid,name:s.name,path:""}],searchQuery:"",offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData()}async _handleCollectionOpen(e){const s=e.detail.collection;if(this.apiClient){this._selectAllId++,this.store.setState({activeCollectionUuid:s.uuid,activeCollectionFolder:null,activeCollectionFolders:[],isLoadingCollectionFolders:!0,breadcrumb:[{uuid:s.uuid,name:s.title,path:""}],searchQuery:"",offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange();try{const i=await Vi(this.apiClient,s.uuid),a=ei(i.folders||[]);this.store.setState({activeCollectionFolders:a,isLoadingCollectionFolders:!1,isLoading:!1})}catch(i){this.store.setState({isLoadingCollectionFolders:!1,isLoading:!1}),this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:i,context:"loadCollectionFolders"},bubbles:!0,composed:!0}))}}}_handleCollectionFolderOpen(e){var c;const s=e.detail.folder,i=this.store.getState(),a=s.path.split(" -> ").filter(Boolean),o=[{uuid:i.activeCollectionUuid,name:((c=i.breadcrumb[0])==null?void 0:c.name)||"Collection",path:""}];let n="";for(const d of a)n=n?`${n} -> ${d}`:d,o.push({uuid:n,name:d,path:n});this._selectAllId++,this.store.setState({activeCollectionFolder:s,breadcrumb:o,searchQuery:"",offset:0,assets:[],folders:[]}),this.selectionCtrl.resetRange(),this._loadData()}_findCollectionFolder(e,s){for(const i of e){if(i.path===s)return i;if(i.children){const a=this._findCollectionFolder(i.children,s);if(a)return a}}return null}_getVisibleCollectionFolders(){const e=this.store.getState();return e.activeCollectionUuid?e.activeCollectionFolder?e.activeCollectionFolder.children??[]:e.activeCollectionFolders:[]}_resolveInitialFolderPath(e){var s,i;return e==="folders"&&((s=this.config)==null?void 0:s.rememberLastFolder)&&Wa(this.config.auth.projectToken)||((i=this.config)==null?void 0:i.rootFolderPath)||"/"}_buildBreadcrumbFromPath(e,s){if(!e||e===s||e==="/")return[];const a=(e.startsWith(s)?e.slice(s.length):e.replace(/^\//,"")).split("/").filter(Boolean),o=[];let n=s.endsWith("/")?s:s+"/";for(const c of a)n+=c+"/",o.push({uuid:n,name:c,path:n});return o}_handlePreviewClose(){this.store.setState({isPreviewOpen:!1,previewAsset:null})}_handlePreviewNavigate(e){this.store.setState({previewAsset:e.detail.asset})}_handleSelectionConfirm(e){var a,o;const s=e.detail.assets,i=e.detail.folders||[];if(i.length>0&&((a=this.config)==null?void 0:a.folderSelection)!==!1&&((o=this.config)==null?void 0:o.folderSelectionMode)==="assets"){this._folderResolveOpen=!0;return}this._emitSelect(s,i.length?i:void 0)}_handleSelectionTransform(e){var o,n;const s=e.detail.assets,i=e.detail.folders||[];if(i.length>0&&((o=this.config)==null?void 0:o.folderSelection)!==!1&&((n=this.config)==null?void 0:n.folderSelectionMode)==="assets"){this._transformAfterResolve=!0,this._folderResolveOpen=!0;return}if(s.filter(je).length===0){this._emitSelect(s,i.length?i:void 0);return}this._transformAssets=s,this._transformFolders=i,this._transformOpen=!0}async _handleFolderResolveConfirm(e){var o;const s=e.detail.mode,i=this.selectionCtrl.getSelectedFolders(),a=this.selectionCtrl.getSelectedAssets();this.store.setState({isResolvingFolders:!0});try{const n=await Promise.all(i.map(p=>De(this.apiClient,{folder:p.path,recursive:s==="recursive"?1:0,limit:1e4}))),c=[];for(const p of n)c.push(...p.files);const d=[...a],h=new Set(d.map(p=>p.uuid));for(const p of c)h.has(p.uuid)||(d.push(p),h.add(p.uuid));const u=(o=this.config)==null?void 0:o.maxSelections,g=u?d.slice(0,u):d;if(this._folderResolveOpen=!1,this.store.setState({isResolvingFolders:!1}),this._transformAfterResolve){this._transformAfterResolve=!1,this._transformAssets=g,this._transformFolders=[],this._transformOpen=!0;return}this._emitSelect(g)}catch(n){this.store.setState({isResolvingFolders:!1}),this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:n,context:"folderResolve"},bubbles:!0,composed:!0}))}}_handleFolderResolveCancel(){this._folderResolveOpen=!1,this._transformAfterResolve=!1}_handleTransformConfirm(e){const s=e.detail.params,i=e.detail.isAspectLocked??!0,a=this._transformAssets,o=this._transformFolders,n=a.length>1,c=fs(s,{isMultiSelect:n,isAspectLocked:i}),d=a.map(h=>{var f,m;if(!je(h))return h;const u=(f=h.url)==null?void 0:f.cdn,g=(m=h.url)==null?void 0:m.permalink,p={cdn:u?xe(u,c):""};return g&&(p.permalink_cdn=xe(g,c)),{...h,transformation:{params:s,url:p}}});this._transformOpen=!1,this._transformAssets=[],this._transformFolders=[],this._emitSelect(d,o.length?o:void 0)}_handleTransformSkip(){const e=this._transformAssets,s=this._transformFolders;this._transformOpen=!1,this._transformAssets=[],this._transformFolders=[],this._emitSelect(e,s.length?s:void 0)}_handleTransformCancel(){this._transformOpen=!1,this._transformAssets=[],this._transformFolders=[]}async _handleSelectAll(e){var d,h,u;const s=this.store.getState();if(s.isSelectingAll||!this.apiClient||!(((d=s.config)==null?void 0:d.multiSelect)??!0))return;const a=((h=e==null?void 0:e.detail)==null?void 0:h.scope)??"all",o=a!=="assets"&&((u=this.config)==null?void 0:u.folderSelection)!==!1&&s.folders.length>0;if(!(a!=="folders")){o&&this.selectionCtrl.selectAllFolders(s.folders);return}if(s.assets.length>=s.totalCount){o&&this.selectionCtrl.selectAllFolders(s.folders),this.selectionCtrl.selectAll(s.assets);return}const c=++this._selectAllId;this.store.setState({isSelectingAll:!0});try{const g=this._buildSearchNotation();let p=s.currentFolderPath||"/";const f=s.limit,m=s.assets,x=s.totalCount;let _=s.activeTab==="folders"?0:1,w=g||void 0;if(s.activeTab==="labels"&&s.activeLabelUuid){const M=s.labels.find(X=>X.uuid===s.activeLabelUuid);M&&(w=`labels:${M.sid.replace("#","")}${g?" "+g:""}`),p="/",_=1}let y,T;s.activeTab==="collections"&&s.activeCollectionFolder&&(y=s.activeCollectionUuid||void 0,T=s.activeCollectionFolder.filters||void 0,p="",_=1);const k=[];for(let M=m.length;M<x;M+=f)k.push(M);const S=4,F=[];for(let M=0;M<k.length;M+=S){if(c!==this._selectAllId)return;const X=k.slice(M,M+S),Z=await Promise.all(X.map(D=>{var Pe;return De(this.apiClient,{...p?{folder:p}:{},offset:D,limit:f,sort_by:s.sortBy,sort_direction:s.sortDirection,search:s.searchQuery||void 0,q:w,recursive:_,...y&&{collection_uuid:y},...T&&{f64:T},...s.isAISearchActive&&s.searchQuery&&{with_ai:!0,ai_query:s.searchQuery,ai_lang:((Pe=s.config)==null?void 0:Pe.locale)??"en"}})}));if(c!==this._selectAllId)return;for(const D of Z)D.files&&F.push(...D.files)}if(c!==this._selectAllId)return;const E=new Set(m.map(M=>M.uuid)),fe=F.filter(M=>E.has(M.uuid)?!1:(E.add(M.uuid),!0)),ie=[...m,...fe];this.store.setState({assets:ie,offset:Math.max(0,ie.length-f),hasMore:!1,isSelectingAll:!1}),o&&this.selectionCtrl.selectAllFolders(s.folders),this.selectionCtrl.selectAll(ie)}catch(g){if(c!==this._selectAllId)return;this.store.setState({isSelectingAll:!1}),this.dispatchEvent(new CustomEvent("ap-error",{detail:{error:g,context:"selectAll"},bubbles:!0,composed:!0}))}}_handleSelectionClear(){this.selectionCtrl.clearSelection()}_handleSelectionDeselect(e){const s=new Map(this.store.getState().selectedAssets);s.delete(e.detail.uuid),this.store.setState({selectedAssets:s})}_isDateFilterKey(e){return e===b.DATE||e===b.LICENSE_EXPIRY||e===G.DUE_DATE}_handleFilterUpdate(e){const{key:s,values:i,operator:a}=e.detail,n={...this.store.getState().filters};let c=i===""||i===null||i===void 0||Array.isArray(i)&&i.length===0||typeof i=="object"&&!Array.isArray(i)&&Object.values(i).every(d=>d==null||d===""||Array.isArray(d)&&d.length===0);if(!c&&this._isDateFilterKey(s)&&typeof i=="object"&&!Array.isArray(i)){const{kind:d,preset:h,from:u,to:g}=i;c=!d&&!h&&!u&&!g}if(c){const d={...n.applied};delete d[s],n.applied=d,n.pinned.includes(s)||(n.visible=n.visible.filter(h=>h!==s))}else{const d={...n.applied};this._isDateFilterKey(s)&&typeof i=="object"&&!Array.isArray(i)?d[s]={type:"date",field:i.field||"created",kind:i.kind||null,preset:i.preset||null,from:i.from||null,to:i.to||null}:s===b.IMAGE&&typeof i=="object"&&!Array.isArray(i)?d[s]=i:d[s]={type:"string",values:Array.isArray(i)?i:[i],operator:a||":"},n.applied=d,n.visible.includes(s)||(n.visible=[...n.visible,s])}if(this.store.setState({filters:n,offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange(),this._debouncedLoadData(),this._pendingFilter===s){this._pendingFilter=null;const d=this.renderRoot.querySelector("ap-filters-bar");d&&(d.pendingFilter=null)}}_handleFilterOpen(e){const s=e.detail.key,i=e.detail.chipRect,a=this.renderRoot.querySelector("ap-content-toolbar");let o,n;if(i){const c=this.renderRoot.querySelector(".toolbar-filters-wrapper");if(c){const d=c.getBoundingClientRect();o=i.left-d.left,n=i.bottom-d.top}}a==null||a.openFilterPanel(s,!0,o,n)}_handleMetadataFilterOpen(e){const{fieldKey:s,chipRect:i}=e.detail,a=this.renderRoot.querySelector("ap-content-toolbar");let o,n;if(i){const c=this.renderRoot.querySelector(".toolbar-filters-wrapper");if(c){const d=c.getBoundingClientRect();o=i.left-d.left,n=i.bottom-d.top}}a==null||a.openMetadataFieldPanel(s,!0,o,n)}_handleFilterPanelChange(e){const s=this.renderRoot.querySelector("ap-filters-bar");s&&(s.activeFilter=e.detail.key,s.activeMetadataField=e.detail.metadataFieldKey||null),!e.detail.key&&!e.detail.metadataFieldKey&&(this._pendingFilter||this._pendingMetadataField)&&(this._pendingFilter=null,this._pendingMetadataField=null,s&&(s.pendingFilter=null,s.pendingMetadataField=null))}async _handleFilterPending(e){var p,f,m;const{key:s,metadataFieldKey:i}=e.detail,a=this.renderRoot.querySelector("ap-filters-bar"),o=this.renderRoot.querySelector("ap-content-toolbar");if(!a||!o)return;i?(this._pendingMetadataField=i,a.pendingMetadataField=i):s&&(this._pendingFilter=s,a.pendingFilter=s),await a.updateComplete;let n=a.renderRoot.querySelector(".chip.pending");if(!n){const x=a.renderRoot.querySelectorAll(".chip.pinned-empty"),_=i?(p=a._getMetadataLabel)==null?void 0:p.call(a,i):void 0;for(const w of x){const y=(m=(f=w.querySelector(".chip-label"))==null?void 0:f.textContent)==null?void 0:m.trim();if(i&&y===_){n=w;break}if(s&&y===(et[s]||s)){n=w;break}}}if(!n)return;const c=n.getBoundingClientRect(),d=this.renderRoot.querySelector(".toolbar-filters-wrapper"),h=d==null?void 0:d.getBoundingClientRect(),u=h?c.left-h.left:c.left,g=h?c.bottom-h.top:void 0;i?o.openMetadataFieldPanel(i,!0,u,g):s&&o.openFilterPanel(s,!0,u,g)}_handleFilterRemove(e){var n;const s=e.detail.key;if(s in(((n=this.config)==null?void 0:n.forcedFilters)??{}))return;const a={...this.store.getState().filters},o={...a.applied};delete o[s],a.applied=o,a.pinned.includes(s)||(a.visible=a.visible.filter(c=>c!==s)),this.store.setState({filters:a,offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange(),this._debouncedLoadData()}_handleMetadataFilterChange(e){const{fieldKey:s,operator:i,values:a,metadataType:o}=e.detail,c={...this.store.getState().filters},d={...c.metadata},h={...d.applied};if(!a||Array.isArray(a)&&a.length===0?(delete h[s],d.applied=h,d.pinned.includes(s)||(d.visible=d.visible.filter(g=>g!==s))):(h[s]={type:"string",values:Array.isArray(a)?a:[a],operator:i||":",metadataType:o},d.applied=h,d.visible.includes(s)||(d.visible=[...d.visible,s])),c.metadata=d,this.store.setState({filters:c,offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange(),this._debouncedLoadData(),this._pendingMetadataField===s){this._pendingMetadataField=null;const g=this.renderRoot.querySelector("ap-filters-bar");g&&(g.pendingMetadataField=null)}}_handleMetadataFieldToggle(e){const{fieldKey:s,visible:i}=e.detail,o={...this.store.getState().filters},n={...o.metadata};i?n.visible.includes(s)||(n.visible=[...n.visible,s]):n.visible=n.visible.filter(c=>c!==s),o.metadata=n,this.store.setState({filters:o})}_handleMetadataFilterRemove(e){const{fieldKey:s}=e.detail,a={...this.store.getState().filters},o={...a.metadata},n={...o.applied};delete n[s],o.applied=n,o.pinned.includes(s)||(o.visible=o.visible.filter(c=>c!==s)),a.metadata=o,this.store.setState({filters:a,offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange(),this._debouncedLoadData()}_handleFilterPin(e){var c,d;const{key:s,pinned:i}=e.detail,o={...this.store.getState().filters};i?o.pinned.includes(s)||(o.pinned=[...o.pinned,s]):(o.pinned=o.pinned.filter(h=>h!==s),s in o.applied||(o.visible=o.visible.filter(h=>h!==s))),this.store.setState({filters:o});const n=((d=(c=this.store.getState().config)==null?void 0:c.auth)==null?void 0:d.projectToken)??null;Ka(n,o.pinned)}_handleMetadataPin(e){var d,h;const{fieldKey:s,pinned:i}=e.detail,o={...this.store.getState().filters},n={...o.metadata};i?n.pinned.includes(s)||(n.pinned=[...n.pinned,s]):(n.pinned=n.pinned.filter(u=>u!==s),s in n.applied||(n.visible=n.visible.filter(u=>u!==s))),o.metadata=n,this.store.setState({filters:o});const c=((h=(d=this.store.getState().config)==null?void 0:d.auth)==null?void 0:h.projectToken)??null;Qa(c,n.pinned)}_handleFiltersClearAll(){const e=this.store.getState();this.store.setState({filters:{...e.filters,applied:{},visible:[...e.filters.pinned],metadata:{...e.filters.metadata,applied:{},visible:[...e.filters.metadata.pinned]}},offset:0,assets:[],folders:[],isLoading:!0});const s=this.renderRoot.querySelector("ap-filters-bar");s&&(s.activeFilter=null),this.selectionCtrl.resetRange(),this._debouncedLoadData()}_handleFilterDeactivate(e){const s=e.detail.key,a={...this.store.getState().filters};a.visible=a.visible.filter(o=>o!==s),this.store.setState({filters:a})}_handleMetadataFieldDeactivate(e){const{fieldKey:s}=e.detail,a={...this.store.getState().filters},o={...a.metadata};o.visible=o.visible.filter(n=>n!==s),a.metadata=o,this.store.setState({filters:a})}_handleFiltersSet(e){var h;const{applied:s,metadata:i}=e.detail,o={...this.store.getState().filters},n=new Set(Object.keys(((h=this.config)==null?void 0:h.forcedFilters)??{})),c={...s};for(const u of n)delete c[u];o.applied=c;const d=Object.keys(s);if(o.visible=[...new Set([...o.pinned,...d])],i){const u={...o.metadata};u.applied=i.applied;const g=Object.keys(i.applied);u.visible=[...new Set([...u.pinned,...g])],o.metadata=u}this.store.setState({filters:o,offset:0,assets:[],folders:[],isLoading:!0}),this.selectionCtrl.resetRange(),this._debouncedLoadData()}_getSortOptions(){var s;const e=this.storeCtrl.state;if(e.activeTab==="labels"&&!e.activeLabelUuid)return no;if(e.activeTab==="collections"){if(!e.activeCollectionUuid)return lo;if(!(e.activeCollectionFolder&&!((s=e.activeCollectionFolder.children)!=null&&s.length)))return co}return e.searchQuery?oo:e.activeTab==="folders"?ro:ms}_buildSearchNotation(){const e=this.store.getState(),s={...this._normalizedForcedFilters,...e.filters.applied};return La(s,e.filters.metadata.applied).join(" ")}render(){var p,f,m,x,_,w,y,T,k,S,F,E,fe,ie,M,X,Z,D;const e=this.storeCtrl.state,s=Array.from(e.selectedAssets.keys()),i=Array.from(e.selectedFolders.keys()),a=this.selectionCtrl.getSelectedAssets(),o=this.selectionCtrl.getSelectedFolders(),n=((p=this.config)==null?void 0:p.folderSelection)!==!1,c=r.html`
7244
7244
  <ap-header
7245
7245
  .activeTab=${e.activeTab}
7246
- .tabs=${((g=this.config)==null?void 0:g.tabs)??["assets","folders"]}
7246
+ .tabs=${((f=this.config)==null?void 0:f.tabs)??["assets","folders"]}
7247
7247
  .isInsideLabel=${e.activeTab==="labels"&&!!e.activeLabelUuid}
7248
7248
  .isInsideCollection=${e.activeTab==="collections"&&!!e.activeCollectionUuid}
7249
7249
  .isInsideCollectionLeaf=${e.activeTab==="collections"&&!!e.activeCollectionFolder&&!((m=e.activeCollectionFolder.children)!=null&&m.length)}
7250
7250
  .viewMode=${e.viewMode}
7251
7251
  .searchQuery=${e.searchQuery}
7252
- .enableAISearch=${!!((_=this.config)!=null&&_.enableAISearch)}
7252
+ .enableAISearch=${!!((x=this.config)!=null&&x.enableAISearch)}
7253
7253
  .isAISearchActive=${e.isAISearchActive}
7254
7254
  .regionalGroups=${e.regionalVariantGroups}
7255
7255
  .regionalFilters=${e.regionalFilters}
@@ -7261,7 +7261,7 @@
7261
7261
  @regional-change=${this._handleRegionalChange}
7262
7262
  @ap-close=${()=>this._handleCancel("close-button")}
7263
7263
  ></ap-header>
7264
- `,d=!!((y=this.config)!=null&&y.uploader),h=r.html`
7264
+ `,d=!!((_=this.config)!=null&&_.uploader),h=r.html`
7265
7265
  <div class="content-area"
7266
7266
  @dragenter=${this._onDragEnter}
7267
7267
  @dragover=${this._onDragOver}
@@ -7277,14 +7277,14 @@
7277
7277
  </div>
7278
7278
  `:r.nothing}
7279
7279
  <div class="main-content">
7280
- <div class="toolbar-filters-wrapper${(C=this.config)!=null&&C.stickyFilters?" sticky":""}">
7280
+ <div class="toolbar-filters-wrapper${(w=this.config)!=null&&w.stickyFilters?" sticky":""}">
7281
7281
  <ap-content-toolbar
7282
7282
  .isLoading=${e.isLoading}
7283
7283
  .totalCount=${e.totalCount}
7284
7284
  .totalFolderCount=${e.totalFolderCount}
7285
7285
  .showUpload=${d}
7286
- .showFilters=${!(e.activeTab==="labels"&&!e.activeLabelUuid)&&!(e.activeTab==="collections"&&!(e.activeCollectionFolder&&!((x=e.activeCollectionFolder.children)!=null&&x.length)))}
7287
- .countLabel=${e.activeTab==="labels"&&!e.activeLabelUuid?`${e.labels.length} label${e.labels.length!==1?"s":""}`:e.activeTab==="collections"&&!e.activeCollectionUuid?`${e.collections.length} collection${e.collections.length!==1?"s":""}`:e.activeTab==="collections"&&e.activeCollectionUuid&&!(e.activeCollectionFolder&&!((M=e.activeCollectionFolder.children)!=null&&M.length))?`${this._getVisibleCollectionFolders().length} folder${this._getVisibleCollectionFolders().length!==1?"s":""}`:""}
7286
+ .showFilters=${!(e.activeTab==="labels"&&!e.activeLabelUuid)&&!(e.activeTab==="collections"&&!(e.activeCollectionFolder&&!((y=e.activeCollectionFolder.children)!=null&&y.length)))}
7287
+ .countLabel=${e.activeTab==="labels"&&!e.activeLabelUuid?`${e.labels.length} label${e.labels.length!==1?"s":""}`:e.activeTab==="collections"&&!e.activeCollectionUuid?`${e.collections.length} collection${e.collections.length!==1?"s":""}`:e.activeTab==="collections"&&e.activeCollectionUuid&&!(e.activeCollectionFolder&&!((T=e.activeCollectionFolder.children)!=null&&T.length))?`${this._getVisibleCollectionFolders().length} folder${this._getVisibleCollectionFolders().length!==1?"s":""}`:""}
7288
7288
  .sortBy=${e.sortBy}
7289
7289
  .sortDirection=${e.sortDirection}
7290
7290
  .sortOptions=${this._getSortOptions()}
@@ -7308,7 +7308,7 @@
7308
7308
  @upload-click=${this._handleUploadClick}
7309
7309
  ></ap-content-toolbar>
7310
7310
 
7311
- ${e.activeTab==="labels"&&!e.activeLabelUuid||e.activeTab==="collections"&&!(e.activeCollectionFolder&&!(($=e.activeCollectionFolder.children)!=null&&$.length))?r.nothing:r.html`
7311
+ ${e.activeTab==="labels"&&!e.activeLabelUuid||e.activeTab==="collections"&&!(e.activeCollectionFolder&&!((k=e.activeCollectionFolder.children)!=null&&k.length))?r.nothing:r.html`
7312
7312
  <ap-filters-bar
7313
7313
  .appliedFilters=${e.filters.applied}
7314
7314
  .appliedMetadata=${e.filters.metadata.applied}
@@ -7317,7 +7317,7 @@
7317
7317
  .labels=${e.labels}
7318
7318
  .pinnedFilters=${e.filters.pinned}
7319
7319
  .pinnedMetadataFields=${e.filters.metadata.pinned}
7320
- .forcedFilters=${((k=this.config)==null?void 0:k.forcedFilters)??{}}
7320
+ .forcedFilters=${((S=this.config)==null?void 0:S.forcedFilters)??{}}
7321
7321
  @filter-remove=${this._handleFilterRemove}
7322
7322
  @filter-deactivate=${this._handleFilterDeactivate}
7323
7323
  @filter-open=${this._handleFilterOpen}
@@ -7337,7 +7337,7 @@
7337
7337
  ></ap-breadcrumb>`:r.nothing}
7338
7338
  </div>
7339
7339
 
7340
- ${e.isLoading&&e.assets.length===0&&e.folders.length===0&&!(e.activeTab==="labels"&&!e.activeLabelUuid)&&!(e.activeTab==="collections"&&!(e.activeCollectionFolder&&!((E=e.activeCollectionFolder.children)!=null&&E.length)))?r.html`<ap-skeleton .variant=${e.viewMode} .gridSize=${((A=this.config)==null?void 0:A.gridSize)??"normal"} .multiSelect=${((fe=this.config)==null?void 0:fe.multiSelect)!==!1} .folderCount=${2}></ap-skeleton>`:this._renderContent(e,s,i,n)}
7340
+ ${e.isLoading&&e.assets.length===0&&e.folders.length===0&&!(e.activeTab==="labels"&&!e.activeLabelUuid)&&!(e.activeTab==="collections"&&!(e.activeCollectionFolder&&!((F=e.activeCollectionFolder.children)!=null&&F.length)))?r.html`<ap-skeleton .variant=${e.viewMode} .gridSize=${((E=this.config)==null?void 0:E.gridSize)??"normal"} .multiSelect=${((fe=this.config)==null?void 0:fe.multiSelect)!==!1} .folderCount=${2}></ap-skeleton>`:this._renderContent(e,s,i,n)}
7341
7341
 
7342
7342
  <ap-marquee-overlay .active=${this.marqueeCtrl.isActive} .rect=${this.marqueeCtrl.rect}></ap-marquee-overlay>
7343
7343
  ${this._folderResolveOpen?r.html`
@@ -7368,7 +7368,7 @@
7368
7368
  .metadataFields=${e.metadataFields}
7369
7369
  .labels=${e.labels}
7370
7370
  .regionalFilters=${e.regionalFilters}
7371
- .multiSelect=${((O=this.config)==null?void 0:O.multiSelect)??!0}
7371
+ .multiSelect=${((M=this.config)==null?void 0:M.multiSelect)??!0}
7372
7372
  @preview-close=${this._handlePreviewClose}
7373
7373
  @preview-navigate=${this._handlePreviewNavigate}
7374
7374
  @asset-select=${this._handleAssetSelect}
@@ -7392,13 +7392,13 @@
7392
7392
  @selection-deselect=${this._handleSelectionDeselect}
7393
7393
  @select-all=${this._handleSelectAll}
7394
7394
  ></ap-selection-bar>
7395
- `,f=this._isUploaderOpen?r.html`
7395
+ `,g=this._isUploaderOpen?r.html`
7396
7396
  <div class="uploader-overlay">
7397
7397
  <div class="uploader-body">${this._uploaderEl}</div>
7398
7398
  </div>
7399
7399
  `:r.nothing;return this._isInline?e.isOpen?r.html`
7400
7400
  <div class="ap-inline">
7401
- ${this._isUploaderOpen?f:r.html`
7401
+ ${this._isUploaderOpen?g:r.html`
7402
7402
  <div class="inline-header">${c}</div>
7403
7403
  <div class="inline-content">${h}</div>
7404
7404
  <div class="inline-footer">${u}</div>
@@ -7409,13 +7409,13 @@
7409
7409
  ?open=${e.isOpen}
7410
7410
  @ap-cancel=${Pe=>this._handleCancel(Pe.detail.reason)}
7411
7411
  >
7412
- ${this._isUploaderOpen?f:r.html`
7412
+ ${this._isUploaderOpen?g:r.html`
7413
7413
  <div slot="header">${c}</div>
7414
7414
  ${h}
7415
7415
  <div slot="footer">${u}</div>
7416
7416
  `}
7417
7417
  </ap-modal>
7418
- `}_renderContent(e,s,i=[],a=!1){var o,n,c,d,h,u,f,p,g,m,_,y,C;if(e.activeTab==="assets")return!e.isLoading&&e.assets.length===0?r.html`
7418
+ `}_renderContent(e,s,i=[],a=!1){var o,n,c,d,h,u,g,p,f,m,x,_,w;if(e.activeTab==="assets")return!e.isLoading&&e.assets.length===0?r.html`
7419
7419
  <div class="empty-state">
7420
7420
  <ap-icon name="search" .size=${48}></ap-icon>
7421
7421
  <div class="empty-title">No assets found</div>
@@ -7501,7 +7501,7 @@
7501
7501
  @selection-clear=${this._handleSelectionClear}
7502
7502
  ></ap-list-view>
7503
7503
  <div id="sentinel"></div>
7504
- `;if(e.activeTab==="labels"){if(!e.activeLabelUuid){let x=e.labels;if(e.searchQuery){const $=e.searchQuery.toLowerCase();x=e.labels.filter(k=>k.name.toLowerCase().includes($))}const M=e.sortDirection==="asc"?1:-1;return x=[...x].sort(($,k)=>M*$.name.localeCompare(k.name)),x.length===0?r.html`
7504
+ `;if(e.activeTab==="labels"){if(!e.activeLabelUuid){let y=e.labels;if(e.searchQuery){const k=e.searchQuery.toLowerCase();y=e.labels.filter(S=>S.name.toLowerCase().includes(k))}const T=e.sortDirection==="asc"?1:-1;return y=[...y].sort((k,S)=>T*k.name.localeCompare(S.name)),y.length===0?r.html`
7505
7505
  <div class="empty-state">
7506
7506
  <ap-icon name="tag" .size=${48}></ap-icon>
7507
7507
  <div class="empty-title">${e.searchQuery?"No labels match your search":"No labels found"}</div>
@@ -7509,14 +7509,14 @@
7509
7509
  </div>
7510
7510
  `:e.viewMode==="grid"?r.html`
7511
7511
  <div class="labels-grid">
7512
- ${x.map(($,k)=>r.html`
7513
- <ap-label-card .label=${$} .index=${k} @label-open=${this._handleLabelOpen}></ap-label-card>
7512
+ ${y.map((k,S)=>r.html`
7513
+ <ap-label-card .label=${k} .index=${S} @label-open=${this._handleLabelOpen}></ap-label-card>
7514
7514
  `)}
7515
7515
  </div>
7516
7516
  `:r.html`
7517
7517
  <div class="labels-list">
7518
- ${x.map(($,k)=>r.html`
7519
- <ap-label-row .label=${$} .index=${k} @label-open=${this._handleLabelOpen}></ap-label-row>
7518
+ ${y.map((k,S)=>r.html`
7519
+ <ap-label-row .label=${k} .index=${S} @label-open=${this._handleLabelOpen}></ap-label-row>
7520
7520
  `)}
7521
7521
  </div>
7522
7522
  `}return!e.isLoading&&e.assets.length===0?r.html`
@@ -7532,7 +7532,7 @@
7532
7532
  .selectedIds=${s}
7533
7533
  .selectedFolderIds=${i}
7534
7534
  .isLoading=${e.isLoading}
7535
- .multiSelect=${((f=this.config)==null?void 0:f.multiSelect)??!0}
7535
+ .multiSelect=${((g=this.config)==null?void 0:g.multiSelect)??!0}
7536
7536
  .folderSelectable=${!1}
7537
7537
  .gridSize=${((p=this.config)==null?void 0:p.gridSize)??"normal"}
7538
7538
  @asset-select=${this._handleAssetSelect}
@@ -7547,7 +7547,7 @@
7547
7547
  .selectedIds=${s}
7548
7548
  .selectedFolderIds=${i}
7549
7549
  .isLoading=${e.isLoading}
7550
- .multiSelect=${((g=this.config)==null?void 0:g.multiSelect)??!0}
7550
+ .multiSelect=${((f=this.config)==null?void 0:f.multiSelect)??!0}
7551
7551
  .folderSelectable=${!1}
7552
7552
  .totalCount=${e.totalCount}
7553
7553
  .isSelectingAll=${e.isSelectingAll}
@@ -7558,7 +7558,7 @@
7558
7558
  @selection-clear=${this._handleSelectionClear}
7559
7559
  ></ap-list-view>
7560
7560
  <div id="sentinel"></div>
7561
- `}if(e.activeTab==="collections"){if(!e.activeCollectionUuid){let $=e.collections;if(e.searchQuery){const E=e.searchQuery.toLowerCase();$=e.collections.filter(A=>A.title.toLowerCase().includes(E))}const k=e.sortDirection==="asc"?1:-1;return e.sortBy==="created_at"?$=[...$].sort((E,A)=>k*(new Date(E.created_at).getTime()-new Date(A.created_at).getTime())):e.sortBy==="updated_at"?$=[...$].sort((E,A)=>k*(new Date(E.updated_at).getTime()-new Date(A.updated_at).getTime())):$=[...$].sort((E,A)=>k*E.title.localeCompare(A.title)),$.length===0?r.html`
7561
+ `}if(e.activeTab==="collections"){if(!e.activeCollectionUuid){let k=e.collections;if(e.searchQuery){const F=e.searchQuery.toLowerCase();k=e.collections.filter(E=>E.title.toLowerCase().includes(F))}const S=e.sortDirection==="asc"?1:-1;return e.sortBy==="created_at"?k=[...k].sort((F,E)=>S*(new Date(F.created_at).getTime()-new Date(E.created_at).getTime())):e.sortBy==="updated_at"?k=[...k].sort((F,E)=>S*(new Date(F.updated_at).getTime()-new Date(E.updated_at).getTime())):k=[...k].sort((F,E)=>S*F.title.localeCompare(E.title)),k.length===0?r.html`
7562
7562
  <div class="empty-state">
7563
7563
  <ap-icon name="layout-grid" .size=${48}></ap-icon>
7564
7564
  <div class="empty-title">${e.searchQuery?"No collections match your search":"No collections found"}</div>
@@ -7566,17 +7566,17 @@
7566
7566
  </div>
7567
7567
  `:e.viewMode==="grid"?r.html`
7568
7568
  <div class="collections-grid">
7569
- ${$.map((E,A)=>r.html`
7570
- <ap-collection-card .collection=${E} .index=${A} @collection-open=${this._handleCollectionOpen}></ap-collection-card>
7569
+ ${k.map((F,E)=>r.html`
7570
+ <ap-collection-card .collection=${F} .index=${E} @collection-open=${this._handleCollectionOpen}></ap-collection-card>
7571
7571
  `)}
7572
7572
  </div>
7573
7573
  `:r.html`
7574
7574
  <div class="collections-list">
7575
- ${$.map((E,A)=>r.html`
7576
- <ap-collection-row .collection=${E} .index=${A} @collection-open=${this._handleCollectionOpen}></ap-collection-row>
7575
+ ${k.map((F,E)=>r.html`
7576
+ <ap-collection-row .collection=${F} .index=${E} @collection-open=${this._handleCollectionOpen}></ap-collection-row>
7577
7577
  `)}
7578
7578
  </div>
7579
- `}if(e.isLoadingCollectionFolders)return r.html`<div class="loading-center"><ap-spinner></ap-spinner></div>`;const x=this._getVisibleCollectionFolders();if(!e.activeCollectionFolder||(((m=e.activeCollectionFolder.children)==null?void 0:m.length)??0)>0){let $=x;if(e.searchQuery){const E=e.searchQuery.toLowerCase();$=x.filter(A=>A.name.toLowerCase().includes(E))}const k=e.sortDirection==="asc"?1:-1;return $=[...$].sort((E,A)=>k*E.name.localeCompare(A.name)),$.length===0?r.html`
7579
+ `}if(e.isLoadingCollectionFolders)return r.html`<div class="loading-center"><ap-spinner></ap-spinner></div>`;const y=this._getVisibleCollectionFolders();if(!e.activeCollectionFolder||(((m=e.activeCollectionFolder.children)==null?void 0:m.length)??0)>0){let k=y;if(e.searchQuery){const F=e.searchQuery.toLowerCase();k=y.filter(E=>E.name.toLowerCase().includes(F))}const S=e.sortDirection==="asc"?1:-1;return k=[...k].sort((F,E)=>S*F.name.localeCompare(E.name)),k.length===0?r.html`
7580
7580
  <div class="empty-state">
7581
7581
  <ap-icon name="folder" .size=${48}></ap-icon>
7582
7582
  <div class="empty-title">${e.searchQuery?"No folders match your search":"No folders in this collection"}</div>
@@ -7584,14 +7584,14 @@
7584
7584
  </div>
7585
7585
  `:e.viewMode==="grid"?r.html`
7586
7586
  <div class="collection-folders-grid">
7587
- ${$.map((E,A)=>r.html`
7588
- <ap-collection-folder-card .folder=${E} .index=${A} @collection-folder-open=${this._handleCollectionFolderOpen}></ap-collection-folder-card>
7587
+ ${k.map((F,E)=>r.html`
7588
+ <ap-collection-folder-card .folder=${F} .index=${E} @collection-folder-open=${this._handleCollectionFolderOpen}></ap-collection-folder-card>
7589
7589
  `)}
7590
7590
  </div>
7591
7591
  `:r.html`
7592
7592
  <div class="collection-folders-list">
7593
- ${$.map((E,A)=>r.html`
7594
- <ap-collection-folder-row .folder=${E} .index=${A} @collection-folder-open=${this._handleCollectionFolderOpen}></ap-collection-folder-row>
7593
+ ${k.map((F,E)=>r.html`
7594
+ <ap-collection-folder-row .folder=${F} .index=${E} @collection-folder-open=${this._handleCollectionFolderOpen}></ap-collection-folder-row>
7595
7595
  `)}
7596
7596
  </div>
7597
7597
  `}return!e.isLoading&&e.assets.length===0?r.html`
@@ -7607,9 +7607,9 @@
7607
7607
  .selectedIds=${s}
7608
7608
  .selectedFolderIds=${i}
7609
7609
  .isLoading=${e.isLoading}
7610
- .multiSelect=${((_=this.config)==null?void 0:_.multiSelect)??!0}
7610
+ .multiSelect=${((x=this.config)==null?void 0:x.multiSelect)??!0}
7611
7611
  .folderSelectable=${!1}
7612
- .gridSize=${((y=this.config)==null?void 0:y.gridSize)??"normal"}
7612
+ .gridSize=${((_=this.config)==null?void 0:_.gridSize)??"normal"}
7613
7613
  @asset-select=${this._handleAssetSelect}
7614
7614
  @asset-preview=${this._handleAssetPreview}
7615
7615
  @asset-quick-select=${this._handleQuickSelect}
@@ -7622,7 +7622,7 @@
7622
7622
  .selectedIds=${s}
7623
7623
  .selectedFolderIds=${i}
7624
7624
  .isLoading=${e.isLoading}
7625
- .multiSelect=${((C=this.config)==null?void 0:C.multiSelect)??!0}
7625
+ .multiSelect=${((w=this.config)==null?void 0:w.multiSelect)??!0}
7626
7626
  .folderSelectable=${!1}
7627
7627
  .totalCount=${e.totalCount}
7628
7628
  .isSelectingAll=${e.isSelectingAll}