@codingfactory/mediables-vue 2.9.3 → 2.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{PixiFrameExporter-6l-tVJXc.cjs → PixiFrameExporter-YTbrR4NY.cjs} +2 -2
- package/dist/{PixiFrameExporter-6l-tVJXc.cjs.map → PixiFrameExporter-YTbrR4NY.cjs.map} +1 -1
- package/dist/{PixiFrameExporter-DiX2TyR3.js → PixiFrameExporter-_vGMbqFu.js} +2 -2
- package/dist/{PixiFrameExporter-DiX2TyR3.js.map → PixiFrameExporter-_vGMbqFu.js.map} +1 -1
- package/dist/components/MediaLibraryPicker.vue.d.ts +14 -1
- package/dist/components/MediaManagementView.vue.d.ts +19 -1
- package/dist/composables/useAssetImport.d.ts +48 -0
- package/dist/composables/useEditorShortcuts.d.ts +53 -0
- package/dist/composables/useMediaLibraryPickerController.d.ts +2 -1
- package/dist/composables/useProjectDraftSync.d.ts +43 -0
- package/dist/composables/useVideoEditor.d.ts +14 -8
- package/dist/index-BCai7yWf.cjs +357 -0
- package/dist/{index-Dvqt7Fr6.cjs.map → index-BCai7yWf.cjs.map} +1 -1
- package/dist/index-CRzkO6MD.js +34984 -0
- package/dist/{index--jjdabLj.js.map → index-CRzkO6MD.js.map} +1 -1
- package/dist/mediables-vue.cjs +1 -1
- package/dist/mediables-vue.mjs +1 -1
- package/dist/style.css +1 -1
- package/dist/types/mediaLibraryPicker.d.ts +119 -0
- package/dist/video/project/assetBlobCache.d.ts +41 -0
- package/dist/video/project/assetLifecycle.d.ts +95 -0
- package/dist/video/project/editorCommandResult.d.ts +25 -0
- package/dist/video/project/projectDraftStore.d.ts +91 -0
- package/dist/video/project/sourceUsage.d.ts +20 -0
- package/dist/video/project/timelineCollision.d.ts +41 -0
- package/dist/video/project/trackCompatibility.d.ts +16 -0
- package/package.json +1 -1
- package/dist/index--jjdabLj.js +0 -33206
- package/dist/index-Dvqt7Fr6.cjs +0 -350
package/dist/index-Dvqt7Fr6.cjs
DELETED
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
"use strict";var Wp=Object.defineProperty;var Zp=(a,n,t)=>n in a?Wp(a,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[n]=t;var K=(a,n,t)=>Zp(a,typeof n!="symbol"?n+"":n,t);const mr=require("pinia"),e=require("vue"),mt=require("pixi.js"),pe=require("./editor-BTwIhrcA.cjs"),U=require("@ionic/vue"),Hp=require("pixi-filters");function Xp(a){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>a[t]})}}return n.default=a,Object.freeze(n)}const Vt=Xp(mt),Es=1,Gp=new Set(["free","square","circle"]);function Jp(a){const n=typeof a;return n==="string"||n==="number"||n==="boolean"}function Kp(a){if(!a||typeof a!="object")return!1;const n=a;return typeof n.x=="number"&&typeof n.y=="number"&&typeof n.width=="number"&&typeof n.height=="number"}function cl(a){if(!a||typeof a!="object")return null;const n=a;if(n.version!==Es)return null;const t=n.crop,o=t&&Kp(t.rect)?{...t.rect}:null,i=t&&typeof t.shape=="string"&&Gp.has(t.shape)?t.shape:"free",r=t&&typeof t.aspectRatio=="string"?t.aspectRatio:"free",s=n.filters,l=[];if(Array.isArray(s))for(const c of s){if(!c||typeof c!="object")continue;const d=c;if(typeof d.id!="string")continue;const u={},f=d.values;if(f&&typeof f=="object"&&!Array.isArray(f))for(const[p,m]of Object.entries(f))Jp(m)&&(u[p]=m);l.push({id:d.id,enabled:d.enabled!==!1,values:u})}return{version:Es,crop:{rect:o,aspectRatio:r,shape:i},filters:l}}function Fd(a){const n=cl(a);return n?JSON.stringify(n):null}function Yp(a){try{const n=JSON.parse(a);return cl(n)}catch{return null}}function qp(){return{version:Es,crop:{rect:null,aspectRatio:"free",shape:"free"},filters:[]}}let dn={apiBaseUrl:"/api/v1",isAdmin:!1};function no(a){dn={...dn,...a}}function $d(){return{...dn}}function Dd(a){dn={...a}}function Rd(a){const n=$d();return no(a),()=>{Dd(n)}}const Qp=async(a,n={})=>{var l;const t=(l=document.querySelector('meta[name="csrf-token"]'))==null?void 0:l.getAttribute("content"),o={Accept:"application/json",...n.headers};t&&(o["X-CSRF-TOKEN"]=t),n.body instanceof FormData||(o["Content-Type"]="application/json");const r={method:n.method||"GET",headers:o,credentials:"include"};n.body instanceof FormData?r.body=n.body:n.body!==void 0&&(r.body=JSON.stringify(n.body));const s=await fetch(a,r);if(!s.ok){const c=await s.json().catch(()=>({message:"Request failed"}));throw new Error(c.message||`HTTP ${s.status}`)}if(s.status!==204)return await s.json()},ln=mr.defineStore("media",()=>{const a=e.ref([]),n=e.ref([]),t=e.ref(!1),o=e.ref(null),i=e.ref(1),r=e.ref(1),s=e.ref(24),l=e.ref({type:null,uuid:null}),c=e.ref([]),d=e.ref(!1),u=e.ref(null),f=e.ref(new Map),p=e.ref(new Map),m=e.ref(new Set),h=e.ref(new Map),g=e.ref({}),k=5*60*1e3,$=e.computed(()=>{if(dn.apiScope)return dn.apiScope;if(dn.isAdmin)return"admin"}),D=e.computed(()=>$.value==="admin");function _(){return dn.httpClient||Qp}function v(de){const ye=dn.apiBaseUrl||"/api/v1",Be=$.value?`/${$.value}`:"";return`${ye}${Be}${de}`}function S(de,ye){return`${$.value??"default"}-${de}-${JSON.stringify(ye)}`}function C(de){return Date.now()-de<k}function V(){h.value.clear(),g.value={}}function x(de){if(!de||!de.data)return;const ye={};de.data.forEach(Be=>{const fe=`${Be.file_name}-${Be.collection_name||"default"}`,ge=ye[fe];(!ge||Object.keys(Be.generated_conversions||{}).length>Object.keys(ge.generated_conversions||{}).length)&&(ye[fe]=Be)}),a.value=Object.values(ye),de.meta&&(i.value=de.meta.current_page,r.value=Math.ceil(de.meta.total/de.meta.per_page))}async function T(de=1,ye={}){const Be=S(de,ye),fe=h.value.get(Be);if(fe&&C(fe.timestamp)){const ge=fe.data;return x(ge),ge}t.value=!0,o.value=null;try{const ge=new URLSearchParams;ge.append("page",de.toString()),ge.append("per_page",s.value.toString()),D.value&&ge.append("linked","1");for(const pt in ye)if(Object.prototype.hasOwnProperty.call(ye,pt)){const lt=ye[pt];lt!=null&<!==""&&ge.append(pt,String(lt))}const Ie=await _()(v(`/media?${ge}`));return h.value.set(Be,{data:Ie,timestamp:Date.now()}),x(Ie),Ie}catch(ge){throw o.value=ge instanceof Error?ge.message:"Failed to fetch media",a.value=[],new Error(o.value)}finally{t.value=!1}}async function j(de,ye){t.value=!0,o.value=null;const Be=`${de.name}-${Date.now()}`,fe={file:de,progress:0,status:"uploading"};f.value.set(Be,fe);try{const ge=new FormData;ge.append("file",de),ge.append("collection",ye.collection),ye.ownerUuid&&(ge.append("owner_uuid",ye.ownerUuid),ge.append("owner_type",ye.ownerType||"")),ye.usageUuid&&(ge.append("usage_uuid",ye.usageUuid),ge.append("usage_type",ye.usageType||""),ge.append("usage_purpose",ye.usagePurpose||"")),ye.customProperties&&ge.append("custom_properties",JSON.stringify(ye.customProperties));const Ie=await _()(v("/media"),{method:"POST",body:ge});return fe.status="completed",fe.progress=100,fe.media=Ie==null?void 0:Ie.data,i.value===1&&(Ie!=null&&Ie.data)&&(a.value=[Ie.data,...a.value]),V(),(Ie==null?void 0:Ie.data)||null}catch(ge){throw fe.status="error",fe.error=ge instanceof Error?ge.message:"Upload failed",o.value=fe.error,new Error(o.value)}finally{t.value=!1,setTimeout(()=>{f.value.delete(Be)},5e3)}}async function E(de){t.value=!0,o.value=null;const ye=a.value.findIndex(fe=>fe.uuid===de);let Be;ye!==-1&&(Be=a.value.splice(ye,1)[0]);try{return await _()(v(`/media/${de}`),{method:"DELETE"}),m.value.delete(de),V(),!0}catch(fe){throw Be&&ye!==-1&&a.value.splice(ye,0,Be),o.value=fe instanceof Error?fe.message:"Failed to delete media",new Error(o.value)}finally{t.value=!1}}async function A(de,ye){t.value=!0,o.value=null;try{const fe=await _()(v(`/media/${de}`),{method:"PATCH",body:ye,data:ye});if(fe!=null&&fe.data){const ge=a.value.findIndex(Se=>Se.uuid===de);return ge!==-1&&(a.value[ge]={...a.value[ge],...fe.data}),V(),fe.data}return null}catch(Be){throw o.value=Be instanceof Error?Be.message:"Failed to update media",new Error(o.value)}finally{t.value=!1}}async function N(){t.value=!0,o.value=null;try{const ye=await _()(v("/media/collections"));return n.value=(ye==null?void 0:ye.data)||[],n.value}catch(de){throw o.value=de instanceof Error?de.message:"Failed to fetch collections",n.value=[],new Error(o.value)}finally{t.value=!1}}async function z(de,ye,Be="images",fe){d.value=!0,u.value=null;try{const ge=new URLSearchParams;ge.append("collection",Be),fe&&ge.append("search",fe);const Ie=await _()(v(`/media/model/${de}/${ye}?${ge}`));return Ie!=null&&Ie.data?(c.value=Ie.data,Ie.data):[]}catch(ge){throw u.value=ge instanceof Error?ge.message:"Failed to fetch model media",c.value=[],new Error(u.value)}finally{d.value=!1}}async function P(de,ye,Be,fe="images"){d.value=!0,u.value=null;const ge=[...c.value];try{const Ie=await _()(v(`/media/model/${de}/${ye}/attach`),{method:"POST",body:{media_uuids:Be,collection:fe}});return await z(de,ye,fe),(Ie==null?void 0:Ie.data)||[]}catch(Se){throw c.value=ge,u.value=Se instanceof Error?Se.message:"Failed to attach media",new Error(u.value)}finally{d.value=!1}}async function B(de,ye,Be,fe="images"){d.value=!0,u.value=null;const ge=[...c.value];c.value=c.value.filter(Se=>Se.uuid!==Be);try{return await _()(v(`/media/model/${de}/${ye}/detach`),{method:"POST",body:{media_uuid:Be,collection:fe}}),!0}catch(Se){throw c.value=ge,u.value=Se instanceof Error?Se.message:"Failed to detach media",new Error(u.value)}finally{d.value=!1}}async function L(de,ye,Be,fe="images"){d.value=!0,u.value=null;const ge=[...c.value],Se=new Map(c.value.map(Ie=>[Ie.uuid,Ie]));c.value=Be.map(Ie=>Se.get(Ie)).filter(Ie=>Ie!==void 0);try{return await _()(v(`/media/model/${de}/${ye}/reorder`),{method:"POST",body:{media_uuids:Be,collection:fe}}),!0}catch(Ie){throw c.value=ge,u.value=Ie instanceof Error?Ie.message:"Failed to reorder media",new Error(u.value)}finally{d.value=!1}}async function w(de,ye,Be={}){const fe=_(),ge=dn.apiBaseUrl||"/api/v1",Se=new FormData,Ie=ye.imageData,pt=Ie.match(/^data:(image\/\w+);base64,/),lt=pt?pt[1]:"image/png",Dt=Ie.replace(/^data:image\/\w+;base64,/,""),ot=atob(Dt),vt=new Uint8Array(ot.length);for(let Et=0;Et<ot.length;Et++)vt[Et]=ot.charCodeAt(Et);const bt=new Blob([vt],{type:lt});Se.append("image_file",bt,`edited.${lt==="image/jpeg"?"jpg":"png"}`);const it=Fd(ye.state);it&&Se.append("editor_state",it),ye.metadata&&(Se.append("filters",JSON.stringify(ye.metadata.filters)),ye.metadata.cropRect&&Se.append("crop_data",JSON.stringify(ye.metadata.cropRect))),Se.append("save_as_new","true"),Be.asVariant&&Se.append("as_variant","true"),Be.name!==void 0&&Se.append("name",Be.name);const wt=await fe(`${ge}/editor/${de}/save`,{method:"POST",body:Se});if("media"in wt&&wt.media)return wt.media;if("status_url"in wt&&wt.status_url)return O(fe,wt.status_url,Be.pollTimeout??6e4);throw new Error("Unexpected response from editor save endpoint")}async function O(de,ye,Be){const fe=Date.now(),ge=2e3;for(;Date.now()-fe<Be;){await new Promise(Ie=>setTimeout(Ie,ge));const Se=await de(ye);if(Se.status==="completed"&&Se.media)return Se.media;if(Se.status==="failed")throw new Error(Se.error??"Image processing failed")}throw new Error("Image processing timed out")}function Z(de,ye,Be){l.value=Be!==void 0?{type:de,uuid:ye,collection:Be}:{type:de,uuid:ye},g.value[`${de}-${ye}`]={timestamp:Date.now()}}function G(){l.value={type:null,uuid:null},c.value=[],u.value=null}async function re(){if(!l.value.type||!l.value.uuid)return;const de=await z(l.value.type,l.value.uuid,l.value.collection||"images");c.value=de||[]}function be(){a.value.forEach(de=>m.value.add(de.uuid))}function Ee(){m.value.clear()}function ie(de){m.value.has(de)?m.value.delete(de):m.value.add(de)}function R(de){return m.value.has(de)}function M(){return Array.from(f.value.values()).some(de=>de.status==="uploading")}function H(de){return f.value.get(de)||p.value.get(de)}function ee(){return[...Array.from(f.value.values()),...Array.from(p.value.values())]}async function ae(){const de=Array.from(m.value);let ye=0;for(const Be of de)try{await E(Be),ye++}catch{}return Ee(),ye}function ue(de,ye){var Be;return ye&&((Be=de.conversion_urls)!=null&&Be[ye])?de.conversion_urls[ye]||"":de.original_url||de.url||""}return{items:a,collections:n,loading:t,error:o,currentPage:i,totalPages:r,itemsPerPage:s,isAdmin:D,modelContext:l,modelMedia:c,isLoadingModelMedia:d,modelMediaError:u,selectedItems:m,uploadProgress:f,uploadQueue:p,cachedResponses:g,fetchMedia:T,uploadFile:j,deleteMedia:E,updateMedia:A,clearCache:V,fetchCollections:N,fetchModelMedia:z,attachMedia:P,detachMedia:B,reorderMedia:L,saveEditedImage:w,setModelContext:Z,clearModelContext:G,refreshModelMedia:re,selectAllItems:be,clearSelection:Ee,toggleSelection:ie,isSelected:R,deleteSelectedItems:ae,getHttpClient:_,getApiUrl:v,hasActiveUploads:M,getUploadProgress:H,getAllUploadProgress:ee,getMediaUrl:ue}}),Ad=()=>((dn.apiScope!=="admin"||dn.isAdmin!==!0)&&no({...dn,apiScope:"admin",isAdmin:!0}),ln());class Ld{constructor(n,t){this.state=n,this.editor=t,this.element=null,this._tabs=new Map,this._unsubscribers=[],this._onSelect=null}render({onSelect:n}={}){return this._onSelect=n,this.element=pe.el("div",{className:"panel-tabs",role:"tablist","aria-label":"Filter categories","data-testid":"v2-category-tabs"}),pe.EDITOR_CATEGORIES.forEach(t=>{const o=pe.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=pe.el("span",{className:"panel-tab-icon","aria-hidden":"true"});i.innerHTML=t.icon,o.appendChild(i)}o.appendChild(pe.el("span",{className:"panel-tab-label"},t.name)),this._tabs.set(t.id,o),this.element.appendChild(o)}),this._unsubscribers.push(this.state.on("change:selectedCategory",()=>this._refreshActive())),this.element}_isSelected(n){const t=this.state.get("selectedCategory");return n==="crop"?this.state.get("mode")==="crop":t===n&&this.state.get("mode")!=="crop"}_selectCategory(n){var o;this.state.set("selectedCategory",n);const t=this.state.get("mode");n==="crop"?t!=="crop"&&this.editor.setMode("crop"):t!=="filters"&&this.editor.setMode("filters"),this._refreshActive(),(o=this._onSelect)==null||o.call(this,n)}_refreshActive(){this._tabs.forEach((n,t)=>{const o=this._isSelected(t);n.classList.toggle("active",o),n.setAttribute("aria-selected",o?"true":"false")})}destroy(){var n;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],this._tabs.clear(),(n=this.element)==null||n.remove(),this.element=null}}class Pd{constructor(n,t){this.state=n,this.filterManager=t,this.element=null,this._unsubscribers=[],this._onToggle=null,this._onSelect=null}render({onToggle:n,onSelect:t}={}){return this._onToggle=n,this._onSelect=t,this.element=pe.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 n=this.state.get("selectedCategory");if(!n||n==="crop")return;const t=this.filterManager.getFiltersByCategory(n),o=this.state.get("activeFilters"),i=this.state.get("selectedFilter");t.forEach(r=>{var c;const s=((c=o==null?void 0:o.has)==null?void 0:c.call(o,r.id))??!1,l=i===r.id;this.element.appendChild(this._renderRow(r,s,l))})}_renderRow(n,t,o){const i=pe.el("button",{type:"button",className:`filter-row ${o?"selected":""}`,role:"option","aria-selected":o?"true":"false","data-filter":n.id,"data-testid":`v2-filter-${n.id}`,onClick:()=>{var d;return(d=this._onSelect)==null?void 0:d.call(this,n.id)}}),r=pe.el("button",{type:"button",className:`filter-row-toggle ${t?"active":""}`,"aria-label":`${t?"Disable":"Enable"} ${n.name}`,"aria-pressed":t?"true":"false","data-testid":`v2-filter-toggle-${n.id}`,onClick:d=>{var f,p,m,h;d.stopPropagation();const u=!((p=(f=this.state.get("activeFilters"))==null?void 0:f.has)!=null&&p.call(f,n.id));(m=this._onToggle)==null||m.call(this,n.id,u),u&&((h=this._onSelect)==null||h.call(this,n.id))}});t&&(r.innerHTML=pe.checkmark),i.appendChild(r);const s=pe.el("div",{className:"filter-row-body"});s.appendChild(pe.el("span",{className:"filter-row-name"},n.name));const l=this._buildSummary(n,t);l&&s.appendChild(pe.el("span",{className:"filter-row-summary"},l)),i.appendChild(s);const c=pe.el("span",{className:"filter-row-chevron","aria-hidden":"true"});return c.innerHTML=pe.chevronRight,i.appendChild(c),i}_buildSummary(n,t){if(!t)return n.description||"";const o=this.state.getFilterValues(n.id);if(!o||Object.keys(o).length===0)return n.description||"Active";const i=[];for(const r of(n.controls||[]).slice(0,4)){const s=o[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(n,t){return n.type==="toggle"?n.label:typeof t=="number"?(n.max??1)<=1&&(n.min??0)>=0?`${n.label} ${Math.round(t*100)}%`:Number.isInteger(t)?`${n.label} ${t}`:`${n.label} ${t.toFixed(2)}`:typeof t=="string"?`${n.label}`:n.label}_refreshSummaries(){var i;const n=this.state.get("selectedCategory");if(!n||n==="crop")return;const t=this.filterManager.getFiltersByCategory(n),o=this.state.get("activeFilters");for(const r of t){const s=this.element.querySelector(`[data-filter="${r.id}"]`);if(!s)continue;const l=((i=o==null?void 0:o.has)==null?void 0:i.call(o,r.id))??!1,c=this._buildSummary(r,l),d=s.querySelector(".filter-row-summary");if(c&&d)d.textContent=c;else if(c&&!d){const u=s.querySelector(".filter-row-body");u==null||u.appendChild(pe.el("span",{className:"filter-row-summary"},c))}else!c&&d&&d.remove()}}destroy(){var n;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(n=this.element)==null||n.remove(),this.element=null}}class Od{constructor(n,t){this.state=n,this.filterManager=t,this.element=null,this._unsubscribers=[],this._onChange=null,this._onReset=null,this._onAction=null}render({onChange:n,onReset:t,onAction:o}={}){return this._onChange=n,this._onReset=t,this._onAction=o,this.element=pe.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 n=this.state.get("selectedFilter");if(!n){this.element.appendChild(pe.el("div",{className:"no-filter-selected"},"Select a filter to adjust"));return}const t=this.filterManager.getFilterDef(n);if(!t){this.element.appendChild(pe.el("div",{className:"no-filter-selected"},"Filter not found"));return}const o=pe.el("div",{className:"controls-header"});o.appendChild(pe.el("span",{className:"controls-title"},t.name)),o.appendChild(pe.createButton({label:"Reset",className:"btn-text",onClick:()=>this._handleReset(n)})),this.element.appendChild(o);const i=pe.el("div",{className:"controls-grid"}),r=this.state.getFilterValues(n);(t.controls||[]).forEach(l=>{if(l.hidden)return;const c=this._createControl(n,l,r[l.id]??l.default);c&&i.appendChild(c)});const s=this.filterManager.getInstance(n);if(s&&typeof s.getDynamicControls=="function"){let l=[];try{l=s.getDynamicControls()||[]}catch{}l.forEach(c=>{const d=c.property||c.id,u=r[d]??c.default,f=this._createControl(n,c,u);f&&i.appendChild(f)})}this.element.appendChild(i)}_createControl(n,t,o){if(t.hidden)return null;const i=t.label||t.id,r=this._normalizeControlType(t.type),s=t.property||t.id;switch(r){case"slider":return pe.createSlider({id:`v2-${n}-${t.id}`,label:i,min:t.min??0,max:t.max??1,step:t.step??.01,value:typeof o=="number"?o:t.default??0,onChange:l=>{var c;return(c=this._onChange)==null?void 0:c.call(this,n,s,l)}});case"toggle":return pe.createToggle({id:`v2-${n}-${t.id}`,label:i,checked:!!o,onChange:l=>{var c;return(c=this._onChange)==null?void 0:c.call(this,n,s,l)}});case"color":return pe.createColorPicker({id:`v2-${n}-${t.id}`,label:i,value:typeof o=="string"&&o.startsWith("#")?o:t.default||"#000000",onChange:l=>{var c;return(c=this._onChange)==null?void 0:c.call(this,n,s,l)}});case"select":{const l=(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 pe.createSelect({id:`v2-${n}-${t.id}`,label:i,options:l,value:o??t.default,onChange:c=>{var d;return(d=this._onChange)==null?void 0:d.call(this,n,s,c)}})}case"text":return pe.createTextInput({id:`v2-${n}-${t.id}`,label:i,value:typeof o=="string"?o:t.default??"",placeholder:t.placeholder||"",onCommit:l=>{var c;return(c=this._onChange)==null?void 0:c.call(this,n,s,l)}});case"button":{const l=pe.el("div",{className:"button-control"});return l.appendChild(pe.createButton({label:i,className:"btn-secondary",onClick:()=>{var c;(c=this._onAction)==null||c.call(this,n,t.action||t.id),this._renderControls()}})),l}default:return null}}_normalizeControlType(n){return{slider:"slider",range:"slider",toggle:"toggle",checkbox:"toggle",color:"color",select:"select",dropdown:"select",button:"button",text:"text"}[n]||n}_handleReset(n){var t;(t=this._onReset)==null||t.call(this,n),this._renderControls()}destroy(){var n;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(n=this.element)==null||n.remove(),this.element=null}}class ef{constructor(n,t){this.state=n,this.filterManager=t,this.element=null,this._unsubscribers=[],this._onRemove=null,this._onSelect=null,this._onClearAll=null}render({onRemove:n,onSelect:t,onClearAll:o}={}){return this._onRemove=n,this._onSelect=t,this._onClearAll=o,this.element=pe.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 n=this.state.get("activeFilters"),t=(n==null?void 0:n.size)??0,o=pe.el("div",{className:"panel-section-title"});if(o.appendChild(pe.el("span",{},`Active (${t})`)),t>0&&this._onClearAll&&o.appendChild(pe.el("button",{type:"button",className:"btn btn-text",style:{padding:"2px 8px",fontSize:"11px"},"data-testid":"v2-clear-all",onClick:()=>{var s;return(s=this._onClearAll)==null?void 0:s.call(this)}},"Clear all")),this.element.appendChild(o),t===0){this.element.appendChild(pe.el("div",{className:"active-empty"},"No filters applied"));return}const i=pe.el("div",{className:"active-stack"}),r=this.state.get("selectedFilter");for(const s of n){const l=this.filterManager.getFilterDef(s);l&&i.appendChild(this._renderChip(l,s===r))}this.element.appendChild(i)}_renderChip(n,t){const o=pe.el("div",{className:`active-chip ${t?"selected":""}`,"data-filter":n.id,"data-testid":`v2-active-${n.id}`});o.appendChild(pe.el("button",{type:"button",className:"active-chip-name","aria-label":`Select ${n.name}`,onClick:()=>{var r;return(r=this._onSelect)==null?void 0:r.call(this,n.id)}},n.name));const i=pe.el("button",{type:"button",className:"active-chip-remove","aria-label":`Remove ${n.name}`,"data-testid":`v2-active-remove-${n.id}`,onClick:()=>{var r;return(r=this._onRemove)==null?void 0:r.call(this,n.id)}});return i.innerHTML=pe.close,o.appendChild(i),o}_refreshSelection(){var o;const n=this.state.get("selectedFilter"),t=(o=this.element)==null?void 0:o.querySelectorAll(".active-chip");t&&t.forEach(i=>{const r=i.getAttribute("data-filter");i.classList.toggle("selected",r===n)})}destroy(){var n;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(n=this.element)==null||n.remove(),this.element=null}}const Ka=["collapsed","half","full"];class tf{constructor(n={}){this._onSnapChange=n.onSnapChange||null,this._ariaLabel=n.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:n,body:t}={}){this.element=pe.el("div",{className:"editor-v2-drawer",role:"dialog","aria-label":this._ariaLabel,"data-testid":"v2-bottom-drawer","data-snap":this._snap}),this._handle=pe.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 o=pe.el("span",{className:"drawer-handle-grip","aria-hidden":"true"});return this._handle.appendChild(o),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=pe.el("div",{className:"drawer-header"}),n&&this._headerSlot.appendChild(n),this.element.appendChild(this._headerSlot),this._body=pe.el("div",{className:"drawer-body"}),t&&this._body.appendChild(t),this.element.appendChild(this._body),this.element}updateContainerHeight(n){this._containerHeight=Math.max(0,Number(n)||0),this._applySnap(this._snap,{animate:!1})}snapTo(n,t={}){Ka.includes(n)&&this._applySnap(n,{animate:t.animate!==!1})}get snap(){return this._snap}setBodyContent(n){this._body&&(this._body.innerHTML="",n&&this._body.appendChild(n))}setHeaderContent(n){this._headerSlot&&(this._headerSlot.innerHTML="",n&&this._headerSlot.appendChild(n))}_onPointerDown(n){var t,o,i;if(!(n.button!==void 0&&n.button!==0)){this._dragging=!0,this._wasDragging=!1,this._dragPointerId=n.pointerId,this._dragStartY=n.clientY,this._dragStartHeight=((t=this.element)==null?void 0:t.offsetHeight)||0;try{(i=(o=this._handle)==null?void 0:o.setPointerCapture)==null||i.call(o,n.pointerId)}catch{}this.element&&(this.element.style.transition="none")}}_onPointerMove(n){if(!this._dragging||n.pointerId!==this._dragPointerId)return;const t=n.clientY-this._dragStartY,o=this._dragStartHeight-t;this._containerHeight||window.innerHeight;const i=this._heightForSnap("collapsed"),r=this._heightForSnap("full"),s=Math.max(i,Math.min(r,o));this.element&&(this.element.style.height=`${s}px`),Math.abs(t)>4&&(this._wasDragging=!0),n.preventDefault()}_onPointerEnd(n){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,n.pointerId)}catch{}this._dragPointerId=null;const t=((s=this.element)==null?void 0:s.offsetHeight)||0,o=this._nearestSnap(t);this._applySnap(o,{animate:!0})}_cycleSnap(){const n=Ka.indexOf(this._snap),t=Ka[(n+1)%Ka.length];this._applySnap(t,{animate:!0})}_heightForSnap(n){const t=this._containerHeight||window.innerHeight||600;switch(n){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(n){let t=Ka[0],o=1/0;for(const i of Ka){const r=this._heightForSnap(i),s=Math.abs(r-n);s<o&&(o=s,t=i)}return t}_applySnap(n,{animate:t}){var r,s;if(!this.element)return;const o=this._snap;this._snap=n;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(n)}px`,this.element.dataset.snap=n,this._handle&&this._handle.setAttribute("aria-expanded",n==="full"?"true":"false"),n!==o&&((s=this._onSnapChange)==null||s.call(this,n,o))}destroy(){var n;(n=this.element)==null||n.remove(),this.element=null,this._handle=null,this._body=null,this._headerSlot=null}}class nf{constructor(n,t,o){this.state=n,this.filterManager=t,this.editor=o,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}build(n){return this._callbacks=n,this._onNavigate=n.onViewChange||null,this.element=pe.el("div",{className:"drawer-nav","data-testid":"v2-mobile-nav"}),this._headerEl=pe.el("div",{className:"drawer-nav-header"}),this.element.appendChild(this._headerEl),this._bodyEl=pe.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 Ld(this.state,this.editor),this._categoryTabsEl=this._categoryTabs.render({onSelect:()=>this.navigateTo("filters")}),this._filterListView=new Pd(this.state,this.filterManager),this._filterListEl=this._filterListView.render({onToggle:(n,t)=>this._callbacks.onFilterToggle(n,t),onSelect:n=>{this._callbacks.onFilterSelect(n),this.navigateTo("controls")}}),this._filterControlsView=new Od(this.state,this.filterManager),this._filterControlsEl=this._filterControlsView.render({onChange:(n,t,o)=>this._callbacks.onFilterChange(n,t,o),onReset:n=>this._callbacks.onFilterReset(n),onAction:(n,t)=>this._callbacks.onFilterAction(n,t)})}navigateTo(n){var o;if(!this.element)return;this._view=n,this._renderHeader(),this._bodyEl.innerHTML="";let t=null;switch(n){case"categories":t=this._categoryTabsEl;break;case"filters":t=this._filterListEl;break;case"controls":t=this._filterControlsEl;break;default:t=this._categoryTabsEl}t&&this._bodyEl.appendChild(t),(o=this._onNavigate)==null||o.call(this,n)}_renderHeader(){if(!this._headerEl)return;if(this._headerEl.innerHTML="",this._view!=="categories"){const o=pe.el("button",{type:"button",className:"drawer-back-btn","aria-label":"Go back","data-testid":"v2-drawer-back",onClick:()=>this._goBack()});o.innerHTML=pe.chevronLeft,this._headerEl.appendChild(o)}const t=this._titleForView(this._view);if(this._headerEl.appendChild(pe.el("h2",{className:"drawer-nav-title"},t)),this._view==="controls"){const o=this.state.get("selectedFilter");o&&this._headerEl.appendChild(pe.createButton({label:"Reset",className:"btn-text",onClick:()=>this._callbacks.onFilterReset(o)}))}}_titleForView(n){switch(n){case"categories":return"Filters";case"filters":{const t=this.state.get("selectedCategory");return this._categoryLabel(t)||"Filters"}case"controls":{const t=this.state.get("selectedFilter"),o=t?this.filterManager.getFilterDef(t):null;return(o==null?void 0:o.name)||"Filter"}default:return""}}_categoryLabel(n){var t;return n&&((t=pe.EDITOR_CATEGORIES.find(o=>o.id===n))==null?void 0:t.name)||null}_goBack(){this._view==="controls"?(this.state.set("selectedFilter",null),this.navigateTo("filters")):this._view==="filters"&&this.navigateTo("categories")}get currentView(){return this._view}destroy(){var n,t,o,i;this._unsubscribers.forEach(r=>r()),this._unsubscribers=[],(n=this._categoryTabs)==null||n.destroy(),(t=this._filterListView)==null||t.destroy(),(o=this._filterControlsView)==null||o.destroy(),(i=this.element)==null||i.remove(),this.element=null}}class af{constructor(n,t){this.state=n,this.filterManager=t,this.element=null,this._onSelect=null,this._onRemove=null,this._unsubscribers=[]}render({onSelect:n,onRemove:t}={}){return this._onSelect=n,this._onRemove=t,this.element=pe.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 n=this.state.get("activeFilters");if(((n==null?void 0:n.size)??0)===0){this.element.style.display="none";return}this.element.style.display="";const o=pe.el("div",{className:"mobile-active-track"}),i=this.state.get("selectedFilter");for(const r of n){const s=this.filterManager.getFilterDef(r);s&&o.appendChild(this._renderChip(s,r===i))}this.element.appendChild(o)}_renderChip(n,t){const o=pe.el("div",{className:`mobile-active-chip ${t?"selected":""}`,"data-filter":n.id,"data-testid":`v2-mobile-chip-${n.id}`});o.appendChild(pe.el("button",{type:"button",className:"mobile-active-chip-name","aria-label":`Edit ${n.name}`,onClick:()=>{var r;return(r=this._onSelect)==null?void 0:r.call(this,n.id)}},n.name));const i=pe.el("button",{type:"button",className:"mobile-active-chip-remove","aria-label":`Remove ${n.name}`,"data-testid":`v2-mobile-chip-remove-${n.id}`,onClick:r=>{var s;r.stopPropagation(),(s=this._onRemove)==null||s.call(this,n.id)}});return i.innerHTML=pe.close,o.appendChild(i),o}_refreshSelection(){var o;const n=this.state.get("selectedFilter"),t=(o=this.element)==null?void 0:o.querySelectorAll(".mobile-active-chip");t==null||t.forEach(i=>{const r=i.getAttribute("data-filter");i.classList.toggle("selected",r===n)})}destroy(){var n;this._unsubscribers.forEach(t=>t()),this._unsubscribers=[],(n=this.element)==null||n.remove(),this.element=null}}const lc="(max-width: 900px)";let of=class{constructor(n,t,o){this.state=n,this.filterManager=t,this.editor=o,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._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(n){var t;return this._callbacks=n,this.root=pe.el("div",{className:"editor-v2-body"}),this.canvasSection=pe.el("div",{className:"editor-v2-canvas"}),this.canvasContainer=pe.el("div",{className:"canvas-container"}),this.cropOverlay=pe.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,lc).matches)===!0,this._isMobile?this._buildMobileShell():this._buildDesktopShell(),typeof window<"u"&&window.matchMedia&&(this._mql=window.matchMedia(lc),this._mqlHandler=o=>this._handleBreakpointChange(o.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:o})=>this._applyMode(o))),{root:this.root,canvasContainer:this.canvasContainer,cropOverlay:this.cropOverlay}}mountCropControls(n){this._cropControlsEl=n,this._mountCropControlsInActiveShell()}_buildDesktopShell(){this._panel=pe.el("div",{className:"editor-v2-panel","data-testid":"v2-inspector-panel"}),this._categoryTabs=new Ld(this.state,this.editor),this._panel.appendChild(this._categoryTabs.render({onSelect:()=>this._handleDesktopCategoryChange()}));const n=pe.el("div",{className:"panel-body"});this._desktopFilterListSection=pe.el("div",{className:"panel-section"}),this._desktopFilterListSection.appendChild(pe.el("div",{className:"panel-section-title"},pe.el("span",{},"Filters"))),this._filterListView=new Pd(this.state,this.filterManager),this._desktopFilterListSection.appendChild(this._filterListView.render({onToggle:(t,o)=>this._callbacks.onFilterToggle(t,o),onSelect:t=>this._callbacks.onFilterSelect(t)})),n.appendChild(this._desktopFilterListSection),this._filterControlsView=new Od(this.state,this.filterManager),n.appendChild(this._filterControlsView.render({onChange:(t,o,i)=>this._callbacks.onFilterChange(t,o,i),onReset:t=>this._callbacks.onFilterReset(t),onAction:(t,o)=>this._callbacks.onFilterAction(t,o)})),this._desktopCropWrapper=pe.el("div",{className:"crop-controls-wrapper",style:{display:"none"}}),n.appendChild(this._desktopCropWrapper),this._activeStack=new ef(this.state,this.filterManager),n.appendChild(this._activeStack.render({onRemove:t=>this._callbacks.onFilterToggle(t,!1),onSelect:t=>this._callbacks.onFilterSelect(t),onClearAll:()=>{var t,o;return(o=(t=this._callbacks).onClearAll)==null?void 0:o.call(t)}})),this._panel.appendChild(n),this.root.appendChild(this._panel),this._mountCropControlsInActiveShell(),this._applyMode(this.state.get("mode"))}_buildMobileShell(){this._mobileChips=new af(this.state,this.filterManager);const n=this._mobileChips.render({onSelect:r=>{var s,l;this._callbacks.onFilterSelect(r),(s=this._mobileDrawer)==null||s.snapTo("full"),(l=this._mobileNav)==null||l.navigateTo("controls")},onRemove:r=>this._callbacks.onFilterToggle(r,!1)});this.root.appendChild(n),this._mobileDrawer=new tf({onSnapChange:r=>{this.canvasContainer&&window.dispatchEvent(new Event("resize"))}}),this._mobileNav=new nf(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=pe.el("div",{className:"crop-controls-wrapper",style:{display:"none"}});const o=pe.el("div",{className:"drawer-content"});o.appendChild(t),o.appendChild(this._mobileCropWrapper);const i=this._mobileDrawer.build({body:o});this.root.appendChild(i),this._wireDrawerSizing(),this._mountCropControlsInActiveShell(),this._applyMode(this.state.get("mode"))}_wireDrawerSizing(){if(!this.root||!this._mobileDrawer)return;const n=()=>{const t=this.root.getBoundingClientRect().height;this._mobileDrawer.updateContainerHeight(t)};n(),this._resizeObserver=new ResizeObserver(()=>n()),this._resizeObserver.observe(this.root)}_destroyDesktopShell(){var n,t,o,i,r,s,l;(n=this._categoryTabs)==null||n.destroy(),this._categoryTabs=null,(t=this._filterListView)==null||t.destroy(),this._filterListView=null,(o=this._filterControlsView)==null||o.destroy(),this._filterControlsView=null,(i=this._activeStack)==null||i.destroy(),this._activeStack=null,this._desktopFilterListSection=null,(r=this._desktopCropWrapper)!=null&&r.parentElement&&((s=this._cropControlsEl)==null?void 0:s.parentElement)===this._desktopCropWrapper&&this._desktopCropWrapper.removeChild(this._cropControlsEl),this._desktopCropWrapper=null,(l=this._panel)==null||l.remove(),this._panel=null}_destroyMobileShell(){var n,t,o,i,r;(n=this._resizeObserver)==null||n.disconnect(),this._resizeObserver=null,(t=this._mobileNav)==null||t.destroy(),this._mobileNav=null,(o=this._mobileChips)==null||o.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(n){n!==this._isMobile&&(this._isMobile=n,n?(this._destroyDesktopShell(),this._buildMobileShell()):(this._destroyMobileShell(),this._buildDesktopShell()))}_mountCropControlsInActiveShell(){if(!this._cropControlsEl)return;this._cropControlsEl.remove();const n=this._isMobile?this._mobileCropWrapper:this._desktopCropWrapper;n==null||n.appendChild(this._cropControlsEl)}_handleDesktopCategoryChange(){if(this.state.get("mode")==="crop")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(n){var o,i,r;const t=n==="crop";this._desktopFilterListSection&&(this._desktopFilterListSection.style.display=t?"none":""),(o=this._filterControlsView)!=null&&o.element&&(this._filterControlsView.element.style.display=t?"none":""),(i=this._activeStack)!=null&&i.element&&(this._activeStack.element.style.display=t?"none":""),this._desktopCropWrapper&&(this._desktopCropWrapper.style.display=t?"":"none"),(r=this._mobileNav)!=null&&r.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 n;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(),(n=this.root)==null||n.remove(),this.root=null,this.canvasSection=null,this.canvasContainer=null,this.cropOverlay=null}};class rf extends pe.EventEmitter{constructor(n,t={}){var r,s,l;if(super(),!n)throw new Error("VanillaImageEditorV2: container element is required");this._container=n,this._destroyed=!1,this._loadVersion=0,this._objectUrls=new Set;const o=t.preset?pe.getPreset(t.preset):null,i=o?{initialMode:o.initialMode==="crop"?"crop":"adjust",cropShape:o.cropShape,initialAspectRatio:o.aspectRatio}:{};this._options={theme:"auto",initialImage:null,initialMode:"adjust",cropShape:"free",initialAspectRatio:"free",layout:"split-panel",backgroundRemoval:{enabled:!0,endpoint:"/api/v1/media/remove-bg",fallbackEndpoint:null},...i,...t},this._preset=o,this._state=pe.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 pe.PixiRenderer,this._filterManager=new pe.FilterManager(this._state,this._renderer),this._cropManager=new pe.CropManager(this._state,this._renderer),this._removeBgManager=null,((r=this._options.backgroundRemoval)==null?void 0:r.enabled)!==!1&&(this._removeBgManager=new pe.RemoveBgManager({endpoint:(s=this._options.backgroundRemoval)==null?void 0:s.endpoint,fallbackEndpoint:(l=this._options.backgroundRemoval)==null?void 0:l.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._init()}async _init(){this._state.detectTheme(),this._buildDOM(),await this._renderer.mount(this._canvasContainer,0,{backgroundAlpha:0}),this._cropManager.setOverlayCanvas(this._cropOverlay),this._initUI(),this._setupResizeObserver(),this._setupWindowResize(),this._subscribeToState(),this._options.initialImage&&await this.loadImage(this._options.initialImage),this.emit("ready")}_buildDOM(){this._container.innerHTML="",this._editorEl=pe.el("div",{className:`vanilla-image-editor-v2 ${this._state.get("isDarkMode")?"dark":"light"}`}),this._toolbarContainer=pe.el("div",{className:"editor-v2-toolbar"}),this._editorEl.appendChild(this._toolbarContainer),this._layout=new of(this._state,this._filterManager,this);const{root:n,canvasContainer:t,cropOverlay:o}=this._layout.build({onFilterToggle:(i,r)=>this._handleFilterToggle(i,r),onFilterSelect:i=>this._handleFilterSelect(i),onFilterChange:(i,r,s)=>this._handleFilterChange(i,r,s),onFilterReset:i=>this._handleFilterReset(i),onFilterAction:(i,r)=>this._handleFilterAction(i,r),onClearAll:()=>this.resetAll()});this._canvasContainer=t,this._cropOverlay=o,this._editorEl.appendChild(n),this._fileInput=pe.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 pe.Toolbar(this._state,this),this._toolbarContainer.appendChild(this._toolbar.render()),this._cropControls=new pe.CropControls(this._state,this._cropManager);const n=this._cropControls.render();this._layout.mountCropControls(n)}_setupResizeObserver(){if(!this._canvasContainer)return;let n=null;this._resizeObserver=new ResizeObserver(()=>{clearTimeout(n),n=setTimeout(()=>{var t,o;this._destroyed||!this._canvasContainer||(this._renderer.resizeTo(this._canvasContainer),this._state.get("mode")==="crop"&&((o=(t=this._cropManager).drawOverlay)==null||o.call(t)))},50)}),this._resizeObserver.observe(this._canvasContainer)}_setupWindowResize(){this._handleWindowResize=()=>{},window.addEventListener("resize",this._handleWindowResize)}_subscribeToState(){this._state.on("change:isDarkMode",({value:n})=>{var t,o;(t=this._editorEl)==null||t.classList.toggle("dark",n),(o=this._editorEl)==null||o.classList.toggle("light",!n)})}async _handleFileSelect(n){var o;const t=(o=n.target.files)==null?void 0:o[0];t&&await this.loadImage(t),this._fileInput.value=""}_handleFilterToggle(n,t){this._filterManager.toggle(n,t),t?this._state.set("selectedFilter",n):this._state.get("selectedFilter")===n&&this._state.set("selectedFilter",null)}_handleFilterSelect(n){var i;const t=this._state.get("activeFilters");(i=t==null?void 0:t.has)!=null&&i.call(t,n)||this._filterManager.toggle(n,!0),this._state.set("selectedFilter",n);const o=this._filterManager.getFilterDef(n);if(typeof(o==null?void 0:o.category)=="string"){const r=pe.REGISTRY_TO_UI[o.category]||o.category;this._state.get("selectedCategory")!==r&&this._state.set("selectedCategory",r)}}_handleFilterChange(n,t,o){this._filterManager.updateValue(n,t,o)||this._filterManager.applyFilters(),this._renderer.render()}_handleFilterReset(n){this._filterManager.resetValues(n),this._filterManager.applyFilters()}_handleFilterAction(n,t){this._filterManager.performFilterAction(n,t)}setFilterRegistry(n){this._filterManager.setRegistry(n)}async loadImage(n,t={}){if(this._destroyed)return;const o=++this._loadVersion;let i=n;this._resetEditorState(),n instanceof Blob&&(i=URL.createObjectURL(n),this._objectUrls.add(i));const r=await this._renderer.loadTexture(i);if(!(this._destroyed||this._loadVersion!==o)){if(!r){this.emit("error",new Error("Failed to load image"));return}this._state.set("hasImage",!0),this._state.set("imageUrl",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.shape",this._options.cropShape||"free"),this._state.set("crop.aspect",this._options.initialAspectRatio||"free"),this._state.get("mode")==="crop"&&(this._cropManager.disable(),this._state.set("mode","filters"))}_hydrateState(n){if(!(!n||n.version!==1)){if(n.crop){const t=n.crop.shape||"free",o=n.crop.aspectRatio||"free";n.crop.rect&&(this._cropManager.applyFromPixelRect(n.crop.rect,t),this._state.set("crop.appliedRect",{...n.crop.rect}),this._state.set("crop.appliedShape",t),this._state.set("crop.appliedAspect",o)),this._state.set("crop.shape",t),this._state.set("crop.aspect",o)}if(Array.isArray(n.filters)){let t=null;for(const o of n.filters)if(o.enabled&&(t===null&&(t=o.id),this._state.toggleFilter(o.id,!0),this._filterManager.initializeValues(o.id),o.values))for(const[i,r]of Object.entries(o.values))this._state.setFilterValue(o.id,i,r);if(t!==null){this._state.set("selectedFilter",t);const o=this._filterManager.getFilterDef(t);if(typeof(o==null?void 0:o.category)=="string"){const i=pe.REGISTRY_TO_UI[o.category]??o.category;this._state.set("selectedCategory",i)}}this._filterManager.applyFilters()}}}openFilePicker(){var n;(n=this._fileInput)==null||n.click()}exportImage(n="png",t=.92,o={}){return this._state.get("crop.rect")&&!this._cropManager.apply()?null:this._renderer.exportImage(n,t,o.maxEdge??0,o.dontUpscale!==!1,o.maxPixels??0)}save(){if(this._state.get("hasImage")){this._state.set("isSaving",!0);try{const n=this.exportImage("png",.92);if(!n)throw new Error("Failed to export image");const t=this._renderer.originalTexture,o={width:Math.round((t==null?void 0:t.width)||0),height:Math.round((t==null?void 0:t.height)||0)},i=document.createElement("a");i.href=n,i.download=`edited-image-${Date.now()}.png`,document.body.appendChild(i),i.click(),document.body.removeChild(i),this.emit("save",{imageData:n,dimensions:o,state:this.getSerializableState()})}catch(n){this.emit("error",{error:n})}finally{this._state.set("isSaving",!1)}}}getSerializableState(){const n=this._state.get("activeFilters"),t=[];if(n)for(const s of n){const l=this._state.getFilterValues(s);t.push({id:s,enabled:!0,values:{...l}})}const o=this._state.get("crop.appliedRect"),i=this._state.get("crop.rect"),r=o||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"},filters:t}}close(){this.emit("cancel")}setZoom(n){this._renderer.setZoom(n)}fitToScreen(){this._renderer.fitToScreen()}resetAll(){this._filterManager.resetAll()}toggleTheme(){const n=this._state.get("isDarkMode");this._state.set("isDarkMode",!n)}setTheme(n){this._state.set("theme",n),this._state.detectTheme()}setMode(n){n==="crop"?this._cropManager.enable():this._cropManager.disable(),this._state.set("mode",n)}getState(){return this._state.getAll()}async removeBackground(n={}){if(!this._removeBgManager)throw new Error("Background removal is not enabled");if(!this._state.get("hasImage"))throw new Error("No image loaded");this._state.set("isProcessing",!0),this._showLoadingOverlay("Removing background...");try{const t=this.exportImage("png");if(!t)throw new Error("Failed to export image for background removal");const o=await this._removeBgManager.removeBackground(t,n);return await this.loadImage(o.dataUrl),this.emit("background-removed",{model:o.model,processMs:o.processMs}),{model:o.model,processMs:o.processMs}}catch(t){throw this.emit("error",{error:t,context:"background-removal"}),t}finally{this._state.set("isProcessing",!1),this._hideLoadingOverlay()}}async isBackgroundRemovalAvailable(){return this._removeBgManager?this._removeBgManager.isAvailable():!1}_showLoadingOverlay(n){var o;if(!this._loadingOverlay)this._loadingOverlay=pe.el("div",{className:"editor-loading-overlay"},pe.el("div",{className:"editor-loading-spinner"}),pe.el("div",{className:"editor-loading-text"},n));else{const i=this._loadingOverlay.querySelector(".editor-loading-text");i&&(i.textContent=n)}const t=(o=this._canvasContainer)==null?void 0:o.parentElement;t&&!this._loadingOverlay.parentElement&&t.appendChild(this._loadingOverlay)}_hideLoadingOverlay(){var n;(n=this._loadingOverlay)==null||n.remove()}destroy(){var n,t,o,i,r;this._destroyed=!0;for(const s of this._objectUrls)try{URL.revokeObjectURL(s)}catch{}this._objectUrls.clear(),(n=this._resizeObserver)==null||n.disconnect(),this._renderer.destroy(),this._cropManager.disable(),this._handleWindowResize&&window.removeEventListener("resize",this._handleWindowResize),(t=this._toolbar)==null||t.destroy(),(o=this._cropControls)==null||o.destroy(),(i=this._layout)==null||i.destroy(),(r=this._editorEl)==null||r.remove(),this._container=null,this._state=null,this.emit("destroyed"),this.removeAllListeners()}}function sf(a,n){try{let t=pe.getFilter(a);if(t||(pe.registerCorePixiFilters(),t=pe.getFilter(a)),!t){try{const r=pe.getAllFilters()}catch{}return null}const o={...t.defaultParams,...n};return t.createFilter(o)}catch{return null}}const ns=78e5,lf=e.defineComponent({__name:"ImageEditor",props:{initialImage:{},initialState:{default:null},sessionKey:{default:0},theme:{default:"auto"},cropShape:{default:"square"},preset:{},editorVersion:{default:"v2"},primaryColor:{default:"#3880ff"},secondaryColor:{default:"#5260ff"},saveButtonColor:{default:"#3880ff"},downloadButtonColor:{default:"#2dd36f"}},emits:["save","cancel","error"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(null);let r=null,s=null;function l(){var _;if(!r){o("error",new Error("Editor not initialized"));return}const f=r.exportImage("png",.92,{maxPixels:ns});if(!f){o("error",new Error("Failed to export image — the image could not be processed"));return}const p=r.getSerializableState(),m=r._renderer,h=((_=m==null?void 0:m.getExportDimensions)==null?void 0:_.call(m))??{width:0,height:0},g=h.width*h.height,k=g>ns?Math.sqrt(ns/Math.max(1,g)):1,$={width:Math.max(1,Math.floor(h.width*k)),height:Math.max(1,Math.floor(h.height*k))};o("save",{imageData:f,dimensions:$,state:p})}function c(){o("cancel")}function d(){if(!i.value||r)return;window.PIXI=Vt,pe.initializeFilterRegistry();const f={theme:t.theme};t.preset&&(f.preset=t.preset),t.preset?t.cropShape==="circle"&&(f.cropShape="circle",f.initialAspectRatio="1:1",f.initialMode="crop"):(f.cropShape=t.cropShape==="circle"?"circle":"free",f.initialAspectRatio=t.cropShape==="circle"?"1:1":"free",f.initialMode=t.cropShape==="circle"?"crop":"adjust");const p=t.editorVersion==="v2"?rf:pe.VanillaImageEditor;r=new p(i.value,f),r.setFilterRegistry({getAllFilters:pe.getAllFilters,getFilter:pe.getFilter,getFiltersByCategory:pe.getFiltersByCategory}),r.save=function(){l()},r.on("cancel",c),t.initialImage&&r.loadImage(t.initialImage,{state:t.initialState??null,sessionKey:t.sessionKey})}e.onMounted(()=>{i.value&&(i.value.clientWidth>0?d():(s=new ResizeObserver(f=>{const p=f[0];p&&p.contentRect.width>0&&!r&&(d(),s==null||s.disconnect(),s=null)}),s.observe(i.value)))});const u=()=>{!r||!t.initialImage||r.loadImage(t.initialImage,{state:t.initialState??null,sessionKey:t.sessionKey})};return e.watch(()=>t.initialImage,(f,p)=>{!r||!f||f===p||u()}),e.watch(()=>t.sessionKey,(f,p)=>{f!==p&&u()}),e.watch(()=>t.initialState,(f,p)=>{f!==p&&u()}),e.onUnmounted(()=>{s==null||s.disconnect(),s=null,r&&(r.destroy(),r=null)}),(f,p)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:i,class:"vanilla-editor-wrapper","data-testid":"vanilla-image-editor"},null,512))}}),Me=(a,n)=>{const t=a.__vccOpts||a;for(const[o,i]of n)t[o]=i;return t},Ud=Me(lf,[["__scopeId","data-v-24c46711"]]),cf={class:"editor-modal-panel"},df={class:"editor-fill"},uf=e.defineComponent({__name:"ImageEditorModal",props:{modelValue:{type:Boolean,default:!1},initialImage:{},initialState:{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"},primaryColor:{default:"#3880ff"},secondaryColor:{default:"#5260ff"},saveButtonColor:{default:"#3880ff"},downloadButtonColor:{default:"#2dd36f"}},emits:["update:modelValue","save","cancel","error"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(null),r=e.ref(t.modelValue),s=e.ref(!1),l=e.ref(null),c=g=>{o("error",g)},d=()=>{e.nextTick(()=>{if(i.value){const g=i.value.querySelector("button:not([disabled]), [href], input:not([disabled])");g&&g.focus()}})};e.watch(()=>t.modelValue,g=>{r.value=g,g&&(l.value=document.activeElement,d())},{immediate:!0});const u=g=>{try{s.value=!0,o("save",g)}catch(k){c(k)}finally{s.value=!1}},f=()=>{o("cancel"),m()},p=()=>{s.value||m()},m=()=>{r.value=!1,o("update:modelValue",!1),l.value&&l.value instanceof HTMLElement&&(l.value.focus(),l.value=null)},h=g=>{if(g.key==="Escape"&&r.value&&!s.value){m();return}if(g.key==="Tab"&&r.value&&i.value){const k=i.value.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(k.length===0)return;const $=k[0],D=k[k.length-1];g.shiftKey&&document.activeElement===$?(g.preventDefault(),D.focus()):!g.shiftKey&&document.activeElement===D&&(g.preventDefault(),$.focus())}};return e.onMounted(()=>{document.addEventListener("keydown",h)}),e.onBeforeUnmount(()=>{document.removeEventListener("keydown",h)}),(g,k)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[r.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"overlayRef",ref:i,role:"dialog","aria-modal":"true","aria-label":"Image editor",class:"editor-modal-overlay","data-testid":"image-editor-modal",onKeydown:e.withKeys(p,["escape"])},[e.createElementVNode("div",{class:"editor-modal-backdrop",onClick:p}),e.createElementVNode("div",cf,[e.createElementVNode("div",df,[e.createVNode(Ud,{"initial-image":g.initialImage,"initial-state":g.initialState,"session-key":g.sessionKey,theme:g.theme,"crop-shape":g.cropShape,preset:g.preset,"editor-version":g.editorVersion,"primary-color":g.primaryColor,"secondary-color":g.secondaryColor,"save-button-color":g.saveButtonColor,"download-button-color":g.downloadButtonColor,onSave:u,onCancel:f,onError:c},null,8,["initial-image","initial-state","session-key","theme","crop-shape","preset","editor-version","primary-color","secondary-color","save-button-color","download-button-color"])])])],544)):e.createCommentVNode("",!0)]))}}),zd=Me(uf,[["__scopeId","data-v-adf95668"]]),mf={class:"media-workspace"},pf={class:"media-workspace-toolbar"},ff={class:"media-workspace-label"},hf=["value"],vf={class:"media-workspace-grid"},gf=["onClick"],yf=e.defineComponent({__name:"MediaWorkspace",props:{apiScope:{},subScopes:{},initialScopeId:{}},emits:["scope-change","update:media","upload","preview"],setup(a,{emit:n}){var f;const t=a,o=n,i=ln(),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(p=>p.id===r.value));let c=null;function d(){c&&(c(),c=null),t.apiScope&&(c=Rd({apiScope:t.apiScope,isAdmin:t.apiScope==="admin"}))}async function u(){var m;const p={};(m=l.value)!=null&&m.collection&&(p.collection=l.value.collection),await i.fetchMedia(1,p),o("update:media",[...i.items])}return e.watch(()=>t.initialScopeId,p=>{p&&p!==r.value&&(r.value=p)}),e.watch(()=>t.subScopes,p=>{if(p.length===0){r.value="";return}p.some(m=>m.id===r.value)||(r.value=p[0].id)},{deep:!0}),e.watch(()=>t.apiScope,()=>{d(),u()}),e.watch(r,p=>{p&&(o("scope-change",p),u())}),e.onMounted(()=>{d(),u()}),e.onUnmounted(()=>{c&&(c(),c=null)}),(p,m)=>(e.openBlock(),e.createElementBlock("div",mf,[e.createElementVNode("div",pf,[e.createElementVNode("label",ff,[m[2]||(m[2]=e.createElementVNode("span",{class:"media-workspace-label-text"},"Scope",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":m[0]||(m[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,hf))),128))],512),[[e.vModelSelect,r.value]])]),e.createElementVNode("button",{type:"button",class:"media-workspace-upload","data-testid":"upload-button",onClick:m[1]||(m[1]=h=>o("upload"))}," Upload ")]),e.createElementVNode("div",vf,[(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:g=>o("preview",h)},e.toDisplayString(h.file_name),9,gf))),128))])]))}}),bf=Me(yf,[["__scopeId","data-v-895f26fe"]]),wf={class:"managed-media-gallery"},kf={class:"gallery-grid"},_f=e.defineComponent({__name:"ManagedMediaGallery",props:{media:{},selectable:{type:Boolean},multiple:{type:Boolean}},emits:["select","remove"],setup(a){return(n,t)=>(e.openBlock(),e.createElementBlock("div",wf,[e.createElementVNode("div",kf,[e.renderSlot(n.$slots,"default",{},void 0,!0)])]))}}),Ef=Me(_f,[["__scopeId","data-v-10a9b8c5"]]),Li="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>",dl="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>",xf="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>",ul="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>",Sf="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>",Cf="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>",cc="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>",dc="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>",Bo="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>",Vf="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>",jd="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>",Wd="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>",uc="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>",Nf="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>",Tf="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>",mc="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>",Na="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>",pc="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>",Mf="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>",oa="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>",Bf="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>",So="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>",xs="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>",If="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>",fc="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>",Yi="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>",ao="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>",Ff="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>",$f="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>",Df="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>",Rf="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>",Io="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>",hc="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>",Af="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>",Lf="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>",os="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>",Pf="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>",Of="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>",Uf="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>",zf="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>",Zd="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>",ml="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>",jf="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>",Wf="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>",Zf="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>",Hf="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>",Hd="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>",Xf="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>",Gf="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>",pl="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>",Jf="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>",Kf="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>",Fa="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>",Yf="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>",qf="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>",vc="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>",pr="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>",Qf="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>",is="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>",aa="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>",Co="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>",gc="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>",eh="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>",Xd="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>",qi="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>",Gd="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>",th="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>",nh="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>",ah="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>",oh="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>",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-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>",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-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>",sh="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>",Ei="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 yc=()=>{};function lh(a,n){function t(...o){return new Promise((i,r)=>{Promise.resolve(a(()=>n.apply(this,o),{fn:n,thisArg:this,args:o})).then(i).catch(r)})}return t}function ch(a,n={}){let t,o,i=yc;const r=c=>{clearTimeout(c),i(),i=yc};let s;return c=>{const d=e.toValue(a),u=e.toValue(n.maxWait);return t&&r(t),d<=0||u!==void 0&&u<=0?(o&&(r(o),o=null),Promise.resolve(c())):new Promise((f,p)=>{i=n.rejectOnCancel?p:f,s=c,u&&!o&&(o=setTimeout(()=>{t&&r(t),o=null,f(s())},u)),t=setTimeout(()=>{o&&r(o),o=null,f(c())},d)})}}function dh(a,n=200,t={}){return lh(ch(n,t),a)}const Vo=new Map;function uh(a){const n=e.getCurrentScope();function t(l){var c;const d=Vo.get(a)||new Set;d.add(l),Vo.set(a,d);const u=()=>i(l);return(c=n==null?void 0:n.cleanups)==null||c.push(u),u}function o(l){function c(...d){i(c),l(...d)}return t(c)}function i(l){const c=Vo.get(a);c&&(c.delete(l),c.size||r())}function r(){Vo.delete(a)}function s(l,c){var d;(d=Vo.get(a))==null||d.forEach(u=>u(l,c))}return{on:t,once:o,off:i,emit:s,reset:r}}function Jd(){var r,s;const a=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,c;if(a)try{const d=(c=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:c.Haptics;d&&d.impact({style:"LIGHT"})}catch{}else"vibrate"in navigator&&navigator.vibrate(10)},success:()=>{var l,c;if(a)try{const d=(c=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:c.Haptics;d&&d.impact({style:"MEDIUM"})}catch{}else"vibrate"in navigator&&navigator.vibrate(30)},error:()=>{var l,c;if(a)try{const d=(c=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:c.Haptics;d&&d.impact({style:"HEAVY"})}catch{}else"vibrate"in navigator&&navigator.vibrate([50,50,50])},notification:()=>{var l,c;if(a)try{const d=(c=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:c.Haptics;d&&d.notification({type:"SUCCESS"})}catch{}else"vibrate"in navigator&&navigator.vibrate([20,100,20])}}}function Kd(a){const n=e.ref(new Set),t=e.ref(null),o=e.ref(-1),i=uh("media-selection"),r=Jd(),s=e.computed(()=>a.value.filter(S=>n.value.has(S.uuid))),l=e.computed(()=>n.value.size);e.watch(n,S=>{i.emit({type:"selection:changed",count:S.size,selectedIds:Array.from(S)})},{deep:!0});const c=e.computed(()=>a.value.length>0&&a.value.every(S=>n.value.has(S.uuid))),d=e.computed(()=>a.value.some(S=>n.value.has(S.uuid)));function u(S){return n.value.has(S)}function f(S){n.value.has(S)?(n.value.delete(S),t.value===S&&(t.value=null,o.value=-1)):(n.value.add(S),t.value=S,o.value=a.value.findIndex(C=>C.uuid===S),n.value.size===1&&r.selection())}function p(S){n.value.add(S),t.value=S,o.value=a.value.findIndex(C=>C.uuid===S)}function m(S){n.value.delete(S),t.value===S&&(t.value=null,o.value=-1)}function h(){a.value.forEach(S=>n.value.add(S.uuid))}function g(){n.value.clear(),t.value=null,o.value=-1}function k(){c.value?g():h()}function $(S,C){const V=a.value.findIndex(x=>x.uuid===S);if(V!==-1)if(C!=null&&C.shiftKey&&o.value!==-1){const x=Math.min(o.value,V),T=Math.max(o.value,V);for(let j=x;j<=T;j++)n.value.add(a.value[j].uuid)}else f(S)}function D(){if(a.value.length===0)return;let S=o.value+1;S>=a.value.length&&(S=0),g(),p(a.value[S].uuid)}function _(){if(a.value.length===0)return;let S=o.value-1;S<0&&(S=a.value.length-1),g(),p(a.value[S].uuid)}function v(S){switch(S.key){case"ArrowDown":S.preventDefault(),D();break;case"ArrowUp":S.preventDefault(),_();break;case"a":(S.ctrlKey||S.metaKey)&&(S.preventDefault(),h());break;case"Escape":S.preventDefault(),g();break;case" ":t.value&&(S.preventDefault(),f(t.value));break}}return{selectedIds:e.computed(()=>n.value),selectedItems:s,selectedCount:l,isAllSelected:c,isSomeSelected:d,lastSelectedId:e.computed(()=>t.value),isSelected:u,toggle:f,select:p,deselect:m,selectAll:h,clear:g,toggleAll:k,rangeSelect:$,selectNext:D,selectPrevious:_,handleKeydown:v,selectionBus:i}}const mh={class:"flex items-center justify-between w-full px-4"},ph={class:"p-4"},fh={key:0,class:"mb-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg"},hh={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"},vh=["value"],gh={class:"flex gap-2 mt-4"},yh={class:"flex justify-end mb-4"},bh={key:1,class:"flex justify-center items-center h-64"},wh={key:2,class:"flex flex-col items-center justify-center h-64 text-center"},kh={class:"text-sm text-theme-secondary"},_h={key:0},Eh={class:"mb-4"},xh={class:"mb-4"},Sh={class:"flex gap-2"},Ch={class:"flex items-center justify-between px-4 py-2"},Vh={class:"text-sm text-theme-secondary"},Nh={key:0},Th={key:0},Mh={key:1},Bh={class:"flex gap-2"},Ih=e.defineComponent({__name:"AdminMediaBrowser",props:{isOpen:{type:Boolean},selectionMode:{default:"single"},selectedItems:{default:()=>[]},modelType:{},modelId:{},collection:{default:"images"},maxSelection:{}},emits:["close","confirm"],setup(a,{emit:n}){const t=a,o=n,i=e.ref("recent"),r=e.ref("grid"),s=e.ref(""),l=e.ref(!1),c=e.ref([]),{selectedItems:d}=e.toRefs(t),u=e.ref(new Set(d.value)),f=e.ref(!1),p=e.ref({}),m=e.ref(["images","documents","videos"]),h=e.ref(1),g=e.ref(!0),k=e.ref(!1),$=Ad(),D=Kd(c);function _(R){var ye;const M=R.conversion_urls||{},H=R.proxy_url||R.original_url||R.url||"",ee=M.thumb||M.preview||R.preview_url||R.thumbnail_url||H,ae=R.custom_properties||{},ue=ae.width,de=ae.height;return{...R,uuid:R.uuid,name:R.name||R.file_name,file_name:R.file_name,filename:R.file_name,mime_type:R.mime_type,size:R.size,collection_name:R.collection_name||"images",disk:R.disk,original_url:H,url:H,thumbnail_url:ee,conversions:R.conversions||{},conversion_urls:M,generated_conversions:R.generated_conversions||{},custom_properties:ae,caption:R.caption||null,alt_text:R.alt_text||null,created_at:R.created_at,updated_at:R.updated_at,is_image:((ye=R.mime_type)==null?void 0:ye.startsWith("image/"))||!1,...typeof ue=="number"?{width:ue}:{},...typeof de=="number"?{height:de}:{},...R.formatted_size!==void 0?{formatted_size:R.formatted_size}:{}}}e.watch(()=>t.selectedItems,R=>{u.value=new Set(R),D.clear(),R.forEach(M=>D.select(M))});const v=e.computed(()=>{var M;let R=c.value;return(M=p.value.types)!=null&&M.length&&(R=R.filter(H=>{var ae,ue;const ee=(ae=H.mime_type)==null?void 0:ae.split("/")[0];return(ue=p.value.types)==null?void 0:ue.includes(ee)})),(p.value.sizeMin!==void 0||p.value.sizeMax!==void 0)&&(R=R.filter(H=>{const ee=H.size/1048576;return!(p.value.sizeMin!==void 0&&ee<p.value.sizeMin||p.value.sizeMax!==void 0&&ee>p.value.sizeMax)})),R}),S=e.computed(()=>{var M;let R=0;return p.value.search&&R++,p.value.collection&&R++,(p.value.dateFrom||p.value.dateTo)&&R++,(M=p.value.types)!=null&&M.length&&(R+=p.value.types.length),(p.value.sizeMin!==void 0||p.value.sizeMax!==void 0)&&R++,R}),C=e.computed(()=>{const R=D.selectedCount.value;return R===0?"Select Media":`Select ${t.selectionMode==="multiple"?`${R} ${R===1?"Item":"Items"}`:"Item"}`}),V=e.computed(()=>{const R=D.selectedCount.value;return!!(R===0||t.selectionMode==="single"&&R>1||t.maxSelection&&R>t.maxSelection)}),x=e.computed(()=>{switch(i.value){case"recent":return"Recent Uploads";case"model":return"Model Media";case"library":return"Media Library";default:return"Media Browser"}});async function T(R=!0){R?(l.value=!0,c.value=[],h.value=1,g.value=!0):k.value=!0;try{const M={collection:p.value.collection||t.collection,per_page:24};switch((s.value||p.value.search)&&(M.search=s.value||p.value.search||""),p.value.dateFrom&&(M.from_date=p.value.dateFrom),p.value.dateTo&&(M.to_date=p.value.dateTo),i.value){case"recent":await $.fetchMedia(h.value,M),R?c.value=$.items.map(H=>_(H)):c.value=[...c.value,...$.items.map(H=>_(H))],g.value=$.currentPage<$.totalPages;break;case"model":if(t.modelType&&t.modelId){const H=await $.fetchModelMedia(t.modelType,t.modelId,M.collection,M.search);c.value=H?H.map(ee=>_(ee)):[],g.value=!1}break;case"library":await $.fetchMedia(h.value,M),R?c.value=$.items.map(H=>_(H)):c.value=[...c.value,...$.items.map(H=>_(H))],g.value=$.currentPage<$.totalPages;break}}catch{}finally{l.value=!1,k.value=!1}}async function j(R){if(!g.value||k.value){R!=null&&R.target&&R.target.complete();return}h.value++,await T(!1),R!=null&&R.target&&(R.target.complete(),g.value||(R.target.disabled=!0))}function E(R){return R==="recent"||R==="model"||R==="library"}function A(R){i.value=R,T()}function N(R){typeof R=="string"&&E(R)&&A(R)}async function z(R){t.selectionMode==="single"?(D.clear(),D.select(R.uuid)):(D.toggle(R.uuid),t.maxSelection&&D.selectedCount.value>t.maxSelection&&(D.deselect(R.uuid),await(await U.toastController.create({message:`Maximum ${t.maxSelection} items can be selected`,duration:2e3,color:"warning"})).present()))}function P(){o("confirm",D.selectedItems.value)}function B(){o("close")}function L(R){}const w=e.ref(null),O=e.ref(!1);function Z(R){w.value=R,O.value=!0}function G(R){const M=c.value.findIndex(ee=>ee.uuid===R.uuid);M!==-1&&(c.value[M]=R);const H={};R.alt_text!==void 0&&(H.alt_text=R.alt_text),R.caption!==void 0&&(H.caption=R.caption),R.custom_properties!==void 0&&(H.custom_properties=R.custom_properties),$.updateMedia(R.uuid,H)}function re(){T()}function be(){p.value={},s.value="",T()}const Ee=dh(()=>{T(!0)},300);e.watch(s,()=>{t.isOpen&&Ee()});async function ie(R){try{await(await U.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 $.deleteMedia(R),await T()}}]})).present()}catch{}}return e.watch(()=>t.isOpen,R=>{R&&T()}),e.onMounted(()=>{t.selectedItems.length>0&&t.selectedItems.forEach(R=>D.select(R))}),(R,M)=>{const H=e.resolveComponent("AdminMediaGrid"),ee=e.resolveComponent("AdminMediaListItem");return e.openBlock(),e.createBlock(e.unref(U.IonModal),{"is-open":R.isOpen,onDidDismiss:B,"backdrop-dismiss":!1,class:"media-browser-modal"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(U.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonButton),{onClick:B},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(U.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(x.value),1)]),_:1})]),_:1}),e.createVNode(e.unref(U.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",mh,[e.createVNode(e.unref(U.IonSegment),{value:i.value,onIonChange:M[0]||(M[0]=ae=>N(ae.detail.value)),class:"max-w-xs"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonSegmentButton),{value:"recent"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...M[15]||(M[15]=[e.createTextVNode("Recent",-1)])]),_:1})]),_:1}),t.modelType&&t.modelId?(e.openBlock(),e.createBlock(e.unref(U.IonSegmentButton),{key:0,value:"model"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...M[16]||(M[16]=[e.createTextVNode("Model",-1)])]),_:1})]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(U.IonSegmentButton),{value:"library"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...M[17]||(M[17]=[e.createTextVNode("Library",-1)])]),_:1})]),_:1})]),_:1},8,["value"]),e.createVNode(e.unref(U.IonButton),{fill:"clear",size:"small",onClick:M[1]||(M[1]=ae=>f.value=!f.value),class:"relative"},{"icon-only":e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{name:"filter-outline"})]),default:e.withCtx(()=>[S.value>0?(e.openBlock(),e.createBlock(e.unref(U.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(S.value),1)]),_:1})):e.createCommentVNode("",!0)]),_:1})])]),_:1})]),_:1}),e.createVNode(e.unref(U.IonContent),null,{default:e.withCtx(()=>[e.createElementVNode("div",ph,[f.value?(e.openBlock(),e.createElementBlock("div",fh,[e.createElementVNode("div",hh,[e.createElementVNode("div",null,[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...M[18]||(M[18]=[e.createTextVNode("Collection",-1)])]),_:1}),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":M[2]||(M[2]=ae=>p.value.collection=ae),class:"w-full p-2 border rounded"},[M[19]||(M[19]=e.createElementVNode("option",{value:""},"All Collections",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,ae=>(e.openBlock(),e.createElementBlock("option",{key:ae,value:ae},e.toDisplayString(ae),9,vh))),128))],512),[[e.vModelSelect,p.value.collection]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...M[20]||(M[20]=[e.createTextVNode("From Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":M[3]||(M[3]=ae=>p.value.dateFrom=ae),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,p.value.dateFrom]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...M[21]||(M[21]=[e.createTextVNode("To Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":M[4]||(M[4]=ae=>p.value.dateTo=ae),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,p.value.dateTo]])])]),e.createElementVNode("div",gh,[e.createVNode(e.unref(U.IonButton),{size:"small",onClick:re},{default:e.withCtx(()=>[...M[22]||(M[22]=[e.createTextVNode("Apply",-1)])]),_:1}),e.createVNode(e.unref(U.IonButton),{size:"small",fill:"clear",onClick:be},{default:e.withCtx(()=>[...M[23]||(M[23]=[e.createTextVNode("Clear",-1)])]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(e.unref(U.IonSearchbar),{modelValue:s.value,"onUpdate:modelValue":M[5]||(M[5]=ae=>s.value=ae),placeholder:"Search media...",debounce:300,class:"mb-4"},null,8,["modelValue"]),e.createElementVNode("div",yh,[e.createVNode(e.unref(U.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonButton),{fill:r.value==="grid"?"solid":"clear",size:"small",onClick:M[6]||(M[6]=ae=>r.value="grid")},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{name:"grid-outline"})]),_:1},8,["fill"]),e.createVNode(e.unref(U.IonButton),{fill:r.value==="list"?"solid":"clear",size:"small",onClick:M[7]||(M[7]=ae=>r.value="list")},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{name:"list-outline"})]),_:1},8,["fill"])]),_:1})]),l.value?(e.openBlock(),e.createElementBlock("div",bh,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"})])):v.value.length===0?(e.openBlock(),e.createElementBlock("div",wh,[e.createVNode(e.unref(U.IonIcon),{name:"images-outline",class:"text-6xl text-theme-secondary mb-4"}),M[24]||(M[24]=e.createElementVNode("h3",{class:"text-lg font-medium text-theme mb-2"}," No Media Found ",-1)),e.createElementVNode("p",kh,e.toDisplayString(s.value?"Try adjusting your search":"No media items available"),1)])):r.value==="grid"?(e.openBlock(),e.createBlock(H,{key:3,"media-items":v.value,"selected-items":e.unref(D).selectedItems.value,"is-loading":!1,"selection-mode":!0,columns:{mobile:2,sm:3,md:4,lg:5,xl:6},onToggleSelect:z,onPreview:L,onEdit:Z,onDelete:ie},null,8,["media-items","selected-items"])):(e.openBlock(),e.createBlock(e.unref(U.IonList),{key:4,lines:"none",class:"rounded-lg overflow-hidden"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,(ae,ue)=>(e.openBlock(),e.createBlock(ee,{key:ae.uuid,media:ae,selected:e.unref(D).isSelected(ae.uuid),"selection-mode":!0,index:ue,onToggleSelect:z,onPreview:L,onEdit:Z,onDelete:ie},null,8,["media","selected","index"]))),128))]),_:1})),!l.value&&v.value.length>0&&i.value!=="model"?(e.openBlock(),e.createBlock(e.unref(U.IonInfiniteScroll),{key:5,threshold:"100px",onIonInfinite:M[8]||(M[8]=ae=>j(ae))},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonInfiniteScrollContent),{"loading-spinner":"crescent","loading-text":"Loading more media..."})]),_:1})):e.createCommentVNode("",!0)])]),_:1}),e.createVNode(e.unref(U.IonModal),{"is-open":O.value,onDidDismiss:M[14]||(M[14]=ae=>O.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(U.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonButton),{onClick:M[9]||(M[9]=ae=>O.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(U.IonTitle),null,{default:e.withCtx(()=>[...M[25]||(M[25]=[e.createTextVNode("Edit Media Info",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(U.IonContent),{class:"p-4"},{default:e.withCtx(()=>[w.value?(e.openBlock(),e.createElementBlock("div",_h,[e.createElementVNode("div",Eh,[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...M[26]||(M[26]=[e.createTextVNode("Caption",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":M[10]||(M[10]=ae=>w.value.caption=ae),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter caption..."},null,512),[[e.vModelText,w.value.caption]])]),e.createElementVNode("div",xh,[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...M[27]||(M[27]=[e.createTextVNode("Alt Text",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":M[11]||(M[11]=ae=>w.value.alt_text=ae),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter alt text..."},null,512),[[e.vModelText,w.value.alt_text]])]),e.createElementVNode("div",Sh,[e.createVNode(e.unref(U.IonButton),{onClick:M[12]||(M[12]=ae=>G(w.value))},{default:e.withCtx(()=>[...M[28]||(M[28]=[e.createTextVNode("Save",-1)])]),_:1}),e.createVNode(e.unref(U.IonButton),{fill:"clear",onClick:M[13]||(M[13]=ae=>O.value=!1)},{default:e.withCtx(()=>[...M[29]||(M[29]=[e.createTextVNode("Cancel",-1)])]),_:1})])])):e.createCommentVNode("",!0)]),_:1})]),_:1},8,["is-open"]),e.createVNode(e.unref(U.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",Ch,[e.createElementVNode("div",Vh,[e.unref(D).selectedCount.value>0?(e.openBlock(),e.createElementBlock("span",Nh,[e.createTextVNode(e.toDisplayString(e.unref(D).selectedCount.value)+" selected ",1),t.maxSelection?(e.openBlock(),e.createElementBlock("span",Th," / "+e.toDisplayString(t.maxSelection)+" max ",1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("span",Mh," Select "+e.toDisplayString(t.selectionMode==="multiple"?"items":"an item"),1))]),e.createElementVNode("div",Bh,[e.createVNode(e.unref(U.IonButton),{fill:"clear",onClick:B},{default:e.withCtx(()=>[...M[30]||(M[30]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(U.IonButton),{disabled:V.value,onClick:P},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(C.value),1)]),_:1},8,["disabled"])])])]),_:1})]),_:1})]),_:1},8,["is-open"])}}}),Fh=Me(Ih,[["__scopeId","data-v-9a8c0954"]]),$h={key:1,class:"flex flex-col items-center justify-center py-16"},Dh=["draggable","onDragstart","onDragover","onDrop"],Rh={key:0,class:"absolute top-2 left-2 z-20"},Ah=["checked","onChange"],Lh={key:2,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-move"},Ph=["data-media-id"],Oh={key:0,class:"w-full h-full flex items-center justify-center"},Uh=["src","alt","onError","onLoad"],zh={key:2,class:"w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-700"},jh={class:"text-center"},Wh={class:"text-4xl text-gray-400 mb-2"},Zh={class:"text-sm font-medium text-gray-500"},Hh={class:"absolute inset-0 bg-black/70 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2"},Xh=["onClick"],Gh=["onClick"],Jh=["onClick"],Kh={class:"p-3"},Yh={class:"text-sm font-medium truncate mb-1"},qh={class:"text-xs text-gray-600 dark:text-gray-400"},Qh={key:0},ev={key:0,class:"text-xs text-gray-500 dark:text-gray-500 mt-1 truncate"},tv=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(a,{emit:n}){const t=a,o=n,i=e.ref(null),r=e.ref(null),s=e.ref(new Set),l=e.ref(null),c=V=>t.selectedItems.some(x=>x.uuid===V.uuid),d=e.computed(()=>{const V=t.columns,x=["grid","gap-4"];switch(V.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(V.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(V.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(V.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(V.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(V,x,T){t.reorderable&&(i.value=x,V.dataTransfer&&(V.dataTransfer.effectAllowed="move",V.dataTransfer.setData("text/html","")))}function f(V,x){t.reorderable&&(V.preventDefault(),r.value=x)}function p(){r.value=null}function m(V,x){if(!t.reorderable||!i.value)return;V.preventDefault();const T=[...t.mediaItems],j=T.findIndex(E=>{var A;return E.uuid===((A=i.value)==null?void 0:A.uuid)});if(j!==-1&&j!==x&&i.value){const[E]=T.splice(j,1);T.splice(x,0,E),o("reorder",T)}i.value=null,r.value=null}function h(V){return V<1024?V+" B":V<1024*1024?(V/1024).toFixed(1)+" KB":(V/(1024*1024)).toFixed(1)+" MB"}function g(V){var T;return V.thumbnail_url||((T=V.conversion_urls)==null?void 0:T.thumb)||V.original_url||V.url||""}function k(V){var j,E,A;const x=((j=V.mime_type)==null?void 0:j.startsWith("image/"))||!1,T=!!(V.thumbnail_url||(E=V.conversion_urls)!=null&&E.thumb||(A=V.conversion_urls)!=null&&A.preview||V.original_url||V.url);return x&&T}function $(V){var x;return((x=V.split(".").pop())==null?void 0:x.toUpperCase())||""}function D(V){var T;const x=((T=V.mime_type)==null?void 0:T.toLowerCase())||"";return x.startsWith("image/")?"image":x.startsWith("video/")?"videocam":x.startsWith("audio/")?"musical-notes":x.includes("pdf")?"document-text":x.includes("zip")||x.includes("rar")?"archive":x.includes("sheet")||x.includes("excel")?"grid":x.includes("document")||x.includes("word")?"document-text":"document"}e.onMounted(()=>{typeof window<"u"&&"IntersectionObserver"in window&&(l.value=new IntersectionObserver(V=>{V.forEach(x=>{var T;if(x.isIntersecting){const j=x.target.getAttribute("data-media-id");j&&(s.value.add(j),(T=l.value)==null||T.unobserve(x.target))}})},{rootMargin:"50px"}))}),e.onUnmounted(()=>{l.value&&l.value.disconnect()});function _(V){return!0}function v(){l.value&&e.nextTick(()=>{document.querySelectorAll("[data-media-id]").forEach(x=>{var j;const T=x.getAttribute("data-media-id");T&&!s.value.has(T)&&((j=l.value)==null||j.observe(x))})})}e.watch(()=>t.mediaItems,()=>{s.value.clear(),v()},{immediate:!0,deep:!0});function S(V,x){const T=V.target;delete T.dataset.fallbackIndex}function C(V,x){const T=V.target,j=T.closest("[data-media-id]"),E=[x.original_url,x.url,x.thumbnail_url,"preview_url"in x?x.preview_url:void 0].filter(A=>A&&A.trim()!==""&&A!==T.src);if(E.length>0&&T.dataset.fallbackIndex){const A=parseInt(T.dataset.fallbackIndex);if(A<E.length){T.dataset.fallbackIndex=(A+1).toString(),T.src=E[A]||"";return}}else if(E.length>0){T.dataset.fallbackIndex="1",T.src=E[0]||"";return}if(T.style.display="none",j&&!j.querySelector(".media-fallback-icon")){const N=document.createElement("div");N.className="media-fallback-icon w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-800",N.innerHTML=`
|
|
2
|
-
<div class="text-center">
|
|
3
|
-
<div class="text-4xl text-gray-400 mb-2">${D(x)}</div>
|
|
4
|
-
<p class="text-sm font-medium text-gray-500">${$(x.file_name)}</p>
|
|
5
|
-
</div>
|
|
6
|
-
`,j.appendChild(N)}}return(V,x)=>V.isLoading?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(d.value)},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(12,T=>e.createElementVNode("div",{key:`skeleton-${T}`,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)):!V.mediaItems||!V.mediaItems.length?(e.openBlock(),e.createElementBlock("div",$h,[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]=T=>o("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(d.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(V.mediaItems,(T,j)=>(e.openBlock(),e.createElementBlock("div",{key:T.uuid,class:e.normalizeClass(["relative group",{"ring-2 ring-blue-500 ring-offset-2":r.value===j}]),draggable:V.reorderable,onDragstart:E=>u(E,T),onDragover:E=>f(E,j),onDragleave:p,onDrop:E=>m(E,j)},[V.selectionMode?(e.openBlock(),e.createElementBlock("div",Rh,[e.createElementVNode("input",{type:"checkbox",checked:c(T),onChange:E=>o("toggleSelect",T),class:"w-5 h-5 bg-white dark:bg-gray-800 rounded cursor-pointer"},null,40,Ah)])):e.createCommentVNode("",!0),V.$slots.badge?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["absolute top-2 z-20",V.selectionMode?"left-10":"left-2"])},[e.renderSlot(V.$slots,"badge",{media:T,index:j},void 0,!0)],2)):e.createCommentVNode("",!0),V.reorderable?(e.openBlock(),e.createElementBlock("div",Lh,[...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":c(T)}])},[e.createElementVNode("div",{class:"relative aspect-square bg-gray-100 dark:bg-gray-700 overflow-hidden","data-media-id":T.uuid},[k(T)&&!_(T.uuid)?(e.openBlock(),e.createElementBlock("div",Oh,[...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),k(T)&&_(T.uuid)?(e.openBlock(),e.createElementBlock("img",{key:1,src:g(T),alt:T.alt_text||T.file_name,class:"w-full h-full object-cover",loading:"lazy",onError:E=>C(E,T),onLoad:E=>S(E)},null,40,Uh)):(e.openBlock(),e.createElementBlock("div",zh,[e.createElementVNode("div",jh,[e.createElementVNode("div",Wh,e.toDisplayString(D(T)),1),e.createElementVNode("p",Zh,e.toDisplayString($(T.file_name)),1)])])),e.createElementVNode("div",Hh,[e.createElementVNode("button",{onClick:E=>o("preview",T),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,Xh),V.showEditButton&&k(T)?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:E=>o("edit",T),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,Gh)):e.createCommentVNode("",!0),e.createElementVNode("button",{onClick:E=>o("delete",T.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,Jh)])],8,Ph),e.createElementVNode("div",Kh,[e.createElementVNode("h4",Yh,e.toDisplayString(T.file_name),1),e.createElementVNode("p",qh,[e.createTextVNode(e.toDisplayString(h(T.size))+" ",1),T.width&&T.height?(e.openBlock(),e.createElementBlock("span",Qh," • "+e.toDisplayString(T.width)+"x"+e.toDisplayString(T.height),1)):e.createCommentVNode("",!0)]),T.caption?(e.openBlock(),e.createElementBlock("p",ev,e.toDisplayString(T.caption),1)):e.createCommentVNode("",!0)])],2)],42,Dh))),128))],2))}}),nv=Me(tv,[["__scopeId","data-v-f0c343b7"]]),av={class:"model-media-manager"},ov=["accept","multiple"],iv={class:"flex items-center justify-between mb-4"},rv={key:0,class:"text-lg font-medium"},sv={class:"flex gap-2"},lv={key:0,class:"flex items-center justify-center py-8"},cv={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"},dv={class:"text-gray-600 dark:text-gray-400"},uv={class:"flex gap-2 mt-4"},mv={key:0,class:"px-2 py-1 bg-blue-500 text-white text-xs font-medium rounded"},pv=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(a,{emit:n}){const t=a,o=n,i=ln(),r=e.ref(!1),s=e.ref(!1),l=e.ref(!1),c=e.ref(!1),d=e.ref(null),u=e.ref(0),f=e.ref(null),p=e.ref(void 0),m=e.ref(null),h=e.ref(null),g=e.computed(()=>{if(t.maxFiles!==void 0)return Math.max(0,t.maxFiles-i.modelMedia.length)}),k=e.computed(()=>i.modelMedia.map(O=>O.uuid)),$=e.computed(()=>{if(!(!t.acceptedMimeTypes||t.acceptedMimeTypes.length===0))return t.acceptedMimeTypes.join(",")});function D(){no({isAdmin:t.mode==="admin"})}async function _(O){await(await U.toastController.create({message:O,duration:3e3,color:"danger",position:"bottom"})).present()}async function v(){if(!s.value)if(s.value=!0,D(),i.setModelContext(t.mediableType,t.mediableId,t.collection),t.initialMedia&&t.initialMedia.length>0)i.modelMedia=[...t.initialMedia],o("update:media",i.modelMedia);else{r.value=!0,o("loading",!0);try{await i.fetchModelMedia(t.mediableType,t.mediableId,t.collection),o("update:media",i.modelMedia)}catch(O){const Z=O instanceof Error?O.message:"Failed to fetch media";o("error",{operation:"fetch",message:Z,details:O})}finally{r.value=!1,o("loading",!1)}}}e.watch(()=>i.modelMedia,O=>{s.value&&o("update:media",O)},{deep:!0}),e.watch(()=>[t.mediableType,t.mediableId,t.collection],()=>{s.value=!1,v()}),e.watch(()=>t.mode,()=>{D()}),e.onMounted(()=>{v()}),e.onUnmounted(()=>{i.clearModelContext()});function S(){return i.modelMedia.length>0}function C(){return t.maxFiles===void 0?!1:i.modelMedia.length>=t.maxFiles}function V(O){var G,re,be;if(!((G=O.mime_type)!=null&&G.startsWith("image/")))return null;const Z=O.original_url||O.url||((re=O.conversion_urls)==null?void 0:re.preview)||((be=O.conversion_urls)==null?void 0:be.thumb)||O.thumbnail_url;return Z&&Z.trim()!==""?Z:null}function x(){l.value=!0}function T(){var O;(O=h.value)==null||O.click()}function j(){l.value=!1}async function E(O){if(!t.allowEdit)return;const Z=V(O);if(Z){d.value=O,u.value++;try{const G=i.getHttpClient(),re=i.getApiUrl(""),be=await G(`${re.replace(/\/$/,"")}/editor/${O.uuid}/edit`);p.value=be.editable_source_url||Z,f.value=be.editor_state??null}catch{p.value=Z,f.value=null}c.value=!0}}function A(){c.value=!1,d.value=null,p.value=void 0,f.value=null}async function N(O){if(!d.value)throw new Error("No media selected for editing");const Z=d.value,G=t.editMode==="variant";try{m.value=null;const re=await i.saveEditedImage(Z.uuid,O,{asVariant:G,name:Z.file_name});G||await i.detachMedia(t.mediableType,t.mediableId,Z.uuid,t.collection),await i.attachMedia(t.mediableType,t.mediableId,[re.uuid],t.collection),o("edit-complete",{originalMedia:Z,editedMedia:re,mode:t.editMode}),c.value=!1,d.value=null}catch(re){const be=re instanceof Error?re.message:"Failed to save edited image";throw m.value=be,await _(be),re}}function z(O){if(m.value===O.message){m.value=null;return}_(O.message)}async function P(O){const Z=O.target,G=Z.files;if(!(!G||G.length===0)){for(let re=0;re<G.length;re++){const be=G[re];if(g.value!==void 0&&g.value<=0)break;if(t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0&&!t.acceptedMimeTypes.includes(be.type)){o("error",{operation:"upload",message:`File type ${be.type} is not accepted`,details:{file:be.name}});continue}if(t.maxFileSize!==void 0&&be.size>t.maxFileSize){o("error",{operation:"upload",message:`File size exceeds limit of ${t.maxFileSize} bytes`,details:{file:be.name,size:be.size}});continue}o("upload-progress",{status:"uploading",progress:0,file:be});try{const Ee=await i.uploadFile(be,{collection:t.collection});Ee!=null&&Ee.uuid&&(await i.attachMedia(t.mediableType,t.mediableId,[Ee.uuid],t.collection),o("upload-progress",{status:"complete",progress:100,file:be}),o("attach",[Ee]))}catch(Ee){const ie=Ee instanceof Error?Ee.message:"Upload failed";o("error",{operation:"upload",message:ie,details:Ee}),o("upload-progress",{status:"error",progress:0,file:be,error:ie})}}Z.value=""}}async function B(O){const Z=O.map(G=>G.uuid);try{await i.reorderMedia(t.mediableType,t.mediableId,Z,t.collection),o("reorder",i.modelMedia)}catch(G){const re=G instanceof Error?G.message:"Failed to reorder media";o("error",{operation:"reorder",message:re,details:G}),await _(re)}}async function L(O){const Z=i.modelMedia.find(G=>G.uuid===O);try{await i.detachMedia(t.mediableType,t.mediableId,O,t.collection),Z&&o("detach",Z)}catch(G){const re=G instanceof Error?G.message:"Failed to detach media";o("error",{operation:"detach",message:re,details:G}),await _(re)}}async function w(O){l.value=!1;const Z=O.map(be=>be.uuid),G=new Set(k.value);let re=Array.from(new Set(Z)).filter(be=>!G.has(be));if(g.value!==void 0&&re.length>g.value&&(re=re.slice(0,g.value)),re.length!==0)try{await i.attachMedia(t.mediableType,t.mediableId,re,t.collection);const be=i.modelMedia.filter(Ee=>re.includes(Ee.uuid));o("attach",be)}catch(be){const Ee=be instanceof Error?be.message:"Failed to attach media";o("error",{operation:"attach",message:Ee,details:be})}}return(O,Z)=>(e.openBlock(),e.createElementBlock("div",av,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:h,type:"file",accept:$.value,multiple:g.value===void 0||g.value>1,class:"hidden","data-testid":"upload-input",onChange:P},null,40,ov),e.createElementVNode("div",iv,[O.title?(e.openBlock(),e.createElementBlock("h3",rv,e.toDisplayString(O.title),1)):e.createCommentVNode("",!0),e.createElementVNode("div",sv,[O.allowBrowse?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:0,fill:"outline",size:"small",disabled:C(),"data-testid":"browse-button",onClick:x},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"start",icon:e.unref(os)},null,8,["icon"]),Z[1]||(Z[1]=e.createTextVNode(" Browse ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0),O.allowUpload?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:1,fill:"solid",size:"small",disabled:C(),"data-testid":"upload-button",onClick:T},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"start",icon:e.unref(pc)},null,8,["icon"]),Z[2]||(Z[2]=e.createTextVNode(" Upload ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0)])]),r.value||e.unref(i).isLoadingModelMedia?(e.openBlock(),e.createElementBlock("div",lv,[e.createVNode(e.unref(U.IonSpinner),{"data-testid":"spinner"})])):S()?(e.openBlock(),e.createBlock(nv,{key:2,"media-items":e.unref(i).modelMedia,reorderable:!!O.allowReorder,"is-loading":r.value||e.unref(i).isLoadingModelMedia,"show-edit-button":!!O.allowEdit,"selection-mode":!1,onReorder:B,onDelete:L,onEdit:E},e.createSlots({_:2},[O.showPrimaryBadge?{name:"badge",fn:e.withCtx(({index:G})=>[G===0?(e.openBlock(),e.createElementBlock("div",mv," Primary ")):e.createCommentVNode("",!0)]),key:"0"}:void 0]),1032,["media-items","reorderable","is-loading","show-edit-button"])):(e.openBlock(),e.createElementBlock("div",cv,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(os),class:"w-12 h-12 text-gray-400 mb-4"},null,8,["icon"]),e.createElementVNode("p",dv,e.toDisplayString(O.emptyText),1),e.createElementVNode("div",uv,[O.allowBrowse?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:0,fill:"outline",size:"small","data-testid":"browse-button-empty",onClick:x},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"start",icon:e.unref(os)},null,8,["icon"]),Z[3]||(Z[3]=e.createTextVNode(" Browse Library ",-1))]),_:1})):e.createCommentVNode("",!0),O.allowUpload?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:1,fill:"solid",size:"small","data-testid":"upload-button-empty",onClick:T},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"start",icon:e.unref(pc)},null,8,["icon"]),Z[4]||(Z[4]=e.createTextVNode(" Upload Files ",-1))]),_:1})):e.createCommentVNode("",!0)])])),e.createVNode(Fh,e.mergeProps({"is-open":l.value,"selected-items":k.value,collection:O.collection},g.value!==null&&g.value!==void 0?{maxSelection:g.value}:{},{onConfirm:w,onClose:j}),null,16,["is-open","selected-items","collection"]),e.createVNode(zd,{modelValue:c.value,"onUpdate:modelValue":Z[0]||(Z[0]=G=>c.value=G),"initial-image":p.value,"initial-state":f.value,"session-key":u.value,onSave:N,onCancel:A,onError:z},null,8,["modelValue","initial-image","initial-state","session-key"])]))}}),fv=Me(pv,[["__scopeId","data-v-f68e70ec"]]),hv={class:"existing-media-selector","data-testid":"existing-media-selector"},vv={key:0,class:"existing-media-selector__status","data-testid":"existing-media-loading"},gv=["data-testid"],yv={class:"existing-media-selector__section-header"},bv={class:"existing-media-selector__section-title"},wv=["data-testid","aria-label","onClick"],kv={class:"existing-media-selector__grid"},_v=["data-testid","aria-label","aria-pressed","onClick"],Ev=["src","alt"],xv={key:0,class:"existing-media-selector__selected-badge"},Sv={key:1,class:"existing-media-selector__caption"},Cv={key:0,class:"existing-media-selector__section existing-media-selector__section--albums","data-testid":"existing-media-albums"},Vv={class:"existing-media-selector__section-header"},Nv={class:"existing-media-selector__section-title"},Tv={class:"existing-media-selector__albums"},Mv=["data-testid","aria-label","aria-pressed","onClick"],Bv={class:"existing-media-selector__album-name"},Iv={key:0,class:"existing-media-selector__album-count"},Fv={class:"existing-media-selector__album-panel","data-testid":"existing-media-active-album"},$v={class:"existing-media-selector__section-header"},Dv={class:"existing-media-selector__section-subtitle"},Rv={key:0,class:"existing-media-selector__section-description"},Av={key:0,class:"existing-media-selector__status","data-testid":"existing-media-active-album-loading"},Lv={key:1,class:"existing-media-selector__grid"},Pv=["data-testid","aria-label","aria-pressed","onClick"],Ov=["src","alt"],Uv={key:0,class:"existing-media-selector__selected-badge"},zv={key:1,class:"existing-media-selector__caption"},jv={key:2,class:"existing-media-selector__empty","data-testid":"existing-media-active-album-empty"},Wv={key:1,class:"existing-media-selector__empty","data-testid":"existing-media-empty"},Zv=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(a,{emit:n}){const t=a,o=n,i=e.reactive({}),r=e.computed(()=>t.sections.filter(v=>v.items.length>0)),s=e.computed(()=>t.albums.length>0),l=e.computed(()=>r.value.length>0||s.value),c=e.computed(()=>{if(typeof t.activeAlbumTitle=="string"&&t.activeAlbumTitle.trim().length>0)return t.activeAlbumTitle.trim();const v=t.albums.find(S=>S.id===t.activeAlbumId);return v!=null&&v.name.trim().length?v.name.trim():t.albumSectionTitle}),d=e.computed(()=>{if(typeof t.activeAlbumDescription=="string"&&t.activeAlbumDescription.trim().length>0)return t.activeAlbumDescription.trim();const v=t.albums.find(S=>S.id===t.activeAlbumId);return typeof(v==null?void 0:v.description)=="string"&&v.description.trim().length>0?v.description.trim():""});function u(v){const S=v.initialVisibleCount??6;return S>0?S:6}function f(v){return i[v]===!0}function p(v){i[v]=!f(v)}function m(v){return f(v.id)?v.items:v.items.slice(0,u(v))}function h(v){return v.items.length>u(v)}function g(v){o("select",v)}function k(v){o("update:activeAlbumId",v)}function $(v){var C;const S=(C=v.description)==null?void 0:C.trim();return S&&S.length>0?`Select ${S}`:"Select existing media"}function D(v,S){var V;const C=(V=S.description)==null?void 0:V.trim();return typeof S.alt=="string"&&S.alt.trim().length>0?S.alt.trim():C&&C.length>0?C:v.title}function _(v){const S=typeof v.mediaCount=="number"?` with ${v.mediaCount} item${v.mediaCount===1?"":"s"}`:"";return`Browse album ${v.name}${S}`}return(v,S)=>(e.openBlock(),e.createElementBlock("div",hv,[v.isLoading?(e.openBlock(),e.createElementBlock("div",vv," Loading your media... ")):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,C=>(e.openBlock(),e.createElementBlock("section",{key:C.id,class:"existing-media-selector__section","data-testid":`existing-media-section-${C.id}`},[e.createElementVNode("div",yv,[e.createElementVNode("h3",bv,e.toDisplayString(C.title),1),h(C)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"existing-media-selector__toggle","data-testid":`existing-media-toggle-${C.id}`,"aria-label":f(C.id)?`Show fewer items from ${C.title}`:`Show more items from ${C.title}`,onClick:V=>p(C.id)},e.toDisplayString(f(C.id)?"See less":"See more"),9,wv)):e.createCommentVNode("",!0)]),e.createElementVNode("div",kv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m(C),V=>(e.openBlock(),e.createElementBlock("button",{key:V.id,type:"button",class:e.normalizeClass(["existing-media-selector__item",{"is-selected":v.selectedId===V.id}]),"data-testid":`existing-media-item-${C.id}-${V.id}`,"aria-label":$(V),"aria-pressed":v.selectedId===V.id?"true":"false",onClick:x=>g(V)},[e.createElementVNode("img",{class:"existing-media-selector__image",src:V.previewUrl,alt:D(C,V)},null,8,Ev),v.selectedId===V.id?(e.openBlock(),e.createElementBlock("div",xv," Selected ")):e.createCommentVNode("",!0),V.description?(e.openBlock(),e.createElementBlock("div",Sv,e.toDisplayString(V.description),1)):e.createCommentVNode("",!0)],10,_v))),128))])],8,gv))),128)),s.value?(e.openBlock(),e.createElementBlock("section",Cv,[e.createElementVNode("div",Vv,[e.createElementVNode("h3",Nv,e.toDisplayString(v.albumBrowseTitle),1)]),e.createElementVNode("div",Tv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.albums,C=>(e.openBlock(),e.createElementBlock("button",{key:C.id,type:"button",class:e.normalizeClass(["existing-media-selector__album",{"is-active":v.activeAlbumId===C.id}]),"data-testid":`existing-media-album-${C.id}`,"aria-label":_(C),"aria-pressed":v.activeAlbumId===C.id?"true":"false",onClick:V=>k(C.id)},[e.createElementVNode("span",Bv,e.toDisplayString(C.name),1),typeof C.mediaCount=="number"?(e.openBlock(),e.createElementBlock("span",Iv,e.toDisplayString(C.mediaCount),1)):e.createCommentVNode("",!0)],10,Mv))),128))]),e.createElementVNode("div",Fv,[e.createElementVNode("div",$v,[e.createElementVNode("div",null,[e.createElementVNode("h4",Dv,e.toDisplayString(c.value),1),d.value?(e.openBlock(),e.createElementBlock("p",Rv,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0)])]),v.isAlbumLoading?(e.openBlock(),e.createElementBlock("div",Av," Loading album... ")):v.activeAlbumItems.length>0?(e.openBlock(),e.createElementBlock("div",Lv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.activeAlbumItems,C=>(e.openBlock(),e.createElementBlock("button",{key:C.id,type:"button",class:e.normalizeClass(["existing-media-selector__item",{"is-selected":v.selectedId===C.id}]),"data-testid":`existing-media-item-album-${C.id}`,"aria-label":$(C),"aria-pressed":v.selectedId===C.id?"true":"false",onClick:V=>g(C)},[e.createElementVNode("img",{class:"existing-media-selector__image",src:C.previewUrl,alt:C.alt||C.description||c.value},null,8,Ov),v.selectedId===C.id?(e.openBlock(),e.createElementBlock("div",Uv," Selected ")):e.createCommentVNode("",!0),C.description?(e.openBlock(),e.createElementBlock("div",zv,e.toDisplayString(C.description),1)):e.createCommentVNode("",!0)],10,Pv))),128))])):(e.openBlock(),e.createElementBlock("div",jv,[e.renderSlot(v.$slots,"active-album-empty",{},()=>[e.createTextVNode(e.toDisplayString(v.activeAlbumEmptyMessage),1)],!0)]))])])):e.createCommentVNode("",!0),l.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Wv,[e.renderSlot(v.$slots,"empty",{},()=>[e.createTextVNode(e.toDisplayString(v.emptyMessage),1)],!0)]))],64))]))}}),Hv=Me(Zv,[["__scopeId","data-v-904abb6b"]]);function xi(a,n,t,o){if(t<=0||o<=0)return!1;try{return n.drawImage(a,0,0,t,o),!0}catch(i){return i instanceof DOMException&&i.name==="InvalidStateError",!1}}function Xv(a,n){return a?{display:"block",position:"absolute",inset:"0",width:"100%",height:"100%",objectFit:n,opacity:"0",pointerEvents:"none"}:{display:"block",position:"relative",inset:"auto",width:"100%",height:"100%",objectFit:n,opacity:"1",pointerEvents:"auto"}}const Gv=["src","crossorigin"],Jv={class:"preview-controls"},Kv=["aria-label"],Yv={class:"time-display"},qv={class:"current-time"},Qv={class:"total-time"},e0={key:0,class:"fps-display"},t0={key:0,class:"loading-overlay"},n0={key:1,class:"error-overlay"},a0=.1,o0=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(a,{expose:n,emit:t}){const{ColorMatrixFilter:o,BlurFilter:i}=Vt,r=a,s=t,l=e.ref(),c=e.ref(),d=e.ref(),u=e.ref(!0),f=e.ref(),p=e.ref(0),m=e.ref(0),h=e.ref(!1);let g,k,$=null,D=null,_=null,v=[],S="",C=null,V=0,x=0,T=0,j=0,E=!1,A=0,N=0,z,P=null,B=!1,L=!1,w=0;const O=e.computed(()=>r.source&&typeof r.source=="string"?r.source:""),Z=e.computed(()=>{const he=O.value;if(!(!he||he.startsWith("blob:")))return"anonymous"}),G=e.computed(()=>Xv(h.value,r.fitMode));function re(he){return typeof he=="number"&&Number.isFinite(he)&&he>=0?he:Number.isFinite(r.fallbackDuration)&&r.fallbackDuration>0?r.fallbackDuration:0}function be(he){const Ne=re(he.duration);return Ne<=0?!1:he.currentTime>=Math.max(0,Ne-a0)}async function Ee(){var he,Ne;if(!L&&c.value&&!g&&!(!d.value||d.value.readyState<3)){L=!0;try{f.value=void 0;let Re=((he=l.value)==null?void 0:he.clientWidth)||800,He=((Ne=l.value)==null?void 0:Ne.clientHeight)||450;if((Re<=0||He<=0)&&(Re=d.value.videoWidth||800,He=d.value.videoHeight||450),g=new Vt.Application,await g.init({width:Re,height:He,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,antialias:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),c.value.appendChild(g.canvas),d.value){if(d.value.videoWidth===0||d.value.videoHeight===0){setTimeout(()=>{d.value&&d.value.videoWidth>0&&!g&&Ee()},100),g&&(g.destroy(!0),g=null);return}if(V=d.value.videoWidth,x=d.value.videoHeight,D=document.createElement("canvas"),D.width=V,D.height=x,_=D.getContext("2d"),!_)throw new Error("Unable to create 2D canvas context for video preview");const je=xi(d.value,_,V,x),Oe=Vt.Texture.from(D);$=Oe.source,k=new Vt.Sprite(Oe),k.visible=!0,k.alpha=1,bt(),g.stage.addChild(k),g.renderer&&!g.renderer.destroyed&&g.render()}H(),r.targetFps<60?ie():g.ticker.add(R),h.value=!0,"ResizeObserver"in window&&(C=new ResizeObserver(je=>{E||(E=!0,requestAnimationFrame(()=>{E=!1;const Oe=je[je.length-1],{width:ct,height:dt}=Oe.contentRect;if(ct<=0||dt<=0)return;const Pt=Math.round(ct),Rt=Math.round(dt);Pt===T&&Rt===j||(T=Pt,j=Rt,bt())}))}),C.observe(l.value)),r.filters&&r.filters.length>0&&H(),r.showFps&&pt(),w=0}catch{if(ot(),!B&&!!d.value&&d.value.readyState>=2&&d.value.videoWidth>0&&d.value.videoHeight>0&&w<2){w+=1,window.setTimeout(()=>{B||Ee()},w*150);return}f.value="Failed to initialize video preview",s("error",f.value)}finally{L=!1}}}function ie(){const he=1e3/r.targetFps;let Ne=performance.now();function Re(){if(B||!g)return;const He=performance.now(),je=He-Ne;je>=he&&(R(),Ne=He-je%he),P=requestAnimationFrame(Re)}P=requestAnimationFrame(Re)}function R(){if(!(!g||!k||B)&&r.active)try{_&&D&&$&&d.value&&(d.value.readyState>=2&&xi(d.value,_,D.width,D.height)&&$.update(),d.value.paused||s("frame-update",ue())),r.showFps&&N++,g.renderer&&!g.renderer.destroyed&&g.render()}catch{B=!0}}function M(){for(const he of v)try{he.destroy()}catch{}v=[]}function H(){if(k){if(!r.filters||r.filters.length===0){k.filters=null,M();return}M(),r.filters.forEach(he=>{const Ne=ee(he);Ne&&v.push(Ne)}),k.filters=v.length>0?v:null,S=JSON.stringify(r.filters),g&&g.render()}}function ee(he){const Ne=he.filterId,Re=he.params||{},He=pe.getFilter(Ne);if(He&&!pe.isFilterCompatibleWithMedia(Ne,"video"))return null;if(He&&He.createFilter)try{return He.createFilter(Re)}catch{}const je=(Oe,ct,dt)=>Math.min(dt,Math.max(ct,Oe));switch(Ne){case"brightness":{const Oe=new o,ct=je(typeof Re.brightness=="number"?Re.brightness:typeof Re.value=="number"?Re.value:1,0,5);return Oe.brightness(ct,!0),Oe}case"contrast":{const Oe=new o,ct=je(typeof Re.contrast=="number"?Re.contrast:typeof Re.value=="number"?Re.value:1,0,5);return Oe.contrast(ct,!0),Oe}case"saturation":{const Oe=new o,ct=je(typeof Re.saturation=="number"?Re.saturation:typeof Re.value=="number"?Re.value:1,0,5);return Oe.saturate(ct,!0),Oe}case"hue":{const Oe=new o,ct=je(typeof Re.value=="number"?Re.value:0,-180,180);return Oe.hue(ct,!0),Oe}case"gaussian-blur":case"blur":{const Oe=je(typeof Re.blur=="number"?Re.blur:typeof Re.value=="number"?Re.value:2,0,10);return new i(Oe)}case"grayscale":{const Oe=new o;return Oe.desaturate(),Oe}case"sepia":case"color-matrix":{const Oe=new o;return Oe.sepia(!0),Oe}case"vignette":{const Oe=typeof Re.value=="number"?Re.value:.3;return ae(je(Oe,0,1))}default:return null}}function ae(he){const Ne=`
|
|
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 Vt.Filter(void 0,Ne,{strength:he})}function ue(){var Ne;return!g||!k?null:{dataUrl:g.canvas.toDataURL("image/jpeg",.8),timestamp:((Ne=d.value)==null?void 0:Ne.currentTime)||0,width:V||0,height:x||0}}function de(){var he;p.value=re((he=d.value)==null?void 0:he.duration),s("duration-change",p.value)}function ye(){u.value=!1,f.value=void 0}function Be(){u.value&&(u.value=!1),!h.value&&r.active?Ee():h.value}function fe(){var Ne,Re,He;const he=((Ne=d.value)==null?void 0:Ne.currentTime)||0;s("frame-update",{dataUrl:null,timestamp:he,width:((Re=d.value)==null?void 0:Re.videoWidth)||0,height:((He=d.value)==null?void 0:He.videoHeight)||0})}function ge(){d.value&&(d.value.currentTime=0),s("play-pause")}function Se(he){var Re;const Ne=he.target;if(Ne!=null&&Ne.error)switch(Ne.error.code){case Ne.error.MEDIA_ERR_ABORTED:f.value="Video playback aborted";break;case Ne.error.MEDIA_ERR_NETWORK:f.value="Network error loading video";break;case Ne.error.MEDIA_ERR_DECODE:f.value="Video format not supported";break;case Ne.error.MEDIA_ERR_SRC_NOT_SUPPORTED:f.value=`Video source not supported: ${(Re=Ne.src)==null?void 0:Re.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 Ie(he){d.value&&(d.value.currentTime=Math.max(0,Math.min(he,p.value)))}function pt(){z=window.setInterval(()=>{const he=performance.now(),Ne=he-A;m.value=Math.round(N*1e3/Ne),N=0,A=he},1e3)}function lt(he){if(!Number.isFinite(he)||he<0)return"00:00";const Ne=Math.floor(he/60),Re=Math.floor(he%60);return`${Ne.toString().padStart(2,"0")}:${Re.toString().padStart(2,"0")}`}function Dt(){f.value=void 0,u.value=!0,w=0,ot(),d.value&&d.value.load()}function ot(){if(C&&(C.disconnect(),C=null),P&&(cancelAnimationFrame(P),P=null),g!=null&&g.ticker&&(g.ticker.stop(),g.ticker.remove(R)),g)try{g.destroy(!0,{children:!0,texture:!0})}catch{}c.value&&(c.value.innerHTML=""),M(),g=null,k=null,$=null,D=null,_=null,h.value=!1,E=!1,S=""}function vt(){g&&(E||(E=!0,requestAnimationFrame(()=>{E=!1,bt()})))}function bt(){if(!g||!k||!V||!x||!l.value)return;const he=Math.round(l.value.clientWidth),Ne=Math.round(l.value.clientHeight);if(he<=0||Ne<=0)return;g.renderer.resize(he,Ne);const Re=g.screen.width/V,He=g.screen.height/x;let je=1;switch(r.fitMode){case"cover":je=Math.max(Re,He);break;case"none":je=1;break;case"contain":default:je=Math.min(Re,He);break}k.scale.set(je),k.anchor.set(.5),k.position.set(g.screen.width/2,g.screen.height/2),k.visible=!0,k.alpha=1,g.renderer&&!g.renderer.destroyed&&g.render()}e.watch(()=>r.filters,()=>{h.value&&H()},{deep:!0}),e.watch(()=>r.active,async he=>{if(he&&!g&&d.value&&d.value.readyState>=2){await Ee();return}g&&(he&&(await e.nextTick(),l.value&&l.value.getBoundingClientRect(),k&&_&&D&&$&&(d.value&&d.value.readyState>=2&&xi(d.value,_,D.width,D.height)&&$.update(),bt(),g.renderer&&!g.renderer.destroyed&&g.render())),r.targetFps>=60&&g.ticker&&(he?g.ticker.start():g.ticker.stop()))}),e.watch(O,he=>{he?(u.value=!0,f.value=void 0,e.nextTick(()=>{d.value&&d.value.load()})):(u.value=!1,f.value="No video source provided")},{immediate:!0});async function it(){if(d.value){f.value=void 0,be(d.value)&&(d.value.currentTime=0);try{await d.value.play();return}catch{if(!d.value.muted){d.value.muted=!0;try{await d.value.play();return}catch{}}}f.value="Unable to start preview playback",s("error",f.value)}}e.watch(()=>r.isPlaying,he=>{d.value&&(he?it():d.value.pause())}),e.watch(()=>r.playhead,he=>{d.value&&Math.abs(d.value.currentTime-he)>.5&&Ie(he)}),e.watch(()=>r.fitMode,()=>{bt()}),e.onMounted(()=>{B=!1,e.nextTick(()=>{l.value&&l.value.getBoundingClientRect(),d.value}),window.addEventListener("resize",vt),A=performance.now(),e.nextTick(()=>{d.value&&d.value.readyState>=2&&!h.value?Ee():d.value&&d.value.src&&d.value.readyState===0&&d.value.load()})}),e.onUnmounted(()=>{if(B=!0,P&&(cancelAnimationFrame(P),P=null),window.removeEventListener("resize",vt),C&&(C.disconnect(),C=null),z&&clearInterval(z),g&&g.ticker&&(g.ticker.stop(),g.ticker.remove(R)),g){try{g.destroy(!0,{children:!0,texture:!0})}catch{}g=null}v.forEach(he=>{try{he.destroy()}catch{}}),v=[],k=null,$=null,D=null,_=null,d.value&&(d.value.pause(),d.value.removeAttribute("src"),d.value.load())});async function wt(he){if(!await Et()||!d.value||!_||!D||!$)return null;const Re=d.value,He=Number.isFinite(p.value)&&p.value>0?p.value:Number.isFinite(Re.duration)&&Re.duration>0?Re.duration:0,je=Math.max(0,Math.min(he,He));return await new Promise(ct=>{let dt=!1,Pt=0;const Rt=()=>{dt||(dt=!0,Re.removeEventListener("seeked",Ot),window.clearTimeout(Pt),ct())},Ot=()=>{Rt()},tn=Number.isFinite(Re.currentTime)?Re.currentTime:0;if(Math.abs(tn-je)<.016){requestAnimationFrame(()=>Rt());return}Re.addEventListener("seeked",Ot),Pt=window.setTimeout(()=>Rt(),700),Re.currentTime=je}),xi(Re,_,D.width,D.height)?($.update(),g.render(),g.canvas):null}async function Et(){if(!d.value)return!1;if(!g){if(!(d.value.readyState>=2))return!1;await Ee()}if(!g||!k||!_||!D||!$)return!1;if(r.filters&&r.filters.length>0){const he=k.filters,Ne=Array.isArray(he)?he.length:0,He=JSON.stringify(r.filters)!==S;(Ne===0||Ne!==r.filters.length||He)&&H()}return await e.nextTick(),await new Promise(he=>{requestAnimationFrame(()=>he())}),!0}return n({captureFrameAt:wt,ensureReadyForCapture:Et,duration:p,pixiCanvas:e.computed(()=>g?g.canvas:null),videoElement:e.computed(()=>d.value??null)}),(he,Ne)=>(e.openBlock(),e.createElementBlock("div",{class:"video-preview",ref_key:"containerRef",ref:l},[e.createElementVNode("div",{class:"canvas-container",ref_key:"canvasContainerRef",ref:c},null,512),e.createElementVNode("video",{ref_key:"videoRef",ref:d,src:O.value,onLoadedmetadata:de,onLoadeddata:ye,onCanplay:Be,onTimeupdate:fe,onEnded:ge,onError:Se,style:e.normalizeStyle(G.value),crossorigin:Z.value,preload:"auto",playsinline:"",controls:""},null,44,Gv),e.createElementVNode("div",Jv,[e.createElementVNode("button",{class:"play-button",onClick:Ne[0]||(Ne[0]=Re=>he.$emit("play-pause")),"aria-label":he.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(U.IonIcon),{icon:he.isPlaying?e.unref(Zd):e.unref(Hd)},null,8,["icon"])],8,Kv),e.createElementVNode("div",Yv,[e.createElementVNode("span",qv,e.toDisplayString(lt(he.playhead)),1),Ne[1]||(Ne[1]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",Qv,e.toDisplayString(lt(p.value)),1)]),he.showFps?(e.openBlock(),e.createElementBlock("div",e0,e.toDisplayString(m.value)+" FPS ",1)):e.createCommentVNode("",!0)]),u.value?(e.openBlock(),e.createElementBlock("div",t0,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"}),Ne[2]||(Ne[2]=e.createElementVNode("p",null,"Loading video...",-1))])):e.createCommentVNode("",!0),f.value?(e.openBlock(),e.createElementBlock("div",n0,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ul)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(f.value),1),e.createElementVNode("button",{onClick:Dt},"Retry")])):e.createCommentVNode("",!0)],512))}}),Ss=Me(o0,[["__scopeId","data-v-dd1744f4"]]);var fl=(a,n,t)=>{if(!n.has(a))throw TypeError("Cannot "+t)},X=(a,n,t)=>(fl(a,n,"read from private field"),t?t.call(a):n.get(a)),Ze=(a,n,t)=>{if(n.has(a))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(a):n.set(a,t)},$t=(a,n,t,o)=>(fl(a,n,"write to private field"),n.set(a,t),t),i0=(a,n,t,o)=>({set _(i){$t(a,n,i)},get _(){return X(a,n,o)}}),Ke=(a,n,t)=>(fl(a,n,"access private method"),t),qe=new Uint8Array(8),On=new DataView(qe.buffer),Bt=a=>[(a%256+256)%256],tt=a=>(On.setUint16(0,a,!1),[qe[0],qe[1]]),r0=a=>(On.setInt16(0,a,!1),[qe[0],qe[1]]),Yd=a=>(On.setUint32(0,a,!1),[qe[1],qe[2],qe[3]]),$e=a=>(On.setUint32(0,a,!1),[qe[0],qe[1],qe[2],qe[3]]),s0=a=>(On.setInt32(0,a,!1),[qe[0],qe[1],qe[2],qe[3]]),Ta=a=>(On.setUint32(0,Math.floor(a/2**32),!1),On.setUint32(4,a,!1),[qe[0],qe[1],qe[2],qe[3],qe[4],qe[5],qe[6],qe[7]]),hl=a=>(On.setInt16(0,2**8*a,!1),[qe[0],qe[1]]),An=a=>(On.setInt32(0,2**16*a,!1),[qe[0],qe[1],qe[2],qe[3]]),rs=a=>(On.setInt32(0,2**30*a,!1),[qe[0],qe[1],qe[2],qe[3]]),yn=(a,n=!1)=>{let t=Array(a.length).fill(null).map((o,i)=>a.charCodeAt(i));return n&&t.push(0),t},Qi=a=>a&&a[a.length-1],vl=a=>{let n;for(let t of a)(!n||t.presentationTimestamp>n.presentationTimestamp)&&(n=t);return n},Pn=(a,n,t=!0)=>{let o=a*n;return t?Math.round(o):o},qd=a=>{let n=a*(Math.PI/180),t=Math.cos(n),o=Math.sin(n);return[t,o,0,-o,t,0,0,0,1]},Qd=qd(0),eu=a=>[An(a[0]),An(a[1]),rs(a[2]),An(a[3]),An(a[4]),rs(a[5]),An(a[6]),An(a[7]),rs(a[8])],Ao=a=>!a||typeof a!="object"?a:Array.isArray(a)?a.map(Ao):Object.fromEntries(Object.entries(a).map(([n,t])=>[n,Ao(t)])),oo=a=>a>=0&&a<2**32,Tt=(a,n,t)=>({type:a,contents:n&&new Uint8Array(n.flat(10)),children:t}),yt=(a,n,t,o,i)=>Tt(a,[Bt(n),Yd(t),o??[]],i),l0=a=>{let n=512;return a.fragmented?Tt("ftyp",[yn("iso5"),$e(n),yn("iso5"),yn("iso6"),yn("mp41")]):Tt("ftyp",[yn("isom"),$e(n),yn("isom"),a.holdsAvc?yn("avc1"):[],yn("mp41")])},Cs=a=>({type:"mdat",largeSize:a}),c0=a=>({type:"free",size:a}),Pi=(a,n,t=!1)=>Tt("moov",null,[d0(n,a),...a.map(o=>u0(o,n)),t?z0(a):null]),d0=(a,n)=>{let t=Pn(Math.max(0,...n.filter(s=>s.samples.length>0).map(s=>{const l=vl(s.samples);return l.presentationTimestamp+l.duration})),Ts),o=Math.max(...n.map(s=>s.id))+1,i=!oo(a)||!oo(t),r=i?Ta:$e;return yt("mvhd",+i,0,[r(a),r(a),$e(Ts),r(t),An(1),hl(1),Array(10).fill(0),eu(Qd),Array(24).fill(0),$e(o)])},u0=(a,n)=>Tt("trak",null,[m0(a,n),p0(a,n)]),m0=(a,n)=>{let t=vl(a.samples),o=Pn(t?t.presentationTimestamp+t.duration:0,Ts),i=!oo(n)||!oo(o),r=i?Ta:$e,s;return a.info.type==="video"?s=typeof a.info.rotation=="number"?qd(a.info.rotation):a.info.rotation:s=Qd,yt("tkhd",+i,3,[r(n),r(n),$e(a.id),$e(0),r(o),Array(8).fill(0),tt(0),tt(0),hl(a.info.type==="audio"?1:0),tt(0),eu(s),An(a.info.type==="video"?a.info.width:0),An(a.info.type==="video"?a.info.height:0)])},p0=(a,n)=>Tt("mdia",null,[f0(a,n),h0(a.info.type==="video"?"vide":"soun"),v0(a)]),f0=(a,n)=>{let t=vl(a.samples),o=Pn(t?t.presentationTimestamp+t.duration:0,a.timescale),i=!oo(n)||!oo(o),r=i?Ta:$e;return yt("mdhd",+i,0,[r(n),r(n),$e(a.timescale),r(o),tt(21956),tt(0)])},h0=a=>yt("hdlr",0,0,[yn("mhlr"),yn(a),$e(0),$e(0),$e(0),yn("mp4-muxer-hdlr",!0)]),v0=a=>Tt("minf",null,[a.info.type==="video"?g0():y0(),b0(),_0(a)]),g0=()=>yt("vmhd",0,1,[tt(0),tt(0),tt(0),tt(0)]),y0=()=>yt("smhd",0,0,[tt(0),tt(0)]),b0=()=>Tt("dinf",null,[w0()]),w0=()=>yt("dref",0,0,[$e(1)],[k0()]),k0=()=>yt("url ",0,1),_0=a=>{const n=a.compositionTimeOffsetTable.length>1||a.compositionTimeOffsetTable.some(t=>t.sampleCompositionTimeOffset!==0);return Tt("stbl",null,[E0(a),R0(a),A0(a),L0(a),P0(a),O0(a),n?U0(a):null])},E0=a=>yt("stsd",0,0,[$e(1)],[a.info.type==="video"?x0(q0[a.info.codec],a):F0(eg[a.info.codec],a)]),x0=(a,n)=>Tt(a,[Array(6).fill(0),tt(1),tt(0),tt(0),Array(12).fill(0),tt(n.info.width),tt(n.info.height),$e(4718592),$e(4718592),$e(0),tt(1),Array(32).fill(0),tt(24),r0(65535)],[Q0[n.info.codec](n),n.info.decoderConfig.colorSpace?N0(n):null]),S0={bt709:1,bt470bg:5,smpte170m:6},C0={bt709:1,smpte170m:6,"iec61966-2-1":13},V0={rgb:0,bt709:1,bt470bg:5,smpte170m:6},N0=a=>Tt("colr",[yn("nclx"),tt(S0[a.info.decoderConfig.colorSpace.primaries]),tt(C0[a.info.decoderConfig.colorSpace.transfer]),tt(V0[a.info.decoderConfig.colorSpace.matrix]),Bt((a.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),T0=a=>a.info.decoderConfig&&Tt("avcC",[...new Uint8Array(a.info.decoderConfig.description)]),M0=a=>a.info.decoderConfig&&Tt("hvcC",[...new Uint8Array(a.info.decoderConfig.description)]),B0=a=>{if(!a.info.decoderConfig)return null;let n=a.info.decoderConfig;if(!n.colorSpace)throw new Error("'colorSpace' is required in the decoder config for VP9.");let t=n.codec.split("."),o=Number(t[1]),i=Number(t[2]),l=(Number(t[3])<<4)+(0<<1)+Number(n.colorSpace.fullRange);return yt("vpcC",1,0,[Bt(o),Bt(i),Bt(l),Bt(2),Bt(2),Bt(2),tt(0)])},I0=()=>{let t=(1<<7)+1;return Tt("av1C",[t,0,0,0])},F0=(a,n)=>Tt(a,[Array(6).fill(0),tt(1),tt(0),tt(0),$e(0),tt(n.info.numberOfChannels),tt(16),tt(0),tt(0),An(n.info.sampleRate)],[tg[n.info.codec](n)]),$0=a=>{let n=new Uint8Array(a.info.decoderConfig.description);return yt("esds",0,0,[$e(58753152),Bt(32+n.byteLength),tt(1),Bt(0),$e(75530368),Bt(18+n.byteLength),Bt(64),Bt(21),Yd(0),$e(130071),$e(130071),$e(92307584),Bt(n.byteLength),...n,$e(109084800),Bt(1),Bt(2)])},D0=a=>{var i;let n=3840,t=0;const o=(i=a.info.decoderConfig)==null?void 0:i.description;if(o){if(o.byteLength<18)throw new TypeError("Invalid decoder description provided for Opus; must be at least 18 bytes long.");const r=ArrayBuffer.isView(o)?new DataView(o.buffer,o.byteOffset,o.byteLength):new DataView(o);n=r.getUint16(10,!0),t=r.getInt16(14,!0)}return Tt("dOps",[Bt(0),Bt(a.info.numberOfChannels),tt(n),$e(a.info.sampleRate),hl(t),Bt(0)])},R0=a=>yt("stts",0,0,[$e(a.timeToSampleTable.length),a.timeToSampleTable.map(n=>[$e(n.sampleCount),$e(n.sampleDelta)])]),A0=a=>{if(a.samples.every(t=>t.type==="key"))return null;let n=[...a.samples.entries()].filter(([,t])=>t.type==="key");return yt("stss",0,0,[$e(n.length),n.map(([t])=>$e(t+1))])},L0=a=>yt("stsc",0,0,[$e(a.compactlyCodedChunkTable.length),a.compactlyCodedChunkTable.map(n=>[$e(n.firstChunk),$e(n.samplesPerChunk),$e(1)])]),P0=a=>yt("stsz",0,0,[$e(0),$e(a.samples.length),a.samples.map(n=>$e(n.size))]),O0=a=>a.finalizedChunks.length>0&&Qi(a.finalizedChunks).offset>=2**32?yt("co64",0,0,[$e(a.finalizedChunks.length),a.finalizedChunks.map(n=>Ta(n.offset))]):yt("stco",0,0,[$e(a.finalizedChunks.length),a.finalizedChunks.map(n=>$e(n.offset))]),U0=a=>yt("ctts",0,0,[$e(a.compositionTimeOffsetTable.length),a.compositionTimeOffsetTable.map(n=>[$e(n.sampleCount),$e(n.sampleCompositionTimeOffset)])]),z0=a=>Tt("mvex",null,a.map(j0)),j0=a=>yt("trex",0,0,[$e(a.id),$e(1),$e(0),$e(0),$e(0)]),bc=(a,n)=>Tt("moof",null,[W0(a),...n.map(Z0)]),W0=a=>yt("mfhd",0,0,[$e(a)]),tu=a=>{let n=0,t=0,o=0,i=0,r=a.type==="delta";return t|=+r,r?n|=1:n|=2,n<<24|t<<16|o<<8|i},Z0=a=>Tt("traf",null,[H0(a),X0(a),G0(a)]),H0=a=>{let n=0;n|=8,n|=16,n|=32,n|=131072;let t=a.currentChunk.samples[1]??a.currentChunk.samples[0],o={duration:t.timescaleUnitsToNextSample,size:t.size,flags:tu(t)};return yt("tfhd",0,n,[$e(a.id),$e(o.duration),$e(o.size),$e(o.flags)])},X0=a=>yt("tfdt",1,0,[Ta(Pn(a.currentChunk.startTimestamp,a.timescale))]),G0=a=>{let n=a.currentChunk.samples.map(g=>g.timescaleUnitsToNextSample),t=a.currentChunk.samples.map(g=>g.size),o=a.currentChunk.samples.map(tu),i=a.currentChunk.samples.map(g=>Pn(g.presentationTimestamp-g.decodeTimestamp,a.timescale)),r=new Set(n),s=new Set(t),l=new Set(o),c=new Set(i),d=l.size===2&&o[0]!==o[1],u=r.size>1,f=s.size>1,p=!d&&l.size>1,m=c.size>1||[...c].some(g=>g!==0),h=0;return h|=1,h|=4*+d,h|=256*+u,h|=512*+f,h|=1024*+p,h|=2048*+m,yt("trun",1,h,[$e(a.currentChunk.samples.length),$e(a.currentChunk.offset-a.currentChunk.moofOffset||0),d?$e(o[0]):[],a.currentChunk.samples.map((g,k)=>[u?$e(n[k]):[],f?$e(t[k]):[],p?$e(o[k]):[],m?s0(i[k]):[]])])},J0=a=>Tt("mfra",null,[...a.map(K0),Y0()]),K0=(a,n)=>yt("tfra",1,0,[$e(a.id),$e(63),$e(a.finalizedChunks.length),a.finalizedChunks.map(o=>[Ta(Pn(o.startTimestamp,a.timescale)),Ta(o.moofOffset),$e(n+1),$e(1),$e(1)])]),Y0=()=>yt("mfro",0,0,[$e(0)]),q0={avc:"avc1",hevc:"hvc1",vp9:"vp09",av1:"av01"},Q0={avc:T0,hevc:M0,vp9:B0,av1:I0},eg={aac:"mp4a",opus:"Opus"},tg={aac:$0,opus:D0},fr=class{},gl=class extends fr{constructor(){super(...arguments),this.buffer=null}},nu=class extends fr{constructor(a){if(super(),this.options=a,typeof a!="object")throw new TypeError("StreamTarget requires an options object to be passed to its constructor.");if(a.onData){if(typeof a.onData!="function")throw new TypeError("options.onData, when provided, must be a function.");if(a.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(a.chunked!==void 0&&typeof a.chunked!="boolean")throw new TypeError("options.chunked, when provided, must be a boolean.");if(a.chunkSize!==void 0&&(!Number.isInteger(a.chunkSize)||a.chunkSize<1024))throw new TypeError("options.chunkSize, when provided, must be an integer and not smaller than 1024.")}},ng=class extends fr{constructor(a,n){if(super(),this.stream=a,this.options=n,!(a instanceof FileSystemWritableFileStream))throw new TypeError("FileSystemWritableFileStreamTarget requires a FileSystemWritableFileStream instance.");if(n!==void 0&&typeof n!="object")throw new TypeError("FileSystemWritableFileStreamTarget's options, when provided, must be an object.");if(n&&n.chunkSize!==void 0&&(!Number.isInteger(n.chunkSize)||n.chunkSize<=0))throw new TypeError("options.chunkSize, when provided, must be a positive integer")}},ya,Ya,au=class{constructor(){this.pos=0,Ze(this,ya,new Uint8Array(8)),Ze(this,Ya,new DataView(X(this,ya).buffer)),this.offsets=new WeakMap}seek(a){this.pos=a}writeU32(a){X(this,Ya).setUint32(0,a,!1),this.write(X(this,ya).subarray(0,4))}writeU64(a){X(this,Ya).setUint32(0,Math.floor(a/2**32),!1),X(this,Ya).setUint32(4,a,!1),this.write(X(this,ya).subarray(0,8))}writeAscii(a){for(let n=0;n<a.length;n++)X(this,Ya).setUint8(n%8,a.charCodeAt(n)),n%8===7&&this.write(X(this,ya));a.length%8!==0&&this.write(X(this,ya).subarray(0,a.length%8))}writeBox(a){if(this.offsets.set(a,this.pos),a.contents&&!a.children)this.writeBoxHeader(a,a.size??a.contents.byteLength+8),this.write(a.contents);else{let n=this.pos;if(this.writeBoxHeader(a,0),a.contents&&this.write(a.contents),a.children)for(let i of a.children)i&&this.writeBox(i);let t=this.pos,o=a.size??t-n;this.seek(n),this.writeBoxHeader(a,o),this.seek(t)}}writeBoxHeader(a,n){this.writeU32(a.largeSize?1:n),this.writeAscii(a.type),a.largeSize&&this.writeU64(n)}measureBoxHeader(a){return 8+(a.largeSize?8:0)}patchBox(a){let n=this.pos;this.seek(this.offsets.get(a)),this.writeBox(a),this.seek(n)}measureBox(a){if(a.contents&&!a.children)return this.measureBoxHeader(a)+a.contents.byteLength;{let n=this.measureBoxHeader(a);if(a.contents&&(n+=a.contents.byteLength),a.children)for(let t of a.children)t&&(n+=this.measureBox(t));return n}}};ya=new WeakMap;Ya=new WeakMap;var Oi,Ca,Ho,Fo,Ui,Vs,ag=class extends au{constructor(a){super(),Ze(this,Ui),Ze(this,Oi,void 0),Ze(this,Ca,new ArrayBuffer(2**16)),Ze(this,Ho,new Uint8Array(X(this,Ca))),Ze(this,Fo,0),$t(this,Oi,a)}write(a){Ke(this,Ui,Vs).call(this,this.pos+a.byteLength),X(this,Ho).set(a,this.pos),this.pos+=a.byteLength,$t(this,Fo,Math.max(X(this,Fo),this.pos))}finalize(){Ke(this,Ui,Vs).call(this,this.pos),X(this,Oi).buffer=X(this,Ca).slice(0,Math.max(X(this,Fo),this.pos))}};Oi=new WeakMap;Ca=new WeakMap;Ho=new WeakMap;Fo=new WeakMap;Ui=new WeakSet;Vs=function(a){let n=X(this,Ca).byteLength;for(;n<a;)n*=2;if(n===X(this,Ca).byteLength)return;let t=new ArrayBuffer(n),o=new Uint8Array(t);o.set(X(this,Ho),0),$t(this,Ca,t),$t(this,Ho,o)};var og=2**24,ig=2,Lo,ba,$o,Xn,un,er,Ns,yl,ou,bl,iu,Po,tr,wl=class extends au{constructor(a){var n,t;super(),Ze(this,er),Ze(this,yl),Ze(this,bl),Ze(this,Po),Ze(this,Lo,void 0),Ze(this,ba,[]),Ze(this,$o,void 0),Ze(this,Xn,void 0),Ze(this,un,[]),$t(this,Lo,a),$t(this,$o,((n=a.options)==null?void 0:n.chunked)??!1),$t(this,Xn,((t=a.options)==null?void 0:t.chunkSize)??og)}write(a){X(this,ba).push({data:a.slice(),start:this.pos}),this.pos+=a.byteLength}flush(){var t,o;if(X(this,ba).length===0)return;let a=[],n=[...X(this,ba)].sort((i,r)=>i.start-r.start);a.push({start:n[0].start,size:n[0].data.byteLength});for(let i=1;i<n.length;i++){let r=a[a.length-1],s=n[i];s.start<=r.start+r.size?r.size=Math.max(r.size,s.start+s.data.byteLength-r.start):a.push({start:s.start,size:s.data.byteLength})}for(let i of a){i.data=new Uint8Array(i.size);for(let r of X(this,ba))i.start<=r.start&&r.start<i.start+i.size&&i.data.set(r.data,r.start-i.start);X(this,$o)?(Ke(this,er,Ns).call(this,i.data,i.start),Ke(this,Po,tr).call(this)):(o=(t=X(this,Lo).options).onData)==null||o.call(t,i.data,i.start)}X(this,ba).length=0}finalize(){X(this,$o)&&Ke(this,Po,tr).call(this,!0)}};Lo=new WeakMap;ba=new WeakMap;$o=new WeakMap;Xn=new WeakMap;un=new WeakMap;er=new WeakSet;Ns=function(a,n){let t=X(this,un).findIndex(l=>l.start<=n&&n<l.start+X(this,Xn));t===-1&&(t=Ke(this,bl,iu).call(this,n));let o=X(this,un)[t],i=n-o.start,r=a.subarray(0,Math.min(X(this,Xn)-i,a.byteLength));o.data.set(r,i);let s={start:i,end:i+r.byteLength};if(Ke(this,yl,ou).call(this,o,s),o.written[0].start===0&&o.written[0].end===X(this,Xn)&&(o.shouldFlush=!0),X(this,un).length>ig){for(let l=0;l<X(this,un).length-1;l++)X(this,un)[l].shouldFlush=!0;Ke(this,Po,tr).call(this)}r.byteLength<a.byteLength&&Ke(this,er,Ns).call(this,a.subarray(r.byteLength),n+r.byteLength)};yl=new WeakSet;ou=function(a,n){let t=0,o=a.written.length-1,i=-1;for(;t<=o;){let r=Math.floor(t+(o-t+1)/2);a.written[r].start<=n.start?(t=r+1,i=r):o=r-1}for(a.written.splice(i+1,0,n),(i===-1||a.written[i].end<n.start)&&i++;i<a.written.length-1&&a.written[i].end>=a.written[i+1].start;)a.written[i].end=Math.max(a.written[i].end,a.written[i+1].end),a.written.splice(i+1,1)};bl=new WeakSet;iu=function(a){let t={start:Math.floor(a/X(this,Xn))*X(this,Xn),data:new Uint8Array(X(this,Xn)),written:[],shouldFlush:!1};return X(this,un).push(t),X(this,un).sort((o,i)=>o.start-i.start),X(this,un).indexOf(t)};Po=new WeakSet;tr=function(a=!1){var n,t;for(let o=0;o<X(this,un).length;o++){let i=X(this,un)[o];if(!(!i.shouldFlush&&!a)){for(let r of i.written)(t=(n=X(this,Lo).options).onData)==null||t.call(n,i.data.subarray(r.start,r.end),i.start+r.start);X(this,un).splice(o--,1)}}};var rg=class extends wl{constructor(a){var n;super(new nu({onData:(t,o)=>a.stream.write({type:"write",data:t,position:o}),chunked:!0,chunkSize:(n=a.options)==null?void 0:n.chunkSize}))}},Ts=1e3,sg=["avc","hevc","vp9","av1"],lg=["aac","opus"],cg=2082844800,dg=["strict","offset","cross-track-offset"],Pe,ze,nr,cn,Lt,Ft,qa,Qa,kl,wa,ka,Oo,Ms,ru,Bs,su,_l,lu,Is,cu,El,du,zi,Fs,Rn,Hn,xl,uu,Uo,ar,or,Sl,io,Qo,ji,$s,mu=class{constructor(a){if(Ze(this,Ms),Ze(this,Bs),Ze(this,_l),Ze(this,Is),Ze(this,El),Ze(this,zi),Ze(this,Rn),Ze(this,xl),Ze(this,Uo),Ze(this,or),Ze(this,io),Ze(this,ji),Ze(this,Pe,void 0),Ze(this,ze,void 0),Ze(this,nr,void 0),Ze(this,cn,void 0),Ze(this,Lt,null),Ze(this,Ft,null),Ze(this,qa,Math.floor(Date.now()/1e3)+cg),Ze(this,Qa,[]),Ze(this,kl,1),Ze(this,wa,[]),Ze(this,ka,[]),Ze(this,Oo,!1),Ke(this,Ms,ru).call(this,a),a.video=Ao(a.video),a.audio=Ao(a.audio),a.fastStart=Ao(a.fastStart),this.target=a.target,$t(this,Pe,{firstTimestampBehavior:"strict",...a}),a.target instanceof gl)$t(this,ze,new ag(a.target));else if(a.target instanceof nu)$t(this,ze,new wl(a.target));else if(a.target instanceof ng)$t(this,ze,new rg(a.target));else throw new Error(`Invalid target: ${a.target}`);Ke(this,Is,cu).call(this),Ke(this,Bs,su).call(this)}addVideoChunk(a,n,t,o){if(!(a instanceof EncodedVideoChunk))throw new TypeError("addVideoChunk's first argument (sample) must be of type EncodedVideoChunk.");if(n&&typeof n!="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(o!==void 0&&!Number.isFinite(o))throw new TypeError("addVideoChunk's fourth argument (compositionTimeOffset), when provided, must be a real number.");let i=new Uint8Array(a.byteLength);a.copyTo(i),this.addVideoChunkRaw(i,a.type,t??a.timestamp,a.duration,n,o)}addVideoChunkRaw(a,n,t,o,i,r){if(!(a instanceof Uint8Array))throw new TypeError("addVideoChunkRaw's first argument (data) must be an instance of Uint8Array.");if(n!=="key"&&n!=="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(o)||o<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(Ke(this,ji,$s).call(this),!X(this,Pe).video)throw new Error("No video track declared.");if(typeof X(this,Pe).fastStart=="object"&&X(this,Lt).samples.length===X(this,Pe).fastStart.expectedVideoChunks)throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${X(this,Pe).fastStart.expectedVideoChunks}).`);let s=Ke(this,zi,Fs).call(this,X(this,Lt),a,n,t,o,i,r);if(X(this,Pe).fastStart==="fragmented"&&X(this,Ft)){for(;X(this,ka).length>0&&X(this,ka)[0].decodeTimestamp<=s.decodeTimestamp;){let l=X(this,ka).shift();Ke(this,Rn,Hn).call(this,X(this,Ft),l)}s.decodeTimestamp<=X(this,Ft).lastDecodeTimestamp?Ke(this,Rn,Hn).call(this,X(this,Lt),s):X(this,wa).push(s)}else Ke(this,Rn,Hn).call(this,X(this,Lt),s)}addAudioChunk(a,n,t){if(!(a instanceof EncodedAudioChunk))throw new TypeError("addAudioChunk's first argument (sample) must be of type EncodedAudioChunk.");if(n&&typeof n!="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 o=new Uint8Array(a.byteLength);a.copyTo(o),this.addAudioChunkRaw(o,a.type,t??a.timestamp,a.duration,n)}addAudioChunkRaw(a,n,t,o,i){if(!(a instanceof Uint8Array))throw new TypeError("addAudioChunkRaw's first argument (data) must be an instance of Uint8Array.");if(n!=="key"&&n!=="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(o)||o<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(Ke(this,ji,$s).call(this),!X(this,Pe).audio)throw new Error("No audio track declared.");if(typeof X(this,Pe).fastStart=="object"&&X(this,Ft).samples.length===X(this,Pe).fastStart.expectedAudioChunks)throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${X(this,Pe).fastStart.expectedAudioChunks}).`);let r=Ke(this,zi,Fs).call(this,X(this,Ft),a,n,t,o,i);if(X(this,Pe).fastStart==="fragmented"&&X(this,Lt)){for(;X(this,wa).length>0&&X(this,wa)[0].decodeTimestamp<=r.decodeTimestamp;){let s=X(this,wa).shift();Ke(this,Rn,Hn).call(this,X(this,Lt),s)}r.decodeTimestamp<=X(this,Lt).lastDecodeTimestamp?Ke(this,Rn,Hn).call(this,X(this,Ft),r):X(this,ka).push(r)}else Ke(this,Rn,Hn).call(this,X(this,Ft),r)}finalize(){if(X(this,Oo))throw new Error("Cannot finalize a muxer more than once.");if(X(this,Pe).fastStart==="fragmented"){for(let n of X(this,wa))Ke(this,Rn,Hn).call(this,X(this,Lt),n);for(let n of X(this,ka))Ke(this,Rn,Hn).call(this,X(this,Ft),n);Ke(this,or,Sl).call(this,!1)}else X(this,Lt)&&Ke(this,Uo,ar).call(this,X(this,Lt)),X(this,Ft)&&Ke(this,Uo,ar).call(this,X(this,Ft));let a=[X(this,Lt),X(this,Ft)].filter(Boolean);if(X(this,Pe).fastStart==="in-memory"){let n;for(let o=0;o<2;o++){let i=Pi(a,X(this,qa)),r=X(this,ze).measureBox(i);n=X(this,ze).measureBox(X(this,cn));let s=X(this,ze).pos+r+n;for(let l of X(this,Qa)){l.offset=s;for(let{data:c}of l.samples)s+=c.byteLength,n+=c.byteLength}if(s<2**32)break;n>=2**32&&(X(this,cn).largeSize=!0)}let t=Pi(a,X(this,qa));X(this,ze).writeBox(t),X(this,cn).size=n,X(this,ze).writeBox(X(this,cn));for(let o of X(this,Qa))for(let i of o.samples)X(this,ze).write(i.data),i.data=null}else if(X(this,Pe).fastStart==="fragmented"){let n=X(this,ze).pos,t=J0(a);X(this,ze).writeBox(t);let o=X(this,ze).pos-n;X(this,ze).seek(X(this,ze).pos-4),X(this,ze).writeU32(o)}else{let n=X(this,ze).offsets.get(X(this,cn)),t=X(this,ze).pos-n;X(this,cn).size=t,X(this,cn).largeSize=t>=2**32,X(this,ze).patchBox(X(this,cn));let o=Pi(a,X(this,qa));if(typeof X(this,Pe).fastStart=="object"){X(this,ze).seek(X(this,nr)),X(this,ze).writeBox(o);let i=n-X(this,ze).pos;X(this,ze).writeBox(c0(i))}else X(this,ze).writeBox(o)}Ke(this,io,Qo).call(this),X(this,ze).finalize(),$t(this,Oo,!0)}};Pe=new WeakMap;ze=new WeakMap;nr=new WeakMap;cn=new WeakMap;Lt=new WeakMap;Ft=new WeakMap;qa=new WeakMap;Qa=new WeakMap;kl=new WeakMap;wa=new WeakMap;ka=new WeakMap;Oo=new WeakMap;Ms=new WeakSet;ru=function(a){if(typeof a!="object")throw new TypeError("The muxer requires an options object to be passed to its constructor.");if(!(a.target instanceof fr))throw new TypeError("The target must be provided and an instance of Target.");if(a.video){if(!sg.includes(a.video.codec))throw new TypeError(`Unsupported video codec: ${a.video.codec}`);if(!Number.isInteger(a.video.width)||a.video.width<=0)throw new TypeError(`Invalid video width: ${a.video.width}. Must be a positive integer.`);if(!Number.isInteger(a.video.height)||a.video.height<=0)throw new TypeError(`Invalid video height: ${a.video.height}. Must be a positive integer.`);const n=a.video.rotation;if(typeof n=="number"&&![0,90,180,270].includes(n))throw new TypeError(`Invalid video rotation: ${n}. Has to be 0, 90, 180 or 270.`);if(Array.isArray(n)&&(n.length!==9||n.some(t=>typeof t!="number")))throw new TypeError(`Invalid video transformation matrix: ${n.join()}`);if(a.video.frameRate!==void 0&&(!Number.isInteger(a.video.frameRate)||a.video.frameRate<=0))throw new TypeError(`Invalid video frame rate: ${a.video.frameRate}. Must be a positive integer.`)}if(a.audio){if(!lg.includes(a.audio.codec))throw new TypeError(`Unsupported audio codec: ${a.audio.codec}`);if(!Number.isInteger(a.audio.numberOfChannels)||a.audio.numberOfChannels<=0)throw new TypeError(`Invalid number of audio channels: ${a.audio.numberOfChannels}. Must be a positive integer.`);if(!Number.isInteger(a.audio.sampleRate)||a.audio.sampleRate<=0)throw new TypeError(`Invalid audio sample rate: ${a.audio.sampleRate}. Must be a positive integer.`)}if(a.firstTimestampBehavior&&!dg.includes(a.firstTimestampBehavior))throw new TypeError(`Invalid first timestamp behavior: ${a.firstTimestampBehavior}`);if(typeof a.fastStart=="object"){if(a.video){if(a.fastStart.expectedVideoChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedVideoChunks'.");if(!Number.isInteger(a.fastStart.expectedVideoChunks)||a.fastStart.expectedVideoChunks<0)throw new TypeError("'expectedVideoChunks' must be a non-negative integer.")}if(a.audio){if(a.fastStart.expectedAudioChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedAudioChunks'.");if(!Number.isInteger(a.fastStart.expectedAudioChunks)||a.fastStart.expectedAudioChunks<0)throw new TypeError("'expectedAudioChunks' must be a non-negative integer.")}}else if(![!1,"in-memory","fragmented"].includes(a.fastStart))throw new TypeError("'fastStart' option must be false, 'in-memory', 'fragmented' or an object.");if(a.minFragmentDuration!==void 0&&(!Number.isFinite(a.minFragmentDuration)||a.minFragmentDuration<0))throw new TypeError("'minFragmentDuration' must be a non-negative number.")};Bs=new WeakSet;su=function(){var a;if(X(this,ze).writeBox(l0({holdsAvc:((a=X(this,Pe).video)==null?void 0:a.codec)==="avc",fragmented:X(this,Pe).fastStart==="fragmented"})),$t(this,nr,X(this,ze).pos),X(this,Pe).fastStart==="in-memory")$t(this,cn,Cs(!1));else if(X(this,Pe).fastStart!=="fragmented"){if(typeof X(this,Pe).fastStart=="object"){let n=Ke(this,_l,lu).call(this);X(this,ze).seek(X(this,ze).pos+n)}$t(this,cn,Cs(!0)),X(this,ze).writeBox(X(this,cn))}Ke(this,io,Qo).call(this)};_l=new WeakSet;lu=function(){if(typeof X(this,Pe).fastStart!="object")return;let a=0,n=[X(this,Pe).fastStart.expectedVideoChunks,X(this,Pe).fastStart.expectedAudioChunks];for(let t of n)t&&(a+=8*Math.ceil(2/3*t),a+=4*t,a+=12*Math.ceil(2/3*t),a+=4*t,a+=8*t);return a+=4096,a};Is=new WeakSet;cu=function(){if(X(this,Pe).video&&$t(this,Lt,{id:1,info:{type:"video",codec:X(this,Pe).video.codec,width:X(this,Pe).video.width,height:X(this,Pe).video.height,rotation:X(this,Pe).video.rotation??0,decoderConfig:null},timescale:X(this,Pe).video.frameRate??57600,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),X(this,Pe).audio&&($t(this,Ft,{id:X(this,Pe).video?2:1,info:{type:"audio",codec:X(this,Pe).audio.codec,numberOfChannels:X(this,Pe).audio.numberOfChannels,sampleRate:X(this,Pe).audio.sampleRate,decoderConfig:null},timescale:X(this,Pe).audio.sampleRate,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),X(this,Pe).audio.codec==="aac")){let a=Ke(this,El,du).call(this,2,X(this,Pe).audio.sampleRate,X(this,Pe).audio.numberOfChannels);X(this,Ft).info.decoderConfig={codec:X(this,Pe).audio.codec,description:a,numberOfChannels:X(this,Pe).audio.numberOfChannels,sampleRate:X(this,Pe).audio.sampleRate}}};El=new WeakSet;du=function(a,n,t){let i=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350].indexOf(n),r=t,s="";s+=a.toString(2).padStart(5,"0"),s+=i.toString(2).padStart(4,"0"),i===15&&(s+=n.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 c=new Uint8Array(s.length/8);for(let d=0;d<s.length;d+=8)c[d/8]=parseInt(s.slice(d,d+8),2);return c};zi=new WeakSet;Fs=function(a,n,t,o,i,r,s){let l=o/1e6,c=(o-(s??0))/1e6,d=i/1e6,u=Ke(this,xl,uu).call(this,l,c,a);return l=u.presentationTimestamp,c=u.decodeTimestamp,r!=null&&r.decoderConfig&&(a.info.decoderConfig===null?a.info.decoderConfig=r.decoderConfig:Object.assign(a.info.decoderConfig,r.decoderConfig)),{presentationTimestamp:l,decodeTimestamp:c,duration:d,data:n,size:n.byteLength,type:t,timescaleUnitsToNextSample:Pn(d,a.timescale)}};Rn=new WeakSet;Hn=function(a,n){X(this,Pe).fastStart!=="fragmented"&&a.samples.push(n);const t=Pn(n.presentationTimestamp-n.decodeTimestamp,a.timescale);if(a.lastTimescaleUnits!==null){let i=Pn(n.decodeTimestamp,a.timescale,!1),r=Math.round(i-a.lastTimescaleUnits);if(a.lastTimescaleUnits+=r,a.lastSample.timescaleUnitsToNextSample=r,X(this,Pe).fastStart!=="fragmented"){let s=Qi(a.timeToSampleTable);s.sampleCount===1?(s.sampleDelta=r,s.sampleCount++):s.sampleDelta===r?s.sampleCount++:(s.sampleCount--,a.timeToSampleTable.push({sampleCount:2,sampleDelta:r}));const l=Qi(a.compositionTimeOffsetTable);l.sampleCompositionTimeOffset===t?l.sampleCount++:a.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t})}}else a.lastTimescaleUnits=0,X(this,Pe).fastStart!=="fragmented"&&(a.timeToSampleTable.push({sampleCount:1,sampleDelta:Pn(n.duration,a.timescale)}),a.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t}));a.lastSample=n;let o=!1;if(!a.currentChunk)o=!0;else{let i=n.presentationTimestamp-a.currentChunk.startTimestamp;if(X(this,Pe).fastStart==="fragmented"){let r=X(this,Lt)??X(this,Ft);const s=X(this,Pe).minFragmentDuration??1;a===r&&n.type==="key"&&i>=s&&(o=!0,Ke(this,or,Sl).call(this))}else o=i>=.5}o&&(a.currentChunk&&Ke(this,Uo,ar).call(this,a),a.currentChunk={startTimestamp:n.presentationTimestamp,samples:[]}),a.currentChunk.samples.push(n)};xl=new WeakSet;uu=function(a,n,t){var s,l;const o=X(this,Pe).firstTimestampBehavior==="strict",i=t.lastDecodeTimestamp===-1;if(o&&i&&n!==0)throw new Error(`The first chunk for your media track must have a timestamp of 0 (received DTS=${n}).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(X(this,Pe).firstTimestampBehavior==="offset"||X(this,Pe).firstTimestampBehavior==="cross-track-offset"){t.firstDecodeTimestamp===void 0&&(t.firstDecodeTimestamp=n);let c;X(this,Pe).firstTimestampBehavior==="offset"?c=t.firstDecodeTimestamp:c=Math.min(((s=X(this,Lt))==null?void 0:s.firstDecodeTimestamp)??1/0,((l=X(this,Ft))==null?void 0:l.firstDecodeTimestamp)??1/0),n-=c,a-=c}if(n<t.lastDecodeTimestamp)throw new Error(`Timestamps must be monotonically increasing (DTS went from ${t.lastDecodeTimestamp*1e6} to ${n*1e6}).`);return t.lastDecodeTimestamp=n,{presentationTimestamp:a,decodeTimestamp:n}};Uo=new WeakSet;ar=function(a){if(X(this,Pe).fastStart==="fragmented")throw new Error("Can't finalize individual chunks if 'fastStart' is set to 'fragmented'.");if(a.currentChunk){if(a.finalizedChunks.push(a.currentChunk),X(this,Qa).push(a.currentChunk),(a.compactlyCodedChunkTable.length===0||Qi(a.compactlyCodedChunkTable).samplesPerChunk!==a.currentChunk.samples.length)&&a.compactlyCodedChunkTable.push({firstChunk:a.finalizedChunks.length,samplesPerChunk:a.currentChunk.samples.length}),X(this,Pe).fastStart==="in-memory"){a.currentChunk.offset=0;return}a.currentChunk.offset=X(this,ze).pos;for(let n of a.currentChunk.samples)X(this,ze).write(n.data),n.data=null;Ke(this,io,Qo).call(this)}};or=new WeakSet;Sl=function(a=!0){if(X(this,Pe).fastStart!=="fragmented")throw new Error("Can't finalize a fragment unless 'fastStart' is set to 'fragmented'.");let n=[X(this,Lt),X(this,Ft)].filter(l=>l&&l.currentChunk);if(n.length===0)return;let t=i0(this,kl)._++;if(t===1){let l=Pi(n,X(this,qa),!0);X(this,ze).writeBox(l)}let o=X(this,ze).pos,i=bc(t,n);X(this,ze).writeBox(i);{let l=Cs(!1),c=0;for(let u of n)for(let f of u.currentChunk.samples)c+=f.size;let d=X(this,ze).measureBox(l)+c;d>=2**32&&(l.largeSize=!0,d=X(this,ze).measureBox(l)+c),l.size=d,X(this,ze).writeBox(l)}for(let l of n){l.currentChunk.offset=X(this,ze).pos,l.currentChunk.moofOffset=o;for(let c of l.currentChunk.samples)X(this,ze).write(c.data),c.data=null}let r=X(this,ze).pos;X(this,ze).seek(X(this,ze).offsets.get(i));let s=bc(t,n);X(this,ze).writeBox(s),X(this,ze).seek(r);for(let l of n)l.finalizedChunks.push(l.currentChunk),X(this,Qa).push(l.currentChunk),l.currentChunk=null;a&&Ke(this,io,Qo).call(this)};io=new WeakSet;Qo=function(){X(this,ze)instanceof wl&&X(this,ze).flush()};ji=new WeakSet;$s=function(){if(X(this,Oo))throw new Error("Cannot add new video or audio chunks after the file has been finalized.")};const Xo=30;class ro extends Error{constructor({message:t="",code:o=""},...i){super(t,...i);K(this,"message");K(this,"code");this.code=o,this.message=t}}class Gn extends ro{}class Nt extends ro{}class ir extends ro{}class wc extends ro{}function ug(a,n=Xo){if(n<1)throw new Nt({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(a*n)}function eo(a,n=Xo){if(n<1)throw new Nt({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(a/n*1e3)}class Fe{constructor(n=0){K(this,"time");this.time=Math.round(n)}get millis(){return this.time}set millis(n){this.time=Math.round(n)}get frames(){return ug(this.millis/1e3)}set frames(n){this.millis=eo(n)}get seconds(){return this.millis/1e3}set seconds(n){this.millis=n*1e3}addMillis(n){return this.millis=this.millis+n,this}addFrames(n){const t=eo(n);return this.millis=this.millis+t,this}add(n){return new Fe(n.millis+this.millis)}subtract(n){return new Fe(this.millis-n.millis)}static fromSeconds(n){const t=new Fe;return t.millis=n*1e3,t}static fromFrames(n,t){const o=new Fe;return o.millis=eo(n,t),o}copy(){return new Fe(this.millis)}toJSON(){return this.millis}static fromJSON(n){return new Fe(n)}}function kc(a,n){return[a.slice(0,n),a.slice(n)].filter(t=>t.length>0)}function Wi(a,n){return n?Math.floor(Math.random()*(n-a+1)+a):a}function mg(a,n,t){t<0&&(t=0);const o=a[n];a.splice(n,1),a.splice(t,0,o)}function _c(a){return typeof a!="function"?!1:/^class\s/.test(Function.prototype.toString.call(a))}function pg(a){const n=a.numberOfChannels,t=a.length,o=new Int16Array(t*n);for(let i=0;i<t;i++)for(let r=0;r<n;r++){let s=a.getChannelData(r)[i]*32767;s>32767&&(s=32767),s<-32767&&(s=-32767),o[i*n+r]=s}return o}function fg(a,n=44100,t=2){if(a.sampleRate==n&&a.numberOfChannels==t)return a;const o=Math.floor(a.duration*n),i=new OfflineAudioContext(t,1,n).createBuffer(t,o,n);for(let r=0;r<a.numberOfChannels;r++){const s=a.getChannelData(r),l=i.getChannelData(r),c=a.sampleRate/n;for(let d=0;d<l.length;d++){const u=d*c,f=Math.floor(u),p=Math.ceil(u);if(p>=s.length)l[d]=s[f];else{const m=u-f;l[d]=s[f]*(1-m)+s[p]*m}}}return i}async function hg(a){const{fps:n,height:t,width:o,bitrate:i}=a,r=["avc1.640034","avc1.4d0034","avc1.640028","avc1.640C32","avc1.64001f","avc1.42001E"],s=["prefer-hardware","prefer-software"],l=[];for(const d of r)for(const u of s)l.push({codec:d,hardwareAcceleration:u,width:o,height:t,bitrate:i,framerate:n});const c=[];if(!("VideoEncoder"in window))return c;for(const d of l){const u=await VideoEncoder.isConfigSupported(d);u.supported&&c.push(u.config??d)}return c.sort(vg)}function vg(a,n){const t=a.hardwareAcceleration??"",o=n.hardwareAcceleration??"";return t<o?-1:t>o?1:0}async function gg(a,n="untitled"){const t=document.createElement("a");if(document.head.appendChild(t),t.download=n,typeof a=="string"&&a.startsWith("data:image/svg+xml;base64,")){const o=a.split(",")[1],i=atob(o),r=new Array(i.length);for(let c=0;c<i.length;c++)r[c]=i.charCodeAt(c);const s=new Uint8Array(r),l=new Blob([s],{type:"image/svg+xml"});t.href=URL.createObjectURL(l),t.download=n.split(".")[0]+".svg"}else typeof a=="string"?t.href=a:t.href=URL.createObjectURL(a);t.click(),t.remove()}function Ec(a){return`${a.hours.toString().padStart(2,"0")}:${a.minutes.toString().padStart(2,"0")}:${a.seconds.toString().padStart(2,"0")},`+a.milliseconds.toString().padStart(3,"0")}function xc(a){const n=new Date(1970,0,1);return n.setSeconds(a),n.setMilliseconds(Math.round(a%1*1e3)),{hours:n.getHours(),minutes:n.getMinutes(),seconds:n.getSeconds(),milliseconds:n.getMilliseconds()}}class Si{constructor(n){K(this,"words",[]);n&&(this.words=n)}get duration(){return this.stop.subtract(this.start)}get text(){return this.words.map(({text:n})=>n).join(" ")}get start(){var n;return((n=this.words.at(0))==null?void 0:n.start)??new Fe}get stop(){var n;return((n=this.words.at(-1))==null?void 0:n.stop)??new Fe}}var Ds=(a=>(a.en="en",a.de="de",a))(Ds||{});class Sc{constructor(n,t,o,i){K(this,"id",crypto.randomUUID());K(this,"text");K(this,"start");K(this,"stop");K(this,"confidence");this.text=n,this.start=new Fe(t),this.stop=new Fe(o),this.confidence=i}get duration(){return this.stop.subtract(this.start)}}class Ea{constructor(n=[],t=Ds.en){K(this,"id",crypto.randomUUID());K(this,"language",Ds.en);K(this,"groups",[]);this.groups=n,this.language=t}get text(){return this.groups.map(({text:n})=>n).join(" ")}get words(){return this.groups.flatMap(({words:n})=>n)}*iter({count:n,duration:t,length:o}){for(const i of this.groups){let r;for(const[s,l]of i.words.entries())r&&(n&&r.words.length>=Wi(...n)?(yield r,r=void 0):t&&(r==null?void 0:r.duration.seconds)>=Wi(...t)?(yield r,r=void 0):o&&r.text.length>=Wi(...o)&&(yield r,r=void 0)),r?r.words.push(l):r=new Si([l]),s==i.words.length-1&&(yield r)}}optimize(){const n=this.groups.flatMap(t=>t.words);for(let t=0;t<n.length-1;t++){const o=n[t],i=n[t+1];i.start.millis-o.stop.millis<0?i.start.millis=o.stop.millis+1:o.stop.millis=i.start.millis-1}return this}toSRT(n={}){let t=1,o="";for(const i of this.iter(n)){const r=xc(i.start.seconds),s=xc(i.stop.seconds);o+=`${t}
|
|
22
|
-
`+Ec(r)+" --> "+Ec(s)+`
|
|
23
|
-
${i.text}
|
|
24
|
-
|
|
25
|
-
`,t+=1}return{text:o,blob:new Blob([o],{type:"text/plain;charset=utf8"})}}toJSON(){return this.groups.map(n=>n.words.map(t=>({token:t.text,start:t.start.millis,stop:t.stop.millis})))}slice(n,t=!0){let o=0;const i=[];for(const r of this.groups)for(const s of r.words)if(i.length==0&&t&&(o=s.start.millis),i.push(new Sc(s.text,s.start.millis-o,s.stop.millis-o)),i.length==n)return new Ea([new Si(i)]);return new Ea([new Si(i)])}copy(){return Ea.fromJSON(this.toJSON())}static fromJSON(n){const t=new Ea;for(const o of n){const i=new Si;for(const r of o)i.words.push(new Sc(r.token,r.start,r.stop));t.groups.push(i)}return t}static async from(n,t){const o=await fetch(n,t);if(!o.ok)throw new Gn({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});return Ea.fromJSON(await o.json())}}function Zi(a,n,t){return a+(n-a)*t}function yg(a,n,t){const o=Number.parseInt(a.slice(1),16),i=Number.parseInt(n.slice(1),16),r=o>>16&255,s=o>>8&255,l=o&255,c=i>>16&255,d=i>>8&255,u=i&255,f=Math.round(Zi(r,c,t)),p=Math.round(Zi(s,d,t)),m=Math.round(Zi(l,u,t));return`#${((1<<24)+(f<<16)+(p<<8)+m).toString(16).slice(1)}`}const bg={linear:a=>a,easeIn:a=>a*a,easeOut:a=>a*(2-a),easeInOut:a=>a<.5?2*a*a:-1+(4-2*a)*a};class Le{constructor(n,t,o={}){K(this,"input");K(this,"output");K(this,"options");if(n.length!==t.length)throw new Nt({code:"invalidKeyframes",message:"inputRange and outputRange must have the same length"});this.input=n.map(i=>eo(i)),this.output=t,this.options={extrapolate:"clamp",easing:"linear",type:"number",...JSON.parse(JSON.stringify(o))}}normalize(n){const{input:t}=this;if(n<t[0])return this.options.extrapolate==="clamp"?{t:0,segment:0}:{t:(n-t[0])/(t[1]-t[0]),segment:0};if(n>t[t.length-1])return this.options.extrapolate==="clamp"?{t:1,segment:t.length-2}:{t:(n-t[t.length-2])/(t[t.length-1]-t[t.length-2]),segment:t.length-2};for(let o=0;o<t.length-1;o++){const i=t[o],r=t[o+1];if(n>=i&&n<=r)return{t:(n-i)/(r-i),segment:o}}return{t:0,segment:0}}interpolate(n,t){const o=this.output[t],i=this.output[t+1],r=bg[this.options.easing](n);if(typeof o=="number"&&typeof i=="number")return Zi(o,i,r);if(typeof o=="string"&&typeof i=="string")return yg(o,i,r);if(this.output.length==1)return this.output[0];throw new Nt({code:"invalidKeyframes",message:"Unsupported output range types"})}value(n){const{t,segment:o}=this.normalize(typeof n=="number"?n:n.millis);return this.interpolate(t,o)}push(n,t){return this.input.push(eo(n)),this.output.push(t),this}toJSON(){return this}static fromJSON(n){const t=new Le([],[]);return Object.assign(t,n),t}}class wn{constructor(){K(this,"id",crypto.randomUUID())}toJSON(){const n={};return(this.constructor.__serializableProperties||[]).forEach(({propertyKey:t,serializer:o})=>{const i=this[t];o&&i instanceof o?n[t]=i.toJSON():n[t]=i}),n}static fromJSON(n){const t=new this;return(this.__serializableProperties||[]).forEach(({propertyKey:o,serializer:i})=>{if(n.hasOwnProperty(o))if(i){const r=i.fromJSON(n[o]);t[o]=r}else t[o]=n[o]}),t}}function Te(a){return function(n,t){n.constructor.__serializableProperties||(n.constructor.__serializableProperties=[]),n.constructor.__serializableProperties.push({propertyKey:t,serializer:a})}}function ei(a){return class extends a{constructor(){super(...arguments);K(this,"_handlers",{})}on(t,o){if(typeof o!="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]=o:this._handlers[t]={[i]:o},i}off(t,...o){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 o)this.off(i)}}trigger(t,o){var r,s;const i=new CustomEvent(t,{detail:o});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("*",o=>{t.trigger(o.type,o.detail)})}resolve(t){return(o,i)=>{this.on("error",i),this.on(t,o)}}}}function Cl(a,n,t=0){if(!(a instanceof mt.Container||a instanceof mt.Filter||t==3))for(const o in a){const i=a[o];o&&(i instanceof Le&&(a[o]=i.value(n)),i!=null&&typeof i=="object"&&Object.keys(i).length&&Cl(i,n,t+1))}}var wg=Object.defineProperty,hr=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&wg(n,t,i),i};const ti=class pu extends ei(wn){constructor(t={}){super();K(this,"_name");K(this,"_start",new Fe);K(this,"_stop",Fe.fromSeconds(16));K(this,"type","base");K(this,"source");K(this,"view",new mt.Container);K(this,"createdAt",new Date);K(this,"disabled",!1);K(this,"state","IDLE");K(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",Fe.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=Fe.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new Nt({code:"splitOutOfRange",message:"Cannot split clip at the specified time"});if(!this.track)throw new Nt({code:"trackNotAttached",message:"Track must be attached to a track"});const o=this.copy();this.stop=t.copy(),o.start=t.copy().addMillis(1),Cl(o,o.start.subtract(this.start));const i=this.track.clips.findIndex(l=>l.id==this.id);return await this.track.add(o,i+1),o}copy(){return pu.fromJSON(JSON.parse(JSON.stringify(this)))}set(t){return t&&Object.assign(this,t),this.trigger("update",void 0),this}};hr([Te()],ti.prototype,"_name");hr([Te(Fe)],ti.prototype,"_start");hr([Te(Fe)],ti.prototype,"_stop");hr([Te()],ti.prototype,"disabled");let ni=ti;var kg=Object.defineProperty,$a=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&kg(n,t,i),i};class Un extends ei(wn){constructor(){super(...arguments);K(this,"state","IDLE");K(this,"metadata");K(this,"objectURL");K(this,"duration",Fe.fromSeconds(16));K(this,"added",!1);K(this,"type","base");K(this,"name","");K(this,"mimeType");K(this,"externalURL");K(this,"external",!1);K(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 Nt({code:"fileNotAccessible",message:"The desired file cannot be accessed"});return this.file}async loadFile(t){this.name=t.name,this.mimeType=Ps(t.type),this.external=!1,this.file=t}async loadUrl(t,o){const i=await fetch(t,o);if(!(i!=null&&i.ok))throw new Gn({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=Ps(r.type)}async from(t,o){try{this.state="LOADING",t instanceof File?await this.loadFile(t):await this.loadUrl(t,o),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();gg(t,this.name)}async thumbnail(){return document.createElement("div")}static async from(t,o,i=new this){return i.from(t,o)}}$a([Te()],Un.prototype,"objectURL");$a([Te()],Un.prototype,"duration");$a([Te()],Un.prototype,"type");$a([Te()],Un.prototype,"name");$a([Te()],Un.prototype,"mimeType");$a([Te()],Un.prototype,"externalURL");$a([Te()],Un.prototype,"external");const Cc="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E";function _g(a){const n=new TextEncoder().encode(a);let t="";const o=n.byteLength;for(let i=0;i<o;i++)t+=String.fromCharCode(n[i]);return btoa(t)}function Vc(a){if(!a||!a.body)return Cc;const n=a.body.scrollWidth,t=a.body.scrollHeight,o=a.cloneNode(!0),i=o.getElementsByTagName("style").item(0),r=o.getElementsByTagName("body").item(0);if(r==null||r.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),!r)return Cc;const s=new XMLSerializer,l=i?s.serializeToString(i):"",c=s.serializeToString(r),d=`
|
|
26
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${t}">
|
|
27
|
-
body { padding: 0; }
|
|
28
|
-
${l}
|
|
29
|
-
<foreignObject width="100%" height="100%">
|
|
30
|
-
${c}
|
|
31
|
-
</foreignObject>
|
|
32
|
-
</svg>`;return"data:image/svg+xml;base64,"+_g(d)}class Nc extends Un{constructor(){super();K(this,"type","html");K(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,o){await super.loadUrl(t,o),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((o,i)=>{this.iframe.onload=()=>o(),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 Eg(a,n={}){const{threshold:t=.02,hopSize:o=1024,minDuration:i=500}=n,r=[],s=a.getChannelData(0),l=a.sampleRate,c=Math.floor(i/1e3*l);let d=null,u=0;for(let f=0;f<s.length;f+=o){let p=0;const m=Math.min(f+o,s.length);for(let h=f;h<m;h++)p+=s[h]*s[h];p=Math.sqrt(p/(m-f)),p<t?(u+=o,d===null&&(d=f)):(d!==null&&u>=c&&r.push({start:Fe.fromSeconds(d/l),stop:Fe.fromSeconds(f/l)}),d=null,u=0)}return d!==null&&u>=c&&r.push({start:Fe.fromSeconds(d/l),stop:Fe.fromSeconds(s.length/l)}),r}const ss=3e3;class ia extends Un{constructor(){super(...arguments);K(this,"type","audio");K(this,"decoding",!1);K(this,"_silences");K(this,"transcript");K(this,"audioBuffer")}async decode(t=2,o=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,o).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,o=50,i=0){const r=this.audioBuffer??await this.decode(1,3e3,!0),s=Math.round(r.sampleRate/o),l=r.sampleRate*r.duration-s,c=Math.ceil(l/t),d=r.getChannelData(0),u=[];for(let f=0;f<l;f+=c){let p=0;for(let m=f;m<f+s;m++)p+=Math.abs(d[f]);u.push(Math.log1p(p/s*100))}return u.map(f=>Math.round(f/Math.max(...u)*(100-i))+i)}async fastsampler({length:t=60,start:o=0,stop:i,logarithmic:r=!1}={}){typeof o=="object"&&(o=o.millis),typeof i=="object"&&(i=i.millis);const s=this.audioBuffer??await this.decode(1,ss,!0),l=s.getChannelData(0),c=Math.floor(Math.max(o*ss/1e3,0)),d=i?Math.floor(Math.min(i*ss/1e3,s.length)):s.length,u=Math.floor((d-c)/t),f=new Float32Array(t);for(let p=0;p<t;p++){const m=c+p*u,h=m+u;let g=-1/0;for(let k=m;k<h;k++){const $=l[k];$>g&&(g=$)}f[p]=r?Math.log2(1+g):g}return f}async thumbnail(...t){const o=await this.samples(...t),i=document.createElement("div");i.className="flex flex-row absolute space-between inset-0 audio-samples";for(const r of o){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 o=await this.arrayBuffer(),i=new AudioContext,r=await i.decodeAudioData(o);return this._silences=Eg(r,t),i.close(),this._silences}}class Rs extends Un{constructor(){super(...arguments);K(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 xa extends ia{constructor(){super(...arguments);K(this,"type","video");K(this,"downloadInProgress",!0)}async loadUrl(t,o){const i=await fetch(t,o);if(!(i!=null&&i.ok))throw new Gn({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=Ps(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 Nt({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",o=>{const i=o.currentTarget,r=i==null?void 0:i.getBoundingClientRect(),s=o.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 o=await t.blob();this.file=new File([o],this.name,{type:o.type}),this.trigger("load",void 0)}catch(o){this.state=="ERROR",this.trigger("error",new Error(String(o)))}finally{this.downloadInProgress=!1}}}class xg{static fromJSON(n){return[new Fe(n[0]),new Fe(n[1])]}}var Sg=Object.defineProperty,Cg=Object.getOwnPropertyDescriptor,lo=(a,n,t,o)=>{for(var i=o>1?void 0:o?Cg(n,t):n,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=(o?s(n,t,i):s(i))||i);return o&&i&&Sg(n,t,i),i};const Da=class fu extends ni{constructor(t={}){super();K(this,"source",new ia);K(this,"_offset",new Fe);K(this,"playing",!1);K(this,"duration",new Fe);K(this,"range",[new Fe,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=Fe.fromFrames(t));const o=t.subtract(this.offset);o.millis>=0&&o.millis<this.range[1].millis?this.range[0].millis=o.millis:o.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=Fe.fromFrames(t));const o=t.subtract(this.offset);o.millis>this.range[0].millis&&o.millis<=this.duration.millis?this.range[1]=o:o.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",Fe.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((o,i)=>{if(!this.element)return i(new wc({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=()=>o()})}subclip(t,o){if(t||(t=this.range[0]),o||(o=this.range[1]),typeof t=="number"&&(t=Fe.fromFrames(t)),typeof o=="number"&&(o=Fe.fromFrames(o)),t.millis>=o.millis)throw new Nt({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]),o.millis>this.duration.millis&&this.duration.millis&&(o=this.duration),this.range=[t,o],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=fu.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=Fe.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new Nt({code:"invalidKeyframe",message:"Cannot split clip at the specified time"});if(!this.track)throw new wc({code:"trackNotDefined",message:"Clip must be attached to a track"});t=t.subtract(this.offset);const o=this.copy();this.range[1]=t.copy(),o.range[0]=t.copy().addMillis(1),Cl(o,o.start.subtract(this.start));const i=this.track.clips.findIndex(l=>l.id==this.id);return await this.track.add(o,i+1),o}async addCaptions(t){var o;if(!((o=this.track)!=null&&o.composition))throw new Nt({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 o=(await this.source.silences(t)).filter(s=>Tc(s,this.range)).sort((s,l)=>s.start.millis-l.start.millis);if(o.length==0)return[this];const i=t.padding??500,r=[this];for(const s of o){const l=r.at(-1);if(!l)break;if(!Tc(s,l.range))continue;const c=new Fe(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 d=l.copy();l.range[1]=c,d.range[0]=s.stop,r.push(d)}else s.start.millis<=l.range[0].millis?l.range[0]=s.stop:s.stop.millis>=l.range[1].millis&&(l.range[1]=c)}return r}};lo([Te(Fe)],Da.prototype,"_offset",2);lo([Te(Fe)],Da.prototype,"duration",2);lo([Te(xg)],Da.prototype,"range",2);lo([Te(Ea)],Da.prototype,"transcript",1);lo([Te()],Da.prototype,"muted",1);lo([Te()],Da.prototype,"volume",1);let vr=Da;function Tc(a,n){return a.start.millis>=n[0].millis&&a.start.millis<=n[1].millis||a.stop.millis<=n[1].millis&&a.stop.millis>=n[0].millis}class Ci{static fromJSON(n){return typeof n=="object"?Le.fromJSON(n):n}}class ls{static fromJSON(n){return typeof n.x=="object"&&(n.x=Le.fromJSON(n.x)),typeof n.y=="object"&&(n.y=Le.fromJSON(n.y)),n}}let Vg=class{constructor(a){K(this,"target");K(this,"animation");this.target=a}init(a,n,t=0,o){if(!(a in this.target))throw new Error(`Property [${String(a)}] cannot be assigned`);const i=[t],r=[n];typeof this.target[a]==typeof n&&t!=0&&(i.unshift(0),r.unshift(this.target[a])),this.target[a]=this.animation=new Le(i,r,{easing:o})}};function Ng(a){const n=new Proxy(a,{get(t,o){return o=="to"?(i,r)=>{if(!t.animation)throw new Nt({code:"undefinedKeyframe",message:"Cannot use 'to() before selecting a property"});const s=new Fe(t.animation.input.at(-1)).frames+r;return t.animation.push(s,i),n}:(i,r,s)=>(t.init(o,i,r,s),n)}});return n}class Tg extends Vg{}var Mg=Object.defineProperty,Bg=Object.getOwnPropertyDescriptor,na=(a,n,t,o)=>{for(var i=o>1?void 0:o?Bg(n,t):n,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=(o?s(n,t,i):s(i))||i);return o&&i&&Mg(n,t,i),i};function gr(a){class n extends a{constructor(){super(...arguments);K(this,"filters");K(this,"_height");K(this,"_width");K(this,"_position",{x:this.view.position.x,y:this.view.position.y});K(this,"_scale");K(this,"rotation",this.view.angle);K(this,"alpha",1);K(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 Le||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 mt.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 mt.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 Ng(new Tg(this))}}return na([Te(Ci)],n.prototype,"_height",2),na([Te(Ci)],n.prototype,"_width",2),na([Te(ls)],n.prototype,"_position",2),na([Te(ls)],n.prototype,"_scale",2),na([Te(Ci)],n.prototype,"rotation",2),na([Te(Ci)],n.prototype,"alpha",2),na([Te(ls)],n.prototype,"translate",2),na([Te()],n.prototype,"anchor",1),n}function yr(a,n,t){const o=t.value;return t.value=function(...i){var f,p,m,h;const r=i[0].subtract(this.start),s={width:((p=(f=this.track)==null?void 0:f.composition)==null?void 0:p.width)??1920,height:((h=(m=this.track)==null?void 0:m.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 c;typeof this.translate.y=="number"?c=this.translate.y:typeof this.translate.y=="function"?c=this.translate.y.bind(this)(r):c=this.translate.y.value(r);let d;typeof this._position.x=="number"?d=this._position.x:typeof this._position.x=="string"?d=Number.parseFloat(this._position.x)*s.width/100:typeof this._position.x=="function"?d=this._position.x.bind(this)(r):d=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(d+l,u+c),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 g;typeof this._scale.x=="number"?g=this._scale.x:typeof this._scale.x=="function"?g=this._scale.x.bind(this)(r):g=this._scale.x.value(r);let k;typeof this._scale.y=="number"?k=this._scale.y:typeof this._scale.y=="function"?k=this._scale.y.bind(this)(r):k=this._scale.y.value(r),(this._width||this._height)&&(g*=this.view.scale._x,k*=this.view.scale._y),this.view.scale.set(g,k)}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),o.apply(this,i)},t}var Ig=Object.defineProperty,Fg=Object.getOwnPropertyDescriptor,$g=(a,n,t,o)=>{for(var i=Fg(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Ig(n,t,i),i};const hu=class vu extends gr(ni){constructor(t,o={}){super();K(this,"type","image");K(this,"element",new Image);K(this,"source",new Rs);K(this,"sprite",new mt.Sprite);this.view.addChild(this.sprite),t instanceof Rs&&(this.source=t),t instanceof File&&this.source.from(t),Object.assign(this,o)}async init(){this.element.setAttribute("src",await this.source.createObjectURL()),await new Promise((t,o)=>{this.element.onload=()=>{this.sprite.texture=mt.Texture.from(this.element),this.state="READY",t()},this.element.onerror=i=>{this.state="ERROR",o(new Gn({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=vu.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};$g([yr],hu.prototype,"update");let Dg=hu;const Vi={"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 Rg=Object.defineProperty,br=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Rg(n,t,i),i};const ai=class As extends ei(wn){constructor(t){super();K(this,"loaded",!1);K(this,"family");K(this,"weight");K(this,"source");K(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(o=>{t.load().then(i=>{document.fonts.add(i),o(null)})}),this.loaded=!0,this.trigger("load",void 0),this}copy(){const t=As.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 o of await window.queryLocalFonts()){if(o.family in t){t[o.family].push(o);continue}t[o.family]=[o]}return Object.keys(t).map(o=>({family:o,variants:t[o].map(i=>({family:o,style:i.style,source:`local('${i.fullName}'), local('${i.postscriptName}')`}))}))}static webFonts(){return Object.keys(Vi).map(t=>({family:t,variants:Vi[t].weights.map(o=>({family:t,source:`url(${Vi[t].url})`,weight:o}))}))}static fromFamily({family:t,weight:o}){return new As({family:t,source:`url(${Vi[t].url})`,weight:o})}};br([Te()],ai.prototype,"family");br([Te()],ai.prototype,"weight");br([Te()],ai.prototype,"source");br([Te()],ai.prototype,"style");let Zt=ai;const Ln=4,gu={center:.5,justify:.5,left:0,right:1},yu={alphabetic:0,top:0,middle:.5,hanging:1,bottom:1,ideographic:1};var Ag=Object.defineProperty,Lg=Object.getOwnPropertyDescriptor,en=(a,n,t,o)=>{for(var i=Lg(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Ag(n,t,i),i};const Gt=class bu extends gr(ni){constructor(t){super();K(this,"type","text");K(this,"_text","");K(this,"_textCase");K(this,"_anchor",{x:0,y:0});K(this,"_font",new Zt);K(this,"style",new mt.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 o=new mt.Text({text:this.transformedText,style:this.style,resolution:Ln,scale:Ln});this.view.addChild(o)}this.view.children[0]instanceof mt.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*Ln}set maxWidth(t){t?(this.style.wordWrap=!0,this.style.wordWrapWidth=t/Ln):this.style.wordWrap=!1}get textAlign(){return this.style.align}set textAlign(t){this.style.align=t,this.anchor.x=gu[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=yu[t]}get fillStyle(){const{fill:t}=this.style;return new mt.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:o=1,width:i=3,join:r="round",miterLimit:s}=this.style.stroke;return t=new mt.Color(t).toHex().toUpperCase(),{color:t,alpha:o,width:i,join:r,miterLimit:s}}set stroke(t){if(!t){this.style.stroke=void 0;return}const{color:o="#000000",alpha:i=1,width:r=3,join:s="round",miterLimit:l}=t;this.style.stroke={color:o,alpha:i,width:r,join:s,miterLimit:l}}get textCase(){return this._textCase}set textCase(t){this._textCase=t,this.view.children[0]instanceof mt.Text&&this.transformedText&&(this.view.children[0].text=this.transformedText)}get shadow(){if(!this.style.dropShadow)return;const{alpha:t,angle:o,blur:i,color:r,distance:s}=this.style.dropShadow,l=new mt.Color(r).toHex().toUpperCase();return{alpha:t,angle:o,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=bu.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,o=((s=this.view.children[0])==null?void 0:s.height)??0,i=(((l=this.style.dropShadow)==null?void 0:l.distance)??0)*Ln;this.view.pivot={x:(t-i)*this._anchor.x,y:(o-i)*this._anchor.y}}set(t){return super.set(t)}};en([Te()],Gt.prototype,"text");en([Te(Zt)],Gt.prototype,"font");en([Te()],Gt.prototype,"maxWidth");en([Te()],Gt.prototype,"textAlign");en([Te()],Gt.prototype,"padding");en([Te()],Gt.prototype,"textBaseline");en([Te()],Gt.prototype,"fillStyle");en([Te()],Gt.prototype,"anchor");en([Te()],Gt.prototype,"stroke");en([Te()],Gt.prototype,"textCase");en([Te()],Gt.prototype,"shadow");en([Te()],Gt.prototype,"fontSize");en([Te()],Gt.prototype,"leading");en([yr],Gt.prototype,"update");let co=Gt;function cs(a){const n=a.split(" ").map(t=>`${t} `);return n[n.length-1]=n[n.length-1].replace(/ $/,""),n}const Pg={get(a,n){const t=a[n];return typeof t=="number"?t*Ln:Array.isArray(t)&&typeof t[0]=="number"?t.map(o=>o*Ln):t}};function Og(a){return new Proxy(a,Pg)}class Ug{constructor(){K(this,"tokens",[])}get width(){return this.tokens.reduce((n,t)=>n+t.metrics.lineWidths[0],0)}get height(){return Math.max(...this.tokens.map(n=>n.metrics.lineHeight))}}class Mc{constructor(){K(this,"lines",[])}get width(){return Math.max(...this.lines.map(n=>n.width))}get height(){return this.lines.reduce((n,t)=>n+t.height,0)}}class zg{static fromJSON(n){return n.map(t=>(t.font&&(t.font=Zt.fromJSON(t.font)),t))}}var jg=Object.defineProperty,Wg=Object.getOwnPropertyDescriptor,uo=(a,n,t,o)=>{for(var i=o>1?void 0:o?Wg(n,t):n,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=(o?s(n,t,i):s(i))||i);return o&&i&&jg(n,t,i),i};const Ra=class wu extends co{constructor(t){super();K(this,"type","complex_text");K(this,"_maxWidth");K(this,"_textAlign","left");K(this,"_textBaseline","top");K(this,"model",new mt.Container);K(this,"segments",[]);K(this,"metrics",new Mc);K(this,"background");K(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=gu[t];const o=this.metrics.width;for(const i of this.metrics.lines){let r=0;(t=="center"||t=="justify")&&(r=(o-i.width)/2),t=="right"&&(r=o-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=yu[t];let o=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=o+l}o+=r}}copy(){const t=wu.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.font=this.font,t}createRenderSplits(t=[]){var r,s;const o=this.transformedText??"",i=[{index:void 0,tokens:cs(o.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:cs(o.substring(t[l].start,t[l].stop))}),!((t[l].stop??o.length)>=o.length)&&i.push({index:void 0,tokens:cs(o.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,o){var r,s,l;const i=new Mc;for(const c of t){const d=c.index!=null?o[c.index]:this.style;for(let u=0;u<c.tokens.length;u++){const f=Og(mt.CanvasTextMetrics.measureText(c.tokens[u],d)),p=(((r=i.lines.at(-1))==null?void 0:r.width)??0)+f.lineWidths[0],m=this.maxWidth??Number.POSITIVE_INFINITY,h=(s=c.tokens.at(u-1))==null?void 0:s.match(/(\n|\\n).$/gim);(p>m||h||!i.lines.length)&&i.lines.push(new Ug),this.model.addChild(new mt.Text({text:c.tokens[u],style:d,resolution:Ln,scale:Ln})),(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(o=>{var r;const i=this.style.clone();return i.fill=o.fillStyle??this.style.fill,i.fontSize=o.fontSize??this.style.fontSize,i.stroke=o.stroke??this.style.stroke,i.fontFamily=((r=o.font)==null?void 0:r.name)??this.style.fontFamily,i}))??[]}drawBackground(){var l,c;if(this.view.children.length>1&&this.view.removeChildAt(0),!this.background)return;const t=this.model.width,o=this.model.height,i=((l=this.background.padding)==null?void 0:l.x)??40,r=((c=this.background.padding)==null?void 0:c.y)??10,s=new mt.Graphics;s.roundRect(0-i/2,2-r/2,t+i,o+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),o=this.createTextStyles();this.metrics=this.createTextMetrics(t,o),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)*Ln;this.view.pivot={x:(i-s)*this._anchor.x,y:(r-s)*this._anchor.y},this.drawBackground()}};uo([Te()],Ra.prototype,"background",2);uo([Te(zg)],Ra.prototype,"styles",2);uo([Te()],Ra.prototype,"text",1);uo([Te()],Ra.prototype,"maxWidth",1);uo([Te()],Ra.prototype,"textAlign",1);uo([Te()],Ra.prototype,"textBaseline",1);let wr=Ra;const ku="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBtPSh0PT4odFt0LkFWTUVESUFfVFlQRV9VTktOT1dOPS0xXT0iQVZNRURJQV9UWVBFX1VOS05PV04iLHRbdC5BVk1FRElBX1RZUEVfVklERU89MF09IkFWTUVESUFfVFlQRV9WSURFTyIsdFt0LkFWTUVESUFfVFlQRV9BVURJTz0xXT0iQVZNRURJQV9UWVBFX0FVRElPIix0W3QuQVZNRURJQV9UWVBFX0RBVEE9Ml09IkFWTUVESUFfVFlQRV9EQVRBIix0W3QuQVZNRURJQV9UWVBFX1NVQlRJVExFPTNdPSJBVk1FRElBX1RZUEVfU1VCVElUTEUiLHRbdC5BVk1FRElBX1RZUEVfQVRUQUNITUVOVD00XT0iQVZNRURJQV9UWVBFX0FUVEFDSE1FTlQiLHRbdC5BVk1FRElBX1RZUEVfTkI9NV09IkFWTUVESUFfVFlQRV9OQiIsdCkpKG18fHt9KSxvPSh0PT4odC5GRm1wZWdXb3JrZXJMb2FkZWQ9IkZGbXBlZ1dvcmtlckxvYWRlZCIsdC5XQVNNUnVudGltZUluaXRpYWxpemVkPSJXQVNNUnVudGltZUluaXRpYWxpemVkIix0LkxvYWRXQVNNPSJMb2FkV0FTTSIsdC5HZXRBVlBhY2tldD0iR2V0QVZQYWNrZXQiLHQuR2V0QVZQYWNrZXRzPSJHZXRBVlBhY2tldHMiLHQuR2V0QVZTdHJlYW09IkdldEFWU3RyZWFtIix0LkdldEFWU3RyZWFtcz0iR2V0QVZTdHJlYW1zIix0LlJlYWRBVlBhY2tldD0iUmVhZEFWUGFja2V0Iix0LkFWUGFja2V0U3RyZWFtPSJBVlBhY2tldFN0cmVhbSIsdC5SZWFkTmV4dEFWUGFja2V0PSJSZWFkTmV4dEFWUGFja2V0Iix0LlN0b3BSZWFkQVZQYWNrZXQ9IlN0b3BSZWFkQVZQYWNrZXQiLHQpKShvfHx7fSk7Y29uc3QgQT0iS0daMWJtTjBhVzl1S0NsN0luVnpaU0J6ZEhKcFkzUWlPMnhsZENCbU8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2SWtaR2JYQmxaMWR2Y210bGNreHZZV1JsWkNKOUtTeHpaV3htTG1Ga1pFVjJaVzUwVEdsemRHVnVaWElvSW0xbGMzTmhaMlVpTEdGemVXNWpJR1oxYm1OMGFXOXVLR3dwZTJOdmJuTjBlM1I1Y0dVNmRDeGtZWFJoT21NOWUzMHNiWE5uU1dRNmIzMDliQzVrWVhSaE8zUnllWHRwWmloMFBUMDlJa3h2WVdSWFFWTk5JaWw3WTI5dWMzUjdkMkZ6YlV4dllXUmxjbEJoZEdnNlpYMDlZM3g4ZTMwN1pqMWhkMkZwZENoaGQyRnBkQ0JwYlhCdmNuUW9aU2twTG1SbFptRjFiSFFvS1gxbGJITmxJR2xtS0hROVBUMGlSMlYwUVZaVGRISmxZVzBpS1h0amIyNXpkSHRtYVd4bE9tVXNjM1J5WldGdFZIbHdaVHB6TEhOMGNtVmhiVWx1WkdWNE9tRjlQV01zY2oxbUxtZGxkRUZXVTNSeVpXRnRLR1VzY3l4aEtUdHpaV3htTG5CdmMzUk5aWE56WVdkbEtIdDBlWEJsT25Rc2JYTm5TV1E2Ynl4eVpYTjFiSFE2Y24wc1czSXVZMjlrWldOd1lYSXVaWGgwY21Ga1lYUmhMbUoxWm1abGNsMHBmV1ZzYzJVZ2FXWW9kRDA5UFNKSFpYUkJWbE4wY21WaGJYTWlLWHRqYjI1emRIdG1hV3hsT21WOVBXTXNjejFtTG1kbGRFRldVM1J5WldGdGN5aGxLVHR6Wld4bUxuQnZjM1JOWlhOellXZGxLSHQwZVhCbE9uUXNiWE5uU1dRNmJ5eHlaWE4xYkhRNmMzMHNjeTV0WVhBb1lUMCtZUzVqYjJSbFkzQmhjaTVsZUhSeVlXUmhkR0V1WW5WbVptVnlLU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBJaWw3WTI5dWMzUjdabWxzWlRwbExIUnBiV1U2Y3l4emRISmxZVzFVZVhCbE9tRXNjM1J5WldGdFNXNWtaWGc2Y24wOVl5eHVQV1l1WjJWMFFWWlFZV05yWlhRb1pTeHpMR0VzY2lrN2MyVnNaaTV3YjNOMFRXVnpjMkZuWlNoN2RIbHdaVHAwTEcxelowbGtPbThzY21WemRXeDBPbTU5TEZ0dUxtUmhkR0V1WW5WbVptVnlYU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBjeUlwZTJOdmJuTjBlMlpwYkdVNlpTeDBhVzFsT25OOVBXTXNZVDFtTG1kbGRFRldVR0ZqYTJWMGN5aGxMSE1wTzNObGJHWXVjRzl6ZEUxbGMzTmhaMlVvZTNSNWNHVTZkQ3h0YzJkSlpEcHZMSEpsYzNWc2REcGhmU3hoTG0xaGNDaHlQVDV5TG1SaGRHRXVZblZtWm1WeUtTbDlaV3h6WlNCcFppaDBQVDA5SWxKbFlXUkJWbEJoWTJ0bGRDSXBlMk52Ym5OMGUyWnBiR1U2WlN4emRHRnlkRHB6TEdWdVpEcGhMSE4wY21WaGJWUjVjR1U2Y2l4emRISmxZVzFKYm1SbGVEcHVmVDFqTEdROVppNXlaV0ZrUVZaUVlXTnJaWFFvYnl4bExITXNZU3h5TEc0cE8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEhKbGMzVnNkRHBrZlNsOWZXTmhkR05vS0dVcGUzTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEdWeWNrMXpaenBsSUdsdWMzUmhibU5sYjJZZ1JYSnliM0kvWlM1dFpYTnpZV2RsT2lKVmJtdHViM2R1SUVWeWNtOXlJbjBwZlgwcGZTa29LVHNLIixnPXQ9PlVpbnQ4QXJyYXkuZnJvbShhdG9iKHQpLGU9PmUuY2hhckNvZGVBdCgwKSksVj10eXBlb2Ygc2VsZjwidSImJnNlbGYuQmxvYiYmbmV3IEJsb2IoW2coQSldLHt0eXBlOiJ0ZXh0L2phdmFzY3JpcHQ7Y2hhcnNldD11dGYtOCJ9KTtmdW5jdGlvbiBFKHQpe2xldCBlO3RyeXtpZihlPVYmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLmNyZWF0ZU9iamVjdFVSTChWKSwhZSl0aHJvdyIiO2NvbnN0IHM9bmV3IFdvcmtlcihlLHtuYW1lOnQ/Lm5hbWV9KTtyZXR1cm4gcy5hZGRFdmVudExpc3RlbmVyKCJlcnJvciIsKCk9Pnsoc2VsZi5VUkx8fHNlbGYud2Via2l0VVJMKS5yZXZva2VPYmplY3RVUkwoZSl9KSxzfWNhdGNoe3JldHVybiBuZXcgV29ya2VyKCJkYXRhOnRleHQvamF2YXNjcmlwdDtiYXNlNjQsIitBLHtuYW1lOnQ/Lm5hbWV9KX1maW5hbGx5e2UmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLnJldm9rZU9iamVjdFVSTChlKX19Y29uc3QgdT0xZTY7Y2xhc3MgcHtmZm1wZWdXb3JrZXI7ZmZtcGVnV29ya2VyTG9hZFN0YXR1czttc2dJZDtmaWxlO2NvbnN0cnVjdG9yKGUpe3RoaXMuZmZtcGVnV29ya2VyPW5ldyBFLHRoaXMuZmZtcGVnV29ya2VyTG9hZFN0YXR1cz1uZXcgUHJvbWlzZSgocyxhKT0+e3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGk9Pntjb25zdHt0eXBlOnIsZXJyTXNnOmR9PWkuZGF0YTtyPT09by5GRm1wZWdXb3JrZXJMb2FkZWQmJnRoaXMucG9zdChvLkxvYWRXQVNNLHt3YXNtTG9hZGVyUGF0aDplLndhc21Mb2FkZXJQYXRofSkscj09PW8uV0FTTVJ1bnRpbWVJbml0aWFsaXplZCYmcyghMCkscj09PW8uTG9hZFdBU00mJmQmJmEoZCl9KX0pLHRoaXMubXNnSWQ9MH1wb3N0KGUscyxhKXt0aGlzLmZmbXBlZ1dvcmtlci5wb3N0TWVzc2FnZSh7dHlwZTplLG1zZ0lkOmE/P3RoaXMubXNnSWQrKyxkYXRhOnN9KX1hc3luYyBsb2FkKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5mZm1wZWdXb3JrZXJMb2FkU3RhdHVzO3JldHVybiB0aGlzLmZpbGU9ZSxzfWRlc3Ryb3koKXt0aGlzLmZpbGU9dm9pZCAwLHRoaXMuZmZtcGVnV29ya2VyLnRlcm1pbmF0ZSgpfWdldEFWU3RyZWFtKGU9bS5BVk1FRElBX1RZUEVfVklERU8scz0tMSl7cmV0dXJuIG5ldyBQcm9taXNlKChhLGkpPT57aWYoIXRoaXMuZmlsZSl7aSgiZmlsZSBpcyBub3QgbG9hZGVkIik7cmV0dXJufWNvbnN0IHI9dGhpcy5tc2dJZCxkPSh7ZGF0YTpufSk9PntuLnR5cGU9PT1vLkdldEFWU3RyZWFtJiZuLm1zZ0lkPT09ciYmKG4uZXJyTXNnP2kobi5lcnJNc2cpOmEobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGQpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZCksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW0se2ZpbGU6dGhpcy5maWxlLHN0cmVhbVR5cGU6ZSxzdHJlYW1JbmRleDpzfSl9KX1nZXRBVlN0cmVhbXMoKXtyZXR1cm4gbmV3IFByb21pc2UoKGUscyk9PntpZighdGhpcy5maWxlKXtzKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgYT10aGlzLm1zZ0lkLGk9KHtkYXRhOnJ9KT0+e3IudHlwZT09PW8uR2V0QVZTdHJlYW1zJiZyLm1zZ0lkPT09YSYmKHIuZXJyTXNnP3Moci5lcnJNc2cpOmUoci5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsaSksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW1zLHtmaWxlOnRoaXMuZmlsZX0pfSl9Z2V0QVZQYWNrZXQoZSxzPW0uQVZNRURJQV9UWVBFX1ZJREVPLGE9LTEpe3JldHVybiBuZXcgUHJvbWlzZSgoaSxyKT0+e2lmKCF0aGlzLmZpbGUpe3IoImZpbGUgaXMgbm90IGxvYWRlZCIpO3JldHVybn1jb25zdCBkPXRoaXMubXNnSWQsbj1oPT57Y29uc3QgbD1oLmRhdGE7bC50eXBlPT09by5HZXRBVlBhY2tldCYmbC5tc2dJZD09PWQmJihsLmVyck1zZz9yKGwuZXJyTXNnKTppKGwucmVzdWx0KSx0aGlzLmZmbXBlZ1dvcmtlci5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixuKSl9O3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLG4pLHRoaXMucG9zdChvLkdldEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSx0aW1lOmUsc3RyZWFtVHlwZTpzLHN0cmVhbUluZGV4OmF9KX0pfWdldEFWUGFja2V0cyhlKXtyZXR1cm4gbmV3IFByb21pc2UoKHMsYSk9PntpZighdGhpcy5maWxlKXthKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgaT10aGlzLm1zZ0lkLHI9ZD0+e2NvbnN0IG49ZC5kYXRhO24udHlwZT09PW8uR2V0QVZQYWNrZXRzJiZuLm1zZ0lkPT09aSYmKG4uZXJyTXNnP2Eobi5lcnJNc2cpOnMobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLHIpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsciksdGhpcy5wb3N0KG8uR2V0QVZQYWNrZXRzLHtmaWxlOnRoaXMuZmlsZSx0aW1lOmV9KX0pfXJlYWRBVlBhY2tldChlPTAscz0wLGE9bS5BVk1FRElBX1RZUEVfVklERU8saT0tMSl7Y29uc3Qgcj1uZXcgQ291bnRRdWV1aW5nU3RyYXRlZ3koe2hpZ2hXYXRlck1hcms6MX0pLGQ9dGhpcy5tc2dJZDtsZXQgbj0wO3JldHVybiBuZXcgUmVhZGFibGVTdHJlYW0oe3N0YXJ0Omg9PntpZighdGhpcy5maWxlKXtoLmVycm9yKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgbD1mPT57Y29uc3QgYz1mLmRhdGE7Yy50eXBlPT09by5SZWFkQVZQYWNrZXQmJmMubXNnSWQ9PT1kJiZjLmVyck1zZyYmKGguZXJyb3IoYy5lcnJNc2cpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGwpKSxjLnR5cGU9PT1vLkFWUGFja2V0U3RyZWFtJiZjLm1zZ0lkPT09ZCYmKGMucmVzdWx0P2guZW5xdWV1ZShjLnJlc3VsdCk6aC5jbG9zZSgpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsbCksdGhpcy5wb3N0KG8uUmVhZEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSxzdGFydDplLGVuZDpzLHN0cmVhbVR5cGU6YSxzdHJlYW1JbmRleDppfSl9LHB1bGw6KCk9PntuPjAmJnRoaXMucG9zdChvLlJlYWROZXh0QVZQYWNrZXQsdm9pZCAwLGQpLG4rK30sY2FuY2VsOigpPT57dGhpcy5wb3N0KG8uU3RvcFJlYWRBVlBhY2tldCx2b2lkIDAsZCl9fSxyKX1nZXRWaWRlb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9WSURFTyxlKX1nZXRBdWRpb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9BVURJTyxlKX1zZWVrVmlkZW9QYWNrZXQoZSl7cmV0dXJuIHRoaXMuZ2V0QVZQYWNrZXQoZSxtLkFWTUVESUFfVFlQRV9WSURFTyl9c2Vla0F1ZGlvUGFja2V0KGUpe3JldHVybiB0aGlzLmdldEFWUGFja2V0KGUsbS5BVk1FRElBX1RZUEVfQVVESU8pfXJlYWRWaWRlb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfVklERU8pfXJlYWRBdWRpb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfQVVESU8pfWdlblZpZGVvRGVjb2RlckNvbmZpZyhlKXtyZXR1cm57Y29kZWM6ZS5jb2RlY3Bhci5jb2RlY19zdHJpbmcsY29kZWRXaWR0aDplLmNvZGVjcGFyLndpZHRoLGNvZGVkSGVpZ2h0OmUuY29kZWNwYXIuaGVpZ2h0LGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRWaWRlb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZFZpZGVvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1nZW5BdWRpb0RlY29kZXJDb25maWcoZSl7cmV0dXJue2NvZGVjOmUuY29kZWNwYXIuY29kZWNfc3RyaW5nfHwiIixzYW1wbGVSYXRlOmUuY29kZWNwYXIuc2FtcGxlX3JhdGUsbnVtYmVyT2ZDaGFubmVsczplLmNvZGVjcGFyLmNoYW5uZWxzLGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRBdWRpb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZEF1ZGlvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1hc3luYyBnZXRWaWRlb0RlY29kZXJDb25maWcoKXtjb25zdCBlPWF3YWl0IHRoaXMuZ2V0VmlkZW9TdHJlYW0oKTtyZXR1cm4gdGhpcy5nZW5WaWRlb0RlY29kZXJDb25maWcoZSl9YXN5bmMgc2Vla0VuY29kZWRWaWRlb0NodW5rKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5zZWVrVmlkZW9QYWNrZXQoZSk7cmV0dXJuIHRoaXMuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsocyl9YXN5bmMgZ2V0QXVkaW9EZWNvZGVyQ29uZmlnKCl7Y29uc3QgZT1hd2FpdCB0aGlzLmdldEF1ZGlvU3RyZWFtKCk7cmV0dXJuIHRoaXMuZ2VuQXVkaW9EZWNvZGVyQ29uZmlnKGUpfWFzeW5jIHNlZWtFbmNvZGVkQXVkaW9DaHVuayhlKXtjb25zdCBzPWF3YWl0IHRoaXMuc2Vla0F1ZGlvUGFja2V0KGUpO3JldHVybiB0aGlzLmdlbkVuY29kZWRBdWRpb0NodW5rKHMpfX1jbGFzcyBre3ZpZGVvO2N1cnJlbnRGcmFtZXM9MDt0b3RhbEZyYW1lcztjdXJyZW50VGltZTtmcHM7Zmlyc3RUaW1lc3RhbXA7Y29uc3RydWN0b3IoZSxzKXt0aGlzLmN1cnJlbnRUaW1lPWVbMF0qMWU2LHRoaXMuZmlyc3RUaW1lc3RhbXA9ZVswXSoxZTYsdGhpcy50b3RhbEZyYW1lcz0oZVsxXS1lWzBdKSpzKzEsdGhpcy5mcHM9cyx0aGlzLnZpZGVvPW5ldyBWaWRlb0RlY29kZXIoe291dHB1dDp0aGlzLmhhbmRsZUZyYW1lT3V0cHV0LmJpbmQodGhpcyksZXJyb3I6dGhpcy5oYW5kbGVFcnJvci5iaW5kKHRoaXMpfSl9cG9zdEZyYW1lKGUpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImZyYW1lIixmcmFtZTplfSksdGhpcy5jdXJyZW50VGltZSs9TWF0aC5mbG9vcigxL3RoaXMuZnBzKjFlNiksdGhpcy5jdXJyZW50RnJhbWVzKz0xfWhhbmRsZUZyYW1lT3V0cHV0KGUpe2NvbnN0IHM9ZS50aW1lc3RhbXAsYT1lLmR1cmF0aW9uPz8wLGk9cythO2lmKCF0aGlzLmlzRnJhbWVJblJhbmdlKHMpKXtlLmNsb3NlKCk7cmV0dXJufWZvcig7aT50aGlzLmN1cnJlbnRUaW1lJiZ0aGlzLmN1cnJlbnRGcmFtZXM8PXRoaXMudG90YWxGcmFtZXM7KXRoaXMucG9zdEZyYW1lKGUpO2UuY2xvc2UoKX1pc0ZyYW1lSW5SYW5nZShlKXtyZXR1cm4gZT49dGhpcy5maXJzdFRpbWVzdGFtcH1oYW5kbGVFcnJvcihlKXtjb25zb2xlLmVycm9yKCJlcnJvciBpbiB3b3JrZXIiLGUpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOmUubWVzc2FnZT8/IkFuIHVua25vd24gd29ya2VyIGVycm9yIG9jY3VycmVkIn0pLHNlbGYuY2xvc2UoKX19ZnVuY3Rpb24gSSh0KXtyZXR1cm4gYXN5bmMgZT0+e3RyeXthd2FpdCB0KGUpfWNhdGNoKHMpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOnM/Lm1lc3NhZ2U/PyJBbiB1bmtvd24gd29ya2VyIGVycm9yIG9jY3VyZWQifSl9fX1mdW5jdGlvbiBXKHQpe3JldHVybiB0LmNvZGVjPT0idnAwOSImJih0LmNvZGVjPSJ2cDA5LjAwLjEwLjA4IiksdH1jb25zdCBaPTMwO2FzeW5jIGZ1bmN0aW9uIFAodCl7aWYodC5kYXRhPy50eXBlIT0iaW5pdCIpcmV0dXJuO2NvbnN0e2ZpbGU6ZSxyYW5nZTpzLGZwczphfT10LmRhdGEsaT1uZXcgcCh7d2FzbUxvYWRlclBhdGg6Imh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vQGRpZmZ1c2lvbnN0dWRpby9mZm1wZWctd2FzbUAxLjAuMC9kaXN0L2ZmbXBlZy5qcyJ9KTthd2FpdCBpLmxvYWQoZSk7Y29uc3Qgcj1hd2FpdCBpLmdldFZpZGVvRGVjb2RlckNvbmZpZygpO1cocik7Y29uc3QgZD1uZXcgayhzLGEpO2QudmlkZW8uY29uZmlndXJlKHIpO2NvbnN0IG49aS5yZWFkQVZQYWNrZXQoc1swXSxzWzFdKS5nZXRSZWFkZXIoKTtuLnJlYWQoKS50aGVuKGFzeW5jIGZ1bmN0aW9uIGgoe2RvbmU6bCx2YWx1ZTpmfSl7aWYobCl7YXdhaXQgZC52aWRlby5mbHVzaCgpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImRvbmUifSksc2VsZi5jbG9zZSgpO3JldHVybn1jb25zdCBjPWkuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsoZik7cmV0dXJuIGQudmlkZW8uZGVjb2RlUXVldWVTaXplPlomJmF3YWl0IG5ldyBQcm9taXNlKEw9PntkLnZpZGVvLm9uZGVxdWV1ZT0oKT0+TCgpfSksYy50aW1lc3RhbXA8PXNbMV0qMWU2JiZkLnZpZGVvLmRlY29kZShjKSxuLnJlYWQoKS50aGVuKGgpfSl9c2VsZi5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixJKFApKX0pKCk7Cg==",Zg=a=>Uint8Array.from(atob(a),n=>n.charCodeAt(0)),Bc=typeof self<"u"&&self.Blob&&new Blob([Zg(ku)],{type:"text/javascript;charset=utf-8"});function Hg(a){let n;try{if(n=Bc&&(self.URL||self.webkitURL).createObjectURL(Bc),!n)throw"";const t=new Worker(n,{name:a==null?void 0:a.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),t}catch{return new Worker("data:text/javascript;base64,"+ku,{name:a==null?void 0:a.name})}finally{n&&(self.URL||self.webkitURL).revokeObjectURL(n)}}class Xg{constructor(){K(this,"frames",[]);K(this,"state","active");K(this,"onenqueue");K(this,"onclose")}enqueue(n){var t;this.frames.unshift(n),(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 n;this.state="closed",(n=this.onclose)==null||n.call(this)}terminate(){for(const n of this.frames)n.close()}async waitFor(n){await new Promise((t,o)=>{const i=setTimeout(()=>{o(`Promise timed out after ${n} ms`)},n);this.onenqueue=()=>{clearTimeout(i),t()},this.onclose=()=>{clearTimeout(i),t()}})}}function Gg(a,n,t){const o=t.value;return t.value=function(...i){var r,s,l,c;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),!((c=(l=this.track)==null?void 0:l.composition)!=null&&c.rendering)&&this.sprite.texture.source.uid!=this.textrues.html5.source.uid&&(this.sprite.texture=this.textrues.html5),o.apply(this,i)},t}var Jg=Object.defineProperty,Kg=Object.getOwnPropertyDescriptor,Yg=(a,n,t,o)=>{for(var i=Kg(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Jg(n,t,i),i};const _u=class Eu extends gr(vr){constructor(t,o={}){super();K(this,"source",new xa);K(this,"type","video");K(this,"worker");K(this,"buffer");K(this,"canvas",document.createElement("canvas"));K(this,"context",this.canvas.getContext("2d"));K(this,"element",document.createElement("video"));K(this,"textrues",{html5:mt.Texture.from(this.element),canvas:mt.Texture.from(this.canvas)});K(this,"sprite",new mt.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 xa&&(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,o)}async init(){const t=await this.source.createObjectURL();this.element.setAttribute("src",t),await new Promise((o,i)=>{this.element.oncanplay=()=>{this.duration.seconds=this.element.duration,this.state="READY",o()},this.element.onerror=()=>{this.state="ERROR";const r=new Gn({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 o=((i=t.composition)==null?void 0:i.frame)??0;await this.seek(Fe.fromFrames(o))}enter(){var t,o,i;super.enter(),(o=(t=this.track)==null?void 0:t.composition)!=null&&o.rendering&&((i=this.buffer)==null?void 0:i.state)!="active"&&this.decodeVideo()}update(t){var o,i,r,s,l,c;if((i=(o=this.track)==null?void 0:o.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((c=(l=this.track)==null?void 0:l.composition)!=null&&c.rendering)return this.nextFrame()}exit(){this.playing&&this.element.pause(),this.filters&&this.view.filters&&(this.view.filters=null)}copy(){const t=Eu.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}async decodeVideo(){var t,o;return this.buffer=new Xg,this.worker=new Hg,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:((o=(t=this.track)==null?void 0:t.composition)==null?void 0:o.fps)??Xo}),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 o;this.start.millis<0?o=Math.abs(this.offset.seconds):o=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,[o,i]}cancelDecoding(){var t,o;(t=this.worker)==null||t.terminate(),this.worker=void 0,(o=this.buffer)==null||o.terminate(),this.buffer=void 0}};Yg([yr,Gg],_u.prototype,"update");let Ls=_u;class zo extends vr{constructor(t,o={}){super();K(this,"type","audio");K(this,"source",new ia);K(this,"element",new Audio);t instanceof ia&&(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,o)}async init(){const t=await this.source.createObjectURL();this.element.setAttribute("src",t),this.element.load(),await new Promise((o,i)=>{this.element.oncanplay=()=>{this.duration.seconds=this.element.duration,this.state="READY",o()},this.element.onerror=()=>{this.state="ERROR";const r=new Gn({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."});i(this.element.error??r)}})}update(){var t,o,i,r,s,l;if((o=(t=this.track)==null?void 0:t.composition)!=null&&o.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=zo.fromJSON(JSON.parse(JSON.stringify(this)));return t.source=this.source,t}}const qg={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 Ps(a){if(!Object.keys(qg.MIXED).includes(a??""))throw new Nt({message:`${a} is not an accepted mime type`,code:"invalid_mimetype"});return a}var Qg=Object.defineProperty,ey=Object.getOwnPropertyDescriptor,ty=(a,n,t,o)=>{for(var i=ey(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Qg(n,t,i),i};const ny=class xu extends gr(ni){constructor(t,o={}){super();K(this,"type","html");K(this,"source",new Nc);K(this,"element",new Image);K(this,"canvas",document.createElement("canvas"));K(this,"context",this.canvas.getContext("2d"));K(this,"sprite",new mt.Sprite);this.view.addChild(this.sprite),Object.assign(this,o),t instanceof Nc&&(this.source=t),t instanceof File&&this.source.from(t),this.element.addEventListener("load",()=>{var s,l,c,d;const i=(l=(s=this.source.document)==null?void 0:s.body)==null?void 0:l.scrollWidth,r=(d=(c=this.source.document)==null?void 0:c.body)==null?void 0:d.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=mt.Texture.from(this.canvas,!0),this.trigger("load",void 0))}),this.element.addEventListener("error",i=>{this.state="ERROR",this.trigger("error",new Gn({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,o)=>{this.element.onload=()=>{var s,l,c,d;const i=(l=(s=this.source.document)==null?void 0:s.body)==null?void 0:l.scrollWidth,r=(d=(c=this.source.document)==null?void 0:c.body)==null?void 0:d.scrollHeight;if(!i||!r)return o(new Gn({code:"sourceNotProcessable",message:"Cannot display source with height or width at 0"}));this.state="READY",t()},this.element.onerror=i=>{o(new Gn({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=xu.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};ty([yr],ny.prototype,"update");const Su=["DEFAULT","STACK"];class Ic{constructor(){K(this,"mode",Su[0]);K(this,"pauseAlignmet",!1)}add(n,t){let o=!0;for(let i=0;i<t.clips.length&&(o=Dc(n,t.clips[i]),!!o);i++)$c(n,t.clips[i]);o&&(t.clips.push(n),t.clips.sort(Fc))}update(n,t){if(!this.pauseAlignmet){t.clips.sort(Fc);for(let o=0;o<t.clips.length;o++)if(n.id!=t.clips[o].id){if(!Dc(n,t.clips[o]))break;$c(n,t.clips[o])}}}offset(n,t){this.pauseAlignmet=!0;for(const o of t.clips)o.offsetBy(n);this.pauseAlignmet=!1}}class ay{constructor(){K(this,"mode",Su[1])}add(n,t,o=void 0){var r;let i=-1;(o!=null&&o>0||o==null)&&(i=((r=t.clips.at((o??0)-1))==null?void 0:r.stop.millis)??-1),n.offsetBy(new Fe(i-n.start.millis+1)),o==null?t.clips.push(n):(t.clips.splice(o,0,n),t.clips.slice(o+1).forEach(s=>{s.offsetBy(n.stop.subtract(n.start))}))}update(n,t){let o=0;for(const i of t.clips){if(i.start.millis!=o){const r=o-i.start.millis;i.offsetBy(new Fe(r))}o=i.stop.millis+1}}offset(){}}function Fc(a,n){return a.start.millis-n.start.millis}function $c(a,n){a.start.millis>=n.start.millis&&a.start.millis<=n.stop.millis&&(a.start=n.stop.copy().addMillis(1)),a.stop.millis>=n.start.millis&&a.stop.millis<=n.stop.millis&&(a.stop=n.start.copy().addMillis(-1))}function Dc(a,n){var t,o,i,r,s;if(a.start.millis>=n.start.millis&&a.stop.millis<=n.stop.millis){const l=(o=(t=n.track)==null?void 0:t.composition)==null?void 0:o.tracks.find(c=>c.type==a.type&&!c.clips.some(d=>a.id!=d.id&&a.start.millis>=d.start.millis&&a.stop.millis<=d.stop.millis));return l?(l.add(a.detach()),!1):((s=(r=(i=n.track)==null?void 0:i.composition)==null?void 0:r.createTrack(a.type))==null||s.add(a.detach()),!1)}return!0}class mo extends ei(wn){constructor(){super(...arguments);K(this,"_disabled",!1);K(this,"view",new mt.Container);K(this,"clips",[]);K(this,"pointer",0);K(this,"composition");K(this,"type","base");K(this,"strategy",new Ic)}get disabled(){return this._disabled}set disabled(t){var o;t&&this.clipRef&&us(this.clipRef)&&(this.view.removeChild(this.clipRef.view),(o=this.clipRef)==null||o.exit()),this._disabled=t,this.trigger("update",void 0)}connect(t){this.composition=t}stacked(t=!0){return t?(this.strategy=new ay,this.strategy.update(new ni,this)):this.strategy=new Ic,this.trigger("update",void 0),this}layer(t){var l,c;const o=((l=this.composition)==null?void 0:l.tracks)??[],i=o.findIndex(d=>d.id==this.id),r=o.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,mg(o,i,s),(c=this.composition)==null||c.stage.setChildIndex(this.view,r-s),this.trigger("update",void 0),this}seek(t){}offsetBy(t){return typeof t=="number"?this.strategy.offset(Fe.fromFrames(t),this):this.strategy.offset(t,this),this}update(t){var i,r;if(this.disabled||!this.clips.length)return;const{millis:o}=t;if(us(this.clipRef)&&(!ds(o,this.clipRef)||(i=this.clipRef)!=null&&i.disabled)&&(this.clipRef&&this.view.removeChild(this.clipRef.view),(r=this.clipRef)==null||r.exit()),!!ds(o,this))for(let s=0;s<this.clips.length;s++){const l=(this.pointer+s)%this.clips.length,c=this.clips[l],d=this.clips[l-1];if(ds(o,c)&&!c.disabled)return this.pointer=l,us(c)||(c.enter(),this.view.addChild(c.view)),c.update(t);if(o<c.start.millis&&o>((d==null?void 0:d.stop.millis)??0)){this.pointer=l;return}}}async add(t,o){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,o),t.on("frame",()=>{this.strategy.update(t,this)}),t.bubble(this),this.trigger("attach",void 0),t}remove(t){const o=this.clips.findIndex(i=>i.id==t.id);if(t.state=="ATTACHED"&&(t.state="READY"),t.view.parent&&this.view.removeChild(t.view),o!=null&&o>=0)return this.clips.splice(o,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 Fe}get start(){var t;return((t=this.clips.at(0))==null?void 0:t.start)??new Fe}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 ds(a,n){return n?a>=n.start.millis&&a<=n.stop.millis:!1}function us(a){return a?!!a.view.parent:!1}class oy{static fromType(n){switch(n.type){case"video":return new iy;case"audio":return new sy;case"html":return new ly;case"image":return new ry;case"text":return new Rc;case"complex_text":return new Rc;case"caption":return new dy;default:return new mo}}}class Cu extends mo{constructor(){super(...arguments);K(this,"clips",[])}async seek(t){for(const o of this.clips)await o.seek(t)}async removeSilences(t={}){const o=[];for(const i of this.clips.map(r=>r.detach()))o.push(...await i.removeSilences(t));for(const i of o)await this.add(i)}}class iy extends Cu{constructor(){super(...arguments);K(this,"type","video")}async seek(t){var o;(o=this.composition)!=null&&o.rendering?this.view.removeChildren():super.seek(t)}}class ry extends mo{constructor(){super(...arguments);K(this,"type","image")}}class sy extends Cu{constructor(){super(...arguments);K(this,"type","audio")}}class Rc extends mo{constructor(){super(...arguments);K(this,"type","text")}}class ly extends mo{constructor(){super(...arguments);K(this,"type","html")}}var cy=Object.defineProperty,Vl=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&cy(n,t,i),i};class oi extends wn{constructor(t={}){super();K(this,"generatorOptions");K(this,"type","CLASSIC");K(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 Nt({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((l=t.clip)==null?void 0:l.offset)??new Fe,i=await Zt.fromFamily({family:"Figtree",weight:"700"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))await t.add(new co({text:c.words.map(d=>d.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:c.stop.add(o),start:c.start.add(o),scale:new Le([0,8],[.96,1],{easing:"easeOut"}),alpha:new Le([0,4],[0,1],{easing:"easeOut"})}))}}Vl([Te()],oi.prototype,"generatorOptions");Vl([Te()],oi.prototype,"type");Vl([Te()],oi.prototype,"position");class dy extends mo{constructor(){super(...arguments);K(this,"clip");K(this,"type","caption");K(this,"preset",new oi)}from(t){var o;return this.clip=t,(o=this.clip)==null||o.on("offsetBy",i=>this.offsetBy(i.detail)),this}async generate(t){let o=this.preset;return typeof t=="object"?o=t:t&&(o=new t),this.clips=[],this.trigger("update",void 0),this.preset=o,await o.applyTo(this),this.trigger("update",void 0),this}}var uy=Object.defineProperty,kr=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&uy(n,t,i),i};class ii extends wn{constructor(t={}){super();K(this,"generatorOptions");K(this,"type","SPOTLIGHT");K(this,"color");K(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 Nt({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((l=t.clip)==null?void 0:l.offset)??new Fe,i=await Zt.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=c.words.map(f=>f.text);await t.add(new wr({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:c.words.length>1?[{index:0,start:u.slice(0,d).join(" ").length,stop:u.slice(0,d+1).join(" ").length}]:void 0,stop:c.words[d].stop.add(o),start:c.words[d].start.add(o)}))}}}kr([Te()],ii.prototype,"generatorOptions");kr([Te()],ii.prototype,"type");kr([Te()],ii.prototype,"color");kr([Te()],ii.prototype,"position");var my=Object.defineProperty,Nl=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&my(n,t,i),i};class _r extends wn{constructor(t={}){super();K(this,"type","GUINEA");K(this,"colors");K(this,"position");this.colors=t.colors??["#1BD724","#FFEE0C","#FF2E17"],this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var r,s,l,c,d,u,f;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new Nt({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((l=t.clip)==null?void 0:l.offset)??new Fe,i=await Zt.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const p of t.clip.transcript.iter({length:[18]})){const{segments:m,words:h}=this.splitSequence(p);for(let g=0;g<p.words.length;g++){const k=(d=(c=h[g])==null?void 0:c.at(0))==null?void 0:d.start,$=(f=(u=h[g])==null?void 0:u.at(-1))==null?void 0:f.stop;!k||!$||await t.add(new wr({text:m.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:$.add(o),start:k.add(o),styles:[{fillStyle:this.colors[0],fontSize:23},{fillStyle:this.colors[1],fontSize:23},{fillStyle:this.colors[2],fontSize:23}],segments:[{index:Wi(0,2),start:m.slice(0,g).join(" ").length,stop:m.slice(0,g+1).join(" ").length+g*2}]}))}}}splitSequence(t){const o=t.text,i=Math.ceil(o.length/2);let r=o.length;for(let c=i,d=i;c>0&&d<t.text.length-1;c--,d++){if(o[c].match(/ /)){r=c;break}if(o[d].match(/ /)){r=d;break}}const s=[...kc(o,r).map(c=>c.trim())],l=kc(t.words,s[0].split(/ /).length);return{segments:s,words:l}}}Nl([Te()],_r.prototype,"type");Nl([Te()],_r.prototype,"colors");Nl([Te()],_r.prototype,"position");var py=Object.defineProperty,Tl=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&py(n,t,i),i};class Er extends wn{constructor(t={}){super();K(this,"generatorOptions");K(this,"type","CASCADE");K(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 Nt({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((l=t.clip)==null?void 0:l.offset)??new Fe,i=await Zt.fromFamily({family:"Geologica",weight:"400"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=()=>c.words.length==1?c.text:c.words.map(f=>f.text).slice(0,d+1).join(" ");await t.add(new co({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:c.words[d].stop.add(o),start:c.words[d].start.add(o)}))}}}Tl([Te()],Er.prototype,"generatorOptions");Tl([Te()],Er.prototype,"type");Tl([Te()],Er.prototype,"position");var fy=Object.defineProperty,Ml=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&fy(n,t,i),i};class xr extends wn{constructor(t={}){super();K(this,"generatorOptions");K(this,"type","SOLAR");K(this,"position");this.generatorOptions=t.generatorOptions??{duration:[.2]},this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var s,l,c;if(!((s=t.clip)!=null&&s.transcript)||!((l=t.composition)!=null&&l.width))throw new Nt({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=await Zt.fromFamily({family:"Urbanist",weight:"800"}).load(),i=((c=t.clip)==null?void 0:c.offset)??new Fe,r=new Hp.GlowFilter({color:"#fffe41",alpha:.25,distance:90,quality:.05});for(const d of t.clip.transcript.iter(this.generatorOptions))await t.add(new co({text:d.words.map(u=>u.text).join(" "),textAlign:"center",textBaseline:"middle",fontSize:19,fillStyle:"#fffe41",font:o,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:d.stop.add(i),start:d.start.add(i),scale:new Le([0,8],[.96,1],{easing:"easeOut"}),alpha:new Le([0,4],[0,1],{easing:"easeOut"}),filters:r}))}}Ml([Te()],xr.prototype,"generatorOptions");Ml([Te()],xr.prototype,"type");Ml([Te()],xr.prototype,"position");var hy=Object.defineProperty,Sr=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&hy(n,t,i),i};class ri extends wn{constructor(t={}){super();K(this,"generatorOptions");K(this,"type","WHISPER");K(this,"color");K(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 Nt({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((l=t.clip)==null?void 0:l.offset)??new Fe,i=await Zt.fromFamily({family:"Montserrat",weight:"300"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=c.words.map(f=>f.text);await t.add(new wr({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:c.words[d].stop.add(o),start:c.words[d].start.add(o),segments:u.length>1?[{index:0,start:u.slice(0,d+1).join(" ").length}]:void 0}))}}}Sr([Te()],ri.prototype,"generatorOptions");Sr([Te()],ri.prototype,"type");Sr([Te()],ri.prototype,"color");Sr([Te()],ri.prototype,"position");var vy=Object.defineProperty,Cr=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&vy(n,t,i),i};class Vr extends wn{constructor(t={}){super();K(this,"type","VERDANT");K(this,"generatorOptions");K(this,"color");K(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 Nt({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((l=t.clip)==null?void 0:l.offset)??new Fe,i=await Zt.fromFamily({family:"Montserrat",weight:"800"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=c.words.map(f=>f.text);await t.add(new wr({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:c.words[d].stop.add(o),start:c.words[d].start.add(o),segments:[{index:0,start:u.slice(0,d).join(" ").length,stop:u.slice(0,d+1).join(" ").length}]}))}}}Cr([Te()],Vr.prototype,"type");Cr([Te()],Vr.prototype,"generatorOptions");Cr([Te()],Vr.prototype,"color");Cr([Te()],Vr.prototype,"position");class gy extends ei(wn){constructor({height:t=1080,width:o=1920,background:i="#000000",backend:r="webgpu"}={}){super();K(this,"_duration",new Fe);K(this,"renderer");K(this,"stage",new mt.Container);K(this,"settings");K(this,"tracks",[]);K(this,"frame",0);K(this,"fixedDuration");K(this,"state","IDLE");K(this,"fps",Xo);K(this,"canvas");K(this,"context");this.settings={height:t,width:o,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)),mt.autoDetectRenderer({...this.settings,preference:r}).then(s=>{this.renderer=s,this.trigger("init",void 0)}).catch(s=>{this.trigger("error",new ro({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 o;t?t instanceof Fe?this.fixedDuration=t:this.fixedDuration=Fe.fromFrames(t):this.fixedDuration=void 0,this.trigger("frame",((o=this.fixedDuration)==null?void 0:o.frames)??0)}resize(t,o){var i;this.settings.width=t,this.settings.height=o,(i=this.renderer)==null||i.resize(t,o),this.canvas&&(this.canvas.height=o,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 o=typeof t=="object"?t:new t;return o.connect(this),this.stage.addChild(o.view),this.tracks.unshift(o),o.bubble(this),this.trigger("update",void 0),o}createTrack(t){const o=oy.fromType({type:t});return this.shiftTrack(o),o}async add(t){return await this.createTrack(t.type).add(t),t}remove(t){for(const o of this.tracks)if(o.clips.find(i=>i.id==t.id))return o.remove(t)}removeTracks(t){const o=this.tracks.filter(i=>i instanceof t);return this.tracks=this.tracks.filter(i=>!(i instanceof t)),o.forEach(i=>this.removeTrack(i)),o}findTracks(t){return this.tracks.filter(o=>{let i;return _c(t)?i=o instanceof t:i=t(o),i})}findClips(t){const o=[];for(const i of this.tracks)for(const r of i.clips){let s;_c(t)?s=r instanceof t:s=t(r),s&&o.push(r)}return o}computeFrame(){var t,o;if(this.renderer){for(let i=0;i<this.tracks.length;i++)this.tracks[i].update(Fe.fromFrames(this.frame));this.renderer.render(this.stage),(t=this.context)==null||t.clearRect(0,0,this.settings.width,this.settings.height),(o=this.context)==null||o.drawImage(this.renderer.canvas,0,0),this.trigger("currentframe",this.frame),this.playing&&this.frame++}}screenshot(t="png",o=1){if(this.computeFrame(),!this.renderer)throw new ro({code:"rendererNotDefined",message:"Please wait until the renderer is defined"});return this.renderer.canvas.toDataURL(`image/${t}`,o)}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 o of this.tracks)await o.seek(Fe.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(Fe.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,o=48e3){var s;const i=this.duration.seconds*o,r=new OfflineAudioContext({sampleRate:o,length:i,numberOfChannels:t}).createBuffer(t,i,o);for(const l of this.findClips(vr)){if(l.disabled||l.muted||(s=l.track)!=null&&s.disabled)continue;const c=Math.round(l.offset.seconds*r.sampleRate),d=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,o),p=f.numberOfChannels-1;for(let m=0;m<t;m++){const h=r.getChannelData(m),g=f.getChannelData(m>p?p:m);for(let k=0;k<h.length-1;k++)k<c+d||k>c+u||k-c<0||(h[k]+=(g[k-c]??0)*l.volume,h[k]>1&&(h[k]=1),h[k]<-1&&(h[k]=-1));r.getChannelData(m).set(h)}}catch{}}return r}time(t){const o=eo(this.frame),i=t!=null&&t.hours?11:14,r=t!=null&&t.milliseconds?23:19;return new Date(o).toISOString().slice(i,r)+" / "+new Date(this.duration.millis).toISOString().slice(i,r)}removeTrack(t){const o=this.tracks.findIndex(i=>i.id==t.id);if(t.view.parent&&this.stage.removeChild(t.view),o!=null&&o>=0)return this.tracks.splice(o,1),this.trigger("detach",void 0),t.off("*"),t}async ticker(){const t=1e3/Xo;let o=performance.now(),i=0;do{const r=await new Promise(requestAnimationFrame);r-o<t-i||(i=Math.min(t,i+r-o-t),o=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 o;return((o=t.stop)==null?void 0:o.frames)??0}),0),this.computeFrame()}}function yy(a,n){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]=n,t[10]=0,t[11]=0,t[12]=a&255,t[13]=a>>8&255,t[14]=a>>16&255,t[15]=a>>24&255,t[16]=0,t[17]=0,t[18]=0,t}const Os=[8e3,12e3,16e3,24e3,48e3],by="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.wasm",wy="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.js";class ky{constructor(n){K(this,"output");K(this,"error");K(this,"config");K(this,"encoder");K(this,"opus");K(this,"meta");this.output=n.output,this.error=n.error}async configure(n){const t=await import(wy),{numberOfChannels:o,sampleRate:i}=this.config=n;if(!Os.includes(i))throw new ir({code:"sampleRateNotSupported",message:`Unsupported sample rate, supported: ${Os.join()}`});this.opus=await t.default({locateFile(r,s){return r.endsWith(".wasm")?by:s+r}}),this.encoder=this.opus._opus_encoder_create(i,o,2048),this.meta={decoderConfig:{codec:"opus",description:yy(i,o).buffer,numberOfChannels:o,sampleRate:i}}}encode({data:n,numberOfFrames:t,timestamp:o=0}){if(!this.encoder||!this.opus||!this.config||!this.meta)throw new ir({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 c=s/i*1e6;for(;l<t;){const d=n.subarray(l*r,(l+s)*r),u=this.opus._malloc(d.length*2);this.opus.HEAP16.set(d,u>>1);const f=4e3,p=this.opus._malloc(f),m=this.opus._opus_encode(this.encoder,u,s,p,f);if(m>0){const h=new Uint8Array(this.opus.HEAPU8.subarray(p,p+m));this.output({data:h,timestamp:o,type:"key",duration:c},this.meta)}else this.error(new DOMException("PCM chunk could not be encoded"));this.opus._free(u),this.opus._free(p),l+=s,o+=c}}}function _y(a){const n=Os;let t=48e3;for(const o of n)Math.abs(a-o)<Math.abs(a-t)&&(t=o);return t}class Ey{constructor(n,t){K(this,"canvas");K(this,"muxer");K(this,"videoEncoder");K(this,"frame",0);K(this,"sampleRate");K(this,"numberOfChannels");K(this,"videoBitrate");K(this,"gpuBatchSize");K(this,"fps");K(this,"height");K(this,"width");K(this,"audio");this.canvas=n,this.width=n.width,this.height=n.height,this.fps=(t==null?void 0:t.fps)??30,this.sampleRate=_y((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 n=await hg({height:Math.round(this.height),width:Math.round(this.width),bitrate:this.videoBitrate,fps:this.fps});this.muxer=new mu({target:new gl,video:{...n[0],codec:"avc"},firstTimestampBehavior:"offset",fastStart:"in-memory",audio:this.audio?{numberOfChannels:this.numberOfChannels,sampleRate:this.sampleRate,codec:"opus"}:void 0});const t={output:(o,i)=>{i&&this.muxer.addVideoChunk(o,i)},error:console.error};this.videoEncoder=new VideoEncoder(t),this.videoEncoder.configure(n[0])}async encodeVideo(n){var o;this.videoEncoder||await this.init(),this.videoEncoder.encodeQueueSize>this.gpuBatchSize&&await new Promise(i=>{this.videoEncoder.ondequeue=()=>i(null)});const t=new VideoFrame(n??this.canvas,{timestamp:Math.floor(this.frame/this.fps*1e6),duration:Math.floor(1e6/this.fps)});(o=this.videoEncoder)==null||o.encode(t,{keyFrame:this.frame%(3*this.fps)==0}),t.close(),this.frame++}async encodeAudio(n){if(!this.audio)throw new ir({code:"initializationError",message:"Encoder must be initialized using {audio: true} to use this method"});this.muxer||await this.init();const t=fg(n,this.sampleRate,this.numberOfChannels),o=new ky({output:(i,r)=>{var s;(s=this.muxer)==null||s.addAudioChunkRaw(i.data,i.type,i.timestamp,i.duration,r)},error:console.error});await o.configure({numberOfChannels:this.numberOfChannels,sampleRate:this.sampleRate}),o.encode({data:pg(t),numberOfFrames:t.length})}async blob(){var t,o,i;await((t=this.videoEncoder)==null?void 0:t.flush()),(o=this.muxer)==null||o.finalize();const n=(i=this.muxer)==null?void 0:i.target.buffer;if(!n)throw new ir({code:"unexpectedRenderError",message:"Muxer could not be finalized because the target buffer is not defined"});return new Blob([n],{type:"video/mp4"})}async export(){return this.blob()}}async function xy(a){var o,i;const n=(o=a.metadata)==null?void 0:o.source_url;if(n)return n;const t=(i=a.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 Zo=class Zo{constructor(n){this.transitions=new Map,this.nextId=0,this.composition=n}async applyTransition(n,t,o){const i=`transition-${this.nextId++}`,r=Math.round(o.duration*30),s=o.easing||"linear",l=this.findTrackForClip(n),c=this.findTrackForClip(t);if(!l||!c)throw new Error("Clips must be added to composition before applying transitions");const d=n.stop.frames-r,u=n.stop.frames;switch(o.type){case"fade":await this.applyFadeTransition(n,t,d,u,s);break;case"dissolve":case"cross-fade":await this.applyCrossFadeTransition(n,t,d,u,s);break;case"wipe-left":case"wipe-right":case"wipe-up":case"wipe-down":await this.applyWipeTransition(n,t,o.type,d,u,s);break;case"slide-left":case"slide-right":case"slide-up":case"slide-down":await this.applySlideTransition(n,t,o.type,d,u,s);break;case"zoom-in":case"zoom-out":await this.applyZoomTransition(n,t,o.type,d,u,s);break;case"dip-to-black":case"dip-to-white":await this.applyDipTransition(n,t,o.type,d,u,s);break}return this.transitions.set(i,o),i}async applyFadeTransition(n,t,o,i,r){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Fade transitions require VideoClip instances");n.alpha=new Le([o,i],[1,0],{easing:r}),t.alpha=new Le([o,i],[0,1],{easing:r}),t.start=Fe.fromFrames(o)}async applyCrossFadeTransition(n,t,o,i,r){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Cross-fade transitions require VideoClip instances");n.alpha=new Le([o,i],[1,0],{easing:r}),t.alpha=new Le([o,i],[0,1],{easing:r}),t.start=Fe.fromFrames(o)}async applyWipeTransition(n,t,o,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Wipe transitions require VideoClip instances");const l={x:0,y:0},c={x:0,y:0};switch(o){case"wipe-left":l.x=new Le([i,r],[0,-1920],{easing:s}),c.x=new Le([i,r],[1920,0],{easing:s});break;case"wipe-right":l.x=new Le([i,r],[0,1920],{easing:s}),c.x=new Le([i,r],[-1920,0],{easing:s});break;case"wipe-up":l.y=new Le([i,r],[0,-1080],{easing:s}),c.y=new Le([i,r],[1080,0],{easing:s});break;case"wipe-down":l.y=new Le([i,r],[0,1080],{easing:s}),c.y=new Le([i,r],[-1080,0],{easing:s});break}n.translate=l,t.translate=c,t.start=Fe.fromFrames(i)}async applySlideTransition(n,t,o,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Slide transitions require VideoClip instances");const l={x:0,y:0},c={x:0,y:0};switch(o){case"slide-left":l.x=new Le([i,r],[0,-1920],{easing:s}),c.x=new Le([i,r],[1920,0],{easing:s});break;case"slide-right":l.x=new Le([i,r],[0,1920],{easing:s}),c.x=new Le([i,r],[-1920,0],{easing:s});break;case"slide-up":l.y=new Le([i,r],[0,-1080],{easing:s}),c.y=new Le([i,r],[1080,0],{easing:s});break;case"slide-down":l.y=new Le([i,r],[0,1080],{easing:s}),c.y=new Le([i,r],[-1080,0],{easing:s});break}n.translate=l,t.translate=c,t.start=Fe.fromFrames(i)}async applyZoomTransition(n,t,o,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Zoom transitions require VideoClip instances");o==="zoom-in"?(n.scale=new Le([i,r],[1,2],{easing:s}),n.alpha=new Le([i,r],[1,0],{easing:s}),t.scale=new Le([i,r],[.5,1],{easing:s}),t.alpha=new Le([i,r],[0,1],{easing:s})):(n.scale=new Le([i,r],[1,.5],{easing:s}),n.alpha=new Le([i,r],[1,0],{easing:s}),t.scale=new Le([i,r],[2,1],{easing:s}),t.alpha=new Le([i,r],[0,1],{easing:s})),t.start=Fe.fromFrames(i)}async applyDipTransition(n,t,o,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Dip transitions require VideoClip instances");const l=Math.round((i+r)/2),c=o==="dip-to-black"?"#000000":"#ffffff",d=await Rs.fromColor(c),u=new Dg(d,{start:Fe.fromFrames(i),stop:Fe.fromFrames(r)});n.alpha=new Le([i,l],[1,0],{easing:s}),u.alpha=new Le([i,l,r],[0,1,0],{easing:s}),t.alpha=new Le([l,r],[0,1],{easing:s}),await this.composition.add(u),t.start=Fe.fromFrames(l)}findTrackForClip(n){for(const t of this.composition.tracks)if(t.clips.includes(n))return t}removeTransition(n){this.transitions.delete(n)}getTransitions(){return new Map(this.transitions)}static getAvailableTransitions(){return[...Zo.TRANSITIONS]}static previewTransition(n){return Zo.TRANSITIONS.find(t=>t.type===n)}isVideoClip(n){return"alpha"in n&&"scale"in n&&"translate"in n}};Zo.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 Go=Zo;function Sn(a,n){if(typeof a=="number"&&Number.isFinite(a))return a;if(typeof a=="string"){const t=Number(a);if(Number.isFinite(t))return t}return n}function Ni(a){return a>5?a/100:a}function Cn(a,n,t){return Math.min(t,Math.max(n,a))}function Yt(){return new Vt.ColorMatrixFilter}function Sy(a,n){switch(a){case"brightness":{const t=Yt(),o=Sn(n.value??n.brightness,1);return t.brightness(Cn(Ni(o),0,5),!1),t}case"contrast":{const t=Yt(),o=Sn(n.value??n.contrast,1);return t.contrast(Cn(Ni(o),0,5),!1),t}case"saturation":{const t=Yt(),o=Sn(n.value??n.saturation,1);return t.saturate(Cn(Ni(o),0,5),!1),t}case"hue":{const t=Yt(),o=Sn(n.degrees??n.value,0);return t.hue(Cn(o,-180,180),!1),t}case"blur":case"softFocus":{const t=a==="softFocus"?1:0,o=Sn(n.radius??n.blur??n.value,t);return new Vt.BlurFilter({strength:Cn(o,0,32),quality:4})}case"grayscale":{const t=Yt(),o=Cn(Sn(n.amount,100),0,100);return o<=0?null:(o>=100?t.desaturate():t.saturate(1-o/100,!1),t)}case"sepia":{if(Cn(Sn(n.amount,100),0,100)<=0)return null;const o=Yt();return o.sepia(!1),o}case"invert":{if(Cn(Sn(n.amount,100),0,100)<=0)return null;const o=Yt();return o.negative(!1),o}case"warmth":{const t=Yt(),o=Cn(Sn(n.value,0),-50,50);return o>0?(t.sepia(!1),t.saturate(1+o/100,!1)):o<0&&t.hue(Math.abs(o)/50*-20,!1),t}case"tint":{const t=Yt(),o=Cn(Sn(n.intensity,.3),0,1),i=typeof n.color=="string"?n.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,c=parseInt(r.slice(4,6),16)/255;t.matrix=[1-o+o*s,0,0,0,0,0,1-o+o*l,0,0,0,0,0,1-o+o*c,0,0,0,0,0,1,0]}return t}case"vintage":{const t=Yt();return t.sepia(!1),t.saturate(1.4,!1),t.contrast(1.1,!1),t}case"blackAndWhite":{const t=Yt(),o=Cn(Ni(Sn(n.contrast,120)),.5,3);return t.desaturate(),t.contrast(o,!1),t}case"cinematic":{const t=Yt();return t.contrast(1.2,!1),t.brightness(.95,!1),t.saturate(.85,!1),t}case"dramatic":{const t=Yt();return t.contrast(1.4,!1),t.brightness(.9,!1),t.saturate(1.1,!1),t.sepia(!1),t}case"dreamy":{const t=Yt();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=Vt);class Vu{constructor(n=1920,t=1080,o=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=o,this.fitMode=(i==null?void 0:i.fitMode)??"contain",this.composition=new gy({width:n,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 c,d,u,f;const l=this.composition;((d=(c=l==null?void 0:l.app)==null?void 0:c.renderer)!=null&&d.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(...n){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(n){this.player=n,this.isDebug()&&this.dbg("attachPlayer:begin",{w:n.clientWidth,h:n.clientHeight}),this.composition.attachPlayer(n),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 o;const n=(o=this.player)==null?void 0:o.parentElement;if(!this.player||!n)return;const t=Math.min(n.clientWidth/this.composition.width,n.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(n){var o,i,r;await this.initPromise,this.clips.clear(),this.recipeSourceDimensions=Number.isFinite((o=n.source)==null?void 0:o.original_width)&&n.source.original_width>0&&Number.isFinite((i=n.source)==null?void 0:i.original_height)&&n.source.original_height>0?{width:n.source.original_width,height:n.source.original_height}:null;const t=await xy(n);for(const s of n.timeline)await this.addTimelineClip(s,t);if(n.textOverlays)for(const s of n.textOverlays)await this.addTextOverlay(s);await new Promise(s=>requestAnimationFrame(s));for(const s of n.timeline)(r=s.filters)!=null&&r.length&&this.applyFiltersToClip(s.id,s.filters);n.transitions&&n.transitions.length>0&&await this.applyTransitionsToClips(n.transitions),this.composition.seek(0),this.applyFitModeToClips(),this.composition.computeFrame()}async applyTransitionsToClips(n){const t=new Go(this.composition);for(const o of n){if(o.type==="cut")continue;const i=this.clips.get(o.fromClipId),r=this.clips.get(o.toClipId),s=this.mapTransitionType(o.type);if(!i||!r||!s)continue;const l={type:s,duration:o.duration,easing:this.mapTransitionEasing(o.easing)};try{await t.applyTransition(i,r,l)}catch{}}}mapTransitionType(n){switch(n){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(n){switch(n){case"ease-in":return"easeIn";case"ease-out":return"easeOut";case"ease-in-out":return"easeInOut";case"linear":return"linear"}}async addTimelineClip(n,t){var o,i;try{const r=n.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((o=xa.from)==null?void 0:o.call(xa,r,{crossOrigin:"anonymous"}))??await xa.from(r),l=new Ls(s,{muted:n.muted||!1,scale:n.scale||1,position:"center"});let c=0,d=null;if(n.sourceIn!==void 0||n.sourceOut!==void 0){const p=Math.max(0,Math.floor((n.sourceIn||0)*this.fps)),m=n.sourceOut!==void 0?Math.max(p+1,Math.floor(n.sourceOut*this.fps)):null;c=p,d=m;try{if(l.offset=l.offset||{frames:0},l.offset.frames=p,m!==null){const h=Math.max(1,m-p);l.duration=l.duration||{frames:h},l.duration.frames=h}}catch{}}const u=await this.composition.add(l);if(d!==null&&c>=0)try{const p=Math.max(1,d-c);u.offset=u.offset||{frames:0},u.offset.frames=c,u.duration=u.duration||{frames:p},u.duration.frames=p}catch{}const f=Math.floor(n.timelineStart*this.fps);f>0&&u.offsetBy(f),this.clipTimelineStart.set(n.id,n.timelineStart),this.applyFitToClip(u),this.clips.set(n.id,u),(i=n.filters)!=null&&i.length&&(await new Promise(p=>requestAnimationFrame(p)),this.applyFiltersToClip(n.id,n.filters))}catch{}}async addTextOverlay(n){try{const t=Zt.fromFamily({family:n.fontFamily||"Arial",weight:n.fontWeight||"400"}),o=new co({text:n.content,font:t,fontSize:n.fontSize||34,position:n.position||"center",fillStyle:n.color||"#FFFFFF",textAlign:n.textAlign||"center",textBaseline:n.textBaseline||"middle"});if(n.animation){const r=n.animation.duration||1,s=0,l=r*this.fps,c=n.animation.easing||"linear";n.animation.type==="rotate"&&n.animation.rotation?o.rotation=new Le([s,l],[n.animation.rotation.from,n.animation.rotation.to],{easing:c}):n.animation.type==="scale"&&n.animation.scale&&(o.scale=new Le([s,l],[n.animation.scale.from,n.animation.scale.to],{easing:c}))}n.startTime&&n.startTime>0&&o.offsetBy(n.startTime*this.fps),n.duration&&o.subclip(0,n.duration*this.fps);const i=await this.composition.add(o);this.clips.set(n.id||`text-${Date.now()}`,i)}catch{}}applyFiltersToClip(n,t){const o=this.clips.get(n);if(!o)return;const i=this.filterCache.get(n)??new Map,r=new Set(t.map(c=>c.id));for(const[c,d]of i.entries())if(!r.has(c)){try{typeof d.instance.destroy=="function"&&d.instance.destroy()}catch{}i.delete(c)}const s=[];for(const c of t){const d=this.buildFilterSignature(c),u=i.get(c.id);let f=null;if(u&&u.signature===d)f=u.instance;else{if(u)try{u.instance.destroy()}catch{}f=this.createPixiFilter(c),f?i.set(c.id,{instance:f,signature:d}):i.delete(c.id)}f&&s.push(f)}this.filterCache.set(n,i);const l=o.view??o.sprite??o.displayObject??null;if("filters"in o)try{o.filters=s}catch{}if(l&&"filters"in l)try{l.filters=s}catch{}typeof o.enter=="function"&&o.enter()}buildFilterSignature(n){const t=typeof n.params=="object"&&n.params!==null?n.params:{},o=Object.keys(t).sort((i,r)=>i.localeCompare(r)).map(i=>[i,t[i]]);return JSON.stringify({filterId:n.filterId,intensity:n.intensity??1,params:o})}setClipFilters(n,t){this.applyFiltersToClip(n,t),this.composition.computeFrame()}createPixiFilter(n){const t=n.intensity??1,o=n.params||{};if(pe.getFilter(n.filterId)&&!pe.isFilterCompatibleWithMedia(n.filterId,"video"))return null;let r=sf(n.filterId,o);return r||(r=Sy(n.filterId,o)),r?(t!==1&&r&&(n.filterId==="colorOverlay"||n.filterId==="alpha"||("alpha"in r&&!o.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(n){this.composition.seek(n)}seekToTime(n){this.composition.seek(n*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(n={}){var s,l,c,d,u,f,p,m,h;const t=n.fps??this.fps,o=this.composition.canvas??((l=(s=this.composition)==null?void 0:s.renderer)==null?void 0:l.view)??((u=(d=(c=this.composition)==null?void 0:c.app)==null?void 0:d.renderer)==null?void 0:u.view)??((p=(f=this.composition)==null?void 0:f.renderer)==null?void 0:p.canvas);if(!o)throw new Error("Export failed: composition canvas is not initialized");(m=n.onProgress)==null||m.call(n,0);const i=new Ey(o,{fps:t});await i.init();const r=await i.export();return(h=n.onProgress)==null||h.call(n,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 n=()=>{(this.composition.state==="PLAY"||this.composition.frame!==this.lastRenderedFrame)&&(this.composition.computeFrame(),this.lastRenderedFrame=this.composition.frame),this.animationFrameId=requestAnimationFrame(n)};n()}stopRenderLoop(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null,this.isDebug()&&this.dbg("renderLoop:stop"))}moveClip(n,t){const o=this.clips.get(n);if(!o)return;const i=this.clipTimelineStart.get(n)||0,r=t-i;r!==0&&(o.offsetBy(r*this.fps),this.clipTimelineStart.set(n,t),this.composition.computeFrame())}setFitMode(n){this.fitMode=n,this.applyFitModeToClips()}applyFitModeToClips(){for(const n of this.clips.values())"scale"in n&&typeof n.scale<"u"&&this.applyFitToClip(n);this.composition.computeFrame()}applyFitToClip(n){var t,o;if(this.fitMode!=="none")try{const i=this.composition.width,r=this.composition.height,s=n.source,l=(s==null?void 0:s.width)??(s==null?void 0:s.videoWidth)??((t=this.recipeSourceDimensions)==null?void 0:t.width),c=(s==null?void 0:s.height)??(s==null?void 0:s.videoHeight)??((o=this.recipeSourceDimensions)==null?void 0:o.height);if(!l||!c)return;const d=Math.min(i/l,r/c),u=Math.max(i/l,r/c),f=this.fitMode==="contain"?d:u;n.scale=f}catch{}}trimClip(n,t,o){const i=this.clips.get(n);if(!i)return;const r=Math.max(0,Math.floor(t*this.fps)),s=Math.max(r+1,Math.floor(o*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(n){var t,o;for(const[i,r]of this.clips.entries()){const s=this.clipTimelineStart.get(i)||0,l=Math.floor(s*this.fps),c=((t=r.duration)==null?void 0:t.frames)??Math.round(r.duration.seconds*this.fps),d=l+c;if(n>=l&&n<d){const u=n-l;return{sourceFrame:(((o=r.offset)==null?void 0:o.frames)??0)+u,clipId:i}}}return{sourceFrame:0,clipId:null}}}const Cy=["src"],Vy={class:"preview-controls"},Ny=["aria-label"],Ty={class:"time-display"},My={class:"current-time"},By={class:"total-time"},Iy={key:2,class:"loading-overlay"},Fy={key:3,class:"error-overlay"},$y=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(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(),s=e.ref(),l=e.ref(!1),c=e.ref("Initializing..."),d=e.ref(null),u=e.ref(!1),f=e.ref(0),p=e.ref(0);let m=null;const h=e.computed(()=>!!t.enableEngine&&!!t.recipe),g=e.computed(()=>{switch(t.fitMode){case"cover":return"cover";case"none":return"none";default:return"contain"}}),k=e.computed(()=>{var E,A;return(E=t.media)!=null&&E.url?t.media.url:(((A=t.media)==null?void 0:A.file)instanceof File,"")});async function $(){var E,A,N;if(!(!r.value||!t.recipe))try{l.value=!0,c.value="Initializing video engine...";const z=((E=t.recipe.source)==null?void 0:E.original_width)||1920,P=((A=t.recipe.source)==null?void 0:A.original_height)||1080,B=((N=t.recipe.output)==null?void 0:N.fps)||30;m=new Vu(z,P,B,{fitMode:t.fitMode}),m.attachPlayer(r.value),c.value="Loading composition...",await m.loadFromRecipe(t.recipe),p.value=m.durationInSeconds,o("duration-change",p.value),D(),l.value=!1,o("engine-ready",m),t.autoPlay&&(m.play(),u.value=!0)}catch(z){const P=z instanceof Error?z.message:String(z);d.value=`Failed to initialize: ${P}`,l.value=!1}}function D(){if(!m)return;const E=setInterval(()=>{m&&u.value&&(f.value=m.currentTimeInSeconds,o("time-update",f.value))},100);j.value=E}function _(){h.value&&m?(u.value?m.pause():m.play(),u.value=!u.value,o("play-state-change",u.value)):s.value&&(u.value?s.value.pause():s.value.play(),u.value=!u.value,o("play-state-change",u.value))}function v(E){const A=Math.floor(E/60),N=Math.floor(E%60);return`${A}:${N.toString().padStart(2,"0")}`}function S(){d.value=null,h.value&&$()}function C(){!h.value&&s.value&&(p.value=s.value.duration,o("duration-change",p.value))}function V(){!h.value&&s.value&&(f.value=s.value.currentTime,o("time-update",f.value))}function x(){u.value=!1,o("play-state-change",!1)}function T(E){d.value="Failed to load video",o("error",d.value)}e.onMounted(()=>{h.value&&t.recipe&&$()}),e.onUnmounted(()=>{m&&(m.destroy(),m=null),j.value&&(clearInterval(j.value),j.value=null),s.value&&(s.value.pause(),s.value.removeAttribute("src"),s.value.load())}),e.watch(()=>t.recipe,async E=>{if(h.value&&E)if(E.timeline,m)try{await m.loadFromRecipe(E),p.value=m.durationInSeconds,o("duration-change",p.value)}catch{}else await $()}),e.watch(()=>t.enableEngine,async E=>{E?(await e.nextTick(),await $()):m&&(j.value&&(clearInterval(j.value),j.value=null),m.destroy(),m=null)}),e.watch(()=>t.fitMode,async E=>{if(!(!h.value||!m))try{m.setFitMode(E||"contain")}catch{}});const j=e.ref(null);return(E,A)=>(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:k.value,onLoadedmetadata:C,onTimeupdate:V,onEnded:x,onError:T,style:e.normalizeStyle({width:"100%",height:"100%",objectFit:g.value}),playsinline:"",controls:""},null,44,Cy)),e.createElementVNode("div",Vy,[e.createElementVNode("button",{class:"play-button",onClick:_,"aria-label":u.value?"Pause":"Play"},[e.createVNode(e.unref(U.IonIcon),{icon:u.value?e.unref(Zd):e.unref(Hd)},null,8,["icon"])],8,Ny),e.createElementVNode("div",Ty,[e.createElementVNode("span",My,e.toDisplayString(v(f.value)),1),A[0]||(A[0]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",By,e.toDisplayString(v(p.value)),1)])]),l.value?(e.openBlock(),e.createElementBlock("div",Iy,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"}),e.createElementVNode("p",null,e.toDisplayString(c.value),1)])):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("div",Fy,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ul)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(d.value),1),e.createElementVNode("button",{onClick:S},"Retry")])):e.createCommentVNode("",!0)],512))}}),Us=Me($y,[["__scopeId","data-v-e199ac48"]]),Dy=["aria-label"],Ry=["aria-label"],Ay={class:"clip-content"},Ly={key:0,class:"clip-thumbnail"},Py=["src","alt"],Oy=["src"],Uy=["data-visual-mode"],zy={class:"clip-info"},jy={class:"clip-label"},Wy={class:"clip-duration"},Zy={key:3,class:"filter-indicators"},Hy={key:4,class:"speed-indicator"},Xy=["aria-label","data-testid"],Gy={key:1,class:"selection-overlay"},Jy=420,Ky=8,Yy=48,qy=32,Ac=1,Qy=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(a,{emit:n}){const t=a,o=n,i=e.ref(null),r=e.ref(!1),s=e.ref(null),l=e.ref(0),c=e.ref(0),d=e.ref(0),u=e.ref(0),f=e.ref(!1),p=e.ref(!1),m=e.ref(null),h=e.computed(()=>{const H=(t.clip.timelineEnd-t.clip.timelineStart)*t.scale;return{left:`${t.clip.timelineStart*t.scale-t.scrollOffset}px`,width:`${H}px`}}),g=e.computed(()=>t.clip.label||`Clip ${t.clip.id.slice(-4)}`),k=e.computed(()=>{const M=t.clip.timelineEnd-t.clip.timelineStart;return V(M)}),$=e.computed(()=>t.clip.filters&&t.clip.filters.length>0),D=e.computed(()=>t.clip.filters||[]),_=e.computed(()=>t.clip.waveformSamples??[]),v=e.computed(()=>t.clip.filmstripFrames??[]),S=e.computed(()=>_.value.length>0),C=e.computed(()=>v.value.length>0);function V(M){if(M<1)return`${Math.round(M*30)}f`;if(M<60)return`${M.toFixed(1)}s`;{const H=Math.floor(M/60),ee=Math.floor(M%60);return`${H}:${ee.toString().padStart(2,"0")}`}}function x(M){return!M||typeof M!="string"?vc:M.includes("color")||M.includes("brightness")?oa:M.includes("blur")?Rf:M.includes("style")?Bo:M.includes("effect")?aa:vc}function T(){r.value||o("select")}function j(M){M.button===0&&(N("move",M.clientX),M.preventDefault())}function E(M){if(M.touches.length!==1)return;const H=M.touches[0];if(!t.isMobile){N("move",H.clientX),M.preventDefault();return}d.value=H.clientX,u.value=H.clientY,f.value=!1,p.value=!1,z(),P(),m.value=window.setTimeout(()=>{p.value=!0,P(),t.selected||o("select"),o("long-press")},Jy),document.addEventListener("touchmove",B),document.addEventListener("touchend",L),document.addEventListener("touchcancel",L),M.preventDefault()}function A(M,H){const ee="touches"in H?H.touches[0].clientX:H.clientX;s.value=M==="start"?"trim-start":"trim-end",N(s.value,ee),H.preventDefault(),H.stopPropagation()}function N(M,H){z(),P(),r.value=!0,s.value=M,l.value=H,M==="move"?c.value=t.clip.timelineStart:M==="trim-start"?c.value=t.clip.sourceIn:M==="trim-end"&&(c.value=t.clip.sourceOut),document.addEventListener("mousemove",w),document.addEventListener("mouseup",Z),document.addEventListener("touchmove",O),document.addEventListener("touchend",Z),t.selected||o("select")}function z(){m.value!==null&&(window.clearTimeout(m.value),m.value=null)}function P(){document.removeEventListener("touchmove",B),document.removeEventListener("touchend",L),document.removeEventListener("touchcancel",L)}function B(M){if(M.touches.length!==1)return;const H=M.touches[0],ee=H.clientX-d.value,ae=H.clientY-u.value;Math.hypot(ee,ae)<Ky||(f.value=!0,z(),P(),N("move",H.clientX),w(M),M.preventDefault())}function L(){const M=!f.value&&!p.value&&!r.value;z(),P(),f.value=!1,p.value=!1,M&&o("select")}function w(M){if(!r.value||!s.value)return;const H="touches"in M?M.touches[0].clientX:M.clientX,ae=H-l.value;s.value==="move"?(o("drag",ae),o("drag-abs",H)):s.value==="trim-start"?(o("trim-start",ae),o("trim-start-abs",H)):s.value==="trim-end"&&(o("trim-end",ae),o("trim-end-abs",H))}function O(M){w(M)}function Z(){r.value=!1,s.value=null,document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",Z),document.removeEventListener("touchmove",O),document.removeEventListener("touchend",Z)}function G(){e.nextTick(()=>{be()})}function re(M){var ye,Be;const H=Math.max(0,t.clip.timelineEnd-t.clip.timelineStart),ee=Math.max(1,Math.round(H*t.scale)),ae=t.isMobile?qy:Yy,ue=Math.max(1,Math.round(M.clientWidth||((ye=M.parentElement)==null?void 0:ye.clientWidth)||ee)),de=Math.max(1,Math.round(M.clientHeight||((Be=M.parentElement)==null?void 0:Be.clientHeight)||ae));return{width:ue,height:de}}function be(){if(C.value||!i.value)return;const M=i.value,H=M.getContext("2d");if(!H)return;const{width:ee,height:ae}=re(M),ue=window.devicePixelRatio||1;if(M.width=Math.max(1,Math.round(ee*ue)),M.height=Math.max(1,Math.round(ae*ue)),H.setTransform(ue,0,0,ue,0,0),H.clearRect(0,0,ee,ae),_.value.length>0){ie(H,ee,ae,_.value);return}Ee(H,ee,ae)}function Ee(M,H,ee){const ae=ee/2;M.strokeStyle="rgba(255, 255, 255, 0.3)",M.lineWidth=1,M.beginPath(),M.moveTo(0,ae),M.lineTo(H,ae);for(let ue=0;ue<H;ue+=4){const de=Math.sin(ue*.05)*(ee*.3);M.moveTo(ue,ae-de),M.lineTo(ue,ae+de)}M.stroke()}function ie(M,H,ee,ae){const ue=t.clip.sourceIn,de=t.clip.sourceOut,ye=Math.max(.001,de-ue),Be=ae.filter(Ie=>Ie.endTime>=ue&&Ie.time<=de);if(Be.length===0){Ee(M,H,ee);return}const fe=ee/2,ge=ee*.44,Se=ee*.32;M.fillStyle="rgba(255, 255, 255, 0.26)",Be.forEach(Ie=>{const pt=Math.max(Ie.time,ue),lt=Math.min(Ie.endTime,de),Dt=(pt-ue)/ye*H,ot=Math.max(Ac,(lt-pt)/ye*H),vt=R(Ie.rms)*Se;M.fillRect(Dt,fe-vt,ot,vt*2)}),M.fillStyle="rgba(255, 255, 255, 0.72)",Be.forEach(Ie=>{const pt=Math.max(Ie.time,ue),lt=Math.min(Ie.endTime,de),Dt=(pt-ue)/ye*H,ot=Math.max(Ac,(lt-pt)/ye*H),vt=R(Ie.peak)*ge;M.fillRect(Dt,fe-vt,ot,vt*2)})}function R(M){return Math.min(1,Math.max(0,M))}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],G,{deep:!0,flush:"post"}),e.onMounted(()=>{G(),window.addEventListener("resize",be)}),e.onUnmounted(()=>{Z(),z(),P(),window.removeEventListener("resize",be)}),(M,H)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-clip",{selected:M.selected,mobile:M.isMobile,"has-filters":$.value}]),style:e.normalizeStyle(h.value),onClick:T,onMousedown:j,onTouchstart:E},[e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:H[0]||(H[0]=e.withModifiers(ee=>A("start",ee),["stop"])),onTouchstart:H[1]||(H[1]=e.withModifiers(ee=>A("start",ee),["stop"])),"aria-label":`Trim start of ${M.clip.label||"clip"}`},[...H[7]||(H[7]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,Dy),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:H[2]||(H[2]=e.withModifiers(ee=>A("end",ee),["stop"])),onTouchstart:H[3]||(H[3]=e.withModifiers(ee=>A("end",ee),["stop"])),"aria-label":`Trim end of ${M.clip.label||"clip"}`},[...H[8]||(H[8]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,Ry),e.createElementVNode("div",Ay,[M.clip.thumbnail?(e.openBlock(),e.createElementBlock("div",Ly,[e.createElementVNode("img",{src:M.clip.thumbnail,alt:M.clip.label||"Video clip"},null,8,Py)])):e.createCommentVNode("",!0),C.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["clip-analysis-strip clip-filmstrip",{compact:M.isMobile}]),"aria-hidden":"true"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,ee=>(e.openBlock(),e.createElementBlock("img",{key:ee.id,class:"clip-filmstrip-frame",src:ee.uri,alt:"",draggable:"false"},null,8,Oy))),128))],2)):(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["clip-analysis-strip clip-waveform",{compact:M.isMobile}]),"data-visual-mode":S.value?"waveform":"placeholder","aria-hidden":"true"},[e.createElementVNode("canvas",{ref_key:"waveformCanvas",ref:i},null,512)],10,Uy)),e.createElementVNode("div",zy,[e.createElementVNode("span",jy,e.toDisplayString(g.value),1),e.createElementVNode("span",Wy,e.toDisplayString(k.value),1)]),$.value?(e.openBlock(),e.createElementBlock("div",Zy,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(D.value,ee=>(e.openBlock(),e.createBlock(e.unref(U.IonIcon),{key:ee.id||ee.filterId,icon:x(ee.filterId||ee.id),title:`Filter: ${ee.filterId||ee.id}`},null,8,["icon","title"]))),128))])):e.createCommentVNode("",!0),M.clip.speed&&M.clip.speed!==1?(e.openBlock(),e.createElementBlock("div",Hy,e.toDisplayString(M.clip.speed)+"x ",1)):e.createCommentVNode("",!0)]),M.selected&&M.canDelete?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"clip-delete-button","aria-label":`Delete ${M.clip.label||"clip"}`,"data-testid":`timeline-clip-delete-${M.clip.id}`,title:"Delete clip",onClick:H[4]||(H[4]=e.withModifiers(ee=>o("delete"),["stop"])),onMousedown:H[5]||(H[5]=e.withModifiers(()=>{},["stop"])),onTouchstart:H[6]||(H[6]=e.withModifiers(()=>{},["stop"]))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(qi)},null,8,["icon"])],40,Xy)):e.createCommentVNode("",!0),M.selected?(e.openBlock(),e.createElementBlock("div",Gy)):e.createCommentVNode("",!0)],38))}}),Lc=Me(Qy,[["__scopeId","data-v-ff3f9a78"]]),e1={class:"timeline-track-header__meta"},t1={class:"timeline-track-header__name"},n1={class:"timeline-track-header__type"},a1=["aria-label"],o1=["aria-pressed","aria-label"],i1=["aria-pressed","aria-label"],r1=["aria-pressed","aria-label"],s1=["aria-pressed","aria-label"],l1=e.defineComponent({__name:"TimelineTrackHeader",props:{track:{}},emits:["toggle-lock","toggle-hidden","toggle-muted","toggle-solo"],setup(a,{emit:n}){const t=n;return(o,i)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-track-header",{"is-hidden":o.track.hidden===!0}])},[e.createElementVNode("div",e1,[e.createElementVNode("span",t1,e.toDisplayString(o.track.name),1),e.createElementVNode("span",n1,e.toDisplayString(o.track.type),1)]),e.createElementVNode("div",{class:"timeline-track-header__actions","aria-label":`Track controls for ${o.track.name}`},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["timeline-track-header__button",{"is-active":o.track.locked===!0}]),"aria-pressed":o.track.locked===!0,"aria-label":o.track.locked===!0?`Unlock ${o.track.name}`:`Lock ${o.track.name}`,title:"Lock",onClick:i[0]||(i[0]=r=>t("toggle-lock",o.track.id))}," Lock ",10,o1),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["timeline-track-header__button",{"is-active":o.track.hidden===!0}]),"aria-pressed":o.track.hidden===!0,"aria-label":o.track.hidden===!0?`Show ${o.track.name}`:`Hide ${o.track.name}`,title:"Hide",onClick:i[1]||(i[1]=r=>t("toggle-hidden",o.track.id))}," Hide ",10,i1),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["timeline-track-header__button",{"is-active":o.track.muted===!0}]),"aria-pressed":o.track.muted===!0,"aria-label":o.track.muted===!0?`Unmute ${o.track.name}`:`Mute ${o.track.name}`,title:"Mute",onClick:i[2]||(i[2]=r=>t("toggle-muted",o.track.id))}," Mute ",10,r1),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["timeline-track-header__button",{"is-active":o.track.solo===!0}]),"aria-pressed":o.track.solo===!0,"aria-label":o.track.solo===!0?`Disable solo for ${o.track.name}`:`Solo ${o.track.name}`,title:"Solo",onClick:i[3]||(i[3]=r=>t("toggle-solo",o.track.id))}," Solo ",10,s1)],8,a1)],2))}}),c1=Me(l1,[["__scopeId","data-v-e3a76d37"]]);class Nu{constructor(n=30){this.fps=30,this.fps=n}setFps(n){this.fps=n}async convertTimelineClipToEngine(n,t){const o=new Ls(t,{muted:n.muted||!1,scale:n.scale||1,position:"center"});if(n.sourceIn!==void 0||n.sourceOut!==void 0){const i=this.secondsToFrames(n.sourceIn||0),r=n.sourceOut?this.secondsToFrames(n.sourceOut):o.duration.frames;o.subclip(i,r)}return n.timelineStart&&n.timelineStart>0&&o.offsetBy(this.secondsToFrames(n.timelineStart)),n.transform&&this.applyTransformations(o,n.transform),o}convertEngineClipToTimeline(n,t,o){const i=this.framesToSeconds(n.duration.frames),r=n.offset?this.framesToSeconds(n.offset.frames):0;return{id:t,url:o,type:"video",timelineStart:r,timelineEnd:r+i,sourceIn:0,sourceOut:i,duration:i,muted:n.muted||!1,scale:n.scale.x||1}}async buildCompositionFromRecipe(n,t){var o;(o=t.clear)==null||o.call(t);for(const i of n.timeline)try{if(!i.url)continue;const r=await xa.from(i.url),s=await this.convertTimelineClipToEngine(i,r);await t.add(s)}catch{}n.duration&&(t.duration=Fe.fromFrames(this.secondsToFrames(n.duration)))}extractTimelineFromComposition(n){const t=[];return(n.clips||[]).forEach((i,r)=>{var s,l;i instanceof Ls&&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(n,t){(t.x!==void 0||t.y!==void 0)&&(n.x=t.x||0,n.y=t.y||0),t.rotation!==void 0&&(n.rotation=t.rotation),t.opacity!==void 0&&(n.alpha=t.opacity),t.scale!==void 0&&(n.scale={x:t.scale,y:t.scale})}secondsToFrames(n){return Math.round(n*this.fps)}framesToSeconds(n){return n/this.fps}framesToTime(n){const t=this.framesToSeconds(n),o=Math.floor(t/60),i=Math.floor(t%60),r=Math.floor(t%1*1e3);return`${o.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}.${r.toString().padStart(3,"0")}`}formatTime(n){const t=Math.floor(n/3600),o=Math.floor(n%3600/60),i=Math.floor(n%60);return`${t.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`}parseTime(n){const t=n.split(":");let o=0;if(t.length===2){const[i,r]=t;o=parseInt(i)*60+parseFloat(r)}else if(t.length===3){const[i,r,s]=t;o=parseInt(i)*3600+parseInt(r)*60+parseFloat(s)}else o=parseFloat(n);return o}timeToFrames(n){const t=n.split(":");let o=0;if(t.length===2){const[i,r]=t;o=parseInt(i)*60+parseFloat(r)}else if(t.length===3){const[i,r,s]=t;o=parseInt(i)*3600+parseInt(r)*60+parseFloat(s)}else o=parseFloat(n);return this.secondsToFrames(o)}}const d1={class:"time-markers"},u1=["data-track-id"],m1=["data-track-id"],p1=["aria-label","title"],f1={key:0,class:"timeline-scrollbar"},Pc=152,Oc=80,h1=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"],setup(a,{expose:n,emit:t}){const o=a,i=e.computed(()=>o.isMobile===!0),r=t,s=e.ref(),l=e.ref(o.selectedClipId||null),c=e.ref(!1),d=e.ref(0),u=e.ref(),f=e.ref(0),p=e.computed(()=>o.selectedClipId??l.value);e.watch(()=>o.selectedClipId,q=>{q!==void 0&&(l.value=q)});const m=new Nu(o.fps);e.watch(()=>o.fps,q=>{m.setFps(q)});const h=e.ref(!1),g=e.ref(null),k=e.ref(0),$=e.ref(0),D=e.ref(null),_=e.ref(0),v=e.ref(0),S=e.ref(0),C=e.ref(!1),V=e.ref(0),x=e.ref(o.zoomLevel),T=e.computed(()=>o.zoomLevel),j=e.computed(()=>o.tracks!==void 0&&o.tracks.length>0&&!i.value),E=e.computed(()=>j.value?Pc:0),A=e.computed(()=>Math.max(0,ie.value-E.value));function N(q){return q.trackId??`legacy-track-${q.track??0}`}function z(q,le){return{id:q,type:"video",name:`Track ${le+1}`,order:le}}const P=e.computed(()=>{const q=new Map;for(const le of o.clips){const oe=N(le),se=q.get(oe);if(se){se.push(le);continue}q.set(oe,[le])}return q}),B=e.computed(()=>{if(!j.value)return[];const q=[...o.tracks??[]].sort((se,Ce)=>se.order-Ce.order),le=new Set(q.map(se=>se.id)),oe=[];for(const se of P.value.keys())le.has(se)||oe.push(z(se,q.length+oe.length));return[...q,...oe].map(se=>({track:se,clips:P.value.get(se.id)??[],height:se.height??Oc}))}),L=e.computed(()=>new Set(B.value.filter(q=>q.track.locked===!0).map(q=>q.track.id)));function w(q){const le=o.clips.find(oe=>oe.id===q);return le?!L.value.has(N(le)):!1}function O(q){const le=o.clips.find(Ce=>Ce.id===q);if(!le)return null;const oe=N(le),se=o.clips.filter(Ce=>Ce.id!==q&&N(Ce)===oe&&Ce.timelineStart>=le.timelineEnd-1e-9).map(Ce=>Ce.timelineStart);return se.length?Math.min(...se):null}function Z(q){const le=q.sourceMaxOut??o.duration,oe=q.timelineStart+(le-q.sourceIn),se=O(q.id),Ce=se!=null?Math.max(q.timelineStart,se):1/0;return Math.min(oe,Ce)}function G(q,le=Oc){const oe=q.sourceMinIn??0,Ce=(q.sourceMaxOut??o.duration)-oe,Ve=q.sourceIn-oe;return{left:`${(q.timelineStart-Ve)*T.value-d.value}px`,width:`${Ce*T.value}px`,top:"0px",height:`${le}px`,opacity:p.value===q.id?.25:.15}}const re=e.computed(()=>o.useFrameMode?o.zoomLevel:o.zoomLevel/o.fps),be=e.computed(()=>m.secondsToFrames(o.duration)),Ee=e.computed(()=>o.useFrameMode?be.value*re.value:o.duration*T.value),ie=e.computed(()=>{var q;return f.value||((q=s.value)==null?void 0:q.clientWidth)||800}),R=e.computed(()=>Ee.value>A.value),M=e.computed(()=>Math.max(0,Ee.value-A.value)),H=e.computed(()=>d.value>0),ee=e.computed(()=>d.value<M.value),ae=e.computed(()=>o.useFrameMode?m.secondsToFrames(o.playhead)*re.value-d.value:o.playhead*T.value-d.value),ue=e.computed(()=>D.value===null?null:o.useFrameMode?m.secondsToFrames(D.value)*re.value-d.value:D.value*T.value-d.value),de=e.computed(()=>{const q=A.value,le=Math.max(50,q/Ee.value*q),oe=d.value/M.value*(q-le);return{width:`${le}px`,left:`${oe}px`}}),ye=e.computed(()=>{const q=[],le=Be();for(let oe=0;oe<=o.duration;oe+=le){const se=oe*T.value-d.value;se>=-50&&se<=A.value+50&&q.push({position:se+E.value,label:fe(oe),time:oe})}return q});function Be(){const le=80/T.value;return le<=1?1:le<=5?5:le<=10?10:le<=30?30:le<=60?60:Math.ceil(le/60)*60}function fe(q){if(o.useFrameMode)return`F${m.secondsToFrames(q)}`;{const le=Math.floor(q/60),oe=Math.floor(q%60),se=Math.floor(q%1*o.fps);return T.value>100?`${le}:${oe.toString().padStart(2,"0")}:${se.toString().padStart(2,"0")}`:`${le}:${oe.toString().padStart(2,"0")}`}}function ge(q){const le=s.value.getBoundingClientRect();let se=(q.clientX-le.left-E.value+d.value)/T.value;const Ce=o.clips.find(Ve=>se>=Ve.timelineStart&&se<=Ve.timelineEnd);if(Ce)se=Math.max(Ce.timelineStart,Math.min(Ce.timelineEnd,se));else if(o.selectedClipId){const Ve=o.clips.find(Je=>Je.id===o.selectedClipId);if(Ve){const Je=Math.abs(se-Ve.timelineStart),st=Math.abs(se-Ve.timelineEnd);se=Je<st?Ve.timelineStart:Ve.timelineEnd}}else se=Math.max(0,Math.min(se,o.duration));r("update:playhead",se)}function Se(q){if(!R.value)return;const le=Math.abs(q.deltaX)>Math.abs(q.deltaY)?q.deltaX:q.deltaY;le!==0&&(q.preventDefault(),d.value=Math.max(0,Math.min(M.value,d.value+le)))}function Ie(q){return[...q===void 0?o.clips:o.clips.filter(oe=>N(oe)===q)].sort((oe,se)=>oe.timelineStart-se.timelineStart)}function pt(q){const le=o.clips.find(Ce=>Ce.id===q),oe=Ie(le?N(le):void 0),se=oe.findIndex(Ce=>Ce.id===q);return{previous:se>0?oe[se-1]:null,next:se!==-1&&se<oe.length-1?oe[se+1]:null}}function lt(q){const le=q.timelineEnd-q.timelineStart,{previous:oe,next:se}=pt(q.id),Ce=oe?oe.timelineEnd:0,Ve=se?se.timelineStart-le:Math.max(q.timelineStart,o.duration-le);return{minStart:Ce,maxStart:Math.max(Ce,Ve)}}function Dt(){return 12/Math.max(T.value,1)}function ot(q){return Array.from(new Set(q.filter(le=>typeof le=="number"&&Number.isFinite(le))))}function vt(q,le,oe,se){const Ce=Math.max(oe,Math.min(q,se));if(!o.snapEnabled)return{value:Ce,guideTime:null};const Ve=Dt();let Je=Ce,st=null,ut=Number.POSITIVE_INFINITY;for(const nt of ot(le)){if(nt<oe||nt>se)continue;const kt=Math.abs(nt-Ce);kt<=Ve&&kt<ut&&(Je=nt,st=nt,ut=kt)}return{value:Je,guideTime:st}}function bt(q){if(q.touches.length===2){C.value=!0;const le=q.touches[0],oe=q.touches[1];V.value=Math.hypot(oe.clientX-le.clientX,oe.clientY-le.clientY),x.value=o.zoomLevel}else q.touches.length===1&&(_.value=q.touches[0].clientX,v.value=q.touches[0].clientY,S.value=_.value)}function it(q){if(C.value&&q.touches.length===2){const le=q.touches[0],oe=q.touches[1],Ce=Math.hypot(oe.clientX-le.clientX,oe.clientY-le.clientY)/V.value;Math.max(10,Math.min(200,x.value*Ce)),r("update:playhead",o.playhead)}else if(q.touches.length===1&&!C.value){const le=q.touches[0],oe=S.value-le.clientX;Math.abs(oe)>Math.abs(le.clientY-v.value)&&(q.preventDefault(),d.value=Math.max(0,Math.min(M.value,d.value+oe)),S.value=le.clientX)}}function wt(){C.value=!1}function Et(q){const le=q.target;if(le.closest(".playhead-handle"))return;const oe=q.button===1,se=!!le.closest(".video-track");(oe||!se&&R.value)&&he(q)}function he(q){h.value=!0,g.value="pan",k.value=q.clientX,$.value=d.value,document.addEventListener("mousemove",He),document.addEventListener("mouseup",je)}function Ne(q){q.preventDefault(),q.stopPropagation(),h.value=!0,g.value="playhead";const le="touches"in q?q.touches[0].clientX:q.clientX;k.value=le,$.value=o.playhead,"touches"in q?(document.addEventListener("touchmove",He),document.addEventListener("touchend",je)):(document.addEventListener("mousemove",He),document.addEventListener("mouseup",je))}function Re(q){q.preventDefault(),q.stopPropagation(),h.value=!0,g.value="scrollbar";const le="touches"in q?q.touches[0].clientX:q.clientX;k.value=le,$.value=d.value,"touches"in q?(document.addEventListener("touchmove",He),document.addEventListener("touchend",je)):(document.addEventListener("mousemove",He),document.addEventListener("mouseup",je))}function He(q){if(!h.value)return;const oe=("touches"in q?q.touches[0].clientX:q.clientX)-k.value;if(g.value==="playhead"){const se=oe/T.value;let Ce=$.value+se;if(o.selectedClipId){const Ve=o.clips.find(Je=>Je.id===o.selectedClipId);Ve?Ce=Math.max(Ve.timelineStart,Math.min(Ve.timelineEnd,Ce)):Ce=Math.max(0,Math.min(o.duration,Ce))}else{const Ve=o.clips.find(Je=>o.playhead>=Je.timelineStart&&o.playhead<=Je.timelineEnd);Ve?Ce=Math.max(Ve.timelineStart,Math.min(Ve.timelineEnd,Ce)):Ce=Math.max(0,Math.min(o.duration,Ce))}r("update:playhead",Ce)}else if(g.value==="scrollbar"){const se=oe/A.value*Ee.value;d.value=Math.max(0,Math.min(M.value,$.value+se))}else if(g.value==="pan"){const se=$.value-oe;d.value=Math.max(0,Math.min(M.value,se))}}function je(){h.value=!1,g.value=null,D.value=null,document.removeEventListener("mousemove",He),document.removeEventListener("mouseup",je),document.removeEventListener("touchmove",He),document.removeEventListener("touchend",je)}function Oe(q){l.value=l.value===q?null:q,r("clip-select",l.value)}function ct(q){w(q)&&(l.value=q,r("clip-select",q),r("clip-long-press",q))}function dt(q){!w(q)||o.clips.length<=1||(l.value=q,r("clip-select",q),r("clip-delete",q))}function Pt(q,le){if(!w(q))return;const oe=o.clips.find(Ce=>Ce.id===q);if(!oe||Math.abs(le)<2)return;const se=le/T.value*o.sensitivity;if(o.useFrameMode){const Ce=m.secondsToFrames(oe.sourceIn),Ve=m.secondsToFrames(se),Je=Math.max(0,Ce+Ve),st=m.framesToSeconds(Je);r("trim",q,"start",st)}else{const Ce=Math.max(0,oe.sourceIn+se);r("trim",q,"start",Ce)}}function Rt(q,le){if(!w(q))return;const oe=o.clips.find(nn=>nn.id===q);if(!oe||!s.value)return;const se=s.value.getBoundingClientRect(),Ce=le-se.left-E.value,Ve=80;Ce<Ve?d.value=Math.max(0,d.value-8):Ce>se.width-E.value-Ve&&(d.value=Math.min(M.value,d.value+8));const Je=Ce+d.value,st=1/o.fps;let ut=Je/T.value;const{previous:nt}=pt(oe.id),kt=vt(ut,[0,nt==null?void 0:nt.timelineEnd,o.playhead],0,oe.timelineEnd-st);ut=kt.value,D.value=kt.guideTime;let At=oe.sourceIn+(ut-oe.timelineStart);At=Math.round(At*o.fps)/o.fps,r("trim",q,"start",At)}function Ot(q,le){if(!w(q))return;const oe=o.clips.find(qn=>qn.id===q);if(!oe||!s.value)return;const se=s.value.getBoundingClientRect(),Ce=le-se.left-E.value,Ve=80;Ce<Ve?d.value=Math.max(0,d.value-8):Ce>se.width-E.value-Ve&&(d.value=Math.min(M.value,d.value+8));const Je=Ce+d.value,st=1/o.fps,ut=Z(oe);let nt=Je/T.value;const{next:kt}=pt(oe.id),At=vt(nt,[kt==null?void 0:kt.timelineStart,o.playhead],oe.timelineStart+st,ut);nt=At.value,D.value=At.guideTime;let nn=oe.sourceIn+(nt-oe.timelineStart);nn=Math.round(nn*o.fps)/o.fps,r("trim",q,"end",nn)}function tn(q,le){if(!w(q))return;const oe=o.clips.find(At=>At.id===q);if(!oe||!s.value)return;const se=s.value.getBoundingClientRect(),Ce=le-se.left-E.value,Ve=80;Ce<Ve?d.value=Math.max(0,d.value-8):Ce>se.width-E.value-Ve&&(d.value=Math.min(M.value,d.value+8));const Je=Ce+d.value,st=oe.timelineEnd-oe.timelineStart,ut=lt(oe);let nt=Je/T.value;const kt=vt(nt,[ut.minStart,ut.maxStart,o.playhead,o.playhead-st],ut.minStart,ut.maxStart);nt=kt.value,D.value=kt.guideTime,nt=Math.round(nt*o.fps)/o.fps,r("clip-move",q,nt)}function zn(q,le){if(!w(q))return;const oe=o.clips.find(Ve=>Ve.id===q);if(!oe||Math.abs(le)<2)return;const se=le/T.value*o.sensitivity,Ce=Ve=>Math.max(0,Math.round(Ve*o.fps)/o.fps);if(o.useFrameMode){const Ve=m.secondsToFrames(oe.sourceOut),Je=m.secondsToFrames(se),st=Z(oe),ut=oe.sourceIn+(st-oe.timelineStart),nt=m.secondsToFrames(ut),kt=Math.min(nt,Ve+Je),At=m.framesToSeconds(kt);r("trim",q,"end",At)}else{const Ve=Z(oe),Je=oe.sourceIn+(Ve-oe.timelineStart),st=Math.min(Je,oe.sourceOut+se),ut=Ce(st);r("trim",q,"end",ut)}}function Yn(q,le){if(!w(q))return;const oe=o.clips.find(Ve=>Ve.id===q);if(!oe||Math.abs(le)<2)return;const se=le/T.value*o.sensitivity,Ce=Ve=>Math.max(0,Math.round(Ve*o.fps)/o.fps);if(o.useFrameMode){const Ve=m.secondsToFrames(oe.timelineStart),Je=m.secondsToFrames(se),st=Math.max(0,Ve+Je),ut=m.framesToSeconds(st);r("clip-move",q,ut)}else{const Ve=Math.max(0,oe.timelineStart+se),Je=Ce(Ve);r("clip-move",q,Je)}}return n({handleTrimStart:Pt,handleTrimEnd:zn,handleClipDrag:Yn,handleTrimStartAbs:Rt,handleTrimEndAbs:Ot,handleClipDragAbs:tn,handleClipLongPress:ct}),e.watch(()=>o.playhead,q=>{const le=q*T.value;le<d.value+50?d.value=Math.max(0,le-50):le>d.value+A.value-50&&(d.value=Math.min(M.value,le-A.value+50))}),e.onMounted(()=>{const q=new ResizeObserver(le=>{le[0]&&(f.value=Math.round(le[0].contentRect.width))});s.value&&q.observe(s.value),e.onUnmounted(()=>q.disconnect())}),e.onUnmounted(()=>{je()}),e.watch([Ee,ie],()=>{d.value>M.value&&(d.value=M.value)}),e.watch(D,(q,le)=>{const oe=q!==null;oe!==(le!==null)&&r("snap-state-change",oe)}),(q,le)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-timeline",{mobile:i.value}]),ref_key:"timelineRef",ref:s,onWheel:Se},[e.createElementVNode("div",{class:"timeline-ruler",onClick:ge},[e.createElementVNode("div",d1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ye.value,oe=>(e.openBlock(),e.createElementBlock("span",{key:oe.position,class:"time-marker",style:e.normalizeStyle({left:`${oe.position}px`})},e.toDisplayString(oe.label),5))),128))])]),e.createElementVNode("div",{class:e.normalizeClass(["timeline-content",{"is-pannable":R.value,"is-panning":h.value&&g.value==="pan","overflow-left":H.value,"overflow-right":ee.value}]),onTouchstart:bt,onTouchmove:it,onTouchend:wt,onMousedown:Et},[j.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"timeline-track-lanes",style:e.normalizeStyle({"--timeline-track-header-width":`${Pc}px`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B.value,oe=>(e.openBlock(),e.createElementBlock("div",{key:oe.track.id,class:e.normalizeClass(["timeline-track-lane",{"timeline-track-lane--locked":oe.track.locked,"timeline-track-lane--hidden":oe.track.hidden}]),style:e.normalizeStyle({height:`${oe.height}px`}),"data-track-id":oe.track.id},[e.createVNode(c1,{class:"timeline-track-lane__header",track:oe.track,onToggleLock:le[0]||(le[0]=se=>r("toggle-lock",se)),onToggleHidden:le[1]||(le[1]=se=>r("toggle-hidden",se)),onToggleMuted:le[2]||(le[2]=se=>r("toggle-muted",se)),onToggleSolo:le[3]||(le[3]=se=>r("toggle-solo",se))},null,8,["track"]),e.createElementVNode("div",{class:"video-track timeline-track-lane__body","data-track-id":oe.track.id},[oe.track.hidden?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(oe.clips,se=>(e.openBlock(),e.createElementBlock("div",{key:`${se.id}-extent`,class:"clip-extent",style:e.normalizeStyle(G(se,oe.height)),"aria-hidden":"true"},null,4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(oe.clips,se=>(e.openBlock(),e.createBlock(Lc,{key:se.id,clip:se,scale:T.value,"scroll-offset":d.value,selected:p.value===se.id,"is-mobile":i.value,"can-delete":o.clips.length>1&&w(se.id),"data-locked":oe.track.locked===!0?"true":void 0,onSelect:Ce=>Oe(se.id),onDelete:Ce=>dt(se.id),onLongPress:Ce=>ct(se.id),onTrimStartAbs:Ce=>Rt(se.id,Ce),onTrimEndAbs:Ce=>Ot(se.id,Ce),onDragAbs:Ce=>tn(se.id,Ce)},null,8,["clip","scale","scroll-offset","selected","is-mobile","can-delete","data-locked","onSelect","onDelete","onLongPress","onTrimStartAbs","onTrimEndAbs","onDragAbs"]))),128))],64))],8,m1)],14,u1))),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(q.clips,oe=>(e.openBlock(),e.createElementBlock("div",{key:`${oe.id}-extent`,class:"clip-extent",style:e.normalizeStyle(G(oe)),"aria-hidden":"true"},null,4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(q.clips,oe=>(e.openBlock(),e.createBlock(Lc,{key:oe.id,clip:oe,scale:T.value,"scroll-offset":d.value,selected:p.value===oe.id,"is-mobile":i.value,"can-delete":o.clips.length>1&&w(oe.id),onSelect:se=>Oe(oe.id),onDelete:se=>dt(oe.id),onLongPress:se=>ct(oe.id),onTrimStartAbs:se=>Rt(oe.id,se),onTrimEndAbs:se=>Ot(oe.id,se),onDragAbs:se=>tn(oe.id,se)},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:`${E.value+ae.value}px`}),onMousedown:Ne,onTouchstart:Ne},[...le[5]||(le[5]=[e.createElementVNode("div",{class:"playhead-handle"},[e.createElementVNode("div",{class:"playhead-line"})],-1)])],36),c.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:"split-indicator",style:e.normalizeStyle({left:`${E.value+ae.value}px`})},null,4)):e.createCommentVNode("",!0),ue.value!==null?(e.openBlock(),e.createElementBlock("div",{key:3,class:"snap-guide",style:e.normalizeStyle({left:`${E.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:le[4]||(le[4]=oe=>q.$emit("toggle-frame-mode")),"aria-label":q.useFrameMode?"Switch to time mode":"Switch to frame mode",title:q.useFrameMode?"Switch to time mode":"Switch to frame mode"},e.toDisplayString(q.useFrameMode?"F":"T"),9,p1))],34),R.value?(e.openBlock(),e.createElementBlock("div",f1,[e.createElementVNode("div",{class:"scrollbar-thumb",style:e.normalizeStyle(de.value),onMousedown:Re,onTouchstart:Re},null,36)])):e.createCommentVNode("",!0)],34))}}),zs=Me(h1,[["__scopeId","data-v-d79841b3"]]),v1={key:0,class:"control-group primary-controls"},g1=["disabled"],y1=["disabled"],b1=["disabled"],w1=["disabled"],k1=["disabled"],_1=["disabled"],E1={key:1,class:"control-group mobile-action-controls"},x1=["aria-expanded"],S1={key:0,class:"mobile-action-menu",role:"menu","aria-label":"Clip actions","data-testid":"timeline-mobile-action-menu"},C1=["disabled"],V1=["disabled"],N1=["disabled"],T1=["disabled"],M1=["disabled"],B1=["disabled"],I1={class:"control-group zoom-controls"},F1={class:"zoom-slider"},$1=["value"],D1={class:"control-group playback-controls"},R1=["aria-label"],A1={key:2,class:"control-group speed-control"},L1=["value"],P1=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(a,{emit:n}){const t=n,o=e.ref(!1);function i(p){switch(p){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}o.value=!1}function r(p){const m=p.target;t("zoom-change",Number(m.value))}function s(){t("fit-to-window")}function l(){t("frame-forward")}function c(){t("frame-backward")}function d(){t("skip-to-start")}function u(){t("skip-to-end")}function f(p){const m=p.target;t("speed-change",Number(m.value))}return(p,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-controls",{mobile:p.isMobile}])},[p.isMobile?(e.openBlock(),e.createElementBlock("div",E1,[e.createElementVNode("button",{class:"control-button","data-testid":"timeline-btn-mobile-actions","aria-expanded":o.value?"true":"false","aria-label":"Clip actions",onClick:m[6]||(m[6]=h=>o.value=!o.value)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ff)},null,8,["icon"]),m[20]||(m[20]=e.createElementVNode("span",{class:"control-label"},"Actions",-1))],8,x1),o.value?(e.openBlock(),e.createElementBlock("div",S1,[p.showAddTrack?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",role:"menuitem",disabled:!p.canAddTrack,"data-testid":"timeline-mobile-btn-add-track",onClick:m[7]||(m[7]=h=>i("add-track"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Li)},null,8,["icon"]),m[21]||(m[21]=e.createTextVNode(" Add Track ",-1))],8,C1)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",role:"menuitem",disabled:!p.canUndo,"data-testid":"timeline-mobile-btn-undo",onClick:m[8]||(m[8]=h=>i("undo"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(dc)},null,8,["icon"]),m[22]||(m[22]=e.createTextVNode(" Undo ",-1))],8,V1),e.createElementVNode("button",{type:"button",role:"menuitem",disabled:!p.canRedo,"data-testid":"timeline-mobile-btn-redo",onClick:m[9]||(m[9]=h=>i("redo"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(cc)},null,8,["icon"]),m[23]||(m[23]=e.createTextVNode(" Redo ",-1))],8,N1),e.createElementVNode("button",{type:"button",role:"menuitem",disabled:!p.canSplit,"data-testid":"timeline-mobile-btn-split",onClick:m[10]||(m[10]=h=>i("split"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Yi)},null,8,["icon"]),m[24]||(m[24]=e.createTextVNode(" Split ",-1))],8,T1),e.createElementVNode("button",{type:"button",role:"menuitem",disabled:!p.selectedClip,"data-testid":"timeline-mobile-btn-duplicate",onClick:m[11]||(m[11]=h=>i("duplicate"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(xs)},null,8,["icon"]),m[25]||(m[25]=e.createTextVNode(" Duplicate ",-1))],8,M1),e.createElementVNode("button",{type:"button",role:"menuitem",class:"danger-menu-item",disabled:!p.canDelete,"data-testid":"timeline-mobile-btn-delete",onClick:m[12]||(m[12]=h=>i("delete"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(qi)},null,8,["icon"]),m[26]||(m[26]=e.createTextVNode(" Delete ",-1))],8,B1)])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",v1,[p.showAddTrack?(e.openBlock(),e.createElementBlock("button",{key:0,class:"control-button",disabled:!p.canAddTrack,"data-testid":"timeline-btn-add-track","aria-label":"Add video track",title:"Add Track",onClick:m[0]||(m[0]=h=>p.$emit("add-track"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Li)},null,8,["icon"]),m[16]||(m[16]=e.createElementVNode("span",{class:"control-label"},"Add Track",-1))],8,g1)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"control-button",disabled:!p.canUndo,"data-testid":"timeline-btn-undo","aria-label":"Undo",title:"Undo",onClick:m[1]||(m[1]=h=>p.$emit("undo"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(dc)},null,8,["icon"])],8,y1),e.createElementVNode("button",{class:"control-button",disabled:!p.canRedo,"data-testid":"timeline-btn-redo","aria-label":"Redo",title:"Redo",onClick:m[2]||(m[2]=h=>p.$emit("redo"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(cc)},null,8,["icon"])],8,b1),e.createElementVNode("button",{class:"control-button",disabled:!p.canSplit,"data-testid":"timeline-btn-split","aria-label":"Split selected clip at playhead",title:"Split",onClick:m[3]||(m[3]=h=>p.$emit("split"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Yi)},null,8,["icon"]),m[17]||(m[17]=e.createElementVNode("span",{class:"control-label"},"Split",-1))],8,w1),e.createElementVNode("button",{class:"control-button",disabled:!p.selectedClip,"data-testid":"timeline-btn-duplicate","aria-label":"Duplicate selected clip",title:"Duplicate",onClick:m[4]||(m[4]=h=>p.$emit("duplicate"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(xs)},null,8,["icon"]),m[18]||(m[18]=e.createElementVNode("span",{class:"control-label"},"Duplicate",-1))],8,k1),e.createElementVNode("button",{class:"control-button danger-button",disabled:!p.canDelete,"data-testid":"timeline-btn-delete","aria-label":"Delete selected clip",title:"Delete",onClick:m[5]||(m[5]=h=>p.$emit("delete"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(qi)},null,8,["icon"]),m[19]||(m[19]=e.createElementVNode("span",{class:"control-label"},"Delete",-1))],8,_1)])),e.createElementVNode("div",I1,[e.createElementVNode("button",{class:"control-button zoom-button",onClick:m[13]||(m[13]=h=>p.$emit("zoom-out")),"aria-label":"Zoom out"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Yf)},null,8,["icon"])]),e.createElementVNode("div",F1,[e.createElementVNode("input",{type:"range",value:p.zoomLevel,onInput:r,min:"10",max:"200",step:"5","aria-label":"Timeline zoom"},null,40,$1)]),e.createElementVNode("button",{class:"control-button zoom-button",onClick:m[14]||(m[14]=h=>p.$emit("zoom-in")),"aria-label":"Zoom in"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Li)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:s,"aria-label":"Fit timeline to window"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Df)},null,8,["icon"]),m[27]||(m[27]=e.createElementVNode("span",{class:"control-label"},"Fit",-1))])]),e.createElementVNode("div",D1,[e.createElementVNode("button",{class:"control-button",onClick:d,"aria-label":"Skip to start"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Jf)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:c,"aria-label":"Previous frame"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Zf)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button play-button",onClick:m[15]||(m[15]=h=>p.$emit("play-pause")),"aria-label":p.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(U.IonIcon),{icon:p.isPlaying?e.unref(ml):e.unref(pl)},null,8,["icon"])],8,R1),e.createElementVNode("button",{class:"control-button",onClick:l,"aria-label":"Next frame"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Gf)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:u,"aria-label":"Skip to end"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Kf)},null,8,["icon"])])]),p.isMobile?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",A1,[m[29]||(m[29]=e.createElementVNode("label",{class:"speed-label"},"Speed:",-1)),e.createElementVNode("select",{value:p.playbackSpeed,onChange:f,class:"speed-select","aria-label":"Playback speed"},[...m[28]||(m[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,L1)]))],2))}}),js=Me(P1,[["__scopeId","data-v-c7b0395a"]]),O1={key:0,class:"category-section"},U1={class:"category-carousel-wrapper"},z1=["disabled"],j1=["onClick","data-testid","aria-label"],W1={class:"category-name"},Z1=["disabled"],H1={class:"filter-section"},X1={class:"filter-carousel-wrapper"},G1=["disabled"],J1=["onClick","onKeydown","data-testid","aria-label"],K1=["onClick"],Y1={class:"filter-preview"},q1={class:"filter-placeholder"},Q1={class:"filter-name"},eb=["disabled"],tb={class:"carousel-pagination"},nb=["onClick"],ab={key:1,class:"filter-adjustments"},ob={class:"adjustment-header"},ib={class:"adjustment-actions"},rb={key:0},sb={key:0,class:"slider-control"},lb={class:"control-label"},cb={class:"slider-wrapper"},db={class:"slider-value"},ub={key:1,class:"color-control"},mb={class:"control-label"},pb={class:"color-wrapper"},fb=["value","onInput","disabled"],hb={class:"color-value"},vb={key:2,class:"toggle-control"},gb={class:"control-label"},yb={key:3,class:"select-control"},bb={class:"control-label"},wb=["value","onChange","disabled"],kb=["value"],_b={key:1,class:"no-params"},Eb=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(a,{emit:n}){const t=a,o=n,i=e.ref("all"),r=e.ref(null),s=e.ref(0),l=e.ref(0),c=e.ref(new Map),d=e.ref(),u=e.ref(),f={all:aa,adjust:So,color:oa,blur:Ei,light:Co,effects:as,stylize:Bo,advanced:aa,distortion:Io,transform:Io};function p(w){return w.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function m(w){return w.replace(/[-_]/g," ").replace(/\b\w/g,O=>O.toUpperCase())}function h(w){return f[w.toLowerCase()]??aa}const g=e.computed(()=>{const w=Array.from(new Set(t.filters.map(O=>O.category).filter(O=>typeof O=="string"&&O.length>0))).sort((O,Z)=>O.localeCompare(Z));return[{id:"all",name:"All",icon:aa},...w.map(O=>({id:O,name:m(O),icon:h(O)}))]}),k=e.computed(()=>i.value==="all"?t.filters:t.filters.filter(w=>w.category===i.value));e.watch(g,w=>{new Set(w.map(G=>G.id)).has(i.value)||(i.value="all");const Z=Math.max(0,w.length-3);s.value>Z&&(s.value=Z)},{immediate:!0});function $(w){var O;return((O=t.activeFilters)==null?void 0:O.has(w))||!1}function D(w){if(r.value=w,!$(w.id)&&(o("apply-filter",w),w.params&&w.params.length>0)){const O=new Map;w.params.forEach(Z=>{O.set(Z.id,Z.default)}),c.value.set(w.id,O)}o("preview-filter",w)}function _(w){var O;o("remove-filter",w),c.value.delete(w),((O=r.value)==null?void 0:O.id)===w&&(r.value=null)}function v(w){if(typeof w=="number"&&Number.isFinite(w))return w;if(typeof w=="string"){const O=Number(w);return Number.isFinite(O)?O:null}return null}function S(w,O){var R;const Z=t.filters.find(M=>M.id===w),G=Z==null?void 0:Z.params.find(M=>M.id===O),re=(G==null?void 0:G.default)??0,be=M=>typeof re=="number"?v(M)??re:typeof re=="boolean"?typeof M=="boolean"?M:re:typeof M=="string"?M:re,Ee=(R=t.activeFilters)==null?void 0:R.get(w);if(Ee&&Ee.params){const M=Ee.params[O];if(M!=null)return be(M)}const ie=c.value.get(w);if(ie){const M=ie.get(O);if(M!=null)return be(M)}return re}function C(w,O,Z){var G;c.value.has(w)||c.value.set(w,new Map),(G=c.value.get(w))==null||G.set(O,Z),o("update-param",w,O,Z)}function V(w){if(typeof w=="boolean")return w?"On":"Off";if(typeof w=="string"){const Z=v(w);return Z===null?"0":Number.isInteger(Z)?Z.toString():Z.toFixed(2)}const O=v(w);return O===null?"0":Number.isInteger(O)?O.toString():O.toFixed(2)}function x(){if(r.value&&(o("apply-filter",r.value),r.value.params&&r.value.params.length>0)){const w=new Map;r.value.params.forEach(O=>{w.set(O.id,O.default)}),c.value.set(r.value.id,w)}}function T(w){const O=t.filters.find(Z=>Z.id===w);O&&O.params&&O.params.forEach(Z=>{C(w,Z.id,Z.default)})}function j(w){return{basic:So,color:oa,blur:Ei,light:Co,effects:as,stylize:Bo,adjustment:So,"color-matrix":oa,glow:aa,distortion:Io}[w]||aa}function E(w){return{adjustment:So,brightness:Co,contrast:So,saturation:oa,blur:Ei,"gaussian-blur":Ei,"color-matrix":oa,grayscale:Bo,sepia:Bo,vignette:Io,glow:aa,glitch:as,godray:Co,lightmap:Co}[w.id]||j(w.category)}function A(){s.value>0&&(s.value--,L(d.value,s.value))}function N(){s.value<g.value.length-3&&(s.value++,L(d.value,s.value))}function z(){l.value>0&&(l.value--,L(u.value,l.value))}function P(){l.value<k.value.length-4&&(l.value++,L(u.value,l.value))}function B(w){l.value=w*4,L(u.value,l.value)}function L(w,O){var Z;if(w){const G=((Z=w.querySelector(".category-chip, .filter-card"))==null?void 0:Z.clientWidth)||100;w.scrollTo({left:O*(G+8),behavior:"smooth"})}}return(w,O)=>{var Z;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-filter-carousel-container",{compact:w.compact}])},[w.showCategories?(e.openBlock(),e.createElementBlock("div",O1,[e.createElementVNode("div",U1,[e.createElementVNode("button",{onClick:A,class:"carousel-nav carousel-nav-left",disabled:s.value===0,"aria-label":"Previous categories","data-testid":"btn-filter-category-prev"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(uc)},null,8,["icon"])],8,z1),e.createElementVNode("div",{ref_key:"categoryCarouselRef",ref:d,class:"category-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,G=>(e.openBlock(),e.createElementBlock("button",{key:G.id,onClick:re=>i.value=G.id,class:e.normalizeClass(["category-chip",{active:i.value===G.id}]),"data-testid":`btn-filter-category-${p(G.id)}`,"aria-label":`Filter category ${G.name}`},[e.createVNode(e.unref(U.IonIcon),{icon:G.icon,class:"category-icon"},null,8,["icon"]),e.createElementVNode("span",W1,e.toDisplayString(G.name),1)],10,j1))),128))],512),e.createElementVNode("button",{onClick:N,class:"carousel-nav carousel-nav-right",disabled:s.value>=g.value.length-3,"aria-label":"Next categories","data-testid":"btn-filter-category-next"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(mc)},null,8,["icon"])],8,Z1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",H1,[e.createElementVNode("div",X1,[e.createElementVNode("button",{onClick:z,class:"carousel-nav carousel-nav-left",disabled:l.value===0,"aria-label":"Previous filters","data-testid":"btn-filter-carousel-prev"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(uc)},null,8,["icon"])],8,G1),e.createElementVNode("div",{ref_key:"filterCarouselRef",ref:u,class:"filter-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.value,G=>{var re;return e.openBlock(),e.createElementBlock("div",{key:G.id,class:e.normalizeClass(["filter-card",{active:$(G.id),selected:((re=r.value)==null?void 0:re.id)===G.id}]),onClick:be=>D(G),onKeydown:[e.withKeys(be=>D(G),["enter"]),e.withKeys(e.withModifiers(be=>D(G),["prevent"]),["space"])],role:"button",tabindex:"0","data-testid":`btn-video-filter-${p(G.id)}`,"aria-label":`Select filter ${G.name}`},[$(G.id)?(e.openBlock(),e.createElementBlock("div",{key:0,class:"filter-checkmark",onClick:e.withModifiers(be=>_(G.id),["stop"])},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(jd)},null,8,["icon"])],8,K1)):e.createCommentVNode("",!0),e.createElementVNode("div",Y1,[e.createElementVNode("div",q1,[e.createVNode(e.unref(U.IonIcon),{icon:E(G),class:"filter-icon"},null,8,["icon"])])]),e.createElementVNode("span",Q1,e.toDisplayString(G.name),1)],42,J1)}),128))],512),e.createElementVNode("button",{onClick:P,class:"carousel-nav carousel-nav-right",disabled:l.value>=Math.max(0,k.value.length-4),"aria-label":"Next filters","data-testid":"btn-filter-carousel-next"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(mc)},null,8,["icon"])],8,eb)]),e.createElementVNode("div",tb,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Math.ceil(k.value.length/4),(G,re)=>(e.openBlock(),e.createElementBlock("span",{key:re,class:e.normalizeClass(["pagination-dot",{active:Math.floor(l.value/4)===re}]),onClick:be=>B(re)},null,10,nb))),128))])]),r.value?(e.openBlock(),e.createElementBlock("div",ab,[e.createElementVNode("div",ob,[e.createElementVNode("h4",null,e.toDisplayString(r.value.name),1),e.createElementVNode("div",ib,[$(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 ")),$(r.value.id)?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:O[0]||(O[0]=G=>_(r.value.id)),class:"remove-btn","data-testid":"btn-remove-selected-filter"}," Remove Filter ")):e.createCommentVNode("",!0),$(r.value.id)&&((Z=r.value.params)==null?void 0:Z.length)>0?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:O[1]||(O[1]=G=>T(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",rb,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value.params,G=>(e.openBlock(),e.createElementBlock("div",{key:G.id,class:"adjustment-control"},[!G.type||G.type==="slider"?(e.openBlock(),e.createElementBlock("div",sb,[e.createElementVNode("label",lb,e.toDisplayString(G.label||G.id),1),e.createElementVNode("div",cb,[e.createVNode(e.unref(U.IonRange),{value:S(r.value.id,G.id),onIonChange:re=>C(r.value.id,G.id,re.detail.value),min:G.min,max:G.max,step:G.step||.01,color:"primary",class:"compact-slider",disabled:!$(r.value.id),"data-testid":`range-filter-${p(r.value.id)}-${p(G.id)}`,"aria-label":`Adjust ${G.label||G.id} for ${r.value.name}`},null,8,["value","onIonChange","min","max","step","disabled","data-testid","aria-label"]),e.createElementVNode("span",db,e.toDisplayString(V(S(r.value.id,G.id))),1)])])):G.type==="color"?(e.openBlock(),e.createElementBlock("div",ub,[e.createElementVNode("label",mb,e.toDisplayString(G.label||G.id),1),e.createElementVNode("div",pb,[e.createElementVNode("input",{type:"color",value:S(r.value.id,G.id),onInput:re=>C(r.value.id,G.id,re.target.value),disabled:!$(r.value.id),class:"color-input"},null,40,fb),e.createElementVNode("span",hb,e.toDisplayString(S(r.value.id,G.id)),1)])])):G.type==="toggle"?(e.openBlock(),e.createElementBlock("div",vb,[e.createElementVNode("label",gb,e.toDisplayString(G.label||G.id),1),e.createVNode(e.unref(U.IonToggle),{checked:!!S(r.value.id,G.id),onIonChange:re=>C(r.value.id,G.id,re.detail.checked),disabled:!$(r.value.id),color:"primary"},null,8,["checked","onIonChange","disabled"])])):G.type==="select"?(e.openBlock(),e.createElementBlock("div",yb,[e.createElementVNode("label",bb,e.toDisplayString(G.label||G.id),1),e.createElementVNode("select",{value:S(r.value.id,G.id),onChange:re=>C(r.value.id,G.id,re.target.value),disabled:!$(r.value.id),class:"select-input"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(G.options,re=>(e.openBlock(),e.createElementBlock("option",{key:String(re.value),value:re.value},e.toDisplayString(re.label),9,kb))),128))],40,wb)])):e.createCommentVNode("",!0)]))),128))])):(e.openBlock(),e.createElementBlock("div",_b," This filter has no adjustable parameters "))])):e.createCommentVNode("",!0)],2)}}}),Ws=Me(Eb,[["__scopeId","data-v-9efd15d9"]]);class xb{constructor(n){this.pixiFilters=new Map,this.filterParams=new Map,this.filterTypes=new Map,this.filterIntensity=new Map,this.composition=n}setComposition(n){this.composition=n}mapMediablesToPIXI(n){switch(n.filterId){case"blur":return this.createBlurFilter(n.params);case"brightness":return this.createBrightnessFilter(n.params);case"contrast":return this.createContrastFilter(n.params);case"saturation":return this.createSaturationFilter(n.params);case"hue":return this.createHueFilter(n.params);case"vintage":return this.createVintageFilter(n.params);case"grayscale":return this.createGrayscaleFilter();case"sepia":return this.createSepiaFilter();default:return null}}createBlurFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.BlurFilter;if(!i)return null;const r=new i;return r.blur=n.intensity||5,r.quality=n.quality||4,r}catch{return null}}createBrightnessFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.brightness(n.value||1,!1),r}catch{return null}}createContrastFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.contrast(n.value||1,!1),r}catch{return null}}createSaturationFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.saturate(n.value||1,!1),r}catch{return null}}createHueFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.hue(n.rotation||0,!1),r}catch{return null}}createVintageFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.vintage(!1),n.intensity&&(r.contrast(1.2,!1),r.saturate(.8,!1)),r}catch{return null}}createGrayscaleFilter(){var n,t;try{const o=(t=(n=window.PIXI)==null?void 0:n.filters)==null?void 0:t.ColorMatrixFilter;if(!o)return null;const i=new o;return i.desaturate(),i}catch{return null}}createSepiaFilter(){var n,t;try{const o=(t=(n=window.PIXI)==null?void 0:n.filters)==null?void 0:t.ColorMatrixFilter;if(!o)return null;const i=new o;return i.sepia(!1),i}catch{return null}}async applyFilters(n){if(this.composition){this.clearFilters();for(const t of n){const o=this.mapMediablesToPIXI(t);o&&(this.pixiFilters.set(t.id,o),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,o))}}}async applyToComposition(n,t){try{this.composition.applyFilter&&await this.composition.applyFilter(n,t)}catch{}}updateFilterParams(n,t){var i;const o=this.pixiFilters.get(n);o&&(this.filterParams.set(n,t),"blur"in o&&(o.blur=t.intensity||o.blur),"brightness"in o&&o.brightness(t.value||1,!1),"contrast"in o&&o.contrast(t.value||1,!1),"saturate"in o&&o.saturate(t.value||1,!1),"hue"in o&&o.hue(t.rotation||0,!1),(i=this.composition)!=null&&i.update&&this.composition.update())}getFilterParams(n){return this.filterParams.get(n)||{}}removeFilter(n){var t;this.pixiFilters.delete(n),this.filterParams.delete(n),this.filterTypes.delete(n),this.filterIntensity.delete(n),(t=this.composition)!=null&&t.removeFilter&&this.composition.removeFilter(n)}clearFilters(){var n;this.pixiFilters.clear(),this.filterParams.clear(),this.filterTypes.clear(),this.filterIntensity.clear(),(n=this.composition)!=null&&n.clearFilters&&this.composition.clearFilters()}getActiveFilters(){return Array.from(this.pixiFilters.values())}exportFilterConfig(){const n=[];return this.pixiFilters.forEach((t,o)=>{const i=this.filterParams.get(o)??{},r=this.filterTypes.get(o)??"unknown",s=this.filterIntensity.get(o)??1;n.push({id:o,filterId:r,params:i,intensity:s})}),n}async importFilterConfig(n){await this.applyFilters(n)}destroy(){this.clearFilters(),this.composition=null}}const Sb={class:"video-filter-preview"},Cb={class:"preview-title"},Vb={class:"filter-controls"},Nb={class:"control-input"},Tb=["value","onInput","min","max","step"],Mb={class:"param-value"},Bb={class:"preview-container"},Ib={key:0,class:"filter-presets"},Fb=["onClick"],$b={class:"preview-actions"},Db=e.defineComponent({__name:"VideoFilterPreview",props:{filter:{},currentFrame:{},useVideoEngine:{type:Boolean,default:!1},composition:{}},emits:["update-params","apply"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(!1),s=e.ref({});let l,c,d=null,u=null;const f=e.computed(()=>{var x;return((x=t.filter)==null?void 0:x.paramRanges)||{}}),p=e.computed(()=>m.value.length>0),m=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 xb(t.composition));try{if(l=new Vt.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 T=await Vt.Assets.load(t.currentFrame.dataUrl);c=new Vt.Sprite(T);const j=Math.min(l.screen.width/c.texture.width,l.screen.height/c.texture.height);c.scale.set(j),c.anchor.set(.5),c.position.set(l.screen.width/2,l.screen.height/2),l.stage.addChild(c)}g()}catch{}}}function g(){if(!(!c||!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(T=>{}),d&&(d.destroy(),d=null),d=k(t.filter.id,s.value),d&&(c.filters=r.value?null:[d])}else d&&(d.destroy(),d=null),d=k(t.filter.id,s.value),d&&(c.filters=r.value?null:[d])}function k(x,T){switch(x){case"brightness":{const j=new Vt.ColorMatrixFilter,E=1+(T.value??0);return typeof j.brightness=="function"&&j.brightness(E,!1),j}case"contrast":{const j=new Vt.ColorMatrixFilter,E=T.value??1;return typeof j.contrast=="function"&&j.contrast(E,!1),j}case"saturation":{const j=new Vt.ColorMatrixFilter,E=T.value??1;return typeof j.saturate=="function"&&j.saturate(E,!1),j}case"hue":{const j=new Vt.ColorMatrixFilter,E=T.value??0;return typeof j.hue=="function"&&j.hue(E,!1),j}case"gaussian-blur":{const j=T.value??5;return new Vt.BlurFilter({strength:j,quality:4})}case"sepia":{const j=new Vt.ColorMatrixFilter;return typeof j.sepia=="function"&&j.sepia(!1),j}case"grayscale":{const j=new Vt.ColorMatrixFilter;return typeof j.desaturate=="function"&&j.desaturate(),j}default:return null}}function $(x,T){const j=T.target,E=Number.parseFloat(j.value),A=Number.isFinite(E)?E:0;s.value={...s.value,[x]:A},t.useVideoEngine&&u&&t.filter&&u.updateFilterParams(t.filter.id,s.value),o("update-params",s.value),g()}function D(x){return x.charAt(0).toUpperCase()+x.slice(1).replace(/_/g," ")}function _(x,T){var E;const j=typeof x=="number"?x:Number(x);return Number.isFinite(j)?T==="hue"||T==="angle"?`${j}°`:T==="value"&&((E=t.filter)==null?void 0:E.id)==="brightness"?`${Math.round((1+j)*100)}%`:Number.isInteger(j)?j.toString():j.toFixed(2):"0"}function v(){var x;s.value=((x=t.filter)==null?void 0:x.defaultParams)||{},o("update-params",s.value),g()}function S(x){s.value={...x.params},o("update-params",s.value),g()}function C(x){return JSON.stringify(x.params)===JSON.stringify(s.value)}function V(){o("apply")}return e.watch(()=>t.filter,x=>{x&&(s.value={...x.defaultParams},g())}),e.watch(()=>t.currentFrame,async x=>{if(x!=null&&x.dataUrl&&c){const T=await Vt.Assets.load(x.dataUrl);c.texture=T}}),e.watch(r,g),e.onMounted(()=>{t.filter&&(s.value={...t.filter.defaultParams}),h()}),e.onUnmounted(()=>{l&&l.destroy(!0,{children:!0,texture:!0}),d&&d.destroy(),u&&u.destroy()}),(x,T)=>{var j;return e.openBlock(),e.createElementBlock("div",Sb,[e.createElementVNode("h4",Cb,e.toDisplayString((j=x.filter)==null?void 0:j.name)+" Settings",1),e.createElementVNode("div",Vb,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(E,A)=>(e.openBlock(),e.createElementBlock("div",{key:A,class:"control-group"},[e.createElementVNode("label",null,e.toDisplayString(D(A)),1),e.createElementVNode("div",Nb,[e.createElementVNode("input",{type:"range",value:s.value[A],onInput:N=>$(A,N),min:E.min,max:E.max,step:E.step,class:"param-slider"},null,40,Tb),e.createElementVNode("span",Mb,e.toDisplayString(_(s.value[A],A)),1)])]))),128))]),e.createElementVNode("div",Bb,[e.createElementVNode("canvas",{ref_key:"previewCanvas",ref:i,class:"preview-canvas"},null,512),e.createElementVNode("button",{class:"compare-button",onMousedown:T[0]||(T[0]=E=>r.value=!0),onMouseup:T[1]||(T[1]=E=>r.value=!1),onTouchstart:T[2]||(T[2]=E=>r.value=!0),onTouchend:T[3]||(T[3]=E=>r.value=!1)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Io)},null,8,["icon"]),T[4]||(T[4]=e.createTextVNode(" Hold to compare ",-1))],32)]),p.value?(e.openBlock(),e.createElementBlock("div",Ib,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,E=>(e.openBlock(),e.createElementBlock("button",{key:E.name,class:e.normalizeClass(["preset-button",{active:C(E)}]),onClick:A=>S(E)},e.toDisplayString(E.name),11,Fb))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",$b,[e.createElementVNode("button",{class:"action-button",onClick:v},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Fa)},null,8,["icon"]),T[5]||(T[5]=e.createTextVNode(" Reset ",-1))]),e.createElementVNode("button",{class:"action-button primary",onClick:V},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Wd)},null,8,["icon"]),T[6]||(T[6]=e.createTextVNode(" Apply Filter ",-1))])])])}}}),Zs=Me(Db,[["__scopeId","data-v-3de3dd04"]]),Tu={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"}},Mu={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"}},Bu={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"}},Iu={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"}},Fu=[Tu,Mu,Bu,Iu],Bl={"mobile-share":Tu,"hd-web":Mu,original:Bu,"server-master":Iu},Rb=["mobile-share","hd-web"],Ab=["hd-web","original","mobile-share"],Lb=["server-master","hd-web","original","mobile-share"];function Nr(a){return typeof a=="string"?Bl[a]:a}function Pb(a){const{bitrate:n,codec:t,format:o,fps:i,quality:r}=Nr(a).settings,s={format:o,codec:t,quality:r,fps:i};return typeof n=="number"&&(s.bitrate=n),s}function Ob(a){const n=Nr(a);return n.settings.mobileSuitable&&n.settings.advancedVisibility==="standard"}function Ub(a=Fu){return a.filter(n=>Ob(n))}function zb(a,n){const t=Nr(a).settings.maxClientDurationSeconds;return t!==null&&Number.isFinite(n)&&n>=0&&n<=t}function jb(a,n){const t=Nr(a),o=n.endpoints.client&&zb(t,n.durationSeconds),i=n.endpoints.server;return t.settings.routePreference==="client"?o?"client":i?"server":null:t.settings.routePreference==="server"?i?"server":o?"client":null:o?"client":i?"server":null}function Wb(a,n){return jb(a,n)!==null}function Zb(a){const n=Hb(a);for(const t of n){const o=Bl[t];if(Xb(o,a.includeAdvanced===!0)&&!(a.device==="mobile"&&!o.settings.mobileSuitable)&&Wb(o,a))return o}return null}function Hb(a){return a.device==="mobile"?Rb:a.includeAdvanced===!0?Lb:Ab}function Xb(a,n){return a.settings.advancedVisibility==="hidden"?!1:a.settings.advancedVisibility==="standard"||n}const Gb={class:"export-settings"},Jb={class:"setting-group preset-setting"},Kb={class:"setting-copy"},Yb={class:"setting-description"},qb=["value"],Qb={key:0,class:"advanced-toggle","data-testid":"export-advanced-toggle"},ew={class:"preset-summary","data-testid":"export-preset-summary"},tw={class:"estimated-size"},nw={key:0,class:"export-progress"},aw={class:"progress-header"},ow={class:"progress-percentage"},iw={class:"progress-time"},rw={class:"action-buttons"},sw=["disabled"],lw=["disabled"],cw=["disabled"],dw={class:"export-options"},uw="hd-web",mw=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(a,{emit:n}){const t=a,o=n,i={client:!0,server:!0},r=Fu,s={"360p":1,"480p":2.5,"720p":5,"1080p":8,"1440p":16,"2160p":35},l=e.ref(!1),c=e.ref(v()),d=e.ref(!0),u=e.ref(!1),f=e.ref(0),p=e.ref(0),m=e.ref(0);let h=null;const g=e.computed(()=>t.isMobile?Ub():r.filter(E=>E.settings.advancedVisibility==="hidden"?!1:E.settings.advancedVisibility==="standard"||l.value)),k=e.computed(()=>g.value.find(E=>E.id===c.value)??Bl[v()]),$=e.computed(()=>Pb(k.value)),D=e.computed(()=>{const E=$.value,A=[E.quality,E.format.toUpperCase(),E.codec.toUpperCase(),`${E.fps} fps`],N=S(E.bitrate);return N!==null&&A.push(N),A.join(" / ")}),_=e.computed(()=>{const E=$.value,N=(typeof E.bitrate=="number"?E.bitrate/1e6:s[E.quality])*t.duration/8;return N<1e3?`~${Math.round(N)} MB`:`~${(N/1e3).toFixed(1)} GB`});function v(){var E;return((E=Zb({durationSeconds:t.duration,device:t.isMobile?"mobile":"desktop",endpoints:i,includeAdvanced:l.value}))==null?void 0:E.id)??uw}function S(E){return typeof E!="number"?null:`${Number((E/1e6).toFixed(1))} Mbps`}function C(){t.isExporting?(o("cancel-export"),T()):V()}function V(){const E=$.value,A={quality:E.quality,format:E.format,optimizeForWeb:d.value,includeWatermark:u.value,presetId:k.value.id,codec:E.codec,fps:E.fps};typeof E.bitrate=="number"&&(A.bitrate=E.bitrate),o("export",A),x()}function x(){f.value=Date.now(),p.value=0,h=window.setInterval(()=>{if(p.value=Math.floor((Date.now()-f.value)/1e3),t.exportProgress>0){const E=p.value/t.exportProgress*100;m.value=Math.max(0,E-p.value)}},1e3)}function T(){h&&(clearInterval(h),h=null)}function j(E){const A=Math.floor(E/60),N=Math.floor(E%60);return`${A}:${N.toString().padStart(2,"0")}`}return e.watch([()=>t.isMobile,()=>l.value],()=>{g.value.some(A=>A.id===c.value)||(c.value=v())},{immediate:!0}),e.watch(()=>t.isExporting,E=>{E||T()}),e.onUnmounted(()=>{T()}),(E,A)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["editor-controls",{mobile:E.isMobile}])},[e.createElementVNode("div",Gb,[A[8]||(A[8]=e.createElementVNode("h3",{class:"section-title"},"Export Settings",-1)),e.createElementVNode("div",Jb,[e.createElementVNode("div",Kb,[A[6]||(A[6]=e.createElementVNode("label",{for:"export-preset-select"},"Preset",-1)),e.createElementVNode("span",Yb,e.toDisplayString(k.value.description),1)]),e.withDirectives(e.createElementVNode("select",{id:"export-preset-select","onUpdate:modelValue":A[0]||(A[0]=N=>c.value=N),class:"setting-select preset-select","data-testid":"export-preset-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,N=>(e.openBlock(),e.createElementBlock("option",{key:N.id,value:N.id},e.toDisplayString(N.label),9,qb))),128))],512),[[e.vModelSelect,c.value]])]),E.isMobile?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("label",Qb,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":A[1]||(A[1]=N=>l.value=N),type:"checkbox","data-testid":"export-advanced-toggle-input"},null,512),[[e.vModelCheckbox,l.value]]),A[7]||(A[7]=e.createElementVNode("span",null,"Advanced presets",-1))])),e.createElementVNode("div",ew,e.toDisplayString(D.value),1),e.createElementVNode("div",tw,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Pf)},null,8,["icon"]),e.createElementVNode("span",null,"Estimated size: "+e.toDisplayString(_.value),1)])]),E.isExporting?(e.openBlock(),e.createElementBlock("div",nw,[e.createElementVNode("div",aw,[A[9]||(A[9]=e.createElementVNode("span",null,"Exporting...",-1)),e.createElementVNode("span",ow,e.toDisplayString(E.exportProgress??0)+"%",1)]),e.createVNode(e.unref(U.IonProgressBar),{value:(E.exportProgress??0)/100},null,8,["value"]),e.createElementVNode("div",iw,[e.createElementVNode("span",null,e.toDisplayString(j(p.value))+" elapsed",1),e.createElementVNode("span",null,e.toDisplayString(j(m.value))+" remaining",1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",rw,[e.createElementVNode("button",{class:"control-button secondary",onClick:A[2]||(A[2]=N=>E.$emit("save-draft")),disabled:!E.canExport||E.isExporting},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(pr)},null,8,["icon"]),A[10]||(A[10]=e.createTextVNode(" Save Draft ",-1))],8,sw),e.createElementVNode("button",{class:"control-button secondary",onClick:A[3]||(A[3]=N=>E.$emit("reset")),disabled:E.isExporting},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Fa)},null,8,["icon"]),A[11]||(A[11]=e.createTextVNode(" Reset ",-1))],8,lw),e.createElementVNode("button",{class:"control-button primary",onClick:C,disabled:!E.canExport&&!E.isExporting,"data-testid":"video-export-button"},[e.createVNode(e.unref(U.IonIcon),{icon:E.isExporting?e.unref(Na):e.unref(ao)},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(E.isExporting?"Cancel":"Export Video"),1)],8,cw)]),e.createElementVNode("div",dw,[e.createVNode(e.unref(U.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonCheckbox),{modelValue:d.value,"onUpdate:modelValue":A[4]||(A[4]=N=>d.value=N)},null,8,["modelValue"]),e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...A[12]||(A[12]=[e.createTextVNode("Optimize for web streaming",-1)])]),_:1})]),_:1}),e.createVNode(e.unref(U.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonCheckbox),{modelValue:u.value,"onUpdate:modelValue":A[5]||(A[5]=N=>u.value=N)},null,8,["modelValue"]),e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...A[13]||(A[13]=[e.createTextVNode("Include watermark",-1)])]),_:1})]),_:1})])],2))}}),Hs=Me(mw,[["__scopeId","data-v-d26ca1bc"]]),pw={class:"thumbnail-picker"},fw={class:"thumbnail-grid"},hw=["onClick"],vw=["src","alt"],gw={key:1,class:"thumbnail-placeholder"},yw={class:"thumbnail-time"},bw={class:"custom-selector"},ww={class:"time-input-group"},kw=["max"],_w={class:"time-value"},Ew=["disabled"],xw={class:"picker-actions"},Sw=["disabled"],Cw=e.defineComponent({__name:"ThumbnailPicker",props:{mediaUuid:{},duration:{},currentTime:{default:0}},emits:["select","cancel"],setup(a,{emit:n}){const t=a,o=n,i=e.ref([]),r=e.ref(-1),s=e.ref(t.currentTime),l=e.ref(!1);function c(){const $=[];if(t.duration<=10)for(let _=0;_<Math.min(9,t.duration);_++)$.push(_);else{const _=t.duration/10;for(let v=1;v<=9;v++)$.push(_*v)}return $}async function d($){try{const D=document.createElement("video");return D.crossOrigin="anonymous",D.src=await u(),new Promise(_=>{D.addEventListener("loadedmetadata",()=>{D.currentTime=$}),D.addEventListener("seeked",()=>{const v=document.createElement("canvas");v.width=D.videoWidth,v.height=D.videoHeight;const S=v.getContext("2d");S?(S.drawImage(D,0,0),_(v.toDataURL("image/jpeg",.8))):_(null),D.remove()}),D.addEventListener("error",()=>{_(null),D.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 $=c();i.value=$.map(_=>({time:_,loading:!0}));const D=3;for(let _=0;_<i.value.length;_+=D){const v=i.value.slice(_,_+D);await Promise.all(v.map(async S=>{const C=await d(S.time);C&&(S.dataUrl=C),S.loading=!1}))}}function p($){r.value=$,s.value=i.value[$].time}function m(){r.value=-1}async function h(){l.value=!0;try{const $=await d(s.value);if($){const D=i.value.findIndex(_=>Math.abs(_.time-s.value)<.1);D>=0?(i.value[D].dataUrl=$,r.value=D):(i.value.push({time:s.value,dataUrl:$}),r.value=i.value.length-1,i.value.sort((_,v)=>_.time-v.time),r.value=i.value.findIndex(_=>_.time===s.value))}}finally{l.value=!1}}function g(){const $=r.value>=0?i.value[r.value].time:s.value;o("select",$)}function k($){const D=Math.floor($/60),_=Math.floor($%60),v=Math.floor($%1*100);return D>0?`${D}:${_.toString().padStart(2,"0")}.${v.toString().padStart(2,"0")}`:`${_}.${v.toString().padStart(2,"0")}s`}return e.onMounted(()=>{f()}),($,D)=>(e.openBlock(),e.createElementBlock("div",pw,[D[5]||(D[5]=e.createElementVNode("h4",{class:"picker-title"},"Select Video Thumbnail",-1)),e.createElementVNode("div",fw,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(_,v)=>(e.openBlock(),e.createElementBlock("div",{key:v,class:e.normalizeClass(["thumbnail-item",{selected:r.value===v}]),onClick:S=>p(v)},[_.dataUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:_.dataUrl,alt:`Frame at ${k(_.time)}`},null,8,vw)):(e.openBlock(),e.createElementBlock("div",gw,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"})])),e.createElementVNode("div",yw,e.toDisplayString(k(_.time)),1)],10,hw))),128))]),e.createElementVNode("div",bw,[D[3]||(D[3]=e.createElementVNode("label",null,"Custom time:",-1)),e.createElementVNode("div",ww,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":D[0]||(D[0]=_=>s.value=_),min:0,max:$.duration,step:.1,onInput:m,class:"time-slider"},null,40,kw),[[e.vModelText,s.value]]),e.createElementVNode("span",_w,e.toDisplayString(k(s.value)),1)]),e.createElementVNode("button",{class:"capture-button",onClick:h,disabled:l.value},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Vf)},null,8,["icon"]),D[2]||(D[2]=e.createTextVNode(" Capture Frame ",-1))],8,Ew)]),e.createElementVNode("div",xw,[e.createElementVNode("button",{class:"action-button",onClick:D[1]||(D[1]=_=>$.$emit("cancel"))}," Cancel "),e.createElementVNode("button",{class:"action-button primary",onClick:g,disabled:r.value===-1},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Wd)},null,8,["icon"]),D[4]||(D[4]=e.createTextVNode(" Set Thumbnail ",-1))],8,Sw)])]))}}),Vw=Me(Cw,[["__scopeId","data-v-336c322c"]]),Nw={class:"text-overlay-panel p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},Tw={class:"mb-4"},Mw={class:"space-y-2 max-h-64 overflow-y-auto"},Bw={class:"flex items-center justify-between"},Iw={class:"flex-1"},Fw={class:"font-medium text-gray-900 dark:text-white"},$w={class:"text-sm text-gray-500 dark:text-gray-400"},Dw={class:"flex items-center space-x-2"},Rw=["onClick"],Aw=["onClick"],Lw={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},Pw={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},Ow={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},Uw={class:"space-y-4"},zw={class:"grid grid-cols-2 gap-4"},jw={class:"grid grid-cols-2 gap-4"},Ww={key:0,class:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},Zw={class:"grid grid-cols-2 gap-3"},Hw={class:"flex justify-end space-x-3 mt-6"},Xw=e.defineComponent({__name:"TextOverlayPanel",props:{overlays:{}},emits:["add-overlay","update-overlay","remove-overlay"],setup(a,{emit:n}){const t=n,o=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(p){Object.assign(s,p),i.value=p}function c(){o.value=!1,i.value=null,Object.assign(s,r())}function d(){const p={text:s.text,fontSize:s.fontSize,color:s.color,position:s.position,startTime:s.startTime,duration:s.duration};if(s.animationType&&(p.animation={type:s.animationType},s.animationDuration!==void 0&&(p.animation.duration=s.animationDuration),s.animationEasing&&(p.animation.easing=s.animationEasing),p.animation))switch(s.animationType){case"rotate":p.animation.rotation={from:0,to:360};break;case"scale":p.animation.scale={from:.5,to:1};break;case"slide":p.animation.translate={fromX:-100,toX:0,fromY:0,toY:0};break}i.value?t("update-overlay",i.value.id,p):t("add-overlay",p),c()}function u(p){confirm("Are you sure you want to remove this text overlay?")&&t("remove-overlay",p)}function f(p){const m=Math.floor(p/60),h=Math.floor(p%60);return`${m}:${h.toString().padStart(2,"0")}`}return(p,m)=>(e.openBlock(),e.createElementBlock("div",Nw,[e.createElementVNode("div",Tw,[m[11]||(m[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Text Overlays ",-1)),e.createElementVNode("button",{onClick:m[0]||(m[0]=h=>o.value=!0),class:"w-full px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"},[...m[10]||(m[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",Mw,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.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",Bw,[e.createElementVNode("div",Iw,[e.createElementVNode("div",Fw,e.toDisplayString(h.text.substring(0,30))+e.toDisplayString(h.text.length>30?"...":""),1),e.createElementVNode("div",$w,e.toDisplayString(f(h.startTime??0))+" - "+e.toDisplayString(f((h.startTime||0)+(h.duration||5))),1)]),e.createElementVNode("div",Dw,[e.createElementVNode("button",{onClick:g=>l(h),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Edit"},[...m[12]||(m[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,Rw),e.createElementVNode("button",{onClick:g=>u(h.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...m[13]||(m[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,Aw)])])]))),128)),p.overlays.length===0?(e.openBlock(),e.createElementBlock("div",Lw," No text overlays added yet ")):e.createCommentVNode("",!0)]),o.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(c,["self"])},[e.createElementVNode("div",Pw,[e.createElementVNode("h4",Ow,e.toDisplayString(i.value?"Edit":"Add")+" Text Overlay ",1),e.createElementVNode("div",Uw,[e.createElementVNode("div",null,[m[14]||(m[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":m[1]||(m[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",zw,[e.createElementVNode("div",null,[m[15]||(m[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":m[2]||(m[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,[m[16]||(m[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":m[3]||(m[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,[m[18]||(m[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":m[4]||(m[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"},[...m[17]||(m[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",jw,[e.createElementVNode("div",null,[m[19]||(m[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":m[5]||(m[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,[m[20]||(m[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":m[6]||(m[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,[m[22]||(m[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":m[7]||(m[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"},[...m[21]||(m[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",Ww,[m[26]||(m[26]=e.createElementVNode("div",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Animation Settings ",-1)),e.createElementVNode("div",Zw,[e.createElementVNode("div",null,[m[23]||(m[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":m[8]||(m[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,[m[25]||(m[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":m[9]||(m[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"},[...m[24]||(m[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",Hw,[e.createElementVNode("button",{onClick:c,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:d,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)]))}}),Xs=Me(Xw,[["__scopeId","data-v-f86e688c"]]),Gw={class:"transition-selector p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},Jw={class:"grid grid-cols-3 gap-3 max-h-96 overflow-y-auto"},Kw=["onClick"],Yw={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"},qw={key:0,class:"w-8 h-8 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Qw={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},ek={key:1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14 5l7 7m0 0l-7 7m7-7H3"},tk={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"},nk={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"},ak={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"},ok={class:"text-sm font-medium text-gray-900 dark:text-white text-center"},ik={key:0,class:"mt-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},rk={class:"space-y-3"},sk={class:"flex items-center space-x-2"},lk=["disabled"],ck=["disabled"],dk={key:1,class:"mt-4"},uk={class:"space-y-2 max-h-32 overflow-y-auto"},mk={class:"text-sm text-gray-700 dark:text-gray-300"},pk=["onClick"],fk=e.defineComponent({__name:"TransitionSelector",props:{selectedClips:{},appliedTransitions:{}},emits:["apply-transition","remove-transition","preview-transition"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(Go.getAvailableTransitions()),r=e.ref(null),s=e.ref(.5),l=e.ref("linear"),c=e.computed(()=>r.value&&t.selectedClips&&t.selectedClips.length>=2);function d(h){r.value=h}function u(){if(!r.value||!c.value)return;const h={type:r.value.type,duration:s.value,easing:l.value};o("apply-transition",h),r.value=null}function f(){if(!r.value)return;const h={type:r.value.type,duration:s.value,easing:l.value};o("preview-transition",h)}function p(h){o("remove-transition",h)}function m(h){return["fade","wipe","slide","zoom"].some(g=>h.includes(g))}return(h,g)=>(e.openBlock(),e.createElementBlock("div",Gw,[g[9]||(g[9]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"}," Transitions ",-1)),e.createElementVNode("div",Jw,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,k=>{var $;return e.openBlock(),e.createElementBlock("div",{key:k.type,onClick:D=>d(k),class:e.normalizeClass(["transition-item cursor-pointer rounded-lg p-3 border-2 transition-all",(($=r.value)==null?void 0:$.type)===k.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",Yw,[m(k.type)?(e.openBlock(),e.createElementBlock("svg",qw,[k.type.includes("fade")?(e.openBlock(),e.createElementBlock("path",Qw)):k.type.includes("wipe")?(e.openBlock(),e.createElementBlock("path",ek)):k.type.includes("slide")?(e.openBlock(),e.createElementBlock("path",tk)):k.type.includes("zoom")?(e.openBlock(),e.createElementBlock("path",nk)):(e.openBlock(),e.createElementBlock("path",ak))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",ok,e.toDisplayString(k.name),1)],10,Kw)}),128))]),r.value?(e.openBlock(),e.createElementBlock("div",ik,[g[6]||(g[6]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3"}," Transition Settings ",-1)),e.createElementVNode("div",rk,[e.createElementVNode("div",null,[g[3]||(g[3]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Duration (seconds) ",-1)),e.createElementVNode("div",sk,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":g[0]||(g[0]=k=>s.value=k),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":g[1]||(g[1]=k=>s.value=k),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,[g[5]||(g[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":g[2]||(g[2]=k=>l.value=k),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"},[...g[4]||(g[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:!c.value,class:e.normalizeClass(["w-full px-3 py-2 rounded-lg font-medium transition-colors",c.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,lk),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,ck)])])):e.createCommentVNode("",!0),h.appliedTransitions.length>0?(e.openBlock(),e.createElementBlock("div",dk,[g[8]||(g[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Applied Transitions ",-1)),e.createElementVNode("div",uk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.appliedTransitions,(k,$)=>(e.openBlock(),e.createElementBlock("div",{key:$,class:"flex items-center justify-between p-2 bg-gray-50 dark:bg-gray-700 rounded"},[e.createElementVNode("div",mk,e.toDisplayString(k.name)+" ("+e.toDisplayString(k.duration)+"s) ",1),e.createElementVNode("button",{onClick:D=>p($),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded"},[...g[7]||(g[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,pk)]))),128))])])):e.createCommentVNode("",!0),g[10]||(g[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))]))}}),Gs=Me(fk,[["__scopeId","data-v-ffcc612d"]]),hk={class:"audio-track-manager p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},vk={class:"mb-4"},gk={class:"mb-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},yk={class:"flex items-center justify-between mb-2"},bk={class:"text-sm text-gray-600 dark:text-gray-400"},wk={class:"flex items-center space-x-2"},kk={class:"space-y-3 max-h-64 overflow-y-auto"},_k={class:"flex items-center justify-between mb-2"},Ek={class:"font-medium text-gray-900 dark:text-white"},xk={class:"flex items-center space-x-2"},Sk=["onClick","title"],Ck={key:0,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},Vk={key:1,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},Nk=["onClick"],Tk=["onClick"],Mk={class:"flex items-center space-x-2"},Bk={class:"text-xs text-gray-500 dark:text-gray-400 w-10"},Ik=["value","onInput","disabled"],Fk={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},$k={key:0,class:"ml-2"},Dk={key:1,class:"ml-2"},Rk={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},Ak={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},Lk={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},Pk={class:"space-y-4"},Ok={class:"space-y-2"},Uk={class:"flex items-center"},zk={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},jk={class:"grid grid-cols-2 gap-4"},Wk={class:"grid grid-cols-2 gap-4"},Zk={class:"flex items-center"},Hk={class:"flex justify-end space-x-3 mt-6"},Xk=["disabled"],Gk=e.defineComponent({__name:"AudioTrackManager",props:{audioLayers:{},masterVolume:{}},emits:["add-track","update-track","remove-track","update-volume","toggle-mute","update-master-volume"],setup(a,{emit:n}){const t=a,o=n,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}),c=e.reactive(l()),d=e.computed(()=>c.sourceUrl||c.sourceFile);function u(_){const v=_.target;v.files&&v.files[0]&&(c.sourceFile=v.files[0],c.name=c.name||v.files[0].name.replace(/\.[^/.]+$/,""))}function f(_){Object.assign(c,_),r.value=_}function p(){i.value=!1,r.value=null,Object.assign(c,l())}function m(){if(!d.value)return;const _={source:c.sourceFile??c.sourceUrl??"",name:c.name,volume:c.volume,startTime:c.startTime,loop:c.loop};c.duration!==void 0&&(_.duration=c.duration),c.fadeIn>0&&(_.fadeIn=c.fadeIn),c.fadeOut>0&&(_.fadeOut=c.fadeOut),r.value?o("update-track",r.value.id,_):o("add-track",_),p()}function h(_){confirm("Are you sure you want to remove this audio track?")&&o("remove-track",_)}function g(_,v){const S=v.target,C=parseFloat(S.value);o("update-volume",_.id,C)}function k(_){o("toggle-mute",_.id,!_.muted)}function $(){o("update-master-volume",s.value)}function D(_){const v=Math.floor(_/60),S=Math.floor(_%60);return`${v}:${S.toString().padStart(2,"0")}`}return(_,v)=>(e.openBlock(),e.createElementBlock("div",hk,[e.createElementVNode("div",vk,[v[11]||(v[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Audio Tracks ",-1)),e.createElementVNode("button",{onClick:v[0]||(v[0]=S=>i.value=!0),class:"w-full px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors"},[...v[10]||(v[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",gk,[e.createElementVNode("div",yk,[v[12]||(v[12]=e.createElementVNode("label",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"}," Master Volume ",-1)),e.createElementVNode("span",bk,e.toDisplayString(Math.round(s.value*100))+"% ",1)]),e.createElementVNode("div",wk,[v[13]||(v[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":v[1]||(v[1]=S=>s.value=S),onInput:$,type:"range",min:"0",max:"1",step:"0.01",class:"flex-1"},null,544),[[e.vModelText,s.value,void 0,{number:!0}]]),v[14]||(v[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",kk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.audioLayers,S=>(e.openBlock(),e.createElementBlock("div",{key:S.id,class:"p-3 border border-gray-200 dark:border-gray-700 rounded-lg"},[e.createElementVNode("div",_k,[e.createElementVNode("div",Ek,e.toDisplayString(S.name),1),e.createElementVNode("div",xk,[e.createElementVNode("button",{onClick:C=>k(S),class:e.normalizeClass(["p-1 rounded",S.muted?"text-red-600 bg-red-50 dark:bg-red-900":"text-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700"]),title:S.muted?"Unmute":"Mute"},[S.muted?(e.openBlock(),e.createElementBlock("svg",Vk,[...v[16]||(v[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",Ck,[...v[15]||(v[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,Sk),e.createElementVNode("button",{onClick:C=>f(S),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Settings"},[...v[17]||(v[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,Nk),e.createElementVNode("button",{onClick:C=>h(S.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...v[18]||(v[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,Tk)])]),e.createElementVNode("div",Mk,[e.createElementVNode("span",Bk,e.toDisplayString(Math.round((S.volume||1)*100))+"% ",1),e.createElementVNode("input",{value:S.volume||1,onInput:C=>g(S,C),type:"range",min:"0",max:"1",step:"0.01",class:"flex-1",disabled:S.muted},null,40,Ik)]),e.createElementVNode("div",Fk,[e.createTextVNode(e.toDisplayString(D(S.startTime||0))+" - "+e.toDisplayString(D((S.startTime||0)+(S.duration||0)))+" ",1),S.fadeIn?(e.openBlock(),e.createElementBlock("span",$k,"Fade In: "+e.toDisplayString(S.fadeIn)+"s",1)):e.createCommentVNode("",!0),S.fadeOut?(e.openBlock(),e.createElementBlock("span",Dk,"Fade Out: "+e.toDisplayString(S.fadeOut)+"s",1)):e.createCommentVNode("",!0)])]))),128)),_.audioLayers.length===0?(e.openBlock(),e.createElementBlock("div",Rk," 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(p,["self"])},[e.createElementVNode("div",Ak,[e.createElementVNode("h4",Lk,e.toDisplayString(r.value?"Edit":"Add")+" Audio Track ",1),e.createElementVNode("div",Pk,[e.createElementVNode("div",null,[v[20]||(v[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",Ok,[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",Uk,[v[19]||(v[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":v[2]||(v[2]=S=>c.sourceUrl=S),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,c.sourceUrl]])])])]),e.createElementVNode("div",null,[v[21]||(v[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":v[3]||(v[3]=S=>c.name=S),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,c.name]])]),e.createElementVNode("div",null,[e.createElementVNode("label",zk," Volume: "+e.toDisplayString(Math.round(c.volume*100))+"% ",1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":v[4]||(v[4]=S=>c.volume=S),type:"range",min:"0",max:"1",step:"0.01",class:"w-full"},null,512),[[e.vModelText,c.volume,void 0,{number:!0}]])]),e.createElementVNode("div",jk,[e.createElementVNode("div",null,[v[22]||(v[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":v[5]||(v[5]=S=>c.startTime=S),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,c.startTime,void 0,{number:!0}]])]),e.createElementVNode("div",null,[v[23]||(v[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":v[6]||(v[6]=S=>c.duration=S),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,c.duration,void 0,{number:!0}]])])]),e.createElementVNode("div",Wk,[e.createElementVNode("div",null,[v[24]||(v[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":v[7]||(v[7]=S=>c.fadeIn=S),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,c.fadeIn,void 0,{number:!0}]])]),e.createElementVNode("div",null,[v[25]||(v[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":v[8]||(v[8]=S=>c.fadeOut=S),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,c.fadeOut,void 0,{number:!0}]])])]),e.createElementVNode("div",Zk,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":v[9]||(v[9]=S=>c.loop=S),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,c.loop]]),v[26]||(v[26]=e.createElementVNode("label",{for:"loop-checkbox",class:"text-sm text-gray-700 dark:text-gray-300"}," Loop audio track ",-1))])]),e.createElementVNode("div",Hk,[e.createElementVNode("button",{onClick:p,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:m,disabled:!d.value,class:e.normalizeClass(["px-4 py-2 rounded-lg transition-colors",d.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,Xk)])])])):e.createCommentVNode("",!0)]))}}),Js=Me(Gk,[["__scopeId","data-v-593719ac"]]);function Qe(a,n={},...t){const o=document.createElement(a);for(const[i,r]of Object.entries(n))r!=null&&(i==="className"?o.className=r:i==="style"&&typeof r=="object"?Object.assign(o.style,r):i.startsWith("on")&&typeof r=="function"?o.addEventListener(i.slice(2).toLowerCase(),r):i==="dataset"&&typeof r=="object"?Object.assign(o.dataset,r):o.setAttribute(i,r));for(const i of t)typeof i=="string"?o.appendChild(document.createTextNode(i)):i instanceof HTMLElement&&o.appendChild(i);return o}function Uc(a){return typeof a=="boolean"?a?"On":"Off":typeof a=="number"?Number.isInteger(a)?String(a):a.toFixed(2):String(a??"")}let zc=!1;function Jk(){if(zc)return;zc=!0;const a=`
|
|
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
|
-
`,n=document.createElement("style");n.textContent=a,document.head.appendChild(n)}class Kk{constructor({filters:n=[],callbacks:t={}}){Jk(),this._filters=n,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(n){return this._root=Qe("div",{className:"mvfp"}),this._catRow=Qe("div",{className:"mvfp-row"}),this._root.appendChild(this._catRow),this._filterRow=Qe("div",{className:"mvfp-row"}),this._root.appendChild(this._filterRow),this._activeRow=Qe("div",{className:"mvfp-active-row"}),this._root.appendChild(this._activeRow),this._buildDrawer(),this._root.appendChild(this._drawer),this._renderCategories(),this._renderFilters(),this._renderActiveChips(),n.appendChild(this._root),this._root}setFilters(n){this._filters=n,this._renderCategories(),this._renderFilters()}setActiveFilters(n){this._activeFilters.clear(),n&&n.forEach((t,o)=>{this._activeFilters.set(o,t)}),this._renderFilters(),this._renderActiveChips(),this._drawerOpen&&this._drawerFilterId&&!this._activeFilters.has(this._drawerFilterId)&&this.closeDrawer()}destroy(){var n;this.closeDrawer(),(n=this._root)==null||n.remove(),this._root=null}_getCategories(){const n=new Map;n.set("all","All");for(const t of this._filters){const o=t.category||"other";n.has(o)||n.set(o,o.charAt(0).toUpperCase()+o.slice(1))}return n}_renderCategories(){this._catRow.innerHTML="",this._getCategories().forEach((t,o)=>{const i=Qe("div",{className:`mvfp-cat${this._selectedCategory===o?" active":""}`,onClick:()=>{this._selectedCategory=o,this._renderCategories(),this._renderFilters()}},t);this._catRow.appendChild(i)})}_currentFilters(){return this._selectedCategory==="all"?this._filters:this._filters.filter(n=>(n.category||"other")===this._selectedCategory)}_renderFilters(){this._filterRow.innerHTML="";for(const n of this._currentFilters()){const t=this._activeFilters.has(n.id),o=this._selectedFilterId===n.id,i=Qe("div",{className:`mvfp-filter${t?" active":""}${o?" selected":""}`,onClick:()=>this._selectFilter(n)});if(t){const r=Qe("div",{className:"mvfp-check",onClick:s=>{s.stopPropagation(),this._removeFilter(n.id)}});r.innerHTML="✓",i.appendChild(r)}i.appendChild(Qe("span",{},n.name)),this._filterRow.appendChild(i)}}_selectFilter(n){var t,o,i,r;this._selectedFilterId=n.id,this._activeFilters.has(n.id)||(o=(t=this._cb).onApplyFilter)==null||o.call(t,n),(r=(i=this._cb).onPreviewFilter)==null||r.call(i,n),this._renderFilters(),n.params&&n.params.length>0&&this.openDrawer(n.id)}_removeFilter(n){var t,o;(o=(t=this._cb).onRemoveFilter)==null||o.call(t,n),this._selectedFilterId===n&&(this._selectedFilterId=null)}_renderActiveChips(){if(this._activeRow.innerHTML="",this._activeFilters.size===0){this._activeRow.appendChild(Qe("div",{className:"mvfp-placeholder"},"No active filters"));return}this._activeFilters.forEach((n,t)=>{const o=this._filters.find(c=>c.id===t);if(!o)return;const i=this._drawerOpen&&this._drawerFilterId===t,r=Qe("div",{className:`mvfp-achip${i?" selected":""}`}),s=Qe("span",{style:{cursor:"pointer"},onClick:()=>{this._selectedFilterId=t,this._renderFilters(),o.params&&o.params.length>0&&this.openDrawer(t)}},o.name),l=Qe("button",{className:"mvfp-achip-x","aria-label":`Remove ${o.name}`,onClick:c=>{c.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=Qe("div",{className:"mvfp-drawer"});const n=Qe("div",{className:"mvfp-drawer-hdr"});this._drawerTitle=Qe("span",{className:"mvfp-drawer-title"},"Filter");const t=Qe("div",{className:"mvfp-drawer-actions"});t.appendChild(Qe("button",{className:"mvfp-drawer-btn",onClick:()=>this._resetDrawerFilter()},"Reset")),t.appendChild(Qe("button",{className:"mvfp-drawer-btn danger",onClick:()=>{this._drawerFilterId&&(this._removeFilter(this._drawerFilterId),this.closeDrawer())}},"Remove"));const o=Qe("button",{className:"mvfp-drawer-close","aria-label":"Close",onClick:()=>this.closeDrawer()});o.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(o),n.appendChild(this._drawerTitle),n.appendChild(t),this._drawer.appendChild(n),this._drawerBody=Qe("div",{className:"mvfp-drawer-body"}),this._drawer.appendChild(this._drawerBody)}openDrawer(n){const t=this._filters.find(o=>o.id===n);if(t&&(this._drawerFilterId=n,this._drawerTitle.textContent=t.name,this._renderDrawerControls(t),this._renderActiveChips(),!this._drawerOpen)){this._drawerOpen=!0;const o=this._root.offsetHeight;o>0&&(this._drawer.style.height=o+"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(n){if(this._drawerBody.innerHTML="",!n.params||n.params.length===0){this._drawerBody.appendChild(Qe("div",{className:"mvfp-no-params"},"No adjustable parameters"));return}const t=this._activeFilters.get(n.id),o=(t==null?void 0:t.params)||{};for(const i of n.params){const r=o[i.id]??i.default,s=Qe("div",{className:"mvfp-ctl"}),l=Qe("label",{className:"mvfp-ctl-label"},i.label||i.id);s.appendChild(l);const c=i.type||"slider";if(c==="slider"||c==="range"){const d=Qe("div",{className:"mvfp-slider-row"}),u=Qe("span",{className:"mvfp-range-val"},Uc(r)),f=Qe("input",{type:"range",className:"mvfp-range",min:String(i.min??0),max:String(i.max??1),step:String(i.step??.01),value:String(typeof r=="number"?r:i.default??0),onInput:p=>{var h,g;const m=parseFloat(p.target.value);u.textContent=Uc(m),(g=(h=this._cb).onUpdateParam)==null||g.call(h,n.id,i.id,m)}});d.appendChild(f),d.appendChild(u),s.appendChild(d)}else if(c==="toggle"||c==="checkbox"){const d=Qe("div",{className:"mvfp-toggle-row"}),u=Qe("input",{type:"checkbox",checked:r?"checked":void 0,onChange:f=>{var p,m;return(m=(p=this._cb).onUpdateParam)==null?void 0:m.call(p,n.id,i.id,f.target.checked)}});d.appendChild(u),s.appendChild(d)}else if(c==="color"){const d=Qe("div",{className:"mvfp-color-row"}),u=Qe("input",{type:"color",className:"mvfp-color-input",value:typeof r=="string"?r:"#000000",onInput:f=>{var p,m;return(m=(p=this._cb).onUpdateParam)==null?void 0:m.call(p,n.id,i.id,f.target.value)}});d.appendChild(u),s.appendChild(d)}else if(c==="select"||c==="dropdown"){const d=Qe("div",{className:"mvfp-select-row"}),u=Qe("select",{className:"mvfp-select",onChange:f=>{var p,m;return(m=(p=this._cb).onUpdateParam)==null?void 0:m.call(p,n.id,i.id,f.target.value)}});for(const f of i.options||[]){const p=Qe("option",{value:f.value},f.label||String(f.value));f.value===r&&(p.selected=!0),u.appendChild(p)}d.appendChild(u),s.appendChild(d)}this._drawerBody.appendChild(s)}}_resetDrawerFilter(){var t,o;if(!this._drawerFilterId)return;const n=this._filters.find(i=>i.id===this._drawerFilterId);if(n!=null&&n.params){for(const i of n.params)(o=(t=this._cb).onUpdateParam)==null||o.call(t,this._drawerFilterId,i.id,i.default);this._renderDrawerControls(n)}}}const Yk=[200,500,1e3];function qk(a){return{"360p":[640,360],"480p":[854,480],"720p":[1280,720],"1080p":[1920,1080],"1440p":[2560,1440],"2160p":[3840,2160]}[a??""]??[1920,1080]}function jc(a){if(!a)return null;const n=a.duration;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n;if(n&&typeof n=="object"&&"value"in n){const t=n.value;if(typeof t=="number"&&Number.isFinite(t)&&t>0)return t}return null}function Qk(a){return new Promise(n=>{window.setTimeout(n,a)})}async function Wc(){return await Promise.resolve().then(()=>require("./PixiFrameExporter-6l-tVJXc.cjs"))}function Zc(a,n=0){var r;const t=a.timeline[0],o=t?Math.max(0,t.sourceIn):0,i=(t==null?void 0:t.sourceOut)??((r=a.source)==null?void 0:r.duration)??n;return Math.max(0,i-o)}function $u(a){let n=null;return{canExportClientSide:async()=>{try{const{isWebCodecsSupported:i}=await Wc();return i()}catch{return!1}},renderRecipeWithPixi:async(i,r,s)=>{var m,h,g,k;const l=i.timeline[0],c=l?Math.max(0,l.sourceIn):0,d=l?l.sourceOut:void 0,[u,f]=qk((r==null?void 0:r.quality)??((m=i.output)==null?void 0:m.quality)),p=((h=i.output)==null?void 0:h.fps)||30;a.setPlaying(!1),a.forcePixiPreview.value=!0,await e.nextTick();try{let $=!1;for(const z of Yk){await Qk(z);const P=a.getPreviewRef();if(!(!P||typeof P.captureFrameAt!="function")){if(typeof P.ensureReadyForCapture=="function"){if($=await P.ensureReadyForCapture(),$)break;continue}$=!0;break}}const D=a.getPreviewRef();if(!D||typeof D.captureFrameAt!="function")throw new Error("PIXI preview not available for export. Ensure the preview is mounted.");if(!$)throw new Error("PIXI preview not ready for frame capture after retries. The video may still be loading.");const{exportWithPixiFrames:_,isWebCodecsSupported:v}=await Wc();if(!v())throw new Error("WebCodecs is not supported in this browser. Export requires Chrome 94+ or equivalent.");n=new AbortController;const S={width:u,height:f,fps:p,trimStart:c,signal:n.signal};d!==void 0&&(S.trimEnd=d),s&&(S.onProgress=s);const C=a.getSourceUrl();C!==""&&(S.sourceUrl=C);const V=jc(D)??((g=i.source)==null?void 0:g.duration)??d??0,x=await _({captureFrameAt:z=>{var P;return((P=D.captureFrameAt)==null?void 0:P.call(D,z))??Promise.resolve(null)},duration:{value:V}},S),T=new File([x],`edited-video-${Date.now()}.mp4`,{type:"video/mp4"}),j=jc(D),E=((k=i.source)==null?void 0:k.duration)??0,N=Math.max(0,(d??j??E)-c);return{file:T,recipe:i,meta:{duration:N,width:u,height:f,format:"mp4",sizeBytes:T.size,size_bytes:T.size}}}finally{a.forcePixiPreview.value=!1,n=null}},cancelClientExport:()=>{n==null||n.abort(),n=null},resetClientExport:()=>{n=null}}}const so="default-video-track",ra="default-media-source";function Du(a){var r,s;const n=t2(a),t=n2(a),o=a2(a.timeline,((r=t[0])==null?void 0:r.id)??so,((s=n[0])==null?void 0:s.id)??ra),i={version:a.version,source:{...a.source},mediaSources:n,tracks:o2(t,o),clips:o,markers:a.markers?a.markers.map(l=>({...l})):[],transitions:a.transitions?a.transitions.map(Lu):[],filters:a.filters.map(l=>({...l,params:{...l.params}})),audio:{...a.audio},output:{...a.output}};return typeof a.duration=="number"&&(i.duration=a.duration),a.snapSettings&&(i.snapSettings={...a.snapSettings}),a.textOverlays&&(i.textOverlays=[...a.textOverlays]),a.captionTracks&&(i.captionTracks=a.captionTracks.map(Pu)),a.visualLayers&&(i.visualLayers=a.visualLayers.map(Ou)),a.audioTracks&&(i.audioTracks=[...a.audioTracks]),a.posterFrame&&(i.posterFrame=a.posterFrame),a.metadata&&(i.metadata={...a.metadata}),i}function e2(a){const n={version:"1.0",source:{...a.source},timeline:a.clips.map(t=>({...t})),mediaSources:a.mediaSources.map(Ru),tracks:a.tracks.map(Au),markers:a.markers.map(t=>({...t})),transitions:a.transitions.map(Lu),filters:a.filters.map(t=>({...t,params:{...t.params}})),audio:{...a.audio},output:{...a.output}};return typeof a.duration=="number"&&(n.duration=a.duration),a.snapSettings&&(n.snapSettings={...a.snapSettings}),a.textOverlays&&(n.textOverlays=[...a.textOverlays]),a.captionTracks&&(n.captionTracks=a.captionTracks.map(Pu)),a.visualLayers&&(n.visualLayers=a.visualLayers.map(Ou)),a.audioTracks&&(n.audioTracks=[...a.audioTracks]),a.posterFrame&&(n.posterFrame=a.posterFrame),a.metadata&&(n.metadata={...a.metadata}),n}function t2(a){var t,o;if(a.mediaSources&&a.mediaSources.length>0)return a.mediaSources.map(Ru);const n={id:((t=a.timeline.find(i=>i.sourceRefId))==null?void 0:t.sourceRefId)??ra,type:"media",mediaUuid:a.source.media_uuid,duration:a.source.duration,width:a.source.original_width,height:a.source.original_height};return(o=a.metadata)!=null&&o.source_url&&(n.url=a.metadata.source_url),[n]}function n2(a){var n;return a.tracks&&a.tracks.length>0?a.tracks.map(Au):[{id:((n=a.timeline.find(t=>t.trackId))==null?void 0:n.trackId)??so,type:"video",name:"Video",order:0}]}function a2(a,n,t){return a.map(o=>{const i={...o,trackId:o.trackId??n,sourceRefId:o.sourceRefId??t};return o.filters&&(i.filters=o.filters.map(r=>({...r,params:{...r.params}}))),o.transform&&(i.transform={...o.transform}),o.keyframes&&(i.keyframes=o.keyframes.map(r=>({...r}))),i})}function o2(a,n){return a.map(t=>{const o=n.filter(i=>i.trackId===t.id).map(i=>i.id);return{...t,clipIds:o}})}function Ru(a){const n={...a};return a.metadata&&(n.metadata={...a.metadata}),n}function Au(a){const n={...a};return a.clipIds&&(n.clipIds=[...a.clipIds]),n}function Lu(a){const n={...a};return a.params&&(n.params={...a.params}),n}function Pu(a){return{...a,segments:a.segments.map(t=>{const o={...t};return t.words&&(o.words=t.words.map(i=>({...i}))),o})}}function Ou(a){return{...a,transform:{...a.transform,position:{...a.transform.position},anchor:{...a.transform.anchor},scale:{...a.transform.scale}},keyframes:a.keyframes?a.keyframes.map(n=>({...n})):void 0}}const Uu="video-project-draft-snapshot:v1",Ks="mediables:video-project-drafts",i2=(a,n={})=>{var p,m;const t=Jn(n.now)??Date.now(),o=Jn(n.createdAt)??t,i=Jn(n.updatedAt)??t,r=g2(a),s={id:bn(n.id)??k2(i),payloadKind:r,createdAt:new Date(o).toISOString(),updatedAt:new Date(i).toISOString(),deviceKind:n.deviceKind??"unknown"},l=bn(n.projectId),c=bn(n.sourceMediaUuid)??bn(a.source.media_uuid),d=Ys(n.durationSeconds)??y2(a),u=bn(n.editorVersion)??bn((p=a.metadata)==null?void 0:p.editor_version),f=bn(n.title)??bn((m=a.metadata)==null?void 0:m.title);return l!==null&&(s.projectId=l),c!==null&&(s.sourceMediaUuid=c),d!==null&&(s.durationSeconds=d),u!==null&&(s.editorVersion=u),f!==null&&(s.title=f),n.saveReason!==void 0&&(s.saveReason=n.saveReason),{schemaVersion:Uu,metadata:s,payload:a}},zu=(a,n=Ks)=>{const t=bn(n)??Ks,o=Kc(a.metadata.projectId??"unsaved-project"),i=Kc(a.metadata.id);return`${t}:${o}:${i}`},r2=a=>JSON.stringify(a),s2=a=>{if(typeof a!="string"||a.trim().length===0)return null;try{const n=JSON.parse(a);return f2(n)?n:null}catch{return null}},l2=a=>{const n=[];for(const t of a){const o=bn(t.key),i=s2(t.value);o===null||i===null||n.push({key:o,snapshot:i})}return jo(n)},c2=(a,n)=>{const t=w2(n.maxCount),o=Jn(n.now)??Date.now(),i=Xu(n.maxAgeMs),r=[],s=[];let l=0;for(const c of jo(a)){if(!Zu(c,n.projectId)){r.push(c);continue}if(Hu(c.snapshot,o,i)||l>=t){s.push(c);continue}r.push(c),l+=1}return{retained:jo(r),removed:jo(s)}},d2=(a,n={})=>{const t={key:zu(a),snapshot:a};if(!Zu(t,n.projectId))return!1;const o=Jn(n.now)??Date.now(),i=Xu(n.maxAgeMs);if(Hu(a,o,i))return!1;const r=n.savedAt===null?null:Jn(n.savedAt);return r===null?!0:rr(a)>r},u2=(a,n={})=>jo(a).filter(t=>d2(t.snapshot,n)),m2=(a,n,t={})=>{const o=u2(a,t);if(n==="mobile"){const i=o[0]??null;return i===null?[]:[i]}return o},p2=async(a,n,t=zu(n))=>(await a.setItem(t,r2(n)),{key:t,snapshot:n}),Hc=async(a,n=Ks)=>{const t=await a.listKeys(n),o=[];for(const i of t)o.push({key:i,value:await a.getItem(i)});return l2(o)},Xc=async(a,n)=>{for(const t of n)await a.removeItem(t.key)},f2=a=>!Kn(a)||a.schemaVersion!==Uu||!h2(a.metadata)?!1:a.metadata.payloadKind==="project"?ju(a.payload):v2(a.payload),h2=a=>Kn(a)?Il(a.id)&&E2(a.payloadKind)&&Jc(a.createdAt)&&Jc(a.updatedAt)&&x2(a.deviceKind)&&Ti(a.projectId)&&Ti(a.sourceMediaUuid)&&_2(a.durationSeconds)&&Ti(a.editorVersion)&&Ti(a.title)&&S2(a.saveReason):!1,v2=a=>Kn(a)?a.version==="1.0"&&Wu(a.source)&&Array.isArray(a.timeline)&&Array.isArray(a.filters)&&Kn(a.audio)&&Kn(a.output):!1,ju=a=>Kn(a)?a.version==="1.0"&&Wu(a.source)&&Array.isArray(a.mediaSources)&&Array.isArray(a.tracks)&&Array.isArray(a.clips)&&Array.isArray(a.markers)&&Array.isArray(a.filters)&&Kn(a.audio)&&Kn(a.output):!1,Wu=a=>Kn(a)?Il(a.media_uuid)&&Wo(a.duration)&&Wo(a.original_width)&&Wo(a.original_height):!1,g2=a=>ju(a)?"project":"recipe",y2=a=>Ys(a.duration)??Ys(a.source.duration),Zu=(a,n)=>{const t=bn(n);return t===null?!0:a.snapshot.metadata.projectId===t},Hu=(a,n,t)=>t===null?!1:n-rr(a)>t,jo=a=>[...a].sort(b2),b2=(a,n)=>{const t=rr(n.snapshot)-rr(a.snapshot);if(t!==0)return t;const o=Gc(n.snapshot)-Gc(a.snapshot);return o!==0?o:a.snapshot.metadata.id.localeCompare(n.snapshot.metadata.id)},rr=a=>Jn(a.metadata.updatedAt)??0,Gc=a=>Jn(a.metadata.createdAt)??0,w2=a=>!Number.isFinite(a)||a<0?0:Math.floor(a),Xu=a=>a===void 0||!Number.isFinite(a)||a<0?null:Math.floor(a),Jn=a=>{if(a==null)return null;if(a instanceof Date)return Number.isFinite(a.getTime())?a.getTime():null;if(typeof a=="number")return Number.isFinite(a)?a:null;const n=a.trim();if(n.length===0)return null;const t=Date.parse(n);return Number.isFinite(t)?t:null},Jc=a=>typeof a=="string"&&Jn(a)!==null,k2=a=>{var t;const n=typeof((t=globalThis.crypto)==null?void 0:t.randomUUID)=="function"?globalThis.crypto.randomUUID():Math.random().toString(36).slice(2,12);return`draft-${a}-${n}`},Kc=a=>encodeURIComponent(a.trim()),bn=a=>{if(typeof a!="string")return null;const n=a.trim();return n.length>0?n:null},Il=a=>bn(a)!==null,Ti=a=>a===void 0||Il(a),Ys=a=>{if(!Wo(a))return null;const n=Number(a.toFixed(6));return Object.is(n,-0)?0:n},Wo=a=>typeof a=="number"&&Number.isFinite(a)&&a>=0,_2=a=>a===void 0||Wo(a),E2=a=>a==="recipe"||a==="project",x2=a=>a==="desktop"||a==="mobile"||a==="tablet"||a==="unknown",S2=a=>a===void 0||a==="autosave"||a==="manual"||a==="before-export"||a==="before-close",Kn=a=>typeof a=="object"&&a!==null&&!Array.isArray(a),C2=1,V2="master",Jo=-60,qs=12,Fl=0,sa=-90,sr=6,N2=4,Gu=8;function Ju(){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:Gu}}}function T2(a,n=Ju()){return el(n[a])}function Ku(a){return Number.isNaN(a)?Fl:a<=0||a===Number.NEGATIVE_INFINITY?Jo:Ko(20*Math.log10(a))}function Qs(a){const n=Ko(a);return n<=Jo?0:ca(Math.pow(10,n/20),6)}function Ko(a){return Number.isNaN(a)?Fl:a===Number.NEGATIVE_INFINITY?Jo:a===Number.POSITIVE_INFINITY?qs:ca(si(a,Jo,qs),3)}function Yu(a){return Number.isFinite(a)?ca(si(a,-1,1),3):0}function M2(a,n=!1){const t=a.some(o=>o.controls.solo);return a.map(o=>{const i=o.controls.muted,r=t&&!o.controls.solo,s=n||i||r,l=s?0:o.controls.fader.linearGain;return{trackId:o.id,soloed:o.controls.solo,mutedByTrack:i,mutedBySolo:r,mutedByMaster:n,effectivelyMuted:s,audible:!s,effectiveGainLinear:l}})}function B2(a,n={}){const t=z2(n.effectSlotCount),o=new Set;return{schemaVersion:C2,capabilities:n.capabilities?H2(n.capabilities):Ju(),tracks:a.map((i,r)=>F2(i,r,t,o)),master:$2(n.master,t)}}function qu(a){const n=Ko(a);return{valueDb:n,minDb:Jo,maxDb:qs,unityDb:Fl,linearGain:Qs(n)}}function I2(a,n="constant-power"){return{value:Yu(a),mode:n}}function Qu(a=sa,n=sa,t=a){const o=ms(a),i=ms(n),r=ms(t);return{peakDb:o,rmsDb:i,peakHoldDb:r,clipping:o>=0||r>=0}}function em(a){const n=am(a);return{id:`empty-effect-slot-${n}`,index:n,kind:"empty",label:"Empty",enabled:!1,bypassed:!0,wetMix:0,parameters:{}}}function F2(a,n,t,o){const i=nm(a.id),s={id:U2(i??`legacy-audio-track-${n+1}`,o),kind:"legacy-url",name:L2(a.name,n),order:n,source:D2(a.source),controls:{fader:qu(a.faderDb??Ku(a.volume??1)),pan:I2(a.pan??0),muted:a.muted??!1,solo:a.solo??!1,meter:Qu(a.peakDb,a.rmsDb,a.peakHoldDb)},timeline:R2(a),effectSlots:tm(a.effectSlots,t)};return i!==void 0&&(s.legacyTrackId=i),s}function $2(a,n){return{id:V2,name:P2(a==null?void 0:a.name),fader:qu((a==null?void 0:a.faderDb)??Ku((a==null?void 0:a.volume)??1)),muted:(a==null?void 0:a.muted)??!1,meter:Qu(a==null?void 0:a.peakDb,a==null?void 0:a.rmsDb,a==null?void 0:a.peakHoldDb),effectSlots:tm(a==null?void 0:a.effectSlots,n)}}function D2(a){const n=a.trim();return n===""?{type:"missing"}:{type:"url",url:n}}function R2(a){const n={startTime:W2(a.startTime??0),loop:a.loop??!1},t=j2(a.duration);t!==void 0&&(n.duration=t);const o=Yc(a.fadeIn);o!==void 0&&(n.fadeIn=o);const i=Yc(a.fadeOut);return i!==void 0&&(n.fadeOut=i),n}function tm(a,n){const t=new Map;for(const o of a??[]){const i=A2(o,n);t.set(i.index,i)}return Array.from({length:n},(o,i)=>t.get(i)??em(i))}function A2(a,n){const t=am(a.index),o=n>0?Math.min(t,n-1):0,i=a.kind;return i==="empty"?em(o):{id:nm(a.id)??`${i}-effect-slot-${o}`,index:o,kind:i,label:O2(a.label,i),enabled:a.enabled,bypassed:a.bypassed,wetMix:Z2(a.wetMix),parameters:{...a.parameters}}}function L2(a,n){const t=a==null?void 0:a.trim();return t&&t!==""?t:`Audio ${n+1}`}function P2(a){const n=a==null?void 0:a.trim();return n&&n!==""?n:"Master"}function O2(a,n){const t=a.trim();return t!==""?t:n}function U2(a,n){if(!n.has(a))return n.add(a),a;let t=2,o=`${a}-${t}`;for(;n.has(o);)t+=1,o=`${a}-${t}`;return n.add(o),o}function nm(a){const n=a==null?void 0:a.trim();if(!(!n||n===""))return n}function z2(a){return a===void 0||!Number.isFinite(a)?N2:Math.trunc(si(a,0,Gu))}function am(a){return!Number.isFinite(a)||a<0?0:Math.trunc(a)}function j2(a){if(!(a===void 0||!Number.isFinite(a)||a<=0))return ca(a,3)}function Yc(a){if(!(a===void 0||!Number.isFinite(a)||a<0))return ca(a,3)}function W2(a){return!Number.isFinite(a)||a<0?0:ca(a,3)}function Z2(a){return Number.isFinite(a)?ca(si(a,0,1),3):1}function ms(a){return Number.isNaN(a)||a===Number.NEGATIVE_INFINITY?sa:a===Number.POSITIVE_INFINITY?sr:ca(si(a,sa,sr),3)}function H2(a){return{mobile:el(a.mobile),desktop:el(a.desktop)}}function el(a){return{...a}}function si(a,n,t){return Math.min(t,Math.max(n,a))}function ca(a,n){const t=10**n;return Math.round(a*t)/t}const X2=/^(\d{2,}:[0-5]\d:[0-5]\d,\d{3})\s+-->\s+(\d{2,}:[0-5]\d:[0-5]\d,\d{3})$/,G2=/^(\d{2,}):([0-5]\d):([0-5]\d),(\d{3})$/,J2="srt-cue";class la extends Error{constructor(n,t,o={}){super(t),this.name="CaptionSrtError",this.code=n,this.context=o}}function K2(a,n={}){var s,l;const t=Y2(n.idPrefix),o=a.replace(/^\uFEFF/,"").replace(/\r\n?/g,`
|
|
337
|
-
`).split(`
|
|
338
|
-
`),i=[];let r=0;for(;r<o.length;){for(;r<o.length&&nd(o[r]);)r+=1;if(r>=o.length)break;const c=r+1,d=q2(((s=o[r])==null?void 0:s.trim())??"",c);if(r+=1,r>=o.length)throw new la("missing-timing",`Cue ${d} is missing its timing line.`,{cueIndex:i.length,cueNumber:d,lineNumber:c});const u=r+1,f=Q2(((l=o[r])==null?void 0:l.trim())??"",d,u);r+=1;const p=[];for(;r<o.length&&!nd(o[r]);)p.push(o[r]??""),r+=1;i.push({cueNumber:d,id:`${t}-${i.length+1}`,startTime:f.startTime,endTime:f.endTime,text:p.join(`
|
|
339
|
-
`)})}return om(i),i}function qc(a){return om(a),a.length===0?"":`${a.map((n,t)=>t_(n,t+1)).join(`
|
|
340
|
-
|
|
341
|
-
`)}
|
|
342
|
-
`}function om(a){const n=a.map((t,o)=>{const i=td(t,o),r=tl(t.startTime,"startTime",i),s=tl(t.endTime,"endTime",i);if(s<=r)throw new la("invalid-duration",`Caption cue "${t.id}" must end after it starts.`,i);return{cue:t,cueIndex:o,startMilliseconds:r,endMilliseconds:s}}).sort((t,o)=>t.startMilliseconds-o.startMilliseconds||t.cueIndex-o.cueIndex);for(let t=1;t<n.length;t+=1){const o=n[t-1],i=n[t];if(!(o===void 0||i===void 0)&&i.startMilliseconds<o.endMilliseconds)throw new la("overlapping-cues",`Caption cue "${i.cue.id}" overlaps cue "${o.cue.id}".`,td(i.cue,i.cueIndex))}}function Qc(a){const n=tl(a,"timestamp",{}),t=Math.floor(n/36e5),o=Math.floor(n%36e5/6e4),i=Math.floor(n%6e4/1e3),r=n%1e3;return[t.toString().padStart(2,"0"),o.toString().padStart(2,"0"),i.toString().padStart(2,"0")].join(":")+`,${r.toString().padStart(3,"0")}`}function Y2(a){return a===void 0||a.trim()===""?J2:a.trim()}function q2(a,n){if(!/^[1-9]\d*$/.test(a))throw new la("invalid-cue-number",`Invalid SRT cue number at line ${n}.`,{lineNumber:n});return Number.parseInt(a,10)}function Q2(a,n,t){const o=X2.exec(a),i=o==null?void 0:o[1],r=o==null?void 0:o[2];if(i===void 0||r===void 0)throw new la("invalid-timing",`Invalid SRT timing line for cue ${n} at line ${t}.`,{cueNumber:n,lineNumber:t});return{startTime:ed(i,n,t),endTime:ed(r,n,t)}}function ed(a,n,t){const o=G2.exec(a),i=o==null?void 0:o[1],r=o==null?void 0:o[2],s=o==null?void 0:o[3],l=o==null?void 0:o[4];if(i===void 0||r===void 0||s===void 0||l===void 0)throw new la("invalid-time",`Invalid SRT timestamp for cue ${n} at line ${t}.`,{cueNumber:n,lineNumber:t});const c=Number.parseInt(i,10),d=Number.parseInt(r,10),u=Number.parseInt(s,10),f=Number.parseInt(l,10);return c*60*60+d*60+u+f/1e3}function tl(a,n,t){if(!Number.isFinite(a)||a<0)throw new la("invalid-time",`Caption cue ${n} must be a finite, non-negative number.`,t);return Math.round(a*1e3)}function td(a,n){const t={cueIndex:n,segmentId:a.id},o=e_(a);return o!==void 0&&(t.cueNumber=o),t}function e_(a){if(!(!("cueNumber"in a)||typeof a.cueNumber!="number"))return a.cueNumber}function t_(a,n){return[n.toString(),`${Qc(a.startTime)} --> ${Qc(a.endTime)}`,n_(a.text)].join(`
|
|
343
|
-
`)}function n_(a){return a.replace(/\r\n?/g,`
|
|
344
|
-
`)}function nd(a){return a===void 0||a.trim()===""}const a_=["linear","ease-in","ease-out","ease-in-out"];class lr extends Error{constructor(n,t="Invalid keyframe automation."){super(t),this.name="KeyframeAutomationError",this.issues=n}}const o_={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 i_(a){return typeof a=="string"&&a_.includes(a)}function r_(a){return a==="mobile"?{platform:a,editingMode:"preset-only",canApplyPresets:!0,canEditKeyframes:!1}:{platform:a,editingMode:"detailed",canApplyPresets:!0,canEditKeyframes:!0}}function s_(a){return[...a].sort((n,t)=>n.target!==t.target?n.target.localeCompare(t.target):n.time!==t.time?n.time-t.time:n.id.localeCompare(t.id))}function im(a,n={}){const t=[],o=new Set,i={...o_,...n.ranges};return a.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}),n.target!==void 0&&r.target!==n.target&&t.push({code:"target-mismatch",message:`Expected ${n.target} keyframe target but received ${r.target}.`,index:s,keyframeId:r.id,target:r.target,time:r.time}),!Number.isFinite(r.time)||r.time<(n.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(n.maxTime!==void 0&&r.time>n.maxTime)t.push({code:"invalid-time",message:`Keyframe time must be less than or equal to ${n.maxTime}.`,index:s,keyframeId:r.id,target:r.target,time:r.time});else{const l=`${r.target}:${r.time}`;o.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}),o.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})}i_(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 l_(a,n={}){const t=s_(a),o=im(t,n);if(!o.valid)throw new lr(o.issues);return t}function c_(a={}){return $l({id:"fade-in",label:"Fade in",target:"opacity",startValue:a.fromOpacity??0,endValue:a.toOpacity??1,timing:Dl(a,"ease-out")})}function d_(a={}){return $l({id:"fade-out",label:"Fade out",target:"opacity",startValue:a.fromOpacity??1,endValue:a.toOpacity??0,timing:Dl(a,"ease-in")})}function u_(a={}){return $l({id:"zoom-in",label:"Zoom in",target:"scale",startValue:a.fromScale??1,endValue:a.toScale??1.1,timing:Dl(a,"ease-out")})}function $l(a){const n=[{id:`${a.id}:start`,target:a.target,time:a.timing.startTime,value:a.startValue,easing:"linear"},{id:`${a.id}:end`,target:a.target,time:a.timing.endTime,value:a.endValue,easing:a.timing.easing}],t=im(n,{target:a.target});if(!t.valid)throw new lr(t.issues);return{id:a.id,label:a.label,target:a.target,editingMode:"preset-only",keyframes:n}}function Dl(a,n){const t=a.startTime??0,o=a.duration??1;if(!Number.isFinite(t)||t<0)throw new lr([{code:"invalid-time",message:"Preset start time must be a finite non-negative number.",time:t}]);if(!Number.isFinite(o)||o<=0)throw new lr([{code:"invalid-time",message:"Preset duration must be a finite number greater than zero."}]);return{startTime:t,endTime:t+o,easing:a.easing??n}}class Ma extends Error{constructor(n,t){super(t),this.name="VisualLayerSchemaError",this.code=n}}function m_(a){Al(a.id,"caption track id");const n={id:a.id,source:a.source,stylePreset:a.stylePreset??"default",animation:a.animation??"none",segments:p_(a.segments)};return a.language!==void 0&&(n.language=a.language),n}function p_(a){const n=a.map(t=>{Al(t.id,"caption segment id");const o=Rl(t.startTime,"caption segment startTime"),i=rm(t.endTime,"caption segment endTime");if(i<=o)throw new Ma("invalid-caption-segment",`Caption segment "${t.id}" must end after it starts.`);const r={id:t.id,startTime:o,endTime:i,text:t.text};return t.words!==void 0&&(r.words=f_(t.id,t.words)),r}).sort((t,o)=>t.startTime-o.startTime);for(let t=1;t<n.length;t+=1){const o=n[t-1],i=n[t];if(!(o===void 0||i===void 0)&&i.startTime<o.endTime)throw new Ma("invalid-caption-segment",`Caption segment "${i.id}" overlaps segment "${o.id}".`)}return n}function f_(a,n){return n.map(t=>{Al(t.id,"caption word id");const o=Rl(t.startTime,"caption word startTime"),i=rm(t.endTime,"caption word endTime");if(i<=o)throw new Ma("invalid-caption-segment",`Caption word "${t.id}" in segment "${a}" must end after it starts.`);return{id:t.id,startTime:o,endTime:i,text:t.text}}).sort((t,o)=>t.startTime-o.startTime)}function Rl(a,n){const t=h_(a,n);if(t<0)throw new Ma("invalid-time",`${n} must be non-negative.`);return Math.round(t*1e3)/1e3}function rm(a,n){const t=Rl(a,n);if(t<=0)throw new Ma("invalid-duration",`${n} must be greater than zero.`);return t}function h_(a,n){if(!v_(a))throw new Ma("invalid-time",`${n} must be a finite number.`);return a}function Al(a,n){if(a.trim()==="")throw new Ma("empty-id",`${n} cannot be empty.`)}function v_(a){return Number.isFinite(a)}function ad(a){var f,p,m,h;g_(a);const n=w_(a),t=k_(a),o=((f=n[0])==null?void 0:f.id)??ra,i=((p=t[0])==null?void 0:p.id)??so,r=y_(a.clips,i,o),s=__(t,r),l=[],c=C_(a),d=V_(a),u={version:"1.0",source:{media_uuid:a.mediaUuid,duration:a.originalDuration,original_width:((m=a.media)==null?void 0:m.width)||1920,original_height:((h=a.media)==null?void 0:h.height)||1080},timeline:r,mediaSources:n,tracks:s,filters:l,audio:c,output:d,metadata:{created_at:new Date().toISOString(),editor_version:"2.0.0"}};return a.textOverlays&&(u.textOverlays=a.textOverlays),a.captionTracks&&(u.captionTracks=a.captionTracks.map(g=>({...g,segments:g.segments.map(k=>{const $={...k};return k.words&&($.words=k.words.map(D=>({...D}))),$})}))),a.visualLayers&&(u.visualLayers=a.visualLayers.map(g=>({...g}))),a.audioTracks&&(u.audioTracks=a.audioTracks.filter(g=>typeof g.source=="string")),a.transitions&&(u.transitions=a.transitions.map(S_)),u}function g_(a){if(!a.mediaUuid)throw new Error("Media UUID is required");if(!a.clips||a.clips.length===0)throw new Error("At least one clip is required");const n=new Map;for(const t of a.clips){const o=b_(t),i=n.get(o)??[];i.push(t),n.set(o,i)}for(const t of n.values()){t.sort((o,i)=>o.timelineStart-i.timelineStart);for(let o=1;o<t.length;o++){const i=t[o],r=t[o-1];if(i.timelineStart<r.timelineEnd)throw new Error(`Clips ${r.id} and ${i.id} overlap on timeline`)}}}function y_(a,n,t){return a.map(o=>{const i=o.speed||1,r=typeof o.sourceIn=="number"&&!Number.isNaN(o.sourceIn),s=typeof o.sourceOut=="number"&&!Number.isNaN(o.sourceOut),l=Math.max(0,o.timelineEnd-o.timelineStart),c=o,d=c.sourceOffset??c.trimStart??0;let u=Number(r?o.sourceIn:d),f=s?Number(o.sourceOut):Number(d)+l/i;f>u||(f=u+Math.max(.033,l/Math.max(1e-6,i)));const p={id:o.id,type:"clip",trackId:o.trackId??n,sourceRefId:o.sourceRefId??t,timelineStart:o.timelineStart,timelineEnd:o.timelineEnd,sourceIn:u,sourceOut:f,speed:i,filters:o.filters?[...o.filters]:[]};return o.keyframes&&(p.keyframes=o.keyframes.map(m=>({...m}))),p})}function b_(a){return a.trackId??`legacy-track-${a.track??0}`}function w_(a){var t,o,i,r,s,l,c,d;if(a.mediaSources&&a.mediaSources.length>0)return a.mediaSources.map(E_);const n={id:((t=a.clips.find(u=>u.sourceRefId))==null?void 0:t.sourceRefId)??ra,type:"media",mediaUuid:a.mediaUuid,duration:a.originalDuration,width:((o=a.media)==null?void 0:o.width)??1920,height:((i=a.media)==null?void 0:i.height)??1080};return(r=a.media)!=null&&r.filename&&(n.filename=a.media.filename),(s=a.media)!=null&&s.mime_type&&(n.mimeType=a.media.mime_type),typeof((l=a.media)==null?void 0:l.frame_rate)=="number"&&(n.frameRate=a.media.frame_rate),typeof((c=a.media)==null?void 0:c.has_audio)=="boolean"&&(n.hasAudio=a.media.has_audio),(d=a.media)!=null&&d.thumbnail_url&&(n.thumbnailUrl=a.media.thumbnail_url),[n]}function k_(a){var n;return a.tracks&&a.tracks.length>0?a.tracks.map(x_):[{id:((n=a.clips.find(t=>t.trackId))==null?void 0:n.trackId)??so,type:"video",name:"Video",order:0}]}function __(a,n){return a.map(t=>({...t,clipIds:n.filter(o=>o.trackId===t.id).map(o=>o.id)}))}function E_(a){const n={...a};return a.metadata&&(n.metadata={...a.metadata}),n}function x_(a){const n={...a};return a.clipIds&&(n.clipIds=[...a.clipIds]),n}function S_(a){const n={...a};return a.params&&(n.params={...a.params}),n}function C_(a){const n={volume:a.audioVolume,muted:a.audioVolume===0};return a.audioFadeIn>0&&(n.fadeIn=a.audioFadeIn),a.audioFadeOut>0&&(n.fadeOut=a.audioFadeOut),n}function V_(a){var r;const n={"360p":{bitrate:1e6},"480p":{bitrate:25e5},"720p":{bitrate:5e6},"1080p":{bitrate:8e6},"1440p":{bitrate:16e6},"2160p":{bitrate:35e6}},t=n[a.exportQuality]||n["1080p"],o=(r=a.media)==null?void 0:r.frame_rate,i=o&&Number.isFinite(o)&&o>0?o:30;return{format:a.exportFormat||"mp4",codec:"h264",quality:a.exportQuality||"1080p",fps:i,bitrate:t.bitrate}}function Mi(a,n=30){const t=typeof a=="number"?a:Number(a);return Number.isFinite(t)&&t>0?t:n}function sm(a,n,t){var kn,pn,fn;const o=typeof a=="string"&&a.trim()!==""?a.trim():`temp-${Date.now()}`,i=e.reactive({mediaUuid:o,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([]),c=e.ref(void 0);let d=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0&&t.duration!==1;const u=e.ref(!1),f=Mi(((kn=n==null?void 0:n.output)==null?void 0:kn.fps)??(t==null?void 0:t.frame_rate)),p=e.shallowRef(null),m=new Nu(f),h=e.ref(f),g=e.ref(!1),k=e.ref(!1);n&&n.timeline&&n.timeline.length>0?(A(n),(pn=n.output)!=null&&pn.fps&&(h.value=Mi(n.output.fps,h.value),m.setFps(h.value))):(S(),n&&((fn=n.output)!=null&&fn.fps&&(h.value=Mi(n.output.fps,h.value),m.setFps(h.value)),n.audio&&(i.audioVolume=n.audio.volume||1,i.audioFadeIn=n.audio.fadeIn||0,i.audioFadeOut=n.audio.fadeOut||0),n.output&&(i.exportFormat=n.output.format||"mp4",i.exportQuality=n.output.quality||"1080p")));const $=e.ref(1),D=e.computed(()=>i.selectedClipId?i.clips.find(W=>W.id===i.selectedClipId)??null:null);e.watch(D,W=>{$.value=(W==null?void 0:W.speed)??1},{immediate:!0});const _=e.computed(()=>s.value.length>0),v=e.computed(()=>l.value.length>0);function S(){const W=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0?t.duration:1;t&&(i.media=t),i.originalDuration=W,i.totalDuration=W;const J=Oe();i.mediaSources=[C(W)],i.tracks=[V([J])];const te={id:J,type:"clip",trackId:so,sourceRefId:ra,timelineStart:0,timelineEnd:W,sourceIn:0,sourceOut:W,sourceMinIn:0,sourceMaxOut:W,speed:1};i.clips=[te],i.selectedClipId=J,c.value=J,!(t||o.startsWith("temp-"))&&(async()=>{try{const ve=await fetch(`/api/v1/video/${encodeURIComponent(o)}`);if(!ve.ok)throw new Error(`Failed to fetch media: ${ve.status}`);const _e=await ve.json(),Ue=typeof _e=="object"&&_e!==null&&"data"in _e?_e.data:_e;if(!Ue||typeof Ue!="object")throw new Error("Failed to parse media payload");const Ye=Ue;i.media=Ye,n||(h.value=Mi(Ye.frame_rate,h.value),m.setFps(h.value));const Xe=typeof Ye.duration=="number"&&Ye.duration>0?Ye.duration:W;if(i.hasChanges||i.clips.length!==1||i.clips[0].id!==J)return;i.originalDuration=Xe,i.totalDuration=Xe,i.mediaSources=[C(Xe,Ye)],i.tracks=[V([J])];const rt=i.clips[0];rt.timelineStart=0,rt.timelineEnd=Xe,rt.sourceIn=0,rt.sourceOut=Xe,rt.sourceMinIn=0,rt.sourceMaxOut=Xe,ot(),d=!0}catch{}})()}function C(W,J=t){const te={id:ra,type:"media",mediaUuid:o,duration:W,width:(J==null?void 0:J.width)??1920,height:(J==null?void 0:J.height)??1080};return J!=null&&J.filename&&(te.filename=J.filename),J!=null&&J.mime_type&&(te.mimeType=J.mime_type),typeof(J==null?void 0:J.frame_rate)=="number"&&(te.frameRate=J.frame_rate),typeof(J==null?void 0:J.has_audio)=="boolean"&&(te.hasAudio=J.has_audio),J!=null&&J.thumbnail_url&&(te.thumbnailUrl=J.thumbnail_url),te}function V(W){return{id:so,type:"video",name:"Video",order:0,clipIds:W}}function x(W){return`track-${W}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function T(W,J){const te=W.charAt(0).toUpperCase()+W.slice(1),ve=J.filter(_e=>_e.type===W).length;return ve===0?te:`${te} ${ve+1}`}function j(W,J){if(W.originalDuration!==1)return;W.originalDuration=J,W.totalDuration===1&&(W.totalDuration=J);const te=W.clips[0],ve=!n&&W.clips.length===1&&te!==void 0&&te.timelineStart===0&&te.timelineEnd===1&&te.sourceIn===0&&te.sourceOut===1;for(const _e of W.clips)(_e.sourceMaxOut===1||_e.sourceMaxOut===void 0)&&(_e.sourceMaxOut=J);if(W.mediaSources)for(const _e of W.mediaSources)_e.id===ra&&(_e.duration===1||_e.duration===void 0)&&(_e.duration=J);ve&&te!==void 0&&(te.sourceOut=J,te.timelineEnd=J)}function E(W){if(!Number.isFinite(W)||W<=0||d)return;const J=i.hasChanges;i.originalDuration=W,i.totalDuration=Math.max(i.totalDuration,W),i.media&&(i.media.duration=W);for(const _e of i.clips)_e.sourceMaxOut=W;if(i.mediaSources)for(const _e of i.mediaSources)(_e.id===ra||_e.mediaUuid===o)&&(_e.duration=W);const te=i.clips[0];!n&&i.clips.length===1&&te!==void 0&&te.timelineStart===0&&te.timelineEnd===1&&te.sourceIn===0&&te.sourceOut===1&&te!==void 0&&(te.sourceOut=W,te.timelineEnd=te.timelineStart+(te.sourceOut-te.sourceIn)),ot();for(const _e of s.value)j(_e,W);for(const _e of l.value)j(_e,W);d=!0,e.nextTick(()=>{J||(i.hasChanges=!1)})}function A(W){const J=Du(W);i.mediaSources=J.mediaSources,i.tracks=J.tracks,i.transitions=J.transitions,i.clips=J.clips.map(te=>({...te,sourceMinIn:te.sourceMinIn??0,sourceMaxOut:te.sourceMaxOut??W.source.duration})),i.filters=[],i.audioVolume=W.audio.volume,i.audioFadeIn=W.audio.fadeIn||0,i.audioFadeOut=W.audio.fadeOut||0,i.exportFormat=W.output.format,i.exportQuality=W.output.quality,i.originalDuration=W.source.duration,i.textOverlays=W.textOverlays?[...W.textOverlays]:[],i.audioTracks=W.audioTracks?[...W.audioTracks]:[],i.captionTracks=W.captionTracks?W.captionTracks.map(nt):[],i.visualLayers=W.visualLayers?W.visualLayers.map(te=>({...te})):[],i.clips.length>0?(i.selectedClipId=i.clips[0].id,c.value=i.selectedClipId):(delete i.selectedClipId,c.value=void 0),ot()}function N(){s.value.push(JSON.parse(JSON.stringify(i))),l.value=[],i.hasChanges=!0}function z(){if(!_.value)return;const W=s.value.pop();l.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,W)}function P(){if(!v.value)return;const W=l.value.pop();s.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,W)}function B(W,J,te){N();const ve=i.clips.find(Xe=>Xe.id===W);if(!ve)return;const _e=1/h.value,Ue=ve.sourceMinIn??0,Ye=ve.sourceMaxOut??i.originalDuration;if(J==="start"){const Xe=ve.sourceIn,rt=Math.max(Ue,Math.min(te,ve.sourceOut-_e));ve.sourceIn=rt;const _n=rt-Xe;ve.timelineStart+=_n}else{const Xe=Math.max(ve.sourceIn+_e,Math.min(te,Ye));ve.sourceOut=Xe;const rt=ve.sourceOut-ve.sourceIn;ve.timelineEnd=ve.timelineStart+rt}ot(),p.value&&p.value.trimClip(W,ve.sourceIn,ve.sourceOut)}function L(W){N();const J=i.clips.find(Ye=>W>Ye.timelineStart&&W<Ye.timelineEnd);if(!J)return;const te=W-J.timelineStart,ve=J.sourceIn+te,_e={id:Oe(),type:"clip",timelineStart:W,timelineEnd:J.timelineEnd,sourceIn:ve,sourceOut:J.sourceOut,speed:J.speed??1,sourceMinIn:J.sourceMinIn??0,sourceMaxOut:J.sourceMaxOut??i.originalDuration,filters:[...J.filters||[]]};J.trackId&&(_e.trackId=J.trackId),J.sourceRefId&&(_e.sourceRefId=J.sourceRefId),J.timelineEnd=W,J.sourceOut=ve;const Ue=i.clips.indexOf(J);i.clips.splice(Ue+1,0,_e),Ee(),i.selectedClipId=_e.id}function w(){L(i.playheadPosition)}function O(W){var te;const J=W??i.selectedClipId??c.value??((te=i.clips[0])==null?void 0:te.id);J&&(i.selectedClipId=J,c.value=J)}function Z(){return i.selectedClipId?G(i.selectedClipId):!1}function G(W){if(i.clips.length<=1)return!1;const J=i.clips.findIndex(te=>te.id===W);return J===-1?!1:(N(),i.clips.splice(J,1),Ee(),re(J),ot(),!0)}function re(W){if(!i.clips.length){delete i.selectedClipId,c.value=void 0;return}const J=Math.max(0,Math.min(W,i.clips.length-1)),te=i.clips[J];te&&(i.selectedClipId=te.id,c.value=te.id)}function be(W){return W.trackId??`legacy-track-${W.track??0}`}function Ee(){const W=i.tracks;if(W)for(const J of W)J.clipIds=i.clips.filter(te=>be(te)===J.id).map(te=>te.id)}function ie(W="video"){N();const J=i.tracks??[],te=J.reduce((_e,Ue)=>Math.max(_e,Ue.order),-1),ve={id:x(W),type:W,name:T(W,J),order:te+1,clipIds:[]};return i.tracks=[...J,ve],i.hasChanges=!0,ve}function R(W){let J=i.tracks??[];if(J.length===0){const ve=V([]);i.tracks=[ve],J=i.tracks}const te=W?J.find(ve=>ve.id===W):void 0;return te&&te.locked!==!0?te:J.find(ve=>ve.type==="video"&&ve.locked!==!0)??J.find(ve=>ve.locked!==!0)??null}function M(W){const J=1/h.value;return typeof W.duration=="number"&&Number.isFinite(W.duration)&&W.duration>J?W.duration:i.originalDuration>J?i.originalDuration:Math.max(J,i.totalDuration)}function H(W){const J=i.clips.filter(te=>be(te)===W);return J.length>0?J.reduce((te,ve)=>Math.max(te,ve.timelineEnd),0):Math.max(0,Math.min(i.playheadPosition,i.totalDuration))}function ee(W,J){const te=(i.mediaSources??[]).find(rt=>rt.id===W);if(!te)return null;const ve=R(J);if(!ve)return null;N();const _e=M(te),Ue=Oe(),Ye=H(ve.id),Xe={id:Ue,type:"clip",trackId:ve.id,sourceRefId:te.id,timelineStart:Ye,timelineEnd:Ye+_e,sourceIn:0,sourceOut:_e,sourceMinIn:0,sourceMaxOut:_e,speed:1};return i.clips.push(Xe),i.selectedClipId=Ue,c.value=Ue,Ee(),ot(),Xe}function ae(W){const J=D.value,te=(i.mediaSources??[]).find(Xe=>Xe.id===W);if(!J||!te)return!1;N();const ve=1/h.value,_e=M(te),Ue=Math.max(ve,J.timelineEnd-J.timelineStart),Ye=Math.max(ve,Math.min(Ue,_e));return J.sourceRefId=te.id,J.sourceIn=0,J.sourceOut=Ye,J.sourceMinIn=0,J.sourceMaxOut=_e,J.timelineEnd=J.timelineStart+Ye,ot(),!0}function ue(W){const J=i.mediaSources??[];return J.length<=1||i.clips.some(ve=>ve.sourceRefId===W)?!1:(N(),i.mediaSources=J.filter(ve=>ve.id!==W),!0)}function de(W,J){const te=(i.tracks??[]).find(ve=>ve.id===W);return te?(N(),te[J]=te[J]!==!0,!0):!1}function ye(W){return de(W,"locked")}function Be(W){return de(W,"hidden")}function fe(W){return de(W,"muted")}function ge(W){return de(W,"solo")}function Se(W){if(i.clips.length<=1)return!1;const J=i.clips.findIndex(Ue=>Ue.id===W),te=J===-1?void 0:i.clips[J];if(!te)return!1;const ve=Math.max(0,te.timelineEnd-te.timelineStart),_e=be(te);if(N(),i.clips.splice(J,1),Ee(),ve>0)for(const Ue of i.clips)be(Ue)!==_e||Ue.timelineStart<te.timelineEnd||(Ue.timelineStart=Math.max(0,Ue.timelineStart-ve),Ue.timelineEnd=Math.max(Ue.timelineStart,Ue.timelineEnd-ve));return i.playheadPosition>=te.timelineEnd?i.playheadPosition=Math.max(0,i.playheadPosition-ve):i.playheadPosition>te.timelineStart&&(i.playheadPosition=te.timelineStart),re(J),ot(),i.hasChanges=!0,!0}function Ie(){return i.selectedClipId?Se(i.selectedClipId):!1}function pt(){return[...i.clips].sort((W,J)=>W.timelineStart-J.timelineStart)}function lt(W){const J=i.clips.find(hn=>hn.id===W);if(!J)return null;const te=be(J),ve=pt().filter(hn=>be(hn)===te),_e=ve.findIndex(hn=>hn.id===W);if(_e===-1)return null;const Ue=ve[_e],Ye=Ue.timelineEnd-Ue.timelineStart,Xe=_e>0?ve[_e-1]:null,rt=_e<ve.length-1?ve[_e+1]:null,_n=Xe?Xe.timelineEnd:0,Xt=rt?rt.timelineStart-Ye:Math.max(Ue.timelineStart,i.totalDuration-Ye);return{minStart:_n,maxStart:Math.max(_n,Xt)}}function Dt(W,J){const te=i.clips.find(Ye=>Ye.id===W);if(!te)return;const ve=lt(W),_e=ve?Math.min(ve.maxStart,Math.max(ve.minStart,J)):Math.max(0,J);if(_e===te.timelineStart)return;N();const Ue=_e-te.timelineStart;te.timelineStart=_e,te.timelineEnd+=Ue,ot(),p.value&&p.value.moveClip(W,_e)}function ot(){if(i.clips.length===0){i.totalDuration=0;return}const W=i.clips.reduce((J,te)=>te.timelineEnd>J.timelineEnd?te:J);i.totalDuration=W.timelineEnd}function vt(){i.zoomLevel=Math.min(200,i.zoomLevel*1.2)}function bt(){i.zoomLevel=Math.max(10,i.zoomLevel/1.2)}function it(W){i.zoomLevel=Math.max(10,Math.min(600,Math.round(W)))}function wt(){i.isPlaying=!i.isPlaying}function Et(W){i.isPlaying=W}function he(W){i.playheadPosition=Math.max(0,Math.min(W,i.totalDuration))}function Ne(){const W=ad(i);try{localStorage.setItem(`video-draft-${o}`,JSON.stringify(W))}catch{}return W}function Re(){i.hasChanges=!1}function He(){return confirm("Are you sure you want to reset all changes?")?(N(),S(),i.hasChanges=!1,!0):!1}function je(){return ad(i)}function Oe(){return`clip-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}async function ct(W=1920,J=1080){if(u.value)try{p.value=new Vu(W,J,h.value),await dt()}catch{p.value=null}}async function dt(){if(!(!p.value||k.value)){k.value=!0;try{const W=je();await p.value.loadFromRecipe(W);const J=m.secondsToFrames(i.playheadPosition);p.value.seek(J)}catch{}finally{k.value=!1}}}function Pt(W){}function Rt(W){return m.secondsToFrames(W)}function Ot(W){return m.framesToSeconds(W)}function tn(W){const J=Ot(W);he(J),p.value&&p.value.seek(W)}function zn(){g.value=!g.value}function Yn(){dt()}function q(W){u.value=!1,p.value=null}e.watch(()=>i.clips,()=>{i.hasChanges=!0,u.value&&p.value&&dt()},{deep:!0}),e.watch(()=>i.filters,()=>{i.hasChanges=!0,u.value&&p.value&&dt()},{deep:!0}),e.watch(()=>i.clips.map(W=>W.id),()=>{var J;if(!i.clips.length){delete i.selectedClipId,c.value=void 0;return}if(!i.clips.some(te=>te.id===i.selectedClipId)){const te=c.value&&((J=i.clips.find(ve=>ve.id===c.value))==null?void 0:J.id);i.selectedClipId=te??i.clips[0].id,c.value=i.selectedClipId}},{deep:!0});function le(W){const J=i.selectedClipId?i.clips.find(te=>te.id===i.selectedClipId):i.clips[0];J&&(J.filters=[...W],i.hasChanges=!0)}function oe(W){i.textOverlays=[...W]}function se(W){i.audioTracks=[...W]}function Ce(W){i.captionTracks=W.map(nt),i.hasChanges=!0}function Ve(W){i.visualLayers=W.map(J=>({...J})),i.hasChanges=!0}function Je(W){i.transitions=W.map(J=>{const te={...J};return J.params&&(te.params={...J.params}),te}),i.hasChanges=!0}function st(W,J){const te=i.clips.find(ve=>ve.id===W);te&&(te.keyframes=J.map(ve=>({...ve})),i.hasChanges=!0)}function ut(W){N(),A(W),i.hasChanges=!0}function nt(W){return{...W,segments:W.segments.map(J=>{const te={...J};return J.words&&(te.words=J.words.map(ve=>({...ve}))),te})}}e.watch(u,W=>{W?ct():p.value&&(p.value.destroy(),p.value=null)}),e.watch(g,()=>{}),e.watch(h,W=>{m.setFps(W)});function kt(){if(!i.selectedClipId)return;N();const W=i.clips.find(ve=>ve.id===i.selectedClipId);if(!W)return;const J={...W,id:Oe(),timelineStart:W.timelineEnd,timelineEnd:W.timelineEnd+(W.timelineEnd-W.timelineStart),filters:[...W.filters||[]]},te=i.clips.indexOf(W);i.clips.splice(te+1,0,J),Ee(),i.selectedClipId=J.id,i.hasChanges=!0}function At(W){const J=W??800,te=i.totalDuration;if(te<=0){i.zoomLevel=50;return}const ve=J*.8/te;i.zoomLevel=Math.max(10,Math.min(600,Math.round(ve)))}function nn(){const W=1/h.value;he(Math.min(i.playheadPosition+W,i.totalDuration))}function qn(){const W=1/h.value;he(Math.max(i.playheadPosition-W,0))}function mn(){he(0)}function Aa(){he(i.totalDuration)}function da(W){if(!Number.isFinite(W)||W<=0)return;const J=D.value??i.clips[0];if(!J){$.value=W;return}const te=J.speed??1;if(te===W){$.value=W;return}N();const ve=Math.max(1/h.value,J.sourceOut-J.sourceIn),_e=ve/te,Ue=ve/W,Ye=Ue-_e;J.speed=W,J.timelineEnd=J.timelineStart+Ue;const Xe=i.clips.findIndex(rt=>rt.id===J.id);if(Xe!==-1&&Ye!==0)for(let rt=Xe+1;rt<i.clips.length;rt+=1){const _n=i.clips[rt];_n.timelineStart+=Ye,_n.timelineEnd+=Ye}ot(),i.playheadPosition=Math.max(0,Math.min(i.playheadPosition,i.totalDuration)),i.hasChanges=!0,$.value=W}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:D,zoomLevel:e.computed(()=>i.zoomLevel),playbackSpeed:$,useVideoEngine:u,compositionAdapter:e.computed(()=>p.value),fps:h,useFrameMode:g,handleTrim:B,handleSplit:L,handleClipSelect:O,splitAtPlayhead:w,deleteSelectedClip:Z,deleteClip:G,rippleDeleteClip:Se,rippleDeleteSelectedClip:Ie,duplicateSelectedClip:kt,addTimelineTrack:ie,appendMediaSourceToTimeline:ee,replaceSelectedClipSource:ae,removeMediaSource:ue,toggleTrackLock:ye,toggleTrackHidden:Be,toggleTrackMuted:fe,toggleTrackSolo:ge,setFilters:le,setTextOverlays:oe,setAudioTracks:se,setCaptionTracks:Ce,setVisualLayers:Ve,setTransitions:Je,setClipKeyframes:st,loadRecipe:ut,moveClip:Dt,saveDraft:Ne,clearHasChanges:Re,resetChanges:He,generateRecipe:je,zoomIn:vt,zoomOut:bt,setZoomLevel:it,fitToWindow:At,togglePlayback:wt,setPlaying:Et,seekTo:he,frameForward:nn,frameBackward:qn,skipToStart:mn,skipToEnd:Aa,setPlaybackSpeed:da,updateSourceDuration:E,undo:z,redo:P,canUndo:_,canRedo:v,initializeComposition:ct,syncCompositionWithState:dt,syncWithComposition:Pt,convertToFrames:Rt,convertToSeconds:Ot,seekToFrame:tn,toggleFrameMode:zn,onCompositionReady:Yn,onCompositionError:q}}const N_=[{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}}}],T_={dropShadow:"drop-shadow",softFocus:"blur",blackAndWhite:"grayscale",gaussianBlur:"blur","gaussian-blur":"blur"};function Tr(a){return typeof a=="object"&&a!==null}function M_(a,n){if(typeof a=="number"&&Number.isFinite(a))return a;if(typeof a=="string"){const t=Number(a);if(Number.isFinite(t))return t}return n}function Mr(a){if(typeof a=="number"||typeof a=="string"||typeof a=="boolean")return a}function B_(a){const n={id:a.id,type:a.type,label:a.label};a.property!==void 0&&(n.property=a.property),a.min!==void 0&&(n.min=a.min),a.max!==void 0&&(n.max=a.max),a.step!==void 0&&(n.step=a.step);const t=Mr(a.default);return t!==void 0&&(n.default=t),a.options!==void 0&&(n.options=a.options),n}function lm(a,n,t){const o=pe.getFilter(a),i={},r=(o==null?void 0:o.defaultParams)??t;if(r&&Tr(r))for(const[s,l]of Object.entries(r))i[s]=Mr(l)??null;for(const s of n){const l=s.property??s.id;i[l]===void 0&&s.default!==void 0&&(i[l]=s.default)}return i}function cm(a){const n={};for(const t of a){if(t.type!=="slider")continue;const o=t.property??t.id;n[o]={min:t.min??0,max:t.max??100,step:t.step??1}}return n}function I_(a,n,t,o){const i=o.map(B_);return{id:a,name:n,category:t,controls:i,params:i,defaultParams:lm(a,i),paramRanges:cm(i)}}function F_(a){const n=a.paramRanges??{},t=Object.entries(n).map(([o,i])=>{var l;const r={id:o,type:"slider",label:o.replace(/[-_]/g," ").replace(/\b\w/g,c=>c.toUpperCase()),property:o,min:i.min,max:i.max,step:i.step},s=Mr((l=a.defaultParams)==null?void 0:l[o]);return s!==void 0&&(r.default=s),r});return{id:a.id,name:a.name,category:a.category,controls:t,params:t,defaultParams:lm(a.id,t,a.defaultParams),paramRanges:cm(t)}}function $_(a,n){return n.toLowerCase()==="unlisted"?!1:pe.isFilterCompatibleWithMedia(a,"video")}function ps(a){return T_[a]??a}function Do(a){const n=M_(a,1);return Math.max(0,Math.min(1,n))}function Ro(a){if(!Tr(a))return{};const n={};for(const[t,o]of Object.entries(a))n[t]=Mr(o)??null;return n}function D_(a){return!Tr(a)||typeof a.filterId!="string"?null:{filterId:a.filterId,params:Ro(a.params),intensity:Do(a.intensity)}}function R_(a){if(!Tr(a)||typeof a.id!="string"||typeof a.name!="string")return null;const t=(Array.isArray(a.filters)?a.filters:[]).map(i=>D_(i)).filter(i=>i!==null),o=typeof a.created_at=="string"?a.created_at:new Date().toISOString();return{id:a.id,name:a.name,filters:t,created_at:o}}function dm(){pe.initializeFilterRegistry();const a=e.ref([]),n=e.ref(null),t=e.ref(null),o=e.ref([]),i=e.ref(null),r=e.reactive({}),s=e.computed(()=>{const N=new Map,z=pe.getRegisteredFilters();for(const P of z)$_(P.id,P.category)&&N.set(P.id,I_(P.id,P.name,P.category,P.controls));for(const P of N_)N.has(P.id)||N.set(P.id,F_(P));return Array.from(N.values())}),l=e.computed(()=>{const N=new Map;for(const z of s.value)N.set(z.id,z);return N}),c=e.computed(()=>a.value.length>0),d=e.computed(()=>{const N={};for(const z of s.value)N[z.category]||(N[z.category]=[]),N[z.category].push(z);return N});function u(N){const z=l.value.get(N);if(z)return z;const P=ps(N);return l.value.get(P)??null}function f(N){const z=l.value.get(N);if(z)return z.id;const P=ps(N),B=l.value.get(P);return B?B.id:null}function p(N){const z=N?u(N):n.value;if(!z)return;const P=z.defaultParams||{},B={id:T(),filterId:z.id,params:{...P},intensity:1};return a.value.push(B),i.value=B.id,n.value=z,Object.keys(r).forEach(L=>delete r[L]),Object.assign(r,B.params),t.value=null,B}function m(N){const z=u(N);if(!z)return;n.value=z;const P=z.defaultParams||E(N);Object.assign(r,P),t.value={id:"preview",filterId:z.id,params:{...P},intensity:1}}function h(N){if(Object.assign(r,N),t.value&&(t.value.params={...r}),i.value){const z=a.value.find(P=>P.id===i.value);z&&(z.params={...r})}}function g(N){const z=a.value.findIndex(P=>P.id===N);z!==-1&&a.value.splice(z,1)}function k(N,z){if(N<0||N>=a.value.length||z<0||z>=a.value.length)return;const[P]=a.value.splice(N,1);a.value.splice(z,0,P)}function $(N,z){const P=a.value.find(B=>B.id===N);P&&(P.intensity=Math.max(0,Math.min(1,z)))}function D(N){const z=a.value.find(P=>P.id===N);z&&(z.intensity=z.intensity>0?0:1)}function _(){a.value=[],t.value=null,n.value=null,i.value=null,Object.keys(r).forEach(N=>delete r[N])}function v(N){const z={id:j(),name:N,filters:a.value.map(B=>({filterId:B.filterId,params:Ro(B.params),intensity:Do(B.intensity)})),created_at:new Date().toISOString()};o.value.push(z);const P=o.value.map(B=>({...B}));return localStorage.setItem("video-filter-presets",JSON.stringify(P)),z}function S(N){const z=o.value.find(P=>P.id===N);if(z){_();for(const P of z.filters){const B=u(P.filterId);B&&a.value.push({id:T(),filterId:B.id,params:{...P.params},intensity:Do(P.intensity)})}}}function C(N){const z=o.value.findIndex(P=>P.id===N);z!==-1&&(o.value.splice(z,1),localStorage.setItem("video-filter-presets",JSON.stringify(o.value)))}function V(){try{const N=localStorage.getItem("video-filter-presets");if(!N)return;const z=JSON.parse(N);if(!Array.isArray(z))return;o.value=z.map(P=>R_(P)).filter(P=>P!==null)}catch{}}function x(){if(a.value.length===0)return"No filters applied";const N=a.value.map(z=>{const P=A(z.filterId);return(P==null?void 0:P.name)||z.filterId});return N.length===1?N[0]:N.length===2?`${N[0]} + ${N[1]}`:`${N[0]} + ${N.length-1} more`}function T(){return`filter-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function j(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function E(N){const z=u(N);return z?z.defaultParams||{}:{}}function A(N){return u(N)}return V(),{videoCompatibleFilters:s,activeFilters:a,selectedFilter:n,previewFilter:t,filterPresets:o,filterParams:r,hasActiveFilters:c,filtersByCategory:d,applyFilter:p,previewFilterEffect:m,updateFilterParams:h,removeFilter:g,reorderFilters:k,updateFilterIntensity:$,toggleFilter:D,clearAllFilters:_,saveFilterPreset:v,loadFilterPreset:S,deleteFilterPreset:C,getFilterSummary:x,setActiveFilters(N){var P;const z=[];for(const B of N){const L=f(B.filterId);if(!L){const w=ps(B.filterId);z.push({...B,filterId:w,params:Ro(B.params),intensity:Do(B.intensity)});continue}z.push({...B,filterId:L,params:Ro(B.params),intensity:Do(B.intensity)})}a.value=z,i.value=((P=a.value[0])==null?void 0:P.id)??null,Object.keys(r).forEach(B=>delete r[B]),a.value[0]&&Object.assign(r,Ro(a.value[0].params))}}}class um{constructor(n){this.textClips=new Map,this.overlayConfigs=new Map,this.fonts=new Map,this.nextId=0,this.composition=n,this.initializeDefaultFonts()}initializeDefaultFonts(){try{this.fonts.set("default",new Zt({source:"https://fonts.googleapis.com/css2?family=Inter:wght@400",family:"Inter",weight:"400"})),this.fonts.set("bold",new Zt({source:"https://fonts.googleapis.com/css2?family=Inter:wght@700",family:"Inter",weight:"700"})),this.fonts.set("serif",new Zt({source:"https://fonts.googleapis.com/css2?family=Merriweather:wght@400",family:"Merriweather",weight:"400"}))}catch{}}async loadWebFont(n,t,o,i="400"){const r=new Zt({source:t,family:o,weight:i});this.fonts.set(n,r)}loadLocalFont(n,t,o="400"){const i=new Zt({source:`local('${t}')`,family:t,weight:o});this.fonts.set(n,i)}async addTextOverlay(n){const t=`text-overlay-${this.nextId++}`,o=this.buildTextClipConfig(n),i=new co(o);return await this.composition.add(i),this.textClips.set(t,i),this.overlayConfigs.set(t,{...n}),t}buildTextClipConfig(n){const t={text:n.text,fontSize:n.fontSize||24,fillStyle:n.color||"#ffffff",textAlign:n.textAlign||"center",textBaseline:n.textBaseline||"middle"},o=n.fontFamily||"default",i=this.fonts.get(o)||this.fonts.get("default");if(i&&(t.font=i),this.applyPosition(t,n.position),n.startTime!==void 0&&(t.start=Fe.fromSeconds(n.startTime)),n.duration!==void 0){const r=n.startTime||0;t.stop=Fe.fromSeconds(r+n.duration)}return n.animation&&this.applyAnimation(t,n.animation,n),t}applyPosition(n,t){if(!t){n.position="center";return}if(typeof t!="string"){n.x=t.x,n.y=t.y;return}switch(t){case"center":n.position="center";break;case"top":n.x="50%",n.y="10%";break;case"bottom":n.x="50%",n.y="90%";break;case"left":n.x="10%",n.y="50%";break;case"right":n.x="90%",n.y="50%";break}}applyAnimation(n,t,o){if(!t)return;const i=o.startTime?Math.round(o.startTime*30):0,r=t.duration||1,s=Math.round(r*30),l=i+s,c=t.easing||"linear";switch(t.type){case"fade-in":n.alpha=new Le([i,l],[0,1],{easing:c});break;case"fade-out":n.alpha=new Le([i,l],[1,0],{easing:c});break;case"rotate":t.rotation&&(n.rotation=new Le([i,l],[t.rotation.from,t.rotation.to],{easing:c}));break;case"scale":t.scale&&(n.scale=new Le([i,l],[t.scale.from,t.scale.to],{easing:c}));break;case"slide":t.translate&&(n.translate={x:new Le([i,l],[t.translate.fromX,t.translate.toX],{easing:c}),y:new Le([i,l],[t.translate.fromY,t.translate.toY],{easing:c})});break;case"typewriter":n.alpha=new Le([i,l],[0,1],{easing:"linear"});break;case"custom":t.rotation&&(n.rotation=new Le([i,l],[t.rotation.from,t.rotation.to],{easing:c})),t.scale&&(n.scale=new Le([i,l],[t.scale.from,t.scale.to],{easing:c})),t.translate&&(n.translate={x:new Le([i,l],[t.translate.fromX,t.translate.toX],{easing:c}),y:new Le([i,l],[t.translate.fromY,t.translate.toY],{easing:c})});break}}async updateTextOverlay(n,t){const o=this.textClips.get(n);if(!o)throw new Error(`Text overlay with id ${n} not found`);const i=this.overlayConfigs.get(n);if(!i)throw new Error(`Text overlay with id ${n} is missing config`);const r={...i,...t};o.set(this.buildTextClipConfig(r)),this.overlayConfigs.set(n,r)}async removeTextOverlay(n){const t=this.textClips.get(n);if(!t)throw new Error(`Text overlay with id ${n} not found`);const o=this.composition.tracks;for(const i of o){const r=i.clips.indexOf(t);if(r!==-1){i.clips.splice(r,1);break}}this.textClips.delete(n),this.overlayConfigs.delete(n)}getTextOverlays(){return new Map(this.textClips)}async clearAllTextOverlays(){const n=Array.from(this.textClips.keys());for(const t of n)await this.removeTextOverlay(t)}getOverlays(){return Array.from(this.overlayConfigs.entries()).map(([n,t])=>({id:n,config:{...t}}))}async addCaptions(n,t="classic",o){var c;const r={classic:oi,cascade:Er,guinea:_r,solar:xr,spotlight:ii,whisper:ri}[t],s=await this.composition.createTrack("caption"),l=new vr({transcript:n});if(await s.add(l),await((c=s.generate)==null?void 0:c.call(s,r)),o&&s.clips.length>0){const d=s.clips[0];d==null||d.set(o)}}}class mm{constructor(n){this.audioLayers=new Map,this.audioSources=new Map,this.nextId=0,this.masterVolume=1,this.composition=n}async loadAudioSource(n,t){try{const o=await ia.from(n),i=t||`audio-source-${this.nextId++}`;return this.audioSources.set(i,o),o}catch(o){throw o instanceof Error?o:new Error("Failed to load audio source")}}async addBackgroundMusic(n){return this.addAudioTrack({...n,name:n.name||"Background Music"})}async addAudioTrack(n){const t=`audio-track-${this.nextId++}`,o=await this.resolveAudioSource(n.source),i=this.createAudioClipConfig(n,o),r=new zo(i);let s=this.findAudioTrack();s||(s=await this.composition.createTrack("audio")),await s.add(r);const l={id:t,name:n.name||`Audio Track ${this.audioLayers.size+1}`,clip:r,track:s,config:n};return this.audioLayers.set(t,l),t}async resolveAudioSource(n){try{if(n instanceof ia)return n;if(typeof n=="string"&&n.trim()!=="")return await ia.from(n);if(n instanceof File)return await ia.from(URL.createObjectURL(n));throw new Error("Invalid audio source")}catch(t){throw t instanceof Error?t:new Error("Failed to create audio source")}}createAudioClipConfig(n,t){const o={source:t,volume:(n.volume??1)*this.masterVolume};if(n.startTime!==void 0&&(o.start=Fe.fromSeconds(n.startTime)),n.duration!==void 0){const i=n.startTime||0;o.stop=Fe.fromSeconds(i+n.duration)}return(n.fadeIn||n.fadeOut)&&(o.volume=this.createVolumeKeyframes(n)),o}findAudioTrack(){return this.composition.tracks.find(n=>n.kind==="audio")}removeClipFromTrack(n,t){const o=n.clips.indexOf(t);o!==-1&&n.clips.splice(o,1)}createVolumeKeyframes(n){const t=(n.volume??1)*this.masterVolume,o=n.startTime?Math.round(n.startTime*30):0,i=n.duration,r=[],s=[];if(n.fadeIn){const l=Math.round(n.fadeIn*30);r.push(o,o+l),s.push(0,t)}else r.push(o),s.push(t);if(n.fadeOut&&i){const l=o+Math.round(i*30),c=Math.round(n.fadeOut*30);n.fadeIn||(r.push(l-c),s.push(t)),r.push(l),s.push(0)}return new Le(r,s,{easing:"linear"})}async updateVolume(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);const i=Math.max(0,Math.min(1,t));o.config.volume=i,o.clip.set({volume:this.resolveLayerVolume(o.config)})}async updateAudioTrack(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);const i={...o.config,...t,source:t.source??o.config.source},r=await this.resolveAudioSource(i.source),s=new zo(this.createAudioClipConfig(i,r));this.removeClipFromTrack(o.track,o.clip),await o.track.add(s),o.clip=s,o.config=i,o.name=i.name||o.name}async applyFadeIn(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);o.config.fadeIn=t,o.clip.set({volume:this.resolveLayerVolume(o.config)})}async applyFadeOut(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);o.config.fadeOut=t,o.clip.set({volume:this.resolveLayerVolume(o.config)})}async removeAudioTrack(n){const t=this.audioLayers.get(n);if(!t)throw new Error(`Audio track with id ${n} not found`);this.removeClipFromTrack(t.track,t.clip),this.audioLayers.delete(n)}async muteTrack(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);t?o.clip.set({volume:0}):o.clip.set({volume:this.resolveLayerVolume(o.config)})}setMasterVolume(n){this.masterVolume=Math.max(0,Math.min(1,n));for(const t of this.audioLayers.values())t.clip.set({volume:this.resolveLayerVolume(t.config)})}resolveLayerVolume(n){return n.fadeIn||n.fadeOut?this.createVolumeKeyframes(n):(n.volume??1)*this.masterVolume}getMasterVolume(){return this.masterVolume}getAudioLayers(){return Array.from(this.audioLayers.values())}getAudioLayer(n){return this.audioLayers.get(n)}async clearAllAudioTracks(){const n=Array.from(this.audioLayers.keys());for(const t of n)await this.removeAudioTrack(t)}async syncWithVideo(n,t){for(const o of this.audioLayers.values()){const i=o.config.startTime||0,r=o.config.duration||t-n;if(i+r>t){o.config.duration=t-i;const s=new zo(this.createAudioClipConfig(o.config,o.clip.source)),l=o.track.clips.indexOf(o.clip);l!==-1&&(o.track.clips[l]=s,o.clip=s)}}}exportConfiguration(){return Array.from(this.audioLayers.values()).map(n=>({id:n.id,name:n.name,config:{...n.config,source:n.config.source&&typeof n.config.source=="object"&&"type"in n.config.source?"[AudioSource]":n.config.source}}))}async importConfiguration(n){for(const{name:t,config:o}of n)await this.addAudioTrack({...o,name:t})}}function pm(a,n){return function(){return a.apply(n,arguments)}}const{toString:A_}=Object.prototype,{getPrototypeOf:Ll}=Object,{iterator:Br,toStringTag:fm}=Symbol,Ir=(a=>n=>{const t=A_.call(n);return a[t]||(a[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Nn=a=>(a=a.toLowerCase(),n=>Ir(n)===a),Fr=a=>n=>typeof n===a,{isArray:po}=Array,Yo=Fr("undefined");function li(a){return a!==null&&!Yo(a)&&a.constructor!==null&&!Yo(a.constructor)&&qt(a.constructor.isBuffer)&&a.constructor.isBuffer(a)}const hm=Nn("ArrayBuffer");function L_(a){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(a):n=a&&a.buffer&&hm(a.buffer),n}const P_=Fr("string"),qt=Fr("function"),vm=Fr("number"),ci=a=>a!==null&&typeof a=="object",O_=a=>a===!0||a===!1,Hi=a=>{if(Ir(a)!=="object")return!1;const n=Ll(a);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(fm in a)&&!(Br in a)},U_=a=>{if(!ci(a)||li(a))return!1;try{return Object.keys(a).length===0&&Object.getPrototypeOf(a)===Object.prototype}catch{return!1}},z_=Nn("Date"),j_=Nn("File"),W_=Nn("Blob"),Z_=Nn("FileList"),H_=a=>ci(a)&&qt(a.pipe),X_=a=>{let n;return a&&(typeof FormData=="function"&&a instanceof FormData||qt(a.append)&&((n=Ir(a))==="formdata"||n==="object"&&qt(a.toString)&&a.toString()==="[object FormData]"))},G_=Nn("URLSearchParams"),[J_,K_,Y_,q_]=["ReadableStream","Request","Response","Headers"].map(Nn),Q_=a=>a.trim?a.trim():a.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function di(a,n,{allOwnKeys:t=!1}={}){if(a===null||typeof a>"u")return;let o,i;if(typeof a!="object"&&(a=[a]),po(a))for(o=0,i=a.length;o<i;o++)n.call(null,a[o],o,a);else{if(li(a))return;const r=t?Object.getOwnPropertyNames(a):Object.keys(a),s=r.length;let l;for(o=0;o<s;o++)l=r[o],n.call(null,a[l],l,a)}}function gm(a,n){if(li(a))return null;n=n.toLowerCase();const t=Object.keys(a);let o=t.length,i;for(;o-- >0;)if(i=t[o],n===i.toLowerCase())return i;return null}const Sa=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ym=a=>!Yo(a)&&a!==Sa;function nl(){const{caseless:a}=ym(this)&&this||{},n={},t=(o,i)=>{const r=a&&gm(n,i)||i;Hi(n[r])&&Hi(o)?n[r]=nl(n[r],o):Hi(o)?n[r]=nl({},o):po(o)?n[r]=o.slice():n[r]=o};for(let o=0,i=arguments.length;o<i;o++)arguments[o]&&di(arguments[o],t);return n}const eE=(a,n,t,{allOwnKeys:o}={})=>(di(n,(i,r)=>{t&&qt(i)?a[r]=pm(i,t):a[r]=i},{allOwnKeys:o}),a),tE=a=>(a.charCodeAt(0)===65279&&(a=a.slice(1)),a),nE=(a,n,t,o)=>{a.prototype=Object.create(n.prototype,o),a.prototype.constructor=a,Object.defineProperty(a,"super",{value:n.prototype}),t&&Object.assign(a.prototype,t)},aE=(a,n,t,o)=>{let i,r,s;const l={};if(n=n||{},a==null)return n;do{for(i=Object.getOwnPropertyNames(a),r=i.length;r-- >0;)s=i[r],(!o||o(s,a,n))&&!l[s]&&(n[s]=a[s],l[s]=!0);a=t!==!1&&Ll(a)}while(a&&(!t||t(a,n))&&a!==Object.prototype);return n},oE=(a,n,t)=>{a=String(a),(t===void 0||t>a.length)&&(t=a.length),t-=n.length;const o=a.indexOf(n,t);return o!==-1&&o===t},iE=a=>{if(!a)return null;if(po(a))return a;let n=a.length;if(!vm(n))return null;const t=new Array(n);for(;n-- >0;)t[n]=a[n];return t},rE=(a=>n=>a&&n instanceof a)(typeof Uint8Array<"u"&&Ll(Uint8Array)),sE=(a,n)=>{const o=(a&&a[Br]).call(a);let i;for(;(i=o.next())&&!i.done;){const r=i.value;n.call(a,r[0],r[1])}},lE=(a,n)=>{let t;const o=[];for(;(t=a.exec(n))!==null;)o.push(t);return o},cE=Nn("HTMLFormElement"),dE=a=>a.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,o,i){return o.toUpperCase()+i}),od=(({hasOwnProperty:a})=>(n,t)=>a.call(n,t))(Object.prototype),uE=Nn("RegExp"),bm=(a,n)=>{const t=Object.getOwnPropertyDescriptors(a),o={};di(t,(i,r)=>{let s;(s=n(i,r,a))!==!1&&(o[r]=s||i)}),Object.defineProperties(a,o)},mE=a=>{bm(a,(n,t)=>{if(qt(a)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const o=a[t];if(qt(o)){if(n.enumerable=!1,"writable"in n){n.writable=!1;return}n.set||(n.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},pE=(a,n)=>{const t={},o=i=>{i.forEach(r=>{t[r]=!0})};return po(a)?o(a):o(String(a).split(n)),t},fE=()=>{},hE=(a,n)=>a!=null&&Number.isFinite(a=+a)?a:n;function vE(a){return!!(a&&qt(a.append)&&a[fm]==="FormData"&&a[Br])}const gE=a=>{const n=new Array(10),t=(o,i)=>{if(ci(o)){if(n.indexOf(o)>=0)return;if(li(o))return o;if(!("toJSON"in o)){n[i]=o;const r=po(o)?[]:{};return di(o,(s,l)=>{const c=t(s,i+1);!Yo(c)&&(r[l]=c)}),n[i]=void 0,r}}return o};return t(a,0)},yE=Nn("AsyncFunction"),bE=a=>a&&(ci(a)||qt(a))&&qt(a.then)&&qt(a.catch),wm=((a,n)=>a?setImmediate:n?((t,o)=>(Sa.addEventListener("message",({source:i,data:r})=>{i===Sa&&r===t&&o.length&&o.shift()()},!1),i=>{o.push(i),Sa.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",qt(Sa.postMessage)),wE=typeof queueMicrotask<"u"?queueMicrotask.bind(Sa):typeof process<"u"&&process.nextTick||wm,kE=a=>a!=null&&qt(a[Br]),ne={isArray:po,isArrayBuffer:hm,isBuffer:li,isFormData:X_,isArrayBufferView:L_,isString:P_,isNumber:vm,isBoolean:O_,isObject:ci,isPlainObject:Hi,isEmptyObject:U_,isReadableStream:J_,isRequest:K_,isResponse:Y_,isHeaders:q_,isUndefined:Yo,isDate:z_,isFile:j_,isBlob:W_,isRegExp:uE,isFunction:qt,isStream:H_,isURLSearchParams:G_,isTypedArray:rE,isFileList:Z_,forEach:di,merge:nl,extend:eE,trim:Q_,stripBOM:tE,inherits:nE,toFlatObject:aE,kindOf:Ir,kindOfTest:Nn,endsWith:oE,toArray:iE,forEachEntry:sE,matchAll:lE,isHTMLForm:cE,hasOwnProperty:od,hasOwnProp:od,reduceDescriptors:bm,freezeMethods:mE,toObjectSet:pE,toCamelCase:dE,noop:fE,toFiniteNumber:hE,findKey:gm,global:Sa,isContextDefined:ym,isSpecCompliantForm:vE,toJSONObject:gE,isAsyncFn:yE,isThenable:bE,setImmediate:wm,asap:wE,isIterable:kE};function We(a,n,t,o,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=a,this.name="AxiosError",n&&(this.code=n),t&&(this.config=t),o&&(this.request=o),i&&(this.response=i,this.status=i.status?i.status:null)}ne.inherits(We,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:ne.toJSONObject(this.config),code:this.code,status:this.status}}});const km=We.prototype,_m={};["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(a=>{_m[a]={value:a}});Object.defineProperties(We,_m);Object.defineProperty(km,"isAxiosError",{value:!0});We.from=(a,n,t,o,i,r)=>{const s=Object.create(km);return ne.toFlatObject(a,s,function(c){return c!==Error.prototype},l=>l!=="isAxiosError"),We.call(s,a.message,n,t,o,i),s.cause=a,s.name=a.name,r&&Object.assign(s,r),s};const _E=null;function al(a){return ne.isPlainObject(a)||ne.isArray(a)}function Em(a){return ne.endsWith(a,"[]")?a.slice(0,-2):a}function id(a,n,t){return a?a.concat(n).map(function(i,r){return i=Em(i),!t&&r?"["+i+"]":i}).join(t?".":""):n}function EE(a){return ne.isArray(a)&&!a.some(al)}const xE=ne.toFlatObject(ne,{},null,function(n){return/^is[A-Z]/.test(n)});function $r(a,n,t){if(!ne.isObject(a))throw new TypeError("target must be an object");n=n||new FormData,t=ne.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,k){return!ne.isUndefined(k[g])});const o=t.metaTokens,i=t.visitor||u,r=t.dots,s=t.indexes,c=(t.Blob||typeof Blob<"u"&&Blob)&&ne.isSpecCompliantForm(n);if(!ne.isFunction(i))throw new TypeError("visitor must be a function");function d(h){if(h===null)return"";if(ne.isDate(h))return h.toISOString();if(ne.isBoolean(h))return h.toString();if(!c&&ne.isBlob(h))throw new We("Blob is not supported. Use a Buffer instead.");return ne.isArrayBuffer(h)||ne.isTypedArray(h)?c&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,g,k){let $=h;if(h&&!k&&typeof h=="object"){if(ne.endsWith(g,"{}"))g=o?g:g.slice(0,-2),h=JSON.stringify(h);else if(ne.isArray(h)&&EE(h)||(ne.isFileList(h)||ne.endsWith(g,"[]"))&&($=ne.toArray(h)))return g=Em(g),$.forEach(function(_,v){!(ne.isUndefined(_)||_===null)&&n.append(s===!0?id([g],v,r):s===null?g:g+"[]",d(_))}),!1}return al(h)?!0:(n.append(id(k,g,r),d(h)),!1)}const f=[],p=Object.assign(xE,{defaultVisitor:u,convertValue:d,isVisitable:al});function m(h,g){if(!ne.isUndefined(h)){if(f.indexOf(h)!==-1)throw Error("Circular reference detected in "+g.join("."));f.push(h),ne.forEach(h,function($,D){(!(ne.isUndefined($)||$===null)&&i.call(n,$,ne.isString(D)?D.trim():D,g,p))===!0&&m($,g?g.concat(D):[D])}),f.pop()}}if(!ne.isObject(a))throw new TypeError("data must be an object");return m(a),n}function rd(a){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(a).replace(/[!'()~]|%20|%00/g,function(o){return n[o]})}function Pl(a,n){this._pairs=[],a&&$r(a,this,n)}const xm=Pl.prototype;xm.append=function(n,t){this._pairs.push([n,t])};xm.toString=function(n){const t=n?function(o){return n.call(this,o,rd)}:rd;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function SE(a){return encodeURIComponent(a).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Sm(a,n,t){if(!n)return a;const o=t&&t.encode||SE;ne.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let r;if(i?r=i(n,t):r=ne.isURLSearchParams(n)?n.toString():new Pl(n,t).toString(o),r){const s=a.indexOf("#");s!==-1&&(a=a.slice(0,s)),a+=(a.indexOf("?")===-1?"?":"&")+r}return a}class sd{constructor(){this.handlers=[]}use(n,t,o){return this.handlers.push({fulfilled:n,rejected:t,synchronous:o?o.synchronous:!1,runWhen:o?o.runWhen:null}),this.handlers.length-1}eject(n){this.handlers[n]&&(this.handlers[n]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(n){ne.forEach(this.handlers,function(o){o!==null&&n(o)})}}const Cm={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},CE=typeof URLSearchParams<"u"?URLSearchParams:Pl,VE=typeof FormData<"u"?FormData:null,NE=typeof Blob<"u"?Blob:null,TE={isBrowser:!0,classes:{URLSearchParams:CE,FormData:VE,Blob:NE},protocols:["http","https","file","blob","url","data"]},Ol=typeof window<"u"&&typeof document<"u",ol=typeof navigator=="object"&&navigator||void 0,ME=Ol&&(!ol||["ReactNative","NativeScript","NS"].indexOf(ol.product)<0),BE=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",IE=Ol&&window.location.href||"http://localhost",FE=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ol,hasStandardBrowserEnv:ME,hasStandardBrowserWebWorkerEnv:BE,navigator:ol,origin:IE},Symbol.toStringTag,{value:"Module"})),Ht={...FE,...TE};function $E(a,n){return $r(a,new Ht.classes.URLSearchParams,{visitor:function(t,o,i,r){return Ht.isNode&&ne.isBuffer(t)?(this.append(o,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...n})}function DE(a){return ne.matchAll(/\w+|\[(\w*)]/g,a).map(n=>n[0]==="[]"?"":n[1]||n[0])}function RE(a){const n={},t=Object.keys(a);let o;const i=t.length;let r;for(o=0;o<i;o++)r=t[o],n[r]=a[r];return n}function Vm(a){function n(t,o,i,r){let s=t[r++];if(s==="__proto__")return!0;const l=Number.isFinite(+s),c=r>=t.length;return s=!s&&ne.isArray(i)?i.length:s,c?(ne.hasOwnProp(i,s)?i[s]=[i[s],o]:i[s]=o,!l):((!i[s]||!ne.isObject(i[s]))&&(i[s]=[]),n(t,o,i[s],r)&&ne.isArray(i[s])&&(i[s]=RE(i[s])),!l)}if(ne.isFormData(a)&&ne.isFunction(a.entries)){const t={};return ne.forEachEntry(a,(o,i)=>{n(DE(o),i,t,0)}),t}return null}function AE(a,n,t){if(ne.isString(a))try{return(n||JSON.parse)(a),ne.trim(a)}catch(o){if(o.name!=="SyntaxError")throw o}return(t||JSON.stringify)(a)}const ui={transitional:Cm,adapter:["xhr","http","fetch"],transformRequest:[function(n,t){const o=t.getContentType()||"",i=o.indexOf("application/json")>-1,r=ne.isObject(n);if(r&&ne.isHTMLForm(n)&&(n=new FormData(n)),ne.isFormData(n))return i?JSON.stringify(Vm(n)):n;if(ne.isArrayBuffer(n)||ne.isBuffer(n)||ne.isStream(n)||ne.isFile(n)||ne.isBlob(n)||ne.isReadableStream(n))return n;if(ne.isArrayBufferView(n))return n.buffer;if(ne.isURLSearchParams(n))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let l;if(r){if(o.indexOf("application/x-www-form-urlencoded")>-1)return $E(n,this.formSerializer).toString();if((l=ne.isFileList(n))||o.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return $r(l?{"files[]":n}:n,c&&new c,this.formSerializer)}}return r||i?(t.setContentType("application/json",!1),AE(n)):n}],transformResponse:[function(n){const t=this.transitional||ui.transitional,o=t&&t.forcedJSONParsing,i=this.responseType==="json";if(ne.isResponse(n)||ne.isReadableStream(n))return n;if(n&&ne.isString(n)&&(o&&!this.responseType||i)){const s=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(n)}catch(l){if(s)throw l.name==="SyntaxError"?We.from(l,We.ERR_BAD_RESPONSE,this,null,this.response):l}}return n}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ht.classes.FormData,Blob:Ht.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ne.forEach(["delete","get","head","post","put","patch"],a=>{ui.headers[a]={}});const LE=ne.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"]),PE=a=>{const n={};let t,o,i;return a&&a.split(`
|
|
345
|
-
`).forEach(function(s){i=s.indexOf(":"),t=s.substring(0,i).trim().toLowerCase(),o=s.substring(i+1).trim(),!(!t||n[t]&&LE[t])&&(t==="set-cookie"?n[t]?n[t].push(o):n[t]=[o]:n[t]=n[t]?n[t]+", "+o:o)}),n},ld=Symbol("internals");function No(a){return a&&String(a).trim().toLowerCase()}function Xi(a){return a===!1||a==null?a:ne.isArray(a)?a.map(Xi):String(a)}function OE(a){const n=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let o;for(;o=t.exec(a);)n[o[1]]=o[2];return n}const UE=a=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(a.trim());function fs(a,n,t,o,i){if(ne.isFunction(o))return o.call(this,n,t);if(i&&(n=t),!!ne.isString(n)){if(ne.isString(o))return n.indexOf(o)!==-1;if(ne.isRegExp(o))return o.test(n)}}function zE(a){return a.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(n,t,o)=>t.toUpperCase()+o)}function jE(a,n){const t=ne.toCamelCase(" "+n);["get","set","has"].forEach(o=>{Object.defineProperty(a,o+t,{value:function(i,r,s){return this[o].call(this,n,i,r,s)},configurable:!0})})}let Qt=class{constructor(n){n&&this.set(n)}set(n,t,o){const i=this;function r(l,c,d){const u=No(c);if(!u)throw new Error("header name must be a non-empty string");const f=ne.findKey(i,u);(!f||i[f]===void 0||d===!0||d===void 0&&i[f]!==!1)&&(i[f||c]=Xi(l))}const s=(l,c)=>ne.forEach(l,(d,u)=>r(d,u,c));if(ne.isPlainObject(n)||n instanceof this.constructor)s(n,t);else if(ne.isString(n)&&(n=n.trim())&&!UE(n))s(PE(n),t);else if(ne.isObject(n)&&ne.isIterable(n)){let l={},c,d;for(const u of n){if(!ne.isArray(u))throw TypeError("Object iterator must return a key-value pair");l[d=u[0]]=(c=l[d])?ne.isArray(c)?[...c,u[1]]:[c,u[1]]:u[1]}s(l,t)}else n!=null&&r(t,n,o);return this}get(n,t){if(n=No(n),n){const o=ne.findKey(this,n);if(o){const i=this[o];if(!t)return i;if(t===!0)return OE(i);if(ne.isFunction(t))return t.call(this,i,o);if(ne.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(n,t){if(n=No(n),n){const o=ne.findKey(this,n);return!!(o&&this[o]!==void 0&&(!t||fs(this,this[o],o,t)))}return!1}delete(n,t){const o=this;let i=!1;function r(s){if(s=No(s),s){const l=ne.findKey(o,s);l&&(!t||fs(o,o[l],l,t))&&(delete o[l],i=!0)}}return ne.isArray(n)?n.forEach(r):r(n),i}clear(n){const t=Object.keys(this);let o=t.length,i=!1;for(;o--;){const r=t[o];(!n||fs(this,this[r],r,n,!0))&&(delete this[r],i=!0)}return i}normalize(n){const t=this,o={};return ne.forEach(this,(i,r)=>{const s=ne.findKey(o,r);if(s){t[s]=Xi(i),delete t[r];return}const l=n?zE(r):String(r).trim();l!==r&&delete t[r],t[l]=Xi(i),o[l]=!0}),this}concat(...n){return this.constructor.concat(this,...n)}toJSON(n){const t=Object.create(null);return ne.forEach(this,(o,i)=>{o!=null&&o!==!1&&(t[i]=n&&ne.isArray(o)?o.join(", "):o)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([n,t])=>n+": "+t).join(`
|
|
346
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(n){return n instanceof this?n:new this(n)}static concat(n,...t){const o=new this(n);return t.forEach(i=>o.set(i)),o}static accessor(n){const o=(this[ld]=this[ld]={accessors:{}}).accessors,i=this.prototype;function r(s){const l=No(s);o[l]||(jE(i,s),o[l]=!0)}return ne.isArray(n)?n.forEach(r):r(n),this}};Qt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);ne.reduceDescriptors(Qt.prototype,({value:a},n)=>{let t=n[0].toUpperCase()+n.slice(1);return{get:()=>a,set(o){this[t]=o}}});ne.freezeMethods(Qt);function hs(a,n){const t=this||ui,o=n||t,i=Qt.from(o.headers);let r=o.data;return ne.forEach(a,function(l){r=l.call(t,r,i.normalize(),n?n.status:void 0)}),i.normalize(),r}function Nm(a){return!!(a&&a.__CANCEL__)}function fo(a,n,t){We.call(this,a??"canceled",We.ERR_CANCELED,n,t),this.name="CanceledError"}ne.inherits(fo,We,{__CANCEL__:!0});function Tm(a,n,t){const o=t.config.validateStatus;!t.status||!o||o(t.status)?a(t):n(new We("Request failed with status code "+t.status,[We.ERR_BAD_REQUEST,We.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function WE(a){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(a);return n&&n[1]||""}function ZE(a,n){a=a||10;const t=new Array(a),o=new Array(a);let i=0,r=0,s;return n=n!==void 0?n:1e3,function(c){const d=Date.now(),u=o[r];s||(s=d),t[i]=c,o[i]=d;let f=r,p=0;for(;f!==i;)p+=t[f++],f=f%a;if(i=(i+1)%a,i===r&&(r=(r+1)%a),d-s<n)return;const m=u&&d-u;return m?Math.round(p*1e3/m):void 0}}function HE(a,n){let t=0,o=1e3/n,i,r;const s=(d,u=Date.now())=>{t=u,i=null,r&&(clearTimeout(r),r=null),a(...d)};return[(...d)=>{const u=Date.now(),f=u-t;f>=o?s(d,u):(i=d,r||(r=setTimeout(()=>{r=null,s(i)},o-f)))},()=>i&&s(i)]}const cr=(a,n,t=3)=>{let o=0;const i=ZE(50,250);return HE(r=>{const s=r.loaded,l=r.lengthComputable?r.total:void 0,c=s-o,d=i(c),u=s<=l;o=s;const f={loaded:s,total:l,progress:l?s/l:void 0,bytes:c,rate:d||void 0,estimated:d&&l&&u?(l-s)/d:void 0,event:r,lengthComputable:l!=null,[n?"download":"upload"]:!0};a(f)},t)},cd=(a,n)=>{const t=a!=null;return[o=>n[0]({lengthComputable:t,total:a,loaded:o}),n[1]]},dd=a=>(...n)=>ne.asap(()=>a(...n)),XE=Ht.hasStandardBrowserEnv?((a,n)=>t=>(t=new URL(t,Ht.origin),a.protocol===t.protocol&&a.host===t.host&&(n||a.port===t.port)))(new URL(Ht.origin),Ht.navigator&&/(msie|trident)/i.test(Ht.navigator.userAgent)):()=>!0,GE=Ht.hasStandardBrowserEnv?{write(a,n,t,o,i,r){const s=[a+"="+encodeURIComponent(n)];ne.isNumber(t)&&s.push("expires="+new Date(t).toGMTString()),ne.isString(o)&&s.push("path="+o),ne.isString(i)&&s.push("domain="+i),r===!0&&s.push("secure"),document.cookie=s.join("; ")},read(a){const n=document.cookie.match(new RegExp("(^|;\\s*)("+a+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove(a){this.write(a,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function JE(a){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(a)}function KE(a,n){return n?a.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):a}function Mm(a,n,t){let o=!JE(n);return a&&(o||t==!1)?KE(a,n):n}const ud=a=>a instanceof Qt?{...a}:a;function Ba(a,n){n=n||{};const t={};function o(d,u,f,p){return ne.isPlainObject(d)&&ne.isPlainObject(u)?ne.merge.call({caseless:p},d,u):ne.isPlainObject(u)?ne.merge({},u):ne.isArray(u)?u.slice():u}function i(d,u,f,p){if(ne.isUndefined(u)){if(!ne.isUndefined(d))return o(void 0,d,f,p)}else return o(d,u,f,p)}function r(d,u){if(!ne.isUndefined(u))return o(void 0,u)}function s(d,u){if(ne.isUndefined(u)){if(!ne.isUndefined(d))return o(void 0,d)}else return o(void 0,u)}function l(d,u,f){if(f in n)return o(d,u);if(f in a)return o(void 0,d)}const c={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:(d,u,f)=>i(ud(d),ud(u),f,!0)};return ne.forEach(Object.keys({...a,...n}),function(u){const f=c[u]||i,p=f(a[u],n[u],u);ne.isUndefined(p)&&f!==l||(t[u]=p)}),t}const Bm=a=>{const n=Ba({},a);let{data:t,withXSRFToken:o,xsrfHeaderName:i,xsrfCookieName:r,headers:s,auth:l}=n;n.headers=s=Qt.from(s),n.url=Sm(Mm(n.baseURL,n.url,n.allowAbsoluteUrls),a.params,a.paramsSerializer),l&&s.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let c;if(ne.isFormData(t)){if(Ht.hasStandardBrowserEnv||Ht.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((c=s.getContentType())!==!1){const[d,...u]=c?c.split(";").map(f=>f.trim()).filter(Boolean):[];s.setContentType([d||"multipart/form-data",...u].join("; "))}}if(Ht.hasStandardBrowserEnv&&(o&&ne.isFunction(o)&&(o=o(n)),o||o!==!1&&XE(n.url))){const d=i&&r&&GE.read(r);d&&s.set(i,d)}return n},YE=typeof XMLHttpRequest<"u",qE=YE&&function(a){return new Promise(function(t,o){const i=Bm(a);let r=i.data;const s=Qt.from(i.headers).normalize();let{responseType:l,onUploadProgress:c,onDownloadProgress:d}=i,u,f,p,m,h;function g(){m&&m(),h&&h(),i.cancelToken&&i.cancelToken.unsubscribe(u),i.signal&&i.signal.removeEventListener("abort",u)}let k=new XMLHttpRequest;k.open(i.method.toUpperCase(),i.url,!0),k.timeout=i.timeout;function $(){if(!k)return;const _=Qt.from("getAllResponseHeaders"in k&&k.getAllResponseHeaders()),S={data:!l||l==="text"||l==="json"?k.responseText:k.response,status:k.status,statusText:k.statusText,headers:_,config:a,request:k};Tm(function(V){t(V),g()},function(V){o(V),g()},S),k=null}"onloadend"in k?k.onloadend=$:k.onreadystatechange=function(){!k||k.readyState!==4||k.status===0&&!(k.responseURL&&k.responseURL.indexOf("file:")===0)||setTimeout($)},k.onabort=function(){k&&(o(new We("Request aborted",We.ECONNABORTED,a,k)),k=null)},k.onerror=function(){o(new We("Network Error",We.ERR_NETWORK,a,k)),k=null},k.ontimeout=function(){let v=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const S=i.transitional||Cm;i.timeoutErrorMessage&&(v=i.timeoutErrorMessage),o(new We(v,S.clarifyTimeoutError?We.ETIMEDOUT:We.ECONNABORTED,a,k)),k=null},r===void 0&&s.setContentType(null),"setRequestHeader"in k&&ne.forEach(s.toJSON(),function(v,S){k.setRequestHeader(S,v)}),ne.isUndefined(i.withCredentials)||(k.withCredentials=!!i.withCredentials),l&&l!=="json"&&(k.responseType=i.responseType),d&&([p,h]=cr(d,!0),k.addEventListener("progress",p)),c&&k.upload&&([f,m]=cr(c),k.upload.addEventListener("progress",f),k.upload.addEventListener("loadend",m)),(i.cancelToken||i.signal)&&(u=_=>{k&&(o(!_||_.type?new fo(null,a,k):_),k.abort(),k=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));const D=WE(i.url);if(D&&Ht.protocols.indexOf(D)===-1){o(new We("Unsupported protocol "+D+":",We.ERR_BAD_REQUEST,a));return}k.send(r||null)})},QE=(a,n)=>{const{length:t}=a=a?a.filter(Boolean):[];if(n||t){let o=new AbortController,i;const r=function(d){if(!i){i=!0,l();const u=d instanceof Error?d:this.reason;o.abort(u instanceof We?u:new fo(u instanceof Error?u.message:u))}};let s=n&&setTimeout(()=>{s=null,r(new We(`timeout ${n} of ms exceeded`,We.ETIMEDOUT))},n);const l=()=>{a&&(s&&clearTimeout(s),s=null,a.forEach(d=>{d.unsubscribe?d.unsubscribe(r):d.removeEventListener("abort",r)}),a=null)};a.forEach(d=>d.addEventListener("abort",r));const{signal:c}=o;return c.unsubscribe=()=>ne.asap(l),c}},ex=function*(a,n){let t=a.byteLength;if(t<n){yield a;return}let o=0,i;for(;o<t;)i=o+n,yield a.slice(o,i),o=i},tx=async function*(a,n){for await(const t of nx(a))yield*ex(t,n)},nx=async function*(a){if(a[Symbol.asyncIterator]){yield*a;return}const n=a.getReader();try{for(;;){const{done:t,value:o}=await n.read();if(t)break;yield o}}finally{await n.cancel()}},md=(a,n,t,o)=>{const i=tx(a,n);let r=0,s,l=c=>{s||(s=!0,o&&o(c))};return new ReadableStream({async pull(c){try{const{done:d,value:u}=await i.next();if(d){l(),c.close();return}let f=u.byteLength;if(t){let p=r+=f;t(p)}c.enqueue(new Uint8Array(u))}catch(d){throw l(d),d}},cancel(c){return l(c),i.return()}},{highWaterMark:2})},Dr=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Im=Dr&&typeof ReadableStream=="function",ax=Dr&&(typeof TextEncoder=="function"?(a=>n=>a.encode(n))(new TextEncoder):async a=>new Uint8Array(await new Response(a).arrayBuffer())),Fm=(a,...n)=>{try{return!!a(...n)}catch{return!1}},ox=Im&&Fm(()=>{let a=!1;const n=new Request(Ht.origin,{body:new ReadableStream,method:"POST",get duplex(){return a=!0,"half"}}).headers.has("Content-Type");return a&&!n}),pd=64*1024,il=Im&&Fm(()=>ne.isReadableStream(new Response("").body)),dr={stream:il&&(a=>a.body)};Dr&&(a=>{["text","arrayBuffer","blob","formData","stream"].forEach(n=>{!dr[n]&&(dr[n]=ne.isFunction(a[n])?t=>t[n]():(t,o)=>{throw new We(`Response type '${n}' is not supported`,We.ERR_NOT_SUPPORT,o)})})})(new Response);const ix=async a=>{if(a==null)return 0;if(ne.isBlob(a))return a.size;if(ne.isSpecCompliantForm(a))return(await new Request(Ht.origin,{method:"POST",body:a}).arrayBuffer()).byteLength;if(ne.isArrayBufferView(a)||ne.isArrayBuffer(a))return a.byteLength;if(ne.isURLSearchParams(a)&&(a=a+""),ne.isString(a))return(await ax(a)).byteLength},rx=async(a,n)=>{const t=ne.toFiniteNumber(a.getContentLength());return t??ix(n)},sx=Dr&&(async a=>{let{url:n,method:t,data:o,signal:i,cancelToken:r,timeout:s,onDownloadProgress:l,onUploadProgress:c,responseType:d,headers:u,withCredentials:f="same-origin",fetchOptions:p}=Bm(a);d=d?(d+"").toLowerCase():"text";let m=QE([i,r&&r.toAbortSignal()],s),h;const g=m&&m.unsubscribe&&(()=>{m.unsubscribe()});let k;try{if(c&&ox&&t!=="get"&&t!=="head"&&(k=await rx(u,o))!==0){let S=new Request(n,{method:"POST",body:o,duplex:"half"}),C;if(ne.isFormData(o)&&(C=S.headers.get("content-type"))&&u.setContentType(C),S.body){const[V,x]=cd(k,cr(dd(c)));o=md(S.body,pd,V,x)}}ne.isString(f)||(f=f?"include":"omit");const $="credentials"in Request.prototype;h=new Request(n,{...p,signal:m,method:t.toUpperCase(),headers:u.normalize().toJSON(),body:o,duplex:"half",credentials:$?f:void 0});let D=await fetch(h,p);const _=il&&(d==="stream"||d==="response");if(il&&(l||_&&g)){const S={};["status","statusText","headers"].forEach(T=>{S[T]=D[T]});const C=ne.toFiniteNumber(D.headers.get("content-length")),[V,x]=l&&cd(C,cr(dd(l),!0))||[];D=new Response(md(D.body,pd,V,()=>{x&&x(),g&&g()}),S)}d=d||"text";let v=await dr[ne.findKey(dr,d)||"text"](D,a);return!_&&g&&g(),await new Promise((S,C)=>{Tm(S,C,{data:v,headers:Qt.from(D.headers),status:D.status,statusText:D.statusText,config:a,request:h})})}catch($){throw g&&g(),$&&$.name==="TypeError"&&/Load failed|fetch/i.test($.message)?Object.assign(new We("Network Error",We.ERR_NETWORK,a,h),{cause:$.cause||$}):We.from($,$&&$.code,a,h)}}),rl={http:_E,xhr:qE,fetch:sx};ne.forEach(rl,(a,n)=>{if(a){try{Object.defineProperty(a,"name",{value:n})}catch{}Object.defineProperty(a,"adapterName",{value:n})}});const fd=a=>`- ${a}`,lx=a=>ne.isFunction(a)||a===null||a===!1,$m={getAdapter:a=>{a=ne.isArray(a)?a:[a];const{length:n}=a;let t,o;const i={};for(let r=0;r<n;r++){t=a[r];let s;if(o=t,!lx(t)&&(o=rl[(s=String(t)).toLowerCase()],o===void 0))throw new We(`Unknown adapter '${s}'`);if(o)break;i[s||"#"+r]=o}if(!o){const r=Object.entries(i).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let s=n?r.length>1?`since :
|
|
347
|
-
`+r.map(fd).join(`
|
|
348
|
-
`):" "+fd(r[0]):"as no adapter specified";throw new We("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return o},adapters:rl};function vs(a){if(a.cancelToken&&a.cancelToken.throwIfRequested(),a.signal&&a.signal.aborted)throw new fo(null,a)}function hd(a){return vs(a),a.headers=Qt.from(a.headers),a.data=hs.call(a,a.transformRequest),["post","put","patch"].indexOf(a.method)!==-1&&a.headers.setContentType("application/x-www-form-urlencoded",!1),$m.getAdapter(a.adapter||ui.adapter)(a).then(function(o){return vs(a),o.data=hs.call(a,a.transformResponse,o),o.headers=Qt.from(o.headers),o},function(o){return Nm(o)||(vs(a),o&&o.response&&(o.response.data=hs.call(a,a.transformResponse,o.response),o.response.headers=Qt.from(o.response.headers))),Promise.reject(o)})}const Dm="1.11.0",Rr={};["object","boolean","number","function","string","symbol"].forEach((a,n)=>{Rr[a]=function(o){return typeof o===a||"a"+(n<1?"n ":" ")+a}});const vd={};Rr.transitional=function(n,t,o){function i(r,s){return"[Axios v"+Dm+"] Transitional option '"+r+"'"+s+(o?". "+o:"")}return(r,s,l)=>{if(n===!1)throw new We(i(s," has been removed"+(t?" in "+t:"")),We.ERR_DEPRECATED);return t&&!vd[s]&&(vd[s]=!0),n?n(r,s,l):!0}};Rr.spelling=function(n){return(t,o)=>!0};function cx(a,n,t){if(typeof a!="object")throw new We("options must be an object",We.ERR_BAD_OPTION_VALUE);const o=Object.keys(a);let i=o.length;for(;i-- >0;){const r=o[i],s=n[r];if(s){const l=a[r],c=l===void 0||s(l,r,a);if(c!==!0)throw new We("option "+r+" must be "+c,We.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new We("Unknown option "+r,We.ERR_BAD_OPTION)}}const Gi={assertOptions:cx,validators:Rr},Dn=Gi.validators;let Va=class{constructor(n){this.defaults=n||{},this.interceptors={request:new sd,response:new sd}}async request(n,t){try{return await this._request(n,t)}catch(o){if(o instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const r=i.stack?i.stack.replace(/^.+\n/,""):"";try{o.stack?r&&!String(o.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(o.stack+=`
|
|
349
|
-
`+r):o.stack=r}catch{}}throw o}}_request(n,t){typeof n=="string"?(t=t||{},t.url=n):t=n||{},t=Ba(this.defaults,t);const{transitional:o,paramsSerializer:i,headers:r}=t;o!==void 0&&Gi.assertOptions(o,{silentJSONParsing:Dn.transitional(Dn.boolean),forcedJSONParsing:Dn.transitional(Dn.boolean),clarifyTimeoutError:Dn.transitional(Dn.boolean)},!1),i!=null&&(ne.isFunction(i)?t.paramsSerializer={serialize:i}:Gi.assertOptions(i,{encode:Dn.function,serialize:Dn.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Gi.assertOptions(t,{baseUrl:Dn.spelling("baseURL"),withXsrfToken:Dn.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=r&&ne.merge(r.common,r[t.method]);r&&ne.forEach(["delete","get","head","post","put","patch","common"],h=>{delete r[h]}),t.headers=Qt.concat(s,r);const l=[];let c=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(t)===!1||(c=c&&g.synchronous,l.unshift(g.fulfilled,g.rejected))});const d=[];this.interceptors.response.forEach(function(g){d.push(g.fulfilled,g.rejected)});let u,f=0,p;if(!c){const h=[hd.bind(this),void 0];for(h.unshift(...l),h.push(...d),p=h.length,u=Promise.resolve(t);f<p;)u=u.then(h[f++],h[f++]);return u}p=l.length;let m=t;for(f=0;f<p;){const h=l[f++],g=l[f++];try{m=h(m)}catch(k){g.call(this,k);break}}try{u=hd.call(this,m)}catch(h){return Promise.reject(h)}for(f=0,p=d.length;f<p;)u=u.then(d[f++],d[f++]);return u}getUri(n){n=Ba(this.defaults,n);const t=Mm(n.baseURL,n.url,n.allowAbsoluteUrls);return Sm(t,n.params,n.paramsSerializer)}};ne.forEach(["delete","get","head","options"],function(n){Va.prototype[n]=function(t,o){return this.request(Ba(o||{},{method:n,url:t,data:(o||{}).data}))}});ne.forEach(["post","put","patch"],function(n){function t(o){return function(r,s,l){return this.request(Ba(l||{},{method:n,headers:o?{"Content-Type":"multipart/form-data"}:{},url:r,data:s}))}}Va.prototype[n]=t(),Va.prototype[n+"Form"]=t(!0)});let dx=class Rm{constructor(n){if(typeof n!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(r){t=r});const o=this;this.promise.then(i=>{if(!o._listeners)return;let r=o._listeners.length;for(;r-- >0;)o._listeners[r](i);o._listeners=null}),this.promise.then=i=>{let r;const s=new Promise(l=>{o.subscribe(l),r=l}).then(i);return s.cancel=function(){o.unsubscribe(r)},s},n(function(r,s,l){o.reason||(o.reason=new fo(r,s,l),t(o.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]}unsubscribe(n){if(!this._listeners)return;const t=this._listeners.indexOf(n);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const n=new AbortController,t=o=>{n.abort(o)};return this.subscribe(t),n.signal.unsubscribe=()=>this.unsubscribe(t),n.signal}static source(){let n;return{token:new Rm(function(i){n=i}),cancel:n}}};function ux(a){return function(t){return a.apply(null,t)}}function mx(a){return ne.isObject(a)&&a.isAxiosError===!0}const sl={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(sl).forEach(([a,n])=>{sl[n]=a});function Am(a){const n=new Va(a),t=pm(Va.prototype.request,n);return ne.extend(t,Va.prototype,n,{allOwnKeys:!0}),ne.extend(t,n,null,{allOwnKeys:!0}),t.create=function(i){return Am(Ba(a,i))},t}const St=Am(ui);St.Axios=Va;St.CanceledError=fo;St.CancelToken=dx;St.isCancel=Nm;St.VERSION=Dm;St.toFormData=$r;St.AxiosError=We;St.Cancel=St.CanceledError;St.all=function(n){return Promise.all(n)};St.spread=ux;St.isAxiosError=mx;St.mergeConfig=Ba;St.AxiosHeaders=Qt;St.formToJSON=a=>Vm(ne.isHTMLForm(a)?new FormData(a):a);St.getAdapter=$m.getAdapter;St.HttpStatusCode=sl;St.default=St;const{Axios:RF,AxiosError:AF,CanceledError:LF,isCancel:PF,CancelToken:OF,VERSION:UF,all:zF,Cancel:jF,isAxiosError:WF,spread:ZF,toFormData:HF,AxiosHeaders:XF,HttpStatusCode:GF,formToJSON:JF,getAdapter:KF,mergeConfig:YF}=St;class Ar{constructor(n="/api/v1"){this.eventSource=null,this.progressCallbacks=new Map,this.api=St.create({baseURL:n,headers:{"Content-Type":"application/json",Accept:"application/json"}}),this.api.interceptors.request.use(t=>{const o=this.getAuthToken();return o&&(t.headers.Authorization=`Bearer ${o}`),t}),this.api.interceptors.response.use(t=>t,t=>{var o;return(o=t.response)==null||o.status,Promise.reject(t)})}async createJob(n){try{const t=await this.api.post("/video/jobs",n);return this.normalizeJob(t.data.data)}catch(t){throw t}}async createRenderJob(n){try{const t=await this.api.post("/video/jobs/render",n);return this.normalizeJob(t.data.data)}catch(t){throw t}}async pollRenderJob(n,t,o=3e3,i=6e5){const r=Date.now();return new Promise((s,l)=>{const c=setInterval(async()=>{try{const d=await this.getJob(n);t==null||t(d.progress,d.status),d.status==="completed"?(clearInterval(c),s(d)):d.status==="failed"?(clearInterval(c),l(new Error(d.error_message??"Render job failed"))):d.status==="cancelled"?(clearInterval(c),l(new Error("Render job cancelled"))):Date.now()-r>i&&(clearInterval(c),l(new Error("Render job timed out")))}catch(d){clearInterval(c),l(d)}},o)})}async getJob(n){try{const t=await this.api.get(`/video/jobs/${n}`);return this.normalizeJob(t.data.data)}catch(t){throw t}}async listJobs(n){try{return(await this.api.get("/video/jobs",{params:n})).data}catch(t){throw t}}async cancelJob(n){try{const t=await this.api.delete(`/video/jobs/${n}`);return this.unsubscribeFromProgress(n),this.normalizeJob(t.data.data)}catch(t){throw t}}async retryJob(n){try{const t=await this.api.post(`/video/jobs/${n}/retry`);return this.normalizeJob(t.data.data)}catch(t){throw t}}subscribeToProgress(n,t){this.progressCallbacks.set(n,t),this.eventSource||this.initializeEventSource(),this.eventSource||this.pollProgress(n)}unsubscribeFromProgress(n){this.progressCallbacks.delete(n),this.progressCallbacks.size===0&&this.eventSource&&(this.eventSource.close(),this.eventSource=null)}initializeEventSource(){try{const n=this.getAuthToken(),t=`/api/v1/video/jobs/events${n?`?token=${n}`:""}`;this.eventSource=new EventSource(t),this.eventSource.addEventListener("progress",o=>{const i=JSON.parse(o.data),r=this.progressCallbacks.get(i.jobId);r&&r(i.progress)}),this.eventSource.addEventListener("complete",o=>{const i=JSON.parse(o.data),r=this.progressCallbacks.get(i.jobId);r&&(r(100),this.unsubscribeFromProgress(i.jobId))}),this.eventSource.addEventListener("error",o=>{this.progressCallbacks.forEach((i,r)=>{this.pollProgress(r)})})}catch{}}async pollProgress(n){const t=setInterval(async()=>{try{const o=await this.getJob(n),i=this.progressCallbacks.get(n);i&&i(o.progress),(o.status==="completed"||o.status==="failed"||o.status==="cancelled")&&(clearInterval(t),this.unsubscribeFromProgress(n))}catch{clearInterval(t)}},2e3)}getAuthToken(){const n=localStorage.getItem("auth_token");if(n)return n;const t=document.cookie.split(";");for(const o of t){const[i,r]=o.trim().split("=");if(i==="auth_token")return decodeURIComponent(r)}return null}async downloadVideo(n){try{return(await this.api.get(`/video/jobs/${n}/download`,{responseType:"blob"})).data}catch(t){throw t}}async getThumbnail(n,t=0){try{const o=await this.api.get(`/video/jobs/${n}/thumbnail`,{params:{time:t},responseType:"blob"});return URL.createObjectURL(o.data)}catch(o){throw o}}normalizeJob(n){const t=n,o={...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!==""&&(o.output_media_id=i);const r=t.error_message??t.errorMessage;typeof r=="string"&&r!==""&&(o.error_message=r);const s=t.progress_message??t.progressMessage;typeof s=="string"&&s!==""&&(o.progress_message=s);const l=t.progress_detail??t.progressDetail;l&&typeof l=="object"&&(o.progress_detail=l);const c=t.started_at??t.startedAt;typeof c=="string"&&c!==""&&(o.started_at=c);const d=t.completed_at??t.completedAt;typeof d=="string"&&d!==""&&(o.completed_at=d);const u=t.cancelled_at??t.cancelledAt;return typeof u=="string"&&u!==""&&(o.cancelled_at=u),o}}new Ar;const px={key:0,class:"mobile-layout"},fx={class:"mobile-toolbar"},hx={class:"mobile-toolbar-left"},vx=["aria-label"],gx={class:"mobile-toolbar-right"},yx=["disabled"],bx=["disabled"],wx={class:"preview-section"},kx={key:0,class:"mobile-export-overlay"},_x={class:"mobile-export-progress"},Ex={class:"mobile-export-bar"},xx={class:"mobile-timeline-zoom"},Sx={class:"mobile-edit-strip"},Cx={class:"mobile-selection-summary"},Vx={class:"mobile-selection-title"},Nx={class:"mobile-selection-meta"},Tx={class:"mobile-readout-row"},Mx=["disabled"],Bx={class:"mobile-readout-grid"},Ix={class:"mobile-readout-chip","data-testid":"mobile-playhead-readout"},Fx={class:"mobile-readout-chip","data-testid":"mobile-clip-in-readout"},$x={class:"mobile-readout-chip","data-testid":"mobile-clip-out-readout"},Dx={class:"mobile-readout-chip","data-testid":"mobile-duration-readout"},Rx=["disabled"],Ax={class:"mobile-speed-strip"},Lx={class:"mobile-speed-chips"},Px=["data-testid","onClick"],Ox={class:"mobile-edit-actions"},Ux=["disabled"],zx=["disabled"],jx=["disabled"],Wx=["disabled"],Zx=["disabled"],Hx={class:"mobile-action-sheet-header"},Xx={class:"mobile-action-sheet-title"},Gx={class:"mobile-action-sheet-subtitle"},Jx={class:"mobile-action-sheet-actions"},Kx=["disabled"],Yx=["disabled"],qx=["disabled"],Qx=["disabled"],eS=["disabled"],tS={key:1,class:"desktop-layout"},nS={class:"desktop-main-row"},aS={class:"preview-panel"},oS={class:"fit-toggle"},iS={class:"editor-content"},rS={class:"editor-tabs"},sS={class:"tab-header"},lS=["onClick"],cS={class:"tab-content-area"},dS={class:"filter-controls"},uS={class:"text-controls"},mS={class:"transition-controls"},pS={class:"audio-controls"},fS={class:"adjustments-controls"},hS={key:1,class:"no-filter-selected"},vS={class:"export-controls"},gS={key:0,"data-testid":"video-export-status-completed"},yS={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},bS={class:"desktop-timeline-row"},wS={class:"timeline-zoom"},kS=["value"],_S={class:"zoom-readout"},ES={key:0,class:"dev-editor-controls","data-testid":"video-editor-dev-controls"},xS={class:"dev-editor-row"},SS={class:"dev-editor-field"},CS={class:"dev-editor-field"},VS=["disabled"],NS=["disabled"],TS=["disabled"],MS={class:"dev-editor-row"},BS={class:"dev-editor-field dev-editor-field--wide"},IS=["value"],FS=["disabled"],$S=["disabled"],DS=["disabled"],RS=["disabled"],AS=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(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>{if(!o.media||typeof o.media!="object")return;const b=o.media.uuid??o.media.id;return typeof b=="string"&&b.trim()!==""?b.trim():void 0}),s=e.computed(()=>{const b=typeof o.mediaUuid=="string"?o.mediaUuid.trim():"";return b!==""?b:r.value??`temp-${Date.now()}`}),l=e.ref(typeof window<"u"?window.innerWidth<768:!1),c=e.ref("filters"),d=e.ref("filters"),u=e.computed(()=>{const b=o.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},I=o.featureFlags;return I?{filters:typeof I.filters=="boolean"?I.filters:b.filters,adjustments:typeof I.adjustments=="boolean"?I.adjustments:b.adjustments,text:typeof I.text=="boolean"?I.text:b.text,transitions:typeof I.transitions=="boolean"?I.transitions:b.transitions,audio:typeof I.audio=="boolean"?I.audio:b.audio,export:typeof I.export=="boolean"?I.export:b.export}:b}),f=e.computed(()=>l.value?c.value:d.value),p=e.computed(()=>f.value==="filters"||k.value),m=e.computed(()=>f.value!=="filters"&&!k.value),h=e.ref(null),g=e.ref(null),k=e.ref(!1),$=e.computed(()=>l.value?h.value:g.value);function D(b){return b==="contain"||b==="cover"||b==="none"}function _(b){if(!(b!=null&&b.metadata))return null;const I=b.metadata.fit_mode;return D(I)?I:null}const v=e.shallowRef(null),S=e.ref(null),C=e.ref(_(o.initialRecipe)??"contain"),V=e.ref(null),x=e.ref(null),T=e.ref(null),j=e.ref(!1),E=new Map,A=e.ref([]),N=e.ref([]),z=e.ref([]),P=e.ref([]),B=e.ref(1),L=()=>{l.value=window.innerWidth<768},w=[{id:"filters",label:"Filters",icon:oa},{id:"adjustments",label:"Adjust",icon:Of},{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:ao}],O=[{id:"filters",label:"Filters"},{id:"adjustments",label:"Adjustments"},{id:"text",label:"Text"},{id:"transitions",label:"Transitions"},{id:"audio",label:"Audio"},{id:"export",label:"Export"}],Z=e.computed(()=>w.filter(b=>u.value[b.id])),G=e.computed(()=>O.filter(b=>u.value[b.id])),re=e.computed(()=>{var b,I;return((b=G.value[0])==null?void 0:b.id)??((I=Z.value[0])==null?void 0:I.id)??"filters"});e.watch(u,b=>{b[c.value]||(c.value=re.value),b[d.value]||(d.value=re.value)},{immediate:!0,deep:!0}),e.watch(re,b=>{u.value[c.value]||(c.value=b),u.value[d.value]||(d.value=b)},{immediate:!0}),e.watch(u,b=>{b.export||(c.value==="export"&&(c.value=re.value),d.value==="export"&&(d.value=re.value))},{immediate:!0,deep:!0});const be=e.computed(()=>typeof window>"u"?!1:window.__MEDIABLES_EDITOR_DEV__===!0),Ee=Jd(),{currentFrame:ie,playheadPosition:R,timelineClips:M,totalDuration:H,hasChanges:ee,isPlaying:ae,selectedClip:ue,zoomLevel:de,playbackSpeed:ye,fps:Be,handleTrim:fe,handleSplit:ge,handleClipSelect:Se,splitAtPlayhead:Ie,deleteSelectedClip:pt,duplicateSelectedClip:lt,setZoomLevel:Dt,moveClip:ot,setFilters:vt,setTextOverlays:bt,setAudioTracks:it,saveDraft:wt,clearHasChanges:Et,resetChanges:he,generateRecipe:Ne,zoomIn:Re,zoomOut:He,fitToWindow:je,togglePlayback:Oe,setPlaying:ct,seekTo:dt,frameForward:Pt,frameBackward:Rt,skipToStart:Ot,skipToEnd:tn,setPlaybackSpeed:zn,updateSourceDuration:Yn,undo:q,redo:le,canUndo:oe,canRedo:se}=sm(s.value,o.initialRecipe,o.media),{videoCompatibleFilters:Ce,activeFilters:Ve,selectedFilter:Je,previewFilter:st,previewFilterEffect:ut,applyFilter:nt,updateFilterParams:kt,removeFilter:At,clearAllFilters:nn,setActiveFilters:qn}=dm();function mn(b){var Y,ce;const I=((Y=ue.value)==null?void 0:Y.id)??((ce=M.value[0])==null?void 0:ce.id);I&&(j.value=!0,typeof b=="object"&&b.id?nt(b.id):typeof b=="string"&&nt(b),vt(Ve.value),v.value?v.value.setClipFilters(I,Ve.value):E.set(I,[...Ve.value]),Se(I),j.value=!1,$n())}function Aa(){var I,Y;const b=((I=ue.value)==null?void 0:I.id)??((Y=M.value[0])==null?void 0:Y.id);b&&Se(b)}function da(b){const I=Ve.value.find(Y=>Y.filterId===b);I&&At(I.id)}const kn=e.computed(()=>Ce.value.map(I=>{var ce;const Y=[];if(I.controls&&I.controls.length>0)for(const xe of I.controls){const we=xe.type;if(we==="button"||we==="text"||we==="range")continue;const ke={id:xe.property||xe.id,label:xe.label||xe.id,type:we,default:xe.default??(we==="toggle"?!1:we==="color"?"#ffffff":0)};we==="slider"&&(ke.min=xe.min??0,ke.max=xe.max??1,ke.step=xe.step??.01),we==="select"&&xe.options&&(ke.options=xe.options),Y.push(ke)}else if(I.paramRanges){const xe=Object.entries(I.paramRanges);for(const[we,ke]of xe){const at=we.replace(/[-_]/g," ").replace(/\b\w/g,ga=>ga.toUpperCase()),rn=(ce=I.defaultParams)==null?void 0:ce[we],Ja=(ke.min+ke.max)/2;Y.push({id:we,label:at,min:ke.min,max:ke.max,step:ke.step??.01,default:typeof rn=="number"?rn:Ja})}}return{id:I.id,name:I.name,category:I.category,params:Y}})),pn=e.ref("0.00"),fn=e.ref("0.00"),W=e.ref("");e.watch(kn,b=>{if(b.length===0){W.value="";return}b.some(Y=>Y.id===W.value)||(W.value=b[0].id)},{immediate:!0});const J=e.ref(!1),te=e.ref(0),ve=e.ref(!1),_e=e.ref(null),Ue=e.ref(null);let Ye=null,Xe=!1;const rt=e.computed(()=>{const b=new Map;return Ve.value.forEach(I=>b.set(I.filterId,I)),b}),_n=e.computed(()=>{var b,I;return ie.value?ie.value:((b=o.media)==null?void 0:b.thumbnail_url)||((I=o.media)==null?void 0:I.url)}),Xt=e.ref("");e.watch(()=>{var b,I;return{file:(b=o.media)==null?void 0:b.file,url:(I=o.media)==null?void 0:I.url}},(b,I,Y)=>{var xe,we;const ce=Xt.value;Y(()=>{ce&&ce.startsWith("blob:")&&URL.revokeObjectURL(ce)}),(xe=o.media)!=null&&xe.file?Xt.value=URL.createObjectURL(o.media.file):(we=o.media)!=null&&we.url?Xt.value=o.media.url:Xt.value=""},{immediate:!0}),e.onUnmounted(()=>{Xt.value&&Xt.value.startsWith("blob:")&&URL.revokeObjectURL(Xt.value)});const hn=e.computed(()=>Xt.value),Tn=$u({forcePixiPreview:k,getPreviewRef:()=>$.value,getSourceUrl:()=>Xt.value,setPlaying:ct}),Mn=e.computed(()=>{if(!o.media)return null;const{file:b,...I}=o.media;return{...I,url:Xt.value}}),gt=e.computed(()=>{var I;const b=(I=o.media)==null?void 0:I.url;return!!(b&&/^https?:/i.test(b))}),an=e.computed(()=>Ve.value),on=e.computed(()=>R.value),Ut=e.computed(()=>!!ue.value&&R.value>0),jn=e.computed(()=>!!ue.value&&M.value.length>1),La=e.computed(()=>!!ue.value),Bn=e.ref(!0),Qn=[.5,1,1.5,2],Pa=e.computed(()=>{const b=new Set([0,Jt.value]);for(const I of M.value)b.add(I.timelineStart),b.add(I.timelineEnd);return Array.from(b).filter(I=>Number.isFinite(I)).sort((I,Y)=>I-Y)}),mi=e.computed(()=>Pa.value.some(b=>b<R.value-.001)),pi=e.computed(()=>Pa.value.some(b=>b>R.value+.001)),Oa=e.ref(!1),Ua=e.ref(null);function In(b){if(!Number.isFinite(b)||b<0)return"0:00";const I=Math.floor(b/60),Y=Math.floor(b%60);return`${I}:${Y.toString().padStart(2,"0")}`}const ho=e.computed(()=>{var Y;const b=ue.value??M.value[0];if(!b)return"No clip selected";const I=(Y=b.label)==null?void 0:Y.trim();return I&&I.length>0?I:`Clip ${b.id.slice(-4)}`}),Ur=e.computed(()=>{const b=ue.value??M.value[0];if(!b)return"Tap a clip to start editing";const I=Math.max(0,b.timelineEnd-b.timelineStart);return`${In(b.timelineStart)} - ${In(b.timelineEnd)} • ${I.toFixed(1)}s`});function fi(b){return!Number.isFinite(b)||b<0?"0.0s":b<60?`${b.toFixed(1)}s`:In(b)}const zr=e.computed(()=>In(R.value)),vo=e.computed(()=>{const b=ue.value??M.value[0];return b?In(b.sourceIn):"0:00"}),jr=e.computed(()=>{const b=ue.value??M.value[0];return b?In(b.sourceOut):"0:00"}),Wr=e.computed(()=>{const b=ue.value??M.value[0];return b?fi(b.timelineEnd-b.timelineStart):"0.0s"}),go=e.computed(()=>Ua.value===null?ue.value??M.value[0]??null:M.value.find(b=>b.id===Ua.value)??null),za=e.computed(()=>{var Y;const b=go.value;if(!b)return"Clip actions";const I=(Y=b.label)==null?void 0:Y.trim();return I&&I.length>0?I:`Clip ${b.id.slice(-4)}`}),Zr=e.computed(()=>{const b=go.value;return b?`${In(b.timelineStart)} - ${In(b.timelineEnd)} • ${fi(b.timelineEnd-b.timelineStart)}`:"Choose an action"}),ja=e.ref(0),Jt=e.computed(()=>{try{const b=H.value??H;return b&&typeof b=="number"&&b>0?b:ja.value}catch{return ja.value}}),_t=e.ref(),Wn=e.ref(),vn=e.ref(),ft=e.ref(),gn=e.ref(0),En=e.ref(!1);let Mt=null,It=null;e.watch(Jt,b=>{var Y;if(En.value||!b||b<=0)return;const I=gn.value||((Y=_t.value)==null?void 0:Y.clientWidth)||0;I>0&&(En.value=!0,je(I))}),e.watch(gn,b=>{if(En.value||!b||b<=0)return;Jt.value>0&&(En.value=!0,je(b))}),e.watch(l,b=>{b||xn()}),e.watch(()=>{var b;return(b=go.value)==null?void 0:b.id},b=>{Oa.value&&!b&&xn()});function Zn(b){return Number.isFinite(b)?b.toFixed(2):"0.00"}function hi(b){const I=Number(b);return Number.isFinite(I)?I:null}function vi(b){b&&(pn.value=Zn(b.sourceIn),fn.value=Zn(b.sourceOut))}e.watch(()=>{var b,I,Y;return[(b=ue.value)==null?void 0:b.id,(I=ue.value)==null?void 0:I.sourceIn,(Y=ue.value)==null?void 0:Y.sourceOut]},()=>{vi(ue.value)},{immediate:!0});function Kt(b){const I=ue.value;if(!I)return;const Y=1/30,ce=I.sourceMinIn??0,xe=I.sourceMaxOut??Jt.value,we=I.sourceIn+(R.value-I.timelineStart);if(b==="start"){const at=Math.max(ce,Math.min(we,I.sourceOut-Y));pn.value=Zn(at);return}const ke=Math.max(I.sourceIn+Y,Math.min(we,xe));fn.value=Zn(ke)}function Hr(){const b=ue.value;if(!b)return;const I=hi(pn.value),Y=hi(fn.value);if(I===null||Y===null)return;const ce=1/30,xe=b.sourceMinIn??0,we=b.sourceMaxOut??Jt.value,ke=Math.max(xe,Math.min(I,we-ce)),at=Math.max(ke+ce,Math.min(Y,we));fe(b.id,"start",ke),fe(b.id,"end",at),pn.value=Zn(ke),fn.value=Zn(at),ue.value&&dt(ue.value.timelineStart)}function Xr(){W.value.trim()!==""&&mn(W.value)}function Wa(){var b;nn(),vt(Ve.value),(b=ue.value)!=null&&b.id&&(v.value?v.value.setClipFilters(ue.value.id,Ve.value):E.set(ue.value.id,[...Ve.value])),$n()}function Za(b,I,Y){var xe,we;const ce=Ve.value.find(ke=>ke.filterId===b);ce?(ce.params={...ce.params,[I]:Y},vt(Ve.value),v.value&&((xe=ue.value)!=null&&xe.id)?v.value.setClipFilters(ue.value.id,Ve.value):(we=ue.value)!=null&&we.id&&E.set(ue.value.id,[...Ve.value]),$n(),Aa()):st.value&&st.value.filterId===b&&(st.value.params={...st.value.params||{},[I]:Y})}function Fn(b){dt(b)}function gi(b){!b||!Number.isFinite(b.timestamp)||dt(b.timestamp)}function yo(b){ct(b)}function ua(b){!Number.isFinite(b)||b<=0||(ja.value=b,Yn(b))}function xn(){Oa.value=!1,Ua.value=null}function yi(b){l.value&&(Ua.value=b,Oa.value=!0)}function ma(b){var ce,xe,we,ke;const I=((ce=ue.value)==null?void 0:ce.id)??((xe=M.value[0])==null?void 0:xe.id)??null;Se(b),(((we=ue.value)==null?void 0:we.id)??((ke=M.value[0])==null?void 0:ke.id)??null)!==I&&Ee.selection()}function bo(b){ma(b),yi(b)}function pa(b){b&&Ee.selection()}function fa(){Bn.value=!Bn.value,Ee.selection()}function ha(){const b=Pa.value.filter(Y=>Y<R.value-.001),I=b.length>0?b[b.length-1]:0;dt(I)}function bi(){const b=Pa.value.find(I=>I>R.value+.001);dt(b??Jt.value)}function wo(){q()}function wi(){le()}function ko(){const b=M.value.length;Ie(),M.value.length>b&&(Ee.success(),xn())}function _o(b){const I=M.value.length;ge(b),M.value.length>I&&Ee.success()}function Ha(){const b=M.value.length;lt(),M.value.length>b&&(Ee.selection(),xn())}function Xa(){const b=M.value.length;pt(),M.value.length<b&&(Ee.error(),xn())}function ki(b){const I=ye.value;zn(b),ye.value!==I&&Ee.selection()}function y(b){return b instanceof HTMLElement?b.closest('input, textarea, select, button, [contenteditable="true"]')!==null:!1}function F(b){if(l.value||y(b.target))return;const I=b.key.toLowerCase(),Y=b.metaKey||b.ctrlKey;if(b.code==="Space"){b.preventDefault(),Oe();return}if(!Y&&I==="s"){b.preventDefault(),ko();return}if(I==="arrowleft"){b.preventDefault(),Rt();return}if(I==="arrowright"){b.preventDefault(),Pt();return}if(I==="home"){b.preventDefault(),Ot();return}if(I==="end"){b.preventDefault(),tn();return}if(!Y&&I==="["){b.preventDefault(),ha();return}if(!Y&&I==="]"){b.preventDefault(),bi();return}if(Y&&I==="z"&&b.shiftKey){b.preventDefault(),wi();return}Y&&I==="z"&&(b.preventDefault(),wo())}function Q(){var I;const b=gn.value||((I=_t.value)==null?void 0:I.clientWidth)||800;je(b)}function me(b){En.value=!0,Dt(b)}function Ae(){En.value=!0,Re()}function De(){En.value=!0,He()}function Ge(b){const I=b.target,Y=Number(I.value);me(Y)}function ht(b){const I=Math.min(600,Math.max(10,de.value+b));me(I)}function Ct(){It==null||It(),It=null;const b=vn.value,I=ft.value;if(!l.value||!b||!I)return;const Y=()=>{ht(-20)},ce=()=>{ht(20)};b.addEventListener("click",Y),I.addEventListener("click",ce),It=()=>{b.removeEventListener("click",Y),I.removeEventListener("click",ce)}}e.watch([l,vn,ft],()=>{Ct()},{flush:"post"});function zt(b){var I;v.value=b,(I=v.value)!=null&&I.composition&&(V.value=new um(v.value.composition),x.value=new Go(v.value.composition),T.value=new mm(v.value.composition));try{E.size&&(E.forEach((Y,ce)=>{v.value.setClipFilters(ce,Y)}),E.clear(),v.value.composition.computeFrame())}catch{}}function Ga(b){b!=null&&b.id&&ut(b.id)}function mp(b){kt(b),$n()}async function pp(b){if(!V.value)return;const I=await V.value.addTextOverlay(b);A.value.push({id:I,...b})}async function fp(b,I){if(!V.value)return;await V.value.updateTextOverlay(b,I);const Y=A.value.findIndex(ce=>ce.id===b);Y!==-1&&(A.value[Y]={...A.value[Y],...I})}async function hp(b){V.value&&(await V.value.removeTextOverlay(b),A.value=A.value.filter(I=>I.id!==b))}async function vp(b){if(!x.value||P.value.length<2)return;const[I,Y]=P.value,ce=await x.value.applyTransition(I,Y,b);N.value.push({id:ce,...b,name:b.type})}function gp(b){if(!x.value)return;const I=N.value[b];I&&(x.value.removeTransition(I.id),N.value.splice(b,1))}function yp(b){}async function bp(b){if(!T.value)return;const I=await T.value.addAudioTrack(b);z.value.push({id:I,...b})}async function wp(b,I){if(!T.value)return;const Y=z.value.findIndex(ce=>ce.id===b);Y!==-1&&(z.value[Y]={...z.value[Y],...I})}async function kp(b){T.value&&(await T.value.removeAudioTrack(b),z.value=z.value.filter(I=>I.id!==b))}async function _p(b,I){if(!T.value)return;await T.value.updateVolume(b,I);const Y=z.value.find(ce=>ce.id===b);Y&&(Y.volume=I)}async function Ep(b,I){if(!T.value)return;await T.value.muteTrack(b,I);const Y=z.value.find(ce=>ce.id===b);Y&&(Y.muted=I)}function xp(b){T.value&&(T.value.setMasterVolume(b),B.value=b)}function Sp(b){i("thumbnail-selected",b)}function ea(){Ye!==null&&(clearInterval(Ye),Ye=null)}function Cp(b,I){return I?{...b,output:{...b.output,format:I.format,quality:I.quality}}:b}function Eo(b){var I;return b.metadata||(b.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),b.metadata.fit_mode=C.value,(I=o.media)!=null&&I.url&&/^https?:/i.test(o.media.url)?b.metadata.source_url=o.media.url:delete b.metadata.source_url,b}function xt(b,I,Y){return Math.min(Y,Math.max(I,b))}function Gr(b,I){if(typeof b=="number"&&Number.isFinite(b))return b;if(typeof b=="string"){const Y=Number(b);if(Number.isFinite(Y))return Y}return I}function jt(b,I,Y){for(const ce of I)if(ce in b)return Gr(b[ce],Y);return Y}function Vp(b){const I=typeof b.params=="object"&&b.params!==null?b.params:{};switch(b.filterId.trim().toLowerCase()){case"brightness":return[{type:"brightness",value:xt(jt(I,["value","brightness"],0),-1,1)}];case"contrast":return[{type:"contrast",value:xt(jt(I,["value","contrast"],1),.1,3)}];case"saturation":return[{type:"saturation",value:xt(jt(I,["value","saturation"],1),0,3)}];case"blur":case"gaussian-blur":case"kawase-blur":case"radial-blur":return[{type:"blur",value:xt(jt(I,["value","blur","radius"],0),0,25)}];case"sharpen":return[{type:"sharpen",value:xt(jt(I,["value","amount"],1),0,5)}];case"sepia":return[{type:"sepia",value:1}];case"grayscale":return[{type:"grayscale",value:1}];case"adjustment":{const ce=xt(jt(I,["brightness"],1)-1,-1,1),xe=xt(jt(I,["contrast"],1),.1,3),we=xt(jt(I,["saturation"],1),0,3);return[{type:"brightness",value:ce},{type:"contrast",value:xe},{type:"saturation",value:we}]}default:return[]}}function Np(b){const I=b.timeline[0],Y=Array.isArray(I==null?void 0:I.filters)?I.filters:[],ce=[];for(const we of Y)if(ce.push(...Vp(we)),ce.length>=12)break;const xe={...b,filters:ce.slice(0,12)};if(b.timeline.length===1&&I){const we=Math.max(0,Gr(I.sourceIn,0)),ke=Gr(I.sourceOut,we);ke>we&&(xe.trim={start:we,end:ke})}return xe}async function ql(b,I,Y){return Tn.renderRecipeWithPixi(b,I,Y)}async function Tp(b,I){var xo;ea(),Xe=!1,Tn.resetClientExport(),Ue.value=null,_e.value=null,ve.value=!1,te.value=0;const Y=Eo(b??Ne()),ce=ic(Y),xe=Array.isArray(ce.filters)&&ce.filters.length>0,we=Yr(ce);if(!(ee.value||xe||we))return Et(),i("video-exported",null),null;const at=ce.timeline[0],rn=at?Math.max(0,at.sourceIn):0,ga=((at==null?void 0:at.sourceOut)??((xo=ce.source)==null?void 0:xo.duration)??Jt.value)-rn,es=o.serverRenderEndpoint!=null&&o.clientExportThreshold>0&&ga>o.clientExportThreshold;if(es){J.value=!0;try{return await Mp(ce),null}catch(Wt){const sn=Wt instanceof Error?Wt.message:"Server render failed";throw _e.value=sn,i("server-render-failed",sn),Wt}finally{J.value=!1}}if(o.maxDuration>0&&ga>o.maxDuration&&!es){const Wt=`This video is too long for in-browser export (${Math.round(ga)}s). Server rendering is not available. Try a shorter clip.`;return _e.value=Wt,i("video-exported",null),null}J.value=!0;try{const Wt=await ql(ce,I,sn=>{Xe||(te.value=sn)});return Xe?(_e.value="Export canceled.",te.value=0,i("video-exported",null),null):(Et(),i("recipe-generated",ce),i("video-exported",Wt),te.value=100,ve.value=!0,Wt)}catch(Wt){if(Xe)return _e.value="Export canceled.",te.value=0,i("video-exported",null),null;const sn=Wt instanceof Error?Wt.message:"Local WebGL export failed.";throw _e.value=sn,new Error(`Video export failed: ${sn}`)}finally{J.value=!1}}function _i(){return new Ar(o.serverRenderEndpoint??"/api/v1")}async function Mp(b){const I=_i();_e.value="Starting server render...",te.value=0;const Y=await I.createRenderJob({source_media_uuid:s.value,recipe:b});Ue.value=Y.id,i("server-render-started",Y.id),i("export-started",Y.id),_e.value="Rendering on server...";const ce=await I.pollRenderJob(Y.id,(we,ke)=>{te.value=we,ke==="processing"&&(_e.value=`Server rendering: ${we}%`)},3e3,(o.maxDuration>0?o.maxDuration*3:1800)*1e3);te.value=100,ve.value=!0,_e.value="Server render complete!",Et(),i("recipe-generated",b);const xe={id:ce.id};typeof ce.output_media_id=="string"&&ce.output_media_id!==""&&(xe.output_media_id=ce.output_media_id),i("server-render-completed",xe)}async function Ql(){if(!J.value)return;Xe=!0,k.value=!1,Tn.cancelClientExport(),ea();const b=Ue.value;if(b)try{await _i().cancelJob(b)}catch(I){const Y=I instanceof Error?I.message:"Failed to cancel export";_e.value=Y,J.value=!1,Ue.value=null;return}J.value=!1,te.value=0,ve.value=!1,Ue.value=null,_e.value="Export canceled."}async function ec(b){ea(),Xe=!1,Tn.resetClientExport(),Ue.value=null,_e.value=null,ve.value=!1,J.value=!0,te.value=0;try{const I=Eo(Cp(Ne(),b));i("recipe-generated",I);const Y=s.value.startsWith("temp-"),ce=I.timeline[0],xe=Array.isArray(ce==null?void 0:ce.filters)?ce.filters:[],we=!0,ke=typeof window<"u"&&window.MEDIABLES_ALLOW_SERVER_EXPORT_FALLBACK===1||typeof localStorage<"u"&&localStorage.getItem("mediables.export.allowServerFallback")==="1";if(we)try{const sn=await ql(I,b,jp=>{Xe||(te.value=jp)});if(Xe){_e.value="Export canceled.",J.value=!1,te.value=0;return}i("video-exported",sn);const sc=URL.createObjectURL(sn.file),ts=document.createElement("a");ts.href=sc,ts.download=`edited-video-${Date.now()}.mp4`,ts.click(),setTimeout(()=>URL.revokeObjectURL(sc),100),J.value=!1,te.value=100,ve.value=!0;return}catch(sn){if(Xe){_e.value="Export canceled.",J.value=!1,te.value=0;return}if(Y||!ke)throw sn;te.value=0,_e.value="Local filter export failed, falling back to server render."}const at={"360p":"low","480p":"low","720p":"medium","1080p":"high","1440p":"ultra","2160p":"ultra"},rn=(b==null?void 0:b.quality)??I.output.quality,Ja=at[rn]??"high",ga={...Np(I),export:{format:(b==null?void 0:b.format)??I.output.format,quality:Ja,resolution:rn,framerate:I.output.fps}},xo=await _i().createJob({source_media_id:s.value,recipe:ga}),Wt=typeof xo.id=="string"?xo.id:null;if(!Wt)throw new Error("Export failed: missing job id");Ue.value=Wt,i("export-started",Wt),Up(Wt)}catch(I){if(k.value=!1,Tn.resetClientExport(),Xe){_e.value="Export canceled.",J.value=!1,te.value=0,Ue.value=null;return}try{const Y=Eo(Ne()),ce=new Blob([JSON.stringify(Y,null,2)],{type:"application/json"}),xe=URL.createObjectURL(ce),we=document.createElement("a");we.href=xe,we.download=`video-recipe-${Date.now()}.json`,we.click(),setTimeout(()=>URL.revokeObjectURL(xe),100)}finally{J.value=!1,te.value=0,Ue.value=null,_e.value=I instanceof Error?I.message:"Export failed"}}}const Jr=async b=>{await new Promise(I=>{window.setTimeout(I,b)})},Kr=b=>{if(!b||b.width<=0||b.height<=0)return null;try{return b.toDataURL("image/jpeg",.85)}catch{return null}},Bp=b=>{if(!b||typeof b!="object")return null;const Y=b.pixiCanvas;if(Y&&typeof Y=="object"&&"value"in Y){const ce=Y.value;return ce instanceof HTMLCanvasElement?ce:null}return Y instanceof HTMLCanvasElement?Y:null},Ip=b=>{if(!b||typeof b!="object")return null;const I=b.duration;if(typeof I=="number"&&Number.isFinite(I))return I;if(I&&typeof I=="object"&&"value"in I){const Y=I.value;if(typeof Y=="number"&&Number.isFinite(Y))return Y}return null},Fp=b=>{if(!b||typeof b!="object")return null;const Y=b.videoElement;if(Y&&typeof Y=="object"&&"value"in Y){const ce=Y.value;return ce instanceof HTMLVideoElement?ce:null}return Y instanceof HTMLVideoElement?Y:null},tc=b=>typeof b.params=="object"&&b.params!==null?b.params:{},$p=b=>{const I=[];for(const Y of b){const ce=tc(Y),xe=Y.filterId.trim().toLowerCase();if(xe==="brightness"){const ke=(xt(jt(ce,["value","brightness"],0),-1,1)+1)*100;I.push(`brightness(${ke.toFixed(2)}%)`);continue}if(xe==="contrast"){const we=xt(jt(ce,["value","contrast"],1),.1,4);I.push(`contrast(${(we*100).toFixed(2)}%)`);continue}if(xe==="saturation"||xe==="saturate"){const we=xt(jt(ce,["value","saturation"],1),0,4);I.push(`saturate(${(we*100).toFixed(2)}%)`);continue}if(xe==="grayscale"){I.push("grayscale(100%)");continue}if(xe==="sepia"){I.push("sepia(100%)");continue}if(xe==="blur"||xe==="gaussian-blur"||xe==="kawase-blur"){const we=xt(jt(ce,["value","blur","radius"],0),0,30);we>.01&&I.push(`blur(${we.toFixed(2)}px)`);continue}if(xe==="adjustment"){const we=jt(ce,["brightness"],1),ke=jt(ce,["contrast"],1),at=jt(ce,["saturation"],1);Math.abs(we-1)>.01&&I.push(`brightness(${(xt(we,0,5)*100).toFixed(2)}%)`),Math.abs(ke-1)>.01&&I.push(`contrast(${(xt(ke,.1,5)*100).toFixed(2)}%)`),Math.abs(at-1)>.01&&I.push(`saturate(${(xt(at,0,5)*100).toFixed(2)}%)`);continue}if(xe==="cinematic"){I.push("contrast(120%) brightness(95%) saturate(85%)");continue}if(xe==="dramatic"){I.push("contrast(140%) brightness(90%) saturate(110%) sepia(10%)");continue}if(xe==="dreamy"){I.push("blur(0.5px) brightness(105%) saturate(90%) contrast(95%)");continue}}return I.join(" ")},Dp=b=>{const I=b.find(xe=>xe.filterId.trim().toLowerCase()==="noise");if(!I)return 0;const Y=tc(I),ce=jt(Y,["noise","value","amount","intensity"],.2);return ce<=1?xt(ce,0,1):xt(ce/100,0,1)},Rp=(b,I,Y,ce)=>{if(ce<=0)return;const xe=b.getImageData(0,0,I,Y),we=255*ce;for(let ke=0;ke<xe.data.length;ke+=4){const at=(Math.random()*2-1)*we;xe.data[ke]=xt(xe.data[ke]+at,0,255),xe.data[ke+1]=xt(xe.data[ke+1]+at,0,255),xe.data[ke+2]=xt(xe.data[ke+2]+at,0,255)}b.putImageData(xe,0,0)},nc=async b=>{b.readyState>=2&&b.videoWidth>0&&b.videoHeight>0||await new Promise(I=>{let Y=!1,ce=0;const xe=()=>{Y||(Y=!0,b.removeEventListener("loadedmetadata",we),b.removeEventListener("loadeddata",we),b.removeEventListener("canplay",we),window.clearTimeout(ce),I())},we=()=>{xe()};b.addEventListener("loadedmetadata",we),b.addEventListener("loadeddata",we),b.addEventListener("canplay",we),ce=window.setTimeout(()=>xe(),800),b.play().catch(()=>{})})},Ap=async(b,I)=>{await new Promise(Y=>{let ce=!1,xe=0;const we=()=>{ce||(ce=!0,b.removeEventListener("seeked",ke),window.clearTimeout(xe),Y())},ke=()=>{we()};if(Math.abs(b.currentTime-I)<.016){requestAnimationFrame(()=>we());return}b.addEventListener("seeked",ke),xe=window.setTimeout(()=>we(),700),b.currentTime=I})},ac=async(b,I)=>{await nc(b);const Y=Math.floor(b.videoWidth),ce=Math.floor(b.videoHeight);if(Y<=0||ce<=0)return null;const xe=Number.isFinite(b.duration)&&b.duration>0?b.duration:0,we=xe>0?xt(I,0,xe):0;await Ap(b,we);const ke=document.createElement("canvas");ke.width=Y,ke.height=ce;const at=ke.getContext("2d");if(!at)return null;const rn=$p(Ve.value);rn!==""&&(at.filter=rn);try{at.drawImage(b,0,0,Y,ce)}catch{return null}const Ja=Dp(Ve.value);return Rp(at,Y,ce,Ja),Kr(ke)},Lp=async(b,I)=>{const Y=document.createElement("video");Y.src=b,Y.muted=!0,Y.playsInline=!0,Y.preload="auto",b.startsWith("blob:")||(Y.crossOrigin="anonymous");try{return await nc(Y),await ac(Y,I)}catch{return null}finally{Y.pause(),Y.removeAttribute("src"),Y.load()}},Pp=async b=>{const I=$.value,Y=Kr(Bp(I));if(Y)return Y;if(I!=null&&I.captureFrameAt)for(let we=0;we<4;we+=1){const ke=Ip(I);if(ke!==null&&ke<=0&&we<2){await Jr(80);continue}const at=await Promise.race([I.captureFrameAt(b),Jr(450).then(()=>null)]),rn=Kr(at);if(rn)return rn;await Jr(80)}const ce=Fp(I);if(ce){const we=await ac(ce,b);if(we)return we}const xe=hn.value.trim();if(xe!==""){const we=await Lp(xe,b);if(we)return we}return null},oc=b=>b.map(I=>({...I,params:I.params&&typeof I.params=="object"?{...I.params}:I.params}));function ic(b){const I=oc(Ve.value);if(!Yr(b)&&I.length>0&&Array.isArray(b.timeline)&&b.timeline.length>0){const ce=b.timeline[0];ce&&(b.timeline=[{...ce,filters:I},...b.timeline.slice(1)])}return b}const Yr=b=>Array.isArray(b.timeline)?b.timeline.some(I=>Array.isArray(I.filters)&&I.filters.length>0):!1,Op=b=>{if(!b||typeof b!="object")return null;const I=b.posterFrame;if(typeof I!="string")return null;const Y=I.trim();return Y!==""?Y:null};async function qr(){const b=Eo(ic(wt())),I=oc(Ve.value),Y=Yr(b)||I.length>0,ce=Op(o.initialRecipe);if(Y){const xe=R.value>0?R.value:.1;try{const we=await Pp(xe);we?b.posterFrame=we:ce&&(b.posterFrame=ce)}catch{ce&&(b.posterFrame=ce)}}else delete b.posterFrame;return Et(),i("draft-saved",b),b}function rc(){he()&&(nn(),$n())}async function Up(b){ea();const I=_i();Ye=window.setInterval(async()=>{try{if(Xe){ea();return}const Y=await I.getJob(b),ce=Number(Y.progress??0);if(te.value=Number.isFinite(ce)?ce:0,Y.status==="completed"||Y.status==="failed"||Y.status==="cancelled")if(ea(),J.value=!1,Ue.value=null,Y.status==="completed")te.value=100,ve.value=!0,_e.value=null;else{const xe=Y.status==="cancelled"||typeof Y.error_message=="string"&&/cancel/i.test(Y.error_message);_e.value=xe?"Export canceled.":typeof Y.error_message=="string"&&Y.error_message.trim()!==""?Y.error_message:"Export failed"}}catch(Y){ea(),J.value=!1,Ue.value=null,_e.value=Y instanceof Error?Y.message:"Failed to check export progress"}},2e3)}function Qr(){const b=Eo(Ne());try{const I=b.timeline??[]}catch{}S.value=b}let va=null;function $n(){va&&clearTimeout(va),va=setTimeout(()=>{Qr(),va=null},200)}e.watch(()=>M.value,$n,{deep:!0}),e.watch(()=>ue.value,b=>{if(j.value||!b)return;const I=(b==null?void 0:b.filters)??[];qn(I)},{immediate:!0}),e.watch(()=>Ve.value,b=>{vt(b),$n()},{deep:!0}),e.watch(()=>A.value,b=>{bt(b),$n()},{deep:!0}),e.watch(()=>z.value,b=>{const I=b.map(Y=>({...Y,source:typeof Y.source=="string"?Y.source:void 0}));it(I),$n()},{deep:!0}),e.watch(()=>R.value,$n),n({saveDraft:qr,exportForUpload:Tp}),Qr(),e.onUnmounted(()=>{ea(),Xe=!0,Tn.cancelClientExport(),va&&(clearTimeout(va),va=null),v.value&&(v.value.destroy(),v.value=null),V.value=null,x.value=null,T.value=null});function zp(){Mt||!Wn.value||(Mt=new Kk({filters:kn.value,callbacks:{onApplyFilter:b=>{mn(b.id)},onRemoveFilter:b=>{da(b)},onUpdateParam:(b,I,Y)=>{Za(b,I,Y)},onPreviewFilter:b=>{ut(b.id)}}}),Mt.mount(Wn.value),Mt.setActiveFilters(rt.value))}e.watch(rt,b=>{Mt==null||Mt.setActiveFilters(b)},{deep:!0}),e.watch(kn,b=>{Mt==null||Mt.setFilters(b)});let ta=null;return e.onMounted(()=>{window.addEventListener("resize",L),window.addEventListener("keydown",F);const b=()=>{!_t.value||ta||(ta=new ResizeObserver(I=>{I[0]&&(gn.value=Math.round(I[0].contentRect.width))}),ta.observe(_t.value))};b(),ta||e.nextTick(b),l.value&&(Ct(),It||e.nextTick(Ct)),o.media&&Qr(),l.value&&e.nextTick(()=>{zp()}),e.nextTick(()=>{const I=document.querySelector(".video-editor");I&&I.getBoundingClientRect();const Y=document.querySelector(".mobile-layout");Y&&Y.getBoundingClientRect()})}),e.onUnmounted(()=>{window.removeEventListener("resize",L),window.removeEventListener("keydown",F),ta==null||ta.disconnect(),ta=null,It==null||It(),It=null,Mt==null||Mt.destroy(),Mt=null}),(b,I)=>{var Y,ce,xe,we;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-editor",{mobile:l.value}])},[l.value?(e.openBlock(),e.createElementBlock("div",px,[e.createElementVNode("div",fx,[e.createElementVNode("div",hx,[e.createElementVNode("button",{class:e.normalizeClass(["mobile-toolbar-btn",{active:e.unref(ae)}]),onClick:I[0]||(I[0]=(...ke)=>e.unref(Oe)&&e.unref(Oe)(...ke)),"aria-label":e.unref(ae)?"Pause":"Play","data-testid":"btn-mobile-play"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ae)?e.unref(ml):e.unref(pl)},null,8,["icon"])],10,vx),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:rc,"aria-label":"Reset all changes","data-testid":"btn-mobile-reset"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Fa)},null,8,["icon"])])]),e.createElementVNode("div",gx,[e.createElementVNode("button",{class:"mobile-toolbar-btn mobile-toolbar-save",onClick:qr,"aria-label":"Save","data-testid":"btn-mobile-save",disabled:!e.unref(ee)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(pr)},null,8,["icon"]),I[13]||(I[13]=e.createElementVNode("span",null,"Save",-1))],8,yx),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:I[1]||(I[1]=ke=>ec()),"aria-label":"Export","data-testid":"btn-mobile-export",disabled:J.value||!e.unref(ee)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ao)},null,8,["icon"])],8,bx),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:I[2]||(I[2]=ke=>i("close")),"aria-label":"Close","data-testid":"btn-mobile-close"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Na)},null,8,["icon"])])])]),e.createElementVNode("div",wx,[e.withDirectives(e.createVNode(Ss,{ref_key:"pixiPreviewMobileRef",ref:h,"aria-hidden":!p.value,class:"preview-host-child",source:hn.value,"fallback-duration":Jt.value,filters:an.value,playhead:on.value,"is-playing":e.unref(ae),"fit-mode":C.value,active:p.value,onPlayPause:e.unref(Oe),onFrameUpdate:gi,onDurationChange:ua},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,p.value]]),e.withDirectives(e.createVNode(Us,{"aria-hidden":!m.value,class:"preview-host-child","media-uuid":s.value,recipe:S.value,media:Mn.value,"enable-engine":m.value&>.value,"fit-mode":C.value,onTimeUpdate:Fn,onPlayStateChange:yo,onDurationChange:ua,onEngineReady:zt},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,m.value]]),J.value?(e.openBlock(),e.createElementBlock("div",kx,[e.createElementVNode("div",_x,[e.createElementVNode("span",null,"Exporting "+e.toDisplayString(te.value)+"%",1),e.createElementVNode("div",Ex,[e.createElementVNode("div",{class:"mobile-export-bar-fill",style:e.normalizeStyle({width:te.value+"%"})},null,4)]),e.createElementVNode("button",{class:"mobile-export-cancel",onClick:Ql},"Cancel")])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:_t,class:"timeline-section"},[e.createElementVNode("div",xx,[e.createElementVNode("button",{ref_key:"mobileZoomOutButtonRef",ref:vn,type:"button",class:"mobile-zoom-btn","aria-label":"Zoom out timeline","data-testid":"btn-timeline-zoom-out"},[...I[14]||(I[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:ft,type:"button",class:"mobile-zoom-btn","aria-label":"Zoom in timeline","data-testid":"btn-timeline-zoom-in"},[...I[15]||(I[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(zs,{playhead:e.unref(R),clips:e.unref(M),"selected-clip-id":((Y=e.unref(ue))==null?void 0:Y.id)??((ce=e.unref(M)[0])==null?void 0:ce.id)??null,duration:Jt.value,fps:e.unref(Be),"zoom-level":e.unref(de),"snap-enabled":Bn.value,sensitivity:.25,"is-mobile":!0,"onUpdate:playhead":e.unref(dt),onTrim:e.unref(fe),onSplit:_o,onClipSelect:ma,onClipMove:e.unref(ot),onClipLongPress:bo,onSnapStateChange:pa},null,8,["playhead","clips","selected-clip-id","duration","fps","zoom-level","snap-enabled","onUpdate:playhead","onTrim","onClipMove"])],512),e.createElementVNode("div",Sx,[e.createElementVNode("div",Cx,[e.createElementVNode("span",Vx,e.toDisplayString(ho.value),1),e.createElementVNode("span",Nx,e.toDisplayString(Ur.value),1)]),e.createElementVNode("div",Tx,[e.createElementVNode("button",{type:"button",class:"mobile-cut-nav-btn","data-testid":"btn-mobile-prev-cut","aria-label":"Jump to previous cut",disabled:!mi.value,onClick:ha}," Prev Cut ",8,Mx),e.createElementVNode("div",Bx,[e.createElementVNode("span",Ix,"Playhead "+e.toDisplayString(zr.value),1),e.createElementVNode("span",Fx,"In "+e.toDisplayString(vo.value),1),e.createElementVNode("span",$x,"Out "+e.toDisplayString(jr.value),1),e.createElementVNode("span",Dx,"Duration "+e.toDisplayString(Wr.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:!pi.value,onClick:bi}," Next Cut ",8,Rx)]),e.createElementVNode("div",Ax,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["mobile-snap-toggle",{active:Bn.value}]),"data-testid":"btn-mobile-snap-toggle",onClick:fa},e.toDisplayString(Bn.value?"Snap On":"Snap Off"),3),e.createElementVNode("div",Lx,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(Qn,ke=>e.createElementVNode("button",{key:ke,type:"button",class:e.normalizeClass(["mobile-speed-chip",{active:e.unref(ye)===ke}]),"data-testid":`btn-mobile-speed-${String(ke).replace(".","-")}`,onClick:at=>ki(ke)},e.toDisplayString(ke)+"x ",11,Px)),64))])]),e.createElementVNode("div",Ox,[e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-undo","aria-label":"Undo",disabled:!e.unref(oe),onClick:wo}," Undo ",8,Ux),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-redo","aria-label":"Redo",disabled:!e.unref(se),onClick:wi}," Redo ",8,zx),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-split","aria-label":"Split at playhead",disabled:!Ut.value,onClick:ko}," Split ",8,jx),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-duplicate","aria-label":"Duplicate selected clip",disabled:!La.value,onClick:Ha}," Duplicate ",8,Wx),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn mobile-edit-btn--danger","data-testid":"btn-mobile-delete","aria-label":"Delete selected clip",disabled:!jn.value,onClick:Xa}," Delete ",8,Zx)])]),e.createElementVNode("div",{ref_key:"mobileControlsRef",ref:Wn,class:"controls-section mobile-controls"},null,512),Oa.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"mobile-action-sheet-backdrop","data-testid":"video-mobile-action-sheet",onClick:xn},[e.createElementVNode("div",{class:"mobile-action-sheet",onClick:I[3]||(I[3]=e.withModifiers(()=>{},["stop"]))},[I[16]||(I[16]=e.createElementVNode("div",{class:"mobile-action-sheet-handle"},null,-1)),e.createElementVNode("div",Hx,[e.createElementVNode("span",Xx,e.toDisplayString(za.value),1),e.createElementVNode("span",Gx,e.toDisplayString(Zr.value),1)]),e.createElementVNode("div",Jx,[e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-undo",disabled:!e.unref(oe),onClick:wo},"Undo",8,Kx),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-redo",disabled:!e.unref(se),onClick:wi},"Redo",8,Yx),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-split",disabled:!Ut.value,onClick:ko},"Split",8,qx),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-duplicate",disabled:!La.value,onClick:Ha},"Duplicate",8,Qx),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn mobile-action-sheet-btn--danger","data-testid":"btn-mobile-sheet-delete",disabled:!jn.value,onClick:Xa},"Delete",8,eS),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-close",onClick:xn},"Close")])])])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",tS,[e.createElementVNode("div",nS,[e.createElementVNode("div",aS,[e.createElementVNode("div",oS,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":I[4]||(I[4]=ke=>C.value=ke),"aria-label":"Fit mode","data-testid":"select-video-fit-mode"},[...I[17]||(I[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,C.value]])])]),e.withDirectives(e.createVNode(Ss,{ref_key:"pixiPreviewDesktopRef",ref:g,"aria-hidden":!p.value,class:"preview-host-child",source:hn.value,"fallback-duration":Jt.value,filters:an.value,playhead:on.value,"is-playing":e.unref(ae),"fit-mode":C.value,active:p.value,onPlayPause:e.unref(Oe),onFrameUpdate:gi,onDurationChange:ua},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,p.value]]),e.withDirectives(e.createVNode(Us,{"aria-hidden":!m.value,class:"preview-host-child","media-uuid":s.value,recipe:S.value,media:Mn.value,"enable-engine":m.value&>.value,"fit-mode":C.value,onTimeUpdate:Fn,onPlayStateChange:yo,onDurationChange:ua,onEngineReady:zt},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,m.value]]),b.showThumbnailPicker?(e.openBlock(),e.createBlock(Vw,{key:0,"media-uuid":s.value,duration:Jt.value,onSelect:Sp},null,8,["media-uuid","duration"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",iS,[e.createElementVNode("div",rS,[e.createElementVNode("div",sS,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(G.value,ke=>(e.openBlock(),e.createElementBlock("button",{key:ke.id,class:e.normalizeClass(["tab-btn",{active:d.value===ke.id}]),onClick:at=>d.value=ke.id},e.toDisplayString(ke.label),11,lS))),128))]),e.createElementVNode("div",cS,[e.withDirectives(e.createElementVNode("div",dS,[e.createVNode(Ws,{filters:kn.value,"active-filters":rt.value,"thumbnail-url":_n.value,onApplyFilter:mn,onRemoveFilter:da,onUpdateParam:Za,onPreviewFilter:Ga},null,8,["filters","active-filters","thumbnail-url"])],512),[[e.vShow,d.value==="filters"]]),e.withDirectives(e.createElementVNode("div",uS,[e.createVNode(Xs,{overlays:A.value,onAddOverlay:pp,onUpdateOverlay:fp,onRemoveOverlay:hp},null,8,["overlays"])],512),[[e.vShow,d.value==="text"]]),e.withDirectives(e.createElementVNode("div",mS,[e.createVNode(Gs,{"selected-clips":P.value,"applied-transitions":N.value,onApplyTransition:vp,onRemoveTransition:gp,onPreviewTransition:yp},null,8,["selected-clips","applied-transitions"])],512),[[e.vShow,d.value==="transitions"]]),e.withDirectives(e.createElementVNode("div",pS,[e.createVNode(Js,{"audio-layers":z.value,"master-volume":B.value,onAddTrack:bp,onUpdateTrack:wp,onRemoveTrack:kp,onUpdateVolume:_p,onToggleMute:Ep,onUpdateMasterVolume:xp},null,8,["audio-layers","master-volume"])],512),[[e.vShow,d.value==="audio"]]),e.withDirectives(e.createElementVNode("div",fS,[e.unref(Je)?(e.openBlock(),e.createBlock(Zs,{key:0,filter:e.unref(Je),"current-frame":e.unref(ie),onUpdateParams:mp},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",hS,[...I[18]||(I[18]=[e.createElementVNode("p",null,"Select a filter from the Filters tab to adjust its parameters",-1)])]))],512),[[e.vShow,d.value==="adjustments"]]),e.withDirectives(e.createElementVNode("div",vS,[e.createVNode(Hs,{"can-export":e.unref(ee),"is-exporting":J.value,"export-progress":te.value,onExport:ec,onCancelExport:Ql,onSaveDraft:qr,onReset:rc},null,8,["can-export","is-exporting","export-progress"]),ve.value?(e.openBlock(),e.createElementBlock("div",gS," Export complete ")):e.createCommentVNode("",!0),_e.value&&!ve.value?(e.openBlock(),e.createElementBlock("div",yS,e.toDisplayString(_e.value),1)):e.createCommentVNode("",!0)],512),[[e.vShow,d.value==="export"]])])])])]),e.createElementVNode("div",bS,[e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:_t,class:"timeline-container"},[e.createElementVNode("div",wS,[e.createElementVNode("label",null,[I[19]||(I[19]=e.createTextVNode(" Zoom ",-1)),e.createElementVNode("input",{type:"range",min:"10",max:"600",value:e.unref(de),onInput:I[5]||(I[5]=ke=>Ge(ke))},null,40,kS)]),e.createElementVNode("span",_S,e.toDisplayString(Math.round(e.unref(de)))+" px/s",1),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["desktop-snap-toggle",{active:Bn.value}]),"data-testid":"btn-desktop-snap-toggle",onClick:fa},e.toDisplayString(Bn.value?"Snap On":"Snap Off"),3)]),e.createVNode(zs,{playhead:e.unref(R),clips:e.unref(M),"selected-clip-id":((xe=e.unref(ue))==null?void 0:xe.id)??((we=e.unref(M)[0])==null?void 0:we.id)??null,duration:Jt.value,fps:e.unref(Be),"zoom-level":e.unref(de),"snap-enabled":Bn.value,sensitivity:.25,"onUpdate:playhead":e.unref(dt),onTrim:e.unref(fe),onSplit:_o,onClipSelect:ma,onClipMove:e.unref(ot),onClipLongPress:bo,onSnapStateChange:pa},null,8,["playhead","clips","selected-clip-id","duration","fps","zoom-level","snap-enabled","onUpdate:playhead","onTrim","onClipMove"]),e.createVNode(js,{"selected-clip":e.unref(ue),"can-split":Ut.value,"can-delete":jn.value,"is-playing":e.unref(ae),"zoom-level":e.unref(de),"playback-speed":e.unref(ye),onSplit:ko,onDelete:Xa,onDuplicate:Ha,onZoomIn:Ae,onZoomOut:De,onZoomChange:me,onFitToWindow:Q,onPlayPause:e.unref(Oe),onFrameForward:e.unref(Pt),onFrameBackward:e.unref(Rt),onSkipToStart:e.unref(Ot),onSkipToEnd:e.unref(tn),onSpeedChange:e.unref(zn)},null,8,["selected-clip","can-split","can-delete","is-playing","zoom-level","playback-speed","onPlayPause","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"]),be.value?(e.openBlock(),e.createElementBlock("div",ES,[e.createElementVNode("div",xS,[e.createElementVNode("label",SS,[I[20]||(I[20]=e.createElementVNode("span",null,"Trim start (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":I[6]||(I[6]=ke=>pn.value=ke),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-start"},null,512),[[e.vModelText,pn.value]])]),e.createElementVNode("label",CS,[I[21]||(I[21]=e.createElementVNode("span",null,"Trim end (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":I[7]||(I[7]=ke=>fn.value=ke),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-end"},null,512),[[e.vModelText,fn.value]])]),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-start-playhead",disabled:!e.unref(ue),onClick:I[8]||(I[8]=ke=>Kt("start"))}," Start = Playhead ",8,VS),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-end-playhead",disabled:!e.unref(ue),onClick:I[9]||(I[9]=ke=>Kt("end"))}," End = Playhead ",8,NS),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-trim",disabled:!e.unref(ue),onClick:Hr}," Apply Trim ",8,TS)]),e.createElementVNode("div",MS,[e.createElementVNode("label",BS,[I[22]||(I[22]=e.createElementVNode("span",null,"Quick filter",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":I[10]||(I[10]=ke=>W.value=ke),"data-testid":"video-dev-filter-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(kn.value,ke=>(e.openBlock(),e.createElementBlock("option",{key:ke.id,value:ke.id},e.toDisplayString(ke.name),9,IS))),128))],512),[[e.vModelSelect,W.value]])]),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-filter",disabled:!e.unref(ue)||W.value==="",onClick:Xr}," Apply Filter ",8,FS),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-clear-filters",disabled:e.unref(Ve).length===0,onClick:Wa}," Clear Filters ",8,$S),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(ue),onClick:I[11]||(I[11]=ke=>mn("noise"))}," QA: Noise ",8,DS),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(ue),onClick:I[12]||(I[12]=ke=>mn("grayscale"))}," QA: Grayscale ",8,RS)])])):e.createCommentVNode("",!0)],512)])]))],2)}}}),Lm=Me(AS,[["__scopeId","data-v-1bb4247b"]]),LS={key:0,class:"video-editor-v2-toolbar"},PS={class:"video-editor-v2-body"},OS={key:0,class:"video-editor-v2-assets","data-testid":"v2-assets-panel"},US={class:"video-editor-v2-main"},zS={class:"video-editor-v2-canvas"},jS={key:1,class:"video-editor-v2-timeline"},WS=["aria-expanded"],ZS=["aria-hidden","inert"],HS="(max-width: 900px)",XS=e.defineComponent({__name:"SplitPanelLayout",setup(a,{expose:n}){const t=e.ref(!1),o=e.ref(!1);let i=null,r=null;const s=d=>{t.value=d,d&&(o.value=!1)},l=()=>{o.value=!0},c=()=>{o.value=!1};return e.onMounted(()=>{typeof window>"u"||!window.matchMedia||(i=window.matchMedia(HS),s(i.matches),r=d=>s(d.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)}),n({isMobile:t}),(d,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"},[d.$slots.toolbar?(e.openBlock(),e.createElementBlock("div",LS,[e.renderSlot(d.$slots,"toolbar",{},void 0,!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",PS,[!t.value&&d.$slots.assets?(e.openBlock(),e.createElementBlock("aside",OS,[e.renderSlot(d.$slots,"assets",{},void 0,!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",US,[e.createElementVNode("div",zS,[e.renderSlot(d.$slots,"canvas",{},void 0,!0)])])]),d.$slots.timeline?(e.openBlock(),e.createElementBlock("div",jS,[e.renderSlot(d.$slots,"timeline",{isMobile:t.value},void 0,!0)])):e.createCommentVNode("",!0),!t.value&&d.$slots.inspector?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[o.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":o.value?"true":"false",onClick:l}," Tools ",8,WS)),o.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"video-editor-v2-drawer-backdrop","data-testid":"v2-tools-drawer-backdrop",onClick:c})):e.createCommentVNode("",!0),e.createElementVNode("aside",{id:"v2-editor-tools-drawer",class:e.normalizeClass(["video-editor-v2-side",{"is-open":o.value}]),"data-testid":"v2-side-panel","aria-hidden":o.value?"false":"true",inert:!o.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:c}," x ")]),e.renderSlot(d.$slots,"inspector",{},void 0,!0)],10,ZS)],64)):e.createCommentVNode("",!0),t.value?e.renderSlot(d.$slots,"drawer",{key:3},void 0,!0):e.createCommentVNode("",!0)],2))}}),GS=Me(XS,[["__scopeId","data-v-aaf8ad3f"]]),JS=["aria-selected"],KS={class:"asset-rail-item__main"},YS={class:"asset-rail-item__type","data-testid":"asset-rail-item-type"},qS={class:"asset-rail-item__label","data-testid":"asset-rail-item-label"},QS={key:0,class:"asset-rail-item__details","data-testid":"asset-rail-item-details"},eC={class:"asset-rail-item__actions","aria-label":"Asset actions"},tC=e.defineComponent({__name:"AssetRailItem",props:{source:{},selected:{type:Boolean}},emits:["add","replaceSelected","remove"],setup(a,{emit:n}){const t=a,o=n,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 d=Math.max(0,Math.round(t.source.duration)),u=Math.floor(d/60),f=d%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(d=>d!==null)),c=d=>{if(d==="add"){o("add",t.source.id);return}if(d==="replaceSelected"){o("replaceSelected",t.source.id);return}o("remove",t.source.id)};return(d,u)=>(e.openBlock(),e.createElementBlock("article",{class:e.normalizeClass(["asset-rail-item",{"is-selected":d.selected}]),"aria-selected":d.selected?"true":"false","data-testid":"asset-rail-item"},[e.createElementVNode("div",KS,[e.createElementVNode("span",YS,e.toDisplayString(d.source.type),1),e.createElementVNode("span",qS,e.toDisplayString(i.value),1),l.value.length>0?(e.openBlock(),e.createElementBlock("span",QS,e.toDisplayString(l.value.join(" / ")),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",eC,[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=>c("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=>c("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=>c("remove"))}," - ")])],10,JS))}}),nC=Me(tC,[["__scopeId","data-v-3ba2fd25"]]),aC={class:"asset-rail","aria-label":"Assets","data-testid":"asset-rail"},oC={key:0,class:"asset-rail__list","data-testid":"asset-rail-list"},iC={key:1,class:"asset-rail__empty","data-testid":"asset-rail-empty"},rC=e.defineComponent({__name:"AssetRail",props:{sources:{},selectedSourceId:{}},emits:["add","replaceSelected","remove"],setup(a,{emit:n}){const t=n,o=(i,r)=>{if(i==="add"){t("add",r);return}if(i==="replaceSelected"){t("replaceSelected",r);return}t("remove",r)};return(i,r)=>(e.openBlock(),e.createElementBlock("section",aC,[r[3]||(r[3]=e.createElementVNode("div",{class:"asset-rail__header"},[e.createElementVNode("h2",{class:"asset-rail__title"},"Assets")],-1)),i.sources.length>0?(e.openBlock(),e.createElementBlock("div",oC,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.sources,s=>(e.openBlock(),e.createBlock(nC,{key:s.id,source:s,selected:s.id===i.selectedSourceId,onAdd:r[0]||(r[0]=l=>o("add",l)),onReplaceSelected:r[1]||(r[1]=l=>o("replaceSelected",l)),onRemove:r[2]||(r[2]=l=>o("remove",l))},null,8,["source","selected"]))),128))])):(e.openBlock(),e.createElementBlock("p",iC,"No assets"))]))}}),sC=Me(rC,[["__scopeId","data-v-db305224"]]),lC={class:"audio-mixer-panel__tracks","data-testid":"audio-mixer-tracks"},cC={key:0,class:"audio-mixer-panel__empty","data-testid":"audio-mixer-empty"},dC=["data-testid"],uC={class:"audio-mixer-strip__header"},mC={class:"audio-mixer-strip__identity"},pC={class:"audio-mixer-strip__kind"},fC=["data-testid"],hC=["data-testid"],vC=["data-testid"],gC={class:"audio-mixer-meter__rail","aria-hidden":"true"},yC={class:"audio-mixer-meter__value"},bC={class:"audio-mixer-strip__controls"},wC=["for"],kC=["id","min","max","value","data-testid","onInput"],_C={class:"audio-mixer-control__value"},EC={class:"audio-mixer-buttons"},xC=["aria-pressed","aria-label","data-testid","onClick"],SC=["aria-pressed","aria-label","data-testid","onClick"],CC=["for"],VC=["id","value","data-testid","onInput"],NC={class:"audio-mixer-control__value"},TC=["data-testid"],MC={key:0},BC={key:1},IC=["data-testid"],FC=["data-testid"],$C=["data-testid"],DC={class:"audio-mixer-routing__target"},RC={class:"audio-mixer-strip__header"},AC={class:"audio-mixer-strip__identity"},LC={class:"audio-mixer-strip__name","data-testid":"audio-mixer-master-name"},PC={class:"audio-mixer-meter__rail","aria-hidden":"true"},OC={class:"audio-mixer-meter__value"},UC={class:"audio-mixer-strip__controls"},zC={key:0,class:"audio-mixer-control audio-mixer-control--fader",for:"audio-mixer-master-fader"},jC=["min","max","value"],WC={class:"audio-mixer-control__value"},ZC={class:"audio-mixer-buttons"},HC=["aria-pressed","aria-label"],XC={key:1,class:"audio-mixer-effects","data-testid":"audio-mixer-master-effects"},GC=["data-testid"],JC=e.defineComponent({__name:"AudioMixerPanel",props:{state:{},deviceClass:{}},emits:["update"],setup(a,{emit:n}){const t=a,o=n,i=e.computed(()=>T2(t.deviceClass,t.state.capabilities)),r=e.computed(()=>t.deviceClass==="desktop"),s=e.computed(()=>[...t.state.tracks].sort((B,L)=>B.order-L.order)),l=e.computed(()=>{const B=new Map(M2(s.value,t.state.master.muted).map(L=>[L.trackId,L]));return s.value.map(L=>({track:L,effectiveState:B.get(L.id)??null}))}),c=e.computed(()=>i.value.canAdjustTrackFaders),d=e.computed(()=>i.value.canAdjustMasterFader),u=e.computed(()=>i.value.canMuteTracks),f=e.computed(()=>r.value&&i.value.canSoloTracks),p=e.computed(()=>r.value&&i.value.canAdjustPan),m=e.computed(()=>i.value.canViewMeters&&i.value.meterMode!=="off"),h=e.computed(()=>r.value&&i.value.canEditEffectSlots&&i.value.maxEffectSlots>0),g=e.computed(()=>r.value&&i.value.canEditRouting),k=B=>{if(!(B.target instanceof HTMLInputElement))return null;const L=Number(B.target.value);return Number.isFinite(L)?L:null},$=(B,L)=>{if(!c.value)return;const w=k(L);w!==null&&o("update",{type:"track-fader-db",trackId:B.id,valueDb:Ko(w)})},D=B=>{u.value&&o("update",{type:"track-mute",trackId:B.id,muted:!B.controls.muted})},_=B=>{f.value&&o("update",{type:"track-solo",trackId:B.id,solo:!B.controls.solo})},v=(B,L)=>{if(!p.value)return;const w=k(L);w!==null&&o("update",{type:"track-pan",trackId:B.id,pan:Yu(w)})},S=B=>{if(!d.value)return;const L=k(B);L!==null&&o("update",{type:"master-fader-db",valueDb:Ko(L)})},C=B=>{u.value&&o("update",{type:"master-mute",muted:!B.muted})},V=B=>{const L=Math.round(B*10)/10;return L>0?`+${L.toFixed(L%1===0?0:1)} dB`:`${L.toFixed(L%1===0?0:1)} dB`},x=B=>B===0?"C":`${B<0?"L":"R"} ${Math.round(Math.abs(B)*100)}`,T=B=>{if(B===void 0)return"";const L=Math.round(B*10)/10;return`${L.toFixed(L%1===0?0:1)}s`},j=B=>V(B),E=B=>{if(!Number.isFinite(B))return 0;const L=Math.min(sr,Math.max(sa,B)),w=sr-sa;return Math.round((L-sa)/w*100)},A=B=>B.slice(0,i.value.maxEffectSlots),N=B=>h.value&&A(B).length>0,z=B=>B.timeline.fadeIn!==void 0||B.timeline.fadeOut!==void 0,P=B=>B===null?"Unknown":B.mutedByMaster?"Master muted":B.mutedByTrack?"Muted":B.mutedBySolo?"Muted by solo":B.soloed?"Solo active":"Audible";return(B,L)=>(e.openBlock(),e.createElementBlock("section",{class:e.normalizeClass(["audio-mixer-panel",`audio-mixer-panel--${B.deviceClass}`]),"data-testid":"audio-mixer-panel","aria-label":"Audio mixer"},[e.createElementVNode("div",lC,[l.value.length===0?(e.openBlock(),e.createElementBlock("p",cC," No audio tracks ")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,({track:w,effectiveState:O})=>(e.openBlock(),e.createElementBlock("article",{key:w.id,class:e.normalizeClass(["audio-mixer-strip",{"is-muted":(O==null?void 0:O.effectivelyMuted)===!0,"is-soloed":w.controls.solo}]),"data-testid":`audio-mixer-track-${w.id}`},[e.createElementVNode("header",uC,[e.createElementVNode("div",mC,[e.createElementVNode("span",pC,e.toDisplayString(w.kind),1),e.createElementVNode("h3",{class:"audio-mixer-strip__name","data-testid":`audio-mixer-track-name-${w.id}`},e.toDisplayString(w.name),9,fC)]),e.createElementVNode("span",{class:e.normalizeClass(["audio-mixer-strip__status",{"is-active":(O==null?void 0:O.audible)===!0}]),"data-testid":`audio-mixer-track-status-${w.id}`},e.toDisplayString(P(O)),11,hC)]),m.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["audio-mixer-meter",{"is-clipping":w.controls.meter.clipping}]),"data-testid":`audio-mixer-track-meter-${w.id}`,"aria-label":"Track meter"},[e.createElementVNode("span",gC,[e.createElementVNode("span",{class:"audio-mixer-meter__fill",style:e.normalizeStyle({width:`${E(w.controls.meter.peakDb)}%`})},null,4)]),e.createElementVNode("span",yC,e.toDisplayString(j(w.controls.meter.peakDb)),1)],10,vC)):e.createCommentVNode("",!0),e.createElementVNode("div",bC,[c.value?(e.openBlock(),e.createElementBlock("label",{key:0,class:"audio-mixer-control audio-mixer-control--fader",for:`audio-mixer-track-fader-${w.id}`},[L[2]||(L[2]=e.createElementVNode("span",{class:"audio-mixer-control__label"},"Level",-1)),e.createElementVNode("input",{id:`audio-mixer-track-fader-${w.id}`,type:"range",class:"audio-mixer-control__range",min:w.controls.fader.minDb,max:w.controls.fader.maxDb,value:w.controls.fader.valueDb,step:"0.5","data-testid":`audio-mixer-track-fader-${w.id}`,onInput:Z=>$(w,Z)},null,40,kC),e.createElementVNode("span",_C,e.toDisplayString(V(w.controls.fader.valueDb)),1)],8,wC)):e.createCommentVNode("",!0),e.createElementVNode("div",EC,[u.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["audio-mixer-button",{"is-active":w.controls.muted}]),"aria-pressed":w.controls.muted?"true":"false","aria-label":w.controls.muted?`Unmute ${w.name}`:`Mute ${w.name}`,"data-testid":`audio-mixer-track-mute-${w.id}`,onClick:Z=>D(w)}," M ",10,xC)):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":w.controls.solo}]),"aria-pressed":w.controls.solo?"true":"false","aria-label":w.controls.solo?`Clear solo on ${w.name}`:`Solo ${w.name}`,"data-testid":`audio-mixer-track-solo-${w.id}`,onClick:Z=>_(w)}," S ",10,SC)):e.createCommentVNode("",!0)])]),p.value?(e.openBlock(),e.createElementBlock("label",{key:1,class:"audio-mixer-control audio-mixer-control--pan",for:`audio-mixer-track-pan-${w.id}`},[L[3]||(L[3]=e.createElementVNode("span",{class:"audio-mixer-control__label"},"Pan",-1)),e.createElementVNode("input",{id:`audio-mixer-track-pan-${w.id}`,type:"range",class:"audio-mixer-control__range",min:"-1",max:"1",step:"0.01",value:w.controls.pan.value,"data-testid":`audio-mixer-track-pan-${w.id}`,onInput:Z=>v(w,Z)},null,40,VC),e.createElementVNode("span",NC,e.toDisplayString(x(w.controls.pan.value)),1)],8,CC)):e.createCommentVNode("",!0),z(w)?(e.openBlock(),e.createElementBlock("div",{key:2,class:"audio-mixer-strip__fades","data-testid":`audio-mixer-track-fades-${w.id}`},[w.timeline.fadeIn!==void 0?(e.openBlock(),e.createElementBlock("span",MC," In "+e.toDisplayString(T(w.timeline.fadeIn)),1)):e.createCommentVNode("",!0),w.timeline.fadeOut!==void 0?(e.openBlock(),e.createElementBlock("span",BC," Out "+e.toDisplayString(T(w.timeline.fadeOut)),1)):e.createCommentVNode("",!0)],8,TC)):e.createCommentVNode("",!0),N(w.effectSlots)?(e.openBlock(),e.createElementBlock("div",{key:3,class:"audio-mixer-effects","data-testid":`audio-mixer-track-effects-${w.id}`},[L[4]||(L[4]=e.createElementVNode("span",{class:"audio-mixer-effects__label"},"FX",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(A(w.effectSlots),Z=>(e.openBlock(),e.createElementBlock("span",{key:Z.id,class:e.normalizeClass(["audio-mixer-effect",{"is-empty":Z.kind==="empty","is-bypassed":Z.bypassed,"is-enabled":Z.enabled&&!Z.bypassed}]),"data-testid":`audio-mixer-track-effect-${w.id}-${Z.index}`},e.toDisplayString(Z.label),11,FC))),128))],8,IC)):e.createCommentVNode("",!0),g.value?(e.openBlock(),e.createElementBlock("div",{key:4,class:"audio-mixer-routing","data-testid":`audio-mixer-track-routing-${w.id}`},[L[5]||(L[5]=e.createElementVNode("span",{class:"audio-mixer-routing__label"},"Route",-1)),e.createElementVNode("span",DC,e.toDisplayString(B.state.master.name),1)],8,$C)):e.createCommentVNode("",!0)],10,dC))),128))]),e.createElementVNode("article",{class:e.normalizeClass(["audio-mixer-strip audio-mixer-strip--master",{"is-muted":B.state.master.muted}]),"data-testid":"audio-mixer-master-strip"},[e.createElementVNode("header",RC,[e.createElementVNode("div",AC,[L[6]||(L[6]=e.createElementVNode("span",{class:"audio-mixer-strip__kind"},"master",-1)),e.createElementVNode("h3",LC,e.toDisplayString(B.state.master.name),1)]),e.createElementVNode("span",{class:e.normalizeClass(["audio-mixer-strip__status",{"is-active":!B.state.master.muted}]),"data-testid":"audio-mixer-master-status"},e.toDisplayString(B.state.master.muted?"Muted":"Active"),3)]),m.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["audio-mixer-meter",{"is-clipping":B.state.master.meter.clipping}]),"data-testid":"audio-mixer-master-meter","aria-label":"Master meter"},[e.createElementVNode("span",PC,[e.createElementVNode("span",{class:"audio-mixer-meter__fill",style:e.normalizeStyle({width:`${E(B.state.master.meter.peakDb)}%`})},null,4)]),e.createElementVNode("span",OC,e.toDisplayString(j(B.state.master.meter.peakDb)),1)],2)):e.createCommentVNode("",!0),e.createElementVNode("div",UC,[d.value?(e.openBlock(),e.createElementBlock("label",zC,[L[7]||(L[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:B.state.master.fader.minDb,max:B.state.master.fader.maxDb,value:B.state.master.fader.valueDb,step:"0.5","data-testid":"audio-mixer-master-fader",onInput:L[0]||(L[0]=w=>S(w))},null,40,jC),e.createElementVNode("span",WC,e.toDisplayString(V(B.state.master.fader.valueDb)),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",ZC,[u.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["audio-mixer-button",{"is-active":B.state.master.muted}]),"aria-pressed":B.state.master.muted?"true":"false","aria-label":B.state.master.muted?`Unmute ${B.state.master.name}`:`Mute ${B.state.master.name}`,"data-testid":"audio-mixer-master-mute",onClick:L[1]||(L[1]=w=>C(B.state.master))}," M ",10,HC)):e.createCommentVNode("",!0)])]),N(B.state.master.effectSlots)?(e.openBlock(),e.createElementBlock("div",XC,[L[8]||(L[8]=e.createElementVNode("span",{class:"audio-mixer-effects__label"},"FX",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(A(B.state.master.effectSlots),w=>(e.openBlock(),e.createElementBlock("span",{key:w.id,class:e.normalizeClass(["audio-mixer-effect",{"is-empty":w.kind==="empty","is-bypassed":w.bypassed,"is-enabled":w.enabled&&!w.bypassed}]),"data-testid":`audio-mixer-master-effect-${w.index}`},e.toDisplayString(w.label),11,GC))),128))])):e.createCommentVNode("",!0)],2)],2))}}),gd=Me(JC,[["__scopeId","data-v-e5c785e8"]]),KC={class:"caption-srt-panel__header"},YC={class:"caption-srt-panel__title-group"},qC={class:"caption-srt-panel__title"},QC=["id"],eV={key:0,class:"caption-srt-panel__stats","data-testid":"caption-srt-desktop-stats"},tV={key:0,class:"caption-srt-panel__desktop-controls","data-testid":"caption-srt-desktop-controls"},nV={class:"caption-srt-panel__field"},aV={class:"caption-srt-panel__field"},oV=["for"],iV=["id","aria-describedby","aria-invalid"],rV=["id"],sV=["id"],lV={key:3,class:"caption-srt-panel__cue-summary","data-testid":"caption-srt-cue-summary","aria-label":"Current caption cue summary"},cV={key:0,class:"caption-srt-panel__cue-list"},dV={class:"caption-srt-panel__cue-time"},uV={class:"caption-srt-panel__cue-text"},mV={key:1,class:"caption-srt-panel__empty"},pV=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(a,{emit:n}){const t=a,o=n,i=e.ref(""),r=e.ref(null),s=e.ref(null),l=e.ref(""),c=e.ref(""),d=e.ref(!1),u=e.computed(()=>t.layout==="mobile"),f=e.computed(()=>`${t.panelId}-textarea`),p=e.computed(()=>`${t.panelId}-helper`),m=e.computed(()=>`${t.panelId}-error`),h=e.computed(()=>`${t.panelId}-status`),g=e.computed(()=>{const N=[p.value,h.value];return r.value!==null&&N.push(m.value),N.join(" ")}),k=e.computed(()=>t.captionTrack!==null?t.captionTrack.segments:t.segments??[]),$=e.computed(()=>{try{return{text:qc(k.value),errorMessage:null}}catch(N){return{text:"",errorMessage:j(N)}}}),D=e.computed(()=>k.value.length),_=e.computed(()=>k.value.reduce((N,z)=>Math.max(N,z.endTime),0)),v=e.computed(()=>k.value.slice(0,5));e.watch(()=>{var N,z;return[(N=t.captionTrack)==null?void 0:N.id,(z=t.captionTrack)==null?void 0:z.language,t.trackId]},([N,z,P])=>{l.value=N??P,c.value=z??""},{immediate:!0}),e.watch($,N=>{if(N.errorMessage!==null){r.value=N.errorMessage;return}d.value||(i.value=N.text)},{immediate:!0});const S=()=>{d.value=!0,s.value=null,r.value!==null&&(r.value=null)},C=()=>{const N=i.value;if(r.value=null,s.value=null,N.trim()===""){r.value="Paste SRT text before importing captions.";return}try{const z=K2(N,{idPrefix:t.idPrefix}),P=m_(T(z)),B=qc(P.segments);i.value=B,d.value=!1,s.value=`Imported ${E(P.segments.length)}.`,o("update:captionTrack",P),o("update:segments",P.segments),o("import",{track:P,segments:P.segments,sourceText:N})}catch(z){r.value=j(z)}},V=()=>{const N=$.value;if(r.value=N.errorMessage,N.errorMessage!==null){s.value=null;return}i.value=N.text,d.value=!1,s.value=N.text===""?"No captions to export.":`Exported ${E(D.value)}.`,o("export",N.text)},x=()=>{i.value="",d.value=!0,r.value=null,s.value="SRT text cleared.",o("clear")};function T(N){var B,L;const z={id:l.value.trim(),source:"srt-import",stylePreset:((B=t.captionTrack)==null?void 0:B.stylePreset)??"default",animation:((L=t.captionTrack)==null?void 0:L.animation)??"none",segments:N},P=c.value.trim();return P!==""&&(z.language=P),z}function j(N){return N instanceof la||N instanceof Error?N.message:"Unable to process SRT captions."}function E(N){return N===1?"1 cue":`${N} cues`}function A(N){const z=Math.floor(N/60),P=Math.floor(N%60);return`${z}:${P.toString().padStart(2,"0")}`}return(N,z)=>(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",KC,[e.createElementVNode("div",YC,[e.createElementVNode("h2",qC,e.toDisplayString(N.title),1),e.createElementVNode("p",{id:p.value,class:"caption-srt-panel__helper"}," Paste SRT, import it as captions, or export the current caption track. ",8,QC)]),u.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",eV,[e.createElementVNode("span",null,e.toDisplayString(E(D.value)),1),e.createElementVNode("span",null,e.toDisplayString(A(_.value)),1)]))]),u.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",tV,[e.createElementVNode("label",nV,[z[3]||(z[3]=e.createElementVNode("span",null,"Track ID",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":z[0]||(z[0]=P=>l.value=P),class:"caption-srt-panel__input",type:"text",autocomplete:"off","data-testid":"caption-srt-track-id"},null,512),[[e.vModelText,l.value]])]),e.createElementVNode("label",aV,[z[4]||(z[4]=e.createElementVNode("span",null,"Language",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":z[1]||(z[1]=P=>c.value=P),class:"caption-srt-panel__input",type:"text",autocomplete:"off",placeholder:"en","data-testid":"caption-srt-language"},null,512),[[e.vModelText,c.value]])])])),e.createElementVNode("label",{class:"caption-srt-panel__textarea-label",for:f.value},e.toDisplayString(N.textareaLabel),9,oV),e.withDirectives(e.createElementVNode("textarea",{id:f.value,"onUpdate:modelValue":z[2]||(z[2]=P=>i.value=P),class:e.normalizeClass(["caption-srt-panel__textarea",{"has-error":r.value!==null}]),spellcheck:"false","aria-describedby":g.value,"aria-invalid":r.value!==null?"true":"false","data-testid":"caption-srt-textarea",onInput:S},null,42,iV),[[e.vModelText,i.value]]),r.value!==null?(e.openBlock(),e.createElementBlock("p",{key:1,id:m.value,class:"caption-srt-panel__error",role:"alert","data-testid":"caption-srt-error"},e.toDisplayString(r.value),9,rV)):(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,sV)),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:C}," Import "),e.createElementVNode("button",{type:"button",class:"caption-srt-panel__button","data-testid":"caption-srt-export",onClick:V}," 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",lV,[z[5]||(z[5]=e.createElementVNode("p",{class:"caption-srt-panel__cue-summary-title"},"Cue summary",-1)),v.value.length>0?(e.openBlock(),e.createElementBlock("ol",cV,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,P=>(e.openBlock(),e.createElementBlock("li",{key:P.id,class:"caption-srt-panel__cue"},[e.createElementVNode("span",dV,e.toDisplayString(A(P.startTime))+"-"+e.toDisplayString(A(P.endTime)),1),e.createElementVNode("span",uV,e.toDisplayString(P.text),1)]))),128))])):(e.openBlock(),e.createElementBlock("p",mV," No captions loaded. "))]))],2))}}),yd=Me(pV,[["__scopeId","data-v-1d5fdb3b"]]),fV=["aria-label"],hV={class:"draft-recovery-banner__header"},vV={class:"draft-recovery-banner__heading"},gV={class:"draft-recovery-banner__title"},yV={class:"draft-recovery-banner__summary","data-testid":"draft-recovery-summary"},bV={key:0,class:"draft-recovery-banner__list","data-testid":"draft-recovery-list"},wV={class:"draft-recovery-banner__record-copy"},kV={class:"draft-recovery-banner__record-title","data-testid":"draft-recovery-record-title"},_V={class:"draft-recovery-banner__record-meta"},EV={"data-testid":"draft-recovery-record-updated"},xV={"data-testid":"draft-recovery-record-reason"},SV={class:"draft-recovery-banner__actions"},CV=["onClick"],VV=["onClick"],NV={key:1,class:"draft-recovery-banner__mobile-prompt","data-testid":"draft-recovery-mobile-prompt"},TV={class:"draft-recovery-banner__record-copy"},MV={class:"draft-recovery-banner__record-title","data-testid":"draft-recovery-record-title"},BV={class:"draft-recovery-banner__record-meta"},IV={"data-testid":"draft-recovery-record-updated"},FV={"data-testid":"draft-recovery-record-reason"},$V={class:"draft-recovery-banner__actions draft-recovery-banner__actions--mobile"},DV={key:2,class:"draft-recovery-banner__empty","data-testid":"draft-recovery-empty"},RV=e.defineComponent({__name:"DraftRecoveryBanner",props:{records:{},surface:{},projectId:{},savedAt:{},maxAgeMs:{},now:{},maxDesktopItems:{default:3}},emits:["restore","dismiss"],setup(a,{emit:n}){const t=a,o=n,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 C={};return t.projectId!==void 0&&(C.projectId=t.projectId),t.savedAt!==void 0&&(C.savedAt=t.savedAt),t.maxAgeMs!==void 0&&(C.maxAgeMs=t.maxAgeMs),t.now!==void 0&&(C.now=t.now),C}),l=e.computed(()=>{const C=t.maxDesktopItems;return!Number.isFinite(C)||C<1?1:Math.floor(C)}),c=e.computed(()=>m2(t.records,t.surface,s.value)),d=e.computed(()=>t.surface==="mobile"?c.value:c.value.slice(0,l.value)),u=e.computed(()=>t.surface==="mobile"),f=e.computed(()=>d.value.length>0),p=e.computed(()=>u.value?d.value[0]??null:null),m=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.":`${d.value.length} recoverable draft${d.value.length===1?"":"s"} found.`:"No recoverable video drafts"),g=C=>{var V;return((V=C.snapshot.metadata.title)==null?void 0:V.trim())||"Untitled video draft"},k=C=>{const V=C.snapshot.metadata.saveReason;return V===void 0?"Saved draft":i[V]},$=C=>{const V=new Date(C.snapshot.metadata.updatedAt);return Number.isFinite(V.getTime())?r.format(V):"Updated time unavailable"},D=C=>{o("restore",C)},_=C=>{C.length!==0&&o("dismiss",C)},v=C=>{_([C])},S=()=>{_(d.value)};return(C,V)=>(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":m.value},[e.createElementVNode("header",hV,[e.createElementVNode("div",vV,[V[2]||(V[2]=e.createElementVNode("p",{class:"draft-recovery-banner__eyebrow"},"Draft recovery",-1)),e.createElementVNode("h2",gV,e.toDisplayString(m.value),1),e.createElementVNode("p",yV,e.toDisplayString(h.value),1)]),!u.value&&d.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:S}," Dismiss all ")):e.createCommentVNode("",!0)]),!u.value&&f.value?(e.openBlock(),e.createElementBlock("ul",bV,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,x=>(e.openBlock(),e.createElementBlock("li",{key:x.key,class:"draft-recovery-banner__record","data-testid":"draft-recovery-record"},[e.createElementVNode("div",wV,[e.createElementVNode("h3",kV,e.toDisplayString(g(x)),1),e.createElementVNode("p",_V,[e.createElementVNode("span",EV,"Updated "+e.toDisplayString($(x)),1),V[3]||(V[3]=e.createElementVNode("span",{"aria-hidden":"true"},"·",-1)),e.createElementVNode("span",xV,e.toDisplayString(k(x)),1)])]),e.createElementVNode("div",SV,[e.createElementVNode("button",{type:"button",class:"draft-recovery-banner__primary-action","data-testid":"draft-recovery-restore",onClick:T=>D(x)}," Restore ",8,CV),e.createElementVNode("button",{type:"button",class:"draft-recovery-banner__secondary-action","data-testid":"draft-recovery-dismiss",onClick:T=>v(x)}," Dismiss ",8,VV)])]))),128))])):p.value?(e.openBlock(),e.createElementBlock("article",NV,[e.createElementVNode("div",TV,[e.createElementVNode("h3",MV,e.toDisplayString(g(p.value)),1),e.createElementVNode("p",BV,[e.createElementVNode("span",IV,"Updated "+e.toDisplayString($(p.value)),1),V[4]||(V[4]=e.createElementVNode("span",{"aria-hidden":"true"},"·",-1)),e.createElementVNode("span",FV,e.toDisplayString(k(p.value)),1)])]),e.createElementVNode("div",$V,[e.createElementVNode("button",{type:"button",class:"draft-recovery-banner__primary-action","data-testid":"draft-recovery-restore",onClick:V[0]||(V[0]=x=>D(p.value))}," Restore "),e.createElementVNode("button",{type:"button",class:"draft-recovery-banner__secondary-action","data-testid":"draft-recovery-dismiss",onClick:V[1]||(V[1]=x=>v(p.value))}," Dismiss ")])])):(e.openBlock(),e.createElementBlock("p",DV," No recoverable drafts "))],10,fV))}}),bd=Me(RV,[["__scopeId","data-v-3ed3c273"]]),AV={class:"inspector-tabs",role:"tablist","aria-label":"Editor tools"},LV=["aria-selected","data-testid","onClick"],PV=["aria-labelledby"],OV={class:"inspector-placeholder","data-testid":"v2-inspector-placeholder"},UV=e.defineComponent({__name:"InspectorPanel",props:{activeTab:{},tabs:{},compact:{type:Boolean,default:!1}},emits:["update:activeTab"],setup(a,{emit:n}){const t=a,o=n,i=e.computed(()=>t.tabs.filter(s=>s.enabled)),r=s=>{s!==t.activeTab&&o("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",AV,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,c=>(e.openBlock(),e.createElementBlock("button",{key:c.id,type:"button",role:"tab",class:e.normalizeClass(["inspector-tab",{"is-active":s.activeTab===c.id}]),"aria-selected":s.activeTab===c.id?"true":"false","data-testid":`v2-inspector-tab-${c.id}`,onClick:d=>r(c.id)},e.toDisplayString(c.label),11,LV))),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",OV,[e.createElementVNode("p",null,e.toDisplayString(s.activeTab)+" controls — coming soon",1)])],!0)],8,PV)],2))}}),zV=Me(UV,[["__scopeId","data-v-7f5b0e50"]]),jV={class:"keyframe-preset-panel__header"},WV={class:"keyframe-preset-panel__target","data-testid":"keyframe-preset-target"},ZV={key:0,class:"keyframe-preset-panel__notice","data-testid":"keyframe-preset-invalid-duration"},HV={class:"keyframe-preset-panel__grid","data-testid":"keyframe-preset-buttons"},XV=["disabled","aria-disabled","data-testid","onClick"],GV={class:"keyframe-preset-panel__preset-label"},JV={class:"keyframe-preset-panel__preset-summary"},KV={key:1,class:"keyframe-preset-panel__compact-summary","data-testid":"keyframe-preset-mobile-summary"},YV={key:2,class:"keyframe-preset-panel__desktop-summary","data-testid":"keyframe-preset-desktop-summary"},qV={class:"keyframe-preset-panel__summary-list"},QV=["data-testid"],eN={key:0,class:"keyframe-preset-panel__summary-empty","data-testid":"keyframe-preset-summary-empty"},tN=e.defineComponent({__name:"KeyframePresetPanel",props:{duration:{},target:{},deviceClass:{}},emits:["apply-preset"],setup(a,{emit:n}){const t=a,o=n,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:C=>{const V=c_({duration:S(C)});return $("fade-in","Fade in",V,C)}},{id:"fade-out",label:"Fade out",target:"opacity",summary:"Opacity 100 -> 0%",create:C=>{const V=S(C),x=d_({startTime:C-V,duration:V});return $("fade-out","Fade out",x,C)}},{id:"push-in",label:"Push in",target:"scale",summary:"Scale 100 -> 108%",create:C=>{const V=u_({duration:C,fromScale:1,toScale:1.08,easing:"ease-out"});return $("push-in","Push in",V,C)}},{id:"push-out",label:"Push out",target:"scale",summary:"Scale 108 -> 100%",create:C=>_({id:"push-out",label:"Push out",target:"scale",duration:C,startValue:1.08,endValue:1,easing:"ease-in"})},{id:"pan-x-left",label:"Pan left",target:"x",summary:"X 55 -> 45%",create:C=>_({id:"pan-x-left",label:"Pan left",target:"x",duration:C,startValue:.55,endValue:.45,easing:"ease-in-out"})},{id:"pan-x-right",label:"Pan right",target:"x",summary:"X 45 -> 55%",create:C=>_({id:"pan-x-right",label:"Pan right",target:"x",duration:C,startValue:.45,endValue:.55,easing:"ease-in-out"})},{id:"pan-y-up",label:"Pan up",target:"y",summary:"Y 55 -> 45%",create:C=>_({id:"pan-y-up",label:"Pan up",target:"y",duration:C,startValue:.55,endValue:.45,easing:"ease-in-out"})},{id:"pan-y-down",label:"Pan down",target:"y",summary:"Y 45 -> 55%",create:C=>_({id:"pan-y-down",label:"Pan down",target:"y",duration:C,startValue:.45,endValue:.55,easing:"ease-in-out"})},{id:"audio-fade-in",label:"Audio fade in",target:"audioVolume",summary:"Volume 0 -> 100%",create:C=>_({id:"audio-fade-in",label:"Audio fade in",target:"audioVolume",duration:S(C),startValue:0,endValue:1,easing:"ease-out"})},{id:"audio-fade-out",label:"Audio fade out",target:"audioVolume",summary:"Volume 100 -> 0%",create:C=>{const V=S(C);return _({id:"audio-fade-out",label:"Audio fade out",target:"audioVolume",duration:V,startTime:C-V,startValue:1,endValue:0,easing:"ease-in"})}}],s=e.computed(()=>r_(t.deviceClass)),l=e.computed(()=>s.value.platform==="mobile"),c=e.computed(()=>Number.isFinite(t.duration)&&t.duration>0),d=e.computed(()=>t.target==="all"?r:r.filter(C=>C.target===t.target)),u=e.computed(()=>c.value?d.value.map(C=>({definition:C,automation:C.create(t.duration)})):[]),f=e.computed(()=>i[t.target]),p=e.computed(()=>{const C=d.value.length,V=C===1?"preset":"presets";return c.value?`${C} ${V} - ${h(t.duration)} clip.`:`${C} ${V} available when duration is set.`}),m=C=>{if(!c.value)return;const V=C.create(t.duration);o("apply-preset",{presetId:V.id,target:V.target,keyframes:V.keyframes,automation:V})},h=C=>{const V=Math.round(C*100)/100;return`${V.toFixed(V%1===0?0:2)}s`},g=(C,V)=>C==="opacity"||C==="audioVolume"?`${Math.round(V*100)}%`:C==="scale"?`${Math.round(V*100)}%`:C==="x"||C==="y"?`${Math.round(V*100)}%`:`${Math.round(V*100)/100}`,k=C=>{const[V,x]=C.keyframes;return`${h(V.time)} ${g(C.target,V.value)} -> ${h(x.time)} ${g(C.target,x.value)}`};function $(C,V,x,T){return D({id:C,label:V,target:x.target,duration:T,keyframes:x.keyframes})}function D(C){const V=l_(C.keyframes,{target:C.target,minTime:0,maxTime:C.duration}),x=V[0],T=V[1];if(V.length!==2||x===void 0||T===void 0)throw new Error("Keyframe preset panel presets must generate exactly two keyframes.");return{id:C.id,label:C.label,target:C.target,editingMode:"preset-only",keyframes:[x,T]}}function _(C){const V=C.startTime??0,x=[v(`${C.id}:start`,C.target,V,C.startValue,"linear"),v(`${C.id}:end`,C.target,V+C.duration,C.endValue,C.easing)];return D({id:C.id,label:C.label,target:C.target,duration:V+C.duration,keyframes:x})}function v(C,V,x,T,j){return{id:C,target:V,time:x,value:T,easing:j}}function S(C){return Math.min(C,1)}return(C,V)=>(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",jV,[V[0]||(V[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",WV,e.toDisplayString(f.value),1)]),c.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",ZV," Set a valid clip duration to apply automation presets. ")),e.createElementVNode("div",HV,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,x=>(e.openBlock(),e.createElementBlock("button",{key:x.id,type:"button",class:"keyframe-preset-panel__preset",disabled:!c.value,"aria-disabled":c.value?void 0:"true","data-testid":`keyframe-preset-button-${x.id}`,onClick:T=>m(x)},[e.createElementVNode("span",GV,e.toDisplayString(x.label),1),e.createElementVNode("span",JV,e.toDisplayString(x.summary),1)],8,XV))),128))]),l.value?(e.openBlock(),e.createElementBlock("p",KV,e.toDisplayString(p.value),1)):(e.openBlock(),e.createElementBlock("div",YV,[V[1]||(V[1]=e.createElementVNode("p",{class:"keyframe-preset-panel__summary-title"},"Generated keyframes",-1)),e.createElementVNode("ul",qV,[(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(k(x.automation)),1)],8,QV))),128))]),u.value.length===0?(e.openBlock(),e.createElementBlock("p",eN," No generated keyframes until duration is valid. ")):e.createCommentVNode("",!0)]))],2))}}),wd=Me(tN,[["__scopeId","data-v-79615683"]]),nN={class:"mobile-clip-summary__main"},aN={class:"mobile-clip-summary__title","data-testid":"v2-mobile-clip-label"},oN={class:"mobile-clip-summary__stats","aria-label":"Selected clip timing"},iN={class:"mobile-clip-summary__stat"},rN={"data-testid":"v2-mobile-clip-start"},sN={class:"mobile-clip-summary__stat"},lN={"data-testid":"v2-mobile-clip-end"},cN={class:"mobile-clip-summary__stat"},dN={"data-testid":"v2-mobile-clip-duration"},uN={key:1,class:"mobile-clip-summary__empty","data-testid":"v2-mobile-no-clip"},mN=e.defineComponent({__name:"MobileClipSummary",props:{selectedClip:{}},emits:["open-actions"],setup(a,{emit:n}){const t=a,o=n,i=f=>f===void 0||!Number.isFinite(f)?null:f,r=e.computed(()=>{var f,p,m;return((p=(f=t.selectedClip)==null?void 0:f.label)==null?void 0:p.trim())||((m=t.selectedClip)==null?void 0:m.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),c=e.computed(()=>{const f=s.value,p=l.value;return f!==null&&p!==null?Math.max(0,p-f):t.selectedClip?i(t.selectedClip.duration):null}),d=f=>{if(f===null)return"--";const p=Math.round(f*100)/100;return`${p.toFixed(p%1===0?0:2)}s`},u=()=>{t.selectedClip&&o("open-actions",t.selectedClip.id)};return(f,p)=>(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",nN,[p[0]||(p[0]=e.createElementVNode("p",{class:"mobile-clip-summary__eyebrow"},"Selected clip",-1)),e.createElementVNode("h2",aN,e.toDisplayString(r.value),1)]),e.createElementVNode("dl",oN,[e.createElementVNode("div",iN,[p[1]||(p[1]=e.createElementVNode("dt",null,"Start",-1)),e.createElementVNode("dd",rN,e.toDisplayString(d(s.value)),1)]),e.createElementVNode("div",sN,[p[2]||(p[2]=e.createElementVNode("dt",null,"End",-1)),e.createElementVNode("dd",lN,e.toDisplayString(d(l.value)),1)]),e.createElementVNode("div",cN,[p[3]||(p[3]=e.createElementVNode("dt",null,"Duration",-1)),e.createElementVNode("dd",dN,e.toDisplayString(d(c.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",uN," No clip selected "))],2))}}),pN=Me(mN,[["__scopeId","data-v-433c7812"]]),fN=["aria-label"],hN=["aria-pressed","data-testid","onClick"],vN={class:"mobile-tool-picker__label"},gN=e.defineComponent({__name:"MobileToolPicker",props:{modelValue:{},ariaLabel:{default:"Mobile editor tools"}},emits:["update:modelValue"],setup(a,{emit:n}){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"}],o=a,i=n,r=s=>{s!==o.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,c=>e.createElementVNode("button",{key:c.id,type:"button",class:e.normalizeClass(["mobile-tool-picker__button",{"is-active":s.modelValue===c.id}]),"aria-pressed":s.modelValue===c.id?"true":"false","data-testid":`v2-mobile-tool-${c.id}`,onClick:d=>r(c.id)},[e.createElementVNode("span",vN,e.toDisplayString(c.label),1)],10,hN)),64))],8,fN))}}),yN=Me(gN,[["__scopeId","data-v-ec597c70"]]),bN=["aria-label","data-snap"],wN=["aria-expanded"],kN={class:"drawer-header"},_N={class:"drawer-body"},EN=e.defineComponent({__name:"VideoBottomDrawer",props:{initialSnap:{default:"half"},ariaLabel:{default:"Editor controls drawer"},containerHeight:{default:0}},emits:["snap-change"],setup(a,{expose:n,emit:t}){const o=["collapsed","half","full"],i=a,r=t,s=e.ref(null),l=e.ref(null),c=e.ref(i.initialSnap);let d=!1,u=!1,f=null,p=0,m=0,h=0;const g=T=>{const j=h||(typeof window<"u"?window.innerHeight:600);switch(T){case"collapsed":return 80;case"half":return Math.round(j*.45);case"full":return Math.round(j*.85)}},k=(T,{animate:j=!0}={})=>{var N;if(!s.value)return;const E=c.value;c.value=T;const A=typeof window<"u"&&((N=window.matchMedia)==null?void 0:N.call(window,"(prefers-reduced-motion: reduce)").matches);s.value.style.transition=j&&!A?"height 0.25s cubic-bezier(0.33, 1, 0.68, 1)":"none",s.value.style.height=`${g(T)}px`,T!==E&&r("snap-change",T,E)},$=T=>{let j=o[0],E=1/0;for(const A of o){const N=Math.abs(g(A)-T);N<E&&(E=N,j=A)}return j},D=()=>{const T=o.indexOf(c.value);k(o[(T+1)%o.length])},_=T=>{if(u){u=!1,T.preventDefault();return}D()},v=T=>{var j,E,A;if(T.button===0){d=!0,u=!1,f=T.pointerId,p=T.clientY,m=((j=s.value)==null?void 0:j.offsetHeight)??0;try{(A=(E=l.value)==null?void 0:E.setPointerCapture)==null||A.call(E,T.pointerId)}catch{}s.value&&(s.value.style.transition="none")}},S=T=>{if(!d||T.pointerId!==f)return;const j=T.clientY-p,E=m-j,A=g("collapsed"),N=g("full"),z=Math.max(A,Math.min(N,E));s.value&&(s.value.style.height=`${z}px`),Math.abs(j)>4&&(u=!0),T.preventDefault()},C=T=>{var E,A,N;if(!d)return;d=!1;try{(A=(E=l.value)==null?void 0:E.releasePointerCapture)==null||A.call(E,T.pointerId)}catch{}f=null;const j=((N=s.value)==null?void 0:N.offsetHeight)??0;k($(j))},V=(T,j={})=>{o.includes(T)&&k(T,{animate:j.animate!==!1})},x=T=>{h=Math.max(0,Number(T)||0),k(c.value,{animate:!1})};return e.watch(()=>i.containerHeight,T=>{T>0&&x(T)}),e.onMounted(()=>{i.containerHeight>0&&(h=i.containerHeight),k(c.value,{animate:!1})}),e.onBeforeUnmount(()=>{d=!1,f=null}),n({snapTo:V,updateContainerHeight:x,snap:c}),(T,j)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootEl",ref:s,class:"video-editor-v2-drawer",role:"dialog","aria-label":T.ariaLabel,"data-snap":c.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":c.value==="full"?"true":"false","data-testid":"v2-video-drawer-handle",onClick:_,onPointerdown:v,onPointermove:S,onPointerup:C,onPointercancel:C},[...j[0]||(j[0]=[e.createElementVNode("span",{class:"drawer-handle-grip","aria-hidden":"true"},null,-1)])],40,wN),e.createElementVNode("div",kN,[e.renderSlot(T.$slots,"header",{},void 0,!0)]),e.createElementVNode("div",_N,[e.renderSlot(T.$slots,"default",{},void 0,!0)])],8,bN))}}),xN=Me(EN,[["__scopeId","data-v-4ebedbf7"]]),SN={class:"v2-toolbar-group"},CN=["aria-label"],VN=["disabled"],NN={class:"v2-toolbar-group"},TN={class:"v2-toolbar-fit"},MN=["disabled"],BN=["disabled"],IN={class:"v2-assets"},FN={key:0,class:"v2-asset-rail-status","data-testid":"v2-asset-rail-status",role:"status"},$N={class:"v2-preview-host"},DN={class:"v2-timeline-topbar"},RN={class:"v2-timeline-heading"},AN={class:"v2-timeline-meta","data-testid":"v2-timeline-meta"},LN={class:"v2-timeline-zoom"},PN=["value"],ON={class:"v2-timeline-zoom-readout"},UN={key:0,class:"v2-timeline-track-actions"},zN={key:0,class:"v2-timeline-track-target"},jN=["value"],WN=["value"],ZN=["aria-pressed"],HN={key:1,class:"v2-empty-state"},XN={key:0,"data-testid":"v2-export-status-completed",class:"v2-export-status"},GN={key:1,class:"v2-export-status","data-testid":"v2-export-status-message"},JN={key:1,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-look"},KN={class:"v2-mobile-panel-section"},YN={class:"v2-mobile-panel-section v2-mobile-panel-section--compact"},qN={key:1,class:"v2-empty-state"},QN={key:2,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-trim"},e4={key:3,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-text"},t4={key:4,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-audio"},n4={key:5,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-export"},a4={key:0,class:"v2-export-status"},o4={key:1,class:"v2-export-status"},i4={key:6,class:"v2-mobile-tool-panel","data-testid":"v2-mobile-panel-more"},r4={class:"v2-mobile-secondary-controls"},s4={class:"v2-mobile-secondary-field"},l4=["aria-pressed"],c4=["disabled"],d4=["disabled"],u4={key:0,class:"v2-mobile-secondary-details","data-testid":"v2-mobile-transitions"},m4={class:"v2-mobile-secondary-details","data-testid":"v2-mobile-keyframes"},p4=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}},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(a,{expose:n,emit:t}){var _o,Ha,Xa,ki;const o=a,i=t,r=e.computed(()=>{var Q;const y=typeof o.mediaUuid=="string"?o.mediaUuid.trim():"";if(y!=="")return y;const F=(Q=o.media)==null?void 0:Q.uuid;return typeof F=="string"&&F.trim()!==""?F.trim():`temp-${Date.now()}`}),s=sm(r.value,o.initialRecipe,o.media),l=dm(),c=e.ref("filters"),d=e.ref("look"),u=e.computed(()=>o.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}),f=e.computed(()=>{const y=o.featureFlags??{},F=["filters","adjustments","text","transitions","audio","export"],Q={filters:"Filters",adjustments:"Adjust",text:"Text",transitions:"Transitions",audio:"Audio",export:"Export"};return F.map(me=>({id:me,label:Q[me],enabled:typeof y[me]=="boolean"?y[me]:u.value[me]}))}),p=y=>f.value.some(F=>F.id===y&&F.enabled),m={look:"filters",text:"text",audio:"audio",export:"export"},h=e.computed(()=>{var y;return((y=o.featureFlags)==null?void 0:y.transitions)===!0});e.watch(d,y=>{if(y==="trim"||y==="more")return;const F=m[y];p(F)&&(c.value=F)});const g=e.ref(!1),k=e.computed(()=>c.value),$=e.computed(()=>k.value==="filters"||g.value),D=e.computed(()=>k.value!=="filters"&&!g.value),_=e.ref(null),v=e.computed(()=>_.value),S=["contain","cover","none"],C=y=>typeof y=="string"&&S.includes(y),V=y=>{var Q;const F=(Q=y==null?void 0:y.metadata)==null?void 0:Q.fit_mode;return C(F)?F:null},x=e.ref(V(o.initialRecipe)??"contain"),T=e.ref("");e.watch(()=>{var y,F;return{file:(y=o.media)==null?void 0:y.file,url:(F=o.media)==null?void 0:F.url}},(y,F,Q)=>{var Ae,De;const me=T.value;Q(()=>{me&&me.startsWith("blob:")&&URL.revokeObjectURL(me)}),(Ae=o.media)!=null&&Ae.file?T.value=URL.createObjectURL(o.media.file):(De=o.media)!=null&&De.url?T.value=o.media.url:T.value=""},{immediate:!0});const j=e.computed(()=>T.value),E=e.computed(()=>l.activeFilters.value),A=e.computed(()=>s.playheadPosition.value),N=$u({forcePixiPreview:g,getPreviewRef:()=>v.value,getSourceUrl:()=>T.value,setPlaying:s.setPlaying}),z=e.computed(()=>{if(!o.media)return null;const{file:y,...F}=o.media;return{...F,url:T.value}}),P=e.computed(()=>{var F;const y=(F=o.media)==null?void 0:F.url;return!!(y&&/^https?:/i.test(y))}),B=e.ref(0),L=e.computed(()=>{var F;if(s.totalDuration.value>0)return s.totalDuration.value;if(B.value>0)return B.value;const y=Number((F=o.media)==null?void 0:F.duration);return Number.isFinite(y)&&y>0?y:0}),w=y=>{!Number.isFinite(y)||y<=0||(B.value=y,s.updateSourceDuration(y))},O=y=>{y&&typeof y.time=="number"&&Number.isFinite(y.time)&&s.seekTo(y.time)},Z=y=>{Number.isFinite(y)&&s.seekTo(y)},G=y=>{s.setPlaying(y)},re=e.computed(()=>l.videoCompatibleFilters.value.map(F=>{var me;const Q=[];if(F.controls&&F.controls.length>0)for(const Ae of F.controls){const De=Ae.type;if(De==="button"||De==="text"||De==="range")continue;const Ge={id:Ae.property||Ae.id,label:Ae.label||Ae.id,type:De,default:Ae.default??(De==="toggle"?!1:De==="color"?"#ffffff":0)};De==="slider"&&(Ge.min=Ae.min??0,Ge.max=Ae.max??1,Ge.step=Ae.step??.01),De==="select"&&Ae.options&&(Ge.options=Ae.options),Q.push(Ge)}else if(F.paramRanges){const Ae=Object.entries(F.paramRanges);for(const[De,Ge]of Ae){const ht=De.replace(/[-_]/g," ").replace(/\b\w/g,Ga=>Ga.toUpperCase()),Ct=(me=F.defaultParams)==null?void 0:me[De],zt=(Ge.min+Ge.max)/2;Q.push({id:De,label:ht,min:Ge.min,max:Ge.max,step:Ge.step??.01,default:typeof Ct=="number"?Ct:zt})}}return{id:F.id,name:F.name,category:F.category,params:Q}})),be=e.computed(()=>{const y=new Map;return l.activeFilters.value.forEach(F=>y.set(F.filterId,F)),y}),Ee=e.computed(()=>{if(s.currentFrame.value)return s.currentFrame.value;const y=o.media;return(y==null?void 0:y.thumbnail_url)??(y==null?void 0:y.url)}),ie=e.shallowRef(null),R=e.ref(null),M=e.ref(null),H=e.ref(null),ee=e.ref(!1),ae=new Map,ue=(y,F)=>{const Q={id:y.id??`text-overlay-recipe-${F}`,text:y.content};return y.fontFamily!==void 0&&(Q.fontFamily=y.fontFamily),y.fontSize!==void 0&&(Q.fontSize=y.fontSize),y.fontWeight!==void 0&&(Q.fontWeight=y.fontWeight),y.color!==void 0&&(Q.color=y.color),y.position!==void 0&&(Q.position=y.position),y.startTime!==void 0&&(Q.startTime=y.startTime),y.duration!==void 0&&(Q.duration=y.duration),y.animation!==void 0&&(Q.animation=y.animation),y.textAlign!==void 0&&(Q.textAlign=y.textAlign),y.textBaseline!==void 0&&(Q.textBaseline=y.textBaseline),Q},de=y=>{const F={id:y.id,content:y.text};return y.fontFamily!==void 0&&(F.fontFamily=y.fontFamily),y.fontSize!==void 0&&(F.fontSize=y.fontSize),y.fontWeight!==void 0&&(F.fontWeight=y.fontWeight),y.color!==void 0&&(F.color=y.color),y.position!==void 0&&(F.position=y.position),y.startTime!==void 0&&(F.startTime=y.startTime),y.duration!==void 0&&(F.duration=y.duration),y.animation!==void 0&&(F.animation=y.animation),y.textAlign!==void 0&&(F.textAlign=y.textAlign),y.textBaseline!==void 0&&(F.textBaseline=y.textBaseline),F},ye=(y,F)=>{const Q={id:y.id??`audio-track-recipe-${F}`,source:y.source};return y.volume!==void 0&&(Q.volume=y.volume),y.startTime!==void 0&&(Q.startTime=y.startTime),y.duration!==void 0&&(Q.duration=y.duration),y.fadeIn!==void 0&&(Q.fadeIn=y.fadeIn),y.fadeOut!==void 0&&(Q.fadeOut=y.fadeOut),y.loop!==void 0&&(Q.loop=y.loop),y.name!==void 0&&(Q.name=y.name),Q},Be=y=>{if(typeof y.source!="string")return null;const F={id:y.id,source:y.source};return y.volume!==void 0&&(F.volume=y.volume),y.startTime!==void 0&&(F.startTime=y.startTime),y.duration!==void 0&&(F.duration=y.duration),y.fadeIn!==void 0&&(F.fadeIn=y.fadeIn),y.fadeOut!==void 0&&(F.fadeOut=y.fadeOut),y.loop!==void 0&&(F.loop=y.loop),y.name!==void 0&&(F.name=y.name),F},fe=y=>{const F={id:y.id,source:typeof y.source=="string"?y.source:""};return y.volume!==void 0&&(F.volume=y.volume),y.startTime!==void 0&&(F.startTime=y.startTime),y.duration!==void 0&&(F.duration=y.duration),y.fadeIn!==void 0&&(F.fadeIn=y.fadeIn),y.fadeOut!==void 0&&(F.fadeOut=y.fadeOut),y.loop!==void 0&&(F.loop=y.loop),y.name!==void 0&&(F.name=y.name),y.muted!==void 0&&(F.muted=y.muted),y.solo!==void 0&&(F.solo=y.solo),y.pan!==void 0&&(F.pan=y.pan),y.faderDb!==void 0&&(F.faderDb=y.faderDb),F},ge=y=>({...y,segments:y.segments.map(F=>{const Q={...F};return F.words&&(Q.words=F.words.map(me=>({...me}))),Q})}),Se=e.ref((((_o=o.initialRecipe)==null?void 0:_o.textOverlays)??[]).map(ue)),Ie=y=>{switch(y){case"crossfade":return"cross-fade";case"zoom":return"zoom-in";case"cut":return"fade";default:return y}},pt=y=>{switch(y){case"ease-in":return"easeIn";case"ease-out":return"easeOut";case"ease-in-out":return"easeInOut";case"linear":return"linear"}},lt=y=>{switch(y){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 y}},Dt=y=>{switch(y){case"easeIn":return"ease-in";case"easeOut":return"ease-out";case"easeInOut":return"ease-in-out";case"linear":default:return"linear"}},ot=y=>({id:y.id,type:Ie(y.type),duration:y.duration,easing:pt(y.easing),name:y.type,fromClipId:y.fromClipId,toClipId:y.toClipId,cutTime:y.cutTime??0}),vt=y=>({id:y.id,type:lt(y.type),fromClipId:y.fromClipId,toClipId:y.toClipId,duration:y.duration,easing:Dt(y.easing),cutTime:y.cutTime}),bt=e.ref((((Ha=o.initialRecipe)==null?void 0:Ha.transitions)??[]).map(ot)),it=e.ref((((Xa=o.initialRecipe)==null?void 0:Xa.audioTracks)??[]).map(ye)),wt=e.ref(1),Et=e.ref(!1),he=e.ref((((ki=o.initialRecipe)==null?void 0:ki.captionTracks)??[]).map(ge)),Ne=e.ref([]),Re=e.ref(null),He=e.computed(()=>r.value),je=e.computed(()=>Ne.value),Oe=e.computed(()=>he.value[0]??null),ct=e.computed(()=>{const y=s.selectedClip.value??s.timelineClips.value[0];return y?Math.max(0,y.timelineEnd-y.timelineStart):L.value}),dt=e.computed(()=>B2(it.value.map(fe),{master:{volume:wt.value,muted:Et.value}})),Pt=e.computed(()=>{const y=[...s.timelineClips.value].sort((Ge,ht)=>Ge.timelineStart-ht.timelineStart),F=s.selectedClip.value??y[0];if(!F)return[];const Q=y.findIndex(Ge=>Ge.id===F.id);if(Q===-1)return[];const me=Ge=>(Ge.trackId??null)===(F.trackId??null),Ae=y.slice(Q+1).find(me);if(Ae)return[F,Ae];const De=[...y.slice(0,Q)].reverse().find(me);return De?[De,F]:[]}),Rt=y=>{ie.value=y,y!=null&&y.composition&&(M.value=new um(y.composition),H.value=new mm(y.composition));try{ae.size&&ie.value&&(ae.forEach((F,Q)=>{ie.value.setClipFilters(Q,F)}),ae.clear(),ie.value.composition.computeFrame())}catch{}},Ot=y=>{ie.value?ie.value.setClipFilters(y,l.activeFilters.value):ae.set(y,[...l.activeFilters.value])},tn=y=>{var Q,me;const F=((Q=s.selectedClip.value)==null?void 0:Q.id)??((me=s.timelineClips.value[0])==null?void 0:me.id);F&&(ee.value=!0,typeof y=="object"&&y!==null&&"id"in y?l.applyFilter(y.id):typeof y=="string"&&l.applyFilter(y),s.setFilters(l.activeFilters.value),Ot(F),s.handleClipSelect(F),ee.value=!1,gt())},zn=y=>{var me,Ae;const F=l.activeFilters.value.find(De=>De.filterId===y);F&&l.removeFilter(F.id),s.setFilters(l.activeFilters.value);const Q=((me=s.selectedClip.value)==null?void 0:me.id)??((Ae=s.timelineClips.value[0])==null?void 0:Ae.id);Q&&Ot(Q),gt()},Yn=(y,F,Q)=>{var De,Ge;const me=l.activeFilters.value.find(ht=>ht.filterId===y);if(me){me.params={...me.params??{},[F]:Q},s.setFilters(l.activeFilters.value);const ht=((De=s.selectedClip.value)==null?void 0:De.id)??((Ge=s.timelineClips.value[0])==null?void 0:Ge.id);ht&&Ot(ht),gt();return}const Ae=l.previewFilter.value;Ae&&Ae.filterId===y&&(Ae.params={...Ae.params??{},[F]:Q})},q=y=>{y&&typeof y.id=="string"&&y.id!==""&&l.previewFilterEffect(y.id)},le=y=>{l.updateFilterParams(y),s.setFilters(l.activeFilters.value),gt()},oe=async y=>{if(!M.value)return;const F=await M.value.addTextOverlay(y);Se.value.push({id:F,...y})},se=async(y,F)=>{if(!M.value)return;await M.value.updateTextOverlay(y,F);const Q=Se.value.findIndex(me=>me.id===y);Q!==-1&&(Se.value[Q]={...Se.value[Q],...F})},Ce=async y=>{M.value&&(await M.value.removeTextOverlay(y),Se.value=Se.value.filter(F=>F.id!==y))},Ve=async y=>{const[F,Q]=Pt.value;if(!F||!Q)return;const me={id:`transition-${F.id}-${Q.id}-${Date.now()}`,...y,name:y.type,fromClipId:F.id,toClipId:Q.id,cutTime:F.timelineEnd};bt.value.push(me),s.setTransitions(bt.value.map(vt)),gt()},Je=y=>{bt.value[y]&&(bt.value.splice(y,1),s.setTransitions(bt.value.map(vt)),gt())},st=y=>{},ut=async y=>{if(!H.value)return;const F=await H.value.addAudioTrack(y);it.value.push({id:F,...y})},nt=async(y,F)=>{if(!H.value)return;await H.value.updateAudioTrack(y,F);const Q=it.value.findIndex(me=>me.id===y);Q!==-1&&(it.value[Q]={...it.value[Q],...F})},kt=async y=>{H.value&&(await H.value.removeAudioTrack(y),it.value=it.value.filter(F=>F.id!==y))},At=async(y,F)=>{if(!H.value)return;await H.value.updateVolume(y,F);const Q=it.value.find(me=>me.id===y);Q&&(Q.volume=F)},nn=async(y,F)=>{if(!H.value)return;await H.value.muteTrack(y,F);const Q=it.value.find(me=>me.id===y);Q&&(Q.muted=F)},qn=y=>{H.value&&(H.value.setMasterVolume(y),wt.value=y)},mn=(y,F)=>{const Q=it.value.findIndex(Ae=>Ae.id===y);if(Q===-1)return null;const me={...it.value[Q],...F};return it.value[Q]=me,me},Aa=y=>{switch(y.type){case"track-fader-db":{const F=Qs(y.valueDb);mn(y.trackId,{faderDb:y.valueDb,volume:F}),H.value&&H.value.updateVolume(y.trackId,F);break}case"track-mute":mn(y.trackId,{muted:y.muted}),H.value&&H.value.muteTrack(y.trackId,y.muted);break;case"track-solo":mn(y.trackId,{solo:y.solo});break;case"track-pan":mn(y.trackId,{pan:y.pan});break;case"master-fader-db":{wt.value=Qs(y.valueDb),H.value&&H.value.setMasterVolume(Et.value?0:wt.value);break}case"master-mute":Et.value=y.muted,H.value&&H.value.setMasterVolume(Et.value?0:wt.value);break}},da=y=>{he.value=[ge(y.track)],s.setCaptionTracks(he.value),gt()},kn=y=>{he.value=[ge(y)],s.setCaptionTracks(he.value),gt()},pn=()=>{he.value=[],s.setCaptionTracks([]),gt()},fn=y=>{const F=s.selectedClip.value??s.timelineClips.value[0];if(!F)return;const me=[...(F.keyframes??[]).filter(Ae=>Ae.target!==y.target),...y.keyframes].sort((Ae,De)=>{const Ge=Ae.time-De.time;return Ge===0?Ae.id.localeCompare(De.id):Ge});s.setClipKeyframes(F.id,me),gt()},W=y=>{var F;return y.metadata||(y.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),y.metadata.fit_mode=x.value,(F=o.media)!=null&&F.url&&/^https?:/i.test(o.media.url)?y.metadata.source_url=o.media.url:delete y.metadata.source_url,y.captionTracks=he.value.map(ge),y},J=(y,F)=>F?{...y,output:{...y.output,format:F.format,quality:F.quality,codec:F.codec??y.output.codec,fps:F.fps??y.output.fps,...typeof F.bitrate=="number"?{bitrate:F.bitrate}:{}}}:y,te=y=>y.map(F=>({...F,params:F.params&&typeof F.params=="object"?{...F.params}:F.params})),ve=y=>y.timeline.some(F=>Array.isArray(F.filters)&&F.filters.length>0),_e=y=>{const F=te(l.activeFilters.value);if(!ve(y)&&F.length>0&&y.timeline.length>0){const me=y.timeline[0];me&&(y.timeline=[{...me,filters:F},...y.timeline.slice(1)])}return y},Ue=()=>{const y=_e(W(s.saveDraft()));try{localStorage.setItem(`video-draft-${r.value}`,JSON.stringify(y))}catch{}return rt(y,"manual",!0),y},Ye=()=>typeof localStorage>"u"?null:{getItem:y=>localStorage.getItem(y),setItem:(y,F)=>{localStorage.setItem(y,F)},removeItem:y=>{localStorage.removeItem(y)},listKeys:y=>{const F=[];for(let Q=0;Q<localStorage.length;Q+=1){const me=localStorage.key(Q);me!=null&&me.startsWith(y)&&F.push(me)}return F}},Xe=async()=>{const y=Ye();if(y===null){Ne.value=[];return}Ne.value=await Hc(y)},rt=async(y,F,Q)=>{var zt,Ga;const me=Ye();if(me===null)return;const Ae=new Date().toISOString(),De={projectId:He.value,sourceMediaUuid:r.value,durationSeconds:L.value,editorVersion:((zt=y.metadata)==null?void 0:zt.editor_version)??"2.0.0",saveReason:F,now:Ae};((Ga=y.metadata)==null?void 0:Ga.title)!==void 0&&(De.title=y.metadata.title);const Ge=i2(Du(y),De);await p2(me,Ge);const ht=await Hc(me),Ct=c2(ht,{maxCount:5,projectId:He.value,now:Ae});await Xc(me,Ct.removed),Ne.value=[...Ct.retained],Q&&(Re.value=Ae)},_n=y=>y.snapshot.metadata.payloadKind==="project"?e2(y.snapshot.payload):y.snapshot.payload,Xt=y=>{const F=_n(y);s.loadRecipe(F),Se.value=(F.textOverlays??[]).map(ue),it.value=(F.audioTracks??[]).map(ye),he.value=(F.captionTracks??[]).map(ge),bt.value=(F.transitions??[]).map(ot);const Q=V(F);Q!==null&&(x.value=Q),Tn()},hn=y=>{const F=Ye();Ne.value=Ne.value.filter(Q=>!y.some(me=>me.key===Q.key)),F!==null&&Xc(F,y)},Tn=()=>{R.value=W(s.generateRecipe())};let Mn=null;const gt=()=>{Mn&&clearTimeout(Mn),Mn=setTimeout(()=>{Tn(),Mn=null},200)};if(e.watch(()=>s.timelineClips.value,gt,{deep:!0}),e.watch(()=>s.selectedClip.value,y=>{if(ee.value||!y)return;const F=(y==null?void 0:y.filters)??[];l.setActiveFilters(F)},{immediate:!0}),e.watch(()=>l.activeFilters.value,y=>{s.setFilters(y),gt()},{deep:!0}),e.watch(()=>Se.value,y=>{s.setTextOverlays(y.map(de)),gt()},{deep:!0}),e.watch(()=>it.value,y=>{const F=y.map(Be).filter(Q=>Q!==null);s.setAudioTracks(F),gt()},{deep:!0}),e.watch(()=>he.value,y=>{s.setCaptionTracks(y.map(ge)),gt()},{deep:!0}),Se.value.length>0&&s.setTextOverlays(Se.value.map(de)),it.value.length>0){const y=it.value.map(Be).filter(F=>F!==null);s.setAudioTracks(y)}he.value.length>0&&s.setCaptionTracks(he.value.map(ge)),e.watch(()=>s.playheadPosition.value,gt),Tn();const an=e.ref(!0),on=e.ref(null),Ut=e.ref(null),jn=e.computed(()=>s.tracks.value),La=e.computed(()=>s.mediaSources.value),Bn=e.computed(()=>{var y,F;return((y=s.selectedClip.value)==null?void 0:y.sourceRefId)??((F=La.value[0])==null?void 0:F.id)}),Qn=e.computed(()=>jn.value.filter(y=>y.locked!==!0&&y.type==="video")),Pa=e.computed(()=>Ut.value?jn.value.find(y=>y.id===Ut.value)??null:null),mi=e.computed(()=>!!s.selectedClip.value&&s.playheadPosition.value>0),pi=e.computed(()=>!!s.selectedClip.value&&s.timelineClips.value.length>1),Oa=e.computed(()=>s.selectedClip.value??s.timelineClips.value[0]??null),Ua=y=>{const F=Number.isFinite(y)&&y>0?Math.round(y):0,Q=Math.floor(F/60),me=F%60;return`${Q}:${me.toString().padStart(2,"0")}`},In=e.computed(()=>{const y=s.timelineClips.value.length,F=jn.value.length,Q=y===1?"1 clip":`${y} clips`,me=F===1?"1 track":`${F} tracks`;return`${Q} / ${me} / ${Ua(L.value)}`});e.watch(()=>jn.value.map(y=>`${y.id}:${y.locked===!0?"locked":"open"}`).join("|"),()=>{var y;Ut.value&&Qn.value.some(F=>F.id===Ut.value)||(Ut.value=((y=Qn.value[0])==null?void 0:y.id)??null)},{immediate:!0}),e.watch(()=>{var y;return(y=s.selectedClip.value)==null?void 0:y.trackId},y=>{y&&Qn.value.some(F=>F.id===y)&&(Ut.value=y)},{immediate:!0});const ho=y=>{const F=La.value.find(Q=>Q.id===y);return F?F.filename??F.mediaUuid??F.url??F.id:"Asset"},Ur=y=>{var me;const F=s.appendMediaSourceToTimeline(y,Ut.value);if(!F){on.value="Asset could not be added.";return}F.trackId&&(Ut.value=F.trackId),s.handleClipSelect(F.id);const Q=((me=Pa.value)==null?void 0:me.name)??"timeline";on.value=`${ho(y)} added to ${Q}.`,gt()},fi=y=>{if(!s.replaceSelectedClipSource(y)){on.value="Select a clip before replacing its source.";return}on.value=`${ho(y)} replaced the selected clip.`,gt()},zr=y=>{const F=ho(y);if(!s.removeMediaSource(y)){on.value="Remove timeline clips before deleting this asset.";return}on.value=`${F} removed.`,gt()},vo=(y="video")=>{const F=s.addTimelineTrack(y);Ut.value=F.id,on.value=`${F.name} added. New assets will be placed on that track.`,gt()},jr=y=>{const F=y.target;F&&(Ut.value=F.value||null)},Wr=y=>{var Q;s.handleClipSelect(y);const F=(Q=s.selectedClip.value)==null?void 0:Q.trackId;F&&Qn.value.some(me=>me.id===F)&&(Ut.value=F)},go=y=>{s.deleteClip(y)&&(on.value="Clip deleted.",gt())},za=(y,F)=>{F(y)&>()},Zr=y=>{an.value=y},ja=()=>{an.value=!an.value},Jt=y=>{const F=y.target;if(!F)return;const Q=Number(F.value);Number.isFinite(Q)&&s.setZoomLevel(Q)},_t=e.ref(!1),Wn=e.ref(0),vn=e.ref(!1),ft=e.ref(null),gn=e.ref(null),En=e.ref("preparing");let Mt=null,It=!1;const Zn={preparing:"Preparing export...",rendering:"Rendering frames...","encoding-video":"Encoding video...","encoding-audio":"Encoding audio...",muxing:"Muxing output...",storing:"Storing export...",complete:"Export complete"},hi=y=>typeof y=="string"&&y in Zn,vi=(y,F)=>{En.value=y,ft.value=typeof F=="string"&&F.trim()!==""?F.trim():Zn[y]},Kt=(y,F,Q)=>{const me=Number.isFinite(y)?Math.max(0,Math.min(100,y)):0;Wn.value=me,F&&vi(F,Q)},Hr=y=>{if(hi(y.phase))return y.phase;switch(y.status){case"pending":return"preparing";case"processing":return"rendering";case"completed":return"complete";default:return En.value}},Xr=y=>typeof y.progress_message=="string"&&y.progress_message.trim()!==""?y.progress_message.trim():void 0,Wa=(y,F,Q={allowClient:!0})=>{if(!Number.isFinite(F)||F<=0||y.timeline.length===0)return{route:"unsupported",exportDuration:F,message:"Export unavailable: the recipe has no renderable duration."};if(o.maxDuration>0&&F>o.maxDuration)return{route:"unsupported",exportDuration:F,message:`Export unavailable: duration exceeds the ${o.maxDuration}s limit.`};if(Q.allowClient&&o.clientExportThreshold>0&&F<=o.clientExportThreshold)return{route:"client",exportDuration:F};const Ae=!!o.serverRenderEndpoint,De=r.value.startsWith("temp-");return Ae&&!De?{route:"server-render",exportDuration:F}:{route:"recipe-download",exportDuration:F,message:De?"Local media — downloaded recipe.json. Client-side PIXI export is unavailable on this device.":"No server render endpoint configured — downloaded recipe.json."}},Za=()=>new Ar(o.serverRenderEndpoint??"/api/v1"),Fn=()=>{Mt!==null&&(clearInterval(Mt),Mt=null)},gi=y=>{Fn();const F=Za();Mt=setInterval(async()=>{if(It){Fn();return}try{const Q=await F.getJob(y),me=Number(Q.progress??0);if(Kt(me,Hr(Q),Xr(Q)),i("server-render-progress",Wn.value),Q.status==="completed"||Q.status==="failed"||Q.status==="cancelled")if(Fn(),_t.value=!1,gn.value=null,Q.status==="completed"){Kt(100,"complete"),vn.value=!0,ft.value=null;const Ae=typeof Q.output_media_id=="string"?Q.output_media_id:void 0,De={id:y};Ae!==void 0&&(De.output_media_id=Ae),i("server-render-completed",De)}else{const Ae=Q.status==="cancelled"||typeof Q.error_message=="string"&&/cancel/i.test(Q.error_message),De=Ae?"Export canceled.":typeof Q.error_message=="string"&&Q.error_message.trim()!==""?Q.error_message:"Export failed";ft.value=De,Ae||i("server-render-failed",De)}}catch(Q){Fn(),_t.value=!1,gn.value=null;const me=Q instanceof Error?Q.message:"Failed to check export progress";ft.value=me,i("server-render-failed",me)}},2e3)},yo=y=>{const F=new Blob([JSON.stringify(y,null,2)],{type:"application/json"}),Q=URL.createObjectURL(F),me=document.createElement("a");me.href=Q,me.download=`video-recipe-${Date.now()}.json`,me.click(),setTimeout(()=>URL.revokeObjectURL(Q),100)},ua=()=>{Fn(),It=!1,N.resetClientExport(),gn.value=null,ft.value=null,vn.value=!1,Wn.value=0,En.value="preparing"},xn=async y=>{Kt(0,"preparing");const Q=await Za().createRenderJob({source_media_uuid:r.value,recipe:y}),me=typeof Q.id=="string"?Q.id:null;if(!me)throw new Error("Export failed: missing job id");gn.value=me,i("export-started",me),i("server-render-started",me),Kt(1,"rendering"),gi(me)},yi=async(y,F)=>{if(!await N.canExportClientSide())return null;const Q=await N.renderRecipeWithPixi(y,F,me=>{It||Kt(me,"rendering")});return It?(ft.value="Export canceled.",Kt(0),i("video-exported",null),null):(s.clearHasChanges(),i("recipe-generated",y),i("video-exported",Q),Kt(100,"complete"),vn.value=!0,Q)},ma=async y=>{ua(),_t.value=!0,vi("preparing");try{const F=W(_e(J(s.generateRecipe(),y)));rt(F,"before-export",!1),i("recipe-generated",F);const Q=Zc(F,L.value),me=Wa(F,Q);if(me.route==="unsupported"){_t.value=!1,ft.value=me.message??"Export unavailable.",i("server-render-failed",ft.value);return}if(me.route==="client"){const De=await yi(F,y);if(De!==null){const Ge=URL.createObjectURL(De.file),ht=document.createElement("a");ht.href=Ge,ht.download=`edited-video-${Date.now()}.mp4`,ht.click(),setTimeout(()=>URL.revokeObjectURL(Ge),100),_t.value=!1;return}}const Ae=me.route==="client"?Wa(F,Q,{allowClient:!1}):me;if(Ae.route==="unsupported"){_t.value=!1,ft.value=Ae.message??"Export unavailable.",i("server-render-failed",ft.value);return}if(Ae.route==="recipe-download"){yo(F),_t.value=!1,Kt(100,"complete"),vn.value=!0,ft.value=Ae.message??"Downloaded recipe.json.";return}await xn(F)}catch(F){const Q=W(s.generateRecipe());yo(Q);const me=F instanceof Error?F.message:"Export failed";_t.value=!1,Kt(0),gn.value=null,ft.value=me,i("server-render-failed",me)}},bo=async()=>{It=!0,g.value=!1,N.cancelClientExport();const y=gn.value;if(Fn(),_t.value=!1,Kt(0),ft.value="Export canceled.",gn.value=null,y&&o.serverRenderEndpoint)try{await Za().cancelJob(y)}catch{}},pa=()=>{s.togglePlayback()},fa=()=>{s.resetChanges()},ha=()=>{const y=Ue();i("draft-saved",y)},bi=()=>{ma()},wo=()=>{i("close")};return n({saveDraft:async()=>{const y=Ue();return i("draft-saved",y),y},exportForUpload:async y=>{ua();const F=W(y??s.generateRecipe()),Q=_e(F),me=Array.isArray(Q.filters)&&Q.filters.length>0,Ae=ve(Q);if(!(s.hasChanges.value||me||Ae))return s.clearHasChanges(),i("video-exported",null),null;const Ge=Zc(Q,L.value),ht=Wa(Q,Ge);if(ht.route==="unsupported"){const Ct=ht.message??"Export unavailable.";throw ft.value=Ct,new Error(`Video export failed: ${Ct}`)}if(ht.route==="server-render")return _t.value=!0,await xn(Q),null;_t.value=!0;try{if(ht.route==="client"){const zt=await yi(Q);if(zt!==null)return zt}const Ct=ht.route==="client"?Wa(Q,Ge,{allowClient:!1}):ht;if(Ct.route==="server-render")return await xn(Q),null;if(Ct.route==="unsupported"){const zt=Ct.message??"Export unavailable.";throw ft.value=zt,new Error(`Video export failed: ${zt}`)}return ft.value=Ct.message??"Export unavailable for upload.",i("video-exported",null),null}catch(Ct){if(It)return ft.value="Export canceled.",Kt(0),i("video-exported",null),null;const zt=Ct instanceof Error?Ct.message:"Local WebGL export failed.";throw ft.value=zt,new Error(`Video export failed: ${zt}`)}finally{_t.value=!1}}}),e.onMounted(()=>{document.documentElement.setAttribute("data-video-editor-version","v2"),Xe()}),e.onBeforeUnmount(()=>{document.documentElement.getAttribute("data-video-editor-version")==="v2"&&document.documentElement.removeAttribute("data-video-editor-version")}),e.onUnmounted(()=>{Fn(),It=!0,N.cancelClientExport(),Mn&&(clearTimeout(Mn),Mn=null),ie.value&&(ie.value.destroy(),ie.value=null),M.value=null,H.value=null}),(y,F)=>(e.openBlock(),e.createBlock(GS,{"data-testid":"video-editor-v2"},{toolbar:e.withCtx(()=>[e.createElementVNode("div",SN,[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:pa},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(s).isPlaying.value?e.unref(ml):e.unref(pl),"aria-hidden":"true"},null,8,["icon"])],10,CN),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:fa},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Fa),"aria-hidden":"true"},null,8,["icon"])],8,VN)]),F[19]||(F[19]=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",NN,[e.createElementVNode("label",TN,[F[17]||(F[17]=e.createElementVNode("span",{class:"sr-only"},"Fit mode",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":F[0]||(F[0]=Q=>x.value=Q),"aria-label":"Fit mode","data-testid":"v2-select-fit-mode"},[...F[16]||(F[16]=[e.createElementVNode("option",{value:"contain"},"Contain",-1),e.createElementVNode("option",{value:"cover"},"Cover",-1),e.createElementVNode("option",{value:"none"},"None",-1)])],512),[[e.vModelSelect,x.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:ha},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(pr),"aria-hidden":"true"},null,8,["icon"]),F[18]||(F[18]=e.createElementVNode("span",{class:"v2-toolbar-btn-label"},"Save",-1))],8,MN),e.createElementVNode("button",{type:"button",class:"v2-toolbar-btn","data-testid":"v2-btn-export","aria-label":"Export",disabled:_t.value,onClick:bi},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ao),"aria-hidden":"true"},null,8,["icon"])],8,BN),e.createElementVNode("button",{type:"button",class:"v2-toolbar-btn","data-testid":"v2-btn-close","aria-label":"Close editor",onClick:wo},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Na),"aria-hidden":"true"},null,8,["icon"])])])]),assets:e.withCtx(()=>[e.createElementVNode("div",IN,[e.createVNode(sC,{sources:La.value,"selected-source-id":Bn.value,onAdd:Ur,onReplaceSelected:fi,onRemove:zr},null,8,["sources","selected-source-id"]),on.value?(e.openBlock(),e.createElementBlock("p",FN,e.toDisplayString(on.value),1)):e.createCommentVNode("",!0)])]),canvas:e.withCtx(()=>[e.createElementVNode("div",$N,[e.withDirectives(e.createVNode(Ss,{ref_key:"pixiPreviewRef",ref:_,class:"v2-preview-child","aria-hidden":!$.value,source:j.value,"fallback-duration":L.value,filters:E.value,playhead:A.value,"is-playing":e.unref(s).isPlaying.value,"fit-mode":x.value,active:$.value,onPlayPause:pa,onFrameUpdate:O,onDurationChange:w},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active"]),[[e.vShow,$.value]]),e.withDirectives(e.createVNode(Us,{class:"v2-preview-child","aria-hidden":!D.value,"media-uuid":r.value,recipe:R.value,media:z.value,"enable-engine":D.value&&P.value,"fit-mode":x.value,onTimeUpdate:Z,onPlayStateChange:G,onDurationChange:w,onEngineReady:Rt},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,D.value]])])]),timeline:e.withCtx(({isMobile:Q})=>{var me,Ae;return[e.createElementVNode("div",{class:e.normalizeClass(["v2-timeline",{"is-mobile":!!Q}])},[e.createElementVNode("div",DN,[e.createElementVNode("div",RN,[F[20]||(F[20]=e.createElementVNode("span",{class:"v2-timeline-title","data-testid":"v2-timeline-title"},"Timeline",-1)),e.createElementVNode("span",AN,e.toDisplayString(In.value),1)]),e.createElementVNode("label",LN,[F[21]||(F[21]=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:Jt},null,40,PN),e.createElementVNode("span",ON,e.toDisplayString(Math.round(e.unref(s).zoomLevel.value))+" px/s",1)]),Q?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",UN,[e.createElementVNode("button",{type:"button",class:"v2-toolbar-btn v2-toolbar-btn--ghost","data-testid":"v2-btn-add-track",onClick:F[1]||(F[1]=De=>vo("video"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Li)},null,8,["icon"]),F[22]||(F[22]=e.createTextVNode(" Add Track ",-1))]),Qn.value.length>0?(e.openBlock(),e.createElementBlock("label",zN,[F[23]||(F[23]=e.createElementVNode("span",null,"Place clips in",-1)),e.createElementVNode("select",{value:Ut.value??"","data-testid":"v2-select-target-track","aria-label":"Target track for added assets",onChange:jr},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Qn.value,De=>(e.openBlock(),e.createElementBlock("option",{key:De.id,value:De.id},e.toDisplayString(De.name),9,WN))),128))],40,jN)])):e.createCommentVNode("",!0)])),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["v2-toolbar-btn v2-toolbar-btn--ghost",{"is-active":an.value}]),"data-testid":"v2-btn-snap-toggle","aria-pressed":an.value?"true":"false",onClick:ja},e.toDisplayString(an.value?"Snap On":"Snap Off"),11,ZN)]),e.createVNode(zs,{playhead:e.unref(s).playheadPosition.value,clips:e.unref(s).timelineClips.value,tracks:jn.value,"selected-clip-id":((me=e.unref(s).selectedClip.value)==null?void 0:me.id)??((Ae=e.unref(s).timelineClips.value[0])==null?void 0:Ae.id)??null,duration:L.value,fps:e.unref(s).fps.value,"is-mobile":!!Q,"zoom-level":e.unref(s).zoomLevel.value,"snap-enabled":an.value,sensitivity:.25,"onUpdate:playhead":F[2]||(F[2]=De=>e.unref(s).seekTo(De)),onTrim:F[3]||(F[3]=(De,Ge,ht)=>e.unref(s).handleTrim(De,Ge,ht)),onSplit:F[4]||(F[4]=De=>e.unref(s).handleSplit(De)),onClipSelect:Wr,onClipDelete:go,onClipMove:F[5]||(F[5]=(De,Ge)=>e.unref(s).moveClip(De,Ge)),onSnapStateChange:Zr,onToggleLock:F[6]||(F[6]=De=>za(De,e.unref(s).toggleTrackLock)),onToggleHidden:F[7]||(F[7]=De=>za(De,e.unref(s).toggleTrackHidden)),onToggleMuted:F[8]||(F[8]=De=>za(De,e.unref(s).toggleTrackMuted)),onToggleSolo:F[9]||(F[9]=De=>za(De,e.unref(s).toggleTrackSolo))},null,8,["playhead","clips","tracks","selected-clip-id","duration","fps","is-mobile","zoom-level","snap-enabled"]),e.createVNode(js,{"selected-clip":e.unref(s).selectedClip.value,"can-split":mi.value,"can-delete":pi.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":!!Q,"show-add-track":!!Q,onSplit:e.unref(s).splitAtPlayhead,onDelete:e.unref(s).deleteSelectedClip,onAddTrack:F[10]||(F[10]=De=>vo("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:pa,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(()=>[je.value.length>0?(e.openBlock(),e.createBlock(bd,{key:0,class:"v2-draft-recovery",records:je.value,surface:"desktop","project-id":He.value,"saved-at":Re.value,onRestore:Xt,onDismiss:hn},null,8,["records","project-id","saved-at"])):e.createCommentVNode("",!0),e.createVNode(zV,{"active-tab":c.value,"onUpdate:activeTab":F[11]||(F[11]=Q=>c.value=Q),tabs:f.value},{filters:e.withCtx(()=>[e.createVNode(Ws,{filters:re.value,"active-filters":be.value,"thumbnail-url":Ee.value,onApplyFilter:tn,onRemoveFilter:zn,onUpdateParam:Yn,onPreviewFilter:q},null,8,["filters","active-filters","thumbnail-url"])]),adjustments:e.withCtx(()=>[e.unref(l).selectedFilter.value?(e.openBlock(),e.createBlock(Zs,{key:0,filter:e.unref(l).selectedFilter.value,"current-frame":e.unref(s).currentFrame.value,onUpdateParams:le},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",HN,[...F[24]||(F[24]=[e.createElementVNode("p",null,"Select a filter from the Filters tab to adjust its parameters.",-1)])])),e.createVNode(wd,{class:"v2-keyframe-panel",duration:ct.value,target:"all","device-class":"desktop",onApplyPreset:fn},null,8,["duration"])]),text:e.withCtx(()=>[e.createVNode(Xs,{overlays:Se.value,onAddOverlay:oe,onUpdateOverlay:se,onRemoveOverlay:Ce},null,8,["overlays"]),e.createVNode(yd,{class:"v2-caption-panel","caption-track":Oe.value,layout:"desktop",onImport:da,"onUpdate:captionTrack":kn,onClear:pn},null,8,["caption-track"])]),transitions:e.withCtx(()=>[e.createVNode(Gs,{"selected-clips":Pt.value,"applied-transitions":bt.value,onApplyTransition:Ve,onRemoveTransition:Je,onPreviewTransition:st},null,8,["selected-clips","applied-transitions"])]),audio:e.withCtx(()=>[e.createVNode(Js,{"audio-layers":it.value,"master-volume":wt.value,onAddTrack:ut,onUpdateTrack:nt,onRemoveTrack:kt,onUpdateVolume:At,onToggleMute:nn,onUpdateMasterVolume:qn},null,8,["audio-layers","master-volume"]),e.createVNode(gd,{class:"v2-audio-mixer",state:dt.value,"device-class":"desktop",onUpdate:Aa},null,8,["state"])]),export:e.withCtx(()=>[e.createVNode(Hs,{"can-export":e.unref(s).hasChanges.value,"is-exporting":_t.value,"export-progress":Wn.value,onExport:ma,onCancelExport:bo,onSaveDraft:ha,onReset:fa},null,8,["can-export","is-exporting","export-progress"]),vn.value?(e.openBlock(),e.createElementBlock("div",XN," Export complete ")):e.createCommentVNode("",!0),ft.value&&!vn.value?(e.openBlock(),e.createElementBlock("div",GN,e.toDisplayString(ft.value),1)):e.createCommentVNode("",!0)]),_:1},8,["active-tab","tabs"])]),drawer:e.withCtx(()=>[e.createVNode(xN,{"initial-snap":"half","aria-label":"Video editor controls"},{default:e.withCtx(()=>[je.value.length>0?(e.openBlock(),e.createBlock(bd,{key:0,class:"v2-draft-recovery",records:je.value,surface:"mobile","project-id":He.value,"saved-at":Re.value,onRestore:Xt,onDismiss:hn},null,8,["records","project-id","saved-at"])):e.createCommentVNode("",!0),e.createVNode(pN,{"selected-clip":Oa.value,onOpenActions:F[12]||(F[12]=Q=>d.value="trim")},null,8,["selected-clip"]),e.createVNode(yN,{modelValue:d.value,"onUpdate:modelValue":F[13]||(F[13]=Q=>d.value=Q)},null,8,["modelValue"]),d.value==="look"?(e.openBlock(),e.createElementBlock("section",JN,[e.createElementVNode("div",KN,[e.createVNode(Ws,{filters:re.value,"active-filters":be.value,"thumbnail-url":Ee.value,onApplyFilter:tn,onRemoveFilter:zn,onUpdateParam:Yn,onPreviewFilter:q},null,8,["filters","active-filters","thumbnail-url"])]),e.createElementVNode("div",YN,[e.unref(l).selectedFilter.value?(e.openBlock(),e.createBlock(Zs,{key:0,filter:e.unref(l).selectedFilter.value,"current-frame":e.unref(s).currentFrame.value,onUpdateParams:le},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",qN,[...F[25]||(F[25]=[e.createElementVNode("p",null,"Select a filter from the Filters tab to adjust its parameters.",-1)])]))])])):d.value==="trim"?(e.openBlock(),e.createElementBlock("section",QN,[e.createVNode(js,{"selected-clip":e.unref(s).selectedClip.value,"can-split":mi.value,"can-delete":pi.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:F[14]||(F[14]=Q=>vo("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:pa,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"])])):d.value==="text"?(e.openBlock(),e.createElementBlock("section",e4,[e.createVNode(Xs,{overlays:Se.value,onAddOverlay:oe,onUpdateOverlay:se,onRemoveOverlay:Ce},null,8,["overlays"]),e.createVNode(yd,{"caption-track":Oe.value,layout:"mobile",onImport:da,"onUpdate:captionTrack":kn,onClear:pn},null,8,["caption-track"])])):d.value==="audio"?(e.openBlock(),e.createElementBlock("section",t4,[e.createVNode(Js,{"audio-layers":it.value,"master-volume":wt.value,onAddTrack:ut,onUpdateTrack:nt,onRemoveTrack:kt,onUpdateVolume:At,onToggleMute:nn,onUpdateMasterVolume:qn},null,8,["audio-layers","master-volume"]),e.createVNode(gd,{state:dt.value,"device-class":"mobile",onUpdate:Aa},null,8,["state"])])):d.value==="export"?(e.openBlock(),e.createElementBlock("section",n4,[e.createVNode(Hs,{"can-export":e.unref(s).hasChanges.value,"is-exporting":_t.value,"export-progress":Wn.value,"is-mobile":"",onExport:ma,onCancelExport:bo,onSaveDraft:ha,onReset:fa},null,8,["can-export","is-exporting","export-progress"]),vn.value?(e.openBlock(),e.createElementBlock("div",a4,"Export complete")):e.createCommentVNode("",!0),ft.value&&!vn.value?(e.openBlock(),e.createElementBlock("div",o4,e.toDisplayString(ft.value),1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("section",i4,[e.createElementVNode("div",r4,[e.createElementVNode("label",s4,[F[27]||(F[27]=e.createElementVNode("span",null,"Fit",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":F[15]||(F[15]=Q=>x.value=Q),"aria-label":"Mobile fit mode"},[...F[26]||(F[26]=[e.createElementVNode("option",{value:"contain"},"Contain",-1),e.createElementVNode("option",{value:"cover"},"Cover",-1),e.createElementVNode("option",{value:"none"},"None",-1)])],512),[[e.vModelSelect,x.value]])]),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["v2-mobile-secondary-button",{"is-active":an.value}]),"aria-pressed":an.value?"true":"false","data-testid":"v2-mobile-btn-snap-toggle",onClick:ja},e.toDisplayString(an.value?"Snap On":"Snap Off"),11,l4),e.createElementVNode("button",{type:"button",class:"v2-mobile-secondary-button","data-testid":"v2-mobile-btn-reset",disabled:!e.unref(s).hasChanges.value,onClick:fa}," Reset ",8,c4),e.createElementVNode("button",{type:"button",class:"v2-mobile-secondary-button","data-testid":"v2-mobile-btn-save",disabled:!e.unref(s).hasChanges.value,onClick:ha}," Save ",8,d4)]),h.value?(e.openBlock(),e.createElementBlock("details",u4,[F[28]||(F[28]=e.createElementVNode("summary",null,"Transitions",-1)),e.createVNode(Gs,{"selected-clips":Pt.value,"applied-transitions":bt.value,onApplyTransition:Ve,onRemoveTransition:Je,onPreviewTransition:st},null,8,["selected-clips","applied-transitions"])])):e.createCommentVNode("",!0),e.createElementVNode("details",m4,[F[29]||(F[29]=e.createElementVNode("summary",null,"Keyframe presets",-1)),e.createVNode(wd,{duration:ct.value,target:"all","device-class":"mobile",onApplyPreset:fn},null,8,["duration"])])]))]),_:1})]),_:1}))}}),f4=Me(p4,[["__scopeId","data-v-76166089"]]),Vn=a=>a===null||typeof a!="object"||Array.isArray(a)?null:a,et=a=>{if(typeof a=="number"&&Number.isFinite(a))return a;if(typeof a=="string"){const n=Number(a);return Number.isFinite(n)?n:null}return null},h4=(a,n)=>{if(n===null)return;const t=Vn(a.source)??{},o=et(t.duration);if(!(o!==null&&o>0&&o<=1&&n>o))return;t.duration=n,a.source=t;const r=Array.isArray(a.timeline)?a.timeline:[];if(r.length===1){const c=Vn(r[0]);if(c!==null){const d=et(c.sourceIn)??0,u=et(c.sourceOut)??et(c.end)??et(c.timelineEnd);if(d===0&&u!==null&&u>0&&u<=1){c.sourceOut=n;const p=et(c.end);p!==null&&p>0&&p<=1&&(c.end=n);const m=et(c.timelineEnd);m!==null&&m>0&&m<=1&&(c.timelineEnd=n)}}}const s=et(a.trimEnd)??et(a.trim_end);s!==null&&s>0&&s<=1&&(a.trimEnd=n);const l=Vn(a.trim);if(l!==null){const c=et(l.end);c!==null&&c>0&&c<=1&&(l.end=n,a.trim=l)}},v4=(a,n)=>{if(!a)return!1;const t=Vn(a);if(t===null)return!1;const o=Vn(t.trim),i=Vn(t.source),s=et(i==null?void 0:i.duration)??n,l=Array.isArray(a.filters)&&a.filters.length>0;let c=!1;if(Array.isArray(a.timeline)&&a.timeline.length===1){const m=a.timeline[0];m&&Array.isArray(m.filters)&&m.filters.length>0&&(c=!0)}let d=!1;const u=et(t.trimStart)??et(t.trim_start)??et(o==null?void 0:o.start),f=et(t.trimEnd)??et(t.trim_end)??et(o==null?void 0:o.end);if(u!==null&&u>0&&(d=!0),f!==null&&s!==void 0&&f<s&&(d=!0),!d&&Array.isArray(a.timeline)&&a.timeline.length===1){const m=a.timeline[0];if(m){const h=et(m.sourceIn),g=et(m.sourceOut);h!==null&&h>0&&(d=!0),g!==null&&s!==void 0&&g<s&&(d=!0)}}let p=!1;if(Array.isArray(a.timeline)&&a.timeline.length===1){const m=a.timeline[0];if(m){const h=et(m.speed);p=h!==null&&h!==1}}return l||c||d||p},Pm=a=>{if(!a)return!1;const n=Vn(a);return n===null?!1:!!(Array.isArray(n.textOverlays)&&n.textOverlays.length>0||Array.isArray(n.transitions)&&n.transitions.length>0||Array.isArray(a.timeline)&&a.timeline.length>1)},g4=(a,n={})=>{var p,m;const t=JSON.parse(JSON.stringify(a)),o=Array.isArray(t.timeline)?t.timeline:[],i=o.length>0?Vn(o[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,o.length===1&&i!==null){const h=et(i.sourceIn),g=et(i.sourceOut);h!==null&&t.trimStart===void 0&&(t.trimStart=h),g!==null&&t.trimEnd===void 0&&(t.trimEnd=g)}const l=Vn(t.trim);if(t.trimStart===void 0){const h=et(l==null?void 0:l.start);h!==null&&(t.trimStart=h)}if(t.trimEnd===void 0){const h=et(l==null?void 0:l.end);h!==null&&(t.trimEnd=h)}const c=Vn(t.source),d=et(t.width)??et(c==null?void 0:c.original_width)??et((p=n.exportMeta)==null?void 0:p.width);d!==null&&(t.width=d);const u=et(t.height)??et(c==null?void 0:c.original_height)??et((m=n.exportMeta)==null?void 0:m.height);u!==null&&(t.height=u);const f=Vn(t.output);return t.fps=et(t.fps)??et(f==null?void 0:f.fps)??30,h4(t,n.mediaDuration??null),t},y4={key:0},b4=["data-testid"],w4={class:"ve-mobile-header"},k4=["data-testid"],_4={class:"ve-mobile-title"},E4=["data-testid","disabled"],x4={key:1,class:"ve-mobile-spacer","aria-hidden":"true"},S4={class:"ve-body"},C4=["data-testid"],V4=["aria-label"],N4={class:"ve-header"},T4={class:"ve-title"},M4=["data-testid"],B4={class:"ve-body"},I4={class:"ve-footer"},F4=["data-testid"],$4=["data-testid","disabled"],D4=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(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>o.dataTestId),s=e.computed(()=>o.open),l=e.computed(()=>o.saveImmediate===!1),c=e.computed(()=>o.closeText),d=e.computed(()=>f.value?o.savingText:o.confirmText),u=e.ref(typeof window<"u"?window.innerWidth<768:!1),f=e.ref(!1),p=e.ref(!1),m=e.ref(null),h=`temp-${Date.now()}`,g=e.computed(()=>{var w;const L=(w=o.featureFlags)==null?void 0:w.export;return typeof L=="boolean"?L:o.workflowMode==="full"}),k=e.computed(()=>{if(o.editorVersion==="v1"||o.editorVersion==="v2")return o.editorVersion;if(typeof window>"u")return"v2";try{const L=new URLSearchParams(window.location.search),w=L.get("editor")??L.get("video-editor");if(w==="v1")return"v1";if(w==="v2")return"v2"}catch{}return"v2"}),$=e.computed(()=>k.value==="v2"?f4:Lm),D=e.computed(()=>typeof o.mediaUuid=="string"&&o.mediaUuid.trim()!==""?o.mediaUuid.trim():o.media&&o.media.uuid.trim()!==""?o.media.uuid.trim():h),_=e.computed(()=>{const L={showThumbnailPicker:o.showThumbnailPicker,workflowMode:o.workflowMode,clientExportThreshold:o.clientExportThreshold,maxDuration:o.maxDuration,serverRenderEndpoint:o.serverRenderEndpoint};return o.featureFlags!==void 0&&(L.featureFlags=o.featureFlags),o.initialRecipe!==void 0&&(L.initialRecipe=o.initialRecipe),o.media!==void 0&&(L.media=o.media),L}),v=()=>{u.value=window.innerWidth<768};e.onMounted(()=>{window.addEventListener("resize",v)}),e.onUnmounted(()=>{window.removeEventListener("resize",v)}),e.onErrorCaptured(()=>(p.value=!0,!1));const S=L=>{const w=Array.isArray(L.timeline)?L.timeline:[];if(w.length===0)return 0;let O=0;for(const Z of w){const G=Number(Z.sourceIn),re=Number(Z.sourceOut),be=Number(Z.speed??1),Ee=Number.isFinite(be)&&be>0?be:1;if(Number.isFinite(G)&&Number.isFinite(re)&&re>G){O+=(re-G)/Ee;continue}const ie=Number(Z.timelineStart),R=Number(Z.timelineEnd);Number.isFinite(ie)&&Number.isFinite(R)&&R>ie&&(O+=R-ie)}return O},C=(L,w,O)=>{let Z=null;const G=new Promise((re,be)=>{Z=setTimeout(()=>be(new Error(`${O} timed out after ${w}ms`)),w)});return Promise.race([L,G]).finally(()=>{Z!==null&&clearTimeout(Z)})},V=()=>{var G;const O=(G=o.media)==null?void 0:G.duration;if(typeof O!="number"||!Number.isFinite(O)||O<=0)return 12e3;const Z=Math.round(O*1e3);return Math.min(45e3,Math.max(12e3,Z))},x=()=>{i("close"),i("update:open",!1)},T=()=>{f.value=!1,x()},j=L=>{i("recipe-generated",L)},E=L=>{i("export-started",L),i("save-started",L)},A=L=>{i("video-exported",L)},N=L=>{i("thumbnail-selected",L)},z=(L,w,O)=>{i("save-recipe",L);const Z={recipe:L,exportPayload:w};O!==void 0&&(Z.toastDescription=O),i("save-complete",Z),x()},P=L=>{f.value||(i("draft-saved",L),z(L,null))},B=async()=>{var L;if(!f.value){if(p.value||m.value===null){i("save-error",{code:"save-failed",message:"Unable to save video edits. Please try again."}),x();return}f.value=!0;try{const w=await C(m.value.saveDraft(),V(),"saveDraft");let O=null,Z=!1,G;const re=S(w),be=re>0?re:((L=o.media)==null?void 0:L.duration)??0;if(g.value&&be>0&&be<=o.clientExportThreshold&&typeof m.value.exportForUpload=="function"){Z=!0;const ie=Math.min(9e4,Math.max(15e3,o.clientExportThreshold*2e3));try{O=await C(m.value.exportForUpload(w),ie,"exportForUpload")}catch{O=null}}if(Pm(w)&&O===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}Z&&O===null&&(G="Video edits saved. Final render will happen when you share."),z(w,O,G)}catch{i("save-error",{code:"save-failed",message:"Unable to save video edits. Please try again."}),x()}finally{f.value=!1}}};return n({saveDraft:B}),(L,w)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[s.value?(e.openBlock(),e.createElementBlock("div",y4,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"ve-fullscreen","data-testid":r.value},[e.createElementVNode("header",w4,[e.createElementVNode("button",{class:"ve-mobile-action",type:"button","data-testid":`${r.value}-close-button`,onClick:T},e.toDisplayString(c.value),9,k4),e.createElementVNode("h2",_4,e.toDisplayString(L.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:B},e.toDisplayString(d.value),9,E4)):(e.openBlock(),e.createElementBlock("span",x4))]),e.createElementVNode("section",S4,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent($.value),e.mergeProps({ref_key:"videoEditorRef",ref:m,"media-uuid":D.value,"data-editor-version":k.value},_.value,{onClose:T,onDraftSaved:P,onExportStarted:E,onRecipeGenerated:j,onThumbnailSelected:N,onVideoExported:A}),null,16,["media-uuid","data-editor-version"]))])],8,b4)):(e.openBlock(),e.createElementBlock("div",{key:1,class:"ve-overlay","data-testid":r.value,onClick:e.withModifiers(T,["self"])},[e.createElementVNode("div",{class:"ve-dialog",role:"dialog","aria-label":L.title,"aria-modal":"true"},[e.createElementVNode("header",N4,[e.createElementVNode("h2",T4,e.toDisplayString(L.title),1),e.createElementVNode("button",{class:"ve-close",type:"button","data-testid":`${r.value}-close-button`,"aria-label":"Close",onClick:T}," ✕ ",8,M4)]),e.createElementVNode("section",B4,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent($.value),e.mergeProps({ref_key:"videoEditorRef",ref:m,"media-uuid":D.value,"data-editor-version":k.value},_.value,{onClose:T,onDraftSaved:P,onExportStarted:E,onRecipeGenerated:j,onThumbnailSelected:N,onVideoExported:A}),null,16,["media-uuid","data-editor-version"]))]),e.createElementVNode("footer",I4,[e.renderSlot(L.$slots,"footer",{close:T,isSaving:f.value,save:B},()=>[e.createElementVNode("button",{class:"ve-btn",type:"button","data-testid":`${r.value}-cancel-button`,onClick:T},e.toDisplayString(c.value),9,F4),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:B},e.toDisplayString(d.value),9,$4)):e.createCommentVNode("",!0)],!0)])],8,V4)],8,C4))])):e.createCommentVNode("",!0)]))}}),R4=Me(D4,[["__scopeId","data-v-3cc6e078"]]),A4={class:"video-editor-modal"},L4={class:"video-preview-container"},P4=["src"],O4={class:"video-overlay-controls"},U4=["aria-label"],z4={class:"time-display"},j4={class:"timeline-container"},W4={class:"clip-name"},Z4={class:"timeline-time-labels"},H4={class:"tool-tabs"},X4=["onClick"],G4={class:"tool-panel"},J4={key:0,class:"trim-panel"},K4={class:"trim-controls"},Y4={key:1,class:"filters-panel"},q4={class:"filter-grid"},Q4=["onClick"],eT={key:2,class:"text-panel"},tT={key:3,class:"transitions-panel"},nT={class:"transition-grid"},aT=["onClick"],oT={class:"action-buttons"},iT=e.defineComponent({__name:"VideoEditorSimple",props:{media:{}},emits:["save","cancel"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(""),s=e.ref(!1),l=e.ref(0),c=e.ref(0),d=e.ref("video-1"),u=e.ref(0),f=e.ref(0),p=e.ref(null),m=e.ref("trim"),h=e.ref(null),g=e.ref(""),k=[{id:"trim",label:"Trim",icon:Yi},{id:"filters",label:"Filters",icon:Mf},{id:"text",label:"Text",icon:Xd},{id:"transitions",label:"Transitions",icon:Lf}],$=[{id:"none",name:"None"},{id:"grayscale",name:"Grayscale"},{id:"sepia",name:"Sepia"},{id:"blur",name:"Blur"},{id:"brightness",name:"Brightness"},{id:"contrast",name:"Contrast"}],D=[{id:"fade",name:"Fade"},{id:"slide",name:"Slide"},{id:"zoom",name:"Zoom"},{id:"wipe",name:"Wipe"}],_=e.ref();e.onMounted(()=>{var w,O;(w=t.media)!=null&&w.url?r.value=t.media.url:(O=t.media)!=null&&O.file&&(r.value=URL.createObjectURL(t.media.file))}),e.onUnmounted(()=>{var w;(w=t.media)!=null&&w.file&&r.value&&URL.revokeObjectURL(r.value)});function v(){i.value&&(c.value=i.value.duration,f.value=c.value)}function S(){i.value&&(l.value=i.value.currentTime)}function C(){s.value=!1}function V(){i.value&&(s.value?(i.value.pause(),s.value=!1):(i.value.play(),s.value=!0))}function x(w){if(!w||isNaN(w))return"00:00";const O=Math.floor(w/60),Z=Math.floor(w%60);return`${O.toString().padStart(2,"0")}:${Z.toString().padStart(2,"0")}`}function T(w){if(!i.value||!_.value)return;const O=_.value.getBoundingClientRect(),re=(w.clientX-O.left)/O.width*c.value;i.value.currentTime=Math.max(0,Math.min(re,c.value))}function j(){u.value=l.value}function E(){f.value=l.value}function A(){u.value=0,f.value=c.value}function N(w){p.value=w;const O=G=>{if(!p.value||!_.value)return;const re=_.value.getBoundingClientRect(),ie=(G.clientX-re.left)/re.width*c.value;p.value==="start"?u.value=Math.max(0,Math.min(ie,f.value-1)):f.value=Math.max(u.value+1,Math.min(ie,c.value))},Z=()=>{p.value=null,document.removeEventListener("mousemove",O),document.removeEventListener("mouseup",Z)};document.addEventListener("mousemove",O),document.addEventListener("mouseup",Z)}function z(w){if(h.value=w,!i.value)return;const O={none:"none",grayscale:"grayscale(100%)",sepia:"sepia(100%)",blur:"blur(5px)",brightness:"brightness(150%)",contrast:"contrast(150%)"};i.value.style.filter=O[w]||"none"}function P(){}function B(w){}function L(){const w={timeline:[{id:d.value,url:r.value,startTime:0,endTime:c.value,sourceIn:u.value,sourceOut:f.value,track:0}],filters:h.value?[{type:h.value}]:[],textOverlays:g.value?[{content:g.value}]:[],duration:f.value-u.value};o("save",w)}return(w,O)=>(e.openBlock(),e.createElementBlock("div",A4,[e.createElementVNode("div",L4,[e.createElementVNode("video",{ref_key:"videoElement",ref:i,class:"video-preview",src:r.value,onLoadedmetadata:v,onTimeupdate:S,onEnded:C,controls:""},null,40,P4),e.createElementVNode("div",O4,[e.createElementVNode("button",{class:"play-pause-btn",onClick:V,"aria-label":s.value?"Pause":"Play"},[e.createVNode(e.unref(U.IonIcon),{icon:s.value?e.unref(zf):e.unref(Hf)},null,8,["icon"])],8,U4),e.createElementVNode("div",z4,e.toDisplayString(x(l.value))+" / "+e.toDisplayString(x(c.value)),1)])]),e.createElementVNode("div",j4,[e.createElementVNode("div",{class:"timeline-track",onClick:T,ref_key:"timelineTrack",ref:_},[e.createElementVNode("div",{class:"timeline-clip",style:e.normalizeStyle({left:`${u.value/c.value*100}%`,right:`${100-f.value/c.value*100}%`})},[e.createElementVNode("span",W4,e.toDisplayString(d.value),1)],4),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:`${l.value/c.value*100}%`})},null,4),m.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:0,class:"trim-handle trim-start",style:e.normalizeStyle({left:`${u.value/c.value*100}%`}),onMousedown:O[0]||(O[0]=Z=>N("start"))},null,36)):e.createCommentVNode("",!0),m.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:1,class:"trim-handle trim-end",style:e.normalizeStyle({left:`${f.value/c.value*100}%`}),onMousedown:O[1]||(O[1]=Z=>N("end"))},null,36)):e.createCommentVNode("",!0)],512),e.createElementVNode("div",Z4,[e.createElementVNode("span",null,e.toDisplayString(x(0)),1),e.createElementVNode("span",null,e.toDisplayString(x(c.value)),1)])]),e.createElementVNode("div",H4,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(k,Z=>e.createElementVNode("button",{key:Z.id,class:e.normalizeClass(["tool-tab",{active:m.value===Z.id}]),onClick:G=>m.value=Z.id},[e.createVNode(e.unref(U.IonIcon),{icon:Z.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(Z.label),1)],10,X4)),64))]),e.createElementVNode("div",G4,[m.value==="trim"?(e.openBlock(),e.createElementBlock("div",J4,[O[7]||(O[7]=e.createElementVNode("h3",null,"Trim Video",-1)),O[8]||(O[8]=e.createElementVNode("p",null,"Click and drag on the timeline to set trim points",-1)),e.createElementVNode("div",K4,[e.createElementVNode("button",{class:"btn-trim",onClick:j},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(fc)},null,8,["icon"]),O[4]||(O[4]=e.createTextVNode(" Set Start ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:E},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(fc)},null,8,["icon"]),O[5]||(O[5]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:A},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Na)},null,8,["icon"]),O[6]||(O[6]=e.createTextVNode(" Clear ",-1))])])])):m.value==="filters"?(e.openBlock(),e.createElementBlock("div",Y4,[O[9]||(O[9]=e.createElementVNode("h3",null,"Filters",-1)),e.createElementVNode("div",q4,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList($,Z=>e.createElementVNode("button",{key:Z.id,class:e.normalizeClass(["filter-option",{active:h.value===Z.id}]),onClick:G=>z(Z.id)},e.toDisplayString(Z.name),11,Q4)),64))])])):m.value==="text"?(e.openBlock(),e.createElementBlock("div",eT,[O[10]||(O[10]=e.createElementVNode("h3",null,"Text Overlay",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":O[2]||(O[2]=Z=>g.value=Z),type:"text",placeholder:"Enter text...",class:"text-input"},null,512),[[e.vModelText,g.value]]),e.createElementVNode("button",{class:"btn-add-text",onClick:P},"Add Text")])):m.value==="transitions"?(e.openBlock(),e.createElementBlock("div",tT,[O[11]||(O[11]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",nT,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(D,Z=>e.createElementVNode("button",{key:Z.id,class:"transition-option",onClick:G=>(Z.id,void 0)},e.toDisplayString(Z.name),9,aT)),64))])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",oT,[e.createElementVNode("button",{class:"btn-cancel",onClick:O[3]||(O[3]=Z=>w.$emit("cancel"))},"CANCEL"),e.createElementVNode("button",{class:"btn-save",onClick:L},"SAVE")])]))}}),rT=Me(iT,[["__scopeId","data-v-b933f33b"]]),sT={class:"time-label"},lT=e.defineComponent({__name:"TimeRuler",props:{duration:{},zoom:{}},setup(a){const n=a,t=e.computed(()=>({width:`${n.duration*n.zoom*100}px`})),o=e.computed(()=>{const s=[],l=i(n.duration,n.zoom);for(let c=0;c<=n.duration;c+=l){const d=`${c/n.duration*100}%`,u=r(c),f=c%(l*5)===0;s.push({time:c,position:d,label:u,major:f})}return s});function i(s,l){const c=s/(10*l);return c<=1?1:c<=5?5:c<=10?10:c<=30?30:c<=60?60:Math.ceil(c/60)*60}function r(s){const l=Math.floor(s/60),c=Math.floor(s%60);return l===0?`${c}s`:c===0?`${l}m`:`${l}:${c.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(o.value,c=>(e.openBlock(),e.createElementBlock("div",{key:c.time,class:"time-mark",style:e.normalizeStyle({left:c.position})},[e.createElementVNode("span",sT,e.toDisplayString(c.label),1),e.createElementVNode("div",{class:e.normalizeClass(["time-tick",{major:c.major}])},null,2)],4))),128))],4))}}),cT=Me(lT,[["__scopeId","data-v-0ef9c910"]]),dT=["data-track-index"],uT={class:"track-header"},mT={class:"track-label"},pT={class:"track-controls"},fT=["data-testid","aria-label"],hT=["data-testid","onMousedown","onClick"],vT={class:"clip-content"},gT={class:"clip-name"},yT={key:0,class:"clip-thumbnail"},bT=["src","alt"],wT=["onMousedown","aria-label"],kT=["onMousedown","aria-label"],_T=e.defineComponent({__name:"VideoTrack",props:{clips:{},trackIndex:{},zoom:{},duration:{}},emits:["clip-move","clip-trim","clip-select"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(null),r=e.ref(!1),s=e.ref(!1),l=e.ref(null),c=e.computed(()=>({width:`${t.duration*t.zoom*100}px`}));function d(k){const $=k.timelineEnd-k.timelineStart,D=k.timelineStart/t.duration*100,_=$/t.duration*100;return{left:`${D}%`,width:`${_}%`,backgroundColor:u(k)}}function u(k){const $=["#4A90E2","#7ED321","#F5A623","#BD10E0","#9013FE","#50E3C2","#B8E986","#F8E71C"],D=parseInt(k.id.replace(/\D/g,""))%$.length;return $[D]}function f(k){return k.label?k.label:k.url?(k.url.split("/").pop()||"Clip").split(".")[0]:`Clip ${k.id.slice(-4)}`}function p(k){i.value=k.id,o("clip-select",k.id)}function m(){r.value=!r.value}function h(k,$){if(l.value)return;s.value=!0;const D=$.clientX,_=k.timelineStart,v=C=>{if(!s.value)return;const V=C.clientX-D,x=parseFloat(c.value.width),T=V/(t.zoom*100)*(t.duration/x),j=Math.max(0,_+T);o("clip-move",k.id,j)},S=()=>{s.value=!1,document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",S)};document.addEventListener("mousemove",v),document.addEventListener("mouseup",S)}function g(k,$,D){l.value=$;const _=D.clientX,v=k.sourceIn,S=k.sourceOut,C=x=>{if(!l.value)return;const T=x.clientX-_,j=parseFloat(c.value.width),E=T/(t.zoom*100)*(t.duration/j);if(l.value==="start"){const A=Math.max(0,v+E);o("clip-trim",k.id,A,S)}else{const A=Math.max(v+1,S+E);o("clip-trim",k.id,v,A)}},V=()=>{l.value=null,document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",V)};document.addEventListener("mousemove",C),document.addEventListener("mouseup",V)}return(k,$)=>(e.openBlock(),e.createElementBlock("div",{class:"video-track","data-track-index":k.trackIndex},[e.createElementVNode("div",uT,[e.createElementVNode("span",mT,"Track "+e.toDisplayString(k.trackIndex+1),1),e.createElementVNode("div",pT,[k.clips.length>0?(e.openBlock(),e.createElementBlock("button",{key:0,class:"track-btn","data-testid":`btn-mute-track-${k.trackIndex}`,"aria-label":`${r.value?"Unmute":"Mute"} track ${k.trackIndex+1}`,onClick:m},[e.createVNode(e.unref(U.IonIcon),{icon:r.value?e.unref(rh):e.unref(oh)},null,8,["icon"])],8,fT)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",{class:"track-timeline",style:e.normalizeStyle(c.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.clips,D=>(e.openBlock(),e.createElementBlock("div",{key:D.id,class:e.normalizeClass(["timeline-clip",{selected:D.id===i.value}]),style:e.normalizeStyle(d(D)),"data-testid":`clip-${D.id}`,onMousedown:_=>h(D,_),onClick:_=>p(D)},[e.createElementVNode("div",vT,[e.createElementVNode("span",gT,e.toDisplayString(f(D)),1),D.thumbnail?(e.openBlock(),e.createElementBlock("div",yT,[e.createElementVNode("img",{src:D.thumbnail,alt:f(D)},null,8,bT)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:e.withModifiers(_=>g(D,"start",_),["stop"]),"aria-label":`Trim start of ${f(D)}`},null,40,wT),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:e.withModifiers(_=>g(D,"end",_),["stop"]),"aria-label":`Trim end of ${f(D)}`},null,40,kT)],46,hT))),128))],4)],8,dT))}}),ET=Me(_T,[["__scopeId","data-v-48e480d2"]]),xT={class:"video-timeline"},ST={class:"timeline-tracks"},CT=["aria-label","aria-valuenow","aria-valuemax"],VT={class:"timeline-controls"},NT={class:"zoom-level"},TT=e.defineComponent({__name:"VideoTimeline",props:{clips:{},duration:{},currentTime:{}},emits:["update:clips","seek","clip-move","clip-trim"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(1),r=e.ref(null),s=e.ref(!1),l=e.ref(),c=e.computed(()=>{const _=Math.max(0,...t.clips.map(v=>v.track||0));return Array(_+1).fill(null)}),d=e.computed(()=>`${t.currentTime/t.duration*100}%`);function u(_){return t.clips.filter(v=>(v.track||0)===_)}function f(_){const v=Math.floor(_/60),S=Math.floor(_%60);return`${v}:${S.toString().padStart(2,"0")}`}function p(_,v){o("clip-move",_,v)}function m(_,v,S){o("clip-trim",_,v,S)}function h(_){r.value=_}function g(){i.value=Math.min(i.value*1.2,5)}function k(){i.value=Math.max(i.value/1.2,.5)}function $(){s.value=!0;const _=S=>{if(!s.value||!l.value)return;const C=l.value.getBoundingClientRect(),T=Math.max(0,Math.min(S.clientX-C.left,C.width))/C.width*t.duration;o("seek",T)},v=()=>{s.value=!1,document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",v)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",v)}function D(_){let v=t.currentTime;switch(_.key){case"ArrowLeft":v=Math.max(0,t.currentTime-1);break;case"ArrowRight":v=Math.min(t.duration,t.currentTime+1);break;case"Home":v=0;break;case"End":v=t.duration;break;default:return}_.preventDefault(),o("seek",v)}return e.onMounted(()=>{l.value=document.querySelector(".video-timeline")}),e.onUnmounted(()=>{}),(_,v)=>(e.openBlock(),e.createElementBlock("div",xT,[e.createVNode(cT,{duration:_.duration,zoom:i.value},null,8,["duration","zoom"]),e.createElementVNode("div",ST,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,(S,C)=>(e.openBlock(),e.createBlock(ET,{key:`track-${C}`,"data-testid":`track-${C}`,clips:u(C),"track-index":C,zoom:i.value,duration:_.duration,onClipMove:p,onClipTrim:m,onClipSelect:h},null,8,["data-testid","clips","track-index","zoom","duration"]))),128))]),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:d.value}),onMousedown:$,"data-testid":"playhead","aria-label":`Playhead at ${f(_.currentTime)}`,role:"slider","aria-valuenow":_.currentTime,"aria-valuemax":_.duration,tabindex:"0",onKeydown:D},null,44,CT),e.createElementVNode("div",VT,[e.createElementVNode("button",{"data-testid":"btn-zoom-in","aria-label":"Zoom in",onClick:g},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(dl)},null,8,["icon"])]),e.createElementVNode("span",NT,e.toDisplayString(Math.round(i.value*100))+"%",1),e.createElementVNode("button",{"data-testid":"btn-zoom-out","aria-label":"Zoom out",onClick:k},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(qf)},null,8,["icon"])])])]))}}),MT=Me(TT,[["__scopeId","data-v-001df415"]]),BT={class:"video-filters-panel"},IT={class:"filter-controls"},FT=["for"],$T={class:"filter-slider-group"},DT=["id","onUpdate:modelValue","min","max","step","data-testid","aria-label","aria-valuenow","aria-valuemin","aria-valuemax","onInput"],RT={class:"filter-value"},AT={class:"filter-actions"},LT={key:0,class:"filter-presets"},PT={class:"preset-list"},OT=["data-testid","aria-label","onClick"],UT=e.defineComponent({__name:"VideoFiltersPanel",emits:["filter-change"],setup(a,{emit:n}){const t=n,o=[{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(o.reduce((p,m)=>(p[m.type]=m.default,p),{})),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(p,m){switch(p){case"brightness":case"contrast":case"saturation":case"sepia":case"grayscale":return`${m}%`;case"hue":return`${m}°`;case"blur":case"sharpen":return m.toFixed(1);default:return m.toString()}}function l(p){return["brightness","contrast","saturation","hue","blur","sharpen","sepia","grayscale"].includes(p)}function c(p){if(!l(p))return;const m={id:`filter-${p}`,filterId:p,params:{value:i[p]},intensity:1};t("filter-change",m)}function d(){o.forEach(p=>{i[p.type]=p.default,c(p.type)})}function u(){const p=prompt("Enter preset name:");if(!p)return;const m={id:`custom-${Date.now()}`,name:p,values:{...i}};r.value.push(m)}function f(p){Object.entries(p.values).forEach(([m,h])=>{i[m]=h,c(m)})}return(p,m)=>(e.openBlock(),e.createElementBlock("div",BT,[m[3]||(m[3]=e.createElementVNode("h3",null,"Video Filters",-1)),e.createElementVNode("div",IT,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(o,h=>e.createElementVNode("div",{key:h.type,class:"filter-control"},[e.createElementVNode("label",{for:`filter-${h.type}`},e.toDisplayString(h.label),9,FT),e.createElementVNode("div",$T,[e.withDirectives(e.createElementVNode("input",{id:`filter-${h.type}`,"onUpdate:modelValue":g=>i[h.type]=g,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:g=>c(h.type)},null,40,DT),[[e.vModelText,i[h.type],void 0,{number:!0}]]),e.createElementVNode("span",RT,e.toDisplayString(s(h.type,i[h.type])),1)])])),64))]),e.createElementVNode("div",AT,[e.createElementVNode("button",{class:"reset-filters-btn","data-testid":"btn-reset-filters","aria-label":"Reset all filters to default",onClick:d},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Fa)},null,8,["icon"]),m[0]||(m[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(U.IonIcon),{icon:e.unref(pr)},null,8,["icon"]),m[1]||(m[1]=e.createTextVNode(" Save as Preset ",-1))])]),r.value.length>0?(e.openBlock(),e.createElementBlock("div",LT,[m[2]||(m[2]=e.createElementVNode("h4",null,"Presets",-1)),e.createElementVNode("div",PT,[(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:g=>f(h)},e.toDisplayString(h.name),9,OT))),128))])])):e.createCommentVNode("",!0)]))}}),zT=Me(UT,[["__scopeId","data-v-5ad2ac63"]]),jT={class:"video-text-panel"},WT={class:"text-input-group"},ZT={class:"text-options"},HT={class:"option-row"},XT={class:"option-row"},GT={class:"option-row"},JT={class:"option-row"},KT={class:"checkbox-label"},YT={class:"option-row"},qT={class:"text-overlay-list"},QT={key:0,class:"empty-state"},e3=["data-testid"],t3={class:"overlay-preview"},n3={class:"overlay-controls"},a3=["data-testid","aria-label","onClick"],o3=["data-testid","aria-label","onClick"],i3=["data-testid","aria-label","onClick"],r3=e.defineComponent({__name:"VideoTextPanel",emits:["text-add","text-remove","text-update"],setup(a,{emit:n}){const t=n,o=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 d={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&&(d.backgroundColor=i.backgroundColor),i.animation!=="none"&&(d.animation=i.animation),o.value.push(d),t("text-add",d),i.text=""}function s(d){const u=o.value.findIndex(f=>f.id===d);u!==-1&&(o.value.splice(u,1),t("text-remove",d))}function l(d){i.text=d.text,i.fontFamily=d.fontFamily||"Arial",i.fontSize=d.fontSize,i.color=d.color,i.backgroundColor=d.backgroundColor||"#000000",i.hasBackground=!!d.backgroundColor,i.animation=d.animation||"none",s(d.id)}function c(d){const u={...d,id:`text-${Date.now()}`,x:d.x+10,y:d.y+10};o.value.push(u),t("text-add",u)}return(d,u)=>(e.openBlock(),e.createElementBlock("div",jT,[u[17]||(u[17]=e.createElementVNode("h3",null,"Text Overlays",-1)),e.createElementVNode("div",WT,[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(U.IonIcon),{icon:e.unref(dl)},null,8,["icon"]),u[7]||(u[7]=e.createTextVNode(" Add ",-1))])]),e.createElementVNode("div",ZT,[e.createElementVNode("div",HT,[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",XT,[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",GT,[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",JT,[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",KT,[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",YT,[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",qT,[u[16]||(u[16]=e.createElementVNode("h4",null,"Active Overlays",-1)),o.value.length===0?(e.openBlock(),e.createElementBlock("div",QT," No text overlays added yet ")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(f,p)=>(e.openBlock(),e.createElementBlock("div",{key:f.id,class:"text-overlay-item","data-testid":`overlay-${p}`},[e.createElementVNode("div",t3,[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",n3,[e.createElementVNode("button",{class:"edit-btn","data-testid":`btn-edit-${p}`,"aria-label":`Edit overlay: ${f.text}`,onClick:m=>l(f)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(If)},null,8,["icon"])],8,a3),e.createElementVNode("button",{class:"duplicate-btn","data-testid":`btn-duplicate-${p}`,"aria-label":`Duplicate overlay: ${f.text}`,onClick:m=>c(f)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(xs)},null,8,["icon"])],8,o3),e.createElementVNode("button",{class:"remove-btn","data-testid":`btn-remove-${p}`,"aria-label":`Remove overlay: ${f.text}`,onClick:m=>s(f.id)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(qi)},null,8,["icon"])],8,i3)])],8,e3))),128))])]))}}),s3=Me(r3,[["__scopeId","data-v-4d240e1e"]]),l3={class:"video-tools-panel"},c3={class:"tool-tabs"},d3=["data-testid","aria-label","aria-selected","onClick"],u3={class:"tool-content"},m3={key:0,class:"trim-panel",role:"tabpanel","aria-label":"Trim controls"},p3={class:"trim-actions"},f3={key:3,class:"transitions-panel",role:"tabpanel","aria-label":"Transition controls"},h3={class:"transition-types"},v3=["data-testid","aria-label","onClick"],g3={class:"transition-preview"},y3=e.defineComponent({__name:"VideoToolsPanel",props:{activeTool:{}},emits:["tool-change","filter-change","text-add","transition-add","trim-set-start","trim-set-end","trim-clear"],setup(a){const n=[{id:"trim",name:"Trim",icon:Yi},{id:"filters",name:"Filters",icon:oa},{id:"text",name:"Text",icon:Xd},{id:"transitions",name:"Transitions",icon:gc}],t=[{id:"fade",name:"Fade",icon:is},{id:"slide-left",name:"Slide Left",icon:Sf},{id:"slide-right",name:"Slide Right",icon:Cf},{id:"dissolve",name:"Dissolve",icon:is},{id:"wipe",name:"Wipe",icon:gc},{id:"zoom",name:"Zoom",icon:is}];return(o,i)=>(e.openBlock(),e.createElementBlock("div",l3,[e.createElementVNode("div",c3,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(n,r=>e.createElementVNode("button",{key:r.id,class:e.normalizeClass(["tool-tab",{active:o.activeTool===r.id}]),"data-testid":`tab-${r.id}`,"aria-label":`${r.name} tool`,"aria-selected":o.activeTool===r.id,role:"tab",onClick:s=>o.$emit("tool-change",r.id)},[e.createVNode(e.unref(U.IonIcon),{icon:r.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(r.name),1)],10,d3)),64))]),e.createElementVNode("div",u3,[o.activeTool==="trim"?(e.openBlock(),e.createElementBlock("div",m3,[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",p3,[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=>o.$emit("trim-set-start"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(hc)},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=>o.$emit("trim-set-end"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(hc)},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=>o.$emit("trim-clear"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Na)},null,8,["icon"]),i[7]||(i[7]=e.createTextVNode(" Clear ",-1))])])])):e.createCommentVNode("",!0),o.activeTool==="filters"?(e.openBlock(),e.createBlock(zT,{key:1,onFilterChange:i[3]||(i[3]=r=>o.$emit("filter-change",r))})):e.createCommentVNode("",!0),o.activeTool==="text"?(e.openBlock(),e.createBlock(s3,{key:2,onTextAdd:i[4]||(i[4]=r=>o.$emit("text-add",r))})):e.createCommentVNode("",!0),o.activeTool==="transitions"?(e.openBlock(),e.createElementBlock("div",f3,[i[10]||(i[10]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",h3,[(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=>o.$emit("transition-add",r.id)},[e.createElementVNode("div",g3,[e.createVNode(e.unref(U.IonIcon),{icon:r.icon},null,8,["icon"])]),e.createElementVNode("span",null,e.toDisplayString(r.name),1)],8,v3)),64))])])):e.createCommentVNode("",!0)])]))}}),b3=Me(y3,[["__scopeId","data-v-fc135306"]]),w3={class:"video-export-panel"},k3={class:"export-presets"},_3=["value"],E3={key:0,class:"preset-details"},x3={class:"detail-row"},S3={class:"detail-row"},C3={class:"detail-row"},V3={class:"advanced-options"},N3={class:"options-content"},T3={class:"option-group"},M3={class:"option-group"},B3={class:"option-group"},I3=["disabled"],F3={key:1,class:"export-progress"},$3={class:"progress-message"},D3={class:"progress-bar"},R3=["aria-valuenow"],A3={class:"progress-percentage"},L3=e.defineComponent({__name:"VideoExportPanel",props:{presets:{},isExporting:{type:Boolean},exportProgress:{}},emits:["export"],setup(a,{emit:n}){const t=a,o=n,i=e.ref("instagram-reel"),r=e.reactive({quality:"medium",bitrate:5,includeAudio:!0}),s=e.computed(()=>t.presets.find(d=>d.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 c(){s.value&&o("export",{...s.value,options:{...r}})}return(d,u)=>(e.openBlock(),e.createElementBlock("div",w3,[u[14]||(u[14]=e.createElementVNode("h3",null,"Export Video",-1)),e.createElementVNode("div",k3,[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(d.presets,f=>(e.openBlock(),e.createElementBlock("option",{key:f.id,value:f.id},e.toDisplayString(f.name),9,_3))),128))],512),[[e.vModelSelect,i.value]])]),s.value?(e.openBlock(),e.createElementBlock("div",E3,[e.createElementVNode("div",x3,[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",S3,[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",C3,[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",V3,[u[12]||(u[12]=e.createElementVNode("summary",null,"Advanced Options",-1)),e.createElementVNode("div",N3,[e.createElementVNode("div",T3,[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",M3,[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",B3,[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:d.isExporting||!s.value,"data-testid":"btn-start-export","aria-label":"Start video export",onClick:c},[d.isExporting?(e.openBlock(),e.createBlock(e.unref(U.IonSpinner),{key:0,name:"crescent"})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ao)},null,8,["icon"]),u[13]||(u[13]=e.createTextVNode(" Export Video ",-1))],64))],8,I3),d.isExporting?(e.openBlock(),e.createElementBlock("div",F3,[e.createElementVNode("div",$3,e.toDisplayString(l.value),1),e.createElementVNode("div",D3,[e.createElementVNode("div",{class:"progress-fill",style:e.normalizeStyle({width:`${d.exportProgress}%`}),role:"progressbar","aria-valuenow":d.exportProgress,"aria-valuemin":"0","aria-valuemax":"100"},null,12,R3)]),e.createElementVNode("div",A3,e.toDisplayString(d.exportProgress)+"% ",1)])):e.createCommentVNode("",!0)]))}}),P3=Me(L3,[["__scopeId","data-v-5caf8fe6"]]),O3=["data-testid"],U3={class:"progress-header"},z3={class:"file-info"},j3={class:"file-details"},W3={class:"file-name"},Z3={class:"file-meta"},H3={class:"file-size"},X3={key:0,class:"separator"},G3={key:1,class:"upload-speed"},J3={key:2,class:"separator"},K3={key:3,class:"time-remaining"},Y3={class:"progress-actions"},q3={key:0,class:"status-icon completed","data-testid":"video-upload-status-completed"},Q3={key:1,class:"status-icon error","data-testid":"video-upload-status-error"},eM={key:2,class:"status-icon processing","data-testid":"video-upload-status-processing",role:"status","aria-label":"Processing video"},tM=["aria-valuenow","aria-label"],nM={class:"progress-bar"},aM={class:"progress-percent"},oM={key:1,class:"error-message","data-testid":"video-upload-error"},iM={key:2,class:"thumbnail-preview","data-testid":"video-upload-thumbnail"},rM=["src","alt"],sM={key:0,class:"video-duration"},lM=e.defineComponent({__name:"VideoUploadProgress",props:{upload:{}},emits:["cancel","retry","remove"],setup(a){const n=a,t=e.computed(()=>({"is-uploading":n.upload.status==="uploading","is-processing":n.upload.status==="processing","is-completed":n.upload.status==="completed","is-error":n.upload.status==="error","is-pending":n.upload.status==="pending"})),o=e.computed(()=>Gd),i=e.computed(()=>["uploading","processing"].includes(n.upload.status)),r=e.computed(()=>(n.upload.status==="processing",n.upload.progress||0)),s=e.computed(()=>{if(!n.upload.timeRemaining||n.upload.status!=="uploading")return null;const p=n.upload.timeRemaining;if(p<60)return`${Math.round(p)}s`;const m=Math.floor(p/60);return m<60?`${m}m ${Math.round(p%60)}s`:`${Math.floor(m/60)}h ${m%60}m`}),l=e.computed(()=>{var p;return n.upload.status==="completed"&&((p=n.upload.media)!=null&&p.thumbnail_url)?n.upload.media.thumbnail_url:null}),c=e.computed(()=>{var p;return(p=n.upload.media)==null?void 0:p.duration});function d(p){if(p===0)return"0 B";const m=["B","KB","MB","GB","TB"],h=1024,g=Math.floor(Math.log(p)/Math.log(h));return`${(p/Math.pow(h,g)).toFixed(1)} ${m[g]}`}function u(p){if(p===0)return"0 B/s";const m=["B/s","KB/s","MB/s","GB/s"],h=1024,g=Math.floor(Math.log(p)/Math.log(h));return`${(p/Math.pow(h,g)).toFixed(1)} ${m[g]}`}function f(p){const m=Math.floor(p/3600),h=Math.floor(p%3600/60),g=Math.floor(p%60);return m>0?`${m}:${h.toString().padStart(2,"0")}:${g.toString().padStart(2,"0")}`:`${h}:${g.toString().padStart(2,"0")}`}return(p,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["upload-progress-item",t.value]),"data-testid":`video-upload-progress-${p.upload.id}`},[e.createElementVNode("div",U3,[e.createElementVNode("div",z3,[e.createVNode(e.unref(U.IonIcon),{icon:o.value,class:"file-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("div",j3,[e.createElementVNode("h4",W3,e.toDisplayString(p.upload.filename),1),e.createElementVNode("p",Z3,[e.createElementVNode("span",H3,e.toDisplayString(d(p.upload.bytesTotal||0)),1),p.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",X3,"•")):e.createCommentVNode("",!0),p.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",G3,e.toDisplayString(u(p.upload.uploadSpeed||0)),1)):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",J3,"•")):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",K3,e.toDisplayString(s.value)+" remaining ",1)):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",Y3,[p.upload.status==="completed"?(e.openBlock(),e.createElementBlock("div",q3,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(jd)},null,8,["icon"])])):p.upload.status==="error"?(e.openBlock(),e.createElementBlock("div",Q3,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(xf),"aria-hidden":"true"},null,8,["icon"])])):p.upload.status==="processing"?(e.openBlock(),e.createElementBlock("div",eM,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),p.upload.status==="uploading"?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:3,fill:"clear",size:"small",onClick:m[0]||(m[0]=h=>p.$emit("cancel")),"data-testid":"btn-cancel-video-upload","aria-label":"Cancel upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Na),slot:"icon-only"},null,8,["icon"])]),_:1})):p.upload.status==="error"?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:4,fill:"clear",size:"small",onClick:m[1]||(m[1]=h=>p.$emit("retry")),"data-testid":"btn-retry-video-upload","aria-label":"Retry upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Fa),slot:"icon-only"},null,8,["icon"])]),_:1})):p.upload.status==="completed"?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:5,fill:"clear",size:"small",onClick:m[2]||(m[2]=h=>p.$emit("remove")),"data-testid":"btn-remove-video-upload","aria-label":"Remove from list"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Na),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":p.upload.status==="processing"?"Processing progress":"Upload progress"},[e.createElementVNode("div",nM,[e.createElementVNode("div",{class:e.normalizeClass(["progress-fill",{indeterminate:p.upload.status==="processing"}]),style:e.normalizeStyle({width:r.value+"%"})},null,6)]),e.createElementVNode("span",aM,e.toDisplayString(Math.round(r.value))+"%",1)],8,tM)):e.createCommentVNode("",!0),p.upload.error?(e.openBlock(),e.createElementBlock("div",oM,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(sh)},null,8,["icon"]),e.createElementVNode("span",null,e.toDisplayString(p.upload.error),1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",iM,[e.createElementVNode("img",{src:l.value,alt:p.upload.filename},null,8,rM),c.value?(e.openBlock(),e.createElementBlock("div",sM,e.toDisplayString(f(c.value)),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],10,O3))}}),cM=Me(lM,[["__scopeId","data-v-9eacbf91"]]),gs=4,dM=500,uM=new Set([408,425,429,500,502,503,504,520,521,522,523,524,525]);function Lr(a){return typeof a=="object"&&a!==null}function kd(a){return Lr(a)?typeof a.upload_url=="string"&&typeof a.upload_id=="string"&&typeof a.media_uuid=="string"&&typeof a.expires_at=="string":!1}function mM(a){if(kd(a))return a;if(Lr(a)&&kd(a.data))return a.data;throw new Error("Invalid upload response from backend")}function _d(a){return Lr(a)?typeof a.uuid=="string"&&typeof a.processing_status=="string":!1}function pM(a){if(_d(a))return a;if(Lr(a)&&_d(a.data))return a.data;throw new Error("Invalid media response from backend")}function Bi(a){return a?{...a}:{}}function Ed(a,n="PUT"){return typeof a.method=="string"&&a.method.trim()!==""?a.method.trim().toUpperCase():n}function fM(a){return a.resumable===!0?!0:/tusupload/i.test(a.upload_url)}function hM(a){if(typeof btoa=="function")try{return btoa(unescape(encodeURIComponent(a)))}catch{return btoa(a)}throw new Error("Base64 encoder is unavailable for TUS metadata")}function vM(a,n){return[["filename",a.filename],["filetype",a.file.type||"application/octet-stream"],["uploadid",n.upload_id],["mediauuid",n.media_uuid]].map(([o,i])=>`${o} ${hM(i)}`).join(",")}function Ii(a,n){const t=Math.max(a.bytesTotal,1);a.bytesUploaded=n,a.progress=Math.min(100,n/t*100);const o=Math.max((Date.now()-a.startedAt.getTime())/1e3,.001);a.uploadSpeed=n/o;const i=Math.max(t-n,0);a.timeRemaining=i/Math.max(a.uploadSpeed,1)}function gM(a,n){return a instanceof Error?a:new Error(n)}function yM(a){if(!(a instanceof Error))return!1;const n=a.message.toLowerCase();return n.includes("failed to fetch")||n.includes("networkerror")||n.includes("network request failed")||n.includes("err_ssl_")}function xd(a){const n=Math.max(0,a-1),t=dM*Math.pow(2,n);return Math.min(5e3,t)}function Sd(a){return new Promise(n=>{window.setTimeout(n,a)})}async function Cd(a,n){for(let t=1;t<=gs;t+=1)try{const o=await n();if(o.ok||!uM.has(o.status)||t>=gs)return o;await Sd(xd(t))}catch(o){if(!yM(o)||t>=gs)throw o;await Sd(xd(t))}throw new Error(`${a} failed after retry attempts`)}function bM(a={}){const n=e.ref(new Map),t=e.ref(new Set),o=e.ref(null),i=new Map,r=new Map,s=e.computed(()=>t.value.size>0),l=e.computed(()=>Array.from(n.value.values())),c=e.computed(()=>{const E=Array.from(n.value.values());return E.length===0?0:E.reduce((N,z)=>N+z.progress,0)/E.length});function d(E){o.value=E}function u(){}async function f(E){var N;const A=E.filter(z=>p(z));if(A.length!==0&&((N=a.onFilesSelected)==null||N.call(a,A),a.autoUpload!==!1))for(const z of A)await m(z)}function p(E){return!(a.maxFileSize&&E.size>a.maxFileSize||a.allowedFormats&&a.allowedFormats.length>0&&!a.allowedFormats.includes(E.type))}async function m(E){var z,P,B;const A=j(E);if(n.value.has(A)){const L=n.value.get(A);if((L==null?void 0:L.status)==="uploading")return}const N={id:A,file:E,filename:E.name,progress:0,status:"pending",startedAt:new Date,bytesTotal:E.size,bytesUploaded:0};n.value.set(N.id,N),t.value.add(N.id);try{N.status="uploading",(z=a.onUploadStart)==null||z.call(a,N);const L=await h(E);a.resumable===!0||L.resumable===!0?await k(N,L):await g(N,L),N.status="processing",N.progress=100;const O=await S(L.media_uuid);N.status="completed",N.media=O,(P=a.onUploadComplete)==null||P.call(a,O)}catch(L){if(N.status!=="cancelled"){const w=gM(L,"Upload failed");N.status="error",N.error=w.message,(B=a.onUploadError)==null||B.call(a,w,N)}}finally{t.value.delete(N.id),i.delete(N.id),r.delete(N.id)}}async function h(E){if(!o.value)throw new Error("API client not configured");const A={collection:a.collection||"videos",filename:E.name,size:E.size,mime_type:E.type,...a.ownerUuid!==void 0?{ownerUuid:a.ownerUuid}:{},...a.ownerType!==void 0?{ownerType:a.ownerType}:{}},N=await o.value.post("/api/v1/video/upload",A);return mM(N)}async function g(E,A){const N=new XMLHttpRequest,z=Ed(A),P=Bi(A.headers);return new Promise((B,L)=>{N.upload.addEventListener("progress",w=>{var O;w.lengthComputable&&(Ii(E,w.loaded),(O=a.onUploadProgress)==null||O.call(a,E))}),N.addEventListener("load",()=>{i.delete(E.id),N.status>=200&&N.status<300?B():L(new Error(`Upload failed with status ${N.status}`))}),N.addEventListener("error",()=>{i.delete(E.id),L(new Error("Upload failed"))}),N.addEventListener("abort",()=>{i.delete(E.id),L(new Error("Upload cancelled"))}),N.open(z,A.upload_url),Object.entries(P).forEach(([w,O])=>{N.setRequestHeader(w,O)}),!Object.keys(P).some(w=>w.toLowerCase()==="content-type")&&E.file.type&&N.setRequestHeader("Content-Type",E.file.type),i.set(E.id,N),N.send(E.file)})}async function k(E,A){var L;if(fM(A)){await $(E,A);return}const N=a.chunkSize||5*1024*1024,z=D(E.file,N),P=new AbortController;r.set(E.id,P);const B=await v(A.upload_id);B&&(z.forEach(w=>{w.end<=B.bytesUploaded&&(w.uploaded=!0)}),Ii(E,B.bytesUploaded));for(const w of z)w.uploaded||(await _(E,A,w,P),Ii(E,w.end),(L=a.onUploadProgress)==null||L.call(a,E))}async function $(E,A){var Z;const N=new AbortController;r.set(E.id,N);const z={...Bi(A.headers),"Tus-Resumable":"1.0.0","Upload-Length":String(E.file.size),"Upload-Metadata":vM(E,A)},P=await Cd("Resumable upload initialization",()=>fetch(A.upload_url,{method:"POST",headers:z,signal:N.signal}));if(!P.ok)throw new Error(`Failed to initialize resumable upload: ${P.status}`);const B=P.headers.get("Location");if(!B)throw new Error("Resumable upload endpoint did not return upload location");const L=new URL(B,A.upload_url).toString(),w=a.chunkSize||5*1024*1024;let O=0;for(;O<E.file.size;){const G=Math.min(O+w,E.file.size),re=E.file.slice(O,G),be={...Bi(A.headers),"Tus-Resumable":"1.0.0","Upload-Offset":String(O),"Content-Type":"application/offset+octet-stream"},Ee=await Cd("Resumable chunk upload",()=>fetch(L,{method:"PATCH",headers:be,body:re,signal:N.signal}));if(Ee.status===409){const R=Number(Ee.headers.get("Upload-Offset")??"-1");if(Number.isFinite(R)&&R>=0){O=R;continue}}if(!Ee.ok)throw new Error(`Resumable chunk upload failed: ${Ee.status}`);const ie=Number(Ee.headers.get("Upload-Offset")??String(G));O=Number.isFinite(ie)&&ie>O?ie:G,Ii(E,O),(Z=a.onUploadProgress)==null||Z.call(a,E)}}function D(E,A){const N=[];let z=0,P=0;for(;z<E.size;){const B=Math.min(z+A,E.size);N.push({start:z,end:B,blob:E.slice(z,B),index:P,uploaded:!1}),z=B,P++}return N}async function _(E,A,N,z){const P={...Bi(A.headers),"Content-Range":`bytes ${N.start}-${N.end-1}/${E.file.size}`,"Content-Type":E.file.type||"application/octet-stream"},B=await fetch(A.upload_url,{method:Ed(A),headers:P,body:N.blob,signal:z.signal});if(!B.ok)throw new Error(`Chunk upload failed: ${B.status}`);N.uploaded=!0}async function v(E){return null}async function S(E){if(!o.value)throw new Error("API client not configured");const A=60;let N=0;for(;N<A;){const z=await o.value.get(`/api/v1/video/${E}`),P=pM(z),B=String(P.processing_status);if(B==="ready")return P;if(B==="failed"||B==="error")throw new Error("Video processing failed");await new Promise(L=>{window.setTimeout(L,5e3)}),N++}throw new Error("Video processing timeout")}function C(E){const A=n.value.get(E);if(!A)return;const N=i.get(E);N&&(N.abort(),i.delete(E));const z=r.get(E);z&&(z.abort(),r.delete(E)),A.status="cancelled",A.error="Upload cancelled",t.value.delete(E)}async function V(E){const A=n.value.get(E);A&&(A.status="pending",A.error="",A.progress=0,A.bytesUploaded=0,await m(A.file))}function x(E){n.value.delete(E),t.value.delete(E),i.delete(E),r.delete(E)}function T(){Array.from(n.value.entries()).forEach(([E,A])=>{A.status==="completed"&&n.value.delete(E)})}function j(E){return`${E.name}-${E.size}-${Date.now()}`}return{uploads:l,isUploading:s,totalProgress:c,openFilePicker:u,handleFileSelect:f,validateFile:p,startUpload:m,cancelUpload:C,retryUpload:V,removeUpload:x,clearCompleted:T,setApiClient:d}}const wM=["accept","multiple"],kM={key:0,class:"upload-trigger","data-testid":"video-uploader-trigger"},_M=["onKeydown"],EM={key:1,class:"upload-list","data-testid":"video-upload-list"},xM={class:"drag-content"},SM=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(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(!1),{uploads:s,isUploading:l,handleFileSelect:c,cancelUpload:d,retryUpload:u,removeUpload:f,setApiClient:p}=bM({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:v=>o("upload-start",v),onUploadProgress:v=>o("upload-progress",v),onUploadComplete:v=>o("upload-complete",v),onUploadError:(v,S)=>o("upload-error",v,S),onFilesSelected:v=>o("files-selected",v)});t.apiClient&&p(t.apiClient);const m=e.computed(()=>t.allowedFormats.join(",")),h=e.computed(()=>t.multiple||s.value.length===0);function g(){i.value&&i.value.click()}function k(v){const S=v.target,C=Array.from(S.files||[]);C.length>0&&(c(C),S.value="")}function $(v){var V;v.preventDefault(),r.value=!1;const C=Array.from(((V=v.dataTransfer)==null?void 0:V.files)||[]).filter(x=>x.type.startsWith("video/"));C.length>0&&c(C)}function D(v){var S;v.preventDefault(),(S=v.dataTransfer)!=null&&S.types.includes("Files")&&(r.value=!0)}function _(v){v.target.closest(".video-uploader")||(r.value=!1)}return e.onMounted(()=>{document.addEventListener("dragover",D),document.addEventListener("dragleave",_),document.addEventListener("drop",v=>v.preventDefault())}),e.onUnmounted(()=>{document.removeEventListener("dragover",D),document.removeEventListener("dragleave",_),document.removeEventListener("drop",v=>v.preventDefault())}),(v,S)=>(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:m.value,multiple:v.multiple,onChange:k,"data-testid":"video-uploader-input","aria-label":"Select video files to upload",hidden:""},null,40,wM),!e.unref(l)||h.value?(e.openBlock(),e.createElementBlock("div",kM,[e.renderSlot(v.$slots,"trigger",{open:g},()=>[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:g,onKeydown:[e.withKeys(g,["enter"]),e.withKeys(e.withModifiers(g,["prevent"]),["space"])]},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Gd),class:"upload-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("h3",null,e.toDisplayString(v.label),1),e.createElementVNode("p",null,e.toDisplayString(v.description),1),e.createVNode(e.unref(U.IonButton),{size:"small","data-testid":"btn-select-video","aria-label":"Select video file"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(dl),slot:"start","aria-hidden":"true"},null,8,["icon"]),S[2]||(S[2]=e.createTextVNode(" Select Video ",-1))]),_:1})],40,_M)],!0)])):e.createCommentVNode("",!0),e.unref(s).length>0?(e.openBlock(),e.createElementBlock("div",EM,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),C=>(e.openBlock(),e.createBlock(cM,{key:C.id,upload:C,onCancel:V=>e.unref(d)(C.id),onRetry:V=>e.unref(u)(C.id),onRemove:V=>e.unref(f)(C.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:$,onDragover:S[0]||(S[0]=e.withModifiers(()=>{},["prevent"])),onDragleave:S[1]||(S[1]=C=>r.value=!1)},[e.createElementVNode("div",xM,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ao),"aria-hidden":"true"},null,8,["icon"]),S[3]||(S[3]=e.createElementVNode("p",null,"Drop video files here",-1))])],32)):e.createCommentVNode("",!0)],2))}}),CM=Me(SM,[["__scopeId","data-v-ea7587f7"]]),VM=["aria-valuenow","aria-valuemax","aria-label"],NM={class:"progress-bar"},TM={class:"time-display","data-testid":"video-time-display"},MM={class:"current-time"},BM={class:"duration"},IM={class:"control-buttons"},FM={class:"controls-left"},$M=["aria-label"],DM={class:"controls-center"},RM={key:0,class:"volume-controls"},AM=["aria-label"],LM=["value"],PM={class:"controls-right"},OM={key:0,class:"quality-selector"},UM=["aria-expanded"],zM={class:"quality-label"},jM={key:0,class:"quality-menu","data-testid":"video-quality-menu",role:"menu"},WM=["data-testid","aria-label","onClick"],ZM=["aria-label"],HM=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(a,{emit:n}){const t=a,o=n,i=e.ref(!0),r=e.ref(!1),s=e.ref(),l=U.isPlatform("mobile"),c="pictureInPictureEnabled"in document,d=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 v=0;v<t.buffered.length;v++){const S=t.buffered.start(v),C=t.buffered.end(v);if(t.currentTime>=S&&t.currentTime<=C)return{width:`${C/t.duration*100}%`}}return t.buffered.length>0?{width:`${t.buffered.end(0)/t.duration*100}%`}:{width:"0%"}}),p=e.computed(()=>t.muted||t.volume===0?ih:t.volume<33?nh:t.volume<66?ah:th);let m=null;function h(){i.value=!0,g()}function g(){m&&clearTimeout(m),t.playing&&!l&&(m=setTimeout(()=>{i.value=!1},3e3))}function k(v){if(!s.value||t.isLive)return;const S=s.value.getBoundingClientRect(),V=(v.clientX-S.left)/S.width*t.duration;o("seek",Math.max(0,Math.min(V,t.duration)))}function $(v){const S=v.target;o("setVolume",parseInt(S.value))}function D(v){o("selectQuality",v),r.value=!1}function _(v){if(!isFinite(v))return"0:00";const S=Math.floor(v/3600),C=Math.floor(v%3600/60),V=Math.floor(v%60);return S>0?`${S}:${C.toString().padStart(2,"0")}:${V.toString().padStart(2,"0")}`:`${C}:${V.toString().padStart(2,"0")}`}return e.onMounted(()=>{document.addEventListener("mousemove",h),g()}),e.onUnmounted(()=>{document.removeEventListener("mousemove",h),m&&clearTimeout(m)}),(v,S)=>(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(v.currentTime),"aria-valuemin":"0","aria-valuemax":Math.round(v.duration),"aria-label":v.isLive?"Live stream":"Video progress",tabindex:"0",onClick:k},[e.createElementVNode("div",NM,[e.createElementVNode("div",{class:"progress-buffered",style:e.normalizeStyle(f.value)},null,4),e.createElementVNode("div",{class:"progress-played",style:e.normalizeStyle(d.value)},null,4),e.createElementVNode("div",{class:"progress-thumb",style:e.normalizeStyle(u.value)},null,4)]),e.createElementVNode("div",TM,[e.createElementVNode("span",MM,e.toDisplayString(_(v.currentTime)),1),S[7]||(S[7]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",BM,e.toDisplayString(v.isLive?"LIVE":_(v.duration)),1)])],8,VM),e.createElementVNode("div",IM,[e.createElementVNode("div",FM,[e.createElementVNode("button",{class:"control-btn play-pause","data-testid":"btn-video-play-pause",onClick:S[0]||(S[0]=C=>v.$emit("play-pause")),"aria-label":v.playing?"Pause":"Play"},[e.createVNode(e.unref(U.IonIcon),{icon:v.playing?e.unref(Uf):e.unref(jf),"aria-hidden":"true"},null,8,["icon"])],8,$M),v.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"control-btn skip-backward","data-testid":"btn-video-skip-backward",onClick:S[1]||(S[1]=C=>v.$emit("skip-backward")),"aria-label":"Skip backward 10 seconds"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Wf),"aria-hidden":"true"},null,8,["icon"]),S[8]||(S[8]=e.createElementVNode("span",{class:"skip-label"},"10",-1))])),v.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn skip-forward","data-testid":"btn-video-skip-forward",onClick:S[2]||(S[2]=C=>v.$emit("skip-forward")),"aria-label":"Skip forward 10 seconds"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Xf),"aria-hidden":"true"},null,8,["icon"]),S[9]||(S[9]=e.createElementVNode("span",{class:"skip-label"},"10",-1))]))]),e.createElementVNode("div",DM,[e.unref(l)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",RM,[e.createElementVNode("button",{class:"control-btn mute-btn","data-testid":"btn-video-mute",onClick:S[3]||(S[3]=C=>v.$emit("toggleMute")),"aria-label":v.muted?"Unmute":"Mute"},[e.createVNode(e.unref(U.IonIcon),{icon:p.value,"aria-hidden":"true"},null,8,["icon"])],8,AM),e.createElementVNode("input",{type:"range",class:"volume-slider","data-testid":"slider-video-volume",min:"0",max:"100",value:v.muted?0:v.volume,onInput:$,"aria-label":"Volume"},null,40,LM)]))]),e.createElementVNode("div",PM,[v.qualityLevels.length>1?(e.openBlock(),e.createElementBlock("div",OM,[e.createElementVNode("button",{class:"control-btn quality-btn","data-testid":"btn-video-quality",onClick:S[4]||(S[4]=C=>r.value=!r.value),"aria-label":"Quality settings","aria-expanded":r.value},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Qf),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("span",zM,e.toDisplayString(v.currentQuality),1)],8,UM),r.value?(e.openBlock(),e.createElementBlock("div",jM,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.qualityLevels,C=>(e.openBlock(),e.createElementBlock("button",{key:C.label,class:e.normalizeClass(["quality-option",{active:C.label===v.currentQuality}]),"data-testid":`btn-video-quality-${C.label}`,"aria-label":`Set quality to ${C.label}`,role:"menuitem",onClick:V=>D(C)},e.toDisplayString(C.label),11,WM))),128))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),!e.unref(l)&&c?(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn pip-btn","data-testid":"btn-video-pip",onClick:S[5]||(S[5]=C=>v.$emit("togglePiP")),"aria-label":"Picture in Picture"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(eh),"aria-hidden":"true"},null,8,["icon"])])):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"control-btn fullscreen-btn","data-testid":"btn-video-fullscreen",onClick:S[6]||(S[6]=C=>v.$emit("toggleFullscreen")),"aria-label":v.fullscreen?"Exit fullscreen":"Enter fullscreen"},[e.createVNode(e.unref(U.IonIcon),{icon:v.fullscreen?e.unref(Bf):e.unref($f),"aria-hidden":"true"},null,8,["icon"])],8,ZM)])])],2))}}),XM=Me(HM,[["__scopeId","data-v-2ae77c13"]]);function GM(a={}){var re,be,Ee;const n=e.ref(),t=e.ref(),o=e.ref(!1),i=e.ref(0),r=e.ref(0),s=e.ref(100),l=e.ref(a.muted||!1),c=e.ref(!1),d=e.ref(),u=e.ref(1),f=e.ref(!1),p=e.ref(null),m=e.ref("idle"),h=e.ref(a.playbackUrl||((re=a.media)==null?void 0:re.playback_url)||((be=a.media)==null?void 0:be.url)||""),g=e.ref(null),k=e.ref(a.isLive||!1),$=e.ref(null),D=e.ref(null);function _(ie){D.value=ie}if((Ee=a.media)!=null&&Ee.token_expires_at){const ie=new Date(a.media.token_expires_at);g.value=Number.isNaN(ie.getTime())?null:ie}async function v(){var R;const ie=k.value?t.value:n.value;if(ie)try{await ie.play(),o.value=!0,m.value=k.value?"live":"playing",(R=a.onPlay)==null||R.call(a)}catch{p.value="Failed to play video",m.value="error"}}function S(){var R;const ie=k.value?t.value:n.value;ie&&(ie.pause(),o.value=!1,m.value="paused",(R=a.onPause)==null||R.call(a))}function C(){o.value?S():v()}function V(ie){const R=k.value?t.value:n.value;if(!R||k.value)return;const M=Number.isFinite(R.duration)?R.duration:ie;R.currentTime=Math.max(0,Math.min(ie,M)),i.value=R.currentTime}function x(ie=10){const R=n.value;!R||k.value||V(R.currentTime+ie)}function T(ie=10){const R=n.value;!R||k.value||V(R.currentTime-ie)}function j(){const ie=k.value?t.value:n.value;ie&&(ie.muted=!ie.muted,l.value=ie.muted)}function E(ie){const R=k.value?t.value:n.value;if(!R)return;const M=Math.max(0,Math.min(100,ie));R.volume=M/100,s.value=M,M>0&&R.muted&&(R.muted=!1,l.value=!1)}function A(ie){const R=n.value;!R||k.value||(R.playbackRate=ie,u.value=ie)}async function N(){const ie=document.querySelector(".video-player-container");if(ie)try{document.fullscreenElement?(await document.exitFullscreen(),c.value=!1):(await ie.requestFullscreen(),c.value=!0)}catch{}}async function z(){const ie=k.value?t.value:n.value;if(ie)try{document.pictureInPictureElement?await document.exitPictureInPicture():document.pictureInPictureEnabled&&await ie.requestPictureInPicture()}catch{}}async function P(){var R;p.value=null,m.value="loading",(R=a.media)!=null&&R.provider&&a.media.provider!=="local"&&await B();const ie=k.value?t.value:n.value;ie&&(ie.load(),await v())}async function B(){if(!(!D.value||!a.media))try{f.value=!0;const ie=await D.value.get(`/api/v1/video/${a.media.uuid}/playback`);h.value=ie.playback_url,g.value=new Date(ie.token_expires_at);const R=k.value?t.value:n.value;if(R&&R.src!==h.value){const M=!R.paused,H=R.currentTime;R.src=h.value,k.value||(R.currentTime=H),M&&await v()}}catch{p.value="Failed to refresh playback token",m.value="error"}finally{f.value=!1}}async function L(ie){if(t.value){if(t.value.canPlayType("application/vnd.apple.mpegurl")){t.value.src=ie;return}try{t.value.src=ie}catch{p.value="Live streaming not supported in this browser",m.value="error"}}}function w(){$.value&&($.value.destroy(),$.value=null)}function O(){var R;const ie=k.value?t.value:n.value;ie&&(i.value=ie.currentTime,r.value=ie.duration,(R=a.onTimeUpdate)==null||R.call(a,ie.currentTime))}const Z=e.computed(()=>{if(!d.value||d.value.length===0||!r.value)return 0;for(let ie=0;ie<d.value.length;ie++){const R=d.value.start(ie),M=d.value.end(ie);if(i.value>=R&&i.value<=M)return M/r.value*100}return 0});function G(){if(!g.value)return!1;const ie=new Date;return g.value.getTime()-ie.getTime()<5*60*1e3}return e.watch([n,t],([ie,R])=>{const M=k.value?R:ie;M&&(M.addEventListener("timeupdate",O),M.addEventListener("loadedmetadata",()=>{r.value=M.duration,m.value="ready"}),M.addEventListener("progress",()=>{d.value=M.buffered}),M.addEventListener("ended",()=>{var H;o.value=!1,m.value="ended",(H=a.onEnded)==null||H.call(a)}),M.addEventListener("error",H=>{var ee;m.value="error",(ee=a.onError)==null||ee.call(a,"Video playback error")}),M.volume=s.value/100,M.muted=l.value)}),e.onUnmounted(()=>{w();const ie=k.value?t.value:n.value;ie&&ie.removeEventListener("timeupdate",O)}),{videoEl:n,liveVideoEl:t,playing:o,currentTime:i,duration:r,volume:s,muted:l,isFullscreen:c,bufferedRanges:d,bufferedPercent:Z,playbackRate:u,isLoading:f,error:p,status:m,currentPlaybackUrl:h,tokenExpiresAt:g,play:v,pause:S,togglePlayPause:C,seek:V,skipForward:x,skipBackward:T,toggleMute:j,setVolume:E,setPlaybackRate:A,toggleFullscreen:N,togglePiP:z,retry:P,refreshToken:B,setupLiveStream:L,setApiClient:_,shouldRefreshToken:G}}const JM=["src","poster","controls","autoplay","muted","loop","preload"],KM={key:1,ref:"livePlayerEl",class:"live-player"},YM=["controls","muted"],qM={key:0,class:"live-indicator","data-testid":"video-live-indicator","aria-label":"Live stream"},QM={key:2,class:"video-loading","data-testid":"video-loading",role:"status","aria-label":"Loading video"},e5={key:3,class:"video-error","data-testid":"video-error",role:"alert"},t5={key:5,class:"gesture-zones","data-testid":"video-gesture-zones"},n5=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(a,{emit:n}){const t=a,o=n,{videoEl:i,liveVideoEl:r,playing:s,currentTime:l,duration:c,volume:d,muted:u,isFullscreen:f,bufferedRanges:p,isLoading:m,error:h,status:g,currentPlaybackUrl:k,tokenExpiresAt:$,play:D,pause:_,seek:v,toggleMute:S,setVolume:C,toggleFullscreen:V,togglePlayPause:x,skipForward:T,skipBackward:j,retry:E,refreshToken:A,setApiClient:N,shouldRefreshToken:z,setupLiveStream:P}=GM({...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 B(){await A()}const L=e.computed(()=>{const ee=["video-player-container"];return t.className&&ee.push(t.className),f.value&&ee.push("fullscreen"),t.isLive&&ee.push("is-live"),s.value&&ee.push("is-playing"),m.value&&ee.push("is-loading"),ee}),w=e.computed(()=>{var ee,ae;if(t.poster)return t.poster;if((ee=t.media)!=null&&ee.poster_url)return t.media.poster_url;if((ae=t.media)!=null&&ae.thumbnail_url)return t.media.thumbnail_url});function O(ee){const ae=ee.target;o("loadedmetadata",{duration:ae.duration,width:ae.videoWidth,height:ae.videoHeight})}function Z(ee){const ae=ee.target;l.value=ae.currentTime,o("timeupdate",ae.currentTime)}function G(){s.value=!0,o("play")}function re(){s.value=!1,o("pause")}function be(){s.value=!1,o("ended")}function Ee(ee){const ae=ee.target;let ue="Failed to load video";if(ae.error)switch(ae.error.code){case ae.error.MEDIA_ERR_ABORTED:ue="Video playback aborted";break;case ae.error.MEDIA_ERR_NETWORK:ue="Network error while loading video";break;case ae.error.MEDIA_ERR_DECODE:ue="Video decoding error";break;case ae.error.MEDIA_ERR_SRC_NOT_SUPPORTED:ue="Video format not supported";break}h.value=ue,o("error",ue)}function ie(ee){const ae=ee.target;p.value=ae.buffered,o("progress",ae.buffered)}function R(){m.value=!0}function M(){m.value=!1}e.watch(()=>t.apiClient,ee=>{ee&&N(ee)},{immediate:!0}),e.watch(()=>t.playbackUrl,ee=>{typeof ee=="string"&&ee.length>0&&(k.value=ee)},{immediate:!0}),e.watch(()=>{var ee;return(ee=t.media)==null?void 0:ee.token_expires_at},ee=>{if(!ee){$.value=null;return}const ae=new Date(ee);$.value=Number.isNaN(ae.getTime())?null:ae},{immediate:!0}),e.watch(()=>{var ee;return(ee=t.media)==null?void 0:ee.playback_url},async(ee,ae)=>{if(t.playbackUrl||!ee||ee===ae)return;const ue=i.value;if(!ue||t.isLive){k.value=ee;return}const de=!ue.paused,ye=ue.currentTime;k.value=ee,await e.nextTick();try{ue.currentTime=ye}catch{}de&&await D()},{immediate:!0});let H=null;return e.watch(()=>t.isLive,async ee=>{var ue;if(!ee)return;const ae=t.playbackUrl||((ue=t.media)==null?void 0:ue.playback_url)||"";ae&&await P(ae)},{immediate:!0}),e.onMounted(()=>{var ee;(ee=t.media)!=null&&ee.provider&&t.media.provider!=="local"&&(H=setInterval(()=>{z()&&B()},3e4)),U.isPlatform("mobile")&&t.showCustomControls}),e.onUnmounted(()=>{H&&clearInterval(H)}),(ee,ae)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-player-container",L.value]),"data-testid":"video-player"},[ee.isLive?(e.openBlock(),e.createElementBlock("div",KM,[e.createElementVNode("video",{ref_key:"liveVideoEl",ref:r,controls:ee.controls&&!ee.showCustomControls,autoplay:!0,muted:e.unref(u),onPlay:G,onPause:re,onError:Ee,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,YM),e.unref(g)==="live"?(e.openBlock(),e.createElementBlock("div",qM,[...ae[3]||(ae[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(k),poster:w.value,controls:ee.controls&&!ee.showCustomControls,autoplay:ee.autoplay,muted:e.unref(u),loop:ee.loop,preload:ee.preload,onLoadedmetadata:O,onTimeupdate:Z,onPlay:G,onPause:re,onEnded:be,onError:Ee,onProgress:ie,onWaiting:R,onCanplay:M,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,JM)),e.unref(m)?(e.openBlock(),e.createElementBlock("div",QM,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),e.unref(h)?(e.openBlock(),e.createElementBlock("div",e5,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ul),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(e.unref(h)),1),e.createVNode(e.unref(U.IonButton),{size:"small",onClick:e.unref(E),"data-testid":"btn-video-retry","aria-label":"Retry loading video"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Fa),slot:"start","aria-hidden":"true"},null,8,["icon"]),ae[4]||(ae[4]=e.createTextVNode(" Retry ",-1))]),_:1},8,["onClick"])])):e.createCommentVNode("",!0),ee.showCustomControls&&!e.unref(h)?(e.openBlock(),e.createBlock(XM,{key:4,playing:e.unref(s),currentTime:e.unref(l),duration:e.unref(c),buffered:e.unref(p),volume:e.unref(d),muted:e.unref(u),fullscreen:e.unref(f),isLive:ee.isLive,onPlay:e.unref(D),onPause:e.unref(_),onSeek:e.unref(v),onToggleMute:e.unref(S),onSetVolume:e.unref(C),onToggleFullscreen:e.unref(V),class:"custom-controls"},null,8,["playing","currentTime","duration","buffered","volume","muted","fullscreen","isLive","onPlay","onPause","onSeek","onToggleMute","onSetVolume","onToggleFullscreen"])):e.createCommentVNode("",!0),ee.enableGestures&&!e.unref(h)?(e.openBlock(),e.createElementBlock("div",t5,[e.createElementVNode("div",{class:"gesture-left","data-testid":"video-gesture-skip-back","aria-label":"Double tap to skip backward",onDblclick:ae[0]||(ae[0]=(...ue)=>e.unref(j)&&e.unref(j)(...ue))},null,32),e.createElementVNode("div",{class:"gesture-center","data-testid":"video-gesture-play-pause","aria-label":"Tap to play or pause",onClick:ae[1]||(ae[1]=(...ue)=>e.unref(x)&&e.unref(x)(...ue))}),e.createElementVNode("div",{class:"gesture-right","data-testid":"video-gesture-skip-forward","aria-label":"Double tap to skip forward",onDblclick:ae[2]||(ae[2]=(...ue)=>e.unref(T)&&e.unref(T)(...ue))},null,32)])):e.createCommentVNode("",!0)],2))}}),Om=Me(n5,[["__scopeId","data-v-b8db4951"]]),a5=mr.defineStore("video",()=>{const a=e.ref(new Map),n=e.ref(new Map),t=e.ref(new Map),o=e.ref(null),i=e.ref(!1),r=e.computed(()=>Array.from(a.value.values())),s=e.computed(()=>Array.from(n.value.values())),l=e.computed(()=>s.value.filter(P=>P.status==="live")),c=e.computed(()=>r.value.filter(P=>P.processing_status==="processing"));function d(P){a.value.set(P.uuid,P)}function u(P,B){const L=a.value.get(P);L&&a.value.set(P,{...L,...B})}function f(P){a.value.delete(P)}function p(P){return a.value.get(P)}function m(P){n.value.set(P.id,P)}function h(P,B){const L=n.value.get(P);L&&n.value.set(P,{...L,...B})}function g(P,B){const L=n.value.get(P);L&&n.value.set(P,{...L,status:B.status,viewer_count:B.viewer_count,peak_viewers:B.peak_viewers})}function k(P){n.value.delete(P)}function $(P){return n.value.get(P)}function D(P){return s.value.find(B=>B.media_uuid===P)}function _(P){t.value.set(P.id,P)}function v(P,B){const L=t.value.get(P);L&&t.value.set(P,{...L,...B})}function S(P){t.value.delete(P)}function C(P){return t.value.get(P)}function V(P){return Array.from(t.value.values()).filter(B=>B.media_uuid===P)}function x(P){o.value=P}function T(P){o.value&&(o.value={...o.value,...P})}function j(){o.value=null}function E(P){i.value=P}function A(){a.value.clear(),n.value.clear(),t.value.clear(),o.value=null,i.value=!1}function N(P){a.value.clear(),P.forEach(B=>{a.value.set(B.uuid,B)})}function z(P){n.value.clear(),P.forEach(B=>{n.value.set(B.id,B)})}return{videos:a,liveStreams:n,exportJobs:t,currentEditorState:o,isProcessing:i,allVideos:r,allLiveStreams:s,activeLiveStreams:l,processingVideos:c,setVideo:d,updateVideo:u,removeVideo:f,getVideo:p,setLiveStream:m,updateLiveStream:h,updateLiveStreamStats:g,removeLiveStream:k,getLiveStream:$,getLiveStreamByMedia:D,addExportJob:_,updateExportJob:v,removeExportJob:S,getExportJob:C,getExportJobsByMedia:V,setEditorState:x,updateEditorState:T,clearEditorState:j,setProcessing:E,clearAll:A,loadVideos:N,loadLiveStreams:z}});let _a=null;function o5(a){_a=a}const Fi={post:async(a,n)=>{if(!_a)throw new Error("HTTP client not configured");return await _a(`/api/v1/video${a}`,{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json"}})},get:async a=>{if(!_a)throw new Error("HTTP client not configured");return await _a(`/api/v1/video${a}`)},delete:async a=>{if(!_a)throw new Error("HTTP client not configured");return await _a(`/api/v1/video${a}`,{method:"DELETE"})}};function $i(a,n=null){const t=typeof a.id=="string"&&a.id!==""?a.id:typeof a.stream_id=="string"&&a.stream_id!==""?a.stream_id:n==null?void 0:n.id;if(!t)throw new Error("Invalid live stream response: missing stream id");const o={id:t,media_uuid:a.media_uuid??(n==null?void 0:n.media_uuid)??"",stream_key:a.stream_key??(n==null?void 0:n.stream_key)??"",rtmp_url:a.rtmp_url??(n==null?void 0:n.rtmp_url)??"",status:a.status??(n==null?void 0:n.status)??"idle",viewer_count:a.viewer_count??(n==null?void 0:n.viewer_count)??0,peak_viewers:a.peak_viewers??(n==null?void 0:n.peak_viewers)??0,auto_record:a.auto_record??(n==null?void 0:n.auto_record)??!0,low_latency:a.low_latency??(n==null?void 0:n.low_latency)??!1},i=a.playback_url??(n==null?void 0:n.playback_url);i!==void 0&&(o.playback_url=i);const r=a.started_at??(n==null?void 0:n.started_at);r!==void 0&&(o.started_at=r);const s=a.ended_at??(n==null?void 0:n.ended_at);return s!==void 0&&(o.ended_at=s),(n==null?void 0:n.metadata)!==void 0&&(o.metadata=n.metadata),(n==null?void 0:n.vod_media_uuid)!==void 0&&(o.vod_media_uuid=n.vod_media_uuid),o}function ys(a,n){return a instanceof Error&&a.message?a.message:n}function i5(a){const n=a5(),t=e.ref(null),o=e.ref(!1),i=e.ref(!0),r=e.ref(""),s=e.ref(!1),l=e.ref(!1),c=e.ref(null),d=e.ref(null),u=e.ref(0),f=e.ref(0);let p;const m=e.computed(()=>d.value?Math.floor((new Date().getTime()-d.value.getTime())/1e3):0),h=e.computed(()=>{var j;if(!((j=t.value)!=null&&j.playback_url))return null;const T=new URL(t.value.playback_url);return T.searchParams.set("live","true"),o.value&&T.searchParams.set("latency","low"),T.toString()}),g=e.computed(()=>{var T;return((T=t.value)==null?void 0:T.status)==="live"}),k=e.computed(()=>{var T;return((T=t.value)==null?void 0:T.status)==="idle"}),$=e.computed(()=>{var T;return((T=t.value)==null?void 0:T.status)==="ended"});async function D(T={}){s.value=!0,c.value=null;try{const j=await Fi.post("/live",{title:r.value||T.title||"Live Stream",low_latency:T.low_latency??o.value,auto_record:T.auto_record??i.value,...T}),E=$i(j);return t.value=E,n.setLiveStream(E),C(),E}catch(j){throw c.value=ys(j,"Failed to create stream"),j instanceof Error?j:new Error(c.value)}finally{s.value=!1}}async function _(){if(!t.value)throw new Error("No active stream");l.value=!0,c.value=null;try{const T=await Fi.post(`/live/${t.value.id}/end`),j=$i(T,t.value);return t.value=j,n.setLiveStream(j),V(),j}catch(T){throw c.value=ys(T,"Failed to end stream"),T instanceof Error?T:new Error(c.value)}finally{l.value=!1}}async function v(){if(t.value)try{const T=await Fi.get(`/live/${t.value.id}`),j=$i(T,t.value);u.value=j.viewer_count,f.value=j.peak_viewers,t.value=j;const E={status:j.status,viewer_count:j.viewer_count,peak_viewers:j.peak_viewers};j.started_at&&(E.started_at=j.started_at),j.ended_at&&(E.ended_at=j.ended_at),n.updateLiveStreamStats(j.id,E),j.status==="live"&&!d.value&&j.started_at&&(d.value=new Date(j.started_at)),j.status==="ended"&&V()}catch{}}async function S(T){try{const j=await Fi.get(`/live/${T}`),E=$i(j,t.value);return{rtmp_url:E.rtmp_url,stream_key:E.stream_key,playback_url:E.playback_url||""}}catch(j){throw c.value=ys(j,"Failed to get stream credentials"),j instanceof Error?j:new Error(c.value)}}function C(T=5e3){V(),p=window.setInterval(()=>{v()},T)}function V(){p!==void 0&&(clearInterval(p),p=void 0)}async function x(){if(!a)return;const T=n.getLiveStreamByMedia(a);T&&(t.value=T,u.value=T.viewer_count,f.value=T.peak_viewers,T.status==="live"&&(C(),T.started_at&&(d.value=new Date(T.started_at))))}return a&&x(),e.onUnmounted(()=>{V()}),{stream:t,lowLatency:o,autoRecord:i,streamTitle:r,isCreating:s,isEnding:l,error:c,streamDuration:m,viewerCount:u,peakViewers:f,playbackUrl:h,isLive:g,isIdle:k,hasEnded:$,createStream:D,endStream:_,refreshStreamStatus:v,getStreamCredentials:S,startStatusPolling:C,stopStatusPolling:V}}const r5={class:"stream-status"},s5={class:"flex items-center justify-between"},l5={class:"flex items-center gap-3"},c5={key:0,class:"flex items-center"},d5={key:2,class:"text-sm text-gray-600"},u5={key:0,class:"flex items-center gap-2"},m5={class:"text-sm font-medium text-gray-700"},p5={key:0,class:"text-xs text-gray-500"},f5=e.defineComponent({__name:"StreamStatus",props:{status:{},viewers:{},peakViewers:{},duration:{}},setup(a){const n=a,t=e.computed(()=>({idle:"Ready to Stream",live:"Live",ended:"Stream Ended",error:"Error"})[n.status]||n.status),o=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[n.status]||s.idle}`}),i=e.computed(()=>{if(!n.duration)return null;const r=Math.floor(n.duration/3600),s=Math.floor(n.duration%3600/60),l=n.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",r5,[e.createElementVNode("div",s5,[e.createElementVNode("div",l5,[r.status==="live"?(e.openBlock(),e.createElementBlock("div",c5,[...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(o.value)},e.toDisplayString(t.value),3)),i.value?(e.openBlock(),e.createElementBlock("div",d5,e.toDisplayString(i.value),1)):e.createCommentVNode("",!0)]),r.viewers!==void 0?(e.openBlock(),e.createElementBlock("div",u5,[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",m5,e.toDisplayString(r.viewers)+" "+e.toDisplayString(r.viewers===1?"viewer":"viewers"),1),r.peakViewers>r.viewers?(e.openBlock(),e.createElementBlock("span",p5," (Peak: "+e.toDisplayString(r.peakViewers)+") ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])]))}}),h5=Me(f5,[["__scopeId","data-v-1d09c19f"]]),v5={class:"stream-credentials"},g5={class:"space-y-3"},y5={class:"credential-field"},b5={class:"flex gap-2"},w5=["value"],k5={class:"credential-field"},_5={class:"flex gap-2"},E5=["value","type"],x5=["aria-label"],S5={key:0,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},C5={key:1,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},V5={key:0,class:"mt-2 text-sm text-green-600"},N5=e.defineComponent({__name:"StreamCredentials",props:{rtmpUrl:{},streamKey:{}},emits:["copy"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(!1),r=e.ref(""),s=e.computed(()=>{if(i.value)return t.streamKey;if(t.streamKey.length>8){const d=t.streamKey.slice(0,4),u=t.streamKey.slice(-4);return`${d}${"•".repeat(16)}${u}`}return"•".repeat(t.streamKey.length)});function l(){i.value=!i.value}async function c(d,u){try{await navigator.clipboard.writeText(d),r.value=u,o("copy",d,u),setTimeout(()=>{r.value=""},2e3)}catch{}}return(d,u)=>(e.openBlock(),e.createElementBlock("div",v5,[u[8]||(u[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Stream Settings",-1)),e.createElementVNode("div",g5,[e.createElementVNode("div",y5,[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",b5,[e.createElementVNode("input",{value:d.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,w5),e.createElementVNode("button",{onClick:u[0]||(u[0]=f=>c(d.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",k5,[u[7]||(u[7]=e.createElementVNode("label",{class:"block text-xs font-medium text-gray-500 mb-1"},"Stream Key",-1)),e.createElementVNode("div",_5,[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,E5),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",C5,[...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",S5,[...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,x5),e.createElementVNode("button",{onClick:u[1]||(u[1]=f=>c(d.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",V5,e.toDisplayString(r.value)+" copied to clipboard! ",1)):e.createCommentVNode("",!0)]),_:1})]))}}),T5=Me(N5,[["__scopeId","data-v-306d92f6"]]),M5={class:"live-stream-manager","data-testid":"live-stream-manager"},B5={key:0,class:"stream-setup"},I5={class:"space-y-4"},F5={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},$5={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},D5=["disabled"],R5={key:0},A5={key:1,class:"flex items-center justify-center"},L5={key:1,class:"stream-active space-y-6"},P5={key:1,class:"video-preview"},O5={key:2,class:"analytics-panel"},U5={class:"grid grid-cols-2 gap-4"},z5={class:"bg-gray-50 p-3 rounded"},j5={class:"text-2xl font-bold text-gray-900"},W5={class:"bg-gray-50 p-3 rounded"},Z5={class:"text-2xl font-bold text-gray-900"},H5={class:"stream-controls flex gap-3"},X5=["disabled"],G5={key:0},J5={key:1},K5={key:2,class:"mt-4 p-4 bg-red-50 border border-red-200 rounded-lg"},Y5={class:"text-red-600 text-sm"},q5=e.defineComponent({__name:"LiveStreamManager",props:{mediaUuid:{},onStreamCreated:{type:Function},onStreamEnded:{type:Function},httpClient:{type:Function}},emits:["stream-created","stream-ended","error"],setup(a,{emit:n}){const t=a,o=n;t.httpClient&&o5(t.httpClient);const{stream:i,lowLatency:r,autoRecord:s,streamTitle:l,isCreating:c,isEnding:d,error:u,createStream:f,endStream:p,streamDuration:m,playbackUrl:h,refreshStreamStatus:g}=i5(t.mediaUuid),k=e.ref(!1);async function $(){var C;try{const V=await f({title:l.value,low_latency:r.value,auto_record:s.value});o("stream-created",V),(C=t.onStreamCreated)==null||C.call(t,V)}catch(V){o("error",V)}}async function D(){var C;try{const V=await p();o("stream-ended",V),(C=t.onStreamEnded)==null||C.call(t,V)}catch(V){o("error",V)}}function _(){i.value=null,l.value="",k.value=!1,u.value=null}async function v(C,V){try{await navigator.clipboard.writeText(C)}catch{}}let S;return e.onMounted(()=>{var C;((C=i.value)==null?void 0:C.status)==="live"&&(S=window.setInterval(()=>{g()},5e3))}),e.onUnmounted(()=>{S&&clearInterval(S)}),(C,V)=>(e.openBlock(),e.createElementBlock("div",M5,[e.unref(i)?(e.openBlock(),e.createElementBlock("div",L5,[e.createVNode(h5,{status:e.unref(i).status,viewers:e.unref(i).viewer_count,duration:e.unref(m),"peak-viewers":e.unref(i).peak_viewers},null,8,["status","viewers","duration","peak-viewers"]),e.unref(i).status==="idle"?(e.openBlock(),e.createBlock(T5,{key:0,"rtmp-url":e.unref(i).rtmp_url,"stream-key":e.unref(i).stream_key,onCopy:v},null,8,["rtmp-url","stream-key"])):e.createCommentVNode("",!0),e.unref(h)?(e.openBlock(),e.createElementBlock("div",P5,[V[9]||(V[9]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-2"},"Live Preview",-1)),e.createVNode(Om,{"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",O5,[V[12]||(V[12]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Live Analytics",-1)),e.createElementVNode("div",U5,[e.createElementVNode("div",z5,[e.createElementVNode("div",j5,e.toDisplayString(e.unref(i).viewer_count),1),V[10]||(V[10]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Current Viewers",-1))]),e.createElementVNode("div",W5,[e.createElementVNode("div",Z5,e.toDisplayString(e.unref(i).peak_viewers),1),V[11]||(V[11]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Peak Viewers",-1))])])])):e.createCommentVNode("",!0),e.createElementVNode("div",H5,[e.unref(i).status==="idle"?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:V[3]||(V[3]=x=>k.value=!k.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(k.value?"Hide":"Show")+" Credentials ",1)):e.createCommentVNode("",!0),e.unref(i).status==="live"?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:D,disabled:e.unref(d),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(d)?(e.openBlock(),e.createElementBlock("span",J5,"Ending...")):(e.openBlock(),e.createElementBlock("span",G5,"End Stream"))],8,X5)):e.createCommentVNode("",!0),e.unref(i).status==="ended"?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:_,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",B5,[V[8]||(V[8]=e.createElementVNode("h3",{class:"text-lg font-semibold mb-4"},"Start Live Stream",-1)),e.createElementVNode("div",I5,[e.createElementVNode("div",F5,[V[4]||(V[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":V[0]||(V[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",$5,[V[5]||(V[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":V[1]||(V[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,[V[6]||(V[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":V[2]||(V[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:$,disabled:e.unref(c),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(c)?(e.openBlock(),e.createElementBlock("span",A5,[...V[7]||(V[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",R5,"Create Stream"))],8,D5)])])),e.unref(u)?(e.openBlock(),e.createElementBlock("div",K5,[e.createElementVNode("p",Y5,e.toDisplayString(e.unref(u)),1)])):e.createCommentVNode("",!0)]))}}),Q5=Me(q5,[["__scopeId","data-v-26291f6f"]]),eB={class:"album-tree-node"},tB=["data-album-id","draggable","aria-selected","aria-expanded"],nB={key:1,class:"album-node__chevron-placeholder"},aB={key:2,"data-testid":"media-count",class:"album-node__count"},oB={key:0,class:"album-tree-node__children",role:"group"},iB=16,rB=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(a,{emit:n}){const t=a,o=n,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),c=e.computed(()=>`${t.depth*iB}px`),d=e.computed(()=>{var _;return((_=t.dragState)==null?void 0:_.draggedAlbumId)===t.album.id}),u=e.computed(()=>{var _;return((_=t.dragState)==null?void 0:_.dropTargetId)===t.album.id}),f=e.computed(()=>{var _;return(_=t.dragState)!=null&&_.draggedAlbumId?t.dragState.draggedAlbumId===t.album.id:!1}),p=e.computed(()=>{const _=["album-node"];return r.value&&_.push("album-node--selected"),s.value&&_.push("album-node--focused"),t.compact&&_.push("album-node--compact"),d.value&&_.push("album-node--dragging"),u.value&&_.push("album-node--drop-target"),f.value&&_.push("album-node--invalid-drop"),_});function m(){o("select",t.album)}function h(_){_.stopPropagation(),o("toggle-expand",t.album.id)}function g(_){t.draggable&&(_.dataTransfer&&(_.dataTransfer.setData("text/plain",t.album.id),_.dataTransfer.effectAllowed="move"),o("drag-start",t.album.id))}function k(_){t.draggable&&(_.preventDefault(),_.dataTransfer&&(_.dataTransfer.dropEffect="move"),o("drag-over",t.album.id))}function $(){o("drag-leave",t.album.id)}function D(_){t.draggable&&(_.preventDefault(),o("drop",t.album.id))}return(_,v)=>{var C;const S=e.resolveComponent("AlbumTreeNode",!0);return e.openBlock(),e.createElementBlock("div",eB,[e.createElementVNode("div",{"data-testid":"album-node","data-album-id":_.album.id,class:e.normalizeClass(p.value),style:e.normalizeStyle({paddingLeft:c.value}),draggable:_.draggable,role:"treeitem","aria-selected":r.value,"aria-expanded":l.value?i.value:void 0,onDragstart:g,onDragover:k,onDragleave:$,onDrop:D},[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(U.IonIcon),{icon:i.value?e.unref(Nf):e.unref(Tf)},null,8,["icon"])])):(e.openBlock(),e.createElementBlock("span",nB)),e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Af),class:"album-node__icon"},null,8,["icon"]),e.createElementVNode("span",{"data-testid":"album-name",class:"album-node__name",onClick:m},e.toDisplayString(_.album.name),1),_.showMediaCount?(e.openBlock(),e.createElementBlock("span",aB,e.toDisplayString(_.album.media_count),1)):e.createCommentVNode("",!0)],46,tB),i.value&&((C=_.album.children)!=null&&C.length)?(e.openBlock(),e.createElementBlock("div",oB,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.album.children,V=>(e.openBlock(),e.createBlock(S,{key:V.id,album:V,depth:_.depth+1,"selected-id":_.selectedId,"expanded-ids":_.expandedIds,"focused-id":_.focusedId,draggable:_.draggable,"show-media-count":_.showMediaCount,compact:_.compact,onSelect:v[0]||(v[0]=x=>o("select",x)),onToggleExpand:v[1]||(v[1]=x=>o("toggle-expand",x))},null,8,["album","depth","selected-id","expanded-ids","focused-id","draggable","show-media-count","compact"]))),128))])):e.createCommentVNode("",!0)])}}}),sB=Me(rB,[["__scopeId","data-v-76be65a6"]]),Pr=mr.defineStore("albums",()=>{const a=e.ref([]),n=e.ref(new Map),t=e.ref(!1),o=e.ref(null),i=e.ref(new Set),r=e.computed(()=>{const v=new Map;return a.value.forEach(S=>v.set(S.id,S)),v}),s=e.computed(()=>a.value.filter(v=>v.parent_id===null));async function l(v){t.value=!0,o.value=null;try{const S=(v==null?void 0:v.parent_id)??null,C=S?`/api/v1/albums?parent_id=${S}`:"/api/v1/albums?parent_id=null",V=await fetch(C);if(!V.ok)throw new Error("Failed to fetch albums");((await V.json()).data||[]).forEach(j=>{const E=a.value.findIndex(A=>A.id===j.id);E>=0?a.value[E]=j:a.value.push(j)}),S!==null&&i.value.add(S)}catch(S){o.value=S instanceof Error?S.message:"Unknown error"}finally{t.value=!1}}async function c(v){t.value=!0,o.value=null;try{const S=await fetch(`/api/v1/albums/${v}`);if(!S.ok)throw new Error("Failed to fetch album");const V=(await S.json()).data,x=a.value.findIndex(T=>T.id===V.id);return x>=0?a.value[x]=V:a.value.push(V),V}catch(S){throw o.value=S instanceof Error?S.message:"Unknown error",S}finally{t.value=!1}}async function d(v){t.value=!0,o.value=null;try{const S=await fetch(`/api/v1/albums/${v}/media`);if(!S.ok)throw new Error("Failed to fetch album media");const V=(await S.json()).data||[];return n.value.set(v,V),V}catch(S){throw o.value=S instanceof Error?S.message:"Unknown error",S}finally{t.value=!1}}async function u(v,S){t.value=!0,o.value=null;try{if(!(await fetch(`/api/v1/albums/${v}/media/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({media_ids:S})})).ok)throw new Error("Failed to reorder album media");const V=n.value.get(v)||[],x=S.map(T=>V.find(j=>j.uuid===T)).filter(T=>T!==void 0);n.value.set(v,x)}catch(C){throw o.value=C instanceof Error?C.message:"Unknown error",C}finally{t.value=!1}}async function f(v){t.value=!0,o.value=null;try{const S=await fetch("/api/v1/albums",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(v)});if(!S.ok)throw new Error("Failed to create album");const V=(await S.json()).data;return a.value.push(V),V}catch(S){throw o.value=S instanceof Error?S.message:"Unknown error",S}finally{t.value=!1}}async function p(v,S){t.value=!0,o.value=null;try{const C=await fetch(`/api/v1/albums/${v}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(S)});if(!C.ok)throw new Error("Failed to update album");const x=(await C.json()).data,T=a.value.findIndex(j=>j.id===x.id);return T>=0&&(a.value[T]=x),x}catch(C){throw o.value=C instanceof Error?C.message:"Unknown error",C}finally{t.value=!1}}async function m(v){t.value=!0,o.value=null;try{if(!(await fetch(`/api/v1/albums/${v}`,{method:"DELETE",headers:{"Content-Type":"application/json"},credentials:"include"})).ok)throw new Error("Failed to delete album");const C=a.value.findIndex(V=>V.id===v);C>=0&&a.value.splice(C,1),n.value.delete(v)}catch(S){throw o.value=S instanceof Error?S.message:"Unknown error",S}finally{t.value=!1}}function h(v){return a.value.filter(S=>S.parent_id===v)}function g(v){return i.value.has(v)}function k(v){return n.value.get(v)||[]}async function $(v,S){const C=a.value.findIndex(x=>x.id===v);if(C<0)return;const V=a.value[C];a.value[C]={...V,parent_id:S};try{if(!(await fetch(`/api/v1/albums/${v}/move`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({parent_id:S})})).ok)throw new Error("Failed to move album")}catch(x){throw a.value[C]=V,o.value=x instanceof Error?x.message:"Unknown error",x instanceof Error?x:new Error("Failed to move album")}}function D(v){a.value=v}function _(){a.value=[],n.value.clear(),t.value=!1,o.value=null,i.value.clear()}return{albums:a,albumMedia:n,loading:t,error:o,childrenLoadedById:i,albumsById:r,rootAlbums:s,fetchAlbums:l,fetchAlbum:c,fetchAlbumMedia:d,reorderAlbumMedia:u,createAlbum:f,updateAlbum:p,deleteAlbum:m,getChildrenOf:h,childrenLoaded:g,getAlbumMedia:k,moveAlbum:$,setAlbums:D,reset:_}});function Um(){const a=Pr(),{albums:n,albumsById:t,rootAlbums:o,loading:i,error:r}=mr.storeToRefs(a);async function s(u){await a.fetchAlbums(u)}function l(u){return a.getChildrenOf(u)}function c(u){return a.childrenLoaded(u)}async function d(u,f){await a.moveAlbum(u,f)}return{albums:n,albumsById:t,rootAlbums:o,loading:i,error:r,fetchAlbums:s,getChildrenOf:l,childrenLoaded:c,moveAlbum:d}}function zm(a){const{childrenByParentId:n,onMove:t}=a,o=e.ref({isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null});function i(f,p){if(f===p)return!0;const m=new Set,h=[f];for(;h.length>0;){const g=h.shift();if(!g||m.has(g))continue;m.add(g);const k=n.get(g)||[];for(const $ of k){if($===p)return!0;h.push($)}}return!1}function r(f,p){return f===p?!1:p===null?!0:!i(f,p)}function s(f){o.value={isDragging:!0,draggedAlbumId:f,dropTargetId:null,dropPosition:null}}function l(){o.value={isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null}}function c(f){o.value.dropTargetId=f}function d(){o.value.dropTargetId=null,o.value.dropPosition=null}async function u(){const{draggedAlbumId:f,dropTargetId:p}=o.value;if(!f){l();return}if(!r(f,p)){l();return}try{await t(f,p)}finally{l()}}return{dragState:o,isDescendant:i,canDropOn:r,startDrag:s,endDrag:l,setDropTarget:c,clearDropTarget:d,executeDrop:u}}const lB={key:0,"data-testid":"loading-spinner",class:"album-tree__loading"},cB={key:1,"data-testid":"error-state",class:"album-tree__error"},dB={key:2,"data-testid":"empty-state",class:"album-tree__empty"},uB={key:3,class:"album-tree__content",role:"group"},mB=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(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>o.draggable===!0),s=e.computed(()=>o.showMediaCount===!0),l=e.computed(()=>o.compact===!0),{albums:c,rootAlbums:d,loading:u,error:f,fetchAlbums:p,getChildrenOf:m,childrenLoaded:h,moveAlbum:g}=Um(),k=e.shallowRef(new Set(o.expandedIds)),$=e.ref(o.modelValue??null),D=e.ref(null),_=new Map,v=new Map;function S(R){_.clear(),v.clear();for(const M of R){_.set(M.id,M);const H=M.parent_id??null,ee=v.get(H)??[];ee.push(M.id),v.set(H,ee)}}e.watch(c,R=>{S(R)},{immediate:!0});const{dragState:C,canDropOn:V,startDrag:x,endDrag:T,setDropTarget:j,clearDropTarget:E,executeDrop:A}=zm({childrenByParentId:v,onMove:async(R,M)=>{await g(R,M),i("album-moved",{albumId:R,newParentId:M})}});e.watch(()=>o.modelValue,R=>{$.value=R??null}),e.watch(()=>o.expandedIds,R=>{k.value=new Set(R)}),e.onMounted(async()=>{await p({parent_id:null})});const N=e.computed(()=>d.value.map(R=>z(R)));function z(R){if(!k.value.has(R.id))return R;const M=m(R.id);return{...R,children:M.map(H=>z(H))}}const P=e.computed(()=>{const R=[];function M(H){var ee;for(const ae of H)R.push(ae),k.value.has(ae.id)&&((ee=ae.children)!=null&&ee.length)&&M(ae.children)}return M(N.value),R});function B(R){var ee;if(!P.value.length)return;const M=D.value?P.value.findIndex(ae=>ae.id===D.value):-1,H=M>=0?P.value[M]:null;switch(R.key){case"ArrowDown":R.preventDefault(),M<P.value.length-1?D.value=P.value[M+1].id:M===-1&&P.value.length>0&&(D.value=P.value[0].id);break;case"ArrowUp":R.preventDefault(),M>0&&(D.value=P.value[M-1].id);break;case"ArrowRight":R.preventDefault(),H&&(H.children_count>0&&!k.value.has(H.id)?L(H.id):k.value.has(H.id)&&((ee=H.children)!=null&&ee.length)&&(D.value=H.children[0].id));break;case"ArrowLeft":R.preventDefault(),H&&(k.value.has(H.id)&&H.children_count>0?L(H.id):H.parent_id&&(D.value=H.parent_id));break;case"Enter":case" ":R.preventDefault(),H&&w(H);break;case"Home":R.preventDefault(),P.value.length>0&&(D.value=P.value[0].id);break;case"End":R.preventDefault(),P.value.length>0&&(D.value=P.value[P.value.length-1].id);break}}async function L(R){k.value.has(R)?(k.value.delete(R),i("album-collapsed",R)):(h(R)||await p({parent_id:R}),k.value.add(R),i("album-expanded",R))}function w(R){$.value=R.id,i("update:modelValue",R.id),i("album-selected",R)}function O(R){o.draggable&&x(R)}function Z(R){var H;if(!o.draggable)return;const M=(H=C.value)==null?void 0:H.draggedAlbumId;M&&(j(R),V(M,R))}function G(){o.draggable&&E()}async function re(R){o.draggable&&(j(R),await A())}function be(R){o.draggable&&(R.preventDefault(),j(null))}async function Ee(R){o.draggable&&(R.preventDefault(),j(null),await A())}function ie(){T()}return n({focusedId:D}),(R,M)=>(e.openBlock(),e.createElementBlock("div",{class:"album-tree","data-testid":"album-tree",tabindex:"0",role:"tree","aria-label":"Album tree",onKeydown:B,onDragover:be,onDrop:Ee,onDragend:ie},[e.unref(u)?(e.openBlock(),e.createElementBlock("div",lB,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"})])):e.unref(f)?(e.openBlock(),e.createElementBlock("div",cB,[e.createElementVNode("p",null,e.toDisplayString(e.unref(f)),1)])):e.unref(d).length?(e.openBlock(),e.createElementBlock("div",uB,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(N.value,H=>(e.openBlock(),e.createBlock(sB,{key:H.id,album:H,depth:0,"selected-id":$.value,"expanded-ids":k.value,"focused-id":D.value,draggable:r.value,"drag-state":r.value?e.unref(C):null,"show-media-count":s.value,compact:l.value,onSelect:w,onToggleExpand:L,onDragStart:O,onDragOver:Z,onDragLeave:G,onDrop:re},null,8,["album","selected-id","expanded-ids","focused-id","draggable","drag-state","show-media-count","compact"]))),128))])):(e.openBlock(),e.createElementBlock("div",dB,[M[0]||(M[0]=e.createElementVNode("p",null,"No albums yet",-1)),e.renderSlot(R.$slots,"empty-action",{},void 0,!0)]))],32))}}),jm=Me(mB,[["__scopeId","data-v-ae3dea7a"]]),pB=300,fB=e.defineComponent({__name:"AlbumBrowser",props:{isOpen:{type:Boolean},selectedAlbumId:{default:null},title:{default:"Select Album"},confirmText:{default:"Select"}},emits:["close","confirm"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(t.selectedAlbumId??null),r=e.ref(null),s=e.ref(0),l=e.ref(null);e.watch(()=>t.selectedAlbumId,m=>{i.value=m??null});const c=e.computed(()=>r.value!==null);function d(m){const h=Date.now();if(l.value===m.id&&h-s.value<pB){o("confirm",m);return}s.value=h,l.value=m.id,i.value=m.id,r.value=m}function u(){r.value&&o("confirm",r.value)}function f(){o("close")}function p(){o("close")}return(m,h)=>(e.openBlock(),e.createBlock(e.unref(U.IonModal),{"is-open":m.isOpen,class:"album-browser-modal",onDidDismiss:p},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(m.title),1)]),_:1}),e.createVNode(e.unref(U.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.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(U.IonContent),{class:"album-browser-content"},{default:e.withCtx(()=>[e.createVNode(jm,{modelValue:i.value,"onUpdate:modelValue":h[0]||(h[0]=g=>i.value=g),draggable:!1,"show-media-count":!0,compact:!1,onAlbumSelected:d},null,8,["modelValue"])]),_:1}),e.createVNode(e.unref(U.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonButton),{fill:"clear",onClick:f},{default:e.withCtx(()=>[...h[2]||(h[2]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(U.IonButton),{"data-testid":"confirm-button",fill:"solid",color:"primary",disabled:!c.value,onClick:u},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(m.confirmText),1)]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"]))}}),Wm=Me(fB,[["__scopeId","data-v-21676ec1"]]),hB={class:"ion-padding-start text-sm"},vB={class:"ion-padding-start text-sm"},gB={key:1},yB={key:1,class:"album-manager-inline rounded-lg border border-gray-200 bg-white p-4"},bB={class:"flex items-center justify-between gap-3 pb-3"},wB={class:"text-base font-semibold text-gray-900"},kB={class:"ion-padding-start text-sm"},_B={class:"ion-padding-start text-sm"},EB={class:"flex justify-between pt-2"},xB={key:1},To=255,Mo=1e3,SB=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(a,{emit:n}){const t=a,o=n,i=Pr(),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"),c=e.ref({name:"",description:"",parent_id:t.parentId}),d=e.ref({name:!1,description:!1}),u=e.ref(null),f=e.ref(!1),p=e.ref(null),m=e.ref(!1),h=e.ref(!1),g=e.computed(()=>d.value.name?c.value.name.trim()?c.value.name.length>To?`Name must be ${To} characters or less`:null:"Name is required":null),k=e.computed(()=>d.value.description&&c.value.description.length>Mo?`Description must be ${Mo} characters or less`:null),$=e.computed(()=>{const B=c.value.name.trim().length>0,L=c.value.name.length<=To,w=c.value.description.length<=Mo;return B&&L&&w&&!m.value}),D=e.computed(()=>{var B;return((B=u.value)==null?void 0:B.name)??"None (Root)"}),_=e.computed(()=>p.value?p.value.children_count===0&&p.value.media_count===0:!1),v=e.computed(()=>p.value?p.value.children_count>0?"Cannot delete album with child albums. Move or delete children first.":p.value.media_count>0?"Cannot delete album with media. Remove media first.":`Are you sure you want to delete "${p.value.name}"? This action cannot be undone.`:"");e.onMounted(async()=>{t.albumId&&await S()});async function S(){if(t.albumId)try{const B=await i.fetchAlbum(t.albumId);p.value=B,c.value={name:B.name,description:B.description??"",parent_id:B.parent_id},B.parent_id&&(u.value={id:B.parent_id,name:"Parent Album"})}catch(B){o("error",B)}}function C(){d.value.name=!0}function V(){d.value.description=!0}function x(){f.value=!0}function T(B){u.value={id:B.id,name:B.name},c.value.parent_id=B.id,f.value=!1}function j(){f.value=!1}function E(){o("close")}function A(){o("close")}async function N(){if(d.value.name=!0,d.value.description=!0,!(!$.value||m.value)){m.value=!0;try{const B={name:c.value.name.trim(),description:c.value.description.trim(),parent_id:c.value.parent_id};if(r.value&&t.albumId){const L=await i.updateAlbum(t.albumId,B);o("updated",L)}else{const L=await i.createAlbum(B);o("created",L)}o("close")}catch(B){o("error",B)}finally{m.value=!1}}}function z(){_.value&&(h.value=!0)}async function P(B){var w;if((((w=B.detail)==null?void 0:w.role)??"")!=="confirm"){h.value=!1;return}if(t.albumId){m.value=!0;try{await i.deleteAlbum(t.albumId),o("deleted",t.albumId),o("close")}catch(O){o("error",O)}finally{m.value=!1,h.value=!1}}}return(B,L)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[B.mode==="modal"?(e.openBlock(),e.createBlock(e.unref(U.IonModal),{key:0,"is-open":B.isOpen,class:"album-manager-modal",onDidDismiss:A},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.value),1)]),_:1}),e.createVNode(e.unref(U.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:E},{default:e.withCtx(()=>[...L[4]||(L[4]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(U.IonContent),{class:"album-manager-content"},{default:e.withCtx(()=>[e.createElementVNode("form",{"data-testid":"album-form",class:"p-4 space-y-3",onSubmit:e.withModifiers(N,["prevent"])},[e.createVNode(e.unref(U.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...L[5]||(L[5]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(U.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":L[0]||(L[0]=w=>c.value.name=w),"data-testid":"name-input",maxlength:To,onIonBlur:C},null,8,["modelValue"])]),_:1}),g.value?(e.openBlock(),e.createBlock(e.unref(U.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",hB,e.toDisplayString(g.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(U.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...L[6]||(L[6]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(U.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":L[1]||(L[1]=w=>c.value.description=w),"data-testid":"description-input",maxlength:Mo,onIonBlur:V},null,8,["modelValue"])]),_:1}),k.value?(e.openBlock(),e.createBlock(e.unref(U.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",vB,e.toDisplayString(k.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(U.IonItem),{button:"","data-testid":"parent-selector",onClick:x},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...L[7]||(L[7]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(U.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(D.value),1)]),_:1})]),_:1})],32)]),_:1}),e.createVNode(e.unref(U.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonButtons),{slot:"start"},{default:e.withCtx(()=>[r.value?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",disabled:!_.value,title:_.value?void 0:v.value,onClick:z},{default:e.withCtx(()=>[...L[8]||(L[8]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.unref(U.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!$.value,onClick:N},{default:e.withCtx(()=>[m.value?(e.openBlock(),e.createBlock(e.unref(U.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",gB,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"])):(e.openBlock(),e.createElementBlock("div",yB,[e.createElementVNode("div",bB,[e.createElementVNode("h2",wB,e.toDisplayString(s.value),1),e.createVNode(e.unref(U.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:E},{default:e.withCtx(()=>[...L[9]||(L[9]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),e.createElementVNode("form",{"data-testid":"album-form",class:"space-y-3",onSubmit:e.withModifiers(N,["prevent"])},[e.createVNode(e.unref(U.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...L[10]||(L[10]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(U.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":L[2]||(L[2]=w=>c.value.name=w),"data-testid":"name-input",maxlength:To,onIonBlur:C},null,8,["modelValue"])]),_:1}),g.value?(e.openBlock(),e.createBlock(e.unref(U.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",kB,e.toDisplayString(g.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(U.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...L[11]||(L[11]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(U.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":L[3]||(L[3]=w=>c.value.description=w),"data-testid":"description-input",maxlength:Mo,onIonBlur:V},null,8,["modelValue"])]),_:1}),k.value?(e.openBlock(),e.createBlock(e.unref(U.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",_B,e.toDisplayString(k.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(U.IonItem),{button:"","data-testid":"parent-selector",onClick:x},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...L[12]||(L[12]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(U.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(D.value),1)]),_:1})]),_:1}),e.createElementVNode("div",EB,[e.createElementVNode("div",null,[r.value?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",fill:"outline",disabled:!_.value,title:_.value?void 0:v.value,onClick:z},{default:e.withCtx(()=>[...L[13]||(L[13]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(U.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!$.value,onClick:N},{default:e.withCtx(()=>[m.value?(e.openBlock(),e.createBlock(e.unref(U.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",xB,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])])],32)])),e.createVNode(Wm,{"is-open":f.value,"selected-album-id":c.value.parent_id,title:"Select Parent Album",onClose:j,onConfirm:T},null,8,["is-open","selected-album-id"]),e.createVNode(e.unref(U.IonAlert),{"is-open":h.value,header:"Delete Album?",message:v.value,buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"confirm",cssClass:"alert-button-danger"}],onDidDismiss:P},null,8,["is-open","message"])],64))}}),CB=Me(SB,[["__scopeId","data-v-22083f3a"]]),VB={class:"album-media-grid"},NB={class:"aspect-square"},TB={key:1,"data-testid":"empty-state",class:"flex flex-col items-center justify-center py-12 gap-4"},MB={class:"text-gray-500"},BB=["data-media-id","draggable","onDragstart","onDragover","onDrop","onMouseenter"],IB={key:0,"data-testid":"drop-indicator",class:"absolute inset-0 border-2 border-primary rounded-lg pointer-events-none z-30"},FB={key:1,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"},$B={class:"aspect-square relative"},DB=["src","alt"],RB={key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center gap-2 transition-opacity"},AB=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(a,{emit:n}){const t=a,o=n,i=Pr(),r=e.ref([]),s=e.ref(!1),l=e.ref(null),c=e.ref(null),d=e.ref(null),u=e.computed(()=>t.isLoading||s.value),f=e.computed(()=>!u.value&&r.value.length===0),p=e.computed(()=>{const A=t.columns;return["grid","gap-4",`grid-cols-${A.mobile??2}`,`sm:grid-cols-${A.sm??3}`,`md:grid-cols-${A.md??4}`,`lg:grid-cols-${A.lg??5}`,`xl:grid-cols-${A.xl??6}`]}),m=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 A=await i.fetchAlbumMedia(t.albumId);r.value=A}catch{r.value=[]}finally{s.value=!1}}function g(A){return t.selectedItems.includes(A)}function k(A){o("toggle-select",A);const N=g(A.uuid)?t.selectedItems.filter(z=>z!==A.uuid):[...t.selectedItems,A.uuid];o("selection-change",N)}function $(A){if(A.conversions&&typeof A.conversions=="object"){const N=A.conversions.thumb;if(typeof N=="string")return N}return A.original_url}function D(A){l.value=A}function _(){l.value=null}function v(A){o("preview",A)}function S(A){o("edit",A)}function C(A){o("detach",A.uuid)}function V(){o("add")}function x(A,N){t.reorderable&&(c.value=N,A.dataTransfer&&(A.dataTransfer.effectAllowed="move",A.dataTransfer.setData("text/plain",String(N))))}function T(A,N){!t.reorderable||c.value===null||(A.preventDefault(),d.value=N)}function j(A,N){if(!t.reorderable||c.value===null)return;A.preventDefault();const z=c.value;if(z!==N){const P=[...r.value],[B]=P.splice(z,1);P.splice(N,0,B),r.value=P;const L=P.map(w=>w.uuid);o("reorder",L),i.reorderAlbumMedia(t.albumId,L).catch(()=>{h()})}c.value=null,d.value=null}function E(){c.value=null,d.value=null}return(A,N)=>(e.openBlock(),e.createElementBlock("div",VB,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,"data-testid":"loading-grid",class:e.normalizeClass(p.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,z=>(e.openBlock(),e.createBlock(e.unref(U.IonCard),{key:z,class:"m-0"},{default:e.withCtx(()=>[e.createElementVNode("div",NB,[e.createVNode(e.unref(U.IonSkeletonText),{animated:"",class:"w-full h-full skeleton"})])]),_:1}))),128))],2)):f.value?(e.openBlock(),e.createElementBlock("div",TB,[e.createVNode(e.unref(U.IonIcon),{name:"images-outline",class:"text-6xl text-gray-400"}),e.createElementVNode("p",MB,e.toDisplayString(A.emptyText),1),e.createVNode(e.unref(U.IonButton),{"data-testid":"add-media-btn",onClick:V},{default:e.withCtx(()=>[...N[0]||(N[0]=[e.createTextVNode(" Add Media ",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("div",{key:2,"data-testid":"media-grid",class:e.normalizeClass(p.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(z,P)=>(e.openBlock(),e.createElementBlock("div",{key:z.uuid,"data-media-id":z.uuid,class:e.normalizeClass(["media-item relative group",{"opacity-50":c.value===P,"ring-2 ring-primary":d.value===P&&c.value!==P}]),draggable:A.reorderable,onDragstart:B=>x(B,P),onDragover:B=>T(B,P),onDrop:B=>j(B,P),onDragend:E,onMouseenter:B=>D(z.uuid),onMouseleave:_},[d.value===P&&c.value!==P&&A.reorderable?(e.openBlock(),e.createElementBlock("div",IB)):e.createCommentVNode("",!0),A.reorderable?(e.openBlock(),e.createElementBlock("div",FB,[e.createVNode(e.unref(U.IonIcon),{name:"reorder-three-outline",class:"text-white drop-shadow-md"})])):e.createCommentVNode("",!0),A.selectionMode?(e.openBlock(),e.createBlock(e.unref(U.IonCheckbox),{key:2,"data-testid":"media-checkbox",checked:g(z.uuid),class:"absolute top-2 left-2 z-20",onIonChange:B=>k(z)},null,8,["checked","onIonChange"])):e.createCommentVNode("",!0),e.createVNode(e.unref(U.IonCard),{class:"m-0 overflow-hidden"},{default:e.withCtx(()=>[e.createElementVNode("div",$B,[e.createElementVNode("img",{src:$(z),alt:z.file_name,class:"w-full h-full object-cover"},null,8,DB),A.showActions&&l.value===z.uuid?(e.openBlock(),e.createElementBlock("div",RB,[e.createVNode(e.unref(U.IonButton),{"data-testid":"action-preview",fill:"clear",size:"small",color:"light",onClick:B=>v(z)},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"icon-only",name:"eye-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(U.IonButton),{"data-testid":"action-edit",fill:"clear",size:"small",color:"light",onClick:B=>S(z)},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"icon-only",name:"create-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(U.IonButton),{"data-testid":"action-detach",fill:"clear",size:"small",color:"danger",onClick:B=>C(z)},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"icon-only",name:"close-circle-outline"})]),_:1},8,["onClick"])])):e.createCommentVNode("",!0)])]),_:2},1024)],42,BB))),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:V},[e.createVNode(e.unref(U.IonIcon),{name:"add-circle-outline",class:"text-4xl text-gray-400"}),N[1]||(N[1]=e.createElementVNode("span",{class:"text-sm text-gray-500"},"Add Media",-1))])],2))]))}}),LB=Me(AB,[["__scopeId","data-v-d84b796a"]]),PB={key:0,class:"media-album-inline-create","data-testid":"media-album-inline-create"},OB={class:"media-album-inline-create__field"},UB={class:"media-album-inline-create__field"},zB=["value"],jB={key:1,class:"media-album-inline-create__autocomplete"},WB={class:"media-album-inline-create__autocomplete-input-wrap"},ZB={key:0,class:"media-album-inline-create__autocomplete-list"},HB=["onMousedown"],XB={key:1,class:"media-album-inline-create__autocomplete-empty"},GB={class:"media-album-inline-create__actions"},JB=e.defineComponent({__name:"MediaAlbumInlineCreate",props:{open:{type:Boolean,default:!1},nameLabel:{default:"Album name"},albums:{default:()=>[]}},emits:["cancel","create"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(""),r=e.ref(""),s=e.ref(""),l=e.ref(!1),c=e.computed(()=>t.albums.length>5),d=e.computed(()=>{if(s.value.trim()==="")return t.albums;const k=s.value.toLowerCase();return t.albums.filter($=>$.name.toLowerCase().includes(k))}),u=e.computed(()=>{if(r.value==="")return"";const k=t.albums.find($=>$.id===r.value);return(k==null?void 0:k.name)??""}),f=k=>{r.value=k.id,s.value=k.name,l.value=!1},p=()=>{r.value="",s.value="",l.value=!1},m=()=>{l.value=!0,r.value!==""&&(s.value=u.value)},h=()=>{setTimeout(()=>{l.value=!1,r.value!==""?s.value=u.value:s.value=""},150)},g=()=>{i.value.trim()!==""&&(o("create",i.value.trim(),r.value!==""?r.value:void 0),i.value="",r.value="",s.value="")};return(k,$)=>k.open?(e.openBlock(),e.createElementBlock("section",PB,[$[7]||($[7]=e.createElementVNode("h4",{class:"media-album-inline-create__heading"}," New album ",-1)),e.createElementVNode("label",OB,[e.createElementVNode("span",null,e.toDisplayString(k.nameLabel),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":$[0]||($[0]=D=>i.value=D),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",UB,[$[6]||($[6]=e.createElementVNode("span",null,"Parent album (optional)",-1)),c.value?(e.openBlock(),e.createElementBlock("div",jB,[e.createElementVNode("div",WB,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":$[2]||($[2]=D=>s.value=D),type:"text",class:"media-album-inline-create__input",placeholder:"Search albums...","data-testid":"input-media-album-parent-search",onFocus:m,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(p,["prevent"])},[...$[5]||($[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",ZB,[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(p,["prevent"])}," None ",32)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,D=>(e.openBlock(),e.createElementBlock("li",{key:D.id,class:e.normalizeClass(["media-album-inline-create__autocomplete-option",{"is-selected":D.id===r.value}]),onMousedown:e.withModifiers(_=>f(D),["prevent"])},e.toDisplayString(D.name),43,HB))),128)),d.value.length===0?(e.openBlock(),e.createElementBlock("li",XB," No albums match ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])):e.withDirectives((e.openBlock(),e.createElementBlock("select",{key:0,"onUpdate:modelValue":$[1]||($[1]=D=>r.value=D),class:"media-album-inline-create__input","data-testid":"select-media-album-parent"},[$[4]||($[4]=e.createElementVNode("option",{value:""}," None ",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.albums,D=>(e.openBlock(),e.createElementBlock("option",{key:D.id,value:D.id},e.toDisplayString(D.name),9,zB))),128))],512)),[[e.vModelSelect,r.value]])]),e.createElementVNode("div",GB,[e.createElementVNode("button",{type:"button",class:"media-album-inline-create__button","data-testid":"btn-media-album-cancel",onClick:$[3]||($[3]=D=>o("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:g}," Create ")])])):e.createCommentVNode("",!0)}}),Zm=Me(JB,[["__scopeId","data-v-a85162fe"]]),KB={class:"media-album-unavailable-state","data-testid":"media-album-unavailable-state"},YB=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(a,{emit:n}){const t=n;return(o,i)=>(e.openBlock(),e.createElementBlock("section",KB,[e.createElementVNode("h3",null,e.toDisplayString(o.title),1),e.createElementVNode("p",null,e.toDisplayString(o.body),1),e.createElementVNode("button",{type:"button",class:"media-album-unavailable-state__button",onClick:i[0]||(i[0]=r=>t("goToLibrary"))},e.toDisplayString(o.actionLabel),1)]))}}),Hm=Me(YB,[["__scopeId","data-v-04620e64"]]),qB={key:0,class:"media-preview-sheet","data-testid":"media-preview-sheet"},QB={class:"media-preview-sheet__header"},e8=["src","alt"],t8=["src"],n8={class:"media-preview-sheet__actions"},a8=["disabled"],o8=["disabled"],i8=e.defineComponent({__name:"MediaPreviewSheet",props:{open:{type:Boolean,default:!1},media:{default:null},canGoPrevious:{type:Boolean,default:!1},canGoNext:{type:Boolean,default:!1},selected:{type:Boolean,default:!1}},emits:["close","previous","next","toggleSelect"],setup(a,{emit:n}){const t=a,o=n,i=e.computed(()=>{var l;return((l=t.media)==null?void 0:l.mime_type.startsWith("image/"))===!0}),r=e.computed(()=>t.media?t.media.preview_url??t.media.original_url:""),s=()=>{t.media&&o("toggleSelect",t.media)};return(l,c)=>l.open&&l.media?(e.openBlock(),e.createElementBlock("section",qB,[e.createElementVNode("header",QB,[e.createElementVNode("strong",null,e.toDisplayString(l.media.file_name),1),e.createElementVNode("button",{type:"button",class:"media-preview-sheet__close","aria-label":"Close preview",onClick:c[0]||(c[0]=d=>o("close"))}," Close ")]),i.value?(e.openBlock(),e.createElementBlock("img",{key:0,class:"media-preview-sheet__image",src:r.value,alt:l.media.file_name},null,8,e8)):(e.openBlock(),e.createElementBlock("video",{key:1,class:"media-preview-sheet__video",src:r.value,controls:""},null,8,t8)),e.createElementVNode("div",n8,[e.createElementVNode("button",{type:"button",class:"media-preview-sheet__nav",disabled:!l.canGoPrevious,onClick:c[1]||(c[1]=d=>o("previous"))}," Previous ",8,a8),e.createElementVNode("button",{type:"button",class:"media-preview-sheet__select",onClick:s},e.toDisplayString(l.selected?"Deselect":"Select"),1),e.createElementVNode("button",{type:"button",class:"media-preview-sheet__nav",disabled:!l.canGoNext,onClick:c[2]||(c[2]=d=>o("next"))}," Next ",8,o8)])])):e.createCommentVNode("",!0)}}),Xm=Me(i8,[["__scopeId","data-v-9a05f74e"]]),r8={key:0,class:"media-album-grid","data-testid":"media-source-sheet"},s8={class:"media-album-grid__items"},l8={class:"media-album-grid__card-name"},c8={class:"media-album-grid__card-name"},d8=["data-testid","onClick"],u8={class:"media-album-grid__card-name"},m8={key:0,class:"media-album-grid__card-meta"},p8={key:0,class:"media-album-grid__empty"},f8=e.defineComponent({__name:"MediaSourceSheet",props:{open:{type:Boolean,default:!1},currentView:{},albums:{},viewLibraryLabel:{default:"Library"},browseAlbumsLabel:{default:"Albums"},createAlbumLabel:{default:"Create album"},enableAlbumCreation:{type:Boolean,default:!1}},emits:["close","selectLibrary","selectAlbum","createAlbum"],setup(a,{emit:n}){const t=n;return(o,i)=>o.open?(e.openBlock(),e.createElementBlock("section",r8,[e.createElementVNode("div",s8,[o.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",l8,e.toDisplayString(o.createAlbumLabel),1)])):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["media-album-grid__card",{"is-active":o.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",c8,e.toDisplayString(o.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(o.albums,r=>(e.openBlock(),e.createElementBlock("button",{key:r.id,type:"button",class:e.normalizeClass(["media-album-grid__card",{"is-active":o.currentView.scope==="album"&&o.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",u8,e.toDisplayString(r.name),1),r.mediaCount!==void 0?(e.openBlock(),e.createElementBlock("span",m8,e.toDisplayString(r.mediaCount)+" item"+e.toDisplayString(r.mediaCount===1?"":"s"),1)):e.createCommentVNode("",!0)],10,d8))),128))]),o.albums.length===0?(e.openBlock(),e.createElementBlock("p",p8," No albums yet. ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}}),Gm=Me(f8,[["__scopeId","data-v-129f67b1"]]),h8={key:0,class:"media-upload-sheet","data-testid":"media-upload-sheet"},v8=["accept"],g8={key:0,class:"media-upload-sheet__queue"},y8={class:"media-upload-sheet__queue-info"},b8={class:"media-upload-sheet__queue-status"},w8={class:"media-upload-sheet__progress-bar"},k8=e.defineComponent({__name:"MediaUploadSheet",props:{open:{type:Boolean,default:!1},queue:{},accept:{default:""},uploadLabel:{default:"Upload"}},emits:["close","filesSelected"],setup(a,{emit:n}){const t=n,o=e.ref(!1),i=c=>{const d=c.target;!(d instanceof HTMLInputElement)||d.files===null||(t("filesSelected",Array.from(d.files)),d.value="")},r=c=>{c.preventDefault(),o.value=!0},s=()=>{o.value=!1},l=c=>{var d;c.preventDefault(),o.value=!1,(d=c.dataTransfer)!=null&&d.files&&c.dataTransfer.files.length>0&&t("filesSelected",Array.from(c.dataTransfer.files))};return(c,d)=>c.open?(e.openBlock(),e.createElementBlock("section",h8,[e.createElementVNode("label",{class:e.normalizeClass(["media-upload-sheet__dropzone",{"is-drag-over":o.value}]),onDragover:r,onDragleave:s,onDrop:l},[d[1]||(d[1]=e.createStaticVNode('<div class="media-upload-sheet__dropzone-icon" data-v-e238d615><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-e238d615><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" data-v-e238d615></path><polyline points="17 8 12 3 7 8" data-v-e238d615></polyline><line x1="12" y1="3" x2="12" y2="15" data-v-e238d615></line></svg></div><span class="media-upload-sheet__dropzone-text" data-v-e238d615> Drop files here or <strong data-v-e238d615>browse</strong></span>',2)),e.createElementVNode("input",{type:"file",accept:c.accept,multiple:"",class:"media-upload-sheet__file-input","data-testid":"input-media-upload-sheet",onChange:i},null,40,v8)],34),c.queue.length>0?(e.openBlock(),e.createElementBlock("ul",g8,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.queue,u=>(e.openBlock(),e.createElementBlock("li",{key:u.id,class:"media-upload-sheet__queue-item"},[e.createElementVNode("div",y8,[e.createElementVNode("strong",null,e.toDisplayString(u.file.name),1),e.createElementVNode("span",b8,e.toDisplayString(u.status),1)]),e.createElementVNode("div",w8,[e.createElementVNode("div",{class:"media-upload-sheet__progress-fill",style:e.normalizeStyle({width:`${u.progress}%`})},null,4)])]))),128))])):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"media-upload-sheet__close-btn","aria-label":"Close upload panel","data-testid":"btn-close-upload-sheet",onClick:d[0]||(d[0]=u=>t("close"))}," Done ")])):e.createCommentVNode("",!0)}}),Jm=Me(k8,[["__scopeId","data-v-e238d615"]]),_8=["aria-label","aria-pressed","data-testid"],E8=["src","alt"],x8={key:1,class:"media-thumbnail-cell__video"},S8={class:"media-thumbnail-cell__video-name"},C8={key:2,class:"media-thumbnail-cell__selected-badge"},V8={key:3,class:"media-thumbnail-cell__status-badge"},N8=["aria-label"],T8=e.defineComponent({__name:"MediaThumbnailCell",props:{media:{},selected:{type:Boolean,default:!1},status:{},testId:{default:"media-library-thumbnail"}},emits:["toggle","preview"],setup(a,{emit:n}){const t=a,o=n,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}`}),c=()=>{o("toggle",t.media)},d=()=>{o("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:c},[r.value?(e.openBlock(),e.createElementBlock("img",{key:0,class:"media-thumbnail-cell__image",src:i.value,alt:u.media.file_name},null,8,E8)):(e.openBlock(),e.createElementBlock("div",x8,[f[0]||(f[0]=e.createElementVNode("span",{class:"media-thumbnail-cell__video-label"},"Video",-1)),e.createElementVNode("span",S8,e.toDisplayString(u.media.file_name),1)])),u.selected?(e.openBlock(),e.createElementBlock("span",C8," Selected ")):e.createCommentVNode("",!0),s.value!==null?(e.openBlock(),e.createElementBlock("span",V8,e.toDisplayString(s.value),1)):e.createCommentVNode("",!0)],8,_8),e.createElementVNode("button",{type:"button",class:"media-thumbnail-cell__preview-button","aria-label":`Preview ${u.media.file_name}`,onClick:d}," Preview ",8,N8)],2))}}),Km=Me(T8,[["__scopeId","data-v-edd4f0ad"]]),M8={class:"virtual-media-grid"},B8={key:0,class:"virtual-media-grid__state","data-testid":"media-grid-loading"},I8={key:1,class:"virtual-media-grid__state","data-testid":"media-grid-empty"},F8={key:2,class:"virtual-media-grid__items"},$8=["disabled"],D8=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"}},emits:["toggle","preview","loadMore"],setup(a,{emit:n}){const t=a,o=n;function i(r){return t.selectedItems.find(s=>s.id===r)}return(r,s)=>(e.openBlock(),e.createElementBlock("div",M8,[r.loading&&r.items.length===0?(e.openBlock(),e.createElementBlock("div",B8," Loading media... ")):r.items.length===0?(e.openBlock(),e.createElementBlock("div",I8,e.toDisplayString(r.emptyMessage),1)):(e.openBlock(),e.createElementBlock("div",F8,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,l=>{var c,d;return e.openBlock(),e.createBlock(Km,{key:l.uuid,media:l,selected:((c=i(l.uuid))==null?void 0:c.status)==="ready",status:(d=i(l.uuid))==null?void 0:d.status,"test-id":`${r.testIdPrefix}-${l.uuid}`,onToggle:s[0]||(s[0]=u=>o("toggle",u)),onPreview:s[1]||(s[1]=u=>o("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=>o("loadMore"))},e.toDisplayString(r.loadingMore?"Loading…":"Load more"),9,$8)):e.createCommentVNode("",!0)]))}}),Ym=Me(D8,[["__scopeId","data-v-820b9a4f"]]);function ur(a){if(a===0)return"0 Bytes";const n=1024,t=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(a)/Math.log(n));return parseFloat((a/Math.pow(n,o)).toFixed(2))+" "+t[o]}function qm(a){var t;const n=a.split(".");return n.length>1?`.${(t=n.pop())==null?void 0:t.toLowerCase()}`:""}function Ul(a){return a.type.startsWith("image/")}async function Qm(a){return Ul(a)?new Promise(n=>{const t=new Image,o=URL.createObjectURL(a);t.onload=()=>{URL.revokeObjectURL(o),n({width:t.naturalWidth,height:t.naturalHeight})},t.onerror=()=>{URL.revokeObjectURL(o),n(null)},t.src=o}):null}async function ep(a,n){const t=[];if(n.maxFileSize&&a.size>n.maxFileSize&&t.push({field:"size",message:`File exceeds maximum size of ${ur(n.maxFileSize)}`,code:"MAX_FILE_SIZE"}),n.minFileSize&&a.size<n.minFileSize&&t.push({field:"size",message:`File is smaller than minimum size of ${ur(n.minFileSize)}`,code:"MIN_FILE_SIZE"}),n.acceptedMimeTypes&&n.acceptedMimeTypes.length>0&&(n.acceptedMimeTypes.some(i=>i.endsWith("/*")?a.type.startsWith(i.slice(0,-1)):a.type===i)||t.push({field:"type",message:`File type "${a.type}" is not allowed`,code:"INVALID_MIME_TYPE"})),n.acceptedExtensions&&n.acceptedExtensions.length>0){const o=qm(a.name);n.acceptedExtensions.some(r=>r.toLowerCase()===o.toLowerCase())||t.push({field:"extension",message:`File extension "${o}" is not allowed`,code:"INVALID_EXTENSION"})}if(Ul(a)&&(n.maxDimensions||n.minDimensions)){const o=await Qm(a);o&&(n.maxDimensions&&(o.width>n.maxDimensions.width&&t.push({field:"dimensions",message:`Image width (${o.width}px) exceeds maximum (${n.maxDimensions.width}px)`,code:"MAX_WIDTH"}),o.height>n.maxDimensions.height&&t.push({field:"dimensions",message:`Image height (${o.height}px) exceeds maximum (${n.maxDimensions.height}px)`,code:"MAX_HEIGHT"})),n.minDimensions&&(o.width<n.minDimensions.width&&t.push({field:"dimensions",message:`Image width (${o.width}px) is smaller than minimum (${n.minDimensions.width}px)`,code:"MIN_WIDTH"}),o.height<n.minDimensions.height&&t.push({field:"dimensions",message:`Image height (${o.height}px) is smaller than minimum (${n.minDimensions.height}px)`,code:"MIN_HEIGHT"})))}if(n.customValidator){const o=await n.customValidator(a);t.push(...o)}return{valid:t.length===0,errors:t}}function zl(a={}){const n=e.ref(a.rules||{});function t(c){n.value=c}async function o(c){return ep(c,n.value)}async function i(c){const d=new Map;return await Promise.all(c.map(async u=>{const f=await o(u);d.set(u,f)})),d}function r(c,d){return n.value.maxItems?d+c<=n.value.maxItems:!0}const s=e.computed(()=>{const c=[];return n.value.acceptedMimeTypes&&c.push(...n.value.acceptedMimeTypes),n.value.acceptedExtensions&&c.push(...n.value.acceptedExtensions),c.join(",")});function l(c){return!n.value.acceptedMimeTypes||n.value.acceptedMimeTypes.length===0?!0:n.value.acceptedMimeTypes.some(d=>d.endsWith("/*")?c.startsWith(d.slice(0,-1)):c===d)}return{rules:n,setRules:t,validateFile:o,validateFiles:i,canAddFiles:r,acceptString:s,isMimeTypeAllowed:l}}function R8(){return`upload-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function A8(a){if(a.type.startsWith("image/"))return URL.createObjectURL(a)}function jl(a){const{adapter:n,maxConcurrent:t=3,rules:o,collection:i,onUploadStart:r,onUploadProgress:s,onUploadComplete:l,onUploadError:c,onQueueComplete:d,postUpload:u}=a,f=e.ref(new Map),p=e.ref(new Set),m=o?{rules:o}:{},{validateFile:h}=zl(m);async function g(){if(p.value.size>=t)return;const A=Array.from(f.value.entries()).find(([P,B])=>B.status==="pending"&&!p.value.has(P));if(!A){Array.from(f.value.values()).every(B=>B.status==="completed"||B.status==="error")&&f.value.size>0&&(d==null||d());return}const[N,z]=A;await k(N,z)}async function k(A,N){p.value.add(A),N.status="uploading",N.abortController=new AbortController,f.value.set(A,{...N}),r==null||r(N);try{const z={onProgress:B=>{N.progress=B,f.value.set(A,{...N}),s==null||s(N)},signal:N.abortController.signal};i&&(z.collection=i);const P=await n.upload(N.file,z);u&&(N.status="attaching",f.value.set(A,{...N}),s==null||s(N),await u(N,P.media,n)),N.status="completed",N.progress=100,N.media=P.media,f.value.set(A,{...N}),l==null||l(N,P.media)}catch(z){z.name==="AbortError"?f.value.delete(A):(N.status="error",N.error=z.message,f.value.set(A,{...N}),c==null||c(N,z))}finally{p.value.delete(A),delete N.abortController,g()}}async function $(A){var P;const N=Array.from(A),z=[];for(const B of N){const L=await h(B),w=R8(),O=A8(B),Z={id:w,file:B,progress:0,status:L.valid?"pending":"error"};!L.valid&&((P=L.errors[0])!=null&&P.message)&&(Z.error=L.errors[0].message),O&&(Z.previewUrl=O),f.value.set(w,Z);const G={media:null,clientId:w,name:B.name,order:0,upload:Z,errors:L.errors};z.push(G)}for(let B=0;B<t;B++)g();return z}function D(A){const N=f.value.get(A);N&&(N.abortController&&N.abortController.abort(),N.previewUrl&&URL.revokeObjectURL(N.previewUrl),f.value.delete(A),p.value.delete(A),g())}async function _(A){const N=f.value.get(A);!N||N.status!=="error"||(N.status="pending",N.progress=0,delete N.error,f.value.set(A,{...N}),g())}function v(){for(const[A,N]of f.value.entries())(N.status==="completed"||N.status==="error")&&(N.previewUrl&&URL.revokeObjectURL(N.previewUrl),f.value.delete(A))}function S(){for(const A of f.value.values())A.abortController&&A.abortController.abort(),A.previewUrl&&URL.revokeObjectURL(A.previewUrl);f.value.clear(),p.value.clear()}function C(A){return f.value.get(A)}const V=e.computed(()=>p.value.size>0),x=e.computed(()=>p.value.size),T=e.computed(()=>Array.from(f.value.values()).filter(A=>A.status==="pending").length),j=e.computed(()=>f.value.size===0?!0:Array.from(f.value.values()).every(A=>A.status==="completed"||A.status==="error")),E=e.computed(()=>Array.from(f.value.values()));return{uploads:f,isUploading:V,activeCount:x,pendingCount:T,isComplete:j,addFiles:$,cancelUpload:D,retryUpload:_,clearCompleted:v,clearAll:S,getUpload:C,uploadsArray:E}}function Ia(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}function qo(a){return typeof a=="string"?a:null}function Vd(a){return typeof a=="number"?a:null}function L8(a){return typeof a=="boolean"?a:null}function tp(a){return Ia(a)&&typeof a.uuid=="string"&&typeof a.file_name=="string"&&typeof a.mime_type=="string"&&(typeof a.original_url=="string"||a.original_url===null)&&typeof a.size=="number"&&typeof a.disk=="string"&&typeof a.created_at=="string"&&typeof a.updated_at=="string"}function P8(a){return!Ia(a)||typeof a.id!="string"||typeof a.status!="string"?null:a.status==="ready"?tp(a.media)?{id:a.id,status:"ready",media:a.media}:null:a.status==="missing"||a.status==="forbidden"?{id:a.id,status:a.status}:null}function O8(a){return Ia(a)?{next_cursor:qo(a.next_cursor),previous_cursor:qo(a.previous_cursor),has_more:L8(a.has_more)??!1,per_page:Vd(a.per_page),count:Vd(a.count)}:null}function Nd(a){const n=Ia(a)?a:{},t=Array.isArray(n.data)?n.data.filter(tp):[],o=Ia(n.meta)?n.meta:{},i=O8(o.pagination),r=(i==null?void 0:i.next_cursor)??qo(o.next_cursor)??qo(o.cursor),s=(i==null?void 0:i.has_more)??o.has_more===!0,l=Array.isArray(n.hydrated)?n.hydrated.map(P8).filter(d=>d!==null):[],c={cursor:r,has_more:s};return i!==null&&(c.pagination=i),{data:t,meta:c,hydrated:l}}function Td(a,n,t,o,i){const r={view:a.scope==="album"?{scope:"album",album_id:a.albumId}:{scope:"library"},per_page:t,sort:n.sort??"newest"};return n.query&&n.query.trim()!==""&&(r.query=n.query.trim()),n.kinds&&n.kinds.length>0&&(r.kinds=n.kinds),o!==null&&(r.cursor=o),i&&i.length>0&&(r.hydrate_ids=i),r}function Md(a){const n=new Set,t=[];for(const o of a)n.has(o.uuid)||(n.add(o.uuid),t.push(o));return t}function U8(a){var t;if(!(a instanceof Error))return null;const n=(t=a.response)==null?void 0:t.status;return typeof n=="number"?n:null}function z8(a){var n;return a instanceof Error?((n=a.response)==null?void 0:n.data)??null:null}function j8(a){if(!Ia(a))return[];const n=[];for(const t of Object.values(a)){if(typeof t=="string"&&t.trim()!==""){n.push(t.trim());continue}if(Array.isArray(t))for(const o of t){if(typeof o!="string")continue;const i=o.trim();i!==""&&n.push(i)}}return Array.from(new Set(n))}function W8(a){var r;const n=z8(a),t=Ia(n)?n:null,o=((r=qo(t==null?void 0:t.message))==null?void 0:r.trim())??null,i=j8(t==null?void 0:t.errors);return o!==null&&i.length>0?o==="Validation failed"?i.join(" "):i.every(l=>o.includes(l))?o:`${o} ${i.join(" ")}`:o!==null?o:i.length>0?i.join(" "):a instanceof Error?a.message:"Failed to load media."}function Bd(a,n){const t=W8(n),o=U8(n);return{code:o===403?"permission_denied":a,message:t,retriable:o!==403,cause:n}}function Wl(a){const n=a.perPage??40,t=e.ref([]),o=e.ref([]),i=e.ref(null),r=e.ref(!1),s=e.ref(!1),l=e.ref(!1),c=e.ref(!1),d=e.ref(null);let u=null,f=0;const p=async g=>{f+=1;const k=f;u==null||u.abort();const $=new AbortController;u=$,g?l.value=!0:s.value=!0,d.value=null,c.value=!1;try{const D=await a.httpClient.get("/v1/media/library",{params:Td(a.view.value,a.filters.value,n,g?i.value:null),signal:$.signal});if(k!==f)return;const _=Nd(D);t.value=g?Md([...t.value,..._.data]):_.data,o.value=_.hydrated,i.value=_.meta.cursor,r.value=_.meta.has_more}catch(D){if($.signal.aborted||k!==f)return;const _=Bd(g?"load_more_failed":"query_failed",D);d.value=_,c.value=_.code==="permission_denied",g||(t.value=[],i.value=null,r.value=!1)}finally{k===f&&(s.value=!1,l.value=!1)}};return{items:t,hydrated:o,cursor:i,hasMore:r,loading:s,loadingMore:l,permissionDenied:c,error:d,loadInitial:async()=>{i.value=null,await p(!1)},loadMore:async()=>{!r.value||l.value||await p(!0)},refresh:async()=>{i.value=null,await p(!1)},hydrateSelection:async g=>{if(g.length===0)return o.value=[],[];try{const k=await a.httpClient.get("/v1/media/library",{params:Td(a.view.value,a.filters.value,1,null,g)}),$=Nd(k);return o.value=$.hydrated,$.hydrated}catch(k){return d.value=Bd("hydration_failed",k),[]}},prepend:g=>{t.value=Md([g,...t.value])}}}const Z8="mediables.media-library.";function H8(a){return!a||a.key.trim()===""?null:`${Z8}${a.key}`}function bs(){return typeof window>"u"||typeof window.sessionStorage>"u"?null:window.sessionStorage}function X8(a,n){const t=Date.parse(a);return Number.isFinite(t)?Date.now()-t>n*60*1e3:!0}function np(a){const n=H8(a),t=(a==null?void 0:a.ttlMinutes)??30,o=`${(a==null?void 0:a.key)??"media-library"}:${Date.now()}`;return{restore:()=>{if(n===null)return null;const l=bs();if(l===null)return null;const c=l.getItem(n);if(c===null)return null;let d;try{d=JSON.parse(c)}catch{return l.removeItem(n),null}if(typeof d!="object"||d===null||Array.isArray(d))return l.removeItem(n),null;const u=d;if(u.version!==1||typeof u.savedAt!="string"||X8(u.savedAt,t))return l.removeItem(n),null;const f={selectedIds:Array.isArray(u.selectedIds)?u.selectedIds.filter(p=>typeof p=="string"&&p.trim()!==""):[]};return((a==null?void 0:a.restoreView)??!0)&&u.view&&(f.view=u.view),u.filters&&(f.filters=u.filters),f},save:l=>{if(n===null)return;const c=bs();if(c===null)return;const d={version:1,savedAt:new Date().toISOString(),selectedIds:[...l.selectedIds]};((a==null?void 0:a.restoreView)??!0)&&l.view&&(d.view=l.view),l.filters&&(d.filters=l.filters),c.setItem(n,JSON.stringify(d))},clear:()=>{if(n===null)return;const l=bs();l==null||l.removeItem(n)},sessionId:o}}function ap(a){const n=e.ref(a);return{state:n,transition:o=>{n.value=o}}}function op(a){return{emitMetric:(t,o)=>{const i={name:t,timestamp:new Date().toISOString()};o!==void 0&&(i.payload=o),a==null||a(i)}}}function to(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}function G8(a){const n=to(a)?a:{};return(Array.isArray(n.data)?n.data:to(n.data)&&Array.isArray(n.data.data)?n.data.data:Array.isArray(a)?a:[]).map(o=>{if(!to(o)||typeof o.id!="string"||typeof o.name!="string")return null;const i={id:o.id,name:o.name};return typeof o.description=="string"&&o.description.trim()!==""&&(i.description=o.description),typeof o.media_count=="number"&&(i.mediaCount=o.media_count),i}).filter(o=>o!==null)}function J8(a){const n=to(a)?a:{},t=to(n.data)?n.data:to(a)?a:null;if(t===null||typeof t.id!="string"||typeof t.name!="string")return null;const o={id:t.id,name:t.name};return typeof t.description=="string"&&t.description.trim()!==""&&(o.description=t.description),o}function K8(a){return a==="ready"||a==="uploading"||a==="failed"}function Di(a,n="ready"){return{id:a.uuid,media:a,status:n,countsTowardMax:K8(n)}}function Y8(a,n){return a.scope==="library"?!0:n.type==="album"&&n.albumId===a.albumId}function q8(a,n){return a.scope==="library"?n.type==="library"||n.type==="album":n.type==="album"&&n.albumId===a.albumId}function ws(a){return{code:"configuration_error",message:a,retriable:!1}}function ip(a){var be,Ee,ie;const n=a.selectionMode??"multiple",t=a.maxSelection,o=a.uploadBehavior??"adapter",i=e.ref(a.initialView??{scope:"library"}),r=e.ref({sort:((be=a.initialFilters)==null?void 0:be.sort)??"newest",...(Ee=a.initialFilters)!=null&&Ee.query?{query:a.initialFilters.query}:{},...(ie=a.initialFilters)!=null&&ie.kinds?{kinds:a.initialFilters.kinds}:{}}),s=e.ref([]),l=e.ref([]),c=e.ref(null),d=e.ref(null),u=np(a.sessionPolicy),{emitMetric:f}=op(a.telemetry),p=ap("idle"),m=Wl({httpClient:a.deps.httpClient,view:i,filters:r}),h=e.computed(()=>l.value.map(R=>R.id)),g=e.computed(()=>{const R=c.value;return R===null?null:m.items.value[R]??null}),k=e.computed(()=>a.uploadTarget??{type:"library"}),$=jl({adapter:a.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:R=>R.original_url,getThumbnailUrl:R=>R.thumbnail_url??R.preview_url??R.original_url},postUpload:async(R,M,H)=>{const ee=k.value;ee.type!=="album"||!ee.albumId||await H.attach(M.uuid,{modelType:"album",modelId:ee.albumId})},onUploadComplete:(R,M)=>{const H=k.value;Y8(i.value,H)&&m.prepend(M),a.autoSelectUploaded&&q8(i.value,H)&&V(M),f("upload-complete",{mediaId:M.uuid,targetType:H.type,targetAlbumId:H.albumId})},onUploadError:(R,M)=>{d.value={code:"upload_failed",message:M.message,retriable:!0,cause:M}}}),D=e.computed(()=>$.isUploading.value),_=()=>{u.save({selectedIds:[...h.value],view:i.value,filters:r.value})},v=async R=>{const M=await m.hydrateSelection(R);l.value=M.map(H=>H.status==="ready"&&H.media?Di(H.media):{id:H.id,media:null,status:H.status,countsTowardMax:!1})},S=e.computed(()=>l.value.filter(R=>R.countsTowardMax).length),C=()=>n==="single"||t===void 0?!0:S.value<t,V=R=>{if(l.value.findIndex(H=>H.id===R.uuid)>=0){n==="multiple"?l.value=l.value.filter(H=>H.id!==R.uuid):l.value=[Di(R)],_();return}if(!C()){d.value={code:"selection_invalid",message:t!==void 0?`You can only select up to ${t} items.`:"You cannot select more items.",retriable:!0};return}n==="single"?l.value=[Di(R)]:l.value=[...l.value,Di(R)],d.value=null,_()},x=async()=>{var M;p.transition("restoring");const R=u.restore();if(R===null){p.transition("ready");return}R.view&&(i.value=R.view),R.filters&&(r.value={sort:R.filters.sort??"newest",...R.filters.query?{query:R.filters.query}:{},...R.filters.kinds?{kinds:R.filters.kinds}:{}}),await m.loadInitial(),(((M=a.sessionPolicy)==null?void 0:M.restoreSelection)??!0)&&await v(R.selectedIds),p.transition("ready")};e.watch(()=>m.error.value,R=>{R!==null&&(d.value=R,p.transition("error"))});const T=async()=>{d.value=null,p.transition("idle"),await x(),m.items.value.length===0&&!m.loading.value&&!m.permissionDenied.value&&await m.loadInitial();const R=a.defaultSelectedIds??[];l.value.length===0&&R.length>0&&await v(R),p.transition("ready")},j=async(R,M="user")=>{const H=i.value;i.value=R,M==="user"&&a.preserveSelectionOnViewChange===!1&&(l.value=[]),f("view-change",{from:H.scope,to:R.scope,reason:M}),await m.loadInitial(),_()},E=async()=>{const R=await a.deps.httpClient.get("/v1/albums");s.value=G8(R)},A=async(R,M)=>{try{const H={name:R,visibility:"private"};M&&M.trim()!==""&&(H.parent_id=M);const ee=await a.deps.httpClient.post("/v1/albums",H),ae=J8(ee);return ae===null?ws("Album creation response was invalid."):(s.value=[ae,...s.value.filter(ue=>ue.id!==ae.id)],await j({scope:"album",albumId:ae.id,albumName:ae.name},"inline-album-created"),ae)}catch(H){const ee={code:"album_create_failed",message:H instanceof Error?H.message:"Album creation failed.",retriable:!0,cause:H};return d.value=ee,ee}},N=async R=>{if(!a.enableUpload){d.value=ws("Uploads are not enabled for this picker.");return}if(o!=="delegate"){if(!a.deps.uploadAdapter){d.value=ws("Uploads require a configured upload adapter.");return}await $.addFiles(R)}},z=()=>{var H;const R=((H=a.validateSelection)==null?void 0:H.call(a,l.value))??null;if(R!==null){const ee={code:"selection_invalid",message:R,retriable:!0};return d.value=ee,ee}if(l.value.filter(ee=>ee.status==="ready"&&ee.media!==null).length===0){const ee={code:"selection_invalid",message:"Select at least one available media item.",retriable:!0};return d.value=ee,ee}return{orderedIds:h.value,items:[...l.value],view:i.value,filters:r.value,dirty:!0,sessionId:u.sessionId}},P=R=>{const M=m.items.value.findIndex(H=>H.uuid===R.uuid);c.value=M>=0?M:null},B=()=>{c.value=null},L=()=>{c.value===null||c.value<=0||(c.value-=1)},w=()=>{c.value===null||c.value>=m.items.value.length-1||(c.value+=1)},O=R=>{l.value=l.value.filter(M=>M.id!==R),_()},Z=async()=>{await m.refresh()},G=async R=>{r.value={...r.value,...R&&R.trim()!==""?{query:R.trim()}:{}},(!R||R.trim()==="")&&delete r.value.query,await m.loadInitial(),_()},re=async()=>{await j({scope:"library"},"permission-unavailable")};return{view:i,filters:r,albums:s,selectedItems:l,orderedIds:h,queryItems:m.items,cursor:m.cursor,hasMore:m.hasMore,loading:m.loading,loadingMore:m.loadingMore,permissionDenied:m.permissionDenied,error:d,uploadQueue:$.uploadsArray,isUploading:D,previewIndex:c,previewItem:g,initialize:T,refresh:Z,loadMore:m.loadMore,setQuery:G,setView:j,toggleSelection:V,removeSelected:O,confirmSelection:z,openPreview:P,closePreview:B,showPreviousPreview:L,showNextPreview:w,loadAlbums:E,createAlbum:A,addUploadFiles:N,goToLibrary:re,sessionId:u.sessionId}}const Q8=["data-testid"],eI={class:"mlp-location-bar"},tI={class:"mlp-location-bar__left"},nI={class:"mlp-location-bar__label"},aI={class:"mlp-tabs","data-testid":"media-picker-tabs"},oI={key:0,class:"mlp-search-row"},iI=["placeholder"],rI={key:2,class:"mlp-overlay-panel"},sI={key:0,class:"mlp-error","data-testid":"media-picker-error"},lI={key:5,class:"mlp-bottom-bar"},cI={key:0,class:"mlp-bottom-bar__selection"},dI={class:"mlp-bottom-bar__count"},uI={class:"mlp-bottom-bar__thumbs"},mI=["src","alt"],pI={key:1,class:"mlp-bottom-bar__thumb-placeholder"},fI=["aria-label","onClick"],hI={class:"mlp-bottom-bar__actions"},vI=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(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>{var B,L,w,O,Z,G,re,be,Ee,ie,R,M,H,ee,ae,ue,de,ye;return{title:((B=o.labels)==null?void 0:B.title)??"Media library",searchPlaceholder:((L=o.labels)==null?void 0:L.searchPlaceholder)??"Search your media",viewLibrary:((w=o.labels)==null?void 0:w.viewLibrary)??"Library",browseAlbums:((O=o.labels)==null?void 0:O.browseAlbums)??"Albums",createAlbum:((Z=o.labels)==null?void 0:Z.createAlbum)??"Create album",createAlbumNameLabel:((G=o.labels)==null?void 0:G.createAlbumNameLabel)??"Album name",emptyLibrary:((re=o.labels)==null?void 0:re.emptyLibrary)??"No media found in your library.",emptyAlbum:((be=o.labels)==null?void 0:be.emptyAlbum)??"No media found in this album.",networkError:((Ee=o.labels)==null?void 0:Ee.networkError)??"Unable to load media right now.",retry:((ie=o.labels)==null?void 0:ie.retry)??"Retry",selectedCount:((R=o.labels)==null?void 0:R.selectedCount)??(Be=>`${Be} selected`),confirmAction:((M=o.labels)==null?void 0:M.confirmAction)??"Attach selected",cancel:((H=o.labels)==null?void 0:H.cancel)??"Cancel",dismiss:((ee=o.labels)==null?void 0:ee.dismiss)??"Remove",uploadLabel:((ae=o.labels)==null?void 0:ae.uploadLabel)??"Upload",albumUnavailableTitle:((ue=o.labels)==null?void 0:ue.albumUnavailableTitle)??"Album unavailable",albumUnavailableBody:((de=o.labels)==null?void 0:de.albumUnavailableBody)??"You no longer have access to this album.",goToLibrary:((ye=o.labels)==null?void 0:ye.goToLibrary)??"Go to library"}}),s={deps:o.deps,selectionMode:o.selectionMode,initialView:o.initialView,initialFilters:o.initialFilters,...o.maxSelection!==void 0?{maxSelection:o.maxSelection}:{},...o.modelValue.length>0||o.defaultSelectedIds.length>0?{defaultSelectedIds:o.modelValue.length>0?o.modelValue:o.defaultSelectedIds}:{},...o.sessionPolicy?{sessionPolicy:o.sessionPolicy}:{},...o.enableUpload?{enableUpload:!0}:{},uploadBehavior:o.uploadBehavior,...o.uploadTarget?{uploadTarget:o.uploadTarget}:{},...o.autoSelectUploaded?{autoSelectUploaded:!0}:{},...o.validateSelection?{validateSelection:o.validateSelection}:{},preserveSelectionOnViewChange:o.preserveSelectionOnViewChange,telemetry:B=>{var L;(L=o.telemetry)==null||L.call(o,B),i("metric",B)}},l=ip(s),c=e.ref(o.initialFilters.query??""),d=e.ref("upload"),u=e.ref(!1),f=JSON.stringify(o.modelValue.length>0?o.modelValue:o.defaultSelectedIds);let p=null;const m=e.computed(()=>JSON.stringify(l.orderedIds.value)!==f),h=e.computed(()=>l.view.value.scope==="album"?r.value.emptyAlbum:r.value.emptyLibrary),g=e.computed(()=>r.value.selectedCount(l.selectedItems.value.length)),k=e.computed(()=>l.view.value.scope==="album"?l.view.value.albumName??"Album":r.value.viewLibrary),$=e.computed(()=>l.view.value.scope==="album"),D=()=>{p!==null&&(window.clearTimeout(p),p=null)},_=()=>{i("update:modelValue",[...l.orderedIds.value]),i("selection-change",{orderedIds:[...l.orderedIds.value],items:[...l.selectedItems.value],dirty:m.value})},v=B=>{B!==null&&i("error",B)},S=B=>typeof B.code=="string",C=B=>typeof B=="object"&&B!==null&&"code"in B&&typeof B.code=="string",V=()=>{const B=l.confirmSelection();if(S(B)){v(B);return}i("confirm",{...B,dirty:m.value})},x=(B="user")=>{i("cancel",{dirty:m.value,reason:B,sessionId:l.sessionId})},T=async()=>{d.value="albums",await l.loadAlbums()},j=async()=>{await l.goToLibrary(),d.value="albums",await l.loadAlbums()},E=B=>{l.setView({scope:"album",albumId:B.id,albumName:B.name}),d.value="media"},A=async(B,L)=>{const w=l.view.value,O=await l.createAlbum(B,L);if(C(O)){v(O);return}u.value=!1,d.value="media",i("view-change",{from:w,to:{scope:"album",albumId:O.id,albumName:O.name},reason:"inline-album-created",restoredFromSession:!1})},N=async B=>{if(o.uploadBehavior==="delegate"){i("request-upload-files",{files:[...B],view:l.view.value,filters:l.filters.value,sessionId:l.sessionId});return}await l.addUploadFiles(B)};function z(B){var L;return B?B.thumbnail_url??((L=B.conversion_urls)==null?void 0:L.thumb)??B.preview_url??B.original_url??B.url??null:null}function P(B){return B!=null&&B.mime_type?B.mime_type.startsWith("image/"):!1}return e.watch(()=>c.value,B=>{D(),p=window.setTimeout(()=>{l.setQuery(B)},250)}),e.watch(()=>l.selectedItems.value,()=>{_()},{deep:!0}),e.watch(()=>l.error.value,B=>{v(B)}),e.onMounted(()=>{l.initialize()}),e.onBeforeUnmount(()=>{D()}),n({refresh:l.refresh}),(B,L)=>(e.openBlock(),e.createElementBlock("section",{class:"media-library-picker","data-testid":B.testIdPrefix},[e.createElementVNode("header",eI,[e.createElementVNode("div",tI,[$.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:j},[...L[8]||(L[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",nI,e.toDisplayString(k.value),1)])]),e.createElementVNode("nav",aI,[B.enableUpload?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["mlp-tabs__tab",{"is-active":d.value==="upload"}]),"data-testid":"tab-media-picker-upload",onClick:L[0]||(L[0]=w=>d.value="upload")},e.toDisplayString(r.value.uploadLabel),3)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["mlp-tabs__tab",{"is-active":d.value==="media"}]),"data-testid":"tab-media-picker-all",onClick:L[1]||(L[1]=w=>d.value="media")}," All Media ",2),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["mlp-tabs__tab",{"is-active":d.value==="albums"}]),"data-testid":"tab-media-picker-albums",onClick:T},e.toDisplayString(r.value.browseAlbums),3)]),d.value==="media"||d.value==="albums"?(e.openBlock(),e.createElementBlock("div",oI,[L[9]||(L[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":L[2]||(L[2]=w=>c.value=w),class:"mlp-search-row__input",type:"search",placeholder:r.value.searchPlaceholder,"data-testid":"input-media-picker-search"},null,8,iI),[[e.vModelText,c.value]])])):e.createCommentVNode("",!0),B.enableUpload&&d.value==="upload"?(e.openBlock(),e.createBlock(Jm,{key:1,open:!0,queue:e.unref(l).uploadQueue.value,accept:B.accept,"upload-label":r.value.uploadLabel,onClose:L[3]||(L[3]=w=>d.value="media"),onFilesSelected:N},null,8,["queue","accept","upload-label"])):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("div",rI,[e.createVNode(Zm,{open:u.value,"name-label":r.value.createAlbumNameLabel,albums:e.unref(l).albums.value,onCancel:L[4]||(L[4]=w=>u.value=!1),onCreate:A},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(Hm,{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",sI,[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:L[5]||(L[5]=(...w)=>e.unref(l).refresh&&e.unref(l).refresh(...w))},e.toDisplayString(r.value.retry),1)])):e.createCommentVNode("",!0),d.value==="media"?(e.openBlock(),e.createBlock(Ym,{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,"test-id-prefix":`${B.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","test-id-prefix","onToggle","onPreview","onLoadMore"])):d.value==="albums"?(e.openBlock(),e.createBlock(Gm,{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":B.enableAlbumCreation,onSelectLibrary:j,onSelectAlbum:E,onCreateAlbum:L[6]||(L[6]=w=>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),B.showFooter?(e.openBlock(),e.createElementBlock("footer",lI,[e.unref(l).selectedItems.value.length>0?(e.openBlock(),e.createElementBlock("div",cI,[e.createElementVNode("span",dI,e.toDisplayString(g.value),1),e.createElementVNode("div",uI,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(l).selectedItems.value,w=>{var O,Z,G;return e.openBlock(),e.createElementBlock("div",{key:w.id,class:"mlp-bottom-bar__thumb-item"},[P(w.media)&&z(w.media)?(e.openBlock(),e.createElementBlock("img",{key:0,src:z(w.media),alt:((O=w.media)==null?void 0:O.alt_text)??((Z=w.media)==null?void 0:Z.file_name)??"Selected",class:"mlp-bottom-bar__thumb-img"},null,8,mI)):(e.openBlock(),e.createElementBlock("div",pI,[...L[10]||(L[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} ${((G=w.media)==null?void 0:G.file_name)??w.id}`,"data-testid":"btn-media-picker-remove-selected",onClick:re=>e.unref(l).removeSelected(w.id)},[...L[11]||(L[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,fI)])}),128))])])):e.createCommentVNode("",!0),e.createElementVNode("div",hI,[e.createElementVNode("button",{type:"button",class:"mlp-bottom-bar__cancel","data-testid":"btn-media-picker-cancel",onClick:L[7]||(L[7]=w=>x())},e.toDisplayString(r.value.cancel),1),e.createElementVNode("button",{type:"button",class:"mlp-bottom-bar__confirm","data-testid":"btn-media-picker-confirm",onClick:V},e.toDisplayString(r.value.confirmAction),1)])])):e.createCommentVNode("",!0),B.enablePreview?(e.openBlock(),e.createBlock(Xm,{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),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","onClose","onPrevious","onNext","onToggleSelect"])):e.createCommentVNode("",!0)],8,Q8))}}),rp=Me(vI,[["__scopeId","data-v-db2ced73"]]),gI={key:0,class:"media-library-picker-modal","data-testid":"media-library-picker-modal"},yI={class:"media-library-picker-modal__panel"},bI=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(a,{emit:n}){const t=a,o=n,i=()=>{t.closeOnBackdrop&&o("close")};return(r,s)=>r.isOpen?(e.openBlock(),e.createElementBlock("div",gI,[e.createElementVNode("button",{type:"button",class:"media-library-picker-modal__backdrop","aria-label":"Close media picker",onClick:i}),e.createElementVNode("div",yI,[e.createVNode(rp,e.mergeProps(t,{"onUpdate:modelValue":s[0]||(s[0]=l=>o("update:modelValue",l)),onConfirm:s[1]||(s[1]=l=>o("confirm",l)),onCancel:s[2]||(s[2]=l=>o("cancel",l))}),null,16)])])):e.createCommentVNode("",!0)}}),wI=Me(bI,[["__scopeId","data-v-a92e8703"]]),kI={key:0,class:"media-selection-tray","data-testid":"media-selection-tray"},_I={class:"media-selection-tray__header"},EI={class:"media-selection-tray__title"},xI={class:"media-selection-tray__items"},SI={class:"media-selection-tray__item-preview"},CI=["src","alt"],VI={key:1,class:"media-selection-tray__file-icon"},NI={class:"media-selection-tray__item-copy"},TI=["aria-label","onClick"],MI=e.defineComponent({__name:"MediaSelectionTray",props:{items:{},selectedCountLabel:{default:"Selected items"},dismissLabel:{default:"Remove"}},emits:["remove"],setup(a,{emit:n}){const t=n;function o(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",kI,[e.createElementVNode("header",_I,[e.createElementVNode("h3",EI,e.toDisplayString(r.selectedCountLabel),1)]),e.createElementVNode("div",xI,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,l=>{var c,d,u,f;return e.openBlock(),e.createElementBlock("article",{key:l.id,class:"media-selection-tray__item"},[e.createElementVNode("div",SI,[i(l.media)&&o(l.media)?(e.openBlock(),e.createElementBlock("img",{key:0,src:o(l.media),alt:((c=l.media)==null?void 0:c.alt_text)??((d=l.media)==null?void 0:d.file_name)??"Selected media",class:"media-selection-tray__thumb"},null,8,CI)):(e.openBlock(),e.createElementBlock("div",VI,[...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",NI,[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:p=>t("remove",l.id)},e.toDisplayString(r.dismissLabel),9,TI)])}),128))])])):e.createCommentVNode("",!0)}}),BI=Me(MI,[["__scopeId","data-v-f2a3d69d"]]);function Zl(a={}){const n=e.ref(!1),t=e.ref(!1),o=e.ref(null),i=e.ref(null),r=e.ref(0),s=e.ref(null),l=e.ref(null),c=e.computed(()=>l.value!==null),d=$=>{if(r.value++,l.value=null,i.value=null,t.value=!1,$!=null&&typeof $=="object"&&!($ instanceof Blob)&&("image"in $||"state"in $||"sessionKey"in $)){const D=$;o.value=D.image??null,s.value=D.state??null}else o.value=$??null,s.value=null;n.value=!0},u=()=>{n.value=!1,o.value=null,i.value=null,l.value=null,t.value=!1,s.value=null},f=async $=>{try{return t.value=!0,i.value=$,a.onSave&&await a.onSave($),u(),$}catch(D){const _=D;throw l.value=_,a.onError&&a.onError(_),_}finally{t.value=!1}},p=()=>{a.onCancel&&a.onCancel(),u()},m=$=>{l.value=$,a.onError&&a.onError($)},h=()=>{l.value=null},g=()=>i.value,k=e.computed(()=>n.value&&i.value!==null&&!t.value);return{isOpen:n,isProcessing:t,uploadedImage:o,editedImage:i,sessionKey:r,initialState:s,error:l,hasError:c,hasUnsavedChanges:k,open:d,close:u,handleSave:f,handleCancel:p,handleError:m,clearError:h,getEditedImage:g}}let ks=null;function II(a){return ks||(ks=Zl(a)),ks}function FI(a){return n=>new Promise((t,o)=>{Zl({...a,onSave:async r=>{a!=null&&a.onSave&&await a.onSave(r),t(r)},onError:r=>{a!=null&&a.onError&&a.onError(r),o(r)},onCancel:()=>{a!=null&&a.onCancel&&a.onCancel(),o(new Error("User cancelled"))}}).open(n)})}function Hl(a){return a.filter(n=>n.media&&!n.markedForRemoval).map((n,t)=>{const o={uuid:n.media.uuid,name:n.name,order:t};return n.customProperties&&(o.custom_properties=n.customProperties),o})}function ll(a){return a.map((n,t)=>{const o={media:n,clientId:n.uuid,name:n.name||n.file_name,order:t};return n.custom_properties&&(o.customProperties=n.custom_properties),o})}function Xl(a){if(a){const t={};a.apiBaseUrl!==void 0&&(t.apiBaseUrl=a.apiBaseUrl),a.isAdmin!==void 0&&(t.isAdmin=a.isAdmin),no(t)}return{name:"mediables",async upload(t,o){const r=await ln().uploadFile(t,{collection:(o==null?void 0:o.collection)||"default",customProperties:o==null?void 0:o.customProperties});if(!r)throw new Error("Upload failed: No media returned");return{media:r,uuid:r.uuid}},async attach(t,o){await ln().attachMedia(o.modelType,String(o.modelId),[t],o.collection||"images")},async attachMany(t,o){await ln().attachMedia(o.modelType,String(o.modelId),t,o.collection||"images")},async detach(t,o){await ln().detachMedia(o.modelType,String(o.modelId),t,o.collection||"images")},async reorder(t,o){await ln().reorderMedia(t.modelType,String(t.modelId),o,t.collection||"images")},async fetchModelMedia(t){return await ln().fetchModelMedia(t.modelType,String(t.modelId),t.collection||"images")},getUrl(t,o){return ln().getMediaUrl(t,o)},getThumbnailUrl(t){var o,i;return(o=t.conversion_urls)!=null&&o.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 ln().deleteMedia(t)},async update(t,o){const r=await ln().updateMedia(t,o);if(!r)throw new Error("Update failed: No media returned");return r},configure(t){const o={};t.apiBaseUrl!==void 0&&(o.apiBaseUrl=t.apiBaseUrl),t.isAdmin!==void 0&&(o.isAdmin=t.isAdmin),no(o)}}}let Ji=null;function $I(){return Ji||(Ji=Xl()),Ji}function DI(){Ji=null}const RI={apiBaseUrl:"/media-library-pro"};function Ri(){var a;return typeof document>"u"?null:((a=document.querySelector('meta[name="csrf-token"]'))==null?void 0:a.getAttribute("content"))||null}function _s(a){const n={uuid:a.uuid,file_name:a.fileName||a.name,mime_type:`application/${a.extension}`,size:a.size,disk:"public",original_url:a.original_url||"",created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return a.name&&(n.name=a.name),a.original_url&&(n.url=a.original_url),a.preview_url&&(n.thumbnail_url=a.preview_url,n.preview_url=a.preview_url),a.custom_properties&&(n.custom_properties=a.custom_properties),n}function Gl(a){const n={...RI,...a};return{name:"spatie",async upload(o,i){const r=new FormData;r.append("file",o),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",...n.headers},l=n.csrfToken||Ri();l&&(s["X-CSRF-TOKEN"]=l);const c={method:"POST",headers:s,body:r,credentials:"include"};i!=null&&i.signal&&(c.signal=i.signal);const d=await fetch(`${n.apiBaseUrl}/uploads`,c);if(!d.ok){const p=await d.json().catch(()=>({message:"Upload failed"}));throw new Error(p.message||`HTTP ${d.status}`)}const u=await d.json(),f=_s(u);return i!=null&&i.onProgress&&i.onProgress(100),{media:f,uuid:u.uuid}},async attach(o,i){},async attachMany(o,i){},async detach(o,i){},async reorder(o,i){},async fetchModelMedia(o){const i={Accept:"application/json",...n.headers},r=n.csrfToken||Ri();r&&(i["X-CSRF-TOKEN"]=r);const s=new URLSearchParams;s.append("model_type",o.modelType),s.append("model_id",String(o.modelId)),o.collection&&s.append("collection",o.collection);try{const l=await fetch(`${n.apiBaseUrl}/media?${s}`,{method:"GET",headers:i,credentials:"include"});if(!l.ok)throw new Error(`HTTP ${l.status}`);return(await l.json()).map(_s)}catch{return[]}},getUrl(o,i){var r;if(i){const s=(r=o.conversion_urls)==null?void 0:r[i];if(s)return s}return o.original_url||o.url||""},getThumbnailUrl(o){var i,r;return o.preview_url?o.preview_url:(i=o.conversion_urls)!=null&&i.preview?o.conversion_urls.preview:o.thumbnail_url?o.thumbnail_url:(r=o.conversion_urls)!=null&&r.thumb?o.conversion_urls.thumb:o.original_url||o.url||""},async delete(o){const i={Accept:"application/json",...n.headers},r=n.csrfToken||Ri();r&&(i["X-CSRF-TOKEN"]=r);const s=await fetch(`${n.apiBaseUrl}/uploads/${o}`,{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(o,i){const r={Accept:"application/json","Content-Type":"application/json",...n.headers},s=n.csrfToken||Ri();s&&(r["X-CSRF-TOKEN"]=s);const l=await fetch(`${n.apiBaseUrl}/uploads/${o}`,{method:"PATCH",headers:r,body:JSON.stringify(i),credentials:"include"});if(!l.ok){const d=await l.json().catch(()=>({message:"Update failed"}));throw new Error(d.message||`HTTP ${l.status}`)}const c=await l.json();return _s(c)},configure(o){Object.assign(n,o)}}}let Ki=null;function AI(){return Ki||(Ki=Gl()),Ki}function LI(){Ki=null}function sp(a,n){switch(a){case"mediables":return Xl(n);case"spatie":return Gl(n);default:throw new Error(`Unknown adapter: ${a}`)}}function lp(a={}){const{enabled:n=!0,onReorder:t,onDragStart:o,onDragEnd:i,draggingClass:r="is-dragging",dropTargetClass:s="is-drop-target"}=a,l=e.ref({isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null}),c=e.ref(!1);let d=null;function u(D,_,v){n&&("dataTransfer"in D&&D.dataTransfer&&(D.dataTransfer.effectAllowed="move",D.dataTransfer.setData("text/plain",String(v))),d=D.target,d&&d.classList.add(r),l.value={isDragging:!0,dragIndex:v,dropIndex:v,draggedItem:_},c.value=!0,o==null||o(_,v))}function f(D,_){var v;if(!(!n||!l.value.isDragging)&&(D.preventDefault(),l.value.dropIndex!==_)){const S=document.querySelector(`.${s}`);S==null||S.classList.remove(s);const C=(v=D.target)==null?void 0:v.closest("[data-index]");C==null||C.classList.add(s),l.value.dropIndex=_}}function p(){if(!l.value.isDragging)return;const{dragIndex:D,dropIndex:_,draggedItem:v}=l.value;d&&d.classList.remove(r);const S=document.querySelector(`.${s}`);S==null||S.classList.remove(s),D!==null&&_!==null&&D!==_&&v&&(t==null||t({fromIndex:D,toIndex:_,item:v})),h(),i==null||i()}function m(){d&&d.classList.remove(r);const D=document.querySelector(`.${s}`);D==null||D.classList.remove(s),h(),i==null||i()}function h(){l.value={isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null},c.value=!1,d=null}function g(D,_,v){const S=[...D],[C]=S.splice(_,1);return S.splice(v,0,C),S.map((V,x)=>({...V,order:x}))}function k(D,_){return{draggable:n,"data-index":_,onDragstart:v=>u(v,D,_),onDragover:v=>f(v,_),onDragend:()=>p(),onDrop:v=>{v.preventDefault(),p()}}}function $(D){D.key==="Escape"&&l.value.isDragging&&m()}return e.onMounted(()=>{document.addEventListener("keydown",$)}),e.onUnmounted(()=>{document.removeEventListener("keydown",$),m()}),{dragState:l,isDragging:c,startDrag:u,handleDragOver:f,endDrag:p,cancelDrag:m,reorderItems:g,getDragProps:k}}function Or(a={}){const{initialItems:n=[],modelType:t,modelId:o,collection:i="images",maxItems:r,maxFileSize:s,acceptedMimeTypes:l,sortable:c=!0,disabled:d=!1,rules:u={},adapterType:f="mediables",adapter:p,maxConcurrentUploads:m=3,onChange:h,onUpload:g,onUploadComplete:k,onUploadError:$,onRemove:D,onReorder:_,onError:v,onReadyToSubmitChange:S}=a,C={maxItems:r,maxFileSize:s,acceptedMimeTypes:l,...u},V=p||sp(f),x=e.ref([]),T=e.ref(!1),j=e.ref([]);function E(fe){if(fe.length===0)return[];const ge=fe[0];return"media"in ge&&"clientId"in ge?fe:ll(fe)}x.value=E(n);const{acceptString:A,canAddFiles:N}=zl({rules:C}),z=jl({adapter:V,maxConcurrent:m,rules:C,collection:i,onUploadStart:fe=>{g==null||g(fe)},onUploadComplete:(fe,ge)=>{const Se=x.value.findIndex(Ie=>Ie.clientId===fe.id);Se!==-1&&(x.value[Se]={...x.value[Se],media:ge,name:ge.name||ge.file_name,upload:{...fe,status:"completed"}}),k==null||k(ge)},onUploadError:(fe,ge)=>{const Se=x.value.findIndex(Ie=>Ie.clientId===fe.id);Se!==-1&&(x.value[Se]={...x.value[Se],upload:{...fe,status:"error",error:ge.message},errors:[{field:"upload",message:ge.message,code:"UPLOAD_ERROR"}]}),$==null||$({file:fe.file,message:ge.message})},onQueueComplete:()=>{h==null||h(x.value)}}),{dragState:P,getDragProps:B,reorderItems:L}=lp({enabled:c&&!d,onReorder:fe=>{x.value=L(x.value,fe.fromIndex,fe.toIndex),_==null||_(x.value),h==null||h(x.value)}}),w=e.computed(()=>z.isUploading.value),O=e.computed(()=>!z.isUploading.value&&z.pendingCount.value===0),Z=e.computed(()=>r?x.value.length>=r:!1),G=e.computed(()=>Hl(x.value)),re=e.computed(()=>x.value.length),be=e.computed(()=>r?Math.max(0,r-x.value.length):1/0);e.watch(O,fe=>{S==null||S(fe)});function Ee(fe){x.value=E(fe),h==null||h(x.value)}async function ie(fe){if(d)return;const ge=Array.from(fe);if(!N(ge.length,x.value.length)){const lt={field:"count",message:`Maximum ${r} files allowed`,code:"MAX_ITEMS"};j.value=[lt],v==null||v([lt]);return}const Se=await z.addFiles(ge),Ie=x.value.length,pt=Se.map((lt,Dt)=>({...lt,order:Ie+Dt}));x.value=[...x.value,...pt],h==null||h(x.value)}function R(fe){d||(fe.upload&&(fe.upload.status==="uploading"||fe.upload.status==="pending")&&z.cancelUpload(fe.clientId),x.value=x.value.filter(ge=>ge.clientId!==fe.clientId),x.value=x.value.map((ge,Se)=>({...ge,order:Se})),D==null||D(fe),h==null||h(x.value))}function M(fe){const ge=x.value.find(Se=>Se.clientId===fe);ge&&R(ge)}function H(){d||(z.clearAll(),x.value=[],h==null||h(x.value))}function ee(fe,ge){d||!c||(x.value=L(x.value,fe,ge),_==null||_(x.value),h==null||h(x.value))}function ae(fe,ge){if(d)return;const Se=x.value.findIndex(Ie=>Ie.clientId===fe);Se!==-1&&(x.value[Se]={...x.value[Se],...ge},h==null||h(x.value))}function ue(fe){z.cancelUpload(fe),M(fe)}async function de(fe){await z.retryUpload(fe)}async function ye(){if(!t||!o)throw new Error("modelType and modelId are required for save()");const fe={modelType:t,modelId:o,collection:i},ge=x.value.filter(Se=>Se.media&&!Se.markedForRemoval).map(Se=>Se.media.uuid);T.value=!0;try{await V.attachMany(ge,fe),await V.reorder(fe,ge)}finally{T.value=!1}}async function Be(){if(!t||!o)throw new Error("modelType and modelId are required for load()");const fe={modelType:t,modelId:o,collection:i};T.value=!0;try{const ge=await V.fetchModelMedia(fe);x.value=ll(ge),h==null||h(x.value)}finally{T.value=!1}}return e.onMounted(()=>{t&&o&&n.length===0&&Be().catch(console.error)}),e.onUnmounted(()=>{z.clearAll()}),{items:x,setItems:Ee,addFiles:ie,removeItem:R,removeItemById:M,clearAll:H,reorderItems:ee,updateItem:ae,cancelUpload:ue,retryUpload:de,save:ye,load:Be,isLoading:T,isUploading:w,isReadyToSubmit:O,isAtMaxItems:Z,errors:j,dragState:P,getDragProps:B,adapter:V,formValues:G,acceptString:A,count:re,remainingSlots:be}}const PI=["aria-disabled"],OI=["accept","multiple","disabled"],UI={class:"media-dropzone__content"},zI={class:"media-dropzone__title"},jI={class:"media-dropzone__subtitle"},WI=["disabled"],ZI={key:0,class:"media-dropzone__helper"},HI=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(a,{emit:n}){const t=a,o=n,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 g=[];return t.maxFileSize&&g.push(`Max size: ${ur(t.maxFileSize)}`),t.maxItems&&t.maxItems>1&&g.push(`Max files: ${t.maxItems}`),g.join(" • ")});function c(g){g.preventDefault(),!t.disabled&&(i.value=!0)}function d(g){g.preventDefault(),i.value=!1}function u(g){g.preventDefault()}function f(g){var $;if(g.preventDefault(),i.value=!1,t.disabled)return;const k=($=g.dataTransfer)==null?void 0:$.files;k&&k.length>0&&o("files",k)}function p(){var g;t.disabled||(g=r.value)==null||g.click()}function m(g){const k=g.target,$=k.files;$&&$.length>0&&o("files",$),k.value=""}function h(g){(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),p())}return(g,k)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(s.value),role:"button",tabindex:"0","aria-disabled":g.disabled,"aria-label":"Upload files",onClick:p,onKeydown:h,onDragenter:c,onDragleave:d,onDragover:u,onDrop:f},[e.createElementVNode("input",{ref_key:"fileInput",ref:r,type:"file",accept:g.accept,multiple:g.multiple,disabled:g.disabled,class:"media-dropzone__input",onChange:m},null,40,OI),e.createElementVNode("div",UI,[e.renderSlot(g.$slots,"icon",{},()=>[k[0]||(k[0]=e.createElementVNode("svg",{class:"media-dropzone__icon",xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.createElementVNode("polyline",{points:"17 8 12 3 7 8"}),e.createElementVNode("line",{x1:"12",y1:"3",x2:"12",y2:"15"})],-1))],!0),e.createElementVNode("p",zI,[e.renderSlot(g.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(g.title),1)],!0)]),e.createElementVNode("p",jI,[e.renderSlot(g.$slots,"subtitle",{},()=>[e.createTextVNode(e.toDisplayString(g.subtitle),1)],!0)]),e.createElementVNode("button",{type:"button",class:"media-dropzone__button",disabled:g.disabled,onClick:e.withModifiers(p,["stop"])},[e.renderSlot(g.$slots,"button",{},()=>[e.createTextVNode(e.toDisplayString(g.buttonText),1)],!0)],8,WI),l.value?(e.openBlock(),e.createElementBlock("p",ZI,e.toDisplayString(l.value),1)):e.createCommentVNode("",!0)])],42,PI))}}),Jl=Me(HI,[["__scopeId","data-v-b1366c1e"]]),XI=["data-index"],GI={key:0,class:"media-item__drag-handle","aria-label":"Drag to reorder",role:"button",tabindex:"0"},JI={class:"media-item__thumbnail"},KI=["src","alt"],YI={key:1,class:"media-item__file-icon"},qI={key:2,class:"media-item__progress-overlay"},QI={class:"media-item__progress-text"},e6={key:3,class:"media-item__processing-overlay"},t6={key:4,class:"media-item__error-overlay"},n6={class:"media-item__info"},a6=["title"],o6={key:0,class:"media-item__size"},i6={key:1,class:"media-item__error-message"},r6={class:"media-item__actions"},s6=["disabled"],l6=["disabled"],c6=["disabled"],d6=["disabled"],u6=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(a,{emit:n}){const t=a,o=n,i=e.ref(!1),r=e.computed(()=>{var _;return(_=t.item.upload)!=null&&_.previewUrl?t.item.upload.previewUrl:t.item.media?t.adapter.getThumbnailUrl(t.item.media):null}),s=e.computed(()=>{var _,v,S;return((_=t.item.upload)==null?void 0:_.status)==="uploading"||((v=t.item.upload)==null?void 0:v.status)==="pending"||((S=t.item.upload)==null?void 0:S.status)==="queued"}),l=e.computed(()=>{var _;return((_=t.item.upload)==null?void 0:_.status)==="processing"}),c=e.computed(()=>{var _;return((_=t.item.upload)==null?void 0:_.status)==="error"||t.item.errors&&t.item.errors.length>0}),d=e.computed(()=>{var _;return(_=t.item.upload)!=null&&_.error?t.item.upload.error:t.item.errors&&t.item.errors.length>0?t.item.errors[0].message:null}),u=e.computed(()=>{var _;return((_=t.item.upload)==null?void 0:_.progress)||0}),f=e.computed(()=>{var _;return t.item.name||((_=t.item.media)==null?void 0:_.file_name)||"Unknown file"}),p=e.computed(()=>{var V,x;const _=((V=t.item.media)==null?void 0:V.size)||((x=t.item.upload)==null?void 0:x.file.size);if(!_)return"";const v=1024,S=["Bytes","KB","MB","GB"],C=Math.floor(Math.log(_)/Math.log(v));return parseFloat((_/Math.pow(v,C)).toFixed(2))+" "+S[C]}),m=e.computed(()=>{var v,S;const _=((v=t.item.media)==null?void 0:v.mime_type)||((S=t.item.upload)==null?void 0:S.file.type);return _==null?void 0:_.startsWith("image/")}),h=e.computed(()=>({"media-item":!0,"media-item--uploading":s.value,"media-item--processing":l.value,"media-item--error":c.value,"media-item--disabled":t.disabled,"media-item--sortable":t.sortable}));function g(){t.disabled||o("remove",t.item)}function k(){t.disabled||o("edit",t.item)}function $(){t.disabled||o("retry",t.item)}function D(){t.disabled||o("cancel",t.item)}return(_,v)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(h.value),"data-index":_.index,onMouseenter:v[0]||(v[0]=S=>i.value=!0),onMouseleave:v[1]||(v[1]=S=>i.value=!1)},[_.sortable&&!_.disabled?(e.openBlock(),e.createElementBlock("div",GI,[...v[2]||(v[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",JI,[r.value&&m.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.value,alt:f.value,class:"media-item__image"},null,8,KI)):(e.openBlock(),e.createElementBlock("div",YI,[...v[3]||(v[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",qI,[e.createElementVNode("div",{class:"media-item__progress-bar",style:e.normalizeStyle({width:`${u.value}%`})},null,4),e.createElementVNode("span",QI,e.toDisplayString(u.value)+"%",1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",e6,[...v[4]||(v[4]=[e.createElementVNode("div",{class:"media-item__spinner","aria-label":"Processing"},null,-1)])])):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",t6,[...v[5]||(v[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",n6,[e.createElementVNode("span",{class:"media-item__name",title:f.value},e.toDisplayString(f.value),9,a6),p.value?(e.openBlock(),e.createElementBlock("span",o6,e.toDisplayString(p.value),1)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("span",i6,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",r6,[s.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-item__action media-item__action--cancel",disabled:_.disabled,"aria-label":"Cancel upload",onClick:D},[...v[6]||(v[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,s6)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"media-item__action media-item__action--retry",disabled:_.disabled,"aria-label":"Retry upload",onClick:$},[...v[7]||(v[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,l6)):e.createCommentVNode("",!0),_.showEdit&&_.item.media&&!s.value?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"media-item__action media-item__action--edit",disabled:_.disabled,"aria-label":"Edit",onClick:k},[...v[8]||(v[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,c6)):e.createCommentVNode("",!0),_.showRemove?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"media-item__action media-item__action--remove",disabled:_.disabled,"aria-label":"Remove",onClick:g},[...v[9]||(v[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,d6)):e.createCommentVNode("",!0)])],42,XI))}}),Kl=Me(u6,[["__scopeId","data-v-ff81c9ec"]]),m6=["aria-label"],p6=["draggable","data-index","onDragstart","onDragover","onDragend","onDrop"],f6={key:0,class:"media-collection__footer"},h6={class:"media-collection__count"},v6={key:0},g6={key:0,class:"media-collection__uploading"},y6=["name","value"],b6=["name","value"],w6=["name","value"],k6=["name","value"],_6={key:3,class:"media-collection__errors",role:"alert","aria-live":"polite"},E6=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(a,{emit:n}){const t=a,o=n,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:w=>{o("update:modelValue",w),o("change",w)},onUpload:w=>{o("upload",w)},onUploadComplete:w=>{o("upload-complete",w)},onUploadError:w=>{o("upload-error",w)},onRemove:w=>{o("remove",w)},onReorder:w=>{o("reorder",w)},onError:w=>{o("validation-error",w)},onReadyToSubmitChange:w=>{o("is-ready-to-submit-change",w)}},{items:r,setItems:s,addFiles:l,removeItem:c,reorderItems:d,cancelUpload:u,retryUpload:f,isLoading:p,isUploading:m,isAtMaxItems:h,errors:g,dragState:k,getDragProps:$,adapter:D,formValues:_,acceptString:v,count:S,remainingSlots:C}=Or(i);e.provide("mediaAdapter",D),e.provide("mediaCollection",{items:r,addFiles:l,removeItem:c,reorderItems:d}),e.watch(()=>t.modelValue,w=>{w!==r.value&&s(w)},{deep:!0});const V=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!h.value),x=e.computed(()=>({"media-collection":!0,"media-collection--disabled":t.disabled,"media-collection--readonly":t.readonly,"media-collection--loading":p.value,"media-collection--has-items":r.value.length>0,"media-collection--dragging":k.value.isDragging}));function T(w){l(w)}function j(w){c(w)}function E(w){f(w.clientId)}function A(w){u(w.clientId)}function N(w){}function z(w,O,Z){if(!t.sortable||t.disabled)return;const G=$(O,Z);G.onDragstart&&G.onDragstart(w)}function P(w,O){if(!t.sortable||t.disabled)return;w.preventDefault();const Z=r.value[O],G=$(Z,O);G.onDragover&&G.onDragover(w)}function B(w,O){const Z=$(w,O);Z.onDragend&&Z.onDragend()}function L(w,O){w.preventDefault();const Z=r.value[O],G=$(Z,O);G.onDrop&&G.onDrop(w)}return(w,O)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(x.value)},[e.renderSlot(w.$slots,"dropzone",{addFiles:e.unref(l)},()=>[V.value?(e.openBlock(),e.createBlock(Jl,{key:0,accept:e.unref(v),multiple:w.maxItems!==1,disabled:w.disabled,"max-file-size":w.maxFileSize,"max-items":e.unref(C),onFiles:T},null,8,["accept","multiple","disabled","max-file-size","max-items"])):e.createCommentVNode("",!0)],!0),e.unref(r).length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"media-collection__list",role:"list","aria-label":`${e.unref(S)} media items`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r),(Z,G)=>e.renderSlot(w.$slots,"item",{key:Z.clientId,item:Z,index:G,remove:()=>j(Z)},()=>[e.createElementVNode("div",{class:e.normalizeClass(["media-collection__item-wrapper",{"media-collection__item-wrapper--drag-over":e.unref(k).dropIndex===G}]),draggable:w.sortable&&!w.disabled,"data-index":G,onDragstart:re=>z(re,Z,G),onDragover:re=>P(re,G),onDragend:re=>B(Z,G),onDrop:re=>L(re,G)},[e.createVNode(Kl,{item:Z,adapter:e.unref(D),disabled:w.disabled,sortable:w.sortable,"show-remove":!w.readonly,"show-edit":!1,index:G,onRemove:j,onRetry:E,onCancel:A,onEdit:N},null,8,["item","adapter","disabled","sortable","show-remove","index"])],42,p6)],!0)),128))],8,m6)):V.value?e.createCommentVNode("",!0):e.renderSlot(w.$slots,"empty",{key:1},()=>[O[0]||(O[0]=e.createElementVNode("div",{class:"media-collection__empty"},[e.createElementVNode("p",null,"No files uploaded")],-1))],!0),e.renderSlot(w.$slots,"footer",{count:e.unref(S),isUploading:e.unref(m)},()=>[e.unref(r).length>0?(e.openBlock(),e.createElementBlock("div",f6,[e.createElementVNode("span",h6,[e.createTextVNode(e.toDisplayString(e.unref(S))+" "+e.toDisplayString(e.unref(S)===1?"file":"files")+" ",1),w.maxItems?(e.openBlock(),e.createElementBlock("span",v6," / "+e.toDisplayString(w.maxItems)+" max",1)):e.createCommentVNode("",!0)]),e.unref(m)?(e.openBlock(),e.createElementBlock("span",g6," Uploading... ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],!0),w.generateFormFields?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(_),(Z,G)=>(e.openBlock(),e.createElementBlock("input",{key:`${w.name}-${Z.uuid}`,type:"hidden",name:`${w.name}[${G}][uuid]`,value:Z.uuid},null,8,y6))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(_),(Z,G)=>(e.openBlock(),e.createElementBlock("input",{key:`${w.name}-${Z.uuid}-name`,type:"hidden",name:`${w.name}[${G}][name]`,value:Z.name},null,8,b6))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(_),(Z,G)=>(e.openBlock(),e.createElementBlock("input",{key:`${w.name}-${Z.uuid}-order`,type:"hidden",name:`${w.name}[${G}][order]`,value:Z.order},null,8,w6))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(_),(Z,G)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${w.name}-${Z.uuid}-props`},[Z.custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${w.name}[${G}][custom_properties]`,value:JSON.stringify(Z.custom_properties)},null,8,k6)):e.createCommentVNode("",!0)],64))),128))],64)):e.createCommentVNode("",!0),e.unref(g).length>0?(e.openBlock(),e.createElementBlock("div",_6,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),Z=>(e.openBlock(),e.createElementBlock("p",{key:Z.code||Z.message,class:"media-collection__error"},e.toDisplayString(Z.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),x6=Me(E6,[["__scopeId","data-v-10a5bfff"]]);function Yl(a={}){const{initialItem:n,onChange:t,onReplace:o,onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:l,onError:c,onReadyToSubmitChange:d,...u}=a,p={...u,initialItems:n?[n]:[],maxItems:1,sortable:!1,onChange:V=>{t==null||t(V[0]||null)},onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:l,onError:c,onReadyToSubmitChange:d},m=Or(p),h=e.computed(()=>m.items.value[0]||null),g=e.computed(()=>h.value!==null),k=e.computed(()=>m.formValues.value[0]||null);function $(V){V===null?m.clearAll():m.setItems([V])}async function D(V){const x=h.value;x&&m.removeItem(x),await m.addFiles([V])}function _(){h.value&&m.removeItem(h.value)}async function v(V){const x=h.value;x&&m.removeItem(x),await m.addFiles([V]);const T=m.items.value[0];T&&(o==null||o(x,T))}function S(){var V;(V=h.value)!=null&&V.upload&&m.cancelUpload(h.value.clientId)}async function C(){var V,x;((x=(V=h.value)==null?void 0:V.upload)==null?void 0:x.status)==="error"&&await m.retryUpload(h.value.clientId)}return{item:h,setItem:$,addFile:D,removeItem:_,replaceItem:v,cancelUpload:S,retryUpload:C,save:m.save,load:m.load,isLoading:m.isLoading,isUploading:m.isUploading,isReadyToSubmit:m.isReadyToSubmit,hasItem:g,errors:m.errors,adapter:m.adapter,formValue:k,acceptString:m.acceptString}}const S6=["accept","disabled"],C6={class:"media-attachment__preview"},V6=["name","value"],N6=["name","value"],T6=["name","value"],M6=["name","value"],B6={key:4,class:"media-attachment__errors",role:"alert","aria-live":"polite"},I6=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(a,{emit:n}){const t=a,o=n,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:E=>{o("update:modelValue",E),o("change",E)},onUpload:E=>{o("upload",E)},onUploadComplete:E=>{o("upload-complete",E)},onUploadError:E=>{o("upload-error",E)},onRemove:E=>{o("remove",E)},onReplace:(E,A)=>{o("replace",A)},onError:E=>{o("validation-error",E)},onReadyToSubmitChange:E=>{o("is-ready-to-submit-change",E)}},{item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:f,retryUpload:p,isLoading:m,hasItem:h,errors:g,adapter:k,formValue:$,acceptString:D}=Yl(r);e.provide("mediaAdapter",k),e.watch(()=>t.modelValue,E=>{E!==s.value&&l(E)},{deep:!0});const _=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!h.value),v=e.computed(()=>({"media-attachment":!0,"media-attachment--disabled":t.disabled,"media-attachment--readonly":t.readonly,"media-attachment--loading":m.value,"media-attachment--has-item":h.value}));function S(E){E.length>0&&c(E[0])}function C(){var E;(E=i.value)==null||E.click()}function V(E){const A=E.target,N=A.files;N&&N.length>0&&u(N[0]),A.value=""}function x(E){d()}function T(E){p()}function j(E){f()}return(E,A)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(v.value)},[e.createElementVNode("input",{ref_key:"fileInputRef",ref:i,type:"file",accept:e.unref(D),disabled:E.disabled,class:"media-attachment__hidden-input",onChange:V},null,40,S6),_.value?e.renderSlot(E.$slots,"dropzone",{key:0,addFile:e.unref(c)},()=>[e.createVNode(Jl,{accept:e.unref(D),multiple:!1,disabled:E.disabled,"max-file-size":E.maxFileSize,onFiles:S},null,8,["accept","disabled","max-file-size"])],!0):e.unref(h)&&e.unref(s)?e.renderSlot(E.$slots,"preview",{key:1,item:e.unref(s),remove:e.unref(d),replace:C},()=>[e.createElementVNode("div",C6,[e.createVNode(Kl,{item:e.unref(s),adapter:e.unref(k),disabled:E.disabled,sortable:!1,"show-remove":!E.readonly,"show-edit":!1,onRemove:x,onRetry:T,onCancel:j},null,8,["item","adapter","disabled","show-remove"]),E.showReplaceButton&&!E.readonly&&!E.disabled&&e.unref(s).media?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-attachment__replace-button",onClick:C},[...A[0]||(A[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(E.$slots,"empty",{key:2},()=>[A[1]||(A[1]=e.createElementVNode("div",{class:"media-attachment__empty"},[e.createElementVNode("p",null,"No file selected")],-1))],!0),E.generateFormFields&&e.unref($)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("input",{type:"hidden",name:`${E.name}[uuid]`,value:e.unref($).uuid},null,8,V6),e.createElementVNode("input",{type:"hidden",name:`${E.name}[name]`,value:e.unref($).name},null,8,N6),e.createElementVNode("input",{type:"hidden",name:`${E.name}[order]`,value:e.unref($).order},null,8,T6),e.unref($).custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${E.name}[custom_properties]`,value:JSON.stringify(e.unref($).custom_properties)},null,8,M6)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),e.unref(g).length>0?(e.openBlock(),e.createElementBlock("div",B6,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),N=>(e.openBlock(),e.createElementBlock("p",{key:N.code||N.message,class:"media-attachment__error"},e.toDisplayString(N.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),F6=Me(I6,[["__scopeId","data-v-26911174"]]),cp={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"}},$6=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(a,{expose:n,emit:t}){const o=a,i=t,r={initialItems:o.modelValue,modelType:o.modelType,modelId:o.modelId,collection:o.collection,maxItems:o.maxItems,maxFileSize:o.maxFileSize,acceptedMimeTypes:o.acceptedMimeTypes,sortable:o.sortable,disabled:o.disabled,rules:o.rules,adapterType:o.adapter,onChange:E=>{i("update:modelValue",E),i("change",E)},onUpload:E=>{i("upload",E)},onUploadComplete:E=>{i("upload-complete",E)},onUploadError:E=>{i("upload-error",E)},onRemove:E=>{i("remove",E)},onReorder:E=>{i("reorder",E)},onError:E=>{i("validation-error",E)},onReadyToSubmitChange:E=>{i("is-ready-to-submit-change",E)}},{items:s,setItems:l,addFiles:c,removeItem:d,reorderItems:u,updateItem:f,cancelUpload:p,retryUpload:m,isLoading:h,isUploading:g,isReadyToSubmit:k,isAtMaxItems:$,errors:D,dragState:_,getDragProps:v,adapter:S,formValues:C,acceptString:V}=Or(r);e.provide("mediaAdapter",S),e.provide("mediaCollection",{items:s,addFiles:c,removeItem:d,reorderItems:u}),e.watch(()=>o.modelValue,E=>{E!==s.value&&l(E)},{deep:!0});const x=e.computed(()=>({...cp,...o.labels})),T=e.computed(()=>({accept:V.value,multiple:o.maxItems!==1,disabled:o.disabled||o.readonly||$.value})),j=e.computed(()=>({items:s.value,isLoading:h.value,isUploading:g.value,isReadyToSubmit:k.value,isAtMaxItems:$.value,errors:D.value,addFiles:c,removeItem:d,reorderItems:u,clearAll:()=>{s.value.forEach(E=>d(E))},cancelUpload:p,retryUpload:m,labels:x.value,dropzoneProps:T.value}));return n({items:s,addFiles:c,removeItem:d,reorderItems:u,updateItem:f,cancelUpload:p,retryUpload:m,isLoading:h,isUploading:g,isReadyToSubmit:k,isAtMaxItems:$,errors:D,dragState:_,getDragProps:v,adapter:S,formValues:C,acceptString:V}),(E,A)=>e.renderSlot(E.$slots,"default",e.normalizeProps(e.guardReactiveProps(j.value)))}}),D6=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(a,{expose:n,emit:t}){const o=a,i=t,r={initialItem:o.modelValue,modelType:o.modelType,modelId:o.modelId,collection:o.collection,maxFileSize:o.maxFileSize,acceptedMimeTypes:o.acceptedMimeTypes,disabled:o.disabled,rules:o.rules,adapterType:o.adapter,onChange:x=>{i("update:modelValue",x),i("change",x)},onUpload:x=>{i("upload",x)},onUploadComplete:x=>{i("upload-complete",x)},onUploadError:x=>{i("upload-error",x)},onRemove:x=>{i("remove",x)},onReplace:(x,T)=>{i("replace",T)},onError:x=>{i("validation-error",x)},onReadyToSubmitChange:x=>{i("is-ready-to-submit-change",x)}},{item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:f,retryUpload:p,isLoading:m,isUploading:h,isReadyToSubmit:g,hasItem:k,errors:$,adapter:D,formValue:_,acceptString:v}=Yl(r);e.provide("mediaAdapter",D),e.watch(()=>o.modelValue,x=>{x!==s.value&&l(x)},{deep:!0});const S=e.computed(()=>({...cp,...o.labels})),C=e.computed(()=>({accept:v.value,multiple:!1,disabled:o.disabled||o.readonly||k.value})),V=e.computed(()=>({item:s.value,hasItem:k.value,isLoading:m.value,isUploading:h.value,isReadyToSubmit:g.value,errors:$.value,addFile:c,removeItem:d,replaceItem:u,cancelUpload:f,retryUpload:p,labels:S.value,dropzoneProps:C.value}));return n({item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:f,retryUpload:p,isLoading:m,isUploading:h,isReadyToSubmit:g,hasItem:k,errors:$,adapter:D,formValue:_,acceptString:v}),(x,T)=>e.renderSlot(x.$slots,"default",e.normalizeProps(e.guardReactiveProps(V.value)))}}),R6=["name","value"],A6=["name","value"],L6=["name","value"],P6=["name","value"],O6=e.defineComponent({__name:"MediaHiddenFields",props:{items:{default:()=>[]},item:{default:null},name:{default:"media"},format:{default:"mediables"}},setup(a){const n=a,t=e.computed(()=>n.item?[n.item]:n.items),o=e.computed(()=>Hl(t.value));function i(l,c){var u;const d=((u=o.value[l])==null?void 0:u.uuid)||"";return`${n.name}[${d}][${c}]`}function r(l,c){return`${n.name}[${l}][${c}]`}function s(l,c){return n.format==="spatie"?i(l,c):r(l,c)}return(l,c)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(d,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:d.uuid},[e.createElementVNode("input",{type:"hidden",name:s(u,"uuid"),value:d.uuid},null,8,R6),e.createElementVNode("input",{type:"hidden",name:s(u,"name"),value:d.name},null,8,A6),e.createElementVNode("input",{type:"hidden",name:s(u,"order"),value:d.order},null,8,L6),d.custom_properties&&Object.keys(d.custom_properties).length>0?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:s(u,"custom_properties"),value:JSON.stringify(d.custom_properties)},null,8,P6)):e.createCommentVNode("",!0)],64))),128))}}),U6=["data-testid"],z6=["data-testid"],j6=["id"],W6=["value","maxlength","disabled","aria-labelledby","placeholder","data-testid","onInput"],Z6=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:(a,n)=>`${a.type==="video"?"video":"photo"} ${n+1}`}},emits:["update:items"],setup(a,{emit:n}){const t=a,o=n;function i(r,s){const l=s.target;l instanceof HTMLInputElement&&o("update:items",t.items.map((c,d)=>d!==r?c:{...c,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,c)=>(e.openBlock(),e.createElementBlock("div",{key:l._key??l.id??`${l.url}:${c}`,class:"media-attachment-metadata-fields__row","data-testid":`${r.testIdPrefix}-${c}`},[e.createElementVNode("p",{id:`${r.testIdPrefix}-label-${c}`,class:"media-attachment-metadata-fields__label"},e.toDisplayString(r.label)+" for "+e.toDisplayString(r.getItemLabel(l,c)),9,j6),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-${c}`,placeholder:r.placeholder,"data-testid":`input-${r.testIdPrefix}-${c}`,onInput:d=>i(c,d)},null,40,W6)],8,z6))),128))],8,U6)):e.createCommentVNode("",!0)}}),H6=Me(Z6,[["__scopeId","data-v-a153768a"]]),X6="/v1/media/deletion/check",G6="/v1/media/deletion/delete",Ai=100;function Id(a){const n=new Set,t=[];for(const o of a){const i=o.trim().toLowerCase();i===""||n.has(i)||(n.add(i),t.push(i))}return t.sort()}function dp(a){const n=a.checkEndpoint??X6,t=a.deleteEndpoint??G6,o=e.ref(!1),i=e.ref(!1),r=e.ref(null),s=e.ref(null),l=e.ref(null);async function c(f){l.value=null;const p=Id(f);if(p.length===0)return r.value=[],[];if(p.length>Ai){const m=new Error(`Cannot check more than ${Ai} media items at once.`);throw l.value=m,m}o.value=!0;try{const m=await a.httpClient.post(n,{uuids:p}),h=((m==null?void 0:m.data)??[]).map(g=>{var k,$,D,_;return{uuid:g.uuid,canDelete:((k=g.report)==null?void 0:k.canDelete)??!1,blocks:Array.isArray(($=g.report)==null?void 0:$.blocks)?g.report.blocks:[],cascade:Array.isArray((D=g.report)==null?void 0:D.cascade)?g.report.cascade:[],variantCount:typeof((_=g.report)==null?void 0:_.variantCount)=="number"?g.report.variantCount:0}});return r.value=h,h}catch(m){throw l.value=m instanceof Error?m:new Error(String(m)),l.value}finally{o.value=!1}}async function d(f,p={}){l.value=null;const m=Id(f);if(m.length===0){const h={results:[],summary:{}};return s.value=h,h}if(m.length>Ai){const h=new Error(`Cannot delete more than ${Ai} media items at once.`);throw l.value=h,h}i.value=!0;try{const h=await a.httpClient.post(t,{uuids:m,force:p.force===!0}),g={results:Array.isArray(h==null?void 0:h.results)?h.results:[],summary:(h==null?void 0:h.summary)??{}};return s.value=g,g}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:o,isDeleting:i,lastReport:r,lastResponse:s,error:l,checkDependencies:c,deleteMany:d,reset:u}}const J6="/v1/user/media/trash";function K6(a){return`/v1/user/media/${encodeURIComponent(a)}/restore`}function up(a){const n=a.listEndpoint??J6,t=a.buildRestoreEndpoint??K6,o=a.perPage??50,i=e.ref([]),r=e.ref(0),s=e.ref(1),l=e.ref(!1),c=e.ref(!1),d=e.ref(null);async function u(m=1){var h,g;d.value=null,l.value=!0;try{const k=await a.httpClient.get(n,{params:{page:m,per_page:o}});i.value=Array.isArray(k==null?void 0:k.data)?k.data:[],r.value=typeof((h=k==null?void 0:k.meta)==null?void 0:h.total)=="number"?k.meta.total:0,s.value=typeof((g=k==null?void 0:k.meta)==null?void 0:g.current_page)=="number"?k.meta.current_page:m}catch(k){throw d.value=k instanceof Error?k:new Error(String(k)),d.value}finally{l.value=!1}}async function f(m){d.value=null,c.value=!0;try{const h=await a.httpClient.post(t(m)),g={status:(h==null?void 0:h.status)??"failed",data:(h==null?void 0:h.data)??null,duplicate_uuid:(h==null?void 0:h.duplicate_uuid)??null};return typeof(h==null?void 0:h.message)=="string"&&(g.message=h.message),g.status==="restored"&&(i.value=i.value.filter(k=>k.uuid!==m),r.value=Math.max(0,r.value-1)),g}catch(h){const g=Y6(h);if(g&&typeof g.status=="string"){const k={status:g.status,duplicate_uuid:typeof g.duplicate_uuid=="string"?g.duplicate_uuid:null};return typeof g.message=="string"&&(k.message=g.message),k}throw d.value=h instanceof Error?h:new Error(String(h)),d.value}finally{c.value=!1}}function p(){i.value=[],r.value=0,s.value=1,d.value=null}return{items:i,total:r,currentPage:s,isLoading:l,isRestoring:c,error:d,fetch:u,restore:f,reset:p}}function Y6(a){var t;if(typeof a!="object"||a===null)return null;const n=a;return(t=n.response)!=null&&t.data&&typeof n.response.data=="object"?n.response.data:null}const q6={class:"media-management-view","data-testid":"media-management-view"},Q6={class:"media-management-view__header"},eF={class:"media-management-view__title"},tF={class:"media-management-view__actions"},nF={key:0,class:"media-management-view__badge"},aF={key:0,class:"media-management-view__panel","data-testid":"panel-library"},oF={key:0,class:"media-management-view__status","data-testid":"library-loading"},iF={key:1,class:"media-management-view__status media-management-view__status--error","data-testid":"library-error"},rF={key:2,class:"media-management-view__empty","data-testid":"library-empty"},sF={key:3,class:"media-management-view__grid","data-testid":"library-grid"},lF=["data-testid"],cF=["data-testid","aria-pressed","onClick"],dF=["src","alt"],uF={key:1,class:"media-management-view__item-placeholder"},mF={class:"media-management-view__item-meta"},pF={class:"media-management-view__item-name"},fF=["data-testid"],hF={key:1,class:"media-management-view__item-badge","data-testid":"badge-orphaned"},vF={key:4,class:"media-management-view__bulk-bar","data-testid":"bulk-bar"},gF={"data-testid":"bulk-count"},yF=["disabled"],bF={key:1,class:"media-management-view__panel","data-testid":"panel-trash"},wF={key:0,class:"media-management-view__status","data-testid":"trash-loading"},kF={key:1,class:"media-management-view__empty","data-testid":"trash-empty"},_F={key:2,class:"media-management-view__grid","data-testid":"trash-grid"},EF=["data-testid"],xF={class:"media-management-view__item-thumb"},SF=["src","alt"],CF={class:"media-management-view__item-meta"},VF={class:"media-management-view__item-name"},NF={key:0,class:"media-management-view__item-meta-line"},TF=["data-testid","disabled","onClick"],MF=e.defineComponent({__name:"MediaManagementView",props:{httpClient:{},capabilities:{default:()=>({})},labels:{default:()=>({})},confirmBulkDelete:{},onRestoreCollision:{}},emits:["deleted","restored","restore-conflict","error"],setup(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>({showTrash:!0,allowBulkDelete:!0,showOwner:!1,...o.capabilities})),s=e.computed(()=>{var B,L,w,O,Z,G,re,be,Ee,ie,R,M;return{title:((B=o.labels)==null?void 0:B.title)??"My Media",libraryTab:((L=o.labels)==null?void 0:L.libraryTab)??"Library",trashTab:((w=o.labels)==null?void 0:w.trashTab)??"Trash",loading:((O=o.labels)==null?void 0:O.loading)??"Loading…",emptyLibrary:((Z=o.labels)==null?void 0:Z.emptyLibrary)??"No media yet — upload your first creation.",emptyTrash:((G=o.labels)==null?void 0:G.emptyTrash)??"Trash is empty.",orphanedBadge:((re=o.labels)==null?void 0:re.orphanedBadge)??"Not in use",selectedCount:((be=o.labels)==null?void 0:be.selectedCount)??(H=>`${H} selected`),deleteButton:((Ee=o.labels)==null?void 0:Ee.deleteButton)??"Delete",restoreButton:((ie=o.labels)==null?void 0:ie.restoreButton)??"Restore",purgeAfter:((R=o.labels)==null?void 0:R.purgeAfter)??(H=>`Purges ${H}`),ownerLabel:((M=o.labels)==null?void 0:M.ownerLabel)??(H=>`User ${H.user_id??""}`)}}),l=e.computed(()=>s.value.title),c=e.computed(()=>s.value.libraryTab),d=e.computed(()=>s.value.trashTab),u=e.computed(()=>s.value.loading),f=e.computed(()=>s.value.emptyLibrary),p=e.computed(()=>s.value.emptyTrash),m=e.computed(()=>s.value.orphanedBadge),h=e.computed(()=>s.value.deleteButton),g=e.computed(()=>s.value.restoreButton),k=e.ref("library"),$=e.ref({scope:"library"}),D=e.ref({}),_=Wl({httpClient:o.httpClient,view:$,filters:D,perPage:50}),v=e.computed(()=>_.items.value),S=e.computed(()=>_.loading.value),C=e.computed(()=>{var B;return((B=_.error.value)==null?void 0:B.message)??null}),V=Kd(v),x=dp({httpClient:o.httpClient}),T=up({httpClient:o.httpClient});function j(B){return s.value.selectedCount(B)}function E(B){return s.value.purgeAfter(B)}function A(B){return s.value.ownerLabel(B)}async function N(){const B=V.selectedItems.value;if(B.length===0)return;const L=r.value.canDelete?B.filter(w=>r.value.canDelete(w)):B;if(L.length!==0&&!(o.confirmBulkDelete&&!await o.confirmBulkDelete(L)))try{const w=L.map(G=>G.uuid),Z=(await x.deleteMany(w)).results.filter(G=>G.status==="trashed"||G.status==="already_trashed").map(G=>G.uuid);if(Z.length>0){for(const G of Z)V.deselect(G);i("deleted",Z),await _.refresh(),r.value.showTrash!==!1&&await T.fetch(T.currentPage.value).catch(()=>{})}}catch(w){i("error",w instanceof Error?w:new Error(String(w)))}}async function z(B){var L;try{const w=await T.restore(B);if(w.status==="restored"){i("restored",B),await _.refresh().catch(()=>{});return}if(w.status==="duplicate_conflict"){i("restore-conflict",{uuid:B,duplicateUuid:w.duplicate_uuid??null}),(L=o.onRestoreCollision)==null||L.call(o,B,w.duplicate_uuid??null);return}}catch(w){i("error",w instanceof Error?w:new Error(String(w)))}}async function P(){k.value="trash",T.items.value.length===0&&!T.isLoading.value&&await T.fetch().catch(B=>{i("error",B instanceof Error?B:new Error(String(B)))})}return e.watch(k,async B=>{B==="library"&&v.value.length===0&&!S.value&&await _.refresh().catch(()=>{})}),e.onMounted(async()=>{await _.refresh().catch(B=>{i("error",B instanceof Error?B:new Error(String(B)))}),r.value.showTrash!==!1&&T.fetch().catch(()=>{})}),n({refresh:()=>_.refresh(),refreshTrash:()=>T.fetch(),selection:V,deletion:x,trash:T}),(B,L)=>(e.openBlock(),e.createElementBlock("div",q6,[e.createElementVNode("header",Q6,[e.createElementVNode("h2",eF,e.toDisplayString(l.value),1),e.createElementVNode("div",tF,[r.value.showTrash!==!1?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["media-management-view__tab-button",{"is-active":k.value==="library"}]),"data-testid":"tab-library",onClick:L[0]||(L[0]=w=>k.value="library")},e.toDisplayString(c.value),3)):e.createCommentVNode("",!0),r.value.showTrash!==!1?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:e.normalizeClass(["media-management-view__tab-button",{"is-active":k.value==="trash"}]),"data-testid":"tab-trash",onClick:P},[e.createTextVNode(e.toDisplayString(d.value)+" ",1),e.unref(T).total.value>0?(e.openBlock(),e.createElementBlock("span",nF,e.toDisplayString(e.unref(T).total.value),1)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)])]),k.value==="library"?(e.openBlock(),e.createElementBlock("section",aF,[S.value?(e.openBlock(),e.createElementBlock("div",oF,e.toDisplayString(u.value),1)):C.value?(e.openBlock(),e.createElementBlock("div",iF,e.toDisplayString(C.value),1)):v.value.length===0?(e.openBlock(),e.createElementBlock("div",rF,e.toDisplayString(f.value),1)):(e.openBlock(),e.createElementBlock("ul",sF,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,w=>(e.openBlock(),e.createElementBlock("li",{key:w.uuid,class:e.normalizeClass(["media-management-view__item",{"is-selected":e.unref(V).isSelected(w.uuid)}]),"data-testid":`media-item-${w.uuid}`},[e.createElementVNode("button",{type:"button",class:"media-management-view__item-thumb","data-testid":`btn-select-${w.uuid}`,"aria-pressed":e.unref(V).isSelected(w.uuid),onClick:O=>e.unref(V).toggle(w.uuid)},[w.thumbnail_url||w.original_url?(e.openBlock(),e.createElementBlock("img",{key:0,src:w.thumbnail_url||w.original_url,alt:w.alt_text||w.file_name,loading:"lazy"},null,8,dF)):(e.openBlock(),e.createElementBlock("span",uF,e.toDisplayString(w.file_name),1))],8,cF),e.createElementVNode("div",mF,[e.createElementVNode("span",pF,e.toDisplayString(w.file_name),1),r.value.showOwner&&w.user_id?(e.openBlock(),e.createElementBlock("span",{key:0,class:"media-management-view__item-owner","data-testid":`owner-${w.uuid}`},e.toDisplayString(A(w)),9,fF)):e.createCommentVNode("",!0),w.is_orphaned?(e.openBlock(),e.createElementBlock("span",hF,e.toDisplayString(m.value),1)):e.createCommentVNode("",!0)])],10,lF))),128))])),e.unref(V).selectedCount.value>0&&r.value.allowBulkDelete!==!1?(e.openBlock(),e.createElementBlock("footer",vF,[e.createElementVNode("span",gF,e.toDisplayString(j(e.unref(V).selectedCount.value)),1),e.createElementVNode("button",{type:"button",class:"media-management-view__btn-delete","data-testid":"btn-bulk-delete",disabled:e.unref(x).isDeleting.value,onClick:N},e.toDisplayString(h.value),9,yF)])):e.createCommentVNode("",!0)])):k.value==="trash"?(e.openBlock(),e.createElementBlock("section",bF,[e.unref(T).isLoading.value?(e.openBlock(),e.createElementBlock("div",wF,e.toDisplayString(u.value),1)):e.unref(T).items.value.length===0?(e.openBlock(),e.createElementBlock("div",kF,e.toDisplayString(p.value),1)):(e.openBlock(),e.createElementBlock("ul",_F,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(T).items.value,w=>(e.openBlock(),e.createElementBlock("li",{key:w.uuid,class:"media-management-view__item is-trashed","data-testid":`trash-item-${w.uuid}`},[e.createElementVNode("div",xF,[w.thumbnail_url||w.original_url?(e.openBlock(),e.createElementBlock("img",{key:0,src:w.thumbnail_url||w.original_url,alt:w.alt_text||w.file_name,loading:"lazy"},null,8,SF)):e.createCommentVNode("",!0)]),e.createElementVNode("div",CF,[e.createElementVNode("span",VF,e.toDisplayString(w.file_name),1),w.purge_after?(e.openBlock(),e.createElementBlock("span",NF,e.toDisplayString(E(w.purge_after)),1)):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",class:"media-management-view__btn-restore","data-testid":`btn-restore-${w.uuid}`,disabled:e.unref(T).isRestoring.value,onClick:O=>z(w.uuid)},e.toDisplayString(g.value),9,TF)],8,EF))),128))]))])):e.createCommentVNode("",!0)]))}}),BF=Me(MF,[["__scopeId","data-v-ec535782"]]);exports.AlbumBrowser=Wm;exports.AlbumManager=CB;exports.AlbumMediaGrid=LB;exports.AlbumTree=jm;exports.ArrayBufferTarget=gl;exports.ExistingMediaSelector=Hv;exports.ImageEditor=Ud;exports.ImageEditorModal=zd;exports.LiveStreamManager=Q5;exports.ManagedMediaGallery=Ef;exports.MediaAlbumInlineCreate=Zm;exports.MediaAlbumUnavailableState=Hm;exports.MediaAttachment=F6;exports.MediaAttachmentMetadataFields=H6;exports.MediaCollection=x6;exports.MediaCollectionDropzone=Jl;exports.MediaCollectionItem=Kl;exports.MediaLibraryPicker=rp;exports.MediaLibraryPickerModal=wI;exports.MediaManagementView=BF;exports.MediaPreviewSheet=Xm;exports.MediaSelectionTray=BI;exports.MediaSourceSheet=Gm;exports.MediaThumbnailCell=Km;exports.MediaUploadSheet=Jm;exports.MediaWorkspace=bf;exports.ModelMediaManager=fv;exports.Muxer=mu;exports.VideoEditor=Lm;exports.VideoEditorDialog=R4;exports.VideoEditorSimple=rT;exports.VideoExportPanel=P3;exports.VideoJobClient=Ar;exports.VideoPlayer=Om;exports.VideoTimeline=MT;exports.VideoToolsPanel=b3;exports.VideoUploader=CM;exports.VirtualMediaGrid=Ym;exports._sfc_main=$6;exports._sfc_main$1=D6;exports._sfc_main$2=O6;exports.applyTemporaryMediaStoreConfig=Rd;exports.configureMediaStore=no;exports.createAdapter=sp;exports.createEmptyEditorState=qp;exports.createImageEditor=FI;exports.createMediablesAdapter=Xl;exports.createSpatieAdapter=Gl;exports.deserializeEditorState=Yp;exports.formatFileSize=ur;exports.fromMediaArray=ll;exports.getFileExtension=qm;exports.getImageDimensions=Qm;exports.getMediablesAdapter=$I;exports.getSpatieAdapter=AI;exports.isImageFile=Ul;exports.normalizeEditorState=cl;exports.normalizeRecipeForServerRender=g4;exports.recipeHasServerRenderableEdits=v4;exports.recipeHasUnsupportedServerEdits=Pm;exports.resetMediablesAdapter=DI;exports.resetSpatieAdapter=LI;exports.restoreMediaStoreConfig=Dd;exports.serializeEditorState=Fd;exports.snapshotMediaStoreConfig=$d;exports.toFormValues=Hl;exports.useAdminMediaStore=Ad;exports.useAlbumDragDrop=zm;exports.useAlbumStore=Pr;exports.useAlbums=Um;exports.useGlobalImageEditor=II;exports.useImageEditorModal=Zl;exports.useMediaAttachment=Yl;exports.useMediaCollection=Or;exports.useMediaDeletion=dp;exports.useMediaDragSort=lp;exports.useMediaLibraryPickerController=ip;exports.useMediaLibraryQuery=Wl;exports.useMediaLibrarySession=np;exports.useMediaLibraryStateMachine=ap;exports.useMediaLibraryTelemetry=op;exports.useMediaStore=ln;exports.useMediaTrash=up;exports.useMediaUploadQueue=jl;exports.useMediaValidation=zl;exports.validateFile=ep;
|
|
350
|
-
//# sourceMappingURL=index-Dvqt7Fr6.cjs.map
|