@codingfactory/mediables-vue 2.18.2 → 2.18.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.
- package/dist/{PixiFrameExporter-C8Ty9X-z.cjs → PixiFrameExporter-DhAJGzIK.cjs} +2 -2
- package/dist/{PixiFrameExporter-C8Ty9X-z.cjs.map → PixiFrameExporter-DhAJGzIK.cjs.map} +1 -1
- package/dist/{PixiFrameExporter-CVa0D6mr.js → PixiFrameExporter-YrJf3-l9.js} +2 -2
- package/dist/{PixiFrameExporter-CVa0D6mr.js.map → PixiFrameExporter-YrJf3-l9.js.map} +1 -1
- package/dist/editor-D85y_zTO.cjs +2 -0
- package/dist/editor-D85y_zTO.cjs.map +1 -0
- package/dist/{editor-4KRKCBKe.js → editor-DAJxTvzM.js} +216 -183
- package/dist/editor-DAJxTvzM.js.map +1 -0
- package/dist/{index-Boyt6ME1.cjs → index-BFrh53TT.cjs} +3 -3
- package/dist/{index-Boyt6ME1.cjs.map → index-BFrh53TT.cjs.map} +1 -1
- package/dist/{index-ZHcVI7XG.js → index-Dc-M8oj6.js} +3 -3
- package/dist/{index-ZHcVI7XG.js.map → index-Dc-M8oj6.js.map} +1 -1
- package/dist/mediables-vanilla.cjs +1 -1
- package/dist/mediables-vanilla.mjs +1 -1
- package/dist/mediables-vue.cjs +1 -1
- package/dist/mediables-vue.mjs +2 -2
- package/dist/vanilla-editor/renderer/CropManager.d.ts +9 -1
- package/package.json +1 -1
- package/dist/editor-4KRKCBKe.js.map +0 -1
- package/dist/editor-HgfBAw_0.cjs +0 -2
- package/dist/editor-HgfBAw_0.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ch=Object.defineProperty;var uh=(o,a,t)=>a in o?ch(o,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[a]=t;var ae=(o,a,t)=>uh(o,typeof a!="symbol"?a+"":a,t);const Qr=require("pinia"),e=require("vue"),$t=require("pixi.js"),te=require("./editor-HgfBAw_0.cjs"),H=require("@ionic/vue"),mh=require("pixi-filters");function ph(o){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(a,t,n.get?n:{enumerable:!0,get:()=>o[t]})}}return a.default=o,Object.freeze(a)}const Jt=ph($t),us=1,fh=new Set(["free","square","circle"]);function hh(o){if(typeof o!="number"||!Number.isFinite(o))return 0;const a=o%360;return a<0?a+360:a}function vh(o){const a=typeof o;return a==="string"||a==="number"||a==="boolean"}function gh(o){if(!o||typeof o!="object")return!1;const a=o;return typeof a.x=="number"&&typeof a.y=="number"&&typeof a.width=="number"&&typeof a.height=="number"}function Qs(o){if(!o||typeof o!="object")return null;const a=o;if(a.version!==us)return null;const t=a.crop,n=t&&gh(t.rect)?{...t.rect}:null,i=t&&typeof t.shape=="string"&&fh.has(t.shape)?t.shape:"free",r=t&&typeof t.aspectRatio=="string"?t.aspectRatio:"free",l=a.transform,s=hh(l==null?void 0:l.rotation),d=a.filters,c=[];if(Array.isArray(d))for(const u of d){if(!u||typeof u!="object")continue;const m=u;if(typeof m.id!="string")continue;const p={},f=m.values;if(f&&typeof f=="object"&&!Array.isArray(f))for(const[h,v]of Object.entries(f))vh(v)&&(p[h]=v);c.push({id:m.id,enabled:m.enabled!==!1,values:p})}return{version:us,crop:{rect:n,aspectRatio:r,shape:i},transform:{rotation:s},filters:c}}function Zu(o){const a=Qs(o);return a?JSON.stringify(a):null}function bh(o){try{const a=JSON.parse(o);return Qs(a)}catch{return null}}function yh(){return{version:us,crop:{rect:null,aspectRatio:"free",shape:"free"},transform:{rotation:0},filters:[]}}let ba={apiBaseUrl:"/api/v1",isAdmin:!1};function ic(o){return typeof o=="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(o)}function $o(o){ba={...ba,...o}}function Gu(){return{...ba}}function Xu(o){ba={...o}}function Ku(o){const a=Gu();return $o(o),()=>{Xu(a)}}function wh(o){const a=o.trim().replace(/\/+$/,"");return a===""?"/api/v1":a.startsWith("/")?a:`/${a}`}function kh(o,a){const t=wh(a),n=(i,r="")=>{const l=`/api${t}`;return!t.startsWith("/api/")&&i.startsWith(`${l}/`)?`${i.slice(4)}${r}`:!t.startsWith("/api/")&&i===l?`${t}${r}`:`${i}${r}`};if(/^https?:\/\//i.test(o))try{const i=typeof window<"u"?window.location.origin:"http://localhost",r=new URL(o,i);if(r.origin===i)return n(r.pathname,`${r.search}${r.hash}`)}catch{return o}return n(o)}const _h=async(o,a={})=>{var s;const t=(s=document.querySelector('meta[name="csrf-token"]'))==null?void 0:s.getAttribute("content"),n={Accept:"application/json",...a.headers};t&&(n["X-CSRF-TOKEN"]=t),a.body instanceof FormData||(n["Content-Type"]="application/json");const r={method:a.method||"GET",headers:n,credentials:"include"};a.body instanceof FormData?r.body=a.body:a.body!==void 0&&(r.body=JSON.stringify(a.body));const l=await fetch(o,r);if(!l.ok){const d=await l.json().catch(()=>({message:"Request failed"}));throw new Error(d.message||`HTTP ${l.status}`)}if(l.status!==204)return await l.json()},xa=Qr.defineStore("media",()=>{const o=e.ref([]),a=e.ref([]),t=e.ref(!1),n=e.ref(null),i=e.ref(1),r=e.ref(1),l=e.ref(24),s=e.ref({type:null,uuid:null}),d=e.ref([]),c=e.ref(!1),u=e.ref(null),m=e.ref(new Map),p=e.ref(new Map),f=e.ref(new Set),h=e.ref(new Map),v=e.ref({}),k=5*60*1e3,y=e.computed(()=>{if(ba.apiScope)return ba.apiScope;if(ba.isAdmin)return"admin"}),w=e.computed(()=>y.value==="admin");function g(){return ba.httpClient||_h}function b(be){const Ee=ba.apiBaseUrl||"/api/v1",ye=y.value?`/${y.value}`:"";return`${Ee}${ye}${be}`}function R(be){return`${ba.apiBaseUrl||"/api/v1"}${be}`}function V(be,Ee){return`${y.value??"default"}-${be}-${JSON.stringify(Ee)}`}function I(be){return Date.now()-be<k}function x(){h.value.clear(),v.value={}}function T(be){if(!be||!be.data)return;const Ee={};be.data.forEach(ye=>{const xe=`${ye.file_name}-${ye.collection_name||"default"}`,Ce=Ee[xe];(!Ce||Object.keys(ye.generated_conversions||{}).length>Object.keys(Ce.generated_conversions||{}).length)&&(Ee[xe]=ye)}),o.value=Object.values(Ee),be.meta&&(i.value=be.meta.current_page,r.value=Math.ceil(be.meta.total/be.meta.per_page))}async function $(be=1,Ee={}){const ye=V(be,Ee),xe=h.value.get(ye);if(xe&&I(xe.timestamp)){const Ce=xe.data;return T(Ce),Ce}t.value=!0,n.value=null;try{const Ce=new URLSearchParams;Ce.append("page",be.toString()),Ce.append("per_page",l.value.toString()),w.value&&Ce.append("linked","1");for(const rt in Ee)if(Object.prototype.hasOwnProperty.call(Ee,rt)){const at=Ee[rt];at!=null&&at!==""&&Ce.append(rt,String(at))}const ze=await g()(b(`/media?${Ce}`));return h.value.set(ye,{data:ze,timestamp:Date.now()}),T(ze),ze}catch(Ce){throw n.value=Ce instanceof Error?Ce.message:"Failed to fetch media",o.value=[],new Error(n.value)}finally{t.value=!1}}async function S(be,Ee){t.value=!0,n.value=null;const ye=`${be.name}-${Date.now()}`,xe={file:be,progress:0,status:"uploading"};m.value.set(ye,xe);try{const Ce=new FormData;Ce.append("file",be),Ce.append("collection",Ee.collection),Ee.ownerUuid&&(Ce.append("owner_uuid",Ee.ownerUuid),Ce.append("owner_type",Ee.ownerType||"")),Ee.usageUuid&&(Ce.append("usage_uuid",Ee.usageUuid),Ce.append("usage_type",Ee.usageType||""),Ce.append("usage_purpose",Ee.usagePurpose||"")),Ee.customProperties&&Ce.append("custom_properties",JSON.stringify(Ee.customProperties));const ze=await g()(b("/media"),{method:"POST",body:Ce});return xe.status="completed",xe.progress=100,xe.media=ze==null?void 0:ze.data,i.value===1&&(ze!=null&&ze.data)&&(o.value=[ze.data,...o.value]),x(),(ze==null?void 0:ze.data)||null}catch(Ce){throw xe.status="error",xe.error=Ce instanceof Error?Ce.message:"Upload failed",n.value=xe.error,new Error(n.value)}finally{t.value=!1,setTimeout(()=>{m.value.delete(ye)},5e3)}}async function B(be){t.value=!0,n.value=null;const Ee=o.value.findIndex(xe=>xe.uuid===be);let ye;Ee!==-1&&(ye=o.value.splice(Ee,1)[0]);try{return await g()(b(`/media/${be}`),{method:"DELETE"}),f.value.delete(be),x(),!0}catch(xe){throw ye&&Ee!==-1&&o.value.splice(Ee,0,ye),n.value=xe instanceof Error?xe.message:"Failed to delete media",new Error(n.value)}finally{t.value=!1}}async function _(be,Ee){t.value=!0,n.value=null;try{const xe=await g()(b(`/media/${be}`),{method:"PATCH",body:Ee,data:Ee});if(xe!=null&&xe.data){const Ce=o.value.findIndex(Re=>Re.uuid===be);return Ce!==-1&&(o.value[Ce]={...o.value[Ce],...xe.data}),x(),xe.data}return null}catch(ye){throw n.value=ye instanceof Error?ye.message:"Failed to update media",new Error(n.value)}finally{t.value=!1}}async function A(){t.value=!0,n.value=null;try{const Ee=await g()(b("/media/collections"));return a.value=(Ee==null?void 0:Ee.data)||[],a.value}catch(be){throw n.value=be instanceof Error?be.message:"Failed to fetch collections",a.value=[],new Error(n.value)}finally{t.value=!1}}async function P(be,Ee,ye="images",xe){c.value=!0,u.value=null;try{const Ce=new URLSearchParams;Ce.append("collection",ye),xe&&Ce.append("search",xe);const ze=await g()(b(`/media/model/${be}/${Ee}?${Ce}`));return ze!=null&&ze.data?(d.value=ze.data,ze.data):[]}catch(Ce){throw u.value=Ce instanceof Error?Ce.message:"Failed to fetch model media",d.value=[],new Error(u.value)}finally{c.value=!1}}async function D(be,Ee,ye,xe="images"){c.value=!0,u.value=null;const Ce=[...d.value];try{const ze=await g()(b(`/media/model/${be}/${Ee}/attach`),{method:"POST",body:{media_uuids:ye,collection:xe}});return await P(be,Ee,xe),(ze==null?void 0:ze.data)||[]}catch(Re){throw d.value=Ce,u.value=Re instanceof Error?Re.message:"Failed to attach media",new Error(u.value)}finally{c.value=!1}}async function z(be,Ee,ye,xe="images"){c.value=!0,u.value=null;const Ce=[...d.value];d.value=d.value.filter(Re=>Re.uuid!==ye);try{return await g()(b(`/media/model/${be}/${Ee}/detach`),{method:"POST",body:{media_uuid:ye,collection:xe}}),!0}catch(Re){throw d.value=Ce,u.value=Re instanceof Error?Re.message:"Failed to detach media",new Error(u.value)}finally{c.value=!1}}async function M(be,Ee,ye,xe="images"){c.value=!0,u.value=null;const Ce=[...d.value],Re=new Map(d.value.map(ze=>[ze.uuid,ze]));d.value=ye.map(ze=>Re.get(ze)).filter(ze=>ze!==void 0);try{return await g()(b(`/media/model/${be}/${Ee}/reorder`),{method:"POST",body:{media_uuids:ye,collection:xe}}),!0}catch(ze){throw d.value=Ce,u.value=ze instanceof Error?ze.message:"Failed to reorder media",new Error(u.value)}finally{c.value=!1}}async function Z(be,Ee,ye={}){var lt,Ct;const xe=g(),Ce=ba.apiBaseUrl||"/api/v1";let Re=ic(Ee.documentId)?Ee.documentId:ic((lt=Ee.document)==null?void 0:lt.id)?Ee.document.id:null,ze=Ee.documentRevisionId??null,rt=typeof Ee.documentRevisionNumber=="number"?Ee.documentRevisionNumber:typeof((Ct=Ee.document)==null?void 0:Ct.revision)=="number"?Ee.document.revision:null;if(Ee.document){const Se=await xe(`${Ce}/media/${be}/editor-documents/materialize`,{method:"POST",body:{document_id:Re,base_document_revision:rt,document:Ee.document}});Re=Se.document_id,ze=Se.document_revision_id,rt=Se.document_revision_number}if(Ee.document&&Re&&ze&&typeof rt=="number"){const Se=new FormData,oe=(Ee.mimeType||Ee.blob.type||"image/png")==="image/jpeg"?"jpg":"png";Se.append("flattened_file",Ee.blob,`edited.${oe}`),Se.append("document_id",Re),Se.append("document_revision_id",ze),Se.append("expected_document_revision",String(rt)),Se.append("output_mode",ye.asVariant?"save-as-variant":"save-as-new");const De=await xe(`${Ce}/media/${be}/editor-documents/save`,{method:"POST",body:Se});if(De.media)return De.media;throw new Error("Unexpected response from layered editor save endpoint")}const at=new FormData,ht=(Ee.mimeType||Ee.blob.type||"image/png")==="image/jpeg"?"jpg":"png";at.append("image_file",Ee.blob,`edited.${ht}`);const St=Zu(Ee.state);St&&at.append("editor_state",St),at.append("save_as_new","true"),ye.asVariant&&at.append("as_variant","true"),ye.name!==void 0&&at.append("name",ye.name);const ut=await xe(`${Ce}/editor/${be}/save`,{method:"POST",body:at});if("media"in ut&&ut.media)return ut.media;if("status_url"in ut&&ut.status_url)return O(xe,kh(ut.status_url,Ce),ye.pollTimeout??6e4);throw new Error("Unexpected response from editor save endpoint")}async function O(be,Ee,ye){const xe=Date.now(),Ce=2e3;for(;Date.now()-xe<ye;){await new Promise(ze=>setTimeout(ze,Ce));const Re=await be(Ee);if(Re.status==="completed"&&Re.media)return Re.media;if(Re.status==="failed")throw new Error(Re.error??"Image processing failed")}throw new Error("Image processing timed out")}function K(be,Ee,ye){s.value=ye!==void 0?{type:be,uuid:Ee,collection:ye}:{type:be,uuid:Ee},v.value[`${be}-${Ee}`]={timestamp:Date.now()}}function de(){s.value={type:null,uuid:null},d.value=[],u.value=null}async function Ne(){if(!s.value.type||!s.value.uuid)return;const be=await P(s.value.type,s.value.uuid,s.value.collection||"images");d.value=be||[]}function ce(){o.value.forEach(be=>f.value.add(be.uuid))}function le(){f.value.clear()}function W(be){f.value.has(be)?f.value.delete(be):f.value.add(be)}function C(be){return f.value.has(be)}function U(){return Array.from(m.value.values()).some(be=>be.status==="uploading")}function j(be){return m.value.get(be)||p.value.get(be)}function re(){return[...Array.from(m.value.values()),...Array.from(p.value.values())]}async function ue(){const be=Array.from(f.value);let Ee=0;for(const ye of be)try{await B(ye),Ee++}catch{}return le(),Ee}function Xe(be,Ee){var ye;return Ee&&((ye=be.conversion_urls)!=null&&ye[Ee])?be.conversion_urls[Ee]||"":be.original_url||be.url||""}return{items:o,collections:a,loading:t,error:n,currentPage:i,totalPages:r,itemsPerPage:l,isAdmin:w,modelContext:s,modelMedia:d,isLoadingModelMedia:c,modelMediaError:u,selectedItems:f,uploadProgress:m,uploadQueue:p,cachedResponses:v,fetchMedia:$,uploadFile:S,deleteMedia:B,updateMedia:_,clearCache:x,fetchCollections:A,fetchModelMedia:P,attachMedia:D,detachMedia:z,reorderMedia:M,saveEditedImage:Z,setModelContext:K,clearModelContext:de,refreshModelMedia:Ne,selectAllItems:ce,clearSelection:le,toggleSelection:W,isSelected:C,deleteSelectedItems:ue,getHttpClient:g,getApiUrl:b,getEditorApiUrl:R,hasActiveUploads:U,getUploadProgress:j,getAllUploadProgress:re,getMediaUrl:Xe}}),Ju=()=>((ba.apiScope!=="admin"||ba.isAdmin!==!0)&&$o({...ba,apiScope:"admin",isAdmin:!0}),xa());class qu{constructor(a,t){this.state=a,this.editor=t,this.element=null,this._tabs=new Map,this._unsubscribers=[],this._onSelect=null}render({onSelect:a}={}){return this._onSelect=a,this.element=te.el("div",{className:"panel-tabs",role:"tablist","aria-label":"Filter categories","data-testid":"v2-category-tabs"}),te.EDITOR_CATEGORIES.forEach(t=>{const n=te.el("button",{type:"button",className:`panel-tab ${this._isSelected(t.id)?"active":""}`,role:"tab","aria-selected":this._isSelected(t.id)?"true":"false","data-category":t.id,"data-testid":`v2-category-${t.id}`,onClick:()=>this._selectCategory(t.id)});if(t.icon){const i=te.el("span",{className:"panel-tab-icon","aria-hidden":"true"});i.innerHTML=t.icon,n.appendChild(i)}n.appendChild(te.el("span",{className:"panel-tab-label"},t.name)),this._tabs.set(t.id,n),this.element.appendChild(n)}),this._unsubscribers.push(this.state.on("change:selectedCategory",()=>this._refreshActive())),this.element}_isSelected(a){const t=this.state.get("selectedCategory");return a==="crop"?this.state.get("mode")==="crop":t===a&&this.state.get("mode")!=="crop"}_selectCategory(a){var n;this.state.set("selectedCategory",a);const t=this.state.get("mode");a==="crop"?t!=="crop"&&this.editor.setMode("crop"):t!=="filters"&&this.editor.setMode("filters"),this._refreshActive(),(n=this._onSelect)==null||n.call(this,a)}_refreshActive(){this._tabs.forEach((a,t)=>{const n=this._isSelected(t);a.classList.toggle("active",n),a.setAttribute("aria-selected",n?"true":"false")})}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],this._tabs.clear(),(a=this.element)==null||a.remove(),this.element=null}}class Yu{constructor(a,t){this.state=a,this.filterManager=t,this.element=null,this._unsubscribers=[],this._onToggle=null,this._onSelect=null}render({onToggle:a,onSelect:t}={}){return this._onToggle=a,this._onSelect=t,this.element=te.el("div",{className:"filter-list",role:"listbox","aria-label":"Filters","data-testid":"v2-filter-list"}),this._renderRows(),this._unsubscribers.push(this.state.on("change:selectedCategory",()=>this._renderRows()),this.state.on("change:activeFilters",()=>this._renderRows()),this.state.on("change:selectedFilter",()=>this._renderRows()),this.state.on("change:filterValues",()=>this._refreshSummaries())),this.element}_renderRows(){this.element.innerHTML="";const a=this.state.get("selectedCategory");if(!a||a==="crop")return;const t=this.filterManager.getFiltersByCategory(a),n=this.state.get("activeFilters"),i=this.state.get("selectedFilter"),r=typeof this.state.getActiveFilterLayerId=="function"?this.state.getActiveFilterLayerId():this.state.get("activeLayerId");t.forEach(l=>{var c;const s=((c=n==null?void 0:n.has)==null?void 0:c.call(n,l.id))??!1,d=i===l.id;this.element.appendChild(this._renderRow(l,s,d,r))})}_renderRow(a,t,n,i=null){const r=te.el("button",{type:"button",className:`filter-row ${n?"selected":""}`,role:"option","aria-selected":n?"true":"false","data-filter":a.id,"data-testid":`v2-filter-${a.id}`,onClick:()=>{var u;return(u=this._onSelect)==null?void 0:u.call(this,a.id,i)}}),l=te.el("button",{type:"button",className:`filter-row-toggle ${t?"active":""}`,"aria-label":`${t?"Disable":"Enable"} ${a.name}`,"aria-pressed":t?"true":"false","data-testid":`v2-filter-toggle-${a.id}`,onClick:u=>{var p,f,h,v;u.stopPropagation();const m=!((f=(p=this.state.get("activeFilters"))==null?void 0:p.has)!=null&&f.call(p,a.id));(h=this._onToggle)==null||h.call(this,a.id,m,i),m&&((v=this._onSelect)==null||v.call(this,a.id,i))}});t&&(l.innerHTML=te.checkmark),r.appendChild(l);const s=te.el("div",{className:"filter-row-body"});s.appendChild(te.el("span",{className:"filter-row-name"},a.name));const d=this._buildSummary(a,t);d&&s.appendChild(te.el("span",{className:"filter-row-summary"},d)),r.appendChild(s);const c=te.el("span",{className:"filter-row-chevron","aria-hidden":"true"});return c.innerHTML=te.chevronRight,r.appendChild(c),r}_buildSummary(a,t){if(!t)return a.description||"";const n=this.state.getFilterValues(a.id);if(!n||Object.keys(n).length===0)return a.description||"Active";const i=[];for(const r of(a.controls||[]).slice(0,4)){const l=n[r.id];if(!(l===void 0||l===r.default)&&(i.push(this._formatControlValue(r,l)),i.length>=2))break}return i.length===0?"Active":i.join(" · ")}_formatControlValue(a,t){return a.type==="toggle"?a.label:typeof t=="number"?(a.max??1)<=1&&(a.min??0)>=0?`${a.label} ${Math.round(t*100)}%`:Number.isInteger(t)?`${a.label} ${t}`:`${a.label} ${t.toFixed(2)}`:typeof t=="string"?`${a.label}`:a.label}_refreshSummaries(){var i;const a=this.state.get("selectedCategory");if(!a||a==="crop")return;const t=this.filterManager.getFiltersByCategory(a),n=this.state.get("activeFilters");for(const r of t){const l=this.element.querySelector(`[data-filter="${r.id}"]`);if(!l)continue;const s=((i=n==null?void 0:n.has)==null?void 0:i.call(n,r.id))??!1,d=this._buildSummary(r,s),c=l.querySelector(".filter-row-summary");if(d&&c)c.textContent=d;else if(d&&!c){const u=l.querySelector(".filter-row-body");u==null||u.appendChild(te.el("span",{className:"filter-row-summary"},d))}else!d&&c&&c.remove()}}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(a=this.element)==null||a.remove(),this.element=null}}class Qu{constructor(a,t){this.state=a,this.filterManager=t,this.element=null,this._unsubscribers=[],this._onChange=null,this._onReset=null,this._onAction=null}render({onChange:a,onReset:t,onAction:n}={}){return this._onChange=a,this._onReset=t,this._onAction=n,this.element=te.el("div",{className:"controls-section","data-testid":"v2-controls-section"}),this._renderControls(),this._unsubscribers.push(this.state.on("change:selectedFilter",()=>this._renderControls()),this.state.on("change:activeFilters",()=>this._renderControls())),this.element}_renderControls(){this.element.innerHTML="";const a=this.state.get("selectedFilter");if(!a){this.element.appendChild(te.el("div",{className:"no-filter-selected"},"Select a filter to adjust"));return}const t=typeof this.state.getActiveFilterLayerId=="function"?this.state.getActiveFilterLayerId():this.state.get("activeLayerId"),n=this.filterManager.getFilterDef(a);if(!n){this.element.appendChild(te.el("div",{className:"no-filter-selected"},"Filter not found"));return}const i=te.el("div",{className:"controls-header"});i.appendChild(te.el("span",{className:"controls-title"},n.name)),i.appendChild(te.createButton({label:"Reset",className:"btn-text",onClick:()=>this._handleReset(a,t)})),this.element.appendChild(i);const r=te.el("div",{className:"controls-grid"}),l=this.state.getFilterValues(a);(n.controls||[]).forEach(d=>{if(d.hidden)return;const c=this._createControl(a,d,l[d.id]??d.default,t);c&&r.appendChild(c)});const s=this.filterManager.getInstance(a);if(s&&typeof s.getDynamicControls=="function"){let d=[];try{d=s.getDynamicControls()||[]}catch{}d.forEach(c=>{const u=c.property||c.id,m=l[u]??c.default,p=this._createControl(a,c,m,t);p&&r.appendChild(p)})}this.element.appendChild(r)}_createControl(a,t,n,i=null){if(t.hidden)return null;const r=t.label||t.id,l=this._normalizeControlType(t.type),s=t.property||t.id;switch(l){case"slider":return te.createSlider({id:`v2-${a}-${t.id}`,label:r,min:t.min??0,max:t.max??1,step:t.step??.01,value:typeof n=="number"?n:t.default??0,onChange:d=>{var c;return(c=this._onChange)==null?void 0:c.call(this,a,s,d,i)}});case"toggle":return te.createToggle({id:`v2-${a}-${t.id}`,label:r,checked:!!n,onChange:d=>{var c;return(c=this._onChange)==null?void 0:c.call(this,a,s,d,i)}});case"color":return te.createColorPicker({id:`v2-${a}-${t.id}`,label:r,value:typeof n=="string"&&n.startsWith("#")?n:t.default||"#000000",onChange:d=>{var c;return(c=this._onChange)==null?void 0:c.call(this,a,s,d,i)}});case"select":{const d=(t.options||[]).map(c=>typeof c=="object"&&c.value!==void 0?{value:c.value,label:c.label||String(c.value)}:{value:c,label:String(c)});return te.createSelect({id:`v2-${a}-${t.id}`,label:r,options:d,value:n??t.default,onChange:c=>{var u;return(u=this._onChange)==null?void 0:u.call(this,a,s,c,i)}})}case"text":return te.createTextInput({id:`v2-${a}-${t.id}`,label:r,value:typeof n=="string"?n:t.default??"",placeholder:t.placeholder||"",onCommit:d=>{var c;return(c=this._onChange)==null?void 0:c.call(this,a,s,d,i)}});case"button":{const d=te.el("div",{className:"button-control"});return d.appendChild(te.createButton({label:r,className:"btn-secondary",onClick:()=>{var c;(c=this._onAction)==null||c.call(this,a,t.action||t.id,i),this._renderControls()}})),d}default:return null}}_normalizeControlType(a){return{slider:"slider",range:"slider",toggle:"toggle",checkbox:"toggle",color:"color",select:"select",dropdown:"select",button:"button",text:"text"}[a]||a}_handleReset(a,t=null){var n;(n=this._onReset)==null||n.call(this,a,t),this._renderControls()}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(a=this.element)==null||a.remove(),this.element=null}}class Eh{constructor(a,t){this.state=a,this.filterManager=t,this.element=null,this._unsubscribers=[],this._onRemove=null,this._onSelect=null,this._onClearAll=null}render({onRemove:a,onSelect:t,onClearAll:n}={}){return this._onRemove=a,this._onSelect=t,this._onClearAll=n,this.element=te.el("div",{className:"panel-section","data-testid":"v2-active-stack"}),this._renderContents(),this._unsubscribers.push(this.state.on("change:activeFilters",()=>this._renderContents()),this.state.on("change:selectedFilter",()=>this._refreshSelection())),this.element}_renderContents(){this.element.innerHTML="";const a=this.state.get("activeFilters"),t=(a==null?void 0:a.size)??0,n=this._activeFilterLayerId(),i=te.el("div",{className:"panel-section-title"});if(i.appendChild(te.el("span",{},`Active (${t})`)),t>0&&this._onClearAll&&i.appendChild(te.el("button",{type:"button",className:"btn btn-text",style:{padding:"2px 8px",fontSize:"11px"},"data-testid":"v2-clear-all",onClick:()=>{var s;return(s=this._onClearAll)==null?void 0:s.call(this,n)}},"Clear all")),this.element.appendChild(i),t===0){this.element.appendChild(te.el("div",{className:"active-empty"},"No filters applied"));return}const r=te.el("div",{className:"active-stack"}),l=this.state.get("selectedFilter");for(const s of a){const d=this.filterManager.getFilterDef(s);d&&r.appendChild(this._renderChip(d,s===l,n))}this.element.appendChild(r)}_renderChip(a,t,n=null){const i=te.el("div",{className:`active-chip ${t?"selected":""}`,"data-filter":a.id,"data-testid":`v2-active-${a.id}`});i.appendChild(te.el("button",{type:"button",className:"active-chip-name","aria-label":`Select ${a.name}`,onClick:()=>{var l;return(l=this._onSelect)==null?void 0:l.call(this,a.id,n)}},a.name));const r=te.el("button",{type:"button",className:"active-chip-remove","aria-label":`Remove ${a.name}`,"data-testid":`v2-active-remove-${a.id}`,onClick:()=>{var l;return(l=this._onRemove)==null?void 0:l.call(this,a.id,n)}});return r.innerHTML=te.close,i.appendChild(r),i}_activeFilterLayerId(){return typeof this.state.getActiveFilterLayerId=="function"?this.state.getActiveFilterLayerId():this.state.get("activeLayerId")}_refreshSelection(){var n;const a=this.state.get("selectedFilter"),t=(n=this.element)==null?void 0:n.querySelectorAll(".active-chip");t&&t.forEach(i=>{const r=i.getAttribute("data-filter");i.classList.toggle("selected",r===a)})}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(a=this.element)==null||a.remove(),this.element=null}}const So=["collapsed","half","full"];class Sh{constructor(a={}){this._onSnapChange=a.onSnapChange||null,this._ariaLabel=a.ariaLabel||"Filter controls drawer",this.element=null,this._handle=null,this._body=null,this._headerSlot=null,this._snap="half",this._dragging=!1,this._dragStartY=0,this._dragStartHeight=0,this._dragPointerId=null,this._containerHeight=0}build({header:a,body:t}={}){this.element=te.el("div",{className:"editor-v2-drawer",role:"dialog","aria-label":this._ariaLabel,"data-testid":"v2-bottom-drawer","data-snap":this._snap}),this._handle=te.el("button",{type:"button",className:"drawer-handle","aria-label":"Drag to resize filters drawer","aria-expanded":this._snap==="full"?"true":"false","data-testid":"v2-drawer-handle"});const n=te.el("span",{className:"drawer-handle-grip","aria-hidden":"true"});return this._handle.appendChild(n),this._handle.addEventListener("click",i=>{if(this._wasDragging){this._wasDragging=!1,i.preventDefault();return}this._cycleSnap()}),this._handle.addEventListener("pointerdown",i=>this._onPointerDown(i)),this._handle.addEventListener("pointermove",i=>this._onPointerMove(i)),this._handle.addEventListener("pointerup",i=>this._onPointerEnd(i)),this._handle.addEventListener("pointercancel",i=>this._onPointerEnd(i)),this.element.appendChild(this._handle),this._headerSlot=te.el("div",{className:"drawer-header"}),a&&this._headerSlot.appendChild(a),this.element.appendChild(this._headerSlot),this._body=te.el("div",{className:"drawer-body"}),t&&this._body.appendChild(t),this.element.appendChild(this._body),this.element}updateContainerHeight(a){this._containerHeight=Math.max(0,Number(a)||0),this._applySnap(this._snap,{animate:!1})}snapTo(a,t={}){So.includes(a)&&this._applySnap(a,{animate:t.animate!==!1})}get snap(){return this._snap}setBodyContent(a){this._body&&(this._body.innerHTML="",a&&this._body.appendChild(a))}setHeaderContent(a){this._headerSlot&&(this._headerSlot.innerHTML="",a&&this._headerSlot.appendChild(a))}_onPointerDown(a){var t,n,i;if(!(a.button!==void 0&&a.button!==0)){this._dragging=!0,this._wasDragging=!1,this._dragPointerId=a.pointerId,this._dragStartY=a.clientY,this._dragStartHeight=((t=this.element)==null?void 0:t.offsetHeight)||0;try{(i=(n=this._handle)==null?void 0:n.setPointerCapture)==null||i.call(n,a.pointerId)}catch{}this.element&&(this.element.style.transition="none")}}_onPointerMove(a){if(!this._dragging||a.pointerId!==this._dragPointerId)return;const t=a.clientY-this._dragStartY,n=this._dragStartHeight-t;this._containerHeight||window.innerHeight;const i=this._heightForSnap("collapsed"),r=this._heightForSnap("full"),l=Math.max(i,Math.min(r,n));this.element&&(this.element.style.height=`${l}px`),Math.abs(t)>4&&(this._wasDragging=!0),a.preventDefault()}_onPointerEnd(a){var i,r,l;if(!this._dragging)return;this._dragging=!1;try{(r=(i=this._handle)==null?void 0:i.releasePointerCapture)==null||r.call(i,a.pointerId)}catch{}this._dragPointerId=null;const t=((l=this.element)==null?void 0:l.offsetHeight)||0,n=this._nearestSnap(t);this._applySnap(n,{animate:!0})}_cycleSnap(){const a=So.indexOf(this._snap),t=So[(a+1)%So.length];this._applySnap(t,{animate:!0})}_heightForSnap(a){const t=this._containerHeight||window.innerHeight||600;switch(a){case"collapsed":return 80;case"half":return Math.round(t*.45);case"full":return Math.round(t*.85);default:return Math.round(t*.45)}}_nearestSnap(a){let t=So[0],n=1/0;for(const i of So){const r=this._heightForSnap(i),l=Math.abs(r-a);l<n&&(n=l,t=i)}return t}_applySnap(a,{animate:t}){var r,l;if(!this.element)return;const n=this._snap;this._snap=a;const i=typeof window<"u"&&((r=window.matchMedia)==null?void 0:r.call(window,"(prefers-reduced-motion: reduce)").matches);t&&!i?this.element.style.transition="height 0.25s cubic-bezier(0.33, 1, 0.68, 1)":this.element.style.transition="none",this.element.style.height=`${this._heightForSnap(a)}px`,this.element.dataset.snap=a,this._handle&&this._handle.setAttribute("aria-expanded",a==="full"?"true":"false"),a!==n&&((l=this._onSnapChange)==null||l.call(this,a,n))}destroy(){var a;(a=this.element)==null||a.remove(),this.element=null,this._handle=null,this._body=null,this._headerSlot=null}}const Ch=[{id:"warm",label:"Warm",ariaLabel:"Apply warm gradient background",style:"linear-gradient(135deg, #101820 0%, #f2aa4c 100%)",fill:{gradientType:"linear",angle:135,stops:[{offset:0,color:"#101820"},{offset:1,color:"#f2aa4c"}]}},{id:"cool",label:"Cool",ariaLabel:"Apply cool gradient background",style:"linear-gradient(135deg, #0f766e 0%, #38bdf8 100%)",fill:{gradientType:"linear",angle:135,stops:[{offset:0,color:"#0f766e"},{offset:1,color:"#38bdf8"}]}},{id:"neutral",label:"Neutral",ariaLabel:"Apply neutral gradient background",style:"linear-gradient(135deg, #27272a 0%, #d4d4d8 100%)",fill:{gradientType:"linear",angle:135,stops:[{offset:0,color:"#27272a"},{offset:1,color:"#d4d4d8"}]}}];class em{constructor(a,t){this.state=a,this.editor=t,this.element=null,this._errorMessage=null,this._unsubscribers=[]}render(){return this.element=te.el("div",{className:"background-panel","data-testid":"v2-background-panel"}),this._render(),this._unsubscribers.push(this.state.on("change:layers",()=>this._render())),this.element}_render(){var f,h,v;if(!this.element)return;this.element.innerHTML="";const a=this._backgroundLayer(),t=a!=null&&a.fill&&typeof a.fill=="object"?a.fill:{kind:"transparent"},n=typeof t.fit=="string"?t.fit:"cover",i=this._backgroundBlur(a),r=(a==null?void 0:a.locked)===!0,l=t.kind==="color"&&typeof t.value=="string"?t.value:"#ffffff";this.element.appendChild(te.el("div",{className:"panel-section-title"},te.el("span",{},"Background"))),this._errorMessage&&this.element.appendChild(te.el("p",{className:"background-panel-error",role:"alert","data-testid":"v2-background-error"},this._errorMessage));const s=te.el("input",{type:"color",className:"color-input",value:l,disabled:r?"disabled":void 0,"aria-label":"Background color","data-testid":"v2-background-color",onInput:k=>{this._runAction(this.editor.setBackgroundColor(k.target.value))}});this.element.appendChild(this._field("Color",s));const d=te.el("div",{className:"background-gradient-grid"});for(const k of Ch){const y=te.el("button",{type:"button",className:"background-gradient-swatch",style:{background:k.style},"aria-label":k.ariaLabel,disabled:r?"disabled":void 0,"data-testid":`v2-background-gradient-${k.id}`,onClick:()=>{this._runAction(this.editor.setBackgroundGradient(k.fill))}},te.el("span",{className:"background-gradient-label"},k.label));d.appendChild(y)}this.element.appendChild(this._field("Gradient",d));const c=te.el("input",{type:"file",accept:"image/*",className:"background-upload-input",disabled:r?"disabled":void 0,"aria-label":"Upload background image","data-testid":"v2-background-upload",onChange:k=>{var w;const y=(w=k.target.files)==null?void 0:w[0];y&&this._runAction(this.editor.setBackgroundImageFromFile(y,{fit:n})),k.target.value=""}});this.element.appendChild(this._field("Upload",c));const u=(v=(h=(f=this.editor)==null?void 0:f._options)==null?void 0:h.backgroundReplacement)==null?void 0:v.mediaChoices;if(Array.isArray(u)&&u.length>0){const k=te.el("div",{className:"background-media-grid"});for(const y of u)y!=null&&y.source&&k.appendChild(te.el("button",{type:"button",className:"background-media-choice","aria-label":`Use ${y.label||"media"} as background`,disabled:r?"disabled":void 0,"data-testid":`v2-background-media-${y.id||y.source.mediaUuid||"choice"}`,onClick:()=>{this._runAction(this.editor.setBackgroundMediaSource(y.source,{fit:y.fit||n}))}},y.label||"Media"));this.element.appendChild(this._field("Media",k))}const m=te.el("select",{className:"select-input",disabled:r?"disabled":void 0,"aria-label":"Background image fit","data-testid":"v2-background-fit",onChange:k=>{this._runAction(this.editor.setBackgroundFit(k.target.value))}},this._option("cover","Cover",n),this._option("contain","Contain",n),this._option("stretch","Stretch",n),this._option("tile","Tile",n));this.element.appendChild(this._field("Fit",m));const p=te.el("input",{type:"range",min:"0",max:"40",step:"1",value:String(i),className:"range-input",disabled:r?"disabled":void 0,"aria-label":"Background blur","data-testid":"v2-background-blur",onInput:k=>{this._runAction(this.editor.setBackgroundBlur(Number(k.target.value)))}});this.element.appendChild(this._field("Blur",p)),this.element.appendChild(te.el("button",{type:"button",className:"btn btn-secondary background-remove-btn","aria-label":"Remove background layer",disabled:r?"disabled":void 0,"data-testid":"v2-background-remove",onClick:()=>{this._runAction(this.editor.removeBackgroundLayer())}},"Remove"))}_runAction(a){this._errorMessage=null,Promise.resolve(a).catch(t=>{var i,r;const n=t instanceof Error?t:new Error(String(t));this._errorMessage=n.message||"Background update failed",(r=(i=this.editor)==null?void 0:i.emit)==null||r.call(i,"error",n),this._render()})}_field(a,t){return te.el("label",{className:"background-field"},te.el("span",{className:"background-field-label"},a),t)}_option(a,t,n){return te.el("option",{value:a,selected:n===a?"selected":void 0},t)}_backgroundLayer(){const a=this.state.get("layers");return Array.isArray(a)?a.find(t=>(t==null?void 0:t.type)==="background"||(t==null?void 0:t.role)==="background")??null:null}_backgroundBlur(a){var r;const n=(Array.isArray(a==null?void 0:a.effects)?a.effects:[]).find(l=>(l==null?void 0:l.id)==="background-blur"),i=Number((r=n==null?void 0:n.params)==null?void 0:r.amount);return Number.isFinite(i)?i:0}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(a=this.element)==null||a.remove(),this.element=null}}class tm{constructor(a,t){this.state=a,this.editor=t,this.element=null,this._listEl=null,this._unsubscribers=[]}render(){return this.element=te.el("section",{className:"layer-stack-panel",role:"region","aria-label":"Layers","data-order":"bottom-to-top","data-testid":"v2-layer-stack-panel"}),this.element.appendChild(te.el("div",{className:"layer-stack-header"},te.el("span",{className:"layer-stack-title"},"Layers"),te.el("span",{className:"layer-stack-order"},"Bottom to top"))),this._listEl=te.el("div",{className:"layer-stack-list",role:"listbox","aria-label":"Layer order, bottom to top"}),this.element.appendChild(this._listEl),this._renderRows(),this._unsubscribers.push(this.state.on("change:layers",()=>this._renderRows()),this.state.on("change:activeLayerId",()=>this._renderRows())),this.element}_layers(){const a=this.state.get("layers");return Array.isArray(a)?a:[]}_renderRows(){if(!this._listEl)return;this._listEl.innerHTML="";const a=this._layers();if(!a.length){this._listEl.appendChild(te.el("div",{className:"layer-stack-empty",role:"status"},"No layers"));return}a.forEach((t,n)=>{this._listEl.appendChild(this._row(t,n,a.length))})}_row(a,t,n){const i=String((a==null?void 0:a.id)??""),r=this._layerName(a),l=(a==null?void 0:a.visible)!==!1,s=(a==null?void 0:a.locked)===!0,d=this.state.get("activeLayerId")===i,c=[d?"active":null,l?"visible":"hidden",s?"locked":"unlocked"].filter(Boolean).join(", "),u=te.el("div",{className:`layer-row${d?" active":""}${l?"":" hidden"}${s?" locked":""}`,role:"option","aria-selected":d?"true":"false","aria-label":`${r}, ${this._layerTypeLabel(a)}, ${c}`,"data-layer-id":i,"data-testid":`v2-layer-row-${i}`});u.appendChild(this._button({testId:`v2-layer-select-${i}`,label:`Select ${r}`,className:"layer-row-select",onClick:()=>this._runAction(()=>{var p,f;return(f=(p=this.editor).selectLayer)==null?void 0:f.call(p,i)})},this._thumbnail(a))),u.appendChild(te.el("div",{className:"layer-row-main"},te.el("span",{className:"layer-row-name"},r),te.el("span",{className:"layer-row-meta"},this._layerTypeLabel(a))));const m=te.el("div",{className:"layer-row-actions"});return m.appendChild(this._iconButton({testId:`v2-layer-${l?"hide":"show"}-${i}`,label:`${l?"Hide":"Show"} ${r}`,icon:l?te.eye:te.eyeOff,disabled:s,onClick:()=>this._runAction(()=>{var p,f;return(f=(p=this.editor).setLayerVisibility)==null?void 0:f.call(p,i,!l)})})),m.appendChild(this._iconButton({testId:`v2-layer-${s?"unlock":"lock"}-${i}`,label:`${s?"Unlock":"Lock"} ${r}`,icon:s?te.lockClosed:te.lockOpen,onClick:()=>this._runAction(()=>{var p,f;return(f=(p=this.editor).setLayerLocked)==null?void 0:f.call(p,i,!s)})})),m.appendChild(this._iconButton({testId:`v2-layer-move-up-${i}`,label:`Move ${r} up`,icon:te.chevronRight,disabled:s,onClick:()=>this._runAction(()=>{var p,f;return(f=(p=this.editor).moveLayer)==null?void 0:f.call(p,i,"up")})})),m.appendChild(this._iconButton({testId:`v2-layer-move-down-${i}`,label:`Move ${r} down`,icon:te.chevronLeft,disabled:s,onClick:()=>this._runAction(()=>{var p,f;return(f=(p=this.editor).moveLayer)==null?void 0:f.call(p,i,"down")})})),m.appendChild(this._iconButton({testId:`v2-layer-bring-front-${i}`,label:`Bring ${r} to front`,icon:te.chevronRight,disabled:s,onClick:()=>this._runAction(()=>{var p,f;return(f=(p=this.editor).moveLayer)==null?void 0:f.call(p,i,"front")})})),m.appendChild(this._iconButton({testId:`v2-layer-send-back-${i}`,label:`Send ${r} to back`,icon:te.chevronLeft,disabled:s,onClick:()=>this._runAction(()=>{var p,f;return(f=(p=this.editor).moveLayer)==null?void 0:f.call(p,i,"back")})})),m.appendChild(this._iconButton({testId:`v2-layer-rename-${i}`,label:`Rename ${r}`,icon:te.pencil,disabled:s,onClick:()=>this._renameLayer(i,r)})),m.appendChild(this._iconButton({testId:`v2-layer-duplicate-${i}`,label:`Duplicate ${r}`,icon:te.duplicate,disabled:s,onClick:()=>this._runAction(()=>{var p,f;return(f=(p=this.editor).duplicateLayer)==null?void 0:f.call(p,i)})})),m.appendChild(this._iconButton({testId:`v2-layer-delete-${i}`,label:`Delete ${r}`,icon:te.trash,disabled:s||n<=1,onClick:()=>this._runAction(()=>{var p,f;return(f=(p=this.editor).deleteLayer)==null?void 0:f.call(p,i)})})),u.appendChild(m),u}_thumbnail(a){const t=te.el("span",{className:"layer-thumb","aria-hidden":"true"}),n=a==null?void 0:a.fill;if((n==null?void 0:n.kind)==="color")t.style.background=n.value||n.color||"#ffffff";else if((n==null?void 0:n.kind)==="gradient"&&Array.isArray(n.stops)){const i=n.stops.map(r=>`${r.color} ${Math.round(Number(r.offset||0)*100)}%`).join(", ");t.style.background=`linear-gradient(${Number(n.angle||135)}deg, ${i})`}else t.innerHTML=(a==null?void 0:a.type)==="background"?te.layers:te.move;return t}_button({testId:a,label:t,...n},i){const r=te.el("button",{type:"button","aria-label":t,"data-testid":a,...n});return i&&r.appendChild(i),r}_iconButton({testId:a,label:t,icon:n,disabled:i=!1,onClick:r}){const l=te.el("button",{type:"button",className:"layer-action-btn","aria-label":t,title:t,disabled:i?"disabled":void 0,"data-testid":a,onClick:r});return l.innerHTML=n,l}_renameLayer(a,t){var i;const n=(i=window.prompt)==null?void 0:i.call(window,"Layer name",t);typeof n=="string"&&this._runAction(()=>{var r,l;return(l=(r=this.editor).renameLayer)==null?void 0:l.call(r,a,n)})}_runAction(a){var t,n;try{Promise.resolve(a()).catch(i=>{var r,l;return(l=(r=this.editor).emit)==null?void 0:l.call(r,"error",{error:i,context:"layer-stack"})})}catch(i){(n=(t=this.editor).emit)==null||n.call(t,"error",{error:i,context:"layer-stack"})}}_layerName(a){return(typeof(a==null?void 0:a.name)=="string"?a.name.trim():"")||"Layer"}_layerTypeLabel(a){return(a==null?void 0:a.type)==="background"||(a==null?void 0:a.role)==="background"?"Background":(a==null?void 0:a.role)==="subject"?"Subject":(a==null?void 0:a.type)==="text"?"Text":"Image"}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(a=this.element)==null||a.remove(),this.element=null,this._listEl=null}}const xh=[{value:"400",label:"Regular"},{value:"500",label:"Medium"},{value:"600",label:"Semibold"},{value:"700",label:"Bold"},{value:"800",label:"Heavy"}],Nh=[{value:"left",label:"Left"},{value:"center",label:"Center"},{value:"right",label:"Right"}],Vh=[{value:"normal",label:"Normal"},{value:"multiply",label:"Multiply"},{value:"screen",label:"Screen"},{value:"overlay",label:"Overlay"}],ir={stroke:{enabled:!1,color:"#000000",width:0},shadow:{enabled:!1,color:"#000000",alpha:.5,blur:0,distance:0,angle:45},glow:{enabled:!1,color:"#ffffff",alpha:.5,blur:0},backdrop:{enabled:!1,color:"#000000",opacity:.5,padding:0,radius:0,blur:0}};class am{constructor(a,t){this.state=a,this.editor=t,this.element=null,this._errorMessage=null,this._unsubscribers=[]}render(){return this.element=te.el("div",{className:"text-panel","data-testid":"v2-text-panel"}),this._render(),this._unsubscribers.push(this.state.on("change:layers",()=>this._render()),this.state.on("change:activeLayerId",()=>this._render())),this.element}_render(){if(!this.element)return;this.element.innerHTML="";const a=this._activeTextLayer(),t=(a==null?void 0:a.locked)===!0;if(this.element.appendChild(te.el("div",{className:"text-panel-header"},te.el("div",{className:"panel-section-title"},te.el("span",{},"Text")),te.el("button",{type:"button",className:"btn btn-secondary","data-testid":"v2-text-add",onClick:()=>{var d,c;return this._runAction((c=(d=this.editor).addTextLayer)==null?void 0:c.call(d))}},"Add text"))),this._errorMessage&&this.element.appendChild(te.el("p",{className:"text-panel-error",role:"alert","data-testid":"v2-text-error"},this._errorMessage)),!a){this.element.appendChild(te.el("p",{className:"text-panel-empty"},"Select or add a text layer."));return}const n=a.text&&typeof a.text=="object"?a.text:{},i=n.style&&typeof n.style=="object"?n.style:{},r=n.box&&typeof n.box=="object"?n.box:{},l=a.transform&&typeof a.transform=="object"?a.transform:{},s=this._textEffects(n.effects);this.element.appendChild(this._contentControl(a.id,n.content??"",t)),this.element.appendChild(this._controlGrid([this._numberField({label:"Opacity",testId:"v2-text-opacity",value:a.opacity??1,min:0,max:1,step:.05,disabled:t,onInput:d=>{var c,u;return this._runAction((u=(c=this.editor).updateTextLayer)==null?void 0:u.call(c,a.id,{opacity:d}))}}),this._selectField({label:"Blend",testId:"v2-text-blend-mode",value:a.blendMode||"normal",options:Vh,disabled:t,onChange:d=>{var c,u;return this._runAction((u=(c=this.editor).updateTextLayer)==null?void 0:u.call(c,a.id,{blendMode:d}))}})])),this.element.appendChild(this._selectField({label:"Font",testId:"v2-text-font-family",value:i.fontFamily||"Inter",options:te.TEXT_LAYER_FONT_FAMILIES.map(d=>({value:d,label:d})),disabled:t,onChange:d=>this._updateStyle(a.id,{fontFamily:d})})),this.element.appendChild(this._controlGrid([this._numberField({label:"Size",testId:"v2-text-font-size",value:i.fontSize??64,min:8,max:400,step:1,disabled:t,onInput:d=>this._updateStyle(a.id,{fontSize:d})}),this._selectField({label:"Weight",testId:"v2-text-font-weight",value:String(i.fontWeight??700),options:xh,disabled:t,onChange:d=>this._updateStyle(a.id,{fontWeight:Number(d)})}),this._selectField({label:"Style",testId:"v2-text-font-style",value:i.fontStyle||"normal",options:[{value:"normal",label:"Normal"},{value:"italic",label:"Italic"}],disabled:t,onChange:d=>this._updateStyle(a.id,{fontStyle:d})}),this._selectField({label:"Align",testId:"v2-text-align",value:i.align||"center",options:Nh,disabled:t,onChange:d=>this._updateStyle(a.id,{align:d})})])),this.element.appendChild(this._controlGrid([this._colorField({label:"Fill",testId:"v2-text-fill",value:i.fill||"#ffffff",disabled:t,onInput:d=>this._updateStyle(a.id,{fill:d})}),this._numberField({label:"Line",testId:"v2-text-line-height",value:i.lineHeight??1.2,min:.8,max:3,step:.05,disabled:t,onInput:d=>this._updateStyle(a.id,{lineHeight:d})}),this._numberField({label:"Track",testId:"v2-text-letter-spacing",value:i.letterSpacing??0,min:-100,max:100,step:.5,disabled:t,onInput:d=>this._updateStyle(a.id,{letterSpacing:d})})])),this.element.appendChild(this._controlGrid([this._numberField({label:"X",testId:"v2-text-box-x",value:r.x??.2,min:0,max:1,step:.01,disabled:t,onInput:d=>this._updateBox(a.id,{x:d})}),this._numberField({label:"Y",testId:"v2-text-box-y",value:r.y??.2,min:0,max:1,step:.01,disabled:t,onInput:d=>this._updateBox(a.id,{y:d})}),this._numberField({label:"W",testId:"v2-text-box-width",value:r.width??.6,min:.05,max:1,step:.01,disabled:t,onInput:d=>this._updateBox(a.id,{width:d})}),this._numberField({label:"H",testId:"v2-text-box-height",value:r.height??.18,min:.05,max:1,step:.01,disabled:t,onInput:d=>this._updateBox(a.id,{height:d})}),this._numberField({label:"Rotate",testId:"v2-text-rotation",value:l.rotation??0,min:0,max:360,step:1,disabled:t,onInput:d=>{var c,u;return this._runAction((u=(c=this.editor).updateTextLayer)==null?void 0:u.call(c,a.id,{transform:{rotation:d}}))}})])),this.element.appendChild(this._effectSection("Stroke",[this._checkboxField({label:"Stroke",testId:"v2-text-stroke-enabled",checked:s.stroke.enabled,disabled:t,onChange:d=>this._updateEffects(a.id,{stroke:{enabled:d}})}),this._colorField({label:"Stroke Color",testId:"v2-text-stroke-color",value:s.stroke.color,disabled:t,onInput:d=>this._updateEffects(a.id,{stroke:{color:d}})}),this._numberField({label:"Stroke Width",testId:"v2-text-stroke-width",value:s.stroke.width,min:0,max:80,step:1,disabled:t,onInput:d=>this._updateEffects(a.id,{stroke:{width:d}})})])),this.element.appendChild(this._effectSection("Shadow",[this._checkboxField({label:"Shadow",testId:"v2-text-shadow-enabled",checked:s.shadow.enabled,disabled:t,onChange:d=>this._updateEffects(a.id,{shadow:{enabled:d}})}),this._colorField({label:"Shadow Color",testId:"v2-text-shadow-color",value:s.shadow.color,disabled:t,onInput:d=>this._updateEffects(a.id,{shadow:{color:d}})}),this._numberField({label:"Shadow Alpha",testId:"v2-text-shadow-alpha",value:s.shadow.alpha,min:0,max:1,step:.05,disabled:t,onInput:d=>this._updateEffects(a.id,{shadow:{alpha:d}})}),this._numberField({label:"Shadow Blur",testId:"v2-text-shadow-blur",value:s.shadow.blur,min:0,max:120,step:1,disabled:t,onInput:d=>this._updateEffects(a.id,{shadow:{blur:d}})}),this._numberField({label:"Shadow Distance",testId:"v2-text-shadow-distance",value:s.shadow.distance,min:0,max:200,step:1,disabled:t,onInput:d=>this._updateEffects(a.id,{shadow:{distance:d}})}),this._numberField({label:"Shadow Angle",testId:"v2-text-shadow-angle",value:s.shadow.angle,min:0,max:360,step:1,disabled:t,onInput:d=>this._updateEffects(a.id,{shadow:{angle:d}})})])),this.element.appendChild(this._effectSection("Glow",[this._checkboxField({label:"Glow",testId:"v2-text-glow-enabled",checked:s.glow.enabled,disabled:t,onChange:d=>this._updateEffects(a.id,{glow:{enabled:d}})}),this._colorField({label:"Glow Color",testId:"v2-text-glow-color",value:s.glow.color,disabled:t,onInput:d=>this._updateEffects(a.id,{glow:{color:d}})}),this._numberField({label:"Glow Alpha",testId:"v2-text-glow-alpha",value:s.glow.alpha,min:0,max:1,step:.05,disabled:t,onInput:d=>this._updateEffects(a.id,{glow:{alpha:d}})}),this._numberField({label:"Glow Blur",testId:"v2-text-glow-blur",value:s.glow.blur,min:0,max:120,step:1,disabled:t,onInput:d=>this._updateEffects(a.id,{glow:{blur:d}})})])),this.element.appendChild(this._effectSection("Backdrop",[this._checkboxField({label:"Backdrop",testId:"v2-text-backdrop-enabled",checked:s.backdrop.enabled,disabled:t,onChange:d=>this._updateEffects(a.id,{backdrop:{enabled:d}})}),this._colorField({label:"Backdrop Color",testId:"v2-text-backdrop-color",value:s.backdrop.color,disabled:t,onInput:d=>this._updateEffects(a.id,{backdrop:{color:d}})}),this._numberField({label:"Backdrop Opacity",testId:"v2-text-backdrop-opacity",value:s.backdrop.opacity,min:0,max:1,step:.05,disabled:t,onInput:d=>this._updateEffects(a.id,{backdrop:{opacity:d}})}),this._numberField({label:"Backdrop Padding",testId:"v2-text-backdrop-padding",value:s.backdrop.padding,min:0,max:200,step:1,disabled:t,onInput:d=>this._updateEffects(a.id,{backdrop:{padding:d}})}),this._numberField({label:"Backdrop Radius",testId:"v2-text-backdrop-radius",value:s.backdrop.radius,min:0,max:200,step:1,disabled:t,onInput:d=>this._updateEffects(a.id,{backdrop:{radius:d}})}),this._numberField({label:"Backdrop Blur",testId:"v2-text-backdrop-blur",value:s.backdrop.blur,min:0,max:80,step:1,disabled:t,onInput:d=>this._updateEffects(a.id,{backdrop:{blur:d}})})]))}_contentControl(a,t,n){const i=te.el("div",{className:"text-field text-content-field"});i.appendChild(te.el("label",{className:"text-field-label",for:"v2-text-content"},"Content"));let r=t==null?"":String(t);const l=te.el("textarea",{id:"v2-text-content",className:"text-area-input",rows:"4",disabled:n?"disabled":void 0,"data-testid":"v2-text-content",onInput:d=>{r=d.target.value},onBlur:()=>{var d,c;r!==t&&this._runAction((c=(d=this.editor).updateTextLayer)==null?void 0:c.call(d,a,{content:r}))},onKeyDown:d=>{var c,u;if(d.key==="Escape"){d.preventDefault(),r=t==null?"":String(t),l.value=r,l.blur();return}d.key==="Enter"&&(d.metaKey||d.ctrlKey)&&(d.preventDefault(),this._runAction((u=(c=this.editor).updateTextLayer)==null?void 0:u.call(c,a,{content:r})),l.blur())}});l.value=r,i.appendChild(l);const s=te.el("div",{className:"text-content-actions"});return s.appendChild(te.el("button",{type:"button",className:"btn btn-text",disabled:n?"disabled":void 0,"data-testid":"v2-text-cancel",onClick:()=>{r=t==null?"":String(t),l.value=r}},"Cancel")),s.appendChild(te.el("button",{type:"button",className:"btn btn-secondary",disabled:n?"disabled":void 0,"data-testid":"v2-text-commit",onClick:()=>{var d,c;return this._runAction((c=(d=this.editor).updateTextLayer)==null?void 0:c.call(d,a,{content:r}))}},"Commit")),i.appendChild(s),i}_controlGrid(a){const t=te.el("div",{className:"text-control-grid"});for(const n of a)t.appendChild(n);return t}_effectSection(a,t){return te.el("div",{className:"text-effect-section"},te.el("div",{className:"text-effect-title"},a),this._controlGrid(t))}_selectField({label:a,testId:t,value:n,options:i,disabled:r,onChange:l}){const s=te.el("select",{className:"select-input",disabled:r?"disabled":void 0,"data-testid":t,onChange:d=>l(d.target.value)});for(const d of i)s.appendChild(te.el("option",{value:d.value,selected:String(n)===String(d.value)?"selected":void 0},d.label));return this._field(a,s)}_numberField({label:a,testId:t,value:n,min:i,max:r,step:l,disabled:s,onInput:d}){const c=te.el("input",{type:"number",className:"text-number-input",min:String(i),max:String(r),step:String(l),value:String(n),disabled:s?"disabled":void 0,"data-testid":t,onInput:u=>d(Number(u.target.value))});return this._field(a,c)}_colorField({label:a,testId:t,value:n,disabled:i,onInput:r}){const l=te.el("input",{type:"color",className:"color-input",value:n,disabled:i?"disabled":void 0,"data-testid":t,onInput:s=>r(s.target.value)});return this._field(a,l)}_checkboxField({label:a,testId:t,checked:n,disabled:i,onChange:r}){const l=te.el("input",{type:"checkbox",className:"text-checkbox-input",checked:n?"checked":void 0,disabled:i?"disabled":void 0,"data-testid":t,onChange:s=>r(s.target.checked===!0)});return te.el("label",{className:"text-field text-checkbox-field"},te.el("span",{className:"text-field-label"},a),l)}_field(a,t){return te.el("label",{className:"text-field"},te.el("span",{className:"text-field-label"},a),t)}_updateStyle(a,t){var n,i;this._runAction((i=(n=this.editor).updateTextLayer)==null?void 0:i.call(n,a,{style:t}))}_updateBox(a,t){var n,i;this._runAction((i=(n=this.editor).updateTextLayer)==null?void 0:i.call(n,a,{box:t}))}_updateEffects(a,t){var n,i;this._runAction((i=(n=this.editor).updateTextLayer)==null?void 0:i.call(n,a,{effects:t}))}_textEffects(a){const t=a&&typeof a=="object"?a:{};return{stroke:{...ir.stroke,...t.stroke&&typeof t.stroke=="object"?t.stroke:{}},shadow:{...ir.shadow,...t.shadow&&typeof t.shadow=="object"?t.shadow:{}},glow:{...ir.glow,...t.glow&&typeof t.glow=="object"?t.glow:{}},backdrop:{...ir.backdrop,...t.backdrop&&typeof t.backdrop=="object"?t.backdrop:{}}}}_runAction(a){this._errorMessage=null,Promise.resolve(a).catch(t=>{var i,r;const n=t instanceof Error?t:new Error(String(t));this._errorMessage=n.message||"Text update failed",(r=(i=this.editor)==null?void 0:i.emit)==null||r.call(i,"error",n),this._render()})}_activeTextLayer(){const a=this.state.get("activeLayerId"),t=this.state.get("layers");return!a||!Array.isArray(t)?null:t.find(n=>(n==null?void 0:n.id)===a&&(n.type==="text"||n.role==="text"))??null}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(a=this.element)==null||a.remove(),this.element=null}}class Th{constructor(a,t,n){this.state=a,this.filterManager=t,this.editor=n,this.element=null,this._headerEl=null,this._bodyEl=null,this._view="categories",this._onNavigate=null,this._callbacks=null,this._unsubscribers=[],this._categoryTabs=null,this._filterListView=null,this._filterControlsView=null,this._backgroundPanel=null,this._layerStackPanel=null,this._textPanel=null}build(a){return this._callbacks=a,this._onNavigate=a.onViewChange||null,this.element=te.el("div",{className:"drawer-nav","data-testid":"v2-mobile-nav"}),this._headerEl=te.el("div",{className:"drawer-nav-header"}),this.element.appendChild(this._headerEl),this._bodyEl=te.el("div",{className:"drawer-nav-body"}),this.element.appendChild(this._bodyEl),this._buildViews(),this._unsubscribers.push(this.state.on("change:selectedFilter",({value:t})=>{t&&this._view!=="controls"&&this.navigateTo("controls")}),this.state.on("change:selectedCategory",()=>{}),this.state.on("change:mode",({value:t})=>{t==="filters"&&this._view!=="categories"&&!this.state.get("selectedFilter")&&this.navigateTo("categories")})),this.navigateTo("categories"),this.element}_buildViews(){this._categoryTabs=new qu(this.state,this.editor),this._categoryTabsEl=this._categoryTabs.render({onSelect:a=>{if(a==="background"||a==="layers"||a==="text"){this.navigateTo(a);return}this.navigateTo("filters")}}),this._filterListView=new Yu(this.state,this.filterManager),this._filterListEl=this._filterListView.render({onToggle:(a,t,n)=>this._callbacks.onFilterToggle(a,t,n),onSelect:(a,t)=>{this._callbacks.onFilterSelect(a,t),this.navigateTo("controls")}}),this._filterControlsView=new Qu(this.state,this.filterManager),this._filterControlsEl=this._filterControlsView.render({onChange:(a,t,n,i)=>this._callbacks.onFilterChange(a,t,n,i),onReset:(a,t)=>this._callbacks.onFilterReset(a,t),onAction:(a,t,n)=>this._callbacks.onFilterAction(a,t,n)}),this._backgroundPanel=new em(this.state,this.editor),this._backgroundPanelEl=this._backgroundPanel.render(),this._layerStackPanel=new tm(this.state,this.editor),this._layerStackPanelEl=this._layerStackPanel.render(),this._textPanel=new am(this.state,this.editor),this._textPanelEl=this._textPanel.render()}navigateTo(a){var n;if(!this.element)return;this._view=a,this._renderHeader(),this._bodyEl.innerHTML="";let t=null;switch(a){case"categories":t=this._categoryTabsEl;break;case"filters":t=this._filterListEl;break;case"controls":t=this._filterControlsEl;break;case"background":t=this._backgroundPanelEl;break;case"layers":t=this._layerStackPanelEl;break;case"text":t=this._textPanelEl;break;default:t=this._categoryTabsEl}t&&this._bodyEl.appendChild(t),(n=this._onNavigate)==null||n.call(this,a)}_renderHeader(){if(!this._headerEl)return;if(this._headerEl.innerHTML="",this._view!=="categories"){const n=te.el("button",{type:"button",className:"drawer-back-btn","aria-label":"Go back","data-testid":"v2-drawer-back",onClick:()=>this._goBack()});n.innerHTML=te.chevronLeft,this._headerEl.appendChild(n)}const t=this._titleForView(this._view);if(this._headerEl.appendChild(te.el("h2",{className:"drawer-nav-title"},t)),this._view==="controls"){const n=this.state.get("selectedFilter");if(n){const i=this._activeFilterLayerId();this._headerEl.appendChild(te.createButton({label:"Reset",className:"btn-text",onClick:()=>this._callbacks.onFilterReset(n,i)}))}}}_activeFilterLayerId(){return typeof this.state.getActiveFilterLayerId=="function"?this.state.getActiveFilterLayerId():this.state.get("activeLayerId")}_titleForView(a){switch(a){case"categories":return"Filters";case"filters":{const t=this.state.get("selectedCategory");return this._categoryLabel(t)||"Filters"}case"background":return"Background";case"layers":return"Layers";case"text":return"Text";case"controls":{const t=this.state.get("selectedFilter"),n=t?this.filterManager.getFilterDef(t):null;return(n==null?void 0:n.name)||"Filter"}default:return""}}_categoryLabel(a){var t;return a&&((t=te.EDITOR_CATEGORIES.find(n=>n.id===a))==null?void 0:t.name)||null}_goBack(){this._view==="controls"?(this.state.set("selectedFilter",null),this.navigateTo("filters")):(this._view==="filters"||this._view==="background"||this._view==="layers"||this._view==="text")&&this.navigateTo("categories")}get currentView(){return this._view}destroy(){var a,t,n,i,r,l,s;this._unsubscribers.forEach(d=>d()),this._unsubscribers=[],(a=this._categoryTabs)==null||a.destroy(),(t=this._filterListView)==null||t.destroy(),(n=this._filterControlsView)==null||n.destroy(),(i=this._backgroundPanel)==null||i.destroy(),(r=this._layerStackPanel)==null||r.destroy(),(l=this._textPanel)==null||l.destroy(),(s=this.element)==null||s.remove(),this.element=null}}class Bh{constructor(a,t){this.state=a,this.filterManager=t,this.element=null,this._onSelect=null,this._onRemove=null,this._unsubscribers=[]}render({onSelect:a,onRemove:t}={}){return this._onSelect=a,this._onRemove=t,this.element=te.el("div",{className:"mobile-active-chips",role:"region","aria-label":"Active filters","data-testid":"v2-mobile-active-chips"}),this._renderChips(),this._unsubscribers.push(this.state.on("change:activeFilters",()=>this._renderChips()),this.state.on("change:selectedFilter",()=>this._refreshSelection())),this.element}_renderChips(){this.element.innerHTML="";const a=this.state.get("activeFilters");if(((a==null?void 0:a.size)??0)===0){this.element.style.display="none";return}this.element.style.display="";const n=te.el("div",{className:"mobile-active-track"}),i=this.state.get("selectedFilter"),r=this._activeFilterLayerId();for(const l of a){const s=this.filterManager.getFilterDef(l);s&&n.appendChild(this._renderChip(s,l===i,r))}this.element.appendChild(n)}_renderChip(a,t,n=null){const i=te.el("div",{className:`mobile-active-chip ${t?"selected":""}`,"data-filter":a.id,"data-testid":`v2-mobile-chip-${a.id}`});i.appendChild(te.el("button",{type:"button",className:"mobile-active-chip-name","aria-label":`Edit ${a.name}`,onClick:()=>{var l;return(l=this._onSelect)==null?void 0:l.call(this,a.id,n)}},a.name));const r=te.el("button",{type:"button",className:"mobile-active-chip-remove","aria-label":`Remove ${a.name}`,"data-testid":`v2-mobile-chip-remove-${a.id}`,onClick:l=>{var s;l.stopPropagation(),(s=this._onRemove)==null||s.call(this,a.id,n)}});return r.innerHTML=te.close,i.appendChild(r),i}_activeFilterLayerId(){return typeof this.state.getActiveFilterLayerId=="function"?this.state.getActiveFilterLayerId():this.state.get("activeLayerId")}_refreshSelection(){var n;const a=this.state.get("selectedFilter"),t=(n=this.element)==null?void 0:n.querySelectorAll(".mobile-active-chip");t==null||t.forEach(i=>{const r=i.getAttribute("data-filter");i.classList.toggle("selected",r===a)})}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(a=this.element)==null||a.remove(),this.element=null}}const rc="(max-width: 900px)";let Ih=class{constructor(a,t,n){this.state=a,this.filterManager=t,this.editor=n,this.root=null,this.canvasSection=null,this.canvasContainer=null,this.cropOverlay=null,this._callbacks=null,this._isMobile=!1,this._panel=null,this._categoryTabs=null,this._filterListView=null,this._filterControlsView=null,this._activeStack=null,this._backgroundPanel=null,this._layerStackPanel=null,this._textPanel=null,this._desktopBackgroundSection=null,this._desktopLayerSection=null,this._desktopTextSection=null,this._desktopFilterListSection=null,this._desktopCropWrapper=null,this._mobileChips=null,this._mobileDrawer=null,this._mobileNav=null,this._mobileCropWrapper=null,this._cropControlsEl=null,this._unsubscribers=[],this._mql=null,this._mqlHandler=null,this._resizeObserver=null}build(a){var t;return this._callbacks=a,this.root=te.el("div",{className:"editor-v2-body"}),this.canvasSection=te.el("div",{className:"editor-v2-canvas"}),this.canvasContainer=te.el("div",{className:"canvas-container"}),this.cropOverlay=te.el("canvas",{className:"crop-overlay","aria-hidden":"true"}),this.canvasSection.appendChild(this.canvasContainer),this.canvasSection.appendChild(this.cropOverlay),this._zoomOverlay=this._buildCanvasZoomOverlay(),this.canvasSection.appendChild(this._zoomOverlay),this.root.appendChild(this.canvasSection),this._isMobile=typeof window<"u"&&((t=window.matchMedia)==null?void 0:t.call(window,rc).matches)===!0,this._isMobile?this._buildMobileShell():this._buildDesktopShell(),typeof window<"u"&&window.matchMedia&&(this._mql=window.matchMedia(rc),this._mqlHandler=n=>this._handleBreakpointChange(n.matches),this._mql.addEventListener?this._mql.addEventListener("change",this._mqlHandler):this._mql.addListener&&this._mql.addListener(this._mqlHandler)),this._unsubscribers.push(this.state.on("change:mode",({value:n})=>this._applyMode(n)),this.state.on("change:selectedCategory",()=>this._applyMode(this.state.get("mode")))),{root:this.root,canvasContainer:this.canvasContainer,cropOverlay:this.cropOverlay}}mountCropControls(a){this._cropControlsEl=a,this._mountCropControlsInActiveShell()}_buildDesktopShell(){this._panel=te.el("div",{className:"editor-v2-panel","data-testid":"v2-inspector-panel"}),this._categoryTabs=new qu(this.state,this.editor),this._panel.appendChild(this._categoryTabs.render({onSelect:()=>this._handleDesktopCategoryChange()}));const a=te.el("div",{className:"panel-body"});this._desktopFilterListSection=te.el("div",{className:"panel-section"}),this._desktopFilterListSection.appendChild(te.el("div",{className:"panel-section-title"},te.el("span",{},"Filters"))),this._filterListView=new Yu(this.state,this.filterManager),this._desktopFilterListSection.appendChild(this._filterListView.render({onToggle:(t,n,i)=>this._callbacks.onFilterToggle(t,n,i),onSelect:(t,n)=>this._callbacks.onFilterSelect(t,n)})),a.appendChild(this._desktopFilterListSection),this._filterControlsView=new Qu(this.state,this.filterManager),a.appendChild(this._filterControlsView.render({onChange:(t,n,i,r)=>this._callbacks.onFilterChange(t,n,i,r),onReset:(t,n)=>this._callbacks.onFilterReset(t,n),onAction:(t,n,i)=>this._callbacks.onFilterAction(t,n,i)})),this._desktopCropWrapper=te.el("div",{className:"crop-controls-wrapper",style:{display:"none"}}),a.appendChild(this._desktopCropWrapper),this._activeStack=new Eh(this.state,this.filterManager),a.appendChild(this._activeStack.render({onRemove:(t,n)=>this._callbacks.onFilterToggle(t,!1,n),onSelect:(t,n)=>this._callbacks.onFilterSelect(t,n),onClearAll:t=>{var n,i;return(i=(n=this._callbacks).onClearAll)==null?void 0:i.call(n,t)}})),this._desktopBackgroundSection=te.el("div",{className:"panel-section",style:{display:"none"}}),this._backgroundPanel=new em(this.state,this.editor),this._desktopBackgroundSection.appendChild(this._backgroundPanel.render()),a.appendChild(this._desktopBackgroundSection),this._desktopLayerSection=te.el("div",{className:"panel-section",style:{display:"none"}}),this._layerStackPanel=new tm(this.state,this.editor),this._desktopLayerSection.appendChild(this._layerStackPanel.render()),a.appendChild(this._desktopLayerSection),this._desktopTextSection=te.el("div",{className:"panel-section",style:{display:"none"}}),this._textPanel=new am(this.state,this.editor),this._desktopTextSection.appendChild(this._textPanel.render()),a.appendChild(this._desktopTextSection),this._panel.appendChild(a),this.root.appendChild(this._panel),this._mountCropControlsInActiveShell(),this._applyMode(this.state.get("mode"))}_buildMobileShell(){this._mobileChips=new Bh(this.state,this.filterManager);const a=this._mobileChips.render({onSelect:(r,l)=>{var s,d;this._callbacks.onFilterSelect(r,l),(s=this._mobileDrawer)==null||s.snapTo("full"),(d=this._mobileNav)==null||d.navigateTo("controls")},onRemove:(r,l)=>this._callbacks.onFilterToggle(r,!1,l)});this.root.appendChild(a),this._mobileDrawer=new Sh({onSnapChange:r=>{this.canvasContainer&&window.dispatchEvent(new Event("resize"))}}),this._mobileNav=new Th(this.state,this.filterManager,this.editor);const t=this._mobileNav.build({onFilterToggle:this._callbacks.onFilterToggle,onFilterSelect:this._callbacks.onFilterSelect,onFilterChange:this._callbacks.onFilterChange,onFilterReset:this._callbacks.onFilterReset,onFilterAction:this._callbacks.onFilterAction,onViewChange:r=>{var l;r==="controls"&&((l=this._mobileDrawer)==null?void 0:l.snap)==="collapsed"&&this._mobileDrawer.snapTo("half")}});this._mobileCropWrapper=te.el("div",{className:"crop-controls-wrapper",style:{display:"none"}});const n=te.el("div",{className:"drawer-content"});n.appendChild(t),n.appendChild(this._mobileCropWrapper);const i=this._mobileDrawer.build({body:n});this.root.appendChild(i),this._wireDrawerSizing(),this._mountCropControlsInActiveShell(),this._applyMode(this.state.get("mode"))}_wireDrawerSizing(){if(!this.root||!this._mobileDrawer)return;const a=()=>{const t=this.root.getBoundingClientRect().height;this._mobileDrawer.updateContainerHeight(t)};a(),this._resizeObserver=new ResizeObserver(()=>a()),this._resizeObserver.observe(this.root)}_destroyDesktopShell(){var a,t,n,i,r,l,s,d,c,u;(a=this._categoryTabs)==null||a.destroy(),this._categoryTabs=null,(t=this._filterListView)==null||t.destroy(),this._filterListView=null,(n=this._filterControlsView)==null||n.destroy(),this._filterControlsView=null,(i=this._activeStack)==null||i.destroy(),this._activeStack=null,(r=this._backgroundPanel)==null||r.destroy(),this._backgroundPanel=null,(l=this._layerStackPanel)==null||l.destroy(),this._layerStackPanel=null,(s=this._textPanel)==null||s.destroy(),this._textPanel=null,this._desktopBackgroundSection=null,this._desktopLayerSection=null,this._desktopTextSection=null,this._desktopFilterListSection=null,(d=this._desktopCropWrapper)!=null&&d.parentElement&&((c=this._cropControlsEl)==null?void 0:c.parentElement)===this._desktopCropWrapper&&this._desktopCropWrapper.removeChild(this._cropControlsEl),this._desktopCropWrapper=null,(u=this._panel)==null||u.remove(),this._panel=null}_destroyMobileShell(){var a,t,n,i,r;(a=this._resizeObserver)==null||a.disconnect(),this._resizeObserver=null,(t=this._mobileNav)==null||t.destroy(),this._mobileNav=null,(n=this._mobileChips)==null||n.destroy(),this._mobileChips=null,this._mobileCropWrapper&&((i=this._cropControlsEl)==null?void 0:i.parentElement)===this._mobileCropWrapper&&this._mobileCropWrapper.removeChild(this._cropControlsEl),this._mobileCropWrapper=null,(r=this._mobileDrawer)==null||r.destroy(),this._mobileDrawer=null}_handleBreakpointChange(a){a!==this._isMobile&&(this._isMobile=a,a?(this._destroyDesktopShell(),this._buildMobileShell()):(this._destroyMobileShell(),this._buildDesktopShell()))}_mountCropControlsInActiveShell(){if(!this._cropControlsEl)return;this._cropControlsEl.remove();const a=this._isMobile?this._mobileCropWrapper:this._desktopCropWrapper;a==null||a.appendChild(this._cropControlsEl)}_handleDesktopCategoryChange(){if(this.state.get("mode")==="crop"||["background","layers","text"].includes(this.state.get("selectedCategory")))return;const t=this.state.get("selectedFilter");if(!t)return;this.filterManager.getFiltersByCategory(this.state.get("selectedCategory")).some(i=>i.id===t)||this.state.set("selectedFilter",null)}_applyMode(a){var s,d,c;const t=a==="crop",n=!t&&this.state.get("selectedCategory")==="background",i=!t&&this.state.get("selectedCategory")==="layers",r=!t&&this.state.get("selectedCategory")==="text",l=n||i||r;this._desktopFilterListSection&&(this._desktopFilterListSection.style.display=t||l?"none":""),(s=this._filterControlsView)!=null&&s.element&&(this._filterControlsView.element.style.display=t||l?"none":""),(d=this._activeStack)!=null&&d.element&&(this._activeStack.element.style.display=t||l?"none":""),this._desktopBackgroundSection&&(this._desktopBackgroundSection.style.display=n?"":"none"),this._desktopLayerSection&&(this._desktopLayerSection.style.display=i?"":"none"),this._desktopTextSection&&(this._desktopTextSection.style.display=r?"":"none"),this._desktopCropWrapper&&(this._desktopCropWrapper.style.display=t?"":"none"),(c=this._mobileNav)!=null&&c.element&&(this._mobileNav.element.style.display=t?"none":""),this._mobileCropWrapper&&(this._mobileCropWrapper.style.display=t?"":"none"),t&&this._mobileDrawer&&this._mobileDrawer.snapTo("half")}_buildCanvasZoomOverlay(){const a=te.el("div",{className:"canvas-zoom-overlay",role:"group","aria-label":"Zoom controls"}),t=te.createIconButton({icon:te.zoomOut,title:"Zoom Out",className:"canvas-zoom-btn",testId:"btn-zoom-out",ariaLabel:"Zoom out",onClick:()=>{const l=this.state.get("zoom");this.editor.setZoom(l-.25)}}),n=te.el("span",{className:"canvas-zoom-label","aria-live":"polite","aria-atomic":"true",role:"status"},`${Math.round((this.state.get("zoom")??1)*100)}%`),i=te.createIconButton({icon:te.zoomIn,title:"Zoom In",className:"canvas-zoom-btn",testId:"btn-zoom-in",ariaLabel:"Zoom in",onClick:()=>{const l=this.state.get("zoom");this.editor.setZoom(l+.25)}}),r=te.createIconButton({icon:te.expand,title:"Fit to Screen",className:"canvas-zoom-btn",testId:"btn-fit-screen",ariaLabel:"Fit to screen",onClick:()=>this.editor.fitToScreen()});return a.appendChild(t),a.appendChild(n),a.appendChild(i),a.appendChild(r),this._unsubscribers.push(this.state.on("change:zoom",({value:l})=>{n.textContent=`${Math.round(l*100)}%`})),a}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],this._mql&&this._mqlHandler&&(this._mql.removeEventListener?this._mql.removeEventListener("change",this._mqlHandler):this._mql.removeListener&&this._mql.removeListener(this._mqlHandler),this._mql=null,this._mqlHandler=null),this._destroyDesktopShell(),this._destroyMobileShell(),(a=this.root)==null||a.remove(),this.root=null,this.canvasSection=null,this.canvasContainer=null,this.cropOverlay=null}};function No(o){if(!Number.isFinite(Number(o)))return 0;const a=Number(o)%360;return a<0?a+360:a}function Mh(o,a){const t=No(o);return(No(a)-t+540)%360-180}function $h(){return new Date().toISOString()}function rr(o){return typeof o=="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(o)}class Fh extends te.EventEmitter{constructor(a,t={}){var r,l,s,d,c;if(super(),!a)throw new Error("VanillaImageEditorV2: container element is required");this._container=a,this._destroyed=!1,this._loadVersion=0,this._objectUrls=new Set,this._activeObjectUrl=null;const n=t.preset?te.getPreset(t.preset):null,i=n?{initialMode:n.initialMode==="crop"?"crop":"adjust",cropShape:n.cropShape,initialAspectRatio:n.aspectRatio}:{};this._options={theme:"auto",initialImage:null,initialMode:"adjust",cropShape:"free",initialAspectRatio:"free",layout:"split-panel",backgroundRemoval:{enabled:!0,endpoint:"/api/v1/media/background-removal/preview",optionsEndpoint:"/api/v1/media/background-removal/options",savedEndpoint:"/api/v1/media/{media}/background-removal",fallbackEndpoint:null},backgroundReplacement:{assetEndpoint:null,materializeEndpoint:null,targetMediaUuid:null,mediaChoices:[]},...i,...t},this._preset=n,this._state=te.createState(),this._state.set("theme",this._options.theme),this._state.set("crop.shape",this._options.cropShape),this._state.set("crop.aspect",this._options.initialAspectRatio),this._preset&&(this._state.set("lockCropShape",!!this._preset.lockCropShape),this._state.set("lockAspectRatio",!!this._preset.lockAspectRatio),this._state.set("showFilters",this._preset.showFilters!==!1),this._state.set("showCropControls",this._preset.showCropControls!==!1),this._state.set("autoZoomOnCropOverflow",!!this._preset.autoZoomOnCropOverflow)),this._renderer=new te.PixiRenderer,this._filterManager=new te.FilterManager(this._state,this._renderer),this._cropManager=new te.CropManager(this._state,this._renderer),this._removeBgManager=null,this._backgroundRemovalAvailable=!1,((r=this._options.backgroundRemoval)==null?void 0:r.enabled)!==!1&&(this._removeBgManager=new te.RemoveBgManager({endpoint:(l=this._options.backgroundRemoval)==null?void 0:l.endpoint,optionsEndpoint:(s=this._options.backgroundRemoval)==null?void 0:s.optionsEndpoint,savedEndpoint:(d=this._options.backgroundRemoval)==null?void 0:d.savedEndpoint,fallbackEndpoint:(c=this._options.backgroundRemoval)==null?void 0:c.fallbackEndpoint})),this._loadingOverlay=null,this._toolbar=null,this._layout=null,this._cropControls=null,this._editorEl=null,this._toolbarContainer=null,this._canvasContainer=null,this._cropOverlay=null,this._fileInput=null,this._mobileSaveBar=null,this._mobileSaveBtn=null,this._mobileSaveUnsub=null,this._resizeObserver=null,this._initPromise=Promise.resolve(this._init()).catch(u=>{this._destroyed||this.emit("error",u instanceof Error?u:new Error(String(u)))})}async _init(){this._state.detectTheme(),this._buildDOM(),!(!await this._renderer.mount(this._canvasContainer,0,{backgroundAlpha:0})||this._destroyed)&&(this._cropManager.setOverlayCanvas(this._cropOverlay),this._initUI(),this._setupResizeObserver(),this._setupWindowResize(),this._subscribeToState(),this._refreshBackgroundRemovalAvailability(),this._options.initialImage&&await this.loadImage(this._options.initialImage),this.emit("ready"))}_buildDOM(){this._container.innerHTML="",this._editorEl=te.el("div",{className:`vanilla-image-editor-v2 ${this._state.get("isDarkMode")?"dark":"light"}`}),this._toolbarContainer=te.el("div",{className:"editor-v2-toolbar"}),this._editorEl.appendChild(this._toolbarContainer),this._layout=new Ih(this._state,this._filterManager,this);const{root:a,canvasContainer:t,cropOverlay:n}=this._layout.build({onFilterToggle:(i,r,l)=>this._handleFilterToggle(i,r,l),onFilterSelect:(i,r)=>this._handleFilterSelect(i,r),onFilterChange:(i,r,l,s)=>this._handleFilterChange(i,r,l,s),onFilterReset:(i,r)=>this._handleFilterReset(i,r),onFilterAction:(i,r,l)=>this._handleFilterAction(i,r,l),onClearAll:i=>this.resetAll(i)});this._canvasContainer=t,this._cropOverlay=n,this._editorEl.appendChild(a),this._buildMobileSaveBar(),this._mobileSaveBar&&this._editorEl.appendChild(this._mobileSaveBar),this._fileInput=te.el("input",{type:"file",accept:"image/*",className:"hidden-file-input",style:{display:"none"},"aria-label":"Choose image file to edit",onChange:i=>this._handleFileSelect(i)}),this._editorEl.appendChild(this._fileInput),this._container.appendChild(this._editorEl)}_initUI(){this._toolbar=new te.Toolbar(this._state,this),this._toolbarContainer.appendChild(this._toolbar.render()),this._cropControls=new te.CropControls(this._state,this._cropManager,this);const a=this._cropControls.render();this._layout.mountCropControls(a)}_setupResizeObserver(){if(!this._canvasContainer)return;let a=null;this._resizeObserver=new ResizeObserver(()=>{clearTimeout(a),a=setTimeout(()=>{var t,n;this._destroyed||!this._canvasContainer||(this._renderer.resizeTo(this._canvasContainer),this._state.get("mode")==="crop"&&((n=(t=this._cropManager).drawOverlay)==null||n.call(t)))},50)}),this._resizeObserver.observe(this._canvasContainer)}_setupWindowResize(){this._handleWindowResize=()=>{},window.addEventListener("resize",this._handleWindowResize)}_subscribeToState(){this._state.on("change:isDarkMode",({value:a})=>{var t,n;(t=this._editorEl)==null||t.classList.toggle("dark",a),(n=this._editorEl)==null||n.classList.toggle("light",!a)})}async _handleFileSelect(a){var n;const t=(n=a.target.files)==null?void 0:n[0];t&&await this.loadImage(t),this._fileInput.value=""}_matchesExpectedFilterLayer(a){if(a===void 0)return!0;if(a===null)return typeof this._state.getActiveFilterLayerId=="function"?this._state.getActiveFilterLayerId()===null:this._state.get("activeLayerId")===null;const t=typeof a=="string"?a.trim():"";return t===""?!1:typeof this._state.getActiveFilterLayerId=="function"?this._state.getActiveFilterLayerId()===t:this._state.get("activeLayerId")===t}_handleFilterToggle(a,t,n=void 0){this._filterManager.toggle(a,t,n)!==!1&&(t?this._state.set("selectedFilter",a):this._state.get("selectedFilter")===a&&this._state.set("selectedFilter",null))}_handleFilterSelect(a,t=void 0){var r;if(!this._matchesExpectedFilterLayer(t))return;const n=this._state.get("activeFilters");if(!((r=n==null?void 0:n.has)!=null&&r.call(n,a))&&this._filterManager.toggle(a,!0,t)===!1)return;this._state.set("selectedFilter",a);const i=this._filterManager.getFilterDef(a);if(typeof(i==null?void 0:i.category)=="string"){const l=te.REGISTRY_TO_UI[i.category]||i.category;this._state.get("selectedCategory")!==l&&this._state.set("selectedCategory",l)}}_handleFilterChange(a,t,n,i=void 0){this._filterManager.updateValue(a,t,n,i)||this._filterManager.applyFilters(),this._renderer.render()}_handleFilterReset(a,t=void 0){var n,i;this._filterManager.resetValues(a,t),(i=(n=this._filterManager)==null?void 0:n.applyFilters)==null||i.call(n)}_handleFilterAction(a,t,n=void 0){this._filterManager.performFilterAction(a,t,n)}_revokeObjectUrl(a){!a||!this._objectUrls.has(a)||(URL.revokeObjectURL(a),this._objectUrls.delete(a),this._activeObjectUrl===a&&(this._activeObjectUrl=null))}_replaceActiveObjectUrl(a){const t=this._activeObjectUrl;this._activeObjectUrl=a,this._objectUrls.add(a),t&&t!==a&&this._revokeObjectUrl(t)}_clearActiveObjectUrl(){this._activeObjectUrl&&this._revokeObjectUrl(this._activeObjectUrl)}async _renderCurrentDocument(){var a,t;return(t=(a=this._renderer).renderLayerDocument)==null?void 0:t.call(a,this._state.getSerializableDocument(),{fallbackImageUrl:this._state.get("imageUrl")??null})}async setBackgroundFill(a){var n;const t=this._state.setBackgroundFill(a);return await this._renderCurrentDocument(),this.emit("background-changed",{layerId:t,fill:((n=this._state.getLayer(t))==null?void 0:n.fill)??null}),t}async setBackgroundColor(a){return this.setBackgroundFill({kind:"color",value:typeof a=="string"&&a.trim()!==""?a:"#ffffff"})}async setBackgroundGradient(a={}){return this.setBackgroundFill({kind:"gradient",gradientType:a.gradientType||"linear",angle:Number.isFinite(Number(a.angle))?Number(a.angle):135,stops:Array.isArray(a.stops)?a.stops:[{offset:0,color:"#111827"},{offset:1,color:"#f59e0b"}],fit:a.fit||"cover"})}async setBackgroundMediaSource(a,t={}){if(!a||typeof a!="object")throw new Error("Background source is required");return this.setBackgroundFill({kind:"media",source:a,fit:t.fit||"cover"})}async setBackgroundImageFromFile(a,t={}){var i,r;if(!(a instanceof Blob))throw new Error("Background image file is required");const n=URL.createObjectURL(a);this._objectUrls.add(n);try{if(((r=(i=this._state).isBackgroundLayerLocked)==null?void 0:r.call(i))===!0)throw new Error("Background layer is locked");const l=this._captureEditorDocumentContext(),s=await this._probeImageDimensions(n);if(!this._isCurrentEditorDocumentContext(l))return URL.revokeObjectURL(n),this._objectUrls.delete(n),null;const d=this._state.ensureBackgroundLayer();if(!d)throw new Error("Background layer is locked");let c=null,u=this._captureEditorDocumentContext(d);if(this._canUploadBackgroundAsset()){if(!await this._materializeBackgroundLayerForUpload(d))return URL.revokeObjectURL(n),this._objectUrls.delete(n),null;if(u=this._captureEditorDocumentContext(d),c=await this._uploadBackgroundAsset(a,d,n),!this._isCurrentEditorDocumentContext(u))return URL.revokeObjectURL(n),this._objectUrls.delete(n),null}return c||(c={kind:"runtime",runtimeRef:`background-${Date.now()}`,originalWidth:s.width,originalHeight:s.height,sourceHash:null,previewUrl:n}),this._isCurrentEditorDocumentContext(u)?this.setBackgroundMediaSource(c,{fit:t.fit||"cover"}):(URL.revokeObjectURL(n),this._objectUrls.delete(n),null)}catch(l){throw URL.revokeObjectURL(n),this._objectUrls.delete(n),l}}async setBackgroundFit(a){if(!this._state.setBackgroundFit(a))return!1;const n=this._backgroundLayerId();await this._renderCurrentDocument();const i=n?this._state.getLayer(n):null;return i&&this.emit("background-changed",{layerId:n,fill:i.fill??null}),!0}async setBackgroundBlur(a){if(!this._state.setBackgroundBlur(a))return!1;const n=this._backgroundLayerId();await this._renderCurrentDocument();const i=n?this._state.getLayer(n):null;return i&&this.emit("background-changed",{layerId:n,effects:i.effects??[]}),!0}_backgroundLayerId(){const a=this._state.getSerializableDocument(),t=Array.isArray(a==null?void 0:a.layers)?a.layers.find(n=>(n==null?void 0:n.type)==="background"||(n==null?void 0:n.role)==="background"):null;return typeof(t==null?void 0:t.id)=="string"?t.id:null}async removeBackgroundLayer(){return this._state.removeBackgroundLayer()?(await this._renderCurrentDocument(),this.emit("background-changed",{layerId:null,fill:null}),!0):!1}async selectLayer(a){var n,i;return this._state.setActiveLayer(a)?((i=(n=this._filterManager)==null?void 0:n.applyFilters)==null||i.call(n),this.emit("layer-changed",{action:"select",layerId:a}),!0):!1}async renameLayer(a,t){var i;return this._state.renameLayer(a,t)?(this.emit("layer-changed",{action:"rename",layerId:a,name:((i=this._state.getLayer(a))==null?void 0:i.name)??null}),!0):!1}async duplicateLayer(a){const t=this._state.duplicateLayer(a);return t?(await this._renderCurrentDocument(),this.emit("layer-changed",{action:"duplicate",layerId:a,duplicateLayerId:t}),t):null}async deleteLayer(a){return this._state.deleteLayer(a)?(await this._renderCurrentDocument(),this.emit("layer-changed",{action:"delete",layerId:a,activeLayerId:this._state.get("activeLayerId")}),!0):!1}async moveLayer(a,t){return this._state.moveLayer(a,t)?(await this._renderCurrentDocument(),this.emit("layer-changed",{action:"move",layerId:a,direction:t}),!0):!1}async setLayerVisibility(a,t){return this._state.setLayerVisibility(a,t)?(await this._renderCurrentDocument(),this.emit("layer-changed",{action:"visibility",layerId:a,visible:!!t}),!0):!1}async setLayerLocked(a,t){return this._state.setLayerLocked(a,t)?(this.emit("layer-changed",{action:"lock",layerId:a,locked:!!t}),!0):!1}async addTextLayer(a={}){const t=this._state.addTextLayer(a);return t?(this._state.set("selectedCategory","text"),await this._renderCurrentDocument(),this.emit("layer-changed",{action:"text-add",layerId:t}),t):null}async updateTextLayer(a,t={}){return this._state.updateTextLayer(a,t)?(await this._renderCurrentDocument(),this.emit("layer-changed",{action:"text-update",layerId:a,patch:t}),!0):!1}_canUploadBackgroundAsset(){var r,l;const a=(l=(r=this._options)==null?void 0:r.backgroundReplacement)==null?void 0:l.assetEndpoint,t=this._state.getEditorDocumentBinding(),n=this._state.getSerializableDocument(),i=this._backgroundTargetMediaUuid(n);return typeof a=="string"&&a.trim()!==""&&!!(t!=null&&t.documentId)&&!!n&&typeof i=="string"&&i.trim()!==""}async _materializeBackgroundLayerForUpload(a){return this._materializeCurrentDocument("Background layer materialization failed",a)}_documentMaterializationSignature(a){try{return JSON.stringify(a??null)}catch{return null}}_captureDocumentMaterializationContext(a,t,n=null){return{loadVersion:this._loadVersion,documentId:(t==null?void 0:t.documentId)??null,documentRevisionId:(t==null?void 0:t.documentRevisionId)??null,documentRevisionNumber:(t==null?void 0:t.documentRevisionNumber)??null,documentSignature:this._documentMaterializationSignature(a),requiredLayerId:n}}_captureEditorDocumentContext(a=null){return{loadVersion:this._loadVersion,documentSignature:this._documentMaterializationSignature(this._state.getSerializableDocument()),requiredLayerId:a}}_isCurrentEditorDocumentContext(a){return!(!a||this._destroyed||this._loadVersion!==a.loadVersion||this._documentMaterializationSignature(this._state.getSerializableDocument())!==a.documentSignature||a.requiredLayerId&&!this._state.getLayer(a.requiredLayerId))}_isCurrentDocumentMaterializationContext(a){if(!a||this._destroyed||this._loadVersion!==a.loadVersion)return!1;const t=this._state.getEditorDocumentBinding();if(!t||(t.documentId??null)!==a.documentId||(t.documentRevisionId??null)!==a.documentRevisionId||(t.documentRevisionNumber??null)!==a.documentRevisionNumber)return!1;const n=this._state.getSerializableDocument();return!(this._documentMaterializationSignature(n)!==a.documentSignature||a.requiredLayerId&&!this._state.getLayer(a.requiredLayerId))}async _materializeCurrentDocument(a="Editor document materialization failed",t=null){const n=this._backgroundMaterializeEndpoint(),i=this._state.getEditorDocumentBinding(),r=this._state.getSerializableDocument();if(!n||!(i!=null&&i.documentId)||!r||t!==null&&!t)return!1;const l=this._resolveBackgroundEndpoint(n,r);if(!l)return!1;const s=this._captureDocumentMaterializationContext(r,i,t),d=rr(i.documentId)?i.documentId:null,c=await fetch(l,{method:"POST",credentials:"include",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({document_id:d,base_document_revision:d===null?null:i.documentRevisionNumber,document:r})});let u=null;try{u=await c.json()}catch{u=null}if(!c.ok){const m=(u==null?void 0:u.message)||a;throw new Error(m)}return this._isCurrentDocumentMaterializationContext(s)?(u!=null&&u.document&&this._state.setEditorDocument(u.document,{documentId:u.document_id??i.documentId,documentRevisionId:u.document_revision_id??i.documentRevisionId,documentRevisionNumber:typeof u.document_revision_number=="number"?u.document_revision_number:i.documentRevisionNumber}),!0):!1}async _uploadBackgroundAsset(a,t,n){var f,h,v;const i=(h=(f=this._options)==null?void 0:f.backgroundReplacement)==null?void 0:h.assetEndpoint,r=this._state.getEditorDocumentBinding(),l=this._state.getSerializableDocument();if(!i||!(r!=null&&r.documentId)||!l)return null;const s=this._resolveBackgroundEndpoint(i,l);if(!s)return null;const d=await this._sha256File(a),c=new FormData;c.append("asset_file",a,a instanceof File&&a.name?a.name:"background.png"),c.append("asset_kind","background-upload"),c.append("document_id",r.documentId),c.append("layer_id",t),c.append("client_hash",d);const u=await fetch(s,{method:"POST",credentials:"include",headers:{Accept:"application/json"},body:c});if(!u.ok)throw new Error("Background upload failed");const m=await u.json(),p=(v=m==null?void 0:m.asset)==null?void 0:v.source;if(!p||typeof p!="object")throw new Error("Background upload did not return a usable layer source");return{...p,previewUrl:n}}_backgroundMaterializeEndpoint(){var i,r,l,s,d,c;const a=(r=(i=this._options)==null?void 0:i.backgroundReplacement)==null?void 0:r.materializeEndpoint;if(typeof a=="string"&&a.trim()!=="")return a;const t=(s=(l=this._options)==null?void 0:l.backgroundReplacement)==null?void 0:s.assetEndpoint;if(typeof t=="string"&&t.trim()!=="")return t.replace(/\/editor-assets\/?$/,"/editor-documents/materialize");const n=(c=(d=this._options)==null?void 0:d.backgroundRemoval)==null?void 0:c.savedEndpoint;return typeof n=="string"&&n.trim()!==""?n.replace(/\/background-removal\/?$/,"/editor-documents/materialize"):null}_resolveBackgroundEndpoint(a,t){if(typeof a!="string"||a.trim()==="")return null;const n=this._backgroundTargetMediaUuid(t);return a.includes("{media}")?typeof n!="string"||n.trim()===""?null:a.replace("{media}",encodeURIComponent(n)):a}_backgroundTargetMediaUuid(a){var n,i;const t=(i=(n=this._options)==null?void 0:n.backgroundReplacement)==null?void 0:i.targetMediaUuid;return typeof t=="string"&&t.trim()!==""?t:typeof(a==null?void 0:a.sourceMediaUuid)=="string"&&a.sourceMediaUuid.trim()!==""?a.sourceMediaUuid:null}async _sha256File(a){var i,r,l;const t=await a.arrayBuffer(),n=await((l=(r=(i=globalThis.crypto)==null?void 0:i.subtle)==null?void 0:r.digest)==null?void 0:l.call(r,"SHA-256",t));if(!n)throw new Error("Background upload hashing is unavailable");return Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")}_probeImageDimensions(a){return new Promise(t=>{const n=new Image;n.onload=()=>t({width:Math.max(1,Math.round(n.naturalWidth||n.width||1)),height:Math.max(1,Math.round(n.naturalHeight||n.height||1))}),n.onerror=()=>t({width:1,height:1}),n.src=a})}setFilterRegistry(a){this._filterManager.setRegistry(a)}async loadImage(a,t={}){var s,d,c,u;if(this._destroyed)return;(d=(s=this._removeBgManager)==null?void 0:s.cancelActiveRequests)==null||d.call(s,"image-load");const n=++this._loadVersion;let i=a,r=null;this._resetEditorState(),this._state.set("hasImage",!1),this._state.set("imageUrl",null),a instanceof Blob&&(i=URL.createObjectURL(a),r=i,this._objectUrls.add(i));const l=await this._renderer.loadTexture(i,{isCurrent:()=>!this._destroyed&&this._loadVersion===n});if(this._destroyed||this._loadVersion!==n){this._revokeObjectUrl(r);return}if(!l){this._revokeObjectUrl(r),this.emit("error",new Error("Failed to load image"));return}r?this._replaceActiveObjectUrl(r):this._clearActiveObjectUrl(),this._state.set("hasImage",!0),this._state.set("imageUrl",i),t.document?await this._hydrateDocument(t.document,{documentId:t.documentId??(rr((c=t.document)==null?void 0:c.id)?t.document.id:null),documentRevisionId:t.documentRevisionId??null,documentRevisionNumber:t.documentRevisionNumber??((u=t.document)==null?void 0:u.revision)??null,fallbackImageUrl:i}):this._initializeDefaultDocument(i),t.state&&this._hydrateState(t.state),this._options.initialMode==="crop"&&this.setMode("crop"),this.emit("imageLoaded",{url:i})}_resetEditorState(){this._filterManager.resetAll(),this._state.set("crop.rect",null),this._state.set("crop.appliedRect",null),this._state.set("crop.appliedShape",null),this._state.set("crop.appliedAspect",null),this._state.set("crop.dirty",!1),this._state.set("crop.shape",this._options.cropShape||"free"),this._state.set("crop.aspect",this._options.initialAspectRatio||"free"),this._state.set("transform.rotation",0),this._state.clearEditorDocument(),this._state.get("mode")==="crop"&&(this._cropManager.disable(),this._state.set("mode","filters"))}_initializeDefaultDocument(a){var c,u,m,p;const t=this._renderer.originalTexture,n=Math.max(1,Math.round((t==null?void 0:t.width)||1)),i=Math.max(1,Math.round((t==null?void 0:t.height)||1)),r=$h(),l=typeof((u=(c=this._options)==null?void 0:c.backgroundReplacement)==null?void 0:u.targetMediaUuid)=="string"&&this._options.backgroundReplacement.targetMediaUuid.trim()!==""?this._options.backgroundReplacement.targetMediaUuid.trim():null,s=l?{kind:"media",mediaUuid:l,originalWidth:n,originalHeight:i,sourceHash:null}:{kind:"runtime",runtimeRef:"source-image",originalWidth:n,originalHeight:i,sourceHash:null,previewUrl:typeof a=="string"?a:null},d={version:2,id:`client-doc-${Date.now()}`,sourceMediaUuid:l,canvas:{width:n,height:i,backgroundPreviewColor:null},revision:0,layers:[{id:"subject-layer",type:"image",role:"subject",name:"Subject",visible:!0,locked:!1,opacity:1,blendMode:"normal",transform:{x:0,y:0,scaleX:1,scaleY:1,rotation:0},effects:[],metadata:{},source:s,crop:null,filters:[]}],activeLayerId:"subject-layer",export:{mimeType:"image/png",quality:null,preserveTransparency:!0,matteColor:null,trimTransparentBounds:!1},createdAt:r,updatedAt:r};this._state.setEditorDocument(d,{documentId:null,documentRevisionId:null,documentRevisionNumber:0}),(p=(m=this._renderer).renderLayerDocument)==null||p.call(m,d,{fallbackImageUrl:typeof a=="string"?a:null})}async _hydrateDocument(a,t={}){var n,i;!a||a.version!==2||(this._state.setEditorDocument(a,{documentId:t.documentId??(rr(a.id)?a.id:null),documentRevisionId:t.documentRevisionId??null,documentRevisionNumber:t.documentRevisionNumber??a.revision??null}),await((i=(n=this._renderer).renderLayerDocument)==null?void 0:i.call(n,this._state.getSerializableDocument(),{fallbackImageUrl:t.fallbackImageUrl??this._state.get("imageUrl")??null})))}_hydrateState(a){var n;if(!a||a.version!==1)return;const t=No(((n=a.transform)==null?void 0:n.rotation)??0);if(t!==0&&this._renderer.rotateBy(t)&&this._state.set("transform.rotation",t),a.crop){const i=a.crop.shape||"free",r=a.crop.aspectRatio||"free";a.crop.rect&&(this._cropManager.applyFromPixelRect(a.crop.rect,i),this._state.set("crop.appliedRect",{...a.crop.rect}),this._state.set("crop.appliedShape",i),this._state.set("crop.appliedAspect",r)),this._state.set("crop.shape",i),this._state.set("crop.aspect",r)}if(Array.isArray(a.filters)){let i=null;for(const r of a.filters)if(r.enabled&&(i===null&&(i=r.id),this._state.toggleFilter(r.id,!0),this._filterManager.initializeValues(r.id),r.values))for(const[l,s]of Object.entries(r.values))this._state.setFilterValue(r.id,l,s);if(i!==null){this._state.set("selectedFilter",i);const r=this._filterManager.getFilterDef(i);if(typeof(r==null?void 0:r.category)=="string"){const l=te.REGISTRY_TO_UI[r.category]??r.category;this._state.set("selectedCategory",l)}}this._filterManager.applyFilters()}}openFilePicker(){var a;(a=this._fileInput)==null||a.click()}exportImage(a="png",t=.92,n={}){return!this._state.get("hasImage")||!this._applyPendingCropBeforeExport("VanillaImageEditorV2.exportImage")?null:this._renderer.exportImage(a,t,n.maxEdge??0,n.dontUpscale!==!1,n.maxPixels??0)}async exportBlob(a="png",t=.92,n={}){return!this._state.get("hasImage")||!this._applyPendingCropBeforeExport("VanillaImageEditorV2.exportBlob")?null:this._renderer.exportBlob(a,t,n)}_applyPendingCropBeforeExport(a){return!(this._state.get("crop.rect")&&!this._cropManager.apply())}async save(){if(!this._state.get("hasImage"))return;this._state.set("isSaving",!0);let a=null;try{const t=await this.exportBlob("png",.92);if(!t)throw new Error("Failed to export image");const n=i.createElement("a");a=URL.createObjectURL(t.blob),n.href=a,n.download=`edited-image-${Date.now()}.png`,i.body.appendChild(n),n.click(),i.body.removeChild(n);const i=this.getSerializableDocument(),r=this.getEditorDocumentBinding();this.emit("save",{blob:t.blob,mimeType:t.blob.type||"image/png",dimensions:{width:t.width,height:t.height},state:this.getSerializableState(),document:i,documentId:(r==null?void 0:r.documentId)??(rr(i==null?void 0:i.id)?i.id:null),documentRevisionId:(r==null?void 0:r.documentRevisionId)??null,documentRevisionNumber:(r==null?void 0:r.documentRevisionNumber)??(i==null?void 0:i.revision)??null})}catch(t){this.emit("error",{error:t})}finally{a&&URL.revokeObjectURL(a),this._state.set("isSaving",!1)}}getSerializableState(){const a=this._state.get("activeFilters"),t=[];if(a)for(const l of a){const s=this._state.getFilterValues(l);t.push({id:l,enabled:!0,values:{...s}})}const n=this._state.get("crop.appliedRect"),i=this._state.get("crop.rect"),r=n||i;return{version:1,crop:{rect:r?{...r}:null,aspectRatio:this._state.get("crop.appliedAspect")||this._state.get("crop.aspect")||"free",shape:this._state.get("crop.appliedShape")||this._state.get("crop.shape")||"free"},transform:{rotation:No(this._state.get("transform.rotation")??0)},filters:t}}getSerializableDocument(){return this._state.getSerializableDocument()}getEditorDocumentBinding(){return this._state.getEditorDocumentBinding()}close(){this.emit("cancel")}setZoom(a){this._renderer.setZoom(a)}fitToScreen(){this._renderer.fitToScreen()}resetAll(a=void 0){this._filterManager.resetAll(a)}rotateBy(a){const t=this._state.get("transform.rotation")??0;return this.setRotationAngle(Number(t)+Number(a))}setRotationAngle(a){if(!this._state.get("hasImage"))return!1;const t=No(this._state.get("transform.rotation")??0),n=No(a),i=Mh(t,n),r=this._state.get("mode")==="crop";if(Math.abs(i)>.001){if(r&&this._cropManager.disable(),!this._renderer.rotateBy(i))return r&&this._cropManager.enable(),!1;this._filterManager.applyFilters(),this._state.set("crop.rect",null),this._state.set("crop.dirty",!1),r&&this._cropManager.enable()}return this._state.set("transform.rotation",n),this.emit("transformChanged",{rotation:n}),!0}resetRotation(){return this.setRotationAngle(0)}toggleTheme(){const a=this._state.get("isDarkMode");this._state.set("isDarkMode",!a)}setTheme(a){this._state.set("theme",a),this._state.detectTheme()}setMode(a){a==="crop"?this._cropManager.enable():this._cropManager.disable(),this._state.set("mode",a)}getState(){return this._state.getAll()}async removeBackground(a={}){var t,n,i,r,l,s,d,c,u,m;if(!this._removeBgManager)throw new Error("Background removal is not enabled");if(!this._state.get("hasImage"))throw new Error("No image loaded");if(!this.canRemoveBackground())throw new Error("Background removal is not available for the current editor state");this._state.set("isProcessing",!0),this._showLoadingOverlay("Removing background...");try{const p=this._activeBackgroundRemovalLayer();if(this._hasSavedEditorDocumentBinding()&&p!==null&&this._backgroundMaterializeEndpoint()&&!await this._materializeCurrentDocument("Background removal materialization failed"))return this.emit("background-removal-stale",{operationId:a.operationId??null,targetLayerId:p.id}),{stale:!0};const f=this._buildSavedBackgroundRemovalContext(a);if(f){const b=await this._removeBgManager.removeSavedMediaBackground(f.request);if(!this._isCurrentBackgroundRemovalContext(f,b))return this.emit("background-removal-stale",{operationId:f.request.operationId,targetLayerId:f.request.targetLayerId}),{stale:!0};const R=(t=b==null?void 0:b.result)==null?void 0:t.source;if(!R||R.kind!=="edit-asset")throw new Error("Background removal did not return a persisted layer source");const V=(n=b==null?void 0:b.result)==null?void 0:n.previewDataUrl;return typeof V=="string"&&V.startsWith("data:image/")&&(!await this._renderer.loadTexture(V,{isCurrent:()=>!this._destroyed&&this._isCurrentBackgroundRemovalContext(f,b)})||!this._isCurrentBackgroundRemovalContext(f,b))?(this.emit("background-removal-stale",{operationId:f.request.operationId,targetLayerId:f.request.targetLayerId}),{stale:!0}):this._isCurrentBackgroundRemovalContext(f,b)?(this._state.replaceLayerSource(f.request.targetLayerId,R),await((r=(i=this._renderer).renderLayerDocument)==null?void 0:r.call(i,this._state.getSerializableDocument(),{fallbackImageUrl:this._state.get("imageUrl")??null})),this.emit("background-removed",{model:(l=b==null?void 0:b.result)==null?void 0:l.model,processMs:(s=b==null?void 0:b.result)==null?void 0:s.process_ms,source:R,operationId:f.request.operationId,targetLayerId:f.request.targetLayerId}),{model:(d=b==null?void 0:b.result)==null?void 0:d.model,processMs:(c=b==null?void 0:b.result)==null?void 0:c.process_ms,source:R}):(this.emit("background-removal-stale",{operationId:f.request.operationId,targetLayerId:f.request.targetLayerId}),{stale:!0})}const h=this._buildPreviewBackgroundRemovalInput(a);if(!h)throw new Error("Failed to export image for background removal");const v=this._buildPreviewBackgroundRemovalContext(h.options),k=await this._removeBgManager.preparePreviewRequest(h.imageData,h.options),y=this._resolvePreviewBackgroundRemovalContext(v,k);if(!await this._isCurrentPreviewBackgroundRemovalContext(y))return this.emit("background-removal-stale",{operationId:y.operationId,sourceHash:y.sourceHash,targetLayerId:y.activeLayerId??null}),{stale:!0};const w=await this._removeBgManager.removeBackground(k.blob,k);if(!await this._isCurrentPreviewBackgroundRemovalContext(y,w))return this.emit("background-removal-stale",{operationId:y.operationId,sourceHash:y.sourceHash}),{stale:!0};const g=await this._applyPreviewBackgroundRemovalResult(y,w);return g?(this.emit("background-removed",{model:w.model,processMs:w.processMs,operationId:y.operationId,targetLayerId:y.activeLayerId??null,source:g.source}),{model:w.model,processMs:w.processMs,...g.source?{source:g.source}:{}}):(this.emit("background-removal-stale",{operationId:y.operationId,sourceHash:y.sourceHash,targetLayerId:y.activeLayerId??null}),{stale:!0})}catch(p){throw this.emit("error",{error:p,context:"background-removal"}),p}finally{(m=(u=this._state)==null?void 0:u.set)==null||m.call(u,"isProcessing",!1),this._hideLoadingOverlay()}}async isBackgroundRemovalAvailable(){return this._removeBgManager?this._refreshBackgroundRemovalAvailability():!1}canRemoveBackground(){if(!this._removeBgManager||this._state.get("hasImage")!==!0||this._backgroundRemovalAvailable!==!0)return!1;const a=this._state.getSerializableDocument();return(a==null?void 0:a.version)===2&&Array.isArray(a.layers)?this._activeBackgroundRemovalLayer({requireSourceHash:this._hasSavedEditorDocumentBinding()})!==null:!0}async _refreshBackgroundRemovalAvailability(){if(!this._removeBgManager)return this._backgroundRemovalAvailable=!1,this._state.set("backgroundRemovalAvailable",!1),!1;const a=await this._removeBgManager.isAvailable();return this._destroyed?!1:(this._backgroundRemovalAvailable=a,this._state.set("backgroundRemovalAvailable",a),a)}_hasSavedEditorDocumentBinding(){const a=this._state.getEditorDocumentBinding();return!!(a!=null&&a.documentId)&&!!(a!=null&&a.documentRevisionId)}_activeBackgroundRemovalLayer(a={}){var l;const t=a.requireSourceHash!==!1,n=this._state.get("activeLayerId");if(!n)return null;const i=this._state.getLayer(n);if(!i||i.type!=="image"||i.locked===!0||i.visible===!1)return null;const r=(l=i==null?void 0:i.source)==null?void 0:l.sourceHash;return t&&(typeof r!="string"||!/^[a-f0-9]{64}$/i.test(r))?null:i}_buildSavedBackgroundRemovalContext(a={}){var u,m,p,f,h;const t=this._state.getSerializableDocument(),n=this._state.getEditorDocumentBinding();if(!t||!(n!=null&&n.documentId)||!(n!=null&&n.documentRevisionId))return null;const i=typeof t.sourceMediaUuid=="string"&&t.sourceMediaUuid!==""?t.sourceMediaUuid:null;if(!i)return null;const r=this._activeBackgroundRemovalLayer({requireSourceHash:!0}),l=r==null?void 0:r.id,s=(u=r==null?void 0:r.source)==null?void 0:u.sourceHash;if(!l||typeof s!="string"||!/^[a-f0-9]{64}$/i.test(s))return null;const d=a.operationId||((p=(m=globalThis.crypto)==null?void 0:m.randomUUID)==null?void 0:p.call(m))||`op-${Date.now()}-${Math.random().toString(16).slice(2)}`,c={loadVersion:this._loadVersion,activeLayerId:l,documentRevisionId:n.documentRevisionId,documentSignature:this._documentMaterializationSignature(t),sourceHash:s,request:{targetMediaUuid:i,operationId:d,documentId:n.documentId,documentRevisionId:n.documentRevisionId,targetLayerId:l,expectedSourceHash:s,tier:a.tier||((h=(f=this._options)==null?void 0:f.backgroundRemoval)==null?void 0:h.defaultTier)||"balanced"}};return a.model&&(c.request.model=a.model),a.alpha_matting!==void 0&&(c.request.alpha_matting=a.alpha_matting),a.max_megapixels!==void 0&&(c.request.max_megapixels=a.max_megapixels),c}_buildPreviewBackgroundRemovalContext(a){const t=this._state.getSerializableDocument(),n=(t==null?void 0:t.version)===2&&Array.isArray(t.layers),i=n?this._activeBackgroundRemovalLayer({requireSourceHash:!1}):null;return{loadVersion:this._loadVersion,activeLayerId:n?(i==null?void 0:i.id)??null:null,documentSignature:n?this._documentMaterializationSignature(t):null,imageUrl:this._state.get("imageUrl")??null,operationId:a.operationId,sessionKey:a.sessionKey,sourceHash:a.sourceHash,targetRef:a.targetRef??null}}_resolvePreviewBackgroundRemovalContext(a,t){return{...a,operationId:t.operationId,sessionKey:t.sessionKey,sourceHash:t.sourceHash,targetRef:t.targetRef??a.targetRef??null}}_buildPreviewBackgroundRemovalInput(a={}){const t=this._state.getSerializableDocument();if((t==null?void 0:t.version)===2&&Array.isArray(t.layers)){const i=this._activeBackgroundRemovalLayer({requireSourceHash:!1}),r=this._sourceUrlForLayerSource(i==null?void 0:i.source);return!i||!r?null:{imageData:r,options:{...a,targetRef:i.id}}}const n=this.exportImage("png");return n?{imageData:n,options:a}:null}_sourceUrlForLayerSource(a){if(!a||typeof a!="object")return null;for(const t of["previewUrl","sourceUrl","url"]){const n=a[t];if(typeof n=="string"&&n.trim()!=="")return n}return null}async _applyPreviewBackgroundRemovalResult(a,t){var r,l;if(a.documentSignature===null||!a.activeLayerId)return await this.loadImage(t.dataUrl),{source:null};const n=await this._probeImageDimensions(t.dataUrl);if(!await this._isCurrentPreviewBackgroundRemovalContext(a,t))return null;const i={kind:"runtime",runtimeRef:`background-removal-${a.operationId||Date.now()}`,originalWidth:n.width,originalHeight:n.height,sourceHash:null,previewUrl:t.dataUrl};return this._state.replaceLayerSource(a.activeLayerId,i)?(await((l=(r=this._renderer).renderLayerDocument)==null?void 0:l.call(r,this._state.getSerializableDocument(),{fallbackImageUrl:this._state.get("imageUrl")??null})),{source:i}):null}async _isCurrentPreviewBackgroundRemovalContext(a,t=null){if(this._destroyed||this._loadVersion!==a.loadVersion||this._state.get("hasImage")!==!0||(this._state.get("imageUrl")??null)!==a.imageUrl)return!1;if(t){if(t.operationId&&t.operationId!==a.operationId||t.sessionKey&&t.sessionKey!==a.sessionKey||t.sourceHash&&t.sourceHash!==a.sourceHash)return!1;if(a.documentSignature!==null){if(!a.targetRef||a.targetRef!==a.activeLayerId||t.targetRef!==a.targetRef)return!1}else if(t.targetRef&&a.targetRef&&t.targetRef!==a.targetRef)return!1}if(a.documentSignature!==null){const i=this._state.getSerializableDocument();if(this._documentMaterializationSignature(i)!==a.documentSignature)return!1;const r=this._activeBackgroundRemovalLayer({requireSourceHash:!1});return!(!r||r.id!==a.activeLayerId)}const n=this.exportImage("png");return n?await this._removeBgManager.computeImageDataHash(n)===a.sourceHash:!1}_isCurrentBackgroundRemovalContext(a,t=null){var l;if(this._destroyed||this._loadVersion!==a.loadVersion)return!1;const n=this._state.getEditorDocumentBinding();if(!n||n.documentRevisionId!==a.documentRevisionId)return!1;const i=this._state.getSerializableDocument();if(this._documentMaterializationSignature(i)!==a.documentSignature||this._state.get("activeLayerId")!==a.activeLayerId)return!1;const r=this._state.getLayer(a.request.targetLayerId);return!(!r||((l=r==null?void 0:r.source)==null?void 0:l.sourceHash)!==a.sourceHash||r.locked===!0||r.visible===!1||t&&(t.operation_id&&t.operation_id!==a.request.operationId||t.target_layer_id&&t.target_layer_id!==a.request.targetLayerId||t.document_revision_id&&t.document_revision_id!==a.request.documentRevisionId||t.source_hash&&t.source_hash!==a.request.expectedSourceHash))}_showLoadingOverlay(a){var n;if(!this._loadingOverlay)this._loadingOverlay=te.el("div",{className:"editor-loading-overlay"},te.el("div",{className:"editor-loading-spinner"}),te.el("div",{className:"editor-loading-text"},a));else{const i=this._loadingOverlay.querySelector(".editor-loading-text");i&&(i.textContent=a)}const t=(n=this._canvasContainer)==null?void 0:n.parentElement;t&&!this._loadingOverlay.parentElement&&t.appendChild(this._loadingOverlay)}_hideLoadingOverlay(){var a;(a=this._loadingOverlay)==null||a.remove()}_buildMobileSaveBar(){var l,s;this._mobileSaveBar=te.el("div",{className:"editor-v2-mobile-save-bar",role:"region","aria-label":"Save bar"}),this._mobileSaveBtn=te.el("button",{type:"button",className:"mobile-save-btn",title:"Save Image","aria-label":"Save image",dataset:{testid:"btn-save-edit-mobile"},onClick:()=>this.save()});const a=te.el("span",{className:"mobile-save-icon"});a.innerHTML=te.save;const t=a.querySelector("svg");t&&t.setAttribute("aria-hidden","true"),this._mobileSaveBtn.appendChild(a),this._mobileSaveBtn.appendChild(te.el("span",{className:"mobile-save-label"},"Save")),this._mobileSaveBar.appendChild(this._mobileSaveBtn);const n=()=>{var m,p;if(!this._mobileSaveBtn)return;const d=((m=this._state)==null?void 0:m.get("hasImage"))===!0,c=((p=this._state)==null?void 0:p.get("isProcessing"))===!0,u=!d||c;this._mobileSaveBtn.disabled=u,this._mobileSaveBtn.setAttribute("aria-disabled",u?"true":"false")};n();const i=(l=this._state)==null?void 0:l.on("change:hasImage",n),r=(s=this._state)==null?void 0:s.on("change:isProcessing",n);this._mobileSaveUnsub=()=>{try{i==null||i()}catch{}try{r==null||r()}catch{}}}destroy(){var a,t,n,i,r,l,s,d;this._destroyed=!0,(t=(a=this._removeBgManager)==null?void 0:a.cancelActiveRequests)==null||t.call(a,"editor-destroy");for(const c of this._objectUrls)try{URL.revokeObjectURL(c)}catch{}this._objectUrls.clear(),this._activeObjectUrl=null,(n=this._resizeObserver)==null||n.disconnect(),this._renderer.destroy(),this._cropManager.disable(),this._handleWindowResize&&window.removeEventListener("resize",this._handleWindowResize),(i=this._toolbar)==null||i.destroy(),(r=this._cropControls)==null||r.destroy(),(l=this._layout)==null||l.destroy(),(s=this._mobileSaveUnsub)==null||s.call(this),this._mobileSaveUnsub=null,this._mobileSaveBtn=null,this._mobileSaveBar=null,(d=this._editorEl)==null||d.remove(),this._container=null,this._state=null,this.emit("destroyed"),this.removeAllListeners()}}function Dh(o,a){try{let t=te.getFilter(o);if(t||(te.registerCorePixiFilters(),t=te.getFilter(o)),!t){try{const r=te.getAllFilters()}catch{}return null}const n={...t.defaultParams,...a};return t.createFilter(n)}catch{return null}}const Ah=78e5,Rh=e.defineComponent({__name:"ImageEditor",props:{initialImage:{},initialState:{default:null},initialDocument:{default:null},initialDocumentId:{default:null},initialDocumentRevisionId:{default:null},initialDocumentRevisionNumber:{default:null},sessionKey:{default:0},theme:{default:"auto"},cropShape:{default:"square"},preset:{},editorVersion:{default:"v2"},backgroundRemoval:{default:null},backgroundReplacement:{default:null},primaryColor:{default:"#3880ff"},secondaryColor:{default:"#5260ff"},saveButtonColor:{default:"#3880ff"},downloadButtonColor:{default:"#2dd36f"}},emits:["save","cancel","error"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(null);let r=null,l=null;function s(v){return typeof v=="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(v)}function d(){const v={state:t.initialState??null,sessionKey:t.sessionKey};return t.initialDocument&&(v.document=t.initialDocument,v.documentId=t.initialDocumentId,v.documentRevisionId=t.initialDocumentRevisionId,v.documentRevisionNumber=t.initialDocumentRevisionNumber),v}async function c(){var v,k,y;try{if(!r){n("error",new Error("Editor not initialized"));return}const w=await((v=r.exportBlob)==null?void 0:v.call(r,"png",.92,{maxPixels:Ah}));if(!w){n("error",new Error("Failed to export image — the image could not be processed"));return}const g=r.getSerializableState(),b={blob:w.blob,mimeType:w.blob.type||"image/png",dimensions:{width:w.width,height:w.height},state:g},R=((k=r.getSerializableDocument)==null?void 0:k.call(r))??null;if(R){const V=((y=r.getEditorDocumentBinding)==null?void 0:y.call(r))??null;b.document=R,b.documentId=(V==null?void 0:V.documentId)??(s(R.id)?R.id:null),b.documentRevisionId=(V==null?void 0:V.documentRevisionId)??null,b.documentRevisionNumber=(V==null?void 0:V.documentRevisionNumber)??R.revision??null}n("save",b)}catch(w){n("error",w instanceof Error?w:new Error("Failed to export image"))}}function u(){n("cancel")}function m(v){if(v instanceof Error)return v;if(v!==null&&typeof v=="object"&&"error"in v){const k=v.error;if(k instanceof Error)return k;if(typeof k=="string"&&k.trim()!=="")return new Error(k)}return typeof v=="string"&&v.trim()!==""?new Error(v):new Error("Failed to load image")}function p(v){n("error",m(v))}function f(){if(!i.value||r)return;window.PIXI=Jt,te.initializeFilterRegistry();const v={theme:t.theme};t.backgroundRemoval&&(v.backgroundRemoval=t.backgroundRemoval),t.backgroundReplacement&&(v.backgroundReplacement=t.backgroundReplacement),t.preset&&(v.preset=t.preset),t.preset?t.cropShape==="circle"&&(v.cropShape="circle",v.initialAspectRatio="1:1",v.initialMode="crop"):(v.cropShape=t.cropShape==="circle"?"circle":"free",v.initialAspectRatio=t.cropShape==="circle"?"1:1":"free",v.initialMode=t.cropShape==="circle"?"crop":"adjust");const k=t.editorVersion==="v2"?Fh:te.VanillaImageEditor,y=new k(i.value,v);r=y,y.setFilterRegistry({getAllFilters:te.getAllFilters,getFilter:te.getFilter,getFiltersByCategory:te.getFiltersByCategory}),y.save=function(){c()},y.on("cancel",u),y.on("error",p),t.initialImage&&y.loadImage(t.initialImage,d())}e.onMounted(()=>{i.value&&(i.value.clientWidth>0?f():(l=new ResizeObserver(v=>{const k=v[0];k&&k.contentRect.width>0&&!r&&(f(),l==null||l.disconnect(),l=null)}),l.observe(i.value)))});const h=()=>{!r||!t.initialImage||r.loadImage(t.initialImage,d())};return e.watch(()=>t.initialImage,(v,k)=>{!r||!v||v===k||h()}),e.watch(()=>t.sessionKey,(v,k)=>{v!==k&&h()}),e.watch(()=>t.initialState,(v,k)=>{v!==k&&h()}),e.watch(()=>[t.initialDocument,t.initialDocumentId,t.initialDocumentRevisionId,t.initialDocumentRevisionNumber],(v,k)=>{v!==k&&h()}),e.onUnmounted(()=>{l==null||l.disconnect(),l=null,r&&(r.destroy(),r=null)}),(v,k)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:i,class:"vanilla-editor-wrapper","data-testid":"vanilla-image-editor"},null,512))}}),$e=(o,a)=>{const t=o.__vccOpts||o;for(const[n,i]of a)t[n]=i;return t},nm=$e(Rh,[["__scopeId","data-v-8ab74f83"]]),Lh={class:"editor-modal-panel"},Ph={class:"editor-fill"},Uh=e.defineComponent({__name:"ImageEditorModal",props:{modelValue:{type:Boolean,default:!1},initialImage:{},initialState:{default:null},initialDocument:{default:null},initialDocumentId:{default:null},initialDocumentRevisionId:{default:null},initialDocumentRevisionNumber:{default:null},sessionKey:{default:0},acceptedFormats:{default:"image/jpeg,image/png,image/webp,image/gif"},maxFileSize:{default:10},theme:{default:"auto"},cropShape:{default:"square"},preset:{},editorVersion:{default:"v2"},backgroundRemoval:{default:null},backgroundReplacement:{default:null},primaryColor:{default:"#3880ff"},secondaryColor:{default:"#5260ff"},saveButtonColor:{default:"#3880ff"},downloadButtonColor:{default:"#2dd36f"},saveHandler:{}},emits:["update:modelValue","save","cancel","error"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(null),r=e.ref(t.modelValue),l=e.ref(!1),s=e.ref(null),d=v=>{n("error",v)},c=()=>{e.nextTick(()=>{if(i.value){const v=i.value.querySelector("button:not([disabled]), [href], input:not([disabled])");v&&v.focus()}})};e.watch(()=>t.modelValue,v=>{r.value=v,v&&(s.value=document.activeElement,c())},{immediate:!0});const u=async v=>{try{if(l.value=!0,t.saveHandler){await t.saveHandler(v);return}n("save",v)}catch(k){d(k instanceof Error?k:new Error("Failed to save image"))}finally{l.value=!1}},m=()=>{n("cancel"),f()},p=()=>{l.value||f()},f=()=>{r.value=!1,n("update:modelValue",!1),s.value&&s.value instanceof HTMLElement&&(s.value.focus(),s.value=null)},h=v=>{if(v.key==="Escape"&&r.value&&!l.value){f();return}if(v.key==="Tab"&&r.value&&i.value){const k=i.value.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(k.length===0)return;const y=k[0],w=k[k.length-1];v.shiftKey&&document.activeElement===y?(v.preventDefault(),w.focus()):!v.shiftKey&&document.activeElement===w&&(v.preventDefault(),y.focus())}};return e.onMounted(()=>{document.addEventListener("keydown",h)}),e.onBeforeUnmount(()=>{document.removeEventListener("keydown",h)}),(v,k)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[r.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"overlayRef",ref:i,role:"dialog","aria-modal":"true","aria-label":"Image editor",class:"editor-modal-overlay","data-testid":"image-editor-modal",onKeydown:e.withKeys(p,["escape"])},[e.createElementVNode("div",{class:"editor-modal-backdrop",onClick:p}),e.createElementVNode("div",Lh,[e.createElementVNode("div",Ph,[e.createVNode(nm,{"initial-image":v.initialImage,"initial-state":v.initialState,"initial-document":v.initialDocument,"initial-document-id":v.initialDocumentId,"initial-document-revision-id":v.initialDocumentRevisionId,"initial-document-revision-number":v.initialDocumentRevisionNumber,"session-key":v.sessionKey,theme:v.theme,"crop-shape":v.cropShape,preset:v.preset,"editor-version":v.editorVersion,"background-removal":v.backgroundRemoval,"background-replacement":v.backgroundReplacement,"primary-color":v.primaryColor,"secondary-color":v.secondaryColor,"save-button-color":v.saveButtonColor,"download-button-color":v.downloadButtonColor,onSave:u,onCancel:m,onError:d},null,8,["initial-image","initial-state","initial-document","initial-document-id","initial-document-revision-id","initial-document-revision-number","session-key","theme","crop-shape","preset","editor-version","background-removal","background-replacement","primary-color","secondary-color","save-button-color","download-button-color"])])])],544)):e.createCommentVNode("",!0)]))}}),om=$e(Uh,[["__scopeId","data-v-bd4e671f"]]),Oh={class:"media-workspace"},zh={class:"media-workspace-toolbar"},jh={class:"media-workspace-label"},Wh=["value"],Hh={class:"media-workspace-grid"},Zh=["onClick"],Gh=e.defineComponent({__name:"MediaWorkspace",props:{apiScope:{},subScopes:{},initialScopeId:{}},emits:["scope-change","update:media","upload","preview"],setup(o,{emit:a}){var m;const t=o,n=a,i=xa(),r=e.ref(t.initialScopeId??((m=t.subScopes[0])==null?void 0:m.id)??""),l=e.computed(()=>t.subScopes),s=e.computed(()=>l.value.find(p=>p.id===r.value));let d=null;function c(){d&&(d(),d=null),t.apiScope&&(d=Ku({apiScope:t.apiScope,isAdmin:t.apiScope==="admin"}))}async function u(){var f;const p={};(f=s.value)!=null&&f.collection&&(p.collection=s.value.collection),await i.fetchMedia(1,p),n("update:media",[...i.items])}return e.watch(()=>t.initialScopeId,p=>{p&&p!==r.value&&(r.value=p)}),e.watch(()=>t.subScopes,p=>{if(p.length===0){r.value="";return}p.some(f=>f.id===r.value)||(r.value=p[0].id)},{deep:!0}),e.watch(()=>t.apiScope,()=>{c(),u()}),e.watch(r,p=>{p&&(n("scope-change",p),u())}),e.onMounted(()=>{c(),u()}),e.onUnmounted(()=>{d&&(d(),d=null)}),(p,f)=>(e.openBlock(),e.createElementBlock("div",Oh,[e.createElementVNode("div",zh,[e.createElementVNode("label",jh,[f[2]||(f[2]=e.createElementVNode("span",{class:"media-workspace-label-text"},"Scope",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":f[0]||(f[0]=h=>r.value=h),"data-testid":"scope-select",class:"media-workspace-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,h=>(e.openBlock(),e.createElementBlock("option",{key:h.id,value:h.id},e.toDisplayString(h.label),9,Wh))),128))],512),[[e.vModelSelect,r.value]])]),e.createElementVNode("button",{type:"button",class:"media-workspace-upload","data-testid":"upload-button",onClick:f[1]||(f[1]=h=>n("upload"))}," Upload ")]),e.createElementVNode("div",Hh,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i).items,h=>(e.openBlock(),e.createElementBlock("button",{key:h.uuid,type:"button",class:"media-workspace-item","data-testid":"media-item",onClick:v=>n("preview",h)},e.toDisplayString(h.file_name),9,Zh))),128))])]))}}),Xh=$e(Gh,[["__scopeId","data-v-895f26fe"]]),Kh={class:"managed-media-gallery"},Jh={class:"gallery-grid"},qh=e.defineComponent({__name:"ManagedMediaGallery",props:{media:{},selectable:{type:Boolean},multiple:{type:Boolean}},emits:["select","remove"],setup(o){return(a,t)=>(e.openBlock(),e.createElementBlock("div",Kh,[e.createElementVNode("div",Jh,[e.renderSlot(a.$slots,"default",{},void 0,!0)])]))}}),Yh=$e(qh,[["__scopeId","data-v-10a9b8c5"]]),kr="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M256 176v160M336 256H176' class='ionicon-fill-none ionicon-stroke-width'/></svg>",ed="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M256 112v288M400 256H112' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Qh="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm0 319.91a20 20 0 1120-20 20 20 0 01-20 20zm21.72-201.15l-5.74 122a16 16 0 01-32 0l-5.74-121.94v-.05a21.74 21.74 0 1143.44 0z'/></svg>",td="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path d='M250.26 166.05L256 288l5.73-121.95a5.74 5.74 0 00-5.79-6h0a5.74 5.74 0 00-5.68 6z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M256 367.91a20 20 0 1120-20 20 20 0 01-20 20z'/></svg>",ev="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M244 400L100 256l144-144M120 256h292' class='ionicon-fill-none'/></svg>",tv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M268 112l144 144-144 144M392 256H100' class='ionicon-fill-none'/></svg>",lc="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256L272 88v96C103.57 184 64 304.77 64 424c48.61-62.24 91.6-96 208-96v96z' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",sc="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M240 424v-96c116.4 0 159.39 33.76 208 96 0-119.23-39.57-240-208-240V88L64 256z' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",ui="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M452.37 59.63h0a40.49 40.49 0 00-57.26 0L184 294.74c23.08 4.7 46.12 27.29 49.26 49.26l219.11-227.11a40.49 40.49 0 000-57.26zM138 336c-29.88 0-54 24.5-54 54.86 0 23.95-20.88 36.57-36 36.57C64.56 449.74 92.82 464 120 464c39.78 0 72-32.73 72-73.14 0-30.36-24.12-54.86-54-54.86z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",av="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M350.54 148.68l-26.62-42.06C318.31 100.08 310.62 96 302 96h-92c-8.62 0-16.31 4.08-21.92 10.62l-26.62 42.06C155.85 155.23 148.62 160 140 160H80a32 32 0 00-32 32v192a32 32 0 0032 32h352a32 32 0 0032-32V192a32 32 0 00-32-32h-59c-8.65 0-16.85-4.77-22.46-11.32z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='256' cy='272' r='80' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M124 158v-22h-24v22' class='ionicon-fill-none ionicon-stroke-width'/></svg>",im="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm108.25 138.29l-134.4 160a16 16 0 01-12 5.71h-.27a16 16 0 01-11.89-5.3l-57.6-64a16 16 0 1123.78-21.4l45.29 50.32 122.59-145.91a16 16 0 0124.5 20.58z'/></svg>",rm="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M416 128L192 384l-96-96' class='ionicon-fill-none ionicon-stroke-width'/></svg>",dc="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M328 112L184 256l144 144' class='ionicon-fill-none'/></svg>",nv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M112 184l144 144 144-144' class='ionicon-fill-none'/></svg>",ov="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M184 112l144 144-144 144' class='ionicon-fill-none'/></svg>",cc="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M184 112l144 144-144 144' class='ionicon-fill-none'/></svg>",Yn="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M368 368L144 144M368 144L144 368' class='ionicon-fill-none ionicon-stroke-width'/></svg>",uc="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M320 367.79h76c55 0 100-29.21 100-83.6s-53-81.47-96-83.6c-8.89-85.06-71-136.8-144-136.8-69 0-113.44 45.79-128 91.2-60 5.7-112 43.88-112 106.4s54 106.4 120 106.4h56' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M320 255.79l-64-64-64 64M256 448.21V207.79' class='ionicon-fill-none ionicon-stroke-width'/></svg>",iv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='256' cy='184' r='120' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='344' cy='328' r='120' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='168' cy='328' r='120' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Cn="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M430.11 347.9c-6.6-6.1-16.3-7.6-24.6-9-11.5-1.9-15.9-4-22.6-10-14.3-12.7-14.3-31.1 0-43.8l30.3-26.9c46.4-41 46.4-108.2 0-149.2-34.2-30.1-80.1-45-127.8-45-55.7 0-113.9 20.3-158.8 60.1-83.5 73.8-83.5 194.7 0 268.5 41.5 36.7 97.5 55 152.9 55.4h1.7c55.4 0 110-17.9 148.8-52.4 14.4-12.7 11.99-36.6.1-47.7z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='144' cy='208' r='32'/><circle cx='152' cy='311' r='32'/><circle cx='224' cy='144' r='32'/><circle cx='256' cy='367' r='48'/><circle cx='328' cy='144' r='32'/></svg>",rv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M304 416V304h112M314.2 314.23L432 432M208 96v112H96M197.8 197.77L80 80M416 208H304V96M314.23 197.8L432 80M96 304h112v112M197.77 314.2L80 432' class='ionicon-fill-none ionicon-stroke-width'/></svg>",ai="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='256' cy='256' r='208' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M256 464c-114.88 0-208-93.12-208-208S141.12 48 256 48z'/></svg>",ms="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><rect x='128' y='128' width='336' height='336' rx='57' ry='57' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M383.5 128l.5-24a56.16 56.16 0 00-56-56H112a64.19 64.19 0 00-64 64v216a56.16 56.16 0 0056 56h24' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",lv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M384 224v184a40 40 0 01-40 40H104a40 40 0 01-40-40V168a40 40 0 0140-40h167.48' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M459.94 53.25a16.06 16.06 0 00-23.22-.56L424.35 65a8 8 0 000 11.31l11.34 11.32a8 8 0 0011.34 0l12.06-12c6.1-6.09 6.67-16.01.85-22.38zM399.34 90L218.82 270.2a9 9 0 00-2.31 3.93L208.16 299a3.91 3.91 0 004.86 4.86l24.85-8.35a9 9 0 003.93-2.31L422 112.66a9 9 0 000-12.66l-9.95-10a9 9 0 00-12.71 0z'/></svg>",mc="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M144 48v272a48 48 0 0048 48h272' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M368 304V192a48 48 0 00-48-48H208M368 368v96M144 144H48' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Fr="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='104' cy='152' r='56' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='104' cy='360' r='56' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M157 175l-11 15 37 15s3.46-6.42 7-10z' stroke-linecap='square' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path d='M154.17 334.43L460 162c-2.5-6.7-28-12-64-4-29.12 6.47-121.16 29.05-159.16 56.05C205.85 236.06 227 272 192 298c-25.61 19-44.43 22.82-44.43 22.82zM344.47 278.24L295 306.67c14.23 6.74 65.54 33.27 117 36.33 14.92.89 30 .39 39-6z' stroke-linecap='round' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='256' cy='240' r='32' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Fo="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M336 176h40a40 40 0 0140 40v208a40 40 0 01-40 40H136a40 40 0 01-40-40V216a40 40 0 0140-40h40' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M176 272l80 80 80-80M256 48v288' class='ionicon-fill-none ionicon-stroke-width'/></svg>",sv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='256' cy='256' r='32' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='416' cy='256' r='32' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='96' cy='256' r='32' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",dv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M432 320v112H320M421.8 421.77L304 304M80 192V80h112M90.2 90.23L208 208M320 80h112v112M421.77 90.2L304 208M192 432H80V320M90.23 421.8L208 304' class='ionicon-fill-none ionicon-stroke-width'/></svg>",cv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M432 320v112H320M421.8 421.77L304 304M80 192V80h112M90.2 90.23L208 208M320 80h112v112M421.77 90.2L304 208M192 432H80V320M90.23 421.8L208 304' class='ionicon-fill-none ionicon-stroke-width'/></svg>",uv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M432 448a15.92 15.92 0 01-11.31-4.69l-352-352a16 16 0 0122.62-22.62l352 352A16 16 0 01432 448zM255.66 384c-41.49 0-81.5-12.28-118.92-36.5-34.07-22-64.74-53.51-88.7-91v-.08c19.94-28.57 41.78-52.73 65.24-72.21a2 2 0 00.14-2.94L93.5 161.38a2 2 0 00-2.71-.12c-24.92 21-48.05 46.76-69.08 76.92a31.92 31.92 0 00-.64 35.54c26.41 41.33 60.4 76.14 98.28 100.65C162 402 207.9 416 255.66 416a239.13 239.13 0 0075.8-12.58 2 2 0 00.77-3.31l-21.58-21.58a4 4 0 00-3.83-1 204.8 204.8 0 01-51.16 6.47zM490.84 238.6c-26.46-40.92-60.79-75.68-99.27-100.53C349 110.55 302 96 255.66 96a227.34 227.34 0 00-74.89 12.83 2 2 0 00-.75 3.31l21.55 21.55a4 4 0 003.88 1 192.82 192.82 0 0150.21-6.69c40.69 0 80.58 12.43 118.55 37 34.71 22.4 65.74 53.88 89.76 91a.13.13 0 010 .16 310.72 310.72 0 01-64.12 72.73 2 2 0 00-.15 2.95l19.9 19.89a2 2 0 002.7.13 343.49 343.49 0 0068.64-78.48 32.2 32.2 0 00-.1-34.78z'/><path d='M256 160a95.88 95.88 0 00-21.37 2.4 2 2 0 00-1 3.38l112.59 112.56a2 2 0 003.38-1A96 96 0 00256 160zM165.78 233.66a2 2 0 00-3.38 1 96 96 0 00115 115 2 2 0 001-3.38z'/></svg>",mi="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M255.66 112c-77.94 0-157.89 45.11-220.83 135.33a16 16 0 00-.27 17.77C82.92 340.8 161.8 400 255.66 400c92.84 0 173.34-59.38 221.79-135.25a16.14 16.14 0 000-17.47C428.89 172.28 347.8 112 255.66 112z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='256' cy='256' r='80' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",pc="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M80 464V68.14a8 8 0 014-6.9C91.81 56.66 112.92 48 160 48c64 0 145 48 192 48a199.53 199.53 0 0077.23-15.77 2 2 0 012.77 1.85v219.36a4 4 0 01-2.39 3.65C421.37 308.7 392.33 320 352 320c-48 0-128-32-192-32s-80 16-80 16' stroke-linecap='round' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",zl="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M315.27 33L96 304h128l-31.51 173.23a2.36 2.36 0 002.33 2.77h0a2.36 2.36 0 001.89-.95L416 208H288l31.66-173.25a2.45 2.45 0 00-2.44-2.75h0a2.42 2.42 0 00-1.95 1z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",mv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M496 152a56 56 0 00-56-56H220.11a23.89 23.89 0 01-13.31-4L179 73.41A55.77 55.77 0 00147.89 64H72a56 56 0 00-56 56v48a8 8 0 008 8h464a8 8 0 008-8zM16 392a56 56 0 0056 56h368a56 56 0 0056-56V216a8 8 0 00-8-8H24a8 8 0 00-8 8z'/></svg>",pv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='129' cy='96' r='48' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='129' cy='416' r='48' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M129 144v224' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='385' cy='288' r='48' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M129 144c0 96 112 144 208 144' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",jl="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M432 112V96a48.14 48.14 0 00-48-48H64a48.14 48.14 0 00-48 48v256a48.14 48.14 0 0048 48h16' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><rect x='96' y='128' width='400' height='336' rx='45.99' ry='45.99' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><ellipse cx='372.92' cy='219.64' rx='30.77' ry='30.55' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path d='M342.15 372.17L255 285.78a30.93 30.93 0 00-42.18-1.21L96 387.64M265.23 464l118.59-117.73a31 31 0 0141.46-1.87L496 402.91' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",fv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M248 64C146.39 64 64 146.39 64 248s82.39 184 184 184 184-82.39 184-184S349.61 64 248 64z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M220 220h32v116' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-miterlimit='10' d='M208 340h88' class='ionicon-fill-none ionicon-stroke-width'/><path d='M248 130a26 26 0 1026 26 26 26 0 00-26-26z'/></svg>",hv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M368 128h80M64 128h240M368 384h80M64 384h240M208 256h240M64 256h80' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='336' cy='128' r='32' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='176' cy='256' r='32' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='336' cy='384' r='32' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",vv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M208 432h-48a16 16 0 01-16-16V96a16 16 0 0116-16h48a16 16 0 0116 16v320a16 16 0 01-16 16zM352 432h-48a16 16 0 01-16-16V96a16 16 0 0116-16h48a16 16 0 0116 16v320a16 16 0 01-16 16z'/></svg>",gv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm-32 272a16 16 0 01-32 0V192a16 16 0 0132 0zm96 0a16 16 0 01-32 0V192a16 16 0 0132 0z'/></svg>",lm="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-miterlimit='10' d='M208 192v128M304 192v128' class='ionicon-fill-none ionicon-stroke-width'/></svg>",ad="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M176 96h16v320h-16zM320 96h16v320h-16z' class='ionicon-fill-none ionicon-stroke-width'/></svg>",bv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M133 440a35.37 35.37 0 01-17.5-4.67c-12-6.8-19.46-20-19.46-34.33V111c0-14.37 7.46-27.53 19.46-34.33a35.13 35.13 0 0135.77.45l247.85 148.36a36 36 0 010 61l-247.89 148.4A35.5 35.5 0 01133 440z'/></svg>",yv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M30.71 229.47l188.87-113a30.54 30.54 0 0131.09-.39 33.74 33.74 0 0116.76 29.47v79.05l180.72-108.16a30.54 30.54 0 0131.09-.39A33.74 33.74 0 01496 145.52v221A33.73 33.73 0 01479.24 396a30.54 30.54 0 01-31.09-.39L267.43 287.4v79.08A33.73 33.73 0 01250.67 396a30.54 30.54 0 01-31.09-.39l-188.87-113a31.27 31.27 0 010-53z'/></svg>",wv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M480 145.52v221c0 13.28-13 21.72-23.63 15.35L267.5 268.8c-9.24-5.53-9.24-20.07 0-25.6l188.87-113C467 123.8 480 132.24 480 145.52zM251.43 145.52v221c0 13.28-13 21.72-23.63 15.35L38.93 268.8c-9.24-5.53-9.24-20.07 0-25.6l188.87-113c10.64-6.4 23.63 2.04 23.63 15.32z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",kv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm74.77 217.3l-114.45 69.14a10.78 10.78 0 01-16.32-9.31V186.87a10.78 10.78 0 0116.32-9.31l114.45 69.14a10.89 10.89 0 010 18.6z'/></svg>",sm="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path d='M216.32 334.44l114.45-69.14a10.89 10.89 0 000-18.6l-114.45-69.14a10.78 10.78 0 00-16.32 9.31v138.26a10.78 10.78 0 0016.32 9.31z'/></svg>",_v="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M481.29 229.47l-188.87-113a30.54 30.54 0 00-31.09-.39 33.74 33.74 0 00-16.76 29.47v79.05L63.85 116.44a30.54 30.54 0 00-31.09-.39A33.74 33.74 0 0016 145.52v221A33.74 33.74 0 0032.76 396a30.54 30.54 0 0031.09-.39L244.57 287.4v79.08A33.74 33.74 0 00261.33 396a30.54 30.54 0 0031.09-.39l188.87-113a31.27 31.27 0 000-53z'/></svg>",Ev="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M32 145.52v221c0 13.28 13 21.72 23.63 15.35l188.87-113c9.24-5.53 9.24-20.07 0-25.6l-188.87-113C45 123.8 32 132.24 32 145.52zM260.57 145.52v221c0 13.28 13 21.72 23.63 15.35l188.87-113c9.24-5.53 9.24-20.07 0-25.6l-188.87-113c-10.64-6.47-23.63 1.97-23.63 15.25z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",nd="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M112 111v290c0 17.44 17 28.52 31 20.16l247.9-148.37c12.12-7.25 12.12-26.33 0-33.58L143 90.84c-14-8.36-31 2.72-31 20.16z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Sv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M400 111v290c0 17.44-17 28.52-31 20.16L121.09 272.79c-12.12-7.25-12.12-26.33 0-33.58L369 90.84c14-8.36 31 2.72 31 20.16z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-miterlimit='10' d='M112 80v352' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Cv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M112 111v290c0 17.44 17 28.52 31 20.16l247.9-148.37c12.12-7.25 12.12-26.33 0-33.58L143 90.84c-14-8.36-31 2.72-31 20.16z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-miterlimit='10' d='M400 80v352' class='ionicon-fill-none ionicon-stroke-width'/></svg>",io="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M320 146s24.36-12-64-12a160 160 0 10160 160' stroke-linecap='round' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M256 58l80 80-80 80' class='ionicon-fill-none ionicon-stroke-width'/></svg>",xv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M336 256H176' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Nv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M400 256H112' class='ionicon-fill-none ionicon-stroke-width'/></svg>",fc="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M304 96h112v112M405.77 106.2L111.98 400.02M208 416H96V304' class='ionicon-fill-none ionicon-stroke-width'/></svg>",el="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M380.93 57.37A32 32 0 00358.3 48H94.22A46.21 46.21 0 0048 94.22v323.56A46.21 46.21 0 0094.22 464h323.56A46.36 46.36 0 00464 417.78V153.7a32 32 0 00-9.37-22.63zM256 416a64 64 0 1164-64 63.92 63.92 0 01-64 64zm48-224H112a16 16 0 01-16-16v-64a16 16 0 0116-16h192a16 16 0 0116 16v64a16 16 0 01-16 16z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Vv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='256' cy='256' r='48'/><path d='M470.39 300l-.47-.38-31.56-24.75a16.11 16.11 0 01-6.1-13.33v-11.56a16 16 0 016.11-13.22L469.92 212l.47-.38a26.68 26.68 0 005.9-34.06l-42.71-73.9a1.59 1.59 0 01-.13-.22A26.86 26.86 0 00401 92.14l-.35.13-37.1 14.93a15.94 15.94 0 01-14.47-1.29q-4.92-3.1-10-5.86a15.94 15.94 0 01-8.19-11.82l-5.59-39.59-.12-.72A27.22 27.22 0 00298.76 26h-85.52a26.92 26.92 0 00-26.45 22.39l-.09.56-5.57 39.67a16 16 0 01-8.13 11.82 175.21 175.21 0 00-10 5.82 15.92 15.92 0 01-14.43 1.27l-37.13-15-.35-.14a26.87 26.87 0 00-32.48 11.34l-.13.22-42.77 73.95a26.71 26.71 0 005.9 34.1l.47.38 31.56 24.75a16.11 16.11 0 016.1 13.33v11.56a16 16 0 01-6.11 13.22L42.08 300l-.47.38a26.68 26.68 0 00-5.9 34.06l42.71 73.9a1.59 1.59 0 01.13.22 26.86 26.86 0 0032.45 11.3l.35-.13 37.07-14.93a15.94 15.94 0 0114.47 1.29q4.92 3.11 10 5.86a15.94 15.94 0 018.19 11.82l5.56 39.59.12.72A27.22 27.22 0 00213.24 486h85.52a26.92 26.92 0 0026.45-22.39l.09-.56 5.57-39.67a16 16 0 018.18-11.82c3.42-1.84 6.76-3.79 10-5.82a15.92 15.92 0 0114.43-1.27l37.13 14.95.35.14a26.85 26.85 0 0032.48-11.34 2.53 2.53 0 01.13-.22l42.71-73.89a26.7 26.7 0 00-5.89-34.11zm-134.48-40.24a80 80 0 11-83.66-83.67 80.21 80.21 0 0183.66 83.67z'/></svg>",Wl="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M400 304l48 48-48 48M400 112l48 48-48 48M64 352h85.19a80 80 0 0066.56-35.62L256 256' class='ionicon-fill-none ionicon-stroke-width'/><path d='M64 160h85.19a80 80 0 0166.56 35.62l80.5 120.76A80 80 0 00362.81 352H416M416 160h-53.19a80 80 0 00-66.56 35.62L288 208' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Sn="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' class='ionicon'><path d='M259.92 262.91L216.4 149.77a9 9 0 00-16.8 0l-43.52 113.14a9 9 0 01-5.17 5.17L37.77 311.6a9 9 0 000 16.8l113.14 43.52a9 9 0 015.17 5.17l43.52 113.14a9 9 0 0016.8 0l43.52-113.14a9 9 0 015.17-5.17l113.14-43.52a9 9 0 000-16.8l-113.14-43.52a9 9 0 01-5.17-5.17zM108 68L88 16 68 68 16 88l52 20 20 52 20-52 52-20-52-20zM426.67 117.33L400 48l-26.67 69.33L304 144l69.33 26.67L400 240l26.67-69.33L496 144l-69.33-26.67z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",ni="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-miterlimit='10' d='M256 48v48M256 416v48M403.08 108.92l-33.94 33.94M142.86 369.14l-33.94 33.94M464 256h-48M96 256H48M403.08 403.08l-33.94-33.94M142.86 142.86l-33.94-33.94' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='256' cy='256' r='80' stroke-linecap='round' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",hc="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M304 48l112 112-112 112M398.87 160H96M208 464L96 352l112-112M114 352h302' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Tv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M512 128v256a64.07 64.07 0 01-64 64H64a64.07 64.07 0 01-64-64V128a64.07 64.07 0 0164-64h384a64.07 64.07 0 0164 64zM32 384a32 32 0 0032 32h384a32 32 0 0032-32V128a32 32 0 00-32-32H64a32 32 0 00-32 32z'/><path d='M0 128a64.07 64.07 0 0164-64h384a64.07 64.07 0 0164 64v256a64.07 64.07 0 01-64 64H64a64.07 64.07 0 01-64-64V128m480 256V128a32 32 0 00-32-32H64a32 32 0 00-32 32v256a32 32 0 0032 32h384a32 32 0 0032-32m-16 0a16 16 0 01-16 16H64a16 16 0 01-16-16V128a16 16 0 0116-16h384a16 16 0 0116 16v256z'/></svg>",dm="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M32 415.5l120-320 120 320M230 303.5H74M326 239.5c12.19-28.69 41-48 74-48h0c46 0 80 32 80 80v144' class='ionicon-fill-none ionicon-stroke-width'/><path d='M320 358.5c0 36 26.86 58 60 58 54 0 100-27 100-106v-15c-20 0-58 1-92 5-32.77 3.86-68 19-68 58z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Dr="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M112 112l20 320c.95 18.49 14.4 32 32 32h184c17.67 0 30.87-13.51 32-32l20-320' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-miterlimit='10' d='M80 112h352' class='ionicon-stroke-width'/><path d='M192 112V72h0a23.93 23.93 0 0124-24h80a23.93 23.93 0 0124 24h0v40M256 176v224M184 176l8 224M328 176l-8 224' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",cm="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M374.79 308.78L457.5 367a16 16 0 0022.5-14.62V159.62A16 16 0 00457.5 145l-82.71 58.22A16 16 0 00368 216.3v79.4a16 16 0 006.79 13.08z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M268 384H84a52.15 52.15 0 01-52-52V180a52.15 52.15 0 0152-52h184.48A51.68 51.68 0 01320 179.52V332a52.15 52.15 0 01-52 52z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Bv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M232 416a23.88 23.88 0 01-14.2-4.68 8.27 8.27 0 01-.66-.51L125.76 336H56a24 24 0 01-24-24V200a24 24 0 0124-24h69.75l91.37-74.81a8.27 8.27 0 01.66-.51A24 24 0 01256 120v272a24 24 0 01-24 24zm-106.18-80zm-.27-159.86zM320 336a16 16 0 01-14.29-23.19c9.49-18.87 14.3-38 14.3-56.81 0-19.38-4.66-37.94-14.25-56.73a16 16 0 0128.5-14.54C346.19 208.12 352 231.44 352 256c0 23.86-6 47.81-17.7 71.19A16 16 0 01320 336z'/><path d='M368 384a16 16 0 01-13.86-24C373.05 327.09 384 299.51 384 256c0-44.17-10.93-71.56-29.82-103.94a16 16 0 0127.64-16.12C402.92 172.11 416 204.81 416 256c0 50.43-13.06 83.29-34.13 120a16 16 0 01-13.87 8z'/><path d='M416 432a16 16 0 01-13.39-24.74C429.85 365.47 448 323.76 448 256c0-66.5-18.18-108.62-45.49-151.39a16 16 0 1127-17.22C459.81 134.89 480 181.74 480 256c0 64.75-14.66 113.63-50.6 168.74A16 16 0 01416 432z'/></svg>",Iv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M296 416.19a23.92 23.92 0 01-14.21-4.69l-.66-.51-91.46-75H120a24 24 0 01-24-24V200a24 24 0 0124-24h69.65l91.46-75 .66-.51A24 24 0 01320 119.83v272.34a24 24 0 01-24 24zM384 336a16 16 0 01-14.29-23.18c9.49-18.9 14.3-38 14.3-56.82 0-19.36-4.66-37.92-14.25-56.73a16 16 0 0128.5-14.54C410.2 208.16 416 231.47 416 256c0 23.83-6 47.78-17.7 71.18A16 16 0 01384 336z'/></svg>",Mv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M264 416.19a23.92 23.92 0 01-14.21-4.69l-.66-.51-91.46-75H88a24 24 0 01-24-24V200a24 24 0 0124-24h69.65l91.46-75 .66-.51A24 24 0 01288 119.83v272.34a24 24 0 01-24 24zM352 336a16 16 0 01-14.29-23.18c9.49-18.9 14.3-38 14.3-56.82 0-19.36-4.66-37.92-14.25-56.73a16 16 0 0128.5-14.54C378.2 208.16 384 231.47 384 256c0 23.83-6 47.78-17.7 71.18A16 16 0 01352 336z'/><path d='M400 384a16 16 0 01-13.87-24C405 327.05 416 299.45 416 256c0-44.12-10.94-71.52-29.83-103.95A16 16 0 01413.83 136C434.92 172.16 448 204.88 448 256c0 50.36-13.06 83.24-34.12 120a16 16 0 01-13.88 8z'/></svg>",$v="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M157.65 192H88a8 8 0 00-8 8v112a8 8 0 008 8h69.65a16 16 0 0110.14 3.63l91.47 75a8 8 0 0012.74-6.46V119.83a8 8 0 00-12.74-6.44l-91.47 75a16 16 0 01-10.14 3.61zM352 320c9.74-19.41 16-40.81 16-64 0-23.51-6-44.4-16-64M400 368c19.48-34 32-64 32-112s-12-77.7-32-112' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Fv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-miterlimit='10' d='M416 432L64 80' class='ionicon-fill-none ionicon-stroke-width'/><path d='M243.33 98.86a23.89 23.89 0 00-25.55 1.82l-.66.51-28.52 23.35a8 8 0 00-.59 11.85l54.33 54.33a8 8 0 0013.66-5.66v-64.49a24.51 24.51 0 00-12.67-21.71zM251.33 335.29L96.69 180.69A16 16 0 0085.38 176H56a24 24 0 00-24 24v112a24 24 0 0024 24h69.76l92 75.31a23.9 23.9 0 0025.87 1.69A24.51 24.51 0 00256 391.45v-44.86a16 16 0 00-4.67-11.3zM352 256c0-24.56-5.81-47.87-17.75-71.27a16 16 0 10-28.5 14.55C315.34 218.06 320 236.62 320 256q0 4-.31 8.13a8 8 0 002.32 6.25l14.36 14.36a8 8 0 0013.55-4.31A146 146 0 00352 256zM416 256c0-51.18-13.08-83.89-34.18-120.06a16 16 0 00-27.64 16.12C373.07 184.44 384 211.83 384 256c0 23.83-3.29 42.88-9.37 60.65a8 8 0 001.9 8.26L389 337.4a8 8 0 0013.13-2.79C411 311.76 416 287.26 416 256z'/><path d='M480 256c0-74.25-20.19-121.11-50.51-168.61a16 16 0 10-27 17.22C429.82 147.38 448 189.5 448 256c0 46.19-8.43 80.27-22.43 110.53a8 8 0 001.59 9l11.92 11.92a8 8 0 0012.92-2.16C471.6 344.9 480 305 480 256z'/></svg>",Dv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-miterlimit='10' d='M416 432L64 80' class='ionicon-fill-none ionicon-stroke-width'/><path d='M224 136.92v33.8a4 4 0 001.17 2.82l24 24a4 4 0 006.83-2.82v-74.15a24.53 24.53 0 00-12.67-21.72 23.91 23.91 0 00-25.55 1.83 8.27 8.27 0 00-.66.51l-31.94 26.15a4 4 0 00-.29 5.92l17.05 17.06a4 4 0 005.37.26zM224 375.08l-78.07-63.92a32 32 0 00-20.28-7.16H64v-96h50.72a4 4 0 002.82-6.83l-24-24a4 4 0 00-2.82-1.17H56a24 24 0 00-24 24v112a24 24 0 0024 24h69.76l91.36 74.8a8.27 8.27 0 00.66.51 23.93 23.93 0 0025.85 1.69A24.49 24.49 0 00256 391.45v-50.17a4 4 0 00-1.17-2.82l-24-24a4 4 0 00-6.83 2.82zM125.82 336zM352 256c0-24.56-5.81-47.88-17.75-71.27a16 16 0 00-28.5 14.54C315.34 218.06 320 236.62 320 256q0 4-.31 8.13a8 8 0 002.32 6.25l19.66 19.67a4 4 0 006.75-2A146.89 146.89 0 00352 256zM416 256c0-51.19-13.08-83.89-34.18-120.06a16 16 0 00-27.64 16.12C373.07 184.44 384 211.83 384 256c0 23.83-3.29 42.88-9.37 60.65a8 8 0 001.9 8.26l16.77 16.76a4 4 0 006.52-1.27C410.09 315.88 416 289.91 416 256z'/><path d='M480 256c0-74.26-20.19-121.11-50.51-168.61a16 16 0 10-27 17.22C429.82 147.38 448 189.5 448 256c0 47.45-8.9 82.12-23.59 113a4 4 0 00.77 4.55L443 391.39a4 4 0 006.4-1C470.88 348.22 480 307 480 256z'/></svg>",Av="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M85.57 446.25h340.86a32 32 0 0028.17-47.17L284.18 82.58c-12.09-22.44-44.27-22.44-56.36 0L57.4 399.08a32 32 0 0028.17 47.17z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M250.26 195.39l5.74 122 5.73-121.95a5.74 5.74 0 00-5.79-6h0a5.74 5.74 0 00-5.68 5.95z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M256 397.25a20 20 0 1120-20 20 20 0 01-20 20z'/></svg>",lr="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M400 320c0 88.37-55.63 144-144 144s-144-55.63-144-144c0-94.83 103.23-222.85 134.89-259.88a12 12 0 0118.23 0C296.77 97.15 400 225.17 400 320z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path d='M344 328a72 72 0 01-72 72' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const vc=()=>{};function Rv(o,a){function t(...n){return new Promise((i,r)=>{Promise.resolve(o(()=>a.apply(this,n),{fn:a,thisArg:this,args:n})).then(i).catch(r)})}return t}function Lv(o,a={}){let t,n,i=vc;const r=d=>{clearTimeout(d),i(),i=vc};let l;return d=>{const c=e.toValue(o),u=e.toValue(a.maxWait);return t&&r(t),c<=0||u!==void 0&&u<=0?(n&&(r(n),n=null),Promise.resolve(d())):new Promise((m,p)=>{i=a.rejectOnCancel?p:m,l=d,u&&!n&&(n=setTimeout(()=>{t&&r(t),n=null,m(l())},u)),t=setTimeout(()=>{n&&r(n),n=null,m(d())},c)})}}function Pv(o,a=200,t={}){return Rv(Lv(a,t),o)}const oi=new Map;function Uv(o){const a=e.getCurrentScope();function t(s){var d;const c=oi.get(o)||new Set;c.add(s),oi.set(o,c);const u=()=>i(s);return(d=a==null?void 0:a.cleanups)==null||d.push(u),u}function n(s){function d(...c){i(d),s(...c)}return t(d)}function i(s){const d=oi.get(o);d&&(d.delete(s),d.size||r())}function r(){oi.delete(o)}function l(s,d){var c;(c=oi.get(o))==null||c.forEach(u=>u(s,d))}return{on:t,once:n,off:i,emit:l,reset:r}}function um(){var r,l;const o=typeof window<"u"&&"Capacitor"in window&&((l=(r=window.Capacitor)==null?void 0:r.isNativePlatform)==null?void 0:l.call(r));return{selection:()=>{var s,d;if(o)try{const c=(d=(s=window.Capacitor)==null?void 0:s.Plugins)==null?void 0:d.Haptics;c&&c.impact({style:"LIGHT"})}catch{}else"vibrate"in navigator&&navigator.vibrate(10)},success:()=>{var s,d;if(o)try{const c=(d=(s=window.Capacitor)==null?void 0:s.Plugins)==null?void 0:d.Haptics;c&&c.impact({style:"MEDIUM"})}catch{}else"vibrate"in navigator&&navigator.vibrate(30)},error:()=>{var s,d;if(o)try{const c=(d=(s=window.Capacitor)==null?void 0:s.Plugins)==null?void 0:d.Haptics;c&&c.impact({style:"HEAVY"})}catch{}else"vibrate"in navigator&&navigator.vibrate([50,50,50])},notification:()=>{var s,d;if(o)try{const c=(d=(s=window.Capacitor)==null?void 0:s.Plugins)==null?void 0:d.Haptics;c&&c.notification({type:"SUCCESS"})}catch{}else"vibrate"in navigator&&navigator.vibrate([20,100,20])}}}function tl(o,a={}){const t=e.ref(new Set),n=e.ref(new Map),i=e.ref(null),r=e.ref(-1),l=e.ref(a.scopeKey!==void 0?e.toValue(a.scopeKey):"default"),s=e.ref(!1),d=e.ref(null),c=Uv("media-selection"),u=um(),m=()=>{if(a.currentPage===void 0)return null;const O=e.toValue(a.currentPage);return typeof O=="number"&&Number.isFinite(O)?O:null};function p(O){t.value=O,n.value=new Map(Array.from(n.value.entries()).filter(([K])=>O.has(K)))}function f(O){if(n.value.has(O))return;const K=new Map(n.value);K.set(O,{uuid:O,selectedAt:Date.now(),page:m()}),n.value=K}const h=e.computed(()=>o.value.filter(O=>t.value.has(O.uuid))),v=e.computed(()=>t.value.size),k=e.computed(()=>Array.from(n.value.values()).sort((O,K)=>O.selectedAt-K.selectedAt).map(O=>O.uuid)),y=e.computed(()=>Math.max(0,v.value-h.value.length)),w=e.computed(()=>{const O=new Map;for(const K of n.value.values())K.page!==null&&O.set(K.page,(O.get(K.page)??0)+1);return O});e.watch(t,O=>{c.emit({type:"selection:changed",count:O.size,selectedIds:Array.from(O)})}),a.scopeKey!==void 0&&e.watch(()=>e.toValue(a.scopeKey),(O,K)=>{O!==void 0&&O!==K&&z(O)});const g=e.computed(()=>o.value.length>0&&o.value.every(O=>t.value.has(O.uuid))),b=e.computed(()=>o.value.some(O=>t.value.has(O.uuid)));function R(O){return t.value.has(O)}function V(O){const K=new Set(t.value),de=K.size===0;K.add(O),f(O),t.value=K,i.value=O,r.value=o.value.findIndex(Ne=>Ne.uuid===O),de&&u.selection()}function I(O){const K=new Set(t.value);K.delete(O);const de=new Map(n.value);de.delete(O),n.value=de,t.value=K,i.value===O&&(i.value=null,r.value=-1)}function x(O){if(t.value.has(O)){I(O);return}V(O)}function T(){const O=new Set(t.value);for(const K of o.value)O.add(K.uuid),f(K.uuid);t.value=O}function $(){t.value=new Set,n.value=new Map,i.value=null,r.value=-1,s.value=!1,d.value=null}function S(){if(g.value){$();return}T()}function B(O,K){const de=o.value.findIndex(Ne=>Ne.uuid===O);if(de!==-1){if(K!=null&&K.shiftKey&&r.value!==-1){const Ne=Math.min(r.value,de),ce=Math.max(r.value,de),le=new Set(t.value);for(let W=Ne;W<=ce;W++){const C=o.value[W];C!==void 0&&(le.add(C.uuid),f(C.uuid))}t.value=le;return}x(O)}}function _(){if(o.value.length===0)return;let O=r.value+1;O>=o.value.length&&(O=0),$();const K=o.value[O];K!==void 0&&V(K.uuid)}function A(){if(o.value.length===0)return;let O=r.value-1;O<0&&(O=o.value.length-1),$();const K=o.value[O];K!==void 0&&V(K.uuid)}function P(O){switch(O.key){case"ArrowDown":O.preventDefault(),_();break;case"ArrowUp":O.preventDefault(),A();break;case"a":(O.ctrlKey||O.metaKey)&&(O.preventDefault(),T());break;case"Escape":O.preventDefault(),$();break;case" ":i.value&&(O.preventDefault(),x(i.value));break}}async function D(O){var de;if(v.value===0||l.value===O)return!0;const K=(de=a.confirmScopeChange)==null?void 0:de.call(a,{from:l.value,to:O,selectedCount:v.value});return K===void 0?!0:await K}async function z(O){return l.value===O?!0:await D(O)?(l.value=O,$(),!0):!1}async function M(){if(!a.fetchMatchingUuids){const K={uuids:o.value.map(de=>de.uuid),overCap:!1,totalMatching:o.value.length};return Z(K),K}const O=await a.fetchMatchingUuids();return Z(O),O}function Z(O){const K=new Set(O.uuids),de=new Map,Ne=Date.now();O.uuids.forEach((ce,le)=>{de.set(ce,{uuid:ce,selectedAt:Ne+le,page:m()})}),p(K),n.value=de,s.value=O.overCap,d.value=O.totalMatching}return{selectedIds:e.computed(()=>t.value),selectedRecords:e.computed(()=>n.value),selectedItems:h,selectedCount:v,orderedIds:k,crossPageCount:y,selectedPages:w,overCap:e.computed(()=>s.value),totalMatching:e.computed(()=>d.value),activeScopeKey:e.computed(()=>l.value),isAllSelected:g,isSomeSelected:b,lastSelectedId:e.computed(()=>i.value),isSelected:R,toggle:x,select:V,deselect:I,selectAll:T,clear:$,toggleAll:S,rangeSelect:B,selectAcrossAllPages:M,setScopeKey:z,canChangeScope:D,selectNext:_,selectPrevious:A,handleKeydown:P,selectionBus:c}}const Ov={class:"flex items-center justify-between w-full px-4"},zv={class:"p-4"},jv={key:0,class:"mb-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg"},Wv={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"},Hv=["value"],Zv={class:"flex gap-2 mt-4"},Gv={class:"flex justify-end mb-4"},Xv={key:1,class:"flex justify-center items-center h-64"},Kv={key:2,class:"flex flex-col items-center justify-center h-64 text-center"},Jv={class:"text-sm text-theme-secondary"},qv={key:0},Yv={class:"mb-4"},Qv={class:"mb-4"},eg={class:"flex gap-2"},tg={class:"flex items-center justify-between px-4 py-2"},ag={class:"text-sm text-theme-secondary"},ng={key:0},og={key:0},ig={key:1},rg={class:"flex gap-2"},lg=e.defineComponent({__name:"AdminMediaBrowser",props:{isOpen:{type:Boolean},selectionMode:{default:"single"},selectedItems:{default:()=>[]},modelType:{},modelId:{},collection:{default:"images"},maxSelection:{}},emits:["close","confirm"],setup(o,{emit:a}){const t=o,n=a,i=e.ref("recent"),r=e.ref("grid"),l=e.ref(""),s=e.ref(!1),d=e.ref([]),{selectedItems:c}=e.toRefs(t),u=e.ref(new Set(c.value)),m=e.ref(!1),p=e.ref({}),f=e.ref(["images","documents","videos"]),h=e.ref(1),v=e.ref(!0),k=e.ref(!1),y=Ju(),w=tl(d);function g(W){var be;const C=W.conversion_urls||{},U=W.proxy_url||W.original_url||W.url||"",j=C.thumb||C.preview||W.preview_url||W.thumbnail_url||U,re=W.custom_properties||{},ue=re.width,Xe=re.height;return{...W,uuid:W.uuid,name:W.name||W.file_name,file_name:W.file_name,filename:W.file_name,mime_type:W.mime_type,size:W.size,collection_name:W.collection_name||"images",disk:W.disk,original_url:U,url:U,thumbnail_url:j,conversions:W.conversions||{},conversion_urls:C,generated_conversions:W.generated_conversions||{},custom_properties:re,caption:W.caption||null,alt_text:W.alt_text||null,created_at:W.created_at,updated_at:W.updated_at,is_image:((be=W.mime_type)==null?void 0:be.startsWith("image/"))||!1,...typeof ue=="number"?{width:ue}:{},...typeof Xe=="number"?{height:Xe}:{},...W.formatted_size!==void 0?{formatted_size:W.formatted_size}:{}}}e.watch(()=>t.selectedItems,W=>{u.value=new Set(W),w.clear(),W.forEach(C=>w.select(C))});const b=e.computed(()=>{var C;let W=d.value;return(C=p.value.types)!=null&&C.length&&(W=W.filter(U=>{var re,ue;const j=(re=U.mime_type)==null?void 0:re.split("/")[0];return(ue=p.value.types)==null?void 0:ue.includes(j)})),(p.value.sizeMin!==void 0||p.value.sizeMax!==void 0)&&(W=W.filter(U=>{const j=U.size/1048576;return!(p.value.sizeMin!==void 0&&j<p.value.sizeMin||p.value.sizeMax!==void 0&&j>p.value.sizeMax)})),W}),R=e.computed(()=>{var C;let W=0;return p.value.search&&W++,p.value.collection&&W++,(p.value.dateFrom||p.value.dateTo)&&W++,(C=p.value.types)!=null&&C.length&&(W+=p.value.types.length),(p.value.sizeMin!==void 0||p.value.sizeMax!==void 0)&&W++,W}),V=e.computed(()=>{const W=w.selectedCount.value;return W===0?"Select Media":`Select ${t.selectionMode==="multiple"?`${W} ${W===1?"Item":"Items"}`:"Item"}`}),I=e.computed(()=>{const W=w.selectedCount.value;return!!(W===0||t.selectionMode==="single"&&W>1||t.maxSelection&&W>t.maxSelection)}),x=e.computed(()=>{switch(i.value){case"recent":return"Recent Uploads";case"model":return"Model Media";case"library":return"Media Library";default:return"Media Browser"}});async function T(W=!0){W?(s.value=!0,d.value=[],h.value=1,v.value=!0):k.value=!0;try{const C={collection:p.value.collection||t.collection,per_page:24};switch((l.value||p.value.search)&&(C.search=l.value||p.value.search||""),p.value.dateFrom&&(C.from_date=p.value.dateFrom),p.value.dateTo&&(C.to_date=p.value.dateTo),i.value){case"recent":await y.fetchMedia(h.value,C),W?d.value=y.items.map(U=>g(U)):d.value=[...d.value,...y.items.map(U=>g(U))],v.value=y.currentPage<y.totalPages;break;case"model":if(t.modelType&&t.modelId){const U=await y.fetchModelMedia(t.modelType,t.modelId,C.collection,C.search);d.value=U?U.map(j=>g(j)):[],v.value=!1}break;case"library":await y.fetchMedia(h.value,C),W?d.value=y.items.map(U=>g(U)):d.value=[...d.value,...y.items.map(U=>g(U))],v.value=y.currentPage<y.totalPages;break}}catch{}finally{s.value=!1,k.value=!1}}async function $(W){if(!v.value||k.value){W!=null&&W.target&&W.target.complete();return}h.value++,await T(!1),W!=null&&W.target&&(W.target.complete(),v.value||(W.target.disabled=!0))}function S(W){return W==="recent"||W==="model"||W==="library"}function B(W){i.value=W,T()}function _(W){typeof W=="string"&&S(W)&&B(W)}async function A(W){t.selectionMode==="single"?(w.clear(),w.select(W.uuid)):(w.toggle(W.uuid),t.maxSelection&&w.selectedCount.value>t.maxSelection&&(w.deselect(W.uuid),await(await H.toastController.create({message:`Maximum ${t.maxSelection} items can be selected`,duration:2e3,color:"warning"})).present()))}function P(){n("confirm",w.selectedItems.value)}function D(){n("close")}function z(W){}const M=e.ref(null),Z=e.ref(!1);function O(W){M.value=W,Z.value=!0}function K(W){const C=d.value.findIndex(j=>j.uuid===W.uuid);C!==-1&&(d.value[C]=W);const U={};W.alt_text!==void 0&&(U.alt_text=W.alt_text),W.caption!==void 0&&(U.caption=W.caption),W.custom_properties!==void 0&&(U.custom_properties=W.custom_properties),y.updateMedia(W.uuid,U)}function de(){T()}function Ne(){p.value={},l.value="",T()}const ce=Pv(()=>{T(!0)},300);e.watch(l,()=>{t.isOpen&&ce()});async function le(W){try{await(await H.alertController.create({header:"Delete Media",message:"Are you sure you want to delete this media item?",buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"destructive",handler:async()=>{await y.deleteMedia(W),await T()}}]})).present()}catch{}}return e.watch(()=>t.isOpen,W=>{W&&T()}),e.onMounted(()=>{t.selectedItems.length>0&&t.selectedItems.forEach(W=>w.select(W))}),(W,C)=>{const U=e.resolveComponent("AdminMediaGrid"),j=e.resolveComponent("AdminMediaListItem");return e.openBlock(),e.createBlock(e.unref(H.IonModal),{"is-open":W.isOpen,onDidDismiss:D,"backdrop-dismiss":!1,class:"media-browser-modal"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(H.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonButton),{onClick:D},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(H.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(x.value),1)]),_:1})]),_:1}),e.createVNode(e.unref(H.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",Ov,[e.createVNode(e.unref(H.IonSegment),{value:i.value,onIonChange:C[0]||(C[0]=re=>_(re.detail.value)),class:"max-w-xs"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonSegmentButton),{value:"recent"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...C[15]||(C[15]=[e.createTextVNode("Recent",-1)])]),_:1})]),_:1}),t.modelType&&t.modelId?(e.openBlock(),e.createBlock(e.unref(H.IonSegmentButton),{key:0,value:"model"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...C[16]||(C[16]=[e.createTextVNode("Model",-1)])]),_:1})]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(H.IonSegmentButton),{value:"library"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...C[17]||(C[17]=[e.createTextVNode("Library",-1)])]),_:1})]),_:1})]),_:1},8,["value"]),e.createVNode(e.unref(H.IonButton),{fill:"clear",size:"small",onClick:C[1]||(C[1]=re=>m.value=!m.value),class:"relative"},{"icon-only":e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{name:"filter-outline"})]),default:e.withCtx(()=>[R.value>0?(e.openBlock(),e.createBlock(e.unref(H.IonBadge),{key:0,color:"primary",class:"absolute -top-1 -right-1 min-w-[20px] h-5 rounded-full flex items-center justify-center text-xs"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(R.value),1)]),_:1})):e.createCommentVNode("",!0)]),_:1})])]),_:1})]),_:1}),e.createVNode(e.unref(H.IonContent),null,{default:e.withCtx(()=>[e.createElementVNode("div",zv,[m.value?(e.openBlock(),e.createElementBlock("div",jv,[e.createElementVNode("div",Wv,[e.createElementVNode("div",null,[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...C[18]||(C[18]=[e.createTextVNode("Collection",-1)])]),_:1}),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":C[2]||(C[2]=re=>p.value.collection=re),class:"w-full p-2 border rounded"},[C[19]||(C[19]=e.createElementVNode("option",{value:""},"All Collections",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,re=>(e.openBlock(),e.createElementBlock("option",{key:re,value:re},e.toDisplayString(re),9,Hv))),128))],512),[[e.vModelSelect,p.value.collection]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...C[20]||(C[20]=[e.createTextVNode("From Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":C[3]||(C[3]=re=>p.value.dateFrom=re),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,p.value.dateFrom]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...C[21]||(C[21]=[e.createTextVNode("To Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":C[4]||(C[4]=re=>p.value.dateTo=re),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,p.value.dateTo]])])]),e.createElementVNode("div",Zv,[e.createVNode(e.unref(H.IonButton),{size:"small",onClick:de},{default:e.withCtx(()=>[...C[22]||(C[22]=[e.createTextVNode("Apply",-1)])]),_:1}),e.createVNode(e.unref(H.IonButton),{size:"small",fill:"clear",onClick:Ne},{default:e.withCtx(()=>[...C[23]||(C[23]=[e.createTextVNode("Clear",-1)])]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(e.unref(H.IonSearchbar),{modelValue:l.value,"onUpdate:modelValue":C[5]||(C[5]=re=>l.value=re),placeholder:"Search media...",debounce:300,class:"mb-4"},null,8,["modelValue"]),e.createElementVNode("div",Gv,[e.createVNode(e.unref(H.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonButton),{fill:r.value==="grid"?"solid":"clear",size:"small",onClick:C[6]||(C[6]=re=>r.value="grid")},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{name:"grid-outline"})]),_:1},8,["fill"]),e.createVNode(e.unref(H.IonButton),{fill:r.value==="list"?"solid":"clear",size:"small",onClick:C[7]||(C[7]=re=>r.value="list")},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{name:"list-outline"})]),_:1},8,["fill"])]),_:1})]),s.value?(e.openBlock(),e.createElementBlock("div",Xv,[e.createVNode(e.unref(H.IonSpinner),{name:"crescent"})])):b.value.length===0?(e.openBlock(),e.createElementBlock("div",Kv,[e.createVNode(e.unref(H.IonIcon),{name:"images-outline",class:"text-6xl text-theme-secondary mb-4"}),C[24]||(C[24]=e.createElementVNode("h3",{class:"text-lg font-medium text-theme mb-2"}," No Media Found ",-1)),e.createElementVNode("p",Jv,e.toDisplayString(l.value?"Try adjusting your search":"No media items available"),1)])):r.value==="grid"?(e.openBlock(),e.createBlock(U,{key:3,"media-items":b.value,"selected-items":e.unref(w).selectedItems.value,"is-loading":!1,"selection-mode":!0,columns:{mobile:2,sm:3,md:4,lg:5,xl:6},onToggleSelect:A,onPreview:z,onEdit:O,onDelete:le},null,8,["media-items","selected-items"])):(e.openBlock(),e.createBlock(e.unref(H.IonList),{key:4,lines:"none",class:"rounded-lg overflow-hidden"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,(re,ue)=>(e.openBlock(),e.createBlock(j,{key:re.uuid,media:re,selected:e.unref(w).isSelected(re.uuid),"selection-mode":!0,index:ue,onToggleSelect:A,onPreview:z,onEdit:O,onDelete:le},null,8,["media","selected","index"]))),128))]),_:1})),!s.value&&b.value.length>0&&i.value!=="model"?(e.openBlock(),e.createBlock(e.unref(H.IonInfiniteScroll),{key:5,threshold:"100px",onIonInfinite:C[8]||(C[8]=re=>$(re))},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonInfiniteScrollContent),{"loading-spinner":"crescent","loading-text":"Loading more media..."})]),_:1})):e.createCommentVNode("",!0)])]),_:1}),e.createVNode(e.unref(H.IonModal),{"is-open":Z.value,onDidDismiss:C[14]||(C[14]=re=>Z.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(H.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonButton),{onClick:C[9]||(C[9]=re=>Z.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(H.IonTitle),null,{default:e.withCtx(()=>[...C[25]||(C[25]=[e.createTextVNode("Edit Media Info",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(H.IonContent),{class:"p-4"},{default:e.withCtx(()=>[M.value?(e.openBlock(),e.createElementBlock("div",qv,[e.createElementVNode("div",Yv,[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...C[26]||(C[26]=[e.createTextVNode("Caption",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":C[10]||(C[10]=re=>M.value.caption=re),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter caption..."},null,512),[[e.vModelText,M.value.caption]])]),e.createElementVNode("div",Qv,[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...C[27]||(C[27]=[e.createTextVNode("Alt Text",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":C[11]||(C[11]=re=>M.value.alt_text=re),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter alt text..."},null,512),[[e.vModelText,M.value.alt_text]])]),e.createElementVNode("div",eg,[e.createVNode(e.unref(H.IonButton),{onClick:C[12]||(C[12]=re=>K(M.value))},{default:e.withCtx(()=>[...C[28]||(C[28]=[e.createTextVNode("Save",-1)])]),_:1}),e.createVNode(e.unref(H.IonButton),{fill:"clear",onClick:C[13]||(C[13]=re=>Z.value=!1)},{default:e.withCtx(()=>[...C[29]||(C[29]=[e.createTextVNode("Cancel",-1)])]),_:1})])])):e.createCommentVNode("",!0)]),_:1})]),_:1},8,["is-open"]),e.createVNode(e.unref(H.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",tg,[e.createElementVNode("div",ag,[e.unref(w).selectedCount.value>0?(e.openBlock(),e.createElementBlock("span",ng,[e.createTextVNode(e.toDisplayString(e.unref(w).selectedCount.value)+" selected ",1),t.maxSelection?(e.openBlock(),e.createElementBlock("span",og," / "+e.toDisplayString(t.maxSelection)+" max ",1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("span",ig," Select "+e.toDisplayString(t.selectionMode==="multiple"?"items":"an item"),1))]),e.createElementVNode("div",rg,[e.createVNode(e.unref(H.IonButton),{fill:"clear",onClick:D},{default:e.withCtx(()=>[...C[30]||(C[30]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(H.IonButton),{disabled:I.value,onClick:P},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(V.value),1)]),_:1},8,["disabled"])])])]),_:1})]),_:1})]),_:1},8,["is-open"])}}}),sg=$e(lg,[["__scopeId","data-v-9a8c0954"]]),dg={key:1,class:"flex flex-col items-center justify-center py-16"},cg=["draggable","onDragstart","onDragover","onDrop"],ug={key:0,class:"absolute top-2 left-2 z-20"},mg=["checked","onChange"],pg={key:2,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-move"},fg=["data-media-id"],hg={key:0,class:"w-full h-full flex items-center justify-center"},vg=["src","alt","onError","onLoad"],gg={key:2,class:"w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-700"},bg={class:"text-center"},yg={class:"text-4xl text-gray-400 mb-2"},wg={class:"text-sm font-medium text-gray-500"},kg={class:"absolute inset-0 bg-black/70 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2"},_g=["onClick"],Eg=["onClick"],Sg=["onClick"],Cg={class:"p-3"},xg={class:"text-sm font-medium truncate mb-1"},Ng={class:"text-xs text-gray-600 dark:text-gray-400"},Vg={key:0},Tg={key:0,class:"text-xs text-gray-500 dark:text-gray-500 mt-1 truncate"},Bg=e.defineComponent({__name:"MediaGrid",props:{mediaItems:{default:()=>[]},selectedItems:{default:()=>[]},isLoading:{type:Boolean,default:!1},selectionMode:{type:Boolean,default:!1},reorderable:{type:Boolean,default:!1},showEditButton:{type:Boolean,default:!1},columns:{default:()=>({mobile:2,sm:3,md:4,lg:5,xl:6})}},emits:["toggleSelect","preview","edit","delete","reorder","upload"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(null),r=e.ref(null),l=e.ref(new Set),s=e.ref(null),d=I=>t.selectedItems.some(x=>x.uuid===I.uuid),c=e.computed(()=>{const I=t.columns,x=["grid","gap-4"];switch(I.mobile){case 1:x.push("grid-cols-1");break;case 2:x.push("grid-cols-2");break;case 3:x.push("grid-cols-3");break;case 4:x.push("grid-cols-4");break;default:x.push("grid-cols-2");break}switch(I.sm){case 1:x.push("sm:grid-cols-1");break;case 2:x.push("sm:grid-cols-2");break;case 3:x.push("sm:grid-cols-3");break;case 4:x.push("sm:grid-cols-4");break;case 5:x.push("sm:grid-cols-5");break;default:x.push("sm:grid-cols-3");break}switch(I.md){case 2:x.push("md:grid-cols-2");break;case 3:x.push("md:grid-cols-3");break;case 4:x.push("md:grid-cols-4");break;case 5:x.push("md:grid-cols-5");break;case 6:x.push("md:grid-cols-6");break;default:x.push("md:grid-cols-4");break}switch(I.lg){case 3:x.push("lg:grid-cols-3");break;case 4:x.push("lg:grid-cols-4");break;case 5:x.push("lg:grid-cols-5");break;case 6:x.push("lg:grid-cols-6");break;case 7:x.push("lg:grid-cols-7");break;default:x.push("lg:grid-cols-5");break}switch(I.xl){case 4:x.push("xl:grid-cols-4");break;case 5:x.push("xl:grid-cols-5");break;case 6:x.push("xl:grid-cols-6");break;case 7:x.push("xl:grid-cols-7");break;case 8:x.push("xl:grid-cols-8");break;default:x.push("xl:grid-cols-6");break}return x.join(" ")});function u(I,x,T){t.reorderable&&(i.value=x,I.dataTransfer&&(I.dataTransfer.effectAllowed="move",I.dataTransfer.setData("text/html","")))}function m(I,x){t.reorderable&&(I.preventDefault(),r.value=x)}function p(){r.value=null}function f(I,x){if(!t.reorderable||!i.value)return;I.preventDefault();const T=[...t.mediaItems],$=T.findIndex(S=>{var B;return S.uuid===((B=i.value)==null?void 0:B.uuid)});if($!==-1&&$!==x&&i.value){const[S]=T.splice($,1);T.splice(x,0,S),n("reorder",T)}i.value=null,r.value=null}function h(I){return I<1024?I+" B":I<1024*1024?(I/1024).toFixed(1)+" KB":(I/(1024*1024)).toFixed(1)+" MB"}function v(I){var T;return I.thumbnail_url||((T=I.conversion_urls)==null?void 0:T.thumb)||I.original_url||I.url||""}function k(I){var $,S,B;const x=(($=I.mime_type)==null?void 0:$.startsWith("image/"))||!1,T=!!(I.thumbnail_url||(S=I.conversion_urls)!=null&&S.thumb||(B=I.conversion_urls)!=null&&B.preview||I.original_url||I.url);return x&&T}function y(I){var x;return((x=I.split(".").pop())==null?void 0:x.toUpperCase())||""}function w(I){var T;const x=((T=I.mime_type)==null?void 0:T.toLowerCase())||"";return x.startsWith("image/")?"image":x.startsWith("video/")?"videocam":x.startsWith("audio/")?"musical-notes":x.includes("pdf")?"document-text":x.includes("zip")||x.includes("rar")?"archive":x.includes("sheet")||x.includes("excel")?"grid":x.includes("document")||x.includes("word")?"document-text":"document"}e.onMounted(()=>{typeof window<"u"&&"IntersectionObserver"in window&&(s.value=new IntersectionObserver(I=>{I.forEach(x=>{var T;if(x.isIntersecting){const $=x.target.getAttribute("data-media-id");$&&(l.value.add($),(T=s.value)==null||T.unobserve(x.target))}})},{rootMargin:"50px"}))}),e.onUnmounted(()=>{s.value&&s.value.disconnect()});function g(I){return!0}function b(){s.value&&e.nextTick(()=>{document.querySelectorAll("[data-media-id]").forEach(x=>{var $;const T=x.getAttribute("data-media-id");T&&!l.value.has(T)&&(($=s.value)==null||$.observe(x))})})}e.watch(()=>t.mediaItems,()=>{l.value.clear(),b()},{immediate:!0,deep:!0});function R(I,x){const T=I.target;delete T.dataset.fallbackIndex}function V(I,x){const T=I.target,$=T.closest("[data-media-id]"),S=[x.original_url,x.url,x.thumbnail_url,"preview_url"in x?x.preview_url:void 0].filter(B=>B&&B.trim()!==""&&B!==T.src);if(S.length>0&&T.dataset.fallbackIndex){const B=parseInt(T.dataset.fallbackIndex);if(B<S.length){T.dataset.fallbackIndex=(B+1).toString(),T.src=S[B]||"";return}}else if(S.length>0){T.dataset.fallbackIndex="1",T.src=S[0]||"";return}if(T.style.display="none",$&&!$.querySelector(".media-fallback-icon")){const _=document.createElement("div");_.className="media-fallback-icon w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-800",_.innerHTML=`
|
|
1
|
+
"use strict";var ch=Object.defineProperty;var uh=(o,a,t)=>a in o?ch(o,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[a]=t;var ae=(o,a,t)=>uh(o,typeof a!="symbol"?a+"":a,t);const Qr=require("pinia"),e=require("vue"),$t=require("pixi.js"),te=require("./editor-D85y_zTO.cjs"),H=require("@ionic/vue"),mh=require("pixi-filters");function ph(o){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(a,t,n.get?n:{enumerable:!0,get:()=>o[t]})}}return a.default=o,Object.freeze(a)}const Jt=ph($t),us=1,fh=new Set(["free","square","circle"]);function hh(o){if(typeof o!="number"||!Number.isFinite(o))return 0;const a=o%360;return a<0?a+360:a}function vh(o){const a=typeof o;return a==="string"||a==="number"||a==="boolean"}function gh(o){if(!o||typeof o!="object")return!1;const a=o;return typeof a.x=="number"&&typeof a.y=="number"&&typeof a.width=="number"&&typeof a.height=="number"}function Qs(o){if(!o||typeof o!="object")return null;const a=o;if(a.version!==us)return null;const t=a.crop,n=t&&gh(t.rect)?{...t.rect}:null,i=t&&typeof t.shape=="string"&&fh.has(t.shape)?t.shape:"free",r=t&&typeof t.aspectRatio=="string"?t.aspectRatio:"free",l=a.transform,s=hh(l==null?void 0:l.rotation),d=a.filters,c=[];if(Array.isArray(d))for(const u of d){if(!u||typeof u!="object")continue;const m=u;if(typeof m.id!="string")continue;const p={},f=m.values;if(f&&typeof f=="object"&&!Array.isArray(f))for(const[h,v]of Object.entries(f))vh(v)&&(p[h]=v);c.push({id:m.id,enabled:m.enabled!==!1,values:p})}return{version:us,crop:{rect:n,aspectRatio:r,shape:i},transform:{rotation:s},filters:c}}function Zu(o){const a=Qs(o);return a?JSON.stringify(a):null}function bh(o){try{const a=JSON.parse(o);return Qs(a)}catch{return null}}function yh(){return{version:us,crop:{rect:null,aspectRatio:"free",shape:"free"},transform:{rotation:0},filters:[]}}let ba={apiBaseUrl:"/api/v1",isAdmin:!1};function ic(o){return typeof o=="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(o)}function $o(o){ba={...ba,...o}}function Gu(){return{...ba}}function Xu(o){ba={...o}}function Ku(o){const a=Gu();return $o(o),()=>{Xu(a)}}function wh(o){const a=o.trim().replace(/\/+$/,"");return a===""?"/api/v1":a.startsWith("/")?a:`/${a}`}function kh(o,a){const t=wh(a),n=(i,r="")=>{const l=`/api${t}`;return!t.startsWith("/api/")&&i.startsWith(`${l}/`)?`${i.slice(4)}${r}`:!t.startsWith("/api/")&&i===l?`${t}${r}`:`${i}${r}`};if(/^https?:\/\//i.test(o))try{const i=typeof window<"u"?window.location.origin:"http://localhost",r=new URL(o,i);if(r.origin===i)return n(r.pathname,`${r.search}${r.hash}`)}catch{return o}return n(o)}const _h=async(o,a={})=>{var s;const t=(s=document.querySelector('meta[name="csrf-token"]'))==null?void 0:s.getAttribute("content"),n={Accept:"application/json",...a.headers};t&&(n["X-CSRF-TOKEN"]=t),a.body instanceof FormData||(n["Content-Type"]="application/json");const r={method:a.method||"GET",headers:n,credentials:"include"};a.body instanceof FormData?r.body=a.body:a.body!==void 0&&(r.body=JSON.stringify(a.body));const l=await fetch(o,r);if(!l.ok){const d=await l.json().catch(()=>({message:"Request failed"}));throw new Error(d.message||`HTTP ${l.status}`)}if(l.status!==204)return await l.json()},xa=Qr.defineStore("media",()=>{const o=e.ref([]),a=e.ref([]),t=e.ref(!1),n=e.ref(null),i=e.ref(1),r=e.ref(1),l=e.ref(24),s=e.ref({type:null,uuid:null}),d=e.ref([]),c=e.ref(!1),u=e.ref(null),m=e.ref(new Map),p=e.ref(new Map),f=e.ref(new Set),h=e.ref(new Map),v=e.ref({}),k=5*60*1e3,y=e.computed(()=>{if(ba.apiScope)return ba.apiScope;if(ba.isAdmin)return"admin"}),w=e.computed(()=>y.value==="admin");function g(){return ba.httpClient||_h}function b(be){const Ee=ba.apiBaseUrl||"/api/v1",ye=y.value?`/${y.value}`:"";return`${Ee}${ye}${be}`}function R(be){return`${ba.apiBaseUrl||"/api/v1"}${be}`}function V(be,Ee){return`${y.value??"default"}-${be}-${JSON.stringify(Ee)}`}function I(be){return Date.now()-be<k}function x(){h.value.clear(),v.value={}}function T(be){if(!be||!be.data)return;const Ee={};be.data.forEach(ye=>{const xe=`${ye.file_name}-${ye.collection_name||"default"}`,Ce=Ee[xe];(!Ce||Object.keys(ye.generated_conversions||{}).length>Object.keys(Ce.generated_conversions||{}).length)&&(Ee[xe]=ye)}),o.value=Object.values(Ee),be.meta&&(i.value=be.meta.current_page,r.value=Math.ceil(be.meta.total/be.meta.per_page))}async function $(be=1,Ee={}){const ye=V(be,Ee),xe=h.value.get(ye);if(xe&&I(xe.timestamp)){const Ce=xe.data;return T(Ce),Ce}t.value=!0,n.value=null;try{const Ce=new URLSearchParams;Ce.append("page",be.toString()),Ce.append("per_page",l.value.toString()),w.value&&Ce.append("linked","1");for(const rt in Ee)if(Object.prototype.hasOwnProperty.call(Ee,rt)){const at=Ee[rt];at!=null&&at!==""&&Ce.append(rt,String(at))}const ze=await g()(b(`/media?${Ce}`));return h.value.set(ye,{data:ze,timestamp:Date.now()}),T(ze),ze}catch(Ce){throw n.value=Ce instanceof Error?Ce.message:"Failed to fetch media",o.value=[],new Error(n.value)}finally{t.value=!1}}async function S(be,Ee){t.value=!0,n.value=null;const ye=`${be.name}-${Date.now()}`,xe={file:be,progress:0,status:"uploading"};m.value.set(ye,xe);try{const Ce=new FormData;Ce.append("file",be),Ce.append("collection",Ee.collection),Ee.ownerUuid&&(Ce.append("owner_uuid",Ee.ownerUuid),Ce.append("owner_type",Ee.ownerType||"")),Ee.usageUuid&&(Ce.append("usage_uuid",Ee.usageUuid),Ce.append("usage_type",Ee.usageType||""),Ce.append("usage_purpose",Ee.usagePurpose||"")),Ee.customProperties&&Ce.append("custom_properties",JSON.stringify(Ee.customProperties));const ze=await g()(b("/media"),{method:"POST",body:Ce});return xe.status="completed",xe.progress=100,xe.media=ze==null?void 0:ze.data,i.value===1&&(ze!=null&&ze.data)&&(o.value=[ze.data,...o.value]),x(),(ze==null?void 0:ze.data)||null}catch(Ce){throw xe.status="error",xe.error=Ce instanceof Error?Ce.message:"Upload failed",n.value=xe.error,new Error(n.value)}finally{t.value=!1,setTimeout(()=>{m.value.delete(ye)},5e3)}}async function B(be){t.value=!0,n.value=null;const Ee=o.value.findIndex(xe=>xe.uuid===be);let ye;Ee!==-1&&(ye=o.value.splice(Ee,1)[0]);try{return await g()(b(`/media/${be}`),{method:"DELETE"}),f.value.delete(be),x(),!0}catch(xe){throw ye&&Ee!==-1&&o.value.splice(Ee,0,ye),n.value=xe instanceof Error?xe.message:"Failed to delete media",new Error(n.value)}finally{t.value=!1}}async function _(be,Ee){t.value=!0,n.value=null;try{const xe=await g()(b(`/media/${be}`),{method:"PATCH",body:Ee,data:Ee});if(xe!=null&&xe.data){const Ce=o.value.findIndex(Re=>Re.uuid===be);return Ce!==-1&&(o.value[Ce]={...o.value[Ce],...xe.data}),x(),xe.data}return null}catch(ye){throw n.value=ye instanceof Error?ye.message:"Failed to update media",new Error(n.value)}finally{t.value=!1}}async function A(){t.value=!0,n.value=null;try{const Ee=await g()(b("/media/collections"));return a.value=(Ee==null?void 0:Ee.data)||[],a.value}catch(be){throw n.value=be instanceof Error?be.message:"Failed to fetch collections",a.value=[],new Error(n.value)}finally{t.value=!1}}async function P(be,Ee,ye="images",xe){c.value=!0,u.value=null;try{const Ce=new URLSearchParams;Ce.append("collection",ye),xe&&Ce.append("search",xe);const ze=await g()(b(`/media/model/${be}/${Ee}?${Ce}`));return ze!=null&&ze.data?(d.value=ze.data,ze.data):[]}catch(Ce){throw u.value=Ce instanceof Error?Ce.message:"Failed to fetch model media",d.value=[],new Error(u.value)}finally{c.value=!1}}async function D(be,Ee,ye,xe="images"){c.value=!0,u.value=null;const Ce=[...d.value];try{const ze=await g()(b(`/media/model/${be}/${Ee}/attach`),{method:"POST",body:{media_uuids:ye,collection:xe}});return await P(be,Ee,xe),(ze==null?void 0:ze.data)||[]}catch(Re){throw d.value=Ce,u.value=Re instanceof Error?Re.message:"Failed to attach media",new Error(u.value)}finally{c.value=!1}}async function z(be,Ee,ye,xe="images"){c.value=!0,u.value=null;const Ce=[...d.value];d.value=d.value.filter(Re=>Re.uuid!==ye);try{return await g()(b(`/media/model/${be}/${Ee}/detach`),{method:"POST",body:{media_uuid:ye,collection:xe}}),!0}catch(Re){throw d.value=Ce,u.value=Re instanceof Error?Re.message:"Failed to detach media",new Error(u.value)}finally{c.value=!1}}async function M(be,Ee,ye,xe="images"){c.value=!0,u.value=null;const Ce=[...d.value],Re=new Map(d.value.map(ze=>[ze.uuid,ze]));d.value=ye.map(ze=>Re.get(ze)).filter(ze=>ze!==void 0);try{return await g()(b(`/media/model/${be}/${Ee}/reorder`),{method:"POST",body:{media_uuids:ye,collection:xe}}),!0}catch(ze){throw d.value=Ce,u.value=ze instanceof Error?ze.message:"Failed to reorder media",new Error(u.value)}finally{c.value=!1}}async function Z(be,Ee,ye={}){var lt,Ct;const xe=g(),Ce=ba.apiBaseUrl||"/api/v1";let Re=ic(Ee.documentId)?Ee.documentId:ic((lt=Ee.document)==null?void 0:lt.id)?Ee.document.id:null,ze=Ee.documentRevisionId??null,rt=typeof Ee.documentRevisionNumber=="number"?Ee.documentRevisionNumber:typeof((Ct=Ee.document)==null?void 0:Ct.revision)=="number"?Ee.document.revision:null;if(Ee.document){const Se=await xe(`${Ce}/media/${be}/editor-documents/materialize`,{method:"POST",body:{document_id:Re,base_document_revision:rt,document:Ee.document}});Re=Se.document_id,ze=Se.document_revision_id,rt=Se.document_revision_number}if(Ee.document&&Re&&ze&&typeof rt=="number"){const Se=new FormData,oe=(Ee.mimeType||Ee.blob.type||"image/png")==="image/jpeg"?"jpg":"png";Se.append("flattened_file",Ee.blob,`edited.${oe}`),Se.append("document_id",Re),Se.append("document_revision_id",ze),Se.append("expected_document_revision",String(rt)),Se.append("output_mode",ye.asVariant?"save-as-variant":"save-as-new");const De=await xe(`${Ce}/media/${be}/editor-documents/save`,{method:"POST",body:Se});if(De.media)return De.media;throw new Error("Unexpected response from layered editor save endpoint")}const at=new FormData,ht=(Ee.mimeType||Ee.blob.type||"image/png")==="image/jpeg"?"jpg":"png";at.append("image_file",Ee.blob,`edited.${ht}`);const St=Zu(Ee.state);St&&at.append("editor_state",St),at.append("save_as_new","true"),ye.asVariant&&at.append("as_variant","true"),ye.name!==void 0&&at.append("name",ye.name);const ut=await xe(`${Ce}/editor/${be}/save`,{method:"POST",body:at});if("media"in ut&&ut.media)return ut.media;if("status_url"in ut&&ut.status_url)return O(xe,kh(ut.status_url,Ce),ye.pollTimeout??6e4);throw new Error("Unexpected response from editor save endpoint")}async function O(be,Ee,ye){const xe=Date.now(),Ce=2e3;for(;Date.now()-xe<ye;){await new Promise(ze=>setTimeout(ze,Ce));const Re=await be(Ee);if(Re.status==="completed"&&Re.media)return Re.media;if(Re.status==="failed")throw new Error(Re.error??"Image processing failed")}throw new Error("Image processing timed out")}function K(be,Ee,ye){s.value=ye!==void 0?{type:be,uuid:Ee,collection:ye}:{type:be,uuid:Ee},v.value[`${be}-${Ee}`]={timestamp:Date.now()}}function de(){s.value={type:null,uuid:null},d.value=[],u.value=null}async function Ne(){if(!s.value.type||!s.value.uuid)return;const be=await P(s.value.type,s.value.uuid,s.value.collection||"images");d.value=be||[]}function ce(){o.value.forEach(be=>f.value.add(be.uuid))}function le(){f.value.clear()}function W(be){f.value.has(be)?f.value.delete(be):f.value.add(be)}function C(be){return f.value.has(be)}function U(){return Array.from(m.value.values()).some(be=>be.status==="uploading")}function j(be){return m.value.get(be)||p.value.get(be)}function re(){return[...Array.from(m.value.values()),...Array.from(p.value.values())]}async function ue(){const be=Array.from(f.value);let Ee=0;for(const ye of be)try{await B(ye),Ee++}catch{}return le(),Ee}function Xe(be,Ee){var ye;return Ee&&((ye=be.conversion_urls)!=null&&ye[Ee])?be.conversion_urls[Ee]||"":be.original_url||be.url||""}return{items:o,collections:a,loading:t,error:n,currentPage:i,totalPages:r,itemsPerPage:l,isAdmin:w,modelContext:s,modelMedia:d,isLoadingModelMedia:c,modelMediaError:u,selectedItems:f,uploadProgress:m,uploadQueue:p,cachedResponses:v,fetchMedia:$,uploadFile:S,deleteMedia:B,updateMedia:_,clearCache:x,fetchCollections:A,fetchModelMedia:P,attachMedia:D,detachMedia:z,reorderMedia:M,saveEditedImage:Z,setModelContext:K,clearModelContext:de,refreshModelMedia:Ne,selectAllItems:ce,clearSelection:le,toggleSelection:W,isSelected:C,deleteSelectedItems:ue,getHttpClient:g,getApiUrl:b,getEditorApiUrl:R,hasActiveUploads:U,getUploadProgress:j,getAllUploadProgress:re,getMediaUrl:Xe}}),Ju=()=>((ba.apiScope!=="admin"||ba.isAdmin!==!0)&&$o({...ba,apiScope:"admin",isAdmin:!0}),xa());class qu{constructor(a,t){this.state=a,this.editor=t,this.element=null,this._tabs=new Map,this._unsubscribers=[],this._onSelect=null}render({onSelect:a}={}){return this._onSelect=a,this.element=te.el("div",{className:"panel-tabs",role:"tablist","aria-label":"Filter categories","data-testid":"v2-category-tabs"}),te.EDITOR_CATEGORIES.forEach(t=>{const n=te.el("button",{type:"button",className:`panel-tab ${this._isSelected(t.id)?"active":""}`,role:"tab","aria-selected":this._isSelected(t.id)?"true":"false","data-category":t.id,"data-testid":`v2-category-${t.id}`,onClick:()=>this._selectCategory(t.id)});if(t.icon){const i=te.el("span",{className:"panel-tab-icon","aria-hidden":"true"});i.innerHTML=t.icon,n.appendChild(i)}n.appendChild(te.el("span",{className:"panel-tab-label"},t.name)),this._tabs.set(t.id,n),this.element.appendChild(n)}),this._unsubscribers.push(this.state.on("change:selectedCategory",()=>this._refreshActive())),this.element}_isSelected(a){const t=this.state.get("selectedCategory");return a==="crop"?this.state.get("mode")==="crop":t===a&&this.state.get("mode")!=="crop"}_selectCategory(a){var n;this.state.set("selectedCategory",a);const t=this.state.get("mode");a==="crop"?t!=="crop"&&this.editor.setMode("crop"):t!=="filters"&&this.editor.setMode("filters"),this._refreshActive(),(n=this._onSelect)==null||n.call(this,a)}_refreshActive(){this._tabs.forEach((a,t)=>{const n=this._isSelected(t);a.classList.toggle("active",n),a.setAttribute("aria-selected",n?"true":"false")})}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],this._tabs.clear(),(a=this.element)==null||a.remove(),this.element=null}}class Yu{constructor(a,t){this.state=a,this.filterManager=t,this.element=null,this._unsubscribers=[],this._onToggle=null,this._onSelect=null}render({onToggle:a,onSelect:t}={}){return this._onToggle=a,this._onSelect=t,this.element=te.el("div",{className:"filter-list",role:"listbox","aria-label":"Filters","data-testid":"v2-filter-list"}),this._renderRows(),this._unsubscribers.push(this.state.on("change:selectedCategory",()=>this._renderRows()),this.state.on("change:activeFilters",()=>this._renderRows()),this.state.on("change:selectedFilter",()=>this._renderRows()),this.state.on("change:filterValues",()=>this._refreshSummaries())),this.element}_renderRows(){this.element.innerHTML="";const a=this.state.get("selectedCategory");if(!a||a==="crop")return;const t=this.filterManager.getFiltersByCategory(a),n=this.state.get("activeFilters"),i=this.state.get("selectedFilter"),r=typeof this.state.getActiveFilterLayerId=="function"?this.state.getActiveFilterLayerId():this.state.get("activeLayerId");t.forEach(l=>{var c;const s=((c=n==null?void 0:n.has)==null?void 0:c.call(n,l.id))??!1,d=i===l.id;this.element.appendChild(this._renderRow(l,s,d,r))})}_renderRow(a,t,n,i=null){const r=te.el("button",{type:"button",className:`filter-row ${n?"selected":""}`,role:"option","aria-selected":n?"true":"false","data-filter":a.id,"data-testid":`v2-filter-${a.id}`,onClick:()=>{var u;return(u=this._onSelect)==null?void 0:u.call(this,a.id,i)}}),l=te.el("button",{type:"button",className:`filter-row-toggle ${t?"active":""}`,"aria-label":`${t?"Disable":"Enable"} ${a.name}`,"aria-pressed":t?"true":"false","data-testid":`v2-filter-toggle-${a.id}`,onClick:u=>{var p,f,h,v;u.stopPropagation();const m=!((f=(p=this.state.get("activeFilters"))==null?void 0:p.has)!=null&&f.call(p,a.id));(h=this._onToggle)==null||h.call(this,a.id,m,i),m&&((v=this._onSelect)==null||v.call(this,a.id,i))}});t&&(l.innerHTML=te.checkmark),r.appendChild(l);const s=te.el("div",{className:"filter-row-body"});s.appendChild(te.el("span",{className:"filter-row-name"},a.name));const d=this._buildSummary(a,t);d&&s.appendChild(te.el("span",{className:"filter-row-summary"},d)),r.appendChild(s);const c=te.el("span",{className:"filter-row-chevron","aria-hidden":"true"});return c.innerHTML=te.chevronRight,r.appendChild(c),r}_buildSummary(a,t){if(!t)return a.description||"";const n=this.state.getFilterValues(a.id);if(!n||Object.keys(n).length===0)return a.description||"Active";const i=[];for(const r of(a.controls||[]).slice(0,4)){const l=n[r.id];if(!(l===void 0||l===r.default)&&(i.push(this._formatControlValue(r,l)),i.length>=2))break}return i.length===0?"Active":i.join(" · ")}_formatControlValue(a,t){return a.type==="toggle"?a.label:typeof t=="number"?(a.max??1)<=1&&(a.min??0)>=0?`${a.label} ${Math.round(t*100)}%`:Number.isInteger(t)?`${a.label} ${t}`:`${a.label} ${t.toFixed(2)}`:typeof t=="string"?`${a.label}`:a.label}_refreshSummaries(){var i;const a=this.state.get("selectedCategory");if(!a||a==="crop")return;const t=this.filterManager.getFiltersByCategory(a),n=this.state.get("activeFilters");for(const r of t){const l=this.element.querySelector(`[data-filter="${r.id}"]`);if(!l)continue;const s=((i=n==null?void 0:n.has)==null?void 0:i.call(n,r.id))??!1,d=this._buildSummary(r,s),c=l.querySelector(".filter-row-summary");if(d&&c)c.textContent=d;else if(d&&!c){const u=l.querySelector(".filter-row-body");u==null||u.appendChild(te.el("span",{className:"filter-row-summary"},d))}else!d&&c&&c.remove()}}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(a=this.element)==null||a.remove(),this.element=null}}class Qu{constructor(a,t){this.state=a,this.filterManager=t,this.element=null,this._unsubscribers=[],this._onChange=null,this._onReset=null,this._onAction=null}render({onChange:a,onReset:t,onAction:n}={}){return this._onChange=a,this._onReset=t,this._onAction=n,this.element=te.el("div",{className:"controls-section","data-testid":"v2-controls-section"}),this._renderControls(),this._unsubscribers.push(this.state.on("change:selectedFilter",()=>this._renderControls()),this.state.on("change:activeFilters",()=>this._renderControls())),this.element}_renderControls(){this.element.innerHTML="";const a=this.state.get("selectedFilter");if(!a){this.element.appendChild(te.el("div",{className:"no-filter-selected"},"Select a filter to adjust"));return}const t=typeof this.state.getActiveFilterLayerId=="function"?this.state.getActiveFilterLayerId():this.state.get("activeLayerId"),n=this.filterManager.getFilterDef(a);if(!n){this.element.appendChild(te.el("div",{className:"no-filter-selected"},"Filter not found"));return}const i=te.el("div",{className:"controls-header"});i.appendChild(te.el("span",{className:"controls-title"},n.name)),i.appendChild(te.createButton({label:"Reset",className:"btn-text",onClick:()=>this._handleReset(a,t)})),this.element.appendChild(i);const r=te.el("div",{className:"controls-grid"}),l=this.state.getFilterValues(a);(n.controls||[]).forEach(d=>{if(d.hidden)return;const c=this._createControl(a,d,l[d.id]??d.default,t);c&&r.appendChild(c)});const s=this.filterManager.getInstance(a);if(s&&typeof s.getDynamicControls=="function"){let d=[];try{d=s.getDynamicControls()||[]}catch{}d.forEach(c=>{const u=c.property||c.id,m=l[u]??c.default,p=this._createControl(a,c,m,t);p&&r.appendChild(p)})}this.element.appendChild(r)}_createControl(a,t,n,i=null){if(t.hidden)return null;const r=t.label||t.id,l=this._normalizeControlType(t.type),s=t.property||t.id;switch(l){case"slider":return te.createSlider({id:`v2-${a}-${t.id}`,label:r,min:t.min??0,max:t.max??1,step:t.step??.01,value:typeof n=="number"?n:t.default??0,onChange:d=>{var c;return(c=this._onChange)==null?void 0:c.call(this,a,s,d,i)}});case"toggle":return te.createToggle({id:`v2-${a}-${t.id}`,label:r,checked:!!n,onChange:d=>{var c;return(c=this._onChange)==null?void 0:c.call(this,a,s,d,i)}});case"color":return te.createColorPicker({id:`v2-${a}-${t.id}`,label:r,value:typeof n=="string"&&n.startsWith("#")?n:t.default||"#000000",onChange:d=>{var c;return(c=this._onChange)==null?void 0:c.call(this,a,s,d,i)}});case"select":{const d=(t.options||[]).map(c=>typeof c=="object"&&c.value!==void 0?{value:c.value,label:c.label||String(c.value)}:{value:c,label:String(c)});return te.createSelect({id:`v2-${a}-${t.id}`,label:r,options:d,value:n??t.default,onChange:c=>{var u;return(u=this._onChange)==null?void 0:u.call(this,a,s,c,i)}})}case"text":return te.createTextInput({id:`v2-${a}-${t.id}`,label:r,value:typeof n=="string"?n:t.default??"",placeholder:t.placeholder||"",onCommit:d=>{var c;return(c=this._onChange)==null?void 0:c.call(this,a,s,d,i)}});case"button":{const d=te.el("div",{className:"button-control"});return d.appendChild(te.createButton({label:r,className:"btn-secondary",onClick:()=>{var c;(c=this._onAction)==null||c.call(this,a,t.action||t.id,i),this._renderControls()}})),d}default:return null}}_normalizeControlType(a){return{slider:"slider",range:"slider",toggle:"toggle",checkbox:"toggle",color:"color",select:"select",dropdown:"select",button:"button",text:"text"}[a]||a}_handleReset(a,t=null){var n;(n=this._onReset)==null||n.call(this,a,t),this._renderControls()}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(a=this.element)==null||a.remove(),this.element=null}}class Eh{constructor(a,t){this.state=a,this.filterManager=t,this.element=null,this._unsubscribers=[],this._onRemove=null,this._onSelect=null,this._onClearAll=null}render({onRemove:a,onSelect:t,onClearAll:n}={}){return this._onRemove=a,this._onSelect=t,this._onClearAll=n,this.element=te.el("div",{className:"panel-section","data-testid":"v2-active-stack"}),this._renderContents(),this._unsubscribers.push(this.state.on("change:activeFilters",()=>this._renderContents()),this.state.on("change:selectedFilter",()=>this._refreshSelection())),this.element}_renderContents(){this.element.innerHTML="";const a=this.state.get("activeFilters"),t=(a==null?void 0:a.size)??0,n=this._activeFilterLayerId(),i=te.el("div",{className:"panel-section-title"});if(i.appendChild(te.el("span",{},`Active (${t})`)),t>0&&this._onClearAll&&i.appendChild(te.el("button",{type:"button",className:"btn btn-text",style:{padding:"2px 8px",fontSize:"11px"},"data-testid":"v2-clear-all",onClick:()=>{var s;return(s=this._onClearAll)==null?void 0:s.call(this,n)}},"Clear all")),this.element.appendChild(i),t===0){this.element.appendChild(te.el("div",{className:"active-empty"},"No filters applied"));return}const r=te.el("div",{className:"active-stack"}),l=this.state.get("selectedFilter");for(const s of a){const d=this.filterManager.getFilterDef(s);d&&r.appendChild(this._renderChip(d,s===l,n))}this.element.appendChild(r)}_renderChip(a,t,n=null){const i=te.el("div",{className:`active-chip ${t?"selected":""}`,"data-filter":a.id,"data-testid":`v2-active-${a.id}`});i.appendChild(te.el("button",{type:"button",className:"active-chip-name","aria-label":`Select ${a.name}`,onClick:()=>{var l;return(l=this._onSelect)==null?void 0:l.call(this,a.id,n)}},a.name));const r=te.el("button",{type:"button",className:"active-chip-remove","aria-label":`Remove ${a.name}`,"data-testid":`v2-active-remove-${a.id}`,onClick:()=>{var l;return(l=this._onRemove)==null?void 0:l.call(this,a.id,n)}});return r.innerHTML=te.close,i.appendChild(r),i}_activeFilterLayerId(){return typeof this.state.getActiveFilterLayerId=="function"?this.state.getActiveFilterLayerId():this.state.get("activeLayerId")}_refreshSelection(){var n;const a=this.state.get("selectedFilter"),t=(n=this.element)==null?void 0:n.querySelectorAll(".active-chip");t&&t.forEach(i=>{const r=i.getAttribute("data-filter");i.classList.toggle("selected",r===a)})}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(a=this.element)==null||a.remove(),this.element=null}}const So=["collapsed","half","full"];class Sh{constructor(a={}){this._onSnapChange=a.onSnapChange||null,this._ariaLabel=a.ariaLabel||"Filter controls drawer",this.element=null,this._handle=null,this._body=null,this._headerSlot=null,this._snap="half",this._dragging=!1,this._dragStartY=0,this._dragStartHeight=0,this._dragPointerId=null,this._containerHeight=0}build({header:a,body:t}={}){this.element=te.el("div",{className:"editor-v2-drawer",role:"dialog","aria-label":this._ariaLabel,"data-testid":"v2-bottom-drawer","data-snap":this._snap}),this._handle=te.el("button",{type:"button",className:"drawer-handle","aria-label":"Drag to resize filters drawer","aria-expanded":this._snap==="full"?"true":"false","data-testid":"v2-drawer-handle"});const n=te.el("span",{className:"drawer-handle-grip","aria-hidden":"true"});return this._handle.appendChild(n),this._handle.addEventListener("click",i=>{if(this._wasDragging){this._wasDragging=!1,i.preventDefault();return}this._cycleSnap()}),this._handle.addEventListener("pointerdown",i=>this._onPointerDown(i)),this._handle.addEventListener("pointermove",i=>this._onPointerMove(i)),this._handle.addEventListener("pointerup",i=>this._onPointerEnd(i)),this._handle.addEventListener("pointercancel",i=>this._onPointerEnd(i)),this.element.appendChild(this._handle),this._headerSlot=te.el("div",{className:"drawer-header"}),a&&this._headerSlot.appendChild(a),this.element.appendChild(this._headerSlot),this._body=te.el("div",{className:"drawer-body"}),t&&this._body.appendChild(t),this.element.appendChild(this._body),this.element}updateContainerHeight(a){this._containerHeight=Math.max(0,Number(a)||0),this._applySnap(this._snap,{animate:!1})}snapTo(a,t={}){So.includes(a)&&this._applySnap(a,{animate:t.animate!==!1})}get snap(){return this._snap}setBodyContent(a){this._body&&(this._body.innerHTML="",a&&this._body.appendChild(a))}setHeaderContent(a){this._headerSlot&&(this._headerSlot.innerHTML="",a&&this._headerSlot.appendChild(a))}_onPointerDown(a){var t,n,i;if(!(a.button!==void 0&&a.button!==0)){this._dragging=!0,this._wasDragging=!1,this._dragPointerId=a.pointerId,this._dragStartY=a.clientY,this._dragStartHeight=((t=this.element)==null?void 0:t.offsetHeight)||0;try{(i=(n=this._handle)==null?void 0:n.setPointerCapture)==null||i.call(n,a.pointerId)}catch{}this.element&&(this.element.style.transition="none")}}_onPointerMove(a){if(!this._dragging||a.pointerId!==this._dragPointerId)return;const t=a.clientY-this._dragStartY,n=this._dragStartHeight-t;this._containerHeight||window.innerHeight;const i=this._heightForSnap("collapsed"),r=this._heightForSnap("full"),l=Math.max(i,Math.min(r,n));this.element&&(this.element.style.height=`${l}px`),Math.abs(t)>4&&(this._wasDragging=!0),a.preventDefault()}_onPointerEnd(a){var i,r,l;if(!this._dragging)return;this._dragging=!1;try{(r=(i=this._handle)==null?void 0:i.releasePointerCapture)==null||r.call(i,a.pointerId)}catch{}this._dragPointerId=null;const t=((l=this.element)==null?void 0:l.offsetHeight)||0,n=this._nearestSnap(t);this._applySnap(n,{animate:!0})}_cycleSnap(){const a=So.indexOf(this._snap),t=So[(a+1)%So.length];this._applySnap(t,{animate:!0})}_heightForSnap(a){const t=this._containerHeight||window.innerHeight||600;switch(a){case"collapsed":return 80;case"half":return Math.round(t*.45);case"full":return Math.round(t*.85);default:return Math.round(t*.45)}}_nearestSnap(a){let t=So[0],n=1/0;for(const i of So){const r=this._heightForSnap(i),l=Math.abs(r-a);l<n&&(n=l,t=i)}return t}_applySnap(a,{animate:t}){var r,l;if(!this.element)return;const n=this._snap;this._snap=a;const i=typeof window<"u"&&((r=window.matchMedia)==null?void 0:r.call(window,"(prefers-reduced-motion: reduce)").matches);t&&!i?this.element.style.transition="height 0.25s cubic-bezier(0.33, 1, 0.68, 1)":this.element.style.transition="none",this.element.style.height=`${this._heightForSnap(a)}px`,this.element.dataset.snap=a,this._handle&&this._handle.setAttribute("aria-expanded",a==="full"?"true":"false"),a!==n&&((l=this._onSnapChange)==null||l.call(this,a,n))}destroy(){var a;(a=this.element)==null||a.remove(),this.element=null,this._handle=null,this._body=null,this._headerSlot=null}}const Ch=[{id:"warm",label:"Warm",ariaLabel:"Apply warm gradient background",style:"linear-gradient(135deg, #101820 0%, #f2aa4c 100%)",fill:{gradientType:"linear",angle:135,stops:[{offset:0,color:"#101820"},{offset:1,color:"#f2aa4c"}]}},{id:"cool",label:"Cool",ariaLabel:"Apply cool gradient background",style:"linear-gradient(135deg, #0f766e 0%, #38bdf8 100%)",fill:{gradientType:"linear",angle:135,stops:[{offset:0,color:"#0f766e"},{offset:1,color:"#38bdf8"}]}},{id:"neutral",label:"Neutral",ariaLabel:"Apply neutral gradient background",style:"linear-gradient(135deg, #27272a 0%, #d4d4d8 100%)",fill:{gradientType:"linear",angle:135,stops:[{offset:0,color:"#27272a"},{offset:1,color:"#d4d4d8"}]}}];class em{constructor(a,t){this.state=a,this.editor=t,this.element=null,this._errorMessage=null,this._unsubscribers=[]}render(){return this.element=te.el("div",{className:"background-panel","data-testid":"v2-background-panel"}),this._render(),this._unsubscribers.push(this.state.on("change:layers",()=>this._render())),this.element}_render(){var f,h,v;if(!this.element)return;this.element.innerHTML="";const a=this._backgroundLayer(),t=a!=null&&a.fill&&typeof a.fill=="object"?a.fill:{kind:"transparent"},n=typeof t.fit=="string"?t.fit:"cover",i=this._backgroundBlur(a),r=(a==null?void 0:a.locked)===!0,l=t.kind==="color"&&typeof t.value=="string"?t.value:"#ffffff";this.element.appendChild(te.el("div",{className:"panel-section-title"},te.el("span",{},"Background"))),this._errorMessage&&this.element.appendChild(te.el("p",{className:"background-panel-error",role:"alert","data-testid":"v2-background-error"},this._errorMessage));const s=te.el("input",{type:"color",className:"color-input",value:l,disabled:r?"disabled":void 0,"aria-label":"Background color","data-testid":"v2-background-color",onInput:k=>{this._runAction(this.editor.setBackgroundColor(k.target.value))}});this.element.appendChild(this._field("Color",s));const d=te.el("div",{className:"background-gradient-grid"});for(const k of Ch){const y=te.el("button",{type:"button",className:"background-gradient-swatch",style:{background:k.style},"aria-label":k.ariaLabel,disabled:r?"disabled":void 0,"data-testid":`v2-background-gradient-${k.id}`,onClick:()=>{this._runAction(this.editor.setBackgroundGradient(k.fill))}},te.el("span",{className:"background-gradient-label"},k.label));d.appendChild(y)}this.element.appendChild(this._field("Gradient",d));const c=te.el("input",{type:"file",accept:"image/*",className:"background-upload-input",disabled:r?"disabled":void 0,"aria-label":"Upload background image","data-testid":"v2-background-upload",onChange:k=>{var w;const y=(w=k.target.files)==null?void 0:w[0];y&&this._runAction(this.editor.setBackgroundImageFromFile(y,{fit:n})),k.target.value=""}});this.element.appendChild(this._field("Upload",c));const u=(v=(h=(f=this.editor)==null?void 0:f._options)==null?void 0:h.backgroundReplacement)==null?void 0:v.mediaChoices;if(Array.isArray(u)&&u.length>0){const k=te.el("div",{className:"background-media-grid"});for(const y of u)y!=null&&y.source&&k.appendChild(te.el("button",{type:"button",className:"background-media-choice","aria-label":`Use ${y.label||"media"} as background`,disabled:r?"disabled":void 0,"data-testid":`v2-background-media-${y.id||y.source.mediaUuid||"choice"}`,onClick:()=>{this._runAction(this.editor.setBackgroundMediaSource(y.source,{fit:y.fit||n}))}},y.label||"Media"));this.element.appendChild(this._field("Media",k))}const m=te.el("select",{className:"select-input",disabled:r?"disabled":void 0,"aria-label":"Background image fit","data-testid":"v2-background-fit",onChange:k=>{this._runAction(this.editor.setBackgroundFit(k.target.value))}},this._option("cover","Cover",n),this._option("contain","Contain",n),this._option("stretch","Stretch",n),this._option("tile","Tile",n));this.element.appendChild(this._field("Fit",m));const p=te.el("input",{type:"range",min:"0",max:"40",step:"1",value:String(i),className:"range-input",disabled:r?"disabled":void 0,"aria-label":"Background blur","data-testid":"v2-background-blur",onInput:k=>{this._runAction(this.editor.setBackgroundBlur(Number(k.target.value)))}});this.element.appendChild(this._field("Blur",p)),this.element.appendChild(te.el("button",{type:"button",className:"btn btn-secondary background-remove-btn","aria-label":"Remove background layer",disabled:r?"disabled":void 0,"data-testid":"v2-background-remove",onClick:()=>{this._runAction(this.editor.removeBackgroundLayer())}},"Remove"))}_runAction(a){this._errorMessage=null,Promise.resolve(a).catch(t=>{var i,r;const n=t instanceof Error?t:new Error(String(t));this._errorMessage=n.message||"Background update failed",(r=(i=this.editor)==null?void 0:i.emit)==null||r.call(i,"error",n),this._render()})}_field(a,t){return te.el("label",{className:"background-field"},te.el("span",{className:"background-field-label"},a),t)}_option(a,t,n){return te.el("option",{value:a,selected:n===a?"selected":void 0},t)}_backgroundLayer(){const a=this.state.get("layers");return Array.isArray(a)?a.find(t=>(t==null?void 0:t.type)==="background"||(t==null?void 0:t.role)==="background")??null:null}_backgroundBlur(a){var r;const n=(Array.isArray(a==null?void 0:a.effects)?a.effects:[]).find(l=>(l==null?void 0:l.id)==="background-blur"),i=Number((r=n==null?void 0:n.params)==null?void 0:r.amount);return Number.isFinite(i)?i:0}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(a=this.element)==null||a.remove(),this.element=null}}class tm{constructor(a,t){this.state=a,this.editor=t,this.element=null,this._listEl=null,this._unsubscribers=[]}render(){return this.element=te.el("section",{className:"layer-stack-panel",role:"region","aria-label":"Layers","data-order":"bottom-to-top","data-testid":"v2-layer-stack-panel"}),this.element.appendChild(te.el("div",{className:"layer-stack-header"},te.el("span",{className:"layer-stack-title"},"Layers"),te.el("span",{className:"layer-stack-order"},"Bottom to top"))),this._listEl=te.el("div",{className:"layer-stack-list",role:"listbox","aria-label":"Layer order, bottom to top"}),this.element.appendChild(this._listEl),this._renderRows(),this._unsubscribers.push(this.state.on("change:layers",()=>this._renderRows()),this.state.on("change:activeLayerId",()=>this._renderRows())),this.element}_layers(){const a=this.state.get("layers");return Array.isArray(a)?a:[]}_renderRows(){if(!this._listEl)return;this._listEl.innerHTML="";const a=this._layers();if(!a.length){this._listEl.appendChild(te.el("div",{className:"layer-stack-empty",role:"status"},"No layers"));return}a.forEach((t,n)=>{this._listEl.appendChild(this._row(t,n,a.length))})}_row(a,t,n){const i=String((a==null?void 0:a.id)??""),r=this._layerName(a),l=(a==null?void 0:a.visible)!==!1,s=(a==null?void 0:a.locked)===!0,d=this.state.get("activeLayerId")===i,c=[d?"active":null,l?"visible":"hidden",s?"locked":"unlocked"].filter(Boolean).join(", "),u=te.el("div",{className:`layer-row${d?" active":""}${l?"":" hidden"}${s?" locked":""}`,role:"option","aria-selected":d?"true":"false","aria-label":`${r}, ${this._layerTypeLabel(a)}, ${c}`,"data-layer-id":i,"data-testid":`v2-layer-row-${i}`});u.appendChild(this._button({testId:`v2-layer-select-${i}`,label:`Select ${r}`,className:"layer-row-select",onClick:()=>this._runAction(()=>{var p,f;return(f=(p=this.editor).selectLayer)==null?void 0:f.call(p,i)})},this._thumbnail(a))),u.appendChild(te.el("div",{className:"layer-row-main"},te.el("span",{className:"layer-row-name"},r),te.el("span",{className:"layer-row-meta"},this._layerTypeLabel(a))));const m=te.el("div",{className:"layer-row-actions"});return m.appendChild(this._iconButton({testId:`v2-layer-${l?"hide":"show"}-${i}`,label:`${l?"Hide":"Show"} ${r}`,icon:l?te.eye:te.eyeOff,disabled:s,onClick:()=>this._runAction(()=>{var p,f;return(f=(p=this.editor).setLayerVisibility)==null?void 0:f.call(p,i,!l)})})),m.appendChild(this._iconButton({testId:`v2-layer-${s?"unlock":"lock"}-${i}`,label:`${s?"Unlock":"Lock"} ${r}`,icon:s?te.lockClosed:te.lockOpen,onClick:()=>this._runAction(()=>{var p,f;return(f=(p=this.editor).setLayerLocked)==null?void 0:f.call(p,i,!s)})})),m.appendChild(this._iconButton({testId:`v2-layer-move-up-${i}`,label:`Move ${r} up`,icon:te.chevronRight,disabled:s,onClick:()=>this._runAction(()=>{var p,f;return(f=(p=this.editor).moveLayer)==null?void 0:f.call(p,i,"up")})})),m.appendChild(this._iconButton({testId:`v2-layer-move-down-${i}`,label:`Move ${r} down`,icon:te.chevronLeft,disabled:s,onClick:()=>this._runAction(()=>{var p,f;return(f=(p=this.editor).moveLayer)==null?void 0:f.call(p,i,"down")})})),m.appendChild(this._iconButton({testId:`v2-layer-bring-front-${i}`,label:`Bring ${r} to front`,icon:te.chevronRight,disabled:s,onClick:()=>this._runAction(()=>{var p,f;return(f=(p=this.editor).moveLayer)==null?void 0:f.call(p,i,"front")})})),m.appendChild(this._iconButton({testId:`v2-layer-send-back-${i}`,label:`Send ${r} to back`,icon:te.chevronLeft,disabled:s,onClick:()=>this._runAction(()=>{var p,f;return(f=(p=this.editor).moveLayer)==null?void 0:f.call(p,i,"back")})})),m.appendChild(this._iconButton({testId:`v2-layer-rename-${i}`,label:`Rename ${r}`,icon:te.pencil,disabled:s,onClick:()=>this._renameLayer(i,r)})),m.appendChild(this._iconButton({testId:`v2-layer-duplicate-${i}`,label:`Duplicate ${r}`,icon:te.duplicate,disabled:s,onClick:()=>this._runAction(()=>{var p,f;return(f=(p=this.editor).duplicateLayer)==null?void 0:f.call(p,i)})})),m.appendChild(this._iconButton({testId:`v2-layer-delete-${i}`,label:`Delete ${r}`,icon:te.trash,disabled:s||n<=1,onClick:()=>this._runAction(()=>{var p,f;return(f=(p=this.editor).deleteLayer)==null?void 0:f.call(p,i)})})),u.appendChild(m),u}_thumbnail(a){const t=te.el("span",{className:"layer-thumb","aria-hidden":"true"}),n=a==null?void 0:a.fill;if((n==null?void 0:n.kind)==="color")t.style.background=n.value||n.color||"#ffffff";else if((n==null?void 0:n.kind)==="gradient"&&Array.isArray(n.stops)){const i=n.stops.map(r=>`${r.color} ${Math.round(Number(r.offset||0)*100)}%`).join(", ");t.style.background=`linear-gradient(${Number(n.angle||135)}deg, ${i})`}else t.innerHTML=(a==null?void 0:a.type)==="background"?te.layers:te.move;return t}_button({testId:a,label:t,...n},i){const r=te.el("button",{type:"button","aria-label":t,"data-testid":a,...n});return i&&r.appendChild(i),r}_iconButton({testId:a,label:t,icon:n,disabled:i=!1,onClick:r}){const l=te.el("button",{type:"button",className:"layer-action-btn","aria-label":t,title:t,disabled:i?"disabled":void 0,"data-testid":a,onClick:r});return l.innerHTML=n,l}_renameLayer(a,t){var i;const n=(i=window.prompt)==null?void 0:i.call(window,"Layer name",t);typeof n=="string"&&this._runAction(()=>{var r,l;return(l=(r=this.editor).renameLayer)==null?void 0:l.call(r,a,n)})}_runAction(a){var t,n;try{Promise.resolve(a()).catch(i=>{var r,l;return(l=(r=this.editor).emit)==null?void 0:l.call(r,"error",{error:i,context:"layer-stack"})})}catch(i){(n=(t=this.editor).emit)==null||n.call(t,"error",{error:i,context:"layer-stack"})}}_layerName(a){return(typeof(a==null?void 0:a.name)=="string"?a.name.trim():"")||"Layer"}_layerTypeLabel(a){return(a==null?void 0:a.type)==="background"||(a==null?void 0:a.role)==="background"?"Background":(a==null?void 0:a.role)==="subject"?"Subject":(a==null?void 0:a.type)==="text"?"Text":"Image"}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(a=this.element)==null||a.remove(),this.element=null,this._listEl=null}}const xh=[{value:"400",label:"Regular"},{value:"500",label:"Medium"},{value:"600",label:"Semibold"},{value:"700",label:"Bold"},{value:"800",label:"Heavy"}],Nh=[{value:"left",label:"Left"},{value:"center",label:"Center"},{value:"right",label:"Right"}],Vh=[{value:"normal",label:"Normal"},{value:"multiply",label:"Multiply"},{value:"screen",label:"Screen"},{value:"overlay",label:"Overlay"}],ir={stroke:{enabled:!1,color:"#000000",width:0},shadow:{enabled:!1,color:"#000000",alpha:.5,blur:0,distance:0,angle:45},glow:{enabled:!1,color:"#ffffff",alpha:.5,blur:0},backdrop:{enabled:!1,color:"#000000",opacity:.5,padding:0,radius:0,blur:0}};class am{constructor(a,t){this.state=a,this.editor=t,this.element=null,this._errorMessage=null,this._unsubscribers=[]}render(){return this.element=te.el("div",{className:"text-panel","data-testid":"v2-text-panel"}),this._render(),this._unsubscribers.push(this.state.on("change:layers",()=>this._render()),this.state.on("change:activeLayerId",()=>this._render())),this.element}_render(){if(!this.element)return;this.element.innerHTML="";const a=this._activeTextLayer(),t=(a==null?void 0:a.locked)===!0;if(this.element.appendChild(te.el("div",{className:"text-panel-header"},te.el("div",{className:"panel-section-title"},te.el("span",{},"Text")),te.el("button",{type:"button",className:"btn btn-secondary","data-testid":"v2-text-add",onClick:()=>{var d,c;return this._runAction((c=(d=this.editor).addTextLayer)==null?void 0:c.call(d))}},"Add text"))),this._errorMessage&&this.element.appendChild(te.el("p",{className:"text-panel-error",role:"alert","data-testid":"v2-text-error"},this._errorMessage)),!a){this.element.appendChild(te.el("p",{className:"text-panel-empty"},"Select or add a text layer."));return}const n=a.text&&typeof a.text=="object"?a.text:{},i=n.style&&typeof n.style=="object"?n.style:{},r=n.box&&typeof n.box=="object"?n.box:{},l=a.transform&&typeof a.transform=="object"?a.transform:{},s=this._textEffects(n.effects);this.element.appendChild(this._contentControl(a.id,n.content??"",t)),this.element.appendChild(this._controlGrid([this._numberField({label:"Opacity",testId:"v2-text-opacity",value:a.opacity??1,min:0,max:1,step:.05,disabled:t,onInput:d=>{var c,u;return this._runAction((u=(c=this.editor).updateTextLayer)==null?void 0:u.call(c,a.id,{opacity:d}))}}),this._selectField({label:"Blend",testId:"v2-text-blend-mode",value:a.blendMode||"normal",options:Vh,disabled:t,onChange:d=>{var c,u;return this._runAction((u=(c=this.editor).updateTextLayer)==null?void 0:u.call(c,a.id,{blendMode:d}))}})])),this.element.appendChild(this._selectField({label:"Font",testId:"v2-text-font-family",value:i.fontFamily||"Inter",options:te.TEXT_LAYER_FONT_FAMILIES.map(d=>({value:d,label:d})),disabled:t,onChange:d=>this._updateStyle(a.id,{fontFamily:d})})),this.element.appendChild(this._controlGrid([this._numberField({label:"Size",testId:"v2-text-font-size",value:i.fontSize??64,min:8,max:400,step:1,disabled:t,onInput:d=>this._updateStyle(a.id,{fontSize:d})}),this._selectField({label:"Weight",testId:"v2-text-font-weight",value:String(i.fontWeight??700),options:xh,disabled:t,onChange:d=>this._updateStyle(a.id,{fontWeight:Number(d)})}),this._selectField({label:"Style",testId:"v2-text-font-style",value:i.fontStyle||"normal",options:[{value:"normal",label:"Normal"},{value:"italic",label:"Italic"}],disabled:t,onChange:d=>this._updateStyle(a.id,{fontStyle:d})}),this._selectField({label:"Align",testId:"v2-text-align",value:i.align||"center",options:Nh,disabled:t,onChange:d=>this._updateStyle(a.id,{align:d})})])),this.element.appendChild(this._controlGrid([this._colorField({label:"Fill",testId:"v2-text-fill",value:i.fill||"#ffffff",disabled:t,onInput:d=>this._updateStyle(a.id,{fill:d})}),this._numberField({label:"Line",testId:"v2-text-line-height",value:i.lineHeight??1.2,min:.8,max:3,step:.05,disabled:t,onInput:d=>this._updateStyle(a.id,{lineHeight:d})}),this._numberField({label:"Track",testId:"v2-text-letter-spacing",value:i.letterSpacing??0,min:-100,max:100,step:.5,disabled:t,onInput:d=>this._updateStyle(a.id,{letterSpacing:d})})])),this.element.appendChild(this._controlGrid([this._numberField({label:"X",testId:"v2-text-box-x",value:r.x??.2,min:0,max:1,step:.01,disabled:t,onInput:d=>this._updateBox(a.id,{x:d})}),this._numberField({label:"Y",testId:"v2-text-box-y",value:r.y??.2,min:0,max:1,step:.01,disabled:t,onInput:d=>this._updateBox(a.id,{y:d})}),this._numberField({label:"W",testId:"v2-text-box-width",value:r.width??.6,min:.05,max:1,step:.01,disabled:t,onInput:d=>this._updateBox(a.id,{width:d})}),this._numberField({label:"H",testId:"v2-text-box-height",value:r.height??.18,min:.05,max:1,step:.01,disabled:t,onInput:d=>this._updateBox(a.id,{height:d})}),this._numberField({label:"Rotate",testId:"v2-text-rotation",value:l.rotation??0,min:0,max:360,step:1,disabled:t,onInput:d=>{var c,u;return this._runAction((u=(c=this.editor).updateTextLayer)==null?void 0:u.call(c,a.id,{transform:{rotation:d}}))}})])),this.element.appendChild(this._effectSection("Stroke",[this._checkboxField({label:"Stroke",testId:"v2-text-stroke-enabled",checked:s.stroke.enabled,disabled:t,onChange:d=>this._updateEffects(a.id,{stroke:{enabled:d}})}),this._colorField({label:"Stroke Color",testId:"v2-text-stroke-color",value:s.stroke.color,disabled:t,onInput:d=>this._updateEffects(a.id,{stroke:{color:d}})}),this._numberField({label:"Stroke Width",testId:"v2-text-stroke-width",value:s.stroke.width,min:0,max:80,step:1,disabled:t,onInput:d=>this._updateEffects(a.id,{stroke:{width:d}})})])),this.element.appendChild(this._effectSection("Shadow",[this._checkboxField({label:"Shadow",testId:"v2-text-shadow-enabled",checked:s.shadow.enabled,disabled:t,onChange:d=>this._updateEffects(a.id,{shadow:{enabled:d}})}),this._colorField({label:"Shadow Color",testId:"v2-text-shadow-color",value:s.shadow.color,disabled:t,onInput:d=>this._updateEffects(a.id,{shadow:{color:d}})}),this._numberField({label:"Shadow Alpha",testId:"v2-text-shadow-alpha",value:s.shadow.alpha,min:0,max:1,step:.05,disabled:t,onInput:d=>this._updateEffects(a.id,{shadow:{alpha:d}})}),this._numberField({label:"Shadow Blur",testId:"v2-text-shadow-blur",value:s.shadow.blur,min:0,max:120,step:1,disabled:t,onInput:d=>this._updateEffects(a.id,{shadow:{blur:d}})}),this._numberField({label:"Shadow Distance",testId:"v2-text-shadow-distance",value:s.shadow.distance,min:0,max:200,step:1,disabled:t,onInput:d=>this._updateEffects(a.id,{shadow:{distance:d}})}),this._numberField({label:"Shadow Angle",testId:"v2-text-shadow-angle",value:s.shadow.angle,min:0,max:360,step:1,disabled:t,onInput:d=>this._updateEffects(a.id,{shadow:{angle:d}})})])),this.element.appendChild(this._effectSection("Glow",[this._checkboxField({label:"Glow",testId:"v2-text-glow-enabled",checked:s.glow.enabled,disabled:t,onChange:d=>this._updateEffects(a.id,{glow:{enabled:d}})}),this._colorField({label:"Glow Color",testId:"v2-text-glow-color",value:s.glow.color,disabled:t,onInput:d=>this._updateEffects(a.id,{glow:{color:d}})}),this._numberField({label:"Glow Alpha",testId:"v2-text-glow-alpha",value:s.glow.alpha,min:0,max:1,step:.05,disabled:t,onInput:d=>this._updateEffects(a.id,{glow:{alpha:d}})}),this._numberField({label:"Glow Blur",testId:"v2-text-glow-blur",value:s.glow.blur,min:0,max:120,step:1,disabled:t,onInput:d=>this._updateEffects(a.id,{glow:{blur:d}})})])),this.element.appendChild(this._effectSection("Backdrop",[this._checkboxField({label:"Backdrop",testId:"v2-text-backdrop-enabled",checked:s.backdrop.enabled,disabled:t,onChange:d=>this._updateEffects(a.id,{backdrop:{enabled:d}})}),this._colorField({label:"Backdrop Color",testId:"v2-text-backdrop-color",value:s.backdrop.color,disabled:t,onInput:d=>this._updateEffects(a.id,{backdrop:{color:d}})}),this._numberField({label:"Backdrop Opacity",testId:"v2-text-backdrop-opacity",value:s.backdrop.opacity,min:0,max:1,step:.05,disabled:t,onInput:d=>this._updateEffects(a.id,{backdrop:{opacity:d}})}),this._numberField({label:"Backdrop Padding",testId:"v2-text-backdrop-padding",value:s.backdrop.padding,min:0,max:200,step:1,disabled:t,onInput:d=>this._updateEffects(a.id,{backdrop:{padding:d}})}),this._numberField({label:"Backdrop Radius",testId:"v2-text-backdrop-radius",value:s.backdrop.radius,min:0,max:200,step:1,disabled:t,onInput:d=>this._updateEffects(a.id,{backdrop:{radius:d}})}),this._numberField({label:"Backdrop Blur",testId:"v2-text-backdrop-blur",value:s.backdrop.blur,min:0,max:80,step:1,disabled:t,onInput:d=>this._updateEffects(a.id,{backdrop:{blur:d}})})]))}_contentControl(a,t,n){const i=te.el("div",{className:"text-field text-content-field"});i.appendChild(te.el("label",{className:"text-field-label",for:"v2-text-content"},"Content"));let r=t==null?"":String(t);const l=te.el("textarea",{id:"v2-text-content",className:"text-area-input",rows:"4",disabled:n?"disabled":void 0,"data-testid":"v2-text-content",onInput:d=>{r=d.target.value},onBlur:()=>{var d,c;r!==t&&this._runAction((c=(d=this.editor).updateTextLayer)==null?void 0:c.call(d,a,{content:r}))},onKeyDown:d=>{var c,u;if(d.key==="Escape"){d.preventDefault(),r=t==null?"":String(t),l.value=r,l.blur();return}d.key==="Enter"&&(d.metaKey||d.ctrlKey)&&(d.preventDefault(),this._runAction((u=(c=this.editor).updateTextLayer)==null?void 0:u.call(c,a,{content:r})),l.blur())}});l.value=r,i.appendChild(l);const s=te.el("div",{className:"text-content-actions"});return s.appendChild(te.el("button",{type:"button",className:"btn btn-text",disabled:n?"disabled":void 0,"data-testid":"v2-text-cancel",onClick:()=>{r=t==null?"":String(t),l.value=r}},"Cancel")),s.appendChild(te.el("button",{type:"button",className:"btn btn-secondary",disabled:n?"disabled":void 0,"data-testid":"v2-text-commit",onClick:()=>{var d,c;return this._runAction((c=(d=this.editor).updateTextLayer)==null?void 0:c.call(d,a,{content:r}))}},"Commit")),i.appendChild(s),i}_controlGrid(a){const t=te.el("div",{className:"text-control-grid"});for(const n of a)t.appendChild(n);return t}_effectSection(a,t){return te.el("div",{className:"text-effect-section"},te.el("div",{className:"text-effect-title"},a),this._controlGrid(t))}_selectField({label:a,testId:t,value:n,options:i,disabled:r,onChange:l}){const s=te.el("select",{className:"select-input",disabled:r?"disabled":void 0,"data-testid":t,onChange:d=>l(d.target.value)});for(const d of i)s.appendChild(te.el("option",{value:d.value,selected:String(n)===String(d.value)?"selected":void 0},d.label));return this._field(a,s)}_numberField({label:a,testId:t,value:n,min:i,max:r,step:l,disabled:s,onInput:d}){const c=te.el("input",{type:"number",className:"text-number-input",min:String(i),max:String(r),step:String(l),value:String(n),disabled:s?"disabled":void 0,"data-testid":t,onInput:u=>d(Number(u.target.value))});return this._field(a,c)}_colorField({label:a,testId:t,value:n,disabled:i,onInput:r}){const l=te.el("input",{type:"color",className:"color-input",value:n,disabled:i?"disabled":void 0,"data-testid":t,onInput:s=>r(s.target.value)});return this._field(a,l)}_checkboxField({label:a,testId:t,checked:n,disabled:i,onChange:r}){const l=te.el("input",{type:"checkbox",className:"text-checkbox-input",checked:n?"checked":void 0,disabled:i?"disabled":void 0,"data-testid":t,onChange:s=>r(s.target.checked===!0)});return te.el("label",{className:"text-field text-checkbox-field"},te.el("span",{className:"text-field-label"},a),l)}_field(a,t){return te.el("label",{className:"text-field"},te.el("span",{className:"text-field-label"},a),t)}_updateStyle(a,t){var n,i;this._runAction((i=(n=this.editor).updateTextLayer)==null?void 0:i.call(n,a,{style:t}))}_updateBox(a,t){var n,i;this._runAction((i=(n=this.editor).updateTextLayer)==null?void 0:i.call(n,a,{box:t}))}_updateEffects(a,t){var n,i;this._runAction((i=(n=this.editor).updateTextLayer)==null?void 0:i.call(n,a,{effects:t}))}_textEffects(a){const t=a&&typeof a=="object"?a:{};return{stroke:{...ir.stroke,...t.stroke&&typeof t.stroke=="object"?t.stroke:{}},shadow:{...ir.shadow,...t.shadow&&typeof t.shadow=="object"?t.shadow:{}},glow:{...ir.glow,...t.glow&&typeof t.glow=="object"?t.glow:{}},backdrop:{...ir.backdrop,...t.backdrop&&typeof t.backdrop=="object"?t.backdrop:{}}}}_runAction(a){this._errorMessage=null,Promise.resolve(a).catch(t=>{var i,r;const n=t instanceof Error?t:new Error(String(t));this._errorMessage=n.message||"Text update failed",(r=(i=this.editor)==null?void 0:i.emit)==null||r.call(i,"error",n),this._render()})}_activeTextLayer(){const a=this.state.get("activeLayerId"),t=this.state.get("layers");return!a||!Array.isArray(t)?null:t.find(n=>(n==null?void 0:n.id)===a&&(n.type==="text"||n.role==="text"))??null}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(a=this.element)==null||a.remove(),this.element=null}}class Th{constructor(a,t,n){this.state=a,this.filterManager=t,this.editor=n,this.element=null,this._headerEl=null,this._bodyEl=null,this._view="categories",this._onNavigate=null,this._callbacks=null,this._unsubscribers=[],this._categoryTabs=null,this._filterListView=null,this._filterControlsView=null,this._backgroundPanel=null,this._layerStackPanel=null,this._textPanel=null}build(a){return this._callbacks=a,this._onNavigate=a.onViewChange||null,this.element=te.el("div",{className:"drawer-nav","data-testid":"v2-mobile-nav"}),this._headerEl=te.el("div",{className:"drawer-nav-header"}),this.element.appendChild(this._headerEl),this._bodyEl=te.el("div",{className:"drawer-nav-body"}),this.element.appendChild(this._bodyEl),this._buildViews(),this._unsubscribers.push(this.state.on("change:selectedFilter",({value:t})=>{t&&this._view!=="controls"&&this.navigateTo("controls")}),this.state.on("change:selectedCategory",()=>{}),this.state.on("change:mode",({value:t})=>{t==="filters"&&this._view!=="categories"&&!this.state.get("selectedFilter")&&this.navigateTo("categories")})),this.navigateTo("categories"),this.element}_buildViews(){this._categoryTabs=new qu(this.state,this.editor),this._categoryTabsEl=this._categoryTabs.render({onSelect:a=>{if(a==="background"||a==="layers"||a==="text"){this.navigateTo(a);return}this.navigateTo("filters")}}),this._filterListView=new Yu(this.state,this.filterManager),this._filterListEl=this._filterListView.render({onToggle:(a,t,n)=>this._callbacks.onFilterToggle(a,t,n),onSelect:(a,t)=>{this._callbacks.onFilterSelect(a,t),this.navigateTo("controls")}}),this._filterControlsView=new Qu(this.state,this.filterManager),this._filterControlsEl=this._filterControlsView.render({onChange:(a,t,n,i)=>this._callbacks.onFilterChange(a,t,n,i),onReset:(a,t)=>this._callbacks.onFilterReset(a,t),onAction:(a,t,n)=>this._callbacks.onFilterAction(a,t,n)}),this._backgroundPanel=new em(this.state,this.editor),this._backgroundPanelEl=this._backgroundPanel.render(),this._layerStackPanel=new tm(this.state,this.editor),this._layerStackPanelEl=this._layerStackPanel.render(),this._textPanel=new am(this.state,this.editor),this._textPanelEl=this._textPanel.render()}navigateTo(a){var n;if(!this.element)return;this._view=a,this._renderHeader(),this._bodyEl.innerHTML="";let t=null;switch(a){case"categories":t=this._categoryTabsEl;break;case"filters":t=this._filterListEl;break;case"controls":t=this._filterControlsEl;break;case"background":t=this._backgroundPanelEl;break;case"layers":t=this._layerStackPanelEl;break;case"text":t=this._textPanelEl;break;default:t=this._categoryTabsEl}t&&this._bodyEl.appendChild(t),(n=this._onNavigate)==null||n.call(this,a)}_renderHeader(){if(!this._headerEl)return;if(this._headerEl.innerHTML="",this._view!=="categories"){const n=te.el("button",{type:"button",className:"drawer-back-btn","aria-label":"Go back","data-testid":"v2-drawer-back",onClick:()=>this._goBack()});n.innerHTML=te.chevronLeft,this._headerEl.appendChild(n)}const t=this._titleForView(this._view);if(this._headerEl.appendChild(te.el("h2",{className:"drawer-nav-title"},t)),this._view==="controls"){const n=this.state.get("selectedFilter");if(n){const i=this._activeFilterLayerId();this._headerEl.appendChild(te.createButton({label:"Reset",className:"btn-text",onClick:()=>this._callbacks.onFilterReset(n,i)}))}}}_activeFilterLayerId(){return typeof this.state.getActiveFilterLayerId=="function"?this.state.getActiveFilterLayerId():this.state.get("activeLayerId")}_titleForView(a){switch(a){case"categories":return"Filters";case"filters":{const t=this.state.get("selectedCategory");return this._categoryLabel(t)||"Filters"}case"background":return"Background";case"layers":return"Layers";case"text":return"Text";case"controls":{const t=this.state.get("selectedFilter"),n=t?this.filterManager.getFilterDef(t):null;return(n==null?void 0:n.name)||"Filter"}default:return""}}_categoryLabel(a){var t;return a&&((t=te.EDITOR_CATEGORIES.find(n=>n.id===a))==null?void 0:t.name)||null}_goBack(){this._view==="controls"?(this.state.set("selectedFilter",null),this.navigateTo("filters")):(this._view==="filters"||this._view==="background"||this._view==="layers"||this._view==="text")&&this.navigateTo("categories")}get currentView(){return this._view}destroy(){var a,t,n,i,r,l,s;this._unsubscribers.forEach(d=>d()),this._unsubscribers=[],(a=this._categoryTabs)==null||a.destroy(),(t=this._filterListView)==null||t.destroy(),(n=this._filterControlsView)==null||n.destroy(),(i=this._backgroundPanel)==null||i.destroy(),(r=this._layerStackPanel)==null||r.destroy(),(l=this._textPanel)==null||l.destroy(),(s=this.element)==null||s.remove(),this.element=null}}class Bh{constructor(a,t){this.state=a,this.filterManager=t,this.element=null,this._onSelect=null,this._onRemove=null,this._unsubscribers=[]}render({onSelect:a,onRemove:t}={}){return this._onSelect=a,this._onRemove=t,this.element=te.el("div",{className:"mobile-active-chips",role:"region","aria-label":"Active filters","data-testid":"v2-mobile-active-chips"}),this._renderChips(),this._unsubscribers.push(this.state.on("change:activeFilters",()=>this._renderChips()),this.state.on("change:selectedFilter",()=>this._refreshSelection())),this.element}_renderChips(){this.element.innerHTML="";const a=this.state.get("activeFilters");if(((a==null?void 0:a.size)??0)===0){this.element.style.display="none";return}this.element.style.display="";const n=te.el("div",{className:"mobile-active-track"}),i=this.state.get("selectedFilter"),r=this._activeFilterLayerId();for(const l of a){const s=this.filterManager.getFilterDef(l);s&&n.appendChild(this._renderChip(s,l===i,r))}this.element.appendChild(n)}_renderChip(a,t,n=null){const i=te.el("div",{className:`mobile-active-chip ${t?"selected":""}`,"data-filter":a.id,"data-testid":`v2-mobile-chip-${a.id}`});i.appendChild(te.el("button",{type:"button",className:"mobile-active-chip-name","aria-label":`Edit ${a.name}`,onClick:()=>{var l;return(l=this._onSelect)==null?void 0:l.call(this,a.id,n)}},a.name));const r=te.el("button",{type:"button",className:"mobile-active-chip-remove","aria-label":`Remove ${a.name}`,"data-testid":`v2-mobile-chip-remove-${a.id}`,onClick:l=>{var s;l.stopPropagation(),(s=this._onRemove)==null||s.call(this,a.id,n)}});return r.innerHTML=te.close,i.appendChild(r),i}_activeFilterLayerId(){return typeof this.state.getActiveFilterLayerId=="function"?this.state.getActiveFilterLayerId():this.state.get("activeLayerId")}_refreshSelection(){var n;const a=this.state.get("selectedFilter"),t=(n=this.element)==null?void 0:n.querySelectorAll(".mobile-active-chip");t==null||t.forEach(i=>{const r=i.getAttribute("data-filter");i.classList.toggle("selected",r===a)})}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(a=this.element)==null||a.remove(),this.element=null}}const rc="(max-width: 900px)";let Ih=class{constructor(a,t,n){this.state=a,this.filterManager=t,this.editor=n,this.root=null,this.canvasSection=null,this.canvasContainer=null,this.cropOverlay=null,this._callbacks=null,this._isMobile=!1,this._panel=null,this._categoryTabs=null,this._filterListView=null,this._filterControlsView=null,this._activeStack=null,this._backgroundPanel=null,this._layerStackPanel=null,this._textPanel=null,this._desktopBackgroundSection=null,this._desktopLayerSection=null,this._desktopTextSection=null,this._desktopFilterListSection=null,this._desktopCropWrapper=null,this._mobileChips=null,this._mobileDrawer=null,this._mobileNav=null,this._mobileCropWrapper=null,this._cropControlsEl=null,this._unsubscribers=[],this._mql=null,this._mqlHandler=null,this._resizeObserver=null}build(a){var t;return this._callbacks=a,this.root=te.el("div",{className:"editor-v2-body"}),this.canvasSection=te.el("div",{className:"editor-v2-canvas"}),this.canvasContainer=te.el("div",{className:"canvas-container"}),this.cropOverlay=te.el("canvas",{className:"crop-overlay","aria-hidden":"true"}),this.canvasSection.appendChild(this.canvasContainer),this.canvasSection.appendChild(this.cropOverlay),this._zoomOverlay=this._buildCanvasZoomOverlay(),this.canvasSection.appendChild(this._zoomOverlay),this.root.appendChild(this.canvasSection),this._isMobile=typeof window<"u"&&((t=window.matchMedia)==null?void 0:t.call(window,rc).matches)===!0,this._isMobile?this._buildMobileShell():this._buildDesktopShell(),typeof window<"u"&&window.matchMedia&&(this._mql=window.matchMedia(rc),this._mqlHandler=n=>this._handleBreakpointChange(n.matches),this._mql.addEventListener?this._mql.addEventListener("change",this._mqlHandler):this._mql.addListener&&this._mql.addListener(this._mqlHandler)),this._unsubscribers.push(this.state.on("change:mode",({value:n})=>this._applyMode(n)),this.state.on("change:selectedCategory",()=>this._applyMode(this.state.get("mode")))),{root:this.root,canvasContainer:this.canvasContainer,cropOverlay:this.cropOverlay}}mountCropControls(a){this._cropControlsEl=a,this._mountCropControlsInActiveShell()}_buildDesktopShell(){this._panel=te.el("div",{className:"editor-v2-panel","data-testid":"v2-inspector-panel"}),this._categoryTabs=new qu(this.state,this.editor),this._panel.appendChild(this._categoryTabs.render({onSelect:()=>this._handleDesktopCategoryChange()}));const a=te.el("div",{className:"panel-body"});this._desktopFilterListSection=te.el("div",{className:"panel-section"}),this._desktopFilterListSection.appendChild(te.el("div",{className:"panel-section-title"},te.el("span",{},"Filters"))),this._filterListView=new Yu(this.state,this.filterManager),this._desktopFilterListSection.appendChild(this._filterListView.render({onToggle:(t,n,i)=>this._callbacks.onFilterToggle(t,n,i),onSelect:(t,n)=>this._callbacks.onFilterSelect(t,n)})),a.appendChild(this._desktopFilterListSection),this._filterControlsView=new Qu(this.state,this.filterManager),a.appendChild(this._filterControlsView.render({onChange:(t,n,i,r)=>this._callbacks.onFilterChange(t,n,i,r),onReset:(t,n)=>this._callbacks.onFilterReset(t,n),onAction:(t,n,i)=>this._callbacks.onFilterAction(t,n,i)})),this._desktopCropWrapper=te.el("div",{className:"crop-controls-wrapper",style:{display:"none"}}),a.appendChild(this._desktopCropWrapper),this._activeStack=new Eh(this.state,this.filterManager),a.appendChild(this._activeStack.render({onRemove:(t,n)=>this._callbacks.onFilterToggle(t,!1,n),onSelect:(t,n)=>this._callbacks.onFilterSelect(t,n),onClearAll:t=>{var n,i;return(i=(n=this._callbacks).onClearAll)==null?void 0:i.call(n,t)}})),this._desktopBackgroundSection=te.el("div",{className:"panel-section",style:{display:"none"}}),this._backgroundPanel=new em(this.state,this.editor),this._desktopBackgroundSection.appendChild(this._backgroundPanel.render()),a.appendChild(this._desktopBackgroundSection),this._desktopLayerSection=te.el("div",{className:"panel-section",style:{display:"none"}}),this._layerStackPanel=new tm(this.state,this.editor),this._desktopLayerSection.appendChild(this._layerStackPanel.render()),a.appendChild(this._desktopLayerSection),this._desktopTextSection=te.el("div",{className:"panel-section",style:{display:"none"}}),this._textPanel=new am(this.state,this.editor),this._desktopTextSection.appendChild(this._textPanel.render()),a.appendChild(this._desktopTextSection),this._panel.appendChild(a),this.root.appendChild(this._panel),this._mountCropControlsInActiveShell(),this._applyMode(this.state.get("mode"))}_buildMobileShell(){this._mobileChips=new Bh(this.state,this.filterManager);const a=this._mobileChips.render({onSelect:(r,l)=>{var s,d;this._callbacks.onFilterSelect(r,l),(s=this._mobileDrawer)==null||s.snapTo("full"),(d=this._mobileNav)==null||d.navigateTo("controls")},onRemove:(r,l)=>this._callbacks.onFilterToggle(r,!1,l)});this.root.appendChild(a),this._mobileDrawer=new Sh({onSnapChange:r=>{this.canvasContainer&&window.dispatchEvent(new Event("resize"))}}),this._mobileNav=new Th(this.state,this.filterManager,this.editor);const t=this._mobileNav.build({onFilterToggle:this._callbacks.onFilterToggle,onFilterSelect:this._callbacks.onFilterSelect,onFilterChange:this._callbacks.onFilterChange,onFilterReset:this._callbacks.onFilterReset,onFilterAction:this._callbacks.onFilterAction,onViewChange:r=>{var l;r==="controls"&&((l=this._mobileDrawer)==null?void 0:l.snap)==="collapsed"&&this._mobileDrawer.snapTo("half")}});this._mobileCropWrapper=te.el("div",{className:"crop-controls-wrapper",style:{display:"none"}});const n=te.el("div",{className:"drawer-content"});n.appendChild(t),n.appendChild(this._mobileCropWrapper);const i=this._mobileDrawer.build({body:n});this.root.appendChild(i),this._wireDrawerSizing(),this._mountCropControlsInActiveShell(),this._applyMode(this.state.get("mode"))}_wireDrawerSizing(){if(!this.root||!this._mobileDrawer)return;const a=()=>{const t=this.root.getBoundingClientRect().height;this._mobileDrawer.updateContainerHeight(t)};a(),this._resizeObserver=new ResizeObserver(()=>a()),this._resizeObserver.observe(this.root)}_destroyDesktopShell(){var a,t,n,i,r,l,s,d,c,u;(a=this._categoryTabs)==null||a.destroy(),this._categoryTabs=null,(t=this._filterListView)==null||t.destroy(),this._filterListView=null,(n=this._filterControlsView)==null||n.destroy(),this._filterControlsView=null,(i=this._activeStack)==null||i.destroy(),this._activeStack=null,(r=this._backgroundPanel)==null||r.destroy(),this._backgroundPanel=null,(l=this._layerStackPanel)==null||l.destroy(),this._layerStackPanel=null,(s=this._textPanel)==null||s.destroy(),this._textPanel=null,this._desktopBackgroundSection=null,this._desktopLayerSection=null,this._desktopTextSection=null,this._desktopFilterListSection=null,(d=this._desktopCropWrapper)!=null&&d.parentElement&&((c=this._cropControlsEl)==null?void 0:c.parentElement)===this._desktopCropWrapper&&this._desktopCropWrapper.removeChild(this._cropControlsEl),this._desktopCropWrapper=null,(u=this._panel)==null||u.remove(),this._panel=null}_destroyMobileShell(){var a,t,n,i,r;(a=this._resizeObserver)==null||a.disconnect(),this._resizeObserver=null,(t=this._mobileNav)==null||t.destroy(),this._mobileNav=null,(n=this._mobileChips)==null||n.destroy(),this._mobileChips=null,this._mobileCropWrapper&&((i=this._cropControlsEl)==null?void 0:i.parentElement)===this._mobileCropWrapper&&this._mobileCropWrapper.removeChild(this._cropControlsEl),this._mobileCropWrapper=null,(r=this._mobileDrawer)==null||r.destroy(),this._mobileDrawer=null}_handleBreakpointChange(a){a!==this._isMobile&&(this._isMobile=a,a?(this._destroyDesktopShell(),this._buildMobileShell()):(this._destroyMobileShell(),this._buildDesktopShell()))}_mountCropControlsInActiveShell(){if(!this._cropControlsEl)return;this._cropControlsEl.remove();const a=this._isMobile?this._mobileCropWrapper:this._desktopCropWrapper;a==null||a.appendChild(this._cropControlsEl)}_handleDesktopCategoryChange(){if(this.state.get("mode")==="crop"||["background","layers","text"].includes(this.state.get("selectedCategory")))return;const t=this.state.get("selectedFilter");if(!t)return;this.filterManager.getFiltersByCategory(this.state.get("selectedCategory")).some(i=>i.id===t)||this.state.set("selectedFilter",null)}_applyMode(a){var s,d,c;const t=a==="crop",n=!t&&this.state.get("selectedCategory")==="background",i=!t&&this.state.get("selectedCategory")==="layers",r=!t&&this.state.get("selectedCategory")==="text",l=n||i||r;this._desktopFilterListSection&&(this._desktopFilterListSection.style.display=t||l?"none":""),(s=this._filterControlsView)!=null&&s.element&&(this._filterControlsView.element.style.display=t||l?"none":""),(d=this._activeStack)!=null&&d.element&&(this._activeStack.element.style.display=t||l?"none":""),this._desktopBackgroundSection&&(this._desktopBackgroundSection.style.display=n?"":"none"),this._desktopLayerSection&&(this._desktopLayerSection.style.display=i?"":"none"),this._desktopTextSection&&(this._desktopTextSection.style.display=r?"":"none"),this._desktopCropWrapper&&(this._desktopCropWrapper.style.display=t?"":"none"),(c=this._mobileNav)!=null&&c.element&&(this._mobileNav.element.style.display=t?"none":""),this._mobileCropWrapper&&(this._mobileCropWrapper.style.display=t?"":"none"),t&&this._mobileDrawer&&this._mobileDrawer.snapTo("half")}_buildCanvasZoomOverlay(){const a=te.el("div",{className:"canvas-zoom-overlay",role:"group","aria-label":"Zoom controls"}),t=te.createIconButton({icon:te.zoomOut,title:"Zoom Out",className:"canvas-zoom-btn",testId:"btn-zoom-out",ariaLabel:"Zoom out",onClick:()=>{const l=this.state.get("zoom");this.editor.setZoom(l-.25)}}),n=te.el("span",{className:"canvas-zoom-label","aria-live":"polite","aria-atomic":"true",role:"status"},`${Math.round((this.state.get("zoom")??1)*100)}%`),i=te.createIconButton({icon:te.zoomIn,title:"Zoom In",className:"canvas-zoom-btn",testId:"btn-zoom-in",ariaLabel:"Zoom in",onClick:()=>{const l=this.state.get("zoom");this.editor.setZoom(l+.25)}}),r=te.createIconButton({icon:te.expand,title:"Fit to Screen",className:"canvas-zoom-btn",testId:"btn-fit-screen",ariaLabel:"Fit to screen",onClick:()=>this.editor.fitToScreen()});return a.appendChild(t),a.appendChild(n),a.appendChild(i),a.appendChild(r),this._unsubscribers.push(this.state.on("change:zoom",({value:l})=>{n.textContent=`${Math.round(l*100)}%`})),a}destroy(){var a;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],this._mql&&this._mqlHandler&&(this._mql.removeEventListener?this._mql.removeEventListener("change",this._mqlHandler):this._mql.removeListener&&this._mql.removeListener(this._mqlHandler),this._mql=null,this._mqlHandler=null),this._destroyDesktopShell(),this._destroyMobileShell(),(a=this.root)==null||a.remove(),this.root=null,this.canvasSection=null,this.canvasContainer=null,this.cropOverlay=null}};function No(o){if(!Number.isFinite(Number(o)))return 0;const a=Number(o)%360;return a<0?a+360:a}function Mh(o,a){const t=No(o);return(No(a)-t+540)%360-180}function $h(){return new Date().toISOString()}function rr(o){return typeof o=="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(o)}class Fh extends te.EventEmitter{constructor(a,t={}){var r,l,s,d,c;if(super(),!a)throw new Error("VanillaImageEditorV2: container element is required");this._container=a,this._destroyed=!1,this._loadVersion=0,this._objectUrls=new Set,this._activeObjectUrl=null;const n=t.preset?te.getPreset(t.preset):null,i=n?{initialMode:n.initialMode==="crop"?"crop":"adjust",cropShape:n.cropShape,initialAspectRatio:n.aspectRatio}:{};this._options={theme:"auto",initialImage:null,initialMode:"adjust",cropShape:"free",initialAspectRatio:"free",layout:"split-panel",backgroundRemoval:{enabled:!0,endpoint:"/api/v1/media/background-removal/preview",optionsEndpoint:"/api/v1/media/background-removal/options",savedEndpoint:"/api/v1/media/{media}/background-removal",fallbackEndpoint:null},backgroundReplacement:{assetEndpoint:null,materializeEndpoint:null,targetMediaUuid:null,mediaChoices:[]},...i,...t},this._preset=n,this._state=te.createState(),this._state.set("theme",this._options.theme),this._state.set("crop.shape",this._options.cropShape),this._state.set("crop.aspect",this._options.initialAspectRatio),this._preset&&(this._state.set("lockCropShape",!!this._preset.lockCropShape),this._state.set("lockAspectRatio",!!this._preset.lockAspectRatio),this._state.set("showFilters",this._preset.showFilters!==!1),this._state.set("showCropControls",this._preset.showCropControls!==!1),this._state.set("autoZoomOnCropOverflow",!!this._preset.autoZoomOnCropOverflow)),this._renderer=new te.PixiRenderer,this._filterManager=new te.FilterManager(this._state,this._renderer),this._cropManager=new te.CropManager(this._state,this._renderer),this._removeBgManager=null,this._backgroundRemovalAvailable=!1,((r=this._options.backgroundRemoval)==null?void 0:r.enabled)!==!1&&(this._removeBgManager=new te.RemoveBgManager({endpoint:(l=this._options.backgroundRemoval)==null?void 0:l.endpoint,optionsEndpoint:(s=this._options.backgroundRemoval)==null?void 0:s.optionsEndpoint,savedEndpoint:(d=this._options.backgroundRemoval)==null?void 0:d.savedEndpoint,fallbackEndpoint:(c=this._options.backgroundRemoval)==null?void 0:c.fallbackEndpoint})),this._loadingOverlay=null,this._toolbar=null,this._layout=null,this._cropControls=null,this._editorEl=null,this._toolbarContainer=null,this._canvasContainer=null,this._cropOverlay=null,this._fileInput=null,this._mobileSaveBar=null,this._mobileSaveBtn=null,this._mobileSaveUnsub=null,this._resizeObserver=null,this._initPromise=Promise.resolve(this._init()).catch(u=>{this._destroyed||this.emit("error",u instanceof Error?u:new Error(String(u)))})}async _init(){this._state.detectTheme(),this._buildDOM(),!(!await this._renderer.mount(this._canvasContainer,0,{backgroundAlpha:0})||this._destroyed)&&(this._cropManager.setOverlayCanvas(this._cropOverlay),this._initUI(),this._setupResizeObserver(),this._setupWindowResize(),this._subscribeToState(),this._refreshBackgroundRemovalAvailability(),this._options.initialImage&&await this.loadImage(this._options.initialImage),this.emit("ready"))}_buildDOM(){this._container.innerHTML="",this._editorEl=te.el("div",{className:`vanilla-image-editor-v2 ${this._state.get("isDarkMode")?"dark":"light"}`}),this._toolbarContainer=te.el("div",{className:"editor-v2-toolbar"}),this._editorEl.appendChild(this._toolbarContainer),this._layout=new Ih(this._state,this._filterManager,this);const{root:a,canvasContainer:t,cropOverlay:n}=this._layout.build({onFilterToggle:(i,r,l)=>this._handleFilterToggle(i,r,l),onFilterSelect:(i,r)=>this._handleFilterSelect(i,r),onFilterChange:(i,r,l,s)=>this._handleFilterChange(i,r,l,s),onFilterReset:(i,r)=>this._handleFilterReset(i,r),onFilterAction:(i,r,l)=>this._handleFilterAction(i,r,l),onClearAll:i=>this.resetAll(i)});this._canvasContainer=t,this._cropOverlay=n,this._editorEl.appendChild(a),this._buildMobileSaveBar(),this._mobileSaveBar&&this._editorEl.appendChild(this._mobileSaveBar),this._fileInput=te.el("input",{type:"file",accept:"image/*",className:"hidden-file-input",style:{display:"none"},"aria-label":"Choose image file to edit",onChange:i=>this._handleFileSelect(i)}),this._editorEl.appendChild(this._fileInput),this._container.appendChild(this._editorEl)}_initUI(){this._toolbar=new te.Toolbar(this._state,this),this._toolbarContainer.appendChild(this._toolbar.render()),this._cropControls=new te.CropControls(this._state,this._cropManager,this);const a=this._cropControls.render();this._layout.mountCropControls(a)}_setupResizeObserver(){if(!this._canvasContainer)return;let a=null;this._resizeObserver=new ResizeObserver(()=>{clearTimeout(a),a=setTimeout(()=>{var t,n;this._destroyed||!this._canvasContainer||(this._renderer.resizeTo(this._canvasContainer),this._state.get("mode")==="crop"&&((n=(t=this._cropManager).drawOverlay)==null||n.call(t)))},50)}),this._resizeObserver.observe(this._canvasContainer)}_setupWindowResize(){this._handleWindowResize=()=>{},window.addEventListener("resize",this._handleWindowResize)}_subscribeToState(){this._state.on("change:isDarkMode",({value:a})=>{var t,n;(t=this._editorEl)==null||t.classList.toggle("dark",a),(n=this._editorEl)==null||n.classList.toggle("light",!a)})}async _handleFileSelect(a){var n;const t=(n=a.target.files)==null?void 0:n[0];t&&await this.loadImage(t),this._fileInput.value=""}_matchesExpectedFilterLayer(a){if(a===void 0)return!0;if(a===null)return typeof this._state.getActiveFilterLayerId=="function"?this._state.getActiveFilterLayerId()===null:this._state.get("activeLayerId")===null;const t=typeof a=="string"?a.trim():"";return t===""?!1:typeof this._state.getActiveFilterLayerId=="function"?this._state.getActiveFilterLayerId()===t:this._state.get("activeLayerId")===t}_handleFilterToggle(a,t,n=void 0){this._filterManager.toggle(a,t,n)!==!1&&(t?this._state.set("selectedFilter",a):this._state.get("selectedFilter")===a&&this._state.set("selectedFilter",null))}_handleFilterSelect(a,t=void 0){var r;if(!this._matchesExpectedFilterLayer(t))return;const n=this._state.get("activeFilters");if(!((r=n==null?void 0:n.has)!=null&&r.call(n,a))&&this._filterManager.toggle(a,!0,t)===!1)return;this._state.set("selectedFilter",a);const i=this._filterManager.getFilterDef(a);if(typeof(i==null?void 0:i.category)=="string"){const l=te.REGISTRY_TO_UI[i.category]||i.category;this._state.get("selectedCategory")!==l&&this._state.set("selectedCategory",l)}}_handleFilterChange(a,t,n,i=void 0){this._filterManager.updateValue(a,t,n,i)||this._filterManager.applyFilters(),this._renderer.render()}_handleFilterReset(a,t=void 0){var n,i;this._filterManager.resetValues(a,t),(i=(n=this._filterManager)==null?void 0:n.applyFilters)==null||i.call(n)}_handleFilterAction(a,t,n=void 0){this._filterManager.performFilterAction(a,t,n)}_revokeObjectUrl(a){!a||!this._objectUrls.has(a)||(URL.revokeObjectURL(a),this._objectUrls.delete(a),this._activeObjectUrl===a&&(this._activeObjectUrl=null))}_replaceActiveObjectUrl(a){const t=this._activeObjectUrl;this._activeObjectUrl=a,this._objectUrls.add(a),t&&t!==a&&this._revokeObjectUrl(t)}_clearActiveObjectUrl(){this._activeObjectUrl&&this._revokeObjectUrl(this._activeObjectUrl)}async _renderCurrentDocument(){var a,t;return(t=(a=this._renderer).renderLayerDocument)==null?void 0:t.call(a,this._state.getSerializableDocument(),{fallbackImageUrl:this._state.get("imageUrl")??null})}async setBackgroundFill(a){var n;const t=this._state.setBackgroundFill(a);return await this._renderCurrentDocument(),this.emit("background-changed",{layerId:t,fill:((n=this._state.getLayer(t))==null?void 0:n.fill)??null}),t}async setBackgroundColor(a){return this.setBackgroundFill({kind:"color",value:typeof a=="string"&&a.trim()!==""?a:"#ffffff"})}async setBackgroundGradient(a={}){return this.setBackgroundFill({kind:"gradient",gradientType:a.gradientType||"linear",angle:Number.isFinite(Number(a.angle))?Number(a.angle):135,stops:Array.isArray(a.stops)?a.stops:[{offset:0,color:"#111827"},{offset:1,color:"#f59e0b"}],fit:a.fit||"cover"})}async setBackgroundMediaSource(a,t={}){if(!a||typeof a!="object")throw new Error("Background source is required");return this.setBackgroundFill({kind:"media",source:a,fit:t.fit||"cover"})}async setBackgroundImageFromFile(a,t={}){var i,r;if(!(a instanceof Blob))throw new Error("Background image file is required");const n=URL.createObjectURL(a);this._objectUrls.add(n);try{if(((r=(i=this._state).isBackgroundLayerLocked)==null?void 0:r.call(i))===!0)throw new Error("Background layer is locked");const l=this._captureEditorDocumentContext(),s=await this._probeImageDimensions(n);if(!this._isCurrentEditorDocumentContext(l))return URL.revokeObjectURL(n),this._objectUrls.delete(n),null;const d=this._state.ensureBackgroundLayer();if(!d)throw new Error("Background layer is locked");let c=null,u=this._captureEditorDocumentContext(d);if(this._canUploadBackgroundAsset()){if(!await this._materializeBackgroundLayerForUpload(d))return URL.revokeObjectURL(n),this._objectUrls.delete(n),null;if(u=this._captureEditorDocumentContext(d),c=await this._uploadBackgroundAsset(a,d,n),!this._isCurrentEditorDocumentContext(u))return URL.revokeObjectURL(n),this._objectUrls.delete(n),null}return c||(c={kind:"runtime",runtimeRef:`background-${Date.now()}`,originalWidth:s.width,originalHeight:s.height,sourceHash:null,previewUrl:n}),this._isCurrentEditorDocumentContext(u)?this.setBackgroundMediaSource(c,{fit:t.fit||"cover"}):(URL.revokeObjectURL(n),this._objectUrls.delete(n),null)}catch(l){throw URL.revokeObjectURL(n),this._objectUrls.delete(n),l}}async setBackgroundFit(a){if(!this._state.setBackgroundFit(a))return!1;const n=this._backgroundLayerId();await this._renderCurrentDocument();const i=n?this._state.getLayer(n):null;return i&&this.emit("background-changed",{layerId:n,fill:i.fill??null}),!0}async setBackgroundBlur(a){if(!this._state.setBackgroundBlur(a))return!1;const n=this._backgroundLayerId();await this._renderCurrentDocument();const i=n?this._state.getLayer(n):null;return i&&this.emit("background-changed",{layerId:n,effects:i.effects??[]}),!0}_backgroundLayerId(){const a=this._state.getSerializableDocument(),t=Array.isArray(a==null?void 0:a.layers)?a.layers.find(n=>(n==null?void 0:n.type)==="background"||(n==null?void 0:n.role)==="background"):null;return typeof(t==null?void 0:t.id)=="string"?t.id:null}async removeBackgroundLayer(){return this._state.removeBackgroundLayer()?(await this._renderCurrentDocument(),this.emit("background-changed",{layerId:null,fill:null}),!0):!1}async selectLayer(a){var n,i;return this._state.setActiveLayer(a)?((i=(n=this._filterManager)==null?void 0:n.applyFilters)==null||i.call(n),this.emit("layer-changed",{action:"select",layerId:a}),!0):!1}async renameLayer(a,t){var i;return this._state.renameLayer(a,t)?(this.emit("layer-changed",{action:"rename",layerId:a,name:((i=this._state.getLayer(a))==null?void 0:i.name)??null}),!0):!1}async duplicateLayer(a){const t=this._state.duplicateLayer(a);return t?(await this._renderCurrentDocument(),this.emit("layer-changed",{action:"duplicate",layerId:a,duplicateLayerId:t}),t):null}async deleteLayer(a){return this._state.deleteLayer(a)?(await this._renderCurrentDocument(),this.emit("layer-changed",{action:"delete",layerId:a,activeLayerId:this._state.get("activeLayerId")}),!0):!1}async moveLayer(a,t){return this._state.moveLayer(a,t)?(await this._renderCurrentDocument(),this.emit("layer-changed",{action:"move",layerId:a,direction:t}),!0):!1}async setLayerVisibility(a,t){return this._state.setLayerVisibility(a,t)?(await this._renderCurrentDocument(),this.emit("layer-changed",{action:"visibility",layerId:a,visible:!!t}),!0):!1}async setLayerLocked(a,t){return this._state.setLayerLocked(a,t)?(this.emit("layer-changed",{action:"lock",layerId:a,locked:!!t}),!0):!1}async addTextLayer(a={}){const t=this._state.addTextLayer(a);return t?(this._state.set("selectedCategory","text"),await this._renderCurrentDocument(),this.emit("layer-changed",{action:"text-add",layerId:t}),t):null}async updateTextLayer(a,t={}){return this._state.updateTextLayer(a,t)?(await this._renderCurrentDocument(),this.emit("layer-changed",{action:"text-update",layerId:a,patch:t}),!0):!1}_canUploadBackgroundAsset(){var r,l;const a=(l=(r=this._options)==null?void 0:r.backgroundReplacement)==null?void 0:l.assetEndpoint,t=this._state.getEditorDocumentBinding(),n=this._state.getSerializableDocument(),i=this._backgroundTargetMediaUuid(n);return typeof a=="string"&&a.trim()!==""&&!!(t!=null&&t.documentId)&&!!n&&typeof i=="string"&&i.trim()!==""}async _materializeBackgroundLayerForUpload(a){return this._materializeCurrentDocument("Background layer materialization failed",a)}_documentMaterializationSignature(a){try{return JSON.stringify(a??null)}catch{return null}}_captureDocumentMaterializationContext(a,t,n=null){return{loadVersion:this._loadVersion,documentId:(t==null?void 0:t.documentId)??null,documentRevisionId:(t==null?void 0:t.documentRevisionId)??null,documentRevisionNumber:(t==null?void 0:t.documentRevisionNumber)??null,documentSignature:this._documentMaterializationSignature(a),requiredLayerId:n}}_captureEditorDocumentContext(a=null){return{loadVersion:this._loadVersion,documentSignature:this._documentMaterializationSignature(this._state.getSerializableDocument()),requiredLayerId:a}}_isCurrentEditorDocumentContext(a){return!(!a||this._destroyed||this._loadVersion!==a.loadVersion||this._documentMaterializationSignature(this._state.getSerializableDocument())!==a.documentSignature||a.requiredLayerId&&!this._state.getLayer(a.requiredLayerId))}_isCurrentDocumentMaterializationContext(a){if(!a||this._destroyed||this._loadVersion!==a.loadVersion)return!1;const t=this._state.getEditorDocumentBinding();if(!t||(t.documentId??null)!==a.documentId||(t.documentRevisionId??null)!==a.documentRevisionId||(t.documentRevisionNumber??null)!==a.documentRevisionNumber)return!1;const n=this._state.getSerializableDocument();return!(this._documentMaterializationSignature(n)!==a.documentSignature||a.requiredLayerId&&!this._state.getLayer(a.requiredLayerId))}async _materializeCurrentDocument(a="Editor document materialization failed",t=null){const n=this._backgroundMaterializeEndpoint(),i=this._state.getEditorDocumentBinding(),r=this._state.getSerializableDocument();if(!n||!(i!=null&&i.documentId)||!r||t!==null&&!t)return!1;const l=this._resolveBackgroundEndpoint(n,r);if(!l)return!1;const s=this._captureDocumentMaterializationContext(r,i,t),d=rr(i.documentId)?i.documentId:null,c=await fetch(l,{method:"POST",credentials:"include",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({document_id:d,base_document_revision:d===null?null:i.documentRevisionNumber,document:r})});let u=null;try{u=await c.json()}catch{u=null}if(!c.ok){const m=(u==null?void 0:u.message)||a;throw new Error(m)}return this._isCurrentDocumentMaterializationContext(s)?(u!=null&&u.document&&this._state.setEditorDocument(u.document,{documentId:u.document_id??i.documentId,documentRevisionId:u.document_revision_id??i.documentRevisionId,documentRevisionNumber:typeof u.document_revision_number=="number"?u.document_revision_number:i.documentRevisionNumber}),!0):!1}async _uploadBackgroundAsset(a,t,n){var f,h,v;const i=(h=(f=this._options)==null?void 0:f.backgroundReplacement)==null?void 0:h.assetEndpoint,r=this._state.getEditorDocumentBinding(),l=this._state.getSerializableDocument();if(!i||!(r!=null&&r.documentId)||!l)return null;const s=this._resolveBackgroundEndpoint(i,l);if(!s)return null;const d=await this._sha256File(a),c=new FormData;c.append("asset_file",a,a instanceof File&&a.name?a.name:"background.png"),c.append("asset_kind","background-upload"),c.append("document_id",r.documentId),c.append("layer_id",t),c.append("client_hash",d);const u=await fetch(s,{method:"POST",credentials:"include",headers:{Accept:"application/json"},body:c});if(!u.ok)throw new Error("Background upload failed");const m=await u.json(),p=(v=m==null?void 0:m.asset)==null?void 0:v.source;if(!p||typeof p!="object")throw new Error("Background upload did not return a usable layer source");return{...p,previewUrl:n}}_backgroundMaterializeEndpoint(){var i,r,l,s,d,c;const a=(r=(i=this._options)==null?void 0:i.backgroundReplacement)==null?void 0:r.materializeEndpoint;if(typeof a=="string"&&a.trim()!=="")return a;const t=(s=(l=this._options)==null?void 0:l.backgroundReplacement)==null?void 0:s.assetEndpoint;if(typeof t=="string"&&t.trim()!=="")return t.replace(/\/editor-assets\/?$/,"/editor-documents/materialize");const n=(c=(d=this._options)==null?void 0:d.backgroundRemoval)==null?void 0:c.savedEndpoint;return typeof n=="string"&&n.trim()!==""?n.replace(/\/background-removal\/?$/,"/editor-documents/materialize"):null}_resolveBackgroundEndpoint(a,t){if(typeof a!="string"||a.trim()==="")return null;const n=this._backgroundTargetMediaUuid(t);return a.includes("{media}")?typeof n!="string"||n.trim()===""?null:a.replace("{media}",encodeURIComponent(n)):a}_backgroundTargetMediaUuid(a){var n,i;const t=(i=(n=this._options)==null?void 0:n.backgroundReplacement)==null?void 0:i.targetMediaUuid;return typeof t=="string"&&t.trim()!==""?t:typeof(a==null?void 0:a.sourceMediaUuid)=="string"&&a.sourceMediaUuid.trim()!==""?a.sourceMediaUuid:null}async _sha256File(a){var i,r,l;const t=await a.arrayBuffer(),n=await((l=(r=(i=globalThis.crypto)==null?void 0:i.subtle)==null?void 0:r.digest)==null?void 0:l.call(r,"SHA-256",t));if(!n)throw new Error("Background upload hashing is unavailable");return Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")}_probeImageDimensions(a){return new Promise(t=>{const n=new Image;n.onload=()=>t({width:Math.max(1,Math.round(n.naturalWidth||n.width||1)),height:Math.max(1,Math.round(n.naturalHeight||n.height||1))}),n.onerror=()=>t({width:1,height:1}),n.src=a})}setFilterRegistry(a){this._filterManager.setRegistry(a)}async loadImage(a,t={}){var s,d,c,u;if(this._destroyed)return;(d=(s=this._removeBgManager)==null?void 0:s.cancelActiveRequests)==null||d.call(s,"image-load");const n=++this._loadVersion;let i=a,r=null;this._resetEditorState(),this._state.set("hasImage",!1),this._state.set("imageUrl",null),a instanceof Blob&&(i=URL.createObjectURL(a),r=i,this._objectUrls.add(i));const l=await this._renderer.loadTexture(i,{isCurrent:()=>!this._destroyed&&this._loadVersion===n});if(this._destroyed||this._loadVersion!==n){this._revokeObjectUrl(r);return}if(!l){this._revokeObjectUrl(r),this.emit("error",new Error("Failed to load image"));return}r?this._replaceActiveObjectUrl(r):this._clearActiveObjectUrl(),this._state.set("hasImage",!0),this._state.set("imageUrl",i),t.document?await this._hydrateDocument(t.document,{documentId:t.documentId??(rr((c=t.document)==null?void 0:c.id)?t.document.id:null),documentRevisionId:t.documentRevisionId??null,documentRevisionNumber:t.documentRevisionNumber??((u=t.document)==null?void 0:u.revision)??null,fallbackImageUrl:i}):this._initializeDefaultDocument(i),t.state&&this._hydrateState(t.state),this._options.initialMode==="crop"&&this.setMode("crop"),this.emit("imageLoaded",{url:i})}_resetEditorState(){this._filterManager.resetAll(),this._state.set("crop.rect",null),this._state.set("crop.appliedRect",null),this._state.set("crop.appliedShape",null),this._state.set("crop.appliedAspect",null),this._state.set("crop.dirty",!1),this._state.set("crop.shape",this._options.cropShape||"free"),this._state.set("crop.aspect",this._options.initialAspectRatio||"free"),this._state.set("transform.rotation",0),this._state.clearEditorDocument(),this._state.get("mode")==="crop"&&(this._cropManager.disable(),this._state.set("mode","filters"))}_initializeDefaultDocument(a){var c,u,m,p;const t=this._renderer.originalTexture,n=Math.max(1,Math.round((t==null?void 0:t.width)||1)),i=Math.max(1,Math.round((t==null?void 0:t.height)||1)),r=$h(),l=typeof((u=(c=this._options)==null?void 0:c.backgroundReplacement)==null?void 0:u.targetMediaUuid)=="string"&&this._options.backgroundReplacement.targetMediaUuid.trim()!==""?this._options.backgroundReplacement.targetMediaUuid.trim():null,s=l?{kind:"media",mediaUuid:l,originalWidth:n,originalHeight:i,sourceHash:null}:{kind:"runtime",runtimeRef:"source-image",originalWidth:n,originalHeight:i,sourceHash:null,previewUrl:typeof a=="string"?a:null},d={version:2,id:`client-doc-${Date.now()}`,sourceMediaUuid:l,canvas:{width:n,height:i,backgroundPreviewColor:null},revision:0,layers:[{id:"subject-layer",type:"image",role:"subject",name:"Subject",visible:!0,locked:!1,opacity:1,blendMode:"normal",transform:{x:0,y:0,scaleX:1,scaleY:1,rotation:0},effects:[],metadata:{},source:s,crop:null,filters:[]}],activeLayerId:"subject-layer",export:{mimeType:"image/png",quality:null,preserveTransparency:!0,matteColor:null,trimTransparentBounds:!1},createdAt:r,updatedAt:r};this._state.setEditorDocument(d,{documentId:null,documentRevisionId:null,documentRevisionNumber:0}),(p=(m=this._renderer).renderLayerDocument)==null||p.call(m,d,{fallbackImageUrl:typeof a=="string"?a:null})}async _hydrateDocument(a,t={}){var n,i;!a||a.version!==2||(this._state.setEditorDocument(a,{documentId:t.documentId??(rr(a.id)?a.id:null),documentRevisionId:t.documentRevisionId??null,documentRevisionNumber:t.documentRevisionNumber??a.revision??null}),await((i=(n=this._renderer).renderLayerDocument)==null?void 0:i.call(n,this._state.getSerializableDocument(),{fallbackImageUrl:t.fallbackImageUrl??this._state.get("imageUrl")??null})))}_hydrateState(a){var n;if(!a||a.version!==1)return;const t=No(((n=a.transform)==null?void 0:n.rotation)??0);if(t!==0&&this._renderer.rotateBy(t)&&this._state.set("transform.rotation",t),a.crop){const i=a.crop.shape||"free",r=a.crop.aspectRatio||"free";a.crop.rect&&(this._cropManager.applyFromPixelRect(a.crop.rect,i),this._state.set("crop.appliedRect",{...a.crop.rect}),this._state.set("crop.appliedShape",i),this._state.set("crop.appliedAspect",r)),this._state.set("crop.shape",i),this._state.set("crop.aspect",r)}if(Array.isArray(a.filters)){let i=null;for(const r of a.filters)if(r.enabled&&(i===null&&(i=r.id),this._state.toggleFilter(r.id,!0),this._filterManager.initializeValues(r.id),r.values))for(const[l,s]of Object.entries(r.values))this._state.setFilterValue(r.id,l,s);if(i!==null){this._state.set("selectedFilter",i);const r=this._filterManager.getFilterDef(i);if(typeof(r==null?void 0:r.category)=="string"){const l=te.REGISTRY_TO_UI[r.category]??r.category;this._state.set("selectedCategory",l)}}this._filterManager.applyFilters()}}openFilePicker(){var a;(a=this._fileInput)==null||a.click()}exportImage(a="png",t=.92,n={}){return!this._state.get("hasImage")||!this._applyPendingCropBeforeExport("VanillaImageEditorV2.exportImage")?null:this._renderer.exportImage(a,t,n.maxEdge??0,n.dontUpscale!==!1,n.maxPixels??0)}async exportBlob(a="png",t=.92,n={}){return!this._state.get("hasImage")||!this._applyPendingCropBeforeExport("VanillaImageEditorV2.exportBlob")?null:this._renderer.exportBlob(a,t,n)}_applyPendingCropBeforeExport(a){return!(this._state.get("crop.rect")&&!this._cropManager.apply())}async save(){if(!this._state.get("hasImage"))return;this._state.set("isSaving",!0);let a=null;try{const t=await this.exportBlob("png",.92);if(!t)throw new Error("Failed to export image");const n=i.createElement("a");a=URL.createObjectURL(t.blob),n.href=a,n.download=`edited-image-${Date.now()}.png`,i.body.appendChild(n),n.click(),i.body.removeChild(n);const i=this.getSerializableDocument(),r=this.getEditorDocumentBinding();this.emit("save",{blob:t.blob,mimeType:t.blob.type||"image/png",dimensions:{width:t.width,height:t.height},state:this.getSerializableState(),document:i,documentId:(r==null?void 0:r.documentId)??(rr(i==null?void 0:i.id)?i.id:null),documentRevisionId:(r==null?void 0:r.documentRevisionId)??null,documentRevisionNumber:(r==null?void 0:r.documentRevisionNumber)??(i==null?void 0:i.revision)??null})}catch(t){this.emit("error",{error:t})}finally{a&&URL.revokeObjectURL(a),this._state.set("isSaving",!1)}}getSerializableState(){const a=this._state.get("activeFilters"),t=[];if(a)for(const l of a){const s=this._state.getFilterValues(l);t.push({id:l,enabled:!0,values:{...s}})}const n=this._state.get("crop.appliedRect"),i=this._state.get("crop.rect"),r=n||i;return{version:1,crop:{rect:r?{...r}:null,aspectRatio:this._state.get("crop.appliedAspect")||this._state.get("crop.aspect")||"free",shape:this._state.get("crop.appliedShape")||this._state.get("crop.shape")||"free"},transform:{rotation:No(this._state.get("transform.rotation")??0)},filters:t}}getSerializableDocument(){return this._state.getSerializableDocument()}getEditorDocumentBinding(){return this._state.getEditorDocumentBinding()}close(){this.emit("cancel")}setZoom(a){this._renderer.setZoom(a)}fitToScreen(){this._renderer.fitToScreen()}resetAll(a=void 0){this._filterManager.resetAll(a)}rotateBy(a){const t=this._state.get("transform.rotation")??0;return this.setRotationAngle(Number(t)+Number(a))}setRotationAngle(a){if(!this._state.get("hasImage"))return!1;const t=No(this._state.get("transform.rotation")??0),n=No(a),i=Mh(t,n),r=this._state.get("mode")==="crop";if(Math.abs(i)>.001){if(r&&this._cropManager.disable(),!this._renderer.rotateBy(i))return r&&this._cropManager.enable(),!1;this._filterManager.applyFilters(),this._state.set("crop.rect",null),this._state.set("crop.dirty",!1),r&&this._cropManager.enable()}return this._state.set("transform.rotation",n),this.emit("transformChanged",{rotation:n}),!0}resetRotation(){return this.setRotationAngle(0)}toggleTheme(){const a=this._state.get("isDarkMode");this._state.set("isDarkMode",!a)}setTheme(a){this._state.set("theme",a),this._state.detectTheme()}setMode(a){a==="crop"?this._cropManager.enable():this._cropManager.disable(),this._state.set("mode",a)}getState(){return this._state.getAll()}async removeBackground(a={}){var t,n,i,r,l,s,d,c,u,m;if(!this._removeBgManager)throw new Error("Background removal is not enabled");if(!this._state.get("hasImage"))throw new Error("No image loaded");if(!this.canRemoveBackground())throw new Error("Background removal is not available for the current editor state");this._state.set("isProcessing",!0),this._showLoadingOverlay("Removing background...");try{const p=this._activeBackgroundRemovalLayer();if(this._hasSavedEditorDocumentBinding()&&p!==null&&this._backgroundMaterializeEndpoint()&&!await this._materializeCurrentDocument("Background removal materialization failed"))return this.emit("background-removal-stale",{operationId:a.operationId??null,targetLayerId:p.id}),{stale:!0};const f=this._buildSavedBackgroundRemovalContext(a);if(f){const b=await this._removeBgManager.removeSavedMediaBackground(f.request);if(!this._isCurrentBackgroundRemovalContext(f,b))return this.emit("background-removal-stale",{operationId:f.request.operationId,targetLayerId:f.request.targetLayerId}),{stale:!0};const R=(t=b==null?void 0:b.result)==null?void 0:t.source;if(!R||R.kind!=="edit-asset")throw new Error("Background removal did not return a persisted layer source");const V=(n=b==null?void 0:b.result)==null?void 0:n.previewDataUrl;return typeof V=="string"&&V.startsWith("data:image/")&&(!await this._renderer.loadTexture(V,{isCurrent:()=>!this._destroyed&&this._isCurrentBackgroundRemovalContext(f,b)})||!this._isCurrentBackgroundRemovalContext(f,b))?(this.emit("background-removal-stale",{operationId:f.request.operationId,targetLayerId:f.request.targetLayerId}),{stale:!0}):this._isCurrentBackgroundRemovalContext(f,b)?(this._state.replaceLayerSource(f.request.targetLayerId,R),await((r=(i=this._renderer).renderLayerDocument)==null?void 0:r.call(i,this._state.getSerializableDocument(),{fallbackImageUrl:this._state.get("imageUrl")??null})),this.emit("background-removed",{model:(l=b==null?void 0:b.result)==null?void 0:l.model,processMs:(s=b==null?void 0:b.result)==null?void 0:s.process_ms,source:R,operationId:f.request.operationId,targetLayerId:f.request.targetLayerId}),{model:(d=b==null?void 0:b.result)==null?void 0:d.model,processMs:(c=b==null?void 0:b.result)==null?void 0:c.process_ms,source:R}):(this.emit("background-removal-stale",{operationId:f.request.operationId,targetLayerId:f.request.targetLayerId}),{stale:!0})}const h=this._buildPreviewBackgroundRemovalInput(a);if(!h)throw new Error("Failed to export image for background removal");const v=this._buildPreviewBackgroundRemovalContext(h.options),k=await this._removeBgManager.preparePreviewRequest(h.imageData,h.options),y=this._resolvePreviewBackgroundRemovalContext(v,k);if(!await this._isCurrentPreviewBackgroundRemovalContext(y))return this.emit("background-removal-stale",{operationId:y.operationId,sourceHash:y.sourceHash,targetLayerId:y.activeLayerId??null}),{stale:!0};const w=await this._removeBgManager.removeBackground(k.blob,k);if(!await this._isCurrentPreviewBackgroundRemovalContext(y,w))return this.emit("background-removal-stale",{operationId:y.operationId,sourceHash:y.sourceHash}),{stale:!0};const g=await this._applyPreviewBackgroundRemovalResult(y,w);return g?(this.emit("background-removed",{model:w.model,processMs:w.processMs,operationId:y.operationId,targetLayerId:y.activeLayerId??null,source:g.source}),{model:w.model,processMs:w.processMs,...g.source?{source:g.source}:{}}):(this.emit("background-removal-stale",{operationId:y.operationId,sourceHash:y.sourceHash,targetLayerId:y.activeLayerId??null}),{stale:!0})}catch(p){throw this.emit("error",{error:p,context:"background-removal"}),p}finally{(m=(u=this._state)==null?void 0:u.set)==null||m.call(u,"isProcessing",!1),this._hideLoadingOverlay()}}async isBackgroundRemovalAvailable(){return this._removeBgManager?this._refreshBackgroundRemovalAvailability():!1}canRemoveBackground(){if(!this._removeBgManager||this._state.get("hasImage")!==!0||this._backgroundRemovalAvailable!==!0)return!1;const a=this._state.getSerializableDocument();return(a==null?void 0:a.version)===2&&Array.isArray(a.layers)?this._activeBackgroundRemovalLayer({requireSourceHash:this._hasSavedEditorDocumentBinding()})!==null:!0}async _refreshBackgroundRemovalAvailability(){if(!this._removeBgManager)return this._backgroundRemovalAvailable=!1,this._state.set("backgroundRemovalAvailable",!1),!1;const a=await this._removeBgManager.isAvailable();return this._destroyed?!1:(this._backgroundRemovalAvailable=a,this._state.set("backgroundRemovalAvailable",a),a)}_hasSavedEditorDocumentBinding(){const a=this._state.getEditorDocumentBinding();return!!(a!=null&&a.documentId)&&!!(a!=null&&a.documentRevisionId)}_activeBackgroundRemovalLayer(a={}){var l;const t=a.requireSourceHash!==!1,n=this._state.get("activeLayerId");if(!n)return null;const i=this._state.getLayer(n);if(!i||i.type!=="image"||i.locked===!0||i.visible===!1)return null;const r=(l=i==null?void 0:i.source)==null?void 0:l.sourceHash;return t&&(typeof r!="string"||!/^[a-f0-9]{64}$/i.test(r))?null:i}_buildSavedBackgroundRemovalContext(a={}){var u,m,p,f,h;const t=this._state.getSerializableDocument(),n=this._state.getEditorDocumentBinding();if(!t||!(n!=null&&n.documentId)||!(n!=null&&n.documentRevisionId))return null;const i=typeof t.sourceMediaUuid=="string"&&t.sourceMediaUuid!==""?t.sourceMediaUuid:null;if(!i)return null;const r=this._activeBackgroundRemovalLayer({requireSourceHash:!0}),l=r==null?void 0:r.id,s=(u=r==null?void 0:r.source)==null?void 0:u.sourceHash;if(!l||typeof s!="string"||!/^[a-f0-9]{64}$/i.test(s))return null;const d=a.operationId||((p=(m=globalThis.crypto)==null?void 0:m.randomUUID)==null?void 0:p.call(m))||`op-${Date.now()}-${Math.random().toString(16).slice(2)}`,c={loadVersion:this._loadVersion,activeLayerId:l,documentRevisionId:n.documentRevisionId,documentSignature:this._documentMaterializationSignature(t),sourceHash:s,request:{targetMediaUuid:i,operationId:d,documentId:n.documentId,documentRevisionId:n.documentRevisionId,targetLayerId:l,expectedSourceHash:s,tier:a.tier||((h=(f=this._options)==null?void 0:f.backgroundRemoval)==null?void 0:h.defaultTier)||"balanced"}};return a.model&&(c.request.model=a.model),a.alpha_matting!==void 0&&(c.request.alpha_matting=a.alpha_matting),a.max_megapixels!==void 0&&(c.request.max_megapixels=a.max_megapixels),c}_buildPreviewBackgroundRemovalContext(a){const t=this._state.getSerializableDocument(),n=(t==null?void 0:t.version)===2&&Array.isArray(t.layers),i=n?this._activeBackgroundRemovalLayer({requireSourceHash:!1}):null;return{loadVersion:this._loadVersion,activeLayerId:n?(i==null?void 0:i.id)??null:null,documentSignature:n?this._documentMaterializationSignature(t):null,imageUrl:this._state.get("imageUrl")??null,operationId:a.operationId,sessionKey:a.sessionKey,sourceHash:a.sourceHash,targetRef:a.targetRef??null}}_resolvePreviewBackgroundRemovalContext(a,t){return{...a,operationId:t.operationId,sessionKey:t.sessionKey,sourceHash:t.sourceHash,targetRef:t.targetRef??a.targetRef??null}}_buildPreviewBackgroundRemovalInput(a={}){const t=this._state.getSerializableDocument();if((t==null?void 0:t.version)===2&&Array.isArray(t.layers)){const i=this._activeBackgroundRemovalLayer({requireSourceHash:!1}),r=this._sourceUrlForLayerSource(i==null?void 0:i.source);return!i||!r?null:{imageData:r,options:{...a,targetRef:i.id}}}const n=this.exportImage("png");return n?{imageData:n,options:a}:null}_sourceUrlForLayerSource(a){if(!a||typeof a!="object")return null;for(const t of["previewUrl","sourceUrl","url"]){const n=a[t];if(typeof n=="string"&&n.trim()!=="")return n}return null}async _applyPreviewBackgroundRemovalResult(a,t){var r,l;if(a.documentSignature===null||!a.activeLayerId)return await this.loadImage(t.dataUrl),{source:null};const n=await this._probeImageDimensions(t.dataUrl);if(!await this._isCurrentPreviewBackgroundRemovalContext(a,t))return null;const i={kind:"runtime",runtimeRef:`background-removal-${a.operationId||Date.now()}`,originalWidth:n.width,originalHeight:n.height,sourceHash:null,previewUrl:t.dataUrl};return this._state.replaceLayerSource(a.activeLayerId,i)?(await((l=(r=this._renderer).renderLayerDocument)==null?void 0:l.call(r,this._state.getSerializableDocument(),{fallbackImageUrl:this._state.get("imageUrl")??null})),{source:i}):null}async _isCurrentPreviewBackgroundRemovalContext(a,t=null){if(this._destroyed||this._loadVersion!==a.loadVersion||this._state.get("hasImage")!==!0||(this._state.get("imageUrl")??null)!==a.imageUrl)return!1;if(t){if(t.operationId&&t.operationId!==a.operationId||t.sessionKey&&t.sessionKey!==a.sessionKey||t.sourceHash&&t.sourceHash!==a.sourceHash)return!1;if(a.documentSignature!==null){if(!a.targetRef||a.targetRef!==a.activeLayerId||t.targetRef!==a.targetRef)return!1}else if(t.targetRef&&a.targetRef&&t.targetRef!==a.targetRef)return!1}if(a.documentSignature!==null){const i=this._state.getSerializableDocument();if(this._documentMaterializationSignature(i)!==a.documentSignature)return!1;const r=this._activeBackgroundRemovalLayer({requireSourceHash:!1});return!(!r||r.id!==a.activeLayerId)}const n=this.exportImage("png");return n?await this._removeBgManager.computeImageDataHash(n)===a.sourceHash:!1}_isCurrentBackgroundRemovalContext(a,t=null){var l;if(this._destroyed||this._loadVersion!==a.loadVersion)return!1;const n=this._state.getEditorDocumentBinding();if(!n||n.documentRevisionId!==a.documentRevisionId)return!1;const i=this._state.getSerializableDocument();if(this._documentMaterializationSignature(i)!==a.documentSignature||this._state.get("activeLayerId")!==a.activeLayerId)return!1;const r=this._state.getLayer(a.request.targetLayerId);return!(!r||((l=r==null?void 0:r.source)==null?void 0:l.sourceHash)!==a.sourceHash||r.locked===!0||r.visible===!1||t&&(t.operation_id&&t.operation_id!==a.request.operationId||t.target_layer_id&&t.target_layer_id!==a.request.targetLayerId||t.document_revision_id&&t.document_revision_id!==a.request.documentRevisionId||t.source_hash&&t.source_hash!==a.request.expectedSourceHash))}_showLoadingOverlay(a){var n;if(!this._loadingOverlay)this._loadingOverlay=te.el("div",{className:"editor-loading-overlay"},te.el("div",{className:"editor-loading-spinner"}),te.el("div",{className:"editor-loading-text"},a));else{const i=this._loadingOverlay.querySelector(".editor-loading-text");i&&(i.textContent=a)}const t=(n=this._canvasContainer)==null?void 0:n.parentElement;t&&!this._loadingOverlay.parentElement&&t.appendChild(this._loadingOverlay)}_hideLoadingOverlay(){var a;(a=this._loadingOverlay)==null||a.remove()}_buildMobileSaveBar(){var l,s;this._mobileSaveBar=te.el("div",{className:"editor-v2-mobile-save-bar",role:"region","aria-label":"Save bar"}),this._mobileSaveBtn=te.el("button",{type:"button",className:"mobile-save-btn",title:"Save Image","aria-label":"Save image",dataset:{testid:"btn-save-edit-mobile"},onClick:()=>this.save()});const a=te.el("span",{className:"mobile-save-icon"});a.innerHTML=te.save;const t=a.querySelector("svg");t&&t.setAttribute("aria-hidden","true"),this._mobileSaveBtn.appendChild(a),this._mobileSaveBtn.appendChild(te.el("span",{className:"mobile-save-label"},"Save")),this._mobileSaveBar.appendChild(this._mobileSaveBtn);const n=()=>{var m,p;if(!this._mobileSaveBtn)return;const d=((m=this._state)==null?void 0:m.get("hasImage"))===!0,c=((p=this._state)==null?void 0:p.get("isProcessing"))===!0,u=!d||c;this._mobileSaveBtn.disabled=u,this._mobileSaveBtn.setAttribute("aria-disabled",u?"true":"false")};n();const i=(l=this._state)==null?void 0:l.on("change:hasImage",n),r=(s=this._state)==null?void 0:s.on("change:isProcessing",n);this._mobileSaveUnsub=()=>{try{i==null||i()}catch{}try{r==null||r()}catch{}}}destroy(){var a,t,n,i,r,l,s,d;this._destroyed=!0,(t=(a=this._removeBgManager)==null?void 0:a.cancelActiveRequests)==null||t.call(a,"editor-destroy");for(const c of this._objectUrls)try{URL.revokeObjectURL(c)}catch{}this._objectUrls.clear(),this._activeObjectUrl=null,(n=this._resizeObserver)==null||n.disconnect(),this._renderer.destroy(),this._cropManager.disable(),this._handleWindowResize&&window.removeEventListener("resize",this._handleWindowResize),(i=this._toolbar)==null||i.destroy(),(r=this._cropControls)==null||r.destroy(),(l=this._layout)==null||l.destroy(),(s=this._mobileSaveUnsub)==null||s.call(this),this._mobileSaveUnsub=null,this._mobileSaveBtn=null,this._mobileSaveBar=null,(d=this._editorEl)==null||d.remove(),this._container=null,this._state=null,this.emit("destroyed"),this.removeAllListeners()}}function Dh(o,a){try{let t=te.getFilter(o);if(t||(te.registerCorePixiFilters(),t=te.getFilter(o)),!t){try{const r=te.getAllFilters()}catch{}return null}const n={...t.defaultParams,...a};return t.createFilter(n)}catch{return null}}const Ah=78e5,Rh=e.defineComponent({__name:"ImageEditor",props:{initialImage:{},initialState:{default:null},initialDocument:{default:null},initialDocumentId:{default:null},initialDocumentRevisionId:{default:null},initialDocumentRevisionNumber:{default:null},sessionKey:{default:0},theme:{default:"auto"},cropShape:{default:"square"},preset:{},editorVersion:{default:"v2"},backgroundRemoval:{default:null},backgroundReplacement:{default:null},primaryColor:{default:"#3880ff"},secondaryColor:{default:"#5260ff"},saveButtonColor:{default:"#3880ff"},downloadButtonColor:{default:"#2dd36f"}},emits:["save","cancel","error"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(null);let r=null,l=null;function s(v){return typeof v=="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(v)}function d(){const v={state:t.initialState??null,sessionKey:t.sessionKey};return t.initialDocument&&(v.document=t.initialDocument,v.documentId=t.initialDocumentId,v.documentRevisionId=t.initialDocumentRevisionId,v.documentRevisionNumber=t.initialDocumentRevisionNumber),v}async function c(){var v,k,y;try{if(!r){n("error",new Error("Editor not initialized"));return}const w=await((v=r.exportBlob)==null?void 0:v.call(r,"png",.92,{maxPixels:Ah}));if(!w){n("error",new Error("Failed to export image — the image could not be processed"));return}const g=r.getSerializableState(),b={blob:w.blob,mimeType:w.blob.type||"image/png",dimensions:{width:w.width,height:w.height},state:g},R=((k=r.getSerializableDocument)==null?void 0:k.call(r))??null;if(R){const V=((y=r.getEditorDocumentBinding)==null?void 0:y.call(r))??null;b.document=R,b.documentId=(V==null?void 0:V.documentId)??(s(R.id)?R.id:null),b.documentRevisionId=(V==null?void 0:V.documentRevisionId)??null,b.documentRevisionNumber=(V==null?void 0:V.documentRevisionNumber)??R.revision??null}n("save",b)}catch(w){n("error",w instanceof Error?w:new Error("Failed to export image"))}}function u(){n("cancel")}function m(v){if(v instanceof Error)return v;if(v!==null&&typeof v=="object"&&"error"in v){const k=v.error;if(k instanceof Error)return k;if(typeof k=="string"&&k.trim()!=="")return new Error(k)}return typeof v=="string"&&v.trim()!==""?new Error(v):new Error("Failed to load image")}function p(v){n("error",m(v))}function f(){if(!i.value||r)return;window.PIXI=Jt,te.initializeFilterRegistry();const v={theme:t.theme};t.backgroundRemoval&&(v.backgroundRemoval=t.backgroundRemoval),t.backgroundReplacement&&(v.backgroundReplacement=t.backgroundReplacement),t.preset&&(v.preset=t.preset),t.preset?t.cropShape==="circle"&&(v.cropShape="circle",v.initialAspectRatio="1:1",v.initialMode="crop"):(v.cropShape=t.cropShape==="circle"?"circle":"free",v.initialAspectRatio=t.cropShape==="circle"?"1:1":"free",v.initialMode=t.cropShape==="circle"?"crop":"adjust");const k=t.editorVersion==="v2"?Fh:te.VanillaImageEditor,y=new k(i.value,v);r=y,y.setFilterRegistry({getAllFilters:te.getAllFilters,getFilter:te.getFilter,getFiltersByCategory:te.getFiltersByCategory}),y.save=function(){c()},y.on("cancel",u),y.on("error",p),t.initialImage&&y.loadImage(t.initialImage,d())}e.onMounted(()=>{i.value&&(i.value.clientWidth>0?f():(l=new ResizeObserver(v=>{const k=v[0];k&&k.contentRect.width>0&&!r&&(f(),l==null||l.disconnect(),l=null)}),l.observe(i.value)))});const h=()=>{!r||!t.initialImage||r.loadImage(t.initialImage,d())};return e.watch(()=>t.initialImage,(v,k)=>{!r||!v||v===k||h()}),e.watch(()=>t.sessionKey,(v,k)=>{v!==k&&h()}),e.watch(()=>t.initialState,(v,k)=>{v!==k&&h()}),e.watch(()=>[t.initialDocument,t.initialDocumentId,t.initialDocumentRevisionId,t.initialDocumentRevisionNumber],(v,k)=>{v!==k&&h()}),e.onUnmounted(()=>{l==null||l.disconnect(),l=null,r&&(r.destroy(),r=null)}),(v,k)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:i,class:"vanilla-editor-wrapper","data-testid":"vanilla-image-editor"},null,512))}}),$e=(o,a)=>{const t=o.__vccOpts||o;for(const[n,i]of a)t[n]=i;return t},nm=$e(Rh,[["__scopeId","data-v-8ab74f83"]]),Lh={class:"editor-modal-panel"},Ph={class:"editor-fill"},Uh=e.defineComponent({__name:"ImageEditorModal",props:{modelValue:{type:Boolean,default:!1},initialImage:{},initialState:{default:null},initialDocument:{default:null},initialDocumentId:{default:null},initialDocumentRevisionId:{default:null},initialDocumentRevisionNumber:{default:null},sessionKey:{default:0},acceptedFormats:{default:"image/jpeg,image/png,image/webp,image/gif"},maxFileSize:{default:10},theme:{default:"auto"},cropShape:{default:"square"},preset:{},editorVersion:{default:"v2"},backgroundRemoval:{default:null},backgroundReplacement:{default:null},primaryColor:{default:"#3880ff"},secondaryColor:{default:"#5260ff"},saveButtonColor:{default:"#3880ff"},downloadButtonColor:{default:"#2dd36f"},saveHandler:{}},emits:["update:modelValue","save","cancel","error"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(null),r=e.ref(t.modelValue),l=e.ref(!1),s=e.ref(null),d=v=>{n("error",v)},c=()=>{e.nextTick(()=>{if(i.value){const v=i.value.querySelector("button:not([disabled]), [href], input:not([disabled])");v&&v.focus()}})};e.watch(()=>t.modelValue,v=>{r.value=v,v&&(s.value=document.activeElement,c())},{immediate:!0});const u=async v=>{try{if(l.value=!0,t.saveHandler){await t.saveHandler(v);return}n("save",v)}catch(k){d(k instanceof Error?k:new Error("Failed to save image"))}finally{l.value=!1}},m=()=>{n("cancel"),f()},p=()=>{l.value||f()},f=()=>{r.value=!1,n("update:modelValue",!1),s.value&&s.value instanceof HTMLElement&&(s.value.focus(),s.value=null)},h=v=>{if(v.key==="Escape"&&r.value&&!l.value){f();return}if(v.key==="Tab"&&r.value&&i.value){const k=i.value.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(k.length===0)return;const y=k[0],w=k[k.length-1];v.shiftKey&&document.activeElement===y?(v.preventDefault(),w.focus()):!v.shiftKey&&document.activeElement===w&&(v.preventDefault(),y.focus())}};return e.onMounted(()=>{document.addEventListener("keydown",h)}),e.onBeforeUnmount(()=>{document.removeEventListener("keydown",h)}),(v,k)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[r.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"overlayRef",ref:i,role:"dialog","aria-modal":"true","aria-label":"Image editor",class:"editor-modal-overlay","data-testid":"image-editor-modal",onKeydown:e.withKeys(p,["escape"])},[e.createElementVNode("div",{class:"editor-modal-backdrop",onClick:p}),e.createElementVNode("div",Lh,[e.createElementVNode("div",Ph,[e.createVNode(nm,{"initial-image":v.initialImage,"initial-state":v.initialState,"initial-document":v.initialDocument,"initial-document-id":v.initialDocumentId,"initial-document-revision-id":v.initialDocumentRevisionId,"initial-document-revision-number":v.initialDocumentRevisionNumber,"session-key":v.sessionKey,theme:v.theme,"crop-shape":v.cropShape,preset:v.preset,"editor-version":v.editorVersion,"background-removal":v.backgroundRemoval,"background-replacement":v.backgroundReplacement,"primary-color":v.primaryColor,"secondary-color":v.secondaryColor,"save-button-color":v.saveButtonColor,"download-button-color":v.downloadButtonColor,onSave:u,onCancel:m,onError:d},null,8,["initial-image","initial-state","initial-document","initial-document-id","initial-document-revision-id","initial-document-revision-number","session-key","theme","crop-shape","preset","editor-version","background-removal","background-replacement","primary-color","secondary-color","save-button-color","download-button-color"])])])],544)):e.createCommentVNode("",!0)]))}}),om=$e(Uh,[["__scopeId","data-v-bd4e671f"]]),Oh={class:"media-workspace"},zh={class:"media-workspace-toolbar"},jh={class:"media-workspace-label"},Wh=["value"],Hh={class:"media-workspace-grid"},Zh=["onClick"],Gh=e.defineComponent({__name:"MediaWorkspace",props:{apiScope:{},subScopes:{},initialScopeId:{}},emits:["scope-change","update:media","upload","preview"],setup(o,{emit:a}){var m;const t=o,n=a,i=xa(),r=e.ref(t.initialScopeId??((m=t.subScopes[0])==null?void 0:m.id)??""),l=e.computed(()=>t.subScopes),s=e.computed(()=>l.value.find(p=>p.id===r.value));let d=null;function c(){d&&(d(),d=null),t.apiScope&&(d=Ku({apiScope:t.apiScope,isAdmin:t.apiScope==="admin"}))}async function u(){var f;const p={};(f=s.value)!=null&&f.collection&&(p.collection=s.value.collection),await i.fetchMedia(1,p),n("update:media",[...i.items])}return e.watch(()=>t.initialScopeId,p=>{p&&p!==r.value&&(r.value=p)}),e.watch(()=>t.subScopes,p=>{if(p.length===0){r.value="";return}p.some(f=>f.id===r.value)||(r.value=p[0].id)},{deep:!0}),e.watch(()=>t.apiScope,()=>{c(),u()}),e.watch(r,p=>{p&&(n("scope-change",p),u())}),e.onMounted(()=>{c(),u()}),e.onUnmounted(()=>{d&&(d(),d=null)}),(p,f)=>(e.openBlock(),e.createElementBlock("div",Oh,[e.createElementVNode("div",zh,[e.createElementVNode("label",jh,[f[2]||(f[2]=e.createElementVNode("span",{class:"media-workspace-label-text"},"Scope",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":f[0]||(f[0]=h=>r.value=h),"data-testid":"scope-select",class:"media-workspace-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,h=>(e.openBlock(),e.createElementBlock("option",{key:h.id,value:h.id},e.toDisplayString(h.label),9,Wh))),128))],512),[[e.vModelSelect,r.value]])]),e.createElementVNode("button",{type:"button",class:"media-workspace-upload","data-testid":"upload-button",onClick:f[1]||(f[1]=h=>n("upload"))}," Upload ")]),e.createElementVNode("div",Hh,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i).items,h=>(e.openBlock(),e.createElementBlock("button",{key:h.uuid,type:"button",class:"media-workspace-item","data-testid":"media-item",onClick:v=>n("preview",h)},e.toDisplayString(h.file_name),9,Zh))),128))])]))}}),Xh=$e(Gh,[["__scopeId","data-v-895f26fe"]]),Kh={class:"managed-media-gallery"},Jh={class:"gallery-grid"},qh=e.defineComponent({__name:"ManagedMediaGallery",props:{media:{},selectable:{type:Boolean},multiple:{type:Boolean}},emits:["select","remove"],setup(o){return(a,t)=>(e.openBlock(),e.createElementBlock("div",Kh,[e.createElementVNode("div",Jh,[e.renderSlot(a.$slots,"default",{},void 0,!0)])]))}}),Yh=$e(qh,[["__scopeId","data-v-10a9b8c5"]]),kr="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M256 176v160M336 256H176' class='ionicon-fill-none ionicon-stroke-width'/></svg>",ed="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M256 112v288M400 256H112' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Qh="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm0 319.91a20 20 0 1120-20 20 20 0 01-20 20zm21.72-201.15l-5.74 122a16 16 0 01-32 0l-5.74-121.94v-.05a21.74 21.74 0 1143.44 0z'/></svg>",td="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path d='M250.26 166.05L256 288l5.73-121.95a5.74 5.74 0 00-5.79-6h0a5.74 5.74 0 00-5.68 6z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M256 367.91a20 20 0 1120-20 20 20 0 01-20 20z'/></svg>",ev="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M244 400L100 256l144-144M120 256h292' class='ionicon-fill-none'/></svg>",tv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M268 112l144 144-144 144M392 256H100' class='ionicon-fill-none'/></svg>",lc="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256L272 88v96C103.57 184 64 304.77 64 424c48.61-62.24 91.6-96 208-96v96z' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",sc="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M240 424v-96c116.4 0 159.39 33.76 208 96 0-119.23-39.57-240-208-240V88L64 256z' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",ui="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M452.37 59.63h0a40.49 40.49 0 00-57.26 0L184 294.74c23.08 4.7 46.12 27.29 49.26 49.26l219.11-227.11a40.49 40.49 0 000-57.26zM138 336c-29.88 0-54 24.5-54 54.86 0 23.95-20.88 36.57-36 36.57C64.56 449.74 92.82 464 120 464c39.78 0 72-32.73 72-73.14 0-30.36-24.12-54.86-54-54.86z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",av="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M350.54 148.68l-26.62-42.06C318.31 100.08 310.62 96 302 96h-92c-8.62 0-16.31 4.08-21.92 10.62l-26.62 42.06C155.85 155.23 148.62 160 140 160H80a32 32 0 00-32 32v192a32 32 0 0032 32h352a32 32 0 0032-32V192a32 32 0 00-32-32h-59c-8.65 0-16.85-4.77-22.46-11.32z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='256' cy='272' r='80' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M124 158v-22h-24v22' class='ionicon-fill-none ionicon-stroke-width'/></svg>",im="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm108.25 138.29l-134.4 160a16 16 0 01-12 5.71h-.27a16 16 0 01-11.89-5.3l-57.6-64a16 16 0 1123.78-21.4l45.29 50.32 122.59-145.91a16 16 0 0124.5 20.58z'/></svg>",rm="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M416 128L192 384l-96-96' class='ionicon-fill-none ionicon-stroke-width'/></svg>",dc="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M328 112L184 256l144 144' class='ionicon-fill-none'/></svg>",nv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M112 184l144 144 144-144' class='ionicon-fill-none'/></svg>",ov="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M184 112l144 144-144 144' class='ionicon-fill-none'/></svg>",cc="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M184 112l144 144-144 144' class='ionicon-fill-none'/></svg>",Yn="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M368 368L144 144M368 144L144 368' class='ionicon-fill-none ionicon-stroke-width'/></svg>",uc="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M320 367.79h76c55 0 100-29.21 100-83.6s-53-81.47-96-83.6c-8.89-85.06-71-136.8-144-136.8-69 0-113.44 45.79-128 91.2-60 5.7-112 43.88-112 106.4s54 106.4 120 106.4h56' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M320 255.79l-64-64-64 64M256 448.21V207.79' class='ionicon-fill-none ionicon-stroke-width'/></svg>",iv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='256' cy='184' r='120' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='344' cy='328' r='120' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='168' cy='328' r='120' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Cn="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M430.11 347.9c-6.6-6.1-16.3-7.6-24.6-9-11.5-1.9-15.9-4-22.6-10-14.3-12.7-14.3-31.1 0-43.8l30.3-26.9c46.4-41 46.4-108.2 0-149.2-34.2-30.1-80.1-45-127.8-45-55.7 0-113.9 20.3-158.8 60.1-83.5 73.8-83.5 194.7 0 268.5 41.5 36.7 97.5 55 152.9 55.4h1.7c55.4 0 110-17.9 148.8-52.4 14.4-12.7 11.99-36.6.1-47.7z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='144' cy='208' r='32'/><circle cx='152' cy='311' r='32'/><circle cx='224' cy='144' r='32'/><circle cx='256' cy='367' r='48'/><circle cx='328' cy='144' r='32'/></svg>",rv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M304 416V304h112M314.2 314.23L432 432M208 96v112H96M197.8 197.77L80 80M416 208H304V96M314.23 197.8L432 80M96 304h112v112M197.77 314.2L80 432' class='ionicon-fill-none ionicon-stroke-width'/></svg>",ai="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='256' cy='256' r='208' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M256 464c-114.88 0-208-93.12-208-208S141.12 48 256 48z'/></svg>",ms="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><rect x='128' y='128' width='336' height='336' rx='57' ry='57' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M383.5 128l.5-24a56.16 56.16 0 00-56-56H112a64.19 64.19 0 00-64 64v216a56.16 56.16 0 0056 56h24' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",lv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M384 224v184a40 40 0 01-40 40H104a40 40 0 01-40-40V168a40 40 0 0140-40h167.48' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M459.94 53.25a16.06 16.06 0 00-23.22-.56L424.35 65a8 8 0 000 11.31l11.34 11.32a8 8 0 0011.34 0l12.06-12c6.1-6.09 6.67-16.01.85-22.38zM399.34 90L218.82 270.2a9 9 0 00-2.31 3.93L208.16 299a3.91 3.91 0 004.86 4.86l24.85-8.35a9 9 0 003.93-2.31L422 112.66a9 9 0 000-12.66l-9.95-10a9 9 0 00-12.71 0z'/></svg>",mc="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M144 48v272a48 48 0 0048 48h272' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M368 304V192a48 48 0 00-48-48H208M368 368v96M144 144H48' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Fr="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='104' cy='152' r='56' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='104' cy='360' r='56' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M157 175l-11 15 37 15s3.46-6.42 7-10z' stroke-linecap='square' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path d='M154.17 334.43L460 162c-2.5-6.7-28-12-64-4-29.12 6.47-121.16 29.05-159.16 56.05C205.85 236.06 227 272 192 298c-25.61 19-44.43 22.82-44.43 22.82zM344.47 278.24L295 306.67c14.23 6.74 65.54 33.27 117 36.33 14.92.89 30 .39 39-6z' stroke-linecap='round' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='256' cy='240' r='32' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Fo="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M336 176h40a40 40 0 0140 40v208a40 40 0 01-40 40H136a40 40 0 01-40-40V216a40 40 0 0140-40h40' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M176 272l80 80 80-80M256 48v288' class='ionicon-fill-none ionicon-stroke-width'/></svg>",sv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='256' cy='256' r='32' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='416' cy='256' r='32' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='96' cy='256' r='32' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",dv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M432 320v112H320M421.8 421.77L304 304M80 192V80h112M90.2 90.23L208 208M320 80h112v112M421.77 90.2L304 208M192 432H80V320M90.23 421.8L208 304' class='ionicon-fill-none ionicon-stroke-width'/></svg>",cv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M432 320v112H320M421.8 421.77L304 304M80 192V80h112M90.2 90.23L208 208M320 80h112v112M421.77 90.2L304 208M192 432H80V320M90.23 421.8L208 304' class='ionicon-fill-none ionicon-stroke-width'/></svg>",uv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M432 448a15.92 15.92 0 01-11.31-4.69l-352-352a16 16 0 0122.62-22.62l352 352A16 16 0 01432 448zM255.66 384c-41.49 0-81.5-12.28-118.92-36.5-34.07-22-64.74-53.51-88.7-91v-.08c19.94-28.57 41.78-52.73 65.24-72.21a2 2 0 00.14-2.94L93.5 161.38a2 2 0 00-2.71-.12c-24.92 21-48.05 46.76-69.08 76.92a31.92 31.92 0 00-.64 35.54c26.41 41.33 60.4 76.14 98.28 100.65C162 402 207.9 416 255.66 416a239.13 239.13 0 0075.8-12.58 2 2 0 00.77-3.31l-21.58-21.58a4 4 0 00-3.83-1 204.8 204.8 0 01-51.16 6.47zM490.84 238.6c-26.46-40.92-60.79-75.68-99.27-100.53C349 110.55 302 96 255.66 96a227.34 227.34 0 00-74.89 12.83 2 2 0 00-.75 3.31l21.55 21.55a4 4 0 003.88 1 192.82 192.82 0 0150.21-6.69c40.69 0 80.58 12.43 118.55 37 34.71 22.4 65.74 53.88 89.76 91a.13.13 0 010 .16 310.72 310.72 0 01-64.12 72.73 2 2 0 00-.15 2.95l19.9 19.89a2 2 0 002.7.13 343.49 343.49 0 0068.64-78.48 32.2 32.2 0 00-.1-34.78z'/><path d='M256 160a95.88 95.88 0 00-21.37 2.4 2 2 0 00-1 3.38l112.59 112.56a2 2 0 003.38-1A96 96 0 00256 160zM165.78 233.66a2 2 0 00-3.38 1 96 96 0 00115 115 2 2 0 001-3.38z'/></svg>",mi="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M255.66 112c-77.94 0-157.89 45.11-220.83 135.33a16 16 0 00-.27 17.77C82.92 340.8 161.8 400 255.66 400c92.84 0 173.34-59.38 221.79-135.25a16.14 16.14 0 000-17.47C428.89 172.28 347.8 112 255.66 112z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='256' cy='256' r='80' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",pc="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M80 464V68.14a8 8 0 014-6.9C91.81 56.66 112.92 48 160 48c64 0 145 48 192 48a199.53 199.53 0 0077.23-15.77 2 2 0 012.77 1.85v219.36a4 4 0 01-2.39 3.65C421.37 308.7 392.33 320 352 320c-48 0-128-32-192-32s-80 16-80 16' stroke-linecap='round' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",zl="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M315.27 33L96 304h128l-31.51 173.23a2.36 2.36 0 002.33 2.77h0a2.36 2.36 0 001.89-.95L416 208H288l31.66-173.25a2.45 2.45 0 00-2.44-2.75h0a2.42 2.42 0 00-1.95 1z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",mv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M496 152a56 56 0 00-56-56H220.11a23.89 23.89 0 01-13.31-4L179 73.41A55.77 55.77 0 00147.89 64H72a56 56 0 00-56 56v48a8 8 0 008 8h464a8 8 0 008-8zM16 392a56 56 0 0056 56h368a56 56 0 0056-56V216a8 8 0 00-8-8H24a8 8 0 00-8 8z'/></svg>",pv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='129' cy='96' r='48' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='129' cy='416' r='48' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M129 144v224' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='385' cy='288' r='48' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M129 144c0 96 112 144 208 144' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",jl="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M432 112V96a48.14 48.14 0 00-48-48H64a48.14 48.14 0 00-48 48v256a48.14 48.14 0 0048 48h16' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><rect x='96' y='128' width='400' height='336' rx='45.99' ry='45.99' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><ellipse cx='372.92' cy='219.64' rx='30.77' ry='30.55' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path d='M342.15 372.17L255 285.78a30.93 30.93 0 00-42.18-1.21L96 387.64M265.23 464l118.59-117.73a31 31 0 0141.46-1.87L496 402.91' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",fv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M248 64C146.39 64 64 146.39 64 248s82.39 184 184 184 184-82.39 184-184S349.61 64 248 64z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M220 220h32v116' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-miterlimit='10' d='M208 340h88' class='ionicon-fill-none ionicon-stroke-width'/><path d='M248 130a26 26 0 1026 26 26 26 0 00-26-26z'/></svg>",hv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M368 128h80M64 128h240M368 384h80M64 384h240M208 256h240M64 256h80' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='336' cy='128' r='32' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='176' cy='256' r='32' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='336' cy='384' r='32' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",vv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M208 432h-48a16 16 0 01-16-16V96a16 16 0 0116-16h48a16 16 0 0116 16v320a16 16 0 01-16 16zM352 432h-48a16 16 0 01-16-16V96a16 16 0 0116-16h48a16 16 0 0116 16v320a16 16 0 01-16 16z'/></svg>",gv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm-32 272a16 16 0 01-32 0V192a16 16 0 0132 0zm96 0a16 16 0 01-32 0V192a16 16 0 0132 0z'/></svg>",lm="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-miterlimit='10' d='M208 192v128M304 192v128' class='ionicon-fill-none ionicon-stroke-width'/></svg>",ad="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M176 96h16v320h-16zM320 96h16v320h-16z' class='ionicon-fill-none ionicon-stroke-width'/></svg>",bv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M133 440a35.37 35.37 0 01-17.5-4.67c-12-6.8-19.46-20-19.46-34.33V111c0-14.37 7.46-27.53 19.46-34.33a35.13 35.13 0 0135.77.45l247.85 148.36a36 36 0 010 61l-247.89 148.4A35.5 35.5 0 01133 440z'/></svg>",yv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M30.71 229.47l188.87-113a30.54 30.54 0 0131.09-.39 33.74 33.74 0 0116.76 29.47v79.05l180.72-108.16a30.54 30.54 0 0131.09-.39A33.74 33.74 0 01496 145.52v221A33.73 33.73 0 01479.24 396a30.54 30.54 0 01-31.09-.39L267.43 287.4v79.08A33.73 33.73 0 01250.67 396a30.54 30.54 0 01-31.09-.39l-188.87-113a31.27 31.27 0 010-53z'/></svg>",wv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M480 145.52v221c0 13.28-13 21.72-23.63 15.35L267.5 268.8c-9.24-5.53-9.24-20.07 0-25.6l188.87-113C467 123.8 480 132.24 480 145.52zM251.43 145.52v221c0 13.28-13 21.72-23.63 15.35L38.93 268.8c-9.24-5.53-9.24-20.07 0-25.6l188.87-113c10.64-6.4 23.63 2.04 23.63 15.32z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",kv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm74.77 217.3l-114.45 69.14a10.78 10.78 0 01-16.32-9.31V186.87a10.78 10.78 0 0116.32-9.31l114.45 69.14a10.89 10.89 0 010 18.6z'/></svg>",sm="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path d='M216.32 334.44l114.45-69.14a10.89 10.89 0 000-18.6l-114.45-69.14a10.78 10.78 0 00-16.32 9.31v138.26a10.78 10.78 0 0016.32 9.31z'/></svg>",_v="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M481.29 229.47l-188.87-113a30.54 30.54 0 00-31.09-.39 33.74 33.74 0 00-16.76 29.47v79.05L63.85 116.44a30.54 30.54 0 00-31.09-.39A33.74 33.74 0 0016 145.52v221A33.74 33.74 0 0032.76 396a30.54 30.54 0 0031.09-.39L244.57 287.4v79.08A33.74 33.74 0 00261.33 396a30.54 30.54 0 0031.09-.39l188.87-113a31.27 31.27 0 000-53z'/></svg>",Ev="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M32 145.52v221c0 13.28 13 21.72 23.63 15.35l188.87-113c9.24-5.53 9.24-20.07 0-25.6l-188.87-113C45 123.8 32 132.24 32 145.52zM260.57 145.52v221c0 13.28 13 21.72 23.63 15.35l188.87-113c9.24-5.53 9.24-20.07 0-25.6l-188.87-113c-10.64-6.47-23.63 1.97-23.63 15.25z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",nd="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M112 111v290c0 17.44 17 28.52 31 20.16l247.9-148.37c12.12-7.25 12.12-26.33 0-33.58L143 90.84c-14-8.36-31 2.72-31 20.16z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Sv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M400 111v290c0 17.44-17 28.52-31 20.16L121.09 272.79c-12.12-7.25-12.12-26.33 0-33.58L369 90.84c14-8.36 31 2.72 31 20.16z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-miterlimit='10' d='M112 80v352' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Cv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M112 111v290c0 17.44 17 28.52 31 20.16l247.9-148.37c12.12-7.25 12.12-26.33 0-33.58L143 90.84c-14-8.36-31 2.72-31 20.16z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-miterlimit='10' d='M400 80v352' class='ionicon-fill-none ionicon-stroke-width'/></svg>",io="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M320 146s24.36-12-64-12a160 160 0 10160 160' stroke-linecap='round' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M256 58l80 80-80 80' class='ionicon-fill-none ionicon-stroke-width'/></svg>",xv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M336 256H176' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Nv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M400 256H112' class='ionicon-fill-none ionicon-stroke-width'/></svg>",fc="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M304 96h112v112M405.77 106.2L111.98 400.02M208 416H96V304' class='ionicon-fill-none ionicon-stroke-width'/></svg>",el="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M380.93 57.37A32 32 0 00358.3 48H94.22A46.21 46.21 0 0048 94.22v323.56A46.21 46.21 0 0094.22 464h323.56A46.36 46.36 0 00464 417.78V153.7a32 32 0 00-9.37-22.63zM256 416a64 64 0 1164-64 63.92 63.92 0 01-64 64zm48-224H112a16 16 0 01-16-16v-64a16 16 0 0116-16h192a16 16 0 0116 16v64a16 16 0 01-16 16z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Vv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='256' cy='256' r='48'/><path d='M470.39 300l-.47-.38-31.56-24.75a16.11 16.11 0 01-6.1-13.33v-11.56a16 16 0 016.11-13.22L469.92 212l.47-.38a26.68 26.68 0 005.9-34.06l-42.71-73.9a1.59 1.59 0 01-.13-.22A26.86 26.86 0 00401 92.14l-.35.13-37.1 14.93a15.94 15.94 0 01-14.47-1.29q-4.92-3.1-10-5.86a15.94 15.94 0 01-8.19-11.82l-5.59-39.59-.12-.72A27.22 27.22 0 00298.76 26h-85.52a26.92 26.92 0 00-26.45 22.39l-.09.56-5.57 39.67a16 16 0 01-8.13 11.82 175.21 175.21 0 00-10 5.82 15.92 15.92 0 01-14.43 1.27l-37.13-15-.35-.14a26.87 26.87 0 00-32.48 11.34l-.13.22-42.77 73.95a26.71 26.71 0 005.9 34.1l.47.38 31.56 24.75a16.11 16.11 0 016.1 13.33v11.56a16 16 0 01-6.11 13.22L42.08 300l-.47.38a26.68 26.68 0 00-5.9 34.06l42.71 73.9a1.59 1.59 0 01.13.22 26.86 26.86 0 0032.45 11.3l.35-.13 37.07-14.93a15.94 15.94 0 0114.47 1.29q4.92 3.11 10 5.86a15.94 15.94 0 018.19 11.82l5.56 39.59.12.72A27.22 27.22 0 00213.24 486h85.52a26.92 26.92 0 0026.45-22.39l.09-.56 5.57-39.67a16 16 0 018.18-11.82c3.42-1.84 6.76-3.79 10-5.82a15.92 15.92 0 0114.43-1.27l37.13 14.95.35.14a26.85 26.85 0 0032.48-11.34 2.53 2.53 0 01.13-.22l42.71-73.89a26.7 26.7 0 00-5.89-34.11zm-134.48-40.24a80 80 0 11-83.66-83.67 80.21 80.21 0 0183.66 83.67z'/></svg>",Wl="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M400 304l48 48-48 48M400 112l48 48-48 48M64 352h85.19a80 80 0 0066.56-35.62L256 256' class='ionicon-fill-none ionicon-stroke-width'/><path d='M64 160h85.19a80 80 0 0166.56 35.62l80.5 120.76A80 80 0 00362.81 352H416M416 160h-53.19a80 80 0 00-66.56 35.62L288 208' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Sn="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' class='ionicon'><path d='M259.92 262.91L216.4 149.77a9 9 0 00-16.8 0l-43.52 113.14a9 9 0 01-5.17 5.17L37.77 311.6a9 9 0 000 16.8l113.14 43.52a9 9 0 015.17 5.17l43.52 113.14a9 9 0 0016.8 0l43.52-113.14a9 9 0 015.17-5.17l113.14-43.52a9 9 0 000-16.8l-113.14-43.52a9 9 0 01-5.17-5.17zM108 68L88 16 68 68 16 88l52 20 20 52 20-52 52-20-52-20zM426.67 117.33L400 48l-26.67 69.33L304 144l69.33 26.67L400 240l26.67-69.33L496 144l-69.33-26.67z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",ni="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-miterlimit='10' d='M256 48v48M256 416v48M403.08 108.92l-33.94 33.94M142.86 369.14l-33.94 33.94M464 256h-48M96 256H48M403.08 403.08l-33.94-33.94M142.86 142.86l-33.94-33.94' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='256' cy='256' r='80' stroke-linecap='round' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",hc="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M304 48l112 112-112 112M398.87 160H96M208 464L96 352l112-112M114 352h302' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Tv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M512 128v256a64.07 64.07 0 01-64 64H64a64.07 64.07 0 01-64-64V128a64.07 64.07 0 0164-64h384a64.07 64.07 0 0164 64zM32 384a32 32 0 0032 32h384a32 32 0 0032-32V128a32 32 0 00-32-32H64a32 32 0 00-32 32z'/><path d='M0 128a64.07 64.07 0 0164-64h384a64.07 64.07 0 0164 64v256a64.07 64.07 0 01-64 64H64a64.07 64.07 0 01-64-64V128m480 256V128a32 32 0 00-32-32H64a32 32 0 00-32 32v256a32 32 0 0032 32h384a32 32 0 0032-32m-16 0a16 16 0 01-16 16H64a16 16 0 01-16-16V128a16 16 0 0116-16h384a16 16 0 0116 16v256z'/></svg>",dm="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M32 415.5l120-320 120 320M230 303.5H74M326 239.5c12.19-28.69 41-48 74-48h0c46 0 80 32 80 80v144' class='ionicon-fill-none ionicon-stroke-width'/><path d='M320 358.5c0 36 26.86 58 60 58 54 0 100-27 100-106v-15c-20 0-58 1-92 5-32.77 3.86-68 19-68 58z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Dr="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M112 112l20 320c.95 18.49 14.4 32 32 32h184c17.67 0 30.87-13.51 32-32l20-320' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-miterlimit='10' d='M80 112h352' class='ionicon-stroke-width'/><path d='M192 112V72h0a23.93 23.93 0 0124-24h80a23.93 23.93 0 0124 24h0v40M256 176v224M184 176l8 224M328 176l-8 224' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",cm="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M374.79 308.78L457.5 367a16 16 0 0022.5-14.62V159.62A16 16 0 00457.5 145l-82.71 58.22A16 16 0 00368 216.3v79.4a16 16 0 006.79 13.08z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M268 384H84a52.15 52.15 0 01-52-52V180a52.15 52.15 0 0152-52h184.48A51.68 51.68 0 01320 179.52V332a52.15 52.15 0 01-52 52z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Bv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M232 416a23.88 23.88 0 01-14.2-4.68 8.27 8.27 0 01-.66-.51L125.76 336H56a24 24 0 01-24-24V200a24 24 0 0124-24h69.75l91.37-74.81a8.27 8.27 0 01.66-.51A24 24 0 01256 120v272a24 24 0 01-24 24zm-106.18-80zm-.27-159.86zM320 336a16 16 0 01-14.29-23.19c9.49-18.87 14.3-38 14.3-56.81 0-19.38-4.66-37.94-14.25-56.73a16 16 0 0128.5-14.54C346.19 208.12 352 231.44 352 256c0 23.86-6 47.81-17.7 71.19A16 16 0 01320 336z'/><path d='M368 384a16 16 0 01-13.86-24C373.05 327.09 384 299.51 384 256c0-44.17-10.93-71.56-29.82-103.94a16 16 0 0127.64-16.12C402.92 172.11 416 204.81 416 256c0 50.43-13.06 83.29-34.13 120a16 16 0 01-13.87 8z'/><path d='M416 432a16 16 0 01-13.39-24.74C429.85 365.47 448 323.76 448 256c0-66.5-18.18-108.62-45.49-151.39a16 16 0 1127-17.22C459.81 134.89 480 181.74 480 256c0 64.75-14.66 113.63-50.6 168.74A16 16 0 01416 432z'/></svg>",Iv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M296 416.19a23.92 23.92 0 01-14.21-4.69l-.66-.51-91.46-75H120a24 24 0 01-24-24V200a24 24 0 0124-24h69.65l91.46-75 .66-.51A24 24 0 01320 119.83v272.34a24 24 0 01-24 24zM384 336a16 16 0 01-14.29-23.18c9.49-18.9 14.3-38 14.3-56.82 0-19.36-4.66-37.92-14.25-56.73a16 16 0 0128.5-14.54C410.2 208.16 416 231.47 416 256c0 23.83-6 47.78-17.7 71.18A16 16 0 01384 336z'/></svg>",Mv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M264 416.19a23.92 23.92 0 01-14.21-4.69l-.66-.51-91.46-75H88a24 24 0 01-24-24V200a24 24 0 0124-24h69.65l91.46-75 .66-.51A24 24 0 01288 119.83v272.34a24 24 0 01-24 24zM352 336a16 16 0 01-14.29-23.18c9.49-18.9 14.3-38 14.3-56.82 0-19.36-4.66-37.92-14.25-56.73a16 16 0 0128.5-14.54C378.2 208.16 384 231.47 384 256c0 23.83-6 47.78-17.7 71.18A16 16 0 01352 336z'/><path d='M400 384a16 16 0 01-13.87-24C405 327.05 416 299.45 416 256c0-44.12-10.94-71.52-29.83-103.95A16 16 0 01413.83 136C434.92 172.16 448 204.88 448 256c0 50.36-13.06 83.24-34.12 120a16 16 0 01-13.88 8z'/></svg>",$v="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M157.65 192H88a8 8 0 00-8 8v112a8 8 0 008 8h69.65a16 16 0 0110.14 3.63l91.47 75a8 8 0 0012.74-6.46V119.83a8 8 0 00-12.74-6.44l-91.47 75a16 16 0 01-10.14 3.61zM352 320c9.74-19.41 16-40.81 16-64 0-23.51-6-44.4-16-64M400 368c19.48-34 32-64 32-112s-12-77.7-32-112' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Fv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-miterlimit='10' d='M416 432L64 80' class='ionicon-fill-none ionicon-stroke-width'/><path d='M243.33 98.86a23.89 23.89 0 00-25.55 1.82l-.66.51-28.52 23.35a8 8 0 00-.59 11.85l54.33 54.33a8 8 0 0013.66-5.66v-64.49a24.51 24.51 0 00-12.67-21.71zM251.33 335.29L96.69 180.69A16 16 0 0085.38 176H56a24 24 0 00-24 24v112a24 24 0 0024 24h69.76l92 75.31a23.9 23.9 0 0025.87 1.69A24.51 24.51 0 00256 391.45v-44.86a16 16 0 00-4.67-11.3zM352 256c0-24.56-5.81-47.87-17.75-71.27a16 16 0 10-28.5 14.55C315.34 218.06 320 236.62 320 256q0 4-.31 8.13a8 8 0 002.32 6.25l14.36 14.36a8 8 0 0013.55-4.31A146 146 0 00352 256zM416 256c0-51.18-13.08-83.89-34.18-120.06a16 16 0 00-27.64 16.12C373.07 184.44 384 211.83 384 256c0 23.83-3.29 42.88-9.37 60.65a8 8 0 001.9 8.26L389 337.4a8 8 0 0013.13-2.79C411 311.76 416 287.26 416 256z'/><path d='M480 256c0-74.25-20.19-121.11-50.51-168.61a16 16 0 10-27 17.22C429.82 147.38 448 189.5 448 256c0 46.19-8.43 80.27-22.43 110.53a8 8 0 001.59 9l11.92 11.92a8 8 0 0012.92-2.16C471.6 344.9 480 305 480 256z'/></svg>",Dv="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-miterlimit='10' d='M416 432L64 80' class='ionicon-fill-none ionicon-stroke-width'/><path d='M224 136.92v33.8a4 4 0 001.17 2.82l24 24a4 4 0 006.83-2.82v-74.15a24.53 24.53 0 00-12.67-21.72 23.91 23.91 0 00-25.55 1.83 8.27 8.27 0 00-.66.51l-31.94 26.15a4 4 0 00-.29 5.92l17.05 17.06a4 4 0 005.37.26zM224 375.08l-78.07-63.92a32 32 0 00-20.28-7.16H64v-96h50.72a4 4 0 002.82-6.83l-24-24a4 4 0 00-2.82-1.17H56a24 24 0 00-24 24v112a24 24 0 0024 24h69.76l91.36 74.8a8.27 8.27 0 00.66.51 23.93 23.93 0 0025.85 1.69A24.49 24.49 0 00256 391.45v-50.17a4 4 0 00-1.17-2.82l-24-24a4 4 0 00-6.83 2.82zM125.82 336zM352 256c0-24.56-5.81-47.88-17.75-71.27a16 16 0 00-28.5 14.54C315.34 218.06 320 236.62 320 256q0 4-.31 8.13a8 8 0 002.32 6.25l19.66 19.67a4 4 0 006.75-2A146.89 146.89 0 00352 256zM416 256c0-51.19-13.08-83.89-34.18-120.06a16 16 0 00-27.64 16.12C373.07 184.44 384 211.83 384 256c0 23.83-3.29 42.88-9.37 60.65a8 8 0 001.9 8.26l16.77 16.76a4 4 0 006.52-1.27C410.09 315.88 416 289.91 416 256z'/><path d='M480 256c0-74.26-20.19-121.11-50.51-168.61a16 16 0 10-27 17.22C429.82 147.38 448 189.5 448 256c0 47.45-8.9 82.12-23.59 113a4 4 0 00.77 4.55L443 391.39a4 4 0 006.4-1C470.88 348.22 480 307 480 256z'/></svg>",Av="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M85.57 446.25h340.86a32 32 0 0028.17-47.17L284.18 82.58c-12.09-22.44-44.27-22.44-56.36 0L57.4 399.08a32 32 0 0028.17 47.17z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M250.26 195.39l5.74 122 5.73-121.95a5.74 5.74 0 00-5.79-6h0a5.74 5.74 0 00-5.68 5.95z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M256 397.25a20 20 0 1120-20 20 20 0 01-20 20z'/></svg>",lr="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M400 320c0 88.37-55.63 144-144 144s-144-55.63-144-144c0-94.83 103.23-222.85 134.89-259.88a12 12 0 0118.23 0C296.77 97.15 400 225.17 400 320z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path d='M344 328a72 72 0 01-72 72' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const vc=()=>{};function Rv(o,a){function t(...n){return new Promise((i,r)=>{Promise.resolve(o(()=>a.apply(this,n),{fn:a,thisArg:this,args:n})).then(i).catch(r)})}return t}function Lv(o,a={}){let t,n,i=vc;const r=d=>{clearTimeout(d),i(),i=vc};let l;return d=>{const c=e.toValue(o),u=e.toValue(a.maxWait);return t&&r(t),c<=0||u!==void 0&&u<=0?(n&&(r(n),n=null),Promise.resolve(d())):new Promise((m,p)=>{i=a.rejectOnCancel?p:m,l=d,u&&!n&&(n=setTimeout(()=>{t&&r(t),n=null,m(l())},u)),t=setTimeout(()=>{n&&r(n),n=null,m(d())},c)})}}function Pv(o,a=200,t={}){return Rv(Lv(a,t),o)}const oi=new Map;function Uv(o){const a=e.getCurrentScope();function t(s){var d;const c=oi.get(o)||new Set;c.add(s),oi.set(o,c);const u=()=>i(s);return(d=a==null?void 0:a.cleanups)==null||d.push(u),u}function n(s){function d(...c){i(d),s(...c)}return t(d)}function i(s){const d=oi.get(o);d&&(d.delete(s),d.size||r())}function r(){oi.delete(o)}function l(s,d){var c;(c=oi.get(o))==null||c.forEach(u=>u(s,d))}return{on:t,once:n,off:i,emit:l,reset:r}}function um(){var r,l;const o=typeof window<"u"&&"Capacitor"in window&&((l=(r=window.Capacitor)==null?void 0:r.isNativePlatform)==null?void 0:l.call(r));return{selection:()=>{var s,d;if(o)try{const c=(d=(s=window.Capacitor)==null?void 0:s.Plugins)==null?void 0:d.Haptics;c&&c.impact({style:"LIGHT"})}catch{}else"vibrate"in navigator&&navigator.vibrate(10)},success:()=>{var s,d;if(o)try{const c=(d=(s=window.Capacitor)==null?void 0:s.Plugins)==null?void 0:d.Haptics;c&&c.impact({style:"MEDIUM"})}catch{}else"vibrate"in navigator&&navigator.vibrate(30)},error:()=>{var s,d;if(o)try{const c=(d=(s=window.Capacitor)==null?void 0:s.Plugins)==null?void 0:d.Haptics;c&&c.impact({style:"HEAVY"})}catch{}else"vibrate"in navigator&&navigator.vibrate([50,50,50])},notification:()=>{var s,d;if(o)try{const c=(d=(s=window.Capacitor)==null?void 0:s.Plugins)==null?void 0:d.Haptics;c&&c.notification({type:"SUCCESS"})}catch{}else"vibrate"in navigator&&navigator.vibrate([20,100,20])}}}function tl(o,a={}){const t=e.ref(new Set),n=e.ref(new Map),i=e.ref(null),r=e.ref(-1),l=e.ref(a.scopeKey!==void 0?e.toValue(a.scopeKey):"default"),s=e.ref(!1),d=e.ref(null),c=Uv("media-selection"),u=um(),m=()=>{if(a.currentPage===void 0)return null;const O=e.toValue(a.currentPage);return typeof O=="number"&&Number.isFinite(O)?O:null};function p(O){t.value=O,n.value=new Map(Array.from(n.value.entries()).filter(([K])=>O.has(K)))}function f(O){if(n.value.has(O))return;const K=new Map(n.value);K.set(O,{uuid:O,selectedAt:Date.now(),page:m()}),n.value=K}const h=e.computed(()=>o.value.filter(O=>t.value.has(O.uuid))),v=e.computed(()=>t.value.size),k=e.computed(()=>Array.from(n.value.values()).sort((O,K)=>O.selectedAt-K.selectedAt).map(O=>O.uuid)),y=e.computed(()=>Math.max(0,v.value-h.value.length)),w=e.computed(()=>{const O=new Map;for(const K of n.value.values())K.page!==null&&O.set(K.page,(O.get(K.page)??0)+1);return O});e.watch(t,O=>{c.emit({type:"selection:changed",count:O.size,selectedIds:Array.from(O)})}),a.scopeKey!==void 0&&e.watch(()=>e.toValue(a.scopeKey),(O,K)=>{O!==void 0&&O!==K&&z(O)});const g=e.computed(()=>o.value.length>0&&o.value.every(O=>t.value.has(O.uuid))),b=e.computed(()=>o.value.some(O=>t.value.has(O.uuid)));function R(O){return t.value.has(O)}function V(O){const K=new Set(t.value),de=K.size===0;K.add(O),f(O),t.value=K,i.value=O,r.value=o.value.findIndex(Ne=>Ne.uuid===O),de&&u.selection()}function I(O){const K=new Set(t.value);K.delete(O);const de=new Map(n.value);de.delete(O),n.value=de,t.value=K,i.value===O&&(i.value=null,r.value=-1)}function x(O){if(t.value.has(O)){I(O);return}V(O)}function T(){const O=new Set(t.value);for(const K of o.value)O.add(K.uuid),f(K.uuid);t.value=O}function $(){t.value=new Set,n.value=new Map,i.value=null,r.value=-1,s.value=!1,d.value=null}function S(){if(g.value){$();return}T()}function B(O,K){const de=o.value.findIndex(Ne=>Ne.uuid===O);if(de!==-1){if(K!=null&&K.shiftKey&&r.value!==-1){const Ne=Math.min(r.value,de),ce=Math.max(r.value,de),le=new Set(t.value);for(let W=Ne;W<=ce;W++){const C=o.value[W];C!==void 0&&(le.add(C.uuid),f(C.uuid))}t.value=le;return}x(O)}}function _(){if(o.value.length===0)return;let O=r.value+1;O>=o.value.length&&(O=0),$();const K=o.value[O];K!==void 0&&V(K.uuid)}function A(){if(o.value.length===0)return;let O=r.value-1;O<0&&(O=o.value.length-1),$();const K=o.value[O];K!==void 0&&V(K.uuid)}function P(O){switch(O.key){case"ArrowDown":O.preventDefault(),_();break;case"ArrowUp":O.preventDefault(),A();break;case"a":(O.ctrlKey||O.metaKey)&&(O.preventDefault(),T());break;case"Escape":O.preventDefault(),$();break;case" ":i.value&&(O.preventDefault(),x(i.value));break}}async function D(O){var de;if(v.value===0||l.value===O)return!0;const K=(de=a.confirmScopeChange)==null?void 0:de.call(a,{from:l.value,to:O,selectedCount:v.value});return K===void 0?!0:await K}async function z(O){return l.value===O?!0:await D(O)?(l.value=O,$(),!0):!1}async function M(){if(!a.fetchMatchingUuids){const K={uuids:o.value.map(de=>de.uuid),overCap:!1,totalMatching:o.value.length};return Z(K),K}const O=await a.fetchMatchingUuids();return Z(O),O}function Z(O){const K=new Set(O.uuids),de=new Map,Ne=Date.now();O.uuids.forEach((ce,le)=>{de.set(ce,{uuid:ce,selectedAt:Ne+le,page:m()})}),p(K),n.value=de,s.value=O.overCap,d.value=O.totalMatching}return{selectedIds:e.computed(()=>t.value),selectedRecords:e.computed(()=>n.value),selectedItems:h,selectedCount:v,orderedIds:k,crossPageCount:y,selectedPages:w,overCap:e.computed(()=>s.value),totalMatching:e.computed(()=>d.value),activeScopeKey:e.computed(()=>l.value),isAllSelected:g,isSomeSelected:b,lastSelectedId:e.computed(()=>i.value),isSelected:R,toggle:x,select:V,deselect:I,selectAll:T,clear:$,toggleAll:S,rangeSelect:B,selectAcrossAllPages:M,setScopeKey:z,canChangeScope:D,selectNext:_,selectPrevious:A,handleKeydown:P,selectionBus:c}}const Ov={class:"flex items-center justify-between w-full px-4"},zv={class:"p-4"},jv={key:0,class:"mb-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg"},Wv={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"},Hv=["value"],Zv={class:"flex gap-2 mt-4"},Gv={class:"flex justify-end mb-4"},Xv={key:1,class:"flex justify-center items-center h-64"},Kv={key:2,class:"flex flex-col items-center justify-center h-64 text-center"},Jv={class:"text-sm text-theme-secondary"},qv={key:0},Yv={class:"mb-4"},Qv={class:"mb-4"},eg={class:"flex gap-2"},tg={class:"flex items-center justify-between px-4 py-2"},ag={class:"text-sm text-theme-secondary"},ng={key:0},og={key:0},ig={key:1},rg={class:"flex gap-2"},lg=e.defineComponent({__name:"AdminMediaBrowser",props:{isOpen:{type:Boolean},selectionMode:{default:"single"},selectedItems:{default:()=>[]},modelType:{},modelId:{},collection:{default:"images"},maxSelection:{}},emits:["close","confirm"],setup(o,{emit:a}){const t=o,n=a,i=e.ref("recent"),r=e.ref("grid"),l=e.ref(""),s=e.ref(!1),d=e.ref([]),{selectedItems:c}=e.toRefs(t),u=e.ref(new Set(c.value)),m=e.ref(!1),p=e.ref({}),f=e.ref(["images","documents","videos"]),h=e.ref(1),v=e.ref(!0),k=e.ref(!1),y=Ju(),w=tl(d);function g(W){var be;const C=W.conversion_urls||{},U=W.proxy_url||W.original_url||W.url||"",j=C.thumb||C.preview||W.preview_url||W.thumbnail_url||U,re=W.custom_properties||{},ue=re.width,Xe=re.height;return{...W,uuid:W.uuid,name:W.name||W.file_name,file_name:W.file_name,filename:W.file_name,mime_type:W.mime_type,size:W.size,collection_name:W.collection_name||"images",disk:W.disk,original_url:U,url:U,thumbnail_url:j,conversions:W.conversions||{},conversion_urls:C,generated_conversions:W.generated_conversions||{},custom_properties:re,caption:W.caption||null,alt_text:W.alt_text||null,created_at:W.created_at,updated_at:W.updated_at,is_image:((be=W.mime_type)==null?void 0:be.startsWith("image/"))||!1,...typeof ue=="number"?{width:ue}:{},...typeof Xe=="number"?{height:Xe}:{},...W.formatted_size!==void 0?{formatted_size:W.formatted_size}:{}}}e.watch(()=>t.selectedItems,W=>{u.value=new Set(W),w.clear(),W.forEach(C=>w.select(C))});const b=e.computed(()=>{var C;let W=d.value;return(C=p.value.types)!=null&&C.length&&(W=W.filter(U=>{var re,ue;const j=(re=U.mime_type)==null?void 0:re.split("/")[0];return(ue=p.value.types)==null?void 0:ue.includes(j)})),(p.value.sizeMin!==void 0||p.value.sizeMax!==void 0)&&(W=W.filter(U=>{const j=U.size/1048576;return!(p.value.sizeMin!==void 0&&j<p.value.sizeMin||p.value.sizeMax!==void 0&&j>p.value.sizeMax)})),W}),R=e.computed(()=>{var C;let W=0;return p.value.search&&W++,p.value.collection&&W++,(p.value.dateFrom||p.value.dateTo)&&W++,(C=p.value.types)!=null&&C.length&&(W+=p.value.types.length),(p.value.sizeMin!==void 0||p.value.sizeMax!==void 0)&&W++,W}),V=e.computed(()=>{const W=w.selectedCount.value;return W===0?"Select Media":`Select ${t.selectionMode==="multiple"?`${W} ${W===1?"Item":"Items"}`:"Item"}`}),I=e.computed(()=>{const W=w.selectedCount.value;return!!(W===0||t.selectionMode==="single"&&W>1||t.maxSelection&&W>t.maxSelection)}),x=e.computed(()=>{switch(i.value){case"recent":return"Recent Uploads";case"model":return"Model Media";case"library":return"Media Library";default:return"Media Browser"}});async function T(W=!0){W?(s.value=!0,d.value=[],h.value=1,v.value=!0):k.value=!0;try{const C={collection:p.value.collection||t.collection,per_page:24};switch((l.value||p.value.search)&&(C.search=l.value||p.value.search||""),p.value.dateFrom&&(C.from_date=p.value.dateFrom),p.value.dateTo&&(C.to_date=p.value.dateTo),i.value){case"recent":await y.fetchMedia(h.value,C),W?d.value=y.items.map(U=>g(U)):d.value=[...d.value,...y.items.map(U=>g(U))],v.value=y.currentPage<y.totalPages;break;case"model":if(t.modelType&&t.modelId){const U=await y.fetchModelMedia(t.modelType,t.modelId,C.collection,C.search);d.value=U?U.map(j=>g(j)):[],v.value=!1}break;case"library":await y.fetchMedia(h.value,C),W?d.value=y.items.map(U=>g(U)):d.value=[...d.value,...y.items.map(U=>g(U))],v.value=y.currentPage<y.totalPages;break}}catch{}finally{s.value=!1,k.value=!1}}async function $(W){if(!v.value||k.value){W!=null&&W.target&&W.target.complete();return}h.value++,await T(!1),W!=null&&W.target&&(W.target.complete(),v.value||(W.target.disabled=!0))}function S(W){return W==="recent"||W==="model"||W==="library"}function B(W){i.value=W,T()}function _(W){typeof W=="string"&&S(W)&&B(W)}async function A(W){t.selectionMode==="single"?(w.clear(),w.select(W.uuid)):(w.toggle(W.uuid),t.maxSelection&&w.selectedCount.value>t.maxSelection&&(w.deselect(W.uuid),await(await H.toastController.create({message:`Maximum ${t.maxSelection} items can be selected`,duration:2e3,color:"warning"})).present()))}function P(){n("confirm",w.selectedItems.value)}function D(){n("close")}function z(W){}const M=e.ref(null),Z=e.ref(!1);function O(W){M.value=W,Z.value=!0}function K(W){const C=d.value.findIndex(j=>j.uuid===W.uuid);C!==-1&&(d.value[C]=W);const U={};W.alt_text!==void 0&&(U.alt_text=W.alt_text),W.caption!==void 0&&(U.caption=W.caption),W.custom_properties!==void 0&&(U.custom_properties=W.custom_properties),y.updateMedia(W.uuid,U)}function de(){T()}function Ne(){p.value={},l.value="",T()}const ce=Pv(()=>{T(!0)},300);e.watch(l,()=>{t.isOpen&&ce()});async function le(W){try{await(await H.alertController.create({header:"Delete Media",message:"Are you sure you want to delete this media item?",buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"destructive",handler:async()=>{await y.deleteMedia(W),await T()}}]})).present()}catch{}}return e.watch(()=>t.isOpen,W=>{W&&T()}),e.onMounted(()=>{t.selectedItems.length>0&&t.selectedItems.forEach(W=>w.select(W))}),(W,C)=>{const U=e.resolveComponent("AdminMediaGrid"),j=e.resolveComponent("AdminMediaListItem");return e.openBlock(),e.createBlock(e.unref(H.IonModal),{"is-open":W.isOpen,onDidDismiss:D,"backdrop-dismiss":!1,class:"media-browser-modal"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(H.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonButton),{onClick:D},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(H.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(x.value),1)]),_:1})]),_:1}),e.createVNode(e.unref(H.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",Ov,[e.createVNode(e.unref(H.IonSegment),{value:i.value,onIonChange:C[0]||(C[0]=re=>_(re.detail.value)),class:"max-w-xs"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonSegmentButton),{value:"recent"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...C[15]||(C[15]=[e.createTextVNode("Recent",-1)])]),_:1})]),_:1}),t.modelType&&t.modelId?(e.openBlock(),e.createBlock(e.unref(H.IonSegmentButton),{key:0,value:"model"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...C[16]||(C[16]=[e.createTextVNode("Model",-1)])]),_:1})]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(H.IonSegmentButton),{value:"library"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...C[17]||(C[17]=[e.createTextVNode("Library",-1)])]),_:1})]),_:1})]),_:1},8,["value"]),e.createVNode(e.unref(H.IonButton),{fill:"clear",size:"small",onClick:C[1]||(C[1]=re=>m.value=!m.value),class:"relative"},{"icon-only":e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{name:"filter-outline"})]),default:e.withCtx(()=>[R.value>0?(e.openBlock(),e.createBlock(e.unref(H.IonBadge),{key:0,color:"primary",class:"absolute -top-1 -right-1 min-w-[20px] h-5 rounded-full flex items-center justify-center text-xs"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(R.value),1)]),_:1})):e.createCommentVNode("",!0)]),_:1})])]),_:1})]),_:1}),e.createVNode(e.unref(H.IonContent),null,{default:e.withCtx(()=>[e.createElementVNode("div",zv,[m.value?(e.openBlock(),e.createElementBlock("div",jv,[e.createElementVNode("div",Wv,[e.createElementVNode("div",null,[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...C[18]||(C[18]=[e.createTextVNode("Collection",-1)])]),_:1}),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":C[2]||(C[2]=re=>p.value.collection=re),class:"w-full p-2 border rounded"},[C[19]||(C[19]=e.createElementVNode("option",{value:""},"All Collections",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,re=>(e.openBlock(),e.createElementBlock("option",{key:re,value:re},e.toDisplayString(re),9,Hv))),128))],512),[[e.vModelSelect,p.value.collection]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...C[20]||(C[20]=[e.createTextVNode("From Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":C[3]||(C[3]=re=>p.value.dateFrom=re),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,p.value.dateFrom]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...C[21]||(C[21]=[e.createTextVNode("To Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":C[4]||(C[4]=re=>p.value.dateTo=re),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,p.value.dateTo]])])]),e.createElementVNode("div",Zv,[e.createVNode(e.unref(H.IonButton),{size:"small",onClick:de},{default:e.withCtx(()=>[...C[22]||(C[22]=[e.createTextVNode("Apply",-1)])]),_:1}),e.createVNode(e.unref(H.IonButton),{size:"small",fill:"clear",onClick:Ne},{default:e.withCtx(()=>[...C[23]||(C[23]=[e.createTextVNode("Clear",-1)])]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(e.unref(H.IonSearchbar),{modelValue:l.value,"onUpdate:modelValue":C[5]||(C[5]=re=>l.value=re),placeholder:"Search media...",debounce:300,class:"mb-4"},null,8,["modelValue"]),e.createElementVNode("div",Gv,[e.createVNode(e.unref(H.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonButton),{fill:r.value==="grid"?"solid":"clear",size:"small",onClick:C[6]||(C[6]=re=>r.value="grid")},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{name:"grid-outline"})]),_:1},8,["fill"]),e.createVNode(e.unref(H.IonButton),{fill:r.value==="list"?"solid":"clear",size:"small",onClick:C[7]||(C[7]=re=>r.value="list")},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{name:"list-outline"})]),_:1},8,["fill"])]),_:1})]),s.value?(e.openBlock(),e.createElementBlock("div",Xv,[e.createVNode(e.unref(H.IonSpinner),{name:"crescent"})])):b.value.length===0?(e.openBlock(),e.createElementBlock("div",Kv,[e.createVNode(e.unref(H.IonIcon),{name:"images-outline",class:"text-6xl text-theme-secondary mb-4"}),C[24]||(C[24]=e.createElementVNode("h3",{class:"text-lg font-medium text-theme mb-2"}," No Media Found ",-1)),e.createElementVNode("p",Jv,e.toDisplayString(l.value?"Try adjusting your search":"No media items available"),1)])):r.value==="grid"?(e.openBlock(),e.createBlock(U,{key:3,"media-items":b.value,"selected-items":e.unref(w).selectedItems.value,"is-loading":!1,"selection-mode":!0,columns:{mobile:2,sm:3,md:4,lg:5,xl:6},onToggleSelect:A,onPreview:z,onEdit:O,onDelete:le},null,8,["media-items","selected-items"])):(e.openBlock(),e.createBlock(e.unref(H.IonList),{key:4,lines:"none",class:"rounded-lg overflow-hidden"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,(re,ue)=>(e.openBlock(),e.createBlock(j,{key:re.uuid,media:re,selected:e.unref(w).isSelected(re.uuid),"selection-mode":!0,index:ue,onToggleSelect:A,onPreview:z,onEdit:O,onDelete:le},null,8,["media","selected","index"]))),128))]),_:1})),!s.value&&b.value.length>0&&i.value!=="model"?(e.openBlock(),e.createBlock(e.unref(H.IonInfiniteScroll),{key:5,threshold:"100px",onIonInfinite:C[8]||(C[8]=re=>$(re))},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonInfiniteScrollContent),{"loading-spinner":"crescent","loading-text":"Loading more media..."})]),_:1})):e.createCommentVNode("",!0)])]),_:1}),e.createVNode(e.unref(H.IonModal),{"is-open":Z.value,onDidDismiss:C[14]||(C[14]=re=>Z.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(H.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonButton),{onClick:C[9]||(C[9]=re=>Z.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(H.IonTitle),null,{default:e.withCtx(()=>[...C[25]||(C[25]=[e.createTextVNode("Edit Media Info",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(H.IonContent),{class:"p-4"},{default:e.withCtx(()=>[M.value?(e.openBlock(),e.createElementBlock("div",qv,[e.createElementVNode("div",Yv,[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...C[26]||(C[26]=[e.createTextVNode("Caption",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":C[10]||(C[10]=re=>M.value.caption=re),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter caption..."},null,512),[[e.vModelText,M.value.caption]])]),e.createElementVNode("div",Qv,[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...C[27]||(C[27]=[e.createTextVNode("Alt Text",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":C[11]||(C[11]=re=>M.value.alt_text=re),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter alt text..."},null,512),[[e.vModelText,M.value.alt_text]])]),e.createElementVNode("div",eg,[e.createVNode(e.unref(H.IonButton),{onClick:C[12]||(C[12]=re=>K(M.value))},{default:e.withCtx(()=>[...C[28]||(C[28]=[e.createTextVNode("Save",-1)])]),_:1}),e.createVNode(e.unref(H.IonButton),{fill:"clear",onClick:C[13]||(C[13]=re=>Z.value=!1)},{default:e.withCtx(()=>[...C[29]||(C[29]=[e.createTextVNode("Cancel",-1)])]),_:1})])])):e.createCommentVNode("",!0)]),_:1})]),_:1},8,["is-open"]),e.createVNode(e.unref(H.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",tg,[e.createElementVNode("div",ag,[e.unref(w).selectedCount.value>0?(e.openBlock(),e.createElementBlock("span",ng,[e.createTextVNode(e.toDisplayString(e.unref(w).selectedCount.value)+" selected ",1),t.maxSelection?(e.openBlock(),e.createElementBlock("span",og," / "+e.toDisplayString(t.maxSelection)+" max ",1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("span",ig," Select "+e.toDisplayString(t.selectionMode==="multiple"?"items":"an item"),1))]),e.createElementVNode("div",rg,[e.createVNode(e.unref(H.IonButton),{fill:"clear",onClick:D},{default:e.withCtx(()=>[...C[30]||(C[30]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(H.IonButton),{disabled:I.value,onClick:P},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(V.value),1)]),_:1},8,["disabled"])])])]),_:1})]),_:1})]),_:1},8,["is-open"])}}}),sg=$e(lg,[["__scopeId","data-v-9a8c0954"]]),dg={key:1,class:"flex flex-col items-center justify-center py-16"},cg=["draggable","onDragstart","onDragover","onDrop"],ug={key:0,class:"absolute top-2 left-2 z-20"},mg=["checked","onChange"],pg={key:2,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-move"},fg=["data-media-id"],hg={key:0,class:"w-full h-full flex items-center justify-center"},vg=["src","alt","onError","onLoad"],gg={key:2,class:"w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-700"},bg={class:"text-center"},yg={class:"text-4xl text-gray-400 mb-2"},wg={class:"text-sm font-medium text-gray-500"},kg={class:"absolute inset-0 bg-black/70 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2"},_g=["onClick"],Eg=["onClick"],Sg=["onClick"],Cg={class:"p-3"},xg={class:"text-sm font-medium truncate mb-1"},Ng={class:"text-xs text-gray-600 dark:text-gray-400"},Vg={key:0},Tg={key:0,class:"text-xs text-gray-500 dark:text-gray-500 mt-1 truncate"},Bg=e.defineComponent({__name:"MediaGrid",props:{mediaItems:{default:()=>[]},selectedItems:{default:()=>[]},isLoading:{type:Boolean,default:!1},selectionMode:{type:Boolean,default:!1},reorderable:{type:Boolean,default:!1},showEditButton:{type:Boolean,default:!1},columns:{default:()=>({mobile:2,sm:3,md:4,lg:5,xl:6})}},emits:["toggleSelect","preview","edit","delete","reorder","upload"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(null),r=e.ref(null),l=e.ref(new Set),s=e.ref(null),d=I=>t.selectedItems.some(x=>x.uuid===I.uuid),c=e.computed(()=>{const I=t.columns,x=["grid","gap-4"];switch(I.mobile){case 1:x.push("grid-cols-1");break;case 2:x.push("grid-cols-2");break;case 3:x.push("grid-cols-3");break;case 4:x.push("grid-cols-4");break;default:x.push("grid-cols-2");break}switch(I.sm){case 1:x.push("sm:grid-cols-1");break;case 2:x.push("sm:grid-cols-2");break;case 3:x.push("sm:grid-cols-3");break;case 4:x.push("sm:grid-cols-4");break;case 5:x.push("sm:grid-cols-5");break;default:x.push("sm:grid-cols-3");break}switch(I.md){case 2:x.push("md:grid-cols-2");break;case 3:x.push("md:grid-cols-3");break;case 4:x.push("md:grid-cols-4");break;case 5:x.push("md:grid-cols-5");break;case 6:x.push("md:grid-cols-6");break;default:x.push("md:grid-cols-4");break}switch(I.lg){case 3:x.push("lg:grid-cols-3");break;case 4:x.push("lg:grid-cols-4");break;case 5:x.push("lg:grid-cols-5");break;case 6:x.push("lg:grid-cols-6");break;case 7:x.push("lg:grid-cols-7");break;default:x.push("lg:grid-cols-5");break}switch(I.xl){case 4:x.push("xl:grid-cols-4");break;case 5:x.push("xl:grid-cols-5");break;case 6:x.push("xl:grid-cols-6");break;case 7:x.push("xl:grid-cols-7");break;case 8:x.push("xl:grid-cols-8");break;default:x.push("xl:grid-cols-6");break}return x.join(" ")});function u(I,x,T){t.reorderable&&(i.value=x,I.dataTransfer&&(I.dataTransfer.effectAllowed="move",I.dataTransfer.setData("text/html","")))}function m(I,x){t.reorderable&&(I.preventDefault(),r.value=x)}function p(){r.value=null}function f(I,x){if(!t.reorderable||!i.value)return;I.preventDefault();const T=[...t.mediaItems],$=T.findIndex(S=>{var B;return S.uuid===((B=i.value)==null?void 0:B.uuid)});if($!==-1&&$!==x&&i.value){const[S]=T.splice($,1);T.splice(x,0,S),n("reorder",T)}i.value=null,r.value=null}function h(I){return I<1024?I+" B":I<1024*1024?(I/1024).toFixed(1)+" KB":(I/(1024*1024)).toFixed(1)+" MB"}function v(I){var T;return I.thumbnail_url||((T=I.conversion_urls)==null?void 0:T.thumb)||I.original_url||I.url||""}function k(I){var $,S,B;const x=(($=I.mime_type)==null?void 0:$.startsWith("image/"))||!1,T=!!(I.thumbnail_url||(S=I.conversion_urls)!=null&&S.thumb||(B=I.conversion_urls)!=null&&B.preview||I.original_url||I.url);return x&&T}function y(I){var x;return((x=I.split(".").pop())==null?void 0:x.toUpperCase())||""}function w(I){var T;const x=((T=I.mime_type)==null?void 0:T.toLowerCase())||"";return x.startsWith("image/")?"image":x.startsWith("video/")?"videocam":x.startsWith("audio/")?"musical-notes":x.includes("pdf")?"document-text":x.includes("zip")||x.includes("rar")?"archive":x.includes("sheet")||x.includes("excel")?"grid":x.includes("document")||x.includes("word")?"document-text":"document"}e.onMounted(()=>{typeof window<"u"&&"IntersectionObserver"in window&&(s.value=new IntersectionObserver(I=>{I.forEach(x=>{var T;if(x.isIntersecting){const $=x.target.getAttribute("data-media-id");$&&(l.value.add($),(T=s.value)==null||T.unobserve(x.target))}})},{rootMargin:"50px"}))}),e.onUnmounted(()=>{s.value&&s.value.disconnect()});function g(I){return!0}function b(){s.value&&e.nextTick(()=>{document.querySelectorAll("[data-media-id]").forEach(x=>{var $;const T=x.getAttribute("data-media-id");T&&!l.value.has(T)&&(($=s.value)==null||$.observe(x))})})}e.watch(()=>t.mediaItems,()=>{l.value.clear(),b()},{immediate:!0,deep:!0});function R(I,x){const T=I.target;delete T.dataset.fallbackIndex}function V(I,x){const T=I.target,$=T.closest("[data-media-id]"),S=[x.original_url,x.url,x.thumbnail_url,"preview_url"in x?x.preview_url:void 0].filter(B=>B&&B.trim()!==""&&B!==T.src);if(S.length>0&&T.dataset.fallbackIndex){const B=parseInt(T.dataset.fallbackIndex);if(B<S.length){T.dataset.fallbackIndex=(B+1).toString(),T.src=S[B]||"";return}}else if(S.length>0){T.dataset.fallbackIndex="1",T.src=S[0]||"";return}if(T.style.display="none",$&&!$.querySelector(".media-fallback-icon")){const _=document.createElement("div");_.className="media-fallback-icon w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-800",_.innerHTML=`
|
|
2
2
|
<div class="text-center">
|
|
3
3
|
<div class="text-4xl text-gray-400 mb-2">${w(x)}</div>
|
|
4
4
|
<p class="text-sm font-medium text-gray-500">${y(x.file_name)}</p>
|
|
@@ -333,7 +333,7 @@ ${i.text}
|
|
|
333
333
|
font-size: 13px;
|
|
334
334
|
padding: 12px 0;
|
|
335
335
|
}
|
|
336
|
-
`,a=document.createElement("style");a.textContent=o,document.head.appendChild(a)}class F2{constructor({filters:a=[],callbacks:t={}}){$2(),this._filters=a,this._cb=t,this._selectedCategory="all",this._selectedFilterId=null,this._activeFilters=new Map,this._drawerOpen=!1,this._drawerFilterId=null,this._root=null,this._catRow=null,this._filterRow=null,this._activeRow=null,this._drawer=null,this._drawerTitle=null,this._drawerBody=null}mount(a){return this._root=bt("div",{className:"mvfp"}),this._catRow=bt("div",{className:"mvfp-row"}),this._root.appendChild(this._catRow),this._filterRow=bt("div",{className:"mvfp-row"}),this._root.appendChild(this._filterRow),this._activeRow=bt("div",{className:"mvfp-active-row"}),this._root.appendChild(this._activeRow),this._buildDrawer(),this._root.appendChild(this._drawer),this._renderCategories(),this._renderFilters(),this._renderActiveChips(),a.appendChild(this._root),this._root}setFilters(a){this._filters=a,this._renderCategories(),this._renderFilters()}setActiveFilters(a){this._activeFilters.clear(),a&&a.forEach((t,n)=>{this._activeFilters.set(n,t)}),this._renderFilters(),this._renderActiveChips(),this._drawerOpen&&this._drawerFilterId&&!this._activeFilters.has(this._drawerFilterId)&&this.closeDrawer()}destroy(){var a;this.closeDrawer(),(a=this._root)==null||a.remove(),this._root=null}_getCategories(){const a=new Map;a.set("all","All");for(const t of this._filters){const n=t.category||"other";a.has(n)||a.set(n,n.charAt(0).toUpperCase()+n.slice(1))}return a}_renderCategories(){this._catRow.innerHTML="",this._getCategories().forEach((t,n)=>{const i=bt("div",{className:`mvfp-cat${this._selectedCategory===n?" active":""}`,onClick:()=>{this._selectedCategory=n,this._renderCategories(),this._renderFilters()}},t);this._catRow.appendChild(i)})}_currentFilters(){return this._selectedCategory==="all"?this._filters:this._filters.filter(a=>(a.category||"other")===this._selectedCategory)}_renderFilters(){this._filterRow.innerHTML="";for(const a of this._currentFilters()){const t=this._activeFilters.has(a.id),n=this._selectedFilterId===a.id,i=bt("div",{className:`mvfp-filter${t?" active":""}${n?" selected":""}`,onClick:()=>this._selectFilter(a)});if(t){const r=bt("div",{className:"mvfp-check",onClick:l=>{l.stopPropagation(),this._removeFilter(a.id)}});r.innerHTML="✓",i.appendChild(r)}i.appendChild(bt("span",{},a.name)),this._filterRow.appendChild(i)}}_selectFilter(a){var t,n,i,r;this._selectedFilterId=a.id,this._activeFilters.has(a.id)||(n=(t=this._cb).onApplyFilter)==null||n.call(t,a),(r=(i=this._cb).onPreviewFilter)==null||r.call(i,a),this._renderFilters(),a.params&&a.params.length>0&&this.openDrawer(a.id)}_removeFilter(a){var t,n;(n=(t=this._cb).onRemoveFilter)==null||n.call(t,a),this._selectedFilterId===a&&(this._selectedFilterId=null)}_renderActiveChips(){if(this._activeRow.innerHTML="",this._activeFilters.size===0){this._activeRow.appendChild(bt("div",{className:"mvfp-placeholder"},"No active filters"));return}this._activeFilters.forEach((a,t)=>{const n=this._filters.find(d=>d.id===t);if(!n)return;const i=this._drawerOpen&&this._drawerFilterId===t,r=bt("div",{className:`mvfp-achip${i?" selected":""}`}),l=bt("span",{style:{cursor:"pointer"},onClick:()=>{this._selectedFilterId=t,this._renderFilters(),n.params&&n.params.length>0&&this.openDrawer(t)}},n.name),s=bt("button",{className:"mvfp-achip-x","aria-label":`Remove ${n.name}`,onClick:d=>{d.stopPropagation(),this._removeFilter(t)}});s.innerHTML='<svg width="10" height="10" viewBox="0 0 12 12"><path d="M3 3l6 6M9 3l-6 6" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',r.appendChild(l),r.appendChild(s),this._activeRow.appendChild(r)})}_buildDrawer(){this._drawer=bt("div",{className:"mvfp-drawer"});const a=bt("div",{className:"mvfp-drawer-hdr"});this._drawerTitle=bt("span",{className:"mvfp-drawer-title"},"Filter");const t=bt("div",{className:"mvfp-drawer-actions"});t.appendChild(bt("button",{className:"mvfp-drawer-btn",onClick:()=>this._resetDrawerFilter()},"Reset")),t.appendChild(bt("button",{className:"mvfp-drawer-btn danger",onClick:()=>{this._drawerFilterId&&(this._removeFilter(this._drawerFilterId),this.closeDrawer())}},"Remove"));const n=bt("button",{className:"mvfp-drawer-close","aria-label":"Close",onClick:()=>this.closeDrawer()});n.innerHTML='<svg width="14" height="14" viewBox="0 0 14 14"><path d="M3 3l8 8M11 3l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',t.appendChild(n),a.appendChild(this._drawerTitle),a.appendChild(t),this._drawer.appendChild(a),this._drawerBody=bt("div",{className:"mvfp-drawer-body"}),this._drawer.appendChild(this._drawerBody)}openDrawer(a){const t=this._filters.find(n=>n.id===a);if(t&&(this._drawerFilterId=a,this._drawerTitle.textContent=t.name,this._renderDrawerControls(t),this._renderActiveChips(),!this._drawerOpen)){this._drawerOpen=!0;const n=this._root.offsetHeight;n>0&&(this._drawer.style.height=n+"px"),this._drawer.style.transition="none",this._drawer.style.transform="translateY(100%)",this._drawer.offsetHeight,this._drawer.style.transition="transform 0.25s cubic-bezier(0.33, 1, 0.68, 1)",this._drawer.style.transform="translateY(0)"}}closeDrawer(){this._drawerOpen&&(this._drawerOpen=!1,this._drawerFilterId=null,this._drawer.style.transition="transform 0.2s cubic-bezier(0.32, 0, 0.67, 0)",this._drawer.style.transform="translateY(100%)",this._renderActiveChips())}_renderDrawerControls(a){if(this._drawerBody.innerHTML="",!a.params||a.params.length===0){this._drawerBody.appendChild(bt("div",{className:"mvfp-no-params"},"No adjustable parameters"));return}const t=this._activeFilters.get(a.id),n=(t==null?void 0:t.params)||{};for(const i of a.params){const r=n[i.id]??i.default,l=bt("div",{className:"mvfp-ctl"}),s=bt("label",{className:"mvfp-ctl-label"},i.label||i.id);l.appendChild(s);const d=i.type||"slider";if(d==="slider"||d==="range"){const c=bt("div",{className:"mvfp-slider-row"}),u=bt("span",{className:"mvfp-range-val"},Pc(r)),m=bt("input",{type:"range",className:"mvfp-range",min:String(i.min??0),max:String(i.max??1),step:String(i.step??.01),value:String(typeof r=="number"?r:i.default??0),onInput:p=>{var h,v;const f=parseFloat(p.target.value);u.textContent=Pc(f),(v=(h=this._cb).onUpdateParam)==null||v.call(h,a.id,i.id,f)}});c.appendChild(m),c.appendChild(u),l.appendChild(c)}else if(d==="toggle"||d==="checkbox"){const c=bt("div",{className:"mvfp-toggle-row"}),u=bt("input",{type:"checkbox",checked:r?"checked":void 0,onChange:m=>{var p,f;return(f=(p=this._cb).onUpdateParam)==null?void 0:f.call(p,a.id,i.id,m.target.checked)}});c.appendChild(u),l.appendChild(c)}else if(d==="color"){const c=bt("div",{className:"mvfp-color-row"}),u=bt("input",{type:"color",className:"mvfp-color-input",value:typeof r=="string"?r:"#000000",onInput:m=>{var p,f;return(f=(p=this._cb).onUpdateParam)==null?void 0:f.call(p,a.id,i.id,m.target.value)}});c.appendChild(u),l.appendChild(c)}else if(d==="select"||d==="dropdown"){const c=bt("div",{className:"mvfp-select-row"}),u=bt("select",{className:"mvfp-select",onChange:m=>{var p,f;return(f=(p=this._cb).onUpdateParam)==null?void 0:f.call(p,a.id,i.id,m.target.value)}});for(const m of i.options||[]){const p=bt("option",{value:m.value},m.label||String(m.value));m.value===r&&(p.selected=!0),u.appendChild(p)}c.appendChild(u),l.appendChild(c)}this._drawerBody.appendChild(l)}}_resetDrawerFilter(){var t,n;if(!this._drawerFilterId)return;const a=this._filters.find(i=>i.id===this._drawerFilterId);if(a!=null&&a.params){for(const i of a.params)(n=(t=this._cb).onUpdateParam)==null||n.call(t,this._drawerFilterId,i.id,i.default);this._renderDrawerControls(a)}}}const D2=[200,500,1e3];function A2(o){return{"360p":[640,360],"480p":[854,480],"720p":[1280,720],"1080p":[1920,1080],"1440p":[2560,1440],"2160p":[3840,2160]}[o??""]??[1920,1080]}function Oc(o){if(!o)return null;const a=o.duration;if(typeof a=="number"&&Number.isFinite(a)&&a>0)return a;if(a&&typeof a=="object"&&"value"in a){const t=a.value;if(typeof t=="number"&&Number.isFinite(t)&&t>0)return t}return null}function R2(o){return new Promise(a=>{window.setTimeout(a,o)})}async function zc(){return await Promise.resolve().then(()=>require("./PixiFrameExporter-C8Ty9X-z.cjs"))}function jc(o,a=0){var r;const t=o.timeline[0],n=t?Math.max(0,t.sourceIn):0,i=(t==null?void 0:t.sourceOut)??((r=o.source)==null?void 0:r.duration)??a;return Math.max(0,i-n)}function Km(o){let a=null;return{canExportClientSide:async()=>{try{const{isWebCodecsSupported:i}=await zc();return i()}catch{return!1}},renderRecipeWithPixi:async(i,r,l)=>{var f,h,v,k;const s=i.timeline[0],d=s?Math.max(0,s.sourceIn):0,c=s?s.sourceOut:void 0,[u,m]=A2((r==null?void 0:r.quality)??((f=i.output)==null?void 0:f.quality)),p=((h=i.output)==null?void 0:h.fps)||30;o.setPlaying(!1),o.forcePixiPreview.value=!0,await e.nextTick();try{let y=!1;for(const A of D2){await R2(A);const P=o.getPreviewRef();if(!(!P||typeof P.captureFrameAt!="function")){if(typeof P.ensureReadyForCapture=="function"){if(y=await P.ensureReadyForCapture(),y)break;continue}y=!0;break}}const w=o.getPreviewRef();if(!w||typeof w.captureFrameAt!="function")throw new Error("PIXI preview not available for export. Ensure the preview is mounted.");if(!y)throw new Error("PIXI preview not ready for frame capture after retries. The video may still be loading.");const{exportWithPixiFrames:g,isWebCodecsSupported:b}=await zc();if(!b())throw new Error("WebCodecs is not supported in this browser. Export requires Chrome 94+ or equivalent.");a=new AbortController;const R={width:u,height:m,fps:p,trimStart:d,signal:a.signal};c!==void 0&&(R.trimEnd=c),l&&(R.onProgress=l);const V=o.getSourceUrl();V!==""&&(R.sourceUrl=V);const I=Oc(w)??((v=i.source)==null?void 0:v.duration)??c??0,x=await g({captureFrameAt:A=>{var P;return((P=w.captureFrameAt)==null?void 0:P.call(w,A))??Promise.resolve(null)},duration:{value:I}},R),T=new File([x],`edited-video-${Date.now()}.mp4`,{type:"video/mp4"}),$=Oc(w),S=((k=i.source)==null?void 0:k.duration)??0,_=Math.max(0,(c??$??S)-d);return{file:T,recipe:i,meta:{duration:_,width:u,height:m,format:"mp4",sizeBytes:T.size,size_bytes:T.size}}}finally{o.forcePixiPreview.value=!1,a=null}},cancelClientExport:()=>{a==null||a.abort(),a=null},resetClientExport:()=>{a=null}}}const Lo="default-video-track",Nn="default-media-source";function Jm(o){var r,l;const a=P2(o),t=U2(o),n=O2(o.timeline,((r=t[0])==null?void 0:r.id)??Lo,((l=a[0])==null?void 0:l.id)??Nn),i={version:o.version,source:{...o.source},mediaSources:a,tracks:z2(t,n),clips:n,markers:o.markers?o.markers.map(s=>({...s})):[],transitions:o.transitions?o.transitions.map(Qm):[],filters:o.filters.map(s=>({...s,params:{...s.params}})),audio:{...o.audio},output:{...o.output}};return typeof o.duration=="number"&&(i.duration=o.duration),o.snapSettings&&(i.snapSettings={...o.snapSettings}),o.textOverlays&&(i.textOverlays=[...o.textOverlays]),o.captionTracks&&(i.captionTracks=o.captionTracks.map(ep)),o.visualLayers&&(i.visualLayers=o.visualLayers.map(tp)),o.audioTracks&&(i.audioTracks=[...o.audioTracks]),o.posterFrame&&(i.posterFrame=o.posterFrame),o.metadata&&(i.metadata={...o.metadata}),i}function L2(o){const a={version:"1.0",source:{...o.source},timeline:o.clips.map(t=>({...t})),mediaSources:o.mediaSources.map(qm),tracks:o.tracks.map(Ym),markers:o.markers.map(t=>({...t})),transitions:o.transitions.map(Qm),filters:o.filters.map(t=>({...t,params:{...t.params}})),audio:{...o.audio},output:{...o.output}};return typeof o.duration=="number"&&(a.duration=o.duration),o.snapSettings&&(a.snapSettings={...o.snapSettings}),o.textOverlays&&(a.textOverlays=[...o.textOverlays]),o.captionTracks&&(a.captionTracks=o.captionTracks.map(ep)),o.visualLayers&&(a.visualLayers=o.visualLayers.map(tp)),o.audioTracks&&(a.audioTracks=[...o.audioTracks]),o.posterFrame&&(a.posterFrame=o.posterFrame),o.metadata&&(a.metadata={...o.metadata}),a}function P2(o){var t,n;if(o.mediaSources&&o.mediaSources.length>0)return o.mediaSources.map(qm);const a={id:((t=o.timeline.find(i=>i.sourceRefId))==null?void 0:t.sourceRefId)??Nn,type:"media",mediaUuid:o.source.media_uuid,duration:o.source.duration,width:o.source.original_width,height:o.source.original_height};return(n=o.metadata)!=null&&n.source_url&&(a.url=o.metadata.source_url),[a]}function U2(o){var a;return o.tracks&&o.tracks.length>0?o.tracks.map(Ym):[{id:((a=o.timeline.find(t=>t.trackId))==null?void 0:a.trackId)??Lo,type:"video",name:"Video",order:0}]}function O2(o,a,t){return o.map(n=>{const i={...n,trackId:n.trackId??a,sourceRefId:n.sourceRefId??t};return n.filters&&(i.filters=n.filters.map(r=>({...r,params:{...r.params}}))),n.transform&&(i.transform={...n.transform}),n.keyframes&&(i.keyframes=n.keyframes.map(r=>({...r}))),i})}function z2(o,a){return o.map(t=>{const n=a.filter(i=>i.trackId===t.id).map(i=>i.id);return{...t,clipIds:n}})}function qm(o){const a={...o};return o.metadata&&(a.metadata={...o.metadata}),a}function Ym(o){const a={...o};return o.clipIds&&(a.clipIds=[...o.clipIds]),a}function Qm(o){const a={...o};return o.params&&(a.params={...o.params}),a}function ep(o){return{...o,segments:o.segments.map(t=>{const n={...t};return t.words&&(n.words=t.words.map(i=>({...i}))),n})}}function tp(o){return{...o,transform:{...o.transform,position:{...o.transform.position},anchor:{...o.transform.anchor},scale:{...o.transform.scale}},keyframes:o.keyframes?o.keyframes.map(a=>({...a})):void 0}}const ap="video-project-draft-snapshot:v1",Ls="mediables:video-project-drafts",j2=(o,a={})=>{var p,f;const t=pn(a.now)??Date.now(),n=pn(a.createdAt)??t,i=pn(a.updatedAt)??t,r=tE(o),l={id:Ma(a.id)??iE(i),payloadKind:r,createdAt:new Date(n).toISOString(),updatedAt:new Date(i).toISOString(),deviceKind:a.deviceKind??"unknown"},s=Ma(a.projectId),d=Ma(a.sourceMediaUuid)??Ma(o.source.media_uuid),c=Ps(a.durationSeconds)??aE(o),u=Ma(a.editorVersion)??Ma((p=o.metadata)==null?void 0:p.editor_version),m=Ma(a.title)??Ma((f=o.metadata)==null?void 0:f.title);return s!==null&&(l.projectId=s),d!==null&&(l.sourceMediaUuid=d),c!==null&&(l.durationSeconds=c),u!==null&&(l.editorVersion=u),m!==null&&(l.title=m),a.saveReason!==void 0&&(l.saveReason=a.saveReason),{schemaVersion:ap,metadata:l,payload:o}},np=(o,a=Ls)=>{const t=Ma(a)??Ls,n=Xc(o.metadata.projectId??"unsaved-project"),i=Xc(o.metadata.id);return`${t}:${n}:${i}`},W2=o=>JSON.stringify(o),H2=o=>{if(typeof o!="string"||o.trim().length===0)return null;try{const a=JSON.parse(o);return Y2(a)?a:null}catch{return null}},Z2=o=>{const a=[];for(const t of o){const n=Ma(t.key),i=H2(t.value);n===null||i===null||a.push({key:n,snapshot:i})}return Si(a)},G2=(o,a)=>{const t=oE(a.maxCount),n=pn(a.now)??Date.now(),i=sp(a.maxAgeMs),r=[],l=[];let s=0;for(const d of Si(o)){if(!rp(d,a.projectId)){r.push(d);continue}if(lp(d.snapshot,n,i)||s>=t){l.push(d);continue}r.push(d),s+=1}return{retained:Si(r),removed:Si(l)}},X2=(o,a={})=>{const t={key:np(o),snapshot:o};if(!rp(t,a.projectId))return!1;const n=pn(a.now)??Date.now(),i=sp(a.maxAgeMs);if(lp(o,n,i))return!1;const r=a.savedAt===null?null:pn(a.savedAt);return r===null?!0:jr(o)>r},K2=(o,a={})=>Si(o).filter(t=>X2(t.snapshot,a)),J2=(o,a,t={})=>{const n=K2(o,t);if(a==="mobile"){const i=n[0]??null;return i===null?[]:[i]}return n},q2=async(o,a,t=np(a))=>(await o.setItem(t,W2(a)),{key:t,snapshot:a}),Wc=async(o,a=Ls)=>{const t=await o.listKeys(a),n=[];for(const i of t)n.push({key:i,value:await o.getItem(i)});return Z2(n)},Hc=async(o,a)=>{for(const t of a)await o.removeItem(t.key)},Y2=o=>!fn(o)||o.schemaVersion!==ap||!Q2(o.metadata)?!1:o.metadata.payloadKind==="project"?op(o.payload):eE(o.payload),Q2=o=>fn(o)?_d(o.id)&&lE(o.payloadKind)&&Gc(o.createdAt)&&Gc(o.updatedAt)&&sE(o.deviceKind)&&mr(o.projectId)&&mr(o.sourceMediaUuid)&&rE(o.durationSeconds)&&mr(o.editorVersion)&&mr(o.title)&&dE(o.saveReason):!1,eE=o=>fn(o)?o.version==="1.0"&&ip(o.source)&&Array.isArray(o.timeline)&&Array.isArray(o.filters)&&fn(o.audio)&&fn(o.output):!1,op=o=>fn(o)?o.version==="1.0"&&ip(o.source)&&Array.isArray(o.mediaSources)&&Array.isArray(o.tracks)&&Array.isArray(o.clips)&&Array.isArray(o.markers)&&Array.isArray(o.filters)&&fn(o.audio)&&fn(o.output):!1,ip=o=>fn(o)?_d(o.media_uuid)&&Ci(o.duration)&&Ci(o.original_width)&&Ci(o.original_height):!1,tE=o=>op(o)?"project":"recipe",aE=o=>Ps(o.duration)??Ps(o.source.duration),rp=(o,a)=>{const t=Ma(a);return t===null?!0:o.snapshot.metadata.projectId===t},lp=(o,a,t)=>t===null?!1:a-jr(o)>t,Si=o=>[...o].sort(nE),nE=(o,a)=>{const t=jr(a.snapshot)-jr(o.snapshot);if(t!==0)return t;const n=Zc(a.snapshot)-Zc(o.snapshot);return n!==0?n:o.snapshot.metadata.id.localeCompare(a.snapshot.metadata.id)},jr=o=>pn(o.metadata.updatedAt)??0,Zc=o=>pn(o.metadata.createdAt)??0,oE=o=>!Number.isFinite(o)||o<0?0:Math.floor(o),sp=o=>o===void 0||!Number.isFinite(o)||o<0?null:Math.floor(o),pn=o=>{if(o==null)return null;if(o instanceof Date)return Number.isFinite(o.getTime())?o.getTime():null;if(typeof o=="number")return Number.isFinite(o)?o:null;const a=o.trim();if(a.length===0)return null;const t=Date.parse(a);return Number.isFinite(t)?t:null},Gc=o=>typeof o=="string"&&pn(o)!==null,iE=o=>{var t;const a=typeof((t=globalThis.crypto)==null?void 0:t.randomUUID)=="function"?globalThis.crypto.randomUUID():Math.random().toString(36).slice(2,12);return`draft-${o}-${a}`},Xc=o=>encodeURIComponent(o.trim()),Ma=o=>{if(typeof o!="string")return null;const a=o.trim();return a.length>0?a:null},_d=o=>Ma(o)!==null,mr=o=>o===void 0||_d(o),Ps=o=>{if(!Ci(o))return null;const a=Number(o.toFixed(6));return Object.is(a,-0)?0:a},Ci=o=>typeof o=="number"&&Number.isFinite(o)&&o>=0,rE=o=>o===void 0||Ci(o),lE=o=>o==="recipe"||o==="project",sE=o=>o==="desktop"||o==="mobile"||o==="tablet"||o==="unknown",dE=o=>o===void 0||o==="autosave"||o==="manual"||o==="before-export"||o==="before-close",fn=o=>typeof o=="object"&&o!==null&&!Array.isArray(o),cE=1,uE="master",Mi=-60,Us=12,Ed=0,Vn=-90,Wr=6,mE=4,dp=8;function cp(){return{mobile:{canAdjustTrackFaders:!0,canAdjustMasterFader:!0,canMuteTracks:!0,canSoloTracks:!0,canAdjustPan:!1,canViewMeters:!0,canEditEffectSlots:!1,canEditRouting:!1,canEditAutomation:!1,meterMode:"basic",maxEffectSlots:0},desktop:{canAdjustTrackFaders:!0,canAdjustMasterFader:!0,canMuteTracks:!0,canSoloTracks:!0,canAdjustPan:!0,canViewMeters:!0,canEditEffectSlots:!0,canEditRouting:!0,canEditAutomation:!0,meterMode:"full",maxEffectSlots:dp}}}function pE(o,a=cp()){return zs(a[o])}function up(o){return Number.isNaN(o)?Ed:o<=0||o===Number.NEGATIVE_INFINITY?Mi:$i(20*Math.log10(o))}function Os(o){const a=$i(o);return a<=Mi?0:Bn(Math.pow(10,a/20),6)}function $i(o){return Number.isNaN(o)?Ed:o===Number.NEGATIVE_INFINITY?Mi:o===Number.POSITIVE_INFINITY?Us:Bn(Wi(o,Mi,Us),3)}function mp(o){return Number.isFinite(o)?Bn(Wi(o,-1,1),3):0}function fE(o,a=!1){const t=o.some(n=>n.controls.solo);return o.map(n=>{const i=n.controls.muted,r=t&&!n.controls.solo,l=a||i||r,s=l?0:n.controls.fader.linearGain;return{trackId:n.id,soloed:n.controls.solo,mutedByTrack:i,mutedBySolo:r,mutedByMaster:a,effectivelyMuted:l,audible:!l,effectiveGainLinear:s}})}function hE(o,a={}){const t=xE(a.effectSlotCount),n=new Set;return{schemaVersion:cE,capabilities:a.capabilities?BE(a.capabilities):cp(),tracks:o.map((i,r)=>gE(i,r,t,n)),master:bE(a.master,t)}}function pp(o){const a=$i(o);return{valueDb:a,minDb:Mi,maxDb:Us,unityDb:Ed,linearGain:Os(a)}}function vE(o,a="constant-power"){return{value:mp(o),mode:a}}function fp(o=Vn,a=Vn,t=o){const n=ql(o),i=ql(a),r=ql(t);return{peakDb:n,rmsDb:i,peakHoldDb:r,clipping:n>=0||r>=0}}function hp(o){const a=bp(o);return{id:`empty-effect-slot-${a}`,index:a,kind:"empty",label:"Empty",enabled:!1,bypassed:!0,wetMix:0,parameters:{}}}function gE(o,a,t,n){const i=gp(o.id),l={id:CE(i??`legacy-audio-track-${a+1}`,n),kind:"legacy-url",name:_E(o.name,a),order:a,source:yE(o.source),controls:{fader:pp(o.faderDb??up(o.volume??1)),pan:vE(o.pan??0),muted:o.muted??!1,solo:o.solo??!1,meter:fp(o.peakDb,o.rmsDb,o.peakHoldDb)},timeline:wE(o),effectSlots:vp(o.effectSlots,t)};return i!==void 0&&(l.legacyTrackId=i),l}function bE(o,a){return{id:uE,name:EE(o==null?void 0:o.name),fader:pp((o==null?void 0:o.faderDb)??up((o==null?void 0:o.volume)??1)),muted:(o==null?void 0:o.muted)??!1,meter:fp(o==null?void 0:o.peakDb,o==null?void 0:o.rmsDb,o==null?void 0:o.peakHoldDb),effectSlots:vp(o==null?void 0:o.effectSlots,a)}}function yE(o){const a=o.trim();return a===""?{type:"missing"}:{type:"url",url:a}}function wE(o){const a={startTime:VE(o.startTime??0),loop:o.loop??!1},t=NE(o.duration);t!==void 0&&(a.duration=t);const n=Kc(o.fadeIn);n!==void 0&&(a.fadeIn=n);const i=Kc(o.fadeOut);return i!==void 0&&(a.fadeOut=i),a}function vp(o,a){const t=new Map;for(const n of o??[]){const i=kE(n,a);t.set(i.index,i)}return Array.from({length:a},(n,i)=>t.get(i)??hp(i))}function kE(o,a){const t=bp(o.index),n=a>0?Math.min(t,a-1):0,i=o.kind;return i==="empty"?hp(n):{id:gp(o.id)??`${i}-effect-slot-${n}`,index:n,kind:i,label:SE(o.label,i),enabled:o.enabled,bypassed:o.bypassed,wetMix:TE(o.wetMix),parameters:{...o.parameters}}}function _E(o,a){const t=o==null?void 0:o.trim();return t&&t!==""?t:`Audio ${a+1}`}function EE(o){const a=o==null?void 0:o.trim();return a&&a!==""?a:"Master"}function SE(o,a){const t=o.trim();return t!==""?t:a}function CE(o,a){if(!a.has(o))return a.add(o),o;let t=2,n=`${o}-${t}`;for(;a.has(n);)t+=1,n=`${o}-${t}`;return a.add(n),n}function gp(o){const a=o==null?void 0:o.trim();if(!(!a||a===""))return a}function xE(o){return o===void 0||!Number.isFinite(o)?mE:Math.trunc(Wi(o,0,dp))}function bp(o){return!Number.isFinite(o)||o<0?0:Math.trunc(o)}function NE(o){if(!(o===void 0||!Number.isFinite(o)||o<=0))return Bn(o,3)}function Kc(o){if(!(o===void 0||!Number.isFinite(o)||o<0))return Bn(o,3)}function VE(o){return!Number.isFinite(o)||o<0?0:Bn(o,3)}function TE(o){return Number.isFinite(o)?Bn(Wi(o,0,1),3):1}function ql(o){return Number.isNaN(o)||o===Number.NEGATIVE_INFINITY?Vn:o===Number.POSITIVE_INFINITY?Wr:Bn(Wi(o,Vn,Wr),3)}function BE(o){return{mobile:zs(o.mobile),desktop:zs(o.desktop)}}function zs(o){return{...o}}function Wi(o,a,t){return Math.min(t,Math.max(a,o))}function Bn(o,a){const t=10**a;return Math.round(o*t)/t}const IE=/^(\d{2,}:[0-5]\d:[0-5]\d,\d{3})\s+-->\s+(\d{2,}:[0-5]\d:[0-5]\d,\d{3})$/,ME=/^(\d{2,}):([0-5]\d):([0-5]\d),(\d{3})$/,$E="srt-cue";class Tn extends Error{constructor(a,t,n={}){super(t),this.name="CaptionSrtError",this.code=a,this.context=n}}function FE(o,a={}){var l,s;const t=DE(a.idPrefix),n=o.replace(/^\uFEFF/,"").replace(/\r\n?/g,`
|
|
336
|
+
`,a=document.createElement("style");a.textContent=o,document.head.appendChild(a)}class F2{constructor({filters:a=[],callbacks:t={}}){$2(),this._filters=a,this._cb=t,this._selectedCategory="all",this._selectedFilterId=null,this._activeFilters=new Map,this._drawerOpen=!1,this._drawerFilterId=null,this._root=null,this._catRow=null,this._filterRow=null,this._activeRow=null,this._drawer=null,this._drawerTitle=null,this._drawerBody=null}mount(a){return this._root=bt("div",{className:"mvfp"}),this._catRow=bt("div",{className:"mvfp-row"}),this._root.appendChild(this._catRow),this._filterRow=bt("div",{className:"mvfp-row"}),this._root.appendChild(this._filterRow),this._activeRow=bt("div",{className:"mvfp-active-row"}),this._root.appendChild(this._activeRow),this._buildDrawer(),this._root.appendChild(this._drawer),this._renderCategories(),this._renderFilters(),this._renderActiveChips(),a.appendChild(this._root),this._root}setFilters(a){this._filters=a,this._renderCategories(),this._renderFilters()}setActiveFilters(a){this._activeFilters.clear(),a&&a.forEach((t,n)=>{this._activeFilters.set(n,t)}),this._renderFilters(),this._renderActiveChips(),this._drawerOpen&&this._drawerFilterId&&!this._activeFilters.has(this._drawerFilterId)&&this.closeDrawer()}destroy(){var a;this.closeDrawer(),(a=this._root)==null||a.remove(),this._root=null}_getCategories(){const a=new Map;a.set("all","All");for(const t of this._filters){const n=t.category||"other";a.has(n)||a.set(n,n.charAt(0).toUpperCase()+n.slice(1))}return a}_renderCategories(){this._catRow.innerHTML="",this._getCategories().forEach((t,n)=>{const i=bt("div",{className:`mvfp-cat${this._selectedCategory===n?" active":""}`,onClick:()=>{this._selectedCategory=n,this._renderCategories(),this._renderFilters()}},t);this._catRow.appendChild(i)})}_currentFilters(){return this._selectedCategory==="all"?this._filters:this._filters.filter(a=>(a.category||"other")===this._selectedCategory)}_renderFilters(){this._filterRow.innerHTML="";for(const a of this._currentFilters()){const t=this._activeFilters.has(a.id),n=this._selectedFilterId===a.id,i=bt("div",{className:`mvfp-filter${t?" active":""}${n?" selected":""}`,onClick:()=>this._selectFilter(a)});if(t){const r=bt("div",{className:"mvfp-check",onClick:l=>{l.stopPropagation(),this._removeFilter(a.id)}});r.innerHTML="✓",i.appendChild(r)}i.appendChild(bt("span",{},a.name)),this._filterRow.appendChild(i)}}_selectFilter(a){var t,n,i,r;this._selectedFilterId=a.id,this._activeFilters.has(a.id)||(n=(t=this._cb).onApplyFilter)==null||n.call(t,a),(r=(i=this._cb).onPreviewFilter)==null||r.call(i,a),this._renderFilters(),a.params&&a.params.length>0&&this.openDrawer(a.id)}_removeFilter(a){var t,n;(n=(t=this._cb).onRemoveFilter)==null||n.call(t,a),this._selectedFilterId===a&&(this._selectedFilterId=null)}_renderActiveChips(){if(this._activeRow.innerHTML="",this._activeFilters.size===0){this._activeRow.appendChild(bt("div",{className:"mvfp-placeholder"},"No active filters"));return}this._activeFilters.forEach((a,t)=>{const n=this._filters.find(d=>d.id===t);if(!n)return;const i=this._drawerOpen&&this._drawerFilterId===t,r=bt("div",{className:`mvfp-achip${i?" selected":""}`}),l=bt("span",{style:{cursor:"pointer"},onClick:()=>{this._selectedFilterId=t,this._renderFilters(),n.params&&n.params.length>0&&this.openDrawer(t)}},n.name),s=bt("button",{className:"mvfp-achip-x","aria-label":`Remove ${n.name}`,onClick:d=>{d.stopPropagation(),this._removeFilter(t)}});s.innerHTML='<svg width="10" height="10" viewBox="0 0 12 12"><path d="M3 3l6 6M9 3l-6 6" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',r.appendChild(l),r.appendChild(s),this._activeRow.appendChild(r)})}_buildDrawer(){this._drawer=bt("div",{className:"mvfp-drawer"});const a=bt("div",{className:"mvfp-drawer-hdr"});this._drawerTitle=bt("span",{className:"mvfp-drawer-title"},"Filter");const t=bt("div",{className:"mvfp-drawer-actions"});t.appendChild(bt("button",{className:"mvfp-drawer-btn",onClick:()=>this._resetDrawerFilter()},"Reset")),t.appendChild(bt("button",{className:"mvfp-drawer-btn danger",onClick:()=>{this._drawerFilterId&&(this._removeFilter(this._drawerFilterId),this.closeDrawer())}},"Remove"));const n=bt("button",{className:"mvfp-drawer-close","aria-label":"Close",onClick:()=>this.closeDrawer()});n.innerHTML='<svg width="14" height="14" viewBox="0 0 14 14"><path d="M3 3l8 8M11 3l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',t.appendChild(n),a.appendChild(this._drawerTitle),a.appendChild(t),this._drawer.appendChild(a),this._drawerBody=bt("div",{className:"mvfp-drawer-body"}),this._drawer.appendChild(this._drawerBody)}openDrawer(a){const t=this._filters.find(n=>n.id===a);if(t&&(this._drawerFilterId=a,this._drawerTitle.textContent=t.name,this._renderDrawerControls(t),this._renderActiveChips(),!this._drawerOpen)){this._drawerOpen=!0;const n=this._root.offsetHeight;n>0&&(this._drawer.style.height=n+"px"),this._drawer.style.transition="none",this._drawer.style.transform="translateY(100%)",this._drawer.offsetHeight,this._drawer.style.transition="transform 0.25s cubic-bezier(0.33, 1, 0.68, 1)",this._drawer.style.transform="translateY(0)"}}closeDrawer(){this._drawerOpen&&(this._drawerOpen=!1,this._drawerFilterId=null,this._drawer.style.transition="transform 0.2s cubic-bezier(0.32, 0, 0.67, 0)",this._drawer.style.transform="translateY(100%)",this._renderActiveChips())}_renderDrawerControls(a){if(this._drawerBody.innerHTML="",!a.params||a.params.length===0){this._drawerBody.appendChild(bt("div",{className:"mvfp-no-params"},"No adjustable parameters"));return}const t=this._activeFilters.get(a.id),n=(t==null?void 0:t.params)||{};for(const i of a.params){const r=n[i.id]??i.default,l=bt("div",{className:"mvfp-ctl"}),s=bt("label",{className:"mvfp-ctl-label"},i.label||i.id);l.appendChild(s);const d=i.type||"slider";if(d==="slider"||d==="range"){const c=bt("div",{className:"mvfp-slider-row"}),u=bt("span",{className:"mvfp-range-val"},Pc(r)),m=bt("input",{type:"range",className:"mvfp-range",min:String(i.min??0),max:String(i.max??1),step:String(i.step??.01),value:String(typeof r=="number"?r:i.default??0),onInput:p=>{var h,v;const f=parseFloat(p.target.value);u.textContent=Pc(f),(v=(h=this._cb).onUpdateParam)==null||v.call(h,a.id,i.id,f)}});c.appendChild(m),c.appendChild(u),l.appendChild(c)}else if(d==="toggle"||d==="checkbox"){const c=bt("div",{className:"mvfp-toggle-row"}),u=bt("input",{type:"checkbox",checked:r?"checked":void 0,onChange:m=>{var p,f;return(f=(p=this._cb).onUpdateParam)==null?void 0:f.call(p,a.id,i.id,m.target.checked)}});c.appendChild(u),l.appendChild(c)}else if(d==="color"){const c=bt("div",{className:"mvfp-color-row"}),u=bt("input",{type:"color",className:"mvfp-color-input",value:typeof r=="string"?r:"#000000",onInput:m=>{var p,f;return(f=(p=this._cb).onUpdateParam)==null?void 0:f.call(p,a.id,i.id,m.target.value)}});c.appendChild(u),l.appendChild(c)}else if(d==="select"||d==="dropdown"){const c=bt("div",{className:"mvfp-select-row"}),u=bt("select",{className:"mvfp-select",onChange:m=>{var p,f;return(f=(p=this._cb).onUpdateParam)==null?void 0:f.call(p,a.id,i.id,m.target.value)}});for(const m of i.options||[]){const p=bt("option",{value:m.value},m.label||String(m.value));m.value===r&&(p.selected=!0),u.appendChild(p)}c.appendChild(u),l.appendChild(c)}this._drawerBody.appendChild(l)}}_resetDrawerFilter(){var t,n;if(!this._drawerFilterId)return;const a=this._filters.find(i=>i.id===this._drawerFilterId);if(a!=null&&a.params){for(const i of a.params)(n=(t=this._cb).onUpdateParam)==null||n.call(t,this._drawerFilterId,i.id,i.default);this._renderDrawerControls(a)}}}const D2=[200,500,1e3];function A2(o){return{"360p":[640,360],"480p":[854,480],"720p":[1280,720],"1080p":[1920,1080],"1440p":[2560,1440],"2160p":[3840,2160]}[o??""]??[1920,1080]}function Oc(o){if(!o)return null;const a=o.duration;if(typeof a=="number"&&Number.isFinite(a)&&a>0)return a;if(a&&typeof a=="object"&&"value"in a){const t=a.value;if(typeof t=="number"&&Number.isFinite(t)&&t>0)return t}return null}function R2(o){return new Promise(a=>{window.setTimeout(a,o)})}async function zc(){return await Promise.resolve().then(()=>require("./PixiFrameExporter-DhAJGzIK.cjs"))}function jc(o,a=0){var r;const t=o.timeline[0],n=t?Math.max(0,t.sourceIn):0,i=(t==null?void 0:t.sourceOut)??((r=o.source)==null?void 0:r.duration)??a;return Math.max(0,i-n)}function Km(o){let a=null;return{canExportClientSide:async()=>{try{const{isWebCodecsSupported:i}=await zc();return i()}catch{return!1}},renderRecipeWithPixi:async(i,r,l)=>{var f,h,v,k;const s=i.timeline[0],d=s?Math.max(0,s.sourceIn):0,c=s?s.sourceOut:void 0,[u,m]=A2((r==null?void 0:r.quality)??((f=i.output)==null?void 0:f.quality)),p=((h=i.output)==null?void 0:h.fps)||30;o.setPlaying(!1),o.forcePixiPreview.value=!0,await e.nextTick();try{let y=!1;for(const A of D2){await R2(A);const P=o.getPreviewRef();if(!(!P||typeof P.captureFrameAt!="function")){if(typeof P.ensureReadyForCapture=="function"){if(y=await P.ensureReadyForCapture(),y)break;continue}y=!0;break}}const w=o.getPreviewRef();if(!w||typeof w.captureFrameAt!="function")throw new Error("PIXI preview not available for export. Ensure the preview is mounted.");if(!y)throw new Error("PIXI preview not ready for frame capture after retries. The video may still be loading.");const{exportWithPixiFrames:g,isWebCodecsSupported:b}=await zc();if(!b())throw new Error("WebCodecs is not supported in this browser. Export requires Chrome 94+ or equivalent.");a=new AbortController;const R={width:u,height:m,fps:p,trimStart:d,signal:a.signal};c!==void 0&&(R.trimEnd=c),l&&(R.onProgress=l);const V=o.getSourceUrl();V!==""&&(R.sourceUrl=V);const I=Oc(w)??((v=i.source)==null?void 0:v.duration)??c??0,x=await g({captureFrameAt:A=>{var P;return((P=w.captureFrameAt)==null?void 0:P.call(w,A))??Promise.resolve(null)},duration:{value:I}},R),T=new File([x],`edited-video-${Date.now()}.mp4`,{type:"video/mp4"}),$=Oc(w),S=((k=i.source)==null?void 0:k.duration)??0,_=Math.max(0,(c??$??S)-d);return{file:T,recipe:i,meta:{duration:_,width:u,height:m,format:"mp4",sizeBytes:T.size,size_bytes:T.size}}}finally{o.forcePixiPreview.value=!1,a=null}},cancelClientExport:()=>{a==null||a.abort(),a=null},resetClientExport:()=>{a=null}}}const Lo="default-video-track",Nn="default-media-source";function Jm(o){var r,l;const a=P2(o),t=U2(o),n=O2(o.timeline,((r=t[0])==null?void 0:r.id)??Lo,((l=a[0])==null?void 0:l.id)??Nn),i={version:o.version,source:{...o.source},mediaSources:a,tracks:z2(t,n),clips:n,markers:o.markers?o.markers.map(s=>({...s})):[],transitions:o.transitions?o.transitions.map(Qm):[],filters:o.filters.map(s=>({...s,params:{...s.params}})),audio:{...o.audio},output:{...o.output}};return typeof o.duration=="number"&&(i.duration=o.duration),o.snapSettings&&(i.snapSettings={...o.snapSettings}),o.textOverlays&&(i.textOverlays=[...o.textOverlays]),o.captionTracks&&(i.captionTracks=o.captionTracks.map(ep)),o.visualLayers&&(i.visualLayers=o.visualLayers.map(tp)),o.audioTracks&&(i.audioTracks=[...o.audioTracks]),o.posterFrame&&(i.posterFrame=o.posterFrame),o.metadata&&(i.metadata={...o.metadata}),i}function L2(o){const a={version:"1.0",source:{...o.source},timeline:o.clips.map(t=>({...t})),mediaSources:o.mediaSources.map(qm),tracks:o.tracks.map(Ym),markers:o.markers.map(t=>({...t})),transitions:o.transitions.map(Qm),filters:o.filters.map(t=>({...t,params:{...t.params}})),audio:{...o.audio},output:{...o.output}};return typeof o.duration=="number"&&(a.duration=o.duration),o.snapSettings&&(a.snapSettings={...o.snapSettings}),o.textOverlays&&(a.textOverlays=[...o.textOverlays]),o.captionTracks&&(a.captionTracks=o.captionTracks.map(ep)),o.visualLayers&&(a.visualLayers=o.visualLayers.map(tp)),o.audioTracks&&(a.audioTracks=[...o.audioTracks]),o.posterFrame&&(a.posterFrame=o.posterFrame),o.metadata&&(a.metadata={...o.metadata}),a}function P2(o){var t,n;if(o.mediaSources&&o.mediaSources.length>0)return o.mediaSources.map(qm);const a={id:((t=o.timeline.find(i=>i.sourceRefId))==null?void 0:t.sourceRefId)??Nn,type:"media",mediaUuid:o.source.media_uuid,duration:o.source.duration,width:o.source.original_width,height:o.source.original_height};return(n=o.metadata)!=null&&n.source_url&&(a.url=o.metadata.source_url),[a]}function U2(o){var a;return o.tracks&&o.tracks.length>0?o.tracks.map(Ym):[{id:((a=o.timeline.find(t=>t.trackId))==null?void 0:a.trackId)??Lo,type:"video",name:"Video",order:0}]}function O2(o,a,t){return o.map(n=>{const i={...n,trackId:n.trackId??a,sourceRefId:n.sourceRefId??t};return n.filters&&(i.filters=n.filters.map(r=>({...r,params:{...r.params}}))),n.transform&&(i.transform={...n.transform}),n.keyframes&&(i.keyframes=n.keyframes.map(r=>({...r}))),i})}function z2(o,a){return o.map(t=>{const n=a.filter(i=>i.trackId===t.id).map(i=>i.id);return{...t,clipIds:n}})}function qm(o){const a={...o};return o.metadata&&(a.metadata={...o.metadata}),a}function Ym(o){const a={...o};return o.clipIds&&(a.clipIds=[...o.clipIds]),a}function Qm(o){const a={...o};return o.params&&(a.params={...o.params}),a}function ep(o){return{...o,segments:o.segments.map(t=>{const n={...t};return t.words&&(n.words=t.words.map(i=>({...i}))),n})}}function tp(o){return{...o,transform:{...o.transform,position:{...o.transform.position},anchor:{...o.transform.anchor},scale:{...o.transform.scale}},keyframes:o.keyframes?o.keyframes.map(a=>({...a})):void 0}}const ap="video-project-draft-snapshot:v1",Ls="mediables:video-project-drafts",j2=(o,a={})=>{var p,f;const t=pn(a.now)??Date.now(),n=pn(a.createdAt)??t,i=pn(a.updatedAt)??t,r=tE(o),l={id:Ma(a.id)??iE(i),payloadKind:r,createdAt:new Date(n).toISOString(),updatedAt:new Date(i).toISOString(),deviceKind:a.deviceKind??"unknown"},s=Ma(a.projectId),d=Ma(a.sourceMediaUuid)??Ma(o.source.media_uuid),c=Ps(a.durationSeconds)??aE(o),u=Ma(a.editorVersion)??Ma((p=o.metadata)==null?void 0:p.editor_version),m=Ma(a.title)??Ma((f=o.metadata)==null?void 0:f.title);return s!==null&&(l.projectId=s),d!==null&&(l.sourceMediaUuid=d),c!==null&&(l.durationSeconds=c),u!==null&&(l.editorVersion=u),m!==null&&(l.title=m),a.saveReason!==void 0&&(l.saveReason=a.saveReason),{schemaVersion:ap,metadata:l,payload:o}},np=(o,a=Ls)=>{const t=Ma(a)??Ls,n=Xc(o.metadata.projectId??"unsaved-project"),i=Xc(o.metadata.id);return`${t}:${n}:${i}`},W2=o=>JSON.stringify(o),H2=o=>{if(typeof o!="string"||o.trim().length===0)return null;try{const a=JSON.parse(o);return Y2(a)?a:null}catch{return null}},Z2=o=>{const a=[];for(const t of o){const n=Ma(t.key),i=H2(t.value);n===null||i===null||a.push({key:n,snapshot:i})}return Si(a)},G2=(o,a)=>{const t=oE(a.maxCount),n=pn(a.now)??Date.now(),i=sp(a.maxAgeMs),r=[],l=[];let s=0;for(const d of Si(o)){if(!rp(d,a.projectId)){r.push(d);continue}if(lp(d.snapshot,n,i)||s>=t){l.push(d);continue}r.push(d),s+=1}return{retained:Si(r),removed:Si(l)}},X2=(o,a={})=>{const t={key:np(o),snapshot:o};if(!rp(t,a.projectId))return!1;const n=pn(a.now)??Date.now(),i=sp(a.maxAgeMs);if(lp(o,n,i))return!1;const r=a.savedAt===null?null:pn(a.savedAt);return r===null?!0:jr(o)>r},K2=(o,a={})=>Si(o).filter(t=>X2(t.snapshot,a)),J2=(o,a,t={})=>{const n=K2(o,t);if(a==="mobile"){const i=n[0]??null;return i===null?[]:[i]}return n},q2=async(o,a,t=np(a))=>(await o.setItem(t,W2(a)),{key:t,snapshot:a}),Wc=async(o,a=Ls)=>{const t=await o.listKeys(a),n=[];for(const i of t)n.push({key:i,value:await o.getItem(i)});return Z2(n)},Hc=async(o,a)=>{for(const t of a)await o.removeItem(t.key)},Y2=o=>!fn(o)||o.schemaVersion!==ap||!Q2(o.metadata)?!1:o.metadata.payloadKind==="project"?op(o.payload):eE(o.payload),Q2=o=>fn(o)?_d(o.id)&&lE(o.payloadKind)&&Gc(o.createdAt)&&Gc(o.updatedAt)&&sE(o.deviceKind)&&mr(o.projectId)&&mr(o.sourceMediaUuid)&&rE(o.durationSeconds)&&mr(o.editorVersion)&&mr(o.title)&&dE(o.saveReason):!1,eE=o=>fn(o)?o.version==="1.0"&&ip(o.source)&&Array.isArray(o.timeline)&&Array.isArray(o.filters)&&fn(o.audio)&&fn(o.output):!1,op=o=>fn(o)?o.version==="1.0"&&ip(o.source)&&Array.isArray(o.mediaSources)&&Array.isArray(o.tracks)&&Array.isArray(o.clips)&&Array.isArray(o.markers)&&Array.isArray(o.filters)&&fn(o.audio)&&fn(o.output):!1,ip=o=>fn(o)?_d(o.media_uuid)&&Ci(o.duration)&&Ci(o.original_width)&&Ci(o.original_height):!1,tE=o=>op(o)?"project":"recipe",aE=o=>Ps(o.duration)??Ps(o.source.duration),rp=(o,a)=>{const t=Ma(a);return t===null?!0:o.snapshot.metadata.projectId===t},lp=(o,a,t)=>t===null?!1:a-jr(o)>t,Si=o=>[...o].sort(nE),nE=(o,a)=>{const t=jr(a.snapshot)-jr(o.snapshot);if(t!==0)return t;const n=Zc(a.snapshot)-Zc(o.snapshot);return n!==0?n:o.snapshot.metadata.id.localeCompare(a.snapshot.metadata.id)},jr=o=>pn(o.metadata.updatedAt)??0,Zc=o=>pn(o.metadata.createdAt)??0,oE=o=>!Number.isFinite(o)||o<0?0:Math.floor(o),sp=o=>o===void 0||!Number.isFinite(o)||o<0?null:Math.floor(o),pn=o=>{if(o==null)return null;if(o instanceof Date)return Number.isFinite(o.getTime())?o.getTime():null;if(typeof o=="number")return Number.isFinite(o)?o:null;const a=o.trim();if(a.length===0)return null;const t=Date.parse(a);return Number.isFinite(t)?t:null},Gc=o=>typeof o=="string"&&pn(o)!==null,iE=o=>{var t;const a=typeof((t=globalThis.crypto)==null?void 0:t.randomUUID)=="function"?globalThis.crypto.randomUUID():Math.random().toString(36).slice(2,12);return`draft-${o}-${a}`},Xc=o=>encodeURIComponent(o.trim()),Ma=o=>{if(typeof o!="string")return null;const a=o.trim();return a.length>0?a:null},_d=o=>Ma(o)!==null,mr=o=>o===void 0||_d(o),Ps=o=>{if(!Ci(o))return null;const a=Number(o.toFixed(6));return Object.is(a,-0)?0:a},Ci=o=>typeof o=="number"&&Number.isFinite(o)&&o>=0,rE=o=>o===void 0||Ci(o),lE=o=>o==="recipe"||o==="project",sE=o=>o==="desktop"||o==="mobile"||o==="tablet"||o==="unknown",dE=o=>o===void 0||o==="autosave"||o==="manual"||o==="before-export"||o==="before-close",fn=o=>typeof o=="object"&&o!==null&&!Array.isArray(o),cE=1,uE="master",Mi=-60,Us=12,Ed=0,Vn=-90,Wr=6,mE=4,dp=8;function cp(){return{mobile:{canAdjustTrackFaders:!0,canAdjustMasterFader:!0,canMuteTracks:!0,canSoloTracks:!0,canAdjustPan:!1,canViewMeters:!0,canEditEffectSlots:!1,canEditRouting:!1,canEditAutomation:!1,meterMode:"basic",maxEffectSlots:0},desktop:{canAdjustTrackFaders:!0,canAdjustMasterFader:!0,canMuteTracks:!0,canSoloTracks:!0,canAdjustPan:!0,canViewMeters:!0,canEditEffectSlots:!0,canEditRouting:!0,canEditAutomation:!0,meterMode:"full",maxEffectSlots:dp}}}function pE(o,a=cp()){return zs(a[o])}function up(o){return Number.isNaN(o)?Ed:o<=0||o===Number.NEGATIVE_INFINITY?Mi:$i(20*Math.log10(o))}function Os(o){const a=$i(o);return a<=Mi?0:Bn(Math.pow(10,a/20),6)}function $i(o){return Number.isNaN(o)?Ed:o===Number.NEGATIVE_INFINITY?Mi:o===Number.POSITIVE_INFINITY?Us:Bn(Wi(o,Mi,Us),3)}function mp(o){return Number.isFinite(o)?Bn(Wi(o,-1,1),3):0}function fE(o,a=!1){const t=o.some(n=>n.controls.solo);return o.map(n=>{const i=n.controls.muted,r=t&&!n.controls.solo,l=a||i||r,s=l?0:n.controls.fader.linearGain;return{trackId:n.id,soloed:n.controls.solo,mutedByTrack:i,mutedBySolo:r,mutedByMaster:a,effectivelyMuted:l,audible:!l,effectiveGainLinear:s}})}function hE(o,a={}){const t=xE(a.effectSlotCount),n=new Set;return{schemaVersion:cE,capabilities:a.capabilities?BE(a.capabilities):cp(),tracks:o.map((i,r)=>gE(i,r,t,n)),master:bE(a.master,t)}}function pp(o){const a=$i(o);return{valueDb:a,minDb:Mi,maxDb:Us,unityDb:Ed,linearGain:Os(a)}}function vE(o,a="constant-power"){return{value:mp(o),mode:a}}function fp(o=Vn,a=Vn,t=o){const n=ql(o),i=ql(a),r=ql(t);return{peakDb:n,rmsDb:i,peakHoldDb:r,clipping:n>=0||r>=0}}function hp(o){const a=bp(o);return{id:`empty-effect-slot-${a}`,index:a,kind:"empty",label:"Empty",enabled:!1,bypassed:!0,wetMix:0,parameters:{}}}function gE(o,a,t,n){const i=gp(o.id),l={id:CE(i??`legacy-audio-track-${a+1}`,n),kind:"legacy-url",name:_E(o.name,a),order:a,source:yE(o.source),controls:{fader:pp(o.faderDb??up(o.volume??1)),pan:vE(o.pan??0),muted:o.muted??!1,solo:o.solo??!1,meter:fp(o.peakDb,o.rmsDb,o.peakHoldDb)},timeline:wE(o),effectSlots:vp(o.effectSlots,t)};return i!==void 0&&(l.legacyTrackId=i),l}function bE(o,a){return{id:uE,name:EE(o==null?void 0:o.name),fader:pp((o==null?void 0:o.faderDb)??up((o==null?void 0:o.volume)??1)),muted:(o==null?void 0:o.muted)??!1,meter:fp(o==null?void 0:o.peakDb,o==null?void 0:o.rmsDb,o==null?void 0:o.peakHoldDb),effectSlots:vp(o==null?void 0:o.effectSlots,a)}}function yE(o){const a=o.trim();return a===""?{type:"missing"}:{type:"url",url:a}}function wE(o){const a={startTime:VE(o.startTime??0),loop:o.loop??!1},t=NE(o.duration);t!==void 0&&(a.duration=t);const n=Kc(o.fadeIn);n!==void 0&&(a.fadeIn=n);const i=Kc(o.fadeOut);return i!==void 0&&(a.fadeOut=i),a}function vp(o,a){const t=new Map;for(const n of o??[]){const i=kE(n,a);t.set(i.index,i)}return Array.from({length:a},(n,i)=>t.get(i)??hp(i))}function kE(o,a){const t=bp(o.index),n=a>0?Math.min(t,a-1):0,i=o.kind;return i==="empty"?hp(n):{id:gp(o.id)??`${i}-effect-slot-${n}`,index:n,kind:i,label:SE(o.label,i),enabled:o.enabled,bypassed:o.bypassed,wetMix:TE(o.wetMix),parameters:{...o.parameters}}}function _E(o,a){const t=o==null?void 0:o.trim();return t&&t!==""?t:`Audio ${a+1}`}function EE(o){const a=o==null?void 0:o.trim();return a&&a!==""?a:"Master"}function SE(o,a){const t=o.trim();return t!==""?t:a}function CE(o,a){if(!a.has(o))return a.add(o),o;let t=2,n=`${o}-${t}`;for(;a.has(n);)t+=1,n=`${o}-${t}`;return a.add(n),n}function gp(o){const a=o==null?void 0:o.trim();if(!(!a||a===""))return a}function xE(o){return o===void 0||!Number.isFinite(o)?mE:Math.trunc(Wi(o,0,dp))}function bp(o){return!Number.isFinite(o)||o<0?0:Math.trunc(o)}function NE(o){if(!(o===void 0||!Number.isFinite(o)||o<=0))return Bn(o,3)}function Kc(o){if(!(o===void 0||!Number.isFinite(o)||o<0))return Bn(o,3)}function VE(o){return!Number.isFinite(o)||o<0?0:Bn(o,3)}function TE(o){return Number.isFinite(o)?Bn(Wi(o,0,1),3):1}function ql(o){return Number.isNaN(o)||o===Number.NEGATIVE_INFINITY?Vn:o===Number.POSITIVE_INFINITY?Wr:Bn(Wi(o,Vn,Wr),3)}function BE(o){return{mobile:zs(o.mobile),desktop:zs(o.desktop)}}function zs(o){return{...o}}function Wi(o,a,t){return Math.min(t,Math.max(a,o))}function Bn(o,a){const t=10**a;return Math.round(o*t)/t}const IE=/^(\d{2,}:[0-5]\d:[0-5]\d,\d{3})\s+-->\s+(\d{2,}:[0-5]\d:[0-5]\d,\d{3})$/,ME=/^(\d{2,}):([0-5]\d):([0-5]\d),(\d{3})$/,$E="srt-cue";class Tn extends Error{constructor(a,t,n={}){super(t),this.name="CaptionSrtError",this.code=a,this.context=n}}function FE(o,a={}){var l,s;const t=DE(a.idPrefix),n=o.replace(/^\uFEFF/,"").replace(/\r\n?/g,`
|
|
337
337
|
`).split(`
|
|
338
338
|
`),i=[];let r=0;for(;r<n.length;){for(;r<n.length&&eu(n[r]);)r+=1;if(r>=n.length)break;const d=r+1,c=AE(((l=n[r])==null?void 0:l.trim())??"",d);if(r+=1,r>=n.length)throw new Tn("missing-timing",`Cue ${c} is missing its timing line.`,{cueIndex:i.length,cueNumber:c,lineNumber:d});const u=r+1,m=RE(((s=n[r])==null?void 0:s.trim())??"",c,u);r+=1;const p=[];for(;r<n.length&&!eu(n[r]);)p.push(n[r]??""),r+=1;i.push({cueNumber:c,id:`${t}-${i.length+1}`,startTime:m.startTime,endTime:m.endTime,text:p.join(`
|
|
339
339
|
`)})}return yp(i),i}function Jc(o){return yp(o),o.length===0?"":`${o.map((a,t)=>PE(a,t+1)).join(`
|
|
@@ -354,4 +354,4 @@ ${i.text}
|
|
|
354
354
|
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
355
355
|
*/function qs(o,a){(a==null||a>o.length)&&(a=o.length);for(var t=0,n=Array(a);t<a;t++)n[t]=o[t];return n}function DF(o){if(Array.isArray(o))return qs(o)}function AF(o,a,t){return(a=OF(a))in o?Object.defineProperty(o,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):o[a]=t,o}function RF(o){if(typeof Symbol<"u"&&o[Symbol.iterator]!=null||o["@@iterator"]!=null)return Array.from(o)}function LF(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
356
356
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Tu(o,a){var t=Object.keys(o);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(o);a&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(o,i).enumerable})),t.push.apply(t,n)}return t}function Bu(o){for(var a=1;a<arguments.length;a++){var t=arguments[a]!=null?arguments[a]:{};a%2?Tu(Object(t),!0).forEach(function(n){AF(o,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(t)):Tu(Object(t)).forEach(function(n){Object.defineProperty(o,n,Object.getOwnPropertyDescriptor(t,n))})}return o}function PF(o){return DF(o)||RF(o)||zF(o)||LF()}function UF(o,a){if(typeof o!="object"||!o)return o;var t=o[Symbol.toPrimitive];if(t!==void 0){var n=t.call(o,a);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(o)}function OF(o){var a=UF(o,"string");return typeof a=="symbol"?a:a+""}function zF(o,a){if(o){if(typeof o=="string")return qs(o,a);var t={}.toString.call(o).slice(8,-1);return t==="Object"&&o.constructor&&(t=o.constructor.name),t==="Map"||t==="Set"?Array.from(o):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?qs(o,a):void 0}}var Iu={activateTrap:function(a,t){if(a.length>0){var n=a[a.length-1];n!==t&&n._setPausedState(!0)}var i=a.indexOf(t);i===-1||a.splice(i,1),a.push(t)},deactivateTrap:function(a,t){var n=a.indexOf(t);n!==-1&&a.splice(n,1),a.length>0&&!a[a.length-1]._isManuallyPaused()&&a[a.length-1]._setPausedState(!1)}},jF=function(a){return a.tagName&&a.tagName.toLowerCase()==="input"&&typeof a.select=="function"},WF=function(a){return(a==null?void 0:a.key)==="Escape"||(a==null?void 0:a.key)==="Esc"||(a==null?void 0:a.keyCode)===27},Ni=function(a){return(a==null?void 0:a.key)==="Tab"||(a==null?void 0:a.keyCode)===9},HF=function(a){return Ni(a)&&!a.shiftKey},ZF=function(a){return Ni(a)&&a.shiftKey},Mu=function(a){return setTimeout(a,0)},di=function(a){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return typeof a=="function"?a.apply(void 0,n):a},br=function(a){return a.target.shadowRoot&&typeof a.composedPath=="function"?a.composedPath()[0]:a.target},GF=[],XF=function(a,t){var n=(t==null?void 0:t.document)||document,i=(t==null?void 0:t.trapStack)||GF,r=Bu({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:HF,isKeyBackward:ZF},t),l={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,manuallyPaused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},s,d=function(_,A,P){return _&&_[A]!==void 0?_[A]:r[P||A]},c=function(_,A){var P=typeof(A==null?void 0:A.composedPath)=="function"?A.composedPath():void 0;return l.containerGroups.findIndex(function(D){var z=D.container,M=D.tabbableNodes;return z.contains(_)||(P==null?void 0:P.includes(z))||M.find(function(Z){return Z===_})})},u=function(_){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},P=A.hasFallback,D=P===void 0?!1:P,z=A.params,M=z===void 0?[]:z,Z=r[_];if(typeof Z=="function"&&(Z=Z.apply(void 0,PF(M))),Z===!0&&(Z=void 0),!Z){if(Z===void 0||Z===!1)return Z;throw new Error("`".concat(_,"` was specified but was not a node, or did not return a node"))}var O=Z;if(typeof Z=="string"){try{O=n.querySelector(Z)}catch(K){throw new Error("`".concat(_,'` appears to be an invalid selector; error="').concat(K.message,'"'))}if(!O&&!D)throw new Error("`".concat(_,"` as selector refers to no known node"))}return O},m=function(){var _=u("initialFocus",{hasFallback:!0});if(_===!1)return!1;if(_===void 0||_&&!rs(_,r.tabbableOptions))if(c(n.activeElement)>=0)_=n.activeElement;else{var A=l.tabbableGroups[0],P=A&&A.firstTabbableNode;_=P||u("fallbackFocus")}else _===null&&(_=u("fallbackFocus"));if(!_)throw new Error("Your focus-trap needs to have at least one focusable element");return _},p=function(){if(l.containerGroups=l.containers.map(function(_){var A=MF(_,r.tabbableOptions),P=$F(_,r.tabbableOptions),D=A.length>0?A[0]:void 0,z=A.length>0?A[A.length-1]:void 0,M=P.find(function(K){return Co(K)}),Z=P.slice().reverse().find(function(K){return Co(K)}),O=!!A.find(function(K){return Gn(K)>0});return{container:_,tabbableNodes:A,focusableNodes:P,posTabIndexesFound:O,firstTabbableNode:D,lastTabbableNode:z,firstDomTabbableNode:M,lastDomTabbableNode:Z,nextTabbableNode:function(de){var Ne=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,ce=A.indexOf(de);return ce<0?Ne?P.slice(P.indexOf(de)+1).find(function(le){return Co(le)}):P.slice(0,P.indexOf(de)).reverse().find(function(le){return Co(le)}):A[ce+(Ne?1:-1)]}}}),l.tabbableGroups=l.containerGroups.filter(function(_){return _.tabbableNodes.length>0}),l.tabbableGroups.length<=0&&!u("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(l.containerGroups.find(function(_){return _.posTabIndexesFound})&&l.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},f=function(_){var A=_.activeElement;if(A)return A.shadowRoot&&A.shadowRoot.activeElement!==null?f(A.shadowRoot):A},h=function(_){if(_!==!1&&_!==f(document)){if(!_||!_.focus){h(m());return}_.focus({preventScroll:!!r.preventScroll}),l.mostRecentlyFocusedNode=_,jF(_)&&_.select()}},v=function(_){var A=u("setReturnFocus",{params:[_]});return A||(A===!1?!1:_)},k=function(_){var A=_.target,P=_.event,D=_.isBackward,z=D===void 0?!1:D;A=A||br(P),p();var M=null;if(l.tabbableGroups.length>0){var Z=c(A,P),O=Z>=0?l.containerGroups[Z]:void 0;if(Z<0)z?M=l.tabbableGroups[l.tabbableGroups.length-1].lastTabbableNode:M=l.tabbableGroups[0].firstTabbableNode;else if(z){var K=l.tabbableGroups.findIndex(function(C){var U=C.firstTabbableNode;return A===U});if(K<0&&(O.container===A||rs(A,r.tabbableOptions)&&!Co(A,r.tabbableOptions)&&!O.nextTabbableNode(A,!1))&&(K=Z),K>=0){var de=K===0?l.tabbableGroups.length-1:K-1,Ne=l.tabbableGroups[de];M=Gn(A)>=0?Ne.lastTabbableNode:Ne.lastDomTabbableNode}else Ni(P)||(M=O.nextTabbableNode(A,!1))}else{var ce=l.tabbableGroups.findIndex(function(C){var U=C.lastTabbableNode;return A===U});if(ce<0&&(O.container===A||rs(A,r.tabbableOptions)&&!Co(A,r.tabbableOptions)&&!O.nextTabbableNode(A))&&(ce=Z),ce>=0){var le=ce===l.tabbableGroups.length-1?0:ce+1,W=l.tabbableGroups[le];M=Gn(A)>=0?W.firstTabbableNode:W.firstDomTabbableNode}else Ni(P)||(M=O.nextTabbableNode(A))}}else M=u("fallbackFocus");return M},y=function(_){var A=br(_);if(!(c(A,_)>=0)){if(di(r.clickOutsideDeactivates,_)){s.deactivate({returnFocus:r.returnFocusOnDeactivate});return}di(r.allowOutsideClick,_)||_.preventDefault()}},w=function(_){var A=br(_),P=c(A,_)>=0;if(P||A instanceof Document)P&&(l.mostRecentlyFocusedNode=A);else{_.stopImmediatePropagation();var D,z=!0;if(l.mostRecentlyFocusedNode)if(Gn(l.mostRecentlyFocusedNode)>0){var M=c(l.mostRecentlyFocusedNode),Z=l.containerGroups[M].tabbableNodes;if(Z.length>0){var O=Z.findIndex(function(K){return K===l.mostRecentlyFocusedNode});O>=0&&(r.isKeyForward(l.recentNavEvent)?O+1<Z.length&&(D=Z[O+1],z=!1):O-1>=0&&(D=Z[O-1],z=!1))}}else l.containerGroups.some(function(K){return K.tabbableNodes.some(function(de){return Gn(de)>0})})||(z=!1);else z=!1;z&&(D=k({target:l.mostRecentlyFocusedNode,isBackward:r.isKeyBackward(l.recentNavEvent)})),h(D||l.mostRecentlyFocusedNode||m())}l.recentNavEvent=void 0},g=function(_){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;l.recentNavEvent=_;var P=k({event:_,isBackward:A});P&&(Ni(_)&&_.preventDefault(),h(P))},b=function(_){(r.isKeyForward(_)||r.isKeyBackward(_))&&g(_,r.isKeyBackward(_))},R=function(_){WF(_)&&di(r.escapeDeactivates,_)!==!1&&(_.preventDefault(),s.deactivate())},V=function(_){var A=br(_);c(A,_)>=0||di(r.clickOutsideDeactivates,_)||di(r.allowOutsideClick,_)||(_.preventDefault(),_.stopImmediatePropagation())},I=function(){if(l.active)return Iu.activateTrap(i,s),l.delayInitialFocusTimer=r.delayInitialFocus?Mu(function(){h(m())}):h(m()),n.addEventListener("focusin",w,!0),n.addEventListener("mousedown",y,{capture:!0,passive:!1}),n.addEventListener("touchstart",y,{capture:!0,passive:!1}),n.addEventListener("click",V,{capture:!0,passive:!1}),n.addEventListener("keydown",b,{capture:!0,passive:!1}),n.addEventListener("keydown",R),s},x=function(){if(l.active)return n.removeEventListener("focusin",w,!0),n.removeEventListener("mousedown",y,!0),n.removeEventListener("touchstart",y,!0),n.removeEventListener("click",V,!0),n.removeEventListener("keydown",b,!0),n.removeEventListener("keydown",R),s},T=function(_){var A=_.some(function(P){var D=Array.from(P.removedNodes);return D.some(function(z){return z===l.mostRecentlyFocusedNode})});A&&h(m())},$=typeof window<"u"&&"MutationObserver"in window?new MutationObserver(T):void 0,S=function(){$&&($.disconnect(),l.active&&!l.paused&&l.containers.map(function(_){$.observe(_,{subtree:!0,childList:!0})}))};return s={get active(){return l.active},get paused(){return l.paused},activate:function(_){if(l.active)return this;var A=d(_,"onActivate"),P=d(_,"onPostActivate"),D=d(_,"checkCanFocusTrap");D||p(),l.active=!0,l.paused=!1,l.nodeFocusedBeforeActivation=f(n),A==null||A();var z=function(){D&&p(),I(),S(),P==null||P()};return D?(D(l.containers.concat()).then(z,z),this):(z(),this)},deactivate:function(_){if(!l.active)return this;var A=Bu({onDeactivate:r.onDeactivate,onPostDeactivate:r.onPostDeactivate,checkCanReturnFocus:r.checkCanReturnFocus},_);clearTimeout(l.delayInitialFocusTimer),l.delayInitialFocusTimer=void 0,x(),l.active=!1,l.paused=!1,S(),Iu.deactivateTrap(i,s);var P=d(A,"onDeactivate"),D=d(A,"onPostDeactivate"),z=d(A,"checkCanReturnFocus"),M=d(A,"returnFocus","returnFocusOnDeactivate");P==null||P();var Z=function(){Mu(function(){M&&h(v(l.nodeFocusedBeforeActivation)),D==null||D()})};return M&&z?(z(v(l.nodeFocusedBeforeActivation)).then(Z,Z),this):(Z(),this)},pause:function(_){return l.active?(l.manuallyPaused=!0,this._setPausedState(!0,_)):this},unpause:function(_){return l.active?(l.manuallyPaused=!1,i[i.length-1]!==this?this:this._setPausedState(!1,_)):this},updateContainerElements:function(_){var A=[].concat(_).filter(Boolean);return l.containers=A.map(function(P){return typeof P=="string"?n.querySelector(P):P}),l.active&&p(),S(),this}},Object.defineProperties(s,{_isManuallyPaused:{value:function(){return l.manuallyPaused}},_setPausedState:{value:function(_,A){if(l.paused===_)return this;if(l.paused=_,_){var P=d(A,"onPause"),D=d(A,"onPostPause");P==null||P(),x(),S(),D==null||D()}else{var z=d(A,"onUnpause"),M=d(A,"onPostUnpause");z==null||z(),p(),I(),S(),M==null||M()}return this}}}),s.updateContainerElements(a),s};const KF=["aria-labelledby"],JF={class:"media-preview-sheet__header"},qF=["id"],YF=["aria-label"],QF=["src","alt"],e8=["src"],t8={class:"media-preview-sheet__actions"},a8=["disabled","aria-label"],n8=["aria-label","aria-pressed"],o8=["disabled","aria-label"],i8=e.defineComponent({__name:"MediaPreviewSheet",props:{open:{type:Boolean,default:!1},media:{default:null},canGoPrevious:{type:Boolean,default:!1},canGoNext:{type:Boolean,default:!1},selected:{type:Boolean,default:!1},closeLabel:{default:"Close"},previousLabel:{default:"Previous"},nextLabel:{default:"Next"},selectLabel:{default:"Select"},deselectLabel:{default:"Deselect"}},emits:["close","previous","next","toggleSelect"],setup(o,{emit:a}){const t=o,n=a,i=e.useId(),r=e.ref(null),l=e.ref(null);let s=null,d=null;const c=e.computed(()=>{var $;return(($=t.media)==null?void 0:$.mime_type.startsWith("image/"))===!0}),u=/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/ig,m=/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i,p=e.computed(()=>t.media?t.media.preview_url??t.media.original_url:"");function f($){const S=$.replace(/\.[^.]+$/,""),_=S.replace(u,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim();return _!==""?_:S||$}function h($){var A,P;const S=(A=$.name)==null?void 0:A.trim(),B=$.file_name.replace(/\.[^.]+$/,"");if(S!==void 0&&S!==""&&S!==$.file_name&&S!==B&&!m.test(S))return S;const _=(P=$.alt_text)==null?void 0:P.trim();return _!==void 0&&_!==""?_:f(S||$.file_name)}const v=e.computed(()=>t.media?h(t.media):"media"),k=e.computed(()=>t.media?`Preview ${v.value}`:"Media preview"),y=e.computed(()=>t.media?`Close preview of ${v.value}`:"Close preview"),w=e.computed(()=>t.canGoPrevious?"Previous media":"No previous media"),g=e.computed(()=>t.canGoNext?"Next media":"No next media"),b=e.computed(()=>{const $=t.selected?t.deselectLabel:t.selectLabel;return t.media?t.selected?`${t.deselectLabel} ${v.value}`:`${t.selectLabel} ${v.value}`:$}),R=e.computed(()=>t.selected?t.deselectLabel:t.selectLabel),V=()=>{t.media&&n("toggleSelect",t.media)},I=$=>{if($.key==="Escape"){$.preventDefault(),n("close");return}if($.key==="ArrowLeft"&&t.canGoPrevious){$.preventDefault(),n("previous");return}$.key==="ArrowRight"&&t.canGoNext&&($.preventDefault(),n("next"))},x=()=>{if(s){try{s.deactivate({returnFocus:!1})}catch{}s=null}},T=()=>{const $=d;d=null,$&&typeof $.focus=="function"&&e.nextTick(()=>{$.focus()})};return e.watch(()=>t.open&&t.media!==null,async $=>{var S;if($){d=document.activeElement instanceof HTMLElement?document.activeElement:null,await e.nextTick();const B=r.value;if(B)try{s=XF(B,{initialFocus:()=>l.value??B,escapeDeactivates:!1,clickOutsideDeactivates:!1,returnFocusOnDeactivate:!1,allowOutsideClick:!0}),s.activate()}catch{(S=l.value)==null||S.focus()}}else x(),T()},{immediate:!0}),e.onBeforeUnmount(()=>{x()}),($,S)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[$.open&&$.media?(e.openBlock(),e.createElementBlock("section",{key:0,ref_key:"sheetRef",ref:r,class:"media-preview-sheet",role:"dialog","aria-modal":"true","aria-labelledby":e.unref(i),tabindex:"-1","data-testid":"media-preview-sheet",onKeydown:I},[e.createElementVNode("header",JF,[e.createElementVNode("strong",{id:e.unref(i),"data-testid":"media-preview-sheet-title"},e.toDisplayString(k.value),9,qF),e.createElementVNode("button",{ref_key:"closeButtonRef",ref:l,type:"button",class:"media-preview-sheet__close","aria-label":y.value,"data-testid":"btn-media-preview-close",onClick:S[0]||(S[0]=B=>n("close"))},e.toDisplayString($.closeLabel),9,YF)]),c.value?(e.openBlock(),e.createElementBlock("img",{key:0,class:"media-preview-sheet__image",src:p.value,alt:$.media.alt_text||v.value},null,8,QF)):(e.openBlock(),e.createElementBlock("video",{key:1,class:"media-preview-sheet__video",src:p.value,controls:""},null,8,e8)),e.createElementVNode("div",t8,[e.createElementVNode("button",{type:"button",class:"media-preview-sheet__nav",disabled:!$.canGoPrevious,"aria-label":w.value,"data-testid":"btn-media-preview-previous",onClick:S[1]||(S[1]=B=>n("previous"))},e.toDisplayString($.previousLabel),9,a8),e.createElementVNode("button",{type:"button",class:"media-preview-sheet__select","aria-label":b.value,"aria-pressed":$.selected,"data-testid":"btn-media-preview-select",onClick:V},e.toDisplayString(R.value),9,n8),e.createElementVNode("button",{type:"button",class:"media-preview-sheet__nav",disabled:!$.canGoNext,"aria-label":g.value,"data-testid":"btn-media-preview-next",onClick:S[2]||(S[2]=B=>n("next"))},e.toDisplayString($.nextLabel),9,o8)])],40,KF)):e.createCommentVNode("",!0)]))}}),Md=$e(i8,[["__scopeId","data-v-fa05530d"]]),r8={key:0,class:"media-album-grid","data-testid":"media-source-sheet"},l8={class:"media-album-grid__items"},s8={class:"media-album-grid__card-name"},d8={class:"media-album-grid__card-name"},c8=["data-testid","onClick"],u8={class:"media-album-grid__card-name"},m8={key:0,class:"media-album-grid__card-meta"},p8={key:0,class:"media-album-grid__empty"},f8=e.defineComponent({__name:"MediaSourceSheet",props:{open:{type:Boolean,default:!1},currentView:{},albums:{},viewLibraryLabel:{default:"Library"},browseAlbumsLabel:{default:"Albums"},createAlbumLabel:{default:"Create album"},enableAlbumCreation:{type:Boolean,default:!1}},emits:["close","selectLibrary","selectAlbum","createAlbum"],setup(o,{emit:a}){const t=a;return(n,i)=>n.open?(e.openBlock(),e.createElementBlock("section",r8,[e.createElementVNode("div",l8,[n.enableAlbumCreation?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-album-grid__card media-album-grid__card--create","data-testid":"btn-media-source-create-album",onClick:i[0]||(i[0]=r=>t("createAlbum"))},[i[2]||(i[2]=e.createElementVNode("div",{class:"media-album-grid__card-icon"},[e.createElementVNode("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.createElementVNode("line",{x1:"5",y1:"12",x2:"19",y2:"12"})])],-1)),e.createElementVNode("span",s8,e.toDisplayString(n.createAlbumLabel),1)])):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["media-album-grid__card",{"is-active":n.currentView.scope==="library"}]),"data-testid":"btn-media-source-library",onClick:i[1]||(i[1]=r=>t("selectLibrary"))},[i[3]||(i[3]=e.createStaticVNode('<div class="media-album-grid__card-icon" data-v-129f67b1><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" data-v-129f67b1><rect x="3" y="3" width="7" height="7" data-v-129f67b1></rect><rect x="14" y="3" width="7" height="7" data-v-129f67b1></rect><rect x="14" y="14" width="7" height="7" data-v-129f67b1></rect><rect x="3" y="14" width="7" height="7" data-v-129f67b1></rect></svg></div>',1)),e.createElementVNode("span",d8,e.toDisplayString(n.viewLibraryLabel),1),i[4]||(i[4]=e.createElementVNode("span",{class:"media-album-grid__card-meta"},"All media",-1))],2),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.albums,r=>(e.openBlock(),e.createElementBlock("button",{key:r.id,type:"button",class:e.normalizeClass(["media-album-grid__card",{"is-active":n.currentView.scope==="album"&&n.currentView.albumId===r.id}]),"data-testid":`btn-media-source-album-${r.id}`,onClick:l=>t("selectAlbum",r)},[i[5]||(i[5]=e.createElementVNode("div",{class:"media-album-grid__card-icon"},[e.createElementVNode("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})])],-1)),e.createElementVNode("span",u8,e.toDisplayString(r.name),1),r.mediaCount!==void 0?(e.openBlock(),e.createElementBlock("span",m8,e.toDisplayString(r.mediaCount)+" item"+e.toDisplayString(r.mediaCount===1?"":"s"),1)):e.createCommentVNode("",!0)],10,c8))),128))]),n.albums.length===0?(e.openBlock(),e.createElementBlock("p",p8," No albums yet. ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}}),hf=$e(f8,[["__scopeId","data-v-129f67b1"]]),h8={key:0,class:"media-upload-sheet","data-testid":"media-upload-sheet"},v8={class:"media-upload-sheet__dropzone-text"},g8={key:0,class:"media-upload-sheet__dropzone-helper","data-testid":"text-media-upload-sheet-helper"},b8={class:"media-upload-sheet__sr-only"},y8=["accept","aria-label"],w8=["aria-label"],k8={class:"media-upload-sheet__queue-row"},_8={key:0,class:"media-upload-sheet__preview"},E8=["src","alt","data-testid"],S8={class:"media-upload-sheet__queue-body"},C8={class:"media-upload-sheet__queue-info"},x8={class:"media-upload-sheet__queue-status"},N8=["aria-valuenow","aria-label","data-testid"],V8=["aria-label"],T8=e.defineComponent({__name:"MediaUploadSheet",props:{open:{type:Boolean,default:!1},queue:{},accept:{default:""},uploadLabel:{default:"Upload"},dropzoneLabel:{default:"Drop files here or browse"},dropzoneHelperText:{default:""},fileInputLabel:{default:"Choose media files"},closeButtonAriaLabel:{default:"Close upload panel"},closeButtonLabel:{default:"Done"},progressAriaLabel:{}},emits:["close","filesSelected"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(!1),r=p=>{var h;return t.progressAriaLabel!==void 0?t.progressAriaLabel(p):`Uploading ${((h=p.file)==null?void 0:h.name)??"file"}`},l=p=>{const f=Number.isFinite(p.progress)?p.progress:0;return f<0?0:f>100?100:Math.round(f)},s=e.computed(()=>t.queue.length===0?"":`${t.queue.length} upload${t.queue.length===1?"":"s"} in progress`),d=p=>{const f=p.target;!(f instanceof HTMLInputElement)||f.files===null||(n("filesSelected",Array.from(f.files)),f.value="")},c=p=>{p.preventDefault(),i.value=!0},u=()=>{i.value=!1},m=p=>{var f;p.preventDefault(),i.value=!1,(f=p.dataTransfer)!=null&&f.files&&p.dataTransfer.files.length>0&&n("filesSelected",Array.from(p.dataTransfer.files))};return(p,f)=>p.open?(e.openBlock(),e.createElementBlock("section",h8,[e.createElementVNode("label",{class:e.normalizeClass(["media-upload-sheet__dropzone",{"is-drag-over":i.value}]),onDragover:c,onDragleave:u,onDrop:m},[f[1]||(f[1]=e.createStaticVNode('<div class="media-upload-sheet__dropzone-icon" data-v-df614629><svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" data-v-df614629><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" data-v-df614629></path><polyline points="17 8 12 3 7 8" data-v-df614629></polyline><line x1="12" y1="3" x2="12" y2="15" data-v-df614629></line></svg></div>',1)),e.createElementVNode("span",v8,e.toDisplayString(p.dropzoneLabel),1),p.dropzoneHelperText?(e.openBlock(),e.createElementBlock("span",g8,e.toDisplayString(p.dropzoneHelperText),1)):e.createCommentVNode("",!0),e.createElementVNode("span",b8,e.toDisplayString(p.fileInputLabel),1),e.createElementVNode("input",{type:"file",accept:p.accept,multiple:"",class:"media-upload-sheet__file-input","data-testid":"input-media-upload-sheet","aria-label":p.fileInputLabel,onChange:d},null,40,y8)],34),p.queue.length>0?(e.openBlock(),e.createElementBlock("ul",{key:0,class:"media-upload-sheet__queue","aria-live":"polite","aria-label":s.value,"data-testid":"list-media-upload-sheet-queue"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.queue,h=>(e.openBlock(),e.createElementBlock("li",{key:h.id,class:"media-upload-sheet__queue-item"},[e.createElementVNode("div",k8,[h.previewUrl?(e.openBlock(),e.createElementBlock("div",_8,[e.createElementVNode("img",{src:h.previewUrl,alt:`Preview of ${h.file.name}`,"data-testid":`img-media-upload-sheet-preview-${h.id}`},null,8,E8)])):e.createCommentVNode("",!0),e.createElementVNode("div",S8,[e.createElementVNode("div",C8,[e.createElementVNode("strong",null,e.toDisplayString(h.file.name),1),e.createElementVNode("span",x8,e.toDisplayString(h.status),1)]),e.createElementVNode("div",{class:"media-upload-sheet__progress-bar",role:"progressbar","aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":l(h),"aria-label":r(h),"data-testid":`progress-media-upload-sheet-${h.id}`},[e.createElementVNode("div",{class:"media-upload-sheet__progress-fill",style:e.normalizeStyle({width:`${l(h)}%`})},null,4)],8,N8)])])]))),128))],8,w8)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"media-upload-sheet__close-btn","aria-label":p.closeButtonAriaLabel,"data-testid":"btn-close-upload-sheet",onClick:f[0]||(f[0]=h=>n("close"))},e.toDisplayString(p.closeButtonLabel),9,V8)])):e.createCommentVNode("",!0)}}),vf=$e(T8,[["__scopeId","data-v-df614629"]]),B8=["aria-label","aria-pressed","data-testid"],I8=["src","alt"],M8={key:1,class:"media-thumbnail-cell__video"},$8={class:"media-thumbnail-cell__video-name"},F8={key:2,class:"media-thumbnail-cell__selected-badge"},D8={key:3,class:"media-thumbnail-cell__status-badge"},A8=["aria-label"],R8=e.defineComponent({__name:"MediaThumbnailCell",props:{media:{},selected:{type:Boolean,default:!1},status:{},testId:{default:"media-library-thumbnail"}},emits:["toggle","preview"],setup(o,{emit:a}){const t=o,n=a,i=e.computed(()=>t.media.thumbnail_url??t.media.preview_url??t.media.original_url),r=e.computed(()=>t.media.mime_type.startsWith("image/")),l=e.computed(()=>{switch(t.status){case"missing":return"Unavailable";case"forbidden":return"Restricted";case"uploading":return"Uploading";case"failed":return"Failed";case"file_lost":return"Needs file";default:return null}}),s=e.computed(()=>{const u=t.media.file_name;return t.selected?`Deselect ${u}`:`Select ${u}`}),d=()=>{n("toggle",t.media)},c=()=>{n("preview",t.media)};return(u,m)=>(e.openBlock(),e.createElementBlock("article",{class:e.normalizeClass(["media-thumbnail-cell",{"is-selected":u.selected,"has-status":l.value!==null}])},[e.createElementVNode("button",{type:"button",class:"media-thumbnail-cell__button","aria-label":s.value,"aria-pressed":u.selected?"true":"false","data-testid":u.testId,onClick:d},[r.value?(e.openBlock(),e.createElementBlock("img",{key:0,class:"media-thumbnail-cell__image",src:i.value,alt:u.media.file_name},null,8,I8)):(e.openBlock(),e.createElementBlock("div",M8,[m[0]||(m[0]=e.createElementVNode("span",{class:"media-thumbnail-cell__video-label"},"Video",-1)),e.createElementVNode("span",$8,e.toDisplayString(u.media.file_name),1)])),u.selected?(e.openBlock(),e.createElementBlock("span",F8," Selected ")):e.createCommentVNode("",!0),l.value!==null?(e.openBlock(),e.createElementBlock("span",D8,e.toDisplayString(l.value),1)):e.createCommentVNode("",!0)],8,B8),e.createElementVNode("button",{type:"button",class:"media-thumbnail-cell__preview-button","aria-label":`Preview ${u.media.file_name}`,onClick:c}," Preview ",8,A8)],2))}}),gf=$e(R8,[["__scopeId","data-v-edd4f0ad"]]),L8={class:"virtual-media-grid"},P8={key:0,class:"virtual-media-grid__state","data-testid":"media-grid-loading"},U8={key:1,class:"virtual-media-grid__state","data-testid":"media-grid-empty"},O8={key:2,class:"virtual-media-grid__items"},z8=["disabled"],j8=e.defineComponent({__name:"VirtualMediaGrid",props:{items:{},selectedItems:{},loading:{type:Boolean,default:!1},loadingMore:{type:Boolean,default:!1},hasMore:{type:Boolean,default:!1},emptyMessage:{default:"No media found."},testIdPrefix:{default:"media-grid-item"},loadingMessage:{default:"Loading media..."},loadMoreLabel:{default:"Load more"},loadingMoreLabel:{default:"Loading…"}},emits:["toggle","preview","loadMore"],setup(o,{emit:a}){const t=o,n=a;function i(r){return t.selectedItems.find(l=>l.id===r)}return(r,l)=>(e.openBlock(),e.createElementBlock("div",L8,[r.loading&&r.items.length===0?(e.openBlock(),e.createElementBlock("div",P8,e.toDisplayString(r.loadingMessage),1)):r.items.length===0?(e.openBlock(),e.createElementBlock("div",U8,e.toDisplayString(r.emptyMessage),1)):(e.openBlock(),e.createElementBlock("div",O8,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,s=>{var d,c;return e.openBlock(),e.createBlock(gf,{key:s.uuid,media:s,selected:((d=i(s.uuid))==null?void 0:d.status)==="ready",status:(c=i(s.uuid))==null?void 0:c.status,"test-id":`${r.testIdPrefix}-${s.uuid}`,onToggle:l[0]||(l[0]=u=>n("toggle",u)),onPreview:l[1]||(l[1]=u=>n("preview",u))},null,8,["media","selected","status","test-id"])}),128))])),r.hasMore?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"virtual-media-grid__load-more",disabled:r.loadingMore,"data-testid":"btn-media-grid-load-more",onClick:l[2]||(l[2]=s=>n("loadMore"))},e.toDisplayString(r.loadingMore?r.loadingMoreLabel:r.loadMoreLabel),9,z8)):e.createCommentVNode("",!0)]))}}),bf=$e(j8,[["__scopeId","data-v-34667f65"]]);function Yr(o){if(o===0)return"0 Bytes";const a=1024,t=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(o)/Math.log(a));return parseFloat((o/Math.pow(a,n)).toFixed(2))+" "+t[n]}function yf(o){var t;const a=o.split(".");return a.length>1?`.${(t=a.pop())==null?void 0:t.toLowerCase()}`:""}function $d(o){return o.type.startsWith("image/")}async function wf(o){return $d(o)?new Promise(a=>{const t=new Image,n=URL.createObjectURL(o);t.onload=()=>{URL.revokeObjectURL(n),a({width:t.naturalWidth,height:t.naturalHeight})},t.onerror=()=>{URL.revokeObjectURL(n),a(null)},t.src=n}):null}async function kf(o,a){const t=[];if(a.maxFileSize&&o.size>a.maxFileSize&&t.push({field:"size",message:`File exceeds maximum size of ${Yr(a.maxFileSize)}`,code:"MAX_FILE_SIZE"}),a.minFileSize&&o.size<a.minFileSize&&t.push({field:"size",message:`File is smaller than minimum size of ${Yr(a.minFileSize)}`,code:"MIN_FILE_SIZE"}),a.acceptedMimeTypes&&a.acceptedMimeTypes.length>0&&(a.acceptedMimeTypes.some(i=>i.endsWith("/*")?o.type.startsWith(i.slice(0,-1)):o.type===i)||t.push({field:"type",message:`File type "${o.type}" is not allowed`,code:"INVALID_MIME_TYPE"})),a.acceptedExtensions&&a.acceptedExtensions.length>0){const n=yf(o.name);a.acceptedExtensions.some(r=>r.toLowerCase()===n.toLowerCase())||t.push({field:"extension",message:`File extension "${n}" is not allowed`,code:"INVALID_EXTENSION"})}if($d(o)&&(a.maxDimensions||a.minDimensions)){const n=await wf(o);n&&(a.maxDimensions&&(n.width>a.maxDimensions.width&&t.push({field:"dimensions",message:`Image width (${n.width}px) exceeds maximum (${a.maxDimensions.width}px)`,code:"MAX_WIDTH"}),n.height>a.maxDimensions.height&&t.push({field:"dimensions",message:`Image height (${n.height}px) exceeds maximum (${a.maxDimensions.height}px)`,code:"MAX_HEIGHT"})),a.minDimensions&&(n.width<a.minDimensions.width&&t.push({field:"dimensions",message:`Image width (${n.width}px) is smaller than minimum (${a.minDimensions.width}px)`,code:"MIN_WIDTH"}),n.height<a.minDimensions.height&&t.push({field:"dimensions",message:`Image height (${n.height}px) is smaller than minimum (${a.minDimensions.height}px)`,code:"MIN_HEIGHT"})))}if(a.customValidator){const n=await a.customValidator(o);t.push(...n)}return{valid:t.length===0,errors:t}}function Fd(o={}){const a=e.ref(o.rules||{});function t(d){a.value=d}async function n(d){return kf(d,a.value)}async function i(d){const c=new Map;return await Promise.all(d.map(async u=>{const m=await n(u);c.set(u,m)})),c}function r(d,c){return a.value.maxItems?c+d<=a.value.maxItems:!0}const l=e.computed(()=>{const d=[];return a.value.acceptedMimeTypes&&d.push(...a.value.acceptedMimeTypes),a.value.acceptedExtensions&&d.push(...a.value.acceptedExtensions),d.join(",")});function s(d){return!a.value.acceptedMimeTypes||a.value.acceptedMimeTypes.length===0?!0:a.value.acceptedMimeTypes.some(c=>c.endsWith("/*")?d.startsWith(c.slice(0,-1)):d===c)}return{rules:a,setRules:t,validateFile:n,validateFiles:i,canAddFiles:r,acceptString:l,isMimeTypeAllowed:s}}function W8(){return`upload-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function H8(o){if(o.type.startsWith("image/"))return URL.createObjectURL(o)}function Dd(o){const{adapter:a,maxConcurrent:t=3,rules:n,collection:i,onUploadStart:r,onUploadProgress:l,onUploadComplete:s,onUploadError:d,onQueueComplete:c,postUpload:u}=o,m=e.ref(new Map),p=e.ref(new Set),f=n?{rules:n}:{},{validateFile:h}=Fd(f);async function v(){if(p.value.size>=t)return;const B=Array.from(m.value.entries()).find(([P,D])=>D.status==="pending"&&!p.value.has(P));if(!B){Array.from(m.value.values()).every(D=>D.status==="completed"||D.status==="error")&&m.value.size>0&&(c==null||c());return}const[_,A]=B;await k(_,A)}async function k(B,_){p.value.add(B),_.status="uploading",_.abortController=new AbortController,m.value.set(B,{..._}),r==null||r(_);try{const A={onProgress:D=>{_.progress=D,m.value.set(B,{..._}),l==null||l(_)},signal:_.abortController.signal};i&&(A.collection=i);const P=await a.upload(_.file,A);u&&(_.status="attaching",m.value.set(B,{..._}),l==null||l(_),await u(_,P.media,a)),_.status="completed",_.progress=100,_.media=P.media,m.value.set(B,{..._}),s==null||s(_,P.media)}catch(A){A.name==="AbortError"?m.value.delete(B):(_.status="error",_.error=A.message,m.value.set(B,{..._}),d==null||d(_,A))}finally{p.value.delete(B),delete _.abortController,v()}}async function y(B){var P;const _=Array.from(B),A=[];for(const D of _){const z=await h(D),M=W8(),Z=H8(D),O={id:M,file:D,progress:0,status:z.valid?"pending":"error"};!z.valid&&((P=z.errors[0])!=null&&P.message)&&(O.error=z.errors[0].message),Z&&(O.previewUrl=Z),m.value.set(M,O);const K={media:null,clientId:M,name:D.name,order:0,upload:O,errors:z.errors};A.push(K)}for(let D=0;D<t;D++)v();return A}function w(B){const _=m.value.get(B);_&&(_.abortController&&_.abortController.abort(),_.previewUrl&&URL.revokeObjectURL(_.previewUrl),m.value.delete(B),p.value.delete(B),v())}async function g(B){const _=m.value.get(B);!_||_.status!=="error"||(_.status="pending",_.progress=0,delete _.error,m.value.set(B,{..._}),v())}function b(){for(const[B,_]of m.value.entries())(_.status==="completed"||_.status==="error")&&(_.previewUrl&&URL.revokeObjectURL(_.previewUrl),m.value.delete(B))}function R(){for(const B of m.value.values())B.abortController&&B.abortController.abort(),B.previewUrl&&URL.revokeObjectURL(B.previewUrl);m.value.clear(),p.value.clear()}function V(B){return m.value.get(B)}const I=e.computed(()=>p.value.size>0),x=e.computed(()=>p.value.size),T=e.computed(()=>Array.from(m.value.values()).filter(B=>B.status==="pending").length),$=e.computed(()=>m.value.size===0?!0:Array.from(m.value.values()).every(B=>B.status==="completed"||B.status==="error")),S=e.computed(()=>Array.from(m.value.values()));return{uploads:m,isUploading:I,activeCount:x,pendingCount:T,isComplete:$,addFiles:y,cancelUpload:w,retryUpload:g,clearCompleted:b,clearAll:R,getUpload:V,uploadsArray:S}}function oo(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}function Di(o){return typeof o=="string"?o:null}function ci(o){return typeof o=="number"?o:null}function Z8(o){return typeof o=="boolean"?o:null}function _f(o){return oo(o)&&typeof o.uuid=="string"&&typeof o.file_name=="string"&&typeof o.mime_type=="string"&&(typeof o.original_url=="string"||o.original_url===null)&&typeof o.size=="number"&&typeof o.disk=="string"&&typeof o.created_at=="string"&&typeof o.updated_at=="string"}function G8(o){return!oo(o)||typeof o.id!="string"||typeof o.status!="string"?null:o.status==="ready"?_f(o.media)?{id:o.id,status:"ready",media:o.media}:null:o.status==="missing"||o.status==="forbidden"?{id:o.id,status:o.status}:null}function X8(o){return oo(o)?{next_cursor:Di(o.next_cursor),previous_cursor:Di(o.previous_cursor),has_more:Z8(o.has_more)??!1,per_page:ci(o.per_page),count:ci(o.count),total:ci(o.total),current_page:ci(o.current_page),last_page:ci(o.last_page)}:null}function $u(o){const a=oo(o)?o:{},t=Array.isArray(a.data)?a.data.filter(_f):[],n=oo(a.meta)?a.meta:{},i=X8(n.pagination),r=(i==null?void 0:i.next_cursor)??Di(n.next_cursor)??Di(n.cursor),l=(i==null?void 0:i.has_more)??n.has_more===!0,s=Array.isArray(a.hydrated)?a.hydrated.map(G8).filter(c=>c!==null):[],d={cursor:r,has_more:l};return i!==null&&(d.pagination=i),{data:t,meta:d,hydrated:s}}function Fu(o,a,t,n,i,r){const l={view:o.scope==="album"?{scope:"album",album_id:o.albumId}:{scope:o.scope},per_page:t,sort:a.sort??"newest"};return a.query&&a.query.trim()!==""&&(l.query=a.query.trim()),a.kinds&&a.kinds.length>0&&(l.kinds=a.kinds),a.created_after&&a.created_after.trim()!==""&&(l.created_after=a.created_after.trim()),a.created_before&&a.created_before.trim()!==""&&(l.created_before=a.created_before.trim()),(a.usage_status==="used"||a.usage_status==="not_used")&&(l.usage_status=a.usage_status),(a.unfiled_only===!0||o.scope==="unfiled")&&(l.unfiled_only=1),a.selected_uuids&&a.selected_uuids.length>0&&(l.selected_uuids=[...a.selected_uuids]),r!=null?(l.page=r,l.include_total=1):n!==null&&(l.cursor=n),i&&i.length>0&&(l.hydrate_ids=i),l}function Du(o){const a=new Set,t=[];for(const n of o)a.has(n.uuid)||(a.add(n.uuid),t.push(n));return t}function K8(o){var t;if(!(o instanceof Error))return null;const a=(t=o.response)==null?void 0:t.status;return typeof a=="number"?a:null}function J8(o){var a;return o instanceof Error?((a=o.response)==null?void 0:a.data)??null:null}function q8(o){if(!oo(o))return[];const a=[];for(const t of Object.values(o)){if(typeof t=="string"&&t.trim()!==""){a.push(t.trim());continue}if(Array.isArray(t))for(const n of t){if(typeof n!="string")continue;const i=n.trim();i!==""&&a.push(i)}}return Array.from(new Set(a))}function Y8(o){var r;const a=J8(o),t=oo(a)?a:null,n=((r=Di(t==null?void 0:t.message))==null?void 0:r.trim())??null,i=q8(t==null?void 0:t.errors);return n!==null&&i.length>0?n==="Validation failed"?i.join(" "):i.every(s=>n.includes(s))?n:`${n} ${i.join(" ")}`:n!==null?n:i.length>0?i.join(" "):o instanceof Error?o.message:"Failed to load media."}function Au(o,a){const t=Y8(a),n=K8(a);return{code:n===403?"permission_denied":o,message:t,retriable:n!==403,cause:a}}function Ad(o){const a=()=>{const V=o.perPage!==void 0?e.toValue(o.perPage):40;return V>0?V:40},t=()=>{const V=o.page!==void 0?e.toValue(o.page):null;return V==null?null:V>0?V:1},n=e.ref([]),i=e.ref([]),r=e.ref(null),l=e.ref(!1),s=e.ref(!1),d=e.ref(!1),c=e.ref(!1),u=e.ref(null),m=e.ref(null),p=e.ref(null),f=e.ref(null);let h=null,v=0;const k=async(V,I)=>{v+=1;const x=v;h==null||h.abort();const T=new AbortController;h=T,V?d.value=!0:s.value=!0,u.value=null,c.value=!1;const $=I??t(),S=$!==null;try{const B=await o.httpClient.get("/v1/media/library",{params:Fu(o.view.value,o.filters.value,a(),S?null:V?r.value:null,void 0,$),signal:T.signal});if(x!==v)return;const _=$u(B);n.value=V&&!S?Du([...n.value,..._.data]):_.data,i.value=_.hydrated,r.value=_.meta.cursor,l.value=_.meta.has_more;const A=_.meta.pagination;m.value=(A==null?void 0:A.total)??null,p.value=(A==null?void 0:A.current_page)??(S&&$!==null?$:null);const P=(A==null?void 0:A.per_page)??a();f.value=(A==null?void 0:A.last_page)??(m.value!==null&&P>0?Math.max(1,Math.ceil(m.value/P)):null)}catch(B){if(T.signal.aborted||x!==v)return;const _=Au(V?"load_more_failed":"query_failed",B);u.value=_,c.value=_.code==="permission_denied",V||(n.value=[],r.value=null,l.value=!1)}finally{x===v&&(s.value=!1,d.value=!1)}},y=async V=>{if(V.length===0)return i.value=[],[];try{const I=await o.httpClient.get("/v1/media/library",{params:Fu(o.view.value,o.filters.value,1,null,V)}),x=$u(I);return i.value=x.hydrated,x.hydrated}catch(I){return u.value=Au("hydration_failed",I),[]}},w=V=>{n.value=Du([V,...n.value])},g=async()=>{!l.value||d.value||t()===null&&await k(!0)};return{items:n,hydrated:i,cursor:r,hasMore:l,loading:s,loadingMore:d,permissionDenied:c,error:u,total:m,currentPage:p,totalPages:f,loadInitial:async()=>{r.value=null,await k(!1)},loadMore:g,loadAll:async V=>{const I=(V==null?void 0:V.maxItems)??5e3;if(!(s.value||d.value))for(;l.value&&n.value.length<I;){const x=n.value.length;if(await g(),u.value!==null||n.value.length===x)return}},goToPage:async V=>{!Number.isFinite(V)||V<1||s.value||d.value||await k(!1,V)},refresh:async()=>{r.value=null,await k(!1)},hydrateSelection:y,prepend:w}}const Q8="mediables.media-library.";function e6(o){return!o||o.key.trim()===""?null:`${Q8}${o.key}`}function ls(){return typeof window>"u"||typeof window.sessionStorage>"u"?null:window.sessionStorage}function t6(o,a){const t=Date.parse(o);return Number.isFinite(t)?Date.now()-t>a*60*1e3:!0}function Ef(o){const a=e6(o),t=(o==null?void 0:o.ttlMinutes)??30,n=`${(o==null?void 0:o.key)??"media-library"}:${Date.now()}`;return{restore:()=>{if(a===null)return null;const s=ls();if(s===null)return null;const d=s.getItem(a);if(d===null)return null;let c;try{c=JSON.parse(d)}catch{return s.removeItem(a),null}if(typeof c!="object"||c===null||Array.isArray(c))return s.removeItem(a),null;const u=c;if(u.version!==1||typeof u.savedAt!="string"||t6(u.savedAt,t))return s.removeItem(a),null;const m={selectedIds:Array.isArray(u.selectedIds)?u.selectedIds.filter(p=>typeof p=="string"&&p.trim()!==""):[]};return((o==null?void 0:o.restoreView)??!0)&&u.view&&(m.view=u.view),u.filters&&(m.filters=u.filters),m},save:s=>{if(a===null)return;const d=ls();if(d===null)return;const c={version:1,savedAt:new Date().toISOString(),selectedIds:[...s.selectedIds]};((o==null?void 0:o.restoreView)??!0)&&s.view&&(c.view=s.view),s.filters&&(c.filters=s.filters),d.setItem(a,JSON.stringify(c))},clear:()=>{if(a===null)return;const s=ls();s==null||s.removeItem(a)},sessionId:n}}function Sf(o){const a=e.ref(o);return{state:a,transition:n=>{a.value=n}}}function Cf(o){return{emitMetric:(t,n)=>{const i={name:t,timestamp:new Date().toISOString()};n!==void 0&&(i.payload=n),o==null||o(i)}}}function Mo(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}function a6(o){const a=Mo(o)?o:{};return(Array.isArray(a.data)?a.data:Mo(a.data)&&Array.isArray(a.data.data)?a.data.data:Array.isArray(o)?o:[]).map(n=>{if(!Mo(n)||typeof n.id!="string"||typeof n.name!="string")return null;const i={id:n.id,name:n.name};return typeof n.description=="string"&&n.description.trim()!==""&&(i.description=n.description),typeof n.media_count=="number"&&(i.mediaCount=n.media_count),i}).filter(n=>n!==null)}function n6(o){const a=Mo(o)?o:{},t=Mo(a.data)?a.data:Mo(o)?o:null;if(t===null||typeof t.id!="string"||typeof t.name!="string")return null;const n={id:t.id,name:t.name};return typeof t.description=="string"&&t.description.trim()!==""&&(n.description=t.description),n}function o6(o){return o==="ready"||o==="uploading"||o==="failed"}function Un(o,a="ready"){return{id:o.uuid,media:o,status:a,countsTowardMax:o6(a)}}function i6(o,a){return o.scope==="library"?!0:o.scope!=="album"?!1:a.type==="album"&&a.albumId===o.albumId}function r6(o,a){return o.scope==="library"?a.type==="library"||a.type==="album":o.scope!=="album"?!1:a.type==="album"&&a.albumId===o.albumId}function ss(o){return{code:"configuration_error",message:o,retriable:!1}}const xf="/v1/albums";function l6(o){var a;return((a=o.deps.albumEndpoints)==null?void 0:a.list)??xf}function s6(o){var a,t;return((a=o.deps.albumEndpoints)==null?void 0:a.create)??((t=o.deps.albumEndpoints)==null?void 0:t.list)??xf}function d6(o){return typeof o!="string"||o.length===0?"document":o.startsWith("image/")?"image":o.startsWith("video/")?"video":o.startsWith("audio/")?"audio":"document"}function c6(o,a){return a.length===0||o===null?!0:a.includes(d6(o.mime_type))}function Ru(o){return{...o??{},...(o==null?void 0:o.kinds)!==void 0?{kinds:[...o.kinds]}:{},...(o==null?void 0:o.selected_uuids)!==void 0?{selected_uuids:[...o.selected_uuids]}:{}}}function Nf(o){var W,C;const a=o.selectionMode??"multiple",t=o.maxSelection,n=o.uploadBehavior??"adapter",i=e.ref(o.initialView??{scope:"library"}),r=((W=o.initialFilters)==null?void 0:W.kinds)??(o.allowedMediaKinds&&o.allowedMediaKinds.length>0?[...o.allowedMediaKinds]:void 0),l=e.ref({...Ru(o.initialFilters),sort:((C=o.initialFilters)==null?void 0:C.sort)??"newest",...r?{kinds:r}:{}}),s=o.allowedMediaKinds?[...o.allowedMediaKinds]:[],d=e.ref([]),c=e.ref([]),u=e.ref(null),m=e.ref(null),p=Ef(o.sessionPolicy),{emitMetric:f}=Cf(o.telemetry),h=Sf("idle"),v=Ad({httpClient:o.deps.httpClient,view:i,filters:l}),k=e.computed(()=>c.value.map(U=>U.id)),y=e.computed(()=>{const U=u.value;return U===null?null:v.items.value[U]??null}),w=e.computed(()=>o.uploadTarget??{type:"library"}),g=Dd({adapter:o.deps.uploadAdapter??{name:"missing-upload-adapter",upload:async()=>{throw new Error("Upload adapter is not configured.")},attach:async()=>{},attachMany:async()=>{},detach:async()=>{},reorder:async()=>{},fetchModelMedia:async()=>[],getUrl:U=>U.original_url,getThumbnailUrl:U=>U.thumbnail_url??U.preview_url??U.original_url},postUpload:async(U,j,re)=>{const ue=w.value;ue.type!=="album"||!ue.albumId||await re.attach(j.uuid,{modelType:"album",modelId:ue.albumId})},onUploadComplete:(U,j)=>{const re=w.value;i6(i.value,re)&&v.prepend(j),o.autoSelectUploaded&&r6(i.value,re)&&$(j),f("upload-complete",{mediaId:j.uuid,targetType:re.type,targetAlbumId:re.albumId})},onUploadError:(U,j)=>{m.value={code:"upload_failed",message:j.message,retriable:!0,cause:j}}}),b=e.computed(()=>g.isUploading.value),R=()=>{p.save({selectedIds:[...k.value],view:i.value,filters:l.value})},V=async U=>{const j=await v.hydrateSelection(U);c.value=j.map(re=>re.status==="ready"&&re.media?Un(re.media):{id:re.id,media:null,status:re.status,countsTowardMax:!1})},I=e.computed(()=>c.value.filter(U=>U.countsTowardMax).length),x=()=>a==="single"||t===void 0?!0:I.value<t,T=U=>{if(c.value.findIndex(re=>re.id===U.uuid)>=0){a==="multiple"?c.value=c.value.filter(re=>re.id!==U.uuid):c.value=[Un(U)],R();return}if(!x()){m.value={code:"selection_invalid",message:t!==void 0?`You can only select up to ${t} items.`:"You cannot select more items.",retriable:!0};return}a==="single"?c.value=[Un(U)]:c.value=[...c.value,Un(U)],m.value=null,R()},$=U=>{const j=c.value.findIndex(re=>re.id===U.uuid);if(j>=0){c.value=c.value.map((re,ue)=>ue===j?Un(U):re),m.value=null,R();return}if(!x()){m.value={code:"selection_invalid",message:t!==void 0?`You can only select up to ${t} items.`:"You cannot select more items.",retriable:!0};return}a==="single"?c.value=[Un(U)]:c.value=[...c.value,Un(U)],m.value=null,R()},S=async()=>{var j;h.transition("restoring");const U=p.restore();if(U===null){h.transition("ready");return}U.view&&(i.value=U.view),U.filters&&(l.value={...Ru(U.filters),sort:U.filters.sort??"newest"}),await v.loadInitial(),(((j=o.sessionPolicy)==null?void 0:j.restoreSelection)??!0)&&await V(U.selectedIds),h.transition("ready")};e.watch(()=>v.error.value,U=>{U!==null&&(m.value=U,h.transition("error"))});const B=async()=>{m.value=null,h.transition("idle"),await S(),v.items.value.length===0&&!v.loading.value&&!v.permissionDenied.value&&await v.loadInitial();const U=o.defaultSelectedIds??[];c.value.length===0&&U.length>0&&await V(U),h.transition("ready")},_=async(U,j="user")=>{const re=i.value;i.value=U,j==="user"&&o.preserveSelectionOnViewChange===!1&&(c.value=[]),f("view-change",{from:re.scope,to:U.scope,reason:j}),await v.loadInitial(),R()},A=async()=>{const U=await o.deps.httpClient.get(l6(o));d.value=a6(U)},P=async(U,j)=>{try{const re={name:U,visibility:"private"};j&&j.trim()!==""&&(re.parent_id=j);const ue=await o.deps.httpClient.post(s6(o),re),Xe=n6(ue);return Xe===null?ss("Album creation response was invalid."):(d.value=[Xe,...d.value.filter(be=>be.id!==Xe.id)],await _({scope:"album",albumId:Xe.id,albumName:Xe.name},"inline-album-created"),Xe)}catch(re){const ue={code:"album_create_failed",message:re instanceof Error?re.message:"Album creation failed.",retriable:!0,cause:re};return m.value=ue,ue}},D=async U=>{if(!o.enableUpload){m.value=ss("Uploads are not enabled for this picker.");return}if(n!=="delegate"){if(!o.deps.uploadAdapter){m.value=ss("Uploads require a configured upload adapter.");return}await g.addFiles(U)}},z=()=>{var re;if(s.length>0&&c.value.find(Xe=>Xe.media!==null&&!c6(Xe.media,s))){const be={code:"selection_invalid",message:`Selected media is not allowed here. Choose one of: ${s.join(", ")}.`,retriable:!0};return m.value=be,be}const U=((re=o.validateSelection)==null?void 0:re.call(o,c.value))??null;if(U!==null){const ue={code:"selection_invalid",message:U,retriable:!0};return m.value=ue,ue}if(c.value.filter(ue=>ue.status==="ready"&&ue.media!==null).length===0){const ue={code:"selection_invalid",message:"Select at least one available media item.",retriable:!0};return m.value=ue,ue}return{orderedIds:k.value,items:[...c.value],view:i.value,filters:l.value,dirty:!0,sessionId:p.sessionId}},M=U=>{const j=v.items.value.findIndex(re=>re.uuid===U.uuid);u.value=j>=0?j:null},Z=()=>{u.value=null},O=()=>{u.value===null||u.value<=0||(u.value-=1)},K=()=>{u.value===null||u.value>=v.items.value.length-1||(u.value+=1)},de=U=>{c.value=c.value.filter(j=>j.id!==U),R()},Ne=async()=>{await v.refresh()},ce=async U=>{l.value={...l.value,...U&&U.trim()!==""?{query:U.trim()}:{}},(!U||U.trim()==="")&&delete l.value.query,await v.loadInitial(),R()},le=async()=>{await _({scope:"library"},"permission-unavailable")};return{view:i,filters:l,albums:d,selectedItems:c,orderedIds:k,queryItems:v.items,cursor:v.cursor,hasMore:v.hasMore,loading:v.loading,loadingMore:v.loadingMore,permissionDenied:v.permissionDenied,error:m,uploadQueue:g.uploadsArray,isUploading:b,previewIndex:u,previewItem:y,initialize:B,refresh:Ne,loadMore:v.loadMore,setQuery:ce,setView:_,toggleSelection:T,removeSelected:de,confirmSelection:z,openPreview:M,closePreview:Z,showPreviousPreview:O,showNextPreview:K,loadAlbums:A,createAlbum:P,addUploadFiles:D,goToLibrary:le,sessionId:p.sessionId}}const u6=["data-testid"],m6={class:"mlp-location-bar"},p6={class:"mlp-location-bar__left"},f6={class:"mlp-location-bar__label"},h6={class:"mlp-tabs","data-testid":"media-picker-tabs"},v6={key:0,class:"mlp-search-row"},g6=["placeholder"],b6={key:2,class:"mlp-overlay-panel"},y6={key:0,class:"mlp-error","data-testid":"media-picker-error"},w6={key:5,class:"mlp-bottom-bar"},k6={key:0,class:"mlp-bottom-bar__selection"},_6={class:"mlp-bottom-bar__count"},E6={class:"mlp-bottom-bar__thumbs"},S6=["src","alt"],C6={key:1,class:"mlp-bottom-bar__thumb-placeholder"},x6=["aria-label","onClick"],N6={class:"mlp-bottom-bar__actions"},V6=e.defineComponent({__name:"MediaLibraryPicker",props:{deps:{},mode:{default:"picker-multi"},capabilities:{default:()=>({})},itemFilter:{},modelValue:{default:()=>[]},defaultSelectedIds:{default:()=>[]},selectionMode:{default:"multiple"},maxSelection:{},preserveSelectionOnViewChange:{type:Boolean,default:!0},initialView:{default:()=>({scope:"library"})},initialFilters:{default:()=>({sort:"newest"})},enableUpload:{type:Boolean,default:!1},uploadBehavior:{default:"adapter"},enablePreview:{type:Boolean,default:!0},enableAlbumCreation:{type:Boolean,default:!1},allowedMediaKinds:{},accept:{},validateSelection:{},uploadTarget:{},autoSelectUploaded:{type:Boolean,default:!1},createAlbumDefaultVisibility:{default:"private"},sessionPolicy:{},labels:{default:()=>({})},showFooter:{type:Boolean,default:!0},testIdPrefix:{default:"media-picker"},telemetry:{}},emits:["update:modelValue","confirm","cancel","selection-change","select","view-change","error","metric","request-upload-files"],setup(o,{expose:a,emit:t}){const n=o,i=t,r=e.computed(()=>{var C,U,j,re,ue,Xe,be,Ee,ye,xe,Ce,Re,ze,rt,at,Dt,ht,St,ut,lt,Ct,Se,J,oe,De,fe,Ae,Ye,st,Bt,Vt,Lt,Pt,zt,Ot,jt,oa,Q,ge;return{title:((C=n.labels)==null?void 0:C.title)??"Media library",searchPlaceholder:((U=n.labels)==null?void 0:U.searchPlaceholder)??"Search your media",viewLibrary:((j=n.labels)==null?void 0:j.viewLibrary)??"Library",browseAlbums:((re=n.labels)==null?void 0:re.browseAlbums)??"Albums",createAlbum:((ue=n.labels)==null?void 0:ue.createAlbum)??"Create album",createAlbumNameLabel:((Xe=n.labels)==null?void 0:Xe.createAlbumNameLabel)??"Album name",emptyLibrary:((be=n.labels)==null?void 0:be.emptyLibrary)??"No media found in your library.",emptyAlbum:((Ee=n.labels)==null?void 0:Ee.emptyAlbum)??"No media found in this album.",networkError:((ye=n.labels)==null?void 0:ye.networkError)??"Unable to load media right now.",retry:((xe=n.labels)==null?void 0:xe.retry)??"Retry",selectedCount:((Ce=n.labels)==null?void 0:Ce.selectedCount)??(me=>`${me} selected`),confirmAction:((Re=n.labels)==null?void 0:Re.confirmAction)??"Attach selected",cancel:((ze=n.labels)==null?void 0:ze.cancel)??"Cancel",dismiss:((rt=n.labels)==null?void 0:rt.dismiss)??"Remove",uploadLabel:((at=n.labels)==null?void 0:at.uploadLabel)??"Upload",albumUnavailableTitle:((Dt=n.labels)==null?void 0:Dt.albumUnavailableTitle)??"Album unavailable",albumUnavailableBody:((ht=n.labels)==null?void 0:ht.albumUnavailableBody)??"You no longer have access to this album.",goToLibrary:((St=n.labels)==null?void 0:St.goToLibrary)??"Go to library",allMediaTab:((ut=n.labels)==null?void 0:ut.allMediaTab)??"All Media",loadingMedia:((lt=n.labels)==null?void 0:lt.loadingMedia)??"Loading media…",loadMore:((Ct=n.labels)==null?void 0:Ct.loadMore)??"Load more",loadingMore:((Se=n.labels)==null?void 0:Se.loadingMore)??"Loading…",uploadDropzone:((J=n.labels)==null?void 0:J.uploadDropzone)??"Drop files here or browse",uploadDropzoneHelper:((oe=n.labels)==null?void 0:oe.uploadDropzoneHelper)??"",uploadDone:((De=n.labels)==null?void 0:De.uploadDone)??"Done",uploadDoneAria:((fe=n.labels)==null?void 0:fe.uploadDoneAria)??"Close upload panel",uploadFileInputLabel:((Ae=n.labels)==null?void 0:Ae.uploadFileInputLabel)??"Choose media files",previewClose:((Ye=n.labels)==null?void 0:Ye.previewClose)??"Close preview",previewPrevious:((st=n.labels)==null?void 0:st.previewPrevious)??"Previous media",previewNext:((Bt=n.labels)==null?void 0:Bt.previewNext)??"Next media",previewSelect:((Vt=n.labels)==null?void 0:Vt.previewSelect)??"Select media",previewDeselect:((Lt=n.labels)==null?void 0:Lt.previewDeselect)??"Deselect media",selectAction:((Pt=n.labels)==null?void 0:Pt.selectAction)??"Select",allMedia:((zt=n.labels)==null?void 0:zt.allMedia)??((Ot=n.labels)==null?void 0:Ot.allMediaTab)??"All media",unfiled:((jt=n.labels)==null?void 0:jt.unfiled)??"Unfiled",pageTitle:((oa=n.labels)==null?void 0:oa.pageTitle)??((Q=n.labels)==null?void 0:Q.title)??"Media library",albumLabel:((ge=n.labels)==null?void 0:ge.albumLabel)??"Album"}}),l=e.computed(()=>n.mode),s=e.computed(()=>l.value==="picker-single"?"single":n.selectionMode),d=e.computed(()=>n.showFooter===!0&&l.value!=="picker-single"),c=e.computed(()=>n.enablePreview===!0&&l.value!=="picker-single"),u={deps:n.deps,selectionMode:s.value,initialView:n.initialView,initialFilters:n.initialFilters,...n.maxSelection!==void 0?{maxSelection:n.maxSelection}:{},...n.modelValue.length>0||n.defaultSelectedIds.length>0?{defaultSelectedIds:n.modelValue.length>0?n.modelValue:n.defaultSelectedIds}:{},...n.sessionPolicy?{sessionPolicy:n.sessionPolicy}:{},...n.enableUpload?{enableUpload:!0}:{},uploadBehavior:n.uploadBehavior,...n.uploadTarget?{uploadTarget:n.uploadTarget}:{},...n.autoSelectUploaded?{autoSelectUploaded:!0}:{},...n.validateSelection?{validateSelection:n.validateSelection}:{},...n.allowedMediaKinds&&n.allowedMediaKinds.length>0?{allowedMediaKinds:n.allowedMediaKinds}:{},preserveSelectionOnViewChange:n.preserveSelectionOnViewChange,telemetry:C=>{var U;(U=n.telemetry)==null||U.call(n,C),i("metric",C)}},m=Nf(u),p=e.ref(n.initialFilters.query??""),f=e.ref(n.enableUpload?"upload":"media"),h=e.ref(!1),v=JSON.stringify(n.modelValue.length>0?n.modelValue:n.defaultSelectedIds);let k=null;const y=e.computed(()=>JSON.stringify(m.orderedIds.value)!==v),w=e.computed(()=>m.view.value.scope==="album"?r.value.emptyAlbum:r.value.emptyLibrary),g=e.computed(()=>r.value.selectedCount(m.selectedItems.value.length));function b(C){return typeof C=="boolean"?{allowed:C}:typeof C=="string"?{allowed:!1,reason:C}:C}function R(C){return n.itemFilter?b(n.itemFilter(C)):{allowed:!0}}const V=e.computed(()=>n.itemFilter?m.queryItems.value.filter(C=>R(C).allowed):m.queryItems.value),I=e.computed(()=>m.view.value.scope==="album"?m.view.value.albumName??"Album":r.value.viewLibrary),x=e.computed(()=>m.view.value.scope==="album"),T=()=>{k!==null&&(window.clearTimeout(k),k=null)},$=()=>{i("update:modelValue",[...m.orderedIds.value]),i("selection-change",{orderedIds:[...m.orderedIds.value],items:[...m.selectedItems.value],dirty:y.value})},S=C=>{C!==null&&i("error",C)},B=C=>typeof C.code=="string",_=C=>typeof C=="object"&&C!==null&&"code"in C&&typeof C.code=="string",A=()=>{const C=m.confirmSelection();if(B(C)){S(C);return}i("confirm",{...C,dirty:y.value})},P=C=>{const U=R(C);if(!U.allowed){S({code:"selection_invalid",message:U.reason??"This media item is not available for this picker.",retriable:!0});return}m.toggleSelection(C),l.value==="picker-single"&&i("select",C)},D=(C="user")=>{i("cancel",{dirty:y.value,reason:C,sessionId:m.sessionId})},z=async()=>{f.value="albums",await m.loadAlbums()},M=async()=>{await m.goToLibrary(),f.value="albums",await m.loadAlbums()},Z=C=>{m.setView({scope:"album",albumId:C.id,albumName:C.name}),f.value="media"},O=async(C,U)=>{const j=m.view.value,re=await m.createAlbum(C,U);if(_(re)){S(re);return}h.value=!1,f.value="media",i("view-change",{from:j,to:{scope:"album",albumId:re.id,albumName:re.name},reason:"inline-album-created",restoredFromSession:!1})},K=async C=>{if(n.uploadBehavior==="delegate"){i("request-upload-files",{files:[...C],view:m.view.value,filters:m.filters.value,sessionId:m.sessionId});return}await m.addUploadFiles(C)};function de(C){var U;return C?C.thumbnail_url??((U=C.conversion_urls)==null?void 0:U.thumb)??C.preview_url??C.original_url??C.url??null:null}function Ne(C){return C!=null&&C.mime_type?C.mime_type.startsWith("image/"):!1}e.watch(()=>p.value,C=>{T(),k=window.setTimeout(()=>{m.setQuery(C)},250)}),e.watch(()=>m.selectedItems.value,()=>{$()},{deep:!0}),e.watch(()=>m.error.value,C=>{S(C)}),e.watch(()=>n.enableUpload,C=>{!C&&f.value==="upload"&&(f.value="media")}),e.onMounted(()=>{m.initialize()}),e.onBeforeUnmount(()=>{T()}),a({refresh:m.refresh});function ce(C){if(C==="albums"){z();return}if(C==="upload"&&!n.enableUpload){f.value="media";return}f.value=C}const le=e.computed(()=>({activeTab:f.value,setActiveTab:ce,enableUpload:n.enableUpload,labels:{uploadLabel:r.value.uploadLabel,allMediaTab:r.value.allMediaTab,browseAlbums:r.value.browseAlbums}})),W=e.computed(()=>({query:p.value,setQuery:C=>{p.value=C},placeholder:r.value.searchPlaceholder}));return(C,U)=>(e.openBlock(),e.createElementBlock("section",{class:"media-library-picker","data-testid":C.testIdPrefix},[e.createElementVNode("header",m6,[e.createElementVNode("div",p6,[x.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"mlp-location-bar__back","aria-label":"Back to library","data-testid":"btn-media-picker-back",onClick:M},[...U[8]||(U[8]=[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("polyline",{points:"15 18 9 12 15 6"})],-1)])])):e.createCommentVNode("",!0),e.createElementVNode("span",f6,e.toDisplayString(I.value),1)])]),e.renderSlot(C.$slots,"tabs",e.normalizeProps(e.guardReactiveProps(le.value)),()=>[e.createElementVNode("nav",h6,[C.enableUpload?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["mlp-tabs__tab",{"is-active":f.value==="upload"}]),"data-testid":"tab-media-picker-upload",onClick:U[0]||(U[0]=j=>f.value="upload")},e.toDisplayString(r.value.uploadLabel),3)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["mlp-tabs__tab",{"is-active":f.value==="media"}]),"data-testid":"tab-media-picker-all",onClick:U[1]||(U[1]=j=>f.value="media")},e.toDisplayString(r.value.allMediaTab),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["mlp-tabs__tab",{"is-active":f.value==="albums"}]),"data-testid":"tab-media-picker-albums",onClick:z},e.toDisplayString(r.value.browseAlbums),3)])],!0),f.value==="media"||f.value==="albums"?(e.openBlock(),e.createElementBlock("div",v6,[e.renderSlot(C.$slots,"search",e.normalizeProps(e.guardReactiveProps(W.value)),()=>[U[9]||(U[9]=e.createElementVNode("svg",{class:"mlp-search-row__icon",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("circle",{cx:"11",cy:"11",r:"8"}),e.createElementVNode("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":U[2]||(U[2]=j=>p.value=j),class:"mlp-search-row__input",type:"search",placeholder:r.value.searchPlaceholder,"data-testid":"input-media-picker-search"},null,8,g6),[[e.vModelText,p.value]])],!0)])):e.createCommentVNode("",!0),C.enableUpload&&f.value==="upload"?(e.openBlock(),e.createBlock(vf,{key:1,open:!0,queue:e.unref(m).uploadQueue.value,accept:C.accept,"upload-label":r.value.uploadLabel,"dropzone-label":r.value.uploadDropzone,"dropzone-helper-text":r.value.uploadDropzoneHelper,"file-input-label":r.value.uploadFileInputLabel,"close-button-label":r.value.uploadDone,"close-button-aria-label":r.value.uploadDoneAria,onClose:U[3]||(U[3]=j=>f.value="media"),onFilesSelected:K},null,8,["queue","accept","upload-label","dropzone-label","dropzone-helper-text","file-input-label","close-button-label","close-button-aria-label"])):e.createCommentVNode("",!0),h.value?(e.openBlock(),e.createElementBlock("div",b6,[e.createVNode(Id,{open:h.value,"name-label":r.value.createAlbumNameLabel,albums:e.unref(m).albums.value,onCancel:U[4]||(U[4]=j=>h.value=!1),onCreate:O},null,8,["open","name-label","albums"])])):e.createCommentVNode("",!0),e.unref(m).permissionDenied.value&&e.unref(m).view.value.scope==="album"?(e.openBlock(),e.createBlock(sf,{key:3,title:r.value.albumUnavailableTitle,body:r.value.albumUnavailableBody,"action-label":r.value.goToLibrary,onGoToLibrary:e.unref(m).goToLibrary},null,8,["title","body","action-label","onGoToLibrary"])):e.createCommentVNode("",!0),!e.unref(m).permissionDenied.value||e.unref(m).view.value.scope!=="album"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:4},[e.unref(m).error.value?(e.openBlock(),e.createElementBlock("div",y6,[e.createElementVNode("p",null,e.toDisplayString(e.unref(m).error.value.message||r.value.networkError),1),e.createElementVNode("button",{type:"button",class:"mlp-error__retry",onClick:U[5]||(U[5]=(...j)=>e.unref(m).refresh&&e.unref(m).refresh(...j))},e.toDisplayString(r.value.retry),1)])):e.createCommentVNode("",!0),f.value==="media"?(e.openBlock(),e.createBlock(bf,{key:1,items:V.value,"selected-items":e.unref(m).selectedItems.value,loading:e.unref(m).loading.value,"loading-more":e.unref(m).loadingMore.value,"has-more":e.unref(m).hasMore.value,"empty-message":w.value,"loading-message":r.value.loadingMedia,"load-more-label":r.value.loadMore,"loading-more-label":r.value.loadingMore,"test-id-prefix":`${C.testIdPrefix}-item`,onToggle:P,onPreview:e.unref(m).openPreview,onLoadMore:e.unref(m).loadMore},null,8,["items","selected-items","loading","loading-more","has-more","empty-message","loading-message","load-more-label","loading-more-label","test-id-prefix","onPreview","onLoadMore"])):f.value==="albums"?(e.openBlock(),e.createBlock(hf,{key:2,open:!0,"current-view":e.unref(m).view.value,albums:e.unref(m).albums.value,"view-library-label":r.value.viewLibrary,"browse-albums-label":r.value.browseAlbums,"create-album-label":r.value.createAlbum,"enable-album-creation":C.enableAlbumCreation,onSelectLibrary:M,onSelectAlbum:Z,onCreateAlbum:U[6]||(U[6]=j=>h.value=!0)},null,8,["current-view","albums","view-library-label","browse-albums-label","create-album-label","enable-album-creation"])):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("footer",w6,[e.unref(m).selectedItems.value.length>0?(e.openBlock(),e.createElementBlock("div",k6,[e.createElementVNode("span",_6,e.toDisplayString(g.value),1),e.createElementVNode("div",E6,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(m).selectedItems.value,j=>{var re,ue,Xe;return e.openBlock(),e.createElementBlock("div",{key:j.id,class:"mlp-bottom-bar__thumb-item"},[Ne(j.media)&&de(j.media)?(e.openBlock(),e.createElementBlock("img",{key:0,src:de(j.media),alt:((re=j.media)==null?void 0:re.alt_text)??((ue=j.media)==null?void 0:ue.file_name)??"Selected",class:"mlp-bottom-bar__thumb-img"},null,8,S6)):(e.openBlock(),e.createElementBlock("div",C6,[...U[10]||(U[10]=[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[e.createElementVNode("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.createElementVNode("polyline",{points:"14 2 14 8 20 8"})],-1)])])),e.createElementVNode("button",{type:"button",class:"mlp-bottom-bar__thumb-remove","aria-label":`${r.value.dismiss} ${((Xe=j.media)==null?void 0:Xe.file_name)??j.id}`,"data-testid":"btn-media-picker-remove-selected",onClick:be=>e.unref(m).removeSelected(j.id)},[...U[11]||(U[11]=[e.createElementVNode("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round"},[e.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])],8,x6)])}),128))])])):e.createCommentVNode("",!0),e.createElementVNode("div",N6,[e.createElementVNode("button",{type:"button",class:"mlp-bottom-bar__cancel","data-testid":"btn-media-picker-cancel",onClick:U[7]||(U[7]=j=>D())},e.toDisplayString(r.value.cancel),1),e.createElementVNode("button",{type:"button",class:"mlp-bottom-bar__confirm","data-testid":"btn-media-picker-confirm",onClick:A},e.toDisplayString(r.value.confirmAction),1)])])):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createBlock(Md,{key:6,open:e.unref(m).previewItem.value!==null,media:e.unref(m).previewItem.value,"can-go-previous":e.unref(m).previewIndex.value!==null&&e.unref(m).previewIndex.value>0,"can-go-next":e.unref(m).previewIndex.value!==null&&e.unref(m).previewIndex.value<e.unref(m).queryItems.value.length-1,selected:e.unref(m).previewItem.value!==null&&e.unref(m).orderedIds.value.includes(e.unref(m).previewItem.value.uuid),"close-label":r.value.previewClose,"previous-label":r.value.previewPrevious,"next-label":r.value.previewNext,"select-label":r.value.previewSelect,"deselect-label":r.value.previewDeselect,onClose:e.unref(m).closePreview,onPrevious:e.unref(m).showPreviousPreview,onNext:e.unref(m).showNextPreview,onToggleSelect:e.unref(m).toggleSelection},null,8,["open","media","can-go-previous","can-go-next","selected","close-label","previous-label","next-label","select-label","deselect-label","onClose","onPrevious","onNext","onToggleSelect"])):e.createCommentVNode("",!0)],8,u6))}}),Vf=$e(V6,[["__scopeId","data-v-307fef12"]]),T6={key:0,class:"media-library-picker-modal","data-testid":"media-library-picker-modal"},B6={class:"media-library-picker-modal__panel"},I6=e.defineComponent({__name:"MediaLibraryPickerModal",props:{deps:{},mode:{},capabilities:{},itemFilter:{},modelValue:{},defaultSelectedIds:{},selectionMode:{},maxSelection:{},preserveSelectionOnViewChange:{type:Boolean},initialView:{},initialFilters:{},enableUpload:{type:Boolean},uploadBehavior:{},enablePreview:{type:Boolean},enableAlbumCreation:{type:Boolean},allowedMediaKinds:{},accept:{},validateSelection:{},uploadTarget:{},autoSelectUploaded:{type:Boolean},createAlbumDefaultVisibility:{},sessionPolicy:{},labels:{},showFooter:{type:Boolean},testIdPrefix:{},telemetry:{},isOpen:{type:Boolean,default:!1},closeOnBackdrop:{type:Boolean,default:!0}},emits:["update:modelValue","confirm","cancel","close"],setup(o,{emit:a}){const t=o,n=a,i=()=>{t.closeOnBackdrop&&n("close")};return(r,l)=>r.isOpen?(e.openBlock(),e.createElementBlock("div",T6,[e.createElementVNode("button",{type:"button",class:"media-library-picker-modal__backdrop","aria-label":"Close media picker",onClick:i}),e.createElementVNode("div",B6,[e.createVNode(Vf,e.mergeProps(t,{"onUpdate:modelValue":l[0]||(l[0]=s=>n("update:modelValue",s)),onConfirm:l[1]||(l[1]=s=>n("confirm",s)),onCancel:l[2]||(l[2]=s=>n("cancel",s))}),null,16)])])):e.createCommentVNode("",!0)}}),M6=$e(I6,[["__scopeId","data-v-a92e8703"]]),$6=["aria-label"],F6={class:"media-album-picker-modal__panel"},D6={class:"media-album-picker-modal__header"},A6={key:0,class:"media-album-picker-modal__selection","data-testid":"media-album-picker-selection"},R6={class:"media-album-picker-modal__actions"},L6=["disabled"],P6=e.defineComponent({__name:"MediaAlbumPickerModal",props:{open:{type:Boolean},selectedCount:{},labels:{default:()=>({})}},emits:["cancel","confirm","error"],setup(o,{emit:a}){const t=o,n=a,i=Vl(),r=e.ref(null),l=e.computed(()=>{var u,m,p,f,h,v,k;return{title:((u=t.labels)==null?void 0:u.title)??"Add to album",body:((m=t.labels)==null?void 0:m.body)??`Choose an album for ${t.selectedCount} selected item${t.selectedCount===1?"":"s"}.`,confirm:((p=t.labels)==null?void 0:p.confirm)??"Add",cancel:((f=t.labels)==null?void 0:f.cancel)??"Cancel",selectedAlbum:((h=t.labels)==null?void 0:h.selectedAlbum)??(y=>`Selected: ${y}`),createNew:((v=t.labels)==null?void 0:v.createNew)??"+ Create new album",createNewPrompt:((k=t.labels)==null?void 0:k.createNewPrompt)??"Name this album"}});e.watch(()=>t.open,u=>{u||(r.value=null)});function s(u){r.value=u}function d(){r.value!==null&&n("confirm",r.value.id)}async function c(){if(typeof window>"u")return;const u=window.prompt(l.value.createNewPrompt);if(u===null)return;const m=u.trim();if(m!=="")try{const p=await i.createAlbum({name:m});p!=null&&(r.value=p,n("confirm",p.id))}catch(p){n("error",p instanceof Error?p:new Error(String(p)))}}return(u,m)=>{var p;return t.open?(e.openBlock(),e.createElementBlock("div",{key:0,class:"media-album-picker-modal","data-testid":"media-album-picker-modal",role:"dialog","aria-modal":"true","aria-label":l.value.title},[e.createElementVNode("div",F6,[e.createElementVNode("header",D6,[e.createElementVNode("h2",null,e.toDisplayString(l.value.title),1),e.createElementVNode("p",null,e.toDisplayString(l.value.body),1)]),e.createElementVNode("button",{type:"button",class:"media-album-picker-modal__create-new","data-testid":"btn-media-album-picker-create-new",onClick:m[0]||(m[0]=f=>void c())},e.toDisplayString(l.value.createNew),1),e.createVNode(Tl,{class:"media-album-picker-modal__tree","model-value":((p=r.value)==null?void 0:p.id)??null,draggable:!1,compact:!0,"data-testid":"media-album-picker-tree",onAlbumSelected:s},null,8,["model-value"]),r.value!==null?(e.openBlock(),e.createElementBlock("p",A6,e.toDisplayString(l.value.selectedAlbum(r.value.name)),1)):e.createCommentVNode("",!0),e.createElementVNode("footer",R6,[e.createElementVNode("button",{type:"button","data-testid":"btn-media-album-picker-cancel",onClick:m[1]||(m[1]=f=>n("cancel"))},e.toDisplayString(l.value.cancel),1),e.createElementVNode("button",{type:"button","data-testid":"btn-media-album-picker-confirm",disabled:r.value===null,onClick:d},e.toDisplayString(l.value.confirm),9,L6)])])],8,$6)):e.createCommentVNode("",!0)}}}),Tf=$e(P6,[["__scopeId","data-v-acdcde4b"]]),U6={key:0,class:"media-bulk-action-bar","data-testid":"media-bulk-action-bar","aria-live":"polite"},O6={class:"media-bulk-action-bar__actions"},z6=["disabled"],j6=e.defineComponent({__name:"MediaBulkActionBar",props:{selectedCount:{},crossPageCount:{default:0},overCap:{type:Boolean,default:!1},totalMatching:{default:null},scope:{},sourceAlbum:{default:null},capabilities:{default:()=>({})},labels:{default:()=>({})}},emits:["bulk-add-to-album","bulk-move-between-albums","bulk-remove-from-current-album","bulk-move-to-trash","bulk-create-post","bulk-create-gallery","bulk-restore","bulk-purge","bulk-download","clear","inspect"],setup(o,{emit:a}){const t=o,n=a,i=e.computed(()=>{var s,d,c,u,m,p,f,h,v,k,y,w,g,b;return{selectedCount:((s=t.labels)==null?void 0:s.selectedCount)??(R=>`${R} selected`),selectedAcrossPages:((d=t.labels)==null?void 0:d.selectedAcrossPages)??((R,V)=>`${R} selected, including ${V} not on this page`),cappedSelection:((c=t.labels)==null?void 0:c.cappedSelection)??((R,V)=>`Selected first ${R} of ${V??"many"} matching items`),addToAlbum:((u=t.labels)==null?void 0:u.addToAlbum)??"Add to album",moveBetweenAlbums:((m=t.labels)==null?void 0:m.moveBetweenAlbums)??(R=>`Move from ${R} to...`),removeFromCurrentAlbum:((p=t.labels)==null?void 0:p.removeFromCurrentAlbum)??"Remove from this album",moveToTrash:((f=t.labels)==null?void 0:f.moveToTrash)??"Move to trash",createPost:((h=t.labels)==null?void 0:h.createPost)??"Create post",createGallery:((v=t.labels)==null?void 0:v.createGallery)??"Create gallery",restore:((k=t.labels)==null?void 0:k.restore)??"Restore",purge:((y=t.labels)==null?void 0:y.purge)??"Delete forever",download:((w=t.labels)==null?void 0:w.download)??"Download",inspect:((g=t.labels)==null?void 0:g.inspect)??"Inspect",clear:((b=t.labels)==null?void 0:b.clear)??"Clear"}}),r=e.computed(()=>t.overCap?i.value.cappedSelection(t.selectedCount,t.totalMatching):t.crossPageCount>0?i.value.selectedAcrossPages(t.selectedCount,t.crossPageCount):i.value.selectedCount(t.selectedCount)),l=e.computed(()=>t.sourceAlbum?i.value.moveBetweenAlbums(t.sourceAlbum.name):i.value.addToAlbum);return(s,d)=>(e.openBlock(),e.createBlock(e.Transition,{name:"media-bulk-action-bar"},{default:e.withCtx(()=>[t.selectedCount>0?(e.openBlock(),e.createElementBlock("aside",U6,[e.createElementVNode("button",{type:"button",class:"media-bulk-action-bar__count","data-testid":"media-bulk-action-count",onClick:d[0]||(d[0]=c=>n("inspect"))},e.toDisplayString(r.value),1),e.createElementVNode("div",O6,[t.scope!=="trash"&&t.capabilities.allowAddToAlbum===!0?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button","data-testid":"btn-media-bulk-add-album",onClick:d[1]||(d[1]=c=>t.scope==="album"?n("bulk-move-between-albums"):n("bulk-add-to-album"))},e.toDisplayString(t.scope==="album"?l.value:i.value.addToAlbum),1)):e.createCommentVNode("",!0),t.scope!=="trash"&&t.capabilities.allowCreatePost===!0?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button","data-testid":"btn-media-bulk-create-post",onClick:d[2]||(d[2]=c=>n("bulk-create-post"))},e.toDisplayString(i.value.createPost),1)):e.createCommentVNode("",!0),t.scope!=="trash"&&t.capabilities.allowCreateGallery===!0?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button","data-testid":"btn-media-bulk-create-gallery",onClick:d[3]||(d[3]=c=>n("bulk-create-gallery"))},e.toDisplayString(i.value.createGallery),1)):e.createCommentVNode("",!0),t.scope==="album"?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button","data-testid":"btn-media-bulk-remove-current-album",onClick:d[4]||(d[4]=c=>n("bulk-remove-from-current-album"))},e.toDisplayString(i.value.removeFromCurrentAlbum),1)):e.createCommentVNode("",!0),t.scope!=="trash"?(e.openBlock(),e.createElementBlock("button",{key:4,type:"button","data-testid":"btn-media-bulk-trash",onClick:d[5]||(d[5]=c=>n("bulk-move-to-trash"))},e.toDisplayString(i.value.moveToTrash),1)):e.createCommentVNode("",!0),t.scope==="trash"?(e.openBlock(),e.createElementBlock("button",{key:5,type:"button","data-testid":"btn-media-bulk-restore",onClick:d[6]||(d[6]=c=>n("bulk-restore"))},e.toDisplayString(i.value.restore),1)):e.createCommentVNode("",!0),t.scope==="trash"?(e.openBlock(),e.createElementBlock("button",{key:6,type:"button","data-testid":"btn-media-bulk-purge",onClick:d[7]||(d[7]=c=>n("bulk-purge"))},e.toDisplayString(i.value.purge),1)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button","data-testid":"btn-media-bulk-download",disabled:t.capabilities.allowDownloadZip!==!0,onClick:d[8]||(d[8]=c=>n("bulk-download"))},e.toDisplayString(i.value.download),9,z6),e.createElementVNode("button",{type:"button","data-testid":"btn-media-bulk-clear",onClick:d[9]||(d[9]=c=>n("clear"))},e.toDisplayString(i.value.clear),1)])])):e.createCommentVNode("",!0)]),_:1}))}}),Rd=$e(j6,[["__scopeId","data-v-56ce7c5e"]]),W6={class:"media-library-toolbar__group"},H6=["aria-expanded"],Z6={key:0,class:"media-library-toolbar__menu",role:"menu","data-testid":"media-library-toolbar-sort-menu"},G6={class:"media-library-toolbar__group"},X6=["aria-expanded"],K6={key:0,class:"media-library-toolbar__menu",role:"menu","data-testid":"media-library-toolbar-jump-menu"},J6={key:0,class:"media-library-toolbar__menu-status"},q6={key:1,class:"media-library-toolbar__menu-status"},Y6=["data-testid","onClick"],Q6={"aria-hidden":"true"},eD={class:"media-library-toolbar__group"},tD=["aria-expanded"],aD={key:0,class:"media-library-toolbar__menu",role:"menu","data-testid":"media-library-toolbar-density-menu"},nD=e.defineComponent({__name:"MediaLibraryToolbar",props:{sort:{default:"newest"},density:{default:"comfortable"},hasDateFilter:{type:Boolean,default:!1},httpClient:{},timelineEndpoint:{default:"/v1/media/library/timeline"},labels:{default:()=>({})}},emits:["update:sort","update:density","jump-to","jump-to-all","upload-files"],setup(o,{emit:a}){const t=o,n=a,i=e.computed(()=>{var T,$,S,B,_,A,P,D,z,M,Z,O;return{sort:((T=t.labels)==null?void 0:T.sort)??"Sort",sortNewest:(($=t.labels)==null?void 0:$.sortNewest)??"Newest",sortOldest:((S=t.labels)==null?void 0:S.sortOldest)??"Oldest",sortName:((B=t.labels)==null?void 0:B.sortName)??"Name A–Z",sortLargest:((_=t.labels)==null?void 0:_.sortLargest)??"Largest first",jumpTo:((A=t.labels)==null?void 0:A.jumpTo)??"Jump to",jumpToAll:((P=t.labels)==null?void 0:P.jumpToAll)??"All time",jumpToEmpty:((D=t.labels)==null?void 0:D.jumpToEmpty)??"No history yet",density:((z=t.labels)==null?void 0:z.density)??"Density",densityComfortable:((M=t.labels)==null?void 0:M.densityComfortable)??"Comfortable",densityCompact:((Z=t.labels)==null?void 0:Z.densityCompact)??"Compact",upload:((O=t.labels)==null?void 0:O.upload)??"Upload"}}),r=e.ref(null);function l(){var T;(T=r.value)==null||T.click()}function s(T){const $=T.target;!($ instanceof HTMLInputElement)||$.files===null||$.files.length===0||(n("upload-files",Array.from($.files)),$.value="")}const d=e.ref(null),c=e.ref(null);function u(T){d.value=d.value===T?null:T}function m(){d.value=null}function p(T){if(d.value===null)return;const $=c.value;$!==null&&(T.target instanceof Node&&$.contains(T.target)||m())}function f(T){d.value!==null&&T.key==="Escape"&&m()}const h=e.computed(()=>{switch(t.sort){case"oldest":return i.value.sortOldest;case"name":return i.value.sortName;case"largest":return i.value.sortLargest;default:return i.value.sortNewest}}),v=e.computed(()=>t.density==="compact"?i.value.densityCompact:i.value.densityComfortable);function k(T){m(),n("update:sort",T)}function y(T){m(),n("update:density",T)}const w=e.ref([]),g=e.ref(!1),b=e.ref(!1);async function R(){if(!(g.value||b.value||t.httpClient===void 0)){b.value=!0;try{const T=await t.httpClient.get(t.timelineEndpoint),$=T.data,S=($==null?void 0:$.buckets)??T.buckets??[];w.value=Array.isArray(S)?S:[],g.value=!0}finally{b.value=!1}}}async function V(){u("jump"),d.value==="jump"&&await R()}function I(T){m(),n("jump-to",T)}function x(){m(),n("jump-to-all")}return e.onMounted(()=>{typeof window<"u"&&(document.addEventListener("pointerdown",p,!0),document.addEventListener("keydown",f))}),e.onBeforeUnmount(()=>{typeof window<"u"&&(document.removeEventListener("pointerdown",p,!0),document.removeEventListener("keydown",f))}),(T,$)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"toolbarRoot",ref:c,class:"media-library-toolbar","data-testid":"media-library-toolbar"},[e.createElementVNode("button",{type:"button",class:"media-library-toolbar__upload","data-testid":"btn-media-toolbar-upload",onClick:l}," ⤴ "+e.toDisplayString(i.value.upload),1),e.createElementVNode("input",{ref_key:"fileInputRef",ref:r,type:"file",multiple:"",accept:"image/*,video/*","data-testid":"input-media-toolbar-upload",class:"media-library-toolbar__file-input",onChange:s},null,544),e.createElementVNode("div",W6,[e.createElementVNode("button",{type:"button",class:"media-library-toolbar__trigger","data-testid":"btn-media-toolbar-sort","aria-expanded":d.value==="sort"?"true":"false",onClick:$[0]||($[0]=S=>u("sort"))},e.toDisplayString(i.value.sort)+": "+e.toDisplayString(h.value),9,H6),d.value==="sort"?(e.openBlock(),e.createElementBlock("div",Z6,[e.createElementVNode("button",{type:"button",role:"menuitem","data-testid":"opt-sort-newest",onClick:$[1]||($[1]=S=>k("newest"))},e.toDisplayString(i.value.sortNewest),1),e.createElementVNode("button",{type:"button",role:"menuitem","data-testid":"opt-sort-oldest",onClick:$[2]||($[2]=S=>k("oldest"))},e.toDisplayString(i.value.sortOldest),1),e.createElementVNode("button",{type:"button",role:"menuitem","data-testid":"opt-sort-name",onClick:$[3]||($[3]=S=>k("name"))},e.toDisplayString(i.value.sortName),1),e.createElementVNode("button",{type:"button",role:"menuitem","data-testid":"opt-sort-largest",onClick:$[4]||($[4]=S=>k("largest"))},e.toDisplayString(i.value.sortLargest),1)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",G6,[e.createElementVNode("button",{type:"button",class:"media-library-toolbar__trigger","data-testid":"btn-media-toolbar-jump-to","aria-expanded":d.value==="jump"?"true":"false",onClick:$[5]||($[5]=S=>void V())},e.toDisplayString(i.value.jumpTo),9,X6),d.value==="jump"?(e.openBlock(),e.createElementBlock("div",K6,[e.createElementVNode("button",{type:"button",role:"menuitem","data-testid":"opt-jump-all",onClick:x},e.toDisplayString(i.value.jumpToAll),1),b.value?(e.openBlock(),e.createElementBlock("p",J6,"Loading…")):g.value&&w.value.length===0?(e.openBlock(),e.createElementBlock("p",q6,e.toDisplayString(i.value.jumpToEmpty),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.value,S=>(e.openBlock(),e.createElementBlock("button",{key:S.starts_at,type:"button",role:"menuitem","data-testid":`opt-jump-${S.starts_at}`,onClick:B=>I(S)},[e.createTextVNode(e.toDisplayString(S.label)+" ",1),e.createElementVNode("span",Q6,"("+e.toDisplayString(S.count)+")",1)],8,Y6))),128))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",eD,[e.createElementVNode("button",{type:"button",class:"media-library-toolbar__trigger","data-testid":"btn-media-toolbar-density","aria-expanded":d.value==="density"?"true":"false",onClick:$[6]||($[6]=S=>u("density"))},e.toDisplayString(i.value.density)+": "+e.toDisplayString(v.value),9,tD),d.value==="density"?(e.openBlock(),e.createElementBlock("div",aD,[e.createElementVNode("button",{type:"button",role:"menuitem","data-testid":"opt-density-comfortable",onClick:$[7]||($[7]=S=>y("comfortable"))},e.toDisplayString(i.value.densityComfortable),1),e.createElementVNode("button",{type:"button",role:"menuitem","data-testid":"opt-density-compact",onClick:$[8]||($[8]=S=>y("compact"))},e.toDisplayString(i.value.densityCompact),1)])):e.createCommentVNode("",!0)])],512))}}),Bf=$e(nD,[["__scopeId","data-v-564647c0"]]),oD={class:"media-shortcut-help__panel"},iD={class:"media-shortcut-help__header"},rD=e.defineComponent({__name:"MediaShortcutHelp",props:{open:{type:Boolean},shortcuts:{default:()=>[{key:"j / k",label:"Move focus",group:"Navigation"},{key:"x",label:"Toggle selection",group:"Selection"},{key:"?",label:"Open shortcuts",group:"Help"},{key:"Esc",label:"Close panel",group:"Navigation"}]},title:{default:"Shortcuts"},closeLabel:{default:"Close"}},emits:["close"],setup(o,{emit:a}){const t=o,n=a;function i(){const r=new Map;for(const l of t.shortcuts)r.set(l.group,[...r.get(l.group)??[],l]);return Array.from(r.entries()).map(([l,s])=>({group:l,shortcuts:s}))}return(r,l)=>t.open?(e.openBlock(),e.createElementBlock("div",{key:0,class:"media-shortcut-help",role:"dialog","aria-modal":"true","data-testid":"media-shortcut-help",onKeydown:l[1]||(l[1]=e.withKeys(s=>n("close"),["escape"]))},[e.createElementVNode("div",oD,[e.createElementVNode("header",iD,[e.createElementVNode("h3",null,e.toDisplayString(t.title),1),e.createElementVNode("button",{type:"button","data-testid":"btn-media-shortcut-close",onClick:l[0]||(l[0]=s=>n("close"))},e.toDisplayString(t.closeLabel),1)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i(),s=>(e.openBlock(),e.createElementBlock("section",{key:s.group,class:"media-shortcut-help__group"},[e.createElementVNode("h4",null,e.toDisplayString(s.group),1),e.createElementVNode("dl",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.shortcuts,d=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${s.group}-${d.key}`},[e.createElementVNode("dt",null,[e.createElementVNode("kbd",null,e.toDisplayString(d.key),1)]),e.createElementVNode("dd",null,e.toDisplayString(d.label),1)],64))),128))])]))),128))])],32)):e.createCommentVNode("",!0)}}),If=$e(rD,[["__scopeId","data-v-abcdccb6"]]),lD="/v1/media/upload";function Mf(o){const a=o.endpoint??lD,t=e.ref([]),n=e.computed(()=>t.value.some(u=>u.status==="uploading"||u.status==="queued"));function i(){return`upload-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function r(u){if(u.type.startsWith("image/")&&typeof URL<"u")try{return URL.createObjectURL(u)}catch{return}}function l(u){t.value=t.value.filter(m=>m.cid!==u)}async function s(u){const m=i(),p=r(u),f={cid:m,fileName:u.name,size:u.size,status:"uploading",progress:0,...p!==void 0?{previewUrl:p}:{}};t.value=[f,...t.value];const h=new FormData;h.append("file",u);try{const v=await o.httpClient.post(a,h),k=v.data??v;return t.value=t.value.map(y=>y.cid===m?{...y,status:"success",progress:100}:y),typeof o.onMediaUploaded=="function"&&k&&typeof k.uuid=="string"&&await o.onMediaUploaded(k),setTimeout(()=>l(m),350),t.value.find(y=>y.cid===m)??f}catch(v){const k=v instanceof Error?v.message:"Upload failed";return t.value=t.value.map(y=>y.cid===m?{...y,status:"error",errorMessage:k}:y),t.value.find(y=>y.cid===m)??f}finally{if(p!==void 0&&typeof URL<"u")try{URL.revokeObjectURL(p)}catch{}}}async function d(u){const m=Array.from(u);return Promise.all(m.map(p=>s(p)))}function c(){t.value=[]}return{uploads:t,hasActiveUploads:n,uploadFile:s,uploadFiles:d,dismiss:l,clear:c}}const sD={class:"media-usage-list","data-testid":"media-usage-list"},dD={class:"media-usage-list__title"},cD={key:0,class:"media-usage-list__empty","data-testid":"media-usage-loading"},uD={key:1,class:"media-usage-list__empty","data-testid":"media-usage-empty"},mD={key:2,class:"media-usage-list__items"},pD=["data-testid"],fD=["href"],hD={key:1},vD={key:2,class:"media-usage-list__count"},gD=e.defineComponent({__name:"MediaUsageList",props:{media:{},httpClient:{},items:{default:()=>[]},title:{default:"Used in"},emptyLabel:{default:"No visible usages"}},setup(o){const a=o,t=e.ref(!1),n=e.ref([]),i=e.computed(()=>a.items.length>0?a.items:n.value);function r(s){var m;if(typeof s!="object"||s===null||!("data"in s))return[];const d=s.data;if(!Array.isArray(d))return[];const c=d[0];return(Array.isArray((m=c==null?void 0:c.report)==null?void 0:m.blocks)?c.report.blocks:[]).map((p,f)=>({id:`${p.type??"usage"}-${f}`,label:p.context??p.type??"Usage"}))}async function l(){if(!a.httpClient||a.media===null){n.value=[];return}t.value=!0;try{const s=await a.httpClient.post("/v1/media/deletion/check",{uuids:[a.media.uuid]});n.value=r(s)}finally{t.value=!1}}return e.watch(()=>{var s;return(s=a.media)==null?void 0:s.uuid},()=>{l()}),e.onMounted(()=>{l()}),(s,d)=>(e.openBlock(),e.createElementBlock("section",sD,[e.createElementVNode("h4",dD,e.toDisplayString(a.title),1),t.value?(e.openBlock(),e.createElementBlock("p",cD," Loading... ")):i.value.length===0?(e.openBlock(),e.createElementBlock("p",uD,e.toDisplayString(a.emptyLabel),1)):(e.openBlock(),e.createElementBlock("ul",mD,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,c=>(e.openBlock(),e.createElementBlock("li",{key:c.id,class:"media-usage-list__item","data-testid":`media-usage-${c.id}`},[c.href?(e.openBlock(),e.createElementBlock("a",{key:0,href:c.href},e.toDisplayString(c.label),9,fD)):(e.openBlock(),e.createElementBlock("span",hD,e.toDisplayString(c.label),1)),typeof c.count=="number"?(e.openBlock(),e.createElementBlock("span",vD,e.toDisplayString(c.count),1)):e.createCommentVNode("",!0)],8,pD))),128))]))]))}}),$f=$e(gD,[["__scopeId","data-v-ef6f09cf"]]),bD={class:"media-variant-strip","data-testid":"media-variant-strip"},yD={class:"media-variant-strip__title"},wD={key:0,class:"media-variant-strip__empty"},kD={key:1,class:"media-variant-strip__empty"},_D={key:2,class:"media-variant-strip__list"},ED=["data-testid"],SD=["src","alt"],CD={key:1,class:"media-variant-strip__placeholder"},xD={class:"media-variant-strip__label"},ND=e.defineComponent({__name:"MediaVariantStrip",props:{media:{},httpClient:{},variants:{default:()=>[]},title:{default:"Variants"}},setup(o){const a=o,t=e.ref(!1),n=e.ref([]),i=e.computed(()=>{const c=a.variants.length>0?a.variants:n.value;return a.media?[a.media,...c.filter(u=>{var m;return u.uuid!==((m=a.media)==null?void 0:m.uuid)})]:c});function r(c){if(typeof c!="object"||c===null||!("data"in c))return[];const u=c.data;return Array.isArray(u)?u.filter(m=>typeof m=="object"&&m!==null&&typeof m.uuid=="string"&&typeof m.file_name=="string"):[]}async function l(){if(!a.httpClient||a.media===null){n.value=[];return}t.value=!0;try{const c=await a.httpClient.get(`/v1/media/${encodeURIComponent(a.media.uuid)}/variants`);n.value=r(c)}finally{t.value=!1}}function s(c){return c.thumbnail_url??c.preview_url??c.original_url??null}function d(c,u){if(c===0)return"Current";if(c===1)return"Original";const m=new Date(u.created_at);if(Number.isNaN(m.getTime()))return"Edited";const p=Math.max(0,Math.round((Date.now()-m.getTime())/864e5));return p===0?"Edited today":p===1?"Edited 1 day ago":`Edited ${p} days ago`}return e.watch(()=>{var c;return(c=a.media)==null?void 0:c.uuid},()=>{l()}),e.onMounted(()=>{l()}),(c,u)=>(e.openBlock(),e.createElementBlock("section",bD,[e.createElementVNode("h4",yD,e.toDisplayString(a.title),1),t.value?(e.openBlock(),e.createElementBlock("p",wD,"Loading...")):i.value.length<=1?(e.openBlock(),e.createElementBlock("p",kD," No edits ")):(e.openBlock(),e.createElementBlock("ol",_D,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(m,p)=>(e.openBlock(),e.createElementBlock("li",{key:m.uuid,class:"media-variant-strip__item","data-testid":`media-variant-${m.uuid}`},[s(m)?(e.openBlock(),e.createElementBlock("img",{key:0,src:s(m)??"",alt:m.alt_text??m.file_name},null,8,SD)):(e.openBlock(),e.createElementBlock("span",CD,e.toDisplayString(m.file_name),1)),e.createElementVNode("span",xD,e.toDisplayString(d(p,m)),1)],8,ED))),128))]))]))}}),Ff=$e(ND,[["__scopeId","data-v-adb529cb"]]),VD=/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/ig,Lu=/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i;function Pu(o){const a=o.replace(/\.[^.]+$/,""),t=a.replace(VD,""),n=t.replace(/(?:[-_\s]+edited)+$/i,""),i=t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/(?:[-_\s]+edited)+$/i,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim();return i!==""?i:n||a||o}function Uu(o,a){var n;const t=(n=o.custom_properties)==null?void 0:n[a];return typeof t=="string"&&t.trim()!==""?t.trim():null}function Df(o){const a=Uu(o,"display_name");if(a!==null&&!Lu.test(a))return a;const t=Uu(o,"original_filename");return t!==null&&!Lu.test(t)?Pu(t):Pu(o.file_name)}const TD=["role","aria-modal"],BD={class:"media-inspector-panel__header"},ID={key:0,class:"media-inspector-panel__raw-name"},MD={class:"media-inspector-panel__preview"},$D=["src","alt"],FD={class:"media-inspector-panel__meta"},DD={class:"media-inspector-panel__actions"},AD={class:"media-inspector-panel__actions"},RD=["disabled"],LD={key:2,class:"media-inspector-panel__empty"},PD=e.defineComponent({__name:"MediaInspectorPanel",props:{target:{},httpClient:{},capabilities:{default:()=>({})},inAlbumScope:{type:Boolean,default:!1},labels:{default:()=>({})},mode:{default:"pinned"}},emits:["edit","replace","download","set-visibility","move-to-trash","remove-from-this-album","remove-from-albums","set-as-album-cover","bulk-add-to-album","bulk-create-album","bulk-move-to-trash","bulk-download","close"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(null),r=e.ref(null);e.watch(()=>t.target,(u,m)=>{const p=m==null,f=u==null;if(p&&!f){typeof document<"u"&&document.activeElement instanceof HTMLElement&&(r.value=document.activeElement),e.nextTick(()=>{var h;(h=i.value)==null||h.focus()});return}if(!p&&f){const h=r.value;r.value=null,h instanceof HTMLElement&&h.focus()}});function l(u){t.mode==="overlay"&&u.key==="Escape"&&(u.stopPropagation(),n("close"))}const s=e.computed(()=>t.mode==="overlay"?"dialog":"complementary"),d=e.computed(()=>{var u,m,p,f,h,v,k,y,w,g,b,R,V;return{title:((u=t.labels)==null?void 0:u.title)??"Inspector",emptyTitle:((m=t.labels)==null?void 0:m.emptyTitle)??"Select media to inspect",multiTitle:((p=t.labels)==null?void 0:p.multiTitle)??(I=>`${I} selected`),edit:((f=t.labels)==null?void 0:f.edit)??"Edit",replace:((h=t.labels)==null?void 0:h.replace)??"Replace",download:((v=t.labels)==null?void 0:v.download)??"Download",setVisibility:((k=t.labels)==null?void 0:k.setVisibility)??"Set visibility",moveToTrash:((y=t.labels)==null?void 0:y.moveToTrash)??"Move to trash",removeFromThisAlbum:((w=t.labels)==null?void 0:w.removeFromThisAlbum)??"Remove from this album",removeFromAlbums:((g=t.labels)==null?void 0:g.removeFromAlbums)??"Remove from album...",addToAlbum:((b=t.labels)==null?void 0:b.addToAlbum)??"Add to album",createAlbum:((R=t.labels)==null?void 0:R.createAlbum)??"Create album from selection",setAsAlbumCover:((V=t.labels)==null?void 0:V.setAsAlbumCover)??"Set as album cover"}}),c=e.computed(()=>{var u;return((u=t.target)==null?void 0:u.kind)==="single"?t.target.media:null});return(u,m)=>{var p;return e.openBlock(),e.createElementBlock("aside",{class:"media-inspector-panel","data-testid":"media-inspector-panel",role:s.value,"aria-modal":t.mode==="overlay"?"true":void 0,"aria-labelledby":"media-inspector-heading",onKeydown:l},[c.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("header",BD,[e.createElementVNode("h3",{id:"media-inspector-heading",ref_key:"headingRef",ref:i,tabindex:"-1"},e.toDisplayString(e.unref(Df)(c.value)),513),c.value.file_name?(e.openBlock(),e.createElementBlock("p",ID,e.toDisplayString(c.value.file_name),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",MD,[c.value.thumbnail_url??c.value.preview_url??c.value.original_url?(e.openBlock(),e.createElementBlock("img",{key:0,src:c.value.thumbnail_url??c.value.preview_url??c.value.original_url,alt:c.value.alt_text??c.value.file_name},null,8,$D)):e.createCommentVNode("",!0)]),e.createElementVNode("dl",FD,[e.createElementVNode("div",null,[m[12]||(m[12]=e.createElementVNode("dt",null,"Type",-1)),e.createElementVNode("dd",null,e.toDisplayString(c.value.mime_type),1)]),e.createElementVNode("div",null,[m[13]||(m[13]=e.createElementVNode("dt",null,"Size",-1)),e.createElementVNode("dd",null,e.toDisplayString(c.value.formatted_size??c.value.size),1)])]),e.createVNode($f,{media:c.value,"http-client":t.httpClient},null,8,["media","http-client"]),e.createVNode(Ff,{media:c.value,"http-client":t.httpClient},null,8,["media","http-client"]),e.createElementVNode("div",DD,[t.capabilities.allowImageEdit||t.capabilities.allowVideoEdit?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",onClick:m[0]||(m[0]=f=>n("edit",c.value))},e.toDisplayString(d.value.edit),1)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",onClick:m[1]||(m[1]=f=>n("replace",c.value))},e.toDisplayString(d.value.replace),1),e.createElementVNode("button",{type:"button",onClick:m[2]||(m[2]=f=>n("download",c.value))},e.toDisplayString(d.value.download),1),t.capabilities.allowVisibilityChange?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",onClick:m[3]||(m[3]=f=>n("set-visibility",c.value))},e.toDisplayString(d.value.setVisibility),1)):e.createCommentVNode("",!0),t.inAlbumScope?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button","data-testid":"btn-set-as-album-cover",onClick:m[4]||(m[4]=f=>n("set-as-album-cover",c.value))},e.toDisplayString(d.value.setAsAlbumCover),1)):e.createCommentVNode("",!0),t.inAlbumScope?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",onClick:m[5]||(m[5]=f=>n("remove-from-this-album",c.value))},e.toDisplayString(d.value.removeFromThisAlbum),1)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",onClick:m[6]||(m[6]=f=>n("remove-from-albums",c.value))},e.toDisplayString(d.value.removeFromAlbums),1),e.createElementVNode("button",{type:"button",onClick:m[7]||(m[7]=f=>n("move-to-trash",c.value))},e.toDisplayString(d.value.moveToTrash),1)])],64)):((p=t.target)==null?void 0:p.kind)==="multi"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("h3",{id:"media-inspector-heading",ref_key:"headingRef",ref:i,tabindex:"-1"},e.toDisplayString(d.value.multiTitle(t.target.count)),513),e.createElementVNode("div",AD,[e.createElementVNode("button",{type:"button",onClick:m[8]||(m[8]=f=>n("bulk-add-to-album"))},e.toDisplayString(d.value.addToAlbum),1),e.createElementVNode("button",{type:"button",onClick:m[9]||(m[9]=f=>n("bulk-create-album"))},e.toDisplayString(d.value.createAlbum),1),e.createElementVNode("button",{type:"button",onClick:m[10]||(m[10]=f=>n("bulk-move-to-trash"))},e.toDisplayString(d.value.moveToTrash),1),e.createElementVNode("button",{type:"button",disabled:t.capabilities.allowDownloadZip!==!0,onClick:m[11]||(m[11]=f=>n("bulk-download"))},e.toDisplayString(d.value.download),9,RD)])],64)):(e.openBlock(),e.createElementBlock("p",LD,e.toDisplayString(d.value.emptyTitle),1))],40,TD)}}}),Af=$e(PD,[["__scopeId","data-v-2646f914"]]),UD={class:"media-filter-chips","data-testid":"media-filter-chips"},OD={class:"media-filter-chips__scroll"},zD={key:0,class:"media-filter-chips__chip media-filter-chips__chip--scope","data-testid":"media-filter-scope-chip"},jD=["data-testid","onClick"],WD={class:"media-filter-chips__add-wrap"},HD=["aria-expanded"],ZD={key:0,class:"media-filter-chips__menu","data-testid":"media-filter-menu"},GD=e.defineComponent({__name:"MediaFilterChips",props:{filters:{},scopeLabel:{default:""},labels:{default:()=>({})}},emits:["update:filters","change","clear"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(!1),r=e.computed(()=>{var w,g,b,R,V,I,x,T,$,S,B;return{addFilter:((w=t.labels)==null?void 0:w.addFilter)??"Filter",clearAll:((g=t.labels)==null?void 0:g.clearAll)??"Clear all filters",typeLabel:((b=t.labels)==null?void 0:b.typeLabel)??"Type",usageLabel:((R=t.labels)==null?void 0:R.usageLabel)??"Usage",imageLabel:((V=t.labels)==null?void 0:V.imageLabel)??"Image",videoLabel:((I=t.labels)==null?void 0:I.videoLabel)??"Video",usedLabel:((x=t.labels)==null?void 0:x.usedLabel)??"Used",notUsedLabel:((T=t.labels)==null?void 0:T.notUsedLabel)??"Not used",dateAfterLabel:(($=t.labels)==null?void 0:$.dateAfterLabel)??"After",dateBeforeLabel:((S=t.labels)==null?void 0:S.dateBeforeLabel)??"Before",searchLabel:((B=t.labels)==null?void 0:B.searchLabel)??"Search"}});function l(){return{...t.filters,...t.filters.kinds!==void 0?{kinds:[...t.filters.kinds]}:{},...t.filters.selected_uuids!==void 0?{selected_uuids:[...t.filters.selected_uuids]}:{}}}function s(w){n("update:filters",w),n("change",w)}function d(w){const g=l(),b=(g.kinds??[]).filter(R=>R!==w);b.length>0?g.kinds=b:delete g.kinds,s(g)}function c(w){const g=l(),b=new Set(g.kinds??[]);b.add(w),g.kinds=Array.from(b),s(g),i.value=!1}function u(){const w=l();delete w.usage_status,s(w)}function m(w){const g=l();g.usage_status=w,s(g),i.value=!1}function p(w){const g=new Date;return g.setHours(0,0,0,0),g.setDate(g.getDate()-w),g.toISOString()}function f(){const w=new Date;return new Date(w.getFullYear(),0,1).toISOString()}function h(w,g=null){const b=l();w===null?delete b.created_after:b.created_after=w,g===null?delete b.created_before:b.created_before=g,s(b),i.value=!1}function v(w){const g=l();delete g[w],s(g)}function k(){s({sort:t.filters.sort??"newest"}),n("clear")}const y=e.computed(()=>{const w=[];for(const g of t.filters.kinds??[]){const b=g==="image"?r.value.imageLabel:g==="video"?r.value.videoLabel:String(g);w.push({key:`kind-${g}`,label:`${r.value.typeLabel}: ${b}`,remove:()=>d(g)})}return(t.filters.usage_status==="used"||t.filters.usage_status==="not_used")&&w.push({key:"usage",label:`${r.value.usageLabel}: ${t.filters.usage_status==="used"?r.value.usedLabel:r.value.notUsedLabel}`,remove:u}),t.filters.created_after&&w.push({key:"created-after",label:`${r.value.dateAfterLabel}: ${t.filters.created_after}`,remove:()=>v("created_after")}),t.filters.created_before&&w.push({key:"created-before",label:`${r.value.dateBeforeLabel}: ${t.filters.created_before}`,remove:()=>v("created_before")}),t.filters.query&&t.filters.query.trim()!==""&&w.push({key:"query",label:`${r.value.searchLabel}: "${t.filters.query.trim()}"`,remove:()=>v("query")}),w});return(w,g)=>(e.openBlock(),e.createElementBlock("div",UD,[e.createElementVNode("div",OD,[t.scopeLabel!==""?(e.openBlock(),e.createElementBlock("span",zD,e.toDisplayString(t.scopeLabel),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.value,b=>(e.openBlock(),e.createElementBlock("button",{key:b.key,type:"button",class:"media-filter-chips__chip","data-testid":`media-filter-chip-${b.key}`,onClick:b.remove},[e.createElementVNode("span",null,e.toDisplayString(b.label),1),g[8]||(g[8]=e.createElementVNode("span",{"aria-hidden":"true"},"×",-1))],8,jD))),128)),y.value.length>=2?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"media-filter-chips__clear","data-testid":"btn-media-filter-clear-all",onClick:k},e.toDisplayString(r.value.clearAll),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",WD,[e.createElementVNode("button",{type:"button",class:"media-filter-chips__add","data-testid":"btn-media-filter-add","aria-expanded":i.value?"true":"false",onClick:g[0]||(g[0]=b=>i.value=!i.value)}," + "+e.toDisplayString(r.value.addFilter),9,HD),i.value?(e.openBlock(),e.createElementBlock("div",ZD,[e.createElementVNode("button",{type:"button","data-testid":"opt-filter-image",onClick:g[1]||(g[1]=b=>c("image"))},e.toDisplayString(r.value.typeLabel)+": "+e.toDisplayString(r.value.imageLabel),1),e.createElementVNode("button",{type:"button","data-testid":"opt-filter-video",onClick:g[2]||(g[2]=b=>c("video"))},e.toDisplayString(r.value.typeLabel)+": "+e.toDisplayString(r.value.videoLabel),1),e.createElementVNode("button",{type:"button","data-testid":"opt-filter-used",onClick:g[3]||(g[3]=b=>m("used"))},e.toDisplayString(r.value.usageLabel)+": "+e.toDisplayString(r.value.usedLabel),1),e.createElementVNode("button",{type:"button","data-testid":"opt-filter-not-used",onClick:g[4]||(g[4]=b=>m("not_used"))},e.toDisplayString(r.value.usageLabel)+": "+e.toDisplayString(r.value.notUsedLabel),1),e.createElementVNode("button",{type:"button","data-testid":"opt-filter-date-7d",onClick:g[5]||(g[5]=b=>h(p(7)))},"Date: Last 7 days"),e.createElementVNode("button",{type:"button","data-testid":"opt-filter-date-30d",onClick:g[6]||(g[6]=b=>h(p(30)))},"Date: Last 30 days"),e.createElementVNode("button",{type:"button","data-testid":"opt-filter-date-year",onClick:g[7]||(g[7]=b=>h(f()))},"Date: This year")])):e.createCommentVNode("",!0)])]))}}),Rf=$e(GD,[["__scopeId","data-v-4861e8d7"]]);class Ld extends Error{constructor(a,t="Media deletion requires explicit confirmation."){super(t),this.name="RequiresConfirmationError",this.softBlocks=a}}const XD="/v1/media/deletion/check",KD="/v1/media/deletion/delete",yr=100;function Ou(o){const a=new Set,t=[];for(const n of o){const i=n.trim().toLowerCase();i===""||a.has(i)||(a.add(i),t.push(i))}return t.sort()}function Lf(o){const a=o.checkEndpoint??XD,t=o.deleteEndpoint??KD,n=e.ref(!1),i=e.ref(!1),r=e.ref(null),l=e.ref(null),s=e.ref(null);async function d(f){s.value=null;const h=Ou(f);if(h.length===0)return r.value=[],[];if(h.length>yr){const v=new Error(`Cannot check more than ${yr} media items at once.`);throw s.value=v,v}n.value=!0;try{const v=await o.httpClient.post(a,{uuids:h}),k=((v==null?void 0:v.data)??[]).map(y=>{var w,g,b,R;return{uuid:y.uuid,canDelete:((w=y.report)==null?void 0:w.canDelete)??!1,blocks:Array.isArray((g=y.report)==null?void 0:g.blocks)?y.report.blocks:[],cascade:Array.isArray((b=y.report)==null?void 0:b.cascade)?y.report.cascade:[],variantCount:typeof((R=y.report)==null?void 0:R.variantCount)=="number"?y.report.variantCount:0}});return r.value=k,k}catch(v){throw s.value=v instanceof Error?v:new Error(String(v)),s.value}finally{n.value=!1}}async function c(f,h={}){s.value=null;const v=Ou(f);if(v.length===0){const k={results:[],summary:{}};return l.value=k,k}if(v.length>yr){const k=new Error(`Cannot delete more than ${yr} media items at once.`);throw s.value=k,k}i.value=!0;try{const k=await o.httpClient.post(t,{uuids:v,force:h.force===!0,confirmed:h.confirmed===!0}),y={results:Array.isArray(k==null?void 0:k.results)?k.results:[],summary:(k==null?void 0:k.summary)??{}};return l.value=y,y}catch(k){const y=u(k);if(y&&y.requires_confirmation===!0){const w=m(y.soft_blocks),g=new Ld(w);throw s.value=g,g}throw s.value=k instanceof Error?k:new Error(String(k)),s.value}finally{i.value=!1}}function u(f){if(typeof f!="object"||f===null)return null;const h=f;if(h.response&&typeof h.response=="object"&&h.response.data&&typeof h.response.data=="object")return h.response.data;const v=f;return"requires_confirmation"in v||"soft_blocks"in v?v:null}function m(f){if(typeof f!="object"||f===null)return{};const h={};for(const[v,k]of Object.entries(f)){if(!Array.isArray(k))continue;const y=[];for(const w of k){if(typeof w!="object"||w===null)continue;const g=w;typeof g.type=="string"&&typeof g.context=="string"&&y.push({type:g.type,context:g.context})}h[v]=y}return h}function p(){r.value=null,l.value=null,s.value=null}return{isChecking:n,isDeleting:i,lastReport:r,lastResponse:l,error:s,checkDependencies:d,deleteMany:c,reset:p}}const JD="/v1/user/media/trash";function qD(o){return`/v1/user/media/${encodeURIComponent(o)}/restore`}function YD(o){return`/v1/user/media/${encodeURIComponent(o)}/purge`}function Pd(o){const a=o.listEndpoint??JD,t=o.buildRestoreEndpoint??qD,n=o.buildPurgeEndpoint??YD,i=o.perPage??50,r=e.ref([]),l=e.ref(0),s=e.ref(1),d=e.ref(!1),c=e.ref(!1),u=e.ref(!1),m=e.ref(null);async function p(k=1){var y,w;m.value=null,d.value=!0;try{const g=await o.httpClient.get(a,{params:{page:k,per_page:i}});r.value=Array.isArray(g==null?void 0:g.data)?g.data:[],l.value=typeof((y=g==null?void 0:g.meta)==null?void 0:y.total)=="number"?g.meta.total:0,s.value=typeof((w=g==null?void 0:g.meta)==null?void 0:w.current_page)=="number"?g.meta.current_page:k}catch(g){throw m.value=g instanceof Error?g:new Error(String(g)),m.value}finally{d.value=!1}}async function f(k){m.value=null,c.value=!0;try{const y=await o.httpClient.post(t(k)),w={status:(y==null?void 0:y.status)??"failed",data:(y==null?void 0:y.data)??null,duplicate_uuid:(y==null?void 0:y.duplicate_uuid)??null};return typeof(y==null?void 0:y.message)=="string"&&(w.message=y.message),w.status==="restored"&&(r.value=r.value.filter(g=>g.uuid!==k),l.value=Math.max(0,l.value-1)),w}catch(y){const w=zu(y);if(w&&typeof w.status=="string"){const g={status:w.status,duplicate_uuid:typeof w.duplicate_uuid=="string"?w.duplicate_uuid:null};return typeof w.message=="string"&&(g.message=w.message),g}throw m.value=y instanceof Error?y:new Error(String(y)),m.value}finally{c.value=!1}}async function h(k){m.value=null,u.value=!0;try{if(typeof o.httpClient.delete!="function")throw new Error("Media trash purge requires an HTTP client with delete support.");const y=await o.httpClient.delete(n(k)),w={status:(y==null?void 0:y.status)??"failed"};return typeof(y==null?void 0:y.message)=="string"&&(w.message=y.message),w.status==="purging"&&(r.value=r.value.filter(g=>g.uuid!==k),l.value=Math.max(0,l.value-1)),w}catch(y){const w=zu(y);if(w&&typeof w.status=="string"){const g={status:w.status};return typeof w.message=="string"&&(g.message=w.message),g}throw m.value=y instanceof Error?y:new Error(String(y)),m.value}finally{u.value=!1}}function v(){r.value=[],l.value=0,s.value=1,m.value=null}return{items:r,total:l,currentPage:s,isLoading:d,isRestoring:c,isPurging:u,error:m,fetch:p,restore:f,purge:h,reset:v}}function zu(o){var t;if(typeof o!="object"||o===null)return null;const a=o;return(t=a.response)!=null&&t.data&&typeof a.response.data=="object"?a.response.data:null}const QD={class:"media-management-view","data-testid":"media-management-view"},eA={key:0,class:"media-management-view__header"},tA={class:"media-management-view__title"},aA={class:"media-management-view__actions"},nA={key:0,class:"media-management-view__badge"},oA={key:1,class:"media-management-view__panel","data-testid":"panel-library"},iA={key:0,class:"media-management-view__view-mode",role:"radiogroup","aria-label":"Media library layout","data-testid":"media-management-layout-mode"},rA=["aria-checked"],lA=["aria-checked"],sA={key:1,class:"media-management-view__status","data-testid":"library-loading"},dA={key:2,class:"media-management-view__status media-management-view__status--error","data-testid":"library-error"},cA={key:3,class:"media-management-view__empty","data-testid":"library-empty"},uA={class:"media-management-view__empty-state"},mA={class:"media-management-view__empty-title","data-testid":"library-empty-title"},pA={class:"media-management-view__empty-description","data-testid":"library-empty-description"},fA={key:4,class:"media-management-view__table","data-testid":"library-table"},hA={scope:"col","data-testid":"table-header-select"},vA={class:"media-management-view__checkbox-label"},gA=["checked",".indeterminate","aria-label"],bA={class:"media-management-view__sr-only"},yA={scope:"col","data-testid":"table-header-thumbnail"},wA={scope:"col","data-testid":"table-header-name"},kA={scope:"col","data-testid":"table-header-type"},_A={scope:"col","data-testid":"table-header-created"},EA={scope:"col","data-testid":"table-header-size"},SA={scope:"col","data-testid":"table-header-status"},CA={scope:"col","data-testid":"table-header-actions"},xA=["data-testid"],NA={class:"media-management-view__checkbox-label"},VA=["checked","aria-label","data-testid","onChange"],TA=["data-testid","onClick"],BA=["src","alt","onError"],IA=["data-testid"],MA=["title","data-testid"],$A=["data-testid"],FA=["data-testid"],DA={class:"media-management-view__item-actions"},AA=["onKeydown"],RA=["data-testid","aria-label","aria-expanded","onClick"],LA=["data-testid"],PA=["data-testid","onClick"],UA={key:5,class:"media-management-view__grid","data-testid":"library-grid"},OA=["data-testid"],zA=["data-testid","aria-pressed","onClick"],jA=["src","alt","onError"],WA=["data-testid"],HA={class:"media-management-view__selection-corner"},ZA={class:"media-management-view__sr-only"},GA=["checked","data-testid","onChange"],XA={class:"media-management-view__item-meta"},KA=["title","data-testid"],JA=["data-testid"],qA=["data-testid"],YA={key:2,class:"media-management-view__item-badge","data-testid":"badge-orphaned"},QA=["data-testid"],eR={class:"media-management-view__item-actions media-management-view__item-actions--grid"},tR=["onKeydown"],aR=["data-testid","aria-label","aria-expanded","onClick"],nR=["data-testid"],oR=["data-testid","onClick"],iR={class:"media-management-view__bulk-bar","data-testid":"bulk-bar"},rR={"data-testid":"bulk-count"},lR=["disabled"],sR={key:7,class:"media-management-view__pagination","data-testid":"media-management-pagination"},dR={class:"media-management-view__pagination-count","data-testid":"media-management-pagination-count","aria-live":"polite"},cR={key:0,class:"media-management-view__page-size",role:"group","aria-label":"Items per page","data-testid":"media-management-page-size"},uR=["value","disabled"],mR=["value","data-testid"],pR=["disabled"],fR={key:2,class:"media-management-view__page-bar","aria-label":"Media library pagination","data-testid":"media-management-page-bar"},hR=["disabled"],vR=["data-testid","disabled","aria-current","aria-label","onClick"],gR=["disabled"],bR={key:2,class:"media-management-view__panel","data-testid":"panel-trash"},yR={key:0,class:"media-management-view__status","data-testid":"trash-loading"},wR={key:1,class:"media-management-view__empty","data-testid":"trash-empty"},kR={class:"media-management-view__empty-state"},_R={class:"media-management-view__empty-title","data-testid":"trash-empty-title"},ER={class:"media-management-view__empty-description","data-testid":"trash-empty-description"},SR={key:2,class:"media-management-view__grid","data-testid":"trash-grid"},CR=["data-testid"],xR={class:"media-management-view__item-thumb"},NR=["src","alt","onError"],VR=["data-testid"],TR={class:"media-management-view__item-meta"},BR={class:"media-management-view__item-name"},IR={key:0,class:"media-management-view__item-meta-line"},MR=["data-testid","disabled","onClick"],$R=["data-testid"],FR=e.defineComponent({__name:"MediaManagementView",props:{httpClient:{},capabilities:{default:()=>({})},labels:{default:()=>({})},filters:{},initialView:{},perPage:{},pageSizeOptions:{default:()=>[]},showAllOption:{type:Boolean,default:!1},loadAllMaxItems:{},paginated:{type:Boolean,default:!1},groupVariants:{type:Boolean,default:!0},paginationWindow:{default:7},initialLayoutMode:{},layoutMode:{},confirmBulkDelete:{},confirmDestructiveAction:{},onRestoreCollision:{}},emits:["deleted","restored","restore-conflict","create-post","create-gallery","add-to-album","edit","update:layoutMode","error"],setup(o,{expose:a,emit:t}){const n=o,i=t,r=e.computed(()=>({showTrash:!0,showHeader:!0,showLayoutSwitcher:!0,allowBulkDelete:!0,allowPreview:!0,allowCreatePost:!1,allowCreateGallery:!1,allowAddToAlbum:!1,allowImageEdit:!1,allowVideoEdit:!1,showOwner:!1,showRawFileName:!1,...n.capabilities})),l=e.computed(()=>{var X,we,ne,Fe,It,At,Mt,mt,pt,Qt,yt,Wt,_a,G,q,pe,he,Te,He,ot,Je,Ze,dt,ft,Qe,ea,Ft,Pa,Fa,co,Da,on,Ua,ha,In,uo,Mn,mo,hn;return{title:((X=n.labels)==null?void 0:X.title)??"My Media",libraryTab:((we=n.labels)==null?void 0:we.libraryTab)??"Library",trashTab:((ne=n.labels)==null?void 0:ne.trashTab)??"Trash",loading:((Fe=n.labels)==null?void 0:Fe.loading)??"Loading…",emptyLibrary:((It=n.labels)==null?void 0:It.emptyLibrary)??"No media yet — upload your first creation.",emptyLibraryTitle:((At=n.labels)==null?void 0:At.emptyLibraryTitle)??"Your media library is ready",emptyLibraryDescription:((Mt=n.labels)==null?void 0:Mt.emptyLibraryDescription)??"Images and videos you upload for creations are saved here so you can reuse them later.",emptyTrash:((mt=n.labels)==null?void 0:mt.emptyTrash)??"Trash is empty.",emptyTrashTitle:((pt=n.labels)==null?void 0:pt.emptyTrashTitle)??"No media in trash",emptyTrashDescription:((Qt=n.labels)==null?void 0:Qt.emptyTrashDescription)??"Deleted files appear here for 30 days before permanent removal.",orphanedBadge:((yt=n.labels)==null?void 0:yt.orphanedBadge)??"Not in use",selectedCount:((Wt=n.labels)==null?void 0:Wt.selectedCount)??(Oa=>`${Oa} selected`),deleteButton:((_a=n.labels)==null?void 0:_a.deleteButton)??"Delete",createPostButton:((G=n.labels)==null?void 0:G.createPostButton)??"Create Post",createGalleryButton:((q=n.labels)==null?void 0:q.createGalleryButton)??"Create Gallery",addToAlbumButton:((pe=n.labels)==null?void 0:pe.addToAlbumButton)??"Add to Album",previewButton:((he=n.labels)==null?void 0:he.previewButton)??"Preview",previewCloseButton:((Te=n.labels)==null?void 0:Te.previewCloseButton)??"Close",previewPreviousButton:((He=n.labels)==null?void 0:He.previewPreviousButton)??"Previous",previewNextButton:((ot=n.labels)==null?void 0:ot.previewNextButton)??"Next",previewSelectButton:((Je=n.labels)==null?void 0:Je.previewSelectButton)??"Select",previewDeselectButton:((Ze=n.labels)==null?void 0:Ze.previewDeselectButton)??"Deselect",editButton:((dt=n.labels)==null?void 0:dt.editButton)??"Edit",loadMoreButton:((ft=n.labels)==null?void 0:ft.loadMoreButton)??"Load more",loadingMoreButton:((Qe=n.labels)==null?void 0:Qe.loadingMoreButton)??"Loading more...",restoreButton:((ea=n.labels)==null?void 0:ea.restoreButton)??"Restore",restoreUnavailable:((Ft=n.labels)==null?void 0:Ft.restoreUnavailable)??"Restore unavailable",gridView:((Pa=n.labels)==null?void 0:Pa.gridView)??"Grid",tableView:((Fa=n.labels)==null?void 0:Fa.tableView)??"Table",tableSelectHeader:((co=n.labels)==null?void 0:co.tableSelectHeader)??"Select",tableThumbnailHeader:((Da=n.labels)==null?void 0:Da.tableThumbnailHeader)??"Preview",tableNameHeader:((on=n.labels)==null?void 0:on.tableNameHeader)??"Name",tableTypeHeader:((Ua=n.labels)==null?void 0:Ua.tableTypeHeader)??"Type",tableCreatedHeader:((ha=n.labels)==null?void 0:ha.tableCreatedHeader)??"Uploaded",tableSizeHeader:((In=n.labels)==null?void 0:In.tableSizeHeader)??"Size",tableStatusHeader:((uo=n.labels)==null?void 0:uo.tableStatusHeader)??"Status",tableActionsHeader:((Mn=n.labels)==null?void 0:Mn.tableActionsHeader)??"Actions",purgeAfter:((mo=n.labels)==null?void 0:mo.purgeAfter)??(Oa=>`Purges ${Oa}`),ownerLabel:((hn=n.labels)==null?void 0:hn.ownerLabel)??(Oa=>`User ${Oa.user_id??""}`)}}),s=e.computed(()=>l.value.title),d=e.computed(()=>l.value.libraryTab),c=e.computed(()=>l.value.trashTab),u=e.computed(()=>l.value.loading),m=e.computed(()=>l.value.emptyLibraryTitle),p=e.computed(()=>l.value.emptyLibraryDescription),f=e.computed(()=>l.value.emptyTrashTitle),h=e.computed(()=>l.value.emptyTrashDescription),v=e.computed(()=>l.value.orphanedBadge),k=e.computed(()=>l.value.deleteButton),y=e.computed(()=>l.value.restoreButton),w=e.computed(()=>l.value.restoreUnavailable),g=e.computed(()=>l.value.gridView),b=e.computed(()=>l.value.tableView);function R(X){const we=r.value.canRestore;return we?we(X):!0}const V=e.ref("library"),I=e.ref(n.layoutMode??n.initialLayoutMode??"grid"),x=e.ref(null),T=e.ref(null);function $(X){return{...X??{},...(X==null?void 0:X.kinds)!==void 0?{kinds:[...X.kinds]}:{}}}const S=e.ref(n.initialView??{scope:"library"}),B=e.ref($(n.filters)),_=e.ref(n.perPage??50),A=e.ref(!1),P=e.ref(n.paginated?1:null),D=Ad({httpClient:n.httpClient,view:S,filters:B,perPage:_,page:P}),z=e.computed(()=>n.groupVariants!==!0?D.items.value:D.items.value.filter(X=>typeof X.parent_media_uuid!="string"||X.parent_media_uuid.trim()==="")),M=e.computed(()=>D.loading.value),Z=e.computed(()=>{var X;return((X=D.error.value)==null?void 0:X.message)??null}),O=e.computed(()=>r.value.allowBulkDelete!==!1||r.value.allowCreatePost===!0||r.value.allowCreateGallery===!0||r.value.allowAddToAlbum===!0),K=e.computed(()=>{const X=x.value;return X===null?null:z.value[X]??null}),de=tl(z),Ne=Lf({httpClient:n.httpClient}),ce=Pd({httpClient:n.httpClient});function le(X){return l.value.selectedCount(X)}function W(X){return l.value.purgeAfter(X)}function C(X){return l.value.ownerLabel(X)}const U=e.computed(()=>{const X=z.value.length;return X===0?"":D.hasMore.value?X===1?"Showing 1 item":`Showing ${X} items`:X===1?"Showing all 1 item":`Showing all ${X} items`});function j(X){I.value!==X&&(Ot(),I.value=X,i("update:layoutMode",X))}function re(X){return X.mime_type.startsWith("image/")}function ue(X){return X.mime_type.startsWith("video/")}function Xe(X){return re(X)?"image":ue(X)?"video":null}function be(X){return re(X)?r.value.allowImageEdit===!0:ue(X)?r.value.allowVideoEdit===!0:!1}const Ee=Df;function ye(X){return typeof X.variant_count=="number"&&Number.isFinite(X.variant_count)?Math.max(0,X.variant_count):0}function xe(X){return X===1?"1 edit":`${X} edits`}function Ce(X){return re(X)?"Image":ue(X)?"Video":X.mime_type.startsWith("audio/")?"Audio":"File"}function Re(X){if(typeof X.formatted_size=="string"&&X.formatted_size.trim()!=="")return X.formatted_size;if(!Number.isFinite(X.size)||X.size<=0)return"";const we=["B","KB","MB","GB"];let ne=X.size,Fe=0;for(;ne>=1024&&Fe<we.length-1;)ne/=1024,Fe+=1;return`${ne>=10||Fe===0?Math.round(ne):ne.toFixed(1)} ${we[Fe]}`}function ze(X){const we=new Date(X.created_at);return Number.isNaN(we.getTime())?X.created_at:new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(we)}function rt(X){return X.deletion_status==="active"||X.deletion_status===void 0||X.deletion_status===null?"Ready":X.deletion_status.replace(/_/g," ").replace(/\b\w/g,we=>we.toUpperCase())}function at(X){if(typeof X.thumbnail_url=="string"&&X.thumbnail_url.length>0)return X.thumbnail_url;const we=typeof X.mime_type=="string"&&X.mime_type.startsWith("image/"),ne=typeof X.mime_type=="string"&&X.mime_type.startsWith("video/");return we?X.original_url||null:ne&&typeof X.preview_url=="string"&&X.preview_url.length>0?X.preview_url:null}function Dt(X){return typeof X.mime_type=="string"&&X.mime_type.startsWith("video/")?`Video — ${X.file_name}`:X.file_name}const ht=e.ref(new Set);function St(X){if(ht.value.has(X.uuid))return;const we=new Set(ht.value);we.add(X.uuid),ht.value=we}function ut(X){if(r.value.allowPreview===!1)return;const we=z.value.findIndex(ne=>ne.uuid===X.uuid);x.value=we>=0?we:null}function lt(){x.value=null}function Ct(){x.value===null||x.value<=0||(x.value-=1)}function Se(){x.value===null||x.value>=z.value.length-1||(x.value+=1)}async function J(){try{await D.loadMore()}catch(X){i("error",X instanceof Error?X:new Error(String(X)))}}const oe=e.computed(()=>{const X=D.totalPages.value??0,we=D.currentPage.value??1;if(X<=1)return[];const ne=Math.max(3,n.paginationWindow);if(X<=ne)return Array.from({length:X},(pt,Qt)=>({kind:"page",key:`p-${Qt+1}`,value:Qt+1}));const Fe=ne-2,It=Math.floor(Fe/2);let At=Math.max(2,we-It),Mt=Math.min(X-1,At+Fe-1);Mt===X-1&&(At=Math.max(2,Mt-Fe+1));const mt=[{kind:"page",key:"p-1",value:1}];At>2&&mt.push({kind:"ellipsis",key:"el-left"});for(let pt=At;pt<=Mt;pt++)mt.push({kind:"page",key:`p-${pt}`,value:pt});return Mt<X-1&&mt.push({kind:"ellipsis",key:"el-right"}),mt.push({kind:"page",key:`p-${X}`,value:X}),mt});async function De(X){if(!(X===D.currentPage.value||D.loading.value)){P.value=X;try{await D.goToPage(X)}catch(we){i("error",we instanceof Error?we:new Error(String(we)))}}}async function fe(X){const we=D.currentPage.value??1,ne=D.totalPages.value??1,Fe=Math.min(Math.max(1,we+X),ne);Fe!==we&&await De(Fe)}const Ae=e.computed(()=>{const X=n.pageSizeOptions.map(we=>({value:String(we),label:String(we)}));return X.length===0&&!n.showAllOption?[]:(n.showAllOption&&X.push({value:"all",label:"All"}),X)}),Ye=e.computed(()=>A.value?"all":String(_.value));async function st(X){const we=X.target;if(!(we instanceof HTMLSelectElement))return;const ne=we.value;try{if(ne==="all"){const Fe=n.pageSizeOptions,It=Fe.length>0?Math.max(...Fe):_.value;P.value=null,_.value=It,A.value=!1,await D.refresh();const At=n.loadAllMaxItems!==void 0?{maxItems:n.loadAllMaxItems}:void 0;await D.loadAll(At),A.value=!D.hasMore.value}else{const Fe=Number.parseInt(ne,10);Number.isFinite(Fe)&&Fe>0&&(_.value=Fe),A.value=!1,n.paginated&&(P.value=1),await D.refresh()}}catch(Fe){i("error",Fe instanceof Error?Fe:new Error(String(Fe)))}}function Bt(X,we){i("create-post",{mediaIds:X.map(ne=>ne.uuid),items:X,source:we})}function Vt(X,we){i("create-gallery",{mediaIds:X.map(ne=>ne.uuid),items:X,source:we})}function Lt(X,we){i("add-to-album",{mediaIds:X.map(ne=>ne.uuid),items:X,source:we})}function Pt(X){const we=Xe(X);we===null||!be(X)||i("edit",{media:X,kind:we})}function zt(X){T.value=T.value===X?null:X}function Ot(){T.value=null}function jt(X){X.run(),Ot()}function oa(X){const we=[];return r.value.allowPreview!==!1&&we.push({id:"preview",label:l.value.previewButton,testId:`btn-preview-${X.uuid}`,run:()=>ut(X)}),be(X)&&we.push({id:"edit",label:l.value.editButton,testId:`btn-edit-${X.uuid}`,run:()=>Pt(X)}),r.value.allowCreatePost===!0&&we.push({id:"create-post",label:l.value.createPostButton,testId:`btn-create-post-${X.uuid}`,run:()=>Bt([X],"item")}),r.value.allowCreateGallery===!0&&we.push({id:"create-gallery",label:l.value.createGalleryButton,testId:`btn-create-gallery-${X.uuid}`,run:()=>Vt([X],"item")}),r.value.allowAddToAlbum===!0&&we.push({id:"add-to-album",label:l.value.addToAlbumButton,testId:`btn-add-to-album-${X.uuid}`,run:()=>Lt([X],"item")}),we}async function Q(X){const we=X.results.filter(ne=>ne.status==="trashed"||ne.status==="already_trashed").map(ne=>ne.uuid);if(we.length!==0){for(const ne of we)de.deselect(ne);i("deleted",we),await D.refresh(),r.value.showTrash!==!1&&await ce.fetch(ce.currentPage.value).catch(()=>{})}}function ge(X){const we=new Set;for(const It of X)for(const At of It.blocks)At.context&&we.add(At.context);const ne=Array.from(we),Fe=ne.length>0?`This media is still attached to: ${ne.map(It=>`"${It}"`).join(", ")}. Remove from those and delete?`:"This media is still attached to other items. Remove from those and delete?";return window.confirm(Fe)}function me(X){return Object.entries(X).map(([we,ne])=>({uuid:we,blocks:ne}))}async function se(){const X=de.selectedItems.value;if(X.length===0)return;const we=r.value.canDelete?X.filter(Fe=>r.value.canDelete(Fe)):X;if(we.length===0||n.confirmBulkDelete&&!await n.confirmBulkDelete(we))return;const ne=we.map(Fe=>Fe.uuid);try{const Fe=await Ne.deleteMany(ne);await Q(Fe)}catch(Fe){if(Fe instanceof Ld){const It=me(Fe.softBlocks);if(!(n.confirmDestructiveAction?await n.confirmDestructiveAction({items:we,softBlocks:It}):ge(It)))return;try{const Mt=await Ne.deleteMany(ne,{confirmed:!0});await Q(Mt)}catch(Mt){i("error",Mt instanceof Error?Mt:new Error(String(Mt)))}return}i("error",Fe instanceof Error?Fe:new Error(String(Fe)))}}async function Ve(X){var ne;const we=ce.items.value.find(Fe=>Fe.uuid===X);if(!(we&&!R(we)))try{const Fe=await ce.restore(X);if(Fe.status==="restored"){i("restored",X),await D.refresh().catch(()=>{});return}if(Fe.status==="duplicate_conflict"){i("restore-conflict",{uuid:X,duplicateUuid:Fe.duplicate_uuid??null}),(ne=n.onRestoreCollision)==null||ne.call(n,X,Fe.duplicate_uuid??null);return}}catch(Fe){i("error",Fe instanceof Error?Fe:new Error(String(Fe)))}}async function Pe(){V.value="trash",ce.items.value.length===0&&!ce.isLoading.value&&await ce.fetch().catch(X=>{i("error",X instanceof Error?X:new Error(String(X)))})}function et(X){if(X==="trash"){Pe();return}V.value=X}const gt=e.computed(()=>({activeTab:V.value,setActiveTab:et,trashCount:ce.total.value,showTrash:r.value.showTrash!==!1,labels:{libraryTab:l.value.libraryTab,trashTab:l.value.trashTab}})),Tt=e.computed(()=>({selectedCount:de.selectedCount.value,selectedItemIds:Array.from(de.selectedIds.value),selectedItems:de.selectedItems.value,crossPageCount:de.crossPageCount.value,isDeleting:Ne.isDeleting.value,onBulkDelete:se,...r.value.allowCreatePost===!0?{onCreatePost:()=>Bt(de.selectedItems.value,"bulk")}:{},...r.value.allowCreateGallery===!0?{onCreateGallery:()=>Vt(de.selectedItems.value,"bulk")}:{},...r.value.allowAddToAlbum===!0?{onAddToAlbum:()=>Lt(de.selectedItems.value,"bulk")}:{},clearSelection:de.clear,labels:{deleteButton:l.value.deleteButton,...r.value.allowCreatePost===!0?{createPostButton:l.value.createPostButton}:{},...r.value.allowCreateGallery===!0?{createGalleryButton:l.value.createGalleryButton}:{},...r.value.allowAddToAlbum===!0?{addToAlbumButton:l.value.addToAlbumButton}:{},selectedCount:l.value.selectedCount}})),xt=e.computed(()=>({filters:B.value,view:S.value,total:D.total.value,shown:z.value.length,loading:D.loading.value}));function _t(X){return{media:X,selected:de.isSelected(X.uuid),canEdit:be(X),onPreview:()=>ut(X),...be(X)?{onEdit:()=>Pt(X)}:{},...r.value.allowCreatePost===!0?{onCreatePost:()=>Bt([X],"item")}:{},...r.value.allowCreateGallery===!0?{onCreateGallery:()=>Vt([X],"item")}:{},...r.value.allowAddToAlbum===!0?{onAddToAlbum:()=>Lt([X],"item")}:{},labels:{previewButton:l.value.previewButton,editButton:l.value.editButton,createPostButton:l.value.createPostButton,createGalleryButton:l.value.createGalleryButton,addToAlbumButton:l.value.addToAlbumButton}}}function Xt(X){return{media:X,canRestore:R(X),isRestoring:ce.isRestoring.value,onRestore:()=>Ve(X.uuid),labels:{restoreButton:l.value.restoreButton,restoreUnavailable:l.value.restoreUnavailable}}}return e.watch(V,async X=>{X==="library"&&z.value.length===0&&!M.value&&await D.refresh().catch(()=>{})}),e.watch(()=>n.layoutMode,X=>{X!==void 0&&(I.value=X)}),e.watch(()=>n.filters,async X=>{B.value=$(X),de.clear(),lt(),await D.refresh().catch(we=>{i("error",we instanceof Error?we:new Error(String(we)))})},{deep:!0}),e.onMounted(async()=>{await D.refresh().catch(X=>{i("error",X instanceof Error?X:new Error(String(X)))}),r.value.showTrash!==!1&&ce.fetch().catch(()=>{})}),a({refresh:()=>D.refresh(),refreshTrash:()=>ce.fetch(),selection:de,deletion:Ne,trash:ce}),(X,we)=>(e.openBlock(),e.createElementBlock("div",QD,[r.value.showHeader!==!1?(e.openBlock(),e.createElementBlock("header",eA,[e.createElementVNode("h2",tA,e.toDisplayString(s.value),1),e.createElementVNode("div",aA,[e.renderSlot(X.$slots,"tabs",e.normalizeProps(e.guardReactiveProps(gt.value)),()=>[r.value.showTrash!==!1?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["media-management-view__tab-button",{"is-active":V.value==="library"}]),"data-testid":"tab-library",onClick:we[0]||(we[0]=ne=>V.value="library")},e.toDisplayString(d.value),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["media-management-view__tab-button",{"is-active":V.value==="trash"}]),"data-testid":"tab-trash",onClick:Pe},[e.createTextVNode(e.toDisplayString(c.value)+" ",1),e.unref(ce).total.value>0?(e.openBlock(),e.createElementBlock("span",nA,e.toDisplayString(e.unref(ce).total.value),1)):e.createCommentVNode("",!0)],2)],64)):e.createCommentVNode("",!0)],!0)])])):e.createCommentVNode("",!0),V.value==="library"?(e.openBlock(),e.createElementBlock("section",oA,[r.value.showLayoutSwitcher!==!1?(e.openBlock(),e.createElementBlock("div",iA,[e.createElementVNode("button",{type:"button",role:"radio",class:e.normalizeClass(["media-management-view__view-mode-button",{"is-active":I.value==="grid"}]),"aria-checked":I.value==="grid"?"true":"false","data-testid":"view-mode-grid",onClick:we[1]||(we[1]=ne=>j("grid"))},e.toDisplayString(g.value),11,rA),e.createElementVNode("button",{type:"button",role:"radio",class:e.normalizeClass(["media-management-view__view-mode-button",{"is-active":I.value==="table"}]),"aria-checked":I.value==="table"?"true":"false","data-testid":"view-mode-table",onClick:we[2]||(we[2]=ne=>j("table"))},e.toDisplayString(b.value),11,lA)])):e.createCommentVNode("",!0),e.renderSlot(X.$slots,"filter-bar",e.normalizeProps(e.guardReactiveProps(xt.value)),void 0,!0),M.value?(e.openBlock(),e.createElementBlock("div",sA,e.toDisplayString(u.value),1)):Z.value?(e.openBlock(),e.createElementBlock("div",dA,e.toDisplayString(Z.value),1)):z.value.length===0?(e.openBlock(),e.createElementBlock("div",cA,[e.renderSlot(X.$slots,"empty-library",{},()=>[e.createElementVNode("div",uA,[e.createElementVNode("p",mA,e.toDisplayString(m.value),1),e.createElementVNode("p",pA,e.toDisplayString(p.value),1)])],!0)])):I.value==="table"?(e.openBlock(),e.createElementBlock("table",fA,[e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[e.createElementVNode("th",hA,[e.createElementVNode("label",vA,[e.createElementVNode("input",{class:"media-management-view__checkbox",type:"checkbox",checked:e.unref(de).isAllSelected.value,".indeterminate":e.unref(de).isSomeSelected.value&&!e.unref(de).isAllSelected.value,"aria-label":l.value.tableSelectHeader,"data-testid":"checkbox-select-all",onChange:we[3]||(we[3]=(...ne)=>e.unref(de).toggleAll&&e.unref(de).toggleAll(...ne))},null,40,gA),e.createElementVNode("span",bA,e.toDisplayString(l.value.tableSelectHeader),1)])]),e.createElementVNode("th",yA,e.toDisplayString(l.value.tableThumbnailHeader),1),e.createElementVNode("th",wA,e.toDisplayString(l.value.tableNameHeader),1),e.createElementVNode("th",kA,e.toDisplayString(l.value.tableTypeHeader),1),e.createElementVNode("th",_A,e.toDisplayString(l.value.tableCreatedHeader),1),e.createElementVNode("th",EA,e.toDisplayString(l.value.tableSizeHeader),1),e.createElementVNode("th",SA,e.toDisplayString(l.value.tableStatusHeader),1),e.createElementVNode("th",CA,e.toDisplayString(l.value.tableActionsHeader),1)])]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(z.value,ne=>(e.openBlock(),e.createElementBlock("tr",{key:ne.uuid,class:e.normalizeClass({"is-selected":e.unref(de).isSelected(ne.uuid),"has-open-actions":T.value===ne.uuid}),"data-testid":`media-row-${ne.uuid}`},[e.createElementVNode("td",null,[e.createElementVNode("label",NA,[e.createElementVNode("input",{class:"media-management-view__checkbox",type:"checkbox",checked:e.unref(de).isSelected(ne.uuid),"aria-label":`${l.value.tableSelectHeader} ${e.unref(Ee)(ne)}`,"data-testid":`checkbox-select-${ne.uuid}`,onChange:Fe=>e.unref(de).toggle(ne.uuid)},null,40,VA)])]),e.createElementVNode("td",null,[e.createElementVNode("button",{type:"button",class:"media-management-view__table-thumb","data-testid":`btn-preview-thumb-${ne.uuid}`,onClick:Fe=>ut(ne)},[at(ne)&&!ht.value.has(ne.uuid)?(e.openBlock(),e.createElementBlock("img",{key:0,src:at(ne)??"",alt:ne.alt_text||ne.file_name,loading:"lazy",onError:Fe=>St(ne)},null,40,BA)):(e.openBlock(),e.createElementBlock("span",{key:1,class:"media-management-view__item-placeholder","data-testid":`placeholder-${ne.uuid}`},e.toDisplayString(Dt(ne)),9,IA))],8,TA)]),e.createElementVNode("td",null,[e.createElementVNode("span",{class:"media-management-view__display-name",title:ne.file_name,"data-testid":`media-display-name-${ne.uuid}`},e.toDisplayString(e.unref(Ee)(ne)),9,MA),ye(ne)>0?(e.openBlock(),e.createElementBlock("span",{key:0,class:"media-management-view__variant-badge","data-testid":`media-variant-badge-${ne.uuid}`},e.toDisplayString(xe(ye(ne))),9,$A)):e.createCommentVNode("",!0),r.value.showRawFileName===!0?(e.openBlock(),e.createElementBlock("span",{key:1,class:"media-management-view__raw-filename","data-testid":`media-raw-filename-${ne.uuid}`},e.toDisplayString(ne.file_name),9,FA)):e.createCommentVNode("",!0)]),e.createElementVNode("td",null,e.toDisplayString(Ce(ne)),1),e.createElementVNode("td",null,e.toDisplayString(ze(ne)),1),e.createElementVNode("td",null,e.toDisplayString(Re(ne)),1),e.createElementVNode("td",null,e.toDisplayString(rt(ne)),1),e.createElementVNode("td",null,[e.renderSlot(X.$slots,"item-actions",e.mergeProps({ref_for:!0},_t(ne)),()=>[e.createElementVNode("div",DA,[e.createElementVNode("div",{class:"media-management-view__action-menu",onKeydown:e.withKeys(e.withModifiers(Ot,["stop"]),["escape"])},[e.createElementVNode("button",{type:"button",class:"media-management-view__action-menu-trigger","data-testid":`btn-actions-menu-${ne.uuid}`,"aria-label":`Actions for ${e.unref(Ee)(ne)}`,"aria-haspopup":"menu","aria-expanded":T.value===ne.uuid?"true":"false",onClick:Fe=>zt(ne.uuid)}," ... ",8,RA),T.value===ne.uuid?(e.openBlock(),e.createElementBlock("div",{key:0,class:"media-management-view__action-menu-panel",role:"menu","data-testid":`media-item-actions-menu-${ne.uuid}`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(oa(ne),Fe=>(e.openBlock(),e.createElementBlock("button",{key:Fe.id,type:"button",class:"media-management-view__action-menu-item",role:"menuitem","data-testid":Fe.testId,onClick:It=>jt(Fe)},e.toDisplayString(Fe.label),9,PA))),128))],8,LA)):e.createCommentVNode("",!0)],40,AA)])],!0)])],10,xA))),128))])])):(e.openBlock(),e.createElementBlock("ul",UA,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(z.value,ne=>(e.openBlock(),e.createElementBlock("li",{key:ne.uuid,class:e.normalizeClass(["media-management-view__item",{"is-selected":e.unref(de).isSelected(ne.uuid),"has-open-actions":T.value===ne.uuid}]),"data-testid":`media-item-${ne.uuid}`},[e.createElementVNode("button",{type:"button",class:"media-management-view__item-thumb","data-testid":`btn-select-${ne.uuid}`,"aria-pressed":e.unref(de).isSelected(ne.uuid),onClick:Fe=>e.unref(de).toggle(ne.uuid)},[at(ne)&&!ht.value.has(ne.uuid)?(e.openBlock(),e.createElementBlock("img",{key:0,src:at(ne)??"",alt:ne.alt_text||ne.file_name,loading:"lazy",onError:Fe=>St(ne)},null,40,jA)):(e.openBlock(),e.createElementBlock("span",{key:1,class:"media-management-view__item-placeholder","data-testid":`placeholder-${ne.uuid}`},e.toDisplayString(Dt(ne)),9,WA))],8,zA),e.createElementVNode("label",HA,[e.createElementVNode("span",ZA,e.toDisplayString(l.value.tableSelectHeader)+" "+e.toDisplayString(e.unref(Ee)(ne)),1),e.createElementVNode("input",{class:"media-management-view__checkbox media-management-view__checkbox--overlay",type:"checkbox",checked:e.unref(de).isSelected(ne.uuid),"data-testid":`checkbox-select-${ne.uuid}`,onClick:we[4]||(we[4]=e.withModifiers(()=>{},["stop"])),onChange:Fe=>e.unref(de).toggle(ne.uuid)},null,40,GA)]),e.createElementVNode("div",XA,[e.createElementVNode("span",{class:"media-management-view__item-name",title:ne.file_name,"data-testid":`media-display-name-${ne.uuid}`},e.toDisplayString(e.unref(Ee)(ne)),9,KA),r.value.showRawFileName===!0?(e.openBlock(),e.createElementBlock("span",{key:0,class:"media-management-view__raw-filename","data-testid":`media-raw-filename-${ne.uuid}`},e.toDisplayString(ne.file_name),9,JA)):e.createCommentVNode("",!0),r.value.showOwner&&ne.user_id?(e.openBlock(),e.createElementBlock("span",{key:1,class:"media-management-view__item-owner","data-testid":`owner-${ne.uuid}`},e.toDisplayString(C(ne)),9,qA)):e.createCommentVNode("",!0),ne.is_orphaned?(e.openBlock(),e.createElementBlock("span",YA,e.toDisplayString(v.value),1)):e.createCommentVNode("",!0),ye(ne)>0?(e.openBlock(),e.createElementBlock("span",{key:3,class:"media-management-view__variant-badge","data-testid":`media-variant-badge-${ne.uuid}`},e.toDisplayString(xe(ye(ne))),9,QA)):e.createCommentVNode("",!0)]),e.renderSlot(X.$slots,"item-actions",e.mergeProps({ref_for:!0},_t(ne)),()=>[e.createElementVNode("div",eR,[e.createElementVNode("div",{class:"media-management-view__action-menu",onKeydown:e.withKeys(e.withModifiers(Ot,["stop"]),["escape"])},[e.createElementVNode("button",{type:"button",class:"media-management-view__action-menu-trigger","data-testid":`btn-actions-menu-${ne.uuid}`,"aria-label":`Actions for ${e.unref(Ee)(ne)}`,"aria-haspopup":"menu","aria-expanded":T.value===ne.uuid?"true":"false",onClick:Fe=>zt(ne.uuid)}," ... ",8,aR),T.value===ne.uuid?(e.openBlock(),e.createElementBlock("div",{key:0,class:"media-management-view__action-menu-panel",role:"menu","data-testid":`media-item-actions-menu-${ne.uuid}`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(oa(ne),Fe=>(e.openBlock(),e.createElementBlock("button",{key:Fe.id,type:"button",class:"media-management-view__action-menu-item",role:"menuitem","data-testid":Fe.testId,onClick:It=>jt(Fe)},e.toDisplayString(Fe.label),9,oR))),128))],8,nR)):e.createCommentVNode("",!0)],40,tR)])],!0)],10,OA))),128))])),e.unref(de).selectedCount.value>0&&O.value?e.renderSlot(X.$slots,"bulk-actions",e.normalizeProps(e.mergeProps({key:6},Tt.value)),()=>[e.createElementVNode("footer",iR,[e.createElementVNode("span",rR,e.toDisplayString(le(e.unref(de).selectedCount.value)),1),r.value.allowCreatePost===!0?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-management-view__btn-action","data-testid":"btn-bulk-create-post",onClick:we[5]||(we[5]=ne=>Bt(e.unref(de).selectedItems.value,"bulk"))},e.toDisplayString(l.value.createPostButton),1)):e.createCommentVNode("",!0),r.value.allowCreateGallery===!0?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"media-management-view__btn-action","data-testid":"btn-bulk-create-gallery",onClick:we[6]||(we[6]=ne=>Vt(e.unref(de).selectedItems.value,"bulk"))},e.toDisplayString(l.value.createGalleryButton),1)):e.createCommentVNode("",!0),r.value.allowAddToAlbum===!0?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"media-management-view__btn-action","data-testid":"btn-bulk-add-to-album",onClick:we[7]||(we[7]=ne=>Lt(e.unref(de).selectedItems.value,"bulk"))},e.toDisplayString(l.value.addToAlbumButton),1)):e.createCommentVNode("",!0),r.value.allowBulkDelete!==!1?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"media-management-view__btn-delete","data-testid":"btn-bulk-delete",disabled:e.unref(Ne).isDeleting.value,onClick:se},e.toDisplayString(k.value),9,lR)):e.createCommentVNode("",!0)])],!0):e.createCommentVNode("",!0),z.value.length>0?(e.openBlock(),e.createElementBlock("footer",sR,[e.createElementVNode("span",dR,e.toDisplayString(U.value),1),Ae.value.length>0?(e.openBlock(),e.createElementBlock("div",cR,[we[11]||(we[11]=e.createElementVNode("label",{class:"media-management-view__page-size-label",for:"media-management-page-size-select"},"Show:",-1)),e.createElementVNode("select",{id:"media-management-page-size-select",class:"media-management-view__page-size-select","data-testid":"select-media-management-page-size",value:Ye.value,disabled:e.unref(D).loading.value||e.unref(D).loadingMore.value,onChange:st},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Ae.value,ne=>(e.openBlock(),e.createElementBlock("option",{key:ne.value,value:ne.value,"data-testid":`option-page-size-${ne.value}`},e.toDisplayString(ne.label),9,mR))),128))],40,uR)])):e.createCommentVNode("",!0),!X.paginated&&e.unref(D).hasMore.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"media-management-view__load-more","data-testid":"btn-media-management-load-more",disabled:e.unref(D).loadingMore.value,onClick:J},e.toDisplayString(e.unref(D).loadingMore.value?l.value.loadingMoreButton:l.value.loadMoreButton),9,pR)):e.createCommentVNode("",!0),X.paginated&&(e.unref(D).totalPages.value??0)>1?(e.openBlock(),e.createElementBlock("nav",fR,[e.createElementVNode("button",{type:"button",class:"media-management-view__page-bar-step","data-testid":"btn-media-management-page-prev",disabled:(e.unref(D).currentPage.value??1)<=1||e.unref(D).loading.value,"aria-label":"Previous page",onClick:we[8]||(we[8]=ne=>fe(-1))}," ‹ ",8,hR),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(oe.value,ne=>(e.openBlock(),e.createElementBlock("button",{key:ne.key,type:"button",class:e.normalizeClass(["media-management-view__page-bar-page",{"is-current":ne.kind==="page"&&ne.value===e.unref(D).currentPage.value}]),"data-testid":ne.kind==="page"?`btn-media-management-page-${ne.value}`:"media-management-page-ellipsis",disabled:ne.kind!=="page"||e.unref(D).loading.value,"aria-current":ne.kind==="page"&&ne.value===e.unref(D).currentPage.value?"page":void 0,"aria-label":ne.kind==="page"?`Page ${ne.value}`:void 0,onClick:Fe=>ne.kind==="page"?De(ne.value):void 0},e.toDisplayString(ne.kind==="page"?ne.value:"…"),11,vR))),128)),e.createElementVNode("button",{type:"button",class:"media-management-view__page-bar-step","data-testid":"btn-media-management-page-next",disabled:(e.unref(D).currentPage.value??1)>=(e.unref(D).totalPages.value??1)||e.unref(D).loading.value,"aria-label":"Next page",onClick:we[9]||(we[9]=ne=>fe(1))}," › ",8,gR)])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])):V.value==="trash"?(e.openBlock(),e.createElementBlock("section",bR,[e.unref(ce).isLoading.value?(e.openBlock(),e.createElementBlock("div",yR,e.toDisplayString(u.value),1)):e.unref(ce).items.value.length===0?(e.openBlock(),e.createElementBlock("div",wR,[e.renderSlot(X.$slots,"empty-trash",{},()=>[e.createElementVNode("div",kR,[e.createElementVNode("p",_R,e.toDisplayString(f.value),1),e.createElementVNode("p",ER,e.toDisplayString(h.value),1)])],!0)])):(e.openBlock(),e.createElementBlock("ul",SR,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(ce).items.value,ne=>(e.openBlock(),e.createElementBlock("li",{key:ne.uuid,class:"media-management-view__item is-trashed","data-testid":`trash-item-${ne.uuid}`},[e.createElementVNode("div",xR,[at(ne)&&!ht.value.has(ne.uuid)?(e.openBlock(),e.createElementBlock("img",{key:0,src:at(ne)??"",alt:ne.alt_text||ne.file_name,loading:"lazy",onError:Fe=>St(ne)},null,40,NR)):(e.openBlock(),e.createElementBlock("span",{key:1,class:"media-management-view__item-placeholder","data-testid":`placeholder-trash-${ne.uuid}`},e.toDisplayString(Dt(ne)),9,VR))]),e.createElementVNode("div",TR,[e.createElementVNode("span",BR,e.toDisplayString(ne.file_name),1),ne.purge_after?(e.openBlock(),e.createElementBlock("span",IR,e.toDisplayString(W(ne.purge_after)),1)):e.createCommentVNode("",!0)]),e.renderSlot(X.$slots,"trash-action",e.mergeProps({ref_for:!0},Xt(ne)),()=>[R(ne)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-management-view__btn-restore","data-testid":`btn-restore-${ne.uuid}`,disabled:e.unref(ce).isRestoring.value,onClick:Fe=>Ve(ne.uuid)},e.toDisplayString(y.value),9,MR)):(e.openBlock(),e.createElementBlock("span",{key:1,class:"media-management-view__btn-restore is-unavailable","data-testid":`btn-restore-${ne.uuid}-unavailable`,"aria-disabled":!0},e.toDisplayString(w.value),9,$R))],!0)],8,CR))),128))]))])):e.createCommentVNode("",!0),r.value.allowPreview!==!1?(e.openBlock(),e.createBlock(Md,{key:3,open:K.value!==null,media:K.value,"can-go-previous":x.value!==null&&x.value>0,"can-go-next":x.value!==null&&x.value<z.value.length-1,selected:K.value!==null&&e.unref(de).isSelected(K.value.uuid),"close-label":l.value.previewCloseButton,"previous-label":l.value.previewPreviousButton,"next-label":l.value.previewNextButton,"select-label":l.value.previewSelectButton,"deselect-label":l.value.previewDeselectButton,onClose:lt,onPrevious:Ct,onNext:Se,onToggleSelect:we[10]||(we[10]=ne=>e.unref(de).toggle(ne.uuid))},null,8,["open","media","can-go-previous","can-go-next","selected","close-label","previous-label","next-label","select-label","deselect-label"])):e.createCommentVNode("",!0)]))}}),Pf=$e(FR,[["__scopeId","data-v-8c4b53f6"]]),DR={class:"media-library-workspace","data-testid":"media-library-workspace"},AR=e.defineComponent({__name:"MediaLibraryWorkspace",props:{httpClient:{},filters:{default:()=>({sort:"newest"})},initialView:{default:()=>({scope:"library"})},capabilities:{default:()=>({})},labels:{default:()=>({})},groupVariants:{type:Boolean,default:!0}},emits:["filters-change","create-post","create-gallery","add-to-album","edit","deleted","restored","restore-conflict","error"],setup(o,{emit:a}){const t=o,n=a;function i(s){return{...s,...s.kinds!==void 0?{kinds:[...s.kinds]}:{},...s.selected_uuids!==void 0?{selected_uuids:[...s.selected_uuids]}:{}}}const r=e.ref(i(t.filters));e.watch(()=>t.filters,s=>{r.value=i(s)},{deep:!0});function l(s){r.value=i(s),n("filters-change",r.value)}return(s,d)=>(e.openBlock(),e.createElementBlock("section",DR,[e.createVNode(Pf,{"http-client":t.httpClient,filters:r.value,"initial-view":t.initialView,"group-variants":t.groupVariants,capabilities:{showHeader:!1,showTrash:!1,allowAddToAlbum:t.capabilities.allowAddToAlbum,allowBulkDelete:t.capabilities.allowBulkDelete,allowCreateGallery:t.capabilities.allowCreateGallery,allowCreatePost:t.capabilities.allowCreatePost,showRawFileName:t.capabilities.showRawFileName,allowPreview:t.capabilities.allowPreview,allowImageEdit:t.capabilities.allowImageEdit,allowVideoEdit:t.capabilities.allowVideoEdit},labels:{title:t.labels.title??"Media"},onCreatePost:d[0]||(d[0]=c=>n("create-post",c)),onCreateGallery:d[1]||(d[1]=c=>n("create-gallery",c)),onAddToAlbum:d[2]||(d[2]=c=>n("add-to-album",c)),onEdit:d[3]||(d[3]=c=>n("edit",c)),onDeleted:d[4]||(d[4]=c=>n("deleted",c)),onRestored:d[5]||(d[5]=c=>n("restored",c)),onRestoreConflict:d[6]||(d[6]=c=>n("restore-conflict",c)),onError:d[7]||(d[7]=c=>n("error",c))},{"filter-bar":e.withCtx(()=>[e.createVNode(Rf,{filters:r.value,"scope-label":t.labels.scopeLabel??"","onUpdate:filters":l},null,8,["filters","scope-label"])]),"bulk-actions":e.withCtx(c=>[e.renderSlot(s.$slots,"bulk-actions",e.normalizeProps(e.guardReactiveProps(c)),void 0,!0)]),"item-actions":e.withCtx(c=>[e.renderSlot(s.$slots,"item-actions",e.normalizeProps(e.guardReactiveProps(c)),void 0,!0)]),"empty-library":e.withCtx(()=>[e.renderSlot(s.$slots,"empty-library",{},void 0,!0)]),_:3},8,["http-client","filters","initial-view","group-variants","capabilities","labels"])]))}}),Uf=$e(AR,[["__scopeId","data-v-28ba5859"]]),RR=["data-testid"],LR={class:"media-empty-state__illustration","aria-hidden":"true"},PR={class:"media-empty-state__copy"},UR={class:"media-empty-state__title"},OR={key:0,class:"media-empty-state__description"},zR={class:"media-empty-state__actions"},jR=e.defineComponent({__name:"MediaEmptyState",props:{title:{},description:{default:""},actionLabel:{default:""},testId:{default:"media-empty-state"}},emits:["action"],setup(o,{emit:a}){const t=o,n=a;return(i,r)=>(e.openBlock(),e.createElementBlock("section",{class:"media-empty-state","data-testid":t.testId},[e.createElementVNode("div",LR,[e.renderSlot(i.$slots,"illustration",{},()=>[r[1]||(r[1]=e.createElementVNode("span",{class:"media-empty-state__icon"},"□",-1))],!0)]),e.createElementVNode("div",PR,[e.createElementVNode("h3",UR,e.toDisplayString(t.title),1),t.description!==""?(e.openBlock(),e.createElementBlock("p",OR,e.toDisplayString(t.description),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",zR,[e.renderSlot(i.$slots,"actions",{},()=>[t.actionLabel!==""?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-empty-state__action","data-testid":"btn-media-empty-state-action",onClick:r[0]||(r[0]=l=>n("action"))},e.toDisplayString(t.actionLabel),1)):e.createCommentVNode("",!0)],!0)])],8,RR))}}),Of=$e(jR,[["__scopeId","data-v-7b8e2619"]]),WR={class:"media-trash-workspace","data-testid":"media-trash-workspace"},HR={class:"media-trash-workspace__header"},ZR={key:0,class:"media-trash-workspace__status"},GR={key:2,class:"media-trash-workspace__grid"},XR=["data-testid"],KR={class:"media-trash-workspace__select"},JR=["checked","data-testid","onChange"],qR=["src","alt"],YR={key:1,class:"media-trash-workspace__purge"},QR=e.defineComponent({__name:"MediaTrashWorkspace",props:{httpClient:{},labels:{default:()=>({})}},emits:["restored","purged","error"],setup(o,{emit:a}){const t=o,n=a,i=e.computed(()=>{var p,f,h,v,k,y;return{title:((p=t.labels)==null?void 0:p.title)??"Trash",emptyTitle:((f=t.labels)==null?void 0:f.emptyTitle)??"Your trash is empty",emptyDescription:((h=t.labels)==null?void 0:h.emptyDescription)??"Deleted files appear here before permanent removal.",restore:((v=t.labels)==null?void 0:v.restore)??"Restore",purge:((k=t.labels)==null?void 0:k.purge)??"Delete forever",emptyTrash:((y=t.labels)==null?void 0:y.emptyTrash)??"Empty trash"}}),r=Pd({httpClient:t.httpClient}),l=tl(r.items);function s(p){return p.thumbnail_url??p.preview_url??p.original_url??null}async function d(){const p=Array.from(l.selectedIds.value),f=[];try{for(const h of p)(await r.restore(h)).status==="restored"&&f.push(h);l.clear(),n("restored",f)}catch(h){n("error",h instanceof Error?h:new Error(String(h)))}}async function c(){const p=Array.from(l.selectedIds.value);await m(p)}async function u(){await m(r.items.value.map(p=>p.uuid))}async function m(p){const f=[];try{for(const h of p)(await r.purge(h)).status==="purging"&&f.push(h);l.clear(),n("purged",f)}catch(h){n("error",h instanceof Error?h:new Error(String(h)))}}return e.onMounted(()=>{r.fetch().catch(p=>{n("error",p instanceof Error?p:new Error(String(p)))})}),(p,f)=>(e.openBlock(),e.createElementBlock("section",WR,[e.createElementVNode("header",HR,[e.createElementVNode("h2",null,e.toDisplayString(i.value.title),1),e.unref(r).items.value.length>0?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button","data-testid":"btn-media-empty-trash",onClick:u},e.toDisplayString(i.value.emptyTrash),1)):e.createCommentVNode("",!0)]),e.unref(r).isLoading.value?(e.openBlock(),e.createElementBlock("p",ZR,"Loading...")):e.unref(r).items.value.length===0?(e.openBlock(),e.createBlock(Of,{key:1,title:i.value.emptyTitle,description:i.value.emptyDescription,"test-id":"media-empty-trash"},null,8,["title","description"])):(e.openBlock(),e.createElementBlock("ul",GR,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r).items.value,h=>(e.openBlock(),e.createElementBlock("li",{key:h.uuid,class:e.normalizeClass(["media-trash-workspace__item",{"is-selected":e.unref(l).isSelected(h.uuid)}]),"data-testid":`media-trash-item-${h.uuid}`},[e.createElementVNode("label",KR,[e.createElementVNode("input",{type:"checkbox",checked:e.unref(l).isSelected(h.uuid),"data-testid":`checkbox-trash-${h.uuid}`,onChange:v=>e.unref(l).toggle(h.uuid)},null,40,JR),e.createElementVNode("span",null,e.toDisplayString(h.file_name),1)]),s(h)?(e.openBlock(),e.createElementBlock("img",{key:0,src:s(h)??"",alt:h.alt_text??h.file_name},null,8,qR)):e.createCommentVNode("",!0),h.purge_after?(e.openBlock(),e.createElementBlock("span",YR,e.toDisplayString(h.purge_after),1)):e.createCommentVNode("",!0)],10,XR))),128))])),e.createVNode(Rd,{"selected-count":e.unref(l).selectedCount.value,"cross-page-count":e.unref(l).crossPageCount.value,scope:"trash",labels:{restore:i.value.restore,purge:i.value.purge},onBulkRestore:d,onBulkPurge:c,onClear:e.unref(l).clear},null,8,["selected-count","cross-page-count","labels","onClear"])]))}}),zf=$e(QR,[["__scopeId","data-v-3b1b3c56"]]),eL=["data-density"],tL={class:"media-library-shell__toolbar"},aL={class:"media-library-shell__tabs","aria-label":"Media library sections"},nL=["aria-label"],oL=["data-testid","onClick"],iL={key:2,class:"media-library-shell__uploads","data-testid":"media-library-uploads","aria-live":"polite"},rL=["data-testid"],lL={class:"media-library-shell__upload-thumb"},sL=["src","alt"],dL={key:1,"aria-hidden":"true"},cL={class:"media-library-shell__upload-meta"},uL={class:"media-library-shell__upload-name"},mL={class:"media-library-shell__upload-status"},pL=["data-testid","onClick"],fL={class:"media-library-shell__workspace"},hL={key:0,class:"media-library-shell__breadcrumb","data-testid":"media-album-breadcrumb"},vL={class:"media-library-shell__breadcrumb-name"},gL=["aria-label"],bL={class:"media-album-grid__toolbar"},yL=["placeholder","aria-label"],wL={class:"media-album-grid__tiles",role:"list"},kL={class:"media-album-grid__new-tile-label"},_L=["data-testid","onClick"],EL={class:"media-album-grid__cover","aria-hidden":"true"},SL=["src"],CL={key:1,class:"media-album-grid__cover-initial"},xL={class:"media-album-grid__tile-meta"},NL={class:"media-album-grid__tile-name"},VL={class:"media-album-grid__tile-count"},TL={key:0,class:"media-album-grid__empty","data-testid":"media-album-grid-empty-search"},BL={key:1,class:"media-album-grid__empty","data-testid":"media-album-grid-empty"},ju="media-library:density",Wu="media-library:recent-albums",Hu=5,IL=e.defineComponent({__name:"MediaLibraryShell",props:{httpClient:{},albumHttpClient:{},albumBaseUrl:{},initialTab:{default:"library"},initialAlbumId:{default:null},initialFilters:{default:()=>({sort:"newest"})},capabilities:{default:()=>({})},labels:{default:()=>({})},currentRoute:{},routerPush:{},routerReplace:{}},emits:["tab-change","album-change","filters-change","selection-change","create-post","create-gallery","add-to-album","edit","deleted","restored","restore-conflict","error"],setup(o,{emit:a}){function t(){if(typeof window>"u")return"comfortable";try{return window.localStorage.getItem(ju)==="compact"?"compact":"comfortable"}catch{return"comfortable"}}function n(J){if(!(typeof window>"u"))try{window.localStorage.setItem(ju,J)}catch{}}function i(){if(typeof window>"u")return[];try{const J=window.localStorage.getItem(Wu);if(typeof J!="string"||J==="")return[];const oe=JSON.parse(J);return Array.isArray(oe)?oe.filter(De=>typeof De=="string"):[]}catch{return[]}}function r(J){if(!(typeof window>"u"))try{window.localStorage.setItem(Wu,JSON.stringify(J.slice(0,Hu)))}catch{}}const l=o,s=a,d=e.ref(l.initialTab),c=e.ref(l.initialAlbumId),u=e.ref({...l.initialFilters}),m=e.ref(null),p=e.ref(null),f=e.ref(!1),h=e.ref(null),v=e.ref(null),k=e.ref(t()),y=e.ref(i()),w=e.ref(!1),g=e.ref("");function b(){if(typeof document>"u")return!1;const J=document.activeElement;if(!(J instanceof HTMLElement))return!1;if(J.isContentEditable)return!0;const oe=J.tagName.toLowerCase();return oe==="input"||oe==="textarea"||oe==="select"}function R(J){J.key==="?"&&(J.metaKey||J.ctrlKey||J.altKey||b()||(J.preventDefault(),w.value=!0))}const V=e.computed(()=>d.value==="albums"&&c.value===null),I=e.computed(()=>d.value==="albums"&&c.value!==null&&c.value!=="unfiled"),x=e.computed(()=>{var J;return c.value===null||c.value==="unfiled"?"":((J=D.albumsById.value.get(c.value))==null?void 0:J.name)??""}),T=e.computed(()=>{const J=g.value.trim().toLowerCase(),oe=D.albums.value;return J===""?oe:oe.filter(De=>De.name.toLowerCase().includes(J))});function $(J){const oe=J.name.trim();return oe.length===0?"·":oe.charAt(0).toUpperCase()}function S(J){var fe,Ae,Ye;const oe=J.cover_media;if(oe==null)return null;const De=((fe=oe.urls)==null?void 0:fe.thumb)??((Ae=oe.urls)==null?void 0:Ae.preview)??((Ye=oe.urls)==null?void 0:Ye.original)??null;return typeof De=="string"&&De!==""?De:null}function B(J){return O.value.itemsCount(J.media_count)}const _=e.computed(()=>y.value.map(J=>{const oe=D.albumsById.value.get(J);return oe?{id:J,name:oe.name}:null}).filter(J=>J!==null));function A(J){const oe=[J,...y.value.filter(De=>De!==J)].slice(0,Hu);y.value=oe,r(oe)}const P=e.computed(()=>u.value.sort??"newest"),D=Vl(),z=Mf({httpClient:l.httpClient,onMediaUploaded:()=>{M.value+=1}}),M=e.ref(0);function Z(J){J.length!==0&&z.uploadFiles(J).catch(oe=>{s("error",oe instanceof Error?oe:new Error(String(oe)))})}const O=e.computed(()=>{var J,oe,De,fe,Ae,Ye,st,Bt,Vt,Lt,Pt,zt,Ot,jt,oa,Q,ge,me,se,Ve,Pe,et,gt;return{library:((J=l.labels)==null?void 0:J.library)??((oe=l.labels)==null?void 0:oe.libraryTab)??"Library",libraryTab:((De=l.labels)==null?void 0:De.libraryTab)??((fe=l.labels)==null?void 0:fe.library)??"Library",albums:((Ae=l.labels)==null?void 0:Ae.albums)??((Ye=l.labels)==null?void 0:Ye.albumsTab)??"Albums",albumsTab:((st=l.labels)==null?void 0:st.albumsTab)??((Bt=l.labels)==null?void 0:Bt.albums)??"Albums",trash:((Vt=l.labels)==null?void 0:Vt.trash)??((Lt=l.labels)==null?void 0:Lt.trashTab)??"Trash",trashTab:((Pt=l.labels)==null?void 0:Pt.trashTab)??((zt=l.labels)==null?void 0:zt.trash)??"Trash",allMedia:((Ot=l.labels)==null?void 0:Ot.allMedia)??"All media",unfiled:((jt=l.labels)==null?void 0:jt.unfiled)??"Unfiled",newAlbum:((oa=l.labels)==null?void 0:oa.newAlbum)??"New album",selectionScope:((Q=l.labels)==null?void 0:Q.selectionScope)??"Showing selected items",exitSelectionScope:((ge=l.labels)==null?void 0:ge.exitSelectionScope)??"Exit selection view",findAlbum:((me=l.labels)==null?void 0:me.findAlbum)??"Find album…",noAlbumsYet:((se=l.labels)==null?void 0:se.noAlbumsYet)??"No albums yet — albums are private buckets where you group photos and videos. Create your first one above to start organising your work.",noAlbumMatchesFound:((Ve=l.labels)==null?void 0:Ve.noAlbumMatchesFound)??"No albums match your search.",itemsCount:((Pe=l.labels)==null?void 0:Pe.itemsCount)??(Tt=>`${Tt} ${Tt===1?"item":"items"}`),newAlbumNamePrompt:((et=l.labels)==null?void 0:et.newAlbumNamePrompt)??"Name this album",recentSection:((gt=l.labels)==null?void 0:gt.recentSection)??"Recent albums"}}),K=e.computed(()=>h.value!==null?{scope:"library"}:c.value==="unfiled"?{scope:"unfiled"}:c.value!==null?{scope:"album",albumId:c.value}:{scope:"library"}),de=e.computed(()=>h.value!==null?{...u.value,selected_uuids:[...h.value],unfiled_only:!1}:u.value),Ne=e.computed(()=>{if(c.value===null||c.value==="unfiled")return null;const J=D.albumsById.value.get(c.value);return{uuid:c.value,name:(J==null?void 0:J.name)??"this album"}}),ce=e.computed(()=>d.value==="trash"?"trash":h.value!==null?"selection":Ne.value!==null?"album":"all"),le=e.computed(()=>d.value==="trash"?O.value.trash:h.value!==null?O.value.selectionScope:c.value==="unfiled"?O.value.unfiled:Ne.value!==null?Ne.value.name:O.value.allMedia);function W(J){var oe,De,fe;d.value!==J&&(d.value=J,s("tab-change",J),J==="trash"?(oe=l.routerPush)==null||oe.call(l,"/media/trash"):J==="albums"?(De=l.routerPush)==null||De.call(l,"/media/albums"):(fe=l.routerPush)==null||fe.call(l,"/media"))}function C(J){var oe;be(),c.value=J,d.value="albums",A(J),u.value={...u.value,unfiled_only:!1},s("album-change",J),(oe=l.routerPush)==null||oe.call(l,`/media/album/${encodeURIComponent(J)}`)}function U(){var J;be(),c.value=null,d.value="albums",u.value={...u.value,unfiled_only:!1},s("album-change",null),(J=l.routerPush)==null||J.call(l,"/media/albums")}async function j(J){if(c.value===null||c.value==="unfiled")return;const oe=c.value;try{await D.updateAlbum(oe,{meta:{cover_media_uuid:J.uuid}}),D.fetchAlbums({parent_id:null})}catch(De){s("error",De instanceof Error?De:new Error(String(De)))}}async function re(){if(typeof window>"u")return;const J=window.prompt(O.value.newAlbumNamePrompt);if(J===null)return;const oe=J.trim();if(oe!=="")try{const De=await D.createAlbum({name:oe});De!=null&&C(De.id)}catch(De){s("error",De instanceof Error?De:new Error(String(De)))}}function ue(){return d.value==="trash"?"/media/trash":c.value==="unfiled"?"/media/unfiled":c.value!==null?`/media/album/${encodeURIComponent(c.value)}`:"/media"}function Xe(J){var oe;J.length!==0&&(h.value===null&&(v.value=ue()),h.value=[...J],(oe=l.routerPush)==null||oe.call(l,{path:"/media",query:{view:"selection"}}))}function be(){h.value=null,v.value=null}function Ee(){var oe;const J=v.value;be(),J!==null&&((oe=l.routerPush)==null||oe.call(l,J))}function ye(J){var oe;u.value={...u.value,sort:J},s("filters-change",u.value),(oe=l.routerReplace)==null||oe.call(l,{query:u.value})}function xe(J){k.value=J,n(J)}function Ce(J){var oe;u.value={...u.value,created_after:J.starts_at,created_before:J.ends_at},s("filters-change",u.value),(oe=l.routerReplace)==null||oe.call(l,{query:u.value})}function Re(){var oe;const J={...u.value};delete J.created_after,delete J.created_before,u.value=J,s("filters-change",u.value),(oe=l.routerReplace)==null||oe.call(l,{query:u.value})}const ze=e.computed(()=>u.value.created_after!==void 0||u.value.created_before!==void 0);function rt(J){var oe;u.value={...J,...J.kinds!==void 0?{kinds:[...J.kinds]}:{},...J.selected_uuids!==void 0?{selected_uuids:[...J.selected_uuids]}:{}},s("filters-change",u.value),(oe=l.routerReplace)==null||oe.call(l,{query:u.value})}function at(){of({...l.albumHttpClient!==void 0?{httpClient:l.albumHttpClient}:{},...l.albumBaseUrl!==void 0?{albumBaseUrl:l.albumBaseUrl}:{}})}function Dt(J){J.mediaIds.length!==0&&(p.value=J,f.value=!0)}function ht(){f.value=!1,p.value=null,ut.value=null}async function St(J){const oe=p.value;if(oe===null)return;const De=ut.value;try{await D.attachMedia(J,oe.mediaIds),De!==null&&await Promise.all(oe.mediaIds.map(fe=>D.detachMedia(De,fe))),f.value=!1,p.value=null,ut.value=null,s("add-to-album",oe)}catch(fe){s("error",fe instanceof Error?fe:new Error(String(fe)))}}const ut=e.ref(null);function lt(J){J.mediaIds.length===0||Ne.value===null||(p.value=J,ut.value=Ne.value.uuid,f.value=!0)}async function Ct(J){if(J.mediaIds.length===0||Ne.value===null)return;const oe=Ne.value.uuid;try{await Promise.all(J.mediaIds.map(De=>D.detachMedia(oe,De)))}catch(De){s("error",De instanceof Error?De:new Error(String(De)))}}e.watch(()=>l.initialAlbumId,J=>{c.value=J});function Se(J){J===null||J==="unfiled"||D.albumsById.value.has(J)||D.fetchAlbum(J).catch(oe=>{s("error",oe instanceof Error?oe:new Error(String(oe)))})}return e.watch(()=>c.value,J=>Se(J)),at(),e.onMounted(()=>{Se(c.value),D.fetchAlbums({parent_id:null}).catch(J=>{s("error",J instanceof Error?J:new Error(String(J)))}),typeof window<"u"&&window.addEventListener("keydown",R)}),e.onUnmounted(()=>{typeof window<"u"&&window.removeEventListener("keydown",R)}),e.watch(()=>[l.albumHttpClient,l.albumBaseUrl],()=>at()),(J,oe)=>{var De;return e.openBlock(),e.createElementBlock("section",{class:e.normalizeClass(["media-library-shell",{"is-density-compact":k.value==="compact"}]),"data-density":k.value,"data-testid":"media-library-shell"},[e.createElementVNode("header",tL,[e.createElementVNode("nav",aL,[e.createElementVNode("button",{type:"button",class:e.normalizeClass({"is-active":d.value==="library"}),"data-testid":"tab-media-library",onClick:oe[0]||(oe[0]=fe=>W("library"))},e.toDisplayString(O.value.library),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass({"is-active":d.value==="albums"}),"data-testid":"tab-media-albums",onClick:oe[1]||(oe[1]=fe=>W("albums"))},e.toDisplayString(O.value.albums),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass({"is-active":d.value==="trash"}),"data-testid":"tab-media-trash",onClick:oe[2]||(oe[2]=fe=>W("trash"))},e.toDisplayString(O.value.trash),3)]),e.createElementVNode("button",{type:"button",class:"media-library-shell__shortcut-trigger","data-testid":"btn-media-shortcuts","aria-label":"Show keyboard shortcuts",onClick:oe[3]||(oe[3]=fe=>w.value=!0)}," ? "),h.value!==null?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-library-shell__exit-selection","data-testid":"btn-media-exit-selection-scope",onClick:Ee},e.toDisplayString(O.value.exitSelectionScope),1)):e.createCommentVNode("",!0)]),d.value!=="trash"&&!V.value?(e.openBlock(),e.createBlock(Bf,{key:0,class:"media-library-shell__toolbar-row",sort:P.value,density:k.value,"has-date-filter":ze.value,"http-client":l.httpClient,"onUpdate:sort":ye,"onUpdate:density":xe,onJumpTo:Ce,onJumpToAll:Re,onUploadFiles:Z},null,8,["sort","density","has-date-filter","http-client"])):e.createCommentVNode("",!0),_.value.length>0&&d.value!=="trash"&&!V.value&&!I.value?(e.openBlock(),e.createElementBlock("nav",{key:1,class:"media-library-shell__recent-albums","data-testid":"media-library-recent-albums","aria-label":O.value.recentSection},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.value,fe=>(e.openBlock(),e.createElementBlock("button",{key:fe.id,type:"button",class:"media-library-shell__recent-chip","data-testid":`btn-media-recent-album-${fe.id}`,onClick:Ae=>C(fe.id)},e.toDisplayString(fe.name),9,oL))),128))],8,nL)):e.createCommentVNode("",!0),e.unref(z).uploads.value.length>0&&d.value!=="trash"?(e.openBlock(),e.createElementBlock("div",iL,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(z).uploads.value,fe=>(e.openBlock(),e.createElementBlock("article",{key:fe.cid,class:e.normalizeClass(["media-library-shell__upload-tile",`is-status-${fe.status}`]),"data-testid":`upload-tile-${fe.cid}`},[e.createElementVNode("div",lL,[fe.previewUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:fe.previewUrl,alt:fe.fileName},null,8,sL)):(e.openBlock(),e.createElementBlock("span",dL,"⤴"))]),e.createElementVNode("div",cL,[e.createElementVNode("span",uL,e.toDisplayString(fe.fileName),1),e.createElementVNode("span",mL,[fe.status==="uploading"||fe.status==="queued"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode("Uploading…")],64)):fe.status==="success"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode("Uploaded")],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createTextVNode(e.toDisplayString(fe.errorMessage??"Upload failed"),1)],64))])]),e.createElementVNode("button",{type:"button",class:"media-library-shell__upload-dismiss","data-testid":`btn-upload-dismiss-${fe.cid}`,onClick:Ae=>e.unref(z).dismiss(fe.cid)}," × ",8,pL)],10,rL))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["media-library-shell__body",{"has-inspector-target":m.value!==null}])},[e.createElementVNode("main",fL,[I.value?(e.openBlock(),e.createElementBlock("header",hL,[e.createElementVNode("button",{type:"button",class:"media-library-shell__breadcrumb-back","data-testid":"btn-media-album-back",onClick:U}," ← "+e.toDisplayString(O.value.albums),1),oe[15]||(oe[15]=e.createElementVNode("span",{class:"media-library-shell__breadcrumb-sep","aria-hidden":"true"},"/",-1)),e.createElementVNode("span",vL,e.toDisplayString(x.value),1)])):e.createCommentVNode("",!0),d.value==="trash"?(e.openBlock(),e.createBlock(zf,{key:1,"http-client":l.httpClient,onError:oe[4]||(oe[4]=fe=>s("error",fe))},null,8,["http-client"])):V.value?(e.openBlock(),e.createElementBlock("section",{key:2,class:"media-album-grid","data-testid":"media-album-grid","aria-label":O.value.albums},[e.createElementVNode("header",bL,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":oe[5]||(oe[5]=fe=>g.value=fe),type:"search",class:"media-album-grid__search",placeholder:O.value.findAlbum,"data-testid":"input-media-album-filter","aria-label":O.value.findAlbum},null,8,yL),[[e.vModelText,g.value]])]),e.createElementVNode("div",wL,[e.createElementVNode("button",{type:"button",class:"media-album-grid__new-tile","data-testid":"btn-media-album-new-tile",role:"listitem",onClick:re},[oe[16]||(oe[16]=e.createElementVNode("span",{class:"media-album-grid__new-tile-glyph","aria-hidden":"true"},"+",-1)),e.createElementVNode("span",kL,e.toDisplayString(O.value.newAlbum),1)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.value,fe=>(e.openBlock(),e.createElementBlock("button",{key:fe.id,type:"button",class:"media-album-grid__tile","data-testid":`media-album-tile-${fe.id}`,role:"listitem",onClick:Ae=>C(fe.id)},[e.createElementVNode("div",EL,[S(fe)!==null?(e.openBlock(),e.createElementBlock("img",{key:0,class:"media-album-grid__cover-image",src:S(fe),alt:"",loading:"lazy"},null,8,SL)):(e.openBlock(),e.createElementBlock("span",CL,e.toDisplayString($(fe)),1))]),e.createElementVNode("div",xL,[e.createElementVNode("span",NL,e.toDisplayString(fe.name),1),e.createElementVNode("span",VL,e.toDisplayString(B(fe)),1)])],8,_L))),128))]),T.value.length===0&&g.value!==""?(e.openBlock(),e.createElementBlock("p",TL,e.toDisplayString(O.value.noAlbumMatchesFound),1)):T.value.length===0?(e.openBlock(),e.createElementBlock("p",BL,e.toDisplayString(O.value.noAlbumsYet),1)):e.createCommentVNode("",!0)],8,gL)):(e.openBlock(),e.createBlock(Uf,{key:`workspace-${M.value}`,"http-client":l.httpClient,filters:de.value,"initial-view":K.value,capabilities:l.capabilities,labels:{scopeLabel:le.value},onFiltersChange:rt,onCreatePost:oe[6]||(oe[6]=fe=>s("create-post",fe)),onCreateGallery:oe[7]||(oe[7]=fe=>s("create-gallery",fe)),onAddToAlbum:Dt,onEdit:oe[8]||(oe[8]=fe=>s("edit",fe)),onDeleted:oe[9]||(oe[9]=fe=>s("deleted",fe)),onRestored:oe[10]||(oe[10]=fe=>s("restored",fe)),onRestoreConflict:oe[11]||(oe[11]=fe=>s("restore-conflict",fe)),onError:oe[12]||(oe[12]=fe=>s("error",fe))},{"bulk-actions":e.withCtx(fe=>[e.createVNode(Rd,{"selected-count":fe.selectedCount,"cross-page-count":fe.crossPageCount,scope:ce.value,"source-album":Ne.value,capabilities:l.capabilities,onClear:fe.clearSelection,onBulkMoveToTrash:fe.onBulkDelete,onBulkAddToAlbum:Ae=>{var Ye;return(Ye=fe.onAddToAlbum)==null?void 0:Ye.call(fe)},onBulkMoveBetweenAlbums:Ae=>lt({mediaIds:fe.selectedItemIds,items:fe.selectedItems,source:"bulk"}),onBulkRemoveFromCurrentAlbum:Ae=>void Ct({mediaIds:fe.selectedItemIds,items:fe.selectedItems,source:"bulk"}),onBulkCreatePost:Ae=>{var Ye;return(Ye=fe.onCreatePost)==null?void 0:Ye.call(fe)},onBulkCreateGallery:Ae=>{var Ye;return(Ye=fe.onCreateGallery)==null?void 0:Ye.call(fe)},onInspect:Ae=>fe.crossPageCount>0?Xe(fe.selectedItemIds):m.value={kind:"multi",count:fe.selectedCount,items:fe.selectedItems}},null,8,["selected-count","cross-page-count","scope","source-album","capabilities","onClear","onBulkMoveToTrash","onBulkAddToAlbum","onBulkMoveBetweenAlbums","onBulkRemoveFromCurrentAlbum","onBulkCreatePost","onBulkCreateGallery","onInspect"])]),_:1},8,["http-client","filters","initial-view","capabilities","labels"]))]),e.createVNode(Tf,{open:f.value,"selected-count":((De=p.value)==null?void 0:De.mediaIds.length)??0,onCancel:ht,onConfirm:St,onError:oe[13]||(oe[13]=fe=>s("error",fe))},null,8,["open","selected-count"]),e.createVNode(Af,{class:"media-library-shell__inspector",target:m.value,"http-client":l.httpClient,capabilities:l.capabilities,"in-album-scope":c.value!==null&&c.value!=="unfiled",onSetAsAlbumCover:j},null,8,["target","http-client","capabilities","in-album-scope"])],2),e.createVNode(If,{open:w.value,onClose:oe[14]||(oe[14]=fe=>w.value=!1)},null,8,["open"])],10,eL)}}}),ML=$e(IL,[["__scopeId","data-v-384bd4f9"]]),$L={class:"album-nav-rail__search"},FL={class:"album-nav-rail__sr-only"},DL=["placeholder"],AL={class:"album-nav-rail__primary","aria-label":"Media scopes"},RL={class:"album-nav-rail__count"},LL={class:"album-nav-rail__count"},PL={key:0,class:"album-nav-rail__recent","data-testid":"album-rail-recent","aria-label":"Recent albums"},UL={class:"album-nav-rail__section-label"},OL=["data-testid","onClick"],zL={class:"album-nav-rail__tree"},jL={class:"album-nav-rail__utility"},WL={class:"album-nav-rail__count"},HL=e.defineComponent({__name:"AlbumNavRail",props:{activeAlbumId:{},collapsed:{type:Boolean,default:!1},allowDragDropTarget:{type:Boolean,default:!1},mediaCounts:{default:()=>({})},labels:{default:()=>({})},recentAlbums:{default:()=>[]}},emits:["change-album","create-album","drop-media","open-trash"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(!1),r=e.ref(""),l=e.ref([]),s=e.ref(null),d=e.computed(()=>{var y,w,g,b,R,V;return{allMedia:((y=t.labels)==null?void 0:y.allMedia)??"All media",unfiled:((w=t.labels)==null?void 0:w.unfiled)??"Unfiled",newAlbum:((g=t.labels)==null?void 0:g.newAlbum)??"New album",findAlbum:((b=t.labels)==null?void 0:b.findAlbum)??"Find album...",trash:((R=t.labels)==null?void 0:R.trash)??"Trash",recentSection:((V=t.labels)==null?void 0:V.recentSection)??"Recent"}});function c(y){return typeof y=="number"&&Number.isFinite(y)?String(y):""}function u(y){n("change-album",y.id)}function m(y,w){i.value=!1,n("create-album",w?{name:y,parentId:w}:{name:y})}function p(y){var g;const w=((g=y.dataTransfer)==null?void 0:g.getData("application/x-mediables-media-ids"))??"";if(w.trim()==="")return l.value;try{const b=JSON.parse(w);return Array.isArray(b)?b.filter(R=>typeof R=="string"&&R.trim()!==""):[]}catch{return w.split(",").map(b=>b.trim()).filter(b=>b!=="")}}function f(y,w){t.allowDragDropTarget&&(y.preventDefault(),s.value=w)}function h(){s.value=null}function v(y,w){if(!t.allowDragDropTarget)return;y.preventDefault();const g=p(y);s.value=null,g.length!==0&&n("drop-media",{albumId:w==="all"||w==="unfiled"?null:w,mediaIds:g})}const k=e.computed(()=>({"is-collapsed":t.collapsed}));return(y,w)=>(e.openBlock(),e.createElementBlock("aside",{class:e.normalizeClass(["album-nav-rail",k.value]),"data-testid":"album-rail"},[e.createElementVNode("label",$L,[e.createElementVNode("span",FL,e.toDisplayString(d.value.findAlbum),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":w[0]||(w[0]=g=>r.value=g),type:"search",placeholder:d.value.findAlbum,"data-testid":"input-album-rail-search"},null,8,DL),[[e.vModelText,r.value]])]),e.createElementVNode("nav",AL,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["album-nav-rail__row",{"is-active":t.activeAlbumId===null,"is-drop-target":s.value==="all"}]),"data-testid":"album-rail-row-all",onClick:w[1]||(w[1]=g=>n("change-album",null)),onDragover:w[2]||(w[2]=g=>f(g,"all")),onDragleave:h,onDrop:w[3]||(w[3]=g=>v(g,"all"))},[e.createElementVNode("span",null,e.toDisplayString(d.value.allMedia),1),e.createElementVNode("span",RL,e.toDisplayString(c(t.mediaCounts.all)),1)],34),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["album-nav-rail__row",{"is-active":t.activeAlbumId==="unfiled","is-drop-target":s.value==="unfiled"}]),"data-testid":"album-rail-row-unfiled",onClick:w[4]||(w[4]=g=>n("change-album","unfiled")),onDragover:w[5]||(w[5]=g=>f(g,"unfiled")),onDragleave:h,onDrop:w[6]||(w[6]=g=>v(g,"unfiled"))},[e.createElementVNode("span",null,e.toDisplayString(d.value.unfiled),1),e.createElementVNode("span",LL,e.toDisplayString(c(t.mediaCounts.unfiled)),1)],34)]),t.recentAlbums.length>0?(e.openBlock(),e.createElementBlock("section",PL,[e.createElementVNode("p",UL,e.toDisplayString(d.value.recentSection),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.recentAlbums,g=>(e.openBlock(),e.createElementBlock("button",{key:`recent-${g.id}`,type:"button",class:e.normalizeClass(["album-nav-rail__row album-nav-rail__row--recent",{"is-active":t.activeAlbumId===g.id}]),"data-testid":`album-rail-recent-${g.id}`,onClick:b=>n("change-album",g.id)},[e.createElementVNode("span",null,e.toDisplayString(g.name),1)],10,OL))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",zL,[e.createVNode(Tl,{"model-value":t.activeAlbumId==="unfiled"?null:t.activeAlbumId,mode:"rail",compact:!0,draggable:!1,onAlbumSelected:u},null,8,["model-value"])]),e.createElementVNode("button",{type:"button",class:"album-nav-rail__new","data-testid":"btn-album-rail-new",onClick:w[7]||(w[7]=g=>i.value=!0)}," + "+e.toDisplayString(d.value.newAlbum),1),e.createVNode(Id,{open:i.value,onCancel:w[8]||(w[8]=g=>i.value=!1),onCreate:m},null,8,["open"]),e.createElementVNode("div",jL,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["album-nav-rail__row album-nav-rail__row--utility",{"is-drop-target":s.value==="trash"}]),"data-testid":"album-rail-row-trash",onClick:w[9]||(w[9]=g=>n("open-trash")),onDragover:w[10]||(w[10]=g=>f(g,"trash")),onDragleave:h,onDrop:w[11]||(w[11]=g=>v(g,"trash"))},[e.createElementVNode("span",null,e.toDisplayString(d.value.trash),1),e.createElementVNode("span",WL,e.toDisplayString(c(t.mediaCounts.trash)),1)],34)])],2))}}),ZL=$e(HL,[["__scopeId","data-v-0913c5b6"]]),GL={key:0,class:"media-selection-tray","data-testid":"media-selection-tray"},XL={class:"media-selection-tray__header"},KL={class:"media-selection-tray__title"},JL={class:"media-selection-tray__items"},qL={class:"media-selection-tray__item-preview"},YL=["src","alt"],QL={key:1,class:"media-selection-tray__file-icon"},eP={class:"media-selection-tray__item-copy"},tP=["aria-label","onClick"],aP=e.defineComponent({__name:"MediaSelectionTray",props:{items:{},selectedCountLabel:{default:"Selected items"},dismissLabel:{default:"Remove"}},emits:["remove"],setup(o,{emit:a}){const t=a;function n(r){var l;return r?r.thumbnail_url??((l=r.conversion_urls)==null?void 0:l.thumb)??r.preview_url??r.original_url??r.url??null:null}function i(r){return r!=null&&r.mime_type?r.mime_type.startsWith("image/"):!1}return(r,l)=>r.items.length>0?(e.openBlock(),e.createElementBlock("section",GL,[e.createElementVNode("header",XL,[e.createElementVNode("h3",KL,e.toDisplayString(r.selectedCountLabel),1)]),e.createElementVNode("div",JL,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,s=>{var d,c,u,m;return e.openBlock(),e.createElementBlock("article",{key:s.id,class:"media-selection-tray__item"},[e.createElementVNode("div",qL,[i(s.media)&&n(s.media)?(e.openBlock(),e.createElementBlock("img",{key:0,src:n(s.media),alt:((d=s.media)==null?void 0:d.alt_text)??((c=s.media)==null?void 0:c.file_name)??"Selected media",class:"media-selection-tray__thumb"},null,8,YL)):(e.openBlock(),e.createElementBlock("div",QL,[...l[0]||(l[0]=[e.createElementVNode("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[e.createElementVNode("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.createElementVNode("polyline",{points:"14 2 14 8 20 8"})],-1)])]))]),e.createElementVNode("div",eP,[e.createElementVNode("strong",null,e.toDisplayString(((u=s.media)==null?void 0:u.file_name)??s.id),1),e.createElementVNode("span",null,e.toDisplayString(s.status),1)]),e.createElementVNode("button",{type:"button",class:"media-selection-tray__remove","aria-label":`${r.dismissLabel} ${((m=s.media)==null?void 0:m.file_name)??s.id}`,onClick:p=>t("remove",s.id)},e.toDisplayString(r.dismissLabel),9,tP)])}),128))])])):e.createCommentVNode("",!0)}}),nP=$e(aP,[["__scopeId","data-v-f2a3d69d"]]);function Ud(o={}){const a=e.ref(!1),t=e.ref(!1),n=e.ref(null),i=e.ref(null),r=e.ref(0),l=e.ref(0),s=e.ref(null),d=e.ref(null),c=e.computed(()=>d.value!==null),u=w=>{if(r.value++,d.value=null,i.value=null,t.value=!1,w!=null&&typeof w=="object"&&!(w instanceof Blob)&&("image"in w||"state"in w||"sessionKey"in w)){const g=w;n.value=g.image??null,s.value=g.state??null,l.value=g.sessionKey??r.value}else n.value=w??null,s.value=null,l.value=r.value;a.value=!0},m=()=>{a.value=!1,n.value=null,i.value=null,d.value=null,t.value=!1,s.value=null},p=async w=>{try{return t.value=!0,i.value=w,o.onSave&&await o.onSave(w),m(),w}catch(g){const b=g;throw d.value=b,o.onError&&o.onError(b),b}finally{t.value=!1}},f=()=>{o.onCancel&&o.onCancel(),m()},h=w=>{d.value=w,o.onError&&o.onError(w)},v=()=>{d.value=null},k=()=>i.value,y=e.computed(()=>a.value&&i.value!==null&&!t.value);return{isOpen:a,isProcessing:t,uploadedImage:n,editedImage:i,sessionKey:l,initialState:s,error:d,hasError:c,hasUnsavedChanges:y,open:u,close:m,handleSave:p,handleCancel:f,handleError:h,clearError:v,getEditedImage:k}}let ds=null;function oP(o){return ds||(ds=Ud(o)),ds}function iP(o){return a=>new Promise((t,n)=>{Ud({...o,onSave:async r=>{o!=null&&o.onSave&&await o.onSave(r),t(r)},onError:r=>{o!=null&&o.onError&&o.onError(r),n(r)},onCancel:()=>{o!=null&&o.onCancel&&o.onCancel(),n(new Error("User cancelled"))}}).open(a)})}function Od(o){return o.filter(a=>a.media&&!a.markedForRemoval).map((a,t)=>{const n={uuid:a.media.uuid,name:a.name,order:t};return a.customProperties&&(n.custom_properties=a.customProperties),n})}function Ys(o){return o.map((a,t)=>{const n={media:a,clientId:a.uuid,name:a.name||a.file_name,order:t};return a.custom_properties&&(n.customProperties=a.custom_properties),n})}function zd(o){if(o){const t={};o.apiBaseUrl!==void 0&&(t.apiBaseUrl=o.apiBaseUrl),o.isAdmin!==void 0&&(t.isAdmin=o.isAdmin),$o(t)}return{name:"mediables",async upload(t,n){const r=await xa().uploadFile(t,{collection:(n==null?void 0:n.collection)||"default",customProperties:n==null?void 0:n.customProperties});if(!r)throw new Error("Upload failed: No media returned");return{media:r,uuid:r.uuid}},async attach(t,n){await xa().attachMedia(n.modelType,String(n.modelId),[t],n.collection||"images")},async attachMany(t,n){await xa().attachMedia(n.modelType,String(n.modelId),t,n.collection||"images")},async detach(t,n){await xa().detachMedia(n.modelType,String(n.modelId),t,n.collection||"images")},async reorder(t,n){await xa().reorderMedia(t.modelType,String(t.modelId),n,t.collection||"images")},async fetchModelMedia(t){return await xa().fetchModelMedia(t.modelType,String(t.modelId),t.collection||"images")},getUrl(t,n){return xa().getMediaUrl(t,n)},getThumbnailUrl(t){var n,i;return(n=t.conversion_urls)!=null&&n.thumb?t.conversion_urls.thumb:(i=t.conversion_urls)!=null&&i.thumbnail?t.conversion_urls.thumbnail:t.thumbnail_url?t.thumbnail_url:t.original_url||t.url||""},async delete(t){await xa().deleteMedia(t)},async update(t,n){const r=await xa().updateMedia(t,n);if(!r)throw new Error("Update failed: No media returned");return r},configure(t){const n={};t.apiBaseUrl!==void 0&&(n.apiBaseUrl=t.apiBaseUrl),t.isAdmin!==void 0&&(n.isAdmin=t.isAdmin),$o(n)}}}let Mr=null;function rP(){return Mr||(Mr=zd()),Mr}function lP(){Mr=null}const sP={apiBaseUrl:"/media-library-pro"};function wr(){var o;return typeof document>"u"?null:((o=document.querySelector('meta[name="csrf-token"]'))==null?void 0:o.getAttribute("content"))||null}function cs(o){const a={uuid:o.uuid,file_name:o.fileName||o.name,mime_type:`application/${o.extension}`,size:o.size,disk:"public",original_url:o.original_url||"",created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return o.name&&(a.name=o.name),o.original_url&&(a.url=o.original_url),o.preview_url&&(a.thumbnail_url=o.preview_url,a.preview_url=o.preview_url),o.custom_properties&&(a.custom_properties=o.custom_properties),a}function jd(o){const a={...sP,...o};return{name:"spatie",async upload(n,i){const r=new FormData;r.append("file",n),i!=null&&i.collection&&r.append("collection",i.collection),i!=null&&i.customProperties&&r.append("custom_properties",JSON.stringify(i.customProperties));const l={Accept:"application/json",...a.headers},s=a.csrfToken||wr();s&&(l["X-CSRF-TOKEN"]=s);const d={method:"POST",headers:l,body:r,credentials:"include"};i!=null&&i.signal&&(d.signal=i.signal);const c=await fetch(`${a.apiBaseUrl}/uploads`,d);if(!c.ok){const p=await c.json().catch(()=>({message:"Upload failed"}));throw new Error(p.message||`HTTP ${c.status}`)}const u=await c.json(),m=cs(u);return i!=null&&i.onProgress&&i.onProgress(100),{media:m,uuid:u.uuid}},async attach(n,i){},async attachMany(n,i){},async detach(n,i){},async reorder(n,i){},async fetchModelMedia(n){const i={Accept:"application/json",...a.headers},r=a.csrfToken||wr();r&&(i["X-CSRF-TOKEN"]=r);const l=new URLSearchParams;l.append("model_type",n.modelType),l.append("model_id",String(n.modelId)),n.collection&&l.append("collection",n.collection);try{const s=await fetch(`${a.apiBaseUrl}/media?${l}`,{method:"GET",headers:i,credentials:"include"});if(!s.ok)throw new Error(`HTTP ${s.status}`);return(await s.json()).map(cs)}catch{return[]}},getUrl(n,i){var r;if(i){const l=(r=n.conversion_urls)==null?void 0:r[i];if(l)return l}return n.original_url||n.url||""},getThumbnailUrl(n){var i,r;return n.preview_url?n.preview_url:(i=n.conversion_urls)!=null&&i.preview?n.conversion_urls.preview:n.thumbnail_url?n.thumbnail_url:(r=n.conversion_urls)!=null&&r.thumb?n.conversion_urls.thumb:n.original_url||n.url||""},async delete(n){const i={Accept:"application/json",...a.headers},r=a.csrfToken||wr();r&&(i["X-CSRF-TOKEN"]=r);const l=await fetch(`${a.apiBaseUrl}/uploads/${n}`,{method:"DELETE",headers:i,credentials:"include"});if(!l.ok){const s=await l.json().catch(()=>({message:"Delete failed"}));throw new Error(s.message||`HTTP ${l.status}`)}},async update(n,i){const r={Accept:"application/json","Content-Type":"application/json",...a.headers},l=a.csrfToken||wr();l&&(r["X-CSRF-TOKEN"]=l);const s=await fetch(`${a.apiBaseUrl}/uploads/${n}`,{method:"PATCH",headers:r,body:JSON.stringify(i),credentials:"include"});if(!s.ok){const c=await s.json().catch(()=>({message:"Update failed"}));throw new Error(c.message||`HTTP ${s.status}`)}const d=await s.json();return cs(d)},configure(n){Object.assign(a,n)}}}let $r=null;function dP(){return $r||($r=jd()),$r}function cP(){$r=null}function jf(o,a){switch(o){case"mediables":return zd(a);case"spatie":return jd(a);default:throw new Error(`Unknown adapter: ${o}`)}}function Wf(o={}){const{enabled:a=!0,onReorder:t,onDragStart:n,onDragEnd:i,draggingClass:r="is-dragging",dropTargetClass:l="is-drop-target"}=o,s=e.ref({isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null}),d=e.ref(!1);let c=null;function u(w,g,b){a&&("dataTransfer"in w&&w.dataTransfer&&(w.dataTransfer.effectAllowed="move",w.dataTransfer.setData("text/plain",String(b))),c=w.target,c&&c.classList.add(r),s.value={isDragging:!0,dragIndex:b,dropIndex:b,draggedItem:g},d.value=!0,n==null||n(g,b))}function m(w,g){var b;if(!(!a||!s.value.isDragging)&&(w.preventDefault(),s.value.dropIndex!==g)){const R=document.querySelector(`.${l}`);R==null||R.classList.remove(l);const V=(b=w.target)==null?void 0:b.closest("[data-index]");V==null||V.classList.add(l),s.value.dropIndex=g}}function p(){if(!s.value.isDragging)return;const{dragIndex:w,dropIndex:g,draggedItem:b}=s.value;c&&c.classList.remove(r);const R=document.querySelector(`.${l}`);R==null||R.classList.remove(l),w!==null&&g!==null&&w!==g&&b&&(t==null||t({fromIndex:w,toIndex:g,item:b})),h(),i==null||i()}function f(){c&&c.classList.remove(r);const w=document.querySelector(`.${l}`);w==null||w.classList.remove(l),h(),i==null||i()}function h(){s.value={isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null},d.value=!1,c=null}function v(w,g,b){const R=[...w],[V]=R.splice(g,1);return R.splice(b,0,V),R.map((I,x)=>({...I,order:x}))}function k(w,g){return{draggable:a,"data-index":g,onDragstart:b=>u(b,w,g),onDragover:b=>m(b,g),onDragend:()=>p(),onDrop:b=>{b.preventDefault(),p()}}}function y(w){w.key==="Escape"&&s.value.isDragging&&f()}return e.onMounted(()=>{document.addEventListener("keydown",y)}),e.onUnmounted(()=>{document.removeEventListener("keydown",y),f()}),{dragState:s,isDragging:d,startDrag:u,handleDragOver:m,endDrag:p,cancelDrag:f,reorderItems:v,getDragProps:k}}function Bl(o={}){const{initialItems:a=[],modelType:t,modelId:n,collection:i="images",maxItems:r,maxFileSize:l,acceptedMimeTypes:s,sortable:d=!0,disabled:c=!1,rules:u={},adapterType:m="mediables",adapter:p,maxConcurrentUploads:f=3,onChange:h,onUpload:v,onUploadComplete:k,onUploadError:y,onRemove:w,onReorder:g,onError:b,onReadyToSubmitChange:R}=o,V={maxItems:r,maxFileSize:l,acceptedMimeTypes:s,...u},I=p||jf(m),x=e.ref([]),T=e.ref(!1),$=e.ref([]);function S(ye){if(ye.length===0)return[];const xe=ye[0];return"media"in xe&&"clientId"in xe?ye:Ys(ye)}x.value=S(a);const{acceptString:B,canAddFiles:_}=Fd({rules:V}),A=Dd({adapter:I,maxConcurrent:f,rules:V,collection:i,onUploadStart:ye=>{v==null||v(ye)},onUploadComplete:(ye,xe)=>{const Ce=x.value.findIndex(Re=>Re.clientId===ye.id);Ce!==-1&&(x.value[Ce]={...x.value[Ce],media:xe,name:xe.name||xe.file_name,upload:{...ye,status:"completed"}}),k==null||k(xe)},onUploadError:(ye,xe)=>{const Ce=x.value.findIndex(Re=>Re.clientId===ye.id);Ce!==-1&&(x.value[Ce]={...x.value[Ce],upload:{...ye,status:"error",error:xe.message},errors:[{field:"upload",message:xe.message,code:"UPLOAD_ERROR"}]}),y==null||y({file:ye.file,message:xe.message})},onQueueComplete:()=>{h==null||h(x.value)}}),{dragState:P,getDragProps:D,reorderItems:z}=Wf({enabled:d&&!c,onReorder:ye=>{x.value=z(x.value,ye.fromIndex,ye.toIndex),g==null||g(x.value),h==null||h(x.value)}}),M=e.computed(()=>A.isUploading.value),Z=e.computed(()=>!A.isUploading.value&&A.pendingCount.value===0),O=e.computed(()=>r?x.value.length>=r:!1),K=e.computed(()=>Od(x.value)),de=e.computed(()=>x.value.length),Ne=e.computed(()=>r?Math.max(0,r-x.value.length):1/0);e.watch(Z,ye=>{R==null||R(ye)});function ce(ye){x.value=S(ye),h==null||h(x.value)}async function le(ye){if(c)return;const xe=Array.from(ye);if(!_(xe.length,x.value.length)){const rt={field:"count",message:`Maximum ${r} files allowed`,code:"MAX_ITEMS"};$.value=[rt],b==null||b([rt]);return}const Ce=await A.addFiles(xe),Re=x.value.length,ze=Ce.map((rt,at)=>({...rt,order:Re+at}));x.value=[...x.value,...ze],h==null||h(x.value)}function W(ye){c||(ye.upload&&(ye.upload.status==="uploading"||ye.upload.status==="pending")&&A.cancelUpload(ye.clientId),x.value=x.value.filter(xe=>xe.clientId!==ye.clientId),x.value=x.value.map((xe,Ce)=>({...xe,order:Ce})),w==null||w(ye),h==null||h(x.value))}function C(ye){const xe=x.value.find(Ce=>Ce.clientId===ye);xe&&W(xe)}function U(){c||(A.clearAll(),x.value=[],h==null||h(x.value))}function j(ye,xe){c||!d||(x.value=z(x.value,ye,xe),g==null||g(x.value),h==null||h(x.value))}function re(ye,xe){if(c)return;const Ce=x.value.findIndex(Re=>Re.clientId===ye);Ce!==-1&&(x.value[Ce]={...x.value[Ce],...xe},h==null||h(x.value))}function ue(ye){A.cancelUpload(ye),C(ye)}async function Xe(ye){await A.retryUpload(ye)}async function be(){if(!t||!n)throw new Error("modelType and modelId are required for save()");const ye={modelType:t,modelId:n,collection:i},xe=x.value.filter(Ce=>Ce.media&&!Ce.markedForRemoval).map(Ce=>Ce.media.uuid);T.value=!0;try{await I.attachMany(xe,ye),await I.reorder(ye,xe)}finally{T.value=!1}}async function Ee(){if(!t||!n)throw new Error("modelType and modelId are required for load()");const ye={modelType:t,modelId:n,collection:i};T.value=!0;try{const xe=await I.fetchModelMedia(ye);x.value=Ys(xe),h==null||h(x.value)}finally{T.value=!1}}return e.onMounted(()=>{t&&n&&a.length===0&&Ee().catch(console.error)}),e.onUnmounted(()=>{A.clearAll()}),{items:x,setItems:ce,addFiles:le,removeItem:W,removeItemById:C,clearAll:U,reorderItems:j,updateItem:re,cancelUpload:ue,retryUpload:Xe,save:be,load:Ee,isLoading:T,isUploading:M,isReadyToSubmit:Z,isAtMaxItems:O,errors:$,dragState:P,getDragProps:D,adapter:I,formValues:K,acceptString:B,count:de,remainingSlots:Ne}}const uP=["aria-disabled"],mP=["accept","multiple","disabled"],pP={class:"media-dropzone__content"},fP={class:"media-dropzone__title"},hP={class:"media-dropzone__subtitle"},vP=["disabled"],gP={key:0,class:"media-dropzone__helper"},bP=e.defineComponent({__name:"MediaCollectionDropzone",props:{accept:{default:"*"},multiple:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},maxFileSize:{},maxItems:{},title:{default:"Drop files here"},subtitle:{default:"or click to browse"},buttonText:{default:"Select files"}},emits:["files"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(!1),r=e.ref(null),l=e.computed(()=>({"media-dropzone":!0,"media-dropzone--drag-over":i.value,"media-dropzone--disabled":t.disabled})),s=e.computed(()=>{const v=[];return t.maxFileSize&&v.push(`Max size: ${Yr(t.maxFileSize)}`),t.maxItems&&t.maxItems>1&&v.push(`Max files: ${t.maxItems}`),v.join(" • ")});function d(v){v.preventDefault(),!t.disabled&&(i.value=!0)}function c(v){v.preventDefault(),i.value=!1}function u(v){v.preventDefault()}function m(v){var y;if(v.preventDefault(),i.value=!1,t.disabled)return;const k=(y=v.dataTransfer)==null?void 0:y.files;k&&k.length>0&&n("files",k)}function p(){var v;t.disabled||(v=r.value)==null||v.click()}function f(v){const k=v.target,y=k.files;y&&y.length>0&&n("files",y),k.value=""}function h(v){(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),p())}return(v,k)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(l.value),role:"button",tabindex:"0","aria-disabled":v.disabled,"aria-label":"Upload files",onClick:p,onKeydown:h,onDragenter:d,onDragleave:c,onDragover:u,onDrop:m},[e.createElementVNode("input",{ref_key:"fileInput",ref:r,type:"file",accept:v.accept,multiple:v.multiple,disabled:v.disabled,class:"media-dropzone__input",onChange:f},null,40,mP),e.createElementVNode("div",pP,[e.renderSlot(v.$slots,"icon",{},()=>[k[0]||(k[0]=e.createElementVNode("svg",{class:"media-dropzone__icon",xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.createElementVNode("polyline",{points:"17 8 12 3 7 8"}),e.createElementVNode("line",{x1:"12",y1:"3",x2:"12",y2:"15"})],-1))],!0),e.createElementVNode("p",fP,[e.renderSlot(v.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(v.title),1)],!0)]),e.createElementVNode("p",hP,[e.renderSlot(v.$slots,"subtitle",{},()=>[e.createTextVNode(e.toDisplayString(v.subtitle),1)],!0)]),e.createElementVNode("button",{type:"button",class:"media-dropzone__button",disabled:v.disabled,onClick:e.withModifiers(p,["stop"])},[e.renderSlot(v.$slots,"button",{},()=>[e.createTextVNode(e.toDisplayString(v.buttonText),1)],!0)],8,vP),s.value?(e.openBlock(),e.createElementBlock("p",gP,e.toDisplayString(s.value),1)):e.createCommentVNode("",!0)])],42,uP))}}),Wd=$e(bP,[["__scopeId","data-v-b1366c1e"]]),yP=["data-index"],wP={key:0,class:"media-item__drag-handle","aria-label":"Drag to reorder",role:"button",tabindex:"0"},kP={class:"media-item__thumbnail"},_P=["src","alt"],EP={key:1,class:"media-item__file-icon"},SP={key:2,class:"media-item__progress-overlay"},CP={class:"media-item__progress-text"},xP={key:3,class:"media-item__processing-overlay"},NP={key:4,class:"media-item__error-overlay"},VP={class:"media-item__info"},TP=["title"],BP={key:0,class:"media-item__size"},IP={key:1,class:"media-item__error-message"},MP={class:"media-item__actions"},$P=["disabled"],FP=["disabled"],DP=["disabled"],AP=["disabled"],RP=e.defineComponent({__name:"MediaCollectionItem",props:{item:{},adapter:{},disabled:{type:Boolean,default:!1},sortable:{type:Boolean,default:!1},showRemove:{type:Boolean,default:!0},showEdit:{type:Boolean,default:!1},index:{default:0}},emits:["remove","edit","retry","cancel"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(!1),r=e.computed(()=>{var g;return(g=t.item.upload)!=null&&g.previewUrl?t.item.upload.previewUrl:t.item.media?t.adapter.getThumbnailUrl(t.item.media):null}),l=e.computed(()=>{var g,b,R;return((g=t.item.upload)==null?void 0:g.status)==="uploading"||((b=t.item.upload)==null?void 0:b.status)==="pending"||((R=t.item.upload)==null?void 0:R.status)==="queued"}),s=e.computed(()=>{var g;return((g=t.item.upload)==null?void 0:g.status)==="processing"}),d=e.computed(()=>{var g;return((g=t.item.upload)==null?void 0:g.status)==="error"||t.item.errors&&t.item.errors.length>0}),c=e.computed(()=>{var g;return(g=t.item.upload)!=null&&g.error?t.item.upload.error:t.item.errors&&t.item.errors.length>0?t.item.errors[0].message:null}),u=e.computed(()=>{var g;return((g=t.item.upload)==null?void 0:g.progress)||0}),m=e.computed(()=>{var g;return t.item.name||((g=t.item.media)==null?void 0:g.file_name)||"Unknown file"}),p=e.computed(()=>{var I,x;const g=((I=t.item.media)==null?void 0:I.size)||((x=t.item.upload)==null?void 0:x.file.size);if(!g)return"";const b=1024,R=["Bytes","KB","MB","GB"],V=Math.floor(Math.log(g)/Math.log(b));return parseFloat((g/Math.pow(b,V)).toFixed(2))+" "+R[V]}),f=e.computed(()=>{var b,R;const g=((b=t.item.media)==null?void 0:b.mime_type)||((R=t.item.upload)==null?void 0:R.file.type);return g==null?void 0:g.startsWith("image/")}),h=e.computed(()=>({"media-item":!0,"media-item--uploading":l.value,"media-item--processing":s.value,"media-item--error":d.value,"media-item--disabled":t.disabled,"media-item--sortable":t.sortable}));function v(){t.disabled||n("remove",t.item)}function k(){t.disabled||n("edit",t.item)}function y(){t.disabled||n("retry",t.item)}function w(){t.disabled||n("cancel",t.item)}return(g,b)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(h.value),"data-index":g.index,onMouseenter:b[0]||(b[0]=R=>i.value=!0),onMouseleave:b[1]||(b[1]=R=>i.value=!1)},[g.sortable&&!g.disabled?(e.openBlock(),e.createElementBlock("div",wP,[...b[2]||(b[2]=[e.createStaticVNode('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-v-ff81c9ec><circle cx="9" cy="5" r="1" data-v-ff81c9ec></circle><circle cx="9" cy="12" r="1" data-v-ff81c9ec></circle><circle cx="9" cy="19" r="1" data-v-ff81c9ec></circle><circle cx="15" cy="5" r="1" data-v-ff81c9ec></circle><circle cx="15" cy="12" r="1" data-v-ff81c9ec></circle><circle cx="15" cy="19" r="1" data-v-ff81c9ec></circle></svg>',1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",kP,[r.value&&f.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.value,alt:m.value,class:"media-item__image"},null,8,_P)):(e.openBlock(),e.createElementBlock("div",EP,[...b[3]||(b[3]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.createElementVNode("polyline",{points:"14 2 14 8 20 8"})],-1)])])),l.value?(e.openBlock(),e.createElementBlock("div",SP,[e.createElementVNode("div",{class:"media-item__progress-bar",style:e.normalizeStyle({width:`${u.value}%`})},null,4),e.createElementVNode("span",CP,e.toDisplayString(u.value)+"%",1)])):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("div",xP,[...b[4]||(b[4]=[e.createElementVNode("div",{class:"media-item__spinner","aria-label":"Processing"},null,-1)])])):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("div",NP,[...b[5]||(b[5]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("circle",{cx:"12",cy:"12",r:"10"}),e.createElementVNode("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.createElementVNode("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})],-1)])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",VP,[e.createElementVNode("span",{class:"media-item__name",title:m.value},e.toDisplayString(m.value),9,TP),p.value?(e.openBlock(),e.createElementBlock("span",BP,e.toDisplayString(p.value),1)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("span",IP,e.toDisplayString(c.value),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",MP,[l.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-item__action media-item__action--cancel",disabled:g.disabled,"aria-label":"Cancel upload",onClick:w},[...b[6]||(b[6]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])],8,$P)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"media-item__action media-item__action--retry",disabled:g.disabled,"aria-label":"Retry upload",onClick:y},[...b[7]||(b[7]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("polyline",{points:"23 4 23 10 17 10"}),e.createElementVNode("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})],-1)])],8,FP)):e.createCommentVNode("",!0),g.showEdit&&g.item.media&&!l.value?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"media-item__action media-item__action--edit",disabled:g.disabled,"aria-label":"Edit",onClick:k},[...b[8]||(b[8]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.createElementVNode("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})],-1)])],8,DP)):e.createCommentVNode("",!0),g.showRemove?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"media-item__action media-item__action--remove",disabled:g.disabled,"aria-label":"Remove",onClick:v},[...b[9]||(b[9]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("polyline",{points:"3 6 5 6 21 6"}),e.createElementVNode("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)])],8,AP)):e.createCommentVNode("",!0)])],42,yP))}}),Hd=$e(RP,[["__scopeId","data-v-ff81c9ec"]]),LP=["aria-label"],PP=["draggable","data-index","onDragstart","onDragover","onDragend","onDrop"],UP={key:0,class:"media-collection__footer"},OP={class:"media-collection__count"},zP={key:0},jP={key:0,class:"media-collection__uploading"},WP=["name","value"],HP=["name","value"],ZP=["name","value"],GP=["name","value"],XP={key:3,class:"media-collection__errors",role:"alert","aria-live":"polite"},KP=e.defineComponent({__name:"MediaCollection",props:{modelValue:{default:()=>[]},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxItems:{},maxFileSize:{},acceptedMimeTypes:{},sortable:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","reorder","is-ready-to-submit-change","validation-error"],setup(o,{emit:a}){const t=o,n=a,i={initialItems:t.modelValue,modelType:t.modelType,modelId:t.modelId,collection:t.collection,maxItems:t.maxItems,maxFileSize:t.maxFileSize,acceptedMimeTypes:t.acceptedMimeTypes,sortable:t.sortable,disabled:t.disabled,rules:t.rules,adapterType:t.adapter,onChange:M=>{n("update:modelValue",M),n("change",M)},onUpload:M=>{n("upload",M)},onUploadComplete:M=>{n("upload-complete",M)},onUploadError:M=>{n("upload-error",M)},onRemove:M=>{n("remove",M)},onReorder:M=>{n("reorder",M)},onError:M=>{n("validation-error",M)},onReadyToSubmitChange:M=>{n("is-ready-to-submit-change",M)}},{items:r,setItems:l,addFiles:s,removeItem:d,reorderItems:c,cancelUpload:u,retryUpload:m,isLoading:p,isUploading:f,isAtMaxItems:h,errors:v,dragState:k,getDragProps:y,adapter:w,formValues:g,acceptString:b,count:R,remainingSlots:V}=Bl(i);e.provide("mediaAdapter",w),e.provide("mediaCollection",{items:r,addFiles:s,removeItem:d,reorderItems:c}),e.watch(()=>t.modelValue,M=>{M!==r.value&&l(M)},{deep:!0});const I=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!h.value),x=e.computed(()=>({"media-collection":!0,"media-collection--disabled":t.disabled,"media-collection--readonly":t.readonly,"media-collection--loading":p.value,"media-collection--has-items":r.value.length>0,"media-collection--dragging":k.value.isDragging}));function T(M){s(M)}function $(M){d(M)}function S(M){m(M.clientId)}function B(M){u(M.clientId)}function _(M){}function A(M,Z,O){if(!t.sortable||t.disabled)return;const K=y(Z,O);K.onDragstart&&K.onDragstart(M)}function P(M,Z){if(!t.sortable||t.disabled)return;M.preventDefault();const O=r.value[Z],K=y(O,Z);K.onDragover&&K.onDragover(M)}function D(M,Z){const O=y(M,Z);O.onDragend&&O.onDragend()}function z(M,Z){M.preventDefault();const O=r.value[Z],K=y(O,Z);K.onDrop&&K.onDrop(M)}return(M,Z)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(x.value)},[e.renderSlot(M.$slots,"dropzone",{addFiles:e.unref(s)},()=>[I.value?(e.openBlock(),e.createBlock(Wd,{key:0,accept:e.unref(b),multiple:M.maxItems!==1,disabled:M.disabled,"max-file-size":M.maxFileSize,"max-items":e.unref(V),onFiles:T},null,8,["accept","multiple","disabled","max-file-size","max-items"])):e.createCommentVNode("",!0)],!0),e.unref(r).length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"media-collection__list",role:"list","aria-label":`${e.unref(R)} media items`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r),(O,K)=>e.renderSlot(M.$slots,"item",{key:O.clientId,item:O,index:K,remove:()=>$(O)},()=>[e.createElementVNode("div",{class:e.normalizeClass(["media-collection__item-wrapper",{"media-collection__item-wrapper--drag-over":e.unref(k).dropIndex===K}]),draggable:M.sortable&&!M.disabled,"data-index":K,onDragstart:de=>A(de,O,K),onDragover:de=>P(de,K),onDragend:de=>D(O,K),onDrop:de=>z(de,K)},[e.createVNode(Hd,{item:O,adapter:e.unref(w),disabled:M.disabled,sortable:M.sortable,"show-remove":!M.readonly,"show-edit":!1,index:K,onRemove:$,onRetry:S,onCancel:B,onEdit:_},null,8,["item","adapter","disabled","sortable","show-remove","index"])],42,PP)],!0)),128))],8,LP)):I.value?e.createCommentVNode("",!0):e.renderSlot(M.$slots,"empty",{key:1},()=>[Z[0]||(Z[0]=e.createElementVNode("div",{class:"media-collection__empty"},[e.createElementVNode("p",null,"No files uploaded")],-1))],!0),e.renderSlot(M.$slots,"footer",{count:e.unref(R),isUploading:e.unref(f)},()=>[e.unref(r).length>0?(e.openBlock(),e.createElementBlock("div",UP,[e.createElementVNode("span",OP,[e.createTextVNode(e.toDisplayString(e.unref(R))+" "+e.toDisplayString(e.unref(R)===1?"file":"files")+" ",1),M.maxItems?(e.openBlock(),e.createElementBlock("span",zP," / "+e.toDisplayString(M.maxItems)+" max",1)):e.createCommentVNode("",!0)]),e.unref(f)?(e.openBlock(),e.createElementBlock("span",jP," Uploading... ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],!0),M.generateFormFields?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),(O,K)=>(e.openBlock(),e.createElementBlock("input",{key:`${M.name}-${O.uuid}`,type:"hidden",name:`${M.name}[${K}][uuid]`,value:O.uuid},null,8,WP))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),(O,K)=>(e.openBlock(),e.createElementBlock("input",{key:`${M.name}-${O.uuid}-name`,type:"hidden",name:`${M.name}[${K}][name]`,value:O.name},null,8,HP))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),(O,K)=>(e.openBlock(),e.createElementBlock("input",{key:`${M.name}-${O.uuid}-order`,type:"hidden",name:`${M.name}[${K}][order]`,value:O.order},null,8,ZP))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),(O,K)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${M.name}-${O.uuid}-props`},[O.custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${M.name}[${K}][custom_properties]`,value:JSON.stringify(O.custom_properties)},null,8,GP)):e.createCommentVNode("",!0)],64))),128))],64)):e.createCommentVNode("",!0),e.unref(v).length>0?(e.openBlock(),e.createElementBlock("div",XP,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(v),O=>(e.openBlock(),e.createElementBlock("p",{key:O.code||O.message,class:"media-collection__error"},e.toDisplayString(O.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),JP=$e(KP,[["__scopeId","data-v-10a5bfff"]]);function Zd(o={}){const{initialItem:a,onChange:t,onReplace:n,onUpload:i,onUploadComplete:r,onUploadError:l,onRemove:s,onError:d,onReadyToSubmitChange:c,...u}=o,p={...u,initialItems:a?[a]:[],maxItems:1,sortable:!1,onChange:I=>{t==null||t(I[0]||null)},onUpload:i,onUploadComplete:r,onUploadError:l,onRemove:s,onError:d,onReadyToSubmitChange:c},f=Bl(p),h=e.computed(()=>f.items.value[0]||null),v=e.computed(()=>h.value!==null),k=e.computed(()=>f.formValues.value[0]||null);function y(I){I===null?f.clearAll():f.setItems([I])}async function w(I){const x=h.value;x&&f.removeItem(x),await f.addFiles([I])}function g(){h.value&&f.removeItem(h.value)}async function b(I){const x=h.value;x&&f.removeItem(x),await f.addFiles([I]);const T=f.items.value[0];T&&(n==null||n(x,T))}function R(){var I;(I=h.value)!=null&&I.upload&&f.cancelUpload(h.value.clientId)}async function V(){var I,x;((x=(I=h.value)==null?void 0:I.upload)==null?void 0:x.status)==="error"&&await f.retryUpload(h.value.clientId)}return{item:h,setItem:y,addFile:w,removeItem:g,replaceItem:b,cancelUpload:R,retryUpload:V,save:f.save,load:f.load,isLoading:f.isLoading,isUploading:f.isUploading,isReadyToSubmit:f.isReadyToSubmit,hasItem:v,errors:f.errors,adapter:f.adapter,formValue:k,acceptString:f.acceptString}}const qP=["accept","disabled"],YP={class:"media-attachment__preview"},QP=["name","value"],eU=["name","value"],tU=["name","value"],aU=["name","value"],nU={key:4,class:"media-attachment__errors",role:"alert","aria-live":"polite"},oU=e.defineComponent({__name:"MediaAttachment",props:{modelValue:{default:null},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxFileSize:{},acceptedMimeTypes:{},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0},showReplaceButton:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","replace","is-ready-to-submit-change","validation-error"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(null),r={initialItem:t.modelValue,modelType:t.modelType,modelId:t.modelId,collection:t.collection,maxFileSize:t.maxFileSize,acceptedMimeTypes:t.acceptedMimeTypes,disabled:t.disabled,rules:t.rules,adapterType:t.adapter,onChange:S=>{n("update:modelValue",S),n("change",S)},onUpload:S=>{n("upload",S)},onUploadComplete:S=>{n("upload-complete",S)},onUploadError:S=>{n("upload-error",S)},onRemove:S=>{n("remove",S)},onReplace:(S,B)=>{n("replace",B)},onError:S=>{n("validation-error",S)},onReadyToSubmitChange:S=>{n("is-ready-to-submit-change",S)}},{item:l,setItem:s,addFile:d,removeItem:c,replaceItem:u,cancelUpload:m,retryUpload:p,isLoading:f,hasItem:h,errors:v,adapter:k,formValue:y,acceptString:w}=Zd(r);e.provide("mediaAdapter",k),e.watch(()=>t.modelValue,S=>{S!==l.value&&s(S)},{deep:!0});const g=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!h.value),b=e.computed(()=>({"media-attachment":!0,"media-attachment--disabled":t.disabled,"media-attachment--readonly":t.readonly,"media-attachment--loading":f.value,"media-attachment--has-item":h.value}));function R(S){S.length>0&&d(S[0])}function V(){var S;(S=i.value)==null||S.click()}function I(S){const B=S.target,_=B.files;_&&_.length>0&&u(_[0]),B.value=""}function x(S){c()}function T(S){p()}function $(S){m()}return(S,B)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(b.value)},[e.createElementVNode("input",{ref_key:"fileInputRef",ref:i,type:"file",accept:e.unref(w),disabled:S.disabled,class:"media-attachment__hidden-input",onChange:I},null,40,qP),g.value?e.renderSlot(S.$slots,"dropzone",{key:0,addFile:e.unref(d)},()=>[e.createVNode(Wd,{accept:e.unref(w),multiple:!1,disabled:S.disabled,"max-file-size":S.maxFileSize,onFiles:R},null,8,["accept","disabled","max-file-size"])],!0):e.unref(h)&&e.unref(l)?e.renderSlot(S.$slots,"preview",{key:1,item:e.unref(l),remove:e.unref(c),replace:V},()=>[e.createElementVNode("div",YP,[e.createVNode(Hd,{item:e.unref(l),adapter:e.unref(k),disabled:S.disabled,sortable:!1,"show-remove":!S.readonly,"show-edit":!1,onRemove:x,onRetry:T,onCancel:$},null,8,["item","adapter","disabled","show-remove"]),S.showReplaceButton&&!S.readonly&&!S.disabled&&e.unref(l).media?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-attachment__replace-button",onClick:V},[...B[0]||(B[0]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.createElementVNode("polyline",{points:"17 8 12 3 7 8"}),e.createElementVNode("line",{x1:"12",y1:"3",x2:"12",y2:"15"})],-1),e.createTextVNode(" Replace ",-1)])])):e.createCommentVNode("",!0)])],!0):e.renderSlot(S.$slots,"empty",{key:2},()=>[B[1]||(B[1]=e.createElementVNode("div",{class:"media-attachment__empty"},[e.createElementVNode("p",null,"No file selected")],-1))],!0),S.generateFormFields&&e.unref(y)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("input",{type:"hidden",name:`${S.name}[uuid]`,value:e.unref(y).uuid},null,8,QP),e.createElementVNode("input",{type:"hidden",name:`${S.name}[name]`,value:e.unref(y).name},null,8,eU),e.createElementVNode("input",{type:"hidden",name:`${S.name}[order]`,value:e.unref(y).order},null,8,tU),e.unref(y).custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${S.name}[custom_properties]`,value:JSON.stringify(e.unref(y).custom_properties)},null,8,aU)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),e.unref(v).length>0?(e.openBlock(),e.createElementBlock("div",nU,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(v),_=>(e.openBlock(),e.createElementBlock("p",{key:_.code||_.message,class:"media-attachment__error"},e.toDisplayString(_.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),iU=$e(oU,[["__scopeId","data-v-26911174"]]),Hf={dropzone:{title:"Drop files here",subtitle:"or click to browse",button:"Select files"},item:{remove:"Remove",replace:"Replace",edit:"Edit",download:"Download"},errors:{maxItems:"Maximum {max} files allowed",maxFileSize:"File exceeds maximum size of {max}",invalidType:"File type not allowed",uploadFailed:"Upload failed"},status:{uploading:"Uploading...",processing:"Processing...",completed:"Complete",error:"Error"}},rU=e.defineComponent({__name:"MediaCollectionProvider",props:{modelValue:{default:()=>[]},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxItems:{},maxFileSize:{},acceptedMimeTypes:{},sortable:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","reorder","is-ready-to-submit-change","validation-error"],setup(o,{expose:a,emit:t}){const n=o,i=t,r={initialItems:n.modelValue,modelType:n.modelType,modelId:n.modelId,collection:n.collection,maxItems:n.maxItems,maxFileSize:n.maxFileSize,acceptedMimeTypes:n.acceptedMimeTypes,sortable:n.sortable,disabled:n.disabled,rules:n.rules,adapterType:n.adapter,onChange:S=>{i("update:modelValue",S),i("change",S)},onUpload:S=>{i("upload",S)},onUploadComplete:S=>{i("upload-complete",S)},onUploadError:S=>{i("upload-error",S)},onRemove:S=>{i("remove",S)},onReorder:S=>{i("reorder",S)},onError:S=>{i("validation-error",S)},onReadyToSubmitChange:S=>{i("is-ready-to-submit-change",S)}},{items:l,setItems:s,addFiles:d,removeItem:c,reorderItems:u,updateItem:m,cancelUpload:p,retryUpload:f,isLoading:h,isUploading:v,isReadyToSubmit:k,isAtMaxItems:y,errors:w,dragState:g,getDragProps:b,adapter:R,formValues:V,acceptString:I}=Bl(r);e.provide("mediaAdapter",R),e.provide("mediaCollection",{items:l,addFiles:d,removeItem:c,reorderItems:u}),e.watch(()=>n.modelValue,S=>{S!==l.value&&s(S)},{deep:!0});const x=e.computed(()=>({...Hf,...n.labels})),T=e.computed(()=>({accept:I.value,multiple:n.maxItems!==1,disabled:n.disabled||n.readonly||y.value})),$=e.computed(()=>({items:l.value,isLoading:h.value,isUploading:v.value,isReadyToSubmit:k.value,isAtMaxItems:y.value,errors:w.value,addFiles:d,removeItem:c,reorderItems:u,clearAll:()=>{l.value.forEach(S=>c(S))},cancelUpload:p,retryUpload:f,labels:x.value,dropzoneProps:T.value}));return a({items:l,addFiles:d,removeItem:c,reorderItems:u,updateItem:m,cancelUpload:p,retryUpload:f,isLoading:h,isUploading:v,isReadyToSubmit:k,isAtMaxItems:y,errors:w,dragState:g,getDragProps:b,adapter:R,formValues:V,acceptString:I}),(S,B)=>e.renderSlot(S.$slots,"default",e.normalizeProps(e.guardReactiveProps($.value)))}}),lU=e.defineComponent({__name:"MediaAttachmentProvider",props:{modelValue:{default:null},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxFileSize:{},acceptedMimeTypes:{},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0},showReplaceButton:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","replace","is-ready-to-submit-change","validation-error"],setup(o,{expose:a,emit:t}){const n=o,i=t,r={initialItem:n.modelValue,modelType:n.modelType,modelId:n.modelId,collection:n.collection,maxFileSize:n.maxFileSize,acceptedMimeTypes:n.acceptedMimeTypes,disabled:n.disabled,rules:n.rules,adapterType:n.adapter,onChange:x=>{i("update:modelValue",x),i("change",x)},onUpload:x=>{i("upload",x)},onUploadComplete:x=>{i("upload-complete",x)},onUploadError:x=>{i("upload-error",x)},onRemove:x=>{i("remove",x)},onReplace:(x,T)=>{i("replace",T)},onError:x=>{i("validation-error",x)},onReadyToSubmitChange:x=>{i("is-ready-to-submit-change",x)}},{item:l,setItem:s,addFile:d,removeItem:c,replaceItem:u,cancelUpload:m,retryUpload:p,isLoading:f,isUploading:h,isReadyToSubmit:v,hasItem:k,errors:y,adapter:w,formValue:g,acceptString:b}=Zd(r);e.provide("mediaAdapter",w),e.watch(()=>n.modelValue,x=>{x!==l.value&&s(x)},{deep:!0});const R=e.computed(()=>({...Hf,...n.labels})),V=e.computed(()=>({accept:b.value,multiple:!1,disabled:n.disabled||n.readonly||k.value})),I=e.computed(()=>({item:l.value,hasItem:k.value,isLoading:f.value,isUploading:h.value,isReadyToSubmit:v.value,errors:y.value,addFile:d,removeItem:c,replaceItem:u,cancelUpload:m,retryUpload:p,labels:R.value,dropzoneProps:V.value}));return a({item:l,setItem:s,addFile:d,removeItem:c,replaceItem:u,cancelUpload:m,retryUpload:p,isLoading:f,isUploading:h,isReadyToSubmit:v,hasItem:k,errors:y,adapter:w,formValue:g,acceptString:b}),(x,T)=>e.renderSlot(x.$slots,"default",e.normalizeProps(e.guardReactiveProps(I.value)))}}),sU=["name","value"],dU=["name","value"],cU=["name","value"],uU=["name","value"],mU=e.defineComponent({__name:"MediaHiddenFields",props:{items:{default:()=>[]},item:{default:null},name:{default:"media"},format:{default:"mediables"}},setup(o){const a=o,t=e.computed(()=>a.item?[a.item]:a.items),n=e.computed(()=>Od(t.value));function i(s,d){var u;const c=((u=n.value[s])==null?void 0:u.uuid)||"";return`${a.name}[${c}][${d}]`}function r(s,d){return`${a.name}[${s}][${d}]`}function l(s,d){return a.format==="spatie"?i(s,d):r(s,d)}return(s,d)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,(c,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:c.uuid},[e.createElementVNode("input",{type:"hidden",name:l(u,"uuid"),value:c.uuid},null,8,sU),e.createElementVNode("input",{type:"hidden",name:l(u,"name"),value:c.name},null,8,dU),e.createElementVNode("input",{type:"hidden",name:l(u,"order"),value:c.order},null,8,cU),c.custom_properties&&Object.keys(c.custom_properties).length>0?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:l(u,"custom_properties"),value:JSON.stringify(c.custom_properties)},null,8,uU)):e.createCommentVNode("",!0)],64))),128))}}),pU=["data-testid"],fU=["data-testid"],hU=["id"],vU=["value","maxlength","disabled","aria-labelledby","placeholder","data-testid","onInput"],gU=e.defineComponent({__name:"MediaAttachmentMetadataFields",props:{items:{},disabled:{type:Boolean,default:!1},label:{default:"Caption"},placeholder:{default:"Add an optional caption"},maxLength:{default:500},testIdPrefix:{default:"media-attachment-metadata"},getItemLabel:{type:Function,default:(o,a)=>`${o.type==="video"?"video":"photo"} ${a+1}`}},emits:["update:items"],setup(o,{emit:a}){const t=o,n=a;function i(r,l){const s=l.target;s instanceof HTMLInputElement&&n("update:items",t.items.map((d,c)=>c!==r?d:{...d,caption:s.value===""?null:s.value}))}return(r,l)=>r.items.length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"media-attachment-metadata-fields","data-testid":r.testIdPrefix},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,(s,d)=>(e.openBlock(),e.createElementBlock("div",{key:s._key??s.id??`${s.url}:${d}`,class:"media-attachment-metadata-fields__row","data-testid":`${r.testIdPrefix}-${d}`},[e.createElementVNode("p",{id:`${r.testIdPrefix}-label-${d}`,class:"media-attachment-metadata-fields__label"},e.toDisplayString(r.label)+" for "+e.toDisplayString(r.getItemLabel(s,d)),9,hU),e.createElementVNode("input",{value:s.caption??"",type:"text",class:"media-attachment-metadata-fields__input",maxlength:r.maxLength,disabled:r.disabled,"aria-labelledby":`${r.testIdPrefix}-label-${d}`,placeholder:r.placeholder,"data-testid":`input-${r.testIdPrefix}-${d}`,onInput:c=>i(d,c)},null,40,vU)],8,fU))),128))],8,pU)):e.createCommentVNode("",!0)}}),bU=$e(gU,[["__scopeId","data-v-a153768a"]]);exports.AlbumBrowser=lf;exports.AlbumManager=Z5;exports.AlbumMediaGrid=oF;exports.AlbumNavRail=ZL;exports.AlbumTree=Tl;exports.ArrayBufferTarget=ld;exports.ExistingMediaSelector=kb;exports.ImageEditor=nm;exports.ImageEditorModal=om;exports.LiveStreamManager=s5;exports.ManagedMediaGallery=Yh;exports.MediaAlbumInlineCreate=Id;exports.MediaAlbumPickerModal=Tf;exports.MediaAlbumUnavailableState=sf;exports.MediaAttachment=iU;exports.MediaAttachmentMetadataFields=bU;exports.MediaBulkActionBar=Rd;exports.MediaCollection=JP;exports.MediaCollectionDropzone=Wd;exports.MediaCollectionItem=Hd;exports.MediaEmptyState=Of;exports.MediaFilterChips=Rf;exports.MediaInspectorPanel=Af;exports.MediaLibraryPicker=Vf;exports.MediaLibraryPickerModal=M6;exports.MediaLibraryShell=ML;exports.MediaLibraryToolbar=Bf;exports.MediaLibraryWorkspace=Uf;exports.MediaManagementView=Pf;exports.MediaPreviewSheet=Md;exports.MediaSelectionTray=nP;exports.MediaShortcutHelp=If;exports.MediaSourceSheet=hf;exports.MediaThumbnailCell=gf;exports.MediaTrashWorkspace=zf;exports.MediaUploadSheet=vf;exports.MediaUsageList=$f;exports.MediaVariantStrip=Ff;exports.MediaWorkspace=Xh;exports.ModelMediaManager=jg;exports.Muxer=Nm;exports.RequiresConfirmationError=Ld;exports.VideoEditor=Qp;exports.VideoEditorDialog=H4;exports.VideoEditorSimple=hI;exports.VideoExportPanel=XM;exports.VideoJobClient=Cl;exports.VideoPlayer=nf;exports.VideoTimeline=PI;exports.VideoToolsPanel=VM;exports.VideoUploader=D3;exports.VirtualMediaGrid=bf;exports._sfc_main=rU;exports._sfc_main$1=lU;exports._sfc_main$2=mU;exports.applyTemporaryMediaStoreConfig=Ku;exports.configureAlbumStore=of;exports.configureMediaStore=$o;exports.createAdapter=jf;exports.createEmptyEditorState=yh;exports.createImageEditor=iP;exports.createMediablesAdapter=zd;exports.createSpatieAdapter=jd;exports.deserializeEditorState=bh;exports.formatFileSize=Yr;exports.fromMediaArray=Ys;exports.getFileExtension=yf;exports.getImageDimensions=wf;exports.getMediablesAdapter=rP;exports.getSpatieAdapter=dP;exports.isImageFile=$d;exports.normalizeEditorState=Qs;exports.normalizeRecipeForServerRender=x4;exports.recipeHasServerRenderableEdits=C4;exports.recipeHasUnsupportedServerEdits=af;exports.resetMediablesAdapter=lP;exports.resetSpatieAdapter=cP;exports.restoreAlbumStoreConfig=b5;exports.restoreMediaStoreConfig=Xu;exports.serializeEditorState=Zu;exports.snapshotAlbumStoreConfig=g5;exports.snapshotMediaStoreConfig=Gu;exports.toFormValues=Od;exports.useAdminMediaStore=Ju;exports.useAlbumDragDrop=rf;exports.useAlbumStore=Nl;exports.useAlbums=Vl;exports.useGlobalImageEditor=oP;exports.useImageEditorModal=Ud;exports.useMediaAttachment=Zd;exports.useMediaCollection=Bl;exports.useMediaDeletion=Lf;exports.useMediaDragSort=Wf;exports.useMediaLibraryPickerController=Nf;exports.useMediaLibraryQuery=Ad;exports.useMediaLibrarySession=Ef;exports.useMediaLibraryStateMachine=Sf;exports.useMediaLibraryTelemetry=Cf;exports.useMediaLibraryUploads=Mf;exports.useMediaSelection=tl;exports.useMediaStore=xa;exports.useMediaTrash=Pd;exports.useMediaUploadQueue=Dd;exports.useMediaValidation=Fd;exports.validateFile=kf;
|
|
357
|
-
//# sourceMappingURL=index-
|
|
357
|
+
//# sourceMappingURL=index-BFrh53TT.cjs.map
|