@codingfactory/mediables-vue 2.4.3 → 2.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{PixiFrameExporter-Suw6Dxf2.cjs → PixiFrameExporter-CcI6-BwD.cjs} +2 -2
- package/dist/{PixiFrameExporter-Suw6Dxf2.cjs.map → PixiFrameExporter-CcI6-BwD.cjs.map} +1 -1
- package/dist/{PixiFrameExporter-C_1YAQeT.js → PixiFrameExporter-I8CmGVyQ.js} +2 -2
- package/dist/{PixiFrameExporter-C_1YAQeT.js.map → PixiFrameExporter-I8CmGVyQ.js.map} +1 -1
- package/dist/components/video/VideoEditorDialog.vue.d.ts +34 -2
- package/dist/index-B3wCqNBN.cjs +342 -0
- package/dist/index-B3wCqNBN.cjs.map +1 -0
- package/dist/{index-mZS1mNLQ.js → index-BjkgtVvd.js} +8799 -8532
- package/dist/index-BjkgtVvd.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/mediables-vue.cjs +1 -1
- package/dist/mediables-vue.mjs +55 -52
- package/dist/render-page/assets/{index-BLDUp5ON.js → index-DigDyl_v.js} +4 -1
- package/dist/render-page/index.html +1 -1
- package/dist/style.css +1 -1
- package/dist/types/api.d.ts +1 -1
- package/dist/utils/videoRecipeCapabilities.d.ts +12 -0
- package/package.json +1 -1
- package/dist/index-mZS1mNLQ.js.map +0 -1
- package/dist/index-wOQ7eP9R.cjs +0 -342
- package/dist/index-wOQ7eP9R.cjs.map +0 -1
package/dist/index-wOQ7eP9R.cjs
DELETED
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
"use strict";var Ed=Object.defineProperty;var Vd=(a,n,t)=>n in a?Ed(a,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[n]=t;var L=(a,n,t)=>Vd(a,typeof n!="symbol"?n+"":n,t);const va=require("pinia"),e=require("vue"),Le=require("pixi.js"),rt=require("./editor-BUpGsg4D.cjs"),B=require("@ionic/vue"),Sd=require("pixi-filters");function Cd(a){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>a[t]})}}return n.default=a,Object.freeze(n)}const Je=Cd(Le),yi=1,Nd=new Set(["free","square","circle"]);function _d(a){const n=typeof a;return n==="string"||n==="number"||n==="boolean"}function Td(a){if(!a||typeof a!="object")return!1;const n=a;return typeof n.x=="number"&&typeof n.y=="number"&&typeof n.width=="number"&&typeof n.height=="number"}function Pi(a){if(!a||typeof a!="object")return null;const n=a;if(n.version!==yi)return null;const t=n.crop,o=t&&Td(t.rect)?{...t.rect}:null,i=t&&typeof t.shape=="string"&&Nd.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[p,h]of Object.entries(m))_d(h)&&(u[p]=h);l.push({id:d.id,enabled:d.enabled!==!1,values:u})}return{version:yi,crop:{rect:o,aspectRatio:r,shape:i},filters:l}}function Zs(a){const n=Pi(a);return n?JSON.stringify(n):null}function Md(a){try{const n=JSON.parse(a);return Pi(n)}catch{return null}}function Bd(){return{version:yi,crop:{rect:null,aspectRatio:"free",shape:"free"},filters:[]}}let Et={apiBaseUrl:"/api/v1",isAdmin:!1};function In(a){Et={...Et,...a}}function Xs(){return{...Et}}function Hs(a){Et={...a}}function Gs(a){const n=Xs();return In(a),()=>{Hs(n)}}const Id=async(a,n={})=>{var l;const t=(l=document.querySelector('meta[name="csrf-token"]'))==null?void 0:l.getAttribute("content"),o={Accept:"application/json",...n.headers};t&&(o["X-CSRF-TOKEN"]=t),n.body instanceof FormData||(o["Content-Type"]="application/json");const r={method:n.method||"GET",headers:o,credentials:"include"};n.body instanceof FormData?r.body=n.body:n.body!==void 0&&(r.body=JSON.stringify(n.body));const s=await fetch(a,r);if(!s.ok){const c=await s.json().catch(()=>({message:"Request failed"}));throw new Error(c.message||`HTTP ${s.status}`)}if(s.status!==204)return await s.json()},kt=va.defineStore("media",()=>{const a=e.ref([]),n=e.ref([]),t=e.ref(!1),o=e.ref(null),i=e.ref(1),r=e.ref(1),s=e.ref(24),l=e.ref({type:null,uuid:null}),c=e.ref([]),d=e.ref(!1),u=e.ref(null),m=e.ref(new Map),p=e.ref(new Map),h=e.ref(new Set),v=e.ref(new Map),y=e.ref({}),E=5*60*1e3,_=e.computed(()=>{if(Et.apiScope)return Et.apiScope;if(Et.isAdmin)return"admin"}),C=e.computed(()=>_.value==="admin");function w(){return Et.httpClient||Id}function f(ue){const se=Et.apiBaseUrl||"/api/v1",be=_.value?`/${_.value}`:"";return`${se}${be}${ue}`}function x(ue,se){return`${_.value??"default"}-${ue}-${JSON.stringify(se)}`}function $(ue){return Date.now()-ue<E}function N(){v.value.clear(),y.value={}}function g(ue){if(!ue||!ue.data)return;const se={};ue.data.forEach(be=>{const ie=`${be.file_name}-${be.collection_name||"default"}`,le=se[ie];(!le||Object.keys(be.generated_conversions||{}).length>Object.keys(le.generated_conversions||{}).length)&&(se[ie]=be)}),a.value=Object.values(se),ue.meta&&(i.value=ue.meta.current_page,r.value=Math.ceil(ue.meta.total/ue.meta.per_page))}async function S(ue=1,se={}){const be=x(ue,se),ie=v.value.get(be);if(ie&&$(ie.timestamp)){const le=ie.data;return g(le),le}t.value=!0,o.value=null;try{const le=new URLSearchParams;le.append("page",ue.toString()),le.append("per_page",s.value.toString()),C.value&&le.append("linked","1");for(const et in se)if(Object.prototype.hasOwnProperty.call(se,et)){const We=se[et];We!=null&&We!==""&&le.append(et,String(We))}const Ve=await w()(f(`/media?${le}`));return v.value.set(be,{data:Ve,timestamp:Date.now()}),g(Ve),Ve}catch(le){throw o.value=le instanceof Error?le.message:"Failed to fetch media",a.value=[],new Error(o.value)}finally{t.value=!1}}async function O(ue,se){t.value=!0,o.value=null;const be=`${ue.name}-${Date.now()}`,ie={file:ue,progress:0,status:"uploading"};m.value.set(be,ie);try{const le=new FormData;le.append("file",ue),le.append("collection",se.collection),se.ownerUuid&&(le.append("owner_uuid",se.ownerUuid),le.append("owner_type",se.ownerType||"")),se.usageUuid&&(le.append("usage_uuid",se.usageUuid),le.append("usage_type",se.usageType||""),le.append("usage_purpose",se.usagePurpose||"")),se.customProperties&&le.append("custom_properties",JSON.stringify(se.customProperties));const Ve=await w()(f("/media"),{method:"POST",body:le});return ie.status="completed",ie.progress=100,ie.media=Ve==null?void 0:Ve.data,i.value===1&&(Ve!=null&&Ve.data)&&(a.value=[Ve.data,...a.value]),N(),(Ve==null?void 0:Ve.data)||null}catch(le){throw ie.status="error",ie.error=le instanceof Error?le.message:"Upload failed",o.value=ie.error,new Error(o.value)}finally{t.value=!1,setTimeout(()=>{m.value.delete(be)},5e3)}}async function k(ue){t.value=!0,o.value=null;const se=a.value.findIndex(ie=>ie.uuid===ue);let be;se!==-1&&(be=a.value.splice(se,1)[0]);try{return await w()(f(`/media/${ue}`),{method:"DELETE"}),h.value.delete(ue),N(),!0}catch(ie){throw be&&se!==-1&&a.value.splice(se,0,be),o.value=ie instanceof Error?ie.message:"Failed to delete media",new Error(o.value)}finally{t.value=!1}}async function T(ue,se){t.value=!0,o.value=null;try{const ie=await w()(f(`/media/${ue}`),{method:"PATCH",body:se,data:se});if(ie!=null&&ie.data){const le=a.value.findIndex(ke=>ke.uuid===ue);return le!==-1&&(a.value[le]={...a.value[le],...ie.data}),N(),ie.data}return null}catch(be){throw o.value=be instanceof Error?be.message:"Failed to update media",new Error(o.value)}finally{t.value=!1}}async function F(){t.value=!0,o.value=null;try{const se=await w()(f("/media/collections"));return n.value=(se==null?void 0:se.data)||[],n.value}catch(ue){throw o.value=ue instanceof Error?ue.message:"Failed to fetch collections",n.value=[],new Error(o.value)}finally{t.value=!1}}async function A(ue,se,be="images",ie){d.value=!0,u.value=null;try{const le=new URLSearchParams;le.append("collection",be),ie&&le.append("search",ie);const Ve=await w()(f(`/media/model/${ue}/${se}?${le}`));return Ve!=null&&Ve.data?(c.value=Ve.data,Ve.data):[]}catch(le){throw u.value=le instanceof Error?le.message:"Failed to fetch model media",c.value=[],new Error(u.value)}finally{d.value=!1}}async function R(ue,se,be,ie="images"){d.value=!0,u.value=null;const le=[...c.value];try{const Ve=await w()(f(`/media/model/${ue}/${se}/attach`),{method:"POST",body:{media_uuids:be,collection:ie}});return await A(ue,se,ie),(Ve==null?void 0:Ve.data)||[]}catch(ke){throw c.value=le,u.value=ke instanceof Error?ke.message:"Failed to attach media",new Error(u.value)}finally{d.value=!1}}async function j(ue,se,be,ie="images"){d.value=!0,u.value=null;const le=[...c.value];c.value=c.value.filter(ke=>ke.uuid!==be);try{return await w()(f(`/media/model/${ue}/${se}/detach`),{method:"POST",body:{media_uuid:be,collection:ie}}),!0}catch(ke){throw c.value=le,u.value=ke instanceof Error?ke.message:"Failed to detach media",new Error(u.value)}finally{d.value=!1}}async function K(ue,se,be,ie="images"){d.value=!0,u.value=null;const le=[...c.value],ke=new Map(c.value.map(Ve=>[Ve.uuid,Ve]));c.value=be.map(Ve=>ke.get(Ve)).filter(Ve=>Ve!==void 0);try{return await w()(f(`/media/model/${ue}/${se}/reorder`),{method:"POST",body:{media_uuids:be,collection:ie}}),!0}catch(Ve){throw c.value=le,u.value=Ve instanceof Error?Ve.message:"Failed to reorder media",new Error(u.value)}finally{d.value=!1}}async function I(ue,se,be={}){const ie=w(),le=Et.apiBaseUrl||"/api/v1",ke=new FormData,Ve=se.imageData,et=Ve.match(/^data:(image\/\w+);base64,/),We=et?et[1]:"image/png",fe=Ve.replace(/^data:image\/\w+;base64,/,""),P=atob(fe),J=new Uint8Array(P.length);for(let ve=0;ve<P.length;ve++)J[ve]=P.charCodeAt(ve);const ee=new Blob([J],{type:We});ke.append("image_file",ee,`edited.${We==="image/jpeg"?"jpg":"png"}`);const te=Zs(se.state);te&&ke.append("editor_state",te),se.metadata&&(ke.append("filters",JSON.stringify(se.metadata.filters)),se.metadata.cropRect&&ke.append("crop_data",JSON.stringify(se.metadata.cropRect))),ke.append("save_as_new","true"),be.asVariant&&ke.append("as_variant","true"),be.name!==void 0&&ke.append("name",be.name);const pe=await ie(`${le}/editor/${ue}/save`,{method:"POST",body:ke});if("media"in pe&&pe.media)return pe.media;if("status_url"in pe&&pe.status_url)return D(ie,pe.status_url,be.pollTimeout??6e4);throw new Error("Unexpected response from editor save endpoint")}async function D(ue,se,be){const ie=Date.now(),le=2e3;for(;Date.now()-ie<be;){await new Promise(Ve=>setTimeout(Ve,le));const ke=await ue(se);if(ke.status==="completed"&&ke.media)return ke.media;if(ke.status==="failed")throw new Error(ke.error??"Image processing failed")}throw new Error("Image processing timed out")}function Z(ue,se,be){l.value=be!==void 0?{type:ue,uuid:se,collection:be}:{type:ue,uuid:se},y.value[`${ue}-${se}`]={timestamp:Date.now()}}function W(){l.value={type:null,uuid:null},c.value=[],u.value=null}async function oe(){if(!l.value.type||!l.value.uuid)return;const ue=await A(l.value.type,l.value.uuid,l.value.collection||"images");c.value=ue||[]}function we(){a.value.forEach(ue=>h.value.add(ue.uuid))}function Ce(){h.value.clear()}function ne(ue){h.value.has(ue)?h.value.delete(ue):h.value.add(ue)}function M(ue){return h.value.has(ue)}function z(){return Array.from(m.value.values()).some(ue=>ue.status==="uploading")}function me(ue){return m.value.get(ue)||p.value.get(ue)}function ae(){return[...Array.from(m.value.values()),...Array.from(p.value.values())]}async function Y(){const ue=Array.from(h.value);let se=0;for(const be of ue)try{await k(be),se++}catch{}return Ce(),se}function Te(ue,se){var be;return se&&((be=ue.conversion_urls)!=null&&be[se])?ue.conversion_urls[se]||"":ue.original_url||ue.url||""}return{items:a,collections:n,loading:t,error:o,currentPage:i,totalPages:r,itemsPerPage:s,isAdmin:C,modelContext:l,modelMedia:c,isLoadingModelMedia:d,modelMediaError:u,selectedItems:h,uploadProgress:m,uploadQueue:p,cachedResponses:y,fetchMedia:S,uploadFile:O,deleteMedia:k,updateMedia:T,clearCache:N,fetchCollections:F,fetchModelMedia:A,attachMedia:R,detachMedia:j,reorderMedia:K,saveEditedImage:I,setModelContext:Z,clearModelContext:W,refreshModelMedia:oe,selectAllItems:we,clearSelection:Ce,toggleSelection:ne,isSelected:M,deleteSelectedItems:Y,getHttpClient:w,getApiUrl:f,hasActiveUploads:z,getUploadProgress:me,getAllUploadProgress:ae,getMediaUrl:Te}}),Js=()=>((Et.apiScope!=="admin"||Et.isAdmin!==!0)&&In({...Et,apiScope:"admin",isAdmin:!0}),kt());function Fd(a,n){try{let t=rt.getFilter(a);if(t||(rt.registerCorePixiFilters(),t=rt.getFilter(a)),!t){try{const r=rt.getAllFilters()}catch{}return null}const o={...t.defaultParams,...n};return t.createFilter(o)}catch{return null}}const Rd=e.defineComponent({__name:"ImageEditor",props:{initialImage:{},initialState:{default:null},sessionKey:{default:0},theme:{default:"auto"},cropShape:{default:"square"},preset:{},primaryColor:{default:"#3880ff"},secondaryColor:{default:"#5260ff"},saveButtonColor:{default:"#3880ff"},downloadButtonColor:{default:"#2dd36f"}},emits:["save","cancel","error"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(null);let r=null,s=null;function l(){var E;if(!r){o("error",new Error("Editor not initialized"));return}const u=r.exportImage("png",.92);if(!u){o("error",new Error("Failed to export image — the image could not be processed"));return}const m=r.getSerializableState(),p=r._renderer,h=((E=p.getExportDimensions)==null?void 0:E.call(p))??{width:0,height:0},v={width:Math.round(h.width),height:Math.round(h.height)};o("save",{imageData:u,dimensions:v,state:m})}function c(){o("cancel")}function d(){if(!i.value||r)return;window.PIXI=Je,rt.initializeFilterRegistry();const u={theme:t.theme};t.preset&&(u.preset=t.preset),t.preset?t.cropShape==="circle"&&(u.cropShape="circle",u.initialAspectRatio="1:1",u.initialMode="crop"):(u.cropShape=t.cropShape==="circle"?"circle":"free",u.initialAspectRatio=t.cropShape==="circle"?"1:1":"free",u.initialMode=t.cropShape==="circle"?"crop":"adjust"),r=new rt.VanillaImageEditor(i.value,u),r.setFilterRegistry({getAllFilters:rt.getAllFilters,getFilter:rt.getFilter,getFiltersByCategory:rt.getFiltersByCategory}),r.save=function(){l()},r.on("cancel",c),t.initialImage&&r.loadImage(t.initialImage,{state:t.initialState??null,sessionKey:t.sessionKey})}return e.onMounted(()=>{i.value&&(i.value.clientWidth>0?d():(s=new ResizeObserver(u=>{const m=u[0];m&&m.contentRect.width>0&&!r&&(d(),s==null||s.disconnect(),s=null)}),s.observe(i.value)))}),e.watch(()=>t.initialImage,u=>{r&&u&&r.loadImage(u,{state:t.initialState??null,sessionKey:t.sessionKey})}),e.watch(()=>t.sessionKey,()=>{r&&t.initialImage&&r.loadImage(t.initialImage,{state:t.initialState??null,sessionKey:t.sessionKey})}),e.onUnmounted(()=>{s==null||s.disconnect(),s=null,r&&(r.destroy(),r=null)}),(u,m)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:i,class:"vanilla-editor-wrapper","data-testid":"vanilla-image-editor"},null,512))}}),Me=(a,n)=>{const t=a.__vccOpts||a;for(const[o,i]of n)t[o]=i;return t},Ys=Me(Rd,[["__scopeId","data-v-d6416384"]]),$d={class:"editor-modal-panel"},Dd={class:"editor-fill"},Ud=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},onSave:{},theme:{default:"auto"},cropShape:{default:"square"},preset:{},primaryColor:{default:"#3880ff"},secondaryColor:{default:"#5260ff"},saveButtonColor:{default:"#3880ff"},downloadButtonColor:{default:"#2dd36f"}},emits:["update:modelValue","save","cancel","error"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(null),r=e.ref(t.modelValue),s=e.ref(!1),l=e.ref(null),c=y=>{o("error",y)},d=()=>{e.nextTick(()=>{if(i.value){const y=i.value.querySelector("button:not([disabled]), [href], input:not([disabled])");y&&y.focus()}})};e.watch(()=>t.modelValue,y=>{r.value=y,y&&(l.value=document.activeElement,d())},{immediate:!0});const u=async y=>{try{s.value=!0,t.onSave&&await t.onSave(y),o("save",y)}catch(E){c(E)}finally{s.value=!1}},m=()=>{o("cancel"),h()},p=()=>{s.value||h()},h=()=>{r.value=!1,o("update:modelValue",!1),l.value&&l.value instanceof HTMLElement&&(l.value.focus(),l.value=null)},v=y=>{if(y.key==="Escape"&&r.value&&!s.value){h();return}if(y.key==="Tab"&&r.value&&i.value){const E=i.value.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(E.length===0)return;const _=E[0],C=E[E.length-1];y.shiftKey&&document.activeElement===_?(y.preventDefault(),C.focus()):!y.shiftKey&&document.activeElement===C&&(y.preventDefault(),_.focus())}};return e.onMounted(()=>{document.addEventListener("keydown",v)}),e.onBeforeUnmount(()=>{document.removeEventListener("keydown",v)}),(y,E)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[r.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"overlayRef",ref:i,role:"dialog","aria-modal":"true","aria-label":"Image editor",class:"editor-modal-overlay","data-testid":"image-editor-modal",onKeydown:e.withKeys(p,["escape"])},[e.createElementVNode("div",{class:"editor-modal-backdrop",onClick:p}),e.createElementVNode("div",$d,[e.createElementVNode("div",Dd,[e.createVNode(Ys,{"initial-image":y.initialImage,"initial-state":y.initialState,"session-key":y.sessionKey,theme:y.theme,"crop-shape":y.cropShape,preset:y.preset,"primary-color":y.primaryColor,"secondary-color":y.secondaryColor,"save-button-color":y.saveButtonColor,"download-button-color":y.downloadButtonColor,onSave:u,onCancel:m,onError:c},null,8,["initial-image","initial-state","session-key","theme","crop-shape","preset","primary-color","secondary-color","save-button-color","download-button-color"])])])],544)):e.createCommentVNode("",!0)]))}}),Ks=Me(Ud,[["__scopeId","data-v-9ca8dea8"]]),Od={class:"media-workspace"},Ad={class:"media-workspace-toolbar"},Ld={class:"media-workspace-label"},zd=["value"],Pd={class:"media-workspace-grid"},jd=["onClick"],Wd=e.defineComponent({__name:"MediaWorkspace",props:{apiScope:{},subScopes:{},initialScopeId:{}},emits:["scope-change","update:media","upload","preview"],setup(a,{emit:n}){var m;const t=a,o=n,i=kt(),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(p=>p.id===r.value));let c=null;function d(){c&&(c(),c=null),t.apiScope&&(c=Gs({apiScope:t.apiScope,isAdmin:t.apiScope==="admin"}))}async function u(){var h;const p={};(h=l.value)!=null&&h.collection&&(p.collection=l.value.collection),await i.fetchMedia(1,p),o("update:media",[...i.items])}return e.watch(()=>t.initialScopeId,p=>{p&&p!==r.value&&(r.value=p)}),e.watch(()=>t.subScopes,p=>{if(p.length===0){r.value="";return}p.some(h=>h.id===r.value)||(r.value=p[0].id)},{deep:!0}),e.watch(()=>t.apiScope,()=>{d(),u()}),e.watch(r,p=>{p&&(o("scope-change",p),u())}),e.onMounted(()=>{d(),u()}),e.onUnmounted(()=>{c&&(c(),c=null)}),(p,h)=>(e.openBlock(),e.createElementBlock("div",Od,[e.createElementVNode("div",Ad,[e.createElementVNode("label",Ld,[h[2]||(h[2]=e.createElementVNode("span",{class:"media-workspace-label-text"},"Scope",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":h[0]||(h[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,zd))),128))],512),[[e.vModelSelect,r.value]])]),e.createElementVNode("button",{type:"button",class:"media-workspace-upload","data-testid":"upload-button",onClick:h[1]||(h[1]=v=>o("upload"))}," Upload ")]),e.createElementVNode("div",Pd,[(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:y=>o("preview",v)},e.toDisplayString(v.file_name),9,jd))),128))])]))}}),Zd=Me(Wd,[["__scopeId","data-v-895f26fe"]]),Xd={class:"managed-media-gallery"},Hd={class:"gallery-grid"},Gd=e.defineComponent({__name:"ManagedMediaGallery",props:{media:{},selectable:{type:Boolean},multiple:{type:Boolean}},emits:["select","remove"],setup(a){return(n,t)=>(e.openBlock(),e.createElementBlock("div",Xd,[e.createElementVNode("div",Hd,[e.renderSlot(n.$slots,"default",{},void 0,!0)])]))}}),Jd=Me(Gd,[["__scopeId","data-v-a60fdcd7"]]),Yd="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>",ji="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>",Kd="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>",Wi="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>",qd="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>",Qd="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>",eo="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>",eu="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>",qs="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>",Qs="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>",Gr="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>",tu="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>",nu="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>",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' stroke-width='48' d='M184 112l144 144-144 144' class='ionicon-fill-none'/></svg>",Fn="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>",Yr="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>",ou="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>",an="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>",au="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>",Gn="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>",iu="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>",ru="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>",Kr="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>",el="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>",po="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>",su="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>",lu="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>",cu="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>",to="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>",qr="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>",ti="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>",du="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>",uu="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>",ni="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>",mu="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>",pu="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>",fu="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>",hu="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>",tl="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>",nl="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>",vu="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>",gu="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>",yu="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>",wu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 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>",ol="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>",bu="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>",ku="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>",al="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>",xu="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>",Eu="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>",Vu="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>",Su="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>",Qr="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>",Zi="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>",Cu="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>",oi="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>",on="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>",Jn="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>",es="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>",Nu="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>",il="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>",_u="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>",rl="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>",Tu="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>",Mu="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>",Bu="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>",Iu="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>",Fu="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>",Ru="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>",$u="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>",Do="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 ts=()=>{};function Du(a,n){function t(...o){return new Promise((i,r)=>{Promise.resolve(a(()=>n.apply(this,o),{fn:n,thisArg:this,args:o})).then(i).catch(r)})}return t}function Uu(a,n={}){let t,o,i=ts;const r=c=>{clearTimeout(c),i(),i=ts};let s;return c=>{const d=e.toValue(a),u=e.toValue(n.maxWait);return t&&r(t),d<=0||u!==void 0&&u<=0?(o&&(r(o),o=null),Promise.resolve(c())):new Promise((m,p)=>{i=n.rejectOnCancel?p:m,s=c,u&&!o&&(o=setTimeout(()=>{t&&r(t),o=null,m(s())},u)),t=setTimeout(()=>{o&&r(o),o=null,m(c())},d)})}}function Ou(a,n=200,t={}){return Du(Uu(n,t),a)}const Yn=new Map;function Au(a){const n=e.getCurrentScope();function t(l){var c;const d=Yn.get(a)||new Set;d.add(l),Yn.set(a,d);const u=()=>i(l);return(c=n==null?void 0:n.cleanups)==null||c.push(u),u}function o(l){function c(...d){i(c),l(...d)}return t(c)}function i(l){const c=Yn.get(a);c&&(c.delete(l),c.size||r())}function r(){Yn.delete(a)}function s(l,c){var d;(d=Yn.get(a))==null||d.forEach(u=>u(l,c))}return{on:t,once:o,off:i,emit:s,reset:r}}function Lu(){var r,s;const a=typeof window<"u"&&"Capacitor"in window&&((s=(r=window.Capacitor)==null?void 0:r.isNativePlatform)==null?void 0:s.call(r));return{selection:()=>{var l,c;if(a)try{const d=(c=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:c.Haptics;d&&d.impact({style:"LIGHT"})}catch{}else"vibrate"in navigator&&navigator.vibrate(10)},success:()=>{var l,c;if(a)try{const d=(c=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:c.Haptics;d&&d.impact({style:"MEDIUM"})}catch{}else"vibrate"in navigator&&navigator.vibrate(30)},error:()=>{var l,c;if(a)try{const d=(c=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:c.Haptics;d&&d.impact({style:"HEAVY"})}catch{}else"vibrate"in navigator&&navigator.vibrate([50,50,50])},notification:()=>{var l,c;if(a)try{const d=(c=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:c.Haptics;d&&d.notification({type:"SUCCESS"})}catch{}else"vibrate"in navigator&&navigator.vibrate([20,100,20])}}}function zu(a){const n=e.ref(new Set),t=e.ref(null),o=e.ref(-1),i=Au("media-selection"),r=Lu(),s=e.computed(()=>a.value.filter(x=>n.value.has(x.uuid))),l=e.computed(()=>n.value.size);e.watch(n,x=>{i.emit({type:"selection:changed",count:x.size,selectedIds:Array.from(x)})},{deep:!0});const c=e.computed(()=>a.value.length>0&&a.value.every(x=>n.value.has(x.uuid))),d=e.computed(()=>a.value.some(x=>n.value.has(x.uuid)));function u(x){return n.value.has(x)}function m(x){n.value.has(x)?(n.value.delete(x),t.value===x&&(t.value=null,o.value=-1)):(n.value.add(x),t.value=x,o.value=a.value.findIndex($=>$.uuid===x),n.value.size===1&&r.selection())}function p(x){n.value.add(x),t.value=x,o.value=a.value.findIndex($=>$.uuid===x)}function h(x){n.value.delete(x),t.value===x&&(t.value=null,o.value=-1)}function v(){a.value.forEach(x=>n.value.add(x.uuid))}function y(){n.value.clear(),t.value=null,o.value=-1}function E(){c.value?y():v()}function _(x,$){const N=a.value.findIndex(g=>g.uuid===x);if(N!==-1)if($!=null&&$.shiftKey&&o.value!==-1){const g=Math.min(o.value,N),S=Math.max(o.value,N);for(let O=g;O<=S;O++)n.value.add(a.value[O].uuid)}else m(x)}function C(){if(a.value.length===0)return;let x=o.value+1;x>=a.value.length&&(x=0),y(),p(a.value[x].uuid)}function w(){if(a.value.length===0)return;let x=o.value-1;x<0&&(x=a.value.length-1),y(),p(a.value[x].uuid)}function f(x){switch(x.key){case"ArrowDown":x.preventDefault(),C();break;case"ArrowUp":x.preventDefault(),w();break;case"a":(x.ctrlKey||x.metaKey)&&(x.preventDefault(),v());break;case"Escape":x.preventDefault(),y();break;case" ":t.value&&(x.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:p,deselect:h,selectAll:v,clear:y,toggleAll:E,rangeSelect:_,selectNext:C,selectPrevious:w,handleKeydown:f,selectionBus:i}}const Pu={class:"flex items-center justify-between w-full px-4"},ju={class:"p-4"},Wu={key:0,class:"mb-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg"},Zu={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"},Xu=["value"],Hu={class:"flex gap-2 mt-4"},Gu={class:"flex justify-end mb-4"},Ju={key:1,class:"flex justify-center items-center h-64"},Yu={key:2,class:"flex flex-col items-center justify-center h-64 text-center"},Ku={class:"text-sm text-theme-secondary"},qu={key:0},Qu={class:"mb-4"},em={class:"mb-4"},tm={class:"flex gap-2"},nm={class:"flex items-center justify-between px-4 py-2"},om={class:"text-sm text-theme-secondary"},am={key:0},im={key:0},rm={key:1},sm={class:"flex gap-2"},lm=e.defineComponent({__name:"AdminMediaBrowser",props:{isOpen:{type:Boolean},selectionMode:{default:"single"},selectedItems:{default:()=>[]},modelType:{},modelId:{},collection:{default:"images"},maxSelection:{}},emits:["close","confirm"],setup(a,{emit:n}){const t=a,o=n,i=e.ref("recent"),r=e.ref("grid"),s=e.ref(""),l=e.ref(!1),c=e.ref([]),{selectedItems:d}=e.toRefs(t),u=e.ref(new Set(d.value)),m=e.ref(!1),p=e.ref({}),h=e.ref(["images","documents","videos"]),v=e.ref(1),y=e.ref(!0),E=e.ref(!1),_=Js(),C=zu(c);function w(M){var se;const z=M.conversion_urls||{},me=M.proxy_url||M.original_url||M.url||"",ae=z.thumb||z.preview||M.preview_url||M.thumbnail_url||me,Y=M.custom_properties||{},Te=Y.width,ue=Y.height;return{...M,uuid:M.uuid,name:M.name||M.file_name,file_name:M.file_name,filename:M.file_name,mime_type:M.mime_type,size:M.size,collection_name:M.collection_name||"images",disk:M.disk,original_url:me,url:me,thumbnail_url:ae,conversions:M.conversions||{},conversion_urls:z,generated_conversions:M.generated_conversions||{},custom_properties:Y,caption:M.caption||null,alt_text:M.alt_text||null,created_at:M.created_at,updated_at:M.updated_at,is_image:((se=M.mime_type)==null?void 0:se.startsWith("image/"))||!1,...typeof Te=="number"?{width:Te}:{},...typeof ue=="number"?{height:ue}:{},...M.formatted_size!==void 0?{formatted_size:M.formatted_size}:{}}}e.watch(()=>t.selectedItems,M=>{u.value=new Set(M),C.clear(),M.forEach(z=>C.select(z))});const f=e.computed(()=>{var z;let M=c.value;return(z=p.value.types)!=null&&z.length&&(M=M.filter(me=>{var Y,Te;const ae=(Y=me.mime_type)==null?void 0:Y.split("/")[0];return(Te=p.value.types)==null?void 0:Te.includes(ae)})),(p.value.sizeMin!==void 0||p.value.sizeMax!==void 0)&&(M=M.filter(me=>{const ae=me.size/1048576;return!(p.value.sizeMin!==void 0&&ae<p.value.sizeMin||p.value.sizeMax!==void 0&&ae>p.value.sizeMax)})),M}),x=e.computed(()=>{var z;let M=0;return p.value.search&&M++,p.value.collection&&M++,(p.value.dateFrom||p.value.dateTo)&&M++,(z=p.value.types)!=null&&z.length&&(M+=p.value.types.length),(p.value.sizeMin!==void 0||p.value.sizeMax!==void 0)&&M++,M}),$=e.computed(()=>{const M=C.selectedCount.value;return M===0?"Select Media":`Select ${t.selectionMode==="multiple"?`${M} ${M===1?"Item":"Items"}`:"Item"}`}),N=e.computed(()=>{const M=C.selectedCount.value;return!!(M===0||t.selectionMode==="single"&&M>1||t.maxSelection&&M>t.maxSelection)}),g=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 S(M=!0){M?(l.value=!0,c.value=[],v.value=1,y.value=!0):E.value=!0;try{const z={collection:p.value.collection||t.collection,per_page:24};switch((s.value||p.value.search)&&(z.search=s.value||p.value.search||""),p.value.dateFrom&&(z.from_date=p.value.dateFrom),p.value.dateTo&&(z.to_date=p.value.dateTo),i.value){case"recent":await _.fetchMedia(v.value,z),M?c.value=_.items.map(me=>w(me)):c.value=[...c.value,..._.items.map(me=>w(me))],y.value=_.currentPage<_.totalPages;break;case"model":if(t.modelType&&t.modelId){const me=await _.fetchModelMedia(t.modelType,t.modelId,z.collection,z.search);c.value=me?me.map(ae=>w(ae)):[],y.value=!1}break;case"library":await _.fetchMedia(v.value,z),M?c.value=_.items.map(me=>w(me)):c.value=[...c.value,..._.items.map(me=>w(me))],y.value=_.currentPage<_.totalPages;break}}catch{}finally{l.value=!1,E.value=!1}}async function O(M){if(!y.value||E.value){M!=null&&M.target&&M.target.complete();return}v.value++,await S(!1),M!=null&&M.target&&(M.target.complete(),y.value||(M.target.disabled=!0))}function k(M){return M==="recent"||M==="model"||M==="library"}function T(M){i.value=M,S()}function F(M){typeof M=="string"&&k(M)&&T(M)}async function A(M){t.selectionMode==="single"?(C.clear(),C.select(M.uuid)):(C.toggle(M.uuid),t.maxSelection&&C.selectedCount.value>t.maxSelection&&(C.deselect(M.uuid),await(await B.toastController.create({message:`Maximum ${t.maxSelection} items can be selected`,duration:2e3,color:"warning"})).present()))}function R(){o("confirm",C.selectedItems.value)}function j(){o("close")}function K(M){}const I=e.ref(null),D=e.ref(!1);function Z(M){I.value=M,D.value=!0}function W(M){const z=c.value.findIndex(ae=>ae.uuid===M.uuid);z!==-1&&(c.value[z]=M);const me={};M.alt_text!==void 0&&(me.alt_text=M.alt_text),M.caption!==void 0&&(me.caption=M.caption),M.custom_properties!==void 0&&(me.custom_properties=M.custom_properties),_.updateMedia(M.uuid,me)}function oe(){S()}function we(){p.value={},s.value="",S()}const Ce=Ou(()=>{S(!0)},300);e.watch(s,()=>{t.isOpen&&Ce()});async function ne(M){try{await(await B.alertController.create({header:"Delete Media",message:"Are you sure you want to delete this media item?",buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"destructive",handler:async()=>{await _.deleteMedia(M),await S()}}]})).present()}catch{}}return e.watch(()=>t.isOpen,M=>{M&&S()}),e.onMounted(()=>{t.selectedItems.length>0&&t.selectedItems.forEach(M=>C.select(M))}),(M,z)=>{const me=e.resolveComponent("AdminMediaGrid"),ae=e.resolveComponent("AdminMediaListItem");return e.openBlock(),e.createBlock(e.unref(B.IonModal),{"is-open":M.isOpen,onDidDismiss:j,"backdrop-dismiss":!1,class:"media-browser-modal"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(B.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonButton),{onClick:j},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(B.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(g.value),1)]),_:1})]),_:1}),e.createVNode(e.unref(B.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",Pu,[e.createVNode(e.unref(B.IonSegment),{value:i.value,onIonChange:z[0]||(z[0]=Y=>F(Y.detail.value)),class:"max-w-xs"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonSegmentButton),{value:"recent"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...z[15]||(z[15]=[e.createTextVNode("Recent",-1)])]),_:1})]),_:1}),t.modelType&&t.modelId?(e.openBlock(),e.createBlock(e.unref(B.IonSegmentButton),{key:0,value:"model"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...z[16]||(z[16]=[e.createTextVNode("Model",-1)])]),_:1})]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(B.IonSegmentButton),{value:"library"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...z[17]||(z[17]=[e.createTextVNode("Library",-1)])]),_:1})]),_:1})]),_:1},8,["value"]),e.createVNode(e.unref(B.IonButton),{fill:"clear",size:"small",onClick:z[1]||(z[1]=Y=>m.value=!m.value),class:"relative"},{"icon-only":e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{name:"filter-outline"})]),default:e.withCtx(()=>[x.value>0?(e.openBlock(),e.createBlock(e.unref(B.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(x.value),1)]),_:1})):e.createCommentVNode("",!0)]),_:1})])]),_:1})]),_:1}),e.createVNode(e.unref(B.IonContent),null,{default:e.withCtx(()=>[e.createElementVNode("div",ju,[m.value?(e.openBlock(),e.createElementBlock("div",Wu,[e.createElementVNode("div",Zu,[e.createElementVNode("div",null,[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...z[18]||(z[18]=[e.createTextVNode("Collection",-1)])]),_:1}),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":z[2]||(z[2]=Y=>p.value.collection=Y),class:"w-full p-2 border rounded"},[z[19]||(z[19]=e.createElementVNode("option",{value:""},"All Collections",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,Y=>(e.openBlock(),e.createElementBlock("option",{key:Y,value:Y},e.toDisplayString(Y),9,Xu))),128))],512),[[e.vModelSelect,p.value.collection]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...z[20]||(z[20]=[e.createTextVNode("From Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":z[3]||(z[3]=Y=>p.value.dateFrom=Y),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,p.value.dateFrom]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...z[21]||(z[21]=[e.createTextVNode("To Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":z[4]||(z[4]=Y=>p.value.dateTo=Y),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,p.value.dateTo]])])]),e.createElementVNode("div",Hu,[e.createVNode(e.unref(B.IonButton),{size:"small",onClick:oe},{default:e.withCtx(()=>[...z[22]||(z[22]=[e.createTextVNode("Apply",-1)])]),_:1}),e.createVNode(e.unref(B.IonButton),{size:"small",fill:"clear",onClick:we},{default:e.withCtx(()=>[...z[23]||(z[23]=[e.createTextVNode("Clear",-1)])]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(e.unref(B.IonSearchbar),{modelValue:s.value,"onUpdate:modelValue":z[5]||(z[5]=Y=>s.value=Y),placeholder:"Search media...",debounce:300,class:"mb-4"},null,8,["modelValue"]),e.createElementVNode("div",Gu,[e.createVNode(e.unref(B.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonButton),{fill:r.value==="grid"?"solid":"clear",size:"small",onClick:z[6]||(z[6]=Y=>r.value="grid")},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{name:"grid-outline"})]),_:1},8,["fill"]),e.createVNode(e.unref(B.IonButton),{fill:r.value==="list"?"solid":"clear",size:"small",onClick:z[7]||(z[7]=Y=>r.value="list")},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{name:"list-outline"})]),_:1},8,["fill"])]),_:1})]),l.value?(e.openBlock(),e.createElementBlock("div",Ju,[e.createVNode(e.unref(B.IonSpinner),{name:"crescent"})])):f.value.length===0?(e.openBlock(),e.createElementBlock("div",Yu,[e.createVNode(e.unref(B.IonIcon),{name:"images-outline",class:"text-6xl text-theme-secondary mb-4"}),z[24]||(z[24]=e.createElementVNode("h3",{class:"text-lg font-medium text-theme mb-2"}," No Media Found ",-1)),e.createElementVNode("p",Ku,e.toDisplayString(s.value?"Try adjusting your search":"No media items available"),1)])):r.value==="grid"?(e.openBlock(),e.createBlock(me,{key:3,"media-items":f.value,"selected-items":e.unref(C).selectedItems.value,"is-loading":!1,"selection-mode":!0,columns:{mobile:2,sm:3,md:4,lg:5,xl:6},onToggleSelect:A,onPreview:K,onEdit:Z,onDelete:ne},null,8,["media-items","selected-items"])):(e.openBlock(),e.createBlock(e.unref(B.IonList),{key:4,lines:"none",class:"rounded-lg overflow-hidden"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(Y,Te)=>(e.openBlock(),e.createBlock(ae,{key:Y.uuid,media:Y,selected:e.unref(C).isSelected(Y.uuid),"selection-mode":!0,index:Te,onToggleSelect:A,onPreview:K,onEdit:Z,onDelete:ne},null,8,["media","selected","index"]))),128))]),_:1})),!l.value&&f.value.length>0&&i.value!=="model"?(e.openBlock(),e.createBlock(e.unref(B.IonInfiniteScroll),{key:5,threshold:"100px",onIonInfinite:z[8]||(z[8]=Y=>O(Y))},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonInfiniteScrollContent),{"loading-spinner":"crescent","loading-text":"Loading more media..."})]),_:1})):e.createCommentVNode("",!0)])]),_:1}),e.createVNode(e.unref(B.IonModal),{"is-open":D.value,onDidDismiss:z[14]||(z[14]=Y=>D.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(B.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonButton),{onClick:z[9]||(z[9]=Y=>D.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(B.IonTitle),null,{default:e.withCtx(()=>[...z[25]||(z[25]=[e.createTextVNode("Edit Media Info",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(B.IonContent),{class:"p-4"},{default:e.withCtx(()=>[I.value?(e.openBlock(),e.createElementBlock("div",qu,[e.createElementVNode("div",Qu,[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...z[26]||(z[26]=[e.createTextVNode("Caption",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":z[10]||(z[10]=Y=>I.value.caption=Y),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter caption..."},null,512),[[e.vModelText,I.value.caption]])]),e.createElementVNode("div",em,[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...z[27]||(z[27]=[e.createTextVNode("Alt Text",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":z[11]||(z[11]=Y=>I.value.alt_text=Y),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter alt text..."},null,512),[[e.vModelText,I.value.alt_text]])]),e.createElementVNode("div",tm,[e.createVNode(e.unref(B.IonButton),{onClick:z[12]||(z[12]=Y=>W(I.value))},{default:e.withCtx(()=>[...z[28]||(z[28]=[e.createTextVNode("Save",-1)])]),_:1}),e.createVNode(e.unref(B.IonButton),{fill:"clear",onClick:z[13]||(z[13]=Y=>D.value=!1)},{default:e.withCtx(()=>[...z[29]||(z[29]=[e.createTextVNode("Cancel",-1)])]),_:1})])])):e.createCommentVNode("",!0)]),_:1})]),_:1},8,["is-open"]),e.createVNode(e.unref(B.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",nm,[e.createElementVNode("div",om,[e.unref(C).selectedCount.value>0?(e.openBlock(),e.createElementBlock("span",am,[e.createTextVNode(e.toDisplayString(e.unref(C).selectedCount.value)+" selected ",1),t.maxSelection?(e.openBlock(),e.createElementBlock("span",im," / "+e.toDisplayString(t.maxSelection)+" max ",1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("span",rm," Select "+e.toDisplayString(t.selectionMode==="multiple"?"items":"an item"),1))]),e.createElementVNode("div",sm,[e.createVNode(e.unref(B.IonButton),{fill:"clear",onClick:j},{default:e.withCtx(()=>[...z[30]||(z[30]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(B.IonButton),{disabled:N.value,onClick:R},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString($.value),1)]),_:1},8,["disabled"])])])]),_:1})]),_:1})]),_:1},8,["is-open"])}}}),cm=Me(lm,[["__scopeId","data-v-9a8c0954"]]),dm={key:1,class:"flex flex-col items-center justify-center py-16"},um=["draggable","onDragstart","onDragover","onDrop"],mm={key:0,class:"absolute top-2 left-2 z-20"},pm=["checked","onChange"],fm={key:2,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-move"},hm=["data-media-id"],vm={key:0,class:"w-full h-full flex items-center justify-center"},gm=["src","alt","onError","onLoad"],ym={key:2,class:"w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-700"},wm={class:"text-center"},bm={class:"text-4xl text-gray-400 mb-2"},km={class:"text-sm font-medium text-gray-500"},xm={class:"absolute inset-0 bg-black/70 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2"},Em=["onClick"],Vm=["onClick"],Sm=["onClick"],Cm={class:"p-3"},Nm={class:"text-sm font-medium truncate mb-1"},_m={class:"text-xs text-gray-600 dark:text-gray-400"},Tm={key:0},Mm={key:0,class:"text-xs text-gray-500 dark:text-gray-500 mt-1 truncate"},Bm=e.defineComponent({__name:"MediaGrid",props:{mediaItems:{default:()=>[]},selectedItems:{default:()=>[]},isLoading:{type:Boolean,default:!1},selectionMode:{type:Boolean,default:!1},reorderable:{type:Boolean,default:!1},showEditButton:{type:Boolean,default:!1},columns:{default:()=>({mobile:2,sm:3,md:4,lg:5,xl:6})}},emits:["toggleSelect","preview","edit","delete","reorder","upload"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(null),r=e.ref(null),s=e.ref(new Set),l=e.ref(null),c=N=>t.selectedItems.some(g=>g.uuid===N.uuid),d=e.computed(()=>{const N=t.columns,g=["grid","gap-4"];switch(N.mobile){case 1:g.push("grid-cols-1");break;case 2:g.push("grid-cols-2");break;case 3:g.push("grid-cols-3");break;case 4:g.push("grid-cols-4");break;default:g.push("grid-cols-2");break}switch(N.sm){case 1:g.push("sm:grid-cols-1");break;case 2:g.push("sm:grid-cols-2");break;case 3:g.push("sm:grid-cols-3");break;case 4:g.push("sm:grid-cols-4");break;case 5:g.push("sm:grid-cols-5");break;default:g.push("sm:grid-cols-3");break}switch(N.md){case 2:g.push("md:grid-cols-2");break;case 3:g.push("md:grid-cols-3");break;case 4:g.push("md:grid-cols-4");break;case 5:g.push("md:grid-cols-5");break;case 6:g.push("md:grid-cols-6");break;default:g.push("md:grid-cols-4");break}switch(N.lg){case 3:g.push("lg:grid-cols-3");break;case 4:g.push("lg:grid-cols-4");break;case 5:g.push("lg:grid-cols-5");break;case 6:g.push("lg:grid-cols-6");break;case 7:g.push("lg:grid-cols-7");break;default:g.push("lg:grid-cols-5");break}switch(N.xl){case 4:g.push("xl:grid-cols-4");break;case 5:g.push("xl:grid-cols-5");break;case 6:g.push("xl:grid-cols-6");break;case 7:g.push("xl:grid-cols-7");break;case 8:g.push("xl:grid-cols-8");break;default:g.push("xl:grid-cols-6");break}return g.join(" ")});function u(N,g,S){t.reorderable&&(i.value=g,N.dataTransfer&&(N.dataTransfer.effectAllowed="move",N.dataTransfer.setData("text/html","")))}function m(N,g){t.reorderable&&(N.preventDefault(),r.value=g)}function p(){r.value=null}function h(N,g){if(!t.reorderable||!i.value)return;N.preventDefault();const S=[...t.mediaItems],O=S.findIndex(k=>{var T;return k.uuid===((T=i.value)==null?void 0:T.uuid)});if(O!==-1&&O!==g&&i.value){const[k]=S.splice(O,1);S.splice(g,0,k),o("reorder",S)}i.value=null,r.value=null}function v(N){return N<1024?N+" B":N<1024*1024?(N/1024).toFixed(1)+" KB":(N/(1024*1024)).toFixed(1)+" MB"}function y(N){var S;return N.thumbnail_url||((S=N.conversion_urls)==null?void 0:S.thumb)||N.original_url||N.url||""}function E(N){var O,k,T;const g=((O=N.mime_type)==null?void 0:O.startsWith("image/"))||!1,S=!!(N.thumbnail_url||(k=N.conversion_urls)!=null&&k.thumb||(T=N.conversion_urls)!=null&&T.preview||N.original_url||N.url);return g&&S}function _(N){var g;return((g=N.split(".").pop())==null?void 0:g.toUpperCase())||""}function C(N){var S;const g=((S=N.mime_type)==null?void 0:S.toLowerCase())||"";return g.startsWith("image/")?"image":g.startsWith("video/")?"videocam":g.startsWith("audio/")?"musical-notes":g.includes("pdf")?"document-text":g.includes("zip")||g.includes("rar")?"archive":g.includes("sheet")||g.includes("excel")?"grid":g.includes("document")||g.includes("word")?"document-text":"document"}e.onMounted(()=>{typeof window<"u"&&"IntersectionObserver"in window&&(l.value=new IntersectionObserver(N=>{N.forEach(g=>{var S;if(g.isIntersecting){const O=g.target.getAttribute("data-media-id");O&&(s.value.add(O),(S=l.value)==null||S.unobserve(g.target))}})},{rootMargin:"50px"}))}),e.onUnmounted(()=>{l.value&&l.value.disconnect()});function w(N){return!0}function f(){l.value&&e.nextTick(()=>{document.querySelectorAll("[data-media-id]").forEach(g=>{var O;const S=g.getAttribute("data-media-id");S&&!s.value.has(S)&&((O=l.value)==null||O.observe(g))})})}e.watch(()=>t.mediaItems,()=>{s.value.clear(),f()},{immediate:!0,deep:!0});function x(N,g){const S=N.target;delete S.dataset.fallbackIndex}function $(N,g){const S=N.target,O=S.closest("[data-media-id]"),k=[g.original_url,g.url,g.thumbnail_url,"preview_url"in g?g.preview_url:void 0].filter(T=>T&&T.trim()!==""&&T!==S.src);if(k.length>0&&S.dataset.fallbackIndex){const T=parseInt(S.dataset.fallbackIndex);if(T<k.length){S.dataset.fallbackIndex=(T+1).toString(),S.src=k[T]||"";return}}else if(k.length>0){S.dataset.fallbackIndex="1",S.src=k[0]||"";return}if(S.style.display="none",O&&!O.querySelector(".media-fallback-icon")){const F=document.createElement("div");F.className="media-fallback-icon w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-800",F.innerHTML=`
|
|
2
|
-
<div class="text-center">
|
|
3
|
-
<div class="text-4xl text-gray-400 mb-2">${C(g)}</div>
|
|
4
|
-
<p class="text-sm font-medium text-gray-500">${_(g.file_name)}</p>
|
|
5
|
-
</div>
|
|
6
|
-
`,O.appendChild(F)}}return(N,g)=>N.isLoading?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(d.value)},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(12,S=>e.createElementVNode("div",{key:`skeleton-${S}`,class:"relative"},[...g[1]||(g[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)):!N.mediaItems||!N.mediaItems.length?(e.openBlock(),e.createElementBlock("div",dm,[g[2]||(g[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)),g[3]||(g[3]=e.createElementVNode("h3",{class:"text-lg font-medium mb-2"}," No Media Items ",-1)),g[4]||(g[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:g[0]||(g[0]=S=>o("upload")),class:"px-3 py-2 bg-blue-500 text-white rounded hover:bg-blue-600"}," Upload Media ")])):(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(d.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(N.mediaItems,(S,O)=>(e.openBlock(),e.createElementBlock("div",{key:S.uuid,class:e.normalizeClass(["relative group",{"ring-2 ring-blue-500 ring-offset-2":r.value===O}]),draggable:N.reorderable,onDragstart:k=>u(k,S),onDragover:k=>m(k,O),onDragleave:p,onDrop:k=>h(k,O)},[N.selectionMode?(e.openBlock(),e.createElementBlock("div",mm,[e.createElementVNode("input",{type:"checkbox",checked:c(S),onChange:k=>o("toggleSelect",S),class:"w-5 h-5 bg-white dark:bg-gray-800 rounded cursor-pointer"},null,40,pm)])):e.createCommentVNode("",!0),N.$slots.badge?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["absolute top-2 z-20",N.selectionMode?"left-10":"left-2"])},[e.renderSlot(N.$slots,"badge",{media:S,index:O},void 0,!0)],2)):e.createCommentVNode("",!0),N.reorderable?(e.openBlock(),e.createElementBlock("div",fm,[...g[5]||(g[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(S)}])},[e.createElementVNode("div",{class:"relative aspect-square bg-gray-100 dark:bg-gray-700 overflow-hidden","data-media-id":S.uuid},[E(S)&&!w(S.uuid)?(e.openBlock(),e.createElementBlock("div",vm,[...g[6]||(g[6]=[e.createElementVNode("div",{class:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"},null,-1)])])):e.createCommentVNode("",!0),E(S)&&w(S.uuid)?(e.openBlock(),e.createElementBlock("img",{key:1,src:y(S),alt:S.alt_text||S.file_name,class:"w-full h-full object-cover",loading:"lazy",onError:k=>$(k,S),onLoad:k=>x(k)},null,40,gm)):(e.openBlock(),e.createElementBlock("div",ym,[e.createElementVNode("div",wm,[e.createElementVNode("div",bm,e.toDisplayString(C(S)),1),e.createElementVNode("p",km,e.toDisplayString(_(S.file_name)),1)])])),e.createElementVNode("div",xm,[e.createElementVNode("button",{onClick:k=>o("preview",S),class:"p-2 bg-white/20 text-white rounded hover:bg-white/30",title:"Preview"},[...g[7]||(g[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,Em),N.showEditButton&&E(S)?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:k=>o("edit",S),class:"p-2 bg-white/20 text-white rounded hover:bg-white/30",title:"Edit"},[...g[8]||(g[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,Vm)):e.createCommentVNode("",!0),e.createElementVNode("button",{onClick:k=>o("delete",S.uuid),class:"p-2 bg-red-500/20 text-red-300 rounded hover:bg-red-500/30",title:"Delete"},[...g[9]||(g[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,Sm)])],8,hm),e.createElementVNode("div",Cm,[e.createElementVNode("h4",Nm,e.toDisplayString(S.file_name),1),e.createElementVNode("p",_m,[e.createTextVNode(e.toDisplayString(v(S.size))+" ",1),S.width&&S.height?(e.openBlock(),e.createElementBlock("span",Tm," • "+e.toDisplayString(S.width)+"x"+e.toDisplayString(S.height),1)):e.createCommentVNode("",!0)]),S.caption?(e.openBlock(),e.createElementBlock("p",Mm,e.toDisplayString(S.caption),1)):e.createCommentVNode("",!0)])],2)],42,um))),128))],2))}}),Im=Me(Bm,[["__scopeId","data-v-f0c343b7"]]),Fm={class:"model-media-manager"},Rm=["accept","multiple"],$m={class:"flex items-center justify-between mb-4"},Dm={key:0,class:"text-lg font-medium"},Um={class:"flex gap-2"},Om={key:0,class:"flex items-center justify-center py-8"},Am={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"},Lm={class:"text-gray-600 dark:text-gray-400"},zm={class:"flex gap-2 mt-4"},Pm={key:0,class:"px-2 py-1 bg-blue-500 text-white text-xs font-medium rounded"},jm=e.defineComponent({__name:"ModelMediaManager",props:{mediableType:{},mediableId:{},collection:{},mode:{default:"user"},initialMedia:{},maxFiles:{},acceptedMimeTypes:{},maxFileSize:{},allowReorder:{type:Boolean,default:!0},allowUpload:{type:Boolean,default:!0},allowBrowse:{type:Boolean,default:!0},allowDetach:{type:Boolean,default:!0},allowEdit:{type:Boolean,default:!1},editMode:{default:"replace"},showPrimaryBadge:{type:Boolean,default:!0},emptyText:{default:"No media attached"},title:{default:"Media"}},emits:["loading","update:media","error","attach","detach","reorder","upload-progress","edit-complete"],setup(a,{emit:n}){const t=a,o=n,i=kt(),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),p=e.ref(void 0),h=e.ref(null),v=e.ref(null),y=e.computed(()=>{if(t.maxFiles!==void 0)return Math.max(0,t.maxFiles-i.modelMedia.length)}),E=e.computed(()=>i.modelMedia.map(D=>D.uuid)),_=e.computed(()=>{if(!(!t.acceptedMimeTypes||t.acceptedMimeTypes.length===0))return t.acceptedMimeTypes.join(",")});function C(){In({isAdmin:t.mode==="admin"})}async function w(D){await(await B.toastController.create({message:D,duration:3e3,color:"danger",position:"bottom"})).present()}async function f(){if(!s.value)if(s.value=!0,C(),i.setModelContext(t.mediableType,t.mediableId,t.collection),t.initialMedia&&t.initialMedia.length>0)i.modelMedia=[...t.initialMedia],o("update:media",i.modelMedia);else{r.value=!0,o("loading",!0);try{await i.fetchModelMedia(t.mediableType,t.mediableId,t.collection),o("update:media",i.modelMedia)}catch(D){const Z=D instanceof Error?D.message:"Failed to fetch media";o("error",{operation:"fetch",message:Z,details:D})}finally{r.value=!1,o("loading",!1)}}}e.watch(()=>i.modelMedia,D=>{s.value&&o("update:media",D)},{deep:!0}),e.watch(()=>[t.mediableType,t.mediableId,t.collection],()=>{s.value=!1,f()}),e.watch(()=>t.mode,()=>{C()}),e.onMounted(()=>{f()}),e.onUnmounted(()=>{i.clearModelContext()});function x(){return i.modelMedia.length>0}function $(){return t.maxFiles===void 0?!1:i.modelMedia.length>=t.maxFiles}function N(D){var W,oe,we;if(!((W=D.mime_type)!=null&&W.startsWith("image/")))return null;const Z=D.original_url||D.url||((oe=D.conversion_urls)==null?void 0:oe.preview)||((we=D.conversion_urls)==null?void 0:we.thumb)||D.thumbnail_url;return Z&&Z.trim()!==""?Z:null}function g(){l.value=!0}function S(){var D;(D=v.value)==null||D.click()}function O(){l.value=!1}async function k(D){if(!t.allowEdit)return;const Z=N(D);if(Z){d.value=D,u.value++;try{const W=i.getHttpClient(),oe=i.getApiUrl(""),we=await W(`${oe.replace(/\/$/,"")}/editor/${D.uuid}/edit`);p.value=we.editable_source_url||Z,m.value=we.editor_state??null}catch{p.value=Z,m.value=null}c.value=!0}}function T(){c.value=!1,d.value=null,p.value=void 0,m.value=null}async function F(D){if(!d.value)throw new Error("No media selected for editing");const Z=d.value,W=t.editMode==="variant";try{h.value=null;const oe=await i.saveEditedImage(Z.uuid,D,{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,[oe.uuid],t.collection),o("edit-complete",{originalMedia:Z,editedMedia:oe,mode:t.editMode}),c.value=!1,d.value=null}catch(oe){const we=oe instanceof Error?oe.message:"Failed to save edited image";throw h.value=we,await w(we),oe}}function A(D){if(h.value===D.message){h.value=null;return}w(D.message)}async function R(D){const Z=D.target,W=Z.files;if(!(!W||W.length===0)){for(let oe=0;oe<W.length;oe++){const we=W[oe];if(y.value!==void 0&&y.value<=0)break;if(t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0&&!t.acceptedMimeTypes.includes(we.type)){o("error",{operation:"upload",message:`File type ${we.type} is not accepted`,details:{file:we.name}});continue}if(t.maxFileSize!==void 0&&we.size>t.maxFileSize){o("error",{operation:"upload",message:`File size exceeds limit of ${t.maxFileSize} bytes`,details:{file:we.name,size:we.size}});continue}o("upload-progress",{status:"uploading",progress:0,file:we});try{const Ce=await i.uploadFile(we,{collection:t.collection});Ce!=null&&Ce.uuid&&(await i.attachMedia(t.mediableType,t.mediableId,[Ce.uuid],t.collection),o("upload-progress",{status:"complete",progress:100,file:we}),o("attach",[Ce]))}catch(Ce){const ne=Ce instanceof Error?Ce.message:"Upload failed";o("error",{operation:"upload",message:ne,details:Ce}),o("upload-progress",{status:"error",progress:0,file:we,error:ne})}}Z.value=""}}async function j(D){const Z=D.map(W=>W.uuid);try{await i.reorderMedia(t.mediableType,t.mediableId,Z,t.collection),o("reorder",i.modelMedia)}catch(W){const oe=W instanceof Error?W.message:"Failed to reorder media";o("error",{operation:"reorder",message:oe,details:W}),await w(oe)}}async function K(D){const Z=i.modelMedia.find(W=>W.uuid===D);try{await i.detachMedia(t.mediableType,t.mediableId,D,t.collection),Z&&o("detach",Z)}catch(W){const oe=W instanceof Error?W.message:"Failed to detach media";o("error",{operation:"detach",message:oe,details:W}),await w(oe)}}async function I(D){l.value=!1;const Z=D.map(we=>we.uuid),W=new Set(E.value);let oe=Array.from(new Set(Z)).filter(we=>!W.has(we));if(y.value!==void 0&&oe.length>y.value&&(oe=oe.slice(0,y.value)),oe.length!==0)try{await i.attachMedia(t.mediableType,t.mediableId,oe,t.collection);const we=i.modelMedia.filter(Ce=>oe.includes(Ce.uuid));o("attach",we)}catch(we){const Ce=we instanceof Error?we.message:"Failed to attach media";o("error",{operation:"attach",message:Ce,details:we})}}return(D,Z)=>(e.openBlock(),e.createElementBlock("div",Fm,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:v,type:"file",accept:_.value,multiple:y.value===void 0||y.value>1,class:"hidden","data-testid":"upload-input",onChange:R},null,40,Rm),e.createElementVNode("div",$m,[D.title?(e.openBlock(),e.createElementBlock("h3",Dm,e.toDisplayString(D.title),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Um,[D.allowBrowse?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:0,fill:"outline",size:"small",disabled:$(),"data-testid":"browse-button",onClick:g},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{slot:"start",icon:e.unref(ni)},null,8,["icon"]),Z[1]||(Z[1]=e.createTextVNode(" Browse ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0),D.allowUpload?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:1,fill:"solid",size:"small",disabled:$(),"data-testid":"upload-button",onClick:S},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{slot:"start",icon:e.unref(Yr)},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",Om,[e.createVNode(e.unref(B.IonSpinner),{"data-testid":"spinner"})])):x()?(e.openBlock(),e.createBlock(Im,{key:2,"media-items":e.unref(i).modelMedia,reorderable:!!D.allowReorder,"is-loading":r.value||e.unref(i).isLoadingModelMedia,"show-edit-button":!!D.allowEdit,"selection-mode":!1,onReorder:j,onDelete:K,onEdit:k},e.createSlots({_:2},[D.showPrimaryBadge?{name:"badge",fn:e.withCtx(({index:W})=>[W===0?(e.openBlock(),e.createElementBlock("div",Pm," Primary ")):e.createCommentVNode("",!0)]),key:"0"}:void 0]),1032,["media-items","reorderable","is-loading","show-edit-button"])):(e.openBlock(),e.createElementBlock("div",Am,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(ni),class:"w-12 h-12 text-gray-400 mb-4"},null,8,["icon"]),e.createElementVNode("p",Lm,e.toDisplayString(D.emptyText),1),e.createElementVNode("div",zm,[D.allowBrowse?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:0,fill:"outline",size:"small","data-testid":"browse-button-empty",onClick:g},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{slot:"start",icon:e.unref(ni)},null,8,["icon"]),Z[3]||(Z[3]=e.createTextVNode(" Browse Library ",-1))]),_:1})):e.createCommentVNode("",!0),D.allowUpload?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:1,fill:"solid",size:"small","data-testid":"upload-button-empty",onClick:S},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{slot:"start",icon:e.unref(Yr)},null,8,["icon"]),Z[4]||(Z[4]=e.createTextVNode(" Upload Files ",-1))]),_:1})):e.createCommentVNode("",!0)])])),e.createVNode(cm,e.mergeProps({"is-open":l.value,"selected-items":E.value,collection:D.collection},y.value!==null&&y.value!==void 0?{maxSelection:y.value}:{},{onConfirm:I,onClose:O}),null,16,["is-open","selected-items","collection"]),e.createVNode(Ks,{modelValue:c.value,"onUpdate:modelValue":Z[0]||(Z[0]=W=>c.value=W),"initial-image":p.value,"initial-state":m.value,"session-key":u.value,"on-save":F,onCancel:T,onError:A},null,8,["modelValue","initial-image","initial-state","session-key"])]))}}),Wm=Me(jm,[["__scopeId","data-v-6677bbfe"]]),Zm=["src"],Xm={class:"preview-controls"},Hm=["aria-label"],Gm={class:"time-display"},Jm={class:"current-time"},Ym={class:"total-time"},Km={key:0,class:"fps-display"},qm={key:0,class:"loading-overlay"},Qm={key:1,class:"error-overlay"},ep=e.defineComponent({__name:"VideoPreview",props:{source:{},filters:{},playhead:{},isPlaying:{type:Boolean,default:!1},showFps:{type:Boolean,default:!1},targetFps:{default:30},fitMode:{default:"contain"},active:{type:Boolean,default:!0}},emits:["frame-update","play-pause","duration-change","error"],setup(a,{expose:n,emit:t}){const{ColorMatrixFilter:o,BlurFilter:i}=Je,r=a,s=t,l=e.ref(),c=e.ref(),d=e.ref(),u=e.ref(!0),m=e.ref(),p=e.ref(0),h=e.ref(0),v=e.ref(!1);let y,E,_=null,C=null,w=null,f=[],x="",$=null,N=0,g=0,S=0,O=0,k=!1,T=0,F=0,A,R=null,j=!1;const K=e.computed(()=>r.source&&typeof r.source=="string"?r.source:"");async function I(){var fe,P;if(c.value&&!y&&!(!d.value||d.value.readyState<3))try{let J=((fe=l.value)==null?void 0:fe.clientWidth)||800,ee=((P=l.value)==null?void 0:P.clientHeight)||450;if((J<=0||ee<=0)&&(J=d.value.videoWidth||800,ee=d.value.videoHeight||450),y=new Je.Application,await y.init({width:J,height:ee,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,antialias:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),c.value.appendChild(y.canvas),d.value){if(d.value.videoWidth===0||d.value.videoHeight===0){setTimeout(()=>{d.value&&d.value.videoWidth>0&&!y&&I()},100),y&&(y.destroy(!0),y=null);return}N=d.value.videoWidth,g=d.value.videoHeight,C=document.createElement("canvas"),C.width=N,C.height=g,w=C.getContext("2d"),w.drawImage(d.value,0,0,N,g);const te=Je.Texture.from(C);_=te.source,E=new Je.Sprite(te),E.visible=!0,E.alpha=1,ke(),y.stage.addChild(E),y.renderer&&!y.renderer.destroyed&&y.render()}oe(),r.targetFps<60?D():y.ticker.add(Z),v.value=!0,"ResizeObserver"in window&&($=new ResizeObserver(te=>{k||(k=!0,requestAnimationFrame(()=>{k=!1;const pe=te[te.length-1],{width:ve,height:Fe}=pe.contentRect;if(ve<=0||Fe<=0)return;const Oe=Math.round(ve),H=Math.round(Fe);Oe===S&&H===O||(S=Oe,O=H,ke())}))}),$.observe(l.value)),r.filters&&r.filters.length>0&&oe(),r.showFps&&se()}catch{m.value="Failed to initialize video preview"}}function D(){const fe=1e3/r.targetFps;let P=performance.now();function J(){if(j||!y)return;const ee=performance.now(),te=ee-P;te>=fe&&(Z(),P=ee-te%fe),R=requestAnimationFrame(J)}R=requestAnimationFrame(J)}function Z(){if(!(!y||!E||j)&&r.active)try{w&&C&&_&&d.value&&(d.value.readyState>=2&&(w.drawImage(d.value,0,0,C.width,C.height),_.update()),d.value.paused||s("frame-update",ne())),r.showFps&&F++,y.renderer&&!y.renderer.destroyed&&y.render()}catch{j=!0}}function W(){for(const fe of f)try{fe.destroy()}catch{}f=[]}function oe(){if(E){if(!r.filters||r.filters.length===0){E.filters=null,W();return}W(),r.filters.forEach(fe=>{const P=we(fe);P&&f.push(P)}),E.filters=f.length>0?f:null,x=JSON.stringify(r.filters),y&&y.render()}}function we(fe){const P=fe.filterId,J=fe.params||{},ee=rt.getFilter(P);if(ee&&!rt.isFilterCompatibleWithMedia(P,"video"))return null;if(ee&&ee.createFilter)try{return ee.createFilter(J)}catch{}const te=(pe,ve,Fe)=>Math.min(Fe,Math.max(ve,pe));switch(P){case"brightness":{const pe=new o,ve=te(typeof J.brightness=="number"?J.brightness:typeof J.value=="number"?J.value:1,0,5);return pe.brightness(ve,!0),pe}case"contrast":{const pe=new o,ve=te(typeof J.contrast=="number"?J.contrast:typeof J.value=="number"?J.value:1,0,5);return pe.contrast(ve,!0),pe}case"saturation":{const pe=new o,ve=te(typeof J.saturation=="number"?J.saturation:typeof J.value=="number"?J.value:1,0,5);return pe.saturate(ve,!0),pe}case"hue":{const pe=new o,ve=te(typeof J.value=="number"?J.value:0,-180,180);return pe.hue(ve,!0),pe}case"gaussian-blur":case"blur":{const pe=te(typeof J.blur=="number"?J.blur:typeof J.value=="number"?J.value:2,0,10);return new i(pe)}case"grayscale":{const pe=new o;return pe.desaturate(),pe}case"sepia":case"color-matrix":{const pe=new o;return pe.sepia(!0),pe}case"vignette":{const pe=typeof J.value=="number"?J.value:.3;return Ce(te(pe,0,1))}default:return null}}function Ce(fe){const P=`
|
|
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 Je.Filter(void 0,P,{strength:fe})}function ne(){var P;return!y||!E?null:{dataUrl:y.canvas.toDataURL("image/jpeg",.8),timestamp:((P=d.value)==null?void 0:P.currentTime)||0,width:N||0,height:g||0}}function M(){var fe;p.value=((fe=d.value)==null?void 0:fe.duration)||0,s("duration-change",p.value)}function z(){u.value=!1,m.value=void 0}function me(){u.value&&(u.value=!1),!v.value&&r.active?I():v.value}function ae(){var P,J,ee;const fe=((P=d.value)==null?void 0:P.currentTime)||0;s("frame-update",{dataUrl:null,timestamp:fe,width:((J=d.value)==null?void 0:J.videoWidth)||0,height:((ee=d.value)==null?void 0:ee.videoHeight)||0})}function Y(){s("play-pause")}function Te(fe){var J;const P=fe.target;if(P!=null&&P.error)switch(P.error.code){case P.error.MEDIA_ERR_ABORTED:m.value="Video playback aborted";break;case P.error.MEDIA_ERR_NETWORK:m.value="Network error loading video";break;case P.error.MEDIA_ERR_DECODE:m.value="Video format not supported";break;case P.error.MEDIA_ERR_SRC_NOT_SUPPORTED:m.value=`Video source not supported: ${(J=P.src)==null?void 0:J.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 ue(fe){d.value&&(d.value.currentTime=Math.max(0,Math.min(fe,p.value)))}function se(){A=window.setInterval(()=>{const fe=performance.now(),P=fe-T;h.value=Math.round(F*1e3/P),F=0,T=fe},1e3)}function be(fe){const P=Math.floor(fe/60),J=Math.floor(fe%60);return`${P.toString().padStart(2,"0")}:${J.toString().padStart(2,"0")}`}function ie(){m.value=void 0,u.value=!0,d.value&&d.value.load()}function le(){y&&(k||(k=!0,requestAnimationFrame(()=>{k=!1,ke()})))}function ke(){if(!y||!E||!N||!g||!l.value)return;const fe=Math.round(l.value.clientWidth),P=Math.round(l.value.clientHeight);if(fe<=0||P<=0)return;y.renderer.resize(fe,P);const J=y.screen.width/N,ee=y.screen.height/g;let te=1;switch(r.fitMode){case"cover":te=Math.max(J,ee);break;case"none":te=1;break;case"contain":default:te=Math.min(J,ee);break}E.scale.set(te),E.anchor.set(.5),E.position.set(y.screen.width/2,y.screen.height/2),E.visible=!0,E.alpha=1,y.renderer&&!y.renderer.destroyed&&y.render()}e.watch(()=>r.filters,()=>{v.value&&oe()},{deep:!0}),e.watch(()=>r.active,async fe=>{if(fe&&!y&&d.value&&d.value.readyState>=2){await I();return}y&&(fe&&(await e.nextTick(),l.value&&l.value.getBoundingClientRect(),E&&w&&C&&_&&(d.value&&d.value.readyState>=2&&(w.drawImage(d.value,0,0,C.width,C.height),_.update()),ke(),y.renderer&&!y.renderer.destroyed&&y.render())),r.targetFps>=60&&y.ticker&&(fe?y.ticker.start():y.ticker.stop()))}),e.watch(K,fe=>{fe?(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 Ve(){if(d.value){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,fe=>{d.value&&(fe?Ve():d.value.pause())}),e.watch(()=>r.playhead,fe=>{d.value&&Math.abs(d.value.currentTime-fe)>.5&&ue(fe)}),e.watch(()=>r.fitMode,()=>{ke()}),e.onMounted(()=>{j=!1,e.nextTick(()=>{l.value&&l.value.getBoundingClientRect(),d.value}),window.addEventListener("resize",le),T=performance.now(),e.nextTick(()=>{d.value&&d.value.readyState>=2&&!v.value&&I()})}),e.onUnmounted(()=>{if(j=!0,R&&(cancelAnimationFrame(R),R=null),window.removeEventListener("resize",le),$&&($.disconnect(),$=null),A&&clearInterval(A),y&&y.ticker&&(y.ticker.stop(),y.ticker.remove(Z)),y){try{y.destroy(!0,{children:!0,texture:!0})}catch{}y=null}f.forEach(fe=>{try{fe.destroy()}catch{}}),f=[],E=null,_=null,C=null,w=null,d.value&&(d.value.pause(),d.value.removeAttribute("src"),d.value.load())});async function et(fe){if(!await We()||!d.value||!w||!C||!_)return null;const J=d.value,ee=Number.isFinite(p.value)&&p.value>0?p.value:Number.isFinite(J.duration)&&J.duration>0?J.duration:0,te=Math.max(0,Math.min(fe,ee));await new Promise(pe=>{let ve=!1,Fe=0;const Oe=()=>{ve||(ve=!0,J.removeEventListener("seeked",H),window.clearTimeout(Fe),pe())},H=()=>{Oe()},re=Number.isFinite(J.currentTime)?J.currentTime:0;if(Math.abs(re-te)<.016){requestAnimationFrame(()=>Oe());return}J.addEventListener("seeked",H),Fe=window.setTimeout(()=>Oe(),700),J.currentTime=te});try{w.drawImage(J,0,0,C.width,C.height),_.update(),y.render()}catch{return null}return y.canvas}async function We(){if(!d.value)return!1;if(!y){if(!(d.value.readyState>=2))return!1;await I()}if(!y||!E||!w||!C||!_)return!1;if(r.filters&&r.filters.length>0){const fe=E.filters,P=Array.isArray(fe)?fe.length:0,ee=JSON.stringify(r.filters)!==x;(P===0||P!==r.filters.length||ee)&&oe()}return await e.nextTick(),await new Promise(fe=>{requestAnimationFrame(()=>fe())}),!0}return n({captureFrameAt:et,ensureReadyForCapture:We,duration:p,pixiCanvas:e.computed(()=>y?y.canvas:null),videoElement:e.computed(()=>d.value??null)}),(fe,P)=>(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:K.value,onLoadedmetadata:M,onLoadeddata:z,onCanplay:me,onTimeupdate:ae,onEnded:Y,onError:Te,style:e.normalizeStyle({display:v.value?"none":"block",position:"relative",width:"100%",height:"100%",objectFit:fe.fitMode}),crossorigin:"anonymous",playsinline:"",controls:""},null,44,Zm),e.createElementVNode("div",Xm,[e.createElementVNode("button",{class:"play-button",onClick:P[0]||(P[0]=J=>fe.$emit("play-pause")),"aria-label":fe.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(B.IonIcon),{icon:fe.isPlaying?e.unref(tl):e.unref(ol)},null,8,["icon"])],8,Hm),e.createElementVNode("div",Gm,[e.createElementVNode("span",Jm,e.toDisplayString(be(fe.playhead)),1),P[1]||(P[1]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",Ym,e.toDisplayString(be(p.value)),1)]),fe.showFps?(e.openBlock(),e.createElementBlock("div",Km,e.toDisplayString(h.value)+" FPS ",1)):e.createCommentVNode("",!0)]),u.value?(e.openBlock(),e.createElementBlock("div",qm,[e.createVNode(e.unref(B.IonSpinner),{name:"crescent"}),P[2]||(P[2]=e.createElementVNode("p",null,"Loading video...",-1))])):e.createCommentVNode("",!0),m.value?(e.openBlock(),e.createElementBlock("div",Qm,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Wi)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(m.value),1),e.createElementVNode("button",{onClick:ie},"Retry")])):e.createCommentVNode("",!0)],512))}}),ns=Me(ep,[["__scopeId","data-v-1565c38d"]]);var Xi=(a,n,t)=>{if(!n.has(a))throw TypeError("Cannot "+t)},U=(a,n,t)=>(Xi(a,n,"read from private field"),t?t.call(a):n.get(a)),Ie=(a,n,t)=>{if(n.has(a))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(a):n.set(a,t)},at=(a,n,t,o)=>(Xi(a,n,"write to private field"),n.set(a,t),t),tp=(a,n,t,o)=>({set _(i){at(a,n,i)},get _(){return U(a,n,o)}}),Re=(a,n,t)=>(Xi(a,n,"access private method"),t),De=new Uint8Array(8),jt=new DataView(De.buffer),Qe=a=>[(a%256+256)%256],Ae=a=>(jt.setUint16(0,a,!1),[De[0],De[1]]),np=a=>(jt.setInt16(0,a,!1),[De[0],De[1]]),sl=a=>(jt.setUint32(0,a,!1),[De[1],De[2],De[3]]),ye=a=>(jt.setUint32(0,a,!1),[De[0],De[1],De[2],De[3]]),op=a=>(jt.setInt32(0,a,!1),[De[0],De[1],De[2],De[3]]),yn=a=>(jt.setUint32(0,Math.floor(a/2**32),!1),jt.setUint32(4,a,!1),[De[0],De[1],De[2],De[3],De[4],De[5],De[6],De[7]]),Hi=a=>(jt.setInt16(0,2**8*a,!1),[De[0],De[1]]),Lt=a=>(jt.setInt32(0,2**16*a,!1),[De[0],De[1],De[2],De[3]]),ai=a=>(jt.setInt32(0,2**30*a,!1),[De[0],De[1],De[2],De[3]]),Nt=(a,n=!1)=>{let t=Array(a.length).fill(null).map((o,i)=>a.charCodeAt(i));return n&&t.push(0),t},aa=a=>a&&a[a.length-1],Gi=a=>{let n;for(let t of a)(!n||t.presentationTimestamp>n.presentationTimestamp)&&(n=t);return n},Pt=(a,n,t=!0)=>{let o=a*n;return t?Math.round(o):o},ll=a=>{let n=a*(Math.PI/180),t=Math.cos(n),o=Math.sin(n);return[t,o,0,-o,t,0,0,0,1]},cl=ll(0),dl=a=>[Lt(a[0]),Lt(a[1]),ai(a[2]),Lt(a[3]),Lt(a[4]),ai(a[5]),Lt(a[6]),Lt(a[7]),ai(a[8])],ro=a=>!a||typeof a!="object"?a:Array.isArray(a)?a.map(ro):Object.fromEntries(Object.entries(a).map(([n,t])=>[n,ro(t)])),Rn=a=>a>=0&&a<2**32,Ke=(a,n,t)=>({type:a,contents:n&&new Uint8Array(n.flat(10)),children:t}),Pe=(a,n,t,o,i)=>Ke(a,[Qe(n),sl(t),o??[]],i),ap=a=>{let n=512;return a.fragmented?Ke("ftyp",[Nt("iso5"),ye(n),Nt("iso5"),Nt("iso6"),Nt("mp41")]):Ke("ftyp",[Nt("isom"),ye(n),Nt("isom"),a.holdsAvc?Nt("avc1"):[],Nt("mp41")])},wi=a=>({type:"mdat",largeSize:a}),ip=a=>({type:"free",size:a}),Xo=(a,n,t=!1)=>Ke("moov",null,[rp(n,a),...a.map(o=>sp(o,n)),t?Op(a):null]),rp=(a,n)=>{let t=Pt(Math.max(0,...n.filter(s=>s.samples.length>0).map(s=>{const l=Gi(s.samples);return l.presentationTimestamp+l.duration})),xi),o=Math.max(...n.map(s=>s.id))+1,i=!Rn(a)||!Rn(t),r=i?yn:ye;return Pe("mvhd",+i,0,[r(a),r(a),ye(xi),r(t),Lt(1),Hi(1),Array(10).fill(0),dl(cl),Array(24).fill(0),ye(o)])},sp=(a,n)=>Ke("trak",null,[lp(a,n),cp(a,n)]),lp=(a,n)=>{let t=Gi(a.samples),o=Pt(t?t.presentationTimestamp+t.duration:0,xi),i=!Rn(n)||!Rn(o),r=i?yn:ye,s;return a.info.type==="video"?s=typeof a.info.rotation=="number"?ll(a.info.rotation):a.info.rotation:s=cl,Pe("tkhd",+i,3,[r(n),r(n),ye(a.id),ye(0),r(o),Array(8).fill(0),Ae(0),Ae(0),Hi(a.info.type==="audio"?1:0),Ae(0),dl(s),Lt(a.info.type==="video"?a.info.width:0),Lt(a.info.type==="video"?a.info.height:0)])},cp=(a,n)=>Ke("mdia",null,[dp(a,n),up(a.info.type==="video"?"vide":"soun"),mp(a)]),dp=(a,n)=>{let t=Gi(a.samples),o=Pt(t?t.presentationTimestamp+t.duration:0,a.timescale),i=!Rn(n)||!Rn(o),r=i?yn:ye;return Pe("mdhd",+i,0,[r(n),r(n),ye(a.timescale),r(o),Ae(21956),Ae(0)])},up=a=>Pe("hdlr",0,0,[Nt("mhlr"),Nt(a),ye(0),ye(0),ye(0),Nt("mp4-muxer-hdlr",!0)]),mp=a=>Ke("minf",null,[a.info.type==="video"?pp():fp(),hp(),yp(a)]),pp=()=>Pe("vmhd",0,1,[Ae(0),Ae(0),Ae(0),Ae(0)]),fp=()=>Pe("smhd",0,0,[Ae(0),Ae(0)]),hp=()=>Ke("dinf",null,[vp()]),vp=()=>Pe("dref",0,0,[ye(1)],[gp()]),gp=()=>Pe("url ",0,1),yp=a=>{const n=a.compositionTimeOffsetTable.length>1||a.compositionTimeOffsetTable.some(t=>t.sampleCompositionTimeOffset!==0);return Ke("stbl",null,[wp(a),Ip(a),Fp(a),Rp(a),$p(a),Dp(a),n?Up(a):null])},wp=a=>Pe("stsd",0,0,[ye(1)],[a.info.type==="video"?bp(Gp[a.info.codec],a):Tp(Yp[a.info.codec],a)]),bp=(a,n)=>Ke(a,[Array(6).fill(0),Ae(1),Ae(0),Ae(0),Array(12).fill(0),Ae(n.info.width),Ae(n.info.height),ye(4718592),ye(4718592),ye(0),Ae(1),Array(32).fill(0),Ae(24),np(65535)],[Jp[n.info.codec](n),n.info.decoderConfig.colorSpace?Vp(n):null]),kp={bt709:1,bt470bg:5,smpte170m:6},xp={bt709:1,smpte170m:6,"iec61966-2-1":13},Ep={rgb:0,bt709:1,bt470bg:5,smpte170m:6},Vp=a=>Ke("colr",[Nt("nclx"),Ae(kp[a.info.decoderConfig.colorSpace.primaries]),Ae(xp[a.info.decoderConfig.colorSpace.transfer]),Ae(Ep[a.info.decoderConfig.colorSpace.matrix]),Qe((a.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),Sp=a=>a.info.decoderConfig&&Ke("avcC",[...new Uint8Array(a.info.decoderConfig.description)]),Cp=a=>a.info.decoderConfig&&Ke("hvcC",[...new Uint8Array(a.info.decoderConfig.description)]),Np=a=>{if(!a.info.decoderConfig)return null;let n=a.info.decoderConfig;if(!n.colorSpace)throw new Error("'colorSpace' is required in the decoder config for VP9.");let t=n.codec.split("."),o=Number(t[1]),i=Number(t[2]),l=(Number(t[3])<<4)+(0<<1)+Number(n.colorSpace.fullRange);return Pe("vpcC",1,0,[Qe(o),Qe(i),Qe(l),Qe(2),Qe(2),Qe(2),Ae(0)])},_p=()=>{let t=(1<<7)+1;return Ke("av1C",[t,0,0,0])},Tp=(a,n)=>Ke(a,[Array(6).fill(0),Ae(1),Ae(0),Ae(0),ye(0),Ae(n.info.numberOfChannels),Ae(16),Ae(0),Ae(0),Lt(n.info.sampleRate)],[Kp[n.info.codec](n)]),Mp=a=>{let n=new Uint8Array(a.info.decoderConfig.description);return Pe("esds",0,0,[ye(58753152),Qe(32+n.byteLength),Ae(1),Qe(0),ye(75530368),Qe(18+n.byteLength),Qe(64),Qe(21),sl(0),ye(130071),ye(130071),ye(92307584),Qe(n.byteLength),...n,ye(109084800),Qe(1),Qe(2)])},Bp=a=>{var i;let n=3840,t=0;const o=(i=a.info.decoderConfig)==null?void 0:i.description;if(o){if(o.byteLength<18)throw new TypeError("Invalid decoder description provided for Opus; must be at least 18 bytes long.");const r=ArrayBuffer.isView(o)?new DataView(o.buffer,o.byteOffset,o.byteLength):new DataView(o);n=r.getUint16(10,!0),t=r.getInt16(14,!0)}return Ke("dOps",[Qe(0),Qe(a.info.numberOfChannels),Ae(n),ye(a.info.sampleRate),Hi(t),Qe(0)])},Ip=a=>Pe("stts",0,0,[ye(a.timeToSampleTable.length),a.timeToSampleTable.map(n=>[ye(n.sampleCount),ye(n.sampleDelta)])]),Fp=a=>{if(a.samples.every(t=>t.type==="key"))return null;let n=[...a.samples.entries()].filter(([,t])=>t.type==="key");return Pe("stss",0,0,[ye(n.length),n.map(([t])=>ye(t+1))])},Rp=a=>Pe("stsc",0,0,[ye(a.compactlyCodedChunkTable.length),a.compactlyCodedChunkTable.map(n=>[ye(n.firstChunk),ye(n.samplesPerChunk),ye(1)])]),$p=a=>Pe("stsz",0,0,[ye(0),ye(a.samples.length),a.samples.map(n=>ye(n.size))]),Dp=a=>a.finalizedChunks.length>0&&aa(a.finalizedChunks).offset>=2**32?Pe("co64",0,0,[ye(a.finalizedChunks.length),a.finalizedChunks.map(n=>yn(n.offset))]):Pe("stco",0,0,[ye(a.finalizedChunks.length),a.finalizedChunks.map(n=>ye(n.offset))]),Up=a=>Pe("ctts",0,0,[ye(a.compositionTimeOffsetTable.length),a.compositionTimeOffsetTable.map(n=>[ye(n.sampleCount),ye(n.sampleCompositionTimeOffset)])]),Op=a=>Ke("mvex",null,a.map(Ap)),Ap=a=>Pe("trex",0,0,[ye(a.id),ye(1),ye(0),ye(0),ye(0)]),os=(a,n)=>Ke("moof",null,[Lp(a),...n.map(zp)]),Lp=a=>Pe("mfhd",0,0,[ye(a)]),ul=a=>{let n=0,t=0,o=0,i=0,r=a.type==="delta";return t|=+r,r?n|=1:n|=2,n<<24|t<<16|o<<8|i},zp=a=>Ke("traf",null,[Pp(a),jp(a),Wp(a)]),Pp=a=>{let n=0;n|=8,n|=16,n|=32,n|=131072;let t=a.currentChunk.samples[1]??a.currentChunk.samples[0],o={duration:t.timescaleUnitsToNextSample,size:t.size,flags:ul(t)};return Pe("tfhd",0,n,[ye(a.id),ye(o.duration),ye(o.size),ye(o.flags)])},jp=a=>Pe("tfdt",1,0,[yn(Pt(a.currentChunk.startTimestamp,a.timescale))]),Wp=a=>{let n=a.currentChunk.samples.map(y=>y.timescaleUnitsToNextSample),t=a.currentChunk.samples.map(y=>y.size),o=a.currentChunk.samples.map(ul),i=a.currentChunk.samples.map(y=>Pt(y.presentationTimestamp-y.decodeTimestamp,a.timescale)),r=new Set(n),s=new Set(t),l=new Set(o),c=new Set(i),d=l.size===2&&o[0]!==o[1],u=r.size>1,m=s.size>1,p=!d&&l.size>1,h=c.size>1||[...c].some(y=>y!==0),v=0;return v|=1,v|=4*+d,v|=256*+u,v|=512*+m,v|=1024*+p,v|=2048*+h,Pe("trun",1,v,[ye(a.currentChunk.samples.length),ye(a.currentChunk.offset-a.currentChunk.moofOffset||0),d?ye(o[0]):[],a.currentChunk.samples.map((y,E)=>[u?ye(n[E]):[],m?ye(t[E]):[],p?ye(o[E]):[],h?op(i[E]):[]])])},Zp=a=>Ke("mfra",null,[...a.map(Xp),Hp()]),Xp=(a,n)=>Pe("tfra",1,0,[ye(a.id),ye(63),ye(a.finalizedChunks.length),a.finalizedChunks.map(o=>[yn(Pt(o.startTimestamp,a.timescale)),yn(o.moofOffset),ye(n+1),ye(1),ye(1)])]),Hp=()=>Pe("mfro",0,0,[ye(0)]),Gp={avc:"avc1",hevc:"hvc1",vp9:"vp09",av1:"av01"},Jp={avc:Sp,hevc:Cp,vp9:Np,av1:_p},Yp={aac:"mp4a",opus:"Opus"},Kp={aac:Mp,opus:Bp},ga=class{},Ji=class extends ga{constructor(){super(...arguments),this.buffer=null}},ml=class extends ga{constructor(a){if(super(),this.options=a,typeof a!="object")throw new TypeError("StreamTarget requires an options object to be passed to its constructor.");if(a.onData){if(typeof a.onData!="function")throw new TypeError("options.onData, when provided, must be a function.");if(a.onData.length<2)throw new TypeError("options.onData, when provided, must be a function that takes in at least two arguments (data and position). Ignoring the position argument, which specifies the byte offset at which the data is to be written, can lead to broken outputs.")}if(a.chunked!==void 0&&typeof a.chunked!="boolean")throw new TypeError("options.chunked, when provided, must be a boolean.");if(a.chunkSize!==void 0&&(!Number.isInteger(a.chunkSize)||a.chunkSize<1024))throw new TypeError("options.chunkSize, when provided, must be an integer and not smaller than 1024.")}},qp=class extends ga{constructor(a,n){if(super(),this.stream=a,this.options=n,!(a instanceof FileSystemWritableFileStream))throw new TypeError("FileSystemWritableFileStreamTarget requires a FileSystemWritableFileStream instance.");if(n!==void 0&&typeof n!="object")throw new TypeError("FileSystemWritableFileStreamTarget's options, when provided, must be an object.");if(n&&n.chunkSize!==void 0&&(!Number.isInteger(n.chunkSize)||n.chunkSize<=0))throw new TypeError("options.chunkSize, when provided, must be a positive integer")}},ln,_n,pl=class{constructor(){this.pos=0,Ie(this,ln,new Uint8Array(8)),Ie(this,_n,new DataView(U(this,ln).buffer)),this.offsets=new WeakMap}seek(a){this.pos=a}writeU32(a){U(this,_n).setUint32(0,a,!1),this.write(U(this,ln).subarray(0,4))}writeU64(a){U(this,_n).setUint32(0,Math.floor(a/2**32),!1),U(this,_n).setUint32(4,a,!1),this.write(U(this,ln).subarray(0,8))}writeAscii(a){for(let n=0;n<a.length;n++)U(this,_n).setUint8(n%8,a.charCodeAt(n)),n%8===7&&this.write(U(this,ln));a.length%8!==0&&this.write(U(this,ln).subarray(0,a.length%8))}writeBox(a){if(this.offsets.set(a,this.pos),a.contents&&!a.children)this.writeBoxHeader(a,a.size??a.contents.byteLength+8),this.write(a.contents);else{let n=this.pos;if(this.writeBoxHeader(a,0),a.contents&&this.write(a.contents),a.children)for(let i of a.children)i&&this.writeBox(i);let t=this.pos,o=a.size??t-n;this.seek(n),this.writeBoxHeader(a,o),this.seek(t)}}writeBoxHeader(a,n){this.writeU32(a.largeSize?1:n),this.writeAscii(a.type),a.largeSize&&this.writeU64(n)}measureBoxHeader(a){return 8+(a.largeSize?8:0)}patchBox(a){let n=this.pos;this.seek(this.offsets.get(a)),this.writeBox(a),this.seek(n)}measureBox(a){if(a.contents&&!a.children)return this.measureBoxHeader(a)+a.contents.byteLength;{let n=this.measureBoxHeader(a);if(a.contents&&(n+=a.contents.byteLength),a.children)for(let t of a.children)t&&(n+=this.measureBox(t));return n}}};ln=new WeakMap;_n=new WeakMap;var Ho,vn,fo,no,Go,bi,Qp=class extends pl{constructor(a){super(),Ie(this,Go),Ie(this,Ho,void 0),Ie(this,vn,new ArrayBuffer(2**16)),Ie(this,fo,new Uint8Array(U(this,vn))),Ie(this,no,0),at(this,Ho,a)}write(a){Re(this,Go,bi).call(this,this.pos+a.byteLength),U(this,fo).set(a,this.pos),this.pos+=a.byteLength,at(this,no,Math.max(U(this,no),this.pos))}finalize(){Re(this,Go,bi).call(this,this.pos),U(this,Ho).buffer=U(this,vn).slice(0,Math.max(U(this,no),this.pos))}};Ho=new WeakMap;vn=new WeakMap;fo=new WeakMap;no=new WeakMap;Go=new WeakSet;bi=function(a){let n=U(this,vn).byteLength;for(;n<a;)n*=2;if(n===U(this,vn).byteLength)return;let t=new ArrayBuffer(n),o=new Uint8Array(t);o.set(U(this,fo),0),at(this,vn,t),at(this,fo,o)};var ef=2**24,tf=2,so,cn,oo,Yt,Vt,ia,ki,Yi,fl,Ki,hl,lo,ra,qi=class extends pl{constructor(a){var n,t;super(),Ie(this,ia),Ie(this,Yi),Ie(this,Ki),Ie(this,lo),Ie(this,so,void 0),Ie(this,cn,[]),Ie(this,oo,void 0),Ie(this,Yt,void 0),Ie(this,Vt,[]),at(this,so,a),at(this,oo,((n=a.options)==null?void 0:n.chunked)??!1),at(this,Yt,((t=a.options)==null?void 0:t.chunkSize)??ef)}write(a){U(this,cn).push({data:a.slice(),start:this.pos}),this.pos+=a.byteLength}flush(){var t,o;if(U(this,cn).length===0)return;let a=[],n=[...U(this,cn)].sort((i,r)=>i.start-r.start);a.push({start:n[0].start,size:n[0].data.byteLength});for(let i=1;i<n.length;i++){let r=a[a.length-1],s=n[i];s.start<=r.start+r.size?r.size=Math.max(r.size,s.start+s.data.byteLength-r.start):a.push({start:s.start,size:s.data.byteLength})}for(let i of a){i.data=new Uint8Array(i.size);for(let r of U(this,cn))i.start<=r.start&&r.start<i.start+i.size&&i.data.set(r.data,r.start-i.start);U(this,oo)?(Re(this,ia,ki).call(this,i.data,i.start),Re(this,lo,ra).call(this)):(o=(t=U(this,so).options).onData)==null||o.call(t,i.data,i.start)}U(this,cn).length=0}finalize(){U(this,oo)&&Re(this,lo,ra).call(this,!0)}};so=new WeakMap;cn=new WeakMap;oo=new WeakMap;Yt=new WeakMap;Vt=new WeakMap;ia=new WeakSet;ki=function(a,n){let t=U(this,Vt).findIndex(l=>l.start<=n&&n<l.start+U(this,Yt));t===-1&&(t=Re(this,Ki,hl).call(this,n));let o=U(this,Vt)[t],i=n-o.start,r=a.subarray(0,Math.min(U(this,Yt)-i,a.byteLength));o.data.set(r,i);let s={start:i,end:i+r.byteLength};if(Re(this,Yi,fl).call(this,o,s),o.written[0].start===0&&o.written[0].end===U(this,Yt)&&(o.shouldFlush=!0),U(this,Vt).length>tf){for(let l=0;l<U(this,Vt).length-1;l++)U(this,Vt)[l].shouldFlush=!0;Re(this,lo,ra).call(this)}r.byteLength<a.byteLength&&Re(this,ia,ki).call(this,a.subarray(r.byteLength),n+r.byteLength)};Yi=new WeakSet;fl=function(a,n){let t=0,o=a.written.length-1,i=-1;for(;t<=o;){let r=Math.floor(t+(o-t+1)/2);a.written[r].start<=n.start?(t=r+1,i=r):o=r-1}for(a.written.splice(i+1,0,n),(i===-1||a.written[i].end<n.start)&&i++;i<a.written.length-1&&a.written[i].end>=a.written[i+1].start;)a.written[i].end=Math.max(a.written[i].end,a.written[i+1].end),a.written.splice(i+1,1)};Ki=new WeakSet;hl=function(a){let t={start:Math.floor(a/U(this,Yt))*U(this,Yt),data:new Uint8Array(U(this,Yt)),written:[],shouldFlush:!1};return U(this,Vt).push(t),U(this,Vt).sort((o,i)=>o.start-i.start),U(this,Vt).indexOf(t)};lo=new WeakSet;ra=function(a=!1){var n,t;for(let o=0;o<U(this,Vt).length;o++){let i=U(this,Vt)[o];if(!(!i.shouldFlush&&!a)){for(let r of i.written)(t=(n=U(this,so).options).onData)==null||t.call(n,i.data.subarray(r.start,r.end),i.start+r.start);U(this,Vt).splice(o--,1)}}};var nf=class extends qi{constructor(a){var n;super(new ml({onData:(t,o)=>a.stream.write({type:"write",data:t,position:o}),chunked:!0,chunkSize:(n=a.options)==null?void 0:n.chunkSize}))}},xi=1e3,of=["avc","hevc","vp9","av1"],af=["aac","opus"],rf=2082844800,sf=["strict","offset","cross-track-offset"],Se,_e,sa,xt,it,ot,Tn,Mn,Qi,dn,un,co,Ei,vl,Vi,gl,er,yl,Si,wl,tr,bl,Jo,Ci,At,Jt,nr,kl,uo,la,ca,or,$n,go,Yo,Ni,xl=class{constructor(a){if(Ie(this,Ei),Ie(this,Vi),Ie(this,er),Ie(this,Si),Ie(this,tr),Ie(this,Jo),Ie(this,At),Ie(this,nr),Ie(this,uo),Ie(this,ca),Ie(this,$n),Ie(this,Yo),Ie(this,Se,void 0),Ie(this,_e,void 0),Ie(this,sa,void 0),Ie(this,xt,void 0),Ie(this,it,null),Ie(this,ot,null),Ie(this,Tn,Math.floor(Date.now()/1e3)+rf),Ie(this,Mn,[]),Ie(this,Qi,1),Ie(this,dn,[]),Ie(this,un,[]),Ie(this,co,!1),Re(this,Ei,vl).call(this,a),a.video=ro(a.video),a.audio=ro(a.audio),a.fastStart=ro(a.fastStart),this.target=a.target,at(this,Se,{firstTimestampBehavior:"strict",...a}),a.target instanceof Ji)at(this,_e,new Qp(a.target));else if(a.target instanceof ml)at(this,_e,new qi(a.target));else if(a.target instanceof qp)at(this,_e,new nf(a.target));else throw new Error(`Invalid target: ${a.target}`);Re(this,Si,wl).call(this),Re(this,Vi,gl).call(this)}addVideoChunk(a,n,t,o){if(!(a instanceof EncodedVideoChunk))throw new TypeError("addVideoChunk's first argument (sample) must be of type EncodedVideoChunk.");if(n&&typeof n!="object")throw new TypeError("addVideoChunk's second argument (meta), when provided, must be an object.");if(t!==void 0&&(!Number.isFinite(t)||t<0))throw new TypeError("addVideoChunk's third argument (timestamp), when provided, must be a non-negative real number.");if(o!==void 0&&!Number.isFinite(o))throw new TypeError("addVideoChunk's fourth argument (compositionTimeOffset), when provided, must be a real number.");let i=new Uint8Array(a.byteLength);a.copyTo(i),this.addVideoChunkRaw(i,a.type,t??a.timestamp,a.duration,n,o)}addVideoChunkRaw(a,n,t,o,i,r){if(!(a instanceof Uint8Array))throw new TypeError("addVideoChunkRaw's first argument (data) must be an instance of Uint8Array.");if(n!=="key"&&n!=="delta")throw new TypeError("addVideoChunkRaw's second argument (type) must be either 'key' or 'delta'.");if(!Number.isFinite(t)||t<0)throw new TypeError("addVideoChunkRaw's third argument (timestamp) must be a non-negative real number.");if(!Number.isFinite(o)||o<0)throw new TypeError("addVideoChunkRaw's fourth argument (duration) must be a non-negative real number.");if(i&&typeof i!="object")throw new TypeError("addVideoChunkRaw's fifth argument (meta), when provided, must be an object.");if(r!==void 0&&!Number.isFinite(r))throw new TypeError("addVideoChunkRaw's sixth argument (compositionTimeOffset), when provided, must be a real number.");if(Re(this,Yo,Ni).call(this),!U(this,Se).video)throw new Error("No video track declared.");if(typeof U(this,Se).fastStart=="object"&&U(this,it).samples.length===U(this,Se).fastStart.expectedVideoChunks)throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${U(this,Se).fastStart.expectedVideoChunks}).`);let s=Re(this,Jo,Ci).call(this,U(this,it),a,n,t,o,i,r);if(U(this,Se).fastStart==="fragmented"&&U(this,ot)){for(;U(this,un).length>0&&U(this,un)[0].decodeTimestamp<=s.decodeTimestamp;){let l=U(this,un).shift();Re(this,At,Jt).call(this,U(this,ot),l)}s.decodeTimestamp<=U(this,ot).lastDecodeTimestamp?Re(this,At,Jt).call(this,U(this,it),s):U(this,dn).push(s)}else Re(this,At,Jt).call(this,U(this,it),s)}addAudioChunk(a,n,t){if(!(a instanceof EncodedAudioChunk))throw new TypeError("addAudioChunk's first argument (sample) must be of type EncodedAudioChunk.");if(n&&typeof n!="object")throw new TypeError("addAudioChunk's second argument (meta), when provided, must be an object.");if(t!==void 0&&(!Number.isFinite(t)||t<0))throw new TypeError("addAudioChunk's third argument (timestamp), when provided, must be a non-negative real number.");let o=new Uint8Array(a.byteLength);a.copyTo(o),this.addAudioChunkRaw(o,a.type,t??a.timestamp,a.duration,n)}addAudioChunkRaw(a,n,t,o,i){if(!(a instanceof Uint8Array))throw new TypeError("addAudioChunkRaw's first argument (data) must be an instance of Uint8Array.");if(n!=="key"&&n!=="delta")throw new TypeError("addAudioChunkRaw's second argument (type) must be either 'key' or 'delta'.");if(!Number.isFinite(t)||t<0)throw new TypeError("addAudioChunkRaw's third argument (timestamp) must be a non-negative real number.");if(!Number.isFinite(o)||o<0)throw new TypeError("addAudioChunkRaw's fourth argument (duration) must be a non-negative real number.");if(i&&typeof i!="object")throw new TypeError("addAudioChunkRaw's fifth argument (meta), when provided, must be an object.");if(Re(this,Yo,Ni).call(this),!U(this,Se).audio)throw new Error("No audio track declared.");if(typeof U(this,Se).fastStart=="object"&&U(this,ot).samples.length===U(this,Se).fastStart.expectedAudioChunks)throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${U(this,Se).fastStart.expectedAudioChunks}).`);let r=Re(this,Jo,Ci).call(this,U(this,ot),a,n,t,o,i);if(U(this,Se).fastStart==="fragmented"&&U(this,it)){for(;U(this,dn).length>0&&U(this,dn)[0].decodeTimestamp<=r.decodeTimestamp;){let s=U(this,dn).shift();Re(this,At,Jt).call(this,U(this,it),s)}r.decodeTimestamp<=U(this,it).lastDecodeTimestamp?Re(this,At,Jt).call(this,U(this,ot),r):U(this,un).push(r)}else Re(this,At,Jt).call(this,U(this,ot),r)}finalize(){if(U(this,co))throw new Error("Cannot finalize a muxer more than once.");if(U(this,Se).fastStart==="fragmented"){for(let n of U(this,dn))Re(this,At,Jt).call(this,U(this,it),n);for(let n of U(this,un))Re(this,At,Jt).call(this,U(this,ot),n);Re(this,ca,or).call(this,!1)}else U(this,it)&&Re(this,uo,la).call(this,U(this,it)),U(this,ot)&&Re(this,uo,la).call(this,U(this,ot));let a=[U(this,it),U(this,ot)].filter(Boolean);if(U(this,Se).fastStart==="in-memory"){let n;for(let o=0;o<2;o++){let i=Xo(a,U(this,Tn)),r=U(this,_e).measureBox(i);n=U(this,_e).measureBox(U(this,xt));let s=U(this,_e).pos+r+n;for(let l of U(this,Mn)){l.offset=s;for(let{data:c}of l.samples)s+=c.byteLength,n+=c.byteLength}if(s<2**32)break;n>=2**32&&(U(this,xt).largeSize=!0)}let t=Xo(a,U(this,Tn));U(this,_e).writeBox(t),U(this,xt).size=n,U(this,_e).writeBox(U(this,xt));for(let o of U(this,Mn))for(let i of o.samples)U(this,_e).write(i.data),i.data=null}else if(U(this,Se).fastStart==="fragmented"){let n=U(this,_e).pos,t=Zp(a);U(this,_e).writeBox(t);let o=U(this,_e).pos-n;U(this,_e).seek(U(this,_e).pos-4),U(this,_e).writeU32(o)}else{let n=U(this,_e).offsets.get(U(this,xt)),t=U(this,_e).pos-n;U(this,xt).size=t,U(this,xt).largeSize=t>=2**32,U(this,_e).patchBox(U(this,xt));let o=Xo(a,U(this,Tn));if(typeof U(this,Se).fastStart=="object"){U(this,_e).seek(U(this,sa)),U(this,_e).writeBox(o);let i=n-U(this,_e).pos;U(this,_e).writeBox(ip(i))}else U(this,_e).writeBox(o)}Re(this,$n,go).call(this),U(this,_e).finalize(),at(this,co,!0)}};Se=new WeakMap;_e=new WeakMap;sa=new WeakMap;xt=new WeakMap;it=new WeakMap;ot=new WeakMap;Tn=new WeakMap;Mn=new WeakMap;Qi=new WeakMap;dn=new WeakMap;un=new WeakMap;co=new WeakMap;Ei=new WeakSet;vl=function(a){if(typeof a!="object")throw new TypeError("The muxer requires an options object to be passed to its constructor.");if(!(a.target instanceof ga))throw new TypeError("The target must be provided and an instance of Target.");if(a.video){if(!of.includes(a.video.codec))throw new TypeError(`Unsupported video codec: ${a.video.codec}`);if(!Number.isInteger(a.video.width)||a.video.width<=0)throw new TypeError(`Invalid video width: ${a.video.width}. Must be a positive integer.`);if(!Number.isInteger(a.video.height)||a.video.height<=0)throw new TypeError(`Invalid video height: ${a.video.height}. Must be a positive integer.`);const n=a.video.rotation;if(typeof n=="number"&&![0,90,180,270].includes(n))throw new TypeError(`Invalid video rotation: ${n}. Has to be 0, 90, 180 or 270.`);if(Array.isArray(n)&&(n.length!==9||n.some(t=>typeof t!="number")))throw new TypeError(`Invalid video transformation matrix: ${n.join()}`);if(a.video.frameRate!==void 0&&(!Number.isInteger(a.video.frameRate)||a.video.frameRate<=0))throw new TypeError(`Invalid video frame rate: ${a.video.frameRate}. Must be a positive integer.`)}if(a.audio){if(!af.includes(a.audio.codec))throw new TypeError(`Unsupported audio codec: ${a.audio.codec}`);if(!Number.isInteger(a.audio.numberOfChannels)||a.audio.numberOfChannels<=0)throw new TypeError(`Invalid number of audio channels: ${a.audio.numberOfChannels}. Must be a positive integer.`);if(!Number.isInteger(a.audio.sampleRate)||a.audio.sampleRate<=0)throw new TypeError(`Invalid audio sample rate: ${a.audio.sampleRate}. Must be a positive integer.`)}if(a.firstTimestampBehavior&&!sf.includes(a.firstTimestampBehavior))throw new TypeError(`Invalid first timestamp behavior: ${a.firstTimestampBehavior}`);if(typeof a.fastStart=="object"){if(a.video){if(a.fastStart.expectedVideoChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedVideoChunks'.");if(!Number.isInteger(a.fastStart.expectedVideoChunks)||a.fastStart.expectedVideoChunks<0)throw new TypeError("'expectedVideoChunks' must be a non-negative integer.")}if(a.audio){if(a.fastStart.expectedAudioChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedAudioChunks'.");if(!Number.isInteger(a.fastStart.expectedAudioChunks)||a.fastStart.expectedAudioChunks<0)throw new TypeError("'expectedAudioChunks' must be a non-negative integer.")}}else if(![!1,"in-memory","fragmented"].includes(a.fastStart))throw new TypeError("'fastStart' option must be false, 'in-memory', 'fragmented' or an object.");if(a.minFragmentDuration!==void 0&&(!Number.isFinite(a.minFragmentDuration)||a.minFragmentDuration<0))throw new TypeError("'minFragmentDuration' must be a non-negative number.")};Vi=new WeakSet;gl=function(){var a;if(U(this,_e).writeBox(ap({holdsAvc:((a=U(this,Se).video)==null?void 0:a.codec)==="avc",fragmented:U(this,Se).fastStart==="fragmented"})),at(this,sa,U(this,_e).pos),U(this,Se).fastStart==="in-memory")at(this,xt,wi(!1));else if(U(this,Se).fastStart!=="fragmented"){if(typeof U(this,Se).fastStart=="object"){let n=Re(this,er,yl).call(this);U(this,_e).seek(U(this,_e).pos+n)}at(this,xt,wi(!0)),U(this,_e).writeBox(U(this,xt))}Re(this,$n,go).call(this)};er=new WeakSet;yl=function(){if(typeof U(this,Se).fastStart!="object")return;let a=0,n=[U(this,Se).fastStart.expectedVideoChunks,U(this,Se).fastStart.expectedAudioChunks];for(let t of n)t&&(a+=8*Math.ceil(2/3*t),a+=4*t,a+=12*Math.ceil(2/3*t),a+=4*t,a+=8*t);return a+=4096,a};Si=new WeakSet;wl=function(){if(U(this,Se).video&&at(this,it,{id:1,info:{type:"video",codec:U(this,Se).video.codec,width:U(this,Se).video.width,height:U(this,Se).video.height,rotation:U(this,Se).video.rotation??0,decoderConfig:null},timescale:U(this,Se).video.frameRate??57600,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),U(this,Se).audio&&(at(this,ot,{id:U(this,Se).video?2:1,info:{type:"audio",codec:U(this,Se).audio.codec,numberOfChannels:U(this,Se).audio.numberOfChannels,sampleRate:U(this,Se).audio.sampleRate,decoderConfig:null},timescale:U(this,Se).audio.sampleRate,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),U(this,Se).audio.codec==="aac")){let a=Re(this,tr,bl).call(this,2,U(this,Se).audio.sampleRate,U(this,Se).audio.numberOfChannels);U(this,ot).info.decoderConfig={codec:U(this,Se).audio.codec,description:a,numberOfChannels:U(this,Se).audio.numberOfChannels,sampleRate:U(this,Se).audio.sampleRate}}};tr=new WeakSet;bl=function(a,n,t){let i=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350].indexOf(n),r=t,s="";s+=a.toString(2).padStart(5,"0"),s+=i.toString(2).padStart(4,"0"),i===15&&(s+=n.toString(2).padStart(24,"0")),s+=r.toString(2).padStart(4,"0");let l=Math.ceil(s.length/8)*8;s=s.padEnd(l,"0");let c=new Uint8Array(s.length/8);for(let d=0;d<s.length;d+=8)c[d/8]=parseInt(s.slice(d,d+8),2);return c};Jo=new WeakSet;Ci=function(a,n,t,o,i,r,s){let l=o/1e6,c=(o-(s??0))/1e6,d=i/1e6,u=Re(this,nr,kl).call(this,l,c,a);return l=u.presentationTimestamp,c=u.decodeTimestamp,r!=null&&r.decoderConfig&&(a.info.decoderConfig===null?a.info.decoderConfig=r.decoderConfig:Object.assign(a.info.decoderConfig,r.decoderConfig)),{presentationTimestamp:l,decodeTimestamp:c,duration:d,data:n,size:n.byteLength,type:t,timescaleUnitsToNextSample:Pt(d,a.timescale)}};At=new WeakSet;Jt=function(a,n){U(this,Se).fastStart!=="fragmented"&&a.samples.push(n);const t=Pt(n.presentationTimestamp-n.decodeTimestamp,a.timescale);if(a.lastTimescaleUnits!==null){let i=Pt(n.decodeTimestamp,a.timescale,!1),r=Math.round(i-a.lastTimescaleUnits);if(a.lastTimescaleUnits+=r,a.lastSample.timescaleUnitsToNextSample=r,U(this,Se).fastStart!=="fragmented"){let s=aa(a.timeToSampleTable);s.sampleCount===1?(s.sampleDelta=r,s.sampleCount++):s.sampleDelta===r?s.sampleCount++:(s.sampleCount--,a.timeToSampleTable.push({sampleCount:2,sampleDelta:r}));const l=aa(a.compositionTimeOffsetTable);l.sampleCompositionTimeOffset===t?l.sampleCount++:a.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t})}}else a.lastTimescaleUnits=0,U(this,Se).fastStart!=="fragmented"&&(a.timeToSampleTable.push({sampleCount:1,sampleDelta:Pt(n.duration,a.timescale)}),a.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t}));a.lastSample=n;let o=!1;if(!a.currentChunk)o=!0;else{let i=n.presentationTimestamp-a.currentChunk.startTimestamp;if(U(this,Se).fastStart==="fragmented"){let r=U(this,it)??U(this,ot);const s=U(this,Se).minFragmentDuration??1;a===r&&n.type==="key"&&i>=s&&(o=!0,Re(this,ca,or).call(this))}else o=i>=.5}o&&(a.currentChunk&&Re(this,uo,la).call(this,a),a.currentChunk={startTimestamp:n.presentationTimestamp,samples:[]}),a.currentChunk.samples.push(n)};nr=new WeakSet;kl=function(a,n,t){var s,l;const o=U(this,Se).firstTimestampBehavior==="strict",i=t.lastDecodeTimestamp===-1;if(o&&i&&n!==0)throw new Error(`The first chunk for your media track must have a timestamp of 0 (received DTS=${n}).Non-zero first timestamps are often caused by directly piping frames or audio data from a MediaStreamTrack into the encoder. Their timestamps are typically relative to the age of thedocument, which is probably what you want.
|
|
19
|
-
|
|
20
|
-
If you want to offset all timestamps of a track such that the first one is zero, set firstTimestampBehavior: 'offset' in the options.
|
|
21
|
-
`);if(U(this,Se).firstTimestampBehavior==="offset"||U(this,Se).firstTimestampBehavior==="cross-track-offset"){t.firstDecodeTimestamp===void 0&&(t.firstDecodeTimestamp=n);let c;U(this,Se).firstTimestampBehavior==="offset"?c=t.firstDecodeTimestamp:c=Math.min(((s=U(this,it))==null?void 0:s.firstDecodeTimestamp)??1/0,((l=U(this,ot))==null?void 0:l.firstDecodeTimestamp)??1/0),n-=c,a-=c}if(n<t.lastDecodeTimestamp)throw new Error(`Timestamps must be monotonically increasing (DTS went from ${t.lastDecodeTimestamp*1e6} to ${n*1e6}).`);return t.lastDecodeTimestamp=n,{presentationTimestamp:a,decodeTimestamp:n}};uo=new WeakSet;la=function(a){if(U(this,Se).fastStart==="fragmented")throw new Error("Can't finalize individual chunks if 'fastStart' is set to 'fragmented'.");if(a.currentChunk){if(a.finalizedChunks.push(a.currentChunk),U(this,Mn).push(a.currentChunk),(a.compactlyCodedChunkTable.length===0||aa(a.compactlyCodedChunkTable).samplesPerChunk!==a.currentChunk.samples.length)&&a.compactlyCodedChunkTable.push({firstChunk:a.finalizedChunks.length,samplesPerChunk:a.currentChunk.samples.length}),U(this,Se).fastStart==="in-memory"){a.currentChunk.offset=0;return}a.currentChunk.offset=U(this,_e).pos;for(let n of a.currentChunk.samples)U(this,_e).write(n.data),n.data=null;Re(this,$n,go).call(this)}};ca=new WeakSet;or=function(a=!0){if(U(this,Se).fastStart!=="fragmented")throw new Error("Can't finalize a fragment unless 'fastStart' is set to 'fragmented'.");let n=[U(this,it),U(this,ot)].filter(l=>l&&l.currentChunk);if(n.length===0)return;let t=tp(this,Qi)._++;if(t===1){let l=Xo(n,U(this,Tn),!0);U(this,_e).writeBox(l)}let o=U(this,_e).pos,i=os(t,n);U(this,_e).writeBox(i);{let l=wi(!1),c=0;for(let u of n)for(let m of u.currentChunk.samples)c+=m.size;let d=U(this,_e).measureBox(l)+c;d>=2**32&&(l.largeSize=!0,d=U(this,_e).measureBox(l)+c),l.size=d,U(this,_e).writeBox(l)}for(let l of n){l.currentChunk.offset=U(this,_e).pos,l.currentChunk.moofOffset=o;for(let c of l.currentChunk.samples)U(this,_e).write(c.data),c.data=null}let r=U(this,_e).pos;U(this,_e).seek(U(this,_e).offsets.get(i));let s=os(t,n);U(this,_e).writeBox(s),U(this,_e).seek(r);for(let l of n)l.finalizedChunks.push(l.currentChunk),U(this,Mn).push(l.currentChunk),l.currentChunk=null;a&&Re(this,$n,go).call(this)};$n=new WeakSet;go=function(){U(this,_e)instanceof qi&&U(this,_e).flush()};Yo=new WeakSet;Ni=function(){if(U(this,co))throw new Error("Cannot add new video or audio chunks after the file has been finalized.")};const ho=30;class Dn extends Error{constructor({message:t="",code:o=""},...i){super(t,...i);L(this,"message");L(this,"code");this.code=o,this.message=t}}class Kt extends Dn{}class Ye extends Dn{}class da extends Dn{}class as extends Dn{}function lf(a,n=ho){if(n<1)throw new Ye({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(a*n)}function Bn(a,n=ho){if(n<1)throw new Ye({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(a/n*1e3)}class ge{constructor(n=0){L(this,"time");this.time=Math.round(n)}get millis(){return this.time}set millis(n){this.time=Math.round(n)}get frames(){return lf(this.millis/1e3)}set frames(n){this.millis=Bn(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=Bn(n);return this.millis=this.millis+t,this}add(n){return new ge(n.millis+this.millis)}subtract(n){return new ge(this.millis-n.millis)}static fromSeconds(n){const t=new ge;return t.millis=n*1e3,t}static fromFrames(n,t){const o=new ge;return o.millis=Bn(n,t),o}copy(){return new ge(this.millis)}toJSON(){return this.millis}static fromJSON(n){return new ge(n)}}function is(a,n){return[a.slice(0,n),a.slice(n)].filter(t=>t.length>0)}function Ko(a,n){return n?Math.floor(Math.random()*(n-a+1)+a):a}function cf(a,n,t){t<0&&(t=0);const o=a[n];a.splice(n,1),a.splice(t,0,o)}function rs(a){return typeof a!="function"?!1:/^class\s/.test(Function.prototype.toString.call(a))}function df(a){const n=a.numberOfChannels,t=a.length,o=new Int16Array(t*n);for(let i=0;i<t;i++)for(let r=0;r<n;r++){let s=a.getChannelData(r)[i]*32767;s>32767&&(s=32767),s<-32767&&(s=-32767),o[i*n+r]=s}return o}function uf(a,n=44100,t=2){if(a.sampleRate==n&&a.numberOfChannels==t)return a;const o=Math.floor(a.duration*n),i=new OfflineAudioContext(t,1,n).createBuffer(t,o,n);for(let r=0;r<a.numberOfChannels;r++){const s=a.getChannelData(r),l=i.getChannelData(r),c=a.sampleRate/n;for(let d=0;d<l.length;d++){const u=d*c,m=Math.floor(u),p=Math.ceil(u);if(p>=s.length)l[d]=s[m];else{const h=u-m;l[d]=s[m]*(1-h)+s[p]*h}}}return i}async function mf(a){const{fps:n,height:t,width:o,bitrate:i}=a,r=["avc1.640034","avc1.4d0034","avc1.640028","avc1.640C32","avc1.64001f","avc1.42001E"],s=["prefer-hardware","prefer-software"],l=[];for(const d of r)for(const u of s)l.push({codec:d,hardwareAcceleration:u,width:o,height:t,bitrate:i,framerate:n});const c=[];if(!("VideoEncoder"in window))return c;for(const d of l){const u=await VideoEncoder.isConfigSupported(d);u.supported&&c.push(u.config??d)}return c.sort(pf)}function pf(a,n){const t=a.hardwareAcceleration??"",o=n.hardwareAcceleration??"";return t<o?-1:t>o?1:0}async function ff(a,n="untitled"){const t=document.createElement("a");if(document.head.appendChild(t),t.download=n,typeof a=="string"&&a.startsWith("data:image/svg+xml;base64,")){const o=a.split(",")[1],i=atob(o),r=new Array(i.length);for(let c=0;c<i.length;c++)r[c]=i.charCodeAt(c);const s=new Uint8Array(r),l=new Blob([s],{type:"image/svg+xml"});t.href=URL.createObjectURL(l),t.download=n.split(".")[0]+".svg"}else typeof a=="string"?t.href=a:t.href=URL.createObjectURL(a);t.click(),t.remove()}function ss(a){return`${a.hours.toString().padStart(2,"0")}:${a.minutes.toString().padStart(2,"0")}:${a.seconds.toString().padStart(2,"0")},`+a.milliseconds.toString().padStart(3,"0")}function ls(a){const n=new Date(1970,0,1);return n.setSeconds(a),n.setMilliseconds(Math.round(a%1*1e3)),{hours:n.getHours(),minutes:n.getMinutes(),seconds:n.getSeconds(),milliseconds:n.getMilliseconds()}}class Uo{constructor(n){L(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 ge}get stop(){var n;return((n=this.words.at(-1))==null?void 0:n.stop)??new ge}}var _i=(a=>(a.en="en",a.de="de",a))(_i||{});class cs{constructor(n,t,o,i){L(this,"id",crypto.randomUUID());L(this,"text");L(this,"start");L(this,"stop");L(this,"confidence");this.text=n,this.start=new ge(t),this.stop=new ge(o),this.confidence=i}get duration(){return this.stop.subtract(this.start)}}class pn{constructor(n=[],t=_i.en){L(this,"id",crypto.randomUUID());L(this,"language",_i.en);L(this,"groups",[]);this.groups=n,this.language=t}get text(){return this.groups.map(({text:n})=>n).join(" ")}get words(){return this.groups.flatMap(({words:n})=>n)}*iter({count:n,duration:t,length:o}){for(const i of this.groups){let r;for(const[s,l]of i.words.entries())r&&(n&&r.words.length>=Ko(...n)?(yield r,r=void 0):t&&(r==null?void 0:r.duration.seconds)>=Ko(...t)?(yield r,r=void 0):o&&r.text.length>=Ko(...o)&&(yield r,r=void 0)),r?r.words.push(l):r=new Uo([l]),s==i.words.length-1&&(yield r)}}optimize(){const n=this.groups.flatMap(t=>t.words);for(let t=0;t<n.length-1;t++){const o=n[t],i=n[t+1];i.start.millis-o.stop.millis<0?i.start.millis=o.stop.millis+1:o.stop.millis=i.start.millis-1}return this}toSRT(n={}){let t=1,o="";for(const i of this.iter(n)){const r=ls(i.start.seconds),s=ls(i.stop.seconds);o+=`${t}
|
|
22
|
-
`+ss(r)+" --> "+ss(s)+`
|
|
23
|
-
${i.text}
|
|
24
|
-
|
|
25
|
-
`,t+=1}return{text:o,blob:new Blob([o],{type:"text/plain;charset=utf8"})}}toJSON(){return this.groups.map(n=>n.words.map(t=>({token:t.text,start:t.start.millis,stop:t.stop.millis})))}slice(n,t=!0){let o=0;const i=[];for(const r of this.groups)for(const s of r.words)if(i.length==0&&t&&(o=s.start.millis),i.push(new cs(s.text,s.start.millis-o,s.stop.millis-o)),i.length==n)return new pn([new Uo(i)]);return new pn([new Uo(i)])}copy(){return pn.fromJSON(this.toJSON())}static fromJSON(n){const t=new pn;for(const o of n){const i=new Uo;for(const r of o)i.words.push(new cs(r.token,r.start,r.stop));t.groups.push(i)}return t}static async from(n,t){const o=await fetch(n,t);if(!o.ok)throw new Kt({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});return pn.fromJSON(await o.json())}}function qo(a,n,t){return a+(n-a)*t}function hf(a,n,t){const o=Number.parseInt(a.slice(1),16),i=Number.parseInt(n.slice(1),16),r=o>>16&255,s=o>>8&255,l=o&255,c=i>>16&255,d=i>>8&255,u=i&255,m=Math.round(qo(r,c,t)),p=Math.round(qo(s,d,t)),h=Math.round(qo(l,u,t));return`#${((1<<24)+(m<<16)+(p<<8)+h).toString(16).slice(1)}`}const vf={linear:a=>a,easeIn:a=>a*a,easeOut:a=>a*(2-a),easeInOut:a=>a<.5?2*a*a:-1+(4-2*a)*a};class Ee{constructor(n,t,o={}){L(this,"input");L(this,"output");L(this,"options");if(n.length!==t.length)throw new Ye({code:"invalidKeyframes",message:"inputRange and outputRange must have the same length"});this.input=n.map(i=>Bn(i)),this.output=t,this.options={extrapolate:"clamp",easing:"linear",type:"number",...JSON.parse(JSON.stringify(o))}}normalize(n){const{input:t}=this;if(n<t[0])return this.options.extrapolate==="clamp"?{t:0,segment:0}:{t:(n-t[0])/(t[1]-t[0]),segment:0};if(n>t[t.length-1])return this.options.extrapolate==="clamp"?{t:1,segment:t.length-2}:{t:(n-t[t.length-2])/(t[t.length-1]-t[t.length-2]),segment:t.length-2};for(let o=0;o<t.length-1;o++){const i=t[o],r=t[o+1];if(n>=i&&n<=r)return{t:(n-i)/(r-i),segment:o}}return{t:0,segment:0}}interpolate(n,t){const o=this.output[t],i=this.output[t+1],r=vf[this.options.easing](n);if(typeof o=="number"&&typeof i=="number")return qo(o,i,r);if(typeof o=="string"&&typeof i=="string")return hf(o,i,r);if(this.output.length==1)return this.output[0];throw new Ye({code:"invalidKeyframes",message:"Unsupported output range types"})}value(n){const{t,segment:o}=this.normalize(typeof n=="number"?n:n.millis);return this.interpolate(t,o)}push(n,t){return this.input.push(Bn(n)),this.output.push(t),this}toJSON(){return this}static fromJSON(n){const t=new Ee([],[]);return Object.assign(t,n),t}}class _t{constructor(){L(this,"id",crypto.randomUUID())}toJSON(){const n={};return(this.constructor.__serializableProperties||[]).forEach(({propertyKey:t,serializer:o})=>{const i=this[t];o&&i instanceof o?n[t]=i.toJSON():n[t]=i}),n}static fromJSON(n){const t=new this;return(this.__serializableProperties||[]).forEach(({propertyKey:o,serializer:i})=>{if(n.hasOwnProperty(o))if(i){const r=i.fromJSON(n[o]);t[o]=r}else t[o]=n[o]}),t}}function he(a){return function(n,t){n.constructor.__serializableProperties||(n.constructor.__serializableProperties=[]),n.constructor.__serializableProperties.push({propertyKey:t,serializer:a})}}function yo(a){return class extends a{constructor(){super(...arguments);L(this,"_handlers",{})}on(t,o){if(typeof o!="function")throw new Error("The callback of an event listener needs to be a function.");const i=crypto.randomUUID();return this._handlers[t]?this._handlers[t][i]=o:this._handlers[t]={[i]:o},i}off(t,...o){if(t){if(t==="*"){this._handlers={};return}for(const i of Object.values(this._handlers))t in i&&delete i[t];for(const i of o)this.off(i)}}trigger(t,o){var r,s;const i=new CustomEvent(t,{detail:o});Object.defineProperty(i,"currentTarget",{writable:!1,value:this});for(const l in this._handlers[t]??{})(r=this._handlers[t])==null||r[l](i);for(const l in this._handlers["*"]??{})(s=this._handlers["*"])==null||s[l](i)}bubble(t){return this.on("*",o=>{t.trigger(o.type,o.detail)})}resolve(t){return(o,i)=>{this.on("error",i),this.on(t,o)}}}}function ar(a,n,t=0){if(!(a instanceof Le.Container||a instanceof Le.Filter||t==3))for(const o in a){const i=a[o];o&&(i instanceof Ee&&(a[o]=i.value(n)),i!=null&&typeof i=="object"&&Object.keys(i).length&&ar(i,n,t+1))}}var gf=Object.defineProperty,ya=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&gf(n,t,i),i};const wo=class El extends yo(_t){constructor(t={}){super();L(this,"_name");L(this,"_start",new ge);L(this,"_stop",ge.fromSeconds(16));L(this,"type","base");L(this,"source");L(this,"view",new Le.Container);L(this,"createdAt",new Date);L(this,"disabled",!1);L(this,"state","IDLE");L(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",ge.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=ge.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new Ye({code:"splitOutOfRange",message:"Cannot split clip at the specified time"});if(!this.track)throw new Ye({code:"trackNotAttached",message:"Track must be attached to a track"});const o=this.copy();this.stop=t.copy(),o.start=t.copy().addMillis(1),ar(o,o.start.subtract(this.start));const i=this.track.clips.findIndex(l=>l.id==this.id);return await this.track.add(o,i+1),o}copy(){return El.fromJSON(JSON.parse(JSON.stringify(this)))}set(t){return t&&Object.assign(this,t),this.trigger("update",void 0),this}};ya([he()],wo.prototype,"_name");ya([he(ge)],wo.prototype,"_start");ya([he(ge)],wo.prototype,"_stop");ya([he()],wo.prototype,"disabled");let bo=wo;var yf=Object.defineProperty,bn=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&yf(n,t,i),i};class Wt extends yo(_t){constructor(){super(...arguments);L(this,"state","IDLE");L(this,"metadata");L(this,"objectURL");L(this,"duration",ge.fromSeconds(16));L(this,"added",!1);L(this,"type","base");L(this,"name","");L(this,"mimeType");L(this,"externalURL");L(this,"external",!1);L(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 Ye({code:"fileNotAccessible",message:"The desired file cannot be accessed"});return this.file}async loadFile(t){this.name=t.name,this.mimeType=Ii(t.type),this.external=!1,this.file=t}async loadUrl(t,o){const i=await fetch(t,o);if(!(i!=null&&i.ok))throw new Kt({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=Ii(r.type)}async from(t,o){try{this.state="LOADING",t instanceof File?await this.loadFile(t):await this.loadUrl(t,o),this.state="READY",this.trigger("load",void 0)}catch(i){throw this.state=="ERROR",this.trigger("error",new Error(String(i))),i}return this}async arrayBuffer(){return await(await this.getFile()).arrayBuffer()}async remove(){this.state="IDLE",this.objectURL&&(URL.revokeObjectURL(this.objectURL),this.objectURL=void 0),delete this.file}async download(){const t=await this.getFile();ff(t,this.name)}async thumbnail(){return document.createElement("div")}static async from(t,o,i=new this){return i.from(t,o)}}bn([he()],Wt.prototype,"objectURL");bn([he()],Wt.prototype,"duration");bn([he()],Wt.prototype,"type");bn([he()],Wt.prototype,"name");bn([he()],Wt.prototype,"mimeType");bn([he()],Wt.prototype,"externalURL");bn([he()],Wt.prototype,"external");const ds="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E";function wf(a){const n=new TextEncoder().encode(a);let t="";const o=n.byteLength;for(let i=0;i<o;i++)t+=String.fromCharCode(n[i]);return btoa(t)}function us(a){if(!a||!a.body)return ds;const n=a.body.scrollWidth,t=a.body.scrollHeight,o=a.cloneNode(!0),i=o.getElementsByTagName("style").item(0),r=o.getElementsByTagName("body").item(0);if(r==null||r.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),!r)return ds;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,"+wf(d)}class ms extends Wt{constructor(){super();L(this,"type","html");L(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=us(this.document),this.objectURL)}async loadUrl(t,o){await super.loadUrl(t,o),this.iframe.setAttribute("src",URL.createObjectURL(this.file)),await new Promise((i,r)=>{this.iframe.onload=()=>i(),this.iframe.onerror=s=>r(s)})}async loadFile(t){await super.loadFile(t),this.iframe.setAttribute("src",URL.createObjectURL(this.file)),await new Promise((o,i)=>{this.iframe.onload=()=>o(),this.iframe.onerror=r=>i(r)})}update(){this.objectURL&&(this.objectURL=us(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 bf(a,n={}){const{threshold:t=.02,hopSize:o=1024,minDuration:i=500}=n,r=[],s=a.getChannelData(0),l=a.sampleRate,c=Math.floor(i/1e3*l);let d=null,u=0;for(let m=0;m<s.length;m+=o){let p=0;const h=Math.min(m+o,s.length);for(let v=m;v<h;v++)p+=s[v]*s[v];p=Math.sqrt(p/(h-m)),p<t?(u+=o,d===null&&(d=m)):(d!==null&&u>=c&&r.push({start:ge.fromSeconds(d/l),stop:ge.fromSeconds(m/l)}),d=null,u=0)}return d!==null&&u>=c&&r.push({start:ge.fromSeconds(d/l),stop:ge.fromSeconds(s.length/l)}),r}const ii=3e3;class rn extends Wt{constructor(){super(...arguments);L(this,"type","audio");L(this,"decoding",!1);L(this,"_silences");L(this,"transcript");L(this,"audioBuffer")}async decode(t=2,o=48e3,i=!1){if(this.decoding&&i&&(await new Promise(this.resolve("update")),this.audioBuffer))return this.audioBuffer;this.decoding=!0;const r=await this.arrayBuffer(),s=await new OfflineAudioContext(t,1,o).decodeAudioData(r);return this.duration.seconds=s.duration,i&&(this.audioBuffer=s),this.decoding=!1,this.trigger("update",void 0),s}async samples(t=60,o=50,i=0){const r=this.audioBuffer??await this.decode(1,3e3,!0),s=Math.round(r.sampleRate/o),l=r.sampleRate*r.duration-s,c=Math.ceil(l/t),d=r.getChannelData(0),u=[];for(let m=0;m<l;m+=c){let p=0;for(let h=m;h<m+s;h++)p+=Math.abs(d[m]);u.push(Math.log1p(p/s*100))}return u.map(m=>Math.round(m/Math.max(...u)*(100-i))+i)}async fastsampler({length:t=60,start:o=0,stop:i,logarithmic:r=!1}={}){typeof o=="object"&&(o=o.millis),typeof i=="object"&&(i=i.millis);const s=this.audioBuffer??await this.decode(1,ii,!0),l=s.getChannelData(0),c=Math.floor(Math.max(o*ii/1e3,0)),d=i?Math.floor(Math.min(i*ii/1e3,s.length)):s.length,u=Math.floor((d-c)/t),m=new Float32Array(t);for(let p=0;p<t;p++){const h=c+p*u,v=h+u;let y=-1/0;for(let E=h;E<v;E++){const _=l[E];_>y&&(y=_)}m[p]=r?Math.log2(1+y):y}return m}async thumbnail(...t){const o=await this.samples(...t),i=document.createElement("div");i.className="flex flex-row absolute space-between inset-0 audio-samples";for(const r of o){const s=document.createElement("div");s.className="audio-sample-item",s.style.height=`${r}%`,i.appendChild(s)}return i}async silences(t={}){if(this._silences)return this._silences;const o=await this.arrayBuffer(),i=new AudioContext,r=await i.decodeAudioData(o);return this._silences=bf(r,t),i.close(),this._silences}}class Ti extends Wt{constructor(){super(...arguments);L(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 fn extends rn{constructor(){super(...arguments);L(this,"type","video");L(this,"downloadInProgress",!0)}async loadUrl(t,o){const i=await fetch(t,o);if(!(i!=null&&i.ok))throw new Kt({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=Ii(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 Ye({code:"fileNotAccessible",message:"The desired file cannot be accessed"});return this.file}async thumbnail(){const t=document.createElement("video");return t.className="object-cover w-full aspect-video h-auto",t.controls=!1,t.addEventListener("loadedmetadata",()=>{this.duration.seconds=t.duration,this.trigger("update",void 0)}),t.addEventListener("mousemove",o=>{const i=o.currentTarget,r=i==null?void 0:i.getBoundingClientRect(),s=o.clientX-((r==null?void 0:r.left)??0),l=i==null?void 0:i.duration;l&&r&&r.width>0&&(i.currentTime=Math.round(l*(s/r.width)))}),t.src=await this.createObjectURL(),t}async getBlob(t){try{this.downloadInProgress=!0;const o=await t.blob();this.file=new File([o],this.name,{type:o.type}),this.trigger("load",void 0)}catch(o){this.state=="ERROR",this.trigger("error",new Error(String(o)))}finally{this.downloadInProgress=!1}}}class kf{static fromJSON(n){return[new ge(n[0]),new ge(n[1])]}}var xf=Object.defineProperty,Ef=Object.getOwnPropertyDescriptor,On=(a,n,t,o)=>{for(var i=o>1?void 0:o?Ef(n,t):n,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=(o?s(n,t,i):s(i))||i);return o&&i&&xf(n,t,i),i};const kn=class Vl extends bo{constructor(t={}){super();L(this,"source",new rn);L(this,"_offset",new ge);L(this,"playing",!1);L(this,"duration",new ge);L(this,"range",[new ge,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=ge.fromFrames(t));const o=t.subtract(this.offset);o.millis>=0&&o.millis<this.range[1].millis?this.range[0].millis=o.millis:o.millis<0?this.range[0].millis=0:this.range[0].millis=this.range[1].millis-1,this.trigger("frame",void 0)}set stop(t){typeof t=="number"&&(t=ge.fromFrames(t));const o=t.subtract(this.offset);o.millis>this.range[0].millis&&o.millis<=this.duration.millis?this.range[1]=o:o.millis>this.duration.millis?this.range[1]=this.duration:this.range[1].millis=this.range[0].millis+1,this.trigger("frame",void 0)}get offset(){return this._offset}set offset(t){typeof t=="number"?this._offset.frames=t:this._offset=t,this.trigger("frame",this.offset.frames)}offsetBy(t){return typeof t=="number"?(this.offset.addFrames(t),this.trigger("offsetBy",ge.fromFrames(t))):(this.offset.addMillis(t.millis),this.trigger("offsetBy",t)),this.trigger("frame",void 0),this}get muted(){var t;return((t=this.element)==null?void 0:t.muted)??!1}set muted(t){this.element&&(this.element.muted=t)}seek(t){return new Promise((o,i)=>{if(!this.element)return i(new as({code:"elementNotDefined",message:"Cannot seek on undefined element"}));(t.millis<this.start.millis||t.millis>this.stop.millis)&&(t=this.start),this.element.onerror=()=>{var r;return i((r=this.element)==null?void 0:r.error)},this.element.pause(),this.element.currentTime=t.subtract(this.offset).seconds,this.element.onseeked=()=>o()})}subclip(t,o){if(t||(t=this.range[0]),o||(o=this.range[1]),typeof t=="number"&&(t=ge.fromFrames(t)),typeof o=="number"&&(o=ge.fromFrames(o)),t.millis>=o.millis)throw new Ye({code:"invalidKeyframe",message:"Start can't lower than or equal the stop"});return t.millis<0&&(this.range[0].millis=0,t=this.range[0]),o.millis>this.duration.millis&&this.duration.millis&&(o=this.duration),this.range=[t,o],this.trigger("frame",void 0),this}get volume(){var t;return((t=this.element)==null?void 0:t.volume)??1}set volume(t){this.element&&(this.element.volume=t)}copy(){const t=Vl.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=ge.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new Ye({code:"invalidKeyframe",message:"Cannot split clip at the specified time"});if(!this.track)throw new as({code:"trackNotDefined",message:"Clip must be attached to a track"});t=t.subtract(this.offset);const o=this.copy();this.range[1]=t.copy(),o.range[0]=t.copy().addMillis(1),ar(o,o.start.subtract(this.start));const i=this.track.clips.findIndex(l=>l.id==this.id);return await this.track.add(o,i+1),o}async addCaptions(t){var o;if(!((o=this.track)!=null&&o.composition))throw new Ye({code:"compositionNotDefined",message:"Captions can only be generated after the clip has been added to the composition"});return await this.track.composition.createTrack("caption").from(this).generate(t)}set(t){return super.set(t)}async generateCaptions(t){return this.addCaptions(t)}async removeSilences(t={}){["READY","ATTACHED"].includes(this.state)||await this.init();const o=(await this.source.silences(t)).filter(s=>ps(s,this.range)).sort((s,l)=>s.start.millis-l.start.millis);if(o.length==0)return[this];const i=t.padding??500,r=[this];for(const s of o){const l=r.at(-1);if(!l)break;if(!ps(s,l.range))continue;const c=new ge(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}};On([he(ge)],kn.prototype,"_offset",2);On([he(ge)],kn.prototype,"duration",2);On([he(kf)],kn.prototype,"range",2);On([he(pn)],kn.prototype,"transcript",1);On([he()],kn.prototype,"muted",1);On([he()],kn.prototype,"volume",1);let wa=kn;function ps(a,n){return a.start.millis>=n[0].millis&&a.start.millis<=n[1].millis||a.stop.millis<=n[1].millis&&a.stop.millis>=n[0].millis}class Oo{static fromJSON(n){return typeof n=="object"?Ee.fromJSON(n):n}}class ri{static fromJSON(n){return typeof n.x=="object"&&(n.x=Ee.fromJSON(n.x)),typeof n.y=="object"&&(n.y=Ee.fromJSON(n.y)),n}}let Vf=class{constructor(a){L(this,"target");L(this,"animation");this.target=a}init(a,n,t=0,o){if(!(a in this.target))throw new Error(`Property [${String(a)}] cannot be assigned`);const i=[t],r=[n];typeof this.target[a]==typeof n&&t!=0&&(i.unshift(0),r.unshift(this.target[a])),this.target[a]=this.animation=new Ee(i,r,{easing:o})}};function Sf(a){const n=new Proxy(a,{get(t,o){return o=="to"?(i,r)=>{if(!t.animation)throw new Ye({code:"undefinedKeyframe",message:"Cannot use 'to() before selecting a property"});const s=new ge(t.animation.input.at(-1)).frames+r;return t.animation.push(s,i),n}:(i,r,s)=>(t.init(o,i,r,s),n)}});return n}class Cf extends Vf{}var Nf=Object.defineProperty,_f=Object.getOwnPropertyDescriptor,nn=(a,n,t,o)=>{for(var i=o>1?void 0:o?_f(n,t):n,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=(o?s(n,t,i):s(i))||i);return o&&i&&Nf(n,t,i),i};function ba(a){class n extends a{constructor(){super(...arguments);L(this,"filters");L(this,"_height");L(this,"_width");L(this,"_position",{x:this.view.position.x,y:this.view.position.y});L(this,"_scale");L(this,"rotation",this.view.angle);L(this,"alpha",1);L(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 Ee||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 Le.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 Le.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 Sf(new Cf(this))}}return nn([he(Oo)],n.prototype,"_height",2),nn([he(Oo)],n.prototype,"_width",2),nn([he(ri)],n.prototype,"_position",2),nn([he(ri)],n.prototype,"_scale",2),nn([he(Oo)],n.prototype,"rotation",2),nn([he(Oo)],n.prototype,"alpha",2),nn([he(ri)],n.prototype,"translate",2),nn([he()],n.prototype,"anchor",1),n}function ka(a,n,t){const o=t.value;return t.value=function(...i){var m,p,h,v;const r=i[0].subtract(this.start),s={width:((p=(m=this.track)==null?void 0:m.composition)==null?void 0:p.width)??1920,height:((v=(h=this.track)==null?void 0:h.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 y;typeof this._scale.x=="number"?y=this._scale.x:typeof this._scale.x=="function"?y=this._scale.x.bind(this)(r):y=this._scale.x.value(r);let E;typeof this._scale.y=="number"?E=this._scale.y:typeof this._scale.y=="function"?E=this._scale.y.bind(this)(r):E=this._scale.y.value(r),(this._width||this._height)&&(y*=this.view.scale._x,E*=this.view.scale._y),this.view.scale.set(y,E)}return typeof this.rotation=="number"?this.view.angle=this.rotation:typeof this.rotation=="function"?this.view.angle=this.rotation.bind(this)(r):this.view.angle=this.rotation.value(r),typeof this.alpha=="number"?this.view.alpha=this.alpha:typeof this.alpha=="function"?this.view.alpha=this.alpha.bind(this)(r):this.view.alpha=this.alpha.value(r),o.apply(this,i)},t}var Tf=Object.defineProperty,Mf=Object.getOwnPropertyDescriptor,Bf=(a,n,t,o)=>{for(var i=Mf(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Tf(n,t,i),i};const Sl=class Cl extends ba(bo){constructor(t,o={}){super();L(this,"type","image");L(this,"element",new Image);L(this,"source",new Ti);L(this,"sprite",new Le.Sprite);this.view.addChild(this.sprite),t instanceof Ti&&(this.source=t),t instanceof File&&this.source.from(t),Object.assign(this,o)}async init(){this.element.setAttribute("src",await this.source.createObjectURL()),await new Promise((t,o)=>{this.element.onload=()=>{this.sprite.texture=Le.Texture.from(this.element),this.state="READY",t()},this.element.onerror=i=>{this.state="ERROR",o(new Kt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=Cl.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};Bf([ka],Sl.prototype,"update");let If=Sl;const Ao={"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 Ff=Object.defineProperty,xa=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Ff(n,t,i),i};const ko=class Mi extends yo(_t){constructor(t){super();L(this,"loaded",!1);L(this,"family");L(this,"weight");L(this,"source");L(this,"style");t!=null&&t.source.startsWith("https://")&&(t.source=`url(${t.source})`),this.family=(t==null?void 0:t.family)??"Arial",this.source=t==null?void 0:t.source,this.style=t==null?void 0:t.style,this.weight=t==null?void 0:t.weight}get name(){return this.family+" "+(this.style??this.weight)}async load(){if(this.loaded||!this.source||!this.family)return this;const t=new FontFace(this.name,this.source);return this.weight&&(t.weight=this.weight),await new Promise(o=>{t.load().then(i=>{document.fonts.add(i),o(null)})}),this.loaded=!0,this.trigger("load",void 0),this}copy(){const t=Mi.fromJSON(JSON.parse(JSON.stringify(this)));return t.loaded=this.loaded,t}static async localFonts(){const t={};"queryLocalFonts"in window||Object.assign(window,{queryLocalFonts:()=>[]});for(const o of await window.queryLocalFonts()){if(o.family in t){t[o.family].push(o);continue}t[o.family]=[o]}return Object.keys(t).map(o=>({family:o,variants:t[o].map(i=>({family:o,style:i.style,source:`local('${i.fullName}'), local('${i.postscriptName}')`}))}))}static webFonts(){return Object.keys(Ao).map(t=>({family:t,variants:Ao[t].weights.map(o=>({family:t,source:`url(${Ao[t].url})`,weight:o}))}))}static fromFamily({family:t,weight:o}){return new Mi({family:t,source:`url(${Ao[t].url})`,weight:o})}};xa([he()],ko.prototype,"family");xa([he()],ko.prototype,"weight");xa([he()],ko.prototype,"source");xa([he()],ko.prototype,"style");let ct=ko;const zt=4,Nl={center:.5,justify:.5,left:0,right:1},_l={alphabetic:0,top:0,middle:.5,hanging:1,bottom:1,ideographic:1};var Rf=Object.defineProperty,$f=Object.getOwnPropertyDescriptor,yt=(a,n,t,o)=>{for(var i=$f(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Rf(n,t,i),i};const pt=class Tl extends ba(bo){constructor(t){super();L(this,"type","text");L(this,"_text","");L(this,"_textCase");L(this,"_anchor",{x:0,y:0});L(this,"_font",new ct);L(this,"style",new Le.TextStyle({fill:"#FFFFFF",fontFamily:this._font.family,fontSize:16}));this.style.padding=20,typeof t=="string"?(this.text=t,this.reflectUpdate()):t&&(Object.assign(this,t),this.reflectUpdate()),this.on("update",this.reflectUpdate.bind(this))}get text(){return this._text}set text(t){if(this._text=t,!this.view.children.length){const o=new Le.Text({text:this.transformedText,style:this.style,resolution:zt,scale:zt});this.view.addChild(o)}this.view.children[0]instanceof Le.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*zt}set maxWidth(t){t?(this.style.wordWrap=!0,this.style.wordWrapWidth=t/zt):this.style.wordWrap=!1}get textAlign(){return this.style.align}set textAlign(t){this.style.align=t,this.anchor.x=Nl[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=_l[t]}get fillStyle(){const{fill:t}=this.style;return new Le.Color(t.toString()).toHex().toUpperCase()}set fillStyle(t){this.style.fill=t}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor={x:t,y:t}:this._anchor=t}get stroke(){if(!this.style.stroke)return;let{color:t="#000000",alpha:o=1,width:i=3,join:r="round",miterLimit:s}=this.style.stroke;return t=new Le.Color(t).toHex().toUpperCase(),{color:t,alpha:o,width:i,join:r,miterLimit:s}}set stroke(t){if(!t){this.style.stroke=void 0;return}const{color:o="#000000",alpha:i=1,width:r=3,join:s="round",miterLimit:l}=t;this.style.stroke={color:o,alpha:i,width:r,join:s,miterLimit:l}}get textCase(){return this._textCase}set textCase(t){this._textCase=t,this.view.children[0]instanceof Le.Text&&this.transformedText&&(this.view.children[0].text=this.transformedText)}get shadow(){if(!this.style.dropShadow)return;const{alpha:t,angle:o,blur:i,color:r,distance:s}=this.style.dropShadow,l=new Le.Color(r).toHex().toUpperCase();return{alpha:t,angle:o,blur:i,color:l,distance:s}}set shadow(t){t?this.style.dropShadow=t:this.style.dropShadow=!1}get fontFamily(){return Array.isArray(this.style.fontFamily)?this.style.fontFamily[0]:this.style.fontFamily}get fontSize(){return this.style.fontSize}set fontSize(t){this.style.fontSize=t}get leading(){return this.style.leading}set leading(t){this.style.leading=t}update(t){}copy(){const t=Tl.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.font=this.font,t}get transformedText(){return this.textCase=="lower"?this._text.toLocaleLowerCase():this.textCase=="upper"?this._text.toUpperCase():this._text}reflectUpdate(){var r,s,l;const t=((r=this.view.children[0])==null?void 0:r.width)??0,o=((s=this.view.children[0])==null?void 0:s.height)??0,i=(((l=this.style.dropShadow)==null?void 0:l.distance)??0)*zt;this.view.pivot={x:(t-i)*this._anchor.x,y:(o-i)*this._anchor.y}}set(t){return super.set(t)}};yt([he()],pt.prototype,"text");yt([he(ct)],pt.prototype,"font");yt([he()],pt.prototype,"maxWidth");yt([he()],pt.prototype,"textAlign");yt([he()],pt.prototype,"padding");yt([he()],pt.prototype,"textBaseline");yt([he()],pt.prototype,"fillStyle");yt([he()],pt.prototype,"anchor");yt([he()],pt.prototype,"stroke");yt([he()],pt.prototype,"textCase");yt([he()],pt.prototype,"shadow");yt([he()],pt.prototype,"fontSize");yt([he()],pt.prototype,"leading");yt([ka],pt.prototype,"update");let An=pt;function si(a){const n=a.split(" ").map(t=>`${t} `);return n[n.length-1]=n[n.length-1].replace(/ $/,""),n}const Df={get(a,n){const t=a[n];return typeof t=="number"?t*zt:Array.isArray(t)&&typeof t[0]=="number"?t.map(o=>o*zt):t}};function Uf(a){return new Proxy(a,Df)}class Of{constructor(){L(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 fs{constructor(){L(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 Af{static fromJSON(n){return n.map(t=>(t.font&&(t.font=ct.fromJSON(t.font)),t))}}var Lf=Object.defineProperty,zf=Object.getOwnPropertyDescriptor,Ln=(a,n,t,o)=>{for(var i=o>1?void 0:o?zf(n,t):n,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=(o?s(n,t,i):s(i))||i);return o&&i&&Lf(n,t,i),i};const xn=class Ml extends An{constructor(t){super();L(this,"type","complex_text");L(this,"_maxWidth");L(this,"_textAlign","left");L(this,"_textBaseline","top");L(this,"model",new Le.Container);L(this,"segments",[]);L(this,"metrics",new fs);L(this,"background");L(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=Nl[t];const o=this.metrics.width;for(const i of this.metrics.lines){let r=0;(t=="center"||t=="justify")&&(r=(o-i.width)/2),t=="right"&&(r=o-i.width);for(const s of i.tokens)this.model.children[s.index].x=r,r+=s.metrics.lineWidths[0]}}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline=t,this._anchor.y=_l[t];let o=0;for(const i of this.metrics.lines){const r=i.height;for(const s of i.tokens){let l=0;t=="middle"&&(l=(r-s.metrics.lineHeight)/2),t=="bottom"&&(l=r-s.metrics.lineHeight),this.model.children[s.index].y=o+l}o+=r}}copy(){const t=Ml.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.font=this.font,t}createRenderSplits(t=[]){var r,s;const o=this.transformedText??"",i=[{index:void 0,tokens:si(o.substring(0,(r=t==null?void 0:t.at(0))==null?void 0:r.start))}];for(let l=0;l<t.length;l++)i.push({index:t[l].index,tokens:si(o.substring(t[l].start,t[l].stop))}),!((t[l].stop??o.length)>=o.length)&&i.push({index:void 0,tokens:si(o.substring(t[l].stop,(s=t.at(l+1))==null?void 0:s.start))});return i.filter(l=>l.tokens.join("").trim().length)}createTextMetrics(t,o){var r,s,l;const i=new fs;for(const c of t){const d=c.index!=null?o[c.index]:this.style;for(let u=0;u<c.tokens.length;u++){const m=Uf(Le.CanvasTextMetrics.measureText(c.tokens[u],d)),p=(((r=i.lines.at(-1))==null?void 0:r.width)??0)+m.lineWidths[0],h=this.maxWidth??Number.POSITIVE_INFINITY,v=(s=c.tokens.at(u-1))==null?void 0:s.match(/(\n|\\n).$/gim);(p>h||v||!i.lines.length)&&i.lines.push(new Of),this.model.addChild(new Le.Text({text:c.tokens[u],style:d,resolution:zt,scale:zt})),(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(o=>{var r;const i=this.style.clone();return i.fill=o.fillStyle??this.style.fill,i.fontSize=o.fontSize??this.style.fontSize,i.stroke=o.stroke??this.style.stroke,i.fontFamily=((r=o.font)==null?void 0:r.name)??this.style.fontFamily,i}))??[]}drawBackground(){var l,c;if(this.view.children.length>1&&this.view.removeChildAt(0),!this.background)return;const t=this.model.width,o=this.model.height,i=((l=this.background.padding)==null?void 0:l.x)??40,r=((c=this.background.padding)==null?void 0:c.y)??10,s=new Le.Graphics;s.roundRect(0-i/2,2-r/2,t+i,o+r,this.background.borderRadius??20),s.fill(this.background.fill??"#000000"),s.alpha=this.background.alpha??1,this.view.addChildAt(s,0)}reflectUpdate(){var l;if(!this.transformedText)return;this.model.removeChildren();const t=this.createRenderSplits(this.segments),o=this.createTextStyles();this.metrics=this.createTextMetrics(t,o),this.textAlign=this.textAlign,this.textBaseline=this.textBaseline;const i=this.view.width,r=this.view.height,s=(((l=this.style.dropShadow)==null?void 0:l.distance)??0)*zt;this.view.pivot={x:(i-s)*this._anchor.x,y:(r-s)*this._anchor.y},this.drawBackground()}};Ln([he()],xn.prototype,"background",2);Ln([he(Af)],xn.prototype,"styles",2);Ln([he()],xn.prototype,"text",1);Ln([he()],xn.prototype,"maxWidth",1);Ln([he()],xn.prototype,"textAlign",1);Ln([he()],xn.prototype,"textBaseline",1);let Ea=xn;const Bl="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBtPSh0PT4odFt0LkFWTUVESUFfVFlQRV9VTktOT1dOPS0xXT0iQVZNRURJQV9UWVBFX1VOS05PV04iLHRbdC5BVk1FRElBX1RZUEVfVklERU89MF09IkFWTUVESUFfVFlQRV9WSURFTyIsdFt0LkFWTUVESUFfVFlQRV9BVURJTz0xXT0iQVZNRURJQV9UWVBFX0FVRElPIix0W3QuQVZNRURJQV9UWVBFX0RBVEE9Ml09IkFWTUVESUFfVFlQRV9EQVRBIix0W3QuQVZNRURJQV9UWVBFX1NVQlRJVExFPTNdPSJBVk1FRElBX1RZUEVfU1VCVElUTEUiLHRbdC5BVk1FRElBX1RZUEVfQVRUQUNITUVOVD00XT0iQVZNRURJQV9UWVBFX0FUVEFDSE1FTlQiLHRbdC5BVk1FRElBX1RZUEVfTkI9NV09IkFWTUVESUFfVFlQRV9OQiIsdCkpKG18fHt9KSxvPSh0PT4odC5GRm1wZWdXb3JrZXJMb2FkZWQ9IkZGbXBlZ1dvcmtlckxvYWRlZCIsdC5XQVNNUnVudGltZUluaXRpYWxpemVkPSJXQVNNUnVudGltZUluaXRpYWxpemVkIix0LkxvYWRXQVNNPSJMb2FkV0FTTSIsdC5HZXRBVlBhY2tldD0iR2V0QVZQYWNrZXQiLHQuR2V0QVZQYWNrZXRzPSJHZXRBVlBhY2tldHMiLHQuR2V0QVZTdHJlYW09IkdldEFWU3RyZWFtIix0LkdldEFWU3RyZWFtcz0iR2V0QVZTdHJlYW1zIix0LlJlYWRBVlBhY2tldD0iUmVhZEFWUGFja2V0Iix0LkFWUGFja2V0U3RyZWFtPSJBVlBhY2tldFN0cmVhbSIsdC5SZWFkTmV4dEFWUGFja2V0PSJSZWFkTmV4dEFWUGFja2V0Iix0LlN0b3BSZWFkQVZQYWNrZXQ9IlN0b3BSZWFkQVZQYWNrZXQiLHQpKShvfHx7fSk7Y29uc3QgQT0iS0daMWJtTjBhVzl1S0NsN0luVnpaU0J6ZEhKcFkzUWlPMnhsZENCbU8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2SWtaR2JYQmxaMWR2Y210bGNreHZZV1JsWkNKOUtTeHpaV3htTG1Ga1pFVjJaVzUwVEdsemRHVnVaWElvSW0xbGMzTmhaMlVpTEdGemVXNWpJR1oxYm1OMGFXOXVLR3dwZTJOdmJuTjBlM1I1Y0dVNmRDeGtZWFJoT21NOWUzMHNiWE5uU1dRNmIzMDliQzVrWVhSaE8zUnllWHRwWmloMFBUMDlJa3h2WVdSWFFWTk5JaWw3WTI5dWMzUjdkMkZ6YlV4dllXUmxjbEJoZEdnNlpYMDlZM3g4ZTMwN1pqMWhkMkZwZENoaGQyRnBkQ0JwYlhCdmNuUW9aU2twTG1SbFptRjFiSFFvS1gxbGJITmxJR2xtS0hROVBUMGlSMlYwUVZaVGRISmxZVzBpS1h0amIyNXpkSHRtYVd4bE9tVXNjM1J5WldGdFZIbHdaVHB6TEhOMGNtVmhiVWx1WkdWNE9tRjlQV01zY2oxbUxtZGxkRUZXVTNSeVpXRnRLR1VzY3l4aEtUdHpaV3htTG5CdmMzUk5aWE56WVdkbEtIdDBlWEJsT25Rc2JYTm5TV1E2Ynl4eVpYTjFiSFE2Y24wc1czSXVZMjlrWldOd1lYSXVaWGgwY21Ga1lYUmhMbUoxWm1abGNsMHBmV1ZzYzJVZ2FXWW9kRDA5UFNKSFpYUkJWbE4wY21WaGJYTWlLWHRqYjI1emRIdG1hV3hsT21WOVBXTXNjejFtTG1kbGRFRldVM1J5WldGdGN5aGxLVHR6Wld4bUxuQnZjM1JOWlhOellXZGxLSHQwZVhCbE9uUXNiWE5uU1dRNmJ5eHlaWE4xYkhRNmMzMHNjeTV0WVhBb1lUMCtZUzVqYjJSbFkzQmhjaTVsZUhSeVlXUmhkR0V1WW5WbVptVnlLU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBJaWw3WTI5dWMzUjdabWxzWlRwbExIUnBiV1U2Y3l4emRISmxZVzFVZVhCbE9tRXNjM1J5WldGdFNXNWtaWGc2Y24wOVl5eHVQV1l1WjJWMFFWWlFZV05yWlhRb1pTeHpMR0VzY2lrN2MyVnNaaTV3YjNOMFRXVnpjMkZuWlNoN2RIbHdaVHAwTEcxelowbGtPbThzY21WemRXeDBPbTU5TEZ0dUxtUmhkR0V1WW5WbVptVnlYU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBjeUlwZTJOdmJuTjBlMlpwYkdVNlpTeDBhVzFsT25OOVBXTXNZVDFtTG1kbGRFRldVR0ZqYTJWMGN5aGxMSE1wTzNObGJHWXVjRzl6ZEUxbGMzTmhaMlVvZTNSNWNHVTZkQ3h0YzJkSlpEcHZMSEpsYzNWc2REcGhmU3hoTG0xaGNDaHlQVDV5TG1SaGRHRXVZblZtWm1WeUtTbDlaV3h6WlNCcFppaDBQVDA5SWxKbFlXUkJWbEJoWTJ0bGRDSXBlMk52Ym5OMGUyWnBiR1U2WlN4emRHRnlkRHB6TEdWdVpEcGhMSE4wY21WaGJWUjVjR1U2Y2l4emRISmxZVzFKYm1SbGVEcHVmVDFqTEdROVppNXlaV0ZrUVZaUVlXTnJaWFFvYnl4bExITXNZU3h5TEc0cE8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEhKbGMzVnNkRHBrZlNsOWZXTmhkR05vS0dVcGUzTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEdWeWNrMXpaenBsSUdsdWMzUmhibU5sYjJZZ1JYSnliM0kvWlM1dFpYTnpZV2RsT2lKVmJtdHViM2R1SUVWeWNtOXlJbjBwZlgwcGZTa29LVHNLIixnPXQ9PlVpbnQ4QXJyYXkuZnJvbShhdG9iKHQpLGU9PmUuY2hhckNvZGVBdCgwKSksVj10eXBlb2Ygc2VsZjwidSImJnNlbGYuQmxvYiYmbmV3IEJsb2IoW2coQSldLHt0eXBlOiJ0ZXh0L2phdmFzY3JpcHQ7Y2hhcnNldD11dGYtOCJ9KTtmdW5jdGlvbiBFKHQpe2xldCBlO3RyeXtpZihlPVYmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLmNyZWF0ZU9iamVjdFVSTChWKSwhZSl0aHJvdyIiO2NvbnN0IHM9bmV3IFdvcmtlcihlLHtuYW1lOnQ/Lm5hbWV9KTtyZXR1cm4gcy5hZGRFdmVudExpc3RlbmVyKCJlcnJvciIsKCk9Pnsoc2VsZi5VUkx8fHNlbGYud2Via2l0VVJMKS5yZXZva2VPYmplY3RVUkwoZSl9KSxzfWNhdGNoe3JldHVybiBuZXcgV29ya2VyKCJkYXRhOnRleHQvamF2YXNjcmlwdDtiYXNlNjQsIitBLHtuYW1lOnQ/Lm5hbWV9KX1maW5hbGx5e2UmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLnJldm9rZU9iamVjdFVSTChlKX19Y29uc3QgdT0xZTY7Y2xhc3MgcHtmZm1wZWdXb3JrZXI7ZmZtcGVnV29ya2VyTG9hZFN0YXR1czttc2dJZDtmaWxlO2NvbnN0cnVjdG9yKGUpe3RoaXMuZmZtcGVnV29ya2VyPW5ldyBFLHRoaXMuZmZtcGVnV29ya2VyTG9hZFN0YXR1cz1uZXcgUHJvbWlzZSgocyxhKT0+e3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGk9Pntjb25zdHt0eXBlOnIsZXJyTXNnOmR9PWkuZGF0YTtyPT09by5GRm1wZWdXb3JrZXJMb2FkZWQmJnRoaXMucG9zdChvLkxvYWRXQVNNLHt3YXNtTG9hZGVyUGF0aDplLndhc21Mb2FkZXJQYXRofSkscj09PW8uV0FTTVJ1bnRpbWVJbml0aWFsaXplZCYmcyghMCkscj09PW8uTG9hZFdBU00mJmQmJmEoZCl9KX0pLHRoaXMubXNnSWQ9MH1wb3N0KGUscyxhKXt0aGlzLmZmbXBlZ1dvcmtlci5wb3N0TWVzc2FnZSh7dHlwZTplLG1zZ0lkOmE/P3RoaXMubXNnSWQrKyxkYXRhOnN9KX1hc3luYyBsb2FkKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5mZm1wZWdXb3JrZXJMb2FkU3RhdHVzO3JldHVybiB0aGlzLmZpbGU9ZSxzfWRlc3Ryb3koKXt0aGlzLmZpbGU9dm9pZCAwLHRoaXMuZmZtcGVnV29ya2VyLnRlcm1pbmF0ZSgpfWdldEFWU3RyZWFtKGU9bS5BVk1FRElBX1RZUEVfVklERU8scz0tMSl7cmV0dXJuIG5ldyBQcm9taXNlKChhLGkpPT57aWYoIXRoaXMuZmlsZSl7aSgiZmlsZSBpcyBub3QgbG9hZGVkIik7cmV0dXJufWNvbnN0IHI9dGhpcy5tc2dJZCxkPSh7ZGF0YTpufSk9PntuLnR5cGU9PT1vLkdldEFWU3RyZWFtJiZuLm1zZ0lkPT09ciYmKG4uZXJyTXNnP2kobi5lcnJNc2cpOmEobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGQpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZCksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW0se2ZpbGU6dGhpcy5maWxlLHN0cmVhbVR5cGU6ZSxzdHJlYW1JbmRleDpzfSl9KX1nZXRBVlN0cmVhbXMoKXtyZXR1cm4gbmV3IFByb21pc2UoKGUscyk9PntpZighdGhpcy5maWxlKXtzKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgYT10aGlzLm1zZ0lkLGk9KHtkYXRhOnJ9KT0+e3IudHlwZT09PW8uR2V0QVZTdHJlYW1zJiZyLm1zZ0lkPT09YSYmKHIuZXJyTXNnP3Moci5lcnJNc2cpOmUoci5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsaSksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW1zLHtmaWxlOnRoaXMuZmlsZX0pfSl9Z2V0QVZQYWNrZXQoZSxzPW0uQVZNRURJQV9UWVBFX1ZJREVPLGE9LTEpe3JldHVybiBuZXcgUHJvbWlzZSgoaSxyKT0+e2lmKCF0aGlzLmZpbGUpe3IoImZpbGUgaXMgbm90IGxvYWRlZCIpO3JldHVybn1jb25zdCBkPXRoaXMubXNnSWQsbj1oPT57Y29uc3QgbD1oLmRhdGE7bC50eXBlPT09by5HZXRBVlBhY2tldCYmbC5tc2dJZD09PWQmJihsLmVyck1zZz9yKGwuZXJyTXNnKTppKGwucmVzdWx0KSx0aGlzLmZmbXBlZ1dvcmtlci5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixuKSl9O3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLG4pLHRoaXMucG9zdChvLkdldEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSx0aW1lOmUsc3RyZWFtVHlwZTpzLHN0cmVhbUluZGV4OmF9KX0pfWdldEFWUGFja2V0cyhlKXtyZXR1cm4gbmV3IFByb21pc2UoKHMsYSk9PntpZighdGhpcy5maWxlKXthKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgaT10aGlzLm1zZ0lkLHI9ZD0+e2NvbnN0IG49ZC5kYXRhO24udHlwZT09PW8uR2V0QVZQYWNrZXRzJiZuLm1zZ0lkPT09aSYmKG4uZXJyTXNnP2Eobi5lcnJNc2cpOnMobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLHIpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsciksdGhpcy5wb3N0KG8uR2V0QVZQYWNrZXRzLHtmaWxlOnRoaXMuZmlsZSx0aW1lOmV9KX0pfXJlYWRBVlBhY2tldChlPTAscz0wLGE9bS5BVk1FRElBX1RZUEVfVklERU8saT0tMSl7Y29uc3Qgcj1uZXcgQ291bnRRdWV1aW5nU3RyYXRlZ3koe2hpZ2hXYXRlck1hcms6MX0pLGQ9dGhpcy5tc2dJZDtsZXQgbj0wO3JldHVybiBuZXcgUmVhZGFibGVTdHJlYW0oe3N0YXJ0Omg9PntpZighdGhpcy5maWxlKXtoLmVycm9yKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgbD1mPT57Y29uc3QgYz1mLmRhdGE7Yy50eXBlPT09by5SZWFkQVZQYWNrZXQmJmMubXNnSWQ9PT1kJiZjLmVyck1zZyYmKGguZXJyb3IoYy5lcnJNc2cpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGwpKSxjLnR5cGU9PT1vLkFWUGFja2V0U3RyZWFtJiZjLm1zZ0lkPT09ZCYmKGMucmVzdWx0P2guZW5xdWV1ZShjLnJlc3VsdCk6aC5jbG9zZSgpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsbCksdGhpcy5wb3N0KG8uUmVhZEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSxzdGFydDplLGVuZDpzLHN0cmVhbVR5cGU6YSxzdHJlYW1JbmRleDppfSl9LHB1bGw6KCk9PntuPjAmJnRoaXMucG9zdChvLlJlYWROZXh0QVZQYWNrZXQsdm9pZCAwLGQpLG4rK30sY2FuY2VsOigpPT57dGhpcy5wb3N0KG8uU3RvcFJlYWRBVlBhY2tldCx2b2lkIDAsZCl9fSxyKX1nZXRWaWRlb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9WSURFTyxlKX1nZXRBdWRpb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9BVURJTyxlKX1zZWVrVmlkZW9QYWNrZXQoZSl7cmV0dXJuIHRoaXMuZ2V0QVZQYWNrZXQoZSxtLkFWTUVESUFfVFlQRV9WSURFTyl9c2Vla0F1ZGlvUGFja2V0KGUpe3JldHVybiB0aGlzLmdldEFWUGFja2V0KGUsbS5BVk1FRElBX1RZUEVfQVVESU8pfXJlYWRWaWRlb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfVklERU8pfXJlYWRBdWRpb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfQVVESU8pfWdlblZpZGVvRGVjb2RlckNvbmZpZyhlKXtyZXR1cm57Y29kZWM6ZS5jb2RlY3Bhci5jb2RlY19zdHJpbmcsY29kZWRXaWR0aDplLmNvZGVjcGFyLndpZHRoLGNvZGVkSGVpZ2h0OmUuY29kZWNwYXIuaGVpZ2h0LGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRWaWRlb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZFZpZGVvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1nZW5BdWRpb0RlY29kZXJDb25maWcoZSl7cmV0dXJue2NvZGVjOmUuY29kZWNwYXIuY29kZWNfc3RyaW5nfHwiIixzYW1wbGVSYXRlOmUuY29kZWNwYXIuc2FtcGxlX3JhdGUsbnVtYmVyT2ZDaGFubmVsczplLmNvZGVjcGFyLmNoYW5uZWxzLGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRBdWRpb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZEF1ZGlvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1hc3luYyBnZXRWaWRlb0RlY29kZXJDb25maWcoKXtjb25zdCBlPWF3YWl0IHRoaXMuZ2V0VmlkZW9TdHJlYW0oKTtyZXR1cm4gdGhpcy5nZW5WaWRlb0RlY29kZXJDb25maWcoZSl9YXN5bmMgc2Vla0VuY29kZWRWaWRlb0NodW5rKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5zZWVrVmlkZW9QYWNrZXQoZSk7cmV0dXJuIHRoaXMuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsocyl9YXN5bmMgZ2V0QXVkaW9EZWNvZGVyQ29uZmlnKCl7Y29uc3QgZT1hd2FpdCB0aGlzLmdldEF1ZGlvU3RyZWFtKCk7cmV0dXJuIHRoaXMuZ2VuQXVkaW9EZWNvZGVyQ29uZmlnKGUpfWFzeW5jIHNlZWtFbmNvZGVkQXVkaW9DaHVuayhlKXtjb25zdCBzPWF3YWl0IHRoaXMuc2Vla0F1ZGlvUGFja2V0KGUpO3JldHVybiB0aGlzLmdlbkVuY29kZWRBdWRpb0NodW5rKHMpfX1jbGFzcyBre3ZpZGVvO2N1cnJlbnRGcmFtZXM9MDt0b3RhbEZyYW1lcztjdXJyZW50VGltZTtmcHM7Zmlyc3RUaW1lc3RhbXA7Y29uc3RydWN0b3IoZSxzKXt0aGlzLmN1cnJlbnRUaW1lPWVbMF0qMWU2LHRoaXMuZmlyc3RUaW1lc3RhbXA9ZVswXSoxZTYsdGhpcy50b3RhbEZyYW1lcz0oZVsxXS1lWzBdKSpzKzEsdGhpcy5mcHM9cyx0aGlzLnZpZGVvPW5ldyBWaWRlb0RlY29kZXIoe291dHB1dDp0aGlzLmhhbmRsZUZyYW1lT3V0cHV0LmJpbmQodGhpcyksZXJyb3I6dGhpcy5oYW5kbGVFcnJvci5iaW5kKHRoaXMpfSl9cG9zdEZyYW1lKGUpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImZyYW1lIixmcmFtZTplfSksdGhpcy5jdXJyZW50VGltZSs9TWF0aC5mbG9vcigxL3RoaXMuZnBzKjFlNiksdGhpcy5jdXJyZW50RnJhbWVzKz0xfWhhbmRsZUZyYW1lT3V0cHV0KGUpe2NvbnN0IHM9ZS50aW1lc3RhbXAsYT1lLmR1cmF0aW9uPz8wLGk9cythO2lmKCF0aGlzLmlzRnJhbWVJblJhbmdlKHMpKXtlLmNsb3NlKCk7cmV0dXJufWZvcig7aT50aGlzLmN1cnJlbnRUaW1lJiZ0aGlzLmN1cnJlbnRGcmFtZXM8PXRoaXMudG90YWxGcmFtZXM7KXRoaXMucG9zdEZyYW1lKGUpO2UuY2xvc2UoKX1pc0ZyYW1lSW5SYW5nZShlKXtyZXR1cm4gZT49dGhpcy5maXJzdFRpbWVzdGFtcH1oYW5kbGVFcnJvcihlKXtjb25zb2xlLmVycm9yKCJlcnJvciBpbiB3b3JrZXIiLGUpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOmUubWVzc2FnZT8/IkFuIHVua25vd24gd29ya2VyIGVycm9yIG9jY3VycmVkIn0pLHNlbGYuY2xvc2UoKX19ZnVuY3Rpb24gSSh0KXtyZXR1cm4gYXN5bmMgZT0+e3RyeXthd2FpdCB0KGUpfWNhdGNoKHMpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOnM/Lm1lc3NhZ2U/PyJBbiB1bmtvd24gd29ya2VyIGVycm9yIG9jY3VyZWQifSl9fX1mdW5jdGlvbiBXKHQpe3JldHVybiB0LmNvZGVjPT0idnAwOSImJih0LmNvZGVjPSJ2cDA5LjAwLjEwLjA4IiksdH1jb25zdCBaPTMwO2FzeW5jIGZ1bmN0aW9uIFAodCl7aWYodC5kYXRhPy50eXBlIT0iaW5pdCIpcmV0dXJuO2NvbnN0e2ZpbGU6ZSxyYW5nZTpzLGZwczphfT10LmRhdGEsaT1uZXcgcCh7d2FzbUxvYWRlclBhdGg6Imh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vQGRpZmZ1c2lvbnN0dWRpby9mZm1wZWctd2FzbUAxLjAuMC9kaXN0L2ZmbXBlZy5qcyJ9KTthd2FpdCBpLmxvYWQoZSk7Y29uc3Qgcj1hd2FpdCBpLmdldFZpZGVvRGVjb2RlckNvbmZpZygpO1cocik7Y29uc3QgZD1uZXcgayhzLGEpO2QudmlkZW8uY29uZmlndXJlKHIpO2NvbnN0IG49aS5yZWFkQVZQYWNrZXQoc1swXSxzWzFdKS5nZXRSZWFkZXIoKTtuLnJlYWQoKS50aGVuKGFzeW5jIGZ1bmN0aW9uIGgoe2RvbmU6bCx2YWx1ZTpmfSl7aWYobCl7YXdhaXQgZC52aWRlby5mbHVzaCgpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImRvbmUifSksc2VsZi5jbG9zZSgpO3JldHVybn1jb25zdCBjPWkuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsoZik7cmV0dXJuIGQudmlkZW8uZGVjb2RlUXVldWVTaXplPlomJmF3YWl0IG5ldyBQcm9taXNlKEw9PntkLnZpZGVvLm9uZGVxdWV1ZT0oKT0+TCgpfSksYy50aW1lc3RhbXA8PXNbMV0qMWU2JiZkLnZpZGVvLmRlY29kZShjKSxuLnJlYWQoKS50aGVuKGgpfSl9c2VsZi5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixJKFApKX0pKCk7Cg==",Pf=a=>Uint8Array.from(atob(a),n=>n.charCodeAt(0)),hs=typeof self<"u"&&self.Blob&&new Blob([Pf(Bl)],{type:"text/javascript;charset=utf-8"});function jf(a){let n;try{if(n=hs&&(self.URL||self.webkitURL).createObjectURL(hs),!n)throw"";const t=new Worker(n,{name:a==null?void 0:a.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),t}catch{return new Worker("data:text/javascript;base64,"+Bl,{name:a==null?void 0:a.name})}finally{n&&(self.URL||self.webkitURL).revokeObjectURL(n)}}class Wf{constructor(){L(this,"frames",[]);L(this,"state","active");L(this,"onenqueue");L(this,"onclose")}enqueue(n){var t;this.frames.unshift(n),(t=this.onenqueue)==null||t.call(this)}async dequeue(){if(this.frames.length==0&&this.state=="active"&&await this.waitFor(2e4),!(this.frames.length==0&&this.state=="closed"))return this.frames.pop()}close(){var n;this.state="closed",(n=this.onclose)==null||n.call(this)}terminate(){for(const n of this.frames)n.close()}async waitFor(n){await new Promise((t,o)=>{const i=setTimeout(()=>{o(`Promise timed out after ${n} ms`)},n);this.onenqueue=()=>{clearTimeout(i),t()},this.onclose=()=>{clearTimeout(i),t()}})}}function Zf(a,n,t){const o=t.value;return t.value=function(...i){var r,s,l,c;return(s=(r=this.track)==null?void 0:r.composition)!=null&&s.rendering&&this.sprite.texture.source.uid!=this.textrues.canvas.source.uid&&(this.sprite.texture=this.textrues.canvas),!((c=(l=this.track)==null?void 0:l.composition)!=null&&c.rendering)&&this.sprite.texture.source.uid!=this.textrues.html5.source.uid&&(this.sprite.texture=this.textrues.html5),o.apply(this,i)},t}var Xf=Object.defineProperty,Hf=Object.getOwnPropertyDescriptor,Gf=(a,n,t,o)=>{for(var i=Hf(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Xf(n,t,i),i};const Il=class Fl extends ba(wa){constructor(t,o={}){super();L(this,"source",new fn);L(this,"type","video");L(this,"worker");L(this,"buffer");L(this,"canvas",document.createElement("canvas"));L(this,"context",this.canvas.getContext("2d"));L(this,"element",document.createElement("video"));L(this,"textrues",{html5:Le.Texture.from(this.element),canvas:Le.Texture.from(this.canvas)});L(this,"sprite",new Le.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 fn&&(this.source=t),t instanceof File&&this.source.from(t),this.element.addEventListener("play",()=>{this.playing=!0}),this.element.addEventListener("pause",()=>{this.playing=!1}),Object.assign(this,o)}async init(){const t=await this.source.createObjectURL();this.element.setAttribute("src",t),await new Promise((o,i)=>{this.element.oncanplay=()=>{this.duration.seconds=this.element.duration,this.state="READY",o()},this.element.onerror=()=>{this.state="ERROR";const r=new Kt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."});i(this.element.error??r)}})}async connect(t){var i;super.connect(t);const o=((i=t.composition)==null?void 0:i.frame)??0;await this.seek(ge.fromFrames(o))}enter(){var t,o,i;super.enter(),(o=(t=this.track)==null?void 0:t.composition)!=null&&o.rendering&&((i=this.buffer)==null?void 0:i.state)!="active"&&this.decodeVideo()}update(t){var o,i,r,s,l,c;if((i=(o=this.track)==null?void 0:o.composition)!=null&&i.playing&&!this.playing)this.element.play();else if(!((s=(r=this.track)==null?void 0:r.composition)!=null&&s.playing)&&this.playing)this.element.pause();else if((c=(l=this.track)==null?void 0:l.composition)!=null&&c.rendering)return this.nextFrame()}exit(){this.playing&&this.element.pause(),this.filters&&this.view.filters&&(this.view.filters=null)}copy(){const t=Fl.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}async decodeVideo(){var t,o;return this.buffer=new Wf,this.worker=new jf,this.worker.addEventListener("message",i=>{var r,s;i.data.type=="frame"?(r=this.buffer)==null||r.enqueue(i.data.frame):i.data.type=="error"?this.cancelDecoding():i.data.type=="done"&&((s=this.buffer)==null||s.close())}),this.worker.postMessage({type:"init",file:await this.source.getFile(),range:this.demuxRange,fps:((o=(t=this.track)==null?void 0:t.composition)==null?void 0:o.fps)??ho}),this.buffer}async nextFrame(){if(!this.buffer)return;const t=await this.buffer.dequeue();t&&(this.canvas.width=t.displayWidth,this.canvas.height=t.displayHeight,this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.drawImage(t,0,0),this.textrues.canvas.source.update(),t.close())}get demuxRange(){var r;const t=(r=this.track)==null?void 0:r.composition;let o;this.start.millis<0?o=Math.abs(this.offset.seconds):o=this.range[0].seconds;let i;return t&&this.stop.millis>t.duration.millis?i=t.duration.subtract(this.offset).seconds:i=this.range[1].seconds,[o,i]}cancelDecoding(){var t,o;(t=this.worker)==null||t.terminate(),this.worker=void 0,(o=this.buffer)==null||o.terminate(),this.buffer=void 0}};Gf([ka,Zf],Il.prototype,"update");let Bi=Il;class ua extends wa{constructor(t,o={}){super();L(this,"type","audio");L(this,"source",new rn);L(this,"element",new Audio);t instanceof rn&&(this.source=t),t instanceof File&&this.source.from(t),this.element.addEventListener("play",()=>{this.playing=!0}),this.element.addEventListener("pause",()=>{this.playing=!1}),Object.assign(this,o)}async init(){const t=await this.source.createObjectURL();this.element.setAttribute("src",t),this.element.load(),await new Promise((o,i)=>{this.element.oncanplay=()=>{this.duration.seconds=this.element.duration,this.state="READY",o()},this.element.onerror=()=>{this.state="ERROR";const r=new Kt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."});i(this.element.error??r)}})}update(){var t,o,i,r,s,l;if((o=(t=this.track)==null?void 0:t.composition)!=null&&o.rendering)return this.exit();(r=(i=this.track)==null?void 0:i.composition)!=null&&r.playing&&!this.playing?this.element.play():!((l=(s=this.track)==null?void 0:s.composition)!=null&&l.playing)&&this.playing&&this.element.pause()}exit(){this.playing&&this.element.pause()}copy(){const t=ua.fromJSON(JSON.parse(JSON.stringify(this)));return t.source=this.source,t}}const Jf={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 Ii(a){if(!Object.keys(Jf.MIXED).includes(a??""))throw new Ye({message:`${a} is not an accepted mime type`,code:"invalid_mimetype"});return a}var Yf=Object.defineProperty,Kf=Object.getOwnPropertyDescriptor,qf=(a,n,t,o)=>{for(var i=Kf(n,t),r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&Yf(n,t,i),i};const Qf=class Rl extends ba(bo){constructor(t,o={}){super();L(this,"type","html");L(this,"source",new ms);L(this,"element",new Image);L(this,"canvas",document.createElement("canvas"));L(this,"context",this.canvas.getContext("2d"));L(this,"sprite",new Le.Sprite);this.view.addChild(this.sprite),Object.assign(this,o),t instanceof ms&&(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=Le.Texture.from(this.canvas,!0),this.trigger("load",void 0))}),this.element.addEventListener("error",i=>{this.state="ERROR",this.trigger("error",new Kt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."})),this.track&&this.detach()}),this.on("update",async()=>{this.source.update(),this.element.setAttribute("src",await this.source.createObjectURL())})}async init(){this.element.setAttribute("src",await this.source.createObjectURL()),await new Promise((t,o)=>{this.element.onload=()=>{var s,l,c,d;const i=(l=(s=this.source.document)==null?void 0:s.body)==null?void 0:l.scrollWidth,r=(d=(c=this.source.document)==null?void 0:c.body)==null?void 0:d.scrollHeight;if(!i||!r)return o(new Kt({code:"sourceNotProcessable",message:"Cannot display source with height or width at 0"}));this.state="READY",t()},this.element.onerror=i=>{o(new Kt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=Rl.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};qf([ka],Qf.prototype,"update");const $l=["DEFAULT","STACK"];class vs{constructor(){L(this,"mode",$l[0]);L(this,"pauseAlignmet",!1)}add(n,t){let o=!0;for(let i=0;i<t.clips.length&&(o=ws(n,t.clips[i]),!!o);i++)ys(n,t.clips[i]);o&&(t.clips.push(n),t.clips.sort(gs))}update(n,t){if(!this.pauseAlignmet){t.clips.sort(gs);for(let o=0;o<t.clips.length;o++)if(n.id!=t.clips[o].id){if(!ws(n,t.clips[o]))break;ys(n,t.clips[o])}}}offset(n,t){this.pauseAlignmet=!0;for(const o of t.clips)o.offsetBy(n);this.pauseAlignmet=!1}}class eh{constructor(){L(this,"mode",$l[1])}add(n,t,o=void 0){var r;let i=-1;(o!=null&&o>0||o==null)&&(i=((r=t.clips.at((o??0)-1))==null?void 0:r.stop.millis)??-1),n.offsetBy(new ge(i-n.start.millis+1)),o==null?t.clips.push(n):(t.clips.splice(o,0,n),t.clips.slice(o+1).forEach(s=>{s.offsetBy(n.stop.subtract(n.start))}))}update(n,t){let o=0;for(const i of t.clips){if(i.start.millis!=o){const r=o-i.start.millis;i.offsetBy(new ge(r))}o=i.stop.millis+1}}offset(){}}function gs(a,n){return a.start.millis-n.start.millis}function ys(a,n){a.start.millis>=n.start.millis&&a.start.millis<=n.stop.millis&&(a.start=n.stop.copy().addMillis(1)),a.stop.millis>=n.start.millis&&a.stop.millis<=n.stop.millis&&(a.stop=n.start.copy().addMillis(-1))}function ws(a,n){var t,o,i,r,s;if(a.start.millis>=n.start.millis&&a.stop.millis<=n.stop.millis){const l=(o=(t=n.track)==null?void 0:t.composition)==null?void 0:o.tracks.find(c=>c.type==a.type&&!c.clips.some(d=>a.id!=d.id&&a.start.millis>=d.start.millis&&a.stop.millis<=d.stop.millis));return l?(l.add(a.detach()),!1):((s=(r=(i=n.track)==null?void 0:i.composition)==null?void 0:r.createTrack(a.type))==null||s.add(a.detach()),!1)}return!0}class zn extends yo(_t){constructor(){super(...arguments);L(this,"_disabled",!1);L(this,"view",new Le.Container);L(this,"clips",[]);L(this,"pointer",0);L(this,"composition");L(this,"type","base");L(this,"strategy",new vs)}get disabled(){return this._disabled}set disabled(t){var o;t&&this.clipRef&&ci(this.clipRef)&&(this.view.removeChild(this.clipRef.view),(o=this.clipRef)==null||o.exit()),this._disabled=t,this.trigger("update",void 0)}connect(t){this.composition=t}stacked(t=!0){return t?(this.strategy=new eh,this.strategy.update(new bo,this)):this.strategy=new vs,this.trigger("update",void 0),this}layer(t){var l,c;const o=((l=this.composition)==null?void 0:l.tracks)??[],i=o.findIndex(d=>d.id==this.id),r=o.length-1;if(i==-1)return this;let s=0;return t=="bottom"?s=r:t=="top"||t<0?s=0:t>r?s=r:s=t,cf(o,i,s),(c=this.composition)==null||c.stage.setChildIndex(this.view,r-s),this.trigger("update",void 0),this}seek(t){}offsetBy(t){return typeof t=="number"?this.strategy.offset(ge.fromFrames(t),this):this.strategy.offset(t,this),this}update(t){var i,r;if(this.disabled||!this.clips.length)return;const{millis:o}=t;if(ci(this.clipRef)&&(!li(o,this.clipRef)||(i=this.clipRef)!=null&&i.disabled)&&(this.clipRef&&this.view.removeChild(this.clipRef.view),(r=this.clipRef)==null||r.exit()),!!li(o,this))for(let s=0;s<this.clips.length;s++){const l=(this.pointer+s)%this.clips.length,c=this.clips[l],d=this.clips[l-1];if(li(o,c)&&!c.disabled)return this.pointer=l,ci(c)||(c.enter(),this.view.addChild(c.view)),c.update(t);if(o<c.start.millis&&o>((d==null?void 0:d.stop.millis)??0)){this.pointer=l;return}}}async add(t,o){return this.composition&&!this.composition.renderer&&await new Promise(this.composition.resolve("init")),await t.init(),await t.connect(this),await this.strategy.add(t,this,o),t.on("frame",()=>{this.strategy.update(t,this)}),t.bubble(this),this.trigger("attach",void 0),t}remove(t){const o=this.clips.findIndex(i=>i.id==t.id);if(t.state=="ATTACHED"&&(t.state="READY"),t.view.parent&&this.view.removeChild(t.view),o!=null&&o>=0)return this.clips.splice(o,1),this.strategy.update(t,this),this.trigger("detach",void 0),t.off("*"),t}get stop(){var t;return((t=this.clips.at(-1))==null?void 0:t.stop)??new ge}get start(){var t;return((t=this.clips.at(0))==null?void 0:t.start)??new ge}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 li(a,n){return n?a>=n.start.millis&&a<=n.stop.millis:!1}function ci(a){return a?!!a.view.parent:!1}class th{static fromType(n){switch(n.type){case"video":return new nh;case"audio":return new ah;case"html":return new ih;case"image":return new oh;case"text":return new bs;case"complex_text":return new bs;case"caption":return new sh;default:return new zn}}}class Dl extends zn{constructor(){super(...arguments);L(this,"clips",[])}async seek(t){for(const o of this.clips)await o.seek(t)}async removeSilences(t={}){const o=[];for(const i of this.clips.map(r=>r.detach()))o.push(...await i.removeSilences(t));for(const i of o)await this.add(i)}}class nh extends Dl{constructor(){super(...arguments);L(this,"type","video")}async seek(t){var o;(o=this.composition)!=null&&o.rendering?this.view.removeChildren():super.seek(t)}}class oh extends zn{constructor(){super(...arguments);L(this,"type","image")}}class ah extends Dl{constructor(){super(...arguments);L(this,"type","audio")}}class bs extends zn{constructor(){super(...arguments);L(this,"type","text")}}class ih extends zn{constructor(){super(...arguments);L(this,"type","html")}}var rh=Object.defineProperty,ir=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&rh(n,t,i),i};class xo extends _t{constructor(t={}){super();L(this,"generatorOptions");L(this,"type","CLASSIC");L(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 Ye({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((l=t.clip)==null?void 0:l.offset)??new ge,i=await ct.fromFamily({family:"Figtree",weight:"700"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))await t.add(new An({text:c.words.map(d=>d.text).join(" "),textAlign:"center",textBaseline:"middle",fontSize:21,fillStyle:"#FFFFFF",font:i,stroke:{color:"#000000",width:4,join:"round"},maxWidth:t.composition.width*.85,shadow:{color:"#000000",blur:0,distance:1.1,angle:Math.PI*.4,alpha:1},position:this.position,stop:c.stop.add(o),start:c.start.add(o),scale:new Ee([0,8],[.96,1],{easing:"easeOut"}),alpha:new Ee([0,4],[0,1],{easing:"easeOut"})}))}}ir([he()],xo.prototype,"generatorOptions");ir([he()],xo.prototype,"type");ir([he()],xo.prototype,"position");class sh extends zn{constructor(){super(...arguments);L(this,"clip");L(this,"type","caption");L(this,"preset",new xo)}from(t){var o;return this.clip=t,(o=this.clip)==null||o.on("offsetBy",i=>this.offsetBy(i.detail)),this}async generate(t){let o=this.preset;return typeof t=="object"?o=t:t&&(o=new t),this.clips=[],this.trigger("update",void 0),this.preset=o,await o.applyTo(this),this.trigger("update",void 0),this}}var lh=Object.defineProperty,Va=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&lh(n,t,i),i};class Eo extends _t{constructor(t={}){super();L(this,"generatorOptions");L(this,"type","SPOTLIGHT");L(this,"color");L(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 Ye({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((l=t.clip)==null?void 0:l.offset)??new ge,i=await ct.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 Ea({text:u.join(" "),textAlign:"center",textBaseline:"middle",fillStyle:"#FFFFFF",fontSize:22,maxWidth:t.composition.width*.8,font:i,stroke:{width:5,color:"#000000"},shadow:{color:"#000000",blur:12,alpha:.7,angle:Math.PI/4,distance:2},position:this.position,styles:[{fillStyle:this.color}],segments:c.words.length>1?[{index:0,start:u.slice(0,d).join(" ").length,stop:u.slice(0,d+1).join(" ").length}]:void 0,stop:c.words[d].stop.add(o),start:c.words[d].start.add(o)}))}}}Va([he()],Eo.prototype,"generatorOptions");Va([he()],Eo.prototype,"type");Va([he()],Eo.prototype,"color");Va([he()],Eo.prototype,"position");var ch=Object.defineProperty,rr=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&ch(n,t,i),i};class Sa extends _t{constructor(t={}){super();L(this,"type","GUINEA");L(this,"colors");L(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 Ye({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((l=t.clip)==null?void 0:l.offset)??new ge,i=await ct.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const p of t.clip.transcript.iter({length:[18]})){const{segments:h,words:v}=this.splitSequence(p);for(let y=0;y<p.words.length;y++){const E=(d=(c=v[y])==null?void 0:c.at(0))==null?void 0:d.start,_=(m=(u=v[y])==null?void 0:u.at(-1))==null?void 0:m.stop;!E||!_||await t.add(new Ea({text:h.join(`
|
|
33
|
-
`),textAlign:"center",textBaseline:"middle",fontSize:20,fillStyle:"#FFFFFF",shadow:{color:"#000000",blur:16,alpha:.8,angle:Math.PI/4,distance:1},stroke:{width:4,color:"#000000"},maxWidth:t.composition.width*.8,leading:1.3,font:i,textCase:"upper",position:this.position,stop:_.add(o),start:E.add(o),styles:[{fillStyle:this.colors[0],fontSize:23},{fillStyle:this.colors[1],fontSize:23},{fillStyle:this.colors[2],fontSize:23}],segments:[{index:Ko(0,2),start:h.slice(0,y).join(" ").length,stop:h.slice(0,y+1).join(" ").length+y*2}]}))}}}splitSequence(t){const o=t.text,i=Math.ceil(o.length/2);let r=o.length;for(let c=i,d=i;c>0&&d<t.text.length-1;c--,d++){if(o[c].match(/ /)){r=c;break}if(o[d].match(/ /)){r=d;break}}const s=[...is(o,r).map(c=>c.trim())],l=is(t.words,s[0].split(/ /).length);return{segments:s,words:l}}}rr([he()],Sa.prototype,"type");rr([he()],Sa.prototype,"colors");rr([he()],Sa.prototype,"position");var dh=Object.defineProperty,sr=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&dh(n,t,i),i};class Ca extends _t{constructor(t={}){super();L(this,"generatorOptions");L(this,"type","CASCADE");L(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 Ye({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((l=t.clip)==null?void 0:l.offset)??new ge,i=await ct.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 An({text:u(),textAlign:"left",textBaseline:"top",fillStyle:"#FFFFFF",fontSize:16,font:i,maxWidth:t.composition.width*.7,stroke:{color:"#000000",width:4,join:"round"},shadow:{color:"#000000",blur:8,alpha:.4,angle:Math.PI/4,distance:2},position:this.position,stop:c.words[d].stop.add(o),start:c.words[d].start.add(o)}))}}}sr([he()],Ca.prototype,"generatorOptions");sr([he()],Ca.prototype,"type");sr([he()],Ca.prototype,"position");var uh=Object.defineProperty,lr=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&uh(n,t,i),i};class Na extends _t{constructor(t={}){super();L(this,"generatorOptions");L(this,"type","SOLAR");L(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 Ye({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=await ct.fromFamily({family:"Urbanist",weight:"800"}).load(),i=((c=t.clip)==null?void 0:c.offset)??new ge,r=new Sd.GlowFilter({color:"#fffe41",alpha:.25,distance:90,quality:.05});for(const d of t.clip.transcript.iter(this.generatorOptions))await t.add(new An({text:d.words.map(u=>u.text).join(" "),textAlign:"center",textBaseline:"middle",fontSize:19,fillStyle:"#fffe41",font:o,maxWidth:t.composition.width*.85,textCase:"upper",shadow:{color:"#ab7a00",blur:0,distance:2.1,angle:Math.PI/2.5,alpha:1},position:this.position,stop:d.stop.add(i),start:d.start.add(i),scale:new Ee([0,8],[.96,1],{easing:"easeOut"}),alpha:new Ee([0,4],[0,1],{easing:"easeOut"}),filters:r}))}}lr([he()],Na.prototype,"generatorOptions");lr([he()],Na.prototype,"type");lr([he()],Na.prototype,"position");var mh=Object.defineProperty,_a=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&mh(n,t,i),i};class Vo extends _t{constructor(t={}){super();L(this,"generatorOptions");L(this,"type","WHISPER");L(this,"color");L(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 Ye({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((l=t.clip)==null?void 0:l.offset)??new ge,i=await ct.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 Ea({text:u.join(" "),textAlign:"center",textBaseline:"middle",fillStyle:"#FFFFFF",fontSize:13,background:{alpha:.3,padding:{x:50,y:30}},maxWidth:t.composition.width*.8,font:i,position:this.position,styles:[{fillStyle:this.color}],stop:c.words[d].stop.add(o),start:c.words[d].start.add(o),segments:u.length>1?[{index:0,start:u.slice(0,d+1).join(" ").length}]:void 0}))}}}_a([he()],Vo.prototype,"generatorOptions");_a([he()],Vo.prototype,"type");_a([he()],Vo.prototype,"color");_a([he()],Vo.prototype,"position");var ph=Object.defineProperty,Ta=(a,n,t,o)=>{for(var i=void 0,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=s(n,t,i)||i);return i&&ph(n,t,i),i};class Ma extends _t{constructor(t={}){super();L(this,"type","VERDANT");L(this,"generatorOptions");L(this,"color");L(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 Ye({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const o=((l=t.clip)==null?void 0:l.offset)??new ge,i=await ct.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 Ea({text:u.join(" "),textAlign:"center",textBaseline:"middle",fontSize:15,fillStyle:"#FFFFFF",shadow:{color:"#000000",blur:4,alpha:.7,angle:Math.PI/4,distance:2},stroke:{width:3,color:"#000000"},maxWidth:t.composition.width*.5,leading:1.1,font:i,textCase:"upper",styles:[{fillStyle:this.color,fontSize:19}],position:this.position,stop:c.words[d].stop.add(o),start:c.words[d].start.add(o),segments:[{index:0,start:u.slice(0,d).join(" ").length,stop:u.slice(0,d+1).join(" ").length}]}))}}}Ta([he()],Ma.prototype,"type");Ta([he()],Ma.prototype,"generatorOptions");Ta([he()],Ma.prototype,"color");Ta([he()],Ma.prototype,"position");class fh extends yo(_t){constructor({height:t=1080,width:o=1920,background:i="#000000",backend:r="webgpu"}={}){super();L(this,"_duration",new ge);L(this,"renderer");L(this,"stage",new Le.Container);L(this,"settings");L(this,"tracks",[]);L(this,"frame",0);L(this,"fixedDuration");L(this,"state","IDLE");L(this,"fps",ho);L(this,"canvas");L(this,"context");this.settings={height:t,width:o,background:i,backend:r},this.on("update",this.update.bind(this)),this.on("attach",this.update.bind(this)),this.on("detach",this.update.bind(this)),this.on("load",this.update.bind(this)),this.on("frame",this.update.bind(this)),this.on("error",this.update.bind(this)),Le.autoDetectRenderer({...this.settings,preference:r}).then(s=>{this.renderer=s,this.trigger("init",void 0)}).catch(s=>{this.trigger("error",new Dn({code:"backendDetectionError",message:`${s}`}))})}get playing(){return this.state=="PLAY"}get rendering(){return this.state=="RENDER"}get width(){return this.settings.width}get height(){return this.settings.height}get duration(){return this.fixedDuration?this.fixedDuration:this._duration}set duration(t){var o;t?t instanceof ge?this.fixedDuration=t:this.fixedDuration=ge.fromFrames(t):this.fixedDuration=void 0,this.trigger("frame",((o=this.fixedDuration)==null?void 0:o.frames)??0)}resize(t,o){var i;this.settings.width=t,this.settings.height=o,(i=this.renderer)==null||i.resize(t,o),this.canvas&&(this.canvas.height=o,this.canvas.width=t),this.trigger("resize",void 0),this.computeFrame()}attachPlayer(t){this.canvas||(this.canvas=document.createElement("canvas"),this.canvas.height=this.settings.height,this.canvas.width=this.settings.width,this.canvas.style.background="black",this.context=this.canvas.getContext("2d"),this.context.imageSmoothingEnabled=!1,this.computeFrame()),t.appendChild(this.canvas)}detachPlayer(t){this.canvas&&t.removeChild(this.canvas)}shiftTrack(t){const o=typeof t=="object"?t:new t;return o.connect(this),this.stage.addChild(o.view),this.tracks.unshift(o),o.bubble(this),this.trigger("update",void 0),o}createTrack(t){const o=th.fromType({type:t});return this.shiftTrack(o),o}async add(t){return await this.createTrack(t.type).add(t),t}remove(t){for(const o of this.tracks)if(o.clips.find(i=>i.id==t.id))return o.remove(t)}removeTracks(t){const o=this.tracks.filter(i=>i instanceof t);return this.tracks=this.tracks.filter(i=>!(i instanceof t)),o.forEach(i=>this.removeTrack(i)),o}findTracks(t){return this.tracks.filter(o=>{let i;return rs(t)?i=o instanceof t:i=t(o),i})}findClips(t){const o=[];for(const i of this.tracks)for(const r of i.clips){let s;rs(t)?s=r instanceof t:s=t(r),s&&o.push(r)}return o}computeFrame(){var t,o;if(this.renderer){for(let i=0;i<this.tracks.length;i++)this.tracks[i].update(ge.fromFrames(this.frame));this.renderer.render(this.stage),(t=this.context)==null||t.clearRect(0,0,this.settings.width,this.settings.height),(o=this.context)==null||o.drawImage(this.renderer.canvas,0,0),this.trigger("currentframe",this.frame),this.playing&&this.frame++}}screenshot(t="png",o=1){if(this.computeFrame(),!this.renderer)throw new Dn({code:"rendererNotDefined",message:"Please wait until the renderer is defined"});return this.renderer.canvas.toDataURL(`image/${t}`,o)}async seek(t){typeof t=="number"?this.frame=Math.round(t>0?t:0):this.frame=t.frames>0?t.frames:0,this.playing&&this.pause();for(const o of this.tracks)await o.seek(ge.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(ge.fromFrames(this.frame));this.ticker(),this.trigger("play",this.frame)}}async pause(){this.state="IDLE",this.computeFrame(),this.trigger("pause",this.frame)}async audio(t=2,o=48e3){var s;const i=this.duration.seconds*o,r=new OfflineAudioContext({sampleRate:o,length:i,numberOfChannels:t}).createBuffer(t,i,o);for(const l of this.findClips(wa)){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,o),p=m.numberOfChannels-1;for(let h=0;h<t;h++){const v=r.getChannelData(h),y=m.getChannelData(h>p?p:h);for(let E=0;E<v.length-1;E++)E<c+d||E>c+u||E-c<0||(v[E]+=(y[E-c]??0)*l.volume,v[E]>1&&(v[E]=1),v[E]<-1&&(v[E]=-1));r.getChannelData(h).set(v)}}catch{}}return r}time(t){const o=Bn(this.frame),i=t!=null&&t.hours?11:14,r=t!=null&&t.milliseconds?23:19;return new Date(o).toISOString().slice(i,r)+" / "+new Date(this.duration.millis).toISOString().slice(i,r)}removeTrack(t){const o=this.tracks.findIndex(i=>i.id==t.id);if(t.view.parent&&this.stage.removeChild(t.view),o!=null&&o>=0)return this.tracks.splice(o,1),this.trigger("detach",void 0),t.off("*"),t}async ticker(){const t=1e3/ho;let o=performance.now(),i=0;do{const r=await new Promise(requestAnimationFrame);r-o<t-i||(i=Math.min(t,i+r-o-t),o=r,this.computeFrame())}while(this.frame<=this.duration.frames&&this.playing);this.playing&&this.seek(0)}update(){this._duration.frames=Math.max(...this.tracks.filter(t=>!t.disabled).map(t=>{var o;return((o=t.stop)==null?void 0:o.frames)??0}),0),this.computeFrame()}}function hh(a,n){const t=new Uint8Array(19);return t[0]=79,t[1]=112,t[2]=117,t[3]=115,t[4]=72,t[5]=101,t[6]=97,t[7]=100,t[8]=1,t[9]=n,t[10]=0,t[11]=0,t[12]=a&255,t[13]=a>>8&255,t[14]=a>>16&255,t[15]=a>>24&255,t[16]=0,t[17]=0,t[18]=0,t}const Fi=[8e3,12e3,16e3,24e3,48e3],vh="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.wasm",gh="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.js";class yh{constructor(n){L(this,"output");L(this,"error");L(this,"config");L(this,"encoder");L(this,"opus");L(this,"meta");this.output=n.output,this.error=n.error}async configure(n){const t=await import(gh),{numberOfChannels:o,sampleRate:i}=this.config=n;if(!Fi.includes(i))throw new da({code:"sampleRateNotSupported",message:`Unsupported sample rate, supported: ${Fi.join()}`});this.opus=await t.default({locateFile(r,s){return r.endsWith(".wasm")?vh:s+r}}),this.encoder=this.opus._opus_encoder_create(i,o,2048),this.meta={decoderConfig:{codec:"opus",description:hh(i,o).buffer,numberOfChannels:o,sampleRate:i}}}encode({data:n,numberOfFrames:t,timestamp:o=0}){if(!this.encoder||!this.opus||!this.config||!this.meta)throw new da({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,p=this.opus._malloc(m),h=this.opus._opus_encode(this.encoder,u,s,p,m);if(h>0){const v=new Uint8Array(this.opus.HEAPU8.subarray(p,p+h));this.output({data:v,timestamp:o,type:"key",duration:c},this.meta)}else this.error(new DOMException("PCM chunk could not be encoded"));this.opus._free(u),this.opus._free(p),l+=s,o+=c}}}function wh(a){const n=Fi;let t=48e3;for(const o of n)Math.abs(a-o)<Math.abs(a-t)&&(t=o);return t}class bh{constructor(n,t){L(this,"canvas");L(this,"muxer");L(this,"videoEncoder");L(this,"frame",0);L(this,"sampleRate");L(this,"numberOfChannels");L(this,"videoBitrate");L(this,"gpuBatchSize");L(this,"fps");L(this,"height");L(this,"width");L(this,"audio");this.canvas=n,this.width=n.width,this.height=n.height,this.fps=(t==null?void 0:t.fps)??30,this.sampleRate=wh((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 mf({height:Math.round(this.height),width:Math.round(this.width),bitrate:this.videoBitrate,fps:this.fps});this.muxer=new xl({target:new Ji,video:{...n[0],codec:"avc"},firstTimestampBehavior:"offset",fastStart:"in-memory",audio:this.audio?{numberOfChannels:this.numberOfChannels,sampleRate:this.sampleRate,codec:"opus"}:void 0});const t={output:(o,i)=>{i&&this.muxer.addVideoChunk(o,i)},error:console.error};this.videoEncoder=new VideoEncoder(t),this.videoEncoder.configure(n[0])}async encodeVideo(n){var o;this.videoEncoder||await this.init(),this.videoEncoder.encodeQueueSize>this.gpuBatchSize&&await new Promise(i=>{this.videoEncoder.ondequeue=()=>i(null)});const t=new VideoFrame(n??this.canvas,{timestamp:Math.floor(this.frame/this.fps*1e6),duration:Math.floor(1e6/this.fps)});(o=this.videoEncoder)==null||o.encode(t,{keyFrame:this.frame%(3*this.fps)==0}),t.close(),this.frame++}async encodeAudio(n){if(!this.audio)throw new da({code:"initializationError",message:"Encoder must be initialized using {audio: true} to use this method"});this.muxer||await this.init();const t=uf(n,this.sampleRate,this.numberOfChannels),o=new yh({output:(i,r)=>{var s;(s=this.muxer)==null||s.addAudioChunkRaw(i.data,i.type,i.timestamp,i.duration,r)},error:console.error});await o.configure({numberOfChannels:this.numberOfChannels,sampleRate:this.sampleRate}),o.encode({data:df(t),numberOfFrames:t.length})}async blob(){var t,o,i;await((t=this.videoEncoder)==null?void 0:t.flush()),(o=this.muxer)==null||o.finalize();const n=(i=this.muxer)==null?void 0:i.target.buffer;if(!n)throw new da({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 kh(a){var o,i;const n=(o=a.metadata)==null?void 0:o.source_url;if(n)return n;const t=(i=a.source)==null?void 0:i.media_uuid;if(t){if(typeof window<"u"){const r=window;if(r.MEDIABLES_MEDIA_URLS&&r.MEDIABLES_MEDIA_URLS[t])return r.MEDIABLES_MEDIA_URLS[t]}if(!t.startsWith("temp-"))try{if(typeof fetch<"u"){const r=await fetch(`/api/media/${t}`);if(r.ok){const s=await r.json();return s.playback_url||s.url||void 0}}}catch{}}}function Mt(a,n){if(typeof a=="number"&&Number.isFinite(a))return a;if(typeof a=="string"){const t=Number(a);if(Number.isFinite(t))return t}return n}function Lo(a){return a>5?a/100:a}function Bt(a,n,t){return Math.min(t,Math.max(n,a))}function ht(){return new Je.ColorMatrixFilter}function xh(a,n){switch(a){case"brightness":{const t=ht(),o=Mt(n.value??n.brightness,1);return t.brightness(Bt(Lo(o),0,5),!1),t}case"contrast":{const t=ht(),o=Mt(n.value??n.contrast,1);return t.contrast(Bt(Lo(o),0,5),!1),t}case"saturation":{const t=ht(),o=Mt(n.value??n.saturation,1);return t.saturate(Bt(Lo(o),0,5),!1),t}case"hue":{const t=ht(),o=Mt(n.degrees??n.value,0);return t.hue(Bt(o,-180,180),!1),t}case"blur":case"softFocus":{const t=a==="softFocus"?1:0,o=Mt(n.radius??n.blur??n.value,t);return new Je.BlurFilter({strength:Bt(o,0,32),quality:4})}case"grayscale":{const t=ht(),o=Bt(Mt(n.amount,100),0,100);return o<=0?null:(o>=100?t.desaturate():t.saturate(1-o/100,!1),t)}case"sepia":{if(Bt(Mt(n.amount,100),0,100)<=0)return null;const o=ht();return o.sepia(!1),o}case"invert":{if(Bt(Mt(n.amount,100),0,100)<=0)return null;const o=ht();return o.negative(!1),o}case"warmth":{const t=ht(),o=Bt(Mt(n.value,0),-50,50);return o>0?(t.sepia(!1),t.saturate(1+o/100,!1)):o<0&&t.hue(Math.abs(o)/50*-20,!1),t}case"tint":{const t=ht(),o=Bt(Mt(n.intensity,.3),0,1),i=typeof n.color=="string"?n.color:"#ff0000",r=i.startsWith("#")?i.slice(1):i;if(r.length===6){const s=parseInt(r.slice(0,2),16)/255,l=parseInt(r.slice(2,4),16)/255,c=parseInt(r.slice(4,6),16)/255;t.matrix=[1-o+o*s,0,0,0,0,0,1-o+o*l,0,0,0,0,0,1-o+o*c,0,0,0,0,0,1,0]}return t}case"vintage":{const t=ht();return t.sepia(!1),t.saturate(1.4,!1),t.contrast(1.1,!1),t}case"blackAndWhite":{const t=ht(),o=Bt(Lo(Mt(n.contrast,120)),.5,3);return t.desaturate(),t.contrast(o,!1),t}case"cinematic":{const t=ht();return t.contrast(1.2,!1),t.brightness(.95,!1),t.saturate(.85,!1),t}case"dramatic":{const t=ht();return t.contrast(1.4,!1),t.brightness(.9,!1),t.saturate(1.1,!1),t.sepia(!1),t}case"dreamy":{const t=ht();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=Je);class Ul{constructor(n=1920,t=1080,o=30,i){this.player=null,this.clips=new Map,this.clipTimelineStart=new Map,this.resizeObserver=null,this.recipeSourceDimensions=null,this.filterCache=new Map,this.animationFrameId=null,this.lastRenderedFrame=-1,this.fps=o,this.fitMode=(i==null?void 0:i.fitMode)??"contain",this.composition=new fh({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 o;const n=(o=this.player)==null?void 0:o.parentElement;if(!this.player||!n)return;const t=Math.min(n.clientWidth/this.composition.width,n.clientHeight/this.composition.height);this.player.style.width=`${this.composition.width}px`,this.player.style.height=`${this.composition.height}px`,this.player.style.transform=`translate(-50%, -50%) scale(${t})`,this.player.style.transformOrigin="center"}),this.resizeObserver.observe(this.player.parentElement??this.player))}async loadFromRecipe(n){var o,i,r;await this.initPromise,this.clips.clear(),this.recipeSourceDimensions=Number.isFinite((o=n.source)==null?void 0:o.original_width)&&n.source.original_width>0&&Number.isFinite((i=n.source)==null?void 0:i.original_height)&&n.source.original_height>0?{width:n.source.original_width,height:n.source.original_height}:null;const t=await kh(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 o,i;try{const r=n.url||t;if(!r)throw new Error("No video source URL available for clip");if(!r.startsWith("blob:")){if(!/^https?:/i.test(String(r)))return}const s=await((o=fn.from)==null?void 0:o.call(fn,r,{crossOrigin:"anonymous"}))??await fn.from(r),l=new Bi(s,{muted:n.muted||!1,scale:n.scale||1,position:"center"});let c=0,d=null;if(n.sourceIn!==void 0||n.sourceOut!==void 0){const p=Math.max(0,Math.floor((n.sourceIn||0)*this.fps)),h=n.sourceOut!==void 0?Math.max(p+1,Math.floor(n.sourceOut*this.fps)):null;c=p,d=h;try{if(l.offset=l.offset||{frames:0},l.offset.frames=p,h!==null){const v=Math.max(1,h-p);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 p=Math.max(1,d-c);u.offset=u.offset||{frames:0},u.offset.frames=c,u.duration=u.duration||{frames:p},u.duration.frames=p}catch{}const 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(p=>requestAnimationFrame(p)),this.applyFiltersToClip(n.id,n.filters))}catch{}}async addTextOverlay(n){try{const t=ct.fromFamily({family:n.fontFamily||"Arial",weight:n.fontWeight||"400"}),o=new An({text:n.content,font:t,fontSize:n.fontSize||34,position:n.position||"center",fillStyle:n.color||"#FFFFFF",textAlign:n.textAlign||"center",textBaseline:n.textBaseline||"middle"});if(n.animation){const r=n.animation.duration||1,s=0,l=r*this.fps,c=n.animation.easing||"linear";n.animation.type==="rotate"&&n.animation.rotation?o.rotation=new Ee([s,l],[n.animation.rotation.from,n.animation.rotation.to],{easing:c}):n.animation.type==="scale"&&n.animation.scale&&(o.scale=new Ee([s,l],[n.animation.scale.from,n.animation.scale.to],{easing:c}))}n.startTime&&n.startTime>0&&o.offsetBy(n.startTime*this.fps),n.duration&&o.subclip(0,n.duration*this.fps);const i=await this.composition.add(o);this.clips.set(n.id||`text-${Date.now()}`,i)}catch{}}applyFiltersToClip(n,t){const o=this.clips.get(n);if(!o)return;const i=this.filterCache.get(n)??new Map,r=new Set(t.map(c=>c.id));for(const[c,d]of i.entries())if(!r.has(c)){try{typeof d.instance.destroy=="function"&&d.instance.destroy()}catch{}i.delete(c)}const s=[];for(const c of t){const d=this.buildFilterSignature(c),u=i.get(c.id);let 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=o.view??o.sprite??o.displayObject??null;if("filters"in o)try{o.filters=s}catch{}if(l&&"filters"in l)try{l.filters=s}catch{}typeof o.enter=="function"&&o.enter()}buildFilterSignature(n){const t=typeof n.params=="object"&&n.params!==null?n.params:{},o=Object.keys(t).sort((i,r)=>i.localeCompare(r)).map(i=>[i,t[i]]);return JSON.stringify({filterId:n.filterId,intensity:n.intensity??1,params:o})}setClipFilters(n,t){this.applyFiltersToClip(n,t),this.composition.computeFrame()}createPixiFilter(n){const t=n.intensity??1,o=n.params||{};if(rt.getFilter(n.filterId)&&!rt.isFilterCompatibleWithMedia(n.filterId,"video"))return null;let r=Fd(n.filterId,o);return r||(r=xh(n.filterId,o)),r?(t!==1&&r&&(n.filterId==="colorOverlay"||n.filterId==="alpha"||("alpha"in r&&!o.alpha&&(r.alpha*=t),"strength"in r&&(r.strength*=t))),r):null}play(){this.composition.play(),this.startRenderLoop()}pause(){this.composition.pause(),this.composition.computeFrame()}seek(n){this.composition.seek(n)}seekToTime(n){this.composition.seek(n*this.fps)}get currentFrame(){return this.composition.frame}get currentTime(){return this.composition.time().seconds.toFixed(2)}get currentTimeInSeconds(){return this.composition.frame/this.fps}get duration(){return this.composition.duration.frames}get durationInSeconds(){return this.composition.duration.frames/this.fps}async export(n={}){var s,l,c,d,u,m,p,h,v;const t=n.fps??this.fps,o=this.composition.canvas??((l=(s=this.composition)==null?void 0:s.renderer)==null?void 0:l.view)??((u=(d=(c=this.composition)==null?void 0:c.app)==null?void 0:d.renderer)==null?void 0:u.view)??((p=(m=this.composition)==null?void 0:m.renderer)==null?void 0:p.canvas);if(!o)throw new Error("Export failed: composition canvas is not initialized");(h=n.onProgress)==null||h.call(n,0);const i=new bh(o,{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 o=this.clips.get(n);if(!o)return;const i=this.clipTimelineStart.get(n)||0,r=t-i;r!==0&&(o.offsetBy(r*this.fps),this.clipTimelineStart.set(n,t),this.composition.computeFrame())}setFitMode(n){this.fitMode=n,this.applyFitModeToClips()}applyFitModeToClips(){for(const n of this.clips.values())"scale"in n&&typeof n.scale<"u"&&this.applyFitToClip(n);this.composition.computeFrame()}applyFitToClip(n){var t,o;if(this.fitMode!=="none")try{const i=this.composition.width,r=this.composition.height,s=n.source,l=(s==null?void 0:s.width)??(s==null?void 0:s.videoWidth)??((t=this.recipeSourceDimensions)==null?void 0:t.width),c=(s==null?void 0:s.height)??(s==null?void 0:s.videoHeight)??((o=this.recipeSourceDimensions)==null?void 0:o.height);if(!l||!c)return;const d=Math.min(i/l,r/c),u=Math.max(i/l,r/c),m=this.fitMode==="contain"?d:u;n.scale=m}catch{}}trimClip(n,t,o){const i=this.clips.get(n);if(!i)return;const r=Math.max(0,Math.floor(t*this.fps)),s=Math.max(r+1,Math.floor(o*this.fps));try{i.offset=i.offset||{frames:0},i.offset.frames=r,i.duration=i.duration||{frames:s-r},i.duration.frames=s-r,this.composition.computeFrame()}catch{}}resolveSourceFrame(n){var t,o;for(const[i,r]of this.clips.entries()){const s=this.clipTimelineStart.get(i)||0,l=Math.floor(s*this.fps),c=((t=r.duration)==null?void 0:t.frames)??Math.round(r.duration.seconds*this.fps),d=l+c;if(n>=l&&n<d){const u=n-l;return{sourceFrame:(((o=r.offset)==null?void 0:o.frames)??0)+u,clipId:i}}}return{sourceFrame:0,clipId:null}}}const Eh=["src"],Vh={class:"preview-controls"},Sh=["aria-label"],Ch={class:"time-display"},Nh={class:"current-time"},_h={class:"total-time"},Th={key:2,class:"loading-overlay"},Mh={key:3,class:"error-overlay"},Bh=e.defineComponent({__name:"VideoPreviewEngine",props:{mediaUuid:{},recipe:{},media:{},autoPlay:{type:Boolean,default:!1},enableEngine:{type:Boolean,default:!0},fitMode:{default:"contain"}},emits:["time-update","duration-change","play-state-change","error","engine-ready"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(),s=e.ref(),l=e.ref(!1),c=e.ref("Initializing..."),d=e.ref(null),u=e.ref(!1),m=e.ref(0),p=e.ref(0);let h=null;const v=e.computed(()=>!!t.enableEngine&&!!t.recipe),y=e.computed(()=>{switch(t.fitMode){case"cover":return"cover";case"none":return"none";default:return"contain"}}),E=e.computed(()=>{var k,T;return(k=t.media)!=null&&k.url?t.media.url:(((T=t.media)==null?void 0:T.file)instanceof File,"")});async function _(){var k,T,F;if(!(!r.value||!t.recipe))try{l.value=!0,c.value="Initializing video engine...";const A=((k=t.recipe.source)==null?void 0:k.original_width)||1920,R=((T=t.recipe.source)==null?void 0:T.original_height)||1080,j=((F=t.recipe.output)==null?void 0:F.fps)||30;h=new Ul(A,R,j,{fitMode:t.fitMode}),h.attachPlayer(r.value),c.value="Loading composition...",await h.loadFromRecipe(t.recipe),p.value=h.durationInSeconds,o("duration-change",p.value),C(),l.value=!1,o("engine-ready",h),t.autoPlay&&(h.play(),u.value=!0)}catch(A){const R=A instanceof Error?A.message:String(A);d.value=`Failed to initialize: ${R}`,l.value=!1}}function C(){if(!h)return;const k=setInterval(()=>{h&&u.value&&(m.value=h.currentTimeInSeconds,o("time-update",m.value))},100);O.value=k}function w(){v.value&&h?(u.value?h.pause():h.play(),u.value=!u.value,o("play-state-change",u.value)):s.value&&(u.value?s.value.pause():s.value.play(),u.value=!u.value,o("play-state-change",u.value))}function f(k){const T=Math.floor(k/60),F=Math.floor(k%60);return`${T}:${F.toString().padStart(2,"0")}`}function x(){d.value=null,v.value&&_()}function $(){!v.value&&s.value&&(p.value=s.value.duration,o("duration-change",p.value))}function N(){!v.value&&s.value&&(m.value=s.value.currentTime,o("time-update",m.value))}function g(){u.value=!1,o("play-state-change",!1)}function S(k){d.value="Failed to load video",o("error",d.value)}e.onMounted(()=>{v.value&&t.recipe&&_()}),e.onUnmounted(()=>{h&&(h.destroy(),h=null),O.value&&(clearInterval(O.value),O.value=null),s.value&&(s.value.pause(),s.value.removeAttribute("src"),s.value.load())}),e.watch(()=>t.recipe,async k=>{if(v.value&&k)if(h)try{await h.loadFromRecipe(k),p.value=h.durationInSeconds,o("duration-change",p.value)}catch{}else await _()}),e.watch(()=>t.enableEngine,async k=>{k?await _():h&&(O.value&&(clearInterval(O.value),O.value=null),h.destroy(),h=null)}),e.watch(()=>t.fitMode,async k=>{if(!(!v.value||!h))try{h.setFitMode(k||"contain")}catch{}});const O=e.ref(null);return(k,T)=>(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:E.value,onLoadedmetadata:$,onTimeupdate:N,onEnded:g,onError:S,style:e.normalizeStyle({width:"100%",height:"100%",objectFit:y.value}),playsinline:"",controls:""},null,44,Eh)),e.createElementVNode("div",Vh,[e.createElementVNode("button",{class:"play-button",onClick:w,"aria-label":u.value?"Pause":"Play"},[e.createVNode(e.unref(B.IonIcon),{icon:u.value?e.unref(tl):e.unref(ol)},null,8,["icon"])],8,Sh),e.createElementVNode("div",Ch,[e.createElementVNode("span",Nh,e.toDisplayString(f(m.value)),1),T[0]||(T[0]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",_h,e.toDisplayString(f(p.value)),1)])]),l.value?(e.openBlock(),e.createElementBlock("div",Th,[e.createVNode(e.unref(B.IonSpinner),{name:"crescent"}),e.createElementVNode("p",null,e.toDisplayString(c.value),1)])):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("div",Mh,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Wi)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(d.value),1),e.createElementVNode("button",{onClick:x},"Retry")])):e.createCommentVNode("",!0)],512))}}),ks=Me(Bh,[["__scopeId","data-v-7e604791"]]),Ih=["aria-label"],Fh=["aria-label"],Rh={class:"clip-content"},$h={key:0,class:"clip-thumbnail"},Dh=["src","alt"],Uh={class:"clip-waveform"},Oh={class:"clip-info"},Ah={class:"clip-label"},Lh={class:"clip-duration"},zh={key:1,class:"filter-indicators"},Ph={key:2,class:"speed-indicator"},jh={key:0,class:"selection-overlay"},Wh=e.defineComponent({__name:"TimelineClip",props:{clip:{},scale:{},scrollOffset:{default:0},selected:{type:Boolean,default:!1},isMobile:{type:Boolean,default:!1}},emits:["select","trim-start","trim-end","drag","trim-start-abs","trim-end-abs","drag-abs"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(!1),s=e.ref(null),l=e.ref(0),c=e.ref(0),d=e.computed(()=>{const S=(t.clip.timelineEnd-t.clip.timelineStart)*t.scale;return{left:`${t.clip.timelineStart*t.scale-t.scrollOffset}px`,width:`${S}px`}}),u=e.computed(()=>t.clip.label||`Clip ${t.clip.id.slice(-4)}`),m=e.computed(()=>{const g=t.clip.timelineEnd-t.clip.timelineStart;return v(g)}),p=e.computed(()=>t.clip.filters&&t.clip.filters.length>0),h=e.computed(()=>t.clip.filters||[]);function v(g){if(g<1)return`${Math.round(g*30)}f`;if(g<60)return`${g.toFixed(1)}s`;{const S=Math.floor(g/60),O=Math.floor(g%60);return`${S}:${O.toString().padStart(2,"0")}`}}function y(g){return!g||typeof g!="string"?Qr:g.includes("color")||g.includes("brightness")?an:g.includes("blur")?cu:g.includes("style")?eo:g.includes("effect")?on:Qr}function E(){r.value||o("select")}function _(g){g.button===0&&(f("move",g.clientX),g.preventDefault())}function C(g){if(g.touches.length!==1)return;const S=g.touches[0];f("move",S.clientX),g.preventDefault()}function w(g,S){const O="touches"in S?S.touches[0].clientX:S.clientX;s.value=g==="start"?"trim-start":"trim-end",f(s.value,O),S.preventDefault(),S.stopPropagation()}function f(g,S){r.value=!0,s.value=g,l.value=S,g==="move"?c.value=t.clip.timelineStart:g==="trim-start"?c.value=t.clip.sourceIn:g==="trim-end"&&(c.value=t.clip.sourceOut),document.addEventListener("mousemove",x),document.addEventListener("mouseup",$),document.addEventListener("touchmove",x),document.addEventListener("touchend",$),t.selected||o("select")}function x(g){if(!r.value||!s.value)return;const S="touches"in g?g.touches[0].clientX:g.clientX,k=S-l.value;s.value==="move"?(o("drag",k),o("drag-abs",S)):s.value==="trim-start"?(o("trim-start",k),o("trim-start-abs",S)):s.value==="trim-end"&&(o("trim-end",k),o("trim-end-abs",S))}function $(){r.value=!1,s.value=null,document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",$),document.removeEventListener("touchmove",x),document.removeEventListener("touchend",$)}function N(){if(!i.value)return;const g=i.value,S=g.getContext("2d");if(!S)return;g.width=g.clientWidth*window.devicePixelRatio,g.height=g.clientHeight*window.devicePixelRatio,S.scale(window.devicePixelRatio,window.devicePixelRatio),S.strokeStyle="rgba(255, 255, 255, 0.3)",S.lineWidth=1,S.beginPath();const O=g.clientWidth,k=g.clientHeight,T=k/2;S.moveTo(0,T),S.lineTo(O,T);for(let F=0;F<O;F+=4){const A=Math.sin(F*.05)*(k*.3);S.moveTo(F,T-A),S.lineTo(F,T+A)}S.stroke()}return e.onMounted(()=>{N(),window.addEventListener("resize",N)}),e.onUnmounted(()=>{$(),window.removeEventListener("resize",N)}),(g,S)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-clip",{selected:g.selected,mobile:g.isMobile,"has-filters":p.value}]),style:e.normalizeStyle(d.value),onClick:E,onMousedown:_,onTouchstart:C},[e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:S[0]||(S[0]=e.withModifiers(O=>w("start",O),["stop"])),onTouchstart:S[1]||(S[1]=e.withModifiers(O=>w("start",O),["stop"])),"aria-label":`Trim start of ${g.clip.label||"clip"}`},[...S[4]||(S[4]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,Ih),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:S[2]||(S[2]=e.withModifiers(O=>w("end",O),["stop"])),onTouchstart:S[3]||(S[3]=e.withModifiers(O=>w("end",O),["stop"])),"aria-label":`Trim end of ${g.clip.label||"clip"}`},[...S[5]||(S[5]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,Fh),e.createElementVNode("div",Rh,[g.clip.thumbnail?(e.openBlock(),e.createElementBlock("div",$h,[e.createElementVNode("img",{src:g.clip.thumbnail,alt:g.clip.label||"Video clip"},null,8,Dh)])):e.createCommentVNode("",!0),e.createElementVNode("div",Uh,[e.createElementVNode("canvas",{ref_key:"waveformCanvas",ref:i},null,512)]),e.createElementVNode("div",Oh,[e.createElementVNode("span",Ah,e.toDisplayString(u.value),1),e.createElementVNode("span",Lh,e.toDisplayString(m.value),1)]),p.value?(e.openBlock(),e.createElementBlock("div",zh,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,O=>(e.openBlock(),e.createBlock(e.unref(B.IonIcon),{key:O.id||O.filterId,icon:y(O.filterId||O.id),title:`Filter: ${O.filterId||O.id}`},null,8,["icon","title"]))),128))])):e.createCommentVNode("",!0),g.clip.speed&&g.clip.speed!==1?(e.openBlock(),e.createElementBlock("div",Ph,e.toDisplayString(g.clip.speed)+"x ",1)):e.createCommentVNode("",!0)]),g.selected?(e.openBlock(),e.createElementBlock("div",jh)):e.createCommentVNode("",!0)],38))}}),Zh=Me(Wh,[["__scopeId","data-v-943b6167"]]);class Ol{constructor(n=30){this.fps=30,this.fps=n}setFps(n){this.fps=n}async convertTimelineClipToEngine(n,t){const o=new Bi(t,{muted:n.muted||!1,scale:n.scale||1,position:"center"});if(n.sourceIn!==void 0||n.sourceOut!==void 0){const i=this.secondsToFrames(n.sourceIn||0),r=n.sourceOut?this.secondsToFrames(n.sourceOut):o.duration.frames;o.subclip(i,r)}return n.timelineStart&&n.timelineStart>0&&o.offsetBy(this.secondsToFrames(n.timelineStart)),n.transform&&this.applyTransformations(o,n.transform),o}convertEngineClipToTimeline(n,t,o){const i=this.framesToSeconds(n.duration.frames),r=n.offset?this.framesToSeconds(n.offset.frames):0;return{id:t,url:o,type:"video",timelineStart:r,timelineEnd:r+i,sourceIn:0,sourceOut:i,duration:i,muted:n.muted||!1,scale:n.scale.x||1}}async buildCompositionFromRecipe(n,t){var o;(o=t.clear)==null||o.call(t);for(const i of n.timeline)try{if(!i.url)continue;const r=await fn.from(i.url),s=await this.convertTimelineClipToEngine(i,r);await t.add(s)}catch{}n.duration&&(t.duration=ge.fromFrames(this.secondsToFrames(n.duration)))}extractTimelineFromComposition(n){const t=[];return(n.clips||[]).forEach((i,r)=>{var s,l;i instanceof Bi&&t.push(this.convertEngineClipToTimeline(i,`clip-${r}`,((s=i.source)==null?void 0:s.externalURL)||((l=i.source)==null?void 0:l.objectURL)||""))}),t}applyTransformations(n,t){(t.x!==void 0||t.y!==void 0)&&(n.x=t.x||0,n.y=t.y||0),t.rotation!==void 0&&(n.rotation=t.rotation),t.opacity!==void 0&&(n.alpha=t.opacity),t.scale!==void 0&&(n.scale={x:t.scale,y:t.scale})}secondsToFrames(n){return Math.round(n*this.fps)}framesToSeconds(n){return n/this.fps}framesToTime(n){const t=this.framesToSeconds(n),o=Math.floor(t/60),i=Math.floor(t%60),r=Math.floor(t%1*1e3);return`${o.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}.${r.toString().padStart(3,"0")}`}formatTime(n){const t=Math.floor(n/3600),o=Math.floor(n%3600/60),i=Math.floor(n%60);return`${t.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`}parseTime(n){const t=n.split(":");let o=0;if(t.length===2){const[i,r]=t;o=parseInt(i)*60+parseFloat(r)}else if(t.length===3){const[i,r,s]=t;o=parseInt(i)*3600+parseInt(r)*60+parseFloat(s)}else o=parseFloat(n);return o}timeToFrames(n){const t=n.split(":");let o=0;if(t.length===2){const[i,r]=t;o=parseInt(i)*60+parseFloat(r)}else if(t.length===3){const[i,r,s]=t;o=parseInt(i)*3600+parseInt(r)*60+parseFloat(s)}else o=parseFloat(n);return this.secondsToFrames(o)}}const Xh={class:"time-markers"},Hh=["aria-label","title"],Gh={key:0,class:"timeline-scrollbar"},Jh=e.defineComponent({__name:"VideoTimeline",props:{playhead:{},clips:{},duration:{},zoomLevel:{default:50},isMobile:{type:Boolean,default:!1},selectedClipId:{},fps:{default:30},useFrameMode:{type:Boolean,default:!1},sensitivity:{default:.25}},emits:["update:playhead","trim","split","clip-select","clip-move","toggle-frame-mode"],setup(a,{emit:n}){const t=a,o=e.computed(()=>t.isMobile===!0),i=n,r=e.ref(),s=e.ref(t.selectedClipId||null),l=e.ref(!1),c=e.ref(0),d=e.ref(),u=e.ref(0),m=e.computed(()=>t.selectedClipId??s.value);e.watch(()=>t.selectedClipId,P=>{P!==void 0&&(s.value=P)});const p=new Ol(t.fps),h=e.ref(!1),v=e.ref(null),y=e.ref(0),E=e.ref(0),_=e.ref(0),C=e.ref(0),w=e.ref(0),f=e.ref(!1),x=e.ref(0),$=e.ref(t.zoomLevel),N=e.computed(()=>t.zoomLevel);function g(P){const J=t.clips.find(te=>te.id===P);if(!J)return null;const ee=t.clips.filter(te=>te.id!==P&&te.timelineStart>=J.timelineEnd-1e-9).map(te=>te.timelineStart);return ee.length?Math.min(...ee):null}function S(P){const J=P.sourceMaxOut??t.duration,ee=P.timelineStart+(J-P.sourceIn),te=g(P.id),pe=te!=null?Math.max(P.timelineStart,te):1/0;return Math.min(ee,pe)}function O(P){const J=P.sourceMinIn??0,te=(P.sourceMaxOut??t.duration)-J,pe=P.sourceIn-J;return{left:`${(P.timelineStart-pe)*N.value-c.value}px`,width:`${te*N.value}px`,top:"0px",height:"80px",opacity:m.value===P.id?.25:.15}}const k=e.computed(()=>t.useFrameMode?t.zoomLevel:t.zoomLevel/t.fps),T=e.computed(()=>p.secondsToFrames(t.duration)),F=e.computed(()=>t.useFrameMode?T.value*k.value:t.duration*N.value),A=e.computed(()=>{var P;return u.value||((P=r.value)==null?void 0:P.clientWidth)||800}),R=e.computed(()=>F.value>A.value),j=e.computed(()=>Math.max(0,F.value-A.value)),K=e.computed(()=>c.value>0),I=e.computed(()=>c.value<j.value),D=e.computed(()=>t.useFrameMode?p.secondsToFrames(t.playhead)*k.value-c.value:t.playhead*N.value-c.value),Z=e.computed(()=>{const P=Math.max(50,A.value/F.value*A.value),J=c.value/j.value*(A.value-P);return{width:`${P}px`,left:`${J}px`}}),W=e.computed(()=>{const P=[],J=oe();for(let ee=0;ee<=t.duration;ee+=J){const te=ee*N.value-c.value;te>=-50&&te<=A.value+50&&P.push({position:te,label:we(ee),time:ee})}return P});function oe(){const J=80/N.value;return J<=1?1:J<=5?5:J<=10?10:J<=30?30:J<=60?60:Math.ceil(J/60)*60}function we(P){if(t.useFrameMode)return`F${p.secondsToFrames(P)}`;{const J=Math.floor(P/60),ee=Math.floor(P%60),te=Math.floor(P%1*t.fps);return N.value>100?`${J}:${ee.toString().padStart(2,"0")}:${te.toString().padStart(2,"0")}`:`${J}:${ee.toString().padStart(2,"0")}`}}function Ce(P){const J=r.value.getBoundingClientRect();let te=(P.clientX-J.left+c.value)/N.value;const pe=t.clips.find(ve=>te>=ve.timelineStart&&te<=ve.timelineEnd);if(pe)te=Math.max(pe.timelineStart,Math.min(pe.timelineEnd,te));else if(t.selectedClipId){const ve=t.clips.find(Fe=>Fe.id===t.selectedClipId);if(ve){const Fe=Math.abs(te-ve.timelineStart),Oe=Math.abs(te-ve.timelineEnd);te=Fe<Oe?ve.timelineStart:ve.timelineEnd}}else te=Math.max(0,Math.min(te,t.duration));i("update:playhead",te)}function ne(P){if(!R.value)return;const J=Math.abs(P.deltaX)>Math.abs(P.deltaY)?P.deltaX:P.deltaY;J!==0&&(P.preventDefault(),c.value=Math.max(0,Math.min(j.value,c.value+J)))}function M(P){if(P.touches.length===2){f.value=!0;const J=P.touches[0],ee=P.touches[1];x.value=Math.hypot(ee.clientX-J.clientX,ee.clientY-J.clientY),$.value=t.zoomLevel}else P.touches.length===1&&(_.value=P.touches[0].clientX,C.value=P.touches[0].clientY,w.value=_.value)}function z(P){if(f.value&&P.touches.length===2){const J=P.touches[0],ee=P.touches[1],pe=Math.hypot(ee.clientX-J.clientX,ee.clientY-J.clientY)/x.value;Math.max(10,Math.min(200,$.value*pe)),i("update:playhead",t.playhead)}else if(P.touches.length===1&&!f.value){const J=P.touches[0],ee=w.value-J.clientX;Math.abs(ee)>Math.abs(J.clientY-C.value)&&(P.preventDefault(),c.value=Math.max(0,Math.min(F.value-A.value,c.value+ee)),w.value=J.clientX)}}function me(){f.value=!1}function ae(P){const J=P.target;if(J.closest(".playhead-handle"))return;const ee=P.button===1,te=!!J.closest(".video-track");(ee||!te&&R.value)&&Y(P)}function Y(P){h.value=!0,v.value="pan",y.value=P.clientX,E.value=c.value,document.addEventListener("mousemove",se),document.addEventListener("mouseup",be)}function Te(P){P.preventDefault(),P.stopPropagation(),h.value=!0,v.value="playhead";const J="touches"in P?P.touches[0].clientX:P.clientX;y.value=J,E.value=t.playhead,"touches"in P?(document.addEventListener("touchmove",se),document.addEventListener("touchend",be)):(document.addEventListener("mousemove",se),document.addEventListener("mouseup",be))}function ue(P){P.preventDefault(),P.stopPropagation(),h.value=!0,v.value="scrollbar";const J="touches"in P?P.touches[0].clientX:P.clientX;y.value=J,E.value=c.value,"touches"in P?(document.addEventListener("touchmove",se),document.addEventListener("touchend",be)):(document.addEventListener("mousemove",se),document.addEventListener("mouseup",be))}function se(P){if(!h.value)return;const ee=("touches"in P?P.touches[0].clientX:P.clientX)-y.value;if(v.value==="playhead"){const te=ee/N.value;let pe=E.value+te;if(t.selectedClipId){const ve=t.clips.find(Fe=>Fe.id===t.selectedClipId);ve?pe=Math.max(ve.timelineStart,Math.min(ve.timelineEnd,pe)):pe=Math.max(0,Math.min(t.duration,pe))}else{const ve=t.clips.find(Fe=>t.playhead>=Fe.timelineStart&&t.playhead<=Fe.timelineEnd);ve?pe=Math.max(ve.timelineStart,Math.min(ve.timelineEnd,pe)):pe=Math.max(0,Math.min(t.duration,pe))}i("update:playhead",pe)}else if(v.value==="scrollbar"){const te=ee/A.value*F.value;c.value=Math.max(0,Math.min(j.value,E.value+te))}else if(v.value==="pan"){const te=E.value-ee;c.value=Math.max(0,Math.min(j.value,te))}}function be(){h.value=!1,v.value=null,document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",be),document.removeEventListener("touchmove",se),document.removeEventListener("touchend",be)}function ie(P){s.value=s.value===P?null:P,i("clip-select",s.value)}function le(P,J){const ee=t.clips.find(pe=>pe.id===P);if(!ee||Math.abs(J)<2)return;const te=J/N.value*t.sensitivity;if(t.useFrameMode){const pe=p.secondsToFrames(ee.sourceIn),ve=p.secondsToFrames(te),Fe=Math.max(0,pe+ve),Oe=p.framesToSeconds(Fe);i("trim",P,"start",Oe)}else{const pe=Math.max(0,ee.sourceIn+te);i("trim",P,"start",pe)}}function ke(P,J){const ee=t.clips.find(xe=>xe.id===P);if(!ee||!r.value)return;const te=r.value.getBoundingClientRect(),pe=J-te.left,ve=80;if(pe<ve)c.value=Math.max(0,c.value-8);else if(pe>te.width-ve){const xe=Math.max(0,F.value-A.value);c.value=Math.min(xe,c.value+8)}const Fe=pe+c.value,Oe=1/t.fps;let H=Fe/N.value;H=Math.max(0,Math.min(H,ee.timelineEnd-Oe));let re=ee.sourceIn+(H-ee.timelineStart);re=Math.round(re*t.fps)/t.fps,i("trim",P,"start",re)}function Ve(P,J){const ee=t.clips.find(Ne=>Ne.id===P);if(!ee||!r.value)return;const te=r.value.getBoundingClientRect(),pe=J-te.left,ve=80;if(pe<ve)c.value=Math.max(0,c.value-8);else if(pe>te.width-ve){const Ne=Math.max(0,F.value-A.value);c.value=Math.min(Ne,c.value+8)}const Fe=pe+c.value,Oe=1/t.fps,H=S(ee);let re=Fe/N.value;re=Math.max(ee.timelineStart+Oe,Math.min(re,H));let xe=ee.sourceIn+(re-ee.timelineStart);xe=Math.round(xe*t.fps)/t.fps,i("trim",P,"end",xe)}function et(P,J){const ee=t.clips.find(H=>H.id===P);if(!ee||!r.value)return;const te=r.value.getBoundingClientRect(),ve=J-te.left+c.value,Fe=ee.timelineEnd-ee.timelineStart;let Oe=ve/N.value;Oe=Math.max(0,Math.min(Oe,t.duration-Fe)),Oe=Math.round(Oe*t.fps)/t.fps,i("clip-move",P,Oe)}function We(P,J){const ee=t.clips.find(ve=>ve.id===P);if(!ee||Math.abs(J)<2)return;const te=J/N.value*t.sensitivity,pe=ve=>Math.max(0,Math.round(ve*t.fps)/t.fps);if(t.useFrameMode){const ve=p.secondsToFrames(ee.sourceOut),Fe=p.secondsToFrames(te),Oe=S(ee),H=ee.sourceIn+(Oe-ee.timelineStart),re=p.secondsToFrames(H),xe=Math.min(re,ve+Fe),Ne=p.framesToSeconds(xe);i("trim",P,"end",Ne)}else{const ve=S(ee),Fe=ee.sourceIn+(ve-ee.timelineStart),Oe=Math.min(Fe,ee.sourceOut+te),H=pe(Oe);i("trim",P,"end",H)}}function fe(P,J){const ee=t.clips.find(ve=>ve.id===P);if(!ee||Math.abs(J)<2)return;const te=J/N.value*t.sensitivity,pe=ve=>Math.max(0,Math.round(ve*t.fps)/t.fps);if(t.useFrameMode){const ve=p.secondsToFrames(ee.timelineStart),Fe=p.secondsToFrames(te),Oe=Math.max(0,ve+Fe),H=p.framesToSeconds(Oe);i("clip-move",P,H)}else{const ve=Math.max(0,ee.timelineStart+te),Fe=pe(ve);i("clip-move",P,Fe)}}return e.watch(()=>t.playhead,P=>{const J=P*N.value;J<c.value+50?c.value=Math.max(0,J-50):J>c.value+A.value-50&&(c.value=Math.min(j.value,J-A.value+50))}),e.onMounted(()=>{const P=new ResizeObserver(J=>{J[0]&&(u.value=Math.round(J[0].contentRect.width))});r.value&&P.observe(r.value),e.onUnmounted(()=>P.disconnect())}),e.onUnmounted(()=>{be()}),e.watch([F,A],()=>{c.value>j.value&&(c.value=j.value)}),(P,J)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-timeline",{mobile:o.value}]),ref_key:"timelineRef",ref:r,onWheel:ne},[e.createElementVNode("div",{class:"timeline-ruler",onClick:Ce},[e.createElementVNode("div",Xh,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.value,ee=>(e.openBlock(),e.createElementBlock("span",{key:ee.position,class:"time-marker",style:e.normalizeStyle({left:`${ee.position}px`})},e.toDisplayString(ee.label),5))),128))])]),e.createElementVNode("div",{class:e.normalizeClass(["timeline-content",{"is-pannable":R.value,"is-panning":h.value&&v.value==="pan","overflow-left":K.value,"overflow-right":I.value}]),onTouchstart:M,onTouchmove:z,onTouchend:me,onMousedown:ae},[e.createElementVNode("div",{class:"video-track",ref_key:"trackRef",ref:d},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(P.clips,ee=>(e.openBlock(),e.createElementBlock("div",{key:`${ee.id}-extent`,class:"clip-extent",style:e.normalizeStyle(O(ee)),"aria-hidden":"true"},null,4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(P.clips,ee=>(e.openBlock(),e.createBlock(Zh,{key:ee.id,clip:ee,scale:N.value,"scroll-offset":c.value,selected:m.value===ee.id,"is-mobile":o.value,onSelect:te=>ie(ee.id),onTrimStart:te=>le(ee.id,te),onTrimEnd:te=>We(ee.id,te),onDrag:te=>fe(ee.id,te),onTrimStartAbs:te=>ke(ee.id,te),onTrimEndAbs:te=>Ve(ee.id,te),onDragAbs:te=>et(ee.id,te)},null,8,["clip","scale","scroll-offset","selected","is-mobile","onSelect","onTrimStart","onTrimEnd","onDrag","onTrimStartAbs","onTrimEndAbs","onDragAbs"]))),128))],512),e.createElementVNode("div",{class:"playhead",style:e.normalizeStyle({left:`${D.value}px`}),onMousedown:Te,onTouchstart:Te},[...J[1]||(J[1]=[e.createElementVNode("div",{class:"playhead-handle"},[e.createElementVNode("div",{class:"playhead-line"})],-1)])],36),l.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"split-indicator",style:e.normalizeStyle({left:`${D.value}px`})},null,4)):e.createCommentVNode("",!0),o.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"frame-mode-toggle",onClick:J[0]||(J[0]=ee=>P.$emit("toggle-frame-mode")),"aria-label":P.useFrameMode?"Switch to time mode":"Switch to frame mode",title:P.useFrameMode?"Switch to time mode":"Switch to frame mode"},e.toDisplayString(P.useFrameMode?"F":"T"),9,Hh))],34),R.value?(e.openBlock(),e.createElementBlock("div",Gh,[e.createElementVNode("div",{class:"scrollbar-thumb",style:e.normalizeStyle(Z.value),onMousedown:ue,onTouchstart:ue},null,36)])):e.createCommentVNode("",!0)],34))}}),xs=Me(Jh,[["__scopeId","data-v-6fa3968c"]]),Yh={class:"control-group zoom-controls"},Kh={class:"zoom-slider"},qh=["value"],Qh={class:"control-group playback-controls"},e0=["aria-label"],t0={key:0,class:"control-group speed-control"},n0=["value"],o0=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(a,{emit:n}){const t=n;function o(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",Yh,[e.createElementVNode("button",{class:"control-button zoom-button",onClick:m[0]||(m[0]=p=>u.$emit("zoom-out")),"aria-label":"Zoom out"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Vu)},null,8,["icon"])]),e.createElementVNode("div",Kh,[e.createElementVNode("input",{type:"range",value:u.zoomLevel,onInput:o,min:"10",max:"200",step:"5","aria-label":"Timeline zoom"},null,40,qh)]),e.createElementVNode("button",{class:"control-button zoom-button",onClick:m[1]||(m[1]=p=>u.$emit("zoom-in")),"aria-label":"Zoom in"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Yd)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:i,"aria-label":"Fit timeline to window"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(lu)},null,8,["icon"]),m[3]||(m[3]=e.createElementVNode("span",{class:"control-label"},"Fit",-1))])]),e.createElementVNode("div",Qh,[e.createElementVNode("button",{class:"control-button",onClick:l,"aria-label":"Skip to start"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(xu)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:s,"aria-label":"Previous frame"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(yu)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button play-button",onClick:m[2]||(m[2]=p=>u.$emit("play-pause")),"aria-label":u.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(B.IonIcon),{icon:u.isPlaying?e.unref(nl):e.unref(al)},null,8,["icon"])],8,e0),e.createElementVNode("button",{class:"control-button",onClick:r,"aria-label":"Next frame"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(ku)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:c,"aria-label":"Skip to end"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Eu)},null,8,["icon"])])]),u.isMobile?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",t0,[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,n0)]))],2))}}),a0=Me(o0,[["__scopeId","data-v-7bf65ab9"]]),i0={key:0,class:"category-section"},r0={class:"category-carousel-wrapper"},s0=["disabled"],l0=["onClick","data-testid","aria-label"],c0={class:"category-name"},d0=["disabled"],u0={class:"filter-section"},m0={class:"filter-carousel-wrapper"},p0=["disabled"],f0=["onClick","onKeydown","data-testid","aria-label"],h0=["onClick"],v0={class:"filter-preview"},g0={class:"filter-placeholder"},y0={class:"filter-name"},w0=["disabled"],b0={class:"carousel-pagination"},k0=["onClick"],x0={key:1,class:"filter-adjustments"},E0={class:"adjustment-header"},V0={class:"adjustment-actions"},S0={key:0},C0={key:0,class:"slider-control"},N0={class:"control-label"},_0={class:"slider-wrapper"},T0={class:"slider-value"},M0={key:1,class:"color-control"},B0={class:"control-label"},I0={class:"color-wrapper"},F0=["value","onInput","disabled"],R0={class:"color-value"},$0={key:2,class:"toggle-control"},D0={class:"control-label"},U0={key:3,class:"select-control"},O0={class:"control-label"},A0=["value","onChange","disabled"],L0=["value"],z0={key:1,class:"no-params"},P0=e.defineComponent({__name:"VideoFilterCarousel",props:{filters:{},activeFilters:{},thumbnailUrl:{},showCategories:{type:Boolean,default:!0},compact:{type:Boolean,default:!1}},emits:["apply-filter","remove-filter","update-param","preview-filter"],setup(a,{emit:n}){const t=a,o=n,i=e.ref("all"),r=e.ref(null),s=e.ref(0),l=e.ref(0),c=e.ref(new Map),d=e.ref(),u=e.ref(),m={all:on,adjust:Gn,color:an,blur:Do,light:Jn,effects:ti,stylize:eo,advanced:on,distortion:to,transform:to};function p(I){return I.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function h(I){return I.replace(/[-_]/g," ").replace(/\b\w/g,D=>D.toUpperCase())}function v(I){return m[I.toLowerCase()]??on}const y=e.computed(()=>{const I=Array.from(new Set(t.filters.map(D=>D.category).filter(D=>typeof D=="string"&&D.length>0))).sort((D,Z)=>D.localeCompare(Z));return[{id:"all",name:"All",icon:on},...I.map(D=>({id:D,name:h(D),icon:v(D)}))]}),E=e.computed(()=>i.value==="all"?t.filters:t.filters.filter(I=>I.category===i.value));e.watch(y,I=>{new Set(I.map(W=>W.id)).has(i.value)||(i.value="all");const Z=Math.max(0,I.length-3);s.value>Z&&(s.value=Z)},{immediate:!0});function _(I){var D;return((D=t.activeFilters)==null?void 0:D.has(I))||!1}function C(I){if(r.value=I,!_(I.id)&&(o("apply-filter",I),I.params&&I.params.length>0)){const D=new Map;I.params.forEach(Z=>{D.set(Z.id,Z.default)}),c.value.set(I.id,D)}o("preview-filter",I)}function w(I){var D;o("remove-filter",I),c.value.delete(I),((D=r.value)==null?void 0:D.id)===I&&(r.value=null)}function f(I){if(typeof I=="number"&&Number.isFinite(I))return I;if(typeof I=="string"){const D=Number(I);return Number.isFinite(D)?D:null}return null}function x(I,D){var M;const Z=t.filters.find(z=>z.id===I),W=Z==null?void 0:Z.params.find(z=>z.id===D),oe=(W==null?void 0:W.default)??0,we=z=>typeof oe=="number"?f(z)??oe:typeof oe=="boolean"?typeof z=="boolean"?z:oe:typeof z=="string"?z:oe,Ce=(M=t.activeFilters)==null?void 0:M.get(I);if(Ce&&Ce.params){const z=Ce.params[D];if(z!=null)return we(z)}const ne=c.value.get(I);if(ne){const z=ne.get(D);if(z!=null)return we(z)}return oe}function $(I,D,Z){var W;c.value.has(I)||c.value.set(I,new Map),(W=c.value.get(I))==null||W.set(D,Z),o("update-param",I,D,Z)}function N(I){if(typeof I=="boolean")return I?"On":"Off";if(typeof I=="string"){const Z=f(I);return Z===null?"0":Number.isInteger(Z)?Z.toString():Z.toFixed(2)}const D=f(I);return D===null?"0":Number.isInteger(D)?D.toString():D.toFixed(2)}function g(){if(r.value&&(o("apply-filter",r.value),r.value.params&&r.value.params.length>0)){const I=new Map;r.value.params.forEach(D=>{I.set(D.id,D.default)}),c.value.set(r.value.id,I)}}function S(I){const D=t.filters.find(Z=>Z.id===I);D&&D.params&&D.params.forEach(Z=>{$(I,Z.id,Z.default)})}function O(I){return{basic:Gn,color:an,blur:Do,light:Jn,effects:ti,stylize:eo,adjustment:Gn,"color-matrix":an,glow:on,distortion:to}[I]||on}function k(I){return{adjustment:Gn,brightness:Jn,contrast:Gn,saturation:an,blur:Do,"gaussian-blur":Do,"color-matrix":an,grayscale:eo,sepia:eo,vignette:to,glow:on,glitch:ti,godray:Jn,lightmap:Jn}[I.id]||O(I.category)}function T(){s.value>0&&(s.value--,K(d.value,s.value))}function F(){s.value<y.value.length-3&&(s.value++,K(d.value,s.value))}function A(){l.value>0&&(l.value--,K(u.value,l.value))}function R(){l.value<E.value.length-4&&(l.value++,K(u.value,l.value))}function j(I){l.value=I*4,K(u.value,l.value)}function K(I,D){var Z;if(I){const W=((Z=I.querySelector(".category-chip, .filter-card"))==null?void 0:Z.clientWidth)||100;I.scrollTo({left:D*(W+8),behavior:"smooth"})}}return(I,D)=>{var Z;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-filter-carousel-container",{compact:I.compact}])},[I.showCategories?(e.openBlock(),e.createElementBlock("div",i0,[e.createElementVNode("div",r0,[e.createElementVNode("button",{onClick:T,class:"carousel-nav carousel-nav-left",disabled:s.value===0,"aria-label":"Previous categories","data-testid":"btn-filter-category-prev"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Gr)},null,8,["icon"])],8,s0),e.createElementVNode("div",{ref_key:"categoryCarouselRef",ref:d,class:"category-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.value,W=>(e.openBlock(),e.createElementBlock("button",{key:W.id,onClick:oe=>i.value=W.id,class:e.normalizeClass(["category-chip",{active:i.value===W.id}]),"data-testid":`btn-filter-category-${p(W.id)}`,"aria-label":`Filter category ${W.name}`},[e.createVNode(e.unref(B.IonIcon),{icon:W.icon,class:"category-icon"},null,8,["icon"]),e.createElementVNode("span",c0,e.toDisplayString(W.name),1)],10,l0))),128))],512),e.createElementVNode("button",{onClick:F,class:"carousel-nav carousel-nav-right",disabled:s.value>=y.value.length-3,"aria-label":"Next categories","data-testid":"btn-filter-category-next"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Jr)},null,8,["icon"])],8,d0)])])):e.createCommentVNode("",!0),e.createElementVNode("div",u0,[e.createElementVNode("div",m0,[e.createElementVNode("button",{onClick:A,class:"carousel-nav carousel-nav-left",disabled:l.value===0,"aria-label":"Previous filters","data-testid":"btn-filter-carousel-prev"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Gr)},null,8,["icon"])],8,p0),e.createElementVNode("div",{ref_key:"filterCarouselRef",ref:u,class:"filter-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.value,W=>{var oe;return e.openBlock(),e.createElementBlock("div",{key:W.id,class:e.normalizeClass(["filter-card",{active:_(W.id),selected:((oe=r.value)==null?void 0:oe.id)===W.id}]),onClick:we=>C(W),onKeydown:[e.withKeys(we=>C(W),["enter"]),e.withKeys(e.withModifiers(we=>C(W),["prevent"]),["space"])],role:"button",tabindex:"0","data-testid":`btn-video-filter-${p(W.id)}`,"aria-label":`Select filter ${W.name}`},[_(W.id)?(e.openBlock(),e.createElementBlock("div",{key:0,class:"filter-checkmark",onClick:e.withModifiers(we=>w(W.id),["stop"])},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(qs)},null,8,["icon"])],8,h0)):e.createCommentVNode("",!0),e.createElementVNode("div",v0,[e.createElementVNode("div",g0,[e.createVNode(e.unref(B.IonIcon),{icon:k(W),class:"filter-icon"},null,8,["icon"])])]),e.createElementVNode("span",y0,e.toDisplayString(W.name),1)],42,f0)}),128))],512),e.createElementVNode("button",{onClick:R,class:"carousel-nav carousel-nav-right",disabled:l.value>=Math.max(0,E.value.length-4),"aria-label":"Next filters","data-testid":"btn-filter-carousel-next"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Jr)},null,8,["icon"])],8,w0)]),e.createElementVNode("div",b0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Math.ceil(E.value.length/4),(W,oe)=>(e.openBlock(),e.createElementBlock("span",{key:oe,class:e.normalizeClass(["pagination-dot",{active:Math.floor(l.value/4)===oe}]),onClick:we=>j(oe)},null,10,k0))),128))])]),r.value?(e.openBlock(),e.createElementBlock("div",x0,[e.createElementVNode("div",E0,[e.createElementVNode("h4",null,e.toDisplayString(r.value.name),1),e.createElementVNode("div",V0,[_(r.value.id)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,onClick:g,class:"apply-btn","data-testid":"btn-apply-selected-filter"}," Apply Filter ")),_(r.value.id)?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:D[0]||(D[0]=W=>w(r.value.id)),class:"remove-btn","data-testid":"btn-remove-selected-filter"}," Remove Filter ")):e.createCommentVNode("",!0),_(r.value.id)&&((Z=r.value.params)==null?void 0:Z.length)>0?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:D[1]||(D[1]=W=>S(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",S0,[(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",C0,[e.createElementVNode("label",N0,e.toDisplayString(W.label||W.id),1),e.createElementVNode("div",_0,[e.createVNode(e.unref(B.IonRange),{value:x(r.value.id,W.id),onIonChange:oe=>$(r.value.id,W.id,oe.detail.value),min:W.min,max:W.max,step:W.step||.01,color:"primary",class:"compact-slider",disabled:!_(r.value.id),"data-testid":`range-filter-${p(r.value.id)}-${p(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",T0,e.toDisplayString(N(x(r.value.id,W.id))),1)])])):W.type==="color"?(e.openBlock(),e.createElementBlock("div",M0,[e.createElementVNode("label",B0,e.toDisplayString(W.label||W.id),1),e.createElementVNode("div",I0,[e.createElementVNode("input",{type:"color",value:x(r.value.id,W.id),onInput:oe=>$(r.value.id,W.id,oe.target.value),disabled:!_(r.value.id),class:"color-input"},null,40,F0),e.createElementVNode("span",R0,e.toDisplayString(x(r.value.id,W.id)),1)])])):W.type==="toggle"?(e.openBlock(),e.createElementBlock("div",$0,[e.createElementVNode("label",D0,e.toDisplayString(W.label||W.id),1),e.createVNode(e.unref(B.IonToggle),{checked:!!x(r.value.id,W.id),onIonChange:oe=>$(r.value.id,W.id,oe.detail.checked),disabled:!_(r.value.id),color:"primary"},null,8,["checked","onIonChange","disabled"])])):W.type==="select"?(e.openBlock(),e.createElementBlock("div",U0,[e.createElementVNode("label",O0,e.toDisplayString(W.label||W.id),1),e.createElementVNode("select",{value:x(r.value.id,W.id),onChange:oe=>$(r.value.id,W.id,oe.target.value),disabled:!_(r.value.id),class:"select-input"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.options,oe=>(e.openBlock(),e.createElementBlock("option",{key:String(oe.value),value:oe.value},e.toDisplayString(oe.label),9,L0))),128))],40,A0)])):e.createCommentVNode("",!0)]))),128))])):(e.openBlock(),e.createElementBlock("div",z0," This filter has no adjustable parameters "))])):e.createCommentVNode("",!0)],2)}}}),j0=Me(P0,[["__scopeId","data-v-9efd15d9"]]);class W0{constructor(n){this.pixiFilters=new Map,this.filterParams=new Map,this.filterTypes=new Map,this.filterIntensity=new Map,this.composition=n}setComposition(n){this.composition=n}mapMediablesToPIXI(n){switch(n.filterId){case"blur":return this.createBlurFilter(n.params);case"brightness":return this.createBrightnessFilter(n.params);case"contrast":return this.createContrastFilter(n.params);case"saturation":return this.createSaturationFilter(n.params);case"hue":return this.createHueFilter(n.params);case"vintage":return this.createVintageFilter(n.params);case"grayscale":return this.createGrayscaleFilter();case"sepia":return this.createSepiaFilter();default:return null}}createBlurFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.BlurFilter;if(!i)return null;const r=new i;return r.blur=n.intensity||5,r.quality=n.quality||4,r}catch{return null}}createBrightnessFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.brightness(n.value||1,!1),r}catch{return null}}createContrastFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.contrast(n.value||1,!1),r}catch{return null}}createSaturationFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.saturate(n.value||1,!1),r}catch{return null}}createHueFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.hue(n.rotation||0,!1),r}catch{return null}}createVintageFilter(n){var t,o;try{const i=(o=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:o.ColorMatrixFilter;if(!i)return null;const r=new i;return r.vintage(!1),n.intensity&&(r.contrast(1.2,!1),r.saturate(.8,!1)),r}catch{return null}}createGrayscaleFilter(){var n,t;try{const o=(t=(n=window.PIXI)==null?void 0:n.filters)==null?void 0:t.ColorMatrixFilter;if(!o)return null;const i=new o;return i.desaturate(),i}catch{return null}}createSepiaFilter(){var n,t;try{const o=(t=(n=window.PIXI)==null?void 0:n.filters)==null?void 0:t.ColorMatrixFilter;if(!o)return null;const i=new o;return i.sepia(!1),i}catch{return null}}async applyFilters(n){if(this.composition){this.clearFilters();for(const t of n){const o=this.mapMediablesToPIXI(t);o&&(this.pixiFilters.set(t.id,o),this.filterParams.set(t.id,t.params),this.filterTypes.set(t.id,t.filterId),this.filterIntensity.set(t.id,t.intensity),await this.applyToComposition(t.id,o))}}}async applyToComposition(n,t){try{this.composition.applyFilter&&await this.composition.applyFilter(n,t)}catch{}}updateFilterParams(n,t){var i;const o=this.pixiFilters.get(n);o&&(this.filterParams.set(n,t),"blur"in o&&(o.blur=t.intensity||o.blur),"brightness"in o&&o.brightness(t.value||1,!1),"contrast"in o&&o.contrast(t.value||1,!1),"saturate"in o&&o.saturate(t.value||1,!1),"hue"in o&&o.hue(t.rotation||0,!1),(i=this.composition)!=null&&i.update&&this.composition.update())}getFilterParams(n){return this.filterParams.get(n)||{}}removeFilter(n){var t;this.pixiFilters.delete(n),this.filterParams.delete(n),this.filterTypes.delete(n),this.filterIntensity.delete(n),(t=this.composition)!=null&&t.removeFilter&&this.composition.removeFilter(n)}clearFilters(){var n;this.pixiFilters.clear(),this.filterParams.clear(),this.filterTypes.clear(),this.filterIntensity.clear(),(n=this.composition)!=null&&n.clearFilters&&this.composition.clearFilters()}getActiveFilters(){return Array.from(this.pixiFilters.values())}exportFilterConfig(){const n=[];return this.pixiFilters.forEach((t,o)=>{const i=this.filterParams.get(o)??{},r=this.filterTypes.get(o)??"unknown",s=this.filterIntensity.get(o)??1;n.push({id:o,filterId:r,params:i,intensity:s})}),n}async importFilterConfig(n){await this.applyFilters(n)}destroy(){this.clearFilters(),this.composition=null}}const Z0={class:"video-filter-preview"},X0={class:"preview-title"},H0={class:"filter-controls"},G0={class:"control-input"},J0=["value","onInput","min","max","step"],Y0={class:"param-value"},K0={class:"preview-container"},q0={key:0,class:"filter-presets"},Q0=["onClick"],ev={class:"preview-actions"},tv=e.defineComponent({__name:"VideoFilterPreview",props:{filter:{},currentFrame:{},useVideoEngine:{type:Boolean,default:!1},composition:{}},emits:["update-params","apply"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(!1),s=e.ref({});let l,c,d=null,u=null;const m=e.computed(()=>{var g;return((g=t.filter)==null?void 0:g.paramRanges)||{}}),p=e.computed(()=>h.value.length>0),h=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 g;if(i.value){t.useVideoEngine&&t.composition&&(u=new W0(t.composition));try{if(l=new Je.Application,await l.init({width:i.value.clientWidth,height:i.value.clientHeight,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,canvas:i.value}),(g=t.currentFrame)!=null&&g.dataUrl){const S=await Je.Assets.load(t.currentFrame.dataUrl);c=new Je.Sprite(S);const O=Math.min(l.screen.width/c.texture.width,l.screen.height/c.texture.height);c.scale.set(O),c.anchor.set(.5),c.position.set(l.screen.width/2,l.screen.height/2),l.stage.addChild(c)}y()}catch{}}}function y(){if(!(!c||!t.filter))if(t.useVideoEngine&&u){const g={id:t.filter.id,filterId:t.filter.id,params:s.value,intensity:s.value.value??s.value.intensity??1};u.applyFilters([g]).then(()=>{}).catch(S=>{}),d&&(d.destroy(),d=null),d=E(t.filter.id,s.value),d&&(c.filters=r.value?null:[d])}else d&&(d.destroy(),d=null),d=E(t.filter.id,s.value),d&&(c.filters=r.value?null:[d])}function E(g,S){switch(g){case"brightness":{const O=new Je.ColorMatrixFilter,k=1+(S.value??0);return typeof O.brightness=="function"&&O.brightness(k,!1),O}case"contrast":{const O=new Je.ColorMatrixFilter,k=S.value??1;return typeof O.contrast=="function"&&O.contrast(k,!1),O}case"saturation":{const O=new Je.ColorMatrixFilter,k=S.value??1;return typeof O.saturate=="function"&&O.saturate(k,!1),O}case"hue":{const O=new Je.ColorMatrixFilter,k=S.value??0;return typeof O.hue=="function"&&O.hue(k,!1),O}case"gaussian-blur":{const O=S.value??5;return new Je.BlurFilter({strength:O,quality:4})}case"sepia":{const O=new Je.ColorMatrixFilter;return typeof O.sepia=="function"&&O.sepia(!1),O}case"grayscale":{const O=new Je.ColorMatrixFilter;return typeof O.desaturate=="function"&&O.desaturate(),O}default:return null}}function _(g,S){const O=S.target,k=Number.parseFloat(O.value),T=Number.isFinite(k)?k:0;s.value={...s.value,[g]:T},t.useVideoEngine&&u&&t.filter&&u.updateFilterParams(t.filter.id,s.value),o("update-params",s.value),y()}function C(g){return g.charAt(0).toUpperCase()+g.slice(1).replace(/_/g," ")}function w(g,S){var k;const O=typeof g=="number"?g:Number(g);return Number.isFinite(O)?S==="hue"||S==="angle"?`${O}°`:S==="value"&&((k=t.filter)==null?void 0:k.id)==="brightness"?`${Math.round((1+O)*100)}%`:Number.isInteger(O)?O.toString():O.toFixed(2):"0"}function f(){var g;s.value=((g=t.filter)==null?void 0:g.defaultParams)||{},o("update-params",s.value),y()}function x(g){s.value={...g.params},o("update-params",s.value),y()}function $(g){return JSON.stringify(g.params)===JSON.stringify(s.value)}function N(){o("apply")}return e.watch(()=>t.filter,g=>{g&&(s.value={...g.defaultParams},y())}),e.watch(()=>t.currentFrame,async g=>{if(g!=null&&g.dataUrl&&c){const S=await Je.Assets.load(g.dataUrl);c.texture=S}}),e.watch(r,y),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()}),(g,S)=>{var O;return e.openBlock(),e.createElementBlock("div",Z0,[e.createElementVNode("h4",X0,e.toDisplayString((O=g.filter)==null?void 0:O.name)+" Settings",1),e.createElementVNode("div",H0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(k,T)=>(e.openBlock(),e.createElementBlock("div",{key:T,class:"control-group"},[e.createElementVNode("label",null,e.toDisplayString(C(T)),1),e.createElementVNode("div",G0,[e.createElementVNode("input",{type:"range",value:s.value[T],onInput:F=>_(T,F),min:k.min,max:k.max,step:k.step,class:"param-slider"},null,40,J0),e.createElementVNode("span",Y0,e.toDisplayString(w(s.value[T],T)),1)])]))),128))]),e.createElementVNode("div",K0,[e.createElementVNode("canvas",{ref_key:"previewCanvas",ref:i,class:"preview-canvas"},null,512),e.createElementVNode("button",{class:"compare-button",onMousedown:S[0]||(S[0]=k=>r.value=!0),onMouseup:S[1]||(S[1]=k=>r.value=!1),onTouchstart:S[2]||(S[2]=k=>r.value=!0),onTouchend:S[3]||(S[3]=k=>r.value=!1)},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(to)},null,8,["icon"]),S[4]||(S[4]=e.createTextVNode(" Hold to compare ",-1))],32)]),p.value?(e.openBlock(),e.createElementBlock("div",q0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,k=>(e.openBlock(),e.createElementBlock("button",{key:k.name,class:e.normalizeClass(["preset-button",{active:$(k)}]),onClick:T=>x(k)},e.toDisplayString(k.name),11,Q0))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",ev,[e.createElementVNode("button",{class:"action-button",onClick:f},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Un)},null,8,["icon"]),S[5]||(S[5]=e.createTextVNode(" Reset ",-1))]),e.createElementVNode("button",{class:"action-button primary",onClick:N},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Qs)},null,8,["icon"]),S[6]||(S[6]=e.createTextVNode(" Apply Filter ",-1))])])])}}}),nv=Me(tv,[["__scopeId","data-v-3de3dd04"]]),ov={class:"export-settings"},av={class:"setting-group"},iv={class:"setting-group"},rv={class:"estimated-size"},sv={key:0,class:"export-progress"},lv={class:"progress-header"},cv={class:"progress-percentage"},dv={class:"progress-time"},uv={class:"action-buttons"},mv=["disabled"],pv=["disabled"],fv=["disabled"],hv={class:"export-options"},vv=e.defineComponent({__name:"EditorControls",props:{canExport:{type:Boolean,default:!1},isExporting:{type:Boolean,default:!1},exportProgress:{default:0},isMobile:{type:Boolean,default:!1},duration:{default:0}},emits:["export","save-draft","reset","cancel-export"],setup(a,{emit:n}){const t=a,o=n,i=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 p=e.computed(()=>{const f=({"360p":1,"480p":2.5,"720p":5,"1080p":8,"1440p":16,"2160p":35}[i.value]||8)*t.duration/8;return f<1e3?`~${Math.round(f)} MB`:`~${(f/1e3).toFixed(1)} GB`});function h(){t.isExporting?(o("cancel-export"),E()):v()}function v(){const C={quality:i.value,format:r.value,optimizeForWeb:s.value,includeWatermark:l.value};o("export",C),y()}function y(){c.value=Date.now(),d.value=0,m=window.setInterval(()=>{if(d.value=Math.floor((Date.now()-c.value)/1e3),t.exportProgress>0){const C=d.value/t.exportProgress*100;u.value=Math.max(0,C-d.value)}},1e3)}function E(){m&&(clearInterval(m),m=null)}function _(C){const w=Math.floor(C/60),f=Math.floor(C%60);return`${w}:${f.toString().padStart(2,"0")}`}return e.watch(()=>t.isExporting,C=>{C||E()}),e.onUnmounted(()=>{E()}),(C,w)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["editor-controls",{mobile:C.isMobile}])},[e.createElementVNode("div",ov,[w[10]||(w[10]=e.createElementVNode("h3",{class:"section-title"},"Export Settings",-1)),e.createElementVNode("div",av,[w[7]||(w[7]=e.createElementVNode("label",null,"Quality",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":w[0]||(w[0]=f=>i.value=f),class:"setting-select"},[...w[6]||(w[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",iv,[w[9]||(w[9]=e.createElementVNode("label",null,"Format",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":w[1]||(w[1]=f=>r.value=f),class:"setting-select"},[...w[8]||(w[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",rv,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(mu)},null,8,["icon"]),e.createElementVNode("span",null,"Estimated size: "+e.toDisplayString(p.value),1)])]),C.isExporting?(e.openBlock(),e.createElementBlock("div",sv,[e.createElementVNode("div",lv,[w[11]||(w[11]=e.createElementVNode("span",null,"Exporting...",-1)),e.createElementVNode("span",cv,e.toDisplayString(C.exportProgress??0)+"%",1)]),e.createVNode(e.unref(B.IonProgressBar),{value:(C.exportProgress??0)/100},null,8,["value"]),e.createElementVNode("div",dv,[e.createElementVNode("span",null,e.toDisplayString(_(d.value))+" elapsed",1),e.createElementVNode("span",null,e.toDisplayString(_(u.value))+" remaining",1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",uv,[e.createElementVNode("button",{class:"control-button secondary",onClick:w[2]||(w[2]=f=>C.$emit("save-draft")),disabled:!C.canExport||C.isExporting},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Zi)},null,8,["icon"]),w[12]||(w[12]=e.createTextVNode(" Save Draft ",-1))],8,mv),e.createElementVNode("button",{class:"control-button secondary",onClick:w[3]||(w[3]=f=>C.$emit("reset")),disabled:C.isExporting},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Un)},null,8,["icon"]),w[13]||(w[13]=e.createTextVNode(" Reset ",-1))],8,pv),e.createElementVNode("button",{class:"control-button primary",onClick:h,disabled:!C.canExport&&!C.isExporting,"data-testid":"video-export-button"},[e.createVNode(e.unref(B.IonIcon),{icon:C.isExporting?e.unref(Fn):e.unref(po)},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(C.isExporting?"Cancel":"Export Video"),1)],8,fv)]),e.createElementVNode("div",hv,[e.createVNode(e.unref(B.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonCheckbox),{modelValue:s.value,"onUpdate:modelValue":w[4]||(w[4]=f=>s.value=f)},null,8,["modelValue"]),e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...w[14]||(w[14]=[e.createTextVNode("Optimize for web streaming",-1)])]),_:1})]),_:1}),e.createVNode(e.unref(B.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonCheckbox),{modelValue:l.value,"onUpdate:modelValue":w[5]||(w[5]=f=>l.value=f)},null,8,["modelValue"]),e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...w[15]||(w[15]=[e.createTextVNode("Include watermark",-1)])]),_:1})]),_:1})])],2))}}),gv=Me(vv,[["__scopeId","data-v-e1338d5e"]]),yv={class:"thumbnail-picker"},wv={class:"thumbnail-grid"},bv=["onClick"],kv=["src","alt"],xv={key:1,class:"thumbnail-placeholder"},Ev={class:"thumbnail-time"},Vv={class:"custom-selector"},Sv={class:"time-input-group"},Cv=["max"],Nv={class:"time-value"},_v=["disabled"],Tv={class:"picker-actions"},Mv=["disabled"],Bv=e.defineComponent({__name:"ThumbnailPicker",props:{mediaUuid:{},duration:{},currentTime:{default:0}},emits:["select","cancel"],setup(a,{emit:n}){const t=a,o=n,i=e.ref([]),r=e.ref(-1),s=e.ref(t.currentTime),l=e.ref(!1);function c(){const _=[];if(t.duration<=10)for(let w=0;w<Math.min(9,t.duration);w++)_.push(w);else{const w=t.duration/10;for(let f=1;f<=9;f++)_.push(w*f)}return _}async function d(_){try{const C=document.createElement("video");return C.crossOrigin="anonymous",C.src=await u(),new Promise(w=>{C.addEventListener("loadedmetadata",()=>{C.currentTime=_}),C.addEventListener("seeked",()=>{const f=document.createElement("canvas");f.width=C.videoWidth,f.height=C.videoHeight;const x=f.getContext("2d");x?(x.drawImage(C,0,0),w(f.toDataURL("image/jpeg",.8))):w(null),C.remove()}),C.addEventListener("error",()=>{w(null),C.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 _=c();i.value=_.map(w=>({time:w,loading:!0}));const C=3;for(let w=0;w<i.value.length;w+=C){const f=i.value.slice(w,w+C);await Promise.all(f.map(async x=>{const $=await d(x.time);$&&(x.dataUrl=$),x.loading=!1}))}}function p(_){r.value=_,s.value=i.value[_].time}function h(){r.value=-1}async function v(){l.value=!0;try{const _=await d(s.value);if(_){const C=i.value.findIndex(w=>Math.abs(w.time-s.value)<.1);C>=0?(i.value[C].dataUrl=_,r.value=C):(i.value.push({time:s.value,dataUrl:_}),r.value=i.value.length-1,i.value.sort((w,f)=>w.time-f.time),r.value=i.value.findIndex(w=>w.time===s.value))}}finally{l.value=!1}}function y(){const _=r.value>=0?i.value[r.value].time:s.value;o("select",_)}function E(_){const C=Math.floor(_/60),w=Math.floor(_%60),f=Math.floor(_%1*100);return C>0?`${C}:${w.toString().padStart(2,"0")}.${f.toString().padStart(2,"0")}`:`${w}.${f.toString().padStart(2,"0")}s`}return e.onMounted(()=>{m()}),(_,C)=>(e.openBlock(),e.createElementBlock("div",yv,[C[5]||(C[5]=e.createElementVNode("h4",{class:"picker-title"},"Select Video Thumbnail",-1)),e.createElementVNode("div",wv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(w,f)=>(e.openBlock(),e.createElementBlock("div",{key:f,class:e.normalizeClass(["thumbnail-item",{selected:r.value===f}]),onClick:x=>p(f)},[w.dataUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:w.dataUrl,alt:`Frame at ${E(w.time)}`},null,8,kv)):(e.openBlock(),e.createElementBlock("div",xv,[e.createVNode(e.unref(B.IonSpinner),{name:"crescent"})])),e.createElementVNode("div",Ev,e.toDisplayString(E(w.time)),1)],10,bv))),128))]),e.createElementVNode("div",Vv,[C[3]||(C[3]=e.createElementVNode("label",null,"Custom time:",-1)),e.createElementVNode("div",Sv,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":C[0]||(C[0]=w=>s.value=w),min:0,max:_.duration,step:.1,onInput:h,class:"time-slider"},null,40,Cv),[[e.vModelText,s.value]]),e.createElementVNode("span",Nv,e.toDisplayString(E(s.value)),1)]),e.createElementVNode("button",{class:"capture-button",onClick:v,disabled:l.value},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(eu)},null,8,["icon"]),C[2]||(C[2]=e.createTextVNode(" Capture Frame ",-1))],8,_v)]),e.createElementVNode("div",Tv,[e.createElementVNode("button",{class:"action-button",onClick:C[1]||(C[1]=w=>_.$emit("cancel"))}," Cancel "),e.createElementVNode("button",{class:"action-button primary",onClick:y,disabled:r.value===-1},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Qs)},null,8,["icon"]),C[4]||(C[4]=e.createTextVNode(" Set Thumbnail ",-1))],8,Mv)])]))}}),Iv=Me(Bv,[["__scopeId","data-v-336c322c"]]),Fv={class:"text-overlay-panel p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},Rv={class:"mb-4"},$v={class:"space-y-2 max-h-64 overflow-y-auto"},Dv={class:"flex items-center justify-between"},Uv={class:"flex-1"},Ov={class:"font-medium text-gray-900 dark:text-white"},Av={class:"text-sm text-gray-500 dark:text-gray-400"},Lv={class:"flex items-center space-x-2"},zv=["onClick"],Pv=["onClick"],jv={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},Wv={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},Zv={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},Xv={class:"space-y-4"},Hv={class:"grid grid-cols-2 gap-4"},Gv={class:"grid grid-cols-2 gap-4"},Jv={key:0,class:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},Yv={class:"grid grid-cols-2 gap-3"},Kv={class:"flex justify-end space-x-3 mt-6"},qv=e.defineComponent({__name:"TextOverlayPanel",props:{overlays:{}},emits:["add-overlay","update-overlay","remove-overlay"],setup(a,{emit:n}){const t=n,o=e.ref(!1),i=e.ref(null),r=()=>({id:"",text:"",fontSize:24,color:"#ffffff",position:"center",startTime:0,duration:5,animationType:"",animationDuration:1,animationEasing:"linear"}),s=e.reactive(r());function l(p){Object.assign(s,p),i.value=p}function c(){o.value=!1,i.value=null,Object.assign(s,r())}function d(){const p={text:s.text,fontSize:s.fontSize,color:s.color,position:s.position,startTime:s.startTime,duration:s.duration};if(s.animationType&&(p.animation={type:s.animationType},s.animationDuration!==void 0&&(p.animation.duration=s.animationDuration),s.animationEasing&&(p.animation.easing=s.animationEasing),p.animation))switch(s.animationType){case"rotate":p.animation.rotation={from:0,to:360};break;case"scale":p.animation.scale={from:.5,to:1};break;case"slide":p.animation.translate={fromX:-100,toX:0,fromY:0,toY:0};break}i.value?t("update-overlay",i.value.id,p):t("add-overlay",p),c()}function u(p){confirm("Are you sure you want to remove this text overlay?")&&t("remove-overlay",p)}function m(p){const h=Math.floor(p/60),v=Math.floor(p%60);return`${h}:${v.toString().padStart(2,"0")}`}return(p,h)=>(e.openBlock(),e.createElementBlock("div",Fv,[e.createElementVNode("div",Rv,[h[11]||(h[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Text Overlays ",-1)),e.createElementVNode("button",{onClick:h[0]||(h[0]=v=>o.value=!0),class:"w-full px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-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 Text Overlay ",-1)])])]),e.createElementVNode("div",$v,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.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",Dv,[e.createElementVNode("div",Uv,[e.createElementVNode("div",Ov,e.toDisplayString(v.text.substring(0,30))+e.toDisplayString(v.text.length>30?"...":""),1),e.createElementVNode("div",Av,e.toDisplayString(m(v.startTime??0))+" - "+e.toDisplayString(m((v.startTime||0)+(v.duration||5))),1)]),e.createElementVNode("div",Lv,[e.createElementVNode("button",{onClick:y=>l(v),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Edit"},[...h[12]||(h[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,zv),e.createElementVNode("button",{onClick:y=>u(v.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...h[13]||(h[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,Pv)])])]))),128)),p.overlays.length===0?(e.openBlock(),e.createElementBlock("div",jv," No text overlays added yet ")):e.createCommentVNode("",!0)]),o.value||i.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",onClick:e.withModifiers(c,["self"])},[e.createElementVNode("div",Wv,[e.createElementVNode("h4",Zv,e.toDisplayString(i.value?"Edit":"Add")+" Text Overlay ",1),e.createElementVNode("div",Xv,[e.createElementVNode("div",null,[h[14]||(h[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":h[1]||(h[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",Hv,[e.createElementVNode("div",null,[h[15]||(h[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":h[2]||(h[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,[h[16]||(h[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":h[3]||(h[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,[h[18]||(h[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":h[4]||(h[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"},[...h[17]||(h[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",Gv,[e.createElementVNode("div",null,[h[19]||(h[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":h[5]||(h[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,[h[20]||(h[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":h[6]||(h[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,[h[22]||(h[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":h[7]||(h[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"},[...h[21]||(h[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",Jv,[h[26]||(h[26]=e.createElementVNode("div",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Animation Settings ",-1)),e.createElementVNode("div",Yv,[e.createElementVNode("div",null,[h[23]||(h[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":h[8]||(h[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,[h[25]||(h[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":h[9]||(h[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"},[...h[24]||(h[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",Kv,[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)]))}}),Qv=Me(qv,[["__scopeId","data-v-f86e688c"]]),mo=class mo{constructor(n){this.transitions=new Map,this.nextId=0,this.composition=n}async applyTransition(n,t,o){const i=`transition-${this.nextId++}`,r=Math.round(o.duration*30),s=o.easing||"linear",l=this.findTrackForClip(n),c=this.findTrackForClip(t);if(!l||!c)throw new Error("Clips must be added to composition before applying transitions");const d=n.stop.frames-r,u=n.stop.frames;switch(o.type){case"fade":await this.applyFadeTransition(n,t,d,u,s);break;case"dissolve":case"cross-fade":await this.applyCrossFadeTransition(n,t,d,u,s);break;case"wipe-left":case"wipe-right":case"wipe-up":case"wipe-down":await this.applyWipeTransition(n,t,o.type,d,u,s);break;case"slide-left":case"slide-right":case"slide-up":case"slide-down":await this.applySlideTransition(n,t,o.type,d,u,s);break;case"zoom-in":case"zoom-out":await this.applyZoomTransition(n,t,o.type,d,u,s);break;case"dip-to-black":case"dip-to-white":await this.applyDipTransition(n,t,o.type,d,u,s);break}return this.transitions.set(i,o),i}async applyFadeTransition(n,t,o,i,r){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Fade transitions require VideoClip instances");n.alpha=new Ee([o,i],[1,0],{easing:r}),t.alpha=new Ee([o,i],[0,1],{easing:r}),t.start=ge.fromFrames(o)}async applyCrossFadeTransition(n,t,o,i,r){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Cross-fade transitions require VideoClip instances");n.alpha=new Ee([o,i],[1,0],{easing:r}),t.alpha=new Ee([o,i],[0,1],{easing:r}),t.start=ge.fromFrames(o)}async applyWipeTransition(n,t,o,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Wipe transitions require VideoClip instances");const l={x:0,y:0},c={x:0,y:0};switch(o){case"wipe-left":l.x=new Ee([i,r],[0,-1920],{easing:s}),c.x=new Ee([i,r],[1920,0],{easing:s});break;case"wipe-right":l.x=new Ee([i,r],[0,1920],{easing:s}),c.x=new Ee([i,r],[-1920,0],{easing:s});break;case"wipe-up":l.y=new Ee([i,r],[0,-1080],{easing:s}),c.y=new Ee([i,r],[1080,0],{easing:s});break;case"wipe-down":l.y=new Ee([i,r],[0,1080],{easing:s}),c.y=new Ee([i,r],[-1080,0],{easing:s});break}n.translate=l,t.translate=c,t.start=ge.fromFrames(i)}async applySlideTransition(n,t,o,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Slide transitions require VideoClip instances");const l={x:0,y:0},c={x:0,y:0};switch(o){case"slide-left":l.x=new Ee([i,r],[0,-1920],{easing:s}),c.x=new Ee([i,r],[1920,0],{easing:s});break;case"slide-right":l.x=new Ee([i,r],[0,1920],{easing:s}),c.x=new Ee([i,r],[-1920,0],{easing:s});break;case"slide-up":l.y=new Ee([i,r],[0,-1080],{easing:s}),c.y=new Ee([i,r],[1080,0],{easing:s});break;case"slide-down":l.y=new Ee([i,r],[0,1080],{easing:s}),c.y=new Ee([i,r],[-1080,0],{easing:s});break}n.translate=l,t.translate=c,t.start=ge.fromFrames(i)}async applyZoomTransition(n,t,o,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Zoom transitions require VideoClip instances");o==="zoom-in"?(n.scale=new Ee([i,r],[1,2],{easing:s}),n.alpha=new Ee([i,r],[1,0],{easing:s}),t.scale=new Ee([i,r],[.5,1],{easing:s}),t.alpha=new Ee([i,r],[0,1],{easing:s})):(n.scale=new Ee([i,r],[1,.5],{easing:s}),n.alpha=new Ee([i,r],[1,0],{easing:s}),t.scale=new Ee([i,r],[2,1],{easing:s}),t.alpha=new Ee([i,r],[0,1],{easing:s})),t.start=ge.fromFrames(i)}async applyDipTransition(n,t,o,i,r,s){if(!this.isVideoClip(n)||!this.isVideoClip(t))throw new Error("Dip transitions require VideoClip instances");const l=Math.round((i+r)/2),c=o==="dip-to-black"?"#000000":"#ffffff",d=await Ti.fromColor(c),u=new If(d,{start:ge.fromFrames(i),stop:ge.fromFrames(r)});n.alpha=new Ee([i,l],[1,0],{easing:s}),u.alpha=new Ee([i,l,r],[0,1,0],{easing:s}),t.alpha=new Ee([l,r],[0,1],{easing:s}),await this.composition.add(u),t.start=ge.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[...mo.TRANSITIONS]}static previewTransition(n){return mo.TRANSITIONS.find(t=>t.type===n)}isVideoClip(n){return"alpha"in n&&"scale"in n&&"translate"in n}};mo.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 ma=mo;const e1={class:"transition-selector p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},t1={class:"grid grid-cols-3 gap-3 max-h-96 overflow-y-auto"},n1=["onClick"],o1={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"},a1={key:0,class:"w-8 h-8 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},i1={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},r1={key:1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14 5l7 7m0 0l-7 7m7-7H3"},s1={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"},l1={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"},c1={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"},d1={class:"text-sm font-medium text-gray-900 dark:text-white text-center"},u1={key:0,class:"mt-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},m1={class:"space-y-3"},p1={class:"flex items-center space-x-2"},f1=["disabled"],h1=["disabled"],v1={key:1,class:"mt-4"},g1={class:"space-y-2 max-h-32 overflow-y-auto"},y1={class:"text-sm text-gray-700 dark:text-gray-300"},w1=["onClick"],b1=e.defineComponent({__name:"TransitionSelector",props:{selectedClips:{},appliedTransitions:{}},emits:["apply-transition","remove-transition","preview-transition"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(ma.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};o("apply-transition",v),r.value=null}function m(){if(!r.value)return;const v={type:r.value.type,duration:s.value,easing:l.value};o("preview-transition",v)}function p(v){o("remove-transition",v)}function h(v){return["fade","wipe","slide","zoom"].some(y=>v.includes(y))}return(v,y)=>(e.openBlock(),e.createElementBlock("div",e1,[y[9]||(y[9]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"}," Transitions ",-1)),e.createElementVNode("div",t1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,E=>{var _;return e.openBlock(),e.createElementBlock("div",{key:E.type,onClick:C=>d(E),class:e.normalizeClass(["transition-item cursor-pointer rounded-lg p-3 border-2 transition-all",((_=r.value)==null?void 0:_.type)===E.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",o1,[h(E.type)?(e.openBlock(),e.createElementBlock("svg",a1,[E.type.includes("fade")?(e.openBlock(),e.createElementBlock("path",i1)):E.type.includes("wipe")?(e.openBlock(),e.createElementBlock("path",r1)):E.type.includes("slide")?(e.openBlock(),e.createElementBlock("path",s1)):E.type.includes("zoom")?(e.openBlock(),e.createElementBlock("path",l1)):(e.openBlock(),e.createElementBlock("path",c1))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",d1,e.toDisplayString(E.name),1)],10,n1)}),128))]),r.value?(e.openBlock(),e.createElementBlock("div",u1,[y[6]||(y[6]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3"}," Transition Settings ",-1)),e.createElementVNode("div",m1,[e.createElementVNode("div",null,[y[3]||(y[3]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Duration (seconds) ",-1)),e.createElementVNode("div",p1,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":y[0]||(y[0]=E=>s.value=E),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":y[1]||(y[1]=E=>s.value=E),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,[y[5]||(y[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":y[2]||(y[2]=E=>l.value=E),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"},[...y[4]||(y[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,f1),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,h1)])])):e.createCommentVNode("",!0),v.appliedTransitions.length>0?(e.openBlock(),e.createElementBlock("div",v1,[y[8]||(y[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Applied Transitions ",-1)),e.createElementVNode("div",g1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.appliedTransitions,(E,_)=>(e.openBlock(),e.createElementBlock("div",{key:_,class:"flex items-center justify-between p-2 bg-gray-50 dark:bg-gray-700 rounded"},[e.createElementVNode("div",y1,e.toDisplayString(E.name)+" ("+e.toDisplayString(E.duration)+"s) ",1),e.createElementVNode("button",{onClick:C=>p(_),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded"},[...y[7]||(y[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,w1)]))),128))])])):e.createCommentVNode("",!0),y[10]||(y[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))]))}}),k1=Me(b1,[["__scopeId","data-v-5ef1b100"]]),x1={class:"audio-track-manager p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},E1={class:"mb-4"},V1={class:"mb-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},S1={class:"flex items-center justify-between mb-2"},C1={class:"text-sm text-gray-600 dark:text-gray-400"},N1={class:"flex items-center space-x-2"},_1={class:"space-y-3 max-h-64 overflow-y-auto"},T1={class:"flex items-center justify-between mb-2"},M1={class:"font-medium text-gray-900 dark:text-white"},B1={class:"flex items-center space-x-2"},I1=["onClick","title"],F1={key:0,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},R1={key:1,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},$1=["onClick"],D1=["onClick"],U1={class:"flex items-center space-x-2"},O1={class:"text-xs text-gray-500 dark:text-gray-400 w-10"},A1=["value","onInput","disabled"],L1={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},z1={key:0,class:"ml-2"},P1={key:1,class:"ml-2"},j1={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},W1={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},Z1={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},X1={class:"space-y-4"},H1={class:"space-y-2"},G1={class:"flex items-center"},J1={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},Y1={class:"grid grid-cols-2 gap-4"},K1={class:"grid grid-cols-2 gap-4"},q1={class:"flex items-center"},Q1={class:"flex justify-end space-x-3 mt-6"},eg=["disabled"],tg=e.defineComponent({__name:"AudioTrackManager",props:{audioLayers:{},masterVolume:{}},emits:["add-track","update-track","remove-track","update-volume","toggle-mute","update-master-volume"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(!1),r=e.ref(null),s=e.ref(t.masterVolume),l=()=>({id:"",source:"",sourceUrl:"",name:"Background Music",volume:.7,startTime:0,fadeIn:0,fadeOut:0,loop:!1}),c=e.reactive(l()),d=e.computed(()=>c.sourceUrl||c.sourceFile);function u(w){const f=w.target;f.files&&f.files[0]&&(c.sourceFile=f.files[0],c.name=c.name||f.files[0].name.replace(/\.[^/.]+$/,""))}function m(w){Object.assign(c,w),r.value=w}function p(){i.value=!1,r.value=null,Object.assign(c,l())}function h(){if(!d.value)return;const w={source:c.sourceFile??c.sourceUrl??"",name:c.name,volume:c.volume,startTime:c.startTime,loop:c.loop};c.duration!==void 0&&(w.duration=c.duration),c.fadeIn>0&&(w.fadeIn=c.fadeIn),c.fadeOut>0&&(w.fadeOut=c.fadeOut),r.value?o("update-track",r.value.id,w):o("add-track",w),p()}function v(w){confirm("Are you sure you want to remove this audio track?")&&o("remove-track",w)}function y(w,f){const x=f.target,$=parseFloat(x.value);o("update-volume",w.id,$)}function E(w){o("toggle-mute",w.id,!w.muted)}function _(){o("update-master-volume",s.value)}function C(w){const f=Math.floor(w/60),x=Math.floor(w%60);return`${f}:${x.toString().padStart(2,"0")}`}return(w,f)=>(e.openBlock(),e.createElementBlock("div",x1,[e.createElementVNode("div",E1,[f[11]||(f[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Audio Tracks ",-1)),e.createElementVNode("button",{onClick:f[0]||(f[0]=x=>i.value=!0),class:"w-full px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors"},[...f[10]||(f[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",V1,[e.createElementVNode("div",S1,[f[12]||(f[12]=e.createElementVNode("label",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"}," Master Volume ",-1)),e.createElementVNode("span",C1,e.toDisplayString(Math.round(s.value*100))+"% ",1)]),e.createElementVNode("div",N1,[f[13]||(f[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":f[1]||(f[1]=x=>s.value=x),onInput:_,type:"range",min:"0",max:"1",step:"0.01",class:"flex-1"},null,544),[[e.vModelText,s.value,void 0,{number:!0}]]),f[14]||(f[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",_1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.audioLayers,x=>(e.openBlock(),e.createElementBlock("div",{key:x.id,class:"p-3 border border-gray-200 dark:border-gray-700 rounded-lg"},[e.createElementVNode("div",T1,[e.createElementVNode("div",M1,e.toDisplayString(x.name),1),e.createElementVNode("div",B1,[e.createElementVNode("button",{onClick:$=>E(x),class:e.normalizeClass(["p-1 rounded",x.muted?"text-red-600 bg-red-50 dark:bg-red-900":"text-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700"]),title:x.muted?"Unmute":"Mute"},[x.muted?(e.openBlock(),e.createElementBlock("svg",R1,[...f[16]||(f[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",F1,[...f[15]||(f[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,I1),e.createElementVNode("button",{onClick:$=>m(x),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Settings"},[...f[17]||(f[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,$1),e.createElementVNode("button",{onClick:$=>v(x.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...f[18]||(f[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,D1)])]),e.createElementVNode("div",U1,[e.createElementVNode("span",O1,e.toDisplayString(Math.round((x.volume||1)*100))+"% ",1),e.createElementVNode("input",{value:x.volume||1,onInput:$=>y(x,$),type:"range",min:"0",max:"1",step:"0.01",class:"flex-1",disabled:x.muted},null,40,A1)]),e.createElementVNode("div",L1,[e.createTextVNode(e.toDisplayString(C(x.startTime||0))+" - "+e.toDisplayString(C((x.startTime||0)+(x.duration||0)))+" ",1),x.fadeIn?(e.openBlock(),e.createElementBlock("span",z1,"Fade In: "+e.toDisplayString(x.fadeIn)+"s",1)):e.createCommentVNode("",!0),x.fadeOut?(e.openBlock(),e.createElementBlock("span",P1,"Fade Out: "+e.toDisplayString(x.fadeOut)+"s",1)):e.createCommentVNode("",!0)])]))),128)),w.audioLayers.length===0?(e.openBlock(),e.createElementBlock("div",j1," No audio tracks added yet ")):e.createCommentVNode("",!0)]),i.value||r.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",onClick:e.withModifiers(p,["self"])},[e.createElementVNode("div",W1,[e.createElementVNode("h4",Z1,e.toDisplayString(r.value?"Edit":"Add")+" Audio Track ",1),e.createElementVNode("div",X1,[e.createElementVNode("div",null,[f[20]||(f[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",H1,[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",G1,[f[19]||(f[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":f[2]||(f[2]=x=>c.sourceUrl=x),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,[f[21]||(f[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":f[3]||(f[3]=x=>c.name=x),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",J1," Volume: "+e.toDisplayString(Math.round(c.volume*100))+"% ",1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[4]||(f[4]=x=>c.volume=x),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",Y1,[e.createElementVNode("div",null,[f[22]||(f[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":f[5]||(f[5]=x=>c.startTime=x),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,[f[23]||(f[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":f[6]||(f[6]=x=>c.duration=x),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",K1,[e.createElementVNode("div",null,[f[24]||(f[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":f[7]||(f[7]=x=>c.fadeIn=x),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,[f[25]||(f[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":f[8]||(f[8]=x=>c.fadeOut=x),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",q1,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[9]||(f[9]=x=>c.loop=x),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]]),f[26]||(f[26]=e.createElementVNode("label",{for:"loop-checkbox",class:"text-sm text-gray-700 dark:text-gray-300"}," Loop audio track ",-1))])]),e.createElementVNode("div",Q1,[e.createElementVNode("button",{onClick:p,class:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"}," Cancel "),e.createElementVNode("button",{onClick:h,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,eg)])])])):e.createCommentVNode("",!0)]))}}),ng=Me(tg,[["__scopeId","data-v-593719ac"]]);function Ue(a,n={},...t){const o=document.createElement(a);for(const[i,r]of Object.entries(n))r!=null&&(i==="className"?o.className=r:i==="style"&&typeof r=="object"?Object.assign(o.style,r):i.startsWith("on")&&typeof r=="function"?o.addEventListener(i.slice(2).toLowerCase(),r):i==="dataset"&&typeof r=="object"?Object.assign(o.dataset,r):o.setAttribute(i,r));for(const i of t)typeof i=="string"?o.appendChild(document.createTextNode(i)):i instanceof HTMLElement&&o.appendChild(i);return o}function Es(a){return typeof a=="boolean"?a?"On":"Off":typeof a=="number"?Number.isInteger(a)?String(a):a.toFixed(2):String(a??"")}let Vs=!1;function og(){if(Vs)return;Vs=!0;const a=`
|
|
34
|
-
/* ── MobileVideoFilterPanel — global (not scoped) ── */
|
|
35
|
-
.mvfp {
|
|
36
|
-
display: flex;
|
|
37
|
-
flex-direction: column;
|
|
38
|
-
width: 100%;
|
|
39
|
-
position: relative;
|
|
40
|
-
background: var(--app-surface, var(--ion-background-color, #1a1a1a));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/* ── Horizontal scroll rows ── */
|
|
44
|
-
.mvfp-row {
|
|
45
|
-
display: flex;
|
|
46
|
-
gap: 8px;
|
|
47
|
-
padding: 8px 12px;
|
|
48
|
-
overflow-x: auto;
|
|
49
|
-
-webkit-overflow-scrolling: touch;
|
|
50
|
-
scrollbar-width: none;
|
|
51
|
-
flex-shrink: 0;
|
|
52
|
-
}
|
|
53
|
-
.mvfp-row::-webkit-scrollbar { display: none; }
|
|
54
|
-
|
|
55
|
-
/* ── Category chips ── */
|
|
56
|
-
.mvfp-cat {
|
|
57
|
-
display: flex;
|
|
58
|
-
align-items: center;
|
|
59
|
-
gap: 6px;
|
|
60
|
-
min-height: 36px;
|
|
61
|
-
padding: 8px 14px;
|
|
62
|
-
border-radius: 20px;
|
|
63
|
-
border: 1.5px solid var(--app-border, var(--ion-color-step-300, #444));
|
|
64
|
-
background: var(--app-surface-variant, var(--ion-color-step-50, #222));
|
|
65
|
-
color: var(--app-text, var(--ion-text-color, #eee));
|
|
66
|
-
font-size: 13px;
|
|
67
|
-
font-weight: 500;
|
|
68
|
-
white-space: nowrap;
|
|
69
|
-
cursor: pointer;
|
|
70
|
-
flex-shrink: 0;
|
|
71
|
-
transition: all 0.15s;
|
|
72
|
-
-webkit-tap-highlight-color: transparent;
|
|
73
|
-
}
|
|
74
|
-
.mvfp-cat.active {
|
|
75
|
-
background: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
76
|
-
border-color: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
77
|
-
color: #fff;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/* ── Filter cards ── */
|
|
81
|
-
.mvfp-filter {
|
|
82
|
-
display: flex;
|
|
83
|
-
flex-direction: column;
|
|
84
|
-
align-items: center;
|
|
85
|
-
justify-content: center;
|
|
86
|
-
min-width: 72px;
|
|
87
|
-
max-width: 100px;
|
|
88
|
-
min-height: 48px;
|
|
89
|
-
padding: 10px 12px;
|
|
90
|
-
border-radius: 12px;
|
|
91
|
-
border: 2px solid var(--app-border, var(--ion-color-step-300, #444));
|
|
92
|
-
background: var(--app-surface-variant, var(--ion-color-step-50, #222));
|
|
93
|
-
color: var(--app-text, var(--ion-text-color, #eee));
|
|
94
|
-
font-size: 12px;
|
|
95
|
-
text-align: center;
|
|
96
|
-
line-height: 1.3;
|
|
97
|
-
cursor: pointer;
|
|
98
|
-
flex-shrink: 0;
|
|
99
|
-
position: relative;
|
|
100
|
-
transition: all 0.15s;
|
|
101
|
-
-webkit-tap-highlight-color: transparent;
|
|
102
|
-
}
|
|
103
|
-
.mvfp-filter.active {
|
|
104
|
-
border-color: var(--app-success, var(--ion-color-success, #2dd36f));
|
|
105
|
-
}
|
|
106
|
-
.mvfp-filter.selected {
|
|
107
|
-
background: rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.15);
|
|
108
|
-
border-color: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
109
|
-
}
|
|
110
|
-
.mvfp-filter .mvfp-check {
|
|
111
|
-
position: absolute;
|
|
112
|
-
top: -5px;
|
|
113
|
-
right: -5px;
|
|
114
|
-
width: 18px;
|
|
115
|
-
height: 18px;
|
|
116
|
-
border-radius: 50%;
|
|
117
|
-
background: var(--app-success, var(--ion-color-success, #2dd36f));
|
|
118
|
-
color: #fff;
|
|
119
|
-
display: flex;
|
|
120
|
-
align-items: center;
|
|
121
|
-
justify-content: center;
|
|
122
|
-
font-size: 11px;
|
|
123
|
-
cursor: pointer;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/* ── Active filter chips ── */
|
|
127
|
-
.mvfp-active-row {
|
|
128
|
-
display: flex;
|
|
129
|
-
gap: 6px;
|
|
130
|
-
padding: 6px 12px;
|
|
131
|
-
overflow-x: auto;
|
|
132
|
-
-webkit-overflow-scrolling: touch;
|
|
133
|
-
scrollbar-width: none;
|
|
134
|
-
flex-shrink: 0;
|
|
135
|
-
}
|
|
136
|
-
.mvfp-active-row::-webkit-scrollbar { display: none; }
|
|
137
|
-
|
|
138
|
-
.mvfp-achip {
|
|
139
|
-
display: flex;
|
|
140
|
-
align-items: center;
|
|
141
|
-
gap: 6px;
|
|
142
|
-
padding: 6px 10px 6px 12px;
|
|
143
|
-
background: rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.12);
|
|
144
|
-
border: 1px solid var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
145
|
-
border-radius: 20px;
|
|
146
|
-
white-space: nowrap;
|
|
147
|
-
flex-shrink: 0;
|
|
148
|
-
font-size: 12px;
|
|
149
|
-
color: var(--app-text, var(--ion-text-color, #eee));
|
|
150
|
-
cursor: pointer;
|
|
151
|
-
transition: all 0.15s;
|
|
152
|
-
}
|
|
153
|
-
.mvfp-achip.selected {
|
|
154
|
-
background: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
155
|
-
color: #fff;
|
|
156
|
-
}
|
|
157
|
-
.mvfp-achip-x {
|
|
158
|
-
width: 20px;
|
|
159
|
-
height: 20px;
|
|
160
|
-
border-radius: 50%;
|
|
161
|
-
border: 1.5px solid currentColor;
|
|
162
|
-
background: transparent;
|
|
163
|
-
color: inherit;
|
|
164
|
-
display: flex;
|
|
165
|
-
align-items: center;
|
|
166
|
-
justify-content: center;
|
|
167
|
-
cursor: pointer;
|
|
168
|
-
padding: 0;
|
|
169
|
-
opacity: 0.7;
|
|
170
|
-
flex-shrink: 0;
|
|
171
|
-
}
|
|
172
|
-
.mvfp-achip-x:hover, .mvfp-achip-x:active {
|
|
173
|
-
background: var(--ion-color-danger, #ef4444);
|
|
174
|
-
border-color: var(--ion-color-danger, #ef4444);
|
|
175
|
-
color: #fff;
|
|
176
|
-
opacity: 1;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
.mvfp-placeholder {
|
|
180
|
-
font-size: 12px;
|
|
181
|
-
color: var(--app-text-secondary, var(--ion-color-medium, #888));
|
|
182
|
-
padding: 6px 12px;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/* ── Drawer ── */
|
|
186
|
-
.mvfp-drawer {
|
|
187
|
-
position: absolute;
|
|
188
|
-
bottom: 0;
|
|
189
|
-
left: 0;
|
|
190
|
-
right: 0;
|
|
191
|
-
background: var(--app-surface, var(--ion-background-color, #1a1a1a));
|
|
192
|
-
border-top: 1px solid var(--app-border, var(--ion-color-step-300, #444));
|
|
193
|
-
transform: translateY(100%);
|
|
194
|
-
z-index: 20;
|
|
195
|
-
display: flex;
|
|
196
|
-
flex-direction: column;
|
|
197
|
-
overflow: hidden;
|
|
198
|
-
border-radius: 14px 14px 0 0;
|
|
199
|
-
}
|
|
200
|
-
.mvfp-drawer-hdr {
|
|
201
|
-
display: flex;
|
|
202
|
-
justify-content: space-between;
|
|
203
|
-
align-items: center;
|
|
204
|
-
padding: 8px 14px;
|
|
205
|
-
border-bottom: 1px solid var(--app-border, var(--ion-color-step-200, #333));
|
|
206
|
-
flex-shrink: 0;
|
|
207
|
-
}
|
|
208
|
-
.mvfp-drawer-title {
|
|
209
|
-
font-weight: 600;
|
|
210
|
-
font-size: 14px;
|
|
211
|
-
color: var(--app-text, var(--ion-text-color, #eee));
|
|
212
|
-
}
|
|
213
|
-
.mvfp-drawer-actions {
|
|
214
|
-
display: flex;
|
|
215
|
-
align-items: center;
|
|
216
|
-
gap: 10px;
|
|
217
|
-
}
|
|
218
|
-
.mvfp-drawer-btn {
|
|
219
|
-
background: none;
|
|
220
|
-
border: none;
|
|
221
|
-
font-size: 13px;
|
|
222
|
-
font-weight: 500;
|
|
223
|
-
cursor: pointer;
|
|
224
|
-
padding: 4px 6px;
|
|
225
|
-
color: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
226
|
-
}
|
|
227
|
-
.mvfp-drawer-btn.danger {
|
|
228
|
-
color: var(--ion-color-danger, #ef4444);
|
|
229
|
-
}
|
|
230
|
-
.mvfp-drawer-close {
|
|
231
|
-
width: 28px;
|
|
232
|
-
height: 28px;
|
|
233
|
-
border: none;
|
|
234
|
-
border-radius: 50%;
|
|
235
|
-
background: var(--app-surface-sunken, var(--ion-color-step-100, #2a2a2a));
|
|
236
|
-
color: var(--app-text-secondary, var(--ion-color-medium, #888));
|
|
237
|
-
display: flex;
|
|
238
|
-
align-items: center;
|
|
239
|
-
justify-content: center;
|
|
240
|
-
cursor: pointer;
|
|
241
|
-
padding: 0;
|
|
242
|
-
}
|
|
243
|
-
.mvfp-drawer-body {
|
|
244
|
-
flex: 1 1 auto;
|
|
245
|
-
overflow-y: auto;
|
|
246
|
-
-webkit-overflow-scrolling: touch;
|
|
247
|
-
padding: 10px 14px 16px;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/* ── Drawer slider controls ── */
|
|
251
|
-
.mvfp-ctl {
|
|
252
|
-
margin-bottom: 12px;
|
|
253
|
-
}
|
|
254
|
-
.mvfp-ctl-label {
|
|
255
|
-
display: block;
|
|
256
|
-
font-size: 11px;
|
|
257
|
-
font-weight: 600;
|
|
258
|
-
color: var(--app-text-secondary, var(--ion-color-medium, #888));
|
|
259
|
-
text-transform: uppercase;
|
|
260
|
-
letter-spacing: 0.5px;
|
|
261
|
-
margin-bottom: 4px;
|
|
262
|
-
}
|
|
263
|
-
.mvfp-slider-row {
|
|
264
|
-
display: flex;
|
|
265
|
-
align-items: center;
|
|
266
|
-
gap: 10px;
|
|
267
|
-
}
|
|
268
|
-
.mvfp-range {
|
|
269
|
-
flex: 1;
|
|
270
|
-
height: 6px;
|
|
271
|
-
-webkit-appearance: none;
|
|
272
|
-
appearance: none;
|
|
273
|
-
background: var(--app-border, var(--ion-color-step-200, #333));
|
|
274
|
-
border-radius: 3px;
|
|
275
|
-
outline: none;
|
|
276
|
-
}
|
|
277
|
-
.mvfp-range::-webkit-slider-thumb {
|
|
278
|
-
-webkit-appearance: none;
|
|
279
|
-
width: 22px;
|
|
280
|
-
height: 22px;
|
|
281
|
-
border-radius: 50%;
|
|
282
|
-
background: var(--app-accent, var(--ion-color-primary, #3880ff));
|
|
283
|
-
cursor: pointer;
|
|
284
|
-
border: 2px solid #fff;
|
|
285
|
-
box-shadow: 0 1px 4px rgba(0,0,0,0.3);
|
|
286
|
-
}
|
|
287
|
-
.mvfp-range-val {
|
|
288
|
-
min-width: 3rem;
|
|
289
|
-
text-align: right;
|
|
290
|
-
font-size: 12px;
|
|
291
|
-
font-weight: 500;
|
|
292
|
-
color: var(--app-text-secondary, var(--ion-color-medium, #888));
|
|
293
|
-
}
|
|
294
|
-
.mvfp-toggle-row {
|
|
295
|
-
display: flex;
|
|
296
|
-
align-items: center;
|
|
297
|
-
justify-content: space-between;
|
|
298
|
-
gap: 10px;
|
|
299
|
-
}
|
|
300
|
-
.mvfp-color-row {
|
|
301
|
-
display: flex;
|
|
302
|
-
align-items: center;
|
|
303
|
-
justify-content: space-between;
|
|
304
|
-
gap: 10px;
|
|
305
|
-
}
|
|
306
|
-
.mvfp-color-input {
|
|
307
|
-
width: 36px;
|
|
308
|
-
height: 36px;
|
|
309
|
-
border: 1px solid var(--app-border, var(--ion-color-step-300, #444));
|
|
310
|
-
border-radius: 8px;
|
|
311
|
-
padding: 2px;
|
|
312
|
-
cursor: pointer;
|
|
313
|
-
background: transparent;
|
|
314
|
-
}
|
|
315
|
-
.mvfp-select-row {
|
|
316
|
-
display: flex;
|
|
317
|
-
align-items: center;
|
|
318
|
-
justify-content: space-between;
|
|
319
|
-
gap: 10px;
|
|
320
|
-
}
|
|
321
|
-
.mvfp-select {
|
|
322
|
-
padding: 6px 10px;
|
|
323
|
-
border: 1px solid var(--app-border, var(--ion-color-step-300, #444));
|
|
324
|
-
border-radius: 8px;
|
|
325
|
-
background: var(--app-surface, var(--ion-background-color, #1a1a1a));
|
|
326
|
-
color: var(--app-text, var(--ion-text-color, #eee));
|
|
327
|
-
font-size: 13px;
|
|
328
|
-
}
|
|
329
|
-
.mvfp-no-params {
|
|
330
|
-
text-align: center;
|
|
331
|
-
color: var(--app-text-secondary, var(--ion-color-medium, #888));
|
|
332
|
-
font-style: italic;
|
|
333
|
-
font-size: 13px;
|
|
334
|
-
padding: 12px 0;
|
|
335
|
-
}
|
|
336
|
-
`,n=document.createElement("style");n.textContent=a,document.head.appendChild(n)}class ag{constructor({filters:n=[],callbacks:t={}}){og(),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=Ue("div",{className:"mvfp"}),this._catRow=Ue("div",{className:"mvfp-row"}),this._root.appendChild(this._catRow),this._filterRow=Ue("div",{className:"mvfp-row"}),this._root.appendChild(this._filterRow),this._activeRow=Ue("div",{className:"mvfp-active-row"}),this._root.appendChild(this._activeRow),this._buildDrawer(),this._root.appendChild(this._drawer),this._renderCategories(),this._renderFilters(),this._renderActiveChips(),n.appendChild(this._root),this._root}setFilters(n){this._filters=n,this._renderCategories(),this._renderFilters()}setActiveFilters(n){this._activeFilters.clear(),n&&n.forEach((t,o)=>{this._activeFilters.set(o,t)}),this._renderFilters(),this._renderActiveChips(),this._drawerOpen&&this._drawerFilterId&&!this._activeFilters.has(this._drawerFilterId)&&this.closeDrawer()}destroy(){var n;this.closeDrawer(),(n=this._root)==null||n.remove(),this._root=null}_getCategories(){const n=new Map;n.set("all","All");for(const t of this._filters){const o=t.category||"other";n.has(o)||n.set(o,o.charAt(0).toUpperCase()+o.slice(1))}return n}_renderCategories(){this._catRow.innerHTML="",this._getCategories().forEach((t,o)=>{const i=Ue("div",{className:`mvfp-cat${this._selectedCategory===o?" active":""}`,onClick:()=>{this._selectedCategory=o,this._renderCategories(),this._renderFilters()}},t);this._catRow.appendChild(i)})}_currentFilters(){return this._selectedCategory==="all"?this._filters:this._filters.filter(n=>(n.category||"other")===this._selectedCategory)}_renderFilters(){this._filterRow.innerHTML="";for(const n of this._currentFilters()){const t=this._activeFilters.has(n.id),o=this._selectedFilterId===n.id,i=Ue("div",{className:`mvfp-filter${t?" active":""}${o?" selected":""}`,onClick:()=>this._selectFilter(n)});if(t){const r=Ue("div",{className:"mvfp-check",onClick:s=>{s.stopPropagation(),this._removeFilter(n.id)}});r.innerHTML="✓",i.appendChild(r)}i.appendChild(Ue("span",{},n.name)),this._filterRow.appendChild(i)}}_selectFilter(n){var t,o,i,r;this._selectedFilterId=n.id,this._activeFilters.has(n.id)||(o=(t=this._cb).onApplyFilter)==null||o.call(t,n),(r=(i=this._cb).onPreviewFilter)==null||r.call(i,n),this._renderFilters(),n.params&&n.params.length>0&&this.openDrawer(n.id)}_removeFilter(n){var t,o;(o=(t=this._cb).onRemoveFilter)==null||o.call(t,n),this._selectedFilterId===n&&(this._selectedFilterId=null)}_renderActiveChips(){if(this._activeRow.innerHTML="",this._activeFilters.size===0){this._activeRow.appendChild(Ue("div",{className:"mvfp-placeholder"},"No active filters"));return}this._activeFilters.forEach((n,t)=>{const o=this._filters.find(c=>c.id===t);if(!o)return;const i=this._drawerOpen&&this._drawerFilterId===t,r=Ue("div",{className:`mvfp-achip${i?" selected":""}`}),s=Ue("span",{style:{cursor:"pointer"},onClick:()=>{this._selectedFilterId=t,this._renderFilters(),o.params&&o.params.length>0&&this.openDrawer(t)}},o.name),l=Ue("button",{className:"mvfp-achip-x","aria-label":`Remove ${o.name}`,onClick:c=>{c.stopPropagation(),this._removeFilter(t)}});l.innerHTML='<svg width="10" height="10" viewBox="0 0 12 12"><path d="M3 3l6 6M9 3l-6 6" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',r.appendChild(s),r.appendChild(l),this._activeRow.appendChild(r)})}_buildDrawer(){this._drawer=Ue("div",{className:"mvfp-drawer"});const n=Ue("div",{className:"mvfp-drawer-hdr"});this._drawerTitle=Ue("span",{className:"mvfp-drawer-title"},"Filter");const t=Ue("div",{className:"mvfp-drawer-actions"});t.appendChild(Ue("button",{className:"mvfp-drawer-btn",onClick:()=>this._resetDrawerFilter()},"Reset")),t.appendChild(Ue("button",{className:"mvfp-drawer-btn danger",onClick:()=>{this._drawerFilterId&&(this._removeFilter(this._drawerFilterId),this.closeDrawer())}},"Remove"));const o=Ue("button",{className:"mvfp-drawer-close","aria-label":"Close",onClick:()=>this.closeDrawer()});o.innerHTML='<svg width="14" height="14" viewBox="0 0 14 14"><path d="M3 3l8 8M11 3l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',t.appendChild(o),n.appendChild(this._drawerTitle),n.appendChild(t),this._drawer.appendChild(n),this._drawerBody=Ue("div",{className:"mvfp-drawer-body"}),this._drawer.appendChild(this._drawerBody)}openDrawer(n){const t=this._filters.find(o=>o.id===n);if(t&&(this._drawerFilterId=n,this._drawerTitle.textContent=t.name,this._renderDrawerControls(t),this._renderActiveChips(),!this._drawerOpen)){this._drawerOpen=!0;const o=this._root.offsetHeight;o>0&&(this._drawer.style.height=o+"px"),this._drawer.style.transition="none",this._drawer.style.transform="translateY(100%)",this._drawer.offsetHeight,this._drawer.style.transition="transform 0.25s cubic-bezier(0.33, 1, 0.68, 1)",this._drawer.style.transform="translateY(0)"}}closeDrawer(){this._drawerOpen&&(this._drawerOpen=!1,this._drawerFilterId=null,this._drawer.style.transition="transform 0.2s cubic-bezier(0.32, 0, 0.67, 0)",this._drawer.style.transform="translateY(100%)",this._renderActiveChips())}_renderDrawerControls(n){if(this._drawerBody.innerHTML="",!n.params||n.params.length===0){this._drawerBody.appendChild(Ue("div",{className:"mvfp-no-params"},"No adjustable parameters"));return}const t=this._activeFilters.get(n.id),o=(t==null?void 0:t.params)||{};for(const i of n.params){const r=o[i.id]??i.default,s=Ue("div",{className:"mvfp-ctl"}),l=Ue("label",{className:"mvfp-ctl-label"},i.label||i.id);s.appendChild(l);const c=i.type||"slider";if(c==="slider"||c==="range"){const d=Ue("div",{className:"mvfp-slider-row"}),u=Ue("span",{className:"mvfp-range-val"},Es(r)),m=Ue("input",{type:"range",className:"mvfp-range",min:String(i.min??0),max:String(i.max??1),step:String(i.step??.01),value:String(typeof r=="number"?r:i.default??0),onInput:p=>{var v,y;const h=parseFloat(p.target.value);u.textContent=Es(h),(y=(v=this._cb).onUpdateParam)==null||y.call(v,n.id,i.id,h)}});d.appendChild(m),d.appendChild(u),s.appendChild(d)}else if(c==="toggle"||c==="checkbox"){const d=Ue("div",{className:"mvfp-toggle-row"}),u=Ue("input",{type:"checkbox",checked:r?"checked":void 0,onChange:m=>{var p,h;return(h=(p=this._cb).onUpdateParam)==null?void 0:h.call(p,n.id,i.id,m.target.checked)}});d.appendChild(u),s.appendChild(d)}else if(c==="color"){const d=Ue("div",{className:"mvfp-color-row"}),u=Ue("input",{type:"color",className:"mvfp-color-input",value:typeof r=="string"?r:"#000000",onInput:m=>{var p,h;return(h=(p=this._cb).onUpdateParam)==null?void 0:h.call(p,n.id,i.id,m.target.value)}});d.appendChild(u),s.appendChild(d)}else if(c==="select"||c==="dropdown"){const d=Ue("div",{className:"mvfp-select-row"}),u=Ue("select",{className:"mvfp-select",onChange:m=>{var p,h;return(h=(p=this._cb).onUpdateParam)==null?void 0:h.call(p,n.id,i.id,m.target.value)}});for(const m of i.options||[]){const p=Ue("option",{value:m.value},m.label||String(m.value));m.value===r&&(p.selected=!0),u.appendChild(p)}d.appendChild(u),s.appendChild(d)}this._drawerBody.appendChild(s)}}_resetDrawerFilter(){var t,o;if(!this._drawerFilterId)return;const n=this._filters.find(i=>i.id===this._drawerFilterId);if(n!=null&&n.params){for(const i of n.params)(o=(t=this._cb).onUpdateParam)==null||o.call(t,this._drawerFilterId,i.id,i.default);this._renderDrawerControls(n)}}}function Ss(a){var s,l;ig(a);const n=rg(a.clips),t=[],o=sg(a),i=lg(a),r={version:"1.0",source:{media_uuid:a.mediaUuid,duration:a.originalDuration,original_width:((s=a.media)==null?void 0:s.width)||1920,original_height:((l=a.media)==null?void 0:l.height)||1080},timeline:n,filters:t,audio:o,output:i,metadata:{created_at:new Date().toISOString(),editor_version:"2.0.0"}};return a.textOverlays&&(r.textOverlays=a.textOverlays),a.audioTracks&&(r.audioTracks=a.audioTracks.filter(c=>typeof c.source=="string")),r}function ig(a){if(!a.mediaUuid)throw new Error("Media UUID is required");if(!a.clips||a.clips.length===0)throw new Error("At least one clip is required");const n=[...a.clips].sort((t,o)=>t.timelineStart-o.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 rg(a){return a.map(n=>{const t=n.speed||1,o=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(o?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 sg(a){const n={volume:a.audioVolume,muted:a.audioVolume===0};return a.audioFadeIn>0&&(n.fadeIn=a.audioFadeIn),a.audioFadeOut>0&&(n.fadeOut=a.audioFadeOut),n}function lg(a){var r;const n={"360p":{bitrate:1e6},"480p":{bitrate:25e5},"720p":{bitrate:5e6},"1080p":{bitrate:8e6},"1440p":{bitrate:16e6},"2160p":{bitrate:35e6}},t=n[a.exportQuality]||n["1080p"],o=(r=a.media)==null?void 0:r.frame_rate,i=o&&Number.isFinite(o)&&o>0?o:30;return{format:a.exportFormat||"mp4",codec:"h264",quality:a.exportQuality||"1080p",fps:i,bitrate:t.bitrate}}function cg(a,n,t){var Fe,Oe;const o=typeof a=="string"&&a.trim()!==""?a.trim():`temp-${Date.now()}`,i=e.reactive({mediaUuid:o,clips:[],playheadPosition:0,totalDuration:0,originalDuration:0,filters:[],audioVolume:1,audioFadeIn:0,audioFadeOut:0,exportQuality:"1080p",exportFormat:"mp4",hasChanges:!1,isPlaying:!1,zoomLevel:100}),r=e.ref(null),s=e.ref([]),l=e.ref([]),c=e.ref(void 0);let d=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0&&t.duration!==1;const u=e.ref(!1),m=e.shallowRef(null),p=new Ol(30),h=e.ref(30),v=e.ref(!1),y=e.ref(!1);n&&n.timeline&&n.timeline.length>0?(N(n),(Fe=n.output)!=null&&Fe.fps&&(h.value=n.output.fps,p.setFps(h.value))):(f(),n&&((Oe=n.output)!=null&&Oe.fps&&(h.value=n.output.fps,p.setFps(h.value)),n.audio&&(i.audioVolume=n.audio.volume||1,i.audioFadeIn=n.audio.fadeIn||0,i.audioFadeOut=n.audio.fadeOut||0),n.output&&(i.exportFormat=n.output.format||"mp4",i.exportQuality=n.output.quality||"1080p")));const E=e.ref(1),_=e.computed(()=>i.selectedClipId?i.clips.find(H=>H.id===i.selectedClipId)??null:null);e.watch(_,H=>{E.value=(H==null?void 0:H.speed)??1},{immediate:!0});const C=e.computed(()=>s.value.length>0),w=e.computed(()=>l.value.length>0);function f(){const H=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0?t.duration:1;t&&(i.media=t),i.originalDuration=H,i.totalDuration=H;const re=me(),xe={id:re,type:"clip",timelineStart:0,timelineEnd:H,sourceIn:0,sourceOut:H,sourceMinIn:0,sourceMaxOut:H,speed:1};i.clips=[xe],i.selectedClipId=re,c.value=re,!(t||o.startsWith("temp-"))&&(async()=>{try{const Ne=await fetch(`/api/v1/video/${encodeURIComponent(o)}`);if(!Ne.ok)throw new Error(`Failed to fetch media: ${Ne.status}`);const ze=await Ne.json(),wt=typeof ze=="object"&&ze!==null&&"data"in ze?ze.data:ze;if(!wt||typeof wt!="object")throw new Error("Failed to parse media payload");const ut=wt;i.media=ut;const St=typeof ut.duration=="number"&&ut.duration>0?ut.duration:H;if(i.hasChanges||i.clips.length!==1||i.clips[0].id!==re)return;i.originalDuration=St,i.totalDuration=St;const Ge=i.clips[0];Ge.timelineStart=0,Ge.timelineEnd=St,Ge.sourceIn=0,Ge.sourceOut=St,Ge.sourceMinIn=0,Ge.sourceMaxOut=St,K(),d=!0}catch{}})()}function x(H,re){if(H.originalDuration!==1)return;H.originalDuration=re,H.totalDuration===1&&(H.totalDuration=re);const xe=H.clips[0],Ne=!n&&H.clips.length===1&&xe!==void 0&&xe.timelineStart===0&&xe.timelineEnd===1&&xe.sourceIn===0&&xe.sourceOut===1;for(const ze of H.clips)(ze.sourceMaxOut===1||ze.sourceMaxOut===void 0)&&(ze.sourceMaxOut=re);Ne&&xe!==void 0&&(xe.sourceOut=re,xe.timelineEnd=re)}function $(H){if(!Number.isFinite(H)||H<=0||d)return;const re=i.hasChanges;i.originalDuration=H,i.totalDuration=Math.max(i.totalDuration,H),i.media&&(i.media.duration=H);for(const ze of i.clips)ze.sourceMaxOut=H;const xe=i.clips[0];!n&&i.clips.length===1&&xe!==void 0&&xe.timelineStart===0&&xe.timelineEnd===1&&xe.sourceIn===0&&xe.sourceOut===1&&xe!==void 0&&(xe.sourceOut=H,xe.timelineEnd=xe.timelineStart+(xe.sourceOut-xe.sourceIn)),K();for(const ze of s.value)x(ze,H);for(const ze of l.value)x(ze,H);d=!0,e.nextTick(()=>{re||(i.hasChanges=!1)})}function N(H){i.clips=H.timeline.map(re=>({...re,sourceMinIn:re.sourceMinIn??0,sourceMaxOut:re.sourceMaxOut??H.source.duration})),i.filters=[],i.audioVolume=H.audio.volume,i.audioFadeIn=H.audio.fadeIn||0,i.audioFadeOut=H.audio.fadeOut||0,i.exportFormat=H.output.format,i.exportQuality=H.output.quality,i.originalDuration=H.source.duration,i.clips.length>0?(i.selectedClipId=i.clips[0].id,c.value=i.selectedClipId):(delete i.selectedClipId,c.value=void 0),K()}function g(){s.value.push(JSON.parse(JSON.stringify(i))),l.value=[],i.hasChanges=!0}function S(){if(!C.value)return;const H=s.value.pop();l.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,H)}function O(){if(!w.value)return;const H=l.value.pop();s.value.push(JSON.parse(JSON.stringify(i))),Object.assign(i,H)}function k(H,re,xe){g();const Ne=i.clips.find(Ge=>Ge.id===H);if(!Ne)return;const wt=1/30,ut=Ne.sourceMinIn??0,St=Ne.sourceMaxOut??i.originalDuration;if(re==="start"){const Ge=Ne.sourceIn,Zt=Math.max(ut,Math.min(xe,Ne.sourceOut-wt));Ne.sourceIn=Zt;const Pa=Zt-Ge;Ne.timelineStart+=Pa}else{const Ge=Math.max(Ne.sourceIn+wt,Math.min(xe,St));Ne.sourceOut=Ge;const Zt=Ne.sourceOut-Ne.sourceIn;Ne.timelineEnd=Ne.timelineStart+Zt}K(),m.value&&m.value.trimClip(H,Ne.sourceIn,Ne.sourceOut)}function T(H){g();const re=i.clips.find(ut=>H>ut.timelineStart&&H<ut.timelineEnd);if(!re)return;const xe=H-re.timelineStart,Ne=re.sourceIn+xe,ze={id:me(),type:"clip",timelineStart:H,timelineEnd:re.timelineEnd,sourceIn:Ne,sourceOut:re.sourceOut,speed:re.speed??1,sourceMinIn:re.sourceMinIn??0,sourceMaxOut:re.sourceMaxOut??i.originalDuration,filters:[...re.filters||[]]};re.timelineEnd=H,re.sourceOut=Ne;const wt=i.clips.indexOf(re);i.clips.splice(wt+1,0,ze),i.selectedClipId=ze.id}function F(){T(i.playheadPosition)}function A(H){var xe;const re=H??i.selectedClipId??c.value??((xe=i.clips[0])==null?void 0:xe.id);re&&(i.selectedClipId=re,c.value=re)}function R(){if(!i.selectedClipId||i.clips.length<=1)return;g();const H=i.clips.findIndex(re=>re.id===i.selectedClipId);if(H!==-1){i.clips.splice(H,1);const re=Math.min(H,i.clips.length-1);i.selectedClipId=i.clips[re].id,c.value=i.selectedClipId,K()}}function j(H,re){g();const xe=i.clips.find(ze=>ze.id===H);if(!xe)return;const Ne=re-xe.timelineStart;xe.timelineStart=re,xe.timelineEnd+=Ne,K(),m.value&&m.value.moveClip(H,re)}function K(){if(i.clips.length===0){i.totalDuration=0;return}const H=i.clips.reduce((re,xe)=>xe.timelineEnd>re.timelineEnd?xe:re);i.totalDuration=H.timelineEnd}function I(){i.zoomLevel=Math.min(200,i.zoomLevel*1.2)}function D(){i.zoomLevel=Math.max(10,i.zoomLevel/1.2)}function Z(H){i.zoomLevel=Math.max(10,Math.min(600,Math.round(H)))}function W(){i.isPlaying=!i.isPlaying}function oe(H){i.isPlaying=H}function we(H){i.playheadPosition=Math.max(0,Math.min(H,i.totalDuration))}function Ce(){const H=Ss(i);try{localStorage.setItem(`video-draft-${o}`,JSON.stringify(H))}catch{}return H}function ne(){i.hasChanges=!1}function M(){return confirm("Are you sure you want to reset all changes?")?(g(),f(),i.hasChanges=!1,!0):!1}function z(){return Ss(i)}function me(){return`clip-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}async function ae(H=1920,re=1080){if(u.value)try{m.value=new Ul(H,re,h.value),await Y()}catch{m.value=null}}async function Y(){if(!(!m.value||y.value)){y.value=!0;try{const H=z();await m.value.loadFromRecipe(H);const re=p.secondsToFrames(i.playheadPosition);m.value.seek(re)}catch{}finally{y.value=!1}}}function Te(H){}function ue(H){return p.secondsToFrames(H)}function se(H){return p.framesToSeconds(H)}function be(H){const re=se(H);we(re),m.value&&m.value.seek(H)}function ie(){v.value=!v.value}function le(){Y()}function ke(H){u.value=!1,m.value=null}e.watch(()=>i.clips,()=>{i.hasChanges=!0,u.value&&m.value&&Y()},{deep:!0}),e.watch(()=>i.filters,()=>{i.hasChanges=!0,u.value&&m.value&&Y()},{deep:!0}),e.watch(()=>i.clips.map(H=>H.id),()=>{var re;if(!i.clips.length){delete i.selectedClipId,c.value=void 0;return}if(!i.clips.some(xe=>xe.id===i.selectedClipId)){const xe=c.value&&((re=i.clips.find(Ne=>Ne.id===c.value))==null?void 0:re.id);i.selectedClipId=xe??i.clips[0].id,c.value=i.selectedClipId}},{deep:!0});function Ve(H){const re=i.selectedClipId?i.clips.find(xe=>xe.id===i.selectedClipId):i.clips[0];re&&(re.filters=[...H],i.hasChanges=!0)}function et(H){i.textOverlays=[...H]}function We(H){i.audioTracks=[...H]}e.watch(u,H=>{H?ae():m.value&&(m.value.destroy(),m.value=null)}),e.watch(v,()=>{}),e.watch(h,H=>{p.setFps(H)});function fe(){if(!i.selectedClipId)return;g();const H=i.clips.find(Ne=>Ne.id===i.selectedClipId);if(!H)return;const re={...H,id:me(),timelineStart:H.timelineEnd,timelineEnd:H.timelineEnd+(H.timelineEnd-H.timelineStart),filters:[...H.filters||[]]},xe=i.clips.indexOf(H);i.clips.splice(xe+1,0,re),i.selectedClipId=re.id,i.hasChanges=!0}function P(H){const re=H??800,xe=i.totalDuration;if(xe<=0){i.zoomLevel=50;return}const Ne=re*.8/xe;i.zoomLevel=Math.max(10,Math.min(600,Math.round(Ne)))}function J(){const H=1/h.value;we(Math.min(i.playheadPosition+H,i.totalDuration))}function ee(){const H=1/h.value;we(Math.max(i.playheadPosition-H,0))}function te(){we(0)}function pe(){we(i.totalDuration)}function ve(H){if(!Number.isFinite(H)||H<=0)return;const re=_.value??i.clips[0];if(!re){E.value=H;return}const xe=re.speed??1;if(xe===H){E.value=H;return}g();const Ne=Math.max(1/h.value,re.sourceOut-re.sourceIn),ze=Ne/xe,wt=Ne/H,ut=wt-ze;re.speed=H,re.timelineEnd=re.timelineStart+wt;const St=i.clips.findIndex(Ge=>Ge.id===re.id);if(St!==-1&&ut!==0)for(let Ge=St+1;Ge<i.clips.length;Ge+=1){const Zt=i.clips[Ge];Zt.timelineStart+=ut,Zt.timelineEnd+=ut}K(),i.playheadPosition=Math.max(0,Math.min(i.playheadPosition,i.totalDuration)),i.hasChanges=!0,E.value=H}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:_,zoomLevel:e.computed(()=>i.zoomLevel),playbackSpeed:E,useVideoEngine:u,compositionAdapter:e.computed(()=>m.value),fps:h,useFrameMode:v,handleTrim:k,handleSplit:T,handleClipSelect:A,splitAtPlayhead:F,deleteSelectedClip:R,duplicateSelectedClip:fe,setFilters:Ve,setTextOverlays:et,setAudioTracks:We,moveClip:j,saveDraft:Ce,clearHasChanges:ne,resetChanges:M,generateRecipe:z,zoomIn:I,zoomOut:D,setZoomLevel:Z,fitToWindow:P,togglePlayback:W,setPlaying:oe,seekTo:we,frameForward:J,frameBackward:ee,skipToStart:te,skipToEnd:pe,setPlaybackSpeed:ve,updateSourceDuration:$,undo:S,redo:O,canUndo:C,canRedo:w,initializeComposition:ae,syncCompositionWithState:Y,syncWithComposition:Te,convertToFrames:ue,convertToSeconds:se,seekToFrame:be,toggleFrameMode:ie,onCompositionReady:le,onCompositionError:ke}}const dg=[{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}}}],ug={dropShadow:"drop-shadow",softFocus:"blur",blackAndWhite:"grayscale",gaussianBlur:"blur","gaussian-blur":"blur"};function Ba(a){return typeof a=="object"&&a!==null}function mg(a,n){if(typeof a=="number"&&Number.isFinite(a))return a;if(typeof a=="string"){const t=Number(a);if(Number.isFinite(t))return t}return n}function Ia(a){if(typeof a=="number"||typeof a=="string"||typeof a=="boolean")return a}function pg(a){const n={id:a.id,type:a.type,label:a.label};a.property!==void 0&&(n.property=a.property),a.min!==void 0&&(n.min=a.min),a.max!==void 0&&(n.max=a.max),a.step!==void 0&&(n.step=a.step);const t=Ia(a.default);return t!==void 0&&(n.default=t),a.options!==void 0&&(n.options=a.options),n}function Al(a,n,t){const o=rt.getFilter(a),i={},r=(o==null?void 0:o.defaultParams)??t;if(r&&Ba(r))for(const[s,l]of Object.entries(r))i[s]=Ia(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 Ll(a){const n={};for(const t of a){if(t.type!=="slider")continue;const o=t.property??t.id;n[o]={min:t.min??0,max:t.max??100,step:t.step??1}}return n}function fg(a,n,t,o){const i=o.map(pg);return{id:a,name:n,category:t,controls:i,params:i,defaultParams:Al(a,i),paramRanges:Ll(i)}}function hg(a){const n=a.paramRanges??{},t=Object.entries(n).map(([o,i])=>{var l;const r={id:o,type:"slider",label:o.replace(/[-_]/g," ").replace(/\b\w/g,c=>c.toUpperCase()),property:o,min:i.min,max:i.max,step:i.step},s=Ia((l=a.defaultParams)==null?void 0:l[o]);return s!==void 0&&(r.default=s),r});return{id:a.id,name:a.name,category:a.category,controls:t,params:t,defaultParams:Al(a.id,t,a.defaultParams),paramRanges:Ll(t)}}function vg(a,n){return n.toLowerCase()==="unlisted"?!1:rt.isFilterCompatibleWithMedia(a,"video")}function di(a){return ug[a]??a}function ao(a){const n=mg(a,1);return Math.max(0,Math.min(1,n))}function io(a){if(!Ba(a))return{};const n={};for(const[t,o]of Object.entries(a))n[t]=Ia(o)??null;return n}function gg(a){return!Ba(a)||typeof a.filterId!="string"?null:{filterId:a.filterId,params:io(a.params),intensity:ao(a.intensity)}}function yg(a){if(!Ba(a)||typeof a.id!="string"||typeof a.name!="string")return null;const t=(Array.isArray(a.filters)?a.filters:[]).map(i=>gg(i)).filter(i=>i!==null),o=typeof a.created_at=="string"?a.created_at:new Date().toISOString();return{id:a.id,name:a.name,filters:t,created_at:o}}function wg(){rt.initializeFilterRegistry();const a=e.ref([]),n=e.ref(null),t=e.ref(null),o=e.ref([]),i=e.ref(null),r=e.reactive({}),s=e.computed(()=>{const F=new Map,A=rt.getRegisteredFilters();for(const R of A)vg(R.id,R.category)&&F.set(R.id,fg(R.id,R.name,R.category,R.controls));for(const R of dg)F.has(R.id)||F.set(R.id,hg(R));return Array.from(F.values())}),l=e.computed(()=>{const F=new Map;for(const A of s.value)F.set(A.id,A);return F}),c=e.computed(()=>a.value.length>0),d=e.computed(()=>{const F={};for(const A of s.value)F[A.category]||(F[A.category]=[]),F[A.category].push(A);return F});function u(F){const A=l.value.get(F);if(A)return A;const R=di(F);return l.value.get(R)??null}function m(F){const A=l.value.get(F);if(A)return A.id;const R=di(F),j=l.value.get(R);return j?j.id:null}function p(F){const A=F?u(F):n.value;if(!A)return;const R=A.defaultParams||{},j={id:S(),filterId:A.id,params:{...R},intensity:1};return a.value.push(j),i.value=j.id,n.value=A,Object.keys(r).forEach(K=>delete r[K]),Object.assign(r,j.params),t.value=null,j}function h(F){const A=u(F);if(!A)return;n.value=A;const R=A.defaultParams||k(F);Object.assign(r,R),t.value={id:"preview",filterId:A.id,params:{...R},intensity:1}}function v(F){if(Object.assign(r,F),t.value&&(t.value.params={...r}),i.value){const A=a.value.find(R=>R.id===i.value);A&&(A.params={...r})}}function y(F){const A=a.value.findIndex(R=>R.id===F);A!==-1&&a.value.splice(A,1)}function E(F,A){if(F<0||F>=a.value.length||A<0||A>=a.value.length)return;const[R]=a.value.splice(F,1);a.value.splice(A,0,R)}function _(F,A){const R=a.value.find(j=>j.id===F);R&&(R.intensity=Math.max(0,Math.min(1,A)))}function C(F){const A=a.value.find(R=>R.id===F);A&&(A.intensity=A.intensity>0?0:1)}function w(){a.value=[],t.value=null,n.value=null,i.value=null,Object.keys(r).forEach(F=>delete r[F])}function f(F){const A={id:O(),name:F,filters:a.value.map(j=>({filterId:j.filterId,params:io(j.params),intensity:ao(j.intensity)})),created_at:new Date().toISOString()};o.value.push(A);const R=o.value.map(j=>({...j}));return localStorage.setItem("video-filter-presets",JSON.stringify(R)),A}function x(F){const A=o.value.find(R=>R.id===F);if(A){w();for(const R of A.filters){const j=u(R.filterId);j&&a.value.push({id:S(),filterId:j.id,params:{...R.params},intensity:ao(R.intensity)})}}}function $(F){const A=o.value.findIndex(R=>R.id===F);A!==-1&&(o.value.splice(A,1),localStorage.setItem("video-filter-presets",JSON.stringify(o.value)))}function N(){try{const F=localStorage.getItem("video-filter-presets");if(!F)return;const A=JSON.parse(F);if(!Array.isArray(A))return;o.value=A.map(R=>yg(R)).filter(R=>R!==null)}catch{}}function g(){if(a.value.length===0)return"No filters applied";const F=a.value.map(A=>{const R=T(A.filterId);return(R==null?void 0:R.name)||A.filterId});return F.length===1?F[0]:F.length===2?`${F[0]} + ${F[1]}`:`${F[0]} + ${F.length-1} more`}function S(){return`filter-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function O(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function k(F){const A=u(F);return A?A.defaultParams||{}:{}}function T(F){return u(F)}return N(),{videoCompatibleFilters:s,activeFilters:a,selectedFilter:n,previewFilter:t,filterPresets:o,filterParams:r,hasActiveFilters:c,filtersByCategory:d,applyFilter:p,previewFilterEffect:h,updateFilterParams:v,removeFilter:y,reorderFilters:E,updateFilterIntensity:_,toggleFilter:C,clearAllFilters:w,saveFilterPreset:f,loadFilterPreset:x,deleteFilterPreset:$,getFilterSummary:g,setActiveFilters(F){var R;const A=[];for(const j of F){const K=m(j.filterId);if(!K){const I=di(j.filterId);A.push({...j,filterId:I,params:io(j.params),intensity:ao(j.intensity)});continue}A.push({...j,filterId:K,params:io(j.params),intensity:ao(j.intensity)})}a.value=A,i.value=((R=a.value[0])==null?void 0:R.id)??null,Object.keys(r).forEach(j=>delete r[j]),a.value[0]&&Object.assign(r,io(a.value[0].params))}}}class bg{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 ct({source:"https://fonts.googleapis.com/css2?family=Inter:wght@400",family:"Inter",weight:"400"})),this.fonts.set("bold",new ct({source:"https://fonts.googleapis.com/css2?family=Inter:wght@700",family:"Inter",weight:"700"})),this.fonts.set("serif",new ct({source:"https://fonts.googleapis.com/css2?family=Merriweather:wght@400",family:"Merriweather",weight:"400"}))}catch{}}async loadWebFont(n,t,o,i="400"){const r=new ct({source:t,family:o,weight:i});this.fonts.set(n,r)}loadLocalFont(n,t,o="400"){const i=new ct({source:`local('${t}')`,family:t,weight:o});this.fonts.set(n,i)}async addTextOverlay(n){const t=`text-overlay-${this.nextId++}`,o={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(o.font=r,n.position)if(typeof n.position=="string")switch(n.position){case"center":o.position="center";break;case"top":o.x="50%",o.y="10%";break;case"bottom":o.x="50%",o.y="90%";break;case"left":o.x="10%",o.y="50%";break;case"right":o.x="90%",o.y="50%";break}else o.x=n.position.x,o.y=n.position.y;else o.position="center";if(n.startTime!==void 0&&(o.start=ge.fromSeconds(n.startTime)),n.duration!==void 0){const l=n.startTime||0;o.stop=ge.fromSeconds(l+n.duration)}n.animation&&this.applyAnimation(o,n.animation,n);const s=new An(o);return await this.composition.add(s),this.textClips.set(t,s),t}applyAnimation(n,t,o){if(!t)return;const i=o.startTime?Math.round(o.startTime*30):0,r=t.duration||1,s=Math.round(r*30),l=i+s,c=t.easing||"linear";switch(t.type){case"fade-in":n.alpha=new Ee([i,l],[0,1],{easing:c});break;case"fade-out":n.alpha=new Ee([i,l],[1,0],{easing:c});break;case"rotate":t.rotation&&(n.rotation=new Ee([i,l],[t.rotation.from,t.rotation.to],{easing:c}));break;case"scale":t.scale&&(n.scale=new Ee([i,l],[t.scale.from,t.scale.to],{easing:c}));break;case"slide":t.translate&&(n.translate={x:new Ee([i,l],[t.translate.fromX,t.translate.toX],{easing:c}),y:new Ee([i,l],[t.translate.fromY,t.translate.toY],{easing:c})});break;case"typewriter":n.alpha=new Ee([i,l],[0,1],{easing:"linear"});break;case"custom":t.rotation&&(n.rotation=new Ee([i,l],[t.rotation.from,t.rotation.to],{easing:c})),t.scale&&(n.scale=new Ee([i,l],[t.scale.from,t.scale.to],{easing:c})),t.translate&&(n.translate={x:new Ee([i,l],[t.translate.fromX,t.translate.toX],{easing:c}),y:new Ee([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 o=this.composition.tracks;for(const i of o){const r=i.clips.indexOf(t);if(r!==-1){i.clips.splice(r,1);break}}this.textClips.delete(n)}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,o)=>{const i={text:t.text||"",fontSize:t.fontSize,color:t.fillStyle,fontFamily:"default",position:"center"};n.push({id:o,config:i})}),n}async addCaptions(n,t="classic",o){var c,d;const r={classic:xo,cascade:Ca,guinea:Sa,solar:Na,spotlight:Eo,whisper:Vo}[t],s=await this.composition.createTrack("caption"),l=new wa({transcript:n});if(await s.add(l),await((c=s.generate)==null?void 0:c.call(s,r)),o&&s.clips.length>0){const u=s.clips[0];(d=u.set)==null||d.call(u,o)}}}class kg{constructor(n){this.audioLayers=new Map,this.audioSources=new Map,this.nextId=0,this.masterVolume=1,this.composition=n}async loadAudioSource(n,t){try{const o=await rn.from(n),i=t||`audio-source-${this.nextId++}`;return this.audioSources.set(i,o),o}catch(o){throw o instanceof Error?o:new Error("Failed to load audio source")}}async addBackgroundMusic(n){return this.addAudioTrack({...n,name:n.name||"Background Music"})}async addAudioTrack(n){const t=`audio-track-${this.nextId++}`;let o;try{if(typeof n.source=="object"&&n.source instanceof rn)o=n.source;else if(typeof n.source=="string")o=await rn.from(n.source);else if(typeof n.source=="object"&&n.source instanceof File)o=await rn.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:o,volume:(n.volume??1)*this.masterVolume};if(n.startTime!==void 0&&(i.start=ge.fromSeconds(n.startTime)),n.duration!==void 0){const c=n.startTime||0;i.stop=ge.fromSeconds(c+n.duration)}(n.fadeIn||n.fadeOut)&&(i.volume=this.createVolumeKeyframes(n));const r=new ua(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,o=n.startTime?Math.round(n.startTime*30):0,i=n.duration,r=[],s=[];if(n.fadeIn){const l=Math.round(n.fadeIn*30);r.push(o,o+l),s.push(0,t)}else r.push(o),s.push(t);if(n.fadeOut&&i){const l=o+Math.round(i*30),c=Math.round(n.fadeOut*30);n.fadeIn||(r.push(l-c),s.push(t)),r.push(l),s.push(0)}return new Ee(r,s,{easing:"linear"})}async updateVolume(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);const i=Math.max(0,Math.min(1,t));o.clip.volume=i*this.masterVolume,o.config.volume=i}async applyFadeIn(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);o.config.fadeIn=t,o.clip.set({volume:this.createVolumeKeyframes(o.config)})}async applyFadeOut(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);o.config.fadeOut=t,o.clip.set({volume:this.createVolumeKeyframes(o.config)})}async removeAudioTrack(n){const t=this.audioLayers.get(n);if(!t)throw new Error(`Audio track with id ${n} not found`);const o=t.track.clips.indexOf(t.clip);o!==-1&&t.track.clips.splice(o,1),this.audioLayers.delete(n)}async muteTrack(n,t){const o=this.audioLayers.get(n);if(!o)throw new Error(`Audio track with id ${n} not found`);t?o.clip.volume=0:o.clip.volume=(o.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 o of this.audioLayers.values()){const i=o.config.startTime||0,r=o.config.duration||t-n;if(i+r>t){o.config.duration=t-i;const s=new ua({source:o.clip.source,start:ge.fromSeconds(i),stop:ge.fromSeconds(t),volume:o.clip.volume}),l=o.track.clips.indexOf(o.clip);l!==-1&&(o.track.clips[l]=s,o.clip=s)}}}exportConfiguration(){return Array.from(this.audioLayers.values()).map(n=>({id:n.id,name:n.name,config:{...n.config,source:n.config.source&&typeof n.config.source=="object"&&"type"in n.config.source?"[AudioSource]":n.config.source}}))}async importConfiguration(n){for(const{name:t,config:o}of n)await this.addAudioTrack({...o,name:t})}}function zl(a,n){return function(){return a.apply(n,arguments)}}const{toString:xg}=Object.prototype,{getPrototypeOf:cr}=Object,{iterator:Fa,toStringTag:Pl}=Symbol,Ra=(a=>n=>{const t=xg.call(n);return a[t]||(a[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),It=a=>(a=a.toLowerCase(),n=>Ra(n)===a),$a=a=>n=>typeof n===a,{isArray:Pn}=Array,vo=$a("undefined");function So(a){return a!==null&&!vo(a)&&a.constructor!==null&&!vo(a.constructor)&&vt(a.constructor.isBuffer)&&a.constructor.isBuffer(a)}const jl=It("ArrayBuffer");function Eg(a){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(a):n=a&&a.buffer&&jl(a.buffer),n}const Vg=$a("string"),vt=$a("function"),Wl=$a("number"),Co=a=>a!==null&&typeof a=="object",Sg=a=>a===!0||a===!1,Qo=a=>{if(Ra(a)!=="object")return!1;const n=cr(a);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Pl in a)&&!(Fa in a)},Cg=a=>{if(!Co(a)||So(a))return!1;try{return Object.keys(a).length===0&&Object.getPrototypeOf(a)===Object.prototype}catch{return!1}},Ng=It("Date"),_g=It("File"),Tg=It("Blob"),Mg=It("FileList"),Bg=a=>Co(a)&&vt(a.pipe),Ig=a=>{let n;return a&&(typeof FormData=="function"&&a instanceof FormData||vt(a.append)&&((n=Ra(a))==="formdata"||n==="object"&&vt(a.toString)&&a.toString()==="[object FormData]"))},Fg=It("URLSearchParams"),[Rg,$g,Dg,Ug]=["ReadableStream","Request","Response","Headers"].map(It),Og=a=>a.trim?a.trim():a.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function No(a,n,{allOwnKeys:t=!1}={}){if(a===null||typeof a>"u")return;let o,i;if(typeof a!="object"&&(a=[a]),Pn(a))for(o=0,i=a.length;o<i;o++)n.call(null,a[o],o,a);else{if(So(a))return;const r=t?Object.getOwnPropertyNames(a):Object.keys(a),s=r.length;let l;for(o=0;o<s;o++)l=r[o],n.call(null,a[l],l,a)}}function Zl(a,n){if(So(a))return null;n=n.toLowerCase();const t=Object.keys(a);let o=t.length,i;for(;o-- >0;)if(i=t[o],n===i.toLowerCase())return i;return null}const hn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Xl=a=>!vo(a)&&a!==hn;function Ri(){const{caseless:a}=Xl(this)&&this||{},n={},t=(o,i)=>{const r=a&&Zl(n,i)||i;Qo(n[r])&&Qo(o)?n[r]=Ri(n[r],o):Qo(o)?n[r]=Ri({},o):Pn(o)?n[r]=o.slice():n[r]=o};for(let o=0,i=arguments.length;o<i;o++)arguments[o]&&No(arguments[o],t);return n}const Ag=(a,n,t,{allOwnKeys:o}={})=>(No(n,(i,r)=>{t&&vt(i)?a[r]=zl(i,t):a[r]=i},{allOwnKeys:o}),a),Lg=a=>(a.charCodeAt(0)===65279&&(a=a.slice(1)),a),zg=(a,n,t,o)=>{a.prototype=Object.create(n.prototype,o),a.prototype.constructor=a,Object.defineProperty(a,"super",{value:n.prototype}),t&&Object.assign(a.prototype,t)},Pg=(a,n,t,o)=>{let i,r,s;const l={};if(n=n||{},a==null)return n;do{for(i=Object.getOwnPropertyNames(a),r=i.length;r-- >0;)s=i[r],(!o||o(s,a,n))&&!l[s]&&(n[s]=a[s],l[s]=!0);a=t!==!1&&cr(a)}while(a&&(!t||t(a,n))&&a!==Object.prototype);return n},jg=(a,n,t)=>{a=String(a),(t===void 0||t>a.length)&&(t=a.length),t-=n.length;const o=a.indexOf(n,t);return o!==-1&&o===t},Wg=a=>{if(!a)return null;if(Pn(a))return a;let n=a.length;if(!Wl(n))return null;const t=new Array(n);for(;n-- >0;)t[n]=a[n];return t},Zg=(a=>n=>a&&n instanceof a)(typeof Uint8Array<"u"&&cr(Uint8Array)),Xg=(a,n)=>{const o=(a&&a[Fa]).call(a);let i;for(;(i=o.next())&&!i.done;){const r=i.value;n.call(a,r[0],r[1])}},Hg=(a,n)=>{let t;const o=[];for(;(t=a.exec(n))!==null;)o.push(t);return o},Gg=It("HTMLFormElement"),Jg=a=>a.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,o,i){return o.toUpperCase()+i}),Cs=(({hasOwnProperty:a})=>(n,t)=>a.call(n,t))(Object.prototype),Yg=It("RegExp"),Hl=(a,n)=>{const t=Object.getOwnPropertyDescriptors(a),o={};No(t,(i,r)=>{let s;(s=n(i,r,a))!==!1&&(o[r]=s||i)}),Object.defineProperties(a,o)},Kg=a=>{Hl(a,(n,t)=>{if(vt(a)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const o=a[t];if(vt(o)){if(n.enumerable=!1,"writable"in n){n.writable=!1;return}n.set||(n.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},qg=(a,n)=>{const t={},o=i=>{i.forEach(r=>{t[r]=!0})};return Pn(a)?o(a):o(String(a).split(n)),t},Qg=()=>{},ey=(a,n)=>a!=null&&Number.isFinite(a=+a)?a:n;function ty(a){return!!(a&&vt(a.append)&&a[Pl]==="FormData"&&a[Fa])}const ny=a=>{const n=new Array(10),t=(o,i)=>{if(Co(o)){if(n.indexOf(o)>=0)return;if(So(o))return o;if(!("toJSON"in o)){n[i]=o;const r=Pn(o)?[]:{};return No(o,(s,l)=>{const c=t(s,i+1);!vo(c)&&(r[l]=c)}),n[i]=void 0,r}}return o};return t(a,0)},oy=It("AsyncFunction"),ay=a=>a&&(Co(a)||vt(a))&&vt(a.then)&&vt(a.catch),Gl=((a,n)=>a?setImmediate:n?((t,o)=>(hn.addEventListener("message",({source:i,data:r})=>{i===hn&&r===t&&o.length&&o.shift()()},!1),i=>{o.push(i),hn.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",vt(hn.postMessage)),iy=typeof queueMicrotask<"u"?queueMicrotask.bind(hn):typeof process<"u"&&process.nextTick||Gl,ry=a=>a!=null&&vt(a[Fa]),G={isArray:Pn,isArrayBuffer:jl,isBuffer:So,isFormData:Ig,isArrayBufferView:Eg,isString:Vg,isNumber:Wl,isBoolean:Sg,isObject:Co,isPlainObject:Qo,isEmptyObject:Cg,isReadableStream:Rg,isRequest:$g,isResponse:Dg,isHeaders:Ug,isUndefined:vo,isDate:Ng,isFile:_g,isBlob:Tg,isRegExp:Yg,isFunction:vt,isStream:Bg,isURLSearchParams:Fg,isTypedArray:Zg,isFileList:Mg,forEach:No,merge:Ri,extend:Ag,trim:Og,stripBOM:Lg,inherits:zg,toFlatObject:Pg,kindOf:Ra,kindOfTest:It,endsWith:jg,toArray:Wg,forEachEntry:Xg,matchAll:Hg,isHTMLForm:Gg,hasOwnProperty:Cs,hasOwnProp:Cs,reduceDescriptors:Hl,freezeMethods:Kg,toObjectSet:qg,toCamelCase:Jg,noop:Qg,toFiniteNumber:ey,findKey:Zl,global:hn,isContextDefined:Xl,isSpecCompliantForm:ty,toJSONObject:ny,isAsyncFn:oy,isThenable:ay,setImmediate:Gl,asap:iy,isIterable:ry};function Be(a,n,t,o,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=a,this.name="AxiosError",n&&(this.code=n),t&&(this.config=t),o&&(this.request=o),i&&(this.response=i,this.status=i.status?i.status:null)}G.inherits(Be,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:G.toJSONObject(this.config),code:this.code,status:this.status}}});const Jl=Be.prototype,Yl={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(a=>{Yl[a]={value:a}});Object.defineProperties(Be,Yl);Object.defineProperty(Jl,"isAxiosError",{value:!0});Be.from=(a,n,t,o,i,r)=>{const s=Object.create(Jl);return G.toFlatObject(a,s,function(c){return c!==Error.prototype},l=>l!=="isAxiosError"),Be.call(s,a.message,n,t,o,i),s.cause=a,s.name=a.name,r&&Object.assign(s,r),s};const sy=null;function $i(a){return G.isPlainObject(a)||G.isArray(a)}function Kl(a){return G.endsWith(a,"[]")?a.slice(0,-2):a}function Ns(a,n,t){return a?a.concat(n).map(function(i,r){return i=Kl(i),!t&&r?"["+i+"]":i}).join(t?".":""):n}function ly(a){return G.isArray(a)&&!a.some($i)}const cy=G.toFlatObject(G,{},null,function(n){return/^is[A-Z]/.test(n)});function Da(a,n,t){if(!G.isObject(a))throw new TypeError("target must be an object");n=n||new FormData,t=G.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,E){return!G.isUndefined(E[y])});const o=t.metaTokens,i=t.visitor||u,r=t.dots,s=t.indexes,c=(t.Blob||typeof Blob<"u"&&Blob)&&G.isSpecCompliantForm(n);if(!G.isFunction(i))throw new TypeError("visitor must be a function");function d(v){if(v===null)return"";if(G.isDate(v))return v.toISOString();if(G.isBoolean(v))return v.toString();if(!c&&G.isBlob(v))throw new Be("Blob is not supported. Use a Buffer instead.");return G.isArrayBuffer(v)||G.isTypedArray(v)?c&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function u(v,y,E){let _=v;if(v&&!E&&typeof v=="object"){if(G.endsWith(y,"{}"))y=o?y:y.slice(0,-2),v=JSON.stringify(v);else if(G.isArray(v)&&ly(v)||(G.isFileList(v)||G.endsWith(y,"[]"))&&(_=G.toArray(v)))return y=Kl(y),_.forEach(function(w,f){!(G.isUndefined(w)||w===null)&&n.append(s===!0?Ns([y],f,r):s===null?y:y+"[]",d(w))}),!1}return $i(v)?!0:(n.append(Ns(E,y,r),d(v)),!1)}const m=[],p=Object.assign(cy,{defaultVisitor:u,convertValue:d,isVisitable:$i});function h(v,y){if(!G.isUndefined(v)){if(m.indexOf(v)!==-1)throw Error("Circular reference detected in "+y.join("."));m.push(v),G.forEach(v,function(_,C){(!(G.isUndefined(_)||_===null)&&i.call(n,_,G.isString(C)?C.trim():C,y,p))===!0&&h(_,y?y.concat(C):[C])}),m.pop()}}if(!G.isObject(a))throw new TypeError("data must be an object");return h(a),n}function _s(a){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(a).replace(/[!'()~]|%20|%00/g,function(o){return n[o]})}function dr(a,n){this._pairs=[],a&&Da(a,this,n)}const ql=dr.prototype;ql.append=function(n,t){this._pairs.push([n,t])};ql.toString=function(n){const t=n?function(o){return n.call(this,o,_s)}:_s;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function dy(a){return encodeURIComponent(a).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Ql(a,n,t){if(!n)return a;const o=t&&t.encode||dy;G.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let r;if(i?r=i(n,t):r=G.isURLSearchParams(n)?n.toString():new dr(n,t).toString(o),r){const s=a.indexOf("#");s!==-1&&(a=a.slice(0,s)),a+=(a.indexOf("?")===-1?"?":"&")+r}return a}class Ts{constructor(){this.handlers=[]}use(n,t,o){return this.handlers.push({fulfilled:n,rejected:t,synchronous:o?o.synchronous:!1,runWhen:o?o.runWhen:null}),this.handlers.length-1}eject(n){this.handlers[n]&&(this.handlers[n]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(n){G.forEach(this.handlers,function(o){o!==null&&n(o)})}}const ec={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},uy=typeof URLSearchParams<"u"?URLSearchParams:dr,my=typeof FormData<"u"?FormData:null,py=typeof Blob<"u"?Blob:null,fy={isBrowser:!0,classes:{URLSearchParams:uy,FormData:my,Blob:py},protocols:["http","https","file","blob","url","data"]},ur=typeof window<"u"&&typeof document<"u",Di=typeof navigator=="object"&&navigator||void 0,hy=ur&&(!Di||["ReactNative","NativeScript","NS"].indexOf(Di.product)<0),vy=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",gy=ur&&window.location.href||"http://localhost",yy=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ur,hasStandardBrowserEnv:hy,hasStandardBrowserWebWorkerEnv:vy,navigator:Di,origin:gy},Symbol.toStringTag,{value:"Module"})),dt={...yy,...fy};function wy(a,n){return Da(a,new dt.classes.URLSearchParams,{visitor:function(t,o,i,r){return dt.isNode&&G.isBuffer(t)?(this.append(o,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...n})}function by(a){return G.matchAll(/\w+|\[(\w*)]/g,a).map(n=>n[0]==="[]"?"":n[1]||n[0])}function ky(a){const n={},t=Object.keys(a);let o;const i=t.length;let r;for(o=0;o<i;o++)r=t[o],n[r]=a[r];return n}function tc(a){function n(t,o,i,r){let s=t[r++];if(s==="__proto__")return!0;const l=Number.isFinite(+s),c=r>=t.length;return s=!s&&G.isArray(i)?i.length:s,c?(G.hasOwnProp(i,s)?i[s]=[i[s],o]:i[s]=o,!l):((!i[s]||!G.isObject(i[s]))&&(i[s]=[]),n(t,o,i[s],r)&&G.isArray(i[s])&&(i[s]=ky(i[s])),!l)}if(G.isFormData(a)&&G.isFunction(a.entries)){const t={};return G.forEachEntry(a,(o,i)=>{n(by(o),i,t,0)}),t}return null}function xy(a,n,t){if(G.isString(a))try{return(n||JSON.parse)(a),G.trim(a)}catch(o){if(o.name!=="SyntaxError")throw o}return(t||JSON.stringify)(a)}const _o={transitional:ec,adapter:["xhr","http","fetch"],transformRequest:[function(n,t){const o=t.getContentType()||"",i=o.indexOf("application/json")>-1,r=G.isObject(n);if(r&&G.isHTMLForm(n)&&(n=new FormData(n)),G.isFormData(n))return i?JSON.stringify(tc(n)):n;if(G.isArrayBuffer(n)||G.isBuffer(n)||G.isStream(n)||G.isFile(n)||G.isBlob(n)||G.isReadableStream(n))return n;if(G.isArrayBufferView(n))return n.buffer;if(G.isURLSearchParams(n))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let l;if(r){if(o.indexOf("application/x-www-form-urlencoded")>-1)return wy(n,this.formSerializer).toString();if((l=G.isFileList(n))||o.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Da(l?{"files[]":n}:n,c&&new c,this.formSerializer)}}return r||i?(t.setContentType("application/json",!1),xy(n)):n}],transformResponse:[function(n){const t=this.transitional||_o.transitional,o=t&&t.forcedJSONParsing,i=this.responseType==="json";if(G.isResponse(n)||G.isReadableStream(n))return n;if(n&&G.isString(n)&&(o&&!this.responseType||i)){const s=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(n)}catch(l){if(s)throw l.name==="SyntaxError"?Be.from(l,Be.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:dt.classes.FormData,Blob:dt.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};G.forEach(["delete","get","head","post","put","patch"],a=>{_o.headers[a]={}});const Ey=G.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"]),Vy=a=>{const n={};let t,o,i;return a&&a.split(`
|
|
337
|
-
`).forEach(function(s){i=s.indexOf(":"),t=s.substring(0,i).trim().toLowerCase(),o=s.substring(i+1).trim(),!(!t||n[t]&&Ey[t])&&(t==="set-cookie"?n[t]?n[t].push(o):n[t]=[o]:n[t]=n[t]?n[t]+", "+o:o)}),n},Ms=Symbol("internals");function Kn(a){return a&&String(a).trim().toLowerCase()}function ea(a){return a===!1||a==null?a:G.isArray(a)?a.map(ea):String(a)}function Sy(a){const n=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let o;for(;o=t.exec(a);)n[o[1]]=o[2];return n}const Cy=a=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(a.trim());function ui(a,n,t,o,i){if(G.isFunction(o))return o.call(this,n,t);if(i&&(n=t),!!G.isString(n)){if(G.isString(o))return n.indexOf(o)!==-1;if(G.isRegExp(o))return o.test(n)}}function Ny(a){return a.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(n,t,o)=>t.toUpperCase()+o)}function _y(a,n){const t=G.toCamelCase(" "+n);["get","set","has"].forEach(o=>{Object.defineProperty(a,o+t,{value:function(i,r,s){return this[o].call(this,n,i,r,s)},configurable:!0})})}let gt=class{constructor(n){n&&this.set(n)}set(n,t,o){const i=this;function r(l,c,d){const u=Kn(c);if(!u)throw new Error("header name must be a non-empty string");const m=G.findKey(i,u);(!m||i[m]===void 0||d===!0||d===void 0&&i[m]!==!1)&&(i[m||c]=ea(l))}const s=(l,c)=>G.forEach(l,(d,u)=>r(d,u,c));if(G.isPlainObject(n)||n instanceof this.constructor)s(n,t);else if(G.isString(n)&&(n=n.trim())&&!Cy(n))s(Vy(n),t);else if(G.isObject(n)&&G.isIterable(n)){let l={},c,d;for(const u of n){if(!G.isArray(u))throw TypeError("Object iterator must return a key-value pair");l[d=u[0]]=(c=l[d])?G.isArray(c)?[...c,u[1]]:[c,u[1]]:u[1]}s(l,t)}else n!=null&&r(t,n,o);return this}get(n,t){if(n=Kn(n),n){const o=G.findKey(this,n);if(o){const i=this[o];if(!t)return i;if(t===!0)return Sy(i);if(G.isFunction(t))return t.call(this,i,o);if(G.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(n,t){if(n=Kn(n),n){const o=G.findKey(this,n);return!!(o&&this[o]!==void 0&&(!t||ui(this,this[o],o,t)))}return!1}delete(n,t){const o=this;let i=!1;function r(s){if(s=Kn(s),s){const l=G.findKey(o,s);l&&(!t||ui(o,o[l],l,t))&&(delete o[l],i=!0)}}return G.isArray(n)?n.forEach(r):r(n),i}clear(n){const t=Object.keys(this);let o=t.length,i=!1;for(;o--;){const r=t[o];(!n||ui(this,this[r],r,n,!0))&&(delete this[r],i=!0)}return i}normalize(n){const t=this,o={};return G.forEach(this,(i,r)=>{const s=G.findKey(o,r);if(s){t[s]=ea(i),delete t[r];return}const l=n?Ny(r):String(r).trim();l!==r&&delete t[r],t[l]=ea(i),o[l]=!0}),this}concat(...n){return this.constructor.concat(this,...n)}toJSON(n){const t=Object.create(null);return G.forEach(this,(o,i)=>{o!=null&&o!==!1&&(t[i]=n&&G.isArray(o)?o.join(", "):o)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([n,t])=>n+": "+t).join(`
|
|
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 o=new this(n);return t.forEach(i=>o.set(i)),o}static accessor(n){const o=(this[Ms]=this[Ms]={accessors:{}}).accessors,i=this.prototype;function r(s){const l=Kn(s);o[l]||(_y(i,s),o[l]=!0)}return G.isArray(n)?n.forEach(r):r(n),this}};gt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);G.reduceDescriptors(gt.prototype,({value:a},n)=>{let t=n[0].toUpperCase()+n.slice(1);return{get:()=>a,set(o){this[t]=o}}});G.freezeMethods(gt);function mi(a,n){const t=this||_o,o=n||t,i=gt.from(o.headers);let r=o.data;return G.forEach(a,function(l){r=l.call(t,r,i.normalize(),n?n.status:void 0)}),i.normalize(),r}function nc(a){return!!(a&&a.__CANCEL__)}function jn(a,n,t){Be.call(this,a??"canceled",Be.ERR_CANCELED,n,t),this.name="CanceledError"}G.inherits(jn,Be,{__CANCEL__:!0});function oc(a,n,t){const o=t.config.validateStatus;!t.status||!o||o(t.status)?a(t):n(new Be("Request failed with status code "+t.status,[Be.ERR_BAD_REQUEST,Be.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function Ty(a){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(a);return n&&n[1]||""}function My(a,n){a=a||10;const t=new Array(a),o=new Array(a);let i=0,r=0,s;return n=n!==void 0?n:1e3,function(c){const d=Date.now(),u=o[r];s||(s=d),t[i]=c,o[i]=d;let m=r,p=0;for(;m!==i;)p+=t[m++],m=m%a;if(i=(i+1)%a,i===r&&(r=(r+1)%a),d-s<n)return;const h=u&&d-u;return h?Math.round(p*1e3/h):void 0}}function By(a,n){let t=0,o=1e3/n,i,r;const s=(d,u=Date.now())=>{t=u,i=null,r&&(clearTimeout(r),r=null),a(...d)};return[(...d)=>{const u=Date.now(),m=u-t;m>=o?s(d,u):(i=d,r||(r=setTimeout(()=>{r=null,s(i)},o-m)))},()=>i&&s(i)]}const pa=(a,n,t=3)=>{let o=0;const i=My(50,250);return By(r=>{const s=r.loaded,l=r.lengthComputable?r.total:void 0,c=s-o,d=i(c),u=s<=l;o=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};a(m)},t)},Bs=(a,n)=>{const t=a!=null;return[o=>n[0]({lengthComputable:t,total:a,loaded:o}),n[1]]},Is=a=>(...n)=>G.asap(()=>a(...n)),Iy=dt.hasStandardBrowserEnv?((a,n)=>t=>(t=new URL(t,dt.origin),a.protocol===t.protocol&&a.host===t.host&&(n||a.port===t.port)))(new URL(dt.origin),dt.navigator&&/(msie|trident)/i.test(dt.navigator.userAgent)):()=>!0,Fy=dt.hasStandardBrowserEnv?{write(a,n,t,o,i,r){const s=[a+"="+encodeURIComponent(n)];G.isNumber(t)&&s.push("expires="+new Date(t).toGMTString()),G.isString(o)&&s.push("path="+o),G.isString(i)&&s.push("domain="+i),r===!0&&s.push("secure"),document.cookie=s.join("; ")},read(a){const n=document.cookie.match(new RegExp("(^|;\\s*)("+a+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove(a){this.write(a,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Ry(a){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(a)}function $y(a,n){return n?a.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):a}function ac(a,n,t){let o=!Ry(n);return a&&(o||t==!1)?$y(a,n):n}const Fs=a=>a instanceof gt?{...a}:a;function wn(a,n){n=n||{};const t={};function o(d,u,m,p){return G.isPlainObject(d)&&G.isPlainObject(u)?G.merge.call({caseless:p},d,u):G.isPlainObject(u)?G.merge({},u):G.isArray(u)?u.slice():u}function i(d,u,m,p){if(G.isUndefined(u)){if(!G.isUndefined(d))return o(void 0,d,m,p)}else return o(d,u,m,p)}function r(d,u){if(!G.isUndefined(u))return o(void 0,u)}function s(d,u){if(G.isUndefined(u)){if(!G.isUndefined(d))return o(void 0,d)}else return o(void 0,u)}function l(d,u,m){if(m in n)return o(d,u);if(m in a)return o(void 0,d)}const c={url:r,method:r,data:r,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:l,headers:(d,u,m)=>i(Fs(d),Fs(u),m,!0)};return G.forEach(Object.keys({...a,...n}),function(u){const m=c[u]||i,p=m(a[u],n[u],u);G.isUndefined(p)&&m!==l||(t[u]=p)}),t}const ic=a=>{const n=wn({},a);let{data:t,withXSRFToken:o,xsrfHeaderName:i,xsrfCookieName:r,headers:s,auth:l}=n;n.headers=s=gt.from(s),n.url=Ql(ac(n.baseURL,n.url,n.allowAbsoluteUrls),a.params,a.paramsSerializer),l&&s.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let c;if(G.isFormData(t)){if(dt.hasStandardBrowserEnv||dt.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(dt.hasStandardBrowserEnv&&(o&&G.isFunction(o)&&(o=o(n)),o||o!==!1&&Iy(n.url))){const d=i&&r&&Fy.read(r);d&&s.set(i,d)}return n},Dy=typeof XMLHttpRequest<"u",Uy=Dy&&function(a){return new Promise(function(t,o){const i=ic(a);let r=i.data;const s=gt.from(i.headers).normalize();let{responseType:l,onUploadProgress:c,onDownloadProgress:d}=i,u,m,p,h,v;function y(){h&&h(),v&&v(),i.cancelToken&&i.cancelToken.unsubscribe(u),i.signal&&i.signal.removeEventListener("abort",u)}let E=new XMLHttpRequest;E.open(i.method.toUpperCase(),i.url,!0),E.timeout=i.timeout;function _(){if(!E)return;const w=gt.from("getAllResponseHeaders"in E&&E.getAllResponseHeaders()),x={data:!l||l==="text"||l==="json"?E.responseText:E.response,status:E.status,statusText:E.statusText,headers:w,config:a,request:E};oc(function(N){t(N),y()},function(N){o(N),y()},x),E=null}"onloadend"in E?E.onloadend=_:E.onreadystatechange=function(){!E||E.readyState!==4||E.status===0&&!(E.responseURL&&E.responseURL.indexOf("file:")===0)||setTimeout(_)},E.onabort=function(){E&&(o(new Be("Request aborted",Be.ECONNABORTED,a,E)),E=null)},E.onerror=function(){o(new Be("Network Error",Be.ERR_NETWORK,a,E)),E=null},E.ontimeout=function(){let f=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const x=i.transitional||ec;i.timeoutErrorMessage&&(f=i.timeoutErrorMessage),o(new Be(f,x.clarifyTimeoutError?Be.ETIMEDOUT:Be.ECONNABORTED,a,E)),E=null},r===void 0&&s.setContentType(null),"setRequestHeader"in E&&G.forEach(s.toJSON(),function(f,x){E.setRequestHeader(x,f)}),G.isUndefined(i.withCredentials)||(E.withCredentials=!!i.withCredentials),l&&l!=="json"&&(E.responseType=i.responseType),d&&([p,v]=pa(d,!0),E.addEventListener("progress",p)),c&&E.upload&&([m,h]=pa(c),E.upload.addEventListener("progress",m),E.upload.addEventListener("loadend",h)),(i.cancelToken||i.signal)&&(u=w=>{E&&(o(!w||w.type?new jn(null,a,E):w),E.abort(),E=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));const C=Ty(i.url);if(C&&dt.protocols.indexOf(C)===-1){o(new Be("Unsupported protocol "+C+":",Be.ERR_BAD_REQUEST,a));return}E.send(r||null)})},Oy=(a,n)=>{const{length:t}=a=a?a.filter(Boolean):[];if(n||t){let o=new AbortController,i;const r=function(d){if(!i){i=!0,l();const u=d instanceof Error?d:this.reason;o.abort(u instanceof Be?u:new jn(u instanceof Error?u.message:u))}};let s=n&&setTimeout(()=>{s=null,r(new Be(`timeout ${n} of ms exceeded`,Be.ETIMEDOUT))},n);const l=()=>{a&&(s&&clearTimeout(s),s=null,a.forEach(d=>{d.unsubscribe?d.unsubscribe(r):d.removeEventListener("abort",r)}),a=null)};a.forEach(d=>d.addEventListener("abort",r));const{signal:c}=o;return c.unsubscribe=()=>G.asap(l),c}},Ay=function*(a,n){let t=a.byteLength;if(t<n){yield a;return}let o=0,i;for(;o<t;)i=o+n,yield a.slice(o,i),o=i},Ly=async function*(a,n){for await(const t of zy(a))yield*Ay(t,n)},zy=async function*(a){if(a[Symbol.asyncIterator]){yield*a;return}const n=a.getReader();try{for(;;){const{done:t,value:o}=await n.read();if(t)break;yield o}}finally{await n.cancel()}},Rs=(a,n,t,o)=>{const i=Ly(a,n);let r=0,s,l=c=>{s||(s=!0,o&&o(c))};return new ReadableStream({async pull(c){try{const{done:d,value:u}=await i.next();if(d){l(),c.close();return}let m=u.byteLength;if(t){let p=r+=m;t(p)}c.enqueue(new Uint8Array(u))}catch(d){throw l(d),d}},cancel(c){return l(c),i.return()}},{highWaterMark:2})},Ua=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",rc=Ua&&typeof ReadableStream=="function",Py=Ua&&(typeof TextEncoder=="function"?(a=>n=>a.encode(n))(new TextEncoder):async a=>new Uint8Array(await new Response(a).arrayBuffer())),sc=(a,...n)=>{try{return!!a(...n)}catch{return!1}},jy=rc&&sc(()=>{let a=!1;const n=new Request(dt.origin,{body:new ReadableStream,method:"POST",get duplex(){return a=!0,"half"}}).headers.has("Content-Type");return a&&!n}),$s=64*1024,Ui=rc&&sc(()=>G.isReadableStream(new Response("").body)),fa={stream:Ui&&(a=>a.body)};Ua&&(a=>{["text","arrayBuffer","blob","formData","stream"].forEach(n=>{!fa[n]&&(fa[n]=G.isFunction(a[n])?t=>t[n]():(t,o)=>{throw new Be(`Response type '${n}' is not supported`,Be.ERR_NOT_SUPPORT,o)})})})(new Response);const Wy=async a=>{if(a==null)return 0;if(G.isBlob(a))return a.size;if(G.isSpecCompliantForm(a))return(await new Request(dt.origin,{method:"POST",body:a}).arrayBuffer()).byteLength;if(G.isArrayBufferView(a)||G.isArrayBuffer(a))return a.byteLength;if(G.isURLSearchParams(a)&&(a=a+""),G.isString(a))return(await Py(a)).byteLength},Zy=async(a,n)=>{const t=G.toFiniteNumber(a.getContentLength());return t??Wy(n)},Xy=Ua&&(async a=>{let{url:n,method:t,data:o,signal:i,cancelToken:r,timeout:s,onDownloadProgress:l,onUploadProgress:c,responseType:d,headers:u,withCredentials:m="same-origin",fetchOptions:p}=ic(a);d=d?(d+"").toLowerCase():"text";let h=Oy([i,r&&r.toAbortSignal()],s),v;const y=h&&h.unsubscribe&&(()=>{h.unsubscribe()});let E;try{if(c&&jy&&t!=="get"&&t!=="head"&&(E=await Zy(u,o))!==0){let x=new Request(n,{method:"POST",body:o,duplex:"half"}),$;if(G.isFormData(o)&&($=x.headers.get("content-type"))&&u.setContentType($),x.body){const[N,g]=Bs(E,pa(Is(c)));o=Rs(x.body,$s,N,g)}}G.isString(m)||(m=m?"include":"omit");const _="credentials"in Request.prototype;v=new Request(n,{...p,signal:h,method:t.toUpperCase(),headers:u.normalize().toJSON(),body:o,duplex:"half",credentials:_?m:void 0});let C=await fetch(v,p);const w=Ui&&(d==="stream"||d==="response");if(Ui&&(l||w&&y)){const x={};["status","statusText","headers"].forEach(S=>{x[S]=C[S]});const $=G.toFiniteNumber(C.headers.get("content-length")),[N,g]=l&&Bs($,pa(Is(l),!0))||[];C=new Response(Rs(C.body,$s,N,()=>{g&&g(),y&&y()}),x)}d=d||"text";let f=await fa[G.findKey(fa,d)||"text"](C,a);return!w&&y&&y(),await new Promise((x,$)=>{oc(x,$,{data:f,headers:gt.from(C.headers),status:C.status,statusText:C.statusText,config:a,request:v})})}catch(_){throw y&&y(),_&&_.name==="TypeError"&&/Load failed|fetch/i.test(_.message)?Object.assign(new Be("Network Error",Be.ERR_NETWORK,a,v),{cause:_.cause||_}):Be.from(_,_&&_.code,a,v)}}),Oi={http:sy,xhr:Uy,fetch:Xy};G.forEach(Oi,(a,n)=>{if(a){try{Object.defineProperty(a,"name",{value:n})}catch{}Object.defineProperty(a,"adapterName",{value:n})}});const Ds=a=>`- ${a}`,Hy=a=>G.isFunction(a)||a===null||a===!1,lc={getAdapter:a=>{a=G.isArray(a)?a:[a];const{length:n}=a;let t,o;const i={};for(let r=0;r<n;r++){t=a[r];let s;if(o=t,!Hy(t)&&(o=Oi[(s=String(t)).toLowerCase()],o===void 0))throw new Be(`Unknown adapter '${s}'`);if(o)break;i[s||"#"+r]=o}if(!o){const r=Object.entries(i).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let s=n?r.length>1?`since :
|
|
339
|
-
`+r.map(Ds).join(`
|
|
340
|
-
`):" "+Ds(r[0]):"as no adapter specified";throw new Be("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return o},adapters:Oi};function pi(a){if(a.cancelToken&&a.cancelToken.throwIfRequested(),a.signal&&a.signal.aborted)throw new jn(null,a)}function Us(a){return pi(a),a.headers=gt.from(a.headers),a.data=mi.call(a,a.transformRequest),["post","put","patch"].indexOf(a.method)!==-1&&a.headers.setContentType("application/x-www-form-urlencoded",!1),lc.getAdapter(a.adapter||_o.adapter)(a).then(function(o){return pi(a),o.data=mi.call(a,a.transformResponse,o),o.headers=gt.from(o.headers),o},function(o){return nc(o)||(pi(a),o&&o.response&&(o.response.data=mi.call(a,a.transformResponse,o.response),o.response.headers=gt.from(o.response.headers))),Promise.reject(o)})}const cc="1.11.0",Oa={};["object","boolean","number","function","string","symbol"].forEach((a,n)=>{Oa[a]=function(o){return typeof o===a||"a"+(n<1?"n ":" ")+a}});const Os={};Oa.transitional=function(n,t,o){function i(r,s){return"[Axios v"+cc+"] Transitional option '"+r+"'"+s+(o?". "+o:"")}return(r,s,l)=>{if(n===!1)throw new Be(i(s," has been removed"+(t?" in "+t:"")),Be.ERR_DEPRECATED);return t&&!Os[s]&&(Os[s]=!0),n?n(r,s,l):!0}};Oa.spelling=function(n){return(t,o)=>!0};function Gy(a,n,t){if(typeof a!="object")throw new Be("options must be an object",Be.ERR_BAD_OPTION_VALUE);const o=Object.keys(a);let i=o.length;for(;i-- >0;){const r=o[i],s=n[r];if(s){const l=a[r],c=l===void 0||s(l,r,a);if(c!==!0)throw new Be("option "+r+" must be "+c,Be.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new Be("Unknown option "+r,Be.ERR_BAD_OPTION)}}const ta={assertOptions:Gy,validators:Oa},Ot=ta.validators;let gn=class{constructor(n){this.defaults=n||{},this.interceptors={request:new Ts,response:new Ts}}async request(n,t){try{return await this._request(n,t)}catch(o){if(o instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const r=i.stack?i.stack.replace(/^.+\n/,""):"";try{o.stack?r&&!String(o.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(o.stack+=`
|
|
341
|
-
`+r):o.stack=r}catch{}}throw o}}_request(n,t){typeof n=="string"?(t=t||{},t.url=n):t=n||{},t=wn(this.defaults,t);const{transitional:o,paramsSerializer:i,headers:r}=t;o!==void 0&&ta.assertOptions(o,{silentJSONParsing:Ot.transitional(Ot.boolean),forcedJSONParsing:Ot.transitional(Ot.boolean),clarifyTimeoutError:Ot.transitional(Ot.boolean)},!1),i!=null&&(G.isFunction(i)?t.paramsSerializer={serialize:i}:ta.assertOptions(i,{encode:Ot.function,serialize:Ot.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),ta.assertOptions(t,{baseUrl:Ot.spelling("baseURL"),withXsrfToken:Ot.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=r&&G.merge(r.common,r[t.method]);r&&G.forEach(["delete","get","head","post","put","patch","common"],v=>{delete r[v]}),t.headers=gt.concat(s,r);const l=[];let c=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(t)===!1||(c=c&&y.synchronous,l.unshift(y.fulfilled,y.rejected))});const d=[];this.interceptors.response.forEach(function(y){d.push(y.fulfilled,y.rejected)});let u,m=0,p;if(!c){const v=[Us.bind(this),void 0];for(v.unshift(...l),v.push(...d),p=v.length,u=Promise.resolve(t);m<p;)u=u.then(v[m++],v[m++]);return u}p=l.length;let h=t;for(m=0;m<p;){const v=l[m++],y=l[m++];try{h=v(h)}catch(E){y.call(this,E);break}}try{u=Us.call(this,h)}catch(v){return Promise.reject(v)}for(m=0,p=d.length;m<p;)u=u.then(d[m++],d[m++]);return u}getUri(n){n=wn(this.defaults,n);const t=ac(n.baseURL,n.url,n.allowAbsoluteUrls);return Ql(t,n.params,n.paramsSerializer)}};G.forEach(["delete","get","head","options"],function(n){gn.prototype[n]=function(t,o){return this.request(wn(o||{},{method:n,url:t,data:(o||{}).data}))}});G.forEach(["post","put","patch"],function(n){function t(o){return function(r,s,l){return this.request(wn(l||{},{method:n,headers:o?{"Content-Type":"multipart/form-data"}:{},url:r,data:s}))}}gn.prototype[n]=t(),gn.prototype[n+"Form"]=t(!0)});let Jy=class dc{constructor(n){if(typeof n!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(r){t=r});const o=this;this.promise.then(i=>{if(!o._listeners)return;let r=o._listeners.length;for(;r-- >0;)o._listeners[r](i);o._listeners=null}),this.promise.then=i=>{let r;const s=new Promise(l=>{o.subscribe(l),r=l}).then(i);return s.cancel=function(){o.unsubscribe(r)},s},n(function(r,s,l){o.reason||(o.reason=new jn(r,s,l),t(o.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]}unsubscribe(n){if(!this._listeners)return;const t=this._listeners.indexOf(n);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const n=new AbortController,t=o=>{n.abort(o)};return this.subscribe(t),n.signal.unsubscribe=()=>this.unsubscribe(t),n.signal}static source(){let n;return{token:new dc(function(i){n=i}),cancel:n}}};function Yy(a){return function(t){return a.apply(null,t)}}function Ky(a){return G.isObject(a)&&a.isAxiosError===!0}const Ai={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(Ai).forEach(([a,n])=>{Ai[n]=a});function uc(a){const n=new gn(a),t=zl(gn.prototype.request,n);return G.extend(t,gn.prototype,n,{allOwnKeys:!0}),G.extend(t,n,null,{allOwnKeys:!0}),t.create=function(i){return uc(wn(a,i))},t}const He=uc(_o);He.Axios=gn;He.CanceledError=jn;He.CancelToken=Jy;He.isCancel=nc;He.VERSION=cc;He.toFormData=Da;He.AxiosError=Be;He.Cancel=He.CanceledError;He.all=function(n){return Promise.all(n)};He.spread=Yy;He.isAxiosError=Ky;He.mergeConfig=wn;He.AxiosHeaders=gt;He.formToJSON=a=>tc(G.isHTMLForm(a)?new FormData(a):a);He.getAdapter=lc.getAdapter;He.HttpStatusCode=Ai;He.default=He;const{Axios:y3,AxiosError:w3,CanceledError:b3,isCancel:k3,CancelToken:x3,VERSION:E3,all:V3,Cancel:S3,isAxiosError:C3,spread:N3,toFormData:_3,AxiosHeaders:T3,HttpStatusCode:M3,formToJSON:B3,getAdapter:I3,mergeConfig:F3}=He;class mr{constructor(n="/api/v1"){this.eventSource=null,this.progressCallbacks=new Map,this.api=He.create({baseURL:n,headers:{"Content-Type":"application/json",Accept:"application/json"}}),this.api.interceptors.request.use(t=>{const o=this.getAuthToken();return o&&(t.headers.Authorization=`Bearer ${o}`),t}),this.api.interceptors.response.use(t=>t,t=>{var o;return(o=t.response)==null||o.status,Promise.reject(t)})}async createJob(n){try{const t=await this.api.post("/video/jobs",n);return this.normalizeJob(t.data.data)}catch(t){throw t}}async createRenderJob(n){try{const t=await this.api.post("/video/jobs/render",n);return this.normalizeJob(t.data.data)}catch(t){throw t}}async pollRenderJob(n,t,o=3e3,i=6e5){const r=Date.now();return new Promise((s,l)=>{const c=setInterval(async()=>{try{const d=await this.getJob(n);t==null||t(d.progress,d.status),d.status==="completed"?(clearInterval(c),s(d)):d.status==="failed"?(clearInterval(c),l(new Error(d.error_message??"Render job failed"))):Date.now()-r>i&&(clearInterval(c),l(new Error("Render job timed out")))}catch(d){clearInterval(c),l(d)}},o)})}async getJob(n){try{const t=await this.api.get(`/video/jobs/${n}`);return this.normalizeJob(t.data.data)}catch(t){throw t}}async listJobs(n){try{return(await this.api.get("/video/jobs",{params:n})).data}catch(t){throw t}}async cancelJob(n){try{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",o=>{const i=JSON.parse(o.data),r=this.progressCallbacks.get(i.jobId);r&&r(i.progress)}),this.eventSource.addEventListener("complete",o=>{const i=JSON.parse(o.data),r=this.progressCallbacks.get(i.jobId);r&&(r(100),this.unsubscribeFromProgress(i.jobId))}),this.eventSource.addEventListener("error",o=>{this.progressCallbacks.forEach((i,r)=>{this.pollProgress(r)})})}catch{}}async pollProgress(n){const t=setInterval(async()=>{try{const o=await this.getJob(n),i=this.progressCallbacks.get(n);i&&i(o.progress),(o.status==="completed"||o.status==="failed")&&(clearInterval(t),this.unsubscribeFromProgress(n))}catch{clearInterval(t)}},2e3)}getAuthToken(){const n=localStorage.getItem("auth_token");if(n)return n;const t=document.cookie.split(";");for(const o of t){const[i,r]=o.trim().split("=");if(i==="auth_token")return decodeURIComponent(r)}return null}async downloadVideo(n){try{return(await this.api.get(`/video/jobs/${n}/download`,{responseType:"blob"})).data}catch(t){throw t}}async getThumbnail(n,t=0){try{const o=await this.api.get(`/video/jobs/${n}/thumbnail`,{params:{time:t},responseType:"blob"});return URL.createObjectURL(o.data)}catch(o){throw o}}normalizeJob(n){const t=n,o={...t,user_id:t.user_id??t.userId??"",source_media_id:t.source_media_id??t.sourceMediaId??"",created_at:t.created_at??t.createdAt??"",updated_at:t.updated_at??t.updatedAt??""},i=t.output_media_id??t.outputMediaId;typeof i=="string"&&i!==""&&(o.output_media_id=i);const r=t.error_message??t.errorMessage;typeof r=="string"&&r!==""&&(o.error_message=r);const s=t.started_at??t.startedAt;typeof s=="string"&&s!==""&&(o.started_at=s);const l=t.completed_at??t.completedAt;return typeof l=="string"&&l!==""&&(o.completed_at=l),o}}new mr;const qy={key:0,class:"mobile-layout"},Qy={class:"mobile-toolbar"},ew={class:"mobile-toolbar-left"},tw=["aria-label"],nw={class:"mobile-toolbar-right"},ow=["disabled"],aw=["disabled"],iw={class:"preview-section"},rw={key:0,class:"mobile-export-overlay"},sw={class:"mobile-export-progress"},lw={class:"mobile-export-bar"},cw={class:"mobile-timeline-zoom"},dw={key:1,class:"desktop-layout"},uw={class:"desktop-main-row"},mw={class:"preview-panel"},pw={class:"fit-toggle"},fw={class:"editor-content"},hw={class:"editor-tabs"},vw={class:"tab-header"},gw=["onClick"],yw={class:"tab-content-area"},ww={class:"filter-controls"},bw={class:"text-controls"},kw={class:"transition-controls"},xw={class:"audio-controls"},Ew={class:"adjustments-controls"},Vw={key:1,class:"no-filter-selected"},Sw={class:"export-controls"},Cw={key:0,"data-testid":"video-export-status-completed"},Nw={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},_w={class:"desktop-timeline-row"},Tw={class:"timeline-zoom"},Mw=["value"],Bw={class:"zoom-readout"},Iw={key:0,class:"dev-editor-controls","data-testid":"video-editor-dev-controls"},Fw={class:"dev-editor-row"},Rw={class:"dev-editor-field"},$w={class:"dev-editor-field"},Dw=["disabled"],Uw=["disabled"],Ow=["disabled"],Aw={class:"dev-editor-row"},Lw={class:"dev-editor-field dev-editor-field--wide"},zw=["value"],Pw=["disabled"],jw=["disabled"],Ww=["disabled"],Zw=["disabled"],Xw=e.defineComponent({__name:"VideoEditor",props:{mediaUuid:{},initialRecipe:{},media:{},showThumbnailPicker:{type:Boolean,default:!1},workflowMode:{default:"full"},featureFlags:{},clientExportThreshold:{default:20},maxDuration:{default:300},serverRenderEndpoint:{default:null}},emits:["recipe-generated","export-started","draft-saved","video-exported","thumbnail-selected","server-render-started","server-render-progress","server-render-completed","server-render-failed","close"],setup(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>{if(!o.media||typeof o.media!="object")return;const b=o.media.uuid??o.media.id;return typeof b=="string"&&b.trim()!==""?b.trim():void 0}),s=e.computed(()=>{const b=typeof o.mediaUuid=="string"?o.mediaUuid.trim():"";return b!==""?b:r.value??`temp-${Date.now()}`}),l=e.ref(typeof window<"u"?window.innerWidth<768:!1),c=e.ref("filters"),d=e.ref("filters"),u=e.computed(()=>{const b=o.workflowMode==="uploader"?{filters:!0,adjustments:!0,text:!1,transitions:!1,audio:!1,export:!1}:{filters:!0,adjustments:!0,text:!0,transitions:!0,audio:!0,export:!0},V=o.featureFlags;return V?{filters:typeof V.filters=="boolean"?V.filters:b.filters,adjustments:typeof V.adjustments=="boolean"?V.adjustments:b.adjustments,text:typeof V.text=="boolean"?V.text:b.text,transitions:typeof V.transitions=="boolean"?V.transitions:b.transitions,audio:typeof V.audio=="boolean"?V.audio:b.audio,export:typeof V.export=="boolean"?V.export:b.export}:b}),m=e.computed(()=>l.value?c.value:d.value),p=e.computed(()=>m.value==="filters"||E.value),h=e.computed(()=>m.value!=="filters"&&!E.value),v=e.ref(null),y=e.ref(null),E=e.ref(!1),_=e.computed(()=>l.value?v.value:y.value);function C(b){return b==="contain"||b==="cover"||b==="none"}function w(b){if(!(b!=null&&b.metadata))return null;const V=b.metadata.fit_mode;return C(V)?V:null}const f=e.shallowRef(null),x=e.ref(null),$=e.ref(w(o.initialRecipe)??"contain"),N=e.ref(null),g=e.ref(null),S=e.ref(null),O=e.ref(!1),k=new Map,T=e.ref([]),F=e.ref([]),A=e.ref([]),R=e.ref([]),j=e.ref(1),K=()=>{l.value=window.innerWidth<768},I=[{id:"filters",label:"Filters",icon:an},{id:"adjustments",label:"Adjust",icon:pu},{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:po}],D=[{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(()=>I.filter(b=>u.value[b.id])),W=e.computed(()=>D.filter(b=>u.value[b.id])),oe=e.computed(()=>{var b,V;return((b=W.value[0])==null?void 0:b.id)??((V=Z.value[0])==null?void 0:V.id)??"filters"});e.watch(u,b=>{b[c.value]||(c.value=oe.value),b[d.value]||(d.value=oe.value)},{immediate:!0,deep:!0}),e.watch(oe,b=>{u.value[c.value]||(c.value=b),u.value[d.value]||(d.value=b)},{immediate:!0}),e.watch(u,b=>{b.export||(c.value==="export"&&(c.value=oe.value),d.value==="export"&&(d.value=oe.value))},{immediate:!0,deep:!0});const we=e.computed(()=>typeof window>"u"?!1:window.__MEDIABLES_EDITOR_DEV__===!0),{currentFrame:Ce,playheadPosition:ne,timelineClips:M,totalDuration:z,hasChanges:me,isPlaying:ae,selectedClip:Y,zoomLevel:Te,playbackSpeed:ue,handleTrim:se,handleSplit:be,handleClipSelect:ie,splitAtPlayhead:le,deleteSelectedClip:ke,duplicateSelectedClip:Ve,setZoomLevel:et,moveClip:We,setFilters:fe,setTextOverlays:P,setAudioTracks:J,saveDraft:ee,clearHasChanges:te,resetChanges:pe,generateRecipe:ve,zoomIn:Fe,zoomOut:Oe,fitToWindow:H,togglePlayback:re,setPlaying:xe,seekTo:Ne,frameForward:ze,frameBackward:wt,skipToStart:ut,skipToEnd:St,setPlaybackSpeed:Ge,updateSourceDuration:Zt}=cg(s.value,o.initialRecipe,o.media),{videoCompatibleFilters:Pa,activeFilters:qe,selectedFilter:xr,previewFilter:To,previewFilterEffect:Er,applyFilter:Vr,updateFilterParams:Vc,removeFilter:Sc,clearAllFilters:Sr,setActiveFilters:Cc}=wg();function Wn(b){var X,q;const V=((X=Y.value)==null?void 0:X.id)??((q=M.value[0])==null?void 0:q.id);V&&(O.value=!0,typeof b=="object"&&b.id?Vr(b.id):typeof b=="string"&&Vr(b),fe(qe.value),f.value?f.value.setClipFilters(V,qe.value):k.set(V,[...qe.value]),ie(V),O.value=!1,Rt())}function Nc(){var V,X;const b=((V=Y.value)==null?void 0:V.id)??((X=M.value[0])==null?void 0:X.id);b&&ie(b)}function Cr(b){const V=qe.value.find(X=>X.filterId===b);V&&Sc(V.id)}const Zn=e.computed(()=>Pa.value.map(V=>{var q;const X=[];if(V.controls&&V.controls.length>0)for(const ce of V.controls){const Q=ce.type;if(Q==="button"||Q==="text"||Q==="range")continue;const de={id:ce.property||ce.id,label:ce.label||ce.id,type:Q,default:ce.default??(Q==="toggle"?!1:Q==="color"?"#ffffff":0)};Q==="slider"&&(de.min=ce.min??0,de.max=ce.max??1,de.step=ce.step??.01),Q==="select"&&ce.options&&(de.options=ce.options),X.push(de)}else if(V.paramRanges){const ce=Object.entries(V.paramRanges);for(const[Q,de]of ce){const $e=Q.replace(/[-_]/g," ").replace(/\b\w/g,$t=>$t.toUpperCase()),mt=(q=V.defaultParams)==null?void 0:q[Q],Gt=(de.min+de.max)/2;X.push({id:Q,label:$e,min:de.min,max:de.max,step:de.step??.01,default:typeof mt=="number"?mt:Gt})}}return{id:V.id,name:V.name,category:V.category,params:X}})),En=e.ref("0.00"),Vn=e.ref("0.00"),qt=e.ref("");e.watch(Zn,b=>{if(b.length===0){qt.value="";return}b.some(X=>X.id===qt.value)||(qt.value=b[0].id)},{immediate:!0});const tt=e.ref(!1),Ze=e.ref(0),Xt=e.ref(!1),je=e.ref(null),Tt=e.ref(null);let Mo=null,Ct=!1,Ht=null;const ja=e.computed(()=>{const b=new Map;return qe.value.forEach(V=>b.set(V.filterId,V)),b}),_c=e.computed(()=>{var b,V;return Ce.value?Ce.value:((b=o.media)==null?void 0:b.thumbnail_url)||((V=o.media)==null?void 0:V.url)}),Ft=e.ref("");e.watch(()=>{var b,V;return{file:(b=o.media)==null?void 0:b.file,url:(V=o.media)==null?void 0:V.url}},(b,V,X)=>{var ce,Q;const q=Ft.value;X(()=>{q&&q.startsWith("blob:")&&URL.revokeObjectURL(q)}),(ce=o.media)!=null&&ce.file?Ft.value=URL.createObjectURL(o.media.file):(Q=o.media)!=null&&Q.url?Ft.value=o.media.url:Ft.value=""},{immediate:!0}),e.onUnmounted(()=>{Ft.value&&Ft.value.startsWith("blob:")&&URL.revokeObjectURL(Ft.value)});const Wa=e.computed(()=>Ft.value),Nr=e.computed(()=>{if(!o.media)return null;const{file:b,...V}=o.media;return{...V,url:Ft.value}}),_r=e.computed(()=>{var V;const b=(V=o.media)==null?void 0:V.url;return!!(b&&/^https?:/i.test(b))}),Tr=e.computed(()=>qe.value),Mr=e.computed(()=>ne.value),Tc=e.computed(()=>!!Y.value&&ne.value>0),Mc=e.computed(()=>!!Y.value&&M.value.length>1),Za=e.ref(0),Qt=e.computed(()=>{try{const b=z.value??z;return b&&typeof b=="number"&&b>0?b:Za.value}catch{return Za.value}}),Sn=e.ref(),Xa=e.ref(),Bo=e.ref(0),Io=e.ref(!1);let ft=null;e.watch(Qt,b=>{var X;if(Io.value||!b||b<=0)return;const V=Bo.value||((X=Sn.value)==null?void 0:X.clientWidth)||0;V>0&&(Io.value=!0,H(V))}),e.watch(Bo,b=>{if(Io.value||!b||b<=0)return;Qt.value>0&&(Io.value=!0,H(b))});function Cn(b){return Number.isFinite(b)?b.toFixed(2):"0.00"}function Br(b){const V=Number(b);return Number.isFinite(V)?V:null}function Bc(b){b&&(En.value=Cn(b.sourceIn),Vn.value=Cn(b.sourceOut))}e.watch(()=>{var b,V,X;return[(b=Y.value)==null?void 0:b.id,(V=Y.value)==null?void 0:V.sourceIn,(X=Y.value)==null?void 0:X.sourceOut]},()=>{Bc(Y.value)},{immediate:!0});function Ir(b){const V=Y.value;if(!V)return;const X=1/30,q=V.sourceMinIn??0,ce=V.sourceMaxOut??Qt.value,Q=V.sourceIn+(ne.value-V.timelineStart);if(b==="start"){const $e=Math.max(q,Math.min(Q,V.sourceOut-X));En.value=Cn($e);return}const de=Math.max(V.sourceIn+X,Math.min(Q,ce));Vn.value=Cn(de)}function Ic(){const b=Y.value;if(!b)return;const V=Br(En.value),X=Br(Vn.value);if(V===null||X===null)return;const q=1/30,ce=b.sourceMinIn??0,Q=b.sourceMaxOut??Qt.value,de=Math.max(ce,Math.min(V,Q-q)),$e=Math.max(de+q,Math.min(X,Q));se(b.id,"start",de),se(b.id,"end",$e),En.value=Cn(de),Vn.value=Cn($e),Y.value&&Ne(Y.value.timelineStart)}function Fc(){qt.value.trim()!==""&&Wn(qt.value)}function Rc(){var b;Sr(),fe(qe.value),(b=Y.value)!=null&&b.id&&(f.value?f.value.setClipFilters(Y.value.id,qe.value):k.set(Y.value.id,[...qe.value])),Rt()}function Fr(b,V,X){var ce,Q;const q=qe.value.find(de=>de.filterId===b);q?(q.params={...q.params,[V]:X},fe(qe.value),f.value&&((ce=Y.value)!=null&&ce.id)?f.value.setClipFilters(Y.value.id,qe.value):(Q=Y.value)!=null&&Q.id&&k.set(Y.value.id,[...qe.value]),Rt(),Nc()):To.value&&To.value.filterId===b&&(To.value.params={...To.value.params||{},[V]:X})}function Rr(b){Ne(b)}function $r(b){xe(b)}function Fo(b){!Number.isFinite(b)||b<=0||(Za.value=b,Zt(b))}function $c(){var V;const b=Bo.value||((V=Sn.value)==null?void 0:V.clientWidth)||800;H(b)}function Dc(b){const V=b.target,X=Number(V.value);et(X)}function Dr(b){const V=Math.min(600,Math.max(10,Te.value+b));et(V)}function Ur(b){var V;f.value=b,(V=f.value)!=null&&V.composition&&(N.value=new bg(f.value.composition),g.value=new ma(f.value.composition),S.value=new kg(f.value.composition));try{k.size&&(k.forEach((X,q)=>{f.value.setClipFilters(q,X)}),k.clear(),f.value.composition.computeFrame())}catch{}}function Uc(b){b!=null&&b.id&&Er(b.id)}function Oc(b){Vc(b),Rt()}async function Ac(b){if(!N.value)return;const V=await N.value.addTextOverlay(b);T.value.push({id:V,...b})}async function Lc(b,V){if(!N.value)return;await N.value.updateTextOverlay(b,V);const X=T.value.findIndex(q=>q.id===b);X!==-1&&(T.value[X]={...T.value[X],...V})}async function zc(b){N.value&&(await N.value.removeTextOverlay(b),T.value=T.value.filter(V=>V.id!==b))}async function Pc(b){if(!g.value||R.value.length<2)return;const[V,X]=R.value,q=await g.value.applyTransition(V,X,b);F.value.push({id:q,...b,name:b.type})}function jc(b){if(!g.value)return;const V=F.value[b];V&&(g.value.removeTransition(V.id),F.value.splice(b,1))}function Wc(b){}async function Zc(b){if(!S.value)return;const V=await S.value.addAudioTrack(b);A.value.push({id:V,...b})}async function Xc(b,V){if(!S.value)return;const X=A.value.findIndex(q=>q.id===b);X!==-1&&(A.value[X]={...A.value[X],...V})}async function Hc(b){S.value&&(await S.value.removeAudioTrack(b),A.value=A.value.filter(V=>V.id!==b))}async function Gc(b,V){if(!S.value)return;await S.value.updateVolume(b,V);const X=A.value.find(q=>q.id===b);X&&(X.volume=V)}async function Jc(b,V){if(!S.value)return;await S.value.muteTrack(b,V);const X=A.value.find(q=>q.id===b);X&&(X.muted=V)}function Yc(b){S.value&&(S.value.setMasterVolume(b),j.value=b)}function Kc(b){i("thumbnail-selected",b)}function en(){Mo!==null&&(clearInterval(Mo),Mo=null)}function qc(b,V){return V?{...b,output:{...b.output,format:V.format,quality:V.quality}}:b}function Xn(b){var V;return b.metadata||(b.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),b.metadata.fit_mode=$.value,(V=o.media)!=null&&V.url&&/^https?:/i.test(o.media.url)?b.metadata.source_url=o.media.url:delete b.metadata.source_url,b}function Xe(b,V,X){return Math.min(X,Math.max(V,b))}function Ha(b,V){if(typeof b=="number"&&Number.isFinite(b))return b;if(typeof b=="string"){const X=Number(b);if(Number.isFinite(X))return X}return V}function st(b,V,X){for(const q of V)if(q in b)return Ha(b[q],X);return X}function Qc(b){const V=typeof b.params=="object"&&b.params!==null?b.params:{};switch(b.filterId.trim().toLowerCase()){case"brightness":return[{type:"brightness",value:Xe(st(V,["value","brightness"],0),-1,1)}];case"contrast":return[{type:"contrast",value:Xe(st(V,["value","contrast"],1),.1,3)}];case"saturation":return[{type:"saturation",value:Xe(st(V,["value","saturation"],1),0,3)}];case"blur":case"gaussian-blur":case"kawase-blur":case"radial-blur":return[{type:"blur",value:Xe(st(V,["value","blur","radius"],0),0,25)}];case"sharpen":return[{type:"sharpen",value:Xe(st(V,["value","amount"],1),0,5)}];case"sepia":return[{type:"sepia",value:1}];case"grayscale":return[{type:"grayscale",value:1}];case"adjustment":{const q=Xe(st(V,["brightness"],1)-1,-1,1),ce=Xe(st(V,["contrast"],1),.1,3),Q=Xe(st(V,["saturation"],1),0,3);return[{type:"brightness",value:q},{type:"contrast",value:ce},{type:"saturation",value:Q}]}default:return[]}}function ed(b){const V=b.timeline[0],X=Array.isArray(V==null?void 0:V.filters)?V.filters:[],q=[];for(const Q of X)if(q.push(...Qc(Q)),q.length>=12)break;const ce={...b,filters:q.slice(0,12)};if(b.timeline.length===1&&V){const Q=Math.max(0,Ha(V.sourceIn,0)),de=Ha(V.sourceOut,Q);de>Q&&(ce.trim={start:Q,end:de})}return ce}function td(b){return{"360p":[640,360],"480p":[854,480],"720p":[1280,720],"1080p":[1920,1080],"1440p":[2560,1440],"2160p":[3840,2160]}[b??""]??[1920,1080]}function nd(b){if(!b||typeof b!="object")return null;const V=b.duration;if(typeof V=="number"&&Number.isFinite(V)&&V>0)return V;if(V&&typeof V=="object"&&"value"in V){const X=V.value;if(typeof X=="number"&&Number.isFinite(X)&&X>0)return X}return null}async function Or(b,V,X){var Gt,$t,Dt,Ut;const q=b.timeline[0],ce=q?Math.max(0,q.sourceIn):0,Q=q?q.sourceOut:void 0,[de,$e]=td((V==null?void 0:V.quality)??((Gt=b.output)==null?void 0:Gt.quality)),mt=(($t=b.output)==null?void 0:$t.fps)||30;xe(!1),E.value=!0,await e.nextTick();try{const nt=[200,500,1e3];let lt=!1;for(const ei of nt){await new Promise(xd=>setTimeout(xd,ei));const $o=_.value;if(!(!$o||typeof $o.captureFrameAt!="function")&&typeof $o.ensureReadyForCapture=="function"&&(lt=await $o.ensureReadyForCapture(),lt))break}const bt=_.value;if(!bt||typeof bt.captureFrameAt!="function")throw new Error("PIXI preview not available for export. Ensure the preview is mounted.");if(!lt)throw new Error("PIXI preview not ready for frame capture after retries. The video may still be loading.");const{exportWithPixiFrames:Ro,isWebCodecsSupported:Hn}=await Promise.resolve().then(()=>require("./PixiFrameExporter-Suw6Dxf2.cjs"));if(!Hn())throw new Error("WebCodecs is not supported in this browser. Export requires Chrome 94+ or equivalent.");Ht=new AbortController;const Nn={width:de,height:$e,fps:mt,trimStart:ce,signal:Ht.signal};Q!==void 0&&(Nn.trimEnd=Q),X&&(Nn.onProgress=X);const Hr=Ft.value;Hr!==""&&(Nn.sourceUrl=Hr);const gd=typeof bt.duration=="number"&&bt.duration>0?bt.duration:((Dt=b.source)==null?void 0:Dt.duration)??Q??0,yd=await Ro({captureFrameAt:ei=>bt.captureFrameAt(ei),duration:{value:gd}},Nn),Qa=new File([yd],`edited-video-${Date.now()}.mp4`,{type:"video/mp4"}),wd=nd(bt),bd=((Ut=b.source)==null?void 0:Ut.duration)??0,kd=Math.max(0,(Q??wd??bd)-ce);return{file:Qa,recipe:b,meta:{duration:kd,width:de,height:$e,format:"mp4",sizeBytes:Qa.size,size_bytes:Qa.size}}}finally{E.value=!1,Ht=null}}async function od(b,V){var Ut;en(),Ct=!1,Ht=null,Tt.value=null,je.value=null,Xt.value=!1,Ze.value=0;const X=Xn(b??ve()),q=Zr(X),ce=Array.isArray(q.filters)&&q.filters.length>0,Q=Ya(q);if(!(me.value||ce||Q))return te(),i("video-exported",null),null;const $e=q.timeline[0],mt=$e?Math.max(0,$e.sourceIn):0,$t=(($e==null?void 0:$e.sourceOut)??((Ut=q.source)==null?void 0:Ut.duration)??Qt.value)-mt,Dt=o.serverRenderEndpoint!=null&&o.clientExportThreshold>0&&$t>o.clientExportThreshold;if(Dt){tt.value=!0;try{return await ad(q),null}catch(nt){const lt=nt instanceof Error?nt.message:"Server render failed";throw je.value=lt,i("server-render-failed",lt),nt}finally{tt.value=!1}}if(o.maxDuration>0&&$t>o.maxDuration&&!Dt){const nt=`This video is too long for in-browser export (${Math.round($t)}s). Server rendering is not available. Try a shorter clip.`;return je.value=nt,i("video-exported",null),null}tt.value=!0;try{const nt=await Or(q,V,lt=>{Ct||(Ze.value=lt)});return Ct?(je.value="Export canceled.",Ze.value=0,i("video-exported",null),null):(te(),i("recipe-generated",q),i("video-exported",nt),Ze.value=100,Xt.value=!0,nt)}catch(nt){if(Ct)return je.value="Export canceled.",Ze.value=0,i("video-exported",null),null;const lt=nt instanceof Error?nt.message:"Local WebGL export failed.";throw je.value=lt,new Error(`Video export failed: ${lt}`)}finally{tt.value=!1}}async function ad(b){const V=new mr(o.serverRenderEndpoint??"/api/v1");je.value="Starting server render...",Ze.value=0;const X=await V.createRenderJob({source_media_uuid:s.value,recipe:b});Tt.value=X.id,i("server-render-started",X.id),i("export-started",X.id),je.value="Rendering on server...";const q=await V.pollRenderJob(X.id,(Q,de)=>{Ze.value=Q,de==="processing"&&(je.value=`Server rendering: ${Q}%`)},3e3,(o.maxDuration>0?o.maxDuration*3:1800)*1e3);Ze.value=100,Xt.value=!0,je.value="Server render complete!",te(),i("recipe-generated",b);const ce={id:q.id};typeof q.output_media_id=="string"&&q.output_media_id!==""&&(ce.output_media_id=q.output_media_id),i("server-render-completed",ce)}async function Ar(){if(!tt.value)return;Ct=!0,E.value=!1,Ht&&(Ht.abort(),Ht=null),en();const b=Tt.value;if(b)try{const V=await fetch(`/api/v1/video/jobs/${b}`,{method:"DELETE"});if(!V.ok)throw new Error(`Cancel failed: ${V.status} ${V.statusText}`)}catch(V){const X=V instanceof Error?V.message:"Failed to cancel export";je.value=X,tt.value=!1,Tt.value=null;return}tt.value=!1,Ze.value=0,Xt.value=!1,Tt.value=null,je.value="Export canceled."}async function Lr(b){en(),Ct=!1,Ht=null,Tt.value=null,je.value=null,Xt.value=!1,tt.value=!0,Ze.value=0;try{const V=Xn(qc(ve(),b));i("recipe-generated",V);const X=s.value.startsWith("temp-"),q=V.timeline[0],ce=Array.isArray(q==null?void 0:q.filters)?q.filters:[],Q=!0,de=typeof window<"u"&&window.MEDIABLES_ALLOW_SERVER_EXPORT_FALLBACK===1||typeof localStorage<"u"&&localStorage.getItem("mediables.export.allowServerFallback")==="1";if(Q)try{const bt=await Or(V,b,Nn=>{Ct||(Ze.value=Nn)});if(Ct){je.value="Export canceled.",tt.value=!1,Ze.value=0;return}i("video-exported",bt);const Ro=URL.createObjectURL(bt.file),Hn=document.createElement("a");Hn.href=Ro,Hn.download=`edited-video-${Date.now()}.mp4`,Hn.click(),setTimeout(()=>URL.revokeObjectURL(Ro),100),tt.value=!1,Ze.value=100,Xt.value=!0;return}catch(bt){if(Ct){je.value="Export canceled.",tt.value=!1,Ze.value=0;return}if(X||!de)throw bt;Ze.value=0,je.value="Local filter export failed, falling back to server render."}const $e={"360p":"low","480p":"low","720p":"medium","1080p":"high","1440p":"ultra","2160p":"ultra"},mt=(b==null?void 0:b.quality)??V.output.quality,Gt=$e[mt]??"high",$t={...ed(V),export:{format:(b==null?void 0:b.format)??V.output.format,quality:Gt,resolution:mt,framerate:V.output.fps}},Dt=await fetch("/api/v1/video/jobs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source_media_id:s.value,recipe:$t})});if(!Dt.ok)throw new Error(`Export failed: ${Dt.status} ${Dt.statusText}`);const Ut=await Dt.json(),nt=(Ut==null?void 0:Ut.data)??Ut,lt=typeof(nt==null?void 0:nt.id)=="string"?nt.id:null;if(!lt)throw new Error("Export failed: missing job id");Tt.value=lt,i("export-started",lt),hd(lt)}catch(V){if(E.value=!1,Ht=null,Ct){je.value="Export canceled.",tt.value=!1,Ze.value=0,Tt.value=null;return}try{const X=Xn(ve()),q=new Blob([JSON.stringify(X,null,2)],{type:"application/json"}),ce=URL.createObjectURL(q),Q=document.createElement("a");Q.href=ce,Q.download=`video-recipe-${Date.now()}.json`,Q.click(),setTimeout(()=>URL.revokeObjectURL(ce),100)}finally{tt.value=!1,Ze.value=0,Tt.value=null,je.value=V instanceof Error?V.message:"Export failed"}}}const Ga=async b=>{await new Promise(V=>{window.setTimeout(V,b)})},Ja=b=>{if(!b||b.width<=0||b.height<=0)return null;try{return b.toDataURL("image/jpeg",.85)}catch{return null}},id=b=>{if(!b||typeof b!="object")return null;const X=b.pixiCanvas;if(X&&typeof X=="object"&&"value"in X){const q=X.value;return q instanceof HTMLCanvasElement?q:null}return X instanceof HTMLCanvasElement?X:null},rd=b=>{if(!b||typeof b!="object")return null;const V=b.duration;if(typeof V=="number"&&Number.isFinite(V))return V;if(V&&typeof V=="object"&&"value"in V){const X=V.value;if(typeof X=="number"&&Number.isFinite(X))return X}return null},sd=b=>{if(!b||typeof b!="object")return null;const X=b.videoElement;if(X&&typeof X=="object"&&"value"in X){const q=X.value;return q instanceof HTMLVideoElement?q:null}return X instanceof HTMLVideoElement?X:null},zr=b=>typeof b.params=="object"&&b.params!==null?b.params:{},ld=b=>{const V=[];for(const X of b){const q=zr(X),ce=X.filterId.trim().toLowerCase();if(ce==="brightness"){const de=(Xe(st(q,["value","brightness"],0),-1,1)+1)*100;V.push(`brightness(${de.toFixed(2)}%)`);continue}if(ce==="contrast"){const Q=Xe(st(q,["value","contrast"],1),.1,4);V.push(`contrast(${(Q*100).toFixed(2)}%)`);continue}if(ce==="saturation"||ce==="saturate"){const Q=Xe(st(q,["value","saturation"],1),0,4);V.push(`saturate(${(Q*100).toFixed(2)}%)`);continue}if(ce==="grayscale"){V.push("grayscale(100%)");continue}if(ce==="sepia"){V.push("sepia(100%)");continue}if(ce==="blur"||ce==="gaussian-blur"||ce==="kawase-blur"){const Q=Xe(st(q,["value","blur","radius"],0),0,30);Q>.01&&V.push(`blur(${Q.toFixed(2)}px)`);continue}if(ce==="adjustment"){const Q=st(q,["brightness"],1),de=st(q,["contrast"],1),$e=st(q,["saturation"],1);Math.abs(Q-1)>.01&&V.push(`brightness(${(Xe(Q,0,5)*100).toFixed(2)}%)`),Math.abs(de-1)>.01&&V.push(`contrast(${(Xe(de,.1,5)*100).toFixed(2)}%)`),Math.abs($e-1)>.01&&V.push(`saturate(${(Xe($e,0,5)*100).toFixed(2)}%)`);continue}if(ce==="cinematic"){V.push("contrast(120%) brightness(95%) saturate(85%)");continue}if(ce==="dramatic"){V.push("contrast(140%) brightness(90%) saturate(110%) sepia(10%)");continue}if(ce==="dreamy"){V.push("blur(0.5px) brightness(105%) saturate(90%) contrast(95%)");continue}}return V.join(" ")},cd=b=>{const V=b.find(ce=>ce.filterId.trim().toLowerCase()==="noise");if(!V)return 0;const X=zr(V),q=st(X,["noise","value","amount","intensity"],.2);return q<=1?Xe(q,0,1):Xe(q/100,0,1)},dd=(b,V,X,q)=>{if(q<=0)return;const ce=b.getImageData(0,0,V,X),Q=255*q;for(let de=0;de<ce.data.length;de+=4){const $e=(Math.random()*2-1)*Q;ce.data[de]=Xe(ce.data[de]+$e,0,255),ce.data[de+1]=Xe(ce.data[de+1]+$e,0,255),ce.data[de+2]=Xe(ce.data[de+2]+$e,0,255)}b.putImageData(ce,0,0)},Pr=async b=>{b.readyState>=2&&b.videoWidth>0&&b.videoHeight>0||await new Promise(V=>{let X=!1,q=0;const ce=()=>{X||(X=!0,b.removeEventListener("loadedmetadata",Q),b.removeEventListener("loadeddata",Q),b.removeEventListener("canplay",Q),window.clearTimeout(q),V())},Q=()=>{ce()};b.addEventListener("loadedmetadata",Q),b.addEventListener("loadeddata",Q),b.addEventListener("canplay",Q),q=window.setTimeout(()=>ce(),800),b.play().catch(()=>{})})},ud=async(b,V)=>{await new Promise(X=>{let q=!1,ce=0;const Q=()=>{q||(q=!0,b.removeEventListener("seeked",de),window.clearTimeout(ce),X())},de=()=>{Q()};if(Math.abs(b.currentTime-V)<.016){requestAnimationFrame(()=>Q());return}b.addEventListener("seeked",de),ce=window.setTimeout(()=>Q(),700),b.currentTime=V})},jr=async(b,V)=>{await Pr(b);const X=Math.floor(b.videoWidth),q=Math.floor(b.videoHeight);if(X<=0||q<=0)return null;const ce=Number.isFinite(b.duration)&&b.duration>0?b.duration:0,Q=ce>0?Xe(V,0,ce):0;await ud(b,Q);const de=document.createElement("canvas");de.width=X,de.height=q;const $e=de.getContext("2d");if(!$e)return null;const mt=ld(qe.value);mt!==""&&($e.filter=mt);try{$e.drawImage(b,0,0,X,q)}catch{return null}const Gt=cd(qe.value);return dd($e,X,q,Gt),Ja(de)},md=async(b,V)=>{const X=document.createElement("video");X.src=b,X.muted=!0,X.playsInline=!0,X.preload="auto",b.startsWith("blob:")||(X.crossOrigin="anonymous");try{return await Pr(X),await jr(X,V)}catch{return null}finally{X.pause(),X.removeAttribute("src"),X.load()}},pd=async b=>{const V=_.value,X=Ja(id(V));if(X)return X;if(V!=null&&V.captureFrameAt)for(let Q=0;Q<4;Q+=1){const de=rd(V);if(de!==null&&de<=0&&Q<2){await Ga(80);continue}const $e=await Promise.race([V.captureFrameAt(b),Ga(450).then(()=>null)]),mt=Ja($e);if(mt)return mt;await Ga(80)}const q=sd(V);if(q){const Q=await jr(q,b);if(Q)return Q}const ce=Wa.value.trim();if(ce!==""){const Q=await md(ce,b);if(Q)return Q}return null},Wr=b=>b.map(V=>({...V,params:V.params&&typeof V.params=="object"?{...V.params}:V.params}));function Zr(b){const V=Wr(qe.value);if(!Ya(b)&&V.length>0&&Array.isArray(b.timeline)&&b.timeline.length>0){const q=b.timeline[0];q&&(b.timeline=[{...q,filters:V},...b.timeline.slice(1)])}return b}const Ya=b=>Array.isArray(b.timeline)?b.timeline.some(V=>Array.isArray(V.filters)&&V.filters.length>0):!1,fd=b=>{if(!b||typeof b!="object")return null;const V=b.posterFrame;if(typeof V!="string")return null;const X=V.trim();return X!==""?X:null};async function Ka(){const b=Xn(Zr(ee())),V=Wr(qe.value),X=Ya(b)||V.length>0,q=fd(o.initialRecipe);if(X){const ce=ne.value>0?ne.value:.1;try{const Q=await pd(ce);Q?b.posterFrame=Q:q&&(b.posterFrame=q)}catch{q&&(b.posterFrame=q)}}else delete b.posterFrame;return te(),i("draft-saved",b),b}function Xr(){pe()&&(Sr(),Rt())}async function hd(b){en(),Mo=window.setInterval(async()=>{var V,X;try{if(Ct){en();return}const q=await fetch(`/api/v1/video/jobs/${b}`);if(!q.ok)throw new Error(`Status poll failed: ${q.status} ${q.statusText}`);const ce=await q.json(),Q=(ce==null?void 0:ce.data)??ce,de=Number((Q==null?void 0:Q.progress)??0);if(Ze.value=Number.isFinite(de)?de:0,Q.status==="completed"||Q.status==="failed"||Q.status==="cancelled")if(en(),tt.value=!1,Tt.value=null,Q.status==="completed"){const $e=((V=Q==null?void 0:Q.output_media)==null?void 0:V.url)??(Q==null?void 0:Q.output_url);Ze.value=100,Xt.value=!0,je.value=null}else{const $e=!!((X=Q==null?void 0:Q.meta)!=null&&X.is_cancelled)||Q.status==="cancelled"||typeof(Q==null?void 0:Q.error_message)=="string"&&/cancel/i.test(Q.error_message);je.value=$e?"Export canceled.":typeof(Q==null?void 0:Q.error_message)=="string"&&Q.error_message.trim()!==""?Q.error_message:"Export failed"}}catch(q){en(),tt.value=!1,Tt.value=null,je.value=q instanceof Error?q.message:"Failed to check export progress"}},2e3)}function qa(){const b=Xn(ve());try{const V=b.timeline??[]}catch{}x.value=b}let sn=null;function Rt(){sn&&clearTimeout(sn),sn=setTimeout(()=>{qa(),sn=null},200)}e.watch(()=>M.value,Rt,{deep:!0}),e.watch(()=>Y.value,b=>{if(O.value||!b)return;const V=(b==null?void 0:b.filters)??[];Cc(V)},{immediate:!0}),e.watch(()=>qe.value,b=>{fe(b),Rt()},{deep:!0}),e.watch(()=>T.value,b=>{P(b),Rt()},{deep:!0}),e.watch(()=>A.value,b=>{const V=b.map(X=>({...X,source:typeof X.source=="string"?X.source:void 0}));J(V),Rt()},{deep:!0}),e.watch(()=>ne.value,Rt),n({saveDraft:Ka,exportForUpload:od}),qa(),e.onUnmounted(()=>{en(),Ct=!0,sn&&(clearTimeout(sn),sn=null),f.value&&(f.value.destroy(),f.value=null),N.value=null,g.value=null,S.value=null});function vd(){ft||!Xa.value||(ft=new ag({filters:Zn.value,callbacks:{onApplyFilter:b=>{Wn(b.id)},onRemoveFilter:b=>{Cr(b)},onUpdateParam:(b,V,X)=>{Fr(b,V,X)},onPreviewFilter:b=>{Er(b.id)}}}),ft.mount(Xa.value),ft.setActiveFilters(ja.value))}e.watch(ja,b=>{ft==null||ft.setActiveFilters(b)},{deep:!0}),e.watch(Zn,b=>{ft==null||ft.setFilters(b)});let tn=null;return e.onMounted(()=>{window.addEventListener("resize",K);const b=()=>{!Sn.value||tn||(tn=new ResizeObserver(V=>{V[0]&&(Bo.value=Math.round(V[0].contentRect.width))}),tn.observe(Sn.value))};b(),tn||e.nextTick(b),o.media&&qa(),l.value&&e.nextTick(()=>{vd()}),e.nextTick(()=>{const V=document.querySelector(".video-editor");V&&V.getBoundingClientRect();const X=document.querySelector(".mobile-layout");X&&X.getBoundingClientRect()})}),e.onUnmounted(()=>{window.removeEventListener("resize",K),tn==null||tn.disconnect(),tn=null,ft==null||ft.destroy(),ft=null}),(b,V)=>{var X,q,ce,Q;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-editor",{mobile:l.value}])},[l.value?(e.openBlock(),e.createElementBlock("div",qy,[e.createElementVNode("div",Qy,[e.createElementVNode("div",ew,[e.createElementVNode("button",{class:e.normalizeClass(["mobile-toolbar-btn",{active:e.unref(ae)}]),onClick:V[0]||(V[0]=(...de)=>e.unref(re)&&e.unref(re)(...de)),"aria-label":e.unref(ae)?"Pause":"Play","data-testid":"btn-mobile-play"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(ae)?e.unref(nl):e.unref(al)},null,8,["icon"])],10,tw),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:Xr,"aria-label":"Reset all changes","data-testid":"btn-mobile-reset"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Un)},null,8,["icon"])])]),e.createElementVNode("div",nw,[e.createElementVNode("button",{class:"mobile-toolbar-btn mobile-toolbar-save",onClick:Ka,"aria-label":"Save","data-testid":"btn-mobile-save",disabled:!e.unref(me)},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Zi)},null,8,["icon"]),V[14]||(V[14]=e.createElementVNode("span",null,"Save",-1))],8,ow),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:V[1]||(V[1]=de=>Lr()),"aria-label":"Export","data-testid":"btn-mobile-export",disabled:tt.value||!e.unref(me)},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(po)},null,8,["icon"])],8,aw),e.createElementVNode("button",{class:"mobile-toolbar-btn",onClick:V[2]||(V[2]=de=>i("close")),"aria-label":"Close","data-testid":"btn-mobile-close"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Fn)},null,8,["icon"])])])]),e.createElementVNode("div",iw,[e.withDirectives(e.createVNode(ns,{ref_key:"pixiPreviewMobileRef",ref:v,"aria-hidden":!p.value,class:"preview-host-child",source:Wa.value,filters:Tr.value,playhead:Mr.value,"is-playing":e.unref(ae),"fit-mode":$.value,active:p.value,onPlayPause:e.unref(re),onDurationChange:Fo},null,8,["aria-hidden","source","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,p.value]]),e.withDirectives(e.createVNode(ks,{"aria-hidden":!h.value,class:"preview-host-child","media-uuid":s.value,recipe:x.value,media:Nr.value,"enable-engine":h.value&&_r.value,"fit-mode":$.value,onTimeUpdate:Rr,onPlayStateChange:$r,onDurationChange:Fo,onEngineReady:Ur},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,h.value]]),tt.value?(e.openBlock(),e.createElementBlock("div",rw,[e.createElementVNode("div",sw,[e.createElementVNode("span",null,"Exporting "+e.toDisplayString(Ze.value)+"%",1),e.createElementVNode("div",lw,[e.createElementVNode("div",{class:"mobile-export-bar-fill",style:e.normalizeStyle({width:Ze.value+"%"})},null,4)]),e.createElementVNode("button",{class:"mobile-export-cancel",onClick:Ar},"Cancel")])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:Sn,class:"timeline-section"},[e.createElementVNode("div",cw,[e.createElementVNode("button",{class:"mobile-zoom-btn",onClick:V[3]||(V[3]=de=>Dr(-20)),"aria-label":"Zoom out timeline","data-testid":"btn-timeline-zoom-out"},[...V[15]||(V[15]=[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)])]),e.createElementVNode("button",{class:"mobile-zoom-btn",onClick:V[4]||(V[4]=de=>Dr(20)),"aria-label":"Zoom in timeline","data-testid":"btn-timeline-zoom-in"},[...V[16]||(V[16]=[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)])])]),e.createVNode(xs,{playhead:e.unref(ne),clips:e.unref(M),"selected-clip-id":((X=e.unref(Y))==null?void 0:X.id)??((q=e.unref(M)[0])==null?void 0:q.id)??null,duration:Qt.value,"zoom-level":e.unref(Te),sensitivity:.25,"is-mobile":!0,"onUpdate:playhead":e.unref(Ne),onTrim:e.unref(se),onSplit:e.unref(be),onClipSelect:e.unref(ie),onClipMove:e.unref(We)},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","onUpdate:playhead","onTrim","onSplit","onClipSelect","onClipMove"])],512),e.createElementVNode("div",{ref_key:"mobileControlsRef",ref:Xa,class:"controls-section mobile-controls"},null,512)])):(e.openBlock(),e.createElementBlock("div",dw,[e.createElementVNode("div",uw,[e.createElementVNode("div",mw,[e.createElementVNode("div",pw,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":V[5]||(V[5]=de=>$.value=de),"aria-label":"Fit mode","data-testid":"select-video-fit-mode"},[...V[17]||(V[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,$.value]])])]),e.withDirectives(e.createVNode(ns,{ref_key:"pixiPreviewDesktopRef",ref:y,"aria-hidden":!p.value,class:"preview-host-child",source:Wa.value,filters:Tr.value,playhead:Mr.value,"is-playing":e.unref(ae),"fit-mode":$.value,active:p.value,onPlayPause:e.unref(re),onDurationChange:Fo},null,8,["aria-hidden","source","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,p.value]]),e.withDirectives(e.createVNode(ks,{"aria-hidden":!h.value,class:"preview-host-child","media-uuid":s.value,recipe:x.value,media:Nr.value,"enable-engine":h.value&&_r.value,"fit-mode":$.value,onTimeUpdate:Rr,onPlayStateChange:$r,onDurationChange:Fo,onEngineReady:Ur},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,h.value]]),b.showThumbnailPicker?(e.openBlock(),e.createBlock(Iv,{key:0,"media-uuid":s.value,duration:Qt.value,onSelect:Kc},null,8,["media-uuid","duration"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",fw,[e.createElementVNode("div",hw,[e.createElementVNode("div",vw,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.value,de=>(e.openBlock(),e.createElementBlock("button",{key:de.id,class:e.normalizeClass(["tab-btn",{active:d.value===de.id}]),onClick:$e=>d.value=de.id},e.toDisplayString(de.label),11,gw))),128))]),e.createElementVNode("div",yw,[e.withDirectives(e.createElementVNode("div",ww,[e.createVNode(j0,{filters:Zn.value,"active-filters":ja.value,"thumbnail-url":_c.value,onApplyFilter:Wn,onRemoveFilter:Cr,onUpdateParam:Fr,onPreviewFilter:Uc},null,8,["filters","active-filters","thumbnail-url"])],512),[[e.vShow,d.value==="filters"]]),e.withDirectives(e.createElementVNode("div",bw,[e.createVNode(Qv,{overlays:T.value,onAddOverlay:Ac,onUpdateOverlay:Lc,onRemoveOverlay:zc},null,8,["overlays"])],512),[[e.vShow,d.value==="text"]]),e.withDirectives(e.createElementVNode("div",kw,[e.createVNode(k1,{"selected-clips":R.value,"applied-transitions":F.value,onApplyTransition:Pc,onRemoveTransition:jc,onPreviewTransition:Wc},null,8,["selected-clips","applied-transitions"])],512),[[e.vShow,d.value==="transitions"]]),e.withDirectives(e.createElementVNode("div",xw,[e.createVNode(ng,{"audio-layers":A.value,"master-volume":j.value,onAddTrack:Zc,onUpdateTrack:Xc,onRemoveTrack:Hc,onUpdateVolume:Gc,onToggleMute:Jc,onUpdateMasterVolume:Yc},null,8,["audio-layers","master-volume"])],512),[[e.vShow,d.value==="audio"]]),e.withDirectives(e.createElementVNode("div",Ew,[e.unref(xr)?(e.openBlock(),e.createBlock(nv,{key:0,filter:e.unref(xr),"current-frame":e.unref(Ce),onUpdateParams:Oc},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",Vw,[...V[18]||(V[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",Sw,[e.createVNode(gv,{"can-export":e.unref(me),"is-exporting":tt.value,"export-progress":Ze.value,onExport:Lr,onCancelExport:Ar,onSaveDraft:Ka,onReset:Xr},null,8,["can-export","is-exporting","export-progress"]),Xt.value?(e.openBlock(),e.createElementBlock("div",Cw," Export complete ")):e.createCommentVNode("",!0),je.value&&!Xt.value?(e.openBlock(),e.createElementBlock("div",Nw,e.toDisplayString(je.value),1)):e.createCommentVNode("",!0)],512),[[e.vShow,d.value==="export"]])])])])]),e.createElementVNode("div",_w,[e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:Sn,class:"timeline-container"},[e.createElementVNode("div",Tw,[e.createElementVNode("label",null,[V[19]||(V[19]=e.createTextVNode(" Zoom ",-1)),e.createElementVNode("input",{type:"range",min:"10",max:"600",value:e.unref(Te),onInput:V[6]||(V[6]=de=>Dc(de))},null,40,Mw)]),e.createElementVNode("span",Bw,e.toDisplayString(Math.round(e.unref(Te)))+" px/s",1)]),e.createVNode(xs,{playhead:e.unref(ne),clips:e.unref(M),"selected-clip-id":((ce=e.unref(Y))==null?void 0:ce.id)??((Q=e.unref(M)[0])==null?void 0:Q.id)??null,duration:Qt.value,"zoom-level":e.unref(Te),sensitivity:.25,"onUpdate:playhead":e.unref(Ne),onTrim:e.unref(se),onSplit:e.unref(be),onClipSelect:e.unref(ie),onClipMove:e.unref(We)},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","onUpdate:playhead","onTrim","onSplit","onClipSelect","onClipMove"]),e.createVNode(a0,{"selected-clip":e.unref(Y),"can-split":Tc.value,"can-delete":Mc.value,"is-playing":e.unref(ae),"zoom-level":e.unref(Te),"playback-speed":e.unref(ue),onSplit:e.unref(le),onDelete:e.unref(ke),onDuplicate:e.unref(Ve),onZoomIn:e.unref(Fe),onZoomOut:e.unref(Oe),onZoomChange:e.unref(et),onFitToWindow:$c,onPlayPause:e.unref(re),onFrameForward:e.unref(ze),onFrameBackward:e.unref(wt),onSkipToStart:e.unref(ut),onSkipToEnd:e.unref(St),onSpeedChange:e.unref(Ge)},null,8,["selected-clip","can-split","can-delete","is-playing","zoom-level","playback-speed","onSplit","onDelete","onDuplicate","onZoomIn","onZoomOut","onZoomChange","onPlayPause","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"]),we.value?(e.openBlock(),e.createElementBlock("div",Iw,[e.createElementVNode("div",Fw,[e.createElementVNode("label",Rw,[V[20]||(V[20]=e.createElementVNode("span",null,"Trim start (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":V[7]||(V[7]=de=>En.value=de),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-start"},null,512),[[e.vModelText,En.value]])]),e.createElementVNode("label",$w,[V[21]||(V[21]=e.createElementVNode("span",null,"Trim end (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":V[8]||(V[8]=de=>Vn.value=de),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-end"},null,512),[[e.vModelText,Vn.value]])]),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-start-playhead",disabled:!e.unref(Y),onClick:V[9]||(V[9]=de=>Ir("start"))}," Start = Playhead ",8,Dw),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-end-playhead",disabled:!e.unref(Y),onClick:V[10]||(V[10]=de=>Ir("end"))}," End = Playhead ",8,Uw),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-trim",disabled:!e.unref(Y),onClick:Ic}," Apply Trim ",8,Ow)]),e.createElementVNode("div",Aw,[e.createElementVNode("label",Lw,[V[22]||(V[22]=e.createElementVNode("span",null,"Quick filter",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":V[11]||(V[11]=de=>qt.value=de),"data-testid":"video-dev-filter-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Zn.value,de=>(e.openBlock(),e.createElementBlock("option",{key:de.id,value:de.id},e.toDisplayString(de.name),9,zw))),128))],512),[[e.vModelSelect,qt.value]])]),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-filter",disabled:!e.unref(Y)||qt.value==="",onClick:Fc}," Apply Filter ",8,Pw),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-clear-filters",disabled:e.unref(qe).length===0,onClick:Rc}," Clear Filters ",8,jw),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(Y),onClick:V[12]||(V[12]=de=>Wn("noise"))}," QA: Noise ",8,Ww),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(Y),onClick:V[13]||(V[13]=de=>Wn("grayscale"))}," QA: Grayscale ",8,Zw)])])):e.createCommentVNode("",!0)],512)])]))],2)}}}),Li=Me(Xw,[["__scopeId","data-v-5d8a0dc1"]]),Hw={key:0,class:"ve-fullscreen"},Gw=["aria-label"],Jw={class:"ve-header"},Yw={class:"ve-title"},Kw={class:"ve-body"},qw={class:"ve-footer"},Qw=e.defineComponent({__name:"VideoEditorDialog",props:{open:{type:Boolean},mediaUuid:{},initialRecipe:{},media:{},showThumbnailPicker:{type:Boolean,default:!1},title:{default:"Edit Video"}},emits:["update:open","close","recipe-generated","export-started","draft-saved","thumbnail-selected"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(typeof window<"u"?window.innerWidth<768:!1);function r(){i.value=window.innerWidth<768}e.onMounted(()=>window.addEventListener("resize",r)),e.onUnmounted(()=>window.removeEventListener("resize",r));const s=e.computed(()=>t.open??!0),l=e.computed(()=>{var d;return t.mediaUuid||((d=t.media)==null?void 0:d.id)||`temp-${Date.now()}`});function c(){o("close"),o("update:open",!1)}return(d,u)=>s.value&&i.value?(e.openBlock(),e.createElementBlock("div",Hw,[e.createVNode(Li,e.mergeProps({"media-uuid":l.value},{...d.initialRecipe?{initialRecipe:d.initialRecipe}:{},...d.media?{media:d.media}:{}},{"show-thumbnail-picker":d.showThumbnailPicker??!1,onRecipeGenerated:u[0]||(u[0]=m=>d.$emit("recipe-generated",m)),onExportStarted:u[1]||(u[1]=m=>d.$emit("export-started",m)),onDraftSaved:u[2]||(u[2]=m=>d.$emit("draft-saved",m)),onThumbnailSelected:u[3]||(u[3]=m=>d.$emit("thumbnail-selected",m))}),null,16,["media-uuid","show-thumbnail-picker"])])):s.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"ve-overlay",onClick:e.withModifiers(c,["self"])},[e.createElementVNode("div",{class:"ve-dialog",role:"dialog","aria-label":d.title,"aria-modal":"true"},[e.createElementVNode("header",Jw,[e.createElementVNode("h2",Yw,e.toDisplayString(d.title),1),e.createElementVNode("button",{class:"ve-close",onClick:c,"aria-label":"Close"}," ✕ ")]),e.createElementVNode("section",Kw,[e.createVNode(Li,e.mergeProps({"media-uuid":l.value},{...d.initialRecipe?{initialRecipe:d.initialRecipe}:{},...d.media?{media:d.media}:{}},{"show-thumbnail-picker":d.showThumbnailPicker??!1,onRecipeGenerated:u[4]||(u[4]=m=>d.$emit("recipe-generated",m)),onExportStarted:u[5]||(u[5]=m=>d.$emit("export-started",m)),onDraftSaved:u[6]||(u[6]=m=>d.$emit("draft-saved",m)),onThumbnailSelected:u[7]||(u[7]=m=>d.$emit("thumbnail-selected",m))}),null,16,["media-uuid","show-thumbnail-picker"])]),e.createElementVNode("footer",qw,[e.renderSlot(d.$slots,"footer",{},()=>[e.createElementVNode("button",{class:"ve-btn",onClick:c},"Cancel")],!0)])],8,Gw)])):e.createCommentVNode("",!0)}}),eb=Me(Qw,[["__scopeId","data-v-b948d9bc"]]),tb={class:"video-editor-modal"},nb={class:"video-preview-container"},ob=["src"],ab={class:"video-overlay-controls"},ib=["aria-label"],rb={class:"time-display"},sb={class:"timeline-container"},lb={class:"clip-name"},cb={class:"timeline-time-labels"},db={class:"tool-tabs"},ub=["onClick"],mb={class:"tool-panel"},pb={key:0,class:"trim-panel"},fb={class:"trim-controls"},hb={key:1,class:"filters-panel"},vb={class:"filter-grid"},gb=["onClick"],yb={key:2,class:"text-panel"},wb={key:3,class:"transitions-panel"},bb={class:"transition-grid"},kb=["onClick"],xb={class:"action-buttons"},Eb=e.defineComponent({__name:"VideoEditorSimple",props:{media:{}},emits:["save","cancel"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(""),s=e.ref(!1),l=e.ref(0),c=e.ref(0),d=e.ref("video-1"),u=e.ref(0),m=e.ref(0),p=e.ref(null),h=e.ref("trim"),v=e.ref(null),y=e.ref(""),E=[{id:"trim",label:"Trim",icon:el},{id:"filters",label:"Filters",icon:ou},{id:"text",label:"Text",icon:il},{id:"transitions",label:"Transitions",icon:uu}],_=[{id:"none",name:"None"},{id:"grayscale",name:"Grayscale"},{id:"sepia",name:"Sepia"},{id:"blur",name:"Blur"},{id:"brightness",name:"Brightness"},{id:"contrast",name:"Contrast"}],C=[{id:"fade",name:"Fade"},{id:"slide",name:"Slide"},{id:"zoom",name:"Zoom"},{id:"wipe",name:"Wipe"}],w=e.ref();e.onMounted(()=>{var I,D;(I=t.media)!=null&&I.url?r.value=t.media.url:(D=t.media)!=null&&D.file&&(r.value=URL.createObjectURL(t.media.file))}),e.onUnmounted(()=>{var I;(I=t.media)!=null&&I.file&&r.value&&URL.revokeObjectURL(r.value)});function f(){i.value&&(c.value=i.value.duration,m.value=c.value)}function x(){i.value&&(l.value=i.value.currentTime)}function $(){s.value=!1}function N(){i.value&&(s.value?(i.value.pause(),s.value=!1):(i.value.play(),s.value=!0))}function g(I){if(!I||isNaN(I))return"00:00";const D=Math.floor(I/60),Z=Math.floor(I%60);return`${D.toString().padStart(2,"0")}:${Z.toString().padStart(2,"0")}`}function S(I){if(!i.value||!w.value)return;const D=w.value.getBoundingClientRect(),oe=(I.clientX-D.left)/D.width*c.value;i.value.currentTime=Math.max(0,Math.min(oe,c.value))}function O(){u.value=l.value}function k(){m.value=l.value}function T(){u.value=0,m.value=c.value}function F(I){p.value=I;const D=W=>{if(!p.value||!w.value)return;const oe=w.value.getBoundingClientRect(),ne=(W.clientX-oe.left)/oe.width*c.value;p.value==="start"?u.value=Math.max(0,Math.min(ne,m.value-1)):m.value=Math.max(u.value+1,Math.min(ne,c.value))},Z=()=>{p.value=null,document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",Z)};document.addEventListener("mousemove",D),document.addEventListener("mouseup",Z)}function A(I){if(v.value=I,!i.value)return;const D={none:"none",grayscale:"grayscale(100%)",sepia:"sepia(100%)",blur:"blur(5px)",brightness:"brightness(150%)",contrast:"contrast(150%)"};i.value.style.filter=D[I]||"none"}function R(){}function j(I){}function K(){const I={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:y.value?[{content:y.value}]:[],duration:m.value-u.value};o("save",I)}return(I,D)=>(e.openBlock(),e.createElementBlock("div",tb,[e.createElementVNode("div",nb,[e.createElementVNode("video",{ref_key:"videoElement",ref:i,class:"video-preview",src:r.value,onLoadedmetadata:f,onTimeupdate:x,onEnded:$,controls:""},null,40,ob),e.createElementVNode("div",ab,[e.createElementVNode("button",{class:"play-pause-btn",onClick:N,"aria-label":s.value?"Pause":"Play"},[e.createVNode(e.unref(B.IonIcon),{icon:s.value?e.unref(hu):e.unref(wu)},null,8,["icon"])],8,ib),e.createElementVNode("div",rb,e.toDisplayString(g(l.value))+" / "+e.toDisplayString(g(c.value)),1)])]),e.createElementVNode("div",sb,[e.createElementVNode("div",{class:"timeline-track",onClick:S,ref_key:"timelineTrack",ref:w},[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",lb,e.toDisplayString(d.value),1)],4),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:`${l.value/c.value*100}%`})},null,4),h.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:0,class:"trim-handle trim-start",style:e.normalizeStyle({left:`${u.value/c.value*100}%`}),onMousedown:D[0]||(D[0]=Z=>F("start"))},null,36)):e.createCommentVNode("",!0),h.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:1,class:"trim-handle trim-end",style:e.normalizeStyle({left:`${m.value/c.value*100}%`}),onMousedown:D[1]||(D[1]=Z=>F("end"))},null,36)):e.createCommentVNode("",!0)],512),e.createElementVNode("div",cb,[e.createElementVNode("span",null,e.toDisplayString(g(0)),1),e.createElementVNode("span",null,e.toDisplayString(g(c.value)),1)])]),e.createElementVNode("div",db,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(E,Z=>e.createElementVNode("button",{key:Z.id,class:e.normalizeClass(["tool-tab",{active:h.value===Z.id}]),onClick:W=>h.value=Z.id},[e.createVNode(e.unref(B.IonIcon),{icon:Z.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(Z.label),1)],10,ub)),64))]),e.createElementVNode("div",mb,[h.value==="trim"?(e.openBlock(),e.createElementBlock("div",pb,[D[7]||(D[7]=e.createElementVNode("h3",null,"Trim Video",-1)),D[8]||(D[8]=e.createElementVNode("p",null,"Click and drag on the timeline to set trim points",-1)),e.createElementVNode("div",fb,[e.createElementVNode("button",{class:"btn-trim",onClick:O},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Kr)},null,8,["icon"]),D[4]||(D[4]=e.createTextVNode(" Set Start ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:k},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Kr)},null,8,["icon"]),D[5]||(D[5]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:T},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Fn)},null,8,["icon"]),D[6]||(D[6]=e.createTextVNode(" Clear ",-1))])])])):h.value==="filters"?(e.openBlock(),e.createElementBlock("div",hb,[D[9]||(D[9]=e.createElementVNode("h3",null,"Filters",-1)),e.createElementVNode("div",vb,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(_,Z=>e.createElementVNode("button",{key:Z.id,class:e.normalizeClass(["filter-option",{active:v.value===Z.id}]),onClick:W=>A(Z.id)},e.toDisplayString(Z.name),11,gb)),64))])])):h.value==="text"?(e.openBlock(),e.createElementBlock("div",yb,[D[10]||(D[10]=e.createElementVNode("h3",null,"Text Overlay",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":D[2]||(D[2]=Z=>y.value=Z),type:"text",placeholder:"Enter text...",class:"text-input"},null,512),[[e.vModelText,y.value]]),e.createElementVNode("button",{class:"btn-add-text",onClick:R},"Add Text")])):h.value==="transitions"?(e.openBlock(),e.createElementBlock("div",wb,[D[11]||(D[11]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",bb,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(C,Z=>e.createElementVNode("button",{key:Z.id,class:"transition-option",onClick:W=>(Z.id,void 0)},e.toDisplayString(Z.name),9,kb)),64))])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",xb,[e.createElementVNode("button",{class:"btn-cancel",onClick:D[3]||(D[3]=Z=>I.$emit("cancel"))},"CANCEL"),e.createElementVNode("button",{class:"btn-save",onClick:K},"SAVE")])]))}}),Vb=Me(Eb,[["__scopeId","data-v-b933f33b"]]),Sb={class:"time-label"},Cb=e.defineComponent({__name:"TimeRuler",props:{duration:{},zoom:{}},setup(a){const n=a,t=e.computed(()=>({width:`${n.duration*n.zoom*100}px`})),o=e.computed(()=>{const s=[],l=i(n.duration,n.zoom);for(let c=0;c<=n.duration;c+=l){const d=`${c/n.duration*100}%`,u=r(c),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(o.value,c=>(e.openBlock(),e.createElementBlock("div",{key:c.time,class:"time-mark",style:e.normalizeStyle({left:c.position})},[e.createElementVNode("span",Sb,e.toDisplayString(c.label),1),e.createElementVNode("div",{class:e.normalizeClass(["time-tick",{major:c.major}])},null,2)],4))),128))],4))}}),Nb=Me(Cb,[["__scopeId","data-v-0ef9c910"]]),_b=["data-track-index"],Tb={class:"track-header"},Mb={class:"track-label"},Bb={class:"track-controls"},Ib=["data-testid","aria-label"],Fb=["data-testid","onMousedown","onClick"],Rb={class:"clip-content"},$b={class:"clip-name"},Db={key:0,class:"clip-thumbnail"},Ub=["src","alt"],Ob=["onMousedown","aria-label"],Ab=["onMousedown","aria-label"],Lb=e.defineComponent({__name:"VideoTrack",props:{clips:{},trackIndex:{},zoom:{},duration:{}},emits:["clip-move","clip-trim","clip-select"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(null),r=e.ref(!1),s=e.ref(!1),l=e.ref(null),c=e.computed(()=>({width:`${t.duration*t.zoom*100}px`}));function d(E){const _=E.timelineEnd-E.timelineStart,C=E.timelineStart/t.duration*100,w=_/t.duration*100;return{left:`${C}%`,width:`${w}%`,backgroundColor:u(E)}}function u(E){const _=["#4A90E2","#7ED321","#F5A623","#BD10E0","#9013FE","#50E3C2","#B8E986","#F8E71C"],C=parseInt(E.id.replace(/\D/g,""))%_.length;return _[C]}function m(E){return E.label?E.label:E.url?(E.url.split("/").pop()||"Clip").split(".")[0]:`Clip ${E.id.slice(-4)}`}function p(E){i.value=E.id,o("clip-select",E.id)}function h(){r.value=!r.value}function v(E,_){if(l.value)return;s.value=!0;const C=_.clientX,w=E.timelineStart,f=$=>{if(!s.value)return;const N=$.clientX-C,g=parseFloat(c.value.width),S=N/(t.zoom*100)*(t.duration/g),O=Math.max(0,w+S);o("clip-move",E.id,O)},x=()=>{s.value=!1,document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",x)};document.addEventListener("mousemove",f),document.addEventListener("mouseup",x)}function y(E,_,C){l.value=_;const w=C.clientX,f=E.sourceIn,x=E.sourceOut,$=g=>{if(!l.value)return;const S=g.clientX-w,O=parseFloat(c.value.width),k=S/(t.zoom*100)*(t.duration/O);if(l.value==="start"){const T=Math.max(0,f+k);o("clip-trim",E.id,T,x)}else{const T=Math.max(f+1,x+k);o("clip-trim",E.id,f,T)}},N=()=>{l.value=null,document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",N)};document.addEventListener("mousemove",$),document.addEventListener("mouseup",N)}return(E,_)=>(e.openBlock(),e.createElementBlock("div",{class:"video-track","data-track-index":E.trackIndex},[e.createElementVNode("div",Tb,[e.createElementVNode("span",Mb,"Track "+e.toDisplayString(E.trackIndex+1),1),e.createElementVNode("div",Bb,[E.clips.length>0?(e.openBlock(),e.createElementBlock("button",{key:0,class:"track-btn","data-testid":`btn-mute-track-${E.trackIndex}`,"aria-label":`${r.value?"Unmute":"Mute"} track ${E.trackIndex+1}`,onClick:h},[e.createVNode(e.unref(B.IonIcon),{icon:r.value?e.unref(Ru):e.unref(Iu)},null,8,["icon"])],8,Ib)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",{class:"track-timeline",style:e.normalizeStyle(c.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.clips,C=>(e.openBlock(),e.createElementBlock("div",{key:C.id,class:e.normalizeClass(["timeline-clip",{selected:C.id===i.value}]),style:e.normalizeStyle(d(C)),"data-testid":`clip-${C.id}`,onMousedown:w=>v(C,w),onClick:w=>p(C)},[e.createElementVNode("div",Rb,[e.createElementVNode("span",$b,e.toDisplayString(m(C)),1),C.thumbnail?(e.openBlock(),e.createElementBlock("div",Db,[e.createElementVNode("img",{src:C.thumbnail,alt:m(C)},null,8,Ub)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:e.withModifiers(w=>y(C,"start",w),["stop"]),"aria-label":`Trim start of ${m(C)}`},null,40,Ob),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:e.withModifiers(w=>y(C,"end",w),["stop"]),"aria-label":`Trim end of ${m(C)}`},null,40,Ab)],46,Fb))),128))],4)],8,_b))}}),zb=Me(Lb,[["__scopeId","data-v-48e480d2"]]),Pb={class:"video-timeline"},jb={class:"timeline-tracks"},Wb=["aria-label","aria-valuenow","aria-valuemax"],Zb={class:"timeline-controls"},Xb={class:"zoom-level"},Hb=e.defineComponent({__name:"VideoTimeline",props:{clips:{},duration:{},currentTime:{}},emits:["update:clips","seek","clip-move","clip-trim"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(1),r=e.ref(null),s=e.ref(!1),l=e.ref(),c=e.computed(()=>{const w=Math.max(0,...t.clips.map(f=>f.track||0));return Array(w+1).fill(null)}),d=e.computed(()=>`${t.currentTime/t.duration*100}%`);function u(w){return t.clips.filter(f=>(f.track||0)===w)}function m(w){const f=Math.floor(w/60),x=Math.floor(w%60);return`${f}:${x.toString().padStart(2,"0")}`}function p(w,f){o("clip-move",w,f)}function h(w,f,x){o("clip-trim",w,f,x)}function v(w){r.value=w}function y(){i.value=Math.min(i.value*1.2,5)}function E(){i.value=Math.max(i.value/1.2,.5)}function _(){s.value=!0;const w=x=>{if(!s.value||!l.value)return;const $=l.value.getBoundingClientRect(),S=Math.max(0,Math.min(x.clientX-$.left,$.width))/$.width*t.duration;o("seek",S)},f=()=>{s.value=!1,document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",f)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",f)}function C(w){let f=t.currentTime;switch(w.key){case"ArrowLeft":f=Math.max(0,t.currentTime-1);break;case"ArrowRight":f=Math.min(t.duration,t.currentTime+1);break;case"Home":f=0;break;case"End":f=t.duration;break;default:return}w.preventDefault(),o("seek",f)}return e.onMounted(()=>{l.value=document.querySelector(".video-timeline")}),e.onUnmounted(()=>{}),(w,f)=>(e.openBlock(),e.createElementBlock("div",Pb,[e.createVNode(Nb,{duration:w.duration,zoom:i.value},null,8,["duration","zoom"]),e.createElementVNode("div",jb,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,(x,$)=>(e.openBlock(),e.createBlock(zb,{key:`track-${$}`,"data-testid":`track-${$}`,clips:u($),"track-index":$,zoom:i.value,duration:w.duration,onClipMove:p,onClipTrim:h,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:_,"data-testid":"playhead","aria-label":`Playhead at ${m(w.currentTime)}`,role:"slider","aria-valuenow":w.currentTime,"aria-valuemax":w.duration,tabindex:"0",onKeydown:C},null,44,Wb),e.createElementVNode("div",Zb,[e.createElementVNode("button",{"data-testid":"btn-zoom-in","aria-label":"Zoom in",onClick:y},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(ji)},null,8,["icon"])]),e.createElementVNode("span",Xb,e.toDisplayString(Math.round(i.value*100))+"%",1),e.createElementVNode("button",{"data-testid":"btn-zoom-out","aria-label":"Zoom out",onClick:E},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Su)},null,8,["icon"])])])]))}}),Gb=Me(Hb,[["__scopeId","data-v-001df415"]]),Jb={class:"video-filters-panel"},Yb={class:"filter-controls"},Kb=["for"],qb={class:"filter-slider-group"},Qb=["id","onUpdate:modelValue","min","max","step","data-testid","aria-label","aria-valuenow","aria-valuemin","aria-valuemax","onInput"],e2={class:"filter-value"},t2={class:"filter-actions"},n2={key:0,class:"filter-presets"},o2={class:"preset-list"},a2=["data-testid","aria-label","onClick"],i2=e.defineComponent({__name:"VideoFiltersPanel",emits:["filter-change"],setup(a,{emit:n}){const t=n,o=[{type:"brightness",label:"Brightness",min:0,max:200,step:1,default:100},{type:"contrast",label:"Contrast",min:0,max:200,step:1,default:100},{type:"saturation",label:"Saturation",min:0,max:200,step:1,default:100},{type:"hue",label:"Hue",min:-180,max:180,step:1,default:0},{type:"blur",label:"Blur",min:0,max:10,step:.5,default:0},{type:"sharpen",label:"Sharpen",min:0,max:10,step:.5,default:0},{type:"sepia",label:"Sepia",min:0,max:100,step:1,default:0},{type:"grayscale",label:"Grayscale",min:0,max:100,step:1,default:0}],i=e.reactive(o.reduce((p,h)=>(p[h.type]=h.default,p),{})),r=e.ref([{id:"vintage",name:"Vintage",values:{brightness:110,contrast:120,saturation:80,sepia:30}},{id:"noir",name:"Film Noir",values:{brightness:90,contrast:130,grayscale:100}},{id:"vibrant",name:"Vibrant",values:{brightness:110,contrast:110,saturation:140}},{id:"dreamy",name:"Dreamy",values:{brightness:120,blur:2,saturation:90}}]);function s(p,h){switch(p){case"brightness":case"contrast":case"saturation":case"sepia":case"grayscale":return`${h}%`;case"hue":return`${h}°`;case"blur":case"sharpen":return h.toFixed(1);default:return h.toString()}}function l(p){return["brightness","contrast","saturation","hue","blur","sharpen","sepia","grayscale"].includes(p)}function c(p){if(!l(p))return;const h={id:`filter-${p}`,filterId:p,params:{value:i[p]},intensity:1};t("filter-change",h)}function d(){o.forEach(p=>{i[p.type]=p.default,c(p.type)})}function u(){const p=prompt("Enter preset name:");if(!p)return;const h={id:`custom-${Date.now()}`,name:p,values:{...i}};r.value.push(h)}function m(p){Object.entries(p.values).forEach(([h,v])=>{i[h]=v,c(h)})}return(p,h)=>(e.openBlock(),e.createElementBlock("div",Jb,[h[3]||(h[3]=e.createElementVNode("h3",null,"Video Filters",-1)),e.createElementVNode("div",Yb,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(o,v=>e.createElementVNode("div",{key:v.type,class:"filter-control"},[e.createElementVNode("label",{for:`filter-${v.type}`},e.toDisplayString(v.label),9,Kb),e.createElementVNode("div",qb,[e.withDirectives(e.createElementVNode("input",{id:`filter-${v.type}`,"onUpdate:modelValue":y=>i[v.type]=y,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:y=>c(v.type)},null,40,Qb),[[e.vModelText,i[v.type],void 0,{number:!0}]]),e.createElementVNode("span",e2,e.toDisplayString(s(v.type,i[v.type])),1)])])),64))]),e.createElementVNode("div",t2,[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(B.IonIcon),{icon:e.unref(Un)},null,8,["icon"]),h[0]||(h[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(B.IonIcon),{icon:e.unref(Zi)},null,8,["icon"]),h[1]||(h[1]=e.createTextVNode(" Save as Preset ",-1))])]),r.value.length>0?(e.openBlock(),e.createElementBlock("div",n2,[h[2]||(h[2]=e.createElementVNode("h4",null,"Presets",-1)),e.createElementVNode("div",o2,[(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:y=>m(v)},e.toDisplayString(v.name),9,a2))),128))])])):e.createCommentVNode("",!0)]))}}),r2=Me(i2,[["__scopeId","data-v-5ad2ac63"]]),s2={class:"video-text-panel"},l2={class:"text-input-group"},c2={class:"text-options"},d2={class:"option-row"},u2={class:"option-row"},m2={class:"option-row"},p2={class:"option-row"},f2={class:"checkbox-label"},h2={class:"option-row"},v2={class:"text-overlay-list"},g2={key:0,class:"empty-state"},y2=["data-testid"],w2={class:"overlay-preview"},b2={class:"overlay-controls"},k2=["data-testid","aria-label","onClick"],x2=["data-testid","aria-label","onClick"],E2=["data-testid","aria-label","onClick"],V2=e.defineComponent({__name:"VideoTextPanel",emits:["text-add","text-remove","text-update"],setup(a,{emit:n}){const t=n,o=e.ref([]),i=e.reactive({text:"",fontFamily:"Arial",fontSize:32,color:"#FFFFFF",backgroundColor:"#000000",hasBackground:!0,animation:"fade-in"});function r(){if(!i.text.trim())return;const d={id:`text-${Date.now()}`,text:i.text,x:50,y:50,fontSize:i.fontSize,fontFamily:i.fontFamily,color:i.color,startTime:0,opacity:1};i.hasBackground&&(d.backgroundColor=i.backgroundColor),i.animation!=="none"&&(d.animation=i.animation),o.value.push(d),t("text-add",d),i.text=""}function s(d){const u=o.value.findIndex(m=>m.id===d);u!==-1&&(o.value.splice(u,1),t("text-remove",d))}function l(d){i.text=d.text,i.fontFamily=d.fontFamily||"Arial",i.fontSize=d.fontSize,i.color=d.color,i.backgroundColor=d.backgroundColor||"#000000",i.hasBackground=!!d.backgroundColor,i.animation=d.animation||"none",s(d.id)}function c(d){const u={...d,id:`text-${Date.now()}`,x:d.x+10,y:d.y+10};o.value.push(u),t("text-add",u)}return(d,u)=>(e.openBlock(),e.createElementBlock("div",s2,[u[17]||(u[17]=e.createElementVNode("h3",null,"Text Overlays",-1)),e.createElementVNode("div",l2,[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(B.IonIcon),{icon:e.unref(ji)},null,8,["icon"]),u[7]||(u[7]=e.createTextVNode(" Add ",-1))])]),e.createElementVNode("div",c2,[e.createElementVNode("div",d2,[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",u2,[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",m2,[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",p2,[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",f2,[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",h2,[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",v2,[u[16]||(u[16]=e.createElementVNode("h4",null,"Active Overlays",-1)),o.value.length===0?(e.openBlock(),e.createElementBlock("div",g2," No text overlays added yet ")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(m,p)=>(e.openBlock(),e.createElementBlock("div",{key:m.id,class:"text-overlay-item","data-testid":`overlay-${p}`},[e.createElementVNode("div",w2,[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",b2,[e.createElementVNode("button",{class:"edit-btn","data-testid":`btn-edit-${p}`,"aria-label":`Edit overlay: ${m.text}`,onClick:h=>l(m)},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(ru)},null,8,["icon"])],8,k2),e.createElementVNode("button",{class:"duplicate-btn","data-testid":`btn-duplicate-${p}`,"aria-label":`Duplicate overlay: ${m.text}`,onClick:h=>c(m)},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(iu)},null,8,["icon"])],8,x2),e.createElementVNode("button",{class:"remove-btn","data-testid":`btn-remove-${p}`,"aria-label":`Remove overlay: ${m.text}`,onClick:h=>s(m.id)},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(_u)},null,8,["icon"])],8,E2)])],8,y2))),128))])]))}}),S2=Me(V2,[["__scopeId","data-v-4d240e1e"]]),C2={class:"video-tools-panel"},N2={class:"tool-tabs"},_2=["data-testid","aria-label","aria-selected","onClick"],T2={class:"tool-content"},M2={key:0,class:"trim-panel",role:"tabpanel","aria-label":"Trim controls"},B2={class:"trim-actions"},I2={key:3,class:"transitions-panel",role:"tabpanel","aria-label":"Transition controls"},F2={class:"transition-types"},R2=["data-testid","aria-label","onClick"],$2={class:"transition-preview"},D2=e.defineComponent({__name:"VideoToolsPanel",props:{activeTool:{}},emits:["tool-change","filter-change","text-add","transition-add","trim-set-start","trim-set-end","trim-clear"],setup(a){const n=[{id:"trim",name:"Trim",icon:el},{id:"filters",name:"Filters",icon:an},{id:"text",name:"Text",icon:il},{id:"transitions",name:"Transitions",icon:es}],t=[{id:"fade",name:"Fade",icon:oi},{id:"slide-left",name:"Slide Left",icon:qd},{id:"slide-right",name:"Slide Right",icon:Qd},{id:"dissolve",name:"Dissolve",icon:oi},{id:"wipe",name:"Wipe",icon:es},{id:"zoom",name:"Zoom",icon:oi}];return(o,i)=>(e.openBlock(),e.createElementBlock("div",C2,[e.createElementVNode("div",N2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(n,r=>e.createElementVNode("button",{key:r.id,class:e.normalizeClass(["tool-tab",{active:o.activeTool===r.id}]),"data-testid":`tab-${r.id}`,"aria-label":`${r.name} tool`,"aria-selected":o.activeTool===r.id,role:"tab",onClick:s=>o.$emit("tool-change",r.id)},[e.createVNode(e.unref(B.IonIcon),{icon:r.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(r.name),1)],10,_2)),64))]),e.createElementVNode("div",T2,[o.activeTool==="trim"?(e.openBlock(),e.createElementBlock("div",M2,[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",B2,[e.createElementVNode("button",{class:"action-btn","data-testid":"btn-set-start","aria-label":"Set trim start at current position",onClick:i[0]||(i[0]=r=>o.$emit("trim-set-start"))},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(qr)},null,8,["icon"]),i[5]||(i[5]=e.createTextVNode(" Set Start ",-1))]),e.createElementVNode("button",{class:"action-btn","data-testid":"btn-set-end","aria-label":"Set trim end at current position",onClick:i[1]||(i[1]=r=>o.$emit("trim-set-end"))},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(qr)},null,8,["icon"]),i[6]||(i[6]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"action-btn","data-testid":"btn-clear-trim","aria-label":"Clear trim points",onClick:i[2]||(i[2]=r=>o.$emit("trim-clear"))},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Fn)},null,8,["icon"]),i[7]||(i[7]=e.createTextVNode(" Clear ",-1))])])])):e.createCommentVNode("",!0),o.activeTool==="filters"?(e.openBlock(),e.createBlock(r2,{key:1,onFilterChange:i[3]||(i[3]=r=>o.$emit("filter-change",r))})):e.createCommentVNode("",!0),o.activeTool==="text"?(e.openBlock(),e.createBlock(S2,{key:2,onTextAdd:i[4]||(i[4]=r=>o.$emit("text-add",r))})):e.createCommentVNode("",!0),o.activeTool==="transitions"?(e.openBlock(),e.createElementBlock("div",I2,[i[10]||(i[10]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",F2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(t,r=>e.createElementVNode("button",{key:r.id,class:"transition-btn","data-testid":`transition-${r.id}`,"aria-label":`Add ${r.name} transition`,onClick:s=>o.$emit("transition-add",r.id)},[e.createElementVNode("div",$2,[e.createVNode(e.unref(B.IonIcon),{icon:r.icon},null,8,["icon"])]),e.createElementVNode("span",null,e.toDisplayString(r.name),1)],8,R2)),64))])])):e.createCommentVNode("",!0)])]))}}),U2=Me(D2,[["__scopeId","data-v-fc135306"]]),O2={class:"video-export-panel"},A2={class:"export-presets"},L2=["value"],z2={key:0,class:"preset-details"},P2={class:"detail-row"},j2={class:"detail-row"},W2={class:"detail-row"},Z2={class:"advanced-options"},X2={class:"options-content"},H2={class:"option-group"},G2={class:"option-group"},J2={class:"option-group"},Y2=["disabled"],K2={key:1,class:"export-progress"},q2={class:"progress-message"},Q2={class:"progress-bar"},ek=["aria-valuenow"],tk={class:"progress-percentage"},nk=e.defineComponent({__name:"VideoExportPanel",props:{presets:{},isExporting:{type:Boolean},exportProgress:{}},emits:["export"],setup(a,{emit:n}){const t=a,o=n,i=e.ref("instagram-reel"),r=e.reactive({quality:"medium",bitrate:5,includeAudio:!0}),s=e.computed(()=>t.presets.find(d=>d.id===i.value)),l=e.computed(()=>t.exportProgress<10?"Initializing export...":t.exportProgress<30?"Processing video tracks...":t.exportProgress<50?"Applying filters and effects...":t.exportProgress<70?"Rendering frames...":t.exportProgress<90?"Encoding video...":t.exportProgress<100?"Finalizing export...":"Export complete!");function c(){s.value&&o("export",{...s.value,options:{...r}})}return(d,u)=>(e.openBlock(),e.createElementBlock("div",O2,[u[14]||(u[14]=e.createElementVNode("h3",null,"Export Video",-1)),e.createElementVNode("div",A2,[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,L2))),128))],512),[[e.vModelSelect,i.value]])]),s.value?(e.openBlock(),e.createElementBlock("div",z2,[e.createElementVNode("div",P2,[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",j2,[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",W2,[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",Z2,[u[12]||(u[12]=e.createElementVNode("summary",null,"Advanced Options",-1)),e.createElementVNode("div",X2,[e.createElementVNode("div",H2,[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",G2,[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",J2,[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(B.IonSpinner),{key:0,name:"crescent"})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(po)},null,8,["icon"]),u[13]||(u[13]=e.createTextVNode(" Export Video ",-1))],64))],8,Y2),d.isExporting?(e.openBlock(),e.createElementBlock("div",K2,[e.createElementVNode("div",q2,e.toDisplayString(l.value),1),e.createElementVNode("div",Q2,[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,ek)]),e.createElementVNode("div",tk,e.toDisplayString(d.exportProgress)+"% ",1)])):e.createCommentVNode("",!0)]))}}),ok=Me(nk,[["__scopeId","data-v-5caf8fe6"]]),ak=["data-testid"],ik={class:"progress-header"},rk={class:"file-info"},sk={class:"file-details"},lk={class:"file-name"},ck={class:"file-meta"},dk={class:"file-size"},uk={key:0,class:"separator"},mk={key:1,class:"upload-speed"},pk={key:2,class:"separator"},fk={key:3,class:"time-remaining"},hk={class:"progress-actions"},vk={key:0,class:"status-icon completed","data-testid":"video-upload-status-completed"},gk={key:1,class:"status-icon error","data-testid":"video-upload-status-error"},yk={key:2,class:"status-icon processing","data-testid":"video-upload-status-processing",role:"status","aria-label":"Processing video"},wk=["aria-valuenow","aria-label"],bk={class:"progress-bar"},kk={class:"progress-percent"},xk={key:1,class:"error-message","data-testid":"video-upload-error"},Ek={key:2,class:"thumbnail-preview","data-testid":"video-upload-thumbnail"},Vk=["src","alt"],Sk={key:0,class:"video-duration"},Ck=e.defineComponent({__name:"VideoUploadProgress",props:{upload:{}},emits:["cancel","retry","remove"],setup(a){const n=a,t=e.computed(()=>({"is-uploading":n.upload.status==="uploading","is-processing":n.upload.status==="processing","is-completed":n.upload.status==="completed","is-error":n.upload.status==="error","is-pending":n.upload.status==="pending"})),o=e.computed(()=>rl),i=e.computed(()=>["uploading","processing"].includes(n.upload.status)),r=e.computed(()=>(n.upload.status==="processing",n.upload.progress||0)),s=e.computed(()=>{if(!n.upload.timeRemaining||n.upload.status!=="uploading")return null;const p=n.upload.timeRemaining;if(p<60)return`${Math.round(p)}s`;const h=Math.floor(p/60);return h<60?`${h}m ${Math.round(p%60)}s`:`${Math.floor(h/60)}h ${h%60}m`}),l=e.computed(()=>{var p;return n.upload.status==="completed"&&((p=n.upload.media)!=null&&p.thumbnail_url)?n.upload.media.thumbnail_url:null}),c=e.computed(()=>{var p;return(p=n.upload.media)==null?void 0:p.duration});function d(p){if(p===0)return"0 B";const h=["B","KB","MB","GB","TB"],v=1024,y=Math.floor(Math.log(p)/Math.log(v));return`${(p/Math.pow(v,y)).toFixed(1)} ${h[y]}`}function u(p){if(p===0)return"0 B/s";const h=["B/s","KB/s","MB/s","GB/s"],v=1024,y=Math.floor(Math.log(p)/Math.log(v));return`${(p/Math.pow(v,y)).toFixed(1)} ${h[y]}`}function m(p){const h=Math.floor(p/3600),v=Math.floor(p%3600/60),y=Math.floor(p%60);return h>0?`${h}:${v.toString().padStart(2,"0")}:${y.toString().padStart(2,"0")}`:`${v}:${y.toString().padStart(2,"0")}`}return(p,h)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["upload-progress-item",t.value]),"data-testid":`video-upload-progress-${p.upload.id}`},[e.createElementVNode("div",ik,[e.createElementVNode("div",rk,[e.createVNode(e.unref(B.IonIcon),{icon:o.value,class:"file-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("div",sk,[e.createElementVNode("h4",lk,e.toDisplayString(p.upload.filename),1),e.createElementVNode("p",ck,[e.createElementVNode("span",dk,e.toDisplayString(d(p.upload.bytesTotal||0)),1),p.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",uk,"•")):e.createCommentVNode("",!0),p.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",mk,e.toDisplayString(u(p.upload.uploadSpeed||0)),1)):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",pk,"•")):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",fk,e.toDisplayString(s.value)+" remaining ",1)):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",hk,[p.upload.status==="completed"?(e.openBlock(),e.createElementBlock("div",vk,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(qs)},null,8,["icon"])])):p.upload.status==="error"?(e.openBlock(),e.createElementBlock("div",gk,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Kd),"aria-hidden":"true"},null,8,["icon"])])):p.upload.status==="processing"?(e.openBlock(),e.createElementBlock("div",yk,[e.createVNode(e.unref(B.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),p.upload.status==="uploading"?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:3,fill:"clear",size:"small",onClick:h[0]||(h[0]=v=>p.$emit("cancel")),"data-testid":"btn-cancel-video-upload","aria-label":"Cancel upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Fn),slot:"icon-only"},null,8,["icon"])]),_:1})):p.upload.status==="error"?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:4,fill:"clear",size:"small",onClick:h[1]||(h[1]=v=>p.$emit("retry")),"data-testid":"btn-retry-video-upload","aria-label":"Retry upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Un),slot:"icon-only"},null,8,["icon"])]),_:1})):p.upload.status==="completed"?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:5,fill:"clear",size:"small",onClick:h[2]||(h[2]=v=>p.$emit("remove")),"data-testid":"btn-remove-video-upload","aria-label":"Remove from list"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Fn),slot:"icon-only"},null,8,["icon"])]),_:1})):e.createCommentVNode("",!0)])]),i.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"progress-bar-container","data-testid":"video-upload-progress-bar",role:"progressbar","aria-valuenow":Math.round(r.value),"aria-valuemin":"0","aria-valuemax":"100","aria-label":p.upload.status==="processing"?"Processing progress":"Upload progress"},[e.createElementVNode("div",bk,[e.createElementVNode("div",{class:e.normalizeClass(["progress-fill",{indeterminate:p.upload.status==="processing"}]),style:e.normalizeStyle({width:r.value+"%"})},null,6)]),e.createElementVNode("span",kk,e.toDisplayString(Math.round(r.value))+"%",1)],8,wk)):e.createCommentVNode("",!0),p.upload.error?(e.openBlock(),e.createElementBlock("div",xk,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref($u)},null,8,["icon"]),e.createElementVNode("span",null,e.toDisplayString(p.upload.error),1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",Ek,[e.createElementVNode("img",{src:l.value,alt:p.upload.filename},null,8,Vk),c.value?(e.openBlock(),e.createElementBlock("div",Sk,e.toDisplayString(m(c.value)),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],10,ak))}}),Nk=Me(Ck,[["__scopeId","data-v-9eacbf91"]]),fi=4,_k=500,Tk=new Set([408,425,429,500,502,503,504,520,521,522,523,524,525]);function Aa(a){return typeof a=="object"&&a!==null}function As(a){return Aa(a)?typeof a.upload_url=="string"&&typeof a.upload_id=="string"&&typeof a.media_uuid=="string"&&typeof a.expires_at=="string":!1}function Mk(a){if(As(a))return a;if(Aa(a)&&As(a.data))return a.data;throw new Error("Invalid upload response from backend")}function Ls(a){return Aa(a)?typeof a.uuid=="string"&&typeof a.processing_status=="string":!1}function Bk(a){if(Ls(a))return a;if(Aa(a)&&Ls(a.data))return a.data;throw new Error("Invalid media response from backend")}function zo(a){return a?{...a}:{}}function zs(a,n="PUT"){return typeof a.method=="string"&&a.method.trim()!==""?a.method.trim().toUpperCase():n}function Ik(a){return a.resumable===!0?!0:/tusupload/i.test(a.upload_url)}function Fk(a){if(typeof btoa=="function")try{return btoa(unescape(encodeURIComponent(a)))}catch{return btoa(a)}throw new Error("Base64 encoder is unavailable for TUS metadata")}function Rk(a,n){return[["filename",a.filename],["filetype",a.file.type||"application/octet-stream"],["uploadid",n.upload_id],["mediauuid",n.media_uuid]].map(([o,i])=>`${o} ${Fk(i)}`).join(",")}function Po(a,n){const t=Math.max(a.bytesTotal,1);a.bytesUploaded=n,a.progress=Math.min(100,n/t*100);const o=Math.max((Date.now()-a.startedAt.getTime())/1e3,.001);a.uploadSpeed=n/o;const i=Math.max(t-n,0);a.timeRemaining=i/Math.max(a.uploadSpeed,1)}function $k(a,n){return a instanceof Error?a:new Error(n)}function Dk(a){if(!(a instanceof Error))return!1;const n=a.message.toLowerCase();return n.includes("failed to fetch")||n.includes("networkerror")||n.includes("network request failed")||n.includes("err_ssl_")}function Ps(a){const n=Math.max(0,a-1),t=_k*Math.pow(2,n);return Math.min(5e3,t)}function js(a){return new Promise(n=>{window.setTimeout(n,a)})}async function Ws(a,n){for(let t=1;t<=fi;t+=1)try{const o=await n();if(o.ok||!Tk.has(o.status)||t>=fi)return o;await js(Ps(t))}catch(o){if(!Dk(o)||t>=fi)throw o;await js(Ps(t))}throw new Error(`${a} failed after retry attempts`)}function Uk(a={}){const n=e.ref(new Map),t=e.ref(new Set),o=e.ref(null),i=new Map,r=new Map,s=e.computed(()=>t.value.size>0),l=e.computed(()=>Array.from(n.value.values())),c=e.computed(()=>{const k=Array.from(n.value.values());return k.length===0?0:k.reduce((F,A)=>F+A.progress,0)/k.length});function d(k){o.value=k}function u(){}async function m(k){var F;const T=k.filter(A=>p(A));if(T.length!==0&&((F=a.onFilesSelected)==null||F.call(a,T),a.autoUpload!==!1))for(const A of T)await h(A)}function p(k){return!(a.maxFileSize&&k.size>a.maxFileSize||a.allowedFormats&&a.allowedFormats.length>0&&!a.allowedFormats.includes(k.type))}async function h(k){var A,R,j;const T=O(k);if(n.value.has(T)){const K=n.value.get(T);if((K==null?void 0:K.status)==="uploading")return}const F={id:T,file:k,filename:k.name,progress:0,status:"pending",startedAt:new Date,bytesTotal:k.size,bytesUploaded:0};n.value.set(F.id,F),t.value.add(F.id);try{F.status="uploading",(A=a.onUploadStart)==null||A.call(a,F);const K=await v(k);a.resumable===!0||K.resumable===!0?await E(F,K):await y(F,K),F.status="processing",F.progress=100;const D=await x(K.media_uuid);F.status="completed",F.media=D,(R=a.onUploadComplete)==null||R.call(a,D)}catch(K){if(F.status!=="cancelled"){const I=$k(K,"Upload failed");F.status="error",F.error=I.message,(j=a.onUploadError)==null||j.call(a,I,F)}}finally{t.value.delete(F.id),i.delete(F.id),r.delete(F.id)}}async function v(k){if(!o.value)throw new Error("API client not configured");const T={collection:a.collection||"videos",filename:k.name,size:k.size,mime_type:k.type,...a.ownerUuid!==void 0?{ownerUuid:a.ownerUuid}:{},...a.ownerType!==void 0?{ownerType:a.ownerType}:{}},F=await o.value.post("/api/v1/video/upload",T);return Mk(F)}async function y(k,T){const F=new XMLHttpRequest,A=zs(T),R=zo(T.headers);return new Promise((j,K)=>{F.upload.addEventListener("progress",I=>{var D;I.lengthComputable&&(Po(k,I.loaded),(D=a.onUploadProgress)==null||D.call(a,k))}),F.addEventListener("load",()=>{i.delete(k.id),F.status>=200&&F.status<300?j():K(new Error(`Upload failed with status ${F.status}`))}),F.addEventListener("error",()=>{i.delete(k.id),K(new Error("Upload failed"))}),F.addEventListener("abort",()=>{i.delete(k.id),K(new Error("Upload cancelled"))}),F.open(A,T.upload_url),Object.entries(R).forEach(([I,D])=>{F.setRequestHeader(I,D)}),!Object.keys(R).some(I=>I.toLowerCase()==="content-type")&&k.file.type&&F.setRequestHeader("Content-Type",k.file.type),i.set(k.id,F),F.send(k.file)})}async function E(k,T){var K;if(Ik(T)){await _(k,T);return}const F=a.chunkSize||5*1024*1024,A=C(k.file,F),R=new AbortController;r.set(k.id,R);const j=await f(T.upload_id);j&&(A.forEach(I=>{I.end<=j.bytesUploaded&&(I.uploaded=!0)}),Po(k,j.bytesUploaded));for(const I of A)I.uploaded||(await w(k,T,I,R),Po(k,I.end),(K=a.onUploadProgress)==null||K.call(a,k))}async function _(k,T){var Z;const F=new AbortController;r.set(k.id,F);const A={...zo(T.headers),"Tus-Resumable":"1.0.0","Upload-Length":String(k.file.size),"Upload-Metadata":Rk(k,T)},R=await Ws("Resumable upload initialization",()=>fetch(T.upload_url,{method:"POST",headers:A,signal:F.signal}));if(!R.ok)throw new Error(`Failed to initialize resumable upload: ${R.status}`);const j=R.headers.get("Location");if(!j)throw new Error("Resumable upload endpoint did not return upload location");const K=new URL(j,T.upload_url).toString(),I=a.chunkSize||5*1024*1024;let D=0;for(;D<k.file.size;){const W=Math.min(D+I,k.file.size),oe=k.file.slice(D,W),we={...zo(T.headers),"Tus-Resumable":"1.0.0","Upload-Offset":String(D),"Content-Type":"application/offset+octet-stream"},Ce=await Ws("Resumable chunk upload",()=>fetch(K,{method:"PATCH",headers:we,body:oe,signal:F.signal}));if(Ce.status===409){const M=Number(Ce.headers.get("Upload-Offset")??"-1");if(Number.isFinite(M)&&M>=0){D=M;continue}}if(!Ce.ok)throw new Error(`Resumable chunk upload failed: ${Ce.status}`);const ne=Number(Ce.headers.get("Upload-Offset")??String(W));D=Number.isFinite(ne)&&ne>D?ne:W,Po(k,D),(Z=a.onUploadProgress)==null||Z.call(a,k)}}function C(k,T){const F=[];let A=0,R=0;for(;A<k.size;){const j=Math.min(A+T,k.size);F.push({start:A,end:j,blob:k.slice(A,j),index:R,uploaded:!1}),A=j,R++}return F}async function w(k,T,F,A){const R={...zo(T.headers),"Content-Range":`bytes ${F.start}-${F.end-1}/${k.file.size}`,"Content-Type":k.file.type||"application/octet-stream"},j=await fetch(T.upload_url,{method:zs(T),headers:R,body:F.blob,signal:A.signal});if(!j.ok)throw new Error(`Chunk upload failed: ${j.status}`);F.uploaded=!0}async function f(k){return null}async function x(k){if(!o.value)throw new Error("API client not configured");const T=60;let F=0;for(;F<T;){const A=await o.value.get(`/api/v1/video/${k}`),R=Bk(A),j=String(R.processing_status);if(j==="ready")return R;if(j==="failed"||j==="error")throw new Error("Video processing failed");await new Promise(K=>{window.setTimeout(K,5e3)}),F++}throw new Error("Video processing timeout")}function $(k){const T=n.value.get(k);if(!T)return;const F=i.get(k);F&&(F.abort(),i.delete(k));const A=r.get(k);A&&(A.abort(),r.delete(k)),T.status="cancelled",T.error="Upload cancelled",t.value.delete(k)}async function N(k){const T=n.value.get(k);T&&(T.status="pending",T.error="",T.progress=0,T.bytesUploaded=0,await h(T.file))}function g(k){n.value.delete(k),t.value.delete(k),i.delete(k),r.delete(k)}function S(){Array.from(n.value.entries()).forEach(([k,T])=>{T.status==="completed"&&n.value.delete(k)})}function O(k){return`${k.name}-${k.size}-${Date.now()}`}return{uploads:l,isUploading:s,totalProgress:c,openFilePicker:u,handleFileSelect:m,validateFile:p,startUpload:h,cancelUpload:$,retryUpload:N,removeUpload:g,clearCompleted:S,setApiClient:d}}const Ok=["accept","multiple"],Ak={key:0,class:"upload-trigger","data-testid":"video-uploader-trigger"},Lk=["onKeydown"],zk={key:1,class:"upload-list","data-testid":"video-upload-list"},Pk={class:"drag-content"},jk=e.defineComponent({__name:"VideoUploader",props:{collection:{default:"videos"},multiple:{type:Boolean,default:!1},maxFileSize:{default:5*1024*1024*1024},maxDuration:{},allowedFormats:{default:()=>["video/mp4","video/webm","video/quicktime","video/x-msvideo"]},autoUpload:{type:Boolean,default:!0},resumable:{type:Boolean,default:!0},label:{default:"Upload Video"},description:{default:"Click to select or drag and drop"},ownerUuid:{},ownerType:{},apiClient:{}},emits:["upload-start","upload-progress","upload-complete","upload-error","files-selected"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(),r=e.ref(!1),{uploads:s,isUploading:l,handleFileSelect:c,cancelUpload:d,retryUpload:u,removeUpload:m,setApiClient:p}=Uk({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:f=>o("upload-start",f),onUploadProgress:f=>o("upload-progress",f),onUploadComplete:f=>o("upload-complete",f),onUploadError:(f,x)=>o("upload-error",f,x),onFilesSelected:f=>o("files-selected",f)});t.apiClient&&p(t.apiClient);const h=e.computed(()=>t.allowedFormats.join(",")),v=e.computed(()=>t.multiple||s.value.length===0);function y(){i.value&&i.value.click()}function E(f){const x=f.target,$=Array.from(x.files||[]);$.length>0&&(c($),x.value="")}function _(f){var N;f.preventDefault(),r.value=!1;const $=Array.from(((N=f.dataTransfer)==null?void 0:N.files)||[]).filter(g=>g.type.startsWith("video/"));$.length>0&&c($)}function C(f){var x;f.preventDefault(),(x=f.dataTransfer)!=null&&x.types.includes("Files")&&(r.value=!0)}function w(f){f.target.closest(".video-uploader")||(r.value=!1)}return e.onMounted(()=>{document.addEventListener("dragover",C),document.addEventListener("dragleave",w),document.addEventListener("drop",f=>f.preventDefault())}),e.onUnmounted(()=>{document.removeEventListener("dragover",C),document.removeEventListener("dragleave",w),document.removeEventListener("drop",f=>f.preventDefault())}),(f,x)=>(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:h.value,multiple:f.multiple,onChange:E,"data-testid":"video-uploader-input","aria-label":"Select video files to upload",hidden:""},null,40,Ok),!e.unref(l)||v.value?(e.openBlock(),e.createElementBlock("div",Ak,[e.renderSlot(f.$slots,"trigger",{open:y},()=>[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:y,onKeydown:[e.withKeys(y,["enter"]),e.withKeys(e.withModifiers(y,["prevent"]),["space"])]},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(rl),class:"upload-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("h3",null,e.toDisplayString(f.label),1),e.createElementVNode("p",null,e.toDisplayString(f.description),1),e.createVNode(e.unref(B.IonButton),{size:"small","data-testid":"btn-select-video","aria-label":"Select video file"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(ji),slot:"start","aria-hidden":"true"},null,8,["icon"]),x[2]||(x[2]=e.createTextVNode(" Select Video ",-1))]),_:1})],40,Lk)],!0)])):e.createCommentVNode("",!0),e.unref(s).length>0?(e.openBlock(),e.createElementBlock("div",zk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),$=>(e.openBlock(),e.createBlock(Nk,{key:$.id,upload:$,onCancel:N=>e.unref(d)($.id),onRetry:N=>e.unref(u)($.id),onRemove:N=>e.unref(m)($.id)},null,8,["upload","onCancel","onRetry","onRemove"]))),128))])):e.createCommentVNode("",!0),r.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:"drag-overlay","data-testid":"video-uploader-drag-overlay",onDrop:_,onDragover:x[0]||(x[0]=e.withModifiers(()=>{},["prevent"])),onDragleave:x[1]||(x[1]=$=>r.value=!1)},[e.createElementVNode("div",Pk,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(po),"aria-hidden":"true"},null,8,["icon"]),x[3]||(x[3]=e.createElementVNode("p",null,"Drop video files here",-1))])],32)):e.createCommentVNode("",!0)],2))}}),Wk=Me(jk,[["__scopeId","data-v-ea7587f7"]]),Zk=["aria-valuenow","aria-valuemax","aria-label"],Xk={class:"progress-bar"},Hk={class:"time-display","data-testid":"video-time-display"},Gk={class:"current-time"},Jk={class:"duration"},Yk={class:"control-buttons"},Kk={class:"controls-left"},qk=["aria-label"],Qk={class:"controls-center"},ex={key:0,class:"volume-controls"},tx=["aria-label"],nx=["value"],ox={class:"controls-right"},ax={key:0,class:"quality-selector"},ix=["aria-expanded"],rx={class:"quality-label"},sx={key:0,class:"quality-menu","data-testid":"video-quality-menu",role:"menu"},lx=["data-testid","aria-label","onClick"],cx=["aria-label"],dx=e.defineComponent({__name:"VideoControls",props:{playing:{type:Boolean},currentTime:{},duration:{},buffered:{},volume:{default:100},muted:{type:Boolean,default:!1},fullscreen:{type:Boolean,default:!1},isLive:{type:Boolean,default:!1},qualityLevels:{default:()=>[]},currentQuality:{default:"Auto"}},emits:["play-pause","play","pause","seek","skip-forward","skip-backward","toggleMute","setVolume","toggleFullscreen","togglePiP","selectQuality"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(!0),r=e.ref(!1),s=e.ref(),l=B.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 f=0;f<t.buffered.length;f++){const x=t.buffered.start(f),$=t.buffered.end(f);if(t.currentTime>=x&&t.currentTime<=$)return{width:`${$/t.duration*100}%`}}return t.buffered.length>0?{width:`${t.buffered.end(0)/t.duration*100}%`}:{width:"0%"}}),p=e.computed(()=>t.muted||t.volume===0?Fu:t.volume<33?Mu:t.volume<66?Bu:Tu);let h=null;function v(){i.value=!0,y()}function y(){h&&clearTimeout(h),t.playing&&!l&&(h=setTimeout(()=>{i.value=!1},3e3))}function E(f){if(!s.value||t.isLive)return;const x=s.value.getBoundingClientRect(),N=(f.clientX-x.left)/x.width*t.duration;o("seek",Math.max(0,Math.min(N,t.duration)))}function _(f){const x=f.target;o("setVolume",parseInt(x.value))}function C(f){o("selectQuality",f),r.value=!1}function w(f){if(!isFinite(f))return"0:00";const x=Math.floor(f/3600),$=Math.floor(f%3600/60),N=Math.floor(f%60);return x>0?`${x}:${$.toString().padStart(2,"0")}:${N.toString().padStart(2,"0")}`:`${$}:${N.toString().padStart(2,"0")}`}return e.onMounted(()=>{document.addEventListener("mousemove",v),y()}),e.onUnmounted(()=>{document.removeEventListener("mousemove",v),h&&clearTimeout(h)}),(f,x)=>(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(f.currentTime),"aria-valuemin":"0","aria-valuemax":Math.round(f.duration),"aria-label":f.isLive?"Live stream":"Video progress",tabindex:"0",onClick:E},[e.createElementVNode("div",Xk,[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",Hk,[e.createElementVNode("span",Gk,e.toDisplayString(w(f.currentTime)),1),x[7]||(x[7]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",Jk,e.toDisplayString(f.isLive?"LIVE":w(f.duration)),1)])],8,Zk),e.createElementVNode("div",Yk,[e.createElementVNode("div",Kk,[e.createElementVNode("button",{class:"control-btn play-pause","data-testid":"btn-video-play-pause",onClick:x[0]||(x[0]=$=>f.$emit("play-pause")),"aria-label":f.playing?"Pause":"Play"},[e.createVNode(e.unref(B.IonIcon),{icon:f.playing?e.unref(fu):e.unref(vu),"aria-hidden":"true"},null,8,["icon"])],8,qk),f.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"control-btn skip-backward","data-testid":"btn-video-skip-backward",onClick:x[1]||(x[1]=$=>f.$emit("skip-backward")),"aria-label":"Skip backward 10 seconds"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(gu),"aria-hidden":"true"},null,8,["icon"]),x[8]||(x[8]=e.createElementVNode("span",{class:"skip-label"},"10",-1))])),f.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn skip-forward","data-testid":"btn-video-skip-forward",onClick:x[2]||(x[2]=$=>f.$emit("skip-forward")),"aria-label":"Skip forward 10 seconds"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(bu),"aria-hidden":"true"},null,8,["icon"]),x[9]||(x[9]=e.createElementVNode("span",{class:"skip-label"},"10",-1))]))]),e.createElementVNode("div",Qk,[e.unref(l)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",ex,[e.createElementVNode("button",{class:"control-btn mute-btn","data-testid":"btn-video-mute",onClick:x[3]||(x[3]=$=>f.$emit("toggleMute")),"aria-label":f.muted?"Unmute":"Mute"},[e.createVNode(e.unref(B.IonIcon),{icon:p.value,"aria-hidden":"true"},null,8,["icon"])],8,tx),e.createElementVNode("input",{type:"range",class:"volume-slider","data-testid":"slider-video-volume",min:"0",max:"100",value:f.muted?0:f.volume,onInput:_,"aria-label":"Volume"},null,40,nx)]))]),e.createElementVNode("div",ox,[f.qualityLevels.length>1?(e.openBlock(),e.createElementBlock("div",ax,[e.createElementVNode("button",{class:"control-btn quality-btn","data-testid":"btn-video-quality",onClick:x[4]||(x[4]=$=>r.value=!r.value),"aria-label":"Quality settings","aria-expanded":r.value},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Cu),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("span",rx,e.toDisplayString(f.currentQuality),1)],8,ix),r.value?(e.openBlock(),e.createElementBlock("div",sx,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.qualityLevels,$=>(e.openBlock(),e.createElementBlock("button",{key:$.label,class:e.normalizeClass(["quality-option",{active:$.label===f.currentQuality}]),"data-testid":`btn-video-quality-${$.label}`,"aria-label":`Set quality to ${$.label}`,role:"menuitem",onClick:N=>C($)},e.toDisplayString($.label),11,lx))),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:x[5]||(x[5]=$=>f.$emit("togglePiP")),"aria-label":"Picture in Picture"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Nu),"aria-hidden":"true"},null,8,["icon"])])):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"control-btn fullscreen-btn","data-testid":"btn-video-fullscreen",onClick:x[6]||(x[6]=$=>f.$emit("toggleFullscreen")),"aria-label":f.fullscreen?"Exit fullscreen":"Enter fullscreen"},[e.createVNode(e.unref(B.IonIcon),{icon:f.fullscreen?e.unref(au):e.unref(su),"aria-hidden":"true"},null,8,["icon"])],8,cx)])])],2))}}),ux=Me(dx,[["__scopeId","data-v-2ae77c13"]]);function mx(a={}){var oe,we,Ce;const n=e.ref(),t=e.ref(),o=e.ref(!1),i=e.ref(0),r=e.ref(0),s=e.ref(100),l=e.ref(a.muted||!1),c=e.ref(!1),d=e.ref(),u=e.ref(1),m=e.ref(!1),p=e.ref(null),h=e.ref("idle"),v=e.ref(a.playbackUrl||((oe=a.media)==null?void 0:oe.playback_url)||((we=a.media)==null?void 0:we.url)||""),y=e.ref(null),E=e.ref(a.isLive||!1),_=e.ref(null),C=e.ref(null);function w(ne){C.value=ne}if((Ce=a.media)!=null&&Ce.token_expires_at){const ne=new Date(a.media.token_expires_at);y.value=Number.isNaN(ne.getTime())?null:ne}async function f(){var M;const ne=E.value?t.value:n.value;if(ne)try{await ne.play(),o.value=!0,h.value=E.value?"live":"playing",(M=a.onPlay)==null||M.call(a)}catch{p.value="Failed to play video",h.value="error"}}function x(){var M;const ne=E.value?t.value:n.value;ne&&(ne.pause(),o.value=!1,h.value="paused",(M=a.onPause)==null||M.call(a))}function $(){o.value?x():f()}function N(ne){const M=E.value?t.value:n.value;if(!M||E.value)return;const z=Number.isFinite(M.duration)?M.duration:ne;M.currentTime=Math.max(0,Math.min(ne,z)),i.value=M.currentTime}function g(ne=10){const M=n.value;!M||E.value||N(M.currentTime+ne)}function S(ne=10){const M=n.value;!M||E.value||N(M.currentTime-ne)}function O(){const ne=E.value?t.value:n.value;ne&&(ne.muted=!ne.muted,l.value=ne.muted)}function k(ne){const M=E.value?t.value:n.value;if(!M)return;const z=Math.max(0,Math.min(100,ne));M.volume=z/100,s.value=z,z>0&&M.muted&&(M.muted=!1,l.value=!1)}function T(ne){const M=n.value;!M||E.value||(M.playbackRate=ne,u.value=ne)}async function F(){const ne=document.querySelector(".video-player-container");if(ne)try{document.fullscreenElement?(await document.exitFullscreen(),c.value=!1):(await ne.requestFullscreen(),c.value=!0)}catch{}}async function A(){const ne=E.value?t.value:n.value;if(ne)try{document.pictureInPictureElement?await document.exitPictureInPicture():document.pictureInPictureEnabled&&await ne.requestPictureInPicture()}catch{}}async function R(){var M;p.value=null,h.value="loading",(M=a.media)!=null&&M.provider&&a.media.provider!=="local"&&await j();const ne=E.value?t.value:n.value;ne&&(ne.load(),await f())}async function j(){if(!(!C.value||!a.media))try{m.value=!0;const ne=await C.value.get(`/api/v1/video/${a.media.uuid}/playback`);v.value=ne.playback_url,y.value=new Date(ne.token_expires_at);const M=E.value?t.value:n.value;if(M&&M.src!==v.value){const z=!M.paused,me=M.currentTime;M.src=v.value,E.value||(M.currentTime=me),z&&await f()}}catch{p.value="Failed to refresh playback token",h.value="error"}finally{m.value=!1}}async function K(ne){if(t.value){if(t.value.canPlayType("application/vnd.apple.mpegurl")){t.value.src=ne;return}try{t.value.src=ne}catch{p.value="Live streaming not supported in this browser",h.value="error"}}}function I(){_.value&&(_.value.destroy(),_.value=null)}function D(){var M;const ne=E.value?t.value:n.value;ne&&(i.value=ne.currentTime,r.value=ne.duration,(M=a.onTimeUpdate)==null||M.call(a,ne.currentTime))}const Z=e.computed(()=>{if(!d.value||d.value.length===0||!r.value)return 0;for(let ne=0;ne<d.value.length;ne++){const M=d.value.start(ne),z=d.value.end(ne);if(i.value>=M&&i.value<=z)return z/r.value*100}return 0});function W(){if(!y.value)return!1;const ne=new Date;return y.value.getTime()-ne.getTime()<5*60*1e3}return e.watch([n,t],([ne,M])=>{const z=E.value?M:ne;z&&(z.addEventListener("timeupdate",D),z.addEventListener("loadedmetadata",()=>{r.value=z.duration,h.value="ready"}),z.addEventListener("progress",()=>{d.value=z.buffered}),z.addEventListener("ended",()=>{var me;o.value=!1,h.value="ended",(me=a.onEnded)==null||me.call(a)}),z.addEventListener("error",me=>{var ae;h.value="error",(ae=a.onError)==null||ae.call(a,"Video playback error")}),z.volume=s.value/100,z.muted=l.value)}),e.onUnmounted(()=>{I();const ne=E.value?t.value:n.value;ne&&ne.removeEventListener("timeupdate",D)}),{videoEl:n,liveVideoEl:t,playing:o,currentTime:i,duration:r,volume:s,muted:l,isFullscreen:c,bufferedRanges:d,bufferedPercent:Z,playbackRate:u,isLoading:m,error:p,status:h,currentPlaybackUrl:v,tokenExpiresAt:y,play:f,pause:x,togglePlayPause:$,seek:N,skipForward:g,skipBackward:S,toggleMute:O,setVolume:k,setPlaybackRate:T,toggleFullscreen:F,togglePiP:A,retry:R,refreshToken:j,setupLiveStream:K,setApiClient:w,shouldRefreshToken:W}}const px=["src","poster","controls","autoplay","muted","loop","preload"],fx={key:1,ref:"livePlayerEl",class:"live-player"},hx=["controls","muted"],vx={key:0,class:"live-indicator","data-testid":"video-live-indicator","aria-label":"Live stream"},gx={key:2,class:"video-loading","data-testid":"video-loading",role:"status","aria-label":"Loading video"},yx={key:3,class:"video-error","data-testid":"video-error",role:"alert"},wx={key:5,class:"gesture-zones","data-testid":"video-gesture-zones"},bx=e.defineComponent({__name:"VideoPlayer",props:{media:{},playbackUrl:{},apiClient:{},isLive:{type:Boolean,default:!1},controls:{type:Boolean,default:!0},autoplay:{type:Boolean,default:!1},muted:{type:Boolean,default:!1},loop:{type:Boolean,default:!1},poster:{},preload:{default:"metadata"},showCustomControls:{type:Boolean,default:!1},enableGestures:{type:Boolean,default:!0},className:{},crossorigin:{}},emits:["play","pause","ended","error","timeupdate","loadedmetadata","progress"],setup(a,{emit:n}){const t=a,o=n,{videoEl:i,liveVideoEl:r,playing:s,currentTime:l,duration:c,volume:d,muted:u,isFullscreen:m,bufferedRanges:p,isLoading:h,error:v,status:y,currentPlaybackUrl:E,tokenExpiresAt:_,play:C,pause:w,seek:f,toggleMute:x,setVolume:$,toggleFullscreen:N,togglePlayPause:g,skipForward:S,skipBackward:O,retry:k,refreshToken:T,setApiClient:F,shouldRefreshToken:A,setupLiveStream:R}=mx({...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 j(){await T()}const K=e.computed(()=>{const ae=["video-player-container"];return t.className&&ae.push(t.className),m.value&&ae.push("fullscreen"),t.isLive&&ae.push("is-live"),s.value&&ae.push("is-playing"),h.value&&ae.push("is-loading"),ae}),I=e.computed(()=>{var ae,Y;if(t.poster)return t.poster;if((ae=t.media)!=null&&ae.poster_url)return t.media.poster_url;if((Y=t.media)!=null&&Y.thumbnail_url)return t.media.thumbnail_url});function D(ae){const Y=ae.target;o("loadedmetadata",{duration:Y.duration,width:Y.videoWidth,height:Y.videoHeight})}function Z(ae){const Y=ae.target;l.value=Y.currentTime,o("timeupdate",Y.currentTime)}function W(){s.value=!0,o("play")}function oe(){s.value=!1,o("pause")}function we(){s.value=!1,o("ended")}function Ce(ae){const Y=ae.target;let Te="Failed to load video";if(Y.error)switch(Y.error.code){case Y.error.MEDIA_ERR_ABORTED:Te="Video playback aborted";break;case Y.error.MEDIA_ERR_NETWORK:Te="Network error while loading video";break;case Y.error.MEDIA_ERR_DECODE:Te="Video decoding error";break;case Y.error.MEDIA_ERR_SRC_NOT_SUPPORTED:Te="Video format not supported";break}v.value=Te,o("error",Te)}function ne(ae){const Y=ae.target;p.value=Y.buffered,o("progress",Y.buffered)}function M(){h.value=!0}function z(){h.value=!1}e.watch(()=>t.apiClient,ae=>{ae&&F(ae)},{immediate:!0}),e.watch(()=>t.playbackUrl,ae=>{typeof ae=="string"&&ae.length>0&&(E.value=ae)},{immediate:!0}),e.watch(()=>{var ae;return(ae=t.media)==null?void 0:ae.token_expires_at},ae=>{if(!ae){_.value=null;return}const Y=new Date(ae);_.value=Number.isNaN(Y.getTime())?null:Y},{immediate:!0}),e.watch(()=>{var ae;return(ae=t.media)==null?void 0:ae.playback_url},async(ae,Y)=>{if(t.playbackUrl||!ae||ae===Y)return;const Te=i.value;if(!Te||t.isLive){E.value=ae;return}const ue=!Te.paused,se=Te.currentTime;E.value=ae,await e.nextTick();try{Te.currentTime=se}catch{}ue&&await C()},{immediate:!0});let me=null;return e.watch(()=>t.isLive,async ae=>{var Te;if(!ae)return;const Y=t.playbackUrl||((Te=t.media)==null?void 0:Te.playback_url)||"";Y&&await R(Y)},{immediate:!0}),e.onMounted(()=>{var ae;(ae=t.media)!=null&&ae.provider&&t.media.provider!=="local"&&(me=setInterval(()=>{A()&&j()},3e4)),B.isPlatform("mobile")&&t.showCustomControls}),e.onUnmounted(()=>{me&&clearInterval(me)}),(ae,Y)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-player-container",K.value]),"data-testid":"video-player"},[ae.isLive?(e.openBlock(),e.createElementBlock("div",fx,[e.createElementVNode("video",{ref_key:"liveVideoEl",ref:r,controls:ae.controls&&!ae.showCustomControls,autoplay:!0,muted:e.unref(u),onPlay:W,onPause:oe,onError:Ce,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,hx),e.unref(y)==="live"?(e.openBlock(),e.createElementBlock("div",vx,[...Y[3]||(Y[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(E),poster:I.value,controls:ae.controls&&!ae.showCustomControls,autoplay:ae.autoplay,muted:e.unref(u),loop:ae.loop,preload:ae.preload,onLoadedmetadata:D,onTimeupdate:Z,onPlay:W,onPause:oe,onEnded:we,onError:Ce,onProgress:ne,onWaiting:M,onCanplay:z,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,px)),e.unref(h)?(e.openBlock(),e.createElementBlock("div",gx,[e.createVNode(e.unref(B.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),e.unref(v)?(e.openBlock(),e.createElementBlock("div",yx,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Wi),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(e.unref(v)),1),e.createVNode(e.unref(B.IonButton),{size:"small",onClick:e.unref(k),"data-testid":"btn-video-retry","aria-label":"Retry loading video"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Un),slot:"start","aria-hidden":"true"},null,8,["icon"]),Y[4]||(Y[4]=e.createTextVNode(" Retry ",-1))]),_:1},8,["onClick"])])):e.createCommentVNode("",!0),ae.showCustomControls&&!e.unref(v)?(e.openBlock(),e.createBlock(ux,{key:4,playing:e.unref(s),currentTime:e.unref(l),duration:e.unref(c),buffered:e.unref(p),volume:e.unref(d),muted:e.unref(u),fullscreen:e.unref(m),isLive:ae.isLive,onPlay:e.unref(C),onPause:e.unref(w),onSeek:e.unref(f),onToggleMute:e.unref(x),onSetVolume:e.unref($),onToggleFullscreen:e.unref(N),class:"custom-controls"},null,8,["playing","currentTime","duration","buffered","volume","muted","fullscreen","isLive","onPlay","onPause","onSeek","onToggleMute","onSetVolume","onToggleFullscreen"])):e.createCommentVNode("",!0),ae.enableGestures&&!e.unref(v)?(e.openBlock(),e.createElementBlock("div",wx,[e.createElementVNode("div",{class:"gesture-left","data-testid":"video-gesture-skip-back","aria-label":"Double tap to skip backward",onDblclick:Y[0]||(Y[0]=(...Te)=>e.unref(O)&&e.unref(O)(...Te))},null,32),e.createElementVNode("div",{class:"gesture-center","data-testid":"video-gesture-play-pause","aria-label":"Tap to play or pause",onClick:Y[1]||(Y[1]=(...Te)=>e.unref(g)&&e.unref(g)(...Te))}),e.createElementVNode("div",{class:"gesture-right","data-testid":"video-gesture-skip-forward","aria-label":"Double tap to skip forward",onDblclick:Y[2]||(Y[2]=(...Te)=>e.unref(S)&&e.unref(S)(...Te))},null,32)])):e.createCommentVNode("",!0)],2))}}),mc=Me(bx,[["__scopeId","data-v-b8db4951"]]),kx=va.defineStore("video",()=>{const a=e.ref(new Map),n=e.ref(new Map),t=e.ref(new Map),o=e.ref(null),i=e.ref(!1),r=e.computed(()=>Array.from(a.value.values())),s=e.computed(()=>Array.from(n.value.values())),l=e.computed(()=>s.value.filter(R=>R.status==="live")),c=e.computed(()=>r.value.filter(R=>R.processing_status==="processing"));function d(R){a.value.set(R.uuid,R)}function u(R,j){const K=a.value.get(R);K&&a.value.set(R,{...K,...j})}function m(R){a.value.delete(R)}function p(R){return a.value.get(R)}function h(R){n.value.set(R.id,R)}function v(R,j){const K=n.value.get(R);K&&n.value.set(R,{...K,...j})}function y(R,j){const K=n.value.get(R);K&&n.value.set(R,{...K,status:j.status,viewer_count:j.viewer_count,peak_viewers:j.peak_viewers})}function E(R){n.value.delete(R)}function _(R){return n.value.get(R)}function C(R){return s.value.find(j=>j.media_uuid===R)}function w(R){t.value.set(R.id,R)}function f(R,j){const K=t.value.get(R);K&&t.value.set(R,{...K,...j})}function x(R){t.value.delete(R)}function $(R){return t.value.get(R)}function N(R){return Array.from(t.value.values()).filter(j=>j.media_uuid===R)}function g(R){o.value=R}function S(R){o.value&&(o.value={...o.value,...R})}function O(){o.value=null}function k(R){i.value=R}function T(){a.value.clear(),n.value.clear(),t.value.clear(),o.value=null,i.value=!1}function F(R){a.value.clear(),R.forEach(j=>{a.value.set(j.uuid,j)})}function A(R){n.value.clear(),R.forEach(j=>{n.value.set(j.id,j)})}return{videos:a,liveStreams:n,exportJobs:t,currentEditorState:o,isProcessing:i,allVideos:r,allLiveStreams:s,activeLiveStreams:l,processingVideos:c,setVideo:d,updateVideo:u,removeVideo:m,getVideo:p,setLiveStream:h,updateLiveStream:v,updateLiveStreamStats:y,removeLiveStream:E,getLiveStream:_,getLiveStreamByMedia:C,addExportJob:w,updateExportJob:f,removeExportJob:x,getExportJob:$,getExportJobsByMedia:N,setEditorState:g,updateEditorState:S,clearEditorState:O,setProcessing:k,clearAll:T,loadVideos:F,loadLiveStreams:A}});let mn=null;function xx(a){mn=a}const jo={post:async(a,n)=>{if(!mn)throw new Error("HTTP client not configured");return await mn(`/api/v1/video${a}`,{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json"}})},get:async a=>{if(!mn)throw new Error("HTTP client not configured");return await mn(`/api/v1/video${a}`)},delete:async a=>{if(!mn)throw new Error("HTTP client not configured");return await mn(`/api/v1/video${a}`,{method:"DELETE"})}};function Wo(a,n=null){const t=typeof a.id=="string"&&a.id!==""?a.id:typeof a.stream_id=="string"&&a.stream_id!==""?a.stream_id:n==null?void 0:n.id;if(!t)throw new Error("Invalid live stream response: missing stream id");const o={id:t,media_uuid:a.media_uuid??(n==null?void 0:n.media_uuid)??"",stream_key:a.stream_key??(n==null?void 0:n.stream_key)??"",rtmp_url:a.rtmp_url??(n==null?void 0:n.rtmp_url)??"",status:a.status??(n==null?void 0:n.status)??"idle",viewer_count:a.viewer_count??(n==null?void 0:n.viewer_count)??0,peak_viewers:a.peak_viewers??(n==null?void 0:n.peak_viewers)??0,auto_record:a.auto_record??(n==null?void 0:n.auto_record)??!0,low_latency:a.low_latency??(n==null?void 0:n.low_latency)??!1},i=a.playback_url??(n==null?void 0:n.playback_url);i!==void 0&&(o.playback_url=i);const r=a.started_at??(n==null?void 0:n.started_at);r!==void 0&&(o.started_at=r);const s=a.ended_at??(n==null?void 0:n.ended_at);return s!==void 0&&(o.ended_at=s),(n==null?void 0:n.metadata)!==void 0&&(o.metadata=n.metadata),(n==null?void 0:n.vod_media_uuid)!==void 0&&(o.vod_media_uuid=n.vod_media_uuid),o}function hi(a,n){return a instanceof Error&&a.message?a.message:n}function Ex(a){const n=kx(),t=e.ref(null),o=e.ref(!1),i=e.ref(!0),r=e.ref(""),s=e.ref(!1),l=e.ref(!1),c=e.ref(null),d=e.ref(null),u=e.ref(0),m=e.ref(0);let p;const h=e.computed(()=>d.value?Math.floor((new Date().getTime()-d.value.getTime())/1e3):0),v=e.computed(()=>{var O;if(!((O=t.value)!=null&&O.playback_url))return null;const S=new URL(t.value.playback_url);return S.searchParams.set("live","true"),o.value&&S.searchParams.set("latency","low"),S.toString()}),y=e.computed(()=>{var S;return((S=t.value)==null?void 0:S.status)==="live"}),E=e.computed(()=>{var S;return((S=t.value)==null?void 0:S.status)==="idle"}),_=e.computed(()=>{var S;return((S=t.value)==null?void 0:S.status)==="ended"});async function C(S={}){s.value=!0,c.value=null;try{const O=await jo.post("/live",{title:r.value||S.title||"Live Stream",low_latency:S.low_latency??o.value,auto_record:S.auto_record??i.value,...S}),k=Wo(O);return t.value=k,n.setLiveStream(k),$(),k}catch(O){throw c.value=hi(O,"Failed to create stream"),O instanceof Error?O:new Error(c.value)}finally{s.value=!1}}async function w(){if(!t.value)throw new Error("No active stream");l.value=!0,c.value=null;try{const S=await jo.post(`/live/${t.value.id}/end`),O=Wo(S,t.value);return t.value=O,n.setLiveStream(O),N(),O}catch(S){throw c.value=hi(S,"Failed to end stream"),S instanceof Error?S:new Error(c.value)}finally{l.value=!1}}async function f(){if(t.value)try{const S=await jo.get(`/live/${t.value.id}`),O=Wo(S,t.value);u.value=O.viewer_count,m.value=O.peak_viewers,t.value=O;const k={status:O.status,viewer_count:O.viewer_count,peak_viewers:O.peak_viewers};O.started_at&&(k.started_at=O.started_at),O.ended_at&&(k.ended_at=O.ended_at),n.updateLiveStreamStats(O.id,k),O.status==="live"&&!d.value&&O.started_at&&(d.value=new Date(O.started_at)),O.status==="ended"&&N()}catch{}}async function x(S){try{const O=await jo.get(`/live/${S}`),k=Wo(O,t.value);return{rtmp_url:k.rtmp_url,stream_key:k.stream_key,playback_url:k.playback_url||""}}catch(O){throw c.value=hi(O,"Failed to get stream credentials"),O instanceof Error?O:new Error(c.value)}}function $(S=5e3){N(),p=window.setInterval(()=>{f()},S)}function N(){p!==void 0&&(clearInterval(p),p=void 0)}async function g(){if(!a)return;const S=n.getLiveStreamByMedia(a);S&&(t.value=S,u.value=S.viewer_count,m.value=S.peak_viewers,S.status==="live"&&($(),S.started_at&&(d.value=new Date(S.started_at))))}return a&&g(),e.onUnmounted(()=>{N()}),{stream:t,lowLatency:o,autoRecord:i,streamTitle:r,isCreating:s,isEnding:l,error:c,streamDuration:h,viewerCount:u,peakViewers:m,playbackUrl:v,isLive:y,isIdle:E,hasEnded:_,createStream:C,endStream:w,refreshStreamStatus:f,getStreamCredentials:x,startStatusPolling:$,stopStatusPolling:N}}const Vx={class:"stream-status"},Sx={class:"flex items-center justify-between"},Cx={class:"flex items-center gap-3"},Nx={key:0,class:"flex items-center"},_x={key:2,class:"text-sm text-gray-600"},Tx={key:0,class:"flex items-center gap-2"},Mx={class:"text-sm font-medium text-gray-700"},Bx={key:0,class:"text-xs text-gray-500"},Ix=e.defineComponent({__name:"StreamStatus",props:{status:{},viewers:{},peakViewers:{},duration:{}},setup(a){const n=a,t=e.computed(()=>({idle:"Ready to Stream",live:"Live",ended:"Stream Ended",error:"Error"})[n.status]||n.status),o=e.computed(()=>{const r="px-3 py-1 rounded-full text-xs font-semibold uppercase",s={idle:"bg-gray-100 text-gray-700",live:"bg-red-100 text-red-700",ended:"bg-blue-100 text-blue-700",error:"bg-yellow-100 text-yellow-700"};return`${r} ${s[n.status]||s.idle}`}),i=e.computed(()=>{if(!n.duration)return null;const r=Math.floor(n.duration/3600),s=Math.floor(n.duration%3600/60),l=n.duration%60;return r>0?`${r}:${s.toString().padStart(2,"0")}:${l.toString().padStart(2,"0")}`:`${s}:${l.toString().padStart(2,"0")}`});return(r,s)=>(e.openBlock(),e.createElementBlock("div",Vx,[e.createElementVNode("div",Sx,[e.createElementVNode("div",Cx,[r.status==="live"?(e.openBlock(),e.createElementBlock("div",Nx,[...s[0]||(s[0]=[e.createElementVNode("span",{class:"relative flex h-3 w-3"},[e.createElementVNode("span",{class:"animate-ping absolute inline-flex h-full w-full rounded-full bg-red-400 opacity-75"}),e.createElementVNode("span",{class:"relative inline-flex rounded-full h-3 w-3 bg-red-500"})],-1),e.createElementVNode("span",{class:"ml-2 text-sm font-semibold text-red-600 uppercase"},"Live",-1)])])):(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(o.value)},e.toDisplayString(t.value),3)),i.value?(e.openBlock(),e.createElementBlock("div",_x,e.toDisplayString(i.value),1)):e.createCommentVNode("",!0)]),r.viewers!==void 0?(e.openBlock(),e.createElementBlock("div",Tx,[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",Mx,e.toDisplayString(r.viewers)+" "+e.toDisplayString(r.viewers===1?"viewer":"viewers"),1),r.peakViewers>r.viewers?(e.openBlock(),e.createElementBlock("span",Bx," (Peak: "+e.toDisplayString(r.peakViewers)+") ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])]))}}),Fx=Me(Ix,[["__scopeId","data-v-1d09c19f"]]),Rx={class:"stream-credentials"},$x={class:"space-y-3"},Dx={class:"credential-field"},Ux={class:"flex gap-2"},Ox=["value"],Ax={class:"credential-field"},Lx={class:"flex gap-2"},zx=["value","type"],Px=["aria-label"],jx={key:0,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Wx={key:1,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Zx={key:0,class:"mt-2 text-sm text-green-600"},Xx=e.defineComponent({__name:"StreamCredentials",props:{rtmpUrl:{},streamKey:{}},emits:["copy"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(!1),r=e.ref(""),s=e.computed(()=>{if(i.value)return t.streamKey;if(t.streamKey.length>8){const d=t.streamKey.slice(0,4),u=t.streamKey.slice(-4);return`${d}${"•".repeat(16)}${u}`}return"•".repeat(t.streamKey.length)});function l(){i.value=!i.value}async function c(d,u){try{await navigator.clipboard.writeText(d),r.value=u,o("copy",d,u),setTimeout(()=>{r.value=""},2e3)}catch{}}return(d,u)=>(e.openBlock(),e.createElementBlock("div",Rx,[u[8]||(u[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Stream Settings",-1)),e.createElementVNode("div",$x,[e.createElementVNode("div",Dx,[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",Ux,[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,Ox),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",Ax,[u[7]||(u[7]=e.createElementVNode("label",{class:"block text-xs font-medium text-gray-500 mb-1"},"Stream Key",-1)),e.createElementVNode("div",Lx,[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,zx),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",Wx,[...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",jx,[...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,Px),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",Zx,e.toDisplayString(r.value)+" copied to clipboard! ",1)):e.createCommentVNode("",!0)]),_:1})]))}}),Hx=Me(Xx,[["__scopeId","data-v-306d92f6"]]),Gx={class:"live-stream-manager","data-testid":"live-stream-manager"},Jx={key:0,class:"stream-setup"},Yx={class:"space-y-4"},Kx={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},qx={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},Qx=["disabled"],eE={key:0},tE={key:1,class:"flex items-center justify-center"},nE={key:1,class:"stream-active space-y-6"},oE={key:1,class:"video-preview"},aE={key:2,class:"analytics-panel"},iE={class:"grid grid-cols-2 gap-4"},rE={class:"bg-gray-50 p-3 rounded"},sE={class:"text-2xl font-bold text-gray-900"},lE={class:"bg-gray-50 p-3 rounded"},cE={class:"text-2xl font-bold text-gray-900"},dE={class:"stream-controls flex gap-3"},uE=["disabled"],mE={key:0},pE={key:1},fE={key:2,class:"mt-4 p-4 bg-red-50 border border-red-200 rounded-lg"},hE={class:"text-red-600 text-sm"},vE=e.defineComponent({__name:"LiveStreamManager",props:{mediaUuid:{},onStreamCreated:{type:Function},onStreamEnded:{type:Function},httpClient:{type:Function}},emits:["stream-created","stream-ended","error"],setup(a,{emit:n}){const t=a,o=n;t.httpClient&&xx(t.httpClient);const{stream:i,lowLatency:r,autoRecord:s,streamTitle:l,isCreating:c,isEnding:d,error:u,createStream:m,endStream:p,streamDuration:h,playbackUrl:v,refreshStreamStatus:y}=Ex(t.mediaUuid),E=e.ref(!1);async function _(){var $;try{const N=await m({title:l.value,low_latency:r.value,auto_record:s.value});o("stream-created",N),($=t.onStreamCreated)==null||$.call(t,N)}catch(N){o("error",N)}}async function C(){var $;try{const N=await p();o("stream-ended",N),($=t.onStreamEnded)==null||$.call(t,N)}catch(N){o("error",N)}}function w(){i.value=null,l.value="",E.value=!1,u.value=null}async function f($,N){try{await navigator.clipboard.writeText($)}catch{}}let x;return e.onMounted(()=>{var $;(($=i.value)==null?void 0:$.status)==="live"&&(x=window.setInterval(()=>{y()},5e3))}),e.onUnmounted(()=>{x&&clearInterval(x)}),($,N)=>(e.openBlock(),e.createElementBlock("div",Gx,[e.unref(i)?(e.openBlock(),e.createElementBlock("div",nE,[e.createVNode(Fx,{status:e.unref(i).status,viewers:e.unref(i).viewer_count,duration:e.unref(h),"peak-viewers":e.unref(i).peak_viewers},null,8,["status","viewers","duration","peak-viewers"]),e.unref(i).status==="idle"?(e.openBlock(),e.createBlock(Hx,{key:0,"rtmp-url":e.unref(i).rtmp_url,"stream-key":e.unref(i).stream_key,onCopy:f},null,8,["rtmp-url","stream-key"])):e.createCommentVNode("",!0),e.unref(v)?(e.openBlock(),e.createElementBlock("div",oE,[N[9]||(N[9]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-2"},"Live Preview",-1)),e.createVNode(mc,{"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",aE,[N[12]||(N[12]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Live Analytics",-1)),e.createElementVNode("div",iE,[e.createElementVNode("div",rE,[e.createElementVNode("div",sE,e.toDisplayString(e.unref(i).viewer_count),1),N[10]||(N[10]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Current Viewers",-1))]),e.createElementVNode("div",lE,[e.createElementVNode("div",cE,e.toDisplayString(e.unref(i).peak_viewers),1),N[11]||(N[11]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Peak Viewers",-1))])])])):e.createCommentVNode("",!0),e.createElementVNode("div",dE,[e.unref(i).status==="idle"?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:N[3]||(N[3]=g=>E.value=!E.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(E.value?"Hide":"Show")+" Credentials ",1)):e.createCommentVNode("",!0),e.unref(i).status==="live"?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:C,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",pE,"Ending...")):(e.openBlock(),e.createElementBlock("span",mE,"End Stream"))],8,uE)):e.createCommentVNode("",!0),e.unref(i).status==="ended"?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:w,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",Jx,[N[8]||(N[8]=e.createElementVNode("h3",{class:"text-lg font-semibold mb-4"},"Start Live Stream",-1)),e.createElementVNode("div",Yx,[e.createElementVNode("div",Kx,[N[4]||(N[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":N[0]||(N[0]=g=>e.isRef(r)?r.value=g: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",qx,[N[5]||(N[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":N[1]||(N[1]=g=>e.isRef(s)?s.value=g: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,[N[6]||(N[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":N[2]||(N[2]=g=>e.isRef(l)?l.value=g:null),type:"text",class:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"My Live Stream"},null,512),[[e.vModelText,e.unref(l)]])]),e.createElementVNode("button",{onClick:_,disabled:e.unref(c),class:"w-full py-3 px-4 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors","data-testid":"create-stream-button","aria-label":"Create live stream"},[e.unref(c)?(e.openBlock(),e.createElementBlock("span",tE,[...N[7]||(N[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",eE,"Create Stream"))],8,Qx)])])),e.unref(u)?(e.openBlock(),e.createElementBlock("div",fE,[e.createElementVNode("p",hE,e.toDisplayString(e.unref(u)),1)])):e.createCommentVNode("",!0)]))}}),gE=Me(vE,[["__scopeId","data-v-26291f6f"]]),yE={class:"album-tree-node"},wE=["data-album-id","draggable","aria-selected","aria-expanded"],bE={key:1,class:"album-node__chevron-placeholder"},kE={key:2,"data-testid":"media-count",class:"album-node__count"},xE={key:0,class:"album-tree-node__children",role:"group"},EE=16,VE=e.defineComponent({__name:"AlbumTreeNode",props:{album:{},depth:{},selectedId:{},expandedIds:{},focusedId:{},draggable:{type:Boolean},showMediaCount:{type:Boolean},compact:{type:Boolean},dragState:{}},emits:["select","toggle-expand","drag-start","drag-over","drag-leave","drop"],setup(a,{emit:n}){const t=a,o=n,i=e.computed(()=>t.expandedIds.has(t.album.id)),r=e.computed(()=>t.selectedId===t.album.id),s=e.computed(()=>t.focusedId===t.album.id),l=e.computed(()=>t.album.children_count>0),c=e.computed(()=>`${t.depth*EE}px`),d=e.computed(()=>{var w;return((w=t.dragState)==null?void 0:w.draggedAlbumId)===t.album.id}),u=e.computed(()=>{var w;return((w=t.dragState)==null?void 0:w.dropTargetId)===t.album.id}),m=e.computed(()=>{var w;return(w=t.dragState)!=null&&w.draggedAlbumId?t.dragState.draggedAlbumId===t.album.id:!1}),p=e.computed(()=>{const w=["album-node"];return r.value&&w.push("album-node--selected"),s.value&&w.push("album-node--focused"),t.compact&&w.push("album-node--compact"),d.value&&w.push("album-node--dragging"),u.value&&w.push("album-node--drop-target"),m.value&&w.push("album-node--invalid-drop"),w});function h(){o("select",t.album)}function v(w){w.stopPropagation(),o("toggle-expand",t.album.id)}function y(w){t.draggable&&(w.dataTransfer&&(w.dataTransfer.setData("text/plain",t.album.id),w.dataTransfer.effectAllowed="move"),o("drag-start",t.album.id))}function E(w){t.draggable&&(w.preventDefault(),w.dataTransfer&&(w.dataTransfer.dropEffect="move"),o("drag-over",t.album.id))}function _(){o("drag-leave",t.album.id)}function C(w){t.draggable&&(w.preventDefault(),o("drop",t.album.id))}return(w,f)=>{var $;const x=e.resolveComponent("AlbumTreeNode",!0);return e.openBlock(),e.createElementBlock("div",yE,[e.createElementVNode("div",{"data-testid":"album-node","data-album-id":w.album.id,class:e.normalizeClass(p.value),style:e.normalizeStyle({paddingLeft:c.value}),draggable:w.draggable,role:"treeitem","aria-selected":r.value,"aria-expanded":l.value?i.value:void 0,onDragstart:y,onDragover:E,onDragleave:_,onDrop:C},[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(B.IonIcon),{icon:i.value?e.unref(tu):e.unref(nu)},null,8,["icon"])])):(e.openBlock(),e.createElementBlock("span",bE)),e.createVNode(e.unref(B.IonIcon),{icon:e.unref(du),class:"album-node__icon"},null,8,["icon"]),e.createElementVNode("span",{"data-testid":"album-name",class:"album-node__name",onClick:h},e.toDisplayString(w.album.name),1),w.showMediaCount?(e.openBlock(),e.createElementBlock("span",kE,e.toDisplayString(w.album.media_count),1)):e.createCommentVNode("",!0)],46,wE),i.value&&(($=w.album.children)!=null&&$.length)?(e.openBlock(),e.createElementBlock("div",xE,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.album.children,N=>(e.openBlock(),e.createBlock(x,{key:N.id,album:N,depth:w.depth+1,"selected-id":w.selectedId,"expanded-ids":w.expandedIds,"focused-id":w.focusedId,draggable:w.draggable,"show-media-count":w.showMediaCount,compact:w.compact,onSelect:f[0]||(f[0]=g=>o("select",g)),onToggleExpand:f[1]||(f[1]=g=>o("toggle-expand",g))},null,8,["album","depth","selected-id","expanded-ids","focused-id","draggable","show-media-count","compact"]))),128))])):e.createCommentVNode("",!0)])}}}),SE=Me(VE,[["__scopeId","data-v-76be65a6"]]),La=va.defineStore("albums",()=>{const a=e.ref([]),n=e.ref(new Map),t=e.ref(!1),o=e.ref(null),i=e.ref(new Set),r=e.computed(()=>{const f=new Map;return a.value.forEach(x=>f.set(x.id,x)),f}),s=e.computed(()=>a.value.filter(f=>f.parent_id===null));async function l(f){t.value=!0,o.value=null;try{const x=(f==null?void 0:f.parent_id)??null,$=x?`/api/v1/albums?parent_id=${x}`:"/api/v1/albums?parent_id=null",N=await fetch($);if(!N.ok)throw new Error("Failed to fetch albums");((await N.json()).data||[]).forEach(O=>{const k=a.value.findIndex(T=>T.id===O.id);k>=0?a.value[k]=O:a.value.push(O)}),x!==null&&i.value.add(x)}catch(x){o.value=x instanceof Error?x.message:"Unknown error"}finally{t.value=!1}}async function c(f){t.value=!0,o.value=null;try{const x=await fetch(`/api/v1/albums/${f}`);if(!x.ok)throw new Error("Failed to fetch album");const N=(await x.json()).data,g=a.value.findIndex(S=>S.id===N.id);return g>=0?a.value[g]=N:a.value.push(N),N}catch(x){throw o.value=x instanceof Error?x.message:"Unknown error",x}finally{t.value=!1}}async function d(f){t.value=!0,o.value=null;try{const x=await fetch(`/api/v1/albums/${f}/media`);if(!x.ok)throw new Error("Failed to fetch album media");const N=(await x.json()).data||[];return n.value.set(f,N),N}catch(x){throw o.value=x instanceof Error?x.message:"Unknown error",x}finally{t.value=!1}}async function u(f,x){t.value=!0,o.value=null;try{if(!(await fetch(`/api/v1/albums/${f}/media/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({media_ids:x})})).ok)throw new Error("Failed to reorder album media");const N=n.value.get(f)||[],g=x.map(S=>N.find(O=>O.uuid===S)).filter(S=>S!==void 0);n.value.set(f,g)}catch($){throw o.value=$ instanceof Error?$.message:"Unknown error",$}finally{t.value=!1}}async function m(f){t.value=!0,o.value=null;try{const x=await fetch("/api/v1/albums",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(f)});if(!x.ok)throw new Error("Failed to create album");const N=(await x.json()).data;return a.value.push(N),N}catch(x){throw o.value=x instanceof Error?x.message:"Unknown error",x}finally{t.value=!1}}async function p(f,x){t.value=!0,o.value=null;try{const $=await fetch(`/api/v1/albums/${f}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(x)});if(!$.ok)throw new Error("Failed to update album");const g=(await $.json()).data,S=a.value.findIndex(O=>O.id===g.id);return S>=0&&(a.value[S]=g),g}catch($){throw o.value=$ instanceof Error?$.message:"Unknown error",$}finally{t.value=!1}}async function h(f){t.value=!0,o.value=null;try{if(!(await fetch(`/api/v1/albums/${f}`,{method:"DELETE",headers:{"Content-Type":"application/json"},credentials:"include"})).ok)throw new Error("Failed to delete album");const $=a.value.findIndex(N=>N.id===f);$>=0&&a.value.splice($,1),n.value.delete(f)}catch(x){throw o.value=x instanceof Error?x.message:"Unknown error",x}finally{t.value=!1}}function v(f){return a.value.filter(x=>x.parent_id===f)}function y(f){return i.value.has(f)}function E(f){return n.value.get(f)||[]}async function _(f,x){const $=a.value.findIndex(g=>g.id===f);if($<0)return;const N=a.value[$];a.value[$]={...N,parent_id:x};try{if(!(await fetch(`/api/v1/albums/${f}/move`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({parent_id:x})})).ok)throw new Error("Failed to move album")}catch(g){throw a.value[$]=N,o.value=g instanceof Error?g.message:"Unknown error",g instanceof Error?g:new Error("Failed to move album")}}function C(f){a.value=f}function w(){a.value=[],n.value.clear(),t.value=!1,o.value=null,i.value.clear()}return{albums:a,albumMedia:n,loading:t,error:o,childrenLoadedById:i,albumsById:r,rootAlbums:s,fetchAlbums:l,fetchAlbum:c,fetchAlbumMedia:d,reorderAlbumMedia:u,createAlbum:m,updateAlbum:p,deleteAlbum:h,getChildrenOf:v,childrenLoaded:y,getAlbumMedia:E,moveAlbum:_,setAlbums:C,reset:w}});function pc(){const a=La(),{albums:n,albumsById:t,rootAlbums:o,loading:i,error:r}=va.storeToRefs(a);async function s(u){await a.fetchAlbums(u)}function l(u){return a.getChildrenOf(u)}function c(u){return a.childrenLoaded(u)}async function d(u,m){await a.moveAlbum(u,m)}return{albums:n,albumsById:t,rootAlbums:o,loading:i,error:r,fetchAlbums:s,getChildrenOf:l,childrenLoaded:c,moveAlbum:d}}function fc(a){const{childrenByParentId:n,onMove:t}=a,o=e.ref({isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null});function i(m,p){if(m===p)return!0;const h=new Set,v=[m];for(;v.length>0;){const y=v.shift();if(!y||h.has(y))continue;h.add(y);const E=n.get(y)||[];for(const _ of E){if(_===p)return!0;v.push(_)}}return!1}function r(m,p){return m===p?!1:p===null?!0:!i(m,p)}function s(m){o.value={isDragging:!0,draggedAlbumId:m,dropTargetId:null,dropPosition:null}}function l(){o.value={isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null}}function c(m){o.value.dropTargetId=m}function d(){o.value.dropTargetId=null,o.value.dropPosition=null}async function u(){const{draggedAlbumId:m,dropTargetId:p}=o.value;if(!m){l();return}if(!r(m,p)){l();return}try{await t(m,p)}finally{l()}}return{dragState:o,isDescendant:i,canDropOn:r,startDrag:s,endDrag:l,setDropTarget:c,clearDropTarget:d,executeDrop:u}}const CE={key:0,"data-testid":"loading-spinner",class:"album-tree__loading"},NE={key:1,"data-testid":"error-state",class:"album-tree__error"},_E={key:2,"data-testid":"empty-state",class:"album-tree__empty"},TE={key:3,class:"album-tree__content",role:"group"},ME=e.defineComponent({__name:"AlbumTree",props:{modelValue:{default:null},expandedIds:{default:()=>[]},draggable:{type:Boolean,default:!0},showMediaCount:{type:Boolean,default:!0},compact:{type:Boolean,default:!1}},emits:["update:modelValue","album-selected","album-moved","album-expanded","album-collapsed"],setup(a,{expose:n,emit:t}){const o=a,i=t,r=e.computed(()=>o.draggable===!0),s=e.computed(()=>o.showMediaCount===!0),l=e.computed(()=>o.compact===!0),{albums:c,rootAlbums:d,loading:u,error:m,fetchAlbums:p,getChildrenOf:h,childrenLoaded:v,moveAlbum:y}=pc(),E=e.shallowRef(new Set(o.expandedIds)),_=e.ref(o.modelValue??null),C=e.ref(null),w=new Map,f=new Map;function x(M){w.clear(),f.clear();for(const z of M){w.set(z.id,z);const me=z.parent_id??null,ae=f.get(me)??[];ae.push(z.id),f.set(me,ae)}}e.watch(c,M=>{x(M)},{immediate:!0});const{dragState:$,canDropOn:N,startDrag:g,endDrag:S,setDropTarget:O,clearDropTarget:k,executeDrop:T}=fc({childrenByParentId:f,onMove:async(M,z)=>{await y(M,z),i("album-moved",{albumId:M,newParentId:z})}});e.watch(()=>o.modelValue,M=>{_.value=M??null}),e.watch(()=>o.expandedIds,M=>{E.value=new Set(M)}),e.onMounted(async()=>{await p({parent_id:null})});const F=e.computed(()=>d.value.map(M=>A(M)));function A(M){if(!E.value.has(M.id))return M;const z=h(M.id);return{...M,children:z.map(me=>A(me))}}const R=e.computed(()=>{const M=[];function z(me){var ae;for(const Y of me)M.push(Y),E.value.has(Y.id)&&((ae=Y.children)!=null&&ae.length)&&z(Y.children)}return z(F.value),M});function j(M){var ae;if(!R.value.length)return;const z=C.value?R.value.findIndex(Y=>Y.id===C.value):-1,me=z>=0?R.value[z]:null;switch(M.key){case"ArrowDown":M.preventDefault(),z<R.value.length-1?C.value=R.value[z+1].id:z===-1&&R.value.length>0&&(C.value=R.value[0].id);break;case"ArrowUp":M.preventDefault(),z>0&&(C.value=R.value[z-1].id);break;case"ArrowRight":M.preventDefault(),me&&(me.children_count>0&&!E.value.has(me.id)?K(me.id):E.value.has(me.id)&&((ae=me.children)!=null&&ae.length)&&(C.value=me.children[0].id));break;case"ArrowLeft":M.preventDefault(),me&&(E.value.has(me.id)&&me.children_count>0?K(me.id):me.parent_id&&(C.value=me.parent_id));break;case"Enter":case" ":M.preventDefault(),me&&I(me);break;case"Home":M.preventDefault(),R.value.length>0&&(C.value=R.value[0].id);break;case"End":M.preventDefault(),R.value.length>0&&(C.value=R.value[R.value.length-1].id);break}}async function K(M){E.value.has(M)?(E.value.delete(M),i("album-collapsed",M)):(v(M)||await p({parent_id:M}),E.value.add(M),i("album-expanded",M))}function I(M){_.value=M.id,i("update:modelValue",M.id),i("album-selected",M)}function D(M){o.draggable&&g(M)}function Z(M){var me;if(!o.draggable)return;const z=(me=$.value)==null?void 0:me.draggedAlbumId;z&&(O(M),N(z,M))}function W(){o.draggable&&k()}async function oe(M){o.draggable&&(O(M),await T())}function we(M){o.draggable&&(M.preventDefault(),O(null))}async function Ce(M){o.draggable&&(M.preventDefault(),O(null),await T())}function ne(){S()}return n({focusedId:C}),(M,z)=>(e.openBlock(),e.createElementBlock("div",{class:"album-tree","data-testid":"album-tree",tabindex:"0",role:"tree","aria-label":"Album tree",onKeydown:j,onDragover:we,onDrop:Ce,onDragend:ne},[e.unref(u)?(e.openBlock(),e.createElementBlock("div",CE,[e.createVNode(e.unref(B.IonSpinner),{name:"crescent"})])):e.unref(m)?(e.openBlock(),e.createElementBlock("div",NE,[e.createElementVNode("p",null,e.toDisplayString(e.unref(m)),1)])):e.unref(d).length?(e.openBlock(),e.createElementBlock("div",TE,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(F.value,me=>(e.openBlock(),e.createBlock(SE,{key:me.id,album:me,depth:0,"selected-id":_.value,"expanded-ids":E.value,"focused-id":C.value,draggable:r.value,"drag-state":r.value?e.unref($):null,"show-media-count":s.value,compact:l.value,onSelect:I,onToggleExpand:K,onDragStart:D,onDragOver:Z,onDragLeave:W,onDrop:oe},null,8,["album","selected-id","expanded-ids","focused-id","draggable","drag-state","show-media-count","compact"]))),128))])):(e.openBlock(),e.createElementBlock("div",_E,[z[0]||(z[0]=e.createElementVNode("p",null,"No albums yet",-1)),e.renderSlot(M.$slots,"empty-action",{},void 0,!0)]))],32))}}),hc=Me(ME,[["__scopeId","data-v-ae3dea7a"]]),BE=300,IE=e.defineComponent({__name:"AlbumBrowser",props:{isOpen:{type:Boolean},selectedAlbumId:{default:null},title:{default:"Select Album"},confirmText:{default:"Select"}},emits:["close","confirm"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(t.selectedAlbumId??null),r=e.ref(null),s=e.ref(0),l=e.ref(null);e.watch(()=>t.selectedAlbumId,h=>{i.value=h??null});const c=e.computed(()=>r.value!==null);function d(h){const v=Date.now();if(l.value===h.id&&v-s.value<BE){o("confirm",h);return}s.value=v,l.value=h.id,i.value=h.id,r.value=h}function u(){r.value&&o("confirm",r.value)}function m(){o("close")}function p(){o("close")}return(h,v)=>(e.openBlock(),e.createBlock(e.unref(B.IonModal),{"is-open":h.isOpen,class:"album-browser-modal",onDidDismiss:p},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(h.title),1)]),_:1}),e.createVNode(e.unref(B.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.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(B.IonContent),{class:"album-browser-content"},{default:e.withCtx(()=>[e.createVNode(hc,{modelValue:i.value,"onUpdate:modelValue":v[0]||(v[0]=y=>i.value=y),draggable:!1,"show-media-count":!0,compact:!1,onAlbumSelected:d},null,8,["modelValue"])]),_:1}),e.createVNode(e.unref(B.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonButton),{fill:"clear",onClick:m},{default:e.withCtx(()=>[...v[2]||(v[2]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(B.IonButton),{"data-testid":"confirm-button",fill:"solid",color:"primary",disabled:!c.value,onClick:u},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(h.confirmText),1)]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"]))}}),vc=Me(IE,[["__scopeId","data-v-21676ec1"]]),FE={class:"ion-padding-start text-sm"},RE={class:"ion-padding-start text-sm"},$E={key:1},DE={key:1,class:"album-manager-inline rounded-lg border border-gray-200 bg-white p-4"},UE={class:"flex items-center justify-between gap-3 pb-3"},OE={class:"text-base font-semibold text-gray-900"},AE={class:"ion-padding-start text-sm"},LE={class:"ion-padding-start text-sm"},zE={class:"flex justify-between pt-2"},PE={key:1},qn=255,Qn=1e3,jE=e.defineComponent({__name:"AlbumManager",props:{albumId:{default:null},parentId:{default:null},mode:{default:"inline"},isOpen:{type:Boolean,default:!1}},emits:["close","created","updated","deleted","error"],setup(a,{emit:n}){const t=a,o=n,i=La(),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),p=e.ref(null),h=e.ref(!1),v=e.ref(!1),y=e.computed(()=>d.value.name?c.value.name.trim()?c.value.name.length>qn?`Name must be ${qn} characters or less`:null:"Name is required":null),E=e.computed(()=>d.value.description&&c.value.description.length>Qn?`Description must be ${Qn} characters or less`:null),_=e.computed(()=>{const j=c.value.name.trim().length>0,K=c.value.name.length<=qn,I=c.value.description.length<=Qn;return j&&K&&I&&!h.value}),C=e.computed(()=>{var j;return((j=u.value)==null?void 0:j.name)??"None (Root)"}),w=e.computed(()=>p.value?p.value.children_count===0&&p.value.media_count===0:!1),f=e.computed(()=>p.value?p.value.children_count>0?"Cannot delete album with child albums. Move or delete children first.":p.value.media_count>0?"Cannot delete album with media. Remove media first.":`Are you sure you want to delete "${p.value.name}"? This action cannot be undone.`:"");e.onMounted(async()=>{t.albumId&&await x()});async function x(){if(t.albumId)try{const j=await i.fetchAlbum(t.albumId);p.value=j,c.value={name:j.name,description:j.description??"",parent_id:j.parent_id},j.parent_id&&(u.value={id:j.parent_id,name:"Parent Album"})}catch(j){o("error",j)}}function $(){d.value.name=!0}function N(){d.value.description=!0}function g(){m.value=!0}function S(j){u.value={id:j.id,name:j.name},c.value.parent_id=j.id,m.value=!1}function O(){m.value=!1}function k(){o("close")}function T(){o("close")}async function F(){if(d.value.name=!0,d.value.description=!0,!(!_.value||h.value)){h.value=!0;try{const j={name:c.value.name.trim(),description:c.value.description.trim(),parent_id:c.value.parent_id};if(r.value&&t.albumId){const K=await i.updateAlbum(t.albumId,j);o("updated",K)}else{const K=await i.createAlbum(j);o("created",K)}o("close")}catch(j){o("error",j)}finally{h.value=!1}}}function A(){w.value&&(v.value=!0)}async function R(j){var I;if((((I=j.detail)==null?void 0:I.role)??"")!=="confirm"){v.value=!1;return}if(t.albumId){h.value=!0;try{await i.deleteAlbum(t.albumId),o("deleted",t.albumId),o("close")}catch(D){o("error",D)}finally{h.value=!1,v.value=!1}}}return(j,K)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[j.mode==="modal"?(e.openBlock(),e.createBlock(e.unref(B.IonModal),{key:0,"is-open":j.isOpen,class:"album-manager-modal",onDidDismiss:T},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.value),1)]),_:1}),e.createVNode(e.unref(B.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:k},{default:e.withCtx(()=>[...K[4]||(K[4]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(B.IonContent),{class:"album-manager-content"},{default:e.withCtx(()=>[e.createElementVNode("form",{"data-testid":"album-form",class:"p-4 space-y-3",onSubmit:e.withModifiers(F,["prevent"])},[e.createVNode(e.unref(B.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...K[5]||(K[5]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(B.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":K[0]||(K[0]=I=>c.value.name=I),"data-testid":"name-input",maxlength:qn,onIonBlur:$},null,8,["modelValue"])]),_:1}),y.value?(e.openBlock(),e.createBlock(e.unref(B.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",FE,e.toDisplayString(y.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(B.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...K[6]||(K[6]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(B.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":K[1]||(K[1]=I=>c.value.description=I),"data-testid":"description-input",maxlength:Qn,onIonBlur:N},null,8,["modelValue"])]),_:1}),E.value?(e.openBlock(),e.createBlock(e.unref(B.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",RE,e.toDisplayString(E.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(B.IonItem),{button:"","data-testid":"parent-selector",onClick:g},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...K[7]||(K[7]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(B.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(C.value),1)]),_:1})]),_:1})],32)]),_:1}),e.createVNode(e.unref(B.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonButtons),{slot:"start"},{default:e.withCtx(()=>[r.value?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",disabled:!w.value,title:w.value?void 0:f.value,onClick:A},{default:e.withCtx(()=>[...K[8]||(K[8]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.unref(B.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!_.value,onClick:F},{default:e.withCtx(()=>[h.value?(e.openBlock(),e.createBlock(e.unref(B.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",$E,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"])):(e.openBlock(),e.createElementBlock("div",DE,[e.createElementVNode("div",UE,[e.createElementVNode("h2",OE,e.toDisplayString(s.value),1),e.createVNode(e.unref(B.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:k},{default:e.withCtx(()=>[...K[9]||(K[9]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),e.createElementVNode("form",{"data-testid":"album-form",class:"space-y-3",onSubmit:e.withModifiers(F,["prevent"])},[e.createVNode(e.unref(B.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...K[10]||(K[10]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(B.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":K[2]||(K[2]=I=>c.value.name=I),"data-testid":"name-input",maxlength:qn,onIonBlur:$},null,8,["modelValue"])]),_:1}),y.value?(e.openBlock(),e.createBlock(e.unref(B.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",AE,e.toDisplayString(y.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(B.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...K[11]||(K[11]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(B.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":K[3]||(K[3]=I=>c.value.description=I),"data-testid":"description-input",maxlength:Qn,onIonBlur:N},null,8,["modelValue"])]),_:1}),E.value?(e.openBlock(),e.createBlock(e.unref(B.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",LE,e.toDisplayString(E.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(B.IonItem),{button:"","data-testid":"parent-selector",onClick:g},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...K[12]||(K[12]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(B.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(C.value),1)]),_:1})]),_:1}),e.createElementVNode("div",zE,[e.createElementVNode("div",null,[r.value?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",fill:"outline",disabled:!w.value,title:w.value?void 0:f.value,onClick:A},{default:e.withCtx(()=>[...K[13]||(K[13]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(B.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!_.value,onClick:F},{default:e.withCtx(()=>[h.value?(e.openBlock(),e.createBlock(e.unref(B.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",PE,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])])],32)])),e.createVNode(vc,{"is-open":m.value,"selected-album-id":c.value.parent_id,title:"Select Parent Album",onClose:O,onConfirm:S},null,8,["is-open","selected-album-id"]),e.createVNode(e.unref(B.IonAlert),{"is-open":v.value,header:"Delete Album?",message:f.value,buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"confirm",cssClass:"alert-button-danger"}],onDidDismiss:R},null,8,["is-open","message"])],64))}}),WE=Me(jE,[["__scopeId","data-v-22083f3a"]]),ZE={class:"album-media-grid"},XE={class:"aspect-square"},HE={key:1,"data-testid":"empty-state",class:"flex flex-col items-center justify-center py-12 gap-4"},GE={class:"text-gray-500"},JE=["data-media-id","draggable","onDragstart","onDragover","onDrop","onMouseenter"],YE={key:0,"data-testid":"drop-indicator",class:"absolute inset-0 border-2 border-primary rounded-lg pointer-events-none z-30"},KE={key:1,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"},qE={class:"aspect-square relative"},QE=["src","alt"],e4={key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center gap-2 transition-opacity"},t4=e.defineComponent({__name:"AlbumMediaGrid",props:{albumId:{},selectionMode:{type:Boolean,default:!1},selectedItems:{default:()=>[]},reorderable:{type:Boolean,default:!1},showActions:{type:Boolean,default:!0},columns:{default:()=>({mobile:2,sm:3,md:4,lg:5,xl:6})},isLoading:{type:Boolean,default:!1},emptyText:{default:"No media in this album"}},emits:["toggle-select","preview","edit","detach","reorder","add","selection-change"],setup(a,{emit:n}){const t=a,o=n,i=La(),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),p=e.computed(()=>{const T=t.columns;return["grid","gap-4",`grid-cols-${T.mobile??2}`,`sm:grid-cols-${T.sm??3}`,`md:grid-cols-${T.md??4}`,`lg:grid-cols-${T.lg??5}`,`xl:grid-cols-${T.xl??6}`]}),h=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 T=await i.fetchAlbumMedia(t.albumId);r.value=T}catch{r.value=[]}finally{s.value=!1}}function y(T){return t.selectedItems.includes(T)}function E(T){o("toggle-select",T);const F=y(T.uuid)?t.selectedItems.filter(A=>A!==T.uuid):[...t.selectedItems,T.uuid];o("selection-change",F)}function _(T){if(T.conversions&&typeof T.conversions=="object"){const F=T.conversions.thumb;if(typeof F=="string")return F}return T.original_url}function C(T){l.value=T}function w(){l.value=null}function f(T){o("preview",T)}function x(T){o("edit",T)}function $(T){o("detach",T.uuid)}function N(){o("add")}function g(T,F){t.reorderable&&(c.value=F,T.dataTransfer&&(T.dataTransfer.effectAllowed="move",T.dataTransfer.setData("text/plain",String(F))))}function S(T,F){!t.reorderable||c.value===null||(T.preventDefault(),d.value=F)}function O(T,F){if(!t.reorderable||c.value===null)return;T.preventDefault();const A=c.value;if(A!==F){const R=[...r.value],[j]=R.splice(A,1);R.splice(F,0,j),r.value=R;const K=R.map(I=>I.uuid);o("reorder",K),i.reorderAlbumMedia(t.albumId,K).catch(()=>{v()})}c.value=null,d.value=null}function k(){c.value=null,d.value=null}return(T,F)=>(e.openBlock(),e.createElementBlock("div",ZE,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,"data-testid":"loading-grid",class:e.normalizeClass(p.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,A=>(e.openBlock(),e.createBlock(e.unref(B.IonCard),{key:A,class:"m-0"},{default:e.withCtx(()=>[e.createElementVNode("div",XE,[e.createVNode(e.unref(B.IonSkeletonText),{animated:"",class:"w-full h-full skeleton"})])]),_:1}))),128))],2)):m.value?(e.openBlock(),e.createElementBlock("div",HE,[e.createVNode(e.unref(B.IonIcon),{name:"images-outline",class:"text-6xl text-gray-400"}),e.createElementVNode("p",GE,e.toDisplayString(T.emptyText),1),e.createVNode(e.unref(B.IonButton),{"data-testid":"add-media-btn",onClick:N},{default:e.withCtx(()=>[...F[0]||(F[0]=[e.createTextVNode(" Add Media ",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("div",{key:2,"data-testid":"media-grid",class:e.normalizeClass(p.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(A,R)=>(e.openBlock(),e.createElementBlock("div",{key:A.uuid,"data-media-id":A.uuid,class:e.normalizeClass(["media-item relative group",{"opacity-50":c.value===R,"ring-2 ring-primary":d.value===R&&c.value!==R}]),draggable:T.reorderable,onDragstart:j=>g(j,R),onDragover:j=>S(j,R),onDrop:j=>O(j,R),onDragend:k,onMouseenter:j=>C(A.uuid),onMouseleave:w},[d.value===R&&c.value!==R&&T.reorderable?(e.openBlock(),e.createElementBlock("div",YE)):e.createCommentVNode("",!0),T.reorderable?(e.openBlock(),e.createElementBlock("div",KE,[e.createVNode(e.unref(B.IonIcon),{name:"reorder-three-outline",class:"text-white drop-shadow-md"})])):e.createCommentVNode("",!0),T.selectionMode?(e.openBlock(),e.createBlock(e.unref(B.IonCheckbox),{key:2,"data-testid":"media-checkbox",checked:y(A.uuid),class:"absolute top-2 left-2 z-20",onIonChange:j=>E(A)},null,8,["checked","onIonChange"])):e.createCommentVNode("",!0),e.createVNode(e.unref(B.IonCard),{class:"m-0 overflow-hidden"},{default:e.withCtx(()=>[e.createElementVNode("div",qE,[e.createElementVNode("img",{src:_(A),alt:A.file_name,class:"w-full h-full object-cover"},null,8,QE),T.showActions&&l.value===A.uuid?(e.openBlock(),e.createElementBlock("div",e4,[e.createVNode(e.unref(B.IonButton),{"data-testid":"action-preview",fill:"clear",size:"small",color:"light",onClick:j=>f(A)},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{slot:"icon-only",name:"eye-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(B.IonButton),{"data-testid":"action-edit",fill:"clear",size:"small",color:"light",onClick:j=>x(A)},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{slot:"icon-only",name:"create-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(B.IonButton),{"data-testid":"action-detach",fill:"clear",size:"small",color:"danger",onClick:j=>$(A)},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{slot:"icon-only",name:"close-circle-outline"})]),_:1},8,["onClick"])])):e.createCommentVNode("",!0)])]),_:2},1024)],42,JE))),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:N},[e.createVNode(e.unref(B.IonIcon),{name:"add-circle-outline",class:"text-4xl text-gray-400"}),F[1]||(F[1]=e.createElementVNode("span",{class:"text-sm text-gray-500"},"Add Media",-1))])],2))]))}}),n4=Me(t4,[["__scopeId","data-v-d84b796a"]]);function pr(a={}){const n=e.ref(!1),t=e.ref(!1),o=e.ref(null),i=e.ref(null),r=e.ref(0),s=e.ref(null),l=e.ref(null),c=e.computed(()=>l.value!==null),d=_=>{if(r.value++,l.value=null,i.value=null,t.value=!1,_!=null&&typeof _=="object"&&!(_ instanceof Blob)&&("image"in _||"state"in _||"sessionKey"in _)){const C=_;o.value=C.image??null,s.value=C.state??null}else o.value=_??null,s.value=null;n.value=!0},u=()=>{n.value=!1,o.value=null,i.value=null,l.value=null,t.value=!1,s.value=null},m=async _=>{try{return t.value=!0,i.value=_,a.onSave&&await a.onSave(_),u(),_}catch(C){const w=C;throw l.value=w,a.onError&&a.onError(w),w}finally{t.value=!1}},p=()=>{a.onCancel&&a.onCancel(),u()},h=_=>{l.value=_,a.onError&&a.onError(_)},v=()=>{l.value=null},y=()=>i.value,E=e.computed(()=>n.value&&i.value!==null&&!t.value);return{isOpen:n,isProcessing:t,uploadedImage:o,editedImage:i,sessionKey:r,initialState:s,error:l,hasError:c,hasUnsavedChanges:E,open:d,close:u,handleSave:m,handleCancel:p,handleError:h,clearError:v,getEditedImage:y}}let vi=null;function o4(a){return vi||(vi=pr(a)),vi}function a4(a){return n=>new Promise((t,o)=>{pr({...a,onSave:async r=>{a!=null&&a.onSave&&await a.onSave(r),t(r)},onError:r=>{a!=null&&a.onError&&a.onError(r),o(r)},onCancel:()=>{a!=null&&a.onCancel&&a.onCancel(),o(new Error("User cancelled"))}}).open(n)})}function fr(a){return a.filter(n=>n.media&&!n.markedForRemoval).map((n,t)=>{const o={uuid:n.media.uuid,name:n.name,order:t};return n.customProperties&&(o.custom_properties=n.customProperties),o})}function zi(a){return a.map((n,t)=>{const o={media:n,clientId:n.uuid,name:n.name||n.file_name,order:t};return n.custom_properties&&(o.customProperties=n.custom_properties),o})}function hr(a){if(a){const t={};a.apiBaseUrl!==void 0&&(t.apiBaseUrl=a.apiBaseUrl),a.isAdmin!==void 0&&(t.isAdmin=a.isAdmin),In(t)}return{name:"mediables",async upload(t,o){const r=await kt().uploadFile(t,{collection:(o==null?void 0:o.collection)||"default",customProperties:o==null?void 0:o.customProperties});if(!r)throw new Error("Upload failed: No media returned");return{media:r,uuid:r.uuid}},async attach(t,o){await kt().attachMedia(o.modelType,String(o.modelId),[t],o.collection||"images")},async attachMany(t,o){await kt().attachMedia(o.modelType,String(o.modelId),t,o.collection||"images")},async detach(t,o){await kt().detachMedia(o.modelType,String(o.modelId),t,o.collection||"images")},async reorder(t,o){await kt().reorderMedia(t.modelType,String(t.modelId),o,t.collection||"images")},async fetchModelMedia(t){return await kt().fetchModelMedia(t.modelType,String(t.modelId),t.collection||"images")},getUrl(t,o){return kt().getMediaUrl(t,o)},getThumbnailUrl(t){var o,i;return(o=t.conversion_urls)!=null&&o.thumb?t.conversion_urls.thumb:(i=t.conversion_urls)!=null&&i.thumbnail?t.conversion_urls.thumbnail:t.thumbnail_url?t.thumbnail_url:t.original_url||t.url||""},async delete(t){await kt().deleteMedia(t)},async update(t,o){const r=await kt().updateMedia(t,o);if(!r)throw new Error("Update failed: No media returned");return r},configure(t){const o={};t.apiBaseUrl!==void 0&&(o.apiBaseUrl=t.apiBaseUrl),t.isAdmin!==void 0&&(o.isAdmin=t.isAdmin),In(o)}}}let na=null;function i4(){return na||(na=hr()),na}function r4(){na=null}const s4={apiBaseUrl:"/media-library-pro"};function Zo(){var a;return typeof document>"u"?null:((a=document.querySelector('meta[name="csrf-token"]'))==null?void 0:a.getAttribute("content"))||null}function gi(a){const n={uuid:a.uuid,file_name:a.fileName||a.name,mime_type:`application/${a.extension}`,size:a.size,disk:"public",original_url:a.original_url||"",created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return a.name&&(n.name=a.name),a.original_url&&(n.url=a.original_url),a.preview_url&&(n.thumbnail_url=a.preview_url,n.preview_url=a.preview_url),a.custom_properties&&(n.custom_properties=a.custom_properties),n}function vr(a){const n={...s4,...a};return{name:"spatie",async upload(o,i){const r=new FormData;r.append("file",o),i!=null&&i.collection&&r.append("collection",i.collection),i!=null&&i.customProperties&&r.append("custom_properties",JSON.stringify(i.customProperties));const s={Accept:"application/json",...n.headers},l=n.csrfToken||Zo();l&&(s["X-CSRF-TOKEN"]=l);const c={method:"POST",headers:s,body:r,credentials:"include"};i!=null&&i.signal&&(c.signal=i.signal);const d=await fetch(`${n.apiBaseUrl}/uploads`,c);if(!d.ok){const p=await d.json().catch(()=>({message:"Upload failed"}));throw new Error(p.message||`HTTP ${d.status}`)}const u=await d.json(),m=gi(u);return i!=null&&i.onProgress&&i.onProgress(100),{media:m,uuid:u.uuid}},async attach(o,i){},async attachMany(o,i){},async detach(o,i){},async reorder(o,i){},async fetchModelMedia(o){const i={Accept:"application/json",...n.headers},r=n.csrfToken||Zo();r&&(i["X-CSRF-TOKEN"]=r);const s=new URLSearchParams;s.append("model_type",o.modelType),s.append("model_id",String(o.modelId)),o.collection&&s.append("collection",o.collection);try{const l=await fetch(`${n.apiBaseUrl}/media?${s}`,{method:"GET",headers:i,credentials:"include"});if(!l.ok)throw new Error(`HTTP ${l.status}`);return(await l.json()).map(gi)}catch{return[]}},getUrl(o,i){var r;if(i){const s=(r=o.conversion_urls)==null?void 0:r[i];if(s)return s}return o.original_url||o.url||""},getThumbnailUrl(o){var i,r;return o.preview_url?o.preview_url:(i=o.conversion_urls)!=null&&i.preview?o.conversion_urls.preview:o.thumbnail_url?o.thumbnail_url:(r=o.conversion_urls)!=null&&r.thumb?o.conversion_urls.thumb:o.original_url||o.url||""},async delete(o){const i={Accept:"application/json",...n.headers},r=n.csrfToken||Zo();r&&(i["X-CSRF-TOKEN"]=r);const s=await fetch(`${n.apiBaseUrl}/uploads/${o}`,{method:"DELETE",headers:i,credentials:"include"});if(!s.ok){const l=await s.json().catch(()=>({message:"Delete failed"}));throw new Error(l.message||`HTTP ${s.status}`)}},async update(o,i){const r={Accept:"application/json","Content-Type":"application/json",...n.headers},s=n.csrfToken||Zo();s&&(r["X-CSRF-TOKEN"]=s);const l=await fetch(`${n.apiBaseUrl}/uploads/${o}`,{method:"PATCH",headers:r,body:JSON.stringify(i),credentials:"include"});if(!l.ok){const d=await l.json().catch(()=>({message:"Update failed"}));throw new Error(d.message||`HTTP ${l.status}`)}const c=await l.json();return gi(c)},configure(o){Object.assign(n,o)}}}let oa=null;function l4(){return oa||(oa=vr()),oa}function c4(){oa=null}function gc(a,n){switch(a){case"mediables":return hr(n);case"spatie":return vr(n);default:throw new Error(`Unknown adapter: ${a}`)}}function ha(a){if(a===0)return"0 Bytes";const n=1024,t=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(a)/Math.log(n));return parseFloat((a/Math.pow(n,o)).toFixed(2))+" "+t[o]}function yc(a){var t;const n=a.split(".");return n.length>1?`.${(t=n.pop())==null?void 0:t.toLowerCase()}`:""}function gr(a){return a.type.startsWith("image/")}async function wc(a){return gr(a)?new Promise(n=>{const t=new Image,o=URL.createObjectURL(a);t.onload=()=>{URL.revokeObjectURL(o),n({width:t.naturalWidth,height:t.naturalHeight})},t.onerror=()=>{URL.revokeObjectURL(o),n(null)},t.src=o}):null}async function bc(a,n){const t=[];if(n.maxFileSize&&a.size>n.maxFileSize&&t.push({field:"size",message:`File exceeds maximum size of ${ha(n.maxFileSize)}`,code:"MAX_FILE_SIZE"}),n.minFileSize&&a.size<n.minFileSize&&t.push({field:"size",message:`File is smaller than minimum size of ${ha(n.minFileSize)}`,code:"MIN_FILE_SIZE"}),n.acceptedMimeTypes&&n.acceptedMimeTypes.length>0&&(n.acceptedMimeTypes.some(i=>i.endsWith("/*")?a.type.startsWith(i.slice(0,-1)):a.type===i)||t.push({field:"type",message:`File type "${a.type}" is not allowed`,code:"INVALID_MIME_TYPE"})),n.acceptedExtensions&&n.acceptedExtensions.length>0){const o=yc(a.name);n.acceptedExtensions.some(r=>r.toLowerCase()===o.toLowerCase())||t.push({field:"extension",message:`File extension "${o}" is not allowed`,code:"INVALID_EXTENSION"})}if(gr(a)&&(n.maxDimensions||n.minDimensions)){const o=await wc(a);o&&(n.maxDimensions&&(o.width>n.maxDimensions.width&&t.push({field:"dimensions",message:`Image width (${o.width}px) exceeds maximum (${n.maxDimensions.width}px)`,code:"MAX_WIDTH"}),o.height>n.maxDimensions.height&&t.push({field:"dimensions",message:`Image height (${o.height}px) exceeds maximum (${n.maxDimensions.height}px)`,code:"MAX_HEIGHT"})),n.minDimensions&&(o.width<n.minDimensions.width&&t.push({field:"dimensions",message:`Image width (${o.width}px) is smaller than minimum (${n.minDimensions.width}px)`,code:"MIN_WIDTH"}),o.height<n.minDimensions.height&&t.push({field:"dimensions",message:`Image height (${o.height}px) is smaller than minimum (${n.minDimensions.height}px)`,code:"MIN_HEIGHT"})))}if(n.customValidator){const o=await n.customValidator(a);t.push(...o)}return{valid:t.length===0,errors:t}}function yr(a={}){const n=e.ref(a.rules||{});function t(c){n.value=c}async function o(c){return bc(c,n.value)}async function i(c){const d=new Map;return await Promise.all(c.map(async u=>{const m=await o(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:o,validateFiles:i,canAddFiles:r,acceptString:s,isMimeTypeAllowed:l}}function d4(){return`upload-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function u4(a){if(a.type.startsWith("image/"))return URL.createObjectURL(a)}function kc(a){const{adapter:n,maxConcurrent:t=3,rules:o,collection:i,onUploadStart:r,onUploadProgress:s,onUploadComplete:l,onUploadError:c,onQueueComplete:d}=a,u=e.ref(new Map),m=e.ref(new Set),p=o?{rules:o}:{},{validateFile:h}=yr(p);async function v(){if(m.value.size>=t)return;const k=Array.from(u.value.entries()).find(([A,R])=>R.status==="pending"&&!m.value.has(A));if(!k){Array.from(u.value.values()).every(R=>R.status==="completed"||R.status==="error")&&u.value.size>0&&(d==null||d());return}const[T,F]=k;await y(T,F)}async function y(k,T){m.value.add(k),T.status="uploading",T.abortController=new AbortController,u.value.set(k,{...T}),r==null||r(T);try{const F={onProgress:R=>{T.progress=R,u.value.set(k,{...T}),s==null||s(T)},signal:T.abortController.signal};i&&(F.collection=i);const A=await n.upload(T.file,F);T.status="completed",T.progress=100,T.media=A.media,u.value.set(k,{...T}),l==null||l(T,A.media)}catch(F){F.name==="AbortError"?u.value.delete(k):(T.status="error",T.error=F.message,u.value.set(k,{...T}),c==null||c(T,F))}finally{m.value.delete(k),delete T.abortController,v()}}async function E(k){var A;const T=Array.from(k),F=[];for(const R of T){const j=await h(R),K=d4(),I=u4(R),D={id:K,file:R,progress:0,status:j.valid?"pending":"error"};!j.valid&&((A=j.errors[0])!=null&&A.message)&&(D.error=j.errors[0].message),I&&(D.previewUrl=I),u.value.set(K,D);const Z={media:null,clientId:K,name:R.name,order:0,upload:D,errors:j.errors};F.push(Z)}for(let R=0;R<t;R++)v();return F}function _(k){const T=u.value.get(k);T&&(T.abortController&&T.abortController.abort(),T.previewUrl&&URL.revokeObjectURL(T.previewUrl),u.value.delete(k),m.value.delete(k),v())}async function C(k){const T=u.value.get(k);!T||T.status!=="error"||(T.status="pending",T.progress=0,delete T.error,u.value.set(k,{...T}),v())}function w(){for(const[k,T]of u.value.entries())(T.status==="completed"||T.status==="error")&&(T.previewUrl&&URL.revokeObjectURL(T.previewUrl),u.value.delete(k))}function f(){for(const k of u.value.values())k.abortController&&k.abortController.abort(),k.previewUrl&&URL.revokeObjectURL(k.previewUrl);u.value.clear(),m.value.clear()}function x(k){return u.value.get(k)}const $=e.computed(()=>m.value.size>0),N=e.computed(()=>m.value.size),g=e.computed(()=>Array.from(u.value.values()).filter(k=>k.status==="pending").length),S=e.computed(()=>u.value.size===0?!0:Array.from(u.value.values()).every(k=>k.status==="completed"||k.status==="error")),O=e.computed(()=>Array.from(u.value.values()));return{uploads:u,isUploading:$,activeCount:N,pendingCount:g,isComplete:S,addFiles:E,cancelUpload:_,retryUpload:C,clearCompleted:w,clearAll:f,getUpload:x,uploadsArray:O}}function xc(a={}){const{enabled:n=!0,onReorder:t,onDragStart:o,onDragEnd:i,draggingClass:r="is-dragging",dropTargetClass:s="is-drop-target"}=a,l=e.ref({isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null}),c=e.ref(!1);let d=null;function u(C,w,f){n&&("dataTransfer"in C&&C.dataTransfer&&(C.dataTransfer.effectAllowed="move",C.dataTransfer.setData("text/plain",String(f))),d=C.target,d&&d.classList.add(r),l.value={isDragging:!0,dragIndex:f,dropIndex:f,draggedItem:w},c.value=!0,o==null||o(w,f))}function m(C,w){var f;if(!(!n||!l.value.isDragging)&&(C.preventDefault(),l.value.dropIndex!==w)){const x=document.querySelector(`.${s}`);x==null||x.classList.remove(s);const $=(f=C.target)==null?void 0:f.closest("[data-index]");$==null||$.classList.add(s),l.value.dropIndex=w}}function p(){if(!l.value.isDragging)return;const{dragIndex:C,dropIndex:w,draggedItem:f}=l.value;d&&d.classList.remove(r);const x=document.querySelector(`.${s}`);x==null||x.classList.remove(s),C!==null&&w!==null&&C!==w&&f&&(t==null||t({fromIndex:C,toIndex:w,item:f})),v(),i==null||i()}function h(){d&&d.classList.remove(r);const C=document.querySelector(`.${s}`);C==null||C.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 y(C,w,f){const x=[...C],[$]=x.splice(w,1);return x.splice(f,0,$),x.map((N,g)=>({...N,order:g}))}function E(C,w){return{draggable:n,"data-index":w,onDragstart:f=>u(f,C,w),onDragover:f=>m(f,w),onDragend:()=>p(),onDrop:f=>{f.preventDefault(),p()}}}function _(C){C.key==="Escape"&&l.value.isDragging&&h()}return e.onMounted(()=>{document.addEventListener("keydown",_)}),e.onUnmounted(()=>{document.removeEventListener("keydown",_),h()}),{dragState:l,isDragging:c,startDrag:u,handleDragOver:m,endDrag:p,cancelDrag:h,reorderItems:y,getDragProps:E}}function za(a={}){const{initialItems:n=[],modelType:t,modelId:o,collection:i="images",maxItems:r,maxFileSize:s,acceptedMimeTypes:l,sortable:c=!0,disabled:d=!1,rules:u={},adapterType:m="mediables",adapter:p,maxConcurrentUploads:h=3,onChange:v,onUpload:y,onUploadComplete:E,onUploadError:_,onRemove:C,onReorder:w,onError:f,onReadyToSubmitChange:x}=a,$={maxItems:r,maxFileSize:s,acceptedMimeTypes:l,...u},N=p||gc(m),g=e.ref([]),S=e.ref(!1),O=e.ref([]);function k(ie){if(ie.length===0)return[];const le=ie[0];return"media"in le&&"clientId"in le?ie:zi(ie)}g.value=k(n);const{acceptString:T,canAddFiles:F}=yr({rules:$}),A=kc({adapter:N,maxConcurrent:h,rules:$,collection:i,onUploadStart:ie=>{y==null||y(ie)},onUploadComplete:(ie,le)=>{const ke=g.value.findIndex(Ve=>Ve.clientId===ie.id);ke!==-1&&(g.value[ke]={...g.value[ke],media:le,name:le.name||le.file_name,upload:{...ie,status:"completed"}}),E==null||E(le)},onUploadError:(ie,le)=>{const ke=g.value.findIndex(Ve=>Ve.clientId===ie.id);ke!==-1&&(g.value[ke]={...g.value[ke],upload:{...ie,status:"error",error:le.message},errors:[{field:"upload",message:le.message,code:"UPLOAD_ERROR"}]}),_==null||_({file:ie.file,message:le.message})},onQueueComplete:()=>{v==null||v(g.value)}}),{dragState:R,getDragProps:j,reorderItems:K}=xc({enabled:c&&!d,onReorder:ie=>{g.value=K(g.value,ie.fromIndex,ie.toIndex),w==null||w(g.value),v==null||v(g.value)}}),I=e.computed(()=>A.isUploading.value),D=e.computed(()=>!A.isUploading.value&&A.pendingCount.value===0),Z=e.computed(()=>r?g.value.length>=r:!1),W=e.computed(()=>fr(g.value)),oe=e.computed(()=>g.value.length),we=e.computed(()=>r?Math.max(0,r-g.value.length):1/0);e.watch(D,ie=>{x==null||x(ie)});function Ce(ie){g.value=k(ie),v==null||v(g.value)}async function ne(ie){if(d)return;const le=Array.from(ie);if(!F(le.length,g.value.length)){const We={field:"count",message:`Maximum ${r} files allowed`,code:"MAX_ITEMS"};O.value=[We],f==null||f([We]);return}const ke=await A.addFiles(le),Ve=g.value.length,et=ke.map((We,fe)=>({...We,order:Ve+fe}));g.value=[...g.value,...et],v==null||v(g.value)}function M(ie){d||(ie.upload&&(ie.upload.status==="uploading"||ie.upload.status==="pending")&&A.cancelUpload(ie.clientId),g.value=g.value.filter(le=>le.clientId!==ie.clientId),g.value=g.value.map((le,ke)=>({...le,order:ke})),C==null||C(ie),v==null||v(g.value))}function z(ie){const le=g.value.find(ke=>ke.clientId===ie);le&&M(le)}function me(){d||(A.clearAll(),g.value=[],v==null||v(g.value))}function ae(ie,le){d||!c||(g.value=K(g.value,ie,le),w==null||w(g.value),v==null||v(g.value))}function Y(ie,le){if(d)return;const ke=g.value.findIndex(Ve=>Ve.clientId===ie);ke!==-1&&(g.value[ke]={...g.value[ke],...le},v==null||v(g.value))}function Te(ie){A.cancelUpload(ie),z(ie)}async function ue(ie){await A.retryUpload(ie)}async function se(){if(!t||!o)throw new Error("modelType and modelId are required for save()");const ie={modelType:t,modelId:o,collection:i},le=g.value.filter(ke=>ke.media&&!ke.markedForRemoval).map(ke=>ke.media.uuid);S.value=!0;try{await N.attachMany(le,ie),await N.reorder(ie,le)}finally{S.value=!1}}async function be(){if(!t||!o)throw new Error("modelType and modelId are required for load()");const ie={modelType:t,modelId:o,collection:i};S.value=!0;try{const le=await N.fetchModelMedia(ie);g.value=zi(le),v==null||v(g.value)}finally{S.value=!1}}return e.onMounted(()=>{t&&o&&n.length===0&&be().catch(console.error)}),e.onUnmounted(()=>{A.clearAll()}),{items:g,setItems:Ce,addFiles:ne,removeItem:M,removeItemById:z,clearAll:me,reorderItems:ae,updateItem:Y,cancelUpload:Te,retryUpload:ue,save:se,load:be,isLoading:S,isUploading:I,isReadyToSubmit:D,isAtMaxItems:Z,errors:O,dragState:R,getDragProps:j,adapter:N,formValues:W,acceptString:T,count:oe,remainingSlots:we}}const m4=["aria-disabled"],p4=["accept","multiple","disabled"],f4={class:"media-dropzone__content"},h4={class:"media-dropzone__title"},v4={class:"media-dropzone__subtitle"},g4=["disabled"],y4={key:0,class:"media-dropzone__helper"},w4=e.defineComponent({__name:"MediaCollectionDropzone",props:{accept:{default:"*"},multiple:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},maxFileSize:{},maxItems:{},title:{default:"Drop files here"},subtitle:{default:"or click to browse"},buttonText:{default:"Select files"}},emits:["files"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(!1),r=e.ref(null),s=e.computed(()=>({"media-dropzone":!0,"media-dropzone--drag-over":i.value,"media-dropzone--disabled":t.disabled})),l=e.computed(()=>{const y=[];return t.maxFileSize&&y.push(`Max size: ${ha(t.maxFileSize)}`),t.maxItems&&t.maxItems>1&&y.push(`Max files: ${t.maxItems}`),y.join(" • ")});function c(y){y.preventDefault(),!t.disabled&&(i.value=!0)}function d(y){y.preventDefault(),i.value=!1}function u(y){y.preventDefault()}function m(y){var _;if(y.preventDefault(),i.value=!1,t.disabled)return;const E=(_=y.dataTransfer)==null?void 0:_.files;E&&E.length>0&&o("files",E)}function p(){var y;t.disabled||(y=r.value)==null||y.click()}function h(y){const E=y.target,_=E.files;_&&_.length>0&&o("files",_),E.value=""}function v(y){(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),p())}return(y,E)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(s.value),role:"button",tabindex:"0","aria-disabled":y.disabled,"aria-label":"Upload files",onClick:p,onKeydown:v,onDragenter:c,onDragleave:d,onDragover:u,onDrop:m},[e.createElementVNode("input",{ref_key:"fileInput",ref:r,type:"file",accept:y.accept,multiple:y.multiple,disabled:y.disabled,class:"media-dropzone__input",onChange:h},null,40,p4),e.createElementVNode("div",f4,[e.renderSlot(y.$slots,"icon",{},()=>[E[0]||(E[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",h4,[e.renderSlot(y.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(y.title),1)],!0)]),e.createElementVNode("p",v4,[e.renderSlot(y.$slots,"subtitle",{},()=>[e.createTextVNode(e.toDisplayString(y.subtitle),1)],!0)]),e.createElementVNode("button",{type:"button",class:"media-dropzone__button",disabled:y.disabled,onClick:e.withModifiers(p,["stop"])},[e.renderSlot(y.$slots,"button",{},()=>[e.createTextVNode(e.toDisplayString(y.buttonText),1)],!0)],8,g4),l.value?(e.openBlock(),e.createElementBlock("p",y4,e.toDisplayString(l.value),1)):e.createCommentVNode("",!0)])],42,m4))}}),wr=Me(w4,[["__scopeId","data-v-b1366c1e"]]),b4=["data-index"],k4={key:0,class:"media-item__drag-handle","aria-label":"Drag to reorder",role:"button",tabindex:"0"},x4={class:"media-item__thumbnail"},E4=["src","alt"],V4={key:1,class:"media-item__file-icon"},S4={key:2,class:"media-item__progress-overlay"},C4={class:"media-item__progress-text"},N4={key:3,class:"media-item__processing-overlay"},_4={key:4,class:"media-item__error-overlay"},T4={class:"media-item__info"},M4=["title"],B4={key:0,class:"media-item__size"},I4={key:1,class:"media-item__error-message"},F4={class:"media-item__actions"},R4=["disabled"],$4=["disabled"],D4=["disabled"],U4=["disabled"],O4=e.defineComponent({__name:"MediaCollectionItem",props:{item:{},adapter:{},disabled:{type:Boolean,default:!1},sortable:{type:Boolean,default:!1},showRemove:{type:Boolean,default:!0},showEdit:{type:Boolean,default:!1},index:{default:0}},emits:["remove","edit","retry","cancel"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(!1),r=e.computed(()=>{var w;return(w=t.item.upload)!=null&&w.previewUrl?t.item.upload.previewUrl:t.item.media?t.adapter.getThumbnailUrl(t.item.media):null}),s=e.computed(()=>{var w,f,x;return((w=t.item.upload)==null?void 0:w.status)==="uploading"||((f=t.item.upload)==null?void 0:f.status)==="pending"||((x=t.item.upload)==null?void 0:x.status)==="queued"}),l=e.computed(()=>{var w;return((w=t.item.upload)==null?void 0:w.status)==="processing"}),c=e.computed(()=>{var w;return((w=t.item.upload)==null?void 0:w.status)==="error"||t.item.errors&&t.item.errors.length>0}),d=e.computed(()=>{var w;return(w=t.item.upload)!=null&&w.error?t.item.upload.error:t.item.errors&&t.item.errors.length>0?t.item.errors[0].message:null}),u=e.computed(()=>{var w;return((w=t.item.upload)==null?void 0:w.progress)||0}),m=e.computed(()=>{var w;return t.item.name||((w=t.item.media)==null?void 0:w.file_name)||"Unknown file"}),p=e.computed(()=>{var N,g;const w=((N=t.item.media)==null?void 0:N.size)||((g=t.item.upload)==null?void 0:g.file.size);if(!w)return"";const f=1024,x=["Bytes","KB","MB","GB"],$=Math.floor(Math.log(w)/Math.log(f));return parseFloat((w/Math.pow(f,$)).toFixed(2))+" "+x[$]}),h=e.computed(()=>{var f,x;const w=((f=t.item.media)==null?void 0:f.mime_type)||((x=t.item.upload)==null?void 0:x.file.type);return w==null?void 0:w.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 y(){t.disabled||o("remove",t.item)}function E(){t.disabled||o("edit",t.item)}function _(){t.disabled||o("retry",t.item)}function C(){t.disabled||o("cancel",t.item)}return(w,f)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(v.value),"data-index":w.index,onMouseenter:f[0]||(f[0]=x=>i.value=!0),onMouseleave:f[1]||(f[1]=x=>i.value=!1)},[w.sortable&&!w.disabled?(e.openBlock(),e.createElementBlock("div",k4,[...f[2]||(f[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",x4,[r.value&&h.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.value,alt:m.value,class:"media-item__image"},null,8,E4)):(e.openBlock(),e.createElementBlock("div",V4,[...f[3]||(f[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",S4,[e.createElementVNode("div",{class:"media-item__progress-bar",style:e.normalizeStyle({width:`${u.value}%`})},null,4),e.createElementVNode("span",C4,e.toDisplayString(u.value)+"%",1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",N4,[...f[4]||(f[4]=[e.createElementVNode("div",{class:"media-item__spinner","aria-label":"Processing"},null,-1)])])):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",_4,[...f[5]||(f[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",T4,[e.createElementVNode("span",{class:"media-item__name",title:m.value},e.toDisplayString(m.value),9,M4),p.value?(e.openBlock(),e.createElementBlock("span",B4,e.toDisplayString(p.value),1)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("span",I4,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",F4,[s.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-item__action media-item__action--cancel",disabled:w.disabled,"aria-label":"Cancel upload",onClick:C},[...f[6]||(f[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,R4)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"media-item__action media-item__action--retry",disabled:w.disabled,"aria-label":"Retry upload",onClick:_},[...f[7]||(f[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,$4)):e.createCommentVNode("",!0),w.showEdit&&w.item.media&&!s.value?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"media-item__action media-item__action--edit",disabled:w.disabled,"aria-label":"Edit",onClick:E},[...f[8]||(f[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,D4)):e.createCommentVNode("",!0),w.showRemove?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"media-item__action media-item__action--remove",disabled:w.disabled,"aria-label":"Remove",onClick:y},[...f[9]||(f[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,U4)):e.createCommentVNode("",!0)])],42,b4))}}),br=Me(O4,[["__scopeId","data-v-ff81c9ec"]]),A4=["aria-label"],L4=["draggable","data-index","onDragstart","onDragover","onDragend","onDrop"],z4={key:0,class:"media-collection__footer"},P4={class:"media-collection__count"},j4={key:0},W4={key:0,class:"media-collection__uploading"},Z4=["name","value"],X4=["name","value"],H4=["name","value"],G4=["name","value"],J4={key:3,class:"media-collection__errors",role:"alert","aria-live":"polite"},Y4=e.defineComponent({__name:"MediaCollection",props:{modelValue:{default:()=>[]},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxItems:{},maxFileSize:{},acceptedMimeTypes:{},sortable:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","reorder","is-ready-to-submit-change","validation-error"],setup(a,{emit:n}){const t=a,o=n,i={initialItems:t.modelValue,modelType:t.modelType,modelId:t.modelId,collection:t.collection,maxItems:t.maxItems,maxFileSize:t.maxFileSize,acceptedMimeTypes:t.acceptedMimeTypes,sortable:t.sortable,disabled:t.disabled,rules:t.rules,adapterType:t.adapter,onChange:I=>{o("update:modelValue",I),o("change",I)},onUpload:I=>{o("upload",I)},onUploadComplete:I=>{o("upload-complete",I)},onUploadError:I=>{o("upload-error",I)},onRemove:I=>{o("remove",I)},onReorder:I=>{o("reorder",I)},onError:I=>{o("validation-error",I)},onReadyToSubmitChange:I=>{o("is-ready-to-submit-change",I)}},{items:r,setItems:s,addFiles:l,removeItem:c,reorderItems:d,cancelUpload:u,retryUpload:m,isLoading:p,isUploading:h,isAtMaxItems:v,errors:y,dragState:E,getDragProps:_,adapter:C,formValues:w,acceptString:f,count:x,remainingSlots:$}=za(i);e.provide("mediaAdapter",C),e.provide("mediaCollection",{items:r,addFiles:l,removeItem:c,reorderItems:d}),e.watch(()=>t.modelValue,I=>{I!==r.value&&s(I)},{deep:!0});const N=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!v.value),g=e.computed(()=>({"media-collection":!0,"media-collection--disabled":t.disabled,"media-collection--readonly":t.readonly,"media-collection--loading":p.value,"media-collection--has-items":r.value.length>0,"media-collection--dragging":E.value.isDragging}));function S(I){l(I)}function O(I){c(I)}function k(I){m(I.clientId)}function T(I){u(I.clientId)}function F(I){}function A(I,D,Z){if(!t.sortable||t.disabled)return;const W=_(D,Z);W.onDragstart&&W.onDragstart(I)}function R(I,D){if(!t.sortable||t.disabled)return;I.preventDefault();const Z=r.value[D],W=_(Z,D);W.onDragover&&W.onDragover(I)}function j(I,D){const Z=_(I,D);Z.onDragend&&Z.onDragend()}function K(I,D){I.preventDefault();const Z=r.value[D],W=_(Z,D);W.onDrop&&W.onDrop(I)}return(I,D)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(g.value)},[e.renderSlot(I.$slots,"dropzone",{addFiles:e.unref(l)},()=>[N.value?(e.openBlock(),e.createBlock(wr,{key:0,accept:e.unref(f),multiple:I.maxItems!==1,disabled:I.disabled,"max-file-size":I.maxFileSize,"max-items":e.unref($),onFiles:S},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(x)} media items`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r),(Z,W)=>e.renderSlot(I.$slots,"item",{key:Z.clientId,item:Z,index:W,remove:()=>O(Z)},()=>[e.createElementVNode("div",{class:e.normalizeClass(["media-collection__item-wrapper",{"media-collection__item-wrapper--drag-over":e.unref(E).dropIndex===W}]),draggable:I.sortable&&!I.disabled,"data-index":W,onDragstart:oe=>A(oe,Z,W),onDragover:oe=>R(oe,W),onDragend:oe=>j(Z,W),onDrop:oe=>K(oe,W)},[e.createVNode(br,{item:Z,adapter:e.unref(C),disabled:I.disabled,sortable:I.sortable,"show-remove":!I.readonly,"show-edit":!1,index:W,onRemove:O,onRetry:k,onCancel:T,onEdit:F},null,8,["item","adapter","disabled","sortable","show-remove","index"])],42,L4)],!0)),128))],8,A4)):N.value?e.createCommentVNode("",!0):e.renderSlot(I.$slots,"empty",{key:1},()=>[D[0]||(D[0]=e.createElementVNode("div",{class:"media-collection__empty"},[e.createElementVNode("p",null,"No files uploaded")],-1))],!0),e.renderSlot(I.$slots,"footer",{count:e.unref(x),isUploading:e.unref(h)},()=>[e.unref(r).length>0?(e.openBlock(),e.createElementBlock("div",z4,[e.createElementVNode("span",P4,[e.createTextVNode(e.toDisplayString(e.unref(x))+" "+e.toDisplayString(e.unref(x)===1?"file":"files")+" ",1),I.maxItems?(e.openBlock(),e.createElementBlock("span",j4," / "+e.toDisplayString(I.maxItems)+" max",1)):e.createCommentVNode("",!0)]),e.unref(h)?(e.openBlock(),e.createElementBlock("span",W4," Uploading... ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],!0),I.generateFormFields?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(w),(Z,W)=>(e.openBlock(),e.createElementBlock("input",{key:`${I.name}-${Z.uuid}`,type:"hidden",name:`${I.name}[${W}][uuid]`,value:Z.uuid},null,8,Z4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(w),(Z,W)=>(e.openBlock(),e.createElementBlock("input",{key:`${I.name}-${Z.uuid}-name`,type:"hidden",name:`${I.name}[${W}][name]`,value:Z.name},null,8,X4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(w),(Z,W)=>(e.openBlock(),e.createElementBlock("input",{key:`${I.name}-${Z.uuid}-order`,type:"hidden",name:`${I.name}[${W}][order]`,value:Z.order},null,8,H4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(w),(Z,W)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${I.name}-${Z.uuid}-props`},[Z.custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${I.name}[${W}][custom_properties]`,value:JSON.stringify(Z.custom_properties)},null,8,G4)):e.createCommentVNode("",!0)],64))),128))],64)):e.createCommentVNode("",!0),e.unref(y).length>0?(e.openBlock(),e.createElementBlock("div",J4,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y),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))}}),K4=Me(Y4,[["__scopeId","data-v-10a5bfff"]]);function kr(a={}){const{initialItem:n,onChange:t,onReplace:o,onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:l,onError:c,onReadyToSubmitChange:d,...u}=a,p={...u,initialItems:n?[n]:[],maxItems:1,sortable:!1,onChange:N=>{t==null||t(N[0]||null)},onUpload:i,onUploadComplete:r,onUploadError:s,onRemove:l,onError:c,onReadyToSubmitChange:d},h=za(p),v=e.computed(()=>h.items.value[0]||null),y=e.computed(()=>v.value!==null),E=e.computed(()=>h.formValues.value[0]||null);function _(N){N===null?h.clearAll():h.setItems([N])}async function C(N){const g=v.value;g&&h.removeItem(g),await h.addFiles([N])}function w(){v.value&&h.removeItem(v.value)}async function f(N){const g=v.value;g&&h.removeItem(g),await h.addFiles([N]);const S=h.items.value[0];S&&(o==null||o(g,S))}function x(){var N;(N=v.value)!=null&&N.upload&&h.cancelUpload(v.value.clientId)}async function $(){var N,g;((g=(N=v.value)==null?void 0:N.upload)==null?void 0:g.status)==="error"&&await h.retryUpload(v.value.clientId)}return{item:v,setItem:_,addFile:C,removeItem:w,replaceItem:f,cancelUpload:x,retryUpload:$,save:h.save,load:h.load,isLoading:h.isLoading,isUploading:h.isUploading,isReadyToSubmit:h.isReadyToSubmit,hasItem:y,errors:h.errors,adapter:h.adapter,formValue:E,acceptString:h.acceptString}}const q4=["accept","disabled"],Q4={class:"media-attachment__preview"},e3=["name","value"],t3=["name","value"],n3=["name","value"],o3=["name","value"],a3={key:4,class:"media-attachment__errors",role:"alert","aria-live":"polite"},i3=e.defineComponent({__name:"MediaAttachment",props:{modelValue:{default:null},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxFileSize:{},acceptedMimeTypes:{},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0},showReplaceButton:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","replace","is-ready-to-submit-change","validation-error"],setup(a,{emit:n}){const t=a,o=n,i=e.ref(null),r={initialItem:t.modelValue,modelType:t.modelType,modelId:t.modelId,collection:t.collection,maxFileSize:t.maxFileSize,acceptedMimeTypes:t.acceptedMimeTypes,disabled:t.disabled,rules:t.rules,adapterType:t.adapter,onChange:k=>{o("update:modelValue",k),o("change",k)},onUpload:k=>{o("upload",k)},onUploadComplete:k=>{o("upload-complete",k)},onUploadError:k=>{o("upload-error",k)},onRemove:k=>{o("remove",k)},onReplace:(k,T)=>{o("replace",T)},onError:k=>{o("validation-error",k)},onReadyToSubmitChange:k=>{o("is-ready-to-submit-change",k)}},{item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:p,isLoading:h,hasItem:v,errors:y,adapter:E,formValue:_,acceptString:C}=kr(r);e.provide("mediaAdapter",E),e.watch(()=>t.modelValue,k=>{k!==s.value&&l(k)},{deep:!0});const w=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!v.value),f=e.computed(()=>({"media-attachment":!0,"media-attachment--disabled":t.disabled,"media-attachment--readonly":t.readonly,"media-attachment--loading":h.value,"media-attachment--has-item":v.value}));function x(k){k.length>0&&c(k[0])}function $(){var k;(k=i.value)==null||k.click()}function N(k){const T=k.target,F=T.files;F&&F.length>0&&u(F[0]),T.value=""}function g(k){d()}function S(k){p()}function O(k){m()}return(k,T)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(f.value)},[e.createElementVNode("input",{ref_key:"fileInputRef",ref:i,type:"file",accept:e.unref(C),disabled:k.disabled,class:"media-attachment__hidden-input",onChange:N},null,40,q4),w.value?e.renderSlot(k.$slots,"dropzone",{key:0,addFile:e.unref(c)},()=>[e.createVNode(wr,{accept:e.unref(C),multiple:!1,disabled:k.disabled,"max-file-size":k.maxFileSize,onFiles:x},null,8,["accept","disabled","max-file-size"])],!0):e.unref(v)&&e.unref(s)?e.renderSlot(k.$slots,"preview",{key:1,item:e.unref(s),remove:e.unref(d),replace:$},()=>[e.createElementVNode("div",Q4,[e.createVNode(br,{item:e.unref(s),adapter:e.unref(E),disabled:k.disabled,sortable:!1,"show-remove":!k.readonly,"show-edit":!1,onRemove:g,onRetry:S,onCancel:O},null,8,["item","adapter","disabled","show-remove"]),k.showReplaceButton&&!k.readonly&&!k.disabled&&e.unref(s).media?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-attachment__replace-button",onClick:$},[...T[0]||(T[0]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.createElementVNode("polyline",{points:"17 8 12 3 7 8"}),e.createElementVNode("line",{x1:"12",y1:"3",x2:"12",y2:"15"})],-1),e.createTextVNode(" Replace ",-1)])])):e.createCommentVNode("",!0)])],!0):e.renderSlot(k.$slots,"empty",{key:2},()=>[T[1]||(T[1]=e.createElementVNode("div",{class:"media-attachment__empty"},[e.createElementVNode("p",null,"No file selected")],-1))],!0),k.generateFormFields&&e.unref(_)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("input",{type:"hidden",name:`${k.name}[uuid]`,value:e.unref(_).uuid},null,8,e3),e.createElementVNode("input",{type:"hidden",name:`${k.name}[name]`,value:e.unref(_).name},null,8,t3),e.createElementVNode("input",{type:"hidden",name:`${k.name}[order]`,value:e.unref(_).order},null,8,n3),e.unref(_).custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${k.name}[custom_properties]`,value:JSON.stringify(e.unref(_).custom_properties)},null,8,o3)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),e.unref(y).length>0?(e.openBlock(),e.createElementBlock("div",a3,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y),F=>(e.openBlock(),e.createElementBlock("p",{key:F.code||F.message,class:"media-attachment__error"},e.toDisplayString(F.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),r3=Me(i3,[["__scopeId","data-v-26911174"]]),Ec={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"}},s3=e.defineComponent({__name:"MediaCollectionProvider",props:{modelValue:{default:()=>[]},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxItems:{},maxFileSize:{},acceptedMimeTypes:{},sortable:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","reorder","is-ready-to-submit-change","validation-error"],setup(a,{expose:n,emit:t}){const o=a,i=t,r={initialItems:o.modelValue,modelType:o.modelType,modelId:o.modelId,collection:o.collection,maxItems:o.maxItems,maxFileSize:o.maxFileSize,acceptedMimeTypes:o.acceptedMimeTypes,sortable:o.sortable,disabled:o.disabled,rules:o.rules,adapterType:o.adapter,onChange:k=>{i("update:modelValue",k),i("change",k)},onUpload:k=>{i("upload",k)},onUploadComplete:k=>{i("upload-complete",k)},onUploadError:k=>{i("upload-error",k)},onRemove:k=>{i("remove",k)},onReorder:k=>{i("reorder",k)},onError:k=>{i("validation-error",k)},onReadyToSubmitChange:k=>{i("is-ready-to-submit-change",k)}},{items:s,setItems:l,addFiles:c,removeItem:d,reorderItems:u,updateItem:m,cancelUpload:p,retryUpload:h,isLoading:v,isUploading:y,isReadyToSubmit:E,isAtMaxItems:_,errors:C,dragState:w,getDragProps:f,adapter:x,formValues:$,acceptString:N}=za(r);e.provide("mediaAdapter",x),e.provide("mediaCollection",{items:s,addFiles:c,removeItem:d,reorderItems:u}),e.watch(()=>o.modelValue,k=>{k!==s.value&&l(k)},{deep:!0});const g=e.computed(()=>({...Ec,...o.labels})),S=e.computed(()=>({accept:N.value,multiple:o.maxItems!==1,disabled:o.disabled||o.readonly||_.value})),O=e.computed(()=>({items:s.value,isLoading:v.value,isUploading:y.value,isReadyToSubmit:E.value,isAtMaxItems:_.value,errors:C.value,addFiles:c,removeItem:d,reorderItems:u,clearAll:()=>{s.value.forEach(k=>d(k))},cancelUpload:p,retryUpload:h,labels:g.value,dropzoneProps:S.value}));return n({items:s,addFiles:c,removeItem:d,reorderItems:u,updateItem:m,cancelUpload:p,retryUpload:h,isLoading:v,isUploading:y,isReadyToSubmit:E,isAtMaxItems:_,errors:C,dragState:w,getDragProps:f,adapter:x,formValues:$,acceptString:N}),(k,T)=>e.renderSlot(k.$slots,"default",e.normalizeProps(e.guardReactiveProps(O.value)))}}),l3=e.defineComponent({__name:"MediaAttachmentProvider",props:{modelValue:{default:null},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxFileSize:{},acceptedMimeTypes:{},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0},showReplaceButton:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","replace","is-ready-to-submit-change","validation-error"],setup(a,{expose:n,emit:t}){const o=a,i=t,r={initialItem:o.modelValue,modelType:o.modelType,modelId:o.modelId,collection:o.collection,maxFileSize:o.maxFileSize,acceptedMimeTypes:o.acceptedMimeTypes,disabled:o.disabled,rules:o.rules,adapterType:o.adapter,onChange:g=>{i("update:modelValue",g),i("change",g)},onUpload:g=>{i("upload",g)},onUploadComplete:g=>{i("upload-complete",g)},onUploadError:g=>{i("upload-error",g)},onRemove:g=>{i("remove",g)},onReplace:(g,S)=>{i("replace",S)},onError:g=>{i("validation-error",g)},onReadyToSubmitChange:g=>{i("is-ready-to-submit-change",g)}},{item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:p,isLoading:h,isUploading:v,isReadyToSubmit:y,hasItem:E,errors:_,adapter:C,formValue:w,acceptString:f}=kr(r);e.provide("mediaAdapter",C),e.watch(()=>o.modelValue,g=>{g!==s.value&&l(g)},{deep:!0});const x=e.computed(()=>({...Ec,...o.labels})),$=e.computed(()=>({accept:f.value,multiple:!1,disabled:o.disabled||o.readonly||E.value})),N=e.computed(()=>({item:s.value,hasItem:E.value,isLoading:h.value,isUploading:v.value,isReadyToSubmit:y.value,errors:_.value,addFile:c,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:p,labels:x.value,dropzoneProps:$.value}));return n({item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:m,retryUpload:p,isLoading:h,isUploading:v,isReadyToSubmit:y,hasItem:E,errors:_,adapter:C,formValue:w,acceptString:f}),(g,S)=>e.renderSlot(g.$slots,"default",e.normalizeProps(e.guardReactiveProps(N.value)))}}),c3=["name","value"],d3=["name","value"],u3=["name","value"],m3=["name","value"],p3=e.defineComponent({__name:"MediaHiddenFields",props:{items:{default:()=>[]},item:{default:null},name:{default:"media"},format:{default:"mediables"}},setup(a){const n=a,t=e.computed(()=>n.item?[n.item]:n.items),o=e.computed(()=>fr(t.value));function i(l,c){var u;const d=((u=o.value[l])==null?void 0:u.uuid)||"";return`${n.name}[${d}][${c}]`}function r(l,c){return`${n.name}[${l}][${c}]`}function s(l,c){return n.format==="spatie"?i(l,c):r(l,c)}return(l,c)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(d,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:d.uuid},[e.createElementVNode("input",{type:"hidden",name:s(u,"uuid"),value:d.uuid},null,8,c3),e.createElementVNode("input",{type:"hidden",name:s(u,"name"),value:d.name},null,8,d3),e.createElementVNode("input",{type:"hidden",name:s(u,"order"),value:d.order},null,8,u3),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,m3)):e.createCommentVNode("",!0)],64))),128))}});exports.AlbumBrowser=vc;exports.AlbumManager=WE;exports.AlbumMediaGrid=n4;exports.AlbumTree=hc;exports.ArrayBufferTarget=Ji;exports.ImageEditor=Ys;exports.ImageEditorModal=Ks;exports.LiveStreamManager=gE;exports.ManagedMediaGallery=Jd;exports.MediaAttachment=r3;exports.MediaCollection=K4;exports.MediaCollectionDropzone=wr;exports.MediaCollectionItem=br;exports.MediaWorkspace=Zd;exports.ModelMediaManager=Wm;exports.Muxer=xl;exports.VideoEditor=Li;exports.VideoEditorDialog=eb;exports.VideoEditorSimple=Vb;exports.VideoExportPanel=ok;exports.VideoJobClient=mr;exports.VideoPlayer=mc;exports.VideoTimeline=Gb;exports.VideoToolsPanel=U2;exports.VideoUploader=Wk;exports._sfc_main=s3;exports._sfc_main$1=l3;exports._sfc_main$2=p3;exports.applyTemporaryMediaStoreConfig=Gs;exports.configureMediaStore=In;exports.createAdapter=gc;exports.createEmptyEditorState=Bd;exports.createImageEditor=a4;exports.createMediablesAdapter=hr;exports.createSpatieAdapter=vr;exports.deserializeEditorState=Md;exports.formatFileSize=ha;exports.fromMediaArray=zi;exports.getFileExtension=yc;exports.getImageDimensions=wc;exports.getMediablesAdapter=i4;exports.getSpatieAdapter=l4;exports.isImageFile=gr;exports.normalizeEditorState=Pi;exports.resetMediablesAdapter=r4;exports.resetSpatieAdapter=c4;exports.restoreMediaStoreConfig=Hs;exports.serializeEditorState=Zs;exports.snapshotMediaStoreConfig=Xs;exports.toFormValues=fr;exports.useAdminMediaStore=Js;exports.useAlbumDragDrop=fc;exports.useAlbumStore=La;exports.useAlbums=pc;exports.useGlobalImageEditor=o4;exports.useImageEditorModal=pr;exports.useMediaAttachment=kr;exports.useMediaCollection=za;exports.useMediaDragSort=xc;exports.useMediaStore=kt;exports.useMediaUploadQueue=kc;exports.useMediaValidation=yr;exports.validateFile=bc;
|
|
342
|
-
//# sourceMappingURL=index-wOQ7eP9R.cjs.map
|