@codingfactory/mediables-vue 2.7.2 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/{PixiFrameExporter-n220y4aZ.cjs → PixiFrameExporter-COcgeYmj.cjs} +2 -2
  2. package/dist/{PixiFrameExporter-n220y4aZ.cjs.map → PixiFrameExporter-COcgeYmj.cjs.map} +1 -1
  3. package/dist/{PixiFrameExporter-C5RSaXvT.js → PixiFrameExporter-SiG3q5-_.js} +2 -2
  4. package/dist/{PixiFrameExporter-C5RSaXvT.js.map → PixiFrameExporter-SiG3q5-_.js.map} +1 -1
  5. package/dist/components/video/ui-v2/AssetRail.vue.d.ts +2 -0
  6. package/dist/components/video/ui-v2/AssetRailItem.vue.d.ts +7 -0
  7. package/dist/components/video/ui-v2/AudioMixerPanel.vue.d.ts +33 -0
  8. package/dist/components/video/ui-v2/CaptionSrtPanel.vue.d.ts +9 -0
  9. package/dist/components/video/ui-v2/DesktopInspectorSections.vue.d.ts +21 -0
  10. package/dist/components/video/ui-v2/DraftRecoveryBanner.vue.d.ts +12 -0
  11. package/dist/components/video/ui-v2/KeyframePresetPanel.vue.d.ts +26 -0
  12. package/dist/components/video/ui-v2/MobileClipSummary.vue.d.ts +4 -0
  13. package/dist/components/video/ui-v2/MobileToolPicker.vue.d.ts +3 -0
  14. package/dist/components/video/ui-v2/SplitPanelLayout.vue.d.ts +9 -5
  15. package/dist/components/video/ui-v2/TimelineTrackHeader.vue.d.ts +2 -0
  16. package/dist/composables/useClientVideoExport.d.ts +27 -0
  17. package/dist/composables/useLiveStream.d.ts +2 -2
  18. package/dist/composables/useRadialMenu.d.ts +1 -1
  19. package/dist/composables/useVideoEditor.d.ts +119 -7
  20. package/dist/composables/useVideoFilters.d.ts +4 -4
  21. package/dist/index-B6oyn6Pa.cjs +350 -0
  22. package/dist/index-B6oyn6Pa.cjs.map +1 -0
  23. package/dist/index-BGexNz7s.js +32993 -0
  24. package/dist/index-BGexNz7s.js.map +1 -0
  25. package/dist/mediables-vue.cjs +1 -1
  26. package/dist/mediables-vue.mjs +1 -1
  27. package/dist/render-page/assets/{index-aDRQNAjC.js → index-jZGmiMRr.js} +972 -159
  28. package/dist/render-page/index.html +1 -1
  29. package/dist/services/VideoJobClient.d.ts +1 -1
  30. package/dist/style.css +1 -1
  31. package/dist/types/api.d.ts +14 -0
  32. package/dist/types/video.d.ts +164 -5
  33. package/dist/video/project/audioMixerSchema.d.ts +152 -0
  34. package/dist/video/project/captionSrt.d.ts +23 -0
  35. package/dist/video/project/draftRecovery.d.ts +86 -0
  36. package/dist/video/project/exportPresets.d.ts +172 -0
  37. package/dist/video/project/index.d.ts +22 -0
  38. package/dist/video/project/keyframeAutomation.d.ts +91 -0
  39. package/dist/video/project/mediaSourceAnalysis.d.ts +127 -0
  40. package/dist/video/project/mediaSourceCache.d.ts +47 -0
  41. package/dist/video/project/recipeMigration.d.ts +26 -0
  42. package/dist/video/project/timelineSelection.d.ts +23 -0
  43. package/dist/video/project/timelineTransactions.d.ts +129 -0
  44. package/dist/video/project/visualLayerSchema.d.ts +238 -0
  45. package/dist/video-engine/adapters/AudioManager.d.ts +9 -0
  46. package/dist/video-engine/adapters/MediablesCompositionAdapter.d.ts +3 -0
  47. package/dist/video-engine/adapters/TextOverlayManager.d.ts +4 -2
  48. package/package.json +1 -1
  49. package/dist/index-B_7DfcKr.js +0 -29339
  50. package/dist/index-B_7DfcKr.js.map +0 -1
  51. package/dist/index-Dx7DOxwK.cjs +0 -342
  52. package/dist/index-Dx7DOxwK.cjs.map +0 -1
@@ -1,342 +0,0 @@
1
- "use strict";var wm=Object.defineProperty;var km=(o,n,t)=>n in o?wm(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t;var X=(o,n,t)=>km(o,typeof n!="symbol"?n+"":n,t);const Xo=require("pinia"),e=require("vue"),et=require("pixi.js"),le=require("./editor-BTwIhrcA.cjs"),U=require("@ionic/vue"),_m=require("pixi-filters");function Em(o){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(n,t,a.get?a:{enumerable:!0,get:()=>o[t]})}}return n.default=o,Object.freeze(n)}const lt=Em(et),fr=1,xm=new Set(["free","square","circle"]);function Cm(o){const n=typeof o;return n==="string"||n==="number"||n==="boolean"}function Sm(o){if(!o||typeof o!="object")return!1;const n=o;return typeof n.x=="number"&&typeof n.y=="number"&&typeof n.width=="number"&&typeof n.height=="number"}function Hr(o){if(!o||typeof o!="object")return null;const n=o;if(n.version!==fr)return null;const t=n.crop,a=t&&Sm(t.rect)?{...t.rect}:null,i=t&&typeof t.shape=="string"&&xm.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={},m=d.values;if(m&&typeof m=="object"&&!Array.isArray(m))for(const[f,p]of Object.entries(m))Cm(p)&&(u[f]=p);l.push({id:d.id,enabled:d.enabled!==!1,values:u})}return{version:fr,crop:{rect:a,aspectRatio:r,shape:i},filters:l}}function lc(o){const n=Hr(o);return n?JSON.stringify(n):null}function Vm(o){try{const n=JSON.parse(o);return Hr(n)}catch{return null}}function Nm(){return{version:fr,crop:{rect:null,aspectRatio:"free",shape:"free"},filters:[]}}let At={apiBaseUrl:"/api/v1",isAdmin:!1};function ta(o){At={...At,...o}}function cc(){return{...At}}function dc(o){At={...o}}function uc(o){const n=cc();return ta(o),()=>{dc(n)}}const Tm=async(o,n={})=>{var l;const t=(l=document.querySelector('meta[name="csrf-token"]'))==null?void 0:l.getAttribute("content"),a={Accept:"application/json",...n.headers};t&&(a["X-CSRF-TOKEN"]=t),n.body instanceof FormData||(a["Content-Type"]="application/json");const r={method:n.method||"GET",headers:a,credentials:"include"};n.body instanceof FormData?r.body=n.body:n.body!==void 0&&(r.body=JSON.stringify(n.body));const s=await fetch(o,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()},Rt=Xo.defineStore("media",()=>{const o=e.ref([]),n=e.ref([]),t=e.ref(!1),a=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),m=e.ref(new Map),f=e.ref(new Map),p=e.ref(new Set),v=e.ref(new Map),g=e.ref({}),k=5*60*1e3,T=e.computed(()=>{if(At.apiScope)return At.apiScope;if(At.isAdmin)return"admin"}),V=e.computed(()=>T.value==="admin");function b(){return At.httpClient||Tm}function h(de){const me=At.apiBaseUrl||"/api/v1",Ve=T.value?`/${T.value}`:"";return`${me}${Ve}${de}`}function _(de,me){return`${T.value??"default"}-${de}-${JSON.stringify(me)}`}function R(de){return Date.now()-de<k}function M(){v.value.clear(),g.value={}}function x(de){if(!de||!de.data)return;const me={};de.data.forEach(Ve=>{const ce=`${Ve.file_name}-${Ve.collection_name||"default"}`,pe=me[ce];(!pe||Object.keys(Ve.generated_conversions||{}).length>Object.keys(pe.generated_conversions||{}).length)&&(me[ce]=Ve)}),o.value=Object.values(me),de.meta&&(i.value=de.meta.current_page,r.value=Math.ceil(de.meta.total/de.meta.per_page))}async function C(de=1,me={}){const Ve=_(de,me),ce=v.value.get(Ve);if(ce&&R(ce.timestamp)){const pe=ce.data;return x(pe),pe}t.value=!0,a.value=null;try{const pe=new URLSearchParams;pe.append("page",de.toString()),pe.append("per_page",s.value.toString()),V.value&&pe.append("linked","1");for(const ut in me)if(Object.prototype.hasOwnProperty.call(me,ut)){const tt=me[ut];tt!=null&&tt!==""&&pe.append(ut,String(tt))}const Fe=await b()(h(`/media?${pe}`));return v.value.set(Ve,{data:Fe,timestamp:Date.now()}),x(Fe),Fe}catch(pe){throw a.value=pe instanceof Error?pe.message:"Failed to fetch media",o.value=[],new Error(a.value)}finally{t.value=!1}}async function P(de,me){t.value=!0,a.value=null;const Ve=`${de.name}-${Date.now()}`,ce={file:de,progress:0,status:"uploading"};m.value.set(Ve,ce);try{const pe=new FormData;pe.append("file",de),pe.append("collection",me.collection),me.ownerUuid&&(pe.append("owner_uuid",me.ownerUuid),pe.append("owner_type",me.ownerType||"")),me.usageUuid&&(pe.append("usage_uuid",me.usageUuid),pe.append("usage_type",me.usageType||""),pe.append("usage_purpose",me.usagePurpose||"")),me.customProperties&&pe.append("custom_properties",JSON.stringify(me.customProperties));const Fe=await b()(h("/media"),{method:"POST",body:pe});return ce.status="completed",ce.progress=100,ce.media=Fe==null?void 0:Fe.data,i.value===1&&(Fe!=null&&Fe.data)&&(o.value=[Fe.data,...o.value]),M(),(Fe==null?void 0:Fe.data)||null}catch(pe){throw ce.status="error",ce.error=pe instanceof Error?pe.message:"Upload failed",a.value=ce.error,new Error(a.value)}finally{t.value=!1,setTimeout(()=>{m.value.delete(Ve)},5e3)}}async function S(de){t.value=!0,a.value=null;const me=o.value.findIndex(ce=>ce.uuid===de);let Ve;me!==-1&&(Ve=o.value.splice(me,1)[0]);try{return await b()(h(`/media/${de}`),{method:"DELETE"}),p.value.delete(de),M(),!0}catch(ce){throw Ve&&me!==-1&&o.value.splice(me,0,Ve),a.value=ce instanceof Error?ce.message:"Failed to delete media",new Error(a.value)}finally{t.value=!1}}async function D(de,me){t.value=!0,a.value=null;try{const ce=await b()(h(`/media/${de}`),{method:"PATCH",body:me,data:me});if(ce!=null&&ce.data){const pe=o.value.findIndex(xe=>xe.uuid===de);return pe!==-1&&(o.value[pe]={...o.value[pe],...ce.data}),M(),ce.data}return null}catch(Ve){throw a.value=Ve instanceof Error?Ve.message:"Failed to update media",new Error(a.value)}finally{t.value=!1}}async function I(){t.value=!0,a.value=null;try{const me=await b()(h("/media/collections"));return n.value=(me==null?void 0:me.data)||[],n.value}catch(de){throw a.value=de instanceof Error?de.message:"Failed to fetch collections",n.value=[],new Error(a.value)}finally{t.value=!1}}async function j(de,me,Ve="images",ce){d.value=!0,u.value=null;try{const pe=new URLSearchParams;pe.append("collection",Ve),ce&&pe.append("search",ce);const Fe=await b()(h(`/media/model/${de}/${me}?${pe}`));return Fe!=null&&Fe.data?(c.value=Fe.data,Fe.data):[]}catch(pe){throw u.value=pe instanceof Error?pe.message:"Failed to fetch model media",c.value=[],new Error(u.value)}finally{d.value=!1}}async function O(de,me,Ve,ce="images"){d.value=!0,u.value=null;const pe=[...c.value];try{const Fe=await b()(h(`/media/model/${de}/${me}/attach`),{method:"POST",body:{media_uuids:Ve,collection:ce}});return await j(de,me,ce),(Fe==null?void 0:Fe.data)||[]}catch(xe){throw c.value=pe,u.value=xe instanceof Error?xe.message:"Failed to attach media",new Error(u.value)}finally{d.value=!1}}async function F(de,me,Ve,ce="images"){d.value=!0,u.value=null;const pe=[...c.value];c.value=c.value.filter(xe=>xe.uuid!==Ve);try{return await b()(h(`/media/model/${de}/${me}/detach`),{method:"POST",body:{media_uuid:Ve,collection:ce}}),!0}catch(xe){throw c.value=pe,u.value=xe instanceof Error?xe.message:"Failed to detach media",new Error(u.value)}finally{d.value=!1}}async function B(de,me,Ve,ce="images"){d.value=!0,u.value=null;const pe=[...c.value],xe=new Map(c.value.map(Fe=>[Fe.uuid,Fe]));c.value=Ve.map(Fe=>xe.get(Fe)).filter(Fe=>Fe!==void 0);try{return await b()(h(`/media/model/${de}/${me}/reorder`),{method:"POST",body:{media_uuids:Ve,collection:ce}}),!0}catch(Fe){throw c.value=pe,u.value=Fe instanceof Error?Fe.message:"Failed to reorder media",new Error(u.value)}finally{d.value=!1}}async function w(de,me,Ve={}){const ce=b(),pe=At.apiBaseUrl||"/api/v1",xe=new FormData,Fe=me.imageData,ut=Fe.match(/^data:(image\/\w+);base64,/),tt=ut?ut[1]:"image/png",Et=Fe.replace(/^data:image\/\w+;base64,/,""),ot=atob(Et),at=new Uint8Array(ot.length);for(let st=0;st<ot.length;st++)at[st]=ot.charCodeAt(st);const bt=new Blob([at],{type:tt});xe.append("image_file",bt,`edited.${tt==="image/jpeg"?"jpg":"png"}`);const Vt=lc(me.state);Vt&&xe.append("editor_state",Vt),me.metadata&&(xe.append("filters",JSON.stringify(me.metadata.filters)),me.metadata.cropRect&&xe.append("crop_data",JSON.stringify(me.metadata.cropRect))),xe.append("save_as_new","true"),Ve.asVariant&&xe.append("as_variant","true"),Ve.name!==void 0&&xe.append("name",Ve.name);const vt=await ce(`${pe}/editor/${de}/save`,{method:"POST",body:xe});if("media"in vt&&vt.media)return vt.media;if("status_url"in vt&&vt.status_url)return $(ce,vt.status_url,Ve.pollTimeout??6e4);throw new Error("Unexpected response from editor save endpoint")}async function $(de,me,Ve){const ce=Date.now(),pe=2e3;for(;Date.now()-ce<Ve;){await new Promise(Fe=>setTimeout(Fe,pe));const xe=await de(me);if(xe.status==="completed"&&xe.media)return xe.media;if(xe.status==="failed")throw new Error(xe.error??"Image processing failed")}throw new Error("Image processing timed out")}function z(de,me,Ve){l.value=Ve!==void 0?{type:de,uuid:me,collection:Ve}:{type:de,uuid:me},g.value[`${de}-${me}`]={timestamp:Date.now()}}function W(){l.value={type:null,uuid:null},c.value=[],u.value=null}async function Q(){if(!l.value.type||!l.value.uuid)return;const de=await j(l.value.type,l.value.uuid,l.value.collection||"images");c.value=de||[]}function ye(){o.value.forEach(de=>p.value.add(de.uuid))}function we(){p.value.clear()}function ie(de){p.value.has(de)?p.value.delete(de):p.value.add(de)}function N(de){return p.value.has(de)}function L(){return Array.from(m.value.values()).some(de=>de.status==="uploading")}function te(de){return m.value.get(de)||f.value.get(de)}function ne(){return[...Array.from(m.value.values()),...Array.from(f.value.values())]}async function re(){const de=Array.from(p.value);let me=0;for(const Ve of de)try{await S(Ve),me++}catch{}return we(),me}function he(de,me){var Ve;return me&&((Ve=de.conversion_urls)!=null&&Ve[me])?de.conversion_urls[me]||"":de.original_url||de.url||""}return{items:o,collections:n,loading:t,error:a,currentPage:i,totalPages:r,itemsPerPage:s,isAdmin:V,modelContext:l,modelMedia:c,isLoadingModelMedia:d,modelMediaError:u,selectedItems:p,uploadProgress:m,uploadQueue:f,cachedResponses:g,fetchMedia:C,uploadFile:P,deleteMedia:S,updateMedia:D,clearCache:M,fetchCollections:I,fetchModelMedia:j,attachMedia:O,detachMedia:F,reorderMedia:B,saveEditedImage:w,setModelContext:z,clearModelContext:W,refreshModelMedia:Q,selectAllItems:ye,clearSelection:we,toggleSelection:ie,isSelected:N,deleteSelectedItems:re,getHttpClient:b,getApiUrl:h,hasActiveUploads:L,getUploadProgress:te,getAllUploadProgress:ne,getMediaUrl:he}}),mc=()=>((At.apiScope!=="admin"||At.isAdmin!==!0)&&ta({...At,apiScope:"admin",isAdmin:!0}),Rt());class pc{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=le.el("div",{className:"panel-tabs",role:"tablist","aria-label":"Filter categories","data-testid":"v2-category-tabs"}),le.EDITOR_CATEGORIES.forEach(t=>{const a=le.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=le.el("span",{className:"panel-tab-icon","aria-hidden":"true"});i.innerHTML=t.icon,a.appendChild(i)}a.appendChild(le.el("span",{className:"panel-tab-label"},t.name)),this._tabs.set(t.id,a),this.element.appendChild(a)}),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 a;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(),(a=this._onSelect)==null||a.call(this,n)}_refreshActive(){this._tabs.forEach((n,t)=>{const a=this._isSelected(t);n.classList.toggle("active",a),n.setAttribute("aria-selected",a?"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 fc{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=le.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),a=this.state.get("activeFilters"),i=this.state.get("selectedFilter");t.forEach(r=>{var c;const s=((c=a==null?void 0:a.has)==null?void 0:c.call(a,r.id))??!1,l=i===r.id;this.element.appendChild(this._renderRow(r,s,l))})}_renderRow(n,t,a){const i=le.el("button",{type:"button",className:`filter-row ${a?"selected":""}`,role:"option","aria-selected":a?"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=le.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 m,f,p,v;d.stopPropagation();const u=!((f=(m=this.state.get("activeFilters"))==null?void 0:m.has)!=null&&f.call(m,n.id));(p=this._onToggle)==null||p.call(this,n.id,u),u&&((v=this._onSelect)==null||v.call(this,n.id))}});t&&(r.innerHTML=le.checkmark),i.appendChild(r);const s=le.el("div",{className:"filter-row-body"});s.appendChild(le.el("span",{className:"filter-row-name"},n.name));const l=this._buildSummary(n,t);l&&s.appendChild(le.el("span",{className:"filter-row-summary"},l)),i.appendChild(s);const c=le.el("span",{className:"filter-row-chevron","aria-hidden":"true"});return c.innerHTML=le.chevronRight,i.appendChild(c),i}_buildSummary(n,t){if(!t)return n.description||"";const a=this.state.getFilterValues(n.id);if(!a||Object.keys(a).length===0)return n.description||"Active";const i=[];for(const r of(n.controls||[]).slice(0,4)){const s=a[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),a=this.state.get("activeFilters");for(const r of t){const s=this.element.querySelector(`[data-filter="${r.id}"]`);if(!s)continue;const l=((i=a==null?void 0:a.has)==null?void 0:i.call(a,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(le.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 hc{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:a}={}){return this._onChange=n,this._onReset=t,this._onAction=a,this.element=le.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(le.el("div",{className:"no-filter-selected"},"Select a filter to adjust"));return}const t=this.filterManager.getFilterDef(n);if(!t){this.element.appendChild(le.el("div",{className:"no-filter-selected"},"Filter not found"));return}const a=le.el("div",{className:"controls-header"});a.appendChild(le.el("span",{className:"controls-title"},t.name)),a.appendChild(le.createButton({label:"Reset",className:"btn-text",onClick:()=>this._handleReset(n)})),this.element.appendChild(a);const i=le.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,m=this._createControl(n,c,u);m&&i.appendChild(m)})}this.element.appendChild(i)}_createControl(n,t,a){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 le.createSlider({id:`v2-${n}-${t.id}`,label:i,min:t.min??0,max:t.max??1,step:t.step??.01,value:typeof a=="number"?a:t.default??0,onChange:l=>{var c;return(c=this._onChange)==null?void 0:c.call(this,n,s,l)}});case"toggle":return le.createToggle({id:`v2-${n}-${t.id}`,label:i,checked:!!a,onChange:l=>{var c;return(c=this._onChange)==null?void 0:c.call(this,n,s,l)}});case"color":return le.createColorPicker({id:`v2-${n}-${t.id}`,label:i,value:typeof a=="string"&&a.startsWith("#")?a: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 le.createSelect({id:`v2-${n}-${t.id}`,label:i,options:l,value:a??t.default,onChange:c=>{var d;return(d=this._onChange)==null?void 0:d.call(this,n,s,c)}})}case"text":return le.createTextInput({id:`v2-${n}-${t.id}`,label:i,value:typeof a=="string"?a: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=le.el("div",{className:"button-control"});return l.appendChild(le.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 Mm{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:a}={}){return this._onRemove=n,this._onSelect=t,this._onClearAll=a,this.element=le.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,a=le.el("div",{className:"panel-section-title"});if(a.appendChild(le.el("span",{},`Active (${t})`)),t>0&&this._onClearAll&&a.appendChild(le.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(a),t===0){this.element.appendChild(le.el("div",{className:"active-empty"},"No filters applied"));return}const i=le.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 a=le.el("div",{className:`active-chip ${t?"selected":""}`,"data-filter":n.id,"data-testid":`v2-active-${n.id}`});a.appendChild(le.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=le.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=le.close,a.appendChild(i),a}_refreshSelection(){var a;const n=this.state.get("selectedFilter"),t=(a=this.element)==null?void 0:a.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 Jn=["collapsed","half","full"];class Bm{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=le.el("div",{className:"editor-v2-drawer",role:"dialog","aria-label":this._ariaLabel,"data-testid":"v2-bottom-drawer","data-snap":this._snap}),this._handle=le.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 a=le.el("span",{className:"drawer-handle-grip","aria-hidden":"true"});return this._handle.appendChild(a),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=le.el("div",{className:"drawer-header"}),n&&this._headerSlot.appendChild(n),this.element.appendChild(this._headerSlot),this._body=le.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={}){Jn.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,a,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=(a=this._handle)==null?void 0:a.setPointerCapture)==null||i.call(a,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,a=this._dragStartHeight-t;this._containerHeight||window.innerHeight;const i=this._heightForSnap("collapsed"),r=this._heightForSnap("full"),s=Math.max(i,Math.min(r,a));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,a=this._nearestSnap(t);this._applySnap(a,{animate:!0})}_cycleSnap(){const n=Jn.indexOf(this._snap),t=Jn[(n+1)%Jn.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=Jn[0],a=1/0;for(const i of Jn){const r=this._heightForSnap(i),s=Math.abs(r-n);s<a&&(a=s,t=i)}return t}_applySnap(n,{animate:t}){var r,s;if(!this.element)return;const a=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!==a&&((s=this._onSnapChange)==null||s.call(this,n,a))}destroy(){var n;(n=this.element)==null||n.remove(),this.element=null,this._handle=null,this._body=null,this._headerSlot=null}}class Fm{constructor(n,t,a){this.state=n,this.filterManager=t,this.editor=a,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=le.el("div",{className:"drawer-nav","data-testid":"v2-mobile-nav"}),this._headerEl=le.el("div",{className:"drawer-nav-header"}),this.element.appendChild(this._headerEl),this._bodyEl=le.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 pc(this.state,this.editor),this._categoryTabsEl=this._categoryTabs.render({onSelect:()=>this.navigateTo("filters")}),this._filterListView=new fc(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 hc(this.state,this.filterManager),this._filterControlsEl=this._filterControlsView.render({onChange:(n,t,a)=>this._callbacks.onFilterChange(n,t,a),onReset:n=>this._callbacks.onFilterReset(n),onAction:(n,t)=>this._callbacks.onFilterAction(n,t)})}navigateTo(n){var a;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),(a=this._onNavigate)==null||a.call(this,n)}_renderHeader(){if(!this._headerEl)return;if(this._headerEl.innerHTML="",this._view!=="categories"){const a=le.el("button",{type:"button",className:"drawer-back-btn","aria-label":"Go back","data-testid":"v2-drawer-back",onClick:()=>this._goBack()});a.innerHTML=le.chevronLeft,this._headerEl.appendChild(a)}const t=this._titleForView(this._view);if(this._headerEl.appendChild(le.el("h2",{className:"drawer-nav-title"},t)),this._view==="controls"){const a=this.state.get("selectedFilter");a&&this._headerEl.appendChild(le.createButton({label:"Reset",className:"btn-text",onClick:()=>this._callbacks.onFilterReset(a)}))}}_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"),a=t?this.filterManager.getFilterDef(t):null;return(a==null?void 0:a.name)||"Filter"}default:return""}}_categoryLabel(n){var t;return n&&((t=le.EDITOR_CATEGORIES.find(a=>a.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,a,i;this._unsubscribers.forEach(r=>r()),this._unsubscribers=[],(n=this._categoryTabs)==null||n.destroy(),(t=this._filterListView)==null||t.destroy(),(a=this._filterControlsView)==null||a.destroy(),(i=this.element)==null||i.remove(),this.element=null}}class Im{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=le.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 a=le.el("div",{className:"mobile-active-track"}),i=this.state.get("selectedFilter");for(const r of n){const s=this.filterManager.getFilterDef(r);s&&a.appendChild(this._renderChip(s,r===i))}this.element.appendChild(a)}_renderChip(n,t){const a=le.el("div",{className:`mobile-active-chip ${t?"selected":""}`,"data-filter":n.id,"data-testid":`v2-mobile-chip-${n.id}`});a.appendChild(le.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=le.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=le.close,a.appendChild(i),a}_refreshSelection(){var a;const n=this.state.get("selectedFilter"),t=(a=this.element)==null?void 0:a.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 rl="(max-width: 900px)";let $m=class{constructor(n,t,a){this.state=n,this.filterManager=t,this.editor=a,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=le.el("div",{className:"editor-v2-body"}),this.canvasSection=le.el("div",{className:"editor-v2-canvas"}),this.canvasContainer=le.el("div",{className:"canvas-container"}),this.cropOverlay=le.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,rl).matches)===!0,this._isMobile?this._buildMobileShell():this._buildDesktopShell(),typeof window<"u"&&window.matchMedia&&(this._mql=window.matchMedia(rl),this._mqlHandler=a=>this._handleBreakpointChange(a.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:a})=>this._applyMode(a))),{root:this.root,canvasContainer:this.canvasContainer,cropOverlay:this.cropOverlay}}mountCropControls(n){this._cropControlsEl=n,this._mountCropControlsInActiveShell()}_buildDesktopShell(){this._panel=le.el("div",{className:"editor-v2-panel","data-testid":"v2-inspector-panel"}),this._categoryTabs=new pc(this.state,this.editor),this._panel.appendChild(this._categoryTabs.render({onSelect:()=>this._handleDesktopCategoryChange()}));const n=le.el("div",{className:"panel-body"});this._desktopFilterListSection=le.el("div",{className:"panel-section"}),this._desktopFilterListSection.appendChild(le.el("div",{className:"panel-section-title"},le.el("span",{},"Filters"))),this._filterListView=new fc(this.state,this.filterManager),this._desktopFilterListSection.appendChild(this._filterListView.render({onToggle:(t,a)=>this._callbacks.onFilterToggle(t,a),onSelect:t=>this._callbacks.onFilterSelect(t)})),n.appendChild(this._desktopFilterListSection),this._filterControlsView=new hc(this.state,this.filterManager),n.appendChild(this._filterControlsView.render({onChange:(t,a,i)=>this._callbacks.onFilterChange(t,a,i),onReset:t=>this._callbacks.onFilterReset(t),onAction:(t,a)=>this._callbacks.onFilterAction(t,a)})),this._desktopCropWrapper=le.el("div",{className:"crop-controls-wrapper",style:{display:"none"}}),n.appendChild(this._desktopCropWrapper),this._activeStack=new Mm(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,a;return(a=(t=this._callbacks).onClearAll)==null?void 0:a.call(t)}})),this._panel.appendChild(n),this.root.appendChild(this._panel),this._mountCropControlsInActiveShell(),this._applyMode(this.state.get("mode"))}_buildMobileShell(){this._mobileChips=new Im(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 Bm({onSnapChange:r=>{this.canvasContainer&&window.dispatchEvent(new Event("resize"))}}),this._mobileNav=new Fm(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=le.el("div",{className:"crop-controls-wrapper",style:{display:"none"}});const a=le.el("div",{className:"drawer-content"});a.appendChild(t),a.appendChild(this._mobileCropWrapper);const i=this._mobileDrawer.build({body:a});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,a,i,r,s,l;(n=this._categoryTabs)==null||n.destroy(),this._categoryTabs=null,(t=this._filterListView)==null||t.destroy(),this._filterListView=null,(a=this._filterControlsView)==null||a.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,a,i,r;(n=this._resizeObserver)==null||n.disconnect(),this._resizeObserver=null,(t=this._mobileNav)==null||t.destroy(),this._mobileNav=null,(a=this._mobileChips)==null||a.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 a,i,r;const t=n==="crop";this._desktopFilterListSection&&(this._desktopFilterListSection.style.display=t?"none":""),(a=this._filterControlsView)!=null&&a.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 Rm extends le.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 a=t.preset?le.getPreset(t.preset):null,i=a?{initialMode:a.initialMode==="crop"?"crop":"adjust",cropShape:a.cropShape,initialAspectRatio:a.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=a,this._state=le.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 le.PixiRenderer,this._filterManager=new le.FilterManager(this._state,this._renderer),this._cropManager=new le.CropManager(this._state,this._renderer),this._removeBgManager=null,((r=this._options.backgroundRemoval)==null?void 0:r.enabled)!==!1&&(this._removeBgManager=new le.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=le.el("div",{className:`vanilla-image-editor-v2 ${this._state.get("isDarkMode")?"dark":"light"}`}),this._toolbarContainer=le.el("div",{className:"editor-v2-toolbar"}),this._editorEl.appendChild(this._toolbarContainer),this._layout=new $m(this._state,this._filterManager,this);const{root:n,canvasContainer:t,cropOverlay:a}=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=a,this._editorEl.appendChild(n),this._fileInput=le.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 le.Toolbar(this._state,this),this._toolbarContainer.appendChild(this._toolbar.render()),this._cropControls=new le.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,a;this._destroyed||!this._canvasContainer||(this._renderer.resizeTo(this._canvasContainer),this._state.get("mode")==="crop"&&((a=(t=this._cropManager).drawOverlay)==null||a.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,a;(t=this._editorEl)==null||t.classList.toggle("dark",n),(a=this._editorEl)==null||a.classList.toggle("light",!n)})}async _handleFileSelect(n){var a;const t=(a=n.target.files)==null?void 0:a[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 a=this._filterManager.getFilterDef(n);if(typeof(a==null?void 0:a.category)=="string"){const r=le.REGISTRY_TO_UI[a.category]||a.category;this._state.get("selectedCategory")!==r&&this._state.set("selectedCategory",r)}}_handleFilterChange(n,t,a){this._filterManager.updateValue(n,t,a)||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 a=++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!==a)){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",a=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",a)),this._state.set("crop.shape",t),this._state.set("crop.aspect",a)}if(Array.isArray(n.filters)){let t=null;for(const a of n.filters)if(a.enabled&&(t===null&&(t=a.id),this._state.toggleFilter(a.id,!0),this._filterManager.initializeValues(a.id),a.values))for(const[i,r]of Object.entries(a.values))this._state.setFilterValue(a.id,i,r);if(t!==null){this._state.set("selectedFilter",t);const a=this._filterManager.getFilterDef(t);if(typeof(a==null?void 0:a.category)=="string"){const i=le.REGISTRY_TO_UI[a.category]??a.category;this._state.set("selectedCategory",i)}}this._filterManager.applyFilters()}}}openFilePicker(){var n;(n=this._fileInput)==null||n.click()}exportImage(n="png",t=.92,a={}){return this._state.get("crop.rect")&&!this._cropManager.apply()?null:this._renderer.exportImage(n,t,a.maxEdge??0,a.dontUpscale!==!1,a.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,a={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:a,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 a=this._state.get("crop.appliedRect"),i=this._state.get("crop.rect"),r=a||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 a=await this._removeBgManager.removeBackground(t,n);return await this.loadImage(a.dataUrl),this.emit("background-removed",{model:a.model,processMs:a.processMs}),{model:a.model,processMs:a.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 a;if(!this._loadingOverlay)this._loadingOverlay=le.el("div",{className:"editor-loading-overlay"},le.el("div",{className:"editor-loading-spinner"}),le.el("div",{className:"editor-loading-text"},n));else{const i=this._loadingOverlay.querySelector(".editor-loading-text");i&&(i.textContent=n)}const t=(a=this._canvasContainer)==null?void 0:a.parentElement;t&&!this._loadingOverlay.parentElement&&t.appendChild(this._loadingOverlay)}_hideLoadingOverlay(){var n;(n=this._loadingOverlay)==null||n.remove()}destroy(){var n,t,a,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(),(a=this._cropControls)==null||a.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 Dm(o,n){try{let t=le.getFilter(o);if(t||(le.registerCorePixiFilters(),t=le.getFilter(o)),!t){try{const r=le.getAllFilters()}catch{}return null}const a={...t.defaultParams,...n};return t.createFilter(a)}catch{return null}}const Gi=78e5,Am=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(o,{emit:n}){const t=o,a=n,i=e.ref(null);let r=null,s=null;function l(){var b;if(!r){a("error",new Error("Editor not initialized"));return}const m=r.exportImage("png",.92,{maxPixels:Gi});if(!m){a("error",new Error("Failed to export image — the image could not be processed"));return}const f=r.getSerializableState(),p=r._renderer,v=((b=p==null?void 0:p.getExportDimensions)==null?void 0:b.call(p))??{width:0,height:0},g=v.width*v.height,k=g>Gi?Math.sqrt(Gi/Math.max(1,g)):1,T={width:Math.max(1,Math.floor(v.width*k)),height:Math.max(1,Math.floor(v.height*k))};a("save",{imageData:m,dimensions:T,state:f})}function c(){a("cancel")}function d(){if(!i.value||r)return;window.PIXI=lt,le.initializeFilterRegistry();const m={theme:t.theme};t.preset&&(m.preset=t.preset),t.preset?t.cropShape==="circle"&&(m.cropShape="circle",m.initialAspectRatio="1:1",m.initialMode="crop"):(m.cropShape=t.cropShape==="circle"?"circle":"free",m.initialAspectRatio=t.cropShape==="circle"?"1:1":"free",m.initialMode=t.cropShape==="circle"?"crop":"adjust");const f=t.editorVersion==="v2"?Rm:le.VanillaImageEditor;r=new f(i.value,m),r.setFilterRegistry({getAllFilters:le.getAllFilters,getFilter:le.getFilter,getFiltersByCategory:le.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(m=>{const f=m[0];f&&f.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,(m,f)=>{!r||!m||m===f||u()}),e.watch(()=>t.sessionKey,(m,f)=>{m!==f&&u()}),e.watch(()=>t.initialState,(m,f)=>{m!==f&&u()}),e.onUnmounted(()=>{s==null||s.disconnect(),s=null,r&&(r.destroy(),r=null)}),(m,f)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:i,class:"vanilla-editor-wrapper","data-testid":"vanilla-image-editor"},null,512))}}),Te=(o,n)=>{const t=o.__vccOpts||o;for(const[a,i]of n)t[a]=i;return t},vc=Te(Am,[["__scopeId","data-v-24c46711"]]),Lm={class:"editor-modal-panel"},Um={class:"editor-fill"},Om=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(o,{emit:n}){const t=o,a=n,i=e.ref(null),r=e.ref(t.modelValue),s=e.ref(!1),l=e.ref(null),c=g=>{a("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,a("save",g)}catch(k){c(k)}finally{s.value=!1}},m=()=>{a("cancel"),p()},f=()=>{s.value||p()},p=()=>{r.value=!1,a("update:modelValue",!1),l.value&&l.value instanceof HTMLElement&&(l.value.focus(),l.value=null)},v=g=>{if(g.key==="Escape"&&r.value&&!s.value){p();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 T=k[0],V=k[k.length-1];g.shiftKey&&document.activeElement===T?(g.preventDefault(),V.focus()):!g.shiftKey&&document.activeElement===V&&(g.preventDefault(),T.focus())}};return e.onMounted(()=>{document.addEventListener("keydown",v)}),e.onBeforeUnmount(()=>{document.removeEventListener("keydown",v)}),(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(f,["escape"])},[e.createElementVNode("div",{class:"editor-modal-backdrop",onClick:f}),e.createElementVNode("div",Lm,[e.createElementVNode("div",Um,[e.createVNode(vc,{"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:m,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)]))}}),gc=Te(Om,[["__scopeId","data-v-adf95668"]]),Pm={class:"media-workspace"},zm={class:"media-workspace-toolbar"},jm={class:"media-workspace-label"},Wm=["value"],Zm={class:"media-workspace-grid"},Hm=["onClick"],Xm=e.defineComponent({__name:"MediaWorkspace",props:{apiScope:{},subScopes:{},initialScopeId:{}},emits:["scope-change","update:media","upload","preview"],setup(o,{emit:n}){var m;const t=o,a=n,i=Rt(),r=e.ref(t.initialScopeId??((m=t.subScopes[0])==null?void 0:m.id)??""),s=e.computed(()=>t.subScopes),l=e.computed(()=>s.value.find(f=>f.id===r.value));let c=null;function d(){c&&(c(),c=null),t.apiScope&&(c=uc({apiScope:t.apiScope,isAdmin:t.apiScope==="admin"}))}async function u(){var p;const f={};(p=l.value)!=null&&p.collection&&(f.collection=l.value.collection),await i.fetchMedia(1,f),a("update:media",[...i.items])}return e.watch(()=>t.initialScopeId,f=>{f&&f!==r.value&&(r.value=f)}),e.watch(()=>t.subScopes,f=>{if(f.length===0){r.value="";return}f.some(p=>p.id===r.value)||(r.value=f[0].id)},{deep:!0}),e.watch(()=>t.apiScope,()=>{d(),u()}),e.watch(r,f=>{f&&(a("scope-change",f),u())}),e.onMounted(()=>{d(),u()}),e.onUnmounted(()=>{c&&(c(),c=null)}),(f,p)=>(e.openBlock(),e.createElementBlock("div",Pm,[e.createElementVNode("div",zm,[e.createElementVNode("label",jm,[p[2]||(p[2]=e.createElementVNode("span",{class:"media-workspace-label-text"},"Scope",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":p[0]||(p[0]=v=>r.value=v),"data-testid":"scope-select",class:"media-workspace-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,v=>(e.openBlock(),e.createElementBlock("option",{key:v.id,value:v.id},e.toDisplayString(v.label),9,Wm))),128))],512),[[e.vModelSelect,r.value]])]),e.createElementVNode("button",{type:"button",class:"media-workspace-upload","data-testid":"upload-button",onClick:p[1]||(p[1]=v=>a("upload"))}," Upload ")]),e.createElementVNode("div",Zm,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i).items,v=>(e.openBlock(),e.createElementBlock("button",{key:v.uuid,type:"button",class:"media-workspace-item","data-testid":"media-item",onClick:g=>a("preview",v)},e.toDisplayString(v.file_name),9,Hm))),128))])]))}}),Gm=Te(Xm,[["__scopeId","data-v-895f26fe"]]),Jm={class:"managed-media-gallery"},Ym={class:"gallery-grid"},qm=e.defineComponent({__name:"ManagedMediaGallery",props:{media:{},selectable:{type:Boolean},multiple:{type:Boolean}},emits:["select","remove"],setup(o){return(n,t)=>(e.openBlock(),e.createElementBlock("div",Jm,[e.createElementVNode("div",Ym,[e.renderSlot(n.$slots,"default",{},void 0,!0)])]))}}),Km=Te(qm,[["__scopeId","data-v-10a9b8c5"]]),Qm="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>",Xr="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>",ep="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>",Gr="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>",tp="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>",np="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>",xa="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>",ap="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>",yc="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>",bc="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>",sl="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>",op="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>",ip="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>",ll="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>",Rn="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>",cl="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>",rp="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>",yn="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>",sp="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>",ya="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>",lp="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>",cp="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>",dl="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>",wc="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>",na="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>",dp="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>",up="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>",mp="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>",Ca="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>",ul="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>",Ji="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>",pp="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>",fp="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>",Yi="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>",hp="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>",vp="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>",gp="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>",yp="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>",kc="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>",Jr="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>",bp="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>",wp="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>",kp="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>",_p="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>",_c="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>",Ep="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>",xp="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>",Yr="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>",Cp="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>",Sp="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>",Un="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>",Vp="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>",Np="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>",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='M304 96h112v112M405.77 106.2L111.98 400.02M208 416H96V304' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Go="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>",Tp="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>",qi="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>",gn="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>",ba="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>",pl="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>",Mp="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>",Ec="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' 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>",Bp="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>",xc="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>",Fp="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>",Ip="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>",$p="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>",Rp="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>",Dp="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>",Ap="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>",Lp="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>",co="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 fl=()=>{};function Up(o,n){function t(...a){return new Promise((i,r)=>{Promise.resolve(o(()=>n.apply(this,a),{fn:n,thisArg:this,args:a})).then(i).catch(r)})}return t}function Op(o,n={}){let t,a,i=fl;const r=c=>{clearTimeout(c),i(),i=fl};let s;return c=>{const d=e.toValue(o),u=e.toValue(n.maxWait);return t&&r(t),d<=0||u!==void 0&&u<=0?(a&&(r(a),a=null),Promise.resolve(c())):new Promise((m,f)=>{i=n.rejectOnCancel?f:m,s=c,u&&!a&&(a=setTimeout(()=>{t&&r(t),a=null,m(s())},u)),t=setTimeout(()=>{a&&r(a),a=null,m(c())},d)})}}function Pp(o,n=200,t={}){return Up(Op(n,t),o)}const wa=new Map;function zp(o){const n=e.getCurrentScope();function t(l){var c;const d=wa.get(o)||new Set;d.add(l),wa.set(o,d);const u=()=>i(l);return(c=n==null?void 0:n.cleanups)==null||c.push(u),u}function a(l){function c(...d){i(c),l(...d)}return t(c)}function i(l){const c=wa.get(o);c&&(c.delete(l),c.size||r())}function r(){wa.delete(o)}function s(l,c){var d;(d=wa.get(o))==null||d.forEach(u=>u(l,c))}return{on:t,once:a,off:i,emit:s,reset:r}}function Cc(){var r,s;const o=typeof window<"u"&&"Capacitor"in window&&((s=(r=window.Capacitor)==null?void 0:r.isNativePlatform)==null?void 0:s.call(r));return{selection:()=>{var l,c;if(o)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(o)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(o)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(o)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 Sc(o){const n=e.ref(new Set),t=e.ref(null),a=e.ref(-1),i=zp("media-selection"),r=Cc(),s=e.computed(()=>o.value.filter(_=>n.value.has(_.uuid))),l=e.computed(()=>n.value.size);e.watch(n,_=>{i.emit({type:"selection:changed",count:_.size,selectedIds:Array.from(_)})},{deep:!0});const c=e.computed(()=>o.value.length>0&&o.value.every(_=>n.value.has(_.uuid))),d=e.computed(()=>o.value.some(_=>n.value.has(_.uuid)));function u(_){return n.value.has(_)}function m(_){n.value.has(_)?(n.value.delete(_),t.value===_&&(t.value=null,a.value=-1)):(n.value.add(_),t.value=_,a.value=o.value.findIndex(R=>R.uuid===_),n.value.size===1&&r.selection())}function f(_){n.value.add(_),t.value=_,a.value=o.value.findIndex(R=>R.uuid===_)}function p(_){n.value.delete(_),t.value===_&&(t.value=null,a.value=-1)}function v(){o.value.forEach(_=>n.value.add(_.uuid))}function g(){n.value.clear(),t.value=null,a.value=-1}function k(){c.value?g():v()}function T(_,R){const M=o.value.findIndex(x=>x.uuid===_);if(M!==-1)if(R!=null&&R.shiftKey&&a.value!==-1){const x=Math.min(a.value,M),C=Math.max(a.value,M);for(let P=x;P<=C;P++)n.value.add(o.value[P].uuid)}else m(_)}function V(){if(o.value.length===0)return;let _=a.value+1;_>=o.value.length&&(_=0),g(),f(o.value[_].uuid)}function b(){if(o.value.length===0)return;let _=a.value-1;_<0&&(_=o.value.length-1),g(),f(o.value[_].uuid)}function h(_){switch(_.key){case"ArrowDown":_.preventDefault(),V();break;case"ArrowUp":_.preventDefault(),b();break;case"a":(_.ctrlKey||_.metaKey)&&(_.preventDefault(),v());break;case"Escape":_.preventDefault(),g();break;case" ":t.value&&(_.preventDefault(),m(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:m,select:f,deselect:p,selectAll:v,clear:g,toggleAll:k,rangeSelect:T,selectNext:V,selectPrevious:b,handleKeydown:h,selectionBus:i}}const jp={class:"flex items-center justify-between w-full px-4"},Wp={class:"p-4"},Zp={key:0,class:"mb-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg"},Hp={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"},Xp=["value"],Gp={class:"flex gap-2 mt-4"},Jp={class:"flex justify-end mb-4"},Yp={key:1,class:"flex justify-center items-center h-64"},qp={key:2,class:"flex flex-col items-center justify-center h-64 text-center"},Kp={class:"text-sm text-theme-secondary"},Qp={key:0},ef={class:"mb-4"},tf={class:"mb-4"},nf={class:"flex gap-2"},af={class:"flex items-center justify-between px-4 py-2"},of={class:"text-sm text-theme-secondary"},rf={key:0},sf={key:0},lf={key:1},cf={class:"flex gap-2"},df=e.defineComponent({__name:"AdminMediaBrowser",props:{isOpen:{type:Boolean},selectionMode:{default:"single"},selectedItems:{default:()=>[]},modelType:{},modelId:{},collection:{default:"images"},maxSelection:{}},emits:["close","confirm"],setup(o,{emit:n}){const t=o,a=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)),m=e.ref(!1),f=e.ref({}),p=e.ref(["images","documents","videos"]),v=e.ref(1),g=e.ref(!0),k=e.ref(!1),T=mc(),V=Sc(c);function b(N){var me;const L=N.conversion_urls||{},te=N.proxy_url||N.original_url||N.url||"",ne=L.thumb||L.preview||N.preview_url||N.thumbnail_url||te,re=N.custom_properties||{},he=re.width,de=re.height;return{...N,uuid:N.uuid,name:N.name||N.file_name,file_name:N.file_name,filename:N.file_name,mime_type:N.mime_type,size:N.size,collection_name:N.collection_name||"images",disk:N.disk,original_url:te,url:te,thumbnail_url:ne,conversions:N.conversions||{},conversion_urls:L,generated_conversions:N.generated_conversions||{},custom_properties:re,caption:N.caption||null,alt_text:N.alt_text||null,created_at:N.created_at,updated_at:N.updated_at,is_image:((me=N.mime_type)==null?void 0:me.startsWith("image/"))||!1,...typeof he=="number"?{width:he}:{},...typeof de=="number"?{height:de}:{},...N.formatted_size!==void 0?{formatted_size:N.formatted_size}:{}}}e.watch(()=>t.selectedItems,N=>{u.value=new Set(N),V.clear(),N.forEach(L=>V.select(L))});const h=e.computed(()=>{var L;let N=c.value;return(L=f.value.types)!=null&&L.length&&(N=N.filter(te=>{var re,he;const ne=(re=te.mime_type)==null?void 0:re.split("/")[0];return(he=f.value.types)==null?void 0:he.includes(ne)})),(f.value.sizeMin!==void 0||f.value.sizeMax!==void 0)&&(N=N.filter(te=>{const ne=te.size/1048576;return!(f.value.sizeMin!==void 0&&ne<f.value.sizeMin||f.value.sizeMax!==void 0&&ne>f.value.sizeMax)})),N}),_=e.computed(()=>{var L;let N=0;return f.value.search&&N++,f.value.collection&&N++,(f.value.dateFrom||f.value.dateTo)&&N++,(L=f.value.types)!=null&&L.length&&(N+=f.value.types.length),(f.value.sizeMin!==void 0||f.value.sizeMax!==void 0)&&N++,N}),R=e.computed(()=>{const N=V.selectedCount.value;return N===0?"Select Media":`Select ${t.selectionMode==="multiple"?`${N} ${N===1?"Item":"Items"}`:"Item"}`}),M=e.computed(()=>{const N=V.selectedCount.value;return!!(N===0||t.selectionMode==="single"&&N>1||t.maxSelection&&N>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 C(N=!0){N?(l.value=!0,c.value=[],v.value=1,g.value=!0):k.value=!0;try{const L={collection:f.value.collection||t.collection,per_page:24};switch((s.value||f.value.search)&&(L.search=s.value||f.value.search||""),f.value.dateFrom&&(L.from_date=f.value.dateFrom),f.value.dateTo&&(L.to_date=f.value.dateTo),i.value){case"recent":await T.fetchMedia(v.value,L),N?c.value=T.items.map(te=>b(te)):c.value=[...c.value,...T.items.map(te=>b(te))],g.value=T.currentPage<T.totalPages;break;case"model":if(t.modelType&&t.modelId){const te=await T.fetchModelMedia(t.modelType,t.modelId,L.collection,L.search);c.value=te?te.map(ne=>b(ne)):[],g.value=!1}break;case"library":await T.fetchMedia(v.value,L),N?c.value=T.items.map(te=>b(te)):c.value=[...c.value,...T.items.map(te=>b(te))],g.value=T.currentPage<T.totalPages;break}}catch{}finally{l.value=!1,k.value=!1}}async function P(N){if(!g.value||k.value){N!=null&&N.target&&N.target.complete();return}v.value++,await C(!1),N!=null&&N.target&&(N.target.complete(),g.value||(N.target.disabled=!0))}function S(N){return N==="recent"||N==="model"||N==="library"}function D(N){i.value=N,C()}function I(N){typeof N=="string"&&S(N)&&D(N)}async function j(N){t.selectionMode==="single"?(V.clear(),V.select(N.uuid)):(V.toggle(N.uuid),t.maxSelection&&V.selectedCount.value>t.maxSelection&&(V.deselect(N.uuid),await(await U.toastController.create({message:`Maximum ${t.maxSelection} items can be selected`,duration:2e3,color:"warning"})).present()))}function O(){a("confirm",V.selectedItems.value)}function F(){a("close")}function B(N){}const w=e.ref(null),$=e.ref(!1);function z(N){w.value=N,$.value=!0}function W(N){const L=c.value.findIndex(ne=>ne.uuid===N.uuid);L!==-1&&(c.value[L]=N);const te={};N.alt_text!==void 0&&(te.alt_text=N.alt_text),N.caption!==void 0&&(te.caption=N.caption),N.custom_properties!==void 0&&(te.custom_properties=N.custom_properties),T.updateMedia(N.uuid,te)}function Q(){C()}function ye(){f.value={},s.value="",C()}const we=Pp(()=>{C(!0)},300);e.watch(s,()=>{t.isOpen&&we()});async function ie(N){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 T.deleteMedia(N),await C()}}]})).present()}catch{}}return e.watch(()=>t.isOpen,N=>{N&&C()}),e.onMounted(()=>{t.selectedItems.length>0&&t.selectedItems.forEach(N=>V.select(N))}),(N,L)=>{const te=e.resolveComponent("AdminMediaGrid"),ne=e.resolveComponent("AdminMediaListItem");return e.openBlock(),e.createBlock(e.unref(U.IonModal),{"is-open":N.isOpen,onDidDismiss:F,"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:F},{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",jp,[e.createVNode(e.unref(U.IonSegment),{value:i.value,onIonChange:L[0]||(L[0]=re=>I(re.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(()=>[...L[15]||(L[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(()=>[...L[16]||(L[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(()=>[...L[17]||(L[17]=[e.createTextVNode("Library",-1)])]),_:1})]),_:1})]),_:1},8,["value"]),e.createVNode(e.unref(U.IonButton),{fill:"clear",size:"small",onClick:L[1]||(L[1]=re=>m.value=!m.value),class:"relative"},{"icon-only":e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{name:"filter-outline"})]),default:e.withCtx(()=>[_.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(_.value),1)]),_:1})):e.createCommentVNode("",!0)]),_:1})])]),_:1})]),_:1}),e.createVNode(e.unref(U.IonContent),null,{default:e.withCtx(()=>[e.createElementVNode("div",Wp,[m.value?(e.openBlock(),e.createElementBlock("div",Zp,[e.createElementVNode("div",Hp,[e.createElementVNode("div",null,[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...L[18]||(L[18]=[e.createTextVNode("Collection",-1)])]),_:1}),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":L[2]||(L[2]=re=>f.value.collection=re),class:"w-full p-2 border rounded"},[L[19]||(L[19]=e.createElementVNode("option",{value:""},"All Collections",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,re=>(e.openBlock(),e.createElementBlock("option",{key:re,value:re},e.toDisplayString(re),9,Xp))),128))],512),[[e.vModelSelect,f.value.collection]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...L[20]||(L[20]=[e.createTextVNode("From Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":L[3]||(L[3]=re=>f.value.dateFrom=re),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,f.value.dateFrom]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...L[21]||(L[21]=[e.createTextVNode("To Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":L[4]||(L[4]=re=>f.value.dateTo=re),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,f.value.dateTo]])])]),e.createElementVNode("div",Gp,[e.createVNode(e.unref(U.IonButton),{size:"small",onClick:Q},{default:e.withCtx(()=>[...L[22]||(L[22]=[e.createTextVNode("Apply",-1)])]),_:1}),e.createVNode(e.unref(U.IonButton),{size:"small",fill:"clear",onClick:ye},{default:e.withCtx(()=>[...L[23]||(L[23]=[e.createTextVNode("Clear",-1)])]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(e.unref(U.IonSearchbar),{modelValue:s.value,"onUpdate:modelValue":L[5]||(L[5]=re=>s.value=re),placeholder:"Search media...",debounce:300,class:"mb-4"},null,8,["modelValue"]),e.createElementVNode("div",Jp,[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:L[6]||(L[6]=re=>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:L[7]||(L[7]=re=>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",Yp,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"})])):h.value.length===0?(e.openBlock(),e.createElementBlock("div",qp,[e.createVNode(e.unref(U.IonIcon),{name:"images-outline",class:"text-6xl text-theme-secondary mb-4"}),L[24]||(L[24]=e.createElementVNode("h3",{class:"text-lg font-medium text-theme mb-2"}," No Media Found ",-1)),e.createElementVNode("p",Kp,e.toDisplayString(s.value?"Try adjusting your search":"No media items available"),1)])):r.value==="grid"?(e.openBlock(),e.createBlock(te,{key:3,"media-items":h.value,"selected-items":e.unref(V).selectedItems.value,"is-loading":!1,"selection-mode":!0,columns:{mobile:2,sm:3,md:4,lg:5,xl:6},onToggleSelect:j,onPreview:B,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(h.value,(re,he)=>(e.openBlock(),e.createBlock(ne,{key:re.uuid,media:re,selected:e.unref(V).isSelected(re.uuid),"selection-mode":!0,index:he,onToggleSelect:j,onPreview:B,onEdit:z,onDelete:ie},null,8,["media","selected","index"]))),128))]),_:1})),!l.value&&h.value.length>0&&i.value!=="model"?(e.openBlock(),e.createBlock(e.unref(U.IonInfiniteScroll),{key:5,threshold:"100px",onIonInfinite:L[8]||(L[8]=re=>P(re))},{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":$.value,onDidDismiss:L[14]||(L[14]=re=>$.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:L[9]||(L[9]=re=>$.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(()=>[...L[25]||(L[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",Qp,[e.createElementVNode("div",ef,[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...L[26]||(L[26]=[e.createTextVNode("Caption",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":L[10]||(L[10]=re=>w.value.caption=re),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter caption..."},null,512),[[e.vModelText,w.value.caption]])]),e.createElementVNode("div",tf,[e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...L[27]||(L[27]=[e.createTextVNode("Alt Text",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":L[11]||(L[11]=re=>w.value.alt_text=re),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",nf,[e.createVNode(e.unref(U.IonButton),{onClick:L[12]||(L[12]=re=>W(w.value))},{default:e.withCtx(()=>[...L[28]||(L[28]=[e.createTextVNode("Save",-1)])]),_:1}),e.createVNode(e.unref(U.IonButton),{fill:"clear",onClick:L[13]||(L[13]=re=>$.value=!1)},{default:e.withCtx(()=>[...L[29]||(L[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",af,[e.createElementVNode("div",of,[e.unref(V).selectedCount.value>0?(e.openBlock(),e.createElementBlock("span",rf,[e.createTextVNode(e.toDisplayString(e.unref(V).selectedCount.value)+" selected ",1),t.maxSelection?(e.openBlock(),e.createElementBlock("span",sf," / "+e.toDisplayString(t.maxSelection)+" max ",1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("span",lf," Select "+e.toDisplayString(t.selectionMode==="multiple"?"items":"an item"),1))]),e.createElementVNode("div",cf,[e.createVNode(e.unref(U.IonButton),{fill:"clear",onClick:F},{default:e.withCtx(()=>[...L[30]||(L[30]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(U.IonButton),{disabled:M.value,onClick:O},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(R.value),1)]),_:1},8,["disabled"])])])]),_:1})]),_:1})]),_:1},8,["is-open"])}}}),uf=Te(df,[["__scopeId","data-v-9a8c0954"]]),mf={key:1,class:"flex flex-col items-center justify-center py-16"},pf=["draggable","onDragstart","onDragover","onDrop"],ff={key:0,class:"absolute top-2 left-2 z-20"},hf=["checked","onChange"],vf={key:2,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-move"},gf=["data-media-id"],yf={key:0,class:"w-full h-full flex items-center justify-center"},bf=["src","alt","onError","onLoad"],wf={key:2,class:"w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-700"},kf={class:"text-center"},_f={class:"text-4xl text-gray-400 mb-2"},Ef={class:"text-sm font-medium text-gray-500"},xf={class:"absolute inset-0 bg-black/70 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2"},Cf=["onClick"],Sf=["onClick"],Vf=["onClick"],Nf={class:"p-3"},Tf={class:"text-sm font-medium truncate mb-1"},Mf={class:"text-xs text-gray-600 dark:text-gray-400"},Bf={key:0},Ff={key:0,class:"text-xs text-gray-500 dark:text-gray-500 mt-1 truncate"},If=e.defineComponent({__name:"MediaGrid",props:{mediaItems:{default:()=>[]},selectedItems:{default:()=>[]},isLoading:{type:Boolean,default:!1},selectionMode:{type:Boolean,default:!1},reorderable:{type:Boolean,default:!1},showEditButton:{type:Boolean,default:!1},columns:{default:()=>({mobile:2,sm:3,md:4,lg:5,xl:6})}},emits:["toggleSelect","preview","edit","delete","reorder","upload"],setup(o,{emit:n}){const t=o,a=n,i=e.ref(null),r=e.ref(null),s=e.ref(new Set),l=e.ref(null),c=M=>t.selectedItems.some(x=>x.uuid===M.uuid),d=e.computed(()=>{const M=t.columns,x=["grid","gap-4"];switch(M.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(M.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(M.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(M.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(M.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(M,x,C){t.reorderable&&(i.value=x,M.dataTransfer&&(M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("text/html","")))}function m(M,x){t.reorderable&&(M.preventDefault(),r.value=x)}function f(){r.value=null}function p(M,x){if(!t.reorderable||!i.value)return;M.preventDefault();const C=[...t.mediaItems],P=C.findIndex(S=>{var D;return S.uuid===((D=i.value)==null?void 0:D.uuid)});if(P!==-1&&P!==x&&i.value){const[S]=C.splice(P,1);C.splice(x,0,S),a("reorder",C)}i.value=null,r.value=null}function v(M){return M<1024?M+" B":M<1024*1024?(M/1024).toFixed(1)+" KB":(M/(1024*1024)).toFixed(1)+" MB"}function g(M){var C;return M.thumbnail_url||((C=M.conversion_urls)==null?void 0:C.thumb)||M.original_url||M.url||""}function k(M){var P,S,D;const x=((P=M.mime_type)==null?void 0:P.startsWith("image/"))||!1,C=!!(M.thumbnail_url||(S=M.conversion_urls)!=null&&S.thumb||(D=M.conversion_urls)!=null&&D.preview||M.original_url||M.url);return x&&C}function T(M){var x;return((x=M.split(".").pop())==null?void 0:x.toUpperCase())||""}function V(M){var C;const x=((C=M.mime_type)==null?void 0:C.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(M=>{M.forEach(x=>{var C;if(x.isIntersecting){const P=x.target.getAttribute("data-media-id");P&&(s.value.add(P),(C=l.value)==null||C.unobserve(x.target))}})},{rootMargin:"50px"}))}),e.onUnmounted(()=>{l.value&&l.value.disconnect()});function b(M){return!0}function h(){l.value&&e.nextTick(()=>{document.querySelectorAll("[data-media-id]").forEach(x=>{var P;const C=x.getAttribute("data-media-id");C&&!s.value.has(C)&&((P=l.value)==null||P.observe(x))})})}e.watch(()=>t.mediaItems,()=>{s.value.clear(),h()},{immediate:!0,deep:!0});function _(M,x){const C=M.target;delete C.dataset.fallbackIndex}function R(M,x){const C=M.target,P=C.closest("[data-media-id]"),S=[x.original_url,x.url,x.thumbnail_url,"preview_url"in x?x.preview_url:void 0].filter(D=>D&&D.trim()!==""&&D!==C.src);if(S.length>0&&C.dataset.fallbackIndex){const D=parseInt(C.dataset.fallbackIndex);if(D<S.length){C.dataset.fallbackIndex=(D+1).toString(),C.src=S[D]||"";return}}else if(S.length>0){C.dataset.fallbackIndex="1",C.src=S[0]||"";return}if(C.style.display="none",P&&!P.querySelector(".media-fallback-icon")){const I=document.createElement("div");I.className="media-fallback-icon w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-800",I.innerHTML=`
2
- <div class="text-center">
3
- <div class="text-4xl text-gray-400 mb-2">${V(x)}</div>
4
- <p class="text-sm font-medium text-gray-500">${T(x.file_name)}</p>
5
- </div>
6
- `,P.appendChild(I)}}return(M,x)=>M.isLoading?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(d.value)},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(12,C=>e.createElementVNode("div",{key:`skeleton-${C}`,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)):!M.mediaItems||!M.mediaItems.length?(e.openBlock(),e.createElementBlock("div",mf,[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]=C=>a("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(M.mediaItems,(C,P)=>(e.openBlock(),e.createElementBlock("div",{key:C.uuid,class:e.normalizeClass(["relative group",{"ring-2 ring-blue-500 ring-offset-2":r.value===P}]),draggable:M.reorderable,onDragstart:S=>u(S,C),onDragover:S=>m(S,P),onDragleave:f,onDrop:S=>p(S,P)},[M.selectionMode?(e.openBlock(),e.createElementBlock("div",ff,[e.createElementVNode("input",{type:"checkbox",checked:c(C),onChange:S=>a("toggleSelect",C),class:"w-5 h-5 bg-white dark:bg-gray-800 rounded cursor-pointer"},null,40,hf)])):e.createCommentVNode("",!0),M.$slots.badge?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["absolute top-2 z-20",M.selectionMode?"left-10":"left-2"])},[e.renderSlot(M.$slots,"badge",{media:C,index:P},void 0,!0)],2)):e.createCommentVNode("",!0),M.reorderable?(e.openBlock(),e.createElementBlock("div",vf,[...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(C)}])},[e.createElementVNode("div",{class:"relative aspect-square bg-gray-100 dark:bg-gray-700 overflow-hidden","data-media-id":C.uuid},[k(C)&&!b(C.uuid)?(e.openBlock(),e.createElementBlock("div",yf,[...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(C)&&b(C.uuid)?(e.openBlock(),e.createElementBlock("img",{key:1,src:g(C),alt:C.alt_text||C.file_name,class:"w-full h-full object-cover",loading:"lazy",onError:S=>R(S,C),onLoad:S=>_(S)},null,40,bf)):(e.openBlock(),e.createElementBlock("div",wf,[e.createElementVNode("div",kf,[e.createElementVNode("div",_f,e.toDisplayString(V(C)),1),e.createElementVNode("p",Ef,e.toDisplayString(T(C.file_name)),1)])])),e.createElementVNode("div",xf,[e.createElementVNode("button",{onClick:S=>a("preview",C),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,Cf),M.showEditButton&&k(C)?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:S=>a("edit",C),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,Sf)):e.createCommentVNode("",!0),e.createElementVNode("button",{onClick:S=>a("delete",C.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,Vf)])],8,gf),e.createElementVNode("div",Nf,[e.createElementVNode("h4",Tf,e.toDisplayString(C.file_name),1),e.createElementVNode("p",Mf,[e.createTextVNode(e.toDisplayString(v(C.size))+" ",1),C.width&&C.height?(e.openBlock(),e.createElementBlock("span",Bf," • "+e.toDisplayString(C.width)+"x"+e.toDisplayString(C.height),1)):e.createCommentVNode("",!0)]),C.caption?(e.openBlock(),e.createElementBlock("p",Ff,e.toDisplayString(C.caption),1)):e.createCommentVNode("",!0)])],2)],42,pf))),128))],2))}}),$f=Te(If,[["__scopeId","data-v-f0c343b7"]]),Rf={class:"model-media-manager"},Df=["accept","multiple"],Af={class:"flex items-center justify-between mb-4"},Lf={key:0,class:"text-lg font-medium"},Uf={class:"flex gap-2"},Of={key:0,class:"flex items-center justify-center py-8"},Pf={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"},zf={class:"text-gray-600 dark:text-gray-400"},jf={class:"flex gap-2 mt-4"},Wf={key:0,class:"px-2 py-1 bg-blue-500 text-white text-xs font-medium rounded"},Zf=e.defineComponent({__name:"ModelMediaManager",props:{mediableType:{},mediableId:{},collection:{},mode:{default:"user"},initialMedia:{},maxFiles:{},acceptedMimeTypes:{},maxFileSize:{},allowReorder:{type:Boolean,default:!0},allowUpload:{type:Boolean,default:!0},allowBrowse:{type:Boolean,default:!0},allowDetach:{type:Boolean,default:!0},allowEdit:{type:Boolean,default:!1},editMode:{default:"replace"},showPrimaryBadge:{type:Boolean,default:!0},emptyText:{default:"No media attached"},title:{default:"Media"}},emits:["loading","update:media","error","attach","detach","reorder","upload-progress","edit-complete"],setup(o,{emit:n}){const t=o,a=n,i=Rt(),r=e.ref(!1),s=e.ref(!1),l=e.ref(!1),c=e.ref(!1),d=e.ref(null),u=e.ref(0),m=e.ref(null),f=e.ref(void 0),p=e.ref(null),v=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($=>$.uuid)),T=e.computed(()=>{if(!(!t.acceptedMimeTypes||t.acceptedMimeTypes.length===0))return t.acceptedMimeTypes.join(",")});function V(){ta({isAdmin:t.mode==="admin"})}async function b($){await(await U.toastController.create({message:$,duration:3e3,color:"danger",position:"bottom"})).present()}async function h(){if(!s.value)if(s.value=!0,V(),i.setModelContext(t.mediableType,t.mediableId,t.collection),t.initialMedia&&t.initialMedia.length>0)i.modelMedia=[...t.initialMedia],a("update:media",i.modelMedia);else{r.value=!0,a("loading",!0);try{await i.fetchModelMedia(t.mediableType,t.mediableId,t.collection),a("update:media",i.modelMedia)}catch($){const z=$ instanceof Error?$.message:"Failed to fetch media";a("error",{operation:"fetch",message:z,details:$})}finally{r.value=!1,a("loading",!1)}}}e.watch(()=>i.modelMedia,$=>{s.value&&a("update:media",$)},{deep:!0}),e.watch(()=>[t.mediableType,t.mediableId,t.collection],()=>{s.value=!1,h()}),e.watch(()=>t.mode,()=>{V()}),e.onMounted(()=>{h()}),e.onUnmounted(()=>{i.clearModelContext()});function _(){return i.modelMedia.length>0}function R(){return t.maxFiles===void 0?!1:i.modelMedia.length>=t.maxFiles}function M($){var W,Q,ye;if(!((W=$.mime_type)!=null&&W.startsWith("image/")))return null;const z=$.original_url||$.url||((Q=$.conversion_urls)==null?void 0:Q.preview)||((ye=$.conversion_urls)==null?void 0:ye.thumb)||$.thumbnail_url;return z&&z.trim()!==""?z:null}function x(){l.value=!0}function C(){var $;($=v.value)==null||$.click()}function P(){l.value=!1}async function S($){if(!t.allowEdit)return;const z=M($);if(z){d.value=$,u.value++;try{const W=i.getHttpClient(),Q=i.getApiUrl(""),ye=await W(`${Q.replace(/\/$/,"")}/editor/${$.uuid}/edit`);f.value=ye.editable_source_url||z,m.value=ye.editor_state??null}catch{f.value=z,m.value=null}c.value=!0}}function D(){c.value=!1,d.value=null,f.value=void 0,m.value=null}async function I($){if(!d.value)throw new Error("No media selected for editing");const z=d.value,W=t.editMode==="variant";try{p.value=null;const Q=await i.saveEditedImage(z.uuid,$,{asVariant:W,name:z.file_name});W||await i.detachMedia(t.mediableType,t.mediableId,z.uuid,t.collection),await i.attachMedia(t.mediableType,t.mediableId,[Q.uuid],t.collection),a("edit-complete",{originalMedia:z,editedMedia:Q,mode:t.editMode}),c.value=!1,d.value=null}catch(Q){const ye=Q instanceof Error?Q.message:"Failed to save edited image";throw p.value=ye,await b(ye),Q}}function j($){if(p.value===$.message){p.value=null;return}b($.message)}async function O($){const z=$.target,W=z.files;if(!(!W||W.length===0)){for(let Q=0;Q<W.length;Q++){const ye=W[Q];if(g.value!==void 0&&g.value<=0)break;if(t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0&&!t.acceptedMimeTypes.includes(ye.type)){a("error",{operation:"upload",message:`File type ${ye.type} is not accepted`,details:{file:ye.name}});continue}if(t.maxFileSize!==void 0&&ye.size>t.maxFileSize){a("error",{operation:"upload",message:`File size exceeds limit of ${t.maxFileSize} bytes`,details:{file:ye.name,size:ye.size}});continue}a("upload-progress",{status:"uploading",progress:0,file:ye});try{const we=await i.uploadFile(ye,{collection:t.collection});we!=null&&we.uuid&&(await i.attachMedia(t.mediableType,t.mediableId,[we.uuid],t.collection),a("upload-progress",{status:"complete",progress:100,file:ye}),a("attach",[we]))}catch(we){const ie=we instanceof Error?we.message:"Upload failed";a("error",{operation:"upload",message:ie,details:we}),a("upload-progress",{status:"error",progress:0,file:ye,error:ie})}}z.value=""}}async function F($){const z=$.map(W=>W.uuid);try{await i.reorderMedia(t.mediableType,t.mediableId,z,t.collection),a("reorder",i.modelMedia)}catch(W){const Q=W instanceof Error?W.message:"Failed to reorder media";a("error",{operation:"reorder",message:Q,details:W}),await b(Q)}}async function B($){const z=i.modelMedia.find(W=>W.uuid===$);try{await i.detachMedia(t.mediableType,t.mediableId,$,t.collection),z&&a("detach",z)}catch(W){const Q=W instanceof Error?W.message:"Failed to detach media";a("error",{operation:"detach",message:Q,details:W}),await b(Q)}}async function w($){l.value=!1;const z=$.map(ye=>ye.uuid),W=new Set(k.value);let Q=Array.from(new Set(z)).filter(ye=>!W.has(ye));if(g.value!==void 0&&Q.length>g.value&&(Q=Q.slice(0,g.value)),Q.length!==0)try{await i.attachMedia(t.mediableType,t.mediableId,Q,t.collection);const ye=i.modelMedia.filter(we=>Q.includes(we.uuid));a("attach",ye)}catch(ye){const we=ye instanceof Error?ye.message:"Failed to attach media";a("error",{operation:"attach",message:we,details:ye})}}return($,z)=>(e.openBlock(),e.createElementBlock("div",Rf,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:v,type:"file",accept:T.value,multiple:g.value===void 0||g.value>1,class:"hidden","data-testid":"upload-input",onChange:O},null,40,Df),e.createElementVNode("div",Af,[$.title?(e.openBlock(),e.createElementBlock("h3",Lf,e.toDisplayString($.title),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Uf,[$.allowBrowse?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:0,fill:"outline",size:"small",disabled:R(),"data-testid":"browse-button",onClick:x},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"start",icon:e.unref(Yi)},null,8,["icon"]),z[1]||(z[1]=e.createTextVNode(" Browse ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0),$.allowUpload?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:1,fill:"solid",size:"small",disabled:R(),"data-testid":"upload-button",onClick:C},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"start",icon:e.unref(cl)},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",Of,[e.createVNode(e.unref(U.IonSpinner),{"data-testid":"spinner"})])):_()?(e.openBlock(),e.createBlock($f,{key:2,"media-items":e.unref(i).modelMedia,reorderable:!!$.allowReorder,"is-loading":r.value||e.unref(i).isLoadingModelMedia,"show-edit-button":!!$.allowEdit,"selection-mode":!1,onReorder:F,onDelete:B,onEdit:S},e.createSlots({_:2},[$.showPrimaryBadge?{name:"badge",fn:e.withCtx(({index:W})=>[W===0?(e.openBlock(),e.createElementBlock("div",Wf," Primary ")):e.createCommentVNode("",!0)]),key:"0"}:void 0]),1032,["media-items","reorderable","is-loading","show-edit-button"])):(e.openBlock(),e.createElementBlock("div",Pf,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Yi),class:"w-12 h-12 text-gray-400 mb-4"},null,8,["icon"]),e.createElementVNode("p",zf,e.toDisplayString($.emptyText),1),e.createElementVNode("div",jf,[$.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(Yi)},null,8,["icon"]),z[3]||(z[3]=e.createTextVNode(" Browse Library ",-1))]),_:1})):e.createCommentVNode("",!0),$.allowUpload?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:1,fill:"solid",size:"small","data-testid":"upload-button-empty",onClick:C},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{slot:"start",icon:e.unref(cl)},null,8,["icon"]),z[4]||(z[4]=e.createTextVNode(" Upload Files ",-1))]),_:1})):e.createCommentVNode("",!0)])])),e.createVNode(uf,e.mergeProps({"is-open":l.value,"selected-items":k.value,collection:$.collection},g.value!==null&&g.value!==void 0?{maxSelection:g.value}:{},{onConfirm:w,onClose:P}),null,16,["is-open","selected-items","collection"]),e.createVNode(gc,{modelValue:c.value,"onUpdate:modelValue":z[0]||(z[0]=W=>c.value=W),"initial-image":f.value,"initial-state":m.value,"session-key":u.value,onSave:I,onCancel:D,onError:j},null,8,["modelValue","initial-image","initial-state","session-key"])]))}}),Hf=Te(Zf,[["__scopeId","data-v-f68e70ec"]]),Xf={class:"existing-media-selector","data-testid":"existing-media-selector"},Gf={key:0,class:"existing-media-selector__status","data-testid":"existing-media-loading"},Jf=["data-testid"],Yf={class:"existing-media-selector__section-header"},qf={class:"existing-media-selector__section-title"},Kf=["data-testid","aria-label","onClick"],Qf={class:"existing-media-selector__grid"},eh=["data-testid","aria-label","aria-pressed","onClick"],th=["src","alt"],nh={key:0,class:"existing-media-selector__selected-badge"},ah={key:1,class:"existing-media-selector__caption"},oh={key:0,class:"existing-media-selector__section existing-media-selector__section--albums","data-testid":"existing-media-albums"},ih={class:"existing-media-selector__section-header"},rh={class:"existing-media-selector__section-title"},sh={class:"existing-media-selector__albums"},lh=["data-testid","aria-label","aria-pressed","onClick"],ch={class:"existing-media-selector__album-name"},dh={key:0,class:"existing-media-selector__album-count"},uh={class:"existing-media-selector__album-panel","data-testid":"existing-media-active-album"},mh={class:"existing-media-selector__section-header"},ph={class:"existing-media-selector__section-subtitle"},fh={key:0,class:"existing-media-selector__section-description"},hh={key:0,class:"existing-media-selector__status","data-testid":"existing-media-active-album-loading"},vh={key:1,class:"existing-media-selector__grid"},gh=["data-testid","aria-label","aria-pressed","onClick"],yh=["src","alt"],bh={key:0,class:"existing-media-selector__selected-badge"},wh={key:1,class:"existing-media-selector__caption"},kh={key:2,class:"existing-media-selector__empty","data-testid":"existing-media-active-album-empty"},_h={key:1,class:"existing-media-selector__empty","data-testid":"existing-media-empty"},Eh=e.defineComponent({__name:"ExistingMediaSelector",props:{sections:{default:()=>[]},albums:{default:()=>[]},selectedId:{default:null},activeAlbumId:{default:null},activeAlbumItems:{default:()=>[]},activeAlbumTitle:{},activeAlbumDescription:{},isLoading:{type:Boolean,default:!1},isAlbumLoading:{type:Boolean,default:!1},emptyMessage:{default:"No media available yet."},albumBrowseTitle:{default:"Browse Your Albums"},albumSectionTitle:{default:"Selected Album"},activeAlbumEmptyMessage:{default:"No media available in this album yet."}},emits:["select","update:activeAlbumId"],setup(o,{emit:n}){const t=o,a=n,i=e.reactive({}),r=e.computed(()=>t.sections.filter(h=>h.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 h=t.albums.find(_=>_.id===t.activeAlbumId);return h!=null&&h.name.trim().length?h.name.trim():t.albumSectionTitle}),d=e.computed(()=>{if(typeof t.activeAlbumDescription=="string"&&t.activeAlbumDescription.trim().length>0)return t.activeAlbumDescription.trim();const h=t.albums.find(_=>_.id===t.activeAlbumId);return typeof(h==null?void 0:h.description)=="string"&&h.description.trim().length>0?h.description.trim():""});function u(h){const _=h.initialVisibleCount??6;return _>0?_:6}function m(h){return i[h]===!0}function f(h){i[h]=!m(h)}function p(h){return m(h.id)?h.items:h.items.slice(0,u(h))}function v(h){return h.items.length>u(h)}function g(h){a("select",h)}function k(h){a("update:activeAlbumId",h)}function T(h){var R;const _=(R=h.description)==null?void 0:R.trim();return _&&_.length>0?`Select ${_}`:"Select existing media"}function V(h,_){var M;const R=(M=_.description)==null?void 0:M.trim();return typeof _.alt=="string"&&_.alt.trim().length>0?_.alt.trim():R&&R.length>0?R:h.title}function b(h){const _=typeof h.mediaCount=="number"?` with ${h.mediaCount} item${h.mediaCount===1?"":"s"}`:"";return`Browse album ${h.name}${_}`}return(h,_)=>(e.openBlock(),e.createElementBlock("div",Xf,[h.isLoading?(e.openBlock(),e.createElementBlock("div",Gf," Loading your media... ")):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,R=>(e.openBlock(),e.createElementBlock("section",{key:R.id,class:"existing-media-selector__section","data-testid":`existing-media-section-${R.id}`},[e.createElementVNode("div",Yf,[e.createElementVNode("h3",qf,e.toDisplayString(R.title),1),v(R)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"existing-media-selector__toggle","data-testid":`existing-media-toggle-${R.id}`,"aria-label":m(R.id)?`Show fewer items from ${R.title}`:`Show more items from ${R.title}`,onClick:M=>f(R.id)},e.toDisplayString(m(R.id)?"See less":"See more"),9,Kf)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Qf,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p(R),M=>(e.openBlock(),e.createElementBlock("button",{key:M.id,type:"button",class:e.normalizeClass(["existing-media-selector__item",{"is-selected":h.selectedId===M.id}]),"data-testid":`existing-media-item-${R.id}-${M.id}`,"aria-label":T(M),"aria-pressed":h.selectedId===M.id?"true":"false",onClick:x=>g(M)},[e.createElementVNode("img",{class:"existing-media-selector__image",src:M.previewUrl,alt:V(R,M)},null,8,th),h.selectedId===M.id?(e.openBlock(),e.createElementBlock("div",nh," Selected ")):e.createCommentVNode("",!0),M.description?(e.openBlock(),e.createElementBlock("div",ah,e.toDisplayString(M.description),1)):e.createCommentVNode("",!0)],10,eh))),128))])],8,Jf))),128)),s.value?(e.openBlock(),e.createElementBlock("section",oh,[e.createElementVNode("div",ih,[e.createElementVNode("h3",rh,e.toDisplayString(h.albumBrowseTitle),1)]),e.createElementVNode("div",sh,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.albums,R=>(e.openBlock(),e.createElementBlock("button",{key:R.id,type:"button",class:e.normalizeClass(["existing-media-selector__album",{"is-active":h.activeAlbumId===R.id}]),"data-testid":`existing-media-album-${R.id}`,"aria-label":b(R),"aria-pressed":h.activeAlbumId===R.id?"true":"false",onClick:M=>k(R.id)},[e.createElementVNode("span",ch,e.toDisplayString(R.name),1),typeof R.mediaCount=="number"?(e.openBlock(),e.createElementBlock("span",dh,e.toDisplayString(R.mediaCount),1)):e.createCommentVNode("",!0)],10,lh))),128))]),e.createElementVNode("div",uh,[e.createElementVNode("div",mh,[e.createElementVNode("div",null,[e.createElementVNode("h4",ph,e.toDisplayString(c.value),1),d.value?(e.openBlock(),e.createElementBlock("p",fh,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0)])]),h.isAlbumLoading?(e.openBlock(),e.createElementBlock("div",hh," Loading album... ")):h.activeAlbumItems.length>0?(e.openBlock(),e.createElementBlock("div",vh,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.activeAlbumItems,R=>(e.openBlock(),e.createElementBlock("button",{key:R.id,type:"button",class:e.normalizeClass(["existing-media-selector__item",{"is-selected":h.selectedId===R.id}]),"data-testid":`existing-media-item-album-${R.id}`,"aria-label":T(R),"aria-pressed":h.selectedId===R.id?"true":"false",onClick:M=>g(R)},[e.createElementVNode("img",{class:"existing-media-selector__image",src:R.previewUrl,alt:R.alt||R.description||c.value},null,8,yh),h.selectedId===R.id?(e.openBlock(),e.createElementBlock("div",bh," Selected ")):e.createCommentVNode("",!0),R.description?(e.openBlock(),e.createElementBlock("div",wh,e.toDisplayString(R.description),1)):e.createCommentVNode("",!0)],10,gh))),128))])):(e.openBlock(),e.createElementBlock("div",kh,[e.renderSlot(h.$slots,"active-album-empty",{},()=>[e.createTextVNode(e.toDisplayString(h.activeAlbumEmptyMessage),1)],!0)]))])])):e.createCommentVNode("",!0),l.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",_h,[e.renderSlot(h.$slots,"empty",{},()=>[e.createTextVNode(e.toDisplayString(h.emptyMessage),1)],!0)]))],64))]))}}),xh=Te(Eh,[["__scopeId","data-v-904abb6b"]]);function uo(o,n,t,a){if(t<=0||a<=0)return!1;try{return n.drawImage(o,0,0,t,a),!0}catch(i){return i instanceof DOMException&&i.name==="InvalidStateError",!1}}function Ch(o,n){return o?{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 Sh=["src","crossorigin"],Vh={class:"preview-controls"},Nh=["aria-label"],Th={class:"time-display"},Mh={class:"current-time"},Bh={class:"total-time"},Fh={key:0,class:"fps-display"},Ih={key:0,class:"loading-overlay"},$h={key:1,class:"error-overlay"},Rh=.1,Dh=e.defineComponent({__name:"VideoPreview",props:{source:{},filters:{},playhead:{},fallbackDuration:{default:0},isPlaying:{type:Boolean,default:!1},showFps:{type:Boolean,default:!1},targetFps:{default:30},fitMode:{default:"contain"},active:{type:Boolean,default:!0}},emits:["frame-update","play-pause","duration-change","error"],setup(o,{expose:n,emit:t}){const{ColorMatrixFilter:a,BlurFilter:i}=lt,r=o,s=t,l=e.ref(),c=e.ref(),d=e.ref(),u=e.ref(!0),m=e.ref(),f=e.ref(0),p=e.ref(0),v=e.ref(!1);let g,k,T=null,V=null,b=null,h=[],_="",R=null,M=0,x=0,C=0,P=0,S=!1,D=0,I=0,j,O=null,F=!1,B=!1,w=0;const $=e.computed(()=>r.source&&typeof r.source=="string"?r.source:""),z=e.computed(()=>{const ve=$.value;if(!(!ve||ve.startsWith("blob:")))return"anonymous"}),W=e.computed(()=>Ch(v.value,r.fitMode));function Q(ve){return typeof ve=="number"&&Number.isFinite(ve)&&ve>=0?ve:Number.isFinite(r.fallbackDuration)&&r.fallbackDuration>0?r.fallbackDuration:0}function ye(ve){const Ee=Q(ve.duration);return Ee<=0?!1:ve.currentTime>=Math.max(0,Ee-Rh)}async function we(){var ve,Ee;if(!B&&c.value&&!g&&!(!d.value||d.value.readyState<3)){B=!0;try{m.value=void 0;let Ne=((ve=l.value)==null?void 0:ve.clientWidth)||800,je=((Ee=l.value)==null?void 0:Ee.clientHeight)||450;if((Ne<=0||je<=0)&&(Ne=d.value.videoWidth||800,je=d.value.videoHeight||450),g=new lt.Application,await g.init({width:Ne,height:je,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&&we()},100),g&&(g.destroy(!0),g=null);return}if(M=d.value.videoWidth,x=d.value.videoHeight,V=document.createElement("canvas"),V.width=M,V.height=x,b=V.getContext("2d"),!b)throw new Error("Unable to create 2D canvas context for video preview");const G=uo(d.value,b,M,x),q=lt.Texture.from(V);T=q.source,k=new lt.Sprite(q),k.visible=!0,k.alpha=1,bt(),g.stage.addChild(k),g.renderer&&!g.renderer.destroyed&&g.render()}te(),r.targetFps<60?ie():g.ticker.add(N),v.value=!0,"ResizeObserver"in window&&(R=new ResizeObserver(G=>{S||(S=!0,requestAnimationFrame(()=>{S=!1;const q=G[G.length-1],{width:A,height:J}=q.contentRect;if(A<=0||J<=0)return;const ae=Math.round(A),se=Math.round(J);ae===C&&se===P||(C=ae,P=se,bt())}))}),R.observe(l.value)),r.filters&&r.filters.length>0&&te(),r.showFps&&ut(),w=0}catch{if(ot(),!F&&!!d.value&&d.value.readyState>=2&&d.value.videoWidth>0&&d.value.videoHeight>0&&w<2){w+=1,window.setTimeout(()=>{F||we()},w*150);return}m.value="Failed to initialize video preview",s("error",m.value)}finally{B=!1}}}function ie(){const ve=1e3/r.targetFps;let Ee=performance.now();function Ne(){if(F||!g)return;const je=performance.now(),G=je-Ee;G>=ve&&(N(),Ee=je-G%ve),O=requestAnimationFrame(Ne)}O=requestAnimationFrame(Ne)}function N(){if(!(!g||!k||F)&&r.active)try{b&&V&&T&&d.value&&(d.value.readyState>=2&&uo(d.value,b,V.width,V.height)&&T.update(),d.value.paused||s("frame-update",he())),r.showFps&&I++,g.renderer&&!g.renderer.destroyed&&g.render()}catch{F=!0}}function L(){for(const ve of h)try{ve.destroy()}catch{}h=[]}function te(){if(k){if(!r.filters||r.filters.length===0){k.filters=null,L();return}L(),r.filters.forEach(ve=>{const Ee=ne(ve);Ee&&h.push(Ee)}),k.filters=h.length>0?h:null,_=JSON.stringify(r.filters),g&&g.render()}}function ne(ve){const Ee=ve.filterId,Ne=ve.params||{},je=le.getFilter(Ee);if(je&&!le.isFilterCompatibleWithMedia(Ee,"video"))return null;if(je&&je.createFilter)try{return je.createFilter(Ne)}catch{}const G=(q,A,J)=>Math.min(J,Math.max(A,q));switch(Ee){case"brightness":{const q=new a,A=G(typeof Ne.brightness=="number"?Ne.brightness:typeof Ne.value=="number"?Ne.value:1,0,5);return q.brightness(A,!0),q}case"contrast":{const q=new a,A=G(typeof Ne.contrast=="number"?Ne.contrast:typeof Ne.value=="number"?Ne.value:1,0,5);return q.contrast(A,!0),q}case"saturation":{const q=new a,A=G(typeof Ne.saturation=="number"?Ne.saturation:typeof Ne.value=="number"?Ne.value:1,0,5);return q.saturate(A,!0),q}case"hue":{const q=new a,A=G(typeof Ne.value=="number"?Ne.value:0,-180,180);return q.hue(A,!0),q}case"gaussian-blur":case"blur":{const q=G(typeof Ne.blur=="number"?Ne.blur:typeof Ne.value=="number"?Ne.value:2,0,10);return new i(q)}case"grayscale":{const q=new a;return q.desaturate(),q}case"sepia":case"color-matrix":{const q=new a;return q.sepia(!0),q}case"vignette":{const q=typeof Ne.value=="number"?Ne.value:.3;return re(G(q,0,1))}default:return null}}function re(ve){const Ee=`
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 lt.Filter(void 0,Ee,{strength:ve})}function he(){var Ee;return!g||!k?null:{dataUrl:g.canvas.toDataURL("image/jpeg",.8),timestamp:((Ee=d.value)==null?void 0:Ee.currentTime)||0,width:M||0,height:x||0}}function de(){var ve;f.value=Q((ve=d.value)==null?void 0:ve.duration),s("duration-change",f.value)}function me(){u.value=!1,m.value=void 0}function Ve(){u.value&&(u.value=!1),!v.value&&r.active?we():v.value}function ce(){var Ee,Ne,je;const ve=((Ee=d.value)==null?void 0:Ee.currentTime)||0;s("frame-update",{dataUrl:null,timestamp:ve,width:((Ne=d.value)==null?void 0:Ne.videoWidth)||0,height:((je=d.value)==null?void 0:je.videoHeight)||0})}function pe(){d.value&&(d.value.currentTime=0),s("play-pause")}function xe(ve){var Ne;const Ee=ve.target;if(Ee!=null&&Ee.error)switch(Ee.error.code){case Ee.error.MEDIA_ERR_ABORTED:m.value="Video playback aborted";break;case Ee.error.MEDIA_ERR_NETWORK:m.value="Network error loading video";break;case Ee.error.MEDIA_ERR_DECODE:m.value="Video format not supported";break;case Ee.error.MEDIA_ERR_SRC_NOT_SUPPORTED:m.value=`Video source not supported: ${(Ne=Ee.src)==null?void 0:Ne.substring(0,100)}`;break;default:m.value="Failed to load video"}else m.value="Failed to load video";s("error",m.value),u.value=!1}function Fe(ve){d.value&&(d.value.currentTime=Math.max(0,Math.min(ve,f.value)))}function ut(){j=window.setInterval(()=>{const ve=performance.now(),Ee=ve-D;p.value=Math.round(I*1e3/Ee),I=0,D=ve},1e3)}function tt(ve){if(!Number.isFinite(ve)||ve<0)return"00:00";const Ee=Math.floor(ve/60),Ne=Math.floor(ve%60);return`${Ee.toString().padStart(2,"0")}:${Ne.toString().padStart(2,"0")}`}function Et(){m.value=void 0,u.value=!0,w=0,ot(),d.value&&d.value.load()}function ot(){if(R&&(R.disconnect(),R=null),O&&(cancelAnimationFrame(O),O=null),g!=null&&g.ticker&&(g.ticker.stop(),g.ticker.remove(N)),g)try{g.destroy(!0,{children:!0,texture:!0})}catch{}c.value&&(c.value.innerHTML=""),L(),g=null,k=null,T=null,V=null,b=null,v.value=!1,S=!1,_=""}function at(){g&&(S||(S=!0,requestAnimationFrame(()=>{S=!1,bt()})))}function bt(){if(!g||!k||!M||!x||!l.value)return;const ve=Math.round(l.value.clientWidth),Ee=Math.round(l.value.clientHeight);if(ve<=0||Ee<=0)return;g.renderer.resize(ve,Ee);const Ne=g.screen.width/M,je=g.screen.height/x;let G=1;switch(r.fitMode){case"cover":G=Math.max(Ne,je);break;case"none":G=1;break;case"contain":default:G=Math.min(Ne,je);break}k.scale.set(G),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,()=>{v.value&&te()},{deep:!0}),e.watch(()=>r.active,async ve=>{if(ve&&!g&&d.value&&d.value.readyState>=2){await we();return}g&&(ve&&(await e.nextTick(),l.value&&l.value.getBoundingClientRect(),k&&b&&V&&T&&(d.value&&d.value.readyState>=2&&uo(d.value,b,V.width,V.height)&&T.update(),bt(),g.renderer&&!g.renderer.destroyed&&g.render())),r.targetFps>=60&&g.ticker&&(ve?g.ticker.start():g.ticker.stop()))}),e.watch($,ve=>{ve?(u.value=!0,m.value=void 0,e.nextTick(()=>{d.value&&d.value.load()})):(u.value=!1,m.value="No video source provided")},{immediate:!0});async function Vt(){if(d.value){m.value=void 0,ye(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{}}}m.value="Unable to start preview playback",s("error",m.value)}}e.watch(()=>r.isPlaying,ve=>{d.value&&(ve?Vt():d.value.pause())}),e.watch(()=>r.playhead,ve=>{d.value&&Math.abs(d.value.currentTime-ve)>.5&&Fe(ve)}),e.watch(()=>r.fitMode,()=>{bt()}),e.onMounted(()=>{F=!1,e.nextTick(()=>{l.value&&l.value.getBoundingClientRect(),d.value}),window.addEventListener("resize",at),D=performance.now(),e.nextTick(()=>{d.value&&d.value.readyState>=2&&!v.value?we():d.value&&d.value.src&&d.value.readyState===0&&d.value.load()})}),e.onUnmounted(()=>{if(F=!0,O&&(cancelAnimationFrame(O),O=null),window.removeEventListener("resize",at),R&&(R.disconnect(),R=null),j&&clearInterval(j),g&&g.ticker&&(g.ticker.stop(),g.ticker.remove(N)),g){try{g.destroy(!0,{children:!0,texture:!0})}catch{}g=null}h.forEach(ve=>{try{ve.destroy()}catch{}}),h=[],k=null,T=null,V=null,b=null,d.value&&(d.value.pause(),d.value.removeAttribute("src"),d.value.load())});async function vt(ve){if(!await st()||!d.value||!b||!V||!T)return null;const Ne=d.value,je=Number.isFinite(f.value)&&f.value>0?f.value:Number.isFinite(Ne.duration)&&Ne.duration>0?Ne.duration:0,G=Math.max(0,Math.min(ve,je));return await new Promise(A=>{let J=!1,ae=0;const se=()=>{J||(J=!0,Ne.removeEventListener("seeked",Ce),window.clearTimeout(ae),A())},Ce=()=>{se()},Ae=Number.isFinite(Ne.currentTime)?Ne.currentTime:0;if(Math.abs(Ae-G)<.016){requestAnimationFrame(()=>se());return}Ne.addEventListener("seeked",Ce),ae=window.setTimeout(()=>se(),700),Ne.currentTime=G}),uo(Ne,b,V.width,V.height)?(T.update(),g.render(),g.canvas):null}async function st(){if(!d.value)return!1;if(!g){if(!(d.value.readyState>=2))return!1;await we()}if(!g||!k||!b||!V||!T)return!1;if(r.filters&&r.filters.length>0){const ve=k.filters,Ee=Array.isArray(ve)?ve.length:0,je=JSON.stringify(r.filters)!==_;(Ee===0||Ee!==r.filters.length||je)&&te()}return await e.nextTick(),await new Promise(ve=>{requestAnimationFrame(()=>ve())}),!0}return n({captureFrameAt:vt,ensureReadyForCapture:st,duration:f,pixiCanvas:e.computed(()=>g?g.canvas:null),videoElement:e.computed(()=>d.value??null)}),(ve,Ee)=>(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:$.value,onLoadedmetadata:de,onLoadeddata:me,onCanplay:Ve,onTimeupdate:ce,onEnded:pe,onError:xe,style:e.normalizeStyle(W.value),crossorigin:z.value,preload:"auto",playsinline:"",controls:""},null,44,Sh),e.createElementVNode("div",Vh,[e.createElementVNode("button",{class:"play-button",onClick:Ee[0]||(Ee[0]=Ne=>ve.$emit("play-pause")),"aria-label":ve.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(U.IonIcon),{icon:ve.isPlaying?e.unref(kc):e.unref(_c)},null,8,["icon"])],8,Nh),e.createElementVNode("div",Th,[e.createElementVNode("span",Mh,e.toDisplayString(tt(ve.playhead)),1),Ee[1]||(Ee[1]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",Bh,e.toDisplayString(tt(f.value)),1)]),ve.showFps?(e.openBlock(),e.createElementBlock("div",Fh,e.toDisplayString(p.value)+" FPS ",1)):e.createCommentVNode("",!0)]),u.value?(e.openBlock(),e.createElementBlock("div",Ih,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"}),Ee[2]||(Ee[2]=e.createElementVNode("p",null,"Loading video...",-1))])):e.createCommentVNode("",!0),m.value?(e.openBlock(),e.createElementBlock("div",$h,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Gr)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(m.value),1),e.createElementVNode("button",{onClick:Et},"Retry")])):e.createCommentVNode("",!0)],512))}}),hr=Te(Dh,[["__scopeId","data-v-dd1744f4"]]);var qr=(o,n,t)=>{if(!n.has(o))throw TypeError("Cannot "+t)},Z=(o,n,t)=>(qr(o,n,"read from private field"),t?t.call(o):n.get(o)),ze=(o,n,t)=>{if(n.has(o))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(o):n.set(o,t)},ht=(o,n,t,a)=>(qr(o,n,"write to private field"),n.set(o,t),t),Ah=(o,n,t,a)=>({set _(i){ht(o,n,i)},get _(){return Z(o,n,a)}}),We=(o,n,t)=>(qr(o,n,"access private method"),t),Ze=new Uint8Array(8),an=new DataView(Ze.buffer),mt=o=>[(o%256+256)%256],Ye=o=>(an.setUint16(0,o,!1),[Ze[0],Ze[1]]),Lh=o=>(an.setInt16(0,o,!1),[Ze[0],Ze[1]]),Vc=o=>(an.setUint32(0,o,!1),[Ze[1],Ze[2],Ze[3]]),Se=o=>(an.setUint32(0,o,!1),[Ze[0],Ze[1],Ze[2],Ze[3]]),Uh=o=>(an.setInt32(0,o,!1),[Ze[0],Ze[1],Ze[2],Ze[3]]),Dn=o=>(an.setUint32(0,Math.floor(o/2**32),!1),an.setUint32(4,o,!1),[Ze[0],Ze[1],Ze[2],Ze[3],Ze[4],Ze[5],Ze[6],Ze[7]]),Kr=o=>(an.setInt16(0,2**8*o,!1),[Ze[0],Ze[1]]),en=o=>(an.setInt32(0,2**16*o,!1),[Ze[0],Ze[1],Ze[2],Ze[3]]),Ki=o=>(an.setInt32(0,2**30*o,!1),[Ze[0],Ze[1],Ze[2],Ze[3]]),Ot=(o,n=!1)=>{let t=Array(o.length).fill(null).map((a,i)=>o.charCodeAt(i));return n&&t.push(0),t},Do=o=>o&&o[o.length-1],Qr=o=>{let n;for(let t of o)(!n||t.presentationTimestamp>n.presentationTimestamp)&&(n=t);return n},nn=(o,n,t=!0)=>{let a=o*n;return t?Math.round(a):a},Nc=o=>{let n=o*(Math.PI/180),t=Math.cos(n),a=Math.sin(n);return[t,a,0,-a,t,0,0,0,1]},Tc=Nc(0),Mc=o=>[en(o[0]),en(o[1]),Ki(o[2]),en(o[3]),en(o[4]),Ki(o[5]),en(o[6]),en(o[7]),Ki(o[8])],Ma=o=>!o||typeof o!="object"?o:Array.isArray(o)?o.map(Ma):Object.fromEntries(Object.entries(o).map(([n,t])=>[n,Ma(t)])),aa=o=>o>=0&&o<2**32,dt=(o,n,t)=>({type:o,contents:n&&new Uint8Array(n.flat(10)),children:t}),nt=(o,n,t,a,i)=>dt(o,[mt(n),Vc(t),a??[]],i),Oh=o=>{let n=512;return o.fragmented?dt("ftyp",[Ot("iso5"),Se(n),Ot("iso5"),Ot("iso6"),Ot("mp41")]):dt("ftyp",[Ot("isom"),Se(n),Ot("isom"),o.holdsAvc?Ot("avc1"):[],Ot("mp41")])},vr=o=>({type:"mdat",largeSize:o}),Ph=o=>({type:"free",size:o}),xo=(o,n,t=!1)=>dt("moov",null,[zh(n,o),...o.map(a=>jh(a,n)),t?wv(o):null]),zh=(o,n)=>{let t=nn(Math.max(0,...n.filter(s=>s.samples.length>0).map(s=>{const l=Qr(s.samples);return l.presentationTimestamp+l.duration})),br),a=Math.max(...n.map(s=>s.id))+1,i=!aa(o)||!aa(t),r=i?Dn:Se;return nt("mvhd",+i,0,[r(o),r(o),Se(br),r(t),en(1),Kr(1),Array(10).fill(0),Mc(Tc),Array(24).fill(0),Se(a)])},jh=(o,n)=>dt("trak",null,[Wh(o,n),Zh(o,n)]),Wh=(o,n)=>{let t=Qr(o.samples),a=nn(t?t.presentationTimestamp+t.duration:0,br),i=!aa(n)||!aa(a),r=i?Dn:Se,s;return o.info.type==="video"?s=typeof o.info.rotation=="number"?Nc(o.info.rotation):o.info.rotation:s=Tc,nt("tkhd",+i,3,[r(n),r(n),Se(o.id),Se(0),r(a),Array(8).fill(0),Ye(0),Ye(0),Kr(o.info.type==="audio"?1:0),Ye(0),Mc(s),en(o.info.type==="video"?o.info.width:0),en(o.info.type==="video"?o.info.height:0)])},Zh=(o,n)=>dt("mdia",null,[Hh(o,n),Xh(o.info.type==="video"?"vide":"soun"),Gh(o)]),Hh=(o,n)=>{let t=Qr(o.samples),a=nn(t?t.presentationTimestamp+t.duration:0,o.timescale),i=!aa(n)||!aa(a),r=i?Dn:Se;return nt("mdhd",+i,0,[r(n),r(n),Se(o.timescale),r(a),Ye(21956),Ye(0)])},Xh=o=>nt("hdlr",0,0,[Ot("mhlr"),Ot(o),Se(0),Se(0),Se(0),Ot("mp4-muxer-hdlr",!0)]),Gh=o=>dt("minf",null,[o.info.type==="video"?Jh():Yh(),qh(),ev(o)]),Jh=()=>nt("vmhd",0,1,[Ye(0),Ye(0),Ye(0),Ye(0)]),Yh=()=>nt("smhd",0,0,[Ye(0),Ye(0)]),qh=()=>dt("dinf",null,[Kh()]),Kh=()=>nt("dref",0,0,[Se(1)],[Qh()]),Qh=()=>nt("url ",0,1),ev=o=>{const n=o.compositionTimeOffsetTable.length>1||o.compositionTimeOffsetTable.some(t=>t.sampleCompositionTimeOffset!==0);return dt("stbl",null,[tv(o),fv(o),hv(o),vv(o),gv(o),yv(o),n?bv(o):null])},tv=o=>nt("stsd",0,0,[Se(1)],[o.info.type==="video"?nv(Mv[o.info.codec],o):uv(Fv[o.info.codec],o)]),nv=(o,n)=>dt(o,[Array(6).fill(0),Ye(1),Ye(0),Ye(0),Array(12).fill(0),Ye(n.info.width),Ye(n.info.height),Se(4718592),Se(4718592),Se(0),Ye(1),Array(32).fill(0),Ye(24),Lh(65535)],[Bv[n.info.codec](n),n.info.decoderConfig.colorSpace?rv(n):null]),av={bt709:1,bt470bg:5,smpte170m:6},ov={bt709:1,smpte170m:6,"iec61966-2-1":13},iv={rgb:0,bt709:1,bt470bg:5,smpte170m:6},rv=o=>dt("colr",[Ot("nclx"),Ye(av[o.info.decoderConfig.colorSpace.primaries]),Ye(ov[o.info.decoderConfig.colorSpace.transfer]),Ye(iv[o.info.decoderConfig.colorSpace.matrix]),mt((o.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),sv=o=>o.info.decoderConfig&&dt("avcC",[...new Uint8Array(o.info.decoderConfig.description)]),lv=o=>o.info.decoderConfig&&dt("hvcC",[...new Uint8Array(o.info.decoderConfig.description)]),cv=o=>{if(!o.info.decoderConfig)return null;let n=o.info.decoderConfig;if(!n.colorSpace)throw new Error("'colorSpace' is required in the decoder config for VP9.");let t=n.codec.split("."),a=Number(t[1]),i=Number(t[2]),l=(Number(t[3])<<4)+(0<<1)+Number(n.colorSpace.fullRange);return nt("vpcC",1,0,[mt(a),mt(i),mt(l),mt(2),mt(2),mt(2),Ye(0)])},dv=()=>{let t=(1<<7)+1;return dt("av1C",[t,0,0,0])},uv=(o,n)=>dt(o,[Array(6).fill(0),Ye(1),Ye(0),Ye(0),Se(0),Ye(n.info.numberOfChannels),Ye(16),Ye(0),Ye(0),en(n.info.sampleRate)],[Iv[n.info.codec](n)]),mv=o=>{let n=new Uint8Array(o.info.decoderConfig.description);return nt("esds",0,0,[Se(58753152),mt(32+n.byteLength),Ye(1),mt(0),Se(75530368),mt(18+n.byteLength),mt(64),mt(21),Vc(0),Se(130071),Se(130071),Se(92307584),mt(n.byteLength),...n,Se(109084800),mt(1),mt(2)])},pv=o=>{var i;let n=3840,t=0;const a=(i=o.info.decoderConfig)==null?void 0:i.description;if(a){if(a.byteLength<18)throw new TypeError("Invalid decoder description provided for Opus; must be at least 18 bytes long.");const r=ArrayBuffer.isView(a)?new DataView(a.buffer,a.byteOffset,a.byteLength):new DataView(a);n=r.getUint16(10,!0),t=r.getInt16(14,!0)}return dt("dOps",[mt(0),mt(o.info.numberOfChannels),Ye(n),Se(o.info.sampleRate),Kr(t),mt(0)])},fv=o=>nt("stts",0,0,[Se(o.timeToSampleTable.length),o.timeToSampleTable.map(n=>[Se(n.sampleCount),Se(n.sampleDelta)])]),hv=o=>{if(o.samples.every(t=>t.type==="key"))return null;let n=[...o.samples.entries()].filter(([,t])=>t.type==="key");return nt("stss",0,0,[Se(n.length),n.map(([t])=>Se(t+1))])},vv=o=>nt("stsc",0,0,[Se(o.compactlyCodedChunkTable.length),o.compactlyCodedChunkTable.map(n=>[Se(n.firstChunk),Se(n.samplesPerChunk),Se(1)])]),gv=o=>nt("stsz",0,0,[Se(0),Se(o.samples.length),o.samples.map(n=>Se(n.size))]),yv=o=>o.finalizedChunks.length>0&&Do(o.finalizedChunks).offset>=2**32?nt("co64",0,0,[Se(o.finalizedChunks.length),o.finalizedChunks.map(n=>Dn(n.offset))]):nt("stco",0,0,[Se(o.finalizedChunks.length),o.finalizedChunks.map(n=>Se(n.offset))]),bv=o=>nt("ctts",0,0,[Se(o.compositionTimeOffsetTable.length),o.compositionTimeOffsetTable.map(n=>[Se(n.sampleCount),Se(n.sampleCompositionTimeOffset)])]),wv=o=>dt("mvex",null,o.map(kv)),kv=o=>nt("trex",0,0,[Se(o.id),Se(1),Se(0),Se(0),Se(0)]),hl=(o,n)=>dt("moof",null,[_v(o),...n.map(Ev)]),_v=o=>nt("mfhd",0,0,[Se(o)]),Bc=o=>{let n=0,t=0,a=0,i=0,r=o.type==="delta";return t|=+r,r?n|=1:n|=2,n<<24|t<<16|a<<8|i},Ev=o=>dt("traf",null,[xv(o),Cv(o),Sv(o)]),xv=o=>{let n=0;n|=8,n|=16,n|=32,n|=131072;let t=o.currentChunk.samples[1]??o.currentChunk.samples[0],a={duration:t.timescaleUnitsToNextSample,size:t.size,flags:Bc(t)};return nt("tfhd",0,n,[Se(o.id),Se(a.duration),Se(a.size),Se(a.flags)])},Cv=o=>nt("tfdt",1,0,[Dn(nn(o.currentChunk.startTimestamp,o.timescale))]),Sv=o=>{let n=o.currentChunk.samples.map(g=>g.timescaleUnitsToNextSample),t=o.currentChunk.samples.map(g=>g.size),a=o.currentChunk.samples.map(Bc),i=o.currentChunk.samples.map(g=>nn(g.presentationTimestamp-g.decodeTimestamp,o.timescale)),r=new Set(n),s=new Set(t),l=new Set(a),c=new Set(i),d=l.size===2&&a[0]!==a[1],u=r.size>1,m=s.size>1,f=!d&&l.size>1,p=c.size>1||[...c].some(g=>g!==0),v=0;return v|=1,v|=4*+d,v|=256*+u,v|=512*+m,v|=1024*+f,v|=2048*+p,nt("trun",1,v,[Se(o.currentChunk.samples.length),Se(o.currentChunk.offset-o.currentChunk.moofOffset||0),d?Se(a[0]):[],o.currentChunk.samples.map((g,k)=>[u?Se(n[k]):[],m?Se(t[k]):[],f?Se(a[k]):[],p?Uh(i[k]):[]])])},Vv=o=>dt("mfra",null,[...o.map(Nv),Tv()]),Nv=(o,n)=>nt("tfra",1,0,[Se(o.id),Se(63),Se(o.finalizedChunks.length),o.finalizedChunks.map(a=>[Dn(nn(a.startTimestamp,o.timescale)),Dn(a.moofOffset),Se(n+1),Se(1),Se(1)])]),Tv=()=>nt("mfro",0,0,[Se(0)]),Mv={avc:"avc1",hevc:"hvc1",vp9:"vp09",av1:"av01"},Bv={avc:sv,hevc:lv,vp9:cv,av1:dv},Fv={aac:"mp4a",opus:"Opus"},Iv={aac:mv,opus:pv},Jo=class{},es=class extends Jo{constructor(){super(...arguments),this.buffer=null}},Fc=class extends Jo{constructor(o){if(super(),this.options=o,typeof o!="object")throw new TypeError("StreamTarget requires an options object to be passed to its constructor.");if(o.onData){if(typeof o.onData!="function")throw new TypeError("options.onData, when provided, must be a function.");if(o.onData.length<2)throw new TypeError("options.onData, when provided, must be a function that takes in at least two arguments (data and position). Ignoring the position argument, which specifies the byte offset at which the data is to be written, can lead to broken outputs.")}if(o.chunked!==void 0&&typeof o.chunked!="boolean")throw new TypeError("options.chunked, when provided, must be a boolean.");if(o.chunkSize!==void 0&&(!Number.isInteger(o.chunkSize)||o.chunkSize<1024))throw new TypeError("options.chunkSize, when provided, must be an integer and not smaller than 1024.")}},$v=class extends Jo{constructor(o,n){if(super(),this.stream=o,this.options=n,!(o 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")}},Cn,Yn,Ic=class{constructor(){this.pos=0,ze(this,Cn,new Uint8Array(8)),ze(this,Yn,new DataView(Z(this,Cn).buffer)),this.offsets=new WeakMap}seek(o){this.pos=o}writeU32(o){Z(this,Yn).setUint32(0,o,!1),this.write(Z(this,Cn).subarray(0,4))}writeU64(o){Z(this,Yn).setUint32(0,Math.floor(o/2**32),!1),Z(this,Yn).setUint32(4,o,!1),this.write(Z(this,Cn).subarray(0,8))}writeAscii(o){for(let n=0;n<o.length;n++)Z(this,Yn).setUint8(n%8,o.charCodeAt(n)),n%8===7&&this.write(Z(this,Cn));o.length%8!==0&&this.write(Z(this,Cn).subarray(0,o.length%8))}writeBox(o){if(this.offsets.set(o,this.pos),o.contents&&!o.children)this.writeBoxHeader(o,o.size??o.contents.byteLength+8),this.write(o.contents);else{let n=this.pos;if(this.writeBoxHeader(o,0),o.contents&&this.write(o.contents),o.children)for(let i of o.children)i&&this.writeBox(i);let t=this.pos,a=o.size??t-n;this.seek(n),this.writeBoxHeader(o,a),this.seek(t)}}writeBoxHeader(o,n){this.writeU32(o.largeSize?1:n),this.writeAscii(o.type),o.largeSize&&this.writeU64(n)}measureBoxHeader(o){return 8+(o.largeSize?8:0)}patchBox(o){let n=this.pos;this.seek(this.offsets.get(o)),this.writeBox(o),this.seek(n)}measureBox(o){if(o.contents&&!o.children)return this.measureBoxHeader(o)+o.contents.byteLength;{let n=this.measureBoxHeader(o);if(o.contents&&(n+=o.contents.byteLength),o.children)for(let t of o.children)t&&(n+=this.measureBox(t));return n}}};Cn=new WeakMap;Yn=new WeakMap;var Co,In,Da,Sa,So,gr,Rv=class extends Ic{constructor(o){super(),ze(this,So),ze(this,Co,void 0),ze(this,In,new ArrayBuffer(2**16)),ze(this,Da,new Uint8Array(Z(this,In))),ze(this,Sa,0),ht(this,Co,o)}write(o){We(this,So,gr).call(this,this.pos+o.byteLength),Z(this,Da).set(o,this.pos),this.pos+=o.byteLength,ht(this,Sa,Math.max(Z(this,Sa),this.pos))}finalize(){We(this,So,gr).call(this,this.pos),Z(this,Co).buffer=Z(this,In).slice(0,Math.max(Z(this,Sa),this.pos))}};Co=new WeakMap;In=new WeakMap;Da=new WeakMap;Sa=new WeakMap;So=new WeakSet;gr=function(o){let n=Z(this,In).byteLength;for(;n<o;)n*=2;if(n===Z(this,In).byteLength)return;let t=new ArrayBuffer(n),a=new Uint8Array(t);a.set(Z(this,Da),0),ht(this,In,t),ht(this,Da,a)};var Dv=2**24,Av=2,Ba,Sn,Va,cn,Lt,Ao,yr,ts,$c,ns,Rc,Fa,Lo,as=class extends Ic{constructor(o){var n,t;super(),ze(this,Ao),ze(this,ts),ze(this,ns),ze(this,Fa),ze(this,Ba,void 0),ze(this,Sn,[]),ze(this,Va,void 0),ze(this,cn,void 0),ze(this,Lt,[]),ht(this,Ba,o),ht(this,Va,((n=o.options)==null?void 0:n.chunked)??!1),ht(this,cn,((t=o.options)==null?void 0:t.chunkSize)??Dv)}write(o){Z(this,Sn).push({data:o.slice(),start:this.pos}),this.pos+=o.byteLength}flush(){var t,a;if(Z(this,Sn).length===0)return;let o=[],n=[...Z(this,Sn)].sort((i,r)=>i.start-r.start);o.push({start:n[0].start,size:n[0].data.byteLength});for(let i=1;i<n.length;i++){let r=o[o.length-1],s=n[i];s.start<=r.start+r.size?r.size=Math.max(r.size,s.start+s.data.byteLength-r.start):o.push({start:s.start,size:s.data.byteLength})}for(let i of o){i.data=new Uint8Array(i.size);for(let r of Z(this,Sn))i.start<=r.start&&r.start<i.start+i.size&&i.data.set(r.data,r.start-i.start);Z(this,Va)?(We(this,Ao,yr).call(this,i.data,i.start),We(this,Fa,Lo).call(this)):(a=(t=Z(this,Ba).options).onData)==null||a.call(t,i.data,i.start)}Z(this,Sn).length=0}finalize(){Z(this,Va)&&We(this,Fa,Lo).call(this,!0)}};Ba=new WeakMap;Sn=new WeakMap;Va=new WeakMap;cn=new WeakMap;Lt=new WeakMap;Ao=new WeakSet;yr=function(o,n){let t=Z(this,Lt).findIndex(l=>l.start<=n&&n<l.start+Z(this,cn));t===-1&&(t=We(this,ns,Rc).call(this,n));let a=Z(this,Lt)[t],i=n-a.start,r=o.subarray(0,Math.min(Z(this,cn)-i,o.byteLength));a.data.set(r,i);let s={start:i,end:i+r.byteLength};if(We(this,ts,$c).call(this,a,s),a.written[0].start===0&&a.written[0].end===Z(this,cn)&&(a.shouldFlush=!0),Z(this,Lt).length>Av){for(let l=0;l<Z(this,Lt).length-1;l++)Z(this,Lt)[l].shouldFlush=!0;We(this,Fa,Lo).call(this)}r.byteLength<o.byteLength&&We(this,Ao,yr).call(this,o.subarray(r.byteLength),n+r.byteLength)};ts=new WeakSet;$c=function(o,n){let t=0,a=o.written.length-1,i=-1;for(;t<=a;){let r=Math.floor(t+(a-t+1)/2);o.written[r].start<=n.start?(t=r+1,i=r):a=r-1}for(o.written.splice(i+1,0,n),(i===-1||o.written[i].end<n.start)&&i++;i<o.written.length-1&&o.written[i].end>=o.written[i+1].start;)o.written[i].end=Math.max(o.written[i].end,o.written[i+1].end),o.written.splice(i+1,1)};ns=new WeakSet;Rc=function(o){let t={start:Math.floor(o/Z(this,cn))*Z(this,cn),data:new Uint8Array(Z(this,cn)),written:[],shouldFlush:!1};return Z(this,Lt).push(t),Z(this,Lt).sort((a,i)=>a.start-i.start),Z(this,Lt).indexOf(t)};Fa=new WeakSet;Lo=function(o=!1){var n,t;for(let a=0;a<Z(this,Lt).length;a++){let i=Z(this,Lt)[a];if(!(!i.shouldFlush&&!o)){for(let r of i.written)(t=(n=Z(this,Ba).options).onData)==null||t.call(n,i.data.subarray(r.start,r.end),i.start+r.start);Z(this,Lt).splice(a--,1)}}};var Lv=class extends as{constructor(o){var n;super(new Fc({onData:(t,a)=>o.stream.write({type:"write",data:t,position:a}),chunked:!0,chunkSize:(n=o.options)==null?void 0:n.chunkSize}))}},br=1e3,Uv=["avc","hevc","vp9","av1"],Ov=["aac","opus"],Pv=2082844800,zv=["strict","offset","cross-track-offset"],Re,Oe,Uo,Dt,yt,ft,qn,Kn,os,Vn,Nn,Ia,wr,Dc,kr,Ac,is,Lc,_r,Uc,rs,Oc,Vo,Er,Qt,ln,ss,Pc,$a,Oo,Po,ls,oa,Pa,No,xr,zc=class{constructor(o){if(ze(this,wr),ze(this,kr),ze(this,is),ze(this,_r),ze(this,rs),ze(this,Vo),ze(this,Qt),ze(this,ss),ze(this,$a),ze(this,Po),ze(this,oa),ze(this,No),ze(this,Re,void 0),ze(this,Oe,void 0),ze(this,Uo,void 0),ze(this,Dt,void 0),ze(this,yt,null),ze(this,ft,null),ze(this,qn,Math.floor(Date.now()/1e3)+Pv),ze(this,Kn,[]),ze(this,os,1),ze(this,Vn,[]),ze(this,Nn,[]),ze(this,Ia,!1),We(this,wr,Dc).call(this,o),o.video=Ma(o.video),o.audio=Ma(o.audio),o.fastStart=Ma(o.fastStart),this.target=o.target,ht(this,Re,{firstTimestampBehavior:"strict",...o}),o.target instanceof es)ht(this,Oe,new Rv(o.target));else if(o.target instanceof Fc)ht(this,Oe,new as(o.target));else if(o.target instanceof $v)ht(this,Oe,new Lv(o.target));else throw new Error(`Invalid target: ${o.target}`);We(this,_r,Uc).call(this),We(this,kr,Ac).call(this)}addVideoChunk(o,n,t,a){if(!(o 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(a!==void 0&&!Number.isFinite(a))throw new TypeError("addVideoChunk's fourth argument (compositionTimeOffset), when provided, must be a real number.");let i=new Uint8Array(o.byteLength);o.copyTo(i),this.addVideoChunkRaw(i,o.type,t??o.timestamp,o.duration,n,a)}addVideoChunkRaw(o,n,t,a,i,r){if(!(o 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(a)||a<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(We(this,No,xr).call(this),!Z(this,Re).video)throw new Error("No video track declared.");if(typeof Z(this,Re).fastStart=="object"&&Z(this,yt).samples.length===Z(this,Re).fastStart.expectedVideoChunks)throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${Z(this,Re).fastStart.expectedVideoChunks}).`);let s=We(this,Vo,Er).call(this,Z(this,yt),o,n,t,a,i,r);if(Z(this,Re).fastStart==="fragmented"&&Z(this,ft)){for(;Z(this,Nn).length>0&&Z(this,Nn)[0].decodeTimestamp<=s.decodeTimestamp;){let l=Z(this,Nn).shift();We(this,Qt,ln).call(this,Z(this,ft),l)}s.decodeTimestamp<=Z(this,ft).lastDecodeTimestamp?We(this,Qt,ln).call(this,Z(this,yt),s):Z(this,Vn).push(s)}else We(this,Qt,ln).call(this,Z(this,yt),s)}addAudioChunk(o,n,t){if(!(o 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 a=new Uint8Array(o.byteLength);o.copyTo(a),this.addAudioChunkRaw(a,o.type,t??o.timestamp,o.duration,n)}addAudioChunkRaw(o,n,t,a,i){if(!(o 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(a)||a<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(We(this,No,xr).call(this),!Z(this,Re).audio)throw new Error("No audio track declared.");if(typeof Z(this,Re).fastStart=="object"&&Z(this,ft).samples.length===Z(this,Re).fastStart.expectedAudioChunks)throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${Z(this,Re).fastStart.expectedAudioChunks}).`);let r=We(this,Vo,Er).call(this,Z(this,ft),o,n,t,a,i);if(Z(this,Re).fastStart==="fragmented"&&Z(this,yt)){for(;Z(this,Vn).length>0&&Z(this,Vn)[0].decodeTimestamp<=r.decodeTimestamp;){let s=Z(this,Vn).shift();We(this,Qt,ln).call(this,Z(this,yt),s)}r.decodeTimestamp<=Z(this,yt).lastDecodeTimestamp?We(this,Qt,ln).call(this,Z(this,ft),r):Z(this,Nn).push(r)}else We(this,Qt,ln).call(this,Z(this,ft),r)}finalize(){if(Z(this,Ia))throw new Error("Cannot finalize a muxer more than once.");if(Z(this,Re).fastStart==="fragmented"){for(let n of Z(this,Vn))We(this,Qt,ln).call(this,Z(this,yt),n);for(let n of Z(this,Nn))We(this,Qt,ln).call(this,Z(this,ft),n);We(this,Po,ls).call(this,!1)}else Z(this,yt)&&We(this,$a,Oo).call(this,Z(this,yt)),Z(this,ft)&&We(this,$a,Oo).call(this,Z(this,ft));let o=[Z(this,yt),Z(this,ft)].filter(Boolean);if(Z(this,Re).fastStart==="in-memory"){let n;for(let a=0;a<2;a++){let i=xo(o,Z(this,qn)),r=Z(this,Oe).measureBox(i);n=Z(this,Oe).measureBox(Z(this,Dt));let s=Z(this,Oe).pos+r+n;for(let l of Z(this,Kn)){l.offset=s;for(let{data:c}of l.samples)s+=c.byteLength,n+=c.byteLength}if(s<2**32)break;n>=2**32&&(Z(this,Dt).largeSize=!0)}let t=xo(o,Z(this,qn));Z(this,Oe).writeBox(t),Z(this,Dt).size=n,Z(this,Oe).writeBox(Z(this,Dt));for(let a of Z(this,Kn))for(let i of a.samples)Z(this,Oe).write(i.data),i.data=null}else if(Z(this,Re).fastStart==="fragmented"){let n=Z(this,Oe).pos,t=Vv(o);Z(this,Oe).writeBox(t);let a=Z(this,Oe).pos-n;Z(this,Oe).seek(Z(this,Oe).pos-4),Z(this,Oe).writeU32(a)}else{let n=Z(this,Oe).offsets.get(Z(this,Dt)),t=Z(this,Oe).pos-n;Z(this,Dt).size=t,Z(this,Dt).largeSize=t>=2**32,Z(this,Oe).patchBox(Z(this,Dt));let a=xo(o,Z(this,qn));if(typeof Z(this,Re).fastStart=="object"){Z(this,Oe).seek(Z(this,Uo)),Z(this,Oe).writeBox(a);let i=n-Z(this,Oe).pos;Z(this,Oe).writeBox(Ph(i))}else Z(this,Oe).writeBox(a)}We(this,oa,Pa).call(this),Z(this,Oe).finalize(),ht(this,Ia,!0)}};Re=new WeakMap;Oe=new WeakMap;Uo=new WeakMap;Dt=new WeakMap;yt=new WeakMap;ft=new WeakMap;qn=new WeakMap;Kn=new WeakMap;os=new WeakMap;Vn=new WeakMap;Nn=new WeakMap;Ia=new WeakMap;wr=new WeakSet;Dc=function(o){if(typeof o!="object")throw new TypeError("The muxer requires an options object to be passed to its constructor.");if(!(o.target instanceof Jo))throw new TypeError("The target must be provided and an instance of Target.");if(o.video){if(!Uv.includes(o.video.codec))throw new TypeError(`Unsupported video codec: ${o.video.codec}`);if(!Number.isInteger(o.video.width)||o.video.width<=0)throw new TypeError(`Invalid video width: ${o.video.width}. Must be a positive integer.`);if(!Number.isInteger(o.video.height)||o.video.height<=0)throw new TypeError(`Invalid video height: ${o.video.height}. Must be a positive integer.`);const n=o.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(o.video.frameRate!==void 0&&(!Number.isInteger(o.video.frameRate)||o.video.frameRate<=0))throw new TypeError(`Invalid video frame rate: ${o.video.frameRate}. Must be a positive integer.`)}if(o.audio){if(!Ov.includes(o.audio.codec))throw new TypeError(`Unsupported audio codec: ${o.audio.codec}`);if(!Number.isInteger(o.audio.numberOfChannels)||o.audio.numberOfChannels<=0)throw new TypeError(`Invalid number of audio channels: ${o.audio.numberOfChannels}. Must be a positive integer.`);if(!Number.isInteger(o.audio.sampleRate)||o.audio.sampleRate<=0)throw new TypeError(`Invalid audio sample rate: ${o.audio.sampleRate}. Must be a positive integer.`)}if(o.firstTimestampBehavior&&!zv.includes(o.firstTimestampBehavior))throw new TypeError(`Invalid first timestamp behavior: ${o.firstTimestampBehavior}`);if(typeof o.fastStart=="object"){if(o.video){if(o.fastStart.expectedVideoChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedVideoChunks'.");if(!Number.isInteger(o.fastStart.expectedVideoChunks)||o.fastStart.expectedVideoChunks<0)throw new TypeError("'expectedVideoChunks' must be a non-negative integer.")}if(o.audio){if(o.fastStart.expectedAudioChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedAudioChunks'.");if(!Number.isInteger(o.fastStart.expectedAudioChunks)||o.fastStart.expectedAudioChunks<0)throw new TypeError("'expectedAudioChunks' must be a non-negative integer.")}}else if(![!1,"in-memory","fragmented"].includes(o.fastStart))throw new TypeError("'fastStart' option must be false, 'in-memory', 'fragmented' or an object.");if(o.minFragmentDuration!==void 0&&(!Number.isFinite(o.minFragmentDuration)||o.minFragmentDuration<0))throw new TypeError("'minFragmentDuration' must be a non-negative number.")};kr=new WeakSet;Ac=function(){var o;if(Z(this,Oe).writeBox(Oh({holdsAvc:((o=Z(this,Re).video)==null?void 0:o.codec)==="avc",fragmented:Z(this,Re).fastStart==="fragmented"})),ht(this,Uo,Z(this,Oe).pos),Z(this,Re).fastStart==="in-memory")ht(this,Dt,vr(!1));else if(Z(this,Re).fastStart!=="fragmented"){if(typeof Z(this,Re).fastStart=="object"){let n=We(this,is,Lc).call(this);Z(this,Oe).seek(Z(this,Oe).pos+n)}ht(this,Dt,vr(!0)),Z(this,Oe).writeBox(Z(this,Dt))}We(this,oa,Pa).call(this)};is=new WeakSet;Lc=function(){if(typeof Z(this,Re).fastStart!="object")return;let o=0,n=[Z(this,Re).fastStart.expectedVideoChunks,Z(this,Re).fastStart.expectedAudioChunks];for(let t of n)t&&(o+=8*Math.ceil(2/3*t),o+=4*t,o+=12*Math.ceil(2/3*t),o+=4*t,o+=8*t);return o+=4096,o};_r=new WeakSet;Uc=function(){if(Z(this,Re).video&&ht(this,yt,{id:1,info:{type:"video",codec:Z(this,Re).video.codec,width:Z(this,Re).video.width,height:Z(this,Re).video.height,rotation:Z(this,Re).video.rotation??0,decoderConfig:null},timescale:Z(this,Re).video.frameRate??57600,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),Z(this,Re).audio&&(ht(this,ft,{id:Z(this,Re).video?2:1,info:{type:"audio",codec:Z(this,Re).audio.codec,numberOfChannels:Z(this,Re).audio.numberOfChannels,sampleRate:Z(this,Re).audio.sampleRate,decoderConfig:null},timescale:Z(this,Re).audio.sampleRate,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),Z(this,Re).audio.codec==="aac")){let o=We(this,rs,Oc).call(this,2,Z(this,Re).audio.sampleRate,Z(this,Re).audio.numberOfChannels);Z(this,ft).info.decoderConfig={codec:Z(this,Re).audio.codec,description:o,numberOfChannels:Z(this,Re).audio.numberOfChannels,sampleRate:Z(this,Re).audio.sampleRate}}};rs=new WeakSet;Oc=function(o,n,t){let i=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350].indexOf(n),r=t,s="";s+=o.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};Vo=new WeakSet;Er=function(o,n,t,a,i,r,s){let l=a/1e6,c=(a-(s??0))/1e6,d=i/1e6,u=We(this,ss,Pc).call(this,l,c,o);return l=u.presentationTimestamp,c=u.decodeTimestamp,r!=null&&r.decoderConfig&&(o.info.decoderConfig===null?o.info.decoderConfig=r.decoderConfig:Object.assign(o.info.decoderConfig,r.decoderConfig)),{presentationTimestamp:l,decodeTimestamp:c,duration:d,data:n,size:n.byteLength,type:t,timescaleUnitsToNextSample:nn(d,o.timescale)}};Qt=new WeakSet;ln=function(o,n){Z(this,Re).fastStart!=="fragmented"&&o.samples.push(n);const t=nn(n.presentationTimestamp-n.decodeTimestamp,o.timescale);if(o.lastTimescaleUnits!==null){let i=nn(n.decodeTimestamp,o.timescale,!1),r=Math.round(i-o.lastTimescaleUnits);if(o.lastTimescaleUnits+=r,o.lastSample.timescaleUnitsToNextSample=r,Z(this,Re).fastStart!=="fragmented"){let s=Do(o.timeToSampleTable);s.sampleCount===1?(s.sampleDelta=r,s.sampleCount++):s.sampleDelta===r?s.sampleCount++:(s.sampleCount--,o.timeToSampleTable.push({sampleCount:2,sampleDelta:r}));const l=Do(o.compositionTimeOffsetTable);l.sampleCompositionTimeOffset===t?l.sampleCount++:o.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t})}}else o.lastTimescaleUnits=0,Z(this,Re).fastStart!=="fragmented"&&(o.timeToSampleTable.push({sampleCount:1,sampleDelta:nn(n.duration,o.timescale)}),o.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t}));o.lastSample=n;let a=!1;if(!o.currentChunk)a=!0;else{let i=n.presentationTimestamp-o.currentChunk.startTimestamp;if(Z(this,Re).fastStart==="fragmented"){let r=Z(this,yt)??Z(this,ft);const s=Z(this,Re).minFragmentDuration??1;o===r&&n.type==="key"&&i>=s&&(a=!0,We(this,Po,ls).call(this))}else a=i>=.5}a&&(o.currentChunk&&We(this,$a,Oo).call(this,o),o.currentChunk={startTimestamp:n.presentationTimestamp,samples:[]}),o.currentChunk.samples.push(n)};ss=new WeakSet;Pc=function(o,n,t){var s,l;const a=Z(this,Re).firstTimestampBehavior==="strict",i=t.lastDecodeTimestamp===-1;if(a&&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(Z(this,Re).firstTimestampBehavior==="offset"||Z(this,Re).firstTimestampBehavior==="cross-track-offset"){t.firstDecodeTimestamp===void 0&&(t.firstDecodeTimestamp=n);let c;Z(this,Re).firstTimestampBehavior==="offset"?c=t.firstDecodeTimestamp:c=Math.min(((s=Z(this,yt))==null?void 0:s.firstDecodeTimestamp)??1/0,((l=Z(this,ft))==null?void 0:l.firstDecodeTimestamp)??1/0),n-=c,o-=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:o,decodeTimestamp:n}};$a=new WeakSet;Oo=function(o){if(Z(this,Re).fastStart==="fragmented")throw new Error("Can't finalize individual chunks if 'fastStart' is set to 'fragmented'.");if(o.currentChunk){if(o.finalizedChunks.push(o.currentChunk),Z(this,Kn).push(o.currentChunk),(o.compactlyCodedChunkTable.length===0||Do(o.compactlyCodedChunkTable).samplesPerChunk!==o.currentChunk.samples.length)&&o.compactlyCodedChunkTable.push({firstChunk:o.finalizedChunks.length,samplesPerChunk:o.currentChunk.samples.length}),Z(this,Re).fastStart==="in-memory"){o.currentChunk.offset=0;return}o.currentChunk.offset=Z(this,Oe).pos;for(let n of o.currentChunk.samples)Z(this,Oe).write(n.data),n.data=null;We(this,oa,Pa).call(this)}};Po=new WeakSet;ls=function(o=!0){if(Z(this,Re).fastStart!=="fragmented")throw new Error("Can't finalize a fragment unless 'fastStart' is set to 'fragmented'.");let n=[Z(this,yt),Z(this,ft)].filter(l=>l&&l.currentChunk);if(n.length===0)return;let t=Ah(this,os)._++;if(t===1){let l=xo(n,Z(this,qn),!0);Z(this,Oe).writeBox(l)}let a=Z(this,Oe).pos,i=hl(t,n);Z(this,Oe).writeBox(i);{let l=vr(!1),c=0;for(let u of n)for(let m of u.currentChunk.samples)c+=m.size;let d=Z(this,Oe).measureBox(l)+c;d>=2**32&&(l.largeSize=!0,d=Z(this,Oe).measureBox(l)+c),l.size=d,Z(this,Oe).writeBox(l)}for(let l of n){l.currentChunk.offset=Z(this,Oe).pos,l.currentChunk.moofOffset=a;for(let c of l.currentChunk.samples)Z(this,Oe).write(c.data),c.data=null}let r=Z(this,Oe).pos;Z(this,Oe).seek(Z(this,Oe).offsets.get(i));let s=hl(t,n);Z(this,Oe).writeBox(s),Z(this,Oe).seek(r);for(let l of n)l.finalizedChunks.push(l.currentChunk),Z(this,Kn).push(l.currentChunk),l.currentChunk=null;o&&We(this,oa,Pa).call(this)};oa=new WeakSet;Pa=function(){Z(this,Oe)instanceof as&&Z(this,Oe).flush()};No=new WeakSet;xr=function(){if(Z(this,Ia))throw new Error("Cannot add new video or audio chunks after the file has been finalized.")};const Aa=30;class ia extends Error{constructor({message:t="",code:a=""},...i){super(t,...i);X(this,"message");X(this,"code");this.code=a,this.message=t}}class dn extends ia{}class ct extends ia{}class zo extends ia{}class vl extends ia{}function jv(o,n=Aa){if(n<1)throw new ct({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(o*n)}function Qn(o,n=Aa){if(n<1)throw new ct({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(o/n*1e3)}class _e{constructor(n=0){X(this,"time");this.time=Math.round(n)}get millis(){return this.time}set millis(n){this.time=Math.round(n)}get frames(){return jv(this.millis/1e3)}set frames(n){this.millis=Qn(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=Qn(n);return this.millis=this.millis+t,this}add(n){return new _e(n.millis+this.millis)}subtract(n){return new _e(this.millis-n.millis)}static fromSeconds(n){const t=new _e;return t.millis=n*1e3,t}static fromFrames(n,t){const a=new _e;return a.millis=Qn(n,t),a}copy(){return new _e(this.millis)}toJSON(){return this.millis}static fromJSON(n){return new _e(n)}}function gl(o,n){return[o.slice(0,n),o.slice(n)].filter(t=>t.length>0)}function To(o,n){return n?Math.floor(Math.random()*(n-o+1)+o):o}function Wv(o,n,t){t<0&&(t=0);const a=o[n];o.splice(n,1),o.splice(t,0,a)}function yl(o){return typeof o!="function"?!1:/^class\s/.test(Function.prototype.toString.call(o))}function Zv(o){const n=o.numberOfChannels,t=o.length,a=new Int16Array(t*n);for(let i=0;i<t;i++)for(let r=0;r<n;r++){let s=o.getChannelData(r)[i]*32767;s>32767&&(s=32767),s<-32767&&(s=-32767),a[i*n+r]=s}return a}function Hv(o,n=44100,t=2){if(o.sampleRate==n&&o.numberOfChannels==t)return o;const a=Math.floor(o.duration*n),i=new OfflineAudioContext(t,1,n).createBuffer(t,a,n);for(let r=0;r<o.numberOfChannels;r++){const s=o.getChannelData(r),l=i.getChannelData(r),c=o.sampleRate/n;for(let d=0;d<l.length;d++){const u=d*c,m=Math.floor(u),f=Math.ceil(u);if(f>=s.length)l[d]=s[m];else{const p=u-m;l[d]=s[m]*(1-p)+s[f]*p}}}return i}async function Xv(o){const{fps:n,height:t,width:a,bitrate:i}=o,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:a,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(Gv)}function Gv(o,n){const t=o.hardwareAcceleration??"",a=n.hardwareAcceleration??"";return t<a?-1:t>a?1:0}async function Jv(o,n="untitled"){const t=document.createElement("a");if(document.head.appendChild(t),t.download=n,typeof o=="string"&&o.startsWith("data:image/svg+xml;base64,")){const a=o.split(",")[1],i=atob(a),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 o=="string"?t.href=o:t.href=URL.createObjectURL(o);t.click(),t.remove()}function bl(o){return`${o.hours.toString().padStart(2,"0")}:${o.minutes.toString().padStart(2,"0")}:${o.seconds.toString().padStart(2,"0")},`+o.milliseconds.toString().padStart(3,"0")}function wl(o){const n=new Date(1970,0,1);return n.setSeconds(o),n.setMilliseconds(Math.round(o%1*1e3)),{hours:n.getHours(),minutes:n.getMinutes(),seconds:n.getSeconds(),milliseconds:n.getMilliseconds()}}class mo{constructor(n){X(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 _e}get stop(){var n;return((n=this.words.at(-1))==null?void 0:n.stop)??new _e}}var Cr=(o=>(o.en="en",o.de="de",o))(Cr||{});class kl{constructor(n,t,a,i){X(this,"id",crypto.randomUUID());X(this,"text");X(this,"start");X(this,"stop");X(this,"confidence");this.text=n,this.start=new _e(t),this.stop=new _e(a),this.confidence=i}get duration(){return this.stop.subtract(this.start)}}class Mn{constructor(n=[],t=Cr.en){X(this,"id",crypto.randomUUID());X(this,"language",Cr.en);X(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:a}){for(const i of this.groups){let r;for(const[s,l]of i.words.entries())r&&(n&&r.words.length>=To(...n)?(yield r,r=void 0):t&&(r==null?void 0:r.duration.seconds)>=To(...t)?(yield r,r=void 0):a&&r.text.length>=To(...a)&&(yield r,r=void 0)),r?r.words.push(l):r=new mo([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 a=n[t],i=n[t+1];i.start.millis-a.stop.millis<0?i.start.millis=a.stop.millis+1:a.stop.millis=i.start.millis-1}return this}toSRT(n={}){let t=1,a="";for(const i of this.iter(n)){const r=wl(i.start.seconds),s=wl(i.stop.seconds);a+=`${t}
22
- `+bl(r)+" --> "+bl(s)+`
23
- ${i.text}
24
-
25
- `,t+=1}return{text:a,blob:new Blob([a],{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 a=0;const i=[];for(const r of this.groups)for(const s of r.words)if(i.length==0&&t&&(a=s.start.millis),i.push(new kl(s.text,s.start.millis-a,s.stop.millis-a)),i.length==n)return new Mn([new mo(i)]);return new Mn([new mo(i)])}copy(){return Mn.fromJSON(this.toJSON())}static fromJSON(n){const t=new Mn;for(const a of n){const i=new mo;for(const r of a)i.words.push(new kl(r.token,r.start,r.stop));t.groups.push(i)}return t}static async from(n,t){const a=await fetch(n,t);if(!a.ok)throw new dn({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});return Mn.fromJSON(await a.json())}}function Mo(o,n,t){return o+(n-o)*t}function Yv(o,n,t){const a=Number.parseInt(o.slice(1),16),i=Number.parseInt(n.slice(1),16),r=a>>16&255,s=a>>8&255,l=a&255,c=i>>16&255,d=i>>8&255,u=i&255,m=Math.round(Mo(r,c,t)),f=Math.round(Mo(s,d,t)),p=Math.round(Mo(l,u,t));return`#${((1<<24)+(m<<16)+(f<<8)+p).toString(16).slice(1)}`}const qv={linear:o=>o,easeIn:o=>o*o,easeOut:o=>o*(2-o),easeInOut:o=>o<.5?2*o*o:-1+(4-2*o)*o};class Ie{constructor(n,t,a={}){X(this,"input");X(this,"output");X(this,"options");if(n.length!==t.length)throw new ct({code:"invalidKeyframes",message:"inputRange and outputRange must have the same length"});this.input=n.map(i=>Qn(i)),this.output=t,this.options={extrapolate:"clamp",easing:"linear",type:"number",...JSON.parse(JSON.stringify(a))}}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 a=0;a<t.length-1;a++){const i=t[a],r=t[a+1];if(n>=i&&n<=r)return{t:(n-i)/(r-i),segment:a}}return{t:0,segment:0}}interpolate(n,t){const a=this.output[t],i=this.output[t+1],r=qv[this.options.easing](n);if(typeof a=="number"&&typeof i=="number")return Mo(a,i,r);if(typeof a=="string"&&typeof i=="string")return Yv(a,i,r);if(this.output.length==1)return this.output[0];throw new ct({code:"invalidKeyframes",message:"Unsupported output range types"})}value(n){const{t,segment:a}=this.normalize(typeof n=="number"?n:n.millis);return this.interpolate(t,a)}push(n,t){return this.input.push(Qn(n)),this.output.push(t),this}toJSON(){return this}static fromJSON(n){const t=new Ie([],[]);return Object.assign(t,n),t}}class Pt{constructor(){X(this,"id",crypto.randomUUID())}toJSON(){const n={};return(this.constructor.__serializableProperties||[]).forEach(({propertyKey:t,serializer:a})=>{const i=this[t];a&&i instanceof a?n[t]=i.toJSON():n[t]=i}),n}static fromJSON(n){const t=new this;return(this.__serializableProperties||[]).forEach(({propertyKey:a,serializer:i})=>{if(n.hasOwnProperty(a))if(i){const r=i.fromJSON(n[a]);t[a]=r}else t[a]=n[a]}),t}}function ke(o){return function(n,t){n.constructor.__serializableProperties||(n.constructor.__serializableProperties=[]),n.constructor.__serializableProperties.push({propertyKey:t,serializer:o})}}function za(o){return class extends o{constructor(){super(...arguments);X(this,"_handlers",{})}on(t,a){if(typeof a!="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]=a:this._handlers[t]={[i]:a},i}off(t,...a){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 a)this.off(i)}}trigger(t,a){var r,s;const i=new CustomEvent(t,{detail:a});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("*",a=>{t.trigger(a.type,a.detail)})}resolve(t){return(a,i)=>{this.on("error",i),this.on(t,a)}}}}function cs(o,n,t=0){if(!(o instanceof et.Container||o instanceof et.Filter||t==3))for(const a in o){const i=o[a];a&&(i instanceof Ie&&(o[a]=i.value(n)),i!=null&&typeof i=="object"&&Object.keys(i).length&&cs(i,n,t+1))}}var Kv=Object.defineProperty,Yo=(o,n,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&Kv(n,t,i),i};const ja=class jc extends za(Pt){constructor(t={}){super();X(this,"_name");X(this,"_start",new _e);X(this,"_stop",_e.fromSeconds(16));X(this,"type","base");X(this,"source");X(this,"view",new et.Container);X(this,"createdAt",new Date);X(this,"disabled",!1);X(this,"state","IDLE");X(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",_e.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=_e.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new ct({code:"splitOutOfRange",message:"Cannot split clip at the specified time"});if(!this.track)throw new ct({code:"trackNotAttached",message:"Track must be attached to a track"});const a=this.copy();this.stop=t.copy(),a.start=t.copy().addMillis(1),cs(a,a.start.subtract(this.start));const i=this.track.clips.findIndex(l=>l.id==this.id);return await this.track.add(a,i+1),a}copy(){return jc.fromJSON(JSON.parse(JSON.stringify(this)))}set(t){return t&&Object.assign(this,t),this.trigger("update",void 0),this}};Yo([ke()],ja.prototype,"_name");Yo([ke(_e)],ja.prototype,"_start");Yo([ke(_e)],ja.prototype,"_stop");Yo([ke()],ja.prototype,"disabled");let Wa=ja;var Qv=Object.defineProperty,On=(o,n,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&Qv(n,t,i),i};class on extends za(Pt){constructor(){super(...arguments);X(this,"state","IDLE");X(this,"metadata");X(this,"objectURL");X(this,"duration",_e.fromSeconds(16));X(this,"added",!1);X(this,"type","base");X(this,"name","");X(this,"mimeType");X(this,"externalURL");X(this,"external",!1);X(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 ct({code:"fileNotAccessible",message:"The desired file cannot be accessed"});return this.file}async loadFile(t){this.name=t.name,this.mimeType=Tr(t.type),this.external=!1,this.file=t}async loadUrl(t,a){const i=await fetch(t,a);if(!(i!=null&&i.ok))throw new dn({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=Tr(r.type)}async from(t,a){try{this.state="LOADING",t instanceof File?await this.loadFile(t):await this.loadUrl(t,a),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();Jv(t,this.name)}async thumbnail(){return document.createElement("div")}static async from(t,a,i=new this){return i.from(t,a)}}On([ke()],on.prototype,"objectURL");On([ke()],on.prototype,"duration");On([ke()],on.prototype,"type");On([ke()],on.prototype,"name");On([ke()],on.prototype,"mimeType");On([ke()],on.prototype,"externalURL");On([ke()],on.prototype,"external");const _l="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E";function e0(o){const n=new TextEncoder().encode(o);let t="";const a=n.byteLength;for(let i=0;i<a;i++)t+=String.fromCharCode(n[i]);return btoa(t)}function El(o){if(!o||!o.body)return _l;const n=o.body.scrollWidth,t=o.body.scrollHeight,a=o.cloneNode(!0),i=a.getElementsByTagName("style").item(0),r=a.getElementsByTagName("body").item(0);if(r==null||r.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),!r)return _l;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,"+e0(d)}class xl extends on{constructor(){super();X(this,"type","html");X(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=El(this.document),this.objectURL)}async loadUrl(t,a){await super.loadUrl(t,a),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((a,i)=>{this.iframe.onload=()=>a(),this.iframe.onerror=r=>i(r)})}update(){this.objectURL&&(this.objectURL=El(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 t0(o,n={}){const{threshold:t=.02,hopSize:a=1024,minDuration:i=500}=n,r=[],s=o.getChannelData(0),l=o.sampleRate,c=Math.floor(i/1e3*l);let d=null,u=0;for(let m=0;m<s.length;m+=a){let f=0;const p=Math.min(m+a,s.length);for(let v=m;v<p;v++)f+=s[v]*s[v];f=Math.sqrt(f/(p-m)),f<t?(u+=a,d===null&&(d=m)):(d!==null&&u>=c&&r.push({start:_e.fromSeconds(d/l),stop:_e.fromSeconds(m/l)}),d=null,u=0)}return d!==null&&u>=c&&r.push({start:_e.fromSeconds(d/l),stop:_e.fromSeconds(s.length/l)}),r}const Qi=3e3;class bn extends on{constructor(){super(...arguments);X(this,"type","audio");X(this,"decoding",!1);X(this,"_silences");X(this,"transcript");X(this,"audioBuffer")}async decode(t=2,a=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,a).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,a=50,i=0){const r=this.audioBuffer??await this.decode(1,3e3,!0),s=Math.round(r.sampleRate/a),l=r.sampleRate*r.duration-s,c=Math.ceil(l/t),d=r.getChannelData(0),u=[];for(let m=0;m<l;m+=c){let f=0;for(let p=m;p<m+s;p++)f+=Math.abs(d[m]);u.push(Math.log1p(f/s*100))}return u.map(m=>Math.round(m/Math.max(...u)*(100-i))+i)}async fastsampler({length:t=60,start:a=0,stop:i,logarithmic:r=!1}={}){typeof a=="object"&&(a=a.millis),typeof i=="object"&&(i=i.millis);const s=this.audioBuffer??await this.decode(1,Qi,!0),l=s.getChannelData(0),c=Math.floor(Math.max(a*Qi/1e3,0)),d=i?Math.floor(Math.min(i*Qi/1e3,s.length)):s.length,u=Math.floor((d-c)/t),m=new Float32Array(t);for(let f=0;f<t;f++){const p=c+f*u,v=p+u;let g=-1/0;for(let k=p;k<v;k++){const T=l[k];T>g&&(g=T)}m[f]=r?Math.log2(1+g):g}return m}async thumbnail(...t){const a=await this.samples(...t),i=document.createElement("div");i.className="flex flex-row absolute space-between inset-0 audio-samples";for(const r of a){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 a=await this.arrayBuffer(),i=new AudioContext,r=await i.decodeAudioData(a);return this._silences=t0(r,t),i.close(),this._silences}}class Sr extends on{constructor(){super(...arguments);X(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 Bn extends bn{constructor(){super(...arguments);X(this,"type","video");X(this,"downloadInProgress",!0)}async loadUrl(t,a){const i=await fetch(t,a);if(!(i!=null&&i.ok))throw new dn({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=Tr(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 ct({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",a=>{const i=a.currentTarget,r=i==null?void 0:i.getBoundingClientRect(),s=a.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 a=await t.blob();this.file=new File([a],this.name,{type:a.type}),this.trigger("load",void 0)}catch(a){this.state=="ERROR",this.trigger("error",new Error(String(a)))}finally{this.downloadInProgress=!1}}}class n0{static fromJSON(n){return[new _e(n[0]),new _e(n[1])]}}var a0=Object.defineProperty,o0=Object.getOwnPropertyDescriptor,ra=(o,n,t,a)=>{for(var i=a>1?void 0:a?o0(n,t):n,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(a?s(n,t,i):s(i))||i);return a&&i&&a0(n,t,i),i};const Pn=class Wc extends Wa{constructor(t={}){super();X(this,"source",new bn);X(this,"_offset",new _e);X(this,"playing",!1);X(this,"duration",new _e);X(this,"range",[new _e,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=_e.fromFrames(t));const a=t.subtract(this.offset);a.millis>=0&&a.millis<this.range[1].millis?this.range[0].millis=a.millis:a.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=_e.fromFrames(t));const a=t.subtract(this.offset);a.millis>this.range[0].millis&&a.millis<=this.duration.millis?this.range[1]=a:a.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",_e.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((a,i)=>{if(!this.element)return i(new vl({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=()=>a()})}subclip(t,a){if(t||(t=this.range[0]),a||(a=this.range[1]),typeof t=="number"&&(t=_e.fromFrames(t)),typeof a=="number"&&(a=_e.fromFrames(a)),t.millis>=a.millis)throw new ct({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]),a.millis>this.duration.millis&&this.duration.millis&&(a=this.duration),this.range=[t,a],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=Wc.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=_e.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new ct({code:"invalidKeyframe",message:"Cannot split clip at the specified time"});if(!this.track)throw new vl({code:"trackNotDefined",message:"Clip must be attached to a track"});t=t.subtract(this.offset);const a=this.copy();this.range[1]=t.copy(),a.range[0]=t.copy().addMillis(1),cs(a,a.start.subtract(this.start));const i=this.track.clips.findIndex(l=>l.id==this.id);return await this.track.add(a,i+1),a}async addCaptions(t){var a;if(!((a=this.track)!=null&&a.composition))throw new ct({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 a=(await this.source.silences(t)).filter(s=>Cl(s,this.range)).sort((s,l)=>s.start.millis-l.start.millis);if(a.length==0)return[this];const i=t.padding??500,r=[this];for(const s of a){const l=r.at(-1);if(!l)break;if(!Cl(s,l.range))continue;const c=new _e(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}};ra([ke(_e)],Pn.prototype,"_offset",2);ra([ke(_e)],Pn.prototype,"duration",2);ra([ke(n0)],Pn.prototype,"range",2);ra([ke(Mn)],Pn.prototype,"transcript",1);ra([ke()],Pn.prototype,"muted",1);ra([ke()],Pn.prototype,"volume",1);let qo=Pn;function Cl(o,n){return o.start.millis>=n[0].millis&&o.start.millis<=n[1].millis||o.stop.millis<=n[1].millis&&o.stop.millis>=n[0].millis}class po{static fromJSON(n){return typeof n=="object"?Ie.fromJSON(n):n}}class er{static fromJSON(n){return typeof n.x=="object"&&(n.x=Ie.fromJSON(n.x)),typeof n.y=="object"&&(n.y=Ie.fromJSON(n.y)),n}}let i0=class{constructor(o){X(this,"target");X(this,"animation");this.target=o}init(o,n,t=0,a){if(!(o in this.target))throw new Error(`Property [${String(o)}] cannot be assigned`);const i=[t],r=[n];typeof this.target[o]==typeof n&&t!=0&&(i.unshift(0),r.unshift(this.target[o])),this.target[o]=this.animation=new Ie(i,r,{easing:a})}};function r0(o){const n=new Proxy(o,{get(t,a){return a=="to"?(i,r)=>{if(!t.animation)throw new ct({code:"undefinedKeyframe",message:"Cannot use 'to() before selecting a property"});const s=new _e(t.animation.input.at(-1)).frames+r;return t.animation.push(s,i),n}:(i,r,s)=>(t.init(a,i,r,s),n)}});return n}class s0 extends i0{}var l0=Object.defineProperty,c0=Object.getOwnPropertyDescriptor,vn=(o,n,t,a)=>{for(var i=a>1?void 0:a?c0(n,t):n,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(a?s(n,t,i):s(i))||i);return a&&i&&l0(n,t,i),i};function Ko(o){class n extends o{constructor(){super(...arguments);X(this,"filters");X(this,"_height");X(this,"_width");X(this,"_position",{x:this.view.position.x,y:this.view.position.y});X(this,"_scale");X(this,"rotation",this.view.angle);X(this,"alpha",1);X(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 Ie||typeof i=="function"?this._scale={x:i,y:i}:this._scale=i}get x(){return this._position.x}set x(i){this._position.x=i}get y(){return this._position.y}set y(i){this._position.y=i}get translateX(){return this.translate.x}set translateX(i){this.translate.x=i}get translateY(){return this.translate.y}set translateY(i){this.translate.y=i}get height(){return this._height??this.view.height}set height(i){this._height=i}get width(){return this._width??this.view.width}set width(i){this._width=i}get mask(){return this.view.mask}set mask(i){this.view.mask=i??null}get anchor(){return this.view.children[0]instanceof et.Sprite?{x:this.view.children[0].anchor.x,y:this.view.children[0].anchor.y}:{x:0,y:0}}set anchor(i){const r=typeof i=="number"?{x:i,y:i}:i;for(const s of this.view.children)s instanceof et.Sprite&&s.anchor.set(r.x,r.y)}enter(){this.filters&&!this.view.filters&&(this.view.filters=this.filters)}exit(){this.filters&&this.view.filters&&(this.view.filters=null)}animate(){return r0(new s0(this))}}return vn([ke(po)],n.prototype,"_height",2),vn([ke(po)],n.prototype,"_width",2),vn([ke(er)],n.prototype,"_position",2),vn([ke(er)],n.prototype,"_scale",2),vn([ke(po)],n.prototype,"rotation",2),vn([ke(po)],n.prototype,"alpha",2),vn([ke(er)],n.prototype,"translate",2),vn([ke()],n.prototype,"anchor",1),n}function Qo(o,n,t){const a=t.value;return t.value=function(...i){var m,f,p,v;const r=i[0].subtract(this.start),s={width:((f=(m=this.track)==null?void 0:m.composition)==null?void 0:f.width)??1920,height:((v=(p=this.track)==null?void 0:p.composition)==null?void 0:v.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),a.apply(this,i)},t}var d0=Object.defineProperty,u0=Object.getOwnPropertyDescriptor,m0=(o,n,t,a)=>{for(var i=u0(n,t),r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&d0(n,t,i),i};const Zc=class Hc extends Ko(Wa){constructor(t,a={}){super();X(this,"type","image");X(this,"element",new Image);X(this,"source",new Sr);X(this,"sprite",new et.Sprite);this.view.addChild(this.sprite),t instanceof Sr&&(this.source=t),t instanceof File&&this.source.from(t),Object.assign(this,a)}async init(){this.element.setAttribute("src",await this.source.createObjectURL()),await new Promise((t,a)=>{this.element.onload=()=>{this.sprite.texture=et.Texture.from(this.element),this.state="READY",t()},this.element.onerror=i=>{this.state="ERROR",a(new dn({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=Hc.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};m0([Qo],Zc.prototype,"update");let p0=Zc;const fo={"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 f0=Object.defineProperty,ei=(o,n,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&f0(n,t,i),i};const Za=class Vr extends za(Pt){constructor(t){super();X(this,"loaded",!1);X(this,"family");X(this,"weight");X(this,"source");X(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(a=>{t.load().then(i=>{document.fonts.add(i),a(null)})}),this.loaded=!0,this.trigger("load",void 0),this}copy(){const t=Vr.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 a of await window.queryLocalFonts()){if(a.family in t){t[a.family].push(a);continue}t[a.family]=[a]}return Object.keys(t).map(a=>({family:a,variants:t[a].map(i=>({family:a,style:i.style,source:`local('${i.fullName}'), local('${i.postscriptName}')`}))}))}static webFonts(){return Object.keys(fo).map(t=>({family:t,variants:fo[t].weights.map(a=>({family:t,source:`url(${fo[t].url})`,weight:a}))}))}static fromFamily({family:t,weight:a}){return new Vr({family:t,source:`url(${fo[t].url})`,weight:a})}};ei([ke()],Za.prototype,"family");ei([ke()],Za.prototype,"weight");ei([ke()],Za.prototype,"source");ei([ke()],Za.prototype,"style");let kt=Za;const tn=4,Xc={center:.5,justify:.5,left:0,right:1},Gc={alphabetic:0,top:0,middle:.5,hanging:1,bottom:1,ideographic:1};var h0=Object.defineProperty,v0=Object.getOwnPropertyDescriptor,$t=(o,n,t,a)=>{for(var i=v0(n,t),r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&h0(n,t,i),i};const St=class Jc extends Ko(Wa){constructor(t){super();X(this,"type","text");X(this,"_text","");X(this,"_textCase");X(this,"_anchor",{x:0,y:0});X(this,"_font",new kt);X(this,"style",new et.TextStyle({fill:"#FFFFFF",fontFamily:this._font.family,fontSize:16}));this.style.padding=20,typeof t=="string"?(this.text=t,this.reflectUpdate()):t&&(Object.assign(this,t),this.reflectUpdate()),this.on("update",this.reflectUpdate.bind(this))}get text(){return this._text}set text(t){if(this._text=t,!this.view.children.length){const a=new et.Text({text:this.transformedText,style:this.style,resolution:tn,scale:tn});this.view.addChild(a)}this.view.children[0]instanceof et.Text&&this.transformedText&&(this.view.children[0].text=this.transformedText)}get name(){return this._text}get font(){return this._font}set font(t){if(this._font=t,t.loaded){this.style.fontFamily=t.name;return}this._font.load().then(()=>{this.style.fontFamily=t.name,this.trigger("update",void 0)})}get maxWidth(){if(this.style.wordWrap)return this.style.wordWrapWidth*tn}set maxWidth(t){t?(this.style.wordWrap=!0,this.style.wordWrapWidth=t/tn):this.style.wordWrap=!1}get textAlign(){return this.style.align}set textAlign(t){this.style.align=t,this.anchor.x=Xc[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=Gc[t]}get fillStyle(){const{fill:t}=this.style;return new et.Color(t.toString()).toHex().toUpperCase()}set fillStyle(t){this.style.fill=t}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor={x:t,y:t}:this._anchor=t}get stroke(){if(!this.style.stroke)return;let{color:t="#000000",alpha:a=1,width:i=3,join:r="round",miterLimit:s}=this.style.stroke;return t=new et.Color(t).toHex().toUpperCase(),{color:t,alpha:a,width:i,join:r,miterLimit:s}}set stroke(t){if(!t){this.style.stroke=void 0;return}const{color:a="#000000",alpha:i=1,width:r=3,join:s="round",miterLimit:l}=t;this.style.stroke={color:a,alpha:i,width:r,join:s,miterLimit:l}}get textCase(){return this._textCase}set textCase(t){this._textCase=t,this.view.children[0]instanceof et.Text&&this.transformedText&&(this.view.children[0].text=this.transformedText)}get shadow(){if(!this.style.dropShadow)return;const{alpha:t,angle:a,blur:i,color:r,distance:s}=this.style.dropShadow,l=new et.Color(r).toHex().toUpperCase();return{alpha:t,angle:a,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=Jc.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,a=((s=this.view.children[0])==null?void 0:s.height)??0,i=(((l=this.style.dropShadow)==null?void 0:l.distance)??0)*tn;this.view.pivot={x:(t-i)*this._anchor.x,y:(a-i)*this._anchor.y}}set(t){return super.set(t)}};$t([ke()],St.prototype,"text");$t([ke(kt)],St.prototype,"font");$t([ke()],St.prototype,"maxWidth");$t([ke()],St.prototype,"textAlign");$t([ke()],St.prototype,"padding");$t([ke()],St.prototype,"textBaseline");$t([ke()],St.prototype,"fillStyle");$t([ke()],St.prototype,"anchor");$t([ke()],St.prototype,"stroke");$t([ke()],St.prototype,"textCase");$t([ke()],St.prototype,"shadow");$t([ke()],St.prototype,"fontSize");$t([ke()],St.prototype,"leading");$t([Qo],St.prototype,"update");let sa=St;function tr(o){const n=o.split(" ").map(t=>`${t} `);return n[n.length-1]=n[n.length-1].replace(/ $/,""),n}const g0={get(o,n){const t=o[n];return typeof t=="number"?t*tn:Array.isArray(t)&&typeof t[0]=="number"?t.map(a=>a*tn):t}};function y0(o){return new Proxy(o,g0)}class b0{constructor(){X(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 Sl{constructor(){X(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 w0{static fromJSON(n){return n.map(t=>(t.font&&(t.font=kt.fromJSON(t.font)),t))}}var k0=Object.defineProperty,_0=Object.getOwnPropertyDescriptor,la=(o,n,t,a)=>{for(var i=a>1?void 0:a?_0(n,t):n,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(a?s(n,t,i):s(i))||i);return a&&i&&k0(n,t,i),i};const zn=class Yc extends sa{constructor(t){super();X(this,"type","complex_text");X(this,"_maxWidth");X(this,"_textAlign","left");X(this,"_textBaseline","top");X(this,"model",new et.Container);X(this,"segments",[]);X(this,"metrics",new Sl);X(this,"background");X(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=Xc[t];const a=this.metrics.width;for(const i of this.metrics.lines){let r=0;(t=="center"||t=="justify")&&(r=(a-i.width)/2),t=="right"&&(r=a-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=Gc[t];let a=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=a+l}a+=r}}copy(){const t=Yc.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.font=this.font,t}createRenderSplits(t=[]){var r,s;const a=this.transformedText??"",i=[{index:void 0,tokens:tr(a.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:tr(a.substring(t[l].start,t[l].stop))}),!((t[l].stop??a.length)>=a.length)&&i.push({index:void 0,tokens:tr(a.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,a){var r,s,l;const i=new Sl;for(const c of t){const d=c.index!=null?a[c.index]:this.style;for(let u=0;u<c.tokens.length;u++){const m=y0(et.CanvasTextMetrics.measureText(c.tokens[u],d)),f=(((r=i.lines.at(-1))==null?void 0:r.width)??0)+m.lineWidths[0],p=this.maxWidth??Number.POSITIVE_INFINITY,v=(s=c.tokens.at(u-1))==null?void 0:s.match(/(\n|\\n).$/gim);(f>p||v||!i.lines.length)&&i.lines.push(new b0),this.model.addChild(new et.Text({text:c.tokens[u],style:d,resolution:tn,scale:tn})),(l=i.lines.at(-1))==null||l.tokens.push({metrics:m,index:this.model.children.length-1})}}return i}createTextStyles(){var t;return((t=this.styles)==null?void 0:t.map(a=>{var r;const i=this.style.clone();return i.fill=a.fillStyle??this.style.fill,i.fontSize=a.fontSize??this.style.fontSize,i.stroke=a.stroke??this.style.stroke,i.fontFamily=((r=a.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,a=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 et.Graphics;s.roundRect(0-i/2,2-r/2,t+i,a+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),a=this.createTextStyles();this.metrics=this.createTextMetrics(t,a),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)*tn;this.view.pivot={x:(i-s)*this._anchor.x,y:(r-s)*this._anchor.y},this.drawBackground()}};la([ke()],zn.prototype,"background",2);la([ke(w0)],zn.prototype,"styles",2);la([ke()],zn.prototype,"text",1);la([ke()],zn.prototype,"maxWidth",1);la([ke()],zn.prototype,"textAlign",1);la([ke()],zn.prototype,"textBaseline",1);let ti=zn;const qc="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBtPSh0PT4odFt0LkFWTUVESUFfVFlQRV9VTktOT1dOPS0xXT0iQVZNRURJQV9UWVBFX1VOS05PV04iLHRbdC5BVk1FRElBX1RZUEVfVklERU89MF09IkFWTUVESUFfVFlQRV9WSURFTyIsdFt0LkFWTUVESUFfVFlQRV9BVURJTz0xXT0iQVZNRURJQV9UWVBFX0FVRElPIix0W3QuQVZNRURJQV9UWVBFX0RBVEE9Ml09IkFWTUVESUFfVFlQRV9EQVRBIix0W3QuQVZNRURJQV9UWVBFX1NVQlRJVExFPTNdPSJBVk1FRElBX1RZUEVfU1VCVElUTEUiLHRbdC5BVk1FRElBX1RZUEVfQVRUQUNITUVOVD00XT0iQVZNRURJQV9UWVBFX0FUVEFDSE1FTlQiLHRbdC5BVk1FRElBX1RZUEVfTkI9NV09IkFWTUVESUFfVFlQRV9OQiIsdCkpKG18fHt9KSxvPSh0PT4odC5GRm1wZWdXb3JrZXJMb2FkZWQ9IkZGbXBlZ1dvcmtlckxvYWRlZCIsdC5XQVNNUnVudGltZUluaXRpYWxpemVkPSJXQVNNUnVudGltZUluaXRpYWxpemVkIix0LkxvYWRXQVNNPSJMb2FkV0FTTSIsdC5HZXRBVlBhY2tldD0iR2V0QVZQYWNrZXQiLHQuR2V0QVZQYWNrZXRzPSJHZXRBVlBhY2tldHMiLHQuR2V0QVZTdHJlYW09IkdldEFWU3RyZWFtIix0LkdldEFWU3RyZWFtcz0iR2V0QVZTdHJlYW1zIix0LlJlYWRBVlBhY2tldD0iUmVhZEFWUGFja2V0Iix0LkFWUGFja2V0U3RyZWFtPSJBVlBhY2tldFN0cmVhbSIsdC5SZWFkTmV4dEFWUGFja2V0PSJSZWFkTmV4dEFWUGFja2V0Iix0LlN0b3BSZWFkQVZQYWNrZXQ9IlN0b3BSZWFkQVZQYWNrZXQiLHQpKShvfHx7fSk7Y29uc3QgQT0iS0daMWJtTjBhVzl1S0NsN0luVnpaU0J6ZEhKcFkzUWlPMnhsZENCbU8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2SWtaR2JYQmxaMWR2Y210bGNreHZZV1JsWkNKOUtTeHpaV3htTG1Ga1pFVjJaVzUwVEdsemRHVnVaWElvSW0xbGMzTmhaMlVpTEdGemVXNWpJR1oxYm1OMGFXOXVLR3dwZTJOdmJuTjBlM1I1Y0dVNmRDeGtZWFJoT21NOWUzMHNiWE5uU1dRNmIzMDliQzVrWVhSaE8zUnllWHRwWmloMFBUMDlJa3h2WVdSWFFWTk5JaWw3WTI5dWMzUjdkMkZ6YlV4dllXUmxjbEJoZEdnNlpYMDlZM3g4ZTMwN1pqMWhkMkZwZENoaGQyRnBkQ0JwYlhCdmNuUW9aU2twTG1SbFptRjFiSFFvS1gxbGJITmxJR2xtS0hROVBUMGlSMlYwUVZaVGRISmxZVzBpS1h0amIyNXpkSHRtYVd4bE9tVXNjM1J5WldGdFZIbHdaVHB6TEhOMGNtVmhiVWx1WkdWNE9tRjlQV01zY2oxbUxtZGxkRUZXVTNSeVpXRnRLR1VzY3l4aEtUdHpaV3htTG5CdmMzUk5aWE56WVdkbEtIdDBlWEJsT25Rc2JYTm5TV1E2Ynl4eVpYTjFiSFE2Y24wc1czSXVZMjlrWldOd1lYSXVaWGgwY21Ga1lYUmhMbUoxWm1abGNsMHBmV1ZzYzJVZ2FXWW9kRDA5UFNKSFpYUkJWbE4wY21WaGJYTWlLWHRqYjI1emRIdG1hV3hsT21WOVBXTXNjejFtTG1kbGRFRldVM1J5WldGdGN5aGxLVHR6Wld4bUxuQnZjM1JOWlhOellXZGxLSHQwZVhCbE9uUXNiWE5uU1dRNmJ5eHlaWE4xYkhRNmMzMHNjeTV0WVhBb1lUMCtZUzVqYjJSbFkzQmhjaTVsZUhSeVlXUmhkR0V1WW5WbVptVnlLU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBJaWw3WTI5dWMzUjdabWxzWlRwbExIUnBiV1U2Y3l4emRISmxZVzFVZVhCbE9tRXNjM1J5WldGdFNXNWtaWGc2Y24wOVl5eHVQV1l1WjJWMFFWWlFZV05yWlhRb1pTeHpMR0VzY2lrN2MyVnNaaTV3YjNOMFRXVnpjMkZuWlNoN2RIbHdaVHAwTEcxelowbGtPbThzY21WemRXeDBPbTU5TEZ0dUxtUmhkR0V1WW5WbVptVnlYU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBjeUlwZTJOdmJuTjBlMlpwYkdVNlpTeDBhVzFsT25OOVBXTXNZVDFtTG1kbGRFRldVR0ZqYTJWMGN5aGxMSE1wTzNObGJHWXVjRzl6ZEUxbGMzTmhaMlVvZTNSNWNHVTZkQ3h0YzJkSlpEcHZMSEpsYzNWc2REcGhmU3hoTG0xaGNDaHlQVDV5TG1SaGRHRXVZblZtWm1WeUtTbDlaV3h6WlNCcFppaDBQVDA5SWxKbFlXUkJWbEJoWTJ0bGRDSXBlMk52Ym5OMGUyWnBiR1U2WlN4emRHRnlkRHB6TEdWdVpEcGhMSE4wY21WaGJWUjVjR1U2Y2l4emRISmxZVzFKYm1SbGVEcHVmVDFqTEdROVppNXlaV0ZrUVZaUVlXTnJaWFFvYnl4bExITXNZU3h5TEc0cE8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEhKbGMzVnNkRHBrZlNsOWZXTmhkR05vS0dVcGUzTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEdWeWNrMXpaenBsSUdsdWMzUmhibU5sYjJZZ1JYSnliM0kvWlM1dFpYTnpZV2RsT2lKVmJtdHViM2R1SUVWeWNtOXlJbjBwZlgwcGZTa29LVHNLIixnPXQ9PlVpbnQ4QXJyYXkuZnJvbShhdG9iKHQpLGU9PmUuY2hhckNvZGVBdCgwKSksVj10eXBlb2Ygc2VsZjwidSImJnNlbGYuQmxvYiYmbmV3IEJsb2IoW2coQSldLHt0eXBlOiJ0ZXh0L2phdmFzY3JpcHQ7Y2hhcnNldD11dGYtOCJ9KTtmdW5jdGlvbiBFKHQpe2xldCBlO3RyeXtpZihlPVYmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLmNyZWF0ZU9iamVjdFVSTChWKSwhZSl0aHJvdyIiO2NvbnN0IHM9bmV3IFdvcmtlcihlLHtuYW1lOnQ/Lm5hbWV9KTtyZXR1cm4gcy5hZGRFdmVudExpc3RlbmVyKCJlcnJvciIsKCk9Pnsoc2VsZi5VUkx8fHNlbGYud2Via2l0VVJMKS5yZXZva2VPYmplY3RVUkwoZSl9KSxzfWNhdGNoe3JldHVybiBuZXcgV29ya2VyKCJkYXRhOnRleHQvamF2YXNjcmlwdDtiYXNlNjQsIitBLHtuYW1lOnQ/Lm5hbWV9KX1maW5hbGx5e2UmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLnJldm9rZU9iamVjdFVSTChlKX19Y29uc3QgdT0xZTY7Y2xhc3MgcHtmZm1wZWdXb3JrZXI7ZmZtcGVnV29ya2VyTG9hZFN0YXR1czttc2dJZDtmaWxlO2NvbnN0cnVjdG9yKGUpe3RoaXMuZmZtcGVnV29ya2VyPW5ldyBFLHRoaXMuZmZtcGVnV29ya2VyTG9hZFN0YXR1cz1uZXcgUHJvbWlzZSgocyxhKT0+e3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGk9Pntjb25zdHt0eXBlOnIsZXJyTXNnOmR9PWkuZGF0YTtyPT09by5GRm1wZWdXb3JrZXJMb2FkZWQmJnRoaXMucG9zdChvLkxvYWRXQVNNLHt3YXNtTG9hZGVyUGF0aDplLndhc21Mb2FkZXJQYXRofSkscj09PW8uV0FTTVJ1bnRpbWVJbml0aWFsaXplZCYmcyghMCkscj09PW8uTG9hZFdBU00mJmQmJmEoZCl9KX0pLHRoaXMubXNnSWQ9MH1wb3N0KGUscyxhKXt0aGlzLmZmbXBlZ1dvcmtlci5wb3N0TWVzc2FnZSh7dHlwZTplLG1zZ0lkOmE/P3RoaXMubXNnSWQrKyxkYXRhOnN9KX1hc3luYyBsb2FkKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5mZm1wZWdXb3JrZXJMb2FkU3RhdHVzO3JldHVybiB0aGlzLmZpbGU9ZSxzfWRlc3Ryb3koKXt0aGlzLmZpbGU9dm9pZCAwLHRoaXMuZmZtcGVnV29ya2VyLnRlcm1pbmF0ZSgpfWdldEFWU3RyZWFtKGU9bS5BVk1FRElBX1RZUEVfVklERU8scz0tMSl7cmV0dXJuIG5ldyBQcm9taXNlKChhLGkpPT57aWYoIXRoaXMuZmlsZSl7aSgiZmlsZSBpcyBub3QgbG9hZGVkIik7cmV0dXJufWNvbnN0IHI9dGhpcy5tc2dJZCxkPSh7ZGF0YTpufSk9PntuLnR5cGU9PT1vLkdldEFWU3RyZWFtJiZuLm1zZ0lkPT09ciYmKG4uZXJyTXNnP2kobi5lcnJNc2cpOmEobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGQpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZCksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW0se2ZpbGU6dGhpcy5maWxlLHN0cmVhbVR5cGU6ZSxzdHJlYW1JbmRleDpzfSl9KX1nZXRBVlN0cmVhbXMoKXtyZXR1cm4gbmV3IFByb21pc2UoKGUscyk9PntpZighdGhpcy5maWxlKXtzKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgYT10aGlzLm1zZ0lkLGk9KHtkYXRhOnJ9KT0+e3IudHlwZT09PW8uR2V0QVZTdHJlYW1zJiZyLm1zZ0lkPT09YSYmKHIuZXJyTXNnP3Moci5lcnJNc2cpOmUoci5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsaSksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW1zLHtmaWxlOnRoaXMuZmlsZX0pfSl9Z2V0QVZQYWNrZXQoZSxzPW0uQVZNRURJQV9UWVBFX1ZJREVPLGE9LTEpe3JldHVybiBuZXcgUHJvbWlzZSgoaSxyKT0+e2lmKCF0aGlzLmZpbGUpe3IoImZpbGUgaXMgbm90IGxvYWRlZCIpO3JldHVybn1jb25zdCBkPXRoaXMubXNnSWQsbj1oPT57Y29uc3QgbD1oLmRhdGE7bC50eXBlPT09by5HZXRBVlBhY2tldCYmbC5tc2dJZD09PWQmJihsLmVyck1zZz9yKGwuZXJyTXNnKTppKGwucmVzdWx0KSx0aGlzLmZmbXBlZ1dvcmtlci5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixuKSl9O3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLG4pLHRoaXMucG9zdChvLkdldEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSx0aW1lOmUsc3RyZWFtVHlwZTpzLHN0cmVhbUluZGV4OmF9KX0pfWdldEFWUGFja2V0cyhlKXtyZXR1cm4gbmV3IFByb21pc2UoKHMsYSk9PntpZighdGhpcy5maWxlKXthKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgaT10aGlzLm1zZ0lkLHI9ZD0+e2NvbnN0IG49ZC5kYXRhO24udHlwZT09PW8uR2V0QVZQYWNrZXRzJiZuLm1zZ0lkPT09aSYmKG4uZXJyTXNnP2Eobi5lcnJNc2cpOnMobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLHIpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsciksdGhpcy5wb3N0KG8uR2V0QVZQYWNrZXRzLHtmaWxlOnRoaXMuZmlsZSx0aW1lOmV9KX0pfXJlYWRBVlBhY2tldChlPTAscz0wLGE9bS5BVk1FRElBX1RZUEVfVklERU8saT0tMSl7Y29uc3Qgcj1uZXcgQ291bnRRdWV1aW5nU3RyYXRlZ3koe2hpZ2hXYXRlck1hcms6MX0pLGQ9dGhpcy5tc2dJZDtsZXQgbj0wO3JldHVybiBuZXcgUmVhZGFibGVTdHJlYW0oe3N0YXJ0Omg9PntpZighdGhpcy5maWxlKXtoLmVycm9yKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgbD1mPT57Y29uc3QgYz1mLmRhdGE7Yy50eXBlPT09by5SZWFkQVZQYWNrZXQmJmMubXNnSWQ9PT1kJiZjLmVyck1zZyYmKGguZXJyb3IoYy5lcnJNc2cpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGwpKSxjLnR5cGU9PT1vLkFWUGFja2V0U3RyZWFtJiZjLm1zZ0lkPT09ZCYmKGMucmVzdWx0P2guZW5xdWV1ZShjLnJlc3VsdCk6aC5jbG9zZSgpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsbCksdGhpcy5wb3N0KG8uUmVhZEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSxzdGFydDplLGVuZDpzLHN0cmVhbVR5cGU6YSxzdHJlYW1JbmRleDppfSl9LHB1bGw6KCk9PntuPjAmJnRoaXMucG9zdChvLlJlYWROZXh0QVZQYWNrZXQsdm9pZCAwLGQpLG4rK30sY2FuY2VsOigpPT57dGhpcy5wb3N0KG8uU3RvcFJlYWRBVlBhY2tldCx2b2lkIDAsZCl9fSxyKX1nZXRWaWRlb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9WSURFTyxlKX1nZXRBdWRpb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9BVURJTyxlKX1zZWVrVmlkZW9QYWNrZXQoZSl7cmV0dXJuIHRoaXMuZ2V0QVZQYWNrZXQoZSxtLkFWTUVESUFfVFlQRV9WSURFTyl9c2Vla0F1ZGlvUGFja2V0KGUpe3JldHVybiB0aGlzLmdldEFWUGFja2V0KGUsbS5BVk1FRElBX1RZUEVfQVVESU8pfXJlYWRWaWRlb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfVklERU8pfXJlYWRBdWRpb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfQVVESU8pfWdlblZpZGVvRGVjb2RlckNvbmZpZyhlKXtyZXR1cm57Y29kZWM6ZS5jb2RlY3Bhci5jb2RlY19zdHJpbmcsY29kZWRXaWR0aDplLmNvZGVjcGFyLndpZHRoLGNvZGVkSGVpZ2h0OmUuY29kZWNwYXIuaGVpZ2h0LGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRWaWRlb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZFZpZGVvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1nZW5BdWRpb0RlY29kZXJDb25maWcoZSl7cmV0dXJue2NvZGVjOmUuY29kZWNwYXIuY29kZWNfc3RyaW5nfHwiIixzYW1wbGVSYXRlOmUuY29kZWNwYXIuc2FtcGxlX3JhdGUsbnVtYmVyT2ZDaGFubmVsczplLmNvZGVjcGFyLmNoYW5uZWxzLGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRBdWRpb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZEF1ZGlvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1hc3luYyBnZXRWaWRlb0RlY29kZXJDb25maWcoKXtjb25zdCBlPWF3YWl0IHRoaXMuZ2V0VmlkZW9TdHJlYW0oKTtyZXR1cm4gdGhpcy5nZW5WaWRlb0RlY29kZXJDb25maWcoZSl9YXN5bmMgc2Vla0VuY29kZWRWaWRlb0NodW5rKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5zZWVrVmlkZW9QYWNrZXQoZSk7cmV0dXJuIHRoaXMuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsocyl9YXN5bmMgZ2V0QXVkaW9EZWNvZGVyQ29uZmlnKCl7Y29uc3QgZT1hd2FpdCB0aGlzLmdldEF1ZGlvU3RyZWFtKCk7cmV0dXJuIHRoaXMuZ2VuQXVkaW9EZWNvZGVyQ29uZmlnKGUpfWFzeW5jIHNlZWtFbmNvZGVkQXVkaW9DaHVuayhlKXtjb25zdCBzPWF3YWl0IHRoaXMuc2Vla0F1ZGlvUGFja2V0KGUpO3JldHVybiB0aGlzLmdlbkVuY29kZWRBdWRpb0NodW5rKHMpfX1jbGFzcyBre3ZpZGVvO2N1cnJlbnRGcmFtZXM9MDt0b3RhbEZyYW1lcztjdXJyZW50VGltZTtmcHM7Zmlyc3RUaW1lc3RhbXA7Y29uc3RydWN0b3IoZSxzKXt0aGlzLmN1cnJlbnRUaW1lPWVbMF0qMWU2LHRoaXMuZmlyc3RUaW1lc3RhbXA9ZVswXSoxZTYsdGhpcy50b3RhbEZyYW1lcz0oZVsxXS1lWzBdKSpzKzEsdGhpcy5mcHM9cyx0aGlzLnZpZGVvPW5ldyBWaWRlb0RlY29kZXIoe291dHB1dDp0aGlzLmhhbmRsZUZyYW1lT3V0cHV0LmJpbmQodGhpcyksZXJyb3I6dGhpcy5oYW5kbGVFcnJvci5iaW5kKHRoaXMpfSl9cG9zdEZyYW1lKGUpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImZyYW1lIixmcmFtZTplfSksdGhpcy5jdXJyZW50VGltZSs9TWF0aC5mbG9vcigxL3RoaXMuZnBzKjFlNiksdGhpcy5jdXJyZW50RnJhbWVzKz0xfWhhbmRsZUZyYW1lT3V0cHV0KGUpe2NvbnN0IHM9ZS50aW1lc3RhbXAsYT1lLmR1cmF0aW9uPz8wLGk9cythO2lmKCF0aGlzLmlzRnJhbWVJblJhbmdlKHMpKXtlLmNsb3NlKCk7cmV0dXJufWZvcig7aT50aGlzLmN1cnJlbnRUaW1lJiZ0aGlzLmN1cnJlbnRGcmFtZXM8PXRoaXMudG90YWxGcmFtZXM7KXRoaXMucG9zdEZyYW1lKGUpO2UuY2xvc2UoKX1pc0ZyYW1lSW5SYW5nZShlKXtyZXR1cm4gZT49dGhpcy5maXJzdFRpbWVzdGFtcH1oYW5kbGVFcnJvcihlKXtjb25zb2xlLmVycm9yKCJlcnJvciBpbiB3b3JrZXIiLGUpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOmUubWVzc2FnZT8/IkFuIHVua25vd24gd29ya2VyIGVycm9yIG9jY3VycmVkIn0pLHNlbGYuY2xvc2UoKX19ZnVuY3Rpb24gSSh0KXtyZXR1cm4gYXN5bmMgZT0+e3RyeXthd2FpdCB0KGUpfWNhdGNoKHMpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOnM/Lm1lc3NhZ2U/PyJBbiB1bmtvd24gd29ya2VyIGVycm9yIG9jY3VyZWQifSl9fX1mdW5jdGlvbiBXKHQpe3JldHVybiB0LmNvZGVjPT0idnAwOSImJih0LmNvZGVjPSJ2cDA5LjAwLjEwLjA4IiksdH1jb25zdCBaPTMwO2FzeW5jIGZ1bmN0aW9uIFAodCl7aWYodC5kYXRhPy50eXBlIT0iaW5pdCIpcmV0dXJuO2NvbnN0e2ZpbGU6ZSxyYW5nZTpzLGZwczphfT10LmRhdGEsaT1uZXcgcCh7d2FzbUxvYWRlclBhdGg6Imh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vQGRpZmZ1c2lvbnN0dWRpby9mZm1wZWctd2FzbUAxLjAuMC9kaXN0L2ZmbXBlZy5qcyJ9KTthd2FpdCBpLmxvYWQoZSk7Y29uc3Qgcj1hd2FpdCBpLmdldFZpZGVvRGVjb2RlckNvbmZpZygpO1cocik7Y29uc3QgZD1uZXcgayhzLGEpO2QudmlkZW8uY29uZmlndXJlKHIpO2NvbnN0IG49aS5yZWFkQVZQYWNrZXQoc1swXSxzWzFdKS5nZXRSZWFkZXIoKTtuLnJlYWQoKS50aGVuKGFzeW5jIGZ1bmN0aW9uIGgoe2RvbmU6bCx2YWx1ZTpmfSl7aWYobCl7YXdhaXQgZC52aWRlby5mbHVzaCgpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImRvbmUifSksc2VsZi5jbG9zZSgpO3JldHVybn1jb25zdCBjPWkuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsoZik7cmV0dXJuIGQudmlkZW8uZGVjb2RlUXVldWVTaXplPlomJmF3YWl0IG5ldyBQcm9taXNlKEw9PntkLnZpZGVvLm9uZGVxdWV1ZT0oKT0+TCgpfSksYy50aW1lc3RhbXA8PXNbMV0qMWU2JiZkLnZpZGVvLmRlY29kZShjKSxuLnJlYWQoKS50aGVuKGgpfSl9c2VsZi5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixJKFApKX0pKCk7Cg==",E0=o=>Uint8Array.from(atob(o),n=>n.charCodeAt(0)),Vl=typeof self<"u"&&self.Blob&&new Blob([E0(qc)],{type:"text/javascript;charset=utf-8"});function x0(o){let n;try{if(n=Vl&&(self.URL||self.webkitURL).createObjectURL(Vl),!n)throw"";const t=new Worker(n,{name:o==null?void 0:o.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),t}catch{return new Worker("data:text/javascript;base64,"+qc,{name:o==null?void 0:o.name})}finally{n&&(self.URL||self.webkitURL).revokeObjectURL(n)}}class C0{constructor(){X(this,"frames",[]);X(this,"state","active");X(this,"onenqueue");X(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,a)=>{const i=setTimeout(()=>{a(`Promise timed out after ${n} ms`)},n);this.onenqueue=()=>{clearTimeout(i),t()},this.onclose=()=>{clearTimeout(i),t()}})}}function S0(o,n,t){const a=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),a.apply(this,i)},t}var V0=Object.defineProperty,N0=Object.getOwnPropertyDescriptor,T0=(o,n,t,a)=>{for(var i=N0(n,t),r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&V0(n,t,i),i};const Kc=class Qc extends Ko(qo){constructor(t,a={}){super();X(this,"source",new Bn);X(this,"type","video");X(this,"worker");X(this,"buffer");X(this,"canvas",document.createElement("canvas"));X(this,"context",this.canvas.getContext("2d"));X(this,"element",document.createElement("video"));X(this,"textrues",{html5:et.Texture.from(this.element),canvas:et.Texture.from(this.canvas)});X(this,"sprite",new et.Sprite);this.element.controls=!1,this.element.playsInline=!0,this.element.style.display="hidden",this.element.crossOrigin="anonymous",this.textrues.html5.source.autoPlay=!1,this.textrues.html5.source.loop=!1,this.sprite.texture=this.textrues.html5,this.view.addChild(this.sprite),t instanceof Bn&&(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,a)}async init(){const t=await this.source.createObjectURL();this.element.setAttribute("src",t),await new Promise((a,i)=>{this.element.oncanplay=()=>{this.duration.seconds=this.element.duration,this.state="READY",a()},this.element.onerror=()=>{this.state="ERROR";const r=new dn({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 a=((i=t.composition)==null?void 0:i.frame)??0;await this.seek(_e.fromFrames(a))}enter(){var t,a,i;super.enter(),(a=(t=this.track)==null?void 0:t.composition)!=null&&a.rendering&&((i=this.buffer)==null?void 0:i.state)!="active"&&this.decodeVideo()}update(t){var a,i,r,s,l,c;if((i=(a=this.track)==null?void 0:a.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=Qc.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}async decodeVideo(){var t,a;return this.buffer=new C0,this.worker=new x0,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:((a=(t=this.track)==null?void 0:t.composition)==null?void 0:a.fps)??Aa}),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 a;this.start.millis<0?a=Math.abs(this.offset.seconds):a=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,[a,i]}cancelDecoding(){var t,a;(t=this.worker)==null||t.terminate(),this.worker=void 0,(a=this.buffer)==null||a.terminate(),this.buffer=void 0}};T0([Qo,S0],Kc.prototype,"update");let Nr=Kc;class jo extends qo{constructor(t,a={}){super();X(this,"type","audio");X(this,"source",new bn);X(this,"element",new Audio);t instanceof bn&&(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,a)}async init(){const t=await this.source.createObjectURL();this.element.setAttribute("src",t),this.element.load(),await new Promise((a,i)=>{this.element.oncanplay=()=>{this.duration.seconds=this.element.duration,this.state="READY",a()},this.element.onerror=()=>{this.state="ERROR";const r=new dn({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."});i(this.element.error??r)}})}update(){var t,a,i,r,s,l;if((a=(t=this.track)==null?void 0:t.composition)!=null&&a.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=jo.fromJSON(JSON.parse(JSON.stringify(this)));return t.source=this.source,t}}const M0={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 Tr(o){if(!Object.keys(M0.MIXED).includes(o??""))throw new ct({message:`${o} is not an accepted mime type`,code:"invalid_mimetype"});return o}var B0=Object.defineProperty,F0=Object.getOwnPropertyDescriptor,I0=(o,n,t,a)=>{for(var i=F0(n,t),r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&B0(n,t,i),i};const $0=class ed extends Ko(Wa){constructor(t,a={}){super();X(this,"type","html");X(this,"source",new xl);X(this,"element",new Image);X(this,"canvas",document.createElement("canvas"));X(this,"context",this.canvas.getContext("2d"));X(this,"sprite",new et.Sprite);this.view.addChild(this.sprite),Object.assign(this,a),t instanceof xl&&(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=et.Texture.from(this.canvas,!0),this.trigger("load",void 0))}),this.element.addEventListener("error",i=>{this.state="ERROR",this.trigger("error",new dn({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,a)=>{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 a(new dn({code:"sourceNotProcessable",message:"Cannot display source with height or width at 0"}));this.state="READY",t()},this.element.onerror=i=>{a(new dn({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=ed.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};I0([Qo],$0.prototype,"update");const td=["DEFAULT","STACK"];class Nl{constructor(){X(this,"mode",td[0]);X(this,"pauseAlignmet",!1)}add(n,t){let a=!0;for(let i=0;i<t.clips.length&&(a=Bl(n,t.clips[i]),!!a);i++)Ml(n,t.clips[i]);a&&(t.clips.push(n),t.clips.sort(Tl))}update(n,t){if(!this.pauseAlignmet){t.clips.sort(Tl);for(let a=0;a<t.clips.length;a++)if(n.id!=t.clips[a].id){if(!Bl(n,t.clips[a]))break;Ml(n,t.clips[a])}}}offset(n,t){this.pauseAlignmet=!0;for(const a of t.clips)a.offsetBy(n);this.pauseAlignmet=!1}}class R0{constructor(){X(this,"mode",td[1])}add(n,t,a=void 0){var r;let i=-1;(a!=null&&a>0||a==null)&&(i=((r=t.clips.at((a??0)-1))==null?void 0:r.stop.millis)??-1),n.offsetBy(new _e(i-n.start.millis+1)),a==null?t.clips.push(n):(t.clips.splice(a,0,n),t.clips.slice(a+1).forEach(s=>{s.offsetBy(n.stop.subtract(n.start))}))}update(n,t){let a=0;for(const i of t.clips){if(i.start.millis!=a){const r=a-i.start.millis;i.offsetBy(new _e(r))}a=i.stop.millis+1}}offset(){}}function Tl(o,n){return o.start.millis-n.start.millis}function Ml(o,n){o.start.millis>=n.start.millis&&o.start.millis<=n.stop.millis&&(o.start=n.stop.copy().addMillis(1)),o.stop.millis>=n.start.millis&&o.stop.millis<=n.stop.millis&&(o.stop=n.start.copy().addMillis(-1))}function Bl(o,n){var t,a,i,r,s;if(o.start.millis>=n.start.millis&&o.stop.millis<=n.stop.millis){const l=(a=(t=n.track)==null?void 0:t.composition)==null?void 0:a.tracks.find(c=>c.type==o.type&&!c.clips.some(d=>o.id!=d.id&&o.start.millis>=d.start.millis&&o.stop.millis<=d.stop.millis));return l?(l.add(o.detach()),!1):((s=(r=(i=n.track)==null?void 0:i.composition)==null?void 0:r.createTrack(o.type))==null||s.add(o.detach()),!1)}return!0}class ca extends za(Pt){constructor(){super(...arguments);X(this,"_disabled",!1);X(this,"view",new et.Container);X(this,"clips",[]);X(this,"pointer",0);X(this,"composition");X(this,"type","base");X(this,"strategy",new Nl)}get disabled(){return this._disabled}set disabled(t){var a;t&&this.clipRef&&ar(this.clipRef)&&(this.view.removeChild(this.clipRef.view),(a=this.clipRef)==null||a.exit()),this._disabled=t,this.trigger("update",void 0)}connect(t){this.composition=t}stacked(t=!0){return t?(this.strategy=new R0,this.strategy.update(new Wa,this)):this.strategy=new Nl,this.trigger("update",void 0),this}layer(t){var l,c;const a=((l=this.composition)==null?void 0:l.tracks)??[],i=a.findIndex(d=>d.id==this.id),r=a.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,Wv(a,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(_e.fromFrames(t),this):this.strategy.offset(t,this),this}update(t){var i,r;if(this.disabled||!this.clips.length)return;const{millis:a}=t;if(ar(this.clipRef)&&(!nr(a,this.clipRef)||(i=this.clipRef)!=null&&i.disabled)&&(this.clipRef&&this.view.removeChild(this.clipRef.view),(r=this.clipRef)==null||r.exit()),!!nr(a,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(nr(a,c)&&!c.disabled)return this.pointer=l,ar(c)||(c.enter(),this.view.addChild(c.view)),c.update(t);if(a<c.start.millis&&a>((d==null?void 0:d.stop.millis)??0)){this.pointer=l;return}}}async add(t,a){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,a),t.on("frame",()=>{this.strategy.update(t,this)}),t.bubble(this),this.trigger("attach",void 0),t}remove(t){const a=this.clips.findIndex(i=>i.id==t.id);if(t.state=="ATTACHED"&&(t.state="READY"),t.view.parent&&this.view.removeChild(t.view),a!=null&&a>=0)return this.clips.splice(a,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 _e}get start(){var t;return((t=this.clips.at(0))==null?void 0:t.start)??new _e}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 nr(o,n){return n?o>=n.start.millis&&o<=n.stop.millis:!1}function ar(o){return o?!!o.view.parent:!1}class D0{static fromType(n){switch(n.type){case"video":return new A0;case"audio":return new U0;case"html":return new O0;case"image":return new L0;case"text":return new Fl;case"complex_text":return new Fl;case"caption":return new z0;default:return new ca}}}class nd extends ca{constructor(){super(...arguments);X(this,"clips",[])}async seek(t){for(const a of this.clips)await a.seek(t)}async removeSilences(t={}){const a=[];for(const i of this.clips.map(r=>r.detach()))a.push(...await i.removeSilences(t));for(const i of a)await this.add(i)}}class A0 extends nd{constructor(){super(...arguments);X(this,"type","video")}async seek(t){var a;(a=this.composition)!=null&&a.rendering?this.view.removeChildren():super.seek(t)}}class L0 extends ca{constructor(){super(...arguments);X(this,"type","image")}}class U0 extends nd{constructor(){super(...arguments);X(this,"type","audio")}}class Fl extends ca{constructor(){super(...arguments);X(this,"type","text")}}class O0 extends ca{constructor(){super(...arguments);X(this,"type","html")}}var P0=Object.defineProperty,ds=(o,n,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&P0(n,t,i),i};class Ha extends Pt{constructor(t={}){super();X(this,"generatorOptions");X(this,"type","CLASSIC");X(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 ct({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new _e,i=await kt.fromFamily({family:"Figtree",weight:"700"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))await t.add(new sa({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(a),start:c.start.add(a),scale:new Ie([0,8],[.96,1],{easing:"easeOut"}),alpha:new Ie([0,4],[0,1],{easing:"easeOut"})}))}}ds([ke()],Ha.prototype,"generatorOptions");ds([ke()],Ha.prototype,"type");ds([ke()],Ha.prototype,"position");class z0 extends ca{constructor(){super(...arguments);X(this,"clip");X(this,"type","caption");X(this,"preset",new Ha)}from(t){var a;return this.clip=t,(a=this.clip)==null||a.on("offsetBy",i=>this.offsetBy(i.detail)),this}async generate(t){let a=this.preset;return typeof t=="object"?a=t:t&&(a=new t),this.clips=[],this.trigger("update",void 0),this.preset=a,await a.applyTo(this),this.trigger("update",void 0),this}}var j0=Object.defineProperty,ni=(o,n,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&j0(n,t,i),i};class Xa extends Pt{constructor(t={}){super();X(this,"generatorOptions");X(this,"type","SPOTLIGHT");X(this,"color");X(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 ct({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new _e,i=await kt.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(m=>m.text);await t.add(new ti({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(a),start:c.words[d].start.add(a)}))}}}ni([ke()],Xa.prototype,"generatorOptions");ni([ke()],Xa.prototype,"type");ni([ke()],Xa.prototype,"color");ni([ke()],Xa.prototype,"position");var W0=Object.defineProperty,us=(o,n,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&W0(n,t,i),i};class ai extends Pt{constructor(t={}){super();X(this,"type","GUINEA");X(this,"colors");X(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,m;if(!((r=t.clip)!=null&&r.transcript)||!((s=t.composition)!=null&&s.width))throw new ct({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new _e,i=await kt.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const f of t.clip.transcript.iter({length:[18]})){const{segments:p,words:v}=this.splitSequence(f);for(let g=0;g<f.words.length;g++){const k=(d=(c=v[g])==null?void 0:c.at(0))==null?void 0:d.start,T=(m=(u=v[g])==null?void 0:u.at(-1))==null?void 0:m.stop;!k||!T||await t.add(new ti({text:p.join(`
33
- `),textAlign:"center",textBaseline:"middle",fontSize:20,fillStyle:"#FFFFFF",shadow:{color:"#000000",blur:16,alpha:.8,angle:Math.PI/4,distance:1},stroke:{width:4,color:"#000000"},maxWidth:t.composition.width*.8,leading:1.3,font:i,textCase:"upper",position:this.position,stop:T.add(a),start:k.add(a),styles:[{fillStyle:this.colors[0],fontSize:23},{fillStyle:this.colors[1],fontSize:23},{fillStyle:this.colors[2],fontSize:23}],segments:[{index:To(0,2),start:p.slice(0,g).join(" ").length,stop:p.slice(0,g+1).join(" ").length+g*2}]}))}}}splitSequence(t){const a=t.text,i=Math.ceil(a.length/2);let r=a.length;for(let c=i,d=i;c>0&&d<t.text.length-1;c--,d++){if(a[c].match(/ /)){r=c;break}if(a[d].match(/ /)){r=d;break}}const s=[...gl(a,r).map(c=>c.trim())],l=gl(t.words,s[0].split(/ /).length);return{segments:s,words:l}}}us([ke()],ai.prototype,"type");us([ke()],ai.prototype,"colors");us([ke()],ai.prototype,"position");var Z0=Object.defineProperty,ms=(o,n,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&Z0(n,t,i),i};class oi extends Pt{constructor(t={}){super();X(this,"generatorOptions");X(this,"type","CASCADE");X(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 ct({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new _e,i=await kt.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(m=>m.text).slice(0,d+1).join(" ");await t.add(new sa({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(a),start:c.words[d].start.add(a)}))}}}ms([ke()],oi.prototype,"generatorOptions");ms([ke()],oi.prototype,"type");ms([ke()],oi.prototype,"position");var H0=Object.defineProperty,ps=(o,n,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&H0(n,t,i),i};class ii extends Pt{constructor(t={}){super();X(this,"generatorOptions");X(this,"type","SOLAR");X(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 ct({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=await kt.fromFamily({family:"Urbanist",weight:"800"}).load(),i=((c=t.clip)==null?void 0:c.offset)??new _e,r=new _m.GlowFilter({color:"#fffe41",alpha:.25,distance:90,quality:.05});for(const d of t.clip.transcript.iter(this.generatorOptions))await t.add(new sa({text:d.words.map(u=>u.text).join(" "),textAlign:"center",textBaseline:"middle",fontSize:19,fillStyle:"#fffe41",font:a,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 Ie([0,8],[.96,1],{easing:"easeOut"}),alpha:new Ie([0,4],[0,1],{easing:"easeOut"}),filters:r}))}}ps([ke()],ii.prototype,"generatorOptions");ps([ke()],ii.prototype,"type");ps([ke()],ii.prototype,"position");var X0=Object.defineProperty,ri=(o,n,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&X0(n,t,i),i};class Ga extends Pt{constructor(t={}){super();X(this,"generatorOptions");X(this,"type","WHISPER");X(this,"color");X(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 ct({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new _e,i=await kt.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(m=>m.text);await t.add(new ti({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(a),start:c.words[d].start.add(a),segments:u.length>1?[{index:0,start:u.slice(0,d+1).join(" ").length}]:void 0}))}}}ri([ke()],Ga.prototype,"generatorOptions");ri([ke()],Ga.prototype,"type");ri([ke()],Ga.prototype,"color");ri([ke()],Ga.prototype,"position");var G0=Object.defineProperty,si=(o,n,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(n,t,i)||i);return i&&G0(n,t,i),i};class li extends Pt{constructor(t={}){super();X(this,"type","VERDANT");X(this,"generatorOptions");X(this,"color");X(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 ct({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new _e,i=await kt.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(m=>m.text);await t.add(new ti({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(a),start:c.words[d].start.add(a),segments:[{index:0,start:u.slice(0,d).join(" ").length,stop:u.slice(0,d+1).join(" ").length}]}))}}}si([ke()],li.prototype,"type");si([ke()],li.prototype,"generatorOptions");si([ke()],li.prototype,"color");si([ke()],li.prototype,"position");class J0 extends za(Pt){constructor({height:t=1080,width:a=1920,background:i="#000000",backend:r="webgpu"}={}){super();X(this,"_duration",new _e);X(this,"renderer");X(this,"stage",new et.Container);X(this,"settings");X(this,"tracks",[]);X(this,"frame",0);X(this,"fixedDuration");X(this,"state","IDLE");X(this,"fps",Aa);X(this,"canvas");X(this,"context");this.settings={height:t,width:a,background:i,backend:r},this.on("update",this.update.bind(this)),this.on("attach",this.update.bind(this)),this.on("detach",this.update.bind(this)),this.on("load",this.update.bind(this)),this.on("frame",this.update.bind(this)),this.on("error",this.update.bind(this)),et.autoDetectRenderer({...this.settings,preference:r}).then(s=>{this.renderer=s,this.trigger("init",void 0)}).catch(s=>{this.trigger("error",new ia({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 a;t?t instanceof _e?this.fixedDuration=t:this.fixedDuration=_e.fromFrames(t):this.fixedDuration=void 0,this.trigger("frame",((a=this.fixedDuration)==null?void 0:a.frames)??0)}resize(t,a){var i;this.settings.width=t,this.settings.height=a,(i=this.renderer)==null||i.resize(t,a),this.canvas&&(this.canvas.height=a,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 a=typeof t=="object"?t:new t;return a.connect(this),this.stage.addChild(a.view),this.tracks.unshift(a),a.bubble(this),this.trigger("update",void 0),a}createTrack(t){const a=D0.fromType({type:t});return this.shiftTrack(a),a}async add(t){return await this.createTrack(t.type).add(t),t}remove(t){for(const a of this.tracks)if(a.clips.find(i=>i.id==t.id))return a.remove(t)}removeTracks(t){const a=this.tracks.filter(i=>i instanceof t);return this.tracks=this.tracks.filter(i=>!(i instanceof t)),a.forEach(i=>this.removeTrack(i)),a}findTracks(t){return this.tracks.filter(a=>{let i;return yl(t)?i=a instanceof t:i=t(a),i})}findClips(t){const a=[];for(const i of this.tracks)for(const r of i.clips){let s;yl(t)?s=r instanceof t:s=t(r),s&&a.push(r)}return a}computeFrame(){var t,a;if(this.renderer){for(let i=0;i<this.tracks.length;i++)this.tracks[i].update(_e.fromFrames(this.frame));this.renderer.render(this.stage),(t=this.context)==null||t.clearRect(0,0,this.settings.width,this.settings.height),(a=this.context)==null||a.drawImage(this.renderer.canvas,0,0),this.trigger("currentframe",this.frame),this.playing&&this.frame++}}screenshot(t="png",a=1){if(this.computeFrame(),!this.renderer)throw new ia({code:"rendererNotDefined",message:"Please wait until the renderer is defined"});return this.renderer.canvas.toDataURL(`image/${t}`,a)}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 a of this.tracks)await a.seek(_e.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(_e.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,a=48e3){var s;const i=this.duration.seconds*a,r=new OfflineAudioContext({sampleRate:a,length:i,numberOfChannels:t}).createBuffer(t,i,a);for(const l of this.findClips(qo)){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 m=await l.source.decode(t,a),f=m.numberOfChannels-1;for(let p=0;p<t;p++){const v=r.getChannelData(p),g=m.getChannelData(p>f?f:p);for(let k=0;k<v.length-1;k++)k<c+d||k>c+u||k-c<0||(v[k]+=(g[k-c]??0)*l.volume,v[k]>1&&(v[k]=1),v[k]<-1&&(v[k]=-1));r.getChannelData(p).set(v)}}catch{}}return r}time(t){const a=Qn(this.frame),i=t!=null&&t.hours?11:14,r=t!=null&&t.milliseconds?23:19;return new Date(a).toISOString().slice(i,r)+" / "+new Date(this.duration.millis).toISOString().slice(i,r)}removeTrack(t){const a=this.tracks.findIndex(i=>i.id==t.id);if(t.view.parent&&this.stage.removeChild(t.view),a!=null&&a>=0)return this.tracks.splice(a,1),this.trigger("detach",void 0),t.off("*"),t}async ticker(){const t=1e3/Aa;let a=performance.now(),i=0;do{const r=await new Promise(requestAnimationFrame);r-a<t-i||(i=Math.min(t,i+r-a-t),a=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 a;return((a=t.stop)==null?void 0:a.frames)??0}),0),this.computeFrame()}}function Y0(o,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]=o&255,t[13]=o>>8&255,t[14]=o>>16&255,t[15]=o>>24&255,t[16]=0,t[17]=0,t[18]=0,t}const Mr=[8e3,12e3,16e3,24e3,48e3],q0="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.wasm",K0="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.js";class Q0{constructor(n){X(this,"output");X(this,"error");X(this,"config");X(this,"encoder");X(this,"opus");X(this,"meta");this.output=n.output,this.error=n.error}async configure(n){const t=await import(K0),{numberOfChannels:a,sampleRate:i}=this.config=n;if(!Mr.includes(i))throw new zo({code:"sampleRateNotSupported",message:`Unsupported sample rate, supported: ${Mr.join()}`});this.opus=await t.default({locateFile(r,s){return r.endsWith(".wasm")?q0:s+r}}),this.encoder=this.opus._opus_encoder_create(i,a,2048),this.meta={decoderConfig:{codec:"opus",description:Y0(i,a).buffer,numberOfChannels:a,sampleRate:i}}}encode({data:n,numberOfFrames:t,timestamp:a=0}){if(!this.encoder||!this.opus||!this.config||!this.meta)throw new zo({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 m=4e3,f=this.opus._malloc(m),p=this.opus._opus_encode(this.encoder,u,s,f,m);if(p>0){const v=new Uint8Array(this.opus.HEAPU8.subarray(f,f+p));this.output({data:v,timestamp:a,type:"key",duration:c},this.meta)}else this.error(new DOMException("PCM chunk could not be encoded"));this.opus._free(u),this.opus._free(f),l+=s,a+=c}}}function eg(o){const n=Mr;let t=48e3;for(const a of n)Math.abs(o-a)<Math.abs(o-t)&&(t=a);return t}class tg{constructor(n,t){X(this,"canvas");X(this,"muxer");X(this,"videoEncoder");X(this,"frame",0);X(this,"sampleRate");X(this,"numberOfChannels");X(this,"videoBitrate");X(this,"gpuBatchSize");X(this,"fps");X(this,"height");X(this,"width");X(this,"audio");this.canvas=n,this.width=n.width,this.height=n.height,this.fps=(t==null?void 0:t.fps)??30,this.sampleRate=eg((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 Xv({height:Math.round(this.height),width:Math.round(this.width),bitrate:this.videoBitrate,fps:this.fps});this.muxer=new zc({target:new es,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:(a,i)=>{i&&this.muxer.addVideoChunk(a,i)},error:console.error};this.videoEncoder=new VideoEncoder(t),this.videoEncoder.configure(n[0])}async encodeVideo(n){var a;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)});(a=this.videoEncoder)==null||a.encode(t,{keyFrame:this.frame%(3*this.fps)==0}),t.close(),this.frame++}async encodeAudio(n){if(!this.audio)throw new zo({code:"initializationError",message:"Encoder must be initialized using {audio: true} to use this method"});this.muxer||await this.init();const t=Hv(n,this.sampleRate,this.numberOfChannels),a=new Q0({output:(i,r)=>{var s;(s=this.muxer)==null||s.addAudioChunkRaw(i.data,i.type,i.timestamp,i.duration,r)},error:console.error});await a.configure({numberOfChannels:this.numberOfChannels,sampleRate:this.sampleRate}),a.encode({data:Zv(t),numberOfFrames:t.length})}async blob(){var t,a,i;await((t=this.videoEncoder)==null?void 0:t.flush()),(a=this.muxer)==null||a.finalize();const n=(i=this.muxer)==null?void 0:i.target.buffer;if(!n)throw new zo({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 ng(o){var a,i;const n=(a=o.metadata)==null?void 0:a.source_url;if(n)return n;const t=(i=o.source)==null?void 0:i.media_uuid;if(t){if(typeof window<"u"){const r=window;if(r.MEDIABLES_MEDIA_URLS&&r.MEDIABLES_MEDIA_URLS[t])return r.MEDIABLES_MEDIA_URLS[t]}if(!t.startsWith("temp-"))try{if(typeof fetch<"u"){const r=await fetch(`/api/media/${t}`);if(r.ok){const s=await r.json();return s.playback_url||s.url||void 0}}}catch{}}}function jt(o,n){if(typeof o=="number"&&Number.isFinite(o))return o;if(typeof o=="string"){const t=Number(o);if(Number.isFinite(t))return t}return n}function ho(o){return o>5?o/100:o}function Wt(o,n,t){return Math.min(t,Math.max(n,o))}function Bt(){return new lt.ColorMatrixFilter}function ag(o,n){switch(o){case"brightness":{const t=Bt(),a=jt(n.value??n.brightness,1);return t.brightness(Wt(ho(a),0,5),!1),t}case"contrast":{const t=Bt(),a=jt(n.value??n.contrast,1);return t.contrast(Wt(ho(a),0,5),!1),t}case"saturation":{const t=Bt(),a=jt(n.value??n.saturation,1);return t.saturate(Wt(ho(a),0,5),!1),t}case"hue":{const t=Bt(),a=jt(n.degrees??n.value,0);return t.hue(Wt(a,-180,180),!1),t}case"blur":case"softFocus":{const t=o==="softFocus"?1:0,a=jt(n.radius??n.blur??n.value,t);return new lt.BlurFilter({strength:Wt(a,0,32),quality:4})}case"grayscale":{const t=Bt(),a=Wt(jt(n.amount,100),0,100);return a<=0?null:(a>=100?t.desaturate():t.saturate(1-a/100,!1),t)}case"sepia":{if(Wt(jt(n.amount,100),0,100)<=0)return null;const a=Bt();return a.sepia(!1),a}case"invert":{if(Wt(jt(n.amount,100),0,100)<=0)return null;const a=Bt();return a.negative(!1),a}case"warmth":{const t=Bt(),a=Wt(jt(n.value,0),-50,50);return a>0?(t.sepia(!1),t.saturate(1+a/100,!1)):a<0&&t.hue(Math.abs(a)/50*-20,!1),t}case"tint":{const t=Bt(),a=Wt(jt(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-a+a*s,0,0,0,0,0,1-a+a*l,0,0,0,0,0,1-a+a*c,0,0,0,0,0,1,0]}return t}case"vintage":{const t=Bt();return t.sepia(!1),t.saturate(1.4,!1),t.contrast(1.1,!1),t}case"blackAndWhite":{const t=Bt(),a=Wt(ho(jt(n.contrast,120)),.5,3);return t.desaturate(),t.contrast(a,!1),t}case"cinematic":{const t=Bt();return t.contrast(1.2,!1),t.brightness(.95,!1),t.saturate(.85,!1),t}case"dramatic":{const t=Bt();return t.contrast(1.4,!1),t.brightness(.9,!1),t.saturate(1.1,!1),t.sepia(!1),t}case"dreamy":{const t=Bt();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=lt);class ad{constructor(n=1920,t=1080,a=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=a,this.fitMode=(i==null?void 0:i.fitMode)??"contain",this.composition=new J0({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,m;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||(m=l==null?void 0:l.renderer)!=null&&m.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 a;const n=(a=this.player)==null?void 0:a.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 a,i,r;await this.initPromise,this.clips.clear(),this.recipeSourceDimensions=Number.isFinite((a=n.source)==null?void 0:a.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 ng(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);this.composition.seek(0),this.applyFitModeToClips(),this.composition.computeFrame()}async addTimelineClip(n,t){var a,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((a=Bn.from)==null?void 0:a.call(Bn,r,{crossOrigin:"anonymous"}))??await Bn.from(r),l=new Nr(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 f=Math.max(0,Math.floor((n.sourceIn||0)*this.fps)),p=n.sourceOut!==void 0?Math.max(f+1,Math.floor(n.sourceOut*this.fps)):null;c=f,d=p;try{if(l.offset=l.offset||{frames:0},l.offset.frames=f,p!==null){const v=Math.max(1,p-f);l.duration=l.duration||{frames:v},l.duration.frames=v}}catch{}}const u=await this.composition.add(l);if(d!==null&&c>=0)try{const f=Math.max(1,d-c);u.offset=u.offset||{frames:0},u.offset.frames=c,u.duration=u.duration||{frames:f},u.duration.frames=f}catch{}const m=Math.floor(n.timelineStart*this.fps);m>0&&u.offsetBy(m),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(f=>requestAnimationFrame(f)),this.applyFiltersToClip(n.id,n.filters))}catch{}}async addTextOverlay(n){try{const t=kt.fromFamily({family:n.fontFamily||"Arial",weight:n.fontWeight||"400"}),a=new sa({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?a.rotation=new Ie([s,l],[n.animation.rotation.from,n.animation.rotation.to],{easing:c}):n.animation.type==="scale"&&n.animation.scale&&(a.scale=new Ie([s,l],[n.animation.scale.from,n.animation.scale.to],{easing:c}))}n.startTime&&n.startTime>0&&a.offsetBy(n.startTime*this.fps),n.duration&&a.subclip(0,n.duration*this.fps);const i=await this.composition.add(a);this.clips.set(n.id||`text-${Date.now()}`,i)}catch{}}applyFiltersToClip(n,t){const a=this.clips.get(n);if(!a)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 m=null;if(u&&u.signature===d)m=u.instance;else{if(u)try{u.instance.destroy()}catch{}m=this.createPixiFilter(c),m?i.set(c.id,{instance:m,signature:d}):i.delete(c.id)}m&&s.push(m)}this.filterCache.set(n,i);const l=a.view??a.sprite??a.displayObject??null;if("filters"in a)try{a.filters=s}catch{}if(l&&"filters"in l)try{l.filters=s}catch{}typeof a.enter=="function"&&a.enter()}buildFilterSignature(n){const t=typeof n.params=="object"&&n.params!==null?n.params:{},a=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:a})}setClipFilters(n,t){this.applyFiltersToClip(n,t),this.composition.computeFrame()}createPixiFilter(n){const t=n.intensity??1,a=n.params||{};if(le.getFilter(n.filterId)&&!le.isFilterCompatibleWithMedia(n.filterId,"video"))return null;let r=Dm(n.filterId,a);return r||(r=ag(n.filterId,a)),r?(t!==1&&r&&(n.filterId==="colorOverlay"||n.filterId==="alpha"||("alpha"in r&&!a.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,m,f,p,v;const t=n.fps??this.fps,a=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)??((f=(m=this.composition)==null?void 0:m.renderer)==null?void 0:f.canvas);if(!a)throw new Error("Export failed: composition canvas is not initialized");(p=n.onProgress)==null||p.call(n,0);const i=new tg(a,{fps:t});await i.init();const r=await i.export();return(v=n.onProgress)==null||v.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 a=this.clips.get(n);if(!a)return;const i=this.clipTimelineStart.get(n)||0,r=t-i;r!==0&&(a.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,a;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)??((a=this.recipeSourceDimensions)==null?void 0:a.height);if(!l||!c)return;const d=Math.min(i/l,r/c),u=Math.max(i/l,r/c),m=this.fitMode==="contain"?d:u;n.scale=m}catch{}}trimClip(n,t,a){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(a*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,a;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:(((a=r.offset)==null?void 0:a.frames)??0)+u,clipId:i}}}return{sourceFrame:0,clipId:null}}}const og=["src"],ig={class:"preview-controls"},rg=["aria-label"],sg={class:"time-display"},lg={class:"current-time"},cg={class:"total-time"},dg={key:2,class:"loading-overlay"},ug={key:3,class:"error-overlay"},mg=e.defineComponent({__name:"VideoPreviewEngine",props:{mediaUuid:{},recipe:{},media:{},autoPlay:{type:Boolean,default:!1},enableEngine:{type:Boolean,default:!0},fitMode:{default:"contain"}},emits:["time-update","duration-change","play-state-change","error","engine-ready"],setup(o,{emit:n}){const t=o,a=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),m=e.ref(0),f=e.ref(0);let p=null;const v=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 S,D;return(S=t.media)!=null&&S.url?t.media.url:(((D=t.media)==null?void 0:D.file)instanceof File,"")});async function T(){var S,D,I;if(!(!r.value||!t.recipe))try{l.value=!0,c.value="Initializing video engine...";const j=((S=t.recipe.source)==null?void 0:S.original_width)||1920,O=((D=t.recipe.source)==null?void 0:D.original_height)||1080,F=((I=t.recipe.output)==null?void 0:I.fps)||30;p=new ad(j,O,F,{fitMode:t.fitMode}),p.attachPlayer(r.value),c.value="Loading composition...",await p.loadFromRecipe(t.recipe),f.value=p.durationInSeconds,a("duration-change",f.value),V(),l.value=!1,a("engine-ready",p),t.autoPlay&&(p.play(),u.value=!0)}catch(j){const O=j instanceof Error?j.message:String(j);d.value=`Failed to initialize: ${O}`,l.value=!1}}function V(){if(!p)return;const S=setInterval(()=>{p&&u.value&&(m.value=p.currentTimeInSeconds,a("time-update",m.value))},100);P.value=S}function b(){v.value&&p?(u.value?p.pause():p.play(),u.value=!u.value,a("play-state-change",u.value)):s.value&&(u.value?s.value.pause():s.value.play(),u.value=!u.value,a("play-state-change",u.value))}function h(S){const D=Math.floor(S/60),I=Math.floor(S%60);return`${D}:${I.toString().padStart(2,"0")}`}function _(){d.value=null,v.value&&T()}function R(){!v.value&&s.value&&(f.value=s.value.duration,a("duration-change",f.value))}function M(){!v.value&&s.value&&(m.value=s.value.currentTime,a("time-update",m.value))}function x(){u.value=!1,a("play-state-change",!1)}function C(S){d.value="Failed to load video",a("error",d.value)}e.onMounted(()=>{v.value&&t.recipe&&T()}),e.onUnmounted(()=>{p&&(p.destroy(),p=null),P.value&&(clearInterval(P.value),P.value=null),s.value&&(s.value.pause(),s.value.removeAttribute("src"),s.value.load())}),e.watch(()=>t.recipe,async S=>{if(v.value&&S)if(p)try{await p.loadFromRecipe(S),f.value=p.durationInSeconds,a("duration-change",f.value)}catch{}else await T()}),e.watch(()=>t.enableEngine,async S=>{S?await T():p&&(P.value&&(clearInterval(P.value),P.value=null),p.destroy(),p=null)}),e.watch(()=>t.fitMode,async S=>{if(!(!v.value||!p))try{p.setFitMode(S||"contain")}catch{}});const P=e.ref(null);return(S,D)=>(e.openBlock(),e.createElementBlock("div",{class:"video-preview-engine",ref_key:"containerRef",ref:i},[v.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:R,onTimeupdate:M,onEnded:x,onError:C,style:e.normalizeStyle({width:"100%",height:"100%",objectFit:g.value}),playsinline:"",controls:""},null,44,og)),e.createElementVNode("div",ig,[e.createElementVNode("button",{class:"play-button",onClick:b,"aria-label":u.value?"Pause":"Play"},[e.createVNode(e.unref(U.IonIcon),{icon:u.value?e.unref(kc):e.unref(_c)},null,8,["icon"])],8,rg),e.createElementVNode("div",sg,[e.createElementVNode("span",lg,e.toDisplayString(h(m.value)),1),D[0]||(D[0]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",cg,e.toDisplayString(h(f.value)),1)])]),l.value?(e.openBlock(),e.createElementBlock("div",dg,[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",ug,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Gr)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(d.value),1),e.createElementVNode("button",{onClick:_},"Retry")])):e.createCommentVNode("",!0)],512))}}),Br=Te(mg,[["__scopeId","data-v-7e604791"]]),pg=["aria-label"],fg=["aria-label"],hg={class:"clip-content"},vg={key:0,class:"clip-thumbnail"},gg=["src","alt"],yg={class:"clip-waveform"},bg={class:"clip-info"},wg={class:"clip-label"},kg={class:"clip-duration"},_g={key:1,class:"filter-indicators"},Eg={key:2,class:"speed-indicator"},xg={key:0,class:"selection-overlay"},Cg=420,Sg=8,Vg=e.defineComponent({__name:"TimelineClip",props:{clip:{},scale:{},scrollOffset:{default:0},selected:{type:Boolean,default:!1},isMobile:{type:Boolean,default:!1}},emits:["select","long-press","trim-start","trim-end","drag","trim-start-abs","trim-end-abs","drag-abs"],setup(o,{emit:n}){const t=o,a=n,i=e.ref(),r=e.ref(!1),s=e.ref(null),l=e.ref(0),c=e.ref(0),d=e.ref(0),u=e.ref(0),m=e.ref(!1),f=e.ref(!1),p=e.ref(null),v=e.computed(()=>{const w=(t.clip.timelineEnd-t.clip.timelineStart)*t.scale;return{left:`${t.clip.timelineStart*t.scale-t.scrollOffset}px`,width:`${w}px`}}),g=e.computed(()=>t.clip.label||`Clip ${t.clip.id.slice(-4)}`),k=e.computed(()=>{const B=t.clip.timelineEnd-t.clip.timelineStart;return b(B)}),T=e.computed(()=>t.clip.filters&&t.clip.filters.length>0),V=e.computed(()=>t.clip.filters||[]);function b(B){if(B<1)return`${Math.round(B*30)}f`;if(B<60)return`${B.toFixed(1)}s`;{const w=Math.floor(B/60),$=Math.floor(B%60);return`${w}:${$.toString().padStart(2,"0")}`}}function h(B){return!B||typeof B!="string"?ml:B.includes("color")||B.includes("brightness")?yn:B.includes("blur")?mp:B.includes("style")?xa:B.includes("effect")?gn:ml}function _(){r.value||a("select")}function R(B){B.button===0&&(C("move",B.clientX),B.preventDefault())}function M(B){if(B.touches.length!==1)return;const w=B.touches[0];if(!t.isMobile){C("move",w.clientX),B.preventDefault();return}d.value=w.clientX,u.value=w.clientY,m.value=!1,f.value=!1,P(),S(),p.value=window.setTimeout(()=>{f.value=!0,S(),t.selected||a("select"),a("long-press")},Cg),document.addEventListener("touchmove",D),document.addEventListener("touchend",I),document.addEventListener("touchcancel",I),B.preventDefault()}function x(B,w){const $="touches"in w?w.touches[0].clientX:w.clientX;s.value=B==="start"?"trim-start":"trim-end",C(s.value,$),w.preventDefault(),w.stopPropagation()}function C(B,w){P(),S(),r.value=!0,s.value=B,l.value=w,B==="move"?c.value=t.clip.timelineStart:B==="trim-start"?c.value=t.clip.sourceIn:B==="trim-end"&&(c.value=t.clip.sourceOut),document.addEventListener("mousemove",j),document.addEventListener("mouseup",O),document.addEventListener("touchmove",j),document.addEventListener("touchend",O),t.selected||a("select")}function P(){p.value!==null&&(window.clearTimeout(p.value),p.value=null)}function S(){document.removeEventListener("touchmove",D),document.removeEventListener("touchend",I),document.removeEventListener("touchcancel",I)}function D(B){if(B.touches.length!==1)return;const w=B.touches[0],$=w.clientX-d.value,z=w.clientY-u.value;Math.hypot($,z)<Sg||(m.value=!0,P(),S(),C("move",w.clientX),j(B),B.preventDefault())}function I(){const B=!m.value&&!f.value&&!r.value;P(),S(),m.value=!1,f.value=!1,B&&a("select")}function j(B){if(!r.value||!s.value)return;const w="touches"in B?B.touches[0].clientX:B.clientX,z=w-l.value;s.value==="move"?(a("drag",z),a("drag-abs",w)):s.value==="trim-start"?(a("trim-start",z),a("trim-start-abs",w)):s.value==="trim-end"&&(a("trim-end",z),a("trim-end-abs",w))}function O(){r.value=!1,s.value=null,document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",O),document.removeEventListener("touchmove",j),document.removeEventListener("touchend",O)}function F(){if(!i.value)return;const B=i.value,w=B.getContext("2d");if(!w)return;B.width=B.clientWidth*window.devicePixelRatio,B.height=B.clientHeight*window.devicePixelRatio,w.scale(window.devicePixelRatio,window.devicePixelRatio),w.strokeStyle="rgba(255, 255, 255, 0.3)",w.lineWidth=1,w.beginPath();const $=B.clientWidth,z=B.clientHeight,W=z/2;w.moveTo(0,W),w.lineTo($,W);for(let Q=0;Q<$;Q+=4){const ye=Math.sin(Q*.05)*(z*.3);w.moveTo(Q,W-ye),w.lineTo(Q,W+ye)}w.stroke()}return e.onMounted(()=>{F(),window.addEventListener("resize",F)}),e.onUnmounted(()=>{O(),P(),S(),window.removeEventListener("resize",F)}),(B,w)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-clip",{selected:B.selected,mobile:B.isMobile,"has-filters":T.value}]),style:e.normalizeStyle(v.value),onClick:_,onMousedown:R,onTouchstart:M},[e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:w[0]||(w[0]=e.withModifiers($=>x("start",$),["stop"])),onTouchstart:w[1]||(w[1]=e.withModifiers($=>x("start",$),["stop"])),"aria-label":`Trim start of ${B.clip.label||"clip"}`},[...w[4]||(w[4]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,pg),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:w[2]||(w[2]=e.withModifiers($=>x("end",$),["stop"])),onTouchstart:w[3]||(w[3]=e.withModifiers($=>x("end",$),["stop"])),"aria-label":`Trim end of ${B.clip.label||"clip"}`},[...w[5]||(w[5]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,fg),e.createElementVNode("div",hg,[B.clip.thumbnail?(e.openBlock(),e.createElementBlock("div",vg,[e.createElementVNode("img",{src:B.clip.thumbnail,alt:B.clip.label||"Video clip"},null,8,gg)])):e.createCommentVNode("",!0),e.createElementVNode("div",yg,[e.createElementVNode("canvas",{ref_key:"waveformCanvas",ref:i},null,512)]),e.createElementVNode("div",bg,[e.createElementVNode("span",wg,e.toDisplayString(g.value),1),e.createElementVNode("span",kg,e.toDisplayString(k.value),1)]),T.value?(e.openBlock(),e.createElementBlock("div",_g,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(V.value,$=>(e.openBlock(),e.createBlock(e.unref(U.IonIcon),{key:$.id||$.filterId,icon:h($.filterId||$.id),title:`Filter: ${$.filterId||$.id}`},null,8,["icon","title"]))),128))])):e.createCommentVNode("",!0),B.clip.speed&&B.clip.speed!==1?(e.openBlock(),e.createElementBlock("div",Eg,e.toDisplayString(B.clip.speed)+"x ",1)):e.createCommentVNode("",!0)]),B.selected?(e.openBlock(),e.createElementBlock("div",xg)):e.createCommentVNode("",!0)],38))}}),Ng=Te(Vg,[["__scopeId","data-v-be208792"]]);class od{constructor(n=30){this.fps=30,this.fps=n}setFps(n){this.fps=n}async convertTimelineClipToEngine(n,t){const a=new Nr(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):a.duration.frames;a.subclip(i,r)}return n.timelineStart&&n.timelineStart>0&&a.offsetBy(this.secondsToFrames(n.timelineStart)),n.transform&&this.applyTransformations(a,n.transform),a}convertEngineClipToTimeline(n,t,a){const i=this.framesToSeconds(n.duration.frames),r=n.offset?this.framesToSeconds(n.offset.frames):0;return{id:t,url:a,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 a;(a=t.clear)==null||a.call(t);for(const i of n.timeline)try{if(!i.url)continue;const r=await Bn.from(i.url),s=await this.convertTimelineClipToEngine(i,r);await t.add(s)}catch{}n.duration&&(t.duration=_e.fromFrames(this.secondsToFrames(n.duration)))}extractTimelineFromComposition(n){const t=[];return(n.clips||[]).forEach((i,r)=>{var s,l;i instanceof Nr&&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),a=Math.floor(t/60),i=Math.floor(t%60),r=Math.floor(t%1*1e3);return`${a.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}.${r.toString().padStart(3,"0")}`}formatTime(n){const t=Math.floor(n/3600),a=Math.floor(n%3600/60),i=Math.floor(n%60);return`${t.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`}parseTime(n){const t=n.split(":");let a=0;if(t.length===2){const[i,r]=t;a=parseInt(i)*60+parseFloat(r)}else if(t.length===3){const[i,r,s]=t;a=parseInt(i)*3600+parseInt(r)*60+parseFloat(s)}else a=parseFloat(n);return a}timeToFrames(n){const t=n.split(":");let a=0;if(t.length===2){const[i,r]=t;a=parseInt(i)*60+parseFloat(r)}else if(t.length===3){const[i,r,s]=t;a=parseInt(i)*3600+parseInt(r)*60+parseFloat(s)}else a=parseFloat(n);return this.secondsToFrames(a)}}const Tg={class:"time-markers"},Mg=["aria-label","title"],Bg={key:0,class:"timeline-scrollbar"},Fg=e.defineComponent({__name:"VideoTimeline",props:{playhead:{},clips:{},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-move","clip-long-press","snap-state-change","toggle-frame-mode"],setup(o,{expose:n,emit:t}){const a=o,i=e.computed(()=>a.isMobile===!0),r=t,s=e.ref(),l=e.ref(a.selectedClipId||null),c=e.ref(!1),d=e.ref(0),u=e.ref(),m=e.ref(0),f=e.computed(()=>a.selectedClipId??l.value);e.watch(()=>a.selectedClipId,G=>{G!==void 0&&(l.value=G)});const p=new od(a.fps);e.watch(()=>a.fps,G=>{p.setFps(G)});const v=e.ref(!1),g=e.ref(null),k=e.ref(0),T=e.ref(0),V=e.ref(null),b=e.ref(0),h=e.ref(0),_=e.ref(0),R=e.ref(!1),M=e.ref(0),x=e.ref(a.zoomLevel),C=e.computed(()=>a.zoomLevel);function P(G){const q=a.clips.find(J=>J.id===G);if(!q)return null;const A=a.clips.filter(J=>J.id!==G&&J.timelineStart>=q.timelineEnd-1e-9).map(J=>J.timelineStart);return A.length?Math.min(...A):null}function S(G){const q=G.sourceMaxOut??a.duration,A=G.timelineStart+(q-G.sourceIn),J=P(G.id),ae=J!=null?Math.max(G.timelineStart,J):1/0;return Math.min(A,ae)}function D(G){const q=G.sourceMinIn??0,J=(G.sourceMaxOut??a.duration)-q,ae=G.sourceIn-q;return{left:`${(G.timelineStart-ae)*C.value-d.value}px`,width:`${J*C.value}px`,top:"0px",height:"80px",opacity:f.value===G.id?.25:.15}}const I=e.computed(()=>a.useFrameMode?a.zoomLevel:a.zoomLevel/a.fps),j=e.computed(()=>p.secondsToFrames(a.duration)),O=e.computed(()=>a.useFrameMode?j.value*I.value:a.duration*C.value),F=e.computed(()=>{var G;return m.value||((G=s.value)==null?void 0:G.clientWidth)||800}),B=e.computed(()=>O.value>F.value),w=e.computed(()=>Math.max(0,O.value-F.value)),$=e.computed(()=>d.value>0),z=e.computed(()=>d.value<w.value),W=e.computed(()=>a.useFrameMode?p.secondsToFrames(a.playhead)*I.value-d.value:a.playhead*C.value-d.value),Q=e.computed(()=>V.value===null?null:a.useFrameMode?p.secondsToFrames(V.value)*I.value-d.value:V.value*C.value-d.value),ye=e.computed(()=>{const G=Math.max(50,F.value/O.value*F.value),q=d.value/w.value*(F.value-G);return{width:`${G}px`,left:`${q}px`}}),we=e.computed(()=>{const G=[],q=ie();for(let A=0;A<=a.duration;A+=q){const J=A*C.value-d.value;J>=-50&&J<=F.value+50&&G.push({position:J,label:N(A),time:A})}return G});function ie(){const q=80/C.value;return q<=1?1:q<=5?5:q<=10?10:q<=30?30:q<=60?60:Math.ceil(q/60)*60}function N(G){if(a.useFrameMode)return`F${p.secondsToFrames(G)}`;{const q=Math.floor(G/60),A=Math.floor(G%60),J=Math.floor(G%1*a.fps);return C.value>100?`${q}:${A.toString().padStart(2,"0")}:${J.toString().padStart(2,"0")}`:`${q}:${A.toString().padStart(2,"0")}`}}function L(G){const q=s.value.getBoundingClientRect();let J=(G.clientX-q.left+d.value)/C.value;const ae=a.clips.find(se=>J>=se.timelineStart&&J<=se.timelineEnd);if(ae)J=Math.max(ae.timelineStart,Math.min(ae.timelineEnd,J));else if(a.selectedClipId){const se=a.clips.find(Ce=>Ce.id===a.selectedClipId);if(se){const Ce=Math.abs(J-se.timelineStart),Ae=Math.abs(J-se.timelineEnd);J=Ce<Ae?se.timelineStart:se.timelineEnd}}else J=Math.max(0,Math.min(J,a.duration));r("update:playhead",J)}function te(G){if(!B.value)return;const q=Math.abs(G.deltaX)>Math.abs(G.deltaY)?G.deltaX:G.deltaY;q!==0&&(G.preventDefault(),d.value=Math.max(0,Math.min(w.value,d.value+q)))}function ne(){return[...a.clips].sort((G,q)=>G.timelineStart-q.timelineStart)}function re(G){const q=ne(),A=q.findIndex(J=>J.id===G);return{previous:A>0?q[A-1]:null,next:A!==-1&&A<q.length-1?q[A+1]:null}}function he(G){const q=G.timelineEnd-G.timelineStart,{previous:A,next:J}=re(G.id),ae=A?A.timelineEnd:0,se=J?J.timelineStart-q:Math.max(G.timelineStart,a.duration-q);return{minStart:ae,maxStart:Math.max(ae,se)}}function de(){return 12/Math.max(C.value,1)}function me(G){return Array.from(new Set(G.filter(q=>typeof q=="number"&&Number.isFinite(q))))}function Ve(G,q,A,J){const ae=Math.max(A,Math.min(G,J));if(!a.snapEnabled)return{value:ae,guideTime:null};const se=de();let Ce=ae,Ae=null,De=Number.POSITIVE_INFINITY;for(const Le of me(q)){if(Le<A||Le>J)continue;const Ue=Math.abs(Le-ae);Ue<=se&&Ue<De&&(Ce=Le,Ae=Le,De=Ue)}return{value:Ce,guideTime:Ae}}function ce(G){if(G.touches.length===2){R.value=!0;const q=G.touches[0],A=G.touches[1];M.value=Math.hypot(A.clientX-q.clientX,A.clientY-q.clientY),x.value=a.zoomLevel}else G.touches.length===1&&(b.value=G.touches[0].clientX,h.value=G.touches[0].clientY,_.value=b.value)}function pe(G){if(R.value&&G.touches.length===2){const q=G.touches[0],A=G.touches[1],ae=Math.hypot(A.clientX-q.clientX,A.clientY-q.clientY)/M.value;Math.max(10,Math.min(200,x.value*ae)),r("update:playhead",a.playhead)}else if(G.touches.length===1&&!R.value){const q=G.touches[0],A=_.value-q.clientX;Math.abs(A)>Math.abs(q.clientY-h.value)&&(G.preventDefault(),d.value=Math.max(0,Math.min(O.value-F.value,d.value+A)),_.value=q.clientX)}}function xe(){R.value=!1}function Fe(G){const q=G.target;if(q.closest(".playhead-handle"))return;const A=G.button===1,J=!!q.closest(".video-track");(A||!J&&B.value)&&ut(G)}function ut(G){v.value=!0,g.value="pan",k.value=G.clientX,T.value=d.value,document.addEventListener("mousemove",ot),document.addEventListener("mouseup",at)}function tt(G){G.preventDefault(),G.stopPropagation(),v.value=!0,g.value="playhead";const q="touches"in G?G.touches[0].clientX:G.clientX;k.value=q,T.value=a.playhead,"touches"in G?(document.addEventListener("touchmove",ot),document.addEventListener("touchend",at)):(document.addEventListener("mousemove",ot),document.addEventListener("mouseup",at))}function Et(G){G.preventDefault(),G.stopPropagation(),v.value=!0,g.value="scrollbar";const q="touches"in G?G.touches[0].clientX:G.clientX;k.value=q,T.value=d.value,"touches"in G?(document.addEventListener("touchmove",ot),document.addEventListener("touchend",at)):(document.addEventListener("mousemove",ot),document.addEventListener("mouseup",at))}function ot(G){if(!v.value)return;const A=("touches"in G?G.touches[0].clientX:G.clientX)-k.value;if(g.value==="playhead"){const J=A/C.value;let ae=T.value+J;if(a.selectedClipId){const se=a.clips.find(Ce=>Ce.id===a.selectedClipId);se?ae=Math.max(se.timelineStart,Math.min(se.timelineEnd,ae)):ae=Math.max(0,Math.min(a.duration,ae))}else{const se=a.clips.find(Ce=>a.playhead>=Ce.timelineStart&&a.playhead<=Ce.timelineEnd);se?ae=Math.max(se.timelineStart,Math.min(se.timelineEnd,ae)):ae=Math.max(0,Math.min(a.duration,ae))}r("update:playhead",ae)}else if(g.value==="scrollbar"){const J=A/F.value*O.value;d.value=Math.max(0,Math.min(w.value,T.value+J))}else if(g.value==="pan"){const J=T.value-A;d.value=Math.max(0,Math.min(w.value,J))}}function at(){v.value=!1,g.value=null,V.value=null,document.removeEventListener("mousemove",ot),document.removeEventListener("mouseup",at),document.removeEventListener("touchmove",ot),document.removeEventListener("touchend",at)}function bt(G){l.value=l.value===G?null:G,r("clip-select",l.value)}function Vt(G){l.value=G,r("clip-select",G),r("clip-long-press",G)}function vt(G,q){const A=a.clips.find(ae=>ae.id===G);if(!A||Math.abs(q)<2)return;const J=q/C.value*a.sensitivity;if(a.useFrameMode){const ae=p.secondsToFrames(A.sourceIn),se=p.secondsToFrames(J),Ce=Math.max(0,ae+se),Ae=p.framesToSeconds(Ce);r("trim",G,"start",Ae)}else{const ae=Math.max(0,A.sourceIn+J);r("trim",G,"start",ae)}}function st(G,q){const A=a.clips.find(xt=>xt.id===G);if(!A||!s.value)return;const J=s.value.getBoundingClientRect(),ae=q-J.left,se=80;if(ae<se)d.value=Math.max(0,d.value-8);else if(ae>J.width-se){const xt=Math.max(0,O.value-F.value);d.value=Math.min(xt,d.value+8)}const Ce=ae+d.value,Ae=1/a.fps;let De=Ce/C.value;const{previous:Le}=re(A.id),Ue=Ve(De,[0,Le==null?void 0:Le.timelineEnd,a.playhead],0,A.timelineEnd-Ae);De=Ue.value,V.value=Ue.guideTime;let Ke=A.sourceIn+(De-A.timelineStart);Ke=Math.round(Ke*a.fps)/a.fps,r("trim",G,"start",Ke)}function ve(G,q){const A=a.clips.find(zt=>zt.id===G);if(!A||!s.value)return;const J=s.value.getBoundingClientRect(),ae=q-J.left,se=80;if(ae<se)d.value=Math.max(0,d.value-8);else if(ae>J.width-se){const zt=Math.max(0,O.value-F.value);d.value=Math.min(zt,d.value+8)}const Ce=ae+d.value,Ae=1/a.fps,De=S(A);let Le=Ce/C.value;const{next:Ue}=re(A.id),Ke=Ve(Le,[Ue==null?void 0:Ue.timelineStart,a.playhead],A.timelineStart+Ae,De);Le=Ke.value,V.value=Ke.guideTime;let xt=A.sourceIn+(Le-A.timelineStart);xt=Math.round(xt*a.fps)/a.fps,r("trim",G,"end",xt)}function Ee(G,q){const A=a.clips.find(Ke=>Ke.id===G);if(!A||!s.value)return;const J=s.value.getBoundingClientRect(),ae=q-J.left,se=80;if(ae<se)d.value=Math.max(0,d.value-8);else if(ae>J.width-se){const Ke=Math.max(0,O.value-F.value);d.value=Math.min(Ke,d.value+8)}const Ce=ae+d.value,Ae=A.timelineEnd-A.timelineStart,De=he(A);let Le=Ce/C.value;const Ue=Ve(Le,[De.minStart,De.maxStart,a.playhead,a.playhead-Ae],De.minStart,De.maxStart);Le=Ue.value,V.value=Ue.guideTime,Le=Math.round(Le*a.fps)/a.fps,r("clip-move",G,Le)}function Ne(G,q){const A=a.clips.find(se=>se.id===G);if(!A||Math.abs(q)<2)return;const J=q/C.value*a.sensitivity,ae=se=>Math.max(0,Math.round(se*a.fps)/a.fps);if(a.useFrameMode){const se=p.secondsToFrames(A.sourceOut),Ce=p.secondsToFrames(J),Ae=S(A),De=A.sourceIn+(Ae-A.timelineStart),Le=p.secondsToFrames(De),Ue=Math.min(Le,se+Ce),Ke=p.framesToSeconds(Ue);r("trim",G,"end",Ke)}else{const se=S(A),Ce=A.sourceIn+(se-A.timelineStart),Ae=Math.min(Ce,A.sourceOut+J),De=ae(Ae);r("trim",G,"end",De)}}function je(G,q){const A=a.clips.find(se=>se.id===G);if(!A||Math.abs(q)<2)return;const J=q/C.value*a.sensitivity,ae=se=>Math.max(0,Math.round(se*a.fps)/a.fps);if(a.useFrameMode){const se=p.secondsToFrames(A.timelineStart),Ce=p.secondsToFrames(J),Ae=Math.max(0,se+Ce),De=p.framesToSeconds(Ae);r("clip-move",G,De)}else{const se=Math.max(0,A.timelineStart+J),Ce=ae(se);r("clip-move",G,Ce)}}return n({handleTrimStart:vt,handleTrimEnd:Ne,handleClipDrag:je,handleTrimStartAbs:st,handleTrimEndAbs:ve,handleClipDragAbs:Ee,handleClipLongPress:Vt}),e.watch(()=>a.playhead,G=>{const q=G*C.value;q<d.value+50?d.value=Math.max(0,q-50):q>d.value+F.value-50&&(d.value=Math.min(w.value,q-F.value+50))}),e.onMounted(()=>{const G=new ResizeObserver(q=>{q[0]&&(m.value=Math.round(q[0].contentRect.width))});s.value&&G.observe(s.value),e.onUnmounted(()=>G.disconnect())}),e.onUnmounted(()=>{at()}),e.watch([O,F],()=>{d.value>w.value&&(d.value=w.value)}),e.watch(V,(G,q)=>{const A=G!==null;A!==(q!==null)&&r("snap-state-change",A)}),(G,q)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-timeline",{mobile:i.value}]),ref_key:"timelineRef",ref:s,onWheel:te},[e.createElementVNode("div",{class:"timeline-ruler",onClick:L},[e.createElementVNode("div",Tg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(we.value,A=>(e.openBlock(),e.createElementBlock("span",{key:A.position,class:"time-marker",style:e.normalizeStyle({left:`${A.position}px`})},e.toDisplayString(A.label),5))),128))])]),e.createElementVNode("div",{class:e.normalizeClass(["timeline-content",{"is-pannable":B.value,"is-panning":v.value&&g.value==="pan","overflow-left":$.value,"overflow-right":z.value}]),onTouchstart:ce,onTouchmove:pe,onTouchend:xe,onMousedown:Fe},[e.createElementVNode("div",{class:"video-track",ref_key:"trackRef",ref:u},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(G.clips,A=>(e.openBlock(),e.createElementBlock("div",{key:`${A.id}-extent`,class:"clip-extent",style:e.normalizeStyle(D(A)),"aria-hidden":"true"},null,4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(G.clips,A=>(e.openBlock(),e.createBlock(Ng,{key:A.id,clip:A,scale:C.value,"scroll-offset":d.value,selected:f.value===A.id,"is-mobile":i.value,onSelect:J=>bt(A.id),onLongPress:J=>Vt(A.id),onTrimStartAbs:J=>st(A.id,J),onTrimEndAbs:J=>ve(A.id,J),onDragAbs:J=>Ee(A.id,J)},null,8,["clip","scale","scroll-offset","selected","is-mobile","onSelect","onLongPress","onTrimStartAbs","onTrimEndAbs","onDragAbs"]))),128))],512),e.createElementVNode("div",{class:"playhead",style:e.normalizeStyle({left:`${W.value}px`}),onMousedown:tt,onTouchstart:tt},[...q[1]||(q[1]=[e.createElementVNode("div",{class:"playhead-handle"},[e.createElementVNode("div",{class:"playhead-line"})],-1)])],36),c.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"split-indicator",style:e.normalizeStyle({left:`${W.value}px`})},null,4)):e.createCommentVNode("",!0),Q.value!==null?(e.openBlock(),e.createElementBlock("div",{key:1,class:"snap-guide",style:e.normalizeStyle({left:`${Q.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0),i.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:2,class:"frame-mode-toggle",onClick:q[0]||(q[0]=A=>G.$emit("toggle-frame-mode")),"aria-label":G.useFrameMode?"Switch to time mode":"Switch to frame mode",title:G.useFrameMode?"Switch to time mode":"Switch to frame mode"},e.toDisplayString(G.useFrameMode?"F":"T"),9,Mg))],34),B.value?(e.openBlock(),e.createElementBlock("div",Bg,[e.createElementVNode("div",{class:"scrollbar-thumb",style:e.normalizeStyle(ye.value),onMousedown:Et,onTouchstart:Et},null,36)])):e.createCommentVNode("",!0)],34))}}),Fr=Te(Fg,[["__scopeId","data-v-5f5fb3e0"]]),Ig={class:"control-group zoom-controls"},$g={class:"zoom-slider"},Rg=["value"],Dg={class:"control-group playback-controls"},Ag=["aria-label"],Lg={key:0,class:"control-group speed-control"},Ug=["value"],Og=e.defineComponent({__name:"TimelineControls",props:{selectedClip:{},canSplit:{type:Boolean,default:!1},canDelete:{type:Boolean,default:!1},isPlaying:{type:Boolean,default:!1},zoomLevel:{default:50},playbackSpeed:{default:1},isMobile:{type:Boolean,default:!1}},emits:["split","delete","duplicate","zoom-in","zoom-out","zoom-change","fit-to-window","play-pause","frame-forward","frame-backward","skip-to-start","skip-to-end","speed-change"],setup(o,{emit:n}){const t=n;function a(u){const m=u.target;t("zoom-change",Number(m.value))}function i(){t("fit-to-window")}function r(){t("frame-forward")}function s(){t("frame-backward")}function l(){t("skip-to-start")}function c(){t("skip-to-end")}function d(u){const m=u.target;t("speed-change",Number(m.value))}return(u,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-controls",{mobile:u.isMobile}])},[e.createElementVNode("div",Ig,[e.createElementVNode("button",{class:"control-button zoom-button",onClick:m[0]||(m[0]=f=>u.$emit("zoom-out")),"aria-label":"Zoom out"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Vp)},null,8,["icon"])]),e.createElementVNode("div",$g,[e.createElementVNode("input",{type:"range",value:u.zoomLevel,onInput:a,min:"10",max:"200",step:"5","aria-label":"Timeline zoom"},null,40,Rg)]),e.createElementVNode("button",{class:"control-button zoom-button",onClick:m[1]||(m[1]=f=>u.$emit("zoom-in")),"aria-label":"Zoom in"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Qm)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:i,"aria-label":"Fit timeline to window"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(up)},null,8,["icon"]),m[3]||(m[3]=e.createElementVNode("span",{class:"control-label"},"Fit",-1))])]),e.createElementVNode("div",Dg,[e.createElementVNode("button",{class:"control-button",onClick:l,"aria-label":"Skip to start"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Cp)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:s,"aria-label":"Previous frame"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(kp)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button play-button",onClick:m[2]||(m[2]=f=>u.$emit("play-pause")),"aria-label":u.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(U.IonIcon),{icon:u.isPlaying?e.unref(Jr):e.unref(Yr)},null,8,["icon"])],8,Ag),e.createElementVNode("button",{class:"control-button",onClick:r,"aria-label":"Next frame"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(xp)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:c,"aria-label":"Skip to end"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Sp)},null,8,["icon"])])]),u.isMobile?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Lg,[m[5]||(m[5]=e.createElementVNode("label",{class:"speed-label"},"Speed:",-1)),e.createElementVNode("select",{value:u.playbackSpeed,onChange:d,class:"speed-select","aria-label":"Playback speed"},[...m[4]||(m[4]=[e.createStaticVNode('<option value="0.25" data-v-7bf65ab9>0.25x</option><option value="0.5" data-v-7bf65ab9>0.5x</option><option value="1" data-v-7bf65ab9>1x</option><option value="1.5" data-v-7bf65ab9>1.5x</option><option value="2" data-v-7bf65ab9>2x</option>',5)])],40,Ug)]))],2))}}),id=Te(Og,[["__scopeId","data-v-7bf65ab9"]]),Pg={key:0,class:"category-section"},zg={class:"category-carousel-wrapper"},jg=["disabled"],Wg=["onClick","data-testid","aria-label"],Zg={class:"category-name"},Hg=["disabled"],Xg={class:"filter-section"},Gg={class:"filter-carousel-wrapper"},Jg=["disabled"],Yg=["onClick","onKeydown","data-testid","aria-label"],qg=["onClick"],Kg={class:"filter-preview"},Qg={class:"filter-placeholder"},e1={class:"filter-name"},t1=["disabled"],n1={class:"carousel-pagination"},a1=["onClick"],o1={key:1,class:"filter-adjustments"},i1={class:"adjustment-header"},r1={class:"adjustment-actions"},s1={key:0},l1={key:0,class:"slider-control"},c1={class:"control-label"},d1={class:"slider-wrapper"},u1={class:"slider-value"},m1={key:1,class:"color-control"},p1={class:"control-label"},f1={class:"color-wrapper"},h1=["value","onInput","disabled"],v1={class:"color-value"},g1={key:2,class:"toggle-control"},y1={class:"control-label"},b1={key:3,class:"select-control"},w1={class:"control-label"},k1=["value","onChange","disabled"],_1=["value"],E1={key:1,class:"no-params"},x1=e.defineComponent({__name:"VideoFilterCarousel",props:{filters:{},activeFilters:{},thumbnailUrl:{},showCategories:{type:Boolean,default:!0},compact:{type:Boolean,default:!1}},emits:["apply-filter","remove-filter","update-param","preview-filter"],setup(o,{emit:n}){const t=o,a=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(),m={all:gn,adjust:ya,color:yn,blur:co,light:ba,effects:Ji,stylize:xa,advanced:gn,distortion:Ca,transform:Ca};function f(w){return w.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function p(w){return w.replace(/[-_]/g," ").replace(/\b\w/g,$=>$.toUpperCase())}function v(w){return m[w.toLowerCase()]??gn}const g=e.computed(()=>{const w=Array.from(new Set(t.filters.map($=>$.category).filter($=>typeof $=="string"&&$.length>0))).sort(($,z)=>$.localeCompare(z));return[{id:"all",name:"All",icon:gn},...w.map($=>({id:$,name:p($),icon:v($)}))]}),k=e.computed(()=>i.value==="all"?t.filters:t.filters.filter(w=>w.category===i.value));e.watch(g,w=>{new Set(w.map(W=>W.id)).has(i.value)||(i.value="all");const z=Math.max(0,w.length-3);s.value>z&&(s.value=z)},{immediate:!0});function T(w){var $;return(($=t.activeFilters)==null?void 0:$.has(w))||!1}function V(w){if(r.value=w,!T(w.id)&&(a("apply-filter",w),w.params&&w.params.length>0)){const $=new Map;w.params.forEach(z=>{$.set(z.id,z.default)}),c.value.set(w.id,$)}a("preview-filter",w)}function b(w){var $;a("remove-filter",w),c.value.delete(w),(($=r.value)==null?void 0:$.id)===w&&(r.value=null)}function h(w){if(typeof w=="number"&&Number.isFinite(w))return w;if(typeof w=="string"){const $=Number(w);return Number.isFinite($)?$:null}return null}function _(w,$){var N;const z=t.filters.find(L=>L.id===w),W=z==null?void 0:z.params.find(L=>L.id===$),Q=(W==null?void 0:W.default)??0,ye=L=>typeof Q=="number"?h(L)??Q:typeof Q=="boolean"?typeof L=="boolean"?L:Q:typeof L=="string"?L:Q,we=(N=t.activeFilters)==null?void 0:N.get(w);if(we&&we.params){const L=we.params[$];if(L!=null)return ye(L)}const ie=c.value.get(w);if(ie){const L=ie.get($);if(L!=null)return ye(L)}return Q}function R(w,$,z){var W;c.value.has(w)||c.value.set(w,new Map),(W=c.value.get(w))==null||W.set($,z),a("update-param",w,$,z)}function M(w){if(typeof w=="boolean")return w?"On":"Off";if(typeof w=="string"){const z=h(w);return z===null?"0":Number.isInteger(z)?z.toString():z.toFixed(2)}const $=h(w);return $===null?"0":Number.isInteger($)?$.toString():$.toFixed(2)}function x(){if(r.value&&(a("apply-filter",r.value),r.value.params&&r.value.params.length>0)){const w=new Map;r.value.params.forEach($=>{w.set($.id,$.default)}),c.value.set(r.value.id,w)}}function C(w){const $=t.filters.find(z=>z.id===w);$&&$.params&&$.params.forEach(z=>{R(w,z.id,z.default)})}function P(w){return{basic:ya,color:yn,blur:co,light:ba,effects:Ji,stylize:xa,adjustment:ya,"color-matrix":yn,glow:gn,distortion:Ca}[w]||gn}function S(w){return{adjustment:ya,brightness:ba,contrast:ya,saturation:yn,blur:co,"gaussian-blur":co,"color-matrix":yn,grayscale:xa,sepia:xa,vignette:Ca,glow:gn,glitch:Ji,godray:ba,lightmap:ba}[w.id]||P(w.category)}function D(){s.value>0&&(s.value--,B(d.value,s.value))}function I(){s.value<g.value.length-3&&(s.value++,B(d.value,s.value))}function j(){l.value>0&&(l.value--,B(u.value,l.value))}function O(){l.value<k.value.length-4&&(l.value++,B(u.value,l.value))}function F(w){l.value=w*4,B(u.value,l.value)}function B(w,$){var z;if(w){const W=((z=w.querySelector(".category-chip, .filter-card"))==null?void 0:z.clientWidth)||100;w.scrollTo({left:$*(W+8),behavior:"smooth"})}}return(w,$)=>{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",Pg,[e.createElementVNode("div",zg,[e.createElementVNode("button",{onClick:D,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(sl)},null,8,["icon"])],8,jg),e.createElementVNode("div",{ref_key:"categoryCarouselRef",ref:d,class:"category-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,W=>(e.openBlock(),e.createElementBlock("button",{key:W.id,onClick:Q=>i.value=W.id,class:e.normalizeClass(["category-chip",{active:i.value===W.id}]),"data-testid":`btn-filter-category-${f(W.id)}`,"aria-label":`Filter category ${W.name}`},[e.createVNode(e.unref(U.IonIcon),{icon:W.icon,class:"category-icon"},null,8,["icon"]),e.createElementVNode("span",Zg,e.toDisplayString(W.name),1)],10,Wg))),128))],512),e.createElementVNode("button",{onClick:I,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(ll)},null,8,["icon"])],8,Hg)])])):e.createCommentVNode("",!0),e.createElementVNode("div",Xg,[e.createElementVNode("div",Gg,[e.createElementVNode("button",{onClick:j,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(sl)},null,8,["icon"])],8,Jg),e.createElementVNode("div",{ref_key:"filterCarouselRef",ref:u,class:"filter-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.value,W=>{var Q;return e.openBlock(),e.createElementBlock("div",{key:W.id,class:e.normalizeClass(["filter-card",{active:T(W.id),selected:((Q=r.value)==null?void 0:Q.id)===W.id}]),onClick:ye=>V(W),onKeydown:[e.withKeys(ye=>V(W),["enter"]),e.withKeys(e.withModifiers(ye=>V(W),["prevent"]),["space"])],role:"button",tabindex:"0","data-testid":`btn-video-filter-${f(W.id)}`,"aria-label":`Select filter ${W.name}`},[T(W.id)?(e.openBlock(),e.createElementBlock("div",{key:0,class:"filter-checkmark",onClick:e.withModifiers(ye=>b(W.id),["stop"])},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(yc)},null,8,["icon"])],8,qg)):e.createCommentVNode("",!0),e.createElementVNode("div",Kg,[e.createElementVNode("div",Qg,[e.createVNode(e.unref(U.IonIcon),{icon:S(W),class:"filter-icon"},null,8,["icon"])])]),e.createElementVNode("span",e1,e.toDisplayString(W.name),1)],42,Yg)}),128))],512),e.createElementVNode("button",{onClick:O,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(ll)},null,8,["icon"])],8,t1)]),e.createElementVNode("div",n1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Math.ceil(k.value.length/4),(W,Q)=>(e.openBlock(),e.createElementBlock("span",{key:Q,class:e.normalizeClass(["pagination-dot",{active:Math.floor(l.value/4)===Q}]),onClick:ye=>F(Q)},null,10,a1))),128))])]),r.value?(e.openBlock(),e.createElementBlock("div",o1,[e.createElementVNode("div",i1,[e.createElementVNode("h4",null,e.toDisplayString(r.value.name),1),e.createElementVNode("div",r1,[T(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 ")),T(r.value.id)?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:$[0]||($[0]=W=>b(r.value.id)),class:"remove-btn","data-testid":"btn-remove-selected-filter"}," Remove Filter ")):e.createCommentVNode("",!0),T(r.value.id)&&((z=r.value.params)==null?void 0:z.length)>0?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:$[1]||($[1]=W=>C(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",s1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value.params,W=>(e.openBlock(),e.createElementBlock("div",{key:W.id,class:"adjustment-control"},[!W.type||W.type==="slider"?(e.openBlock(),e.createElementBlock("div",l1,[e.createElementVNode("label",c1,e.toDisplayString(W.label||W.id),1),e.createElementVNode("div",d1,[e.createVNode(e.unref(U.IonRange),{value:_(r.value.id,W.id),onIonChange:Q=>R(r.value.id,W.id,Q.detail.value),min:W.min,max:W.max,step:W.step||.01,color:"primary",class:"compact-slider",disabled:!T(r.value.id),"data-testid":`range-filter-${f(r.value.id)}-${f(W.id)}`,"aria-label":`Adjust ${W.label||W.id} for ${r.value.name}`},null,8,["value","onIonChange","min","max","step","disabled","data-testid","aria-label"]),e.createElementVNode("span",u1,e.toDisplayString(M(_(r.value.id,W.id))),1)])])):W.type==="color"?(e.openBlock(),e.createElementBlock("div",m1,[e.createElementVNode("label",p1,e.toDisplayString(W.label||W.id),1),e.createElementVNode("div",f1,[e.createElementVNode("input",{type:"color",value:_(r.value.id,W.id),onInput:Q=>R(r.value.id,W.id,Q.target.value),disabled:!T(r.value.id),class:"color-input"},null,40,h1),e.createElementVNode("span",v1,e.toDisplayString(_(r.value.id,W.id)),1)])])):W.type==="toggle"?(e.openBlock(),e.createElementBlock("div",g1,[e.createElementVNode("label",y1,e.toDisplayString(W.label||W.id),1),e.createVNode(e.unref(U.IonToggle),{checked:!!_(r.value.id,W.id),onIonChange:Q=>R(r.value.id,W.id,Q.detail.checked),disabled:!T(r.value.id),color:"primary"},null,8,["checked","onIonChange","disabled"])])):W.type==="select"?(e.openBlock(),e.createElementBlock("div",b1,[e.createElementVNode("label",w1,e.toDisplayString(W.label||W.id),1),e.createElementVNode("select",{value:_(r.value.id,W.id),onChange:Q=>R(r.value.id,W.id,Q.target.value),disabled:!T(r.value.id),class:"select-input"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.options,Q=>(e.openBlock(),e.createElementBlock("option",{key:String(Q.value),value:Q.value},e.toDisplayString(Q.label),9,_1))),128))],40,k1)])):e.createCommentVNode("",!0)]))),128))])):(e.openBlock(),e.createElementBlock("div",E1," This filter has no adjustable parameters "))])):e.createCommentVNode("",!0)],2)}}}),Ir=Te(x1,[["__scopeId","data-v-9efd15d9"]]);class C1{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,a;try{const i=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.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,a;try{const i=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.ColorMatrixFilter;if(!i)return null;const r=new i;return r.brightness(n.value||1,!1),r}catch{return null}}createContrastFilter(n){var t,a;try{const i=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.ColorMatrixFilter;if(!i)return null;const r=new i;return r.contrast(n.value||1,!1),r}catch{return null}}createSaturationFilter(n){var t,a;try{const i=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.ColorMatrixFilter;if(!i)return null;const r=new i;return r.saturate(n.value||1,!1),r}catch{return null}}createHueFilter(n){var t,a;try{const i=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.ColorMatrixFilter;if(!i)return null;const r=new i;return r.hue(n.rotation||0,!1),r}catch{return null}}createVintageFilter(n){var t,a;try{const i=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.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 a=(t=(n=window.PIXI)==null?void 0:n.filters)==null?void 0:t.ColorMatrixFilter;if(!a)return null;const i=new a;return i.desaturate(),i}catch{return null}}createSepiaFilter(){var n,t;try{const a=(t=(n=window.PIXI)==null?void 0:n.filters)==null?void 0:t.ColorMatrixFilter;if(!a)return null;const i=new a;return i.sepia(!1),i}catch{return null}}async applyFilters(n){if(this.composition){this.clearFilters();for(const t of n){const a=this.mapMediablesToPIXI(t);a&&(this.pixiFilters.set(t.id,a),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,a))}}}async applyToComposition(n,t){try{this.composition.applyFilter&&await this.composition.applyFilter(n,t)}catch{}}updateFilterParams(n,t){var i;const a=this.pixiFilters.get(n);a&&(this.filterParams.set(n,t),"blur"in a&&(a.blur=t.intensity||a.blur),"brightness"in a&&a.brightness(t.value||1,!1),"contrast"in a&&a.contrast(t.value||1,!1),"saturate"in a&&a.saturate(t.value||1,!1),"hue"in a&&a.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,a)=>{const i=this.filterParams.get(a)??{},r=this.filterTypes.get(a)??"unknown",s=this.filterIntensity.get(a)??1;n.push({id:a,filterId:r,params:i,intensity:s})}),n}async importFilterConfig(n){await this.applyFilters(n)}destroy(){this.clearFilters(),this.composition=null}}const S1={class:"video-filter-preview"},V1={class:"preview-title"},N1={class:"filter-controls"},T1={class:"control-input"},M1=["value","onInput","min","max","step"],B1={class:"param-value"},F1={class:"preview-container"},I1={key:0,class:"filter-presets"},$1=["onClick"],R1={class:"preview-actions"},D1=e.defineComponent({__name:"VideoFilterPreview",props:{filter:{},currentFrame:{},useVideoEngine:{type:Boolean,default:!1},composition:{}},emits:["update-params","apply"],setup(o,{emit:n}){const t=o,a=n,i=e.ref(),r=e.ref(!1),s=e.ref({});let l,c,d=null,u=null;const m=e.computed(()=>{var x;return((x=t.filter)==null?void 0:x.paramRanges)||{}}),f=e.computed(()=>p.value.length>0),p=e.computed(()=>t.filter?{brightness:[{name:"Subtle",params:{value:.1}},{name:"Medium",params:{value:.3}},{name:"Strong",params:{value:.5}}],contrast:[{name:"Low",params:{value:.8}},{name:"Normal",params:{value:1}},{name:"High",params:{value:1.5}}],"gaussian-blur":[{name:"Subtle",params:{value:1}},{name:"Medium",params:{value:3}},{name:"Strong",params:{value:5}}]}[t.filter.id]||[]:[]);async function v(){var x;if(i.value){t.useVideoEngine&&t.composition&&(u=new C1(t.composition));try{if(l=new lt.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 C=await lt.Assets.load(t.currentFrame.dataUrl);c=new lt.Sprite(C);const P=Math.min(l.screen.width/c.texture.width,l.screen.height/c.texture.height);c.scale.set(P),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(C=>{}),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,C){switch(x){case"brightness":{const P=new lt.ColorMatrixFilter,S=1+(C.value??0);return typeof P.brightness=="function"&&P.brightness(S,!1),P}case"contrast":{const P=new lt.ColorMatrixFilter,S=C.value??1;return typeof P.contrast=="function"&&P.contrast(S,!1),P}case"saturation":{const P=new lt.ColorMatrixFilter,S=C.value??1;return typeof P.saturate=="function"&&P.saturate(S,!1),P}case"hue":{const P=new lt.ColorMatrixFilter,S=C.value??0;return typeof P.hue=="function"&&P.hue(S,!1),P}case"gaussian-blur":{const P=C.value??5;return new lt.BlurFilter({strength:P,quality:4})}case"sepia":{const P=new lt.ColorMatrixFilter;return typeof P.sepia=="function"&&P.sepia(!1),P}case"grayscale":{const P=new lt.ColorMatrixFilter;return typeof P.desaturate=="function"&&P.desaturate(),P}default:return null}}function T(x,C){const P=C.target,S=Number.parseFloat(P.value),D=Number.isFinite(S)?S:0;s.value={...s.value,[x]:D},t.useVideoEngine&&u&&t.filter&&u.updateFilterParams(t.filter.id,s.value),a("update-params",s.value),g()}function V(x){return x.charAt(0).toUpperCase()+x.slice(1).replace(/_/g," ")}function b(x,C){var S;const P=typeof x=="number"?x:Number(x);return Number.isFinite(P)?C==="hue"||C==="angle"?`${P}°`:C==="value"&&((S=t.filter)==null?void 0:S.id)==="brightness"?`${Math.round((1+P)*100)}%`:Number.isInteger(P)?P.toString():P.toFixed(2):"0"}function h(){var x;s.value=((x=t.filter)==null?void 0:x.defaultParams)||{},a("update-params",s.value),g()}function _(x){s.value={...x.params},a("update-params",s.value),g()}function R(x){return JSON.stringify(x.params)===JSON.stringify(s.value)}function M(){a("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 C=await lt.Assets.load(x.dataUrl);c.texture=C}}),e.watch(r,g),e.onMounted(()=>{t.filter&&(s.value={...t.filter.defaultParams}),v()}),e.onUnmounted(()=>{l&&l.destroy(!0,{children:!0,texture:!0}),d&&d.destroy(),u&&u.destroy()}),(x,C)=>{var P;return e.openBlock(),e.createElementBlock("div",S1,[e.createElementVNode("h4",V1,e.toDisplayString((P=x.filter)==null?void 0:P.name)+" Settings",1),e.createElementVNode("div",N1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(S,D)=>(e.openBlock(),e.createElementBlock("div",{key:D,class:"control-group"},[e.createElementVNode("label",null,e.toDisplayString(V(D)),1),e.createElementVNode("div",T1,[e.createElementVNode("input",{type:"range",value:s.value[D],onInput:I=>T(D,I),min:S.min,max:S.max,step:S.step,class:"param-slider"},null,40,M1),e.createElementVNode("span",B1,e.toDisplayString(b(s.value[D],D)),1)])]))),128))]),e.createElementVNode("div",F1,[e.createElementVNode("canvas",{ref_key:"previewCanvas",ref:i,class:"preview-canvas"},null,512),e.createElementVNode("button",{class:"compare-button",onMousedown:C[0]||(C[0]=S=>r.value=!0),onMouseup:C[1]||(C[1]=S=>r.value=!1),onTouchstart:C[2]||(C[2]=S=>r.value=!0),onTouchend:C[3]||(C[3]=S=>r.value=!1)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ca)},null,8,["icon"]),C[4]||(C[4]=e.createTextVNode(" Hold to compare ",-1))],32)]),f.value?(e.openBlock(),e.createElementBlock("div",I1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,S=>(e.openBlock(),e.createElementBlock("button",{key:S.name,class:e.normalizeClass(["preset-button",{active:R(S)}]),onClick:D=>_(S)},e.toDisplayString(S.name),11,$1))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",R1,[e.createElementVNode("button",{class:"action-button",onClick:h},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Un)},null,8,["icon"]),C[5]||(C[5]=e.createTextVNode(" Reset ",-1))]),e.createElementVNode("button",{class:"action-button primary",onClick:M},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(bc)},null,8,["icon"]),C[6]||(C[6]=e.createTextVNode(" Apply Filter ",-1))])])])}}}),$r=Te(D1,[["__scopeId","data-v-3de3dd04"]]),A1={class:"export-settings"},L1={class:"setting-group"},U1={class:"setting-group"},O1={class:"estimated-size"},P1={key:0,class:"export-progress"},z1={class:"progress-header"},j1={class:"progress-percentage"},W1={class:"progress-time"},Z1={class:"action-buttons"},H1=["disabled"],X1=["disabled"],G1=["disabled"],J1={class:"export-options"},Y1=e.defineComponent({__name:"EditorControls",props:{canExport:{type:Boolean,default:!1},isExporting:{type:Boolean,default:!1},exportProgress:{default:0},isMobile:{type:Boolean,default:!1},duration:{default:0}},emits:["export","save-draft","reset","cancel-export"],setup(o,{emit:n}){const t=o,a=n,i=e.ref("1080p"),r=e.ref("mp4"),s=e.ref(!0),l=e.ref(!1),c=e.ref(0),d=e.ref(0),u=e.ref(0);let m=null;const f=e.computed(()=>{const h=({"360p":1,"480p":2.5,"720p":5,"1080p":8,"1440p":16,"2160p":35}[i.value]||8)*t.duration/8;return h<1e3?`~${Math.round(h)} MB`:`~${(h/1e3).toFixed(1)} GB`});function p(){t.isExporting?(a("cancel-export"),k()):v()}function v(){const V={quality:i.value,format:r.value,optimizeForWeb:s.value,includeWatermark:l.value};a("export",V),g()}function g(){c.value=Date.now(),d.value=0,m=window.setInterval(()=>{if(d.value=Math.floor((Date.now()-c.value)/1e3),t.exportProgress>0){const V=d.value/t.exportProgress*100;u.value=Math.max(0,V-d.value)}},1e3)}function k(){m&&(clearInterval(m),m=null)}function T(V){const b=Math.floor(V/60),h=Math.floor(V%60);return`${b}:${h.toString().padStart(2,"0")}`}return e.watch(()=>t.isExporting,V=>{V||k()}),e.onUnmounted(()=>{k()}),(V,b)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["editor-controls",{mobile:V.isMobile}])},[e.createElementVNode("div",A1,[b[10]||(b[10]=e.createElementVNode("h3",{class:"section-title"},"Export Settings",-1)),e.createElementVNode("div",L1,[b[7]||(b[7]=e.createElementVNode("label",null,"Quality",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":b[0]||(b[0]=h=>i.value=h),class:"setting-select"},[...b[6]||(b[6]=[e.createStaticVNode('<option value="360p" data-v-e1338d5e>360p (Low)</option><option value="480p" data-v-e1338d5e>480p (SD)</option><option value="720p" data-v-e1338d5e>720p (HD)</option><option value="1080p" data-v-e1338d5e>1080p (Full HD)</option><option value="1440p" data-v-e1338d5e>1440p (2K)</option><option value="2160p" data-v-e1338d5e>2160p (4K)</option>',6)])],512),[[e.vModelSelect,i.value]])]),e.createElementVNode("div",U1,[b[9]||(b[9]=e.createElementVNode("label",null,"Format",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":b[1]||(b[1]=h=>r.value=h),class:"setting-select"},[...b[8]||(b[8]=[e.createElementVNode("option",{value:"mp4"},"MP4 (Most Compatible)",-1),e.createElementVNode("option",{value:"webm"},"WebM (Web Optimized)",-1),e.createElementVNode("option",{value:"mov"},"MOV (Apple)",-1)])],512),[[e.vModelSelect,r.value]])]),e.createElementVNode("div",O1,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(hp)},null,8,["icon"]),e.createElementVNode("span",null,"Estimated size: "+e.toDisplayString(f.value),1)])]),V.isExporting?(e.openBlock(),e.createElementBlock("div",P1,[e.createElementVNode("div",z1,[b[11]||(b[11]=e.createElementVNode("span",null,"Exporting...",-1)),e.createElementVNode("span",j1,e.toDisplayString(V.exportProgress??0)+"%",1)]),e.createVNode(e.unref(U.IonProgressBar),{value:(V.exportProgress??0)/100},null,8,["value"]),e.createElementVNode("div",W1,[e.createElementVNode("span",null,e.toDisplayString(T(d.value))+" elapsed",1),e.createElementVNode("span",null,e.toDisplayString(T(u.value))+" remaining",1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",Z1,[e.createElementVNode("button",{class:"control-button secondary",onClick:b[2]||(b[2]=h=>V.$emit("save-draft")),disabled:!V.canExport||V.isExporting},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Go)},null,8,["icon"]),b[12]||(b[12]=e.createTextVNode(" Save Draft ",-1))],8,H1),e.createElementVNode("button",{class:"control-button secondary",onClick:b[3]||(b[3]=h=>V.$emit("reset")),disabled:V.isExporting},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Un)},null,8,["icon"]),b[13]||(b[13]=e.createTextVNode(" Reset ",-1))],8,X1),e.createElementVNode("button",{class:"control-button primary",onClick:p,disabled:!V.canExport&&!V.isExporting,"data-testid":"video-export-button"},[e.createVNode(e.unref(U.IonIcon),{icon:V.isExporting?e.unref(Rn):e.unref(na)},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(V.isExporting?"Cancel":"Export Video"),1)],8,G1)]),e.createElementVNode("div",J1,[e.createVNode(e.unref(U.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonCheckbox),{modelValue:s.value,"onUpdate:modelValue":b[4]||(b[4]=h=>s.value=h)},null,8,["modelValue"]),e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...b[14]||(b[14]=[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:l.value,"onUpdate:modelValue":b[5]||(b[5]=h=>l.value=h)},null,8,["modelValue"]),e.createVNode(e.unref(U.IonLabel),null,{default:e.withCtx(()=>[...b[15]||(b[15]=[e.createTextVNode("Include watermark",-1)])]),_:1})]),_:1})])],2))}}),Rr=Te(Y1,[["__scopeId","data-v-e1338d5e"]]),q1={class:"thumbnail-picker"},K1={class:"thumbnail-grid"},Q1=["onClick"],ey=["src","alt"],ty={key:1,class:"thumbnail-placeholder"},ny={class:"thumbnail-time"},ay={class:"custom-selector"},oy={class:"time-input-group"},iy=["max"],ry={class:"time-value"},sy=["disabled"],ly={class:"picker-actions"},cy=["disabled"],dy=e.defineComponent({__name:"ThumbnailPicker",props:{mediaUuid:{},duration:{},currentTime:{default:0}},emits:["select","cancel"],setup(o,{emit:n}){const t=o,a=n,i=e.ref([]),r=e.ref(-1),s=e.ref(t.currentTime),l=e.ref(!1);function c(){const T=[];if(t.duration<=10)for(let b=0;b<Math.min(9,t.duration);b++)T.push(b);else{const b=t.duration/10;for(let h=1;h<=9;h++)T.push(b*h)}return T}async function d(T){try{const V=document.createElement("video");return V.crossOrigin="anonymous",V.src=await u(),new Promise(b=>{V.addEventListener("loadedmetadata",()=>{V.currentTime=T}),V.addEventListener("seeked",()=>{const h=document.createElement("canvas");h.width=V.videoWidth,h.height=V.videoHeight;const _=h.getContext("2d");_?(_.drawImage(V,0,0),b(h.toDataURL("image/jpeg",.8))):b(null),V.remove()}),V.addEventListener("error",()=>{b(null),V.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 m(){const T=c();i.value=T.map(b=>({time:b,loading:!0}));const V=3;for(let b=0;b<i.value.length;b+=V){const h=i.value.slice(b,b+V);await Promise.all(h.map(async _=>{const R=await d(_.time);R&&(_.dataUrl=R),_.loading=!1}))}}function f(T){r.value=T,s.value=i.value[T].time}function p(){r.value=-1}async function v(){l.value=!0;try{const T=await d(s.value);if(T){const V=i.value.findIndex(b=>Math.abs(b.time-s.value)<.1);V>=0?(i.value[V].dataUrl=T,r.value=V):(i.value.push({time:s.value,dataUrl:T}),r.value=i.value.length-1,i.value.sort((b,h)=>b.time-h.time),r.value=i.value.findIndex(b=>b.time===s.value))}}finally{l.value=!1}}function g(){const T=r.value>=0?i.value[r.value].time:s.value;a("select",T)}function k(T){const V=Math.floor(T/60),b=Math.floor(T%60),h=Math.floor(T%1*100);return V>0?`${V}:${b.toString().padStart(2,"0")}.${h.toString().padStart(2,"0")}`:`${b}.${h.toString().padStart(2,"0")}s`}return e.onMounted(()=>{m()}),(T,V)=>(e.openBlock(),e.createElementBlock("div",q1,[V[5]||(V[5]=e.createElementVNode("h4",{class:"picker-title"},"Select Video Thumbnail",-1)),e.createElementVNode("div",K1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(b,h)=>(e.openBlock(),e.createElementBlock("div",{key:h,class:e.normalizeClass(["thumbnail-item",{selected:r.value===h}]),onClick:_=>f(h)},[b.dataUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:b.dataUrl,alt:`Frame at ${k(b.time)}`},null,8,ey)):(e.openBlock(),e.createElementBlock("div",ty,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"})])),e.createElementVNode("div",ny,e.toDisplayString(k(b.time)),1)],10,Q1))),128))]),e.createElementVNode("div",ay,[V[3]||(V[3]=e.createElementVNode("label",null,"Custom time:",-1)),e.createElementVNode("div",oy,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":V[0]||(V[0]=b=>s.value=b),min:0,max:T.duration,step:.1,onInput:p,class:"time-slider"},null,40,iy),[[e.vModelText,s.value]]),e.createElementVNode("span",ry,e.toDisplayString(k(s.value)),1)]),e.createElementVNode("button",{class:"capture-button",onClick:v,disabled:l.value},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ap)},null,8,["icon"]),V[2]||(V[2]=e.createTextVNode(" Capture Frame ",-1))],8,sy)]),e.createElementVNode("div",ly,[e.createElementVNode("button",{class:"action-button",onClick:V[1]||(V[1]=b=>T.$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(bc)},null,8,["icon"]),V[4]||(V[4]=e.createTextVNode(" Set Thumbnail ",-1))],8,cy)])]))}}),uy=Te(dy,[["__scopeId","data-v-336c322c"]]),my={class:"text-overlay-panel p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},py={class:"mb-4"},fy={class:"space-y-2 max-h-64 overflow-y-auto"},hy={class:"flex items-center justify-between"},vy={class:"flex-1"},gy={class:"font-medium text-gray-900 dark:text-white"},yy={class:"text-sm text-gray-500 dark:text-gray-400"},by={class:"flex items-center space-x-2"},wy=["onClick"],ky=["onClick"],_y={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},Ey={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},xy={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},Cy={class:"space-y-4"},Sy={class:"grid grid-cols-2 gap-4"},Vy={class:"grid grid-cols-2 gap-4"},Ny={key:0,class:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},Ty={class:"grid grid-cols-2 gap-3"},My={class:"flex justify-end space-x-3 mt-6"},By=e.defineComponent({__name:"TextOverlayPanel",props:{overlays:{}},emits:["add-overlay","update-overlay","remove-overlay"],setup(o,{emit:n}){const t=n,a=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(f){Object.assign(s,f),i.value=f}function c(){a.value=!1,i.value=null,Object.assign(s,r())}function d(){const f={text:s.text,fontSize:s.fontSize,color:s.color,position:s.position,startTime:s.startTime,duration:s.duration};if(s.animationType&&(f.animation={type:s.animationType},s.animationDuration!==void 0&&(f.animation.duration=s.animationDuration),s.animationEasing&&(f.animation.easing=s.animationEasing),f.animation))switch(s.animationType){case"rotate":f.animation.rotation={from:0,to:360};break;case"scale":f.animation.scale={from:.5,to:1};break;case"slide":f.animation.translate={fromX:-100,toX:0,fromY:0,toY:0};break}i.value?t("update-overlay",i.value.id,f):t("add-overlay",f),c()}function u(f){confirm("Are you sure you want to remove this text overlay?")&&t("remove-overlay",f)}function m(f){const p=Math.floor(f/60),v=Math.floor(f%60);return`${p}:${v.toString().padStart(2,"0")}`}return(f,p)=>(e.openBlock(),e.createElementBlock("div",my,[e.createElementVNode("div",py,[p[11]||(p[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Text Overlays ",-1)),e.createElementVNode("button",{onClick:p[0]||(p[0]=v=>a.value=!0),class:"w-full px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"},[...p[10]||(p[10]=[e.createElementVNode("svg",{class:"w-5 h-5 inline-block mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),e.createTextVNode(" Add Text Overlay ",-1)])])]),e.createElementVNode("div",fy,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.overlays,v=>(e.openBlock(),e.createElementBlock("div",{key:v.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",hy,[e.createElementVNode("div",vy,[e.createElementVNode("div",gy,e.toDisplayString(v.text.substring(0,30))+e.toDisplayString(v.text.length>30?"...":""),1),e.createElementVNode("div",yy,e.toDisplayString(m(v.startTime??0))+" - "+e.toDisplayString(m((v.startTime||0)+(v.duration||5))),1)]),e.createElementVNode("div",by,[e.createElementVNode("button",{onClick:g=>l(v),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Edit"},[...p[12]||(p[12]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})],-1)])],8,wy),e.createElementVNode("button",{onClick:g=>u(v.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...p[13]||(p[13]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])],8,ky)])])]))),128)),f.overlays.length===0?(e.openBlock(),e.createElementBlock("div",_y," No text overlays added yet ")):e.createCommentVNode("",!0)]),a.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",Ey,[e.createElementVNode("h4",xy,e.toDisplayString(i.value?"Edit":"Add")+" Text Overlay ",1),e.createElementVNode("div",Cy,[e.createElementVNode("div",null,[p[14]||(p[14]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Text ",-1)),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":p[1]||(p[1]=v=>s.text=v),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",Sy,[e.createElementVNode("div",null,[p[15]||(p[15]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Font Size ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[2]||(p[2]=v=>s.fontSize=v),type:"number",min:"10",max:"200",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.fontSize,void 0,{number:!0}]])]),e.createElementVNode("div",null,[p[16]||(p[16]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Color ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[3]||(p[3]=v=>s.color=v),type:"color",class:"w-full h-10 border border-gray-300 dark:border-gray-600 rounded-lg cursor-pointer"},null,512),[[e.vModelText,s.color]])])]),e.createElementVNode("div",null,[p[18]||(p[18]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Position ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":p[4]||(p[4]=v=>s.position=v),class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},[...p[17]||(p[17]=[e.createStaticVNode('<option value="center" data-v-f86e688c>Center</option><option value="top" data-v-f86e688c>Top</option><option value="bottom" data-v-f86e688c>Bottom</option><option value="left" data-v-f86e688c>Left</option><option value="right" data-v-f86e688c>Right</option>',5)])],512),[[e.vModelSelect,s.position]])]),e.createElementVNode("div",Vy,[e.createElementVNode("div",null,[p[19]||(p[19]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Start Time (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[5]||(p[5]=v=>s.startTime=v),type:"number",min:"0",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.startTime,void 0,{number:!0}]])]),e.createElementVNode("div",null,[p[20]||(p[20]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Duration (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[6]||(p[6]=v=>s.duration=v),type:"number",min:"0.1",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.duration,void 0,{number:!0}]])])]),e.createElementVNode("div",null,[p[22]||(p[22]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Animation ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":p[7]||(p[7]=v=>s.animationType=v),class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},[...p[21]||(p[21]=[e.createStaticVNode('<option value="" data-v-f86e688c>None</option><option value="fade-in" data-v-f86e688c>Fade In</option><option value="fade-out" data-v-f86e688c>Fade Out</option><option value="slide" data-v-f86e688c>Slide</option><option value="scale" data-v-f86e688c>Scale</option><option value="rotate" data-v-f86e688c>Rotate</option><option value="typewriter" data-v-f86e688c>Typewriter</option>',7)])],512),[[e.vModelSelect,s.animationType]])]),s.animationType?(e.openBlock(),e.createElementBlock("div",Ny,[p[26]||(p[26]=e.createElementVNode("div",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Animation Settings ",-1)),e.createElementVNode("div",Ty,[e.createElementVNode("div",null,[p[23]||(p[23]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Duration (s) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[8]||(p[8]=v=>s.animationDuration=v),type:"number",min:"0.1",step:"0.1",class:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},null,512),[[e.vModelText,s.animationDuration,void 0,{number:!0}]])]),e.createElementVNode("div",null,[p[25]||(p[25]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Easing ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":p[9]||(p[9]=v=>s.animationEasing=v),class:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},[...p[24]||(p[24]=[e.createElementVNode("option",{value:"linear"},"Linear",-1),e.createElementVNode("option",{value:"easeIn"},"Ease In",-1),e.createElementVNode("option",{value:"easeOut"},"Ease Out",-1),e.createElementVNode("option",{value:"easeInOut"},"Ease In Out",-1)])],512),[[e.vModelSelect,s.animationEasing]])])])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",My,[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)]))}}),Dr=Te(By,[["__scopeId","data-v-f86e688c"]]),Ra=class Ra{constructor(n){this.transitions=new Map,this.nextId=0,this.composition=n}async applyTransition(n,t,a){const i=`transition-${this.nextId++}`,r=Math.round(a.duration*30),s=a.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(a.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,a.type,d,u,s);break;case"slide-left":case"slide-right":case"slide-up":case"slide-down":await this.applySlideTransition(n,t,a.type,d,u,s);break;case"zoom-in":case"zoom-out":await this.applyZoomTransition(n,t,a.type,d,u,s);break;case"dip-to-black":case"dip-to-white":await this.applyDipTransition(n,t,a.type,d,u,s);break}return this.transitions.set(i,a),i}async applyFadeTransition(n,t,a,i,r){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Fade transitions require VideoClip instances");n.alpha=new Ie([a,i],[1,0],{easing:r}),t.alpha=new Ie([a,i],[0,1],{easing:r}),t.start=_e.fromFrames(a)}async applyCrossFadeTransition(n,t,a,i,r){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Cross-fade transitions require VideoClip instances");n.alpha=new Ie([a,i],[1,0],{easing:r}),t.alpha=new Ie([a,i],[0,1],{easing:r}),t.start=_e.fromFrames(a)}async applyWipeTransition(n,t,a,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(a){case"wipe-left":l.x=new Ie([i,r],[0,-1920],{easing:s}),c.x=new Ie([i,r],[1920,0],{easing:s});break;case"wipe-right":l.x=new Ie([i,r],[0,1920],{easing:s}),c.x=new Ie([i,r],[-1920,0],{easing:s});break;case"wipe-up":l.y=new Ie([i,r],[0,-1080],{easing:s}),c.y=new Ie([i,r],[1080,0],{easing:s});break;case"wipe-down":l.y=new Ie([i,r],[0,1080],{easing:s}),c.y=new Ie([i,r],[-1080,0],{easing:s});break}n.translate=l,t.translate=c,t.start=_e.fromFrames(i)}async applySlideTransition(n,t,a,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(a){case"slide-left":l.x=new Ie([i,r],[0,-1920],{easing:s}),c.x=new Ie([i,r],[1920,0],{easing:s});break;case"slide-right":l.x=new Ie([i,r],[0,1920],{easing:s}),c.x=new Ie([i,r],[-1920,0],{easing:s});break;case"slide-up":l.y=new Ie([i,r],[0,-1080],{easing:s}),c.y=new Ie([i,r],[1080,0],{easing:s});break;case"slide-down":l.y=new Ie([i,r],[0,1080],{easing:s}),c.y=new Ie([i,r],[-1080,0],{easing:s});break}n.translate=l,t.translate=c,t.start=_e.fromFrames(i)}async applyZoomTransition(n,t,a,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Zoom transitions require VideoClip instances");a==="zoom-in"?(n.scale=new Ie([i,r],[1,2],{easing:s}),n.alpha=new Ie([i,r],[1,0],{easing:s}),t.scale=new Ie([i,r],[.5,1],{easing:s}),t.alpha=new Ie([i,r],[0,1],{easing:s})):(n.scale=new Ie([i,r],[1,.5],{easing:s}),n.alpha=new Ie([i,r],[1,0],{easing:s}),t.scale=new Ie([i,r],[2,1],{easing:s}),t.alpha=new Ie([i,r],[0,1],{easing:s})),t.start=_e.fromFrames(i)}async applyDipTransition(n,t,a,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=a==="dip-to-black"?"#000000":"#ffffff",d=await Sr.fromColor(c),u=new p0(d,{start:_e.fromFrames(i),stop:_e.fromFrames(r)});n.alpha=new Ie([i,l],[1,0],{easing:s}),u.alpha=new Ie([i,l,r],[0,1,0],{easing:s}),t.alpha=new Ie([l,r],[0,1],{easing:s}),await this.composition.add(u),t.start=_e.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[...Ra.TRANSITIONS]}static previewTransition(n){return Ra.TRANSITIONS.find(t=>t.type===n)}isVideoClip(n){return"alpha"in n&&"scale"in n&&"translate"in n}};Ra.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 La=Ra;const Fy={class:"transition-selector p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},Iy={class:"grid grid-cols-3 gap-3 max-h-96 overflow-y-auto"},$y=["onClick"],Ry={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"},Dy={key:0,class:"w-8 h-8 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Ay={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},Ly={key:1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14 5l7 7m0 0l-7 7m7-7H3"},Uy={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"},Oy={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"},Py={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"},zy={class:"text-sm font-medium text-gray-900 dark:text-white text-center"},jy={key:0,class:"mt-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},Wy={class:"space-y-3"},Zy={class:"flex items-center space-x-2"},Hy=["disabled"],Xy=["disabled"],Gy={key:1,class:"mt-4"},Jy={class:"space-y-2 max-h-32 overflow-y-auto"},Yy={class:"text-sm text-gray-700 dark:text-gray-300"},qy=["onClick"],Ky=e.defineComponent({__name:"TransitionSelector",props:{selectedClips:{},appliedTransitions:{}},emits:["apply-transition","remove-transition","preview-transition"],setup(o,{emit:n}){const t=o,a=n,i=e.ref(La.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(v){r.value=v}function u(){if(!r.value||!c.value)return;const v={type:r.value.type,duration:s.value,easing:l.value};a("apply-transition",v),r.value=null}function m(){if(!r.value)return;const v={type:r.value.type,duration:s.value,easing:l.value};a("preview-transition",v)}function f(v){a("remove-transition",v)}function p(v){return["fade","wipe","slide","zoom"].some(g=>v.includes(g))}return(v,g)=>(e.openBlock(),e.createElementBlock("div",Fy,[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",Iy,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,k=>{var T;return e.openBlock(),e.createElementBlock("div",{key:k.type,onClick:V=>d(k),class:e.normalizeClass(["transition-item cursor-pointer rounded-lg p-3 border-2 transition-all",((T=r.value)==null?void 0:T.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",Ry,[p(k.type)?(e.openBlock(),e.createElementBlock("svg",Dy,[k.type.includes("fade")?(e.openBlock(),e.createElementBlock("path",Ay)):k.type.includes("wipe")?(e.openBlock(),e.createElementBlock("path",Ly)):k.type.includes("slide")?(e.openBlock(),e.createElementBlock("path",Uy)):k.type.includes("zoom")?(e.openBlock(),e.createElementBlock("path",Oy)):(e.openBlock(),e.createElementBlock("path",Py))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",zy,e.toDisplayString(k.name),1)],10,$y)}),128))]),r.value?(e.openBlock(),e.createElementBlock("div",jy,[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",Wy,[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",Zy,[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,Hy),e.createElementVNode("button",{onClick:m,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,Xy)])])):e.createCommentVNode("",!0),v.appliedTransitions.length>0?(e.openBlock(),e.createElementBlock("div",Gy,[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",Jy,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.appliedTransitions,(k,T)=>(e.openBlock(),e.createElementBlock("div",{key:T,class:"flex items-center justify-between p-2 bg-gray-50 dark:bg-gray-700 rounded"},[e.createElementVNode("div",Yy,e.toDisplayString(k.name)+" ("+e.toDisplayString(k.duration)+"s) ",1),e.createElementVNode("button",{onClick:V=>f(T),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,qy)]))),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))]))}}),Ar=Te(Ky,[["__scopeId","data-v-5ef1b100"]]),Qy={class:"audio-track-manager p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},eb={class:"mb-4"},tb={class:"mb-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},nb={class:"flex items-center justify-between mb-2"},ab={class:"text-sm text-gray-600 dark:text-gray-400"},ob={class:"flex items-center space-x-2"},ib={class:"space-y-3 max-h-64 overflow-y-auto"},rb={class:"flex items-center justify-between mb-2"},sb={class:"font-medium text-gray-900 dark:text-white"},lb={class:"flex items-center space-x-2"},cb=["onClick","title"],db={key:0,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},ub={key:1,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},mb=["onClick"],pb=["onClick"],fb={class:"flex items-center space-x-2"},hb={class:"text-xs text-gray-500 dark:text-gray-400 w-10"},vb=["value","onInput","disabled"],gb={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},yb={key:0,class:"ml-2"},bb={key:1,class:"ml-2"},wb={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},kb={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},_b={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},Eb={class:"space-y-4"},xb={class:"space-y-2"},Cb={class:"flex items-center"},Sb={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},Vb={class:"grid grid-cols-2 gap-4"},Nb={class:"grid grid-cols-2 gap-4"},Tb={class:"flex items-center"},Mb={class:"flex justify-end space-x-3 mt-6"},Bb=["disabled"],Fb=e.defineComponent({__name:"AudioTrackManager",props:{audioLayers:{},masterVolume:{}},emits:["add-track","update-track","remove-track","update-volume","toggle-mute","update-master-volume"],setup(o,{emit:n}){const t=o,a=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(b){const h=b.target;h.files&&h.files[0]&&(c.sourceFile=h.files[0],c.name=c.name||h.files[0].name.replace(/\.[^/.]+$/,""))}function m(b){Object.assign(c,b),r.value=b}function f(){i.value=!1,r.value=null,Object.assign(c,l())}function p(){if(!d.value)return;const b={source:c.sourceFile??c.sourceUrl??"",name:c.name,volume:c.volume,startTime:c.startTime,loop:c.loop};c.duration!==void 0&&(b.duration=c.duration),c.fadeIn>0&&(b.fadeIn=c.fadeIn),c.fadeOut>0&&(b.fadeOut=c.fadeOut),r.value?a("update-track",r.value.id,b):a("add-track",b),f()}function v(b){confirm("Are you sure you want to remove this audio track?")&&a("remove-track",b)}function g(b,h){const _=h.target,R=parseFloat(_.value);a("update-volume",b.id,R)}function k(b){a("toggle-mute",b.id,!b.muted)}function T(){a("update-master-volume",s.value)}function V(b){const h=Math.floor(b/60),_=Math.floor(b%60);return`${h}:${_.toString().padStart(2,"0")}`}return(b,h)=>(e.openBlock(),e.createElementBlock("div",Qy,[e.createElementVNode("div",eb,[h[11]||(h[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Audio Tracks ",-1)),e.createElementVNode("button",{onClick:h[0]||(h[0]=_=>i.value=!0),class:"w-full px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors"},[...h[10]||(h[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",tb,[e.createElementVNode("div",nb,[h[12]||(h[12]=e.createElementVNode("label",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"}," Master Volume ",-1)),e.createElementVNode("span",ab,e.toDisplayString(Math.round(s.value*100))+"% ",1)]),e.createElementVNode("div",ob,[h[13]||(h[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":h[1]||(h[1]=_=>s.value=_),onInput:T,type:"range",min:"0",max:"1",step:"0.01",class:"flex-1"},null,544),[[e.vModelText,s.value,void 0,{number:!0}]]),h[14]||(h[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",ib,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.audioLayers,_=>(e.openBlock(),e.createElementBlock("div",{key:_.id,class:"p-3 border border-gray-200 dark:border-gray-700 rounded-lg"},[e.createElementVNode("div",rb,[e.createElementVNode("div",sb,e.toDisplayString(_.name),1),e.createElementVNode("div",lb,[e.createElementVNode("button",{onClick:R=>k(_),class:e.normalizeClass(["p-1 rounded",_.muted?"text-red-600 bg-red-50 dark:bg-red-900":"text-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700"]),title:_.muted?"Unmute":"Mute"},[_.muted?(e.openBlock(),e.createElementBlock("svg",ub,[...h[16]||(h[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",db,[...h[15]||(h[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,cb),e.createElementVNode("button",{onClick:R=>m(_),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Settings"},[...h[17]||(h[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,mb),e.createElementVNode("button",{onClick:R=>v(_.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...h[18]||(h[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,pb)])]),e.createElementVNode("div",fb,[e.createElementVNode("span",hb,e.toDisplayString(Math.round((_.volume||1)*100))+"% ",1),e.createElementVNode("input",{value:_.volume||1,onInput:R=>g(_,R),type:"range",min:"0",max:"1",step:"0.01",class:"flex-1",disabled:_.muted},null,40,vb)]),e.createElementVNode("div",gb,[e.createTextVNode(e.toDisplayString(V(_.startTime||0))+" - "+e.toDisplayString(V((_.startTime||0)+(_.duration||0)))+" ",1),_.fadeIn?(e.openBlock(),e.createElementBlock("span",yb,"Fade In: "+e.toDisplayString(_.fadeIn)+"s",1)):e.createCommentVNode("",!0),_.fadeOut?(e.openBlock(),e.createElementBlock("span",bb,"Fade Out: "+e.toDisplayString(_.fadeOut)+"s",1)):e.createCommentVNode("",!0)])]))),128)),b.audioLayers.length===0?(e.openBlock(),e.createElementBlock("div",wb," 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(f,["self"])},[e.createElementVNode("div",kb,[e.createElementVNode("h4",_b,e.toDisplayString(r.value?"Edit":"Add")+" Audio Track ",1),e.createElementVNode("div",Eb,[e.createElementVNode("div",null,[h[20]||(h[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",xb,[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",Cb,[h[19]||(h[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":h[2]||(h[2]=_=>c.sourceUrl=_),type:"url",placeholder:"https://example.com/audio.mp3",class:"flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.sourceUrl]])])])]),e.createElementVNode("div",null,[h[21]||(h[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":h[3]||(h[3]=_=>c.name=_),type:"text",placeholder:"Background Music",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.name]])]),e.createElementVNode("div",null,[e.createElementVNode("label",Sb," Volume: "+e.toDisplayString(Math.round(c.volume*100))+"% ",1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[4]||(h[4]=_=>c.volume=_),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",Vb,[e.createElementVNode("div",null,[h[22]||(h[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":h[5]||(h[5]=_=>c.startTime=_),type:"number",min:"0",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.startTime,void 0,{number:!0}]])]),e.createElementVNode("div",null,[h[23]||(h[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":h[6]||(h[6]=_=>c.duration=_),type:"number",min:"0.1",step:"0.1",placeholder:"Auto",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.duration,void 0,{number:!0}]])])]),e.createElementVNode("div",Nb,[e.createElementVNode("div",null,[h[24]||(h[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":h[7]||(h[7]=_=>c.fadeIn=_),type:"number",min:"0",max:"10",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.fadeIn,void 0,{number:!0}]])]),e.createElementVNode("div",null,[h[25]||(h[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":h[8]||(h[8]=_=>c.fadeOut=_),type:"number",min:"0",max:"10",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.fadeOut,void 0,{number:!0}]])])]),e.createElementVNode("div",Tb,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[9]||(h[9]=_=>c.loop=_),type:"checkbox",id:"loop-checkbox",class:"mr-2 rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"},null,512),[[e.vModelCheckbox,c.loop]]),h[26]||(h[26]=e.createElementVNode("label",{for:"loop-checkbox",class:"text-sm text-gray-700 dark:text-gray-300"}," Loop audio track ",-1))])]),e.createElementVNode("div",Mb,[e.createElementVNode("button",{onClick:f,class:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"}," Cancel "),e.createElementVNode("button",{onClick:p,disabled:!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,Bb)])])])):e.createCommentVNode("",!0)]))}}),Lr=Te(Fb,[["__scopeId","data-v-593719ac"]]);function Xe(o,n={},...t){const a=document.createElement(o);for(const[i,r]of Object.entries(n))r!=null&&(i==="className"?a.className=r:i==="style"&&typeof r=="object"?Object.assign(a.style,r):i.startsWith("on")&&typeof r=="function"?a.addEventListener(i.slice(2).toLowerCase(),r):i==="dataset"&&typeof r=="object"?Object.assign(a.dataset,r):a.setAttribute(i,r));for(const i of t)typeof i=="string"?a.appendChild(document.createTextNode(i)):i instanceof HTMLElement&&a.appendChild(i);return a}function Il(o){return typeof o=="boolean"?o?"On":"Off":typeof o=="number"?Number.isInteger(o)?String(o):o.toFixed(2):String(o??"")}let $l=!1;function Ib(){if($l)return;$l=!0;const o=`
34
- /* ── MobileVideoFilterPanel — global (not scoped) ── */
35
- .mvfp {
36
- display: flex;
37
- flex-direction: column;
38
- width: 100%;
39
- position: relative;
40
- background: var(--app-surface, var(--ion-background-color, #1a1a1a));
41
- }
42
-
43
- /* ── Horizontal scroll rows ── */
44
- .mvfp-row {
45
- display: flex;
46
- gap: 8px;
47
- padding: 8px 12px;
48
- overflow-x: auto;
49
- -webkit-overflow-scrolling: touch;
50
- scrollbar-width: none;
51
- flex-shrink: 0;
52
- }
53
- .mvfp-row::-webkit-scrollbar { display: none; }
54
-
55
- /* ── Category chips ── */
56
- .mvfp-cat {
57
- display: flex;
58
- align-items: center;
59
- gap: 6px;
60
- min-height: 36px;
61
- padding: 8px 14px;
62
- border-radius: 20px;
63
- border: 1.5px solid var(--app-border, var(--ion-color-step-300, #444));
64
- background: var(--app-surface-variant, var(--ion-color-step-50, #222));
65
- color: var(--app-text, var(--ion-text-color, #eee));
66
- font-size: 13px;
67
- font-weight: 500;
68
- white-space: nowrap;
69
- cursor: pointer;
70
- flex-shrink: 0;
71
- transition: all 0.15s;
72
- -webkit-tap-highlight-color: transparent;
73
- }
74
- .mvfp-cat.active {
75
- background: var(--app-accent, var(--ion-color-primary, #3880ff));
76
- border-color: var(--app-accent, var(--ion-color-primary, #3880ff));
77
- color: #fff;
78
- }
79
-
80
- /* ── Filter cards ── */
81
- .mvfp-filter {
82
- display: flex;
83
- flex-direction: column;
84
- align-items: center;
85
- justify-content: center;
86
- min-width: 72px;
87
- max-width: 100px;
88
- min-height: 48px;
89
- padding: 10px 12px;
90
- border-radius: 12px;
91
- border: 2px solid var(--app-border, var(--ion-color-step-300, #444));
92
- background: var(--app-surface-variant, var(--ion-color-step-50, #222));
93
- color: var(--app-text, var(--ion-text-color, #eee));
94
- font-size: 12px;
95
- text-align: center;
96
- line-height: 1.3;
97
- cursor: pointer;
98
- flex-shrink: 0;
99
- position: relative;
100
- transition: all 0.15s;
101
- -webkit-tap-highlight-color: transparent;
102
- }
103
- .mvfp-filter.active {
104
- border-color: var(--app-success, var(--ion-color-success, #2dd36f));
105
- }
106
- .mvfp-filter.selected {
107
- background: rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.15);
108
- border-color: var(--app-accent, var(--ion-color-primary, #3880ff));
109
- }
110
- .mvfp-filter .mvfp-check {
111
- position: absolute;
112
- top: -5px;
113
- right: -5px;
114
- width: 18px;
115
- height: 18px;
116
- border-radius: 50%;
117
- background: var(--app-success, var(--ion-color-success, #2dd36f));
118
- color: #fff;
119
- display: flex;
120
- align-items: center;
121
- justify-content: center;
122
- font-size: 11px;
123
- cursor: pointer;
124
- }
125
-
126
- /* ── Active filter chips ── */
127
- .mvfp-active-row {
128
- display: flex;
129
- gap: 6px;
130
- padding: 6px 12px;
131
- overflow-x: auto;
132
- -webkit-overflow-scrolling: touch;
133
- scrollbar-width: none;
134
- flex-shrink: 0;
135
- }
136
- .mvfp-active-row::-webkit-scrollbar { display: none; }
137
-
138
- .mvfp-achip {
139
- display: flex;
140
- align-items: center;
141
- gap: 6px;
142
- padding: 6px 10px 6px 12px;
143
- background: rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.12);
144
- border: 1px solid var(--app-accent, var(--ion-color-primary, #3880ff));
145
- border-radius: 20px;
146
- white-space: nowrap;
147
- flex-shrink: 0;
148
- font-size: 12px;
149
- color: var(--app-text, var(--ion-text-color, #eee));
150
- cursor: pointer;
151
- transition: all 0.15s;
152
- }
153
- .mvfp-achip.selected {
154
- background: var(--app-accent, var(--ion-color-primary, #3880ff));
155
- color: #fff;
156
- }
157
- .mvfp-achip-x {
158
- width: 20px;
159
- height: 20px;
160
- border-radius: 50%;
161
- border: 1.5px solid currentColor;
162
- background: transparent;
163
- color: inherit;
164
- display: flex;
165
- align-items: center;
166
- justify-content: center;
167
- cursor: pointer;
168
- padding: 0;
169
- opacity: 0.7;
170
- flex-shrink: 0;
171
- }
172
- .mvfp-achip-x:hover, .mvfp-achip-x:active {
173
- background: var(--ion-color-danger, #ef4444);
174
- border-color: var(--ion-color-danger, #ef4444);
175
- color: #fff;
176
- opacity: 1;
177
- }
178
-
179
- .mvfp-placeholder {
180
- font-size: 12px;
181
- color: var(--app-text-secondary, var(--ion-color-medium, #888));
182
- padding: 6px 12px;
183
- }
184
-
185
- /* ── Drawer ── */
186
- .mvfp-drawer {
187
- position: absolute;
188
- bottom: 0;
189
- left: 0;
190
- right: 0;
191
- background: var(--app-surface, var(--ion-background-color, #1a1a1a));
192
- border-top: 1px solid var(--app-border, var(--ion-color-step-300, #444));
193
- transform: translateY(100%);
194
- z-index: 20;
195
- display: flex;
196
- flex-direction: column;
197
- overflow: hidden;
198
- border-radius: 14px 14px 0 0;
199
- }
200
- .mvfp-drawer-hdr {
201
- display: flex;
202
- justify-content: space-between;
203
- align-items: center;
204
- padding: 8px 14px;
205
- border-bottom: 1px solid var(--app-border, var(--ion-color-step-200, #333));
206
- flex-shrink: 0;
207
- }
208
- .mvfp-drawer-title {
209
- font-weight: 600;
210
- font-size: 14px;
211
- color: var(--app-text, var(--ion-text-color, #eee));
212
- }
213
- .mvfp-drawer-actions {
214
- display: flex;
215
- align-items: center;
216
- gap: 10px;
217
- }
218
- .mvfp-drawer-btn {
219
- background: none;
220
- border: none;
221
- font-size: 13px;
222
- font-weight: 500;
223
- cursor: pointer;
224
- padding: 4px 6px;
225
- color: var(--app-accent, var(--ion-color-primary, #3880ff));
226
- }
227
- .mvfp-drawer-btn.danger {
228
- color: var(--ion-color-danger, #ef4444);
229
- }
230
- .mvfp-drawer-close {
231
- width: 28px;
232
- height: 28px;
233
- border: none;
234
- border-radius: 50%;
235
- background: var(--app-surface-sunken, var(--ion-color-step-100, #2a2a2a));
236
- color: var(--app-text-secondary, var(--ion-color-medium, #888));
237
- display: flex;
238
- align-items: center;
239
- justify-content: center;
240
- cursor: pointer;
241
- padding: 0;
242
- }
243
- .mvfp-drawer-body {
244
- flex: 1 1 auto;
245
- overflow-y: auto;
246
- -webkit-overflow-scrolling: touch;
247
- padding: 10px 14px 16px;
248
- }
249
-
250
- /* ── Drawer slider controls ── */
251
- .mvfp-ctl {
252
- margin-bottom: 12px;
253
- }
254
- .mvfp-ctl-label {
255
- display: block;
256
- font-size: 11px;
257
- font-weight: 600;
258
- color: var(--app-text-secondary, var(--ion-color-medium, #888));
259
- text-transform: uppercase;
260
- letter-spacing: 0.5px;
261
- margin-bottom: 4px;
262
- }
263
- .mvfp-slider-row {
264
- display: flex;
265
- align-items: center;
266
- gap: 10px;
267
- }
268
- .mvfp-range {
269
- flex: 1;
270
- height: 6px;
271
- -webkit-appearance: none;
272
- appearance: none;
273
- background: var(--app-border, var(--ion-color-step-200, #333));
274
- border-radius: 3px;
275
- outline: none;
276
- }
277
- .mvfp-range::-webkit-slider-thumb {
278
- -webkit-appearance: none;
279
- width: 22px;
280
- height: 22px;
281
- border-radius: 50%;
282
- background: var(--app-accent, var(--ion-color-primary, #3880ff));
283
- cursor: pointer;
284
- border: 2px solid #fff;
285
- box-shadow: 0 1px 4px rgba(0,0,0,0.3);
286
- }
287
- .mvfp-range-val {
288
- min-width: 3rem;
289
- text-align: right;
290
- font-size: 12px;
291
- font-weight: 500;
292
- color: var(--app-text-secondary, var(--ion-color-medium, #888));
293
- }
294
- .mvfp-toggle-row {
295
- display: flex;
296
- align-items: center;
297
- justify-content: space-between;
298
- gap: 10px;
299
- }
300
- .mvfp-color-row {
301
- display: flex;
302
- align-items: center;
303
- justify-content: space-between;
304
- gap: 10px;
305
- }
306
- .mvfp-color-input {
307
- width: 36px;
308
- height: 36px;
309
- border: 1px solid var(--app-border, var(--ion-color-step-300, #444));
310
- border-radius: 8px;
311
- padding: 2px;
312
- cursor: pointer;
313
- background: transparent;
314
- }
315
- .mvfp-select-row {
316
- display: flex;
317
- align-items: center;
318
- justify-content: space-between;
319
- gap: 10px;
320
- }
321
- .mvfp-select {
322
- padding: 6px 10px;
323
- border: 1px solid var(--app-border, var(--ion-color-step-300, #444));
324
- border-radius: 8px;
325
- background: var(--app-surface, var(--ion-background-color, #1a1a1a));
326
- color: var(--app-text, var(--ion-text-color, #eee));
327
- font-size: 13px;
328
- }
329
- .mvfp-no-params {
330
- text-align: center;
331
- color: var(--app-text-secondary, var(--ion-color-medium, #888));
332
- font-style: italic;
333
- font-size: 13px;
334
- padding: 12px 0;
335
- }
336
- `,n=document.createElement("style");n.textContent=o,document.head.appendChild(n)}class $b{constructor({filters:n=[],callbacks:t={}}){Ib(),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=Xe("div",{className:"mvfp"}),this._catRow=Xe("div",{className:"mvfp-row"}),this._root.appendChild(this._catRow),this._filterRow=Xe("div",{className:"mvfp-row"}),this._root.appendChild(this._filterRow),this._activeRow=Xe("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,a)=>{this._activeFilters.set(a,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 a=t.category||"other";n.has(a)||n.set(a,a.charAt(0).toUpperCase()+a.slice(1))}return n}_renderCategories(){this._catRow.innerHTML="",this._getCategories().forEach((t,a)=>{const i=Xe("div",{className:`mvfp-cat${this._selectedCategory===a?" active":""}`,onClick:()=>{this._selectedCategory=a,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),a=this._selectedFilterId===n.id,i=Xe("div",{className:`mvfp-filter${t?" active":""}${a?" selected":""}`,onClick:()=>this._selectFilter(n)});if(t){const r=Xe("div",{className:"mvfp-check",onClick:s=>{s.stopPropagation(),this._removeFilter(n.id)}});r.innerHTML="✓",i.appendChild(r)}i.appendChild(Xe("span",{},n.name)),this._filterRow.appendChild(i)}}_selectFilter(n){var t,a,i,r;this._selectedFilterId=n.id,this._activeFilters.has(n.id)||(a=(t=this._cb).onApplyFilter)==null||a.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,a;(a=(t=this._cb).onRemoveFilter)==null||a.call(t,n),this._selectedFilterId===n&&(this._selectedFilterId=null)}_renderActiveChips(){if(this._activeRow.innerHTML="",this._activeFilters.size===0){this._activeRow.appendChild(Xe("div",{className:"mvfp-placeholder"},"No active filters"));return}this._activeFilters.forEach((n,t)=>{const a=this._filters.find(c=>c.id===t);if(!a)return;const i=this._drawerOpen&&this._drawerFilterId===t,r=Xe("div",{className:`mvfp-achip${i?" selected":""}`}),s=Xe("span",{style:{cursor:"pointer"},onClick:()=>{this._selectedFilterId=t,this._renderFilters(),a.params&&a.params.length>0&&this.openDrawer(t)}},a.name),l=Xe("button",{className:"mvfp-achip-x","aria-label":`Remove ${a.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=Xe("div",{className:"mvfp-drawer"});const n=Xe("div",{className:"mvfp-drawer-hdr"});this._drawerTitle=Xe("span",{className:"mvfp-drawer-title"},"Filter");const t=Xe("div",{className:"mvfp-drawer-actions"});t.appendChild(Xe("button",{className:"mvfp-drawer-btn",onClick:()=>this._resetDrawerFilter()},"Reset")),t.appendChild(Xe("button",{className:"mvfp-drawer-btn danger",onClick:()=>{this._drawerFilterId&&(this._removeFilter(this._drawerFilterId),this.closeDrawer())}},"Remove"));const a=Xe("button",{className:"mvfp-drawer-close","aria-label":"Close",onClick:()=>this.closeDrawer()});a.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(a),n.appendChild(this._drawerTitle),n.appendChild(t),this._drawer.appendChild(n),this._drawerBody=Xe("div",{className:"mvfp-drawer-body"}),this._drawer.appendChild(this._drawerBody)}openDrawer(n){const t=this._filters.find(a=>a.id===n);if(t&&(this._drawerFilterId=n,this._drawerTitle.textContent=t.name,this._renderDrawerControls(t),this._renderActiveChips(),!this._drawerOpen)){this._drawerOpen=!0;const a=this._root.offsetHeight;a>0&&(this._drawer.style.height=a+"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(Xe("div",{className:"mvfp-no-params"},"No adjustable parameters"));return}const t=this._activeFilters.get(n.id),a=(t==null?void 0:t.params)||{};for(const i of n.params){const r=a[i.id]??i.default,s=Xe("div",{className:"mvfp-ctl"}),l=Xe("label",{className:"mvfp-ctl-label"},i.label||i.id);s.appendChild(l);const c=i.type||"slider";if(c==="slider"||c==="range"){const d=Xe("div",{className:"mvfp-slider-row"}),u=Xe("span",{className:"mvfp-range-val"},Il(r)),m=Xe("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:f=>{var v,g;const p=parseFloat(f.target.value);u.textContent=Il(p),(g=(v=this._cb).onUpdateParam)==null||g.call(v,n.id,i.id,p)}});d.appendChild(m),d.appendChild(u),s.appendChild(d)}else if(c==="toggle"||c==="checkbox"){const d=Xe("div",{className:"mvfp-toggle-row"}),u=Xe("input",{type:"checkbox",checked:r?"checked":void 0,onChange:m=>{var f,p;return(p=(f=this._cb).onUpdateParam)==null?void 0:p.call(f,n.id,i.id,m.target.checked)}});d.appendChild(u),s.appendChild(d)}else if(c==="color"){const d=Xe("div",{className:"mvfp-color-row"}),u=Xe("input",{type:"color",className:"mvfp-color-input",value:typeof r=="string"?r:"#000000",onInput:m=>{var f,p;return(p=(f=this._cb).onUpdateParam)==null?void 0:p.call(f,n.id,i.id,m.target.value)}});d.appendChild(u),s.appendChild(d)}else if(c==="select"||c==="dropdown"){const d=Xe("div",{className:"mvfp-select-row"}),u=Xe("select",{className:"mvfp-select",onChange:m=>{var f,p;return(p=(f=this._cb).onUpdateParam)==null?void 0:p.call(f,n.id,i.id,m.target.value)}});for(const m of i.options||[]){const f=Xe("option",{value:m.value},m.label||String(m.value));m.value===r&&(f.selected=!0),u.appendChild(f)}d.appendChild(u),s.appendChild(d)}this._drawerBody.appendChild(s)}}_resetDrawerFilter(){var t,a;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)(a=(t=this._cb).onUpdateParam)==null||a.call(t,this._drawerFilterId,i.id,i.default);this._renderDrawerControls(n)}}}function Rl(o){var s,l;Rb(o);const n=Db(o.clips),t=[],a=Ab(o),i=Lb(o),r={version:"1.0",source:{media_uuid:o.mediaUuid,duration:o.originalDuration,original_width:((s=o.media)==null?void 0:s.width)||1920,original_height:((l=o.media)==null?void 0:l.height)||1080},timeline:n,filters:t,audio:a,output:i,metadata:{created_at:new Date().toISOString(),editor_version:"2.0.0"}};return o.textOverlays&&(r.textOverlays=o.textOverlays),o.audioTracks&&(r.audioTracks=o.audioTracks.filter(c=>typeof c.source=="string")),r}function Rb(o){if(!o.mediaUuid)throw new Error("Media UUID is required");if(!o.clips||o.clips.length===0)throw new Error("At least one clip is required");const n=[...o.clips].sort((t,a)=>t.timelineStart-a.timelineStart);for(let t=1;t<n.length;t++)if(n[t].timelineStart<n[t-1].timelineEnd)throw new Error(`Clips ${n[t-1].id} and ${n[t].id} overlap on timeline`)}function Db(o){return o.map(n=>{const t=n.speed||1,a=typeof n.sourceIn=="number"&&!Number.isNaN(n.sourceIn),i=typeof n.sourceOut=="number"&&!Number.isNaN(n.sourceOut),r=Math.max(0,n.timelineEnd-n.timelineStart),s=n.sourceOffset??n.trimStart??0;let l=Number(a?n.sourceIn:s),c=i?Number(n.sourceOut):Number(s)+r/t;return c>l||(c=l+Math.max(.033,r/Math.max(1e-6,t))),{id:n.id,type:"clip",timelineStart:n.timelineStart,timelineEnd:n.timelineEnd,sourceIn:l,sourceOut:c,speed:t,filters:n.filters?[...n.filters]:[]}})}function Ab(o){const n={volume:o.audioVolume,muted:o.audioVolume===0};return o.audioFadeIn>0&&(n.fadeIn=o.audioFadeIn),o.audioFadeOut>0&&(n.fadeOut=o.audioFadeOut),n}function Lb(o){var r;const n={"360p":{bitrate:1e6},"480p":{bitrate:25e5},"720p":{bitrate:5e6},"1080p":{bitrate:8e6},"1440p":{bitrate:16e6},"2160p":{bitrate:35e6}},t=n[o.exportQuality]||n["1080p"],a=(r=o.media)==null?void 0:r.frame_rate,i=a&&Number.isFinite(a)&&a>0?a:30;return{format:o.exportFormat||"mp4",codec:"h264",quality:o.exportQuality||"1080p",fps:i,bitrate:t.bitrate}}function vo(o,n=30){const t=typeof o=="number"?o:Number(o);return Number.isFinite(t)&&t>0?t:n}function rd(o,n,t){var je,G,q;const a=typeof o=="string"&&o.trim()!==""?o.trim():`temp-${Date.now()}`,i=e.reactive({mediaUuid:a,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),m=vo(((je=n==null?void 0:n.output)==null?void 0:je.fps)??(t==null?void 0:t.frame_rate)),f=e.shallowRef(null),p=new od(m),v=e.ref(m),g=e.ref(!1),k=e.ref(!1);n&&n.timeline&&n.timeline.length>0?(x(n),(G=n.output)!=null&&G.fps&&(v.value=vo(n.output.fps,v.value),p.setFps(v.value))):(_(),n&&((q=n.output)!=null&&q.fps&&(v.value=vo(n.output.fps,v.value),p.setFps(v.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 T=e.ref(1),V=e.computed(()=>i.selectedClipId?i.clips.find(A=>A.id===i.selectedClipId)??null:null);e.watch(V,A=>{T.value=(A==null?void 0:A.speed)??1},{immediate:!0});const b=e.computed(()=>s.value.length>0),h=e.computed(()=>l.value.length>0);function _(){const A=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0?t.duration:1;t&&(i.media=t),i.originalDuration=A,i.totalDuration=A;const J=he(),ae={id:J,type:"clip",timelineStart:0,timelineEnd:A,sourceIn:0,sourceOut:A,sourceMinIn:0,sourceMaxOut:A,speed:1};i.clips=[ae],i.selectedClipId=J,c.value=J,!(t||a.startsWith("temp-"))&&(async()=>{try{const se=await fetch(`/api/v1/video/${encodeURIComponent(a)}`);if(!se.ok)throw new Error(`Failed to fetch media: ${se.status}`);const Ce=await se.json(),Ae=typeof Ce=="object"&&Ce!==null&&"data"in Ce?Ce.data:Ce;if(!Ae||typeof Ae!="object")throw new Error("Failed to parse media payload");const De=Ae;i.media=De,n||(v.value=vo(De.frame_rate,v.value),p.setFps(v.value));const Le=typeof De.duration=="number"&&De.duration>0?De.duration:A;if(i.hasChanges||i.clips.length!==1||i.clips[0].id!==J)return;i.originalDuration=Le,i.totalDuration=Le;const Ue=i.clips[0];Ue.timelineStart=0,Ue.timelineEnd=Le,Ue.sourceIn=0,Ue.sourceOut=Le,Ue.sourceMinIn=0,Ue.sourceMaxOut=Le,z(),d=!0}catch{}})()}function R(A,J){if(A.originalDuration!==1)return;A.originalDuration=J,A.totalDuration===1&&(A.totalDuration=J);const ae=A.clips[0],se=!n&&A.clips.length===1&&ae!==void 0&&ae.timelineStart===0&&ae.timelineEnd===1&&ae.sourceIn===0&&ae.sourceOut===1;for(const Ce of A.clips)(Ce.sourceMaxOut===1||Ce.sourceMaxOut===void 0)&&(Ce.sourceMaxOut=J);se&&ae!==void 0&&(ae.sourceOut=J,ae.timelineEnd=J)}function M(A){if(!Number.isFinite(A)||A<=0||d)return;const J=i.hasChanges;i.originalDuration=A,i.totalDuration=Math.max(i.totalDuration,A),i.media&&(i.media.duration=A);for(const Ce of i.clips)Ce.sourceMaxOut=A;const ae=i.clips[0];!n&&i.clips.length===1&&ae!==void 0&&ae.timelineStart===0&&ae.timelineEnd===1&&ae.sourceIn===0&&ae.sourceOut===1&&ae!==void 0&&(ae.sourceOut=A,ae.timelineEnd=ae.timelineStart+(ae.sourceOut-ae.sourceIn)),z();for(const Ce of s.value)R(Ce,A);for(const Ce of l.value)R(Ce,A);d=!0,e.nextTick(()=>{J||(i.hasChanges=!1)})}function x(A){i.clips=A.timeline.map(J=>({...J,sourceMinIn:J.sourceMinIn??0,sourceMaxOut:J.sourceMaxOut??A.source.duration})),i.filters=[],i.audioVolume=A.audio.volume,i.audioFadeIn=A.audio.fadeIn||0,i.audioFadeOut=A.audio.fadeOut||0,i.exportFormat=A.output.format,i.exportQuality=A.output.quality,i.originalDuration=A.source.duration,i.clips.length>0?(i.selectedClipId=i.clips[0].id,c.value=i.selectedClipId):(delete i.selectedClipId,c.value=void 0),z()}function C(){s.value.push(JSON.parse(JSON.stringify(i))),l.value=[],i.hasChanges=!0}function P(){if(!b.value)return;const A=s.value.pop();l.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,A)}function S(){if(!h.value)return;const A=l.value.pop();s.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,A)}function D(A,J,ae){C();const se=i.clips.find(Le=>Le.id===A);if(!se)return;const Ce=1/v.value,Ae=se.sourceMinIn??0,De=se.sourceMaxOut??i.originalDuration;if(J==="start"){const Le=se.sourceIn,Ue=Math.max(Ae,Math.min(ae,se.sourceOut-Ce));se.sourceIn=Ue;const Ke=Ue-Le;se.timelineStart+=Ke}else{const Le=Math.max(se.sourceIn+Ce,Math.min(ae,De));se.sourceOut=Le;const Ue=se.sourceOut-se.sourceIn;se.timelineEnd=se.timelineStart+Ue}z(),f.value&&f.value.trimClip(A,se.sourceIn,se.sourceOut)}function I(A){C();const J=i.clips.find(De=>A>De.timelineStart&&A<De.timelineEnd);if(!J)return;const ae=A-J.timelineStart,se=J.sourceIn+ae,Ce={id:he(),type:"clip",timelineStart:A,timelineEnd:J.timelineEnd,sourceIn:se,sourceOut:J.sourceOut,speed:J.speed??1,sourceMinIn:J.sourceMinIn??0,sourceMaxOut:J.sourceMaxOut??i.originalDuration,filters:[...J.filters||[]]};J.timelineEnd=A,J.sourceOut=se;const Ae=i.clips.indexOf(J);i.clips.splice(Ae+1,0,Ce),i.selectedClipId=Ce.id}function j(){I(i.playheadPosition)}function O(A){var ae;const J=A??i.selectedClipId??c.value??((ae=i.clips[0])==null?void 0:ae.id);J&&(i.selectedClipId=J,c.value=J)}function F(){if(!i.selectedClipId||i.clips.length<=1)return;C();const A=i.clips.findIndex(J=>J.id===i.selectedClipId);if(A!==-1){i.clips.splice(A,1);const J=Math.min(A,i.clips.length-1);i.selectedClipId=i.clips[J].id,c.value=i.selectedClipId,z()}}function B(){return[...i.clips].sort((A,J)=>A.timelineStart-J.timelineStart)}function w(A){const J=B(),ae=J.findIndex(Ke=>Ke.id===A);if(ae===-1)return null;const se=J[ae],Ce=se.timelineEnd-se.timelineStart,Ae=ae>0?J[ae-1]:null,De=ae<J.length-1?J[ae+1]:null,Le=Ae?Ae.timelineEnd:0,Ue=De?De.timelineStart-Ce:Math.max(se.timelineStart,i.totalDuration-Ce);return{minStart:Le,maxStart:Math.max(Le,Ue)}}function $(A,J){const ae=i.clips.find(De=>De.id===A);if(!ae)return;const se=w(A),Ce=se?Math.min(se.maxStart,Math.max(se.minStart,J)):Math.max(0,J);if(Ce===ae.timelineStart)return;C();const Ae=Ce-ae.timelineStart;ae.timelineStart=Ce,ae.timelineEnd+=Ae,z(),f.value&&f.value.moveClip(A,Ce)}function z(){if(i.clips.length===0){i.totalDuration=0;return}const A=i.clips.reduce((J,ae)=>ae.timelineEnd>J.timelineEnd?ae:J);i.totalDuration=A.timelineEnd}function W(){i.zoomLevel=Math.min(200,i.zoomLevel*1.2)}function Q(){i.zoomLevel=Math.max(10,i.zoomLevel/1.2)}function ye(A){i.zoomLevel=Math.max(10,Math.min(600,Math.round(A)))}function we(){i.isPlaying=!i.isPlaying}function ie(A){i.isPlaying=A}function N(A){i.playheadPosition=Math.max(0,Math.min(A,i.totalDuration))}function L(){const A=Rl(i);try{localStorage.setItem(`video-draft-${a}`,JSON.stringify(A))}catch{}return A}function te(){i.hasChanges=!1}function ne(){return confirm("Are you sure you want to reset all changes?")?(C(),_(),i.hasChanges=!1,!0):!1}function re(){return Rl(i)}function he(){return`clip-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}async function de(A=1920,J=1080){if(u.value)try{f.value=new ad(A,J,v.value),await me()}catch{f.value=null}}async function me(){if(!(!f.value||k.value)){k.value=!0;try{const A=re();await f.value.loadFromRecipe(A);const J=p.secondsToFrames(i.playheadPosition);f.value.seek(J)}catch{}finally{k.value=!1}}}function Ve(A){}function ce(A){return p.secondsToFrames(A)}function pe(A){return p.framesToSeconds(A)}function xe(A){const J=pe(A);N(J),f.value&&f.value.seek(A)}function Fe(){g.value=!g.value}function ut(){me()}function tt(A){u.value=!1,f.value=null}e.watch(()=>i.clips,()=>{i.hasChanges=!0,u.value&&f.value&&me()},{deep:!0}),e.watch(()=>i.filters,()=>{i.hasChanges=!0,u.value&&f.value&&me()},{deep:!0}),e.watch(()=>i.clips.map(A=>A.id),()=>{var J;if(!i.clips.length){delete i.selectedClipId,c.value=void 0;return}if(!i.clips.some(ae=>ae.id===i.selectedClipId)){const ae=c.value&&((J=i.clips.find(se=>se.id===c.value))==null?void 0:J.id);i.selectedClipId=ae??i.clips[0].id,c.value=i.selectedClipId}},{deep:!0});function Et(A){const J=i.selectedClipId?i.clips.find(ae=>ae.id===i.selectedClipId):i.clips[0];J&&(J.filters=[...A],i.hasChanges=!0)}function ot(A){i.textOverlays=[...A]}function at(A){i.audioTracks=[...A]}e.watch(u,A=>{A?de():f.value&&(f.value.destroy(),f.value=null)}),e.watch(g,()=>{}),e.watch(v,A=>{p.setFps(A)});function bt(){if(!i.selectedClipId)return;C();const A=i.clips.find(se=>se.id===i.selectedClipId);if(!A)return;const J={...A,id:he(),timelineStart:A.timelineEnd,timelineEnd:A.timelineEnd+(A.timelineEnd-A.timelineStart),filters:[...A.filters||[]]},ae=i.clips.indexOf(A);i.clips.splice(ae+1,0,J),i.selectedClipId=J.id,i.hasChanges=!0}function Vt(A){const J=A??800,ae=i.totalDuration;if(ae<=0){i.zoomLevel=50;return}const se=J*.8/ae;i.zoomLevel=Math.max(10,Math.min(600,Math.round(se)))}function vt(){const A=1/v.value;N(Math.min(i.playheadPosition+A,i.totalDuration))}function st(){const A=1/v.value;N(Math.max(i.playheadPosition-A,0))}function ve(){N(0)}function Ee(){N(i.totalDuration)}function Ne(A){if(!Number.isFinite(A)||A<=0)return;const J=V.value??i.clips[0];if(!J){T.value=A;return}const ae=J.speed??1;if(ae===A){T.value=A;return}C();const se=Math.max(1/v.value,J.sourceOut-J.sourceIn),Ce=se/ae,Ae=se/A,De=Ae-Ce;J.speed=A,J.timelineEnd=J.timelineStart+Ae;const Le=i.clips.findIndex(Ue=>Ue.id===J.id);if(Le!==-1&&De!==0)for(let Ue=Le+1;Ue<i.clips.length;Ue+=1){const Ke=i.clips[Ue];Ke.timelineStart+=De,Ke.timelineEnd+=De}z(),i.playheadPosition=Math.max(0,Math.min(i.playheadPosition,i.totalDuration)),i.hasChanges=!0,T.value=A}return{currentFrame:r,playheadPosition:e.computed(()=>i.playheadPosition),timelineClips:e.computed(()=>i.clips),totalDuration:e.computed(()=>i.totalDuration),hasChanges:e.computed(()=>i.hasChanges),isPlaying:e.computed(()=>i.isPlaying),selectedClip:V,zoomLevel:e.computed(()=>i.zoomLevel),playbackSpeed:T,useVideoEngine:u,compositionAdapter:e.computed(()=>f.value),fps:v,useFrameMode:g,handleTrim:D,handleSplit:I,handleClipSelect:O,splitAtPlayhead:j,deleteSelectedClip:F,duplicateSelectedClip:bt,setFilters:Et,setTextOverlays:ot,setAudioTracks:at,moveClip:$,saveDraft:L,clearHasChanges:te,resetChanges:ne,generateRecipe:re,zoomIn:W,zoomOut:Q,setZoomLevel:ye,fitToWindow:Vt,togglePlayback:we,setPlaying:ie,seekTo:N,frameForward:vt,frameBackward:st,skipToStart:ve,skipToEnd:Ee,setPlaybackSpeed:Ne,updateSourceDuration:M,undo:P,redo:S,canUndo:b,canRedo:h,initializeComposition:de,syncCompositionWithState:me,syncWithComposition:Ve,convertToFrames:ce,convertToSeconds:pe,seekToFrame:xe,toggleFrameMode:Fe,onCompositionReady:ut,onCompositionError:tt}}const Ub=[{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}}}],Ob={dropShadow:"drop-shadow",softFocus:"blur",blackAndWhite:"grayscale",gaussianBlur:"blur","gaussian-blur":"blur"};function ci(o){return typeof o=="object"&&o!==null}function Pb(o,n){if(typeof o=="number"&&Number.isFinite(o))return o;if(typeof o=="string"){const t=Number(o);if(Number.isFinite(t))return t}return n}function di(o){if(typeof o=="number"||typeof o=="string"||typeof o=="boolean")return o}function zb(o){const n={id:o.id,type:o.type,label:o.label};o.property!==void 0&&(n.property=o.property),o.min!==void 0&&(n.min=o.min),o.max!==void 0&&(n.max=o.max),o.step!==void 0&&(n.step=o.step);const t=di(o.default);return t!==void 0&&(n.default=t),o.options!==void 0&&(n.options=o.options),n}function sd(o,n,t){const a=le.getFilter(o),i={},r=(a==null?void 0:a.defaultParams)??t;if(r&&ci(r))for(const[s,l]of Object.entries(r))i[s]=di(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 ld(o){const n={};for(const t of o){if(t.type!=="slider")continue;const a=t.property??t.id;n[a]={min:t.min??0,max:t.max??100,step:t.step??1}}return n}function jb(o,n,t,a){const i=a.map(zb);return{id:o,name:n,category:t,controls:i,params:i,defaultParams:sd(o,i),paramRanges:ld(i)}}function Wb(o){const n=o.paramRanges??{},t=Object.entries(n).map(([a,i])=>{var l;const r={id:a,type:"slider",label:a.replace(/[-_]/g," ").replace(/\b\w/g,c=>c.toUpperCase()),property:a,min:i.min,max:i.max,step:i.step},s=di((l=o.defaultParams)==null?void 0:l[a]);return s!==void 0&&(r.default=s),r});return{id:o.id,name:o.name,category:o.category,controls:t,params:t,defaultParams:sd(o.id,t,o.defaultParams),paramRanges:ld(t)}}function Zb(o,n){return n.toLowerCase()==="unlisted"?!1:le.isFilterCompatibleWithMedia(o,"video")}function or(o){return Ob[o]??o}function Na(o){const n=Pb(o,1);return Math.max(0,Math.min(1,n))}function Ta(o){if(!ci(o))return{};const n={};for(const[t,a]of Object.entries(o))n[t]=di(a)??null;return n}function Hb(o){return!ci(o)||typeof o.filterId!="string"?null:{filterId:o.filterId,params:Ta(o.params),intensity:Na(o.intensity)}}function Xb(o){if(!ci(o)||typeof o.id!="string"||typeof o.name!="string")return null;const t=(Array.isArray(o.filters)?o.filters:[]).map(i=>Hb(i)).filter(i=>i!==null),a=typeof o.created_at=="string"?o.created_at:new Date().toISOString();return{id:o.id,name:o.name,filters:t,created_at:a}}function cd(){le.initializeFilterRegistry();const o=e.ref([]),n=e.ref(null),t=e.ref(null),a=e.ref([]),i=e.ref(null),r=e.reactive({}),s=e.computed(()=>{const I=new Map,j=le.getRegisteredFilters();for(const O of j)Zb(O.id,O.category)&&I.set(O.id,jb(O.id,O.name,O.category,O.controls));for(const O of Ub)I.has(O.id)||I.set(O.id,Wb(O));return Array.from(I.values())}),l=e.computed(()=>{const I=new Map;for(const j of s.value)I.set(j.id,j);return I}),c=e.computed(()=>o.value.length>0),d=e.computed(()=>{const I={};for(const j of s.value)I[j.category]||(I[j.category]=[]),I[j.category].push(j);return I});function u(I){const j=l.value.get(I);if(j)return j;const O=or(I);return l.value.get(O)??null}function m(I){const j=l.value.get(I);if(j)return j.id;const O=or(I),F=l.value.get(O);return F?F.id:null}function f(I){const j=I?u(I):n.value;if(!j)return;const O=j.defaultParams||{},F={id:C(),filterId:j.id,params:{...O},intensity:1};return o.value.push(F),i.value=F.id,n.value=j,Object.keys(r).forEach(B=>delete r[B]),Object.assign(r,F.params),t.value=null,F}function p(I){const j=u(I);if(!j)return;n.value=j;const O=j.defaultParams||S(I);Object.assign(r,O),t.value={id:"preview",filterId:j.id,params:{...O},intensity:1}}function v(I){if(Object.assign(r,I),t.value&&(t.value.params={...r}),i.value){const j=o.value.find(O=>O.id===i.value);j&&(j.params={...r})}}function g(I){const j=o.value.findIndex(O=>O.id===I);j!==-1&&o.value.splice(j,1)}function k(I,j){if(I<0||I>=o.value.length||j<0||j>=o.value.length)return;const[O]=o.value.splice(I,1);o.value.splice(j,0,O)}function T(I,j){const O=o.value.find(F=>F.id===I);O&&(O.intensity=Math.max(0,Math.min(1,j)))}function V(I){const j=o.value.find(O=>O.id===I);j&&(j.intensity=j.intensity>0?0:1)}function b(){o.value=[],t.value=null,n.value=null,i.value=null,Object.keys(r).forEach(I=>delete r[I])}function h(I){const j={id:P(),name:I,filters:o.value.map(F=>({filterId:F.filterId,params:Ta(F.params),intensity:Na(F.intensity)})),created_at:new Date().toISOString()};a.value.push(j);const O=a.value.map(F=>({...F}));return localStorage.setItem("video-filter-presets",JSON.stringify(O)),j}function _(I){const j=a.value.find(O=>O.id===I);if(j){b();for(const O of j.filters){const F=u(O.filterId);F&&o.value.push({id:C(),filterId:F.id,params:{...O.params},intensity:Na(O.intensity)})}}}function R(I){const j=a.value.findIndex(O=>O.id===I);j!==-1&&(a.value.splice(j,1),localStorage.setItem("video-filter-presets",JSON.stringify(a.value)))}function M(){try{const I=localStorage.getItem("video-filter-presets");if(!I)return;const j=JSON.parse(I);if(!Array.isArray(j))return;a.value=j.map(O=>Xb(O)).filter(O=>O!==null)}catch{}}function x(){if(o.value.length===0)return"No filters applied";const I=o.value.map(j=>{const O=D(j.filterId);return(O==null?void 0:O.name)||j.filterId});return I.length===1?I[0]:I.length===2?`${I[0]} + ${I[1]}`:`${I[0]} + ${I.length-1} more`}function C(){return`filter-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function P(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function S(I){const j=u(I);return j?j.defaultParams||{}:{}}function D(I){return u(I)}return M(),{videoCompatibleFilters:s,activeFilters:o,selectedFilter:n,previewFilter:t,filterPresets:a,filterParams:r,hasActiveFilters:c,filtersByCategory:d,applyFilter:f,previewFilterEffect:p,updateFilterParams:v,removeFilter:g,reorderFilters:k,updateFilterIntensity:T,toggleFilter:V,clearAllFilters:b,saveFilterPreset:h,loadFilterPreset:_,deleteFilterPreset:R,getFilterSummary:x,setActiveFilters(I){var O;const j=[];for(const F of I){const B=m(F.filterId);if(!B){const w=or(F.filterId);j.push({...F,filterId:w,params:Ta(F.params),intensity:Na(F.intensity)});continue}j.push({...F,filterId:B,params:Ta(F.params),intensity:Na(F.intensity)})}o.value=j,i.value=((O=o.value[0])==null?void 0:O.id)??null,Object.keys(r).forEach(F=>delete r[F]),o.value[0]&&Object.assign(r,Ta(o.value[0].params))}}}class dd{constructor(n){this.textClips=new Map,this.fonts=new Map,this.nextId=0,this.composition=n,this.initializeDefaultFonts()}initializeDefaultFonts(){try{this.fonts.set("default",new kt({source:"https://fonts.googleapis.com/css2?family=Inter:wght@400",family:"Inter",weight:"400"})),this.fonts.set("bold",new kt({source:"https://fonts.googleapis.com/css2?family=Inter:wght@700",family:"Inter",weight:"700"})),this.fonts.set("serif",new kt({source:"https://fonts.googleapis.com/css2?family=Merriweather:wght@400",family:"Merriweather",weight:"400"}))}catch{}}async loadWebFont(n,t,a,i="400"){const r=new kt({source:t,family:a,weight:i});this.fonts.set(n,r)}loadLocalFont(n,t,a="400"){const i=new kt({source:`local('${t}')`,family:t,weight:a});this.fonts.set(n,i)}async addTextOverlay(n){const t=`text-overlay-${this.nextId++}`,a={text:n.text,fontSize:n.fontSize||24,fillStyle:n.color||"#ffffff",textAlign:n.textAlign||"center",textBaseline:n.textBaseline||"middle"},i=n.fontFamily||"default",r=this.fonts.get(i)||this.fonts.get("default");if(a.font=r,n.position)if(typeof n.position=="string")switch(n.position){case"center":a.position="center";break;case"top":a.x="50%",a.y="10%";break;case"bottom":a.x="50%",a.y="90%";break;case"left":a.x="10%",a.y="50%";break;case"right":a.x="90%",a.y="50%";break}else a.x=n.position.x,a.y=n.position.y;else a.position="center";if(n.startTime!==void 0&&(a.start=_e.fromSeconds(n.startTime)),n.duration!==void 0){const l=n.startTime||0;a.stop=_e.fromSeconds(l+n.duration)}n.animation&&this.applyAnimation(a,n.animation,n);const s=new sa(a);return await this.composition.add(s),this.textClips.set(t,s),t}applyAnimation(n,t,a){if(!t)return;const i=a.startTime?Math.round(a.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 Ie([i,l],[0,1],{easing:c});break;case"fade-out":n.alpha=new Ie([i,l],[1,0],{easing:c});break;case"rotate":t.rotation&&(n.rotation=new Ie([i,l],[t.rotation.from,t.rotation.to],{easing:c}));break;case"scale":t.scale&&(n.scale=new Ie([i,l],[t.scale.from,t.scale.to],{easing:c}));break;case"slide":t.translate&&(n.translate={x:new Ie([i,l],[t.translate.fromX,t.translate.toX],{easing:c}),y:new Ie([i,l],[t.translate.fromY,t.translate.toY],{easing:c})});break;case"typewriter":n.alpha=new Ie([i,l],[0,1],{easing:"linear"});break;case"custom":t.rotation&&(n.rotation=new Ie([i,l],[t.rotation.from,t.rotation.to],{easing:c})),t.scale&&(n.scale=new Ie([i,l],[t.scale.from,t.scale.to],{easing:c})),t.translate&&(n.translate={x:new Ie([i,l],[t.translate.fromX,t.translate.toX],{easing:c}),y:new Ie([i,l],[t.translate.fromY,t.translate.toY],{easing:c})});break}}async updateTextOverlay(n,t){if(!this.textClips.get(n))throw new Error(`Text overlay with id ${n} not found`);await this.removeTextOverlay(n);const i={...t};await this.addTextOverlay(i)}async removeTextOverlay(n){const t=this.textClips.get(n);if(!t)throw new Error(`Text overlay with id ${n} not found`);const a=this.composition.tracks;for(const i of a){const r=i.clips.indexOf(t);if(r!==-1){i.clips.splice(r,1);break}}this.textClips.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(){const n=[];return this.textClips.forEach((t,a)=>{const i={text:t.text||"",fontSize:t.fontSize,color:t.fillStyle,fontFamily:"default",position:"center"};n.push({id:a,config:i})}),n}async addCaptions(n,t="classic",a){var c,d;const r={classic:Ha,cascade:oi,guinea:ai,solar:ii,spotlight:Xa,whisper:Ga}[t],s=await this.composition.createTrack("caption"),l=new qo({transcript:n});if(await s.add(l),await((c=s.generate)==null?void 0:c.call(s,r)),a&&s.clips.length>0){const u=s.clips[0];(d=u.set)==null||d.call(u,a)}}}class ud{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 a=await bn.from(n),i=t||`audio-source-${this.nextId++}`;return this.audioSources.set(i,a),a}catch(a){throw a instanceof Error?a: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++}`;let a;try{if(typeof n.source=="object"&&n.source instanceof bn)a=n.source;else if(typeof n.source=="string")a=await bn.from(n.source);else if(typeof n.source=="object"&&n.source instanceof File)a=await bn.from(URL.createObjectURL(n.source));else throw new Error("Invalid audio source")}catch(c){throw c instanceof Error?c:new Error("Failed to create audio source")}const i={source:a,volume:(n.volume??1)*this.masterVolume};if(n.startTime!==void 0&&(i.start=_e.fromSeconds(n.startTime)),n.duration!==void 0){const c=n.startTime||0;i.stop=_e.fromSeconds(c+n.duration)}(n.fadeIn||n.fadeOut)&&(i.volume=this.createVolumeKeyframes(n));const r=new jo(i);let s=this.composition.tracks.find(c=>c.kind==="audio");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}createVolumeKeyframes(n){const t=(n.volume??1)*this.masterVolume,a=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(a,a+l),s.push(0,t)}else r.push(a),s.push(t);if(n.fadeOut&&i){const l=a+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 Ie(r,s,{easing:"linear"})}async updateVolume(n,t){const a=this.audioLayers.get(n);if(!a)throw new Error(`Audio track with id ${n} not found`);const i=Math.max(0,Math.min(1,t));a.clip.volume=i*this.masterVolume,a.config.volume=i}async applyFadeIn(n,t){const a=this.audioLayers.get(n);if(!a)throw new Error(`Audio track with id ${n} not found`);a.config.fadeIn=t,a.clip.set({volume:this.createVolumeKeyframes(a.config)})}async applyFadeOut(n,t){const a=this.audioLayers.get(n);if(!a)throw new Error(`Audio track with id ${n} not found`);a.config.fadeOut=t,a.clip.set({volume:this.createVolumeKeyframes(a.config)})}async removeAudioTrack(n){const t=this.audioLayers.get(n);if(!t)throw new Error(`Audio track with id ${n} not found`);const a=t.track.clips.indexOf(t.clip);a!==-1&&t.track.clips.splice(a,1),this.audioLayers.delete(n)}async muteTrack(n,t){const a=this.audioLayers.get(n);if(!a)throw new Error(`Audio track with id ${n} not found`);t?a.clip.volume=0:a.clip.volume=(a.config.volume??1)*this.masterVolume}setMasterVolume(n){this.masterVolume=Math.max(0,Math.min(1,n));for(const t of this.audioLayers.values())t.clip.volume=(t.config.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 a of this.audioLayers.values()){const i=a.config.startTime||0,r=a.config.duration||t-n;if(i+r>t){a.config.duration=t-i;const s=new jo({source:a.clip.source,start:_e.fromSeconds(i),stop:_e.fromSeconds(t),volume:a.clip.volume}),l=a.track.clips.indexOf(a.clip);l!==-1&&(a.track.clips[l]=s,a.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:a}of n)await this.addAudioTrack({...a,name:t})}}function md(o,n){return function(){return o.apply(n,arguments)}}const{toString:Gb}=Object.prototype,{getPrototypeOf:fs}=Object,{iterator:ui,toStringTag:pd}=Symbol,mi=(o=>n=>{const t=Gb.call(n);return o[t]||(o[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Ht=o=>(o=o.toLowerCase(),n=>mi(n)===o),pi=o=>n=>typeof n===o,{isArray:da}=Array,Ua=pi("undefined");function Ja(o){return o!==null&&!Ua(o)&&o.constructor!==null&&!Ua(o.constructor)&&Ft(o.constructor.isBuffer)&&o.constructor.isBuffer(o)}const fd=Ht("ArrayBuffer");function Jb(o){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(o):n=o&&o.buffer&&fd(o.buffer),n}const Yb=pi("string"),Ft=pi("function"),hd=pi("number"),Ya=o=>o!==null&&typeof o=="object",qb=o=>o===!0||o===!1,Bo=o=>{if(mi(o)!=="object")return!1;const n=fs(o);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(pd in o)&&!(ui in o)},Kb=o=>{if(!Ya(o)||Ja(o))return!1;try{return Object.keys(o).length===0&&Object.getPrototypeOf(o)===Object.prototype}catch{return!1}},Qb=Ht("Date"),ew=Ht("File"),tw=Ht("Blob"),nw=Ht("FileList"),aw=o=>Ya(o)&&Ft(o.pipe),ow=o=>{let n;return o&&(typeof FormData=="function"&&o instanceof FormData||Ft(o.append)&&((n=mi(o))==="formdata"||n==="object"&&Ft(o.toString)&&o.toString()==="[object FormData]"))},iw=Ht("URLSearchParams"),[rw,sw,lw,cw]=["ReadableStream","Request","Response","Headers"].map(Ht),dw=o=>o.trim?o.trim():o.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function qa(o,n,{allOwnKeys:t=!1}={}){if(o===null||typeof o>"u")return;let a,i;if(typeof o!="object"&&(o=[o]),da(o))for(a=0,i=o.length;a<i;a++)n.call(null,o[a],a,o);else{if(Ja(o))return;const r=t?Object.getOwnPropertyNames(o):Object.keys(o),s=r.length;let l;for(a=0;a<s;a++)l=r[a],n.call(null,o[l],l,o)}}function vd(o,n){if(Ja(o))return null;n=n.toLowerCase();const t=Object.keys(o);let a=t.length,i;for(;a-- >0;)if(i=t[a],n===i.toLowerCase())return i;return null}const Fn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,gd=o=>!Ua(o)&&o!==Fn;function Ur(){const{caseless:o}=gd(this)&&this||{},n={},t=(a,i)=>{const r=o&&vd(n,i)||i;Bo(n[r])&&Bo(a)?n[r]=Ur(n[r],a):Bo(a)?n[r]=Ur({},a):da(a)?n[r]=a.slice():n[r]=a};for(let a=0,i=arguments.length;a<i;a++)arguments[a]&&qa(arguments[a],t);return n}const uw=(o,n,t,{allOwnKeys:a}={})=>(qa(n,(i,r)=>{t&&Ft(i)?o[r]=md(i,t):o[r]=i},{allOwnKeys:a}),o),mw=o=>(o.charCodeAt(0)===65279&&(o=o.slice(1)),o),pw=(o,n,t,a)=>{o.prototype=Object.create(n.prototype,a),o.prototype.constructor=o,Object.defineProperty(o,"super",{value:n.prototype}),t&&Object.assign(o.prototype,t)},fw=(o,n,t,a)=>{let i,r,s;const l={};if(n=n||{},o==null)return n;do{for(i=Object.getOwnPropertyNames(o),r=i.length;r-- >0;)s=i[r],(!a||a(s,o,n))&&!l[s]&&(n[s]=o[s],l[s]=!0);o=t!==!1&&fs(o)}while(o&&(!t||t(o,n))&&o!==Object.prototype);return n},hw=(o,n,t)=>{o=String(o),(t===void 0||t>o.length)&&(t=o.length),t-=n.length;const a=o.indexOf(n,t);return a!==-1&&a===t},vw=o=>{if(!o)return null;if(da(o))return o;let n=o.length;if(!hd(n))return null;const t=new Array(n);for(;n-- >0;)t[n]=o[n];return t},gw=(o=>n=>o&&n instanceof o)(typeof Uint8Array<"u"&&fs(Uint8Array)),yw=(o,n)=>{const a=(o&&o[ui]).call(o);let i;for(;(i=a.next())&&!i.done;){const r=i.value;n.call(o,r[0],r[1])}},bw=(o,n)=>{let t;const a=[];for(;(t=o.exec(n))!==null;)a.push(t);return a},ww=Ht("HTMLFormElement"),kw=o=>o.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,a,i){return a.toUpperCase()+i}),Dl=(({hasOwnProperty:o})=>(n,t)=>o.call(n,t))(Object.prototype),_w=Ht("RegExp"),yd=(o,n)=>{const t=Object.getOwnPropertyDescriptors(o),a={};qa(t,(i,r)=>{let s;(s=n(i,r,o))!==!1&&(a[r]=s||i)}),Object.defineProperties(o,a)},Ew=o=>{yd(o,(n,t)=>{if(Ft(o)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const a=o[t];if(Ft(a)){if(n.enumerable=!1,"writable"in n){n.writable=!1;return}n.set||(n.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},xw=(o,n)=>{const t={},a=i=>{i.forEach(r=>{t[r]=!0})};return da(o)?a(o):a(String(o).split(n)),t},Cw=()=>{},Sw=(o,n)=>o!=null&&Number.isFinite(o=+o)?o:n;function Vw(o){return!!(o&&Ft(o.append)&&o[pd]==="FormData"&&o[ui])}const Nw=o=>{const n=new Array(10),t=(a,i)=>{if(Ya(a)){if(n.indexOf(a)>=0)return;if(Ja(a))return a;if(!("toJSON"in a)){n[i]=a;const r=da(a)?[]:{};return qa(a,(s,l)=>{const c=t(s,i+1);!Ua(c)&&(r[l]=c)}),n[i]=void 0,r}}return a};return t(o,0)},Tw=Ht("AsyncFunction"),Mw=o=>o&&(Ya(o)||Ft(o))&&Ft(o.then)&&Ft(o.catch),bd=((o,n)=>o?setImmediate:n?((t,a)=>(Fn.addEventListener("message",({source:i,data:r})=>{i===Fn&&r===t&&a.length&&a.shift()()},!1),i=>{a.push(i),Fn.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",Ft(Fn.postMessage)),Bw=typeof queueMicrotask<"u"?queueMicrotask.bind(Fn):typeof process<"u"&&process.nextTick||bd,Fw=o=>o!=null&&Ft(o[ui]),K={isArray:da,isArrayBuffer:fd,isBuffer:Ja,isFormData:ow,isArrayBufferView:Jb,isString:Yb,isNumber:hd,isBoolean:qb,isObject:Ya,isPlainObject:Bo,isEmptyObject:Kb,isReadableStream:rw,isRequest:sw,isResponse:lw,isHeaders:cw,isUndefined:Ua,isDate:Qb,isFile:ew,isBlob:tw,isRegExp:_w,isFunction:Ft,isStream:aw,isURLSearchParams:iw,isTypedArray:gw,isFileList:nw,forEach:qa,merge:Ur,extend:uw,trim:dw,stripBOM:mw,inherits:pw,toFlatObject:fw,kindOf:mi,kindOfTest:Ht,endsWith:hw,toArray:vw,forEachEntry:yw,matchAll:bw,isHTMLForm:ww,hasOwnProperty:Dl,hasOwnProp:Dl,reduceDescriptors:yd,freezeMethods:Ew,toObjectSet:xw,toCamelCase:kw,noop:Cw,toFiniteNumber:Sw,findKey:vd,global:Fn,isContextDefined:gd,isSpecCompliantForm:Vw,toJSONObject:Nw,isAsyncFn:Tw,isThenable:Mw,setImmediate:bd,asap:Bw,isIterable:Fw};function Pe(o,n,t,a,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=o,this.name="AxiosError",n&&(this.code=n),t&&(this.config=t),a&&(this.request=a),i&&(this.response=i,this.status=i.status?i.status:null)}K.inherits(Pe,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:K.toJSONObject(this.config),code:this.code,status:this.status}}});const wd=Pe.prototype,kd={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(o=>{kd[o]={value:o}});Object.defineProperties(Pe,kd);Object.defineProperty(wd,"isAxiosError",{value:!0});Pe.from=(o,n,t,a,i,r)=>{const s=Object.create(wd);return K.toFlatObject(o,s,function(c){return c!==Error.prototype},l=>l!=="isAxiosError"),Pe.call(s,o.message,n,t,a,i),s.cause=o,s.name=o.name,r&&Object.assign(s,r),s};const Iw=null;function Or(o){return K.isPlainObject(o)||K.isArray(o)}function _d(o){return K.endsWith(o,"[]")?o.slice(0,-2):o}function Al(o,n,t){return o?o.concat(n).map(function(i,r){return i=_d(i),!t&&r?"["+i+"]":i}).join(t?".":""):n}function $w(o){return K.isArray(o)&&!o.some(Or)}const Rw=K.toFlatObject(K,{},null,function(n){return/^is[A-Z]/.test(n)});function fi(o,n,t){if(!K.isObject(o))throw new TypeError("target must be an object");n=n||new FormData,t=K.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,k){return!K.isUndefined(k[g])});const a=t.metaTokens,i=t.visitor||u,r=t.dots,s=t.indexes,c=(t.Blob||typeof Blob<"u"&&Blob)&&K.isSpecCompliantForm(n);if(!K.isFunction(i))throw new TypeError("visitor must be a function");function d(v){if(v===null)return"";if(K.isDate(v))return v.toISOString();if(K.isBoolean(v))return v.toString();if(!c&&K.isBlob(v))throw new Pe("Blob is not supported. Use a Buffer instead.");return K.isArrayBuffer(v)||K.isTypedArray(v)?c&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function u(v,g,k){let T=v;if(v&&!k&&typeof v=="object"){if(K.endsWith(g,"{}"))g=a?g:g.slice(0,-2),v=JSON.stringify(v);else if(K.isArray(v)&&$w(v)||(K.isFileList(v)||K.endsWith(g,"[]"))&&(T=K.toArray(v)))return g=_d(g),T.forEach(function(b,h){!(K.isUndefined(b)||b===null)&&n.append(s===!0?Al([g],h,r):s===null?g:g+"[]",d(b))}),!1}return Or(v)?!0:(n.append(Al(k,g,r),d(v)),!1)}const m=[],f=Object.assign(Rw,{defaultVisitor:u,convertValue:d,isVisitable:Or});function p(v,g){if(!K.isUndefined(v)){if(m.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));m.push(v),K.forEach(v,function(T,V){(!(K.isUndefined(T)||T===null)&&i.call(n,T,K.isString(V)?V.trim():V,g,f))===!0&&p(T,g?g.concat(V):[V])}),m.pop()}}if(!K.isObject(o))throw new TypeError("data must be an object");return p(o),n}function Ll(o){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(o).replace(/[!'()~]|%20|%00/g,function(a){return n[a]})}function hs(o,n){this._pairs=[],o&&fi(o,this,n)}const Ed=hs.prototype;Ed.append=function(n,t){this._pairs.push([n,t])};Ed.toString=function(n){const t=n?function(a){return n.call(this,a,Ll)}:Ll;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function Dw(o){return encodeURIComponent(o).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function xd(o,n,t){if(!n)return o;const a=t&&t.encode||Dw;K.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let r;if(i?r=i(n,t):r=K.isURLSearchParams(n)?n.toString():new hs(n,t).toString(a),r){const s=o.indexOf("#");s!==-1&&(o=o.slice(0,s)),o+=(o.indexOf("?")===-1?"?":"&")+r}return o}class Ul{constructor(){this.handlers=[]}use(n,t,a){return this.handlers.push({fulfilled:n,rejected:t,synchronous:a?a.synchronous:!1,runWhen:a?a.runWhen:null}),this.handlers.length-1}eject(n){this.handlers[n]&&(this.handlers[n]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(n){K.forEach(this.handlers,function(a){a!==null&&n(a)})}}const Cd={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Aw=typeof URLSearchParams<"u"?URLSearchParams:hs,Lw=typeof FormData<"u"?FormData:null,Uw=typeof Blob<"u"?Blob:null,Ow={isBrowser:!0,classes:{URLSearchParams:Aw,FormData:Lw,Blob:Uw},protocols:["http","https","file","blob","url","data"]},vs=typeof window<"u"&&typeof document<"u",Pr=typeof navigator=="object"&&navigator||void 0,Pw=vs&&(!Pr||["ReactNative","NativeScript","NS"].indexOf(Pr.product)<0),zw=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",jw=vs&&window.location.href||"http://localhost",Ww=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:vs,hasStandardBrowserEnv:Pw,hasStandardBrowserWebWorkerEnv:zw,navigator:Pr,origin:jw},Symbol.toStringTag,{value:"Module"})),_t={...Ww,...Ow};function Zw(o,n){return fi(o,new _t.classes.URLSearchParams,{visitor:function(t,a,i,r){return _t.isNode&&K.isBuffer(t)?(this.append(a,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...n})}function Hw(o){return K.matchAll(/\w+|\[(\w*)]/g,o).map(n=>n[0]==="[]"?"":n[1]||n[0])}function Xw(o){const n={},t=Object.keys(o);let a;const i=t.length;let r;for(a=0;a<i;a++)r=t[a],n[r]=o[r];return n}function Sd(o){function n(t,a,i,r){let s=t[r++];if(s==="__proto__")return!0;const l=Number.isFinite(+s),c=r>=t.length;return s=!s&&K.isArray(i)?i.length:s,c?(K.hasOwnProp(i,s)?i[s]=[i[s],a]:i[s]=a,!l):((!i[s]||!K.isObject(i[s]))&&(i[s]=[]),n(t,a,i[s],r)&&K.isArray(i[s])&&(i[s]=Xw(i[s])),!l)}if(K.isFormData(o)&&K.isFunction(o.entries)){const t={};return K.forEachEntry(o,(a,i)=>{n(Hw(a),i,t,0)}),t}return null}function Gw(o,n,t){if(K.isString(o))try{return(n||JSON.parse)(o),K.trim(o)}catch(a){if(a.name!=="SyntaxError")throw a}return(t||JSON.stringify)(o)}const Ka={transitional:Cd,adapter:["xhr","http","fetch"],transformRequest:[function(n,t){const a=t.getContentType()||"",i=a.indexOf("application/json")>-1,r=K.isObject(n);if(r&&K.isHTMLForm(n)&&(n=new FormData(n)),K.isFormData(n))return i?JSON.stringify(Sd(n)):n;if(K.isArrayBuffer(n)||K.isBuffer(n)||K.isStream(n)||K.isFile(n)||K.isBlob(n)||K.isReadableStream(n))return n;if(K.isArrayBufferView(n))return n.buffer;if(K.isURLSearchParams(n))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let l;if(r){if(a.indexOf("application/x-www-form-urlencoded")>-1)return Zw(n,this.formSerializer).toString();if((l=K.isFileList(n))||a.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return fi(l?{"files[]":n}:n,c&&new c,this.formSerializer)}}return r||i?(t.setContentType("application/json",!1),Gw(n)):n}],transformResponse:[function(n){const t=this.transitional||Ka.transitional,a=t&&t.forcedJSONParsing,i=this.responseType==="json";if(K.isResponse(n)||K.isReadableStream(n))return n;if(n&&K.isString(n)&&(a&&!this.responseType||i)){const s=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(n)}catch(l){if(s)throw l.name==="SyntaxError"?Pe.from(l,Pe.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:_t.classes.FormData,Blob:_t.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};K.forEach(["delete","get","head","post","put","patch"],o=>{Ka.headers[o]={}});const Jw=K.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"]),Yw=o=>{const n={};let t,a,i;return o&&o.split(`
337
- `).forEach(function(s){i=s.indexOf(":"),t=s.substring(0,i).trim().toLowerCase(),a=s.substring(i+1).trim(),!(!t||n[t]&&Jw[t])&&(t==="set-cookie"?n[t]?n[t].push(a):n[t]=[a]:n[t]=n[t]?n[t]+", "+a:a)}),n},Ol=Symbol("internals");function ka(o){return o&&String(o).trim().toLowerCase()}function Fo(o){return o===!1||o==null?o:K.isArray(o)?o.map(Fo):String(o)}function qw(o){const n=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let a;for(;a=t.exec(o);)n[a[1]]=a[2];return n}const Kw=o=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(o.trim());function ir(o,n,t,a,i){if(K.isFunction(a))return a.call(this,n,t);if(i&&(n=t),!!K.isString(n)){if(K.isString(a))return n.indexOf(a)!==-1;if(K.isRegExp(a))return a.test(n)}}function Qw(o){return o.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(n,t,a)=>t.toUpperCase()+a)}function e2(o,n){const t=K.toCamelCase(" "+n);["get","set","has"].forEach(a=>{Object.defineProperty(o,a+t,{value:function(i,r,s){return this[a].call(this,n,i,r,s)},configurable:!0})})}let It=class{constructor(n){n&&this.set(n)}set(n,t,a){const i=this;function r(l,c,d){const u=ka(c);if(!u)throw new Error("header name must be a non-empty string");const m=K.findKey(i,u);(!m||i[m]===void 0||d===!0||d===void 0&&i[m]!==!1)&&(i[m||c]=Fo(l))}const s=(l,c)=>K.forEach(l,(d,u)=>r(d,u,c));if(K.isPlainObject(n)||n instanceof this.constructor)s(n,t);else if(K.isString(n)&&(n=n.trim())&&!Kw(n))s(Yw(n),t);else if(K.isObject(n)&&K.isIterable(n)){let l={},c,d;for(const u of n){if(!K.isArray(u))throw TypeError("Object iterator must return a key-value pair");l[d=u[0]]=(c=l[d])?K.isArray(c)?[...c,u[1]]:[c,u[1]]:u[1]}s(l,t)}else n!=null&&r(t,n,a);return this}get(n,t){if(n=ka(n),n){const a=K.findKey(this,n);if(a){const i=this[a];if(!t)return i;if(t===!0)return qw(i);if(K.isFunction(t))return t.call(this,i,a);if(K.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(n,t){if(n=ka(n),n){const a=K.findKey(this,n);return!!(a&&this[a]!==void 0&&(!t||ir(this,this[a],a,t)))}return!1}delete(n,t){const a=this;let i=!1;function r(s){if(s=ka(s),s){const l=K.findKey(a,s);l&&(!t||ir(a,a[l],l,t))&&(delete a[l],i=!0)}}return K.isArray(n)?n.forEach(r):r(n),i}clear(n){const t=Object.keys(this);let a=t.length,i=!1;for(;a--;){const r=t[a];(!n||ir(this,this[r],r,n,!0))&&(delete this[r],i=!0)}return i}normalize(n){const t=this,a={};return K.forEach(this,(i,r)=>{const s=K.findKey(a,r);if(s){t[s]=Fo(i),delete t[r];return}const l=n?Qw(r):String(r).trim();l!==r&&delete t[r],t[l]=Fo(i),a[l]=!0}),this}concat(...n){return this.constructor.concat(this,...n)}toJSON(n){const t=Object.create(null);return K.forEach(this,(a,i)=>{a!=null&&a!==!1&&(t[i]=n&&K.isArray(a)?a.join(", "):a)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([n,t])=>n+": "+t).join(`
338
- `)}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 a=new this(n);return t.forEach(i=>a.set(i)),a}static accessor(n){const a=(this[Ol]=this[Ol]={accessors:{}}).accessors,i=this.prototype;function r(s){const l=ka(s);a[l]||(e2(i,s),a[l]=!0)}return K.isArray(n)?n.forEach(r):r(n),this}};It.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);K.reduceDescriptors(It.prototype,({value:o},n)=>{let t=n[0].toUpperCase()+n.slice(1);return{get:()=>o,set(a){this[t]=a}}});K.freezeMethods(It);function rr(o,n){const t=this||Ka,a=n||t,i=It.from(a.headers);let r=a.data;return K.forEach(o,function(l){r=l.call(t,r,i.normalize(),n?n.status:void 0)}),i.normalize(),r}function Vd(o){return!!(o&&o.__CANCEL__)}function ua(o,n,t){Pe.call(this,o??"canceled",Pe.ERR_CANCELED,n,t),this.name="CanceledError"}K.inherits(ua,Pe,{__CANCEL__:!0});function Nd(o,n,t){const a=t.config.validateStatus;!t.status||!a||a(t.status)?o(t):n(new Pe("Request failed with status code "+t.status,[Pe.ERR_BAD_REQUEST,Pe.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function t2(o){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(o);return n&&n[1]||""}function n2(o,n){o=o||10;const t=new Array(o),a=new Array(o);let i=0,r=0,s;return n=n!==void 0?n:1e3,function(c){const d=Date.now(),u=a[r];s||(s=d),t[i]=c,a[i]=d;let m=r,f=0;for(;m!==i;)f+=t[m++],m=m%o;if(i=(i+1)%o,i===r&&(r=(r+1)%o),d-s<n)return;const p=u&&d-u;return p?Math.round(f*1e3/p):void 0}}function a2(o,n){let t=0,a=1e3/n,i,r;const s=(d,u=Date.now())=>{t=u,i=null,r&&(clearTimeout(r),r=null),o(...d)};return[(...d)=>{const u=Date.now(),m=u-t;m>=a?s(d,u):(i=d,r||(r=setTimeout(()=>{r=null,s(i)},a-m)))},()=>i&&s(i)]}const Wo=(o,n,t=3)=>{let a=0;const i=n2(50,250);return a2(r=>{const s=r.loaded,l=r.lengthComputable?r.total:void 0,c=s-a,d=i(c),u=s<=l;a=s;const m={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};o(m)},t)},Pl=(o,n)=>{const t=o!=null;return[a=>n[0]({lengthComputable:t,total:o,loaded:a}),n[1]]},zl=o=>(...n)=>K.asap(()=>o(...n)),o2=_t.hasStandardBrowserEnv?((o,n)=>t=>(t=new URL(t,_t.origin),o.protocol===t.protocol&&o.host===t.host&&(n||o.port===t.port)))(new URL(_t.origin),_t.navigator&&/(msie|trident)/i.test(_t.navigator.userAgent)):()=>!0,i2=_t.hasStandardBrowserEnv?{write(o,n,t,a,i,r){const s=[o+"="+encodeURIComponent(n)];K.isNumber(t)&&s.push("expires="+new Date(t).toGMTString()),K.isString(a)&&s.push("path="+a),K.isString(i)&&s.push("domain="+i),r===!0&&s.push("secure"),document.cookie=s.join("; ")},read(o){const n=document.cookie.match(new RegExp("(^|;\\s*)("+o+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove(o){this.write(o,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function r2(o){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(o)}function s2(o,n){return n?o.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):o}function Td(o,n,t){let a=!r2(n);return o&&(a||t==!1)?s2(o,n):n}const jl=o=>o instanceof It?{...o}:o;function An(o,n){n=n||{};const t={};function a(d,u,m,f){return K.isPlainObject(d)&&K.isPlainObject(u)?K.merge.call({caseless:f},d,u):K.isPlainObject(u)?K.merge({},u):K.isArray(u)?u.slice():u}function i(d,u,m,f){if(K.isUndefined(u)){if(!K.isUndefined(d))return a(void 0,d,m,f)}else return a(d,u,m,f)}function r(d,u){if(!K.isUndefined(u))return a(void 0,u)}function s(d,u){if(K.isUndefined(u)){if(!K.isUndefined(d))return a(void 0,d)}else return a(void 0,u)}function l(d,u,m){if(m in n)return a(d,u);if(m in o)return a(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,m)=>i(jl(d),jl(u),m,!0)};return K.forEach(Object.keys({...o,...n}),function(u){const m=c[u]||i,f=m(o[u],n[u],u);K.isUndefined(f)&&m!==l||(t[u]=f)}),t}const Md=o=>{const n=An({},o);let{data:t,withXSRFToken:a,xsrfHeaderName:i,xsrfCookieName:r,headers:s,auth:l}=n;n.headers=s=It.from(s),n.url=xd(Td(n.baseURL,n.url,n.allowAbsoluteUrls),o.params,o.paramsSerializer),l&&s.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let c;if(K.isFormData(t)){if(_t.hasStandardBrowserEnv||_t.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((c=s.getContentType())!==!1){const[d,...u]=c?c.split(";").map(m=>m.trim()).filter(Boolean):[];s.setContentType([d||"multipart/form-data",...u].join("; "))}}if(_t.hasStandardBrowserEnv&&(a&&K.isFunction(a)&&(a=a(n)),a||a!==!1&&o2(n.url))){const d=i&&r&&i2.read(r);d&&s.set(i,d)}return n},l2=typeof XMLHttpRequest<"u",c2=l2&&function(o){return new Promise(function(t,a){const i=Md(o);let r=i.data;const s=It.from(i.headers).normalize();let{responseType:l,onUploadProgress:c,onDownloadProgress:d}=i,u,m,f,p,v;function g(){p&&p(),v&&v(),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 T(){if(!k)return;const b=It.from("getAllResponseHeaders"in k&&k.getAllResponseHeaders()),_={data:!l||l==="text"||l==="json"?k.responseText:k.response,status:k.status,statusText:k.statusText,headers:b,config:o,request:k};Nd(function(M){t(M),g()},function(M){a(M),g()},_),k=null}"onloadend"in k?k.onloadend=T:k.onreadystatechange=function(){!k||k.readyState!==4||k.status===0&&!(k.responseURL&&k.responseURL.indexOf("file:")===0)||setTimeout(T)},k.onabort=function(){k&&(a(new Pe("Request aborted",Pe.ECONNABORTED,o,k)),k=null)},k.onerror=function(){a(new Pe("Network Error",Pe.ERR_NETWORK,o,k)),k=null},k.ontimeout=function(){let h=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const _=i.transitional||Cd;i.timeoutErrorMessage&&(h=i.timeoutErrorMessage),a(new Pe(h,_.clarifyTimeoutError?Pe.ETIMEDOUT:Pe.ECONNABORTED,o,k)),k=null},r===void 0&&s.setContentType(null),"setRequestHeader"in k&&K.forEach(s.toJSON(),function(h,_){k.setRequestHeader(_,h)}),K.isUndefined(i.withCredentials)||(k.withCredentials=!!i.withCredentials),l&&l!=="json"&&(k.responseType=i.responseType),d&&([f,v]=Wo(d,!0),k.addEventListener("progress",f)),c&&k.upload&&([m,p]=Wo(c),k.upload.addEventListener("progress",m),k.upload.addEventListener("loadend",p)),(i.cancelToken||i.signal)&&(u=b=>{k&&(a(!b||b.type?new ua(null,o,k):b),k.abort(),k=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));const V=t2(i.url);if(V&&_t.protocols.indexOf(V)===-1){a(new Pe("Unsupported protocol "+V+":",Pe.ERR_BAD_REQUEST,o));return}k.send(r||null)})},d2=(o,n)=>{const{length:t}=o=o?o.filter(Boolean):[];if(n||t){let a=new AbortController,i;const r=function(d){if(!i){i=!0,l();const u=d instanceof Error?d:this.reason;a.abort(u instanceof Pe?u:new ua(u instanceof Error?u.message:u))}};let s=n&&setTimeout(()=>{s=null,r(new Pe(`timeout ${n} of ms exceeded`,Pe.ETIMEDOUT))},n);const l=()=>{o&&(s&&clearTimeout(s),s=null,o.forEach(d=>{d.unsubscribe?d.unsubscribe(r):d.removeEventListener("abort",r)}),o=null)};o.forEach(d=>d.addEventListener("abort",r));const{signal:c}=a;return c.unsubscribe=()=>K.asap(l),c}},u2=function*(o,n){let t=o.byteLength;if(t<n){yield o;return}let a=0,i;for(;a<t;)i=a+n,yield o.slice(a,i),a=i},m2=async function*(o,n){for await(const t of p2(o))yield*u2(t,n)},p2=async function*(o){if(o[Symbol.asyncIterator]){yield*o;return}const n=o.getReader();try{for(;;){const{done:t,value:a}=await n.read();if(t)break;yield a}}finally{await n.cancel()}},Wl=(o,n,t,a)=>{const i=m2(o,n);let r=0,s,l=c=>{s||(s=!0,a&&a(c))};return new ReadableStream({async pull(c){try{const{done:d,value:u}=await i.next();if(d){l(),c.close();return}let m=u.byteLength;if(t){let f=r+=m;t(f)}c.enqueue(new Uint8Array(u))}catch(d){throw l(d),d}},cancel(c){return l(c),i.return()}},{highWaterMark:2})},hi=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Bd=hi&&typeof ReadableStream=="function",f2=hi&&(typeof TextEncoder=="function"?(o=>n=>o.encode(n))(new TextEncoder):async o=>new Uint8Array(await new Response(o).arrayBuffer())),Fd=(o,...n)=>{try{return!!o(...n)}catch{return!1}},h2=Bd&&Fd(()=>{let o=!1;const n=new Request(_t.origin,{body:new ReadableStream,method:"POST",get duplex(){return o=!0,"half"}}).headers.has("Content-Type");return o&&!n}),Zl=64*1024,zr=Bd&&Fd(()=>K.isReadableStream(new Response("").body)),Zo={stream:zr&&(o=>o.body)};hi&&(o=>{["text","arrayBuffer","blob","formData","stream"].forEach(n=>{!Zo[n]&&(Zo[n]=K.isFunction(o[n])?t=>t[n]():(t,a)=>{throw new Pe(`Response type '${n}' is not supported`,Pe.ERR_NOT_SUPPORT,a)})})})(new Response);const v2=async o=>{if(o==null)return 0;if(K.isBlob(o))return o.size;if(K.isSpecCompliantForm(o))return(await new Request(_t.origin,{method:"POST",body:o}).arrayBuffer()).byteLength;if(K.isArrayBufferView(o)||K.isArrayBuffer(o))return o.byteLength;if(K.isURLSearchParams(o)&&(o=o+""),K.isString(o))return(await f2(o)).byteLength},g2=async(o,n)=>{const t=K.toFiniteNumber(o.getContentLength());return t??v2(n)},y2=hi&&(async o=>{let{url:n,method:t,data:a,signal:i,cancelToken:r,timeout:s,onDownloadProgress:l,onUploadProgress:c,responseType:d,headers:u,withCredentials:m="same-origin",fetchOptions:f}=Md(o);d=d?(d+"").toLowerCase():"text";let p=d2([i,r&&r.toAbortSignal()],s),v;const g=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let k;try{if(c&&h2&&t!=="get"&&t!=="head"&&(k=await g2(u,a))!==0){let _=new Request(n,{method:"POST",body:a,duplex:"half"}),R;if(K.isFormData(a)&&(R=_.headers.get("content-type"))&&u.setContentType(R),_.body){const[M,x]=Pl(k,Wo(zl(c)));a=Wl(_.body,Zl,M,x)}}K.isString(m)||(m=m?"include":"omit");const T="credentials"in Request.prototype;v=new Request(n,{...f,signal:p,method:t.toUpperCase(),headers:u.normalize().toJSON(),body:a,duplex:"half",credentials:T?m:void 0});let V=await fetch(v,f);const b=zr&&(d==="stream"||d==="response");if(zr&&(l||b&&g)){const _={};["status","statusText","headers"].forEach(C=>{_[C]=V[C]});const R=K.toFiniteNumber(V.headers.get("content-length")),[M,x]=l&&Pl(R,Wo(zl(l),!0))||[];V=new Response(Wl(V.body,Zl,M,()=>{x&&x(),g&&g()}),_)}d=d||"text";let h=await Zo[K.findKey(Zo,d)||"text"](V,o);return!b&&g&&g(),await new Promise((_,R)=>{Nd(_,R,{data:h,headers:It.from(V.headers),status:V.status,statusText:V.statusText,config:o,request:v})})}catch(T){throw g&&g(),T&&T.name==="TypeError"&&/Load failed|fetch/i.test(T.message)?Object.assign(new Pe("Network Error",Pe.ERR_NETWORK,o,v),{cause:T.cause||T}):Pe.from(T,T&&T.code,o,v)}}),jr={http:Iw,xhr:c2,fetch:y2};K.forEach(jr,(o,n)=>{if(o){try{Object.defineProperty(o,"name",{value:n})}catch{}Object.defineProperty(o,"adapterName",{value:n})}});const Hl=o=>`- ${o}`,b2=o=>K.isFunction(o)||o===null||o===!1,Id={getAdapter:o=>{o=K.isArray(o)?o:[o];const{length:n}=o;let t,a;const i={};for(let r=0;r<n;r++){t=o[r];let s;if(a=t,!b2(t)&&(a=jr[(s=String(t)).toLowerCase()],a===void 0))throw new Pe(`Unknown adapter '${s}'`);if(a)break;i[s||"#"+r]=a}if(!a){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 :
339
- `+r.map(Hl).join(`
340
- `):" "+Hl(r[0]):"as no adapter specified";throw new Pe("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return a},adapters:jr};function sr(o){if(o.cancelToken&&o.cancelToken.throwIfRequested(),o.signal&&o.signal.aborted)throw new ua(null,o)}function Xl(o){return sr(o),o.headers=It.from(o.headers),o.data=rr.call(o,o.transformRequest),["post","put","patch"].indexOf(o.method)!==-1&&o.headers.setContentType("application/x-www-form-urlencoded",!1),Id.getAdapter(o.adapter||Ka.adapter)(o).then(function(a){return sr(o),a.data=rr.call(o,o.transformResponse,a),a.headers=It.from(a.headers),a},function(a){return Vd(a)||(sr(o),a&&a.response&&(a.response.data=rr.call(o,o.transformResponse,a.response),a.response.headers=It.from(a.response.headers))),Promise.reject(a)})}const $d="1.11.0",vi={};["object","boolean","number","function","string","symbol"].forEach((o,n)=>{vi[o]=function(a){return typeof a===o||"a"+(n<1?"n ":" ")+o}});const Gl={};vi.transitional=function(n,t,a){function i(r,s){return"[Axios v"+$d+"] Transitional option '"+r+"'"+s+(a?". "+a:"")}return(r,s,l)=>{if(n===!1)throw new Pe(i(s," has been removed"+(t?" in "+t:"")),Pe.ERR_DEPRECATED);return t&&!Gl[s]&&(Gl[s]=!0),n?n(r,s,l):!0}};vi.spelling=function(n){return(t,a)=>!0};function w2(o,n,t){if(typeof o!="object")throw new Pe("options must be an object",Pe.ERR_BAD_OPTION_VALUE);const a=Object.keys(o);let i=a.length;for(;i-- >0;){const r=a[i],s=n[r];if(s){const l=o[r],c=l===void 0||s(l,r,o);if(c!==!0)throw new Pe("option "+r+" must be "+c,Pe.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new Pe("Unknown option "+r,Pe.ERR_BAD_OPTION)}}const Io={assertOptions:w2,validators:vi},Kt=Io.validators;let $n=class{constructor(n){this.defaults=n||{},this.interceptors={request:new Ul,response:new Ul}}async request(n,t){try{return await this._request(n,t)}catch(a){if(a instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const r=i.stack?i.stack.replace(/^.+\n/,""):"";try{a.stack?r&&!String(a.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(a.stack+=`
341
- `+r):a.stack=r}catch{}}throw a}}_request(n,t){typeof n=="string"?(t=t||{},t.url=n):t=n||{},t=An(this.defaults,t);const{transitional:a,paramsSerializer:i,headers:r}=t;a!==void 0&&Io.assertOptions(a,{silentJSONParsing:Kt.transitional(Kt.boolean),forcedJSONParsing:Kt.transitional(Kt.boolean),clarifyTimeoutError:Kt.transitional(Kt.boolean)},!1),i!=null&&(K.isFunction(i)?t.paramsSerializer={serialize:i}:Io.assertOptions(i,{encode:Kt.function,serialize:Kt.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Io.assertOptions(t,{baseUrl:Kt.spelling("baseURL"),withXsrfToken:Kt.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=r&&K.merge(r.common,r[t.method]);r&&K.forEach(["delete","get","head","post","put","patch","common"],v=>{delete r[v]}),t.headers=It.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,m=0,f;if(!c){const v=[Xl.bind(this),void 0];for(v.unshift(...l),v.push(...d),f=v.length,u=Promise.resolve(t);m<f;)u=u.then(v[m++],v[m++]);return u}f=l.length;let p=t;for(m=0;m<f;){const v=l[m++],g=l[m++];try{p=v(p)}catch(k){g.call(this,k);break}}try{u=Xl.call(this,p)}catch(v){return Promise.reject(v)}for(m=0,f=d.length;m<f;)u=u.then(d[m++],d[m++]);return u}getUri(n){n=An(this.defaults,n);const t=Td(n.baseURL,n.url,n.allowAbsoluteUrls);return xd(t,n.params,n.paramsSerializer)}};K.forEach(["delete","get","head","options"],function(n){$n.prototype[n]=function(t,a){return this.request(An(a||{},{method:n,url:t,data:(a||{}).data}))}});K.forEach(["post","put","patch"],function(n){function t(a){return function(r,s,l){return this.request(An(l||{},{method:n,headers:a?{"Content-Type":"multipart/form-data"}:{},url:r,data:s}))}}$n.prototype[n]=t(),$n.prototype[n+"Form"]=t(!0)});let k2=class Rd{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 a=this;this.promise.then(i=>{if(!a._listeners)return;let r=a._listeners.length;for(;r-- >0;)a._listeners[r](i);a._listeners=null}),this.promise.then=i=>{let r;const s=new Promise(l=>{a.subscribe(l),r=l}).then(i);return s.cancel=function(){a.unsubscribe(r)},s},n(function(r,s,l){a.reason||(a.reason=new ua(r,s,l),t(a.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=a=>{n.abort(a)};return this.subscribe(t),n.signal.unsubscribe=()=>this.unsubscribe(t),n.signal}static source(){let n;return{token:new Rd(function(i){n=i}),cancel:n}}};function _2(o){return function(t){return o.apply(null,t)}}function E2(o){return K.isObject(o)&&o.isAxiosError===!0}const Wr={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(Wr).forEach(([o,n])=>{Wr[n]=o});function Dd(o){const n=new $n(o),t=md($n.prototype.request,n);return K.extend(t,$n.prototype,n,{allOwnKeys:!0}),K.extend(t,n,null,{allOwnKeys:!0}),t.create=function(i){return Dd(An(o,i))},t}const rt=Dd(Ka);rt.Axios=$n;rt.CanceledError=ua;rt.CancelToken=k2;rt.isCancel=Vd;rt.VERSION=$d;rt.toFormData=fi;rt.AxiosError=Pe;rt.Cancel=rt.CanceledError;rt.all=function(n){return Promise.all(n)};rt.spread=_2;rt.isAxiosError=E2;rt.mergeConfig=An;rt.AxiosHeaders=It;rt.formToJSON=o=>Sd(K.isHTMLForm(o)?new FormData(o):o);rt.getAdapter=Id.getAdapter;rt.HttpStatusCode=Wr;rt.default=rt;const{Axios:iT,AxiosError:rT,CanceledError:sT,isCancel:lT,CancelToken:cT,VERSION:dT,all:uT,Cancel:mT,isAxiosError:pT,spread:fT,toFormData:hT,AxiosHeaders:vT,HttpStatusCode:gT,formToJSON:yT,getAdapter:bT,mergeConfig:wT}=rt;class gi{constructor(n="/api/v1"){this.eventSource=null,this.progressCallbacks=new Map,this.api=rt.create({baseURL:n,headers:{"Content-Type":"application/json",Accept:"application/json"}}),this.api.interceptors.request.use(t=>{const a=this.getAuthToken();return a&&(t.headers.Authorization=`Bearer ${a}`),t}),this.api.interceptors.response.use(t=>t,t=>{var a;return(a=t.response)==null||a.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,a=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"))):Date.now()-r>i&&(clearInterval(c),l(new Error("Render job timed out")))}catch(d){clearInterval(c),l(d)}},a)})}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{await this.api.delete(`/video/jobs/${n}`),this.unsubscribeFromProgress(n)}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",a=>{const i=JSON.parse(a.data),r=this.progressCallbacks.get(i.jobId);r&&r(i.progress)}),this.eventSource.addEventListener("complete",a=>{const i=JSON.parse(a.data),r=this.progressCallbacks.get(i.jobId);r&&(r(100),this.unsubscribeFromProgress(i.jobId))}),this.eventSource.addEventListener("error",a=>{this.progressCallbacks.forEach((i,r)=>{this.pollProgress(r)})})}catch{}}async pollProgress(n){const t=setInterval(async()=>{try{const a=await this.getJob(n),i=this.progressCallbacks.get(n);i&&i(a.progress),(a.status==="completed"||a.status==="failed")&&(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 a of t){const[i,r]=a.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 a=await this.api.get(`/video/jobs/${n}/thumbnail`,{params:{time:t},responseType:"blob"});return URL.createObjectURL(a.data)}catch(a){throw a}}normalizeJob(n){const t=n,a={...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!==""&&(a.output_media_id=i);const r=t.error_message??t.errorMessage;typeof r=="string"&&r!==""&&(a.error_message=r);const s=t.started_at??t.startedAt;typeof s=="string"&&s!==""&&(a.started_at=s);const l=t.completed_at??t.completedAt;return typeof l=="string"&&l!==""&&(a.completed_at=l),a}}new gi;const x2={key:0,class:"mobile-layout"},C2={class:"mobile-toolbar"},S2={class:"mobile-toolbar-left"},V2=["aria-label"],N2={class:"mobile-toolbar-right"},T2=["disabled"],M2=["disabled"],B2={class:"preview-section"},F2={key:0,class:"mobile-export-overlay"},I2={class:"mobile-export-progress"},$2={class:"mobile-export-bar"},R2={class:"mobile-timeline-zoom"},D2={class:"mobile-edit-strip"},A2={class:"mobile-selection-summary"},L2={class:"mobile-selection-title"},U2={class:"mobile-selection-meta"},O2={class:"mobile-readout-row"},P2=["disabled"],z2={class:"mobile-readout-grid"},j2={class:"mobile-readout-chip","data-testid":"mobile-playhead-readout"},W2={class:"mobile-readout-chip","data-testid":"mobile-clip-in-readout"},Z2={class:"mobile-readout-chip","data-testid":"mobile-clip-out-readout"},H2={class:"mobile-readout-chip","data-testid":"mobile-duration-readout"},X2=["disabled"],G2={class:"mobile-speed-strip"},J2={class:"mobile-speed-chips"},Y2=["data-testid","onClick"],q2={class:"mobile-edit-actions"},K2=["disabled"],Q2=["disabled"],ek=["disabled"],tk=["disabled"],nk=["disabled"],ak={class:"mobile-action-sheet-header"},ok={class:"mobile-action-sheet-title"},ik={class:"mobile-action-sheet-subtitle"},rk={class:"mobile-action-sheet-actions"},sk=["disabled"],lk=["disabled"],ck=["disabled"],dk=["disabled"],uk=["disabled"],mk={key:1,class:"desktop-layout"},pk={class:"desktop-main-row"},fk={class:"preview-panel"},hk={class:"fit-toggle"},vk={class:"editor-content"},gk={class:"editor-tabs"},yk={class:"tab-header"},bk=["onClick"],wk={class:"tab-content-area"},kk={class:"filter-controls"},_k={class:"text-controls"},Ek={class:"transition-controls"},xk={class:"audio-controls"},Ck={class:"adjustments-controls"},Sk={key:1,class:"no-filter-selected"},Vk={class:"export-controls"},Nk={key:0,"data-testid":"video-export-status-completed"},Tk={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},Mk={class:"desktop-timeline-row"},Bk={class:"timeline-zoom"},Fk=["value"],Ik={class:"zoom-readout"},$k={key:0,class:"dev-editor-controls","data-testid":"video-editor-dev-controls"},Rk={class:"dev-editor-row"},Dk={class:"dev-editor-field"},Ak={class:"dev-editor-field"},Lk=["disabled"],Uk=["disabled"],Ok=["disabled"],Pk={class:"dev-editor-row"},zk={class:"dev-editor-field dev-editor-field--wide"},jk=["value"],Wk=["disabled"],Zk=["disabled"],Hk=["disabled"],Xk=["disabled"],Gk=e.defineComponent({__name:"VideoEditor",props:{mediaUuid:{},initialRecipe:{},media:{},showThumbnailPicker:{type:Boolean,default:!1},workflowMode:{default:"full"},featureFlags:{},clientExportThreshold:{default:20},maxDuration:{default:300},serverRenderEndpoint:{default:null}},emits:["recipe-generated","export-started","draft-saved","video-exported","thumbnail-selected","server-render-started","server-render-progress","server-render-completed","server-render-failed","close"],setup(o,{expose:n,emit:t}){const a=o,i=t,r=e.computed(()=>{if(!a.media||typeof a.media!="object")return;const y=a.media.uuid??a.media.id;return typeof y=="string"&&y.trim()!==""?y.trim():void 0}),s=e.computed(()=>{const y=typeof a.mediaUuid=="string"?a.mediaUuid.trim():"";return y!==""?y: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 y=a.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},E=a.featureFlags;return E?{filters:typeof E.filters=="boolean"?E.filters:y.filters,adjustments:typeof E.adjustments=="boolean"?E.adjustments:y.adjustments,text:typeof E.text=="boolean"?E.text:y.text,transitions:typeof E.transitions=="boolean"?E.transitions:y.transitions,audio:typeof E.audio=="boolean"?E.audio:y.audio,export:typeof E.export=="boolean"?E.export:y.export}:y}),m=e.computed(()=>l.value?c.value:d.value),f=e.computed(()=>m.value==="filters"||k.value),p=e.computed(()=>m.value!=="filters"&&!k.value),v=e.ref(null),g=e.ref(null),k=e.ref(!1),T=e.computed(()=>l.value?v.value:g.value);function V(y){return y==="contain"||y==="cover"||y==="none"}function b(y){if(!(y!=null&&y.metadata))return null;const E=y.metadata.fit_mode;return V(E)?E:null}const h=e.shallowRef(null),_=e.ref(null),R=e.ref(b(a.initialRecipe)??"contain"),M=e.ref(null),x=e.ref(null),C=e.ref(null),P=e.ref(!1),S=new Map,D=e.ref([]),I=e.ref([]),j=e.ref([]),O=e.ref([]),F=e.ref(1),B=()=>{l.value=window.innerWidth<768},w=[{id:"filters",label:"Filters",icon:yn},{id:"adjustments",label:"Adjust",icon:vp},{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:na}],$=[{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(y=>u.value[y.id])),W=e.computed(()=>$.filter(y=>u.value[y.id])),Q=e.computed(()=>{var y,E;return((y=W.value[0])==null?void 0:y.id)??((E=z.value[0])==null?void 0:E.id)??"filters"});e.watch(u,y=>{y[c.value]||(c.value=Q.value),y[d.value]||(d.value=Q.value)},{immediate:!0,deep:!0}),e.watch(Q,y=>{u.value[c.value]||(c.value=y),u.value[d.value]||(d.value=y)},{immediate:!0}),e.watch(u,y=>{y.export||(c.value==="export"&&(c.value=Q.value),d.value==="export"&&(d.value=Q.value))},{immediate:!0,deep:!0});const ye=e.computed(()=>typeof window>"u"?!1:window.__MEDIABLES_EDITOR_DEV__===!0),we=Cc(),{currentFrame:ie,playheadPosition:N,timelineClips:L,totalDuration:te,hasChanges:ne,isPlaying:re,selectedClip:he,zoomLevel:de,playbackSpeed:me,fps:Ve,handleTrim:ce,handleSplit:pe,handleClipSelect:xe,splitAtPlayhead:Fe,deleteSelectedClip:ut,duplicateSelectedClip:tt,setZoomLevel:Et,moveClip:ot,setFilters:at,setTextOverlays:bt,setAudioTracks:Vt,saveDraft:vt,clearHasChanges:st,resetChanges:ve,generateRecipe:Ee,zoomIn:Ne,zoomOut:je,fitToWindow:G,togglePlayback:q,setPlaying:A,seekTo:J,frameForward:ae,frameBackward:se,skipToStart:Ce,skipToEnd:Ae,setPlaybackSpeed:De,updateSourceDuration:Le,undo:Ue,redo:Ke,canUndo:xt,canRedo:zt}=rd(s.value,a.initialRecipe,a.media),{videoCompatibleFilters:ma,activeFilters:Qe,selectedFilter:Qa,previewFilter:wn,previewFilterEffect:jn,applyFilter:pa,updateFilterParams:fa,removeFilter:ha,clearAllFilters:Wn,setActiveFilters:ki}=cd();function kn(y){var H,oe;const E=((H=he.value)==null?void 0:H.id)??((oe=L.value[0])==null?void 0:oe.id);E&&(P.value=!0,typeof y=="object"&&y.id?pa(y.id):typeof y=="string"&&pa(y),at(Qe.value),h.value?h.value.setClipFilters(E,Qe.value):S.set(E,[...Qe.value]),xe(E),P.value=!1,Jt())}function Ns(){var E,H;const y=((E=he.value)==null?void 0:E.id)??((H=L.value[0])==null?void 0:H.id);y&&xe(y)}function _i(y){const E=Qe.value.find(H=>H.filterId===y);E&&ha(E.id)}const Y=e.computed(()=>ma.value.map(E=>{var oe;const H=[];if(E.controls&&E.controls.length>0)for(const ge of E.controls){const ue=ge.type;if(ue==="button"||ue==="text"||ue==="range")continue;const fe={id:ge.property||ge.id,label:ge.label||ge.id,type:ue,default:ge.default??(ue==="toggle"?!1:ue==="color"?"#ffffff":0)};ue==="slider"&&(fe.min=ge.min??0,fe.max=ge.max??1,fe.step=ge.step??.01),ue==="select"&&ge.options&&(fe.options=ge.options),H.push(fe)}else if(E.paramRanges){const ge=Object.entries(E.paramRanges);for(const[ue,fe]of ge){const He=ue.replace(/[-_]/g," ").replace(/\b\w/g,Yt=>Yt.toUpperCase()),Ct=(oe=E.defaultParams)==null?void 0:oe[ue],sn=(fe.min+fe.max)/2;H.push({id:ue,label:He,min:fe.min,max:fe.max,step:fe.step??.01,default:typeof Ct=="number"?Ct:sn})}}return{id:E.id,name:E.name,category:E.category,params:H}})),ee=e.ref("0.00"),be=e.ref("0.00"),Me=e.ref("");e.watch(Y,y=>{if(y.length===0){Me.value="";return}y.some(H=>H.id===Me.value)||(Me.value=y[0].id)},{immediate:!0});const Be=e.ref(!1),$e=e.ref(0),Ge=e.ref(!1),qe=e.ref(null),Nt=e.ref(null);let Zn=null,Tt=!1,rn=null;const Ei=e.computed(()=>{const y=new Map;return Qe.value.forEach(E=>y.set(E.filterId,E)),y}),uu=e.computed(()=>{var y,E;return ie.value?ie.value:((y=a.media)==null?void 0:y.thumbnail_url)||((E=a.media)==null?void 0:E.url)}),Xt=e.ref("");e.watch(()=>{var y,E;return{file:(y=a.media)==null?void 0:y.file,url:(E=a.media)==null?void 0:E.url}},(y,E,H)=>{var ge,ue;const oe=Xt.value;H(()=>{oe&&oe.startsWith("blob:")&&URL.revokeObjectURL(oe)}),(ge=a.media)!=null&&ge.file?Xt.value=URL.createObjectURL(a.media.file):(ue=a.media)!=null&&ue.url?Xt.value=a.media.url:Xt.value=""},{immediate:!0}),e.onUnmounted(()=>{Xt.value&&Xt.value.startsWith("blob:")&&URL.revokeObjectURL(Xt.value)});const xi=e.computed(()=>Xt.value),Ts=e.computed(()=>{if(!a.media)return null;const{file:y,...E}=a.media;return{...E,url:Xt.value}}),Ms=e.computed(()=>{var E;const y=(E=a.media)==null?void 0:E.url;return!!(y&&/^https?:/i.test(y))}),Bs=e.computed(()=>Qe.value),Fs=e.computed(()=>N.value),Ci=e.computed(()=>!!he.value&&N.value>0),Si=e.computed(()=>!!he.value&&L.value.length>1),Is=e.computed(()=>!!he.value),un=e.ref(!0),mu=[.5,1,1.5,2],eo=e.computed(()=>{const y=new Set([0,Ut.value]);for(const E of L.value)y.add(E.timelineStart),y.add(E.timelineEnd);return Array.from(y).filter(E=>Number.isFinite(E)).sort((E,H)=>E-H)}),pu=e.computed(()=>eo.value.some(y=>y<N.value-.001)),fu=e.computed(()=>eo.value.some(y=>y>N.value+.001)),to=e.ref(!1),no=e.ref(null);function mn(y){if(!Number.isFinite(y)||y<0)return"0:00";const E=Math.floor(y/60),H=Math.floor(y%60);return`${E}:${H.toString().padStart(2,"0")}`}const hu=e.computed(()=>{var H;const y=he.value??L.value[0];if(!y)return"No clip selected";const E=(H=y.label)==null?void 0:H.trim();return E&&E.length>0?E:`Clip ${y.id.slice(-4)}`}),vu=e.computed(()=>{const y=he.value??L.value[0];if(!y)return"Tap a clip to start editing";const E=Math.max(0,y.timelineEnd-y.timelineStart);return`${mn(y.timelineStart)} - ${mn(y.timelineEnd)} • ${E.toFixed(1)}s`});function $s(y){return!Number.isFinite(y)||y<0?"0.0s":y<60?`${y.toFixed(1)}s`:mn(y)}const gu=e.computed(()=>mn(N.value)),yu=e.computed(()=>{const y=he.value??L.value[0];return y?mn(y.sourceIn):"0:00"}),bu=e.computed(()=>{const y=he.value??L.value[0];return y?mn(y.sourceOut):"0:00"}),wu=e.computed(()=>{const y=he.value??L.value[0];return y?$s(y.timelineEnd-y.timelineStart):"0.0s"}),Vi=e.computed(()=>no.value===null?he.value??L.value[0]??null:L.value.find(y=>y.id===no.value)??null),ku=e.computed(()=>{var H;const y=Vi.value;if(!y)return"Clip actions";const E=(H=y.label)==null?void 0:H.trim();return E&&E.length>0?E:`Clip ${y.id.slice(-4)}`}),_u=e.computed(()=>{const y=Vi.value;return y?`${mn(y.timelineStart)} - ${mn(y.timelineEnd)} • ${$s(y.timelineEnd-y.timelineStart)}`:"Choose an action"}),Ni=e.ref(0),Ut=e.computed(()=>{try{const y=te.value??te;return y&&typeof y=="number"&&y>0?y:Ni.value}catch{return Ni.value}}),Hn=e.ref(),Ti=e.ref(),Mi=e.ref(),Bi=e.ref(),ao=e.ref(0),_n=e.ref(!1);let Mt=null,Gt=null;e.watch(Ut,y=>{var H;if(_n.value||!y||y<=0)return;const E=ao.value||((H=Hn.value)==null?void 0:H.clientWidth)||0;E>0&&(_n.value=!0,G(E))}),e.watch(ao,y=>{if(_n.value||!y||y<=0)return;Ut.value>0&&(_n.value=!0,G(y))}),e.watch(l,y=>{y||En()}),e.watch(()=>{var y;return(y=Vi.value)==null?void 0:y.id},y=>{to.value&&!y&&En()});function Xn(y){return Number.isFinite(y)?y.toFixed(2):"0.00"}function Rs(y){const E=Number(y);return Number.isFinite(E)?E:null}function Eu(y){y&&(ee.value=Xn(y.sourceIn),be.value=Xn(y.sourceOut))}e.watch(()=>{var y,E,H;return[(y=he.value)==null?void 0:y.id,(E=he.value)==null?void 0:E.sourceIn,(H=he.value)==null?void 0:H.sourceOut]},()=>{Eu(he.value)},{immediate:!0});function Ds(y){const E=he.value;if(!E)return;const H=1/30,oe=E.sourceMinIn??0,ge=E.sourceMaxOut??Ut.value,ue=E.sourceIn+(N.value-E.timelineStart);if(y==="start"){const He=Math.max(oe,Math.min(ue,E.sourceOut-H));ee.value=Xn(He);return}const fe=Math.max(E.sourceIn+H,Math.min(ue,ge));be.value=Xn(fe)}function xu(){const y=he.value;if(!y)return;const E=Rs(ee.value),H=Rs(be.value);if(E===null||H===null)return;const oe=1/30,ge=y.sourceMinIn??0,ue=y.sourceMaxOut??Ut.value,fe=Math.max(ge,Math.min(E,ue-oe)),He=Math.max(fe+oe,Math.min(H,ue));ce(y.id,"start",fe),ce(y.id,"end",He),ee.value=Xn(fe),be.value=Xn(He),he.value&&J(he.value.timelineStart)}function Cu(){Me.value.trim()!==""&&kn(Me.value)}function Su(){var y;Wn(),at(Qe.value),(y=he.value)!=null&&y.id&&(h.value?h.value.setClipFilters(he.value.id,Qe.value):S.set(he.value.id,[...Qe.value])),Jt()}function As(y,E,H){var ge,ue;const oe=Qe.value.find(fe=>fe.filterId===y);oe?(oe.params={...oe.params,[E]:H},at(Qe.value),h.value&&((ge=he.value)!=null&&ge.id)?h.value.setClipFilters(he.value.id,Qe.value):(ue=he.value)!=null&&ue.id&&S.set(he.value.id,[...Qe.value]),Jt(),Ns()):wn.value&&wn.value.filterId===y&&(wn.value.params={...wn.value.params||{},[E]:H})}function Ls(y){J(y)}function Us(y){!y||!Number.isFinite(y.timestamp)||J(y.timestamp)}function Os(y){A(y)}function oo(y){!Number.isFinite(y)||y<=0||(Ni.value=y,Le(y))}function En(){to.value=!1,no.value=null}function Vu(y){l.value&&(no.value=y,to.value=!0)}function Fi(y){var oe,ge,ue,fe;const E=((oe=he.value)==null?void 0:oe.id)??((ge=L.value[0])==null?void 0:ge.id)??null;xe(y),(((ue=he.value)==null?void 0:ue.id)??((fe=L.value[0])==null?void 0:fe.id)??null)!==E&&we.selection()}function Ps(y){Fi(y),Vu(y)}function zs(y){y&&we.selection()}function js(){un.value=!un.value,we.selection()}function Ws(){const y=eo.value.filter(H=>H<N.value-.001),E=y.length>0?y[y.length-1]:0;J(E)}function Zs(){const y=eo.value.find(E=>E>N.value+.001);J(y??Ut.value)}function Ii(){Ue()}function $i(){Ke()}function io(){const y=L.value.length;Fe(),L.value.length>y&&(we.success(),En())}function Hs(y){const E=L.value.length;pe(y),L.value.length>E&&we.success()}function Ri(){const y=L.value.length;tt(),L.value.length>y&&(we.selection(),En())}function Di(){const y=L.value.length;ut(),L.value.length<y&&(we.error(),En())}function Nu(y){const E=me.value;De(y),me.value!==E&&we.selection()}function Tu(y){return y instanceof HTMLElement?y.closest('input, textarea, select, button, [contenteditable="true"]')!==null:!1}function Xs(y){if(l.value||Tu(y.target))return;const E=y.key.toLowerCase(),H=y.metaKey||y.ctrlKey;if(y.code==="Space"){y.preventDefault(),q();return}if(!H&&E==="s"){y.preventDefault(),io();return}if(E==="arrowleft"){y.preventDefault(),se();return}if(E==="arrowright"){y.preventDefault(),ae();return}if(E==="home"){y.preventDefault(),Ce();return}if(E==="end"){y.preventDefault(),Ae();return}if(!H&&E==="["){y.preventDefault(),Ws();return}if(!H&&E==="]"){y.preventDefault(),Zs();return}if(H&&E==="z"&&y.shiftKey){y.preventDefault(),$i();return}H&&E==="z"&&(y.preventDefault(),Ii())}function Mu(){var E;const y=ao.value||((E=Hn.value)==null?void 0:E.clientWidth)||800;G(y)}function Ai(y){_n.value=!0,Et(y)}function Bu(){_n.value=!0,Ne()}function Fu(){_n.value=!0,je()}function Iu(y){const E=y.target,H=Number(E.value);Ai(H)}function Gs(y){const E=Math.min(600,Math.max(10,de.value+y));Ai(E)}function Li(){Gt==null||Gt(),Gt=null;const y=Mi.value,E=Bi.value;if(!l.value||!y||!E)return;const H=()=>{Gs(-20)},oe=()=>{Gs(20)};y.addEventListener("click",H),E.addEventListener("click",oe),Gt=()=>{y.removeEventListener("click",H),E.removeEventListener("click",oe)}}e.watch([l,Mi,Bi],()=>{Li()},{flush:"post"});function Js(y){var E;h.value=y,(E=h.value)!=null&&E.composition&&(M.value=new dd(h.value.composition),x.value=new La(h.value.composition),C.value=new ud(h.value.composition));try{S.size&&(S.forEach((H,oe)=>{h.value.setClipFilters(oe,H)}),S.clear(),h.value.composition.computeFrame())}catch{}}function $u(y){y!=null&&y.id&&jn(y.id)}function Ru(y){fa(y),Jt()}async function Du(y){if(!M.value)return;const E=await M.value.addTextOverlay(y);D.value.push({id:E,...y})}async function Au(y,E){if(!M.value)return;await M.value.updateTextOverlay(y,E);const H=D.value.findIndex(oe=>oe.id===y);H!==-1&&(D.value[H]={...D.value[H],...E})}async function Lu(y){M.value&&(await M.value.removeTextOverlay(y),D.value=D.value.filter(E=>E.id!==y))}async function Uu(y){if(!x.value||O.value.length<2)return;const[E,H]=O.value,oe=await x.value.applyTransition(E,H,y);I.value.push({id:oe,...y,name:y.type})}function Ou(y){if(!x.value)return;const E=I.value[y];E&&(x.value.removeTransition(E.id),I.value.splice(y,1))}function Pu(y){}async function zu(y){if(!C.value)return;const E=await C.value.addAudioTrack(y);j.value.push({id:E,...y})}async function ju(y,E){if(!C.value)return;const H=j.value.findIndex(oe=>oe.id===y);H!==-1&&(j.value[H]={...j.value[H],...E})}async function Wu(y){C.value&&(await C.value.removeAudioTrack(y),j.value=j.value.filter(E=>E.id!==y))}async function Zu(y,E){if(!C.value)return;await C.value.updateVolume(y,E);const H=j.value.find(oe=>oe.id===y);H&&(H.volume=E)}async function Hu(y,E){if(!C.value)return;await C.value.muteTrack(y,E);const H=j.value.find(oe=>oe.id===y);H&&(H.muted=E)}function Xu(y){C.value&&(C.value.setMasterVolume(y),F.value=y)}function Gu(y){i("thumbnail-selected",y)}function pn(){Zn!==null&&(clearInterval(Zn),Zn=null)}function Ju(y,E){return E?{...y,output:{...y.output,format:E.format,quality:E.quality}}:y}function va(y){var E;return y.metadata||(y.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),y.metadata.fit_mode=R.value,(E=a.media)!=null&&E.url&&/^https?:/i.test(a.media.url)?y.metadata.source_url=a.media.url:delete y.metadata.source_url,y}function it(y,E,H){return Math.min(H,Math.max(E,y))}function Ui(y,E){if(typeof y=="number"&&Number.isFinite(y))return y;if(typeof y=="string"){const H=Number(y);if(Number.isFinite(H))return H}return E}function wt(y,E,H){for(const oe of E)if(oe in y)return Ui(y[oe],H);return H}function Yu(y){const E=typeof y.params=="object"&&y.params!==null?y.params:{};switch(y.filterId.trim().toLowerCase()){case"brightness":return[{type:"brightness",value:it(wt(E,["value","brightness"],0),-1,1)}];case"contrast":return[{type:"contrast",value:it(wt(E,["value","contrast"],1),.1,3)}];case"saturation":return[{type:"saturation",value:it(wt(E,["value","saturation"],1),0,3)}];case"blur":case"gaussian-blur":case"kawase-blur":case"radial-blur":return[{type:"blur",value:it(wt(E,["value","blur","radius"],0),0,25)}];case"sharpen":return[{type:"sharpen",value:it(wt(E,["value","amount"],1),0,5)}];case"sepia":return[{type:"sepia",value:1}];case"grayscale":return[{type:"grayscale",value:1}];case"adjustment":{const oe=it(wt(E,["brightness"],1)-1,-1,1),ge=it(wt(E,["contrast"],1),.1,3),ue=it(wt(E,["saturation"],1),0,3);return[{type:"brightness",value:oe},{type:"contrast",value:ge},{type:"saturation",value:ue}]}default:return[]}}function qu(y){const E=y.timeline[0],H=Array.isArray(E==null?void 0:E.filters)?E.filters:[],oe=[];for(const ue of H)if(oe.push(...Yu(ue)),oe.length>=12)break;const ge={...y,filters:oe.slice(0,12)};if(y.timeline.length===1&&E){const ue=Math.max(0,Ui(E.sourceIn,0)),fe=Ui(E.sourceOut,ue);fe>ue&&(ge.trim={start:ue,end:fe})}return ge}function Ku(y){return{"360p":[640,360],"480p":[854,480],"720p":[1280,720],"1080p":[1920,1080],"1440p":[2560,1440],"2160p":[3840,2160]}[y??""]??[1920,1080]}function Qu(y){if(!y||typeof y!="object")return null;const E=y.duration;if(typeof E=="number"&&Number.isFinite(E)&&E>0)return E;if(E&&typeof E=="object"&&"value"in E){const H=E.value;if(typeof H=="number"&&Number.isFinite(H)&&H>0)return H}return null}async function Ys(y,E,H){var sn,Yt,Gn,hn;const oe=y.timeline[0],ge=oe?Math.max(0,oe.sourceIn):0,ue=oe?oe.sourceOut:void 0,[fe,He]=Ku((E==null?void 0:E.quality)??((sn=y.output)==null?void 0:sn.quality)),Ct=((Yt=y.output)==null?void 0:Yt.fps)||30;A(!1),k.value=!0,await e.nextTick();try{const pt=[200,500,1e3];let gt=!1;for(const Xi of pt){await new Promise(bm=>setTimeout(bm,Xi));const lo=T.value;if(!(!lo||typeof lo.captureFrameAt!="function")&&typeof lo.ensureReadyForCapture=="function"&&(gt=await lo.ensureReadyForCapture(),gt))break}const qt=T.value;if(!qt||typeof qt.captureFrameAt!="function")throw new Error("PIXI preview not available for export. Ensure the preview is mounted.");if(!gt)throw new Error("PIXI preview not ready for frame capture after retries. The video may still be loading.");const{exportWithPixiFrames:ga,isWebCodecsSupported:Zi}=await Promise.resolve().then(()=>require("./PixiFrameExporter-n220y4aZ.cjs"));if(!Zi())throw new Error("WebCodecs is not supported in this browser. Export requires Chrome 94+ or equivalent.");rn=new AbortController;const so={width:fe,height:He,fps:Ct,trimStart:ge,signal:rn.signal};ue!==void 0&&(so.trimEnd=ue),H&&(so.onProgress=H);const il=Xt.value;il!==""&&(so.sourceUrl=il);const fm=typeof qt.duration=="number"&&qt.duration>0?qt.duration:((Gn=y.source)==null?void 0:Gn.duration)??ue??0,hm=await ga({captureFrameAt:Xi=>qt.captureFrameAt(Xi),duration:{value:fm}},so),Hi=new File([hm],`edited-video-${Date.now()}.mp4`,{type:"video/mp4"}),vm=Qu(qt),gm=((hn=y.source)==null?void 0:hn.duration)??0,ym=Math.max(0,(ue??vm??gm)-ge);return{file:Hi,recipe:y,meta:{duration:ym,width:fe,height:He,format:"mp4",sizeBytes:Hi.size,size_bytes:Hi.size}}}finally{k.value=!1,rn=null}}async function em(y,E){var hn;pn(),Tt=!1,rn=null,Nt.value=null,qe.value=null,Ge.value=!1,$e.value=0;const H=va(y??Ee()),oe=al(H),ge=Array.isArray(oe.filters)&&oe.filters.length>0,ue=zi(oe);if(!(ne.value||ge||ue))return st(),i("video-exported",null),null;const He=oe.timeline[0],Ct=He?Math.max(0,He.sourceIn):0,Yt=((He==null?void 0:He.sourceOut)??((hn=oe.source)==null?void 0:hn.duration)??Ut.value)-Ct,Gn=a.serverRenderEndpoint!=null&&a.clientExportThreshold>0&&Yt>a.clientExportThreshold;if(Gn){Be.value=!0;try{return await tm(oe),null}catch(pt){const gt=pt instanceof Error?pt.message:"Server render failed";throw qe.value=gt,i("server-render-failed",gt),pt}finally{Be.value=!1}}if(a.maxDuration>0&&Yt>a.maxDuration&&!Gn){const pt=`This video is too long for in-browser export (${Math.round(Yt)}s). Server rendering is not available. Try a shorter clip.`;return qe.value=pt,i("video-exported",null),null}Be.value=!0;try{const pt=await Ys(oe,E,gt=>{Tt||($e.value=gt)});return Tt?(qe.value="Export canceled.",$e.value=0,i("video-exported",null),null):(st(),i("recipe-generated",oe),i("video-exported",pt),$e.value=100,Ge.value=!0,pt)}catch(pt){if(Tt)return qe.value="Export canceled.",$e.value=0,i("video-exported",null),null;const gt=pt instanceof Error?pt.message:"Local WebGL export failed.";throw qe.value=gt,new Error(`Video export failed: ${gt}`)}finally{Be.value=!1}}function ro(){return new gi(a.serverRenderEndpoint??"/api/v1")}async function tm(y){const E=ro();qe.value="Starting server render...",$e.value=0;const H=await E.createRenderJob({source_media_uuid:s.value,recipe:y});Nt.value=H.id,i("server-render-started",H.id),i("export-started",H.id),qe.value="Rendering on server...";const oe=await E.pollRenderJob(H.id,(ue,fe)=>{$e.value=ue,fe==="processing"&&(qe.value=`Server rendering: ${ue}%`)},3e3,(a.maxDuration>0?a.maxDuration*3:1800)*1e3);$e.value=100,Ge.value=!0,qe.value="Server render complete!",st(),i("recipe-generated",y);const ge={id:oe.id};typeof oe.output_media_id=="string"&&oe.output_media_id!==""&&(ge.output_media_id=oe.output_media_id),i("server-render-completed",ge)}async function qs(){if(!Be.value)return;Tt=!0,k.value=!1,rn&&(rn.abort(),rn=null),pn();const y=Nt.value;if(y)try{await ro().cancelJob(y)}catch(E){const H=E instanceof Error?E.message:"Failed to cancel export";qe.value=H,Be.value=!1,Nt.value=null;return}Be.value=!1,$e.value=0,Ge.value=!1,Nt.value=null,qe.value="Export canceled."}async function Ks(y){pn(),Tt=!1,rn=null,Nt.value=null,qe.value=null,Ge.value=!1,Be.value=!0,$e.value=0;try{const E=va(Ju(Ee(),y));i("recipe-generated",E);const H=s.value.startsWith("temp-"),oe=E.timeline[0],ge=Array.isArray(oe==null?void 0:oe.filters)?oe.filters:[],ue=!0,fe=typeof window<"u"&&window.MEDIABLES_ALLOW_SERVER_EXPORT_FALLBACK===1||typeof localStorage<"u"&&localStorage.getItem("mediables.export.allowServerFallback")==="1";if(ue)try{const gt=await Ys(E,y,Zi=>{Tt||($e.value=Zi)});if(Tt){qe.value="Export canceled.",Be.value=!1,$e.value=0;return}i("video-exported",gt);const qt=URL.createObjectURL(gt.file),ga=document.createElement("a");ga.href=qt,ga.download=`edited-video-${Date.now()}.mp4`,ga.click(),setTimeout(()=>URL.revokeObjectURL(qt),100),Be.value=!1,$e.value=100,Ge.value=!0;return}catch(gt){if(Tt){qe.value="Export canceled.",Be.value=!1,$e.value=0;return}if(H||!fe)throw gt;$e.value=0,qe.value="Local filter export failed, falling back to server render."}const He={"360p":"low","480p":"low","720p":"medium","1080p":"high","1440p":"ultra","2160p":"ultra"},Ct=(y==null?void 0:y.quality)??E.output.quality,sn=He[Ct]??"high",Yt={...qu(E),export:{format:(y==null?void 0:y.format)??E.output.format,quality:sn,resolution:Ct,framerate:E.output.fps}},hn=await ro().createJob({source_media_id:s.value,recipe:Yt}),pt=typeof hn.id=="string"?hn.id:null;if(!pt)throw new Error("Export failed: missing job id");Nt.value=pt,i("export-started",pt),mm(pt)}catch(E){if(k.value=!1,rn=null,Tt){qe.value="Export canceled.",Be.value=!1,$e.value=0,Nt.value=null;return}try{const H=va(Ee()),oe=new Blob([JSON.stringify(H,null,2)],{type:"application/json"}),ge=URL.createObjectURL(oe),ue=document.createElement("a");ue.href=ge,ue.download=`video-recipe-${Date.now()}.json`,ue.click(),setTimeout(()=>URL.revokeObjectURL(ge),100)}finally{Be.value=!1,$e.value=0,Nt.value=null,qe.value=E instanceof Error?E.message:"Export failed"}}}const Oi=async y=>{await new Promise(E=>{window.setTimeout(E,y)})},Pi=y=>{if(!y||y.width<=0||y.height<=0)return null;try{return y.toDataURL("image/jpeg",.85)}catch{return null}},nm=y=>{if(!y||typeof y!="object")return null;const H=y.pixiCanvas;if(H&&typeof H=="object"&&"value"in H){const oe=H.value;return oe instanceof HTMLCanvasElement?oe:null}return H instanceof HTMLCanvasElement?H:null},am=y=>{if(!y||typeof y!="object")return null;const E=y.duration;if(typeof E=="number"&&Number.isFinite(E))return E;if(E&&typeof E=="object"&&"value"in E){const H=E.value;if(typeof H=="number"&&Number.isFinite(H))return H}return null},om=y=>{if(!y||typeof y!="object")return null;const H=y.videoElement;if(H&&typeof H=="object"&&"value"in H){const oe=H.value;return oe instanceof HTMLVideoElement?oe:null}return H instanceof HTMLVideoElement?H:null},Qs=y=>typeof y.params=="object"&&y.params!==null?y.params:{},im=y=>{const E=[];for(const H of y){const oe=Qs(H),ge=H.filterId.trim().toLowerCase();if(ge==="brightness"){const fe=(it(wt(oe,["value","brightness"],0),-1,1)+1)*100;E.push(`brightness(${fe.toFixed(2)}%)`);continue}if(ge==="contrast"){const ue=it(wt(oe,["value","contrast"],1),.1,4);E.push(`contrast(${(ue*100).toFixed(2)}%)`);continue}if(ge==="saturation"||ge==="saturate"){const ue=it(wt(oe,["value","saturation"],1),0,4);E.push(`saturate(${(ue*100).toFixed(2)}%)`);continue}if(ge==="grayscale"){E.push("grayscale(100%)");continue}if(ge==="sepia"){E.push("sepia(100%)");continue}if(ge==="blur"||ge==="gaussian-blur"||ge==="kawase-blur"){const ue=it(wt(oe,["value","blur","radius"],0),0,30);ue>.01&&E.push(`blur(${ue.toFixed(2)}px)`);continue}if(ge==="adjustment"){const ue=wt(oe,["brightness"],1),fe=wt(oe,["contrast"],1),He=wt(oe,["saturation"],1);Math.abs(ue-1)>.01&&E.push(`brightness(${(it(ue,0,5)*100).toFixed(2)}%)`),Math.abs(fe-1)>.01&&E.push(`contrast(${(it(fe,.1,5)*100).toFixed(2)}%)`),Math.abs(He-1)>.01&&E.push(`saturate(${(it(He,0,5)*100).toFixed(2)}%)`);continue}if(ge==="cinematic"){E.push("contrast(120%) brightness(95%) saturate(85%)");continue}if(ge==="dramatic"){E.push("contrast(140%) brightness(90%) saturate(110%) sepia(10%)");continue}if(ge==="dreamy"){E.push("blur(0.5px) brightness(105%) saturate(90%) contrast(95%)");continue}}return E.join(" ")},rm=y=>{const E=y.find(ge=>ge.filterId.trim().toLowerCase()==="noise");if(!E)return 0;const H=Qs(E),oe=wt(H,["noise","value","amount","intensity"],.2);return oe<=1?it(oe,0,1):it(oe/100,0,1)},sm=(y,E,H,oe)=>{if(oe<=0)return;const ge=y.getImageData(0,0,E,H),ue=255*oe;for(let fe=0;fe<ge.data.length;fe+=4){const He=(Math.random()*2-1)*ue;ge.data[fe]=it(ge.data[fe]+He,0,255),ge.data[fe+1]=it(ge.data[fe+1]+He,0,255),ge.data[fe+2]=it(ge.data[fe+2]+He,0,255)}y.putImageData(ge,0,0)},el=async y=>{y.readyState>=2&&y.videoWidth>0&&y.videoHeight>0||await new Promise(E=>{let H=!1,oe=0;const ge=()=>{H||(H=!0,y.removeEventListener("loadedmetadata",ue),y.removeEventListener("loadeddata",ue),y.removeEventListener("canplay",ue),window.clearTimeout(oe),E())},ue=()=>{ge()};y.addEventListener("loadedmetadata",ue),y.addEventListener("loadeddata",ue),y.addEventListener("canplay",ue),oe=window.setTimeout(()=>ge(),800),y.play().catch(()=>{})})},lm=async(y,E)=>{await new Promise(H=>{let oe=!1,ge=0;const ue=()=>{oe||(oe=!0,y.removeEventListener("seeked",fe),window.clearTimeout(ge),H())},fe=()=>{ue()};if(Math.abs(y.currentTime-E)<.016){requestAnimationFrame(()=>ue());return}y.addEventListener("seeked",fe),ge=window.setTimeout(()=>ue(),700),y.currentTime=E})},tl=async(y,E)=>{await el(y);const H=Math.floor(y.videoWidth),oe=Math.floor(y.videoHeight);if(H<=0||oe<=0)return null;const ge=Number.isFinite(y.duration)&&y.duration>0?y.duration:0,ue=ge>0?it(E,0,ge):0;await lm(y,ue);const fe=document.createElement("canvas");fe.width=H,fe.height=oe;const He=fe.getContext("2d");if(!He)return null;const Ct=im(Qe.value);Ct!==""&&(He.filter=Ct);try{He.drawImage(y,0,0,H,oe)}catch{return null}const sn=rm(Qe.value);return sm(He,H,oe,sn),Pi(fe)},cm=async(y,E)=>{const H=document.createElement("video");H.src=y,H.muted=!0,H.playsInline=!0,H.preload="auto",y.startsWith("blob:")||(H.crossOrigin="anonymous");try{return await el(H),await tl(H,E)}catch{return null}finally{H.pause(),H.removeAttribute("src"),H.load()}},dm=async y=>{const E=T.value,H=Pi(nm(E));if(H)return H;if(E!=null&&E.captureFrameAt)for(let ue=0;ue<4;ue+=1){const fe=am(E);if(fe!==null&&fe<=0&&ue<2){await Oi(80);continue}const He=await Promise.race([E.captureFrameAt(y),Oi(450).then(()=>null)]),Ct=Pi(He);if(Ct)return Ct;await Oi(80)}const oe=om(E);if(oe){const ue=await tl(oe,y);if(ue)return ue}const ge=xi.value.trim();if(ge!==""){const ue=await cm(ge,y);if(ue)return ue}return null},nl=y=>y.map(E=>({...E,params:E.params&&typeof E.params=="object"?{...E.params}:E.params}));function al(y){const E=nl(Qe.value);if(!zi(y)&&E.length>0&&Array.isArray(y.timeline)&&y.timeline.length>0){const oe=y.timeline[0];oe&&(y.timeline=[{...oe,filters:E},...y.timeline.slice(1)])}return y}const zi=y=>Array.isArray(y.timeline)?y.timeline.some(E=>Array.isArray(E.filters)&&E.filters.length>0):!1,um=y=>{if(!y||typeof y!="object")return null;const E=y.posterFrame;if(typeof E!="string")return null;const H=E.trim();return H!==""?H:null};async function ji(){const y=va(al(vt())),E=nl(Qe.value),H=zi(y)||E.length>0,oe=um(a.initialRecipe);if(H){const ge=N.value>0?N.value:.1;try{const ue=await dm(ge);ue?y.posterFrame=ue:oe&&(y.posterFrame=oe)}catch{oe&&(y.posterFrame=oe)}}else delete y.posterFrame;return st(),i("draft-saved",y),y}function ol(){ve()&&(Wn(),Jt())}async function mm(y){pn();const E=ro();Zn=window.setInterval(async()=>{try{if(Tt){pn();return}const H=await E.getJob(y),oe=Number(H.progress??0);if($e.value=Number.isFinite(oe)?oe:0,H.status==="completed"||H.status==="failed"||H.status==="cancelled")if(pn(),Be.value=!1,Nt.value=null,H.status==="completed")$e.value=100,Ge.value=!0,qe.value=null;else{const ge=H.status==="cancelled"||typeof H.error_message=="string"&&/cancel/i.test(H.error_message);qe.value=ge?"Export canceled.":typeof H.error_message=="string"&&H.error_message.trim()!==""?H.error_message:"Export failed"}}catch(H){pn(),Be.value=!1,Nt.value=null,qe.value=H instanceof Error?H.message:"Failed to check export progress"}},2e3)}function Wi(){const y=va(Ee());try{const E=y.timeline??[]}catch{}_.value=y}let xn=null;function Jt(){xn&&clearTimeout(xn),xn=setTimeout(()=>{Wi(),xn=null},200)}e.watch(()=>L.value,Jt,{deep:!0}),e.watch(()=>he.value,y=>{if(P.value||!y)return;const E=(y==null?void 0:y.filters)??[];ki(E)},{immediate:!0}),e.watch(()=>Qe.value,y=>{at(y),Jt()},{deep:!0}),e.watch(()=>D.value,y=>{bt(y),Jt()},{deep:!0}),e.watch(()=>j.value,y=>{const E=y.map(H=>({...H,source:typeof H.source=="string"?H.source:void 0}));Vt(E),Jt()},{deep:!0}),e.watch(()=>N.value,Jt),n({saveDraft:ji,exportForUpload:em}),Wi(),e.onUnmounted(()=>{pn(),Tt=!0,xn&&(clearTimeout(xn),xn=null),h.value&&(h.value.destroy(),h.value=null),M.value=null,x.value=null,C.value=null});function pm(){Mt||!Ti.value||(Mt=new $b({filters:Y.value,callbacks:{onApplyFilter:y=>{kn(y.id)},onRemoveFilter:y=>{_i(y)},onUpdateParam:(y,E,H)=>{As(y,E,H)},onPreviewFilter:y=>{jn(y.id)}}}),Mt.mount(Ti.value),Mt.setActiveFilters(Ei.value))}e.watch(Ei,y=>{Mt==null||Mt.setActiveFilters(y)},{deep:!0}),e.watch(Y,y=>{Mt==null||Mt.setFilters(y)});let fn=null;return e.onMounted(()=>{window.addEventListener("resize",B),window.addEventListener("keydown",Xs);const y=()=>{!Hn.value||fn||(fn=new ResizeObserver(E=>{E[0]&&(ao.value=Math.round(E[0].contentRect.width))}),fn.observe(Hn.value))};y(),fn||e.nextTick(y),l.value&&(Li(),Gt||e.nextTick(Li)),a.media&&Wi(),l.value&&e.nextTick(()=>{pm()}),e.nextTick(()=>{const E=document.querySelector(".video-editor");E&&E.getBoundingClientRect();const H=document.querySelector(".mobile-layout");H&&H.getBoundingClientRect()})}),e.onUnmounted(()=>{window.removeEventListener("resize",B),window.removeEventListener("keydown",Xs),fn==null||fn.disconnect(),fn=null,Gt==null||Gt(),Gt=null,Mt==null||Mt.destroy(),Mt=null}),(y,E)=>{var H,oe,ge,ue;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-editor",{mobile:l.value}])},[l.value?(e.openBlock(),e.createElementBlock("div",x2,[e.createElementVNode("div",C2,[e.createElementVNode("div",S2,[e.createElementVNode("button",{class:e.normalizeClass(["mobile-toolbar-btn",{active:e.unref(re)}]),onClick:E[0]||(E[0]=(...fe)=>e.unref(q)&&e.unref(q)(...fe)),"aria-label":e.unref(re)?"Pause":"Play","data-testid":"btn-mobile-play"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(re)?e.unref(Jr):e.unref(Yr)},null,8,["icon"])],10,V2),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:ol,"aria-label":"Reset all changes","data-testid":"btn-mobile-reset"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Un)},null,8,["icon"])])]),e.createElementVNode("div",N2,[e.createElementVNode("button",{class:"mobile-toolbar-btn mobile-toolbar-save",onClick:ji,"aria-label":"Save","data-testid":"btn-mobile-save",disabled:!e.unref(ne)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Go)},null,8,["icon"]),E[13]||(E[13]=e.createElementVNode("span",null,"Save",-1))],8,T2),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:E[1]||(E[1]=fe=>Ks()),"aria-label":"Export","data-testid":"btn-mobile-export",disabled:Be.value||!e.unref(ne)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(na)},null,8,["icon"])],8,M2),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:E[2]||(E[2]=fe=>i("close")),"aria-label":"Close","data-testid":"btn-mobile-close"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Rn)},null,8,["icon"])])])]),e.createElementVNode("div",B2,[e.withDirectives(e.createVNode(hr,{ref_key:"pixiPreviewMobileRef",ref:v,"aria-hidden":!f.value,class:"preview-host-child",source:xi.value,"fallback-duration":Ut.value,filters:Bs.value,playhead:Fs.value,"is-playing":e.unref(re),"fit-mode":R.value,active:f.value,onPlayPause:e.unref(q),onFrameUpdate:Us,onDurationChange:oo},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,f.value]]),e.withDirectives(e.createVNode(Br,{"aria-hidden":!p.value,class:"preview-host-child","media-uuid":s.value,recipe:_.value,media:Ts.value,"enable-engine":p.value&&Ms.value,"fit-mode":R.value,onTimeUpdate:Ls,onPlayStateChange:Os,onDurationChange:oo,onEngineReady:Js},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,p.value]]),Be.value?(e.openBlock(),e.createElementBlock("div",F2,[e.createElementVNode("div",I2,[e.createElementVNode("span",null,"Exporting "+e.toDisplayString($e.value)+"%",1),e.createElementVNode("div",$2,[e.createElementVNode("div",{class:"mobile-export-bar-fill",style:e.normalizeStyle({width:$e.value+"%"})},null,4)]),e.createElementVNode("button",{class:"mobile-export-cancel",onClick:qs},"Cancel")])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:Hn,class:"timeline-section"},[e.createElementVNode("div",R2,[e.createElementVNode("button",{ref_key:"mobileZoomOutButtonRef",ref:Mi,type:"button",class:"mobile-zoom-btn","aria-label":"Zoom out timeline","data-testid":"btn-timeline-zoom-out"},[...E[14]||(E[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:Bi,type:"button",class:"mobile-zoom-btn","aria-label":"Zoom in timeline","data-testid":"btn-timeline-zoom-in"},[...E[15]||(E[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(Fr,{playhead:e.unref(N),clips:e.unref(L),"selected-clip-id":((H=e.unref(he))==null?void 0:H.id)??((oe=e.unref(L)[0])==null?void 0:oe.id)??null,duration:Ut.value,fps:e.unref(Ve),"zoom-level":e.unref(de),"snap-enabled":un.value,sensitivity:.25,"is-mobile":!0,"onUpdate:playhead":e.unref(J),onTrim:e.unref(ce),onSplit:Hs,onClipSelect:Fi,onClipMove:e.unref(ot),onClipLongPress:Ps,onSnapStateChange:zs},null,8,["playhead","clips","selected-clip-id","duration","fps","zoom-level","snap-enabled","onUpdate:playhead","onTrim","onClipMove"])],512),e.createElementVNode("div",D2,[e.createElementVNode("div",A2,[e.createElementVNode("span",L2,e.toDisplayString(hu.value),1),e.createElementVNode("span",U2,e.toDisplayString(vu.value),1)]),e.createElementVNode("div",O2,[e.createElementVNode("button",{type:"button",class:"mobile-cut-nav-btn","data-testid":"btn-mobile-prev-cut","aria-label":"Jump to previous cut",disabled:!pu.value,onClick:Ws}," Prev Cut ",8,P2),e.createElementVNode("div",z2,[e.createElementVNode("span",j2,"Playhead "+e.toDisplayString(gu.value),1),e.createElementVNode("span",W2,"In "+e.toDisplayString(yu.value),1),e.createElementVNode("span",Z2,"Out "+e.toDisplayString(bu.value),1),e.createElementVNode("span",H2,"Duration "+e.toDisplayString(wu.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:!fu.value,onClick:Zs}," Next Cut ",8,X2)]),e.createElementVNode("div",G2,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["mobile-snap-toggle",{active:un.value}]),"data-testid":"btn-mobile-snap-toggle",onClick:js},e.toDisplayString(un.value?"Snap On":"Snap Off"),3),e.createElementVNode("div",J2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(mu,fe=>e.createElementVNode("button",{key:fe,type:"button",class:e.normalizeClass(["mobile-speed-chip",{active:e.unref(me)===fe}]),"data-testid":`btn-mobile-speed-${String(fe).replace(".","-")}`,onClick:He=>Nu(fe)},e.toDisplayString(fe)+"x ",11,Y2)),64))])]),e.createElementVNode("div",q2,[e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-undo","aria-label":"Undo",disabled:!e.unref(xt),onClick:Ii}," Undo ",8,K2),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-redo","aria-label":"Redo",disabled:!e.unref(zt),onClick:$i}," Redo ",8,Q2),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-split","aria-label":"Split at playhead",disabled:!Ci.value,onClick:io}," Split ",8,ek),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn","data-testid":"btn-mobile-duplicate","aria-label":"Duplicate selected clip",disabled:!Is.value,onClick:Ri}," Duplicate ",8,tk),e.createElementVNode("button",{type:"button",class:"mobile-edit-btn mobile-edit-btn--danger","data-testid":"btn-mobile-delete","aria-label":"Delete selected clip",disabled:!Si.value,onClick:Di}," Delete ",8,nk)])]),e.createElementVNode("div",{ref_key:"mobileControlsRef",ref:Ti,class:"controls-section mobile-controls"},null,512),to.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"mobile-action-sheet-backdrop","data-testid":"video-mobile-action-sheet",onClick:En},[e.createElementVNode("div",{class:"mobile-action-sheet",onClick:E[3]||(E[3]=e.withModifiers(()=>{},["stop"]))},[E[16]||(E[16]=e.createElementVNode("div",{class:"mobile-action-sheet-handle"},null,-1)),e.createElementVNode("div",ak,[e.createElementVNode("span",ok,e.toDisplayString(ku.value),1),e.createElementVNode("span",ik,e.toDisplayString(_u.value),1)]),e.createElementVNode("div",rk,[e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-undo",disabled:!e.unref(xt),onClick:Ii},"Undo",8,sk),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-redo",disabled:!e.unref(zt),onClick:$i},"Redo",8,lk),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-split",disabled:!Ci.value,onClick:io},"Split",8,ck),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-duplicate",disabled:!Is.value,onClick:Ri},"Duplicate",8,dk),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn mobile-action-sheet-btn--danger","data-testid":"btn-mobile-sheet-delete",disabled:!Si.value,onClick:Di},"Delete",8,uk),e.createElementVNode("button",{type:"button",class:"mobile-action-sheet-btn","data-testid":"btn-mobile-sheet-close",onClick:En},"Close")])])])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",mk,[e.createElementVNode("div",pk,[e.createElementVNode("div",fk,[e.createElementVNode("div",hk,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":E[4]||(E[4]=fe=>R.value=fe),"aria-label":"Fit mode","data-testid":"select-video-fit-mode"},[...E[17]||(E[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,R.value]])])]),e.withDirectives(e.createVNode(hr,{ref_key:"pixiPreviewDesktopRef",ref:g,"aria-hidden":!f.value,class:"preview-host-child",source:xi.value,"fallback-duration":Ut.value,filters:Bs.value,playhead:Fs.value,"is-playing":e.unref(re),"fit-mode":R.value,active:f.value,onPlayPause:e.unref(q),onFrameUpdate:Us,onDurationChange:oo},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,f.value]]),e.withDirectives(e.createVNode(Br,{"aria-hidden":!p.value,class:"preview-host-child","media-uuid":s.value,recipe:_.value,media:Ts.value,"enable-engine":p.value&&Ms.value,"fit-mode":R.value,onTimeUpdate:Ls,onPlayStateChange:Os,onDurationChange:oo,onEngineReady:Js},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,p.value]]),y.showThumbnailPicker?(e.openBlock(),e.createBlock(uy,{key:0,"media-uuid":s.value,duration:Ut.value,onSelect:Gu},null,8,["media-uuid","duration"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",vk,[e.createElementVNode("div",gk,[e.createElementVNode("div",yk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.value,fe=>(e.openBlock(),e.createElementBlock("button",{key:fe.id,class:e.normalizeClass(["tab-btn",{active:d.value===fe.id}]),onClick:He=>d.value=fe.id},e.toDisplayString(fe.label),11,bk))),128))]),e.createElementVNode("div",wk,[e.withDirectives(e.createElementVNode("div",kk,[e.createVNode(Ir,{filters:Y.value,"active-filters":Ei.value,"thumbnail-url":uu.value,onApplyFilter:kn,onRemoveFilter:_i,onUpdateParam:As,onPreviewFilter:$u},null,8,["filters","active-filters","thumbnail-url"])],512),[[e.vShow,d.value==="filters"]]),e.withDirectives(e.createElementVNode("div",_k,[e.createVNode(Dr,{overlays:D.value,onAddOverlay:Du,onUpdateOverlay:Au,onRemoveOverlay:Lu},null,8,["overlays"])],512),[[e.vShow,d.value==="text"]]),e.withDirectives(e.createElementVNode("div",Ek,[e.createVNode(Ar,{"selected-clips":O.value,"applied-transitions":I.value,onApplyTransition:Uu,onRemoveTransition:Ou,onPreviewTransition:Pu},null,8,["selected-clips","applied-transitions"])],512),[[e.vShow,d.value==="transitions"]]),e.withDirectives(e.createElementVNode("div",xk,[e.createVNode(Lr,{"audio-layers":j.value,"master-volume":F.value,onAddTrack:zu,onUpdateTrack:ju,onRemoveTrack:Wu,onUpdateVolume:Zu,onToggleMute:Hu,onUpdateMasterVolume:Xu},null,8,["audio-layers","master-volume"])],512),[[e.vShow,d.value==="audio"]]),e.withDirectives(e.createElementVNode("div",Ck,[e.unref(Qa)?(e.openBlock(),e.createBlock($r,{key:0,filter:e.unref(Qa),"current-frame":e.unref(ie),onUpdateParams:Ru},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",Sk,[...E[18]||(E[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",Vk,[e.createVNode(Rr,{"can-export":e.unref(ne),"is-exporting":Be.value,"export-progress":$e.value,onExport:Ks,onCancelExport:qs,onSaveDraft:ji,onReset:ol},null,8,["can-export","is-exporting","export-progress"]),Ge.value?(e.openBlock(),e.createElementBlock("div",Nk," Export complete ")):e.createCommentVNode("",!0),qe.value&&!Ge.value?(e.openBlock(),e.createElementBlock("div",Tk,e.toDisplayString(qe.value),1)):e.createCommentVNode("",!0)],512),[[e.vShow,d.value==="export"]])])])])]),e.createElementVNode("div",Mk,[e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:Hn,class:"timeline-container"},[e.createElementVNode("div",Bk,[e.createElementVNode("label",null,[E[19]||(E[19]=e.createTextVNode(" Zoom ",-1)),e.createElementVNode("input",{type:"range",min:"10",max:"600",value:e.unref(de),onInput:E[5]||(E[5]=fe=>Iu(fe))},null,40,Fk)]),e.createElementVNode("span",Ik,e.toDisplayString(Math.round(e.unref(de)))+" px/s",1),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["desktop-snap-toggle",{active:un.value}]),"data-testid":"btn-desktop-snap-toggle",onClick:js},e.toDisplayString(un.value?"Snap On":"Snap Off"),3)]),e.createVNode(Fr,{playhead:e.unref(N),clips:e.unref(L),"selected-clip-id":((ge=e.unref(he))==null?void 0:ge.id)??((ue=e.unref(L)[0])==null?void 0:ue.id)??null,duration:Ut.value,fps:e.unref(Ve),"zoom-level":e.unref(de),"snap-enabled":un.value,sensitivity:.25,"onUpdate:playhead":e.unref(J),onTrim:e.unref(ce),onSplit:Hs,onClipSelect:Fi,onClipMove:e.unref(ot),onClipLongPress:Ps,onSnapStateChange:zs},null,8,["playhead","clips","selected-clip-id","duration","fps","zoom-level","snap-enabled","onUpdate:playhead","onTrim","onClipMove"]),e.createVNode(id,{"selected-clip":e.unref(he),"can-split":Ci.value,"can-delete":Si.value,"is-playing":e.unref(re),"zoom-level":e.unref(de),"playback-speed":e.unref(me),onSplit:io,onDelete:Di,onDuplicate:Ri,onZoomIn:Bu,onZoomOut:Fu,onZoomChange:Ai,onFitToWindow:Mu,onPlayPause:e.unref(q),onFrameForward:e.unref(ae),onFrameBackward:e.unref(se),onSkipToStart:e.unref(Ce),onSkipToEnd:e.unref(Ae),onSpeedChange:e.unref(De)},null,8,["selected-clip","can-split","can-delete","is-playing","zoom-level","playback-speed","onPlayPause","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"]),ye.value?(e.openBlock(),e.createElementBlock("div",$k,[e.createElementVNode("div",Rk,[e.createElementVNode("label",Dk,[E[20]||(E[20]=e.createElementVNode("span",null,"Trim start (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":E[6]||(E[6]=fe=>ee.value=fe),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-start"},null,512),[[e.vModelText,ee.value]])]),e.createElementVNode("label",Ak,[E[21]||(E[21]=e.createElementVNode("span",null,"Trim end (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":E[7]||(E[7]=fe=>be.value=fe),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-end"},null,512),[[e.vModelText,be.value]])]),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-start-playhead",disabled:!e.unref(he),onClick:E[8]||(E[8]=fe=>Ds("start"))}," Start = Playhead ",8,Lk),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-end-playhead",disabled:!e.unref(he),onClick:E[9]||(E[9]=fe=>Ds("end"))}," End = Playhead ",8,Uk),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-trim",disabled:!e.unref(he),onClick:xu}," Apply Trim ",8,Ok)]),e.createElementVNode("div",Pk,[e.createElementVNode("label",zk,[E[22]||(E[22]=e.createElementVNode("span",null,"Quick filter",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":E[10]||(E[10]=fe=>Me.value=fe),"data-testid":"video-dev-filter-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Y.value,fe=>(e.openBlock(),e.createElementBlock("option",{key:fe.id,value:fe.id},e.toDisplayString(fe.name),9,jk))),128))],512),[[e.vModelSelect,Me.value]])]),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-filter",disabled:!e.unref(he)||Me.value==="",onClick:Cu}," Apply Filter ",8,Wk),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-clear-filters",disabled:e.unref(Qe).length===0,onClick:Su}," Clear Filters ",8,Zk),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(he),onClick:E[11]||(E[11]=fe=>kn("noise"))}," QA: Noise ",8,Hk),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(he),onClick:E[12]||(E[12]=fe=>kn("grayscale"))}," QA: Grayscale ",8,Xk)])])):e.createCommentVNode("",!0)],512)])]))],2)}}}),Ad=Te(Gk,[["__scopeId","data-v-abddf14f"]]),Jk={key:0,class:"video-editor-v2-toolbar"},Yk={class:"video-editor-v2-body"},qk={class:"video-editor-v2-main"},Kk={class:"video-editor-v2-canvas"},Qk={key:0,class:"video-editor-v2-timeline"},e_={class:"video-editor-v2-side","data-testid":"v2-side-panel"},t_="(max-width: 900px)",n_=e.defineComponent({__name:"SplitPanelLayout",setup(o,{expose:n}){const t=e.ref(!1);let a=null,i=null;const r=s=>{t.value=s};return e.onMounted(()=>{typeof window>"u"||!window.matchMedia||(a=window.matchMedia(t_),r(a.matches),i=s=>r(s.matches),a.addEventListener?a.addEventListener("change",i):"addListener"in a&&a.addListener(i))}),e.onBeforeUnmount(()=>{!a||!i||(a.removeEventListener?a.removeEventListener("change",i):"removeListener"in a&&a.removeListener(i),a=null,i=null)}),n({isMobile:t}),(s,l)=>(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"},[s.$slots.toolbar?(e.openBlock(),e.createElementBlock("div",Jk,[e.renderSlot(s.$slots,"toolbar",{},void 0,!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",Yk,[e.createElementVNode("div",qk,[e.createElementVNode("div",Kk,[e.renderSlot(s.$slots,"canvas",{},void 0,!0)]),s.$slots.timeline?(e.openBlock(),e.createElementBlock("div",Qk,[e.renderSlot(s.$slots,"timeline",{},void 0,!0)])):e.createCommentVNode("",!0)]),e.withDirectives(e.createElementVNode("aside",e_,[e.renderSlot(s.$slots,"inspector",{},void 0,!0)],512),[[e.vShow,!t.value]])]),t.value?e.renderSlot(s.$slots,"drawer",{key:1},void 0,!0):e.createCommentVNode("",!0)],2))}}),a_=Te(n_,[["__scopeId","data-v-a0d79157"]]),o_={class:"inspector-tabs",role:"tablist","aria-label":"Editor tools"},i_=["aria-selected","data-testid","onClick"],r_=["aria-labelledby"],s_={class:"inspector-placeholder","data-testid":"v2-inspector-placeholder"},l_=e.defineComponent({__name:"InspectorPanel",props:{activeTab:{},tabs:{},compact:{type:Boolean,default:!1}},emits:["update:activeTab"],setup(o,{emit:n}){const t=o,a=n,i=e.computed(()=>t.tabs.filter(s=>s.enabled)),r=s=>{s!==t.activeTab&&a("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",o_,[(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,i_))),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",s_,[e.createElementVNode("p",null,e.toDisplayString(s.activeTab)+" controls — coming soon",1)])],!0)],8,r_)],2))}}),Jl=Te(l_,[["__scopeId","data-v-7f5b0e50"]]),c_=["aria-label","data-snap"],d_=["aria-expanded"],u_={class:"drawer-header"},m_={class:"drawer-body"},p_=e.defineComponent({__name:"VideoBottomDrawer",props:{initialSnap:{default:"half"},ariaLabel:{default:"Editor controls drawer"},containerHeight:{default:0}},emits:["snap-change"],setup(o,{expose:n,emit:t}){const a=["collapsed","half","full"],i=o,r=t,s=e.ref(null),l=e.ref(null),c=e.ref(i.initialSnap);let d=!1,u=!1,m=null,f=0,p=0,v=0;const g=C=>{const P=v||(typeof window<"u"?window.innerHeight:600);switch(C){case"collapsed":return 80;case"half":return Math.round(P*.45);case"full":return Math.round(P*.85)}},k=(C,{animate:P=!0}={})=>{var I;if(!s.value)return;const S=c.value;c.value=C;const D=typeof window<"u"&&((I=window.matchMedia)==null?void 0:I.call(window,"(prefers-reduced-motion: reduce)").matches);s.value.style.transition=P&&!D?"height 0.25s cubic-bezier(0.33, 1, 0.68, 1)":"none",s.value.style.height=`${g(C)}px`,C!==S&&r("snap-change",C,S)},T=C=>{let P=a[0],S=1/0;for(const D of a){const I=Math.abs(g(D)-C);I<S&&(S=I,P=D)}return P},V=()=>{const C=a.indexOf(c.value);k(a[(C+1)%a.length])},b=C=>{if(u){u=!1,C.preventDefault();return}V()},h=C=>{var P,S,D;if(C.button===0){d=!0,u=!1,m=C.pointerId,f=C.clientY,p=((P=s.value)==null?void 0:P.offsetHeight)??0;try{(D=(S=l.value)==null?void 0:S.setPointerCapture)==null||D.call(S,C.pointerId)}catch{}s.value&&(s.value.style.transition="none")}},_=C=>{if(!d||C.pointerId!==m)return;const P=C.clientY-f,S=p-P,D=g("collapsed"),I=g("full"),j=Math.max(D,Math.min(I,S));s.value&&(s.value.style.height=`${j}px`),Math.abs(P)>4&&(u=!0),C.preventDefault()},R=C=>{var S,D,I;if(!d)return;d=!1;try{(D=(S=l.value)==null?void 0:S.releasePointerCapture)==null||D.call(S,C.pointerId)}catch{}m=null;const P=((I=s.value)==null?void 0:I.offsetHeight)??0;k(T(P))},M=(C,P={})=>{a.includes(C)&&k(C,{animate:P.animate!==!1})},x=C=>{v=Math.max(0,Number(C)||0),k(c.value,{animate:!1})};return e.watch(()=>i.containerHeight,C=>{C>0&&x(C)}),e.onMounted(()=>{i.containerHeight>0&&(v=i.containerHeight),k(c.value,{animate:!1})}),e.onBeforeUnmount(()=>{d=!1,m=null}),n({snapTo:M,updateContainerHeight:x,snap:c}),(C,P)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootEl",ref:s,class:"video-editor-v2-drawer",role:"dialog","aria-label":C.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:b,onPointerdown:h,onPointermove:_,onPointerup:R,onPointercancel:R},[...P[0]||(P[0]=[e.createElementVNode("span",{class:"drawer-handle-grip","aria-hidden":"true"},null,-1)])],40,d_),e.createElementVNode("div",u_,[e.renderSlot(C.$slots,"header",{},void 0,!0)]),e.createElementVNode("div",m_,[e.renderSlot(C.$slots,"default",{},void 0,!0)])],8,c_))}}),f_=Te(p_,[["__scopeId","data-v-4ebedbf7"]]),h_={class:"v2-toolbar-group"},v_=["aria-label"],g_=["disabled"],y_={class:"v2-toolbar-group"},b_={class:"v2-toolbar-fit"},w_=["disabled"],k_=["disabled"],__={class:"v2-preview-host"},E_={class:"v2-timeline"},x_={class:"v2-timeline-topbar"},C_={class:"v2-timeline-zoom"},S_=["value"],V_={class:"v2-timeline-zoom-readout"},N_=["aria-pressed"],T_={key:1,class:"v2-empty-state"},M_={key:0,"data-testid":"v2-export-status-completed",class:"v2-export-status"},B_={key:1,class:"v2-export-status","data-testid":"v2-export-status-message"},F_={key:1,class:"v2-empty-state"},I_={key:0,class:"v2-export-status"},$_={key:1,class:"v2-export-status"},R_=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(o,{expose:n,emit:t}){const a=o,i=t,r=e.computed(()=>{var be;const Y=typeof a.mediaUuid=="string"?a.mediaUuid.trim():"";if(Y!=="")return Y;const ee=(be=a.media)==null?void 0:be.uuid;return typeof ee=="string"&&ee.trim()!==""?ee.trim():`temp-${Date.now()}`}),s=rd(r.value,a.initialRecipe,a.media),l=cd(),c=e.ref("filters"),d=e.computed(()=>a.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}),u=e.computed(()=>{const Y=a.featureFlags??{},ee=["filters","adjustments","text","transitions","audio","export"],be={filters:"Filters",adjustments:"Adjust",text:"Text",transitions:"Transitions",audio:"Audio",export:"Export"};return ee.map(Me=>({id:Me,label:be[Me],enabled:typeof Y[Me]=="boolean"?Y[Me]:d.value[Me]}))}),m=e.ref(!1),f=e.computed(()=>c.value),p=e.computed(()=>f.value==="filters"||m.value),v=e.computed(()=>f.value!=="filters"&&!m.value),g=["contain","cover","none"],k=Y=>typeof Y=="string"&&g.includes(Y),T=Y=>{const ee=Y==null?void 0:Y.editor;return k(ee==null?void 0:ee.fitMode)?ee.fitMode:null},V=e.ref(T(a.initialRecipe)??"contain"),b=e.ref("");e.watch(()=>{var Y,ee;return{file:(Y=a.media)==null?void 0:Y.file,url:(ee=a.media)==null?void 0:ee.url}},(Y,ee,be)=>{var Be,$e;const Me=b.value;be(()=>{Me&&Me.startsWith("blob:")&&URL.revokeObjectURL(Me)}),(Be=a.media)!=null&&Be.file?b.value=URL.createObjectURL(a.media.file):($e=a.media)!=null&&$e.url?b.value=a.media.url:b.value=""},{immediate:!0});const h=e.computed(()=>b.value),_=e.computed(()=>l.activeFilters.value),R=e.computed(()=>s.playheadPosition.value),M=e.computed(()=>{if(!a.media)return null;const{file:Y,...ee}=a.media;return{...ee,url:b.value}}),x=e.computed(()=>{var ee;const Y=(ee=a.media)==null?void 0:ee.url;return!!(Y&&/^https?:/i.test(Y))}),C=e.ref(0),P=e.computed(()=>{var ee;if(s.totalDuration.value>0)return s.totalDuration.value;if(C.value>0)return C.value;const Y=Number((ee=a.media)==null?void 0:ee.duration);return Number.isFinite(Y)&&Y>0?Y:0}),S=Y=>{!Number.isFinite(Y)||Y<=0||(C.value=Y,s.updateSourceDuration(Y))},D=Y=>{Y&&typeof Y.time=="number"&&Number.isFinite(Y.time)&&s.seekTo(Y.time)},I=Y=>{Number.isFinite(Y)&&s.seekTo(Y)},j=Y=>{s.setPlaying(Y)},O=e.computed(()=>l.videoCompatibleFilters.value.map(ee=>{var Me;const be=[];if(ee.controls&&ee.controls.length>0)for(const Be of ee.controls){const $e=Be.type;if($e==="button"||$e==="text"||$e==="range")continue;const Ge={id:Be.property||Be.id,label:Be.label||Be.id,type:$e,default:Be.default??($e==="toggle"?!1:$e==="color"?"#ffffff":0)};$e==="slider"&&(Ge.min=Be.min??0,Ge.max=Be.max??1,Ge.step=Be.step??.01),$e==="select"&&Be.options&&(Ge.options=Be.options),be.push(Ge)}else if(ee.paramRanges){const Be=Object.entries(ee.paramRanges);for(const[$e,Ge]of Be){const qe=$e.replace(/[-_]/g," ").replace(/\b\w/g,Tt=>Tt.toUpperCase()),Nt=(Me=ee.defaultParams)==null?void 0:Me[$e],Zn=(Ge.min+Ge.max)/2;be.push({id:$e,label:qe,min:Ge.min,max:Ge.max,step:Ge.step??.01,default:typeof Nt=="number"?Nt:Zn})}}return{id:ee.id,name:ee.name,category:ee.category,params:be}})),F=e.computed(()=>{const Y=new Map;return l.activeFilters.value.forEach(ee=>Y.set(ee.filterId,ee)),Y}),B=e.computed(()=>{if(s.currentFrame.value)return s.currentFrame.value;const Y=a.media;return(Y==null?void 0:Y.thumbnail_url)??(Y==null?void 0:Y.url)}),w=e.shallowRef(null),$=e.ref(null),z=e.ref(null),W=e.ref(null),Q=e.ref(null),ye=e.ref(!1),we=new Map,ie=e.ref([]),N=e.ref([]),L=e.ref([]),te=e.ref(1),ne=e.ref([]),re=Y=>{w.value=Y,Y!=null&&Y.composition&&(z.value=new dd(Y.composition),W.value=new La(Y.composition),Q.value=new ud(Y.composition));try{we.size&&w.value&&(we.forEach((ee,be)=>{w.value.setClipFilters(be,ee)}),we.clear(),w.value.composition.computeFrame())}catch{}},he=Y=>{w.value?w.value.setClipFilters(Y,l.activeFilters.value):we.set(Y,[...l.activeFilters.value])},de=Y=>{var be,Me;const ee=((be=s.selectedClip.value)==null?void 0:be.id)??((Me=s.timelineClips.value[0])==null?void 0:Me.id);ee&&(ye.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),he(ee),s.handleClipSelect(ee),ye.value=!1,G())},me=Y=>{var Me,Be;const ee=l.activeFilters.value.find($e=>$e.filterId===Y);ee&&l.removeFilter(ee.id),s.setFilters(l.activeFilters.value);const be=((Me=s.selectedClip.value)==null?void 0:Me.id)??((Be=s.timelineClips.value[0])==null?void 0:Be.id);be&&he(be),G()},Ve=(Y,ee,be)=>{var $e,Ge;const Me=l.activeFilters.value.find(qe=>qe.filterId===Y);if(Me){Me.params={...Me.params??{},[ee]:be},s.setFilters(l.activeFilters.value);const qe=(($e=s.selectedClip.value)==null?void 0:$e.id)??((Ge=s.timelineClips.value[0])==null?void 0:Ge.id);qe&&he(qe),G();return}const Be=l.previewFilter.value;Be&&Be.filterId===Y&&(Be.params={...Be.params??{},[ee]:be})},ce=Y=>{Y&&typeof Y.id=="string"&&Y.id!==""&&l.previewFilterEffect(Y.id)},pe=Y=>{l.updateFilterParams(Y),s.setFilters(l.activeFilters.value),G()},xe=async Y=>{if(!z.value)return;const ee=await z.value.addTextOverlay(Y);ie.value.push({id:ee,...Y})},Fe=async(Y,ee)=>{if(!z.value)return;await z.value.updateTextOverlay(Y,ee);const be=ie.value.findIndex(Me=>Me.id===Y);be!==-1&&(ie.value[be]={...ie.value[be],...ee})},ut=async Y=>{z.value&&(await z.value.removeTextOverlay(Y),ie.value=ie.value.filter(ee=>ee.id!==Y))},tt=async Y=>{if(!W.value||ne.value.length<2)return;const[ee,be]=ne.value,Me=await W.value.applyTransition(ee,be,Y);N.value.push({id:Me,...Y,name:Y.type})},Et=Y=>{if(!W.value)return;const ee=N.value[Y];ee&&(W.value.removeTransition(ee.id),N.value.splice(Y,1))},ot=Y=>{},at=async Y=>{if(!Q.value)return;const ee=await Q.value.addAudioTrack(Y);L.value.push({id:ee,...Y})},bt=async(Y,ee)=>{if(!Q.value)return;const be=L.value.findIndex(Me=>Me.id===Y);be!==-1&&(L.value[be]={...L.value[be],...ee})},Vt=async Y=>{Q.value&&(await Q.value.removeAudioTrack(Y),L.value=L.value.filter(ee=>ee.id!==Y))},vt=async(Y,ee)=>{if(!Q.value)return;await Q.value.updateVolume(Y,ee);const be=L.value.find(Me=>Me.id===Y);be&&(be.volume=ee)},st=async(Y,ee)=>{if(!Q.value)return;await Q.value.muteTrack(Y,ee);const be=L.value.find(Me=>Me.id===Y);be&&(be.muted=ee)},ve=Y=>{Q.value&&(Q.value.setMasterVolume(Y),te.value=Y)},Ee=Y=>{var ee;return Y.metadata||(Y.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),Y.metadata.fit_mode=V.value,(ee=a.media)!=null&&ee.url&&/^https?:/i.test(a.media.url)?Y.metadata.source_url=a.media.url:delete Y.metadata.source_url,Y},Ne=()=>{$.value=Ee(s.generateRecipe())};let je=null;const G=()=>{je&&clearTimeout(je),je=setTimeout(()=>{Ne(),je=null},200)};e.watch(()=>s.timelineClips.value,G,{deep:!0}),e.watch(()=>s.selectedClip.value,Y=>{if(ye.value||!Y)return;const ee=(Y==null?void 0:Y.filters)??[];l.setActiveFilters(ee)},{immediate:!0}),e.watch(()=>l.activeFilters.value,Y=>{s.setFilters(Y),G()},{deep:!0}),e.watch(()=>ie.value,Y=>{s.setTextOverlays(Y),G()},{deep:!0}),e.watch(()=>L.value,Y=>{const ee=Y.map(be=>({...be,source:typeof be.source=="string"?be.source:void 0}));s.setAudioTracks(ee),G()},{deep:!0}),e.watch(()=>s.playheadPosition.value,G),Ne();const q=e.ref(!0),A=e.computed(()=>!!s.selectedClip.value&&s.playheadPosition.value>0),J=e.computed(()=>!!s.selectedClip.value&&s.timelineClips.value.length>1),ae=Y=>{q.value=Y},se=()=>{q.value=!q.value},Ce=Y=>{const ee=Y.target;if(!ee)return;const be=Number(ee.value);Number.isFinite(be)&&s.setZoomLevel(be)},Ae=e.ref(!1),De=e.ref(0),Le=e.ref(!1),Ue=e.ref(null),Ke=e.ref(null);let xt=null,zt=!1;const ma=()=>new gi(a.serverRenderEndpoint??"/api/v1"),Qe=()=>{xt!==null&&(clearInterval(xt),xt=null)},Qa=Y=>{Qe();const ee=ma();xt=setInterval(async()=>{if(zt){Qe();return}try{const be=await ee.getJob(Y),Me=Number(be.progress??0);if(De.value=Number.isFinite(Me)?Me:0,i("server-render-progress",De.value),be.status==="completed"||be.status==="failed"||be.status==="cancelled")if(Qe(),Ae.value=!1,Ke.value=null,be.status==="completed"){De.value=100,Le.value=!0,Ue.value=null;const Be=typeof be.output_media_id=="string"?be.output_media_id:void 0,$e={id:Y};Be!==void 0&&($e.output_media_id=Be),i("server-render-completed",$e)}else{const Be=be.status==="cancelled"||typeof be.error_message=="string"&&/cancel/i.test(be.error_message),$e=Be?"Export canceled.":typeof be.error_message=="string"&&be.error_message.trim()!==""?be.error_message:"Export failed";Ue.value=$e,Be||i("server-render-failed",$e)}}catch(be){Qe(),Ae.value=!1,Ke.value=null;const Me=be instanceof Error?be.message:"Failed to check export progress";Ue.value=Me,i("server-render-failed",Me)}},2e3)},wn=Y=>{const ee=new Blob([JSON.stringify(Y,null,2)],{type:"application/json"}),be=URL.createObjectURL(ee),Me=document.createElement("a");Me.href=be,Me.download=`video-recipe-${Date.now()}.json`,Me.click(),setTimeout(()=>URL.revokeObjectURL(be),100)},jn=async Y=>{Qe(),zt=!1,Ke.value=null,Ue.value=null,Le.value=!1,Ae.value=!0,De.value=0;try{const ee=Ee(s.generateRecipe());i("recipe-generated",ee);const be=!!a.serverRenderEndpoint,Me=r.value.startsWith("temp-");if(!be||Me){wn(ee),Ae.value=!1,De.value=100,Le.value=!0,Ue.value=Me?"Local media — downloaded recipe.json. Switch to V1 for PIXI-based client export.":"No server render endpoint configured — downloaded recipe.json.";return}const $e=await ma().createJob({source_media_id:r.value,recipe:ee}),Ge=typeof $e.id=="string"?$e.id:null;if(!Ge)throw new Error("Export failed: missing job id");Ke.value=Ge,i("export-started",Ge),i("server-render-started",Ge),Qa(Ge)}catch(ee){const be=Ee(s.generateRecipe());wn(be);const Me=ee instanceof Error?ee.message:"Export failed";Ae.value=!1,De.value=0,Ke.value=null,Ue.value=Me,i("server-render-failed",Me)}},pa=async()=>{zt=!0;const Y=Ke.value;if(Qe(),Ae.value=!1,De.value=0,Ue.value="Export canceled.",Ke.value=null,Y&&a.serverRenderEndpoint)try{await ma().cancelJob(Y)}catch{}},fa=()=>{s.togglePlayback()},ha=()=>{s.resetChanges()},Wn=()=>{const Y=s.saveDraft();i("draft-saved",Y)},ki=()=>{jn()},kn=()=>{i("close")};return n({saveDraft:async()=>{const Y=s.saveDraft();return i("draft-saved",Y),Y},exportForUpload:async Y=>null}),e.onMounted(()=>{document.documentElement.setAttribute("data-video-editor-version","v2")}),e.onBeforeUnmount(()=>{document.documentElement.getAttribute("data-video-editor-version")==="v2"&&document.documentElement.removeAttribute("data-video-editor-version")}),e.onUnmounted(()=>{Qe(),zt=!0,je&&(clearTimeout(je),je=null),w.value&&(w.value.destroy(),w.value=null),z.value=null,W.value=null,Q.value=null}),(Y,ee)=>(e.openBlock(),e.createBlock(a_,{"data-testid":"video-editor-v2"},{toolbar:e.withCtx(()=>[e.createElementVNode("div",h_,[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:fa},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(s).isPlaying.value?e.unref(Jr):e.unref(Yr),"aria-hidden":"true"},null,8,["icon"])],10,v_),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:ha},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Un),"aria-hidden":"true"},null,8,["icon"])],8,g_)]),ee[11]||(ee[11]=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",y_,[e.createElementVNode("label",b_,[ee[9]||(ee[9]=e.createElementVNode("span",{class:"sr-only"},"Fit mode",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":ee[0]||(ee[0]=be=>V.value=be),"aria-label":"Fit mode","data-testid":"v2-select-fit-mode"},[...ee[8]||(ee[8]=[e.createElementVNode("option",{value:"contain"},"Contain",-1),e.createElementVNode("option",{value:"cover"},"Cover",-1),e.createElementVNode("option",{value:"none"},"None",-1)])],512),[[e.vModelSelect,V.value]])]),e.createElementVNode("button",{type:"button",class:"v2-toolbar-btn","data-testid":"v2-btn-save","aria-label":"Save draft",disabled:!e.unref(s).hasChanges.value,onClick:Wn},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Go),"aria-hidden":"true"},null,8,["icon"]),ee[10]||(ee[10]=e.createElementVNode("span",{class:"v2-toolbar-btn-label"},"Save",-1))],8,w_),e.createElementVNode("button",{type:"button",class:"v2-toolbar-btn","data-testid":"v2-btn-export","aria-label":"Export",disabled:Ae.value,onClick:ki},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(na),"aria-hidden":"true"},null,8,["icon"])],8,k_),e.createElementVNode("button",{type:"button",class:"v2-toolbar-btn","data-testid":"v2-btn-close","aria-label":"Close editor",onClick:kn},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Rn),"aria-hidden":"true"},null,8,["icon"])])])]),canvas:e.withCtx(()=>[e.createElementVNode("div",__,[e.withDirectives(e.createVNode(hr,{class:"v2-preview-child","aria-hidden":!p.value,source:h.value,"fallback-duration":P.value,filters:_.value,playhead:R.value,"is-playing":e.unref(s).isPlaying.value,"fit-mode":V.value,active:p.value,onPlayPause:fa,onFrameUpdate:D,onDurationChange:S},null,8,["aria-hidden","source","fallback-duration","filters","playhead","is-playing","fit-mode","active"]),[[e.vShow,p.value]]),e.withDirectives(e.createVNode(Br,{class:"v2-preview-child","aria-hidden":!v.value,"media-uuid":r.value,recipe:$.value,media:M.value,"enable-engine":v.value&&x.value,"fit-mode":V.value,onTimeUpdate:I,onPlayStateChange:j,onDurationChange:S,onEngineReady:re},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,v.value]])])]),timeline:e.withCtx(()=>{var be,Me;return[e.createElementVNode("div",E_,[e.createElementVNode("div",x_,[e.createElementVNode("label",C_,[ee[12]||(ee[12]=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:Ce},null,40,S_),e.createElementVNode("span",V_,e.toDisplayString(Math.round(e.unref(s).zoomLevel.value))+" px/s",1)]),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["v2-toolbar-btn v2-toolbar-btn--ghost",{"is-active":q.value}]),"data-testid":"v2-btn-snap-toggle","aria-pressed":q.value?"true":"false",onClick:se},e.toDisplayString(q.value?"Snap On":"Snap Off"),11,N_)]),e.createVNode(Fr,{playhead:e.unref(s).playheadPosition.value,clips:e.unref(s).timelineClips.value,"selected-clip-id":((be=e.unref(s).selectedClip.value)==null?void 0:be.id)??((Me=e.unref(s).timelineClips.value[0])==null?void 0:Me.id)??null,duration:P.value,fps:e.unref(s).fps.value,"zoom-level":e.unref(s).zoomLevel.value,"snap-enabled":q.value,sensitivity:.25,"onUpdate:playhead":ee[1]||(ee[1]=Be=>e.unref(s).seekTo(Be)),onTrim:ee[2]||(ee[2]=(Be,$e,Ge)=>e.unref(s).handleTrim(Be,$e,Ge)),onSplit:ee[3]||(ee[3]=Be=>e.unref(s).handleSplit(Be)),onClipSelect:ee[4]||(ee[4]=Be=>e.unref(s).handleClipSelect(Be)),onClipMove:ee[5]||(ee[5]=(Be,$e)=>e.unref(s).moveClip(Be,$e)),onSnapStateChange:ae},null,8,["playhead","clips","selected-clip-id","duration","fps","zoom-level","snap-enabled"]),e.createVNode(id,{"selected-clip":e.unref(s).selectedClip.value,"can-split":A.value,"can-delete":J.value,"is-playing":e.unref(s).isPlaying.value,"zoom-level":e.unref(s).zoomLevel.value,"playback-speed":e.unref(s).playbackSpeed.value,onSplit:e.unref(s).splitAtPlayhead,onDelete:e.unref(s).deleteSelectedClip,onDuplicate:e.unref(s).duplicateSelectedClip,onZoomIn:e.unref(s).zoomIn,onZoomOut:e.unref(s).zoomOut,onZoomChange:e.unref(s).setZoomLevel,onFitToWindow:e.unref(s).fitToWindow,onPlayPause:fa,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","is-playing","zoom-level","playback-speed","onSplit","onDelete","onDuplicate","onZoomIn","onZoomOut","onZoomChange","onFitToWindow","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"])])]}),inspector:e.withCtx(()=>[e.createVNode(Jl,{"active-tab":c.value,"onUpdate:activeTab":ee[6]||(ee[6]=be=>c.value=be),tabs:u.value},{filters:e.withCtx(()=>[e.createVNode(Ir,{filters:O.value,"active-filters":F.value,"thumbnail-url":B.value,onApplyFilter:de,onRemoveFilter:me,onUpdateParam:Ve,onPreviewFilter:ce},null,8,["filters","active-filters","thumbnail-url"])]),adjustments:e.withCtx(()=>[e.unref(l).selectedFilter.value?(e.openBlock(),e.createBlock($r,{key:0,filter:e.unref(l).selectedFilter.value,"current-frame":e.unref(s).currentFrame.value,onUpdateParams:pe},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",T_,[...ee[13]||(ee[13]=[e.createElementVNode("p",null,"Select a filter from the Filters tab to adjust its parameters.",-1)])]))]),text:e.withCtx(()=>[e.createVNode(Dr,{overlays:ie.value,onAddOverlay:xe,onUpdateOverlay:Fe,onRemoveOverlay:ut},null,8,["overlays"])]),transitions:e.withCtx(()=>[e.createVNode(Ar,{"selected-clips":ne.value,"applied-transitions":N.value,onApplyTransition:tt,onRemoveTransition:Et,onPreviewTransition:ot},null,8,["selected-clips","applied-transitions"])]),audio:e.withCtx(()=>[e.createVNode(Lr,{"audio-layers":L.value,"master-volume":te.value,onAddTrack:at,onUpdateTrack:bt,onRemoveTrack:Vt,onUpdateVolume:vt,onToggleMute:st,onUpdateMasterVolume:ve},null,8,["audio-layers","master-volume"])]),export:e.withCtx(()=>[e.createVNode(Rr,{"can-export":e.unref(s).hasChanges.value,"is-exporting":Ae.value,"export-progress":De.value,onExport:jn,onCancelExport:pa,onSaveDraft:Wn,onReset:ha},null,8,["can-export","is-exporting","export-progress"]),Le.value?(e.openBlock(),e.createElementBlock("div",M_," Export complete ")):e.createCommentVNode("",!0),Ue.value&&!Le.value?(e.openBlock(),e.createElementBlock("div",B_,e.toDisplayString(Ue.value),1)):e.createCommentVNode("",!0)]),_:1},8,["active-tab","tabs"])]),drawer:e.withCtx(()=>[e.createVNode(f_,{"initial-snap":"half","aria-label":"Video editor controls"},{default:e.withCtx(()=>[e.createVNode(Jl,{"active-tab":c.value,"onUpdate:activeTab":ee[7]||(ee[7]=be=>c.value=be),tabs:u.value,compact:""},{filters:e.withCtx(()=>[e.createVNode(Ir,{filters:O.value,"active-filters":F.value,"thumbnail-url":B.value,onApplyFilter:de,onRemoveFilter:me,onUpdateParam:Ve,onPreviewFilter:ce},null,8,["filters","active-filters","thumbnail-url"])]),adjustments:e.withCtx(()=>[e.unref(l).selectedFilter.value?(e.openBlock(),e.createBlock($r,{key:0,filter:e.unref(l).selectedFilter.value,"current-frame":e.unref(s).currentFrame.value,onUpdateParams:pe},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",F_,[...ee[14]||(ee[14]=[e.createElementVNode("p",null,"Select a filter from the Filters tab to adjust its parameters.",-1)])]))]),text:e.withCtx(()=>[e.createVNode(Dr,{overlays:ie.value,onAddOverlay:xe,onUpdateOverlay:Fe,onRemoveOverlay:ut},null,8,["overlays"])]),transitions:e.withCtx(()=>[e.createVNode(Ar,{"selected-clips":ne.value,"applied-transitions":N.value,onApplyTransition:tt,onRemoveTransition:Et,onPreviewTransition:ot},null,8,["selected-clips","applied-transitions"])]),audio:e.withCtx(()=>[e.createVNode(Lr,{"audio-layers":L.value,"master-volume":te.value,onAddTrack:at,onUpdateTrack:bt,onRemoveTrack:Vt,onUpdateVolume:vt,onToggleMute:st,onUpdateMasterVolume:ve},null,8,["audio-layers","master-volume"])]),export:e.withCtx(()=>[e.createVNode(Rr,{"can-export":e.unref(s).hasChanges.value,"is-exporting":Ae.value,"export-progress":De.value,onExport:jn,onCancelExport:pa,onSaveDraft:Wn,onReset:ha},null,8,["can-export","is-exporting","export-progress"]),Le.value?(e.openBlock(),e.createElementBlock("div",I_,"Export complete")):e.createCommentVNode("",!0),Ue.value&&!Le.value?(e.openBlock(),e.createElementBlock("div",$_,e.toDisplayString(Ue.value),1)):e.createCommentVNode("",!0)]),_:1},8,["active-tab","tabs"])]),_:1})]),_:1}))}}),D_=Te(R_,[["__scopeId","data-v-19512812"]]),Zt=o=>o===null||typeof o!="object"||Array.isArray(o)?null:o,Je=o=>{if(typeof o=="number"&&Number.isFinite(o))return o;if(typeof o=="string"){const n=Number(o);return Number.isFinite(n)?n:null}return null},A_=(o,n)=>{if(n===null)return;const t=Zt(o.source)??{},a=Je(t.duration);if(!(a!==null&&a>0&&a<=1&&n>a))return;t.duration=n,o.source=t;const r=Array.isArray(o.timeline)?o.timeline:[];if(r.length===1){const c=Zt(r[0]);if(c!==null){const d=Je(c.sourceIn)??0,u=Je(c.sourceOut)??Je(c.end)??Je(c.timelineEnd);if(d===0&&u!==null&&u>0&&u<=1){c.sourceOut=n;const f=Je(c.end);f!==null&&f>0&&f<=1&&(c.end=n);const p=Je(c.timelineEnd);p!==null&&p>0&&p<=1&&(c.timelineEnd=n)}}}const s=Je(o.trimEnd)??Je(o.trim_end);s!==null&&s>0&&s<=1&&(o.trimEnd=n);const l=Zt(o.trim);if(l!==null){const c=Je(l.end);c!==null&&c>0&&c<=1&&(l.end=n,o.trim=l)}},L_=(o,n)=>{if(!o)return!1;const t=Zt(o);if(t===null)return!1;const a=Zt(t.trim),i=Zt(t.source),s=Je(i==null?void 0:i.duration)??n,l=Array.isArray(o.filters)&&o.filters.length>0;let c=!1;if(Array.isArray(o.timeline)&&o.timeline.length===1){const p=o.timeline[0];p&&Array.isArray(p.filters)&&p.filters.length>0&&(c=!0)}let d=!1;const u=Je(t.trimStart)??Je(t.trim_start)??Je(a==null?void 0:a.start),m=Je(t.trimEnd)??Je(t.trim_end)??Je(a==null?void 0:a.end);if(u!==null&&u>0&&(d=!0),m!==null&&s!==void 0&&m<s&&(d=!0),!d&&Array.isArray(o.timeline)&&o.timeline.length===1){const p=o.timeline[0];if(p){const v=Je(p.sourceIn),g=Je(p.sourceOut);v!==null&&v>0&&(d=!0),g!==null&&s!==void 0&&g<s&&(d=!0)}}let f=!1;if(Array.isArray(o.timeline)&&o.timeline.length===1){const p=o.timeline[0];if(p){const v=Je(p.speed);f=v!==null&&v!==1}}return l||c||d||f},Ld=o=>{if(!o)return!1;const n=Zt(o);return n===null?!1:!!(Array.isArray(n.textOverlays)&&n.textOverlays.length>0||Array.isArray(n.transitions)&&n.transitions.length>0||Array.isArray(o.timeline)&&o.timeline.length>1)},U_=(o,n={})=>{var f,p;const t=JSON.parse(JSON.stringify(o)),a=Array.isArray(t.timeline)?t.timeline:[],i=a.length>0?Zt(a[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,a.length===1&&i!==null){const v=Je(i.sourceIn),g=Je(i.sourceOut);v!==null&&t.trimStart===void 0&&(t.trimStart=v),g!==null&&t.trimEnd===void 0&&(t.trimEnd=g)}const l=Zt(t.trim);if(t.trimStart===void 0){const v=Je(l==null?void 0:l.start);v!==null&&(t.trimStart=v)}if(t.trimEnd===void 0){const v=Je(l==null?void 0:l.end);v!==null&&(t.trimEnd=v)}const c=Zt(t.source),d=Je(t.width)??Je(c==null?void 0:c.original_width)??Je((f=n.exportMeta)==null?void 0:f.width);d!==null&&(t.width=d);const u=Je(t.height)??Je(c==null?void 0:c.original_height)??Je((p=n.exportMeta)==null?void 0:p.height);u!==null&&(t.height=u);const m=Zt(t.output);return t.fps=Je(t.fps)??Je(m==null?void 0:m.fps)??30,A_(t,n.mediaDuration??null),t},O_={key:0},P_=["data-testid"],z_={class:"ve-mobile-header"},j_=["data-testid"],W_={class:"ve-mobile-title"},Z_=["data-testid","disabled"],H_={key:1,class:"ve-mobile-spacer","aria-hidden":"true"},X_={class:"ve-body"},G_=["data-testid"],J_=["aria-label"],Y_={class:"ve-header"},q_={class:"ve-title"},K_=["data-testid"],Q_={class:"ve-body"},eE={class:"ve-footer"},tE=["data-testid"],nE=["data-testid","disabled"],aE=e.defineComponent({__name:"VideoEditorDialog",props:{open:{type:Boolean,default:!0},mediaUuid:{},initialRecipe:{},media:{},showThumbnailPicker:{type:Boolean,default:!1},title:{default:"Edit Video"},workflowMode:{default:"full"},featureFlags:{},clientExportThreshold:{default:20},maxDuration:{default:300},serverRenderEndpoint:{default:null},saveImmediate:{type:Boolean,default:!0},confirmText:{default:"Save"},savingText:{default:"Rendering..."},closeText:{default:"Cancel"},dataTestId:{default:"video-editor-dialog"},editorVersion:{}},emits:["update:open","close","recipe-generated","export-started","draft-saved","thumbnail-selected","video-exported","save-recipe","save-started","save-complete","save-error"],setup(o,{expose:n,emit:t}){const a=o,i=t,r=e.computed(()=>a.dataTestId),s=e.computed(()=>a.open),l=e.computed(()=>a.saveImmediate===!1),c=e.computed(()=>a.closeText),d=e.computed(()=>m.value?a.savingText:a.confirmText),u=e.ref(typeof window<"u"?window.innerWidth<768:!1),m=e.ref(!1),f=e.ref(!1),p=e.ref(null),v=`temp-${Date.now()}`,g=e.computed(()=>{var w;const B=(w=a.featureFlags)==null?void 0:w.export;return typeof B=="boolean"?B:a.workflowMode==="full"}),k=e.computed(()=>{if(a.editorVersion==="v1"||a.editorVersion==="v2")return a.editorVersion;if(typeof window>"u")return"v2";try{const B=new URLSearchParams(window.location.search),w=B.get("editor")??B.get("video-editor");if(w==="v1")return"v1";if(w==="v2")return"v2"}catch{}return"v2"}),T=e.computed(()=>k.value==="v2"?D_:Ad),V=e.computed(()=>typeof a.mediaUuid=="string"&&a.mediaUuid.trim()!==""?a.mediaUuid.trim():a.media&&a.media.uuid.trim()!==""?a.media.uuid.trim():v),b=e.computed(()=>{const B={showThumbnailPicker:a.showThumbnailPicker,workflowMode:a.workflowMode,clientExportThreshold:a.clientExportThreshold,maxDuration:a.maxDuration,serverRenderEndpoint:a.serverRenderEndpoint};return a.featureFlags!==void 0&&(B.featureFlags=a.featureFlags),a.initialRecipe!==void 0&&(B.initialRecipe=a.initialRecipe),a.media!==void 0&&(B.media=a.media),B}),h=()=>{u.value=window.innerWidth<768};e.onMounted(()=>{window.addEventListener("resize",h)}),e.onUnmounted(()=>{window.removeEventListener("resize",h)}),e.onErrorCaptured(()=>(f.value=!0,!1));const _=B=>{const w=Array.isArray(B.timeline)?B.timeline:[];if(w.length===0)return 0;let $=0;for(const z of w){const W=Number(z.sourceIn),Q=Number(z.sourceOut),ye=Number(z.speed??1),we=Number.isFinite(ye)&&ye>0?ye:1;if(Number.isFinite(W)&&Number.isFinite(Q)&&Q>W){$+=(Q-W)/we;continue}const ie=Number(z.timelineStart),N=Number(z.timelineEnd);Number.isFinite(ie)&&Number.isFinite(N)&&N>ie&&($+=N-ie)}return $},R=(B,w,$)=>{let z=null;const W=new Promise((Q,ye)=>{z=setTimeout(()=>ye(new Error(`${$} timed out after ${w}ms`)),w)});return Promise.race([B,W]).finally(()=>{z!==null&&clearTimeout(z)})},M=()=>{var W;const $=(W=a.media)==null?void 0:W.duration;if(typeof $!="number"||!Number.isFinite($)||$<=0)return 12e3;const z=Math.round($*1e3);return Math.min(45e3,Math.max(12e3,z))},x=()=>{i("close"),i("update:open",!1)},C=()=>{m.value=!1,x()},P=B=>{i("recipe-generated",B)},S=B=>{i("export-started",B),i("save-started",B)},D=B=>{i("video-exported",B)},I=B=>{i("thumbnail-selected",B)},j=(B,w,$)=>{i("save-recipe",B);const z={recipe:B,exportPayload:w};$!==void 0&&(z.toastDescription=$),i("save-complete",z),x()},O=B=>{m.value||(i("draft-saved",B),j(B,null))},F=async()=>{var B;if(!m.value){if(f.value||p.value===null){i("save-error",{code:"save-failed",message:"Unable to save video edits. Please try again."}),x();return}m.value=!0;try{const w=await R(p.value.saveDraft(),M(),"saveDraft");let $=null,z=!1,W;const Q=_(w),ye=Q>0?Q:((B=a.media)==null?void 0:B.duration)??0;if(g.value&&ye>0&&ye<=a.clientExportThreshold&&typeof p.value.exportForUpload=="function"){z=!0;const ie=Math.min(9e4,Math.max(15e3,a.clientExportThreshold*2e3));try{$=await R(p.value.exportForUpload(w),ie,"exportForUpload")}catch{$=null}}if(Ld(w)&&$===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&&$===null&&(W="Video edits saved. Final render will happen when you share."),j(w,$,W)}catch{i("save-error",{code:"save-failed",message:"Unable to save video edits. Please try again."}),x()}finally{m.value=!1}}};return n({saveDraft:F}),(B,w)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[s.value?(e.openBlock(),e.createElementBlock("div",O_,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"ve-fullscreen","data-testid":r.value},[e.createElementVNode("header",z_,[e.createElementVNode("button",{class:"ve-mobile-action",type:"button","data-testid":`${r.value}-close-button`,onClick:C},e.toDisplayString(c.value),9,j_),e.createElementVNode("h2",W_,e.toDisplayString(B.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:m.value,onClick:F},e.toDisplayString(d.value),9,Z_)):(e.openBlock(),e.createElementBlock("span",H_))]),e.createElementVNode("section",X_,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(T.value),e.mergeProps({ref_key:"videoEditorRef",ref:p,"media-uuid":V.value,"data-editor-version":k.value},b.value,{onClose:C,onDraftSaved:O,onExportStarted:S,onRecipeGenerated:P,onThumbnailSelected:I,onVideoExported:D}),null,16,["media-uuid","data-editor-version"]))])],8,P_)):(e.openBlock(),e.createElementBlock("div",{key:1,class:"ve-overlay","data-testid":r.value,onClick:e.withModifiers(C,["self"])},[e.createElementVNode("div",{class:"ve-dialog",role:"dialog","aria-label":B.title,"aria-modal":"true"},[e.createElementVNode("header",Y_,[e.createElementVNode("h2",q_,e.toDisplayString(B.title),1),e.createElementVNode("button",{class:"ve-close",type:"button","data-testid":`${r.value}-close-button`,"aria-label":"Close",onClick:C}," ✕ ",8,K_)]),e.createElementVNode("section",Q_,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(T.value),e.mergeProps({ref_key:"videoEditorRef",ref:p,"media-uuid":V.value,"data-editor-version":k.value},b.value,{onClose:C,onDraftSaved:O,onExportStarted:S,onRecipeGenerated:P,onThumbnailSelected:I,onVideoExported:D}),null,16,["media-uuid","data-editor-version"]))]),e.createElementVNode("footer",eE,[e.renderSlot(B.$slots,"footer",{close:C,isSaving:m.value,save:F},()=>[e.createElementVNode("button",{class:"ve-btn",type:"button","data-testid":`${r.value}-cancel-button`,onClick:C},e.toDisplayString(c.value),9,tE),l.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"ve-btn ve-btn--primary",type:"button","data-testid":`${r.value}-confirm-button`,disabled:m.value,onClick:F},e.toDisplayString(d.value),9,nE)):e.createCommentVNode("",!0)],!0)])],8,J_)],8,G_))])):e.createCommentVNode("",!0)]))}}),oE=Te(aE,[["__scopeId","data-v-7fb767d8"]]),iE={class:"video-editor-modal"},rE={class:"video-preview-container"},sE=["src"],lE={class:"video-overlay-controls"},cE=["aria-label"],dE={class:"time-display"},uE={class:"timeline-container"},mE={class:"clip-name"},pE={class:"timeline-time-labels"},fE={class:"tool-tabs"},hE=["onClick"],vE={class:"tool-panel"},gE={key:0,class:"trim-panel"},yE={class:"trim-controls"},bE={key:1,class:"filters-panel"},wE={class:"filter-grid"},kE=["onClick"],_E={key:2,class:"text-panel"},EE={key:3,class:"transitions-panel"},xE={class:"transition-grid"},CE=["onClick"],SE={class:"action-buttons"},VE=e.defineComponent({__name:"VideoEditorSimple",props:{media:{}},emits:["save","cancel"],setup(o,{emit:n}){const t=o,a=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),m=e.ref(0),f=e.ref(null),p=e.ref("trim"),v=e.ref(null),g=e.ref(""),k=[{id:"trim",label:"Trim",icon:wc},{id:"filters",label:"Filters",icon:rp},{id:"text",label:"Text",icon:Ec},{id:"transitions",label:"Transitions",icon:fp}],T=[{id:"none",name:"None"},{id:"grayscale",name:"Grayscale"},{id:"sepia",name:"Sepia"},{id:"blur",name:"Blur"},{id:"brightness",name:"Brightness"},{id:"contrast",name:"Contrast"}],V=[{id:"fade",name:"Fade"},{id:"slide",name:"Slide"},{id:"zoom",name:"Zoom"},{id:"wipe",name:"Wipe"}],b=e.ref();e.onMounted(()=>{var w,$;(w=t.media)!=null&&w.url?r.value=t.media.url:($=t.media)!=null&&$.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 h(){i.value&&(c.value=i.value.duration,m.value=c.value)}function _(){i.value&&(l.value=i.value.currentTime)}function R(){s.value=!1}function M(){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 $=Math.floor(w/60),z=Math.floor(w%60);return`${$.toString().padStart(2,"0")}:${z.toString().padStart(2,"0")}`}function C(w){if(!i.value||!b.value)return;const $=b.value.getBoundingClientRect(),Q=(w.clientX-$.left)/$.width*c.value;i.value.currentTime=Math.max(0,Math.min(Q,c.value))}function P(){u.value=l.value}function S(){m.value=l.value}function D(){u.value=0,m.value=c.value}function I(w){f.value=w;const $=W=>{if(!f.value||!b.value)return;const Q=b.value.getBoundingClientRect(),ie=(W.clientX-Q.left)/Q.width*c.value;f.value==="start"?u.value=Math.max(0,Math.min(ie,m.value-1)):m.value=Math.max(u.value+1,Math.min(ie,c.value))},z=()=>{f.value=null,document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",z)};document.addEventListener("mousemove",$),document.addEventListener("mouseup",z)}function j(w){if(v.value=w,!i.value)return;const $={none:"none",grayscale:"grayscale(100%)",sepia:"sepia(100%)",blur:"blur(5px)",brightness:"brightness(150%)",contrast:"contrast(150%)"};i.value.style.filter=$[w]||"none"}function O(){}function F(w){}function B(){const w={timeline:[{id:d.value,url:r.value,startTime:0,endTime:c.value,sourceIn:u.value,sourceOut:m.value,track:0}],filters:v.value?[{type:v.value}]:[],textOverlays:g.value?[{content:g.value}]:[],duration:m.value-u.value};a("save",w)}return(w,$)=>(e.openBlock(),e.createElementBlock("div",iE,[e.createElementVNode("div",rE,[e.createElementVNode("video",{ref_key:"videoElement",ref:i,class:"video-preview",src:r.value,onLoadedmetadata:h,onTimeupdate:_,onEnded:R,controls:""},null,40,sE),e.createElementVNode("div",lE,[e.createElementVNode("button",{class:"play-pause-btn",onClick:M,"aria-label":s.value?"Pause":"Play"},[e.createVNode(e.unref(U.IonIcon),{icon:s.value?e.unref(yp):e.unref(_p)},null,8,["icon"])],8,cE),e.createElementVNode("div",dE,e.toDisplayString(x(l.value))+" / "+e.toDisplayString(x(c.value)),1)])]),e.createElementVNode("div",uE,[e.createElementVNode("div",{class:"timeline-track",onClick:C,ref_key:"timelineTrack",ref:b},[e.createElementVNode("div",{class:"timeline-clip",style:e.normalizeStyle({left:`${u.value/c.value*100}%`,right:`${100-m.value/c.value*100}%`})},[e.createElementVNode("span",mE,e.toDisplayString(d.value),1)],4),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:`${l.value/c.value*100}%`})},null,4),p.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:0,class:"trim-handle trim-start",style:e.normalizeStyle({left:`${u.value/c.value*100}%`}),onMousedown:$[0]||($[0]=z=>I("start"))},null,36)):e.createCommentVNode("",!0),p.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:1,class:"trim-handle trim-end",style:e.normalizeStyle({left:`${m.value/c.value*100}%`}),onMousedown:$[1]||($[1]=z=>I("end"))},null,36)):e.createCommentVNode("",!0)],512),e.createElementVNode("div",pE,[e.createElementVNode("span",null,e.toDisplayString(x(0)),1),e.createElementVNode("span",null,e.toDisplayString(x(c.value)),1)])]),e.createElementVNode("div",fE,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(k,z=>e.createElementVNode("button",{key:z.id,class:e.normalizeClass(["tool-tab",{active:p.value===z.id}]),onClick:W=>p.value=z.id},[e.createVNode(e.unref(U.IonIcon),{icon:z.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(z.label),1)],10,hE)),64))]),e.createElementVNode("div",vE,[p.value==="trim"?(e.openBlock(),e.createElementBlock("div",gE,[$[7]||($[7]=e.createElementVNode("h3",null,"Trim Video",-1)),$[8]||($[8]=e.createElementVNode("p",null,"Click and drag on the timeline to set trim points",-1)),e.createElementVNode("div",yE,[e.createElementVNode("button",{class:"btn-trim",onClick:P},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(dl)},null,8,["icon"]),$[4]||($[4]=e.createTextVNode(" Set Start ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:S},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(dl)},null,8,["icon"]),$[5]||($[5]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:D},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Rn)},null,8,["icon"]),$[6]||($[6]=e.createTextVNode(" Clear ",-1))])])])):p.value==="filters"?(e.openBlock(),e.createElementBlock("div",bE,[$[9]||($[9]=e.createElementVNode("h3",null,"Filters",-1)),e.createElementVNode("div",wE,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(T,z=>e.createElementVNode("button",{key:z.id,class:e.normalizeClass(["filter-option",{active:v.value===z.id}]),onClick:W=>j(z.id)},e.toDisplayString(z.name),11,kE)),64))])])):p.value==="text"?(e.openBlock(),e.createElementBlock("div",_E,[$[10]||($[10]=e.createElementVNode("h3",null,"Text Overlay",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":$[2]||($[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:O},"Add Text")])):p.value==="transitions"?(e.openBlock(),e.createElementBlock("div",EE,[$[11]||($[11]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",xE,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(V,z=>e.createElementVNode("button",{key:z.id,class:"transition-option",onClick:W=>(z.id,void 0)},e.toDisplayString(z.name),9,CE)),64))])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",SE,[e.createElementVNode("button",{class:"btn-cancel",onClick:$[3]||($[3]=z=>w.$emit("cancel"))},"CANCEL"),e.createElementVNode("button",{class:"btn-save",onClick:B},"SAVE")])]))}}),NE=Te(VE,[["__scopeId","data-v-b933f33b"]]),TE={class:"time-label"},ME=e.defineComponent({__name:"TimeRuler",props:{duration:{},zoom:{}},setup(o){const n=o,t=e.computed(()=>({width:`${n.duration*n.zoom*100}px`})),a=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),m=c%(l*5)===0;s.push({time:c,position:d,label:u,major:m})}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(a.value,c=>(e.openBlock(),e.createElementBlock("div",{key:c.time,class:"time-mark",style:e.normalizeStyle({left:c.position})},[e.createElementVNode("span",TE,e.toDisplayString(c.label),1),e.createElementVNode("div",{class:e.normalizeClass(["time-tick",{major:c.major}])},null,2)],4))),128))],4))}}),BE=Te(ME,[["__scopeId","data-v-0ef9c910"]]),FE=["data-track-index"],IE={class:"track-header"},$E={class:"track-label"},RE={class:"track-controls"},DE=["data-testid","aria-label"],AE=["data-testid","onMousedown","onClick"],LE={class:"clip-content"},UE={class:"clip-name"},OE={key:0,class:"clip-thumbnail"},PE=["src","alt"],zE=["onMousedown","aria-label"],jE=["onMousedown","aria-label"],WE=e.defineComponent({__name:"VideoTrack",props:{clips:{},trackIndex:{},zoom:{},duration:{}},emits:["clip-move","clip-trim","clip-select"],setup(o,{emit:n}){const t=o,a=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 T=k.timelineEnd-k.timelineStart,V=k.timelineStart/t.duration*100,b=T/t.duration*100;return{left:`${V}%`,width:`${b}%`,backgroundColor:u(k)}}function u(k){const T=["#4A90E2","#7ED321","#F5A623","#BD10E0","#9013FE","#50E3C2","#B8E986","#F8E71C"],V=parseInt(k.id.replace(/\D/g,""))%T.length;return T[V]}function m(k){return k.label?k.label:k.url?(k.url.split("/").pop()||"Clip").split(".")[0]:`Clip ${k.id.slice(-4)}`}function f(k){i.value=k.id,a("clip-select",k.id)}function p(){r.value=!r.value}function v(k,T){if(l.value)return;s.value=!0;const V=T.clientX,b=k.timelineStart,h=R=>{if(!s.value)return;const M=R.clientX-V,x=parseFloat(c.value.width),C=M/(t.zoom*100)*(t.duration/x),P=Math.max(0,b+C);a("clip-move",k.id,P)},_=()=>{s.value=!1,document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",_)};document.addEventListener("mousemove",h),document.addEventListener("mouseup",_)}function g(k,T,V){l.value=T;const b=V.clientX,h=k.sourceIn,_=k.sourceOut,R=x=>{if(!l.value)return;const C=x.clientX-b,P=parseFloat(c.value.width),S=C/(t.zoom*100)*(t.duration/P);if(l.value==="start"){const D=Math.max(0,h+S);a("clip-trim",k.id,D,_)}else{const D=Math.max(h+1,_+S);a("clip-trim",k.id,h,D)}},M=()=>{l.value=null,document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",M)};document.addEventListener("mousemove",R),document.addEventListener("mouseup",M)}return(k,T)=>(e.openBlock(),e.createElementBlock("div",{class:"video-track","data-track-index":k.trackIndex},[e.createElementVNode("div",IE,[e.createElementVNode("span",$E,"Track "+e.toDisplayString(k.trackIndex+1),1),e.createElementVNode("div",RE,[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:p},[e.createVNode(e.unref(U.IonIcon),{icon:r.value?e.unref(Ap):e.unref(Rp)},null,8,["icon"])],8,DE)):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,V=>(e.openBlock(),e.createElementBlock("div",{key:V.id,class:e.normalizeClass(["timeline-clip",{selected:V.id===i.value}]),style:e.normalizeStyle(d(V)),"data-testid":`clip-${V.id}`,onMousedown:b=>v(V,b),onClick:b=>f(V)},[e.createElementVNode("div",LE,[e.createElementVNode("span",UE,e.toDisplayString(m(V)),1),V.thumbnail?(e.openBlock(),e.createElementBlock("div",OE,[e.createElementVNode("img",{src:V.thumbnail,alt:m(V)},null,8,PE)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:e.withModifiers(b=>g(V,"start",b),["stop"]),"aria-label":`Trim start of ${m(V)}`},null,40,zE),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:e.withModifiers(b=>g(V,"end",b),["stop"]),"aria-label":`Trim end of ${m(V)}`},null,40,jE)],46,AE))),128))],4)],8,FE))}}),ZE=Te(WE,[["__scopeId","data-v-48e480d2"]]),HE={class:"video-timeline"},XE={class:"timeline-tracks"},GE=["aria-label","aria-valuenow","aria-valuemax"],JE={class:"timeline-controls"},YE={class:"zoom-level"},qE=e.defineComponent({__name:"VideoTimeline",props:{clips:{},duration:{},currentTime:{}},emits:["update:clips","seek","clip-move","clip-trim"],setup(o,{emit:n}){const t=o,a=n,i=e.ref(1),r=e.ref(null),s=e.ref(!1),l=e.ref(),c=e.computed(()=>{const b=Math.max(0,...t.clips.map(h=>h.track||0));return Array(b+1).fill(null)}),d=e.computed(()=>`${t.currentTime/t.duration*100}%`);function u(b){return t.clips.filter(h=>(h.track||0)===b)}function m(b){const h=Math.floor(b/60),_=Math.floor(b%60);return`${h}:${_.toString().padStart(2,"0")}`}function f(b,h){a("clip-move",b,h)}function p(b,h,_){a("clip-trim",b,h,_)}function v(b){r.value=b}function g(){i.value=Math.min(i.value*1.2,5)}function k(){i.value=Math.max(i.value/1.2,.5)}function T(){s.value=!0;const b=_=>{if(!s.value||!l.value)return;const R=l.value.getBoundingClientRect(),C=Math.max(0,Math.min(_.clientX-R.left,R.width))/R.width*t.duration;a("seek",C)},h=()=>{s.value=!1,document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",h)};document.addEventListener("mousemove",b),document.addEventListener("mouseup",h)}function V(b){let h=t.currentTime;switch(b.key){case"ArrowLeft":h=Math.max(0,t.currentTime-1);break;case"ArrowRight":h=Math.min(t.duration,t.currentTime+1);break;case"Home":h=0;break;case"End":h=t.duration;break;default:return}b.preventDefault(),a("seek",h)}return e.onMounted(()=>{l.value=document.querySelector(".video-timeline")}),e.onUnmounted(()=>{}),(b,h)=>(e.openBlock(),e.createElementBlock("div",HE,[e.createVNode(BE,{duration:b.duration,zoom:i.value},null,8,["duration","zoom"]),e.createElementVNode("div",XE,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,(_,R)=>(e.openBlock(),e.createBlock(ZE,{key:`track-${R}`,"data-testid":`track-${R}`,clips:u(R),"track-index":R,zoom:i.value,duration:b.duration,onClipMove:f,onClipTrim:p,onClipSelect:v},null,8,["data-testid","clips","track-index","zoom","duration"]))),128))]),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:d.value}),onMousedown:T,"data-testid":"playhead","aria-label":`Playhead at ${m(b.currentTime)}`,role:"slider","aria-valuenow":b.currentTime,"aria-valuemax":b.duration,tabindex:"0",onKeydown:V},null,44,GE),e.createElementVNode("div",JE,[e.createElementVNode("button",{"data-testid":"btn-zoom-in","aria-label":"Zoom in",onClick:g},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Xr)},null,8,["icon"])]),e.createElementVNode("span",YE,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(Np)},null,8,["icon"])])])]))}}),KE=Te(qE,[["__scopeId","data-v-001df415"]]),QE={class:"video-filters-panel"},ex={class:"filter-controls"},tx=["for"],nx={class:"filter-slider-group"},ax=["id","onUpdate:modelValue","min","max","step","data-testid","aria-label","aria-valuenow","aria-valuemin","aria-valuemax","onInput"],ox={class:"filter-value"},ix={class:"filter-actions"},rx={key:0,class:"filter-presets"},sx={class:"preset-list"},lx=["data-testid","aria-label","onClick"],cx=e.defineComponent({__name:"VideoFiltersPanel",emits:["filter-change"],setup(o,{emit:n}){const t=n,a=[{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(a.reduce((f,p)=>(f[p.type]=p.default,f),{})),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(f,p){switch(f){case"brightness":case"contrast":case"saturation":case"sepia":case"grayscale":return`${p}%`;case"hue":return`${p}°`;case"blur":case"sharpen":return p.toFixed(1);default:return p.toString()}}function l(f){return["brightness","contrast","saturation","hue","blur","sharpen","sepia","grayscale"].includes(f)}function c(f){if(!l(f))return;const p={id:`filter-${f}`,filterId:f,params:{value:i[f]},intensity:1};t("filter-change",p)}function d(){a.forEach(f=>{i[f.type]=f.default,c(f.type)})}function u(){const f=prompt("Enter preset name:");if(!f)return;const p={id:`custom-${Date.now()}`,name:f,values:{...i}};r.value.push(p)}function m(f){Object.entries(f.values).forEach(([p,v])=>{i[p]=v,c(p)})}return(f,p)=>(e.openBlock(),e.createElementBlock("div",QE,[p[3]||(p[3]=e.createElementVNode("h3",null,"Video Filters",-1)),e.createElementVNode("div",ex,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,v=>e.createElementVNode("div",{key:v.type,class:"filter-control"},[e.createElementVNode("label",{for:`filter-${v.type}`},e.toDisplayString(v.label),9,tx),e.createElementVNode("div",nx,[e.withDirectives(e.createElementVNode("input",{id:`filter-${v.type}`,"onUpdate:modelValue":g=>i[v.type]=g,type:"range",min:v.min,max:v.max,step:v.step,class:"filter-slider","data-testid":`filter-${v.type}`,"aria-label":`${v.label} filter`,"aria-valuenow":i[v.type],"aria-valuemin":v.min,"aria-valuemax":v.max,onInput:g=>c(v.type)},null,40,ax),[[e.vModelText,i[v.type],void 0,{number:!0}]]),e.createElementVNode("span",ox,e.toDisplayString(s(v.type,i[v.type])),1)])])),64))]),e.createElementVNode("div",ix,[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(Un)},null,8,["icon"]),p[0]||(p[0]=e.createTextVNode(" Reset All Filters ",-1))]),e.createElementVNode("button",{class:"save-preset-btn","data-testid":"btn-save-preset","aria-label":"Save current filter settings as preset",onClick:u},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Go)},null,8,["icon"]),p[1]||(p[1]=e.createTextVNode(" Save as Preset ",-1))])]),r.value.length>0?(e.openBlock(),e.createElementBlock("div",rx,[p[2]||(p[2]=e.createElementVNode("h4",null,"Presets",-1)),e.createElementVNode("div",sx,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,v=>(e.openBlock(),e.createElementBlock("button",{key:v.id,class:"preset-btn","data-testid":`preset-${v.id}`,"aria-label":`Apply ${v.name} preset`,onClick:g=>m(v)},e.toDisplayString(v.name),9,lx))),128))])])):e.createCommentVNode("",!0)]))}}),dx=Te(cx,[["__scopeId","data-v-5ad2ac63"]]),ux={class:"video-text-panel"},mx={class:"text-input-group"},px={class:"text-options"},fx={class:"option-row"},hx={class:"option-row"},vx={class:"option-row"},gx={class:"option-row"},yx={class:"checkbox-label"},bx={class:"option-row"},wx={class:"text-overlay-list"},kx={key:0,class:"empty-state"},_x=["data-testid"],Ex={class:"overlay-preview"},xx={class:"overlay-controls"},Cx=["data-testid","aria-label","onClick"],Sx=["data-testid","aria-label","onClick"],Vx=["data-testid","aria-label","onClick"],Nx=e.defineComponent({__name:"VideoTextPanel",emits:["text-add","text-remove","text-update"],setup(o,{emit:n}){const t=n,a=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),a.value.push(d),t("text-add",d),i.text=""}function s(d){const u=a.value.findIndex(m=>m.id===d);u!==-1&&(a.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};a.value.push(u),t("text-add",u)}return(d,u)=>(e.openBlock(),e.createElementBlock("div",ux,[u[17]||(u[17]=e.createElementVNode("h3",null,"Text Overlays",-1)),e.createElementVNode("div",mx,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[0]||(u[0]=m=>i.text=m),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(Xr)},null,8,["icon"]),u[7]||(u[7]=e.createTextVNode(" Add ",-1))])]),e.createElementVNode("div",px,[e.createElementVNode("div",fx,[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]=m=>i.fontFamily=m),"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",hx,[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]=m=>i.fontSize=m),type:"number",min:"10",max:"200","data-testid":"input-font-size"},null,512),[[e.vModelText,i.fontSize,void 0,{number:!0}]])]),e.createElementVNode("div",vx,[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]=m=>i.color=m),type:"color","data-testid":"input-text-color"},null,512),[[e.vModelText,i.color]])]),e.createElementVNode("div",gx,[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]=m=>i.backgroundColor=m),type:"color","data-testid":"input-bg-color"},null,512),[[e.vModelText,i.backgroundColor]]),e.createElementVNode("label",yx,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[5]||(u[5]=m=>i.hasBackground=m),type:"checkbox","data-testid":"checkbox-bg"},null,512),[[e.vModelCheckbox,i.hasBackground]]),u[12]||(u[12]=e.createTextVNode(" Enable ",-1))])]),e.createElementVNode("div",bx,[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]=m=>i.animation=m),"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",wx,[u[16]||(u[16]=e.createElementVNode("h4",null,"Active Overlays",-1)),a.value.length===0?(e.openBlock(),e.createElementBlock("div",kx," No text overlays added yet ")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(m,f)=>(e.openBlock(),e.createElementBlock("div",{key:m.id,class:"text-overlay-item","data-testid":`overlay-${f}`},[e.createElementVNode("div",Ex,[e.createElementVNode("span",{style:e.normalizeStyle({fontFamily:m.fontFamily,fontSize:`${Math.min(m.fontSize/4,16)}px`,color:m.color})},e.toDisplayString(m.text),5)]),e.createElementVNode("div",xx,[e.createElementVNode("button",{class:"edit-btn","data-testid":`btn-edit-${f}`,"aria-label":`Edit overlay: ${m.text}`,onClick:p=>l(m)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(cp)},null,8,["icon"])],8,Cx),e.createElementVNode("button",{class:"duplicate-btn","data-testid":`btn-duplicate-${f}`,"aria-label":`Duplicate overlay: ${m.text}`,onClick:p=>c(m)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(lp)},null,8,["icon"])],8,Sx),e.createElementVNode("button",{class:"remove-btn","data-testid":`btn-remove-${f}`,"aria-label":`Remove overlay: ${m.text}`,onClick:p=>s(m.id)},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Bp)},null,8,["icon"])],8,Vx)])],8,_x))),128))])]))}}),Tx=Te(Nx,[["__scopeId","data-v-4d240e1e"]]),Mx={class:"video-tools-panel"},Bx={class:"tool-tabs"},Fx=["data-testid","aria-label","aria-selected","onClick"],Ix={class:"tool-content"},$x={key:0,class:"trim-panel",role:"tabpanel","aria-label":"Trim controls"},Rx={class:"trim-actions"},Dx={key:3,class:"transitions-panel",role:"tabpanel","aria-label":"Transition controls"},Ax={class:"transition-types"},Lx=["data-testid","aria-label","onClick"],Ux={class:"transition-preview"},Ox=e.defineComponent({__name:"VideoToolsPanel",props:{activeTool:{}},emits:["tool-change","filter-change","text-add","transition-add","trim-set-start","trim-set-end","trim-clear"],setup(o){const n=[{id:"trim",name:"Trim",icon:wc},{id:"filters",name:"Filters",icon:yn},{id:"text",name:"Text",icon:Ec},{id:"transitions",name:"Transitions",icon:pl}],t=[{id:"fade",name:"Fade",icon:qi},{id:"slide-left",name:"Slide Left",icon:tp},{id:"slide-right",name:"Slide Right",icon:np},{id:"dissolve",name:"Dissolve",icon:qi},{id:"wipe",name:"Wipe",icon:pl},{id:"zoom",name:"Zoom",icon:qi}];return(a,i)=>(e.openBlock(),e.createElementBlock("div",Mx,[e.createElementVNode("div",Bx,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(n,r=>e.createElementVNode("button",{key:r.id,class:e.normalizeClass(["tool-tab",{active:a.activeTool===r.id}]),"data-testid":`tab-${r.id}`,"aria-label":`${r.name} tool`,"aria-selected":a.activeTool===r.id,role:"tab",onClick:s=>a.$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,Fx)),64))]),e.createElementVNode("div",Ix,[a.activeTool==="trim"?(e.openBlock(),e.createElementBlock("div",$x,[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",Rx,[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=>a.$emit("trim-set-start"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ul)},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=>a.$emit("trim-set-end"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ul)},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=>a.$emit("trim-clear"))},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Rn)},null,8,["icon"]),i[7]||(i[7]=e.createTextVNode(" Clear ",-1))])])])):e.createCommentVNode("",!0),a.activeTool==="filters"?(e.openBlock(),e.createBlock(dx,{key:1,onFilterChange:i[3]||(i[3]=r=>a.$emit("filter-change",r))})):e.createCommentVNode("",!0),a.activeTool==="text"?(e.openBlock(),e.createBlock(Tx,{key:2,onTextAdd:i[4]||(i[4]=r=>a.$emit("text-add",r))})):e.createCommentVNode("",!0),a.activeTool==="transitions"?(e.openBlock(),e.createElementBlock("div",Dx,[i[10]||(i[10]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",Ax,[(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=>a.$emit("transition-add",r.id)},[e.createElementVNode("div",Ux,[e.createVNode(e.unref(U.IonIcon),{icon:r.icon},null,8,["icon"])]),e.createElementVNode("span",null,e.toDisplayString(r.name),1)],8,Lx)),64))])])):e.createCommentVNode("",!0)])]))}}),Px=Te(Ox,[["__scopeId","data-v-fc135306"]]),zx={class:"video-export-panel"},jx={class:"export-presets"},Wx=["value"],Zx={key:0,class:"preset-details"},Hx={class:"detail-row"},Xx={class:"detail-row"},Gx={class:"detail-row"},Jx={class:"advanced-options"},Yx={class:"options-content"},qx={class:"option-group"},Kx={class:"option-group"},Qx={class:"option-group"},eC=["disabled"],tC={key:1,class:"export-progress"},nC={class:"progress-message"},aC={class:"progress-bar"},oC=["aria-valuenow"],iC={class:"progress-percentage"},rC=e.defineComponent({__name:"VideoExportPanel",props:{presets:{},isExporting:{type:Boolean},exportProgress:{}},emits:["export"],setup(o,{emit:n}){const t=o,a=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&&a("export",{...s.value,options:{...r}})}return(d,u)=>(e.openBlock(),e.createElementBlock("div",zx,[u[14]||(u[14]=e.createElementVNode("h3",null,"Export Video",-1)),e.createElementVNode("div",jx,[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]=m=>i.value=m),"data-testid":"preset-select","aria-label":"Select export preset"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.presets,m=>(e.openBlock(),e.createElementBlock("option",{key:m.id,value:m.id},e.toDisplayString(m.name),9,Wx))),128))],512),[[e.vModelSelect,i.value]])]),s.value?(e.openBlock(),e.createElementBlock("div",Zx,[e.createElementVNode("div",Hx,[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",Xx,[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",Gx,[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",Jx,[u[12]||(u[12]=e.createElementVNode("summary",null,"Advanced Options",-1)),e.createElementVNode("div",Yx,[e.createElementVNode("div",qx,[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]=m=>r.quality=m),"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",Kx,[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]=m=>r.bitrate=m),type:"number",min:"1",max:"50","data-testid":"bitrate-input"},null,512),[[e.vModelText,r.bitrate,void 0,{number:!0}]])]),e.createElementVNode("div",Qx,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[3]||(u[3]=m=>r.includeAudio=m),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(na)},null,8,["icon"]),u[13]||(u[13]=e.createTextVNode(" Export Video ",-1))],64))],8,eC),d.isExporting?(e.openBlock(),e.createElementBlock("div",tC,[e.createElementVNode("div",nC,e.toDisplayString(l.value),1),e.createElementVNode("div",aC,[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,oC)]),e.createElementVNode("div",iC,e.toDisplayString(d.exportProgress)+"% ",1)])):e.createCommentVNode("",!0)]))}}),sC=Te(rC,[["__scopeId","data-v-5caf8fe6"]]),lC=["data-testid"],cC={class:"progress-header"},dC={class:"file-info"},uC={class:"file-details"},mC={class:"file-name"},pC={class:"file-meta"},fC={class:"file-size"},hC={key:0,class:"separator"},vC={key:1,class:"upload-speed"},gC={key:2,class:"separator"},yC={key:3,class:"time-remaining"},bC={class:"progress-actions"},wC={key:0,class:"status-icon completed","data-testid":"video-upload-status-completed"},kC={key:1,class:"status-icon error","data-testid":"video-upload-status-error"},_C={key:2,class:"status-icon processing","data-testid":"video-upload-status-processing",role:"status","aria-label":"Processing video"},EC=["aria-valuenow","aria-label"],xC={class:"progress-bar"},CC={class:"progress-percent"},SC={key:1,class:"error-message","data-testid":"video-upload-error"},VC={key:2,class:"thumbnail-preview","data-testid":"video-upload-thumbnail"},NC=["src","alt"],TC={key:0,class:"video-duration"},MC=e.defineComponent({__name:"VideoUploadProgress",props:{upload:{}},emits:["cancel","retry","remove"],setup(o){const n=o,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"})),a=e.computed(()=>xc),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 f=n.upload.timeRemaining;if(f<60)return`${Math.round(f)}s`;const p=Math.floor(f/60);return p<60?`${p}m ${Math.round(f%60)}s`:`${Math.floor(p/60)}h ${p%60}m`}),l=e.computed(()=>{var f;return n.upload.status==="completed"&&((f=n.upload.media)!=null&&f.thumbnail_url)?n.upload.media.thumbnail_url:null}),c=e.computed(()=>{var f;return(f=n.upload.media)==null?void 0:f.duration});function d(f){if(f===0)return"0 B";const p=["B","KB","MB","GB","TB"],v=1024,g=Math.floor(Math.log(f)/Math.log(v));return`${(f/Math.pow(v,g)).toFixed(1)} ${p[g]}`}function u(f){if(f===0)return"0 B/s";const p=["B/s","KB/s","MB/s","GB/s"],v=1024,g=Math.floor(Math.log(f)/Math.log(v));return`${(f/Math.pow(v,g)).toFixed(1)} ${p[g]}`}function m(f){const p=Math.floor(f/3600),v=Math.floor(f%3600/60),g=Math.floor(f%60);return p>0?`${p}:${v.toString().padStart(2,"0")}:${g.toString().padStart(2,"0")}`:`${v}:${g.toString().padStart(2,"0")}`}return(f,p)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["upload-progress-item",t.value]),"data-testid":`video-upload-progress-${f.upload.id}`},[e.createElementVNode("div",cC,[e.createElementVNode("div",dC,[e.createVNode(e.unref(U.IonIcon),{icon:a.value,class:"file-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("div",uC,[e.createElementVNode("h4",mC,e.toDisplayString(f.upload.filename),1),e.createElementVNode("p",pC,[e.createElementVNode("span",fC,e.toDisplayString(d(f.upload.bytesTotal||0)),1),f.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",hC,"•")):e.createCommentVNode("",!0),f.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",vC,e.toDisplayString(u(f.upload.uploadSpeed||0)),1)):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",gC,"•")):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",yC,e.toDisplayString(s.value)+" remaining ",1)):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",bC,[f.upload.status==="completed"?(e.openBlock(),e.createElementBlock("div",wC,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(yc)},null,8,["icon"])])):f.upload.status==="error"?(e.openBlock(),e.createElementBlock("div",kC,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(ep),"aria-hidden":"true"},null,8,["icon"])])):f.upload.status==="processing"?(e.openBlock(),e.createElementBlock("div",_C,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),f.upload.status==="uploading"?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:3,fill:"clear",size:"small",onClick:p[0]||(p[0]=v=>f.$emit("cancel")),"data-testid":"btn-cancel-video-upload","aria-label":"Cancel upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Rn),slot:"icon-only"},null,8,["icon"])]),_:1})):f.upload.status==="error"?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:4,fill:"clear",size:"small",onClick:p[1]||(p[1]=v=>f.$emit("retry")),"data-testid":"btn-retry-video-upload","aria-label":"Retry upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Un),slot:"icon-only"},null,8,["icon"])]),_:1})):f.upload.status==="completed"?(e.openBlock(),e.createBlock(e.unref(U.IonButton),{key:5,fill:"clear",size:"small",onClick:p[2]||(p[2]=v=>f.$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(Rn),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":f.upload.status==="processing"?"Processing progress":"Upload progress"},[e.createElementVNode("div",xC,[e.createElementVNode("div",{class:e.normalizeClass(["progress-fill",{indeterminate:f.upload.status==="processing"}]),style:e.normalizeStyle({width:r.value+"%"})},null,6)]),e.createElementVNode("span",CC,e.toDisplayString(Math.round(r.value))+"%",1)],8,EC)):e.createCommentVNode("",!0),f.upload.error?(e.openBlock(),e.createElementBlock("div",SC,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Lp)},null,8,["icon"]),e.createElementVNode("span",null,e.toDisplayString(f.upload.error),1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",VC,[e.createElementVNode("img",{src:l.value,alt:f.upload.filename},null,8,NC),c.value?(e.openBlock(),e.createElementBlock("div",TC,e.toDisplayString(m(c.value)),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],10,lC))}}),BC=Te(MC,[["__scopeId","data-v-9eacbf91"]]),lr=4,FC=500,IC=new Set([408,425,429,500,502,503,504,520,521,522,523,524,525]);function yi(o){return typeof o=="object"&&o!==null}function Yl(o){return yi(o)?typeof o.upload_url=="string"&&typeof o.upload_id=="string"&&typeof o.media_uuid=="string"&&typeof o.expires_at=="string":!1}function $C(o){if(Yl(o))return o;if(yi(o)&&Yl(o.data))return o.data;throw new Error("Invalid upload response from backend")}function ql(o){return yi(o)?typeof o.uuid=="string"&&typeof o.processing_status=="string":!1}function RC(o){if(ql(o))return o;if(yi(o)&&ql(o.data))return o.data;throw new Error("Invalid media response from backend")}function go(o){return o?{...o}:{}}function Kl(o,n="PUT"){return typeof o.method=="string"&&o.method.trim()!==""?o.method.trim().toUpperCase():n}function DC(o){return o.resumable===!0?!0:/tusupload/i.test(o.upload_url)}function AC(o){if(typeof btoa=="function")try{return btoa(unescape(encodeURIComponent(o)))}catch{return btoa(o)}throw new Error("Base64 encoder is unavailable for TUS metadata")}function LC(o,n){return[["filename",o.filename],["filetype",o.file.type||"application/octet-stream"],["uploadid",n.upload_id],["mediauuid",n.media_uuid]].map(([a,i])=>`${a} ${AC(i)}`).join(",")}function yo(o,n){const t=Math.max(o.bytesTotal,1);o.bytesUploaded=n,o.progress=Math.min(100,n/t*100);const a=Math.max((Date.now()-o.startedAt.getTime())/1e3,.001);o.uploadSpeed=n/a;const i=Math.max(t-n,0);o.timeRemaining=i/Math.max(o.uploadSpeed,1)}function UC(o,n){return o instanceof Error?o:new Error(n)}function OC(o){if(!(o instanceof Error))return!1;const n=o.message.toLowerCase();return n.includes("failed to fetch")||n.includes("networkerror")||n.includes("network request failed")||n.includes("err_ssl_")}function Ql(o){const n=Math.max(0,o-1),t=FC*Math.pow(2,n);return Math.min(5e3,t)}function ec(o){return new Promise(n=>{window.setTimeout(n,o)})}async function tc(o,n){for(let t=1;t<=lr;t+=1)try{const a=await n();if(a.ok||!IC.has(a.status)||t>=lr)return a;await ec(Ql(t))}catch(a){if(!OC(a)||t>=lr)throw a;await ec(Ql(t))}throw new Error(`${o} failed after retry attempts`)}function PC(o={}){const n=e.ref(new Map),t=e.ref(new Set),a=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 S=Array.from(n.value.values());return S.length===0?0:S.reduce((I,j)=>I+j.progress,0)/S.length});function d(S){a.value=S}function u(){}async function m(S){var I;const D=S.filter(j=>f(j));if(D.length!==0&&((I=o.onFilesSelected)==null||I.call(o,D),o.autoUpload!==!1))for(const j of D)await p(j)}function f(S){return!(o.maxFileSize&&S.size>o.maxFileSize||o.allowedFormats&&o.allowedFormats.length>0&&!o.allowedFormats.includes(S.type))}async function p(S){var j,O,F;const D=P(S);if(n.value.has(D)){const B=n.value.get(D);if((B==null?void 0:B.status)==="uploading")return}const I={id:D,file:S,filename:S.name,progress:0,status:"pending",startedAt:new Date,bytesTotal:S.size,bytesUploaded:0};n.value.set(I.id,I),t.value.add(I.id);try{I.status="uploading",(j=o.onUploadStart)==null||j.call(o,I);const B=await v(S);o.resumable===!0||B.resumable===!0?await k(I,B):await g(I,B),I.status="processing",I.progress=100;const $=await _(B.media_uuid);I.status="completed",I.media=$,(O=o.onUploadComplete)==null||O.call(o,$)}catch(B){if(I.status!=="cancelled"){const w=UC(B,"Upload failed");I.status="error",I.error=w.message,(F=o.onUploadError)==null||F.call(o,w,I)}}finally{t.value.delete(I.id),i.delete(I.id),r.delete(I.id)}}async function v(S){if(!a.value)throw new Error("API client not configured");const D={collection:o.collection||"videos",filename:S.name,size:S.size,mime_type:S.type,...o.ownerUuid!==void 0?{ownerUuid:o.ownerUuid}:{},...o.ownerType!==void 0?{ownerType:o.ownerType}:{}},I=await a.value.post("/api/v1/video/upload",D);return $C(I)}async function g(S,D){const I=new XMLHttpRequest,j=Kl(D),O=go(D.headers);return new Promise((F,B)=>{I.upload.addEventListener("progress",w=>{var $;w.lengthComputable&&(yo(S,w.loaded),($=o.onUploadProgress)==null||$.call(o,S))}),I.addEventListener("load",()=>{i.delete(S.id),I.status>=200&&I.status<300?F():B(new Error(`Upload failed with status ${I.status}`))}),I.addEventListener("error",()=>{i.delete(S.id),B(new Error("Upload failed"))}),I.addEventListener("abort",()=>{i.delete(S.id),B(new Error("Upload cancelled"))}),I.open(j,D.upload_url),Object.entries(O).forEach(([w,$])=>{I.setRequestHeader(w,$)}),!Object.keys(O).some(w=>w.toLowerCase()==="content-type")&&S.file.type&&I.setRequestHeader("Content-Type",S.file.type),i.set(S.id,I),I.send(S.file)})}async function k(S,D){var B;if(DC(D)){await T(S,D);return}const I=o.chunkSize||5*1024*1024,j=V(S.file,I),O=new AbortController;r.set(S.id,O);const F=await h(D.upload_id);F&&(j.forEach(w=>{w.end<=F.bytesUploaded&&(w.uploaded=!0)}),yo(S,F.bytesUploaded));for(const w of j)w.uploaded||(await b(S,D,w,O),yo(S,w.end),(B=o.onUploadProgress)==null||B.call(o,S))}async function T(S,D){var z;const I=new AbortController;r.set(S.id,I);const j={...go(D.headers),"Tus-Resumable":"1.0.0","Upload-Length":String(S.file.size),"Upload-Metadata":LC(S,D)},O=await tc("Resumable upload initialization",()=>fetch(D.upload_url,{method:"POST",headers:j,signal:I.signal}));if(!O.ok)throw new Error(`Failed to initialize resumable upload: ${O.status}`);const F=O.headers.get("Location");if(!F)throw new Error("Resumable upload endpoint did not return upload location");const B=new URL(F,D.upload_url).toString(),w=o.chunkSize||5*1024*1024;let $=0;for(;$<S.file.size;){const W=Math.min($+w,S.file.size),Q=S.file.slice($,W),ye={...go(D.headers),"Tus-Resumable":"1.0.0","Upload-Offset":String($),"Content-Type":"application/offset+octet-stream"},we=await tc("Resumable chunk upload",()=>fetch(B,{method:"PATCH",headers:ye,body:Q,signal:I.signal}));if(we.status===409){const N=Number(we.headers.get("Upload-Offset")??"-1");if(Number.isFinite(N)&&N>=0){$=N;continue}}if(!we.ok)throw new Error(`Resumable chunk upload failed: ${we.status}`);const ie=Number(we.headers.get("Upload-Offset")??String(W));$=Number.isFinite(ie)&&ie>$?ie:W,yo(S,$),(z=o.onUploadProgress)==null||z.call(o,S)}}function V(S,D){const I=[];let j=0,O=0;for(;j<S.size;){const F=Math.min(j+D,S.size);I.push({start:j,end:F,blob:S.slice(j,F),index:O,uploaded:!1}),j=F,O++}return I}async function b(S,D,I,j){const O={...go(D.headers),"Content-Range":`bytes ${I.start}-${I.end-1}/${S.file.size}`,"Content-Type":S.file.type||"application/octet-stream"},F=await fetch(D.upload_url,{method:Kl(D),headers:O,body:I.blob,signal:j.signal});if(!F.ok)throw new Error(`Chunk upload failed: ${F.status}`);I.uploaded=!0}async function h(S){return null}async function _(S){if(!a.value)throw new Error("API client not configured");const D=60;let I=0;for(;I<D;){const j=await a.value.get(`/api/v1/video/${S}`),O=RC(j),F=String(O.processing_status);if(F==="ready")return O;if(F==="failed"||F==="error")throw new Error("Video processing failed");await new Promise(B=>{window.setTimeout(B,5e3)}),I++}throw new Error("Video processing timeout")}function R(S){const D=n.value.get(S);if(!D)return;const I=i.get(S);I&&(I.abort(),i.delete(S));const j=r.get(S);j&&(j.abort(),r.delete(S)),D.status="cancelled",D.error="Upload cancelled",t.value.delete(S)}async function M(S){const D=n.value.get(S);D&&(D.status="pending",D.error="",D.progress=0,D.bytesUploaded=0,await p(D.file))}function x(S){n.value.delete(S),t.value.delete(S),i.delete(S),r.delete(S)}function C(){Array.from(n.value.entries()).forEach(([S,D])=>{D.status==="completed"&&n.value.delete(S)})}function P(S){return`${S.name}-${S.size}-${Date.now()}`}return{uploads:l,isUploading:s,totalProgress:c,openFilePicker:u,handleFileSelect:m,validateFile:f,startUpload:p,cancelUpload:R,retryUpload:M,removeUpload:x,clearCompleted:C,setApiClient:d}}const zC=["accept","multiple"],jC={key:0,class:"upload-trigger","data-testid":"video-uploader-trigger"},WC=["onKeydown"],ZC={key:1,class:"upload-list","data-testid":"video-upload-list"},HC={class:"drag-content"},XC=e.defineComponent({__name:"VideoUploader",props:{collection:{default:"videos"},multiple:{type:Boolean,default:!1},maxFileSize:{default:5*1024*1024*1024},maxDuration:{},allowedFormats:{default:()=>["video/mp4","video/webm","video/quicktime","video/x-msvideo"]},autoUpload:{type:Boolean,default:!0},resumable:{type:Boolean,default:!0},label:{default:"Upload Video"},description:{default:"Click to select or drag and drop"},ownerUuid:{},ownerType:{},apiClient:{}},emits:["upload-start","upload-progress","upload-complete","upload-error","files-selected"],setup(o,{emit:n}){const t=o,a=n,i=e.ref(),r=e.ref(!1),{uploads:s,isUploading:l,handleFileSelect:c,cancelUpload:d,retryUpload:u,removeUpload:m,setApiClient:f}=PC({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:h=>a("upload-start",h),onUploadProgress:h=>a("upload-progress",h),onUploadComplete:h=>a("upload-complete",h),onUploadError:(h,_)=>a("upload-error",h,_),onFilesSelected:h=>a("files-selected",h)});t.apiClient&&f(t.apiClient);const p=e.computed(()=>t.allowedFormats.join(",")),v=e.computed(()=>t.multiple||s.value.length===0);function g(){i.value&&i.value.click()}function k(h){const _=h.target,R=Array.from(_.files||[]);R.length>0&&(c(R),_.value="")}function T(h){var M;h.preventDefault(),r.value=!1;const R=Array.from(((M=h.dataTransfer)==null?void 0:M.files)||[]).filter(x=>x.type.startsWith("video/"));R.length>0&&c(R)}function V(h){var _;h.preventDefault(),(_=h.dataTransfer)!=null&&_.types.includes("Files")&&(r.value=!0)}function b(h){h.target.closest(".video-uploader")||(r.value=!1)}return e.onMounted(()=>{document.addEventListener("dragover",V),document.addEventListener("dragleave",b),document.addEventListener("drop",h=>h.preventDefault())}),e.onUnmounted(()=>{document.removeEventListener("dragover",V),document.removeEventListener("dragleave",b),document.removeEventListener("drop",h=>h.preventDefault())}),(h,_)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-uploader",{"is-uploading":e.unref(l)}]),"data-testid":"video-uploader"},[e.createElementVNode("input",{ref_key:"fileInputEl",ref:i,type:"file",accept:p.value,multiple:h.multiple,onChange:k,"data-testid":"video-uploader-input","aria-label":"Select video files to upload",hidden:""},null,40,zC),!e.unref(l)||v.value?(e.openBlock(),e.createElementBlock("div",jC,[e.renderSlot(h.$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(xc),class:"upload-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("h3",null,e.toDisplayString(h.label),1),e.createElementVNode("p",null,e.toDisplayString(h.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(Xr),slot:"start","aria-hidden":"true"},null,8,["icon"]),_[2]||(_[2]=e.createTextVNode(" Select Video ",-1))]),_:1})],40,WC)],!0)])):e.createCommentVNode("",!0),e.unref(s).length>0?(e.openBlock(),e.createElementBlock("div",ZC,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),R=>(e.openBlock(),e.createBlock(BC,{key:R.id,upload:R,onCancel:M=>e.unref(d)(R.id),onRetry:M=>e.unref(u)(R.id),onRemove:M=>e.unref(m)(R.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:T,onDragover:_[0]||(_[0]=e.withModifiers(()=>{},["prevent"])),onDragleave:_[1]||(_[1]=R=>r.value=!1)},[e.createElementVNode("div",HC,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(na),"aria-hidden":"true"},null,8,["icon"]),_[3]||(_[3]=e.createElementVNode("p",null,"Drop video files here",-1))])],32)):e.createCommentVNode("",!0)],2))}}),GC=Te(XC,[["__scopeId","data-v-ea7587f7"]]),JC=["aria-valuenow","aria-valuemax","aria-label"],YC={class:"progress-bar"},qC={class:"time-display","data-testid":"video-time-display"},KC={class:"current-time"},QC={class:"duration"},eS={class:"control-buttons"},tS={class:"controls-left"},nS=["aria-label"],aS={class:"controls-center"},oS={key:0,class:"volume-controls"},iS=["aria-label"],rS=["value"],sS={class:"controls-right"},lS={key:0,class:"quality-selector"},cS=["aria-expanded"],dS={class:"quality-label"},uS={key:0,class:"quality-menu","data-testid":"video-quality-menu",role:"menu"},mS=["data-testid","aria-label","onClick"],pS=["aria-label"],fS=e.defineComponent({__name:"VideoControls",props:{playing:{type:Boolean},currentTime:{},duration:{},buffered:{},volume:{default:100},muted:{type:Boolean,default:!1},fullscreen:{type:Boolean,default:!1},isLive:{type:Boolean,default:!1},qualityLevels:{default:()=>[]},currentQuality:{default:"Auto"}},emits:["play-pause","play","pause","seek","skip-forward","skip-backward","toggleMute","setVolume","toggleFullscreen","togglePiP","selectQuality"],setup(o,{emit:n}){const t=o,a=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}%`})),m=e.computed(()=>{if(!t.buffered||t.buffered.length===0)return{width:"0%"};for(let h=0;h<t.buffered.length;h++){const _=t.buffered.start(h),R=t.buffered.end(h);if(t.currentTime>=_&&t.currentTime<=R)return{width:`${R/t.duration*100}%`}}return t.buffered.length>0?{width:`${t.buffered.end(0)/t.duration*100}%`}:{width:"0%"}}),f=e.computed(()=>t.muted||t.volume===0?Dp:t.volume<33?Ip:t.volume<66?$p:Fp);let p=null;function v(){i.value=!0,g()}function g(){p&&clearTimeout(p),t.playing&&!l&&(p=setTimeout(()=>{i.value=!1},3e3))}function k(h){if(!s.value||t.isLive)return;const _=s.value.getBoundingClientRect(),M=(h.clientX-_.left)/_.width*t.duration;a("seek",Math.max(0,Math.min(M,t.duration)))}function T(h){const _=h.target;a("setVolume",parseInt(_.value))}function V(h){a("selectQuality",h),r.value=!1}function b(h){if(!isFinite(h))return"0:00";const _=Math.floor(h/3600),R=Math.floor(h%3600/60),M=Math.floor(h%60);return _>0?`${_}:${R.toString().padStart(2,"0")}:${M.toString().padStart(2,"0")}`:`${R}:${M.toString().padStart(2,"0")}`}return e.onMounted(()=>{document.addEventListener("mousemove",v),g()}),e.onUnmounted(()=>{document.removeEventListener("mousemove",v),p&&clearTimeout(p)}),(h,_)=>(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(h.currentTime),"aria-valuemin":"0","aria-valuemax":Math.round(h.duration),"aria-label":h.isLive?"Live stream":"Video progress",tabindex:"0",onClick:k},[e.createElementVNode("div",YC,[e.createElementVNode("div",{class:"progress-buffered",style:e.normalizeStyle(m.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",qC,[e.createElementVNode("span",KC,e.toDisplayString(b(h.currentTime)),1),_[7]||(_[7]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",QC,e.toDisplayString(h.isLive?"LIVE":b(h.duration)),1)])],8,JC),e.createElementVNode("div",eS,[e.createElementVNode("div",tS,[e.createElementVNode("button",{class:"control-btn play-pause","data-testid":"btn-video-play-pause",onClick:_[0]||(_[0]=R=>h.$emit("play-pause")),"aria-label":h.playing?"Pause":"Play"},[e.createVNode(e.unref(U.IonIcon),{icon:h.playing?e.unref(gp):e.unref(bp),"aria-hidden":"true"},null,8,["icon"])],8,nS),h.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"control-btn skip-backward","data-testid":"btn-video-skip-backward",onClick:_[1]||(_[1]=R=>h.$emit("skip-backward")),"aria-label":"Skip backward 10 seconds"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(wp),"aria-hidden":"true"},null,8,["icon"]),_[8]||(_[8]=e.createElementVNode("span",{class:"skip-label"},"10",-1))])),h.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn skip-forward","data-testid":"btn-video-skip-forward",onClick:_[2]||(_[2]=R=>h.$emit("skip-forward")),"aria-label":"Skip forward 10 seconds"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Ep),"aria-hidden":"true"},null,8,["icon"]),_[9]||(_[9]=e.createElementVNode("span",{class:"skip-label"},"10",-1))]))]),e.createElementVNode("div",aS,[e.unref(l)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",oS,[e.createElementVNode("button",{class:"control-btn mute-btn","data-testid":"btn-video-mute",onClick:_[3]||(_[3]=R=>h.$emit("toggleMute")),"aria-label":h.muted?"Unmute":"Mute"},[e.createVNode(e.unref(U.IonIcon),{icon:f.value,"aria-hidden":"true"},null,8,["icon"])],8,iS),e.createElementVNode("input",{type:"range",class:"volume-slider","data-testid":"slider-video-volume",min:"0",max:"100",value:h.muted?0:h.volume,onInput:T,"aria-label":"Volume"},null,40,rS)]))]),e.createElementVNode("div",sS,[h.qualityLevels.length>1?(e.openBlock(),e.createElementBlock("div",lS,[e.createElementVNode("button",{class:"control-btn quality-btn","data-testid":"btn-video-quality",onClick:_[4]||(_[4]=R=>r.value=!r.value),"aria-label":"Quality settings","aria-expanded":r.value},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Tp),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("span",dS,e.toDisplayString(h.currentQuality),1)],8,cS),r.value?(e.openBlock(),e.createElementBlock("div",uS,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.qualityLevels,R=>(e.openBlock(),e.createElementBlock("button",{key:R.label,class:e.normalizeClass(["quality-option",{active:R.label===h.currentQuality}]),"data-testid":`btn-video-quality-${R.label}`,"aria-label":`Set quality to ${R.label}`,role:"menuitem",onClick:M=>V(R)},e.toDisplayString(R.label),11,mS))),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:_[5]||(_[5]=R=>h.$emit("togglePiP")),"aria-label":"Picture in Picture"},[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Mp),"aria-hidden":"true"},null,8,["icon"])])):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"control-btn fullscreen-btn","data-testid":"btn-video-fullscreen",onClick:_[6]||(_[6]=R=>h.$emit("toggleFullscreen")),"aria-label":h.fullscreen?"Exit fullscreen":"Enter fullscreen"},[e.createVNode(e.unref(U.IonIcon),{icon:h.fullscreen?e.unref(sp):e.unref(dp),"aria-hidden":"true"},null,8,["icon"])],8,pS)])])],2))}}),hS=Te(fS,[["__scopeId","data-v-2ae77c13"]]);function vS(o={}){var Q,ye,we;const n=e.ref(),t=e.ref(),a=e.ref(!1),i=e.ref(0),r=e.ref(0),s=e.ref(100),l=e.ref(o.muted||!1),c=e.ref(!1),d=e.ref(),u=e.ref(1),m=e.ref(!1),f=e.ref(null),p=e.ref("idle"),v=e.ref(o.playbackUrl||((Q=o.media)==null?void 0:Q.playback_url)||((ye=o.media)==null?void 0:ye.url)||""),g=e.ref(null),k=e.ref(o.isLive||!1),T=e.ref(null),V=e.ref(null);function b(ie){V.value=ie}if((we=o.media)!=null&&we.token_expires_at){const ie=new Date(o.media.token_expires_at);g.value=Number.isNaN(ie.getTime())?null:ie}async function h(){var N;const ie=k.value?t.value:n.value;if(ie)try{await ie.play(),a.value=!0,p.value=k.value?"live":"playing",(N=o.onPlay)==null||N.call(o)}catch{f.value="Failed to play video",p.value="error"}}function _(){var N;const ie=k.value?t.value:n.value;ie&&(ie.pause(),a.value=!1,p.value="paused",(N=o.onPause)==null||N.call(o))}function R(){a.value?_():h()}function M(ie){const N=k.value?t.value:n.value;if(!N||k.value)return;const L=Number.isFinite(N.duration)?N.duration:ie;N.currentTime=Math.max(0,Math.min(ie,L)),i.value=N.currentTime}function x(ie=10){const N=n.value;!N||k.value||M(N.currentTime+ie)}function C(ie=10){const N=n.value;!N||k.value||M(N.currentTime-ie)}function P(){const ie=k.value?t.value:n.value;ie&&(ie.muted=!ie.muted,l.value=ie.muted)}function S(ie){const N=k.value?t.value:n.value;if(!N)return;const L=Math.max(0,Math.min(100,ie));N.volume=L/100,s.value=L,L>0&&N.muted&&(N.muted=!1,l.value=!1)}function D(ie){const N=n.value;!N||k.value||(N.playbackRate=ie,u.value=ie)}async function I(){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 j(){const ie=k.value?t.value:n.value;if(ie)try{document.pictureInPictureElement?await document.exitPictureInPicture():document.pictureInPictureEnabled&&await ie.requestPictureInPicture()}catch{}}async function O(){var N;f.value=null,p.value="loading",(N=o.media)!=null&&N.provider&&o.media.provider!=="local"&&await F();const ie=k.value?t.value:n.value;ie&&(ie.load(),await h())}async function F(){if(!(!V.value||!o.media))try{m.value=!0;const ie=await V.value.get(`/api/v1/video/${o.media.uuid}/playback`);v.value=ie.playback_url,g.value=new Date(ie.token_expires_at);const N=k.value?t.value:n.value;if(N&&N.src!==v.value){const L=!N.paused,te=N.currentTime;N.src=v.value,k.value||(N.currentTime=te),L&&await h()}}catch{f.value="Failed to refresh playback token",p.value="error"}finally{m.value=!1}}async function B(ie){if(t.value){if(t.value.canPlayType("application/vnd.apple.mpegurl")){t.value.src=ie;return}try{t.value.src=ie}catch{f.value="Live streaming not supported in this browser",p.value="error"}}}function w(){T.value&&(T.value.destroy(),T.value=null)}function $(){var N;const ie=k.value?t.value:n.value;ie&&(i.value=ie.currentTime,r.value=ie.duration,(N=o.onTimeUpdate)==null||N.call(o,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 N=d.value.start(ie),L=d.value.end(ie);if(i.value>=N&&i.value<=L)return L/r.value*100}return 0});function W(){if(!g.value)return!1;const ie=new Date;return g.value.getTime()-ie.getTime()<5*60*1e3}return e.watch([n,t],([ie,N])=>{const L=k.value?N:ie;L&&(L.addEventListener("timeupdate",$),L.addEventListener("loadedmetadata",()=>{r.value=L.duration,p.value="ready"}),L.addEventListener("progress",()=>{d.value=L.buffered}),L.addEventListener("ended",()=>{var te;a.value=!1,p.value="ended",(te=o.onEnded)==null||te.call(o)}),L.addEventListener("error",te=>{var ne;p.value="error",(ne=o.onError)==null||ne.call(o,"Video playback error")}),L.volume=s.value/100,L.muted=l.value)}),e.onUnmounted(()=>{w();const ie=k.value?t.value:n.value;ie&&ie.removeEventListener("timeupdate",$)}),{videoEl:n,liveVideoEl:t,playing:a,currentTime:i,duration:r,volume:s,muted:l,isFullscreen:c,bufferedRanges:d,bufferedPercent:z,playbackRate:u,isLoading:m,error:f,status:p,currentPlaybackUrl:v,tokenExpiresAt:g,play:h,pause:_,togglePlayPause:R,seek:M,skipForward:x,skipBackward:C,toggleMute:P,setVolume:S,setPlaybackRate:D,toggleFullscreen:I,togglePiP:j,retry:O,refreshToken:F,setupLiveStream:B,setApiClient:b,shouldRefreshToken:W}}const gS=["src","poster","controls","autoplay","muted","loop","preload"],yS={key:1,ref:"livePlayerEl",class:"live-player"},bS=["controls","muted"],wS={key:0,class:"live-indicator","data-testid":"video-live-indicator","aria-label":"Live stream"},kS={key:2,class:"video-loading","data-testid":"video-loading",role:"status","aria-label":"Loading video"},_S={key:3,class:"video-error","data-testid":"video-error",role:"alert"},ES={key:5,class:"gesture-zones","data-testid":"video-gesture-zones"},xS=e.defineComponent({__name:"VideoPlayer",props:{media:{},playbackUrl:{},apiClient:{},isLive:{type:Boolean,default:!1},controls:{type:Boolean,default:!0},autoplay:{type:Boolean,default:!1},muted:{type:Boolean,default:!1},loop:{type:Boolean,default:!1},poster:{},preload:{default:"metadata"},showCustomControls:{type:Boolean,default:!1},enableGestures:{type:Boolean,default:!0},className:{},crossorigin:{}},emits:["play","pause","ended","error","timeupdate","loadedmetadata","progress"],setup(o,{emit:n}){const t=o,a=n,{videoEl:i,liveVideoEl:r,playing:s,currentTime:l,duration:c,volume:d,muted:u,isFullscreen:m,bufferedRanges:f,isLoading:p,error:v,status:g,currentPlaybackUrl:k,tokenExpiresAt:T,play:V,pause:b,seek:h,toggleMute:_,setVolume:R,toggleFullscreen:M,togglePlayPause:x,skipForward:C,skipBackward:P,retry:S,refreshToken:D,setApiClient:I,shouldRefreshToken:j,setupLiveStream:O}=vS({...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 F(){await D()}const B=e.computed(()=>{const ne=["video-player-container"];return t.className&&ne.push(t.className),m.value&&ne.push("fullscreen"),t.isLive&&ne.push("is-live"),s.value&&ne.push("is-playing"),p.value&&ne.push("is-loading"),ne}),w=e.computed(()=>{var ne,re;if(t.poster)return t.poster;if((ne=t.media)!=null&&ne.poster_url)return t.media.poster_url;if((re=t.media)!=null&&re.thumbnail_url)return t.media.thumbnail_url});function $(ne){const re=ne.target;a("loadedmetadata",{duration:re.duration,width:re.videoWidth,height:re.videoHeight})}function z(ne){const re=ne.target;l.value=re.currentTime,a("timeupdate",re.currentTime)}function W(){s.value=!0,a("play")}function Q(){s.value=!1,a("pause")}function ye(){s.value=!1,a("ended")}function we(ne){const re=ne.target;let he="Failed to load video";if(re.error)switch(re.error.code){case re.error.MEDIA_ERR_ABORTED:he="Video playback aborted";break;case re.error.MEDIA_ERR_NETWORK:he="Network error while loading video";break;case re.error.MEDIA_ERR_DECODE:he="Video decoding error";break;case re.error.MEDIA_ERR_SRC_NOT_SUPPORTED:he="Video format not supported";break}v.value=he,a("error",he)}function ie(ne){const re=ne.target;f.value=re.buffered,a("progress",re.buffered)}function N(){p.value=!0}function L(){p.value=!1}e.watch(()=>t.apiClient,ne=>{ne&&I(ne)},{immediate:!0}),e.watch(()=>t.playbackUrl,ne=>{typeof ne=="string"&&ne.length>0&&(k.value=ne)},{immediate:!0}),e.watch(()=>{var ne;return(ne=t.media)==null?void 0:ne.token_expires_at},ne=>{if(!ne){T.value=null;return}const re=new Date(ne);T.value=Number.isNaN(re.getTime())?null:re},{immediate:!0}),e.watch(()=>{var ne;return(ne=t.media)==null?void 0:ne.playback_url},async(ne,re)=>{if(t.playbackUrl||!ne||ne===re)return;const he=i.value;if(!he||t.isLive){k.value=ne;return}const de=!he.paused,me=he.currentTime;k.value=ne,await e.nextTick();try{he.currentTime=me}catch{}de&&await V()},{immediate:!0});let te=null;return e.watch(()=>t.isLive,async ne=>{var he;if(!ne)return;const re=t.playbackUrl||((he=t.media)==null?void 0:he.playback_url)||"";re&&await O(re)},{immediate:!0}),e.onMounted(()=>{var ne;(ne=t.media)!=null&&ne.provider&&t.media.provider!=="local"&&(te=setInterval(()=>{j()&&F()},3e4)),U.isPlatform("mobile")&&t.showCustomControls}),e.onUnmounted(()=>{te&&clearInterval(te)}),(ne,re)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-player-container",B.value]),"data-testid":"video-player"},[ne.isLive?(e.openBlock(),e.createElementBlock("div",yS,[e.createElementVNode("video",{ref_key:"liveVideoEl",ref:r,controls:ne.controls&&!ne.showCustomControls,autoplay:!0,muted:e.unref(u),onPlay:W,onPause:Q,onError:we,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,bS),e.unref(g)==="live"?(e.openBlock(),e.createElementBlock("div",wS,[...re[3]||(re[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:ne.controls&&!ne.showCustomControls,autoplay:ne.autoplay,muted:e.unref(u),loop:ne.loop,preload:ne.preload,onLoadedmetadata:$,onTimeupdate:z,onPlay:W,onPause:Q,onEnded:ye,onError:we,onProgress:ie,onWaiting:N,onCanplay:L,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,gS)),e.unref(p)?(e.openBlock(),e.createElementBlock("div",kS,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),e.unref(v)?(e.openBlock(),e.createElementBlock("div",_S,[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Gr),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(e.unref(v)),1),e.createVNode(e.unref(U.IonButton),{size:"small",onClick:e.unref(S),"data-testid":"btn-video-retry","aria-label":"Retry loading video"},{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonIcon),{icon:e.unref(Un),slot:"start","aria-hidden":"true"},null,8,["icon"]),re[4]||(re[4]=e.createTextVNode(" Retry ",-1))]),_:1},8,["onClick"])])):e.createCommentVNode("",!0),ne.showCustomControls&&!e.unref(v)?(e.openBlock(),e.createBlock(hS,{key:4,playing:e.unref(s),currentTime:e.unref(l),duration:e.unref(c),buffered:e.unref(f),volume:e.unref(d),muted:e.unref(u),fullscreen:e.unref(m),isLive:ne.isLive,onPlay:e.unref(V),onPause:e.unref(b),onSeek:e.unref(h),onToggleMute:e.unref(_),onSetVolume:e.unref(R),onToggleFullscreen:e.unref(M),class:"custom-controls"},null,8,["playing","currentTime","duration","buffered","volume","muted","fullscreen","isLive","onPlay","onPause","onSeek","onToggleMute","onSetVolume","onToggleFullscreen"])):e.createCommentVNode("",!0),ne.enableGestures&&!e.unref(v)?(e.openBlock(),e.createElementBlock("div",ES,[e.createElementVNode("div",{class:"gesture-left","data-testid":"video-gesture-skip-back","aria-label":"Double tap to skip backward",onDblclick:re[0]||(re[0]=(...he)=>e.unref(P)&&e.unref(P)(...he))},null,32),e.createElementVNode("div",{class:"gesture-center","data-testid":"video-gesture-play-pause","aria-label":"Tap to play or pause",onClick:re[1]||(re[1]=(...he)=>e.unref(x)&&e.unref(x)(...he))}),e.createElementVNode("div",{class:"gesture-right","data-testid":"video-gesture-skip-forward","aria-label":"Double tap to skip forward",onDblclick:re[2]||(re[2]=(...he)=>e.unref(C)&&e.unref(C)(...he))},null,32)])):e.createCommentVNode("",!0)],2))}}),Ud=Te(xS,[["__scopeId","data-v-b8db4951"]]),CS=Xo.defineStore("video",()=>{const o=e.ref(new Map),n=e.ref(new Map),t=e.ref(new Map),a=e.ref(null),i=e.ref(!1),r=e.computed(()=>Array.from(o.value.values())),s=e.computed(()=>Array.from(n.value.values())),l=e.computed(()=>s.value.filter(O=>O.status==="live")),c=e.computed(()=>r.value.filter(O=>O.processing_status==="processing"));function d(O){o.value.set(O.uuid,O)}function u(O,F){const B=o.value.get(O);B&&o.value.set(O,{...B,...F})}function m(O){o.value.delete(O)}function f(O){return o.value.get(O)}function p(O){n.value.set(O.id,O)}function v(O,F){const B=n.value.get(O);B&&n.value.set(O,{...B,...F})}function g(O,F){const B=n.value.get(O);B&&n.value.set(O,{...B,status:F.status,viewer_count:F.viewer_count,peak_viewers:F.peak_viewers})}function k(O){n.value.delete(O)}function T(O){return n.value.get(O)}function V(O){return s.value.find(F=>F.media_uuid===O)}function b(O){t.value.set(O.id,O)}function h(O,F){const B=t.value.get(O);B&&t.value.set(O,{...B,...F})}function _(O){t.value.delete(O)}function R(O){return t.value.get(O)}function M(O){return Array.from(t.value.values()).filter(F=>F.media_uuid===O)}function x(O){a.value=O}function C(O){a.value&&(a.value={...a.value,...O})}function P(){a.value=null}function S(O){i.value=O}function D(){o.value.clear(),n.value.clear(),t.value.clear(),a.value=null,i.value=!1}function I(O){o.value.clear(),O.forEach(F=>{o.value.set(F.uuid,F)})}function j(O){n.value.clear(),O.forEach(F=>{n.value.set(F.id,F)})}return{videos:o,liveStreams:n,exportJobs:t,currentEditorState:a,isProcessing:i,allVideos:r,allLiveStreams:s,activeLiveStreams:l,processingVideos:c,setVideo:d,updateVideo:u,removeVideo:m,getVideo:f,setLiveStream:p,updateLiveStream:v,updateLiveStreamStats:g,removeLiveStream:k,getLiveStream:T,getLiveStreamByMedia:V,addExportJob:b,updateExportJob:h,removeExportJob:_,getExportJob:R,getExportJobsByMedia:M,setEditorState:x,updateEditorState:C,clearEditorState:P,setProcessing:S,clearAll:D,loadVideos:I,loadLiveStreams:j}});let Tn=null;function SS(o){Tn=o}const bo={post:async(o,n)=>{if(!Tn)throw new Error("HTTP client not configured");return await Tn(`/api/v1/video${o}`,{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json"}})},get:async o=>{if(!Tn)throw new Error("HTTP client not configured");return await Tn(`/api/v1/video${o}`)},delete:async o=>{if(!Tn)throw new Error("HTTP client not configured");return await Tn(`/api/v1/video${o}`,{method:"DELETE"})}};function wo(o,n=null){const t=typeof o.id=="string"&&o.id!==""?o.id:typeof o.stream_id=="string"&&o.stream_id!==""?o.stream_id:n==null?void 0:n.id;if(!t)throw new Error("Invalid live stream response: missing stream id");const a={id:t,media_uuid:o.media_uuid??(n==null?void 0:n.media_uuid)??"",stream_key:o.stream_key??(n==null?void 0:n.stream_key)??"",rtmp_url:o.rtmp_url??(n==null?void 0:n.rtmp_url)??"",status:o.status??(n==null?void 0:n.status)??"idle",viewer_count:o.viewer_count??(n==null?void 0:n.viewer_count)??0,peak_viewers:o.peak_viewers??(n==null?void 0:n.peak_viewers)??0,auto_record:o.auto_record??(n==null?void 0:n.auto_record)??!0,low_latency:o.low_latency??(n==null?void 0:n.low_latency)??!1},i=o.playback_url??(n==null?void 0:n.playback_url);i!==void 0&&(a.playback_url=i);const r=o.started_at??(n==null?void 0:n.started_at);r!==void 0&&(a.started_at=r);const s=o.ended_at??(n==null?void 0:n.ended_at);return s!==void 0&&(a.ended_at=s),(n==null?void 0:n.metadata)!==void 0&&(a.metadata=n.metadata),(n==null?void 0:n.vod_media_uuid)!==void 0&&(a.vod_media_uuid=n.vod_media_uuid),a}function cr(o,n){return o instanceof Error&&o.message?o.message:n}function VS(o){const n=CS(),t=e.ref(null),a=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),m=e.ref(0);let f;const p=e.computed(()=>d.value?Math.floor((new Date().getTime()-d.value.getTime())/1e3):0),v=e.computed(()=>{var P;if(!((P=t.value)!=null&&P.playback_url))return null;const C=new URL(t.value.playback_url);return C.searchParams.set("live","true"),a.value&&C.searchParams.set("latency","low"),C.toString()}),g=e.computed(()=>{var C;return((C=t.value)==null?void 0:C.status)==="live"}),k=e.computed(()=>{var C;return((C=t.value)==null?void 0:C.status)==="idle"}),T=e.computed(()=>{var C;return((C=t.value)==null?void 0:C.status)==="ended"});async function V(C={}){s.value=!0,c.value=null;try{const P=await bo.post("/live",{title:r.value||C.title||"Live Stream",low_latency:C.low_latency??a.value,auto_record:C.auto_record??i.value,...C}),S=wo(P);return t.value=S,n.setLiveStream(S),R(),S}catch(P){throw c.value=cr(P,"Failed to create stream"),P instanceof Error?P:new Error(c.value)}finally{s.value=!1}}async function b(){if(!t.value)throw new Error("No active stream");l.value=!0,c.value=null;try{const C=await bo.post(`/live/${t.value.id}/end`),P=wo(C,t.value);return t.value=P,n.setLiveStream(P),M(),P}catch(C){throw c.value=cr(C,"Failed to end stream"),C instanceof Error?C:new Error(c.value)}finally{l.value=!1}}async function h(){if(t.value)try{const C=await bo.get(`/live/${t.value.id}`),P=wo(C,t.value);u.value=P.viewer_count,m.value=P.peak_viewers,t.value=P;const S={status:P.status,viewer_count:P.viewer_count,peak_viewers:P.peak_viewers};P.started_at&&(S.started_at=P.started_at),P.ended_at&&(S.ended_at=P.ended_at),n.updateLiveStreamStats(P.id,S),P.status==="live"&&!d.value&&P.started_at&&(d.value=new Date(P.started_at)),P.status==="ended"&&M()}catch{}}async function _(C){try{const P=await bo.get(`/live/${C}`),S=wo(P,t.value);return{rtmp_url:S.rtmp_url,stream_key:S.stream_key,playback_url:S.playback_url||""}}catch(P){throw c.value=cr(P,"Failed to get stream credentials"),P instanceof Error?P:new Error(c.value)}}function R(C=5e3){M(),f=window.setInterval(()=>{h()},C)}function M(){f!==void 0&&(clearInterval(f),f=void 0)}async function x(){if(!o)return;const C=n.getLiveStreamByMedia(o);C&&(t.value=C,u.value=C.viewer_count,m.value=C.peak_viewers,C.status==="live"&&(R(),C.started_at&&(d.value=new Date(C.started_at))))}return o&&x(),e.onUnmounted(()=>{M()}),{stream:t,lowLatency:a,autoRecord:i,streamTitle:r,isCreating:s,isEnding:l,error:c,streamDuration:p,viewerCount:u,peakViewers:m,playbackUrl:v,isLive:g,isIdle:k,hasEnded:T,createStream:V,endStream:b,refreshStreamStatus:h,getStreamCredentials:_,startStatusPolling:R,stopStatusPolling:M}}const NS={class:"stream-status"},TS={class:"flex items-center justify-between"},MS={class:"flex items-center gap-3"},BS={key:0,class:"flex items-center"},FS={key:2,class:"text-sm text-gray-600"},IS={key:0,class:"flex items-center gap-2"},$S={class:"text-sm font-medium text-gray-700"},RS={key:0,class:"text-xs text-gray-500"},DS=e.defineComponent({__name:"StreamStatus",props:{status:{},viewers:{},peakViewers:{},duration:{}},setup(o){const n=o,t=e.computed(()=>({idle:"Ready to Stream",live:"Live",ended:"Stream Ended",error:"Error"})[n.status]||n.status),a=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",NS,[e.createElementVNode("div",TS,[e.createElementVNode("div",MS,[r.status==="live"?(e.openBlock(),e.createElementBlock("div",BS,[...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(a.value)},e.toDisplayString(t.value),3)),i.value?(e.openBlock(),e.createElementBlock("div",FS,e.toDisplayString(i.value),1)):e.createCommentVNode("",!0)]),r.viewers!==void 0?(e.openBlock(),e.createElementBlock("div",IS,[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",$S,e.toDisplayString(r.viewers)+" "+e.toDisplayString(r.viewers===1?"viewer":"viewers"),1),r.peakViewers>r.viewers?(e.openBlock(),e.createElementBlock("span",RS," (Peak: "+e.toDisplayString(r.peakViewers)+") ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])]))}}),AS=Te(DS,[["__scopeId","data-v-1d09c19f"]]),LS={class:"stream-credentials"},US={class:"space-y-3"},OS={class:"credential-field"},PS={class:"flex gap-2"},zS=["value"],jS={class:"credential-field"},WS={class:"flex gap-2"},ZS=["value","type"],HS=["aria-label"],XS={key:0,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},GS={key:1,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},JS={key:0,class:"mt-2 text-sm text-green-600"},YS=e.defineComponent({__name:"StreamCredentials",props:{rtmpUrl:{},streamKey:{}},emits:["copy"],setup(o,{emit:n}){const t=o,a=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,a("copy",d,u),setTimeout(()=>{r.value=""},2e3)}catch{}}return(d,u)=>(e.openBlock(),e.createElementBlock("div",LS,[u[8]||(u[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Stream Settings",-1)),e.createElementVNode("div",US,[e.createElementVNode("div",OS,[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",PS,[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,zS),e.createElementVNode("button",{onClick:u[0]||(u[0]=m=>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",jS,[u[7]||(u[7]=e.createElementVNode("label",{class:"block text-xs font-medium text-gray-500 mb-1"},"Stream Key",-1)),e.createElementVNode("div",WS,[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,ZS),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",GS,[...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",XS,[...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,HS),e.createElementVNode("button",{onClick:u[1]||(u[1]=m=>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",JS,e.toDisplayString(r.value)+" copied to clipboard! ",1)):e.createCommentVNode("",!0)]),_:1})]))}}),qS=Te(YS,[["__scopeId","data-v-306d92f6"]]),KS={class:"live-stream-manager","data-testid":"live-stream-manager"},QS={key:0,class:"stream-setup"},eV={class:"space-y-4"},tV={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},nV={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},aV=["disabled"],oV={key:0},iV={key:1,class:"flex items-center justify-center"},rV={key:1,class:"stream-active space-y-6"},sV={key:1,class:"video-preview"},lV={key:2,class:"analytics-panel"},cV={class:"grid grid-cols-2 gap-4"},dV={class:"bg-gray-50 p-3 rounded"},uV={class:"text-2xl font-bold text-gray-900"},mV={class:"bg-gray-50 p-3 rounded"},pV={class:"text-2xl font-bold text-gray-900"},fV={class:"stream-controls flex gap-3"},hV=["disabled"],vV={key:0},gV={key:1},yV={key:2,class:"mt-4 p-4 bg-red-50 border border-red-200 rounded-lg"},bV={class:"text-red-600 text-sm"},wV=e.defineComponent({__name:"LiveStreamManager",props:{mediaUuid:{},onStreamCreated:{type:Function},onStreamEnded:{type:Function},httpClient:{type:Function}},emits:["stream-created","stream-ended","error"],setup(o,{emit:n}){const t=o,a=n;t.httpClient&&SS(t.httpClient);const{stream:i,lowLatency:r,autoRecord:s,streamTitle:l,isCreating:c,isEnding:d,error:u,createStream:m,endStream:f,streamDuration:p,playbackUrl:v,refreshStreamStatus:g}=VS(t.mediaUuid),k=e.ref(!1);async function T(){var R;try{const M=await m({title:l.value,low_latency:r.value,auto_record:s.value});a("stream-created",M),(R=t.onStreamCreated)==null||R.call(t,M)}catch(M){a("error",M)}}async function V(){var R;try{const M=await f();a("stream-ended",M),(R=t.onStreamEnded)==null||R.call(t,M)}catch(M){a("error",M)}}function b(){i.value=null,l.value="",k.value=!1,u.value=null}async function h(R,M){try{await navigator.clipboard.writeText(R)}catch{}}let _;return e.onMounted(()=>{var R;((R=i.value)==null?void 0:R.status)==="live"&&(_=window.setInterval(()=>{g()},5e3))}),e.onUnmounted(()=>{_&&clearInterval(_)}),(R,M)=>(e.openBlock(),e.createElementBlock("div",KS,[e.unref(i)?(e.openBlock(),e.createElementBlock("div",rV,[e.createVNode(AS,{status:e.unref(i).status,viewers:e.unref(i).viewer_count,duration:e.unref(p),"peak-viewers":e.unref(i).peak_viewers},null,8,["status","viewers","duration","peak-viewers"]),e.unref(i).status==="idle"?(e.openBlock(),e.createBlock(qS,{key:0,"rtmp-url":e.unref(i).rtmp_url,"stream-key":e.unref(i).stream_key,onCopy:h},null,8,["rtmp-url","stream-key"])):e.createCommentVNode("",!0),e.unref(v)?(e.openBlock(),e.createElementBlock("div",sV,[M[9]||(M[9]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-2"},"Live Preview",-1)),e.createVNode(Ud,{"playback-url":e.unref(v),"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",lV,[M[12]||(M[12]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Live Analytics",-1)),e.createElementVNode("div",cV,[e.createElementVNode("div",dV,[e.createElementVNode("div",uV,e.toDisplayString(e.unref(i).viewer_count),1),M[10]||(M[10]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Current Viewers",-1))]),e.createElementVNode("div",mV,[e.createElementVNode("div",pV,e.toDisplayString(e.unref(i).peak_viewers),1),M[11]||(M[11]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Peak Viewers",-1))])])])):e.createCommentVNode("",!0),e.createElementVNode("div",fV,[e.unref(i).status==="idle"?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:M[3]||(M[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:V,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",gV,"Ending...")):(e.openBlock(),e.createElementBlock("span",vV,"End Stream"))],8,hV)):e.createCommentVNode("",!0),e.unref(i).status==="ended"?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:b,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",QS,[M[8]||(M[8]=e.createElementVNode("h3",{class:"text-lg font-semibold mb-4"},"Start Live Stream",-1)),e.createElementVNode("div",eV,[e.createElementVNode("div",tV,[M[4]||(M[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":M[0]||(M[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",nV,[M[5]||(M[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":M[1]||(M[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,[M[6]||(M[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":M[2]||(M[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:T,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",iV,[...M[7]||(M[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",oV,"Create Stream"))],8,aV)])])),e.unref(u)?(e.openBlock(),e.createElementBlock("div",yV,[e.createElementVNode("p",bV,e.toDisplayString(e.unref(u)),1)])):e.createCommentVNode("",!0)]))}}),kV=Te(wV,[["__scopeId","data-v-26291f6f"]]),_V={class:"album-tree-node"},EV=["data-album-id","draggable","aria-selected","aria-expanded"],xV={key:1,class:"album-node__chevron-placeholder"},CV={key:2,"data-testid":"media-count",class:"album-node__count"},SV={key:0,class:"album-tree-node__children",role:"group"},VV=16,NV=e.defineComponent({__name:"AlbumTreeNode",props:{album:{},depth:{},selectedId:{},expandedIds:{},focusedId:{},draggable:{type:Boolean},showMediaCount:{type:Boolean},compact:{type:Boolean},dragState:{}},emits:["select","toggle-expand","drag-start","drag-over","drag-leave","drop"],setup(o,{emit:n}){const t=o,a=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*VV}px`),d=e.computed(()=>{var b;return((b=t.dragState)==null?void 0:b.draggedAlbumId)===t.album.id}),u=e.computed(()=>{var b;return((b=t.dragState)==null?void 0:b.dropTargetId)===t.album.id}),m=e.computed(()=>{var b;return(b=t.dragState)!=null&&b.draggedAlbumId?t.dragState.draggedAlbumId===t.album.id:!1}),f=e.computed(()=>{const b=["album-node"];return r.value&&b.push("album-node--selected"),s.value&&b.push("album-node--focused"),t.compact&&b.push("album-node--compact"),d.value&&b.push("album-node--dragging"),u.value&&b.push("album-node--drop-target"),m.value&&b.push("album-node--invalid-drop"),b});function p(){a("select",t.album)}function v(b){b.stopPropagation(),a("toggle-expand",t.album.id)}function g(b){t.draggable&&(b.dataTransfer&&(b.dataTransfer.setData("text/plain",t.album.id),b.dataTransfer.effectAllowed="move"),a("drag-start",t.album.id))}function k(b){t.draggable&&(b.preventDefault(),b.dataTransfer&&(b.dataTransfer.dropEffect="move"),a("drag-over",t.album.id))}function T(){a("drag-leave",t.album.id)}function V(b){t.draggable&&(b.preventDefault(),a("drop",t.album.id))}return(b,h)=>{var R;const _=e.resolveComponent("AlbumTreeNode",!0);return e.openBlock(),e.createElementBlock("div",_V,[e.createElementVNode("div",{"data-testid":"album-node","data-album-id":b.album.id,class:e.normalizeClass(f.value),style:e.normalizeStyle({paddingLeft:c.value}),draggable:b.draggable,role:"treeitem","aria-selected":r.value,"aria-expanded":l.value?i.value:void 0,onDragstart:g,onDragover:k,onDragleave:T,onDrop:V},[l.value?(e.openBlock(),e.createElementBlock("button",{key:0,"data-testid":"expand-chevron",class:"album-node__chevron",type:"button","aria-label":"Toggle expand",onClick:v},[e.createVNode(e.unref(U.IonIcon),{icon:i.value?e.unref(op):e.unref(ip)},null,8,["icon"])])):(e.openBlock(),e.createElementBlock("span",xV)),e.createVNode(e.unref(U.IonIcon),{icon:e.unref(pp),class:"album-node__icon"},null,8,["icon"]),e.createElementVNode("span",{"data-testid":"album-name",class:"album-node__name",onClick:p},e.toDisplayString(b.album.name),1),b.showMediaCount?(e.openBlock(),e.createElementBlock("span",CV,e.toDisplayString(b.album.media_count),1)):e.createCommentVNode("",!0)],46,EV),i.value&&((R=b.album.children)!=null&&R.length)?(e.openBlock(),e.createElementBlock("div",SV,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.album.children,M=>(e.openBlock(),e.createBlock(_,{key:M.id,album:M,depth:b.depth+1,"selected-id":b.selectedId,"expanded-ids":b.expandedIds,"focused-id":b.focusedId,draggable:b.draggable,"show-media-count":b.showMediaCount,compact:b.compact,onSelect:h[0]||(h[0]=x=>a("select",x)),onToggleExpand:h[1]||(h[1]=x=>a("toggle-expand",x))},null,8,["album","depth","selected-id","expanded-ids","focused-id","draggable","show-media-count","compact"]))),128))])):e.createCommentVNode("",!0)])}}}),TV=Te(NV,[["__scopeId","data-v-76be65a6"]]),bi=Xo.defineStore("albums",()=>{const o=e.ref([]),n=e.ref(new Map),t=e.ref(!1),a=e.ref(null),i=e.ref(new Set),r=e.computed(()=>{const h=new Map;return o.value.forEach(_=>h.set(_.id,_)),h}),s=e.computed(()=>o.value.filter(h=>h.parent_id===null));async function l(h){t.value=!0,a.value=null;try{const _=(h==null?void 0:h.parent_id)??null,R=_?`/api/v1/albums?parent_id=${_}`:"/api/v1/albums?parent_id=null",M=await fetch(R);if(!M.ok)throw new Error("Failed to fetch albums");((await M.json()).data||[]).forEach(P=>{const S=o.value.findIndex(D=>D.id===P.id);S>=0?o.value[S]=P:o.value.push(P)}),_!==null&&i.value.add(_)}catch(_){a.value=_ instanceof Error?_.message:"Unknown error"}finally{t.value=!1}}async function c(h){t.value=!0,a.value=null;try{const _=await fetch(`/api/v1/albums/${h}`);if(!_.ok)throw new Error("Failed to fetch album");const M=(await _.json()).data,x=o.value.findIndex(C=>C.id===M.id);return x>=0?o.value[x]=M:o.value.push(M),M}catch(_){throw a.value=_ instanceof Error?_.message:"Unknown error",_}finally{t.value=!1}}async function d(h){t.value=!0,a.value=null;try{const _=await fetch(`/api/v1/albums/${h}/media`);if(!_.ok)throw new Error("Failed to fetch album media");const M=(await _.json()).data||[];return n.value.set(h,M),M}catch(_){throw a.value=_ instanceof Error?_.message:"Unknown error",_}finally{t.value=!1}}async function u(h,_){t.value=!0,a.value=null;try{if(!(await fetch(`/api/v1/albums/${h}/media/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({media_ids:_})})).ok)throw new Error("Failed to reorder album media");const M=n.value.get(h)||[],x=_.map(C=>M.find(P=>P.uuid===C)).filter(C=>C!==void 0);n.value.set(h,x)}catch(R){throw a.value=R instanceof Error?R.message:"Unknown error",R}finally{t.value=!1}}async function m(h){t.value=!0,a.value=null;try{const _=await fetch("/api/v1/albums",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(h)});if(!_.ok)throw new Error("Failed to create album");const M=(await _.json()).data;return o.value.push(M),M}catch(_){throw a.value=_ instanceof Error?_.message:"Unknown error",_}finally{t.value=!1}}async function f(h,_){t.value=!0,a.value=null;try{const R=await fetch(`/api/v1/albums/${h}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(_)});if(!R.ok)throw new Error("Failed to update album");const x=(await R.json()).data,C=o.value.findIndex(P=>P.id===x.id);return C>=0&&(o.value[C]=x),x}catch(R){throw a.value=R instanceof Error?R.message:"Unknown error",R}finally{t.value=!1}}async function p(h){t.value=!0,a.value=null;try{if(!(await fetch(`/api/v1/albums/${h}`,{method:"DELETE",headers:{"Content-Type":"application/json"},credentials:"include"})).ok)throw new Error("Failed to delete album");const R=o.value.findIndex(M=>M.id===h);R>=0&&o.value.splice(R,1),n.value.delete(h)}catch(_){throw a.value=_ instanceof Error?_.message:"Unknown error",_}finally{t.value=!1}}function v(h){return o.value.filter(_=>_.parent_id===h)}function g(h){return i.value.has(h)}function k(h){return n.value.get(h)||[]}async function T(h,_){const R=o.value.findIndex(x=>x.id===h);if(R<0)return;const M=o.value[R];o.value[R]={...M,parent_id:_};try{if(!(await fetch(`/api/v1/albums/${h}/move`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({parent_id:_})})).ok)throw new Error("Failed to move album")}catch(x){throw o.value[R]=M,a.value=x instanceof Error?x.message:"Unknown error",x instanceof Error?x:new Error("Failed to move album")}}function V(h){o.value=h}function b(){o.value=[],n.value.clear(),t.value=!1,a.value=null,i.value.clear()}return{albums:o,albumMedia:n,loading:t,error:a,childrenLoadedById:i,albumsById:r,rootAlbums:s,fetchAlbums:l,fetchAlbum:c,fetchAlbumMedia:d,reorderAlbumMedia:u,createAlbum:m,updateAlbum:f,deleteAlbum:p,getChildrenOf:v,childrenLoaded:g,getAlbumMedia:k,moveAlbum:T,setAlbums:V,reset:b}});function Od(){const o=bi(),{albums:n,albumsById:t,rootAlbums:a,loading:i,error:r}=Xo.storeToRefs(o);async function s(u){await o.fetchAlbums(u)}function l(u){return o.getChildrenOf(u)}function c(u){return o.childrenLoaded(u)}async function d(u,m){await o.moveAlbum(u,m)}return{albums:n,albumsById:t,rootAlbums:a,loading:i,error:r,fetchAlbums:s,getChildrenOf:l,childrenLoaded:c,moveAlbum:d}}function Pd(o){const{childrenByParentId:n,onMove:t}=o,a=e.ref({isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null});function i(m,f){if(m===f)return!0;const p=new Set,v=[m];for(;v.length>0;){const g=v.shift();if(!g||p.has(g))continue;p.add(g);const k=n.get(g)||[];for(const T of k){if(T===f)return!0;v.push(T)}}return!1}function r(m,f){return m===f?!1:f===null?!0:!i(m,f)}function s(m){a.value={isDragging:!0,draggedAlbumId:m,dropTargetId:null,dropPosition:null}}function l(){a.value={isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null}}function c(m){a.value.dropTargetId=m}function d(){a.value.dropTargetId=null,a.value.dropPosition=null}async function u(){const{draggedAlbumId:m,dropTargetId:f}=a.value;if(!m){l();return}if(!r(m,f)){l();return}try{await t(m,f)}finally{l()}}return{dragState:a,isDescendant:i,canDropOn:r,startDrag:s,endDrag:l,setDropTarget:c,clearDropTarget:d,executeDrop:u}}const MV={key:0,"data-testid":"loading-spinner",class:"album-tree__loading"},BV={key:1,"data-testid":"error-state",class:"album-tree__error"},FV={key:2,"data-testid":"empty-state",class:"album-tree__empty"},IV={key:3,class:"album-tree__content",role:"group"},$V=e.defineComponent({__name:"AlbumTree",props:{modelValue:{default:null},expandedIds:{default:()=>[]},draggable:{type:Boolean,default:!0},showMediaCount:{type:Boolean,default:!0},compact:{type:Boolean,default:!1}},emits:["update:modelValue","album-selected","album-moved","album-expanded","album-collapsed"],setup(o,{expose:n,emit:t}){const a=o,i=t,r=e.computed(()=>a.draggable===!0),s=e.computed(()=>a.showMediaCount===!0),l=e.computed(()=>a.compact===!0),{albums:c,rootAlbums:d,loading:u,error:m,fetchAlbums:f,getChildrenOf:p,childrenLoaded:v,moveAlbum:g}=Od(),k=e.shallowRef(new Set(a.expandedIds)),T=e.ref(a.modelValue??null),V=e.ref(null),b=new Map,h=new Map;function _(N){b.clear(),h.clear();for(const L of N){b.set(L.id,L);const te=L.parent_id??null,ne=h.get(te)??[];ne.push(L.id),h.set(te,ne)}}e.watch(c,N=>{_(N)},{immediate:!0});const{dragState:R,canDropOn:M,startDrag:x,endDrag:C,setDropTarget:P,clearDropTarget:S,executeDrop:D}=Pd({childrenByParentId:h,onMove:async(N,L)=>{await g(N,L),i("album-moved",{albumId:N,newParentId:L})}});e.watch(()=>a.modelValue,N=>{T.value=N??null}),e.watch(()=>a.expandedIds,N=>{k.value=new Set(N)}),e.onMounted(async()=>{await f({parent_id:null})});const I=e.computed(()=>d.value.map(N=>j(N)));function j(N){if(!k.value.has(N.id))return N;const L=p(N.id);return{...N,children:L.map(te=>j(te))}}const O=e.computed(()=>{const N=[];function L(te){var ne;for(const re of te)N.push(re),k.value.has(re.id)&&((ne=re.children)!=null&&ne.length)&&L(re.children)}return L(I.value),N});function F(N){var ne;if(!O.value.length)return;const L=V.value?O.value.findIndex(re=>re.id===V.value):-1,te=L>=0?O.value[L]:null;switch(N.key){case"ArrowDown":N.preventDefault(),L<O.value.length-1?V.value=O.value[L+1].id:L===-1&&O.value.length>0&&(V.value=O.value[0].id);break;case"ArrowUp":N.preventDefault(),L>0&&(V.value=O.value[L-1].id);break;case"ArrowRight":N.preventDefault(),te&&(te.children_count>0&&!k.value.has(te.id)?B(te.id):k.value.has(te.id)&&((ne=te.children)!=null&&ne.length)&&(V.value=te.children[0].id));break;case"ArrowLeft":N.preventDefault(),te&&(k.value.has(te.id)&&te.children_count>0?B(te.id):te.parent_id&&(V.value=te.parent_id));break;case"Enter":case" ":N.preventDefault(),te&&w(te);break;case"Home":N.preventDefault(),O.value.length>0&&(V.value=O.value[0].id);break;case"End":N.preventDefault(),O.value.length>0&&(V.value=O.value[O.value.length-1].id);break}}async function B(N){k.value.has(N)?(k.value.delete(N),i("album-collapsed",N)):(v(N)||await f({parent_id:N}),k.value.add(N),i("album-expanded",N))}function w(N){T.value=N.id,i("update:modelValue",N.id),i("album-selected",N)}function $(N){a.draggable&&x(N)}function z(N){var te;if(!a.draggable)return;const L=(te=R.value)==null?void 0:te.draggedAlbumId;L&&(P(N),M(L,N))}function W(){a.draggable&&S()}async function Q(N){a.draggable&&(P(N),await D())}function ye(N){a.draggable&&(N.preventDefault(),P(null))}async function we(N){a.draggable&&(N.preventDefault(),P(null),await D())}function ie(){C()}return n({focusedId:V}),(N,L)=>(e.openBlock(),e.createElementBlock("div",{class:"album-tree","data-testid":"album-tree",tabindex:"0",role:"tree","aria-label":"Album tree",onKeydown:F,onDragover:ye,onDrop:we,onDragend:ie},[e.unref(u)?(e.openBlock(),e.createElementBlock("div",MV,[e.createVNode(e.unref(U.IonSpinner),{name:"crescent"})])):e.unref(m)?(e.openBlock(),e.createElementBlock("div",BV,[e.createElementVNode("p",null,e.toDisplayString(e.unref(m)),1)])):e.unref(d).length?(e.openBlock(),e.createElementBlock("div",IV,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(I.value,te=>(e.openBlock(),e.createBlock(TV,{key:te.id,album:te,depth:0,"selected-id":T.value,"expanded-ids":k.value,"focused-id":V.value,draggable:r.value,"drag-state":r.value?e.unref(R):null,"show-media-count":s.value,compact:l.value,onSelect:w,onToggleExpand:B,onDragStart:$,onDragOver:z,onDragLeave:W,onDrop:Q},null,8,["album","selected-id","expanded-ids","focused-id","draggable","drag-state","show-media-count","compact"]))),128))])):(e.openBlock(),e.createElementBlock("div",FV,[L[0]||(L[0]=e.createElementVNode("p",null,"No albums yet",-1)),e.renderSlot(N.$slots,"empty-action",{},void 0,!0)]))],32))}}),zd=Te($V,[["__scopeId","data-v-ae3dea7a"]]),RV=300,DV=e.defineComponent({__name:"AlbumBrowser",props:{isOpen:{type:Boolean},selectedAlbumId:{default:null},title:{default:"Select Album"},confirmText:{default:"Select"}},emits:["close","confirm"],setup(o,{emit:n}){const t=o,a=n,i=e.ref(t.selectedAlbumId??null),r=e.ref(null),s=e.ref(0),l=e.ref(null);e.watch(()=>t.selectedAlbumId,p=>{i.value=p??null});const c=e.computed(()=>r.value!==null);function d(p){const v=Date.now();if(l.value===p.id&&v-s.value<RV){a("confirm",p);return}s.value=v,l.value=p.id,i.value=p.id,r.value=p}function u(){r.value&&a("confirm",r.value)}function m(){a("close")}function f(){a("close")}return(p,v)=>(e.openBlock(),e.createBlock(e.unref(U.IonModal),{"is-open":p.isOpen,class:"album-browser-modal",onDidDismiss:f},{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(p.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:m},{default:e.withCtx(()=>[...v[1]||(v[1]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(U.IonContent),{class:"album-browser-content"},{default:e.withCtx(()=>[e.createVNode(zd,{modelValue:i.value,"onUpdate:modelValue":v[0]||(v[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:m},{default:e.withCtx(()=>[...v[2]||(v[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(p.confirmText),1)]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"]))}}),jd=Te(DV,[["__scopeId","data-v-21676ec1"]]),AV={class:"ion-padding-start text-sm"},LV={class:"ion-padding-start text-sm"},UV={key:1},OV={key:1,class:"album-manager-inline rounded-lg border border-gray-200 bg-white p-4"},PV={class:"flex items-center justify-between gap-3 pb-3"},zV={class:"text-base font-semibold text-gray-900"},jV={class:"ion-padding-start text-sm"},WV={class:"ion-padding-start text-sm"},ZV={class:"flex justify-between pt-2"},HV={key:1},_a=255,Ea=1e3,XV=e.defineComponent({__name:"AlbumManager",props:{albumId:{default:null},parentId:{default:null},mode:{default:"inline"},isOpen:{type:Boolean,default:!1}},emits:["close","created","updated","deleted","error"],setup(o,{emit:n}){const t=o,a=n,i=bi(),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),m=e.ref(!1),f=e.ref(null),p=e.ref(!1),v=e.ref(!1),g=e.computed(()=>d.value.name?c.value.name.trim()?c.value.name.length>_a?`Name must be ${_a} characters or less`:null:"Name is required":null),k=e.computed(()=>d.value.description&&c.value.description.length>Ea?`Description must be ${Ea} characters or less`:null),T=e.computed(()=>{const F=c.value.name.trim().length>0,B=c.value.name.length<=_a,w=c.value.description.length<=Ea;return F&&B&&w&&!p.value}),V=e.computed(()=>{var F;return((F=u.value)==null?void 0:F.name)??"None (Root)"}),b=e.computed(()=>f.value?f.value.children_count===0&&f.value.media_count===0:!1),h=e.computed(()=>f.value?f.value.children_count>0?"Cannot delete album with child albums. Move or delete children first.":f.value.media_count>0?"Cannot delete album with media. Remove media first.":`Are you sure you want to delete "${f.value.name}"? This action cannot be undone.`:"");e.onMounted(async()=>{t.albumId&&await _()});async function _(){if(t.albumId)try{const F=await i.fetchAlbum(t.albumId);f.value=F,c.value={name:F.name,description:F.description??"",parent_id:F.parent_id},F.parent_id&&(u.value={id:F.parent_id,name:"Parent Album"})}catch(F){a("error",F)}}function R(){d.value.name=!0}function M(){d.value.description=!0}function x(){m.value=!0}function C(F){u.value={id:F.id,name:F.name},c.value.parent_id=F.id,m.value=!1}function P(){m.value=!1}function S(){a("close")}function D(){a("close")}async function I(){if(d.value.name=!0,d.value.description=!0,!(!T.value||p.value)){p.value=!0;try{const F={name:c.value.name.trim(),description:c.value.description.trim(),parent_id:c.value.parent_id};if(r.value&&t.albumId){const B=await i.updateAlbum(t.albumId,F);a("updated",B)}else{const B=await i.createAlbum(F);a("created",B)}a("close")}catch(F){a("error",F)}finally{p.value=!1}}}function j(){b.value&&(v.value=!0)}async function O(F){var w;if((((w=F.detail)==null?void 0:w.role)??"")!=="confirm"){v.value=!1;return}if(t.albumId){p.value=!0;try{await i.deleteAlbum(t.albumId),a("deleted",t.albumId),a("close")}catch($){a("error",$)}finally{p.value=!1,v.value=!1}}}return(F,B)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[F.mode==="modal"?(e.openBlock(),e.createBlock(e.unref(U.IonModal),{key:0,"is-open":F.isOpen,class:"album-manager-modal",onDidDismiss:D},{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:S},{default:e.withCtx(()=>[...B[4]||(B[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(I,["prevent"])},[e.createVNode(e.unref(U.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...B[5]||(B[5]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(U.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":B[0]||(B[0]=w=>c.value.name=w),"data-testid":"name-input",maxlength:_a,onIonBlur:R},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",AV,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(()=>[...B[6]||(B[6]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(U.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":B[1]||(B[1]=w=>c.value.description=w),"data-testid":"description-input",maxlength:Ea,onIonBlur:M},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",LV,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(()=>[...B[7]||(B[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(V.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:!b.value,title:b.value?void 0:h.value,onClick:j},{default:e.withCtx(()=>[...B[8]||(B[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:!T.value,onClick:I},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createBlock(e.unref(U.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",UV,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"])):(e.openBlock(),e.createElementBlock("div",OV,[e.createElementVNode("div",PV,[e.createElementVNode("h2",zV,e.toDisplayString(s.value),1),e.createVNode(e.unref(U.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:S},{default:e.withCtx(()=>[...B[9]||(B[9]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),e.createElementVNode("form",{"data-testid":"album-form",class:"space-y-3",onSubmit:e.withModifiers(I,["prevent"])},[e.createVNode(e.unref(U.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(U.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...B[10]||(B[10]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(U.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":B[2]||(B[2]=w=>c.value.name=w),"data-testid":"name-input",maxlength:_a,onIonBlur:R},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",jV,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(()=>[...B[11]||(B[11]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(U.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":B[3]||(B[3]=w=>c.value.description=w),"data-testid":"description-input",maxlength:Ea,onIonBlur:M},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",WV,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(()=>[...B[12]||(B[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(V.value),1)]),_:1})]),_:1}),e.createElementVNode("div",ZV,[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:!b.value,title:b.value?void 0:h.value,onClick:j},{default:e.withCtx(()=>[...B[13]||(B[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:!T.value,onClick:I},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createBlock(e.unref(U.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",HV,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])])],32)])),e.createVNode(jd,{"is-open":m.value,"selected-album-id":c.value.parent_id,title:"Select Parent Album",onClose:P,onConfirm:C},null,8,["is-open","selected-album-id"]),e.createVNode(e.unref(U.IonAlert),{"is-open":v.value,header:"Delete Album?",message:h.value,buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"confirm",cssClass:"alert-button-danger"}],onDidDismiss:O},null,8,["is-open","message"])],64))}}),GV=Te(XV,[["__scopeId","data-v-22083f3a"]]),JV={class:"album-media-grid"},YV={class:"aspect-square"},qV={key:1,"data-testid":"empty-state",class:"flex flex-col items-center justify-center py-12 gap-4"},KV={class:"text-gray-500"},QV=["data-media-id","draggable","onDragstart","onDragover","onDrop","onMouseenter"],e4={key:0,"data-testid":"drop-indicator",class:"absolute inset-0 border-2 border-primary rounded-lg pointer-events-none z-30"},t4={key:1,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"},n4={class:"aspect-square relative"},a4=["src","alt"],o4={key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center gap-2 transition-opacity"},i4=e.defineComponent({__name:"AlbumMediaGrid",props:{albumId:{},selectionMode:{type:Boolean,default:!1},selectedItems:{default:()=>[]},reorderable:{type:Boolean,default:!1},showActions:{type:Boolean,default:!0},columns:{default:()=>({mobile:2,sm:3,md:4,lg:5,xl:6})},isLoading:{type:Boolean,default:!1},emptyText:{default:"No media in this album"}},emits:["toggle-select","preview","edit","detach","reorder","add","selection-change"],setup(o,{emit:n}){const t=o,a=n,i=bi(),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),m=e.computed(()=>!u.value&&r.value.length===0),f=e.computed(()=>{const D=t.columns;return["grid","gap-4",`grid-cols-${D.mobile??2}`,`sm:grid-cols-${D.sm??3}`,`md:grid-cols-${D.md??4}`,`lg:grid-cols-${D.lg??5}`,`xl:grid-cols-${D.xl??6}`]}),p=e.computed(()=>(t.columns.md??4)*2);e.onMounted(async()=>{await v()}),e.watch(()=>t.albumId,async()=>{await v()});async function v(){s.value=!0;try{const D=await i.fetchAlbumMedia(t.albumId);r.value=D}catch{r.value=[]}finally{s.value=!1}}function g(D){return t.selectedItems.includes(D)}function k(D){a("toggle-select",D);const I=g(D.uuid)?t.selectedItems.filter(j=>j!==D.uuid):[...t.selectedItems,D.uuid];a("selection-change",I)}function T(D){if(D.conversions&&typeof D.conversions=="object"){const I=D.conversions.thumb;if(typeof I=="string")return I}return D.original_url}function V(D){l.value=D}function b(){l.value=null}function h(D){a("preview",D)}function _(D){a("edit",D)}function R(D){a("detach",D.uuid)}function M(){a("add")}function x(D,I){t.reorderable&&(c.value=I,D.dataTransfer&&(D.dataTransfer.effectAllowed="move",D.dataTransfer.setData("text/plain",String(I))))}function C(D,I){!t.reorderable||c.value===null||(D.preventDefault(),d.value=I)}function P(D,I){if(!t.reorderable||c.value===null)return;D.preventDefault();const j=c.value;if(j!==I){const O=[...r.value],[F]=O.splice(j,1);O.splice(I,0,F),r.value=O;const B=O.map(w=>w.uuid);a("reorder",B),i.reorderAlbumMedia(t.albumId,B).catch(()=>{v()})}c.value=null,d.value=null}function S(){c.value=null,d.value=null}return(D,I)=>(e.openBlock(),e.createElementBlock("div",JV,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,"data-testid":"loading-grid",class:e.normalizeClass(f.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,j=>(e.openBlock(),e.createBlock(e.unref(U.IonCard),{key:j,class:"m-0"},{default:e.withCtx(()=>[e.createElementVNode("div",YV,[e.createVNode(e.unref(U.IonSkeletonText),{animated:"",class:"w-full h-full skeleton"})])]),_:1}))),128))],2)):m.value?(e.openBlock(),e.createElementBlock("div",qV,[e.createVNode(e.unref(U.IonIcon),{name:"images-outline",class:"text-6xl text-gray-400"}),e.createElementVNode("p",KV,e.toDisplayString(D.emptyText),1),e.createVNode(e.unref(U.IonButton),{"data-testid":"add-media-btn",onClick:M},{default:e.withCtx(()=>[...I[0]||(I[0]=[e.createTextVNode(" Add Media ",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("div",{key:2,"data-testid":"media-grid",class:e.normalizeClass(f.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(j,O)=>(e.openBlock(),e.createElementBlock("div",{key:j.uuid,"data-media-id":j.uuid,class:e.normalizeClass(["media-item relative group",{"opacity-50":c.value===O,"ring-2 ring-primary":d.value===O&&c.value!==O}]),draggable:D.reorderable,onDragstart:F=>x(F,O),onDragover:F=>C(F,O),onDrop:F=>P(F,O),onDragend:S,onMouseenter:F=>V(j.uuid),onMouseleave:b},[d.value===O&&c.value!==O&&D.reorderable?(e.openBlock(),e.createElementBlock("div",e4)):e.createCommentVNode("",!0),D.reorderable?(e.openBlock(),e.createElementBlock("div",t4,[e.createVNode(e.unref(U.IonIcon),{name:"reorder-three-outline",class:"text-white drop-shadow-md"})])):e.createCommentVNode("",!0),D.selectionMode?(e.openBlock(),e.createBlock(e.unref(U.IonCheckbox),{key:2,"data-testid":"media-checkbox",checked:g(j.uuid),class:"absolute top-2 left-2 z-20",onIonChange:F=>k(j)},null,8,["checked","onIonChange"])):e.createCommentVNode("",!0),e.createVNode(e.unref(U.IonCard),{class:"m-0 overflow-hidden"},{default:e.withCtx(()=>[e.createElementVNode("div",n4,[e.createElementVNode("img",{src:T(j),alt:j.file_name,class:"w-full h-full object-cover"},null,8,a4),D.showActions&&l.value===j.uuid?(e.openBlock(),e.createElementBlock("div",o4,[e.createVNode(e.unref(U.IonButton),{"data-testid":"action-preview",fill:"clear",size:"small",color:"light",onClick:F=>h(j)},{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:F=>_(j)},{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:F=>R(j)},{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,QV))),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:M},[e.createVNode(e.unref(U.IonIcon),{name:"add-circle-outline",class:"text-4xl text-gray-400"}),I[1]||(I[1]=e.createElementVNode("span",{class:"text-sm text-gray-500"},"Add Media",-1))])],2))]))}}),r4=Te(i4,[["__scopeId","data-v-d84b796a"]]),s4={key:0,class:"media-album-inline-create","data-testid":"media-album-inline-create"},l4={class:"media-album-inline-create__field"},c4={class:"media-album-inline-create__field"},d4=["value"],u4={key:1,class:"media-album-inline-create__autocomplete"},m4={class:"media-album-inline-create__autocomplete-input-wrap"},p4={key:0,class:"media-album-inline-create__autocomplete-list"},f4=["onMousedown"],h4={key:1,class:"media-album-inline-create__autocomplete-empty"},v4={class:"media-album-inline-create__actions"},g4=e.defineComponent({__name:"MediaAlbumInlineCreate",props:{open:{type:Boolean,default:!1},nameLabel:{default:"Album name"},albums:{default:()=>[]}},emits:["cancel","create"],setup(o,{emit:n}){const t=o,a=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(T=>T.name.toLowerCase().includes(k))}),u=e.computed(()=>{if(r.value==="")return"";const k=t.albums.find(T=>T.id===r.value);return(k==null?void 0:k.name)??""}),m=k=>{r.value=k.id,s.value=k.name,l.value=!1},f=()=>{r.value="",s.value="",l.value=!1},p=()=>{l.value=!0,r.value!==""&&(s.value=u.value)},v=()=>{setTimeout(()=>{l.value=!1,r.value!==""?s.value=u.value:s.value=""},150)},g=()=>{i.value.trim()!==""&&(a("create",i.value.trim(),r.value!==""?r.value:void 0),i.value="",r.value="",s.value="")};return(k,T)=>k.open?(e.openBlock(),e.createElementBlock("section",s4,[T[7]||(T[7]=e.createElementVNode("h4",{class:"media-album-inline-create__heading"}," New album ",-1)),e.createElementVNode("label",l4,[e.createElementVNode("span",null,e.toDisplayString(k.nameLabel),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":T[0]||(T[0]=V=>i.value=V),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",c4,[T[6]||(T[6]=e.createElementVNode("span",null,"Parent album (optional)",-1)),c.value?(e.openBlock(),e.createElementBlock("div",u4,[e.createElementVNode("div",m4,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":T[2]||(T[2]=V=>s.value=V),type:"text",class:"media-album-inline-create__input",placeholder:"Search albums...","data-testid":"input-media-album-parent-search",onFocus:p,onBlur:v},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(f,["prevent"])},[...T[5]||(T[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",p4,[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(f,["prevent"])}," None ",32)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,V=>(e.openBlock(),e.createElementBlock("li",{key:V.id,class:e.normalizeClass(["media-album-inline-create__autocomplete-option",{"is-selected":V.id===r.value}]),onMousedown:e.withModifiers(b=>m(V),["prevent"])},e.toDisplayString(V.name),43,f4))),128)),d.value.length===0?(e.openBlock(),e.createElementBlock("li",h4," No albums match ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])):e.withDirectives((e.openBlock(),e.createElementBlock("select",{key:0,"onUpdate:modelValue":T[1]||(T[1]=V=>r.value=V),class:"media-album-inline-create__input","data-testid":"select-media-album-parent"},[T[4]||(T[4]=e.createElementVNode("option",{value:""}," None ",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.albums,V=>(e.openBlock(),e.createElementBlock("option",{key:V.id,value:V.id},e.toDisplayString(V.name),9,d4))),128))],512)),[[e.vModelSelect,r.value]])]),e.createElementVNode("div",v4,[e.createElementVNode("button",{type:"button",class:"media-album-inline-create__button","data-testid":"btn-media-album-cancel",onClick:T[3]||(T[3]=V=>a("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)}}),Wd=Te(g4,[["__scopeId","data-v-a85162fe"]]),y4={class:"media-album-unavailable-state","data-testid":"media-album-unavailable-state"},b4=e.defineComponent({__name:"MediaAlbumUnavailableState",props:{title:{default:"Album unavailable"},body:{default:"You no longer have access to this album."},actionLabel:{default:"Go to library"}},emits:["goToLibrary"],setup(o,{emit:n}){const t=n;return(a,i)=>(e.openBlock(),e.createElementBlock("section",y4,[e.createElementVNode("h3",null,e.toDisplayString(a.title),1),e.createElementVNode("p",null,e.toDisplayString(a.body),1),e.createElementVNode("button",{type:"button",class:"media-album-unavailable-state__button",onClick:i[0]||(i[0]=r=>t("goToLibrary"))},e.toDisplayString(a.actionLabel),1)]))}}),Zd=Te(b4,[["__scopeId","data-v-04620e64"]]),w4={key:0,class:"media-preview-sheet","data-testid":"media-preview-sheet"},k4={class:"media-preview-sheet__header"},_4=["src","alt"],E4=["src"],x4={class:"media-preview-sheet__actions"},C4=["disabled"],S4=["disabled"],V4=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(o,{emit:n}){const t=o,a=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&&a("toggleSelect",t.media)};return(l,c)=>l.open&&l.media?(e.openBlock(),e.createElementBlock("section",w4,[e.createElementVNode("header",k4,[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=>a("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,_4)):(e.openBlock(),e.createElementBlock("video",{key:1,class:"media-preview-sheet__video",src:r.value,controls:""},null,8,E4)),e.createElementVNode("div",x4,[e.createElementVNode("button",{type:"button",class:"media-preview-sheet__nav",disabled:!l.canGoPrevious,onClick:c[1]||(c[1]=d=>a("previous"))}," Previous ",8,C4),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=>a("next"))}," Next ",8,S4)])])):e.createCommentVNode("",!0)}}),Hd=Te(V4,[["__scopeId","data-v-9a05f74e"]]),N4={key:0,class:"media-album-grid","data-testid":"media-source-sheet"},T4={class:"media-album-grid__items"},M4={class:"media-album-grid__card-name"},B4={class:"media-album-grid__card-name"},F4=["data-testid","onClick"],I4={class:"media-album-grid__card-name"},$4={key:0,class:"media-album-grid__card-meta"},R4={key:0,class:"media-album-grid__empty"},D4=e.defineComponent({__name:"MediaSourceSheet",props:{open:{type:Boolean,default:!1},currentView:{},albums:{},viewLibraryLabel:{default:"Library"},browseAlbumsLabel:{default:"Albums"},createAlbumLabel:{default:"Create album"},enableAlbumCreation:{type:Boolean,default:!1}},emits:["close","selectLibrary","selectAlbum","createAlbum"],setup(o,{emit:n}){const t=n;return(a,i)=>a.open?(e.openBlock(),e.createElementBlock("section",N4,[e.createElementVNode("div",T4,[a.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",M4,e.toDisplayString(a.createAlbumLabel),1)])):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["media-album-grid__card",{"is-active":a.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",B4,e.toDisplayString(a.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(a.albums,r=>(e.openBlock(),e.createElementBlock("button",{key:r.id,type:"button",class:e.normalizeClass(["media-album-grid__card",{"is-active":a.currentView.scope==="album"&&a.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",I4,e.toDisplayString(r.name),1),r.mediaCount!==void 0?(e.openBlock(),e.createElementBlock("span",$4,e.toDisplayString(r.mediaCount)+" item"+e.toDisplayString(r.mediaCount===1?"":"s"),1)):e.createCommentVNode("",!0)],10,F4))),128))]),a.albums.length===0?(e.openBlock(),e.createElementBlock("p",R4," No albums yet. ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}}),Xd=Te(D4,[["__scopeId","data-v-129f67b1"]]),A4={key:0,class:"media-upload-sheet","data-testid":"media-upload-sheet"},L4=["accept"],U4={key:0,class:"media-upload-sheet__queue"},O4={class:"media-upload-sheet__queue-info"},P4={class:"media-upload-sheet__queue-status"},z4={class:"media-upload-sheet__progress-bar"},j4=e.defineComponent({__name:"MediaUploadSheet",props:{open:{type:Boolean,default:!1},queue:{},accept:{default:""},uploadLabel:{default:"Upload"}},emits:["close","filesSelected"],setup(o,{emit:n}){const t=n,a=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(),a.value=!0},s=()=>{a.value=!1},l=c=>{var d;c.preventDefault(),a.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",A4,[e.createElementVNode("label",{class:e.normalizeClass(["media-upload-sheet__dropzone",{"is-drag-over":a.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,L4)],34),c.queue.length>0?(e.openBlock(),e.createElementBlock("ul",U4,[(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",O4,[e.createElementVNode("strong",null,e.toDisplayString(u.file.name),1),e.createElementVNode("span",P4,e.toDisplayString(u.status),1)]),e.createElementVNode("div",z4,[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)}}),Gd=Te(j4,[["__scopeId","data-v-e238d615"]]),W4=["aria-label","aria-pressed","data-testid"],Z4=["src","alt"],H4={key:1,class:"media-thumbnail-cell__video"},X4={class:"media-thumbnail-cell__video-name"},G4={key:2,class:"media-thumbnail-cell__selected-badge"},J4={key:3,class:"media-thumbnail-cell__status-badge"},Y4=["aria-label"],q4=e.defineComponent({__name:"MediaThumbnailCell",props:{media:{},selected:{type:Boolean,default:!1},status:{},testId:{default:"media-library-thumbnail"}},emits:["toggle","preview"],setup(o,{emit:n}){const t=o,a=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=()=>{a("toggle",t.media)},d=()=>{a("preview",t.media)};return(u,m)=>(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,Z4)):(e.openBlock(),e.createElementBlock("div",H4,[m[0]||(m[0]=e.createElementVNode("span",{class:"media-thumbnail-cell__video-label"},"Video",-1)),e.createElementVNode("span",X4,e.toDisplayString(u.media.file_name),1)])),u.selected?(e.openBlock(),e.createElementBlock("span",G4," Selected ")):e.createCommentVNode("",!0),s.value!==null?(e.openBlock(),e.createElementBlock("span",J4,e.toDisplayString(s.value),1)):e.createCommentVNode("",!0)],8,W4),e.createElementVNode("button",{type:"button",class:"media-thumbnail-cell__preview-button","aria-label":`Preview ${u.media.file_name}`,onClick:d}," Preview ",8,Y4)],2))}}),Jd=Te(q4,[["__scopeId","data-v-edd4f0ad"]]),K4={class:"virtual-media-grid"},Q4={key:0,class:"virtual-media-grid__state","data-testid":"media-grid-loading"},e3={key:1,class:"virtual-media-grid__state","data-testid":"media-grid-empty"},t3={key:2,class:"virtual-media-grid__items"},n3=["disabled"],a3=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(o,{emit:n}){const t=o,a=n;function i(r){return t.selectedItems.find(s=>s.id===r)}return(r,s)=>(e.openBlock(),e.createElementBlock("div",K4,[r.loading&&r.items.length===0?(e.openBlock(),e.createElementBlock("div",Q4," Loading media... ")):r.items.length===0?(e.openBlock(),e.createElementBlock("div",e3,e.toDisplayString(r.emptyMessage),1)):(e.openBlock(),e.createElementBlock("div",t3,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,l=>{var c,d;return e.openBlock(),e.createBlock(Jd,{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=>a("toggle",u)),onPreview:s[1]||(s[1]=u=>a("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=>a("loadMore"))},e.toDisplayString(r.loadingMore?"Loading…":"Load more"),9,n3)):e.createCommentVNode("",!0)]))}}),Yd=Te(a3,[["__scopeId","data-v-820b9a4f"]]);function Ho(o){if(o===0)return"0 Bytes";const n=1024,t=["Bytes","KB","MB","GB"],a=Math.floor(Math.log(o)/Math.log(n));return parseFloat((o/Math.pow(n,a)).toFixed(2))+" "+t[a]}function qd(o){var t;const n=o.split(".");return n.length>1?`.${(t=n.pop())==null?void 0:t.toLowerCase()}`:""}function gs(o){return o.type.startsWith("image/")}async function Kd(o){return gs(o)?new Promise(n=>{const t=new Image,a=URL.createObjectURL(o);t.onload=()=>{URL.revokeObjectURL(a),n({width:t.naturalWidth,height:t.naturalHeight})},t.onerror=()=>{URL.revokeObjectURL(a),n(null)},t.src=a}):null}async function Qd(o,n){const t=[];if(n.maxFileSize&&o.size>n.maxFileSize&&t.push({field:"size",message:`File exceeds maximum size of ${Ho(n.maxFileSize)}`,code:"MAX_FILE_SIZE"}),n.minFileSize&&o.size<n.minFileSize&&t.push({field:"size",message:`File is smaller than minimum size of ${Ho(n.minFileSize)}`,code:"MIN_FILE_SIZE"}),n.acceptedMimeTypes&&n.acceptedMimeTypes.length>0&&(n.acceptedMimeTypes.some(i=>i.endsWith("/*")?o.type.startsWith(i.slice(0,-1)):o.type===i)||t.push({field:"type",message:`File type "${o.type}" is not allowed`,code:"INVALID_MIME_TYPE"})),n.acceptedExtensions&&n.acceptedExtensions.length>0){const a=qd(o.name);n.acceptedExtensions.some(r=>r.toLowerCase()===a.toLowerCase())||t.push({field:"extension",message:`File extension "${a}" is not allowed`,code:"INVALID_EXTENSION"})}if(gs(o)&&(n.maxDimensions||n.minDimensions)){const a=await Kd(o);a&&(n.maxDimensions&&(a.width>n.maxDimensions.width&&t.push({field:"dimensions",message:`Image width (${a.width}px) exceeds maximum (${n.maxDimensions.width}px)`,code:"MAX_WIDTH"}),a.height>n.maxDimensions.height&&t.push({field:"dimensions",message:`Image height (${a.height}px) exceeds maximum (${n.maxDimensions.height}px)`,code:"MAX_HEIGHT"})),n.minDimensions&&(a.width<n.minDimensions.width&&t.push({field:"dimensions",message:`Image width (${a.width}px) is smaller than minimum (${n.minDimensions.width}px)`,code:"MIN_WIDTH"}),a.height<n.minDimensions.height&&t.push({field:"dimensions",message:`Image height (${a.height}px) is smaller than minimum (${n.minDimensions.height}px)`,code:"MIN_HEIGHT"})))}if(n.customValidator){const a=await n.customValidator(o);t.push(...a)}return{valid:t.length===0,errors:t}}function ys(o={}){const n=e.ref(o.rules||{});function t(c){n.value=c}async function a(c){return Qd(c,n.value)}async function i(c){const d=new Map;return await Promise.all(c.map(async u=>{const m=await a(u);d.set(u,m)})),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:a,validateFiles:i,canAddFiles:r,acceptString:s,isMimeTypeAllowed:l}}function o3(){return`upload-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function i3(o){if(o.type.startsWith("image/"))return URL.createObjectURL(o)}function bs(o){const{adapter:n,maxConcurrent:t=3,rules:a,collection:i,onUploadStart:r,onUploadProgress:s,onUploadComplete:l,onUploadError:c,onQueueComplete:d,postUpload:u}=o,m=e.ref(new Map),f=e.ref(new Set),p=a?{rules:a}:{},{validateFile:v}=ys(p);async function g(){if(f.value.size>=t)return;const D=Array.from(m.value.entries()).find(([O,F])=>F.status==="pending"&&!f.value.has(O));if(!D){Array.from(m.value.values()).every(F=>F.status==="completed"||F.status==="error")&&m.value.size>0&&(d==null||d());return}const[I,j]=D;await k(I,j)}async function k(D,I){f.value.add(D),I.status="uploading",I.abortController=new AbortController,m.value.set(D,{...I}),r==null||r(I);try{const j={onProgress:F=>{I.progress=F,m.value.set(D,{...I}),s==null||s(I)},signal:I.abortController.signal};i&&(j.collection=i);const O=await n.upload(I.file,j);u&&(I.status="attaching",m.value.set(D,{...I}),s==null||s(I),await u(I,O.media,n)),I.status="completed",I.progress=100,I.media=O.media,m.value.set(D,{...I}),l==null||l(I,O.media)}catch(j){j.name==="AbortError"?m.value.delete(D):(I.status="error",I.error=j.message,m.value.set(D,{...I}),c==null||c(I,j))}finally{f.value.delete(D),delete I.abortController,g()}}async function T(D){var O;const I=Array.from(D),j=[];for(const F of I){const B=await v(F),w=o3(),$=i3(F),z={id:w,file:F,progress:0,status:B.valid?"pending":"error"};!B.valid&&((O=B.errors[0])!=null&&O.message)&&(z.error=B.errors[0].message),$&&(z.previewUrl=$),m.value.set(w,z);const W={media:null,clientId:w,name:F.name,order:0,upload:z,errors:B.errors};j.push(W)}for(let F=0;F<t;F++)g();return j}function V(D){const I=m.value.get(D);I&&(I.abortController&&I.abortController.abort(),I.previewUrl&&URL.revokeObjectURL(I.previewUrl),m.value.delete(D),f.value.delete(D),g())}async function b(D){const I=m.value.get(D);!I||I.status!=="error"||(I.status="pending",I.progress=0,delete I.error,m.value.set(D,{...I}),g())}function h(){for(const[D,I]of m.value.entries())(I.status==="completed"||I.status==="error")&&(I.previewUrl&&URL.revokeObjectURL(I.previewUrl),m.value.delete(D))}function _(){for(const D of m.value.values())D.abortController&&D.abortController.abort(),D.previewUrl&&URL.revokeObjectURL(D.previewUrl);m.value.clear(),f.value.clear()}function R(D){return m.value.get(D)}const M=e.computed(()=>f.value.size>0),x=e.computed(()=>f.value.size),C=e.computed(()=>Array.from(m.value.values()).filter(D=>D.status==="pending").length),P=e.computed(()=>m.value.size===0?!0:Array.from(m.value.values()).every(D=>D.status==="completed"||D.status==="error")),S=e.computed(()=>Array.from(m.value.values()));return{uploads:m,isUploading:M,activeCount:x,pendingCount:C,isComplete:P,addFiles:T,cancelUpload:V,retryUpload:b,clearCompleted:h,clearAll:_,getUpload:R,uploadsArray:S}}function Ln(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}function Oa(o){return typeof o=="string"?o:null}function nc(o){return typeof o=="number"?o:null}function r3(o){return typeof o=="boolean"?o:null}function eu(o){return Ln(o)&&typeof o.uuid=="string"&&typeof o.file_name=="string"&&typeof o.mime_type=="string"&&(typeof o.original_url=="string"||o.original_url===null)&&typeof o.size=="number"&&typeof o.disk=="string"&&typeof o.created_at=="string"&&typeof o.updated_at=="string"}function s3(o){return!Ln(o)||typeof o.id!="string"||typeof o.status!="string"?null:o.status==="ready"?eu(o.media)?{id:o.id,status:"ready",media:o.media}:null:o.status==="missing"||o.status==="forbidden"?{id:o.id,status:o.status}:null}function l3(o){return Ln(o)?{next_cursor:Oa(o.next_cursor),previous_cursor:Oa(o.previous_cursor),has_more:r3(o.has_more)??!1,per_page:nc(o.per_page),count:nc(o.count)}:null}function ac(o){const n=Ln(o)?o:{},t=Array.isArray(n.data)?n.data.filter(eu):[],a=Ln(n.meta)?n.meta:{},i=l3(a.pagination),r=(i==null?void 0:i.next_cursor)??Oa(a.next_cursor)??Oa(a.cursor),s=(i==null?void 0:i.has_more)??a.has_more===!0,l=Array.isArray(n.hydrated)?n.hydrated.map(s3).filter(d=>d!==null):[],c={cursor:r,has_more:s};return i!==null&&(c.pagination=i),{data:t,meta:c,hydrated:l}}function oc(o,n,t,a,i){const r={view:o.scope==="album"?{scope:"album",album_id:o.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),a!==null&&(r.cursor=a),i&&i.length>0&&(r.hydrate_ids=i),r}function ic(o){const n=new Set,t=[];for(const a of o)n.has(a.uuid)||(n.add(a.uuid),t.push(a));return t}function c3(o){var t;if(!(o instanceof Error))return null;const n=(t=o.response)==null?void 0:t.status;return typeof n=="number"?n:null}function d3(o){var n;return o instanceof Error?((n=o.response)==null?void 0:n.data)??null:null}function u3(o){if(!Ln(o))return[];const n=[];for(const t of Object.values(o)){if(typeof t=="string"&&t.trim()!==""){n.push(t.trim());continue}if(Array.isArray(t))for(const a of t){if(typeof a!="string")continue;const i=a.trim();i!==""&&n.push(i)}}return Array.from(new Set(n))}function m3(o){var r;const n=d3(o),t=Ln(n)?n:null,a=((r=Oa(t==null?void 0:t.message))==null?void 0:r.trim())??null,i=u3(t==null?void 0:t.errors);return a!==null&&i.length>0?a==="Validation failed"?i.join(" "):i.every(l=>a.includes(l))?a:`${a} ${i.join(" ")}`:a!==null?a:i.length>0?i.join(" "):o instanceof Error?o.message:"Failed to load media."}function rc(o,n){const t=m3(n),a=c3(n);return{code:a===403?"permission_denied":o,message:t,retriable:a!==403,cause:n}}function ws(o){const n=o.perPage??40,t=e.ref([]),a=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,m=0;const f=async g=>{m+=1;const k=m;u==null||u.abort();const T=new AbortController;u=T,g?l.value=!0:s.value=!0,d.value=null,c.value=!1;try{const V=await o.httpClient.get("/v1/media/library",{params:oc(o.view.value,o.filters.value,n,g?i.value:null),signal:T.signal});if(k!==m)return;const b=ac(V);t.value=g?ic([...t.value,...b.data]):b.data,a.value=b.hydrated,i.value=b.meta.cursor,r.value=b.meta.has_more}catch(V){if(T.signal.aborted||k!==m)return;const b=rc(g?"load_more_failed":"query_failed",V);d.value=b,c.value=b.code==="permission_denied",g||(t.value=[],i.value=null,r.value=!1)}finally{k===m&&(s.value=!1,l.value=!1)}};return{items:t,hydrated:a,cursor:i,hasMore:r,loading:s,loadingMore:l,permissionDenied:c,error:d,loadInitial:async()=>{i.value=null,await f(!1)},loadMore:async()=>{!r.value||l.value||await f(!0)},refresh:async()=>{i.value=null,await f(!1)},hydrateSelection:async g=>{if(g.length===0)return a.value=[],[];try{const k=await o.httpClient.get("/v1/media/library",{params:oc(o.view.value,o.filters.value,1,null,g)}),T=ac(k);return a.value=T.hydrated,T.hydrated}catch(k){return d.value=rc("hydration_failed",k),[]}},prepend:g=>{t.value=ic([g,...t.value])}}}const p3="mediables.media-library.";function f3(o){return!o||o.key.trim()===""?null:`${p3}${o.key}`}function dr(){return typeof window>"u"||typeof window.sessionStorage>"u"?null:window.sessionStorage}function h3(o,n){const t=Date.parse(o);return Number.isFinite(t)?Date.now()-t>n*60*1e3:!0}function tu(o){const n=f3(o),t=(o==null?void 0:o.ttlMinutes)??30,a=`${(o==null?void 0:o.key)??"media-library"}:${Date.now()}`;return{restore:()=>{if(n===null)return null;const l=dr();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"||h3(u.savedAt,t))return l.removeItem(n),null;const m={selectedIds:Array.isArray(u.selectedIds)?u.selectedIds.filter(f=>typeof f=="string"&&f.trim()!==""):[]};return((o==null?void 0:o.restoreView)??!0)&&u.view&&(m.view=u.view),u.filters&&(m.filters=u.filters),m},save:l=>{if(n===null)return;const c=dr();if(c===null)return;const d={version:1,savedAt:new Date().toISOString(),selectedIds:[...l.selectedIds]};((o==null?void 0:o.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=dr();l==null||l.removeItem(n)},sessionId:a}}function nu(o){const n=e.ref(o);return{state:n,transition:a=>{n.value=a}}}function au(o){return{emitMetric:(t,a)=>{const i={name:t,timestamp:new Date().toISOString()};a!==void 0&&(i.payload=a),o==null||o(i)}}}function ea(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}function v3(o){const n=ea(o)?o:{};return(Array.isArray(n.data)?n.data:ea(n.data)&&Array.isArray(n.data.data)?n.data.data:Array.isArray(o)?o:[]).map(a=>{if(!ea(a)||typeof a.id!="string"||typeof a.name!="string")return null;const i={id:a.id,name:a.name};return typeof a.description=="string"&&a.description.trim()!==""&&(i.description=a.description),typeof a.media_count=="number"&&(i.mediaCount=a.media_count),i}).filter(a=>a!==null)}function g3(o){const n=ea(o)?o:{},t=ea(n.data)?n.data:ea(o)?o:null;if(t===null||typeof t.id!="string"||typeof t.name!="string")return null;const a={id:t.id,name:t.name};return typeof t.description=="string"&&t.description.trim()!==""&&(a.description=t.description),a}function y3(o){return o==="ready"||o==="uploading"||o==="failed"}function ko(o,n="ready"){return{id:o.uuid,media:o,status:n,countsTowardMax:y3(n)}}function b3(o,n){return o.scope==="library"?!0:n.type==="album"&&n.albumId===o.albumId}function w3(o,n){return o.scope==="library"?n.type==="library"||n.type==="album":n.type==="album"&&n.albumId===o.albumId}function ur(o){return{code:"configuration_error",message:o,retriable:!1}}function ou(o){var ye,we,ie;const n=o.selectionMode??"multiple",t=o.maxSelection,a=o.uploadBehavior??"adapter",i=e.ref(o.initialView??{scope:"library"}),r=e.ref({sort:((ye=o.initialFilters)==null?void 0:ye.sort)??"newest",...(we=o.initialFilters)!=null&&we.query?{query:o.initialFilters.query}:{},...(ie=o.initialFilters)!=null&&ie.kinds?{kinds:o.initialFilters.kinds}:{}}),s=e.ref([]),l=e.ref([]),c=e.ref(null),d=e.ref(null),u=tu(o.sessionPolicy),{emitMetric:m}=au(o.telemetry),f=nu("idle"),p=ws({httpClient:o.deps.httpClient,view:i,filters:r}),v=e.computed(()=>l.value.map(N=>N.id)),g=e.computed(()=>{const N=c.value;return N===null?null:p.items.value[N]??null}),k=e.computed(()=>o.uploadTarget??{type:"library"}),T=bs({adapter:o.deps.uploadAdapter??{name:"missing-upload-adapter",upload:async()=>{throw new Error("Upload adapter is not configured.")},attach:async()=>{},attachMany:async()=>{},detach:async()=>{},reorder:async()=>{},fetchModelMedia:async()=>[],getUrl:N=>N.original_url,getThumbnailUrl:N=>N.thumbnail_url??N.preview_url??N.original_url},postUpload:async(N,L,te)=>{const ne=k.value;ne.type!=="album"||!ne.albumId||await te.attach(L.uuid,{modelType:"album",modelId:ne.albumId})},onUploadComplete:(N,L)=>{const te=k.value;b3(i.value,te)&&p.prepend(L),o.autoSelectUploaded&&w3(i.value,te)&&M(L),m("upload-complete",{mediaId:L.uuid,targetType:te.type,targetAlbumId:te.albumId})},onUploadError:(N,L)=>{d.value={code:"upload_failed",message:L.message,retriable:!0,cause:L}}}),V=e.computed(()=>T.isUploading.value),b=()=>{u.save({selectedIds:[...v.value],view:i.value,filters:r.value})},h=async N=>{const L=await p.hydrateSelection(N);l.value=L.map(te=>te.status==="ready"&&te.media?ko(te.media):{id:te.id,media:null,status:te.status,countsTowardMax:!1})},_=e.computed(()=>l.value.filter(N=>N.countsTowardMax).length),R=()=>n==="single"||t===void 0?!0:_.value<t,M=N=>{if(l.value.findIndex(te=>te.id===N.uuid)>=0){n==="multiple"?l.value=l.value.filter(te=>te.id!==N.uuid):l.value=[ko(N)],b();return}if(!R()){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=[ko(N)]:l.value=[...l.value,ko(N)],d.value=null,b()},x=async()=>{var L;f.transition("restoring");const N=u.restore();if(N===null){f.transition("ready");return}N.view&&(i.value=N.view),N.filters&&(r.value={sort:N.filters.sort??"newest",...N.filters.query?{query:N.filters.query}:{},...N.filters.kinds?{kinds:N.filters.kinds}:{}}),await p.loadInitial(),(((L=o.sessionPolicy)==null?void 0:L.restoreSelection)??!0)&&await h(N.selectedIds),f.transition("ready")};e.watch(()=>p.error.value,N=>{N!==null&&(d.value=N,f.transition("error"))});const C=async()=>{d.value=null,f.transition("idle"),await x(),p.items.value.length===0&&!p.loading.value&&!p.permissionDenied.value&&await p.loadInitial();const N=o.defaultSelectedIds??[];l.value.length===0&&N.length>0&&await h(N),f.transition("ready")},P=async(N,L="user")=>{const te=i.value;i.value=N,L==="user"&&o.preserveSelectionOnViewChange===!1&&(l.value=[]),m("view-change",{from:te.scope,to:N.scope,reason:L}),await p.loadInitial(),b()},S=async()=>{const N=await o.deps.httpClient.get("/v1/albums");s.value=v3(N)},D=async(N,L)=>{try{const te={name:N,visibility:"private"};L&&L.trim()!==""&&(te.parent_id=L);const ne=await o.deps.httpClient.post("/v1/albums",te),re=g3(ne);return re===null?ur("Album creation response was invalid."):(s.value=[re,...s.value.filter(he=>he.id!==re.id)],await P({scope:"album",albumId:re.id,albumName:re.name},"inline-album-created"),re)}catch(te){const ne={code:"album_create_failed",message:te instanceof Error?te.message:"Album creation failed.",retriable:!0,cause:te};return d.value=ne,ne}},I=async N=>{if(!o.enableUpload){d.value=ur("Uploads are not enabled for this picker.");return}if(a!=="delegate"){if(!o.deps.uploadAdapter){d.value=ur("Uploads require a configured upload adapter.");return}await T.addFiles(N)}},j=()=>{var te;const N=((te=o.validateSelection)==null?void 0:te.call(o,l.value))??null;if(N!==null){const ne={code:"selection_invalid",message:N,retriable:!0};return d.value=ne,ne}if(l.value.filter(ne=>ne.status==="ready"&&ne.media!==null).length===0){const ne={code:"selection_invalid",message:"Select at least one available media item.",retriable:!0};return d.value=ne,ne}return{orderedIds:v.value,items:[...l.value],view:i.value,filters:r.value,dirty:!0,sessionId:u.sessionId}},O=N=>{const L=p.items.value.findIndex(te=>te.uuid===N.uuid);c.value=L>=0?L:null},F=()=>{c.value=null},B=()=>{c.value===null||c.value<=0||(c.value-=1)},w=()=>{c.value===null||c.value>=p.items.value.length-1||(c.value+=1)},$=N=>{l.value=l.value.filter(L=>L.id!==N),b()},z=async()=>{await p.refresh()},W=async N=>{r.value={...r.value,...N&&N.trim()!==""?{query:N.trim()}:{}},(!N||N.trim()==="")&&delete r.value.query,await p.loadInitial(),b()},Q=async()=>{await P({scope:"library"},"permission-unavailable")};return{view:i,filters:r,albums:s,selectedItems:l,orderedIds:v,queryItems:p.items,cursor:p.cursor,hasMore:p.hasMore,loading:p.loading,loadingMore:p.loadingMore,permissionDenied:p.permissionDenied,error:d,uploadQueue:T.uploadsArray,isUploading:V,previewIndex:c,previewItem:g,initialize:C,refresh:z,loadMore:p.loadMore,setQuery:W,setView:P,toggleSelection:M,removeSelected:$,confirmSelection:j,openPreview:O,closePreview:F,showPreviousPreview:B,showNextPreview:w,loadAlbums:S,createAlbum:D,addUploadFiles:I,goToLibrary:Q,sessionId:u.sessionId}}const k3=["data-testid"],_3={class:"mlp-location-bar"},E3={class:"mlp-location-bar__left"},x3={class:"mlp-location-bar__label"},C3={class:"mlp-tabs","data-testid":"media-picker-tabs"},S3={key:0,class:"mlp-search-row"},V3=["placeholder"],N3={key:2,class:"mlp-overlay-panel"},T3={key:0,class:"mlp-error","data-testid":"media-picker-error"},M3={key:5,class:"mlp-bottom-bar"},B3={key:0,class:"mlp-bottom-bar__selection"},F3={class:"mlp-bottom-bar__count"},I3={class:"mlp-bottom-bar__thumbs"},$3=["src","alt"],R3={key:1,class:"mlp-bottom-bar__thumb-placeholder"},D3=["aria-label","onClick"],A3={class:"mlp-bottom-bar__actions"},L3=e.defineComponent({__name:"MediaLibraryPicker",props:{deps:{},modelValue:{default:()=>[]},defaultSelectedIds:{default:()=>[]},selectionMode:{default:"multiple"},maxSelection:{},preserveSelectionOnViewChange:{type:Boolean,default:!0},initialView:{default:()=>({scope:"library"})},initialFilters:{default:()=>({sort:"newest"})},enableUpload:{type:Boolean,default:!1},uploadBehavior:{default:"adapter"},enablePreview:{type:Boolean,default:!0},enableAlbumCreation:{type:Boolean,default:!1},allowedMediaKinds:{},accept:{},validateSelection:{},uploadTarget:{},autoSelectUploaded:{type:Boolean,default:!1},createAlbumDefaultVisibility:{default:"private"},sessionPolicy:{},labels:{default:()=>({})},showFooter:{type:Boolean,default:!0},testIdPrefix:{default:"media-picker"},telemetry:{}},emits:["update:modelValue","confirm","cancel","selection-change","view-change","error","metric","request-upload-files"],setup(o,{expose:n,emit:t}){const a=o,i=t,r=e.computed(()=>{var F,B,w,$,z,W,Q,ye,we,ie,N,L,te,ne,re,he,de,me;return{title:((F=a.labels)==null?void 0:F.title)??"Media library",searchPlaceholder:((B=a.labels)==null?void 0:B.searchPlaceholder)??"Search your media",viewLibrary:((w=a.labels)==null?void 0:w.viewLibrary)??"Library",browseAlbums:(($=a.labels)==null?void 0:$.browseAlbums)??"Albums",createAlbum:((z=a.labels)==null?void 0:z.createAlbum)??"Create album",createAlbumNameLabel:((W=a.labels)==null?void 0:W.createAlbumNameLabel)??"Album name",emptyLibrary:((Q=a.labels)==null?void 0:Q.emptyLibrary)??"No media found in your library.",emptyAlbum:((ye=a.labels)==null?void 0:ye.emptyAlbum)??"No media found in this album.",networkError:((we=a.labels)==null?void 0:we.networkError)??"Unable to load media right now.",retry:((ie=a.labels)==null?void 0:ie.retry)??"Retry",selectedCount:((N=a.labels)==null?void 0:N.selectedCount)??(Ve=>`${Ve} selected`),confirmAction:((L=a.labels)==null?void 0:L.confirmAction)??"Attach selected",cancel:((te=a.labels)==null?void 0:te.cancel)??"Cancel",dismiss:((ne=a.labels)==null?void 0:ne.dismiss)??"Remove",uploadLabel:((re=a.labels)==null?void 0:re.uploadLabel)??"Upload",albumUnavailableTitle:((he=a.labels)==null?void 0:he.albumUnavailableTitle)??"Album unavailable",albumUnavailableBody:((de=a.labels)==null?void 0:de.albumUnavailableBody)??"You no longer have access to this album.",goToLibrary:((me=a.labels)==null?void 0:me.goToLibrary)??"Go to library"}}),s={deps:a.deps,selectionMode:a.selectionMode,initialView:a.initialView,initialFilters:a.initialFilters,...a.maxSelection!==void 0?{maxSelection:a.maxSelection}:{},...a.modelValue.length>0||a.defaultSelectedIds.length>0?{defaultSelectedIds:a.modelValue.length>0?a.modelValue:a.defaultSelectedIds}:{},...a.sessionPolicy?{sessionPolicy:a.sessionPolicy}:{},...a.enableUpload?{enableUpload:!0}:{},uploadBehavior:a.uploadBehavior,...a.uploadTarget?{uploadTarget:a.uploadTarget}:{},...a.autoSelectUploaded?{autoSelectUploaded:!0}:{},...a.validateSelection?{validateSelection:a.validateSelection}:{},preserveSelectionOnViewChange:a.preserveSelectionOnViewChange,telemetry:F=>{var B;(B=a.telemetry)==null||B.call(a,F),i("metric",F)}},l=ou(s),c=e.ref(a.initialFilters.query??""),d=e.ref("upload"),u=e.ref(!1),m=JSON.stringify(a.modelValue.length>0?a.modelValue:a.defaultSelectedIds);let f=null;const p=e.computed(()=>JSON.stringify(l.orderedIds.value)!==m),v=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),T=e.computed(()=>l.view.value.scope==="album"),V=()=>{f!==null&&(window.clearTimeout(f),f=null)},b=()=>{i("update:modelValue",[...l.orderedIds.value]),i("selection-change",{orderedIds:[...l.orderedIds.value],items:[...l.selectedItems.value],dirty:p.value})},h=F=>{F!==null&&i("error",F)},_=F=>typeof F.code=="string",R=F=>typeof F=="object"&&F!==null&&"code"in F&&typeof F.code=="string",M=()=>{const F=l.confirmSelection();if(_(F)){h(F);return}i("confirm",{...F,dirty:p.value})},x=(F="user")=>{i("cancel",{dirty:p.value,reason:F,sessionId:l.sessionId})},C=async()=>{d.value="albums",await l.loadAlbums()},P=async()=>{await l.goToLibrary(),d.value="albums",await l.loadAlbums()},S=F=>{l.setView({scope:"album",albumId:F.id,albumName:F.name}),d.value="media"},D=async(F,B)=>{const w=l.view.value,$=await l.createAlbum(F,B);if(R($)){h($);return}u.value=!1,d.value="media",i("view-change",{from:w,to:{scope:"album",albumId:$.id,albumName:$.name},reason:"inline-album-created",restoredFromSession:!1})},I=async F=>{if(a.uploadBehavior==="delegate"){i("request-upload-files",{files:[...F],view:l.view.value,filters:l.filters.value,sessionId:l.sessionId});return}await l.addUploadFiles(F)};function j(F){var B;return F?F.thumbnail_url??((B=F.conversion_urls)==null?void 0:B.thumb)??F.preview_url??F.original_url??F.url??null:null}function O(F){return F!=null&&F.mime_type?F.mime_type.startsWith("image/"):!1}return e.watch(()=>c.value,F=>{V(),f=window.setTimeout(()=>{l.setQuery(F)},250)}),e.watch(()=>l.selectedItems.value,()=>{b()},{deep:!0}),e.watch(()=>l.error.value,F=>{h(F)}),e.onMounted(()=>{l.initialize()}),e.onBeforeUnmount(()=>{V()}),n({refresh:l.refresh}),(F,B)=>(e.openBlock(),e.createElementBlock("section",{class:"media-library-picker","data-testid":F.testIdPrefix},[e.createElementVNode("header",_3,[e.createElementVNode("div",E3,[T.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:P},[...B[8]||(B[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",x3,e.toDisplayString(k.value),1)])]),e.createElementVNode("nav",C3,[F.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:B[0]||(B[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:B[1]||(B[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:C},e.toDisplayString(r.value.browseAlbums),3)]),d.value==="media"||d.value==="albums"?(e.openBlock(),e.createElementBlock("div",S3,[B[9]||(B[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":B[2]||(B[2]=w=>c.value=w),class:"mlp-search-row__input",type:"search",placeholder:r.value.searchPlaceholder,"data-testid":"input-media-picker-search"},null,8,V3),[[e.vModelText,c.value]])])):e.createCommentVNode("",!0),F.enableUpload&&d.value==="upload"?(e.openBlock(),e.createBlock(Gd,{key:1,open:!0,queue:e.unref(l).uploadQueue.value,accept:F.accept,"upload-label":r.value.uploadLabel,onClose:B[3]||(B[3]=w=>d.value="media"),onFilesSelected:I},null,8,["queue","accept","upload-label"])):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("div",N3,[e.createVNode(Wd,{open:u.value,"name-label":r.value.createAlbumNameLabel,albums:e.unref(l).albums.value,onCancel:B[4]||(B[4]=w=>u.value=!1),onCreate:D},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(Zd,{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",T3,[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:B[5]||(B[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(Yd,{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":v.value,"test-id-prefix":`${F.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(Xd,{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":F.enableAlbumCreation,onSelectLibrary:P,onSelectAlbum:S,onCreateAlbum:B[6]||(B[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),F.showFooter?(e.openBlock(),e.createElementBlock("footer",M3,[e.unref(l).selectedItems.value.length>0?(e.openBlock(),e.createElementBlock("div",B3,[e.createElementVNode("span",F3,e.toDisplayString(g.value),1),e.createElementVNode("div",I3,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(l).selectedItems.value,w=>{var $,z,W;return e.openBlock(),e.createElementBlock("div",{key:w.id,class:"mlp-bottom-bar__thumb-item"},[O(w.media)&&j(w.media)?(e.openBlock(),e.createElementBlock("img",{key:0,src:j(w.media),alt:(($=w.media)==null?void 0:$.alt_text)??((z=w.media)==null?void 0:z.file_name)??"Selected",class:"mlp-bottom-bar__thumb-img"},null,8,$3)):(e.openBlock(),e.createElementBlock("div",R3,[...B[10]||(B[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} ${((W=w.media)==null?void 0:W.file_name)??w.id}`,"data-testid":"btn-media-picker-remove-selected",onClick:Q=>e.unref(l).removeSelected(w.id)},[...B[11]||(B[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,D3)])}),128))])])):e.createCommentVNode("",!0),e.createElementVNode("div",A3,[e.createElementVNode("button",{type:"button",class:"mlp-bottom-bar__cancel","data-testid":"btn-media-picker-cancel",onClick:B[7]||(B[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:M},e.toDisplayString(r.value.confirmAction),1)])])):e.createCommentVNode("",!0),F.enablePreview?(e.openBlock(),e.createBlock(Hd,{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,k3))}}),iu=Te(L3,[["__scopeId","data-v-db2ced73"]]),U3={key:0,class:"media-library-picker-modal","data-testid":"media-library-picker-modal"},O3={class:"media-library-picker-modal__panel"},P3=e.defineComponent({__name:"MediaLibraryPickerModal",props:{deps:{},modelValue:{},defaultSelectedIds:{},selectionMode:{},maxSelection:{},preserveSelectionOnViewChange:{type:Boolean},initialView:{},initialFilters:{},enableUpload:{type:Boolean},uploadBehavior:{},enablePreview:{type:Boolean},enableAlbumCreation:{type:Boolean},allowedMediaKinds:{},accept:{},validateSelection:{},uploadTarget:{},autoSelectUploaded:{type:Boolean},createAlbumDefaultVisibility:{},sessionPolicy:{},labels:{},showFooter:{type:Boolean},testIdPrefix:{},telemetry:{},isOpen:{type:Boolean,default:!1},closeOnBackdrop:{type:Boolean,default:!0}},emits:["update:modelValue","confirm","cancel","close"],setup(o,{emit:n}){const t=o,a=n,i=()=>{t.closeOnBackdrop&&a("close")};return(r,s)=>r.isOpen?(e.openBlock(),e.createElementBlock("div",U3,[e.createElementVNode("button",{type:"button",class:"media-library-picker-modal__backdrop","aria-label":"Close media picker",onClick:i}),e.createElementVNode("div",O3,[e.createVNode(iu,e.mergeProps(t,{"onUpdate:modelValue":s[0]||(s[0]=l=>a("update:modelValue",l)),onConfirm:s[1]||(s[1]=l=>a("confirm",l)),onCancel:s[2]||(s[2]=l=>a("cancel",l))}),null,16)])])):e.createCommentVNode("",!0)}}),z3=Te(P3,[["__scopeId","data-v-a92e8703"]]),j3={key:0,class:"media-selection-tray","data-testid":"media-selection-tray"},W3={class:"media-selection-tray__header"},Z3={class:"media-selection-tray__title"},H3={class:"media-selection-tray__items"},X3={class:"media-selection-tray__item-preview"},G3=["src","alt"],J3={key:1,class:"media-selection-tray__file-icon"},Y3={class:"media-selection-tray__item-copy"},q3=["aria-label","onClick"],K3=e.defineComponent({__name:"MediaSelectionTray",props:{items:{},selectedCountLabel:{default:"Selected items"},dismissLabel:{default:"Remove"}},emits:["remove"],setup(o,{emit:n}){const t=n;function a(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",j3,[e.createElementVNode("header",W3,[e.createElementVNode("h3",Z3,e.toDisplayString(r.selectedCountLabel),1)]),e.createElementVNode("div",H3,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,l=>{var c,d,u,m;return e.openBlock(),e.createElementBlock("article",{key:l.id,class:"media-selection-tray__item"},[e.createElementVNode("div",X3,[i(l.media)&&a(l.media)?(e.openBlock(),e.createElementBlock("img",{key:0,src:a(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,G3)):(e.openBlock(),e.createElementBlock("div",J3,[...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",Y3,[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} ${((m=l.media)==null?void 0:m.file_name)??l.id}`,onClick:f=>t("remove",l.id)},e.toDisplayString(r.dismissLabel),9,q3)])}),128))])])):e.createCommentVNode("",!0)}}),Q3=Te(K3,[["__scopeId","data-v-f2a3d69d"]]);function ks(o={}){const n=e.ref(!1),t=e.ref(!1),a=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=T=>{if(r.value++,l.value=null,i.value=null,t.value=!1,T!=null&&typeof T=="object"&&!(T instanceof Blob)&&("image"in T||"state"in T||"sessionKey"in T)){const V=T;a.value=V.image??null,s.value=V.state??null}else a.value=T??null,s.value=null;n.value=!0},u=()=>{n.value=!1,a.value=null,i.value=null,l.value=null,t.value=!1,s.value=null},m=async T=>{try{return t.value=!0,i.value=T,o.onSave&&await o.onSave(T),u(),T}catch(V){const b=V;throw l.value=b,o.onError&&o.onError(b),b}finally{t.value=!1}},f=()=>{o.onCancel&&o.onCancel(),u()},p=T=>{l.value=T,o.onError&&o.onError(T)},v=()=>{l.value=null},g=()=>i.value,k=e.computed(()=>n.value&&i.value!==null&&!t.value);return{isOpen:n,isProcessing:t,uploadedImage:a,editedImage:i,sessionKey:r,initialState:s,error:l,hasError:c,hasUnsavedChanges:k,open:d,close:u,handleSave:m,handleCancel:f,handleError:p,clearError:v,getEditedImage:g}}let mr=null;function eN(o){return mr||(mr=ks(o)),mr}function tN(o){return n=>new Promise((t,a)=>{ks({...o,onSave:async r=>{o!=null&&o.onSave&&await o.onSave(r),t(r)},onError:r=>{o!=null&&o.onError&&o.onError(r),a(r)},onCancel:()=>{o!=null&&o.onCancel&&o.onCancel(),a(new Error("User cancelled"))}}).open(n)})}function _s(o){return o.filter(n=>n.media&&!n.markedForRemoval).map((n,t)=>{const a={uuid:n.media.uuid,name:n.name,order:t};return n.customProperties&&(a.custom_properties=n.customProperties),a})}function Zr(o){return o.map((n,t)=>{const a={media:n,clientId:n.uuid,name:n.name||n.file_name,order:t};return n.custom_properties&&(a.customProperties=n.custom_properties),a})}function Es(o){if(o){const t={};o.apiBaseUrl!==void 0&&(t.apiBaseUrl=o.apiBaseUrl),o.isAdmin!==void 0&&(t.isAdmin=o.isAdmin),ta(t)}return{name:"mediables",async upload(t,a){const r=await Rt().uploadFile(t,{collection:(a==null?void 0:a.collection)||"default",customProperties:a==null?void 0:a.customProperties});if(!r)throw new Error("Upload failed: No media returned");return{media:r,uuid:r.uuid}},async attach(t,a){await Rt().attachMedia(a.modelType,String(a.modelId),[t],a.collection||"images")},async attachMany(t,a){await Rt().attachMedia(a.modelType,String(a.modelId),t,a.collection||"images")},async detach(t,a){await Rt().detachMedia(a.modelType,String(a.modelId),t,a.collection||"images")},async reorder(t,a){await Rt().reorderMedia(t.modelType,String(t.modelId),a,t.collection||"images")},async fetchModelMedia(t){return await Rt().fetchModelMedia(t.modelType,String(t.modelId),t.collection||"images")},getUrl(t,a){return Rt().getMediaUrl(t,a)},getThumbnailUrl(t){var a,i;return(a=t.conversion_urls)!=null&&a.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 Rt().deleteMedia(t)},async update(t,a){const r=await Rt().updateMedia(t,a);if(!r)throw new Error("Update failed: No media returned");return r},configure(t){const a={};t.apiBaseUrl!==void 0&&(a.apiBaseUrl=t.apiBaseUrl),t.isAdmin!==void 0&&(a.isAdmin=t.isAdmin),ta(a)}}}let $o=null;function nN(){return $o||($o=Es()),$o}function aN(){$o=null}const oN={apiBaseUrl:"/media-library-pro"};function _o(){var o;return typeof document>"u"?null:((o=document.querySelector('meta[name="csrf-token"]'))==null?void 0:o.getAttribute("content"))||null}function pr(o){const n={uuid:o.uuid,file_name:o.fileName||o.name,mime_type:`application/${o.extension}`,size:o.size,disk:"public",original_url:o.original_url||"",created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return o.name&&(n.name=o.name),o.original_url&&(n.url=o.original_url),o.preview_url&&(n.thumbnail_url=o.preview_url,n.preview_url=o.preview_url),o.custom_properties&&(n.custom_properties=o.custom_properties),n}function xs(o){const n={...oN,...o};return{name:"spatie",async upload(a,i){const r=new FormData;r.append("file",a),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||_o();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 f=await d.json().catch(()=>({message:"Upload failed"}));throw new Error(f.message||`HTTP ${d.status}`)}const u=await d.json(),m=pr(u);return i!=null&&i.onProgress&&i.onProgress(100),{media:m,uuid:u.uuid}},async attach(a,i){},async attachMany(a,i){},async detach(a,i){},async reorder(a,i){},async fetchModelMedia(a){const i={Accept:"application/json",...n.headers},r=n.csrfToken||_o();r&&(i["X-CSRF-TOKEN"]=r);const s=new URLSearchParams;s.append("model_type",a.modelType),s.append("model_id",String(a.modelId)),a.collection&&s.append("collection",a.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(pr)}catch{return[]}},getUrl(a,i){var r;if(i){const s=(r=a.conversion_urls)==null?void 0:r[i];if(s)return s}return a.original_url||a.url||""},getThumbnailUrl(a){var i,r;return a.preview_url?a.preview_url:(i=a.conversion_urls)!=null&&i.preview?a.conversion_urls.preview:a.thumbnail_url?a.thumbnail_url:(r=a.conversion_urls)!=null&&r.thumb?a.conversion_urls.thumb:a.original_url||a.url||""},async delete(a){const i={Accept:"application/json",...n.headers},r=n.csrfToken||_o();r&&(i["X-CSRF-TOKEN"]=r);const s=await fetch(`${n.apiBaseUrl}/uploads/${a}`,{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(a,i){const r={Accept:"application/json","Content-Type":"application/json",...n.headers},s=n.csrfToken||_o();s&&(r["X-CSRF-TOKEN"]=s);const l=await fetch(`${n.apiBaseUrl}/uploads/${a}`,{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 pr(c)},configure(a){Object.assign(n,a)}}}let Ro=null;function iN(){return Ro||(Ro=xs()),Ro}function rN(){Ro=null}function ru(o,n){switch(o){case"mediables":return Es(n);case"spatie":return xs(n);default:throw new Error(`Unknown adapter: ${o}`)}}function su(o={}){const{enabled:n=!0,onReorder:t,onDragStart:a,onDragEnd:i,draggingClass:r="is-dragging",dropTargetClass:s="is-drop-target"}=o,l=e.ref({isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null}),c=e.ref(!1);let d=null;function u(V,b,h){n&&("dataTransfer"in V&&V.dataTransfer&&(V.dataTransfer.effectAllowed="move",V.dataTransfer.setData("text/plain",String(h))),d=V.target,d&&d.classList.add(r),l.value={isDragging:!0,dragIndex:h,dropIndex:h,draggedItem:b},c.value=!0,a==null||a(b,h))}function m(V,b){var h;if(!(!n||!l.value.isDragging)&&(V.preventDefault(),l.value.dropIndex!==b)){const _=document.querySelector(`.${s}`);_==null||_.classList.remove(s);const R=(h=V.target)==null?void 0:h.closest("[data-index]");R==null||R.classList.add(s),l.value.dropIndex=b}}function f(){if(!l.value.isDragging)return;const{dragIndex:V,dropIndex:b,draggedItem:h}=l.value;d&&d.classList.remove(r);const _=document.querySelector(`.${s}`);_==null||_.classList.remove(s),V!==null&&b!==null&&V!==b&&h&&(t==null||t({fromIndex:V,toIndex:b,item:h})),v(),i==null||i()}function p(){d&&d.classList.remove(r);const V=document.querySelector(`.${s}`);V==null||V.classList.remove(s),v(),i==null||i()}function v(){l.value={isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null},c.value=!1,d=null}function g(V,b,h){const _=[...V],[R]=_.splice(b,1);return _.splice(h,0,R),_.map((M,x)=>({...M,order:x}))}function k(V,b){return{draggable:n,"data-index":b,onDragstart:h=>u(h,V,b),onDragover:h=>m(h,b),onDragend:()=>f(),onDrop:h=>{h.preventDefault(),f()}}}function T(V){V.key==="Escape"&&l.value.isDragging&&p()}return e.onMounted(()=>{document.addEventListener("keydown",T)}),e.onUnmounted(()=>{document.removeEventListener("keydown",T),p()}),{dragState:l,isDragging:c,startDrag:u,handleDragOver:m,endDrag:f,cancelDrag:p,reorderItems:g,getDragProps:k}}function wi(o={}){const{initialItems:n=[],modelType:t,modelId:a,collection:i="images",maxItems:r,maxFileSize:s,acceptedMimeTypes:l,sortable:c=!0,disabled:d=!1,rules:u={},adapterType:m="mediables",adapter:f,maxConcurrentUploads:p=3,onChange:v,onUpload:g,onUploadComplete:k,onUploadError:T,onRemove:V,onReorder:b,onError:h,onReadyToSubmitChange:_}=o,R={maxItems:r,maxFileSize:s,acceptedMimeTypes:l,...u},M=f||ru(m),x=e.ref([]),C=e.ref(!1),P=e.ref([]);function S(ce){if(ce.length===0)return[];const pe=ce[0];return"media"in pe&&"clientId"in pe?ce:Zr(ce)}x.value=S(n);const{acceptString:D,canAddFiles:I}=ys({rules:R}),j=bs({adapter:M,maxConcurrent:p,rules:R,collection:i,onUploadStart:ce=>{g==null||g(ce)},onUploadComplete:(ce,pe)=>{const xe=x.value.findIndex(Fe=>Fe.clientId===ce.id);xe!==-1&&(x.value[xe]={...x.value[xe],media:pe,name:pe.name||pe.file_name,upload:{...ce,status:"completed"}}),k==null||k(pe)},onUploadError:(ce,pe)=>{const xe=x.value.findIndex(Fe=>Fe.clientId===ce.id);xe!==-1&&(x.value[xe]={...x.value[xe],upload:{...ce,status:"error",error:pe.message},errors:[{field:"upload",message:pe.message,code:"UPLOAD_ERROR"}]}),T==null||T({file:ce.file,message:pe.message})},onQueueComplete:()=>{v==null||v(x.value)}}),{dragState:O,getDragProps:F,reorderItems:B}=su({enabled:c&&!d,onReorder:ce=>{x.value=B(x.value,ce.fromIndex,ce.toIndex),b==null||b(x.value),v==null||v(x.value)}}),w=e.computed(()=>j.isUploading.value),$=e.computed(()=>!j.isUploading.value&&j.pendingCount.value===0),z=e.computed(()=>r?x.value.length>=r:!1),W=e.computed(()=>_s(x.value)),Q=e.computed(()=>x.value.length),ye=e.computed(()=>r?Math.max(0,r-x.value.length):1/0);e.watch($,ce=>{_==null||_(ce)});function we(ce){x.value=S(ce),v==null||v(x.value)}async function ie(ce){if(d)return;const pe=Array.from(ce);if(!I(pe.length,x.value.length)){const tt={field:"count",message:`Maximum ${r} files allowed`,code:"MAX_ITEMS"};P.value=[tt],h==null||h([tt]);return}const xe=await j.addFiles(pe),Fe=x.value.length,ut=xe.map((tt,Et)=>({...tt,order:Fe+Et}));x.value=[...x.value,...ut],v==null||v(x.value)}function N(ce){d||(ce.upload&&(ce.upload.status==="uploading"||ce.upload.status==="pending")&&j.cancelUpload(ce.clientId),x.value=x.value.filter(pe=>pe.clientId!==ce.clientId),x.value=x.value.map((pe,xe)=>({...pe,order:xe})),V==null||V(ce),v==null||v(x.value))}function L(ce){const pe=x.value.find(xe=>xe.clientId===ce);pe&&N(pe)}function te(){d||(j.clearAll(),x.value=[],v==null||v(x.value))}function ne(ce,pe){d||!c||(x.value=B(x.value,ce,pe),b==null||b(x.value),v==null||v(x.value))}function re(ce,pe){if(d)return;const xe=x.value.findIndex(Fe=>Fe.clientId===ce);xe!==-1&&(x.value[xe]={...x.value[xe],...pe},v==null||v(x.value))}function he(ce){j.cancelUpload(ce),L(ce)}async function de(ce){await j.retryUpload(ce)}async function me(){if(!t||!a)throw new Error("modelType and modelId are required for save()");const ce={modelType:t,modelId:a,collection:i},pe=x.value.filter(xe=>xe.media&&!xe.markedForRemoval).map(xe=>xe.media.uuid);C.value=!0;try{await M.attachMany(pe,ce),await M.reorder(ce,pe)}finally{C.value=!1}}async function Ve(){if(!t||!a)throw new Error("modelType and modelId are required for load()");const ce={modelType:t,modelId:a,collection:i};C.value=!0;try{const pe=await M.fetchModelMedia(ce);x.value=Zr(pe),v==null||v(x.value)}finally{C.value=!1}}return e.onMounted(()=>{t&&a&&n.length===0&&Ve().catch(console.error)}),e.onUnmounted(()=>{j.clearAll()}),{items:x,setItems:we,addFiles:ie,removeItem:N,removeItemById:L,clearAll:te,reorderItems:ne,updateItem:re,cancelUpload:he,retryUpload:de,save:me,load:Ve,isLoading:C,isUploading:w,isReadyToSubmit:$,isAtMaxItems:z,errors:P,dragState:O,getDragProps:F,adapter:M,formValues:W,acceptString:D,count:Q,remainingSlots:ye}}const sN=["aria-disabled"],lN=["accept","multiple","disabled"],cN={class:"media-dropzone__content"},dN={class:"media-dropzone__title"},uN={class:"media-dropzone__subtitle"},mN=["disabled"],pN={key:0,class:"media-dropzone__helper"},fN=e.defineComponent({__name:"MediaCollectionDropzone",props:{accept:{default:"*"},multiple:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},maxFileSize:{},maxItems:{},title:{default:"Drop files here"},subtitle:{default:"or click to browse"},buttonText:{default:"Select files"}},emits:["files"],setup(o,{emit:n}){const t=o,a=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: ${Ho(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 m(g){var T;if(g.preventDefault(),i.value=!1,t.disabled)return;const k=(T=g.dataTransfer)==null?void 0:T.files;k&&k.length>0&&a("files",k)}function f(){var g;t.disabled||(g=r.value)==null||g.click()}function p(g){const k=g.target,T=k.files;T&&T.length>0&&a("files",T),k.value=""}function v(g){(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),f())}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:f,onKeydown:v,onDragenter:c,onDragleave:d,onDragover:u,onDrop:m},[e.createElementVNode("input",{ref_key:"fileInput",ref:r,type:"file",accept:g.accept,multiple:g.multiple,disabled:g.disabled,class:"media-dropzone__input",onChange:p},null,40,lN),e.createElementVNode("div",cN,[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",dN,[e.renderSlot(g.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(g.title),1)],!0)]),e.createElementVNode("p",uN,[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(f,["stop"])},[e.renderSlot(g.$slots,"button",{},()=>[e.createTextVNode(e.toDisplayString(g.buttonText),1)],!0)],8,mN),l.value?(e.openBlock(),e.createElementBlock("p",pN,e.toDisplayString(l.value),1)):e.createCommentVNode("",!0)])],42,sN))}}),Cs=Te(fN,[["__scopeId","data-v-b1366c1e"]]),hN=["data-index"],vN={key:0,class:"media-item__drag-handle","aria-label":"Drag to reorder",role:"button",tabindex:"0"},gN={class:"media-item__thumbnail"},yN=["src","alt"],bN={key:1,class:"media-item__file-icon"},wN={key:2,class:"media-item__progress-overlay"},kN={class:"media-item__progress-text"},_N={key:3,class:"media-item__processing-overlay"},EN={key:4,class:"media-item__error-overlay"},xN={class:"media-item__info"},CN=["title"],SN={key:0,class:"media-item__size"},VN={key:1,class:"media-item__error-message"},NN={class:"media-item__actions"},TN=["disabled"],MN=["disabled"],BN=["disabled"],FN=["disabled"],IN=e.defineComponent({__name:"MediaCollectionItem",props:{item:{},adapter:{},disabled:{type:Boolean,default:!1},sortable:{type:Boolean,default:!1},showRemove:{type:Boolean,default:!0},showEdit:{type:Boolean,default:!1},index:{default:0}},emits:["remove","edit","retry","cancel"],setup(o,{emit:n}){const t=o,a=n,i=e.ref(!1),r=e.computed(()=>{var b;return(b=t.item.upload)!=null&&b.previewUrl?t.item.upload.previewUrl:t.item.media?t.adapter.getThumbnailUrl(t.item.media):null}),s=e.computed(()=>{var b,h,_;return((b=t.item.upload)==null?void 0:b.status)==="uploading"||((h=t.item.upload)==null?void 0:h.status)==="pending"||((_=t.item.upload)==null?void 0:_.status)==="queued"}),l=e.computed(()=>{var b;return((b=t.item.upload)==null?void 0:b.status)==="processing"}),c=e.computed(()=>{var b;return((b=t.item.upload)==null?void 0:b.status)==="error"||t.item.errors&&t.item.errors.length>0}),d=e.computed(()=>{var b;return(b=t.item.upload)!=null&&b.error?t.item.upload.error:t.item.errors&&t.item.errors.length>0?t.item.errors[0].message:null}),u=e.computed(()=>{var b;return((b=t.item.upload)==null?void 0:b.progress)||0}),m=e.computed(()=>{var b;return t.item.name||((b=t.item.media)==null?void 0:b.file_name)||"Unknown file"}),f=e.computed(()=>{var M,x;const b=((M=t.item.media)==null?void 0:M.size)||((x=t.item.upload)==null?void 0:x.file.size);if(!b)return"";const h=1024,_=["Bytes","KB","MB","GB"],R=Math.floor(Math.log(b)/Math.log(h));return parseFloat((b/Math.pow(h,R)).toFixed(2))+" "+_[R]}),p=e.computed(()=>{var h,_;const b=((h=t.item.media)==null?void 0:h.mime_type)||((_=t.item.upload)==null?void 0:_.file.type);return b==null?void 0:b.startsWith("image/")}),v=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||a("remove",t.item)}function k(){t.disabled||a("edit",t.item)}function T(){t.disabled||a("retry",t.item)}function V(){t.disabled||a("cancel",t.item)}return(b,h)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(v.value),"data-index":b.index,onMouseenter:h[0]||(h[0]=_=>i.value=!0),onMouseleave:h[1]||(h[1]=_=>i.value=!1)},[b.sortable&&!b.disabled?(e.openBlock(),e.createElementBlock("div",vN,[...h[2]||(h[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",gN,[r.value&&p.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.value,alt:m.value,class:"media-item__image"},null,8,yN)):(e.openBlock(),e.createElementBlock("div",bN,[...h[3]||(h[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",wN,[e.createElementVNode("div",{class:"media-item__progress-bar",style:e.normalizeStyle({width:`${u.value}%`})},null,4),e.createElementVNode("span",kN,e.toDisplayString(u.value)+"%",1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",_N,[...h[4]||(h[4]=[e.createElementVNode("div",{class:"media-item__spinner","aria-label":"Processing"},null,-1)])])):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",EN,[...h[5]||(h[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",xN,[e.createElementVNode("span",{class:"media-item__name",title:m.value},e.toDisplayString(m.value),9,CN),f.value?(e.openBlock(),e.createElementBlock("span",SN,e.toDisplayString(f.value),1)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("span",VN,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",NN,[s.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-item__action media-item__action--cancel",disabled:b.disabled,"aria-label":"Cancel upload",onClick:V},[...h[6]||(h[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,TN)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"media-item__action media-item__action--retry",disabled:b.disabled,"aria-label":"Retry upload",onClick:T},[...h[7]||(h[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,MN)):e.createCommentVNode("",!0),b.showEdit&&b.item.media&&!s.value?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"media-item__action media-item__action--edit",disabled:b.disabled,"aria-label":"Edit",onClick:k},[...h[8]||(h[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,BN)):e.createCommentVNode("",!0),b.showRemove?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"media-item__action media-item__action--remove",disabled:b.disabled,"aria-label":"Remove",onClick:g},[...h[9]||(h[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,FN)):e.createCommentVNode("",!0)])],42,hN))}}),Ss=Te(IN,[["__scopeId","data-v-ff81c9ec"]]),$N=["aria-label"],RN=["draggable","data-index","onDragstart","onDragover","onDragend","onDrop"],DN={key:0,class:"media-collection__footer"},AN={class:"media-collection__count"},LN={key:0},UN={key:0,class:"media-collection__uploading"},ON=["name","value"],PN=["name","value"],zN=["name","value"],jN=["name","value"],WN={key:3,class:"media-collection__errors",role:"alert","aria-live":"polite"},ZN=e.defineComponent({__name:"MediaCollection",props:{modelValue:{default:()=>[]},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxItems:{},maxFileSize:{},acceptedMimeTypes:{},sortable:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","reorder","is-ready-to-submit-change","validation-error"],setup(o,{emit:n}){const t=o,a=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=>{a("update:modelValue",w),a("change",w)},onUpload:w=>{a("upload",w)},onUploadComplete:w=>{a("upload-complete",w)},onUploadError:w=>{a("upload-error",w)},onRemove:w=>{a("remove",w)},onReorder:w=>{a("reorder",w)},onError:w=>{a("validation-error",w)},onReadyToSubmitChange:w=>{a("is-ready-to-submit-change",w)}},{items:r,setItems:s,addFiles:l,removeItem:c,reorderItems:d,cancelUpload:u,retryUpload:m,isLoading:f,isUploading:p,isAtMaxItems:v,errors:g,dragState:k,getDragProps:T,adapter:V,formValues:b,acceptString:h,count:_,remainingSlots:R}=wi(i);e.provide("mediaAdapter",V),e.provide("mediaCollection",{items:r,addFiles:l,removeItem:c,reorderItems:d}),e.watch(()=>t.modelValue,w=>{w!==r.value&&s(w)},{deep:!0});const M=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!v.value),x=e.computed(()=>({"media-collection":!0,"media-collection--disabled":t.disabled,"media-collection--readonly":t.readonly,"media-collection--loading":f.value,"media-collection--has-items":r.value.length>0,"media-collection--dragging":k.value.isDragging}));function C(w){l(w)}function P(w){c(w)}function S(w){m(w.clientId)}function D(w){u(w.clientId)}function I(w){}function j(w,$,z){if(!t.sortable||t.disabled)return;const W=T($,z);W.onDragstart&&W.onDragstart(w)}function O(w,$){if(!t.sortable||t.disabled)return;w.preventDefault();const z=r.value[$],W=T(z,$);W.onDragover&&W.onDragover(w)}function F(w,$){const z=T(w,$);z.onDragend&&z.onDragend()}function B(w,$){w.preventDefault();const z=r.value[$],W=T(z,$);W.onDrop&&W.onDrop(w)}return(w,$)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(x.value)},[e.renderSlot(w.$slots,"dropzone",{addFiles:e.unref(l)},()=>[M.value?(e.openBlock(),e.createBlock(Cs,{key:0,accept:e.unref(h),multiple:w.maxItems!==1,disabled:w.disabled,"max-file-size":w.maxFileSize,"max-items":e.unref(R),onFiles:C},null,8,["accept","multiple","disabled","max-file-size","max-items"])):e.createCommentVNode("",!0)],!0),e.unref(r).length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"media-collection__list",role:"list","aria-label":`${e.unref(_)} media items`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r),(z,W)=>e.renderSlot(w.$slots,"item",{key:z.clientId,item:z,index:W,remove:()=>P(z)},()=>[e.createElementVNode("div",{class:e.normalizeClass(["media-collection__item-wrapper",{"media-collection__item-wrapper--drag-over":e.unref(k).dropIndex===W}]),draggable:w.sortable&&!w.disabled,"data-index":W,onDragstart:Q=>j(Q,z,W),onDragover:Q=>O(Q,W),onDragend:Q=>F(z,W),onDrop:Q=>B(Q,W)},[e.createVNode(Ss,{item:z,adapter:e.unref(V),disabled:w.disabled,sortable:w.sortable,"show-remove":!w.readonly,"show-edit":!1,index:W,onRemove:P,onRetry:S,onCancel:D,onEdit:I},null,8,["item","adapter","disabled","sortable","show-remove","index"])],42,RN)],!0)),128))],8,$N)):M.value?e.createCommentVNode("",!0):e.renderSlot(w.$slots,"empty",{key:1},()=>[$[0]||($[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(_),isUploading:e.unref(p)},()=>[e.unref(r).length>0?(e.openBlock(),e.createElementBlock("div",DN,[e.createElementVNode("span",AN,[e.createTextVNode(e.toDisplayString(e.unref(_))+" "+e.toDisplayString(e.unref(_)===1?"file":"files")+" ",1),w.maxItems?(e.openBlock(),e.createElementBlock("span",LN," / "+e.toDisplayString(w.maxItems)+" max",1)):e.createCommentVNode("",!0)]),e.unref(p)?(e.openBlock(),e.createElementBlock("span",UN," 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(b),(z,W)=>(e.openBlock(),e.createElementBlock("input",{key:`${w.name}-${z.uuid}`,type:"hidden",name:`${w.name}[${W}][uuid]`,value:z.uuid},null,8,ON))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),(z,W)=>(e.openBlock(),e.createElementBlock("input",{key:`${w.name}-${z.uuid}-name`,type:"hidden",name:`${w.name}[${W}][name]`,value:z.name},null,8,PN))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),(z,W)=>(e.openBlock(),e.createElementBlock("input",{key:`${w.name}-${z.uuid}-order`,type:"hidden",name:`${w.name}[${W}][order]`,value:z.order},null,8,zN))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),(z,W)=>(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}[${W}][custom_properties]`,value:JSON.stringify(z.custom_properties)},null,8,jN)):e.createCommentVNode("",!0)],64))),128))],64)):e.createCommentVNode("",!0),e.unref(g).length>0?(e.openBlock(),e.createElementBlock("div",WN,[(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))}}),HN=Te(ZN,[["__scopeId","data-v-10a5bfff"]]);function Vs(o={}){const{initialItem:n,onChange:t,onReplace:a,onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:l,onError:c,onReadyToSubmitChange:d,...u}=o,f={...u,initialItems:n?[n]:[],maxItems:1,sortable:!1,onChange:M=>{t==null||t(M[0]||null)},onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:l,onError:c,onReadyToSubmitChange:d},p=wi(f),v=e.computed(()=>p.items.value[0]||null),g=e.computed(()=>v.value!==null),k=e.computed(()=>p.formValues.value[0]||null);function T(M){M===null?p.clearAll():p.setItems([M])}async function V(M){const x=v.value;x&&p.removeItem(x),await p.addFiles([M])}function b(){v.value&&p.removeItem(v.value)}async function h(M){const x=v.value;x&&p.removeItem(x),await p.addFiles([M]);const C=p.items.value[0];C&&(a==null||a(x,C))}function _(){var M;(M=v.value)!=null&&M.upload&&p.cancelUpload(v.value.clientId)}async function R(){var M,x;((x=(M=v.value)==null?void 0:M.upload)==null?void 0:x.status)==="error"&&await p.retryUpload(v.value.clientId)}return{item:v,setItem:T,addFile:V,removeItem:b,replaceItem:h,cancelUpload:_,retryUpload:R,save:p.save,load:p.load,isLoading:p.isLoading,isUploading:p.isUploading,isReadyToSubmit:p.isReadyToSubmit,hasItem:g,errors:p.errors,adapter:p.adapter,formValue:k,acceptString:p.acceptString}}const XN=["accept","disabled"],GN={class:"media-attachment__preview"},JN=["name","value"],YN=["name","value"],qN=["name","value"],KN=["name","value"],QN={key:4,class:"media-attachment__errors",role:"alert","aria-live":"polite"},e5=e.defineComponent({__name:"MediaAttachment",props:{modelValue:{default:null},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxFileSize:{},acceptedMimeTypes:{},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0},showReplaceButton:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","replace","is-ready-to-submit-change","validation-error"],setup(o,{emit:n}){const t=o,a=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:S=>{a("update:modelValue",S),a("change",S)},onUpload:S=>{a("upload",S)},onUploadComplete:S=>{a("upload-complete",S)},onUploadError:S=>{a("upload-error",S)},onRemove:S=>{a("remove",S)},onReplace:(S,D)=>{a("replace",D)},onError:S=>{a("validation-error",S)},onReadyToSubmitChange:S=>{a("is-ready-to-submit-change",S)}},{item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:f,isLoading:p,hasItem:v,errors:g,adapter:k,formValue:T,acceptString:V}=Vs(r);e.provide("mediaAdapter",k),e.watch(()=>t.modelValue,S=>{S!==s.value&&l(S)},{deep:!0});const b=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!v.value),h=e.computed(()=>({"media-attachment":!0,"media-attachment--disabled":t.disabled,"media-attachment--readonly":t.readonly,"media-attachment--loading":p.value,"media-attachment--has-item":v.value}));function _(S){S.length>0&&c(S[0])}function R(){var S;(S=i.value)==null||S.click()}function M(S){const D=S.target,I=D.files;I&&I.length>0&&u(I[0]),D.value=""}function x(S){d()}function C(S){f()}function P(S){m()}return(S,D)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(h.value)},[e.createElementVNode("input",{ref_key:"fileInputRef",ref:i,type:"file",accept:e.unref(V),disabled:S.disabled,class:"media-attachment__hidden-input",onChange:M},null,40,XN),b.value?e.renderSlot(S.$slots,"dropzone",{key:0,addFile:e.unref(c)},()=>[e.createVNode(Cs,{accept:e.unref(V),multiple:!1,disabled:S.disabled,"max-file-size":S.maxFileSize,onFiles:_},null,8,["accept","disabled","max-file-size"])],!0):e.unref(v)&&e.unref(s)?e.renderSlot(S.$slots,"preview",{key:1,item:e.unref(s),remove:e.unref(d),replace:R},()=>[e.createElementVNode("div",GN,[e.createVNode(Ss,{item:e.unref(s),adapter:e.unref(k),disabled:S.disabled,sortable:!1,"show-remove":!S.readonly,"show-edit":!1,onRemove:x,onRetry:C,onCancel:P},null,8,["item","adapter","disabled","show-remove"]),S.showReplaceButton&&!S.readonly&&!S.disabled&&e.unref(s).media?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-attachment__replace-button",onClick:R},[...D[0]||(D[0]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.createElementVNode("polyline",{points:"17 8 12 3 7 8"}),e.createElementVNode("line",{x1:"12",y1:"3",x2:"12",y2:"15"})],-1),e.createTextVNode(" Replace ",-1)])])):e.createCommentVNode("",!0)])],!0):e.renderSlot(S.$slots,"empty",{key:2},()=>[D[1]||(D[1]=e.createElementVNode("div",{class:"media-attachment__empty"},[e.createElementVNode("p",null,"No file selected")],-1))],!0),S.generateFormFields&&e.unref(T)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("input",{type:"hidden",name:`${S.name}[uuid]`,value:e.unref(T).uuid},null,8,JN),e.createElementVNode("input",{type:"hidden",name:`${S.name}[name]`,value:e.unref(T).name},null,8,YN),e.createElementVNode("input",{type:"hidden",name:`${S.name}[order]`,value:e.unref(T).order},null,8,qN),e.unref(T).custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${S.name}[custom_properties]`,value:JSON.stringify(e.unref(T).custom_properties)},null,8,KN)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),e.unref(g).length>0?(e.openBlock(),e.createElementBlock("div",QN,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),I=>(e.openBlock(),e.createElementBlock("p",{key:I.code||I.message,class:"media-attachment__error"},e.toDisplayString(I.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),t5=Te(e5,[["__scopeId","data-v-26911174"]]),lu={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"}},n5=e.defineComponent({__name:"MediaCollectionProvider",props:{modelValue:{default:()=>[]},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxItems:{},maxFileSize:{},acceptedMimeTypes:{},sortable:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","reorder","is-ready-to-submit-change","validation-error"],setup(o,{expose:n,emit:t}){const a=o,i=t,r={initialItems:a.modelValue,modelType:a.modelType,modelId:a.modelId,collection:a.collection,maxItems:a.maxItems,maxFileSize:a.maxFileSize,acceptedMimeTypes:a.acceptedMimeTypes,sortable:a.sortable,disabled:a.disabled,rules:a.rules,adapterType:a.adapter,onChange:S=>{i("update:modelValue",S),i("change",S)},onUpload:S=>{i("upload",S)},onUploadComplete:S=>{i("upload-complete",S)},onUploadError:S=>{i("upload-error",S)},onRemove:S=>{i("remove",S)},onReorder:S=>{i("reorder",S)},onError:S=>{i("validation-error",S)},onReadyToSubmitChange:S=>{i("is-ready-to-submit-change",S)}},{items:s,setItems:l,addFiles:c,removeItem:d,reorderItems:u,updateItem:m,cancelUpload:f,retryUpload:p,isLoading:v,isUploading:g,isReadyToSubmit:k,isAtMaxItems:T,errors:V,dragState:b,getDragProps:h,adapter:_,formValues:R,acceptString:M}=wi(r);e.provide("mediaAdapter",_),e.provide("mediaCollection",{items:s,addFiles:c,removeItem:d,reorderItems:u}),e.watch(()=>a.modelValue,S=>{S!==s.value&&l(S)},{deep:!0});const x=e.computed(()=>({...lu,...a.labels})),C=e.computed(()=>({accept:M.value,multiple:a.maxItems!==1,disabled:a.disabled||a.readonly||T.value})),P=e.computed(()=>({items:s.value,isLoading:v.value,isUploading:g.value,isReadyToSubmit:k.value,isAtMaxItems:T.value,errors:V.value,addFiles:c,removeItem:d,reorderItems:u,clearAll:()=>{s.value.forEach(S=>d(S))},cancelUpload:f,retryUpload:p,labels:x.value,dropzoneProps:C.value}));return n({items:s,addFiles:c,removeItem:d,reorderItems:u,updateItem:m,cancelUpload:f,retryUpload:p,isLoading:v,isUploading:g,isReadyToSubmit:k,isAtMaxItems:T,errors:V,dragState:b,getDragProps:h,adapter:_,formValues:R,acceptString:M}),(S,D)=>e.renderSlot(S.$slots,"default",e.normalizeProps(e.guardReactiveProps(P.value)))}}),a5=e.defineComponent({__name:"MediaAttachmentProvider",props:{modelValue:{default:null},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxFileSize:{},acceptedMimeTypes:{},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0},showReplaceButton:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","replace","is-ready-to-submit-change","validation-error"],setup(o,{expose:n,emit:t}){const a=o,i=t,r={initialItem:a.modelValue,modelType:a.modelType,modelId:a.modelId,collection:a.collection,maxFileSize:a.maxFileSize,acceptedMimeTypes:a.acceptedMimeTypes,disabled:a.disabled,rules:a.rules,adapterType:a.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,C)=>{i("replace",C)},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:m,retryUpload:f,isLoading:p,isUploading:v,isReadyToSubmit:g,hasItem:k,errors:T,adapter:V,formValue:b,acceptString:h}=Vs(r);e.provide("mediaAdapter",V),e.watch(()=>a.modelValue,x=>{x!==s.value&&l(x)},{deep:!0});const _=e.computed(()=>({...lu,...a.labels})),R=e.computed(()=>({accept:h.value,multiple:!1,disabled:a.disabled||a.readonly||k.value})),M=e.computed(()=>({item:s.value,hasItem:k.value,isLoading:p.value,isUploading:v.value,isReadyToSubmit:g.value,errors:T.value,addFile:c,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:f,labels:_.value,dropzoneProps:R.value}));return n({item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:f,isLoading:p,isUploading:v,isReadyToSubmit:g,hasItem:k,errors:T,adapter:V,formValue:b,acceptString:h}),(x,C)=>e.renderSlot(x.$slots,"default",e.normalizeProps(e.guardReactiveProps(M.value)))}}),o5=["name","value"],i5=["name","value"],r5=["name","value"],s5=["name","value"],l5=e.defineComponent({__name:"MediaHiddenFields",props:{items:{default:()=>[]},item:{default:null},name:{default:"media"},format:{default:"mediables"}},setup(o){const n=o,t=e.computed(()=>n.item?[n.item]:n.items),a=e.computed(()=>_s(t.value));function i(l,c){var u;const d=((u=a.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(a.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,o5),e.createElementVNode("input",{type:"hidden",name:s(u,"name"),value:d.name},null,8,i5),e.createElementVNode("input",{type:"hidden",name:s(u,"order"),value:d.order},null,8,r5),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,s5)):e.createCommentVNode("",!0)],64))),128))}}),c5=["data-testid"],d5=["data-testid"],u5=["id"],m5=["value","maxlength","disabled","aria-labelledby","placeholder","data-testid","onInput"],p5=e.defineComponent({__name:"MediaAttachmentMetadataFields",props:{items:{},disabled:{type:Boolean,default:!1},label:{default:"Caption"},placeholder:{default:"Add an optional caption"},maxLength:{default:500},testIdPrefix:{default:"media-attachment-metadata"},getItemLabel:{type:Function,default:(o,n)=>`${o.type==="video"?"video":"photo"} ${n+1}`}},emits:["update:items"],setup(o,{emit:n}){const t=o,a=n;function i(r,s){const l=s.target;l instanceof HTMLInputElement&&a("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,u5),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,m5)],8,d5))),128))],8,c5)):e.createCommentVNode("",!0)}}),f5=Te(p5,[["__scopeId","data-v-a153768a"]]),h5="/v1/media/deletion/check",v5="/v1/media/deletion/delete",Eo=100;function sc(o){const n=new Set,t=[];for(const a of o){const i=a.trim().toLowerCase();i===""||n.has(i)||(n.add(i),t.push(i))}return t.sort()}function cu(o){const n=o.checkEndpoint??h5,t=o.deleteEndpoint??v5,a=e.ref(!1),i=e.ref(!1),r=e.ref(null),s=e.ref(null),l=e.ref(null);async function c(m){l.value=null;const f=sc(m);if(f.length===0)return r.value=[],[];if(f.length>Eo){const p=new Error(`Cannot check more than ${Eo} media items at once.`);throw l.value=p,p}a.value=!0;try{const p=await o.httpClient.post(n,{uuids:f}),v=((p==null?void 0:p.data)??[]).map(g=>{var k,T,V,b;return{uuid:g.uuid,canDelete:((k=g.report)==null?void 0:k.canDelete)??!1,blocks:Array.isArray((T=g.report)==null?void 0:T.blocks)?g.report.blocks:[],cascade:Array.isArray((V=g.report)==null?void 0:V.cascade)?g.report.cascade:[],variantCount:typeof((b=g.report)==null?void 0:b.variantCount)=="number"?g.report.variantCount:0}});return r.value=v,v}catch(p){throw l.value=p instanceof Error?p:new Error(String(p)),l.value}finally{a.value=!1}}async function d(m,f={}){l.value=null;const p=sc(m);if(p.length===0){const v={results:[],summary:{}};return s.value=v,v}if(p.length>Eo){const v=new Error(`Cannot delete more than ${Eo} media items at once.`);throw l.value=v,v}i.value=!0;try{const v=await o.httpClient.post(t,{uuids:p,force:f.force===!0}),g={results:Array.isArray(v==null?void 0:v.results)?v.results:[],summary:(v==null?void 0:v.summary)??{}};return s.value=g,g}catch(v){throw l.value=v instanceof Error?v:new Error(String(v)),l.value}finally{i.value=!1}}function u(){r.value=null,s.value=null,l.value=null}return{isChecking:a,isDeleting:i,lastReport:r,lastResponse:s,error:l,checkDependencies:c,deleteMany:d,reset:u}}const g5="/v1/user/media/trash";function y5(o){return`/v1/user/media/${encodeURIComponent(o)}/restore`}function du(o){const n=o.listEndpoint??g5,t=o.buildRestoreEndpoint??y5,a=o.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(p=1){var v,g;d.value=null,l.value=!0;try{const k=await o.httpClient.get(n,{params:{page:p,per_page:a}});i.value=Array.isArray(k==null?void 0:k.data)?k.data:[],r.value=typeof((v=k==null?void 0:k.meta)==null?void 0:v.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:p}catch(k){throw d.value=k instanceof Error?k:new Error(String(k)),d.value}finally{l.value=!1}}async function m(p){d.value=null,c.value=!0;try{const v=await o.httpClient.post(t(p)),g={status:(v==null?void 0:v.status)??"failed",data:(v==null?void 0:v.data)??null,duplicate_uuid:(v==null?void 0:v.duplicate_uuid)??null};return typeof(v==null?void 0:v.message)=="string"&&(g.message=v.message),g.status==="restored"&&(i.value=i.value.filter(k=>k.uuid!==p),r.value=Math.max(0,r.value-1)),g}catch(v){const g=b5(v);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=v instanceof Error?v:new Error(String(v)),d.value}finally{c.value=!1}}function f(){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:m,reset:f}}function b5(o){var t;if(typeof o!="object"||o===null)return null;const n=o;return(t=n.response)!=null&&t.data&&typeof n.response.data=="object"?n.response.data:null}const w5={class:"media-management-view","data-testid":"media-management-view"},k5={class:"media-management-view__header"},_5={class:"media-management-view__title"},E5={class:"media-management-view__actions"},x5={key:0,class:"media-management-view__badge"},C5={key:0,class:"media-management-view__panel","data-testid":"panel-library"},S5={key:0,class:"media-management-view__status","data-testid":"library-loading"},V5={key:1,class:"media-management-view__status media-management-view__status--error","data-testid":"library-error"},N5={key:2,class:"media-management-view__empty","data-testid":"library-empty"},T5={key:3,class:"media-management-view__grid","data-testid":"library-grid"},M5=["data-testid"],B5=["data-testid","aria-pressed","onClick"],F5=["src","alt"],I5={key:1,class:"media-management-view__item-placeholder"},$5={class:"media-management-view__item-meta"},R5={class:"media-management-view__item-name"},D5=["data-testid"],A5={key:1,class:"media-management-view__item-badge","data-testid":"badge-orphaned"},L5={key:4,class:"media-management-view__bulk-bar","data-testid":"bulk-bar"},U5={"data-testid":"bulk-count"},O5=["disabled"],P5={key:1,class:"media-management-view__panel","data-testid":"panel-trash"},z5={key:0,class:"media-management-view__status","data-testid":"trash-loading"},j5={key:1,class:"media-management-view__empty","data-testid":"trash-empty"},W5={key:2,class:"media-management-view__grid","data-testid":"trash-grid"},Z5=["data-testid"],H5={class:"media-management-view__item-thumb"},X5=["src","alt"],G5={class:"media-management-view__item-meta"},J5={class:"media-management-view__item-name"},Y5={key:0,class:"media-management-view__item-meta-line"},q5=["data-testid","disabled","onClick"],K5=e.defineComponent({__name:"MediaManagementView",props:{httpClient:{},capabilities:{default:()=>({})},labels:{default:()=>({})},confirmBulkDelete:{},onRestoreCollision:{}},emits:["deleted","restored","restore-conflict","error"],setup(o,{expose:n,emit:t}){const a=o,i=t,r=e.computed(()=>({showTrash:!0,allowBulkDelete:!0,showOwner:!1,...a.capabilities})),s=e.computed(()=>{var F,B,w,$,z,W,Q,ye,we,ie,N,L;return{title:((F=a.labels)==null?void 0:F.title)??"My Media",libraryTab:((B=a.labels)==null?void 0:B.libraryTab)??"Library",trashTab:((w=a.labels)==null?void 0:w.trashTab)??"Trash",loading:(($=a.labels)==null?void 0:$.loading)??"Loading…",emptyLibrary:((z=a.labels)==null?void 0:z.emptyLibrary)??"No media yet — upload your first creation.",emptyTrash:((W=a.labels)==null?void 0:W.emptyTrash)??"Trash is empty.",orphanedBadge:((Q=a.labels)==null?void 0:Q.orphanedBadge)??"Not in use",selectedCount:((ye=a.labels)==null?void 0:ye.selectedCount)??(te=>`${te} selected`),deleteButton:((we=a.labels)==null?void 0:we.deleteButton)??"Delete",restoreButton:((ie=a.labels)==null?void 0:ie.restoreButton)??"Restore",purgeAfter:((N=a.labels)==null?void 0:N.purgeAfter)??(te=>`Purges ${te}`),ownerLabel:((L=a.labels)==null?void 0:L.ownerLabel)??(te=>`User ${te.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),m=e.computed(()=>s.value.emptyLibrary),f=e.computed(()=>s.value.emptyTrash),p=e.computed(()=>s.value.orphanedBadge),v=e.computed(()=>s.value.deleteButton),g=e.computed(()=>s.value.restoreButton),k=e.ref("library"),T=e.ref({scope:"library"}),V=e.ref({}),b=ws({httpClient:a.httpClient,view:T,filters:V,perPage:50}),h=e.computed(()=>b.items.value),_=e.computed(()=>b.loading.value),R=e.computed(()=>{var F;return((F=b.error.value)==null?void 0:F.message)??null}),M=Sc(h),x=cu({httpClient:a.httpClient}),C=du({httpClient:a.httpClient});function P(F){return s.value.selectedCount(F)}function S(F){return s.value.purgeAfter(F)}function D(F){return s.value.ownerLabel(F)}async function I(){const F=M.selectedItems.value;if(F.length===0)return;const B=r.value.canDelete?F.filter(w=>r.value.canDelete(w)):F;if(B.length!==0&&!(a.confirmBulkDelete&&!await a.confirmBulkDelete(B)))try{const w=B.map(W=>W.uuid),z=(await x.deleteMany(w)).results.filter(W=>W.status==="trashed"||W.status==="already_trashed").map(W=>W.uuid);if(z.length>0){for(const W of z)M.deselect(W);i("deleted",z),await b.refresh(),r.value.showTrash!==!1&&await C.fetch(C.currentPage.value).catch(()=>{})}}catch(w){i("error",w instanceof Error?w:new Error(String(w)))}}async function j(F){var B;try{const w=await C.restore(F);if(w.status==="restored"){i("restored",F),await b.refresh().catch(()=>{});return}if(w.status==="duplicate_conflict"){i("restore-conflict",{uuid:F,duplicateUuid:w.duplicate_uuid??null}),(B=a.onRestoreCollision)==null||B.call(a,F,w.duplicate_uuid??null);return}}catch(w){i("error",w instanceof Error?w:new Error(String(w)))}}async function O(){k.value="trash",C.items.value.length===0&&!C.isLoading.value&&await C.fetch().catch(F=>{i("error",F instanceof Error?F:new Error(String(F)))})}return e.watch(k,async F=>{F==="library"&&h.value.length===0&&!_.value&&await b.refresh().catch(()=>{})}),e.onMounted(async()=>{await b.refresh().catch(F=>{i("error",F instanceof Error?F:new Error(String(F)))}),r.value.showTrash!==!1&&C.fetch().catch(()=>{})}),n({refresh:()=>b.refresh(),refreshTrash:()=>C.fetch(),selection:M,deletion:x,trash:C}),(F,B)=>(e.openBlock(),e.createElementBlock("div",w5,[e.createElementVNode("header",k5,[e.createElementVNode("h2",_5,e.toDisplayString(l.value),1),e.createElementVNode("div",E5,[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:B[0]||(B[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:O},[e.createTextVNode(e.toDisplayString(d.value)+" ",1),e.unref(C).total.value>0?(e.openBlock(),e.createElementBlock("span",x5,e.toDisplayString(e.unref(C).total.value),1)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)])]),k.value==="library"?(e.openBlock(),e.createElementBlock("section",C5,[_.value?(e.openBlock(),e.createElementBlock("div",S5,e.toDisplayString(u.value),1)):R.value?(e.openBlock(),e.createElementBlock("div",V5,e.toDisplayString(R.value),1)):h.value.length===0?(e.openBlock(),e.createElementBlock("div",N5,e.toDisplayString(m.value),1)):(e.openBlock(),e.createElementBlock("ul",T5,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,w=>(e.openBlock(),e.createElementBlock("li",{key:w.uuid,class:e.normalizeClass(["media-management-view__item",{"is-selected":e.unref(M).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(M).isSelected(w.uuid),onClick:$=>e.unref(M).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,F5)):(e.openBlock(),e.createElementBlock("span",I5,e.toDisplayString(w.file_name),1))],8,B5),e.createElementVNode("div",$5,[e.createElementVNode("span",R5,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(D(w)),9,D5)):e.createCommentVNode("",!0),w.is_orphaned?(e.openBlock(),e.createElementBlock("span",A5,e.toDisplayString(p.value),1)):e.createCommentVNode("",!0)])],10,M5))),128))])),e.unref(M).selectedCount.value>0&&r.value.allowBulkDelete!==!1?(e.openBlock(),e.createElementBlock("footer",L5,[e.createElementVNode("span",U5,e.toDisplayString(P(e.unref(M).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:I},e.toDisplayString(v.value),9,O5)])):e.createCommentVNode("",!0)])):k.value==="trash"?(e.openBlock(),e.createElementBlock("section",P5,[e.unref(C).isLoading.value?(e.openBlock(),e.createElementBlock("div",z5,e.toDisplayString(u.value),1)):e.unref(C).items.value.length===0?(e.openBlock(),e.createElementBlock("div",j5,e.toDisplayString(f.value),1)):(e.openBlock(),e.createElementBlock("ul",W5,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(C).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",H5,[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,X5)):e.createCommentVNode("",!0)]),e.createElementVNode("div",G5,[e.createElementVNode("span",J5,e.toDisplayString(w.file_name),1),w.purge_after?(e.openBlock(),e.createElementBlock("span",Y5,e.toDisplayString(S(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(C).isRestoring.value,onClick:$=>j(w.uuid)},e.toDisplayString(g.value),9,q5)],8,Z5))),128))]))])):e.createCommentVNode("",!0)]))}}),Q5=Te(K5,[["__scopeId","data-v-ec535782"]]);exports.AlbumBrowser=jd;exports.AlbumManager=GV;exports.AlbumMediaGrid=r4;exports.AlbumTree=zd;exports.ArrayBufferTarget=es;exports.ExistingMediaSelector=xh;exports.ImageEditor=vc;exports.ImageEditorModal=gc;exports.LiveStreamManager=kV;exports.ManagedMediaGallery=Km;exports.MediaAlbumInlineCreate=Wd;exports.MediaAlbumUnavailableState=Zd;exports.MediaAttachment=t5;exports.MediaAttachmentMetadataFields=f5;exports.MediaCollection=HN;exports.MediaCollectionDropzone=Cs;exports.MediaCollectionItem=Ss;exports.MediaLibraryPicker=iu;exports.MediaLibraryPickerModal=z3;exports.MediaManagementView=Q5;exports.MediaPreviewSheet=Hd;exports.MediaSelectionTray=Q3;exports.MediaSourceSheet=Xd;exports.MediaThumbnailCell=Jd;exports.MediaUploadSheet=Gd;exports.MediaWorkspace=Gm;exports.ModelMediaManager=Hf;exports.Muxer=zc;exports.VideoEditor=Ad;exports.VideoEditorDialog=oE;exports.VideoEditorSimple=NE;exports.VideoExportPanel=sC;exports.VideoJobClient=gi;exports.VideoPlayer=Ud;exports.VideoTimeline=KE;exports.VideoToolsPanel=Px;exports.VideoUploader=GC;exports.VirtualMediaGrid=Yd;exports._sfc_main=n5;exports._sfc_main$1=a5;exports._sfc_main$2=l5;exports.applyTemporaryMediaStoreConfig=uc;exports.configureMediaStore=ta;exports.createAdapter=ru;exports.createEmptyEditorState=Nm;exports.createImageEditor=tN;exports.createMediablesAdapter=Es;exports.createSpatieAdapter=xs;exports.deserializeEditorState=Vm;exports.formatFileSize=Ho;exports.fromMediaArray=Zr;exports.getFileExtension=qd;exports.getImageDimensions=Kd;exports.getMediablesAdapter=nN;exports.getSpatieAdapter=iN;exports.isImageFile=gs;exports.normalizeEditorState=Hr;exports.normalizeRecipeForServerRender=U_;exports.recipeHasServerRenderableEdits=L_;exports.recipeHasUnsupportedServerEdits=Ld;exports.resetMediablesAdapter=aN;exports.resetSpatieAdapter=rN;exports.restoreMediaStoreConfig=dc;exports.serializeEditorState=lc;exports.snapshotMediaStoreConfig=cc;exports.toFormValues=_s;exports.useAdminMediaStore=mc;exports.useAlbumDragDrop=Pd;exports.useAlbumStore=bi;exports.useAlbums=Od;exports.useGlobalImageEditor=eN;exports.useImageEditorModal=ks;exports.useMediaAttachment=Vs;exports.useMediaCollection=wi;exports.useMediaDeletion=cu;exports.useMediaDragSort=su;exports.useMediaLibraryPickerController=ou;exports.useMediaLibraryQuery=ws;exports.useMediaLibrarySession=tu;exports.useMediaLibraryStateMachine=nu;exports.useMediaLibraryTelemetry=au;exports.useMediaStore=Rt;exports.useMediaTrash=du;exports.useMediaUploadQueue=bs;exports.useMediaValidation=ys;exports.validateFile=Qd;
342
- //# sourceMappingURL=index-Dx7DOxwK.cjs.map