@codingfactory/mediables-vue 2.16.0 → 2.18.0
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-cu2jpN20.js → PixiFrameExporter-D4eUjOce.js} +2 -2
- package/dist/{PixiFrameExporter-cu2jpN20.js.map → PixiFrameExporter-D4eUjOce.js.map} +1 -1
- package/dist/{PixiFrameExporter-BOijjcAa.cjs → PixiFrameExporter-Dcbwik8a.cjs} +2 -2
- package/dist/{PixiFrameExporter-BOijjcAa.cjs.map → PixiFrameExporter-Dcbwik8a.cjs.map} +1 -1
- package/dist/components/AlbumNavRail.vue.d.ts +27 -0
- package/dist/components/AlbumTree.vue.d.ts +2 -0
- package/dist/components/MediaAlbumPickerModal.vue.d.ts +16 -0
- package/dist/components/MediaBulkActionBar.vue.d.ts +33 -0
- package/dist/components/MediaEmptyState.vue.d.ts +20 -0
- package/dist/components/MediaFilterChips.vue.d.ts +26 -0
- package/dist/components/MediaInspectorPanel.vue.d.ts +37 -0
- package/dist/components/MediaLibraryShell.vue.d.ts +42 -0
- package/dist/components/MediaLibraryToolbar.vue.d.ts +11 -0
- package/dist/components/MediaLibraryWorkspace.vue.d.ts +70 -0
- package/dist/components/MediaManagementView.vue.d.ts +30 -0
- package/dist/components/MediaShortcutHelp.vue.d.ts +13 -0
- package/dist/components/MediaTrashWorkspace.vue.d.ts +15 -0
- package/dist/components/MediaUsageList.vue.d.ts +17 -0
- package/dist/components/MediaVariantStrip.vue.d.ts +10 -0
- package/dist/composables/useMediaDeletion.d.ts +36 -0
- package/dist/composables/useMediaDisplayName.d.ts +19 -0
- package/dist/composables/useMediaLibraryQuery.d.ts +25 -2
- package/dist/composables/useMediaLibraryUploads.d.ts +41 -0
- package/dist/composables/useMediaSelection.d.ts +34 -4
- package/dist/{index-Bff5fDnU.js → index-CpKp0R25.js} +20236 -17730
- package/dist/index-CpKp0R25.js.map +1 -0
- package/dist/index-DRMt6jsC.cjs +357 -0
- package/dist/index-DRMt6jsC.cjs.map +1 -0
- package/dist/index.d.ts +32 -2
- package/dist/mediables-vue.cjs +1 -1
- package/dist/mediables-vue.mjs +109 -93
- package/dist/stores/albumStore.d.ts +1 -0
- package/dist/style.css +1 -1
- package/dist/types/album.d.ts +11 -0
- package/dist/types/media.d.ts +5 -0
- package/dist/types/mediaLibraryPicker.d.ts +43 -1
- package/package.json +1 -1
- package/dist/index-Bff5fDnU.js.map +0 -1
- package/dist/index-zFuo-sDY.cjs +0 -357
- package/dist/index-zFuo-sDY.cjs.map +0 -1
package/dist/index-zFuo-sDY.cjs
DELETED
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
"use strict";var Uf=Object.defineProperty;var Of=(o,a,t)=>a in o?Uf(o,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[a]=t;var ae=(o,a,t)=>Of(o,typeof a!="symbol"?a+"":a,t);const Xr=require("pinia"),e=require("vue"),Et=require("pixi.js"),oe=require("./editor-DLvndiXG.cjs"),H=require("@ionic/vue"),zf=require("pixi-filters");function jf(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 Pt=jf(Et),rl=1,Wf=new Set(["free","square","circle"]);function Hf(o){if(typeof o!="number"||!Number.isFinite(o))return 0;const a=o%360;return a<0?a+360:a}function Zf(o){const a=typeof o;return a==="string"||a==="number"||a==="boolean"}function Gf(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 Xl(o){if(!o||typeof o!="object")return null;const a=o;if(a.version!==rl)return null;const t=a.crop,n=t&&Gf(t.rect)?{...t.rect}:null,i=t&&typeof t.shape=="string"&&Wf.has(t.shape)?t.shape:"free",r=t&&typeof t.aspectRatio=="string"?t.aspectRatio:"free",s=a.transform,l=Hf(s==null?void 0:s.rotation),d=a.filters,c=[];if(Array.isArray(d))for(const u of d){if(!u||typeof u!="object")continue;const f=u;if(typeof f.id!="string")continue;const m={},p=f.values;if(p&&typeof p=="object"&&!Array.isArray(p))for(const[h,v]of Object.entries(p))Zf(v)&&(m[h]=v);c.push({id:f.id,enabled:f.enabled!==!1,values:m})}return{version:rl,crop:{rect:n,aspectRatio:r,shape:i},transform:{rotation:l},filters:c}}function Iu(o){const a=Xl(o);return a?JSON.stringify(a):null}function Xf(o){try{const a=JSON.parse(o);return Xl(a)}catch{return null}}function Kf(){return{version:rl,crop:{rect:null,aspectRatio:"free",shape:"free"},transform:{rotation:0},filters:[]}}let pa={apiBaseUrl:"/api/v1",isAdmin:!1};function Jd(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 So(o){pa={...pa,...o}}function Mu(){return{...pa}}function Fu(o){pa={...o}}function $u(o){const a=Mu();return So(o),()=>{Fu(a)}}function Jf(o){const a=o.trim().replace(/\/+$/,"");return a===""?"/api/v1":a.startsWith("/")?a:`/${a}`}function qf(o,a){const t=Jf(a),n=(i,r="")=>{const s=`/api${t}`;return!t.startsWith("/api/")&&i.startsWith(`${s}/`)?`${i.slice(4)}${r}`:!t.startsWith("/api/")&&i===s?`${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 Yf=async(o,a={})=>{var l;const t=(l=document.querySelector('meta[name="csrf-token"]'))==null?void 0:l.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 s=await fetch(o,r);if(!s.ok){const d=await s.json().catch(()=>({message:"Request failed"}));throw new Error(d.message||`HTTP ${s.status}`)}if(s.status!==204)return await s.json()},xa=Xr.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),s=e.ref(24),l=e.ref({type:null,uuid:null}),d=e.ref([]),c=e.ref(!1),u=e.ref(null),f=e.ref(new Map),m=e.ref(new Map),p=e.ref(new Set),h=e.ref(new Map),v=e.ref({}),w=5*60*1e3,E=e.computed(()=>{if(pa.apiScope)return pa.apiScope;if(pa.isAdmin)return"admin"}),S=e.computed(()=>E.value==="admin");function k(){return pa.httpClient||Yf}function b(me){const ve=pa.apiBaseUrl||"/api/v1",fe=E.value?`/${E.value}`:"";return`${ve}${fe}${me}`}function $(me){return`${pa.apiBaseUrl||"/api/v1"}${me}`}function V(me,ve){return`${E.value??"default"}-${me}-${JSON.stringify(ve)}`}function I(me){return Date.now()-me<w}function x(){h.value.clear(),v.value={}}function N(me){if(!me||!me.data)return;const ve={};me.data.forEach(fe=>{const Ee=`${fe.file_name}-${fe.collection_name||"default"}`,ye=ve[Ee];(!ye||Object.keys(fe.generated_conversions||{}).length>Object.keys(ye.generated_conversions||{}).length)&&(ve[Ee]=fe)}),o.value=Object.values(ve),me.meta&&(i.value=me.meta.current_page,r.value=Math.ceil(me.meta.total/me.meta.per_page))}async function L(me=1,ve={}){const fe=V(me,ve),Ee=h.value.get(fe);if(Ee&&I(Ee.timestamp)){const ye=Ee.data;return N(ye),ye}t.value=!0,n.value=null;try{const ye=new URLSearchParams;ye.append("page",me.toString()),ye.append("per_page",s.value.toString()),S.value&&ye.append("linked","1");for(const et in ve)if(Object.prototype.hasOwnProperty.call(ve,et)){const tt=ve[et];tt!=null&&tt!==""&&ye.append(et,String(tt))}const Ie=await k()(b(`/media?${ye}`));return h.value.set(fe,{data:Ie,timestamp:Date.now()}),N(Ie),Ie}catch(ye){throw n.value=ye instanceof Error?ye.message:"Failed to fetch media",o.value=[],new Error(n.value)}finally{t.value=!1}}async function C(me,ve){t.value=!0,n.value=null;const fe=`${me.name}-${Date.now()}`,Ee={file:me,progress:0,status:"uploading"};f.value.set(fe,Ee);try{const ye=new FormData;ye.append("file",me),ye.append("collection",ve.collection),ve.ownerUuid&&(ye.append("owner_uuid",ve.ownerUuid),ye.append("owner_type",ve.ownerType||"")),ve.usageUuid&&(ye.append("usage_uuid",ve.usageUuid),ye.append("usage_type",ve.usageType||""),ye.append("usage_purpose",ve.usagePurpose||"")),ve.customProperties&&ye.append("custom_properties",JSON.stringify(ve.customProperties));const Ie=await k()(b("/media"),{method:"POST",body:ye});return Ee.status="completed",Ee.progress=100,Ee.media=Ie==null?void 0:Ie.data,i.value===1&&(Ie!=null&&Ie.data)&&(o.value=[Ie.data,...o.value]),x(),(Ie==null?void 0:Ie.data)||null}catch(ye){throw Ee.status="error",Ee.error=ye instanceof Error?ye.message:"Upload failed",n.value=Ee.error,new Error(n.value)}finally{t.value=!1,setTimeout(()=>{f.value.delete(fe)},5e3)}}async function T(me){t.value=!0,n.value=null;const ve=o.value.findIndex(Ee=>Ee.uuid===me);let fe;ve!==-1&&(fe=o.value.splice(ve,1)[0]);try{return await k()(b(`/media/${me}`),{method:"DELETE"}),p.value.delete(me),x(),!0}catch(Ee){throw fe&&ve!==-1&&o.value.splice(ve,0,fe),n.value=Ee instanceof Error?Ee.message:"Failed to delete media",new Error(n.value)}finally{t.value=!1}}async function y(me,ve){t.value=!0,n.value=null;try{const Ee=await k()(b(`/media/${me}`),{method:"PATCH",body:ve,data:ve});if(Ee!=null&&Ee.data){const ye=o.value.findIndex(Be=>Be.uuid===me);return ye!==-1&&(o.value[ye]={...o.value[ye],...Ee.data}),x(),Ee.data}return null}catch(fe){throw n.value=fe instanceof Error?fe.message:"Failed to update media",new Error(n.value)}finally{t.value=!1}}async function R(){t.value=!0,n.value=null;try{const ve=await k()(b("/media/collections"));return a.value=(ve==null?void 0:ve.data)||[],a.value}catch(me){throw n.value=me instanceof Error?me.message:"Failed to fetch collections",a.value=[],new Error(n.value)}finally{t.value=!1}}async function U(me,ve,fe="images",Ee){c.value=!0,u.value=null;try{const ye=new URLSearchParams;ye.append("collection",fe),Ee&&ye.append("search",Ee);const Ie=await k()(b(`/media/model/${me}/${ve}?${ye}`));return Ie!=null&&Ie.data?(d.value=Ie.data,Ie.data):[]}catch(ye){throw u.value=ye instanceof Error?ye.message:"Failed to fetch model media",d.value=[],new Error(u.value)}finally{c.value=!1}}async function z(me,ve,fe,Ee="images"){c.value=!0,u.value=null;const ye=[...d.value];try{const Ie=await k()(b(`/media/model/${me}/${ve}/attach`),{method:"POST",body:{media_uuids:fe,collection:Ee}});return await U(me,ve,Ee),(Ie==null?void 0:Ie.data)||[]}catch(Be){throw d.value=ye,u.value=Be instanceof Error?Be.message:"Failed to attach media",new Error(u.value)}finally{c.value=!1}}async function W(me,ve,fe,Ee="images"){c.value=!0,u.value=null;const ye=[...d.value];d.value=d.value.filter(Be=>Be.uuid!==fe);try{return await k()(b(`/media/model/${me}/${ve}/detach`),{method:"POST",body:{media_uuid:fe,collection:Ee}}),!0}catch(Be){throw d.value=ye,u.value=Be instanceof Error?Be.message:"Failed to detach media",new Error(u.value)}finally{c.value=!1}}async function B(me,ve,fe,Ee="images"){c.value=!0,u.value=null;const ye=[...d.value],Be=new Map(d.value.map(Ie=>[Ie.uuid,Ie]));d.value=fe.map(Ie=>Be.get(Ie)).filter(Ie=>Ie!==void 0);try{return await k()(b(`/media/model/${me}/${ve}/reorder`),{method:"POST",body:{media_uuids:fe,collection:Ee}}),!0}catch(Ie){throw d.value=ye,u.value=Ie instanceof Error?Ie.message:"Failed to reorder media",new Error(u.value)}finally{c.value=!1}}async function P(me,ve,fe={}){var it,_t;const Ee=k(),ye=pa.apiBaseUrl||"/api/v1";let Be=Jd(ve.documentId)?ve.documentId:Jd((it=ve.document)==null?void 0:it.id)?ve.document.id:null,Ie=ve.documentRevisionId??null,et=typeof ve.documentRevisionNumber=="number"?ve.documentRevisionNumber:typeof((_t=ve.document)==null?void 0:_t.revision)=="number"?ve.document.revision:null;if(ve.document){const ge=await Ee(`${ye}/media/${me}/editor-documents/materialize`,{method:"POST",body:{document_id:Be,base_document_revision:et,document:ve.document}});Be=ge.document_id,Ie=ge.document_revision_id,et=ge.document_revision_number}if(ve.document&&Be&&Ie&&typeof et=="number"){const ge=new FormData,Te=(ve.mimeType||ve.blob.type||"image/png")==="image/jpeg"?"jpg":"png";ge.append("flattened_file",ve.blob,`edited.${Te}`),ge.append("document_id",Be),ge.append("document_revision_id",Ie),ge.append("expected_document_revision",String(et)),ge.append("output_mode",fe.asVariant?"save-as-variant":"save-as-new");const Ke=await Ee(`${ye}/media/${me}/editor-documents/save`,{method:"POST",body:ge});if(Ke.media)return Ke.media;throw new Error("Unexpected response from layered editor save endpoint")}const tt=new FormData,vt=(ve.mimeType||ve.blob.type||"image/png")==="image/jpeg"?"jpg":"png";tt.append("image_file",ve.blob,`edited.${vt}`);const xt=Iu(ve.state);xt&&tt.append("editor_state",xt),tt.append("save_as_new","true"),fe.asVariant&&tt.append("as_variant","true"),fe.name!==void 0&&tt.append("name",fe.name);const wt=await Ee(`${ye}/editor/${me}/save`,{method:"POST",body:tt});if("media"in wt&&wt.media)return wt.media;if("status_url"in wt&&wt.status_url)return X(Ee,qf(wt.status_url,ye),fe.pollTimeout??6e4);throw new Error("Unexpected response from editor save endpoint")}async function X(me,ve,fe){const Ee=Date.now(),ye=2e3;for(;Date.now()-Ee<fe;){await new Promise(Ie=>setTimeout(Ie,ye));const Be=await me(ve);if(Be.status==="completed"&&Be.media)return Be.media;if(Be.status==="failed")throw new Error(Be.error??"Image processing failed")}throw new Error("Image processing timed out")}function K(me,ve,fe){l.value=fe!==void 0?{type:me,uuid:ve,collection:fe}:{type:me,uuid:ve},v.value[`${me}-${ve}`]={timestamp:Date.now()}}function be(){l.value={type:null,uuid:null},d.value=[],u.value=null}async function Ne(){if(!l.value.type||!l.value.uuid)return;const me=await U(l.value.type,l.value.uuid,l.value.collection||"images");d.value=me||[]}function ue(){o.value.forEach(me=>p.value.add(me.uuid))}function re(){p.value.clear()}function O(me){p.value.has(me)?p.value.delete(me):p.value.add(me)}function D(me){return p.value.has(me)}function J(){return Array.from(f.value.values()).some(me=>me.status==="uploading")}function Z(me){return f.value.get(me)||m.value.get(me)}function ie(){return[...Array.from(f.value.values()),...Array.from(m.value.values())]}async function se(){const me=Array.from(p.value);let ve=0;for(const fe of me)try{await T(fe),ve++}catch{}return re(),ve}function Ue(me,ve){var fe;return ve&&((fe=me.conversion_urls)!=null&&fe[ve])?me.conversion_urls[ve]||"":me.original_url||me.url||""}return{items:o,collections:a,loading:t,error:n,currentPage:i,totalPages:r,itemsPerPage:s,isAdmin:S,modelContext:l,modelMedia:d,isLoadingModelMedia:c,modelMediaError:u,selectedItems:p,uploadProgress:f,uploadQueue:m,cachedResponses:v,fetchMedia:L,uploadFile:C,deleteMedia:T,updateMedia:y,clearCache:x,fetchCollections:R,fetchModelMedia:U,attachMedia:z,detachMedia:W,reorderMedia:B,saveEditedImage:P,setModelContext:K,clearModelContext:be,refreshModelMedia:Ne,selectAllItems:ue,clearSelection:re,toggleSelection:O,isSelected:D,deleteSelectedItems:se,getHttpClient:k,getApiUrl:b,getEditorApiUrl:$,hasActiveUploads:J,getUploadProgress:Z,getAllUploadProgress:ie,getMediaUrl:Ue}}),Du=()=>((pa.apiScope!=="admin"||pa.isAdmin!==!0)&&So({...pa,apiScope:"admin",isAdmin:!0}),xa());class Ru{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=oe.el("div",{className:"panel-tabs",role:"tablist","aria-label":"Filter categories","data-testid":"v2-category-tabs"}),oe.EDITOR_CATEGORIES.forEach(t=>{const n=oe.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=oe.el("span",{className:"panel-tab-icon","aria-hidden":"true"});i.innerHTML=t.icon,n.appendChild(i)}n.appendChild(oe.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 Au{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=oe.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(s=>{var c;const l=((c=n==null?void 0:n.has)==null?void 0:c.call(n,s.id))??!1,d=i===s.id;this.element.appendChild(this._renderRow(s,l,d,r))})}_renderRow(a,t,n,i=null){const r=oe.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)}}),s=oe.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 m,p,h,v;u.stopPropagation();const f=!((p=(m=this.state.get("activeFilters"))==null?void 0:m.has)!=null&&p.call(m,a.id));(h=this._onToggle)==null||h.call(this,a.id,f,i),f&&((v=this._onSelect)==null||v.call(this,a.id,i))}});t&&(s.innerHTML=oe.checkmark),r.appendChild(s);const l=oe.el("div",{className:"filter-row-body"});l.appendChild(oe.el("span",{className:"filter-row-name"},a.name));const d=this._buildSummary(a,t);d&&l.appendChild(oe.el("span",{className:"filter-row-summary"},d)),r.appendChild(l);const c=oe.el("span",{className:"filter-row-chevron","aria-hidden":"true"});return c.innerHTML=oe.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 s=n[r.id];if(!(s===void 0||s===r.default)&&(i.push(this._formatControlValue(r,s)),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 s=this.element.querySelector(`[data-filter="${r.id}"]`);if(!s)continue;const l=((i=n==null?void 0:n.has)==null?void 0:i.call(n,r.id))??!1,d=this._buildSummary(r,l),c=s.querySelector(".filter-row-summary");if(d&&c)c.textContent=d;else if(d&&!c){const u=s.querySelector(".filter-row-body");u==null||u.appendChild(oe.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 Lu{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=oe.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(oe.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(oe.el("div",{className:"no-filter-selected"},"Filter not found"));return}const i=oe.el("div",{className:"controls-header"});i.appendChild(oe.el("span",{className:"controls-title"},n.name)),i.appendChild(oe.createButton({label:"Reset",className:"btn-text",onClick:()=>this._handleReset(a,t)})),this.element.appendChild(i);const r=oe.el("div",{className:"controls-grid"}),s=this.state.getFilterValues(a);(n.controls||[]).forEach(d=>{if(d.hidden)return;const c=this._createControl(a,d,s[d.id]??d.default,t);c&&r.appendChild(c)});const l=this.filterManager.getInstance(a);if(l&&typeof l.getDynamicControls=="function"){let d=[];try{d=l.getDynamicControls()||[]}catch{}d.forEach(c=>{const u=c.property||c.id,f=s[u]??c.default,m=this._createControl(a,c,f,t);m&&r.appendChild(m)})}this.element.appendChild(r)}_createControl(a,t,n,i=null){if(t.hidden)return null;const r=t.label||t.id,s=this._normalizeControlType(t.type),l=t.property||t.id;switch(s){case"slider":return oe.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,l,d,i)}});case"toggle":return oe.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,l,d,i)}});case"color":return oe.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,l,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 oe.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,l,c,i)}})}case"text":return oe.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,l,d,i)}});case"button":{const d=oe.el("div",{className:"button-control"});return d.appendChild(oe.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 Qf{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=oe.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=oe.el("div",{className:"panel-section-title"});if(i.appendChild(oe.el("span",{},`Active (${t})`)),t>0&&this._onClearAll&&i.appendChild(oe.el("button",{type:"button",className:"btn btn-text",style:{padding:"2px 8px",fontSize:"11px"},"data-testid":"v2-clear-all",onClick:()=>{var l;return(l=this._onClearAll)==null?void 0:l.call(this,n)}},"Clear all")),this.element.appendChild(i),t===0){this.element.appendChild(oe.el("div",{className:"active-empty"},"No filters applied"));return}const r=oe.el("div",{className:"active-stack"}),s=this.state.get("selectedFilter");for(const l of a){const d=this.filterManager.getFilterDef(l);d&&r.appendChild(this._renderChip(d,l===s,n))}this.element.appendChild(r)}_renderChip(a,t,n=null){const i=oe.el("div",{className:`active-chip ${t?"selected":""}`,"data-filter":a.id,"data-testid":`v2-active-${a.id}`});i.appendChild(oe.el("button",{type:"button",className:"active-chip-name","aria-label":`Select ${a.name}`,onClick:()=>{var s;return(s=this._onSelect)==null?void 0:s.call(this,a.id,n)}},a.name));const r=oe.el("button",{type:"button",className:"active-chip-remove","aria-label":`Remove ${a.name}`,"data-testid":`v2-active-remove-${a.id}`,onClick:()=>{var s;return(s=this._onRemove)==null?void 0:s.call(this,a.id,n)}});return r.innerHTML=oe.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 go=["collapsed","half","full"];class eh{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=oe.el("div",{className:"editor-v2-drawer",role:"dialog","aria-label":this._ariaLabel,"data-testid":"v2-bottom-drawer","data-snap":this._snap}),this._handle=oe.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=oe.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=oe.el("div",{className:"drawer-header"}),a&&this._headerSlot.appendChild(a),this.element.appendChild(this._headerSlot),this._body=oe.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={}){go.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"),s=Math.max(i,Math.min(r,n));this.element&&(this.element.style.height=`${s}px`),Math.abs(t)>4&&(this._wasDragging=!0),a.preventDefault()}_onPointerEnd(a){var i,r,s;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=((s=this.element)==null?void 0:s.offsetHeight)||0,n=this._nearestSnap(t);this._applySnap(n,{animate:!0})}_cycleSnap(){const a=go.indexOf(this._snap),t=go[(a+1)%go.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=go[0],n=1/0;for(const i of go){const r=this._heightForSnap(i),s=Math.abs(r-a);s<n&&(n=s,t=i)}return t}_applySnap(a,{animate:t}){var r,s;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&&((s=this._onSnapChange)==null||s.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 th=[{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 Pu{constructor(a,t){this.state=a,this.editor=t,this.element=null,this._errorMessage=null,this._unsubscribers=[]}render(){return this.element=oe.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 p,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,s=t.kind==="color"&&typeof t.value=="string"?t.value:"#ffffff";this.element.appendChild(oe.el("div",{className:"panel-section-title"},oe.el("span",{},"Background"))),this._errorMessage&&this.element.appendChild(oe.el("p",{className:"background-panel-error",role:"alert","data-testid":"v2-background-error"},this._errorMessage));const l=oe.el("input",{type:"color",className:"color-input",value:s,disabled:r?"disabled":void 0,"aria-label":"Background color","data-testid":"v2-background-color",onInput:w=>{this._runAction(this.editor.setBackgroundColor(w.target.value))}});this.element.appendChild(this._field("Color",l));const d=oe.el("div",{className:"background-gradient-grid"});for(const w of th){const E=oe.el("button",{type:"button",className:"background-gradient-swatch",style:{background:w.style},"aria-label":w.ariaLabel,disabled:r?"disabled":void 0,"data-testid":`v2-background-gradient-${w.id}`,onClick:()=>{this._runAction(this.editor.setBackgroundGradient(w.fill))}},oe.el("span",{className:"background-gradient-label"},w.label));d.appendChild(E)}this.element.appendChild(this._field("Gradient",d));const c=oe.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:w=>{var S;const E=(S=w.target.files)==null?void 0:S[0];E&&this._runAction(this.editor.setBackgroundImageFromFile(E,{fit:n})),w.target.value=""}});this.element.appendChild(this._field("Upload",c));const u=(v=(h=(p=this.editor)==null?void 0:p._options)==null?void 0:h.backgroundReplacement)==null?void 0:v.mediaChoices;if(Array.isArray(u)&&u.length>0){const w=oe.el("div",{className:"background-media-grid"});for(const E of u)E!=null&&E.source&&w.appendChild(oe.el("button",{type:"button",className:"background-media-choice","aria-label":`Use ${E.label||"media"} as background`,disabled:r?"disabled":void 0,"data-testid":`v2-background-media-${E.id||E.source.mediaUuid||"choice"}`,onClick:()=>{this._runAction(this.editor.setBackgroundMediaSource(E.source,{fit:E.fit||n}))}},E.label||"Media"));this.element.appendChild(this._field("Media",w))}const f=oe.el("select",{className:"select-input",disabled:r?"disabled":void 0,"aria-label":"Background image fit","data-testid":"v2-background-fit",onChange:w=>{this._runAction(this.editor.setBackgroundFit(w.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",f));const m=oe.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:w=>{this._runAction(this.editor.setBackgroundBlur(Number(w.target.value)))}});this.element.appendChild(this._field("Blur",m)),this.element.appendChild(oe.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 oe.el("label",{className:"background-field"},oe.el("span",{className:"background-field-label"},a),t)}_option(a,t,n){return oe.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(s=>(s==null?void 0:s.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 Uu{constructor(a,t){this.state=a,this.editor=t,this.element=null,this._listEl=null,this._unsubscribers=[]}render(){return this.element=oe.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(oe.el("div",{className:"layer-stack-header"},oe.el("span",{className:"layer-stack-title"},"Layers"),oe.el("span",{className:"layer-stack-order"},"Bottom to top"))),this._listEl=oe.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(oe.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),s=(a==null?void 0:a.visible)!==!1,l=(a==null?void 0:a.locked)===!0,d=this.state.get("activeLayerId")===i,c=[d?"active":null,s?"visible":"hidden",l?"locked":"unlocked"].filter(Boolean).join(", "),u=oe.el("div",{className:`layer-row${d?" active":""}${s?"":" hidden"}${l?" 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 m,p;return(p=(m=this.editor).selectLayer)==null?void 0:p.call(m,i)})},this._thumbnail(a))),u.appendChild(oe.el("div",{className:"layer-row-main"},oe.el("span",{className:"layer-row-name"},r),oe.el("span",{className:"layer-row-meta"},this._layerTypeLabel(a))));const f=oe.el("div",{className:"layer-row-actions"});return f.appendChild(this._iconButton({testId:`v2-layer-${s?"hide":"show"}-${i}`,label:`${s?"Hide":"Show"} ${r}`,icon:s?oe.eye:oe.eyeOff,disabled:l,onClick:()=>this._runAction(()=>{var m,p;return(p=(m=this.editor).setLayerVisibility)==null?void 0:p.call(m,i,!s)})})),f.appendChild(this._iconButton({testId:`v2-layer-${l?"unlock":"lock"}-${i}`,label:`${l?"Unlock":"Lock"} ${r}`,icon:l?oe.lockClosed:oe.lockOpen,onClick:()=>this._runAction(()=>{var m,p;return(p=(m=this.editor).setLayerLocked)==null?void 0:p.call(m,i,!l)})})),f.appendChild(this._iconButton({testId:`v2-layer-move-up-${i}`,label:`Move ${r} up`,icon:oe.chevronRight,disabled:l,onClick:()=>this._runAction(()=>{var m,p;return(p=(m=this.editor).moveLayer)==null?void 0:p.call(m,i,"up")})})),f.appendChild(this._iconButton({testId:`v2-layer-move-down-${i}`,label:`Move ${r} down`,icon:oe.chevronLeft,disabled:l,onClick:()=>this._runAction(()=>{var m,p;return(p=(m=this.editor).moveLayer)==null?void 0:p.call(m,i,"down")})})),f.appendChild(this._iconButton({testId:`v2-layer-bring-front-${i}`,label:`Bring ${r} to front`,icon:oe.chevronRight,disabled:l,onClick:()=>this._runAction(()=>{var m,p;return(p=(m=this.editor).moveLayer)==null?void 0:p.call(m,i,"front")})})),f.appendChild(this._iconButton({testId:`v2-layer-send-back-${i}`,label:`Send ${r} to back`,icon:oe.chevronLeft,disabled:l,onClick:()=>this._runAction(()=>{var m,p;return(p=(m=this.editor).moveLayer)==null?void 0:p.call(m,i,"back")})})),f.appendChild(this._iconButton({testId:`v2-layer-rename-${i}`,label:`Rename ${r}`,icon:oe.pencil,disabled:l,onClick:()=>this._renameLayer(i,r)})),f.appendChild(this._iconButton({testId:`v2-layer-duplicate-${i}`,label:`Duplicate ${r}`,icon:oe.duplicate,disabled:l,onClick:()=>this._runAction(()=>{var m,p;return(p=(m=this.editor).duplicateLayer)==null?void 0:p.call(m,i)})})),f.appendChild(this._iconButton({testId:`v2-layer-delete-${i}`,label:`Delete ${r}`,icon:oe.trash,disabled:l||n<=1,onClick:()=>this._runAction(()=>{var m,p;return(p=(m=this.editor).deleteLayer)==null?void 0:p.call(m,i)})})),u.appendChild(f),u}_thumbnail(a){const t=oe.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"?oe.layers:oe.move;return t}_button({testId:a,label:t,...n},i){const r=oe.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 s=oe.el("button",{type:"button",className:"layer-action-btn","aria-label":t,title:t,disabled:i?"disabled":void 0,"data-testid":a,onClick:r});return s.innerHTML=n,s}_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,s;return(s=(r=this.editor).renameLayer)==null?void 0:s.call(r,a,n)})}_runAction(a){var t,n;try{Promise.resolve(a()).catch(i=>{var r,s;return(s=(r=this.editor).emit)==null?void 0:s.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 ah=[{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"}],oh=[{value:"normal",label:"Normal"},{value:"multiply",label:"Multiply"},{value:"screen",label:"Screen"},{value:"overlay",label:"Overlay"}],er={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 Ou{constructor(a,t){this.state=a,this.editor=t,this.element=null,this._errorMessage=null,this._unsubscribers=[]}render(){return this.element=oe.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(oe.el("div",{className:"text-panel-header"},oe.el("div",{className:"panel-section-title"},oe.el("span",{},"Text")),oe.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(oe.el("p",{className:"text-panel-error",role:"alert","data-testid":"v2-text-error"},this._errorMessage)),!a){this.element.appendChild(oe.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:{},s=a.transform&&typeof a.transform=="object"?a.transform:{},l=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:oh,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:oe.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:ah,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:s.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:l.stroke.enabled,disabled:t,onChange:d=>this._updateEffects(a.id,{stroke:{enabled:d}})}),this._colorField({label:"Stroke Color",testId:"v2-text-stroke-color",value:l.stroke.color,disabled:t,onInput:d=>this._updateEffects(a.id,{stroke:{color:d}})}),this._numberField({label:"Stroke Width",testId:"v2-text-stroke-width",value:l.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:l.shadow.enabled,disabled:t,onChange:d=>this._updateEffects(a.id,{shadow:{enabled:d}})}),this._colorField({label:"Shadow Color",testId:"v2-text-shadow-color",value:l.shadow.color,disabled:t,onInput:d=>this._updateEffects(a.id,{shadow:{color:d}})}),this._numberField({label:"Shadow Alpha",testId:"v2-text-shadow-alpha",value:l.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:l.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:l.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:l.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:l.glow.enabled,disabled:t,onChange:d=>this._updateEffects(a.id,{glow:{enabled:d}})}),this._colorField({label:"Glow Color",testId:"v2-text-glow-color",value:l.glow.color,disabled:t,onInput:d=>this._updateEffects(a.id,{glow:{color:d}})}),this._numberField({label:"Glow Alpha",testId:"v2-text-glow-alpha",value:l.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:l.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:l.backdrop.enabled,disabled:t,onChange:d=>this._updateEffects(a.id,{backdrop:{enabled:d}})}),this._colorField({label:"Backdrop Color",testId:"v2-text-backdrop-color",value:l.backdrop.color,disabled:t,onInput:d=>this._updateEffects(a.id,{backdrop:{color:d}})}),this._numberField({label:"Backdrop Opacity",testId:"v2-text-backdrop-opacity",value:l.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:l.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:l.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:l.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=oe.el("div",{className:"text-field text-content-field"});i.appendChild(oe.el("label",{className:"text-field-label",for:"v2-text-content"},"Content"));let r=t==null?"":String(t);const s=oe.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),s.value=r,s.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})),s.blur())}});s.value=r,i.appendChild(s);const l=oe.el("div",{className:"text-content-actions"});return l.appendChild(oe.el("button",{type:"button",className:"btn btn-text",disabled:n?"disabled":void 0,"data-testid":"v2-text-cancel",onClick:()=>{r=t==null?"":String(t),s.value=r}},"Cancel")),l.appendChild(oe.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(l),i}_controlGrid(a){const t=oe.el("div",{className:"text-control-grid"});for(const n of a)t.appendChild(n);return t}_effectSection(a,t){return oe.el("div",{className:"text-effect-section"},oe.el("div",{className:"text-effect-title"},a),this._controlGrid(t))}_selectField({label:a,testId:t,value:n,options:i,disabled:r,onChange:s}){const l=oe.el("select",{className:"select-input",disabled:r?"disabled":void 0,"data-testid":t,onChange:d=>s(d.target.value)});for(const d of i)l.appendChild(oe.el("option",{value:d.value,selected:String(n)===String(d.value)?"selected":void 0},d.label));return this._field(a,l)}_numberField({label:a,testId:t,value:n,min:i,max:r,step:s,disabled:l,onInput:d}){const c=oe.el("input",{type:"number",className:"text-number-input",min:String(i),max:String(r),step:String(s),value:String(n),disabled:l?"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 s=oe.el("input",{type:"color",className:"color-input",value:n,disabled:i?"disabled":void 0,"data-testid":t,onInput:l=>r(l.target.value)});return this._field(a,s)}_checkboxField({label:a,testId:t,checked:n,disabled:i,onChange:r}){const s=oe.el("input",{type:"checkbox",className:"text-checkbox-input",checked:n?"checked":void 0,disabled:i?"disabled":void 0,"data-testid":t,onChange:l=>r(l.target.checked===!0)});return oe.el("label",{className:"text-field text-checkbox-field"},oe.el("span",{className:"text-field-label"},a),s)}_field(a,t){return oe.el("label",{className:"text-field"},oe.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:{...er.stroke,...t.stroke&&typeof t.stroke=="object"?t.stroke:{}},shadow:{...er.shadow,...t.shadow&&typeof t.shadow=="object"?t.shadow:{}},glow:{...er.glow,...t.glow&&typeof t.glow=="object"?t.glow:{}},backdrop:{...er.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 ih{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=oe.el("div",{className:"drawer-nav","data-testid":"v2-mobile-nav"}),this._headerEl=oe.el("div",{className:"drawer-nav-header"}),this.element.appendChild(this._headerEl),this._bodyEl=oe.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 Ru(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 Au(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 Lu(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 Pu(this.state,this.editor),this._backgroundPanelEl=this._backgroundPanel.render(),this._layerStackPanel=new Uu(this.state,this.editor),this._layerStackPanelEl=this._layerStackPanel.render(),this._textPanel=new Ou(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=oe.el("button",{type:"button",className:"drawer-back-btn","aria-label":"Go back","data-testid":"v2-drawer-back",onClick:()=>this._goBack()});n.innerHTML=oe.chevronLeft,this._headerEl.appendChild(n)}const t=this._titleForView(this._view);if(this._headerEl.appendChild(oe.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(oe.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=oe.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,s,l;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(),(s=this._textPanel)==null||s.destroy(),(l=this.element)==null||l.remove(),this.element=null}}class rh{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=oe.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=oe.el("div",{className:"mobile-active-track"}),i=this.state.get("selectedFilter"),r=this._activeFilterLayerId();for(const s of a){const l=this.filterManager.getFilterDef(s);l&&n.appendChild(this._renderChip(l,s===i,r))}this.element.appendChild(n)}_renderChip(a,t,n=null){const i=oe.el("div",{className:`mobile-active-chip ${t?"selected":""}`,"data-filter":a.id,"data-testid":`v2-mobile-chip-${a.id}`});i.appendChild(oe.el("button",{type:"button",className:"mobile-active-chip-name","aria-label":`Edit ${a.name}`,onClick:()=>{var s;return(s=this._onSelect)==null?void 0:s.call(this,a.id,n)}},a.name));const r=oe.el("button",{type:"button",className:"mobile-active-chip-remove","aria-label":`Remove ${a.name}`,"data-testid":`v2-mobile-chip-remove-${a.id}`,onClick:s=>{var l;s.stopPropagation(),(l=this._onRemove)==null||l.call(this,a.id,n)}});return r.innerHTML=oe.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 qd="(max-width: 900px)";let sh=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=oe.el("div",{className:"editor-v2-body"}),this.canvasSection=oe.el("div",{className:"editor-v2-canvas"}),this.canvasContainer=oe.el("div",{className:"canvas-container"}),this.cropOverlay=oe.el("canvas",{className:"crop-overlay","aria-hidden":"true"}),this.canvasSection.appendChild(this.canvasContainer),this.canvasSection.appendChild(this.cropOverlay),this.root.appendChild(this.canvasSection),this._isMobile=typeof window<"u"&&((t=window.matchMedia)==null?void 0:t.call(window,qd).matches)===!0,this._isMobile?this._buildMobileShell():this._buildDesktopShell(),typeof window<"u"&&window.matchMedia&&(this._mql=window.matchMedia(qd),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=oe.el("div",{className:"editor-v2-panel","data-testid":"v2-inspector-panel"}),this._categoryTabs=new Ru(this.state,this.editor),this._panel.appendChild(this._categoryTabs.render({onSelect:()=>this._handleDesktopCategoryChange()}));const a=oe.el("div",{className:"panel-body"});this._desktopFilterListSection=oe.el("div",{className:"panel-section"}),this._desktopFilterListSection.appendChild(oe.el("div",{className:"panel-section-title"},oe.el("span",{},"Filters"))),this._filterListView=new Au(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 Lu(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=oe.el("div",{className:"crop-controls-wrapper",style:{display:"none"}}),a.appendChild(this._desktopCropWrapper),this._activeStack=new Qf(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=oe.el("div",{className:"panel-section",style:{display:"none"}}),this._backgroundPanel=new Pu(this.state,this.editor),this._desktopBackgroundSection.appendChild(this._backgroundPanel.render()),a.appendChild(this._desktopBackgroundSection),this._desktopLayerSection=oe.el("div",{className:"panel-section",style:{display:"none"}}),this._layerStackPanel=new Uu(this.state,this.editor),this._desktopLayerSection.appendChild(this._layerStackPanel.render()),a.appendChild(this._desktopLayerSection),this._desktopTextSection=oe.el("div",{className:"panel-section",style:{display:"none"}}),this._textPanel=new Ou(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 rh(this.state,this.filterManager);const a=this._mobileChips.render({onSelect:(r,s)=>{var l,d;this._callbacks.onFilterSelect(r,s),(l=this._mobileDrawer)==null||l.snapTo("full"),(d=this._mobileNav)==null||d.navigateTo("controls")},onRemove:(r,s)=>this._callbacks.onFilterToggle(r,!1,s)});this.root.appendChild(a),this._mobileDrawer=new eh({onSnapChange:r=>{this.canvasContainer&&window.dispatchEvent(new Event("resize"))}}),this._mobileNav=new ih(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 s;r==="controls"&&((s=this._mobileDrawer)==null?void 0:s.snap)==="collapsed"&&this._mobileDrawer.snapTo("half")}});this._mobileCropWrapper=oe.el("div",{className:"crop-controls-wrapper",style:{display:"none"}});const n=oe.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,s,l,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,(s=this._layerStackPanel)==null||s.destroy(),this._layerStackPanel=null,(l=this._textPanel)==null||l.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 l,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",s=n||i||r;this._desktopFilterListSection&&(this._desktopFilterListSection.style.display=t||s?"none":""),(l=this._filterControlsView)!=null&&l.element&&(this._filterControlsView.element.style.display=t||s?"none":""),(d=this._activeStack)!=null&&d.element&&(this._activeStack.element.style.display=t||s?"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")}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 wo(o){if(!Number.isFinite(Number(o)))return 0;const a=Number(o)%360;return a<0?a+360:a}function lh(o,a){const t=wo(o);return(wo(a)-t+540)%360-180}function dh(){return new Date().toISOString()}function tr(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 ch extends oe.EventEmitter{constructor(a,t={}){var r,s,l,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?oe.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=oe.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 oe.PixiRenderer,this._filterManager=new oe.FilterManager(this._state,this._renderer),this._cropManager=new oe.CropManager(this._state,this._renderer),this._removeBgManager=null,this._backgroundRemovalAvailable=!1,((r=this._options.backgroundRemoval)==null?void 0:r.enabled)!==!1&&(this._removeBgManager=new oe.RemoveBgManager({endpoint:(s=this._options.backgroundRemoval)==null?void 0:s.endpoint,optionsEndpoint:(l=this._options.backgroundRemoval)==null?void 0:l.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._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=oe.el("div",{className:`vanilla-image-editor-v2 ${this._state.get("isDarkMode")?"dark":"light"}`}),this._toolbarContainer=oe.el("div",{className:"editor-v2-toolbar"}),this._editorEl.appendChild(this._toolbarContainer),this._layout=new sh(this._state,this._filterManager,this);const{root:a,canvasContainer:t,cropOverlay:n}=this._layout.build({onFilterToggle:(i,r,s)=>this._handleFilterToggle(i,r,s),onFilterSelect:(i,r)=>this._handleFilterSelect(i,r),onFilterChange:(i,r,s,l)=>this._handleFilterChange(i,r,s,l),onFilterReset:(i,r)=>this._handleFilterReset(i,r),onFilterAction:(i,r,s)=>this._handleFilterAction(i,r,s),onClearAll:i=>this.resetAll(i)});this._canvasContainer=t,this._cropOverlay=n,this._editorEl.appendChild(a),this._fileInput=oe.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 oe.Toolbar(this._state,this),this._toolbarContainer.appendChild(this._toolbar.render()),this._cropControls=new oe.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 s=oe.REGISTRY_TO_UI[i.category]||i.category;this._state.get("selectedCategory")!==s&&this._state.set("selectedCategory",s)}}_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 s=this._captureEditorDocumentContext(),l=await this._probeImageDimensions(n);if(!this._isCurrentEditorDocumentContext(s))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:l.width,originalHeight:l.height,sourceHash:null,previewUrl:n}),this._isCurrentEditorDocumentContext(u)?this.setBackgroundMediaSource(c,{fit:t.fit||"cover"}):(URL.revokeObjectURL(n),this._objectUrls.delete(n),null)}catch(s){throw URL.revokeObjectURL(n),this._objectUrls.delete(n),s}}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,s;const a=(s=(r=this._options)==null?void 0:r.backgroundReplacement)==null?void 0:s.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 s=this._resolveBackgroundEndpoint(n,r);if(!s)return!1;const l=this._captureDocumentMaterializationContext(r,i,t),d=tr(i.documentId)?i.documentId:null,c=await fetch(s,{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 f=(u==null?void 0:u.message)||a;throw new Error(f)}return this._isCurrentDocumentMaterializationContext(l)?(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 p,h,v;const i=(h=(p=this._options)==null?void 0:p.backgroundReplacement)==null?void 0:h.assetEndpoint,r=this._state.getEditorDocumentBinding(),s=this._state.getSerializableDocument();if(!i||!(r!=null&&r.documentId)||!s)return null;const l=this._resolveBackgroundEndpoint(i,s);if(!l)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(l,{method:"POST",credentials:"include",headers:{Accept:"application/json"},body:c});if(!u.ok)throw new Error("Background upload failed");const f=await u.json(),m=(v=f==null?void 0:f.asset)==null?void 0:v.source;if(!m||typeof m!="object")throw new Error("Background upload did not return a usable layer source");return{...m,previewUrl:n}}_backgroundMaterializeEndpoint(){var i,r,s,l,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=(l=(s=this._options)==null?void 0:s.backgroundReplacement)==null?void 0:l.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,s;const t=await a.arrayBuffer(),n=await((s=(r=(i=globalThis.crypto)==null?void 0:i.subtle)==null?void 0:r.digest)==null?void 0:s.call(r,"SHA-256",t));if(!n)throw new Error("Background upload hashing is unavailable");return Array.from(new Uint8Array(n)).map(l=>l.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 l,d,c,u;if(this._destroyed)return;(d=(l=this._removeBgManager)==null?void 0:l.cancelActiveRequests)==null||d.call(l,"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 s=await this._renderer.loadTexture(i,{isCurrent:()=>!this._destroyed&&this._loadVersion===n});if(this._destroyed||this._loadVersion!==n){this._revokeObjectUrl(r);return}if(!s){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??(tr((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,f,m;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=dh(),s=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,l=s?{kind:"media",mediaUuid:s,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:s,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:l,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}),(m=(f=this._renderer).renderLayerDocument)==null||m.call(f,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??(tr(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=wo(((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[s,l]of Object.entries(r.values))this._state.setFilterValue(r.id,s,l);if(i!==null){this._state.set("selectedFilter",i);const r=this._filterManager.getFilterDef(i);if(typeof(r==null?void 0:r.category)=="string"){const s=oe.REGISTRY_TO_UI[r.category]??r.category;this._state.set("selectedCategory",s)}}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)??(tr(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 s of a){const l=this._state.getFilterValues(s);t.push({id:s,enabled:!0,values:{...l}})}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:wo(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=wo(this._state.get("transform.rotation")??0),n=wo(a),i=lh(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,s,l,d,c,u,f;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 m=this._activeBackgroundRemovalLayer();if(this._hasSavedEditorDocumentBinding()&&m!==null&&this._backgroundMaterializeEndpoint()&&!await this._materializeCurrentDocument("Background removal materialization failed"))return this.emit("background-removal-stale",{operationId:a.operationId??null,targetLayerId:m.id}),{stale:!0};const p=this._buildSavedBackgroundRemovalContext(a);if(p){const b=await this._removeBgManager.removeSavedMediaBackground(p.request);if(!this._isCurrentBackgroundRemovalContext(p,b))return this.emit("background-removal-stale",{operationId:p.request.operationId,targetLayerId:p.request.targetLayerId}),{stale:!0};const $=(t=b==null?void 0:b.result)==null?void 0:t.source;if(!$||$.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(p,b)})||!this._isCurrentBackgroundRemovalContext(p,b))?(this.emit("background-removal-stale",{operationId:p.request.operationId,targetLayerId:p.request.targetLayerId}),{stale:!0}):this._isCurrentBackgroundRemovalContext(p,b)?(this._state.replaceLayerSource(p.request.targetLayerId,$),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:(s=b==null?void 0:b.result)==null?void 0:s.model,processMs:(l=b==null?void 0:b.result)==null?void 0:l.process_ms,source:$,operationId:p.request.operationId,targetLayerId:p.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:$}):(this.emit("background-removal-stale",{operationId:p.request.operationId,targetLayerId:p.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),w=await this._removeBgManager.preparePreviewRequest(h.imageData,h.options),E=this._resolvePreviewBackgroundRemovalContext(v,w);if(!await this._isCurrentPreviewBackgroundRemovalContext(E))return this.emit("background-removal-stale",{operationId:E.operationId,sourceHash:E.sourceHash,targetLayerId:E.activeLayerId??null}),{stale:!0};const S=await this._removeBgManager.removeBackground(w.blob,w);if(!await this._isCurrentPreviewBackgroundRemovalContext(E,S))return this.emit("background-removal-stale",{operationId:E.operationId,sourceHash:E.sourceHash}),{stale:!0};const k=await this._applyPreviewBackgroundRemovalResult(E,S);return k?(this.emit("background-removed",{model:S.model,processMs:S.processMs,operationId:E.operationId,targetLayerId:E.activeLayerId??null,source:k.source}),{model:S.model,processMs:S.processMs,...k.source?{source:k.source}:{}}):(this.emit("background-removal-stale",{operationId:E.operationId,sourceHash:E.sourceHash,targetLayerId:E.activeLayerId??null}),{stale:!0})}catch(m){throw this.emit("error",{error:m,context:"background-removal"}),m}finally{(f=(u=this._state)==null?void 0:u.set)==null||f.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 s;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=(s=i==null?void 0:i.source)==null?void 0:s.sourceHash;return t&&(typeof r!="string"||!/^[a-f0-9]{64}$/i.test(r))?null:i}_buildSavedBackgroundRemovalContext(a={}){var u,f,m,p,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}),s=r==null?void 0:r.id,l=(u=r==null?void 0:r.source)==null?void 0:u.sourceHash;if(!s||typeof l!="string"||!/^[a-f0-9]{64}$/i.test(l))return null;const d=a.operationId||((m=(f=globalThis.crypto)==null?void 0:f.randomUUID)==null?void 0:m.call(f))||`op-${Date.now()}-${Math.random().toString(16).slice(2)}`,c={loadVersion:this._loadVersion,activeLayerId:s,documentRevisionId:n.documentRevisionId,documentSignature:this._documentMaterializationSignature(t),sourceHash:l,request:{targetMediaUuid:i,operationId:d,documentId:n.documentId,documentRevisionId:n.documentRevisionId,targetLayerId:s,expectedSourceHash:l,tier:a.tier||((h=(p=this._options)==null?void 0:p.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,s;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((s=(r=this._renderer).renderLayerDocument)==null?void 0:s.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 s;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||((s=r==null?void 0:r.source)==null?void 0:s.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=oe.el("div",{className:"editor-loading-overlay"},oe.el("div",{className:"editor-loading-spinner"}),oe.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()}destroy(){var a,t,n,i,r,s,l;this._destroyed=!0,(t=(a=this._removeBgManager)==null?void 0:a.cancelActiveRequests)==null||t.call(a,"editor-destroy");for(const d of this._objectUrls)try{URL.revokeObjectURL(d)}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(),(s=this._layout)==null||s.destroy(),(l=this._editorEl)==null||l.remove(),this._container=null,this._state=null,this.emit("destroyed"),this.removeAllListeners()}}function uh(o,a){try{let t=oe.getFilter(o);if(t||(oe.registerCorePixiFilters(),t=oe.getFilter(o)),!t){try{const r=oe.getAllFilters()}catch{}return null}const n={...t.defaultParams,...a};return t.createFilter(n)}catch{return null}}const mh=78e5,ph=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,s=null;function l(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,w,E;try{if(!r){n("error",new Error("Editor not initialized"));return}const S=await((v=r.exportBlob)==null?void 0:v.call(r,"png",.92,{maxPixels:mh}));if(!S){n("error",new Error("Failed to export image — the image could not be processed"));return}const k=r.getSerializableState(),b={blob:S.blob,mimeType:S.blob.type||"image/png",dimensions:{width:S.width,height:S.height},state:k},$=((w=r.getSerializableDocument)==null?void 0:w.call(r))??null;if($){const V=((E=r.getEditorDocumentBinding)==null?void 0:E.call(r))??null;b.document=$,b.documentId=(V==null?void 0:V.documentId)??(l($.id)?$.id:null),b.documentRevisionId=(V==null?void 0:V.documentRevisionId)??null,b.documentRevisionNumber=(V==null?void 0:V.documentRevisionNumber)??$.revision??null}n("save",b)}catch(S){n("error",S instanceof Error?S:new Error("Failed to export image"))}}function u(){n("cancel")}function f(v){if(v instanceof Error)return v;if(v!==null&&typeof v=="object"&&"error"in v){const w=v.error;if(w instanceof Error)return w;if(typeof w=="string"&&w.trim()!=="")return new Error(w)}return typeof v=="string"&&v.trim()!==""?new Error(v):new Error("Failed to load image")}function m(v){n("error",f(v))}function p(){if(!i.value||r)return;window.PIXI=Pt,oe.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 w=t.editorVersion==="v2"?ch:oe.VanillaImageEditor,E=new w(i.value,v);r=E,E.setFilterRegistry({getAllFilters:oe.getAllFilters,getFilter:oe.getFilter,getFiltersByCategory:oe.getFiltersByCategory}),E.save=function(){c()},E.on("cancel",u),E.on("error",m),t.initialImage&&E.loadImage(t.initialImage,d())}e.onMounted(()=>{i.value&&(i.value.clientWidth>0?p():(s=new ResizeObserver(v=>{const w=v[0];w&&w.contentRect.width>0&&!r&&(p(),s==null||s.disconnect(),s=null)}),s.observe(i.value)))});const h=()=>{!r||!t.initialImage||r.loadImage(t.initialImage,d())};return e.watch(()=>t.initialImage,(v,w)=>{!r||!v||v===w||h()}),e.watch(()=>t.sessionKey,(v,w)=>{v!==w&&h()}),e.watch(()=>t.initialState,(v,w)=>{v!==w&&h()}),e.watch(()=>[t.initialDocument,t.initialDocumentId,t.initialDocumentRevisionId,t.initialDocumentRevisionNumber],(v,w)=>{v!==w&&h()}),e.onUnmounted(()=>{s==null||s.disconnect(),s=null,r&&(r.destroy(),r=null)}),(v,w)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:i,class:"vanilla-editor-wrapper","data-testid":"vanilla-image-editor"},null,512))}}),Fe=(o,a)=>{const t=o.__vccOpts||o;for(const[n,i]of a)t[n]=i;return t},zu=Fe(ph,[["__scopeId","data-v-8ab74f83"]]),fh={class:"editor-modal-panel"},hh={class:"editor-fill"},vh=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),s=e.ref(!1),l=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&&(l.value=document.activeElement,c())},{immediate:!0});const u=async v=>{try{if(s.value=!0,t.saveHandler){await t.saveHandler(v);return}n("save",v)}catch(w){d(w instanceof Error?w:new Error("Failed to save image"))}finally{s.value=!1}},f=()=>{n("cancel"),p()},m=()=>{s.value||p()},p=()=>{r.value=!1,n("update:modelValue",!1),l.value&&l.value instanceof HTMLElement&&(l.value.focus(),l.value=null)},h=v=>{if(v.key==="Escape"&&r.value&&!s.value){p();return}if(v.key==="Tab"&&r.value&&i.value){const w=i.value.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(w.length===0)return;const E=w[0],S=w[w.length-1];v.shiftKey&&document.activeElement===E?(v.preventDefault(),S.focus()):!v.shiftKey&&document.activeElement===S&&(v.preventDefault(),E.focus())}};return e.onMounted(()=>{document.addEventListener("keydown",h)}),e.onBeforeUnmount(()=>{document.removeEventListener("keydown",h)}),(v,w)=>(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(m,["escape"])},[e.createElementVNode("div",{class:"editor-modal-backdrop",onClick:m}),e.createElementVNode("div",fh,[e.createElementVNode("div",hh,[e.createVNode(zu,{"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:f,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)]))}}),ju=Fe(vh,[["__scopeId","data-v-bd4e671f"]]),gh={class:"media-workspace"},bh={class:"media-workspace-toolbar"},yh={class:"media-workspace-label"},wh=["value"],kh={class:"media-workspace-grid"},_h=["onClick"],Eh=e.defineComponent({__name:"MediaWorkspace",props:{apiScope:{},subScopes:{},initialScopeId:{}},emits:["scope-change","update:media","upload","preview"],setup(o,{emit:a}){var f;const t=o,n=a,i=xa(),r=e.ref(t.initialScopeId??((f=t.subScopes[0])==null?void 0:f.id)??""),s=e.computed(()=>t.subScopes),l=e.computed(()=>s.value.find(m=>m.id===r.value));let d=null;function c(){d&&(d(),d=null),t.apiScope&&(d=$u({apiScope:t.apiScope,isAdmin:t.apiScope==="admin"}))}async function u(){var p;const m={};(p=l.value)!=null&&p.collection&&(m.collection=l.value.collection),await i.fetchMedia(1,m),n("update:media",[...i.items])}return e.watch(()=>t.initialScopeId,m=>{m&&m!==r.value&&(r.value=m)}),e.watch(()=>t.subScopes,m=>{if(m.length===0){r.value="";return}m.some(p=>p.id===r.value)||(r.value=m[0].id)},{deep:!0}),e.watch(()=>t.apiScope,()=>{c(),u()}),e.watch(r,m=>{m&&(n("scope-change",m),u())}),e.onMounted(()=>{c(),u()}),e.onUnmounted(()=>{d&&(d(),d=null)}),(m,p)=>(e.openBlock(),e.createElementBlock("div",gh,[e.createElementVNode("div",bh,[e.createElementVNode("label",yh,[p[2]||(p[2]=e.createElementVNode("span",{class:"media-workspace-label-text"},"Scope",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":p[0]||(p[0]=h=>r.value=h),"data-testid":"scope-select",class:"media-workspace-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.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:p[1]||(p[1]=h=>n("upload"))}," Upload ")]),e.createElementVNode("div",kh,[(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,_h))),128))])]))}}),xh=Fe(Eh,[["__scopeId","data-v-895f26fe"]]),Sh={class:"managed-media-gallery"},Ch={class:"gallery-grid"},Vh=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",Sh,[e.createElementVNode("div",Ch,[e.renderSlot(a.$slots,"default",{},void 0,!0)])]))}}),Nh=Fe(Vh,[["__scopeId","data-v-10a9b8c5"]]),vr="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>",Kl="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>",Th="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>",Jl="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>",Bh="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>",Ih="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>",Yd="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>",Qd="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>",ni="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>",Mh="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>",Wu="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>",Hu="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>",ec="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>",Fh="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>",$h="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>",tc="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>",Gn="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>",ac="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>",Dh="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>",kn="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>",Rh="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>",Ko="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>",sl="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>",Ah="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>",nc="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>",Tr="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>",Co="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>",Lh="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>",Ph="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>",Uh="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>",Oh="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>",oi="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>",oc="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>",As="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>",zh="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>",jh="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>",Ls="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>",Wh="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>",Hh="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>",Zh="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>",Gh="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>",Zu="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>",ql="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>",Xh="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>",Kh="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>",Jh="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>",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 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>",Gu="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>",Yh="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>",Qh="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>",Yl="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>",ev="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>",tv="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>",eo="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>",av="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>",ic="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>",Kr="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>",ov="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>",Ps="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>",wn="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>",Jo="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>",rc="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>",iv="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>",Xu="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>",Br="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>",Ku="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>",rv="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>",sv="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>",lv="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>",dv="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>",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-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>",uv="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>",mv="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>",ar="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 sc=()=>{};function pv(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 fv(o,a={}){let t,n,i=sc;const r=d=>{clearTimeout(d),i(),i=sc};let s;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((f,m)=>{i=a.rejectOnCancel?m:f,s=d,u&&!n&&(n=setTimeout(()=>{t&&r(t),n=null,f(s())},u)),t=setTimeout(()=>{n&&r(n),n=null,f(d())},c)})}}function hv(o,a=200,t={}){return pv(fv(a,t),o)}const qo=new Map;function vv(o){const a=e.getCurrentScope();function t(l){var d;const c=qo.get(o)||new Set;c.add(l),qo.set(o,c);const u=()=>i(l);return(d=a==null?void 0:a.cleanups)==null||d.push(u),u}function n(l){function d(...c){i(d),l(...c)}return t(d)}function i(l){const d=qo.get(o);d&&(d.delete(l),d.size||r())}function r(){qo.delete(o)}function s(l,d){var c;(c=qo.get(o))==null||c.forEach(u=>u(l,d))}return{on:t,once:n,off:i,emit:s,reset:r}}function Ju(){var r,s;const o=typeof window<"u"&&"Capacitor"in window&&((s=(r=window.Capacitor)==null?void 0:r.isNativePlatform)==null?void 0:s.call(r));return{selection:()=>{var l,d;if(o)try{const c=(d=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:d.Haptics;c&&c.impact({style:"LIGHT"})}catch{}else"vibrate"in navigator&&navigator.vibrate(10)},success:()=>{var l,d;if(o)try{const c=(d=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:d.Haptics;c&&c.impact({style:"MEDIUM"})}catch{}else"vibrate"in navigator&&navigator.vibrate(30)},error:()=>{var l,d;if(o)try{const c=(d=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:d.Haptics;c&&c.impact({style:"HEAVY"})}catch{}else"vibrate"in navigator&&navigator.vibrate([50,50,50])},notification:()=>{var l,d;if(o)try{const c=(d=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:d.Haptics;c&&c.notification({type:"SUCCESS"})}catch{}else"vibrate"in navigator&&navigator.vibrate([20,100,20])}}}function qu(o){const a=e.ref(new Set),t=e.ref(null),n=e.ref(-1),i=vv("media-selection"),r=Ju(),s=e.computed(()=>o.value.filter($=>a.value.has($.uuid))),l=e.computed(()=>a.value.size);e.watch(a,$=>{i.emit({type:"selection:changed",count:$.size,selectedIds:Array.from($)})},{deep:!0});const d=e.computed(()=>o.value.length>0&&o.value.every($=>a.value.has($.uuid))),c=e.computed(()=>o.value.some($=>a.value.has($.uuid)));function u($){return a.value.has($)}function f($){a.value.has($)?(a.value.delete($),t.value===$&&(t.value=null,n.value=-1)):(a.value.add($),t.value=$,n.value=o.value.findIndex(V=>V.uuid===$),a.value.size===1&&r.selection())}function m($){a.value.add($),t.value=$,n.value=o.value.findIndex(V=>V.uuid===$)}function p($){a.value.delete($),t.value===$&&(t.value=null,n.value=-1)}function h(){o.value.forEach($=>a.value.add($.uuid))}function v(){a.value.clear(),t.value=null,n.value=-1}function w(){d.value?v():h()}function E($,V){const I=o.value.findIndex(x=>x.uuid===$);if(I!==-1)if(V!=null&&V.shiftKey&&n.value!==-1){const x=Math.min(n.value,I),N=Math.max(n.value,I);for(let L=x;L<=N;L++)a.value.add(o.value[L].uuid)}else f($)}function S(){if(o.value.length===0)return;let $=n.value+1;$>=o.value.length&&($=0),v(),m(o.value[$].uuid)}function k(){if(o.value.length===0)return;let $=n.value-1;$<0&&($=o.value.length-1),v(),m(o.value[$].uuid)}function b($){switch($.key){case"ArrowDown":$.preventDefault(),S();break;case"ArrowUp":$.preventDefault(),k();break;case"a":($.ctrlKey||$.metaKey)&&($.preventDefault(),h());break;case"Escape":$.preventDefault(),v();break;case" ":t.value&&($.preventDefault(),f(t.value));break}}return{selectedIds:e.computed(()=>a.value),selectedItems:s,selectedCount:l,isAllSelected:d,isSomeSelected:c,lastSelectedId:e.computed(()=>t.value),isSelected:u,toggle:f,select:m,deselect:p,selectAll:h,clear:v,toggleAll:w,rangeSelect:E,selectNext:S,selectPrevious:k,handleKeydown:b,selectionBus:i}}const gv={class:"flex items-center justify-between w-full px-4"},bv={class:"p-4"},yv={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"},kv=["value"],_v={class:"flex gap-2 mt-4"},Ev={class:"flex justify-end mb-4"},xv={key:1,class:"flex justify-center items-center h-64"},Sv={key:2,class:"flex flex-col items-center justify-center h-64 text-center"},Cv={class:"text-sm text-theme-secondary"},Vv={key:0},Nv={class:"mb-4"},Tv={class:"mb-4"},Bv={class:"flex gap-2"},Iv={class:"flex items-center justify-between px-4 py-2"},Mv={class:"text-sm text-theme-secondary"},Fv={key:0},$v={key:0},Dv={key:1},Rv={class:"flex gap-2"},Av=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"),s=e.ref(""),l=e.ref(!1),d=e.ref([]),{selectedItems:c}=e.toRefs(t),u=e.ref(new Set(c.value)),f=e.ref(!1),m=e.ref({}),p=e.ref(["images","documents","videos"]),h=e.ref(1),v=e.ref(!0),w=e.ref(!1),E=Du(),S=qu(d);function k(O){var me;const D=O.conversion_urls||{},J=O.proxy_url||O.original_url||O.url||"",Z=D.thumb||D.preview||O.preview_url||O.thumbnail_url||J,ie=O.custom_properties||{},se=ie.width,Ue=ie.height;return{...O,uuid:O.uuid,name:O.name||O.file_name,file_name:O.file_name,filename:O.file_name,mime_type:O.mime_type,size:O.size,collection_name:O.collection_name||"images",disk:O.disk,original_url:J,url:J,thumbnail_url:Z,conversions:O.conversions||{},conversion_urls:D,generated_conversions:O.generated_conversions||{},custom_properties:ie,caption:O.caption||null,alt_text:O.alt_text||null,created_at:O.created_at,updated_at:O.updated_at,is_image:((me=O.mime_type)==null?void 0:me.startsWith("image/"))||!1,...typeof se=="number"?{width:se}:{},...typeof Ue=="number"?{height:Ue}:{},...O.formatted_size!==void 0?{formatted_size:O.formatted_size}:{}}}e.watch(()=>t.selectedItems,O=>{u.value=new Set(O),S.clear(),O.forEach(D=>S.select(D))});const b=e.computed(()=>{var D;let O=d.value;return(D=m.value.types)!=null&&D.length&&(O=O.filter(J=>{var ie,se;const Z=(ie=J.mime_type)==null?void 0:ie.split("/")[0];return(se=m.value.types)==null?void 0:se.includes(Z)})),(m.value.sizeMin!==void 0||m.value.sizeMax!==void 0)&&(O=O.filter(J=>{const Z=J.size/1048576;return!(m.value.sizeMin!==void 0&&Z<m.value.sizeMin||m.value.sizeMax!==void 0&&Z>m.value.sizeMax)})),O}),$=e.computed(()=>{var D;let O=0;return m.value.search&&O++,m.value.collection&&O++,(m.value.dateFrom||m.value.dateTo)&&O++,(D=m.value.types)!=null&&D.length&&(O+=m.value.types.length),(m.value.sizeMin!==void 0||m.value.sizeMax!==void 0)&&O++,O}),V=e.computed(()=>{const O=S.selectedCount.value;return O===0?"Select Media":`Select ${t.selectionMode==="multiple"?`${O} ${O===1?"Item":"Items"}`:"Item"}`}),I=e.computed(()=>{const O=S.selectedCount.value;return!!(O===0||t.selectionMode==="single"&&O>1||t.maxSelection&&O>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 N(O=!0){O?(l.value=!0,d.value=[],h.value=1,v.value=!0):w.value=!0;try{const D={collection:m.value.collection||t.collection,per_page:24};switch((s.value||m.value.search)&&(D.search=s.value||m.value.search||""),m.value.dateFrom&&(D.from_date=m.value.dateFrom),m.value.dateTo&&(D.to_date=m.value.dateTo),i.value){case"recent":await E.fetchMedia(h.value,D),O?d.value=E.items.map(J=>k(J)):d.value=[...d.value,...E.items.map(J=>k(J))],v.value=E.currentPage<E.totalPages;break;case"model":if(t.modelType&&t.modelId){const J=await E.fetchModelMedia(t.modelType,t.modelId,D.collection,D.search);d.value=J?J.map(Z=>k(Z)):[],v.value=!1}break;case"library":await E.fetchMedia(h.value,D),O?d.value=E.items.map(J=>k(J)):d.value=[...d.value,...E.items.map(J=>k(J))],v.value=E.currentPage<E.totalPages;break}}catch{}finally{l.value=!1,w.value=!1}}async function L(O){if(!v.value||w.value){O!=null&&O.target&&O.target.complete();return}h.value++,await N(!1),O!=null&&O.target&&(O.target.complete(),v.value||(O.target.disabled=!0))}function C(O){return O==="recent"||O==="model"||O==="library"}function T(O){i.value=O,N()}function y(O){typeof O=="string"&&C(O)&&T(O)}async function R(O){t.selectionMode==="single"?(S.clear(),S.select(O.uuid)):(S.toggle(O.uuid),t.maxSelection&&S.selectedCount.value>t.maxSelection&&(S.deselect(O.uuid),await(await H.toastController.create({message:`Maximum ${t.maxSelection} items can be selected`,duration:2e3,color:"warning"})).present()))}function U(){n("confirm",S.selectedItems.value)}function z(){n("close")}function W(O){}const B=e.ref(null),P=e.ref(!1);function X(O){B.value=O,P.value=!0}function K(O){const D=d.value.findIndex(Z=>Z.uuid===O.uuid);D!==-1&&(d.value[D]=O);const J={};O.alt_text!==void 0&&(J.alt_text=O.alt_text),O.caption!==void 0&&(J.caption=O.caption),O.custom_properties!==void 0&&(J.custom_properties=O.custom_properties),E.updateMedia(O.uuid,J)}function be(){N()}function Ne(){m.value={},s.value="",N()}const ue=hv(()=>{N(!0)},300);e.watch(s,()=>{t.isOpen&&ue()});async function re(O){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 E.deleteMedia(O),await N()}}]})).present()}catch{}}return e.watch(()=>t.isOpen,O=>{O&&N()}),e.onMounted(()=>{t.selectedItems.length>0&&t.selectedItems.forEach(O=>S.select(O))}),(O,D)=>{const J=e.resolveComponent("AdminMediaGrid"),Z=e.resolveComponent("AdminMediaListItem");return e.openBlock(),e.createBlock(e.unref(H.IonModal),{"is-open":O.isOpen,onDidDismiss:z,"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:z},{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",gv,[e.createVNode(e.unref(H.IonSegment),{value:i.value,onIonChange:D[0]||(D[0]=ie=>y(ie.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(()=>[...D[15]||(D[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(()=>[...D[16]||(D[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(()=>[...D[17]||(D[17]=[e.createTextVNode("Library",-1)])]),_:1})]),_:1})]),_:1},8,["value"]),e.createVNode(e.unref(H.IonButton),{fill:"clear",size:"small",onClick:D[1]||(D[1]=ie=>f.value=!f.value),class:"relative"},{"icon-only":e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{name:"filter-outline"})]),default:e.withCtx(()=>[$.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($.value),1)]),_:1})):e.createCommentVNode("",!0)]),_:1})])]),_:1})]),_:1}),e.createVNode(e.unref(H.IonContent),null,{default:e.withCtx(()=>[e.createElementVNode("div",bv,[f.value?(e.openBlock(),e.createElementBlock("div",yv,[e.createElementVNode("div",wv,[e.createElementVNode("div",null,[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...D[18]||(D[18]=[e.createTextVNode("Collection",-1)])]),_:1}),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":D[2]||(D[2]=ie=>m.value.collection=ie),class:"w-full p-2 border rounded"},[D[19]||(D[19]=e.createElementVNode("option",{value:""},"All Collections",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,ie=>(e.openBlock(),e.createElementBlock("option",{key:ie,value:ie},e.toDisplayString(ie),9,kv))),128))],512),[[e.vModelSelect,m.value.collection]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...D[20]||(D[20]=[e.createTextVNode("From Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":D[3]||(D[3]=ie=>m.value.dateFrom=ie),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,m.value.dateFrom]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...D[21]||(D[21]=[e.createTextVNode("To Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":D[4]||(D[4]=ie=>m.value.dateTo=ie),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,m.value.dateTo]])])]),e.createElementVNode("div",_v,[e.createVNode(e.unref(H.IonButton),{size:"small",onClick:be},{default:e.withCtx(()=>[...D[22]||(D[22]=[e.createTextVNode("Apply",-1)])]),_:1}),e.createVNode(e.unref(H.IonButton),{size:"small",fill:"clear",onClick:Ne},{default:e.withCtx(()=>[...D[23]||(D[23]=[e.createTextVNode("Clear",-1)])]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(e.unref(H.IonSearchbar),{modelValue:s.value,"onUpdate:modelValue":D[5]||(D[5]=ie=>s.value=ie),placeholder:"Search media...",debounce:300,class:"mb-4"},null,8,["modelValue"]),e.createElementVNode("div",Ev,[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:D[6]||(D[6]=ie=>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:D[7]||(D[7]=ie=>r.value="list")},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{name:"list-outline"})]),_:1},8,["fill"])]),_:1})]),l.value?(e.openBlock(),e.createElementBlock("div",xv,[e.createVNode(e.unref(H.IonSpinner),{name:"crescent"})])):b.value.length===0?(e.openBlock(),e.createElementBlock("div",Sv,[e.createVNode(e.unref(H.IonIcon),{name:"images-outline",class:"text-6xl text-theme-secondary mb-4"}),D[24]||(D[24]=e.createElementVNode("h3",{class:"text-lg font-medium text-theme mb-2"}," No Media Found ",-1)),e.createElementVNode("p",Cv,e.toDisplayString(s.value?"Try adjusting your search":"No media items available"),1)])):r.value==="grid"?(e.openBlock(),e.createBlock(J,{key:3,"media-items":b.value,"selected-items":e.unref(S).selectedItems.value,"is-loading":!1,"selection-mode":!0,columns:{mobile:2,sm:3,md:4,lg:5,xl:6},onToggleSelect:R,onPreview:W,onEdit:X,onDelete:re},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,(ie,se)=>(e.openBlock(),e.createBlock(Z,{key:ie.uuid,media:ie,selected:e.unref(S).isSelected(ie.uuid),"selection-mode":!0,index:se,onToggleSelect:R,onPreview:W,onEdit:X,onDelete:re},null,8,["media","selected","index"]))),128))]),_:1})),!l.value&&b.value.length>0&&i.value!=="model"?(e.openBlock(),e.createBlock(e.unref(H.IonInfiniteScroll),{key:5,threshold:"100px",onIonInfinite:D[8]||(D[8]=ie=>L(ie))},{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":P.value,onDidDismiss:D[14]||(D[14]=ie=>P.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:D[9]||(D[9]=ie=>P.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(()=>[...D[25]||(D[25]=[e.createTextVNode("Edit Media Info",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(H.IonContent),{class:"p-4"},{default:e.withCtx(()=>[B.value?(e.openBlock(),e.createElementBlock("div",Vv,[e.createElementVNode("div",Nv,[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...D[26]||(D[26]=[e.createTextVNode("Caption",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":D[10]||(D[10]=ie=>B.value.caption=ie),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter caption..."},null,512),[[e.vModelText,B.value.caption]])]),e.createElementVNode("div",Tv,[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...D[27]||(D[27]=[e.createTextVNode("Alt Text",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":D[11]||(D[11]=ie=>B.value.alt_text=ie),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter alt text..."},null,512),[[e.vModelText,B.value.alt_text]])]),e.createElementVNode("div",Bv,[e.createVNode(e.unref(H.IonButton),{onClick:D[12]||(D[12]=ie=>K(B.value))},{default:e.withCtx(()=>[...D[28]||(D[28]=[e.createTextVNode("Save",-1)])]),_:1}),e.createVNode(e.unref(H.IonButton),{fill:"clear",onClick:D[13]||(D[13]=ie=>P.value=!1)},{default:e.withCtx(()=>[...D[29]||(D[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",Iv,[e.createElementVNode("div",Mv,[e.unref(S).selectedCount.value>0?(e.openBlock(),e.createElementBlock("span",Fv,[e.createTextVNode(e.toDisplayString(e.unref(S).selectedCount.value)+" selected ",1),t.maxSelection?(e.openBlock(),e.createElementBlock("span",$v," / "+e.toDisplayString(t.maxSelection)+" max ",1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("span",Dv," Select "+e.toDisplayString(t.selectionMode==="multiple"?"items":"an item"),1))]),e.createElementVNode("div",Rv,[e.createVNode(e.unref(H.IonButton),{fill:"clear",onClick:z},{default:e.withCtx(()=>[...D[30]||(D[30]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(H.IonButton),{disabled:I.value,onClick:U},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(V.value),1)]),_:1},8,["disabled"])])])]),_:1})]),_:1})]),_:1},8,["is-open"])}}}),Lv=Fe(Av,[["__scopeId","data-v-9a8c0954"]]),Pv={key:1,class:"flex flex-col items-center justify-center py-16"},Uv=["draggable","onDragstart","onDragover","onDrop"],Ov={key:0,class:"absolute top-2 left-2 z-20"},zv=["checked","onChange"],jv={key:2,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-move"},Wv=["data-media-id"],Hv={key:0,class:"w-full h-full flex items-center justify-center"},Zv=["src","alt","onError","onLoad"],Gv={key:2,class:"w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-700"},Xv={class:"text-center"},Kv={class:"text-4xl text-gray-400 mb-2"},Jv={class:"text-sm font-medium text-gray-500"},qv={class:"absolute inset-0 bg-black/70 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2"},Yv=["onClick"],Qv=["onClick"],eg=["onClick"],tg={class:"p-3"},ag={class:"text-sm font-medium truncate mb-1"},ng={class:"text-xs text-gray-600 dark:text-gray-400"},og={key:0},ig={key:0,class:"text-xs text-gray-500 dark:text-gray-500 mt-1 truncate"},rg=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),s=e.ref(new Set),l=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,N){t.reorderable&&(i.value=x,I.dataTransfer&&(I.dataTransfer.effectAllowed="move",I.dataTransfer.setData("text/html","")))}function f(I,x){t.reorderable&&(I.preventDefault(),r.value=x)}function m(){r.value=null}function p(I,x){if(!t.reorderable||!i.value)return;I.preventDefault();const N=[...t.mediaItems],L=N.findIndex(C=>{var T;return C.uuid===((T=i.value)==null?void 0:T.uuid)});if(L!==-1&&L!==x&&i.value){const[C]=N.splice(L,1);N.splice(x,0,C),n("reorder",N)}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 N;return I.thumbnail_url||((N=I.conversion_urls)==null?void 0:N.thumb)||I.original_url||I.url||""}function w(I){var L,C,T;const x=((L=I.mime_type)==null?void 0:L.startsWith("image/"))||!1,N=!!(I.thumbnail_url||(C=I.conversion_urls)!=null&&C.thumb||(T=I.conversion_urls)!=null&&T.preview||I.original_url||I.url);return x&&N}function E(I){var x;return((x=I.split(".").pop())==null?void 0:x.toUpperCase())||""}function S(I){var N;const x=((N=I.mime_type)==null?void 0:N.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&&(l.value=new IntersectionObserver(I=>{I.forEach(x=>{var N;if(x.isIntersecting){const L=x.target.getAttribute("data-media-id");L&&(s.value.add(L),(N=l.value)==null||N.unobserve(x.target))}})},{rootMargin:"50px"}))}),e.onUnmounted(()=>{l.value&&l.value.disconnect()});function k(I){return!0}function b(){l.value&&e.nextTick(()=>{document.querySelectorAll("[data-media-id]").forEach(x=>{var L;const N=x.getAttribute("data-media-id");N&&!s.value.has(N)&&((L=l.value)==null||L.observe(x))})})}e.watch(()=>t.mediaItems,()=>{s.value.clear(),b()},{immediate:!0,deep:!0});function $(I,x){const N=I.target;delete N.dataset.fallbackIndex}function V(I,x){const N=I.target,L=N.closest("[data-media-id]"),C=[x.original_url,x.url,x.thumbnail_url,"preview_url"in x?x.preview_url:void 0].filter(T=>T&&T.trim()!==""&&T!==N.src);if(C.length>0&&N.dataset.fallbackIndex){const T=parseInt(N.dataset.fallbackIndex);if(T<C.length){N.dataset.fallbackIndex=(T+1).toString(),N.src=C[T]||"";return}}else if(C.length>0){N.dataset.fallbackIndex="1",N.src=C[0]||"";return}if(N.style.display="none",L&&!L.querySelector(".media-fallback-icon")){const y=document.createElement("div");y.className="media-fallback-icon w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-800",y.innerHTML=`
|
|
2
|
-
<div class="text-center">
|
|
3
|
-
<div class="text-4xl text-gray-400 mb-2">${S(x)}</div>
|
|
4
|
-
<p class="text-sm font-medium text-gray-500">${E(x.file_name)}</p>
|
|
5
|
-
</div>
|
|
6
|
-
`,L.appendChild(y)}}return(I,x)=>I.isLoading?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(c.value)},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(12,N=>e.createElementVNode("div",{key:`skeleton-${N}`,class:"relative"},[...x[1]||(x[1]=[e.createStaticVNode('<div class="bg-white dark:bg-gray-800 rounded-lg shadow" data-v-f0c343b7><div class="aspect-square bg-gray-200 dark:bg-gray-700 animate-pulse rounded-t-lg" data-v-f0c343b7></div><div class="p-3" data-v-f0c343b7><div class="h-4 bg-gray-200 dark:bg-gray-700 animate-pulse rounded w-3/4 mb-2" data-v-f0c343b7></div><div class="h-3 bg-gray-200 dark:bg-gray-700 animate-pulse rounded w-1/2" data-v-f0c343b7></div></div></div>',1)])])),64))],2)):!I.mediaItems||!I.mediaItems.length?(e.openBlock(),e.createElementBlock("div",Pv,[x[2]||(x[2]=e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-16 h-16 text-gray-400 mb-4"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m2.25 15.75 5.159-5.159a2.25 2.25 0 0 1 3.182 0l5.159 5.159m-1.5-1.5 1.409-1.409a2.25 2.25 0 0 1 3.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 0 0 1.5-1.5V6a1.5 1.5 0 0 0-1.5-1.5H3.75A1.5 1.5 0 0 0 2.25 6v12a1.5 1.5 0 0 0 1.5 1.5Zm10.5-11.25h.008v.008h-.008V8.25Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Z"})],-1)),x[3]||(x[3]=e.createElementVNode("h3",{class:"text-lg font-medium mb-2"}," No Media Items ",-1)),x[4]||(x[4]=e.createElementVNode("p",{class:"text-sm text-gray-600 dark:text-gray-400 mb-4"}," Upload some files to get started ",-1)),e.createElementVNode("button",{onClick:x[0]||(x[0]=N=>n("upload")),class:"px-3 py-2 bg-blue-500 text-white rounded hover:bg-blue-600"}," Upload Media ")])):(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(c.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(I.mediaItems,(N,L)=>(e.openBlock(),e.createElementBlock("div",{key:N.uuid,class:e.normalizeClass(["relative group",{"ring-2 ring-blue-500 ring-offset-2":r.value===L}]),draggable:I.reorderable,onDragstart:C=>u(C,N),onDragover:C=>f(C,L),onDragleave:m,onDrop:C=>p(C,L)},[I.selectionMode?(e.openBlock(),e.createElementBlock("div",Ov,[e.createElementVNode("input",{type:"checkbox",checked:d(N),onChange:C=>n("toggleSelect",N),class:"w-5 h-5 bg-white dark:bg-gray-800 rounded cursor-pointer"},null,40,zv)])):e.createCommentVNode("",!0),I.$slots.badge?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["absolute top-2 z-20",I.selectionMode?"left-10":"left-2"])},[e.renderSlot(I.$slots,"badge",{media:N,index:L},void 0,!0)],2)):e.createCommentVNode("",!0),I.reorderable?(e.openBlock(),e.createElementBlock("div",jv,[...x[5]||(x[5]=[e.createElementVNode("div",{class:"bg-black/70 text-white p-2 rounded"},[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-4 h-4"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5"})])],-1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden h-full",{"ring-2 ring-blue-500":d(N)}])},[e.createElementVNode("div",{class:"relative aspect-square bg-gray-100 dark:bg-gray-700 overflow-hidden","data-media-id":N.uuid},[w(N)&&!k(N.uuid)?(e.openBlock(),e.createElementBlock("div",Hv,[...x[6]||(x[6]=[e.createElementVNode("div",{class:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"},null,-1)])])):e.createCommentVNode("",!0),w(N)&&k(N.uuid)?(e.openBlock(),e.createElementBlock("img",{key:1,src:v(N),alt:N.alt_text||N.file_name,class:"w-full h-full object-cover",loading:"lazy",onError:C=>V(C,N),onLoad:C=>$(C)},null,40,Zv)):(e.openBlock(),e.createElementBlock("div",Gv,[e.createElementVNode("div",Xv,[e.createElementVNode("div",Kv,e.toDisplayString(S(N)),1),e.createElementVNode("p",Jv,e.toDisplayString(E(N.file_name)),1)])])),e.createElementVNode("div",qv,[e.createElementVNode("button",{onClick:C=>n("preview",N),class:"p-2 bg-white/20 text-white rounded hover:bg-white/30",title:"Preview"},[...x[7]||(x[7]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-5 h-5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"}),e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})],-1)])],8,Yv),I.showEditButton&&w(N)?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:C=>n("edit",N),class:"p-2 bg-white/20 text-white rounded hover:bg-white/30",title:"Edit"},[...x[8]||(x[8]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-5 h-5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0115.75 21H5.25A2.25 2.25 0 013 18.75V8.25A2.25 2.25 0 015.25 6H10"})],-1)])],8,Qv)):e.createCommentVNode("",!0),e.createElementVNode("button",{onClick:C=>n("delete",N.uuid),class:"p-2 bg-red-500/20 text-red-300 rounded hover:bg-red-500/30",title:"Delete"},[...x[9]||(x[9]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-5 h-5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})],-1)])],8,eg)])],8,Wv),e.createElementVNode("div",tg,[e.createElementVNode("h4",ag,e.toDisplayString(N.file_name),1),e.createElementVNode("p",ng,[e.createTextVNode(e.toDisplayString(h(N.size))+" ",1),N.width&&N.height?(e.openBlock(),e.createElementBlock("span",og," • "+e.toDisplayString(N.width)+"x"+e.toDisplayString(N.height),1)):e.createCommentVNode("",!0)]),N.caption?(e.openBlock(),e.createElementBlock("p",ig,e.toDisplayString(N.caption),1)):e.createCommentVNode("",!0)])],2)],42,Uv))),128))],2))}}),sg=Fe(rg,[["__scopeId","data-v-f0c343b7"]]),lg={class:"model-media-manager"},dg=["accept","multiple"],cg={class:"flex items-center justify-between mb-4"},ug={key:0,class:"text-lg font-medium"},mg={class:"flex gap-2"},pg={key:0,class:"flex items-center justify-center py-8"},fg={key:1,class:"flex flex-col items-center justify-center py-12 text-center border-2 border-dashed border-gray-300 dark:border-gray-600 rounded-lg"},hg={class:"text-gray-600 dark:text-gray-400"},vg={class:"flex gap-2 mt-4"},gg={key:0,class:"px-2 py-1 bg-blue-500 text-white text-xs font-medium rounded"},bg=e.defineComponent({__name:"ModelMediaManager",props:{mediableType:{},mediableId:{},collection:{},mode:{default:"user"},initialMedia:{},maxFiles:{},acceptedMimeTypes:{},maxFileSize:{},allowReorder:{type:Boolean,default:!0},allowUpload:{type:Boolean,default:!0},allowBrowse:{type:Boolean,default:!0},allowDetach:{type:Boolean,default:!0},allowEdit:{type:Boolean,default:!1},editMode:{default:"replace"},showPrimaryBadge:{type:Boolean,default:!0},emptyText:{default:"No media attached"},title:{default:"Media"}},emits:["loading","update:media","error","attach","detach","reorder","upload-progress","edit-complete"],setup(o,{emit:a}){const t=o,n=a,i=xa(),r=e.ref(!1),s=e.ref(!1),l=e.ref(!1),d=e.ref(!1),c=e.ref(null),u=e.ref(0),f=e.ref(null),m=e.ref(null),p=e.ref(null),h=e.ref(null),v=e.ref(null),w=e.ref(void 0),E=e.ref(null),S=e.ref(null),k=e.computed(()=>{if(t.maxFiles!==void 0)return Math.max(0,t.maxFiles-i.modelMedia.length)}),b=e.computed(()=>i.modelMedia.map(ue=>ue.uuid)),$=e.computed(()=>{if(!(!t.acceptedMimeTypes||t.acceptedMimeTypes.length===0))return t.acceptedMimeTypes.join(",")});function V(){So({isAdmin:t.mode==="admin"})}async function I(ue){await(await H.toastController.create({message:ue,duration:3e3,color:"danger",position:"bottom"})).present()}async function x(){if(!s.value)if(s.value=!0,V(),i.setModelContext(t.mediableType,t.mediableId,t.collection),t.initialMedia&&t.initialMedia.length>0)i.modelMedia=[...t.initialMedia],n("update:media",i.modelMedia);else{r.value=!0,n("loading",!0);try{await i.fetchModelMedia(t.mediableType,t.mediableId,t.collection),n("update:media",i.modelMedia)}catch(ue){const re=ue instanceof Error?ue.message:"Failed to fetch media";n("error",{operation:"fetch",message:re,details:ue})}finally{r.value=!1,n("loading",!1)}}}e.watch(()=>i.modelMedia,ue=>{s.value&&n("update:media",ue)},{deep:!0}),e.watch(()=>[t.mediableType,t.mediableId,t.collection],()=>{s.value=!1,x()}),e.watch(()=>t.mode,()=>{V()}),e.onMounted(()=>{x()}),e.onUnmounted(()=>{i.clearModelContext()});function N(){return i.modelMedia.length>0}function L(){return t.maxFiles===void 0?!1:i.modelMedia.length>=t.maxFiles}function C(ue){var O,D,J;if(!((O=ue.mime_type)!=null&&O.startsWith("image/")))return null;const re=ue.original_url||ue.url||((D=ue.conversion_urls)==null?void 0:D.preview)||((J=ue.conversion_urls)==null?void 0:J.thumb)||ue.thumbnail_url;return re&&re.trim()!==""?re:null}function T(){c.value=null,w.value=void 0,f.value=null,m.value=null,p.value=null,h.value=null,v.value=null}function y(){l.value=!0}function R(){var ue;(ue=S.value)==null||ue.click()}function U(){l.value=!1}async function z(ue){if(t.allowEdit&&C(ue)){T(),c.value=ue,u.value++;try{const re=i.getHttpClient(),O=i.getEditorApiUrl(""),D=await re(`${O.replace(/\/$/,"")}/editor/${ue.uuid}/edit`);if(!D.editable_source_url)throw new Error("Editor source URL missing from edit context");w.value=D.editable_source_url,f.value=D.editor_state??null,m.value=D.editor_document??null,p.value=D.editor_document_id??null,h.value=D.editor_document_revision_id??null,v.value=D.editor_document_revision_number??null}catch(re){T();const O=re instanceof Error?`Unable to load image editor: ${re.message}`:"Unable to load image editor";await I(O);return}d.value=!0}}function W(){d.value=!1,T()}async function B(ue){if(!c.value)throw new Error("No media selected for editing");const re=c.value,O=t.editMode==="variant";try{E.value=null;const D=await i.saveEditedImage(re.uuid,ue,{asVariant:O});O||await i.detachMedia(t.mediableType,t.mediableId,re.uuid,t.collection),await i.attachMedia(t.mediableType,t.mediableId,[D.uuid],t.collection),n("edit-complete",{originalMedia:re,editedMedia:D,mode:t.editMode}),d.value=!1,T()}catch(D){const J=D instanceof Error?D.message:"Failed to save edited image";throw E.value=J,await I(J),D}}function P(ue){if(E.value===ue.message){E.value=null;return}I(ue.message)}async function X(ue){const re=ue.target,O=re.files;if(!(!O||O.length===0)){for(let D=0;D<O.length;D++){const J=O[D];if(k.value!==void 0&&k.value<=0)break;if(t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0&&!t.acceptedMimeTypes.includes(J.type)){n("error",{operation:"upload",message:`File type ${J.type} is not accepted`,details:{file:J.name}});continue}if(t.maxFileSize!==void 0&&J.size>t.maxFileSize){n("error",{operation:"upload",message:`File size exceeds limit of ${t.maxFileSize} bytes`,details:{file:J.name,size:J.size}});continue}n("upload-progress",{status:"uploading",progress:0,file:J});try{const Z=await i.uploadFile(J,{collection:t.collection});Z!=null&&Z.uuid&&(await i.attachMedia(t.mediableType,t.mediableId,[Z.uuid],t.collection),n("upload-progress",{status:"complete",progress:100,file:J}),n("attach",[Z]))}catch(Z){const ie=Z instanceof Error?Z.message:"Upload failed";n("error",{operation:"upload",message:ie,details:Z}),n("upload-progress",{status:"error",progress:0,file:J,error:ie})}}re.value=""}}async function K(ue){const re=ue.map(O=>O.uuid);try{await i.reorderMedia(t.mediableType,t.mediableId,re,t.collection),n("reorder",i.modelMedia)}catch(O){const D=O instanceof Error?O.message:"Failed to reorder media";n("error",{operation:"reorder",message:D,details:O}),await I(D)}}async function be(ue){const re=i.modelMedia.find(O=>O.uuid===ue);try{await i.detachMedia(t.mediableType,t.mediableId,ue,t.collection),re&&n("detach",re)}catch(O){const D=O instanceof Error?O.message:"Failed to detach media";n("error",{operation:"detach",message:D,details:O}),await I(D)}}async function Ne(ue){l.value=!1;const re=ue.map(J=>J.uuid),O=new Set(b.value);let D=Array.from(new Set(re)).filter(J=>!O.has(J));if(k.value!==void 0&&D.length>k.value&&(D=D.slice(0,k.value)),D.length!==0)try{await i.attachMedia(t.mediableType,t.mediableId,D,t.collection);const J=i.modelMedia.filter(Z=>D.includes(Z.uuid));n("attach",J)}catch(J){const Z=J instanceof Error?J.message:"Failed to attach media";n("error",{operation:"attach",message:Z,details:J})}}return(ue,re)=>(e.openBlock(),e.createElementBlock("div",lg,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:S,type:"file",accept:$.value,multiple:k.value===void 0||k.value>1,class:"hidden","data-testid":"upload-input",onChange:X},null,40,dg),e.createElementVNode("div",cg,[ue.title?(e.openBlock(),e.createElementBlock("h3",ug,e.toDisplayString(ue.title),1)):e.createCommentVNode("",!0),e.createElementVNode("div",mg,[ue.allowBrowse?(e.openBlock(),e.createBlock(e.unref(H.IonButton),{key:0,fill:"outline",size:"small",disabled:L(),"data-testid":"browse-button",onClick:y},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{slot:"start",icon:e.unref(Ls)},null,8,["icon"]),re[1]||(re[1]=e.createTextVNode(" Browse ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0),ue.allowUpload?(e.openBlock(),e.createBlock(e.unref(H.IonButton),{key:1,fill:"solid",size:"small",disabled:L(),"data-testid":"upload-button",onClick:R},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{slot:"start",icon:e.unref(ac)},null,8,["icon"]),re[2]||(re[2]=e.createTextVNode(" Upload ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0)])]),r.value||e.unref(i).isLoadingModelMedia?(e.openBlock(),e.createElementBlock("div",pg,[e.createVNode(e.unref(H.IonSpinner),{"data-testid":"spinner"})])):N()?(e.openBlock(),e.createBlock(sg,{key:2,"media-items":e.unref(i).modelMedia,reorderable:!!ue.allowReorder,"is-loading":r.value||e.unref(i).isLoadingModelMedia,"show-edit-button":!!ue.allowEdit,"selection-mode":!1,onReorder:K,onDelete:be,onEdit:z},e.createSlots({_:2},[ue.showPrimaryBadge?{name:"badge",fn:e.withCtx(({index:O})=>[O===0?(e.openBlock(),e.createElementBlock("div",gg," Primary ")):e.createCommentVNode("",!0)]),key:"0"}:void 0]),1032,["media-items","reorderable","is-loading","show-edit-button"])):(e.openBlock(),e.createElementBlock("div",fg,[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Ls),class:"w-12 h-12 text-gray-400 mb-4"},null,8,["icon"]),e.createElementVNode("p",hg,e.toDisplayString(ue.emptyText),1),e.createElementVNode("div",vg,[ue.allowBrowse?(e.openBlock(),e.createBlock(e.unref(H.IonButton),{key:0,fill:"outline",size:"small","data-testid":"browse-button-empty",onClick:y},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{slot:"start",icon:e.unref(Ls)},null,8,["icon"]),re[3]||(re[3]=e.createTextVNode(" Browse Library ",-1))]),_:1})):e.createCommentVNode("",!0),ue.allowUpload?(e.openBlock(),e.createBlock(e.unref(H.IonButton),{key:1,fill:"solid",size:"small","data-testid":"upload-button-empty",onClick:R},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{slot:"start",icon:e.unref(ac)},null,8,["icon"]),re[4]||(re[4]=e.createTextVNode(" Upload Files ",-1))]),_:1})):e.createCommentVNode("",!0)])])),e.createVNode(Lv,e.mergeProps({"is-open":l.value,"selected-items":b.value,collection:ue.collection},k.value!==null&&k.value!==void 0?{maxSelection:k.value}:{},{onConfirm:Ne,onClose:U}),null,16,["is-open","selected-items","collection"]),e.createVNode(ju,{modelValue:d.value,"onUpdate:modelValue":re[0]||(re[0]=O=>d.value=O),"initial-image":w.value,"initial-state":f.value,"initial-document":m.value,"initial-document-id":p.value,"initial-document-revision-id":h.value,"initial-document-revision-number":v.value,"session-key":u.value,"save-handler":B,onCancel:W,onError:P},null,8,["modelValue","initial-image","initial-state","initial-document","initial-document-id","initial-document-revision-id","initial-document-revision-number","session-key"])]))}}),yg=Fe(bg,[["__scopeId","data-v-c58d85c8"]]),wg={class:"existing-media-selector","data-testid":"existing-media-selector"},kg={key:0,class:"existing-media-selector__status","data-testid":"existing-media-loading"},_g=["data-testid"],Eg={class:"existing-media-selector__section-header"},xg={class:"existing-media-selector__section-title"},Sg=["data-testid","aria-label","onClick"],Cg={class:"existing-media-selector__grid"},Vg=["data-testid","aria-label","aria-pressed","onClick"],Ng=["src","alt"],Tg={key:0,class:"existing-media-selector__selected-badge"},Bg={key:1,class:"existing-media-selector__caption"},Ig={key:0,class:"existing-media-selector__section existing-media-selector__section--albums","data-testid":"existing-media-albums"},Mg={class:"existing-media-selector__section-header"},Fg={class:"existing-media-selector__section-title"},$g={class:"existing-media-selector__albums"},Dg=["data-testid","aria-label","aria-pressed","onClick"],Rg={class:"existing-media-selector__album-name"},Ag={key:0,class:"existing-media-selector__album-count"},Lg={class:"existing-media-selector__album-panel","data-testid":"existing-media-active-album"},Pg={class:"existing-media-selector__section-header"},Ug={class:"existing-media-selector__section-subtitle"},Og={key:0,class:"existing-media-selector__section-description"},zg={key:0,class:"existing-media-selector__status","data-testid":"existing-media-active-album-loading"},jg={key:1,class:"existing-media-selector__grid"},Wg=["data-testid","aria-label","aria-pressed","onClick"],Hg=["src","alt"],Zg={key:0,class:"existing-media-selector__selected-badge"},Gg={key:1,class:"existing-media-selector__caption"},Xg={key:2,class:"existing-media-selector__empty","data-testid":"existing-media-active-album-empty"},Kg={key:1,class:"existing-media-selector__empty","data-testid":"existing-media-empty"},Jg=e.defineComponent({__name:"ExistingMediaSelector",props:{sections:{default:()=>[]},albums:{default:()=>[]},selectedId:{default:null},activeAlbumId:{default:null},activeAlbumItems:{default:()=>[]},activeAlbumTitle:{},activeAlbumDescription:{},isLoading:{type:Boolean,default:!1},isAlbumLoading:{type:Boolean,default:!1},emptyMessage:{default:"No media available yet."},albumBrowseTitle:{default:"Browse Your Albums"},albumSectionTitle:{default:"Selected Album"},activeAlbumEmptyMessage:{default:"No media available in this album yet."}},emits:["select","update:activeAlbumId"],setup(o,{emit:a}){const t=o,n=a,i=e.reactive({}),r=e.computed(()=>t.sections.filter(b=>b.items.length>0)),s=e.computed(()=>t.albums.length>0),l=e.computed(()=>r.value.length>0||s.value),d=e.computed(()=>{if(typeof t.activeAlbumTitle=="string"&&t.activeAlbumTitle.trim().length>0)return t.activeAlbumTitle.trim();const b=t.albums.find($=>$.id===t.activeAlbumId);return b!=null&&b.name.trim().length?b.name.trim():t.albumSectionTitle}),c=e.computed(()=>{if(typeof t.activeAlbumDescription=="string"&&t.activeAlbumDescription.trim().length>0)return t.activeAlbumDescription.trim();const b=t.albums.find($=>$.id===t.activeAlbumId);return typeof(b==null?void 0:b.description)=="string"&&b.description.trim().length>0?b.description.trim():""});function u(b){const $=b.initialVisibleCount??6;return $>0?$:6}function f(b){return i[b]===!0}function m(b){i[b]=!f(b)}function p(b){return f(b.id)?b.items:b.items.slice(0,u(b))}function h(b){return b.items.length>u(b)}function v(b){n("select",b)}function w(b){n("update:activeAlbumId",b)}function E(b){var V;const $=(V=b.description)==null?void 0:V.trim();return $&&$.length>0?`Select ${$}`:"Select existing media"}function S(b,$){var I;const V=(I=$.description)==null?void 0:I.trim();return typeof $.alt=="string"&&$.alt.trim().length>0?$.alt.trim():V&&V.length>0?V:b.title}function k(b){const $=typeof b.mediaCount=="number"?` with ${b.mediaCount} item${b.mediaCount===1?"":"s"}`:"";return`Browse album ${b.name}${$}`}return(b,$)=>(e.openBlock(),e.createElementBlock("div",wg,[b.isLoading?(e.openBlock(),e.createElementBlock("div",kg," Loading your media... ")):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,V=>(e.openBlock(),e.createElementBlock("section",{key:V.id,class:"existing-media-selector__section","data-testid":`existing-media-section-${V.id}`},[e.createElementVNode("div",Eg,[e.createElementVNode("h3",xg,e.toDisplayString(V.title),1),h(V)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"existing-media-selector__toggle","data-testid":`existing-media-toggle-${V.id}`,"aria-label":f(V.id)?`Show fewer items from ${V.title}`:`Show more items from ${V.title}`,onClick:I=>m(V.id)},e.toDisplayString(f(V.id)?"See less":"See more"),9,Sg)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Cg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p(V),I=>(e.openBlock(),e.createElementBlock("button",{key:I.id,type:"button",class:e.normalizeClass(["existing-media-selector__item",{"is-selected":b.selectedId===I.id}]),"data-testid":`existing-media-item-${V.id}-${I.id}`,"aria-label":E(I),"aria-pressed":b.selectedId===I.id?"true":"false",onClick:x=>v(I)},[e.createElementVNode("img",{class:"existing-media-selector__image",src:I.previewUrl,alt:S(V,I)},null,8,Ng),b.selectedId===I.id?(e.openBlock(),e.createElementBlock("div",Tg," Selected ")):e.createCommentVNode("",!0),I.description?(e.openBlock(),e.createElementBlock("div",Bg,e.toDisplayString(I.description),1)):e.createCommentVNode("",!0)],10,Vg))),128))])],8,_g))),128)),s.value?(e.openBlock(),e.createElementBlock("section",Ig,[e.createElementVNode("div",Mg,[e.createElementVNode("h3",Fg,e.toDisplayString(b.albumBrowseTitle),1)]),e.createElementVNode("div",$g,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.albums,V=>(e.openBlock(),e.createElementBlock("button",{key:V.id,type:"button",class:e.normalizeClass(["existing-media-selector__album",{"is-active":b.activeAlbumId===V.id}]),"data-testid":`existing-media-album-${V.id}`,"aria-label":k(V),"aria-pressed":b.activeAlbumId===V.id?"true":"false",onClick:I=>w(V.id)},[e.createElementVNode("span",Rg,e.toDisplayString(V.name),1),typeof V.mediaCount=="number"?(e.openBlock(),e.createElementBlock("span",Ag,e.toDisplayString(V.mediaCount),1)):e.createCommentVNode("",!0)],10,Dg))),128))]),e.createElementVNode("div",Lg,[e.createElementVNode("div",Pg,[e.createElementVNode("div",null,[e.createElementVNode("h4",Ug,e.toDisplayString(d.value),1),c.value?(e.openBlock(),e.createElementBlock("p",Og,e.toDisplayString(c.value),1)):e.createCommentVNode("",!0)])]),b.isAlbumLoading?(e.openBlock(),e.createElementBlock("div",zg," Loading album... ")):b.activeAlbumItems.length>0?(e.openBlock(),e.createElementBlock("div",jg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.activeAlbumItems,V=>(e.openBlock(),e.createElementBlock("button",{key:V.id,type:"button",class:e.normalizeClass(["existing-media-selector__item",{"is-selected":b.selectedId===V.id}]),"data-testid":`existing-media-item-album-${V.id}`,"aria-label":E(V),"aria-pressed":b.selectedId===V.id?"true":"false",onClick:I=>v(V)},[e.createElementVNode("img",{class:"existing-media-selector__image",src:V.previewUrl,alt:V.alt||V.description||d.value},null,8,Hg),b.selectedId===V.id?(e.openBlock(),e.createElementBlock("div",Zg," Selected ")):e.createCommentVNode("",!0),V.description?(e.openBlock(),e.createElementBlock("div",Gg,e.toDisplayString(V.description),1)):e.createCommentVNode("",!0)],10,Wg))),128))])):(e.openBlock(),e.createElementBlock("div",Xg,[e.renderSlot(b.$slots,"active-album-empty",{},()=>[e.createTextVNode(e.toDisplayString(b.activeAlbumEmptyMessage),1)],!0)]))])])):e.createCommentVNode("",!0),l.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Kg,[e.renderSlot(b.$slots,"empty",{},()=>[e.createTextVNode(e.toDisplayString(b.emptyMessage),1)],!0)]))],64))]))}}),qg=Fe(Jg,[["__scopeId","data-v-904abb6b"]]);function nr(o,a,t,n){if(t<=0||n<=0)return!1;try{return a.drawImage(o,0,0,t,n),!0}catch(i){return i instanceof DOMException&&i.name==="InvalidStateError",!1}}function Yg(o,a){return o?{display:"block",position:"absolute",inset:"0",width:"100%",height:"100%",objectFit:a,opacity:"0",pointerEvents:"none"}:{display:"block",position:"relative",inset:"auto",width:"100%",height:"100%",objectFit:a,opacity:"1",pointerEvents:"auto"}}const Qg=["src","crossorigin"],e0={class:"preview-controls"},t0=["aria-label"],a0={class:"time-display"},n0={class:"current-time"},o0={class:"total-time"},i0={key:0,class:"fps-display"},r0={key:0,class:"loading-overlay"},s0={key:1,class:"error-overlay"},l0=.1,d0=e.defineComponent({__name:"VideoPreview",props:{source:{},filters:{},playhead:{},fallbackDuration:{default:0},isPlaying:{type:Boolean,default:!1},showFps:{type:Boolean,default:!1},targetFps:{default:30},fitMode:{default:"contain"},active:{type:Boolean,default:!0}},emits:["frame-update","play-pause","duration-change","error"],setup(o,{expose:a,emit:t}){const{ColorMatrixFilter:n,BlurFilter:i}=Pt,r=o,s=t,l=e.ref(),d=e.ref(),c=e.ref(),u=e.ref(!0),f=e.ref(),m=e.ref(0),p=e.ref(0),h=e.ref(!1);let v,w,E=null,S=null,k=null,b=[],$="",V=null,I=0,x=0,N=0,L=0,C=!1,T=0,y=0,R,U=null,z=!1,W=!1,B=0;const P=e.computed(()=>r.source&&typeof r.source=="string"?r.source:""),X=e.computed(()=>{const ge=P.value;if(!(!ge||ge.startsWith("blob:")))return"anonymous"}),K=e.computed(()=>Yg(h.value,r.fitMode));function be(ge){return typeof ge=="number"&&Number.isFinite(ge)&&ge>=0?ge:Number.isFinite(r.fallbackDuration)&&r.fallbackDuration>0?r.fallbackDuration:0}function Ne(ge){const ke=be(ge.duration);return ke<=0?!1:ge.currentTime>=Math.max(0,ke-l0)}async function ue(){var ge,ke;if(!W&&d.value&&!v&&!(!c.value||c.value.readyState<3)){W=!0;try{f.value=void 0;let Te=((ge=l.value)==null?void 0:ge.clientWidth)||800,Ke=((ke=l.value)==null?void 0:ke.clientHeight)||450;if((Te<=0||Ke<=0)&&(Te=c.value.videoWidth||800,Ke=c.value.videoHeight||450),v=new Pt.Application,await v.init({width:Te,height:Ke,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,antialias:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),d.value.appendChild(v.canvas),c.value){if(c.value.videoWidth===0||c.value.videoHeight===0){setTimeout(()=>{c.value&&c.value.videoWidth>0&&!v&&ue()},100),v&&(v.destroy(!0),v=null);return}if(I=c.value.videoWidth,x=c.value.videoHeight,S=document.createElement("canvas"),S.width=I,S.height=x,k=S.getContext("2d"),!k)throw new Error("Unable to create 2D canvas context for video preview");const Ge=nr(c.value,k,I,x),Oe=Pt.Texture.from(S);E=Oe.source,w=new Pt.Sprite(Oe),w.visible=!0,w.alpha=1,xt(),v.stage.addChild(w),v.renderer&&!v.renderer.destroyed&&v.render()}J(),r.targetFps<60?re():v.ticker.add(O),h.value=!0,"ResizeObserver"in window&&(V=new ResizeObserver(Ge=>{C||(C=!0,requestAnimationFrame(()=>{C=!1;const Oe=Ge[Ge.length-1],{width:kt,height:lt}=Oe.contentRect;if(kt<=0||lt<=0)return;const zt=Math.round(kt),At=Math.round(lt);zt===N&&At===L||(N=zt,L=At,xt())}))}),V.observe(l.value)),r.filters&&r.filters.length>0&&J(),r.showFps&&Ie(),B=0}catch{if(Tt(),!z&&!!c.value&&c.value.readyState>=2&&c.value.videoWidth>0&&c.value.videoHeight>0&&B<2){B+=1,window.setTimeout(()=>{z||ue()},B*150);return}f.value="Failed to initialize video preview",s("error",f.value)}finally{W=!1}}}function re(){const ge=1e3/r.targetFps;let ke=performance.now();function Te(){if(z||!v)return;const Ke=performance.now(),Ge=Ke-ke;Ge>=ge&&(O(),ke=Ke-Ge%ge),U=requestAnimationFrame(Te)}U=requestAnimationFrame(Te)}function O(){if(!(!v||!w||z)&&r.active)try{k&&S&&E&&c.value&&(c.value.readyState>=2&&nr(c.value,k,S.width,S.height)&&E.update(),c.value.paused||s("frame-update",se())),r.showFps&&y++,v.renderer&&!v.renderer.destroyed&&v.render()}catch{z=!0}}function D(){for(const ge of b)try{ge.destroy()}catch{}b=[]}function J(){if(w){if(!r.filters||r.filters.length===0){w.filters=null,D();return}D(),r.filters.forEach(ge=>{const ke=Z(ge);ke&&b.push(ke)}),w.filters=b.length>0?b:null,$=JSON.stringify(r.filters),v&&v.render()}}function Z(ge){const ke=ge.filterId,Te=ge.params||{},Ke=oe.getFilter(ke);if(Ke&&!oe.isFilterCompatibleWithMedia(ke,"video"))return null;if(Ke&&Ke.createFilter)try{return Ke.createFilter(Te)}catch{}const Ge=(Oe,kt,lt)=>Math.min(lt,Math.max(kt,Oe));switch(ke){case"brightness":{const Oe=new n,kt=Ge(typeof Te.brightness=="number"?Te.brightness:typeof Te.value=="number"?Te.value:1,0,5);return Oe.brightness(kt,!0),Oe}case"contrast":{const Oe=new n,kt=Ge(typeof Te.contrast=="number"?Te.contrast:typeof Te.value=="number"?Te.value:1,0,5);return Oe.contrast(kt,!0),Oe}case"saturation":{const Oe=new n,kt=Ge(typeof Te.saturation=="number"?Te.saturation:typeof Te.value=="number"?Te.value:1,0,5);return Oe.saturate(kt,!0),Oe}case"hue":{const Oe=new n,kt=Ge(typeof Te.value=="number"?Te.value:0,-180,180);return Oe.hue(kt,!0),Oe}case"gaussian-blur":case"blur":{const Oe=Ge(typeof Te.blur=="number"?Te.blur:typeof Te.value=="number"?Te.value:2,0,10);return new i(Oe)}case"grayscale":{const Oe=new n;return Oe.desaturate(),Oe}case"sepia":case"color-matrix":{const Oe=new n;return Oe.sepia(!0),Oe}case"vignette":{const Oe=typeof Te.value=="number"?Te.value:.3;return ie(Ge(Oe,0,1))}default:return null}}function ie(ge){const ke=`
|
|
7
|
-
precision mediump float;
|
|
8
|
-
varying vec2 vTextureCoord;
|
|
9
|
-
uniform sampler2D uSampler;
|
|
10
|
-
uniform float strength;
|
|
11
|
-
void main(void){
|
|
12
|
-
vec2 uv = vTextureCoord - 0.5;
|
|
13
|
-
float dist = length(uv) * 2.0;
|
|
14
|
-
float vignette = smoothstep(1.0, 1.0 - strength, dist);
|
|
15
|
-
vec4 color = texture2D(uSampler, vTextureCoord);
|
|
16
|
-
gl_FragColor = vec4(color.rgb * (1.0 - vignette), color.a);
|
|
17
|
-
}
|
|
18
|
-
`;return new Pt.Filter(void 0,ke,{strength:ge})}function se(){var ke;return!v||!w?null:{dataUrl:v.canvas.toDataURL("image/jpeg",.8),timestamp:((ke=c.value)==null?void 0:ke.currentTime)||0,width:I||0,height:x||0}}function Ue(){var ge;m.value=be((ge=c.value)==null?void 0:ge.duration),s("duration-change",m.value)}function me(){u.value=!1,f.value=void 0}function ve(){u.value&&(u.value=!1),!h.value&&r.active?ue():h.value}function fe(){var ke,Te,Ke;const ge=((ke=c.value)==null?void 0:ke.currentTime)||0;s("frame-update",{dataUrl:null,timestamp:ge,width:((Te=c.value)==null?void 0:Te.videoWidth)||0,height:((Ke=c.value)==null?void 0:Ke.videoHeight)||0})}function Ee(){c.value&&(c.value.currentTime=0),s("play-pause")}function ye(ge){var Te;const ke=ge.target;if(ke!=null&&ke.error)switch(ke.error.code){case ke.error.MEDIA_ERR_ABORTED:f.value="Video playback aborted";break;case ke.error.MEDIA_ERR_NETWORK:f.value="Network error loading video";break;case ke.error.MEDIA_ERR_DECODE:f.value="Video format not supported";break;case ke.error.MEDIA_ERR_SRC_NOT_SUPPORTED:f.value=`Video source not supported: ${(Te=ke.src)==null?void 0:Te.substring(0,100)}`;break;default:f.value="Failed to load video"}else f.value="Failed to load video";s("error",f.value),u.value=!1}function Be(ge){c.value&&(c.value.currentTime=Math.max(0,Math.min(ge,m.value)))}function Ie(){R=window.setInterval(()=>{const ge=performance.now(),ke=ge-T;p.value=Math.round(y*1e3/ke),y=0,T=ge},1e3)}function et(ge){if(!Number.isFinite(ge)||ge<0)return"00:00";const ke=Math.floor(ge/60),Te=Math.floor(ge%60);return`${ke.toString().padStart(2,"0")}:${Te.toString().padStart(2,"0")}`}function tt(){f.value=void 0,u.value=!0,B=0,Tt(),c.value&&c.value.load()}function Tt(){if(V&&(V.disconnect(),V=null),U&&(cancelAnimationFrame(U),U=null),v!=null&&v.ticker&&(v.ticker.stop(),v.ticker.remove(O)),v)try{v.destroy(!0,{children:!0,texture:!0})}catch{}d.value&&(d.value.innerHTML=""),D(),v=null,w=null,E=null,S=null,k=null,h.value=!1,C=!1,$=""}function vt(){v&&(C||(C=!0,requestAnimationFrame(()=>{C=!1,xt()})))}function xt(){if(!v||!w||!I||!x||!l.value)return;const ge=Math.round(l.value.clientWidth),ke=Math.round(l.value.clientHeight);if(ge<=0||ke<=0)return;v.renderer.resize(ge,ke);const Te=v.screen.width/I,Ke=v.screen.height/x;let Ge=1;switch(r.fitMode){case"cover":Ge=Math.max(Te,Ke);break;case"none":Ge=1;break;case"contain":default:Ge=Math.min(Te,Ke);break}w.scale.set(Ge),w.anchor.set(.5),w.position.set(v.screen.width/2,v.screen.height/2),w.visible=!0,w.alpha=1,v.renderer&&!v.renderer.destroyed&&v.render()}e.watch(()=>r.filters,()=>{h.value&&J()},{deep:!0}),e.watch(()=>r.active,async ge=>{if(ge&&!v&&c.value&&c.value.readyState>=2){await ue();return}v&&(ge&&(await e.nextTick(),l.value&&l.value.getBoundingClientRect(),w&&k&&S&&E&&(c.value&&c.value.readyState>=2&&nr(c.value,k,S.width,S.height)&&E.update(),xt(),v.renderer&&!v.renderer.destroyed&&v.render())),r.targetFps>=60&&v.ticker&&(ge?v.ticker.start():v.ticker.stop()))}),e.watch(P,ge=>{ge?(u.value=!0,f.value=void 0,e.nextTick(()=>{c.value&&c.value.load()})):(u.value=!1,f.value="No video source provided")},{immediate:!0});async function wt(){if(c.value){f.value=void 0,Ne(c.value)&&(c.value.currentTime=0);try{await c.value.play();return}catch{if(!c.value.muted){c.value.muted=!0;try{await c.value.play();return}catch{}}}f.value="Unable to start preview playback",s("error",f.value)}}e.watch(()=>r.isPlaying,ge=>{c.value&&(ge?wt():c.value.pause())}),e.watch(()=>r.playhead,ge=>{c.value&&Math.abs(c.value.currentTime-ge)>.5&&Be(ge)}),e.watch(()=>r.fitMode,()=>{xt()}),e.onMounted(()=>{z=!1,e.nextTick(()=>{l.value&&l.value.getBoundingClientRect(),c.value}),window.addEventListener("resize",vt),T=performance.now(),e.nextTick(()=>{c.value&&c.value.readyState>=2&&!h.value?ue():c.value&&c.value.src&&c.value.readyState===0&&c.value.load()})}),e.onUnmounted(()=>{if(z=!0,U&&(cancelAnimationFrame(U),U=null),window.removeEventListener("resize",vt),V&&(V.disconnect(),V=null),R&&clearInterval(R),v&&v.ticker&&(v.ticker.stop(),v.ticker.remove(O)),v){try{v.destroy(!0,{children:!0,texture:!0})}catch{}v=null}b.forEach(ge=>{try{ge.destroy()}catch{}}),b=[],w=null,E=null,S=null,k=null,c.value&&(c.value.pause(),c.value.removeAttribute("src"),c.value.load())});async function it(ge){if(!await _t()||!c.value||!k||!S||!E)return null;const Te=c.value,Ke=Number.isFinite(m.value)&&m.value>0?m.value:Number.isFinite(Te.duration)&&Te.duration>0?Te.duration:0,Ge=Math.max(0,Math.min(ge,Ke));return await new Promise(kt=>{let lt=!1,zt=0;const At=()=>{lt||(lt=!0,Te.removeEventListener("seeked",Jt),window.clearTimeout(zt),kt())},Jt=()=>{At()},Gt=Number.isFinite(Te.currentTime)?Te.currentTime:0;if(Math.abs(Gt-Ge)<.016){requestAnimationFrame(()=>At());return}Te.addEventListener("seeked",Jt),zt=window.setTimeout(()=>At(),700),Te.currentTime=Ge}),nr(Te,k,S.width,S.height)?(E.update(),v.render(),v.canvas):null}async function _t(){if(!c.value)return!1;if(!v){if(!(c.value.readyState>=2))return!1;await ue()}if(!v||!w||!k||!S||!E)return!1;if(r.filters&&r.filters.length>0){const ge=w.filters,ke=Array.isArray(ge)?ge.length:0,Ke=JSON.stringify(r.filters)!==$;(ke===0||ke!==r.filters.length||Ke)&&J()}return await e.nextTick(),await new Promise(ge=>{requestAnimationFrame(()=>ge())}),!0}return a({captureFrameAt:it,ensureReadyForCapture:_t,duration:m,pixiCanvas:e.computed(()=>v?v.canvas:null),videoElement:e.computed(()=>c.value??null)}),(ge,ke)=>(e.openBlock(),e.createElementBlock("div",{class:"video-preview",ref_key:"containerRef",ref:l},[e.createElementVNode("div",{class:"canvas-container",ref_key:"canvasContainerRef",ref:d},null,512),e.createElementVNode("video",{ref_key:"videoRef",ref:c,src:P.value,onLoadedmetadata:Ue,onLoadeddata:me,onCanplay:ve,onTimeupdate:fe,onEnded:Ee,onError:ye,style:e.normalizeStyle(K.value),crossorigin:X.value,preload:"auto",playsinline:"",controls:""},null,44,Qg),e.createElementVNode("div",e0,[e.createElementVNode("button",{class:"play-button",onClick:ke[0]||(ke[0]=Te=>ge.$emit("play-pause")),"aria-label":ge.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(H.IonIcon),{icon:ge.isPlaying?e.unref(Zu):e.unref(Gu)},null,8,["icon"])],8,t0),e.createElementVNode("div",a0,[e.createElementVNode("span",n0,e.toDisplayString(et(ge.playhead)),1),ke[1]||(ke[1]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",o0,e.toDisplayString(et(m.value)),1)]),ge.showFps?(e.openBlock(),e.createElementBlock("div",i0,e.toDisplayString(p.value)+" FPS ",1)):e.createCommentVNode("",!0)]),u.value?(e.openBlock(),e.createElementBlock("div",r0,[e.createVNode(e.unref(H.IonSpinner),{name:"crescent"}),ke[2]||(ke[2]=e.createElementVNode("p",null,"Loading video...",-1))])):e.createCommentVNode("",!0),f.value?(e.openBlock(),e.createElementBlock("div",s0,[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Jl)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(f.value),1),e.createElementVNode("button",{onClick:tt},"Retry")])):e.createCommentVNode("",!0)],512))}}),ll=Fe(d0,[["__scopeId","data-v-dd1744f4"]]);var Ql=(o,a,t)=>{if(!a.has(o))throw TypeError("Cannot "+t)},Q=(o,a,t)=>(Ql(o,a,"read from private field"),t?t.call(o):a.get(o)),qe=(o,a,t)=>{if(a.has(o))throw TypeError("Cannot add the same private member more than once");a instanceof WeakSet?a.add(o):a.set(o,t)},Zt=(o,a,t,n)=>(Ql(o,a,"write to private field"),a.set(o,t),t),c0=(o,a,t,n)=>({set _(i){Zt(o,a,i)},get _(){return Q(o,a,n)}}),nt=(o,a,t)=>(Ql(o,a,"access private method"),t),rt=new Uint8Array(8),Ya=new DataView(rt.buffer),Wt=o=>[(o%256+256)%256],mt=o=>(Ya.setUint16(0,o,!1),[rt[0],rt[1]]),u0=o=>(Ya.setInt16(0,o,!1),[rt[0],rt[1]]),Yu=o=>(Ya.setUint32(0,o,!1),[rt[1],rt[2],rt[3]]),Ae=o=>(Ya.setUint32(0,o,!1),[rt[0],rt[1],rt[2],rt[3]]),m0=o=>(Ya.setInt32(0,o,!1),[rt[0],rt[1],rt[2],rt[3]]),Xn=o=>(Ya.setUint32(0,Math.floor(o/2**32),!1),Ya.setUint32(4,o,!1),[rt[0],rt[1],rt[2],rt[3],rt[4],rt[5],rt[6],rt[7]]),ed=o=>(Ya.setInt16(0,2**8*o,!1),[rt[0],rt[1]]),Ka=o=>(Ya.setInt32(0,2**16*o,!1),[rt[0],rt[1],rt[2],rt[3]]),Us=o=>(Ya.setInt32(0,2**30*o,!1),[rt[0],rt[1],rt[2],rt[3]]),Ta=(o,a=!1)=>{let t=Array(o.length).fill(null).map((n,i)=>o.charCodeAt(i));return a&&t.push(0),t},Ir=o=>o&&o[o.length-1],td=o=>{let a;for(let t of o)(!a||t.presentationTimestamp>a.presentationTimestamp)&&(a=t);return a},qa=(o,a,t=!0)=>{let n=o*a;return t?Math.round(n):n},Qu=o=>{let a=o*(Math.PI/180),t=Math.cos(a),n=Math.sin(a);return[t,n,0,-n,t,0,0,0,1]},em=Qu(0),tm=o=>[Ka(o[0]),Ka(o[1]),Us(o[2]),Ka(o[3]),Ka(o[4]),Us(o[5]),Ka(o[6]),Ka(o[7]),Us(o[8])],di=o=>!o||typeof o!="object"?o:Array.isArray(o)?o.map(di):Object.fromEntries(Object.entries(o).map(([a,t])=>[a,di(t)])),Vo=o=>o>=0&&o<2**32,Ot=(o,a,t)=>({type:o,contents:a&&new Uint8Array(a.flat(10)),children:t}),Vt=(o,a,t,n,i)=>Ot(o,[Wt(a),Yu(t),n??[]],i),p0=o=>{let a=512;return o.fragmented?Ot("ftyp",[Ta("iso5"),Ae(a),Ta("iso5"),Ta("iso6"),Ta("mp41")]):Ot("ftyp",[Ta("isom"),Ae(a),Ta("isom"),o.holdsAvc?Ta("avc1"):[],Ta("mp41")])},dl=o=>({type:"mdat",largeSize:o}),f0=o=>({type:"free",size:o}),gr=(o,a,t=!1)=>Ot("moov",null,[h0(a,o),...o.map(n=>v0(n,a)),t?G0(o):null]),h0=(o,a)=>{let t=qa(Math.max(0,...a.filter(s=>s.samples.length>0).map(s=>{const l=td(s.samples);return l.presentationTimestamp+l.duration})),ml),n=Math.max(...a.map(s=>s.id))+1,i=!Vo(o)||!Vo(t),r=i?Xn:Ae;return Vt("mvhd",+i,0,[r(o),r(o),Ae(ml),r(t),Ka(1),ed(1),Array(10).fill(0),tm(em),Array(24).fill(0),Ae(n)])},v0=(o,a)=>Ot("trak",null,[g0(o,a),b0(o,a)]),g0=(o,a)=>{let t=td(o.samples),n=qa(t?t.presentationTimestamp+t.duration:0,ml),i=!Vo(a)||!Vo(n),r=i?Xn:Ae,s;return o.info.type==="video"?s=typeof o.info.rotation=="number"?Qu(o.info.rotation):o.info.rotation:s=em,Vt("tkhd",+i,3,[r(a),r(a),Ae(o.id),Ae(0),r(n),Array(8).fill(0),mt(0),mt(0),ed(o.info.type==="audio"?1:0),mt(0),tm(s),Ka(o.info.type==="video"?o.info.width:0),Ka(o.info.type==="video"?o.info.height:0)])},b0=(o,a)=>Ot("mdia",null,[y0(o,a),w0(o.info.type==="video"?"vide":"soun"),k0(o)]),y0=(o,a)=>{let t=td(o.samples),n=qa(t?t.presentationTimestamp+t.duration:0,o.timescale),i=!Vo(a)||!Vo(n),r=i?Xn:Ae;return Vt("mdhd",+i,0,[r(a),r(a),Ae(o.timescale),r(n),mt(21956),mt(0)])},w0=o=>Vt("hdlr",0,0,[Ta("mhlr"),Ta(o),Ae(0),Ae(0),Ae(0),Ta("mp4-muxer-hdlr",!0)]),k0=o=>Ot("minf",null,[o.info.type==="video"?_0():E0(),x0(),V0(o)]),_0=()=>Vt("vmhd",0,1,[mt(0),mt(0),mt(0),mt(0)]),E0=()=>Vt("smhd",0,0,[mt(0),mt(0)]),x0=()=>Ot("dinf",null,[S0()]),S0=()=>Vt("dref",0,0,[Ae(1)],[C0()]),C0=()=>Vt("url ",0,1),V0=o=>{const a=o.compositionTimeOffsetTable.length>1||o.compositionTimeOffsetTable.some(t=>t.sampleCompositionTimeOffset!==0);return Ot("stbl",null,[N0(o),O0(o),z0(o),j0(o),W0(o),H0(o),a?Z0(o):null])},N0=o=>Vt("stsd",0,0,[Ae(1)],[o.info.type==="video"?T0(nb[o.info.codec],o):L0(ib[o.info.codec],o)]),T0=(o,a)=>Ot(o,[Array(6).fill(0),mt(1),mt(0),mt(0),Array(12).fill(0),mt(a.info.width),mt(a.info.height),Ae(4718592),Ae(4718592),Ae(0),mt(1),Array(32).fill(0),mt(24),u0(65535)],[ob[a.info.codec](a),a.info.decoderConfig.colorSpace?F0(a):null]),B0={bt709:1,bt470bg:5,smpte170m:6},I0={bt709:1,smpte170m:6,"iec61966-2-1":13},M0={rgb:0,bt709:1,bt470bg:5,smpte170m:6},F0=o=>Ot("colr",[Ta("nclx"),mt(B0[o.info.decoderConfig.colorSpace.primaries]),mt(I0[o.info.decoderConfig.colorSpace.transfer]),mt(M0[o.info.decoderConfig.colorSpace.matrix]),Wt((o.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),$0=o=>o.info.decoderConfig&&Ot("avcC",[...new Uint8Array(o.info.decoderConfig.description)]),D0=o=>o.info.decoderConfig&&Ot("hvcC",[...new Uint8Array(o.info.decoderConfig.description)]),R0=o=>{if(!o.info.decoderConfig)return null;let a=o.info.decoderConfig;if(!a.colorSpace)throw new Error("'colorSpace' is required in the decoder config for VP9.");let t=a.codec.split("."),n=Number(t[1]),i=Number(t[2]),l=(Number(t[3])<<4)+(0<<1)+Number(a.colorSpace.fullRange);return Vt("vpcC",1,0,[Wt(n),Wt(i),Wt(l),Wt(2),Wt(2),Wt(2),mt(0)])},A0=()=>{let t=(1<<7)+1;return Ot("av1C",[t,0,0,0])},L0=(o,a)=>Ot(o,[Array(6).fill(0),mt(1),mt(0),mt(0),Ae(0),mt(a.info.numberOfChannels),mt(16),mt(0),mt(0),Ka(a.info.sampleRate)],[rb[a.info.codec](a)]),P0=o=>{let a=new Uint8Array(o.info.decoderConfig.description);return Vt("esds",0,0,[Ae(58753152),Wt(32+a.byteLength),mt(1),Wt(0),Ae(75530368),Wt(18+a.byteLength),Wt(64),Wt(21),Yu(0),Ae(130071),Ae(130071),Ae(92307584),Wt(a.byteLength),...a,Ae(109084800),Wt(1),Wt(2)])},U0=o=>{var i;let a=3840,t=0;const n=(i=o.info.decoderConfig)==null?void 0:i.description;if(n){if(n.byteLength<18)throw new TypeError("Invalid decoder description provided for Opus; must be at least 18 bytes long.");const r=ArrayBuffer.isView(n)?new DataView(n.buffer,n.byteOffset,n.byteLength):new DataView(n);a=r.getUint16(10,!0),t=r.getInt16(14,!0)}return Ot("dOps",[Wt(0),Wt(o.info.numberOfChannels),mt(a),Ae(o.info.sampleRate),ed(t),Wt(0)])},O0=o=>Vt("stts",0,0,[Ae(o.timeToSampleTable.length),o.timeToSampleTable.map(a=>[Ae(a.sampleCount),Ae(a.sampleDelta)])]),z0=o=>{if(o.samples.every(t=>t.type==="key"))return null;let a=[...o.samples.entries()].filter(([,t])=>t.type==="key");return Vt("stss",0,0,[Ae(a.length),a.map(([t])=>Ae(t+1))])},j0=o=>Vt("stsc",0,0,[Ae(o.compactlyCodedChunkTable.length),o.compactlyCodedChunkTable.map(a=>[Ae(a.firstChunk),Ae(a.samplesPerChunk),Ae(1)])]),W0=o=>Vt("stsz",0,0,[Ae(0),Ae(o.samples.length),o.samples.map(a=>Ae(a.size))]),H0=o=>o.finalizedChunks.length>0&&Ir(o.finalizedChunks).offset>=2**32?Vt("co64",0,0,[Ae(o.finalizedChunks.length),o.finalizedChunks.map(a=>Xn(a.offset))]):Vt("stco",0,0,[Ae(o.finalizedChunks.length),o.finalizedChunks.map(a=>Ae(a.offset))]),Z0=o=>Vt("ctts",0,0,[Ae(o.compositionTimeOffsetTable.length),o.compositionTimeOffsetTable.map(a=>[Ae(a.sampleCount),Ae(a.sampleCompositionTimeOffset)])]),G0=o=>Ot("mvex",null,o.map(X0)),X0=o=>Vt("trex",0,0,[Ae(o.id),Ae(1),Ae(0),Ae(0),Ae(0)]),lc=(o,a)=>Ot("moof",null,[K0(o),...a.map(J0)]),K0=o=>Vt("mfhd",0,0,[Ae(o)]),am=o=>{let a=0,t=0,n=0,i=0,r=o.type==="delta";return t|=+r,r?a|=1:a|=2,a<<24|t<<16|n<<8|i},J0=o=>Ot("traf",null,[q0(o),Y0(o),Q0(o)]),q0=o=>{let a=0;a|=8,a|=16,a|=32,a|=131072;let t=o.currentChunk.samples[1]??o.currentChunk.samples[0],n={duration:t.timescaleUnitsToNextSample,size:t.size,flags:am(t)};return Vt("tfhd",0,a,[Ae(o.id),Ae(n.duration),Ae(n.size),Ae(n.flags)])},Y0=o=>Vt("tfdt",1,0,[Xn(qa(o.currentChunk.startTimestamp,o.timescale))]),Q0=o=>{let a=o.currentChunk.samples.map(v=>v.timescaleUnitsToNextSample),t=o.currentChunk.samples.map(v=>v.size),n=o.currentChunk.samples.map(am),i=o.currentChunk.samples.map(v=>qa(v.presentationTimestamp-v.decodeTimestamp,o.timescale)),r=new Set(a),s=new Set(t),l=new Set(n),d=new Set(i),c=l.size===2&&n[0]!==n[1],u=r.size>1,f=s.size>1,m=!c&&l.size>1,p=d.size>1||[...d].some(v=>v!==0),h=0;return h|=1,h|=4*+c,h|=256*+u,h|=512*+f,h|=1024*+m,h|=2048*+p,Vt("trun",1,h,[Ae(o.currentChunk.samples.length),Ae(o.currentChunk.offset-o.currentChunk.moofOffset||0),c?Ae(n[0]):[],o.currentChunk.samples.map((v,w)=>[u?Ae(a[w]):[],f?Ae(t[w]):[],m?Ae(n[w]):[],p?m0(i[w]):[]])])},eb=o=>Ot("mfra",null,[...o.map(tb),ab()]),tb=(o,a)=>Vt("tfra",1,0,[Ae(o.id),Ae(63),Ae(o.finalizedChunks.length),o.finalizedChunks.map(n=>[Xn(qa(n.startTimestamp,o.timescale)),Xn(n.moofOffset),Ae(a+1),Ae(1),Ae(1)])]),ab=()=>Vt("mfro",0,0,[Ae(0)]),nb={avc:"avc1",hevc:"hvc1",vp9:"vp09",av1:"av01"},ob={avc:$0,hevc:D0,vp9:R0,av1:A0},ib={aac:"mp4a",opus:"Opus"},rb={aac:P0,opus:U0},Jr=class{},ad=class extends Jr{constructor(){super(...arguments),this.buffer=null}},nm=class extends Jr{constructor(o){if(super(),this.options=o,typeof o!="object")throw new TypeError("StreamTarget requires an options object to be passed to its constructor.");if(o.onData){if(typeof o.onData!="function")throw new TypeError("options.onData, when provided, must be a function.");if(o.onData.length<2)throw new TypeError("options.onData, when provided, must be a function that takes in at least two arguments (data and position). Ignoring the position argument, which specifies the byte offset at which the data is to be written, can lead to broken outputs.")}if(o.chunked!==void 0&&typeof o.chunked!="boolean")throw new TypeError("options.chunked, when provided, must be a boolean.");if(o.chunkSize!==void 0&&(!Number.isInteger(o.chunkSize)||o.chunkSize<1024))throw new TypeError("options.chunkSize, when provided, must be an integer and not smaller than 1024.")}},sb=class extends Jr{constructor(o,a){if(super(),this.stream=o,this.options=a,!(o instanceof FileSystemWritableFileStream))throw new TypeError("FileSystemWritableFileStreamTarget requires a FileSystemWritableFileStream instance.");if(a!==void 0&&typeof a!="object")throw new TypeError("FileSystemWritableFileStreamTarget's options, when provided, must be an object.");if(a&&a.chunkSize!==void 0&&(!Number.isInteger(a.chunkSize)||a.chunkSize<=0))throw new TypeError("options.chunkSize, when provided, must be a positive integer")}},Rn,yo,om=class{constructor(){this.pos=0,qe(this,Rn,new Uint8Array(8)),qe(this,yo,new DataView(Q(this,Rn).buffer)),this.offsets=new WeakMap}seek(o){this.pos=o}writeU32(o){Q(this,yo).setUint32(0,o,!1),this.write(Q(this,Rn).subarray(0,4))}writeU64(o){Q(this,yo).setUint32(0,Math.floor(o/2**32),!1),Q(this,yo).setUint32(4,o,!1),this.write(Q(this,Rn).subarray(0,8))}writeAscii(o){for(let a=0;a<o.length;a++)Q(this,yo).setUint8(a%8,o.charCodeAt(a)),a%8===7&&this.write(Q(this,Rn));o.length%8!==0&&this.write(Q(this,Rn).subarray(0,o.length%8))}writeBox(o){if(this.offsets.set(o,this.pos),o.contents&&!o.children)this.writeBoxHeader(o,o.size??o.contents.byteLength+8),this.write(o.contents);else{let a=this.pos;if(this.writeBoxHeader(o,0),o.contents&&this.write(o.contents),o.children)for(let i of o.children)i&&this.writeBox(i);let t=this.pos,n=o.size??t-a;this.seek(a),this.writeBoxHeader(o,n),this.seek(t)}}writeBoxHeader(o,a){this.writeU32(o.largeSize?1:a),this.writeAscii(o.type),o.largeSize&&this.writeU64(a)}measureBoxHeader(o){return 8+(o.largeSize?8:0)}patchBox(o){let a=this.pos;this.seek(this.offsets.get(o)),this.writeBox(o),this.seek(a)}measureBox(o){if(o.contents&&!o.children)return this.measureBoxHeader(o)+o.contents.byteLength;{let a=this.measureBoxHeader(o);if(o.contents&&(a+=o.contents.byteLength),o.children)for(let t of o.children)t&&(a+=this.measureBox(t));return a}}};Rn=new WeakMap;yo=new WeakMap;var br,Hn,ki,ii,yr,cl,lb=class extends om{constructor(o){super(),qe(this,yr),qe(this,br,void 0),qe(this,Hn,new ArrayBuffer(2**16)),qe(this,ki,new Uint8Array(Q(this,Hn))),qe(this,ii,0),Zt(this,br,o)}write(o){nt(this,yr,cl).call(this,this.pos+o.byteLength),Q(this,ki).set(o,this.pos),this.pos+=o.byteLength,Zt(this,ii,Math.max(Q(this,ii),this.pos))}finalize(){nt(this,yr,cl).call(this,this.pos),Q(this,br).buffer=Q(this,Hn).slice(0,Math.max(Q(this,ii),this.pos))}};br=new WeakMap;Hn=new WeakMap;ki=new WeakMap;ii=new WeakMap;yr=new WeakSet;cl=function(o){let a=Q(this,Hn).byteLength;for(;a<o;)a*=2;if(a===Q(this,Hn).byteLength)return;let t=new ArrayBuffer(a),n=new Uint8Array(t);n.set(Q(this,ki),0),Zt(this,Hn,t),Zt(this,ki,n)};var db=2**24,cb=2,ci,An,ri,rn,Ca,Mr,ul,nd,im,od,rm,ui,Fr,id=class extends om{constructor(o){var a,t;super(),qe(this,Mr),qe(this,nd),qe(this,od),qe(this,ui),qe(this,ci,void 0),qe(this,An,[]),qe(this,ri,void 0),qe(this,rn,void 0),qe(this,Ca,[]),Zt(this,ci,o),Zt(this,ri,((a=o.options)==null?void 0:a.chunked)??!1),Zt(this,rn,((t=o.options)==null?void 0:t.chunkSize)??db)}write(o){Q(this,An).push({data:o.slice(),start:this.pos}),this.pos+=o.byteLength}flush(){var t,n;if(Q(this,An).length===0)return;let o=[],a=[...Q(this,An)].sort((i,r)=>i.start-r.start);o.push({start:a[0].start,size:a[0].data.byteLength});for(let i=1;i<a.length;i++){let r=o[o.length-1],s=a[i];s.start<=r.start+r.size?r.size=Math.max(r.size,s.start+s.data.byteLength-r.start):o.push({start:s.start,size:s.data.byteLength})}for(let i of o){i.data=new Uint8Array(i.size);for(let r of Q(this,An))i.start<=r.start&&r.start<i.start+i.size&&i.data.set(r.data,r.start-i.start);Q(this,ri)?(nt(this,Mr,ul).call(this,i.data,i.start),nt(this,ui,Fr).call(this)):(n=(t=Q(this,ci).options).onData)==null||n.call(t,i.data,i.start)}Q(this,An).length=0}finalize(){Q(this,ri)&&nt(this,ui,Fr).call(this,!0)}};ci=new WeakMap;An=new WeakMap;ri=new WeakMap;rn=new WeakMap;Ca=new WeakMap;Mr=new WeakSet;ul=function(o,a){let t=Q(this,Ca).findIndex(l=>l.start<=a&&a<l.start+Q(this,rn));t===-1&&(t=nt(this,od,rm).call(this,a));let n=Q(this,Ca)[t],i=a-n.start,r=o.subarray(0,Math.min(Q(this,rn)-i,o.byteLength));n.data.set(r,i);let s={start:i,end:i+r.byteLength};if(nt(this,nd,im).call(this,n,s),n.written[0].start===0&&n.written[0].end===Q(this,rn)&&(n.shouldFlush=!0),Q(this,Ca).length>cb){for(let l=0;l<Q(this,Ca).length-1;l++)Q(this,Ca)[l].shouldFlush=!0;nt(this,ui,Fr).call(this)}r.byteLength<o.byteLength&&nt(this,Mr,ul).call(this,o.subarray(r.byteLength),a+r.byteLength)};nd=new WeakSet;im=function(o,a){let t=0,n=o.written.length-1,i=-1;for(;t<=n;){let r=Math.floor(t+(n-t+1)/2);o.written[r].start<=a.start?(t=r+1,i=r):n=r-1}for(o.written.splice(i+1,0,a),(i===-1||o.written[i].end<a.start)&&i++;i<o.written.length-1&&o.written[i].end>=o.written[i+1].start;)o.written[i].end=Math.max(o.written[i].end,o.written[i+1].end),o.written.splice(i+1,1)};od=new WeakSet;rm=function(o){let t={start:Math.floor(o/Q(this,rn))*Q(this,rn),data:new Uint8Array(Q(this,rn)),written:[],shouldFlush:!1};return Q(this,Ca).push(t),Q(this,Ca).sort((n,i)=>n.start-i.start),Q(this,Ca).indexOf(t)};ui=new WeakSet;Fr=function(o=!1){var a,t;for(let n=0;n<Q(this,Ca).length;n++){let i=Q(this,Ca)[n];if(!(!i.shouldFlush&&!o)){for(let r of i.written)(t=(a=Q(this,ci).options).onData)==null||t.call(a,i.data.subarray(r.start,r.end),i.start+r.start);Q(this,Ca).splice(n--,1)}}};var ub=class extends id{constructor(o){var a;super(new nm({onData:(t,n)=>o.stream.write({type:"write",data:t,position:n}),chunked:!0,chunkSize:(a=o.options)==null?void 0:a.chunkSize}))}},ml=1e3,mb=["avc","hevc","vp9","av1"],pb=["aac","opus"],fb=2082844800,hb=["strict","offset","cross-track-offset"],je,He,$r,Sa,Kt,Ht,ko,_o,rd,Ln,Pn,mi,pl,sm,fl,lm,sd,dm,hl,cm,ld,um,wr,vl,Xa,on,dd,mm,pi,Dr,Rr,cd,No,Ni,kr,gl,pm=class{constructor(o){if(qe(this,pl),qe(this,fl),qe(this,sd),qe(this,hl),qe(this,ld),qe(this,wr),qe(this,Xa),qe(this,dd),qe(this,pi),qe(this,Rr),qe(this,No),qe(this,kr),qe(this,je,void 0),qe(this,He,void 0),qe(this,$r,void 0),qe(this,Sa,void 0),qe(this,Kt,null),qe(this,Ht,null),qe(this,ko,Math.floor(Date.now()/1e3)+fb),qe(this,_o,[]),qe(this,rd,1),qe(this,Ln,[]),qe(this,Pn,[]),qe(this,mi,!1),nt(this,pl,sm).call(this,o),o.video=di(o.video),o.audio=di(o.audio),o.fastStart=di(o.fastStart),this.target=o.target,Zt(this,je,{firstTimestampBehavior:"strict",...o}),o.target instanceof ad)Zt(this,He,new lb(o.target));else if(o.target instanceof nm)Zt(this,He,new id(o.target));else if(o.target instanceof sb)Zt(this,He,new ub(o.target));else throw new Error(`Invalid target: ${o.target}`);nt(this,hl,cm).call(this),nt(this,fl,lm).call(this)}addVideoChunk(o,a,t,n){if(!(o instanceof EncodedVideoChunk))throw new TypeError("addVideoChunk's first argument (sample) must be of type EncodedVideoChunk.");if(a&&typeof a!="object")throw new TypeError("addVideoChunk's second argument (meta), when provided, must be an object.");if(t!==void 0&&(!Number.isFinite(t)||t<0))throw new TypeError("addVideoChunk's third argument (timestamp), when provided, must be a non-negative real number.");if(n!==void 0&&!Number.isFinite(n))throw new TypeError("addVideoChunk's fourth argument (compositionTimeOffset), when provided, must be a real number.");let i=new Uint8Array(o.byteLength);o.copyTo(i),this.addVideoChunkRaw(i,o.type,t??o.timestamp,o.duration,a,n)}addVideoChunkRaw(o,a,t,n,i,r){if(!(o instanceof Uint8Array))throw new TypeError("addVideoChunkRaw's first argument (data) must be an instance of Uint8Array.");if(a!=="key"&&a!=="delta")throw new TypeError("addVideoChunkRaw's second argument (type) must be either 'key' or 'delta'.");if(!Number.isFinite(t)||t<0)throw new TypeError("addVideoChunkRaw's third argument (timestamp) must be a non-negative real number.");if(!Number.isFinite(n)||n<0)throw new TypeError("addVideoChunkRaw's fourth argument (duration) must be a non-negative real number.");if(i&&typeof i!="object")throw new TypeError("addVideoChunkRaw's fifth argument (meta), when provided, must be an object.");if(r!==void 0&&!Number.isFinite(r))throw new TypeError("addVideoChunkRaw's sixth argument (compositionTimeOffset), when provided, must be a real number.");if(nt(this,kr,gl).call(this),!Q(this,je).video)throw new Error("No video track declared.");if(typeof Q(this,je).fastStart=="object"&&Q(this,Kt).samples.length===Q(this,je).fastStart.expectedVideoChunks)throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${Q(this,je).fastStart.expectedVideoChunks}).`);let s=nt(this,wr,vl).call(this,Q(this,Kt),o,a,t,n,i,r);if(Q(this,je).fastStart==="fragmented"&&Q(this,Ht)){for(;Q(this,Pn).length>0&&Q(this,Pn)[0].decodeTimestamp<=s.decodeTimestamp;){let l=Q(this,Pn).shift();nt(this,Xa,on).call(this,Q(this,Ht),l)}s.decodeTimestamp<=Q(this,Ht).lastDecodeTimestamp?nt(this,Xa,on).call(this,Q(this,Kt),s):Q(this,Ln).push(s)}else nt(this,Xa,on).call(this,Q(this,Kt),s)}addAudioChunk(o,a,t){if(!(o instanceof EncodedAudioChunk))throw new TypeError("addAudioChunk's first argument (sample) must be of type EncodedAudioChunk.");if(a&&typeof a!="object")throw new TypeError("addAudioChunk's second argument (meta), when provided, must be an object.");if(t!==void 0&&(!Number.isFinite(t)||t<0))throw new TypeError("addAudioChunk's third argument (timestamp), when provided, must be a non-negative real number.");let n=new Uint8Array(o.byteLength);o.copyTo(n),this.addAudioChunkRaw(n,o.type,t??o.timestamp,o.duration,a)}addAudioChunkRaw(o,a,t,n,i){if(!(o instanceof Uint8Array))throw new TypeError("addAudioChunkRaw's first argument (data) must be an instance of Uint8Array.");if(a!=="key"&&a!=="delta")throw new TypeError("addAudioChunkRaw's second argument (type) must be either 'key' or 'delta'.");if(!Number.isFinite(t)||t<0)throw new TypeError("addAudioChunkRaw's third argument (timestamp) must be a non-negative real number.");if(!Number.isFinite(n)||n<0)throw new TypeError("addAudioChunkRaw's fourth argument (duration) must be a non-negative real number.");if(i&&typeof i!="object")throw new TypeError("addAudioChunkRaw's fifth argument (meta), when provided, must be an object.");if(nt(this,kr,gl).call(this),!Q(this,je).audio)throw new Error("No audio track declared.");if(typeof Q(this,je).fastStart=="object"&&Q(this,Ht).samples.length===Q(this,je).fastStart.expectedAudioChunks)throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${Q(this,je).fastStart.expectedAudioChunks}).`);let r=nt(this,wr,vl).call(this,Q(this,Ht),o,a,t,n,i);if(Q(this,je).fastStart==="fragmented"&&Q(this,Kt)){for(;Q(this,Ln).length>0&&Q(this,Ln)[0].decodeTimestamp<=r.decodeTimestamp;){let s=Q(this,Ln).shift();nt(this,Xa,on).call(this,Q(this,Kt),s)}r.decodeTimestamp<=Q(this,Kt).lastDecodeTimestamp?nt(this,Xa,on).call(this,Q(this,Ht),r):Q(this,Pn).push(r)}else nt(this,Xa,on).call(this,Q(this,Ht),r)}finalize(){if(Q(this,mi))throw new Error("Cannot finalize a muxer more than once.");if(Q(this,je).fastStart==="fragmented"){for(let a of Q(this,Ln))nt(this,Xa,on).call(this,Q(this,Kt),a);for(let a of Q(this,Pn))nt(this,Xa,on).call(this,Q(this,Ht),a);nt(this,Rr,cd).call(this,!1)}else Q(this,Kt)&&nt(this,pi,Dr).call(this,Q(this,Kt)),Q(this,Ht)&&nt(this,pi,Dr).call(this,Q(this,Ht));let o=[Q(this,Kt),Q(this,Ht)].filter(Boolean);if(Q(this,je).fastStart==="in-memory"){let a;for(let n=0;n<2;n++){let i=gr(o,Q(this,ko)),r=Q(this,He).measureBox(i);a=Q(this,He).measureBox(Q(this,Sa));let s=Q(this,He).pos+r+a;for(let l of Q(this,_o)){l.offset=s;for(let{data:d}of l.samples)s+=d.byteLength,a+=d.byteLength}if(s<2**32)break;a>=2**32&&(Q(this,Sa).largeSize=!0)}let t=gr(o,Q(this,ko));Q(this,He).writeBox(t),Q(this,Sa).size=a,Q(this,He).writeBox(Q(this,Sa));for(let n of Q(this,_o))for(let i of n.samples)Q(this,He).write(i.data),i.data=null}else if(Q(this,je).fastStart==="fragmented"){let a=Q(this,He).pos,t=eb(o);Q(this,He).writeBox(t);let n=Q(this,He).pos-a;Q(this,He).seek(Q(this,He).pos-4),Q(this,He).writeU32(n)}else{let a=Q(this,He).offsets.get(Q(this,Sa)),t=Q(this,He).pos-a;Q(this,Sa).size=t,Q(this,Sa).largeSize=t>=2**32,Q(this,He).patchBox(Q(this,Sa));let n=gr(o,Q(this,ko));if(typeof Q(this,je).fastStart=="object"){Q(this,He).seek(Q(this,$r)),Q(this,He).writeBox(n);let i=a-Q(this,He).pos;Q(this,He).writeBox(f0(i))}else Q(this,He).writeBox(n)}nt(this,No,Ni).call(this),Q(this,He).finalize(),Zt(this,mi,!0)}};je=new WeakMap;He=new WeakMap;$r=new WeakMap;Sa=new WeakMap;Kt=new WeakMap;Ht=new WeakMap;ko=new WeakMap;_o=new WeakMap;rd=new WeakMap;Ln=new WeakMap;Pn=new WeakMap;mi=new WeakMap;pl=new WeakSet;sm=function(o){if(typeof o!="object")throw new TypeError("The muxer requires an options object to be passed to its constructor.");if(!(o.target instanceof Jr))throw new TypeError("The target must be provided and an instance of Target.");if(o.video){if(!mb.includes(o.video.codec))throw new TypeError(`Unsupported video codec: ${o.video.codec}`);if(!Number.isInteger(o.video.width)||o.video.width<=0)throw new TypeError(`Invalid video width: ${o.video.width}. Must be a positive integer.`);if(!Number.isInteger(o.video.height)||o.video.height<=0)throw new TypeError(`Invalid video height: ${o.video.height}. Must be a positive integer.`);const a=o.video.rotation;if(typeof a=="number"&&![0,90,180,270].includes(a))throw new TypeError(`Invalid video rotation: ${a}. Has to be 0, 90, 180 or 270.`);if(Array.isArray(a)&&(a.length!==9||a.some(t=>typeof t!="number")))throw new TypeError(`Invalid video transformation matrix: ${a.join()}`);if(o.video.frameRate!==void 0&&(!Number.isInteger(o.video.frameRate)||o.video.frameRate<=0))throw new TypeError(`Invalid video frame rate: ${o.video.frameRate}. Must be a positive integer.`)}if(o.audio){if(!pb.includes(o.audio.codec))throw new TypeError(`Unsupported audio codec: ${o.audio.codec}`);if(!Number.isInteger(o.audio.numberOfChannels)||o.audio.numberOfChannels<=0)throw new TypeError(`Invalid number of audio channels: ${o.audio.numberOfChannels}. Must be a positive integer.`);if(!Number.isInteger(o.audio.sampleRate)||o.audio.sampleRate<=0)throw new TypeError(`Invalid audio sample rate: ${o.audio.sampleRate}. Must be a positive integer.`)}if(o.firstTimestampBehavior&&!hb.includes(o.firstTimestampBehavior))throw new TypeError(`Invalid first timestamp behavior: ${o.firstTimestampBehavior}`);if(typeof o.fastStart=="object"){if(o.video){if(o.fastStart.expectedVideoChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedVideoChunks'.");if(!Number.isInteger(o.fastStart.expectedVideoChunks)||o.fastStart.expectedVideoChunks<0)throw new TypeError("'expectedVideoChunks' must be a non-negative integer.")}if(o.audio){if(o.fastStart.expectedAudioChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedAudioChunks'.");if(!Number.isInteger(o.fastStart.expectedAudioChunks)||o.fastStart.expectedAudioChunks<0)throw new TypeError("'expectedAudioChunks' must be a non-negative integer.")}}else if(![!1,"in-memory","fragmented"].includes(o.fastStart))throw new TypeError("'fastStart' option must be false, 'in-memory', 'fragmented' or an object.");if(o.minFragmentDuration!==void 0&&(!Number.isFinite(o.minFragmentDuration)||o.minFragmentDuration<0))throw new TypeError("'minFragmentDuration' must be a non-negative number.")};fl=new WeakSet;lm=function(){var o;if(Q(this,He).writeBox(p0({holdsAvc:((o=Q(this,je).video)==null?void 0:o.codec)==="avc",fragmented:Q(this,je).fastStart==="fragmented"})),Zt(this,$r,Q(this,He).pos),Q(this,je).fastStart==="in-memory")Zt(this,Sa,dl(!1));else if(Q(this,je).fastStart!=="fragmented"){if(typeof Q(this,je).fastStart=="object"){let a=nt(this,sd,dm).call(this);Q(this,He).seek(Q(this,He).pos+a)}Zt(this,Sa,dl(!0)),Q(this,He).writeBox(Q(this,Sa))}nt(this,No,Ni).call(this)};sd=new WeakSet;dm=function(){if(typeof Q(this,je).fastStart!="object")return;let o=0,a=[Q(this,je).fastStart.expectedVideoChunks,Q(this,je).fastStart.expectedAudioChunks];for(let t of a)t&&(o+=8*Math.ceil(2/3*t),o+=4*t,o+=12*Math.ceil(2/3*t),o+=4*t,o+=8*t);return o+=4096,o};hl=new WeakSet;cm=function(){if(Q(this,je).video&&Zt(this,Kt,{id:1,info:{type:"video",codec:Q(this,je).video.codec,width:Q(this,je).video.width,height:Q(this,je).video.height,rotation:Q(this,je).video.rotation??0,decoderConfig:null},timescale:Q(this,je).video.frameRate??57600,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),Q(this,je).audio&&(Zt(this,Ht,{id:Q(this,je).video?2:1,info:{type:"audio",codec:Q(this,je).audio.codec,numberOfChannels:Q(this,je).audio.numberOfChannels,sampleRate:Q(this,je).audio.sampleRate,decoderConfig:null},timescale:Q(this,je).audio.sampleRate,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),Q(this,je).audio.codec==="aac")){let o=nt(this,ld,um).call(this,2,Q(this,je).audio.sampleRate,Q(this,je).audio.numberOfChannels);Q(this,Ht).info.decoderConfig={codec:Q(this,je).audio.codec,description:o,numberOfChannels:Q(this,je).audio.numberOfChannels,sampleRate:Q(this,je).audio.sampleRate}}};ld=new WeakSet;um=function(o,a,t){let i=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350].indexOf(a),r=t,s="";s+=o.toString(2).padStart(5,"0"),s+=i.toString(2).padStart(4,"0"),i===15&&(s+=a.toString(2).padStart(24,"0")),s+=r.toString(2).padStart(4,"0");let l=Math.ceil(s.length/8)*8;s=s.padEnd(l,"0");let d=new Uint8Array(s.length/8);for(let c=0;c<s.length;c+=8)d[c/8]=parseInt(s.slice(c,c+8),2);return d};wr=new WeakSet;vl=function(o,a,t,n,i,r,s){let l=n/1e6,d=(n-(s??0))/1e6,c=i/1e6,u=nt(this,dd,mm).call(this,l,d,o);return l=u.presentationTimestamp,d=u.decodeTimestamp,r!=null&&r.decoderConfig&&(o.info.decoderConfig===null?o.info.decoderConfig=r.decoderConfig:Object.assign(o.info.decoderConfig,r.decoderConfig)),{presentationTimestamp:l,decodeTimestamp:d,duration:c,data:a,size:a.byteLength,type:t,timescaleUnitsToNextSample:qa(c,o.timescale)}};Xa=new WeakSet;on=function(o,a){Q(this,je).fastStart!=="fragmented"&&o.samples.push(a);const t=qa(a.presentationTimestamp-a.decodeTimestamp,o.timescale);if(o.lastTimescaleUnits!==null){let i=qa(a.decodeTimestamp,o.timescale,!1),r=Math.round(i-o.lastTimescaleUnits);if(o.lastTimescaleUnits+=r,o.lastSample.timescaleUnitsToNextSample=r,Q(this,je).fastStart!=="fragmented"){let s=Ir(o.timeToSampleTable);s.sampleCount===1?(s.sampleDelta=r,s.sampleCount++):s.sampleDelta===r?s.sampleCount++:(s.sampleCount--,o.timeToSampleTable.push({sampleCount:2,sampleDelta:r}));const l=Ir(o.compositionTimeOffsetTable);l.sampleCompositionTimeOffset===t?l.sampleCount++:o.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t})}}else o.lastTimescaleUnits=0,Q(this,je).fastStart!=="fragmented"&&(o.timeToSampleTable.push({sampleCount:1,sampleDelta:qa(a.duration,o.timescale)}),o.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t}));o.lastSample=a;let n=!1;if(!o.currentChunk)n=!0;else{let i=a.presentationTimestamp-o.currentChunk.startTimestamp;if(Q(this,je).fastStart==="fragmented"){let r=Q(this,Kt)??Q(this,Ht);const s=Q(this,je).minFragmentDuration??1;o===r&&a.type==="key"&&i>=s&&(n=!0,nt(this,Rr,cd).call(this))}else n=i>=.5}n&&(o.currentChunk&&nt(this,pi,Dr).call(this,o),o.currentChunk={startTimestamp:a.presentationTimestamp,samples:[]}),o.currentChunk.samples.push(a)};dd=new WeakSet;mm=function(o,a,t){var s,l;const n=Q(this,je).firstTimestampBehavior==="strict",i=t.lastDecodeTimestamp===-1;if(n&&i&&a!==0)throw new Error(`The first chunk for your media track must have a timestamp of 0 (received DTS=${a}).Non-zero first timestamps are often caused by directly piping frames or audio data from a MediaStreamTrack into the encoder. Their timestamps are typically relative to the age of thedocument, which is probably what you want.
|
|
19
|
-
|
|
20
|
-
If you want to offset all timestamps of a track such that the first one is zero, set firstTimestampBehavior: 'offset' in the options.
|
|
21
|
-
`);if(Q(this,je).firstTimestampBehavior==="offset"||Q(this,je).firstTimestampBehavior==="cross-track-offset"){t.firstDecodeTimestamp===void 0&&(t.firstDecodeTimestamp=a);let d;Q(this,je).firstTimestampBehavior==="offset"?d=t.firstDecodeTimestamp:d=Math.min(((s=Q(this,Kt))==null?void 0:s.firstDecodeTimestamp)??1/0,((l=Q(this,Ht))==null?void 0:l.firstDecodeTimestamp)??1/0),a-=d,o-=d}if(a<t.lastDecodeTimestamp)throw new Error(`Timestamps must be monotonically increasing (DTS went from ${t.lastDecodeTimestamp*1e6} to ${a*1e6}).`);return t.lastDecodeTimestamp=a,{presentationTimestamp:o,decodeTimestamp:a}};pi=new WeakSet;Dr=function(o){if(Q(this,je).fastStart==="fragmented")throw new Error("Can't finalize individual chunks if 'fastStart' is set to 'fragmented'.");if(o.currentChunk){if(o.finalizedChunks.push(o.currentChunk),Q(this,_o).push(o.currentChunk),(o.compactlyCodedChunkTable.length===0||Ir(o.compactlyCodedChunkTable).samplesPerChunk!==o.currentChunk.samples.length)&&o.compactlyCodedChunkTable.push({firstChunk:o.finalizedChunks.length,samplesPerChunk:o.currentChunk.samples.length}),Q(this,je).fastStart==="in-memory"){o.currentChunk.offset=0;return}o.currentChunk.offset=Q(this,He).pos;for(let a of o.currentChunk.samples)Q(this,He).write(a.data),a.data=null;nt(this,No,Ni).call(this)}};Rr=new WeakSet;cd=function(o=!0){if(Q(this,je).fastStart!=="fragmented")throw new Error("Can't finalize a fragment unless 'fastStart' is set to 'fragmented'.");let a=[Q(this,Kt),Q(this,Ht)].filter(l=>l&&l.currentChunk);if(a.length===0)return;let t=c0(this,rd)._++;if(t===1){let l=gr(a,Q(this,ko),!0);Q(this,He).writeBox(l)}let n=Q(this,He).pos,i=lc(t,a);Q(this,He).writeBox(i);{let l=dl(!1),d=0;for(let u of a)for(let f of u.currentChunk.samples)d+=f.size;let c=Q(this,He).measureBox(l)+d;c>=2**32&&(l.largeSize=!0,c=Q(this,He).measureBox(l)+d),l.size=c,Q(this,He).writeBox(l)}for(let l of a){l.currentChunk.offset=Q(this,He).pos,l.currentChunk.moofOffset=n;for(let d of l.currentChunk.samples)Q(this,He).write(d.data),d.data=null}let r=Q(this,He).pos;Q(this,He).seek(Q(this,He).offsets.get(i));let s=lc(t,a);Q(this,He).writeBox(s),Q(this,He).seek(r);for(let l of a)l.finalizedChunks.push(l.currentChunk),Q(this,_o).push(l.currentChunk),l.currentChunk=null;o&&nt(this,No,Ni).call(this)};No=new WeakSet;Ni=function(){Q(this,He)instanceof id&&Q(this,He).flush()};kr=new WeakSet;gl=function(){if(Q(this,mi))throw new Error("Cannot add new video or audio chunks after the file has been finalized.")};const _i=30;class To extends Error{constructor({message:t="",code:n=""},...i){super(t,...i);ae(this,"message");ae(this,"code");this.code=n,this.message=t}}class sn extends To{}class Ut extends To{}class Ar extends To{}class dc extends To{}function vb(o,a=_i){if(a<1)throw new Ut({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(o*a)}function Eo(o,a=_i){if(a<1)throw new Ut({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(o/a*1e3)}class Re{constructor(a=0){ae(this,"time");this.time=Math.round(a)}get millis(){return this.time}set millis(a){this.time=Math.round(a)}get frames(){return vb(this.millis/1e3)}set frames(a){this.millis=Eo(a)}get seconds(){return this.millis/1e3}set seconds(a){this.millis=a*1e3}addMillis(a){return this.millis=this.millis+a,this}addFrames(a){const t=Eo(a);return this.millis=this.millis+t,this}add(a){return new Re(a.millis+this.millis)}subtract(a){return new Re(this.millis-a.millis)}static fromSeconds(a){const t=new Re;return t.millis=a*1e3,t}static fromFrames(a,t){const n=new Re;return n.millis=Eo(a,t),n}copy(){return new Re(this.millis)}toJSON(){return this.millis}static fromJSON(a){return new Re(a)}}function cc(o,a){return[o.slice(0,a),o.slice(a)].filter(t=>t.length>0)}function _r(o,a){return a?Math.floor(Math.random()*(a-o+1)+o):o}function gb(o,a,t){t<0&&(t=0);const n=o[a];o.splice(a,1),o.splice(t,0,n)}function uc(o){return typeof o!="function"?!1:/^class\s/.test(Function.prototype.toString.call(o))}function bb(o){const a=o.numberOfChannels,t=o.length,n=new Int16Array(t*a);for(let i=0;i<t;i++)for(let r=0;r<a;r++){let s=o.getChannelData(r)[i]*32767;s>32767&&(s=32767),s<-32767&&(s=-32767),n[i*a+r]=s}return n}function yb(o,a=44100,t=2){if(o.sampleRate==a&&o.numberOfChannels==t)return o;const n=Math.floor(o.duration*a),i=new OfflineAudioContext(t,1,a).createBuffer(t,n,a);for(let r=0;r<o.numberOfChannels;r++){const s=o.getChannelData(r),l=i.getChannelData(r),d=o.sampleRate/a;for(let c=0;c<l.length;c++){const u=c*d,f=Math.floor(u),m=Math.ceil(u);if(m>=s.length)l[c]=s[f];else{const p=u-f;l[c]=s[f]*(1-p)+s[m]*p}}}return i}async function wb(o){const{fps:a,height:t,width:n,bitrate:i}=o,r=["avc1.640034","avc1.4d0034","avc1.640028","avc1.640C32","avc1.64001f","avc1.42001E"],s=["prefer-hardware","prefer-software"],l=[];for(const c of r)for(const u of s)l.push({codec:c,hardwareAcceleration:u,width:n,height:t,bitrate:i,framerate:a});const d=[];if(!("VideoEncoder"in window))return d;for(const c of l){const u=await VideoEncoder.isConfigSupported(c);u.supported&&d.push(u.config??c)}return d.sort(kb)}function kb(o,a){const t=o.hardwareAcceleration??"",n=a.hardwareAcceleration??"";return t<n?-1:t>n?1:0}async function _b(o,a="untitled"){const t=document.createElement("a");if(document.head.appendChild(t),t.download=a,typeof o=="string"&&o.startsWith("data:image/svg+xml;base64,")){const n=o.split(",")[1],i=atob(n),r=new Array(i.length);for(let d=0;d<i.length;d++)r[d]=i.charCodeAt(d);const s=new Uint8Array(r),l=new Blob([s],{type:"image/svg+xml"});t.href=URL.createObjectURL(l),t.download=a.split(".")[0]+".svg"}else typeof o=="string"?t.href=o:t.href=URL.createObjectURL(o);t.click(),t.remove()}function mc(o){return`${o.hours.toString().padStart(2,"0")}:${o.minutes.toString().padStart(2,"0")}:${o.seconds.toString().padStart(2,"0")},`+o.milliseconds.toString().padStart(3,"0")}function pc(o){const a=new Date(1970,0,1);return a.setSeconds(o),a.setMilliseconds(Math.round(o%1*1e3)),{hours:a.getHours(),minutes:a.getMinutes(),seconds:a.getSeconds(),milliseconds:a.getMilliseconds()}}class or{constructor(a){ae(this,"words",[]);a&&(this.words=a)}get duration(){return this.stop.subtract(this.start)}get text(){return this.words.map(({text:a})=>a).join(" ")}get start(){var a;return((a=this.words.at(0))==null?void 0:a.start)??new Re}get stop(){var a;return((a=this.words.at(-1))==null?void 0:a.stop)??new Re}}var bl=(o=>(o.en="en",o.de="de",o))(bl||{});class fc{constructor(a,t,n,i){ae(this,"id",crypto.randomUUID());ae(this,"text");ae(this,"start");ae(this,"stop");ae(this,"confidence");this.text=a,this.start=new Re(t),this.stop=new Re(n),this.confidence=i}get duration(){return this.stop.subtract(this.start)}}class On{constructor(a=[],t=bl.en){ae(this,"id",crypto.randomUUID());ae(this,"language",bl.en);ae(this,"groups",[]);this.groups=a,this.language=t}get text(){return this.groups.map(({text:a})=>a).join(" ")}get words(){return this.groups.flatMap(({words:a})=>a)}*iter({count:a,duration:t,length:n}){for(const i of this.groups){let r;for(const[s,l]of i.words.entries())r&&(a&&r.words.length>=_r(...a)?(yield r,r=void 0):t&&(r==null?void 0:r.duration.seconds)>=_r(...t)?(yield r,r=void 0):n&&r.text.length>=_r(...n)&&(yield r,r=void 0)),r?r.words.push(l):r=new or([l]),s==i.words.length-1&&(yield r)}}optimize(){const a=this.groups.flatMap(t=>t.words);for(let t=0;t<a.length-1;t++){const n=a[t],i=a[t+1];i.start.millis-n.stop.millis<0?i.start.millis=n.stop.millis+1:n.stop.millis=i.start.millis-1}return this}toSRT(a={}){let t=1,n="";for(const i of this.iter(a)){const r=pc(i.start.seconds),s=pc(i.stop.seconds);n+=`${t}
|
|
22
|
-
`+mc(r)+" --> "+mc(s)+`
|
|
23
|
-
${i.text}
|
|
24
|
-
|
|
25
|
-
`,t+=1}return{text:n,blob:new Blob([n],{type:"text/plain;charset=utf8"})}}toJSON(){return this.groups.map(a=>a.words.map(t=>({token:t.text,start:t.start.millis,stop:t.stop.millis})))}slice(a,t=!0){let n=0;const i=[];for(const r of this.groups)for(const s of r.words)if(i.length==0&&t&&(n=s.start.millis),i.push(new fc(s.text,s.start.millis-n,s.stop.millis-n)),i.length==a)return new On([new or(i)]);return new On([new or(i)])}copy(){return On.fromJSON(this.toJSON())}static fromJSON(a){const t=new On;for(const n of a){const i=new or;for(const r of n)i.words.push(new fc(r.token,r.start,r.stop));t.groups.push(i)}return t}static async from(a,t){const n=await fetch(a,t);if(!n.ok)throw new sn({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});return On.fromJSON(await n.json())}}function Er(o,a,t){return o+(a-o)*t}function Eb(o,a,t){const n=Number.parseInt(o.slice(1),16),i=Number.parseInt(a.slice(1),16),r=n>>16&255,s=n>>8&255,l=n&255,d=i>>16&255,c=i>>8&255,u=i&255,f=Math.round(Er(r,d,t)),m=Math.round(Er(s,c,t)),p=Math.round(Er(l,u,t));return`#${((1<<24)+(f<<16)+(m<<8)+p).toString(16).slice(1)}`}const xb={linear:o=>o,easeIn:o=>o*o,easeOut:o=>o*(2-o),easeInOut:o=>o<.5?2*o*o:-1+(4-2*o)*o};class ze{constructor(a,t,n={}){ae(this,"input");ae(this,"output");ae(this,"options");if(a.length!==t.length)throw new Ut({code:"invalidKeyframes",message:"inputRange and outputRange must have the same length"});this.input=a.map(i=>Eo(i)),this.output=t,this.options={extrapolate:"clamp",easing:"linear",type:"number",...JSON.parse(JSON.stringify(n))}}normalize(a){const{input:t}=this;if(a<t[0])return this.options.extrapolate==="clamp"?{t:0,segment:0}:{t:(a-t[0])/(t[1]-t[0]),segment:0};if(a>t[t.length-1])return this.options.extrapolate==="clamp"?{t:1,segment:t.length-2}:{t:(a-t[t.length-2])/(t[t.length-1]-t[t.length-2]),segment:t.length-2};for(let n=0;n<t.length-1;n++){const i=t[n],r=t[n+1];if(a>=i&&a<=r)return{t:(a-i)/(r-i),segment:n}}return{t:0,segment:0}}interpolate(a,t){const n=this.output[t],i=this.output[t+1],r=xb[this.options.easing](a);if(typeof n=="number"&&typeof i=="number")return Er(n,i,r);if(typeof n=="string"&&typeof i=="string")return Eb(n,i,r);if(this.output.length==1)return this.output[0];throw new Ut({code:"invalidKeyframes",message:"Unsupported output range types"})}value(a){const{t,segment:n}=this.normalize(typeof a=="number"?a:a.millis);return this.interpolate(t,n)}push(a,t){return this.input.push(Eo(a)),this.output.push(t),this}toJSON(){return this}static fromJSON(a){const t=new ze([],[]);return Object.assign(t,a),t}}class Ia{constructor(){ae(this,"id",crypto.randomUUID())}toJSON(){const a={};return(this.constructor.__serializableProperties||[]).forEach(({propertyKey:t,serializer:n})=>{const i=this[t];n&&i instanceof n?a[t]=i.toJSON():a[t]=i}),a}static fromJSON(a){const t=new this;return(this.__serializableProperties||[]).forEach(({propertyKey:n,serializer:i})=>{if(a.hasOwnProperty(n))if(i){const r=i.fromJSON(a[n]);t[n]=r}else t[n]=a[n]}),t}}function Me(o){return function(a,t){a.constructor.__serializableProperties||(a.constructor.__serializableProperties=[]),a.constructor.__serializableProperties.push({propertyKey:t,serializer:o})}}function Ti(o){return class extends o{constructor(){super(...arguments);ae(this,"_handlers",{})}on(t,n){if(typeof n!="function")throw new Error("The callback of an event listener needs to be a function.");const i=crypto.randomUUID();return this._handlers[t]?this._handlers[t][i]=n:this._handlers[t]={[i]:n},i}off(t,...n){if(t){if(t==="*"){this._handlers={};return}for(const i of Object.values(this._handlers))t in i&&delete i[t];for(const i of n)this.off(i)}}trigger(t,n){var r,s;const i=new CustomEvent(t,{detail:n});Object.defineProperty(i,"currentTarget",{writable:!1,value:this});for(const l in this._handlers[t]??{})(r=this._handlers[t])==null||r[l](i);for(const l in this._handlers["*"]??{})(s=this._handlers["*"])==null||s[l](i)}bubble(t){return this.on("*",n=>{t.trigger(n.type,n.detail)})}resolve(t){return(n,i)=>{this.on("error",i),this.on(t,n)}}}}function ud(o,a,t=0){if(!(o instanceof Et.Container||o instanceof Et.Filter||t==3))for(const n in o){const i=o[n];n&&(i instanceof ze&&(o[n]=i.value(a)),i!=null&&typeof i=="object"&&Object.keys(i).length&&ud(i,a,t+1))}}var Sb=Object.defineProperty,qr=(o,a,t,n)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(a,t,i)||i);return i&&Sb(a,t,i),i};const Bi=class fm extends Ti(Ia){constructor(t={}){super();ae(this,"_name");ae(this,"_start",new Re);ae(this,"_stop",Re.fromSeconds(16));ae(this,"type","base");ae(this,"source");ae(this,"view",new Et.Container);ae(this,"createdAt",new Date);ae(this,"disabled",!1);ae(this,"state","IDLE");ae(this,"track");Object.assign(this,t)}get name(){var t;return this._name??((t=this.source)==null?void 0:t.name)}set name(t){this._name=t}get start(){return this._start}get stop(){return this._stop}async connect(t){this.state="ATTACHED",this.track=t,this.trigger("attach",void 0)}set start(t){typeof t=="number"?this.start.frames=t:this._start=t,this.start.millis>=this.stop.millis&&(this.stop.millis=this.start.millis+1),this.trigger("frame",this.start.frames)}set stop(t){typeof t=="number"?this.stop.frames=t:this._stop=t,this.stop.millis<=this.start.millis&&(this.start.millis=this.stop.millis-1),this.trigger("frame",this.stop.frames)}offsetBy(t){return typeof t=="number"?(this.start.addFrames(t),this.stop.addFrames(t),this.trigger("offsetBy",Re.fromFrames(t))):(this.start.addMillis(t.millis),this.stop.addMillis(t.millis),this.trigger("offsetBy",t)),this.trigger("frame",void 0),this}async init(){}enter(){}update(t){}exit(){}detach(){var t;return(t=this.track)==null||t.remove(this),this}async split(t){var r,s;if(t||(t=(s=(r=this.track)==null?void 0:r.composition)==null?void 0:s.frame),typeof t=="number"&&(t=Re.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new Ut({code:"splitOutOfRange",message:"Cannot split clip at the specified time"});if(!this.track)throw new Ut({code:"trackNotAttached",message:"Track must be attached to a track"});const n=this.copy();this.stop=t.copy(),n.start=t.copy().addMillis(1),ud(n,n.start.subtract(this.start));const i=this.track.clips.findIndex(l=>l.id==this.id);return await this.track.add(n,i+1),n}copy(){return fm.fromJSON(JSON.parse(JSON.stringify(this)))}set(t){return t&&Object.assign(this,t),this.trigger("update",void 0),this}};qr([Me()],Bi.prototype,"_name");qr([Me(Re)],Bi.prototype,"_start");qr([Me(Re)],Bi.prototype,"_stop");qr([Me()],Bi.prototype,"disabled");let Ii=Bi;var Cb=Object.defineProperty,to=(o,a,t,n)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(a,t,i)||i);return i&&Cb(a,t,i),i};class Qa extends Ti(Ia){constructor(){super(...arguments);ae(this,"state","IDLE");ae(this,"metadata");ae(this,"objectURL");ae(this,"duration",Re.fromSeconds(16));ae(this,"added",!1);ae(this,"type","base");ae(this,"name","");ae(this,"mimeType");ae(this,"externalURL");ae(this,"external",!1);ae(this,"file")}async createObjectURL(){return this.objectURL?this.objectURL:(this.objectURL=URL.createObjectURL(await this.getFile()),this.objectURL)}async getFile(){if(!this.file&&this.state=="LOADING"&&await new Promise(this.resolve("load")),!this.file)throw new Ut({code:"fileNotAccessible",message:"The desired file cannot be accessed"});return this.file}async loadFile(t){this.name=t.name,this.mimeType=_l(t.type),this.external=!1,this.file=t}async loadUrl(t,n){const i=await fetch(t,n);if(!(i!=null&&i.ok))throw new sn({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});const r=await i.blob();this.name=t.toString().split("/").at(-1)??"",this.external=!0,this.file=new File([r],this.name,{type:r.type}),this.externalURL=t,this.mimeType=_l(r.type)}async from(t,n){try{this.state="LOADING",t instanceof File?await this.loadFile(t):await this.loadUrl(t,n),this.state="READY",this.trigger("load",void 0)}catch(i){throw this.state=="ERROR",this.trigger("error",new Error(String(i))),i}return this}async arrayBuffer(){return await(await this.getFile()).arrayBuffer()}async remove(){this.state="IDLE",this.objectURL&&(URL.revokeObjectURL(this.objectURL),this.objectURL=void 0),delete this.file}async download(){const t=await this.getFile();_b(t,this.name)}async thumbnail(){return document.createElement("div")}static async from(t,n,i=new this){return i.from(t,n)}}to([Me()],Qa.prototype,"objectURL");to([Me()],Qa.prototype,"duration");to([Me()],Qa.prototype,"type");to([Me()],Qa.prototype,"name");to([Me()],Qa.prototype,"mimeType");to([Me()],Qa.prototype,"externalURL");to([Me()],Qa.prototype,"external");const hc="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E";function Vb(o){const a=new TextEncoder().encode(o);let t="";const n=a.byteLength;for(let i=0;i<n;i++)t+=String.fromCharCode(a[i]);return btoa(t)}function vc(o){if(!o||!o.body)return hc;const a=o.body.scrollWidth,t=o.body.scrollHeight,n=o.cloneNode(!0),i=n.getElementsByTagName("style").item(0),r=n.getElementsByTagName("body").item(0);if(r==null||r.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),!r)return hc;const s=new XMLSerializer,l=i?s.serializeToString(i):"",d=s.serializeToString(r),c=`
|
|
26
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${t}">
|
|
27
|
-
body { padding: 0; }
|
|
28
|
-
${l}
|
|
29
|
-
<foreignObject width="100%" height="100%">
|
|
30
|
-
${d}
|
|
31
|
-
</foreignObject>
|
|
32
|
-
</svg>`;return"data:image/svg+xml;base64,"+Vb(c)}class gc extends Qa{constructor(){super();ae(this,"type","html");ae(this,"iframe");const t=document.createElement("iframe");t.style.position="absolute",t.style.width="0",t.style.height="0",t.style.border="0",t.style.visibility="hidden",document.body.appendChild(t),this.iframe=t}get document(){var t;return(t=this.iframe.contentWindow)==null?void 0:t.document}async createObjectURL(){return!this.file&&this.state=="LOADING"&&await new Promise(this.resolve("load")),this.objectURL?this.objectURL:(this.objectURL=vc(this.document),this.objectURL)}async loadUrl(t,n){await super.loadUrl(t,n),this.iframe.setAttribute("src",URL.createObjectURL(this.file)),await new Promise((i,r)=>{this.iframe.onload=()=>i(),this.iframe.onerror=s=>r(s)})}async loadFile(t){await super.loadFile(t),this.iframe.setAttribute("src",URL.createObjectURL(this.file)),await new Promise((n,i)=>{this.iframe.onload=()=>n(),this.iframe.onerror=r=>i(r)})}update(){this.objectURL&&(this.objectURL=vc(this.document))}async thumbnail(){const t=new Image;return t.src=await this.createObjectURL(),t.className="object-contain w-full aspect-video h-auto",t}}function Nb(o,a={}){const{threshold:t=.02,hopSize:n=1024,minDuration:i=500}=a,r=[],s=o.getChannelData(0),l=o.sampleRate,d=Math.floor(i/1e3*l);let c=null,u=0;for(let f=0;f<s.length;f+=n){let m=0;const p=Math.min(f+n,s.length);for(let h=f;h<p;h++)m+=s[h]*s[h];m=Math.sqrt(m/(p-f)),m<t?(u+=n,c===null&&(c=f)):(c!==null&&u>=d&&r.push({start:Re.fromSeconds(c/l),stop:Re.fromSeconds(f/l)}),c=null,u=0)}return c!==null&&u>=d&&r.push({start:Re.fromSeconds(c/l),stop:Re.fromSeconds(s.length/l)}),r}const Os=3e3;class _n extends Qa{constructor(){super(...arguments);ae(this,"type","audio");ae(this,"decoding",!1);ae(this,"_silences");ae(this,"transcript");ae(this,"audioBuffer")}async decode(t=2,n=48e3,i=!1){if(this.decoding&&i&&(await new Promise(this.resolve("update")),this.audioBuffer))return this.audioBuffer;this.decoding=!0;const r=await this.arrayBuffer(),s=await new OfflineAudioContext(t,1,n).decodeAudioData(r);return this.duration.seconds=s.duration,i&&(this.audioBuffer=s),this.decoding=!1,this.trigger("update",void 0),s}async samples(t=60,n=50,i=0){const r=this.audioBuffer??await this.decode(1,3e3,!0),s=Math.round(r.sampleRate/n),l=r.sampleRate*r.duration-s,d=Math.ceil(l/t),c=r.getChannelData(0),u=[];for(let f=0;f<l;f+=d){let m=0;for(let p=f;p<f+s;p++)m+=Math.abs(c[f]);u.push(Math.log1p(m/s*100))}return u.map(f=>Math.round(f/Math.max(...u)*(100-i))+i)}async fastsampler({length:t=60,start:n=0,stop:i,logarithmic:r=!1}={}){typeof n=="object"&&(n=n.millis),typeof i=="object"&&(i=i.millis);const s=this.audioBuffer??await this.decode(1,Os,!0),l=s.getChannelData(0),d=Math.floor(Math.max(n*Os/1e3,0)),c=i?Math.floor(Math.min(i*Os/1e3,s.length)):s.length,u=Math.floor((c-d)/t),f=new Float32Array(t);for(let m=0;m<t;m++){const p=d+m*u,h=p+u;let v=-1/0;for(let w=p;w<h;w++){const E=l[w];E>v&&(v=E)}f[m]=r?Math.log2(1+v):v}return f}async thumbnail(...t){const n=await this.samples(...t),i=document.createElement("div");i.className="flex flex-row absolute space-between inset-0 audio-samples";for(const r of n){const s=document.createElement("div");s.className="audio-sample-item",s.style.height=`${r}%`,i.appendChild(s)}return i}async silences(t={}){if(this._silences)return this._silences;const n=await this.arrayBuffer(),i=new AudioContext,r=await i.decodeAudioData(n);return this._silences=Nb(r,t),i.close(),this._silences}}class yl extends Qa{constructor(){super(...arguments);ae(this,"type","image")}async thumbnail(){const t=new Image;return t.src=await this.createObjectURL(),t.className="object-cover w-full aspect-video h-auto",t}}class jn extends _n{constructor(){super(...arguments);ae(this,"type","video");ae(this,"downloadInProgress",!0)}async loadUrl(t,n){const i=await fetch(t,n);if(!(i!=null&&i.ok))throw new sn({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});this.name=t.toString().split("/").at(-1)??"",this.external=!0,this.externalURL=t,this.objectURL=String(t),this.mimeType=_l(i.headers.get("Content-type")),this.getBlob(i)}async getFile(){if(!this.file&&this.downloadInProgress&&await new Promise(this.resolve("load")),!this.file)throw new Ut({code:"fileNotAccessible",message:"The desired file cannot be accessed"});return this.file}async thumbnail(){const t=document.createElement("video");return t.className="object-cover w-full aspect-video h-auto",t.controls=!1,t.addEventListener("loadedmetadata",()=>{this.duration.seconds=t.duration,this.trigger("update",void 0)}),t.addEventListener("mousemove",n=>{const i=n.currentTarget,r=i==null?void 0:i.getBoundingClientRect(),s=n.clientX-((r==null?void 0:r.left)??0),l=i==null?void 0:i.duration;l&&r&&r.width>0&&(i.currentTime=Math.round(l*(s/r.width)))}),t.src=await this.createObjectURL(),t}async getBlob(t){try{this.downloadInProgress=!0;const n=await t.blob();this.file=new File([n],this.name,{type:n.type}),this.trigger("load",void 0)}catch(n){this.state=="ERROR",this.trigger("error",new Error(String(n)))}finally{this.downloadInProgress=!1}}}class Tb{static fromJSON(a){return[new Re(a[0]),new Re(a[1])]}}var Bb=Object.defineProperty,Ib=Object.getOwnPropertyDescriptor,Io=(o,a,t,n)=>{for(var i=n>1?void 0:n?Ib(a,t):a,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(a,t,i):s(i))||i);return n&&i&&Bb(a,t,i),i};const ao=class hm extends Ii{constructor(t={}){super();ae(this,"source",new _n);ae(this,"_offset",new Re);ae(this,"playing",!1);ae(this,"duration",new Re);ae(this,"range",[new Re,this.duration]);Object.assign(this,t)}get transcript(){return this.source.transcript}set transcript(t){this.source.transcript=t}get start(){return this.range[0].add(this.offset)}get stop(){return this.range[1].add(this.offset)}set start(t){typeof t=="number"&&(t=Re.fromFrames(t));const n=t.subtract(this.offset);n.millis>=0&&n.millis<this.range[1].millis?this.range[0].millis=n.millis:n.millis<0?this.range[0].millis=0:this.range[0].millis=this.range[1].millis-1,this.trigger("frame",void 0)}set stop(t){typeof t=="number"&&(t=Re.fromFrames(t));const n=t.subtract(this.offset);n.millis>this.range[0].millis&&n.millis<=this.duration.millis?this.range[1]=n:n.millis>this.duration.millis?this.range[1]=this.duration:this.range[1].millis=this.range[0].millis+1,this.trigger("frame",void 0)}get offset(){return this._offset}set offset(t){typeof t=="number"?this._offset.frames=t:this._offset=t,this.trigger("frame",this.offset.frames)}offsetBy(t){return typeof t=="number"?(this.offset.addFrames(t),this.trigger("offsetBy",Re.fromFrames(t))):(this.offset.addMillis(t.millis),this.trigger("offsetBy",t)),this.trigger("frame",void 0),this}get muted(){var t;return((t=this.element)==null?void 0:t.muted)??!1}set muted(t){this.element&&(this.element.muted=t)}seek(t){return new Promise((n,i)=>{if(!this.element)return i(new dc({code:"elementNotDefined",message:"Cannot seek on undefined element"}));(t.millis<this.start.millis||t.millis>this.stop.millis)&&(t=this.start),this.element.onerror=()=>{var r;return i((r=this.element)==null?void 0:r.error)},this.element.pause(),this.element.currentTime=t.subtract(this.offset).seconds,this.element.onseeked=()=>n()})}subclip(t,n){if(t||(t=this.range[0]),n||(n=this.range[1]),typeof t=="number"&&(t=Re.fromFrames(t)),typeof n=="number"&&(n=Re.fromFrames(n)),t.millis>=n.millis)throw new Ut({code:"invalidKeyframe",message:"Start can't lower than or equal the stop"});return t.millis<0&&(this.range[0].millis=0,t=this.range[0]),n.millis>this.duration.millis&&this.duration.millis&&(n=this.duration),this.range=[t,n],this.trigger("frame",void 0),this}get volume(){var t;return((t=this.element)==null?void 0:t.volume)??1}set volume(t){this.element&&(this.element.volume=t)}copy(){const t=hm.fromJSON(JSON.parse(JSON.stringify(this)));return t.source=this.source,t}async split(t){var r,s;if(t||(t=(s=(r=this.track)==null?void 0:r.composition)==null?void 0:s.frame),typeof t=="number"&&(t=Re.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new Ut({code:"invalidKeyframe",message:"Cannot split clip at the specified time"});if(!this.track)throw new dc({code:"trackNotDefined",message:"Clip must be attached to a track"});t=t.subtract(this.offset);const n=this.copy();this.range[1]=t.copy(),n.range[0]=t.copy().addMillis(1),ud(n,n.start.subtract(this.start));const i=this.track.clips.findIndex(l=>l.id==this.id);return await this.track.add(n,i+1),n}async addCaptions(t){var n;if(!((n=this.track)!=null&&n.composition))throw new Ut({code:"compositionNotDefined",message:"Captions can only be generated after the clip has been added to the composition"});return await this.track.composition.createTrack("caption").from(this).generate(t)}set(t){return super.set(t)}async generateCaptions(t){return this.addCaptions(t)}async removeSilences(t={}){["READY","ATTACHED"].includes(this.state)||await this.init();const n=(await this.source.silences(t)).filter(s=>bc(s,this.range)).sort((s,l)=>s.start.millis-l.start.millis);if(n.length==0)return[this];const i=t.padding??500,r=[this];for(const s of n){const l=r.at(-1);if(!l)break;if(!bc(s,l.range))continue;const d=new Re(Math.min(s.start.millis+i,s.stop.millis));if(s.start.millis>l.range[0].millis&&s.stop.millis<l.range[1].millis){const c=l.copy();l.range[1]=d,c.range[0]=s.stop,r.push(c)}else s.start.millis<=l.range[0].millis?l.range[0]=s.stop:s.stop.millis>=l.range[1].millis&&(l.range[1]=d)}return r}};Io([Me(Re)],ao.prototype,"_offset",2);Io([Me(Re)],ao.prototype,"duration",2);Io([Me(Tb)],ao.prototype,"range",2);Io([Me(On)],ao.prototype,"transcript",1);Io([Me()],ao.prototype,"muted",1);Io([Me()],ao.prototype,"volume",1);let Yr=ao;function bc(o,a){return o.start.millis>=a[0].millis&&o.start.millis<=a[1].millis||o.stop.millis<=a[1].millis&&o.stop.millis>=a[0].millis}class ir{static fromJSON(a){return typeof a=="object"?ze.fromJSON(a):a}}class zs{static fromJSON(a){return typeof a.x=="object"&&(a.x=ze.fromJSON(a.x)),typeof a.y=="object"&&(a.y=ze.fromJSON(a.y)),a}}let Mb=class{constructor(o){ae(this,"target");ae(this,"animation");this.target=o}init(o,a,t=0,n){if(!(o in this.target))throw new Error(`Property [${String(o)}] cannot be assigned`);const i=[t],r=[a];typeof this.target[o]==typeof a&&t!=0&&(i.unshift(0),r.unshift(this.target[o])),this.target[o]=this.animation=new ze(i,r,{easing:n})}};function Fb(o){const a=new Proxy(o,{get(t,n){return n=="to"?(i,r)=>{if(!t.animation)throw new Ut({code:"undefinedKeyframe",message:"Cannot use 'to() before selecting a property"});const s=new Re(t.animation.input.at(-1)).frames+r;return t.animation.push(s,i),a}:(i,r,s)=>(t.init(n,i,r,s),a)}});return a}class $b extends Mb{}var Db=Object.defineProperty,Rb=Object.getOwnPropertyDescriptor,yn=(o,a,t,n)=>{for(var i=n>1?void 0:n?Rb(a,t):a,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(a,t,i):s(i))||i);return n&&i&&Db(a,t,i),i};function Qr(o){class a extends o{constructor(){super(...arguments);ae(this,"filters");ae(this,"_height");ae(this,"_width");ae(this,"_position",{x:this.view.position.x,y:this.view.position.y});ae(this,"_scale");ae(this,"rotation",this.view.angle);ae(this,"alpha",1);ae(this,"translate",{x:0,y:0})}get position(){return this._position}set position(i){typeof i=="string"?(this._position={x:"50%",y:"50%"},this.anchor={x:.5,y:.5}):this._position=i}get scale(){return this._scale??{x:this.view.scale.x,y:this.view.scale.y}}set scale(i){typeof i=="number"||i instanceof ze||typeof i=="function"?this._scale={x:i,y:i}:this._scale=i}get x(){return this._position.x}set x(i){this._position.x=i}get y(){return this._position.y}set y(i){this._position.y=i}get translateX(){return this.translate.x}set translateX(i){this.translate.x=i}get translateY(){return this.translate.y}set translateY(i){this.translate.y=i}get height(){return this._height??this.view.height}set height(i){this._height=i}get width(){return this._width??this.view.width}set width(i){this._width=i}get mask(){return this.view.mask}set mask(i){this.view.mask=i??null}get anchor(){return this.view.children[0]instanceof Et.Sprite?{x:this.view.children[0].anchor.x,y:this.view.children[0].anchor.y}:{x:0,y:0}}set anchor(i){const r=typeof i=="number"?{x:i,y:i}:i;for(const s of this.view.children)s instanceof Et.Sprite&&s.anchor.set(r.x,r.y)}enter(){this.filters&&!this.view.filters&&(this.view.filters=this.filters)}exit(){this.filters&&this.view.filters&&(this.view.filters=null)}animate(){return Fb(new $b(this))}}return yn([Me(ir)],a.prototype,"_height",2),yn([Me(ir)],a.prototype,"_width",2),yn([Me(zs)],a.prototype,"_position",2),yn([Me(zs)],a.prototype,"_scale",2),yn([Me(ir)],a.prototype,"rotation",2),yn([Me(ir)],a.prototype,"alpha",2),yn([Me(zs)],a.prototype,"translate",2),yn([Me()],a.prototype,"anchor",1),a}function es(o,a,t){const n=t.value;return t.value=function(...i){var f,m,p,h;const r=i[0].subtract(this.start),s={width:((m=(f=this.track)==null?void 0:f.composition)==null?void 0:m.width)??1920,height:((h=(p=this.track)==null?void 0:p.composition)==null?void 0:h.height)??1080};let l;typeof this.translate.x=="number"?l=this.translate.x:typeof this.translate.x=="function"?l=this.translate.x.bind(this)(r):l=this.translate.x.value(r);let d;typeof this.translate.y=="number"?d=this.translate.y:typeof this.translate.y=="function"?d=this.translate.y.bind(this)(r):d=this.translate.y.value(r);let c;typeof this._position.x=="number"?c=this._position.x:typeof this._position.x=="string"?c=Number.parseFloat(this._position.x)*s.width/100:typeof this._position.x=="function"?c=this._position.x.bind(this)(r):c=this._position.x.value(r);let u;if(typeof this._position.y=="number"?u=this._position.y:typeof this._position.y=="string"?u=Number.parseFloat(this._position.y)*s.height/100:typeof this._position.y=="function"?u=this._position.y.bind(this)(r):u=this._position.y.value(r),this.view.position.set(c+l,u+d),typeof this._height=="string"?this.view.height=Math.round(Number.parseFloat(this._height)*s.height/100):typeof this._height=="object"?this.view.height=this._height.value(r):typeof this._height=="function"?this.view.height=this._height.bind(this)(r):this._height&&(this.view.height=this._height),this._height&&!this._width&&this.view.scale.set(this.view.scale.y),typeof this._width=="string"?this.view.width=Math.round(Number.parseFloat(this._width)*s.width/100):typeof this._width=="object"?this.view.width=this._width.value(r):typeof this._width=="function"?this.view.width=this._width.bind(this)(r):this._width&&(this.view.width=this._width),this._width&&!this._height&&this.view.scale.set(this.view.scale.x),this._scale){let v;typeof this._scale.x=="number"?v=this._scale.x:typeof this._scale.x=="function"?v=this._scale.x.bind(this)(r):v=this._scale.x.value(r);let w;typeof this._scale.y=="number"?w=this._scale.y:typeof this._scale.y=="function"?w=this._scale.y.bind(this)(r):w=this._scale.y.value(r),(this._width||this._height)&&(v*=this.view.scale._x,w*=this.view.scale._y),this.view.scale.set(v,w)}return typeof this.rotation=="number"?this.view.angle=this.rotation:typeof this.rotation=="function"?this.view.angle=this.rotation.bind(this)(r):this.view.angle=this.rotation.value(r),typeof this.alpha=="number"?this.view.alpha=this.alpha:typeof this.alpha=="function"?this.view.alpha=this.alpha.bind(this)(r):this.view.alpha=this.alpha.value(r),n.apply(this,i)},t}var Ab=Object.defineProperty,Lb=Object.getOwnPropertyDescriptor,Pb=(o,a,t,n)=>{for(var i=Lb(a,t),r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(a,t,i)||i);return i&&Ab(a,t,i),i};const vm=class gm extends Qr(Ii){constructor(t,n={}){super();ae(this,"type","image");ae(this,"element",new Image);ae(this,"source",new yl);ae(this,"sprite",new Et.Sprite);this.view.addChild(this.sprite),t instanceof yl&&(this.source=t),t instanceof File&&this.source.from(t),Object.assign(this,n)}async init(){this.element.setAttribute("src",await this.source.createObjectURL()),await new Promise((t,n)=>{this.element.onload=()=>{this.sprite.texture=Et.Texture.from(this.element),this.state="READY",t()},this.element.onerror=i=>{this.state="ERROR",n(new sn({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=gm.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};Pb([es],vm.prototype,"update");let Ub=vm;const rr={"The Bold Font":{weights:["500"],url:"https://diffusion-studio-public.s3.eu-central-1.amazonaws.com/fonts/the-bold-font.ttf"},"Komika Axis":{weights:["400"],url:"https://diffusion-studio-public.s3.eu-central-1.amazonaws.com/fonts/komika-axis.ttf"},Geologica:{weights:["100","200","300","400","500","600","700","800","900"],url:"https://fonts.gstatic.com/s/geologica/v1/oY1l8evIr7j9P3TN9YwNAdyjzUyDKkKdAGOJh1UlCDUIhAIdhCZOn1fLsig7jfvCCPHZckUWE1lELWNN-w.woff2"},Figtree:{weights:["300","400","500","600","700","800","900"],url:"https://fonts.gstatic.com/s/figtree/v5/_Xms-HUzqDCFdgfMm4S9DaRvzig.woff2"},Urbanist:{weights:["100","200","300","400","500","600","700","800","900"],url:"https://fonts.gstatic.com/s/urbanist/v15/L0x-DF02iFML4hGCyMqlbS1miXK2.woff2"},Montserrat:{weights:["100","200","300","400","500","600","700","800","900"],url:"https://fonts.gstatic.com/s/montserrat/v26/JTUSjIg1_i6t8kCHKm459WlhyyTh89Y.woff2"},Bangers:{weights:["400"],url:"https://fonts.gstatic.com/s/bangers/v20/FeVQS0BTqb0h60ACH55Q2J5hm24.woff2"},Chewy:{weights:["400"],url:"https://fonts.gstatic.com/s/chewy/v18/uK_94ruUb-k-wn52KjI9OPec.woff2"},"Source Code Pro":{weights:["200","300","400","500","600","700","800","900"],url:"https://fonts.gstatic.com/s/sourcecodepro/v22/HI_SiYsKILxRpg3hIP6sJ7fM7PqlPevWnsUnxg.woff2"}};var Ob=Object.defineProperty,ts=(o,a,t,n)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(a,t,i)||i);return i&&Ob(a,t,i),i};const Mi=class wl extends Ti(Ia){constructor(t){super();ae(this,"loaded",!1);ae(this,"family");ae(this,"weight");ae(this,"source");ae(this,"style");t!=null&&t.source.startsWith("https://")&&(t.source=`url(${t.source})`),this.family=(t==null?void 0:t.family)??"Arial",this.source=t==null?void 0:t.source,this.style=t==null?void 0:t.style,this.weight=t==null?void 0:t.weight}get name(){return this.family+" "+(this.style??this.weight)}async load(){if(this.loaded||!this.source||!this.family)return this;const t=new FontFace(this.name,this.source);return this.weight&&(t.weight=this.weight),await new Promise(n=>{t.load().then(i=>{document.fonts.add(i),n(null)})}),this.loaded=!0,this.trigger("load",void 0),this}copy(){const t=wl.fromJSON(JSON.parse(JSON.stringify(this)));return t.loaded=this.loaded,t}static async localFonts(){const t={};"queryLocalFonts"in window||Object.assign(window,{queryLocalFonts:()=>[]});for(const n of await window.queryLocalFonts()){if(n.family in t){t[n.family].push(n);continue}t[n.family]=[n]}return Object.keys(t).map(n=>({family:n,variants:t[n].map(i=>({family:n,style:i.style,source:`local('${i.fullName}'), local('${i.postscriptName}')`}))}))}static webFonts(){return Object.keys(rr).map(t=>({family:t,variants:rr[t].weights.map(n=>({family:t,source:`url(${rr[t].url})`,weight:n}))}))}static fromFamily({family:t,weight:n}){return new wl({family:t,source:`url(${rr[t].url})`,weight:n})}};ts([Me()],Mi.prototype,"family");ts([Me()],Mi.prototype,"weight");ts([Me()],Mi.prototype,"source");ts([Me()],Mi.prototype,"style");let na=Mi;const Ja=4,bm={center:.5,justify:.5,left:0,right:1},ym={alphabetic:0,top:0,middle:.5,hanging:1,bottom:1,ideographic:1};var zb=Object.defineProperty,jb=Object.getOwnPropertyDescriptor,va=(o,a,t,n)=>{for(var i=jb(a,t),r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(a,t,i)||i);return i&&zb(a,t,i),i};const sa=class wm extends Qr(Ii){constructor(t){super();ae(this,"type","text");ae(this,"_text","");ae(this,"_textCase");ae(this,"_anchor",{x:0,y:0});ae(this,"_font",new na);ae(this,"style",new Et.TextStyle({fill:"#FFFFFF",fontFamily:this._font.family,fontSize:16}));this.style.padding=20,typeof t=="string"?(this.text=t,this.reflectUpdate()):t&&(Object.assign(this,t),this.reflectUpdate()),this.on("update",this.reflectUpdate.bind(this))}get text(){return this._text}set text(t){if(this._text=t,!this.view.children.length){const n=new Et.Text({text:this.transformedText,style:this.style,resolution:Ja,scale:Ja});this.view.addChild(n)}this.view.children[0]instanceof Et.Text&&this.transformedText&&(this.view.children[0].text=this.transformedText)}get name(){return this._text}get font(){return this._font}set font(t){if(this._font=t,t.loaded){this.style.fontFamily=t.name;return}this._font.load().then(()=>{this.style.fontFamily=t.name,this.trigger("update",void 0)})}get maxWidth(){if(this.style.wordWrap)return this.style.wordWrapWidth*Ja}set maxWidth(t){t?(this.style.wordWrap=!0,this.style.wordWrapWidth=t/Ja):this.style.wordWrap=!1}get textAlign(){return this.style.align}set textAlign(t){this.style.align=t,this.anchor.x=bm[t]}get padding(){return this.style.padding}set padding(t){this.style.padding=t}get textBaseline(){return this.style.textBaseline}set textBaseline(t){this.style.textBaseline=t,this.anchor.y=ym[t]}get fillStyle(){const{fill:t}=this.style;return new Et.Color(t.toString()).toHex().toUpperCase()}set fillStyle(t){this.style.fill=t}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor={x:t,y:t}:this._anchor=t}get stroke(){if(!this.style.stroke)return;let{color:t="#000000",alpha:n=1,width:i=3,join:r="round",miterLimit:s}=this.style.stroke;return t=new Et.Color(t).toHex().toUpperCase(),{color:t,alpha:n,width:i,join:r,miterLimit:s}}set stroke(t){if(!t){this.style.stroke=void 0;return}const{color:n="#000000",alpha:i=1,width:r=3,join:s="round",miterLimit:l}=t;this.style.stroke={color:n,alpha:i,width:r,join:s,miterLimit:l}}get textCase(){return this._textCase}set textCase(t){this._textCase=t,this.view.children[0]instanceof Et.Text&&this.transformedText&&(this.view.children[0].text=this.transformedText)}get shadow(){if(!this.style.dropShadow)return;const{alpha:t,angle:n,blur:i,color:r,distance:s}=this.style.dropShadow,l=new Et.Color(r).toHex().toUpperCase();return{alpha:t,angle:n,blur:i,color:l,distance:s}}set shadow(t){t?this.style.dropShadow=t:this.style.dropShadow=!1}get fontFamily(){return Array.isArray(this.style.fontFamily)?this.style.fontFamily[0]:this.style.fontFamily}get fontSize(){return this.style.fontSize}set fontSize(t){this.style.fontSize=t}get leading(){return this.style.leading}set leading(t){this.style.leading=t}update(t){}copy(){const t=wm.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.font=this.font,t}get transformedText(){return this.textCase=="lower"?this._text.toLocaleLowerCase():this.textCase=="upper"?this._text.toUpperCase():this._text}reflectUpdate(){var r,s,l;const t=((r=this.view.children[0])==null?void 0:r.width)??0,n=((s=this.view.children[0])==null?void 0:s.height)??0,i=(((l=this.style.dropShadow)==null?void 0:l.distance)??0)*Ja;this.view.pivot={x:(t-i)*this._anchor.x,y:(n-i)*this._anchor.y}}set(t){return super.set(t)}};va([Me()],sa.prototype,"text");va([Me(na)],sa.prototype,"font");va([Me()],sa.prototype,"maxWidth");va([Me()],sa.prototype,"textAlign");va([Me()],sa.prototype,"padding");va([Me()],sa.prototype,"textBaseline");va([Me()],sa.prototype,"fillStyle");va([Me()],sa.prototype,"anchor");va([Me()],sa.prototype,"stroke");va([Me()],sa.prototype,"textCase");va([Me()],sa.prototype,"shadow");va([Me()],sa.prototype,"fontSize");va([Me()],sa.prototype,"leading");va([es],sa.prototype,"update");let Mo=sa;function js(o){const a=o.split(" ").map(t=>`${t} `);return a[a.length-1]=a[a.length-1].replace(/ $/,""),a}const Wb={get(o,a){const t=o[a];return typeof t=="number"?t*Ja:Array.isArray(t)&&typeof t[0]=="number"?t.map(n=>n*Ja):t}};function Hb(o){return new Proxy(o,Wb)}class Zb{constructor(){ae(this,"tokens",[])}get width(){return this.tokens.reduce((a,t)=>a+t.metrics.lineWidths[0],0)}get height(){return Math.max(...this.tokens.map(a=>a.metrics.lineHeight))}}class yc{constructor(){ae(this,"lines",[])}get width(){return Math.max(...this.lines.map(a=>a.width))}get height(){return this.lines.reduce((a,t)=>a+t.height,0)}}class Gb{static fromJSON(a){return a.map(t=>(t.font&&(t.font=na.fromJSON(t.font)),t))}}var Xb=Object.defineProperty,Kb=Object.getOwnPropertyDescriptor,Fo=(o,a,t,n)=>{for(var i=n>1?void 0:n?Kb(a,t):a,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(a,t,i):s(i))||i);return n&&i&&Xb(a,t,i),i};const no=class km extends Mo{constructor(t){super();ae(this,"type","complex_text");ae(this,"_maxWidth");ae(this,"_textAlign","left");ae(this,"_textBaseline","top");ae(this,"model",new Et.Container);ae(this,"segments",[]);ae(this,"metrics",new yc);ae(this,"background");ae(this,"styles");this.view.addChild(this.model),typeof t=="string"?(this.text=t,this.reflectUpdate()):t&&(Object.assign(this,t),this.reflectUpdate())}get text(){return this._text}set text(t){this._text=t}get maxWidth(){return this._maxWidth}set maxWidth(t){this._maxWidth=t}get textAlign(){return this._textAlign}set textAlign(t){this._textAlign=t,this._anchor.x=bm[t];const n=this.metrics.width;for(const i of this.metrics.lines){let r=0;(t=="center"||t=="justify")&&(r=(n-i.width)/2),t=="right"&&(r=n-i.width);for(const s of i.tokens)this.model.children[s.index].x=r,r+=s.metrics.lineWidths[0]}}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline=t,this._anchor.y=ym[t];let n=0;for(const i of this.metrics.lines){const r=i.height;for(const s of i.tokens){let l=0;t=="middle"&&(l=(r-s.metrics.lineHeight)/2),t=="bottom"&&(l=r-s.metrics.lineHeight),this.model.children[s.index].y=n+l}n+=r}}copy(){const t=km.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.font=this.font,t}createRenderSplits(t=[]){var r,s;const n=this.transformedText??"",i=[{index:void 0,tokens:js(n.substring(0,(r=t==null?void 0:t.at(0))==null?void 0:r.start))}];for(let l=0;l<t.length;l++)i.push({index:t[l].index,tokens:js(n.substring(t[l].start,t[l].stop))}),!((t[l].stop??n.length)>=n.length)&&i.push({index:void 0,tokens:js(n.substring(t[l].stop,(s=t.at(l+1))==null?void 0:s.start))});return i.filter(l=>l.tokens.join("").trim().length)}createTextMetrics(t,n){var r,s,l;const i=new yc;for(const d of t){const c=d.index!=null?n[d.index]:this.style;for(let u=0;u<d.tokens.length;u++){const f=Hb(Et.CanvasTextMetrics.measureText(d.tokens[u],c)),m=(((r=i.lines.at(-1))==null?void 0:r.width)??0)+f.lineWidths[0],p=this.maxWidth??Number.POSITIVE_INFINITY,h=(s=d.tokens.at(u-1))==null?void 0:s.match(/(\n|\\n).$/gim);(m>p||h||!i.lines.length)&&i.lines.push(new Zb),this.model.addChild(new Et.Text({text:d.tokens[u],style:c,resolution:Ja,scale:Ja})),(l=i.lines.at(-1))==null||l.tokens.push({metrics:f,index:this.model.children.length-1})}}return i}createTextStyles(){var t;return((t=this.styles)==null?void 0:t.map(n=>{var r;const i=this.style.clone();return i.fill=n.fillStyle??this.style.fill,i.fontSize=n.fontSize??this.style.fontSize,i.stroke=n.stroke??this.style.stroke,i.fontFamily=((r=n.font)==null?void 0:r.name)??this.style.fontFamily,i}))??[]}drawBackground(){var l,d;if(this.view.children.length>1&&this.view.removeChildAt(0),!this.background)return;const t=this.model.width,n=this.model.height,i=((l=this.background.padding)==null?void 0:l.x)??40,r=((d=this.background.padding)==null?void 0:d.y)??10,s=new Et.Graphics;s.roundRect(0-i/2,2-r/2,t+i,n+r,this.background.borderRadius??20),s.fill(this.background.fill??"#000000"),s.alpha=this.background.alpha??1,this.view.addChildAt(s,0)}reflectUpdate(){var l;if(!this.transformedText)return;this.model.removeChildren();const t=this.createRenderSplits(this.segments),n=this.createTextStyles();this.metrics=this.createTextMetrics(t,n),this.textAlign=this.textAlign,this.textBaseline=this.textBaseline;const i=this.view.width,r=this.view.height,s=(((l=this.style.dropShadow)==null?void 0:l.distance)??0)*Ja;this.view.pivot={x:(i-s)*this._anchor.x,y:(r-s)*this._anchor.y},this.drawBackground()}};Fo([Me()],no.prototype,"background",2);Fo([Me(Gb)],no.prototype,"styles",2);Fo([Me()],no.prototype,"text",1);Fo([Me()],no.prototype,"maxWidth",1);Fo([Me()],no.prototype,"textAlign",1);Fo([Me()],no.prototype,"textBaseline",1);let as=no;const _m="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBtPSh0PT4odFt0LkFWTUVESUFfVFlQRV9VTktOT1dOPS0xXT0iQVZNRURJQV9UWVBFX1VOS05PV04iLHRbdC5BVk1FRElBX1RZUEVfVklERU89MF09IkFWTUVESUFfVFlQRV9WSURFTyIsdFt0LkFWTUVESUFfVFlQRV9BVURJTz0xXT0iQVZNRURJQV9UWVBFX0FVRElPIix0W3QuQVZNRURJQV9UWVBFX0RBVEE9Ml09IkFWTUVESUFfVFlQRV9EQVRBIix0W3QuQVZNRURJQV9UWVBFX1NVQlRJVExFPTNdPSJBVk1FRElBX1RZUEVfU1VCVElUTEUiLHRbdC5BVk1FRElBX1RZUEVfQVRUQUNITUVOVD00XT0iQVZNRURJQV9UWVBFX0FUVEFDSE1FTlQiLHRbdC5BVk1FRElBX1RZUEVfTkI9NV09IkFWTUVESUFfVFlQRV9OQiIsdCkpKG18fHt9KSxvPSh0PT4odC5GRm1wZWdXb3JrZXJMb2FkZWQ9IkZGbXBlZ1dvcmtlckxvYWRlZCIsdC5XQVNNUnVudGltZUluaXRpYWxpemVkPSJXQVNNUnVudGltZUluaXRpYWxpemVkIix0LkxvYWRXQVNNPSJMb2FkV0FTTSIsdC5HZXRBVlBhY2tldD0iR2V0QVZQYWNrZXQiLHQuR2V0QVZQYWNrZXRzPSJHZXRBVlBhY2tldHMiLHQuR2V0QVZTdHJlYW09IkdldEFWU3RyZWFtIix0LkdldEFWU3RyZWFtcz0iR2V0QVZTdHJlYW1zIix0LlJlYWRBVlBhY2tldD0iUmVhZEFWUGFja2V0Iix0LkFWUGFja2V0U3RyZWFtPSJBVlBhY2tldFN0cmVhbSIsdC5SZWFkTmV4dEFWUGFja2V0PSJSZWFkTmV4dEFWUGFja2V0Iix0LlN0b3BSZWFkQVZQYWNrZXQ9IlN0b3BSZWFkQVZQYWNrZXQiLHQpKShvfHx7fSk7Y29uc3QgQT0iS0daMWJtTjBhVzl1S0NsN0luVnpaU0J6ZEhKcFkzUWlPMnhsZENCbU8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2SWtaR2JYQmxaMWR2Y210bGNreHZZV1JsWkNKOUtTeHpaV3htTG1Ga1pFVjJaVzUwVEdsemRHVnVaWElvSW0xbGMzTmhaMlVpTEdGemVXNWpJR1oxYm1OMGFXOXVLR3dwZTJOdmJuTjBlM1I1Y0dVNmRDeGtZWFJoT21NOWUzMHNiWE5uU1dRNmIzMDliQzVrWVhSaE8zUnllWHRwWmloMFBUMDlJa3h2WVdSWFFWTk5JaWw3WTI5dWMzUjdkMkZ6YlV4dllXUmxjbEJoZEdnNlpYMDlZM3g4ZTMwN1pqMWhkMkZwZENoaGQyRnBkQ0JwYlhCdmNuUW9aU2twTG1SbFptRjFiSFFvS1gxbGJITmxJR2xtS0hROVBUMGlSMlYwUVZaVGRISmxZVzBpS1h0amIyNXpkSHRtYVd4bE9tVXNjM1J5WldGdFZIbHdaVHB6TEhOMGNtVmhiVWx1WkdWNE9tRjlQV01zY2oxbUxtZGxkRUZXVTNSeVpXRnRLR1VzY3l4aEtUdHpaV3htTG5CdmMzUk5aWE56WVdkbEtIdDBlWEJsT25Rc2JYTm5TV1E2Ynl4eVpYTjFiSFE2Y24wc1czSXVZMjlrWldOd1lYSXVaWGgwY21Ga1lYUmhMbUoxWm1abGNsMHBmV1ZzYzJVZ2FXWW9kRDA5UFNKSFpYUkJWbE4wY21WaGJYTWlLWHRqYjI1emRIdG1hV3hsT21WOVBXTXNjejFtTG1kbGRFRldVM1J5WldGdGN5aGxLVHR6Wld4bUxuQnZjM1JOWlhOellXZGxLSHQwZVhCbE9uUXNiWE5uU1dRNmJ5eHlaWE4xYkhRNmMzMHNjeTV0WVhBb1lUMCtZUzVqYjJSbFkzQmhjaTVsZUhSeVlXUmhkR0V1WW5WbVptVnlLU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBJaWw3WTI5dWMzUjdabWxzWlRwbExIUnBiV1U2Y3l4emRISmxZVzFVZVhCbE9tRXNjM1J5WldGdFNXNWtaWGc2Y24wOVl5eHVQV1l1WjJWMFFWWlFZV05yWlhRb1pTeHpMR0VzY2lrN2MyVnNaaTV3YjNOMFRXVnpjMkZuWlNoN2RIbHdaVHAwTEcxelowbGtPbThzY21WemRXeDBPbTU5TEZ0dUxtUmhkR0V1WW5WbVptVnlYU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBjeUlwZTJOdmJuTjBlMlpwYkdVNlpTeDBhVzFsT25OOVBXTXNZVDFtTG1kbGRFRldVR0ZqYTJWMGN5aGxMSE1wTzNObGJHWXVjRzl6ZEUxbGMzTmhaMlVvZTNSNWNHVTZkQ3h0YzJkSlpEcHZMSEpsYzNWc2REcGhmU3hoTG0xaGNDaHlQVDV5TG1SaGRHRXVZblZtWm1WeUtTbDlaV3h6WlNCcFppaDBQVDA5SWxKbFlXUkJWbEJoWTJ0bGRDSXBlMk52Ym5OMGUyWnBiR1U2WlN4emRHRnlkRHB6TEdWdVpEcGhMSE4wY21WaGJWUjVjR1U2Y2l4emRISmxZVzFKYm1SbGVEcHVmVDFqTEdROVppNXlaV0ZrUVZaUVlXTnJaWFFvYnl4bExITXNZU3h5TEc0cE8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEhKbGMzVnNkRHBrZlNsOWZXTmhkR05vS0dVcGUzTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEdWeWNrMXpaenBsSUdsdWMzUmhibU5sYjJZZ1JYSnliM0kvWlM1dFpYTnpZV2RsT2lKVmJtdHViM2R1SUVWeWNtOXlJbjBwZlgwcGZTa29LVHNLIixnPXQ9PlVpbnQ4QXJyYXkuZnJvbShhdG9iKHQpLGU9PmUuY2hhckNvZGVBdCgwKSksVj10eXBlb2Ygc2VsZjwidSImJnNlbGYuQmxvYiYmbmV3IEJsb2IoW2coQSldLHt0eXBlOiJ0ZXh0L2phdmFzY3JpcHQ7Y2hhcnNldD11dGYtOCJ9KTtmdW5jdGlvbiBFKHQpe2xldCBlO3RyeXtpZihlPVYmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLmNyZWF0ZU9iamVjdFVSTChWKSwhZSl0aHJvdyIiO2NvbnN0IHM9bmV3IFdvcmtlcihlLHtuYW1lOnQ/Lm5hbWV9KTtyZXR1cm4gcy5hZGRFdmVudExpc3RlbmVyKCJlcnJvciIsKCk9Pnsoc2VsZi5VUkx8fHNlbGYud2Via2l0VVJMKS5yZXZva2VPYmplY3RVUkwoZSl9KSxzfWNhdGNoe3JldHVybiBuZXcgV29ya2VyKCJkYXRhOnRleHQvamF2YXNjcmlwdDtiYXNlNjQsIitBLHtuYW1lOnQ/Lm5hbWV9KX1maW5hbGx5e2UmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLnJldm9rZU9iamVjdFVSTChlKX19Y29uc3QgdT0xZTY7Y2xhc3MgcHtmZm1wZWdXb3JrZXI7ZmZtcGVnV29ya2VyTG9hZFN0YXR1czttc2dJZDtmaWxlO2NvbnN0cnVjdG9yKGUpe3RoaXMuZmZtcGVnV29ya2VyPW5ldyBFLHRoaXMuZmZtcGVnV29ya2VyTG9hZFN0YXR1cz1uZXcgUHJvbWlzZSgocyxhKT0+e3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGk9Pntjb25zdHt0eXBlOnIsZXJyTXNnOmR9PWkuZGF0YTtyPT09by5GRm1wZWdXb3JrZXJMb2FkZWQmJnRoaXMucG9zdChvLkxvYWRXQVNNLHt3YXNtTG9hZGVyUGF0aDplLndhc21Mb2FkZXJQYXRofSkscj09PW8uV0FTTVJ1bnRpbWVJbml0aWFsaXplZCYmcyghMCkscj09PW8uTG9hZFdBU00mJmQmJmEoZCl9KX0pLHRoaXMubXNnSWQ9MH1wb3N0KGUscyxhKXt0aGlzLmZmbXBlZ1dvcmtlci5wb3N0TWVzc2FnZSh7dHlwZTplLG1zZ0lkOmE/P3RoaXMubXNnSWQrKyxkYXRhOnN9KX1hc3luYyBsb2FkKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5mZm1wZWdXb3JrZXJMb2FkU3RhdHVzO3JldHVybiB0aGlzLmZpbGU9ZSxzfWRlc3Ryb3koKXt0aGlzLmZpbGU9dm9pZCAwLHRoaXMuZmZtcGVnV29ya2VyLnRlcm1pbmF0ZSgpfWdldEFWU3RyZWFtKGU9bS5BVk1FRElBX1RZUEVfVklERU8scz0tMSl7cmV0dXJuIG5ldyBQcm9taXNlKChhLGkpPT57aWYoIXRoaXMuZmlsZSl7aSgiZmlsZSBpcyBub3QgbG9hZGVkIik7cmV0dXJufWNvbnN0IHI9dGhpcy5tc2dJZCxkPSh7ZGF0YTpufSk9PntuLnR5cGU9PT1vLkdldEFWU3RyZWFtJiZuLm1zZ0lkPT09ciYmKG4uZXJyTXNnP2kobi5lcnJNc2cpOmEobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGQpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZCksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW0se2ZpbGU6dGhpcy5maWxlLHN0cmVhbVR5cGU6ZSxzdHJlYW1JbmRleDpzfSl9KX1nZXRBVlN0cmVhbXMoKXtyZXR1cm4gbmV3IFByb21pc2UoKGUscyk9PntpZighdGhpcy5maWxlKXtzKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgYT10aGlzLm1zZ0lkLGk9KHtkYXRhOnJ9KT0+e3IudHlwZT09PW8uR2V0QVZTdHJlYW1zJiZyLm1zZ0lkPT09YSYmKHIuZXJyTXNnP3Moci5lcnJNc2cpOmUoci5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsaSksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW1zLHtmaWxlOnRoaXMuZmlsZX0pfSl9Z2V0QVZQYWNrZXQoZSxzPW0uQVZNRURJQV9UWVBFX1ZJREVPLGE9LTEpe3JldHVybiBuZXcgUHJvbWlzZSgoaSxyKT0+e2lmKCF0aGlzLmZpbGUpe3IoImZpbGUgaXMgbm90IGxvYWRlZCIpO3JldHVybn1jb25zdCBkPXRoaXMubXNnSWQsbj1oPT57Y29uc3QgbD1oLmRhdGE7bC50eXBlPT09by5HZXRBVlBhY2tldCYmbC5tc2dJZD09PWQmJihsLmVyck1zZz9yKGwuZXJyTXNnKTppKGwucmVzdWx0KSx0aGlzLmZmbXBlZ1dvcmtlci5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixuKSl9O3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLG4pLHRoaXMucG9zdChvLkdldEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSx0aW1lOmUsc3RyZWFtVHlwZTpzLHN0cmVhbUluZGV4OmF9KX0pfWdldEFWUGFja2V0cyhlKXtyZXR1cm4gbmV3IFByb21pc2UoKHMsYSk9PntpZighdGhpcy5maWxlKXthKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgaT10aGlzLm1zZ0lkLHI9ZD0+e2NvbnN0IG49ZC5kYXRhO24udHlwZT09PW8uR2V0QVZQYWNrZXRzJiZuLm1zZ0lkPT09aSYmKG4uZXJyTXNnP2Eobi5lcnJNc2cpOnMobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLHIpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsciksdGhpcy5wb3N0KG8uR2V0QVZQYWNrZXRzLHtmaWxlOnRoaXMuZmlsZSx0aW1lOmV9KX0pfXJlYWRBVlBhY2tldChlPTAscz0wLGE9bS5BVk1FRElBX1RZUEVfVklERU8saT0tMSl7Y29uc3Qgcj1uZXcgQ291bnRRdWV1aW5nU3RyYXRlZ3koe2hpZ2hXYXRlck1hcms6MX0pLGQ9dGhpcy5tc2dJZDtsZXQgbj0wO3JldHVybiBuZXcgUmVhZGFibGVTdHJlYW0oe3N0YXJ0Omg9PntpZighdGhpcy5maWxlKXtoLmVycm9yKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgbD1mPT57Y29uc3QgYz1mLmRhdGE7Yy50eXBlPT09by5SZWFkQVZQYWNrZXQmJmMubXNnSWQ9PT1kJiZjLmVyck1zZyYmKGguZXJyb3IoYy5lcnJNc2cpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGwpKSxjLnR5cGU9PT1vLkFWUGFja2V0U3RyZWFtJiZjLm1zZ0lkPT09ZCYmKGMucmVzdWx0P2guZW5xdWV1ZShjLnJlc3VsdCk6aC5jbG9zZSgpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsbCksdGhpcy5wb3N0KG8uUmVhZEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSxzdGFydDplLGVuZDpzLHN0cmVhbVR5cGU6YSxzdHJlYW1JbmRleDppfSl9LHB1bGw6KCk9PntuPjAmJnRoaXMucG9zdChvLlJlYWROZXh0QVZQYWNrZXQsdm9pZCAwLGQpLG4rK30sY2FuY2VsOigpPT57dGhpcy5wb3N0KG8uU3RvcFJlYWRBVlBhY2tldCx2b2lkIDAsZCl9fSxyKX1nZXRWaWRlb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9WSURFTyxlKX1nZXRBdWRpb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9BVURJTyxlKX1zZWVrVmlkZW9QYWNrZXQoZSl7cmV0dXJuIHRoaXMuZ2V0QVZQYWNrZXQoZSxtLkFWTUVESUFfVFlQRV9WSURFTyl9c2Vla0F1ZGlvUGFja2V0KGUpe3JldHVybiB0aGlzLmdldEFWUGFja2V0KGUsbS5BVk1FRElBX1RZUEVfQVVESU8pfXJlYWRWaWRlb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfVklERU8pfXJlYWRBdWRpb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfQVVESU8pfWdlblZpZGVvRGVjb2RlckNvbmZpZyhlKXtyZXR1cm57Y29kZWM6ZS5jb2RlY3Bhci5jb2RlY19zdHJpbmcsY29kZWRXaWR0aDplLmNvZGVjcGFyLndpZHRoLGNvZGVkSGVpZ2h0OmUuY29kZWNwYXIuaGVpZ2h0LGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRWaWRlb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZFZpZGVvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1nZW5BdWRpb0RlY29kZXJDb25maWcoZSl7cmV0dXJue2NvZGVjOmUuY29kZWNwYXIuY29kZWNfc3RyaW5nfHwiIixzYW1wbGVSYXRlOmUuY29kZWNwYXIuc2FtcGxlX3JhdGUsbnVtYmVyT2ZDaGFubmVsczplLmNvZGVjcGFyLmNoYW5uZWxzLGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRBdWRpb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZEF1ZGlvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1hc3luYyBnZXRWaWRlb0RlY29kZXJDb25maWcoKXtjb25zdCBlPWF3YWl0IHRoaXMuZ2V0VmlkZW9TdHJlYW0oKTtyZXR1cm4gdGhpcy5nZW5WaWRlb0RlY29kZXJDb25maWcoZSl9YXN5bmMgc2Vla0VuY29kZWRWaWRlb0NodW5rKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5zZWVrVmlkZW9QYWNrZXQoZSk7cmV0dXJuIHRoaXMuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsocyl9YXN5bmMgZ2V0QXVkaW9EZWNvZGVyQ29uZmlnKCl7Y29uc3QgZT1hd2FpdCB0aGlzLmdldEF1ZGlvU3RyZWFtKCk7cmV0dXJuIHRoaXMuZ2VuQXVkaW9EZWNvZGVyQ29uZmlnKGUpfWFzeW5jIHNlZWtFbmNvZGVkQXVkaW9DaHVuayhlKXtjb25zdCBzPWF3YWl0IHRoaXMuc2Vla0F1ZGlvUGFja2V0KGUpO3JldHVybiB0aGlzLmdlbkVuY29kZWRBdWRpb0NodW5rKHMpfX1jbGFzcyBre3ZpZGVvO2N1cnJlbnRGcmFtZXM9MDt0b3RhbEZyYW1lcztjdXJyZW50VGltZTtmcHM7Zmlyc3RUaW1lc3RhbXA7Y29uc3RydWN0b3IoZSxzKXt0aGlzLmN1cnJlbnRUaW1lPWVbMF0qMWU2LHRoaXMuZmlyc3RUaW1lc3RhbXA9ZVswXSoxZTYsdGhpcy50b3RhbEZyYW1lcz0oZVsxXS1lWzBdKSpzKzEsdGhpcy5mcHM9cyx0aGlzLnZpZGVvPW5ldyBWaWRlb0RlY29kZXIoe291dHB1dDp0aGlzLmhhbmRsZUZyYW1lT3V0cHV0LmJpbmQodGhpcyksZXJyb3I6dGhpcy5oYW5kbGVFcnJvci5iaW5kKHRoaXMpfSl9cG9zdEZyYW1lKGUpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImZyYW1lIixmcmFtZTplfSksdGhpcy5jdXJyZW50VGltZSs9TWF0aC5mbG9vcigxL3RoaXMuZnBzKjFlNiksdGhpcy5jdXJyZW50RnJhbWVzKz0xfWhhbmRsZUZyYW1lT3V0cHV0KGUpe2NvbnN0IHM9ZS50aW1lc3RhbXAsYT1lLmR1cmF0aW9uPz8wLGk9cythO2lmKCF0aGlzLmlzRnJhbWVJblJhbmdlKHMpKXtlLmNsb3NlKCk7cmV0dXJufWZvcig7aT50aGlzLmN1cnJlbnRUaW1lJiZ0aGlzLmN1cnJlbnRGcmFtZXM8PXRoaXMudG90YWxGcmFtZXM7KXRoaXMucG9zdEZyYW1lKGUpO2UuY2xvc2UoKX1pc0ZyYW1lSW5SYW5nZShlKXtyZXR1cm4gZT49dGhpcy5maXJzdFRpbWVzdGFtcH1oYW5kbGVFcnJvcihlKXtjb25zb2xlLmVycm9yKCJlcnJvciBpbiB3b3JrZXIiLGUpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOmUubWVzc2FnZT8/IkFuIHVua25vd24gd29ya2VyIGVycm9yIG9jY3VycmVkIn0pLHNlbGYuY2xvc2UoKX19ZnVuY3Rpb24gSSh0KXtyZXR1cm4gYXN5bmMgZT0+e3RyeXthd2FpdCB0KGUpfWNhdGNoKHMpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOnM/Lm1lc3NhZ2U/PyJBbiB1bmtvd24gd29ya2VyIGVycm9yIG9jY3VyZWQifSl9fX1mdW5jdGlvbiBXKHQpe3JldHVybiB0LmNvZGVjPT0idnAwOSImJih0LmNvZGVjPSJ2cDA5LjAwLjEwLjA4IiksdH1jb25zdCBaPTMwO2FzeW5jIGZ1bmN0aW9uIFAodCl7aWYodC5kYXRhPy50eXBlIT0iaW5pdCIpcmV0dXJuO2NvbnN0e2ZpbGU6ZSxyYW5nZTpzLGZwczphfT10LmRhdGEsaT1uZXcgcCh7d2FzbUxvYWRlclBhdGg6Imh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vQGRpZmZ1c2lvbnN0dWRpby9mZm1wZWctd2FzbUAxLjAuMC9kaXN0L2ZmbXBlZy5qcyJ9KTthd2FpdCBpLmxvYWQoZSk7Y29uc3Qgcj1hd2FpdCBpLmdldFZpZGVvRGVjb2RlckNvbmZpZygpO1cocik7Y29uc3QgZD1uZXcgayhzLGEpO2QudmlkZW8uY29uZmlndXJlKHIpO2NvbnN0IG49aS5yZWFkQVZQYWNrZXQoc1swXSxzWzFdKS5nZXRSZWFkZXIoKTtuLnJlYWQoKS50aGVuKGFzeW5jIGZ1bmN0aW9uIGgoe2RvbmU6bCx2YWx1ZTpmfSl7aWYobCl7YXdhaXQgZC52aWRlby5mbHVzaCgpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImRvbmUifSksc2VsZi5jbG9zZSgpO3JldHVybn1jb25zdCBjPWkuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsoZik7cmV0dXJuIGQudmlkZW8uZGVjb2RlUXVldWVTaXplPlomJmF3YWl0IG5ldyBQcm9taXNlKEw9PntkLnZpZGVvLm9uZGVxdWV1ZT0oKT0+TCgpfSksYy50aW1lc3RhbXA8PXNbMV0qMWU2JiZkLnZpZGVvLmRlY29kZShjKSxuLnJlYWQoKS50aGVuKGgpfSl9c2VsZi5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixJKFApKX0pKCk7Cg==",Jb=o=>Uint8Array.from(atob(o),a=>a.charCodeAt(0)),wc=typeof self<"u"&&self.Blob&&new Blob([Jb(_m)],{type:"text/javascript;charset=utf-8"});function qb(o){let a;try{if(a=wc&&(self.URL||self.webkitURL).createObjectURL(wc),!a)throw"";const t=new Worker(a,{name:o==null?void 0:o.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(a)}),t}catch{return new Worker("data:text/javascript;base64,"+_m,{name:o==null?void 0:o.name})}finally{a&&(self.URL||self.webkitURL).revokeObjectURL(a)}}class Yb{constructor(){ae(this,"frames",[]);ae(this,"state","active");ae(this,"onenqueue");ae(this,"onclose")}enqueue(a){var t;this.frames.unshift(a),(t=this.onenqueue)==null||t.call(this)}async dequeue(){if(this.frames.length==0&&this.state=="active"&&await this.waitFor(2e4),!(this.frames.length==0&&this.state=="closed"))return this.frames.pop()}close(){var a;this.state="closed",(a=this.onclose)==null||a.call(this)}terminate(){for(const a of this.frames)a.close()}async waitFor(a){await new Promise((t,n)=>{const i=setTimeout(()=>{n(`Promise timed out after ${a} ms`)},a);this.onenqueue=()=>{clearTimeout(i),t()},this.onclose=()=>{clearTimeout(i),t()}})}}function Qb(o,a,t){const n=t.value;return t.value=function(...i){var r,s,l,d;return(s=(r=this.track)==null?void 0:r.composition)!=null&&s.rendering&&this.sprite.texture.source.uid!=this.textrues.canvas.source.uid&&(this.sprite.texture=this.textrues.canvas),!((d=(l=this.track)==null?void 0:l.composition)!=null&&d.rendering)&&this.sprite.texture.source.uid!=this.textrues.html5.source.uid&&(this.sprite.texture=this.textrues.html5),n.apply(this,i)},t}var ey=Object.defineProperty,ty=Object.getOwnPropertyDescriptor,ay=(o,a,t,n)=>{for(var i=ty(a,t),r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(a,t,i)||i);return i&&ey(a,t,i),i};const Em=class xm extends Qr(Yr){constructor(t,n={}){super();ae(this,"source",new jn);ae(this,"type","video");ae(this,"worker");ae(this,"buffer");ae(this,"canvas",document.createElement("canvas"));ae(this,"context",this.canvas.getContext("2d"));ae(this,"element",document.createElement("video"));ae(this,"textrues",{html5:Et.Texture.from(this.element),canvas:Et.Texture.from(this.canvas)});ae(this,"sprite",new Et.Sprite);this.element.controls=!1,this.element.playsInline=!0,this.element.style.display="hidden",this.element.crossOrigin="anonymous",this.textrues.html5.source.autoPlay=!1,this.textrues.html5.source.loop=!1,this.sprite.texture=this.textrues.html5,this.view.addChild(this.sprite),t instanceof jn&&(this.source=t),t instanceof File&&this.source.from(t),this.element.addEventListener("play",()=>{this.playing=!0}),this.element.addEventListener("pause",()=>{this.playing=!1}),Object.assign(this,n)}async init(){const t=await this.source.createObjectURL();this.element.setAttribute("src",t),await new Promise((n,i)=>{this.element.oncanplay=()=>{this.duration.seconds=this.element.duration,this.state="READY",n()},this.element.onerror=()=>{this.state="ERROR";const r=new sn({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."});i(this.element.error??r)}})}async connect(t){var i;super.connect(t);const n=((i=t.composition)==null?void 0:i.frame)??0;await this.seek(Re.fromFrames(n))}enter(){var t,n,i;super.enter(),(n=(t=this.track)==null?void 0:t.composition)!=null&&n.rendering&&((i=this.buffer)==null?void 0:i.state)!="active"&&this.decodeVideo()}update(t){var n,i,r,s,l,d;if((i=(n=this.track)==null?void 0:n.composition)!=null&&i.playing&&!this.playing)this.element.play();else if(!((s=(r=this.track)==null?void 0:r.composition)!=null&&s.playing)&&this.playing)this.element.pause();else if((d=(l=this.track)==null?void 0:l.composition)!=null&&d.rendering)return this.nextFrame()}exit(){this.playing&&this.element.pause(),this.filters&&this.view.filters&&(this.view.filters=null)}copy(){const t=xm.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}async decodeVideo(){var t,n;return this.buffer=new Yb,this.worker=new qb,this.worker.addEventListener("message",i=>{var r,s;i.data.type=="frame"?(r=this.buffer)==null||r.enqueue(i.data.frame):i.data.type=="error"?this.cancelDecoding():i.data.type=="done"&&((s=this.buffer)==null||s.close())}),this.worker.postMessage({type:"init",file:await this.source.getFile(),range:this.demuxRange,fps:((n=(t=this.track)==null?void 0:t.composition)==null?void 0:n.fps)??_i}),this.buffer}async nextFrame(){if(!this.buffer)return;const t=await this.buffer.dequeue();t&&(this.canvas.width=t.displayWidth,this.canvas.height=t.displayHeight,this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.drawImage(t,0,0),this.textrues.canvas.source.update(),t.close())}get demuxRange(){var r;const t=(r=this.track)==null?void 0:r.composition;let n;this.start.millis<0?n=Math.abs(this.offset.seconds):n=this.range[0].seconds;let i;return t&&this.stop.millis>t.duration.millis?i=t.duration.subtract(this.offset).seconds:i=this.range[1].seconds,[n,i]}cancelDecoding(){var t,n;(t=this.worker)==null||t.terminate(),this.worker=void 0,(n=this.buffer)==null||n.terminate(),this.buffer=void 0}};ay([es,Qb],Em.prototype,"update");let kl=Em;class fi extends Yr{constructor(t,n={}){super();ae(this,"type","audio");ae(this,"source",new _n);ae(this,"element",new Audio);t instanceof _n&&(this.source=t),t instanceof File&&this.source.from(t),this.element.addEventListener("play",()=>{this.playing=!0}),this.element.addEventListener("pause",()=>{this.playing=!1}),Object.assign(this,n)}async init(){const t=await this.source.createObjectURL();this.element.setAttribute("src",t),this.element.load(),await new Promise((n,i)=>{this.element.oncanplay=()=>{this.duration.seconds=this.element.duration,this.state="READY",n()},this.element.onerror=()=>{this.state="ERROR";const r=new sn({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."});i(this.element.error??r)}})}update(){var t,n,i,r,s,l;if((n=(t=this.track)==null?void 0:t.composition)!=null&&n.rendering)return this.exit();(r=(i=this.track)==null?void 0:i.composition)!=null&&r.playing&&!this.playing?this.element.play():!((l=(s=this.track)==null?void 0:s.composition)!=null&&l.playing)&&this.playing&&this.element.pause()}exit(){this.playing&&this.element.pause()}copy(){const t=fi.fromJSON(JSON.parse(JSON.stringify(this)));return t.source=this.source,t}}const ny={IMAGE:{"image/jpeg":"jpg","image/png":"png","image/webp":"webp","image/svg+xml":"svg"},VIDEO:{"video/mp4":"mp4","video/webm":"webm","video/quicktime":"mov"},AUDIO:{"audio/mp3":"mp3","audio/mpeg":"mp3","audio/aac":"aac","audio/wav":"wav","audio/x-wav":"wav"},DOCUMENT:{"text/html":"html"},get MIXED(){return{...this.IMAGE,...this.VIDEO,...this.AUDIO,...this.DOCUMENT}}};function _l(o){if(!Object.keys(ny.MIXED).includes(o??""))throw new Ut({message:`${o} is not an accepted mime type`,code:"invalid_mimetype"});return o}var oy=Object.defineProperty,iy=Object.getOwnPropertyDescriptor,ry=(o,a,t,n)=>{for(var i=iy(a,t),r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(a,t,i)||i);return i&&oy(a,t,i),i};const sy=class Sm extends Qr(Ii){constructor(t,n={}){super();ae(this,"type","html");ae(this,"source",new gc);ae(this,"element",new Image);ae(this,"canvas",document.createElement("canvas"));ae(this,"context",this.canvas.getContext("2d"));ae(this,"sprite",new Et.Sprite);this.view.addChild(this.sprite),Object.assign(this,n),t instanceof gc&&(this.source=t),t instanceof File&&this.source.from(t),this.element.addEventListener("load",()=>{var s,l,d,c;const i=(l=(s=this.source.document)==null?void 0:s.body)==null?void 0:l.scrollWidth,r=(c=(d=this.source.document)==null?void 0:d.body)==null?void 0:c.scrollHeight;!i||!r||(this.canvas.width=i,this.canvas.height=r,this.context.imageSmoothingEnabled=!1,this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.drawImage(this.element,0,0),this.sprite.texture=Et.Texture.from(this.canvas,!0),this.trigger("load",void 0))}),this.element.addEventListener("error",i=>{this.state="ERROR",this.trigger("error",new sn({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."})),this.track&&this.detach()}),this.on("update",async()=>{this.source.update(),this.element.setAttribute("src",await this.source.createObjectURL())})}async init(){this.element.setAttribute("src",await this.source.createObjectURL()),await new Promise((t,n)=>{this.element.onload=()=>{var s,l,d,c;const i=(l=(s=this.source.document)==null?void 0:s.body)==null?void 0:l.scrollWidth,r=(c=(d=this.source.document)==null?void 0:d.body)==null?void 0:c.scrollHeight;if(!i||!r)return n(new sn({code:"sourceNotProcessable",message:"Cannot display source with height or width at 0"}));this.state="READY",t()},this.element.onerror=i=>{n(new sn({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=Sm.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};ry([es],sy.prototype,"update");const Cm=["DEFAULT","STACK"];class kc{constructor(){ae(this,"mode",Cm[0]);ae(this,"pauseAlignmet",!1)}add(a,t){let n=!0;for(let i=0;i<t.clips.length&&(n=xc(a,t.clips[i]),!!n);i++)Ec(a,t.clips[i]);n&&(t.clips.push(a),t.clips.sort(_c))}update(a,t){if(!this.pauseAlignmet){t.clips.sort(_c);for(let n=0;n<t.clips.length;n++)if(a.id!=t.clips[n].id){if(!xc(a,t.clips[n]))break;Ec(a,t.clips[n])}}}offset(a,t){this.pauseAlignmet=!0;for(const n of t.clips)n.offsetBy(a);this.pauseAlignmet=!1}}class ly{constructor(){ae(this,"mode",Cm[1])}add(a,t,n=void 0){var r;let i=-1;(n!=null&&n>0||n==null)&&(i=((r=t.clips.at((n??0)-1))==null?void 0:r.stop.millis)??-1),a.offsetBy(new Re(i-a.start.millis+1)),n==null?t.clips.push(a):(t.clips.splice(n,0,a),t.clips.slice(n+1).forEach(s=>{s.offsetBy(a.stop.subtract(a.start))}))}update(a,t){let n=0;for(const i of t.clips){if(i.start.millis!=n){const r=n-i.start.millis;i.offsetBy(new Re(r))}n=i.stop.millis+1}}offset(){}}function _c(o,a){return o.start.millis-a.start.millis}function Ec(o,a){o.start.millis>=a.start.millis&&o.start.millis<=a.stop.millis&&(o.start=a.stop.copy().addMillis(1)),o.stop.millis>=a.start.millis&&o.stop.millis<=a.stop.millis&&(o.stop=a.start.copy().addMillis(-1))}function xc(o,a){var t,n,i,r,s;if(o.start.millis>=a.start.millis&&o.stop.millis<=a.stop.millis){const l=(n=(t=a.track)==null?void 0:t.composition)==null?void 0:n.tracks.find(d=>d.type==o.type&&!d.clips.some(c=>o.id!=c.id&&o.start.millis>=c.start.millis&&o.stop.millis<=c.stop.millis));return l?(l.add(o.detach()),!1):((s=(r=(i=a.track)==null?void 0:i.composition)==null?void 0:r.createTrack(o.type))==null||s.add(o.detach()),!1)}return!0}class $o extends Ti(Ia){constructor(){super(...arguments);ae(this,"_disabled",!1);ae(this,"view",new Et.Container);ae(this,"clips",[]);ae(this,"pointer",0);ae(this,"composition");ae(this,"type","base");ae(this,"strategy",new kc)}get disabled(){return this._disabled}set disabled(t){var n;t&&this.clipRef&&Hs(this.clipRef)&&(this.view.removeChild(this.clipRef.view),(n=this.clipRef)==null||n.exit()),this._disabled=t,this.trigger("update",void 0)}connect(t){this.composition=t}stacked(t=!0){return t?(this.strategy=new ly,this.strategy.update(new Ii,this)):this.strategy=new kc,this.trigger("update",void 0),this}layer(t){var l,d;const n=((l=this.composition)==null?void 0:l.tracks)??[],i=n.findIndex(c=>c.id==this.id),r=n.length-1;if(i==-1)return this;let s=0;return t=="bottom"?s=r:t=="top"||t<0?s=0:t>r?s=r:s=t,gb(n,i,s),(d=this.composition)==null||d.stage.setChildIndex(this.view,r-s),this.trigger("update",void 0),this}seek(t){}offsetBy(t){return typeof t=="number"?this.strategy.offset(Re.fromFrames(t),this):this.strategy.offset(t,this),this}update(t){var i,r;if(this.disabled||!this.clips.length)return;const{millis:n}=t;if(Hs(this.clipRef)&&(!Ws(n,this.clipRef)||(i=this.clipRef)!=null&&i.disabled)&&(this.clipRef&&this.view.removeChild(this.clipRef.view),(r=this.clipRef)==null||r.exit()),!!Ws(n,this))for(let s=0;s<this.clips.length;s++){const l=(this.pointer+s)%this.clips.length,d=this.clips[l],c=this.clips[l-1];if(Ws(n,d)&&!d.disabled)return this.pointer=l,Hs(d)||(d.enter(),this.view.addChild(d.view)),d.update(t);if(n<d.start.millis&&n>((c==null?void 0:c.stop.millis)??0)){this.pointer=l;return}}}async add(t,n){return this.composition&&!this.composition.renderer&&await new Promise(this.composition.resolve("init")),await t.init(),await t.connect(this),await this.strategy.add(t,this,n),t.on("frame",()=>{this.strategy.update(t,this)}),t.bubble(this),this.trigger("attach",void 0),t}remove(t){const n=this.clips.findIndex(i=>i.id==t.id);if(t.state=="ATTACHED"&&(t.state="READY"),t.view.parent&&this.view.removeChild(t.view),n!=null&&n>=0)return this.clips.splice(n,1),this.strategy.update(t,this),this.trigger("detach",void 0),t.off("*"),t}get stop(){var t;return((t=this.clips.at(-1))==null?void 0:t.stop)??new Re}get start(){var t;return((t=this.clips.at(0))==null?void 0:t.start)??new Re}apply(t){this.clips.forEach(t)}detach(){var t;return(t=this.composition)==null||t.removeTrack(this),this}get clipRef(){return this.clips[this.pointer]}}function Ws(o,a){return a?o>=a.start.millis&&o<=a.stop.millis:!1}function Hs(o){return o?!!o.view.parent:!1}class dy{static fromType(a){switch(a.type){case"video":return new cy;case"audio":return new my;case"html":return new py;case"image":return new uy;case"text":return new Sc;case"complex_text":return new Sc;case"caption":return new hy;default:return new $o}}}class Vm extends $o{constructor(){super(...arguments);ae(this,"clips",[])}async seek(t){for(const n of this.clips)await n.seek(t)}async removeSilences(t={}){const n=[];for(const i of this.clips.map(r=>r.detach()))n.push(...await i.removeSilences(t));for(const i of n)await this.add(i)}}class cy extends Vm{constructor(){super(...arguments);ae(this,"type","video")}async seek(t){var n;(n=this.composition)!=null&&n.rendering?this.view.removeChildren():super.seek(t)}}class uy extends $o{constructor(){super(...arguments);ae(this,"type","image")}}class my extends Vm{constructor(){super(...arguments);ae(this,"type","audio")}}class Sc extends $o{constructor(){super(...arguments);ae(this,"type","text")}}class py extends $o{constructor(){super(...arguments);ae(this,"type","html")}}var fy=Object.defineProperty,md=(o,a,t,n)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(a,t,i)||i);return i&&fy(a,t,i),i};class Fi extends Ia{constructor(t={}){super();ae(this,"generatorOptions");ae(this,"type","CLASSIC");ae(this,"position");this.generatorOptions=t.generatorOptions??{duration:[.2]},this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var r,s,l;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Ut({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const n=((l=t.clip)==null?void 0:l.offset)??new Re,i=await na.fromFamily({family:"Figtree",weight:"700"}).load();for(const d of t.clip.transcript.iter(this.generatorOptions))await t.add(new Mo({text:d.words.map(c=>c.text).join(" "),textAlign:"center",textBaseline:"middle",fontSize:21,fillStyle:"#FFFFFF",font:i,stroke:{color:"#000000",width:4,join:"round"},maxWidth:t.composition.width*.85,shadow:{color:"#000000",blur:0,distance:1.1,angle:Math.PI*.4,alpha:1},position:this.position,stop:d.stop.add(n),start:d.start.add(n),scale:new ze([0,8],[.96,1],{easing:"easeOut"}),alpha:new ze([0,4],[0,1],{easing:"easeOut"})}))}}md([Me()],Fi.prototype,"generatorOptions");md([Me()],Fi.prototype,"type");md([Me()],Fi.prototype,"position");class hy extends $o{constructor(){super(...arguments);ae(this,"clip");ae(this,"type","caption");ae(this,"preset",new Fi)}from(t){var n;return this.clip=t,(n=this.clip)==null||n.on("offsetBy",i=>this.offsetBy(i.detail)),this}async generate(t){let n=this.preset;return typeof t=="object"?n=t:t&&(n=new t),this.clips=[],this.trigger("update",void 0),this.preset=n,await n.applyTo(this),this.trigger("update",void 0),this}}var vy=Object.defineProperty,ns=(o,a,t,n)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(a,t,i)||i);return i&&vy(a,t,i),i};class $i extends Ia{constructor(t={}){super();ae(this,"generatorOptions");ae(this,"type","SPOTLIGHT");ae(this,"color");ae(this,"position");this.generatorOptions=t.generatorOptions??{duration:[.2]},this.color=t.color??"#00FF4C",this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var r,s,l;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Ut({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const n=((l=t.clip)==null?void 0:l.offset)??new Re,i=await na.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const d of t.clip.transcript.iter(this.generatorOptions))for(let c=0;c<d.words.length;c++){const u=d.words.map(f=>f.text);await t.add(new as({text:u.join(" "),textAlign:"center",textBaseline:"middle",fillStyle:"#FFFFFF",fontSize:22,maxWidth:t.composition.width*.8,font:i,stroke:{width:5,color:"#000000"},shadow:{color:"#000000",blur:12,alpha:.7,angle:Math.PI/4,distance:2},position:this.position,styles:[{fillStyle:this.color}],segments:d.words.length>1?[{index:0,start:u.slice(0,c).join(" ").length,stop:u.slice(0,c+1).join(" ").length}]:void 0,stop:d.words[c].stop.add(n),start:d.words[c].start.add(n)}))}}}ns([Me()],$i.prototype,"generatorOptions");ns([Me()],$i.prototype,"type");ns([Me()],$i.prototype,"color");ns([Me()],$i.prototype,"position");var gy=Object.defineProperty,pd=(o,a,t,n)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(a,t,i)||i);return i&&gy(a,t,i),i};class os extends Ia{constructor(t={}){super();ae(this,"type","GUINEA");ae(this,"colors");ae(this,"position");this.colors=t.colors??["#1BD724","#FFEE0C","#FF2E17"],this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var r,s,l,d,c,u,f;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Ut({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const n=((l=t.clip)==null?void 0:l.offset)??new Re,i=await na.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const m of t.clip.transcript.iter({length:[18]})){const{segments:p,words:h}=this.splitSequence(m);for(let v=0;v<m.words.length;v++){const w=(c=(d=h[v])==null?void 0:d.at(0))==null?void 0:c.start,E=(f=(u=h[v])==null?void 0:u.at(-1))==null?void 0:f.stop;!w||!E||await t.add(new as({text:p.join(`
|
|
33
|
-
`),textAlign:"center",textBaseline:"middle",fontSize:20,fillStyle:"#FFFFFF",shadow:{color:"#000000",blur:16,alpha:.8,angle:Math.PI/4,distance:1},stroke:{width:4,color:"#000000"},maxWidth:t.composition.width*.8,leading:1.3,font:i,textCase:"upper",position:this.position,stop:E.add(n),start:w.add(n),styles:[{fillStyle:this.colors[0],fontSize:23},{fillStyle:this.colors[1],fontSize:23},{fillStyle:this.colors[2],fontSize:23}],segments:[{index:_r(0,2),start:p.slice(0,v).join(" ").length,stop:p.slice(0,v+1).join(" ").length+v*2}]}))}}}splitSequence(t){const n=t.text,i=Math.ceil(n.length/2);let r=n.length;for(let d=i,c=i;d>0&&c<t.text.length-1;d--,c++){if(n[d].match(/ /)){r=d;break}if(n[c].match(/ /)){r=c;break}}const s=[...cc(n,r).map(d=>d.trim())],l=cc(t.words,s[0].split(/ /).length);return{segments:s,words:l}}}pd([Me()],os.prototype,"type");pd([Me()],os.prototype,"colors");pd([Me()],os.prototype,"position");var by=Object.defineProperty,fd=(o,a,t,n)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(a,t,i)||i);return i&&by(a,t,i),i};class is extends Ia{constructor(t={}){super();ae(this,"generatorOptions");ae(this,"type","CASCADE");ae(this,"position");this.generatorOptions=t.generatorOptions??{duration:[1.4]},this.position=t.position??{x:"12%",y:"44%"}}async applyTo(t){var r,s,l;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Ut({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const n=((l=t.clip)==null?void 0:l.offset)??new Re,i=await na.fromFamily({family:"Geologica",weight:"400"}).load();for(const d of t.clip.transcript.iter(this.generatorOptions))for(let c=0;c<d.words.length;c++){const u=()=>d.words.length==1?d.text:d.words.map(f=>f.text).slice(0,c+1).join(" ");await t.add(new Mo({text:u(),textAlign:"left",textBaseline:"top",fillStyle:"#FFFFFF",fontSize:16,font:i,maxWidth:t.composition.width*.7,stroke:{color:"#000000",width:4,join:"round"},shadow:{color:"#000000",blur:8,alpha:.4,angle:Math.PI/4,distance:2},position:this.position,stop:d.words[c].stop.add(n),start:d.words[c].start.add(n)}))}}}fd([Me()],is.prototype,"generatorOptions");fd([Me()],is.prototype,"type");fd([Me()],is.prototype,"position");var yy=Object.defineProperty,hd=(o,a,t,n)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(a,t,i)||i);return i&&yy(a,t,i),i};class rs extends Ia{constructor(t={}){super();ae(this,"generatorOptions");ae(this,"type","SOLAR");ae(this,"position");this.generatorOptions=t.generatorOptions??{duration:[.2]},this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var s,l,d;if(!((s=t.clip)!=null&&s.transcript)||!((l=t.composition)!=null&&l.width))throw new Ut({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const n=await na.fromFamily({family:"Urbanist",weight:"800"}).load(),i=((d=t.clip)==null?void 0:d.offset)??new Re,r=new zf.GlowFilter({color:"#fffe41",alpha:.25,distance:90,quality:.05});for(const c of t.clip.transcript.iter(this.generatorOptions))await t.add(new Mo({text:c.words.map(u=>u.text).join(" "),textAlign:"center",textBaseline:"middle",fontSize:19,fillStyle:"#fffe41",font:n,maxWidth:t.composition.width*.85,textCase:"upper",shadow:{color:"#ab7a00",blur:0,distance:2.1,angle:Math.PI/2.5,alpha:1},position:this.position,stop:c.stop.add(i),start:c.start.add(i),scale:new ze([0,8],[.96,1],{easing:"easeOut"}),alpha:new ze([0,4],[0,1],{easing:"easeOut"}),filters:r}))}}hd([Me()],rs.prototype,"generatorOptions");hd([Me()],rs.prototype,"type");hd([Me()],rs.prototype,"position");var wy=Object.defineProperty,ss=(o,a,t,n)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(a,t,i)||i);return i&&wy(a,t,i),i};class Di extends Ia{constructor(t={}){super();ae(this,"generatorOptions");ae(this,"type","WHISPER");ae(this,"color");ae(this,"position");this.generatorOptions=t.generatorOptions??{length:[20]},this.color=t.color??"#8c8c8c",this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var r,s,l;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Ut({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const n=((l=t.clip)==null?void 0:l.offset)??new Re,i=await na.fromFamily({family:"Montserrat",weight:"300"}).load();for(const d of t.clip.transcript.iter(this.generatorOptions))for(let c=0;c<d.words.length;c++){const u=d.words.map(f=>f.text);await t.add(new as({text:u.join(" "),textAlign:"center",textBaseline:"middle",fillStyle:"#FFFFFF",fontSize:13,background:{alpha:.3,padding:{x:50,y:30}},maxWidth:t.composition.width*.8,font:i,position:this.position,styles:[{fillStyle:this.color}],stop:d.words[c].stop.add(n),start:d.words[c].start.add(n),segments:u.length>1?[{index:0,start:u.slice(0,c+1).join(" ").length}]:void 0}))}}}ss([Me()],Di.prototype,"generatorOptions");ss([Me()],Di.prototype,"type");ss([Me()],Di.prototype,"color");ss([Me()],Di.prototype,"position");var ky=Object.defineProperty,ls=(o,a,t,n)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(a,t,i)||i);return i&&ky(a,t,i),i};class ds extends Ia{constructor(t={}){super();ae(this,"type","VERDANT");ae(this,"generatorOptions");ae(this,"color");ae(this,"position");this.generatorOptions=t.generatorOptions??{duration:[1]},this.color=t.color??"#69E34C",this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var r,s,l;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Ut({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const n=((l=t.clip)==null?void 0:l.offset)??new Re,i=await na.fromFamily({family:"Montserrat",weight:"800"}).load();for(const d of t.clip.transcript.iter(this.generatorOptions))for(let c=0;c<d.words.length;c++){const u=d.words.map(f=>f.text);await t.add(new as({text:u.join(" "),textAlign:"center",textBaseline:"middle",fontSize:15,fillStyle:"#FFFFFF",shadow:{color:"#000000",blur:4,alpha:.7,angle:Math.PI/4,distance:2},stroke:{width:3,color:"#000000"},maxWidth:t.composition.width*.5,leading:1.1,font:i,textCase:"upper",styles:[{fillStyle:this.color,fontSize:19}],position:this.position,stop:d.words[c].stop.add(n),start:d.words[c].start.add(n),segments:[{index:0,start:u.slice(0,c).join(" ").length,stop:u.slice(0,c+1).join(" ").length}]}))}}}ls([Me()],ds.prototype,"type");ls([Me()],ds.prototype,"generatorOptions");ls([Me()],ds.prototype,"color");ls([Me()],ds.prototype,"position");class _y extends Ti(Ia){constructor({height:t=1080,width:n=1920,background:i="#000000",backend:r="webgpu"}={}){super();ae(this,"_duration",new Re);ae(this,"renderer");ae(this,"stage",new Et.Container);ae(this,"settings");ae(this,"tracks",[]);ae(this,"frame",0);ae(this,"fixedDuration");ae(this,"state","IDLE");ae(this,"fps",_i);ae(this,"canvas");ae(this,"context");this.settings={height:t,width:n,background:i,backend:r},this.on("update",this.update.bind(this)),this.on("attach",this.update.bind(this)),this.on("detach",this.update.bind(this)),this.on("load",this.update.bind(this)),this.on("frame",this.update.bind(this)),this.on("error",this.update.bind(this)),Et.autoDetectRenderer({...this.settings,preference:r}).then(s=>{this.renderer=s,this.trigger("init",void 0)}).catch(s=>{this.trigger("error",new To({code:"backendDetectionError",message:`${s}`}))})}get playing(){return this.state=="PLAY"}get rendering(){return this.state=="RENDER"}get width(){return this.settings.width}get height(){return this.settings.height}get duration(){return this.fixedDuration?this.fixedDuration:this._duration}set duration(t){var n;t?t instanceof Re?this.fixedDuration=t:this.fixedDuration=Re.fromFrames(t):this.fixedDuration=void 0,this.trigger("frame",((n=this.fixedDuration)==null?void 0:n.frames)??0)}resize(t,n){var i;this.settings.width=t,this.settings.height=n,(i=this.renderer)==null||i.resize(t,n),this.canvas&&(this.canvas.height=n,this.canvas.width=t),this.trigger("resize",void 0),this.computeFrame()}attachPlayer(t){this.canvas||(this.canvas=document.createElement("canvas"),this.canvas.height=this.settings.height,this.canvas.width=this.settings.width,this.canvas.style.background="black",this.context=this.canvas.getContext("2d"),this.context.imageSmoothingEnabled=!1,this.computeFrame()),t.appendChild(this.canvas)}detachPlayer(t){this.canvas&&t.removeChild(this.canvas)}shiftTrack(t){const n=typeof t=="object"?t:new t;return n.connect(this),this.stage.addChild(n.view),this.tracks.unshift(n),n.bubble(this),this.trigger("update",void 0),n}createTrack(t){const n=dy.fromType({type:t});return this.shiftTrack(n),n}async add(t){return await this.createTrack(t.type).add(t),t}remove(t){for(const n of this.tracks)if(n.clips.find(i=>i.id==t.id))return n.remove(t)}removeTracks(t){const n=this.tracks.filter(i=>i instanceof t);return this.tracks=this.tracks.filter(i=>!(i instanceof t)),n.forEach(i=>this.removeTrack(i)),n}findTracks(t){return this.tracks.filter(n=>{let i;return uc(t)?i=n instanceof t:i=t(n),i})}findClips(t){const n=[];for(const i of this.tracks)for(const r of i.clips){let s;uc(t)?s=r instanceof t:s=t(r),s&&n.push(r)}return n}computeFrame(){var t,n;if(this.renderer){for(let i=0;i<this.tracks.length;i++)this.tracks[i].update(Re.fromFrames(this.frame));this.renderer.render(this.stage),(t=this.context)==null||t.clearRect(0,0,this.settings.width,this.settings.height),(n=this.context)==null||n.drawImage(this.renderer.canvas,0,0),this.trigger("currentframe",this.frame),this.playing&&this.frame++}}screenshot(t="png",n=1){if(this.computeFrame(),!this.renderer)throw new To({code:"rendererNotDefined",message:"Please wait until the renderer is defined"});return this.renderer.canvas.toDataURL(`image/${t}`,n)}async seek(t){typeof t=="number"?this.frame=Math.round(t>0?t:0):this.frame=t.frames>0?t.frames:0,this.playing&&this.pause();for(const n of this.tracks)await n.seek(Re.fromFrames(this.frame));this.rendering||this.computeFrame()}async play(){if(!this.rendering){this.state="PLAY",this.frame>=this.duration.frames&&(this.frame=0);for(const t of this.tracks)await t.seek(Re.fromFrames(this.frame));this.ticker(),this.trigger("play",this.frame)}}async pause(){this.state="IDLE",this.computeFrame(),this.trigger("pause",this.frame)}async audio(t=2,n=48e3){var s;const i=this.duration.seconds*n,r=new OfflineAudioContext({sampleRate:n,length:i,numberOfChannels:t}).createBuffer(t,i,n);for(const l of this.findClips(Yr)){if(l.disabled||l.muted||(s=l.track)!=null&&s.disabled)continue;const d=Math.round(l.offset.seconds*r.sampleRate),c=Math.round(l.range[0].seconds*r.sampleRate),u=Math.round(l.range[1].seconds*r.sampleRate);try{const f=await l.source.decode(t,n),m=f.numberOfChannels-1;for(let p=0;p<t;p++){const h=r.getChannelData(p),v=f.getChannelData(p>m?m:p);for(let w=0;w<h.length-1;w++)w<d+c||w>d+u||w-d<0||(h[w]+=(v[w-d]??0)*l.volume,h[w]>1&&(h[w]=1),h[w]<-1&&(h[w]=-1));r.getChannelData(p).set(h)}}catch{}}return r}time(t){const n=Eo(this.frame),i=t!=null&&t.hours?11:14,r=t!=null&&t.milliseconds?23:19;return new Date(n).toISOString().slice(i,r)+" / "+new Date(this.duration.millis).toISOString().slice(i,r)}removeTrack(t){const n=this.tracks.findIndex(i=>i.id==t.id);if(t.view.parent&&this.stage.removeChild(t.view),n!=null&&n>=0)return this.tracks.splice(n,1),this.trigger("detach",void 0),t.off("*"),t}async ticker(){const t=1e3/_i;let n=performance.now(),i=0;do{const r=await new Promise(requestAnimationFrame);r-n<t-i||(i=Math.min(t,i+r-n-t),n=r,this.computeFrame())}while(this.frame<=this.duration.frames&&this.playing);this.playing&&this.seek(0)}update(){this._duration.frames=Math.max(...this.tracks.filter(t=>!t.disabled).map(t=>{var n;return((n=t.stop)==null?void 0:n.frames)??0}),0),this.computeFrame()}}function Ey(o,a){const t=new Uint8Array(19);return t[0]=79,t[1]=112,t[2]=117,t[3]=115,t[4]=72,t[5]=101,t[6]=97,t[7]=100,t[8]=1,t[9]=a,t[10]=0,t[11]=0,t[12]=o&255,t[13]=o>>8&255,t[14]=o>>16&255,t[15]=o>>24&255,t[16]=0,t[17]=0,t[18]=0,t}const El=[8e3,12e3,16e3,24e3,48e3],xy="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.wasm",Sy="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.js";class Cy{constructor(a){ae(this,"output");ae(this,"error");ae(this,"config");ae(this,"encoder");ae(this,"opus");ae(this,"meta");this.output=a.output,this.error=a.error}async configure(a){const t=await import(Sy),{numberOfChannels:n,sampleRate:i}=this.config=a;if(!El.includes(i))throw new Ar({code:"sampleRateNotSupported",message:`Unsupported sample rate, supported: ${El.join()}`});this.opus=await t.default({locateFile(r,s){return r.endsWith(".wasm")?xy:s+r}}),this.encoder=this.opus._opus_encoder_create(i,n,2048),this.meta={decoderConfig:{codec:"opus",description:Ey(i,n).buffer,numberOfChannels:n,sampleRate:i}}}encode({data:a,numberOfFrames:t,timestamp:n=0}){if(!this.encoder||!this.opus||!this.config||!this.meta)throw new Ar({code:"unconfiguredEncoder",message:"Cannot encode samples using an unconfigured encoder"});const{sampleRate:i,numberOfChannels:r}=this.config,s=Math.floor(i/1e3*20);let l=0;const d=s/i*1e6;for(;l<t;){const c=a.subarray(l*r,(l+s)*r),u=this.opus._malloc(c.length*2);this.opus.HEAP16.set(c,u>>1);const f=4e3,m=this.opus._malloc(f),p=this.opus._opus_encode(this.encoder,u,s,m,f);if(p>0){const h=new Uint8Array(this.opus.HEAPU8.subarray(m,m+p));this.output({data:h,timestamp:n,type:"key",duration:d},this.meta)}else this.error(new DOMException("PCM chunk could not be encoded"));this.opus._free(u),this.opus._free(m),l+=s,n+=d}}}function Vy(o){const a=El;let t=48e3;for(const n of a)Math.abs(o-n)<Math.abs(o-t)&&(t=n);return t}class Ny{constructor(a,t){ae(this,"canvas");ae(this,"muxer");ae(this,"videoEncoder");ae(this,"frame",0);ae(this,"sampleRate");ae(this,"numberOfChannels");ae(this,"videoBitrate");ae(this,"gpuBatchSize");ae(this,"fps");ae(this,"height");ae(this,"width");ae(this,"audio");this.canvas=a,this.width=a.width,this.height=a.height,this.fps=(t==null?void 0:t.fps)??30,this.sampleRate=Vy((t==null?void 0:t.sampleRate)??48e3),this.numberOfChannels=(t==null?void 0:t.numberOfChannels)??2,this.videoBitrate=(t==null?void 0:t.videoBitrate)??1e7,this.gpuBatchSize=(t==null?void 0:t.gpuBatchSize)??5,this.audio=(t==null?void 0:t.audio)??!1}async init(){const a=await wb({height:Math.round(this.height),width:Math.round(this.width),bitrate:this.videoBitrate,fps:this.fps});this.muxer=new pm({target:new ad,video:{...a[0],codec:"avc"},firstTimestampBehavior:"offset",fastStart:"in-memory",audio:this.audio?{numberOfChannels:this.numberOfChannels,sampleRate:this.sampleRate,codec:"opus"}:void 0});const t={output:(n,i)=>{i&&this.muxer.addVideoChunk(n,i)},error:console.error};this.videoEncoder=new VideoEncoder(t),this.videoEncoder.configure(a[0])}async encodeVideo(a){var n;this.videoEncoder||await this.init(),this.videoEncoder.encodeQueueSize>this.gpuBatchSize&&await new Promise(i=>{this.videoEncoder.ondequeue=()=>i(null)});const t=new VideoFrame(a??this.canvas,{timestamp:Math.floor(this.frame/this.fps*1e6),duration:Math.floor(1e6/this.fps)});(n=this.videoEncoder)==null||n.encode(t,{keyFrame:this.frame%(3*this.fps)==0}),t.close(),this.frame++}async encodeAudio(a){if(!this.audio)throw new Ar({code:"initializationError",message:"Encoder must be initialized using {audio: true} to use this method"});this.muxer||await this.init();const t=yb(a,this.sampleRate,this.numberOfChannels),n=new Cy({output:(i,r)=>{var s;(s=this.muxer)==null||s.addAudioChunkRaw(i.data,i.type,i.timestamp,i.duration,r)},error:console.error});await n.configure({numberOfChannels:this.numberOfChannels,sampleRate:this.sampleRate}),n.encode({data:bb(t),numberOfFrames:t.length})}async blob(){var t,n,i;await((t=this.videoEncoder)==null?void 0:t.flush()),(n=this.muxer)==null||n.finalize();const a=(i=this.muxer)==null?void 0:i.target.buffer;if(!a)throw new Ar({code:"unexpectedRenderError",message:"Muxer could not be finalized because the target buffer is not defined"});return new Blob([a],{type:"video/mp4"})}async export(){return this.blob()}}async function Ty(o){var n,i;const a=(n=o.metadata)==null?void 0:n.source_url;if(a)return a;const t=(i=o.source)==null?void 0:i.media_uuid;if(t){if(typeof window<"u"){const r=window;if(r.MEDIABLES_MEDIA_URLS&&r.MEDIABLES_MEDIA_URLS[t])return r.MEDIABLES_MEDIA_URLS[t]}if(!t.startsWith("temp-"))try{if(typeof fetch<"u"){const r=await fetch(`/api/media/${t}`);if(r.ok){const s=await r.json();return s.playback_url||s.url||void 0}}}catch{}}}const wi=class wi{constructor(a){this.transitions=new Map,this.nextId=0,this.composition=a}async applyTransition(a,t,n){const i=`transition-${this.nextId++}`,r=Math.round(n.duration*30),s=n.easing||"linear",l=this.findTrackForClip(a),d=this.findTrackForClip(t);if(!l||!d)throw new Error("Clips must be added to composition before applying transitions");const c=a.stop.frames-r,u=a.stop.frames;switch(n.type){case"fade":await this.applyFadeTransition(a,t,c,u,s);break;case"dissolve":case"cross-fade":await this.applyCrossFadeTransition(a,t,c,u,s);break;case"wipe-left":case"wipe-right":case"wipe-up":case"wipe-down":await this.applyWipeTransition(a,t,n.type,c,u,s);break;case"slide-left":case"slide-right":case"slide-up":case"slide-down":await this.applySlideTransition(a,t,n.type,c,u,s);break;case"zoom-in":case"zoom-out":await this.applyZoomTransition(a,t,n.type,c,u,s);break;case"dip-to-black":case"dip-to-white":await this.applyDipTransition(a,t,n.type,c,u,s);break}return this.transitions.set(i,n),i}async applyFadeTransition(a,t,n,i,r){if(!this.isVideoClip(a)||!this.isVideoClip(t))throw new Error("Fade transitions require VideoClip instances");a.alpha=new ze([n,i],[1,0],{easing:r}),t.alpha=new ze([n,i],[0,1],{easing:r}),t.start=Re.fromFrames(n)}async applyCrossFadeTransition(a,t,n,i,r){if(!this.isVideoClip(a)||!this.isVideoClip(t))throw new Error("Cross-fade transitions require VideoClip instances");a.alpha=new ze([n,i],[1,0],{easing:r}),t.alpha=new ze([n,i],[0,1],{easing:r}),t.start=Re.fromFrames(n)}async applyWipeTransition(a,t,n,i,r,s){if(!this.isVideoClip(a)||!this.isVideoClip(t))throw new Error("Wipe transitions require VideoClip instances");const l={x:0,y:0},d={x:0,y:0};switch(n){case"wipe-left":l.x=new ze([i,r],[0,-1920],{easing:s}),d.x=new ze([i,r],[1920,0],{easing:s});break;case"wipe-right":l.x=new ze([i,r],[0,1920],{easing:s}),d.x=new ze([i,r],[-1920,0],{easing:s});break;case"wipe-up":l.y=new ze([i,r],[0,-1080],{easing:s}),d.y=new ze([i,r],[1080,0],{easing:s});break;case"wipe-down":l.y=new ze([i,r],[0,1080],{easing:s}),d.y=new ze([i,r],[-1080,0],{easing:s});break}a.translate=l,t.translate=d,t.start=Re.fromFrames(i)}async applySlideTransition(a,t,n,i,r,s){if(!this.isVideoClip(a)||!this.isVideoClip(t))throw new Error("Slide transitions require VideoClip instances");const l={x:0,y:0},d={x:0,y:0};switch(n){case"slide-left":l.x=new ze([i,r],[0,-1920],{easing:s}),d.x=new ze([i,r],[1920,0],{easing:s});break;case"slide-right":l.x=new ze([i,r],[0,1920],{easing:s}),d.x=new ze([i,r],[-1920,0],{easing:s});break;case"slide-up":l.y=new ze([i,r],[0,-1080],{easing:s}),d.y=new ze([i,r],[1080,0],{easing:s});break;case"slide-down":l.y=new ze([i,r],[0,1080],{easing:s}),d.y=new ze([i,r],[-1080,0],{easing:s});break}a.translate=l,t.translate=d,t.start=Re.fromFrames(i)}async applyZoomTransition(a,t,n,i,r,s){if(!this.isVideoClip(a)||!this.isVideoClip(t))throw new Error("Zoom transitions require VideoClip instances");n==="zoom-in"?(a.scale=new ze([i,r],[1,2],{easing:s}),a.alpha=new ze([i,r],[1,0],{easing:s}),t.scale=new ze([i,r],[.5,1],{easing:s}),t.alpha=new ze([i,r],[0,1],{easing:s})):(a.scale=new ze([i,r],[1,.5],{easing:s}),a.alpha=new ze([i,r],[1,0],{easing:s}),t.scale=new ze([i,r],[2,1],{easing:s}),t.alpha=new ze([i,r],[0,1],{easing:s})),t.start=Re.fromFrames(i)}async applyDipTransition(a,t,n,i,r,s){if(!this.isVideoClip(a)||!this.isVideoClip(t))throw new Error("Dip transitions require VideoClip instances");const l=Math.round((i+r)/2),d=n==="dip-to-black"?"#000000":"#ffffff",c=await yl.fromColor(d),u=new Ub(c,{start:Re.fromFrames(i),stop:Re.fromFrames(r)});a.alpha=new ze([i,l],[1,0],{easing:s}),u.alpha=new ze([i,l,r],[0,1,0],{easing:s}),t.alpha=new ze([l,r],[0,1],{easing:s}),await this.composition.add(u),t.start=Re.fromFrames(l)}findTrackForClip(a){for(const t of this.composition.tracks)if(t.clips.includes(a))return t}removeTransition(a){this.transitions.delete(a)}getTransitions(){return new Map(this.transitions)}static getAvailableTransitions(){return[...wi.TRANSITIONS]}static previewTransition(a){return wi.TRANSITIONS.find(t=>t.type===a)}isVideoClip(a){return"alpha"in a&&"scale"in a&&"translate"in a}};wi.TRANSITIONS=[{type:"fade",name:"Fade",description:"Simple fade transition"},{type:"dissolve",name:"Dissolve",description:"Cross-dissolve between clips"},{type:"wipe-left",name:"Wipe Left",description:"Wipe from right to left"},{type:"wipe-right",name:"Wipe Right",description:"Wipe from left to right"},{type:"wipe-up",name:"Wipe Up",description:"Wipe from bottom to top"},{type:"wipe-down",name:"Wipe Down",description:"Wipe from top to bottom"},{type:"slide-left",name:"Slide Left",description:"Slide out to the left"},{type:"slide-right",name:"Slide Right",description:"Slide out to the right"},{type:"slide-up",name:"Slide Up",description:"Slide out upward"},{type:"slide-down",name:"Slide Down",description:"Slide out downward"},{type:"zoom-in",name:"Zoom In",description:"Zoom into the next clip"},{type:"zoom-out",name:"Zoom Out",description:"Zoom out to the next clip"},{type:"cross-fade",name:"Cross Fade",description:"Cross-fade between clips"},{type:"dip-to-black",name:"Dip to Black",description:"Fade through black"},{type:"dip-to-white",name:"Dip to White",description:"Fade through white"}];let Ei=wi;function Na(o,a){if(typeof o=="number"&&Number.isFinite(o))return o;if(typeof o=="string"){const t=Number(o);if(Number.isFinite(t))return t}return a}function hi(o){return o>5?o/100:o}function By(o){if(o.value!==void 0){const a=Na(o.value,0);return a>=-1&&a<=1?1+a:hi(a)}return hi(Na(o.brightness,1))}function $a(o,a,t){return Math.min(t,Math.max(a,o))}function ma(){return new Pt.ColorMatrixFilter}function Iy(o,a){switch(o){case"brightness":{const t=ma();return t.brightness($a(By(a),0,5),!1),t}case"contrast":{const t=ma(),n=Na(a.value??a.contrast,1);return t.contrast($a(hi(n),0,5),!1),t}case"saturation":{const t=ma(),n=Na(a.value??a.saturation,1);return t.saturate($a(hi(n),0,5),!1),t}case"hue":{const t=ma(),n=Na(a.degrees??a.value,0);return t.hue($a(n,-180,180),!1),t}case"blur":case"softFocus":{const t=o==="softFocus"?1:0,n=Na(a.radius??a.blur??a.value,t);return new Pt.BlurFilter({strength:$a(n,0,32),quality:4})}case"grayscale":{const t=ma(),n=$a(Na(a.amount,100),0,100);return n<=0?null:(n>=100?t.desaturate():t.saturate(1-n/100,!1),t)}case"sepia":{if($a(Na(a.amount,100),0,100)<=0)return null;const n=ma();return n.sepia(!1),n}case"invert":{if($a(Na(a.amount,100),0,100)<=0)return null;const n=ma();return n.negative(!1),n}case"warmth":{const t=ma(),n=$a(Na(a.value,0),-50,50);return n>0?(t.sepia(!1),t.saturate(1+n/100,!1)):n<0&&t.hue(Math.abs(n)/50*-20,!1),t}case"tint":{const t=ma(),n=$a(Na(a.intensity,.3),0,1),i=typeof a.color=="string"?a.color:"#ff0000",r=i.startsWith("#")?i.slice(1):i;if(r.length===6){const s=parseInt(r.slice(0,2),16)/255,l=parseInt(r.slice(2,4),16)/255,d=parseInt(r.slice(4,6),16)/255;t.matrix=[1-n+n*s,0,0,0,0,0,1-n+n*l,0,0,0,0,0,1-n+n*d,0,0,0,0,0,1,0]}return t}case"vintage":{const t=ma();return t.sepia(!1),t.saturate(1.4,!1),t.contrast(1.1,!1),t}case"blackAndWhite":{const t=ma(),n=$a(hi(Na(a.contrast,120)),.5,3);return t.desaturate(),t.contrast(n,!1),t}case"cinematic":{const t=ma();return t.contrast(1.2,!1),t.brightness(.95,!1),t.saturate(.85,!1),t}case"dramatic":{const t=ma();return t.contrast(1.4,!1),t.brightness(.9,!1),t.saturate(1.1,!1),t.sepia(!1),t}case"dreamy":{const t=ma();return t.brightness(1.05,!1),t.saturate(.9,!1),t.contrast(.95,!1),t}default:return null}}typeof window<"u"&&!window.PIXI&&(window.PIXI=Pt);class Nm{constructor(a=1920,t=1080,n=30,i){this.player=null,this.clips=new Map,this.clipTimelineStart=new Map,this.resizeObserver=null,this.recipeSourceDimensions=null,this.filterCache=new Map,this.animationFrameId=null,this.lastRenderedFrame=-1,this.fps=n,this.fitMode=(i==null?void 0:i.fitMode)??"contain",this.composition=new _y({width:a,height:t,background:"#000000"}),this.initPromise=new Promise(r=>{const s=()=>{this.isDebug()&&this.dbg("init:renderer-ready"),r()};this.composition.on("init",s),queueMicrotask(()=>{var d,c,u,f;const l=this.composition;((c=(d=l==null?void 0:l.app)==null?void 0:d.renderer)!=null&&c.view||(u=l==null?void 0:l.renderer)!=null&&u.view||(f=l==null?void 0:l.renderer)!=null&&f.canvas)&&s()})}),this.setupEventHandlers()}isDebug(){try{if(typeof window<"u"&&window.MEDIABLES_DEBUG===1||typeof localStorage<"u"&&localStorage.getItem("mediables.debug")==="1")return!0}catch{}return!1}dbg(...a){this.isDebug()}setupEventHandlers(){this.composition.on("play",()=>this.onPlay()),this.composition.on("pause",()=>this.onPause()),this.composition.on("currentframe",()=>this.onFrameUpdate())}onPlay(){}onPause(){}onFrameUpdate(){}async attachPlayer(a){this.player=a,this.isDebug()&&this.dbg("attachPlayer:begin",{w:a.clientWidth,h:a.clientHeight}),this.composition.attachPlayer(a),await this.initPromise;const t=this.composition;this.isDebug()&&this.dbg("attachPlayer:ready",{hasRenderer:!!(t!=null&&t.renderer),hasCanvas:!!(t!=null&&t.canvas),canvasSize:t!=null&&t.canvas?{w:t.canvas.width,h:t.canvas.height}:null}),this.setupResponsiveScaling(),this.composition.seek(0),this.startRenderLoop()}setupResponsiveScaling(){this.player&&(this.player.style.position="absolute",this.player.style.top="50%",this.player.style.left="50%",this.resizeObserver=new ResizeObserver(()=>{var n;const a=(n=this.player)==null?void 0:n.parentElement;if(!this.player||!a)return;const t=Math.min(a.clientWidth/this.composition.width,a.clientHeight/this.composition.height);this.player.style.width=`${this.composition.width}px`,this.player.style.height=`${this.composition.height}px`,this.player.style.transform=`translate(-50%, -50%) scale(${t})`,this.player.style.transformOrigin="center"}),this.resizeObserver.observe(this.player.parentElement??this.player))}async loadFromRecipe(a){var n,i,r;await this.initPromise,this.clips.clear(),this.recipeSourceDimensions=Number.isFinite((n=a.source)==null?void 0:n.original_width)&&a.source.original_width>0&&Number.isFinite((i=a.source)==null?void 0:i.original_height)&&a.source.original_height>0?{width:a.source.original_width,height:a.source.original_height}:null;const t=await Ty(a);for(const s of a.timeline)await this.addTimelineClip(s,t);if(a.textOverlays)for(const s of a.textOverlays)await this.addTextOverlay(s);await new Promise(s=>requestAnimationFrame(s));for(const s of a.timeline)(r=s.filters)!=null&&r.length&&this.applyFiltersToClip(s.id,s.filters);a.transitions&&a.transitions.length>0&&await this.applyTransitionsToClips(a.transitions),this.composition.seek(0),this.applyFitModeToClips(),this.composition.computeFrame()}async applyTransitionsToClips(a){const t=new Ei(this.composition);for(const n of a){if(n.type==="cut")continue;const i=this.clips.get(n.fromClipId),r=this.clips.get(n.toClipId),s=this.mapTransitionType(n.type);if(!i||!r||!s)continue;const l={type:s,duration:n.duration,easing:this.mapTransitionEasing(n.easing)};try{await t.applyTransition(i,r,l)}catch{}}}mapTransitionType(a){switch(a){case"fade":return"fade";case"crossfade":return"cross-fade";case"dip-to-black":return"dip-to-black";case"wipe-left":return"wipe-left";case"wipe-right":return"wipe-right";case"slide-left":return"slide-left";case"slide-right":return"slide-right";case"zoom":return"zoom-in";case"cut":return null}}mapTransitionEasing(a){switch(a){case"ease-in":return"easeIn";case"ease-out":return"easeOut";case"ease-in-out":return"easeInOut";case"linear":return"linear"}}async addTimelineClip(a,t){var n,i;try{const r=a.url||t;if(!r)throw new Error("No video source URL available for clip");if(!r.startsWith("blob:")){if(!/^https?:/i.test(String(r)))return}const s=await((n=jn.from)==null?void 0:n.call(jn,r,{crossOrigin:"anonymous"}))??await jn.from(r),l=new kl(s,{muted:a.muted||!1,scale:a.scale||1,position:"center"});let d=0,c=null;if(a.sourceIn!==void 0||a.sourceOut!==void 0){const m=Math.max(0,Math.floor((a.sourceIn||0)*this.fps)),p=a.sourceOut!==void 0?Math.max(m+1,Math.floor(a.sourceOut*this.fps)):null;d=m,c=p;try{if(l.offset=l.offset||{frames:0},l.offset.frames=m,p!==null){const h=Math.max(1,p-m);l.duration=l.duration||{frames:h},l.duration.frames=h}}catch{}}const u=await this.composition.add(l);if(c!==null&&d>=0)try{const m=Math.max(1,c-d);u.offset=u.offset||{frames:0},u.offset.frames=d,u.duration=u.duration||{frames:m},u.duration.frames=m}catch{}const f=Math.floor(a.timelineStart*this.fps);f>0&&u.offsetBy(f),this.clipTimelineStart.set(a.id,a.timelineStart),this.applyFitToClip(u),this.clips.set(a.id,u),(i=a.filters)!=null&&i.length&&(await new Promise(m=>requestAnimationFrame(m)),this.applyFiltersToClip(a.id,a.filters))}catch{}}async addTextOverlay(a){try{const t=na.fromFamily({family:a.fontFamily||"Arial",weight:a.fontWeight||"400"}),n=new Mo({text:a.content,font:t,fontSize:a.fontSize||34,position:a.position||"center",fillStyle:a.color||"#FFFFFF",textAlign:a.textAlign||"center",textBaseline:a.textBaseline||"middle"});if(a.animation){const r=a.animation.duration||1,s=0,l=r*this.fps,d=a.animation.easing||"linear";a.animation.type==="rotate"&&a.animation.rotation?n.rotation=new ze([s,l],[a.animation.rotation.from,a.animation.rotation.to],{easing:d}):a.animation.type==="scale"&&a.animation.scale&&(n.scale=new ze([s,l],[a.animation.scale.from,a.animation.scale.to],{easing:d}))}a.startTime&&a.startTime>0&&n.offsetBy(a.startTime*this.fps),a.duration&&n.subclip(0,a.duration*this.fps);const i=await this.composition.add(n);this.clips.set(a.id||`text-${Date.now()}`,i)}catch{}}applyFiltersToClip(a,t){const n=this.clips.get(a);if(!n)return;const i=this.filterCache.get(a)??new Map,r=new Set(t.map(d=>d.id));for(const[d,c]of i.entries())if(!r.has(d)){try{typeof c.instance.destroy=="function"&&c.instance.destroy()}catch{}i.delete(d)}const s=[];for(const d of t){const c=this.buildFilterSignature(d),u=i.get(d.id);let f=null;if(u&&u.signature===c)f=u.instance;else{if(u)try{u.instance.destroy()}catch{}f=this.createPixiFilter(d),f?i.set(d.id,{instance:f,signature:c}):i.delete(d.id)}f&&s.push(f)}this.filterCache.set(a,i);const l=n.view??n.sprite??n.displayObject??null;if("filters"in n)try{n.filters=s}catch{}if(l&&"filters"in l)try{l.filters=s}catch{}typeof n.enter=="function"&&n.enter()}buildFilterSignature(a){const t=typeof a.params=="object"&&a.params!==null?a.params:{},n=Object.keys(t).sort((i,r)=>i.localeCompare(r)).map(i=>[i,t[i]]);return JSON.stringify({filterId:a.filterId,intensity:a.intensity??1,params:n})}setClipFilters(a,t){this.applyFiltersToClip(a,t),this.composition.computeFrame()}createPixiFilter(a){const t=a.intensity??1,n=a.params||{};if(oe.getFilter(a.filterId)&&!oe.isFilterCompatibleWithMedia(a.filterId,"video"))return null;let r=uh(a.filterId,n);return r||(r=Iy(a.filterId,n)),r?(t!==1&&r&&(a.filterId==="colorOverlay"||a.filterId==="alpha"||("alpha"in r&&!n.alpha&&(r.alpha*=t),"strength"in r&&(r.strength*=t))),r):null}play(){this.composition.play(),this.startRenderLoop()}pause(){this.composition.pause(),this.composition.computeFrame()}seek(a){this.composition.seek(a)}seekToTime(a){this.composition.seek(a*this.fps)}get currentFrame(){return this.composition.frame}get currentTime(){return this.composition.time().seconds.toFixed(2)}get currentTimeInSeconds(){return this.composition.frame/this.fps}get duration(){return this.composition.duration.frames}get durationInSeconds(){return this.composition.duration.frames/this.fps}async export(a={}){var s,l,d,c,u,f,m,p,h;const t=a.fps??this.fps,n=this.composition.canvas??((l=(s=this.composition)==null?void 0:s.renderer)==null?void 0:l.view)??((u=(c=(d=this.composition)==null?void 0:d.app)==null?void 0:c.renderer)==null?void 0:u.view)??((m=(f=this.composition)==null?void 0:f.renderer)==null?void 0:m.canvas);if(!n)throw new Error("Export failed: composition canvas is not initialized");(p=a.onProgress)==null||p.call(a,0);const i=new Ny(n,{fps:t});await i.init();const r=await i.export();return(h=a.onProgress)==null||h.call(a,100),r}destroy(){if(this.stopRenderLoop(),this.composition.pause(),this.clips.clear(),this.clipTimelineStart.clear(),this.filterCache.clear(),this.player&&this.composition.detachPlayer(this.player),this.resizeObserver){try{this.resizeObserver.disconnect()}catch{}this.resizeObserver=null}this.player=null}startRenderLoop(){this.stopRenderLoop(),this.isDebug()&&this.dbg("renderLoop:start");const a=()=>{(this.composition.state==="PLAY"||this.composition.frame!==this.lastRenderedFrame)&&(this.composition.computeFrame(),this.lastRenderedFrame=this.composition.frame),this.animationFrameId=requestAnimationFrame(a)};a()}stopRenderLoop(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null,this.isDebug()&&this.dbg("renderLoop:stop"))}moveClip(a,t){const n=this.clips.get(a);if(!n)return;const i=this.clipTimelineStart.get(a)||0,r=t-i;r!==0&&(n.offsetBy(r*this.fps),this.clipTimelineStart.set(a,t),this.composition.computeFrame())}setFitMode(a){this.fitMode=a,this.applyFitModeToClips()}applyFitModeToClips(){for(const a of this.clips.values())"scale"in a&&typeof a.scale<"u"&&this.applyFitToClip(a);this.composition.computeFrame()}applyFitToClip(a){var t,n;if(this.fitMode!=="none")try{const i=this.composition.width,r=this.composition.height,s=a.source,l=(s==null?void 0:s.width)??(s==null?void 0:s.videoWidth)??((t=this.recipeSourceDimensions)==null?void 0:t.width),d=(s==null?void 0:s.height)??(s==null?void 0:s.videoHeight)??((n=this.recipeSourceDimensions)==null?void 0:n.height);if(!l||!d)return;const c=Math.min(i/l,r/d),u=Math.max(i/l,r/d),f=this.fitMode==="contain"?c:u;a.scale=f}catch{}}trimClip(a,t,n){const i=this.clips.get(a);if(!i)return;const r=Math.max(0,Math.floor(t*this.fps)),s=Math.max(r+1,Math.floor(n*this.fps));try{i.offset=i.offset||{frames:0},i.offset.frames=r,i.duration=i.duration||{frames:s-r},i.duration.frames=s-r,this.composition.computeFrame()}catch{}}resolveSourceFrame(a){var t,n;for(const[i,r]of this.clips.entries()){const s=this.clipTimelineStart.get(i)||0,l=Math.floor(s*this.fps),d=((t=r.duration)==null?void 0:t.frames)??Math.round(r.duration.seconds*this.fps),c=l+d;if(a>=l&&a<c){const u=a-l;return{sourceFrame:(((n=r.offset)==null?void 0:n.frames)??0)+u,clipId:i}}}return{sourceFrame:0,clipId:null}}}const My=["src"],Fy={class:"preview-controls"},$y=["aria-label"],Dy={class:"time-display"},Ry={class:"current-time"},Ay={class:"total-time"},Ly={key:2,class:"loading-overlay"},Py={key:3,class:"error-overlay"},Uy=e.defineComponent({__name:"VideoPreviewEngine",props:{mediaUuid:{},recipe:{},media:{},autoPlay:{type:Boolean,default:!1},enableEngine:{type:Boolean,default:!0},fitMode:{default:"contain"}},emits:["time-update","duration-change","play-state-change","error","engine-ready"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(),r=e.ref(),s=e.ref(),l=e.ref(!1),d=e.ref("Initializing..."),c=e.ref(null),u=e.ref(!1),f=e.ref(0),m=e.ref(0);let p=null;const h=e.computed(()=>!!t.enableEngine&&!!t.recipe),v=e.computed(()=>{switch(t.fitMode){case"cover":return"cover";case"none":return"none";default:return"contain"}}),w=e.computed(()=>{var C,T;return(C=t.media)!=null&&C.url?t.media.url:(((T=t.media)==null?void 0:T.file)instanceof File,"")});async function E(){var C,T,y;if(!(!r.value||!t.recipe))try{l.value=!0,d.value="Initializing video engine...";const R=((C=t.recipe.source)==null?void 0:C.original_width)||1920,U=((T=t.recipe.source)==null?void 0:T.original_height)||1080,z=((y=t.recipe.output)==null?void 0:y.fps)||30;p=new Nm(R,U,z,{fitMode:t.fitMode}),p.attachPlayer(r.value),d.value="Loading composition...",await p.loadFromRecipe(t.recipe),m.value=p.durationInSeconds,n("duration-change",m.value),S(),l.value=!1,n("engine-ready",p),t.autoPlay&&(p.play(),u.value=!0)}catch(R){const U=R instanceof Error?R.message:String(R);c.value=`Failed to initialize: ${U}`,l.value=!1}}function S(){if(!p)return;const C=setInterval(()=>{p&&u.value&&(f.value=p.currentTimeInSeconds,n("time-update",f.value))},100);L.value=C}function k(){h.value&&p?(u.value?p.pause():p.play(),u.value=!u.value,n("play-state-change",u.value)):s.value&&(u.value?s.value.pause():s.value.play(),u.value=!u.value,n("play-state-change",u.value))}function b(C){const T=Math.floor(C/60),y=Math.floor(C%60);return`${T}:${y.toString().padStart(2,"0")}`}function $(){c.value=null,h.value&&E()}function V(){!h.value&&s.value&&(m.value=s.value.duration,n("duration-change",m.value))}function I(){!h.value&&s.value&&(f.value=s.value.currentTime,n("time-update",f.value))}function x(){u.value=!1,n("play-state-change",!1)}function N(C){c.value="Failed to load video",n("error",c.value)}e.onMounted(()=>{h.value&&t.recipe&&E()}),e.onUnmounted(()=>{p&&(p.destroy(),p=null),L.value&&(clearInterval(L.value),L.value=null),s.value&&(s.value.pause(),s.value.removeAttribute("src"),s.value.load())}),e.watch(()=>t.recipe,async C=>{if(h.value&&C)if(C.timeline,p)try{await p.loadFromRecipe(C),m.value=p.durationInSeconds,n("duration-change",m.value)}catch{}else await E()}),e.watch(()=>t.enableEngine,async C=>{C?(await e.nextTick(),await E()):p&&(L.value&&(clearInterval(L.value),L.value=null),p.destroy(),p=null)}),e.watch(()=>t.fitMode,async C=>{if(!(!h.value||!p))try{p.setFitMode(C||"contain")}catch{}});const L=e.ref(null);return(C,T)=>(e.openBlock(),e.createElementBlock("div",{class:"video-preview-engine",ref_key:"containerRef",ref:i},[h.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"videoEnginePlayer",ref:r,class:"video-engine-player",style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"}},null,512)):(e.openBlock(),e.createElementBlock("video",{key:1,ref_key:"videoRef",ref:s,src:w.value,onLoadedmetadata:V,onTimeupdate:I,onEnded:x,onError:N,style:e.normalizeStyle({width:"100%",height:"100%",objectFit:v.value}),playsinline:"",controls:""},null,44,My)),e.createElementVNode("div",Fy,[e.createElementVNode("button",{class:"play-button",onClick:k,"aria-label":u.value?"Pause":"Play"},[e.createVNode(e.unref(H.IonIcon),{icon:u.value?e.unref(Zu):e.unref(Gu)},null,8,["icon"])],8,$y),e.createElementVNode("div",Dy,[e.createElementVNode("span",Ry,e.toDisplayString(b(f.value)),1),T[0]||(T[0]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",Ay,e.toDisplayString(b(m.value)),1)])]),l.value?(e.openBlock(),e.createElementBlock("div",Ly,[e.createVNode(e.unref(H.IonSpinner),{name:"crescent"}),e.createElementVNode("p",null,e.toDisplayString(d.value),1)])):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",Py,[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Jl)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(c.value),1),e.createElementVNode("button",{onClick:$},"Retry")])):e.createCommentVNode("",!0)],512))}}),xl=Fe(Uy,[["__scopeId","data-v-e199ac48"]]),Oy=["aria-label"],zy=["aria-label"],jy={class:"clip-content"},Wy={key:0,class:"clip-thumbnail"},Hy=["src","alt"],Zy=["src"],Gy=["data-visual-mode"],Xy={class:"clip-info"},Ky={class:"clip-label"},Jy={class:"clip-duration"},qy={key:3,class:"filter-indicators"},Yy={key:4,class:"speed-indicator"},Qy=["aria-label","data-testid"],e1={key:1,class:"selection-overlay"},t1=420,a1=8,n1=48,o1=32,Cc=1,i1=e.defineComponent({__name:"TimelineClip",props:{clip:{},scale:{},scrollOffset:{default:0},selected:{type:Boolean,default:!1},isMobile:{type:Boolean,default:!1},canDelete:{type:Boolean,default:!1}},emits:["select","delete","long-press","trim-start","trim-end","drag","trim-start-abs","trim-end-abs","drag-abs"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(null),r=e.ref(!1),s=e.ref(null),l=e.ref(0),d=e.ref(0),c=e.ref(0),u=e.ref(0),f=e.ref(!1),m=e.ref(!1),p=e.ref(null),h=e.computed(()=>{const J=(t.clip.timelineEnd-t.clip.timelineStart)*t.scale;return{left:`${t.clip.timelineStart*t.scale-t.scrollOffset}px`,width:`${J}px`}}),v=e.computed(()=>t.clip.label||`Clip ${t.clip.id.slice(-4)}`),w=e.computed(()=>{const D=t.clip.timelineEnd-t.clip.timelineStart;return I(D)}),E=e.computed(()=>t.clip.filters&&t.clip.filters.length>0),S=e.computed(()=>t.clip.filters||[]),k=e.computed(()=>t.clip.waveformSamples??[]),b=e.computed(()=>t.clip.filmstripFrames??[]),$=e.computed(()=>k.value.length>0),V=e.computed(()=>b.value.length>0);function I(D){if(D<1)return`${Math.round(D*30)}f`;if(D<60)return`${D.toFixed(1)}s`;{const J=Math.floor(D/60),Z=Math.floor(D%60);return`${J}:${Z.toString().padStart(2,"0")}`}}function x(D){return!D||typeof D!="string"?ic:D.includes("color")||D.includes("brightness")?kn:D.includes("blur")?Oh:D.includes("style")?ni:D.includes("effect")?wn:ic}function N(){r.value||n("select")}function L(D){D.button===0&&(y("move",D.clientX),D.preventDefault())}function C(D){if(D.touches.length!==1)return;const J=D.touches[0];if(!t.isMobile){y("move",J.clientX),D.preventDefault();return}c.value=J.clientX,u.value=J.clientY,f.value=!1,m.value=!1,R(),U(),p.value=window.setTimeout(()=>{m.value=!0,U(),t.selected||n("select"),n("long-press")},t1),document.addEventListener("touchmove",z),document.addEventListener("touchend",W),document.addEventListener("touchcancel",W),D.preventDefault()}function T(D,J){const Z="touches"in J?J.touches[0].clientX:J.clientX;s.value=D==="start"?"trim-start":"trim-end",y(s.value,Z),J.preventDefault(),J.stopPropagation()}function y(D,J){R(),U(),r.value=!0,s.value=D,l.value=J,D==="move"?d.value=t.clip.timelineStart:D==="trim-start"?d.value=t.clip.sourceIn:D==="trim-end"&&(d.value=t.clip.sourceOut),document.addEventListener("mousemove",B),document.addEventListener("mouseup",X),document.addEventListener("touchmove",P),document.addEventListener("touchend",X),t.selected||n("select")}function R(){p.value!==null&&(window.clearTimeout(p.value),p.value=null)}function U(){document.removeEventListener("touchmove",z),document.removeEventListener("touchend",W),document.removeEventListener("touchcancel",W)}function z(D){if(D.touches.length!==1)return;const J=D.touches[0],Z=J.clientX-c.value,ie=J.clientY-u.value;Math.hypot(Z,ie)<a1||(f.value=!0,R(),U(),y("move",J.clientX),B(D),D.preventDefault())}function W(){const D=!f.value&&!m.value&&!r.value;R(),U(),f.value=!1,m.value=!1,D&&n("select")}function B(D){if(!r.value||!s.value)return;const J="touches"in D?D.touches[0].clientX:D.clientX,Z="touches"in D?D.touches[0].clientY:D.clientY,se=J-l.value;s.value==="move"?(n("drag",se),n("drag-abs",J,Z)):s.value==="trim-start"?(n("trim-start",se),n("trim-start-abs",J)):s.value==="trim-end"&&(n("trim-end",se),n("trim-end-abs",J))}function P(D){B(D)}function X(){r.value=!1,s.value=null,document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",X),document.removeEventListener("touchmove",P),document.removeEventListener("touchend",X)}function K(){e.nextTick(()=>{Ne()})}function be(D){var me,ve;const J=Math.max(0,t.clip.timelineEnd-t.clip.timelineStart),Z=Math.max(1,Math.round(J*t.scale)),ie=t.isMobile?o1:n1,se=Math.max(1,Math.round(D.clientWidth||((me=D.parentElement)==null?void 0:me.clientWidth)||Z)),Ue=Math.max(1,Math.round(D.clientHeight||((ve=D.parentElement)==null?void 0:ve.clientHeight)||ie));return{width:se,height:Ue}}function Ne(){if(V.value||!i.value)return;const D=i.value,J=D.getContext("2d");if(!J)return;const{width:Z,height:ie}=be(D),se=window.devicePixelRatio||1;if(D.width=Math.max(1,Math.round(Z*se)),D.height=Math.max(1,Math.round(ie*se)),J.setTransform(se,0,0,se,0,0),J.clearRect(0,0,Z,ie),k.value.length>0){re(J,Z,ie,k.value);return}ue(J,Z,ie)}function ue(D,J,Z){const ie=Z/2;D.strokeStyle="rgba(255, 255, 255, 0.3)",D.lineWidth=1,D.beginPath(),D.moveTo(0,ie),D.lineTo(J,ie);for(let se=0;se<J;se+=4){const Ue=Math.sin(se*.05)*(Z*.3);D.moveTo(se,ie-Ue),D.lineTo(se,ie+Ue)}D.stroke()}function re(D,J,Z,ie){const se=t.clip.sourceIn,Ue=t.clip.sourceOut,me=Math.max(.001,Ue-se),ve=ie.filter(Be=>Be.endTime>=se&&Be.time<=Ue);if(ve.length===0){ue(D,J,Z);return}const fe=Z/2,Ee=Z*.44,ye=Z*.32;D.fillStyle="rgba(255, 255, 255, 0.26)",ve.forEach(Be=>{const Ie=Math.max(Be.time,se),et=Math.min(Be.endTime,Ue),tt=(Ie-se)/me*J,Tt=Math.max(Cc,(et-Ie)/me*J),vt=O(Be.rms)*ye;D.fillRect(tt,fe-vt,Tt,vt*2)}),D.fillStyle="rgba(255, 255, 255, 0.72)",ve.forEach(Be=>{const Ie=Math.max(Be.time,se),et=Math.min(Be.endTime,Ue),tt=(Ie-se)/me*J,Tt=Math.max(Cc,(et-Ie)/me*J),vt=O(Be.peak)*Ee;D.fillRect(tt,fe-vt,Tt,vt*2)})}function O(D){return Math.min(1,Math.max(0,D))}return e.watch(()=>[t.clip.id,t.clip.timelineStart,t.clip.timelineEnd,t.clip.sourceIn,t.clip.sourceOut,t.clip.waveformSamples,t.clip.filmstripFrames,t.scale,t.isMobile],K,{deep:!0,flush:"post"}),e.onMounted(()=>{K(),window.addEventListener("resize",Ne)}),e.onUnmounted(()=>{X(),R(),U(),window.removeEventListener("resize",Ne)}),(D,J)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-clip",{selected:D.selected,mobile:D.isMobile,"has-filters":E.value}]),style:e.normalizeStyle(h.value),onClick:N,onMousedown:L,onTouchstart:C},[e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:J[0]||(J[0]=e.withModifiers(Z=>T("start",Z),["stop"])),onTouchstart:J[1]||(J[1]=e.withModifiers(Z=>T("start",Z),["stop"])),"aria-label":`Trim start of ${D.clip.label||"clip"}`},[...J[7]||(J[7]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,Oy),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:J[2]||(J[2]=e.withModifiers(Z=>T("end",Z),["stop"])),onTouchstart:J[3]||(J[3]=e.withModifiers(Z=>T("end",Z),["stop"])),"aria-label":`Trim end of ${D.clip.label||"clip"}`},[...J[8]||(J[8]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,zy),e.createElementVNode("div",jy,[D.clip.thumbnail?(e.openBlock(),e.createElementBlock("div",Wy,[e.createElementVNode("img",{src:D.clip.thumbnail,alt:D.clip.label||"Video clip"},null,8,Hy)])):e.createCommentVNode("",!0),V.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["clip-analysis-strip clip-filmstrip",{compact:D.isMobile}]),"aria-hidden":"true"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,Z=>(e.openBlock(),e.createElementBlock("img",{key:Z.id,class:"clip-filmstrip-frame",src:Z.uri,alt:"",draggable:"false"},null,8,Zy))),128))],2)):(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["clip-analysis-strip clip-waveform",{compact:D.isMobile}]),"data-visual-mode":$.value?"waveform":"placeholder","aria-hidden":"true"},[e.createElementVNode("canvas",{ref_key:"waveformCanvas",ref:i},null,512)],10,Gy)),e.createElementVNode("div",Xy,[e.createElementVNode("span",Ky,e.toDisplayString(v.value),1),e.createElementVNode("span",Jy,e.toDisplayString(w.value),1)]),E.value?(e.openBlock(),e.createElementBlock("div",qy,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(S.value,Z=>(e.openBlock(),e.createBlock(e.unref(H.IonIcon),{key:Z.id||Z.filterId,icon:x(Z.filterId||Z.id),title:`Filter: ${Z.filterId||Z.id}`},null,8,["icon","title"]))),128))])):e.createCommentVNode("",!0),D.clip.speed&&D.clip.speed!==1?(e.openBlock(),e.createElementBlock("div",Yy,e.toDisplayString(D.clip.speed)+"x ",1)):e.createCommentVNode("",!0)]),D.selected&&D.canDelete?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"clip-delete-button","aria-label":`Delete ${D.clip.label||"clip"}`,"data-testid":`timeline-clip-delete-${D.clip.id}`,title:"Delete clip",onClick:J[4]||(J[4]=e.withModifiers(Z=>n("delete"),["stop"])),onMousedown:J[5]||(J[5]=e.withModifiers(()=>{},["stop"])),onTouchstart:J[6]||(J[6]=e.withModifiers(()=>{},["stop"]))},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Br)},null,8,["icon"])],40,Qy)):e.createCommentVNode("",!0),D.selected?(e.openBlock(),e.createElementBlock("div",e1)):e.createCommentVNode("",!0)],38))}}),Vc=Fe(i1,[["__scopeId","data-v-deeaa999"]]),r1={class:"timeline-track-header__meta"},s1=["data-testid"],l1=["data-testid","value","aria-label","onKeydown"],d1={class:"timeline-track-header__type"},c1=["aria-label"],u1=["aria-pressed","aria-label"],m1=["aria-pressed","aria-label"],p1=["aria-pressed","aria-label"],f1=["aria-pressed","aria-label"],h1={class:"timeline-track-header__menu-row"},v1=["data-testid","aria-label","aria-expanded"],g1=["aria-label"],b1=["data-testid"],y1=["data-testid"],w1=["data-testid"],k1=["data-testid"],_1=e.defineComponent({__name:"TimelineTrackHeader",props:{track:{}},emits:["toggle-lock","toggle-hidden","toggle-muted","toggle-solo","rename-track","delete-track","reorder-track"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(!1),r=e.ref(!1),s=e.ref(""),l=e.ref(null);function d(){i.value=!i.value}function c(){i.value=!1}function u(){c(),f()}async function f(){var E,S;s.value=t.track.name,r.value=!0,await e.nextTick(),(E=l.value)==null||E.focus(),(S=l.value)==null||S.select()}function m(E){const S=E.target;S&&(s.value=S.value)}function p(){if(!r.value)return;const E=s.value.trim();r.value=!1,!(E===""||E===t.track.name)&&n("rename-track",t.track.id,E)}function h(){r.value=!1}function v(E){c(),n("reorder-track",t.track.id,E)}function w(){c(),n("delete-track",t.track.id)}return(E,S)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-track-header",{"is-hidden":E.track.hidden===!0}])},[e.createElementVNode("div",r1,[r.value?(e.openBlock(),e.createElementBlock("input",{key:1,ref_key:"renameInput",ref:l,class:"timeline-track-header__rename-input","data-testid":`timeline-track-rename-${E.track.id}`,value:s.value,"aria-label":`Rename ${E.track.name}`,onInput:m,onKeydown:[e.withKeys(e.withModifiers(p,["prevent"]),["enter"]),e.withKeys(e.withModifiers(h,["prevent"]),["escape"])],onBlur:p},null,40,l1)):(e.openBlock(),e.createElementBlock("span",{key:0,class:"timeline-track-header__name","data-testid":`timeline-track-name-${E.track.id}`,onDblclick:f},e.toDisplayString(E.track.name),41,s1)),e.createElementVNode("span",d1,e.toDisplayString(E.track.type),1)]),e.createElementVNode("div",{class:"timeline-track-header__actions","aria-label":`Track controls for ${E.track.name}`},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["timeline-track-header__button",{"is-active":E.track.locked===!0}]),"aria-pressed":E.track.locked===!0,"aria-label":E.track.locked===!0?`Unlock ${E.track.name}`:`Lock ${E.track.name}`,title:"Lock",onClick:S[0]||(S[0]=k=>n("toggle-lock",E.track.id))}," Lock ",10,u1),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["timeline-track-header__button",{"is-active":E.track.hidden===!0}]),"aria-pressed":E.track.hidden===!0,"aria-label":E.track.hidden===!0?`Show ${E.track.name}`:`Hide ${E.track.name}`,title:"Hide",onClick:S[1]||(S[1]=k=>n("toggle-hidden",E.track.id))}," Hide ",10,m1),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["timeline-track-header__button",{"is-active":E.track.muted===!0}]),"aria-pressed":E.track.muted===!0,"aria-label":E.track.muted===!0?`Unmute ${E.track.name}`:`Mute ${E.track.name}`,title:"Mute",onClick:S[2]||(S[2]=k=>n("toggle-muted",E.track.id))}," Mute ",10,p1),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["timeline-track-header__button",{"is-active":E.track.solo===!0}]),"aria-pressed":E.track.solo===!0,"aria-label":E.track.solo===!0?`Disable solo for ${E.track.name}`:`Solo ${E.track.name}`,title:"Solo",onClick:S[3]||(S[3]=k=>n("toggle-solo",E.track.id))}," Solo ",10,f1)],8,c1),e.createElementVNode("div",h1,[e.createElementVNode("button",{type:"button",class:"timeline-track-header__menu-button","data-testid":`timeline-track-menu-${E.track.id}`,"aria-label":`More actions for ${E.track.name}`,"aria-expanded":i.value,"aria-haspopup":!0,onClick:d}," ⋯ ",8,v1),i.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"timeline-track-header__menu",role:"menu","aria-label":`${E.track.name} actions`},[e.createElementVNode("button",{type:"button",role:"menuitem","data-testid":`timeline-track-rename-action-${E.track.id}`,onClick:u}," Rename ",8,b1),e.createElementVNode("button",{type:"button",role:"menuitem","data-testid":`timeline-track-move-up-${E.track.id}`,onClick:S[4]||(S[4]=k=>v("up"))}," Move up ",8,y1),e.createElementVNode("button",{type:"button",role:"menuitem","data-testid":`timeline-track-move-down-${E.track.id}`,onClick:S[5]||(S[5]=k=>v("down"))}," Move down ",8,w1),e.createElementVNode("button",{type:"button",role:"menuitem",class:"timeline-track-header__menu-button--danger","data-testid":`timeline-track-delete-${E.track.id}`,onClick:w}," Delete track ",8,k1)],8,g1)):e.createCommentVNode("",!0)])],2))}}),E1=Fe(_1,[["__scopeId","data-v-54e2bc6a"]]);class Tm{constructor(a=30){this.fps=30,this.fps=a}setFps(a){this.fps=a}async convertTimelineClipToEngine(a,t){const n=new kl(t,{muted:a.muted||!1,scale:a.scale||1,position:"center"});if(a.sourceIn!==void 0||a.sourceOut!==void 0){const i=this.secondsToFrames(a.sourceIn||0),r=a.sourceOut?this.secondsToFrames(a.sourceOut):n.duration.frames;n.subclip(i,r)}return a.timelineStart&&a.timelineStart>0&&n.offsetBy(this.secondsToFrames(a.timelineStart)),a.transform&&this.applyTransformations(n,a.transform),n}convertEngineClipToTimeline(a,t,n){const i=this.framesToSeconds(a.duration.frames),r=a.offset?this.framesToSeconds(a.offset.frames):0;return{id:t,url:n,type:"video",timelineStart:r,timelineEnd:r+i,sourceIn:0,sourceOut:i,duration:i,muted:a.muted||!1,scale:a.scale.x||1}}async buildCompositionFromRecipe(a,t){var n;(n=t.clear)==null||n.call(t);for(const i of a.timeline)try{if(!i.url)continue;const r=await jn.from(i.url),s=await this.convertTimelineClipToEngine(i,r);await t.add(s)}catch{}a.duration&&(t.duration=Re.fromFrames(this.secondsToFrames(a.duration)))}extractTimelineFromComposition(a){const t=[];return(a.clips||[]).forEach((i,r)=>{var s,l;i instanceof kl&&t.push(this.convertEngineClipToTimeline(i,`clip-${r}`,((s=i.source)==null?void 0:s.externalURL)||((l=i.source)==null?void 0:l.objectURL)||""))}),t}applyTransformations(a,t){(t.x!==void 0||t.y!==void 0)&&(a.x=t.x||0,a.y=t.y||0),t.rotation!==void 0&&(a.rotation=t.rotation),t.opacity!==void 0&&(a.alpha=t.opacity),t.scale!==void 0&&(a.scale={x:t.scale,y:t.scale})}secondsToFrames(a){return Math.round(a*this.fps)}framesToSeconds(a){return a/this.fps}framesToTime(a){const t=this.framesToSeconds(a),n=Math.floor(t/60),i=Math.floor(t%60),r=Math.floor(t%1*1e3);return`${n.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}.${r.toString().padStart(3,"0")}`}formatTime(a){const t=Math.floor(a/3600),n=Math.floor(a%3600/60),i=Math.floor(a%60);return`${t.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`}parseTime(a){const t=a.split(":");let n=0;if(t.length===2){const[i,r]=t;n=parseInt(i)*60+parseFloat(r)}else if(t.length===3){const[i,r,s]=t;n=parseInt(i)*3600+parseInt(r)*60+parseFloat(s)}else n=parseFloat(a);return n}timeToFrames(a){const t=a.split(":");let n=0;if(t.length===2){const[i,r]=t;n=parseInt(i)*60+parseFloat(r)}else if(t.length===3){const[i,r,s]=t;n=parseInt(i)*3600+parseInt(r)*60+parseFloat(s)}else n=parseFloat(a);return this.secondsToFrames(n)}}const x1={class:"time-markers"},S1=["data-track-id"],C1=["data-track-id"],V1=["aria-label","title"],N1={key:0,class:"timeline-scrollbar"},Nc=152,Tc=80,T1=e.defineComponent({__name:"VideoTimeline",props:{playhead:{},clips:{},tracks:{},duration:{},zoomLevel:{default:50},isMobile:{type:Boolean,default:!1},snapEnabled:{type:Boolean,default:!0},selectedClipId:{},fps:{default:30},useFrameMode:{type:Boolean,default:!1},sensitivity:{default:.25}},emits:["update:playhead","trim","split","clip-select","clip-delete","clip-move","clip-long-press","snap-state-change","toggle-frame-mode","toggle-lock","toggle-hidden","toggle-muted","toggle-solo","rename-track","delete-track","reorder-track"],setup(o,{expose:a,emit:t}){const n=o,i=e.computed(()=>n.isMobile===!0),r=t,s=e.ref(),l=e.ref(n.selectedClipId||null),d=e.ref(!1),c=e.ref(0),u=e.ref(),f=e.ref(0),m=e.computed(()=>n.selectedClipId??l.value);e.watch(()=>n.selectedClipId,F=>{F!==void 0&&(l.value=F)});const p=new Tm(n.fps);e.watch(()=>n.fps,F=>{p.setFps(F)});const h=e.ref(!1),v=e.ref(null),w=e.ref(0),E=e.ref(0),S=e.ref(null),k=e.ref(null),b=e.ref(0),$=e.ref(0),V=e.ref(0),I=e.ref(!1),x=e.ref(0),N=e.ref(n.zoomLevel),L=e.computed(()=>n.zoomLevel),C=e.computed(()=>n.tracks!==void 0&&n.tracks.length>0&&!i.value),T=e.computed(()=>C.value?Nc:0),y=e.computed(()=>Math.max(0,O.value-T.value));function R(F){return F.trackId??`legacy-track-${F.track??0}`}function U(F,Y){return{id:F,type:"video",name:`Track ${Y+1}`,order:Y}}const z=e.computed(()=>{const F=new Map;for(const Y of n.clips){const j=R(Y),ee=F.get(j);if(ee){ee.push(Y);continue}F.set(j,[Y])}return F}),W=e.computed(()=>{if(!C.value)return[];const F=[...n.tracks??[]].sort((ee,we)=>ee.order-we.order),Y=new Set(F.map(ee=>ee.id)),j=[];for(const ee of z.value.keys())Y.has(ee)||j.push(U(ee,F.length+j.length));return[...F,...j].map(ee=>({track:ee,clips:z.value.get(ee.id)??[],height:ee.height??Tc}))}),B=e.computed(()=>new Set(W.value.filter(F=>F.track.locked===!0).map(F=>F.track.id)));function P(F){const Y=n.clips.find(j=>j.id===F);return Y?!B.value.has(R(Y)):!1}function X(F){const Y=n.clips.find(we=>we.id===F);if(!Y)return null;const j=R(Y),ee=n.clips.filter(we=>we.id!==F&&R(we)===j&&we.timelineStart>=Y.timelineEnd-1e-9).map(we=>we.timelineStart);return ee.length?Math.min(...ee):null}function K(F){const Y=F.sourceMaxOut??n.duration,j=F.timelineStart+(Y-F.sourceIn),ee=X(F.id),we=ee!=null?Math.max(F.timelineStart,ee):1/0;return Math.min(j,we)}function be(F,Y=Tc){const j=F.sourceMinIn??0,we=(F.sourceMaxOut??n.duration)-j,Ve=F.sourceIn-j;return{left:`${(F.timelineStart-Ve)*L.value-c.value}px`,width:`${we*L.value}px`,top:"0px",height:`${Y}px`,opacity:m.value===F.id?.25:.15}}const Ne=e.computed(()=>n.useFrameMode?n.zoomLevel:n.zoomLevel/n.fps),ue=e.computed(()=>p.secondsToFrames(n.duration)),re=e.computed(()=>n.useFrameMode?ue.value*Ne.value:n.duration*L.value),O=e.computed(()=>{var F;return f.value||((F=s.value)==null?void 0:F.clientWidth)||800}),D=e.computed(()=>re.value>y.value),J=e.computed(()=>Math.max(0,re.value-y.value)),Z=e.computed(()=>c.value>0),ie=e.computed(()=>c.value<J.value),se=e.computed(()=>n.useFrameMode?p.secondsToFrames(n.playhead)*Ne.value-c.value:n.playhead*L.value-c.value),Ue=e.computed(()=>S.value===null?null:n.useFrameMode?p.secondsToFrames(S.value)*Ne.value-c.value:S.value*L.value-c.value),me=e.computed(()=>{const F=y.value,Y=Math.max(50,F/re.value*F),j=c.value/J.value*(F-Y);return{width:`${Y}px`,left:`${j}px`}}),ve=e.computed(()=>{const F=[],Y=fe();for(let j=0;j<=n.duration;j+=Y){const ee=j*L.value-c.value;ee>=-50&&ee<=y.value+50&&F.push({position:ee+T.value,label:Ee(j),time:j})}return F});function fe(){const Y=80/L.value;return Y<=1?1:Y<=5?5:Y<=10?10:Y<=30?30:Y<=60?60:Math.ceil(Y/60)*60}function Ee(F){if(n.useFrameMode)return`F${p.secondsToFrames(F)}`;{const Y=Math.floor(F/60),j=Math.floor(F%60),ee=Math.floor(F%1*n.fps);return L.value>100?`${Y}:${j.toString().padStart(2,"0")}:${ee.toString().padStart(2,"0")}`:`${Y}:${j.toString().padStart(2,"0")}`}}function ye(F){const Y=s.value.getBoundingClientRect();let ee=(F.clientX-Y.left-T.value+c.value)/L.value;const we=n.clips.find(Ve=>ee>=Ve.timelineStart&&ee<=Ve.timelineEnd);if(we)ee=Math.max(we.timelineStart,Math.min(we.timelineEnd,ee));else if(n.selectedClipId){const Ve=n.clips.find(Je=>Je.id===n.selectedClipId);if(Ve){const Je=Math.abs(ee-Ve.timelineStart),ut=Math.abs(ee-Ve.timelineEnd);ee=Je<ut?Ve.timelineStart:Ve.timelineEnd}}else ee=Math.max(0,Math.min(ee,n.duration));r("update:playhead",ee)}function Be(F){if(!D.value)return;const Y=Math.abs(F.deltaX)>Math.abs(F.deltaY)?F.deltaX:F.deltaY;Y!==0&&(F.preventDefault(),c.value=Math.max(0,Math.min(J.value,c.value+Y)))}function Ie(F){return[...F===void 0?n.clips:n.clips.filter(j=>R(j)===F)].sort((j,ee)=>j.timelineStart-ee.timelineStart)}function et(F){const Y=n.clips.find(we=>we.id===F),j=Ie(Y?R(Y):void 0),ee=j.findIndex(we=>we.id===F);return{previous:ee>0?j[ee-1]:null,next:ee!==-1&&ee<j.length-1?j[ee+1]:null}}function tt(F){const Y=F.timelineEnd-F.timelineStart,{previous:j,next:ee}=et(F.id),we=j?j.timelineEnd:0,Ve=ee?ee.timelineStart-Y:Math.max(F.timelineStart,n.duration-Y);return{minStart:we,maxStart:Math.max(we,Ve)}}function Tt(){return 12/Math.max(L.value,1)}function vt(F){return Array.from(new Set(F.filter(Y=>typeof Y=="number"&&Number.isFinite(Y))))}function xt(F,Y,j,ee){const we=Math.max(j,Math.min(F,ee));if(!n.snapEnabled)return{value:we,guideTime:null};const Ve=Tt();let Je=we,ut=null,St=Number.POSITIVE_INFINITY;for(const pt of vt(Y)){if(pt<j||pt>ee)continue;const ft=Math.abs(pt-we);ft<=Ve&&ft<St&&(Je=pt,ut=pt,St=ft)}return{value:Je,guideTime:ut}}function wt(F){if(F.touches.length===2){I.value=!0;const Y=F.touches[0],j=F.touches[1];x.value=Math.hypot(j.clientX-Y.clientX,j.clientY-Y.clientY),N.value=n.zoomLevel}else F.touches.length===1&&(b.value=F.touches[0].clientX,$.value=F.touches[0].clientY,V.value=b.value)}function it(F){if(I.value&&F.touches.length===2){const Y=F.touches[0],j=F.touches[1],we=Math.hypot(j.clientX-Y.clientX,j.clientY-Y.clientY)/x.value;Math.max(10,Math.min(200,N.value*we)),r("update:playhead",n.playhead)}else if(F.touches.length===1&&!I.value){const Y=F.touches[0],j=V.value-Y.clientX;Math.abs(j)>Math.abs(Y.clientY-$.value)&&(F.preventDefault(),c.value=Math.max(0,Math.min(J.value,c.value+j)),V.value=Y.clientX)}}function _t(){I.value=!1}function ge(F){const Y=F.target;if(Y.closest(".playhead-handle"))return;const j=F.button===1,ee=!!Y.closest(".video-track");(j||!ee&&D.value)&&ke(F)}function ke(F){h.value=!0,v.value="pan",w.value=F.clientX,E.value=c.value,document.addEventListener("mousemove",Ge),document.addEventListener("mouseup",Oe)}function Te(F){F.preventDefault(),F.stopPropagation(),h.value=!0,v.value="playhead";const Y="touches"in F?F.touches[0].clientX:F.clientX;w.value=Y,E.value=n.playhead,"touches"in F?(document.addEventListener("touchmove",Ge),document.addEventListener("touchend",Oe)):(document.addEventListener("mousemove",Ge),document.addEventListener("mouseup",Oe))}function Ke(F){F.preventDefault(),F.stopPropagation(),h.value=!0,v.value="scrollbar";const Y="touches"in F?F.touches[0].clientX:F.clientX;w.value=Y,E.value=c.value,"touches"in F?(document.addEventListener("touchmove",Ge),document.addEventListener("touchend",Oe)):(document.addEventListener("mousemove",Ge),document.addEventListener("mouseup",Oe))}function Ge(F){if(!h.value)return;const j=("touches"in F?F.touches[0].clientX:F.clientX)-w.value;if(v.value==="playhead"){const ee=j/L.value;let we=E.value+ee;if(n.selectedClipId){const Ve=n.clips.find(Je=>Je.id===n.selectedClipId);Ve?we=Math.max(Ve.timelineStart,Math.min(Ve.timelineEnd,we)):we=Math.max(0,Math.min(n.duration,we))}else{const Ve=n.clips.find(Je=>n.playhead>=Je.timelineStart&&n.playhead<=Je.timelineEnd);Ve?we=Math.max(Ve.timelineStart,Math.min(Ve.timelineEnd,we)):we=Math.max(0,Math.min(n.duration,we))}r("update:playhead",we)}else if(v.value==="scrollbar"){const ee=j/y.value*re.value;c.value=Math.max(0,Math.min(J.value,E.value+ee))}else if(v.value==="pan"){const ee=E.value-j;c.value=Math.max(0,Math.min(J.value,ee))}}function Oe(){h.value=!1,v.value=null,S.value=null,k.value=null,document.removeEventListener("mousemove",Ge),document.removeEventListener("mouseup",Oe),document.removeEventListener("touchmove",Ge),document.removeEventListener("touchend",Oe)}function kt(F){l.value=l.value===F?null:F,r("clip-select",l.value)}function lt(F){P(F)&&(l.value=F,r("clip-select",F),r("clip-long-press",F))}function zt(F){!P(F)||n.clips.length<=1||(l.value=F,r("clip-select",F),r("clip-delete",F))}function At(F,Y){if(!P(F))return;const j=n.clips.find(we=>we.id===F);if(!j||Math.abs(Y)<2)return;const ee=Y/L.value*n.sensitivity;if(n.useFrameMode){const we=p.secondsToFrames(j.sourceIn),Ve=p.secondsToFrames(ee),Je=Math.max(0,we+Ve),ut=p.framesToSeconds(Je);r("trim",F,"start",ut)}else{const we=Math.max(0,j.sourceIn+ee);r("trim",F,"start",we)}}function Jt(F,Y){if(!P(F))return;const j=n.clips.find(Bt=>Bt.id===F);if(!j||!s.value)return;const ee=s.value.getBoundingClientRect(),we=Y-ee.left-T.value,Ve=80;we<Ve?c.value=Math.max(0,c.value-8):we>ee.width-T.value-Ve&&(c.value=Math.min(J.value,c.value+8));const Je=we+c.value,ut=1/n.fps;let St=Je/L.value;const{previous:pt}=et(j.id),ft=xt(St,[0,pt==null?void 0:pt.timelineEnd,n.playhead],0,j.timelineEnd-ut);St=ft.value,S.value=ft.guideTime;let Mt=j.sourceIn+(St-j.timelineStart);Mt=Math.round(Mt*n.fps)/n.fps,r("trim",F,"start",Mt)}function Gt(F,Y){if(!P(F))return;const j=n.clips.find(It=>It.id===F);if(!j||!s.value)return;const ee=s.value.getBoundingClientRect(),we=Y-ee.left-T.value,Ve=80;we<Ve?c.value=Math.max(0,c.value-8):we>ee.width-T.value-Ve&&(c.value=Math.min(J.value,c.value+8));const Je=we+c.value,ut=1/n.fps,St=K(j);let pt=Je/L.value;const{next:ft}=et(j.id),Mt=xt(pt,[ft==null?void 0:ft.timelineStart,n.playhead],j.timelineStart+ut,St);pt=Mt.value,S.value=Mt.guideTime;let Bt=j.sourceIn+(pt-j.timelineStart);Bt=Math.round(Bt*n.fps)/n.fps,r("trim",F,"end",Bt)}function la(F){var j;if(!C.value||!s.value)return null;const Y=Array.from(s.value.querySelectorAll(".timeline-track-lane__body"));for(const ee of Y){const we=ee.getBoundingClientRect();if(F>=we.top&&F<=we.bottom){const Ve=ee.getAttribute("data-track-id");if(!Ve)continue;return((j=n.tracks)==null?void 0:j.find(ut=>ut.id===Ve))??null}}return null}function ga(F,Y,j){if(!P(F))return;const ee=n.clips.find(It=>It.id===F);if(!ee||!s.value)return;const we=s.value.getBoundingClientRect(),Ve=Y-we.left-T.value,Je=80;Ve<Je?c.value=Math.max(0,c.value-8):Ve>we.width-T.value-Je&&(c.value=Math.min(J.value,c.value+8));const ut=Ve+c.value,St=ee.timelineEnd-ee.timelineStart,pt=tt(ee);let ft=ut/L.value;const Mt=xt(ft,[pt.minStart,pt.maxStart,n.playhead,n.playhead-St],pt.minStart,pt.maxStart);ft=Mt.value,S.value=Mt.guideTime,ft=Math.round(ft*n.fps)/n.fps;let Bt;if(typeof j=="number"){const It=la(j);k.value=(It==null?void 0:It.id)??null,It&&It.id!==(ee.trackId??null)&&It.locked!==!0&&(Bt=It.id)}Bt!==void 0?r("clip-move",F,ft,Bt):r("clip-move",F,ft)}function ia(F,Y){if(!P(F))return;const j=n.clips.find(Ve=>Ve.id===F);if(!j||Math.abs(Y)<2)return;const ee=Y/L.value*n.sensitivity,we=Ve=>Math.max(0,Math.round(Ve*n.fps)/n.fps);if(n.useFrameMode){const Ve=p.secondsToFrames(j.sourceOut),Je=p.secondsToFrames(ee),ut=K(j),St=j.sourceIn+(ut-j.timelineStart),pt=p.secondsToFrames(St),ft=Math.min(pt,Ve+Je),Mt=p.framesToSeconds(ft);r("trim",F,"end",Mt)}else{const Ve=K(j),Je=j.sourceIn+(Ve-j.timelineStart),ut=Math.min(Je,j.sourceOut+ee),St=we(ut);r("trim",F,"end",St)}}function Aa(F,Y){if(!P(F))return;const j=n.clips.find(Ve=>Ve.id===F);if(!j||Math.abs(Y)<2)return;const ee=Y/L.value*n.sensitivity,we=Ve=>Math.max(0,Math.round(Ve*n.fps)/n.fps);if(n.useFrameMode){const Ve=p.secondsToFrames(j.timelineStart),Je=p.secondsToFrames(ee),ut=Math.max(0,Ve+Je),St=p.framesToSeconds(ut);r("clip-move",F,St)}else{const Ve=Math.max(0,j.timelineStart+ee),Je=we(Ve);r("clip-move",F,Je)}}return a({handleTrimStart:At,handleTrimEnd:ia,handleClipDrag:Aa,handleTrimStartAbs:Jt,handleTrimEndAbs:Gt,handleClipDragAbs:ga,handleClipLongPress:lt}),e.watch(()=>n.playhead,F=>{const Y=F*L.value;Y<c.value+50?c.value=Math.max(0,Y-50):Y>c.value+y.value-50&&(c.value=Math.min(J.value,Y-y.value+50))}),e.onMounted(()=>{const F=new ResizeObserver(Y=>{Y[0]&&(f.value=Math.round(Y[0].contentRect.width))});s.value&&F.observe(s.value),e.onUnmounted(()=>F.disconnect())}),e.onUnmounted(()=>{Oe()}),e.watch([re,O],()=>{c.value>J.value&&(c.value=J.value)}),e.watch(S,(F,Y)=>{const j=F!==null;j!==(Y!==null)&&r("snap-state-change",j)}),(F,Y)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-timeline",{mobile:i.value}]),ref_key:"timelineRef",ref:s,onWheel:Be},[e.createElementVNode("div",{class:"timeline-ruler",onClick:ye},[e.createElementVNode("div",x1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ve.value,j=>(e.openBlock(),e.createElementBlock("span",{key:j.position,class:"time-marker",style:e.normalizeStyle({left:`${j.position}px`})},e.toDisplayString(j.label),5))),128))])]),e.createElementVNode("div",{class:e.normalizeClass(["timeline-content",{"is-pannable":D.value,"is-panning":h.value&&v.value==="pan","overflow-left":Z.value,"overflow-right":ie.value}]),onTouchstart:wt,onTouchmove:it,onTouchend:_t,onMousedown:ge},[C.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"timeline-track-lanes",style:e.normalizeStyle({"--timeline-track-header-width":`${Nc}px`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.value,j=>(e.openBlock(),e.createElementBlock("div",{key:j.track.id,class:e.normalizeClass(["timeline-track-lane",{"timeline-track-lane--locked":j.track.locked,"timeline-track-lane--hidden":j.track.hidden,"timeline-track-lane--drop-target":k.value===j.track.id&&j.track.locked!==!0,"timeline-track-lane--drop-rejected":k.value===j.track.id&&j.track.locked===!0}]),style:e.normalizeStyle({height:`${j.height}px`}),"data-track-id":j.track.id},[e.createVNode(E1,{class:"timeline-track-lane__header",track:j.track,onToggleLock:Y[0]||(Y[0]=ee=>r("toggle-lock",ee)),onToggleHidden:Y[1]||(Y[1]=ee=>r("toggle-hidden",ee)),onToggleMuted:Y[2]||(Y[2]=ee=>r("toggle-muted",ee)),onToggleSolo:Y[3]||(Y[3]=ee=>r("toggle-solo",ee)),onRenameTrack:Y[4]||(Y[4]=(ee,we)=>r("rename-track",ee,we)),onDeleteTrack:Y[5]||(Y[5]=ee=>r("delete-track",ee)),onReorderTrack:Y[6]||(Y[6]=(ee,we)=>r("reorder-track",ee,we))},null,8,["track"]),e.createElementVNode("div",{class:"video-track timeline-track-lane__body","data-track-id":j.track.id},[j.track.hidden?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(j.clips,ee=>(e.openBlock(),e.createElementBlock("div",{key:`${ee.id}-extent`,class:"clip-extent",style:e.normalizeStyle(be(ee,j.height)),"aria-hidden":"true"},null,4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(j.clips,ee=>(e.openBlock(),e.createBlock(Vc,{key:ee.id,clip:ee,scale:L.value,"scroll-offset":c.value,selected:m.value===ee.id,"is-mobile":i.value,"can-delete":n.clips.length>1&&P(ee.id),"data-locked":j.track.locked===!0?"true":void 0,onSelect:we=>kt(ee.id),onDelete:we=>zt(ee.id),onLongPress:we=>lt(ee.id),onTrimStartAbs:we=>Jt(ee.id,we),onTrimEndAbs:we=>Gt(ee.id,we),onDragAbs:(we,Ve)=>ga(ee.id,we,Ve)},null,8,["clip","scale","scroll-offset","selected","is-mobile","can-delete","data-locked","onSelect","onDelete","onLongPress","onTrimStartAbs","onTrimEndAbs","onDragAbs"]))),128))],64))],8,C1)],14,S1))),128))],4)):(e.openBlock(),e.createElementBlock("div",{key:1,class:"video-track",ref_key:"trackRef",ref:u},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(F.clips,j=>(e.openBlock(),e.createElementBlock("div",{key:`${j.id}-extent`,class:"clip-extent",style:e.normalizeStyle(be(j)),"aria-hidden":"true"},null,4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(F.clips,j=>(e.openBlock(),e.createBlock(Vc,{key:j.id,clip:j,scale:L.value,"scroll-offset":c.value,selected:m.value===j.id,"is-mobile":i.value,"can-delete":n.clips.length>1&&P(j.id),onSelect:ee=>kt(j.id),onDelete:ee=>zt(j.id),onLongPress:ee=>lt(j.id),onTrimStartAbs:ee=>Jt(j.id,ee),onTrimEndAbs:ee=>Gt(j.id,ee),onDragAbs:(ee,we)=>ga(j.id,ee,we)},null,8,["clip","scale","scroll-offset","selected","is-mobile","can-delete","onSelect","onDelete","onLongPress","onTrimStartAbs","onTrimEndAbs","onDragAbs"]))),128))],512)),e.createElementVNode("div",{class:"playhead",style:e.normalizeStyle({left:`${T.value+se.value}px`}),onMousedown:Te,onTouchstart:Te},[...Y[8]||(Y[8]=[e.createElementVNode("div",{class:"playhead-handle"},[e.createElementVNode("div",{class:"playhead-line"})],-1)])],36),d.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:"split-indicator",style:e.normalizeStyle({left:`${T.value+se.value}px`})},null,4)):e.createCommentVNode("",!0),Ue.value!==null?(e.openBlock(),e.createElementBlock("div",{key:3,class:"snap-guide",style:e.normalizeStyle({left:`${T.value+Ue.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0),i.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:4,class:"frame-mode-toggle",onClick:Y[7]||(Y[7]=j=>F.$emit("toggle-frame-mode")),"aria-label":F.useFrameMode?"Switch to time mode":"Switch to frame mode",title:F.useFrameMode?"Switch to time mode":"Switch to frame mode"},e.toDisplayString(F.useFrameMode?"F":"T"),9,V1))],34),D.value?(e.openBlock(),e.createElementBlock("div",N1,[e.createElementVNode("div",{class:"scrollbar-thumb",style:e.normalizeStyle(me.value),onMousedown:Ke,onTouchstart:Ke},null,36)])):e.createCommentVNode("",!0)],34))}}),Sl=Fe(T1,[["__scopeId","data-v-2484f443"]]),B1={key:0,class:"control-group primary-controls"},I1=["disabled"],M1=["disabled"],F1=["disabled"],$1=["disabled"],D1=["disabled"],R1=["disabled"],A1={key:1,class:"control-group mobile-action-controls"},L1=["aria-expanded"],P1={key:0,class:"mobile-action-menu",role:"menu","aria-label":"Clip actions","data-testid":"timeline-mobile-action-menu"},U1=["disabled"],O1=["disabled"],z1=["disabled"],j1=["disabled"],W1=["disabled"],H1=["disabled"],Z1={class:"control-group zoom-controls"},G1={class:"zoom-slider"},X1=["value"],K1={class:"control-group playback-controls"},J1=["aria-label"],q1={key:2,class:"control-group speed-control"},Y1=["value"],Q1=e.defineComponent({__name:"TimelineControls",props:{selectedClip:{},canSplit:{type:Boolean,default:!1},canDelete:{type:Boolean,default:!1},canAddTrack:{type:Boolean,default:!0},showAddTrack:{type:Boolean,default:!1},canUndo:{type:Boolean,default:!1},canRedo:{type:Boolean,default:!1},isPlaying:{type:Boolean,default:!1},zoomLevel:{default:50},playbackSpeed:{default:1},isMobile:{type:Boolean,default:!1}},emits:["split","delete","duplicate","add-track","undo","redo","zoom-in","zoom-out","zoom-change","fit-to-window","play-pause","frame-forward","frame-backward","skip-to-start","skip-to-end","speed-change"],setup(o,{emit:a}){const t=a,n=e.ref(!1);function i(m){switch(m){case"split":t("split");break;case"delete":t("delete");break;case"duplicate":t("duplicate");break;case"add-track":t("add-track");break;case"undo":t("undo");break;case"redo":t("redo");break}n.value=!1}function r(m){const p=m.target;t("zoom-change",Number(p.value))}function s(){t("fit-to-window")}function l(){t("frame-forward")}function d(){t("frame-backward")}function c(){t("skip-to-start")}function u(){t("skip-to-end")}function f(m){const p=m.target;t("speed-change",Number(p.value))}return(m,p)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-controls",{mobile:m.isMobile}])},[m.isMobile?(e.openBlock(),e.createElementBlock("div",A1,[e.createElementVNode("button",{class:"control-button","data-testid":"timeline-btn-mobile-actions","aria-expanded":n.value?"true":"false","aria-label":"Clip actions",onClick:p[6]||(p[6]=h=>n.value=!n.value)},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Lh)},null,8,["icon"]),p[20]||(p[20]=e.createElementVNode("span",{class:"control-label"},"Actions",-1))],8,L1),n.value?(e.openBlock(),e.createElementBlock("div",P1,[m.showAddTrack?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",role:"menuitem",disabled:!m.canAddTrack,"data-testid":"timeline-mobile-btn-add-track",onClick:p[7]||(p[7]=h=>i("add-track"))},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(vr)},null,8,["icon"]),p[21]||(p[21]=e.createTextVNode(" Add Track ",-1))],8,U1)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",role:"menuitem",disabled:!m.canUndo,"data-testid":"timeline-mobile-btn-undo",onClick:p[8]||(p[8]=h=>i("undo"))},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Qd)},null,8,["icon"]),p[22]||(p[22]=e.createTextVNode(" Undo ",-1))],8,O1),e.createElementVNode("button",{type:"button",role:"menuitem",disabled:!m.canRedo,"data-testid":"timeline-mobile-btn-redo",onClick:p[9]||(p[9]=h=>i("redo"))},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Yd)},null,8,["icon"]),p[23]||(p[23]=e.createTextVNode(" Redo ",-1))],8,z1),e.createElementVNode("button",{type:"button",role:"menuitem",disabled:!m.canSplit,"data-testid":"timeline-mobile-btn-split",onClick:p[10]||(p[10]=h=>i("split"))},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Tr)},null,8,["icon"]),p[24]||(p[24]=e.createTextVNode(" Split ",-1))],8,j1),e.createElementVNode("button",{type:"button",role:"menuitem",disabled:!m.selectedClip,"data-testid":"timeline-mobile-btn-duplicate",onClick:p[11]||(p[11]=h=>i("duplicate"))},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(sl)},null,8,["icon"]),p[25]||(p[25]=e.createTextVNode(" Duplicate ",-1))],8,W1),e.createElementVNode("button",{type:"button",role:"menuitem",class:"danger-menu-item",disabled:!m.canDelete,"data-testid":"timeline-mobile-btn-delete",onClick:p[12]||(p[12]=h=>i("delete"))},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Br)},null,8,["icon"]),p[26]||(p[26]=e.createTextVNode(" Delete ",-1))],8,H1)])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",B1,[m.showAddTrack?(e.openBlock(),e.createElementBlock("button",{key:0,class:"control-button",disabled:!m.canAddTrack,"data-testid":"timeline-btn-add-track","aria-label":"Add video track",title:"Add Track",onClick:p[0]||(p[0]=h=>m.$emit("add-track"))},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(vr)},null,8,["icon"]),p[16]||(p[16]=e.createElementVNode("span",{class:"control-label"},"Add Track",-1))],8,I1)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"control-button",disabled:!m.canUndo,"data-testid":"timeline-btn-undo","aria-label":"Undo",title:"Undo",onClick:p[1]||(p[1]=h=>m.$emit("undo"))},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Qd)},null,8,["icon"])],8,M1),e.createElementVNode("button",{class:"control-button",disabled:!m.canRedo,"data-testid":"timeline-btn-redo","aria-label":"Redo",title:"Redo",onClick:p[2]||(p[2]=h=>m.$emit("redo"))},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Yd)},null,8,["icon"])],8,F1),e.createElementVNode("button",{class:"control-button",disabled:!m.canSplit,"data-testid":"timeline-btn-split","aria-label":"Split selected clip at playhead",title:"Split",onClick:p[3]||(p[3]=h=>m.$emit("split"))},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Tr)},null,8,["icon"]),p[17]||(p[17]=e.createElementVNode("span",{class:"control-label"},"Split",-1))],8,$1),e.createElementVNode("button",{class:"control-button",disabled:!m.selectedClip,"data-testid":"timeline-btn-duplicate","aria-label":"Duplicate selected clip",title:"Duplicate",onClick:p[4]||(p[4]=h=>m.$emit("duplicate"))},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(sl)},null,8,["icon"]),p[18]||(p[18]=e.createElementVNode("span",{class:"control-label"},"Duplicate",-1))],8,D1),e.createElementVNode("button",{class:"control-button danger-button",disabled:!m.canDelete,"data-testid":"timeline-btn-delete","aria-label":"Delete selected clip",title:"Delete",onClick:p[5]||(p[5]=h=>m.$emit("delete"))},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Br)},null,8,["icon"]),p[19]||(p[19]=e.createElementVNode("span",{class:"control-label"},"Delete",-1))],8,R1)])),e.createElementVNode("div",Z1,[e.createElementVNode("button",{class:"control-button zoom-button",onClick:p[13]||(p[13]=h=>m.$emit("zoom-out")),"aria-label":"Zoom out"},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(av)},null,8,["icon"])]),e.createElementVNode("div",G1,[e.createElementVNode("input",{type:"range",value:m.zoomLevel,onInput:r,min:"10",max:"200",step:"5","aria-label":"Timeline zoom"},null,40,X1)]),e.createElementVNode("button",{class:"control-button zoom-button",onClick:p[14]||(p[14]=h=>m.$emit("zoom-in")),"aria-label":"Zoom in"},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(vr)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:s,"aria-label":"Fit timeline to window"},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Uh)},null,8,["icon"]),p[27]||(p[27]=e.createElementVNode("span",{class:"control-label"},"Fit",-1))])]),e.createElementVNode("div",K1,[e.createElementVNode("button",{class:"control-button",onClick:c,"aria-label":"Skip to start"},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(ev)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:d,"aria-label":"Previous frame"},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Jh)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button play-button",onClick:p[15]||(p[15]=h=>m.$emit("play-pause")),"aria-label":m.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(H.IonIcon),{icon:m.isPlaying?e.unref(ql):e.unref(Yl)},null,8,["icon"])],8,J1),e.createElementVNode("button",{class:"control-button",onClick:l,"aria-label":"Next frame"},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Qh)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:u,"aria-label":"Skip to end"},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(tv)},null,8,["icon"])])]),m.isMobile?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",q1,[p[29]||(p[29]=e.createElementVNode("label",{class:"speed-label"},"Speed:",-1)),e.createElementVNode("select",{value:m.playbackSpeed,onChange:f,class:"speed-select","aria-label":"Playback speed"},[...p[28]||(p[28]=[e.createStaticVNode('<option value="0.25" data-v-c7b0395a>0.25x</option><option value="0.5" data-v-c7b0395a>0.5x</option><option value="1" data-v-c7b0395a>1x</option><option value="1.5" data-v-c7b0395a>1.5x</option><option value="2" data-v-c7b0395a>2x</option>',5)])],40,Y1)]))],2))}}),Cl=Fe(Q1,[["__scopeId","data-v-c7b0395a"]]),ew={key:0,class:"category-section"},tw={class:"category-carousel-wrapper"},aw=["disabled"],nw=["onClick","data-testid","aria-label"],ow={class:"category-name"},iw=["disabled"],rw={class:"filter-section"},sw={class:"filter-carousel-wrapper"},lw=["disabled"],dw=["onClick","onKeydown","data-testid","aria-label"],cw=["onClick"],uw={class:"filter-preview"},mw={class:"filter-placeholder"},pw={class:"filter-name"},fw=["disabled"],hw={class:"carousel-pagination"},vw=["onClick"],gw={key:1,class:"filter-adjustments"},bw={class:"adjustment-header"},yw={class:"adjustment-actions"},ww={key:0},kw={key:0,class:"slider-control"},_w={class:"control-label"},Ew={class:"slider-wrapper"},xw={class:"slider-value"},Sw={key:1,class:"color-control"},Cw={class:"control-label"},Vw={class:"color-wrapper"},Nw=["value","onInput","disabled"],Tw={class:"color-value"},Bw={key:2,class:"toggle-control"},Iw={class:"control-label"},Mw={key:3,class:"select-control"},Fw={class:"control-label"},$w=["value","onChange","disabled"],Dw=["value"],Rw={key:1,class:"no-params"},Aw=e.defineComponent({__name:"VideoFilterCarousel",props:{filters:{},activeFilters:{},thumbnailUrl:{},showCategories:{type:Boolean,default:!0},compact:{type:Boolean,default:!1}},emits:["apply-filter","remove-filter","update-param","preview-filter"],setup(o,{emit:a}){const t=o,n=a,i=e.ref("all"),r=e.ref(null),s=e.ref(0),l=e.ref(0),d=e.ref(new Map),c=e.ref(),u=e.ref(),f={all:wn,adjust:Ko,color:kn,blur:ar,light:Jo,effects:As,stylize:ni,advanced:wn,distortion:oi,transform:oi};function m(B){return B.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function p(B){return B.replace(/[-_]/g," ").replace(/\b\w/g,P=>P.toUpperCase())}function h(B){return f[B.toLowerCase()]??wn}const v=e.computed(()=>{const B=Array.from(new Set(t.filters.map(P=>P.category).filter(P=>typeof P=="string"&&P.length>0))).sort((P,X)=>P.localeCompare(X));return[{id:"all",name:"All",icon:wn},...B.map(P=>({id:P,name:p(P),icon:h(P)}))]}),w=e.computed(()=>i.value==="all"?t.filters:t.filters.filter(B=>B.category===i.value));e.watch(v,B=>{new Set(B.map(K=>K.id)).has(i.value)||(i.value="all");const X=Math.max(0,B.length-3);s.value>X&&(s.value=X)},{immediate:!0});function E(B){var P;return((P=t.activeFilters)==null?void 0:P.has(B))||!1}function S(B){if(r.value=B,!E(B.id)&&(n("apply-filter",B),B.params&&B.params.length>0)){const P=new Map;B.params.forEach(X=>{P.set(X.id,X.default)}),d.value.set(B.id,P)}n("preview-filter",B)}function k(B){var P;n("remove-filter",B),d.value.delete(B),((P=r.value)==null?void 0:P.id)===B&&(r.value=null)}function b(B){if(typeof B=="number"&&Number.isFinite(B))return B;if(typeof B=="string"){const P=Number(B);return Number.isFinite(P)?P:null}return null}function $(B,P){var O;const X=t.filters.find(D=>D.id===B),K=X==null?void 0:X.params.find(D=>D.id===P),be=(K==null?void 0:K.default)??0,Ne=D=>typeof be=="number"?b(D)??be:typeof be=="boolean"?typeof D=="boolean"?D:be:typeof D=="string"?D:be,ue=(O=t.activeFilters)==null?void 0:O.get(B);if(ue&&ue.params){const D=ue.params[P];if(D!=null)return Ne(D)}const re=d.value.get(B);if(re){const D=re.get(P);if(D!=null)return Ne(D)}return be}function V(B,P,X){var K;d.value.has(B)||d.value.set(B,new Map),(K=d.value.get(B))==null||K.set(P,X),n("update-param",B,P,X)}function I(B){if(typeof B=="boolean")return B?"On":"Off";if(typeof B=="string"){const X=b(B);return X===null?"0":Number.isInteger(X)?X.toString():X.toFixed(2)}const P=b(B);return P===null?"0":Number.isInteger(P)?P.toString():P.toFixed(2)}function x(){if(r.value&&(n("apply-filter",r.value),r.value.params&&r.value.params.length>0)){const B=new Map;r.value.params.forEach(P=>{B.set(P.id,P.default)}),d.value.set(r.value.id,B)}}function N(B){const P=t.filters.find(X=>X.id===B);P&&P.params&&P.params.forEach(X=>{V(B,X.id,X.default)})}function L(B){return{basic:Ko,color:kn,blur:ar,light:Jo,effects:As,stylize:ni,adjustment:Ko,"color-matrix":kn,glow:wn,distortion:oi}[B]||wn}function C(B){return{adjustment:Ko,brightness:Jo,contrast:Ko,saturation:kn,blur:ar,"gaussian-blur":ar,"color-matrix":kn,grayscale:ni,sepia:ni,vignette:oi,glow:wn,glitch:As,godray:Jo,lightmap:Jo}[B.id]||L(B.category)}function T(){s.value>0&&(s.value--,W(c.value,s.value))}function y(){s.value<v.value.length-3&&(s.value++,W(c.value,s.value))}function R(){l.value>0&&(l.value--,W(u.value,l.value))}function U(){l.value<w.value.length-4&&(l.value++,W(u.value,l.value))}function z(B){l.value=B*4,W(u.value,l.value)}function W(B,P){var X;if(B){const K=((X=B.querySelector(".category-chip, .filter-card"))==null?void 0:X.clientWidth)||100;B.scrollTo({left:P*(K+8),behavior:"smooth"})}}return(B,P)=>{var X;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-filter-carousel-container",{compact:B.compact}])},[B.showCategories?(e.openBlock(),e.createElementBlock("div",ew,[e.createElementVNode("div",tw,[e.createElementVNode("button",{onClick:T,class:"carousel-nav carousel-nav-left",disabled:s.value===0,"aria-label":"Previous categories","data-testid":"btn-filter-category-prev"},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(ec)},null,8,["icon"])],8,aw),e.createElementVNode("div",{ref_key:"categoryCarouselRef",ref:c,class:"category-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,K=>(e.openBlock(),e.createElementBlock("button",{key:K.id,onClick:be=>i.value=K.id,class:e.normalizeClass(["category-chip",{active:i.value===K.id}]),"data-testid":`btn-filter-category-${m(K.id)}`,"aria-label":`Filter category ${K.name}`},[e.createVNode(e.unref(H.IonIcon),{icon:K.icon,class:"category-icon"},null,8,["icon"]),e.createElementVNode("span",ow,e.toDisplayString(K.name),1)],10,nw))),128))],512),e.createElementVNode("button",{onClick:y,class:"carousel-nav carousel-nav-right",disabled:s.value>=v.value.length-3,"aria-label":"Next categories","data-testid":"btn-filter-category-next"},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(tc)},null,8,["icon"])],8,iw)])])):e.createCommentVNode("",!0),e.createElementVNode("div",rw,[e.createElementVNode("div",sw,[e.createElementVNode("button",{onClick:R,class:"carousel-nav carousel-nav-left",disabled:l.value===0,"aria-label":"Previous filters","data-testid":"btn-filter-carousel-prev"},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(ec)},null,8,["icon"])],8,lw),e.createElementVNode("div",{ref_key:"filterCarouselRef",ref:u,class:"filter-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.value,K=>{var be;return e.openBlock(),e.createElementBlock("div",{key:K.id,class:e.normalizeClass(["filter-card",{active:E(K.id),selected:((be=r.value)==null?void 0:be.id)===K.id}]),onClick:Ne=>S(K),onKeydown:[e.withKeys(Ne=>S(K),["enter"]),e.withKeys(e.withModifiers(Ne=>S(K),["prevent"]),["space"])],role:"button",tabindex:"0","data-testid":`btn-video-filter-${m(K.id)}`,"aria-label":`Select filter ${K.name}`},[E(K.id)?(e.openBlock(),e.createElementBlock("div",{key:0,class:"filter-checkmark",onClick:e.withModifiers(Ne=>k(K.id),["stop"])},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Wu)},null,8,["icon"])],8,cw)):e.createCommentVNode("",!0),e.createElementVNode("div",uw,[e.createElementVNode("div",mw,[e.createVNode(e.unref(H.IonIcon),{icon:C(K),class:"filter-icon"},null,8,["icon"])])]),e.createElementVNode("span",pw,e.toDisplayString(K.name),1)],42,dw)}),128))],512),e.createElementVNode("button",{onClick:U,class:"carousel-nav carousel-nav-right",disabled:l.value>=Math.max(0,w.value.length-4),"aria-label":"Next filters","data-testid":"btn-filter-carousel-next"},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(tc)},null,8,["icon"])],8,fw)]),e.createElementVNode("div",hw,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Math.ceil(w.value.length/4),(K,be)=>(e.openBlock(),e.createElementBlock("span",{key:be,class:e.normalizeClass(["pagination-dot",{active:Math.floor(l.value/4)===be}]),onClick:Ne=>z(be)},null,10,vw))),128))])]),r.value?(e.openBlock(),e.createElementBlock("div",gw,[e.createElementVNode("div",bw,[e.createElementVNode("h4",null,e.toDisplayString(r.value.name),1),e.createElementVNode("div",yw,[E(r.value.id)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,onClick:x,class:"apply-btn","data-testid":"btn-apply-selected-filter"}," Apply Filter ")),E(r.value.id)?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:P[0]||(P[0]=K=>k(r.value.id)),class:"remove-btn","data-testid":"btn-remove-selected-filter"}," Remove Filter ")):e.createCommentVNode("",!0),E(r.value.id)&&((X=r.value.params)==null?void 0:X.length)>0?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:P[1]||(P[1]=K=>N(r.value.id)),class:"reset-btn","data-testid":"btn-reset-selected-filter"}," Reset ")):e.createCommentVNode("",!0)])]),r.value.params&&r.value.params.length>0?(e.openBlock(),e.createElementBlock("div",ww,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value.params,K=>(e.openBlock(),e.createElementBlock("div",{key:K.id,class:"adjustment-control"},[!K.type||K.type==="slider"?(e.openBlock(),e.createElementBlock("div",kw,[e.createElementVNode("label",_w,e.toDisplayString(K.label||K.id),1),e.createElementVNode("div",Ew,[e.createVNode(e.unref(H.IonRange),{value:$(r.value.id,K.id),onIonChange:be=>V(r.value.id,K.id,be.detail.value),min:K.min,max:K.max,step:K.step||.01,color:"primary",class:"compact-slider",disabled:!E(r.value.id),"data-testid":`range-filter-${m(r.value.id)}-${m(K.id)}`,"aria-label":`Adjust ${K.label||K.id} for ${r.value.name}`},null,8,["value","onIonChange","min","max","step","disabled","data-testid","aria-label"]),e.createElementVNode("span",xw,e.toDisplayString(I($(r.value.id,K.id))),1)])])):K.type==="color"?(e.openBlock(),e.createElementBlock("div",Sw,[e.createElementVNode("label",Cw,e.toDisplayString(K.label||K.id),1),e.createElementVNode("div",Vw,[e.createElementVNode("input",{type:"color",value:$(r.value.id,K.id),onInput:be=>V(r.value.id,K.id,be.target.value),disabled:!E(r.value.id),class:"color-input"},null,40,Nw),e.createElementVNode("span",Tw,e.toDisplayString($(r.value.id,K.id)),1)])])):K.type==="toggle"?(e.openBlock(),e.createElementBlock("div",Bw,[e.createElementVNode("label",Iw,e.toDisplayString(K.label||K.id),1),e.createVNode(e.unref(H.IonToggle),{checked:!!$(r.value.id,K.id),onIonChange:be=>V(r.value.id,K.id,be.detail.checked),disabled:!E(r.value.id),color:"primary"},null,8,["checked","onIonChange","disabled"])])):K.type==="select"?(e.openBlock(),e.createElementBlock("div",Mw,[e.createElementVNode("label",Fw,e.toDisplayString(K.label||K.id),1),e.createElementVNode("select",{value:$(r.value.id,K.id),onChange:be=>V(r.value.id,K.id,be.target.value),disabled:!E(r.value.id),class:"select-input"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(K.options,be=>(e.openBlock(),e.createElementBlock("option",{key:String(be.value),value:be.value},e.toDisplayString(be.label),9,Dw))),128))],40,$w)])):e.createCommentVNode("",!0)]))),128))])):(e.openBlock(),e.createElementBlock("div",Rw," This filter has no adjustable parameters "))])):e.createCommentVNode("",!0)],2)}}}),Vl=Fe(Aw,[["__scopeId","data-v-9efd15d9"]]);class Lw{constructor(a){this.pixiFilters=new Map,this.filterParams=new Map,this.filterTypes=new Map,this.filterIntensity=new Map,this.composition=a}setComposition(a){this.composition=a}mapMediablesToPIXI(a){switch(a.filterId){case"blur":return this.createBlurFilter(a.params);case"brightness":return this.createBrightnessFilter(a.params);case"contrast":return this.createContrastFilter(a.params);case"saturation":return this.createSaturationFilter(a.params);case"hue":return this.createHueFilter(a.params);case"vintage":return this.createVintageFilter(a.params);case"grayscale":return this.createGrayscaleFilter();case"sepia":return this.createSepiaFilter();default:return null}}createBlurFilter(a){var t,n;try{const i=(n=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:n.BlurFilter;if(!i)return null;const r=new i;return r.blur=a.intensity||5,r.quality=a.quality||4,r}catch{return null}}createBrightnessFilter(a){var t,n;try{const i=(n=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:n.ColorMatrixFilter;if(!i)return null;const r=new i;return r.brightness(a.value||1,!1),r}catch{return null}}createContrastFilter(a){var t,n;try{const i=(n=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:n.ColorMatrixFilter;if(!i)return null;const r=new i;return r.contrast(a.value||1,!1),r}catch{return null}}createSaturationFilter(a){var t,n;try{const i=(n=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:n.ColorMatrixFilter;if(!i)return null;const r=new i;return r.saturate(a.value||1,!1),r}catch{return null}}createHueFilter(a){var t,n;try{const i=(n=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:n.ColorMatrixFilter;if(!i)return null;const r=new i;return r.hue(a.rotation||0,!1),r}catch{return null}}createVintageFilter(a){var t,n;try{const i=(n=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:n.ColorMatrixFilter;if(!i)return null;const r=new i;return r.vintage(!1),a.intensity&&(r.contrast(1.2,!1),r.saturate(.8,!1)),r}catch{return null}}createGrayscaleFilter(){var a,t;try{const n=(t=(a=window.PIXI)==null?void 0:a.filters)==null?void 0:t.ColorMatrixFilter;if(!n)return null;const i=new n;return i.desaturate(),i}catch{return null}}createSepiaFilter(){var a,t;try{const n=(t=(a=window.PIXI)==null?void 0:a.filters)==null?void 0:t.ColorMatrixFilter;if(!n)return null;const i=new n;return i.sepia(!1),i}catch{return null}}async applyFilters(a){if(this.composition){this.clearFilters();for(const t of a){const n=this.mapMediablesToPIXI(t);n&&(this.pixiFilters.set(t.id,n),this.filterParams.set(t.id,t.params),this.filterTypes.set(t.id,t.filterId),this.filterIntensity.set(t.id,t.intensity),await this.applyToComposition(t.id,n))}}}async applyToComposition(a,t){try{this.composition.applyFilter&&await this.composition.applyFilter(a,t)}catch{}}updateFilterParams(a,t){var i;const n=this.pixiFilters.get(a);n&&(this.filterParams.set(a,t),"blur"in n&&(n.blur=t.intensity||n.blur),"brightness"in n&&n.brightness(t.value||1,!1),"contrast"in n&&n.contrast(t.value||1,!1),"saturate"in n&&n.saturate(t.value||1,!1),"hue"in n&&n.hue(t.rotation||0,!1),(i=this.composition)!=null&&i.update&&this.composition.update())}getFilterParams(a){return this.filterParams.get(a)||{}}removeFilter(a){var t;this.pixiFilters.delete(a),this.filterParams.delete(a),this.filterTypes.delete(a),this.filterIntensity.delete(a),(t=this.composition)!=null&&t.removeFilter&&this.composition.removeFilter(a)}clearFilters(){var a;this.pixiFilters.clear(),this.filterParams.clear(),this.filterTypes.clear(),this.filterIntensity.clear(),(a=this.composition)!=null&&a.clearFilters&&this.composition.clearFilters()}getActiveFilters(){return Array.from(this.pixiFilters.values())}exportFilterConfig(){const a=[];return this.pixiFilters.forEach((t,n)=>{const i=this.filterParams.get(n)??{},r=this.filterTypes.get(n)??"unknown",s=this.filterIntensity.get(n)??1;a.push({id:n,filterId:r,params:i,intensity:s})}),a}async importFilterConfig(a){await this.applyFilters(a)}destroy(){this.clearFilters(),this.composition=null}}const Pw={class:"video-filter-preview"},Uw={class:"preview-title"},Ow={class:"filter-controls"},zw={class:"control-input"},jw=["value","onInput","min","max","step"],Ww={class:"param-value"},Hw={class:"preview-container"},Zw={key:0,class:"filter-presets"},Gw=["onClick"],Xw={class:"preview-actions"},Kw=e.defineComponent({__name:"VideoFilterPreview",props:{filter:{},currentFrame:{},useVideoEngine:{type:Boolean,default:!1},composition:{}},emits:["update-params","apply"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(),r=e.ref(!1),s=e.ref({});let l,d,c=null,u=null;const f=e.computed(()=>{var x;return((x=t.filter)==null?void 0:x.paramRanges)||{}}),m=e.computed(()=>p.value.length>0),p=e.computed(()=>t.filter?{brightness:[{name:"Subtle",params:{value:.1}},{name:"Medium",params:{value:.3}},{name:"Strong",params:{value:.5}}],contrast:[{name:"Low",params:{value:.8}},{name:"Normal",params:{value:1}},{name:"High",params:{value:1.5}}],"gaussian-blur":[{name:"Subtle",params:{value:1}},{name:"Medium",params:{value:3}},{name:"Strong",params:{value:5}}]}[t.filter.id]||[]:[]);async function h(){var x;if(i.value){t.useVideoEngine&&t.composition&&(u=new Lw(t.composition));try{if(l=new Pt.Application,await l.init({width:i.value.clientWidth,height:i.value.clientHeight,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,canvas:i.value}),(x=t.currentFrame)!=null&&x.dataUrl){const N=await Pt.Assets.load(t.currentFrame.dataUrl);d=new Pt.Sprite(N);const L=Math.min(l.screen.width/d.texture.width,l.screen.height/d.texture.height);d.scale.set(L),d.anchor.set(.5),d.position.set(l.screen.width/2,l.screen.height/2),l.stage.addChild(d)}v()}catch{}}}function v(){if(!(!d||!t.filter))if(t.useVideoEngine&&u){const x={id:t.filter.id,filterId:t.filter.id,params:s.value,intensity:s.value.value??s.value.intensity??1};u.applyFilters([x]).then(()=>{}).catch(N=>{}),c&&(c.destroy(),c=null),c=w(t.filter.id,s.value),c&&(d.filters=r.value?null:[c])}else c&&(c.destroy(),c=null),c=w(t.filter.id,s.value),c&&(d.filters=r.value?null:[c])}function w(x,N){switch(x){case"brightness":{const L=new Pt.ColorMatrixFilter,C=1+(N.value??0);return typeof L.brightness=="function"&&L.brightness(C,!1),L}case"contrast":{const L=new Pt.ColorMatrixFilter,C=N.value??1;return typeof L.contrast=="function"&&L.contrast(C,!1),L}case"saturation":{const L=new Pt.ColorMatrixFilter,C=N.value??1;return typeof L.saturate=="function"&&L.saturate(C,!1),L}case"hue":{const L=new Pt.ColorMatrixFilter,C=N.value??0;return typeof L.hue=="function"&&L.hue(C,!1),L}case"gaussian-blur":{const L=N.value??5;return new Pt.BlurFilter({strength:L,quality:4})}case"sepia":{const L=new Pt.ColorMatrixFilter;return typeof L.sepia=="function"&&L.sepia(!1),L}case"grayscale":{const L=new Pt.ColorMatrixFilter;return typeof L.desaturate=="function"&&L.desaturate(),L}default:return null}}function E(x,N){const L=N.target,C=Number.parseFloat(L.value),T=Number.isFinite(C)?C:0;s.value={...s.value,[x]:T},t.useVideoEngine&&u&&t.filter&&u.updateFilterParams(t.filter.id,s.value),n("update-params",s.value),v()}function S(x){return x.charAt(0).toUpperCase()+x.slice(1).replace(/_/g," ")}function k(x,N){var C;const L=typeof x=="number"?x:Number(x);return Number.isFinite(L)?N==="hue"||N==="angle"?`${L}°`:N==="value"&&((C=t.filter)==null?void 0:C.id)==="brightness"?`${Math.round((1+L)*100)}%`:Number.isInteger(L)?L.toString():L.toFixed(2):"0"}function b(){var x;s.value=((x=t.filter)==null?void 0:x.defaultParams)||{},n("update-params",s.value),v()}function $(x){s.value={...x.params},n("update-params",s.value),v()}function V(x){return JSON.stringify(x.params)===JSON.stringify(s.value)}function I(){n("apply")}return e.watch(()=>t.filter,x=>{x&&(s.value={...x.defaultParams},v())}),e.watch(()=>t.currentFrame,async x=>{if(x!=null&&x.dataUrl&&d){const N=await Pt.Assets.load(x.dataUrl);d.texture=N}}),e.watch(r,v),e.onMounted(()=>{t.filter&&(s.value={...t.filter.defaultParams}),h()}),e.onUnmounted(()=>{l&&l.destroy(!0,{children:!0,texture:!0}),c&&c.destroy(),u&&u.destroy()}),(x,N)=>{var L;return e.openBlock(),e.createElementBlock("div",Pw,[e.createElementVNode("h4",Uw,e.toDisplayString((L=x.filter)==null?void 0:L.name)+" Settings",1),e.createElementVNode("div",Ow,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(C,T)=>(e.openBlock(),e.createElementBlock("div",{key:T,class:"control-group"},[e.createElementVNode("label",null,e.toDisplayString(S(T)),1),e.createElementVNode("div",zw,[e.createElementVNode("input",{type:"range",value:s.value[T],onInput:y=>E(T,y),min:C.min,max:C.max,step:C.step,class:"param-slider"},null,40,jw),e.createElementVNode("span",Ww,e.toDisplayString(k(s.value[T],T)),1)])]))),128))]),e.createElementVNode("div",Hw,[e.createElementVNode("canvas",{ref_key:"previewCanvas",ref:i,class:"preview-canvas"},null,512),e.createElementVNode("button",{class:"compare-button",onMousedown:N[0]||(N[0]=C=>r.value=!0),onMouseup:N[1]||(N[1]=C=>r.value=!1),onTouchstart:N[2]||(N[2]=C=>r.value=!0),onTouchend:N[3]||(N[3]=C=>r.value=!1)},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(oi)},null,8,["icon"]),N[4]||(N[4]=e.createTextVNode(" Hold to compare ",-1))],32)]),m.value?(e.openBlock(),e.createElementBlock("div",Zw,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,C=>(e.openBlock(),e.createElementBlock("button",{key:C.name,class:e.normalizeClass(["preset-button",{active:V(C)}]),onClick:T=>$(C)},e.toDisplayString(C.name),11,Gw))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",Xw,[e.createElementVNode("button",{class:"action-button",onClick:b},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(eo)},null,8,["icon"]),N[5]||(N[5]=e.createTextVNode(" Reset ",-1))]),e.createElementVNode("button",{class:"action-button primary",onClick:I},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Hu)},null,8,["icon"]),N[6]||(N[6]=e.createTextVNode(" Apply Filter ",-1))])])])}}}),Nl=Fe(Kw,[["__scopeId","data-v-3de3dd04"]]),Bm={id:"mobile-share",label:"Mobile share",description:"Fast H.264 MP4 export for short social clips and mobile uploads.",settings:{format:"mp4",codec:"h264",quality:"720p",fps:30,bitrate:45e5,routePreference:"client",maxClientDurationSeconds:90,mobileSuitable:!0,advancedVisibility:"standard"}},Im={id:"hd-web",label:"HD web",description:"Balanced 1080p H.264 MP4 export for web playback.",settings:{format:"mp4",codec:"h264",quality:"1080p",fps:30,bitrate:8e6,routePreference:"auto",maxClientDurationSeconds:180,mobileSuitable:!0,advancedVisibility:"standard"}},Mm={id:"original",label:"Original",description:"Server-rendered MP4 export that preserves the editor output quality target.",settings:{format:"mp4",codec:"h264",quality:"1080p",fps:30,routePreference:"server",maxClientDurationSeconds:null,mobileSuitable:!1,advancedVisibility:"standard"}},Fm={id:"server-master",label:"Server master",description:"High-bitrate master render for archival and downstream transcodes.",settings:{format:"mov",codec:"h265",quality:"2160p",fps:60,bitrate:32e6,routePreference:"server",maxClientDurationSeconds:null,mobileSuitable:!1,advancedVisibility:"advanced"}},$m=[Bm,Im,Mm,Fm],vd={"mobile-share":Bm,"hd-web":Im,original:Mm,"server-master":Fm},Jw=["mobile-share","hd-web"],qw=["hd-web","original","mobile-share"],Yw=["server-master","hd-web","original","mobile-share"];function cs(o){return typeof o=="string"?vd[o]:o}function Qw(o){const{bitrate:a,codec:t,format:n,fps:i,quality:r}=cs(o).settings,s={format:n,codec:t,quality:r,fps:i};return typeof a=="number"&&(s.bitrate=a),s}function ek(o){const a=cs(o);return a.settings.mobileSuitable&&a.settings.advancedVisibility==="standard"}function tk(o=$m){return o.filter(a=>ek(a))}function ak(o,a){const t=cs(o).settings.maxClientDurationSeconds;return t!==null&&Number.isFinite(a)&&a>=0&&a<=t}function nk(o,a){const t=cs(o),n=a.endpoints.client&&ak(t,a.durationSeconds),i=a.endpoints.server;return t.settings.routePreference==="client"?n?"client":i?"server":null:t.settings.routePreference==="server"?i?"server":n?"client":null:n?"client":i?"server":null}function ok(o,a){return nk(o,a)!==null}function ik(o){const a=rk(o);for(const t of a){const n=vd[t];if(sk(n,o.includeAdvanced===!0)&&!(o.device==="mobile"&&!n.settings.mobileSuitable)&&ok(n,o))return n}return null}function rk(o){return o.device==="mobile"?Jw:o.includeAdvanced===!0?Yw:qw}function sk(o,a){return o.settings.advancedVisibility==="hidden"?!1:o.settings.advancedVisibility==="standard"||a}const lk={class:"export-settings"},dk={class:"setting-group preset-setting"},ck={class:"setting-copy"},uk={class:"setting-description"},mk=["value"],pk={key:0,class:"advanced-toggle","data-testid":"export-advanced-toggle"},fk={class:"preset-summary","data-testid":"export-preset-summary"},hk={class:"estimated-size"},vk={key:0,class:"export-progress"},gk={class:"progress-header"},bk={class:"progress-percentage"},yk={class:"progress-time"},wk={class:"action-buttons"},kk=["disabled"],_k=["disabled"],Ek=["disabled"],xk={class:"export-options"},Sk="hd-web",Ck=e.defineComponent({__name:"EditorControls",props:{canExport:{type:Boolean,default:!1},isExporting:{type:Boolean,default:!1},exportProgress:{default:0},isMobile:{type:Boolean,default:!1},duration:{default:0}},emits:["export","save-draft","reset","cancel-export"],setup(o,{emit:a}){const t=o,n=a,i={client:!0,server:!0},r=$m,s={"360p":1,"480p":2.5,"720p":5,"1080p":8,"1440p":16,"2160p":35},l=e.ref(!1),d=e.ref(b()),c=e.ref(!0),u=e.ref(!1),f=e.ref(0),m=e.ref(0),p=e.ref(0);let h=null;const v=e.computed(()=>t.isMobile?tk():r.filter(C=>C.settings.advancedVisibility==="hidden"?!1:C.settings.advancedVisibility==="standard"||l.value)),w=e.computed(()=>v.value.find(C=>C.id===d.value)??vd[b()]),E=e.computed(()=>Qw(w.value)),S=e.computed(()=>{const C=E.value,T=[C.quality,C.format.toUpperCase(),C.codec.toUpperCase(),`${C.fps} fps`],y=$(C.bitrate);return y!==null&&T.push(y),T.join(" / ")}),k=e.computed(()=>{const C=E.value,y=(typeof C.bitrate=="number"?C.bitrate/1e6:s[C.quality])*t.duration/8;return y<1e3?`~${Math.round(y)} MB`:`~${(y/1e3).toFixed(1)} GB`});function b(){var C;return((C=ik({durationSeconds:t.duration,device:t.isMobile?"mobile":"desktop",endpoints:i,includeAdvanced:l.value}))==null?void 0:C.id)??Sk}function $(C){return typeof C!="number"?null:`${Number((C/1e6).toFixed(1))} Mbps`}function V(){t.isExporting?(n("cancel-export"),N()):I()}function I(){const C=E.value,T={quality:C.quality,format:C.format,optimizeForWeb:c.value,includeWatermark:u.value,presetId:w.value.id,codec:C.codec,fps:C.fps};typeof C.bitrate=="number"&&(T.bitrate=C.bitrate),n("export",T),x()}function x(){f.value=Date.now(),m.value=0,h=window.setInterval(()=>{if(m.value=Math.floor((Date.now()-f.value)/1e3),t.exportProgress>0){const C=m.value/t.exportProgress*100;p.value=Math.max(0,C-m.value)}},1e3)}function N(){h&&(clearInterval(h),h=null)}function L(C){const T=Math.floor(C/60),y=Math.floor(C%60);return`${T}:${y.toString().padStart(2,"0")}`}return e.watch([()=>t.isMobile,()=>l.value],()=>{v.value.some(T=>T.id===d.value)||(d.value=b())},{immediate:!0}),e.watch(()=>t.isExporting,C=>{C||N()}),e.onUnmounted(()=>{N()}),(C,T)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["editor-controls",{mobile:C.isMobile}])},[e.createElementVNode("div",lk,[T[8]||(T[8]=e.createElementVNode("h3",{class:"section-title"},"Export Settings",-1)),e.createElementVNode("div",dk,[e.createElementVNode("div",ck,[T[6]||(T[6]=e.createElementVNode("label",{for:"export-preset-select"},"Preset",-1)),e.createElementVNode("span",uk,e.toDisplayString(w.value.description),1)]),e.withDirectives(e.createElementVNode("select",{id:"export-preset-select","onUpdate:modelValue":T[0]||(T[0]=y=>d.value=y),class:"setting-select preset-select","data-testid":"export-preset-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,y=>(e.openBlock(),e.createElementBlock("option",{key:y.id,value:y.id},e.toDisplayString(y.label),9,mk))),128))],512),[[e.vModelSelect,d.value]])]),C.isMobile?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("label",pk,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":T[1]||(T[1]=y=>l.value=y),type:"checkbox","data-testid":"export-advanced-toggle-input"},null,512),[[e.vModelCheckbox,l.value]]),T[7]||(T[7]=e.createElementVNode("span",null,"Advanced presets",-1))])),e.createElementVNode("div",fk,e.toDisplayString(S.value),1),e.createElementVNode("div",hk,[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Wh)},null,8,["icon"]),e.createElementVNode("span",null,"Estimated size: "+e.toDisplayString(k.value),1)])]),C.isExporting?(e.openBlock(),e.createElementBlock("div",vk,[e.createElementVNode("div",gk,[T[9]||(T[9]=e.createElementVNode("span",null,"Exporting...",-1)),e.createElementVNode("span",bk,e.toDisplayString(C.exportProgress??0)+"%",1)]),e.createVNode(e.unref(H.IonProgressBar),{value:(C.exportProgress??0)/100},null,8,["value"]),e.createElementVNode("div",yk,[e.createElementVNode("span",null,e.toDisplayString(L(m.value))+" elapsed",1),e.createElementVNode("span",null,e.toDisplayString(L(p.value))+" remaining",1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",wk,[e.createElementVNode("button",{class:"control-button secondary",onClick:T[2]||(T[2]=y=>C.$emit("save-draft")),disabled:!C.canExport||C.isExporting},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Kr)},null,8,["icon"]),T[10]||(T[10]=e.createTextVNode(" Save Draft ",-1))],8,kk),e.createElementVNode("button",{class:"control-button secondary",onClick:T[3]||(T[3]=y=>C.$emit("reset")),disabled:C.isExporting},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(eo)},null,8,["icon"]),T[11]||(T[11]=e.createTextVNode(" Reset ",-1))],8,_k),e.createElementVNode("button",{class:"control-button primary",onClick:V,disabled:!C.canExport&&!C.isExporting,"data-testid":"video-export-button"},[e.createVNode(e.unref(H.IonIcon),{icon:C.isExporting?e.unref(Gn):e.unref(Co)},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(C.isExporting?"Cancel":"Export Video"),1)],8,Ek)]),e.createElementVNode("div",xk,[e.createVNode(e.unref(H.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonCheckbox),{modelValue:c.value,"onUpdate:modelValue":T[4]||(T[4]=y=>c.value=y)},null,8,["modelValue"]),e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...T[12]||(T[12]=[e.createTextVNode("Optimize for web streaming",-1)])]),_:1})]),_:1}),e.createVNode(e.unref(H.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonCheckbox),{modelValue:u.value,"onUpdate:modelValue":T[5]||(T[5]=y=>u.value=y)},null,8,["modelValue"]),e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...T[13]||(T[13]=[e.createTextVNode("Include watermark",-1)])]),_:1})]),_:1})])],2))}}),Tl=Fe(Ck,[["__scopeId","data-v-d26ca1bc"]]),Vk={class:"thumbnail-picker"},Nk={class:"thumbnail-grid"},Tk=["onClick"],Bk=["src","alt"],Ik={key:1,class:"thumbnail-placeholder"},Mk={class:"thumbnail-time"},Fk={class:"custom-selector"},$k={class:"time-input-group"},Dk=["max"],Rk={class:"time-value"},Ak=["disabled"],Lk={class:"picker-actions"},Pk=["disabled"],Uk=e.defineComponent({__name:"ThumbnailPicker",props:{mediaUuid:{},duration:{},currentTime:{default:0}},emits:["select","cancel"],setup(o,{emit:a}){const t=o,n=a,i=e.ref([]),r=e.ref(-1),s=e.ref(t.currentTime),l=e.ref(!1);function d(){const E=[];if(t.duration<=10)for(let k=0;k<Math.min(9,t.duration);k++)E.push(k);else{const k=t.duration/10;for(let b=1;b<=9;b++)E.push(k*b)}return E}async function c(E){try{const S=document.createElement("video");return S.crossOrigin="anonymous",S.src=await u(),new Promise(k=>{S.addEventListener("loadedmetadata",()=>{S.currentTime=E}),S.addEventListener("seeked",()=>{const b=document.createElement("canvas");b.width=S.videoWidth,b.height=S.videoHeight;const $=b.getContext("2d");$?($.drawImage(S,0,0),k(b.toDataURL("image/jpeg",.8))):k(null),S.remove()}),S.addEventListener("error",()=>{k(null),S.remove()})})}catch{return null}}async function u(){try{return(await(await fetch(`/api/media/${t.mediaUuid}/playback`)).json()).playback_url}catch{return`/media/${t.mediaUuid}/video`}}async function f(){const E=d();i.value=E.map(k=>({time:k,loading:!0}));const S=3;for(let k=0;k<i.value.length;k+=S){const b=i.value.slice(k,k+S);await Promise.all(b.map(async $=>{const V=await c($.time);V&&($.dataUrl=V),$.loading=!1}))}}function m(E){r.value=E,s.value=i.value[E].time}function p(){r.value=-1}async function h(){l.value=!0;try{const E=await c(s.value);if(E){const S=i.value.findIndex(k=>Math.abs(k.time-s.value)<.1);S>=0?(i.value[S].dataUrl=E,r.value=S):(i.value.push({time:s.value,dataUrl:E}),r.value=i.value.length-1,i.value.sort((k,b)=>k.time-b.time),r.value=i.value.findIndex(k=>k.time===s.value))}}finally{l.value=!1}}function v(){const E=r.value>=0?i.value[r.value].time:s.value;n("select",E)}function w(E){const S=Math.floor(E/60),k=Math.floor(E%60),b=Math.floor(E%1*100);return S>0?`${S}:${k.toString().padStart(2,"0")}.${b.toString().padStart(2,"0")}`:`${k}.${b.toString().padStart(2,"0")}s`}return e.onMounted(()=>{f()}),(E,S)=>(e.openBlock(),e.createElementBlock("div",Vk,[S[5]||(S[5]=e.createElementVNode("h4",{class:"picker-title"},"Select Video Thumbnail",-1)),e.createElementVNode("div",Nk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(k,b)=>(e.openBlock(),e.createElementBlock("div",{key:b,class:e.normalizeClass(["thumbnail-item",{selected:r.value===b}]),onClick:$=>m(b)},[k.dataUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:k.dataUrl,alt:`Frame at ${w(k.time)}`},null,8,Bk)):(e.openBlock(),e.createElementBlock("div",Ik,[e.createVNode(e.unref(H.IonSpinner),{name:"crescent"})])),e.createElementVNode("div",Mk,e.toDisplayString(w(k.time)),1)],10,Tk))),128))]),e.createElementVNode("div",Fk,[S[3]||(S[3]=e.createElementVNode("label",null,"Custom time:",-1)),e.createElementVNode("div",$k,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":S[0]||(S[0]=k=>s.value=k),min:0,max:E.duration,step:.1,onInput:p,class:"time-slider"},null,40,Dk),[[e.vModelText,s.value]]),e.createElementVNode("span",Rk,e.toDisplayString(w(s.value)),1)]),e.createElementVNode("button",{class:"capture-button",onClick:h,disabled:l.value},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Mh)},null,8,["icon"]),S[2]||(S[2]=e.createTextVNode(" Capture Frame ",-1))],8,Ak)]),e.createElementVNode("div",Lk,[e.createElementVNode("button",{class:"action-button",onClick:S[1]||(S[1]=k=>E.$emit("cancel"))}," Cancel "),e.createElementVNode("button",{class:"action-button primary",onClick:v,disabled:r.value===-1},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Hu)},null,8,["icon"]),S[4]||(S[4]=e.createTextVNode(" Set Thumbnail ",-1))],8,Pk)])]))}}),Ok=Fe(Uk,[["__scopeId","data-v-336c322c"]]),zk={class:"text-overlay-panel p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},jk={class:"mb-4"},Wk={class:"space-y-2 max-h-64 overflow-y-auto"},Hk={class:"flex items-center justify-between"},Zk={class:"flex-1"},Gk={class:"font-medium text-gray-900 dark:text-white"},Xk={class:"text-sm text-gray-500 dark:text-gray-400"},Kk={class:"flex items-center space-x-2"},Jk=["onClick"],qk=["onClick"],Yk={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},Qk={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},e_={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},t_={class:"space-y-4"},a_={class:"grid grid-cols-2 gap-4"},n_={class:"grid grid-cols-2 gap-4"},o_={key:0,class:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},i_={class:"grid grid-cols-2 gap-3"},r_={class:"flex justify-end space-x-3 mt-6"},s_=e.defineComponent({__name:"TextOverlayPanel",props:{overlays:{}},emits:["add-overlay","update-overlay","remove-overlay"],setup(o,{emit:a}){const t=a,n=e.ref(!1),i=e.ref(null),r=()=>({id:"",text:"",fontSize:24,color:"#ffffff",position:"center",startTime:0,duration:5,animationType:"",animationDuration:1,animationEasing:"linear"}),s=e.reactive(r());function l(m){Object.assign(s,m),i.value=m}function d(){n.value=!1,i.value=null,Object.assign(s,r())}function c(){const m={text:s.text,fontSize:s.fontSize,color:s.color,position:s.position,startTime:s.startTime,duration:s.duration};if(s.animationType&&(m.animation={type:s.animationType},s.animationDuration!==void 0&&(m.animation.duration=s.animationDuration),s.animationEasing&&(m.animation.easing=s.animationEasing),m.animation))switch(s.animationType){case"rotate":m.animation.rotation={from:0,to:360};break;case"scale":m.animation.scale={from:.5,to:1};break;case"slide":m.animation.translate={fromX:-100,toX:0,fromY:0,toY:0};break}i.value?t("update-overlay",i.value.id,m):t("add-overlay",m),d()}function u(m){confirm("Are you sure you want to remove this text overlay?")&&t("remove-overlay",m)}function f(m){const p=Math.floor(m/60),h=Math.floor(m%60);return`${p}:${h.toString().padStart(2,"0")}`}return(m,p)=>(e.openBlock(),e.createElementBlock("div",zk,[e.createElementVNode("div",jk,[p[11]||(p[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Text Overlays ",-1)),e.createElementVNode("button",{onClick:p[0]||(p[0]=h=>n.value=!0),class:"w-full px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"},[...p[10]||(p[10]=[e.createElementVNode("svg",{class:"w-5 h-5 inline-block mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),e.createTextVNode(" Add Text Overlay ",-1)])])]),e.createElementVNode("div",Wk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.overlays,h=>(e.openBlock(),e.createElementBlock("div",{key:h.id,class:"p-3 border border-gray-200 dark:border-gray-700 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors"},[e.createElementVNode("div",Hk,[e.createElementVNode("div",Zk,[e.createElementVNode("div",Gk,e.toDisplayString(h.text.substring(0,30))+e.toDisplayString(h.text.length>30?"...":""),1),e.createElementVNode("div",Xk,e.toDisplayString(f(h.startTime??0))+" - "+e.toDisplayString(f((h.startTime||0)+(h.duration||5))),1)]),e.createElementVNode("div",Kk,[e.createElementVNode("button",{onClick:v=>l(h),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Edit"},[...p[12]||(p[12]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})],-1)])],8,Jk),e.createElementVNode("button",{onClick:v=>u(h.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...p[13]||(p[13]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])],8,qk)])])]))),128)),m.overlays.length===0?(e.openBlock(),e.createElementBlock("div",Yk," No text overlays added yet ")):e.createCommentVNode("",!0)]),n.value||i.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",onClick:e.withModifiers(d,["self"])},[e.createElementVNode("div",Qk,[e.createElementVNode("h4",e_,e.toDisplayString(i.value?"Edit":"Add")+" Text Overlay ",1),e.createElementVNode("div",t_,[e.createElementVNode("div",null,[p[14]||(p[14]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Text ",-1)),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":p[1]||(p[1]=h=>s.text=h),rows:"3",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"Enter your text..."},null,512),[[e.vModelText,s.text]])]),e.createElementVNode("div",a_,[e.createElementVNode("div",null,[p[15]||(p[15]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Font Size ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[2]||(p[2]=h=>s.fontSize=h),type:"number",min:"10",max:"200",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.fontSize,void 0,{number:!0}]])]),e.createElementVNode("div",null,[p[16]||(p[16]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Color ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[3]||(p[3]=h=>s.color=h),type:"color",class:"w-full h-10 border border-gray-300 dark:border-gray-600 rounded-lg cursor-pointer"},null,512),[[e.vModelText,s.color]])])]),e.createElementVNode("div",null,[p[18]||(p[18]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Position ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":p[4]||(p[4]=h=>s.position=h),class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},[...p[17]||(p[17]=[e.createStaticVNode('<option value="center" data-v-f86e688c>Center</option><option value="top" data-v-f86e688c>Top</option><option value="bottom" data-v-f86e688c>Bottom</option><option value="left" data-v-f86e688c>Left</option><option value="right" data-v-f86e688c>Right</option>',5)])],512),[[e.vModelSelect,s.position]])]),e.createElementVNode("div",n_,[e.createElementVNode("div",null,[p[19]||(p[19]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Start Time (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[5]||(p[5]=h=>s.startTime=h),type:"number",min:"0",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.startTime,void 0,{number:!0}]])]),e.createElementVNode("div",null,[p[20]||(p[20]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Duration (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[6]||(p[6]=h=>s.duration=h),type:"number",min:"0.1",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.duration,void 0,{number:!0}]])])]),e.createElementVNode("div",null,[p[22]||(p[22]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Animation ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":p[7]||(p[7]=h=>s.animationType=h),class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},[...p[21]||(p[21]=[e.createStaticVNode('<option value="" data-v-f86e688c>None</option><option value="fade-in" data-v-f86e688c>Fade In</option><option value="fade-out" data-v-f86e688c>Fade Out</option><option value="slide" data-v-f86e688c>Slide</option><option value="scale" data-v-f86e688c>Scale</option><option value="rotate" data-v-f86e688c>Rotate</option><option value="typewriter" data-v-f86e688c>Typewriter</option>',7)])],512),[[e.vModelSelect,s.animationType]])]),s.animationType?(e.openBlock(),e.createElementBlock("div",o_,[p[26]||(p[26]=e.createElementVNode("div",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Animation Settings ",-1)),e.createElementVNode("div",i_,[e.createElementVNode("div",null,[p[23]||(p[23]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Duration (s) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[8]||(p[8]=h=>s.animationDuration=h),type:"number",min:"0.1",step:"0.1",class:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},null,512),[[e.vModelText,s.animationDuration,void 0,{number:!0}]])]),e.createElementVNode("div",null,[p[25]||(p[25]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Easing ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":p[9]||(p[9]=h=>s.animationEasing=h),class:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},[...p[24]||(p[24]=[e.createElementVNode("option",{value:"linear"},"Linear",-1),e.createElementVNode("option",{value:"easeIn"},"Ease In",-1),e.createElementVNode("option",{value:"easeOut"},"Ease Out",-1),e.createElementVNode("option",{value:"easeInOut"},"Ease In Out",-1)])],512),[[e.vModelSelect,s.animationEasing]])])])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",r_,[e.createElementVNode("button",{onClick:d,class:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"}," Cancel "),e.createElementVNode("button",{onClick:c,class:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"},e.toDisplayString(i.value?"Save":"Add"),1)])])])):e.createCommentVNode("",!0)]))}}),Bl=Fe(s_,[["__scopeId","data-v-f86e688c"]]),l_={class:"transition-selector p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},d_={class:"grid grid-cols-3 gap-3 max-h-96 overflow-y-auto"},c_=["onClick"],u_={class:"w-full h-16 bg-gradient-to-r from-gray-300 to-gray-400 dark:from-gray-600 dark:to-gray-700 rounded mb-2 flex items-center justify-center"},m_={key:0,class:"w-8 h-8 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},p_={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},f_={key:1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14 5l7 7m0 0l-7 7m7-7H3"},h_={key:2,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"},v_={key:3,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"},g_={key:4,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 5a1 1 0 011-1h14a1 1 0 011 1v14a1 1 0 01-1 1H5a1 1 0 01-1-1V5z"},b_={class:"text-sm font-medium text-gray-900 dark:text-white text-center"},y_={key:0,class:"mt-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},w_={class:"space-y-3"},k_={class:"flex items-center space-x-2"},__=["disabled"],E_=["disabled"],x_={key:1,class:"mt-4"},S_={class:"space-y-2 max-h-32 overflow-y-auto"},C_={class:"text-sm text-gray-700 dark:text-gray-300"},V_=["onClick"],N_=e.defineComponent({__name:"TransitionSelector",props:{selectedClips:{},appliedTransitions:{}},emits:["apply-transition","remove-transition","preview-transition"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(Ei.getAvailableTransitions()),r=e.ref(null),s=e.ref(.5),l=e.ref("linear"),d=e.computed(()=>r.value&&t.selectedClips&&t.selectedClips.length>=2);function c(h){r.value=h}function u(){if(!r.value||!d.value)return;const h={type:r.value.type,duration:s.value,easing:l.value};n("apply-transition",h),r.value=null}function f(){if(!r.value)return;const h={type:r.value.type,duration:s.value,easing:l.value};n("preview-transition",h)}function m(h){n("remove-transition",h)}function p(h){return["fade","wipe","slide","zoom"].some(v=>h.includes(v))}return(h,v)=>(e.openBlock(),e.createElementBlock("div",l_,[v[9]||(v[9]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"}," Transitions ",-1)),e.createElementVNode("div",d_,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,w=>{var E;return e.openBlock(),e.createElementBlock("div",{key:w.type,onClick:S=>c(w),class:e.normalizeClass(["transition-item cursor-pointer rounded-lg p-3 border-2 transition-all",((E=r.value)==null?void 0:E.type)===w.type?"border-blue-500 bg-blue-50 dark:bg-blue-900":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"])},[e.createElementVNode("div",u_,[p(w.type)?(e.openBlock(),e.createElementBlock("svg",m_,[w.type.includes("fade")?(e.openBlock(),e.createElementBlock("path",p_)):w.type.includes("wipe")?(e.openBlock(),e.createElementBlock("path",f_)):w.type.includes("slide")?(e.openBlock(),e.createElementBlock("path",h_)):w.type.includes("zoom")?(e.openBlock(),e.createElementBlock("path",v_)):(e.openBlock(),e.createElementBlock("path",g_))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",b_,e.toDisplayString(w.name),1)],10,c_)}),128))]),r.value?(e.openBlock(),e.createElementBlock("div",y_,[v[6]||(v[6]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3"}," Transition Settings ",-1)),e.createElementVNode("div",w_,[e.createElementVNode("div",null,[v[3]||(v[3]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Duration (seconds) ",-1)),e.createElementVNode("div",k_,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":v[0]||(v[0]=w=>s.value=w),type:"range",min:"0.1",max:"3",step:"0.1",class:"flex-1"},null,512),[[e.vModelText,s.value,void 0,{number:!0}]]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":v[1]||(v[1]=w=>s.value=w),type:"number",min:"0.1",max:"3",step:"0.1",class:"w-16 px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},null,512),[[e.vModelText,s.value,void 0,{number:!0}]])])]),e.createElementVNode("div",null,[v[5]||(v[5]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Easing ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":v[2]||(v[2]=w=>l.value=w),class:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},[...v[4]||(v[4]=[e.createElementVNode("option",{value:"linear"},"Linear",-1),e.createElementVNode("option",{value:"easeIn"},"Ease In",-1),e.createElementVNode("option",{value:"easeOut"},"Ease Out",-1),e.createElementVNode("option",{value:"easeInOut"},"Ease In Out",-1)])],512),[[e.vModelSelect,l.value]])]),e.createElementVNode("button",{onClick:u,disabled:!d.value,class:e.normalizeClass(["w-full px-3 py-2 rounded-lg font-medium transition-colors",d.value?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed"])}," Apply Transition ",10,__),e.createElementVNode("button",{onClick:f,disabled:!r.value,class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors"}," Preview ",8,E_)])])):e.createCommentVNode("",!0),h.appliedTransitions.length>0?(e.openBlock(),e.createElementBlock("div",x_,[v[8]||(v[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Applied Transitions ",-1)),e.createElementVNode("div",S_,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.appliedTransitions,(w,E)=>(e.openBlock(),e.createElementBlock("div",{key:E,class:"flex items-center justify-between p-2 bg-gray-50 dark:bg-gray-700 rounded"},[e.createElementVNode("div",C_,e.toDisplayString(w.name)+" ("+e.toDisplayString(w.duration)+"s) ",1),e.createElementVNode("button",{onClick:S=>m(E),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded"},[...v[7]||(v[7]=[e.createElementVNode("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,V_)]))),128))])])):e.createCommentVNode("",!0),v[10]||(v[10]=e.createElementVNode("div",{class:"mt-4 text-xs text-gray-500 dark:text-gray-400"},[e.createElementVNode("p",null,"Select clips in the timeline, then choose a transition to apply between them.")],-1))]))}}),Il=Fe(N_,[["__scopeId","data-v-ffcc612d"]]),T_={class:"audio-track-manager p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},B_={class:"mb-4"},I_={class:"mb-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},M_={class:"flex items-center justify-between mb-2"},F_={class:"text-sm text-gray-600 dark:text-gray-400"},$_={class:"flex items-center space-x-2"},D_={class:"space-y-3 max-h-64 overflow-y-auto"},R_={class:"flex items-center justify-between mb-2"},A_={class:"font-medium text-gray-900 dark:text-white"},L_={class:"flex items-center space-x-2"},P_=["onClick","title"],U_={key:0,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},O_={key:1,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},z_=["onClick"],j_=["onClick"],W_={class:"flex items-center space-x-2"},H_={class:"text-xs text-gray-500 dark:text-gray-400 w-10"},Z_=["value","onInput","disabled"],G_={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},X_={key:0,class:"ml-2"},K_={key:1,class:"ml-2"},J_={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},q_={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},Y_={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},Q_={class:"space-y-4"},e2={class:"space-y-2"},t2={class:"flex items-center"},a2={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},n2={class:"grid grid-cols-2 gap-4"},o2={class:"grid grid-cols-2 gap-4"},i2={class:"flex items-center"},r2={class:"flex justify-end space-x-3 mt-6"},s2=["disabled"],l2=e.defineComponent({__name:"AudioTrackManager",props:{audioLayers:{},masterVolume:{}},emits:["add-track","update-track","remove-track","update-volume","toggle-mute","update-master-volume"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(!1),r=e.ref(null),s=e.ref(t.masterVolume),l=()=>({id:"",source:"",sourceUrl:"",name:"Background Music",volume:.7,startTime:0,fadeIn:0,fadeOut:0,loop:!1}),d=e.reactive(l()),c=e.computed(()=>d.sourceUrl||d.sourceFile);function u(k){const b=k.target;b.files&&b.files[0]&&(d.sourceFile=b.files[0],d.name=d.name||b.files[0].name.replace(/\.[^/.]+$/,""))}function f(k){Object.assign(d,k),r.value=k}function m(){i.value=!1,r.value=null,Object.assign(d,l())}function p(){if(!c.value)return;const k={source:d.sourceFile??d.sourceUrl??"",name:d.name,volume:d.volume,startTime:d.startTime,loop:d.loop};d.duration!==void 0&&(k.duration=d.duration),d.fadeIn>0&&(k.fadeIn=d.fadeIn),d.fadeOut>0&&(k.fadeOut=d.fadeOut),r.value?n("update-track",r.value.id,k):n("add-track",k),m()}function h(k){confirm("Are you sure you want to remove this audio track?")&&n("remove-track",k)}function v(k,b){const $=b.target,V=parseFloat($.value);n("update-volume",k.id,V)}function w(k){n("toggle-mute",k.id,!k.muted)}function E(){n("update-master-volume",s.value)}function S(k){const b=Math.floor(k/60),$=Math.floor(k%60);return`${b}:${$.toString().padStart(2,"0")}`}return(k,b)=>(e.openBlock(),e.createElementBlock("div",T_,[e.createElementVNode("div",B_,[b[11]||(b[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Audio Tracks ",-1)),e.createElementVNode("button",{onClick:b[0]||(b[0]=$=>i.value=!0),class:"w-full px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors"},[...b[10]||(b[10]=[e.createElementVNode("svg",{class:"w-5 h-5 inline-block mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),e.createTextVNode(" Add Audio Track ",-1)])])]),e.createElementVNode("div",I_,[e.createElementVNode("div",M_,[b[12]||(b[12]=e.createElementVNode("label",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"}," Master Volume ",-1)),e.createElementVNode("span",F_,e.toDisplayString(Math.round(s.value*100))+"% ",1)]),e.createElementVNode("div",$_,[b[13]||(b[13]=e.createElementVNode("svg",{class:"w-4 h-4 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20"},[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM12.293 7.293a1 1 0 011.414 0L15 8.586l1.293-1.293a1 1 0 111.414 1.414L16.414 10l1.293 1.293a1 1 0 01-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 01-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[1]||(b[1]=$=>s.value=$),onInput:E,type:"range",min:"0",max:"1",step:"0.01",class:"flex-1"},null,544),[[e.vModelText,s.value,void 0,{number:!0}]]),b[14]||(b[14]=e.createElementVNode("svg",{class:"w-4 h-4 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20"},[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM14.657 2.929a1 1 0 011.414 0l3 3a1 1 0 010 1.414l-3 3a1 1 0 01-1.414-1.414L16.586 7l-1.929-1.929a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1))])]),e.createElementVNode("div",D_,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.audioLayers,$=>(e.openBlock(),e.createElementBlock("div",{key:$.id,class:"p-3 border border-gray-200 dark:border-gray-700 rounded-lg"},[e.createElementVNode("div",R_,[e.createElementVNode("div",A_,e.toDisplayString($.name),1),e.createElementVNode("div",L_,[e.createElementVNode("button",{onClick:V=>w($),class:e.normalizeClass(["p-1 rounded",$.muted?"text-red-600 bg-red-50 dark:bg-red-900":"text-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700"]),title:$.muted?"Unmute":"Mute"},[$.muted?(e.openBlock(),e.createElementBlock("svg",O_,[...b[16]||(b[16]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM12.293 7.293a1 1 0 011.414 0L15 8.586l1.293-1.293a1 1 0 111.414 1.414L16.414 10l1.293 1.293a1 1 0 01-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 01-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",U_,[...b[15]||(b[15]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM14.657 2.929a1 1 0 011.414 0l3 3a1 1 0 010 1.414l-3 3a1 1 0 01-1.414-1.414L16.586 7l-1.929-1.929a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)])]))],10,P_),e.createElementVNode("button",{onClick:V=>f($),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Settings"},[...b[17]||(b[17]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})],-1)])],8,z_),e.createElementVNode("button",{onClick:V=>h($.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...b[18]||(b[18]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])],8,j_)])]),e.createElementVNode("div",W_,[e.createElementVNode("span",H_,e.toDisplayString(Math.round(($.volume||1)*100))+"% ",1),e.createElementVNode("input",{value:$.volume||1,onInput:V=>v($,V),type:"range",min:"0",max:"1",step:"0.01",class:"flex-1",disabled:$.muted},null,40,Z_)]),e.createElementVNode("div",G_,[e.createTextVNode(e.toDisplayString(S($.startTime||0))+" - "+e.toDisplayString(S(($.startTime||0)+($.duration||0)))+" ",1),$.fadeIn?(e.openBlock(),e.createElementBlock("span",X_,"Fade In: "+e.toDisplayString($.fadeIn)+"s",1)):e.createCommentVNode("",!0),$.fadeOut?(e.openBlock(),e.createElementBlock("span",K_,"Fade Out: "+e.toDisplayString($.fadeOut)+"s",1)):e.createCommentVNode("",!0)])]))),128)),k.audioLayers.length===0?(e.openBlock(),e.createElementBlock("div",J_," No audio tracks added yet ")):e.createCommentVNode("",!0)]),i.value||r.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",onClick:e.withModifiers(m,["self"])},[e.createElementVNode("div",q_,[e.createElementVNode("h4",Y_,e.toDisplayString(r.value?"Edit":"Add")+" Audio Track ",1),e.createElementVNode("div",Q_,[e.createElementVNode("div",null,[b[20]||(b[20]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Audio Source ",-1)),e.createElementVNode("div",e2,[e.createElementVNode("input",{type:"file",accept:"audio/*",onChange:u,class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,32),e.createElementVNode("div",t2,[b[19]||(b[19]=e.createElementVNode("span",{class:"text-sm text-gray-500 dark:text-gray-400 mr-2"},"or URL:",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[2]||(b[2]=$=>d.sourceUrl=$),type:"url",placeholder:"https://example.com/audio.mp3",class:"flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,d.sourceUrl]])])])]),e.createElementVNode("div",null,[b[21]||(b[21]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Track Name ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[3]||(b[3]=$=>d.name=$),type:"text",placeholder:"Background Music",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,d.name]])]),e.createElementVNode("div",null,[e.createElementVNode("label",a2," Volume: "+e.toDisplayString(Math.round(d.volume*100))+"% ",1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[4]||(b[4]=$=>d.volume=$),type:"range",min:"0",max:"1",step:"0.01",class:"w-full"},null,512),[[e.vModelText,d.volume,void 0,{number:!0}]])]),e.createElementVNode("div",n2,[e.createElementVNode("div",null,[b[22]||(b[22]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Start Time (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[5]||(b[5]=$=>d.startTime=$),type:"number",min:"0",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,d.startTime,void 0,{number:!0}]])]),e.createElementVNode("div",null,[b[23]||(b[23]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Duration (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[6]||(b[6]=$=>d.duration=$),type:"number",min:"0.1",step:"0.1",placeholder:"Auto",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,d.duration,void 0,{number:!0}]])])]),e.createElementVNode("div",o2,[e.createElementVNode("div",null,[b[24]||(b[24]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Fade In (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[7]||(b[7]=$=>d.fadeIn=$),type:"number",min:"0",max:"10",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,d.fadeIn,void 0,{number:!0}]])]),e.createElementVNode("div",null,[b[25]||(b[25]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Fade Out (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[8]||(b[8]=$=>d.fadeOut=$),type:"number",min:"0",max:"10",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,d.fadeOut,void 0,{number:!0}]])])]),e.createElementVNode("div",i2,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[9]||(b[9]=$=>d.loop=$),type:"checkbox",id:"loop-checkbox",class:"mr-2 rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"},null,512),[[e.vModelCheckbox,d.loop]]),b[26]||(b[26]=e.createElementVNode("label",{for:"loop-checkbox",class:"text-sm text-gray-700 dark:text-gray-300"}," Loop audio track ",-1))])]),e.createElementVNode("div",r2,[e.createElementVNode("button",{onClick:m,class:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"}," Cancel "),e.createElementVNode("button",{onClick:p,disabled:!c.value,class:e.normalizeClass(["px-4 py-2 rounded-lg transition-colors",c.value?"bg-green-600 text-white hover:bg-green-700":"bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed"])},e.toDisplayString(r.value?"Save":"Add"),11,s2)])])])):e.createCommentVNode("",!0)]))}}),Ml=Fe(l2,[["__scopeId","data-v-593719ac"]]);function st(o,a={},...t){const n=document.createElement(o);for(const[i,r]of Object.entries(a))r!=null&&(i==="className"?n.className=r:i==="style"&&typeof r=="object"?Object.assign(n.style,r):i.startsWith("on")&&typeof r=="function"?n.addEventListener(i.slice(2).toLowerCase(),r):i==="dataset"&&typeof r=="object"?Object.assign(n.dataset,r):n.setAttribute(i,r));for(const i of t)typeof i=="string"?n.appendChild(document.createTextNode(i)):i instanceof HTMLElement&&n.appendChild(i);return n}function Bc(o){return typeof o=="boolean"?o?"On":"Off":typeof o=="number"?Number.isInteger(o)?String(o):o.toFixed(2):String(o??"")}let Ic=!1;function d2(){if(Ic)return;Ic=!0;const o=`
|
|
34
|
-
/* ── MobileVideoFilterPanel — global (not scoped) ── */
|
|
35
|
-
.mvfp {
|
|
36
|
-
display: flex;
|
|
37
|
-
flex-direction: column;
|
|
38
|
-
width: 100%;
|
|
39
|
-
position: relative;
|
|
40
|
-
background: var(--app-surface, var(--ion-background-color, #1a1a1a));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/* ── Horizontal scroll rows ── */
|
|
44
|
-
.mvfp-row {
|
|
45
|
-
display: flex;
|
|
46
|
-
gap: 8px;
|
|
47
|
-
padding: 8px 12px;
|
|
48
|
-
overflow-x: auto;
|
|
49
|
-
-webkit-overflow-scrolling: touch;
|
|
50
|
-
scrollbar-width: none;
|
|
51
|
-
flex-shrink: 0;
|
|
52
|
-
}
|
|
53
|
-
.mvfp-row::-webkit-scrollbar { display: none; }
|
|
54
|
-
|
|
55
|
-
/* ── Category chips ── */
|
|
56
|
-
.mvfp-cat {
|
|
57
|
-
display: flex;
|
|
58
|
-
align-items: center;
|
|
59
|
-
gap: 6px;
|
|
60
|
-
min-height: 36px;
|
|
61
|
-
padding: 8px 14px;
|
|
62
|
-
border-radius: 20px;
|
|
63
|
-
border: 1.5px solid var(--app-border, var(--ion-color-step-300, #444));
|
|
64
|
-
background: var(--app-surface-variant, var(--ion-color-step-50, #222));
|
|
65
|
-
color: var(--app-text, var(--ion-text-color, #eee));
|
|
66
|
-
font-size: 13px;
|
|
67
|
-
font-weight: 500;
|
|
68
|
-
white-space: nowrap;
|
|
69
|
-
cursor: pointer;
|
|
70
|
-
flex-shrink: 0;
|
|
71
|
-
transition: all 0.15s;
|
|
72
|
-
-webkit-tap-highlight-color: transparent;
|
|
73
|
-
}
|
|
74
|
-
.mvfp-cat.active {
|
|
75
|
-
background: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
76
|
-
border-color: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
77
|
-
color: #fff;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/* ── Filter cards ── */
|
|
81
|
-
.mvfp-filter {
|
|
82
|
-
display: flex;
|
|
83
|
-
flex-direction: column;
|
|
84
|
-
align-items: center;
|
|
85
|
-
justify-content: center;
|
|
86
|
-
min-width: 72px;
|
|
87
|
-
max-width: 100px;
|
|
88
|
-
min-height: 48px;
|
|
89
|
-
padding: 10px 12px;
|
|
90
|
-
border-radius: 12px;
|
|
91
|
-
border: 2px solid var(--app-border, var(--ion-color-step-300, #444));
|
|
92
|
-
background: var(--app-surface-variant, var(--ion-color-step-50, #222));
|
|
93
|
-
color: var(--app-text, var(--ion-text-color, #eee));
|
|
94
|
-
font-size: 12px;
|
|
95
|
-
text-align: center;
|
|
96
|
-
line-height: 1.3;
|
|
97
|
-
cursor: pointer;
|
|
98
|
-
flex-shrink: 0;
|
|
99
|
-
position: relative;
|
|
100
|
-
transition: all 0.15s;
|
|
101
|
-
-webkit-tap-highlight-color: transparent;
|
|
102
|
-
}
|
|
103
|
-
.mvfp-filter.active {
|
|
104
|
-
border-color: var(--app-success, var(--ion-color-success, #2dd36f));
|
|
105
|
-
}
|
|
106
|
-
.mvfp-filter.selected {
|
|
107
|
-
background: rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.15);
|
|
108
|
-
border-color: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
109
|
-
}
|
|
110
|
-
.mvfp-filter .mvfp-check {
|
|
111
|
-
position: absolute;
|
|
112
|
-
top: -5px;
|
|
113
|
-
right: -5px;
|
|
114
|
-
width: 18px;
|
|
115
|
-
height: 18px;
|
|
116
|
-
border-radius: 50%;
|
|
117
|
-
background: var(--app-success, var(--ion-color-success, #2dd36f));
|
|
118
|
-
color: #fff;
|
|
119
|
-
display: flex;
|
|
120
|
-
align-items: center;
|
|
121
|
-
justify-content: center;
|
|
122
|
-
font-size: 11px;
|
|
123
|
-
cursor: pointer;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/* ── Active filter chips ── */
|
|
127
|
-
.mvfp-active-row {
|
|
128
|
-
display: flex;
|
|
129
|
-
gap: 6px;
|
|
130
|
-
padding: 6px 12px;
|
|
131
|
-
overflow-x: auto;
|
|
132
|
-
-webkit-overflow-scrolling: touch;
|
|
133
|
-
scrollbar-width: none;
|
|
134
|
-
flex-shrink: 0;
|
|
135
|
-
}
|
|
136
|
-
.mvfp-active-row::-webkit-scrollbar { display: none; }
|
|
137
|
-
|
|
138
|
-
.mvfp-achip {
|
|
139
|
-
display: flex;
|
|
140
|
-
align-items: center;
|
|
141
|
-
gap: 6px;
|
|
142
|
-
padding: 6px 10px 6px 12px;
|
|
143
|
-
background: rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.12);
|
|
144
|
-
border: 1px solid var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
145
|
-
border-radius: 20px;
|
|
146
|
-
white-space: nowrap;
|
|
147
|
-
flex-shrink: 0;
|
|
148
|
-
font-size: 12px;
|
|
149
|
-
color: var(--app-text, var(--ion-text-color, #eee));
|
|
150
|
-
cursor: pointer;
|
|
151
|
-
transition: all 0.15s;
|
|
152
|
-
}
|
|
153
|
-
.mvfp-achip.selected {
|
|
154
|
-
background: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
155
|
-
color: #fff;
|
|
156
|
-
}
|
|
157
|
-
.mvfp-achip-x {
|
|
158
|
-
width: 20px;
|
|
159
|
-
height: 20px;
|
|
160
|
-
border-radius: 50%;
|
|
161
|
-
border: 1.5px solid currentColor;
|
|
162
|
-
background: transparent;
|
|
163
|
-
color: inherit;
|
|
164
|
-
display: flex;
|
|
165
|
-
align-items: center;
|
|
166
|
-
justify-content: center;
|
|
167
|
-
cursor: pointer;
|
|
168
|
-
padding: 0;
|
|
169
|
-
opacity: 0.7;
|
|
170
|
-
flex-shrink: 0;
|
|
171
|
-
}
|
|
172
|
-
.mvfp-achip-x:hover, .mvfp-achip-x:active {
|
|
173
|
-
background: var(--ion-color-danger, #ef4444);
|
|
174
|
-
border-color: var(--ion-color-danger, #ef4444);
|
|
175
|
-
color: #fff;
|
|
176
|
-
opacity: 1;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
.mvfp-placeholder {
|
|
180
|
-
font-size: 12px;
|
|
181
|
-
color: var(--app-text-secondary, var(--ion-color-medium, #888));
|
|
182
|
-
padding: 6px 12px;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/* ── Drawer ── */
|
|
186
|
-
.mvfp-drawer {
|
|
187
|
-
position: absolute;
|
|
188
|
-
bottom: 0;
|
|
189
|
-
left: 0;
|
|
190
|
-
right: 0;
|
|
191
|
-
background: var(--app-surface, var(--ion-background-color, #1a1a1a));
|
|
192
|
-
border-top: 1px solid var(--app-border, var(--ion-color-step-300, #444));
|
|
193
|
-
transform: translateY(100%);
|
|
194
|
-
z-index: 20;
|
|
195
|
-
display: flex;
|
|
196
|
-
flex-direction: column;
|
|
197
|
-
overflow: hidden;
|
|
198
|
-
border-radius: 14px 14px 0 0;
|
|
199
|
-
}
|
|
200
|
-
.mvfp-drawer-hdr {
|
|
201
|
-
display: flex;
|
|
202
|
-
justify-content: space-between;
|
|
203
|
-
align-items: center;
|
|
204
|
-
padding: 8px 14px;
|
|
205
|
-
border-bottom: 1px solid var(--app-border, var(--ion-color-step-200, #333));
|
|
206
|
-
flex-shrink: 0;
|
|
207
|
-
}
|
|
208
|
-
.mvfp-drawer-title {
|
|
209
|
-
font-weight: 600;
|
|
210
|
-
font-size: 14px;
|
|
211
|
-
color: var(--app-text, var(--ion-text-color, #eee));
|
|
212
|
-
}
|
|
213
|
-
.mvfp-drawer-actions {
|
|
214
|
-
display: flex;
|
|
215
|
-
align-items: center;
|
|
216
|
-
gap: 10px;
|
|
217
|
-
}
|
|
218
|
-
.mvfp-drawer-btn {
|
|
219
|
-
background: none;
|
|
220
|
-
border: none;
|
|
221
|
-
font-size: 13px;
|
|
222
|
-
font-weight: 500;
|
|
223
|
-
cursor: pointer;
|
|
224
|
-
padding: 4px 6px;
|
|
225
|
-
color: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
226
|
-
}
|
|
227
|
-
.mvfp-drawer-btn.danger {
|
|
228
|
-
color: var(--ion-color-danger, #ef4444);
|
|
229
|
-
}
|
|
230
|
-
.mvfp-drawer-close {
|
|
231
|
-
width: 28px;
|
|
232
|
-
height: 28px;
|
|
233
|
-
border: none;
|
|
234
|
-
border-radius: 50%;
|
|
235
|
-
background: var(--app-surface-sunken, var(--ion-color-step-100, #2a2a2a));
|
|
236
|
-
color: var(--app-text-secondary, var(--ion-color-medium, #888));
|
|
237
|
-
display: flex;
|
|
238
|
-
align-items: center;
|
|
239
|
-
justify-content: center;
|
|
240
|
-
cursor: pointer;
|
|
241
|
-
padding: 0;
|
|
242
|
-
}
|
|
243
|
-
.mvfp-drawer-body {
|
|
244
|
-
flex: 1 1 auto;
|
|
245
|
-
overflow-y: auto;
|
|
246
|
-
-webkit-overflow-scrolling: touch;
|
|
247
|
-
padding: 10px 14px 16px;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/* ── Drawer slider controls ── */
|
|
251
|
-
.mvfp-ctl {
|
|
252
|
-
margin-bottom: 12px;
|
|
253
|
-
}
|
|
254
|
-
.mvfp-ctl-label {
|
|
255
|
-
display: block;
|
|
256
|
-
font-size: 11px;
|
|
257
|
-
font-weight: 600;
|
|
258
|
-
color: var(--app-text-secondary, var(--ion-color-medium, #888));
|
|
259
|
-
text-transform: uppercase;
|
|
260
|
-
letter-spacing: 0.5px;
|
|
261
|
-
margin-bottom: 4px;
|
|
262
|
-
}
|
|
263
|
-
.mvfp-slider-row {
|
|
264
|
-
display: flex;
|
|
265
|
-
align-items: center;
|
|
266
|
-
gap: 10px;
|
|
267
|
-
}
|
|
268
|
-
.mvfp-range {
|
|
269
|
-
flex: 1;
|
|
270
|
-
height: 6px;
|
|
271
|
-
-webkit-appearance: none;
|
|
272
|
-
appearance: none;
|
|
273
|
-
background: var(--app-border, var(--ion-color-step-200, #333));
|
|
274
|
-
border-radius: 3px;
|
|
275
|
-
outline: none;
|
|
276
|
-
}
|
|
277
|
-
.mvfp-range::-webkit-slider-thumb {
|
|
278
|
-
-webkit-appearance: none;
|
|
279
|
-
width: 22px;
|
|
280
|
-
height: 22px;
|
|
281
|
-
border-radius: 50%;
|
|
282
|
-
background: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
283
|
-
cursor: pointer;
|
|
284
|
-
border: 2px solid #fff;
|
|
285
|
-
box-shadow: 0 1px 4px rgba(0,0,0,0.3);
|
|
286
|
-
}
|
|
287
|
-
.mvfp-range-val {
|
|
288
|
-
min-width: 3rem;
|
|
289
|
-
text-align: right;
|
|
290
|
-
font-size: 12px;
|
|
291
|
-
font-weight: 500;
|
|
292
|
-
color: var(--app-text-secondary, var(--ion-color-medium, #888));
|
|
293
|
-
}
|
|
294
|
-
.mvfp-toggle-row {
|
|
295
|
-
display: flex;
|
|
296
|
-
align-items: center;
|
|
297
|
-
justify-content: space-between;
|
|
298
|
-
gap: 10px;
|
|
299
|
-
}
|
|
300
|
-
.mvfp-color-row {
|
|
301
|
-
display: flex;
|
|
302
|
-
align-items: center;
|
|
303
|
-
justify-content: space-between;
|
|
304
|
-
gap: 10px;
|
|
305
|
-
}
|
|
306
|
-
.mvfp-color-input {
|
|
307
|
-
width: 36px;
|
|
308
|
-
height: 36px;
|
|
309
|
-
border: 1px solid var(--app-border, var(--ion-color-step-300, #444));
|
|
310
|
-
border-radius: 8px;
|
|
311
|
-
padding: 2px;
|
|
312
|
-
cursor: pointer;
|
|
313
|
-
background: transparent;
|
|
314
|
-
}
|
|
315
|
-
.mvfp-select-row {
|
|
316
|
-
display: flex;
|
|
317
|
-
align-items: center;
|
|
318
|
-
justify-content: space-between;
|
|
319
|
-
gap: 10px;
|
|
320
|
-
}
|
|
321
|
-
.mvfp-select {
|
|
322
|
-
padding: 6px 10px;
|
|
323
|
-
border: 1px solid var(--app-border, var(--ion-color-step-300, #444));
|
|
324
|
-
border-radius: 8px;
|
|
325
|
-
background: var(--app-surface, var(--ion-background-color, #1a1a1a));
|
|
326
|
-
color: var(--app-text, var(--ion-text-color, #eee));
|
|
327
|
-
font-size: 13px;
|
|
328
|
-
}
|
|
329
|
-
.mvfp-no-params {
|
|
330
|
-
text-align: center;
|
|
331
|
-
color: var(--app-text-secondary, var(--ion-color-medium, #888));
|
|
332
|
-
font-style: italic;
|
|
333
|
-
font-size: 13px;
|
|
334
|
-
padding: 12px 0;
|
|
335
|
-
}
|
|
336
|
-
`,a=document.createElement("style");a.textContent=o,document.head.appendChild(a)}class c2{constructor({filters:a=[],callbacks:t={}}){d2(),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=st("div",{className:"mvfp"}),this._catRow=st("div",{className:"mvfp-row"}),this._root.appendChild(this._catRow),this._filterRow=st("div",{className:"mvfp-row"}),this._root.appendChild(this._filterRow),this._activeRow=st("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=st("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=st("div",{className:`mvfp-filter${t?" active":""}${n?" selected":""}`,onClick:()=>this._selectFilter(a)});if(t){const r=st("div",{className:"mvfp-check",onClick:s=>{s.stopPropagation(),this._removeFilter(a.id)}});r.innerHTML="✓",i.appendChild(r)}i.appendChild(st("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(st("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=st("div",{className:`mvfp-achip${i?" selected":""}`}),s=st("span",{style:{cursor:"pointer"},onClick:()=>{this._selectedFilterId=t,this._renderFilters(),n.params&&n.params.length>0&&this.openDrawer(t)}},n.name),l=st("button",{className:"mvfp-achip-x","aria-label":`Remove ${n.name}`,onClick:d=>{d.stopPropagation(),this._removeFilter(t)}});l.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(s),r.appendChild(l),this._activeRow.appendChild(r)})}_buildDrawer(){this._drawer=st("div",{className:"mvfp-drawer"});const a=st("div",{className:"mvfp-drawer-hdr"});this._drawerTitle=st("span",{className:"mvfp-drawer-title"},"Filter");const t=st("div",{className:"mvfp-drawer-actions"});t.appendChild(st("button",{className:"mvfp-drawer-btn",onClick:()=>this._resetDrawerFilter()},"Reset")),t.appendChild(st("button",{className:"mvfp-drawer-btn danger",onClick:()=>{this._drawerFilterId&&(this._removeFilter(this._drawerFilterId),this.closeDrawer())}},"Remove"));const n=st("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=st("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(st("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,s=st("div",{className:"mvfp-ctl"}),l=st("label",{className:"mvfp-ctl-label"},i.label||i.id);s.appendChild(l);const d=i.type||"slider";if(d==="slider"||d==="range"){const c=st("div",{className:"mvfp-slider-row"}),u=st("span",{className:"mvfp-range-val"},Bc(r)),f=st("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:m=>{var h,v;const p=parseFloat(m.target.value);u.textContent=Bc(p),(v=(h=this._cb).onUpdateParam)==null||v.call(h,a.id,i.id,p)}});c.appendChild(f),c.appendChild(u),s.appendChild(c)}else if(d==="toggle"||d==="checkbox"){const c=st("div",{className:"mvfp-toggle-row"}),u=st("input",{type:"checkbox",checked:r?"checked":void 0,onChange:f=>{var m,p;return(p=(m=this._cb).onUpdateParam)==null?void 0:p.call(m,a.id,i.id,f.target.checked)}});c.appendChild(u),s.appendChild(c)}else if(d==="color"){const c=st("div",{className:"mvfp-color-row"}),u=st("input",{type:"color",className:"mvfp-color-input",value:typeof r=="string"?r:"#000000",onInput:f=>{var m,p;return(p=(m=this._cb).onUpdateParam)==null?void 0:p.call(m,a.id,i.id,f.target.value)}});c.appendChild(u),s.appendChild(c)}else if(d==="select"||d==="dropdown"){const c=st("div",{className:"mvfp-select-row"}),u=st("select",{className:"mvfp-select",onChange:f=>{var m,p;return(p=(m=this._cb).onUpdateParam)==null?void 0:p.call(m,a.id,i.id,f.target.value)}});for(const f of i.options||[]){const m=st("option",{value:f.value},f.label||String(f.value));f.value===r&&(m.selected=!0),u.appendChild(m)}c.appendChild(u),s.appendChild(c)}this._drawerBody.appendChild(s)}}_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 u2=[200,500,1e3];function m2(o){return{"360p":[640,360],"480p":[854,480],"720p":[1280,720],"1080p":[1920,1080],"1440p":[2560,1440],"2160p":[3840,2160]}[o??""]??[1920,1080]}function Mc(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 p2(o){return new Promise(a=>{window.setTimeout(a,o)})}async function Fc(){return await Promise.resolve().then(()=>require("./PixiFrameExporter-BOijjcAa.cjs"))}function $c(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 Dm(o){let a=null;return{canExportClientSide:async()=>{try{const{isWebCodecsSupported:i}=await Fc();return i()}catch{return!1}},renderRecipeWithPixi:async(i,r,s)=>{var p,h,v,w;const l=i.timeline[0],d=l?Math.max(0,l.sourceIn):0,c=l?l.sourceOut:void 0,[u,f]=m2((r==null?void 0:r.quality)??((p=i.output)==null?void 0:p.quality)),m=((h=i.output)==null?void 0:h.fps)||30;o.setPlaying(!1),o.forcePixiPreview.value=!0,await e.nextTick();try{let E=!1;for(const R of u2){await p2(R);const U=o.getPreviewRef();if(!(!U||typeof U.captureFrameAt!="function")){if(typeof U.ensureReadyForCapture=="function"){if(E=await U.ensureReadyForCapture(),E)break;continue}E=!0;break}}const S=o.getPreviewRef();if(!S||typeof S.captureFrameAt!="function")throw new Error("PIXI preview not available for export. Ensure the preview is mounted.");if(!E)throw new Error("PIXI preview not ready for frame capture after retries. The video may still be loading.");const{exportWithPixiFrames:k,isWebCodecsSupported:b}=await Fc();if(!b())throw new Error("WebCodecs is not supported in this browser. Export requires Chrome 94+ or equivalent.");a=new AbortController;const $={width:u,height:f,fps:m,trimStart:d,signal:a.signal};c!==void 0&&($.trimEnd=c),s&&($.onProgress=s);const V=o.getSourceUrl();V!==""&&($.sourceUrl=V);const I=Mc(S)??((v=i.source)==null?void 0:v.duration)??c??0,x=await k({captureFrameAt:R=>{var U;return((U=S.captureFrameAt)==null?void 0:U.call(S,R))??Promise.resolve(null)},duration:{value:I}},$),N=new File([x],`edited-video-${Date.now()}.mp4`,{type:"video/mp4"}),L=Mc(S),C=((w=i.source)==null?void 0:w.duration)??0,y=Math.max(0,(c??L??C)-d);return{file:N,recipe:i,meta:{duration:y,width:u,height:f,format:"mp4",sizeBytes:N.size,size_bytes:N.size}}}finally{o.forcePixiPreview.value=!1,a=null}},cancelClientExport:()=>{a==null||a.abort(),a=null},resetClientExport:()=>{a=null}}}const Bo="default-video-track",En="default-media-source";function Rm(o){var r,s;const a=h2(o),t=v2(o),n=g2(o.timeline,((r=t[0])==null?void 0:r.id)??Bo,((s=a[0])==null?void 0:s.id)??En),i={version:o.version,source:{...o.source},mediaSources:a,tracks:b2(t,n),clips:n,markers:o.markers?o.markers.map(l=>({...l})):[],transitions:o.transitions?o.transitions.map(Pm):[],filters:o.filters.map(l=>({...l,params:{...l.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(Um)),o.visualLayers&&(i.visualLayers=o.visualLayers.map(Om)),o.audioTracks&&(i.audioTracks=[...o.audioTracks]),o.posterFrame&&(i.posterFrame=o.posterFrame),o.metadata&&(i.metadata={...o.metadata}),i}function f2(o){const a={version:"1.0",source:{...o.source},timeline:o.clips.map(t=>({...t})),mediaSources:o.mediaSources.map(Am),tracks:o.tracks.map(Lm),markers:o.markers.map(t=>({...t})),transitions:o.transitions.map(Pm),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(Um)),o.visualLayers&&(a.visualLayers=o.visualLayers.map(Om)),o.audioTracks&&(a.audioTracks=[...o.audioTracks]),o.posterFrame&&(a.posterFrame=o.posterFrame),o.metadata&&(a.metadata={...o.metadata}),a}function h2(o){var t,n;if(o.mediaSources&&o.mediaSources.length>0)return o.mediaSources.map(Am);const a={id:((t=o.timeline.find(i=>i.sourceRefId))==null?void 0:t.sourceRefId)??En,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 v2(o){var a;return o.tracks&&o.tracks.length>0?o.tracks.map(Lm):[{id:((a=o.timeline.find(t=>t.trackId))==null?void 0:a.trackId)??Bo,type:"video",name:"Video",order:0}]}function g2(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 b2(o,a){return o.map(t=>{const n=a.filter(i=>i.trackId===t.id).map(i=>i.id);return{...t,clipIds:n}})}function Am(o){const a={...o};return o.metadata&&(a.metadata={...o.metadata}),a}function Lm(o){const a={...o};return o.clipIds&&(a.clipIds=[...o.clipIds]),a}function Pm(o){const a={...o};return o.params&&(a.params={...o.params}),a}function Um(o){return{...o,segments:o.segments.map(t=>{const n={...t};return t.words&&(n.words=t.words.map(i=>({...i}))),n})}}function Om(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 zm="video-project-draft-snapshot:v1",Fl="mediables:video-project-drafts",y2=(o,a={})=>{var m,p;const t=ln(a.now)??Date.now(),n=ln(a.createdAt)??t,i=ln(a.updatedAt)??t,r=I2(o),s={id:Ba(a.id)??D2(i),payloadKind:r,createdAt:new Date(n).toISOString(),updatedAt:new Date(i).toISOString(),deviceKind:a.deviceKind??"unknown"},l=Ba(a.projectId),d=Ba(a.sourceMediaUuid)??Ba(o.source.media_uuid),c=$l(a.durationSeconds)??M2(o),u=Ba(a.editorVersion)??Ba((m=o.metadata)==null?void 0:m.editor_version),f=Ba(a.title)??Ba((p=o.metadata)==null?void 0:p.title);return l!==null&&(s.projectId=l),d!==null&&(s.sourceMediaUuid=d),c!==null&&(s.durationSeconds=c),u!==null&&(s.editorVersion=u),f!==null&&(s.title=f),a.saveReason!==void 0&&(s.saveReason=a.saveReason),{schemaVersion:zm,metadata:s,payload:o}},jm=(o,a=Fl)=>{const t=Ba(a)??Fl,n=Pc(o.metadata.projectId??"unsaved-project"),i=Pc(o.metadata.id);return`${t}:${n}:${i}`},w2=o=>JSON.stringify(o),k2=o=>{if(typeof o!="string"||o.trim().length===0)return null;try{const a=JSON.parse(o);return N2(a)?a:null}catch{return null}},_2=o=>{const a=[];for(const t of o){const n=Ba(t.key),i=k2(t.value);n===null||i===null||a.push({key:n,snapshot:i})}return vi(a)},E2=(o,a)=>{const t=$2(a.maxCount),n=ln(a.now)??Date.now(),i=Xm(a.maxAgeMs),r=[],s=[];let l=0;for(const d of vi(o)){if(!Zm(d,a.projectId)){r.push(d);continue}if(Gm(d.snapshot,n,i)||l>=t){s.push(d);continue}r.push(d),l+=1}return{retained:vi(r),removed:vi(s)}},x2=(o,a={})=>{const t={key:jm(o),snapshot:o};if(!Zm(t,a.projectId))return!1;const n=ln(a.now)??Date.now(),i=Xm(a.maxAgeMs);if(Gm(o,n,i))return!1;const r=a.savedAt===null?null:ln(a.savedAt);return r===null?!0:Lr(o)>r},S2=(o,a={})=>vi(o).filter(t=>x2(t.snapshot,a)),C2=(o,a,t={})=>{const n=S2(o,t);if(a==="mobile"){const i=n[0]??null;return i===null?[]:[i]}return n},V2=async(o,a,t=jm(a))=>(await o.setItem(t,w2(a)),{key:t,snapshot:a}),Dc=async(o,a=Fl)=>{const t=await o.listKeys(a),n=[];for(const i of t)n.push({key:i,value:await o.getItem(i)});return _2(n)},Rc=async(o,a)=>{for(const t of a)await o.removeItem(t.key)},N2=o=>!dn(o)||o.schemaVersion!==zm||!T2(o.metadata)?!1:o.metadata.payloadKind==="project"?Wm(o.payload):B2(o.payload),T2=o=>dn(o)?gd(o.id)&&A2(o.payloadKind)&&Lc(o.createdAt)&&Lc(o.updatedAt)&&L2(o.deviceKind)&&sr(o.projectId)&&sr(o.sourceMediaUuid)&&R2(o.durationSeconds)&&sr(o.editorVersion)&&sr(o.title)&&P2(o.saveReason):!1,B2=o=>dn(o)?o.version==="1.0"&&Hm(o.source)&&Array.isArray(o.timeline)&&Array.isArray(o.filters)&&dn(o.audio)&&dn(o.output):!1,Wm=o=>dn(o)?o.version==="1.0"&&Hm(o.source)&&Array.isArray(o.mediaSources)&&Array.isArray(o.tracks)&&Array.isArray(o.clips)&&Array.isArray(o.markers)&&Array.isArray(o.filters)&&dn(o.audio)&&dn(o.output):!1,Hm=o=>dn(o)?gd(o.media_uuid)&&gi(o.duration)&&gi(o.original_width)&&gi(o.original_height):!1,I2=o=>Wm(o)?"project":"recipe",M2=o=>$l(o.duration)??$l(o.source.duration),Zm=(o,a)=>{const t=Ba(a);return t===null?!0:o.snapshot.metadata.projectId===t},Gm=(o,a,t)=>t===null?!1:a-Lr(o)>t,vi=o=>[...o].sort(F2),F2=(o,a)=>{const t=Lr(a.snapshot)-Lr(o.snapshot);if(t!==0)return t;const n=Ac(a.snapshot)-Ac(o.snapshot);return n!==0?n:o.snapshot.metadata.id.localeCompare(a.snapshot.metadata.id)},Lr=o=>ln(o.metadata.updatedAt)??0,Ac=o=>ln(o.metadata.createdAt)??0,$2=o=>!Number.isFinite(o)||o<0?0:Math.floor(o),Xm=o=>o===void 0||!Number.isFinite(o)||o<0?null:Math.floor(o),ln=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},Lc=o=>typeof o=="string"&&ln(o)!==null,D2=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}`},Pc=o=>encodeURIComponent(o.trim()),Ba=o=>{if(typeof o!="string")return null;const a=o.trim();return a.length>0?a:null},gd=o=>Ba(o)!==null,sr=o=>o===void 0||gd(o),$l=o=>{if(!gi(o))return null;const a=Number(o.toFixed(6));return Object.is(a,-0)?0:a},gi=o=>typeof o=="number"&&Number.isFinite(o)&&o>=0,R2=o=>o===void 0||gi(o),A2=o=>o==="recipe"||o==="project",L2=o=>o==="desktop"||o==="mobile"||o==="tablet"||o==="unknown",P2=o=>o===void 0||o==="autosave"||o==="manual"||o==="before-export"||o==="before-close",dn=o=>typeof o=="object"&&o!==null&&!Array.isArray(o),U2=1,O2="master",xi=-60,Dl=12,bd=0,xn=-90,Pr=6,z2=4,Km=8;function Jm(){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:Km}}}function j2(o,a=Jm()){return Al(a[o])}function qm(o){return Number.isNaN(o)?bd:o<=0||o===Number.NEGATIVE_INFINITY?xi:Si(20*Math.log10(o))}function Rl(o){const a=Si(o);return a<=xi?0:Cn(Math.pow(10,a/20),6)}function Si(o){return Number.isNaN(o)?bd:o===Number.NEGATIVE_INFINITY?xi:o===Number.POSITIVE_INFINITY?Dl:Cn(Ri(o,xi,Dl),3)}function Ym(o){return Number.isFinite(o)?Cn(Ri(o,-1,1),3):0}function W2(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,s=a||i||r,l=s?0:n.controls.fader.linearGain;return{trackId:n.id,soloed:n.controls.solo,mutedByTrack:i,mutedBySolo:r,mutedByMaster:a,effectivelyMuted:s,audible:!s,effectiveGainLinear:l}})}function H2(o,a={}){const t=aE(a.effectSlotCount),n=new Set;return{schemaVersion:U2,capabilities:a.capabilities?rE(a.capabilities):Jm(),tracks:o.map((i,r)=>G2(i,r,t,n)),master:X2(a.master,t)}}function Qm(o){const a=Si(o);return{valueDb:a,minDb:xi,maxDb:Dl,unityDb:bd,linearGain:Rl(a)}}function Z2(o,a="constant-power"){return{value:Ym(o),mode:a}}function ep(o=xn,a=xn,t=o){const n=Zs(o),i=Zs(a),r=Zs(t);return{peakDb:n,rmsDb:i,peakHoldDb:r,clipping:n>=0||r>=0}}function tp(o){const a=op(o);return{id:`empty-effect-slot-${a}`,index:a,kind:"empty",label:"Empty",enabled:!1,bypassed:!0,wetMix:0,parameters:{}}}function G2(o,a,t,n){const i=np(o.id),s={id:tE(i??`legacy-audio-track-${a+1}`,n),kind:"legacy-url",name:Y2(o.name,a),order:a,source:K2(o.source),controls:{fader:Qm(o.faderDb??qm(o.volume??1)),pan:Z2(o.pan??0),muted:o.muted??!1,solo:o.solo??!1,meter:ep(o.peakDb,o.rmsDb,o.peakHoldDb)},timeline:J2(o),effectSlots:ap(o.effectSlots,t)};return i!==void 0&&(s.legacyTrackId=i),s}function X2(o,a){return{id:O2,name:Q2(o==null?void 0:o.name),fader:Qm((o==null?void 0:o.faderDb)??qm((o==null?void 0:o.volume)??1)),muted:(o==null?void 0:o.muted)??!1,meter:ep(o==null?void 0:o.peakDb,o==null?void 0:o.rmsDb,o==null?void 0:o.peakHoldDb),effectSlots:ap(o==null?void 0:o.effectSlots,a)}}function K2(o){const a=o.trim();return a===""?{type:"missing"}:{type:"url",url:a}}function J2(o){const a={startTime:oE(o.startTime??0),loop:o.loop??!1},t=nE(o.duration);t!==void 0&&(a.duration=t);const n=Uc(o.fadeIn);n!==void 0&&(a.fadeIn=n);const i=Uc(o.fadeOut);return i!==void 0&&(a.fadeOut=i),a}function ap(o,a){const t=new Map;for(const n of o??[]){const i=q2(n,a);t.set(i.index,i)}return Array.from({length:a},(n,i)=>t.get(i)??tp(i))}function q2(o,a){const t=op(o.index),n=a>0?Math.min(t,a-1):0,i=o.kind;return i==="empty"?tp(n):{id:np(o.id)??`${i}-effect-slot-${n}`,index:n,kind:i,label:eE(o.label,i),enabled:o.enabled,bypassed:o.bypassed,wetMix:iE(o.wetMix),parameters:{...o.parameters}}}function Y2(o,a){const t=o==null?void 0:o.trim();return t&&t!==""?t:`Audio ${a+1}`}function Q2(o){const a=o==null?void 0:o.trim();return a&&a!==""?a:"Master"}function eE(o,a){const t=o.trim();return t!==""?t:a}function tE(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 np(o){const a=o==null?void 0:o.trim();if(!(!a||a===""))return a}function aE(o){return o===void 0||!Number.isFinite(o)?z2:Math.trunc(Ri(o,0,Km))}function op(o){return!Number.isFinite(o)||o<0?0:Math.trunc(o)}function nE(o){if(!(o===void 0||!Number.isFinite(o)||o<=0))return Cn(o,3)}function Uc(o){if(!(o===void 0||!Number.isFinite(o)||o<0))return Cn(o,3)}function oE(o){return!Number.isFinite(o)||o<0?0:Cn(o,3)}function iE(o){return Number.isFinite(o)?Cn(Ri(o,0,1),3):1}function Zs(o){return Number.isNaN(o)||o===Number.NEGATIVE_INFINITY?xn:o===Number.POSITIVE_INFINITY?Pr:Cn(Ri(o,xn,Pr),3)}function rE(o){return{mobile:Al(o.mobile),desktop:Al(o.desktop)}}function Al(o){return{...o}}function Ri(o,a,t){return Math.min(t,Math.max(a,o))}function Cn(o,a){const t=10**a;return Math.round(o*t)/t}const sE=/^(\d{2,}:[0-5]\d:[0-5]\d,\d{3})\s+-->\s+(\d{2,}:[0-5]\d:[0-5]\d,\d{3})$/,lE=/^(\d{2,}):([0-5]\d):([0-5]\d),(\d{3})$/,dE="srt-cue";class Sn extends Error{constructor(a,t,n={}){super(t),this.name="CaptionSrtError",this.code=a,this.context=n}}function cE(o,a={}){var s,l;const t=uE(a.idPrefix),n=o.replace(/^\uFEFF/,"").replace(/\r\n?/g,`
|
|
337
|
-
`).split(`
|
|
338
|
-
`),i=[];let r=0;for(;r<n.length;){for(;r<n.length&&Hc(n[r]);)r+=1;if(r>=n.length)break;const d=r+1,c=mE(((s=n[r])==null?void 0:s.trim())??"",d);if(r+=1,r>=n.length)throw new Sn("missing-timing",`Cue ${c} is missing its timing line.`,{cueIndex:i.length,cueNumber:c,lineNumber:d});const u=r+1,f=pE(((l=n[r])==null?void 0:l.trim())??"",c,u);r+=1;const m=[];for(;r<n.length&&!Hc(n[r]);)m.push(n[r]??""),r+=1;i.push({cueNumber:c,id:`${t}-${i.length+1}`,startTime:f.startTime,endTime:f.endTime,text:m.join(`
|
|
339
|
-
`)})}return ip(i),i}function Oc(o){return ip(o),o.length===0?"":`${o.map((a,t)=>hE(a,t+1)).join(`
|
|
340
|
-
|
|
341
|
-
`)}
|
|
342
|
-
`}function ip(o){const a=o.map((t,n)=>{const i=Wc(t,n),r=Ll(t.startTime,"startTime",i),s=Ll(t.endTime,"endTime",i);if(s<=r)throw new Sn("invalid-duration",`Caption cue "${t.id}" must end after it starts.`,i);return{cue:t,cueIndex:n,startMilliseconds:r,endMilliseconds:s}}).sort((t,n)=>t.startMilliseconds-n.startMilliseconds||t.cueIndex-n.cueIndex);for(let t=1;t<a.length;t+=1){const n=a[t-1],i=a[t];if(!(n===void 0||i===void 0)&&i.startMilliseconds<n.endMilliseconds)throw new Sn("overlapping-cues",`Caption cue "${i.cue.id}" overlaps cue "${n.cue.id}".`,Wc(i.cue,i.cueIndex))}}function zc(o){const a=Ll(o,"timestamp",{}),t=Math.floor(a/36e5),n=Math.floor(a%36e5/6e4),i=Math.floor(a%6e4/1e3),r=a%1e3;return[t.toString().padStart(2,"0"),n.toString().padStart(2,"0"),i.toString().padStart(2,"0")].join(":")+`,${r.toString().padStart(3,"0")}`}function uE(o){return o===void 0||o.trim()===""?dE:o.trim()}function mE(o,a){if(!/^[1-9]\d*$/.test(o))throw new Sn("invalid-cue-number",`Invalid SRT cue number at line ${a}.`,{lineNumber:a});return Number.parseInt(o,10)}function pE(o,a,t){const n=sE.exec(o),i=n==null?void 0:n[1],r=n==null?void 0:n[2];if(i===void 0||r===void 0)throw new Sn("invalid-timing",`Invalid SRT timing line for cue ${a} at line ${t}.`,{cueNumber:a,lineNumber:t});return{startTime:jc(i,a,t),endTime:jc(r,a,t)}}function jc(o,a,t){const n=lE.exec(o),i=n==null?void 0:n[1],r=n==null?void 0:n[2],s=n==null?void 0:n[3],l=n==null?void 0:n[4];if(i===void 0||r===void 0||s===void 0||l===void 0)throw new Sn("invalid-time",`Invalid SRT timestamp for cue ${a} at line ${t}.`,{cueNumber:a,lineNumber:t});const d=Number.parseInt(i,10),c=Number.parseInt(r,10),u=Number.parseInt(s,10),f=Number.parseInt(l,10);return d*60*60+c*60+u+f/1e3}function Ll(o,a,t){if(!Number.isFinite(o)||o<0)throw new Sn("invalid-time",`Caption cue ${a} must be a finite, non-negative number.`,t);return Math.round(o*1e3)}function Wc(o,a){const t={cueIndex:a,segmentId:o.id},n=fE(o);return n!==void 0&&(t.cueNumber=n),t}function fE(o){if(!(!("cueNumber"in o)||typeof o.cueNumber!="number"))return o.cueNumber}function hE(o,a){return[a.toString(),`${zc(o.startTime)} --> ${zc(o.endTime)}`,vE(o.text)].join(`
|
|
343
|
-
`)}function vE(o){return o.replace(/\r\n?/g,`
|
|
344
|
-
`)}function Hc(o){return o===void 0||o.trim()===""}const gE=["linear","ease-in","ease-out","ease-in-out"];class Ur extends Error{constructor(a,t="Invalid keyframe automation."){super(t),this.name="KeyframeAutomationError",this.issues=a}}const bE={opacity:{min:0,max:1},scale:{min:0,max:10},x:{min:0,max:1},y:{min:0,max:1},rotation:{},audioVolume:{min:0,max:1}};function yE(o){return typeof o=="string"&&gE.includes(o)}function wE(o){return o==="mobile"?{platform:o,editingMode:"preset-only",canApplyPresets:!0,canEditKeyframes:!1}:{platform:o,editingMode:"detailed",canApplyPresets:!0,canEditKeyframes:!0}}function kE(o){return[...o].sort((a,t)=>a.target!==t.target?a.target.localeCompare(t.target):a.time!==t.time?a.time-t.time:a.id.localeCompare(t.id))}function rp(o,a={}){const t=[],n=new Set,i={...bE,...a.ranges};return o.forEach((r,s)=>{if(r.id.trim()===""&&t.push({code:"empty-id",message:"Keyframe id cannot be empty.",index:s,target:r.target,time:r.time}),a.target!==void 0&&r.target!==a.target&&t.push({code:"target-mismatch",message:`Expected ${a.target} keyframe target but received ${r.target}.`,index:s,keyframeId:r.id,target:r.target,time:r.time}),!Number.isFinite(r.time)||r.time<(a.minTime??0))t.push({code:"invalid-time",message:"Keyframe time must be a finite non-negative number.",index:s,keyframeId:r.id,target:r.target,time:r.time});else if(a.maxTime!==void 0&&r.time>a.maxTime)t.push({code:"invalid-time",message:`Keyframe time must be less than or equal to ${a.maxTime}.`,index:s,keyframeId:r.id,target:r.target,time:r.time});else{const l=`${r.target}:${r.time}`;n.has(l)&&t.push({code:"duplicate-time",message:`Keyframe target ${r.target} already has a point at ${r.time}.`,index:s,keyframeId:r.id,target:r.target,time:r.time}),n.add(l)}if(!Number.isFinite(r.value))t.push({code:"invalid-value",message:"Keyframe value must be a finite number.",index:s,keyframeId:r.id,target:r.target,time:r.time});else{const l=i[r.target];l.min!==void 0&&r.value<l.min&&t.push({code:"invalid-value",message:`Keyframe value for ${r.target} must be greater than or equal to ${l.min}.`,index:s,keyframeId:r.id,target:r.target,time:r.time}),l.max!==void 0&&r.value>l.max&&t.push({code:"invalid-value",message:`Keyframe value for ${r.target} must be less than or equal to ${l.max}.`,index:s,keyframeId:r.id,target:r.target,time:r.time})}yE(r.easing)||t.push({code:"invalid-easing",message:`Unsupported keyframe easing "${String(r.easing)}".`,index:s,keyframeId:r.id,target:r.target,time:r.time})}),{valid:t.length===0,issues:t}}function _E(o,a={}){const t=kE(o),n=rp(t,a);if(!n.valid)throw new Ur(n.issues);return t}function EE(o={}){return yd({id:"fade-in",label:"Fade in",target:"opacity",startValue:o.fromOpacity??0,endValue:o.toOpacity??1,timing:wd(o,"ease-out")})}function xE(o={}){return yd({id:"fade-out",label:"Fade out",target:"opacity",startValue:o.fromOpacity??1,endValue:o.toOpacity??0,timing:wd(o,"ease-in")})}function SE(o={}){return yd({id:"zoom-in",label:"Zoom in",target:"scale",startValue:o.fromScale??1,endValue:o.toScale??1.1,timing:wd(o,"ease-out")})}function yd(o){const a=[{id:`${o.id}:start`,target:o.target,time:o.timing.startTime,value:o.startValue,easing:"linear"},{id:`${o.id}:end`,target:o.target,time:o.timing.endTime,value:o.endValue,easing:o.timing.easing}],t=rp(a,{target:o.target});if(!t.valid)throw new Ur(t.issues);return{id:o.id,label:o.label,target:o.target,editingMode:"preset-only",keyframes:a}}function wd(o,a){const t=o.startTime??0,n=o.duration??1;if(!Number.isFinite(t)||t<0)throw new Ur([{code:"invalid-time",message:"Preset start time must be a finite non-negative number.",time:t}]);if(!Number.isFinite(n)||n<=0)throw new Ur([{code:"invalid-time",message:"Preset duration must be a finite number greater than zero."}]);return{startTime:t,endTime:t+n,easing:o.easing??a}}class Kn extends Error{constructor(a,t){super(t),this.name="VisualLayerSchemaError",this.code=a}}function CE(o){_d(o.id,"caption track id");const a={id:o.id,source:o.source,stylePreset:o.stylePreset??"default",animation:o.animation??"none",segments:VE(o.segments)};return o.language!==void 0&&(a.language=o.language),a}function VE(o){const a=o.map(t=>{_d(t.id,"caption segment id");const n=kd(t.startTime,"caption segment startTime"),i=sp(t.endTime,"caption segment endTime");if(i<=n)throw new Kn("invalid-caption-segment",`Caption segment "${t.id}" must end after it starts.`);const r={id:t.id,startTime:n,endTime:i,text:t.text};return t.words!==void 0&&(r.words=NE(t.id,t.words)),r}).sort((t,n)=>t.startTime-n.startTime);for(let t=1;t<a.length;t+=1){const n=a[t-1],i=a[t];if(!(n===void 0||i===void 0)&&i.startTime<n.endTime)throw new Kn("invalid-caption-segment",`Caption segment "${i.id}" overlaps segment "${n.id}".`)}return a}function NE(o,a){return a.map(t=>{_d(t.id,"caption word id");const n=kd(t.startTime,"caption word startTime"),i=sp(t.endTime,"caption word endTime");if(i<=n)throw new Kn("invalid-caption-segment",`Caption word "${t.id}" in segment "${o}" must end after it starts.`);return{id:t.id,startTime:n,endTime:i,text:t.text}}).sort((t,n)=>t.startTime-n.startTime)}function kd(o,a){const t=TE(o,a);if(t<0)throw new Kn("invalid-time",`${a} must be non-negative.`);return Math.round(t*1e3)/1e3}function sp(o,a){const t=kd(o,a);if(t<=0)throw new Kn("invalid-duration",`${a} must be greater than zero.`);return t}function TE(o,a){if(!BE(o))throw new Kn("invalid-time",`${a} must be a finite number.`);return o}function _d(o,a){if(o.trim()==="")throw new Kn("empty-id",`${a} cannot be empty.`)}function BE(o){return Number.isFinite(o)}function Zc(o){var f,m,p,h;IE(o);const a=$E(o),t=DE(o),n=((f=a[0])==null?void 0:f.id)??En,i=((m=t[0])==null?void 0:m.id)??Bo,r=ME(o.clips,i,n),s=RE(t,r),l=[],d=UE(o),c=OE(o),u={version:"1.0",source:{media_uuid:o.mediaUuid,duration:o.originalDuration,original_width:((p=o.media)==null?void 0:p.width)||1920,original_height:((h=o.media)==null?void 0:h.height)||1080},timeline:r,mediaSources:a,tracks:s,filters:l,audio:d,output:c,metadata:{created_at:new Date().toISOString(),editor_version:"2.0.0"}};return o.textOverlays&&(u.textOverlays=o.textOverlays),o.captionTracks&&(u.captionTracks=o.captionTracks.map(v=>({...v,segments:v.segments.map(w=>{const E={...w};return w.words&&(E.words=w.words.map(S=>({...S}))),E})}))),o.visualLayers&&(u.visualLayers=o.visualLayers.map(v=>({...v}))),o.audioTracks&&(u.audioTracks=o.audioTracks.filter(v=>typeof v.source=="string")),o.transitions&&(u.transitions=o.transitions.map(PE)),u}function IE(o){if(!o.mediaUuid)throw new Error("Media UUID is required");if(!o.clips||o.clips.length===0)throw new Error("At least one clip is required");const a=new Map;for(const t of o.clips){const n=FE(t),i=a.get(n)??[];i.push(t),a.set(n,i)}for(const t of a.values()){t.sort((n,i)=>n.timelineStart-i.timelineStart);for(let n=1;n<t.length;n++){const i=t[n],r=t[n-1];if(i.timelineStart<r.timelineEnd)throw new Error(`Clips ${r.id} and ${i.id} overlap on timeline`)}}}function ME(o,a,t){return o.map(n=>{const i=n.speed||1,r=typeof n.sourceIn=="number"&&!Number.isNaN(n.sourceIn),s=typeof n.sourceOut=="number"&&!Number.isNaN(n.sourceOut),l=Math.max(0,n.timelineEnd-n.timelineStart),d=n,c=d.sourceOffset??d.trimStart??0;let u=Number(r?n.sourceIn:c),f=s?Number(n.sourceOut):Number(c)+l/i;f>u||(f=u+Math.max(.033,l/Math.max(1e-6,i)));const m={id:n.id,type:n.type??"clip",trackId:n.trackId??a,sourceRefId:n.sourceRefId??t,timelineStart:n.timelineStart,timelineEnd:n.timelineEnd,sourceIn:u,sourceOut:f,speed:i,filters:n.filters?[...n.filters]:[]};return n.keyframes&&(m.keyframes=n.keyframes.map(p=>({...p}))),m})}function FE(o){return o.trackId??`legacy-track-${o.track??0}`}function $E(o){var t,n,i,r,s,l,d,c;if(o.mediaSources&&o.mediaSources.length>0)return o.mediaSources.map(AE);const a={id:((t=o.clips.find(u=>u.sourceRefId))==null?void 0:t.sourceRefId)??En,type:"media",mediaUuid:o.mediaUuid,duration:o.originalDuration,width:((n=o.media)==null?void 0:n.width)??1920,height:((i=o.media)==null?void 0:i.height)??1080};return(r=o.media)!=null&&r.filename&&(a.filename=o.media.filename),(s=o.media)!=null&&s.mime_type&&(a.mimeType=o.media.mime_type),typeof((l=o.media)==null?void 0:l.frame_rate)=="number"&&(a.frameRate=o.media.frame_rate),typeof((d=o.media)==null?void 0:d.has_audio)=="boolean"&&(a.hasAudio=o.media.has_audio),(c=o.media)!=null&&c.thumbnail_url&&(a.thumbnailUrl=o.media.thumbnail_url),[a]}function DE(o){var a;return o.tracks&&o.tracks.length>0?o.tracks.map(LE):[{id:((a=o.clips.find(t=>t.trackId))==null?void 0:a.trackId)??Bo,type:"video",name:"Video",order:0}]}function RE(o,a){return o.map(t=>({...t,clipIds:a.filter(n=>n.trackId===t.id).map(n=>n.id)}))}function AE(o){const a={...o};return o.metadata&&(a.metadata={...o.metadata}),a}function LE(o){const a={...o};return o.clipIds&&(a.clipIds=[...o.clipIds]),a}function PE(o){const a={...o};return o.params&&(a.params={...o.params}),a}function UE(o){const a={volume:o.audioVolume,muted:o.audioVolume===0};return o.audioFadeIn>0&&(a.fadeIn=o.audioFadeIn),o.audioFadeOut>0&&(a.fadeOut=o.audioFadeOut),a}function OE(o){var r;const a={"360p":{bitrate:1e6},"480p":{bitrate:25e5},"720p":{bitrate:5e6},"1080p":{bitrate:8e6},"1440p":{bitrate:16e6},"2160p":{bitrate:35e6}},t=a[o.exportQuality]||a["1080p"],n=(r=o.media)==null?void 0:r.frame_rate,i=n&&Number.isFinite(n)&&n>0?n:30;return{format:o.exportFormat||"mp4",codec:"h264",quality:o.exportQuality||"1080p",fps:i,bitrate:t.bitrate}}function ja(o){return arguments.length===0?{ok:!0,value:void 0}:{ok:!0,value:o}}function Dt(o,a){return{ok:!1,reason:o,message:a}}const zE={last_clip:"Can't delete the last clip — leave the timeline empty or use Reset.",no_selection:"Select a clip first.",track_locked:"Target track is locked. Unlock it or pick another track.",track_missing:"That track no longer exists.",track_type_mismatch:"Clip can't be placed on that track type.",overlap:"No room on this track. Move neighboring clips or use a different track.",asset_not_ready:"Asset is still uploading or processing.",invariant_violation:"Editor state would be invalid — change rejected.",source_not_found:"Asset source not found.",source_in_use:"This asset is in use on the timeline. Remove its clips before deleting."};function aa(o){return zE[o]}const bi=1e-6;function Gs(o){if(!Number.isFinite(o.desiredDuration)||o.desiredDuration<=0)return{ok:!1};const a=Math.max(0,o.preferredStart),t=[...o.trackClips].filter(i=>i.id!==o.ignoreClipId).sort((i,r)=>i.timelineStart-r.timelineStart);if(t.length===0)return{ok:!0,start:a};if(jE(a,o.desiredDuration,t))return{ok:!0,start:a};let n=a;for(const i of t)if(!(i.timelineEnd<=n+bi)){if(i.timelineStart-n>=o.desiredDuration-bi&&n+bi>=a)return{ok:!0,start:n};n=Math.max(n,i.timelineEnd)}return{ok:!0,start:n}}function jE(o,a,t){const n=o+a;for(const i of t)if(!(i.timelineEnd<=o+bi)&&!(i.timelineStart>=n-bi))return!1;return!0}const WE={video:new Set(["clip","video","image"]),image:new Set(["image"]),audio:new Set(["audio"]),text:new Set(["text"]),graphics:new Set(["graphics"]),caption:new Set([])};function Gc(o,a){return WE[a].has(o)}function HE(o){const a=new Set;for(const t of o.clips)typeof t.sourceRefId=="string"&&t.sourceRefId!==""&&a.add(t.sourceRefId);return a}function ZE(o,a){return HE(o).has(a)}function lr(o,a=30){const t=typeof o=="number"?o:Number(o);return Number.isFinite(t)&&t>0?t:a}function lp(o,a,t){var dt,Ft,ya;const n=typeof o=="string"&&o.trim()!==""?o.trim():`temp-${Date.now()}`,i=e.reactive({mediaUuid:n,clips:[],playheadPosition:0,totalDuration:0,originalDuration:0,filters:[],audioVolume:1,audioFadeIn:0,audioFadeOut:0,exportQuality:"1080p",exportFormat:"mp4",hasChanges:!1,isPlaying:!1,zoomLevel:100}),r=e.ref(null),s=e.ref([]),l=e.ref([]),d=e.ref(void 0);let c=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0&&t.duration!==1;const u=e.ref(!1),f=lr(((dt=a==null?void 0:a.output)==null?void 0:dt.fps)??(t==null?void 0:t.frame_rate)),m=e.shallowRef(null),p=new Tm(f),h=e.ref(f),v=e.ref(!1),w=e.ref(!1);a&&a.timeline&&a.timeline.length>0?(T(a),(Ft=a.output)!=null&&Ft.fps&&(h.value=lr(a.output.fps,h.value),p.setFps(h.value))):($(),a&&((ya=a.output)!=null&&ya.fps&&(h.value=lr(a.output.fps,h.value),p.setFps(h.value)),a.audio&&(i.audioVolume=a.audio.volume||1,i.audioFadeIn=a.audio.fadeIn||0,i.audioFadeOut=a.audio.fadeOut||0),a.output&&(i.exportFormat=a.output.format||"mp4",i.exportQuality=a.output.quality||"1080p")));const E=e.ref(1),S=e.computed(()=>i.selectedClipId?i.clips.find(G=>G.id===i.selectedClipId)??null:null);e.watch(S,G=>{E.value=(G==null?void 0:G.speed)??1},{immediate:!0});const k=e.computed(()=>s.value.length>0),b=e.computed(()=>l.value.length>0);function $(){const G=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0?t.duration:1;t&&(i.media=t),i.originalDuration=G,i.totalDuration=G;const q=la();i.mediaSources=[V(G)],i.tracks=[I([q])];const le={id:q,type:"clip",trackId:Bo,sourceRefId:En,timelineStart:0,timelineEnd:G,sourceIn:0,sourceOut:G,sourceMinIn:0,sourceMaxOut:G,speed:1};i.clips=[le],i.selectedClipId=q,d.value=q,!(t||n.startsWith("temp-"))&&(async()=>{try{const de=await fetch(`/api/v1/video/${encodeURIComponent(n)}`);if(!de.ok)throw new Error(`Failed to fetch media: ${de.status}`);const _e=await de.json(),Le=typeof _e=="object"&&_e!==null&&"data"in _e?_e.data:_e;if(!Le||typeof Le!="object")throw new Error("Failed to parse media payload");const Ye=Le;i.media=Ye,a||(h.value=lr(Ye.frame_rate,h.value),p.setFps(h.value));const We=typeof Ye.duration=="number"&&Ye.duration>0?Ye.duration:G;if(i.hasChanges||i.clips.length!==1||i.clips[0].id!==q)return;i.originalDuration=We,i.totalDuration=We,i.mediaSources=[V(We,Ye)],i.tracks=[I([q])];const Pe=i.clips[0];Pe.timelineStart=0,Pe.timelineEnd=We,Pe.sourceIn=0,Pe.sourceOut=We,Pe.sourceMinIn=0,Pe.sourceMaxOut=We,ke(),c=!0}catch{}})()}function V(G,q=t){const le={id:En,type:"media",mediaUuid:n,duration:G,width:(q==null?void 0:q.width)??1920,height:(q==null?void 0:q.height)??1080};return q!=null&&q.filename&&(le.filename=q.filename),q!=null&&q.mime_type&&(le.mimeType=q.mime_type),typeof(q==null?void 0:q.frame_rate)=="number"&&(le.frameRate=q.frame_rate),typeof(q==null?void 0:q.has_audio)=="boolean"&&(le.hasAudio=q.has_audio),q!=null&&q.thumbnail_url&&(le.thumbnailUrl=q.thumbnail_url),le}function I(G){return{id:Bo,type:"video",name:"Video",order:0,clipIds:G}}function x(G){return`track-${G}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function N(G,q){const le=G.charAt(0).toUpperCase()+G.slice(1),de=q.filter(_e=>_e.type===G).length;return de===0?le:`${le} ${de+1}`}function L(G,q){if(G.originalDuration!==1)return;G.originalDuration=q,G.totalDuration===1&&(G.totalDuration=q);const le=G.clips[0],de=!a&&G.clips.length===1&&le!==void 0&&le.timelineStart===0&&le.timelineEnd===1&&le.sourceIn===0&&le.sourceOut===1;for(const _e of G.clips)(_e.sourceMaxOut===1||_e.sourceMaxOut===void 0)&&(_e.sourceMaxOut=q);if(G.mediaSources)for(const _e of G.mediaSources)_e.id===En&&(_e.duration===1||_e.duration===void 0)&&(_e.duration=q);de&&le!==void 0&&(le.sourceOut=q,le.timelineEnd=q)}function C(G){if(!Number.isFinite(G)||G<=0||c)return;const q=i.hasChanges;i.originalDuration=G,i.totalDuration=Math.max(i.totalDuration,G),i.media&&(i.media.duration=G);for(const _e of i.clips)_e.sourceMaxOut=G;if(i.mediaSources)for(const _e of i.mediaSources)(_e.id===En||_e.mediaUuid===n)&&(_e.duration=G);const le=i.clips[0];!a&&i.clips.length===1&&le!==void 0&&le.timelineStart===0&&le.timelineEnd===1&&le.sourceIn===0&&le.sourceOut===1&&le!==void 0&&(le.sourceOut=G,le.timelineEnd=le.timelineStart+(le.sourceOut-le.sourceIn)),ke();for(const _e of s.value)L(_e,G);for(const _e of l.value)L(_e,G);c=!0,e.nextTick(()=>{q||(i.hasChanges=!1)})}function T(G){const q=Rm(G);i.mediaSources=q.mediaSources,i.tracks=q.tracks,i.transitions=q.transitions,i.clips=q.clips.map(le=>({...le,sourceMinIn:le.sourceMinIn??0,sourceMaxOut:le.sourceMaxOut??G.source.duration})),i.filters=[],i.audioVolume=G.audio.volume,i.audioFadeIn=G.audio.fadeIn||0,i.audioFadeOut=G.audio.fadeOut||0,i.exportFormat=G.output.format,i.exportQuality=G.output.quality,i.originalDuration=G.source.duration,i.textOverlays=G.textOverlays?[...G.textOverlays]:[],i.audioTracks=G.audioTracks?[...G.audioTracks]:[],i.captionTracks=G.captionTracks?G.captionTracks.map(Ma):[],i.visualLayers=G.visualLayers?G.visualLayers.map(le=>({...le})):[],i.clips.length>0?(i.selectedClipId=i.clips[0].id,d.value=i.selectedClipId):(delete i.selectedClipId,d.value=void 0),ke()}function y(){s.value.push(JSON.parse(JSON.stringify(i))),l.value=[],i.hasChanges=!0}function R(){if(!k.value)return;const G=s.value.pop();l.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,G)}function U(){if(!b.value)return;const G=l.value.pop();s.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,G)}function z(G,q,le){y();const de=i.clips.find(We=>We.id===G);if(!de)return;const _e=1/h.value,Le=de.sourceMinIn??0,Ye=de.sourceMaxOut??i.originalDuration;if(q==="start"){const We=de.sourceIn,Pe=Math.max(Le,Math.min(le,de.sourceOut-_e));de.sourceIn=Pe;const at=Pe-We;de.timelineStart+=at}else{const We=Math.max(de.sourceIn+_e,Math.min(le,Ye));de.sourceOut=We;const Pe=de.sourceOut-de.sourceIn;de.timelineEnd=de.timelineStart+Pe}ke(),m.value&&m.value.trimClip(G,de.sourceIn,de.sourceOut)}function W(G){y();const q=i.clips.find(Ye=>G>Ye.timelineStart&&G<Ye.timelineEnd);if(!q)return;const le=G-q.timelineStart,de=q.sourceIn+le,_e={id:la(),type:"clip",timelineStart:G,timelineEnd:q.timelineEnd,sourceIn:de,sourceOut:q.sourceOut,speed:q.speed??1,sourceMinIn:q.sourceMinIn??0,sourceMaxOut:q.sourceMaxOut??i.originalDuration,filters:[...q.filters||[]]};q.trackId&&(_e.trackId=q.trackId),q.sourceRefId&&(_e.sourceRefId=q.sourceRefId),q.timelineEnd=G,q.sourceOut=de;const Le=i.clips.indexOf(q);i.clips.splice(Le+1,0,_e),ue(),i.selectedClipId=_e.id}function B(){W(i.playheadPosition)}function P(G){var le;const q=G??i.selectedClipId??d.value??((le=i.clips[0])==null?void 0:le.id);q&&(i.selectedClipId=q,d.value=q)}function X(){return i.selectedClipId?K(i.selectedClipId):Dt("no_selection",aa("no_selection"))}function K(G){const q=i.clips.findIndex(le=>le.id===G);return q===-1?Dt("source_not_found","Clip not found."):(y(),i.clips.splice(q,1),ue(),be(q),ke(),ja())}function be(G){if(!i.clips.length){delete i.selectedClipId,d.value=void 0;return}const q=Math.max(0,Math.min(G,i.clips.length-1)),le=i.clips[q];le&&(i.selectedClipId=le.id,d.value=le.id)}function Ne(G){return G.trackId??`legacy-track-${G.track??0}`}function ue(){const G=i.tracks;if(G)for(const q of G)q.clipIds=i.clips.filter(le=>Ne(le)===q.id).map(le=>le.id)}function re(G="video"){y();const q=i.tracks??[],le=q.reduce((_e,Le)=>Math.max(_e,Le.order),-1),de={id:x(G),type:G,name:N(G,q),order:le+1,clipIds:[]};return i.tracks=[...q,de],i.hasChanges=!0,de}function O(G){if(G.length===0)return;const q=new Set(G),le=i.clips.findIndex(de=>q.has(de.id));i.clips=i.clips.filter(de=>!q.has(de.id)),i.transitions&&i.transitions.length>0&&(i.transitions=i.transitions.filter(de=>!q.has(de.fromClipId)&&!q.has(de.toClipId))),ue(),i.selectedClipId!==void 0&&q.has(i.selectedClipId)&&be(le>=0?le:0),ke()}function D(G){const q=i.tracks??[],le=q.find(_e=>_e.id===G);if(!le)return Dt("track_missing",aa("track_missing"));if(q.length<=1)return Dt("invariant_violation","Can't delete the last remaining track. Add another track first.");y();const de=i.clips.filter(_e=>Ne(_e)===le.id).map(_e=>_e.id);return O(de),i.tracks=q.filter(_e=>_e.id!==le.id),i.hasChanges=!0,ja()}function J(G,q){const de=(i.tracks??[]).find(Le=>Le.id===G);if(!de)return Dt("track_missing",aa("track_missing"));const _e=q.trim();return _e===""?Dt("invariant_violation","Track name cannot be empty."):(de.name===_e||(y(),de.name=_e,i.hasChanges=!0),ja())}function Z(G,q){const le=i.tracks??[],de=le.find(at=>at.id===G);if(!de)return Dt("track_missing",aa("track_missing"));const _e=[...le].sort((at,ot)=>at.order-ot.order),Le=_e.findIndex(at=>at.id===de.id),Ye=q==="up"?Le+1:Le-1,We=_e[Ye];if(!We)return Dt("invariant_violation","Track is already at the edge.");y();const Pe=de.order;return de.order=We.order,We.order=Pe,i.hasChanges=!0,ja()}function ie(G){let q=i.tracks??[];if(q.length===0){const de=I([]);i.tracks=[de],q=i.tracks}if(G){const de=q.find(_e=>_e.id===G);return de?de.locked===!0?{ok:!1,reason:"track_locked"}:{ok:!0,track:de}:{ok:!1,reason:"track_missing"}}const le=q.find(de=>de.type==="video"&&de.locked!==!0)??q.find(de=>de.locked!==!0);return le?{ok:!0,track:le}:{ok:!1,reason:"no_editable_track"}}function se(G){const q=1/h.value;return typeof G.duration=="number"&&Number.isFinite(G.duration)&&G.duration>q?G.duration:i.originalDuration>q?i.originalDuration:Math.max(q,i.totalDuration)}function Ue(G){const q=i.clips.filter(le=>Ne(le)===G);return q.length>0?q.reduce((le,de)=>Math.max(le,de.timelineEnd),0):Math.max(0,Math.min(i.playheadPosition,i.totalDuration))}function me(G){const q=i.mediaSources??[],le=q.find(de=>de.id===G.id);return le||(i.mediaSources=[...q,G],i.hasChanges=!0,G)}function ve(G,q){return Ee(G,"clip",q)}function fe(G,q){if(!(i.mediaSources??[]).find(_e=>_e.id===G))return Dt("source_not_found",aa("source_not_found"));let de=q;if(!de){const _e=(i.tracks??[]).find(Le=>Le.type==="audio"&&Le.locked!==!0);de=(_e==null?void 0:_e.id)??re("audio").id}return Ee(G,"audio",de)}function Ee(G,q,le){const de=(i.mediaSources??[]).find(jt=>jt.id===G);if(!de)return Dt("source_not_found",aa("source_not_found"));const _e=ie(le);if(!_e.ok){const jt=_e.reason==="no_editable_track"?"track_missing":_e.reason;return Dt(jt,aa(jt))}const Le=_e.track;if(!Gc(q,Le.type))return Dt("track_type_mismatch",aa("track_type_mismatch"));const Ye=i.clips.filter(jt=>Ne(jt)===Le.id),We=se(de),Pe=Ue(Le.id),at=Gs({trackClips:Ye,desiredDuration:We,preferredStart:Pe});if(!at.ok)return Dt("overlap",aa("overlap"));y();const ot=la(),Ze={id:ot,type:q,trackId:Le.id,sourceRefId:de.id,timelineStart:at.start,timelineEnd:at.start+We,sourceIn:0,sourceOut:We,sourceMinIn:0,sourceMaxOut:We,speed:1};return i.clips.push(Ze),i.selectedClipId=ot,d.value=ot,ue(),ke(),ja(Ze)}function ye(G){const q=S.value,le=(i.mediaSources??[]).find(We=>We.id===G);if(!q||!le)return!1;y();const de=1/h.value,_e=se(le),Le=Math.max(de,q.timelineEnd-q.timelineStart),Ye=Math.max(de,Math.min(Le,_e));return q.sourceRefId=le.id,q.sourceIn=0,q.sourceOut=Ye,q.sourceMinIn=0,q.sourceMaxOut=_e,q.timelineEnd=q.timelineStart+Ye,ke(),!0}function Be(G){const q=i.mediaSources??[];return q.length<=1||ZE({clips:i.clips},G)?!1:(y(),i.mediaSources=q.filter(le=>le.id!==G),!0)}function Ie(G,q){const le=(i.tracks??[]).find(de=>de.id===G);return le?(y(),le[q]=le[q]!==!0,!0):!1}function et(G){return Ie(G,"locked")}function tt(G){return Ie(G,"hidden")}function Tt(G){return Ie(G,"muted")}function vt(G){return Ie(G,"solo")}function xt(G){if(i.clips.length<=1)return!1;const q=i.clips.findIndex(Le=>Le.id===G),le=q===-1?void 0:i.clips[q];if(!le)return!1;const de=Math.max(0,le.timelineEnd-le.timelineStart),_e=Ne(le);if(y(),i.clips.splice(q,1),ue(),de>0)for(const Le of i.clips)Ne(Le)!==_e||Le.timelineStart<le.timelineEnd||(Le.timelineStart=Math.max(0,Le.timelineStart-de),Le.timelineEnd=Math.max(Le.timelineStart,Le.timelineEnd-de));return i.playheadPosition>=le.timelineEnd?i.playheadPosition=Math.max(0,i.playheadPosition-de):i.playheadPosition>le.timelineStart&&(i.playheadPosition=le.timelineStart),be(q),ke(),i.hasChanges=!0,!0}function wt(){return i.selectedClipId?xt(i.selectedClipId):!1}function it(){return[...i.clips].sort((G,q)=>G.timelineStart-q.timelineStart)}function _t(G){const q=i.clips.find(Ze=>Ze.id===G);if(!q)return null;const le=Ne(q),de=it().filter(Ze=>Ne(Ze)===le),_e=de.findIndex(Ze=>Ze.id===G);if(_e===-1)return null;const Le=de[_e],Ye=Le.timelineEnd-Le.timelineStart,We=_e>0?de[_e-1]:null,Pe=_e<de.length-1?de[_e+1]:null,at=We?We.timelineEnd:0,ot=Pe?Pe.timelineStart-Ye:Math.max(Le.timelineStart,i.totalDuration-Ye);return{minStart:at,maxStart:Math.max(at,ot)}}function ge(G,q,le){const de=i.clips.find(ot=>ot.id===G);if(!de)return Dt("source_not_found","Clip not found.");if(le===void 0||le===de.trackId){const ot=_t(G),Ze=ot?Math.min(ot.maxStart,Math.max(ot.minStart,q)):Math.max(0,q);if(Ze===de.timelineStart)return ja();y();const jt=Ze-de.timelineStart;return de.timelineStart=Ze,de.timelineEnd+=jt,ke(),m.value&&m.value.moveClip(G,Ze),ja()}const Le=(i.tracks??[]).find(ot=>ot.id===le);if(!Le)return Dt("track_missing",aa("track_missing"));if(Le.locked===!0)return Dt("track_locked",aa("track_locked"));if(!Gc(de.type,Le.type))return Dt("track_type_mismatch",aa("track_type_mismatch"));const Ye=i.clips.filter(ot=>Ne(ot)===Le.id&&ot.id!==de.id),We=de.timelineEnd-de.timelineStart,Pe=Gs({trackClips:Ye,desiredDuration:We,preferredStart:Math.max(0,q),ignoreClipId:de.id});if(!Pe.ok)return Dt("overlap",aa("overlap"));y(),de.trackId=Le.id;const at=de.timelineStart;return de.timelineStart=Pe.start,de.timelineEnd=Pe.start+We,ue(),ke(),m.value&&at!==Pe.start&&m.value.moveClip(G,Pe.start),ja()}function ke(){if(i.clips.length===0){i.totalDuration=0;return}const G=i.clips.reduce((q,le)=>le.timelineEnd>q.timelineEnd?le:q);i.totalDuration=G.timelineEnd}function Te(){i.zoomLevel=Math.min(200,i.zoomLevel*1.2)}function Ke(){i.zoomLevel=Math.max(10,i.zoomLevel/1.2)}function Ge(G){i.zoomLevel=Math.max(10,Math.min(600,Math.round(G)))}function Oe(){i.isPlaying=!i.isPlaying}function kt(G){i.isPlaying=G}function lt(G){i.playheadPosition=Math.max(0,Math.min(G,i.totalDuration))}function zt(){const G=Zc(i);try{localStorage.setItem(`video-draft-${n}`,JSON.stringify(G))}catch{}return G}function At(){i.hasChanges=!1}function Jt(){return confirm("Are you sure you want to reset all changes?")?(y(),$(),i.hasChanges=!1,!0):!1}function Gt(){return Zc(i)}function la(){return`clip-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}async function ga(G=1920,q=1080){if(u.value)try{m.value=new Nm(G,q,h.value),await ia()}catch{m.value=null}}async function ia(){if(!(!m.value||w.value)){w.value=!0;try{const G=Gt();await m.value.loadFromRecipe(G);const q=p.secondsToFrames(i.playheadPosition);m.value.seek(q)}catch{}finally{w.value=!1}}}function Aa(G){}function F(G){return p.secondsToFrames(G)}function Y(G){return p.framesToSeconds(G)}function j(G){const q=Y(G);lt(q),m.value&&m.value.seek(G)}function ee(){v.value=!v.value}function we(){ia()}function Ve(G){u.value=!1,m.value=null}e.watch(()=>i.clips,()=>{i.hasChanges=!0,u.value&&m.value&&ia()},{deep:!0}),e.watch(()=>i.filters,()=>{i.hasChanges=!0,u.value&&m.value&&ia()},{deep:!0}),e.watch(()=>i.clips.map(G=>G.id),()=>{var q;if(!i.clips.length){delete i.selectedClipId,d.value=void 0;return}if(!i.clips.some(le=>le.id===i.selectedClipId)){const le=d.value&&((q=i.clips.find(de=>de.id===d.value))==null?void 0:q.id);i.selectedClipId=le??i.clips[0].id,d.value=i.selectedClipId}},{deep:!0});function Je(G){const q=i.selectedClipId?i.clips.find(le=>le.id===i.selectedClipId):i.clips[0];q&&(q.filters=[...G],i.hasChanges=!0)}function ut(G){i.textOverlays=[...G]}function St(G){i.audioTracks=[...G]}function pt(G){i.captionTracks=G.map(Ma),i.hasChanges=!0}function ft(G){i.visualLayers=G.map(q=>({...q})),i.hasChanges=!0}function Mt(G){i.transitions=G.map(q=>{const le={...q};return q.params&&(le.params={...q.params}),le}),i.hasChanges=!0}function Bt(G,q){const le=i.clips.find(de=>de.id===G);le&&(le.keyframes=q.map(de=>({...de})),i.hasChanges=!0)}function It(G){y(),T(G),i.hasChanges=!0}function Ma(G){return{...G,segments:G.segments.map(q=>{const le={...q};return q.words&&(le.words=q.words.map(de=>({...de}))),le})}}e.watch(u,G=>{G?ga():m.value&&(m.value.destroy(),m.value=null)}),e.watch(v,()=>{}),e.watch(h,G=>{p.setFps(G)});function ba(){if(!i.selectedClipId)return Dt("no_selection",aa("no_selection"));const G=i.clips.find(We=>We.id===i.selectedClipId);if(!G)return Dt("no_selection",aa("no_selection"));const q=Ne(G),le=i.clips.filter(We=>Ne(We)===q),de=G.timelineEnd-G.timelineStart,_e=Gs({trackClips:le,desiredDuration:de,preferredStart:G.timelineEnd});if(!_e.ok)return Dt("overlap",aa("overlap"));y();const Le={...G,id:la(),timelineStart:_e.start,timelineEnd:_e.start+de,filters:[...G.filters||[]]},Ye=i.clips.indexOf(G);return i.clips.splice(Ye+1,0,Le),ue(),i.selectedClipId=Le.id,i.hasChanges=!0,ja(Le)}function da(G){const q=G??800,le=i.totalDuration;if(le<=0){i.zoomLevel=50;return}const de=q*.8/le;i.zoomLevel=Math.max(10,Math.min(600,Math.round(de)))}function ca(){const G=1/h.value;lt(Math.min(i.playheadPosition+G,i.totalDuration))}function qt(){const G=1/h.value;lt(Math.max(i.playheadPosition-G,0))}function gt(){lt(0)}function bt(){lt(i.totalDuration)}function Yt(G){if(!Number.isFinite(G)||G<=0)return;const q=S.value??i.clips[0];if(!q){E.value=G;return}const le=q.speed??1;if(le===G){E.value=G;return}y();const de=Math.max(1/h.value,q.sourceOut-q.sourceIn),_e=de/le,Le=de/G,Ye=Le-_e;q.speed=G,q.timelineEnd=q.timelineStart+Le;const We=i.clips.findIndex(Pe=>Pe.id===q.id);if(We!==-1&&Ye!==0)for(let Pe=We+1;Pe<i.clips.length;Pe+=1){const at=i.clips[Pe];at.timelineStart+=Ye,at.timelineEnd+=Ye}ke(),i.playheadPosition=Math.max(0,Math.min(i.playheadPosition,i.totalDuration)),i.hasChanges=!0,E.value=G}return{currentFrame:r,playheadPosition:e.computed(()=>i.playheadPosition),timelineClips:e.computed(()=>i.clips),tracks:e.computed(()=>i.tracks??[]),mediaSources:e.computed(()=>i.mediaSources??[]),transitions:e.computed(()=>i.transitions??[]),totalDuration:e.computed(()=>i.totalDuration),hasChanges:e.computed(()=>i.hasChanges),isPlaying:e.computed(()=>i.isPlaying),selectedClip:S,zoomLevel:e.computed(()=>i.zoomLevel),playbackSpeed:E,useVideoEngine:u,compositionAdapter:e.computed(()=>m.value),fps:h,useFrameMode:v,handleTrim:z,handleSplit:W,handleClipSelect:P,splitAtPlayhead:B,deleteSelectedClip:X,deleteClip:K,rippleDeleteClip:xt,rippleDeleteSelectedClip:wt,duplicateSelectedClip:ba,addTimelineTrack:re,deleteTimelineTrack:D,renameTimelineTrack:J,reorderTimelineTrack:Z,appendMediaSourceToTimeline:ve,appendAudioSourceToTimeline:fe,registerMediaSource:me,replaceSelectedClipSource:ye,removeMediaSource:Be,toggleTrackLock:et,toggleTrackHidden:tt,toggleTrackMuted:Tt,toggleTrackSolo:vt,setFilters:Je,setTextOverlays:ut,setAudioTracks:St,setCaptionTracks:pt,setVisualLayers:ft,setTransitions:Mt,setClipKeyframes:Bt,loadRecipe:It,moveClip:ge,saveDraft:zt,clearHasChanges:At,resetChanges:Jt,generateRecipe:Gt,zoomIn:Te,zoomOut:Ke,setZoomLevel:Ge,fitToWindow:da,togglePlayback:Oe,setPlaying:kt,seekTo:lt,frameForward:ca,frameBackward:qt,skipToStart:gt,skipToEnd:bt,setPlaybackSpeed:Yt,updateSourceDuration:C,undo:R,redo:U,canUndo:k,canRedo:b,initializeComposition:ga,syncCompositionWithState:ia,syncWithComposition:Aa,convertToFrames:F,convertToSeconds:Y,seekToFrame:j,toggleFrameMode:ee,onCompositionReady:we,onCompositionError:Ve}}const GE=[{id:"brightness",name:"Brightness",category:"color",ffmpeg:"eq=brightness={value}",pixiFilter:"AdjustmentFilter",defaultParams:{value:0},paramRanges:{value:{min:-1,max:1,step:.05}}},{id:"contrast",name:"Contrast",category:"color",ffmpeg:"eq=contrast={value}",pixiFilter:"AdjustmentFilter",defaultParams:{value:1},paramRanges:{value:{min:.5,max:2,step:.05}}},{id:"saturation",name:"Saturation",category:"color",ffmpeg:"eq=saturation={value}",pixiFilter:"AdjustmentFilter",defaultParams:{value:1},paramRanges:{value:{min:0,max:2,step:.05}}},{id:"hue",name:"Hue Shift",category:"color",ffmpeg:"hue=h={value}",pixiFilter:"HueRotateFilter",defaultParams:{value:0},paramRanges:{value:{min:-180,max:180,step:5}}},{id:"gaussian-blur",name:"Gaussian Blur",category:"blur",ffmpeg:"gblur=sigma={value}",pixiFilter:"BlurFilter",defaultParams:{value:2},paramRanges:{value:{min:0,max:10,step:.5}}},{id:"motion-blur",name:"Motion Blur",category:"blur",ffmpeg:"minterpolate=fps=60:mi_mode=mci:mc_mode=aobmc:me_mode=bidir:me=epzs:vsbmc=1",pixiFilter:"MotionBlurFilter",defaultParams:{velocity:5,angle:0},paramRanges:{velocity:{min:0,max:20,step:1},angle:{min:0,max:360,step:15}}},{id:"vintage",name:"Vintage",category:"stylize",ffmpeg:"curves=preset=vintage",pixiFilter:"ColorMatrixFilter",defaultParams:{preset:"vintage"},paramRanges:{}},{id:"sepia",name:"Sepia",category:"stylize",ffmpeg:"colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131",pixiFilter:"ColorMatrixFilter",defaultParams:{preset:"sepia"},paramRanges:{}},{id:"grayscale",name:"Black & White",category:"stylize",ffmpeg:"colorchannelmixer=0.3:0.59:0.11:0:0.3:0.59:0.11:0:0.3:0.59:0.11",pixiFilter:"ColorMatrixFilter",defaultParams:{preset:"grayscale"},paramRanges:{}},{id:"vignette",name:"Vignette",category:"effects",ffmpeg:"vignette=a={value}",pixiFilter:"VignetteFilter",defaultParams:{value:.3},paramRanges:{value:{min:0,max:1,step:.05}}},{id:"sharpen",name:"Sharpen",category:"effects",ffmpeg:"unsharp=5:5:{value}:5:5:0",pixiFilter:"SharpenFilter",defaultParams:{value:1},paramRanges:{value:{min:0,max:5,step:.25}}},{id:"denoise",name:"Noise Reduction",category:"effects",ffmpeg:"nlmeans=s={value}",pixiFilter:"NoiseFilter",defaultParams:{value:1},paramRanges:{value:{min:.1,max:5,step:.1}}},{id:"motion-blur",name:"Motion Blur",category:"effects",ffmpeg:"minterpolate=fps=30:mi_mode=blend",pixiFilter:"MotionBlurFilter",defaultParams:{velocity:[0,0],kernelSize:5},paramRanges:{velocityX:{min:-100,max:100,step:1},velocityY:{min:-100,max:100,step:1},kernelSize:{min:3,max:15,step:2}}},{id:"radial-blur",name:"Radial Blur",category:"effects",ffmpeg:"boxblur={radius}:{radius}",pixiFilter:"RadialBlurFilter",defaultParams:{radius:.1,angle:0,kernelSize:5},paramRanges:{radius:{min:0,max:1,step:.01},angle:{min:-180,max:180,step:1},kernelSize:{min:3,max:15,step:2}}},{id:"kawase-blur",name:"Kawase Blur",category:"effects",ffmpeg:"gblur=sigma={blur}:steps={quality}",pixiFilter:"KawaseBlurFilter",defaultParams:{blur:4,quality:3},paramRanges:{blur:{min:0,max:20,step:.5},quality:{min:1,max:10,step:1}}},{id:"flip-horizontal",name:"Flip Horizontal",category:"transform",ffmpeg:"hflip",pixiFilter:"FlipFilter",defaultParams:{horizontal:!0},paramRanges:{}},{id:"flip-vertical",name:"Flip Vertical",category:"transform",ffmpeg:"vflip",pixiFilter:"FlipFilter",defaultParams:{vertical:!0},paramRanges:{}},{id:"rotate",name:"Rotate",category:"transform",ffmpeg:"rotate={value}*PI/180",pixiFilter:"RotateFilter",defaultParams:{value:0},paramRanges:{value:{min:-180,max:180,step:15}}}],XE={dropShadow:"drop-shadow",softFocus:"blur",blackAndWhite:"grayscale",gaussianBlur:"blur","gaussian-blur":"blur"};function us(o){return typeof o=="object"&&o!==null}function KE(o,a){if(typeof o=="number"&&Number.isFinite(o))return o;if(typeof o=="string"){const t=Number(o);if(Number.isFinite(t))return t}return a}function ms(o){if(typeof o=="number"||typeof o=="string"||typeof o=="boolean")return o}function JE(o){const a={id:o.id,type:o.type,label:o.label};o.property!==void 0&&(a.property=o.property),o.min!==void 0&&(a.min=o.min),o.max!==void 0&&(a.max=o.max),o.step!==void 0&&(a.step=o.step);const t=ms(o.default);return t!==void 0&&(a.default=t),o.options!==void 0&&(a.options=o.options),a}function dp(o,a,t){const n=oe.getFilter(o),i={},r=(n==null?void 0:n.defaultParams)??t;if(r&&us(r))for(const[s,l]of Object.entries(r))i[s]=ms(l)??null;for(const s of a){const l=s.property??s.id;i[l]===void 0&&s.default!==void 0&&(i[l]=s.default)}return i}function cp(o){const a={};for(const t of o){if(t.type!=="slider")continue;const n=t.property??t.id;a[n]={min:t.min??0,max:t.max??100,step:t.step??1}}return a}function qE(o,a,t,n){const i=n.map(JE);return{id:o,name:a,category:t,controls:i,params:i,defaultParams:dp(o,i),paramRanges:cp(i)}}function YE(o){const a=o.paramRanges??{},t=Object.entries(a).map(([n,i])=>{var l;const r={id:n,type:"slider",label:n.replace(/[-_]/g," ").replace(/\b\w/g,d=>d.toUpperCase()),property:n,min:i.min,max:i.max,step:i.step},s=ms((l=o.defaultParams)==null?void 0:l[n]);return s!==void 0&&(r.default=s),r});return{id:o.id,name:o.name,category:o.category,controls:t,params:t,defaultParams:dp(o.id,t,o.defaultParams),paramRanges:cp(t)}}function QE(o,a){return a.toLowerCase()==="unlisted"?!1:oe.isFilterCompatibleWithMedia(o,"video")}function Xs(o){return XE[o]??o}function si(o){const a=KE(o,1);return Math.max(0,Math.min(1,a))}function li(o){if(!us(o))return{};const a={};for(const[t,n]of Object.entries(o))a[t]=ms(n)??null;return a}function ex(o){return!us(o)||typeof o.filterId!="string"?null:{filterId:o.filterId,params:li(o.params),intensity:si(o.intensity)}}function tx(o){if(!us(o)||typeof o.id!="string"||typeof o.name!="string")return null;const t=(Array.isArray(o.filters)?o.filters:[]).map(i=>ex(i)).filter(i=>i!==null),n=typeof o.created_at=="string"?o.created_at:new Date().toISOString();return{id:o.id,name:o.name,filters:t,created_at:n}}function up(){oe.initializeFilterRegistry();const o=e.ref([]),a=e.ref(null),t=e.ref(null),n=e.ref([]),i=e.ref(null),r=e.reactive({}),s=e.computed(()=>{const y=new Map,R=oe.getRegisteredFilters();for(const U of R)QE(U.id,U.category)&&y.set(U.id,qE(U.id,U.name,U.category,U.controls));for(const U of GE)y.has(U.id)||y.set(U.id,YE(U));return Array.from(y.values())}),l=e.computed(()=>{const y=new Map;for(const R of s.value)y.set(R.id,R);return y}),d=e.computed(()=>o.value.length>0),c=e.computed(()=>{const y={};for(const R of s.value)y[R.category]||(y[R.category]=[]),y[R.category].push(R);return y});function u(y){const R=l.value.get(y);if(R)return R;const U=Xs(y);return l.value.get(U)??null}function f(y){const R=l.value.get(y);if(R)return R.id;const U=Xs(y),z=l.value.get(U);return z?z.id:null}function m(y){const R=y?u(y):a.value;if(!R)return;const U=R.defaultParams||{},z={id:N(),filterId:R.id,params:{...U},intensity:1};return o.value.push(z),i.value=z.id,a.value=R,Object.keys(r).forEach(W=>delete r[W]),Object.assign(r,z.params),t.value=null,z}function p(y){const R=u(y);if(!R)return;a.value=R;const U=R.defaultParams||C(y);Object.assign(r,U),t.value={id:"preview",filterId:R.id,params:{...U},intensity:1}}function h(y){if(Object.assign(r,y),t.value&&(t.value.params={...r}),i.value){const R=o.value.find(U=>U.id===i.value);R&&(R.params={...r})}}function v(y){const R=o.value.findIndex(U=>U.id===y);R!==-1&&o.value.splice(R,1)}function w(y,R){if(y<0||y>=o.value.length||R<0||R>=o.value.length)return;const[U]=o.value.splice(y,1);o.value.splice(R,0,U)}function E(y,R){const U=o.value.find(z=>z.id===y);U&&(U.intensity=Math.max(0,Math.min(1,R)))}function S(y){const R=o.value.find(U=>U.id===y);R&&(R.intensity=R.intensity>0?0:1)}function k(){o.value=[],t.value=null,a.value=null,i.value=null,Object.keys(r).forEach(y=>delete r[y])}function b(y){const R={id:L(),name:y,filters:o.value.map(z=>({filterId:z.filterId,params:li(z.params),intensity:si(z.intensity)})),created_at:new Date().toISOString()};n.value.push(R);const U=n.value.map(z=>({...z}));return localStorage.setItem("video-filter-presets",JSON.stringify(U)),R}function $(y){const R=n.value.find(U=>U.id===y);if(R){k();for(const U of R.filters){const z=u(U.filterId);z&&o.value.push({id:N(),filterId:z.id,params:{...U.params},intensity:si(U.intensity)})}}}function V(y){const R=n.value.findIndex(U=>U.id===y);R!==-1&&(n.value.splice(R,1),localStorage.setItem("video-filter-presets",JSON.stringify(n.value)))}function I(){try{const y=localStorage.getItem("video-filter-presets");if(!y)return;const R=JSON.parse(y);if(!Array.isArray(R))return;n.value=R.map(U=>tx(U)).filter(U=>U!==null)}catch{}}function x(){if(o.value.length===0)return"No filters applied";const y=o.value.map(R=>{const U=T(R.filterId);return(U==null?void 0:U.name)||R.filterId});return y.length===1?y[0]:y.length===2?`${y[0]} + ${y[1]}`:`${y[0]} + ${y.length-1} more`}function N(){return`filter-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function L(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function C(y){const R=u(y);return R?R.defaultParams||{}:{}}function T(y){return u(y)}return I(),{videoCompatibleFilters:s,activeFilters:o,selectedFilter:a,previewFilter:t,filterPresets:n,filterParams:r,hasActiveFilters:d,filtersByCategory:c,applyFilter:m,previewFilterEffect:p,updateFilterParams:h,removeFilter:v,reorderFilters:w,updateFilterIntensity:E,toggleFilter:S,clearAllFilters:k,saveFilterPreset:b,loadFilterPreset:$,deleteFilterPreset:V,getFilterSummary:x,setActiveFilters(y){var U;const R=[];for(const z of y){const W=f(z.filterId);if(!W){const B=Xs(z.filterId);R.push({...z,filterId:B,params:li(z.params),intensity:si(z.intensity)});continue}R.push({...z,filterId:W,params:li(z.params),intensity:si(z.intensity)})}o.value=R,i.value=((U=o.value[0])==null?void 0:U.id)??null,Object.keys(r).forEach(z=>delete r[z]),o.value[0]&&Object.assign(r,li(o.value[0].params))}}}class mp{constructor(a){this.textClips=new Map,this.overlayConfigs=new Map,this.fonts=new Map,this.nextId=0,this.composition=a,this.initializeDefaultFonts()}initializeDefaultFonts(){try{this.fonts.set("default",new na({source:"https://fonts.googleapis.com/css2?family=Inter:wght@400",family:"Inter",weight:"400"})),this.fonts.set("bold",new na({source:"https://fonts.googleapis.com/css2?family=Inter:wght@700",family:"Inter",weight:"700"})),this.fonts.set("serif",new na({source:"https://fonts.googleapis.com/css2?family=Merriweather:wght@400",family:"Merriweather",weight:"400"}))}catch{}}async loadWebFont(a,t,n,i="400"){const r=new na({source:t,family:n,weight:i});this.fonts.set(a,r)}loadLocalFont(a,t,n="400"){const i=new na({source:`local('${t}')`,family:t,weight:n});this.fonts.set(a,i)}async addTextOverlay(a){const t=`text-overlay-${this.nextId++}`,n=this.buildTextClipConfig(a),i=new Mo(n);return await this.composition.add(i),this.textClips.set(t,i),this.overlayConfigs.set(t,{...a}),t}buildTextClipConfig(a){const t={text:a.text,fontSize:a.fontSize||24,fillStyle:a.color||"#ffffff",textAlign:a.textAlign||"center",textBaseline:a.textBaseline||"middle"},n=a.fontFamily||"default",i=this.fonts.get(n)||this.fonts.get("default");if(i&&(t.font=i),this.applyPosition(t,a.position),a.startTime!==void 0&&(t.start=Re.fromSeconds(a.startTime)),a.duration!==void 0){const r=a.startTime||0;t.stop=Re.fromSeconds(r+a.duration)}return a.animation&&this.applyAnimation(t,a.animation,a),t}applyPosition(a,t){if(!t){a.position="center";return}if(typeof t!="string"){a.x=t.x,a.y=t.y;return}switch(t){case"center":a.position="center";break;case"top":a.x="50%",a.y="10%";break;case"bottom":a.x="50%",a.y="90%";break;case"left":a.x="10%",a.y="50%";break;case"right":a.x="90%",a.y="50%";break}}applyAnimation(a,t,n){if(!t)return;const i=n.startTime?Math.round(n.startTime*30):0,r=t.duration||1,s=Math.round(r*30),l=i+s,d=t.easing||"linear";switch(t.type){case"fade-in":a.alpha=new ze([i,l],[0,1],{easing:d});break;case"fade-out":a.alpha=new ze([i,l],[1,0],{easing:d});break;case"rotate":t.rotation&&(a.rotation=new ze([i,l],[t.rotation.from,t.rotation.to],{easing:d}));break;case"scale":t.scale&&(a.scale=new ze([i,l],[t.scale.from,t.scale.to],{easing:d}));break;case"slide":t.translate&&(a.translate={x:new ze([i,l],[t.translate.fromX,t.translate.toX],{easing:d}),y:new ze([i,l],[t.translate.fromY,t.translate.toY],{easing:d})});break;case"typewriter":a.alpha=new ze([i,l],[0,1],{easing:"linear"});break;case"custom":t.rotation&&(a.rotation=new ze([i,l],[t.rotation.from,t.rotation.to],{easing:d})),t.scale&&(a.scale=new ze([i,l],[t.scale.from,t.scale.to],{easing:d})),t.translate&&(a.translate={x:new ze([i,l],[t.translate.fromX,t.translate.toX],{easing:d}),y:new ze([i,l],[t.translate.fromY,t.translate.toY],{easing:d})});break}}async updateTextOverlay(a,t){const n=this.textClips.get(a);if(!n)throw new Error(`Text overlay with id ${a} not found`);const i=this.overlayConfigs.get(a);if(!i)throw new Error(`Text overlay with id ${a} is missing config`);const r={...i,...t};n.set(this.buildTextClipConfig(r)),this.overlayConfigs.set(a,r)}async removeTextOverlay(a){const t=this.textClips.get(a);if(!t)throw new Error(`Text overlay with id ${a} not found`);const n=this.composition.tracks;for(const i of n){const r=i.clips.indexOf(t);if(r!==-1){i.clips.splice(r,1);break}}this.textClips.delete(a),this.overlayConfigs.delete(a)}getTextOverlays(){return new Map(this.textClips)}async clearAllTextOverlays(){const a=Array.from(this.textClips.keys());for(const t of a)await this.removeTextOverlay(t)}getOverlays(){return Array.from(this.overlayConfigs.entries()).map(([a,t])=>({id:a,config:{...t}}))}async addCaptions(a,t="classic",n){var d;const r={classic:Fi,cascade:is,guinea:os,solar:rs,spotlight:$i,whisper:Di}[t],s=await this.composition.createTrack("caption"),l=new Yr({transcript:a});if(await s.add(l),await((d=s.generate)==null?void 0:d.call(s,r)),n&&s.clips.length>0){const c=s.clips[0];c==null||c.set(n)}}}class pp{constructor(a){this.audioLayers=new Map,this.audioSources=new Map,this.nextId=0,this.masterVolume=1,this.composition=a}async loadAudioSource(a,t){try{const n=await _n.from(a),i=t||`audio-source-${this.nextId++}`;return this.audioSources.set(i,n),n}catch(n){throw n instanceof Error?n:new Error("Failed to load audio source")}}async addBackgroundMusic(a){return this.addAudioTrack({...a,name:a.name||"Background Music"})}async addAudioTrack(a){const t=`audio-track-${this.nextId++}`,n=await this.resolveAudioSource(a.source),i=this.createAudioClipConfig(a,n),r=new fi(i);let s=this.findAudioTrack();s||(s=await this.composition.createTrack("audio")),await s.add(r);const l={id:t,name:a.name||`Audio Track ${this.audioLayers.size+1}`,clip:r,track:s,config:a};return this.audioLayers.set(t,l),t}async resolveAudioSource(a){try{if(a instanceof _n)return a;if(typeof a=="string"&&a.trim()!=="")return await _n.from(a);if(a instanceof File)return await _n.from(URL.createObjectURL(a));throw new Error("Invalid audio source")}catch(t){throw t instanceof Error?t:new Error("Failed to create audio source")}}createAudioClipConfig(a,t){const n={source:t,volume:(a.volume??1)*this.masterVolume};if(a.startTime!==void 0&&(n.start=Re.fromSeconds(a.startTime)),a.duration!==void 0){const i=a.startTime||0;n.stop=Re.fromSeconds(i+a.duration)}return(a.fadeIn||a.fadeOut)&&(n.volume=this.createVolumeKeyframes(a)),n}findAudioTrack(){return this.composition.tracks.find(a=>a.kind==="audio")}removeClipFromTrack(a,t){const n=a.clips.indexOf(t);n!==-1&&a.clips.splice(n,1)}createVolumeKeyframes(a){const t=(a.volume??1)*this.masterVolume,n=a.startTime?Math.round(a.startTime*30):0,i=a.duration,r=[],s=[];if(a.fadeIn){const l=Math.round(a.fadeIn*30);r.push(n,n+l),s.push(0,t)}else r.push(n),s.push(t);if(a.fadeOut&&i){const l=n+Math.round(i*30),d=Math.round(a.fadeOut*30);a.fadeIn||(r.push(l-d),s.push(t)),r.push(l),s.push(0)}return new ze(r,s,{easing:"linear"})}async updateVolume(a,t){const n=this.audioLayers.get(a);if(!n)throw new Error(`Audio track with id ${a} not found`);const i=Math.max(0,Math.min(1,t));n.config.volume=i,n.clip.set({volume:this.resolveLayerVolume(n.config)})}async updateAudioTrack(a,t){const n=this.audioLayers.get(a);if(!n)throw new Error(`Audio track with id ${a} not found`);const i={...n.config,...t,source:t.source??n.config.source},r=await this.resolveAudioSource(i.source),s=new fi(this.createAudioClipConfig(i,r));this.removeClipFromTrack(n.track,n.clip),await n.track.add(s),n.clip=s,n.config=i,n.name=i.name||n.name}async applyFadeIn(a,t){const n=this.audioLayers.get(a);if(!n)throw new Error(`Audio track with id ${a} not found`);n.config.fadeIn=t,n.clip.set({volume:this.resolveLayerVolume(n.config)})}async applyFadeOut(a,t){const n=this.audioLayers.get(a);if(!n)throw new Error(`Audio track with id ${a} not found`);n.config.fadeOut=t,n.clip.set({volume:this.resolveLayerVolume(n.config)})}async removeAudioTrack(a){const t=this.audioLayers.get(a);if(!t)throw new Error(`Audio track with id ${a} not found`);this.removeClipFromTrack(t.track,t.clip),this.audioLayers.delete(a)}async muteTrack(a,t){const n=this.audioLayers.get(a);if(!n)throw new Error(`Audio track with id ${a} not found`);t?n.clip.set({volume:0}):n.clip.set({volume:this.resolveLayerVolume(n.config)})}setMasterVolume(a){this.masterVolume=Math.max(0,Math.min(1,a));for(const t of this.audioLayers.values())t.clip.set({volume:this.resolveLayerVolume(t.config)})}resolveLayerVolume(a){return a.fadeIn||a.fadeOut?this.createVolumeKeyframes(a):(a.volume??1)*this.masterVolume}getMasterVolume(){return this.masterVolume}getAudioLayers(){return Array.from(this.audioLayers.values())}getAudioLayer(a){return this.audioLayers.get(a)}async clearAllAudioTracks(){const a=Array.from(this.audioLayers.keys());for(const t of a)await this.removeAudioTrack(t)}async syncWithVideo(a,t){for(const n of this.audioLayers.values()){const i=n.config.startTime||0,r=n.config.duration||t-a;if(i+r>t){n.config.duration=t-i;const s=new fi(this.createAudioClipConfig(n.config,n.clip.source)),l=n.track.clips.indexOf(n.clip);l!==-1&&(n.track.clips[l]=s,n.clip=s)}}}exportConfiguration(){return Array.from(this.audioLayers.values()).map(a=>({id:a.id,name:a.name,config:{...a.config,source:a.config.source&&typeof a.config.source=="object"&&"type"in a.config.source?"[AudioSource]":a.config.source}}))}async importConfiguration(a){for(const{name:t,config:n}of a)await this.addAudioTrack({...n,name:t})}}function fp(o,a){return function(){return o.apply(a,arguments)}}const{toString:ax}=Object.prototype,{getPrototypeOf:Ed}=Object,{iterator:ps,toStringTag:hp}=Symbol,fs=(o=>a=>{const t=ax.call(a);return o[t]||(o[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Ra=o=>(o=o.toLowerCase(),a=>fs(a)===o),hs=o=>a=>typeof a===o,{isArray:Do}=Array,Ci=hs("undefined");function Ai(o){return o!==null&&!Ci(o)&&o.constructor!==null&&!Ci(o.constructor)&&fa(o.constructor.isBuffer)&&o.constructor.isBuffer(o)}const vp=Ra("ArrayBuffer");function nx(o){let a;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?a=ArrayBuffer.isView(o):a=o&&o.buffer&&vp(o.buffer),a}const ox=hs("string"),fa=hs("function"),gp=hs("number"),Li=o=>o!==null&&typeof o=="object",ix=o=>o===!0||o===!1,xr=o=>{if(fs(o)!=="object")return!1;const a=Ed(o);return(a===null||a===Object.prototype||Object.getPrototypeOf(a)===null)&&!(hp in o)&&!(ps in o)},rx=o=>{if(!Li(o)||Ai(o))return!1;try{return Object.keys(o).length===0&&Object.getPrototypeOf(o)===Object.prototype}catch{return!1}},sx=Ra("Date"),lx=Ra("File"),dx=Ra("Blob"),cx=Ra("FileList"),ux=o=>Li(o)&&fa(o.pipe),mx=o=>{let a;return o&&(typeof FormData=="function"&&o instanceof FormData||fa(o.append)&&((a=fs(o))==="formdata"||a==="object"&&fa(o.toString)&&o.toString()==="[object FormData]"))},px=Ra("URLSearchParams"),[fx,hx,vx,gx]=["ReadableStream","Request","Response","Headers"].map(Ra),bx=o=>o.trim?o.trim():o.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Pi(o,a,{allOwnKeys:t=!1}={}){if(o===null||typeof o>"u")return;let n,i;if(typeof o!="object"&&(o=[o]),Do(o))for(n=0,i=o.length;n<i;n++)a.call(null,o[n],n,o);else{if(Ai(o))return;const r=t?Object.getOwnPropertyNames(o):Object.keys(o),s=r.length;let l;for(n=0;n<s;n++)l=r[n],a.call(null,o[l],l,o)}}function bp(o,a){if(Ai(o))return null;a=a.toLowerCase();const t=Object.keys(o);let n=t.length,i;for(;n-- >0;)if(i=t[n],a===i.toLowerCase())return i;return null}const Wn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,yp=o=>!Ci(o)&&o!==Wn;function Pl(){const{caseless:o}=yp(this)&&this||{},a={},t=(n,i)=>{const r=o&&bp(a,i)||i;xr(a[r])&&xr(n)?a[r]=Pl(a[r],n):xr(n)?a[r]=Pl({},n):Do(n)?a[r]=n.slice():a[r]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&Pi(arguments[n],t);return a}const yx=(o,a,t,{allOwnKeys:n}={})=>(Pi(a,(i,r)=>{t&&fa(i)?o[r]=fp(i,t):o[r]=i},{allOwnKeys:n}),o),wx=o=>(o.charCodeAt(0)===65279&&(o=o.slice(1)),o),kx=(o,a,t,n)=>{o.prototype=Object.create(a.prototype,n),o.prototype.constructor=o,Object.defineProperty(o,"super",{value:a.prototype}),t&&Object.assign(o.prototype,t)},_x=(o,a,t,n)=>{let i,r,s;const l={};if(a=a||{},o==null)return a;do{for(i=Object.getOwnPropertyNames(o),r=i.length;r-- >0;)s=i[r],(!n||n(s,o,a))&&!l[s]&&(a[s]=o[s],l[s]=!0);o=t!==!1&&Ed(o)}while(o&&(!t||t(o,a))&&o!==Object.prototype);return a},Ex=(o,a,t)=>{o=String(o),(t===void 0||t>o.length)&&(t=o.length),t-=a.length;const n=o.indexOf(a,t);return n!==-1&&n===t},xx=o=>{if(!o)return null;if(Do(o))return o;let a=o.length;if(!gp(a))return null;const t=new Array(a);for(;a-- >0;)t[a]=o[a];return t},Sx=(o=>a=>o&&a instanceof o)(typeof Uint8Array<"u"&&Ed(Uint8Array)),Cx=(o,a)=>{const n=(o&&o[ps]).call(o);let i;for(;(i=n.next())&&!i.done;){const r=i.value;a.call(o,r[0],r[1])}},Vx=(o,a)=>{let t;const n=[];for(;(t=o.exec(a))!==null;)n.push(t);return n},Nx=Ra("HTMLFormElement"),Tx=o=>o.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,n,i){return n.toUpperCase()+i}),Xc=(({hasOwnProperty:o})=>(a,t)=>o.call(a,t))(Object.prototype),Bx=Ra("RegExp"),wp=(o,a)=>{const t=Object.getOwnPropertyDescriptors(o),n={};Pi(t,(i,r)=>{let s;(s=a(i,r,o))!==!1&&(n[r]=s||i)}),Object.defineProperties(o,n)},Ix=o=>{wp(o,(a,t)=>{if(fa(o)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const n=o[t];if(fa(n)){if(a.enumerable=!1,"writable"in a){a.writable=!1;return}a.set||(a.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},Mx=(o,a)=>{const t={},n=i=>{i.forEach(r=>{t[r]=!0})};return Do(o)?n(o):n(String(o).split(a)),t},Fx=()=>{},$x=(o,a)=>o!=null&&Number.isFinite(o=+o)?o:a;function Dx(o){return!!(o&&fa(o.append)&&o[hp]==="FormData"&&o[ps])}const Rx=o=>{const a=new Array(10),t=(n,i)=>{if(Li(n)){if(a.indexOf(n)>=0)return;if(Ai(n))return n;if(!("toJSON"in n)){a[i]=n;const r=Do(n)?[]:{};return Pi(n,(s,l)=>{const d=t(s,i+1);!Ci(d)&&(r[l]=d)}),a[i]=void 0,r}}return n};return t(o,0)},Ax=Ra("AsyncFunction"),Lx=o=>o&&(Li(o)||fa(o))&&fa(o.then)&&fa(o.catch),kp=((o,a)=>o?setImmediate:a?((t,n)=>(Wn.addEventListener("message",({source:i,data:r})=>{i===Wn&&r===t&&n.length&&n.shift()()},!1),i=>{n.push(i),Wn.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",fa(Wn.postMessage)),Px=typeof queueMicrotask<"u"?queueMicrotask.bind(Wn):typeof process<"u"&&process.nextTick||kp,Ux=o=>o!=null&&fa(o[ps]),ce={isArray:Do,isArrayBuffer:vp,isBuffer:Ai,isFormData:mx,isArrayBufferView:nx,isString:ox,isNumber:gp,isBoolean:ix,isObject:Li,isPlainObject:xr,isEmptyObject:rx,isReadableStream:fx,isRequest:hx,isResponse:vx,isHeaders:gx,isUndefined:Ci,isDate:sx,isFile:lx,isBlob:dx,isRegExp:Bx,isFunction:fa,isStream:ux,isURLSearchParams:px,isTypedArray:Sx,isFileList:cx,forEach:Pi,merge:Pl,extend:yx,trim:bx,stripBOM:wx,inherits:kx,toFlatObject:_x,kindOf:fs,kindOfTest:Ra,endsWith:Ex,toArray:xx,forEachEntry:Cx,matchAll:Vx,isHTMLForm:Nx,hasOwnProperty:Xc,hasOwnProp:Xc,reduceDescriptors:wp,freezeMethods:Ix,toObjectSet:Mx,toCamelCase:Tx,noop:Fx,toFiniteNumber:$x,findKey:bp,global:Wn,isContextDefined:yp,isSpecCompliantForm:Dx,toJSONObject:Rx,isAsyncFn:Ax,isThenable:Lx,setImmediate:kp,asap:Px,isIterable:Ux};function Xe(o,a,t,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=o,this.name="AxiosError",a&&(this.code=a),t&&(this.config=t),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}ce.inherits(Xe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ce.toJSONObject(this.config),code:this.code,status:this.status}}});const _p=Xe.prototype,Ep={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(o=>{Ep[o]={value:o}});Object.defineProperties(Xe,Ep);Object.defineProperty(_p,"isAxiosError",{value:!0});Xe.from=(o,a,t,n,i,r)=>{const s=Object.create(_p);return ce.toFlatObject(o,s,function(d){return d!==Error.prototype},l=>l!=="isAxiosError"),Xe.call(s,o.message,a,t,n,i),s.cause=o,s.name=o.name,r&&Object.assign(s,r),s};const Ox=null;function Ul(o){return ce.isPlainObject(o)||ce.isArray(o)}function xp(o){return ce.endsWith(o,"[]")?o.slice(0,-2):o}function Kc(o,a,t){return o?o.concat(a).map(function(i,r){return i=xp(i),!t&&r?"["+i+"]":i}).join(t?".":""):a}function zx(o){return ce.isArray(o)&&!o.some(Ul)}const jx=ce.toFlatObject(ce,{},null,function(a){return/^is[A-Z]/.test(a)});function vs(o,a,t){if(!ce.isObject(o))throw new TypeError("target must be an object");a=a||new FormData,t=ce.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,w){return!ce.isUndefined(w[v])});const n=t.metaTokens,i=t.visitor||u,r=t.dots,s=t.indexes,d=(t.Blob||typeof Blob<"u"&&Blob)&&ce.isSpecCompliantForm(a);if(!ce.isFunction(i))throw new TypeError("visitor must be a function");function c(h){if(h===null)return"";if(ce.isDate(h))return h.toISOString();if(ce.isBoolean(h))return h.toString();if(!d&&ce.isBlob(h))throw new Xe("Blob is not supported. Use a Buffer instead.");return ce.isArrayBuffer(h)||ce.isTypedArray(h)?d&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,v,w){let E=h;if(h&&!w&&typeof h=="object"){if(ce.endsWith(v,"{}"))v=n?v:v.slice(0,-2),h=JSON.stringify(h);else if(ce.isArray(h)&&zx(h)||(ce.isFileList(h)||ce.endsWith(v,"[]"))&&(E=ce.toArray(h)))return v=xp(v),E.forEach(function(k,b){!(ce.isUndefined(k)||k===null)&&a.append(s===!0?Kc([v],b,r):s===null?v:v+"[]",c(k))}),!1}return Ul(h)?!0:(a.append(Kc(w,v,r),c(h)),!1)}const f=[],m=Object.assign(jx,{defaultVisitor:u,convertValue:c,isVisitable:Ul});function p(h,v){if(!ce.isUndefined(h)){if(f.indexOf(h)!==-1)throw Error("Circular reference detected in "+v.join("."));f.push(h),ce.forEach(h,function(E,S){(!(ce.isUndefined(E)||E===null)&&i.call(a,E,ce.isString(S)?S.trim():S,v,m))===!0&&p(E,v?v.concat(S):[S])}),f.pop()}}if(!ce.isObject(o))throw new TypeError("data must be an object");return p(o),a}function Jc(o){const a={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(o).replace(/[!'()~]|%20|%00/g,function(n){return a[n]})}function xd(o,a){this._pairs=[],o&&vs(o,this,a)}const Sp=xd.prototype;Sp.append=function(a,t){this._pairs.push([a,t])};Sp.toString=function(a){const t=a?function(n){return a.call(this,n,Jc)}:Jc;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function Wx(o){return encodeURIComponent(o).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Cp(o,a,t){if(!a)return o;const n=t&&t.encode||Wx;ce.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let r;if(i?r=i(a,t):r=ce.isURLSearchParams(a)?a.toString():new xd(a,t).toString(n),r){const s=o.indexOf("#");s!==-1&&(o=o.slice(0,s)),o+=(o.indexOf("?")===-1?"?":"&")+r}return o}class qc{constructor(){this.handlers=[]}use(a,t,n){return this.handlers.push({fulfilled:a,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(a){this.handlers[a]&&(this.handlers[a]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(a){ce.forEach(this.handlers,function(n){n!==null&&a(n)})}}const Vp={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Hx=typeof URLSearchParams<"u"?URLSearchParams:xd,Zx=typeof FormData<"u"?FormData:null,Gx=typeof Blob<"u"?Blob:null,Xx={isBrowser:!0,classes:{URLSearchParams:Hx,FormData:Zx,Blob:Gx},protocols:["http","https","file","blob","url","data"]},Sd=typeof window<"u"&&typeof document<"u",Ol=typeof navigator=="object"&&navigator||void 0,Kx=Sd&&(!Ol||["ReactNative","NativeScript","NS"].indexOf(Ol.product)<0),Jx=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",qx=Sd&&window.location.href||"http://localhost",Yx=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Sd,hasStandardBrowserEnv:Kx,hasStandardBrowserWebWorkerEnv:Jx,navigator:Ol,origin:qx},Symbol.toStringTag,{value:"Module"})),oa={...Yx,...Xx};function Qx(o,a){return vs(o,new oa.classes.URLSearchParams,{visitor:function(t,n,i,r){return oa.isNode&&ce.isBuffer(t)?(this.append(n,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...a})}function eS(o){return ce.matchAll(/\w+|\[(\w*)]/g,o).map(a=>a[0]==="[]"?"":a[1]||a[0])}function tS(o){const a={},t=Object.keys(o);let n;const i=t.length;let r;for(n=0;n<i;n++)r=t[n],a[r]=o[r];return a}function Np(o){function a(t,n,i,r){let s=t[r++];if(s==="__proto__")return!0;const l=Number.isFinite(+s),d=r>=t.length;return s=!s&&ce.isArray(i)?i.length:s,d?(ce.hasOwnProp(i,s)?i[s]=[i[s],n]:i[s]=n,!l):((!i[s]||!ce.isObject(i[s]))&&(i[s]=[]),a(t,n,i[s],r)&&ce.isArray(i[s])&&(i[s]=tS(i[s])),!l)}if(ce.isFormData(o)&&ce.isFunction(o.entries)){const t={};return ce.forEachEntry(o,(n,i)=>{a(eS(n),i,t,0)}),t}return null}function aS(o,a,t){if(ce.isString(o))try{return(a||JSON.parse)(o),ce.trim(o)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(o)}const Ui={transitional:Vp,adapter:["xhr","http","fetch"],transformRequest:[function(a,t){const n=t.getContentType()||"",i=n.indexOf("application/json")>-1,r=ce.isObject(a);if(r&&ce.isHTMLForm(a)&&(a=new FormData(a)),ce.isFormData(a))return i?JSON.stringify(Np(a)):a;if(ce.isArrayBuffer(a)||ce.isBuffer(a)||ce.isStream(a)||ce.isFile(a)||ce.isBlob(a)||ce.isReadableStream(a))return a;if(ce.isArrayBufferView(a))return a.buffer;if(ce.isURLSearchParams(a))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),a.toString();let l;if(r){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Qx(a,this.formSerializer).toString();if((l=ce.isFileList(a))||n.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return vs(l?{"files[]":a}:a,d&&new d,this.formSerializer)}}return r||i?(t.setContentType("application/json",!1),aS(a)):a}],transformResponse:[function(a){const t=this.transitional||Ui.transitional,n=t&&t.forcedJSONParsing,i=this.responseType==="json";if(ce.isResponse(a)||ce.isReadableStream(a))return a;if(a&&ce.isString(a)&&(n&&!this.responseType||i)){const s=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(a)}catch(l){if(s)throw l.name==="SyntaxError"?Xe.from(l,Xe.ERR_BAD_RESPONSE,this,null,this.response):l}}return a}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:oa.classes.FormData,Blob:oa.classes.Blob},validateStatus:function(a){return a>=200&&a<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ce.forEach(["delete","get","head","post","put","patch"],o=>{Ui.headers[o]={}});const nS=ce.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),oS=o=>{const a={};let t,n,i;return o&&o.split(`
|
|
345
|
-
`).forEach(function(s){i=s.indexOf(":"),t=s.substring(0,i).trim().toLowerCase(),n=s.substring(i+1).trim(),!(!t||a[t]&&nS[t])&&(t==="set-cookie"?a[t]?a[t].push(n):a[t]=[n]:a[t]=a[t]?a[t]+", "+n:n)}),a},Yc=Symbol("internals");function Yo(o){return o&&String(o).trim().toLowerCase()}function Sr(o){return o===!1||o==null?o:ce.isArray(o)?o.map(Sr):String(o)}function iS(o){const a=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=t.exec(o);)a[n[1]]=n[2];return a}const rS=o=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(o.trim());function Ks(o,a,t,n,i){if(ce.isFunction(n))return n.call(this,a,t);if(i&&(a=t),!!ce.isString(a)){if(ce.isString(n))return a.indexOf(n)!==-1;if(ce.isRegExp(n))return n.test(a)}}function sS(o){return o.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(a,t,n)=>t.toUpperCase()+n)}function lS(o,a){const t=ce.toCamelCase(" "+a);["get","set","has"].forEach(n=>{Object.defineProperty(o,n+t,{value:function(i,r,s){return this[n].call(this,a,i,r,s)},configurable:!0})})}let ha=class{constructor(a){a&&this.set(a)}set(a,t,n){const i=this;function r(l,d,c){const u=Yo(d);if(!u)throw new Error("header name must be a non-empty string");const f=ce.findKey(i,u);(!f||i[f]===void 0||c===!0||c===void 0&&i[f]!==!1)&&(i[f||d]=Sr(l))}const s=(l,d)=>ce.forEach(l,(c,u)=>r(c,u,d));if(ce.isPlainObject(a)||a instanceof this.constructor)s(a,t);else if(ce.isString(a)&&(a=a.trim())&&!rS(a))s(oS(a),t);else if(ce.isObject(a)&&ce.isIterable(a)){let l={},d,c;for(const u of a){if(!ce.isArray(u))throw TypeError("Object iterator must return a key-value pair");l[c=u[0]]=(d=l[c])?ce.isArray(d)?[...d,u[1]]:[d,u[1]]:u[1]}s(l,t)}else a!=null&&r(t,a,n);return this}get(a,t){if(a=Yo(a),a){const n=ce.findKey(this,a);if(n){const i=this[n];if(!t)return i;if(t===!0)return iS(i);if(ce.isFunction(t))return t.call(this,i,n);if(ce.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(a,t){if(a=Yo(a),a){const n=ce.findKey(this,a);return!!(n&&this[n]!==void 0&&(!t||Ks(this,this[n],n,t)))}return!1}delete(a,t){const n=this;let i=!1;function r(s){if(s=Yo(s),s){const l=ce.findKey(n,s);l&&(!t||Ks(n,n[l],l,t))&&(delete n[l],i=!0)}}return ce.isArray(a)?a.forEach(r):r(a),i}clear(a){const t=Object.keys(this);let n=t.length,i=!1;for(;n--;){const r=t[n];(!a||Ks(this,this[r],r,a,!0))&&(delete this[r],i=!0)}return i}normalize(a){const t=this,n={};return ce.forEach(this,(i,r)=>{const s=ce.findKey(n,r);if(s){t[s]=Sr(i),delete t[r];return}const l=a?sS(r):String(r).trim();l!==r&&delete t[r],t[l]=Sr(i),n[l]=!0}),this}concat(...a){return this.constructor.concat(this,...a)}toJSON(a){const t=Object.create(null);return ce.forEach(this,(n,i)=>{n!=null&&n!==!1&&(t[i]=a&&ce.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([a,t])=>a+": "+t).join(`
|
|
346
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(a){return a instanceof this?a:new this(a)}static concat(a,...t){const n=new this(a);return t.forEach(i=>n.set(i)),n}static accessor(a){const n=(this[Yc]=this[Yc]={accessors:{}}).accessors,i=this.prototype;function r(s){const l=Yo(s);n[l]||(lS(i,s),n[l]=!0)}return ce.isArray(a)?a.forEach(r):r(a),this}};ha.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);ce.reduceDescriptors(ha.prototype,({value:o},a)=>{let t=a[0].toUpperCase()+a.slice(1);return{get:()=>o,set(n){this[t]=n}}});ce.freezeMethods(ha);function Js(o,a){const t=this||Ui,n=a||t,i=ha.from(n.headers);let r=n.data;return ce.forEach(o,function(l){r=l.call(t,r,i.normalize(),a?a.status:void 0)}),i.normalize(),r}function Tp(o){return!!(o&&o.__CANCEL__)}function Ro(o,a,t){Xe.call(this,o??"canceled",Xe.ERR_CANCELED,a,t),this.name="CanceledError"}ce.inherits(Ro,Xe,{__CANCEL__:!0});function Bp(o,a,t){const n=t.config.validateStatus;!t.status||!n||n(t.status)?o(t):a(new Xe("Request failed with status code "+t.status,[Xe.ERR_BAD_REQUEST,Xe.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function dS(o){const a=/^([-+\w]{1,25})(:?\/\/|:)/.exec(o);return a&&a[1]||""}function cS(o,a){o=o||10;const t=new Array(o),n=new Array(o);let i=0,r=0,s;return a=a!==void 0?a:1e3,function(d){const c=Date.now(),u=n[r];s||(s=c),t[i]=d,n[i]=c;let f=r,m=0;for(;f!==i;)m+=t[f++],f=f%o;if(i=(i+1)%o,i===r&&(r=(r+1)%o),c-s<a)return;const p=u&&c-u;return p?Math.round(m*1e3/p):void 0}}function uS(o,a){let t=0,n=1e3/a,i,r;const s=(c,u=Date.now())=>{t=u,i=null,r&&(clearTimeout(r),r=null),o(...c)};return[(...c)=>{const u=Date.now(),f=u-t;f>=n?s(c,u):(i=c,r||(r=setTimeout(()=>{r=null,s(i)},n-f)))},()=>i&&s(i)]}const Or=(o,a,t=3)=>{let n=0;const i=cS(50,250);return uS(r=>{const s=r.loaded,l=r.lengthComputable?r.total:void 0,d=s-n,c=i(d),u=s<=l;n=s;const f={loaded:s,total:l,progress:l?s/l:void 0,bytes:d,rate:c||void 0,estimated:c&&l&&u?(l-s)/c:void 0,event:r,lengthComputable:l!=null,[a?"download":"upload"]:!0};o(f)},t)},Qc=(o,a)=>{const t=o!=null;return[n=>a[0]({lengthComputable:t,total:o,loaded:n}),a[1]]},eu=o=>(...a)=>ce.asap(()=>o(...a)),mS=oa.hasStandardBrowserEnv?((o,a)=>t=>(t=new URL(t,oa.origin),o.protocol===t.protocol&&o.host===t.host&&(a||o.port===t.port)))(new URL(oa.origin),oa.navigator&&/(msie|trident)/i.test(oa.navigator.userAgent)):()=>!0,pS=oa.hasStandardBrowserEnv?{write(o,a,t,n,i,r){const s=[o+"="+encodeURIComponent(a)];ce.isNumber(t)&&s.push("expires="+new Date(t).toGMTString()),ce.isString(n)&&s.push("path="+n),ce.isString(i)&&s.push("domain="+i),r===!0&&s.push("secure"),document.cookie=s.join("; ")},read(o){const a=document.cookie.match(new RegExp("(^|;\\s*)("+o+")=([^;]*)"));return a?decodeURIComponent(a[3]):null},remove(o){this.write(o,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function fS(o){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(o)}function hS(o,a){return a?o.replace(/\/?\/$/,"")+"/"+a.replace(/^\/+/,""):o}function Ip(o,a,t){let n=!fS(a);return o&&(n||t==!1)?hS(o,a):a}const tu=o=>o instanceof ha?{...o}:o;function Jn(o,a){a=a||{};const t={};function n(c,u,f,m){return ce.isPlainObject(c)&&ce.isPlainObject(u)?ce.merge.call({caseless:m},c,u):ce.isPlainObject(u)?ce.merge({},u):ce.isArray(u)?u.slice():u}function i(c,u,f,m){if(ce.isUndefined(u)){if(!ce.isUndefined(c))return n(void 0,c,f,m)}else return n(c,u,f,m)}function r(c,u){if(!ce.isUndefined(u))return n(void 0,u)}function s(c,u){if(ce.isUndefined(u)){if(!ce.isUndefined(c))return n(void 0,c)}else return n(void 0,u)}function l(c,u,f){if(f in a)return n(c,u);if(f in o)return n(void 0,c)}const d={url:r,method:r,data:r,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:l,headers:(c,u,f)=>i(tu(c),tu(u),f,!0)};return ce.forEach(Object.keys({...o,...a}),function(u){const f=d[u]||i,m=f(o[u],a[u],u);ce.isUndefined(m)&&f!==l||(t[u]=m)}),t}const Mp=o=>{const a=Jn({},o);let{data:t,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:r,headers:s,auth:l}=a;a.headers=s=ha.from(s),a.url=Cp(Ip(a.baseURL,a.url,a.allowAbsoluteUrls),o.params,o.paramsSerializer),l&&s.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let d;if(ce.isFormData(t)){if(oa.hasStandardBrowserEnv||oa.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((d=s.getContentType())!==!1){const[c,...u]=d?d.split(";").map(f=>f.trim()).filter(Boolean):[];s.setContentType([c||"multipart/form-data",...u].join("; "))}}if(oa.hasStandardBrowserEnv&&(n&&ce.isFunction(n)&&(n=n(a)),n||n!==!1&&mS(a.url))){const c=i&&r&&pS.read(r);c&&s.set(i,c)}return a},vS=typeof XMLHttpRequest<"u",gS=vS&&function(o){return new Promise(function(t,n){const i=Mp(o);let r=i.data;const s=ha.from(i.headers).normalize();let{responseType:l,onUploadProgress:d,onDownloadProgress:c}=i,u,f,m,p,h;function v(){p&&p(),h&&h(),i.cancelToken&&i.cancelToken.unsubscribe(u),i.signal&&i.signal.removeEventListener("abort",u)}let w=new XMLHttpRequest;w.open(i.method.toUpperCase(),i.url,!0),w.timeout=i.timeout;function E(){if(!w)return;const k=ha.from("getAllResponseHeaders"in w&&w.getAllResponseHeaders()),$={data:!l||l==="text"||l==="json"?w.responseText:w.response,status:w.status,statusText:w.statusText,headers:k,config:o,request:w};Bp(function(I){t(I),v()},function(I){n(I),v()},$),w=null}"onloadend"in w?w.onloadend=E:w.onreadystatechange=function(){!w||w.readyState!==4||w.status===0&&!(w.responseURL&&w.responseURL.indexOf("file:")===0)||setTimeout(E)},w.onabort=function(){w&&(n(new Xe("Request aborted",Xe.ECONNABORTED,o,w)),w=null)},w.onerror=function(){n(new Xe("Network Error",Xe.ERR_NETWORK,o,w)),w=null},w.ontimeout=function(){let b=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const $=i.transitional||Vp;i.timeoutErrorMessage&&(b=i.timeoutErrorMessage),n(new Xe(b,$.clarifyTimeoutError?Xe.ETIMEDOUT:Xe.ECONNABORTED,o,w)),w=null},r===void 0&&s.setContentType(null),"setRequestHeader"in w&&ce.forEach(s.toJSON(),function(b,$){w.setRequestHeader($,b)}),ce.isUndefined(i.withCredentials)||(w.withCredentials=!!i.withCredentials),l&&l!=="json"&&(w.responseType=i.responseType),c&&([m,h]=Or(c,!0),w.addEventListener("progress",m)),d&&w.upload&&([f,p]=Or(d),w.upload.addEventListener("progress",f),w.upload.addEventListener("loadend",p)),(i.cancelToken||i.signal)&&(u=k=>{w&&(n(!k||k.type?new Ro(null,o,w):k),w.abort(),w=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));const S=dS(i.url);if(S&&oa.protocols.indexOf(S)===-1){n(new Xe("Unsupported protocol "+S+":",Xe.ERR_BAD_REQUEST,o));return}w.send(r||null)})},bS=(o,a)=>{const{length:t}=o=o?o.filter(Boolean):[];if(a||t){let n=new AbortController,i;const r=function(c){if(!i){i=!0,l();const u=c instanceof Error?c:this.reason;n.abort(u instanceof Xe?u:new Ro(u instanceof Error?u.message:u))}};let s=a&&setTimeout(()=>{s=null,r(new Xe(`timeout ${a} of ms exceeded`,Xe.ETIMEDOUT))},a);const l=()=>{o&&(s&&clearTimeout(s),s=null,o.forEach(c=>{c.unsubscribe?c.unsubscribe(r):c.removeEventListener("abort",r)}),o=null)};o.forEach(c=>c.addEventListener("abort",r));const{signal:d}=n;return d.unsubscribe=()=>ce.asap(l),d}},yS=function*(o,a){let t=o.byteLength;if(t<a){yield o;return}let n=0,i;for(;n<t;)i=n+a,yield o.slice(n,i),n=i},wS=async function*(o,a){for await(const t of kS(o))yield*yS(t,a)},kS=async function*(o){if(o[Symbol.asyncIterator]){yield*o;return}const a=o.getReader();try{for(;;){const{done:t,value:n}=await a.read();if(t)break;yield n}}finally{await a.cancel()}},au=(o,a,t,n)=>{const i=wS(o,a);let r=0,s,l=d=>{s||(s=!0,n&&n(d))};return new ReadableStream({async pull(d){try{const{done:c,value:u}=await i.next();if(c){l(),d.close();return}let f=u.byteLength;if(t){let m=r+=f;t(m)}d.enqueue(new Uint8Array(u))}catch(c){throw l(c),c}},cancel(d){return l(d),i.return()}},{highWaterMark:2})},gs=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Fp=gs&&typeof ReadableStream=="function",_S=gs&&(typeof TextEncoder=="function"?(o=>a=>o.encode(a))(new TextEncoder):async o=>new Uint8Array(await new Response(o).arrayBuffer())),$p=(o,...a)=>{try{return!!o(...a)}catch{return!1}},ES=Fp&&$p(()=>{let o=!1;const a=new Request(oa.origin,{body:new ReadableStream,method:"POST",get duplex(){return o=!0,"half"}}).headers.has("Content-Type");return o&&!a}),nu=64*1024,zl=Fp&&$p(()=>ce.isReadableStream(new Response("").body)),zr={stream:zl&&(o=>o.body)};gs&&(o=>{["text","arrayBuffer","blob","formData","stream"].forEach(a=>{!zr[a]&&(zr[a]=ce.isFunction(o[a])?t=>t[a]():(t,n)=>{throw new Xe(`Response type '${a}' is not supported`,Xe.ERR_NOT_SUPPORT,n)})})})(new Response);const xS=async o=>{if(o==null)return 0;if(ce.isBlob(o))return o.size;if(ce.isSpecCompliantForm(o))return(await new Request(oa.origin,{method:"POST",body:o}).arrayBuffer()).byteLength;if(ce.isArrayBufferView(o)||ce.isArrayBuffer(o))return o.byteLength;if(ce.isURLSearchParams(o)&&(o=o+""),ce.isString(o))return(await _S(o)).byteLength},SS=async(o,a)=>{const t=ce.toFiniteNumber(o.getContentLength());return t??xS(a)},CS=gs&&(async o=>{let{url:a,method:t,data:n,signal:i,cancelToken:r,timeout:s,onDownloadProgress:l,onUploadProgress:d,responseType:c,headers:u,withCredentials:f="same-origin",fetchOptions:m}=Mp(o);c=c?(c+"").toLowerCase():"text";let p=bS([i,r&&r.toAbortSignal()],s),h;const v=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let w;try{if(d&&ES&&t!=="get"&&t!=="head"&&(w=await SS(u,n))!==0){let $=new Request(a,{method:"POST",body:n,duplex:"half"}),V;if(ce.isFormData(n)&&(V=$.headers.get("content-type"))&&u.setContentType(V),$.body){const[I,x]=Qc(w,Or(eu(d)));n=au($.body,nu,I,x)}}ce.isString(f)||(f=f?"include":"omit");const E="credentials"in Request.prototype;h=new Request(a,{...m,signal:p,method:t.toUpperCase(),headers:u.normalize().toJSON(),body:n,duplex:"half",credentials:E?f:void 0});let S=await fetch(h,m);const k=zl&&(c==="stream"||c==="response");if(zl&&(l||k&&v)){const $={};["status","statusText","headers"].forEach(N=>{$[N]=S[N]});const V=ce.toFiniteNumber(S.headers.get("content-length")),[I,x]=l&&Qc(V,Or(eu(l),!0))||[];S=new Response(au(S.body,nu,I,()=>{x&&x(),v&&v()}),$)}c=c||"text";let b=await zr[ce.findKey(zr,c)||"text"](S,o);return!k&&v&&v(),await new Promise(($,V)=>{Bp($,V,{data:b,headers:ha.from(S.headers),status:S.status,statusText:S.statusText,config:o,request:h})})}catch(E){throw v&&v(),E&&E.name==="TypeError"&&/Load failed|fetch/i.test(E.message)?Object.assign(new Xe("Network Error",Xe.ERR_NETWORK,o,h),{cause:E.cause||E}):Xe.from(E,E&&E.code,o,h)}}),jl={http:Ox,xhr:gS,fetch:CS};ce.forEach(jl,(o,a)=>{if(o){try{Object.defineProperty(o,"name",{value:a})}catch{}Object.defineProperty(o,"adapterName",{value:a})}});const ou=o=>`- ${o}`,VS=o=>ce.isFunction(o)||o===null||o===!1,Dp={getAdapter:o=>{o=ce.isArray(o)?o:[o];const{length:a}=o;let t,n;const i={};for(let r=0;r<a;r++){t=o[r];let s;if(n=t,!VS(t)&&(n=jl[(s=String(t)).toLowerCase()],n===void 0))throw new Xe(`Unknown adapter '${s}'`);if(n)break;i[s||"#"+r]=n}if(!n){const r=Object.entries(i).map(([l,d])=>`adapter ${l} `+(d===!1?"is not supported by the environment":"is not available in the build"));let s=a?r.length>1?`since :
|
|
347
|
-
`+r.map(ou).join(`
|
|
348
|
-
`):" "+ou(r[0]):"as no adapter specified";throw new Xe("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return n},adapters:jl};function qs(o){if(o.cancelToken&&o.cancelToken.throwIfRequested(),o.signal&&o.signal.aborted)throw new Ro(null,o)}function iu(o){return qs(o),o.headers=ha.from(o.headers),o.data=Js.call(o,o.transformRequest),["post","put","patch"].indexOf(o.method)!==-1&&o.headers.setContentType("application/x-www-form-urlencoded",!1),Dp.getAdapter(o.adapter||Ui.adapter)(o).then(function(n){return qs(o),n.data=Js.call(o,o.transformResponse,n),n.headers=ha.from(n.headers),n},function(n){return Tp(n)||(qs(o),n&&n.response&&(n.response.data=Js.call(o,o.transformResponse,n.response),n.response.headers=ha.from(n.response.headers))),Promise.reject(n)})}const Rp="1.11.0",bs={};["object","boolean","number","function","string","symbol"].forEach((o,a)=>{bs[o]=function(n){return typeof n===o||"a"+(a<1?"n ":" ")+o}});const ru={};bs.transitional=function(a,t,n){function i(r,s){return"[Axios v"+Rp+"] Transitional option '"+r+"'"+s+(n?". "+n:"")}return(r,s,l)=>{if(a===!1)throw new Xe(i(s," has been removed"+(t?" in "+t:"")),Xe.ERR_DEPRECATED);return t&&!ru[s]&&(ru[s]=!0),a?a(r,s,l):!0}};bs.spelling=function(a){return(t,n)=>!0};function NS(o,a,t){if(typeof o!="object")throw new Xe("options must be an object",Xe.ERR_BAD_OPTION_VALUE);const n=Object.keys(o);let i=n.length;for(;i-- >0;){const r=n[i],s=a[r];if(s){const l=o[r],d=l===void 0||s(l,r,o);if(d!==!0)throw new Xe("option "+r+" must be "+d,Xe.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new Xe("Unknown option "+r,Xe.ERR_BAD_OPTION)}}const Cr={assertOptions:NS,validators:bs},Wa=Cr.validators;let Zn=class{constructor(a){this.defaults=a||{},this.interceptors={request:new qc,response:new qc}}async request(a,t){try{return await this._request(a,t)}catch(n){if(n instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const r=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?r&&!String(n.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
349
|
-
`+r):n.stack=r}catch{}}throw n}}_request(a,t){typeof a=="string"?(t=t||{},t.url=a):t=a||{},t=Jn(this.defaults,t);const{transitional:n,paramsSerializer:i,headers:r}=t;n!==void 0&&Cr.assertOptions(n,{silentJSONParsing:Wa.transitional(Wa.boolean),forcedJSONParsing:Wa.transitional(Wa.boolean),clarifyTimeoutError:Wa.transitional(Wa.boolean)},!1),i!=null&&(ce.isFunction(i)?t.paramsSerializer={serialize:i}:Cr.assertOptions(i,{encode:Wa.function,serialize:Wa.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Cr.assertOptions(t,{baseUrl:Wa.spelling("baseURL"),withXsrfToken:Wa.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=r&&ce.merge(r.common,r[t.method]);r&&ce.forEach(["delete","get","head","post","put","patch","common"],h=>{delete r[h]}),t.headers=ha.concat(s,r);const l=[];let d=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(t)===!1||(d=d&&v.synchronous,l.unshift(v.fulfilled,v.rejected))});const c=[];this.interceptors.response.forEach(function(v){c.push(v.fulfilled,v.rejected)});let u,f=0,m;if(!d){const h=[iu.bind(this),void 0];for(h.unshift(...l),h.push(...c),m=h.length,u=Promise.resolve(t);f<m;)u=u.then(h[f++],h[f++]);return u}m=l.length;let p=t;for(f=0;f<m;){const h=l[f++],v=l[f++];try{p=h(p)}catch(w){v.call(this,w);break}}try{u=iu.call(this,p)}catch(h){return Promise.reject(h)}for(f=0,m=c.length;f<m;)u=u.then(c[f++],c[f++]);return u}getUri(a){a=Jn(this.defaults,a);const t=Ip(a.baseURL,a.url,a.allowAbsoluteUrls);return Cp(t,a.params,a.paramsSerializer)}};ce.forEach(["delete","get","head","options"],function(a){Zn.prototype[a]=function(t,n){return this.request(Jn(n||{},{method:a,url:t,data:(n||{}).data}))}});ce.forEach(["post","put","patch"],function(a){function t(n){return function(r,s,l){return this.request(Jn(l||{},{method:a,headers:n?{"Content-Type":"multipart/form-data"}:{},url:r,data:s}))}}Zn.prototype[a]=t(),Zn.prototype[a+"Form"]=t(!0)});let TS=class Ap{constructor(a){if(typeof a!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(r){t=r});const n=this;this.promise.then(i=>{if(!n._listeners)return;let r=n._listeners.length;for(;r-- >0;)n._listeners[r](i);n._listeners=null}),this.promise.then=i=>{let r;const s=new Promise(l=>{n.subscribe(l),r=l}).then(i);return s.cancel=function(){n.unsubscribe(r)},s},a(function(r,s,l){n.reason||(n.reason=new Ro(r,s,l),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(a){if(this.reason){a(this.reason);return}this._listeners?this._listeners.push(a):this._listeners=[a]}unsubscribe(a){if(!this._listeners)return;const t=this._listeners.indexOf(a);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const a=new AbortController,t=n=>{a.abort(n)};return this.subscribe(t),a.signal.unsubscribe=()=>this.unsubscribe(t),a.signal}static source(){let a;return{token:new Ap(function(i){a=i}),cancel:a}}};function BS(o){return function(t){return o.apply(null,t)}}function IS(o){return ce.isObject(o)&&o.isAxiosError===!0}const Wl={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Wl).forEach(([o,a])=>{Wl[a]=o});function Lp(o){const a=new Zn(o),t=fp(Zn.prototype.request,a);return ce.extend(t,Zn.prototype,a,{allOwnKeys:!0}),ce.extend(t,a,null,{allOwnKeys:!0}),t.create=function(i){return Lp(Jn(o,i))},t}const Rt=Lp(Ui);Rt.Axios=Zn;Rt.CanceledError=Ro;Rt.CancelToken=TS;Rt.isCancel=Tp;Rt.VERSION=Rp;Rt.toFormData=vs;Rt.AxiosError=Xe;Rt.Cancel=Rt.CanceledError;Rt.all=function(a){return Promise.all(a)};Rt.spread=BS;Rt.isAxiosError=IS;Rt.mergeConfig=Jn;Rt.AxiosHeaders=ha;Rt.formToJSON=o=>Np(ce.isHTMLForm(o)?new FormData(o):o);Rt.getAdapter=Dp.getAdapter;Rt.HttpStatusCode=Wl;Rt.default=Rt;const{Axios:sA,AxiosError:lA,CanceledError:dA,isCancel:cA,CancelToken:uA,VERSION:mA,all:pA,Cancel:fA,isAxiosError:hA,spread:vA,toFormData:gA,AxiosHeaders:bA,HttpStatusCode:yA,formToJSON:wA,getAdapter:kA,mergeConfig:_A}=Rt;class ys{constructor(a="/api/v1"){this.eventSource=null,this.progressCallbacks=new Map,this.api=Rt.create({baseURL:a,headers:{"Content-Type":"application/json",Accept:"application/json"}}),this.api.interceptors.request.use(t=>{const n=this.getAuthToken();return n&&(t.headers.Authorization=`Bearer ${n}`),t}),this.api.interceptors.response.use(t=>t,t=>{var n;return(n=t.response)==null||n.status,Promise.reject(t)})}async createJob(a){try{const t=await this.api.post("/video/jobs",a);return this.normalizeJob(t.data.data)}catch(t){throw t}}async createRenderJob(a){try{const t=await this.api.post("/video/jobs/render",a);return this.normalizeJob(t.data.data)}catch(t){throw t}}async pollRenderJob(a,t,n=3e3,i=6e5){const r=Date.now();return new Promise((s,l)=>{const d=setInterval(async()=>{try{const c=await this.getJob(a);t==null||t(c.progress,c.status),c.status==="completed"?(clearInterval(d),s(c)):c.status==="failed"?(clearInterval(d),l(new Error(c.error_message??"Render job failed"))):c.status==="cancelled"?(clearInterval(d),l(new Error("Render job cancelled"))):Date.now()-r>i&&(clearInterval(d),l(new Error("Render job timed out")))}catch(c){clearInterval(d),l(c)}},n)})}async getJob(a){try{const t=await this.api.get(`/video/jobs/${a}`);return this.normalizeJob(t.data.data)}catch(t){throw t}}async listJobs(a){try{return(await this.api.get("/video/jobs",{params:a})).data}catch(t){throw t}}async cancelJob(a){try{const t=await this.api.delete(`/video/jobs/${a}`);return this.unsubscribeFromProgress(a),this.normalizeJob(t.data.data)}catch(t){throw t}}async retryJob(a){try{const t=await this.api.post(`/video/jobs/${a}/retry`);return this.normalizeJob(t.data.data)}catch(t){throw t}}subscribeToProgress(a,t){this.progressCallbacks.set(a,t),this.eventSource||this.initializeEventSource(),this.eventSource||this.pollProgress(a)}unsubscribeFromProgress(a){this.progressCallbacks.delete(a),this.progressCallbacks.size===0&&this.eventSource&&(this.eventSource.close(),this.eventSource=null)}initializeEventSource(){try{const a=this.getAuthToken(),t=`/api/v1/video/jobs/events${a?`?token=${a}`:""}`;this.eventSource=new EventSource(t),this.eventSource.addEventListener("progress",n=>{const i=JSON.parse(n.data),r=this.progressCallbacks.get(i.jobId);r&&r(i.progress)}),this.eventSource.addEventListener("complete",n=>{const i=JSON.parse(n.data),r=this.progressCallbacks.get(i.jobId);r&&(r(100),this.unsubscribeFromProgress(i.jobId))}),this.eventSource.addEventListener("error",n=>{this.progressCallbacks.forEach((i,r)=>{this.pollProgress(r)})})}catch{}}async pollProgress(a){const t=setInterval(async()=>{try{const n=await this.getJob(a),i=this.progressCallbacks.get(a);i&&i(n.progress),(n.status==="completed"||n.status==="failed"||n.status==="cancelled")&&(clearInterval(t),this.unsubscribeFromProgress(a))}catch{clearInterval(t)}},2e3)}getAuthToken(){const a=localStorage.getItem("auth_token");if(a)return a;const t=document.cookie.split(";");for(const n of t){const[i,r]=n.trim().split("=");if(i==="auth_token")return decodeURIComponent(r)}return null}async downloadVideo(a){try{return(await this.api.get(`/video/jobs/${a}/download`,{responseType:"blob"})).data}catch(t){throw t}}async getThumbnail(a,t=0){try{const n=await this.api.get(`/video/jobs/${a}/thumbnail`,{params:{time:t},responseType:"blob"});return URL.createObjectURL(n.data)}catch(n){throw n}}normalizeJob(a){const t=a,n={...t,user_id:t.user_id??t.userId??"",source_media_id:t.source_media_id??t.sourceMediaId??"",created_at:t.created_at??t.createdAt??"",updated_at:t.updated_at??t.updatedAt??""},i=t.output_media_id??t.outputMediaId;typeof i=="string"&&i!==""&&(n.output_media_id=i);const r=t.error_message??t.errorMessage;typeof r=="string"&&r!==""&&(n.error_message=r);const s=t.progress_message??t.progressMessage;typeof s=="string"&&s!==""&&(n.progress_message=s);const l=t.progress_detail??t.progressDetail;l&&typeof l=="object"&&(n.progress_detail=l);const d=t.started_at??t.startedAt;typeof d=="string"&&d!==""&&(n.started_at=d);const c=t.completed_at??t.completedAt;typeof c=="string"&&c!==""&&(n.completed_at=c);const u=t.cancelled_at??t.cancelledAt;return typeof u=="string"&&u!==""&&(n.cancelled_at=u),n}}new ys;const MS={key:0,class:"mobile-layout"},FS={class:"mobile-toolbar"},$S={class:"mobile-toolbar-left"},DS=["aria-label"],RS={class:"mobile-toolbar-right"},AS=["disabled"],LS=["disabled"],PS={class:"preview-section"},US={key:0,class:"mobile-export-overlay"},OS={class:"mobile-export-progress"},zS={class:"mobile-export-bar"},jS={class:"mobile-timeline-zoom"},WS={class:"mobile-edit-strip"},HS={class:"mobile-selection-summary"},ZS={class:"mobile-selection-title"},GS={class:"mobile-selection-meta"},XS={class:"mobile-readout-row"},KS=["disabled"],JS={class:"mobile-readout-grid"},qS={class:"mobile-readout-chip","data-testid":"mobile-playhead-readout"},YS={class:"mobile-readout-chip","data-testid":"mobile-clip-in-readout"},QS={class:"mobile-readout-chip","data-testid":"mobile-clip-out-readout"},eC={class:"mobile-readout-chip","data-testid":"mobile-duration-readout"},tC=["disabled"],aC={class:"mobile-speed-strip"},nC={class:"mobile-speed-chips"},oC=["data-testid","onClick"],iC={class:"mobile-edit-actions"},rC=["disabled"],sC=["disabled"],lC=["disabled"],dC=["disabled"],cC=["disabled"],uC={class:"mobile-action-sheet-header"},mC={class:"mobile-action-sheet-title"},pC={class:"mobile-action-sheet-subtitle"},fC={class:"mobile-action-sheet-actions"},hC=["disabled"],vC=["disabled"],gC=["disabled"],bC=["disabled"],yC=["disabled"],wC={key:1,class:"desktop-layout"},kC={class:"desktop-main-row"},_C={class:"preview-panel"},EC={class:"fit-toggle"},xC={class:"editor-content"},SC={class:"editor-tabs"},CC={class:"tab-header"},VC=["onClick"],NC={class:"tab-content-area"},TC={class:"filter-controls"},BC={class:"text-controls"},IC={class:"transition-controls"},MC={class:"audio-controls"},FC={class:"adjustments-controls"},$C={key:1,class:"no-filter-selected"},DC={class:"export-controls"},RC={key:0,"data-testid":"video-export-status-completed"},AC={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},LC={class:"desktop-timeline-row"},PC={class:"timeline-zoom"},UC=["value"],OC={class:"zoom-readout"},zC={key:0,class:"dev-editor-controls","data-testid":"video-editor-dev-controls"},jC={class:"dev-editor-row"},WC={class:"dev-editor-field"},HC={class:"dev-editor-field"},ZC=["disabled"],GC=["disabled"],XC=["disabled"],KC={class:"dev-editor-row"},JC={class:"dev-editor-field dev-editor-field--wide"},qC=["value"],YC=["disabled"],QC=["disabled"],eV=["disabled"],tV=["disabled"],aV=e.defineComponent({__name:"VideoEditor",props:{mediaUuid:{},initialRecipe:{},media:{},showThumbnailPicker:{type:Boolean,default:!1},workflowMode:{default:"full"},featureFlags:{},clientExportThreshold:{default:20},maxDuration:{default:300},serverRenderEndpoint:{default:null}},emits:["recipe-generated","export-started","draft-saved","video-exported","thumbnail-selected","server-render-started","server-render-progress","server-render-completed","server-render-failed","close"],setup(o,{expose:a,emit:t}){const n=o,i=t,r=e.computed(()=>{if(!n.media||typeof n.media!="object")return;const _=n.media.uuid??n.media.id;return typeof _=="string"&&_.trim()!==""?_.trim():void 0}),s=e.computed(()=>{const _=typeof n.mediaUuid=="string"?n.mediaUuid.trim():"";return _!==""?_:r.value??`temp-${Date.now()}`}),l=e.ref(typeof window<"u"?window.innerWidth<768:!1),d=e.ref("filters"),c=e.ref("filters"),u=e.computed(()=>{const _=n.workflowMode==="uploader"?{filters:!0,adjustments:!0,text:!1,transitions:!1,audio:!1,export:!1}:{filters:!0,adjustments:!0,text:!0,transitions:!0,audio:!0,export:!0},A=n.featureFlags;return A?{filters:typeof A.filters=="boolean"?A.filters:_.filters,adjustments:typeof A.adjustments=="boolean"?A.adjustments:_.adjustments,text:typeof A.text=="boolean"?A.text:_.text,transitions:typeof A.transitions=="boolean"?A.transitions:_.transitions,audio:typeof A.audio=="boolean"?A.audio:_.audio,export:typeof A.export=="boolean"?A.export:_.export}:_}),f=e.computed(()=>l.value?d.value:c.value),m=e.computed(()=>f.value==="filters"||w.value),p=e.computed(()=>f.value!=="filters"&&!w.value),h=e.ref(null),v=e.ref(null),w=e.ref(!1),E=e.computed(()=>l.value?h.value:v.value);function S(_){return _==="contain"||_==="cover"||_==="none"}function k(_){if(!(_!=null&&_.metadata))return null;const A=_.metadata.fit_mode;return S(A)?A:null}const b=e.shallowRef(null),$=e.ref(null),V=e.ref(k(n.initialRecipe)??"contain"),I=e.ref(null),x=e.ref(null),N=e.ref(null),L=e.ref(!1),C=new Map,T=e.ref([]),y=e.ref([]),R=e.ref([]),U=e.ref([]),z=e.ref(1),W=()=>{l.value=window.innerWidth<768},B=[{id:"filters",label:"Filters",icon:kn},{id:"adjustments",label:"Adjust",icon:Hh},{id:"text",label:"Text",icon:"text-outline"},{id:"transitions",label:"Transitions",icon:"swap-horizontal-outline"},{id:"audio",label:"Audio",icon:"musical-notes-outline"},{id:"export",label:"Export",icon:Co}],P=[{id:"filters",label:"Filters"},{id:"adjustments",label:"Adjustments"},{id:"text",label:"Text"},{id:"transitions",label:"Transitions"},{id:"audio",label:"Audio"},{id:"export",label:"Export"}],X=e.computed(()=>B.filter(_=>u.value[_.id])),K=e.computed(()=>P.filter(_=>u.value[_.id])),be=e.computed(()=>{var _,A;return((_=K.value[0])==null?void 0:_.id)??((A=X.value[0])==null?void 0:A.id)??"filters"});e.watch(u,_=>{_[d.value]||(d.value=be.value),_[c.value]||(c.value=be.value)},{immediate:!0,deep:!0}),e.watch(be,_=>{u.value[d.value]||(d.value=_),u.value[c.value]||(c.value=_)},{immediate:!0}),e.watch(u,_=>{_.export||(d.value==="export"&&(d.value=be.value),c.value==="export"&&(c.value=be.value))},{immediate:!0,deep:!0});const Ne=e.computed(()=>typeof window>"u"?!1:window.__MEDIABLES_EDITOR_DEV__===!0),ue=Ju(),{currentFrame:re,playheadPosition:O,timelineClips:D,totalDuration:J,hasChanges:Z,isPlaying:ie,selectedClip:se,zoomLevel:Ue,playbackSpeed:me,fps:ve,handleTrim:fe,handleSplit:Ee,handleClipSelect:ye,splitAtPlayhead:Be,deleteSelectedClip:Ie,duplicateSelectedClip:et,setZoomLevel:tt,moveClip:Tt,setFilters:vt,setTextOverlays:xt,setAudioTracks:wt,saveDraft:it,clearHasChanges:_t,resetChanges:ge,generateRecipe:ke,zoomIn:Te,zoomOut:Ke,fitToWindow:Ge,togglePlayback:Oe,setPlaying:kt,seekTo:lt,frameForward:zt,frameBackward:At,skipToStart:Jt,skipToEnd:Gt,setPlaybackSpeed:la,updateSourceDuration:ga,undo:ia,redo:Aa,canUndo:F,canRedo:Y}=lp(s.value,n.initialRecipe,n.media),{videoCompatibleFilters:j,activeFilters:ee,selectedFilter:we,previewFilter:Ve,previewFilterEffect:Je,applyFilter:ut,updateFilterParams:St,removeFilter:pt,clearAllFilters:ft,setActiveFilters:Mt}=up();function Bt(_){var ne,he;const A=((ne=se.value)==null?void 0:ne.id)??((he=D.value[0])==null?void 0:he.id);A&&(L.value=!0,typeof _=="object"&&_.id?ut(_.id):typeof _=="string"&&ut(_),vt(ee.value),b.value?b.value.setClipFilters(A,ee.value):C.set(A,[...ee.value]),ye(A),L.value=!1,za())}function It(){var A,ne;const _=((A=se.value)==null?void 0:A.id)??((ne=D.value[0])==null?void 0:ne.id);_&&ye(_)}function Ma(_){const A=ee.value.find(ne=>ne.filterId===_);A&&pt(A.id)}const ba=e.computed(()=>j.value.map(A=>{var he;const ne=[];if(A.controls&&A.controls.length>0)for(const Ce of A.controls){const xe=Ce.type;if(xe==="button"||xe==="text"||xe==="range")continue;const Se={id:Ce.property||Ce.id,label:Ce.label||Ce.id,type:xe,default:Ce.default??(xe==="toggle"?!1:xe==="color"?"#ffffff":0)};xe==="slider"&&(Se.min=Ce.min??0,Se.max=Ce.max??1,Se.step=Ce.step??.01),xe==="select"&&Ce.options&&(Se.options=Ce.options),ne.push(Se)}else if(A.paramRanges){const Ce=Object.entries(A.paramRanges);for(const[xe,Se]of Ce){const ht=xe.replace(/[-_]/g," ").replace(/\b\w/g,$n=>$n.toUpperCase()),_a=(he=A.defaultParams)==null?void 0:he[xe],vo=(Se.min+Se.max)/2;ne.push({id:xe,label:ht,min:Se.min,max:Se.max,step:Se.step??.01,default:typeof _a=="number"?_a:vo})}}return{id:A.id,name:A.name,category:A.category,params:ne}})),da=e.ref("0.00"),ca=e.ref("0.00"),qt=e.ref("");e.watch(ba,_=>{if(_.length===0){qt.value="";return}_.some(ne=>ne.id===qt.value)||(qt.value=_[0].id)},{immediate:!0});const gt=e.ref(!1),bt=e.ref(0),Yt=e.ref(!1),dt=e.ref(null),Ft=e.ref(null);let ya=null,G=!1;const q=e.computed(()=>{const _=new Map;return ee.value.forEach(A=>_.set(A.filterId,A)),_}),le=e.computed(()=>{var _,A;return re.value?re.value:((_=n.media)==null?void 0:_.thumbnail_url)||((A=n.media)==null?void 0:A.url)}),de=e.ref("");e.watch(()=>{var _,A;return{file:(_=n.media)==null?void 0:_.file,url:(A=n.media)==null?void 0:A.url}},(_,A,ne)=>{var Ce,xe;const he=de.value;ne(()=>{he&&he.startsWith("blob:")&&URL.revokeObjectURL(he)}),(Ce=n.media)!=null&&Ce.file?de.value=URL.createObjectURL(n.media.file):(xe=n.media)!=null&&xe.url?de.value=n.media.url:de.value=""},{immediate:!0}),e.onUnmounted(()=>{de.value&&de.value.startsWith("blob:")&&URL.revokeObjectURL(de.value)});const _e=e.computed(()=>de.value),Le=Dm({forcePixiPreview:w,getPreviewRef:()=>E.value,getSourceUrl:()=>de.value,setPlaying:kt}),Ye=e.computed(()=>{if(!n.media)return null;const{file:_,...A}=n.media;return{...A,url:de.value}}),We=e.computed(()=>{var A;const _=(A=n.media)==null?void 0:A.url;return!!(_&&/^https?:/i.test(_))}),Pe=e.computed(()=>ee.value),at=e.computed(()=>O.value),ot=e.computed(()=>!!se.value&&O.value>0),Ze=e.computed(()=>!!se.value&&D.value.length>1),jt=e.computed(()=>!!se.value),Ct=e.ref(!0),wa=[.5,1,1.5,2],cn=e.computed(()=>{const _=new Set([0,ua.value]);for(const A of D.value)_.add(A.timelineStart),_.add(A.timelineEnd);return Array.from(_).filter(A=>Number.isFinite(A)).sort((A,ne)=>A-ne)}),Es=e.computed(()=>cn.value.some(_=>_<O.value-.001)),un=e.computed(()=>cn.value.some(_=>_>O.value+.001)),oo=e.ref(!1),Vn=e.ref(null);function Fa(_){if(!Number.isFinite(_)||_<0)return"0:00";const A=Math.floor(_/60),ne=Math.floor(_%60);return`${A}:${ne.toString().padStart(2,"0")}`}const Oi=e.computed(()=>{var ne;const _=se.value??D.value[0];if(!_)return"No clip selected";const A=(ne=_.label)==null?void 0:ne.trim();return A&&A.length>0?A:`Clip ${_.id.slice(-4)}`}),xs=e.computed(()=>{const _=se.value??D.value[0];if(!_)return"Tap a clip to start editing";const A=Math.max(0,_.timelineEnd-_.timelineStart);return`${Fa(_.timelineStart)} - ${Fa(_.timelineEnd)} • ${A.toFixed(1)}s`});function zi(_){return!Number.isFinite(_)||_<0?"0.0s":_<60?`${_.toFixed(1)}s`:Fa(_)}const Ss=e.computed(()=>Fa(O.value)),Ao=e.computed(()=>{const _=se.value??D.value[0];return _?Fa(_.sourceIn):"0:00"}),ji=e.computed(()=>{const _=se.value??D.value[0];return _?Fa(_.sourceOut):"0:00"}),Cs=e.computed(()=>{const _=se.value??D.value[0];return _?zi(_.timelineEnd-_.timelineStart):"0.0s"}),Lo=e.computed(()=>Vn.value===null?se.value??D.value[0]??null:D.value.find(_=>_.id===Vn.value)??null),Vs=e.computed(()=>{var ne;const _=Lo.value;if(!_)return"Clip actions";const A=(ne=_.label)==null?void 0:ne.trim();return A&&A.length>0?A:`Clip ${_.id.slice(-4)}`}),Ns=e.computed(()=>{const _=Lo.value;return _?`${Fa(_.timelineStart)} - ${Fa(_.timelineEnd)} • ${zi(_.timelineEnd-_.timelineStart)}`:"Choose an action"}),Nn=e.ref(0),ua=e.computed(()=>{try{const _=J.value??J;return _&&typeof _=="number"&&_>0?_:Nn.value}catch{return Nn.value}}),mn=e.ref(),Po=e.ref(),Uo=e.ref(),pn=e.ref(),io=e.ref(0),en=e.ref(!1);let Qt=null,Va=null;e.watch(ua,_=>{var ne;if(en.value||!_||_<=0)return;const A=io.value||((ne=mn.value)==null?void 0:ne.clientWidth)||0;A>0&&(en.value=!0,Ge(A))}),e.watch(io,_=>{if(en.value||!_||_<=0)return;ua.value>0&&(en.value=!0,Ge(_))}),e.watch(l,_=>{_||Ua()}),e.watch(()=>{var _;return(_=Lo.value)==null?void 0:_.id},_=>{oo.value&&!_&&Ua()});function tn(_){return Number.isFinite(_)?_.toFixed(2):"0.00"}function Wi(_){const A=Number(_);return Number.isFinite(A)?A:null}function Xt(_){_&&(da.value=tn(_.sourceIn),ca.value=tn(_.sourceOut))}e.watch(()=>{var _,A,ne;return[(_=se.value)==null?void 0:_.id,(A=se.value)==null?void 0:A.sourceIn,(ne=se.value)==null?void 0:ne.sourceOut]},()=>{Xt(se.value)},{immediate:!0});function fn(_){const A=se.value;if(!A)return;const ne=1/30,he=A.sourceMinIn??0,Ce=A.sourceMaxOut??ua.value,xe=A.sourceIn+(O.value-A.timelineStart);if(_==="start"){const ht=Math.max(he,Math.min(xe,A.sourceOut-ne));da.value=tn(ht);return}const Se=Math.max(A.sourceIn+ne,Math.min(xe,Ce));ca.value=tn(Se)}function La(){const _=se.value;if(!_)return;const A=Wi(da.value),ne=Wi(ca.value);if(A===null||ne===null)return;const he=1/30,Ce=_.sourceMinIn??0,xe=_.sourceMaxOut??ua.value,Se=Math.max(Ce,Math.min(A,xe-he)),ht=Math.max(Se+he,Math.min(ne,xe));fe(_.id,"start",Se),fe(_.id,"end",ht),da.value=tn(Se),ca.value=tn(ht),se.value&<(se.value.timelineStart)}function Nt(){qt.value.trim()!==""&&Bt(qt.value)}function an(){var _;ft(),vt(ee.value),(_=se.value)!=null&&_.id&&(b.value?b.value.setClipFilters(se.value.id,ee.value):C.set(se.value.id,[...ee.value])),za()}function ro(_,A,ne){var Ce,xe;const he=ee.value.find(Se=>Se.filterId===_);he?(he.params={...he.params,[A]:ne},vt(ee.value),b.value&&((Ce=se.value)!=null&&Ce.id)?b.value.setClipFilters(se.value.id,ee.value):(xe=se.value)!=null&&xe.id&&C.set(se.value.id,[...ee.value]),za(),It()):Ve.value&&Ve.value.filterId===_&&(Ve.value.params={...Ve.value.params||{},[A]:ne})}function Tn(_){lt(_)}function Pa(_){!_||!Number.isFinite(_.timestamp)||lt(_.timestamp)}function Oo(_){kt(_)}function so(_){!Number.isFinite(_)||_<=0||(Nn.value=_,ga(_))}function Ua(){oo.value=!1,Vn.value=null}function ka(_){l.value&&(Vn.value=_,oo.value=!0)}function zo(_){var he,Ce,xe,Se;const A=((he=se.value)==null?void 0:he.id)??((Ce=D.value[0])==null?void 0:Ce.id)??null;ye(_),(((xe=se.value)==null?void 0:xe.id)??((Se=D.value[0])==null?void 0:Se.id)??null)!==A&&ue.selection()}function Hi(_){zo(_),ka(_)}function Bn(_){_&&ue.selection()}function lo(){Ct.value=!Ct.value,ue.selection()}function Oa(){const _=cn.value.filter(ne=>ne<O.value-.001),A=_.length>0?_[_.length-1]:0;lt(A)}function Zi(){const _=cn.value.find(A=>A>O.value+.001);lt(_??ua.value)}function co(){ia()}function uo(){Aa()}function hn(){const _=D.value.length;Be(),D.value.length>_&&(ue.success(),Ua())}function jo(_){const A=D.value.length;Ee(_),D.value.length>A&&ue.success()}function In(){const _=D.value.length;et(),D.value.length>_&&(ue.selection(),Ua())}function mo(){const _=D.value.length;Ie(),D.value.length<_&&(ue.error(),Ua())}function Mn(_){const A=me.value;la(_),me.value!==A&&ue.selection()}function po(_){return _ instanceof HTMLElement?_.closest('input, textarea, select, button, [contenteditable="true"]')!==null:!1}function vn(_){if(l.value||po(_.target))return;const A=_.key.toLowerCase(),ne=_.metaKey||_.ctrlKey;if(_.code==="Space"){_.preventDefault(),Oe();return}if(!ne&&A==="s"){_.preventDefault(),hn();return}if(A==="arrowleft"){_.preventDefault(),At();return}if(A==="arrowright"){_.preventDefault(),zt();return}if(A==="home"){_.preventDefault(),Jt();return}if(A==="end"){_.preventDefault(),Gt();return}if(!ne&&A==="["){_.preventDefault(),Oa();return}if(!ne&&A==="]"){_.preventDefault(),Zi();return}if(ne&&A==="z"&&_.shiftKey){_.preventDefault(),uo();return}ne&&A==="z"&&(_.preventDefault(),co())}function Gi(){var A;const _=io.value||((A=mn.value)==null?void 0:A.clientWidth)||800;Ge(_)}function Wo(_){en.value=!0,tt(_)}function Ld(){en.value=!0,Te()}function Pd(){en.value=!0,Ke()}function fo(_){const A=_.target,ne=Number(A.value);Wo(ne)}function Ho(_){const A=Math.min(600,Math.max(10,Ue.value+_));Wo(A)}function Zo(){Va==null||Va(),Va=null;const _=Uo.value,A=pn.value;if(!l.value||!_||!A)return;const ne=()=>{Ho(-20)},he=()=>{Ho(20)};_.addEventListener("click",ne),A.addEventListener("click",he),Va=()=>{_.removeEventListener("click",ne),A.removeEventListener("click",he)}}e.watch([l,Uo,pn],()=>{Zo()},{flush:"post"});function Xi(_){var A;b.value=_,(A=b.value)!=null&&A.composition&&(I.value=new mp(b.value.composition),x.value=new Ei(b.value.composition),N.value=new pp(b.value.composition));try{C.size&&(C.forEach((ne,he)=>{b.value.setClipFilters(he,ne)}),C.clear(),b.value.composition.computeFrame())}catch{}}function Ki(_){_!=null&&_.id&&Je(_.id)}function Ji(_){St(_),za()}async function qi(_){if(!I.value)return;const A=await I.value.addTextOverlay(_);T.value.push({id:A,..._})}async function Yi(_,A){if(!I.value)return;await I.value.updateTextOverlay(_,A);const ne=T.value.findIndex(he=>he.id===_);ne!==-1&&(T.value[ne]={...T.value[ne],...A})}async function g(_){I.value&&(await I.value.removeTextOverlay(_),T.value=T.value.filter(A=>A.id!==_))}async function M(_){if(!x.value||U.value.length<2)return;const[A,ne]=U.value,he=await x.value.applyTransition(A,ne,_);y.value.push({id:he,..._,name:_.type})}function te(_){if(!x.value)return;const A=y.value[_];A&&(x.value.removeTransition(A.id),y.value.splice(_,1))}function pe(_){}async function $e(_){if(!N.value)return;const A=await N.value.addAudioTrack(_);R.value.push({id:A,..._})}async function De(_,A){if(!N.value)return;const ne=R.value.findIndex(he=>he.id===_);ne!==-1&&(R.value[ne]={...R.value[ne],...A})}async function Qe(_){N.value&&(await N.value.removeAudioTrack(_),R.value=R.value.filter(A=>A.id!==_))}async function yt(_,A){if(!N.value)return;await N.value.updateVolume(_,A);const ne=R.value.find(he=>he.id===_);ne&&(ne.volume=A)}async function Lt(_,A){if(!N.value)return;await N.value.muteTrack(_,A);const ne=R.value.find(he=>he.id===_);ne&&(ne.muted=A)}function ra(_){N.value&&(N.value.setMasterVolume(_),z.value=_)}function ho(_){i("thumbnail-selected",_)}function gn(){ya!==null&&(clearInterval(ya),ya=null)}function _f(_,A){return A?{..._,output:{..._.output,format:A.format,quality:A.quality}}:_}function Go(_){var A;return _.metadata||(_.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),_.metadata.fit_mode=V.value,(A=n.media)!=null&&A.url&&/^https?:/i.test(n.media.url)?_.metadata.source_url=n.media.url:delete _.metadata.source_url,_}function $t(_,A,ne){return Math.min(ne,Math.max(A,_))}function Ts(_,A){if(typeof _=="number"&&Number.isFinite(_))return _;if(typeof _=="string"){const ne=Number(_);if(Number.isFinite(ne))return ne}return A}function ea(_,A,ne){for(const he of A)if(he in _)return Ts(_[he],ne);return ne}function Ef(_){const A=typeof _.params=="object"&&_.params!==null?_.params:{};switch(_.filterId.trim().toLowerCase()){case"brightness":return[{type:"brightness",value:$t(ea(A,["value","brightness"],0),-1,1)}];case"contrast":return[{type:"contrast",value:$t(ea(A,["value","contrast"],1),.1,3)}];case"saturation":return[{type:"saturation",value:$t(ea(A,["value","saturation"],1),0,3)}];case"blur":case"gaussian-blur":case"kawase-blur":case"radial-blur":return[{type:"blur",value:$t(ea(A,["value","blur","radius"],0),0,25)}];case"sharpen":return[{type:"sharpen",value:$t(ea(A,["value","amount"],1),0,5)}];case"sepia":return[{type:"sepia",value:1}];case"grayscale":return[{type:"grayscale",value:1}];case"adjustment":{const he=$t(ea(A,["brightness"],1)-1,-1,1),Ce=$t(ea(A,["contrast"],1),.1,3),xe=$t(ea(A,["saturation"],1),0,3);return[{type:"brightness",value:he},{type:"contrast",value:Ce},{type:"saturation",value:xe}]}default:return[]}}function xf(_){const A=_.timeline[0],ne=Array.isArray(A==null?void 0:A.filters)?A.filters:[],he=[];for(const xe of ne)if(he.push(...Ef(xe)),he.length>=12)break;const Ce={..._,filters:he.slice(0,12)};if(_.timeline.length===1&&A){const xe=Math.max(0,Ts(A.sourceIn,0)),Se=Ts(A.sourceOut,xe);Se>xe&&(Ce.trim={start:xe,end:Se})}return Ce}async function Ud(_,A,ne){return Le.renderRecipeWithPixi(_,A,ne)}async function Sf(_,A){var Xo;gn(),G=!1,Le.resetClientExport(),Ft.value=null,dt.value=null,Yt.value=!1,bt.value=0;const ne=Go(_??ke()),he=Gd(ne),Ce=Array.isArray(he.filters)&&he.filters.length>0,xe=Ms(he);if(!(Z.value||Ce||xe))return _t(),i("video-exported",null),null;const ht=he.timeline[0],_a=ht?Math.max(0,ht.sourceIn):0,$n=((ht==null?void 0:ht.sourceOut)??((Xo=he.source)==null?void 0:Xo.duration)??ua.value)-_a,Ds=n.serverRenderEndpoint!=null&&n.clientExportThreshold>0&&$n>n.clientExportThreshold;if(Ds){gt.value=!0;try{return await Cf(he),null}catch(ta){const Ea=ta instanceof Error?ta.message:"Server render failed";throw dt.value=Ea,i("server-render-failed",Ea),ta}finally{gt.value=!1}}if(n.maxDuration>0&&$n>n.maxDuration&&!Ds){const ta=`This video is too long for in-browser export (${Math.round($n)}s). Server rendering is not available. Try a shorter clip.`;return dt.value=ta,i("video-exported",null),null}gt.value=!0;try{const ta=await Ud(he,A,Ea=>{G||(bt.value=Ea)});return G?(dt.value="Export canceled.",bt.value=0,i("video-exported",null),null):(_t(),i("recipe-generated",he),i("video-exported",ta),bt.value=100,Yt.value=!0,ta)}catch(ta){if(G)return dt.value="Export canceled.",bt.value=0,i("video-exported",null),null;const Ea=ta instanceof Error?ta.message:"Local WebGL export failed.";throw dt.value=Ea,new Error(`Video export failed: ${Ea}`)}finally{gt.value=!1}}function Qi(){return new ys(n.serverRenderEndpoint??"/api/v1")}async function Cf(_){const A=Qi();dt.value="Starting server render...",bt.value=0;const ne=await A.createRenderJob({source_media_uuid:s.value,recipe:_});Ft.value=ne.id,i("server-render-started",ne.id),i("export-started",ne.id),dt.value="Rendering on server...";const he=await A.pollRenderJob(ne.id,(xe,Se)=>{bt.value=xe,Se==="processing"&&(dt.value=`Server rendering: ${xe}%`)},3e3,(n.maxDuration>0?n.maxDuration*3:1800)*1e3);bt.value=100,Yt.value=!0,dt.value="Server render complete!",_t(),i("recipe-generated",_);const Ce={id:he.id};typeof he.output_media_id=="string"&&he.output_media_id!==""&&(Ce.output_media_id=he.output_media_id),i("server-render-completed",Ce)}async function Od(){if(!gt.value)return;G=!0,w.value=!1,Le.cancelClientExport(),gn();const _=Ft.value;if(_)try{await Qi().cancelJob(_)}catch(A){const ne=A instanceof Error?A.message:"Failed to cancel export";dt.value=ne,gt.value=!1,Ft.value=null;return}gt.value=!1,bt.value=0,Yt.value=!1,Ft.value=null,dt.value="Export canceled."}async function zd(_){gn(),G=!1,Le.resetClientExport(),Ft.value=null,dt.value=null,Yt.value=!1,gt.value=!0,bt.value=0;try{const A=Go(_f(ke(),_));i("recipe-generated",A);const ne=s.value.startsWith("temp-"),he=A.timeline[0],Ce=Array.isArray(he==null?void 0:he.filters)?he.filters:[],xe=!0,Se=typeof window<"u"&&window.MEDIABLES_ALLOW_SERVER_EXPORT_FALLBACK===1||typeof localStorage<"u"&&localStorage.getItem("mediables.export.allowServerFallback")==="1";if(xe)try{const Ea=await Ud(A,_,Pf=>{G||(bt.value=Pf)});if(G){dt.value="Export canceled.",gt.value=!1,bt.value=0;return}i("video-exported",Ea);const Kd=URL.createObjectURL(Ea.file),Rs=document.createElement("a");Rs.href=Kd,Rs.download=`edited-video-${Date.now()}.mp4`,Rs.click(),setTimeout(()=>URL.revokeObjectURL(Kd),100),gt.value=!1,bt.value=100,Yt.value=!0;return}catch(Ea){if(G){dt.value="Export canceled.",gt.value=!1,bt.value=0;return}if(ne||!Se)throw Ea;bt.value=0,dt.value="Local filter export failed, falling back to server render."}const ht={"360p":"low","480p":"low","720p":"medium","1080p":"high","1440p":"ultra","2160p":"ultra"},_a=(_==null?void 0:_.quality)??A.output.quality,vo=ht[_a]??"high",$n={...xf(A),export:{format:(_==null?void 0:_.format)??A.output.format,quality:vo,resolution:_a,framerate:A.output.fps}},Xo=await Qi().createJob({source_media_id:s.value,recipe:$n}),ta=typeof Xo.id=="string"?Xo.id:null;if(!ta)throw new Error("Export failed: missing job id");Ft.value=ta,i("export-started",ta),Af(ta)}catch(A){if(w.value=!1,Le.resetClientExport(),G){dt.value="Export canceled.",gt.value=!1,bt.value=0,Ft.value=null;return}try{const ne=Go(ke()),he=new Blob([JSON.stringify(ne,null,2)],{type:"application/json"}),Ce=URL.createObjectURL(he),xe=document.createElement("a");xe.href=Ce,xe.download=`video-recipe-${Date.now()}.json`,xe.click(),setTimeout(()=>URL.revokeObjectURL(Ce),100)}finally{gt.value=!1,bt.value=0,Ft.value=null,dt.value=A instanceof Error?A.message:"Export failed"}}}const Bs=async _=>{await new Promise(A=>{window.setTimeout(A,_)})},Is=_=>{if(!_||_.width<=0||_.height<=0)return null;try{return _.toDataURL("image/jpeg",.85)}catch{return null}},Vf=_=>{if(!_||typeof _!="object")return null;const ne=_.pixiCanvas;if(ne&&typeof ne=="object"&&"value"in ne){const he=ne.value;return he instanceof HTMLCanvasElement?he:null}return ne instanceof HTMLCanvasElement?ne:null},Nf=_=>{if(!_||typeof _!="object")return null;const A=_.duration;if(typeof A=="number"&&Number.isFinite(A))return A;if(A&&typeof A=="object"&&"value"in A){const ne=A.value;if(typeof ne=="number"&&Number.isFinite(ne))return ne}return null},Tf=_=>{if(!_||typeof _!="object")return null;const ne=_.videoElement;if(ne&&typeof ne=="object"&&"value"in ne){const he=ne.value;return he instanceof HTMLVideoElement?he:null}return ne instanceof HTMLVideoElement?ne:null},jd=_=>typeof _.params=="object"&&_.params!==null?_.params:{},Bf=_=>{const A=[];for(const ne of _){const he=jd(ne),Ce=ne.filterId.trim().toLowerCase();if(Ce==="brightness"){const Se=($t(ea(he,["value","brightness"],0),-1,1)+1)*100;A.push(`brightness(${Se.toFixed(2)}%)`);continue}if(Ce==="contrast"){const xe=$t(ea(he,["value","contrast"],1),.1,4);A.push(`contrast(${(xe*100).toFixed(2)}%)`);continue}if(Ce==="saturation"||Ce==="saturate"){const xe=$t(ea(he,["value","saturation"],1),0,4);A.push(`saturate(${(xe*100).toFixed(2)}%)`);continue}if(Ce==="grayscale"){A.push("grayscale(100%)");continue}if(Ce==="sepia"){A.push("sepia(100%)");continue}if(Ce==="blur"||Ce==="gaussian-blur"||Ce==="kawase-blur"){const xe=$t(ea(he,["value","blur","radius"],0),0,30);xe>.01&&A.push(`blur(${xe.toFixed(2)}px)`);continue}if(Ce==="adjustment"){const xe=ea(he,["brightness"],1),Se=ea(he,["contrast"],1),ht=ea(he,["saturation"],1);Math.abs(xe-1)>.01&&A.push(`brightness(${($t(xe,0,5)*100).toFixed(2)}%)`),Math.abs(Se-1)>.01&&A.push(`contrast(${($t(Se,.1,5)*100).toFixed(2)}%)`),Math.abs(ht-1)>.01&&A.push(`saturate(${($t(ht,0,5)*100).toFixed(2)}%)`);continue}if(Ce==="cinematic"){A.push("contrast(120%) brightness(95%) saturate(85%)");continue}if(Ce==="dramatic"){A.push("contrast(140%) brightness(90%) saturate(110%) sepia(10%)");continue}if(Ce==="dreamy"){A.push("blur(0.5px) brightness(105%) saturate(90%) contrast(95%)");continue}}return A.join(" ")},If=_=>{const A=_.find(Ce=>Ce.filterId.trim().toLowerCase()==="noise");if(!A)return 0;const ne=jd(A),he=ea(ne,["noise","value","amount","intensity"],.2);return he<=1?$t(he,0,1):$t(he/100,0,1)},Mf=(_,A,ne,he)=>{if(he<=0)return;const Ce=_.getImageData(0,0,A,ne),xe=255*he;for(let Se=0;Se<Ce.data.length;Se+=4){const ht=(Math.random()*2-1)*xe;Ce.data[Se]=$t(Ce.data[Se]+ht,0,255),Ce.data[Se+1]=$t(Ce.data[Se+1]+ht,0,255),Ce.data[Se+2]=$t(Ce.data[Se+2]+ht,0,255)}_.putImageData(Ce,0,0)},Wd=async _=>{_.readyState>=2&&_.videoWidth>0&&_.videoHeight>0||await new Promise(A=>{let ne=!1,he=0;const Ce=()=>{ne||(ne=!0,_.removeEventListener("loadedmetadata",xe),_.removeEventListener("loadeddata",xe),_.removeEventListener("canplay",xe),window.clearTimeout(he),A())},xe=()=>{Ce()};_.addEventListener("loadedmetadata",xe),_.addEventListener("loadeddata",xe),_.addEventListener("canplay",xe),he=window.setTimeout(()=>Ce(),800),_.play().catch(()=>{})})},Ff=async(_,A)=>{await new Promise(ne=>{let he=!1,Ce=0;const xe=()=>{he||(he=!0,_.removeEventListener("seeked",Se),window.clearTimeout(Ce),ne())},Se=()=>{xe()};if(Math.abs(_.currentTime-A)<.016){requestAnimationFrame(()=>xe());return}_.addEventListener("seeked",Se),Ce=window.setTimeout(()=>xe(),700),_.currentTime=A})},Hd=async(_,A)=>{await Wd(_);const ne=Math.floor(_.videoWidth),he=Math.floor(_.videoHeight);if(ne<=0||he<=0)return null;const Ce=Number.isFinite(_.duration)&&_.duration>0?_.duration:0,xe=Ce>0?$t(A,0,Ce):0;await Ff(_,xe);const Se=document.createElement("canvas");Se.width=ne,Se.height=he;const ht=Se.getContext("2d");if(!ht)return null;const _a=Bf(ee.value);_a!==""&&(ht.filter=_a);try{ht.drawImage(_,0,0,ne,he)}catch{return null}const vo=If(ee.value);return Mf(ht,ne,he,vo),Is(Se)},$f=async(_,A)=>{const ne=document.createElement("video");ne.src=_,ne.muted=!0,ne.playsInline=!0,ne.preload="auto",_.startsWith("blob:")||(ne.crossOrigin="anonymous");try{return await Wd(ne),await Hd(ne,A)}catch{return null}finally{ne.pause(),ne.removeAttribute("src"),ne.load()}},Df=async _=>{const A=E.value,ne=Is(Vf(A));if(ne)return ne;if(A!=null&&A.captureFrameAt)for(let xe=0;xe<4;xe+=1){const Se=Nf(A);if(Se!==null&&Se<=0&&xe<2){await Bs(80);continue}const ht=await Promise.race([A.captureFrameAt(_),Bs(450).then(()=>null)]),_a=Is(ht);if(_a)return _a;await Bs(80)}const he=Tf(A);if(he){const xe=await Hd(he,_);if(xe)return xe}const Ce=_e.value.trim();if(Ce!==""){const xe=await $f(Ce,_);if(xe)return xe}return null},Zd=_=>_.map(A=>({...A,params:A.params&&typeof A.params=="object"?{...A.params}:A.params}));function Gd(_){const A=Zd(ee.value);if(!Ms(_)&&A.length>0&&Array.isArray(_.timeline)&&_.timeline.length>0){const he=_.timeline[0];he&&(_.timeline=[{...he,filters:A},..._.timeline.slice(1)])}return _}const Ms=_=>Array.isArray(_.timeline)?_.timeline.some(A=>Array.isArray(A.filters)&&A.filters.length>0):!1,Rf=_=>{if(!_||typeof _!="object")return null;const A=_.posterFrame;if(typeof A!="string")return null;const ne=A.trim();return ne!==""?ne:null};async function Fs(){const _=Go(Gd(it())),A=Zd(ee.value),ne=Ms(_)||A.length>0,he=Rf(n.initialRecipe);if(ne){const Ce=O.value>0?O.value:.1;try{const xe=await Df(Ce);xe?_.posterFrame=xe:he&&(_.posterFrame=he)}catch{he&&(_.posterFrame=he)}}else delete _.posterFrame;return _t(),i("draft-saved",_),_}function Xd(){ge()&&(ft(),za())}async function Af(_){gn();const A=Qi();ya=window.setInterval(async()=>{try{if(G){gn();return}const ne=await A.getJob(_),he=Number(ne.progress??0);if(bt.value=Number.isFinite(he)?he:0,ne.status==="completed"||ne.status==="failed"||ne.status==="cancelled")if(gn(),gt.value=!1,Ft.value=null,ne.status==="completed")bt.value=100,Yt.value=!0,dt.value=null;else{const Ce=ne.status==="cancelled"||typeof ne.error_message=="string"&&/cancel/i.test(ne.error_message);dt.value=Ce?"Export canceled.":typeof ne.error_message=="string"&&ne.error_message.trim()!==""?ne.error_message:"Export failed"}}catch(ne){gn(),gt.value=!1,Ft.value=null,dt.value=ne instanceof Error?ne.message:"Failed to check export progress"}},2e3)}function $s(){const _=Go(ke());try{const A=_.timeline??[]}catch{}$.value=_}let Fn=null;function za(){Fn&&clearTimeout(Fn),Fn=setTimeout(()=>{$s(),Fn=null},200)}e.watch(()=>D.value,za,{deep:!0}),e.watch(()=>se.value,_=>{if(L.value||!_)return;const A=(_==null?void 0:_.filters)??[];Mt(A)},{immediate:!0}),e.watch(()=>ee.value,_=>{vt(_),za()},{deep:!0}),e.watch(()=>T.value,_=>{xt(_),za()},{deep:!0}),e.watch(()=>R.value,_=>{const A=_.map(ne=>({...ne,source:typeof ne.source=="string"?ne.source:void 0}));wt(A),za()},{deep:!0}),e.watch(()=>O.value,za),a({saveDraft:Fs,exportForUpload:Sf}),$s(),e.onUnmounted(()=>{gn(),G=!0,Le.cancelClientExport(),Fn&&(clearTimeout(Fn),Fn=null),b.value&&(b.value.destroy(),b.value=null),I.value=null,x.value=null,N.value=null});function Lf(){Qt||!Po.value||(Qt=new c2({filters:ba.value,callbacks:{onApplyFilter:_=>{Bt(_.id)},onRemoveFilter:_=>{Ma(_)},onUpdateParam:(_,A,ne)=>{ro(_,A,ne)},onPreviewFilter:_=>{Je(_.id)}}}),Qt.mount(Po.value),Qt.setActiveFilters(q.value))}e.watch(q,_=>{Qt==null||Qt.setActiveFilters(_)},{deep:!0}),e.watch(ba,_=>{Qt==null||Qt.setFilters(_)});let bn=null;return e.onMounted(()=>{window.addEventListener("resize",W),window.addEventListener("keydown",vn);const _=()=>{!mn.value||bn||(bn=new ResizeObserver(A=>{A[0]&&(io.value=Math.round(A[0].contentRect.width))}),bn.observe(mn.value))};_(),bn||e.nextTick(_),l.value&&(Zo(),Va||e.nextTick(Zo)),n.media&&$s(),l.value&&e.nextTick(()=>{Lf()}),e.nextTick(()=>{const A=document.querySelector(".video-editor");A&&A.getBoundingClientRect();const ne=document.querySelector(".mobile-layout");ne&&ne.getBoundingClientRect()})}),e.onUnmounted(()=>{window.removeEventListener("resize",W),window.removeEventListener("keydown",vn),bn==null||bn.disconnect(),bn=null,Va==null||Va(),Va=null,Qt==null||Qt.destroy(),Qt=null}),(_,A)=>{var ne,he,Ce,xe;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-editor",{mobile:l.value}])},[l.value?(e.openBlock(),e.createElementBlock("div",MS,[e.createElementVNode("div",FS,[e.createElementVNode("div",$S,[e.createElementVNode("button",{class:e.normalizeClass(["mobile-toolbar-btn",{active:e.unref(ie)}]),onClick:A[0]||(A[0]=(...Se)=>e.unref(Oe)&&e.unref(Oe)(...Se)),"aria-label":e.unref(ie)?"Pause":"Play","data-testid":"btn-mobile-play"},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(ie)?e.unref(ql):e.unref(Yl)},null,8,["icon"])],10,DS),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:Xd,"aria-label":"Reset all changes","data-testid":"btn-mobile-reset"},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(eo)},null,8,["icon"])])]),e.createElementVNode("div",RS,[e.createElementVNode("button",{class:"mobile-toolbar-btn mobile-toolbar-save",onClick:Fs,"aria-label":"Save","data-testid":"btn-mobile-save",disabled:!e.unref(Z)},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Kr)},null,8,["icon"]),A[13]||(A[13]=e.createElementVNode("span",null,"Save",-1))],8,AS),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:A[1]||(A[1]=Se=>zd()),"aria-label":"Export","data-testid":"btn-mobile-export",disabled:gt.value||!e.unref(Z)},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Co)},null,8,["icon"])],8,LS),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:A[2]||(A[2]=Se=>i("close")),"aria-label":"Close","data-testid":"btn-mobile-close"},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Gn)},null,8,["icon"])])])]),e.createElementVNode("div",PS,[e.withDirectives(e.createVNode(ll,{ref_key:"pixiPreviewMobileRef",ref:h,"aria-hidden":!m.value,class:"preview-host-child",source:_e.value,"fallback-duration":ua.value,filters:Pe.value,playhead:at.value,"is-playing":e.unref(ie),"fit-mode":V.value,active:m.value,onPlayPause:e.unref(Oe),onFrameUpdate:Pa,onDurationChange:so},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,m.value]]),e.withDirectives(e.createVNode(xl,{"aria-hidden":!p.value,class:"preview-host-child","media-uuid":s.value,recipe:$.value,media:Ye.value,"enable-engine":p.value&&We.value,"fit-mode":V.value,onTimeUpdate:Tn,onPlayStateChange:Oo,onDurationChange:so,onEngineReady:Xi},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,p.value]]),gt.value?(e.openBlock(),e.createElementBlock("div",US,[e.createElementVNode("div",OS,[e.createElementVNode("span",null,"Exporting "+e.toDisplayString(bt.value)+"%",1),e.createElementVNode("div",zS,[e.createElementVNode("div",{class:"mobile-export-bar-fill",style:e.normalizeStyle({width:bt.value+"%"})},null,4)]),e.createElementVNode("button",{class:"mobile-export-cancel",onClick:Od},"Cancel")])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:mn,class:"timeline-section"},[e.createElementVNode("div",jS,[e.createElementVNode("button",{ref_key:"mobileZoomOutButtonRef",ref:Uo,type:"button",class:"mobile-zoom-btn","aria-label":"Zoom out timeline","data-testid":"btn-timeline-zoom-out"},[...A[14]||(A[14]=[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16"},[e.createElementVNode("path",{d:"M4 8h8",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})],-1)])],512),e.createElementVNode("button",{ref_key:"mobileZoomInButtonRef",ref:pn,type:"button",class:"mobile-zoom-btn","aria-label":"Zoom in timeline","data-testid":"btn-timeline-zoom-in"},[...A[15]||(A[15]=[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16"},[e.createElementVNode("path",{d:"M4 8h8M8 4v8",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})],-1)])],512)]),e.createVNode(Sl,{playhead:e.unref(O),clips:e.unref(D),"selected-clip-id":((ne=e.unref(se))==null?void 0:ne.id)??((he=e.unref(D)[0])==null?void 0:he.id)??null,duration:ua.value,fps:e.unref(ve),"zoom-level":e.unref(Ue),"snap-enabled":Ct.value,sensitivity:.25,"is-mobile":!0,"onUpdate:playhead":e.unref(lt),onTrim:e.unref(fe),onSplit:jo,onClipSelect:zo,onClipMove:e.unref(Tt),onClipLongPress:Hi,onSnapStateChange:Bn},null,8,["playhead","clips","selected-clip-id","duration","fps","zoom-level","snap-enabled","onUpdate:playhead","onTrim","onClipMove"])],512),e.createElementVNode("div",WS,[e.createElementVNode("div",HS,[e.createElementVNode("span",ZS,e.toDisplayString(Oi.value),1),e.createElementVNode("span",GS,e.toDisplayString(xs.value),1)]),e.createElementVNode("div",XS,[e.createElementVNode("button",{type:"button",class:"mobile-cut-nav-btn","data-testid":"btn-mobile-prev-cut","aria-label":"Jump to previous cut",disabled:!Es.value,onClick:Oa}," Prev Cut ",8,KS),e.createElementVNode("div",JS,[e.createElementVNode("span",qS,"Playhead "+e.toDisplayString(Ss.value),1),e.createElementVNode("span",YS,"In "+e.toDisplayString(Ao.value),1),e.createElementVNode("span",QS,"Out "+e.toDisplayString(ji.value),1),e.createElementVNode("span",eC,"Duration "+e.toDisplayString(Cs.value),1)]),e.createElementVNode("button",{type:"button",class:"mobile-cut-nav-btn","data-testid":"btn-mobile-next-cut","aria-label":"Jump to next cut",disabled:!un.value,onClick:Zi}," Next Cut ",8,tC)]),e.createElementVNode("div",aC,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["mobile-snap-toggle",{active:Ct.value}]),"data-testid":"btn-mobile-snap-toggle",onClick:lo},e.toDisplayString(Ct.value?"Snap On":"Snap Off"),3),e.createElementVNode("div",nC,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(wa,Se=>e.createElementVNode("button",{key:Se,type:"button",class:e.normalizeClass(["mobile-speed-chip",{active:e.unref(me)===Se}]),"data-testid":`btn-mobile-speed-${String(Se).replace(".","-")}`,onClick:ht=>Mn(Se)},e.toDisplayString(Se)+"x ",11,oC)),64))])]),e.createElementVNode("div",iC,[e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-undo","aria-label":"Undo",disabled:!e.unref(F),onClick:co}," Undo ",8,rC),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-redo","aria-label":"Redo",disabled:!e.unref(Y),onClick:uo}," Redo ",8,sC),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-split","aria-label":"Split at playhead",disabled:!ot.value,onClick:hn}," Split ",8,lC),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-duplicate","aria-label":"Duplicate selected clip",disabled:!jt.value,onClick:In}," Duplicate ",8,dC),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn mobile-edit-btn--danger","data-testid":"btn-mobile-delete","aria-label":"Delete selected clip",disabled:!Ze.value,onClick:mo}," Delete ",8,cC)])]),e.createElementVNode("div",{ref_key:"mobileControlsRef",ref:Po,class:"controls-section mobile-controls"},null,512),oo.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"mobile-action-sheet-backdrop","data-testid":"video-mobile-action-sheet",onClick:Ua},[e.createElementVNode("div",{class:"mobile-action-sheet",onClick:A[3]||(A[3]=e.withModifiers(()=>{},["stop"]))},[A[16]||(A[16]=e.createElementVNode("div",{class:"mobile-action-sheet-handle"},null,-1)),e.createElementVNode("div",uC,[e.createElementVNode("span",mC,e.toDisplayString(Vs.value),1),e.createElementVNode("span",pC,e.toDisplayString(Ns.value),1)]),e.createElementVNode("div",fC,[e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-undo",disabled:!e.unref(F),onClick:co},"Undo",8,hC),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-redo",disabled:!e.unref(Y),onClick:uo},"Redo",8,vC),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-split",disabled:!ot.value,onClick:hn},"Split",8,gC),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-duplicate",disabled:!jt.value,onClick:In},"Duplicate",8,bC),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn mobile-action-sheet-btn--danger","data-testid":"btn-mobile-sheet-delete",disabled:!Ze.value,onClick:mo},"Delete",8,yC),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-close",onClick:Ua},"Close")])])])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",wC,[e.createElementVNode("div",kC,[e.createElementVNode("div",_C,[e.createElementVNode("div",EC,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":A[4]||(A[4]=Se=>V.value=Se),"aria-label":"Fit mode","data-testid":"select-video-fit-mode"},[...A[17]||(A[17]=[e.createElementVNode("option",{value:"contain"},"Contain",-1),e.createElementVNode("option",{value:"cover"},"Cover",-1),e.createElementVNode("option",{value:"none"},"None",-1)])],512),[[e.vModelSelect,V.value]])])]),e.withDirectives(e.createVNode(ll,{ref_key:"pixiPreviewDesktopRef",ref:v,"aria-hidden":!m.value,class:"preview-host-child",source:_e.value,"fallback-duration":ua.value,filters:Pe.value,playhead:at.value,"is-playing":e.unref(ie),"fit-mode":V.value,active:m.value,onPlayPause:e.unref(Oe),onFrameUpdate:Pa,onDurationChange:so},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,m.value]]),e.withDirectives(e.createVNode(xl,{"aria-hidden":!p.value,class:"preview-host-child","media-uuid":s.value,recipe:$.value,media:Ye.value,"enable-engine":p.value&&We.value,"fit-mode":V.value,onTimeUpdate:Tn,onPlayStateChange:Oo,onDurationChange:so,onEngineReady:Xi},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,p.value]]),_.showThumbnailPicker?(e.openBlock(),e.createBlock(Ok,{key:0,"media-uuid":s.value,duration:ua.value,onSelect:ho},null,8,["media-uuid","duration"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",xC,[e.createElementVNode("div",SC,[e.createElementVNode("div",CC,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(K.value,Se=>(e.openBlock(),e.createElementBlock("button",{key:Se.id,class:e.normalizeClass(["tab-btn",{active:c.value===Se.id}]),onClick:ht=>c.value=Se.id},e.toDisplayString(Se.label),11,VC))),128))]),e.createElementVNode("div",NC,[e.withDirectives(e.createElementVNode("div",TC,[e.createVNode(Vl,{filters:ba.value,"active-filters":q.value,"thumbnail-url":le.value,onApplyFilter:Bt,onRemoveFilter:Ma,onUpdateParam:ro,onPreviewFilter:Ki},null,8,["filters","active-filters","thumbnail-url"])],512),[[e.vShow,c.value==="filters"]]),e.withDirectives(e.createElementVNode("div",BC,[e.createVNode(Bl,{overlays:T.value,onAddOverlay:qi,onUpdateOverlay:Yi,onRemoveOverlay:g},null,8,["overlays"])],512),[[e.vShow,c.value==="text"]]),e.withDirectives(e.createElementVNode("div",IC,[e.createVNode(Il,{"selected-clips":U.value,"applied-transitions":y.value,onApplyTransition:M,onRemoveTransition:te,onPreviewTransition:pe},null,8,["selected-clips","applied-transitions"])],512),[[e.vShow,c.value==="transitions"]]),e.withDirectives(e.createElementVNode("div",MC,[e.createVNode(Ml,{"audio-layers":R.value,"master-volume":z.value,onAddTrack:$e,onUpdateTrack:De,onRemoveTrack:Qe,onUpdateVolume:yt,onToggleMute:Lt,onUpdateMasterVolume:ra},null,8,["audio-layers","master-volume"])],512),[[e.vShow,c.value==="audio"]]),e.withDirectives(e.createElementVNode("div",FC,[e.unref(we)?(e.openBlock(),e.createBlock(Nl,{key:0,filter:e.unref(we),"current-frame":e.unref(re),onUpdateParams:Ji},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",$C,[...A[18]||(A[18]=[e.createElementVNode("p",null,"Select a filter from the Filters tab to adjust its parameters",-1)])]))],512),[[e.vShow,c.value==="adjustments"]]),e.withDirectives(e.createElementVNode("div",DC,[e.createVNode(Tl,{"can-export":e.unref(Z),"is-exporting":gt.value,"export-progress":bt.value,onExport:zd,onCancelExport:Od,onSaveDraft:Fs,onReset:Xd},null,8,["can-export","is-exporting","export-progress"]),Yt.value?(e.openBlock(),e.createElementBlock("div",RC," Export complete ")):e.createCommentVNode("",!0),dt.value&&!Yt.value?(e.openBlock(),e.createElementBlock("div",AC,e.toDisplayString(dt.value),1)):e.createCommentVNode("",!0)],512),[[e.vShow,c.value==="export"]])])])])]),e.createElementVNode("div",LC,[e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:mn,class:"timeline-container"},[e.createElementVNode("div",PC,[e.createElementVNode("label",null,[A[19]||(A[19]=e.createTextVNode(" Zoom ",-1)),e.createElementVNode("input",{type:"range",min:"10",max:"600",value:e.unref(Ue),onInput:A[5]||(A[5]=Se=>fo(Se))},null,40,UC)]),e.createElementVNode("span",OC,e.toDisplayString(Math.round(e.unref(Ue)))+" px/s",1),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["desktop-snap-toggle",{active:Ct.value}]),"data-testid":"btn-desktop-snap-toggle",onClick:lo},e.toDisplayString(Ct.value?"Snap On":"Snap Off"),3)]),e.createVNode(Sl,{playhead:e.unref(O),clips:e.unref(D),"selected-clip-id":((Ce=e.unref(se))==null?void 0:Ce.id)??((xe=e.unref(D)[0])==null?void 0:xe.id)??null,duration:ua.value,fps:e.unref(ve),"zoom-level":e.unref(Ue),"snap-enabled":Ct.value,sensitivity:.25,"onUpdate:playhead":e.unref(lt),onTrim:e.unref(fe),onSplit:jo,onClipSelect:zo,onClipMove:e.unref(Tt),onClipLongPress:Hi,onSnapStateChange:Bn},null,8,["playhead","clips","selected-clip-id","duration","fps","zoom-level","snap-enabled","onUpdate:playhead","onTrim","onClipMove"]),e.createVNode(Cl,{"selected-clip":e.unref(se),"can-split":ot.value,"can-delete":Ze.value,"is-playing":e.unref(ie),"zoom-level":e.unref(Ue),"playback-speed":e.unref(me),onSplit:hn,onDelete:mo,onDuplicate:In,onZoomIn:Ld,onZoomOut:Pd,onZoomChange:Wo,onFitToWindow:Gi,onPlayPause:e.unref(Oe),onFrameForward:e.unref(zt),onFrameBackward:e.unref(At),onSkipToStart:e.unref(Jt),onSkipToEnd:e.unref(Gt),onSpeedChange:e.unref(la)},null,8,["selected-clip","can-split","can-delete","is-playing","zoom-level","playback-speed","onPlayPause","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"]),Ne.value?(e.openBlock(),e.createElementBlock("div",zC,[e.createElementVNode("div",jC,[e.createElementVNode("label",WC,[A[20]||(A[20]=e.createElementVNode("span",null,"Trim start (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":A[6]||(A[6]=Se=>da.value=Se),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-start"},null,512),[[e.vModelText,da.value]])]),e.createElementVNode("label",HC,[A[21]||(A[21]=e.createElementVNode("span",null,"Trim end (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":A[7]||(A[7]=Se=>ca.value=Se),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-end"},null,512),[[e.vModelText,ca.value]])]),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-start-playhead",disabled:!e.unref(se),onClick:A[8]||(A[8]=Se=>fn("start"))}," Start = Playhead ",8,ZC),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-end-playhead",disabled:!e.unref(se),onClick:A[9]||(A[9]=Se=>fn("end"))}," End = Playhead ",8,GC),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-trim",disabled:!e.unref(se),onClick:La}," Apply Trim ",8,XC)]),e.createElementVNode("div",KC,[e.createElementVNode("label",JC,[A[22]||(A[22]=e.createElementVNode("span",null,"Quick filter",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":A[10]||(A[10]=Se=>qt.value=Se),"data-testid":"video-dev-filter-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ba.value,Se=>(e.openBlock(),e.createElementBlock("option",{key:Se.id,value:Se.id},e.toDisplayString(Se.name),9,qC))),128))],512),[[e.vModelSelect,qt.value]])]),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-filter",disabled:!e.unref(se)||qt.value==="",onClick:Nt}," Apply Filter ",8,YC),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-clear-filters",disabled:e.unref(ee).length===0,onClick:an}," Clear Filters ",8,QC),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"btn-apply-noise-filter","aria-label":"Apply noise filter for QA testing",disabled:!e.unref(se),onClick:A[11]||(A[11]=Se=>Bt("noise"))}," QA: Noise ",8,eV),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"btn-apply-grayscale-filter","aria-label":"Apply grayscale filter for QA testing",disabled:!e.unref(se),onClick:A[12]||(A[12]=Se=>Bt("grayscale"))}," QA: Grayscale ",8,tV)])])):e.createCommentVNode("",!0)],512)])]))],2)}}}),Pp=Fe(aV,[["__scopeId","data-v-1bb4247b"]]),nV={key:0,class:"video-editor-v2-toolbar"},oV={class:"video-editor-v2-body"},iV={key:0,class:"video-editor-v2-assets","data-testid":"v2-assets-panel"},rV={class:"video-editor-v2-main"},sV={class:"video-editor-v2-canvas"},lV={key:1,class:"video-editor-v2-timeline"},dV=["aria-expanded"],cV=["aria-hidden","inert"],uV="(max-width: 900px)",mV=e.defineComponent({__name:"SplitPanelLayout",setup(o,{expose:a}){const t=e.ref(!1),n=e.ref(!1);let i=null,r=null;const s=c=>{t.value=c,c&&(n.value=!1)},l=()=>{n.value=!0},d=()=>{n.value=!1};return e.onMounted(()=>{typeof window>"u"||!window.matchMedia||(i=window.matchMedia(uV),s(i.matches),r=c=>s(c.matches),i.addEventListener?i.addEventListener("change",r):"addListener"in i&&i.addListener(r))}),e.onBeforeUnmount(()=>{!i||!r||(i.removeEventListener?i.removeEventListener("change",r):"removeListener"in i&&i.removeListener(r),i=null,r=null)}),a({isMobile:t}),(c,u)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-editor-v2",{"is-mobile":t.value,"is-desktop":!t.value}]),"data-testid":"video-editor-v2-shell"},[c.$slots.toolbar?(e.openBlock(),e.createElementBlock("div",nV,[e.renderSlot(c.$slots,"toolbar",{},void 0,!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",oV,[!t.value&&c.$slots.assets?(e.openBlock(),e.createElementBlock("aside",iV,[e.renderSlot(c.$slots,"assets",{},void 0,!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",rV,[e.createElementVNode("div",sV,[e.renderSlot(c.$slots,"canvas",{},void 0,!0)])])]),c.$slots.timeline?(e.openBlock(),e.createElementBlock("div",lV,[e.renderSlot(c.$slots,"timeline",{isMobile:t.value},void 0,!0)])):e.createCommentVNode("",!0),!t.value&&c.$slots.inspector?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[n.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"video-editor-v2-tools-tab",type:"button","data-testid":"v2-tools-drawer-open","aria-label":"Open editor tools","aria-controls":"v2-editor-tools-drawer","aria-expanded":n.value?"true":"false",onClick:l}," Tools ",8,dV)),n.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"video-editor-v2-drawer-backdrop","data-testid":"v2-tools-drawer-backdrop",onClick:d})):e.createCommentVNode("",!0),e.createElementVNode("aside",{id:"v2-editor-tools-drawer",class:e.normalizeClass(["video-editor-v2-side",{"is-open":n.value}]),"data-testid":"v2-side-panel","aria-hidden":n.value?"false":"true",inert:!n.value},[e.createElementVNode("div",{class:"video-editor-v2-side-header"},[u[0]||(u[0]=e.createElementVNode("span",null,"Tools",-1)),e.createElementVNode("button",{class:"video-editor-v2-side-close",type:"button","data-testid":"v2-tools-drawer-close","aria-label":"Close editor tools",onClick:d}," x ")]),e.renderSlot(c.$slots,"inspector",{},void 0,!0)],10,cV)],64)):e.createCommentVNode("",!0),t.value?e.renderSlot(c.$slots,"drawer",{key:3},void 0,!0):e.createCommentVNode("",!0)],2))}}),pV=Fe(mV,[["__scopeId","data-v-ed83bde0"]]),fV=["aria-selected"],hV={class:"asset-rail-item__main"},vV={class:"asset-rail-item__type","data-testid":"asset-rail-item-type"},gV={class:"asset-rail-item__label","data-testid":"asset-rail-item-label"},bV={key:0,class:"asset-rail-item__details","data-testid":"asset-rail-item-details"},yV={class:"asset-rail-item__actions","aria-label":"Asset actions"},wV=e.defineComponent({__name:"AssetRailItem",props:{source:{},selected:{type:Boolean}},emits:["add","replaceSelected","remove"],setup(o,{emit:a}){const t=o,n=a,i=e.computed(()=>t.source.label??t.source.name??t.source.filename??t.source.id),r=e.computed(()=>{if(typeof t.source.duration!="number"||!Number.isFinite(t.source.duration))return null;const c=Math.max(0,Math.round(t.source.duration)),u=Math.floor(c/60),f=c%60;return`${u}:${f.toString().padStart(2,"0")}`}),s=e.computed(()=>typeof t.source.width!="number"||typeof t.source.height!="number"||!Number.isFinite(t.source.width)||!Number.isFinite(t.source.height)?null:`${Math.round(t.source.width)}x${Math.round(t.source.height)}`),l=e.computed(()=>[r.value,s.value].filter(c=>c!==null)),d=c=>{if(c==="add"){n("add",t.source.id);return}if(c==="replaceSelected"){n("replaceSelected",t.source.id);return}n("remove",t.source.id)};return(c,u)=>(e.openBlock(),e.createElementBlock("article",{class:e.normalizeClass(["asset-rail-item",{"is-selected":c.selected}]),"aria-selected":c.selected?"true":"false","data-testid":"asset-rail-item"},[e.createElementVNode("div",hV,[e.createElementVNode("span",vV,e.toDisplayString(c.source.type),1),e.createElementVNode("span",gV,e.toDisplayString(i.value),1),l.value.length>0?(e.openBlock(),e.createElementBlock("span",bV,e.toDisplayString(l.value.join(" / ")),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",yV,[e.createElementVNode("button",{class:"asset-rail-item__action",type:"button",title:"Add to timeline","aria-label":"Add to timeline","data-testid":"asset-rail-item-add",onClick:u[0]||(u[0]=f=>d("add"))}," + "),e.createElementVNode("button",{class:"asset-rail-item__action",type:"button",title:"Replace selected","aria-label":"Replace selected","data-testid":"asset-rail-item-replace",onClick:u[1]||(u[1]=f=>d("replaceSelected"))}," R "),e.createElementVNode("button",{class:"asset-rail-item__action asset-rail-item__action--danger",type:"button",title:"Remove asset","aria-label":"Remove asset","data-testid":"asset-rail-item-remove",onClick:u[2]||(u[2]=f=>d("remove"))}," - ")])],10,fV))}}),kV=Fe(wV,[["__scopeId","data-v-3ba2fd25"]]),_V={class:"asset-rail__header"},EV={key:0,class:"asset-rail__list","data-testid":"asset-rail-list"},xV={key:1,class:"asset-rail__empty","data-testid":"asset-rail-empty"},SV=e.defineComponent({__name:"AssetRail",props:{sources:{},selectedSourceId:{},uploadsEnabled:{type:Boolean}},emits:["add","replaceSelected","remove","importFiles"],setup(o,{emit:a}){const t=a,n=e.ref(null),i=e.ref(!1),r=(f,m)=>{if(f==="add"){t("add",m);return}if(f==="replaceSelected"){t("replaceSelected",m);return}t("remove",m)},s=()=>{var f;(f=n.value)==null||f.click()},l=f=>{const m=f.target;if(!(m!=null&&m.files)||m.files.length===0)return;const p=Array.from(m.files);t("importFiles",p),m.value=""},d=f=>{f.preventDefault(),f.dataTransfer&&(f.dataTransfer.dropEffect="copy"),i.value=!0},c=()=>{i.value=!1},u=f=>{var p;f.preventDefault(),i.value=!1;const m=Array.from(((p=f.dataTransfer)==null?void 0:p.files)??[]);m.length!==0&&t("importFiles",m)};return(f,m)=>(e.openBlock(),e.createElementBlock("section",{class:e.normalizeClass(["asset-rail",{"asset-rail--drag-over":i.value&&f.uploadsEnabled}]),"aria-label":"Assets","data-testid":"asset-rail",onDragover:d,onDragleave:c,onDrop:u},[e.createElementVNode("div",_V,[m[3]||(m[3]=e.createElementVNode("h2",{class:"asset-rail__title"},"Assets",-1)),f.uploadsEnabled?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"asset-rail__upload","data-testid":"asset-rail-upload","aria-label":"Upload media files",onClick:s}," Upload ")):e.createCommentVNode("",!0),f.uploadsEnabled?(e.openBlock(),e.createElementBlock("input",{key:1,ref_key:"fileInput",ref:n,class:"asset-rail__file-input",type:"file",accept:"video/mp4,video/webm,video/quicktime,image/png,image/jpeg,image/webp,audio/mpeg,audio/aac,audio/wav",multiple:"","data-testid":"asset-rail-file-input",onChange:l},null,544)):e.createCommentVNode("",!0)]),f.sources.length>0?(e.openBlock(),e.createElementBlock("div",EV,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.sources,p=>(e.openBlock(),e.createBlock(kV,{key:p.id,source:p,selected:p.id===f.selectedSourceId,onAdd:m[0]||(m[0]=h=>r("add",h)),onReplaceSelected:m[1]||(m[1]=h=>r("replaceSelected",h)),onRemove:m[2]||(m[2]=h=>r("remove",h))},null,8,["source","selected"]))),128))])):(e.openBlock(),e.createElementBlock("p",xV,e.toDisplayString(f.uploadsEnabled?"Drop files here or click Upload to add media.":"No assets"),1))],34))}}),CV=Fe(SV,[["__scopeId","data-v-3db665c6"]]),VV={class:"audio-mixer-panel__tracks","data-testid":"audio-mixer-tracks"},NV={key:0,class:"audio-mixer-panel__empty","data-testid":"audio-mixer-empty"},TV=["data-testid"],BV={class:"audio-mixer-strip__header"},IV={class:"audio-mixer-strip__identity"},MV={class:"audio-mixer-strip__kind"},FV=["data-testid"],$V=["data-testid"],DV=["data-testid"],RV={class:"audio-mixer-meter__rail","aria-hidden":"true"},AV={class:"audio-mixer-meter__value"},LV={class:"audio-mixer-strip__controls"},PV=["for"],UV=["id","min","max","value","data-testid","onInput"],OV={class:"audio-mixer-control__value"},zV={class:"audio-mixer-buttons"},jV=["aria-pressed","aria-label","data-testid","onClick"],WV=["aria-pressed","aria-label","data-testid","onClick"],HV=["for"],ZV=["id","value","data-testid","onInput"],GV={class:"audio-mixer-control__value"},XV=["data-testid"],KV={key:0},JV={key:1},qV=["data-testid"],YV=["data-testid"],QV=["data-testid"],eN={class:"audio-mixer-routing__target"},tN={class:"audio-mixer-strip__header"},aN={class:"audio-mixer-strip__identity"},nN={class:"audio-mixer-strip__name","data-testid":"audio-mixer-master-name"},oN={class:"audio-mixer-meter__rail","aria-hidden":"true"},iN={class:"audio-mixer-meter__value"},rN={class:"audio-mixer-strip__controls"},sN={key:0,class:"audio-mixer-control audio-mixer-control--fader",for:"audio-mixer-master-fader"},lN=["min","max","value"],dN={class:"audio-mixer-control__value"},cN={class:"audio-mixer-buttons"},uN=["aria-pressed","aria-label"],mN={key:1,class:"audio-mixer-effects","data-testid":"audio-mixer-master-effects"},pN=["data-testid"],fN=e.defineComponent({__name:"AudioMixerPanel",props:{state:{},deviceClass:{}},emits:["update"],setup(o,{emit:a}){const t=o,n=a,i=e.computed(()=>j2(t.deviceClass,t.state.capabilities)),r=e.computed(()=>t.deviceClass==="desktop"),s=e.computed(()=>[...t.state.tracks].sort((z,W)=>z.order-W.order)),l=e.computed(()=>{const z=new Map(W2(s.value,t.state.master.muted).map(W=>[W.trackId,W]));return s.value.map(W=>({track:W,effectiveState:z.get(W.id)??null}))}),d=e.computed(()=>i.value.canAdjustTrackFaders),c=e.computed(()=>i.value.canAdjustMasterFader),u=e.computed(()=>i.value.canMuteTracks),f=e.computed(()=>r.value&&i.value.canSoloTracks),m=e.computed(()=>r.value&&i.value.canAdjustPan),p=e.computed(()=>i.value.canViewMeters&&i.value.meterMode!=="off"),h=e.computed(()=>r.value&&i.value.canEditEffectSlots&&i.value.maxEffectSlots>0),v=e.computed(()=>r.value&&i.value.canEditRouting),w=z=>{if(!(z.target instanceof HTMLInputElement))return null;const W=Number(z.target.value);return Number.isFinite(W)?W:null},E=(z,W)=>{if(!d.value)return;const B=w(W);B!==null&&n("update",{type:"track-fader-db",trackId:z.id,valueDb:Si(B)})},S=z=>{u.value&&n("update",{type:"track-mute",trackId:z.id,muted:!z.controls.muted})},k=z=>{f.value&&n("update",{type:"track-solo",trackId:z.id,solo:!z.controls.solo})},b=(z,W)=>{if(!m.value)return;const B=w(W);B!==null&&n("update",{type:"track-pan",trackId:z.id,pan:Ym(B)})},$=z=>{if(!c.value)return;const W=w(z);W!==null&&n("update",{type:"master-fader-db",valueDb:Si(W)})},V=z=>{u.value&&n("update",{type:"master-mute",muted:!z.muted})},I=z=>{const W=Math.round(z*10)/10;return W>0?`+${W.toFixed(W%1===0?0:1)} dB`:`${W.toFixed(W%1===0?0:1)} dB`},x=z=>z===0?"C":`${z<0?"L":"R"} ${Math.round(Math.abs(z)*100)}`,N=z=>{if(z===void 0)return"";const W=Math.round(z*10)/10;return`${W.toFixed(W%1===0?0:1)}s`},L=z=>I(z),C=z=>{if(!Number.isFinite(z))return 0;const W=Math.min(Pr,Math.max(xn,z)),B=Pr-xn;return Math.round((W-xn)/B*100)},T=z=>z.slice(0,i.value.maxEffectSlots),y=z=>h.value&&T(z).length>0,R=z=>z.timeline.fadeIn!==void 0||z.timeline.fadeOut!==void 0,U=z=>z===null?"Unknown":z.mutedByMaster?"Master muted":z.mutedByTrack?"Muted":z.mutedBySolo?"Muted by solo":z.soloed?"Solo active":"Audible";return(z,W)=>(e.openBlock(),e.createElementBlock("section",{class:e.normalizeClass(["audio-mixer-panel",`audio-mixer-panel--${z.deviceClass}`]),"data-testid":"audio-mixer-panel","aria-label":"Audio mixer"},[e.createElementVNode("div",VV,[l.value.length===0?(e.openBlock(),e.createElementBlock("p",NV," No audio tracks ")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,({track:B,effectiveState:P})=>(e.openBlock(),e.createElementBlock("article",{key:B.id,class:e.normalizeClass(["audio-mixer-strip",{"is-muted":(P==null?void 0:P.effectivelyMuted)===!0,"is-soloed":B.controls.solo}]),"data-testid":`audio-mixer-track-${B.id}`},[e.createElementVNode("header",BV,[e.createElementVNode("div",IV,[e.createElementVNode("span",MV,e.toDisplayString(B.kind),1),e.createElementVNode("h3",{class:"audio-mixer-strip__name","data-testid":`audio-mixer-track-name-${B.id}`},e.toDisplayString(B.name),9,FV)]),e.createElementVNode("span",{class:e.normalizeClass(["audio-mixer-strip__status",{"is-active":(P==null?void 0:P.audible)===!0}]),"data-testid":`audio-mixer-track-status-${B.id}`},e.toDisplayString(U(P)),11,$V)]),p.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["audio-mixer-meter",{"is-clipping":B.controls.meter.clipping}]),"data-testid":`audio-mixer-track-meter-${B.id}`,"aria-label":"Track meter"},[e.createElementVNode("span",RV,[e.createElementVNode("span",{class:"audio-mixer-meter__fill",style:e.normalizeStyle({width:`${C(B.controls.meter.peakDb)}%`})},null,4)]),e.createElementVNode("span",AV,e.toDisplayString(L(B.controls.meter.peakDb)),1)],10,DV)):e.createCommentVNode("",!0),e.createElementVNode("div",LV,[d.value?(e.openBlock(),e.createElementBlock("label",{key:0,class:"audio-mixer-control audio-mixer-control--fader",for:`audio-mixer-track-fader-${B.id}`},[W[2]||(W[2]=e.createElementVNode("span",{class:"audio-mixer-control__label"},"Level",-1)),e.createElementVNode("input",{id:`audio-mixer-track-fader-${B.id}`,type:"range",class:"audio-mixer-control__range",min:B.controls.fader.minDb,max:B.controls.fader.maxDb,value:B.controls.fader.valueDb,step:"0.5","data-testid":`audio-mixer-track-fader-${B.id}`,onInput:X=>E(B,X)},null,40,UV),e.createElementVNode("span",OV,e.toDisplayString(I(B.controls.fader.valueDb)),1)],8,PV)):e.createCommentVNode("",!0),e.createElementVNode("div",zV,[u.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["audio-mixer-button",{"is-active":B.controls.muted}]),"aria-pressed":B.controls.muted?"true":"false","aria-label":B.controls.muted?`Unmute ${B.name}`:`Mute ${B.name}`,"data-testid":`audio-mixer-track-mute-${B.id}`,onClick:X=>S(B)}," M ",10,jV)):e.createCommentVNode("",!0),f.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:e.normalizeClass(["audio-mixer-button audio-mixer-button--solo",{"is-active":B.controls.solo}]),"aria-pressed":B.controls.solo?"true":"false","aria-label":B.controls.solo?`Clear solo on ${B.name}`:`Solo ${B.name}`,"data-testid":`audio-mixer-track-solo-${B.id}`,onClick:X=>k(B)}," S ",10,WV)):e.createCommentVNode("",!0)])]),m.value?(e.openBlock(),e.createElementBlock("label",{key:1,class:"audio-mixer-control audio-mixer-control--pan",for:`audio-mixer-track-pan-${B.id}`},[W[3]||(W[3]=e.createElementVNode("span",{class:"audio-mixer-control__label"},"Pan",-1)),e.createElementVNode("input",{id:`audio-mixer-track-pan-${B.id}`,type:"range",class:"audio-mixer-control__range",min:"-1",max:"1",step:"0.01",value:B.controls.pan.value,"data-testid":`audio-mixer-track-pan-${B.id}`,onInput:X=>b(B,X)},null,40,ZV),e.createElementVNode("span",GV,e.toDisplayString(x(B.controls.pan.value)),1)],8,HV)):e.createCommentVNode("",!0),R(B)?(e.openBlock(),e.createElementBlock("div",{key:2,class:"audio-mixer-strip__fades","data-testid":`audio-mixer-track-fades-${B.id}`},[B.timeline.fadeIn!==void 0?(e.openBlock(),e.createElementBlock("span",KV," In "+e.toDisplayString(N(B.timeline.fadeIn)),1)):e.createCommentVNode("",!0),B.timeline.fadeOut!==void 0?(e.openBlock(),e.createElementBlock("span",JV," Out "+e.toDisplayString(N(B.timeline.fadeOut)),1)):e.createCommentVNode("",!0)],8,XV)):e.createCommentVNode("",!0),y(B.effectSlots)?(e.openBlock(),e.createElementBlock("div",{key:3,class:"audio-mixer-effects","data-testid":`audio-mixer-track-effects-${B.id}`},[W[4]||(W[4]=e.createElementVNode("span",{class:"audio-mixer-effects__label"},"FX",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T(B.effectSlots),X=>(e.openBlock(),e.createElementBlock("span",{key:X.id,class:e.normalizeClass(["audio-mixer-effect",{"is-empty":X.kind==="empty","is-bypassed":X.bypassed,"is-enabled":X.enabled&&!X.bypassed}]),"data-testid":`audio-mixer-track-effect-${B.id}-${X.index}`},e.toDisplayString(X.label),11,YV))),128))],8,qV)):e.createCommentVNode("",!0),v.value?(e.openBlock(),e.createElementBlock("div",{key:4,class:"audio-mixer-routing","data-testid":`audio-mixer-track-routing-${B.id}`},[W[5]||(W[5]=e.createElementVNode("span",{class:"audio-mixer-routing__label"},"Route",-1)),e.createElementVNode("span",eN,e.toDisplayString(z.state.master.name),1)],8,QV)):e.createCommentVNode("",!0)],10,TV))),128))]),e.createElementVNode("article",{class:e.normalizeClass(["audio-mixer-strip audio-mixer-strip--master",{"is-muted":z.state.master.muted}]),"data-testid":"audio-mixer-master-strip"},[e.createElementVNode("header",tN,[e.createElementVNode("div",aN,[W[6]||(W[6]=e.createElementVNode("span",{class:"audio-mixer-strip__kind"},"master",-1)),e.createElementVNode("h3",nN,e.toDisplayString(z.state.master.name),1)]),e.createElementVNode("span",{class:e.normalizeClass(["audio-mixer-strip__status",{"is-active":!z.state.master.muted}]),"data-testid":"audio-mixer-master-status"},e.toDisplayString(z.state.master.muted?"Muted":"Active"),3)]),p.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["audio-mixer-meter",{"is-clipping":z.state.master.meter.clipping}]),"data-testid":"audio-mixer-master-meter","aria-label":"Master meter"},[e.createElementVNode("span",oN,[e.createElementVNode("span",{class:"audio-mixer-meter__fill",style:e.normalizeStyle({width:`${C(z.state.master.meter.peakDb)}%`})},null,4)]),e.createElementVNode("span",iN,e.toDisplayString(L(z.state.master.meter.peakDb)),1)],2)):e.createCommentVNode("",!0),e.createElementVNode("div",rN,[c.value?(e.openBlock(),e.createElementBlock("label",sN,[W[7]||(W[7]=e.createElementVNode("span",{class:"audio-mixer-control__label"},"Level",-1)),e.createElementVNode("input",{id:"audio-mixer-master-fader",type:"range",class:"audio-mixer-control__range",min:z.state.master.fader.minDb,max:z.state.master.fader.maxDb,value:z.state.master.fader.valueDb,step:"0.5","data-testid":"audio-mixer-master-fader",onInput:W[0]||(W[0]=B=>$(B))},null,40,lN),e.createElementVNode("span",dN,e.toDisplayString(I(z.state.master.fader.valueDb)),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",cN,[u.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["audio-mixer-button",{"is-active":z.state.master.muted}]),"aria-pressed":z.state.master.muted?"true":"false","aria-label":z.state.master.muted?`Unmute ${z.state.master.name}`:`Mute ${z.state.master.name}`,"data-testid":"audio-mixer-master-mute",onClick:W[1]||(W[1]=B=>V(z.state.master))}," M ",10,uN)):e.createCommentVNode("",!0)])]),y(z.state.master.effectSlots)?(e.openBlock(),e.createElementBlock("div",mN,[W[8]||(W[8]=e.createElementVNode("span",{class:"audio-mixer-effects__label"},"FX",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T(z.state.master.effectSlots),B=>(e.openBlock(),e.createElementBlock("span",{key:B.id,class:e.normalizeClass(["audio-mixer-effect",{"is-empty":B.kind==="empty","is-bypassed":B.bypassed,"is-enabled":B.enabled&&!B.bypassed}]),"data-testid":`audio-mixer-master-effect-${B.index}`},e.toDisplayString(B.label),11,pN))),128))])):e.createCommentVNode("",!0)],2)],2))}}),su=Fe(fN,[["__scopeId","data-v-e5c785e8"]]),hN={class:"caption-srt-panel__header"},vN={class:"caption-srt-panel__title-group"},gN={class:"caption-srt-panel__title"},bN=["id"],yN={key:0,class:"caption-srt-panel__stats","data-testid":"caption-srt-desktop-stats"},wN={key:0,class:"caption-srt-panel__desktop-controls","data-testid":"caption-srt-desktop-controls"},kN={class:"caption-srt-panel__field"},_N={class:"caption-srt-panel__field"},EN=["for"],xN=["id","aria-describedby","aria-invalid"],SN=["id"],CN=["id"],VN={key:3,class:"caption-srt-panel__cue-summary","data-testid":"caption-srt-cue-summary","aria-label":"Current caption cue summary"},NN={key:0,class:"caption-srt-panel__cue-list"},TN={class:"caption-srt-panel__cue-time"},BN={class:"caption-srt-panel__cue-text"},IN={key:1,class:"caption-srt-panel__empty"},MN=e.defineComponent({__name:"CaptionSrtPanel",props:{captionTrack:{default:null},segments:{default:null},layout:{default:"desktop"},trackId:{default:"caption-track-srt"},idPrefix:{default:"srt-cue"},panelId:{default:"caption-srt-panel"},title:{default:"Caption SRT"},textareaLabel:{default:"SRT caption text"}},emits:["import","update:captionTrack","update:segments","export","clear"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(""),r=e.ref(null),s=e.ref(null),l=e.ref(""),d=e.ref(""),c=e.ref(!1),u=e.computed(()=>t.layout==="mobile"),f=e.computed(()=>`${t.panelId}-textarea`),m=e.computed(()=>`${t.panelId}-helper`),p=e.computed(()=>`${t.panelId}-error`),h=e.computed(()=>`${t.panelId}-status`),v=e.computed(()=>{const y=[m.value,h.value];return r.value!==null&&y.push(p.value),y.join(" ")}),w=e.computed(()=>t.captionTrack!==null?t.captionTrack.segments:t.segments??[]),E=e.computed(()=>{try{return{text:Oc(w.value),errorMessage:null}}catch(y){return{text:"",errorMessage:L(y)}}}),S=e.computed(()=>w.value.length),k=e.computed(()=>w.value.reduce((y,R)=>Math.max(y,R.endTime),0)),b=e.computed(()=>w.value.slice(0,5));e.watch(()=>{var y,R;return[(y=t.captionTrack)==null?void 0:y.id,(R=t.captionTrack)==null?void 0:R.language,t.trackId]},([y,R,U])=>{l.value=y??U,d.value=R??""},{immediate:!0}),e.watch(E,y=>{if(y.errorMessage!==null){r.value=y.errorMessage;return}c.value||(i.value=y.text)},{immediate:!0});const $=()=>{c.value=!0,s.value=null,r.value!==null&&(r.value=null)},V=()=>{const y=i.value;if(r.value=null,s.value=null,y.trim()===""){r.value="Paste SRT text before importing captions.";return}try{const R=cE(y,{idPrefix:t.idPrefix}),U=CE(N(R)),z=Oc(U.segments);i.value=z,c.value=!1,s.value=`Imported ${C(U.segments.length)}.`,n("update:captionTrack",U),n("update:segments",U.segments),n("import",{track:U,segments:U.segments,sourceText:y})}catch(R){r.value=L(R)}},I=()=>{const y=E.value;if(r.value=y.errorMessage,y.errorMessage!==null){s.value=null;return}i.value=y.text,c.value=!1,s.value=y.text===""?"No captions to export.":`Exported ${C(S.value)}.`,n("export",y.text)},x=()=>{i.value="",c.value=!0,r.value=null,s.value="SRT text cleared.",n("clear")};function N(y){var z,W;const R={id:l.value.trim(),source:"srt-import",stylePreset:((z=t.captionTrack)==null?void 0:z.stylePreset)??"default",animation:((W=t.captionTrack)==null?void 0:W.animation)??"none",segments:y},U=d.value.trim();return U!==""&&(R.language=U),R}function L(y){return y instanceof Sn||y instanceof Error?y.message:"Unable to process SRT captions."}function C(y){return y===1?"1 cue":`${y} cues`}function T(y){const R=Math.floor(y/60),U=Math.floor(y%60);return`${R}:${U.toString().padStart(2,"0")}`}return(y,R)=>(e.openBlock(),e.createElementBlock("section",{class:e.normalizeClass(["caption-srt-panel",{"caption-srt-panel--mobile":u.value}]),"data-testid":"caption-srt-panel","aria-label":"SRT caption import and export"},[e.createElementVNode("header",hN,[e.createElementVNode("div",vN,[e.createElementVNode("h2",gN,e.toDisplayString(y.title),1),e.createElementVNode("p",{id:m.value,class:"caption-srt-panel__helper"}," Paste SRT, import it as captions, or export the current caption track. ",8,bN)]),u.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",yN,[e.createElementVNode("span",null,e.toDisplayString(C(S.value)),1),e.createElementVNode("span",null,e.toDisplayString(T(k.value)),1)]))]),u.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",wN,[e.createElementVNode("label",kN,[R[3]||(R[3]=e.createElementVNode("span",null,"Track ID",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":R[0]||(R[0]=U=>l.value=U),class:"caption-srt-panel__input",type:"text",autocomplete:"off","data-testid":"caption-srt-track-id"},null,512),[[e.vModelText,l.value]])]),e.createElementVNode("label",_N,[R[4]||(R[4]=e.createElementVNode("span",null,"Language",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":R[1]||(R[1]=U=>d.value=U),class:"caption-srt-panel__input",type:"text",autocomplete:"off",placeholder:"en","data-testid":"caption-srt-language"},null,512),[[e.vModelText,d.value]])])])),e.createElementVNode("label",{class:"caption-srt-panel__textarea-label",for:f.value},e.toDisplayString(y.textareaLabel),9,EN),e.withDirectives(e.createElementVNode("textarea",{id:f.value,"onUpdate:modelValue":R[2]||(R[2]=U=>i.value=U),class:e.normalizeClass(["caption-srt-panel__textarea",{"has-error":r.value!==null}]),spellcheck:"false","aria-describedby":v.value,"aria-invalid":r.value!==null?"true":"false","data-testid":"caption-srt-textarea",onInput:$},null,42,xN),[[e.vModelText,i.value]]),r.value!==null?(e.openBlock(),e.createElementBlock("p",{key:1,id:p.value,class:"caption-srt-panel__error",role:"alert","data-testid":"caption-srt-error"},e.toDisplayString(r.value),9,SN)):(e.openBlock(),e.createElementBlock("p",{key:2,id:h.value,class:"caption-srt-panel__status","aria-live":"polite","data-testid":"caption-srt-status"},e.toDisplayString(s.value??"Ready for caption import or export."),9,CN)),e.createElementVNode("div",{class:"caption-srt-panel__actions","aria-label":"SRT caption actions"},[e.createElementVNode("button",{type:"button",class:"caption-srt-panel__button caption-srt-panel__button--primary","data-testid":"caption-srt-import",onClick:V}," Import "),e.createElementVNode("button",{type:"button",class:"caption-srt-panel__button","data-testid":"caption-srt-export",onClick:I}," Export "),e.createElementVNode("button",{type:"button",class:"caption-srt-panel__button","data-testid":"caption-srt-clear",onClick:x}," Clear ")]),u.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",VN,[R[5]||(R[5]=e.createElementVNode("p",{class:"caption-srt-panel__cue-summary-title"},"Cue summary",-1)),b.value.length>0?(e.openBlock(),e.createElementBlock("ol",NN,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,U=>(e.openBlock(),e.createElementBlock("li",{key:U.id,class:"caption-srt-panel__cue"},[e.createElementVNode("span",TN,e.toDisplayString(T(U.startTime))+"-"+e.toDisplayString(T(U.endTime)),1),e.createElementVNode("span",BN,e.toDisplayString(U.text),1)]))),128))])):(e.openBlock(),e.createElementBlock("p",IN," No captions loaded. "))]))],2))}}),lu=Fe(MN,[["__scopeId","data-v-1d5fdb3b"]]),FN=["aria-label"],$N={class:"draft-recovery-banner__header"},DN={class:"draft-recovery-banner__heading"},RN={class:"draft-recovery-banner__title"},AN={class:"draft-recovery-banner__summary","data-testid":"draft-recovery-summary"},LN={key:0,class:"draft-recovery-banner__list","data-testid":"draft-recovery-list"},PN={class:"draft-recovery-banner__record-copy"},UN={class:"draft-recovery-banner__record-title","data-testid":"draft-recovery-record-title"},ON={class:"draft-recovery-banner__record-meta"},zN={"data-testid":"draft-recovery-record-updated"},jN={"data-testid":"draft-recovery-record-reason"},WN={class:"draft-recovery-banner__actions"},HN=["onClick"],ZN=["onClick"],GN={key:1,class:"draft-recovery-banner__mobile-prompt","data-testid":"draft-recovery-mobile-prompt"},XN={class:"draft-recovery-banner__record-copy"},KN={class:"draft-recovery-banner__record-title","data-testid":"draft-recovery-record-title"},JN={class:"draft-recovery-banner__record-meta"},qN={"data-testid":"draft-recovery-record-updated"},YN={"data-testid":"draft-recovery-record-reason"},QN={class:"draft-recovery-banner__actions draft-recovery-banner__actions--mobile"},eT={key:2,class:"draft-recovery-banner__empty","data-testid":"draft-recovery-empty"},tT=e.defineComponent({__name:"DraftRecoveryBanner",props:{records:{},surface:{},projectId:{},savedAt:{},maxAgeMs:{},now:{},maxDesktopItems:{default:3}},emits:["restore","dismiss"],setup(o,{emit:a}){const t=o,n=a,i={autosave:"Autosaved",manual:"Manual save","before-export":"Before export","before-close":"Before close"},r=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),s=e.computed(()=>{const V={};return t.projectId!==void 0&&(V.projectId=t.projectId),t.savedAt!==void 0&&(V.savedAt=t.savedAt),t.maxAgeMs!==void 0&&(V.maxAgeMs=t.maxAgeMs),t.now!==void 0&&(V.now=t.now),V}),l=e.computed(()=>{const V=t.maxDesktopItems;return!Number.isFinite(V)||V<1?1:Math.floor(V)}),d=e.computed(()=>C2(t.records,t.surface,s.value)),c=e.computed(()=>t.surface==="mobile"?d.value:d.value.slice(0,l.value)),u=e.computed(()=>t.surface==="mobile"),f=e.computed(()=>c.value.length>0),m=e.computed(()=>u.value?c.value[0]??null:null),p=e.computed(()=>u.value?"Unsaved video draft":"Unsaved video drafts"),h=e.computed(()=>f.value?u.value?"A newer draft is available on this device.":`${c.value.length} recoverable draft${c.value.length===1?"":"s"} found.`:"No recoverable video drafts"),v=V=>{var I;return((I=V.snapshot.metadata.title)==null?void 0:I.trim())||"Untitled video draft"},w=V=>{const I=V.snapshot.metadata.saveReason;return I===void 0?"Saved draft":i[I]},E=V=>{const I=new Date(V.snapshot.metadata.updatedAt);return Number.isFinite(I.getTime())?r.format(I):"Updated time unavailable"},S=V=>{n("restore",V)},k=V=>{V.length!==0&&n("dismiss",V)},b=V=>{k([V])},$=()=>{k(c.value)};return(V,I)=>(e.openBlock(),e.createElementBlock("section",{class:e.normalizeClass(["draft-recovery-banner",{"draft-recovery-banner--mobile":u.value,"draft-recovery-banner--empty":!f.value}]),"data-testid":"draft-recovery-banner","aria-live":"polite","aria-label":p.value},[e.createElementVNode("header",$N,[e.createElementVNode("div",DN,[I[2]||(I[2]=e.createElementVNode("p",{class:"draft-recovery-banner__eyebrow"},"Draft recovery",-1)),e.createElementVNode("h2",RN,e.toDisplayString(p.value),1),e.createElementVNode("p",AN,e.toDisplayString(h.value),1)]),!u.value&&c.value.length>1?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"draft-recovery-banner__ghost-action","data-testid":"draft-recovery-dismiss-all",onClick:$}," Dismiss all ")):e.createCommentVNode("",!0)]),!u.value&&f.value?(e.openBlock(),e.createElementBlock("ul",LN,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,x=>(e.openBlock(),e.createElementBlock("li",{key:x.key,class:"draft-recovery-banner__record","data-testid":"draft-recovery-record"},[e.createElementVNode("div",PN,[e.createElementVNode("h3",UN,e.toDisplayString(v(x)),1),e.createElementVNode("p",ON,[e.createElementVNode("span",zN,"Updated "+e.toDisplayString(E(x)),1),I[3]||(I[3]=e.createElementVNode("span",{"aria-hidden":"true"},"·",-1)),e.createElementVNode("span",jN,e.toDisplayString(w(x)),1)])]),e.createElementVNode("div",WN,[e.createElementVNode("button",{type:"button",class:"draft-recovery-banner__primary-action","data-testid":"draft-recovery-restore",onClick:N=>S(x)}," Restore ",8,HN),e.createElementVNode("button",{type:"button",class:"draft-recovery-banner__secondary-action","data-testid":"draft-recovery-dismiss",onClick:N=>b(x)}," Dismiss ",8,ZN)])]))),128))])):m.value?(e.openBlock(),e.createElementBlock("article",GN,[e.createElementVNode("div",XN,[e.createElementVNode("h3",KN,e.toDisplayString(v(m.value)),1),e.createElementVNode("p",JN,[e.createElementVNode("span",qN,"Updated "+e.toDisplayString(E(m.value)),1),I[4]||(I[4]=e.createElementVNode("span",{"aria-hidden":"true"},"·",-1)),e.createElementVNode("span",YN,e.toDisplayString(w(m.value)),1)])]),e.createElementVNode("div",QN,[e.createElementVNode("button",{type:"button",class:"draft-recovery-banner__primary-action","data-testid":"draft-recovery-restore",onClick:I[0]||(I[0]=x=>S(m.value))}," Restore "),e.createElementVNode("button",{type:"button",class:"draft-recovery-banner__secondary-action","data-testid":"draft-recovery-dismiss",onClick:I[1]||(I[1]=x=>b(m.value))}," Dismiss ")])])):(e.openBlock(),e.createElementBlock("p",eT," No recoverable drafts "))],10,FN))}}),du=Fe(tT,[["__scopeId","data-v-3ed3c273"]]),aT={class:"inspector-tabs",role:"tablist","aria-label":"Editor tools"},nT=["aria-selected","data-testid","onClick"],oT=["aria-labelledby"],iT={class:"inspector-placeholder","data-testid":"v2-inspector-placeholder"},rT=e.defineComponent({__name:"InspectorPanel",props:{activeTab:{},tabs:{},compact:{type:Boolean,default:!1}},emits:["update:activeTab"],setup(o,{emit:a}){const t=o,n=a,i=e.computed(()=>t.tabs.filter(s=>s.enabled)),r=s=>{s!==t.activeTab&&n("update:activeTab",s)};return(s,l)=>(e.openBlock(),e.createElementBlock("section",{class:e.normalizeClass(["inspector-panel",{"inspector-panel--compact":s.compact}]),"data-testid":"v2-inspector-panel"},[e.createElementVNode("nav",aT,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,d=>(e.openBlock(),e.createElementBlock("button",{key:d.id,type:"button",role:"tab",class:e.normalizeClass(["inspector-tab",{"is-active":s.activeTab===d.id}]),"aria-selected":s.activeTab===d.id?"true":"false","data-testid":`v2-inspector-tab-${d.id}`,onClick:c=>r(d.id)},e.toDisplayString(d.label),11,nT))),128))]),e.createElementVNode("div",{class:"inspector-body",role:"tabpanel","aria-labelledby":`v2-inspector-tab-${s.activeTab}`},[e.renderSlot(s.$slots,s.activeTab,{},()=>[e.createElementVNode("div",iT,[e.createElementVNode("p",null,e.toDisplayString(s.activeTab)+" controls — coming soon",1)])],!0)],8,oT)],2))}}),sT=Fe(rT,[["__scopeId","data-v-7f5b0e50"]]),lT={class:"keyframe-preset-panel__header"},dT={class:"keyframe-preset-panel__target","data-testid":"keyframe-preset-target"},cT={key:0,class:"keyframe-preset-panel__notice","data-testid":"keyframe-preset-invalid-duration"},uT={class:"keyframe-preset-panel__grid","data-testid":"keyframe-preset-buttons"},mT=["disabled","aria-disabled","data-testid","onClick"],pT={class:"keyframe-preset-panel__preset-label"},fT={class:"keyframe-preset-panel__preset-summary"},hT={key:1,class:"keyframe-preset-panel__compact-summary","data-testid":"keyframe-preset-mobile-summary"},vT={key:2,class:"keyframe-preset-panel__desktop-summary","data-testid":"keyframe-preset-desktop-summary"},gT={class:"keyframe-preset-panel__summary-list"},bT=["data-testid"],yT={key:0,class:"keyframe-preset-panel__summary-empty","data-testid":"keyframe-preset-summary-empty"},wT=e.defineComponent({__name:"KeyframePresetPanel",props:{duration:{},target:{},deviceClass:{}},emits:["apply-preset"],setup(o,{emit:a}){const t=o,n=a,i={all:"All targets",opacity:"Opacity",scale:"Scale",x:"Pan X",y:"Pan Y",rotation:"Rotation",audioVolume:"Audio"},r=[{id:"fade-in",label:"Fade in",target:"opacity",summary:"Opacity 0 -> 100%",create:V=>{const I=EE({duration:$(V)});return E("fade-in","Fade in",I,V)}},{id:"fade-out",label:"Fade out",target:"opacity",summary:"Opacity 100 -> 0%",create:V=>{const I=$(V),x=xE({startTime:V-I,duration:I});return E("fade-out","Fade out",x,V)}},{id:"push-in",label:"Push in",target:"scale",summary:"Scale 100 -> 108%",create:V=>{const I=SE({duration:V,fromScale:1,toScale:1.08,easing:"ease-out"});return E("push-in","Push in",I,V)}},{id:"push-out",label:"Push out",target:"scale",summary:"Scale 108 -> 100%",create:V=>k({id:"push-out",label:"Push out",target:"scale",duration:V,startValue:1.08,endValue:1,easing:"ease-in"})},{id:"pan-x-left",label:"Pan left",target:"x",summary:"X 55 -> 45%",create:V=>k({id:"pan-x-left",label:"Pan left",target:"x",duration:V,startValue:.55,endValue:.45,easing:"ease-in-out"})},{id:"pan-x-right",label:"Pan right",target:"x",summary:"X 45 -> 55%",create:V=>k({id:"pan-x-right",label:"Pan right",target:"x",duration:V,startValue:.45,endValue:.55,easing:"ease-in-out"})},{id:"pan-y-up",label:"Pan up",target:"y",summary:"Y 55 -> 45%",create:V=>k({id:"pan-y-up",label:"Pan up",target:"y",duration:V,startValue:.55,endValue:.45,easing:"ease-in-out"})},{id:"pan-y-down",label:"Pan down",target:"y",summary:"Y 45 -> 55%",create:V=>k({id:"pan-y-down",label:"Pan down",target:"y",duration:V,startValue:.45,endValue:.55,easing:"ease-in-out"})},{id:"audio-fade-in",label:"Audio fade in",target:"audioVolume",summary:"Volume 0 -> 100%",create:V=>k({id:"audio-fade-in",label:"Audio fade in",target:"audioVolume",duration:$(V),startValue:0,endValue:1,easing:"ease-out"})},{id:"audio-fade-out",label:"Audio fade out",target:"audioVolume",summary:"Volume 100 -> 0%",create:V=>{const I=$(V);return k({id:"audio-fade-out",label:"Audio fade out",target:"audioVolume",duration:I,startTime:V-I,startValue:1,endValue:0,easing:"ease-in"})}}],s=e.computed(()=>wE(t.deviceClass)),l=e.computed(()=>s.value.platform==="mobile"),d=e.computed(()=>Number.isFinite(t.duration)&&t.duration>0),c=e.computed(()=>t.target==="all"?r:r.filter(V=>V.target===t.target)),u=e.computed(()=>d.value?c.value.map(V=>({definition:V,automation:V.create(t.duration)})):[]),f=e.computed(()=>i[t.target]),m=e.computed(()=>{const V=c.value.length,I=V===1?"preset":"presets";return d.value?`${V} ${I} - ${h(t.duration)} clip.`:`${V} ${I} available when duration is set.`}),p=V=>{if(!d.value)return;const I=V.create(t.duration);n("apply-preset",{presetId:I.id,target:I.target,keyframes:I.keyframes,automation:I})},h=V=>{const I=Math.round(V*100)/100;return`${I.toFixed(I%1===0?0:2)}s`},v=(V,I)=>V==="opacity"||V==="audioVolume"?`${Math.round(I*100)}%`:V==="scale"?`${Math.round(I*100)}%`:V==="x"||V==="y"?`${Math.round(I*100)}%`:`${Math.round(I*100)/100}`,w=V=>{const[I,x]=V.keyframes;return`${h(I.time)} ${v(V.target,I.value)} -> ${h(x.time)} ${v(V.target,x.value)}`};function E(V,I,x,N){return S({id:V,label:I,target:x.target,duration:N,keyframes:x.keyframes})}function S(V){const I=_E(V.keyframes,{target:V.target,minTime:0,maxTime:V.duration}),x=I[0],N=I[1];if(I.length!==2||x===void 0||N===void 0)throw new Error("Keyframe preset panel presets must generate exactly two keyframes.");return{id:V.id,label:V.label,target:V.target,editingMode:"preset-only",keyframes:[x,N]}}function k(V){const I=V.startTime??0,x=[b(`${V.id}:start`,V.target,I,V.startValue,"linear"),b(`${V.id}:end`,V.target,I+V.duration,V.endValue,V.easing)];return S({id:V.id,label:V.label,target:V.target,duration:I+V.duration,keyframes:x})}function b(V,I,x,N,L){return{id:V,target:I,time:x,value:N,easing:L}}function $(V){return Math.min(V,1)}return(V,I)=>(e.openBlock(),e.createElementBlock("section",{class:e.normalizeClass(["keyframe-preset-panel",{"keyframe-preset-panel--mobile":l.value}]),"data-testid":"keyframe-preset-panel","aria-label":"Keyframe presets"},[e.createElementVNode("header",lT,[I[0]||(I[0]=e.createElementVNode("div",{class:"keyframe-preset-panel__heading"},[e.createElementVNode("p",{class:"keyframe-preset-panel__eyebrow"},"Presets"),e.createElementVNode("h3",{class:"keyframe-preset-panel__title"},"Keyframe automation")],-1)),e.createElementVNode("span",dT,e.toDisplayString(f.value),1)]),d.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",cT," Set a valid clip duration to apply automation presets. ")),e.createElementVNode("div",uT,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,x=>(e.openBlock(),e.createElementBlock("button",{key:x.id,type:"button",class:"keyframe-preset-panel__preset",disabled:!d.value,"aria-disabled":d.value?void 0:"true","data-testid":`keyframe-preset-button-${x.id}`,onClick:N=>p(x)},[e.createElementVNode("span",pT,e.toDisplayString(x.label),1),e.createElementVNode("span",fT,e.toDisplayString(x.summary),1)],8,mT))),128))]),l.value?(e.openBlock(),e.createElementBlock("p",hT,e.toDisplayString(m.value),1)):(e.openBlock(),e.createElementBlock("div",vT,[I[1]||(I[1]=e.createElementVNode("p",{class:"keyframe-preset-panel__summary-title"},"Generated keyframes",-1)),e.createElementVNode("ul",gT,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.value,x=>(e.openBlock(),e.createElementBlock("li",{key:x.definition.id,class:"keyframe-preset-panel__summary-row","data-testid":`keyframe-preset-summary-${x.definition.id}`},[e.createElementVNode("span",null,e.toDisplayString(x.definition.label),1),e.createElementVNode("span",null,e.toDisplayString(w(x.automation)),1)],8,bT))),128))]),u.value.length===0?(e.openBlock(),e.createElementBlock("p",yT," No generated keyframes until duration is valid. ")):e.createCommentVNode("",!0)]))],2))}}),cu=Fe(wT,[["__scopeId","data-v-79615683"]]),kT={class:"mobile-clip-summary__main"},_T={class:"mobile-clip-summary__title","data-testid":"v2-mobile-clip-label"},ET={class:"mobile-clip-summary__stats","aria-label":"Selected clip timing"},xT={class:"mobile-clip-summary__stat"},ST={"data-testid":"v2-mobile-clip-start"},CT={class:"mobile-clip-summary__stat"},VT={"data-testid":"v2-mobile-clip-end"},NT={class:"mobile-clip-summary__stat"},TT={"data-testid":"v2-mobile-clip-duration"},BT={key:1,class:"mobile-clip-summary__empty","data-testid":"v2-mobile-no-clip"},IT=e.defineComponent({__name:"MobileClipSummary",props:{selectedClip:{}},emits:["open-actions"],setup(o,{emit:a}){const t=o,n=a,i=f=>f===void 0||!Number.isFinite(f)?null:f,r=e.computed(()=>{var f,m,p;return((m=(f=t.selectedClip)==null?void 0:f.label)==null?void 0:m.trim())||((p=t.selectedClip)==null?void 0:p.id)||""}),s=e.computed(()=>t.selectedClip?i(t.selectedClip.timelineStart)??i(t.selectedClip.startTime):null),l=e.computed(()=>t.selectedClip?i(t.selectedClip.timelineEnd)??i(t.selectedClip.endTime):null),d=e.computed(()=>{const f=s.value,m=l.value;return f!==null&&m!==null?Math.max(0,m-f):t.selectedClip?i(t.selectedClip.duration):null}),c=f=>{if(f===null)return"--";const m=Math.round(f*100)/100;return`${m.toFixed(m%1===0?0:2)}s`},u=()=>{t.selectedClip&&n("open-actions",t.selectedClip.id)};return(f,m)=>(e.openBlock(),e.createElementBlock("section",{class:e.normalizeClass(["mobile-clip-summary",{"mobile-clip-summary--empty":!f.selectedClip}]),"data-testid":"v2-mobile-clip-summary","aria-live":"polite"},[f.selectedClip?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",kT,[m[0]||(m[0]=e.createElementVNode("p",{class:"mobile-clip-summary__eyebrow"},"Selected clip",-1)),e.createElementVNode("h2",_T,e.toDisplayString(r.value),1)]),e.createElementVNode("dl",ET,[e.createElementVNode("div",xT,[m[1]||(m[1]=e.createElementVNode("dt",null,"Start",-1)),e.createElementVNode("dd",ST,e.toDisplayString(c(s.value)),1)]),e.createElementVNode("div",CT,[m[2]||(m[2]=e.createElementVNode("dt",null,"End",-1)),e.createElementVNode("dd",VT,e.toDisplayString(c(l.value)),1)]),e.createElementVNode("div",NT,[m[3]||(m[3]=e.createElementVNode("dt",null,"Duration",-1)),e.createElementVNode("dd",TT,e.toDisplayString(c(d.value)),1)])]),e.createElementVNode("button",{type:"button",class:"mobile-clip-summary__actions","aria-label":"Open selected clip actions","data-testid":"v2-mobile-clip-actions",onClick:u}," Actions ")],64)):(e.openBlock(),e.createElementBlock("p",BT," No clip selected "))],2))}}),MT=Fe(IT,[["__scopeId","data-v-433c7812"]]),FT=["aria-label"],$T=["aria-pressed","data-testid","onClick"],DT={class:"mobile-tool-picker__label"},RT=e.defineComponent({__name:"MobileToolPicker",props:{modelValue:{},ariaLabel:{default:"Mobile editor tools"}},emits:["update:modelValue"],setup(o,{emit:a}){const t=[{id:"look",label:"Look"},{id:"trim",label:"Trim"},{id:"text",label:"Text"},{id:"audio",label:"Audio"},{id:"export",label:"Export"},{id:"more",label:"More"}],n=o,i=a,r=s=>{s!==n.modelValue&&i("update:modelValue",s)};return(s,l)=>(e.openBlock(),e.createElementBlock("div",{class:"mobile-tool-picker",role:"group","aria-label":s.ariaLabel,"data-testid":"v2-mobile-tool-picker"},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(t,d=>e.createElementVNode("button",{key:d.id,type:"button",class:e.normalizeClass(["mobile-tool-picker__button",{"is-active":s.modelValue===d.id}]),"aria-pressed":s.modelValue===d.id?"true":"false","data-testid":`v2-mobile-tool-${d.id}`,onClick:c=>r(d.id)},[e.createElementVNode("span",DT,e.toDisplayString(d.label),1)],10,$T)),64))],8,FT))}}),AT=Fe(RT,[["__scopeId","data-v-ec597c70"]]),LT=["aria-label","data-snap"],PT=["aria-expanded"],UT={class:"drawer-header"},OT={class:"drawer-body"},zT=e.defineComponent({__name:"VideoBottomDrawer",props:{initialSnap:{default:"half"},ariaLabel:{default:"Editor controls drawer"},containerHeight:{default:0}},emits:["snap-change"],setup(o,{expose:a,emit:t}){const n=["collapsed","half","full"],i=o,r=t,s=e.ref(null),l=e.ref(null),d=e.ref(i.initialSnap);let c=!1,u=!1,f=null,m=0,p=0,h=0;const v=N=>{const L=h||(typeof window<"u"?window.innerHeight:600);switch(N){case"collapsed":return 80;case"half":return Math.round(L*.45);case"full":return Math.round(L*.85)}},w=(N,{animate:L=!0}={})=>{var y;if(!s.value)return;const C=d.value;d.value=N;const T=typeof window<"u"&&((y=window.matchMedia)==null?void 0:y.call(window,"(prefers-reduced-motion: reduce)").matches);s.value.style.transition=L&&!T?"height 0.25s cubic-bezier(0.33, 1, 0.68, 1)":"none",s.value.style.height=`${v(N)}px`,N!==C&&r("snap-change",N,C)},E=N=>{let L=n[0],C=1/0;for(const T of n){const y=Math.abs(v(T)-N);y<C&&(C=y,L=T)}return L},S=()=>{const N=n.indexOf(d.value);w(n[(N+1)%n.length])},k=N=>{if(u){u=!1,N.preventDefault();return}S()},b=N=>{var L,C,T;if(N.button===0){c=!0,u=!1,f=N.pointerId,m=N.clientY,p=((L=s.value)==null?void 0:L.offsetHeight)??0;try{(T=(C=l.value)==null?void 0:C.setPointerCapture)==null||T.call(C,N.pointerId)}catch{}s.value&&(s.value.style.transition="none")}},$=N=>{if(!c||N.pointerId!==f)return;const L=N.clientY-m,C=p-L,T=v("collapsed"),y=v("full"),R=Math.max(T,Math.min(y,C));s.value&&(s.value.style.height=`${R}px`),Math.abs(L)>4&&(u=!0),N.preventDefault()},V=N=>{var C,T,y;if(!c)return;c=!1;try{(T=(C=l.value)==null?void 0:C.releasePointerCapture)==null||T.call(C,N.pointerId)}catch{}f=null;const L=((y=s.value)==null?void 0:y.offsetHeight)??0;w(E(L))},I=(N,L={})=>{n.includes(N)&&w(N,{animate:L.animate!==!1})},x=N=>{h=Math.max(0,Number(N)||0),w(d.value,{animate:!1})};return e.watch(()=>i.containerHeight,N=>{N>0&&x(N)}),e.onMounted(()=>{i.containerHeight>0&&(h=i.containerHeight),w(d.value,{animate:!1})}),e.onBeforeUnmount(()=>{c=!1,f=null}),a({snapTo:I,updateContainerHeight:x,snap:d}),(N,L)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootEl",ref:s,class:"video-editor-v2-drawer",role:"dialog","aria-label":N.ariaLabel,"data-snap":d.value,"data-testid":"v2-video-bottom-drawer"},[e.createElementVNode("button",{ref_key:"handleEl",ref:l,type:"button",class:"drawer-handle","aria-label":"Drag to resize editor drawer","aria-expanded":d.value==="full"?"true":"false","data-testid":"v2-video-drawer-handle",onClick:k,onPointerdown:b,onPointermove:$,onPointerup:V,onPointercancel:V},[...L[0]||(L[0]=[e.createElementVNode("span",{class:"drawer-handle-grip","aria-hidden":"true"},null,-1)])],40,PT),e.createElementVNode("div",UT,[e.renderSlot(N.$slots,"header",{},void 0,!0)]),e.createElementVNode("div",OT,[e.renderSlot(N.$slots,"default",{},void 0,!0)])],8,LT))}}),jT=Fe(zT,[["__scopeId","data-v-4ebedbf7"]]),WT=new Set(["INPUT","TEXTAREA","SELECT"]);function HT(o){return o instanceof HTMLElement?!!(WT.has(o.tagName)||o.isContentEditable):!1}function ZT(o,a={}){const t=n=>{var l,d,c,u,f,m,p,h,v,w,E,S,k,b,$,V,I;if(a.enabled&&a.enabled()===!1||HT(n.target))return;const i=n.ctrlKey||n.metaKey,r=n.shiftKey,s=n.key;if(i&&(s==="z"||s==="Z")){r?(l=o.redo)==null||l.call(o):(d=o.undo)==null||d.call(o),n.preventDefault();return}if(i&&(s==="s"||s==="S")){(c=o.save)==null||c.call(o),n.preventDefault();return}if(i&&(s==="e"||s==="E")){(u=o.exportNow)==null||u.call(o),n.preventDefault();return}switch(s){case" ":case"Spacebar":(f=o.playPause)==null||f.call(o),n.preventDefault();return;case"ArrowLeft":r?(m=o.secondBackward)==null||m.call(o):(p=o.frameBackward)==null||p.call(o),n.preventDefault();return;case"ArrowRight":r?(h=o.secondForward)==null||h.call(o):(v=o.frameForward)==null||v.call(o),n.preventDefault();return;case"Home":(w=o.skipToStart)==null||w.call(o),n.preventDefault();return;case"End":(E=o.skipToEnd)==null||E.call(o),n.preventDefault();return;case"[":(S=o.prevClip)==null||S.call(o),n.preventDefault();return;case"]":(k=o.nextClip)==null||k.call(o),n.preventDefault();return;case"s":case"S":i||((b=o.splitAtPlayhead)==null||b.call(o),n.preventDefault());return;case"Delete":case"Backspace":r?($=o.rippleDeleteSelected)==null||$.call(o):(V=o.deleteSelected)==null||V.call(o),n.preventDefault();return;case"?":(I=o.showShortcutsOverlay)==null||I.call(o),n.preventDefault();return}};e.onMounted(()=>{window.addEventListener("keydown",t)}),e.onBeforeUnmount(()=>{window.removeEventListener("keydown",t)})}const Up=["video/mp4","video/webm","video/quicktime"],Op=["image/png","image/jpeg","image/jpg","image/webp"],GT=["audio/mpeg","audio/mp3","audio/aac","audio/wav","audio/x-wav","audio/wave"],XT=new Set([...Up,...Op,...GT]),KT=2*1024*1024*1024,JT=60*60;function uu(o,a){const t=o.type.toLowerCase();return XT.has(t)?o.size>KT?{ok:!1,reason:"oversize",message:`File is too large (${(o.size/(1024*1024*1024)).toFixed(2)} GiB). Limit is 2 GiB.`}:typeof a=="number"&&Number.isFinite(a)&&a>JT?{ok:!1,reason:"duration_exceeded",message:`Clip is too long (${Math.round(a)}s). Limit is 1 hour.`}:{ok:!0,kind:Up.includes(t)?"video":Op.includes(t)?"image":"audio"}:{ok:!1,reason:"unsupported_mime",message:`Unsupported file type: ${t||"unknown"}.`}}const qT="mediables-asset-blobs",Ha="blobs",YT=1;class QT{constructor(){this.dbPromise=null}openDb(){return this.dbPromise?this.dbPromise:(this.dbPromise=new Promise((a,t)=>{if(typeof indexedDB>"u"){t(new Error("IndexedDB is not available in this environment."));return}const n=indexedDB.open(qT,YT);n.onupgradeneeded=()=>{const i=n.result;i.objectStoreNames.contains(Ha)||i.createObjectStore(Ha)},n.onsuccess=()=>{a(n.result)},n.onerror=()=>{t(n.error??new Error("Failed to open IndexedDB."))}}),this.dbPromise)}async put(a,t){const n=await this.openDb();await new Promise((i,r)=>{const d=n.transaction(Ha,"readwrite").objectStore(Ha).put(t,a);d.onsuccess=()=>{i()},d.onerror=()=>{r(d.error??new Error("Failed to write blob."))}})}async get(a){const t=await this.openDb();return new Promise((n,i)=>{const l=t.transaction(Ha,"readonly").objectStore(Ha).get(a);l.onsuccess=()=>{const d=l.result;d==null?n(null):d instanceof Blob?n(d):n(null)},l.onerror=()=>{i(l.error??new Error("Failed to read blob."))}})}async delete(a){const t=await this.openDb();await new Promise((n,i)=>{const l=t.transaction(Ha,"readwrite").objectStore(Ha).delete(a);l.onsuccess=()=>{n()},l.onerror=()=>{i(l.error??new Error("Failed to delete blob."))}})}async clear(){const a=await this.openDb();await new Promise((t,n)=>{const s=a.transaction(Ha,"readwrite").objectStore(Ha).clear();s.onsuccess=()=>{t()},s.onerror=()=>{n(s.error??new Error("Failed to clear cache."))}})}}let Ys=null;function e4(){return Ys===null&&(Ys=new QT),Ys}class t4{constructor(){this.store=new Map}async put(a,t){this.store.set(a,t)}async get(a){return this.store.get(a)??null}async delete(a){this.store.delete(a)}async clear(){this.store.clear()}}function a4(){return`asset-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}async function n4(o,a){if(a<=0)return{};if(typeof URL>"u"||typeof document>"u")return{};const t=URL.createObjectURL(o),n=async()=>o.type.startsWith("video/")?new Promise(i=>{const r=document.createElement("video");r.preload="metadata",r.src=t,r.onloadedmetadata=()=>{i({durationSeconds:r.duration,width:r.videoWidth,height:r.videoHeight})},r.onerror=()=>{i({})}}):o.type.startsWith("audio/")?new Promise(i=>{const r=document.createElement("audio");r.preload="metadata",r.src=t,r.onloadedmetadata=()=>{i({durationSeconds:r.duration})},r.onerror=()=>{i({})}}):o.type.startsWith("image/")?new Promise(i=>{const r=new Image;r.src=t,r.onload=()=>{i({width:r.naturalWidth,height:r.naturalHeight})},r.onerror=()=>{i({})}}):{};try{return await Promise.race([n(),new Promise(i=>{setTimeout(()=>i({}),a)})])}finally{URL.revokeObjectURL(t)}}function o4(o){const a=e.reactive(new Map),t=o.blobCache??i4();async function n(u,f){try{await t.put(u,f)}catch{}}async function i(u){try{await t.delete(u)}catch{}}async function r(u,f,m){var p,h,v;try{f.status="uploading",f.uploadProgress=0,a.set(f.assetId,f);const w=await o.uploader.upload({file:u},({assetId:E,progress:S,status:k})=>{if(E!==f.assetId)return;const b=a.get(E);b&&(b.uploadProgress=S,b.status=k,a.set(E,b))});return a.set(f.assetId,w),w.status==="ready"?(i(f.assetId),(p=o.onReady)==null||p.call(o,w)):w.status==="failed"&&((h=o.onFailure)==null||h.call(o,w)),{ok:!0,record:w}}catch(w){const E=w instanceof Error?w.message:"Upload failed.",S={...f,status:"failed",failureMessage:E};return a.set(f.assetId,S),(v=o.onFailure)==null||v.call(o,S),{ok:!1,reason:"upload",message:E}}}const s=o.probeTimeoutMs??1500;async function l(u){const f=await n4(u,s),m=uu(u,f.durationSeconds);if(!m.ok)return{ok:!1,reason:"preflight",message:m.message};const p=a4(),h={assetId:p,filename:u.name,mime:u.type,sizeBytes:u.size,status:"local-selected"};return f.durationSeconds!==void 0&&(h.durationSeconds=f.durationSeconds),f.width!==void 0&&(h.width=f.width),f.height!==void 0&&(h.height=f.height),a.set(p,h),await n(p,u),r(u,h)}async function d(u){const f=a.get(u);if(!f)return{ok:!1,reason:"unknown",message:"Unknown asset."};const m=await t.get(u);if(!m)return{ok:!1,reason:"unknown",message:"Original file is no longer cached."};const p=m instanceof File?m:new File([m],f.filename,{type:f.mime}),h=uu(p,f.durationSeconds);return h.ok?r(p,f):{ok:!1,reason:"preflight",message:h.message}}async function c(u){a.delete(u),await i(u)}return{records:e.readonly(a),importFile:l,retry:d,remove:c}}function i4(){return typeof indexedDB<"u"?e4():new t4}const r4={class:"v2-toolbar-group"},s4=["aria-label"],l4=["disabled"],d4={class:"v2-toolbar-group"},c4={class:"v2-toolbar-fit"},u4=["disabled"],m4=["aria-label","title","disabled"],p4={class:"v2-assets"},f4={key:0,class:"v2-asset-rail-status","data-testid":"v2-asset-rail-status",role:"status"},h4={class:"v2-preview-host"},v4={class:"v2-timeline-topbar"},g4={class:"v2-timeline-heading"},b4={class:"v2-timeline-meta","data-testid":"v2-timeline-meta"},y4={class:"v2-timeline-zoom"},w4=["value"],k4={class:"v2-timeline-zoom-readout"},_4={key:0,class:"v2-timeline-track-actions"},E4={key:0,class:"v2-timeline-track-target"},x4=["value"],S4=["value"],C4=["aria-pressed"],V4={key:0,class:"v2-editor-status","data-testid":"v2-editor-status",role:"status","aria-live":"polite"},N4={key:1,class:"v2-timeline-empty","data-testid":"v2-timeline-empty"},T4={key:1,class:"v2-empty-state"},B4={key:0,"data-testid":"v2-export-status-completed",class:"v2-export-status"},I4={key:1,class:"v2-export-status","data-testid":"v2-export-status-message"},M4={key:1,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-look"},F4={class:"v2-mobile-panel-section"},$4={class:"v2-mobile-panel-section v2-mobile-panel-section--compact"},D4={key:1,class:"v2-empty-state"},R4={key:2,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-trim"},A4={key:3,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-text"},L4={key:4,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-audio"},P4={key:5,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-export"},U4={key:0,class:"v2-export-status"},O4={key:1,class:"v2-export-status"},z4={key:6,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-more"},j4={class:"v2-mobile-secondary-controls"},W4={class:"v2-mobile-secondary-field"},H4=["aria-pressed"],Z4=["disabled"],G4=["disabled"],X4={key:0,class:"v2-mobile-secondary-details","data-testid":"v2-mobile-transitions"},K4={class:"v2-mobile-secondary-details","data-testid":"v2-mobile-keyframes"},J4={class:"v2-shortcuts-overlay__panel"},q4={class:"v2-shortcuts-overlay__header"},Y4=e.defineComponent({__name:"VideoEditorV2",props:{mediaUuid:{},initialRecipe:{},media:{},showThumbnailPicker:{type:Boolean,default:!1},workflowMode:{default:"full"},featureFlags:{},clientExportThreshold:{default:20},maxDuration:{default:300},serverRenderEndpoint:{default:null},assetUploader:{default:null}},emits:["recipe-generated","export-started","draft-saved","video-exported","thumbnail-selected","server-render-started","server-render-progress","server-render-completed","server-render-failed","close"],setup(o,{expose:a,emit:t}){var Ki,Ji,qi,Yi;const n=o,i=t,r=e.computed(()=>{var te;const g=typeof n.mediaUuid=="string"?n.mediaUuid.trim():"";if(g!=="")return g;const M=(te=n.media)==null?void 0:te.uuid;return typeof M=="string"&&M.trim()!==""?M.trim():`temp-${Date.now()}`}),s=lp(r.value,n.initialRecipe,n.media),l=up(),d=e.ref("filters"),c=e.ref("look"),u=e.ref(null),f=e.computed(()=>n.workflowMode==="uploader"?{filters:!0,adjustments:!0,text:!1,transitions:!1,audio:!1,export:!1}:{filters:!0,adjustments:!0,text:!0,transitions:!0,audio:!0,export:!0}),m=e.computed(()=>{const g=n.featureFlags??{},M=["filters","adjustments","text","transitions","audio","export"],te={filters:"Filters",adjustments:"Adjust",text:"Text",transitions:"Transitions",audio:"Audio",export:"Export"};return M.map(pe=>({id:pe,label:te[pe],enabled:typeof g[pe]=="boolean"?g[pe]:f.value[pe]}))}),p=g=>m.value.some(M=>M.id===g&&M.enabled),h={look:"filters",text:"text",audio:"audio",export:"export"},v=e.computed(()=>{var g;return((g=n.featureFlags)==null?void 0:g.transitions)===!0});e.watch(c,g=>{var M,te;if(g!=="trim"&&g!=="more"){const pe=h[g];p(pe)&&(d.value=pe)}(te=(M=u.value)==null?void 0:M.snapTo)==null||te.call(M,"full"),e.nextTick(()=>{var De;if(typeof document>"u")return;const pe=document.querySelector(`[data-testid="v2-mobile-panel-${g}"]`);if(!pe||!(pe instanceof HTMLElement))return;const $e=typeof window<"u"&&((De=window.matchMedia)==null?void 0:De.call(window,"(prefers-reduced-motion: reduce)").matches);pe.scrollIntoView({block:"start",behavior:$e?"auto":"smooth"})})});const w=e.ref(!1),E=e.computed(()=>d.value),S=e.computed(()=>E.value==="filters"||w.value),k=e.computed(()=>E.value!=="filters"&&!w.value),b=e.ref(null),$=e.computed(()=>b.value),V=["contain","cover","none"],I=g=>typeof g=="string"&&V.includes(g),x=g=>{var te;const M=(te=g==null?void 0:g.metadata)==null?void 0:te.fit_mode;return I(M)?M:null},N=e.ref(x(n.initialRecipe)??"contain"),L=e.ref("");e.watch(()=>{var g,M;return{file:(g=n.media)==null?void 0:g.file,url:(M=n.media)==null?void 0:M.url}},(g,M,te)=>{var $e,De;const pe=L.value;te(()=>{pe&&pe.startsWith("blob:")&&URL.revokeObjectURL(pe)}),($e=n.media)!=null&&$e.file?L.value=URL.createObjectURL(n.media.file):(De=n.media)!=null&&De.url?L.value=n.media.url:L.value=""},{immediate:!0});const C=e.computed(()=>L.value),T=e.computed(()=>l.activeFilters.value),y=e.computed(()=>s.playheadPosition.value),R=Dm({forcePixiPreview:w,getPreviewRef:()=>$.value,getSourceUrl:()=>L.value,setPlaying:s.setPlaying}),U=e.computed(()=>{if(!n.media)return null;const{file:g,...M}=n.media;return{...M,url:L.value}}),z=e.computed(()=>{var M;const g=(M=n.media)==null?void 0:M.url;return!!(g&&/^https?:/i.test(g))}),W=e.ref(0),B=e.computed(()=>{var M;if(s.totalDuration.value>0)return s.totalDuration.value;if(W.value>0)return W.value;const g=Number((M=n.media)==null?void 0:M.duration);return Number.isFinite(g)&&g>0?g:0}),P=g=>{!Number.isFinite(g)||g<=0||(W.value=g,s.updateSourceDuration(g))},X=g=>{g&&typeof g.time=="number"&&Number.isFinite(g.time)&&s.seekTo(g.time)},K=g=>{Number.isFinite(g)&&s.seekTo(g)},be=g=>{s.setPlaying(g)},Ne=e.computed(()=>l.videoCompatibleFilters.value.map(M=>{var pe;const te=[];if(M.controls&&M.controls.length>0)for(const $e of M.controls){const De=$e.type;if(De==="button"||De==="text"||De==="range")continue;const Qe={id:$e.property||$e.id,label:$e.label||$e.id,type:De,default:$e.default??(De==="toggle"?!1:De==="color"?"#ffffff":0)};De==="slider"&&(Qe.min=$e.min??0,Qe.max=$e.max??1,Qe.step=$e.step??.01),De==="select"&&$e.options&&(Qe.options=$e.options),te.push(Qe)}else if(M.paramRanges){const $e=Object.entries(M.paramRanges);for(const[De,Qe]of $e){const yt=De.replace(/[-_]/g," ").replace(/\b\w/g,ho=>ho.toUpperCase()),Lt=(pe=M.defaultParams)==null?void 0:pe[De],ra=(Qe.min+Qe.max)/2;te.push({id:De,label:yt,min:Qe.min,max:Qe.max,step:Qe.step??.01,default:typeof Lt=="number"?Lt:ra})}}return{id:M.id,name:M.name,category:M.category,params:te}})),ue=e.computed(()=>{const g=new Map;return l.activeFilters.value.forEach(M=>g.set(M.filterId,M)),g}),re=e.computed(()=>{if(s.currentFrame.value)return s.currentFrame.value;const g=n.media;return(g==null?void 0:g.thumbnail_url)??(g==null?void 0:g.url)}),O=e.shallowRef(null),D=e.ref(null),J=e.ref(null),Z=e.ref(null),ie=e.ref(!1),se=new Map,Ue=(g,M)=>{const te={id:g.id??`text-overlay-recipe-${M}`,text:g.content};return g.fontFamily!==void 0&&(te.fontFamily=g.fontFamily),g.fontSize!==void 0&&(te.fontSize=g.fontSize),g.fontWeight!==void 0&&(te.fontWeight=g.fontWeight),g.color!==void 0&&(te.color=g.color),g.position!==void 0&&(te.position=g.position),g.startTime!==void 0&&(te.startTime=g.startTime),g.duration!==void 0&&(te.duration=g.duration),g.animation!==void 0&&(te.animation=g.animation),g.textAlign!==void 0&&(te.textAlign=g.textAlign),g.textBaseline!==void 0&&(te.textBaseline=g.textBaseline),te},me=g=>{const M={id:g.id,content:g.text};return g.fontFamily!==void 0&&(M.fontFamily=g.fontFamily),g.fontSize!==void 0&&(M.fontSize=g.fontSize),g.fontWeight!==void 0&&(M.fontWeight=g.fontWeight),g.color!==void 0&&(M.color=g.color),g.position!==void 0&&(M.position=g.position),g.startTime!==void 0&&(M.startTime=g.startTime),g.duration!==void 0&&(M.duration=g.duration),g.animation!==void 0&&(M.animation=g.animation),g.textAlign!==void 0&&(M.textAlign=g.textAlign),g.textBaseline!==void 0&&(M.textBaseline=g.textBaseline),M},ve=(g,M)=>{const te={id:g.id??`audio-track-recipe-${M}`,source:g.source};return g.volume!==void 0&&(te.volume=g.volume),g.startTime!==void 0&&(te.startTime=g.startTime),g.duration!==void 0&&(te.duration=g.duration),g.fadeIn!==void 0&&(te.fadeIn=g.fadeIn),g.fadeOut!==void 0&&(te.fadeOut=g.fadeOut),g.loop!==void 0&&(te.loop=g.loop),g.name!==void 0&&(te.name=g.name),te},fe=g=>{if(typeof g.source!="string")return null;const M={id:g.id,source:g.source};return g.volume!==void 0&&(M.volume=g.volume),g.startTime!==void 0&&(M.startTime=g.startTime),g.duration!==void 0&&(M.duration=g.duration),g.fadeIn!==void 0&&(M.fadeIn=g.fadeIn),g.fadeOut!==void 0&&(M.fadeOut=g.fadeOut),g.loop!==void 0&&(M.loop=g.loop),g.name!==void 0&&(M.name=g.name),M},Ee=g=>{const M={id:g.id,source:typeof g.source=="string"?g.source:""};return g.volume!==void 0&&(M.volume=g.volume),g.startTime!==void 0&&(M.startTime=g.startTime),g.duration!==void 0&&(M.duration=g.duration),g.fadeIn!==void 0&&(M.fadeIn=g.fadeIn),g.fadeOut!==void 0&&(M.fadeOut=g.fadeOut),g.loop!==void 0&&(M.loop=g.loop),g.name!==void 0&&(M.name=g.name),g.muted!==void 0&&(M.muted=g.muted),g.solo!==void 0&&(M.solo=g.solo),g.pan!==void 0&&(M.pan=g.pan),g.faderDb!==void 0&&(M.faderDb=g.faderDb),M},ye=g=>({...g,segments:g.segments.map(M=>{const te={...M};return M.words&&(te.words=M.words.map(pe=>({...pe}))),te})}),Be=e.ref((((Ki=n.initialRecipe)==null?void 0:Ki.textOverlays)??[]).map(Ue)),Ie=g=>{switch(g){case"crossfade":return"cross-fade";case"zoom":return"zoom-in";case"cut":return"fade";default:return g}},et=g=>{switch(g){case"ease-in":return"easeIn";case"ease-out":return"easeOut";case"ease-in-out":return"easeInOut";case"linear":return"linear"}},tt=g=>{switch(g){case"cross-fade":case"dissolve":return"crossfade";case"zoom-in":case"zoom-out":return"zoom";case"dip-to-white":return"fade";case"wipe-up":case"wipe-down":return"wipe-left";case"slide-up":case"slide-down":return"slide-left";default:return g}},Tt=g=>{switch(g){case"easeIn":return"ease-in";case"easeOut":return"ease-out";case"easeInOut":return"ease-in-out";case"linear":default:return"linear"}},vt=g=>({id:g.id,type:Ie(g.type),duration:g.duration,easing:et(g.easing),name:g.type,fromClipId:g.fromClipId,toClipId:g.toClipId,cutTime:g.cutTime??0}),xt=g=>({id:g.id,type:tt(g.type),fromClipId:g.fromClipId,toClipId:g.toClipId,duration:g.duration,easing:Tt(g.easing),cutTime:g.cutTime}),wt=e.ref((((Ji=n.initialRecipe)==null?void 0:Ji.transitions)??[]).map(vt)),it=e.ref((((qi=n.initialRecipe)==null?void 0:qi.audioTracks)??[]).map(ve)),_t=e.ref(1),ge=e.ref(!1),ke=e.ref((((Yi=n.initialRecipe)==null?void 0:Yi.captionTracks)??[]).map(ye)),Te=e.ref([]),Ke=e.ref(null),Ge=e.computed(()=>r.value),Oe=e.computed(()=>Te.value),kt=e.computed(()=>ke.value[0]??null),lt=e.computed(()=>{const g=s.selectedClip.value??s.timelineClips.value[0];return g?Math.max(0,g.timelineEnd-g.timelineStart):B.value}),zt=e.computed(()=>H2(it.value.map(Ee),{master:{volume:_t.value,muted:ge.value}})),At=e.computed(()=>{const g=[...s.timelineClips.value].sort((Qe,yt)=>Qe.timelineStart-yt.timelineStart),M=s.selectedClip.value??g[0];if(!M)return[];const te=g.findIndex(Qe=>Qe.id===M.id);if(te===-1)return[];const pe=Qe=>(Qe.trackId??null)===(M.trackId??null),$e=g.slice(te+1).find(pe);if($e)return[M,$e];const De=[...g.slice(0,te)].reverse().find(pe);return De?[De,M]:[]}),Jt=g=>{O.value=g,g!=null&&g.composition&&(J.value=new mp(g.composition),Z.value=new pp(g.composition));try{se.size&&O.value&&(se.forEach((M,te)=>{O.value.setClipFilters(te,M)}),se.clear(),O.value.composition.computeFrame())}catch{}},Gt=g=>{O.value?O.value.setClipFilters(g,l.activeFilters.value):se.set(g,[...l.activeFilters.value])},la=g=>{var te,pe;const M=((te=s.selectedClip.value)==null?void 0:te.id)??((pe=s.timelineClips.value[0])==null?void 0:pe.id);M&&(ie.value=!0,typeof g=="object"&&g!==null&&"id"in g?l.applyFilter(g.id):typeof g=="string"&&l.applyFilter(g),s.setFilters(l.activeFilters.value),Gt(M),s.handleClipSelect(M),ie.value=!1,Pe())},ga=g=>{var pe,$e;const M=l.activeFilters.value.find(De=>De.filterId===g);M&&l.removeFilter(M.id),s.setFilters(l.activeFilters.value);const te=((pe=s.selectedClip.value)==null?void 0:pe.id)??(($e=s.timelineClips.value[0])==null?void 0:$e.id);te&&Gt(te),Pe()},ia=(g,M,te)=>{var De,Qe;const pe=l.activeFilters.value.find(yt=>yt.filterId===g);if(pe){pe.params={...pe.params??{},[M]:te},s.setFilters(l.activeFilters.value);const yt=((De=s.selectedClip.value)==null?void 0:De.id)??((Qe=s.timelineClips.value[0])==null?void 0:Qe.id);yt&&Gt(yt),Pe();return}const $e=l.previewFilter.value;$e&&$e.filterId===g&&($e.params={...$e.params??{},[M]:te})},Aa=g=>{g&&typeof g.id=="string"&&g.id!==""&&l.previewFilterEffect(g.id)},F=g=>{l.updateFilterParams(g),s.setFilters(l.activeFilters.value),Pe()},Y=async g=>{if(!J.value)return;const M=await J.value.addTextOverlay(g);Be.value.push({id:M,...g})},j=async(g,M)=>{if(!J.value)return;await J.value.updateTextOverlay(g,M);const te=Be.value.findIndex(pe=>pe.id===g);te!==-1&&(Be.value[te]={...Be.value[te],...M})},ee=async g=>{J.value&&(await J.value.removeTextOverlay(g),Be.value=Be.value.filter(M=>M.id!==g))},we=async g=>{const[M,te]=At.value;if(!M||!te)return;const pe={id:`transition-${M.id}-${te.id}-${Date.now()}`,...g,name:g.type,fromClipId:M.id,toClipId:te.id,cutTime:M.timelineEnd};wt.value.push(pe),s.setTransitions(wt.value.map(xt)),Pe()},Ve=g=>{wt.value[g]&&(wt.value.splice(g,1),s.setTransitions(wt.value.map(xt)),Pe())},Je=g=>{},ut=async g=>{if(!Z.value)return;const M=await Z.value.addAudioTrack(g);it.value.push({id:M,...g});const te=typeof g.source=="string"?g.source:g.source instanceof File?URL.createObjectURL(g.source):null;if(!te)return;const pe={id:`audio-source-${M}`,type:"url",url:te,duration:typeof g.duration=="number"&&g.duration>0?g.duration:0,width:0,height:0};typeof g.name=="string"&&(pe.filename=g.name),s.registerMediaSource(pe);const $e=s.appendAudioSourceToTimeline(pe.id);if(!$e.ok){Ze.value=$e.message;return}Ze.value=`Audio added to ${$e.value.trackId??"timeline"}.`,Pe()},St=async(g,M)=>{if(!Z.value)return;await Z.value.updateAudioTrack(g,M);const te=it.value.findIndex(pe=>pe.id===g);te!==-1&&(it.value[te]={...it.value[te],...M})},pt=async g=>{Z.value&&(await Z.value.removeAudioTrack(g),it.value=it.value.filter(M=>M.id!==g))},ft=async(g,M)=>{if(!Z.value)return;await Z.value.updateVolume(g,M);const te=it.value.find(pe=>pe.id===g);te&&(te.volume=M)},Mt=async(g,M)=>{if(!Z.value)return;await Z.value.muteTrack(g,M);const te=it.value.find(pe=>pe.id===g);te&&(te.muted=M)},Bt=g=>{Z.value&&(Z.value.setMasterVolume(g),_t.value=g)},It=(g,M)=>{const te=it.value.findIndex($e=>$e.id===g);if(te===-1)return null;const pe={...it.value[te],...M};return it.value[te]=pe,pe},Ma=g=>{switch(g.type){case"track-fader-db":{const M=Rl(g.valueDb);It(g.trackId,{faderDb:g.valueDb,volume:M}),Z.value&&Z.value.updateVolume(g.trackId,M);break}case"track-mute":It(g.trackId,{muted:g.muted}),Z.value&&Z.value.muteTrack(g.trackId,g.muted);break;case"track-solo":It(g.trackId,{solo:g.solo});break;case"track-pan":It(g.trackId,{pan:g.pan});break;case"master-fader-db":{_t.value=Rl(g.valueDb),Z.value&&Z.value.setMasterVolume(ge.value?0:_t.value);break}case"master-mute":ge.value=g.muted,Z.value&&Z.value.setMasterVolume(ge.value?0:_t.value);break}},ba=g=>{ke.value=[ye(g.track)],s.setCaptionTracks(ke.value),Pe()},da=g=>{ke.value=[ye(g)],s.setCaptionTracks(ke.value),Pe()},ca=()=>{ke.value=[],s.setCaptionTracks([]),Pe()},qt=g=>{const M=s.selectedClip.value??s.timelineClips.value[0];if(!M)return;const pe=[...(M.keyframes??[]).filter($e=>$e.target!==g.target),...g.keyframes].sort(($e,De)=>{const Qe=$e.time-De.time;return Qe===0?$e.id.localeCompare(De.id):Qe});s.setClipKeyframes(M.id,pe),Pe()},gt=g=>{var M;return g.metadata||(g.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),g.metadata.fit_mode=N.value,(M=n.media)!=null&&M.url&&/^https?:/i.test(n.media.url)?g.metadata.source_url=n.media.url:delete g.metadata.source_url,g.captionTracks=ke.value.map(ye),g},bt=(g,M)=>M?{...g,output:{...g.output,format:M.format,quality:M.quality,codec:M.codec??g.output.codec,fps:M.fps??g.output.fps,...typeof M.bitrate=="number"?{bitrate:M.bitrate}:{}}}:g,Yt=g=>g.map(M=>({...M,params:M.params&&typeof M.params=="object"?{...M.params}:M.params})),dt=g=>g.timeline.some(M=>Array.isArray(M.filters)&&M.filters.length>0),Ft=g=>{const M=Yt(l.activeFilters.value);if(!dt(g)&&M.length>0&&g.timeline.length>0){const pe=g.timeline[0];pe&&(g.timeline=[{...pe,filters:M},...g.timeline.slice(1)])}return g},ya=()=>{const g=Ft(gt(s.saveDraft()));try{localStorage.setItem(`video-draft-${r.value}`,JSON.stringify(g))}catch{}return le(g,"manual",!0),g},G=()=>typeof localStorage>"u"?null:{getItem:g=>localStorage.getItem(g),setItem:(g,M)=>{localStorage.setItem(g,M)},removeItem:g=>{localStorage.removeItem(g)},listKeys:g=>{const M=[];for(let te=0;te<localStorage.length;te+=1){const pe=localStorage.key(te);pe!=null&&pe.startsWith(g)&&M.push(pe)}return M}},q=async()=>{const g=G();if(g===null){Te.value=[];return}Te.value=await Dc(g)},le=async(g,M,te)=>{var ra,ho;const pe=G();if(pe===null)return;const $e=new Date().toISOString(),De={projectId:Ge.value,sourceMediaUuid:r.value,durationSeconds:B.value,editorVersion:((ra=g.metadata)==null?void 0:ra.editor_version)??"2.0.0",saveReason:M,now:$e};((ho=g.metadata)==null?void 0:ho.title)!==void 0&&(De.title=g.metadata.title);const Qe=y2(Rm(g),De);await V2(pe,Qe);const yt=await Dc(pe),Lt=E2(yt,{maxCount:5,projectId:Ge.value,now:$e});await Rc(pe,Lt.removed),Te.value=[...Lt.retained],te&&(Ke.value=$e)},de=g=>g.snapshot.metadata.payloadKind==="project"?f2(g.snapshot.payload):g.snapshot.payload,_e=g=>{const M=de(g);s.loadRecipe(M),Be.value=(M.textOverlays??[]).map(Ue),it.value=(M.audioTracks??[]).map(ve),ke.value=(M.captionTracks??[]).map(ye),wt.value=(M.transitions??[]).map(vt);const te=x(M);te!==null&&(N.value=te),Ye()},Le=g=>{const M=G();Te.value=Te.value.filter(te=>!g.some(pe=>pe.key===te.key)),M!==null&&Rc(M,g)},Ye=()=>{D.value=gt(s.generateRecipe())};let We=null;const Pe=()=>{We&&clearTimeout(We),We=setTimeout(()=>{Ye(),We=null},200)};if(e.watch(()=>s.timelineClips.value,Pe,{deep:!0}),e.watch(()=>s.selectedClip.value,g=>{if(ie.value||!g)return;const M=(g==null?void 0:g.filters)??[];l.setActiveFilters(M)},{immediate:!0}),e.watch(()=>l.activeFilters.value,g=>{s.setFilters(g),Pe()},{deep:!0}),e.watch(()=>Be.value,g=>{s.setTextOverlays(g.map(me)),Pe()},{deep:!0}),e.watch(()=>it.value,g=>{const M=g.map(fe).filter(te=>te!==null);s.setAudioTracks(M),Pe()},{deep:!0}),e.watch(()=>ke.value,g=>{s.setCaptionTracks(g.map(ye)),Pe()},{deep:!0}),Be.value.length>0&&s.setTextOverlays(Be.value.map(me)),it.value.length>0){const g=it.value.map(fe).filter(M=>M!==null);s.setAudioTracks(g)}ke.value.length>0&&s.setCaptionTracks(ke.value.map(ye)),e.watch(()=>s.playheadPosition.value,Pe),Ye();const at=e.ref(!0),ot=e.ref(null),Ze=e.ref(null);let jt=null;e.watch(Ze,g=>{jt!==null&&(clearTimeout(jt),jt=null),!(g===null||g==="")&&(jt=setTimeout(()=>{Ze.value=null},4e3))});const Ct=e.ref(null),wa=e.computed(()=>s.tracks.value),cn=e.computed(()=>s.mediaSources.value),Es=e.computed(()=>{var g,M;return((g=s.selectedClip.value)==null?void 0:g.sourceRefId)??((M=cn.value[0])==null?void 0:M.id)}),un=e.computed(()=>wa.value.filter(g=>g.locked!==!0&&g.type==="video")),oo=e.computed(()=>Ct.value?wa.value.find(g=>g.id===Ct.value)??null:null),Vn=e.computed(()=>!!s.selectedClip.value&&s.playheadPosition.value>0),Fa=e.computed(()=>!!s.selectedClip.value),Oi=e.computed(()=>s.timelineClips.value.length>0&&s.hasChanges.value),xs=e.computed(()=>s.selectedClip.value??s.timelineClips.value[0]??null),zi=g=>{const M=Number.isFinite(g)&&g>0?Math.round(g):0,te=Math.floor(M/60),pe=M%60;return`${te}:${pe.toString().padStart(2,"0")}`},Ss=e.computed(()=>{const g=s.timelineClips.value.length,M=wa.value.length,te=g===1?"1 clip":`${g} clips`,pe=M===1?"1 track":`${M} tracks`;return`${te} / ${pe} / ${zi(B.value)}`});e.watch(()=>wa.value.map(g=>`${g.id}:${g.locked===!0?"locked":"open"}`).join("|"),()=>{var g;Ct.value&&un.value.some(M=>M.id===Ct.value)||(Ct.value=((g=un.value[0])==null?void 0:g.id)??null)},{immediate:!0}),e.watch(()=>{var g;return(g=s.selectedClip.value)==null?void 0:g.trackId},g=>{g&&un.value.some(M=>M.id===g)&&(Ct.value=g)},{immediate:!0});const Ao=g=>{const M=cn.value.find(te=>te.id===g);return M?M.filename??M.mediaUuid??M.url??M.id:"Asset"},ji=n.assetUploader?o4({uploader:n.assetUploader,onReady:g=>{if(!g.mediaUrl&&!g.mediaUuid)return;const M={id:`imported-${g.assetId}`,type:g.mediaUuid?"media":"url",filename:g.filename,mimeType:g.mime,duration:g.durationSeconds??0,width:g.width??0,height:g.height??0};g.mediaUuid!==void 0&&(M.mediaUuid=g.mediaUuid),g.mediaUrl!==void 0&&(M.url=g.mediaUrl),s.registerMediaSource(M),Ze.value=`${g.filename} ready.`},onFailure:g=>{Ze.value=g.failureMessage??`Upload of ${g.filename} failed.`}}):null,Cs=async g=>{if(!ji){Ze.value="Asset import is not configured for this editor host.";return}for(const M of g){const te=await ji.importFile(M);te.ok||(Ze.value=te.message)}},Lo=g=>{var $e;const M=s.appendMediaSourceToTimeline(g,Ct.value);if(!M.ok){ot.value=M.message;return}const te=M.value;te.trackId&&(Ct.value=te.trackId),s.handleClipSelect(te.id);const pe=(($e=oo.value)==null?void 0:$e.name)??"timeline";ot.value=`${Ao(g)} added to ${pe}.`,Pe()},Vs=g=>{if(!s.replaceSelectedClipSource(g)){ot.value="Select a clip before replacing its source.";return}ot.value=`${Ao(g)} replaced the selected clip.`,Pe()},Ns=g=>{const M=Ao(g);if(!s.removeMediaSource(g)){ot.value="Remove timeline clips before deleting this asset.";return}ot.value=`${M} removed.`,Pe()},Nn=(g="video")=>{const M=s.addTimelineTrack(g);Ct.value=M.id,ot.value=`${M.name} added. New assets will be placed on that track.`,Pe()},ua=g=>{const M=g.target;M&&(Ct.value=M.value||null)},mn=g=>{var te;s.handleClipSelect(g);const M=(te=s.selectedClip.value)==null?void 0:te.trackId;M&&un.value.some(pe=>pe.id===M)&&(Ct.value=M)},Po=(g,M,te)=>{const pe=s.moveClip(g,M,te);if(!pe.ok){Ze.value=pe.message;return}Pe()},Uo=g=>{const M=s.deleteClip(g);if(!M.ok){Ze.value=M.message;return}Ze.value="Clip deleted.",Pe()},pn=(g,M)=>{M(g)&&Pe()},io=(g,M)=>{const te=s.renameTimelineTrack(g,M);if(!te.ok){Ze.value=te.message;return}Ze.value=`Track renamed to "${M}".`,Pe()},en=g=>{const M=s.deleteTimelineTrack(g);if(!M.ok){Ze.value=M.message;return}Ct.value===g&&(Ct.value=null),Ze.value="Track deleted.",Pe()},Qt=(g,M)=>{const te=s.reorderTimelineTrack(g,M);if(!te.ok){Ze.value=te.message;return}Ze.value=`Track moved ${M}.`,Pe()},Va=g=>{at.value=g},tn=()=>{at.value=!at.value},Wi=g=>{const M=g.target;if(!M)return;const te=Number(M.value);Number.isFinite(te)&&s.setZoomLevel(te)},Xt=e.ref(!1),fn=e.ref(0),La=e.ref(!1),Nt=e.ref(null),an=e.ref(null),ro=e.ref("preparing");let Tn=null,Pa=!1;const Oo={preparing:"Preparing export...",rendering:"Rendering frames...","encoding-video":"Encoding video...","encoding-audio":"Encoding audio...",muxing:"Muxing output...",storing:"Storing export...",complete:"Export complete"},so=g=>typeof g=="string"&&g in Oo,Ua=(g,M)=>{ro.value=g,Nt.value=typeof M=="string"&&M.trim()!==""?M.trim():Oo[g]},ka=(g,M,te)=>{const pe=Number.isFinite(g)?Math.max(0,Math.min(100,g)):0;fn.value=pe,M&&Ua(M,te)},zo=g=>{if(so(g.phase))return g.phase;switch(g.status){case"pending":return"preparing";case"processing":return"rendering";case"completed":return"complete";default:return ro.value}},Hi=g=>typeof g.progress_message=="string"&&g.progress_message.trim()!==""?g.progress_message.trim():void 0,Bn=(g,M,te={allowClient:!0})=>{if(!Number.isFinite(M)||M<=0||g.timeline.length===0)return{route:"unsupported",exportDuration:M,message:"Export unavailable: the recipe has no renderable duration."};if(n.maxDuration>0&&M>n.maxDuration)return{route:"unsupported",exportDuration:M,message:`Export unavailable: duration exceeds the ${n.maxDuration}s limit.`};if(te.allowClient&&n.clientExportThreshold>0&&M<=n.clientExportThreshold)return{route:"client",exportDuration:M};const $e=!!n.serverRenderEndpoint,De=r.value.startsWith("temp-");return $e&&!De?{route:"server-render",exportDuration:M}:{route:"recipe-download",exportDuration:M,message:De?"Local media — downloaded recipe.json. Client-side PIXI export is unavailable on this device.":"No server render endpoint configured — downloaded recipe.json."}},lo=()=>new ys(n.serverRenderEndpoint??"/api/v1"),Oa=()=>{Tn!==null&&(clearInterval(Tn),Tn=null)},Zi=g=>{Oa();const M=lo();Tn=setInterval(async()=>{if(Pa){Oa();return}try{const te=await M.getJob(g),pe=Number(te.progress??0);if(ka(pe,zo(te),Hi(te)),i("server-render-progress",fn.value),te.status==="completed"||te.status==="failed"||te.status==="cancelled")if(Oa(),Xt.value=!1,an.value=null,te.status==="completed"){ka(100,"complete"),La.value=!0,Nt.value=null;const $e=typeof te.output_media_id=="string"?te.output_media_id:void 0,De={id:g};$e!==void 0&&(De.output_media_id=$e),i("server-render-completed",De)}else{const $e=te.status==="cancelled"||typeof te.error_message=="string"&&/cancel/i.test(te.error_message),De=$e?"Export canceled.":typeof te.error_message=="string"&&te.error_message.trim()!==""?te.error_message:"Export failed";Nt.value=De,$e||i("server-render-failed",De)}}catch(te){Oa(),Xt.value=!1,an.value=null;const pe=te instanceof Error?te.message:"Failed to check export progress";Nt.value=pe,i("server-render-failed",pe)}},2e3)},co=g=>{const M=new Blob([JSON.stringify(g,null,2)],{type:"application/json"}),te=URL.createObjectURL(M),pe=document.createElement("a");pe.href=te,pe.download=`video-recipe-${Date.now()}.json`,pe.click(),setTimeout(()=>URL.revokeObjectURL(te),100)},uo=()=>{Oa(),Pa=!1,R.resetClientExport(),an.value=null,Nt.value=null,La.value=!1,fn.value=0,ro.value="preparing"},hn=async g=>{ka(0,"preparing");const te=await lo().createRenderJob({source_media_uuid:r.value,recipe:g}),pe=typeof te.id=="string"?te.id:null;if(!pe)throw new Error("Export failed: missing job id");an.value=pe,i("export-started",pe),i("server-render-started",pe),ka(1,"rendering"),Zi(pe)},jo=async(g,M)=>{if(!await R.canExportClientSide())return null;const te=await R.renderRecipeWithPixi(g,M,pe=>{Pa||ka(pe,"rendering")});return Pa?(Nt.value="Export canceled.",ka(0),i("video-exported",null),null):(s.clearHasChanges(),i("recipe-generated",g),i("video-exported",te),ka(100,"complete"),La.value=!0,te)},In=async g=>{uo(),Xt.value=!0,Ua("preparing");try{const M=gt(Ft(bt(s.generateRecipe(),g)));le(M,"before-export",!1),i("recipe-generated",M);const te=$c(M,B.value),pe=Bn(M,te);if(pe.route==="unsupported"){Xt.value=!1,Nt.value=pe.message??"Export unavailable.",i("server-render-failed",Nt.value);return}if(pe.route==="client"){const De=await jo(M,g);if(De!==null){const Qe=URL.createObjectURL(De.file),yt=document.createElement("a");yt.href=Qe,yt.download=`edited-video-${Date.now()}.mp4`,yt.click(),setTimeout(()=>URL.revokeObjectURL(Qe),100),Xt.value=!1;return}}const $e=pe.route==="client"?Bn(M,te,{allowClient:!1}):pe;if($e.route==="unsupported"){Xt.value=!1,Nt.value=$e.message??"Export unavailable.",i("server-render-failed",Nt.value);return}if($e.route==="recipe-download"){co(M),Xt.value=!1,ka(100,"complete"),La.value=!0,Nt.value=$e.message??"Downloaded recipe.json.";return}await hn(M)}catch(M){const te=gt(s.generateRecipe());co(te);const pe=M instanceof Error?M.message:"Export failed";Xt.value=!1,ka(0),an.value=null,Nt.value=pe,i("server-render-failed",pe)}},mo=async()=>{Pa=!0,w.value=!1,R.cancelClientExport();const g=an.value;if(Oa(),Xt.value=!1,ka(0),Nt.value="Export canceled.",an.value=null,g&&n.serverRenderEndpoint)try{await lo().cancelJob(g)}catch{}},Mn=()=>{s.togglePlayback()},po=()=>{s.resetChanges()},vn=()=>{const g=ya();i("draft-saved",g)},Gi=()=>{In()},Wo=()=>{i("close")};a({saveDraft:async()=>{const g=ya();return i("draft-saved",g),g},exportForUpload:async g=>{uo();const M=gt(g??s.generateRecipe()),te=Ft(M),pe=Array.isArray(te.filters)&&te.filters.length>0,$e=dt(te);if(!(s.hasChanges.value||pe||$e))return s.clearHasChanges(),i("video-exported",null),null;const Qe=$c(te,B.value),yt=Bn(te,Qe);if(yt.route==="unsupported"){const Lt=yt.message??"Export unavailable.";throw Nt.value=Lt,new Error(`Video export failed: ${Lt}`)}if(yt.route==="server-render")return Xt.value=!0,await hn(te),null;Xt.value=!0;try{if(yt.route==="client"){const ra=await jo(te);if(ra!==null)return ra}const Lt=yt.route==="client"?Bn(te,Qe,{allowClient:!1}):yt;if(Lt.route==="server-render")return await hn(te),null;if(Lt.route==="unsupported"){const ra=Lt.message??"Export unavailable.";throw Nt.value=ra,new Error(`Video export failed: ${ra}`)}return Nt.value=Lt.message??"Export unavailable for upload.",i("video-exported",null),null}catch(Lt){if(Pa)return Nt.value="Export canceled.",ka(0),i("video-exported",null),null;const ra=Lt instanceof Error?Lt.message:"Local WebGL export failed.";throw Nt.value=ra,new Error(`Video export failed: ${ra}`)}finally{Xt.value=!1}}});const fo=e.ref(!1),Ho=g=>{var De,Qe;const M=[...s.timelineClips.value].sort((yt,Lt)=>yt.timelineStart-Lt.timelineStart);if(M.length===0)return;const te=s.selectedClip.value;if(!te){s.handleClipSelect(((De=M[0])==null?void 0:De.id)??null);return}const pe=M.findIndex(yt=>yt.id===te.id);if(pe===-1){s.handleClipSelect(((Qe=M[0])==null?void 0:Qe.id)??null);return}const $e=g==="next"?M[Math.min(pe+1,M.length-1)]:M[Math.max(pe-1,0)];$e&&s.handleClipSelect($e.id)},Zo=()=>{s.seekTo(Math.min(s.totalDuration.value,s.playheadPosition.value+1))},Xi=()=>{s.seekTo(Math.max(0,s.playheadPosition.value-1))};return ZT({playPause:Mn,frameForward:s.frameForward,frameBackward:s.frameBackward,secondForward:Zo,secondBackward:Xi,skipToStart:s.skipToStart,skipToEnd:s.skipToEnd,prevClip:()=>Ho("prev"),nextClip:()=>Ho("next"),splitAtPlayhead:s.splitAtPlayhead,deleteSelected:()=>{const g=s.deleteSelectedClip();g.ok?Ze.value="Clip deleted.":Ze.value=g.message},rippleDeleteSelected:()=>{s.rippleDeleteSelectedClip()?Ze.value="Clip removed and gap closed.":Ze.value="Nothing to ripple-delete."},undo:s.undo,redo:s.redo,save:vn,exportNow:()=>{if(s.timelineClips.value.length===0){Ze.value="Add media to export.";return}Gi()},showShortcutsOverlay:()=>{fo.value=!0}}),e.onMounted(()=>{document.documentElement.setAttribute("data-video-editor-version","v2"),q()}),e.onBeforeUnmount(()=>{document.documentElement.getAttribute("data-video-editor-version")==="v2"&&document.documentElement.removeAttribute("data-video-editor-version")}),e.onUnmounted(()=>{Oa(),Pa=!0,R.cancelClientExport(),We&&(clearTimeout(We),We=null),O.value&&(O.value.destroy(),O.value=null),J.value=null,Z.value=null}),(g,M)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(pV,{"data-testid":"video-editor-v2"},{toolbar:e.withCtx(()=>[e.createElementVNode("div",r4,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["v2-toolbar-btn",{"is-active":e.unref(s).isPlaying.value}]),"data-testid":"v2-btn-play","aria-label":e.unref(s).isPlaying.value?"Pause":"Play",onClick:Mn},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(s).isPlaying.value?e.unref(ql):e.unref(Yl),"aria-hidden":"true"},null,8,["icon"])],10,s4),e.createElementVNode("button",{type:"button",class:"v2-toolbar-btn","data-testid":"v2-btn-reset","aria-label":"Reset all changes",disabled:!e.unref(s).hasChanges.value,onClick:po},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(eo),"aria-hidden":"true"},null,8,["icon"])],8,l4)]),M[20]||(M[20]=e.createElementVNode("div",{class:"v2-toolbar-title","aria-live":"polite"},[e.createElementVNode("span",{class:"v2-toolbar-badge"},"V2"),e.createTextVNode(" Video Editor ")],-1)),e.createElementVNode("div",d4,[e.createElementVNode("label",c4,[M[18]||(M[18]=e.createElementVNode("span",{class:"sr-only"},"Fit mode",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":M[0]||(M[0]=te=>N.value=te),"aria-label":"Fit mode","data-testid":"v2-select-fit-mode"},[...M[17]||(M[17]=[e.createElementVNode("option",{value:"contain"},"Contain",-1),e.createElementVNode("option",{value:"cover"},"Cover",-1),e.createElementVNode("option",{value:"none"},"None",-1)])],512),[[e.vModelSelect,N.value]])]),e.createElementVNode("button",{type:"button",class:"v2-toolbar-btn","data-testid":"v2-btn-save","aria-label":"Save draft",disabled:!e.unref(s).hasChanges.value,onClick:vn},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Kr),"aria-hidden":"true"},null,8,["icon"]),M[19]||(M[19]=e.createElementVNode("span",{class:"v2-toolbar-btn-label"},"Save",-1))],8,u4),e.createElementVNode("button",{type:"button",class:"v2-toolbar-btn","data-testid":"v2-btn-export","aria-label":e.unref(s).timelineClips.value.length===0?"Export disabled — add media first":"Export",title:e.unref(s).timelineClips.value.length===0?"Add media to export":void 0,disabled:Xt.value||e.unref(s).timelineClips.value.length===0,onClick:Gi},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Co),"aria-hidden":"true"},null,8,["icon"])],8,m4),e.createElementVNode("button",{type:"button",class:"v2-toolbar-btn","data-testid":"v2-btn-close","aria-label":"Close editor",onClick:Wo},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Gn),"aria-hidden":"true"},null,8,["icon"])])])]),assets:e.withCtx(()=>[e.createElementVNode("div",p4,[e.createVNode(CV,{sources:cn.value,"selected-source-id":Es.value,"uploads-enabled":!!g.assetUploader,onAdd:Lo,onReplaceSelected:Vs,onRemove:Ns,onImportFiles:Cs},null,8,["sources","selected-source-id","uploads-enabled"]),ot.value?(e.openBlock(),e.createElementBlock("p",f4,e.toDisplayString(ot.value),1)):e.createCommentVNode("",!0)])]),canvas:e.withCtx(()=>[e.createElementVNode("div",h4,[e.withDirectives(e.createVNode(ll,{ref_key:"pixiPreviewRef",ref:b,class:"v2-preview-child","aria-hidden":!S.value,source:C.value,"fallback-duration":B.value,filters:T.value,playhead:y.value,"is-playing":e.unref(s).isPlaying.value,"fit-mode":N.value,active:S.value,onPlayPause:Mn,onFrameUpdate:X,onDurationChange:P},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active"]),[[e.vShow,S.value]]),e.withDirectives(e.createVNode(xl,{class:"v2-preview-child","aria-hidden":!k.value,"media-uuid":r.value,recipe:D.value,media:U.value,"enable-engine":k.value&&z.value,"fit-mode":N.value,onTimeUpdate:K,onPlayStateChange:be,onDurationChange:P,onEngineReady:Jt},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,k.value]])])]),timeline:e.withCtx(({isMobile:te})=>{var pe,$e;return[e.createElementVNode("div",{class:e.normalizeClass(["v2-timeline",{"is-mobile":!!te}])},[e.createElementVNode("div",v4,[e.createElementVNode("div",g4,[M[21]||(M[21]=e.createElementVNode("span",{class:"v2-timeline-title","data-testid":"v2-timeline-title"},"Timeline",-1)),e.createElementVNode("span",b4,e.toDisplayString(Ss.value),1)]),e.createElementVNode("label",y4,[M[22]||(M[22]=e.createElementVNode("span",null,"Zoom",-1)),e.createElementVNode("input",{type:"range",min:"10",max:"600",value:e.unref(s).zoomLevel.value,"aria-label":"Timeline zoom","data-testid":"v2-timeline-zoom",onInput:Wi},null,40,w4),e.createElementVNode("span",k4,e.toDisplayString(Math.round(e.unref(s).zoomLevel.value))+" px/s",1)]),te?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",_4,[e.createElementVNode("button",{type:"button",class:"v2-toolbar-btn v2-toolbar-btn--ghost","data-testid":"v2-btn-add-track",onClick:M[1]||(M[1]=De=>Nn("video"))},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(vr)},null,8,["icon"]),M[23]||(M[23]=e.createTextVNode(" Add Track ",-1))]),un.value.length>0?(e.openBlock(),e.createElementBlock("label",E4,[M[24]||(M[24]=e.createElementVNode("span",null,"Place clips in",-1)),e.createElementVNode("select",{value:Ct.value??"","data-testid":"v2-select-target-track","aria-label":"Target track for added assets",onChange:ua},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(un.value,De=>(e.openBlock(),e.createElementBlock("option",{key:De.id,value:De.id},e.toDisplayString(De.name),9,S4))),128))],40,x4)])):e.createCommentVNode("",!0)])),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["v2-toolbar-btn v2-toolbar-btn--ghost",{"is-active":at.value}]),"data-testid":"v2-btn-snap-toggle","aria-pressed":at.value?"true":"false",onClick:tn},e.toDisplayString(at.value?"Snap On":"Snap Off"),11,C4)]),Ze.value?(e.openBlock(),e.createElementBlock("p",V4,e.toDisplayString(Ze.value),1)):e.createCommentVNode("",!0),e.unref(s).timelineClips.value.length===0?(e.openBlock(),e.createElementBlock("div",N4,[...M[25]||(M[25]=[e.createElementVNode("p",{class:"v2-timeline-empty-title"},"Your timeline is empty",-1),e.createElementVNode("p",{class:"v2-timeline-empty-hint"}," Add a clip from the Assets panel or upload media to get started. Export is disabled until the timeline has at least one clip. ",-1)])])):(e.openBlock(),e.createBlock(Sl,{key:2,playhead:e.unref(s).playheadPosition.value,clips:e.unref(s).timelineClips.value,tracks:wa.value,"selected-clip-id":((pe=e.unref(s).selectedClip.value)==null?void 0:pe.id)??(($e=e.unref(s).timelineClips.value[0])==null?void 0:$e.id)??null,duration:B.value,fps:e.unref(s).fps.value,"is-mobile":!!te,"zoom-level":e.unref(s).zoomLevel.value,"snap-enabled":at.value,sensitivity:.25,"onUpdate:playhead":M[2]||(M[2]=De=>e.unref(s).seekTo(De)),onTrim:M[3]||(M[3]=(De,Qe,yt)=>e.unref(s).handleTrim(De,Qe,yt)),onSplit:M[4]||(M[4]=De=>e.unref(s).handleSplit(De)),onClipSelect:mn,onClipDelete:Uo,onClipMove:Po,onSnapStateChange:Va,onToggleLock:M[5]||(M[5]=De=>pn(De,e.unref(s).toggleTrackLock)),onToggleHidden:M[6]||(M[6]=De=>pn(De,e.unref(s).toggleTrackHidden)),onToggleMuted:M[7]||(M[7]=De=>pn(De,e.unref(s).toggleTrackMuted)),onToggleSolo:M[8]||(M[8]=De=>pn(De,e.unref(s).toggleTrackSolo)),onRenameTrack:io,onDeleteTrack:en,onReorderTrack:Qt},null,8,["playhead","clips","tracks","selected-clip-id","duration","fps","is-mobile","zoom-level","snap-enabled"])),e.createVNode(Cl,{"selected-clip":e.unref(s).selectedClip.value,"can-split":Vn.value,"can-delete":Fa.value,"can-undo":e.unref(s).canUndo.value,"can-redo":e.unref(s).canRedo.value,"is-playing":e.unref(s).isPlaying.value,"zoom-level":e.unref(s).zoomLevel.value,"playback-speed":e.unref(s).playbackSpeed.value,"is-mobile":!!te,"show-add-track":!!te,onSplit:e.unref(s).splitAtPlayhead,onDelete:e.unref(s).deleteSelectedClip,onAddTrack:M[9]||(M[9]=De=>Nn("video")),onDuplicate:e.unref(s).duplicateSelectedClip,onUndo:e.unref(s).undo,onRedo:e.unref(s).redo,onZoomIn:e.unref(s).zoomIn,onZoomOut:e.unref(s).zoomOut,onZoomChange:e.unref(s).setZoomLevel,onFitToWindow:e.unref(s).fitToWindow,onPlayPause:Mn,onFrameForward:e.unref(s).frameForward,onFrameBackward:e.unref(s).frameBackward,onSkipToStart:e.unref(s).skipToStart,onSkipToEnd:e.unref(s).skipToEnd,onSpeedChange:e.unref(s).setPlaybackSpeed},null,8,["selected-clip","can-split","can-delete","can-undo","can-redo","is-playing","zoom-level","playback-speed","is-mobile","show-add-track","onSplit","onDelete","onDuplicate","onUndo","onRedo","onZoomIn","onZoomOut","onZoomChange","onFitToWindow","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"])],2)]}),inspector:e.withCtx(()=>[Oe.value.length>0?(e.openBlock(),e.createBlock(du,{key:0,class:"v2-draft-recovery",records:Oe.value,surface:"desktop","project-id":Ge.value,"saved-at":Ke.value,onRestore:_e,onDismiss:Le},null,8,["records","project-id","saved-at"])):e.createCommentVNode("",!0),e.createVNode(sT,{"active-tab":d.value,"onUpdate:activeTab":M[10]||(M[10]=te=>d.value=te),tabs:m.value},{filters:e.withCtx(()=>[e.createVNode(Vl,{filters:Ne.value,"active-filters":ue.value,"thumbnail-url":re.value,onApplyFilter:la,onRemoveFilter:ga,onUpdateParam:ia,onPreviewFilter:Aa},null,8,["filters","active-filters","thumbnail-url"])]),adjustments:e.withCtx(()=>[e.unref(l).selectedFilter.value?(e.openBlock(),e.createBlock(Nl,{key:0,filter:e.unref(l).selectedFilter.value,"current-frame":e.unref(s).currentFrame.value,onUpdateParams:F},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",T4,[...M[26]||(M[26]=[e.createElementVNode("p",null,"Select a filter from the Filters tab to adjust its parameters.",-1)])])),e.createVNode(cu,{class:"v2-keyframe-panel",duration:lt.value,target:"all","device-class":"desktop",onApplyPreset:qt},null,8,["duration"])]),text:e.withCtx(()=>[e.createVNode(Bl,{overlays:Be.value,onAddOverlay:Y,onUpdateOverlay:j,onRemoveOverlay:ee},null,8,["overlays"]),e.createVNode(lu,{class:"v2-caption-panel","caption-track":kt.value,layout:"desktop",onImport:ba,"onUpdate:captionTrack":da,onClear:ca},null,8,["caption-track"])]),transitions:e.withCtx(()=>[e.createVNode(Il,{"selected-clips":At.value,"applied-transitions":wt.value,onApplyTransition:we,onRemoveTransition:Ve,onPreviewTransition:Je},null,8,["selected-clips","applied-transitions"])]),audio:e.withCtx(()=>[e.createVNode(Ml,{"audio-layers":it.value,"master-volume":_t.value,onAddTrack:ut,onUpdateTrack:St,onRemoveTrack:pt,onUpdateVolume:ft,onToggleMute:Mt,onUpdateMasterVolume:Bt},null,8,["audio-layers","master-volume"]),e.createVNode(su,{class:"v2-audio-mixer",state:zt.value,"device-class":"desktop",onUpdate:Ma},null,8,["state"])]),export:e.withCtx(()=>[e.createVNode(Tl,{"can-export":Oi.value,"is-exporting":Xt.value,"export-progress":fn.value,onExport:In,onCancelExport:mo,onSaveDraft:vn,onReset:po},null,8,["can-export","is-exporting","export-progress"]),La.value?(e.openBlock(),e.createElementBlock("div",B4," Export complete ")):e.createCommentVNode("",!0),Nt.value&&!La.value?(e.openBlock(),e.createElementBlock("div",I4,e.toDisplayString(Nt.value),1)):e.createCommentVNode("",!0)]),_:1},8,["active-tab","tabs"])]),drawer:e.withCtx(()=>[e.createVNode(jT,{ref_key:"mobileDrawerRef",ref:u,"initial-snap":"half","aria-label":"Video editor controls"},{default:e.withCtx(()=>[Oe.value.length>0?(e.openBlock(),e.createBlock(du,{key:0,class:"v2-draft-recovery",records:Oe.value,surface:"mobile","project-id":Ge.value,"saved-at":Ke.value,onRestore:_e,onDismiss:Le},null,8,["records","project-id","saved-at"])):e.createCommentVNode("",!0),e.createVNode(MT,{"selected-clip":xs.value,onOpenActions:M[11]||(M[11]=te=>c.value="trim")},null,8,["selected-clip"]),e.createVNode(AT,{modelValue:c.value,"onUpdate:modelValue":M[12]||(M[12]=te=>c.value=te)},null,8,["modelValue"]),c.value==="look"?(e.openBlock(),e.createElementBlock("section",M4,[e.createElementVNode("div",F4,[e.createVNode(Vl,{filters:Ne.value,"active-filters":ue.value,"thumbnail-url":re.value,onApplyFilter:la,onRemoveFilter:ga,onUpdateParam:ia,onPreviewFilter:Aa},null,8,["filters","active-filters","thumbnail-url"])]),e.createElementVNode("div",$4,[e.unref(l).selectedFilter.value?(e.openBlock(),e.createBlock(Nl,{key:0,filter:e.unref(l).selectedFilter.value,"current-frame":e.unref(s).currentFrame.value,onUpdateParams:F},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",D4,[...M[27]||(M[27]=[e.createElementVNode("p",null,"Select a filter from the Filters tab to adjust its parameters.",-1)])]))])])):c.value==="trim"?(e.openBlock(),e.createElementBlock("section",R4,[e.createVNode(Cl,{"selected-clip":e.unref(s).selectedClip.value,"can-split":Vn.value,"can-delete":Fa.value,"can-undo":e.unref(s).canUndo.value,"can-redo":e.unref(s).canRedo.value,"is-playing":e.unref(s).isPlaying.value,"zoom-level":e.unref(s).zoomLevel.value,"playback-speed":e.unref(s).playbackSpeed.value,"is-mobile":"","show-add-track":"",onSplit:e.unref(s).splitAtPlayhead,onDelete:e.unref(s).deleteSelectedClip,onAddTrack:M[13]||(M[13]=te=>Nn("video")),onDuplicate:e.unref(s).duplicateSelectedClip,onUndo:e.unref(s).undo,onRedo:e.unref(s).redo,onZoomIn:e.unref(s).zoomIn,onZoomOut:e.unref(s).zoomOut,onZoomChange:e.unref(s).setZoomLevel,onFitToWindow:e.unref(s).fitToWindow,onPlayPause:Mn,onFrameForward:e.unref(s).frameForward,onFrameBackward:e.unref(s).frameBackward,onSkipToStart:e.unref(s).skipToStart,onSkipToEnd:e.unref(s).skipToEnd,onSpeedChange:e.unref(s).setPlaybackSpeed},null,8,["selected-clip","can-split","can-delete","can-undo","can-redo","is-playing","zoom-level","playback-speed","onSplit","onDelete","onDuplicate","onUndo","onRedo","onZoomIn","onZoomOut","onZoomChange","onFitToWindow","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"])])):c.value==="text"?(e.openBlock(),e.createElementBlock("section",A4,[e.createVNode(Bl,{overlays:Be.value,onAddOverlay:Y,onUpdateOverlay:j,onRemoveOverlay:ee},null,8,["overlays"]),e.createVNode(lu,{"caption-track":kt.value,layout:"mobile",onImport:ba,"onUpdate:captionTrack":da,onClear:ca},null,8,["caption-track"])])):c.value==="audio"?(e.openBlock(),e.createElementBlock("section",L4,[e.createVNode(Ml,{"audio-layers":it.value,"master-volume":_t.value,onAddTrack:ut,onUpdateTrack:St,onRemoveTrack:pt,onUpdateVolume:ft,onToggleMute:Mt,onUpdateMasterVolume:Bt},null,8,["audio-layers","master-volume"]),e.createVNode(su,{state:zt.value,"device-class":"mobile",onUpdate:Ma},null,8,["state"])])):c.value==="export"?(e.openBlock(),e.createElementBlock("section",P4,[e.createVNode(Tl,{"can-export":Oi.value,"is-exporting":Xt.value,"export-progress":fn.value,"is-mobile":"",onExport:In,onCancelExport:mo,onSaveDraft:vn,onReset:po},null,8,["can-export","is-exporting","export-progress"]),La.value?(e.openBlock(),e.createElementBlock("div",U4,"Export complete")):e.createCommentVNode("",!0),Nt.value&&!La.value?(e.openBlock(),e.createElementBlock("div",O4,e.toDisplayString(Nt.value),1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("section",z4,[e.createElementVNode("div",j4,[e.createElementVNode("label",W4,[M[29]||(M[29]=e.createElementVNode("span",null,"Fit",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":M[14]||(M[14]=te=>N.value=te),"aria-label":"Mobile fit mode"},[...M[28]||(M[28]=[e.createElementVNode("option",{value:"contain"},"Contain",-1),e.createElementVNode("option",{value:"cover"},"Cover",-1),e.createElementVNode("option",{value:"none"},"None",-1)])],512),[[e.vModelSelect,N.value]])]),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["v2-mobile-secondary-button",{"is-active":at.value}]),"aria-pressed":at.value?"true":"false","data-testid":"v2-mobile-btn-snap-toggle",onClick:tn},e.toDisplayString(at.value?"Snap On":"Snap Off"),11,H4),e.createElementVNode("button",{type:"button",class:"v2-mobile-secondary-button","data-testid":"v2-mobile-btn-reset",disabled:!e.unref(s).hasChanges.value,onClick:po}," Reset ",8,Z4),e.createElementVNode("button",{type:"button",class:"v2-mobile-secondary-button","data-testid":"v2-mobile-btn-save",disabled:!e.unref(s).hasChanges.value,onClick:vn}," Save ",8,G4)]),v.value?(e.openBlock(),e.createElementBlock("details",X4,[M[30]||(M[30]=e.createElementVNode("summary",null,"Transitions",-1)),e.createVNode(Il,{"selected-clips":At.value,"applied-transitions":wt.value,onApplyTransition:we,onRemoveTransition:Ve,onPreviewTransition:Je},null,8,["selected-clips","applied-transitions"])])):e.createCommentVNode("",!0),e.createElementVNode("details",K4,[M[31]||(M[31]=e.createElementVNode("summary",null,"Keyframe presets",-1)),e.createVNode(cu,{duration:lt.value,target:"all","device-class":"mobile",onApplyPreset:qt},null,8,["duration"])])]))]),_:1},512)]),_:1}),fo.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"v2-shortcuts-overlay",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts","data-testid":"v2-shortcuts-overlay",onClick:M[16]||(M[16]=e.withModifiers(te=>fo.value=!1,["self"]))},[e.createElementVNode("div",J4,[e.createElementVNode("div",q4,[M[32]||(M[32]=e.createElementVNode("h2",null,"Keyboard shortcuts",-1)),e.createElementVNode("button",{type:"button",class:"v2-shortcuts-overlay__close","aria-label":"Close shortcuts overlay","data-testid":"v2-shortcuts-overlay-close",onClick:M[15]||(M[15]=te=>fo.value=!1)},"×")]),M[33]||(M[33]=e.createStaticVNode('<dl class="v2-shortcuts-overlay__list" data-v-aa4426a6><div data-v-aa4426a6><dt data-v-aa4426a6>Space</dt><dd data-v-aa4426a6>Play / pause</dd></div><div data-v-aa4426a6><dt data-v-aa4426a6>← / →</dt><dd data-v-aa4426a6>Frame back / forward</dd></div><div data-v-aa4426a6><dt data-v-aa4426a6>Shift + ← / →</dt><dd data-v-aa4426a6>1 second back / forward</dd></div><div data-v-aa4426a6><dt data-v-aa4426a6>Home / End</dt><dd data-v-aa4426a6>Skip to start / end</dd></div><div data-v-aa4426a6><dt data-v-aa4426a6>[ / ]</dt><dd data-v-aa4426a6>Previous / next clip</dd></div><div data-v-aa4426a6><dt data-v-aa4426a6>S</dt><dd data-v-aa4426a6>Split at playhead</dd></div><div data-v-aa4426a6><dt data-v-aa4426a6>Delete</dt><dd data-v-aa4426a6>Delete selected clip</dd></div><div data-v-aa4426a6><dt data-v-aa4426a6>Shift + Delete</dt><dd data-v-aa4426a6>Ripple delete (closes the gap)</dd></div><div data-v-aa4426a6><dt data-v-aa4426a6>Cmd / Ctrl + Z</dt><dd data-v-aa4426a6>Undo</dd></div><div data-v-aa4426a6><dt data-v-aa4426a6>Cmd / Ctrl + Shift + Z</dt><dd data-v-aa4426a6>Redo</dd></div><div data-v-aa4426a6><dt data-v-aa4426a6>Cmd / Ctrl + S</dt><dd data-v-aa4426a6>Save draft</dd></div><div data-v-aa4426a6><dt data-v-aa4426a6>Cmd / Ctrl + E</dt><dd data-v-aa4426a6>Export</dd></div><div data-v-aa4426a6><dt data-v-aa4426a6>?</dt><dd data-v-aa4426a6>This overlay</dd></div></dl>',1))])])):e.createCommentVNode("",!0)],64))}}),Q4=Fe(Y4,[["__scopeId","data-v-aa4426a6"]]),Da=o=>o===null||typeof o!="object"||Array.isArray(o)?null:o,ct=o=>{if(typeof o=="number"&&Number.isFinite(o))return o;if(typeof o=="string"){const a=Number(o);return Number.isFinite(a)?a:null}return null},eB=(o,a)=>{if(a===null)return;const t=Da(o.source)??{},n=ct(t.duration);if(!(n!==null&&n>0&&n<=1&&a>n))return;t.duration=a,o.source=t;const r=Array.isArray(o.timeline)?o.timeline:[];if(r.length===1){const d=Da(r[0]);if(d!==null){const c=ct(d.sourceIn)??0,u=ct(d.sourceOut)??ct(d.end)??ct(d.timelineEnd);if(c===0&&u!==null&&u>0&&u<=1){d.sourceOut=a;const m=ct(d.end);m!==null&&m>0&&m<=1&&(d.end=a);const p=ct(d.timelineEnd);p!==null&&p>0&&p<=1&&(d.timelineEnd=a)}}}const s=ct(o.trimEnd)??ct(o.trim_end);s!==null&&s>0&&s<=1&&(o.trimEnd=a);const l=Da(o.trim);if(l!==null){const d=ct(l.end);d!==null&&d>0&&d<=1&&(l.end=a,o.trim=l)}},tB=(o,a)=>{if(!o)return!1;const t=Da(o);if(t===null)return!1;const n=Da(t.trim),i=Da(t.source),s=ct(i==null?void 0:i.duration)??a,l=Array.isArray(o.filters)&&o.filters.length>0;let d=!1;if(Array.isArray(o.timeline)&&o.timeline.length===1){const p=o.timeline[0];p&&Array.isArray(p.filters)&&p.filters.length>0&&(d=!0)}let c=!1;const u=ct(t.trimStart)??ct(t.trim_start)??ct(n==null?void 0:n.start),f=ct(t.trimEnd)??ct(t.trim_end)??ct(n==null?void 0:n.end);if(u!==null&&u>0&&(c=!0),f!==null&&s!==void 0&&f<s&&(c=!0),!c&&Array.isArray(o.timeline)&&o.timeline.length===1){const p=o.timeline[0];if(p){const h=ct(p.sourceIn),v=ct(p.sourceOut);h!==null&&h>0&&(c=!0),v!==null&&s!==void 0&&v<s&&(c=!0)}}let m=!1;if(Array.isArray(o.timeline)&&o.timeline.length===1){const p=o.timeline[0];if(p){const h=ct(p.speed);m=h!==null&&h!==1}}return l||d||c||m},zp=o=>{if(!o)return!1;const a=Da(o);return a===null?!1:!!(Array.isArray(a.textOverlays)&&a.textOverlays.length>0||Array.isArray(a.transitions)&&a.transitions.length>0||Array.isArray(o.timeline)&&o.timeline.length>1)},aB=(o,a={})=>{var m,p;const t=JSON.parse(JSON.stringify(o)),n=Array.isArray(t.timeline)?t.timeline:[],i=n.length>0?Da(n[0]):null,r=Array.isArray(i==null?void 0:i.filters)?i.filters:[],s=Array.isArray(t.filters)?t.filters:[];if(s.length>0?t.filters=s:t.filters=r,n.length===1&&i!==null){const h=ct(i.sourceIn),v=ct(i.sourceOut);h!==null&&t.trimStart===void 0&&(t.trimStart=h),v!==null&&t.trimEnd===void 0&&(t.trimEnd=v)}const l=Da(t.trim);if(t.trimStart===void 0){const h=ct(l==null?void 0:l.start);h!==null&&(t.trimStart=h)}if(t.trimEnd===void 0){const h=ct(l==null?void 0:l.end);h!==null&&(t.trimEnd=h)}const d=Da(t.source),c=ct(t.width)??ct(d==null?void 0:d.original_width)??ct((m=a.exportMeta)==null?void 0:m.width);c!==null&&(t.width=c);const u=ct(t.height)??ct(d==null?void 0:d.original_height)??ct((p=a.exportMeta)==null?void 0:p.height);u!==null&&(t.height=u);const f=Da(t.output);return t.fps=ct(t.fps)??ct(f==null?void 0:f.fps)??30,eB(t,a.mediaDuration??null),t},nB={key:0},oB=["data-testid"],iB={class:"ve-mobile-header"},rB=["data-testid"],sB={class:"ve-mobile-title"},lB=["data-testid","disabled"],dB={key:1,class:"ve-mobile-spacer","aria-hidden":"true"},cB={class:"ve-body"},uB=["data-testid"],mB=["aria-label"],pB={class:"ve-header"},fB={class:"ve-title"},hB=["data-testid"],vB={class:"ve-body"},gB={class:"ve-footer"},bB=["data-testid"],yB=["data-testid","disabled"],wB=e.defineComponent({__name:"VideoEditorDialog",props:{open:{type:Boolean,default:!0},mediaUuid:{},initialRecipe:{},media:{},showThumbnailPicker:{type:Boolean,default:!1},title:{default:"Edit Video"},workflowMode:{default:"full"},featureFlags:{},clientExportThreshold:{default:20},maxDuration:{default:300},serverRenderEndpoint:{default:null},saveImmediate:{type:Boolean,default:!0},confirmText:{default:"Save"},savingText:{default:"Rendering..."},closeText:{default:"Cancel"},dataTestId:{default:"video-editor-dialog"},editorVersion:{}},emits:["update:open","close","recipe-generated","export-started","draft-saved","thumbnail-selected","video-exported","save-recipe","save-started","save-complete","save-error"],setup(o,{expose:a,emit:t}){const n=o,i=t,r=e.computed(()=>n.dataTestId),s=e.computed(()=>n.open),l=e.computed(()=>n.saveImmediate===!1),d=e.computed(()=>n.closeText),c=e.computed(()=>f.value?n.savingText:n.confirmText),u=e.ref(typeof window<"u"?window.innerWidth<768:!1),f=e.ref(!1),m=e.ref(!1),p=e.ref(null),h=`temp-${Date.now()}`,v=e.computed(()=>{var B;const W=(B=n.featureFlags)==null?void 0:B.export;return typeof W=="boolean"?W:n.workflowMode==="full"}),w=e.computed(()=>{if(n.editorVersion==="v1"||n.editorVersion==="v2")return n.editorVersion;if(typeof window>"u")return"v2";try{const W=new URLSearchParams(window.location.search),B=W.get("editor")??W.get("video-editor");if(B==="v1")return"v1";if(B==="v2")return"v2"}catch{}return"v2"}),E=e.computed(()=>w.value==="v2"?Q4:Pp),S=e.computed(()=>typeof n.mediaUuid=="string"&&n.mediaUuid.trim()!==""?n.mediaUuid.trim():n.media&&n.media.uuid.trim()!==""?n.media.uuid.trim():h),k=e.computed(()=>{const W={showThumbnailPicker:n.showThumbnailPicker,workflowMode:n.workflowMode,clientExportThreshold:n.clientExportThreshold,maxDuration:n.maxDuration,serverRenderEndpoint:n.serverRenderEndpoint};return n.featureFlags!==void 0&&(W.featureFlags=n.featureFlags),n.initialRecipe!==void 0&&(W.initialRecipe=n.initialRecipe),n.media!==void 0&&(W.media=n.media),W}),b=()=>{u.value=window.innerWidth<768};e.onMounted(()=>{window.addEventListener("resize",b)}),e.onUnmounted(()=>{window.removeEventListener("resize",b)}),e.onErrorCaptured(()=>(m.value=!0,!1));const $=W=>{const B=Array.isArray(W.timeline)?W.timeline:[];if(B.length===0)return 0;let P=0;for(const X of B){const K=Number(X.sourceIn),be=Number(X.sourceOut),Ne=Number(X.speed??1),ue=Number.isFinite(Ne)&&Ne>0?Ne:1;if(Number.isFinite(K)&&Number.isFinite(be)&&be>K){P+=(be-K)/ue;continue}const re=Number(X.timelineStart),O=Number(X.timelineEnd);Number.isFinite(re)&&Number.isFinite(O)&&O>re&&(P+=O-re)}return P},V=(W,B,P)=>{let X=null;const K=new Promise((be,Ne)=>{X=setTimeout(()=>Ne(new Error(`${P} timed out after ${B}ms`)),B)});return Promise.race([W,K]).finally(()=>{X!==null&&clearTimeout(X)})},I=()=>{var K;const P=(K=n.media)==null?void 0:K.duration;if(typeof P!="number"||!Number.isFinite(P)||P<=0)return 12e3;const X=Math.round(P*1e3);return Math.min(45e3,Math.max(12e3,X))},x=()=>{i("close"),i("update:open",!1)},N=()=>{f.value=!1,x()},L=W=>{i("recipe-generated",W)},C=W=>{i("export-started",W),i("save-started",W)},T=W=>{i("video-exported",W)},y=W=>{i("thumbnail-selected",W)},R=(W,B,P)=>{i("save-recipe",W);const X={recipe:W,exportPayload:B};P!==void 0&&(X.toastDescription=P),i("save-complete",X),x()},U=W=>{f.value||(i("draft-saved",W),R(W,null))},z=async()=>{var W;if(!f.value){if(m.value||p.value===null){i("save-error",{code:"save-failed",message:"Unable to save video edits. Please try again."}),x();return}f.value=!0;try{const B=await V(p.value.saveDraft(),I(),"saveDraft");let P=null,X=!1,K;const be=$(B),Ne=be>0?be:((W=n.media)==null?void 0:W.duration)??0;if(v.value&&Ne>0&&Ne<=n.clientExportThreshold&&typeof p.value.exportForUpload=="function"){X=!0;const re=Math.min(9e4,Math.max(15e3,n.clientExportThreshold*2e3));try{P=await V(p.value.exportForUpload(B),re,"exportForUpload")}catch{P=null}}if(zp(B)&&P===null){i("save-error",{code:"unsupported-client-export-required",message:"These edits require in-browser export. Shorten the clip or remove text overlays, transitions, or extra clips and try again."});return}X&&P===null&&(K="Video edits saved. Final render will happen when you share."),R(B,P,K)}catch{i("save-error",{code:"save-failed",message:"Unable to save video edits. Please try again."}),x()}finally{f.value=!1}}};return a({saveDraft:z}),(W,B)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[s.value?(e.openBlock(),e.createElementBlock("div",nB,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"ve-fullscreen","data-testid":r.value},[e.createElementVNode("header",iB,[e.createElementVNode("button",{class:"ve-mobile-action",type:"button","data-testid":`${r.value}-close-button`,onClick:N},e.toDisplayString(d.value),9,rB),e.createElementVNode("h2",sB,e.toDisplayString(W.title),1),l.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"ve-mobile-action ve-mobile-action--primary",type:"button","data-testid":`${r.value}-confirm-button`,disabled:f.value,onClick:z},e.toDisplayString(c.value),9,lB)):(e.openBlock(),e.createElementBlock("span",dB))]),e.createElementVNode("section",cB,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(E.value),e.mergeProps({ref_key:"videoEditorRef",ref:p,"media-uuid":S.value,"data-editor-version":w.value},k.value,{onClose:N,onDraftSaved:U,onExportStarted:C,onRecipeGenerated:L,onThumbnailSelected:y,onVideoExported:T}),null,16,["media-uuid","data-editor-version"]))])],8,oB)):(e.openBlock(),e.createElementBlock("div",{key:1,class:"ve-overlay","data-testid":r.value,onClick:e.withModifiers(N,["self"])},[e.createElementVNode("div",{class:"ve-dialog",role:"dialog","aria-label":W.title,"aria-modal":"true"},[e.createElementVNode("header",pB,[e.createElementVNode("h2",fB,e.toDisplayString(W.title),1),e.createElementVNode("button",{class:"ve-close",type:"button","data-testid":`${r.value}-close-button`,"aria-label":"Close",onClick:N}," ✕ ",8,hB)]),e.createElementVNode("section",vB,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(E.value),e.mergeProps({ref_key:"videoEditorRef",ref:p,"media-uuid":S.value,"data-editor-version":w.value},k.value,{onClose:N,onDraftSaved:U,onExportStarted:C,onRecipeGenerated:L,onThumbnailSelected:y,onVideoExported:T}),null,16,["media-uuid","data-editor-version"]))]),e.createElementVNode("footer",gB,[e.renderSlot(W.$slots,"footer",{close:N,isSaving:f.value,save:z},()=>[e.createElementVNode("button",{class:"ve-btn",type:"button","data-testid":`${r.value}-cancel-button`,onClick:N},e.toDisplayString(d.value),9,bB),l.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"ve-btn ve-btn--primary",type:"button","data-testid":`${r.value}-confirm-button`,disabled:f.value,onClick:z},e.toDisplayString(c.value),9,yB)):e.createCommentVNode("",!0)],!0)])],8,mB)],8,uB))])):e.createCommentVNode("",!0)]))}}),kB=Fe(wB,[["__scopeId","data-v-3cc6e078"]]),_B={class:"video-editor-modal"},EB={class:"video-preview-container"},xB=["src"],SB={class:"video-overlay-controls"},CB=["aria-label"],VB={class:"time-display"},NB={class:"timeline-container"},TB={class:"clip-name"},BB={class:"timeline-time-labels"},IB={class:"tool-tabs"},MB=["onClick"],FB={class:"tool-panel"},$B={key:0,class:"trim-panel"},DB={class:"trim-controls"},RB={key:1,class:"filters-panel"},AB={class:"filter-grid"},LB=["onClick"],PB={key:2,class:"text-panel"},UB={key:3,class:"transitions-panel"},OB={class:"transition-grid"},zB=["onClick"],jB={class:"action-buttons"},WB=e.defineComponent({__name:"VideoEditorSimple",props:{media:{}},emits:["save","cancel"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(),r=e.ref(""),s=e.ref(!1),l=e.ref(0),d=e.ref(0),c=e.ref("video-1"),u=e.ref(0),f=e.ref(0),m=e.ref(null),p=e.ref("trim"),h=e.ref(null),v=e.ref(""),w=[{id:"trim",label:"Trim",icon:Tr},{id:"filters",label:"Filters",icon:Dh},{id:"text",label:"Text",icon:Xu},{id:"transitions",label:"Transitions",icon:jh}],E=[{id:"none",name:"None"},{id:"grayscale",name:"Grayscale"},{id:"sepia",name:"Sepia"},{id:"blur",name:"Blur"},{id:"brightness",name:"Brightness"},{id:"contrast",name:"Contrast"}],S=[{id:"fade",name:"Fade"},{id:"slide",name:"Slide"},{id:"zoom",name:"Zoom"},{id:"wipe",name:"Wipe"}],k=e.ref();e.onMounted(()=>{var B,P;(B=t.media)!=null&&B.url?r.value=t.media.url:(P=t.media)!=null&&P.file&&(r.value=URL.createObjectURL(t.media.file))}),e.onUnmounted(()=>{var B;(B=t.media)!=null&&B.file&&r.value&&URL.revokeObjectURL(r.value)});function b(){i.value&&(d.value=i.value.duration,f.value=d.value)}function $(){i.value&&(l.value=i.value.currentTime)}function V(){s.value=!1}function I(){i.value&&(s.value?(i.value.pause(),s.value=!1):(i.value.play(),s.value=!0))}function x(B){if(!B||isNaN(B))return"00:00";const P=Math.floor(B/60),X=Math.floor(B%60);return`${P.toString().padStart(2,"0")}:${X.toString().padStart(2,"0")}`}function N(B){if(!i.value||!k.value)return;const P=k.value.getBoundingClientRect(),be=(B.clientX-P.left)/P.width*d.value;i.value.currentTime=Math.max(0,Math.min(be,d.value))}function L(){u.value=l.value}function C(){f.value=l.value}function T(){u.value=0,f.value=d.value}function y(B){m.value=B;const P=K=>{if(!m.value||!k.value)return;const be=k.value.getBoundingClientRect(),re=(K.clientX-be.left)/be.width*d.value;m.value==="start"?u.value=Math.max(0,Math.min(re,f.value-1)):f.value=Math.max(u.value+1,Math.min(re,d.value))},X=()=>{m.value=null,document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",X)};document.addEventListener("mousemove",P),document.addEventListener("mouseup",X)}function R(B){if(h.value=B,!i.value)return;const P={none:"none",grayscale:"grayscale(100%)",sepia:"sepia(100%)",blur:"blur(5px)",brightness:"brightness(150%)",contrast:"contrast(150%)"};i.value.style.filter=P[B]||"none"}function U(){}function z(B){}function W(){const B={timeline:[{id:c.value,url:r.value,startTime:0,endTime:d.value,sourceIn:u.value,sourceOut:f.value,track:0}],filters:h.value?[{type:h.value}]:[],textOverlays:v.value?[{content:v.value}]:[],duration:f.value-u.value};n("save",B)}return(B,P)=>(e.openBlock(),e.createElementBlock("div",_B,[e.createElementVNode("div",EB,[e.createElementVNode("video",{ref_key:"videoElement",ref:i,class:"video-preview",src:r.value,onLoadedmetadata:b,onTimeupdate:$,onEnded:V,controls:""},null,40,xB),e.createElementVNode("div",SB,[e.createElementVNode("button",{class:"play-pause-btn",onClick:I,"aria-label":s.value?"Pause":"Play"},[e.createVNode(e.unref(H.IonIcon),{icon:s.value?e.unref(Gh):e.unref(qh)},null,8,["icon"])],8,CB),e.createElementVNode("div",VB,e.toDisplayString(x(l.value))+" / "+e.toDisplayString(x(d.value)),1)])]),e.createElementVNode("div",NB,[e.createElementVNode("div",{class:"timeline-track",onClick:N,ref_key:"timelineTrack",ref:k},[e.createElementVNode("div",{class:"timeline-clip",style:e.normalizeStyle({left:`${u.value/d.value*100}%`,right:`${100-f.value/d.value*100}%`})},[e.createElementVNode("span",TB,e.toDisplayString(c.value),1)],4),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:`${l.value/d.value*100}%`})},null,4),p.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:0,class:"trim-handle trim-start",style:e.normalizeStyle({left:`${u.value/d.value*100}%`}),onMousedown:P[0]||(P[0]=X=>y("start"))},null,36)):e.createCommentVNode("",!0),p.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:1,class:"trim-handle trim-end",style:e.normalizeStyle({left:`${f.value/d.value*100}%`}),onMousedown:P[1]||(P[1]=X=>y("end"))},null,36)):e.createCommentVNode("",!0)],512),e.createElementVNode("div",BB,[e.createElementVNode("span",null,e.toDisplayString(x(0)),1),e.createElementVNode("span",null,e.toDisplayString(x(d.value)),1)])]),e.createElementVNode("div",IB,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(w,X=>e.createElementVNode("button",{key:X.id,class:e.normalizeClass(["tool-tab",{active:p.value===X.id}]),onClick:K=>p.value=X.id},[e.createVNode(e.unref(H.IonIcon),{icon:X.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(X.label),1)],10,MB)),64))]),e.createElementVNode("div",FB,[p.value==="trim"?(e.openBlock(),e.createElementBlock("div",$B,[P[7]||(P[7]=e.createElementVNode("h3",null,"Trim Video",-1)),P[8]||(P[8]=e.createElementVNode("p",null,"Click and drag on the timeline to set trim points",-1)),e.createElementVNode("div",DB,[e.createElementVNode("button",{class:"btn-trim",onClick:L},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(nc)},null,8,["icon"]),P[4]||(P[4]=e.createTextVNode(" Set Start ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:C},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(nc)},null,8,["icon"]),P[5]||(P[5]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:T},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Gn)},null,8,["icon"]),P[6]||(P[6]=e.createTextVNode(" Clear ",-1))])])])):p.value==="filters"?(e.openBlock(),e.createElementBlock("div",RB,[P[9]||(P[9]=e.createElementVNode("h3",null,"Filters",-1)),e.createElementVNode("div",AB,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(E,X=>e.createElementVNode("button",{key:X.id,class:e.normalizeClass(["filter-option",{active:h.value===X.id}]),onClick:K=>R(X.id)},e.toDisplayString(X.name),11,LB)),64))])])):p.value==="text"?(e.openBlock(),e.createElementBlock("div",PB,[P[10]||(P[10]=e.createElementVNode("h3",null,"Text Overlay",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":P[2]||(P[2]=X=>v.value=X),type:"text",placeholder:"Enter text...",class:"text-input"},null,512),[[e.vModelText,v.value]]),e.createElementVNode("button",{class:"btn-add-text",onClick:U},"Add Text")])):p.value==="transitions"?(e.openBlock(),e.createElementBlock("div",UB,[P[11]||(P[11]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",OB,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(S,X=>e.createElementVNode("button",{key:X.id,class:"transition-option",onClick:K=>(X.id,void 0)},e.toDisplayString(X.name),9,zB)),64))])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",jB,[e.createElementVNode("button",{class:"btn-cancel",onClick:P[3]||(P[3]=X=>B.$emit("cancel"))},"CANCEL"),e.createElementVNode("button",{class:"btn-save",onClick:W},"SAVE")])]))}}),HB=Fe(WB,[["__scopeId","data-v-b933f33b"]]),ZB={class:"time-label"},GB=e.defineComponent({__name:"TimeRuler",props:{duration:{},zoom:{}},setup(o){const a=o,t=e.computed(()=>({width:`${a.duration*a.zoom*100}px`})),n=e.computed(()=>{const s=[],l=i(a.duration,a.zoom);for(let d=0;d<=a.duration;d+=l){const c=`${d/a.duration*100}%`,u=r(d),f=d%(l*5)===0;s.push({time:d,position:c,label:u,major:f})}return s});function i(s,l){const d=s/(10*l);return d<=1?1:d<=5?5:d<=10?10:d<=30?30:d<=60?60:Math.ceil(d/60)*60}function r(s){const l=Math.floor(s/60),d=Math.floor(s%60);return l===0?`${d}s`:d===0?`${l}m`:`${l}:${d.toString().padStart(2,"0")}`}return(s,l)=>(e.openBlock(),e.createElementBlock("div",{class:"time-ruler",style:e.normalizeStyle(t.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,d=>(e.openBlock(),e.createElementBlock("div",{key:d.time,class:"time-mark",style:e.normalizeStyle({left:d.position})},[e.createElementVNode("span",ZB,e.toDisplayString(d.label),1),e.createElementVNode("div",{class:e.normalizeClass(["time-tick",{major:d.major}])},null,2)],4))),128))],4))}}),XB=Fe(GB,[["__scopeId","data-v-0ef9c910"]]),KB=["data-track-index"],JB={class:"track-header"},qB={class:"track-label"},YB={class:"track-controls"},QB=["data-testid","aria-label"],eI=["data-testid","onMousedown","onClick"],tI={class:"clip-content"},aI={class:"clip-name"},nI={key:0,class:"clip-thumbnail"},oI=["src","alt"],iI=["onMousedown","aria-label"],rI=["onMousedown","aria-label"],sI=e.defineComponent({__name:"VideoTrack",props:{clips:{},trackIndex:{},zoom:{},duration:{}},emits:["clip-move","clip-trim","clip-select"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(null),r=e.ref(!1),s=e.ref(!1),l=e.ref(null),d=e.computed(()=>({width:`${t.duration*t.zoom*100}px`}));function c(w){const E=w.timelineEnd-w.timelineStart,S=w.timelineStart/t.duration*100,k=E/t.duration*100;return{left:`${S}%`,width:`${k}%`,backgroundColor:u(w)}}function u(w){const E=["#4A90E2","#7ED321","#F5A623","#BD10E0","#9013FE","#50E3C2","#B8E986","#F8E71C"],S=parseInt(w.id.replace(/\D/g,""))%E.length;return E[S]}function f(w){return w.label?w.label:w.url?(w.url.split("/").pop()||"Clip").split(".")[0]:`Clip ${w.id.slice(-4)}`}function m(w){i.value=w.id,n("clip-select",w.id)}function p(){r.value=!r.value}function h(w,E){if(l.value)return;s.value=!0;const S=E.clientX,k=w.timelineStart,b=V=>{if(!s.value)return;const I=V.clientX-S,x=parseFloat(d.value.width),N=I/(t.zoom*100)*(t.duration/x),L=Math.max(0,k+N);n("clip-move",w.id,L)},$=()=>{s.value=!1,document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",$)};document.addEventListener("mousemove",b),document.addEventListener("mouseup",$)}function v(w,E,S){l.value=E;const k=S.clientX,b=w.sourceIn,$=w.sourceOut,V=x=>{if(!l.value)return;const N=x.clientX-k,L=parseFloat(d.value.width),C=N/(t.zoom*100)*(t.duration/L);if(l.value==="start"){const T=Math.max(0,b+C);n("clip-trim",w.id,T,$)}else{const T=Math.max(b+1,$+C);n("clip-trim",w.id,b,T)}},I=()=>{l.value=null,document.removeEventListener("mousemove",V),document.removeEventListener("mouseup",I)};document.addEventListener("mousemove",V),document.addEventListener("mouseup",I)}return(w,E)=>(e.openBlock(),e.createElementBlock("div",{class:"video-track","data-track-index":w.trackIndex},[e.createElementVNode("div",JB,[e.createElementVNode("span",qB,"Track "+e.toDisplayString(w.trackIndex+1),1),e.createElementVNode("div",YB,[w.clips.length>0?(e.openBlock(),e.createElementBlock("button",{key:0,class:"track-btn","data-testid":`btn-mute-track-${w.trackIndex}`,"aria-label":`${r.value?"Unmute":"Mute"} track ${w.trackIndex+1}`,onClick:p},[e.createVNode(e.unref(H.IonIcon),{icon:r.value?e.unref(uv):e.unref(dv)},null,8,["icon"])],8,QB)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",{class:"track-timeline",style:e.normalizeStyle(d.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.clips,S=>(e.openBlock(),e.createElementBlock("div",{key:S.id,class:e.normalizeClass(["timeline-clip",{selected:S.id===i.value}]),style:e.normalizeStyle(c(S)),"data-testid":`clip-${S.id}`,onMousedown:k=>h(S,k),onClick:k=>m(S)},[e.createElementVNode("div",tI,[e.createElementVNode("span",aI,e.toDisplayString(f(S)),1),S.thumbnail?(e.openBlock(),e.createElementBlock("div",nI,[e.createElementVNode("img",{src:S.thumbnail,alt:f(S)},null,8,oI)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:e.withModifiers(k=>v(S,"start",k),["stop"]),"aria-label":`Trim start of ${f(S)}`},null,40,iI),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:e.withModifiers(k=>v(S,"end",k),["stop"]),"aria-label":`Trim end of ${f(S)}`},null,40,rI)],46,eI))),128))],4)],8,KB))}}),lI=Fe(sI,[["__scopeId","data-v-48e480d2"]]),dI={class:"video-timeline"},cI={class:"timeline-tracks"},uI=["aria-label","aria-valuenow","aria-valuemax"],mI={class:"timeline-controls"},pI={class:"zoom-level"},fI=e.defineComponent({__name:"VideoTimeline",props:{clips:{},duration:{},currentTime:{}},emits:["update:clips","seek","clip-move","clip-trim"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(1),r=e.ref(null),s=e.ref(!1),l=e.ref(),d=e.computed(()=>{const k=Math.max(0,...t.clips.map(b=>b.track||0));return Array(k+1).fill(null)}),c=e.computed(()=>`${t.currentTime/t.duration*100}%`);function u(k){return t.clips.filter(b=>(b.track||0)===k)}function f(k){const b=Math.floor(k/60),$=Math.floor(k%60);return`${b}:${$.toString().padStart(2,"0")}`}function m(k,b){n("clip-move",k,b)}function p(k,b,$){n("clip-trim",k,b,$)}function h(k){r.value=k}function v(){i.value=Math.min(i.value*1.2,5)}function w(){i.value=Math.max(i.value/1.2,.5)}function E(){s.value=!0;const k=$=>{if(!s.value||!l.value)return;const V=l.value.getBoundingClientRect(),N=Math.max(0,Math.min($.clientX-V.left,V.width))/V.width*t.duration;n("seek",N)},b=()=>{s.value=!1,document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",b)};document.addEventListener("mousemove",k),document.addEventListener("mouseup",b)}function S(k){let b=t.currentTime;switch(k.key){case"ArrowLeft":b=Math.max(0,t.currentTime-1);break;case"ArrowRight":b=Math.min(t.duration,t.currentTime+1);break;case"Home":b=0;break;case"End":b=t.duration;break;default:return}k.preventDefault(),n("seek",b)}return e.onMounted(()=>{l.value=document.querySelector(".video-timeline")}),e.onUnmounted(()=>{}),(k,b)=>(e.openBlock(),e.createElementBlock("div",dI,[e.createVNode(XB,{duration:k.duration,zoom:i.value},null,8,["duration","zoom"]),e.createElementVNode("div",cI,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,($,V)=>(e.openBlock(),e.createBlock(lI,{key:`track-${V}`,"data-testid":`track-${V}`,clips:u(V),"track-index":V,zoom:i.value,duration:k.duration,onClipMove:m,onClipTrim:p,onClipSelect:h},null,8,["data-testid","clips","track-index","zoom","duration"]))),128))]),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:c.value}),onMousedown:E,"data-testid":"playhead","aria-label":`Playhead at ${f(k.currentTime)}`,role:"slider","aria-valuenow":k.currentTime,"aria-valuemax":k.duration,tabindex:"0",onKeydown:S},null,44,uI),e.createElementVNode("div",mI,[e.createElementVNode("button",{"data-testid":"btn-zoom-in","aria-label":"Zoom in",onClick:v},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Kl)},null,8,["icon"])]),e.createElementVNode("span",pI,e.toDisplayString(Math.round(i.value*100))+"%",1),e.createElementVNode("button",{"data-testid":"btn-zoom-out","aria-label":"Zoom out",onClick:w},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(nv)},null,8,["icon"])])])]))}}),hI=Fe(fI,[["__scopeId","data-v-001df415"]]),vI={class:"video-filters-panel"},gI={class:"filter-controls"},bI=["for"],yI={class:"filter-slider-group"},wI=["id","onUpdate:modelValue","min","max","step","data-testid","aria-label","aria-valuenow","aria-valuemin","aria-valuemax","onInput"],kI={class:"filter-value"},_I={class:"filter-actions"},EI={key:0,class:"filter-presets"},xI={class:"preset-list"},SI=["data-testid","aria-label","onClick"],CI=e.defineComponent({__name:"VideoFiltersPanel",emits:["filter-change"],setup(o,{emit:a}){const t=a,n=[{type:"brightness",label:"Brightness",min:0,max:200,step:1,default:100},{type:"contrast",label:"Contrast",min:0,max:200,step:1,default:100},{type:"saturation",label:"Saturation",min:0,max:200,step:1,default:100},{type:"hue",label:"Hue",min:-180,max:180,step:1,default:0},{type:"blur",label:"Blur",min:0,max:10,step:.5,default:0},{type:"sharpen",label:"Sharpen",min:0,max:10,step:.5,default:0},{type:"sepia",label:"Sepia",min:0,max:100,step:1,default:0},{type:"grayscale",label:"Grayscale",min:0,max:100,step:1,default:0}],i=e.reactive(n.reduce((m,p)=>(m[p.type]=p.default,m),{})),r=e.ref([{id:"vintage",name:"Vintage",values:{brightness:110,contrast:120,saturation:80,sepia:30}},{id:"noir",name:"Film Noir",values:{brightness:90,contrast:130,grayscale:100}},{id:"vibrant",name:"Vibrant",values:{brightness:110,contrast:110,saturation:140}},{id:"dreamy",name:"Dreamy",values:{brightness:120,blur:2,saturation:90}}]);function s(m,p){switch(m){case"brightness":case"contrast":case"saturation":case"sepia":case"grayscale":return`${p}%`;case"hue":return`${p}°`;case"blur":case"sharpen":return p.toFixed(1);default:return p.toString()}}function l(m){return["brightness","contrast","saturation","hue","blur","sharpen","sepia","grayscale"].includes(m)}function d(m){if(!l(m))return;const p={id:`filter-${m}`,filterId:m,params:{value:i[m]},intensity:1};t("filter-change",p)}function c(){n.forEach(m=>{i[m.type]=m.default,d(m.type)})}function u(){const m=prompt("Enter preset name:");if(!m)return;const p={id:`custom-${Date.now()}`,name:m,values:{...i}};r.value.push(p)}function f(m){Object.entries(m.values).forEach(([p,h])=>{i[p]=h,d(p)})}return(m,p)=>(e.openBlock(),e.createElementBlock("div",vI,[p[3]||(p[3]=e.createElementVNode("h3",null,"Video Filters",-1)),e.createElementVNode("div",gI,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(n,h=>e.createElementVNode("div",{key:h.type,class:"filter-control"},[e.createElementVNode("label",{for:`filter-${h.type}`},e.toDisplayString(h.label),9,bI),e.createElementVNode("div",yI,[e.withDirectives(e.createElementVNode("input",{id:`filter-${h.type}`,"onUpdate:modelValue":v=>i[h.type]=v,type:"range",min:h.min,max:h.max,step:h.step,class:"filter-slider","data-testid":`filter-${h.type}`,"aria-label":`${h.label} filter`,"aria-valuenow":i[h.type],"aria-valuemin":h.min,"aria-valuemax":h.max,onInput:v=>d(h.type)},null,40,wI),[[e.vModelText,i[h.type],void 0,{number:!0}]]),e.createElementVNode("span",kI,e.toDisplayString(s(h.type,i[h.type])),1)])])),64))]),e.createElementVNode("div",_I,[e.createElementVNode("button",{class:"reset-filters-btn","data-testid":"btn-reset-filters","aria-label":"Reset all filters to default",onClick:c},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(eo)},null,8,["icon"]),p[0]||(p[0]=e.createTextVNode(" Reset All Filters ",-1))]),e.createElementVNode("button",{class:"save-preset-btn","data-testid":"btn-save-preset","aria-label":"Save current filter settings as preset",onClick:u},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Kr)},null,8,["icon"]),p[1]||(p[1]=e.createTextVNode(" Save as Preset ",-1))])]),r.value.length>0?(e.openBlock(),e.createElementBlock("div",EI,[p[2]||(p[2]=e.createElementVNode("h4",null,"Presets",-1)),e.createElementVNode("div",xI,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,h=>(e.openBlock(),e.createElementBlock("button",{key:h.id,class:"preset-btn","data-testid":`preset-${h.id}`,"aria-label":`Apply ${h.name} preset`,onClick:v=>f(h)},e.toDisplayString(h.name),9,SI))),128))])])):e.createCommentVNode("",!0)]))}}),VI=Fe(CI,[["__scopeId","data-v-5ad2ac63"]]),NI={class:"video-text-panel"},TI={class:"text-input-group"},BI={class:"text-options"},II={class:"option-row"},MI={class:"option-row"},FI={class:"option-row"},$I={class:"option-row"},DI={class:"checkbox-label"},RI={class:"option-row"},AI={class:"text-overlay-list"},LI={key:0,class:"empty-state"},PI=["data-testid"],UI={class:"overlay-preview"},OI={class:"overlay-controls"},zI=["data-testid","aria-label","onClick"],jI=["data-testid","aria-label","onClick"],WI=["data-testid","aria-label","onClick"],HI=e.defineComponent({__name:"VideoTextPanel",emits:["text-add","text-remove","text-update"],setup(o,{emit:a}){const t=a,n=e.ref([]),i=e.reactive({text:"",fontFamily:"Arial",fontSize:32,color:"#FFFFFF",backgroundColor:"#000000",hasBackground:!0,animation:"fade-in"});function r(){if(!i.text.trim())return;const c={id:`text-${Date.now()}`,text:i.text,x:50,y:50,fontSize:i.fontSize,fontFamily:i.fontFamily,color:i.color,startTime:0,opacity:1};i.hasBackground&&(c.backgroundColor=i.backgroundColor),i.animation!=="none"&&(c.animation=i.animation),n.value.push(c),t("text-add",c),i.text=""}function s(c){const u=n.value.findIndex(f=>f.id===c);u!==-1&&(n.value.splice(u,1),t("text-remove",c))}function l(c){i.text=c.text,i.fontFamily=c.fontFamily||"Arial",i.fontSize=c.fontSize,i.color=c.color,i.backgroundColor=c.backgroundColor||"#000000",i.hasBackground=!!c.backgroundColor,i.animation=c.animation||"none",s(c.id)}function d(c){const u={...c,id:`text-${Date.now()}`,x:c.x+10,y:c.y+10};n.value.push(u),t("text-add",u)}return(c,u)=>(e.openBlock(),e.createElementBlock("div",NI,[u[17]||(u[17]=e.createElementVNode("h3",null,"Text Overlays",-1)),e.createElementVNode("div",TI,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[0]||(u[0]=f=>i.text=f),type:"text",placeholder:"Enter text...",class:"text-input","data-testid":"input-text","aria-label":"Text overlay content",onKeyup:e.withKeys(r,["enter"])},null,544),[[e.vModelText,i.text]]),e.createElementVNode("button",{class:"add-text-btn","data-testid":"btn-add-text","aria-label":"Add text overlay",onClick:r},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Kl)},null,8,["icon"]),u[7]||(u[7]=e.createTextVNode(" Add ",-1))])]),e.createElementVNode("div",BI,[e.createElementVNode("div",II,[u[9]||(u[9]=e.createElementVNode("label",{for:"font-family"},"Font:",-1)),e.withDirectives(e.createElementVNode("select",{id:"font-family","onUpdate:modelValue":u[1]||(u[1]=f=>i.fontFamily=f),"data-testid":"select-font"},[...u[8]||(u[8]=[e.createStaticVNode('<option value="Arial" data-v-4d240e1e>Arial</option><option value="Helvetica" data-v-4d240e1e>Helvetica</option><option value="Times New Roman" data-v-4d240e1e>Times New Roman</option><option value="Georgia" data-v-4d240e1e>Georgia</option><option value="Courier New" data-v-4d240e1e>Courier New</option><option value="Impact" data-v-4d240e1e>Impact</option><option value="Comic Sans MS" data-v-4d240e1e>Comic Sans MS</option>',7)])],512),[[e.vModelSelect,i.fontFamily]])]),e.createElementVNode("div",MI,[u[10]||(u[10]=e.createElementVNode("label",{for:"font-size"},"Size:",-1)),e.withDirectives(e.createElementVNode("input",{id:"font-size","onUpdate:modelValue":u[2]||(u[2]=f=>i.fontSize=f),type:"number",min:"10",max:"200","data-testid":"input-font-size"},null,512),[[e.vModelText,i.fontSize,void 0,{number:!0}]])]),e.createElementVNode("div",FI,[u[11]||(u[11]=e.createElementVNode("label",{for:"text-color"},"Color:",-1)),e.withDirectives(e.createElementVNode("input",{id:"text-color","onUpdate:modelValue":u[3]||(u[3]=f=>i.color=f),type:"color","data-testid":"input-text-color"},null,512),[[e.vModelText,i.color]])]),e.createElementVNode("div",$I,[u[13]||(u[13]=e.createElementVNode("label",{for:"bg-color"},"Background:",-1)),e.withDirectives(e.createElementVNode("input",{id:"bg-color","onUpdate:modelValue":u[4]||(u[4]=f=>i.backgroundColor=f),type:"color","data-testid":"input-bg-color"},null,512),[[e.vModelText,i.backgroundColor]]),e.createElementVNode("label",DI,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[5]||(u[5]=f=>i.hasBackground=f),type:"checkbox","data-testid":"checkbox-bg"},null,512),[[e.vModelCheckbox,i.hasBackground]]),u[12]||(u[12]=e.createTextVNode(" Enable ",-1))])]),e.createElementVNode("div",RI,[u[15]||(u[15]=e.createElementVNode("label",{for:"text-animation"},"Animation:",-1)),e.withDirectives(e.createElementVNode("select",{id:"text-animation","onUpdate:modelValue":u[6]||(u[6]=f=>i.animation=f),"data-testid":"select-animation"},[...u[14]||(u[14]=[e.createStaticVNode('<option value="none" data-v-4d240e1e>None</option><option value="fade-in" data-v-4d240e1e>Fade In</option><option value="slide-left" data-v-4d240e1e>Slide from Left</option><option value="slide-right" data-v-4d240e1e>Slide from Right</option><option value="slide-up" data-v-4d240e1e>Slide from Bottom</option><option value="slide-down" data-v-4d240e1e>Slide from Top</option><option value="typewriter" data-v-4d240e1e>Typewriter</option><option value="bounce" data-v-4d240e1e>Bounce</option>',8)])],512),[[e.vModelSelect,i.animation]])])]),e.createElementVNode("div",AI,[u[16]||(u[16]=e.createElementVNode("h4",null,"Active Overlays",-1)),n.value.length===0?(e.openBlock(),e.createElementBlock("div",LI," No text overlays added yet ")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,(f,m)=>(e.openBlock(),e.createElementBlock("div",{key:f.id,class:"text-overlay-item","data-testid":`overlay-${m}`},[e.createElementVNode("div",UI,[e.createElementVNode("span",{style:e.normalizeStyle({fontFamily:f.fontFamily,fontSize:`${Math.min(f.fontSize/4,16)}px`,color:f.color})},e.toDisplayString(f.text),5)]),e.createElementVNode("div",OI,[e.createElementVNode("button",{class:"edit-btn","data-testid":`btn-edit-${m}`,"aria-label":`Edit overlay: ${f.text}`,onClick:p=>l(f)},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Ah)},null,8,["icon"])],8,zI),e.createElementVNode("button",{class:"duplicate-btn","data-testid":`btn-duplicate-${m}`,"aria-label":`Duplicate overlay: ${f.text}`,onClick:p=>d(f)},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(sl)},null,8,["icon"])],8,jI),e.createElementVNode("button",{class:"remove-btn","data-testid":`btn-remove-${m}`,"aria-label":`Remove overlay: ${f.text}`,onClick:p=>s(f.id)},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Br)},null,8,["icon"])],8,WI)])],8,PI))),128))])]))}}),ZI=Fe(HI,[["__scopeId","data-v-4d240e1e"]]),GI={class:"video-tools-panel"},XI={class:"tool-tabs"},KI=["data-testid","aria-label","aria-selected","onClick"],JI={class:"tool-content"},qI={key:0,class:"trim-panel",role:"tabpanel","aria-label":"Trim controls"},YI={class:"trim-actions"},QI={key:3,class:"transitions-panel",role:"tabpanel","aria-label":"Transition controls"},e3={class:"transition-types"},t3=["data-testid","aria-label","onClick"],a3={class:"transition-preview"},n3=e.defineComponent({__name:"VideoToolsPanel",props:{activeTool:{}},emits:["tool-change","filter-change","text-add","transition-add","trim-set-start","trim-set-end","trim-clear"],setup(o){const a=[{id:"trim",name:"Trim",icon:Tr},{id:"filters",name:"Filters",icon:kn},{id:"text",name:"Text",icon:Xu},{id:"transitions",name:"Transitions",icon:rc}],t=[{id:"fade",name:"Fade",icon:Ps},{id:"slide-left",name:"Slide Left",icon:Bh},{id:"slide-right",name:"Slide Right",icon:Ih},{id:"dissolve",name:"Dissolve",icon:Ps},{id:"wipe",name:"Wipe",icon:rc},{id:"zoom",name:"Zoom",icon:Ps}];return(n,i)=>(e.openBlock(),e.createElementBlock("div",GI,[e.createElementVNode("div",XI,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,r=>e.createElementVNode("button",{key:r.id,class:e.normalizeClass(["tool-tab",{active:n.activeTool===r.id}]),"data-testid":`tab-${r.id}`,"aria-label":`${r.name} tool`,"aria-selected":n.activeTool===r.id,role:"tab",onClick:s=>n.$emit("tool-change",r.id)},[e.createVNode(e.unref(H.IonIcon),{icon:r.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(r.name),1)],10,KI)),64))]),e.createElementVNode("div",JI,[n.activeTool==="trim"?(e.openBlock(),e.createElementBlock("div",qI,[i[8]||(i[8]=e.createElementVNode("h3",null,"Trim Video",-1)),i[9]||(i[9]=e.createElementVNode("p",null,"Click and drag on the timeline to set trim points",-1)),e.createElementVNode("div",YI,[e.createElementVNode("button",{class:"action-btn","data-testid":"btn-set-start","aria-label":"Set trim start at current position",onClick:i[0]||(i[0]=r=>n.$emit("trim-set-start"))},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(oc)},null,8,["icon"]),i[5]||(i[5]=e.createTextVNode(" Set Start ",-1))]),e.createElementVNode("button",{class:"action-btn","data-testid":"btn-set-end","aria-label":"Set trim end at current position",onClick:i[1]||(i[1]=r=>n.$emit("trim-set-end"))},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(oc)},null,8,["icon"]),i[6]||(i[6]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"action-btn","data-testid":"btn-clear-trim","aria-label":"Clear trim points",onClick:i[2]||(i[2]=r=>n.$emit("trim-clear"))},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Gn)},null,8,["icon"]),i[7]||(i[7]=e.createTextVNode(" Clear ",-1))])])])):e.createCommentVNode("",!0),n.activeTool==="filters"?(e.openBlock(),e.createBlock(VI,{key:1,onFilterChange:i[3]||(i[3]=r=>n.$emit("filter-change",r))})):e.createCommentVNode("",!0),n.activeTool==="text"?(e.openBlock(),e.createBlock(ZI,{key:2,onTextAdd:i[4]||(i[4]=r=>n.$emit("text-add",r))})):e.createCommentVNode("",!0),n.activeTool==="transitions"?(e.openBlock(),e.createElementBlock("div",QI,[i[10]||(i[10]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",e3,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(t,r=>e.createElementVNode("button",{key:r.id,class:"transition-btn","data-testid":`transition-${r.id}`,"aria-label":`Add ${r.name} transition`,onClick:s=>n.$emit("transition-add",r.id)},[e.createElementVNode("div",a3,[e.createVNode(e.unref(H.IonIcon),{icon:r.icon},null,8,["icon"])]),e.createElementVNode("span",null,e.toDisplayString(r.name),1)],8,t3)),64))])])):e.createCommentVNode("",!0)])]))}}),o3=Fe(n3,[["__scopeId","data-v-fc135306"]]),i3={class:"video-export-panel"},r3={class:"export-presets"},s3=["value"],l3={key:0,class:"preset-details"},d3={class:"detail-row"},c3={class:"detail-row"},u3={class:"detail-row"},m3={class:"advanced-options"},p3={class:"options-content"},f3={class:"option-group"},h3={class:"option-group"},v3={class:"option-group"},g3=["disabled"],b3={key:1,class:"export-progress"},y3={class:"progress-message"},w3={class:"progress-bar"},k3=["aria-valuenow"],_3={class:"progress-percentage"},E3=e.defineComponent({__name:"VideoExportPanel",props:{presets:{},isExporting:{type:Boolean},exportProgress:{}},emits:["export"],setup(o,{emit:a}){const t=o,n=a,i=e.ref("instagram-reel"),r=e.reactive({quality:"medium",bitrate:5,includeAudio:!0}),s=e.computed(()=>t.presets.find(c=>c.id===i.value)),l=e.computed(()=>t.exportProgress<10?"Initializing export...":t.exportProgress<30?"Processing video tracks...":t.exportProgress<50?"Applying filters and effects...":t.exportProgress<70?"Rendering frames...":t.exportProgress<90?"Encoding video...":t.exportProgress<100?"Finalizing export...":"Export complete!");function d(){s.value&&n("export",{...s.value,options:{...r}})}return(c,u)=>(e.openBlock(),e.createElementBlock("div",i3,[u[14]||(u[14]=e.createElementVNode("h3",null,"Export Video",-1)),e.createElementVNode("div",r3,[u[4]||(u[4]=e.createElementVNode("label",{for:"preset-select"},"Export Preset:",-1)),e.withDirectives(e.createElementVNode("select",{id:"preset-select","onUpdate:modelValue":u[0]||(u[0]=f=>i.value=f),"data-testid":"preset-select","aria-label":"Select export preset"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.presets,f=>(e.openBlock(),e.createElementBlock("option",{key:f.id,value:f.id},e.toDisplayString(f.name),9,s3))),128))],512),[[e.vModelSelect,i.value]])]),s.value?(e.openBlock(),e.createElementBlock("div",l3,[e.createElementVNode("div",d3,[u[5]||(u[5]=e.createElementVNode("span",null,"Resolution:",-1)),e.createElementVNode("span",null,e.toDisplayString(s.value.width)+"x"+e.toDisplayString(s.value.height),1)]),e.createElementVNode("div",c3,[u[6]||(u[6]=e.createElementVNode("span",null,"Frame Rate:",-1)),e.createElementVNode("span",null,e.toDisplayString(s.value.fps)+" fps",1)]),e.createElementVNode("div",u3,[u[7]||(u[7]=e.createElementVNode("span",null,"Format:",-1)),e.createElementVNode("span",null,e.toDisplayString(s.value.format.toUpperCase()),1)])])):e.createCommentVNode("",!0),e.createElementVNode("details",m3,[u[12]||(u[12]=e.createElementVNode("summary",null,"Advanced Options",-1)),e.createElementVNode("div",p3,[e.createElementVNode("div",f3,[u[9]||(u[9]=e.createElementVNode("label",{for:"quality-select"},"Quality:",-1)),e.withDirectives(e.createElementVNode("select",{id:"quality-select","onUpdate:modelValue":u[1]||(u[1]=f=>r.quality=f),"data-testid":"quality-select"},[...u[8]||(u[8]=[e.createElementVNode("option",{value:"low"},"Low (smaller file)",-1),e.createElementVNode("option",{value:"medium"},"Medium (balanced)",-1),e.createElementVNode("option",{value:"high"},"High (best quality)",-1)])],512),[[e.vModelSelect,r.quality]])]),e.createElementVNode("div",h3,[u[10]||(u[10]=e.createElementVNode("label",{for:"bitrate-input"},"Bitrate (Mbps):",-1)),e.withDirectives(e.createElementVNode("input",{id:"bitrate-input","onUpdate:modelValue":u[2]||(u[2]=f=>r.bitrate=f),type:"number",min:"1",max:"50","data-testid":"bitrate-input"},null,512),[[e.vModelText,r.bitrate,void 0,{number:!0}]])]),e.createElementVNode("div",v3,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[3]||(u[3]=f=>r.includeAudio=f),type:"checkbox","data-testid":"include-audio"},null,512),[[e.vModelCheckbox,r.includeAudio]]),u[11]||(u[11]=e.createTextVNode(" Include Audio ",-1))])])])]),e.createElementVNode("button",{class:"btn-export",disabled:c.isExporting||!s.value,"data-testid":"btn-start-export","aria-label":"Start video export",onClick:d},[c.isExporting?(e.openBlock(),e.createBlock(e.unref(H.IonSpinner),{key:0,name:"crescent"})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Co)},null,8,["icon"]),u[13]||(u[13]=e.createTextVNode(" Export Video ",-1))],64))],8,g3),c.isExporting?(e.openBlock(),e.createElementBlock("div",b3,[e.createElementVNode("div",y3,e.toDisplayString(l.value),1),e.createElementVNode("div",w3,[e.createElementVNode("div",{class:"progress-fill",style:e.normalizeStyle({width:`${c.exportProgress}%`}),role:"progressbar","aria-valuenow":c.exportProgress,"aria-valuemin":"0","aria-valuemax":"100"},null,12,k3)]),e.createElementVNode("div",_3,e.toDisplayString(c.exportProgress)+"% ",1)])):e.createCommentVNode("",!0)]))}}),x3=Fe(E3,[["__scopeId","data-v-5caf8fe6"]]),S3=["data-testid"],C3={class:"progress-header"},V3={class:"file-info"},N3={class:"file-details"},T3={class:"file-name"},B3={class:"file-meta"},I3={class:"file-size"},M3={key:0,class:"separator"},F3={key:1,class:"upload-speed"},$3={key:2,class:"separator"},D3={key:3,class:"time-remaining"},R3={class:"progress-actions"},A3={key:0,class:"status-icon completed","data-testid":"video-upload-status-completed"},L3={key:1,class:"status-icon error","data-testid":"video-upload-status-error"},P3={key:2,class:"status-icon processing","data-testid":"video-upload-status-processing",role:"status","aria-label":"Processing video"},U3=["aria-valuenow","aria-label"],O3={class:"progress-bar"},z3={class:"progress-percent"},j3={key:1,class:"error-message","data-testid":"video-upload-error"},W3={key:2,class:"thumbnail-preview","data-testid":"video-upload-thumbnail"},H3=["src","alt"],Z3={key:0,class:"video-duration"},G3=e.defineComponent({__name:"VideoUploadProgress",props:{upload:{}},emits:["cancel","retry","remove"],setup(o){const a=o,t=e.computed(()=>({"is-uploading":a.upload.status==="uploading","is-processing":a.upload.status==="processing","is-completed":a.upload.status==="completed","is-error":a.upload.status==="error","is-pending":a.upload.status==="pending"})),n=e.computed(()=>Ku),i=e.computed(()=>["uploading","processing"].includes(a.upload.status)),r=e.computed(()=>(a.upload.status==="processing",a.upload.progress||0)),s=e.computed(()=>{if(!a.upload.timeRemaining||a.upload.status!=="uploading")return null;const m=a.upload.timeRemaining;if(m<60)return`${Math.round(m)}s`;const p=Math.floor(m/60);return p<60?`${p}m ${Math.round(m%60)}s`:`${Math.floor(p/60)}h ${p%60}m`}),l=e.computed(()=>{var m;return a.upload.status==="completed"&&((m=a.upload.media)!=null&&m.thumbnail_url)?a.upload.media.thumbnail_url:null}),d=e.computed(()=>{var m;return(m=a.upload.media)==null?void 0:m.duration});function c(m){if(m===0)return"0 B";const p=["B","KB","MB","GB","TB"],h=1024,v=Math.floor(Math.log(m)/Math.log(h));return`${(m/Math.pow(h,v)).toFixed(1)} ${p[v]}`}function u(m){if(m===0)return"0 B/s";const p=["B/s","KB/s","MB/s","GB/s"],h=1024,v=Math.floor(Math.log(m)/Math.log(h));return`${(m/Math.pow(h,v)).toFixed(1)} ${p[v]}`}function f(m){const p=Math.floor(m/3600),h=Math.floor(m%3600/60),v=Math.floor(m%60);return p>0?`${p}:${h.toString().padStart(2,"0")}:${v.toString().padStart(2,"0")}`:`${h}:${v.toString().padStart(2,"0")}`}return(m,p)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["upload-progress-item",t.value]),"data-testid":`video-upload-progress-${m.upload.id}`},[e.createElementVNode("div",C3,[e.createElementVNode("div",V3,[e.createVNode(e.unref(H.IonIcon),{icon:n.value,class:"file-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("div",N3,[e.createElementVNode("h4",T3,e.toDisplayString(m.upload.filename),1),e.createElementVNode("p",B3,[e.createElementVNode("span",I3,e.toDisplayString(c(m.upload.bytesTotal||0)),1),m.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",M3,"•")):e.createCommentVNode("",!0),m.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",F3,e.toDisplayString(u(m.upload.uploadSpeed||0)),1)):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",$3,"•")):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",D3,e.toDisplayString(s.value)+" remaining ",1)):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",R3,[m.upload.status==="completed"?(e.openBlock(),e.createElementBlock("div",A3,[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Wu)},null,8,["icon"])])):m.upload.status==="error"?(e.openBlock(),e.createElementBlock("div",L3,[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Th),"aria-hidden":"true"},null,8,["icon"])])):m.upload.status==="processing"?(e.openBlock(),e.createElementBlock("div",P3,[e.createVNode(e.unref(H.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),m.upload.status==="uploading"?(e.openBlock(),e.createBlock(e.unref(H.IonButton),{key:3,fill:"clear",size:"small",onClick:p[0]||(p[0]=h=>m.$emit("cancel")),"data-testid":"btn-cancel-video-upload","aria-label":"Cancel upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Gn),slot:"icon-only"},null,8,["icon"])]),_:1})):m.upload.status==="error"?(e.openBlock(),e.createBlock(e.unref(H.IonButton),{key:4,fill:"clear",size:"small",onClick:p[1]||(p[1]=h=>m.$emit("retry")),"data-testid":"btn-retry-video-upload","aria-label":"Retry upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(eo),slot:"icon-only"},null,8,["icon"])]),_:1})):m.upload.status==="completed"?(e.openBlock(),e.createBlock(e.unref(H.IonButton),{key:5,fill:"clear",size:"small",onClick:p[2]||(p[2]=h=>m.$emit("remove")),"data-testid":"btn-remove-video-upload","aria-label":"Remove from list"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Gn),slot:"icon-only"},null,8,["icon"])]),_:1})):e.createCommentVNode("",!0)])]),i.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"progress-bar-container","data-testid":"video-upload-progress-bar",role:"progressbar","aria-valuenow":Math.round(r.value),"aria-valuemin":"0","aria-valuemax":"100","aria-label":m.upload.status==="processing"?"Processing progress":"Upload progress"},[e.createElementVNode("div",O3,[e.createElementVNode("div",{class:e.normalizeClass(["progress-fill",{indeterminate:m.upload.status==="processing"}]),style:e.normalizeStyle({width:r.value+"%"})},null,6)]),e.createElementVNode("span",z3,e.toDisplayString(Math.round(r.value))+"%",1)],8,U3)):e.createCommentVNode("",!0),m.upload.error?(e.openBlock(),e.createElementBlock("div",j3,[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(mv)},null,8,["icon"]),e.createElementVNode("span",null,e.toDisplayString(m.upload.error),1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",W3,[e.createElementVNode("img",{src:l.value,alt:m.upload.filename},null,8,H3),d.value?(e.openBlock(),e.createElementBlock("div",Z3,e.toDisplayString(f(d.value)),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],10,S3))}}),X3=Fe(G3,[["__scopeId","data-v-9eacbf91"]]),Qs=4,K3=500,J3=new Set([408,425,429,500,502,503,504,520,521,522,523,524,525]);function ws(o){return typeof o=="object"&&o!==null}function mu(o){return ws(o)?typeof o.upload_url=="string"&&typeof o.upload_id=="string"&&typeof o.media_uuid=="string"&&typeof o.expires_at=="string":!1}function q3(o){if(mu(o))return o;if(ws(o)&&mu(o.data))return o.data;throw new Error("Invalid upload response from backend")}function pu(o){return ws(o)?typeof o.uuid=="string"&&typeof o.processing_status=="string":!1}function Y3(o){if(pu(o))return o;if(ws(o)&&pu(o.data))return o.data;throw new Error("Invalid media response from backend")}function dr(o){return o?{...o}:{}}function fu(o,a="PUT"){return typeof o.method=="string"&&o.method.trim()!==""?o.method.trim().toUpperCase():a}function Q3(o){return o.resumable===!0?!0:/tusupload/i.test(o.upload_url)}function eM(o){if(typeof btoa=="function")try{return btoa(unescape(encodeURIComponent(o)))}catch{return btoa(o)}throw new Error("Base64 encoder is unavailable for TUS metadata")}function tM(o,a){return[["filename",o.filename],["filetype",o.file.type||"application/octet-stream"],["uploadid",a.upload_id],["mediauuid",a.media_uuid]].map(([n,i])=>`${n} ${eM(i)}`).join(",")}function cr(o,a){const t=Math.max(o.bytesTotal,1);o.bytesUploaded=a,o.progress=Math.min(100,a/t*100);const n=Math.max((Date.now()-o.startedAt.getTime())/1e3,.001);o.uploadSpeed=a/n;const i=Math.max(t-a,0);o.timeRemaining=i/Math.max(o.uploadSpeed,1)}function aM(o,a){return o instanceof Error?o:new Error(a)}function nM(o){if(!(o instanceof Error))return!1;const a=o.message.toLowerCase();return a.includes("failed to fetch")||a.includes("networkerror")||a.includes("network request failed")||a.includes("err_ssl_")}function hu(o){const a=Math.max(0,o-1),t=K3*Math.pow(2,a);return Math.min(5e3,t)}function vu(o){return new Promise(a=>{window.setTimeout(a,o)})}async function gu(o,a){for(let t=1;t<=Qs;t+=1)try{const n=await a();if(n.ok||!J3.has(n.status)||t>=Qs)return n;await vu(hu(t))}catch(n){if(!nM(n)||t>=Qs)throw n;await vu(hu(t))}throw new Error(`${o} failed after retry attempts`)}function oM(o={}){const a=e.ref(new Map),t=e.ref(new Set),n=e.ref(null),i=new Map,r=new Map,s=e.computed(()=>t.value.size>0),l=e.computed(()=>Array.from(a.value.values())),d=e.computed(()=>{const C=Array.from(a.value.values());return C.length===0?0:C.reduce((y,R)=>y+R.progress,0)/C.length});function c(C){n.value=C}function u(){}async function f(C){var y;const T=C.filter(R=>m(R));if(T.length!==0&&((y=o.onFilesSelected)==null||y.call(o,T),o.autoUpload!==!1))for(const R of T)await p(R)}function m(C){return!(o.maxFileSize&&C.size>o.maxFileSize||o.allowedFormats&&o.allowedFormats.length>0&&!o.allowedFormats.includes(C.type))}async function p(C){var R,U,z;const T=L(C);if(a.value.has(T)){const W=a.value.get(T);if((W==null?void 0:W.status)==="uploading")return}const y={id:T,file:C,filename:C.name,progress:0,status:"pending",startedAt:new Date,bytesTotal:C.size,bytesUploaded:0};a.value.set(y.id,y),t.value.add(y.id);try{y.status="uploading",(R=o.onUploadStart)==null||R.call(o,y);const W=await h(C);o.resumable===!0||W.resumable===!0?await w(y,W):await v(y,W),y.status="processing",y.progress=100;const P=await $(W.media_uuid);y.status="completed",y.media=P,(U=o.onUploadComplete)==null||U.call(o,P)}catch(W){if(y.status!=="cancelled"){const B=aM(W,"Upload failed");y.status="error",y.error=B.message,(z=o.onUploadError)==null||z.call(o,B,y)}}finally{t.value.delete(y.id),i.delete(y.id),r.delete(y.id)}}async function h(C){if(!n.value)throw new Error("API client not configured");const T={collection:o.collection||"videos",filename:C.name,size:C.size,mime_type:C.type,...o.ownerUuid!==void 0?{ownerUuid:o.ownerUuid}:{},...o.ownerType!==void 0?{ownerType:o.ownerType}:{}},y=await n.value.post("/api/v1/video/upload",T);return q3(y)}async function v(C,T){const y=new XMLHttpRequest,R=fu(T),U=dr(T.headers);return new Promise((z,W)=>{y.upload.addEventListener("progress",B=>{var P;B.lengthComputable&&(cr(C,B.loaded),(P=o.onUploadProgress)==null||P.call(o,C))}),y.addEventListener("load",()=>{i.delete(C.id),y.status>=200&&y.status<300?z():W(new Error(`Upload failed with status ${y.status}`))}),y.addEventListener("error",()=>{i.delete(C.id),W(new Error("Upload failed"))}),y.addEventListener("abort",()=>{i.delete(C.id),W(new Error("Upload cancelled"))}),y.open(R,T.upload_url),Object.entries(U).forEach(([B,P])=>{y.setRequestHeader(B,P)}),!Object.keys(U).some(B=>B.toLowerCase()==="content-type")&&C.file.type&&y.setRequestHeader("Content-Type",C.file.type),i.set(C.id,y),y.send(C.file)})}async function w(C,T){var W;if(Q3(T)){await E(C,T);return}const y=o.chunkSize||5*1024*1024,R=S(C.file,y),U=new AbortController;r.set(C.id,U);const z=await b(T.upload_id);z&&(R.forEach(B=>{B.end<=z.bytesUploaded&&(B.uploaded=!0)}),cr(C,z.bytesUploaded));for(const B of R)B.uploaded||(await k(C,T,B,U),cr(C,B.end),(W=o.onUploadProgress)==null||W.call(o,C))}async function E(C,T){var X;const y=new AbortController;r.set(C.id,y);const R={...dr(T.headers),"Tus-Resumable":"1.0.0","Upload-Length":String(C.file.size),"Upload-Metadata":tM(C,T)},U=await gu("Resumable upload initialization",()=>fetch(T.upload_url,{method:"POST",headers:R,signal:y.signal}));if(!U.ok)throw new Error(`Failed to initialize resumable upload: ${U.status}`);const z=U.headers.get("Location");if(!z)throw new Error("Resumable upload endpoint did not return upload location");const W=new URL(z,T.upload_url).toString(),B=o.chunkSize||5*1024*1024;let P=0;for(;P<C.file.size;){const K=Math.min(P+B,C.file.size),be=C.file.slice(P,K),Ne={...dr(T.headers),"Tus-Resumable":"1.0.0","Upload-Offset":String(P),"Content-Type":"application/offset+octet-stream"},ue=await gu("Resumable chunk upload",()=>fetch(W,{method:"PATCH",headers:Ne,body:be,signal:y.signal}));if(ue.status===409){const O=Number(ue.headers.get("Upload-Offset")??"-1");if(Number.isFinite(O)&&O>=0){P=O;continue}}if(!ue.ok)throw new Error(`Resumable chunk upload failed: ${ue.status}`);const re=Number(ue.headers.get("Upload-Offset")??String(K));P=Number.isFinite(re)&&re>P?re:K,cr(C,P),(X=o.onUploadProgress)==null||X.call(o,C)}}function S(C,T){const y=[];let R=0,U=0;for(;R<C.size;){const z=Math.min(R+T,C.size);y.push({start:R,end:z,blob:C.slice(R,z),index:U,uploaded:!1}),R=z,U++}return y}async function k(C,T,y,R){const U={...dr(T.headers),"Content-Range":`bytes ${y.start}-${y.end-1}/${C.file.size}`,"Content-Type":C.file.type||"application/octet-stream"},z=await fetch(T.upload_url,{method:fu(T),headers:U,body:y.blob,signal:R.signal});if(!z.ok)throw new Error(`Chunk upload failed: ${z.status}`);y.uploaded=!0}async function b(C){return null}async function $(C){if(!n.value)throw new Error("API client not configured");const T=60;let y=0;for(;y<T;){const R=await n.value.get(`/api/v1/video/${C}`),U=Y3(R),z=String(U.processing_status);if(z==="ready")return U;if(z==="failed"||z==="error")throw new Error("Video processing failed");await new Promise(W=>{window.setTimeout(W,5e3)}),y++}throw new Error("Video processing timeout")}function V(C){const T=a.value.get(C);if(!T)return;const y=i.get(C);y&&(y.abort(),i.delete(C));const R=r.get(C);R&&(R.abort(),r.delete(C)),T.status="cancelled",T.error="Upload cancelled",t.value.delete(C)}async function I(C){const T=a.value.get(C);T&&(T.status="pending",T.error="",T.progress=0,T.bytesUploaded=0,await p(T.file))}function x(C){a.value.delete(C),t.value.delete(C),i.delete(C),r.delete(C)}function N(){Array.from(a.value.entries()).forEach(([C,T])=>{T.status==="completed"&&a.value.delete(C)})}function L(C){return`${C.name}-${C.size}-${Date.now()}`}return{uploads:l,isUploading:s,totalProgress:d,openFilePicker:u,handleFileSelect:f,validateFile:m,startUpload:p,cancelUpload:V,retryUpload:I,removeUpload:x,clearCompleted:N,setApiClient:c}}const iM=["accept","multiple"],rM={key:0,class:"upload-trigger","data-testid":"video-uploader-trigger"},sM=["onKeydown"],lM={key:1,class:"upload-list","data-testid":"video-upload-list"},dM={class:"drag-content"},cM=e.defineComponent({__name:"VideoUploader",props:{collection:{default:"videos"},multiple:{type:Boolean,default:!1},maxFileSize:{default:5*1024*1024*1024},maxDuration:{},allowedFormats:{default:()=>["video/mp4","video/webm","video/quicktime","video/x-msvideo"]},autoUpload:{type:Boolean,default:!0},resumable:{type:Boolean,default:!0},label:{default:"Upload Video"},description:{default:"Click to select or drag and drop"},ownerUuid:{},ownerType:{},apiClient:{}},emits:["upload-start","upload-progress","upload-complete","upload-error","files-selected"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(),r=e.ref(!1),{uploads:s,isUploading:l,handleFileSelect:d,cancelUpload:c,retryUpload:u,removeUpload:f,setApiClient:m}=oM({collection:t.collection,...t.ownerUuid!==void 0?{ownerUuid:t.ownerUuid}:{},...t.ownerType!==void 0?{ownerType:t.ownerType}:{},maxFileSize:t.maxFileSize,...t.maxDuration!==void 0?{maxDuration:t.maxDuration}:{},allowedFormats:t.allowedFormats,autoUpload:t.autoUpload,resumable:t.resumable,onUploadStart:b=>n("upload-start",b),onUploadProgress:b=>n("upload-progress",b),onUploadComplete:b=>n("upload-complete",b),onUploadError:(b,$)=>n("upload-error",b,$),onFilesSelected:b=>n("files-selected",b)});t.apiClient&&m(t.apiClient);const p=e.computed(()=>t.allowedFormats.join(",")),h=e.computed(()=>t.multiple||s.value.length===0);function v(){i.value&&i.value.click()}function w(b){const $=b.target,V=Array.from($.files||[]);V.length>0&&(d(V),$.value="")}function E(b){var I;b.preventDefault(),r.value=!1;const V=Array.from(((I=b.dataTransfer)==null?void 0:I.files)||[]).filter(x=>x.type.startsWith("video/"));V.length>0&&d(V)}function S(b){var $;b.preventDefault(),($=b.dataTransfer)!=null&&$.types.includes("Files")&&(r.value=!0)}function k(b){b.target.closest(".video-uploader")||(r.value=!1)}return e.onMounted(()=>{document.addEventListener("dragover",S),document.addEventListener("dragleave",k),document.addEventListener("drop",b=>b.preventDefault())}),e.onUnmounted(()=>{document.removeEventListener("dragover",S),document.removeEventListener("dragleave",k),document.removeEventListener("drop",b=>b.preventDefault())}),(b,$)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-uploader",{"is-uploading":e.unref(l)}]),"data-testid":"video-uploader"},[e.createElementVNode("input",{ref_key:"fileInputEl",ref:i,type:"file",accept:p.value,multiple:b.multiple,onChange:w,"data-testid":"video-uploader-input","aria-label":"Select video files to upload",hidden:""},null,40,iM),!e.unref(l)||h.value?(e.openBlock(),e.createElementBlock("div",rM,[e.renderSlot(b.$slots,"trigger",{open:v},()=>[e.createElementVNode("div",{class:"default-upload-area","data-testid":"video-uploader-area",role:"button",tabindex:"0","aria-label":"Click to select video for upload",onClick:v,onKeydown:[e.withKeys(v,["enter"]),e.withKeys(e.withModifiers(v,["prevent"]),["space"])]},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Ku),class:"upload-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("h3",null,e.toDisplayString(b.label),1),e.createElementVNode("p",null,e.toDisplayString(b.description),1),e.createVNode(e.unref(H.IonButton),{size:"small","data-testid":"btn-select-video","aria-label":"Select video file"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Kl),slot:"start","aria-hidden":"true"},null,8,["icon"]),$[2]||($[2]=e.createTextVNode(" Select Video ",-1))]),_:1})],40,sM)],!0)])):e.createCommentVNode("",!0),e.unref(s).length>0?(e.openBlock(),e.createElementBlock("div",lM,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),V=>(e.openBlock(),e.createBlock(X3,{key:V.id,upload:V,onCancel:I=>e.unref(c)(V.id),onRetry:I=>e.unref(u)(V.id),onRemove:I=>e.unref(f)(V.id)},null,8,["upload","onCancel","onRetry","onRemove"]))),128))])):e.createCommentVNode("",!0),r.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:"drag-overlay","data-testid":"video-uploader-drag-overlay",onDrop:E,onDragover:$[0]||($[0]=e.withModifiers(()=>{},["prevent"])),onDragleave:$[1]||($[1]=V=>r.value=!1)},[e.createElementVNode("div",dM,[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Co),"aria-hidden":"true"},null,8,["icon"]),$[3]||($[3]=e.createElementVNode("p",null,"Drop video files here",-1))])],32)):e.createCommentVNode("",!0)],2))}}),uM=Fe(cM,[["__scopeId","data-v-ea7587f7"]]),mM=["aria-valuenow","aria-valuemax","aria-label"],pM={class:"progress-bar"},fM={class:"time-display","data-testid":"video-time-display"},hM={class:"current-time"},vM={class:"duration"},gM={class:"control-buttons"},bM={class:"controls-left"},yM=["aria-label"],wM={class:"controls-center"},kM={key:0,class:"volume-controls"},_M=["aria-label"],EM=["value"],xM={class:"controls-right"},SM={key:0,class:"quality-selector"},CM=["aria-expanded"],VM={class:"quality-label"},NM={key:0,class:"quality-menu","data-testid":"video-quality-menu",role:"menu"},TM=["data-testid","aria-label","onClick"],BM=["aria-label"],IM=e.defineComponent({__name:"VideoControls",props:{playing:{type:Boolean},currentTime:{},duration:{},buffered:{},volume:{default:100},muted:{type:Boolean,default:!1},fullscreen:{type:Boolean,default:!1},isLive:{type:Boolean,default:!1},qualityLevels:{default:()=>[]},currentQuality:{default:"Auto"}},emits:["play-pause","play","pause","seek","skip-forward","skip-backward","toggleMute","setVolume","toggleFullscreen","togglePiP","selectQuality"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(!0),r=e.ref(!1),s=e.ref(),l=H.isPlatform("mobile"),d="pictureInPictureEnabled"in document,c=e.computed(()=>({width:`${t.currentTime/t.duration*100}%`})),u=e.computed(()=>({left:`${t.currentTime/t.duration*100}%`})),f=e.computed(()=>{if(!t.buffered||t.buffered.length===0)return{width:"0%"};for(let b=0;b<t.buffered.length;b++){const $=t.buffered.start(b),V=t.buffered.end(b);if(t.currentTime>=$&&t.currentTime<=V)return{width:`${V/t.duration*100}%`}}return t.buffered.length>0?{width:`${t.buffered.end(0)/t.duration*100}%`}:{width:"0%"}}),m=e.computed(()=>t.muted||t.volume===0?cv:t.volume<33?sv:t.volume<66?lv:rv);let p=null;function h(){i.value=!0,v()}function v(){p&&clearTimeout(p),t.playing&&!l&&(p=setTimeout(()=>{i.value=!1},3e3))}function w(b){if(!s.value||t.isLive)return;const $=s.value.getBoundingClientRect(),I=(b.clientX-$.left)/$.width*t.duration;n("seek",Math.max(0,Math.min(I,t.duration)))}function E(b){const $=b.target;n("setVolume",parseInt($.value))}function S(b){n("selectQuality",b),r.value=!1}function k(b){if(!isFinite(b))return"0:00";const $=Math.floor(b/3600),V=Math.floor(b%3600/60),I=Math.floor(b%60);return $>0?`${$}:${V.toString().padStart(2,"0")}:${I.toString().padStart(2,"0")}`:`${V}:${I.toString().padStart(2,"0")}`}return e.onMounted(()=>{document.addEventListener("mousemove",h),v()}),e.onUnmounted(()=>{document.removeEventListener("mousemove",h),p&&clearTimeout(p)}),(b,$)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-controls",{"controls-visible":i.value}]),"data-testid":"video-controls"},[e.createElementVNode("div",{class:"progress-container","data-testid":"video-progress-bar",role:"slider","aria-valuenow":Math.round(b.currentTime),"aria-valuemin":"0","aria-valuemax":Math.round(b.duration),"aria-label":b.isLive?"Live stream":"Video progress",tabindex:"0",onClick:w},[e.createElementVNode("div",pM,[e.createElementVNode("div",{class:"progress-buffered",style:e.normalizeStyle(f.value)},null,4),e.createElementVNode("div",{class:"progress-played",style:e.normalizeStyle(c.value)},null,4),e.createElementVNode("div",{class:"progress-thumb",style:e.normalizeStyle(u.value)},null,4)]),e.createElementVNode("div",fM,[e.createElementVNode("span",hM,e.toDisplayString(k(b.currentTime)),1),$[7]||($[7]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",vM,e.toDisplayString(b.isLive?"LIVE":k(b.duration)),1)])],8,mM),e.createElementVNode("div",gM,[e.createElementVNode("div",bM,[e.createElementVNode("button",{class:"control-btn play-pause","data-testid":"btn-video-play-pause",onClick:$[0]||($[0]=V=>b.$emit("play-pause")),"aria-label":b.playing?"Pause":"Play"},[e.createVNode(e.unref(H.IonIcon),{icon:b.playing?e.unref(Zh):e.unref(Xh),"aria-hidden":"true"},null,8,["icon"])],8,yM),b.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"control-btn skip-backward","data-testid":"btn-video-skip-backward",onClick:$[1]||($[1]=V=>b.$emit("skip-backward")),"aria-label":"Skip backward 10 seconds"},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Kh),"aria-hidden":"true"},null,8,["icon"]),$[8]||($[8]=e.createElementVNode("span",{class:"skip-label"},"10",-1))])),b.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn skip-forward","data-testid":"btn-video-skip-forward",onClick:$[2]||($[2]=V=>b.$emit("skip-forward")),"aria-label":"Skip forward 10 seconds"},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Yh),"aria-hidden":"true"},null,8,["icon"]),$[9]||($[9]=e.createElementVNode("span",{class:"skip-label"},"10",-1))]))]),e.createElementVNode("div",wM,[e.unref(l)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",kM,[e.createElementVNode("button",{class:"control-btn mute-btn","data-testid":"btn-video-mute",onClick:$[3]||($[3]=V=>b.$emit("toggleMute")),"aria-label":b.muted?"Unmute":"Mute"},[e.createVNode(e.unref(H.IonIcon),{icon:m.value,"aria-hidden":"true"},null,8,["icon"])],8,_M),e.createElementVNode("input",{type:"range",class:"volume-slider","data-testid":"slider-video-volume",min:"0",max:"100",value:b.muted?0:b.volume,onInput:E,"aria-label":"Volume"},null,40,EM)]))]),e.createElementVNode("div",xM,[b.qualityLevels.length>1?(e.openBlock(),e.createElementBlock("div",SM,[e.createElementVNode("button",{class:"control-btn quality-btn","data-testid":"btn-video-quality",onClick:$[4]||($[4]=V=>r.value=!r.value),"aria-label":"Quality settings","aria-expanded":r.value},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(ov),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("span",VM,e.toDisplayString(b.currentQuality),1)],8,CM),r.value?(e.openBlock(),e.createElementBlock("div",NM,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.qualityLevels,V=>(e.openBlock(),e.createElementBlock("button",{key:V.label,class:e.normalizeClass(["quality-option",{active:V.label===b.currentQuality}]),"data-testid":`btn-video-quality-${V.label}`,"aria-label":`Set quality to ${V.label}`,role:"menuitem",onClick:I=>S(V)},e.toDisplayString(V.label),11,TM))),128))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),!e.unref(l)&&d?(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn pip-btn","data-testid":"btn-video-pip",onClick:$[5]||($[5]=V=>b.$emit("togglePiP")),"aria-label":"Picture in Picture"},[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(iv),"aria-hidden":"true"},null,8,["icon"])])):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"control-btn fullscreen-btn","data-testid":"btn-video-fullscreen",onClick:$[6]||($[6]=V=>b.$emit("toggleFullscreen")),"aria-label":b.fullscreen?"Exit fullscreen":"Enter fullscreen"},[e.createVNode(e.unref(H.IonIcon),{icon:b.fullscreen?e.unref(Rh):e.unref(Ph),"aria-hidden":"true"},null,8,["icon"])],8,BM)])])],2))}}),MM=Fe(IM,[["__scopeId","data-v-2ae77c13"]]);function FM(o={}){var be,Ne,ue;const a=e.ref(),t=e.ref(),n=e.ref(!1),i=e.ref(0),r=e.ref(0),s=e.ref(100),l=e.ref(o.muted||!1),d=e.ref(!1),c=e.ref(),u=e.ref(1),f=e.ref(!1),m=e.ref(null),p=e.ref("idle"),h=e.ref(o.playbackUrl||((be=o.media)==null?void 0:be.playback_url)||((Ne=o.media)==null?void 0:Ne.url)||""),v=e.ref(null),w=e.ref(o.isLive||!1),E=e.ref(null),S=e.ref(null);function k(re){S.value=re}if((ue=o.media)!=null&&ue.token_expires_at){const re=new Date(o.media.token_expires_at);v.value=Number.isNaN(re.getTime())?null:re}async function b(){var O;const re=w.value?t.value:a.value;if(re)try{await re.play(),n.value=!0,p.value=w.value?"live":"playing",(O=o.onPlay)==null||O.call(o)}catch{m.value="Failed to play video",p.value="error"}}function $(){var O;const re=w.value?t.value:a.value;re&&(re.pause(),n.value=!1,p.value="paused",(O=o.onPause)==null||O.call(o))}function V(){n.value?$():b()}function I(re){const O=w.value?t.value:a.value;if(!O||w.value)return;const D=Number.isFinite(O.duration)?O.duration:re;O.currentTime=Math.max(0,Math.min(re,D)),i.value=O.currentTime}function x(re=10){const O=a.value;!O||w.value||I(O.currentTime+re)}function N(re=10){const O=a.value;!O||w.value||I(O.currentTime-re)}function L(){const re=w.value?t.value:a.value;re&&(re.muted=!re.muted,l.value=re.muted)}function C(re){const O=w.value?t.value:a.value;if(!O)return;const D=Math.max(0,Math.min(100,re));O.volume=D/100,s.value=D,D>0&&O.muted&&(O.muted=!1,l.value=!1)}function T(re){const O=a.value;!O||w.value||(O.playbackRate=re,u.value=re)}async function y(){const re=document.querySelector(".video-player-container");if(re)try{document.fullscreenElement?(await document.exitFullscreen(),d.value=!1):(await re.requestFullscreen(),d.value=!0)}catch{}}async function R(){const re=w.value?t.value:a.value;if(re)try{document.pictureInPictureElement?await document.exitPictureInPicture():document.pictureInPictureEnabled&&await re.requestPictureInPicture()}catch{}}async function U(){var O;m.value=null,p.value="loading",(O=o.media)!=null&&O.provider&&o.media.provider!=="local"&&await z();const re=w.value?t.value:a.value;re&&(re.load(),await b())}async function z(){if(!(!S.value||!o.media))try{f.value=!0;const re=await S.value.get(`/api/v1/video/${o.media.uuid}/playback`);h.value=re.playback_url,v.value=new Date(re.token_expires_at);const O=w.value?t.value:a.value;if(O&&O.src!==h.value){const D=!O.paused,J=O.currentTime;O.src=h.value,w.value||(O.currentTime=J),D&&await b()}}catch{m.value="Failed to refresh playback token",p.value="error"}finally{f.value=!1}}async function W(re){if(t.value){if(t.value.canPlayType("application/vnd.apple.mpegurl")){t.value.src=re;return}try{t.value.src=re}catch{m.value="Live streaming not supported in this browser",p.value="error"}}}function B(){E.value&&(E.value.destroy(),E.value=null)}function P(){var O;const re=w.value?t.value:a.value;re&&(i.value=re.currentTime,r.value=re.duration,(O=o.onTimeUpdate)==null||O.call(o,re.currentTime))}const X=e.computed(()=>{if(!c.value||c.value.length===0||!r.value)return 0;for(let re=0;re<c.value.length;re++){const O=c.value.start(re),D=c.value.end(re);if(i.value>=O&&i.value<=D)return D/r.value*100}return 0});function K(){if(!v.value)return!1;const re=new Date;return v.value.getTime()-re.getTime()<5*60*1e3}return e.watch([a,t],([re,O])=>{const D=w.value?O:re;D&&(D.addEventListener("timeupdate",P),D.addEventListener("loadedmetadata",()=>{r.value=D.duration,p.value="ready"}),D.addEventListener("progress",()=>{c.value=D.buffered}),D.addEventListener("ended",()=>{var J;n.value=!1,p.value="ended",(J=o.onEnded)==null||J.call(o)}),D.addEventListener("error",J=>{var Z;p.value="error",(Z=o.onError)==null||Z.call(o,"Video playback error")}),D.volume=s.value/100,D.muted=l.value)}),e.onUnmounted(()=>{B();const re=w.value?t.value:a.value;re&&re.removeEventListener("timeupdate",P)}),{videoEl:a,liveVideoEl:t,playing:n,currentTime:i,duration:r,volume:s,muted:l,isFullscreen:d,bufferedRanges:c,bufferedPercent:X,playbackRate:u,isLoading:f,error:m,status:p,currentPlaybackUrl:h,tokenExpiresAt:v,play:b,pause:$,togglePlayPause:V,seek:I,skipForward:x,skipBackward:N,toggleMute:L,setVolume:C,setPlaybackRate:T,toggleFullscreen:y,togglePiP:R,retry:U,refreshToken:z,setupLiveStream:W,setApiClient:k,shouldRefreshToken:K}}const $M=["src","poster","controls","autoplay","muted","loop","preload"],DM={key:1,ref:"livePlayerEl",class:"live-player"},RM=["controls","muted"],AM={key:0,class:"live-indicator","data-testid":"video-live-indicator","aria-label":"Live stream"},LM={key:2,class:"video-loading","data-testid":"video-loading",role:"status","aria-label":"Loading video"},PM={key:3,class:"video-error","data-testid":"video-error",role:"alert"},UM={key:5,class:"gesture-zones","data-testid":"video-gesture-zones"},OM=e.defineComponent({__name:"VideoPlayer",props:{media:{},playbackUrl:{},apiClient:{},isLive:{type:Boolean,default:!1},controls:{type:Boolean,default:!0},autoplay:{type:Boolean,default:!1},muted:{type:Boolean,default:!1},loop:{type:Boolean,default:!1},poster:{},preload:{default:"metadata"},showCustomControls:{type:Boolean,default:!1},enableGestures:{type:Boolean,default:!0},className:{},crossorigin:{}},emits:["play","pause","ended","error","timeupdate","loadedmetadata","progress"],setup(o,{emit:a}){const t=o,n=a,{videoEl:i,liveVideoEl:r,playing:s,currentTime:l,duration:d,volume:c,muted:u,isFullscreen:f,bufferedRanges:m,isLoading:p,error:h,status:v,currentPlaybackUrl:w,tokenExpiresAt:E,play:S,pause:k,seek:b,toggleMute:$,setVolume:V,toggleFullscreen:I,togglePlayPause:x,skipForward:N,skipBackward:L,retry:C,refreshToken:T,setApiClient:y,shouldRefreshToken:R,setupLiveStream:U}=FM({...t.media!==void 0?{media:t.media}:{},...t.playbackUrl!==void 0?{playbackUrl:t.playbackUrl}:{},isLive:t.isLive??!1,autoplay:t.autoplay??!1,muted:t.muted??!1});async function z(){await T()}const W=e.computed(()=>{const Z=["video-player-container"];return t.className&&Z.push(t.className),f.value&&Z.push("fullscreen"),t.isLive&&Z.push("is-live"),s.value&&Z.push("is-playing"),p.value&&Z.push("is-loading"),Z}),B=e.computed(()=>{var Z,ie;if(t.poster)return t.poster;if((Z=t.media)!=null&&Z.poster_url)return t.media.poster_url;if((ie=t.media)!=null&&ie.thumbnail_url)return t.media.thumbnail_url});function P(Z){const ie=Z.target;n("loadedmetadata",{duration:ie.duration,width:ie.videoWidth,height:ie.videoHeight})}function X(Z){const ie=Z.target;l.value=ie.currentTime,n("timeupdate",ie.currentTime)}function K(){s.value=!0,n("play")}function be(){s.value=!1,n("pause")}function Ne(){s.value=!1,n("ended")}function ue(Z){const ie=Z.target;let se="Failed to load video";if(ie.error)switch(ie.error.code){case ie.error.MEDIA_ERR_ABORTED:se="Video playback aborted";break;case ie.error.MEDIA_ERR_NETWORK:se="Network error while loading video";break;case ie.error.MEDIA_ERR_DECODE:se="Video decoding error";break;case ie.error.MEDIA_ERR_SRC_NOT_SUPPORTED:se="Video format not supported";break}h.value=se,n("error",se)}function re(Z){const ie=Z.target;m.value=ie.buffered,n("progress",ie.buffered)}function O(){p.value=!0}function D(){p.value=!1}e.watch(()=>t.apiClient,Z=>{Z&&y(Z)},{immediate:!0}),e.watch(()=>t.playbackUrl,Z=>{typeof Z=="string"&&Z.length>0&&(w.value=Z)},{immediate:!0}),e.watch(()=>{var Z;return(Z=t.media)==null?void 0:Z.token_expires_at},Z=>{if(!Z){E.value=null;return}const ie=new Date(Z);E.value=Number.isNaN(ie.getTime())?null:ie},{immediate:!0}),e.watch(()=>{var Z;return(Z=t.media)==null?void 0:Z.playback_url},async(Z,ie)=>{if(t.playbackUrl||!Z||Z===ie)return;const se=i.value;if(!se||t.isLive){w.value=Z;return}const Ue=!se.paused,me=se.currentTime;w.value=Z,await e.nextTick();try{se.currentTime=me}catch{}Ue&&await S()},{immediate:!0});let J=null;return e.watch(()=>t.isLive,async Z=>{var se;if(!Z)return;const ie=t.playbackUrl||((se=t.media)==null?void 0:se.playback_url)||"";ie&&await U(ie)},{immediate:!0}),e.onMounted(()=>{var Z;(Z=t.media)!=null&&Z.provider&&t.media.provider!=="local"&&(J=setInterval(()=>{R()&&z()},3e4)),H.isPlatform("mobile")&&t.showCustomControls}),e.onUnmounted(()=>{J&&clearInterval(J)}),(Z,ie)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-player-container",W.value]),"data-testid":"video-player"},[Z.isLive?(e.openBlock(),e.createElementBlock("div",DM,[e.createElementVNode("video",{ref_key:"liveVideoEl",ref:r,controls:Z.controls&&!Z.showCustomControls,autoplay:!0,muted:e.unref(u),onPlay:K,onPause:be,onError:ue,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,RM),e.unref(v)==="live"?(e.openBlock(),e.createElementBlock("div",AM,[...ie[3]||(ie[3]=[e.createElementVNode("span",{class:"live-dot"},null,-1),e.createElementVNode("span",{class:"live-text"},"LIVE",-1)])])):e.createCommentVNode("",!0)],512)):(e.openBlock(),e.createElementBlock("video",{key:0,ref_key:"videoEl",ref:i,src:e.unref(w),poster:B.value,controls:Z.controls&&!Z.showCustomControls,autoplay:Z.autoplay,muted:e.unref(u),loop:Z.loop,preload:Z.preload,onLoadedmetadata:P,onTimeupdate:X,onPlay:K,onPause:be,onEnded:Ne,onError:ue,onProgress:re,onWaiting:O,onCanplay:D,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,$M)),e.unref(p)?(e.openBlock(),e.createElementBlock("div",LM,[e.createVNode(e.unref(H.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),e.unref(h)?(e.openBlock(),e.createElementBlock("div",PM,[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(Jl),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(e.unref(h)),1),e.createVNode(e.unref(H.IonButton),{size:"small",onClick:e.unref(C),"data-testid":"btn-video-retry","aria-label":"Retry loading video"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{icon:e.unref(eo),slot:"start","aria-hidden":"true"},null,8,["icon"]),ie[4]||(ie[4]=e.createTextVNode(" Retry ",-1))]),_:1},8,["onClick"])])):e.createCommentVNode("",!0),Z.showCustomControls&&!e.unref(h)?(e.openBlock(),e.createBlock(MM,{key:4,playing:e.unref(s),currentTime:e.unref(l),duration:e.unref(d),buffered:e.unref(m),volume:e.unref(c),muted:e.unref(u),fullscreen:e.unref(f),isLive:Z.isLive,onPlay:e.unref(S),onPause:e.unref(k),onSeek:e.unref(b),onToggleMute:e.unref($),onSetVolume:e.unref(V),onToggleFullscreen:e.unref(I),class:"custom-controls"},null,8,["playing","currentTime","duration","buffered","volume","muted","fullscreen","isLive","onPlay","onPause","onSeek","onToggleMute","onSetVolume","onToggleFullscreen"])):e.createCommentVNode("",!0),Z.enableGestures&&!e.unref(h)?(e.openBlock(),e.createElementBlock("div",UM,[e.createElementVNode("div",{class:"gesture-left","data-testid":"video-gesture-skip-back","aria-label":"Double tap to skip backward",onDblclick:ie[0]||(ie[0]=(...se)=>e.unref(L)&&e.unref(L)(...se))},null,32),e.createElementVNode("div",{class:"gesture-center","data-testid":"video-gesture-play-pause","aria-label":"Tap to play or pause",onClick:ie[1]||(ie[1]=(...se)=>e.unref(x)&&e.unref(x)(...se))}),e.createElementVNode("div",{class:"gesture-right","data-testid":"video-gesture-skip-forward","aria-label":"Double tap to skip forward",onDblclick:ie[2]||(ie[2]=(...se)=>e.unref(N)&&e.unref(N)(...se))},null,32)])):e.createCommentVNode("",!0)],2))}}),jp=Fe(OM,[["__scopeId","data-v-b8db4951"]]),zM=Xr.defineStore("video",()=>{const o=e.ref(new Map),a=e.ref(new Map),t=e.ref(new Map),n=e.ref(null),i=e.ref(!1),r=e.computed(()=>Array.from(o.value.values())),s=e.computed(()=>Array.from(a.value.values())),l=e.computed(()=>s.value.filter(U=>U.status==="live")),d=e.computed(()=>r.value.filter(U=>U.processing_status==="processing"));function c(U){o.value.set(U.uuid,U)}function u(U,z){const W=o.value.get(U);W&&o.value.set(U,{...W,...z})}function f(U){o.value.delete(U)}function m(U){return o.value.get(U)}function p(U){a.value.set(U.id,U)}function h(U,z){const W=a.value.get(U);W&&a.value.set(U,{...W,...z})}function v(U,z){const W=a.value.get(U);W&&a.value.set(U,{...W,status:z.status,viewer_count:z.viewer_count,peak_viewers:z.peak_viewers})}function w(U){a.value.delete(U)}function E(U){return a.value.get(U)}function S(U){return s.value.find(z=>z.media_uuid===U)}function k(U){t.value.set(U.id,U)}function b(U,z){const W=t.value.get(U);W&&t.value.set(U,{...W,...z})}function $(U){t.value.delete(U)}function V(U){return t.value.get(U)}function I(U){return Array.from(t.value.values()).filter(z=>z.media_uuid===U)}function x(U){n.value=U}function N(U){n.value&&(n.value={...n.value,...U})}function L(){n.value=null}function C(U){i.value=U}function T(){o.value.clear(),a.value.clear(),t.value.clear(),n.value=null,i.value=!1}function y(U){o.value.clear(),U.forEach(z=>{o.value.set(z.uuid,z)})}function R(U){a.value.clear(),U.forEach(z=>{a.value.set(z.id,z)})}return{videos:o,liveStreams:a,exportJobs:t,currentEditorState:n,isProcessing:i,allVideos:r,allLiveStreams:s,activeLiveStreams:l,processingVideos:d,setVideo:c,updateVideo:u,removeVideo:f,getVideo:m,setLiveStream:p,updateLiveStream:h,updateLiveStreamStats:v,removeLiveStream:w,getLiveStream:E,getLiveStreamByMedia:S,addExportJob:k,updateExportJob:b,removeExportJob:$,getExportJob:V,getExportJobsByMedia:I,setEditorState:x,updateEditorState:N,clearEditorState:L,setProcessing:C,clearAll:T,loadVideos:y,loadLiveStreams:R}});let Un=null;function jM(o){Un=o}const ur={post:async(o,a)=>{if(!Un)throw new Error("HTTP client not configured");return await Un(`/api/v1/video${o}`,{method:"POST",body:JSON.stringify(a),headers:{"Content-Type":"application/json"}})},get:async o=>{if(!Un)throw new Error("HTTP client not configured");return await Un(`/api/v1/video${o}`)},delete:async o=>{if(!Un)throw new Error("HTTP client not configured");return await Un(`/api/v1/video${o}`,{method:"DELETE"})}};function mr(o,a=null){const t=typeof o.id=="string"&&o.id!==""?o.id:typeof o.stream_id=="string"&&o.stream_id!==""?o.stream_id:a==null?void 0:a.id;if(!t)throw new Error("Invalid live stream response: missing stream id");const n={id:t,media_uuid:o.media_uuid??(a==null?void 0:a.media_uuid)??"",stream_key:o.stream_key??(a==null?void 0:a.stream_key)??"",rtmp_url:o.rtmp_url??(a==null?void 0:a.rtmp_url)??"",status:o.status??(a==null?void 0:a.status)??"idle",viewer_count:o.viewer_count??(a==null?void 0:a.viewer_count)??0,peak_viewers:o.peak_viewers??(a==null?void 0:a.peak_viewers)??0,auto_record:o.auto_record??(a==null?void 0:a.auto_record)??!0,low_latency:o.low_latency??(a==null?void 0:a.low_latency)??!1},i=o.playback_url??(a==null?void 0:a.playback_url);i!==void 0&&(n.playback_url=i);const r=o.started_at??(a==null?void 0:a.started_at);r!==void 0&&(n.started_at=r);const s=o.ended_at??(a==null?void 0:a.ended_at);return s!==void 0&&(n.ended_at=s),(a==null?void 0:a.metadata)!==void 0&&(n.metadata=a.metadata),(a==null?void 0:a.vod_media_uuid)!==void 0&&(n.vod_media_uuid=a.vod_media_uuid),n}function el(o,a){return o instanceof Error&&o.message?o.message:a}function WM(o){const a=zM(),t=e.ref(null),n=e.ref(!1),i=e.ref(!0),r=e.ref(""),s=e.ref(!1),l=e.ref(!1),d=e.ref(null),c=e.ref(null),u=e.ref(0),f=e.ref(0);let m;const p=e.computed(()=>c.value?Math.floor((new Date().getTime()-c.value.getTime())/1e3):0),h=e.computed(()=>{var L;if(!((L=t.value)!=null&&L.playback_url))return null;const N=new URL(t.value.playback_url);return N.searchParams.set("live","true"),n.value&&N.searchParams.set("latency","low"),N.toString()}),v=e.computed(()=>{var N;return((N=t.value)==null?void 0:N.status)==="live"}),w=e.computed(()=>{var N;return((N=t.value)==null?void 0:N.status)==="idle"}),E=e.computed(()=>{var N;return((N=t.value)==null?void 0:N.status)==="ended"});async function S(N={}){s.value=!0,d.value=null;try{const L=await ur.post("/live",{title:r.value||N.title||"Live Stream",low_latency:N.low_latency??n.value,auto_record:N.auto_record??i.value,...N}),C=mr(L);return t.value=C,a.setLiveStream(C),V(),C}catch(L){throw d.value=el(L,"Failed to create stream"),L instanceof Error?L:new Error(d.value)}finally{s.value=!1}}async function k(){if(!t.value)throw new Error("No active stream");l.value=!0,d.value=null;try{const N=await ur.post(`/live/${t.value.id}/end`),L=mr(N,t.value);return t.value=L,a.setLiveStream(L),I(),L}catch(N){throw d.value=el(N,"Failed to end stream"),N instanceof Error?N:new Error(d.value)}finally{l.value=!1}}async function b(){if(t.value)try{const N=await ur.get(`/live/${t.value.id}`),L=mr(N,t.value);u.value=L.viewer_count,f.value=L.peak_viewers,t.value=L;const C={status:L.status,viewer_count:L.viewer_count,peak_viewers:L.peak_viewers};L.started_at&&(C.started_at=L.started_at),L.ended_at&&(C.ended_at=L.ended_at),a.updateLiveStreamStats(L.id,C),L.status==="live"&&!c.value&&L.started_at&&(c.value=new Date(L.started_at)),L.status==="ended"&&I()}catch{}}async function $(N){try{const L=await ur.get(`/live/${N}`),C=mr(L,t.value);return{rtmp_url:C.rtmp_url,stream_key:C.stream_key,playback_url:C.playback_url||""}}catch(L){throw d.value=el(L,"Failed to get stream credentials"),L instanceof Error?L:new Error(d.value)}}function V(N=5e3){I(),m=window.setInterval(()=>{b()},N)}function I(){m!==void 0&&(clearInterval(m),m=void 0)}async function x(){if(!o)return;const N=a.getLiveStreamByMedia(o);N&&(t.value=N,u.value=N.viewer_count,f.value=N.peak_viewers,N.status==="live"&&(V(),N.started_at&&(c.value=new Date(N.started_at))))}return o&&x(),e.onUnmounted(()=>{I()}),{stream:t,lowLatency:n,autoRecord:i,streamTitle:r,isCreating:s,isEnding:l,error:d,streamDuration:p,viewerCount:u,peakViewers:f,playbackUrl:h,isLive:v,isIdle:w,hasEnded:E,createStream:S,endStream:k,refreshStreamStatus:b,getStreamCredentials:$,startStatusPolling:V,stopStatusPolling:I}}const HM={class:"stream-status"},ZM={class:"flex items-center justify-between"},GM={class:"flex items-center gap-3"},XM={key:0,class:"flex items-center"},KM={key:2,class:"text-sm text-gray-600"},JM={key:0,class:"flex items-center gap-2"},qM={class:"text-sm font-medium text-gray-700"},YM={key:0,class:"text-xs text-gray-500"},QM=e.defineComponent({__name:"StreamStatus",props:{status:{},viewers:{},peakViewers:{},duration:{}},setup(o){const a=o,t=e.computed(()=>({idle:"Ready to Stream",live:"Live",ended:"Stream Ended",error:"Error"})[a.status]||a.status),n=e.computed(()=>{const r="px-3 py-1 rounded-full text-xs font-semibold uppercase",s={idle:"bg-gray-100 text-gray-700",live:"bg-red-100 text-red-700",ended:"bg-blue-100 text-blue-700",error:"bg-yellow-100 text-yellow-700"};return`${r} ${s[a.status]||s.idle}`}),i=e.computed(()=>{if(!a.duration)return null;const r=Math.floor(a.duration/3600),s=Math.floor(a.duration%3600/60),l=a.duration%60;return r>0?`${r}:${s.toString().padStart(2,"0")}:${l.toString().padStart(2,"0")}`:`${s}:${l.toString().padStart(2,"0")}`});return(r,s)=>(e.openBlock(),e.createElementBlock("div",HM,[e.createElementVNode("div",ZM,[e.createElementVNode("div",GM,[r.status==="live"?(e.openBlock(),e.createElementBlock("div",XM,[...s[0]||(s[0]=[e.createElementVNode("span",{class:"relative flex h-3 w-3"},[e.createElementVNode("span",{class:"animate-ping absolute inline-flex h-full w-full rounded-full bg-red-400 opacity-75"}),e.createElementVNode("span",{class:"relative inline-flex rounded-full h-3 w-3 bg-red-500"})],-1),e.createElementVNode("span",{class:"ml-2 text-sm font-semibold text-red-600 uppercase"},"Live",-1)])])):(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(n.value)},e.toDisplayString(t.value),3)),i.value?(e.openBlock(),e.createElementBlock("div",KM,e.toDisplayString(i.value),1)):e.createCommentVNode("",!0)]),r.viewers!==void 0?(e.openBlock(),e.createElementBlock("div",JM,[s[1]||(s[1]=e.createElementVNode("svg",{class:"w-4 h-4 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20"},[e.createElementVNode("path",{d:"M10 12a2 2 0 100-4 2 2 0 000 4z"}),e.createElementVNode("path",{"fill-rule":"evenodd",d:"M.458 10C1.732 5.943 5.522 3 10 3s8.268 2.943 9.542 7c-1.274 4.057-5.064 7-9.542 7S1.732 14.057.458 10zM14 10a4 4 0 11-8 0 4 4 0 018 0z","clip-rule":"evenodd"})],-1)),e.createElementVNode("span",qM,e.toDisplayString(r.viewers)+" "+e.toDisplayString(r.viewers===1?"viewer":"viewers"),1),r.peakViewers>r.viewers?(e.openBlock(),e.createElementBlock("span",YM," (Peak: "+e.toDisplayString(r.peakViewers)+") ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])]))}}),e5=Fe(QM,[["__scopeId","data-v-1d09c19f"]]),t5={class:"stream-credentials"},a5={class:"space-y-3"},n5={class:"credential-field"},o5={class:"flex gap-2"},i5=["value"],r5={class:"credential-field"},s5={class:"flex gap-2"},l5=["value","type"],d5=["aria-label"],c5={key:0,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},u5={key:1,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},m5={key:0,class:"mt-2 text-sm text-green-600"},p5=e.defineComponent({__name:"StreamCredentials",props:{rtmpUrl:{},streamKey:{}},emits:["copy"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(!1),r=e.ref(""),s=e.computed(()=>{if(i.value)return t.streamKey;if(t.streamKey.length>8){const c=t.streamKey.slice(0,4),u=t.streamKey.slice(-4);return`${c}${"•".repeat(16)}${u}`}return"•".repeat(t.streamKey.length)});function l(){i.value=!i.value}async function d(c,u){try{await navigator.clipboard.writeText(c),r.value=u,n("copy",c,u),setTimeout(()=>{r.value=""},2e3)}catch{}}return(c,u)=>(e.openBlock(),e.createElementBlock("div",t5,[u[8]||(u[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Stream Settings",-1)),e.createElementVNode("div",a5,[e.createElementVNode("div",n5,[u[3]||(u[3]=e.createElementVNode("label",{class:"block text-xs font-medium text-gray-500 mb-1"},"RTMP Server URL",-1)),e.createElementVNode("div",o5,[e.createElementVNode("input",{value:c.rtmpUrl,readonly:"",type:"text",class:"flex-1 px-3 py-2 bg-gray-50 border border-gray-200 rounded-md text-sm font-mono text-gray-700","aria-label":"RTMP server URL"},null,8,i5),e.createElementVNode("button",{onClick:u[0]||(u[0]=f=>d(c.rtmpUrl,"RTMP URL")),class:"px-3 py-2 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors","aria-label":"Copy RTMP URL"},[...u[2]||(u[2]=[e.createElementVNode("svg",{class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})],-1)])])])]),e.createElementVNode("div",r5,[u[7]||(u[7]=e.createElementVNode("label",{class:"block text-xs font-medium text-gray-500 mb-1"},"Stream Key",-1)),e.createElementVNode("div",s5,[e.createElementVNode("input",{value:s.value,readonly:"",type:i.value?"text":"password",class:"flex-1 px-3 py-2 bg-gray-50 border border-gray-200 rounded-md text-sm font-mono text-gray-700","aria-label":"Stream key"},null,8,l5),e.createElementVNode("button",{onClick:l,class:"px-3 py-2 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors","aria-label":i.value?"Hide stream key":"Show stream key"},[i.value?(e.openBlock(),e.createElementBlock("svg",u5,[...u[5]||(u[5]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",c5,[...u[4]||(u[4]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},null,-1),e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"},null,-1)])]))],8,d5),e.createElementVNode("button",{onClick:u[1]||(u[1]=f=>d(c.streamKey,"Stream Key")),class:"px-3 py-2 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors","aria-label":"Copy stream key"},[...u[6]||(u[6]=[e.createElementVNode("svg",{class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})],-1)])])])])]),u[9]||(u[9]=e.createElementVNode("details",{class:"mt-4"},[e.createElementVNode("summary",{class:"cursor-pointer text-sm text-blue-600 hover:text-blue-700"}," How to connect with OBS Studio "),e.createElementVNode("div",{class:"mt-2 p-3 bg-blue-50 rounded-md text-sm text-gray-700"},[e.createElementVNode("ol",{class:"list-decimal list-inside space-y-1"},[e.createElementVNode("li",null,"Open OBS Studio"),e.createElementVNode("li",null,"Go to Settings → Stream"),e.createElementVNode("li",null,'Set Service to "Custom"'),e.createElementVNode("li",null,'Paste the RTMP URL in "Server"'),e.createElementVNode("li",null,'Paste the Stream Key in "Stream Key"'),e.createElementVNode("li",null,'Click OK and then "Start Streaming"')])])],-1)),e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[r.value?(e.openBlock(),e.createElementBlock("div",m5,e.toDisplayString(r.value)+" copied to clipboard! ",1)):e.createCommentVNode("",!0)]),_:1})]))}}),f5=Fe(p5,[["__scopeId","data-v-306d92f6"]]),h5={class:"live-stream-manager","data-testid":"live-stream-manager"},v5={key:0,class:"stream-setup"},g5={class:"space-y-4"},b5={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},y5={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},w5=["disabled"],k5={key:0},_5={key:1,class:"flex items-center justify-center"},E5={key:1,class:"stream-active space-y-6"},x5={key:1,class:"video-preview"},S5={key:2,class:"analytics-panel"},C5={class:"grid grid-cols-2 gap-4"},V5={class:"bg-gray-50 p-3 rounded"},N5={class:"text-2xl font-bold text-gray-900"},T5={class:"bg-gray-50 p-3 rounded"},B5={class:"text-2xl font-bold text-gray-900"},I5={class:"stream-controls flex gap-3"},M5=["disabled"],F5={key:0},$5={key:1},D5={key:2,class:"mt-4 p-4 bg-red-50 border border-red-200 rounded-lg"},R5={class:"text-red-600 text-sm"},A5=e.defineComponent({__name:"LiveStreamManager",props:{mediaUuid:{},onStreamCreated:{type:Function},onStreamEnded:{type:Function},httpClient:{type:Function}},emits:["stream-created","stream-ended","error"],setup(o,{emit:a}){const t=o,n=a;t.httpClient&&jM(t.httpClient);const{stream:i,lowLatency:r,autoRecord:s,streamTitle:l,isCreating:d,isEnding:c,error:u,createStream:f,endStream:m,streamDuration:p,playbackUrl:h,refreshStreamStatus:v}=WM(t.mediaUuid),w=e.ref(!1);async function E(){var V;try{const I=await f({title:l.value,low_latency:r.value,auto_record:s.value});n("stream-created",I),(V=t.onStreamCreated)==null||V.call(t,I)}catch(I){n("error",I)}}async function S(){var V;try{const I=await m();n("stream-ended",I),(V=t.onStreamEnded)==null||V.call(t,I)}catch(I){n("error",I)}}function k(){i.value=null,l.value="",w.value=!1,u.value=null}async function b(V,I){try{await navigator.clipboard.writeText(V)}catch{}}let $;return e.onMounted(()=>{var V;((V=i.value)==null?void 0:V.status)==="live"&&($=window.setInterval(()=>{v()},5e3))}),e.onUnmounted(()=>{$&&clearInterval($)}),(V,I)=>(e.openBlock(),e.createElementBlock("div",h5,[e.unref(i)?(e.openBlock(),e.createElementBlock("div",E5,[e.createVNode(e5,{status:e.unref(i).status,viewers:e.unref(i).viewer_count,duration:e.unref(p),"peak-viewers":e.unref(i).peak_viewers},null,8,["status","viewers","duration","peak-viewers"]),e.unref(i).status==="idle"?(e.openBlock(),e.createBlock(f5,{key:0,"rtmp-url":e.unref(i).rtmp_url,"stream-key":e.unref(i).stream_key,onCopy:b},null,8,["rtmp-url","stream-key"])):e.createCommentVNode("",!0),e.unref(h)?(e.openBlock(),e.createElementBlock("div",x5,[I[9]||(I[9]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-2"},"Live Preview",-1)),e.createVNode(jp,{"playback-url":e.unref(h),"is-live":!0,muted:!0,controls:!1,class:"w-full rounded-lg overflow-hidden"},null,8,["playback-url"])])):e.createCommentVNode("",!0),e.unref(i).status==="live"?(e.openBlock(),e.createElementBlock("div",S5,[I[12]||(I[12]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Live Analytics",-1)),e.createElementVNode("div",C5,[e.createElementVNode("div",V5,[e.createElementVNode("div",N5,e.toDisplayString(e.unref(i).viewer_count),1),I[10]||(I[10]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Current Viewers",-1))]),e.createElementVNode("div",T5,[e.createElementVNode("div",B5,e.toDisplayString(e.unref(i).peak_viewers),1),I[11]||(I[11]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Peak Viewers",-1))])])])):e.createCommentVNode("",!0),e.createElementVNode("div",I5,[e.unref(i).status==="idle"?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:I[3]||(I[3]=x=>w.value=!w.value),class:"flex-1 py-2 px-4 bg-gray-200 text-gray-700 font-medium rounded-lg hover:bg-gray-300 transition-colors"},e.toDisplayString(w.value?"Hide":"Show")+" Credentials ",1)):e.createCommentVNode("",!0),e.unref(i).status==="live"?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:S,disabled:e.unref(c),class:"flex-1 py-2 px-4 bg-red-600 text-white font-medium rounded-lg hover:bg-red-700 disabled:opacity-50 transition-colors","aria-label":"End live stream"},[e.unref(c)?(e.openBlock(),e.createElementBlock("span",$5,"Ending...")):(e.openBlock(),e.createElementBlock("span",F5,"End Stream"))],8,M5)):e.createCommentVNode("",!0),e.unref(i).status==="ended"?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:k,class:"flex-1 py-2 px-4 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 transition-colors"}," Start New Stream ")):e.createCommentVNode("",!0)])])):(e.openBlock(),e.createElementBlock("div",v5,[I[8]||(I[8]=e.createElementVNode("h3",{class:"text-lg font-semibold mb-4"},"Start Live Stream",-1)),e.createElementVNode("div",g5,[e.createElementVNode("div",b5,[I[4]||(I[4]=e.createElementVNode("div",{class:"flex-1"},[e.createElementVNode("label",{class:"font-medium text-gray-900"},"Low Latency Mode"),e.createElementVNode("p",{class:"text-sm text-gray-500 mt-1"}," 5-7 second delay (vs 15-20s standard) ")],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":I[0]||(I[0]=x=>e.isRef(r)?r.value=x:null),type:"checkbox",class:"h-5 w-5 text-blue-600 rounded focus:ring-blue-500","aria-label":"Enable low latency mode"},null,512),[[e.vModelCheckbox,e.unref(r)]])]),e.createElementVNode("div",y5,[I[5]||(I[5]=e.createElementVNode("div",{class:"flex-1"},[e.createElementVNode("label",{class:"font-medium text-gray-900"},"Auto-Record Stream"),e.createElementVNode("p",{class:"text-sm text-gray-500 mt-1"}," Save stream as VOD for later viewing ")],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":I[1]||(I[1]=x=>e.isRef(s)?s.value=x:null),type:"checkbox",class:"h-5 w-5 text-blue-600 rounded focus:ring-blue-500","aria-label":"Enable auto-recording"},null,512),[[e.vModelCheckbox,e.unref(s)]])]),e.createElementVNode("div",null,[I[6]||(I[6]=e.createElementVNode("label",{for:"stream-title",class:"block text-sm font-medium text-gray-700 mb-2"}," Stream Title (optional) ",-1)),e.withDirectives(e.createElementVNode("input",{id:"stream-title","onUpdate:modelValue":I[2]||(I[2]=x=>e.isRef(l)?l.value=x:null),type:"text",class:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"My Live Stream"},null,512),[[e.vModelText,e.unref(l)]])]),e.createElementVNode("button",{onClick:E,disabled:e.unref(d),class:"w-full py-3 px-4 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors","data-testid":"create-stream-button","aria-label":"Create live stream"},[e.unref(d)?(e.openBlock(),e.createElementBlock("span",_5,[...I[7]||(I[7]=[e.createElementVNode("svg",{class:"animate-spin h-5 w-5 mr-2",viewBox:"0 0 24 24"},[e.createElementVNode("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4",fill:"none"}),e.createElementVNode("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})],-1),e.createTextVNode(" Creating... ",-1)])])):(e.openBlock(),e.createElementBlock("span",k5,"Create Stream"))],8,w5)])])),e.unref(u)?(e.openBlock(),e.createElementBlock("div",D5,[e.createElementVNode("p",R5,e.toDisplayString(e.unref(u)),1)])):e.createCommentVNode("",!0)]))}}),L5=Fe(A5,[["__scopeId","data-v-26291f6f"]]),P5={class:"album-tree-node"},U5=["data-album-id","draggable","aria-selected","aria-expanded"],O5={key:1,class:"album-node__chevron-placeholder"},z5={key:2,"data-testid":"media-count",class:"album-node__count"},j5={key:0,class:"album-tree-node__children",role:"group"},W5=16,H5=e.defineComponent({__name:"AlbumTreeNode",props:{album:{},depth:{},selectedId:{},expandedIds:{},focusedId:{},draggable:{type:Boolean},showMediaCount:{type:Boolean},compact:{type:Boolean},dragState:{}},emits:["select","toggle-expand","drag-start","drag-over","drag-leave","drop"],setup(o,{emit:a}){const t=o,n=a,i=e.computed(()=>t.expandedIds.has(t.album.id)),r=e.computed(()=>t.selectedId===t.album.id),s=e.computed(()=>t.focusedId===t.album.id),l=e.computed(()=>t.album.children_count>0),d=e.computed(()=>`${t.depth*W5}px`),c=e.computed(()=>{var k;return((k=t.dragState)==null?void 0:k.draggedAlbumId)===t.album.id}),u=e.computed(()=>{var k;return((k=t.dragState)==null?void 0:k.dropTargetId)===t.album.id}),f=e.computed(()=>{var k;return(k=t.dragState)!=null&&k.draggedAlbumId?t.dragState.draggedAlbumId===t.album.id:!1}),m=e.computed(()=>{const k=["album-node"];return r.value&&k.push("album-node--selected"),s.value&&k.push("album-node--focused"),t.compact&&k.push("album-node--compact"),c.value&&k.push("album-node--dragging"),u.value&&k.push("album-node--drop-target"),f.value&&k.push("album-node--invalid-drop"),k});function p(){n("select",t.album)}function h(k){k.stopPropagation(),n("toggle-expand",t.album.id)}function v(k){t.draggable&&(k.dataTransfer&&(k.dataTransfer.setData("text/plain",t.album.id),k.dataTransfer.effectAllowed="move"),n("drag-start",t.album.id))}function w(k){t.draggable&&(k.preventDefault(),k.dataTransfer&&(k.dataTransfer.dropEffect="move"),n("drag-over",t.album.id))}function E(){n("drag-leave",t.album.id)}function S(k){t.draggable&&(k.preventDefault(),n("drop",t.album.id))}return(k,b)=>{var V;const $=e.resolveComponent("AlbumTreeNode",!0);return e.openBlock(),e.createElementBlock("div",P5,[e.createElementVNode("div",{"data-testid":"album-node","data-album-id":k.album.id,class:e.normalizeClass(m.value),style:e.normalizeStyle({paddingLeft:d.value}),draggable:k.draggable,role:"treeitem","aria-selected":r.value,"aria-expanded":l.value?i.value:void 0,onDragstart:v,onDragover:w,onDragleave:E,onDrop:S},[l.value?(e.openBlock(),e.createElementBlock("button",{key:0,"data-testid":"expand-chevron",class:"album-node__chevron",type:"button","aria-label":"Toggle expand",onClick:h},[e.createVNode(e.unref(H.IonIcon),{icon:i.value?e.unref(Fh):e.unref($h)},null,8,["icon"])])):(e.openBlock(),e.createElementBlock("span",O5)),e.createVNode(e.unref(H.IonIcon),{icon:e.unref(zh),class:"album-node__icon"},null,8,["icon"]),e.createElementVNode("span",{"data-testid":"album-name",class:"album-node__name",onClick:p},e.toDisplayString(k.album.name),1),k.showMediaCount?(e.openBlock(),e.createElementBlock("span",z5,e.toDisplayString(k.album.media_count),1)):e.createCommentVNode("",!0)],46,U5),i.value&&((V=k.album.children)!=null&&V.length)?(e.openBlock(),e.createElementBlock("div",j5,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.album.children,I=>(e.openBlock(),e.createBlock($,{key:I.id,album:I,depth:k.depth+1,"selected-id":k.selectedId,"expanded-ids":k.expandedIds,"focused-id":k.focusedId,draggable:k.draggable,"show-media-count":k.showMediaCount,compact:k.compact,onSelect:b[0]||(b[0]=x=>n("select",x)),onToggleExpand:b[1]||(b[1]=x=>n("toggle-expand",x))},null,8,["album","depth","selected-id","expanded-ids","focused-id","draggable","show-media-count","compact"]))),128))])):e.createCommentVNode("",!0)])}}}),Z5=Fe(H5,[["__scopeId","data-v-76be65a6"]]);let qn={apiBaseUrl:"/api/v1"};function G5(o){qn={...qn,...o}}function X5(){return{...qn}}function K5(o){qn={...o}}function bu(o,a){const t=(o??a).trim().replace(/\/+$/,"");return t===""?a:/^https?:\/\//i.test(t)||t.startsWith("/")?t:`/${t}`}function J5(){const o=bu(qn.apiBaseUrl,"/api/v1");return bu(qn.albumBaseUrl,`${o}/albums`)}function nn(o){return encodeURIComponent(o)}function q5(o,a){const t=new URLSearchParams;for(const[i,r]of Object.entries(a))r!==void 0&&t.set(i,r===null?"null":String(r));const n=t.toString();return n===""?o:`${o}?${n}`}function Za(o="",a={}){return q5(`${J5()}${o}`,a)}async function Y5(o,a={}){const t=a.method??"GET",n={Accept:"application/json",...a.headers},i={method:t,credentials:a.credentials??"include",headers:n};a.body!==void 0&&(n["Content-Type"]=n["Content-Type"]??"application/json",i.body=JSON.stringify(a.body));const r=await fetch(o,i);if(!r.ok)throw new Error(`Album request failed with status ${r.status}.`);return r.status===204?{}:await r.json()}async function Ga(o,a){return await(qn.httpClient??Y5)(o,a)}function Qo(o){if(typeof o=="object"&&o!==null&&"data"in o&&typeof o.data=="object"&&o.data!==null)return o.data;throw new Error("Album response was invalid")}function Q5(o){return typeof o=="object"&&o!==null&&"data"in o&&Array.isArray(o.data)?o.data:[]}const ks=Xr.defineStore("albums",()=>{const o=e.ref([]),a=e.ref(new Map),t=e.ref(!1),n=e.ref(null),i=e.ref(new Set),r=e.computed(()=>{const x=new Map;return o.value.forEach(N=>x.set(N.id,N)),x}),s=e.computed(()=>o.value.filter(x=>x.parent_id===null));function l(x){const N=o.value.findIndex(L=>L.id===x.id);N>=0?o.value[N]=x:o.value.push(x)}function d(x,N){Array.isArray(N.media)&&a.value.set(x,N.media)}async function c(x){t.value=!0,n.value=null;try{const N=(x==null?void 0:x.parent_id)??null,L=await Ga(Za("",{parent_id:N})),C=Q5(L);for(const T of C)l(T);N!==null&&i.value.add(N)}catch(N){n.value=N instanceof Error?N.message:"Unknown error"}finally{t.value=!1}}async function u(x){t.value=!0,n.value=null;try{const N=await Ga(Za(`/${nn(x)}`)),L=Qo(N);return l(L),L}catch(N){throw n.value=N instanceof Error?N.message:"Unknown error",N}finally{t.value=!1}}async function f(x){t.value=!0,n.value=null;try{const N=await Ga(Za(`/${nn(x)}`,{include_media:!0})),L=Qo(N);l(L);const C=Array.isArray(L.media)?L.media:[];return a.value.set(x,C),C}catch(N){throw n.value=N instanceof Error?N.message:"Unknown error",N}finally{t.value=!1}}async function m(x,N,L){t.value=!0,n.value=null;try{const C={media_uuids:N};L!==void 0&&(C.order_column=L);const T=await Ga(Za(`/${nn(x)}/media`),{method:"POST",body:C}),y=Qo(T);return l(y),d(x,y),y}catch(C){throw n.value=C instanceof Error?C.message:"Unknown error",C}finally{t.value=!1}}async function p(x,N){t.value=!0,n.value=null;try{await Ga(Za(`/${nn(x)}/media/${nn(N)}`),{method:"DELETE"});const L=a.value.get(x)||[];a.value.set(x,L.filter(C=>C.uuid!==N))}catch(L){throw n.value=L instanceof Error?L.message:"Unknown error",L}finally{t.value=!1}}async function h(x,N){t.value=!0,n.value=null;try{const L=await Ga(Za(`/${nn(x)}/media/reorder`),{method:"POST",body:{ordered_media_uuids:N}});if(L.data!==void 0){l(L.data),d(x,L.data);return}const C=a.value.get(x)||[],T=N.map(y=>C.find(R=>R.uuid===y)).filter(y=>y!==void 0);a.value.set(x,T)}catch(L){throw n.value=L instanceof Error?L.message:"Unknown error",L}finally{t.value=!1}}async function v(x){t.value=!0,n.value=null;try{const N=await Ga(Za(),{method:"POST",body:x}),L=Qo(N);return l(L),L}catch(N){throw n.value=N instanceof Error?N.message:"Unknown error",N}finally{t.value=!1}}async function w(x,N){t.value=!0,n.value=null;try{const L=await Ga(Za(`/${nn(x)}`),{method:"PATCH",body:N}),C=Qo(L);return l(C),C}catch(L){throw n.value=L instanceof Error?L.message:"Unknown error",L}finally{t.value=!1}}async function E(x){t.value=!0,n.value=null;try{await Ga(Za(`/${nn(x)}`),{method:"DELETE"});const N=o.value.findIndex(L=>L.id===x);N>=0&&o.value.splice(N,1),a.value.delete(x)}catch(N){throw n.value=N instanceof Error?N.message:"Unknown error",N}finally{t.value=!1}}function S(x){return o.value.filter(N=>N.parent_id===x)}function k(x){return i.value.has(x)}function b(x){return a.value.get(x)||[]}async function $(x,N){const L=o.value.findIndex(T=>T.id===x);if(L<0)return;const C=o.value[L];o.value[L]={...C,parent_id:N};try{const T=await Ga(Za(`/${nn(x)}/move`),{method:"POST",body:{parent_id:N}});T.data!==void 0&&l(T.data)}catch(T){throw o.value[L]=C,n.value=T instanceof Error?T.message:"Unknown error",T instanceof Error?T:new Error("Failed to move album")}}function V(x){o.value=x}function I(){o.value=[],a.value.clear(),t.value=!1,n.value=null,i.value.clear()}return{albums:o,albumMedia:a,loading:t,error:n,childrenLoadedById:i,albumsById:r,rootAlbums:s,fetchAlbums:c,fetchAlbum:u,fetchAlbumMedia:f,attachMedia:m,detachMedia:p,reorderAlbumMedia:h,createAlbum:v,updateAlbum:w,deleteAlbum:E,getChildrenOf:S,childrenLoaded:k,getAlbumMedia:b,moveAlbum:$,setAlbums:V,reset:I}});function Wp(){const o=ks(),{albums:a,albumsById:t,rootAlbums:n,loading:i,error:r}=Xr.storeToRefs(o);async function s(S){await o.fetchAlbums(S)}async function l(S){return await o.fetchAlbum(S)}async function d(S){return await o.fetchAlbumMedia(S)}async function c(S,k,b){return await o.attachMedia(S,k,b)}async function u(S,k){await o.detachMedia(S,k)}async function f(S,k){await o.reorderAlbumMedia(S,k)}async function m(S){return await o.createAlbum(S)}async function p(S,k){return await o.updateAlbum(S,k)}async function h(S){await o.deleteAlbum(S)}function v(S){return o.getChildrenOf(S)}function w(S){return o.childrenLoaded(S)}async function E(S,k){await o.moveAlbum(S,k)}return{albums:a,albumsById:t,rootAlbums:n,loading:i,error:r,fetchAlbums:s,fetchAlbum:l,fetchAlbumMedia:d,attachMedia:c,detachMedia:u,reorderAlbumMedia:f,createAlbum:m,updateAlbum:p,deleteAlbum:h,getChildrenOf:v,childrenLoaded:w,moveAlbum:E}}function Hp(o){const{childrenByParentId:a,onMove:t}=o,n=e.ref({isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null});function i(f,m){if(f===m)return!0;const p=new Set,h=[f];for(;h.length>0;){const v=h.shift();if(!v||p.has(v))continue;p.add(v);const w=a.get(v)||[];for(const E of w){if(E===m)return!0;h.push(E)}}return!1}function r(f,m){return f===m?!1:m===null?!0:!i(f,m)}function s(f){n.value={isDragging:!0,draggedAlbumId:f,dropTargetId:null,dropPosition:null}}function l(){n.value={isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null}}function d(f){n.value.dropTargetId=f}function c(){n.value.dropTargetId=null,n.value.dropPosition=null}async function u(){const{draggedAlbumId:f,dropTargetId:m}=n.value;if(!f){l();return}if(!r(f,m)){l();return}try{await t(f,m)}finally{l()}}return{dragState:n,isDescendant:i,canDropOn:r,startDrag:s,endDrag:l,setDropTarget:d,clearDropTarget:c,executeDrop:u}}const eF={key:0,"data-testid":"loading-spinner",class:"album-tree__loading"},tF={key:1,"data-testid":"error-state",class:"album-tree__error"},aF={key:2,"data-testid":"empty-state",class:"album-tree__empty"},nF={key:3,class:"album-tree__content",role:"group"},oF=e.defineComponent({__name:"AlbumTree",props:{modelValue:{default:null},expandedIds:{default:()=>[]},draggable:{type:Boolean,default:!0},showMediaCount:{type:Boolean,default:!0},compact:{type:Boolean,default:!1}},emits:["update:modelValue","album-selected","album-moved","album-expanded","album-collapsed"],setup(o,{expose:a,emit:t}){const n=o,i=t,r=e.computed(()=>n.draggable===!0),s=e.computed(()=>n.showMediaCount===!0),l=e.computed(()=>n.compact===!0),{albums:d,rootAlbums:c,loading:u,error:f,fetchAlbums:m,getChildrenOf:p,childrenLoaded:h,moveAlbum:v}=Wp(),w=e.shallowRef(new Set(n.expandedIds)),E=e.ref(n.modelValue??null),S=e.ref(null),k=new Map,b=new Map;function $(O){k.clear(),b.clear();for(const D of O){k.set(D.id,D);const J=D.parent_id??null,Z=b.get(J)??[];Z.push(D.id),b.set(J,Z)}}e.watch(d,O=>{$(O)},{immediate:!0});const{dragState:V,canDropOn:I,startDrag:x,endDrag:N,setDropTarget:L,clearDropTarget:C,executeDrop:T}=Hp({childrenByParentId:b,onMove:async(O,D)=>{await v(O,D),i("album-moved",{albumId:O,newParentId:D})}});e.watch(()=>n.modelValue,O=>{E.value=O??null}),e.watch(()=>n.expandedIds,O=>{w.value=new Set(O)}),e.onMounted(async()=>{await m({parent_id:null})});const y=e.computed(()=>c.value.map(O=>R(O)));function R(O){if(!w.value.has(O.id))return O;const D=p(O.id);return{...O,children:D.map(J=>R(J))}}const U=e.computed(()=>{const O=[];function D(J){var Z;for(const ie of J)O.push(ie),w.value.has(ie.id)&&((Z=ie.children)!=null&&Z.length)&&D(ie.children)}return D(y.value),O});function z(O){var Z;if(!U.value.length)return;const D=S.value?U.value.findIndex(ie=>ie.id===S.value):-1,J=D>=0?U.value[D]:null;switch(O.key){case"ArrowDown":O.preventDefault(),D<U.value.length-1?S.value=U.value[D+1].id:D===-1&&U.value.length>0&&(S.value=U.value[0].id);break;case"ArrowUp":O.preventDefault(),D>0&&(S.value=U.value[D-1].id);break;case"ArrowRight":O.preventDefault(),J&&(J.children_count>0&&!w.value.has(J.id)?W(J.id):w.value.has(J.id)&&((Z=J.children)!=null&&Z.length)&&(S.value=J.children[0].id));break;case"ArrowLeft":O.preventDefault(),J&&(w.value.has(J.id)&&J.children_count>0?W(J.id):J.parent_id&&(S.value=J.parent_id));break;case"Enter":case" ":O.preventDefault(),J&&B(J);break;case"Home":O.preventDefault(),U.value.length>0&&(S.value=U.value[0].id);break;case"End":O.preventDefault(),U.value.length>0&&(S.value=U.value[U.value.length-1].id);break}}async function W(O){w.value.has(O)?(w.value.delete(O),i("album-collapsed",O)):(h(O)||await m({parent_id:O}),w.value.add(O),i("album-expanded",O))}function B(O){E.value=O.id,i("update:modelValue",O.id),i("album-selected",O)}function P(O){n.draggable&&x(O)}function X(O){var J;if(!n.draggable)return;const D=(J=V.value)==null?void 0:J.draggedAlbumId;D&&(L(O),I(D,O))}function K(){n.draggable&&C()}async function be(O){n.draggable&&(L(O),await T())}function Ne(O){n.draggable&&(O.preventDefault(),L(null))}async function ue(O){n.draggable&&(O.preventDefault(),L(null),await T())}function re(){N()}return a({focusedId:S}),(O,D)=>(e.openBlock(),e.createElementBlock("div",{class:"album-tree","data-testid":"album-tree",tabindex:"0",role:"tree","aria-label":"Album tree",onKeydown:z,onDragover:Ne,onDrop:ue,onDragend:re},[e.unref(u)?(e.openBlock(),e.createElementBlock("div",eF,[e.createVNode(e.unref(H.IonSpinner),{name:"crescent"})])):e.unref(f)?(e.openBlock(),e.createElementBlock("div",tF,[e.createElementVNode("p",null,e.toDisplayString(e.unref(f)),1)])):e.unref(c).length?(e.openBlock(),e.createElementBlock("div",nF,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.value,J=>(e.openBlock(),e.createBlock(Z5,{key:J.id,album:J,depth:0,"selected-id":E.value,"expanded-ids":w.value,"focused-id":S.value,draggable:r.value,"drag-state":r.value?e.unref(V):null,"show-media-count":s.value,compact:l.value,onSelect:B,onToggleExpand:W,onDragStart:P,onDragOver:X,onDragLeave:K,onDrop:be},null,8,["album","selected-id","expanded-ids","focused-id","draggable","drag-state","show-media-count","compact"]))),128))])):(e.openBlock(),e.createElementBlock("div",aF,[D[0]||(D[0]=e.createElementVNode("p",null,"No albums yet",-1)),e.renderSlot(O.$slots,"empty-action",{},void 0,!0)]))],32))}}),Zp=Fe(oF,[["__scopeId","data-v-ae3dea7a"]]),iF=300,rF=e.defineComponent({__name:"AlbumBrowser",props:{isOpen:{type:Boolean},selectedAlbumId:{default:null},title:{default:"Select Album"},confirmText:{default:"Select"}},emits:["close","confirm"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(t.selectedAlbumId??null),r=e.ref(null),s=e.ref(0),l=e.ref(null);e.watch(()=>t.selectedAlbumId,p=>{i.value=p??null});const d=e.computed(()=>r.value!==null);function c(p){const h=Date.now();if(l.value===p.id&&h-s.value<iF){n("confirm",p);return}s.value=h,l.value=p.id,i.value=p.id,r.value=p}function u(){r.value&&n("confirm",r.value)}function f(){n("close")}function m(){n("close")}return(p,h)=>(e.openBlock(),e.createBlock(e.unref(H.IonModal),{"is-open":p.isOpen,class:"album-browser-modal",onDidDismiss:m},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(p.title),1)]),_:1}),e.createVNode(e.unref(H.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonButton),{"data-testid":"cancel-button",onClick:f},{default:e.withCtx(()=>[...h[1]||(h[1]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(H.IonContent),{class:"album-browser-content"},{default:e.withCtx(()=>[e.createVNode(Zp,{modelValue:i.value,"onUpdate:modelValue":h[0]||(h[0]=v=>i.value=v),draggable:!1,"show-media-count":!0,compact:!1,onAlbumSelected:c},null,8,["modelValue"])]),_:1}),e.createVNode(e.unref(H.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonButton),{fill:"clear",onClick:f},{default:e.withCtx(()=>[...h[2]||(h[2]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(H.IonButton),{"data-testid":"confirm-button",fill:"solid",color:"primary",disabled:!d.value,onClick:u},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(p.confirmText),1)]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"]))}}),Gp=Fe(rF,[["__scopeId","data-v-21676ec1"]]),sF={class:"ion-padding-start text-sm"},lF={class:"ion-padding-start text-sm"},dF={key:1},cF={key:1,class:"album-manager-inline rounded-lg border border-gray-200 bg-white p-4"},uF={class:"flex items-center justify-between gap-3 pb-3"},mF={class:"text-base font-semibold text-gray-900"},pF={class:"ion-padding-start text-sm"},fF={class:"ion-padding-start text-sm"},hF={class:"flex justify-between pt-2"},vF={key:1},ei=255,ti=1e3,gF=e.defineComponent({__name:"AlbumManager",props:{albumId:{default:null},parentId:{default:null},mode:{default:"inline"},isOpen:{type:Boolean,default:!1}},emits:["close","created","updated","deleted","error"],setup(o,{emit:a}){const t=o,n=a,i=ks(),r=e.computed(()=>t.albumId!==null&&t.albumId!==void 0),s=e.computed(()=>r.value?"Edit Album":"Create Album"),l=e.computed(()=>r.value?"Save":"Create"),d=e.ref({name:"",description:"",parent_id:t.parentId}),c=e.ref({name:!1,description:!1}),u=e.ref(null),f=e.ref(!1),m=e.ref(null),p=e.ref(!1),h=e.ref(!1),v=e.computed(()=>c.value.name?d.value.name.trim()?d.value.name.length>ei?`Name must be ${ei} characters or less`:null:"Name is required":null),w=e.computed(()=>c.value.description&&d.value.description.length>ti?`Description must be ${ti} characters or less`:null),E=e.computed(()=>{const z=d.value.name.trim().length>0,W=d.value.name.length<=ei,B=d.value.description.length<=ti;return z&&W&&B&&!p.value}),S=e.computed(()=>{var z;return((z=u.value)==null?void 0:z.name)??"None (Root)"}),k=e.computed(()=>m.value?m.value.children_count===0&&m.value.media_count===0:!1),b=e.computed(()=>m.value?m.value.children_count>0?"Cannot delete album with child albums. Move or delete children first.":m.value.media_count>0?"Cannot delete album with media. Remove media first.":`Are you sure you want to delete "${m.value.name}"? This action cannot be undone.`:"");e.onMounted(async()=>{t.albumId&&await $()});async function $(){if(t.albumId)try{const z=await i.fetchAlbum(t.albumId);m.value=z,d.value={name:z.name,description:z.description??"",parent_id:z.parent_id},z.parent_id&&(u.value={id:z.parent_id,name:"Parent Album"})}catch(z){n("error",z)}}function V(){c.value.name=!0}function I(){c.value.description=!0}function x(){f.value=!0}function N(z){u.value={id:z.id,name:z.name},d.value.parent_id=z.id,f.value=!1}function L(){f.value=!1}function C(){n("close")}function T(){n("close")}async function y(){if(c.value.name=!0,c.value.description=!0,!(!E.value||p.value)){p.value=!0;try{const z={name:d.value.name.trim(),description:d.value.description.trim(),parent_id:d.value.parent_id};if(r.value&&t.albumId){const W=await i.updateAlbum(t.albumId,z);n("updated",W)}else{const W=await i.createAlbum(z);n("created",W)}n("close")}catch(z){n("error",z)}finally{p.value=!1}}}function R(){k.value&&(h.value=!0)}async function U(z){var B;if((((B=z.detail)==null?void 0:B.role)??"")!=="confirm"){h.value=!1;return}if(t.albumId){p.value=!0;try{await i.deleteAlbum(t.albumId),n("deleted",t.albumId),n("close")}catch(P){n("error",P)}finally{p.value=!1,h.value=!1}}}return(z,W)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[z.mode==="modal"?(e.openBlock(),e.createBlock(e.unref(H.IonModal),{key:0,"is-open":z.isOpen,class:"album-manager-modal",onDidDismiss:T},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.value),1)]),_:1}),e.createVNode(e.unref(H.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:C},{default:e.withCtx(()=>[...W[4]||(W[4]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(H.IonContent),{class:"album-manager-content"},{default:e.withCtx(()=>[e.createElementVNode("form",{"data-testid":"album-form",class:"p-4 space-y-3",onSubmit:e.withModifiers(y,["prevent"])},[e.createVNode(e.unref(H.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...W[5]||(W[5]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(H.IonInput),{modelValue:d.value.name,"onUpdate:modelValue":W[0]||(W[0]=B=>d.value.name=B),"data-testid":"name-input",maxlength:ei,onIonBlur:V},null,8,["modelValue"])]),_:1}),v.value?(e.openBlock(),e.createBlock(e.unref(H.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",sF,e.toDisplayString(v.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(H.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...W[6]||(W[6]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(H.IonTextarea),{modelValue:d.value.description,"onUpdate:modelValue":W[1]||(W[1]=B=>d.value.description=B),"data-testid":"description-input",maxlength:ti,onIonBlur:I},null,8,["modelValue"])]),_:1}),w.value?(e.openBlock(),e.createBlock(e.unref(H.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",lF,e.toDisplayString(w.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(H.IonItem),{button:"","data-testid":"parent-selector",onClick:x},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...W[7]||(W[7]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(H.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(S.value),1)]),_:1})]),_:1})],32)]),_:1}),e.createVNode(e.unref(H.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonButtons),{slot:"start"},{default:e.withCtx(()=>[r.value?(e.openBlock(),e.createBlock(e.unref(H.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",disabled:!k.value,title:k.value?void 0:b.value,onClick:R},{default:e.withCtx(()=>[...W[8]||(W[8]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.unref(H.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!E.value,onClick:y},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createBlock(e.unref(H.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",dF,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"])):(e.openBlock(),e.createElementBlock("div",cF,[e.createElementVNode("div",uF,[e.createElementVNode("h2",mF,e.toDisplayString(s.value),1),e.createVNode(e.unref(H.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:C},{default:e.withCtx(()=>[...W[9]||(W[9]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),e.createElementVNode("form",{"data-testid":"album-form",class:"space-y-3",onSubmit:e.withModifiers(y,["prevent"])},[e.createVNode(e.unref(H.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...W[10]||(W[10]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(H.IonInput),{modelValue:d.value.name,"onUpdate:modelValue":W[2]||(W[2]=B=>d.value.name=B),"data-testid":"name-input",maxlength:ei,onIonBlur:V},null,8,["modelValue"])]),_:1}),v.value?(e.openBlock(),e.createBlock(e.unref(H.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",pF,e.toDisplayString(v.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(H.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...W[11]||(W[11]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(H.IonTextarea),{modelValue:d.value.description,"onUpdate:modelValue":W[3]||(W[3]=B=>d.value.description=B),"data-testid":"description-input",maxlength:ti,onIonBlur:I},null,8,["modelValue"])]),_:1}),w.value?(e.openBlock(),e.createBlock(e.unref(H.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",fF,e.toDisplayString(w.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(H.IonItem),{button:"","data-testid":"parent-selector",onClick:x},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonLabel),null,{default:e.withCtx(()=>[...W[12]||(W[12]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(H.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(S.value),1)]),_:1})]),_:1}),e.createElementVNode("div",hF,[e.createElementVNode("div",null,[r.value?(e.openBlock(),e.createBlock(e.unref(H.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",fill:"outline",disabled:!k.value,title:k.value?void 0:b.value,onClick:R},{default:e.withCtx(()=>[...W[13]||(W[13]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(H.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!E.value,onClick:y},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createBlock(e.unref(H.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",vF,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])])],32)])),e.createVNode(Gp,{"is-open":f.value,"selected-album-id":d.value.parent_id,title:"Select Parent Album",onClose:L,onConfirm:N},null,8,["is-open","selected-album-id"]),e.createVNode(e.unref(H.IonAlert),{"is-open":h.value,header:"Delete Album?",message:b.value,buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"confirm",cssClass:"alert-button-danger"}],onDidDismiss:U},null,8,["is-open","message"])],64))}}),bF=Fe(gF,[["__scopeId","data-v-22083f3a"]]),yF={class:"album-media-grid"},wF={class:"aspect-square"},kF={key:1,"data-testid":"empty-state",class:"flex flex-col items-center justify-center py-12 gap-4"},_F={class:"text-gray-500"},EF=["data-media-id","draggable","onDragstart","onDragover","onDrop","onMouseenter"],xF={key:0,"data-testid":"drop-indicator",class:"absolute inset-0 border-2 border-primary rounded-lg pointer-events-none z-30"},SF={key:1,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"},CF={class:"aspect-square relative"},VF=["src","alt"],NF={key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center gap-2 transition-opacity"},TF=e.defineComponent({__name:"AlbumMediaGrid",props:{albumId:{},selectionMode:{type:Boolean,default:!1},selectedItems:{default:()=>[]},reorderable:{type:Boolean,default:!1},showActions:{type:Boolean,default:!0},columns:{default:()=>({mobile:2,sm:3,md:4,lg:5,xl:6})},isLoading:{type:Boolean,default:!1},emptyText:{default:"No media in this album"}},emits:["toggle-select","preview","edit","detach","reorder","add","selection-change"],setup(o,{emit:a}){const t=o,n=a,i=ks(),r=e.ref([]),s=e.ref(!1),l=e.ref(null),d=e.ref(null),c=e.ref(null),u=e.computed(()=>t.isLoading||s.value),f=e.computed(()=>!u.value&&r.value.length===0),m=e.computed(()=>{const T=t.columns;return["grid","gap-4",`grid-cols-${T.mobile??2}`,`sm:grid-cols-${T.sm??3}`,`md:grid-cols-${T.md??4}`,`lg:grid-cols-${T.lg??5}`,`xl:grid-cols-${T.xl??6}`]}),p=e.computed(()=>(t.columns.md??4)*2);e.onMounted(async()=>{await h()}),e.watch(()=>t.albumId,async()=>{await h()});async function h(){s.value=!0;try{const T=await i.fetchAlbumMedia(t.albumId);r.value=T}catch{r.value=[]}finally{s.value=!1}}function v(T){return t.selectedItems.includes(T)}function w(T){n("toggle-select",T);const y=v(T.uuid)?t.selectedItems.filter(R=>R!==T.uuid):[...t.selectedItems,T.uuid];n("selection-change",y)}function E(T){if(T.conversions&&typeof T.conversions=="object"){const y=T.conversions.thumb;if(typeof y=="string")return y}return T.original_url}function S(T){l.value=T}function k(){l.value=null}function b(T){n("preview",T)}function $(T){n("edit",T)}function V(T){n("detach",T.uuid)}function I(){n("add")}function x(T,y){t.reorderable&&(d.value=y,T.dataTransfer&&(T.dataTransfer.effectAllowed="move",T.dataTransfer.setData("text/plain",String(y))))}function N(T,y){!t.reorderable||d.value===null||(T.preventDefault(),c.value=y)}function L(T,y){if(!t.reorderable||d.value===null)return;T.preventDefault();const R=d.value;if(R!==y){const U=[...r.value],[z]=U.splice(R,1);U.splice(y,0,z),r.value=U;const W=U.map(B=>B.uuid);n("reorder",W),i.reorderAlbumMedia(t.albumId,W).catch(()=>{h()})}d.value=null,c.value=null}function C(){d.value=null,c.value=null}return(T,y)=>(e.openBlock(),e.createElementBlock("div",yF,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,"data-testid":"loading-grid",class:e.normalizeClass(m.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,R=>(e.openBlock(),e.createBlock(e.unref(H.IonCard),{key:R,class:"m-0"},{default:e.withCtx(()=>[e.createElementVNode("div",wF,[e.createVNode(e.unref(H.IonSkeletonText),{animated:"",class:"w-full h-full skeleton"})])]),_:1}))),128))],2)):f.value?(e.openBlock(),e.createElementBlock("div",kF,[e.createVNode(e.unref(H.IonIcon),{name:"images-outline",class:"text-6xl text-gray-400"}),e.createElementVNode("p",_F,e.toDisplayString(T.emptyText),1),e.createVNode(e.unref(H.IonButton),{"data-testid":"add-media-btn",onClick:I},{default:e.withCtx(()=>[...y[0]||(y[0]=[e.createTextVNode(" Add Media ",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("div",{key:2,"data-testid":"media-grid",class:e.normalizeClass(m.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(R,U)=>(e.openBlock(),e.createElementBlock("div",{key:R.uuid,"data-media-id":R.uuid,class:e.normalizeClass(["media-item relative group",{"opacity-50":d.value===U,"ring-2 ring-primary":c.value===U&&d.value!==U}]),draggable:T.reorderable,onDragstart:z=>x(z,U),onDragover:z=>N(z,U),onDrop:z=>L(z,U),onDragend:C,onMouseenter:z=>S(R.uuid),onMouseleave:k},[c.value===U&&d.value!==U&&T.reorderable?(e.openBlock(),e.createElementBlock("div",xF)):e.createCommentVNode("",!0),T.reorderable?(e.openBlock(),e.createElementBlock("div",SF,[e.createVNode(e.unref(H.IonIcon),{name:"reorder-three-outline",class:"text-white drop-shadow-md"})])):e.createCommentVNode("",!0),T.selectionMode?(e.openBlock(),e.createBlock(e.unref(H.IonCheckbox),{key:2,"data-testid":"media-checkbox",checked:v(R.uuid),class:"absolute top-2 left-2 z-20",onIonChange:z=>w(R)},null,8,["checked","onIonChange"])):e.createCommentVNode("",!0),e.createVNode(e.unref(H.IonCard),{class:"m-0 overflow-hidden"},{default:e.withCtx(()=>[e.createElementVNode("div",CF,[e.createElementVNode("img",{src:E(R),alt:R.file_name,class:"w-full h-full object-cover"},null,8,VF),T.showActions&&l.value===R.uuid?(e.openBlock(),e.createElementBlock("div",NF,[e.createVNode(e.unref(H.IonButton),{"data-testid":"action-preview",fill:"clear",size:"small",color:"light",onClick:z=>b(R)},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{slot:"icon-only",name:"eye-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(H.IonButton),{"data-testid":"action-edit",fill:"clear",size:"small",color:"light",onClick:z=>$(R)},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{slot:"icon-only",name:"create-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(H.IonButton),{"data-testid":"action-detach",fill:"clear",size:"small",color:"danger",onClick:z=>V(R)},{default:e.withCtx(()=>[e.createVNode(e.unref(H.IonIcon),{slot:"icon-only",name:"close-circle-outline"})]),_:1},8,["onClick"])])):e.createCommentVNode("",!0)])]),_:2},1024)],42,EF))),128)),e.createElementVNode("div",{class:"aspect-square border-2 border-dashed border-gray-300 rounded-lg flex flex-col items-center justify-center gap-2 cursor-pointer hover:border-primary hover:bg-gray-50 transition-colors","data-testid":"add-more-card",onClick:I},[e.createVNode(e.unref(H.IonIcon),{name:"add-circle-outline",class:"text-4xl text-gray-400"}),y[1]||(y[1]=e.createElementVNode("span",{class:"text-sm text-gray-500"},"Add Media",-1))])],2))]))}}),BF=Fe(TF,[["__scopeId","data-v-d84b796a"]]),IF={key:0,class:"media-album-inline-create","data-testid":"media-album-inline-create"},MF={class:"media-album-inline-create__field"},FF={class:"media-album-inline-create__field"},$F=["value"],DF={key:1,class:"media-album-inline-create__autocomplete"},RF={class:"media-album-inline-create__autocomplete-input-wrap"},AF={key:0,class:"media-album-inline-create__autocomplete-list"},LF=["onMousedown"],PF={key:1,class:"media-album-inline-create__autocomplete-empty"},UF={class:"media-album-inline-create__actions"},OF=e.defineComponent({__name:"MediaAlbumInlineCreate",props:{open:{type:Boolean,default:!1},nameLabel:{default:"Album name"},albums:{default:()=>[]}},emits:["cancel","create"],setup(o,{emit:a}){const t=o,n=a,i=e.ref(""),r=e.ref(""),s=e.ref(""),l=e.ref(!1),d=e.computed(()=>t.albums.length>5),c=e.computed(()=>{if(s.value.trim()==="")return t.albums;const w=s.value.toLowerCase();return t.albums.filter(E=>E.name.toLowerCase().includes(w))}),u=e.computed(()=>{if(r.value==="")return"";const w=t.albums.find(E=>E.id===r.value);return(w==null?void 0:w.name)??""}),f=w=>{r.value=w.id,s.value=w.name,l.value=!1},m=()=>{r.value="",s.value="",l.value=!1},p=()=>{l.value=!0,r.value!==""&&(s.value=u.value)},h=()=>{setTimeout(()=>{l.value=!1,r.value!==""?s.value=u.value:s.value=""},150)},v=()=>{i.value.trim()!==""&&(n("create",i.value.trim(),r.value!==""?r.value:void 0),i.value="",r.value="",s.value="")};return(w,E)=>w.open?(e.openBlock(),e.createElementBlock("section",IF,[E[7]||(E[7]=e.createElementVNode("h4",{class:"media-album-inline-create__heading"}," New album ",-1)),e.createElementVNode("label",MF,[e.createElementVNode("span",null,e.toDisplayString(w.nameLabel),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":E[0]||(E[0]=S=>i.value=S),type:"text",class:"media-album-inline-create__input",placeholder:"e.g. Marbles, Pendants","data-testid":"input-media-album-name"},null,512),[[e.vModelText,i.value]])]),e.createElementVNode("label",FF,[E[6]||(E[6]=e.createElementVNode("span",null,"Parent album (optional)",-1)),d.value?(e.openBlock(),e.createElementBlock("div",DF,[e.createElementVNode("div",RF,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":E[2]||(E[2]=S=>s.value=S),type:"text",class:"media-album-inline-create__input",placeholder:"Search albums...","data-testid":"input-media-album-parent-search",onFocus:p,onBlur:h},null,544),[[e.vModelText,s.value]]),r.value!==""?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-album-inline-create__autocomplete-clear","aria-label":"Clear parent album",onMousedown:e.withModifiers(m,["prevent"])},[...E[5]||(E[5]=[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.5","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)])],32)):e.createCommentVNode("",!0)]),l.value?(e.openBlock(),e.createElementBlock("ul",AF,[r.value!==""?(e.openBlock(),e.createElementBlock("li",{key:0,class:"media-album-inline-create__autocomplete-option media-album-inline-create__autocomplete-option--none",onMousedown:e.withModifiers(m,["prevent"])}," None ",32)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,S=>(e.openBlock(),e.createElementBlock("li",{key:S.id,class:e.normalizeClass(["media-album-inline-create__autocomplete-option",{"is-selected":S.id===r.value}]),onMousedown:e.withModifiers(k=>f(S),["prevent"])},e.toDisplayString(S.name),43,LF))),128)),c.value.length===0?(e.openBlock(),e.createElementBlock("li",PF," No albums match ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])):e.withDirectives((e.openBlock(),e.createElementBlock("select",{key:0,"onUpdate:modelValue":E[1]||(E[1]=S=>r.value=S),class:"media-album-inline-create__input","data-testid":"select-media-album-parent"},[E[4]||(E[4]=e.createElementVNode("option",{value:""}," None ",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.albums,S=>(e.openBlock(),e.createElementBlock("option",{key:S.id,value:S.id},e.toDisplayString(S.name),9,$F))),128))],512)),[[e.vModelSelect,r.value]])]),e.createElementVNode("div",UF,[e.createElementVNode("button",{type:"button",class:"media-album-inline-create__button","data-testid":"btn-media-album-cancel",onClick:E[3]||(E[3]=S=>n("cancel"))}," Cancel "),e.createElementVNode("button",{type:"button",class:"media-album-inline-create__button media-album-inline-create__button--primary","data-testid":"btn-media-album-create",onClick:v}," Create ")])])):e.createCommentVNode("",!0)}}),Xp=Fe(OF,[["__scopeId","data-v-a85162fe"]]),zF={class:"media-album-unavailable-state","data-testid":"media-album-unavailable-state"},jF=e.defineComponent({__name:"MediaAlbumUnavailableState",props:{title:{default:"Album unavailable"},body:{default:"You no longer have access to this album."},actionLabel:{default:"Go to library"}},emits:["goToLibrary"],setup(o,{emit:a}){const t=a;return(n,i)=>(e.openBlock(),e.createElementBlock("section",zF,[e.createElementVNode("h3",null,e.toDisplayString(n.title),1),e.createElementVNode("p",null,e.toDisplayString(n.body),1),e.createElementVNode("button",{type:"button",class:"media-album-unavailable-state__button",onClick:i[0]||(i[0]=r=>t("goToLibrary"))},e.toDisplayString(n.actionLabel),1)]))}}),Kp=Fe(jF,[["__scopeId","data-v-04620e64"]]);/*!
|
|
350
|
-
* tabbable 6.2.0
|
|
351
|
-
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
|
|
352
|
-
*/var Jp=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],jr=Jp.join(","),qp=typeof Element>"u",Yn=qp?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Wr=!qp&&Element.prototype.getRootNode?function(o){var a;return o==null||(a=o.getRootNode)===null||a===void 0?void 0:a.call(o)}:function(o){return o==null?void 0:o.ownerDocument},Hr=function o(a,t){var n;t===void 0&&(t=!0);var i=a==null||(n=a.getAttribute)===null||n===void 0?void 0:n.call(a,"inert"),r=i===""||i==="true",s=r||t&&a&&o(a.parentNode);return s},WF=function(a){var t,n=a==null||(t=a.getAttribute)===null||t===void 0?void 0:t.call(a,"contenteditable");return n===""||n==="true"},Yp=function(a,t,n){if(Hr(a))return[];var i=Array.prototype.slice.apply(a.querySelectorAll(jr));return t&&Yn.call(a,jr)&&i.unshift(a),i=i.filter(n),i},Qp=function o(a,t,n){for(var i=[],r=Array.from(a);r.length;){var s=r.shift();if(!Hr(s,!1))if(s.tagName==="SLOT"){var l=s.assignedElements(),d=l.length?l:s.children,c=o(d,!0,n);n.flatten?i.push.apply(i,c):i.push({scopeParent:s,candidates:c})}else{var u=Yn.call(s,jr);u&&n.filter(s)&&(t||!a.includes(s))&&i.push(s);var f=s.shadowRoot||typeof n.getShadowRoot=="function"&&n.getShadowRoot(s),m=!Hr(f,!1)&&(!n.shadowRootFilter||n.shadowRootFilter(s));if(f&&m){var p=o(f===!0?s.children:f.children,!0,n);n.flatten?i.push.apply(i,p):i.push({scopeParent:s,candidates:p})}else r.unshift.apply(r,s.children)}}return i},ef=function(a){return!isNaN(parseInt(a.getAttribute("tabindex"),10))},zn=function(a){if(!a)throw new Error("No node provided");return a.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(a.tagName)||WF(a))&&!ef(a)?0:a.tabIndex},HF=function(a,t){var n=zn(a);return n<0&&t&&!ef(a)?0:n},ZF=function(a,t){return a.tabIndex===t.tabIndex?a.documentOrder-t.documentOrder:a.tabIndex-t.tabIndex},tf=function(a){return a.tagName==="INPUT"},GF=function(a){return tf(a)&&a.type==="hidden"},XF=function(a){var t=a.tagName==="DETAILS"&&Array.prototype.slice.apply(a.children).some(function(n){return n.tagName==="SUMMARY"});return t},KF=function(a,t){for(var n=0;n<a.length;n++)if(a[n].checked&&a[n].form===t)return a[n]},JF=function(a){if(!a.name)return!0;var t=a.form||Wr(a),n=function(l){return t.querySelectorAll('input[type="radio"][name="'+l+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=n(window.CSS.escape(a.name));else try{i=n(a.name)}catch{return!1}var r=KF(i,a.form);return!r||r===a},qF=function(a){return tf(a)&&a.type==="radio"},YF=function(a){return qF(a)&&!JF(a)},QF=function(a){var t,n=a&&Wr(a),i=(t=n)===null||t===void 0?void 0:t.host,r=!1;if(n&&n!==a){var s,l,d;for(r=!!((s=i)!==null&&s!==void 0&&(l=s.ownerDocument)!==null&&l!==void 0&&l.contains(i)||a!=null&&(d=a.ownerDocument)!==null&&d!==void 0&&d.contains(a));!r&&i;){var c,u,f;n=Wr(i),i=(c=n)===null||c===void 0?void 0:c.host,r=!!((u=i)!==null&&u!==void 0&&(f=u.ownerDocument)!==null&&f!==void 0&&f.contains(i))}}return r},yu=function(a){var t=a.getBoundingClientRect(),n=t.width,i=t.height;return n===0&&i===0},e6=function(a,t){var n=t.displayCheck,i=t.getShadowRoot;if(getComputedStyle(a).visibility==="hidden")return!0;var r=Yn.call(a,"details>summary:first-of-type"),s=r?a.parentElement:a;if(Yn.call(s,"details:not([open]) *"))return!0;if(!n||n==="full"||n==="legacy-full"){if(typeof i=="function"){for(var l=a;a;){var d=a.parentElement,c=Wr(a);if(d&&!d.shadowRoot&&i(d)===!0)return yu(a);a.assignedSlot?a=a.assignedSlot:!d&&c!==a.ownerDocument?a=c.host:a=d}a=l}if(QF(a))return!a.getClientRects().length;if(n!=="legacy-full")return!0}else if(n==="non-zero-area")return yu(a);return!1},t6=function(a){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(a.tagName))for(var t=a.parentElement;t;){if(t.tagName==="FIELDSET"&&t.disabled){for(var n=0;n<t.children.length;n++){var i=t.children.item(n);if(i.tagName==="LEGEND")return Yn.call(t,"fieldset[disabled] *")?!0:!i.contains(a)}return!0}t=t.parentElement}return!1},Zr=function(a,t){return!(t.disabled||Hr(t)||GF(t)||e6(t,a)||XF(t)||t6(t))},Hl=function(a,t){return!(YF(t)||zn(t)<0||!Zr(a,t))},a6=function(a){var t=parseInt(a.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},n6=function o(a){var t=[],n=[];return a.forEach(function(i,r){var s=!!i.scopeParent,l=s?i.scopeParent:i,d=HF(l,s),c=s?o(i.candidates):l;d===0?s?t.push.apply(t,c):t.push(l):n.push({documentOrder:r,tabIndex:d,item:i,isScope:s,content:c})}),n.sort(ZF).reduce(function(i,r){return r.isScope?i.push.apply(i,r.content):i.push(r.content),i},[]).concat(t)},o6=function(a,t){t=t||{};var n;return t.getShadowRoot?n=Qp([a],t.includeContainer,{filter:Hl.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:a6}):n=Yp(a,t.includeContainer,Hl.bind(null,t)),n6(n)},i6=function(a,t){t=t||{};var n;return t.getShadowRoot?n=Qp([a],t.includeContainer,{filter:Zr.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):n=Yp(a,t.includeContainer,Zr.bind(null,t)),n},bo=function(a,t){if(t=t||{},!a)throw new Error("No node provided");return Yn.call(a,jr)===!1?!1:Hl(t,a)},r6=Jp.concat("iframe").join(","),tl=function(a,t){if(t=t||{},!a)throw new Error("No node provided");return Yn.call(a,r6)===!1?!1:Zr(t,a)};/*!
|
|
353
|
-
* focus-trap 7.6.5
|
|
354
|
-
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
355
|
-
*/function Zl(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 s6(o){if(Array.isArray(o))return Zl(o)}function l6(o,a,t){return(a=p6(a))in o?Object.defineProperty(o,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):o[a]=t,o}function d6(o){if(typeof Symbol<"u"&&o[Symbol.iterator]!=null||o["@@iterator"]!=null)return Array.from(o)}function c6(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
356
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wu(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 ku(o){for(var a=1;a<arguments.length;a++){var t=arguments[a]!=null?arguments[a]:{};a%2?wu(Object(t),!0).forEach(function(n){l6(o,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(t)):wu(Object(t)).forEach(function(n){Object.defineProperty(o,n,Object.getOwnPropertyDescriptor(t,n))})}return o}function u6(o){return s6(o)||d6(o)||f6(o)||c6()}function m6(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 p6(o){var a=m6(o,"string");return typeof a=="symbol"?a:a+""}function f6(o,a){if(o){if(typeof o=="string")return Zl(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)?Zl(o,a):void 0}}var _u={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)}},h6=function(a){return a.tagName&&a.tagName.toLowerCase()==="input"&&typeof a.select=="function"},v6=function(a){return(a==null?void 0:a.key)==="Escape"||(a==null?void 0:a.key)==="Esc"||(a==null?void 0:a.keyCode)===27},yi=function(a){return(a==null?void 0:a.key)==="Tab"||(a==null?void 0:a.keyCode)===9},g6=function(a){return yi(a)&&!a.shiftKey},b6=function(a){return yi(a)&&a.shiftKey},Eu=function(a){return setTimeout(a,0)},ai=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},pr=function(a){return a.target.shadowRoot&&typeof a.composedPath=="function"?a.composedPath()[0]:a.target},y6=[],w6=function(a,t){var n=(t==null?void 0:t.document)||document,i=(t==null?void 0:t.trapStack)||y6,r=ku({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:g6,isKeyBackward:b6},t),s={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,manuallyPaused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},l,d=function(y,R,U){return y&&y[R]!==void 0?y[R]:r[U||R]},c=function(y,R){var U=typeof(R==null?void 0:R.composedPath)=="function"?R.composedPath():void 0;return s.containerGroups.findIndex(function(z){var W=z.container,B=z.tabbableNodes;return W.contains(y)||(U==null?void 0:U.includes(W))||B.find(function(P){return P===y})})},u=function(y){var R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},U=R.hasFallback,z=U===void 0?!1:U,W=R.params,B=W===void 0?[]:W,P=r[y];if(typeof P=="function"&&(P=P.apply(void 0,u6(B))),P===!0&&(P=void 0),!P){if(P===void 0||P===!1)return P;throw new Error("`".concat(y,"` was specified but was not a node, or did not return a node"))}var X=P;if(typeof P=="string"){try{X=n.querySelector(P)}catch(K){throw new Error("`".concat(y,'` appears to be an invalid selector; error="').concat(K.message,'"'))}if(!X&&!z)throw new Error("`".concat(y,"` as selector refers to no known node"))}return X},f=function(){var y=u("initialFocus",{hasFallback:!0});if(y===!1)return!1;if(y===void 0||y&&!tl(y,r.tabbableOptions))if(c(n.activeElement)>=0)y=n.activeElement;else{var R=s.tabbableGroups[0],U=R&&R.firstTabbableNode;y=U||u("fallbackFocus")}else y===null&&(y=u("fallbackFocus"));if(!y)throw new Error("Your focus-trap needs to have at least one focusable element");return y},m=function(){if(s.containerGroups=s.containers.map(function(y){var R=o6(y,r.tabbableOptions),U=i6(y,r.tabbableOptions),z=R.length>0?R[0]:void 0,W=R.length>0?R[R.length-1]:void 0,B=U.find(function(K){return bo(K)}),P=U.slice().reverse().find(function(K){return bo(K)}),X=!!R.find(function(K){return zn(K)>0});return{container:y,tabbableNodes:R,focusableNodes:U,posTabIndexesFound:X,firstTabbableNode:z,lastTabbableNode:W,firstDomTabbableNode:B,lastDomTabbableNode:P,nextTabbableNode:function(be){var Ne=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,ue=R.indexOf(be);return ue<0?Ne?U.slice(U.indexOf(be)+1).find(function(re){return bo(re)}):U.slice(0,U.indexOf(be)).reverse().find(function(re){return bo(re)}):R[ue+(Ne?1:-1)]}}}),s.tabbableGroups=s.containerGroups.filter(function(y){return y.tabbableNodes.length>0}),s.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(s.containerGroups.find(function(y){return y.posTabIndexesFound})&&s.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.")},p=function(y){var R=y.activeElement;if(R)return R.shadowRoot&&R.shadowRoot.activeElement!==null?p(R.shadowRoot):R},h=function(y){if(y!==!1&&y!==p(document)){if(!y||!y.focus){h(f());return}y.focus({preventScroll:!!r.preventScroll}),s.mostRecentlyFocusedNode=y,h6(y)&&y.select()}},v=function(y){var R=u("setReturnFocus",{params:[y]});return R||(R===!1?!1:y)},w=function(y){var R=y.target,U=y.event,z=y.isBackward,W=z===void 0?!1:z;R=R||pr(U),m();var B=null;if(s.tabbableGroups.length>0){var P=c(R,U),X=P>=0?s.containerGroups[P]:void 0;if(P<0)W?B=s.tabbableGroups[s.tabbableGroups.length-1].lastTabbableNode:B=s.tabbableGroups[0].firstTabbableNode;else if(W){var K=s.tabbableGroups.findIndex(function(D){var J=D.firstTabbableNode;return R===J});if(K<0&&(X.container===R||tl(R,r.tabbableOptions)&&!bo(R,r.tabbableOptions)&&!X.nextTabbableNode(R,!1))&&(K=P),K>=0){var be=K===0?s.tabbableGroups.length-1:K-1,Ne=s.tabbableGroups[be];B=zn(R)>=0?Ne.lastTabbableNode:Ne.lastDomTabbableNode}else yi(U)||(B=X.nextTabbableNode(R,!1))}else{var ue=s.tabbableGroups.findIndex(function(D){var J=D.lastTabbableNode;return R===J});if(ue<0&&(X.container===R||tl(R,r.tabbableOptions)&&!bo(R,r.tabbableOptions)&&!X.nextTabbableNode(R))&&(ue=P),ue>=0){var re=ue===s.tabbableGroups.length-1?0:ue+1,O=s.tabbableGroups[re];B=zn(R)>=0?O.firstTabbableNode:O.firstDomTabbableNode}else yi(U)||(B=X.nextTabbableNode(R))}}else B=u("fallbackFocus");return B},E=function(y){var R=pr(y);if(!(c(R,y)>=0)){if(ai(r.clickOutsideDeactivates,y)){l.deactivate({returnFocus:r.returnFocusOnDeactivate});return}ai(r.allowOutsideClick,y)||y.preventDefault()}},S=function(y){var R=pr(y),U=c(R,y)>=0;if(U||R instanceof Document)U&&(s.mostRecentlyFocusedNode=R);else{y.stopImmediatePropagation();var z,W=!0;if(s.mostRecentlyFocusedNode)if(zn(s.mostRecentlyFocusedNode)>0){var B=c(s.mostRecentlyFocusedNode),P=s.containerGroups[B].tabbableNodes;if(P.length>0){var X=P.findIndex(function(K){return K===s.mostRecentlyFocusedNode});X>=0&&(r.isKeyForward(s.recentNavEvent)?X+1<P.length&&(z=P[X+1],W=!1):X-1>=0&&(z=P[X-1],W=!1))}}else s.containerGroups.some(function(K){return K.tabbableNodes.some(function(be){return zn(be)>0})})||(W=!1);else W=!1;W&&(z=w({target:s.mostRecentlyFocusedNode,isBackward:r.isKeyBackward(s.recentNavEvent)})),h(z||s.mostRecentlyFocusedNode||f())}s.recentNavEvent=void 0},k=function(y){var R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;s.recentNavEvent=y;var U=w({event:y,isBackward:R});U&&(yi(y)&&y.preventDefault(),h(U))},b=function(y){(r.isKeyForward(y)||r.isKeyBackward(y))&&k(y,r.isKeyBackward(y))},$=function(y){v6(y)&&ai(r.escapeDeactivates,y)!==!1&&(y.preventDefault(),l.deactivate())},V=function(y){var R=pr(y);c(R,y)>=0||ai(r.clickOutsideDeactivates,y)||ai(r.allowOutsideClick,y)||(y.preventDefault(),y.stopImmediatePropagation())},I=function(){if(s.active)return _u.activateTrap(i,l),s.delayInitialFocusTimer=r.delayInitialFocus?Eu(function(){h(f())}):h(f()),n.addEventListener("focusin",S,!0),n.addEventListener("mousedown",E,{capture:!0,passive:!1}),n.addEventListener("touchstart",E,{capture:!0,passive:!1}),n.addEventListener("click",V,{capture:!0,passive:!1}),n.addEventListener("keydown",b,{capture:!0,passive:!1}),n.addEventListener("keydown",$),l},x=function(){if(s.active)return n.removeEventListener("focusin",S,!0),n.removeEventListener("mousedown",E,!0),n.removeEventListener("touchstart",E,!0),n.removeEventListener("click",V,!0),n.removeEventListener("keydown",b,!0),n.removeEventListener("keydown",$),l},N=function(y){var R=y.some(function(U){var z=Array.from(U.removedNodes);return z.some(function(W){return W===s.mostRecentlyFocusedNode})});R&&h(f())},L=typeof window<"u"&&"MutationObserver"in window?new MutationObserver(N):void 0,C=function(){L&&(L.disconnect(),s.active&&!s.paused&&s.containers.map(function(y){L.observe(y,{subtree:!0,childList:!0})}))};return l={get active(){return s.active},get paused(){return s.paused},activate:function(y){if(s.active)return this;var R=d(y,"onActivate"),U=d(y,"onPostActivate"),z=d(y,"checkCanFocusTrap");z||m(),s.active=!0,s.paused=!1,s.nodeFocusedBeforeActivation=p(n),R==null||R();var W=function(){z&&m(),I(),C(),U==null||U()};return z?(z(s.containers.concat()).then(W,W),this):(W(),this)},deactivate:function(y){if(!s.active)return this;var R=ku({onDeactivate:r.onDeactivate,onPostDeactivate:r.onPostDeactivate,checkCanReturnFocus:r.checkCanReturnFocus},y);clearTimeout(s.delayInitialFocusTimer),s.delayInitialFocusTimer=void 0,x(),s.active=!1,s.paused=!1,C(),_u.deactivateTrap(i,l);var U=d(R,"onDeactivate"),z=d(R,"onPostDeactivate"),W=d(R,"checkCanReturnFocus"),B=d(R,"returnFocus","returnFocusOnDeactivate");U==null||U();var P=function(){Eu(function(){B&&h(v(s.nodeFocusedBeforeActivation)),z==null||z()})};return B&&W?(W(v(s.nodeFocusedBeforeActivation)).then(P,P),this):(P(),this)},pause:function(y){return s.active?(s.manuallyPaused=!0,this._setPausedState(!0,y)):this},unpause:function(y){return s.active?(s.manuallyPaused=!1,i[i.length-1]!==this?this:this._setPausedState(!1,y)):this},updateContainerElements:function(y){var R=[].concat(y).filter(Boolean);return s.containers=R.map(function(U){return typeof U=="string"?n.querySelector(U):U}),s.active&&m(),C(),this}},Object.defineProperties(l,{_isManuallyPaused:{value:function(){return s.manuallyPaused}},_setPausedState:{value:function(y,R){if(s.paused===y)return this;if(s.paused=y,y){var U=d(R,"onPause"),z=d(R,"onPostPause");U==null||U(),x(),C(),z==null||z()}else{var W=d(R,"onUnpause"),B=d(R,"onPostUnpause");W==null||W(),m(),I(),C(),B==null||B()}return this}}}),l.updateContainerElements(a),l};const k6=["aria-labelledby"],_6={class:"media-preview-sheet__header"},E6=["id"],x6=["aria-label"],S6=["src","alt"],C6=["src"],V6={class:"media-preview-sheet__actions"},N6=["disabled","aria-label"],T6=["aria-label","aria-pressed"],B6=["disabled","aria-label"],I6=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),s=e.ref(null);let l=null,d=null;const c=e.computed(()=>{var L;return((L=t.media)==null?void 0:L.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,f=/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i,m=e.computed(()=>t.media?t.media.preview_url??t.media.original_url:"");function p(L){const C=L.replace(/\.[^.]+$/,""),y=C.replace(u,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim();return y!==""?y:C||L}function h(L){var R,U;const C=(R=L.name)==null?void 0:R.trim(),T=L.file_name.replace(/\.[^.]+$/,"");if(C!==void 0&&C!==""&&C!==L.file_name&&C!==T&&!f.test(C))return C;const y=(U=L.alt_text)==null?void 0:U.trim();return y!==void 0&&y!==""?y:p(C||L.file_name)}const v=e.computed(()=>t.media?h(t.media):"media"),w=e.computed(()=>t.media?`Preview ${v.value}`:"Media preview"),E=e.computed(()=>t.media?`Close preview of ${v.value}`:"Close preview"),S=e.computed(()=>t.canGoPrevious?"Previous media":"No previous media"),k=e.computed(()=>t.canGoNext?"Next media":"No next media"),b=e.computed(()=>{const L=t.selected?t.deselectLabel:t.selectLabel;return t.media?t.selected?`${t.deselectLabel} ${v.value}`:`${t.selectLabel} ${v.value}`:L}),$=e.computed(()=>t.selected?t.deselectLabel:t.selectLabel),V=()=>{t.media&&n("toggleSelect",t.media)},I=L=>{if(L.key==="Escape"){L.preventDefault(),n("close");return}if(L.key==="ArrowLeft"&&t.canGoPrevious){L.preventDefault(),n("previous");return}L.key==="ArrowRight"&&t.canGoNext&&(L.preventDefault(),n("next"))},x=()=>{if(l){try{l.deactivate({returnFocus:!1})}catch{}l=null}},N=()=>{const L=d;d=null,L&&typeof L.focus=="function"&&e.nextTick(()=>{L.focus()})};return e.watch(()=>t.open&&t.media!==null,async L=>{var C;if(L){d=document.activeElement instanceof HTMLElement?document.activeElement:null,await e.nextTick();const T=r.value;if(T)try{l=w6(T,{initialFocus:()=>s.value??T,escapeDeactivates:!1,clickOutsideDeactivates:!1,returnFocusOnDeactivate:!1,allowOutsideClick:!0}),l.activate()}catch{(C=s.value)==null||C.focus()}}else x(),N()},{immediate:!0}),e.onBeforeUnmount(()=>{x()}),(L,C)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[L.open&&L.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",_6,[e.createElementVNode("strong",{id:e.unref(i),"data-testid":"media-preview-sheet-title"},e.toDisplayString(w.value),9,E6),e.createElementVNode("button",{ref_key:"closeButtonRef",ref:s,type:"button",class:"media-preview-sheet__close","aria-label":E.value,"data-testid":"btn-media-preview-close",onClick:C[0]||(C[0]=T=>n("close"))},e.toDisplayString(L.closeLabel),9,x6)]),c.value?(e.openBlock(),e.createElementBlock("img",{key:0,class:"media-preview-sheet__image",src:m.value,alt:L.media.alt_text||v.value},null,8,S6)):(e.openBlock(),e.createElementBlock("video",{key:1,class:"media-preview-sheet__video",src:m.value,controls:""},null,8,C6)),e.createElementVNode("div",V6,[e.createElementVNode("button",{type:"button",class:"media-preview-sheet__nav",disabled:!L.canGoPrevious,"aria-label":S.value,"data-testid":"btn-media-preview-previous",onClick:C[1]||(C[1]=T=>n("previous"))},e.toDisplayString(L.previousLabel),9,N6),e.createElementVNode("button",{type:"button",class:"media-preview-sheet__select","aria-label":b.value,"aria-pressed":L.selected,"data-testid":"btn-media-preview-select",onClick:V},e.toDisplayString($.value),9,T6),e.createElementVNode("button",{type:"button",class:"media-preview-sheet__nav",disabled:!L.canGoNext,"aria-label":k.value,"data-testid":"btn-media-preview-next",onClick:C[2]||(C[2]=T=>n("next"))},e.toDisplayString(L.nextLabel),9,B6)])],40,k6)):e.createCommentVNode("",!0)]))}}),Cd=Fe(I6,[["__scopeId","data-v-fa05530d"]]),M6={key:0,class:"media-album-grid","data-testid":"media-source-sheet"},F6={class:"media-album-grid__items"},$6={class:"media-album-grid__card-name"},D6={class:"media-album-grid__card-name"},R6=["data-testid","onClick"],A6={class:"media-album-grid__card-name"},L6={key:0,class:"media-album-grid__card-meta"},P6={key:0,class:"media-album-grid__empty"},U6=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",M6,[e.createElementVNode("div",F6,[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",$6,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",D6,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:s=>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",A6,e.toDisplayString(r.name),1),r.mediaCount!==void 0?(e.openBlock(),e.createElementBlock("span",L6,e.toDisplayString(r.mediaCount)+" item"+e.toDisplayString(r.mediaCount===1?"":"s"),1)):e.createCommentVNode("",!0)],10,R6))),128))]),n.albums.length===0?(e.openBlock(),e.createElementBlock("p",P6," No albums yet. ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}}),af=Fe(U6,[["__scopeId","data-v-129f67b1"]]),O6={key:0,class:"media-upload-sheet","data-testid":"media-upload-sheet"},z6={class:"media-upload-sheet__dropzone-text"},j6={key:0,class:"media-upload-sheet__dropzone-helper","data-testid":"text-media-upload-sheet-helper"},W6={class:"media-upload-sheet__sr-only"},H6=["accept","aria-label"],Z6=["aria-label"],G6={class:"media-upload-sheet__queue-row"},X6={key:0,class:"media-upload-sheet__preview"},K6=["src","alt","data-testid"],J6={class:"media-upload-sheet__queue-body"},q6={class:"media-upload-sheet__queue-info"},Y6={class:"media-upload-sheet__queue-status"},Q6=["aria-valuenow","aria-label","data-testid"],e8=["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=m=>{var h;return t.progressAriaLabel!==void 0?t.progressAriaLabel(m):`Uploading ${((h=m.file)==null?void 0:h.name)??"file"}`},s=m=>{const p=Number.isFinite(m.progress)?m.progress:0;return p<0?0:p>100?100:Math.round(p)},l=e.computed(()=>t.queue.length===0?"":`${t.queue.length} upload${t.queue.length===1?"":"s"} in progress`),d=m=>{const p=m.target;!(p instanceof HTMLInputElement)||p.files===null||(n("filesSelected",Array.from(p.files)),p.value="")},c=m=>{m.preventDefault(),i.value=!0},u=()=>{i.value=!1},f=m=>{var p;m.preventDefault(),i.value=!1,(p=m.dataTransfer)!=null&&p.files&&m.dataTransfer.files.length>0&&n("filesSelected",Array.from(m.dataTransfer.files))};return(m,p)=>m.open?(e.openBlock(),e.createElementBlock("section",O6,[e.createElementVNode("label",{class:e.normalizeClass(["media-upload-sheet__dropzone",{"is-drag-over":i.value}]),onDragover:c,onDragleave:u,onDrop:f},[p[1]||(p[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",z6,e.toDisplayString(m.dropzoneLabel),1),m.dropzoneHelperText?(e.openBlock(),e.createElementBlock("span",j6,e.toDisplayString(m.dropzoneHelperText),1)):e.createCommentVNode("",!0),e.createElementVNode("span",W6,e.toDisplayString(m.fileInputLabel),1),e.createElementVNode("input",{type:"file",accept:m.accept,multiple:"",class:"media-upload-sheet__file-input","data-testid":"input-media-upload-sheet","aria-label":m.fileInputLabel,onChange:d},null,40,H6)],34),m.queue.length>0?(e.openBlock(),e.createElementBlock("ul",{key:0,class:"media-upload-sheet__queue","aria-live":"polite","aria-label":l.value,"data-testid":"list-media-upload-sheet-queue"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.queue,h=>(e.openBlock(),e.createElementBlock("li",{key:h.id,class:"media-upload-sheet__queue-item"},[e.createElementVNode("div",G6,[h.previewUrl?(e.openBlock(),e.createElementBlock("div",X6,[e.createElementVNode("img",{src:h.previewUrl,alt:`Preview of ${h.file.name}`,"data-testid":`img-media-upload-sheet-preview-${h.id}`},null,8,K6)])):e.createCommentVNode("",!0),e.createElementVNode("div",J6,[e.createElementVNode("div",q6,[e.createElementVNode("strong",null,e.toDisplayString(h.file.name),1),e.createElementVNode("span",Y6,e.toDisplayString(h.status),1)]),e.createElementVNode("div",{class:"media-upload-sheet__progress-bar",role:"progressbar","aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":s(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:`${s(h)}%`})},null,4)],8,Q6)])])]))),128))],8,Z6)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"media-upload-sheet__close-btn","aria-label":m.closeButtonAriaLabel,"data-testid":"btn-close-upload-sheet",onClick:p[0]||(p[0]=h=>n("close"))},e.toDisplayString(m.closeButtonLabel),9,e8)])):e.createCommentVNode("",!0)}}),nf=Fe(t8,[["__scopeId","data-v-df614629"]]),a8=["aria-label","aria-pressed","data-testid"],n8=["src","alt"],o8={key:1,class:"media-thumbnail-cell__video"},i8={class:"media-thumbnail-cell__video-name"},r8={key:2,class:"media-thumbnail-cell__selected-badge"},s8={key:3,class:"media-thumbnail-cell__status-badge"},l8=["aria-label"],d8=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/")),s=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}}),l=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,f)=>(e.openBlock(),e.createElementBlock("article",{class:e.normalizeClass(["media-thumbnail-cell",{"is-selected":u.selected,"has-status":s.value!==null}])},[e.createElementVNode("button",{type:"button",class:"media-thumbnail-cell__button","aria-label":l.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,n8)):(e.openBlock(),e.createElementBlock("div",o8,[f[0]||(f[0]=e.createElementVNode("span",{class:"media-thumbnail-cell__video-label"},"Video",-1)),e.createElementVNode("span",i8,e.toDisplayString(u.media.file_name),1)])),u.selected?(e.openBlock(),e.createElementBlock("span",r8," Selected ")):e.createCommentVNode("",!0),s.value!==null?(e.openBlock(),e.createElementBlock("span",s8,e.toDisplayString(s.value),1)):e.createCommentVNode("",!0)],8,a8),e.createElementVNode("button",{type:"button",class:"media-thumbnail-cell__preview-button","aria-label":`Preview ${u.media.file_name}`,onClick:c}," Preview ",8,l8)],2))}}),of=Fe(d8,[["__scopeId","data-v-edd4f0ad"]]),c8={class:"virtual-media-grid"},u8={key:0,class:"virtual-media-grid__state","data-testid":"media-grid-loading"},m8={key:1,class:"virtual-media-grid__state","data-testid":"media-grid-empty"},p8={key:2,class:"virtual-media-grid__items"},f8=["disabled"],h8=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(s=>s.id===r)}return(r,s)=>(e.openBlock(),e.createElementBlock("div",c8,[r.loading&&r.items.length===0?(e.openBlock(),e.createElementBlock("div",u8,e.toDisplayString(r.loadingMessage),1)):r.items.length===0?(e.openBlock(),e.createElementBlock("div",m8,e.toDisplayString(r.emptyMessage),1)):(e.openBlock(),e.createElementBlock("div",p8,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,l=>{var d,c;return e.openBlock(),e.createBlock(of,{key:l.uuid,media:l,selected:((d=i(l.uuid))==null?void 0:d.status)==="ready",status:(c=i(l.uuid))==null?void 0:c.status,"test-id":`${r.testIdPrefix}-${l.uuid}`,onToggle:s[0]||(s[0]=u=>n("toggle",u)),onPreview:s[1]||(s[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:s[2]||(s[2]=l=>n("loadMore"))},e.toDisplayString(r.loadingMore?r.loadingMoreLabel:r.loadMoreLabel),9,f8)):e.createCommentVNode("",!0)]))}}),rf=Fe(h8,[["__scopeId","data-v-34667f65"]]);function Gr(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 sf(o){var t;const a=o.split(".");return a.length>1?`.${(t=a.pop())==null?void 0:t.toLowerCase()}`:""}function Vd(o){return o.type.startsWith("image/")}async function lf(o){return Vd(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 df(o,a){const t=[];if(a.maxFileSize&&o.size>a.maxFileSize&&t.push({field:"size",message:`File exceeds maximum size of ${Gr(a.maxFileSize)}`,code:"MAX_FILE_SIZE"}),a.minFileSize&&o.size<a.minFileSize&&t.push({field:"size",message:`File is smaller than minimum size of ${Gr(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=sf(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(Vd(o)&&(a.maxDimensions||a.minDimensions)){const n=await lf(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 Nd(o={}){const a=e.ref(o.rules||{});function t(d){a.value=d}async function n(d){return df(d,a.value)}async function i(d){const c=new Map;return await Promise.all(d.map(async u=>{const f=await n(u);c.set(u,f)})),c}function r(d,c){return a.value.maxItems?c+d<=a.value.maxItems:!0}const s=e.computed(()=>{const d=[];return a.value.acceptedMimeTypes&&d.push(...a.value.acceptedMimeTypes),a.value.acceptedExtensions&&d.push(...a.value.acceptedExtensions),d.join(",")});function l(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:s,isMimeTypeAllowed:l}}function v8(){return`upload-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function g8(o){if(o.type.startsWith("image/"))return URL.createObjectURL(o)}function Td(o){const{adapter:a,maxConcurrent:t=3,rules:n,collection:i,onUploadStart:r,onUploadProgress:s,onUploadComplete:l,onUploadError:d,onQueueComplete:c,postUpload:u}=o,f=e.ref(new Map),m=e.ref(new Set),p=n?{rules:n}:{},{validateFile:h}=Nd(p);async function v(){if(m.value.size>=t)return;const T=Array.from(f.value.entries()).find(([U,z])=>z.status==="pending"&&!m.value.has(U));if(!T){Array.from(f.value.values()).every(z=>z.status==="completed"||z.status==="error")&&f.value.size>0&&(c==null||c());return}const[y,R]=T;await w(y,R)}async function w(T,y){m.value.add(T),y.status="uploading",y.abortController=new AbortController,f.value.set(T,{...y}),r==null||r(y);try{const R={onProgress:z=>{y.progress=z,f.value.set(T,{...y}),s==null||s(y)},signal:y.abortController.signal};i&&(R.collection=i);const U=await a.upload(y.file,R);u&&(y.status="attaching",f.value.set(T,{...y}),s==null||s(y),await u(y,U.media,a)),y.status="completed",y.progress=100,y.media=U.media,f.value.set(T,{...y}),l==null||l(y,U.media)}catch(R){R.name==="AbortError"?f.value.delete(T):(y.status="error",y.error=R.message,f.value.set(T,{...y}),d==null||d(y,R))}finally{m.value.delete(T),delete y.abortController,v()}}async function E(T){var U;const y=Array.from(T),R=[];for(const z of y){const W=await h(z),B=v8(),P=g8(z),X={id:B,file:z,progress:0,status:W.valid?"pending":"error"};!W.valid&&((U=W.errors[0])!=null&&U.message)&&(X.error=W.errors[0].message),P&&(X.previewUrl=P),f.value.set(B,X);const K={media:null,clientId:B,name:z.name,order:0,upload:X,errors:W.errors};R.push(K)}for(let z=0;z<t;z++)v();return R}function S(T){const y=f.value.get(T);y&&(y.abortController&&y.abortController.abort(),y.previewUrl&&URL.revokeObjectURL(y.previewUrl),f.value.delete(T),m.value.delete(T),v())}async function k(T){const y=f.value.get(T);!y||y.status!=="error"||(y.status="pending",y.progress=0,delete y.error,f.value.set(T,{...y}),v())}function b(){for(const[T,y]of f.value.entries())(y.status==="completed"||y.status==="error")&&(y.previewUrl&&URL.revokeObjectURL(y.previewUrl),f.value.delete(T))}function $(){for(const T of f.value.values())T.abortController&&T.abortController.abort(),T.previewUrl&&URL.revokeObjectURL(T.previewUrl);f.value.clear(),m.value.clear()}function V(T){return f.value.get(T)}const I=e.computed(()=>m.value.size>0),x=e.computed(()=>m.value.size),N=e.computed(()=>Array.from(f.value.values()).filter(T=>T.status==="pending").length),L=e.computed(()=>f.value.size===0?!0:Array.from(f.value.values()).every(T=>T.status==="completed"||T.status==="error")),C=e.computed(()=>Array.from(f.value.values()));return{uploads:f,isUploading:I,activeCount:x,pendingCount:N,isComplete:L,addFiles:E,cancelUpload:S,retryUpload:k,clearCompleted:b,clearAll:$,getUpload:V,uploadsArray:C}}function Qn(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}function Vi(o){return typeof o=="string"?o:null}function xu(o){return typeof o=="number"?o:null}function b8(o){return typeof o=="boolean"?o:null}function cf(o){return Qn(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 y8(o){return!Qn(o)||typeof o.id!="string"||typeof o.status!="string"?null:o.status==="ready"?cf(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 w8(o){return Qn(o)?{next_cursor:Vi(o.next_cursor),previous_cursor:Vi(o.previous_cursor),has_more:b8(o.has_more)??!1,per_page:xu(o.per_page),count:xu(o.count)}:null}function Su(o){const a=Qn(o)?o:{},t=Array.isArray(a.data)?a.data.filter(cf):[],n=Qn(a.meta)?a.meta:{},i=w8(n.pagination),r=(i==null?void 0:i.next_cursor)??Vi(n.next_cursor)??Vi(n.cursor),s=(i==null?void 0:i.has_more)??n.has_more===!0,l=Array.isArray(a.hydrated)?a.hydrated.map(y8).filter(c=>c!==null):[],d={cursor:r,has_more:s};return i!==null&&(d.pagination=i),{data:t,meta:d,hydrated:l}}function Cu(o,a,t,n,i){const r={view:o.scope==="album"?{scope:"album",album_id:o.albumId}:{scope:"library"},per_page:t,sort:a.sort??"newest"};return a.query&&a.query.trim()!==""&&(r.query=a.query.trim()),a.kinds&&a.kinds.length>0&&(r.kinds=a.kinds),n!==null&&(r.cursor=n),i&&i.length>0&&(r.hydrate_ids=i),r}function Vu(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 _8(o){var a;return o instanceof Error?((a=o.response)==null?void 0:a.data)??null:null}function E8(o){if(!Qn(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 x8(o){var r;const a=_8(o),t=Qn(a)?a:null,n=((r=Vi(t==null?void 0:t.message))==null?void 0:r.trim())??null,i=E8(t==null?void 0:t.errors);return n!==null&&i.length>0?n==="Validation failed"?i.join(" "):i.every(l=>n.includes(l))?n:`${n} ${i.join(" ")}`:n!==null?n:i.length>0?i.join(" "):o instanceof Error?o.message:"Failed to load media."}function Nu(o,a){const t=x8(a),n=k8(a);return{code:n===403?"permission_denied":o,message:t,retriable:n!==403,cause:a}}function Bd(o){const a=o.perPage??40,t=e.ref([]),n=e.ref([]),i=e.ref(null),r=e.ref(!1),s=e.ref(!1),l=e.ref(!1),d=e.ref(!1),c=e.ref(null);let u=null,f=0;const m=async v=>{f+=1;const w=f;u==null||u.abort();const E=new AbortController;u=E,v?l.value=!0:s.value=!0,c.value=null,d.value=!1;try{const S=await o.httpClient.get("/v1/media/library",{params:Cu(o.view.value,o.filters.value,a,v?i.value:null),signal:E.signal});if(w!==f)return;const k=Su(S);t.value=v?Vu([...t.value,...k.data]):k.data,n.value=k.hydrated,i.value=k.meta.cursor,r.value=k.meta.has_more}catch(S){if(E.signal.aborted||w!==f)return;const k=Nu(v?"load_more_failed":"query_failed",S);c.value=k,d.value=k.code==="permission_denied",v||(t.value=[],i.value=null,r.value=!1)}finally{w===f&&(s.value=!1,l.value=!1)}};return{items:t,hydrated:n,cursor:i,hasMore:r,loading:s,loadingMore:l,permissionDenied:d,error:c,loadInitial:async()=>{i.value=null,await m(!1)},loadMore:async()=>{!r.value||l.value||await m(!0)},refresh:async()=>{i.value=null,await m(!1)},hydrateSelection:async v=>{if(v.length===0)return n.value=[],[];try{const w=await o.httpClient.get("/v1/media/library",{params:Cu(o.view.value,o.filters.value,1,null,v)}),E=Su(w);return n.value=E.hydrated,E.hydrated}catch(w){return c.value=Nu("hydration_failed",w),[]}},prepend:v=>{t.value=Vu([v,...t.value])}}}const S8="mediables.media-library.";function C8(o){return!o||o.key.trim()===""?null:`${S8}${o.key}`}function al(){return typeof window>"u"||typeof window.sessionStorage>"u"?null:window.sessionStorage}function V8(o,a){const t=Date.parse(o);return Number.isFinite(t)?Date.now()-t>a*60*1e3:!0}function uf(o){const a=C8(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 l=al();if(l===null)return null;const d=l.getItem(a);if(d===null)return null;let c;try{c=JSON.parse(d)}catch{return l.removeItem(a),null}if(typeof c!="object"||c===null||Array.isArray(c))return l.removeItem(a),null;const u=c;if(u.version!==1||typeof u.savedAt!="string"||V8(u.savedAt,t))return l.removeItem(a),null;const f={selectedIds:Array.isArray(u.selectedIds)?u.selectedIds.filter(m=>typeof m=="string"&&m.trim()!==""):[]};return((o==null?void 0:o.restoreView)??!0)&&u.view&&(f.view=u.view),u.filters&&(f.filters=u.filters),f},save:l=>{if(a===null)return;const d=al();if(d===null)return;const c={version:1,savedAt:new Date().toISOString(),selectedIds:[...l.selectedIds]};((o==null?void 0:o.restoreView)??!0)&&l.view&&(c.view=l.view),l.filters&&(c.filters=l.filters),d.setItem(a,JSON.stringify(c))},clear:()=>{if(a===null)return;const l=al();l==null||l.removeItem(a)},sessionId:n}}function mf(o){const a=e.ref(o);return{state:a,transition:n=>{a.value=n}}}function pf(o){return{emitMetric:(t,n)=>{const i={name:t,timestamp:new Date().toISOString()};n!==void 0&&(i.payload=n),o==null||o(i)}}}function xo(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}function N8(o){const a=xo(o)?o:{};return(Array.isArray(a.data)?a.data:xo(a.data)&&Array.isArray(a.data.data)?a.data.data:Array.isArray(o)?o:[]).map(n=>{if(!xo(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 T8(o){const a=xo(o)?o:{},t=xo(a.data)?a.data:xo(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 B8(o){return o==="ready"||o==="uploading"||o==="failed"}function Dn(o,a="ready"){return{id:o.uuid,media:o,status:a,countsTowardMax:B8(a)}}function I8(o,a){return o.scope==="library"?!0:a.type==="album"&&a.albumId===o.albumId}function M8(o,a){return o.scope==="library"?a.type==="library"||a.type==="album":a.type==="album"&&a.albumId===o.albumId}function nl(o){return{code:"configuration_error",message:o,retriable:!1}}const ff="/v1/albums";function F8(o){var a;return((a=o.deps.albumEndpoints)==null?void 0:a.list)??ff}function $8(o){var a,t;return((a=o.deps.albumEndpoints)==null?void 0:a.create)??((t=o.deps.albumEndpoints)==null?void 0:t.list)??ff}function D8(o){return typeof o!="string"||o.length===0?"document":o.startsWith("image/")?"image":o.startsWith("video/")?"video":o.startsWith("audio/")?"audio":"document"}function R8(o,a){return a.length===0||o===null?!0:a.includes(D8(o.mime_type))}function hf(o){var O,D,J;const a=o.selectionMode??"multiple",t=o.maxSelection,n=o.uploadBehavior??"adapter",i=e.ref(o.initialView??{scope:"library"}),r=((O=o.initialFilters)==null?void 0:O.kinds)??(o.allowedMediaKinds&&o.allowedMediaKinds.length>0?[...o.allowedMediaKinds]:void 0),s=e.ref({sort:((D=o.initialFilters)==null?void 0:D.sort)??"newest",...(J=o.initialFilters)!=null&&J.query?{query:o.initialFilters.query}:{},...r?{kinds:r}:{}}),l=o.allowedMediaKinds?[...o.allowedMediaKinds]:[],d=e.ref([]),c=e.ref([]),u=e.ref(null),f=e.ref(null),m=uf(o.sessionPolicy),{emitMetric:p}=pf(o.telemetry),h=mf("idle"),v=Bd({httpClient:o.deps.httpClient,view:i,filters:s}),w=e.computed(()=>c.value.map(Z=>Z.id)),E=e.computed(()=>{const Z=u.value;return Z===null?null:v.items.value[Z]??null}),S=e.computed(()=>o.uploadTarget??{type:"library"}),k=Td({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:Z=>Z.original_url,getThumbnailUrl:Z=>Z.thumbnail_url??Z.preview_url??Z.original_url},postUpload:async(Z,ie,se)=>{const Ue=S.value;Ue.type!=="album"||!Ue.albumId||await se.attach(ie.uuid,{modelType:"album",modelId:Ue.albumId})},onUploadComplete:(Z,ie)=>{const se=S.value;I8(i.value,se)&&v.prepend(ie),o.autoSelectUploaded&&M8(i.value,se)&&L(ie),p("upload-complete",{mediaId:ie.uuid,targetType:se.type,targetAlbumId:se.albumId})},onUploadError:(Z,ie)=>{f.value={code:"upload_failed",message:ie.message,retriable:!0,cause:ie}}}),b=e.computed(()=>k.isUploading.value),$=()=>{m.save({selectedIds:[...w.value],view:i.value,filters:s.value})},V=async Z=>{const ie=await v.hydrateSelection(Z);c.value=ie.map(se=>se.status==="ready"&&se.media?Dn(se.media):{id:se.id,media:null,status:se.status,countsTowardMax:!1})},I=e.computed(()=>c.value.filter(Z=>Z.countsTowardMax).length),x=()=>a==="single"||t===void 0?!0:I.value<t,N=Z=>{if(c.value.findIndex(se=>se.id===Z.uuid)>=0){a==="multiple"?c.value=c.value.filter(se=>se.id!==Z.uuid):c.value=[Dn(Z)],$();return}if(!x()){f.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=[Dn(Z)]:c.value=[...c.value,Dn(Z)],f.value=null,$()},L=Z=>{const ie=c.value.findIndex(se=>se.id===Z.uuid);if(ie>=0){c.value=c.value.map((se,Ue)=>Ue===ie?Dn(Z):se),f.value=null,$();return}if(!x()){f.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=[Dn(Z)]:c.value=[...c.value,Dn(Z)],f.value=null,$()},C=async()=>{var ie;h.transition("restoring");const Z=m.restore();if(Z===null){h.transition("ready");return}Z.view&&(i.value=Z.view),Z.filters&&(s.value={sort:Z.filters.sort??"newest",...Z.filters.query?{query:Z.filters.query}:{},...Z.filters.kinds?{kinds:Z.filters.kinds}:{}}),await v.loadInitial(),(((ie=o.sessionPolicy)==null?void 0:ie.restoreSelection)??!0)&&await V(Z.selectedIds),h.transition("ready")};e.watch(()=>v.error.value,Z=>{Z!==null&&(f.value=Z,h.transition("error"))});const T=async()=>{f.value=null,h.transition("idle"),await C(),v.items.value.length===0&&!v.loading.value&&!v.permissionDenied.value&&await v.loadInitial();const Z=o.defaultSelectedIds??[];c.value.length===0&&Z.length>0&&await V(Z),h.transition("ready")},y=async(Z,ie="user")=>{const se=i.value;i.value=Z,ie==="user"&&o.preserveSelectionOnViewChange===!1&&(c.value=[]),p("view-change",{from:se.scope,to:Z.scope,reason:ie}),await v.loadInitial(),$()},R=async()=>{const Z=await o.deps.httpClient.get(F8(o));d.value=N8(Z)},U=async(Z,ie)=>{try{const se={name:Z,visibility:"private"};ie&&ie.trim()!==""&&(se.parent_id=ie);const Ue=await o.deps.httpClient.post($8(o),se),me=T8(Ue);return me===null?nl("Album creation response was invalid."):(d.value=[me,...d.value.filter(ve=>ve.id!==me.id)],await y({scope:"album",albumId:me.id,albumName:me.name},"inline-album-created"),me)}catch(se){const Ue={code:"album_create_failed",message:se instanceof Error?se.message:"Album creation failed.",retriable:!0,cause:se};return f.value=Ue,Ue}},z=async Z=>{if(!o.enableUpload){f.value=nl("Uploads are not enabled for this picker.");return}if(n!=="delegate"){if(!o.deps.uploadAdapter){f.value=nl("Uploads require a configured upload adapter.");return}await k.addFiles(Z)}},W=()=>{var se;if(l.length>0&&c.value.find(me=>me.media!==null&&!R8(me.media,l))){const ve={code:"selection_invalid",message:`Selected media is not allowed here. Choose one of: ${l.join(", ")}.`,retriable:!0};return f.value=ve,ve}const Z=((se=o.validateSelection)==null?void 0:se.call(o,c.value))??null;if(Z!==null){const Ue={code:"selection_invalid",message:Z,retriable:!0};return f.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 f.value=Ue,Ue}return{orderedIds:w.value,items:[...c.value],view:i.value,filters:s.value,dirty:!0,sessionId:m.sessionId}},B=Z=>{const ie=v.items.value.findIndex(se=>se.uuid===Z.uuid);u.value=ie>=0?ie:null},P=()=>{u.value=null},X=()=>{u.value===null||u.value<=0||(u.value-=1)},K=()=>{u.value===null||u.value>=v.items.value.length-1||(u.value+=1)},be=Z=>{c.value=c.value.filter(ie=>ie.id!==Z),$()},Ne=async()=>{await v.refresh()},ue=async Z=>{s.value={...s.value,...Z&&Z.trim()!==""?{query:Z.trim()}:{}},(!Z||Z.trim()==="")&&delete s.value.query,await v.loadInitial(),$()},re=async()=>{await y({scope:"library"},"permission-unavailable")};return{view:i,filters:s,albums:d,selectedItems:c,orderedIds:w,queryItems:v.items,cursor:v.cursor,hasMore:v.hasMore,loading:v.loading,loadingMore:v.loadingMore,permissionDenied:v.permissionDenied,error:f,uploadQueue:k.uploadsArray,isUploading:b,previewIndex:u,previewItem:E,initialize:T,refresh:Ne,loadMore:v.loadMore,setQuery:ue,setView:y,toggleSelection:N,removeSelected:be,confirmSelection:W,openPreview:B,closePreview:P,showPreviousPreview:X,showNextPreview:K,loadAlbums:R,createAlbum:U,addUploadFiles:z,goToLibrary:re,sessionId:m.sessionId}}const A8=["data-testid"],L8={class:"mlp-location-bar"},P8={class:"mlp-location-bar__left"},U8={class:"mlp-location-bar__label"},O8={class:"mlp-tabs","data-testid":"media-picker-tabs"},z8={key:0,class:"mlp-search-row"},j8=["placeholder"],W8={key:2,class:"mlp-overlay-panel"},H8={key:0,class:"mlp-error","data-testid":"media-picker-error"},Z8={key:5,class:"mlp-bottom-bar"},G8={key:0,class:"mlp-bottom-bar__selection"},X8={class:"mlp-bottom-bar__count"},K8={class:"mlp-bottom-bar__thumbs"},J8=["src","alt"],q8={key:1,class:"mlp-bottom-bar__thumb-placeholder"},Y8=["aria-label","onClick"],Q8={class:"mlp-bottom-bar__actions"},e$=e.defineComponent({__name:"MediaLibraryPicker",props:{deps:{},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","view-change","error","metric","request-upload-files"],setup(o,{expose:a,emit:t}){const n=o,i=t,r=e.computed(()=>{var P,X,K,be,Ne,ue,re,O,D,J,Z,ie,se,Ue,me,ve,fe,Ee,ye,Be,Ie,et,tt,Tt,vt,xt,wt,it,_t,ge,ke,Te;return{title:((P=n.labels)==null?void 0:P.title)??"Media library",searchPlaceholder:((X=n.labels)==null?void 0:X.searchPlaceholder)??"Search your media",viewLibrary:((K=n.labels)==null?void 0:K.viewLibrary)??"Library",browseAlbums:((be=n.labels)==null?void 0:be.browseAlbums)??"Albums",createAlbum:((Ne=n.labels)==null?void 0:Ne.createAlbum)??"Create album",createAlbumNameLabel:((ue=n.labels)==null?void 0:ue.createAlbumNameLabel)??"Album name",emptyLibrary:((re=n.labels)==null?void 0:re.emptyLibrary)??"No media found in your library.",emptyAlbum:((O=n.labels)==null?void 0:O.emptyAlbum)??"No media found in this album.",networkError:((D=n.labels)==null?void 0:D.networkError)??"Unable to load media right now.",retry:((J=n.labels)==null?void 0:J.retry)??"Retry",selectedCount:((Z=n.labels)==null?void 0:Z.selectedCount)??(Ke=>`${Ke} selected`),confirmAction:((ie=n.labels)==null?void 0:ie.confirmAction)??"Attach selected",cancel:((se=n.labels)==null?void 0:se.cancel)??"Cancel",dismiss:((Ue=n.labels)==null?void 0:Ue.dismiss)??"Remove",uploadLabel:((me=n.labels)==null?void 0:me.uploadLabel)??"Upload",albumUnavailableTitle:((ve=n.labels)==null?void 0:ve.albumUnavailableTitle)??"Album unavailable",albumUnavailableBody:((fe=n.labels)==null?void 0:fe.albumUnavailableBody)??"You no longer have access to this album.",goToLibrary:((Ee=n.labels)==null?void 0:Ee.goToLibrary)??"Go to library",allMediaTab:((ye=n.labels)==null?void 0:ye.allMediaTab)??"All Media",loadingMedia:((Be=n.labels)==null?void 0:Be.loadingMedia)??"Loading media…",loadMore:((Ie=n.labels)==null?void 0:Ie.loadMore)??"Load more",loadingMore:((et=n.labels)==null?void 0:et.loadingMore)??"Loading…",uploadDropzone:((tt=n.labels)==null?void 0:tt.uploadDropzone)??"Drop files here or browse",uploadDropzoneHelper:((Tt=n.labels)==null?void 0:Tt.uploadDropzoneHelper)??"",uploadDone:((vt=n.labels)==null?void 0:vt.uploadDone)??"Done",uploadDoneAria:((xt=n.labels)==null?void 0:xt.uploadDoneAria)??"Close upload panel",uploadFileInputLabel:((wt=n.labels)==null?void 0:wt.uploadFileInputLabel)??"Choose media files",previewClose:((it=n.labels)==null?void 0:it.previewClose)??"Close preview",previewPrevious:((_t=n.labels)==null?void 0:_t.previewPrevious)??"Previous media",previewNext:((ge=n.labels)==null?void 0:ge.previewNext)??"Next media",previewSelect:((ke=n.labels)==null?void 0:ke.previewSelect)??"Select media",previewDeselect:((Te=n.labels)==null?void 0:Te.previewDeselect)??"Deselect media"}}),s={deps:n.deps,selectionMode:n.selectionMode,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:P=>{var X;(X=n.telemetry)==null||X.call(n,P),i("metric",P)}},l=hf(s),d=e.ref(n.initialFilters.query??""),c=e.ref(n.enableUpload?"upload":"media"),u=e.ref(!1),f=JSON.stringify(n.modelValue.length>0?n.modelValue:n.defaultSelectedIds);let m=null;const p=e.computed(()=>JSON.stringify(l.orderedIds.value)!==f),h=e.computed(()=>l.view.value.scope==="album"?r.value.emptyAlbum:r.value.emptyLibrary),v=e.computed(()=>r.value.selectedCount(l.selectedItems.value.length)),w=e.computed(()=>l.view.value.scope==="album"?l.view.value.albumName??"Album":r.value.viewLibrary),E=e.computed(()=>l.view.value.scope==="album"),S=()=>{m!==null&&(window.clearTimeout(m),m=null)},k=()=>{i("update:modelValue",[...l.orderedIds.value]),i("selection-change",{orderedIds:[...l.orderedIds.value],items:[...l.selectedItems.value],dirty:p.value})},b=P=>{P!==null&&i("error",P)},$=P=>typeof P.code=="string",V=P=>typeof P=="object"&&P!==null&&"code"in P&&typeof P.code=="string",I=()=>{const P=l.confirmSelection();if($(P)){b(P);return}i("confirm",{...P,dirty:p.value})},x=(P="user")=>{i("cancel",{dirty:p.value,reason:P,sessionId:l.sessionId})},N=async()=>{c.value="albums",await l.loadAlbums()},L=async()=>{await l.goToLibrary(),c.value="albums",await l.loadAlbums()},C=P=>{l.setView({scope:"album",albumId:P.id,albumName:P.name}),c.value="media"},T=async(P,X)=>{const K=l.view.value,be=await l.createAlbum(P,X);if(V(be)){b(be);return}u.value=!1,c.value="media",i("view-change",{from:K,to:{scope:"album",albumId:be.id,albumName:be.name},reason:"inline-album-created",restoredFromSession:!1})},y=async P=>{if(n.uploadBehavior==="delegate"){i("request-upload-files",{files:[...P],view:l.view.value,filters:l.filters.value,sessionId:l.sessionId});return}await l.addUploadFiles(P)};function R(P){var X;return P?P.thumbnail_url??((X=P.conversion_urls)==null?void 0:X.thumb)??P.preview_url??P.original_url??P.url??null:null}function U(P){return P!=null&&P.mime_type?P.mime_type.startsWith("image/"):!1}e.watch(()=>d.value,P=>{S(),m=window.setTimeout(()=>{l.setQuery(P)},250)}),e.watch(()=>l.selectedItems.value,()=>{k()},{deep:!0}),e.watch(()=>l.error.value,P=>{b(P)}),e.watch(()=>n.enableUpload,P=>{!P&&c.value==="upload"&&(c.value="media")}),e.onMounted(()=>{l.initialize()}),e.onBeforeUnmount(()=>{S()}),a({refresh:l.refresh});function z(P){if(P==="albums"){N();return}if(P==="upload"&&!n.enableUpload){c.value="media";return}c.value=P}const W=e.computed(()=>({activeTab:c.value,setActiveTab:z,enableUpload:n.enableUpload,labels:{uploadLabel:r.value.uploadLabel,allMediaTab:r.value.allMediaTab,browseAlbums:r.value.browseAlbums}})),B=e.computed(()=>({query:d.value,setQuery:P=>{d.value=P},placeholder:r.value.searchPlaceholder}));return(P,X)=>(e.openBlock(),e.createElementBlock("section",{class:"media-library-picker","data-testid":P.testIdPrefix},[e.createElementVNode("header",L8,[e.createElementVNode("div",P8,[E.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:L},[...X[8]||(X[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",U8,e.toDisplayString(w.value),1)])]),e.renderSlot(P.$slots,"tabs",e.normalizeProps(e.guardReactiveProps(W.value)),()=>[e.createElementVNode("nav",O8,[P.enableUpload?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["mlp-tabs__tab",{"is-active":c.value==="upload"}]),"data-testid":"tab-media-picker-upload",onClick:X[0]||(X[0]=K=>c.value="upload")},e.toDisplayString(r.value.uploadLabel),3)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["mlp-tabs__tab",{"is-active":c.value==="media"}]),"data-testid":"tab-media-picker-all",onClick:X[1]||(X[1]=K=>c.value="media")},e.toDisplayString(r.value.allMediaTab),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["mlp-tabs__tab",{"is-active":c.value==="albums"}]),"data-testid":"tab-media-picker-albums",onClick:N},e.toDisplayString(r.value.browseAlbums),3)])],!0),c.value==="media"||c.value==="albums"?(e.openBlock(),e.createElementBlock("div",z8,[e.renderSlot(P.$slots,"search",e.normalizeProps(e.guardReactiveProps(B.value)),()=>[X[9]||(X[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":X[2]||(X[2]=K=>d.value=K),class:"mlp-search-row__input",type:"search",placeholder:r.value.searchPlaceholder,"data-testid":"input-media-picker-search"},null,8,j8),[[e.vModelText,d.value]])],!0)])):e.createCommentVNode("",!0),P.enableUpload&&c.value==="upload"?(e.openBlock(),e.createBlock(nf,{key:1,open:!0,queue:e.unref(l).uploadQueue.value,accept:P.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:X[3]||(X[3]=K=>c.value="media"),onFilesSelected:y},null,8,["queue","accept","upload-label","dropzone-label","dropzone-helper-text","file-input-label","close-button-label","close-button-aria-label"])):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("div",W8,[e.createVNode(Xp,{open:u.value,"name-label":r.value.createAlbumNameLabel,albums:e.unref(l).albums.value,onCancel:X[4]||(X[4]=K=>u.value=!1),onCreate:T},null,8,["open","name-label","albums"])])):e.createCommentVNode("",!0),e.unref(l).permissionDenied.value&&e.unref(l).view.value.scope==="album"?(e.openBlock(),e.createBlock(Kp,{key:3,title:r.value.albumUnavailableTitle,body:r.value.albumUnavailableBody,"action-label":r.value.goToLibrary,onGoToLibrary:e.unref(l).goToLibrary},null,8,["title","body","action-label","onGoToLibrary"])):e.createCommentVNode("",!0),!e.unref(l).permissionDenied.value||e.unref(l).view.value.scope!=="album"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:4},[e.unref(l).error.value?(e.openBlock(),e.createElementBlock("div",H8,[e.createElementVNode("p",null,e.toDisplayString(e.unref(l).error.value.message||r.value.networkError),1),e.createElementVNode("button",{type:"button",class:"mlp-error__retry",onClick:X[5]||(X[5]=(...K)=>e.unref(l).refresh&&e.unref(l).refresh(...K))},e.toDisplayString(r.value.retry),1)])):e.createCommentVNode("",!0),c.value==="media"?(e.openBlock(),e.createBlock(rf,{key:1,items:e.unref(l).queryItems.value,"selected-items":e.unref(l).selectedItems.value,loading:e.unref(l).loading.value,"loading-more":e.unref(l).loadingMore.value,"has-more":e.unref(l).hasMore.value,"empty-message":h.value,"loading-message":r.value.loadingMedia,"load-more-label":r.value.loadMore,"loading-more-label":r.value.loadingMore,"test-id-prefix":`${P.testIdPrefix}-item`,onToggle:e.unref(l).toggleSelection,onPreview:e.unref(l).openPreview,onLoadMore:e.unref(l).loadMore},null,8,["items","selected-items","loading","loading-more","has-more","empty-message","loading-message","load-more-label","loading-more-label","test-id-prefix","onToggle","onPreview","onLoadMore"])):c.value==="albums"?(e.openBlock(),e.createBlock(af,{key:2,open:!0,"current-view":e.unref(l).view.value,albums:e.unref(l).albums.value,"view-library-label":r.value.viewLibrary,"browse-albums-label":r.value.browseAlbums,"create-album-label":r.value.createAlbum,"enable-album-creation":P.enableAlbumCreation,onSelectLibrary:L,onSelectAlbum:C,onCreateAlbum:X[6]||(X[6]=K=>u.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),P.showFooter?(e.openBlock(),e.createElementBlock("footer",Z8,[e.unref(l).selectedItems.value.length>0?(e.openBlock(),e.createElementBlock("div",G8,[e.createElementVNode("span",X8,e.toDisplayString(v.value),1),e.createElementVNode("div",K8,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(l).selectedItems.value,K=>{var be,Ne,ue;return e.openBlock(),e.createElementBlock("div",{key:K.id,class:"mlp-bottom-bar__thumb-item"},[U(K.media)&&R(K.media)?(e.openBlock(),e.createElementBlock("img",{key:0,src:R(K.media),alt:((be=K.media)==null?void 0:be.alt_text)??((Ne=K.media)==null?void 0:Ne.file_name)??"Selected",class:"mlp-bottom-bar__thumb-img"},null,8,J8)):(e.openBlock(),e.createElementBlock("div",q8,[...X[10]||(X[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} ${((ue=K.media)==null?void 0:ue.file_name)??K.id}`,"data-testid":"btn-media-picker-remove-selected",onClick:re=>e.unref(l).removeSelected(K.id)},[...X[11]||(X[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,Y8)])}),128))])])):e.createCommentVNode("",!0),e.createElementVNode("div",Q8,[e.createElementVNode("button",{type:"button",class:"mlp-bottom-bar__cancel","data-testid":"btn-media-picker-cancel",onClick:X[7]||(X[7]=K=>x())},e.toDisplayString(r.value.cancel),1),e.createElementVNode("button",{type:"button",class:"mlp-bottom-bar__confirm","data-testid":"btn-media-picker-confirm",onClick:I},e.toDisplayString(r.value.confirmAction),1)])])):e.createCommentVNode("",!0),P.enablePreview?(e.openBlock(),e.createBlock(Cd,{key:6,open:e.unref(l).previewItem.value!==null,media:e.unref(l).previewItem.value,"can-go-previous":e.unref(l).previewIndex.value!==null&&e.unref(l).previewIndex.value>0,"can-go-next":e.unref(l).previewIndex.value!==null&&e.unref(l).previewIndex.value<e.unref(l).queryItems.value.length-1,selected:e.unref(l).previewItem.value!==null&&e.unref(l).orderedIds.value.includes(e.unref(l).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(l).closePreview,onPrevious:e.unref(l).showPreviousPreview,onNext:e.unref(l).showNextPreview,onToggleSelect:e.unref(l).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,A8))}}),vf=Fe(e$,[["__scopeId","data-v-68a73e25"]]),t$={key:0,class:"media-library-picker-modal","data-testid":"media-library-picker-modal"},a$={class:"media-library-picker-modal__panel"},n$=e.defineComponent({__name:"MediaLibraryPickerModal",props:{deps:{},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,s)=>r.isOpen?(e.openBlock(),e.createElementBlock("div",t$,[e.createElementVNode("button",{type:"button",class:"media-library-picker-modal__backdrop","aria-label":"Close media picker",onClick:i}),e.createElementVNode("div",a$,[e.createVNode(vf,e.mergeProps(t,{"onUpdate:modelValue":s[0]||(s[0]=l=>n("update:modelValue",l)),onConfirm:s[1]||(s[1]=l=>n("confirm",l)),onCancel:s[2]||(s[2]=l=>n("cancel",l))}),null,16)])])):e.createCommentVNode("",!0)}}),o$=Fe(n$,[["__scopeId","data-v-a92e8703"]]),i$={key:0,class:"media-selection-tray","data-testid":"media-selection-tray"},r$={class:"media-selection-tray__header"},s$={class:"media-selection-tray__title"},l$={class:"media-selection-tray__items"},d$={class:"media-selection-tray__item-preview"},c$=["src","alt"],u$={key:1,class:"media-selection-tray__file-icon"},m$={class:"media-selection-tray__item-copy"},p$=["aria-label","onClick"],f$=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 s;return r?r.thumbnail_url??((s=r.conversion_urls)==null?void 0:s.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,s)=>r.items.length>0?(e.openBlock(),e.createElementBlock("section",i$,[e.createElementVNode("header",r$,[e.createElementVNode("h3",s$,e.toDisplayString(r.selectedCountLabel),1)]),e.createElementVNode("div",l$,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,l=>{var d,c,u,f;return e.openBlock(),e.createElementBlock("article",{key:l.id,class:"media-selection-tray__item"},[e.createElementVNode("div",d$,[i(l.media)&&n(l.media)?(e.openBlock(),e.createElementBlock("img",{key:0,src:n(l.media),alt:((d=l.media)==null?void 0:d.alt_text)??((c=l.media)==null?void 0:c.file_name)??"Selected media",class:"media-selection-tray__thumb"},null,8,c$)):(e.openBlock(),e.createElementBlock("div",u$,[...s[0]||(s[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",m$,[e.createElementVNode("strong",null,e.toDisplayString(((u=l.media)==null?void 0:u.file_name)??l.id),1),e.createElementVNode("span",null,e.toDisplayString(l.status),1)]),e.createElementVNode("button",{type:"button",class:"media-selection-tray__remove","aria-label":`${r.dismissLabel} ${((f=l.media)==null?void 0:f.file_name)??l.id}`,onClick:m=>t("remove",l.id)},e.toDisplayString(r.dismissLabel),9,p$)])}),128))])])):e.createCommentVNode("",!0)}}),h$=Fe(f$,[["__scopeId","data-v-f2a3d69d"]]);function Id(o={}){const a=e.ref(!1),t=e.ref(!1),n=e.ref(null),i=e.ref(null),r=e.ref(0),s=e.ref(0),l=e.ref(null),d=e.ref(null),c=e.computed(()=>d.value!==null),u=S=>{if(r.value++,d.value=null,i.value=null,t.value=!1,S!=null&&typeof S=="object"&&!(S instanceof Blob)&&("image"in S||"state"in S||"sessionKey"in S)){const k=S;n.value=k.image??null,l.value=k.state??null,s.value=k.sessionKey??r.value}else n.value=S??null,l.value=null,s.value=r.value;a.value=!0},f=()=>{a.value=!1,n.value=null,i.value=null,d.value=null,t.value=!1,l.value=null},m=async S=>{try{return t.value=!0,i.value=S,o.onSave&&await o.onSave(S),f(),S}catch(k){const b=k;throw d.value=b,o.onError&&o.onError(b),b}finally{t.value=!1}},p=()=>{o.onCancel&&o.onCancel(),f()},h=S=>{d.value=S,o.onError&&o.onError(S)},v=()=>{d.value=null},w=()=>i.value,E=e.computed(()=>a.value&&i.value!==null&&!t.value);return{isOpen:a,isProcessing:t,uploadedImage:n,editedImage:i,sessionKey:s,initialState:l,error:d,hasError:c,hasUnsavedChanges:E,open:u,close:f,handleSave:m,handleCancel:p,handleError:h,clearError:v,getEditedImage:w}}let ol=null;function v$(o){return ol||(ol=Id(o)),ol}function g$(o){return a=>new Promise((t,n)=>{Id({...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 Md(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 Gl(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 Fd(o){if(o){const t={};o.apiBaseUrl!==void 0&&(t.apiBaseUrl=o.apiBaseUrl),o.isAdmin!==void 0&&(t.isAdmin=o.isAdmin),So(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),So(n)}}}let Vr=null;function b$(){return Vr||(Vr=Fd()),Vr}function y$(){Vr=null}const w$={apiBaseUrl:"/media-library-pro"};function fr(){var o;return typeof document>"u"?null:((o=document.querySelector('meta[name="csrf-token"]'))==null?void 0:o.getAttribute("content"))||null}function il(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 $d(o){const a={...w$,...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 s={Accept:"application/json",...a.headers},l=a.csrfToken||fr();l&&(s["X-CSRF-TOKEN"]=l);const d={method:"POST",headers:s,body:r,credentials:"include"};i!=null&&i.signal&&(d.signal=i.signal);const c=await fetch(`${a.apiBaseUrl}/uploads`,d);if(!c.ok){const m=await c.json().catch(()=>({message:"Upload failed"}));throw new Error(m.message||`HTTP ${c.status}`)}const u=await c.json(),f=il(u);return i!=null&&i.onProgress&&i.onProgress(100),{media:f,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||fr();r&&(i["X-CSRF-TOKEN"]=r);const s=new URLSearchParams;s.append("model_type",n.modelType),s.append("model_id",String(n.modelId)),n.collection&&s.append("collection",n.collection);try{const l=await fetch(`${a.apiBaseUrl}/media?${s}`,{method:"GET",headers:i,credentials:"include"});if(!l.ok)throw new Error(`HTTP ${l.status}`);return(await l.json()).map(il)}catch{return[]}},getUrl(n,i){var r;if(i){const s=(r=n.conversion_urls)==null?void 0:r[i];if(s)return s}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||fr();r&&(i["X-CSRF-TOKEN"]=r);const s=await fetch(`${a.apiBaseUrl}/uploads/${n}`,{method:"DELETE",headers:i,credentials:"include"});if(!s.ok){const l=await s.json().catch(()=>({message:"Delete failed"}));throw new Error(l.message||`HTTP ${s.status}`)}},async update(n,i){const r={Accept:"application/json","Content-Type":"application/json",...a.headers},s=a.csrfToken||fr();s&&(r["X-CSRF-TOKEN"]=s);const l=await fetch(`${a.apiBaseUrl}/uploads/${n}`,{method:"PATCH",headers:r,body:JSON.stringify(i),credentials:"include"});if(!l.ok){const c=await l.json().catch(()=>({message:"Update failed"}));throw new Error(c.message||`HTTP ${l.status}`)}const d=await l.json();return il(d)},configure(n){Object.assign(a,n)}}}let Nr=null;function k$(){return Nr||(Nr=$d()),Nr}function _$(){Nr=null}function gf(o,a){switch(o){case"mediables":return Fd(a);case"spatie":return $d(a);default:throw new Error(`Unknown adapter: ${o}`)}}function bf(o={}){const{enabled:a=!0,onReorder:t,onDragStart:n,onDragEnd:i,draggingClass:r="is-dragging",dropTargetClass:s="is-drop-target"}=o,l=e.ref({isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null}),d=e.ref(!1);let c=null;function u(S,k,b){a&&("dataTransfer"in S&&S.dataTransfer&&(S.dataTransfer.effectAllowed="move",S.dataTransfer.setData("text/plain",String(b))),c=S.target,c&&c.classList.add(r),l.value={isDragging:!0,dragIndex:b,dropIndex:b,draggedItem:k},d.value=!0,n==null||n(k,b))}function f(S,k){var b;if(!(!a||!l.value.isDragging)&&(S.preventDefault(),l.value.dropIndex!==k)){const $=document.querySelector(`.${s}`);$==null||$.classList.remove(s);const V=(b=S.target)==null?void 0:b.closest("[data-index]");V==null||V.classList.add(s),l.value.dropIndex=k}}function m(){if(!l.value.isDragging)return;const{dragIndex:S,dropIndex:k,draggedItem:b}=l.value;c&&c.classList.remove(r);const $=document.querySelector(`.${s}`);$==null||$.classList.remove(s),S!==null&&k!==null&&S!==k&&b&&(t==null||t({fromIndex:S,toIndex:k,item:b})),h(),i==null||i()}function p(){c&&c.classList.remove(r);const S=document.querySelector(`.${s}`);S==null||S.classList.remove(s),h(),i==null||i()}function h(){l.value={isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null},d.value=!1,c=null}function v(S,k,b){const $=[...S],[V]=$.splice(k,1);return $.splice(b,0,V),$.map((I,x)=>({...I,order:x}))}function w(S,k){return{draggable:a,"data-index":k,onDragstart:b=>u(b,S,k),onDragover:b=>f(b,k),onDragend:()=>m(),onDrop:b=>{b.preventDefault(),m()}}}function E(S){S.key==="Escape"&&l.value.isDragging&&p()}return e.onMounted(()=>{document.addEventListener("keydown",E)}),e.onUnmounted(()=>{document.removeEventListener("keydown",E),p()}),{dragState:l,isDragging:d,startDrag:u,handleDragOver:f,endDrag:m,cancelDrag:p,reorderItems:v,getDragProps:w}}function _s(o={}){const{initialItems:a=[],modelType:t,modelId:n,collection:i="images",maxItems:r,maxFileSize:s,acceptedMimeTypes:l,sortable:d=!0,disabled:c=!1,rules:u={},adapterType:f="mediables",adapter:m,maxConcurrentUploads:p=3,onChange:h,onUpload:v,onUploadComplete:w,onUploadError:E,onRemove:S,onReorder:k,onError:b,onReadyToSubmitChange:$}=o,V={maxItems:r,maxFileSize:s,acceptedMimeTypes:l,...u},I=m||gf(f),x=e.ref([]),N=e.ref(!1),L=e.ref([]);function C(fe){if(fe.length===0)return[];const Ee=fe[0];return"media"in Ee&&"clientId"in Ee?fe:Gl(fe)}x.value=C(a);const{acceptString:T,canAddFiles:y}=Nd({rules:V}),R=Td({adapter:I,maxConcurrent:p,rules:V,collection:i,onUploadStart:fe=>{v==null||v(fe)},onUploadComplete:(fe,Ee)=>{const ye=x.value.findIndex(Be=>Be.clientId===fe.id);ye!==-1&&(x.value[ye]={...x.value[ye],media:Ee,name:Ee.name||Ee.file_name,upload:{...fe,status:"completed"}}),w==null||w(Ee)},onUploadError:(fe,Ee)=>{const ye=x.value.findIndex(Be=>Be.clientId===fe.id);ye!==-1&&(x.value[ye]={...x.value[ye],upload:{...fe,status:"error",error:Ee.message},errors:[{field:"upload",message:Ee.message,code:"UPLOAD_ERROR"}]}),E==null||E({file:fe.file,message:Ee.message})},onQueueComplete:()=>{h==null||h(x.value)}}),{dragState:U,getDragProps:z,reorderItems:W}=bf({enabled:d&&!c,onReorder:fe=>{x.value=W(x.value,fe.fromIndex,fe.toIndex),k==null||k(x.value),h==null||h(x.value)}}),B=e.computed(()=>R.isUploading.value),P=e.computed(()=>!R.isUploading.value&&R.pendingCount.value===0),X=e.computed(()=>r?x.value.length>=r:!1),K=e.computed(()=>Md(x.value)),be=e.computed(()=>x.value.length),Ne=e.computed(()=>r?Math.max(0,r-x.value.length):1/0);e.watch(P,fe=>{$==null||$(fe)});function ue(fe){x.value=C(fe),h==null||h(x.value)}async function re(fe){if(c)return;const Ee=Array.from(fe);if(!y(Ee.length,x.value.length)){const et={field:"count",message:`Maximum ${r} files allowed`,code:"MAX_ITEMS"};L.value=[et],b==null||b([et]);return}const ye=await R.addFiles(Ee),Be=x.value.length,Ie=ye.map((et,tt)=>({...et,order:Be+tt}));x.value=[...x.value,...Ie],h==null||h(x.value)}function O(fe){c||(fe.upload&&(fe.upload.status==="uploading"||fe.upload.status==="pending")&&R.cancelUpload(fe.clientId),x.value=x.value.filter(Ee=>Ee.clientId!==fe.clientId),x.value=x.value.map((Ee,ye)=>({...Ee,order:ye})),S==null||S(fe),h==null||h(x.value))}function D(fe){const Ee=x.value.find(ye=>ye.clientId===fe);Ee&&O(Ee)}function J(){c||(R.clearAll(),x.value=[],h==null||h(x.value))}function Z(fe,Ee){c||!d||(x.value=W(x.value,fe,Ee),k==null||k(x.value),h==null||h(x.value))}function ie(fe,Ee){if(c)return;const ye=x.value.findIndex(Be=>Be.clientId===fe);ye!==-1&&(x.value[ye]={...x.value[ye],...Ee},h==null||h(x.value))}function se(fe){R.cancelUpload(fe),D(fe)}async function Ue(fe){await R.retryUpload(fe)}async function me(){if(!t||!n)throw new Error("modelType and modelId are required for save()");const fe={modelType:t,modelId:n,collection:i},Ee=x.value.filter(ye=>ye.media&&!ye.markedForRemoval).map(ye=>ye.media.uuid);N.value=!0;try{await I.attachMany(Ee,fe),await I.reorder(fe,Ee)}finally{N.value=!1}}async function ve(){if(!t||!n)throw new Error("modelType and modelId are required for load()");const fe={modelType:t,modelId:n,collection:i};N.value=!0;try{const Ee=await I.fetchModelMedia(fe);x.value=Gl(Ee),h==null||h(x.value)}finally{N.value=!1}}return e.onMounted(()=>{t&&n&&a.length===0&&ve().catch(console.error)}),e.onUnmounted(()=>{R.clearAll()}),{items:x,setItems:ue,addFiles:re,removeItem:O,removeItemById:D,clearAll:J,reorderItems:Z,updateItem:ie,cancelUpload:se,retryUpload:Ue,save:me,load:ve,isLoading:N,isUploading:B,isReadyToSubmit:P,isAtMaxItems:X,errors:L,dragState:U,getDragProps:z,adapter:I,formValues:K,acceptString:T,count:be,remainingSlots:Ne}}const E$=["aria-disabled"],x$=["accept","multiple","disabled"],S$={class:"media-dropzone__content"},C$={class:"media-dropzone__title"},V$={class:"media-dropzone__subtitle"},N$=["disabled"],T$={key:0,class:"media-dropzone__helper"},B$=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),s=e.computed(()=>({"media-dropzone":!0,"media-dropzone--drag-over":i.value,"media-dropzone--disabled":t.disabled})),l=e.computed(()=>{const v=[];return t.maxFileSize&&v.push(`Max size: ${Gr(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 f(v){var E;if(v.preventDefault(),i.value=!1,t.disabled)return;const w=(E=v.dataTransfer)==null?void 0:E.files;w&&w.length>0&&n("files",w)}function m(){var v;t.disabled||(v=r.value)==null||v.click()}function p(v){const w=v.target,E=w.files;E&&E.length>0&&n("files",E),w.value=""}function h(v){(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),m())}return(v,w)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(s.value),role:"button",tabindex:"0","aria-disabled":v.disabled,"aria-label":"Upload files",onClick:m,onKeydown:h,onDragenter:d,onDragleave:c,onDragover:u,onDrop:f},[e.createElementVNode("input",{ref_key:"fileInput",ref:r,type:"file",accept:v.accept,multiple:v.multiple,disabled:v.disabled,class:"media-dropzone__input",onChange:p},null,40,x$),e.createElementVNode("div",S$,[e.renderSlot(v.$slots,"icon",{},()=>[w[0]||(w[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",C$,[e.renderSlot(v.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(v.title),1)],!0)]),e.createElementVNode("p",V$,[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(m,["stop"])},[e.renderSlot(v.$slots,"button",{},()=>[e.createTextVNode(e.toDisplayString(v.buttonText),1)],!0)],8,N$),l.value?(e.openBlock(),e.createElementBlock("p",T$,e.toDisplayString(l.value),1)):e.createCommentVNode("",!0)])],42,E$))}}),Dd=Fe(B$,[["__scopeId","data-v-b1366c1e"]]),I$=["data-index"],M$={key:0,class:"media-item__drag-handle","aria-label":"Drag to reorder",role:"button",tabindex:"0"},F$={class:"media-item__thumbnail"},$$=["src","alt"],D$={key:1,class:"media-item__file-icon"},R$={key:2,class:"media-item__progress-overlay"},A$={class:"media-item__progress-text"},L$={key:3,class:"media-item__processing-overlay"},P$={key:4,class:"media-item__error-overlay"},U$={class:"media-item__info"},O$=["title"],z$={key:0,class:"media-item__size"},j$={key:1,class:"media-item__error-message"},W$={class:"media-item__actions"},H$=["disabled"],Z$=["disabled"],G$=["disabled"],X$=["disabled"],K$=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 k;return(k=t.item.upload)!=null&&k.previewUrl?t.item.upload.previewUrl:t.item.media?t.adapter.getThumbnailUrl(t.item.media):null}),s=e.computed(()=>{var k,b,$;return((k=t.item.upload)==null?void 0:k.status)==="uploading"||((b=t.item.upload)==null?void 0:b.status)==="pending"||(($=t.item.upload)==null?void 0:$.status)==="queued"}),l=e.computed(()=>{var k;return((k=t.item.upload)==null?void 0:k.status)==="processing"}),d=e.computed(()=>{var k;return((k=t.item.upload)==null?void 0:k.status)==="error"||t.item.errors&&t.item.errors.length>0}),c=e.computed(()=>{var k;return(k=t.item.upload)!=null&&k.error?t.item.upload.error:t.item.errors&&t.item.errors.length>0?t.item.errors[0].message:null}),u=e.computed(()=>{var k;return((k=t.item.upload)==null?void 0:k.progress)||0}),f=e.computed(()=>{var k;return t.item.name||((k=t.item.media)==null?void 0:k.file_name)||"Unknown file"}),m=e.computed(()=>{var I,x;const k=((I=t.item.media)==null?void 0:I.size)||((x=t.item.upload)==null?void 0:x.file.size);if(!k)return"";const b=1024,$=["Bytes","KB","MB","GB"],V=Math.floor(Math.log(k)/Math.log(b));return parseFloat((k/Math.pow(b,V)).toFixed(2))+" "+$[V]}),p=e.computed(()=>{var b,$;const k=((b=t.item.media)==null?void 0:b.mime_type)||(($=t.item.upload)==null?void 0:$.file.type);return k==null?void 0:k.startsWith("image/")}),h=e.computed(()=>({"media-item":!0,"media-item--uploading":s.value,"media-item--processing":l.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 w(){t.disabled||n("edit",t.item)}function E(){t.disabled||n("retry",t.item)}function S(){t.disabled||n("cancel",t.item)}return(k,b)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(h.value),"data-index":k.index,onMouseenter:b[0]||(b[0]=$=>i.value=!0),onMouseleave:b[1]||(b[1]=$=>i.value=!1)},[k.sortable&&!k.disabled?(e.openBlock(),e.createElementBlock("div",M$,[...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",F$,[r.value&&p.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.value,alt:f.value,class:"media-item__image"},null,8,$$)):(e.openBlock(),e.createElementBlock("div",D$,[...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)])])),s.value?(e.openBlock(),e.createElementBlock("div",R$,[e.createElementVNode("div",{class:"media-item__progress-bar",style:e.normalizeStyle({width:`${u.value}%`})},null,4),e.createElementVNode("span",A$,e.toDisplayString(u.value)+"%",1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",L$,[...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",P$,[...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",U$,[e.createElementVNode("span",{class:"media-item__name",title:f.value},e.toDisplayString(f.value),9,O$),m.value?(e.openBlock(),e.createElementBlock("span",z$,e.toDisplayString(m.value),1)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("span",j$,e.toDisplayString(c.value),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",W$,[s.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-item__action media-item__action--cancel",disabled:k.disabled,"aria-label":"Cancel upload",onClick:S},[...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,H$)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"media-item__action media-item__action--retry",disabled:k.disabled,"aria-label":"Retry upload",onClick:E},[...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,Z$)):e.createCommentVNode("",!0),k.showEdit&&k.item.media&&!s.value?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"media-item__action media-item__action--edit",disabled:k.disabled,"aria-label":"Edit",onClick:w},[...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,G$)):e.createCommentVNode("",!0),k.showRemove?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"media-item__action media-item__action--remove",disabled:k.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,X$)):e.createCommentVNode("",!0)])],42,I$))}}),Rd=Fe(K$,[["__scopeId","data-v-ff81c9ec"]]),J$=["aria-label"],q$=["draggable","data-index","onDragstart","onDragover","onDragend","onDrop"],Y$={key:0,class:"media-collection__footer"},Q$={class:"media-collection__count"},eD={key:0},tD={key:0,class:"media-collection__uploading"},aD=["name","value"],nD=["name","value"],oD=["name","value"],iD=["name","value"],rD={key:3,class:"media-collection__errors",role:"alert","aria-live":"polite"},sD=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:B=>{n("update:modelValue",B),n("change",B)},onUpload:B=>{n("upload",B)},onUploadComplete:B=>{n("upload-complete",B)},onUploadError:B=>{n("upload-error",B)},onRemove:B=>{n("remove",B)},onReorder:B=>{n("reorder",B)},onError:B=>{n("validation-error",B)},onReadyToSubmitChange:B=>{n("is-ready-to-submit-change",B)}},{items:r,setItems:s,addFiles:l,removeItem:d,reorderItems:c,cancelUpload:u,retryUpload:f,isLoading:m,isUploading:p,isAtMaxItems:h,errors:v,dragState:w,getDragProps:E,adapter:S,formValues:k,acceptString:b,count:$,remainingSlots:V}=_s(i);e.provide("mediaAdapter",S),e.provide("mediaCollection",{items:r,addFiles:l,removeItem:d,reorderItems:c}),e.watch(()=>t.modelValue,B=>{B!==r.value&&s(B)},{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":m.value,"media-collection--has-items":r.value.length>0,"media-collection--dragging":w.value.isDragging}));function N(B){l(B)}function L(B){d(B)}function C(B){f(B.clientId)}function T(B){u(B.clientId)}function y(B){}function R(B,P,X){if(!t.sortable||t.disabled)return;const K=E(P,X);K.onDragstart&&K.onDragstart(B)}function U(B,P){if(!t.sortable||t.disabled)return;B.preventDefault();const X=r.value[P],K=E(X,P);K.onDragover&&K.onDragover(B)}function z(B,P){const X=E(B,P);X.onDragend&&X.onDragend()}function W(B,P){B.preventDefault();const X=r.value[P],K=E(X,P);K.onDrop&&K.onDrop(B)}return(B,P)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(x.value)},[e.renderSlot(B.$slots,"dropzone",{addFiles:e.unref(l)},()=>[I.value?(e.openBlock(),e.createBlock(Dd,{key:0,accept:e.unref(b),multiple:B.maxItems!==1,disabled:B.disabled,"max-file-size":B.maxFileSize,"max-items":e.unref(V),onFiles:N},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($)} media items`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r),(X,K)=>e.renderSlot(B.$slots,"item",{key:X.clientId,item:X,index:K,remove:()=>L(X)},()=>[e.createElementVNode("div",{class:e.normalizeClass(["media-collection__item-wrapper",{"media-collection__item-wrapper--drag-over":e.unref(w).dropIndex===K}]),draggable:B.sortable&&!B.disabled,"data-index":K,onDragstart:be=>R(be,X,K),onDragover:be=>U(be,K),onDragend:be=>z(X,K),onDrop:be=>W(be,K)},[e.createVNode(Rd,{item:X,adapter:e.unref(S),disabled:B.disabled,sortable:B.sortable,"show-remove":!B.readonly,"show-edit":!1,index:K,onRemove:L,onRetry:C,onCancel:T,onEdit:y},null,8,["item","adapter","disabled","sortable","show-remove","index"])],42,q$)],!0)),128))],8,J$)):I.value?e.createCommentVNode("",!0):e.renderSlot(B.$slots,"empty",{key:1},()=>[P[0]||(P[0]=e.createElementVNode("div",{class:"media-collection__empty"},[e.createElementVNode("p",null,"No files uploaded")],-1))],!0),e.renderSlot(B.$slots,"footer",{count:e.unref($),isUploading:e.unref(p)},()=>[e.unref(r).length>0?(e.openBlock(),e.createElementBlock("div",Y$,[e.createElementVNode("span",Q$,[e.createTextVNode(e.toDisplayString(e.unref($))+" "+e.toDisplayString(e.unref($)===1?"file":"files")+" ",1),B.maxItems?(e.openBlock(),e.createElementBlock("span",eD," / "+e.toDisplayString(B.maxItems)+" max",1)):e.createCommentVNode("",!0)]),e.unref(p)?(e.openBlock(),e.createElementBlock("span",tD," Uploading... ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],!0),B.generateFormFields?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(k),(X,K)=>(e.openBlock(),e.createElementBlock("input",{key:`${B.name}-${X.uuid}`,type:"hidden",name:`${B.name}[${K}][uuid]`,value:X.uuid},null,8,aD))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(k),(X,K)=>(e.openBlock(),e.createElementBlock("input",{key:`${B.name}-${X.uuid}-name`,type:"hidden",name:`${B.name}[${K}][name]`,value:X.name},null,8,nD))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(k),(X,K)=>(e.openBlock(),e.createElementBlock("input",{key:`${B.name}-${X.uuid}-order`,type:"hidden",name:`${B.name}[${K}][order]`,value:X.order},null,8,oD))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(k),(X,K)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${B.name}-${X.uuid}-props`},[X.custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${B.name}[${K}][custom_properties]`,value:JSON.stringify(X.custom_properties)},null,8,iD)):e.createCommentVNode("",!0)],64))),128))],64)):e.createCommentVNode("",!0),e.unref(v).length>0?(e.openBlock(),e.createElementBlock("div",rD,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(v),X=>(e.openBlock(),e.createElementBlock("p",{key:X.code||X.message,class:"media-collection__error"},e.toDisplayString(X.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),lD=Fe(sD,[["__scopeId","data-v-10a5bfff"]]);function Ad(o={}){const{initialItem:a,onChange:t,onReplace:n,onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:l,onError:d,onReadyToSubmitChange:c,...u}=o,m={...u,initialItems:a?[a]:[],maxItems:1,sortable:!1,onChange:I=>{t==null||t(I[0]||null)},onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:l,onError:d,onReadyToSubmitChange:c},p=_s(m),h=e.computed(()=>p.items.value[0]||null),v=e.computed(()=>h.value!==null),w=e.computed(()=>p.formValues.value[0]||null);function E(I){I===null?p.clearAll():p.setItems([I])}async function S(I){const x=h.value;x&&p.removeItem(x),await p.addFiles([I])}function k(){h.value&&p.removeItem(h.value)}async function b(I){const x=h.value;x&&p.removeItem(x),await p.addFiles([I]);const N=p.items.value[0];N&&(n==null||n(x,N))}function $(){var I;(I=h.value)!=null&&I.upload&&p.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 p.retryUpload(h.value.clientId)}return{item:h,setItem:E,addFile:S,removeItem:k,replaceItem:b,cancelUpload:$,retryUpload:V,save:p.save,load:p.load,isLoading:p.isLoading,isUploading:p.isUploading,isReadyToSubmit:p.isReadyToSubmit,hasItem:v,errors:p.errors,adapter:p.adapter,formValue:w,acceptString:p.acceptString}}const dD=["accept","disabled"],cD={class:"media-attachment__preview"},uD=["name","value"],mD=["name","value"],pD=["name","value"],fD=["name","value"],hD={key:4,class:"media-attachment__errors",role:"alert","aria-live":"polite"},vD=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:C=>{n("update:modelValue",C),n("change",C)},onUpload:C=>{n("upload",C)},onUploadComplete:C=>{n("upload-complete",C)},onUploadError:C=>{n("upload-error",C)},onRemove:C=>{n("remove",C)},onReplace:(C,T)=>{n("replace",T)},onError:C=>{n("validation-error",C)},onReadyToSubmitChange:C=>{n("is-ready-to-submit-change",C)}},{item:s,setItem:l,addFile:d,removeItem:c,replaceItem:u,cancelUpload:f,retryUpload:m,isLoading:p,hasItem:h,errors:v,adapter:w,formValue:E,acceptString:S}=Ad(r);e.provide("mediaAdapter",w),e.watch(()=>t.modelValue,C=>{C!==s.value&&l(C)},{deep:!0});const k=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":p.value,"media-attachment--has-item":h.value}));function $(C){C.length>0&&d(C[0])}function V(){var C;(C=i.value)==null||C.click()}function I(C){const T=C.target,y=T.files;y&&y.length>0&&u(y[0]),T.value=""}function x(C){c()}function N(C){m()}function L(C){f()}return(C,T)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(b.value)},[e.createElementVNode("input",{ref_key:"fileInputRef",ref:i,type:"file",accept:e.unref(S),disabled:C.disabled,class:"media-attachment__hidden-input",onChange:I},null,40,dD),k.value?e.renderSlot(C.$slots,"dropzone",{key:0,addFile:e.unref(d)},()=>[e.createVNode(Dd,{accept:e.unref(S),multiple:!1,disabled:C.disabled,"max-file-size":C.maxFileSize,onFiles:$},null,8,["accept","disabled","max-file-size"])],!0):e.unref(h)&&e.unref(s)?e.renderSlot(C.$slots,"preview",{key:1,item:e.unref(s),remove:e.unref(c),replace:V},()=>[e.createElementVNode("div",cD,[e.createVNode(Rd,{item:e.unref(s),adapter:e.unref(w),disabled:C.disabled,sortable:!1,"show-remove":!C.readonly,"show-edit":!1,onRemove:x,onRetry:N,onCancel:L},null,8,["item","adapter","disabled","show-remove"]),C.showReplaceButton&&!C.readonly&&!C.disabled&&e.unref(s).media?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-attachment__replace-button",onClick:V},[...T[0]||(T[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(C.$slots,"empty",{key:2},()=>[T[1]||(T[1]=e.createElementVNode("div",{class:"media-attachment__empty"},[e.createElementVNode("p",null,"No file selected")],-1))],!0),C.generateFormFields&&e.unref(E)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("input",{type:"hidden",name:`${C.name}[uuid]`,value:e.unref(E).uuid},null,8,uD),e.createElementVNode("input",{type:"hidden",name:`${C.name}[name]`,value:e.unref(E).name},null,8,mD),e.createElementVNode("input",{type:"hidden",name:`${C.name}[order]`,value:e.unref(E).order},null,8,pD),e.unref(E).custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${C.name}[custom_properties]`,value:JSON.stringify(e.unref(E).custom_properties)},null,8,fD)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),e.unref(v).length>0?(e.openBlock(),e.createElementBlock("div",hD,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(v),y=>(e.openBlock(),e.createElementBlock("p",{key:y.code||y.message,class:"media-attachment__error"},e.toDisplayString(y.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),gD=Fe(vD,[["__scopeId","data-v-26911174"]]),yf={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"}},bD=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:C=>{i("update:modelValue",C),i("change",C)},onUpload:C=>{i("upload",C)},onUploadComplete:C=>{i("upload-complete",C)},onUploadError:C=>{i("upload-error",C)},onRemove:C=>{i("remove",C)},onReorder:C=>{i("reorder",C)},onError:C=>{i("validation-error",C)},onReadyToSubmitChange:C=>{i("is-ready-to-submit-change",C)}},{items:s,setItems:l,addFiles:d,removeItem:c,reorderItems:u,updateItem:f,cancelUpload:m,retryUpload:p,isLoading:h,isUploading:v,isReadyToSubmit:w,isAtMaxItems:E,errors:S,dragState:k,getDragProps:b,adapter:$,formValues:V,acceptString:I}=_s(r);e.provide("mediaAdapter",$),e.provide("mediaCollection",{items:s,addFiles:d,removeItem:c,reorderItems:u}),e.watch(()=>n.modelValue,C=>{C!==s.value&&l(C)},{deep:!0});const x=e.computed(()=>({...yf,...n.labels})),N=e.computed(()=>({accept:I.value,multiple:n.maxItems!==1,disabled:n.disabled||n.readonly||E.value})),L=e.computed(()=>({items:s.value,isLoading:h.value,isUploading:v.value,isReadyToSubmit:w.value,isAtMaxItems:E.value,errors:S.value,addFiles:d,removeItem:c,reorderItems:u,clearAll:()=>{s.value.forEach(C=>c(C))},cancelUpload:m,retryUpload:p,labels:x.value,dropzoneProps:N.value}));return a({items:s,addFiles:d,removeItem:c,reorderItems:u,updateItem:f,cancelUpload:m,retryUpload:p,isLoading:h,isUploading:v,isReadyToSubmit:w,isAtMaxItems:E,errors:S,dragState:k,getDragProps:b,adapter:$,formValues:V,acceptString:I}),(C,T)=>e.renderSlot(C.$slots,"default",e.normalizeProps(e.guardReactiveProps(L.value)))}}),yD=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,N)=>{i("replace",N)},onError:x=>{i("validation-error",x)},onReadyToSubmitChange:x=>{i("is-ready-to-submit-change",x)}},{item:s,setItem:l,addFile:d,removeItem:c,replaceItem:u,cancelUpload:f,retryUpload:m,isLoading:p,isUploading:h,isReadyToSubmit:v,hasItem:w,errors:E,adapter:S,formValue:k,acceptString:b}=Ad(r);e.provide("mediaAdapter",S),e.watch(()=>n.modelValue,x=>{x!==s.value&&l(x)},{deep:!0});const $=e.computed(()=>({...yf,...n.labels})),V=e.computed(()=>({accept:b.value,multiple:!1,disabled:n.disabled||n.readonly||w.value})),I=e.computed(()=>({item:s.value,hasItem:w.value,isLoading:p.value,isUploading:h.value,isReadyToSubmit:v.value,errors:E.value,addFile:d,removeItem:c,replaceItem:u,cancelUpload:f,retryUpload:m,labels:$.value,dropzoneProps:V.value}));return a({item:s,setItem:l,addFile:d,removeItem:c,replaceItem:u,cancelUpload:f,retryUpload:m,isLoading:p,isUploading:h,isReadyToSubmit:v,hasItem:w,errors:E,adapter:S,formValue:k,acceptString:b}),(x,N)=>e.renderSlot(x.$slots,"default",e.normalizeProps(e.guardReactiveProps(I.value)))}}),wD=["name","value"],kD=["name","value"],_D=["name","value"],ED=["name","value"],xD=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(()=>Md(t.value));function i(l,d){var u;const c=((u=n.value[l])==null?void 0:u.uuid)||"";return`${a.name}[${c}][${d}]`}function r(l,d){return`${a.name}[${l}][${d}]`}function s(l,d){return a.format==="spatie"?i(l,d):r(l,d)}return(l,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:s(u,"uuid"),value:c.uuid},null,8,wD),e.createElementVNode("input",{type:"hidden",name:s(u,"name"),value:c.name},null,8,kD),e.createElementVNode("input",{type:"hidden",name:s(u,"order"),value:c.order},null,8,_D),c.custom_properties&&Object.keys(c.custom_properties).length>0?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:s(u,"custom_properties"),value:JSON.stringify(c.custom_properties)},null,8,ED)):e.createCommentVNode("",!0)],64))),128))}}),SD=["data-testid"],CD=["data-testid"],VD=["id"],ND=["value","maxlength","disabled","aria-labelledby","placeholder","data-testid","onInput"],TD=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,s){const l=s.target;l instanceof HTMLInputElement&&n("update:items",t.items.map((d,c)=>c!==r?d:{...d,caption:l.value===""?null:l.value}))}return(r,s)=>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,(l,d)=>(e.openBlock(),e.createElementBlock("div",{key:l._key??l.id??`${l.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(l,d)),9,VD),e.createElementVNode("input",{value:l.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,ND)],8,CD))),128))],8,SD)):e.createCommentVNode("",!0)}}),BD=Fe(TD,[["__scopeId","data-v-a153768a"]]),ID="/v1/media/deletion/check",MD="/v1/media/deletion/delete",hr=100;function Tu(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 wf(o){const a=o.checkEndpoint??ID,t=o.deleteEndpoint??MD,n=e.ref(!1),i=e.ref(!1),r=e.ref(null),s=e.ref(null),l=e.ref(null);async function d(f){l.value=null;const m=Tu(f);if(m.length===0)return r.value=[],[];if(m.length>hr){const p=new Error(`Cannot check more than ${hr} media items at once.`);throw l.value=p,p}n.value=!0;try{const p=await o.httpClient.post(a,{uuids:m}),h=((p==null?void 0:p.data)??[]).map(v=>{var w,E,S,k;return{uuid:v.uuid,canDelete:((w=v.report)==null?void 0:w.canDelete)??!1,blocks:Array.isArray((E=v.report)==null?void 0:E.blocks)?v.report.blocks:[],cascade:Array.isArray((S=v.report)==null?void 0:S.cascade)?v.report.cascade:[],variantCount:typeof((k=v.report)==null?void 0:k.variantCount)=="number"?v.report.variantCount:0}});return r.value=h,h}catch(p){throw l.value=p instanceof Error?p:new Error(String(p)),l.value}finally{n.value=!1}}async function c(f,m={}){l.value=null;const p=Tu(f);if(p.length===0){const h={results:[],summary:{}};return s.value=h,h}if(p.length>hr){const h=new Error(`Cannot delete more than ${hr} media items at once.`);throw l.value=h,h}i.value=!0;try{const h=await o.httpClient.post(t,{uuids:p,force:m.force===!0}),v={results:Array.isArray(h==null?void 0:h.results)?h.results:[],summary:(h==null?void 0:h.summary)??{}};return s.value=v,v}catch(h){throw l.value=h instanceof Error?h:new Error(String(h)),l.value}finally{i.value=!1}}function u(){r.value=null,s.value=null,l.value=null}return{isChecking:n,isDeleting:i,lastReport:r,lastResponse:s,error:l,checkDependencies:d,deleteMany:c,reset:u}}const FD="/v1/user/media/trash";function $D(o){return`/v1/user/media/${encodeURIComponent(o)}/restore`}function DD(o){return`/v1/user/media/${encodeURIComponent(o)}/purge`}function kf(o){const a=o.listEndpoint??FD,t=o.buildRestoreEndpoint??$D,n=o.buildPurgeEndpoint??DD,i=o.perPage??50,r=e.ref([]),s=e.ref(0),l=e.ref(1),d=e.ref(!1),c=e.ref(!1),u=e.ref(!1),f=e.ref(null);async function m(w=1){var E,S;f.value=null,d.value=!0;try{const k=await o.httpClient.get(a,{params:{page:w,per_page:i}});r.value=Array.isArray(k==null?void 0:k.data)?k.data:[],s.value=typeof((E=k==null?void 0:k.meta)==null?void 0:E.total)=="number"?k.meta.total:0,l.value=typeof((S=k==null?void 0:k.meta)==null?void 0:S.current_page)=="number"?k.meta.current_page:w}catch(k){throw f.value=k instanceof Error?k:new Error(String(k)),f.value}finally{d.value=!1}}async function p(w){f.value=null,c.value=!0;try{const E=await o.httpClient.post(t(w)),S={status:(E==null?void 0:E.status)??"failed",data:(E==null?void 0:E.data)??null,duplicate_uuid:(E==null?void 0:E.duplicate_uuid)??null};return typeof(E==null?void 0:E.message)=="string"&&(S.message=E.message),S.status==="restored"&&(r.value=r.value.filter(k=>k.uuid!==w),s.value=Math.max(0,s.value-1)),S}catch(E){const S=Bu(E);if(S&&typeof S.status=="string"){const k={status:S.status,duplicate_uuid:typeof S.duplicate_uuid=="string"?S.duplicate_uuid:null};return typeof S.message=="string"&&(k.message=S.message),k}throw f.value=E instanceof Error?E:new Error(String(E)),f.value}finally{c.value=!1}}async function h(w){f.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 E=await o.httpClient.delete(n(w)),S={status:(E==null?void 0:E.status)??"failed"};return typeof(E==null?void 0:E.message)=="string"&&(S.message=E.message),S.status==="purging"&&(r.value=r.value.filter(k=>k.uuid!==w),s.value=Math.max(0,s.value-1)),S}catch(E){const S=Bu(E);if(S&&typeof S.status=="string"){const k={status:S.status};return typeof S.message=="string"&&(k.message=S.message),k}throw f.value=E instanceof Error?E:new Error(String(E)),f.value}finally{u.value=!1}}function v(){r.value=[],s.value=0,l.value=1,f.value=null}return{items:r,total:s,currentPage:l,isLoading:d,isRestoring:c,isPurging:u,error:f,fetch:m,restore:p,purge:h,reset:v}}function Bu(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 RD={class:"media-management-view","data-testid":"media-management-view"},AD={key:0,class:"media-management-view__header"},LD={class:"media-management-view__title"},PD={class:"media-management-view__actions"},UD={key:0,class:"media-management-view__badge"},OD={key:1,class:"media-management-view__panel","data-testid":"panel-library"},zD={key:0,class:"media-management-view__view-mode",role:"radiogroup","aria-label":"Media library layout","data-testid":"media-management-layout-mode"},jD=["aria-checked"],WD=["aria-checked"],HD={key:1,class:"media-management-view__status","data-testid":"library-loading"},ZD={key:2,class:"media-management-view__status media-management-view__status--error","data-testid":"library-error"},GD={key:3,class:"media-management-view__empty","data-testid":"library-empty"},XD={class:"media-management-view__empty-state"},KD={class:"media-management-view__empty-title","data-testid":"library-empty-title"},JD={class:"media-management-view__empty-description","data-testid":"library-empty-description"},qD={key:4,class:"media-management-view__table","data-testid":"library-table"},YD={scope:"col","data-testid":"table-header-select"},QD={scope:"col","data-testid":"table-header-thumbnail"},eR={scope:"col","data-testid":"table-header-name"},tR={scope:"col","data-testid":"table-header-type"},aR={scope:"col","data-testid":"table-header-created"},nR={scope:"col","data-testid":"table-header-size"},oR={scope:"col","data-testid":"table-header-status"},iR={scope:"col","data-testid":"table-header-actions"},rR=["data-testid"],sR=["data-testid","aria-pressed","onClick"],lR=["data-testid","onClick"],dR=["src","alt","onError"],cR=["data-testid"],uR=["title","data-testid"],mR=["data-testid"],pR={class:"media-management-view__item-actions"},fR=["onKeydown"],hR=["data-testid","aria-label","aria-expanded","onClick"],vR=["data-testid"],gR=["data-testid","onClick"],bR={key:5,class:"media-management-view__grid","data-testid":"library-grid"},yR=["data-testid"],wR=["data-testid","aria-pressed","onClick"],kR=["src","alt","onError"],_R=["data-testid"],ER={class:"media-management-view__item-meta"},xR=["title","data-testid"],SR=["data-testid"],CR=["data-testid"],VR={key:2,class:"media-management-view__item-badge","data-testid":"badge-orphaned"},NR={class:"media-management-view__item-actions media-management-view__item-actions--grid"},TR=["onKeydown"],BR=["data-testid","aria-label","aria-expanded","onClick"],IR=["data-testid"],MR=["data-testid","onClick"],FR={class:"media-management-view__bulk-bar","data-testid":"bulk-bar"},$R={"data-testid":"bulk-count"},DR=["disabled"],RR={key:7,class:"media-management-view__pagination","data-testid":"media-management-pagination"},AR={class:"media-management-view__pagination-count","data-testid":"media-management-pagination-count","aria-live":"polite"},LR=["disabled"],PR={key:2,class:"media-management-view__panel","data-testid":"panel-trash"},UR={key:0,class:"media-management-view__status","data-testid":"trash-loading"},OR={key:1,class:"media-management-view__empty","data-testid":"trash-empty"},zR={class:"media-management-view__empty-state"},jR={class:"media-management-view__empty-title","data-testid":"trash-empty-title"},WR={class:"media-management-view__empty-description","data-testid":"trash-empty-description"},HR={key:2,class:"media-management-view__grid","data-testid":"trash-grid"},ZR=["data-testid"],GR={class:"media-management-view__item-thumb"},XR=["src","alt","onError"],KR=["data-testid"],JR={class:"media-management-view__item-meta"},qR={class:"media-management-view__item-name"},YR={key:0,class:"media-management-view__item-meta-line"},QR=["data-testid","disabled","onClick"],eA=["data-testid"],tA=e.defineComponent({__name:"MediaManagementView",props:{httpClient:{},capabilities:{default:()=>({})},labels:{default:()=>({})},filters:{},initialView:{},perPage:{},initialLayoutMode:{},layoutMode:{},confirmBulkDelete:{},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})),s=e.computed(()=>{var F,Y,j,ee,we,Ve,Je,ut,St,pt,ft,Mt,Bt,It,Ma,ba,da,ca,qt,gt,bt,Yt,dt,Ft,ya,G,q,le,de,_e,Le,Ye,We,Pe,at,ot,Ze,jt,Ct;return{title:((F=n.labels)==null?void 0:F.title)??"My Media",libraryTab:((Y=n.labels)==null?void 0:Y.libraryTab)??"Library",trashTab:((j=n.labels)==null?void 0:j.trashTab)??"Trash",loading:((ee=n.labels)==null?void 0:ee.loading)??"Loading…",emptyLibrary:((we=n.labels)==null?void 0:we.emptyLibrary)??"No media yet — upload your first creation.",emptyLibraryTitle:((Ve=n.labels)==null?void 0:Ve.emptyLibraryTitle)??"Your media library is ready",emptyLibraryDescription:((Je=n.labels)==null?void 0:Je.emptyLibraryDescription)??"Images and videos you upload for creations are saved here so you can reuse them later.",emptyTrash:((ut=n.labels)==null?void 0:ut.emptyTrash)??"Trash is empty.",emptyTrashTitle:((St=n.labels)==null?void 0:St.emptyTrashTitle)??"No media in trash",emptyTrashDescription:((pt=n.labels)==null?void 0:pt.emptyTrashDescription)??"Deleted files appear here for 30 days before permanent removal.",orphanedBadge:((ft=n.labels)==null?void 0:ft.orphanedBadge)??"Not in use",selectedCount:((Mt=n.labels)==null?void 0:Mt.selectedCount)??(wa=>`${wa} selected`),deleteButton:((Bt=n.labels)==null?void 0:Bt.deleteButton)??"Delete",createPostButton:((It=n.labels)==null?void 0:It.createPostButton)??"Create Post",createGalleryButton:((Ma=n.labels)==null?void 0:Ma.createGalleryButton)??"Create Gallery",addToAlbumButton:((ba=n.labels)==null?void 0:ba.addToAlbumButton)??"Add to Album",previewButton:((da=n.labels)==null?void 0:da.previewButton)??"Preview",previewCloseButton:((ca=n.labels)==null?void 0:ca.previewCloseButton)??"Close",previewPreviousButton:((qt=n.labels)==null?void 0:qt.previewPreviousButton)??"Previous",previewNextButton:((gt=n.labels)==null?void 0:gt.previewNextButton)??"Next",previewSelectButton:((bt=n.labels)==null?void 0:bt.previewSelectButton)??"Select",previewDeselectButton:((Yt=n.labels)==null?void 0:Yt.previewDeselectButton)??"Deselect",editButton:((dt=n.labels)==null?void 0:dt.editButton)??"Edit",loadMoreButton:((Ft=n.labels)==null?void 0:Ft.loadMoreButton)??"Load more",loadingMoreButton:((ya=n.labels)==null?void 0:ya.loadingMoreButton)??"Loading more...",restoreButton:((G=n.labels)==null?void 0:G.restoreButton)??"Restore",restoreUnavailable:((q=n.labels)==null?void 0:q.restoreUnavailable)??"Restore unavailable",gridView:((le=n.labels)==null?void 0:le.gridView)??"Grid",tableView:((de=n.labels)==null?void 0:de.tableView)??"Table",tableSelectHeader:((_e=n.labels)==null?void 0:_e.tableSelectHeader)??"Select",tableThumbnailHeader:((Le=n.labels)==null?void 0:Le.tableThumbnailHeader)??"Preview",tableNameHeader:((Ye=n.labels)==null?void 0:Ye.tableNameHeader)??"Name",tableTypeHeader:((We=n.labels)==null?void 0:We.tableTypeHeader)??"Type",tableCreatedHeader:((Pe=n.labels)==null?void 0:Pe.tableCreatedHeader)??"Uploaded",tableSizeHeader:((at=n.labels)==null?void 0:at.tableSizeHeader)??"Size",tableStatusHeader:((ot=n.labels)==null?void 0:ot.tableStatusHeader)??"Status",tableActionsHeader:((Ze=n.labels)==null?void 0:Ze.tableActionsHeader)??"Actions",purgeAfter:((jt=n.labels)==null?void 0:jt.purgeAfter)??(wa=>`Purges ${wa}`),ownerLabel:((Ct=n.labels)==null?void 0:Ct.ownerLabel)??(wa=>`User ${wa.user_id??""}`)}}),l=e.computed(()=>s.value.title),d=e.computed(()=>s.value.libraryTab),c=e.computed(()=>s.value.trashTab),u=e.computed(()=>s.value.loading),f=e.computed(()=>s.value.emptyLibraryTitle),m=e.computed(()=>s.value.emptyLibraryDescription),p=e.computed(()=>s.value.emptyTrashTitle),h=e.computed(()=>s.value.emptyTrashDescription),v=e.computed(()=>s.value.orphanedBadge),w=e.computed(()=>s.value.deleteButton),E=e.computed(()=>s.value.restoreButton),S=e.computed(()=>s.value.restoreUnavailable),k=e.computed(()=>s.value.gridView),b=e.computed(()=>s.value.tableView);function $(F){const Y=r.value.canRestore;return Y?Y(F):!0}const V=e.ref("library"),I=e.ref(n.layoutMode??n.initialLayoutMode??"grid"),x=e.ref(null),N=e.ref(null);function L(F){return{...F??{},...(F==null?void 0:F.kinds)!==void 0?{kinds:[...F.kinds]}:{}}}const C=e.ref(n.initialView??{scope:"library"}),T=e.ref(L(n.filters)),y=Bd({httpClient:n.httpClient,view:C,filters:T,perPage:n.perPage??50}),R=e.computed(()=>y.items.value),U=e.computed(()=>y.loading.value),z=e.computed(()=>{var F;return((F=y.error.value)==null?void 0:F.message)??null}),W=e.computed(()=>r.value.allowBulkDelete!==!1||r.value.allowCreatePost===!0||r.value.allowCreateGallery===!0||r.value.allowAddToAlbum===!0),B=e.computed(()=>{const F=x.value;return F===null?null:R.value[F]??null}),P=qu(R),X=wf({httpClient:n.httpClient}),K=kf({httpClient:n.httpClient});function be(F){return s.value.selectedCount(F)}function Ne(F){return s.value.purgeAfter(F)}function ue(F){return s.value.ownerLabel(F)}const re=e.computed(()=>{const F=R.value.length;return F===0?"":y.hasMore.value?F===1?"Showing 1 item":`Showing ${F} items`:F===1?"Showing all 1 item":`Showing all ${F} items`});function O(F){I.value!==F&&(Oe(),I.value=F,i("update:layoutMode",F))}function D(F){return F.mime_type.startsWith("image/")}function J(F){return F.mime_type.startsWith("video/")}function Z(F){return D(F)?"image":J(F)?"video":null}function ie(F){return D(F)?r.value.allowImageEdit===!0:J(F)?r.value.allowVideoEdit===!0:!1}const se=/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/ig,Ue=/[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 me(F){const Y=F.replace(/\.[^.]+$/,""),ee=Y.replace(se,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim();return ee!==""?ee:Y||F}function ve(F){var we,Ve;const Y=(we=F.name)==null?void 0:we.trim(),j=F.file_name.replace(/\.[^.]+$/,"");if(Y!==void 0&&Y!==""&&Y!==F.file_name&&Y!==j&&!Ue.test(Y))return Y;const ee=(Ve=F.alt_text)==null?void 0:Ve.trim();return ee!==void 0&&ee!==""?ee:me(Y||F.file_name)}function fe(F){return D(F)?"Image":J(F)?"Video":F.mime_type.startsWith("audio/")?"Audio":"File"}function Ee(F){if(typeof F.formatted_size=="string"&&F.formatted_size.trim()!=="")return F.formatted_size;if(!Number.isFinite(F.size)||F.size<=0)return"";const Y=["B","KB","MB","GB"];let j=F.size,ee=0;for(;j>=1024&&ee<Y.length-1;)j/=1024,ee+=1;return`${j>=10||ee===0?Math.round(j):j.toFixed(1)} ${Y[ee]}`}function ye(F){const Y=new Date(F.created_at);return Number.isNaN(Y.getTime())?F.created_at:new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(Y)}function Be(F){return F.deletion_status==="active"||F.deletion_status===void 0||F.deletion_status===null?"Ready":F.deletion_status.replace(/_/g," ").replace(/\b\w/g,Y=>Y.toUpperCase())}function Ie(F){if(typeof F.thumbnail_url=="string"&&F.thumbnail_url.length>0)return F.thumbnail_url;const Y=typeof F.mime_type=="string"&&F.mime_type.startsWith("image/"),j=typeof F.mime_type=="string"&&F.mime_type.startsWith("video/");return Y?F.original_url||null:j&&typeof F.preview_url=="string"&&F.preview_url.length>0?F.preview_url:null}function et(F){return typeof F.mime_type=="string"&&F.mime_type.startsWith("video/")?`Video — ${F.file_name}`:F.file_name}const tt=e.ref(new Set);function Tt(F){if(tt.value.has(F.uuid))return;const Y=new Set(tt.value);Y.add(F.uuid),tt.value=Y}function vt(F){if(r.value.allowPreview===!1)return;const Y=R.value.findIndex(j=>j.uuid===F.uuid);x.value=Y>=0?Y:null}function xt(){x.value=null}function wt(){x.value===null||x.value<=0||(x.value-=1)}function it(){x.value===null||x.value>=R.value.length-1||(x.value+=1)}async function _t(){try{await y.loadMore()}catch(F){i("error",F instanceof Error?F:new Error(String(F)))}}function ge(F,Y){i("create-post",{mediaIds:F.map(j=>j.uuid),items:F,source:Y})}function ke(F,Y){i("create-gallery",{mediaIds:F.map(j=>j.uuid),items:F,source:Y})}function Te(F,Y){i("add-to-album",{mediaIds:F.map(j=>j.uuid),items:F,source:Y})}function Ke(F){const Y=Z(F);Y===null||!ie(F)||i("edit",{media:F,kind:Y})}function Ge(F){N.value=N.value===F?null:F}function Oe(){N.value=null}function kt(F){F.run(),Oe()}function lt(F){const Y=[];return r.value.allowPreview!==!1&&Y.push({id:"preview",label:s.value.previewButton,testId:`btn-preview-${F.uuid}`,run:()=>vt(F)}),ie(F)&&Y.push({id:"edit",label:s.value.editButton,testId:`btn-edit-${F.uuid}`,run:()=>Ke(F)}),r.value.allowCreatePost===!0&&Y.push({id:"create-post",label:s.value.createPostButton,testId:`btn-create-post-${F.uuid}`,run:()=>ge([F],"item")}),r.value.allowCreateGallery===!0&&Y.push({id:"create-gallery",label:s.value.createGalleryButton,testId:`btn-create-gallery-${F.uuid}`,run:()=>ke([F],"item")}),r.value.allowAddToAlbum===!0&&Y.push({id:"add-to-album",label:s.value.addToAlbumButton,testId:`btn-add-to-album-${F.uuid}`,run:()=>Te([F],"item")}),Y}async function zt(){const F=P.selectedItems.value;if(F.length===0)return;const Y=r.value.canDelete?F.filter(j=>r.value.canDelete(j)):F;if(Y.length!==0&&!(n.confirmBulkDelete&&!await n.confirmBulkDelete(Y)))try{const j=Y.map(Ve=>Ve.uuid),we=(await X.deleteMany(j)).results.filter(Ve=>Ve.status==="trashed"||Ve.status==="already_trashed").map(Ve=>Ve.uuid);if(we.length>0){for(const Ve of we)P.deselect(Ve);i("deleted",we),await y.refresh(),r.value.showTrash!==!1&&await K.fetch(K.currentPage.value).catch(()=>{})}}catch(j){i("error",j instanceof Error?j:new Error(String(j)))}}async function At(F){var j;const Y=K.items.value.find(ee=>ee.uuid===F);if(!(Y&&!$(Y)))try{const ee=await K.restore(F);if(ee.status==="restored"){i("restored",F),await y.refresh().catch(()=>{});return}if(ee.status==="duplicate_conflict"){i("restore-conflict",{uuid:F,duplicateUuid:ee.duplicate_uuid??null}),(j=n.onRestoreCollision)==null||j.call(n,F,ee.duplicate_uuid??null);return}}catch(ee){i("error",ee instanceof Error?ee:new Error(String(ee)))}}async function Jt(){V.value="trash",K.items.value.length===0&&!K.isLoading.value&&await K.fetch().catch(F=>{i("error",F instanceof Error?F:new Error(String(F)))})}function Gt(F){if(F==="trash"){Jt();return}V.value=F}const la=e.computed(()=>({activeTab:V.value,setActiveTab:Gt,trashCount:K.total.value,showTrash:r.value.showTrash!==!1,labels:{libraryTab:s.value.libraryTab,trashTab:s.value.trashTab}})),ga=e.computed(()=>({selectedCount:P.selectedCount.value,selectedItemIds:Array.from(P.selectedIds.value),selectedItems:P.selectedItems.value,isDeleting:X.isDeleting.value,onBulkDelete:zt,...r.value.allowCreatePost===!0?{onCreatePost:()=>ge(P.selectedItems.value,"bulk")}:{},...r.value.allowCreateGallery===!0?{onCreateGallery:()=>ke(P.selectedItems.value,"bulk")}:{},...r.value.allowAddToAlbum===!0?{onAddToAlbum:()=>Te(P.selectedItems.value,"bulk")}:{},clearSelection:P.clear,labels:{deleteButton:s.value.deleteButton,...r.value.allowCreatePost===!0?{createPostButton:s.value.createPostButton}:{},...r.value.allowCreateGallery===!0?{createGalleryButton:s.value.createGalleryButton}:{},...r.value.allowAddToAlbum===!0?{addToAlbumButton:s.value.addToAlbumButton}:{},selectedCount:s.value.selectedCount}}));function ia(F){return{media:F,selected:P.isSelected(F.uuid),canEdit:ie(F),onPreview:()=>vt(F),...ie(F)?{onEdit:()=>Ke(F)}:{},...r.value.allowCreatePost===!0?{onCreatePost:()=>ge([F],"item")}:{},...r.value.allowCreateGallery===!0?{onCreateGallery:()=>ke([F],"item")}:{},...r.value.allowAddToAlbum===!0?{onAddToAlbum:()=>Te([F],"item")}:{},labels:{previewButton:s.value.previewButton,editButton:s.value.editButton,createPostButton:s.value.createPostButton,createGalleryButton:s.value.createGalleryButton,addToAlbumButton:s.value.addToAlbumButton}}}function Aa(F){return{media:F,canRestore:$(F),isRestoring:K.isRestoring.value,onRestore:()=>At(F.uuid),labels:{restoreButton:s.value.restoreButton,restoreUnavailable:s.value.restoreUnavailable}}}return e.watch(V,async F=>{F==="library"&&R.value.length===0&&!U.value&&await y.refresh().catch(()=>{})}),e.watch(()=>n.layoutMode,F=>{F!==void 0&&(I.value=F)}),e.watch(()=>n.filters,async F=>{T.value=L(F),P.clear(),xt(),await y.refresh().catch(Y=>{i("error",Y instanceof Error?Y:new Error(String(Y)))})},{deep:!0}),e.onMounted(async()=>{await y.refresh().catch(F=>{i("error",F instanceof Error?F:new Error(String(F)))}),r.value.showTrash!==!1&&K.fetch().catch(()=>{})}),a({refresh:()=>y.refresh(),refreshTrash:()=>K.fetch(),selection:P,deletion:X,trash:K}),(F,Y)=>(e.openBlock(),e.createElementBlock("div",RD,[r.value.showHeader!==!1?(e.openBlock(),e.createElementBlock("header",AD,[e.createElementVNode("h2",LD,e.toDisplayString(l.value),1),e.createElementVNode("div",PD,[e.renderSlot(F.$slots,"tabs",e.normalizeProps(e.guardReactiveProps(la.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:Y[0]||(Y[0]=j=>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:Jt},[e.createTextVNode(e.toDisplayString(c.value)+" ",1),e.unref(K).total.value>0?(e.openBlock(),e.createElementBlock("span",UD,e.toDisplayString(e.unref(K).total.value),1)):e.createCommentVNode("",!0)],2)],64)):e.createCommentVNode("",!0)],!0)])])):e.createCommentVNode("",!0),V.value==="library"?(e.openBlock(),e.createElementBlock("section",OD,[r.value.showLayoutSwitcher!==!1?(e.openBlock(),e.createElementBlock("div",zD,[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:Y[1]||(Y[1]=j=>O("grid"))},e.toDisplayString(k.value),11,jD),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:Y[2]||(Y[2]=j=>O("table"))},e.toDisplayString(b.value),11,WD)])):e.createCommentVNode("",!0),U.value?(e.openBlock(),e.createElementBlock("div",HD,e.toDisplayString(u.value),1)):z.value?(e.openBlock(),e.createElementBlock("div",ZD,e.toDisplayString(z.value),1)):R.value.length===0?(e.openBlock(),e.createElementBlock("div",GD,[e.renderSlot(F.$slots,"empty-library",{},()=>[e.createElementVNode("div",XD,[e.createElementVNode("p",KD,e.toDisplayString(f.value),1),e.createElementVNode("p",JD,e.toDisplayString(m.value),1)])],!0)])):I.value==="table"?(e.openBlock(),e.createElementBlock("table",qD,[e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[e.createElementVNode("th",YD,e.toDisplayString(s.value.tableSelectHeader),1),e.createElementVNode("th",QD,e.toDisplayString(s.value.tableThumbnailHeader),1),e.createElementVNode("th",eR,e.toDisplayString(s.value.tableNameHeader),1),e.createElementVNode("th",tR,e.toDisplayString(s.value.tableTypeHeader),1),e.createElementVNode("th",aR,e.toDisplayString(s.value.tableCreatedHeader),1),e.createElementVNode("th",nR,e.toDisplayString(s.value.tableSizeHeader),1),e.createElementVNode("th",oR,e.toDisplayString(s.value.tableStatusHeader),1),e.createElementVNode("th",iR,e.toDisplayString(s.value.tableActionsHeader),1)])]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(R.value,j=>(e.openBlock(),e.createElementBlock("tr",{key:j.uuid,class:e.normalizeClass({"is-selected":e.unref(P).isSelected(j.uuid),"has-open-actions":N.value===j.uuid}),"data-testid":`media-row-${j.uuid}`},[e.createElementVNode("td",null,[e.createElementVNode("button",{type:"button",class:"media-management-view__table-select","data-testid":`btn-select-${j.uuid}`,"aria-pressed":e.unref(P).isSelected(j.uuid),onClick:ee=>e.unref(P).toggle(j.uuid)},e.toDisplayString(e.unref(P).isSelected(j.uuid)?"Selected":"Select"),9,sR)]),e.createElementVNode("td",null,[e.createElementVNode("button",{type:"button",class:"media-management-view__table-thumb","data-testid":`btn-preview-thumb-${j.uuid}`,onClick:ee=>vt(j)},[Ie(j)&&!tt.value.has(j.uuid)?(e.openBlock(),e.createElementBlock("img",{key:0,src:Ie(j)??"",alt:j.alt_text||j.file_name,loading:"lazy",onError:ee=>Tt(j)},null,40,dR)):(e.openBlock(),e.createElementBlock("span",{key:1,class:"media-management-view__item-placeholder","data-testid":`placeholder-${j.uuid}`},e.toDisplayString(et(j)),9,cR))],8,lR)]),e.createElementVNode("td",null,[e.createElementVNode("span",{class:"media-management-view__display-name",title:j.file_name,"data-testid":`media-display-name-${j.uuid}`},e.toDisplayString(ve(j)),9,uR),r.value.showRawFileName===!0?(e.openBlock(),e.createElementBlock("span",{key:0,class:"media-management-view__raw-filename","data-testid":`media-raw-filename-${j.uuid}`},e.toDisplayString(j.file_name),9,mR)):e.createCommentVNode("",!0)]),e.createElementVNode("td",null,e.toDisplayString(fe(j)),1),e.createElementVNode("td",null,e.toDisplayString(ye(j)),1),e.createElementVNode("td",null,e.toDisplayString(Ee(j)),1),e.createElementVNode("td",null,e.toDisplayString(Be(j)),1),e.createElementVNode("td",null,[e.renderSlot(F.$slots,"item-actions",e.mergeProps({ref_for:!0},ia(j)),()=>[e.createElementVNode("div",pR,[e.createElementVNode("div",{class:"media-management-view__action-menu",onKeydown:e.withKeys(e.withModifiers(Oe,["stop"]),["escape"])},[e.createElementVNode("button",{type:"button",class:"media-management-view__action-menu-trigger","data-testid":`btn-actions-menu-${j.uuid}`,"aria-label":`Actions for ${ve(j)}`,"aria-haspopup":"menu","aria-expanded":N.value===j.uuid?"true":"false",onClick:ee=>Ge(j.uuid)}," ... ",8,hR),N.value===j.uuid?(e.openBlock(),e.createElementBlock("div",{key:0,class:"media-management-view__action-menu-panel",role:"menu","data-testid":`media-item-actions-menu-${j.uuid}`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(lt(j),ee=>(e.openBlock(),e.createElementBlock("button",{key:ee.id,type:"button",class:"media-management-view__action-menu-item",role:"menuitem","data-testid":ee.testId,onClick:we=>kt(ee)},e.toDisplayString(ee.label),9,gR))),128))],8,vR)):e.createCommentVNode("",!0)],40,fR)])],!0)])],10,rR))),128))])])):(e.openBlock(),e.createElementBlock("ul",bR,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(R.value,j=>(e.openBlock(),e.createElementBlock("li",{key:j.uuid,class:e.normalizeClass(["media-management-view__item",{"is-selected":e.unref(P).isSelected(j.uuid),"has-open-actions":N.value===j.uuid}]),"data-testid":`media-item-${j.uuid}`},[e.createElementVNode("button",{type:"button",class:"media-management-view__item-thumb","data-testid":`btn-select-${j.uuid}`,"aria-pressed":e.unref(P).isSelected(j.uuid),onClick:ee=>e.unref(P).toggle(j.uuid)},[Ie(j)&&!tt.value.has(j.uuid)?(e.openBlock(),e.createElementBlock("img",{key:0,src:Ie(j)??"",alt:j.alt_text||j.file_name,loading:"lazy",onError:ee=>Tt(j)},null,40,kR)):(e.openBlock(),e.createElementBlock("span",{key:1,class:"media-management-view__item-placeholder","data-testid":`placeholder-${j.uuid}`},e.toDisplayString(et(j)),9,_R))],8,wR),e.createElementVNode("div",ER,[e.createElementVNode("span",{class:"media-management-view__item-name",title:j.file_name,"data-testid":`media-display-name-${j.uuid}`},e.toDisplayString(ve(j)),9,xR),r.value.showRawFileName===!0?(e.openBlock(),e.createElementBlock("span",{key:0,class:"media-management-view__raw-filename","data-testid":`media-raw-filename-${j.uuid}`},e.toDisplayString(j.file_name),9,SR)):e.createCommentVNode("",!0),r.value.showOwner&&j.user_id?(e.openBlock(),e.createElementBlock("span",{key:1,class:"media-management-view__item-owner","data-testid":`owner-${j.uuid}`},e.toDisplayString(ue(j)),9,CR)):e.createCommentVNode("",!0),j.is_orphaned?(e.openBlock(),e.createElementBlock("span",VR,e.toDisplayString(v.value),1)):e.createCommentVNode("",!0)]),e.renderSlot(F.$slots,"item-actions",e.mergeProps({ref_for:!0},ia(j)),()=>[e.createElementVNode("div",NR,[e.createElementVNode("div",{class:"media-management-view__action-menu",onKeydown:e.withKeys(e.withModifiers(Oe,["stop"]),["escape"])},[e.createElementVNode("button",{type:"button",class:"media-management-view__action-menu-trigger","data-testid":`btn-actions-menu-${j.uuid}`,"aria-label":`Actions for ${ve(j)}`,"aria-haspopup":"menu","aria-expanded":N.value===j.uuid?"true":"false",onClick:ee=>Ge(j.uuid)}," ... ",8,BR),N.value===j.uuid?(e.openBlock(),e.createElementBlock("div",{key:0,class:"media-management-view__action-menu-panel",role:"menu","data-testid":`media-item-actions-menu-${j.uuid}`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(lt(j),ee=>(e.openBlock(),e.createElementBlock("button",{key:ee.id,type:"button",class:"media-management-view__action-menu-item",role:"menuitem","data-testid":ee.testId,onClick:we=>kt(ee)},e.toDisplayString(ee.label),9,MR))),128))],8,IR)):e.createCommentVNode("",!0)],40,TR)])],!0)],10,yR))),128))])),e.unref(P).selectedCount.value>0&&W.value?e.renderSlot(F.$slots,"bulk-actions",e.normalizeProps(e.mergeProps({key:6},ga.value)),()=>[e.createElementVNode("footer",FR,[e.createElementVNode("span",$R,e.toDisplayString(be(e.unref(P).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:Y[3]||(Y[3]=j=>ge(e.unref(P).selectedItems.value,"bulk"))},e.toDisplayString(s.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:Y[4]||(Y[4]=j=>ke(e.unref(P).selectedItems.value,"bulk"))},e.toDisplayString(s.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:Y[5]||(Y[5]=j=>Te(e.unref(P).selectedItems.value,"bulk"))},e.toDisplayString(s.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(X).isDeleting.value,onClick:zt},e.toDisplayString(w.value),9,DR)):e.createCommentVNode("",!0)])],!0):e.createCommentVNode("",!0),R.value.length>0?(e.openBlock(),e.createElementBlock("footer",RR,[e.createElementVNode("span",AR,e.toDisplayString(re.value),1),e.unref(y).hasMore.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-management-view__load-more","data-testid":"btn-media-management-load-more",disabled:e.unref(y).loadingMore.value,onClick:_t},e.toDisplayString(e.unref(y).loadingMore.value?s.value.loadingMoreButton:s.value.loadMoreButton),9,LR)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])):V.value==="trash"?(e.openBlock(),e.createElementBlock("section",PR,[e.unref(K).isLoading.value?(e.openBlock(),e.createElementBlock("div",UR,e.toDisplayString(u.value),1)):e.unref(K).items.value.length===0?(e.openBlock(),e.createElementBlock("div",OR,[e.renderSlot(F.$slots,"empty-trash",{},()=>[e.createElementVNode("div",zR,[e.createElementVNode("p",jR,e.toDisplayString(p.value),1),e.createElementVNode("p",WR,e.toDisplayString(h.value),1)])],!0)])):(e.openBlock(),e.createElementBlock("ul",HR,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(K).items.value,j=>(e.openBlock(),e.createElementBlock("li",{key:j.uuid,class:"media-management-view__item is-trashed","data-testid":`trash-item-${j.uuid}`},[e.createElementVNode("div",GR,[Ie(j)&&!tt.value.has(j.uuid)?(e.openBlock(),e.createElementBlock("img",{key:0,src:Ie(j)??"",alt:j.alt_text||j.file_name,loading:"lazy",onError:ee=>Tt(j)},null,40,XR)):(e.openBlock(),e.createElementBlock("span",{key:1,class:"media-management-view__item-placeholder","data-testid":`placeholder-trash-${j.uuid}`},e.toDisplayString(et(j)),9,KR))]),e.createElementVNode("div",JR,[e.createElementVNode("span",qR,e.toDisplayString(j.file_name),1),j.purge_after?(e.openBlock(),e.createElementBlock("span",YR,e.toDisplayString(Ne(j.purge_after)),1)):e.createCommentVNode("",!0)]),e.renderSlot(F.$slots,"trash-action",e.mergeProps({ref_for:!0},Aa(j)),()=>[$(j)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-management-view__btn-restore","data-testid":`btn-restore-${j.uuid}`,disabled:e.unref(K).isRestoring.value,onClick:ee=>At(j.uuid)},e.toDisplayString(E.value),9,QR)):(e.openBlock(),e.createElementBlock("span",{key:1,class:"media-management-view__btn-restore is-unavailable","data-testid":`btn-restore-${j.uuid}-unavailable`,"aria-disabled":!0},e.toDisplayString(S.value),9,eA))],!0)],8,ZR))),128))]))])):e.createCommentVNode("",!0),r.value.allowPreview!==!1?(e.openBlock(),e.createBlock(Cd,{key:3,open:B.value!==null,media:B.value,"can-go-previous":x.value!==null&&x.value>0,"can-go-next":x.value!==null&&x.value<R.value.length-1,selected:B.value!==null&&e.unref(P).isSelected(B.value.uuid),"close-label":s.value.previewCloseButton,"previous-label":s.value.previewPreviousButton,"next-label":s.value.previewNextButton,"select-label":s.value.previewSelectButton,"deselect-label":s.value.previewDeselectButton,onClose:xt,onPrevious:wt,onNext:it,onToggleSelect:Y[6]||(Y[6]=j=>e.unref(P).toggle(j.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)]))}}),aA=Fe(tA,[["__scopeId","data-v-d7a5e627"]]);exports.AlbumBrowser=Gp;exports.AlbumManager=bF;exports.AlbumMediaGrid=BF;exports.AlbumTree=Zp;exports.ArrayBufferTarget=ad;exports.ExistingMediaSelector=qg;exports.ImageEditor=zu;exports.ImageEditorModal=ju;exports.LiveStreamManager=L5;exports.ManagedMediaGallery=Nh;exports.MediaAlbumInlineCreate=Xp;exports.MediaAlbumUnavailableState=Kp;exports.MediaAttachment=gD;exports.MediaAttachmentMetadataFields=BD;exports.MediaCollection=lD;exports.MediaCollectionDropzone=Dd;exports.MediaCollectionItem=Rd;exports.MediaLibraryPicker=vf;exports.MediaLibraryPickerModal=o$;exports.MediaManagementView=aA;exports.MediaPreviewSheet=Cd;exports.MediaSelectionTray=h$;exports.MediaSourceSheet=af;exports.MediaThumbnailCell=of;exports.MediaUploadSheet=nf;exports.MediaWorkspace=xh;exports.ModelMediaManager=yg;exports.Muxer=pm;exports.VideoEditor=Pp;exports.VideoEditorDialog=kB;exports.VideoEditorSimple=HB;exports.VideoExportPanel=x3;exports.VideoJobClient=ys;exports.VideoPlayer=jp;exports.VideoTimeline=hI;exports.VideoToolsPanel=o3;exports.VideoUploader=uM;exports.VirtualMediaGrid=rf;exports._sfc_main=bD;exports._sfc_main$1=yD;exports._sfc_main$2=xD;exports.applyTemporaryMediaStoreConfig=$u;exports.configureAlbumStore=G5;exports.configureMediaStore=So;exports.createAdapter=gf;exports.createEmptyEditorState=Kf;exports.createImageEditor=g$;exports.createMediablesAdapter=Fd;exports.createSpatieAdapter=$d;exports.deserializeEditorState=Xf;exports.formatFileSize=Gr;exports.fromMediaArray=Gl;exports.getFileExtension=sf;exports.getImageDimensions=lf;exports.getMediablesAdapter=b$;exports.getSpatieAdapter=k$;exports.isImageFile=Vd;exports.normalizeEditorState=Xl;exports.normalizeRecipeForServerRender=aB;exports.recipeHasServerRenderableEdits=tB;exports.recipeHasUnsupportedServerEdits=zp;exports.resetMediablesAdapter=y$;exports.resetSpatieAdapter=_$;exports.restoreAlbumStoreConfig=K5;exports.restoreMediaStoreConfig=Fu;exports.serializeEditorState=Iu;exports.snapshotAlbumStoreConfig=X5;exports.snapshotMediaStoreConfig=Mu;exports.toFormValues=Md;exports.useAdminMediaStore=Du;exports.useAlbumDragDrop=Hp;exports.useAlbumStore=ks;exports.useAlbums=Wp;exports.useGlobalImageEditor=v$;exports.useImageEditorModal=Id;exports.useMediaAttachment=Ad;exports.useMediaCollection=_s;exports.useMediaDeletion=wf;exports.useMediaDragSort=bf;exports.useMediaLibraryPickerController=hf;exports.useMediaLibraryQuery=Bd;exports.useMediaLibrarySession=uf;exports.useMediaLibraryStateMachine=mf;exports.useMediaLibraryTelemetry=pf;exports.useMediaStore=xa;exports.useMediaTrash=kf;exports.useMediaUploadQueue=Td;exports.useMediaValidation=Nd;exports.validateFile=df;
|
|
357
|
-
//# sourceMappingURL=index-zFuo-sDY.cjs.map
|