@scaleflex/asset-picker 1.0.0 → 1.0.1

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.
@@ -781,16 +781,17 @@ function Pe(t, e) {
781
781
  const Ws = /^(https:\/\/)([a-z0-9_-]+)\.filerobot\.com\//i;
782
782
  function Ge(t, e) {
783
783
  if (!t) return "";
784
- if (t.includes("assets.filerobot.com")) return t;
785
- const s = t.match(Ws);
786
- if (s) {
787
- const i = s[2];
788
- return t.replace(Ws, `$1assets.filerobot.com/${i}/`);
784
+ const s = (a) => a.replace(/(\.filerobot\.com\/[a-z0-9_-]+)\/v\d+\//i, "$1/");
785
+ if (t.includes("assets.filerobot.com")) return s(t);
786
+ const i = t.match(Ws);
787
+ if (i) {
788
+ const a = i[2], o = t.replace(Ws, `$1assets.filerobot.com/${a}/`);
789
+ return s(o);
789
790
  }
790
791
  if (e)
791
792
  try {
792
- const i = new URL(t);
793
- return `https://assets.filerobot.com/${e}${i.pathname}${i.search}`;
793
+ const a = new URL(t);
794
+ return s(`https://assets.filerobot.com/${e}${a.pathname}${a.search}`);
794
795
  } catch {
795
796
  }
796
797
  return t;
@@ -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"";if(t.includes("assets.filerobot.com"))return t;const s=t.match(Hs);if(s){const i=s[2];return t.replace(Hs,`$1assets.filerobot.com/${i}/`)}if(e)try{const i=new URL(t);return`https://assets.filerobot.com/${e}${i.pathname}${i.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 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`
2
2
  <dialog
3
3
  @click=${this._handleBackdropClick}
4
4
  @cancel=${this._handleCancel}
package/dist/define.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const e=require("./asset-picker-iM7pJfrx.cjs");typeof customElements<"u"&&!customElements.get("sfx-asset-picker")&&customElements.define("sfx-asset-picker",e.AssetPicker);
1
+ "use strict";const e=require("./asset-picker-C2mx-TCz.cjs");typeof customElements<"u"&&!customElements.get("sfx-asset-picker")&&customElements.define("sfx-asset-picker",e.AssetPicker);
package/dist/define.js CHANGED
@@ -1,2 +1,2 @@
1
- import { A as e } from "./asset-picker-Q4043aB2.js";
1
+ import { A as e } from "./asset-picker-9PYfjZbQ.js";
2
2
  typeof customElements < "u" && !customElements.get("sfx-asset-picker") && customElements.define("sfx-asset-picker", e);
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./asset-picker-iM7pJfrx.cjs");exports.AssetPicker=e.AssetPicker;exports.addCdnParams=e.addCdnParams;exports.buildTransformCdnParams=e.buildTransformCdnParams;exports.buildTransformedUrl=e.buildTransformedUrl;exports.getAltText=e.getAltText;exports.getAssetDimensions=e.getAssetDimensions;exports.getAssetHeight=e.getAssetHeight;exports.getAssetWidth=e.getAssetWidth;exports.getBestVideoUrl=e.getBestVideoUrl;exports.getCdnUrl=e.getCdnUrl;exports.getTranscodedUrl=e.getTranscodedUrl;exports.isAudio=e.isAudio;exports.isImage=e.isImage;exports.isTranscoded=e.isTranscoded;exports.isVideo=e.isVideo;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./asset-picker-C2mx-TCz.cjs");exports.AssetPicker=e.AssetPicker;exports.addCdnParams=e.addCdnParams;exports.buildTransformCdnParams=e.buildTransformCdnParams;exports.buildTransformedUrl=e.buildTransformedUrl;exports.getAltText=e.getAltText;exports.getAssetDimensions=e.getAssetDimensions;exports.getAssetHeight=e.getAssetHeight;exports.getAssetWidth=e.getAssetWidth;exports.getBestVideoUrl=e.getBestVideoUrl;exports.getCdnUrl=e.getCdnUrl;exports.getTranscodedUrl=e.getTranscodedUrl;exports.isAudio=e.isAudio;exports.isImage=e.isImage;exports.isTranscoded=e.isTranscoded;exports.isVideo=e.isVideo;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as e, a as d, b as t, c as i, g as r, d as g, e as n, f as o, h as l, i as m, j as A, k as T, l as c, m as f, n as U } from "./asset-picker-Q4043aB2.js";
1
+ import { A as e, a as d, b as t, c as i, g as r, d as g, e as n, f as o, h as l, i as m, j as A, k as T, l as c, m as f, n as U } from "./asset-picker-9PYfjZbQ.js";
2
2
  export {
3
3
  e as AssetPicker,
4
4
  d as addCdnParams,
@@ -1 +1 @@
1
- {"version":3,"file":"thumbnail.d.ts","sourceRoot":"","sources":["../../src/utils/thumbnail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAI1E;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CASzD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAOzD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAarD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAUhF;AASD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAsBtF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAkBtF;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9D,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAwBxB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,oBAAoB,EAC5B,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9D,MAAM,CAMR"}
1
+ {"version":3,"file":"thumbnail.d.ts","sourceRoot":"","sources":["../../src/utils/thumbnail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAI1E;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CASzD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAOzD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAarD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAUhF;AASD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CA6BtF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAkBtF;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9D,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAwBxB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,oBAAoB,EAC5B,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9D,MAAM,CAMR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleflex/asset-picker",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Framework-agnostic Asset Picker for Scaleflex VXP DAM",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -31,8 +31,7 @@
31
31
  "CHANGELOG.md"
32
32
  ],
33
33
  "scripts": {
34
- "dev": "vite serve dev",
35
- "dev:demo": "vite serve --config vite.demo.config.ts",
34
+ "dev": "vite serve --config vite.demo.config.ts",
36
35
  "build": "vite build",
37
36
  "build:cdn": "vite build --config vite.cdn.config.ts",
38
37
  "release": "node scripts/release-cdn.mjs plugin",