@codingfactory/mediables-vue 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{PixiFrameExporter-D_yS7r_n.cjs → PixiFrameExporter-DT4-swZ4.cjs} +2 -2
- package/dist/{PixiFrameExporter-D_yS7r_n.cjs.map → PixiFrameExporter-DT4-swZ4.cjs.map} +1 -1
- package/dist/{PixiFrameExporter-DClr376o.js → PixiFrameExporter-HWfgnNTX.js} +2 -2
- package/dist/{PixiFrameExporter-DClr376o.js.map → PixiFrameExporter-HWfgnNTX.js.map} +1 -1
- package/dist/composables/useVideoEditor.d.ts +1 -1
- package/dist/{index-yxrF48R3.js → index-BR9cD87d.js} +8198 -8092
- package/dist/{index-yxrF48R3.js.map → index-BR9cD87d.js.map} +1 -1
- package/dist/index-Bu6zs7yN.cjs +39 -0
- package/dist/{index-DvFmBczx.cjs.map → index-Bu6zs7yN.cjs.map} +1 -1
- package/dist/mediables-vue.cjs +1 -1
- package/dist/mediables-vue.mjs +1 -1
- package/dist/render-page/assets/{index-SU1f_egA.js → index-DykUbryA.js} +60 -7
- package/dist/render-page/index.html +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/index-DvFmBczx.cjs +0 -39
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";var Dd=Object.defineProperty;var Ud=(n,o,t)=>o in n?Dd(n,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[o]=t;var U=(n,o,t)=>Ud(n,typeof o!="symbol"?o+"":o,t);const Ca=require("pinia"),e=require("vue"),Oe=require("pixi.js"),Et=require("./index-HREFg1jF.cjs"),yl=require("pixi-filters"),B=require("@ionic/vue");function bl(n){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(o,t,a.get?a:{enumerable:!0,get:()=>n[t]})}}return o.default=n,Object.freeze(o)}const Ae=bl(Oe),Ie=bl(yl);let xt={apiBaseUrl:"/api/v1",isAdmin:!1};function Dn(n){xt={...xt,...n}}function wl(){return{...xt}}function kl(n){xt={...n}}function xl(n){const o=wl();return Dn(n),()=>{kl(o)}}const Od=async(n,o={})=>{var l;const t=(l=document.querySelector('meta[name="csrf-token"]'))==null?void 0:l.getAttribute("content"),a={Accept:"application/json",...o.headers};t&&(a["X-CSRF-TOKEN"]=t),o.body instanceof FormData||(a["Content-Type"]="application/json");const i={method:o.method||"GET",headers:a,credentials:"include"};o.body instanceof FormData?i.body=o.body:o.body!==void 0&&(i.body=JSON.stringify(o.body));const s=await fetch(n,i);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()},wt=Ca.defineStore("media",()=>{const n=e.ref([]),o=e.ref([]),t=e.ref(!1),a=e.ref(null),r=e.ref(1),i=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),p=e.ref(new Map),m=e.ref(new Map),f=e.ref(new Set),v=e.ref(new Map),b=e.ref({}),S=5*60*1e3,M=e.computed(()=>{if(xt.apiScope)return xt.apiScope;if(xt.isAdmin)return"admin"}),E=e.computed(()=>M.value==="admin");function y(){return xt.httpClient||Od}function h(ee){const ue=xt.apiBaseUrl||"/api/v1",ge=M.value?`/${M.value}`:"";return`${ue}${ge}${ee}`}function w(ee,ue){return`${M.value??"default"}-${ee}-${JSON.stringify(ue)}`}function R(ee){return Date.now()-ee<S}function N(){v.value.clear(),b.value={}}function g(ee){if(!ee||!ee.data)return;const ue={};ee.data.forEach(ge=>{const xe=`${ge.file_name}-${ge.collection_name||"default"}`,ne=ue[xe];(!ne||Object.keys(ge.generated_conversions||{}).length>Object.keys(ne.generated_conversions||{}).length)&&(ue[xe]=ge)}),n.value=Object.values(ue),ee.meta&&(r.value=ee.meta.current_page,i.value=Math.ceil(ee.meta.total/ee.meta.per_page))}async function C(ee=1,ue={}){const ge=w(ee,ue),xe=v.value.get(ge);if(xe&&R(xe.timestamp)){const ne=xe.data;return g(ne),ne}t.value=!0,a.value=null;try{const ne=new URLSearchParams;ne.append("page",ee.toString()),ne.append("per_page",s.value.toString()),E.value&&ne.append("linked","1");for(const qe in ue)if(Object.prototype.hasOwnProperty.call(ue,qe)){const ct=ue[qe];ct!=null&&ct!==""&&ne.append(qe,String(ct))}const he=await y()(h(`/media?${ne}`));return v.value.set(ge,{data:he,timestamp:Date.now()}),g(he),he}catch(ne){throw a.value=ne instanceof Error?ne.message:"Failed to fetch media",n.value=[],new Error(a.value)}finally{t.value=!1}}async function A(ee,ue){t.value=!0,a.value=null;const ge=`${ee.name}-${Date.now()}`,xe={file:ee,progress:0,status:"uploading"};p.value.set(ge,xe);try{const ne=new FormData;ne.append("file",ee),ne.append("collection",ue.collection),ue.ownerUuid&&(ne.append("owner_uuid",ue.ownerUuid),ne.append("owner_type",ue.ownerType||"")),ue.usageUuid&&(ne.append("usage_uuid",ue.usageUuid),ne.append("usage_type",ue.usageType||""),ne.append("usage_purpose",ue.usagePurpose||"")),ue.customProperties&&ne.append("custom_properties",JSON.stringify(ue.customProperties));const he=await y()(h("/media"),{method:"POST",body:ne});return xe.status="completed",xe.progress=100,xe.media=he==null?void 0:he.data,r.value===1&&(he!=null&&he.data)&&(n.value=[he.data,...n.value]),N(),(he==null?void 0:he.data)||null}catch(ne){throw xe.status="error",xe.error=ne instanceof Error?ne.message:"Upload failed",a.value=xe.error,new Error(a.value)}finally{t.value=!1,setTimeout(()=>{p.value.delete(ge)},5e3)}}async function x(ee){t.value=!0,a.value=null;const ue=n.value.findIndex(xe=>xe.uuid===ee);let ge;ue!==-1&&(ge=n.value.splice(ue,1)[0]);try{return await y()(h(`/media/${ee}`),{method:"DELETE"}),f.value.delete(ee),N(),!0}catch(xe){throw ge&&ue!==-1&&n.value.splice(ue,0,ge),a.value=xe instanceof Error?xe.message:"Failed to delete media",new Error(a.value)}finally{t.value=!1}}async function T(ee,ue){t.value=!0,a.value=null;try{const xe=await y()(h(`/media/${ee}`),{method:"PATCH",body:ue,data:ue});if(xe!=null&&xe.data){const ne=n.value.findIndex(ke=>ke.uuid===ee);return ne!==-1&&(n.value[ne]={...n.value[ne],...xe.data}),N(),xe.data}return null}catch(ge){throw a.value=ge instanceof Error?ge.message:"Failed to update media",new Error(a.value)}finally{t.value=!1}}async function I(){t.value=!0,a.value=null;try{const ue=await y()(h("/media/collections"));return o.value=(ue==null?void 0:ue.data)||[],o.value}catch(ee){throw a.value=ee instanceof Error?ee.message:"Failed to fetch collections",o.value=[],new Error(a.value)}finally{t.value=!1}}async function z(ee,ue,ge="images",xe){d.value=!0,u.value=null;try{const ne=new URLSearchParams;ne.append("collection",ge),xe&&ne.append("search",xe);const he=await y()(h(`/media/model/${ee}/${ue}?${ne}`));return he!=null&&he.data?(c.value=he.data,he.data):[]}catch(ne){throw u.value=ne instanceof Error?ne.message:"Failed to fetch model media",c.value=[],new Error(u.value)}finally{d.value=!1}}async function P(ee,ue,ge,xe="images"){d.value=!0,u.value=null;const ne=[...c.value];try{const he=await y()(h(`/media/model/${ee}/${ue}/attach`),{method:"POST",body:{media_uuids:ge,collection:xe}});return await z(ee,ue,xe),(he==null?void 0:he.data)||[]}catch(ke){throw c.value=ne,u.value=ke instanceof Error?ke.message:"Failed to attach media",new Error(u.value)}finally{d.value=!1}}async function j(ee,ue,ge,xe="images"){d.value=!0,u.value=null;const ne=[...c.value];c.value=c.value.filter(ke=>ke.uuid!==ge);try{return await y()(h(`/media/model/${ee}/${ue}/detach`),{method:"POST",body:{media_uuid:ge,collection:xe}}),!0}catch(ke){throw c.value=ne,u.value=ke instanceof Error?ke.message:"Failed to detach media",new Error(u.value)}finally{d.value=!1}}async function L(ee,ue,ge,xe="images"){d.value=!0,u.value=null;const ne=[...c.value],ke=new Map(c.value.map(he=>[he.uuid,he]));c.value=ge.map(he=>ke.get(he)).filter(he=>he!==void 0);try{return await y()(h(`/media/model/${ee}/${ue}/reorder`),{method:"POST",body:{media_uuids:ge,collection:xe}}),!0}catch(he){throw c.value=ne,u.value=he instanceof Error?he.message:"Failed to reorder media",new Error(u.value)}finally{d.value=!1}}async function _(ee,ue,ge={}){const xe=y(),ne=xt.apiBaseUrl||"/api/v1",ke={image_data:ue.imageData,filters:ue.metadata.filters,crop_data:ue.metadata.cropRect,save_as_new:!0,as_variant:ge.asVariant===!0};return ge.name!==void 0&&(ke.name=ge.name),(await xe(`${ne}/editor/${ee}/save`,{method:"POST",body:ke})).media}function D(ee,ue,ge){l.value=ge!==void 0?{type:ee,uuid:ue,collection:ge}:{type:ee,uuid:ue},b.value[`${ee}-${ue}`]={timestamp:Date.now()}}function G(){l.value={type:null,uuid:null},c.value=[],u.value=null}async function X(){if(!l.value.type||!l.value.uuid)return;const ee=await z(l.value.type,l.value.uuid,l.value.collection||"images");c.value=ee||[]}function ce(){n.value.forEach(ee=>f.value.add(ee.uuid))}function Me(){f.value.clear()}function $e(ee){f.value.has(ee)?f.value.delete(ee):f.value.add(ee)}function ae(ee){return f.value.has(ee)}function F(){return Array.from(p.value.values()).some(ee=>ee.status==="uploading")}function O(ee){return p.value.get(ee)||m.value.get(ee)}function de(){return[...Array.from(p.value.values()),...Array.from(m.value.values())]}async function re(){const ee=Array.from(f.value);let ue=0;for(const ge of ee)try{await x(ge),ue++}catch{}return Me(),ue}function q(ee,ue){var ge;return ue&&((ge=ee.conversion_urls)!=null&&ge[ue])?ee.conversion_urls[ue]||"":ee.original_url||ee.url||""}return{items:n,collections:o,loading:t,error:a,currentPage:r,totalPages:i,itemsPerPage:s,isAdmin:E,modelContext:l,modelMedia:c,isLoadingModelMedia:d,modelMediaError:u,selectedItems:f,uploadProgress:p,uploadQueue:m,cachedResponses:b,fetchMedia:C,uploadFile:A,deleteMedia:x,updateMedia:T,clearCache:N,fetchCollections:I,fetchModelMedia:z,attachMedia:P,detachMedia:j,reorderMedia:L,saveEditedImage:_,setModelContext:D,clearModelContext:G,refreshModelMedia:X,selectAllItems:ce,clearSelection:Me,toggleSelection:$e,isSelected:ae,deleteSelectedItems:re,hasActiveUploads:F,getUploadProgress:O,getAllUploadProgress:de,getMediaUrl:q}}),Sl=()=>((xt.apiScope!=="admin"||xt.isAdmin!==!0)&&Dn({...xt,apiScope:"admin",isAdmin:!0}),wt()),en=new Map,uo=new Map;function Ne(n){var o;return en.has(n.id),en.set(n.id,n),uo.has(n.category)||uo.set(n.category,[]),(o=uo.get(n.category))==null||o.push(n.id),n}function El(n){return en.get(n)}function yo(){return Array.from(en.values())}function Ld(){yo().map(a=>a.id);const n=Ie,o=Object.entries(Ie).filter(([a])=>/Filter$/.test(a)&&typeof n[a]=="function");process.env.NODE_ENV;let t=0;o.forEach(([a,r])=>{const i=a.replace(/Filter$/,"").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();en.has(i)||(process.env.NODE_ENV,t++,Ne({id:i,name:a.replace(/Filter$/,""),category:"unlisted",defaultParams:{},controls:[],createFilter:(s={})=>{try{return new r(s)}catch{return null}}}))}),process.env.NODE_ENV!=="production"&&t>0}function Vl(n){return(uo.get(n)||[]).map(t=>en.get(t)).filter(Boolean)}function Wd(){return Array.from(uo.keys())}function jd(){return Array.from(en.values()).map(n=>({id:n.id,name:n.name,category:n.category,controls:n.controls}))}if(typeof window<"u"){window.__DEBUG_FILTERS_LIST=Array.from(en.keys()),window.getAllFilters=yo,window.getFilter=El,window.getFiltersByCategory=Vl,window.getRegisteredFilters=jd;const n=Ne;window.registerFilter=o=>{const t=n(o);return window.__DEBUG_FILTERS_LIST=Array.from(en.keys()),t}}typeof window<"u"&&(window.initializeFilterRegistry=window.initializeFilterRegistry||function(){return[]});const{AdjustmentFilter:Xd}=Ie,{ColorMatrixFilter:Zd}=Ae,Ot={gamma:1,saturation:1,contrast:1,brightness:1,red:1,green:1,blue:1,alpha:1},Yd=new Set(["gamma","saturation","contrast","brightness","red","green","blue","alpha"]);function Lt(n,o){if(typeof n=="number"&&Number.isFinite(n))return n;if(typeof n=="string"){const t=Number(n);if(Number.isFinite(t))return t}return o}function us(n){return Yd.has(n)}function Gd(n){return{gamma:Lt(n.gamma,Ot.gamma),saturation:Lt(n.saturation,Ot.saturation),contrast:Lt(n.contrast,Ot.contrast),brightness:Lt(n.brightness,Ot.brightness),red:Lt(n.red,Ot.red),green:Lt(n.green,Ot.green),blue:Lt(n.blue,Ot.blue),alpha:Lt(n.alpha,Ot.alpha)}}function ms(n,o){n.reset(),n.brightness(o.brightness,!0),n.contrast(o.contrast,!0),n.saturate(o.saturation,!0)}Ne({id:"adjustment",name:"Adjustment",category:"adjust",description:"Adjust basic image properties like brightness, contrast, and saturation",createFilter:n=>{try{const o=Gd(n??{}),t={...o};try{const a=new Xd(t),r=a;return r._customParams={...o},r.updateUIParam=function(s,l){try{if(!us(s))return;const c=this._customParams??{...Ot},d=Lt(l,c[s]);c[s]=d,this._customParams=c;const u=this;s in u&&(u[s]=d)}catch{}},a}catch{const r=new Zd,i=r;return i._customParams={...o},ms(r,o),i.updateUIParam=function(l,c){try{if(!us(l))return;const d=this._customParams??{...Ot},u=Lt(c,d[l]);d[l]=u,this._customParams=d,ms(this,d)}catch{}},r}}catch{return null}},defaultParams:{gamma:1,saturation:1,contrast:1,brightness:1,red:1,green:1,blue:1,alpha:1},controls:[{id:"brightness",type:"slider",label:"Brightness",property:"brightness",min:0,max:2,step:.01,default:1},{id:"contrast",type:"slider",label:"Contrast",property:"contrast",min:0,max:2,step:.01,default:1},{id:"saturation",type:"slider",label:"Saturation",property:"saturation",min:0,max:2,step:.01,default:1},{id:"gamma",type:"slider",label:"Gamma",property:"gamma",min:.1,max:3,step:.01,default:1},{id:"red",type:"slider",label:"Red",property:"red",min:0,max:2,step:.01,default:1},{id:"green",type:"slider",label:"Green",property:"green",min:0,max:2,step:.01,default:1},{id:"blue",type:"slider",label:"Blue",property:"blue",min:0,max:2,step:.01,default:1},{id:"alpha",type:"slider",label:"Alpha",property:"alpha",min:0,max:1,step:.01,default:1}]});const{ColorMatrixFilter:Hd}=Ae,mn={brightness:1,contrast:1,saturation:1,hue:0,sepia:0,negative:!1},Jd=new Set(["brightness","contrast","saturation","hue","sepia","negative"]);function qd(n){return Jd.has(n)}function Rn(n,o){if(typeof n=="number"&&Number.isFinite(n))return n;if(typeof n=="string"){const t=Number(n);if(Number.isFinite(t))return t}return o}function Cl(n,o){if(typeof n=="boolean")return n;if(typeof n=="string"){if(n==="true")return!0;if(n==="false")return!1}return o}function Kd(n){return{brightness:Rn(n.brightness,mn.brightness),contrast:Rn(n.contrast,mn.contrast),saturation:Rn(n.saturation,mn.saturation),hue:Rn(n.hue,mn.hue),sepia:Rn(n.sepia,mn.sepia),negative:Cl(n.negative,mn.negative)}}function ps(n,o){n.reset(),o.brightness!==1&&n.brightness(o.brightness,!0),o.contrast!==1&&n.contrast(o.contrast,!0),o.saturation!==1&&n.saturate(o.saturation,!0),o.hue!==0&&n.hue(o.hue,!0),o.sepia>0&&n.sepia(!0),o.negative&&n.negative(!0)}Ne({id:"adjustment-advanced",name:"Advanced Adjustment",category:"adjust",description:"Comprehensive image adjustments including brightness, contrast, saturation, hue, and more",createFilter:n=>{try{const o=Kd(n??{}),t=new Hd,a=t;return a._customParams={...o},ps(t,o),a.updateUIParam=function(i,s){try{if(!qd(i))return;const l=this._customParams??{...mn};if(i==="negative")l.negative=Cl(s,l.negative);else{const c=i;l[c]=Rn(s,l[c])}this._customParams=l,ps(this,l)}catch{}},t}catch{return null}},defaultParams:{brightness:1,contrast:1,saturation:1,hue:0,sepia:0,negative:!1},controls:[{id:"brightness",type:"slider",label:"Brightness",property:"brightness",min:0,max:2,step:.01,default:1},{id:"contrast",type:"slider",label:"Contrast",property:"contrast",min:0,max:2,step:.01,default:1},{id:"saturation",type:"slider",label:"Saturation",property:"saturation",min:0,max:2,step:.01,default:1},{id:"hue",type:"slider",label:"Hue Rotation",property:"hue",min:0,max:360,step:1,default:0},{id:"sepia",type:"slider",label:"Sepia",property:"sepia",min:0,max:1,step:.01,default:0},{id:"negative",type:"toggle",label:"Negative",property:"negative",default:!1}]});Ne({id:"alpha",name:"Alpha",category:"adjust",description:"Adjust the transparency of the image",createFilter:n=>{try{const o=n.alpha!==void 0?n.alpha:1,t=new Ae.ColorMatrixFilter;return t.alpha=o,t._customParams={alpha:o},t.updateUIParam=function(a,r){try{const i=this._customParams||{};if(this._customParams=i,a==="alpha"){const s=Number(r);this.alpha=s,i.alpha=s}else a in this&&(this[a]=r)}catch{}},t}catch{return null}},defaultParams:{alpha:1},controls:[{id:"alpha",type:"slider",label:"Transparency",property:"alpha",min:0,max:1,step:.01,default:1}]});Ne({id:"blur",name:"Blur",category:"blur",description:"Apply a smooth blur effect to the entire image",createFilter:n=>{try{const o=new Ae.BlurFilter({strength:n.strength||8,quality:n.quality||4,kernelSize:n.kernelSize||5});return o._customParams={...n},o.updateUIParam=function(t,a){const r=this._customParams||{};switch(this._customParams=r,r[t]=a,t){case"strength":this.strength=a;break;case"quality":this.quality=a;break;case"kernelSize":this.blurXFilter.kernelSize=a,this.blurYFilter.kernelSize=a;break;default:t in this&&(this[t]=a);break}return!0},o}catch{return null}},defaultParams:{strength:8,quality:4,kernelSize:5},controls:[{id:"strength",type:"slider",label:"Strength",property:"strength",min:0,max:20,step:.1,default:8},{id:"quality",type:"slider",label:"Quality",property:"quality",min:1,max:10,step:1,default:4},{id:"kernelSize",type:"select",label:"Kernel Size",property:"kernelSize",options:[{label:"5",value:5},{label:"7",value:7},{label:"9",value:9},{label:"11",value:11},{label:"13",value:13},{label:"15",value:15}],default:5}]});Ne({id:"color-matrix",name:"Color Matrix",category:"adjustment",description:"Advanced color adjustments including sepia, hue rotation, and more",createFilter:n=>{const o=Ae.ColorMatrixFilter;if(!o)return null;const t=new o;try{return typeof t.reset=="function"&&t.reset(),n.brightness!==1&&typeof t.brightness=="function"&&t.brightness(n.brightness,!1),n.contrast!==1&&typeof t.contrast=="function"&&t.contrast(n.contrast,!1),n.saturation!==1&&typeof t.saturate=="function"&&t.saturate(n.saturation,!1),n.hue!==0&&typeof t.hue=="function"&&t.hue(n.hue,!1),n.sepia>0&&typeof t.sepia=="function"&&t.sepia(n.sepia),n.negative&&typeof t.negative=="function"&&t.negative(!1),t}catch{return t}},defaultParams:{brightness:1,contrast:1,saturation:1,hue:0,sepia:0,negative:!1},controls:[{id:"brightness",type:"slider",label:"Brightness",property:"brightness",min:0,max:2,step:.01,default:1},{id:"contrast",type:"slider",label:"Contrast",property:"contrast",min:0,max:2,step:.01,default:1},{id:"saturation",type:"slider",label:"Saturation",property:"saturation",min:0,max:2,step:.01,default:1},{id:"hue",type:"slider",label:"Hue Rotation",property:"hue",min:0,max:360,step:1,default:0},{id:"sepia",type:"slider",label:"Sepia",property:"sepia",min:0,max:1,step:.01,default:0},{id:"negative",type:"toggle",label:"Negative",property:"negative",default:!1}]});const{ColorOverlayFilter:Qd}=Ie;Ne({id:"colorOverlay",name:"Color Overlay",category:"color",description:"Apply a colored tint or overlay to the entire image",createFilter:n=>{try{let o=16711680;n.color&&(typeof n.color=="string"?o=parseInt(n.color.replace("#","0x"),16):typeof n.color=="number"&&(o=n.color));const t=new Qd({color:o,alpha:n.alpha||.5});return t._customParams={...n},t.updateUIParam=function(a,r){const i=this._customParams||{};switch(this._customParams=i,i[a]=r,a){case"color":typeof r=="string"?this.color=parseInt(r.replace("#","0x"),16):typeof r=="number"&&(this.color=r);break;case"alpha":this.alpha=r;break;default:a in this&&(this[a]=r);break}return!0},t}catch{return null}},defaultParams:{color:"#ff0000",alpha:.5},controls:[{id:"color",type:"color",label:"Color",property:"color",default:"#ff0000"},{id:"alpha",type:"slider",label:"Opacity",property:"alpha",min:0,max:1,step:.01,default:.5}]});Ne({id:"drop-shadow",name:"Drop Shadow",category:"effects",description:"Add a soft drop shadow to the image",createFilter:n=>{try{const o=n.color?n.color.replace("#","0x"):"0x000000",t=n.distance!==void 0?n.distance:5,a=n.angle!==void 0?n.angle:90,r={x:t*Math.cos(a*Math.PI/180),y:t*Math.sin(a*Math.PI/180)},i=new Ie.DropShadowFilter({offset:r,color:parseInt(o,16),alpha:n.alpha!==void 0?n.alpha:.5,blur:n.blur!==void 0?n.blur:2,quality:n.quality!==void 0?n.quality:3,shadowOnly:n.shadowOnly!==void 0?n.shadowOnly:!1,pixelSize:{x:n.pixelSizeX!==void 0?n.pixelSizeX:1,y:n.pixelSizeY!==void 0?n.pixelSizeY:1}});return i._customParams={...n,_offset:r,_distance:t,_angle:a},i.updateUIParam=function(s,l){try{const c=this._customParams||{};switch(this._customParams=c,c[s]=l,s){case"color":if(typeof l=="string"){const u=parseInt(l.replace("#","0x"),16);this.color=u}break;case"alpha":this.alpha=Number(l);break;case"blur":this.blur=Number(l);break;case"quality":this.quality=Number(l);break;case"shadowOnly":this.shadowOnly=!!l;break;case"pixelSizeX":this.pixelSizeX=Number(l),c.pixelSizeX=Number(l);break;case"pixelSizeY":this.pixelSizeY=Number(l),c.pixelSizeY=Number(l);break;case"distance":case"angle":s==="distance"?c._distance=Number(l):c._angle=Number(l);const d={x:c._distance*Math.cos(c._angle*Math.PI/180),y:c._distance*Math.sin(c._angle*Math.PI/180)};c._offset=d,this.offset=d;break;default:s in this&&(this[s]=l);break}return!0}catch{return this._customParams&&(this._customParams[s]=l),!1}},i}catch{return null}},defaultParams:{alpha:.5,blur:2,color:"#000000",distance:5,angle:90,quality:3,shadowOnly:!1,pixelSizeX:1,pixelSizeY:1},controls:[{id:"alpha",type:"slider",label:"Opacity",property:"alpha",min:0,max:1,step:.01,default:.5},{id:"blur",type:"slider",label:"Blur",property:"blur",min:0,max:20,step:.1,default:2},{id:"color",type:"color",label:"Color",property:"color",default:"#000000"},{id:"distance",type:"slider",label:"Distance",property:"distance",min:0,max:50,step:1,default:5},{id:"angle",type:"slider",label:"Angle",property:"angle",min:0,max:360,step:1,default:90},{id:"quality",type:"slider",label:"Quality",property:"quality",min:1,max:10,step:1,default:3},{id:"shadowOnly",type:"toggle",label:"Shadow Only",property:"shadowOnly",default:!1},{id:"pixelSizeX",type:"slider",label:"Pixel Size X",property:"pixelSizeX",min:.5,max:8,step:.5,default:1},{id:"pixelSizeY",type:"slider",label:"Pixel Size Y",property:"pixelSizeY",min:.5,max:8,step:.5,default:1}]});Ne({id:"grayscale",name:"Grayscale",category:"color",description:"Convert the image to black and white with adjustable intensity",createFilter:n=>{try{const o=new Oe.ColorMatrixFilter;o._customParams={...n};const t=n.intensity!==void 0?n.intensity:1;return fs(o,t),o.updateUIParam=function(a,r){const i=this._customParams||{};switch(this._customParams=i,i[a]=r,a){case"intensity":fs(this,r);break;default:a in this&&(this[a]=r);break}return!0},o}catch{return null}},defaultParams:{intensity:.35},controls:[{id:"intensity",type:"slider",label:"Intensity",property:"intensity",min:0,max:1,step:.01,default:.35}]});function fs(n,o){n.reset(),n.greyscale(o,!1)}const{HslAdjustmentFilter:eu}=Ie;Ne({id:"hsl-adjustment",name:"HSL Adjustment",category:"color",description:"Control hue, saturation, and lightness independently",createFilter:n=>{try{const o=new eu({hue:n.hue!==void 0?n.hue:0,saturation:n.saturation!==void 0?n.saturation:0,lightness:n.lightness!==void 0?n.lightness:0,colorize:n.colorize!==void 0?n.colorize:!1,alpha:n.alpha!==void 0?n.alpha:1});return o._customParams={...n},o.updateUIParam=function(t,a){try{const r=this._customParams||{};switch(this._customParams=r,r[t]=a,t){case"hue":this.hue=Number(a);break;case"saturation":this.saturation=Number(a);break;case"lightness":this.lightness=Number(a);break;case"colorize":this.colorize=!!a;break;case"alpha":this.alpha=Number(a);break;default:t in this&&(this[t]=a);break}return!0}catch{return this._customParams&&(this._customParams[t]=a),!1}},o}catch{return null}},defaultParams:{hue:0,saturation:0,lightness:0,colorize:!1,alpha:1},controls:[{id:"hue",type:"slider",label:"Hue",property:"hue",min:-180,max:180,step:1,default:0},{id:"saturation",type:"slider",label:"Saturation",property:"saturation",min:-1,max:1,step:.01,default:0},{id:"lightness",type:"slider",label:"Lightness",property:"lightness",min:-1,max:1,step:.01,default:0},{id:"colorize",type:"toggle",label:"Colorize",property:"colorize",default:!1},{id:"alpha",type:"slider",label:"Alpha",property:"alpha",min:0,max:1,step:.01,default:1}]});const{KawaseBlurFilter:tu}=Ie;Ne({id:"kawase-blur",name:"Kawase Blur",category:"blur",description:"A more optimized blur algorithm that is faster than standard blur",createFilter:n=>{try{const o=new tu({strength:n.strength||4,quality:n.quality||3,clamp:n.clamp||!1,pixelSize:n.pixelSize||1});return o._customParams={...n},o.updateUIParam=function(t,a){const r=this._customParams||{};switch(this._customParams=r,r[t]=a,t){case"strength":this.strength=a;break;case"quality":this.quality=a;break;case"clamp":this.clamp=a;break;case"pixelSize":typeof a=="number"?this.pixelSize=a:typeof a=="object"&&a!==null&&"x"in a&&"y"in a&&(this.pixelSize=a);break;case"pixelSizeX":this.pixelSizeX=a;break;case"pixelSizeY":this.pixelSizeY=a;break;default:t in this&&(this[t]=a);break}return!0},o}catch{return null}},defaultParams:{strength:4,quality:3,clamp:!1,pixelSize:1},controls:[{id:"strength",type:"slider",label:"Strength",property:"strength",min:0,max:20,step:.1,default:4},{id:"quality",type:"slider",label:"Quality",property:"quality",min:1,max:10,step:1,default:3},{id:"clamp",type:"toggle",label:"Clamp Edges",property:"clamp",default:!1},{id:"pixelSize",type:"slider",label:"Pixel Size",property:"pixelSize",min:.5,max:10,step:.5,default:1},{id:"pixelSizeX",type:"slider",label:"Pixel Size X",property:"pixelSizeX",min:.5,max:10,step:.5,default:1},{id:"pixelSizeY",type:"slider",label:"Pixel Size Y",property:"pixelSizeY",min:.5,max:10,step:.5,default:1}]});const{MotionBlurFilter:nu}=Ie;Ne({id:"motion-blur",name:"Motion Blur",category:"blur",description:"Creates a directional blur effect simulating motion",createFilter:n=>{try{const o=new nu({velocity:{x:n.velocityX!==void 0?n.velocityX:0,y:n.velocityY!==void 0?n.velocityY:0},kernelSize:n.kernelSize||5,offset:n.offset!==void 0?n.offset:0});return o._customParams={...n},o.updateUIParam=function(t,a){const r=this._customParams||{};switch(this._customParams=r,r[t]=a,t){case"velocityX":this.velocityX=a;break;case"velocityY":this.velocityY=a;break;case"kernelSize":this.kernelSize=a;break;case"offset":this.offset=a;break;default:t in this&&(this[t]=a);break}return!0},o}catch{return null}},defaultParams:{velocityX:0,velocityY:0,kernelSize:5,offset:0},controls:[{id:"velocityX",type:"slider",label:"Velocity X",property:"velocityX",min:-40,max:40,step:.5,default:0},{id:"velocityY",type:"slider",label:"Velocity Y",property:"velocityY",min:-40,max:40,step:.5,default:0},{id:"kernelSize",type:"select",label:"Kernel Size",property:"kernelSize",options:[{label:"5",value:5},{label:"7",value:7},{label:"9",value:9},{label:"11",value:11},{label:"13",value:13},{label:"15",value:15}],default:5},{id:"offset",type:"slider",label:"Offset",property:"offset",min:0,max:20,step:.1,default:0}]});const{RadialBlurFilter:ou}=Ie;Ne({id:"radial-blur",name:"Radial Blur",category:"blur",description:"Creates a circular blur effect emanating from a center point",createFilter:n=>{try{const o=new ou({angle:n.angle||10,center:{x:n.centerX||0,y:n.centerY||0},kernelSize:n.kernelSize||5,radius:n.radius??-1});return o._customParams={centerX:n.centerX||0,centerY:n.centerY||0},o.updateUIParam=function(t,a){try{switch(t){case"angle":this.angle=Number(a);break;case"centerX":this._customParams.centerX=Number(a),this.center={x:Number(a),y:this._customParams.centerY};break;case"centerY":this._customParams.centerY=Number(a),this.center={x:this._customParams.centerX,y:Number(a)};break;case"kernelSize":this.kernelSize=Number(a);break;case"radius":this.radius=Number(a);break;default:}}catch{}},o}catch{return null}},defaultParams:{angle:10,centerX:0,centerY:0,kernelSize:5,radius:-1},controls:[{id:"angle",type:"slider",label:"Angle",property:"angle",min:0,max:360,step:1,default:10},{id:"centerX",type:"slider",label:"Center X",property:"centerX",min:-1,max:1,step:.01,default:0},{id:"centerY",type:"slider",label:"Center Y",property:"centerY",min:-1,max:1,step:.01,default:0},{id:"kernelSize",type:"select",label:"Kernel Size",property:"kernelSize",options:[{label:"3",value:3},{label:"5",value:5},{label:"7",value:7},{label:"9",value:9},{label:"11",value:11},{label:"13",value:13},{label:"15",value:15}],default:5},{id:"radius",type:"slider",label:"Radius",property:"radius",min:-1,max:1e3,step:10,default:-1}]});const{TiltShiftFilter:au}=Ie;Ne({id:"tilt-shift",name:"Tilt Shift",category:"blur",description:"Creates a depth-of-field effect simulating miniature photography",createFilter:n=>{try{const o=typeof n.blur=="number"?n.blur:100,t=typeof n.gradientBlur=="number"?n.gradientBlur:600,a=typeof n.startX=="number"?n.startX:0,r=typeof n.startY=="number"?n.startY:.5,i=typeof n.endX=="number"?n.endX:1,s=typeof n.endY=="number"?n.endY:.5,l=new au({blur:Number(o),gradientBlur:Number(t),start:{x:Number(a),y:Number(r)},end:{x:Number(i),y:Number(s)}});return l._customParams={blur:o,gradientBlur:t,startX:a,startY:r,endX:i,endY:s},l.updateUIParam=function(c,d){try{const u=Number(d),p=this._customParams||{};switch(this._customParams=p,p[c]=u,c){case"blur":this.blur=u;break;case"gradientBlur":this.gradientBlur=u;break;case"startX":this.start&&typeof this.start=="object"&&(this.start.x=u);break;case"startY":this.start&&typeof this.start=="object"&&(this.start.y=u);break;case"endX":this.end&&typeof this.end=="object"&&(this.end.x=u);break;case"endY":this.end&&typeof this.end=="object"&&(this.end.y=u);break;default:c in this&&(this[c]=u);break}}catch{}},l}catch{return null}},defaultParams:{blur:100,gradientBlur:600,startX:0,startY:.5,endX:1,endY:.5},controls:[{id:"blur",type:"slider",label:"Blur Strength",property:"blur",min:0,max:300,step:1,default:100},{id:"gradientBlur",type:"slider",label:"Gradient Width",property:"gradientBlur",min:100,max:2e3,step:10,default:600},{id:"startX",type:"slider",label:"Start X",property:"startX",min:0,max:1,step:.01,default:0},{id:"startY",type:"slider",label:"Start Y",property:"startY",min:0,max:1,step:.01,default:.5},{id:"endX",type:"slider",label:"End X",property:"endX",min:0,max:1,step:.01,default:1},{id:"endY",type:"slider",label:"End Y",property:"endY",min:0,max:1,step:.01,default:.5}]});const{ZoomBlurFilter:ru}=Ie;Ne({id:"zoom-blur",name:"Zoom Blur",category:"blur",description:"Creates a zoom blur effect from a center point",createFilter:n=>{try{const o=new ru({strength:n.strength||.1,center:{x:n.centerX!==void 0?n.centerX:.5,y:n.centerY!==void 0?n.centerY:.5},innerRadius:n.innerRadius||0,radius:n.radius!==void 0?n.radius:-1,maxKernelSize:n.maxKernelSize||32});return o._customParams={...n},o.updateUIParam=function(t,a){const r=this._customParams||{};switch(this._customParams=r,r[t]=a,t){case"strength":this.strength=a;break;case"centerX":this.centerX=a;break;case"centerY":this.centerY=a;break;case"innerRadius":this.innerRadius=a;break;case"radius":this.radius=a;break;default:t in this&&(this[t]=a);break}return!0},o}catch{return null}},defaultParams:{strength:.1,centerX:.5,centerY:.5,innerRadius:0,radius:-1,maxKernelSize:32},controls:[{id:"strength",type:"slider",label:"Strength",property:"strength",min:0,max:.5,step:.01,default:.1},{id:"centerX",type:"slider",label:"Center X",property:"centerX",min:0,max:1,step:.01,default:.5},{id:"centerY",type:"slider",label:"Center Y",property:"centerY",min:0,max:1,step:.01,default:.5},{id:"innerRadius",type:"slider",label:"Inner Radius",property:"innerRadius",min:0,max:300,step:1,default:0},{id:"radius",type:"slider",label:"Outer Radius",property:"radius",min:-1,max:1e3,step:10,default:-1},{id:"maxKernelSize",type:"select",label:"Quality",property:"maxKernelSize",options:[{label:"Low",value:16},{label:"Medium",value:32},{label:"High",value:48},{label:"Very High",value:64}],default:32}]});const{ColorGradientFilter:hs}=Ie;Ne({id:"color-gradient",name:"Color Gradient",category:"color",description:"Applies a linear, radial or conic color gradient over the image with multiple color stops",createFilter:n=>{try{let o=[];o=(n.colorStops||[{offset:0,color:"#ff0000",alpha:1},{offset:1,color:"#0000ff",alpha:1}]).map(a=>({offset:a.offset,color:typeof a.color=="string"?parseInt(a.color.replace("#","0x")):a.color,alpha:a.alpha})),o.length<2&&(o=[{offset:0,color:16711680,alpha:1},{offset:1,color:255,alpha:1}]),o.sort((a,r)=>a.offset-r.offset);const t=new hs({type:n.gradientType,stops:o,angle:n.angle,alpha:n.alpha,maxColors:n.maxColors||0,replace:n.replace});return t._customParams={...n},t.getColorStopsForUI=function(){return!this.stops||!Array.isArray(this.stops)?[]:this.stops.map(r=>({offset:r.offset,color:typeof r.color=="number"?"#"+r.color.toString(16).padStart(6,"0"):r.color,alpha:r.alpha}))},t.getDynamicControls=function(){const a=this.getColorStopsForUI(),r=[];return a.forEach((i,s)=>{r.push({id:`colorStop-${s}-color`,type:"color",label:`Stop ${s+1} Color`,property:`colorStops[${s}].color`,default:i.color}),r.push({id:`colorStop-${s}-offset`,type:"slider",label:`Stop ${s+1} Position`,property:`colorStops[${s}].offset`,min:0,max:1,step:.01,default:i.offset}),r.push({id:`colorStop-${s}-alpha`,type:"slider",label:`Stop ${s+1} Alpha`,property:`colorStops[${s}].alpha`,min:0,max:1,step:.01,default:i.alpha})}),r},t.handleButtonAction=function(a){(a==="addColorStop"||a==="removeColorStop")&&this.updateUIParam(a,!0)},t.updateUIParam=function(a,r){const i=this._customParams||{};switch(this._customParams=i,i[a]=r,a){case"gradientType":this.type=r;break;case"angle":case"alpha":case"maxColors":case"replace":a in this&&(this[a]=r);break;case"addColorStop":const s=[...this.stops],d={offset:1,alpha:1,color:(()=>{const p=Math.floor(Math.random()*255),m=Math.floor(Math.random()*255),f=Math.floor(Math.random()*255);return p<<16|m<<8|f})()};if(s.length>0){for(let m=0;m<s.length;m++)s[m].offset*=.8;d.offset=1}s.push(d),this.stops=s,i.colorStops=this.stops.map(p=>({offset:p.offset,color:typeof p.color=="number"?"#"+p.color.toString(16).padStart(6,"0"):p.color,alpha:p.alpha}));break;case"removeColorStop":const u=[...this.stops];u.length>2&&(u.pop(),this.stops=u,i.colorStops=this.stops.map(p=>({offset:p.offset,color:typeof p.color=="number"?"#"+p.color.toString(16).padStart(6,"0"):p.color,alpha:p.alpha})));break;case"cssGradient":if(r&&typeof r=="string"&&r.trim()!=="")try{const p=new hs({css:r});this.type=p.type,this.angle=p.angle,this.stops=[...p.stops],i.colorStops=this.stops.map(m=>({offset:m.offset,color:typeof m.color=="number"?"#"+m.color.toString(16).padStart(6,"0"):m.color,alpha:m.alpha}))}catch{}break;case"colorStops":if(Array.isArray(r)){const p=r.map(m=>({offset:m.offset,color:typeof m.color=="string"?parseInt(m.color.replace("#","0x")):m.color,alpha:m.alpha}));p.sort((m,f)=>m.offset-f.offset),this.stops=p}break;default:if(/colorStops\[\d+\]\..*/.test(a)){const p=a.match(/colorStops\[(\d+)\]\.(.*)/);if(p){const[m,f,v]=p,b=parseInt(f),S=[...this.stops];if(b>=0&&b<S.length)return v==="color"&&typeof r=="string"?S[b].color=parseInt(r.replace("#","0x")):(v==="offset"||v==="alpha")&&(S[b][v]=r),this.stops=S,this.stops.sort((M,E)=>M.offset-E.offset),i.colorStops=this.getColorStopsForUI(),!0}}else a in this&&(this[a]=r);break}},t}catch{return null}},defaultParams:{gradientType:0,colorStops:[{offset:0,color:"#ff0000",alpha:1},{offset:1,color:"#0000ff",alpha:1}],addColorStop:!1,removeColorStop:!1,cssGradient:"",angle:90,alpha:.75,maxColors:0,replace:!1},controls:[{id:"gradientType",type:"select",label:"Gradient Type",property:"gradientType",options:[{label:"Linear",value:0},{label:"Radial",value:1},{label:"Conic",value:2}],default:0},{id:"angle",type:"slider",label:"Angle",property:"angle",min:0,max:360,step:1,default:90},{id:"alpha",type:"slider",label:"Overall Alpha",property:"alpha",min:0,max:1,step:.01,default:.75},{id:"maxColors",type:"slider",label:"Max Colors",property:"maxColors",min:0,max:24,step:1,default:0},{id:"replace",type:"toggle",label:"Replace Original Colors",property:"replace",default:!1},{id:"addColorStop",type:"button",label:"Add New Color Stop",action:"addColorStop"},{id:"removeColorStop",type:"button",label:"Remove Last Color Stop",action:"removeColorStop"},{id:"cssGradient",type:"text",label:"CSS Gradient",property:"cssGradient",default:"",tooltip:'Enter a CSS gradient like "linear-gradient(to right, red, blue)"'}]});Ne({id:"color-map",name:"Color Map",category:"color",description:"Maps colors using a reference texture as a lookup table",createFilter:n=>{try{const o=Ie.ColorMapFilter;if(!o)return null;let t=null;n.texturePath?t=Ae.Texture.from(n.texturePath):t=Ae.Texture.from("/examples/filters-main/examples/images/colormap.png");const a=new o({colorMap:t,nearest:n.nearest,mix:n.mix});return a._customParams={...n},a.updateUIParam=function(r,i){const s=this._customParams||{};switch(this._customParams=s,s[r]=i,r){case"texturePath":i&&(this.colorMap=Ae.Texture.from(i));break;case"mix":this.mix=i;break;case"nearest":this.nearest=i;break;default:r in this&&(this[r]=i);break}return!0},a}catch{return null}},defaultParams:{texturePath:"",mix:1,nearest:!1},controls:[{id:"texturePath",type:"select",label:"Color Map",property:"texturePath",options:[{label:"Default",value:"/examples/filters-main/examples/images/colormap.png"},{label:"Grayscale",value:"/examples/filters-main/examples/images/colormap-grayscale.png"},{label:"Sepia",value:"/examples/filters-main/examples/images/colormap-sepia.png"}],default:"/examples/filters-main/examples/images/colormap.png"},{id:"mix",type:"slider",label:"Mix",property:"mix",min:0,max:1,step:.01,default:1},{id:"nearest",type:"toggle",label:"Nearest Neighbor Sampling",property:"nearest",default:!1}]});const iu=Ie.ColorReplaceFilter;Ne({id:"color-replace",name:"Color Replace",category:"color",description:"Replaces a specific color in the image with another color",createFilter:n=>{try{let o=16711680;n.originalColor&&(typeof n.originalColor=="string"?o=parseInt(n.originalColor.replace("#","0x"),16):typeof n.originalColor=="number"&&(o=n.originalColor));let t=255;n.targetColor&&(typeof n.targetColor=="string"?t=parseInt(n.targetColor.replace("#","0x"),16):typeof n.targetColor=="number"&&(t=n.targetColor));const a=new iu({originalColor:o,targetColor:t,tolerance:n.tolerance||.4});return a._customParams={...n},a.updateUIParam=function(r,i){const s=this._customParams||{};switch(this._customParams=s,s[r]=i,r){case"originalColor":typeof i=="string"?this.originalColor=parseInt(i.replace("#","0x"),16):typeof i=="number"&&(this.originalColor=i);break;case"targetColor":typeof i=="string"?this.targetColor=parseInt(i.replace("#","0x"),16):typeof i=="number"&&(this.targetColor=i);break;case"tolerance":this.tolerance=i;break;default:r in this&&(this[r]=i);break}return!0},a}catch{return null}},defaultParams:{originalColor:"#ff0000",targetColor:"#0000ff",tolerance:.4},controls:[{id:"originalColor",type:"color",label:"Original Color",property:"originalColor",default:"#ff0000"},{id:"targetColor",type:"color",label:"Target Color",property:"targetColor",default:"#0000ff"},{id:"tolerance",type:"slider",label:"Tolerance",property:"tolerance",min:0,max:1,step:.01,default:.4}]});const su=Ie.MultiColorReplaceFilter;Ne({id:"multi-color-replace",name:"Multi-Color Replace",category:"color",description:"Replaces multiple colors in the image with different target colors",createFilter:n=>{try{const o=[];if(n.originalColor1&&n.targetColor1){const a=typeof n.originalColor1=="string"?parseInt(n.originalColor1.replace("#","0x"),16):n.originalColor1,r=typeof n.targetColor1=="string"?parseInt(n.targetColor1.replace("#","0x"),16):n.targetColor1;o.push([a,r])}if(n.originalColor2&&n.targetColor2){const a=typeof n.originalColor2=="string"?parseInt(n.originalColor2.replace("#","0x"),16):n.originalColor2,r=typeof n.targetColor2=="string"?parseInt(n.targetColor2.replace("#","0x"),16):n.targetColor2;o.push([a,r])}if(n.enableThirdPair&&n.originalColor3&&n.targetColor3){const a=typeof n.originalColor3=="string"?parseInt(n.originalColor3.replace("#","0x"),16):n.originalColor3,r=typeof n.targetColor3=="string"?parseInt(n.targetColor3.replace("#","0x"),16):n.targetColor3;o.push([a,r])}const t=new su({replacements:o,tolerance:n.tolerance||.05,maxColors:3});return t._customParams={...n},t.updateUIParam=function(a,r){const i=this._customParams||{};if(this._customParams=i,i[a]=r,a==="originalColor1"||a==="targetColor1"||a==="originalColor2"||a==="targetColor2"||a==="originalColor3"||a==="targetColor3"||a==="enableThirdPair"){const s=[];if(i.originalColor1&&i.targetColor1){const l=typeof i.originalColor1=="string"?parseInt(i.originalColor1.replace("#","0x"),16):i.originalColor1,c=typeof i.targetColor1=="string"?parseInt(i.targetColor1.replace("#","0x"),16):i.targetColor1;s.push([l,c])}if(i.originalColor2&&i.targetColor2){const l=typeof i.originalColor2=="string"?parseInt(i.originalColor2.replace("#","0x"),16):i.originalColor2,c=typeof i.targetColor2=="string"?parseInt(i.targetColor2.replace("#","0x"),16):i.targetColor2;s.push([l,c])}if(i.enableThirdPair&&i.originalColor3&&i.targetColor3){const l=typeof i.originalColor3=="string"?parseInt(i.originalColor3.replace("#","0x"),16):i.originalColor3,c=typeof i.targetColor3=="string"?parseInt(i.targetColor3.replace("#","0x"),16):i.targetColor3;s.push([l,c])}this.replacements=s,this.refresh()}else a==="tolerance"?this.tolerance=r:a in this&&(this[a]=r);return!0},t}catch{return null}},defaultParams:{originalColor1:"#ff0000",targetColor1:"#0000ff",originalColor2:"#00ff00",targetColor2:"#ffff00",enableThirdPair:!1,originalColor3:"#ff00ff",targetColor3:"#00ffff",tolerance:.05},controls:[{id:"originalColor1",type:"color",label:"Original Color 1",property:"originalColor1",default:"#ff0000"},{id:"targetColor1",type:"color",label:"Target Color 1",property:"targetColor1",default:"#0000ff"},{id:"originalColor2",type:"color",label:"Original Color 2",property:"originalColor2",default:"#00ff00"},{id:"targetColor2",type:"color",label:"Target Color 2",property:"targetColor2",default:"#ffff00"},{id:"enableThirdPair",type:"toggle",label:"Enable Third Color Pair",property:"enableThirdPair",default:!1},{id:"originalColor3",type:"color",label:"Original Color 3",property:"originalColor3",default:"#ff00ff"},{id:"targetColor3",type:"color",label:"Target Color 3",property:"targetColor3",default:"#00ffff"},{id:"tolerance",type:"slider",label:"Tolerance",property:"tolerance",min:0,max:.5,step:.01,default:.05}]});const{RGBSplitFilter:lu}=Ie;Ne({id:"rgb-split",name:"RGB Split",category:"color",description:"Shifts the red, green, and blue channels to create a retro 3D or glitch effect",createFilter:n=>{try{const o={x:n.redX!==void 0?n.redX:-10,y:n.redY!==void 0?n.redY:0},t={x:n.greenX!==void 0?n.greenX:0,y:n.greenY!==void 0?n.greenY:10},a={x:n.blueX!==void 0?n.blueX:0,y:n.blueY!==void 0?n.blueY:0},r=new lu({red:o,green:t,blue:a});return r._customParams={...n},r.updateUIParam=function(i,s){try{const l=this._customParams||{};switch(this._customParams=l,l[i]=s,i){case"redX":this.redX=Number(s);break;case"redY":this.redY=Number(s);break;case"greenX":this.greenX=Number(s);break;case"greenY":this.greenY=Number(s);break;case"blueX":this.blueX=Number(s);break;case"blueY":this.blueY=Number(s);break;default:i in this&&(this[i]=s);break}return!0}catch{return this._customParams&&(this._customParams[i]=s),!1}},r}catch{return null}},defaultParams:{redX:-10,redY:0,greenX:0,greenY:10,blueX:0,blueY:0},controls:[{id:"redX",type:"slider",label:"Red X Offset",property:"redX",min:-20,max:20,step:1,default:-10},{id:"redY",type:"slider",label:"Red Y Offset",property:"redY",min:-20,max:20,step:1,default:0},{id:"greenX",type:"slider",label:"Green X Offset",property:"greenX",min:-20,max:20,step:1,default:0},{id:"greenY",type:"slider",label:"Green Y Offset",property:"greenY",min:-20,max:20,step:1,default:10},{id:"blueX",type:"slider",label:"Blue X Offset",property:"blueX",min:-20,max:20,step:1,default:0},{id:"blueY",type:"slider",label:"Blue Y Offset",property:"blueY",min:-20,max:20,step:1,default:0}]});const{AdvancedBloomFilter:cu}=Ie;Ne({id:"advanced-bloom",name:"Advanced Bloom",category:"light",description:"Adds a sophisticated bloom/glow effect with fine-grained control",createFilter:n=>{try{const o=new cu({threshold:n.threshold||.5,bloomScale:n.bloomScale||1,brightness:n.brightness||1,blur:n.blur||8,quality:n.quality||4,pixelSize:{x:n.pixelSizeX||1,y:n.pixelSizeY||1}});return o._customParams={pixelSizeX:n.pixelSizeX||1,pixelSizeY:n.pixelSizeY||1},o.updateUIParam=function(t,a){try{const r=this._customParams||{};switch(this._customParams=r,r[t]=a,t){case"threshold":this.threshold=Number(a);break;case"bloomScale":this.bloomScale=Number(a);break;case"brightness":this.brightness=Number(a);break;case"blur":this.blur=Number(a);break;case"quality":this.quality=Number(a);break;case"pixelSizeX":r.pixelSizeX=Number(a),this.pixelSize={x:Number(a),y:r.pixelSizeY};break;case"pixelSizeY":r.pixelSizeY=Number(a),this.pixelSize={x:r.pixelSizeX,y:Number(a)};break;default:t in this&&(this[t]=a);break}}catch{}},o}catch{return null}},defaultParams:{threshold:.5,bloomScale:1,brightness:1,blur:8,quality:4,pixelSizeX:1,pixelSizeY:1},controls:[{id:"threshold",type:"slider",label:"Threshold",property:"threshold",min:0,max:1,step:.01,default:.5},{id:"bloomScale",type:"slider",label:"Bloom Intensity",property:"bloomScale",min:0,max:3,step:.1,default:1},{id:"brightness",type:"slider",label:"Brightness",property:"brightness",min:0,max:3,step:.1,default:1},{id:"blur",type:"slider",label:"Blur Strength",property:"blur",min:0,max:20,step:1,default:8},{id:"quality",type:"slider",label:"Quality",property:"quality",min:1,max:10,step:1,default:4},{id:"pixelSizeX",type:"slider",label:"Pixel Size X",property:"pixelSizeX",min:.5,max:10,step:.5,default:1},{id:"pixelSizeY",type:"slider",label:"Pixel Size Y",property:"pixelSizeY",min:.5,max:10,step:.5,default:1}]});const du=Ie.AsciiFilter;Ne({id:"ascii",name:"ASCII",category:"stylize",description:"Convert image to ASCII text characters",createFilter:n=>{try{const o=typeof n.size=="number"?n.size:8;let t=n.color;typeof t=="string"&&t.startsWith("#")&&(t=parseInt(t.replace("#","0x"),16));const a=n.replaceColor===!0,r=new du({size:o,color:t,replaceColor:a});return r._customParams={size:o,color:t,replaceColor:a},r.updateUIParam=function(i,s){try{const l=this._customParams||{};switch(this._customParams=l,l[i]=s,i){case"size":this.size=Number(s);break;case"color":typeof s=="string"&&s.startsWith("#")?(l.color=s,this.color=parseInt(s.replace("#","0x"),16)):this.color=s;break;case"replaceColor":this.replaceColor=!!s;break;default:i in this&&(this[i]=s);break}}catch{}},r}catch{return null}},defaultParams:{size:8,color:"#ffffff",replaceColor:!1},controls:[{id:"size",type:"slider",label:"Character Size",property:"size",min:2,max:20,step:1,default:8},{id:"color",type:"color",label:"Character Color",property:"color",default:"#ffffff"},{id:"replaceColor",type:"toggle",label:"Replace Original Colors",property:"replaceColor",default:!1}]});const uu=Ie.BackdropBlurFilter;Ne({id:"backdrop-blur",name:"Backdrop Blur",category:"blur",description:"Blurs what is behind the object, creating a glass-like effect",createFilter:n=>{try{const o=new uu({strength:n.strength||20,quality:n.quality||4,resolution:n.resolution||.5,kernelSize:n.kernelSize||9});return o._customParams={...n},o.updateUIParam=function(t,a){try{const r=this._customParams||{};switch(this._customParams=r,r[t]=a,t){case"strength":this.strength=Number(a),this.blur=Number(a)/4;break;case"quality":this.quality=Number(a);break;case"resolution":this.resolution=Number(a);break;case"kernelSize":const i=Number(a);this.blurXFilter&&this.blurYFilter?(this.blurXFilter.kernelSize=i,this.blurYFilter.kernelSize=i):this.kernelSize=i;break;default:t in this&&(this[t]=a);break}}catch{}},o}catch{return null}},defaultParams:{strength:20,quality:4,resolution:.5,kernelSize:9},controls:[{id:"strength",type:"slider",label:"Strength",property:"strength",min:0,max:50,step:1,default:20},{id:"quality",type:"slider",label:"Quality",property:"quality",min:1,max:10,step:1,default:4},{id:"resolution",type:"slider",label:"Resolution",property:"resolution",min:.1,max:1,step:.1,default:.5},{id:"kernelSize",type:"select",label:"Kernel Size",property:"kernelSize",options:[{label:"5",value:5},{label:"7",value:7},{label:"9",value:9},{label:"11",value:11},{label:"13",value:13},{label:"15",value:15}],default:9}]});const{BevelFilter:mu}=Ie;Ne({id:"bevel",name:"Bevel",category:"effects",description:"Add a 3D-like beveled edge effect to the image",createFilter:n=>{try{const o=n.lightColor?n.lightColor.replace("#","0x"):"0xffffff",t=n.shadowColor?n.shadowColor.replace("#","0x"):"0x000000",a=new mu({rotation:n.rotation!==void 0?n.rotation:45,thickness:n.thickness!==void 0?n.thickness:2,lightColor:parseInt(o,16),lightAlpha:n.lightAlpha!==void 0?n.lightAlpha:.7,shadowColor:parseInt(t,16),shadowAlpha:n.shadowAlpha!==void 0?n.shadowAlpha:.7});return a._customParams={...n},a.updateUIParam=function(r,i){try{const s=this._customParams||{};switch(this._customParams=s,s[r]=i,r){case"rotation":this.rotation=Number(i);break;case"thickness":this.thickness=Number(i);break;case"lightColor":if(typeof i=="string"){const l=parseInt(i.replace("#","0x"),16);this.lightColor=l}break;case"lightAlpha":this.lightAlpha=Number(i);break;case"shadowColor":if(typeof i=="string"){const l=parseInt(i.replace("#","0x"),16);this.shadowColor=l}break;case"shadowAlpha":this.shadowAlpha=Number(i);break;default:r in this&&(this[r]=i);break}return!0}catch{return this._customParams&&(this._customParams[r]=i),!1}},a}catch{return null}},defaultParams:{rotation:45,thickness:2,lightColor:"#ffffff",lightAlpha:.7,shadowColor:"#000000",shadowAlpha:.7},controls:[{id:"rotation",type:"slider",label:"Angle",property:"rotation",min:0,max:360,step:1,default:45},{id:"thickness",type:"slider",label:"Thickness",property:"thickness",min:0,max:20,step:.1,default:2},{id:"lightColor",type:"color",label:"Light Color",property:"lightColor",default:"#ffffff"},{id:"lightAlpha",type:"slider",label:"Light Opacity",property:"lightAlpha",min:0,max:1,step:.01,default:.7},{id:"shadowColor",type:"color",label:"Shadow Color",property:"shadowColor",default:"#000000"},{id:"shadowAlpha",type:"slider",label:"Shadow Opacity",property:"shadowAlpha",min:0,max:1,step:.01,default:.7}]});const{BloomFilter:pu}=Ie;Ne({id:"bloom",name:"Bloom/Glow",category:"light",description:"Add a subtle glow effect to bright areas of the image",createFilter:n=>{try{const o=typeof n.strengthX=="number"?n.strengthX:2,t=typeof n.strengthY=="number"?n.strengthY:2,a=typeof n.quality=="number"?n.quality:4,r=typeof n.resolution=="number"?n.resolution:1,i=typeof n.kernelSize=="number"?n.kernelSize:5,s=new pu({strength:{x:Number(o),y:Number(t)},quality:Number(a),resolution:Number(r),kernelSize:Number(i)}),l=s;return s._customParams={strengthX:o,strengthY:t,quality:a,resolution:r,kernelSize:i},s.updateUIParam=function(c,d){var u,p;try{const m=Number(d),f=this._customParams||{};switch(this._customParams=f,f[c]=m,c){case"strengthX":this.strength&&typeof this.strength=="object"&&(this.strength.x=m,(u=this._updateStrength)==null||u.call(this));break;case"strengthY":this.strength&&typeof this.strength=="object"&&(this.strength.y=m,(p=this._updateStrength)==null||p.call(this));break;case"quality":this.quality=m;break;case"resolution":this.resolution=m;break;case"kernelSize":this.kernelSize=m;break;default:c in this&&(this[c]=m);break}}catch{}},s}catch{return null}},defaultParams:{strengthX:2,strengthY:2,quality:4,resolution:1,kernelSize:5},controls:[{id:"strengthX",type:"slider",label:"Horizontal Strength",property:"strengthX",min:0,max:20,step:.1,default:2},{id:"strengthY",type:"slider",label:"Vertical Strength",property:"strengthY",min:0,max:20,step:.1,default:2},{id:"quality",type:"slider",label:"Quality",property:"quality",min:1,max:10,step:1,default:4},{id:"kernelSize",type:"select",label:"Kernel Size",property:"kernelSize",options:[{label:"5",value:5},{label:"7",value:7},{label:"9",value:9},{label:"11",value:11},{label:"13",value:13},{label:"15",value:15}],default:5}]});const{BulgePinchFilter:fu}=Ie;Ne({id:"bulge-pinch",name:"Bulge/Pinch",category:"distortion",description:"Creates a bulge or pinch effect in a circular area",createFilter:n=>{try{const o=n.centerX??.5,t=n.centerY??.5,a=n.radius??100,r=n.strength??1,i=new fu({center:{x:o,y:t},radius:a,strength:r});return i._customParams={...n},i.updateUIParam=function(s,l){const c=this._customParams||{};switch(this._customParams=c,c[s]=l,s){case"centerX":this.center||(this.center={x:.5,y:.5}),this.center.x=l;break;case"centerY":this.center||(this.center={x:.5,y:.5}),this.center.y=l;break;case"radius":case"strength":this[s]=l;break;default:s in this&&(this[s]=l);break}return!0},i}catch{return null}},defaultParams:{centerX:.5,centerY:.5,radius:100,strength:1},controls:[{id:"centerX",type:"slider",label:"Center X",property:"centerX",min:0,max:1,step:.01,default:.5},{id:"centerY",type:"slider",label:"Center Y",property:"centerY",min:0,max:1,step:.01,default:.5},{id:"radius",type:"slider",label:"Radius",property:"radius",min:1,max:500,step:1,default:100},{id:"strength",type:"slider",label:"Strength",property:"strength",min:-1,max:1,step:.01,default:1}]});const{ConvolutionFilter:hu}=Ie,Bn={normal:[0,0,0,0,1,0,0,0,0],gaussianBlur:[.045,.122,.045,.122,.332,.122,.045,.122,.045],boxBlur:[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],edgeDetection:[-1,-1,-1,-1,8,-1,-1,-1,-1],edgeEnhance:[0,0,0,-1,1,0,0,0,0],emboss:[-2,-1,0,-1,1,1,0,1,2],sharpen:[0,-1,0,-1,5,-1,0,-1,0],sobelHorizontal:[1,2,1,0,0,0,-1,-2,-1],sobelVertical:[1,0,-1,2,0,-2,1,0,-1]};Ne({id:"convolution",name:"Convolution Matrix",category:"effects",description:"Apply custom image effects using matrix convolution",createFilter:n=>{try{let o;if(n.customMatrix)o=[n.m00,n.m01,n.m02,n.m10,n.m11,n.m12,n.m20,n.m21,n.m22];else{const a=n.preset;o=Bn[a]||Bn.normal}const t=new hu({matrix:new Float32Array(o),width:n.width||200,height:n.height||200});return t._customParams={...n},t.updateUIParam=function(a,r){const i=this._customParams||{};switch(this._customParams=i,i[a]=r,a){case"preset":if(!i.customMatrix){const s=r;Bn[s]&&(this.matrix=Bn[s])}break;case"customMatrix":if(r){const s=this.matrix;i.m00=s[0],i.m01=s[1],i.m02=s[2],i.m10=s[3],i.m11=s[4],i.m12=s[5],i.m20=s[6],i.m21=s[7],i.m22=s[8]}else{const s=i.preset;this.matrix=Bn[s]||Bn.normal}break;case"m00":case"m01":case"m02":case"m10":case"m11":case"m12":case"m20":case"m21":case"m22":if(i.customMatrix){const s=[...this.matrix],c={m00:0,m01:1,m02:2,m10:3,m11:4,m12:5,m20:6,m21:7,m22:8}[a];c!==void 0&&(s[c]=r,this.matrix=s)}break;case"width":this.width=r;break;case"height":this.height=r;break;default:a in this&&(this[a]=r);break}},t}catch{return null}},defaultParams:{preset:"normal",customMatrix:!1,m00:0,m01:0,m02:0,m10:0,m11:1,m12:0,m20:0,m21:0,m22:0,width:200,height:200},controls:[{id:"preset",type:"select",label:"Effect Preset",property:"preset",options:[{value:"normal",label:"Normal"},{value:"gaussianBlur",label:"Gaussian Blur"},{value:"boxBlur",label:"Box Blur"},{value:"edgeDetection",label:"Edge Detection"},{value:"edgeEnhance",label:"Edge Enhance"},{value:"emboss",label:"Emboss"},{value:"sharpen",label:"Sharpen"},{value:"sobelHorizontal",label:"Sobel Horizontal"},{value:"sobelVertical",label:"Sobel Vertical"}],default:"normal"},{id:"customMatrix",type:"toggle",label:"Use Custom Matrix",property:"customMatrix",default:!1},{id:"width",type:"slider",label:"Width",property:"width",min:50,max:500,step:10,default:200},{id:"height",type:"slider",label:"Height",property:"height",min:50,max:500,step:10,default:200},{id:"m00",type:"slider",label:"Matrix [0,0]",property:"m00",min:-5,max:5,step:.1,default:0},{id:"m01",type:"slider",label:"Matrix [0,1]",property:"m01",min:-5,max:5,step:.1,default:0},{id:"m02",type:"slider",label:"Matrix [0,2]",property:"m02",min:-5,max:5,step:.1,default:0},{id:"m10",type:"slider",label:"Matrix [1,0]",property:"m10",min:-5,max:5,step:.1,default:0},{id:"m11",type:"slider",label:"Matrix [1,1]",property:"m11",min:-5,max:5,step:.1,default:1},{id:"m12",type:"slider",label:"Matrix [1,2]",property:"m12",min:-5,max:5,step:.1,default:0},{id:"m20",type:"slider",label:"Matrix [2,0]",property:"m20",min:-5,max:5,step:.1,default:0},{id:"m21",type:"slider",label:"Matrix [2,1]",property:"m21",min:-5,max:5,step:.1,default:0},{id:"m22",type:"slider",label:"Matrix [2,2]",property:"m22",min:-5,max:5,step:.1,default:0}]});Ne({id:"cross-hatch",name:"Cross Hatch",category:"stylize",description:"Creates a crosshatching effect like in a pencil drawing",createFilter:n=>{try{const o=typeof n.thickness=="number"?n.thickness:10,t=new Ie.CrossHatchFilter;t._customParams={thickness:o};const a=t;try{a.uniforms&&a.uniforms.thickness===void 0&&Object.defineProperty(a.uniforms,"thickness",{get:()=>t._customParams.thickness/10,set:r=>t._customParams.thickness=r*10,enumerable:!0,configurable:!0})}catch{}return t.updateUIParam=function(r,i){try{const s=this._customParams||{};switch(this._customParams=s,s[r]=i,r){case"thickness":s.thickness=Number(i),this.uniforms&&this.uniforms.thickness!==void 0&&(this.uniforms.thickness=Number(i)/10);break;default:r in this&&(this[r]=i);break}}catch{}},t}catch{return null}},defaultParams:{thickness:10},controls:[{id:"thickness",type:"slider",label:"Line Thickness",property:"thickness",min:2,max:20,step:1,default:10}]});Ne({id:"crt",name:"CRT Screen",category:"stylize",description:"Simulates an old CRT screen with scan lines and noise",createFilter:n=>{try{const o={lineWidth:typeof n.lineWidth=="number"?n.lineWidth:1,noise:typeof n.noise=="number"?n.noise:.3,curvature:typeof n.curvature=="number"?n.curvature:1,lineContrast:typeof n.lineContrast=="number"?n.lineContrast:.25,verticalLine:n.verticalLine===!0,noiseSize:typeof n.noiseSize=="number"?n.noiseSize:1,vignetting:typeof n.vignetting=="number"?n.vignetting:.3,vignettingAlpha:typeof n.vignettingAlpha=="number"?n.vignettingAlpha:1,vignettingBlur:typeof n.vignettingBlur=="number"?n.vignettingBlur:.3,time:typeof n.time=="number"?n.time:0,seed:typeof n.seed=="number"?n.seed:Math.random()},t=new Ie.CRTFilter(o);return t._customParams={...o},t.updateUIParam=function(a,r){try{const i=this._customParams||{};switch(this._customParams=i,i[a]=r,a){case"lineWidth":this.lineWidth=Number(r);break;case"noise":this.noise=Number(r);break;case"curvature":this.curvature=Number(r);break;case"lineContrast":this.lineContrast=Number(r);break;case"verticalLine":this.verticalLine=!!r;break;case"noiseSize":this.noiseSize=Number(r);break;case"vignetting":this.vignetting=Number(r);break;case"vignettingAlpha":this.vignettingAlpha=Number(r);break;case"vignettingBlur":this.vignettingBlur=Number(r);break;case"time":this.time=Number(r);break;case"seed":this.seed=Number(r);break;default:a in this&&(this[a]=r);break}}catch{}},t}catch{return null}},defaultParams:{lineWidth:1,noise:.3,curvature:1,lineContrast:.25,verticalLine:!1,noiseSize:1,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3,time:0,seed:1},controls:[{id:"lineWidth",type:"slider",label:"Scan Line Width",property:"lineWidth",min:0,max:5,step:.1,default:1},{id:"noise",type:"slider",label:"Noise Amount",property:"noise",min:0,max:1,step:.01,default:.3},{id:"curvature",type:"slider",label:"Screen Curvature",property:"curvature",min:0,max:10,step:.1,default:1},{id:"lineContrast",type:"slider",label:"Line Contrast",property:"lineContrast",min:0,max:1,step:.01,default:.25},{id:"verticalLine",type:"toggle",label:"Vertical Lines",property:"verticalLine",default:!1},{id:"noiseSize",type:"slider",label:"Noise Size",property:"noiseSize",min:.5,max:5,step:.1,default:1},{id:"vignetting",type:"slider",label:"Vignette Size",property:"vignetting",min:0,max:1,step:.01,default:.3},{id:"vignettingAlpha",type:"slider",label:"Vignette Opacity",property:"vignettingAlpha",min:0,max:1,step:.01,default:1},{id:"vignettingBlur",type:"slider",label:"Vignette Blur",property:"vignettingBlur",min:0,max:1,step:.01,default:.3},{id:"time",type:"slider",label:"Animation Time",property:"time",min:0,max:10,step:.1,default:0}]});const vu=Ae.DisplacementFilter,gu=Ae.Sprite,dr=Ae.Texture;Ne({id:"displacement",name:"Displacement Map",category:"distortion",description:"Distorts the image using a displacement map texture",createFilter:n=>{try{const o=n.mapTexture||"/assets/images/displacement_map.png";let t;try{t=dr.from(o),t.source.addressMode="repeat"}catch{const s=document.createElement("canvas");s.width=256,s.height=256;const l=s.getContext("2d");if(l){l.fillStyle="#ffffff",l.fillRect(0,0,s.width,s.height),l.fillStyle="#000000";for(let c=0;c<10;c++)for(let d=0;d<10;d++)(c+d)%2===0&&l.fillRect(c*25,d*25,25,25)}t=dr.from(s)}const a=new gu(t),r=new vu(a,n.scale||50);return r.scale.x=n.scaleX||50,r.scale.y=n.scaleY||50,r._customParams={...n},r._displacementSprite=a,r.updateUIParam=function(i,s){const l=this._customParams||{};switch(this._customParams=l,l[i]=s,i){case"scaleX":this.scale.x=s;break;case"scaleY":this.scale.y=s;break;case"mapTexture":try{const c=this._displacementSprite;if(c){const d=dr.from(s);d.source.addressMode="repeat",c.texture=d}}catch{}break;default:i in this?this[i]=s:i in this.scale&&(this.scale[i]=s);break}return!0},r}catch{return null}},defaultParams:{mapTexture:"/assets/images/displacement_map.png",scale:50,scaleX:50,scaleY:50},controls:[{id:"mapTexture",type:"select",label:"Displacement Map",property:"mapTexture",options:[{label:"Default",value:"/assets/images/displacement_map.png"},{label:"Clouds",value:"/assets/images/clouds.png"},{label:"Ripple",value:"/assets/images/ripple.png"}],default:"/assets/images/displacement_map.png"},{id:"scaleX",type:"slider",label:"Scale X",property:"scaleX",min:0,max:200,step:1,default:50},{id:"scaleY",type:"slider",label:"Scale Y",property:"scaleY",min:0,max:200,step:1,default:50}]});Ne({id:"dot",name:"Dot Screen",category:"stylize",description:"Simulates a halftone printing pattern with dots",createFilter:n=>{try{const o={scale:typeof n.scale=="number"?n.scale:1,angle:typeof n.angle=="number"?n.angle:5,grayscale:n.grayscale===!0},t=new Ie.DotFilter(o);return t._customParams={...o},t.updateUIParam=function(a,r){try{const i=this._customParams||{};switch(this._customParams=i,i[a]=r,a){case"scale":this.scale=Number(r);break;case"angle":this.angle=Number(r);break;case"grayscale":this.grayscale=!!r;break;default:a in this&&(this[a]=r);break}}catch{}},t}catch{return null}},defaultParams:{scale:1,angle:5,grayscale:!0},controls:[{id:"scale",type:"slider",label:"Dot Scale",property:"scale",min:.5,max:10,step:.1,default:1},{id:"angle",type:"slider",label:"Dot Angle",property:"angle",min:0,max:10,step:.1,default:5},{id:"grayscale",type:"toggle",label:"Grayscale",property:"grayscale",default:!0}]});const{ConvolutionFilter:yu}=Ie;Ne({id:"emboss",name:"Emboss",category:"stylize",description:"Creates an embossed relief effect",createFilter:n=>{try{const o=typeof n.strength=="number"?n.strength:5,t=o/3,a=[-t,-t,0,-t,1,t,0,t,t],r=new yu({matrix:new Float32Array(a),width:3,height:3});return r.bias=.5,r._customParams={strength:o},r.updateUIParam=function(i,s){try{const l=this._customParams||{};switch(this._customParams=l,l[i]=s,i){case"strength":const c=Math.max(Number(s),1);l.strength=c;const d=c/3;this.matrix[0]=-d,this.matrix[1]=-d,this.matrix[3]=-d,this.matrix[4]=1,this.matrix[5]=d,this.matrix[7]=d,this.matrix[8]=d,this.bias=.5;break;case"grayscale":l.grayscale=!!s;break;default:i in this&&(this[i]=s);break}}catch{}},r}catch{return null}},defaultParams:{strength:5,grayscale:!1},controls:[{id:"strength",type:"slider",label:"Strength",property:"strength",min:1,max:20,step:1,default:5},{id:"grayscale",type:"toggle",label:"Grayscale",property:"grayscale",default:!1}]});const{GlitchFilter:bu}=Ie,un={TRANSPARENT:0,ORIGINAL:1,LOOP:2,CLAMP:3,MIRROR:4};Ne({id:"glitch",name:"Glitch",category:"effects",description:"Apply digital distortion and glitch effects",createFilter:n=>{try{const o={x:n.redX,y:n.redY},t={x:n.greenX,y:n.greenY},a={x:n.blueX,y:n.blueY},r=new bu({slices:n.slices,offset:n.offset,direction:n.direction,fillMode:n.fillMode,seed:n.seed,average:n.average,minSize:n.minSize,sampleSize:n.sampleSize,red:o,green:t,blue:a});r.animating=n.animating||!1,r._customParams={...n},typeof r.refresh=="function"&&r.refresh();let i=null;const s=()=>{r.animating&&(r.seed=Math.random()),i=requestAnimationFrame(s)};return r.animating&&(i=requestAnimationFrame(s)),r._stopAnimation=()=>{i!==null&&(cancelAnimationFrame(i),i=null)},r.updateUIParam=function(l,c){const d=this._customParams||{};switch(this._customParams=d,d[l]=c,l){case"animating":this.animating=c,c&&!i&&(i=requestAnimationFrame(s));break;case"slices":this.slices=Math.round(c);break;case"redX":case"redY":const u=this.red;l==="redX"?u.x=c:u.y=c,this.red=u;break;case"greenX":case"greenY":const p=this.green;l==="greenX"?p.x=c:p.y=c,this.green=p;break;case"blueX":case"blueY":const m=this.blue;l==="blueX"?m.x=c:m.y=c,this.blue=m;break;case"seed":this.animating||(this.seed=c);break;case"randomizeSeed":c&&!d.animating&&(this.seed=Math.random());break;case"refresh":if(c)try{this.refresh()}catch{}break;case"offset":case"direction":case"fillMode":case"average":case"minSize":case"sampleSize":l in this&&(this[l]=c);break;default:l in this&&(this[l]=c);break}},r}catch{return null}},defaultParams:{slices:10,offset:100,direction:0,fillMode:un.LOOP,seed:.5,average:!1,minSize:8,sampleSize:512,redX:2,redY:2,greenX:-2,greenY:0,blueX:0,blueY:-2,animating:!1,randomizeSeed:!1,refresh:!1},controls:[{id:"animating",type:"toggle",label:"Animate Automatically",property:"animating",default:!1},{id:"slices",type:"slider",label:"Slices",property:"slices",min:2,max:20,step:1,default:10},{id:"offset",type:"slider",label:"Offset Amount",property:"offset",min:0,max:400,step:1,default:100},{id:"direction",type:"slider",label:"Direction",property:"direction",min:-180,max:180,step:1,default:0},{id:"fillMode",type:"select",label:"Fill Mode",property:"fillMode",options:[{value:un.TRANSPARENT,label:"Transparent"},{value:un.ORIGINAL,label:"Original"},{value:un.LOOP,label:"Loop"},{value:un.CLAMP,label:"Clamp"},{value:un.MIRROR,label:"Mirror"}],default:un.LOOP},{id:"seed",type:"slider",label:"Seed",property:"seed",min:0,max:1,step:.01,default:.5},{id:"randomizeSeed",type:"button",label:"Randomize Seed",action:"randomizeSeed"},{id:"refresh",type:"button",label:"Refresh Filter",action:"refresh"},{id:"average",type:"toggle",label:"Average Slices",property:"average",default:!1},{id:"redX",type:"slider",label:"Red X Offset",property:"redX",min:-20,max:20,step:.5,default:2},{id:"redY",type:"slider",label:"Red Y Offset",property:"redY",min:-20,max:20,step:.5,default:2},{id:"greenX",type:"slider",label:"Green X Offset",property:"greenX",min:-20,max:20,step:.5,default:-2},{id:"greenY",type:"slider",label:"Green Y Offset",property:"greenY",min:-20,max:20,step:.5,default:0},{id:"blueX",type:"slider",label:"Blue X Offset",property:"blueX",min:-20,max:20,step:.5,default:0},{id:"blueY",type:"slider",label:"Blue Y Offset",property:"blueY",min:-20,max:20,step:.5,default:-2}]});const{GlowFilter:wu}=Ie;Ne({id:"glow",name:"Glow",category:"light",description:"Adds a customizable glow effect around the image",createFilter:n=>{try{const o=parseInt(n.color.replace("#","0x"),16),t=new wu({distance:n.distance||10,outerStrength:n.outerStrength||4,innerStrength:n.innerStrength||0,color:o,alpha:n.alpha??1,quality:n.quality||.1,knockout:n.knockout||!1});return t._customParams={color:n.color||"#ffffff",...n},t.updateUIParam=function(a,r){try{const i=this._customParams||{};switch(this._customParams=i,i[a]=r,a){case"distance":this.distance=Number(r);break;case"outerStrength":this.outerStrength=Number(r);break;case"innerStrength":this.innerStrength=Number(r);break;case"color":i.color=r,this.color=parseInt(r.replace("#","0x"),16);break;case"alpha":this.alpha=Number(r);break;case"quality":this.quality=Number(r);break;case"knockout":this.knockout=!!r;break;default:a in this&&(this[a]=r);break}}catch{}},t}catch{return null}},defaultParams:{distance:10,outerStrength:4,innerStrength:0,color:"#ffffff",alpha:1,quality:.1,knockout:!1},controls:[{id:"distance",type:"slider",label:"Distance",property:"distance",min:0,max:20,step:1,default:10},{id:"outerStrength",type:"slider",label:"Outer Strength",property:"outerStrength",min:0,max:20,step:.1,default:4},{id:"innerStrength",type:"slider",label:"Inner Strength",property:"innerStrength",min:0,max:20,step:.1,default:0},{id:"color",type:"color",label:"Color",property:"color",default:"#ffffff"},{id:"alpha",type:"slider",label:"Alpha",property:"alpha",min:0,max:1,step:.01,default:1},{id:"quality",type:"slider",label:"Quality",property:"quality",min:.01,max:1,step:.01,default:.1},{id:"knockout",type:"toggle",label:"Show Glow Only",property:"knockout",default:!1}]});const{GodrayFilter:ku}=Ie;Ne({id:"godray",name:"Godray",category:"light",description:"Creates volumetric light-ray effects (crepuscular rays)",createFilter:n=>{try{const o=new ku({angle:n.angle||30,parallel:n.parallel??!0,center:{x:n.centerX||0,y:n.centerY||0},gain:n.gain||.5,lacunarity:n.lacunarity||2.5,time:n.time||0,alpha:n.alpha||1});return o._customParams={centerX:n.centerX||0,centerY:n.centerY||0,...n},o.updateUIParam=function(t,a){try{const r=this._customParams||{};switch(this._customParams=r,r[t]=a,t){case"angle":this.angle=Number(a);break;case"parallel":this.parallel=!!a;break;case"centerX":r.centerX=Number(a),this.center={x:Number(a),y:r.centerY};break;case"centerY":r.centerY=Number(a),this.center={x:r.centerX,y:Number(a)};break;case"gain":this.gain=Number(a);break;case"lacunarity":this.lacunarity=Number(a);break;case"time":this.time=Number(a);break;case"alpha":this.alpha=Number(a);break;default:t in this&&(this[t]=a);break}}catch{}},o}catch{return null}},defaultParams:{angle:30,parallel:!0,centerX:0,centerY:0,gain:.5,lacunarity:2.5,time:0,alpha:1},controls:[{id:"angle",type:"slider",label:"Angle",property:"angle",min:0,max:360,step:1,default:30},{id:"parallel",type:"toggle",label:"Parallel Rays",property:"parallel",default:!0},{id:"centerX",type:"slider",label:"Light Source X",property:"centerX",min:-1,max:1,step:.01,default:0},{id:"centerY",type:"slider",label:"Light Source Y",property:"centerY",min:-1,max:1,step:.01,default:0},{id:"gain",type:"slider",label:"Gain/Intensity",property:"gain",min:0,max:1,step:.01,default:.5},{id:"lacunarity",type:"slider",label:"Density",property:"lacunarity",min:.1,max:10,step:.1,default:2.5},{id:"time",type:"slider",label:"Time",property:"time",min:0,max:10,step:.1,default:0},{id:"alpha",type:"slider",label:"Alpha",property:"alpha",min:0,max:1,step:.01,default:1}]});const xu=Ie.SimpleLightmapFilter,vs=Ae.Texture;Ne({id:"lightmap",name:"Lightmap",category:"light",description:"Applies lighting effects using a reference texture as a light map",createFilter:n=>{try{const o=n.textureType||"default",t=n.color||"#000000",a=typeof n.alpha=="number"?n.alpha:1,r=document.createElement("canvas");r.width=256,r.height=256;const i=r.getContext("2d");if(!i)throw new Error("Canvas 2D context not available");if(o==="spotlight"){i.fillStyle="black",i.fillRect(0,0,256,256);const d=i.createRadialGradient(128,128,5,128,128,80);d.addColorStop(0,"white"),d.addColorStop(.5,"rgba(255, 255, 255, 0.5)"),d.addColorStop(1,"rgba(0, 0, 0, 0)"),i.fillStyle=d,i.beginPath(),i.arc(128,128,100,0,Math.PI*2),i.fill()}else if(o==="softlight"){const d=i.createLinearGradient(0,0,256,256);d.addColorStop(0,"white"),d.addColorStop(.3,"rgba(220, 220, 220, 1)"),d.addColorStop(.7,"rgba(150, 150, 150, 1)"),d.addColorStop(1,"rgba(80, 80, 80, 1)"),i.fillStyle=d,i.fillRect(0,0,256,256)}else{const d=i.createRadialGradient(128,128,10,128,128,160);d.addColorStop(0,"white"),d.addColorStop(.3,"rgba(220, 220, 220, 1)"),d.addColorStop(.6,"rgba(150, 150, 150, 1)"),d.addColorStop(1,"black"),i.fillStyle=d,i.fillRect(0,0,256,256)}const s=vs.from(r);let l;try{typeof t=="string"&&t.startsWith("#")?l=parseInt(t.replace("#","0x"),16):l=0}catch{l=0}const c=new xu(s,l,a);return c._customParams={textureType:o,color:t,alpha:a},c.updateUIParam=function(d,u){try{const p=this._customParams||{};switch(this._customParams=p,p[d]=u,d){case"textureType":p.textureType=u;const m=document.createElement("canvas");m.width=256,m.height=256;const f=m.getContext("2d");if(f){if(u==="spotlight"){f.fillStyle="black",f.fillRect(0,0,256,256);const b=f.createRadialGradient(128,128,5,128,128,80);b.addColorStop(0,"white"),b.addColorStop(.5,"rgba(255, 255, 255, 0.5)"),b.addColorStop(1,"rgba(0, 0, 0, 0)"),f.fillStyle=b,f.beginPath(),f.arc(128,128,100,0,Math.PI*2),f.fill()}else if(u==="softlight"){const b=f.createLinearGradient(0,0,256,256);b.addColorStop(0,"white"),b.addColorStop(.3,"rgba(220, 220, 220, 1)"),b.addColorStop(.7,"rgba(150, 150, 150, 1)"),b.addColorStop(1,"rgba(80, 80, 80, 1)"),f.fillStyle=b,f.fillRect(0,0,256,256)}else{const b=f.createRadialGradient(128,128,10,128,128,160);b.addColorStop(0,"white"),b.addColorStop(.3,"rgba(220, 220, 220, 1)"),b.addColorStop(.6,"rgba(150, 150, 150, 1)"),b.addColorStop(1,"black"),f.fillStyle=b,f.fillRect(0,0,256,256)}const v=vs.from(m);if(this.lightMap=v,this.enabled!==void 0){const b=this.enabled;this.enabled=!1,setTimeout(()=>{this.enabled=b},0)}}break;case"color":p.color=u;try{typeof u=="string"&&u.startsWith("#")?this.color=parseInt(u.replace("#","0x"),16):this.color=0}catch{this.color=0}break;case"alpha":this.alpha=Number(u);break;default:d in this&&(this[d]=u);break}}catch{}},c}catch{return null}},defaultParams:{textureType:"default",color:"#000000",alpha:1},controls:[{id:"textureType",type:"select",label:"Light Map Type",property:"textureType",options:[{label:"Default",value:"default"},{label:"Spotlight",value:"spotlight"},{label:"Soft Light",value:"softlight"}],default:"default"},{id:"color",type:"color",label:"Ambient Color",property:"color",default:"#000000"},{id:"alpha",type:"slider",label:"Intensity",property:"alpha",min:0,max:1,step:.01,default:1}]});const{NoiseFilter:Su}=Ae;Ne({id:"noise",name:"Noise",category:"effects",description:"Add random noise to the image",createFilter:n=>{try{const o=new Su({noise:n.noise||.5,seed:n.seed||Math.random()});o.animating=n.animating||!1,o._customParams={...n};let t=null;const a=()=>{o.animating&&(o.seed=Math.random()),t=requestAnimationFrame(a)};return o.animating&&(t=requestAnimationFrame(a)),o._stopAnimation=()=>{t!==null&&(cancelAnimationFrame(t),t=null)},o.updateUIParam=function(r,i){const s=this._customParams||{};switch(this._customParams=s,s[r]=i,r){case"animating":this.animating=i,i&&!t&&(t=requestAnimationFrame(a));break;case"noise":this.noise=Math.max(0,Math.min(1,i));break;case"seed":this.animating||(this.seed=i);break;case"randomizeSeed":i&&(this.seed=Math.random());break;default:r in this&&(this[r]=i);break}},o}catch{return null}},defaultParams:{noise:.5,seed:.5,animating:!1,randomizeSeed:!1},controls:[{id:"animating",type:"toggle",label:"Animate Noise",property:"animating",default:!1},{id:"noise",type:"slider",label:"Noise Amount",property:"noise",min:0,max:1,step:.01,default:.5},{id:"seed",type:"slider",label:"Random Seed",property:"seed",min:0,max:1,step:.01,default:.5},{id:"randomizeSeed",type:"button",label:"Randomize Seed",action:"randomizeSeed"}]});const{OldFilmFilter:Eu}=Ie;Ne({id:"old-film",name:"Old Film",category:"effects",description:"Apply a vintage film effect with scratches and grain",createFilter:n=>{try{const o=new Eu({sepia:n.sepia,noise:n.noise,noiseSize:n.noiseSize,scratch:n.scratch,scratchDensity:n.scratchDensity,scratchWidth:n.scratchWidth,vignetting:n.vignetting,vignettingAlpha:n.vignettingAlpha,vignettingBlur:n.vignettingBlur,seed:n.seed||Math.random()});o.animating=n.animating||!1,o._customParams={...n};let t=null;const a=()=>{o.animating&&(o.seed=Math.random()),t=requestAnimationFrame(a)};return o.animating&&(t=requestAnimationFrame(a)),o._stopAnimation=()=>{t!==null&&(cancelAnimationFrame(t),t=null)},o.updateUIParam=function(r,i){const s=this._customParams||{};switch(this._customParams=s,s[r]=i,r){case"animating":this.animating=i,i&&!t&&(t=requestAnimationFrame(a));break;case"seed":this.animating||(this.seed=i);break;case"randomizeSeed":i&&(this.seed=Math.random());break;case"sepia":case"noise":case"noiseSize":case"scratch":case"scratchDensity":case"scratchWidth":case"vignetting":case"vignettingAlpha":case"vignettingBlur":r in this&&(this[r]=i);break;default:r in this&&(this[r]=i);break}},o}catch{return null}},defaultParams:{sepia:.3,noise:.3,noiseSize:1,scratch:.5,scratchDensity:.3,scratchWidth:1,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3,seed:.5,animating:!1,randomizeSeed:!1},controls:[{id:"animating",type:"toggle",label:"Animate Film",property:"animating",default:!1},{id:"sepia",type:"slider",label:"Sepia Tone",property:"sepia",min:0,max:1,step:.01,default:.3},{id:"noise",type:"slider",label:"Noise Amount",property:"noise",min:0,max:1,step:.01,default:.3},{id:"noiseSize",type:"slider",label:"Noise Size",property:"noiseSize",min:1,max:10,step:.1,default:1},{id:"scratch",type:"slider",label:"Scratch Amount",property:"scratch",min:-1,max:1,step:.01,default:.5},{id:"scratchDensity",type:"slider",label:"Scratch Density",property:"scratchDensity",min:0,max:1,step:.01,default:.3},{id:"scratchWidth",type:"slider",label:"Scratch Width",property:"scratchWidth",min:1,max:20,step:1,default:1},{id:"vignetting",type:"slider",label:"Vignette Size",property:"vignetting",min:0,max:1,step:.01,default:.3},{id:"vignettingAlpha",type:"slider",label:"Vignette Opacity",property:"vignettingAlpha",min:0,max:1,step:.01,default:1},{id:"vignettingBlur",type:"slider",label:"Vignette Blur",property:"vignettingBlur",min:0,max:1,step:.01,default:.3},{id:"seed",type:"slider",label:"Random Seed",property:"seed",min:0,max:1,step:.01,default:.5},{id:"randomizeSeed",type:"button",label:"Randomize Seed",action:"randomizeSeed"}]});const{OutlineFilter:Vu}=Ie;Ne({id:"outline",name:"Outline",category:"effects",description:"Add an outline or stroke around the image",createFilter:n=>{try{let o=n.color;typeof o=="string"&&(o=parseInt(o.replace("#","0x"),16));const t=new Vu({thickness:n.thickness||1,color:o,alpha:n.alpha||1,quality:n.quality||.1,knockout:n.knockout||!1});return t._customParams={...n},t.updateUIParam=function(a,r){const i=this._customParams||{};switch(this._customParams=i,i[a]=r,a){case"thickness":this.thickness=Math.max(0,r);break;case"color":typeof r=="string"?(this.color=parseInt(r.replace("#","0x"),16),i.color=r):this.color=r;break;case"alpha":this.alpha=Math.max(0,Math.min(1,r));break;case"quality":this.quality=Math.max(.01,Math.min(1,r));break;case"knockout":this.knockout=!!r;break;default:a in this&&(this[a]=r);break}},t}catch{return null}},defaultParams:{thickness:2,color:"#000000",alpha:1,quality:.1,knockout:!1},controls:[{id:"thickness",type:"slider",label:"Thickness",property:"thickness",min:0,max:10,step:.1,default:2},{id:"color",type:"color",label:"Color",property:"color",default:"#000000"},{id:"alpha",type:"slider",label:"Alpha",property:"alpha",min:0,max:1,step:.01,default:1},{id:"quality",type:"slider",label:"Quality",property:"quality",min:.01,max:1,step:.01,default:.1,tooltip:"Higher values give better quality but slower performance"},{id:"knockout",type:"toggle",label:"Outline Only",property:"knockout",default:!1,tooltip:"Only show the outline, not the image content"}]});const{PixelateFilter:Cu}=Ie;Ne({id:"pixelate",name:"Pixelate",category:"effects",description:"Create a pixelated or mosaic effect",createFilter:n=>{try{const o=new Cu(n.useUniform?Math.max(2,n.size||10):[Math.max(2,n.sizeX||10),Math.max(2,n.sizeY||10)]);return o._customParams={...n},o.updateUIParam=function(t,a){const r=this._customParams||{};switch(this._customParams=r,r[t]=a,t){case"useUniform":if(r.useUniform=a,a){const i=Math.round((this.sizeX+this.sizeY)/2);this.size=Math.max(2,i),r.size=i}else{const i=Array.isArray(this.size)?this.size[0]:this.size;this.sizeX=Math.max(2,i),this.sizeY=Math.max(2,i),r.sizeX=this.sizeX,r.sizeY=this.sizeY}break;case"size":r.useUniform&&(this.size=Math.max(2,a));break;case"sizeX":r.useUniform||(this.sizeX=Math.max(2,a));break;case"sizeY":r.useUniform||(this.sizeY=Math.max(2,a));break;default:t in this&&(this[t]=a);break}},o}catch{return null}},defaultParams:{useUniform:!0,size:10,sizeX:10,sizeY:10},controls:[{id:"useUniform",type:"toggle",label:"Uniform Pixels",property:"useUniform",default:!0,tooltip:"Use the same size for both X and Y dimensions"},{id:"size",type:"slider",label:"Pixel Size",property:"size",min:2,max:40,step:1,default:10,tooltip:"Size of the pixels in both dimensions"},{id:"sizeX",type:"slider",label:"Horizontal Size",property:"sizeX",min:2,max:40,step:1,default:10,tooltip:"Size of the pixels in the horizontal direction"},{id:"sizeY",type:"slider",label:"Vertical Size",property:"sizeY",min:2,max:40,step:1,default:10,tooltip:"Size of the pixels in the vertical direction"}]});const{ReflectionFilter:Nu}=Ie;Ne({id:"reflection",name:"Reflection",category:"distortion",description:"Creates a water reflection effect with configurable waves",createFilter:n=>{try{const o={mirror:n.mirror??!0,boundary:n.boundary??.5,amplitude:[n.amplitudeStart??0,n.amplitudeEnd??20],waveLength:[n.wavelengthStart??30,n.wavelengthEnd??100],alpha:[n.alphaStart??1,n.alphaEnd??1],time:n.time??0},t=new Nu(o);return t._customParams={...n},t.animating=n.animating??!1,t.updateUIParam=function(a,r){const i=this._customParams||{};switch(this._customParams=i,i[a]=r,a){case"mirror":case"boundary":case"time":this[a]=r;break;case"amplitudeStart":Array.isArray(this.amplitude)||(this.amplitude=[0,this._customParams.amplitudeEnd||20]),this.amplitude[0]=r;break;case"amplitudeEnd":Array.isArray(this.amplitude)||(this.amplitude=[this._customParams.amplitudeStart||0,20]),this.amplitude[1]=r;break;case"wavelengthStart":Array.isArray(this.waveLength)||(this.waveLength=[30,this._customParams.wavelengthEnd||100]),this.waveLength[0]=r;break;case"wavelengthEnd":Array.isArray(this.waveLength)||(this.waveLength=[this._customParams.wavelengthStart||30,100]),this.waveLength[1]=r;break;case"alphaStart":Array.isArray(this.alpha)||(this.alpha=[1,this._customParams.alphaEnd||1]),this.alpha[0]=r;break;case"alphaEnd":Array.isArray(this.alpha)||(this.alpha=[this._customParams.alphaStart||1,1]),this.alpha[1]=r;break;case"animating":this.animating=r;break;default:a in this&&(this[a]=r);break}return!0},t}catch{return null}},defaultParams:{mirror:!0,boundary:.5,amplitudeStart:0,amplitudeEnd:20,wavelengthStart:30,wavelengthEnd:100,alphaStart:1,alphaEnd:1,time:0,animating:!1},controls:[{id:"mirror",type:"toggle",label:"Mirror Image",property:"mirror",default:!0},{id:"boundary",type:"slider",label:"Boundary Line",property:"boundary",min:0,max:1,step:.01,default:.5},{id:"amplitudeStart",type:"slider",label:"Wave Height (Start)",property:"amplitudeStart",min:0,max:50,step:1,default:0},{id:"amplitudeEnd",type:"slider",label:"Wave Height (End)",property:"amplitudeEnd",min:0,max:50,step:1,default:20},{id:"wavelengthStart",type:"slider",label:"Wave Length (Start)",property:"wavelengthStart",min:10,max:200,step:1,default:30},{id:"wavelengthEnd",type:"slider",label:"Wave Length (End)",property:"wavelengthEnd",min:10,max:200,step:1,default:100},{id:"alphaStart",type:"slider",label:"Opacity (Start)",property:"alphaStart",min:0,max:1,step:.01,default:1},{id:"alphaEnd",type:"slider",label:"Opacity (End)",property:"alphaEnd",min:0,max:1,step:.01,default:1},{id:"time",type:"slider",label:"Animation Time",property:"time",min:0,max:10,step:.1,default:0},{id:"animating",type:"toggle",label:"Auto Animate",property:"animating",default:!1}]});const{ShockwaveFilter:_u}=Ie;Ne({id:"shockwave",name:"Shockwave",category:"distortion",description:"Creates a rippling shockwave or blast wave effect",createFilter:n=>{try{const o=n.centerX??.5,t=n.centerY??.5,a={x:o,y:t},r=n.amplitude??30,i=n.wavelength??160,s=n.speed??500,l=n.brightness??1,c=n.radius??-1,d=n.time??0,u=new _u({center:a,amplitude:r,wavelength:i,speed:s,brightness:l,radius:c,time:d});return u._customParams={...n},u.animating=n.animating??!1,u.updateUIParam=function(p,m){const f=this._customParams||{};switch(this._customParams=f,f[p]=m,p){case"centerX":this.center||(this.center={x:.5,y:.5}),this.center.x=m;break;case"centerY":this.center||(this.center={x:.5,y:.5}),this.center.y=m;break;case"amplitude":case"wavelength":case"speed":case"brightness":case"radius":case"time":this[p]=m;break;case"animating":this.animating=m;break;default:p in this&&(this[p]=m);break}return!0},u}catch{return null}},defaultParams:{centerX:.5,centerY:.5,amplitude:30,wavelength:160,speed:500,brightness:1,radius:-1,time:0,animating:!1},controls:[{id:"centerX",type:"slider",label:"Center X",property:"centerX",min:0,max:1,step:.01,default:.5},{id:"centerY",type:"slider",label:"Center Y",property:"centerY",min:0,max:1,step:.01,default:.5},{id:"amplitude",type:"slider",label:"Amplitude",property:"amplitude",min:0,max:100,step:1,default:30},{id:"wavelength",type:"slider",label:"Wavelength",property:"wavelength",min:10,max:500,step:1,default:160},{id:"speed",type:"slider",label:"Speed",property:"speed",min:1,max:1e3,step:10,default:500},{id:"brightness",type:"slider",label:"Brightness",property:"brightness",min:0,max:5,step:.1,default:1},{id:"radius",type:"slider",label:"Max Radius",property:"radius",min:-1,max:1e3,step:10,default:-1},{id:"time",type:"slider",label:"Time",property:"time",min:0,max:5,step:.1,default:0},{id:"animating",type:"toggle",label:"Auto Animate",property:"animating",default:!1}]});const{SimplexNoiseFilter:Tu}=Ie;Ne({id:"simplex-noise",name:"Simplex Noise",category:"effects",description:"Apply procedural noise to create texture effects",createFilter:n=>{try{const o=n.animating?0:n.offsetZ||0,t=new Tu({strength:n.strength,noiseScale:n.noiseScale,offsetX:n.offsetX,offsetY:n.offsetY,offsetZ:o,step:n.step});t.animating=n.animating||!1,t.animationSpeed=n.animationSpeed||.01,t._customParams={...n};let a=null,r=0;const i=()=>{t.animating&&(r+=t.animationSpeed,t.offsetZ=r),a=requestAnimationFrame(i)};return t.animating&&(a=requestAnimationFrame(i)),t._stopAnimation=()=>{a!==null&&(cancelAnimationFrame(a),a=null)},t.updateUIParam=function(s,l){const c=this._customParams||{};switch(this._customParams=c,c[s]=l,s){case"animating":this.animating=l,l&&!a&&(a=requestAnimationFrame(i));break;case"animationSpeed":this.animationSpeed=l;break;case"offsetZ":this.animating||(this.offsetZ=l);break;case"randomizeSeed":if(l){const d=()=>Math.random()*100-50;this.offsetX=d(),this.offsetY=d(),this.offsetZ=d(),c.offsetX=this.offsetX,c.offsetY=this.offsetY,c.offsetZ=this.offsetZ}break;case"strength":case"noiseScale":case"offsetX":case"offsetY":case"step":s in this&&(this[s]=l);break;default:s in this&&(this[s]=l);break}},t}catch{return null}},defaultParams:{strength:.5,noiseScale:10,offsetX:0,offsetY:0,offsetZ:0,step:-1,animating:!1,animationSpeed:.01,randomizeSeed:!1},controls:[{id:"strength",type:"slider",label:"Noise Strength",property:"strength",min:0,max:1,step:.01,default:.5},{id:"noiseScale",type:"slider",label:"Noise Scale",property:"noiseScale",min:1,max:50,step:.5,default:10},{id:"offsetX",type:"slider",label:"X Offset",property:"offsetX",min:-50,max:50,step:.5,default:0},{id:"offsetY",type:"slider",label:"Y Offset",property:"offsetY",min:-50,max:50,step:.5,default:0},{id:"offsetZ",type:"slider",label:"Z Offset",property:"offsetZ",min:-50,max:50,step:.5,default:0},{id:"step",type:"slider",label:"Step Threshold",property:"step",min:-1,max:1,step:.01,default:-1,tooltip:"Values above 0 create a blocky effect"},{id:"animating",type:"toggle",label:"Animate Noise",property:"animating",default:!1},{id:"animationSpeed",type:"slider",label:"Animation Speed",property:"animationSpeed",min:.001,max:.05,step:.001,default:.01},{id:"randomizeSeed",type:"button",label:"Randomize Pattern",action:"randomizeSeed"}]});const{TwistFilter:Mu}=Ie;Ne({id:"twist",name:"Twist",category:"distortion",description:"Creates a twisting distortion effect around a central point",createFilter:n=>{try{const o=n.radius??200,t=n.angle??4,a=new Mu({radius:o,angle:t,padding:n.padding??20,offset:{x:n.offsetX??.5,y:n.offsetY??.5}});return a._offset=a.offset,n.offsetX=n.offsetX??.5,n.offsetY=n.offsetY??.5,a._customParams={...n},a.updateUIParam=function(r,i){const s=this._customParams||{};switch(this._customParams=s,s[r]=i,r){case"radius":case"angle":this[r]=i;break;case"offsetX":!this.offset||typeof this.offset!="object"?(this.offset={x:i,y:.5},this._offset=this.offset):this.offset.x=i,s.offsetX=i;break;case"offsetY":!this.offset||typeof this.offset!="object"?(this.offset={x:.5,y:i},this._offset=this.offset):this.offset.y=i,s.offsetY=i;break;case"padding":break;default:r in this&&(this[r]=i);break}},a}catch{return null}},defaultParams:{radius:200,angle:4,offsetX:.5,offsetY:.5,padding:20},controls:[{id:"angle",type:"slider",label:"Angle",property:"angle",min:-10,max:10,step:.1,default:4},{id:"radius",type:"slider",label:"Radius",property:"radius",min:1,max:500,step:1,default:200},{id:"offsetX",type:"slider",label:"Center X",property:"offsetX",min:0,max:1,step:.01,default:.5},{id:"offsetY",type:"slider",label:"Center Y",property:"offsetY",min:0,max:1,step:.01,default:.5}]});const{AdjustmentFilter:Fu}=Ie;function Xo(n){const o=typeof n=="string"?parseInt(n.replace("#","0x"),16):n;return[(o>>16&255)/255,(o>>8&255)/255,(o&255)/255]}class Iu extends Fu{constructor(o={}){super({brightness:1,contrast:1,saturation:1,alpha:1}),this._radius=.8,this._strength=1,this._colorRgb=[0,0,0],this._colorValue="#000000",this._radius=o.radius??.8,this._strength=o.strength??1,o.color!==void 0&&(typeof o.color=="string"?(this._colorValue=o.color,this._colorRgb=Xo(o.color)):(this._colorValue="#"+o.color.toString(16).padStart(6,"0"),this._colorRgb=Xo(o.color))),this.updateVignette()}updateVignette(){const o=1-this._radius/2,t=this._strength*o;this.brightness=Math.max(.5,1-t*.5),this.contrast=1+t*.2,(this._colorRgb[0]>0||this._colorRgb[1]>0||this._colorRgb[2]>0)&&(this.saturation=1-t*.3)}get radius(){return this._radius}set radius(o){this._radius=Math.max(.1,Math.min(1.5,o)),this.updateVignette()}get strength(){return this._strength}set strength(o){this._strength=Math.max(0,Math.min(2,o)),this.updateVignette()}get color(){return this._colorValue}set color(o){typeof o=="string"?(this._colorValue=o,this._colorRgb=Xo(o)):(this._colorValue="#"+o.toString(16).padStart(6,"0"),this._colorRgb=Xo(o)),this.updateVignette()}}Ne({id:"vignette",name:"Vignette",category:"effects",description:"Add a classic darkened border effect to the image",createFilter:n=>{try{const o=new Iu({radius:n.radius||.8,strength:n.strength||1,color:n.color||"#000000"});return o._customParams={...n},o.updateUIParam=function(t,a){const r=this._customParams||{};switch(this._customParams=r,r[t]=a,t){case"radius":this.radius=Math.max(.1,Math.min(1.5,a));break;case"strength":this.strength=Math.max(0,a);break;case"color":this.color=a,typeof a=="string"&&(r.color=a);break;default:t in this&&(this[t]=a);break}},o}catch{return null}},defaultParams:{radius:.8,strength:1,color:"#000000"},controls:[{id:"radius",type:"slider",label:"Radius",property:"radius",min:.1,max:1.5,step:.01,default:.8,tooltip:"Size of the vignette effect (larger values create a smaller vignette)"},{id:"strength",type:"slider",label:"Strength",property:"strength",min:0,max:2,step:.01,default:1,tooltip:"Intensity of the vignette effect"},{id:"color",type:"color",label:"Color",property:"color",default:"#000000",tooltip:"Color of the vignette (usually black)"}]});function Bu(){try{let n=[],o=[];try{n=yo(),n.length===0&&Ld()}catch{}try{n=yo(),o=Wd()}catch{n||(n=[]),o||(o=[])}return n.length,n}catch{return[]}}const Ru=e.defineComponent({__name:"ImageEditor",props:{initialImage:{},theme:{default:"auto"},cropShape:{default:"square"},preset:{},primaryColor:{default:"#3880ff"},secondaryColor:{default:"#5260ff"},saveButtonColor:{default:"#3880ff"},downloadButtonColor:{default:"#2dd36f"}},emits:["save","cancel","error"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(null);let i=null,s=null;function l(){if(!i){a("error",new Error("Editor not initialized"));return}const u=i.exportImage("png",.92);if(!u){a("error",new Error("Failed to export image — the image could not be processed"));return}const p=i.getState(),m=p.crop,f=p.activeFilters,v=p.filterValues,b=i._renderer.sprite,S={width:Math.round((b==null?void 0:b.width)??0),height:Math.round((b==null?void 0:b.height)??0)},M={imageData:u,dimensions:S,metadata:{hasCrop:(m==null?void 0:m.rect)!=null,cropRect:(m==null?void 0:m.rect)??null,filters:f?Array.from(f):[],filterValues:v??{},aspectRatio:(m==null?void 0:m.aspect)??"free",dimensions:S}};a("save",M)}function c(){a("cancel")}function d(){if(!r.value||i)return;window.PIXI=Ae,Bu();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"),i=new Et.VanillaImageEditor(r.value,u),i.setFilterRegistry({getAllFilters:yo,getFilter:El,getFiltersByCategory:Vl}),i.save=function(){l()},i.on("cancel",c),t.initialImage&&i.loadImage(t.initialImage)}return e.onMounted(()=>{r.value&&(r.value.clientWidth>0?d():(s=new ResizeObserver(u=>{const p=u[0];p&&p.contentRect.width>0&&!i&&(d(),s==null||s.disconnect(),s=null)}),s.observe(r.value)))}),e.watch(()=>t.initialImage,u=>{i&&u&&i.loadImage(u)}),e.onUnmounted(()=>{s==null||s.disconnect(),s=null,i&&(i.destroy(),i=null)}),(u,p)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:r,class:"vanilla-editor-wrapper","data-testid":"vanilla-image-editor"},null,512))}}),_e=(n,o)=>{const t=n.__vccOpts||n;for(const[a,r]of o)t[a]=r;return t},Nl=_e(Ru,[["__scopeId","data-v-3b3ff253"]]);function Pu(n,o){try{let t=Et.getFilter(n);if(t||(Et.registerCorePixiFilters(),t=Et.getFilter(n)),!t){try{const i=Et.getAllFilters()}catch{}return null}const a={...t.defaultParams,...o};return t.createFilter(a)}catch{return null}}const $u={class:"editor-modal-panel"},zu={class:"editor-fill"},Au=e.defineComponent({__name:"ImageEditorModal",props:{modelValue:{type:Boolean,default:!1},initialImage:{},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(n,{emit:o}){const t=n,a=o,r=e.ref(null),i=e.ref(t.modelValue),s=e.ref(null),l=e.ref(!1),c=e.ref(null),d=E=>new Promise((y,h)=>{const w=new FileReader;w.onload=R=>{var g;const N=(g=R.target)==null?void 0:g.result;typeof N=="string"?y(N):h(new Error("Failed to read file"))},w.onerror=()=>h(new Error("Failed to read file")),w.readAsDataURL(E)}),u=E=>{a("error",E)},p=async()=>{if(t.initialImage instanceof File)try{const E=await d(t.initialImage);s.value=E}catch(E){u(E)}else typeof t.initialImage=="string"&&(s.value=t.initialImage)},m=()=>{e.nextTick(()=>{if(r.value){const E=r.value.querySelector("button:not([disabled]), [href], input:not([disabled])");E&&E.focus()}})};e.watch(()=>t.modelValue,E=>{i.value=E,E&&(c.value=document.activeElement,t.initialImage&&p(),m())},{immediate:!0}),e.watch(()=>t.initialImage,E=>{E&&i.value&&p()});const f=async E=>{try{l.value=!0,t.onSave&&await t.onSave(E),a("save",E)}catch(y){u(y)}finally{l.value=!1}},v=()=>{a("cancel"),S()},b=()=>{l.value||S()},S=()=>{i.value=!1,a("update:modelValue",!1),c.value&&c.value instanceof HTMLElement&&(c.value.focus(),c.value=null),setTimeout(()=>{s.value=null},300)},M=E=>{if(E.key==="Escape"&&i.value&&!l.value){S();return}if(E.key==="Tab"&&i.value&&r.value){const y=r.value.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(y.length===0)return;const h=y[0],w=y[y.length-1];E.shiftKey&&document.activeElement===h?(E.preventDefault(),w.focus()):!E.shiftKey&&document.activeElement===w&&(E.preventDefault(),h.focus())}};return e.onMounted(()=>{document.addEventListener("keydown",M)}),e.onBeforeUnmount(()=>{document.removeEventListener("keydown",M)}),t.modelValue&&t.initialImage&&p(),(E,y)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[i.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"overlayRef",ref:r,role:"dialog","aria-modal":"true","aria-label":"Image editor",class:"editor-modal-overlay","data-testid":"image-editor-modal",onKeydown:e.withKeys(b,["escape"])},[e.createElementVNode("div",{class:"editor-modal-backdrop",onClick:b}),e.createElementVNode("div",$u,[e.createElementVNode("div",zu,[e.createVNode(Nl,{"initial-image":s.value??E.initialImage,theme:E.theme,"crop-shape":E.cropShape,preset:E.preset,"primary-color":E.primaryColor,"secondary-color":E.secondaryColor,"save-button-color":E.saveButtonColor,"download-button-color":E.downloadButtonColor,onSave:f,onCancel:v,onError:u},null,8,["initial-image","theme","crop-shape","preset","primary-color","secondary-color","save-button-color","download-button-color"])])])],544)):e.createCommentVNode("",!0)]))}}),_l=_e(Au,[["__scopeId","data-v-e19beb15"]]),Du={class:"media-workspace"},Uu={class:"media-workspace-toolbar"},Ou={class:"media-workspace-label"},Lu=["value"],Wu={class:"media-workspace-grid"},ju=["onClick"],Xu=e.defineComponent({__name:"MediaWorkspace",props:{apiScope:{},subScopes:{},initialScopeId:{}},emits:["scope-change","update:media","upload","preview"],setup(n,{emit:o}){var p;const t=n,a=o,r=wt(),i=e.ref(t.initialScopeId??((p=t.subScopes[0])==null?void 0:p.id)??""),s=e.computed(()=>t.subScopes),l=e.computed(()=>s.value.find(m=>m.id===i.value));let c=null;function d(){c&&(c(),c=null),t.apiScope&&(c=xl({apiScope:t.apiScope,isAdmin:t.apiScope==="admin"}))}async function u(){var f;const m={};(f=l.value)!=null&&f.collection&&(m.collection=l.value.collection),await r.fetchMedia(1,m),a("update:media",[...r.items])}return e.watch(()=>t.initialScopeId,m=>{m&&m!==i.value&&(i.value=m)}),e.watch(()=>t.subScopes,m=>{if(m.length===0){i.value="";return}m.some(f=>f.id===i.value)||(i.value=m[0].id)},{deep:!0}),e.watch(()=>t.apiScope,()=>{d(),u()}),e.watch(i,m=>{m&&(a("scope-change",m),u())}),e.onMounted(()=>{d(),u()}),e.onUnmounted(()=>{c&&(c(),c=null)}),(m,f)=>(e.openBlock(),e.createElementBlock("div",Du,[e.createElementVNode("div",Uu,[e.createElementVNode("label",Ou,[f[2]||(f[2]=e.createElementVNode("span",{class:"media-workspace-label-text"},"Scope",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":f[0]||(f[0]=v=>i.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,Lu))),128))],512),[[e.vModelSelect,i.value]])]),e.createElementVNode("button",{type:"button",class:"media-workspace-upload","data-testid":"upload-button",onClick:f[1]||(f[1]=v=>a("upload"))}," Upload ")]),e.createElementVNode("div",Wu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r).items,v=>(e.openBlock(),e.createElementBlock("button",{key:v.uuid,type:"button",class:"media-workspace-item","data-testid":"media-item",onClick:b=>a("preview",v)},e.toDisplayString(v.file_name),9,ju))),128))])]))}}),Zu=_e(Xu,[["__scopeId","data-v-895f26fe"]]),Yu={class:"managed-media-gallery"},Gu={class:"gallery-grid"},Hu=e.defineComponent({__name:"ManagedMediaGallery",props:{media:{},selectable:{type:Boolean},multiple:{type:Boolean}},emits:["select","remove"],setup(n){return(o,t)=>(e.openBlock(),e.createElementBlock("div",Yu,[e.createElementVNode("div",Gu,[e.renderSlot(o.$slots,"default",{},void 0,!0)])]))}}),Ju=_e(Hu,[["__scopeId","data-v-a60fdcd7"]]),qu="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>",Hr="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>",Ku="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>",Jr="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>",Qu="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>",em="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>",ao="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>",tm="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>",Tl="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>",Ml="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M416 128L192 384l-96-96' class='ionicon-fill-none ionicon-stroke-width'/></svg>",gs="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>",nm="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>",om="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>",ys="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>",bo="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>",bs="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>",am="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>",ln="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>",rm="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='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>",Kn="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>",im="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>",sm="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>",ws="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>",Fl="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='104' cy='152' r='56' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='104' cy='360' r='56' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M157 175l-11 15 37 15s3.46-6.42 7-10z' stroke-linecap='square' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path d='M154.17 334.43L460 162c-2.5-6.7-28-12-64-4-29.12 6.47-121.16 29.05-159.16 56.05C205.85 236.06 227 272 192 298c-25.61 19-44.43 22.82-44.43 22.82zM344.47 278.24L295 306.67c14.23 6.74 65.54 33.27 117 36.33 14.92.89 30 .39 39-6z' stroke-linecap='round' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='256' cy='240' r='32' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Na="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M336 176h40a40 40 0 0140 40v208a40 40 0 01-40 40H136a40 40 0 01-40-40V216a40 40 0 0140-40h40' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M176 272l80 80 80-80M256 48v288' class='ionicon-fill-none ionicon-stroke-width'/></svg>",lm="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>",cm="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>",dm="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>",ro="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>",ks="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>",ur="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>",um="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>",mm="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>",mr="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>",pm="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>",fm="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>",hm="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>",vm="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>",Il="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>",gm="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>",ym="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>",bm="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>",wm="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>",km="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>",Bl="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>",xm="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>",Sm="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>",Em="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>",Vm="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>",Cm="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>",So="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>",Nm="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>",_m="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>",xs="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>",Rl="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>",Tm="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>",pr="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M400 304l48 48-48 48M400 112l48 48-48 48M64 352h85.19a80 80 0 0066.56-35.62L256 256' class='ionicon-fill-none ionicon-stroke-width'/><path d='M64 160h85.19a80 80 0 0166.56 35.62l80.5 120.76A80 80 0 00362.81 352H416M416 160h-53.19a80 80 0 00-66.56 35.62L288 208' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",sn="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' class='ionicon'><path d='M259.92 262.91L216.4 149.77a9 9 0 00-16.8 0l-43.52 113.14a9 9 0 01-5.17 5.17L37.77 311.6a9 9 0 000 16.8l113.14 43.52a9 9 0 015.17 5.17l43.52 113.14a9 9 0 0016.8 0l43.52-113.14a9 9 0 015.17-5.17l113.14-43.52a9 9 0 000-16.8l-113.14-43.52a9 9 0 01-5.17-5.17zM108 68L88 16 68 68 16 88l52 20 20 52 20-52 52-20-52-20zM426.67 117.33L400 48l-26.67 69.33L304 144l69.33 26.67L400 240l26.67-69.33L496 144l-69.33-26.67z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Qn="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>",Ss="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>",Mm="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>",Pl="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='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>",Fm="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>",$l="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>",Im="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>",Bm="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>",Rm="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>",Pm="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>",$m="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>",zm="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>",Am="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>",Zo="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 Es=()=>{};function Dm(n,o){function t(...a){return new Promise((r,i)=>{Promise.resolve(n(()=>o.apply(this,a),{fn:o,thisArg:this,args:a})).then(r).catch(i)})}return t}function Um(n,o={}){let t,a,r=Es;const i=c=>{clearTimeout(c),r(),r=Es};let s;return c=>{const d=e.toValue(n),u=e.toValue(o.maxWait);return t&&i(t),d<=0||u!==void 0&&u<=0?(a&&(i(a),a=null),Promise.resolve(c())):new Promise((p,m)=>{r=o.rejectOnCancel?m:p,s=c,u&&!a&&(a=setTimeout(()=>{t&&i(t),a=null,p(s())},u)),t=setTimeout(()=>{a&&i(a),a=null,p(c())},d)})}}function Om(n,o=200,t={}){return Dm(Um(o,t),n)}const eo=new Map;function Lm(n){const o=e.getCurrentScope();function t(l){var c;const d=eo.get(n)||new Set;d.add(l),eo.set(n,d);const u=()=>r(l);return(c=o==null?void 0:o.cleanups)==null||c.push(u),u}function a(l){function c(...d){r(c),l(...d)}return t(c)}function r(l){const c=eo.get(n);c&&(c.delete(l),c.size||i())}function i(){eo.delete(n)}function s(l,c){var d;(d=eo.get(n))==null||d.forEach(u=>u(l,c))}return{on:t,once:a,off:r,emit:s,reset:i}}function Wm(){var i,s;const n=typeof window<"u"&&"Capacitor"in window&&((s=(i=window.Capacitor)==null?void 0:i.isNativePlatform)==null?void 0:s.call(i));return{selection:()=>{var l,c;if(n)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(n)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(n)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(n)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 jm(n){const o=e.ref(new Set),t=e.ref(null),a=e.ref(-1),r=Lm("media-selection"),i=Wm(),s=e.computed(()=>n.value.filter(w=>o.value.has(w.uuid))),l=e.computed(()=>o.value.size);e.watch(o,w=>{r.emit({type:"selection:changed",count:w.size,selectedIds:Array.from(w)})},{deep:!0});const c=e.computed(()=>n.value.length>0&&n.value.every(w=>o.value.has(w.uuid))),d=e.computed(()=>n.value.some(w=>o.value.has(w.uuid)));function u(w){return o.value.has(w)}function p(w){o.value.has(w)?(o.value.delete(w),t.value===w&&(t.value=null,a.value=-1)):(o.value.add(w),t.value=w,a.value=n.value.findIndex(R=>R.uuid===w),o.value.size===1&&i.selection())}function m(w){o.value.add(w),t.value=w,a.value=n.value.findIndex(R=>R.uuid===w)}function f(w){o.value.delete(w),t.value===w&&(t.value=null,a.value=-1)}function v(){n.value.forEach(w=>o.value.add(w.uuid))}function b(){o.value.clear(),t.value=null,a.value=-1}function S(){c.value?b():v()}function M(w,R){const N=n.value.findIndex(g=>g.uuid===w);if(N!==-1)if(R!=null&&R.shiftKey&&a.value!==-1){const g=Math.min(a.value,N),C=Math.max(a.value,N);for(let A=g;A<=C;A++)o.value.add(n.value[A].uuid)}else p(w)}function E(){if(n.value.length===0)return;let w=a.value+1;w>=n.value.length&&(w=0),b(),m(n.value[w].uuid)}function y(){if(n.value.length===0)return;let w=a.value-1;w<0&&(w=n.value.length-1),b(),m(n.value[w].uuid)}function h(w){switch(w.key){case"ArrowDown":w.preventDefault(),E();break;case"ArrowUp":w.preventDefault(),y();break;case"a":(w.ctrlKey||w.metaKey)&&(w.preventDefault(),v());break;case"Escape":w.preventDefault(),b();break;case" ":t.value&&(w.preventDefault(),p(t.value));break}}return{selectedIds:e.computed(()=>o.value),selectedItems:s,selectedCount:l,isAllSelected:c,isSomeSelected:d,lastSelectedId:e.computed(()=>t.value),isSelected:u,toggle:p,select:m,deselect:f,selectAll:v,clear:b,toggleAll:S,rangeSelect:M,selectNext:E,selectPrevious:y,handleKeydown:h,selectionBus:r}}const Xm={class:"flex items-center justify-between w-full px-4"},Zm={class:"p-4"},Ym={key:0,class:"mb-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg"},Gm={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"},Hm=["value"],Jm={class:"flex gap-2 mt-4"},qm={class:"flex justify-end mb-4"},Km={key:1,class:"flex justify-center items-center h-64"},Qm={key:2,class:"flex flex-col items-center justify-center h-64 text-center"},ep={class:"text-sm text-theme-secondary"},tp={key:0},np={class:"mb-4"},op={class:"mb-4"},ap={class:"flex gap-2"},rp={class:"flex items-center justify-between px-4 py-2"},ip={class:"text-sm text-theme-secondary"},sp={key:0},lp={key:0},cp={key:1},dp={class:"flex gap-2"},up=e.defineComponent({__name:"AdminMediaBrowser",props:{isOpen:{type:Boolean},selectionMode:{default:"single"},selectedItems:{default:()=>[]},modelType:{},modelId:{},collection:{default:"images"},maxSelection:{}},emits:["close","confirm"],setup(n,{emit:o}){const t=n,a=o,r=e.ref("recent"),i=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)),p=e.ref(!1),m=e.ref({}),f=e.ref(["images","documents","videos"]),v=e.ref(1),b=e.ref(!0),S=e.ref(!1),M=Sl(),E=jm(c);function y(F){var ge;const O=F.conversion_urls||{},de=F.proxy_url||F.original_url||F.url||"",re=O.thumb||O.preview||F.preview_url||F.thumbnail_url||de,q=F.custom_properties||{},ee=q.width,ue=q.height;return{...F,uuid:F.uuid,name:F.name||F.file_name,file_name:F.file_name,filename:F.file_name,mime_type:F.mime_type,size:F.size,collection_name:F.collection_name||"images",disk:F.disk,original_url:de,url:de,thumbnail_url:re,conversions:F.conversions||{},conversion_urls:O,generated_conversions:F.generated_conversions||{},custom_properties:q,caption:F.caption||null,alt_text:F.alt_text||null,created_at:F.created_at,updated_at:F.updated_at,is_image:((ge=F.mime_type)==null?void 0:ge.startsWith("image/"))||!1,...typeof ee=="number"?{width:ee}:{},...typeof ue=="number"?{height:ue}:{},...F.formatted_size!==void 0?{formatted_size:F.formatted_size}:{}}}e.watch(()=>t.selectedItems,F=>{u.value=new Set(F),E.clear(),F.forEach(O=>E.select(O))});const h=e.computed(()=>{var O;let F=c.value;return(O=m.value.types)!=null&&O.length&&(F=F.filter(de=>{var q,ee;const re=(q=de.mime_type)==null?void 0:q.split("/")[0];return(ee=m.value.types)==null?void 0:ee.includes(re)})),(m.value.sizeMin!==void 0||m.value.sizeMax!==void 0)&&(F=F.filter(de=>{const re=de.size/1048576;return!(m.value.sizeMin!==void 0&&re<m.value.sizeMin||m.value.sizeMax!==void 0&&re>m.value.sizeMax)})),F}),w=e.computed(()=>{var O;let F=0;return m.value.search&&F++,m.value.collection&&F++,(m.value.dateFrom||m.value.dateTo)&&F++,(O=m.value.types)!=null&&O.length&&(F+=m.value.types.length),(m.value.sizeMin!==void 0||m.value.sizeMax!==void 0)&&F++,F}),R=e.computed(()=>{const F=E.selectedCount.value;return F===0?"Select Media":`Select ${t.selectionMode==="multiple"?`${F} ${F===1?"Item":"Items"}`:"Item"}`}),N=e.computed(()=>{const F=E.selectedCount.value;return!!(F===0||t.selectionMode==="single"&&F>1||t.maxSelection&&F>t.maxSelection)}),g=e.computed(()=>{switch(r.value){case"recent":return"Recent Uploads";case"model":return"Model Media";case"library":return"Media Library";default:return"Media Browser"}});async function C(F=!0){F?(l.value=!0,c.value=[],v.value=1,b.value=!0):S.value=!0;try{const O={collection:m.value.collection||t.collection,per_page:24};switch((s.value||m.value.search)&&(O.search=s.value||m.value.search||""),m.value.dateFrom&&(O.from_date=m.value.dateFrom),m.value.dateTo&&(O.to_date=m.value.dateTo),r.value){case"recent":await M.fetchMedia(v.value,O),F?c.value=M.items.map(de=>y(de)):c.value=[...c.value,...M.items.map(de=>y(de))],b.value=M.currentPage<M.totalPages;break;case"model":if(t.modelType&&t.modelId){const de=await M.fetchModelMedia(t.modelType,t.modelId,O.collection,O.search);c.value=de?de.map(re=>y(re)):[],b.value=!1}break;case"library":await M.fetchMedia(v.value,O),F?c.value=M.items.map(de=>y(de)):c.value=[...c.value,...M.items.map(de=>y(de))],b.value=M.currentPage<M.totalPages;break}}catch{}finally{l.value=!1,S.value=!1}}async function A(F){if(!b.value||S.value){F!=null&&F.target&&F.target.complete();return}v.value++,await C(!1),F!=null&&F.target&&(F.target.complete(),b.value||(F.target.disabled=!0))}function x(F){return F==="recent"||F==="model"||F==="library"}function T(F){r.value=F,C()}function I(F){typeof F=="string"&&x(F)&&T(F)}async function z(F){t.selectionMode==="single"?(E.clear(),E.select(F.uuid)):(E.toggle(F.uuid),t.maxSelection&&E.selectedCount.value>t.maxSelection&&(E.deselect(F.uuid),await(await B.toastController.create({message:`Maximum ${t.maxSelection} items can be selected`,duration:2e3,color:"warning"})).present()))}function P(){a("confirm",E.selectedItems.value)}function j(){a("close")}function L(F){}const _=e.ref(null),D=e.ref(!1);function G(F){_.value=F,D.value=!0}function X(F){const O=c.value.findIndex(re=>re.uuid===F.uuid);O!==-1&&(c.value[O]=F);const de={};F.alt_text!==void 0&&(de.alt_text=F.alt_text),F.caption!==void 0&&(de.caption=F.caption),F.custom_properties!==void 0&&(de.custom_properties=F.custom_properties),M.updateMedia(F.uuid,de)}function ce(){C()}function Me(){m.value={},s.value="",C()}const $e=Om(()=>{C(!0)},300);e.watch(s,()=>{t.isOpen&&$e()});async function ae(F){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 M.deleteMedia(F),await C()}}]})).present()}catch{}}return e.watch(()=>t.isOpen,F=>{F&&C()}),e.onMounted(()=>{t.selectedItems.length>0&&t.selectedItems.forEach(F=>E.select(F))}),(F,O)=>{const de=e.resolveComponent("AdminMediaGrid"),re=e.resolveComponent("AdminMediaListItem");return e.openBlock(),e.createBlock(e.unref(B.IonModal),{"is-open":F.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",Xm,[e.createVNode(e.unref(B.IonSegment),{value:r.value,onIonChange:O[0]||(O[0]=q=>I(q.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(()=>[...O[15]||(O[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(()=>[...O[16]||(O[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(()=>[...O[17]||(O[17]=[e.createTextVNode("Library",-1)])]),_:1})]),_:1})]),_:1},8,["value"]),e.createVNode(e.unref(B.IonButton),{fill:"clear",size:"small",onClick:O[1]||(O[1]=q=>p.value=!p.value),class:"relative"},{"icon-only":e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{name:"filter-outline"})]),default:e.withCtx(()=>[w.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(w.value),1)]),_:1})):e.createCommentVNode("",!0)]),_:1})])]),_:1})]),_:1}),e.createVNode(e.unref(B.IonContent),null,{default:e.withCtx(()=>[e.createElementVNode("div",Zm,[p.value?(e.openBlock(),e.createElementBlock("div",Ym,[e.createElementVNode("div",Gm,[e.createElementVNode("div",null,[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...O[18]||(O[18]=[e.createTextVNode("Collection",-1)])]),_:1}),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":O[2]||(O[2]=q=>m.value.collection=q),class:"w-full p-2 border rounded"},[O[19]||(O[19]=e.createElementVNode("option",{value:""},"All Collections",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,q=>(e.openBlock(),e.createElementBlock("option",{key:q,value:q},e.toDisplayString(q),9,Hm))),128))],512),[[e.vModelSelect,m.value.collection]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...O[20]||(O[20]=[e.createTextVNode("From Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":O[3]||(O[3]=q=>m.value.dateFrom=q),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,m.value.dateFrom]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...O[21]||(O[21]=[e.createTextVNode("To Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":O[4]||(O[4]=q=>m.value.dateTo=q),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,m.value.dateTo]])])]),e.createElementVNode("div",Jm,[e.createVNode(e.unref(B.IonButton),{size:"small",onClick:ce},{default:e.withCtx(()=>[...O[22]||(O[22]=[e.createTextVNode("Apply",-1)])]),_:1}),e.createVNode(e.unref(B.IonButton),{size:"small",fill:"clear",onClick:Me},{default:e.withCtx(()=>[...O[23]||(O[23]=[e.createTextVNode("Clear",-1)])]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(e.unref(B.IonSearchbar),{modelValue:s.value,"onUpdate:modelValue":O[5]||(O[5]=q=>s.value=q),placeholder:"Search media...",debounce:300,class:"mb-4"},null,8,["modelValue"]),e.createElementVNode("div",qm,[e.createVNode(e.unref(B.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonButton),{fill:i.value==="grid"?"solid":"clear",size:"small",onClick:O[6]||(O[6]=q=>i.value="grid")},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{name:"grid-outline"})]),_:1},8,["fill"]),e.createVNode(e.unref(B.IonButton),{fill:i.value==="list"?"solid":"clear",size:"small",onClick:O[7]||(O[7]=q=>i.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",Km,[e.createVNode(e.unref(B.IonSpinner),{name:"crescent"})])):h.value.length===0?(e.openBlock(),e.createElementBlock("div",Qm,[e.createVNode(e.unref(B.IonIcon),{name:"images-outline",class:"text-6xl text-theme-secondary mb-4"}),O[24]||(O[24]=e.createElementVNode("h3",{class:"text-lg font-medium text-theme mb-2"}," No Media Found ",-1)),e.createElementVNode("p",ep,e.toDisplayString(s.value?"Try adjusting your search":"No media items available"),1)])):i.value==="grid"?(e.openBlock(),e.createBlock(de,{key:3,"media-items":h.value,"selected-items":e.unref(E).selectedItems.value,"is-loading":!1,"selection-mode":!0,columns:{mobile:2,sm:3,md:4,lg:5,xl:6},onToggleSelect:z,onPreview:L,onEdit:G,onDelete:ae},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(h.value,(q,ee)=>(e.openBlock(),e.createBlock(re,{key:q.uuid,media:q,selected:e.unref(E).isSelected(q.uuid),"selection-mode":!0,index:ee,onToggleSelect:z,onPreview:L,onEdit:G,onDelete:ae},null,8,["media","selected","index"]))),128))]),_:1})),!l.value&&h.value.length>0&&r.value!=="model"?(e.openBlock(),e.createBlock(e.unref(B.IonInfiniteScroll),{key:5,threshold:"100px",onIonInfinite:O[8]||(O[8]=q=>A(q))},{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:O[14]||(O[14]=q=>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:O[9]||(O[9]=q=>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(()=>[...O[25]||(O[25]=[e.createTextVNode("Edit Media Info",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(B.IonContent),{class:"p-4"},{default:e.withCtx(()=>[_.value?(e.openBlock(),e.createElementBlock("div",tp,[e.createElementVNode("div",np,[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...O[26]||(O[26]=[e.createTextVNode("Caption",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":O[10]||(O[10]=q=>_.value.caption=q),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter caption..."},null,512),[[e.vModelText,_.value.caption]])]),e.createElementVNode("div",op,[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...O[27]||(O[27]=[e.createTextVNode("Alt Text",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":O[11]||(O[11]=q=>_.value.alt_text=q),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter alt text..."},null,512),[[e.vModelText,_.value.alt_text]])]),e.createElementVNode("div",ap,[e.createVNode(e.unref(B.IonButton),{onClick:O[12]||(O[12]=q=>X(_.value))},{default:e.withCtx(()=>[...O[28]||(O[28]=[e.createTextVNode("Save",-1)])]),_:1}),e.createVNode(e.unref(B.IonButton),{fill:"clear",onClick:O[13]||(O[13]=q=>D.value=!1)},{default:e.withCtx(()=>[...O[29]||(O[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",rp,[e.createElementVNode("div",ip,[e.unref(E).selectedCount.value>0?(e.openBlock(),e.createElementBlock("span",sp,[e.createTextVNode(e.toDisplayString(e.unref(E).selectedCount.value)+" selected ",1),t.maxSelection?(e.openBlock(),e.createElementBlock("span",lp," / "+e.toDisplayString(t.maxSelection)+" max ",1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("span",cp," Select "+e.toDisplayString(t.selectionMode==="multiple"?"items":"an item"),1))]),e.createElementVNode("div",dp,[e.createVNode(e.unref(B.IonButton),{fill:"clear",onClick:j},{default:e.withCtx(()=>[...O[30]||(O[30]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(B.IonButton),{disabled:N.value,onClick:P},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(R.value),1)]),_:1},8,["disabled"])])])]),_:1})]),_:1})]),_:1},8,["is-open"])}}}),mp=_e(up,[["__scopeId","data-v-9a8c0954"]]),pp={key:1,class:"flex flex-col items-center justify-center py-16"},fp=["draggable","onDragstart","onDragover","onDrop"],hp={key:0,class:"absolute top-2 left-2 z-20"},vp=["checked","onChange"],gp={key:2,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-move"},yp=["data-media-id"],bp={key:0,class:"w-full h-full flex items-center justify-center"},wp=["src","alt","onError","onLoad"],kp={key:2,class:"w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-700"},xp={class:"text-center"},Sp={class:"text-4xl text-gray-400 mb-2"},Ep={class:"text-sm font-medium text-gray-500"},Vp={class:"absolute inset-0 bg-black/70 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2"},Cp=["onClick"],Np=["onClick"],_p=["onClick"],Tp={class:"p-3"},Mp={class:"text-sm font-medium truncate mb-1"},Fp={class:"text-xs text-gray-600 dark:text-gray-400"},Ip={key:0},Bp={key:0,class:"text-xs text-gray-500 dark:text-gray-500 mt-1 truncate"},Rp=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(n,{emit:o}){const t=n,a=o,r=e.ref(null),i=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,C){t.reorderable&&(r.value=g,N.dataTransfer&&(N.dataTransfer.effectAllowed="move",N.dataTransfer.setData("text/html","")))}function p(N,g){t.reorderable&&(N.preventDefault(),i.value=g)}function m(){i.value=null}function f(N,g){if(!t.reorderable||!r.value)return;N.preventDefault();const C=[...t.mediaItems],A=C.findIndex(x=>{var T;return x.uuid===((T=r.value)==null?void 0:T.uuid)});if(A!==-1&&A!==g&&r.value){const[x]=C.splice(A,1);C.splice(g,0,x),a("reorder",C)}r.value=null,i.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 b(N){var C;return N.thumbnail_url||((C=N.conversion_urls)==null?void 0:C.thumb)||N.original_url||N.url||""}function S(N){var A,x,T;const g=((A=N.mime_type)==null?void 0:A.startsWith("image/"))||!1,C=!!(N.thumbnail_url||(x=N.conversion_urls)!=null&&x.thumb||(T=N.conversion_urls)!=null&&T.preview||N.original_url||N.url);return g&&C}function M(N){var g;return((g=N.split(".").pop())==null?void 0:g.toUpperCase())||""}function E(N){var C;const g=((C=N.mime_type)==null?void 0:C.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 C;if(g.isIntersecting){const A=g.target.getAttribute("data-media-id");A&&(s.value.add(A),(C=l.value)==null||C.unobserve(g.target))}})},{rootMargin:"50px"}))}),e.onUnmounted(()=>{l.value&&l.value.disconnect()});function y(N){return!0}function h(){l.value&&e.nextTick(()=>{document.querySelectorAll("[data-media-id]").forEach(g=>{var A;const C=g.getAttribute("data-media-id");C&&!s.value.has(C)&&((A=l.value)==null||A.observe(g))})})}e.watch(()=>t.mediaItems,()=>{s.value.clear(),h()},{immediate:!0,deep:!0});function w(N,g){const C=N.target;delete C.dataset.fallbackIndex}function R(N,g){const C=N.target,A=C.closest("[data-media-id]"),x=[g.original_url,g.url,g.thumbnail_url,"preview_url"in g?g.preview_url:void 0].filter(T=>T&&T.trim()!==""&&T!==C.src);if(x.length>0&&C.dataset.fallbackIndex){const T=parseInt(C.dataset.fallbackIndex);if(T<x.length){C.dataset.fallbackIndex=(T+1).toString(),C.src=x[T]||"";return}}else if(x.length>0){C.dataset.fallbackIndex="1",C.src=x[0]||"";return}if(C.style.display="none",A&&!A.querySelector(".media-fallback-icon")){const I=document.createElement("div");I.className="media-fallback-icon w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-800",I.innerHTML=`
|
|
2
|
+
<div class="text-center">
|
|
3
|
+
<div class="text-4xl text-gray-400 mb-2">${E(g)}</div>
|
|
4
|
+
<p class="text-sm font-medium text-gray-500">${M(g.file_name)}</p>
|
|
5
|
+
</div>
|
|
6
|
+
`,A.appendChild(I)}}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,C=>e.createElementVNode("div",{key:`skeleton-${C}`,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",pp,[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]=C=>a("upload")),class:"px-3 py-2 bg-blue-500 text-white rounded hover:bg-blue-600"}," Upload Media ")])):(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(d.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(N.mediaItems,(C,A)=>(e.openBlock(),e.createElementBlock("div",{key:C.uuid,class:e.normalizeClass(["relative group",{"ring-2 ring-blue-500 ring-offset-2":i.value===A}]),draggable:N.reorderable,onDragstart:x=>u(x,C),onDragover:x=>p(x,A),onDragleave:m,onDrop:x=>f(x,A)},[N.selectionMode?(e.openBlock(),e.createElementBlock("div",hp,[e.createElementVNode("input",{type:"checkbox",checked:c(C),onChange:x=>a("toggleSelect",C),class:"w-5 h-5 bg-white dark:bg-gray-800 rounded cursor-pointer"},null,40,vp)])):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:C,index:A},void 0,!0)],2)):e.createCommentVNode("",!0),N.reorderable?(e.openBlock(),e.createElementBlock("div",gp,[...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(C)}])},[e.createElementVNode("div",{class:"relative aspect-square bg-gray-100 dark:bg-gray-700 overflow-hidden","data-media-id":C.uuid},[S(C)&&!y(C.uuid)?(e.openBlock(),e.createElementBlock("div",bp,[...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),S(C)&&y(C.uuid)?(e.openBlock(),e.createElementBlock("img",{key:1,src:b(C),alt:C.alt_text||C.file_name,class:"w-full h-full object-cover",loading:"lazy",onError:x=>R(x,C),onLoad:x=>w(x)},null,40,wp)):(e.openBlock(),e.createElementBlock("div",kp,[e.createElementVNode("div",xp,[e.createElementVNode("div",Sp,e.toDisplayString(E(C)),1),e.createElementVNode("p",Ep,e.toDisplayString(M(C.file_name)),1)])])),e.createElementVNode("div",Vp,[e.createElementVNode("button",{onClick:x=>a("preview",C),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,Cp),N.showEditButton&&S(C)?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:x=>a("edit",C),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,Np)):e.createCommentVNode("",!0),e.createElementVNode("button",{onClick:x=>a("delete",C.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,_p)])],8,yp),e.createElementVNode("div",Tp,[e.createElementVNode("h4",Mp,e.toDisplayString(C.file_name),1),e.createElementVNode("p",Fp,[e.createTextVNode(e.toDisplayString(v(C.size))+" ",1),C.width&&C.height?(e.openBlock(),e.createElementBlock("span",Ip," • "+e.toDisplayString(C.width)+"x"+e.toDisplayString(C.height),1)):e.createCommentVNode("",!0)]),C.caption?(e.openBlock(),e.createElementBlock("p",Bp,e.toDisplayString(C.caption),1)):e.createCommentVNode("",!0)])],2)],42,fp))),128))],2))}}),Pp=_e(Rp,[["__scopeId","data-v-f0c343b7"]]),$p={class:"model-media-manager"},zp=["accept","multiple"],Ap={class:"flex items-center justify-between mb-4"},Dp={key:0,class:"text-lg font-medium"},Up={class:"flex gap-2"},Op={key:0,class:"flex items-center justify-center py-8"},Lp={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"},Wp={class:"text-gray-600 dark:text-gray-400"},jp={class:"flex gap-2 mt-4"},Xp={key:0,class:"px-2 py-1 bg-blue-500 text-white text-xs font-medium rounded"},Zp=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(n,{emit:o}){const t=n,a=o,r=wt(),i=e.ref(!1),s=e.ref(!1),l=e.ref(!1),c=e.ref(!1),d=e.ref(null),u=e.ref(null),p=e.ref(null),m=e.computed(()=>{if(t.maxFiles!==void 0)return Math.max(0,t.maxFiles-r.modelMedia.length)}),f=e.computed(()=>r.modelMedia.map(L=>L.uuid)),v=e.computed(()=>{if(!(!t.acceptedMimeTypes||t.acceptedMimeTypes.length===0))return t.acceptedMimeTypes.join(",")}),b=e.computed(()=>{if(d.value)return w(d.value)??void 0});function S(){Dn({isAdmin:t.mode==="admin"})}async function M(L){await(await B.toastController.create({message:L,duration:3e3,color:"danger",position:"bottom"})).present()}async function E(){if(!s.value)if(s.value=!0,S(),r.setModelContext(t.mediableType,t.mediableId,t.collection),t.initialMedia&&t.initialMedia.length>0)r.modelMedia=[...t.initialMedia],a("update:media",r.modelMedia);else{i.value=!0,a("loading",!0);try{await r.fetchModelMedia(t.mediableType,t.mediableId,t.collection),a("update:media",r.modelMedia)}catch(L){const _=L instanceof Error?L.message:"Failed to fetch media";a("error",{operation:"fetch",message:_,details:L})}finally{i.value=!1,a("loading",!1)}}}e.watch(()=>r.modelMedia,L=>{s.value&&a("update:media",L)},{deep:!0}),e.watch(()=>[t.mediableType,t.mediableId,t.collection],()=>{s.value=!1,E()}),e.watch(()=>t.mode,()=>{S()}),e.onMounted(()=>{E()}),e.onUnmounted(()=>{r.clearModelContext()});function y(){return r.modelMedia.length>0}function h(){return t.maxFiles===void 0?!1:r.modelMedia.length>=t.maxFiles}function w(L){var D,G,X;if(!((D=L.mime_type)!=null&&D.startsWith("image/")))return null;const _=L.original_url||L.url||((G=L.conversion_urls)==null?void 0:G.preview)||((X=L.conversion_urls)==null?void 0:X.thumb)||L.thumbnail_url;return _&&_.trim()!==""?_:null}function R(){l.value=!0}function N(){var L;(L=p.value)==null||L.click()}function g(){l.value=!1}function C(L){!t.allowEdit||!w(L)||(d.value=L,c.value=!0)}function A(){c.value=!1,d.value=null}async function x(L){if(!d.value)throw new Error("No media selected for editing");const _=d.value,D=t.editMode==="variant";try{u.value=null;const G=await r.saveEditedImage(_.uuid,L,{asVariant:D,name:_.file_name});D||await r.detachMedia(t.mediableType,t.mediableId,_.uuid,t.collection),await r.attachMedia(t.mediableType,t.mediableId,[G.uuid],t.collection),a("edit-complete",{originalMedia:_,editedMedia:G,mode:t.editMode}),c.value=!1,d.value=null}catch(G){const X=G instanceof Error?G.message:"Failed to save edited image";throw u.value=X,await M(X),G}}function T(L){if(u.value===L.message){u.value=null;return}M(L.message)}async function I(L){const _=L.target,D=_.files;if(!(!D||D.length===0)){for(let G=0;G<D.length;G++){const X=D[G];if(m.value!==void 0&&m.value<=0)break;if(t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0&&!t.acceptedMimeTypes.includes(X.type)){a("error",{operation:"upload",message:`File type ${X.type} is not accepted`,details:{file:X.name}});continue}if(t.maxFileSize!==void 0&&X.size>t.maxFileSize){a("error",{operation:"upload",message:`File size exceeds limit of ${t.maxFileSize} bytes`,details:{file:X.name,size:X.size}});continue}a("upload-progress",{status:"uploading",progress:0,file:X});try{const ce=await r.uploadFile(X,{collection:t.collection});ce!=null&&ce.uuid&&(await r.attachMedia(t.mediableType,t.mediableId,[ce.uuid],t.collection),a("upload-progress",{status:"complete",progress:100,file:X}),a("attach",[ce]))}catch(ce){const Me=ce instanceof Error?ce.message:"Upload failed";a("error",{operation:"upload",message:Me,details:ce}),a("upload-progress",{status:"error",progress:0,file:X,error:Me})}}_.value=""}}async function z(L){const _=L.map(D=>D.uuid);try{await r.reorderMedia(t.mediableType,t.mediableId,_,t.collection),a("reorder",r.modelMedia)}catch(D){const G=D instanceof Error?D.message:"Failed to reorder media";a("error",{operation:"reorder",message:G,details:D}),await M(G)}}async function P(L){const _=r.modelMedia.find(D=>D.uuid===L);try{await r.detachMedia(t.mediableType,t.mediableId,L,t.collection),_&&a("detach",_)}catch(D){const G=D instanceof Error?D.message:"Failed to detach media";a("error",{operation:"detach",message:G,details:D}),await M(G)}}async function j(L){l.value=!1;const _=L.map(X=>X.uuid),D=new Set(f.value);let G=Array.from(new Set(_)).filter(X=>!D.has(X));if(m.value!==void 0&&G.length>m.value&&(G=G.slice(0,m.value)),G.length!==0)try{await r.attachMedia(t.mediableType,t.mediableId,G,t.collection);const X=r.modelMedia.filter(ce=>G.includes(ce.uuid));a("attach",X)}catch(X){const ce=X instanceof Error?X.message:"Failed to attach media";a("error",{operation:"attach",message:ce,details:X})}}return(L,_)=>(e.openBlock(),e.createElementBlock("div",$p,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:p,type:"file",accept:v.value,multiple:m.value===void 0||m.value>1,class:"hidden","data-testid":"upload-input",onChange:I},null,40,zp),e.createElementVNode("div",Ap,[L.title?(e.openBlock(),e.createElementBlock("h3",Dp,e.toDisplayString(L.title),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Up,[L.allowBrowse?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:0,fill:"outline",size:"small",disabled:h(),"data-testid":"browse-button",onClick:R},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{slot:"start",icon:e.unref(mr)},null,8,["icon"]),_[1]||(_[1]=e.createTextVNode(" Browse ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0),L.allowUpload?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:1,fill:"solid",size:"small",disabled:h(),"data-testid":"upload-button",onClick:N},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{slot:"start",icon:e.unref(bs)},null,8,["icon"]),_[2]||(_[2]=e.createTextVNode(" Upload ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0)])]),i.value||e.unref(r).isLoadingModelMedia?(e.openBlock(),e.createElementBlock("div",Op,[e.createVNode(e.unref(B.IonSpinner),{"data-testid":"spinner"})])):y()?(e.openBlock(),e.createBlock(Pp,{key:2,"media-items":e.unref(r).modelMedia,reorderable:!!L.allowReorder,"is-loading":i.value||e.unref(r).isLoadingModelMedia,"show-edit-button":!!L.allowEdit,"selection-mode":!1,onReorder:z,onDelete:P,onEdit:C},e.createSlots({_:2},[L.showPrimaryBadge?{name:"badge",fn:e.withCtx(({index:D})=>[D===0?(e.openBlock(),e.createElementBlock("div",Xp," Primary ")):e.createCommentVNode("",!0)]),key:"0"}:void 0]),1032,["media-items","reorderable","is-loading","show-edit-button"])):(e.openBlock(),e.createElementBlock("div",Lp,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(mr),class:"w-12 h-12 text-gray-400 mb-4"},null,8,["icon"]),e.createElementVNode("p",Wp,e.toDisplayString(L.emptyText),1),e.createElementVNode("div",jp,[L.allowBrowse?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:0,fill:"outline",size:"small","data-testid":"browse-button-empty",onClick:R},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{slot:"start",icon:e.unref(mr)},null,8,["icon"]),_[3]||(_[3]=e.createTextVNode(" Browse Library ",-1))]),_:1})):e.createCommentVNode("",!0),L.allowUpload?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:1,fill:"solid",size:"small","data-testid":"upload-button-empty",onClick:N},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{slot:"start",icon:e.unref(bs)},null,8,["icon"]),_[4]||(_[4]=e.createTextVNode(" Upload Files ",-1))]),_:1})):e.createCommentVNode("",!0)])])),e.createVNode(mp,e.mergeProps({"is-open":l.value,"selected-items":f.value,collection:L.collection},m.value!==null&&m.value!==void 0?{maxSelection:m.value}:{},{onConfirm:j,onClose:g}),null,16,["is-open","selected-items","collection"]),e.createVNode(_l,e.mergeProps({modelValue:c.value,"onUpdate:modelValue":_[0]||(_[0]=D=>c.value=D)},b.value?{initialImage:b.value}:{},{"on-save":x,onCancel:A,onError:T}),null,16,["modelValue"])]))}}),Yp=_e(Zp,[["__scopeId","data-v-71504dc3"]]),Gp=["src"],Hp={class:"preview-controls"},Jp=["aria-label"],qp={class:"time-display"},Kp={class:"current-time"},Qp={class:"total-time"},ef={key:0,class:"fps-display"},tf={key:0,class:"loading-overlay"},nf={key:1,class:"error-overlay"},of=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(n,{expose:o,emit:t}){const{ColorMatrixFilter:a,BlurFilter:r}=Ae,i=n,s=t,l=e.ref(),c=e.ref(),d=e.ref(),u=e.ref(!0),p=e.ref(),m=e.ref(0),f=e.ref(0),v=e.ref(!1);let b,S,M=null,E=null,y=null,h=[],w="",R=null,N=0,g=0,C=0,A=0,x=!1,T=0,I=0,z,P=null,j=!1;const L=e.computed(()=>i.source&&typeof i.source=="string"?i.source:"");async function _(){var me,W;if(c.value&&!b&&!(!d.value||d.value.readyState<3))try{let J=((me=l.value)==null?void 0:me.clientWidth)||800,te=((W=l.value)==null?void 0:W.clientHeight)||450;if((J<=0||te<=0)&&(J=d.value.videoWidth||800,te=d.value.videoHeight||450),b=new Ae.Application,await b.init({width:J,height:te,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,antialias:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),c.value.appendChild(b.canvas),d.value){if(d.value.videoWidth===0||d.value.videoHeight===0){setTimeout(()=>{d.value&&d.value.videoWidth>0&&!b&&_()},100),b&&(b.destroy(!0),b=null);return}N=d.value.videoWidth,g=d.value.videoHeight,E=document.createElement("canvas"),E.width=N,E.height=g,y=E.getContext("2d"),y.drawImage(d.value,0,0,N,g);const oe=Ae.Texture.from(E);M=oe.source,S=new Ae.Sprite(oe),S.visible=!0,S.alpha=1,he(),b.stage.addChild(S),b.renderer&&!b.renderer.destroyed&&b.render()}ce(),i.targetFps<60?D():b.ticker.add(G),v.value=!0,"ResizeObserver"in window&&(R=new ResizeObserver(oe=>{x||(x=!0,requestAnimationFrame(()=>{x=!1;const pe=oe[oe.length-1],{width:be,height:Be}=pe.contentRect;if(be<=0||Be<=0)return;const De=Math.round(be),Y=Math.round(Be);De===C&&Y===A||(C=De,A=Y,he())}))}),R.observe(l.value)),i.filters&&i.filters.length>0&&ce(),i.showFps&&ge()}catch{p.value="Failed to initialize video preview"}}function D(){const me=1e3/i.targetFps;let W=performance.now();function J(){if(j||!b)return;const te=performance.now(),oe=te-W;oe>=me&&(G(),W=te-oe%me),P=requestAnimationFrame(J)}P=requestAnimationFrame(J)}function G(){if(!(!b||!S||j)&&i.active)try{y&&E&&M&&d.value&&(d.value.readyState>=2&&(y.drawImage(d.value,0,0,E.width,E.height),M.update()),d.value.paused||s("frame-update",ae())),i.showFps&&I++,b.renderer&&!b.renderer.destroyed&&b.render()}catch{j=!0}}function X(){for(const me of h)try{me.destroy()}catch{}h=[]}function ce(){if(S){if(!i.filters||i.filters.length===0){S.filters=null,X();return}X(),i.filters.forEach(me=>{const W=Me(me);W&&h.push(W)}),S.filters=h.length>0?h:null,w=JSON.stringify(i.filters),b&&b.render()}}function Me(me){const W=me.filterId,J=me.params||{},te=Et.getFilter(W);if(te&&!Et.isFilterCompatibleWithMedia(W,"video"))return null;if(te&&te.createFilter)try{return te.createFilter(J)}catch{}const oe=(pe,be,Be)=>Math.min(Be,Math.max(be,pe));switch(W){case"brightness":{const pe=new a,be=oe(typeof J.brightness=="number"?J.brightness:typeof J.value=="number"?J.value:1,0,5);return pe.brightness(be,!0),pe}case"contrast":{const pe=new a,be=oe(typeof J.contrast=="number"?J.contrast:typeof J.value=="number"?J.value:1,0,5);return pe.contrast(be,!0),pe}case"saturation":{const pe=new a,be=oe(typeof J.saturation=="number"?J.saturation:typeof J.value=="number"?J.value:1,0,5);return pe.saturate(be,!0),pe}case"hue":{const pe=new a,be=oe(typeof J.value=="number"?J.value:0,-180,180);return pe.hue(be,!0),pe}case"gaussian-blur":case"blur":{const pe=oe(typeof J.blur=="number"?J.blur:typeof J.value=="number"?J.value:2,0,10);return new r(pe)}case"grayscale":{const pe=new a;return pe.desaturate(),pe}case"sepia":case"color-matrix":{const pe=new a;return pe.sepia(!0),pe}case"vignette":{const pe=typeof J.value=="number"?J.value:.3;return $e(oe(pe,0,1))}default:return null}}function $e(me){const W=`
|
|
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 Ae.Filter(void 0,W,{strength:me})}function ae(){var W;return!b||!S?null:{dataUrl:b.canvas.toDataURL("image/jpeg",.8),timestamp:((W=d.value)==null?void 0:W.currentTime)||0,width:N||0,height:g||0}}function F(){var me;m.value=((me=d.value)==null?void 0:me.duration)||0,s("duration-change",m.value)}function O(){u.value=!1,p.value=void 0}function de(){u.value&&(u.value=!1),!v.value&&i.active?_():v.value}function re(){var W,J,te;const me=((W=d.value)==null?void 0:W.currentTime)||0;s("frame-update",{dataUrl:null,timestamp:me,width:((J=d.value)==null?void 0:J.videoWidth)||0,height:((te=d.value)==null?void 0:te.videoHeight)||0})}function q(){s("play-pause")}function ee(me){var J;const W=me.target;if(W!=null&&W.error)switch(W.error.code){case W.error.MEDIA_ERR_ABORTED:p.value="Video playback aborted";break;case W.error.MEDIA_ERR_NETWORK:p.value="Network error loading video";break;case W.error.MEDIA_ERR_DECODE:p.value="Video format not supported";break;case W.error.MEDIA_ERR_SRC_NOT_SUPPORTED:p.value=`Video source not supported: ${(J=W.src)==null?void 0:J.substring(0,100)}`;break;default:p.value="Failed to load video"}else p.value="Failed to load video";s("error",p.value),u.value=!1}function ue(me){d.value&&(d.value.currentTime=Math.max(0,Math.min(me,m.value)))}function ge(){z=window.setInterval(()=>{const me=performance.now(),W=me-T;f.value=Math.round(I*1e3/W),I=0,T=me},1e3)}function xe(me){const W=Math.floor(me/60),J=Math.floor(me%60);return`${W.toString().padStart(2,"0")}:${J.toString().padStart(2,"0")}`}function ne(){p.value=void 0,u.value=!0,d.value&&d.value.load()}function ke(){b&&(x||(x=!0,requestAnimationFrame(()=>{x=!1,he()})))}function he(){if(!b||!S||!N||!g||!l.value)return;const me=Math.round(l.value.clientWidth),W=Math.round(l.value.clientHeight);if(me<=0||W<=0)return;b.renderer.resize(me,W);const J=b.screen.width/N,te=b.screen.height/g;let oe=1;switch(i.fitMode){case"cover":oe=Math.max(J,te);break;case"none":oe=1;break;case"contain":default:oe=Math.min(J,te);break}S.scale.set(oe),S.anchor.set(.5),S.position.set(b.screen.width/2,b.screen.height/2),S.visible=!0,S.alpha=1,b.renderer&&!b.renderer.destroyed&&b.render()}e.watch(()=>i.filters,()=>{v.value&&ce()},{deep:!0}),e.watch(()=>i.active,async me=>{if(me&&!b&&d.value&&d.value.readyState>=2){await _();return}b&&(me&&(await e.nextTick(),l.value&&l.value.getBoundingClientRect(),S&&y&&E&&M&&(d.value&&d.value.readyState>=2&&(y.drawImage(d.value,0,0,E.width,E.height),M.update()),he(),b.renderer&&!b.renderer.destroyed&&b.render())),i.targetFps>=60&&b.ticker&&(me?b.ticker.start():b.ticker.stop()))}),e.watch(L,me=>{me?(u.value=!0,p.value=void 0,e.nextTick(()=>{d.value&&d.value.load()})):(u.value=!1,p.value="No video source provided")},{immediate:!0});async function qe(){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{}}}p.value="Unable to start preview playback",s("error",p.value)}}e.watch(()=>i.isPlaying,me=>{d.value&&(me?qe():d.value.pause())}),e.watch(()=>i.playhead,me=>{d.value&&Math.abs(d.value.currentTime-me)>.5&&ue(me)}),e.watch(()=>i.fitMode,()=>{he()}),e.onMounted(()=>{j=!1,e.nextTick(()=>{l.value&&l.value.getBoundingClientRect(),d.value}),window.addEventListener("resize",ke),T=performance.now(),e.nextTick(()=>{d.value&&d.value.readyState>=2&&!v.value&&_()})}),e.onUnmounted(()=>{if(j=!0,P&&(cancelAnimationFrame(P),P=null),window.removeEventListener("resize",ke),R&&(R.disconnect(),R=null),z&&clearInterval(z),b&&b.ticker&&(b.ticker.stop(),b.ticker.remove(G)),b){try{b.destroy(!0,{children:!0,texture:!0})}catch{}b=null}h.forEach(me=>{try{me.destroy()}catch{}}),h=[],S=null,M=null,E=null,y=null,d.value&&(d.value.pause(),d.value.removeAttribute("src"),d.value.load())});async function ct(me){if(!await pt()||!d.value||!y||!E||!M)return null;const J=d.value,te=Number.isFinite(m.value)&&m.value>0?m.value:Number.isFinite(J.duration)&&J.duration>0?J.duration:0,oe=Math.max(0,Math.min(me,te));await new Promise(pe=>{let be=!1,Be=0;const De=()=>{be||(be=!0,J.removeEventListener("seeked",Y),window.clearTimeout(Be),pe())},Y=()=>{De()},ie=Number.isFinite(J.currentTime)?J.currentTime:0;if(Math.abs(ie-oe)<.016){requestAnimationFrame(()=>De());return}J.addEventListener("seeked",Y),Be=window.setTimeout(()=>De(),700),J.currentTime=oe});try{y.drawImage(J,0,0,E.width,E.height),M.update(),b.render()}catch{return null}return b.canvas}async function pt(){if(!d.value)return!1;if(!b){if(!(d.value.readyState>=2))return!1;await _()}if(!b||!S||!y||!E||!M)return!1;if(i.filters&&i.filters.length>0){const me=S.filters,W=Array.isArray(me)?me.length:0,te=JSON.stringify(i.filters)!==w;(W===0||W!==i.filters.length||te)&&ce()}return await e.nextTick(),await new Promise(me=>{requestAnimationFrame(()=>me())}),!0}return o({captureFrameAt:ct,ensureReadyForCapture:pt,duration:m,pixiCanvas:e.computed(()=>b?b.canvas:null),videoElement:e.computed(()=>d.value??null)}),(me,W)=>(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:L.value,onLoadedmetadata:F,onLoadeddata:O,onCanplay:de,onTimeupdate:re,onEnded:q,onError:ee,style:e.normalizeStyle({display:v.value?"none":"block",position:"relative",width:"100%",height:"100%",objectFit:me.fitMode}),crossorigin:"anonymous",playsinline:"",controls:""},null,44,Gp),e.createElementVNode("div",Hp,[e.createElementVNode("button",{class:"play-button",onClick:W[0]||(W[0]=J=>me.$emit("play-pause")),"aria-label":me.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(B.IonIcon),{icon:me.isPlaying?e.unref(Il):e.unref(Bl)},null,8,["icon"])],8,Jp),e.createElementVNode("div",qp,[e.createElementVNode("span",Kp,e.toDisplayString(xe(me.playhead)),1),W[1]||(W[1]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",Qp,e.toDisplayString(xe(m.value)),1)]),me.showFps?(e.openBlock(),e.createElementBlock("div",ef,e.toDisplayString(f.value)+" FPS ",1)):e.createCommentVNode("",!0)]),u.value?(e.openBlock(),e.createElementBlock("div",tf,[e.createVNode(e.unref(B.IonSpinner),{name:"crescent"}),W[2]||(W[2]=e.createElementVNode("p",null,"Loading video...",-1))])):e.createCommentVNode("",!0),p.value?(e.openBlock(),e.createElementBlock("div",nf,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Jr)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(p.value),1),e.createElementVNode("button",{onClick:ne},"Retry")])):e.createCommentVNode("",!0)],512))}}),Vs=_e(of,[["__scopeId","data-v-1565c38d"]]);var qr=(n,o,t)=>{if(!o.has(n))throw TypeError("Cannot "+t)},$=(n,o,t)=>(qr(n,o,"read from private field"),t?t.call(n):o.get(n)),Fe=(n,o,t)=>{if(o.has(n))throw TypeError("Cannot add the same private member more than once");o instanceof WeakSet?o.add(n):o.set(n,t)},nt=(n,o,t,a)=>(qr(n,o,"write to private field"),o.set(n,t),t),af=(n,o,t,a)=>({set _(r){nt(n,o,r)},get _(){return $(n,o,a)}}),Pe=(n,o,t)=>(qr(n,o,"access private method"),t),ze=new Uint8Array(8),Zt=new DataView(ze.buffer),Qe=n=>[(n%256+256)%256],Ue=n=>(Zt.setUint16(0,n,!1),[ze[0],ze[1]]),rf=n=>(Zt.setInt16(0,n,!1),[ze[0],ze[1]]),zl=n=>(Zt.setUint32(0,n,!1),[ze[1],ze[2],ze[3]]),ye=n=>(Zt.setUint32(0,n,!1),[ze[0],ze[1],ze[2],ze[3]]),sf=n=>(Zt.setInt32(0,n,!1),[ze[0],ze[1],ze[2],ze[3]]),Sn=n=>(Zt.setUint32(0,Math.floor(n/2**32),!1),Zt.setUint32(4,n,!1),[ze[0],ze[1],ze[2],ze[3],ze[4],ze[5],ze[6],ze[7]]),Kr=n=>(Zt.setInt16(0,2**8*n,!1),[ze[0],ze[1]]),Wt=n=>(Zt.setInt32(0,2**16*n,!1),[ze[0],ze[1],ze[2],ze[3]]),fr=n=>(Zt.setInt32(0,2**30*n,!1),[ze[0],ze[1],ze[2],ze[3]]),Nt=(n,o=!1)=>{let t=Array(n.length).fill(null).map((a,r)=>n.charCodeAt(r));return o&&t.push(0),t},fa=n=>n&&n[n.length-1],Qr=n=>{let o;for(let t of n)(!o||t.presentationTimestamp>o.presentationTimestamp)&&(o=t);return o},Xt=(n,o,t=!0)=>{let a=n*o;return t?Math.round(a):a},Al=n=>{let o=n*(Math.PI/180),t=Math.cos(o),a=Math.sin(o);return[t,a,0,-a,t,0,0,0,1]},Dl=Al(0),Ul=n=>[Wt(n[0]),Wt(n[1]),fr(n[2]),Wt(n[3]),Wt(n[4]),fr(n[5]),Wt(n[6]),Wt(n[7]),fr(n[8])],mo=n=>!n||typeof n!="object"?n:Array.isArray(n)?n.map(mo):Object.fromEntries(Object.entries(n).map(([o,t])=>[o,mo(t)])),Un=n=>n>=0&&n<2**32,Je=(n,o,t)=>({type:n,contents:o&&new Uint8Array(o.flat(10)),children:t}),je=(n,o,t,a,r)=>Je(n,[Qe(o),zl(t),a??[]],r),lf=n=>{let o=512;return n.fragmented?Je("ftyp",[Nt("iso5"),ye(o),Nt("iso5"),Nt("iso6"),Nt("mp41")]):Je("ftyp",[Nt("isom"),ye(o),Nt("isom"),n.holdsAvc?Nt("avc1"):[],Nt("mp41")])},Nr=n=>({type:"mdat",largeSize:n}),cf=n=>({type:"free",size:n}),na=(n,o,t=!1)=>Je("moov",null,[df(o,n),...n.map(a=>uf(a,o)),t?Lf(n):null]),df=(n,o)=>{let t=Xt(Math.max(0,...o.filter(s=>s.samples.length>0).map(s=>{const l=Qr(s.samples);return l.presentationTimestamp+l.duration})),Mr),a=Math.max(...o.map(s=>s.id))+1,r=!Un(n)||!Un(t),i=r?Sn:ye;return je("mvhd",+r,0,[i(n),i(n),ye(Mr),i(t),Wt(1),Kr(1),Array(10).fill(0),Ul(Dl),Array(24).fill(0),ye(a)])},uf=(n,o)=>Je("trak",null,[mf(n,o),pf(n,o)]),mf=(n,o)=>{let t=Qr(n.samples),a=Xt(t?t.presentationTimestamp+t.duration:0,Mr),r=!Un(o)||!Un(a),i=r?Sn:ye,s;return n.info.type==="video"?s=typeof n.info.rotation=="number"?Al(n.info.rotation):n.info.rotation:s=Dl,je("tkhd",+r,3,[i(o),i(o),ye(n.id),ye(0),i(a),Array(8).fill(0),Ue(0),Ue(0),Kr(n.info.type==="audio"?1:0),Ue(0),Ul(s),Wt(n.info.type==="video"?n.info.width:0),Wt(n.info.type==="video"?n.info.height:0)])},pf=(n,o)=>Je("mdia",null,[ff(n,o),hf(n.info.type==="video"?"vide":"soun"),vf(n)]),ff=(n,o)=>{let t=Qr(n.samples),a=Xt(t?t.presentationTimestamp+t.duration:0,n.timescale),r=!Un(o)||!Un(a),i=r?Sn:ye;return je("mdhd",+r,0,[i(o),i(o),ye(n.timescale),i(a),Ue(21956),Ue(0)])},hf=n=>je("hdlr",0,0,[Nt("mhlr"),Nt(n),ye(0),ye(0),ye(0),Nt("mp4-muxer-hdlr",!0)]),vf=n=>Je("minf",null,[n.info.type==="video"?gf():yf(),bf(),xf(n)]),gf=()=>je("vmhd",0,1,[Ue(0),Ue(0),Ue(0),Ue(0)]),yf=()=>je("smhd",0,0,[Ue(0),Ue(0)]),bf=()=>Je("dinf",null,[wf()]),wf=()=>je("dref",0,0,[ye(1)],[kf()]),kf=()=>je("url ",0,1),xf=n=>{const o=n.compositionTimeOffsetTable.length>1||n.compositionTimeOffsetTable.some(t=>t.sampleCompositionTimeOffset!==0);return Je("stbl",null,[Sf(n),$f(n),zf(n),Af(n),Df(n),Uf(n),o?Of(n):null])},Sf=n=>je("stsd",0,0,[ye(1)],[n.info.type==="video"?Ef(Kf[n.info.codec],n):Bf(eh[n.info.codec],n)]),Ef=(n,o)=>Je(n,[Array(6).fill(0),Ue(1),Ue(0),Ue(0),Array(12).fill(0),Ue(o.info.width),Ue(o.info.height),ye(4718592),ye(4718592),ye(0),Ue(1),Array(32).fill(0),Ue(24),rf(65535)],[Qf[o.info.codec](o),o.info.decoderConfig.colorSpace?_f(o):null]),Vf={bt709:1,bt470bg:5,smpte170m:6},Cf={bt709:1,smpte170m:6,"iec61966-2-1":13},Nf={rgb:0,bt709:1,bt470bg:5,smpte170m:6},_f=n=>Je("colr",[Nt("nclx"),Ue(Vf[n.info.decoderConfig.colorSpace.primaries]),Ue(Cf[n.info.decoderConfig.colorSpace.transfer]),Ue(Nf[n.info.decoderConfig.colorSpace.matrix]),Qe((n.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),Tf=n=>n.info.decoderConfig&&Je("avcC",[...new Uint8Array(n.info.decoderConfig.description)]),Mf=n=>n.info.decoderConfig&&Je("hvcC",[...new Uint8Array(n.info.decoderConfig.description)]),Ff=n=>{if(!n.info.decoderConfig)return null;let o=n.info.decoderConfig;if(!o.colorSpace)throw new Error("'colorSpace' is required in the decoder config for VP9.");let t=o.codec.split("."),a=Number(t[1]),r=Number(t[2]),l=(Number(t[3])<<4)+(0<<1)+Number(o.colorSpace.fullRange);return je("vpcC",1,0,[Qe(a),Qe(r),Qe(l),Qe(2),Qe(2),Qe(2),Ue(0)])},If=()=>{let t=(1<<7)+1;return Je("av1C",[t,0,0,0])},Bf=(n,o)=>Je(n,[Array(6).fill(0),Ue(1),Ue(0),Ue(0),ye(0),Ue(o.info.numberOfChannels),Ue(16),Ue(0),Ue(0),Wt(o.info.sampleRate)],[th[o.info.codec](o)]),Rf=n=>{let o=new Uint8Array(n.info.decoderConfig.description);return je("esds",0,0,[ye(58753152),Qe(32+o.byteLength),Ue(1),Qe(0),ye(75530368),Qe(18+o.byteLength),Qe(64),Qe(21),zl(0),ye(130071),ye(130071),ye(92307584),Qe(o.byteLength),...o,ye(109084800),Qe(1),Qe(2)])},Pf=n=>{var r;let o=3840,t=0;const a=(r=n.info.decoderConfig)==null?void 0:r.description;if(a){if(a.byteLength<18)throw new TypeError("Invalid decoder description provided for Opus; must be at least 18 bytes long.");const i=ArrayBuffer.isView(a)?new DataView(a.buffer,a.byteOffset,a.byteLength):new DataView(a);o=i.getUint16(10,!0),t=i.getInt16(14,!0)}return Je("dOps",[Qe(0),Qe(n.info.numberOfChannels),Ue(o),ye(n.info.sampleRate),Kr(t),Qe(0)])},$f=n=>je("stts",0,0,[ye(n.timeToSampleTable.length),n.timeToSampleTable.map(o=>[ye(o.sampleCount),ye(o.sampleDelta)])]),zf=n=>{if(n.samples.every(t=>t.type==="key"))return null;let o=[...n.samples.entries()].filter(([,t])=>t.type==="key");return je("stss",0,0,[ye(o.length),o.map(([t])=>ye(t+1))])},Af=n=>je("stsc",0,0,[ye(n.compactlyCodedChunkTable.length),n.compactlyCodedChunkTable.map(o=>[ye(o.firstChunk),ye(o.samplesPerChunk),ye(1)])]),Df=n=>je("stsz",0,0,[ye(0),ye(n.samples.length),n.samples.map(o=>ye(o.size))]),Uf=n=>n.finalizedChunks.length>0&&fa(n.finalizedChunks).offset>=2**32?je("co64",0,0,[ye(n.finalizedChunks.length),n.finalizedChunks.map(o=>Sn(o.offset))]):je("stco",0,0,[ye(n.finalizedChunks.length),n.finalizedChunks.map(o=>ye(o.offset))]),Of=n=>je("ctts",0,0,[ye(n.compositionTimeOffsetTable.length),n.compositionTimeOffsetTable.map(o=>[ye(o.sampleCount),ye(o.sampleCompositionTimeOffset)])]),Lf=n=>Je("mvex",null,n.map(Wf)),Wf=n=>je("trex",0,0,[ye(n.id),ye(1),ye(0),ye(0),ye(0)]),Cs=(n,o)=>Je("moof",null,[jf(n),...o.map(Xf)]),jf=n=>je("mfhd",0,0,[ye(n)]),Ol=n=>{let o=0,t=0,a=0,r=0,i=n.type==="delta";return t|=+i,i?o|=1:o|=2,o<<24|t<<16|a<<8|r},Xf=n=>Je("traf",null,[Zf(n),Yf(n),Gf(n)]),Zf=n=>{let o=0;o|=8,o|=16,o|=32,o|=131072;let t=n.currentChunk.samples[1]??n.currentChunk.samples[0],a={duration:t.timescaleUnitsToNextSample,size:t.size,flags:Ol(t)};return je("tfhd",0,o,[ye(n.id),ye(a.duration),ye(a.size),ye(a.flags)])},Yf=n=>je("tfdt",1,0,[Sn(Xt(n.currentChunk.startTimestamp,n.timescale))]),Gf=n=>{let o=n.currentChunk.samples.map(b=>b.timescaleUnitsToNextSample),t=n.currentChunk.samples.map(b=>b.size),a=n.currentChunk.samples.map(Ol),r=n.currentChunk.samples.map(b=>Xt(b.presentationTimestamp-b.decodeTimestamp,n.timescale)),i=new Set(o),s=new Set(t),l=new Set(a),c=new Set(r),d=l.size===2&&a[0]!==a[1],u=i.size>1,p=s.size>1,m=!d&&l.size>1,f=c.size>1||[...c].some(b=>b!==0),v=0;return v|=1,v|=4*+d,v|=256*+u,v|=512*+p,v|=1024*+m,v|=2048*+f,je("trun",1,v,[ye(n.currentChunk.samples.length),ye(n.currentChunk.offset-n.currentChunk.moofOffset||0),d?ye(a[0]):[],n.currentChunk.samples.map((b,S)=>[u?ye(o[S]):[],p?ye(t[S]):[],m?ye(a[S]):[],f?sf(r[S]):[]])])},Hf=n=>Je("mfra",null,[...n.map(Jf),qf()]),Jf=(n,o)=>je("tfra",1,0,[ye(n.id),ye(63),ye(n.finalizedChunks.length),n.finalizedChunks.map(a=>[Sn(Xt(a.startTimestamp,n.timescale)),Sn(a.moofOffset),ye(o+1),ye(1),ye(1)])]),qf=()=>je("mfro",0,0,[ye(0)]),Kf={avc:"avc1",hevc:"hvc1",vp9:"vp09",av1:"av01"},Qf={avc:Tf,hevc:Mf,vp9:Ff,av1:If},eh={aac:"mp4a",opus:"Opus"},th={aac:Rf,opus:Pf},_a=class{},ei=class extends _a{constructor(){super(...arguments),this.buffer=null}},Ll=class extends _a{constructor(n){if(super(),this.options=n,typeof n!="object")throw new TypeError("StreamTarget requires an options object to be passed to its constructor.");if(n.onData){if(typeof n.onData!="function")throw new TypeError("options.onData, when provided, must be a function.");if(n.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(n.chunked!==void 0&&typeof n.chunked!="boolean")throw new TypeError("options.chunked, when provided, must be a boolean.");if(n.chunkSize!==void 0&&(!Number.isInteger(n.chunkSize)||n.chunkSize<1024))throw new TypeError("options.chunkSize, when provided, must be an integer and not smaller than 1024.")}},nh=class extends _a{constructor(n,o){if(super(),this.stream=n,this.options=o,!(n instanceof FileSystemWritableFileStream))throw new TypeError("FileSystemWritableFileStreamTarget requires a FileSystemWritableFileStream instance.");if(o!==void 0&&typeof o!="object")throw new TypeError("FileSystemWritableFileStreamTarget's options, when provided, must be an object.");if(o&&o.chunkSize!==void 0&&(!Number.isInteger(o.chunkSize)||o.chunkSize<=0))throw new TypeError("options.chunkSize, when provided, must be a positive integer")}},pn,Pn,Wl=class{constructor(){this.pos=0,Fe(this,pn,new Uint8Array(8)),Fe(this,Pn,new DataView($(this,pn).buffer)),this.offsets=new WeakMap}seek(n){this.pos=n}writeU32(n){$(this,Pn).setUint32(0,n,!1),this.write($(this,pn).subarray(0,4))}writeU64(n){$(this,Pn).setUint32(0,Math.floor(n/2**32),!1),$(this,Pn).setUint32(4,n,!1),this.write($(this,pn).subarray(0,8))}writeAscii(n){for(let o=0;o<n.length;o++)$(this,Pn).setUint8(o%8,n.charCodeAt(o)),o%8===7&&this.write($(this,pn));n.length%8!==0&&this.write($(this,pn).subarray(0,n.length%8))}writeBox(n){if(this.offsets.set(n,this.pos),n.contents&&!n.children)this.writeBoxHeader(n,n.size??n.contents.byteLength+8),this.write(n.contents);else{let o=this.pos;if(this.writeBoxHeader(n,0),n.contents&&this.write(n.contents),n.children)for(let r of n.children)r&&this.writeBox(r);let t=this.pos,a=n.size??t-o;this.seek(o),this.writeBoxHeader(n,a),this.seek(t)}}writeBoxHeader(n,o){this.writeU32(n.largeSize?1:o),this.writeAscii(n.type),n.largeSize&&this.writeU64(o)}measureBoxHeader(n){return 8+(n.largeSize?8:0)}patchBox(n){let o=this.pos;this.seek(this.offsets.get(n)),this.writeBox(n),this.seek(o)}measureBox(n){if(n.contents&&!n.children)return this.measureBoxHeader(n)+n.contents.byteLength;{let o=this.measureBoxHeader(n);if(n.contents&&(o+=n.contents.byteLength),n.children)for(let t of n.children)t&&(o+=this.measureBox(t));return o}}};pn=new WeakMap;Pn=new WeakMap;var oa,kn,wo,io,aa,_r,oh=class extends Wl{constructor(n){super(),Fe(this,aa),Fe(this,oa,void 0),Fe(this,kn,new ArrayBuffer(2**16)),Fe(this,wo,new Uint8Array($(this,kn))),Fe(this,io,0),nt(this,oa,n)}write(n){Pe(this,aa,_r).call(this,this.pos+n.byteLength),$(this,wo).set(n,this.pos),this.pos+=n.byteLength,nt(this,io,Math.max($(this,io),this.pos))}finalize(){Pe(this,aa,_r).call(this,this.pos),$(this,oa).buffer=$(this,kn).slice(0,Math.max($(this,io),this.pos))}};oa=new WeakMap;kn=new WeakMap;wo=new WeakMap;io=new WeakMap;aa=new WeakSet;_r=function(n){let o=$(this,kn).byteLength;for(;o<n;)o*=2;if(o===$(this,kn).byteLength)return;let t=new ArrayBuffer(o),a=new Uint8Array(t);a.set($(this,wo),0),nt(this,kn,t),nt(this,wo,a)};var ah=2**24,rh=2,po,fn,so,Kt,St,ha,Tr,ti,jl,ni,Xl,fo,va,oi=class extends Wl{constructor(n){var o,t;super(),Fe(this,ha),Fe(this,ti),Fe(this,ni),Fe(this,fo),Fe(this,po,void 0),Fe(this,fn,[]),Fe(this,so,void 0),Fe(this,Kt,void 0),Fe(this,St,[]),nt(this,po,n),nt(this,so,((o=n.options)==null?void 0:o.chunked)??!1),nt(this,Kt,((t=n.options)==null?void 0:t.chunkSize)??ah)}write(n){$(this,fn).push({data:n.slice(),start:this.pos}),this.pos+=n.byteLength}flush(){var t,a;if($(this,fn).length===0)return;let n=[],o=[...$(this,fn)].sort((r,i)=>r.start-i.start);n.push({start:o[0].start,size:o[0].data.byteLength});for(let r=1;r<o.length;r++){let i=n[n.length-1],s=o[r];s.start<=i.start+i.size?i.size=Math.max(i.size,s.start+s.data.byteLength-i.start):n.push({start:s.start,size:s.data.byteLength})}for(let r of n){r.data=new Uint8Array(r.size);for(let i of $(this,fn))r.start<=i.start&&i.start<r.start+r.size&&r.data.set(i.data,i.start-r.start);$(this,so)?(Pe(this,ha,Tr).call(this,r.data,r.start),Pe(this,fo,va).call(this)):(a=(t=$(this,po).options).onData)==null||a.call(t,r.data,r.start)}$(this,fn).length=0}finalize(){$(this,so)&&Pe(this,fo,va).call(this,!0)}};po=new WeakMap;fn=new WeakMap;so=new WeakMap;Kt=new WeakMap;St=new WeakMap;ha=new WeakSet;Tr=function(n,o){let t=$(this,St).findIndex(l=>l.start<=o&&o<l.start+$(this,Kt));t===-1&&(t=Pe(this,ni,Xl).call(this,o));let a=$(this,St)[t],r=o-a.start,i=n.subarray(0,Math.min($(this,Kt)-r,n.byteLength));a.data.set(i,r);let s={start:r,end:r+i.byteLength};if(Pe(this,ti,jl).call(this,a,s),a.written[0].start===0&&a.written[0].end===$(this,Kt)&&(a.shouldFlush=!0),$(this,St).length>rh){for(let l=0;l<$(this,St).length-1;l++)$(this,St)[l].shouldFlush=!0;Pe(this,fo,va).call(this)}i.byteLength<n.byteLength&&Pe(this,ha,Tr).call(this,n.subarray(i.byteLength),o+i.byteLength)};ti=new WeakSet;jl=function(n,o){let t=0,a=n.written.length-1,r=-1;for(;t<=a;){let i=Math.floor(t+(a-t+1)/2);n.written[i].start<=o.start?(t=i+1,r=i):a=i-1}for(n.written.splice(r+1,0,o),(r===-1||n.written[r].end<o.start)&&r++;r<n.written.length-1&&n.written[r].end>=n.written[r+1].start;)n.written[r].end=Math.max(n.written[r].end,n.written[r+1].end),n.written.splice(r+1,1)};ni=new WeakSet;Xl=function(n){let t={start:Math.floor(n/$(this,Kt))*$(this,Kt),data:new Uint8Array($(this,Kt)),written:[],shouldFlush:!1};return $(this,St).push(t),$(this,St).sort((a,r)=>a.start-r.start),$(this,St).indexOf(t)};fo=new WeakSet;va=function(n=!1){var o,t;for(let a=0;a<$(this,St).length;a++){let r=$(this,St)[a];if(!(!r.shouldFlush&&!n)){for(let i of r.written)(t=(o=$(this,po).options).onData)==null||t.call(o,r.data.subarray(i.start,i.end),r.start+i.start);$(this,St).splice(a--,1)}}};var ih=class extends oi{constructor(n){var o;super(new Ll({onData:(t,a)=>n.stream.write({type:"write",data:t,position:a}),chunked:!0,chunkSize:(o=n.options)==null?void 0:o.chunkSize}))}},Mr=1e3,sh=["avc","hevc","vp9","av1"],lh=["aac","opus"],ch=2082844800,dh=["strict","offset","cross-track-offset"],Ee,Ce,ga,kt,at,tt,$n,zn,ai,hn,vn,ho,Fr,Zl,Ir,Yl,ri,Gl,Br,Hl,ii,Jl,ra,Rr,Ut,qt,si,ql,vo,ya,ba,li,On,Eo,ia,Pr,Kl=class{constructor(n){if(Fe(this,Fr),Fe(this,Ir),Fe(this,ri),Fe(this,Br),Fe(this,ii),Fe(this,ra),Fe(this,Ut),Fe(this,si),Fe(this,vo),Fe(this,ba),Fe(this,On),Fe(this,ia),Fe(this,Ee,void 0),Fe(this,Ce,void 0),Fe(this,ga,void 0),Fe(this,kt,void 0),Fe(this,at,null),Fe(this,tt,null),Fe(this,$n,Math.floor(Date.now()/1e3)+ch),Fe(this,zn,[]),Fe(this,ai,1),Fe(this,hn,[]),Fe(this,vn,[]),Fe(this,ho,!1),Pe(this,Fr,Zl).call(this,n),n.video=mo(n.video),n.audio=mo(n.audio),n.fastStart=mo(n.fastStart),this.target=n.target,nt(this,Ee,{firstTimestampBehavior:"strict",...n}),n.target instanceof ei)nt(this,Ce,new oh(n.target));else if(n.target instanceof Ll)nt(this,Ce,new oi(n.target));else if(n.target instanceof nh)nt(this,Ce,new ih(n.target));else throw new Error(`Invalid target: ${n.target}`);Pe(this,Br,Hl).call(this),Pe(this,Ir,Yl).call(this)}addVideoChunk(n,o,t,a){if(!(n instanceof EncodedVideoChunk))throw new TypeError("addVideoChunk's first argument (sample) must be of type EncodedVideoChunk.");if(o&&typeof o!="object")throw new TypeError("addVideoChunk's second argument (meta), when provided, must be an object.");if(t!==void 0&&(!Number.isFinite(t)||t<0))throw new TypeError("addVideoChunk's third argument (timestamp), when provided, must be a non-negative real number.");if(a!==void 0&&!Number.isFinite(a))throw new TypeError("addVideoChunk's fourth argument (compositionTimeOffset), when provided, must be a real number.");let r=new Uint8Array(n.byteLength);n.copyTo(r),this.addVideoChunkRaw(r,n.type,t??n.timestamp,n.duration,o,a)}addVideoChunkRaw(n,o,t,a,r,i){if(!(n instanceof Uint8Array))throw new TypeError("addVideoChunkRaw's first argument (data) must be an instance of Uint8Array.");if(o!=="key"&&o!=="delta")throw new TypeError("addVideoChunkRaw's second argument (type) must be either 'key' or 'delta'.");if(!Number.isFinite(t)||t<0)throw new TypeError("addVideoChunkRaw's third argument (timestamp) must be a non-negative real number.");if(!Number.isFinite(a)||a<0)throw new TypeError("addVideoChunkRaw's fourth argument (duration) must be a non-negative real number.");if(r&&typeof r!="object")throw new TypeError("addVideoChunkRaw's fifth argument (meta), when provided, must be an object.");if(i!==void 0&&!Number.isFinite(i))throw new TypeError("addVideoChunkRaw's sixth argument (compositionTimeOffset), when provided, must be a real number.");if(Pe(this,ia,Pr).call(this),!$(this,Ee).video)throw new Error("No video track declared.");if(typeof $(this,Ee).fastStart=="object"&&$(this,at).samples.length===$(this,Ee).fastStart.expectedVideoChunks)throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${$(this,Ee).fastStart.expectedVideoChunks}).`);let s=Pe(this,ra,Rr).call(this,$(this,at),n,o,t,a,r,i);if($(this,Ee).fastStart==="fragmented"&&$(this,tt)){for(;$(this,vn).length>0&&$(this,vn)[0].decodeTimestamp<=s.decodeTimestamp;){let l=$(this,vn).shift();Pe(this,Ut,qt).call(this,$(this,tt),l)}s.decodeTimestamp<=$(this,tt).lastDecodeTimestamp?Pe(this,Ut,qt).call(this,$(this,at),s):$(this,hn).push(s)}else Pe(this,Ut,qt).call(this,$(this,at),s)}addAudioChunk(n,o,t){if(!(n instanceof EncodedAudioChunk))throw new TypeError("addAudioChunk's first argument (sample) must be of type EncodedAudioChunk.");if(o&&typeof o!="object")throw new TypeError("addAudioChunk's second argument (meta), when provided, must be an object.");if(t!==void 0&&(!Number.isFinite(t)||t<0))throw new TypeError("addAudioChunk's third argument (timestamp), when provided, must be a non-negative real number.");let a=new Uint8Array(n.byteLength);n.copyTo(a),this.addAudioChunkRaw(a,n.type,t??n.timestamp,n.duration,o)}addAudioChunkRaw(n,o,t,a,r){if(!(n instanceof Uint8Array))throw new TypeError("addAudioChunkRaw's first argument (data) must be an instance of Uint8Array.");if(o!=="key"&&o!=="delta")throw new TypeError("addAudioChunkRaw's second argument (type) must be either 'key' or 'delta'.");if(!Number.isFinite(t)||t<0)throw new TypeError("addAudioChunkRaw's third argument (timestamp) must be a non-negative real number.");if(!Number.isFinite(a)||a<0)throw new TypeError("addAudioChunkRaw's fourth argument (duration) must be a non-negative real number.");if(r&&typeof r!="object")throw new TypeError("addAudioChunkRaw's fifth argument (meta), when provided, must be an object.");if(Pe(this,ia,Pr).call(this),!$(this,Ee).audio)throw new Error("No audio track declared.");if(typeof $(this,Ee).fastStart=="object"&&$(this,tt).samples.length===$(this,Ee).fastStart.expectedAudioChunks)throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${$(this,Ee).fastStart.expectedAudioChunks}).`);let i=Pe(this,ra,Rr).call(this,$(this,tt),n,o,t,a,r);if($(this,Ee).fastStart==="fragmented"&&$(this,at)){for(;$(this,hn).length>0&&$(this,hn)[0].decodeTimestamp<=i.decodeTimestamp;){let s=$(this,hn).shift();Pe(this,Ut,qt).call(this,$(this,at),s)}i.decodeTimestamp<=$(this,at).lastDecodeTimestamp?Pe(this,Ut,qt).call(this,$(this,tt),i):$(this,vn).push(i)}else Pe(this,Ut,qt).call(this,$(this,tt),i)}finalize(){if($(this,ho))throw new Error("Cannot finalize a muxer more than once.");if($(this,Ee).fastStart==="fragmented"){for(let o of $(this,hn))Pe(this,Ut,qt).call(this,$(this,at),o);for(let o of $(this,vn))Pe(this,Ut,qt).call(this,$(this,tt),o);Pe(this,ba,li).call(this,!1)}else $(this,at)&&Pe(this,vo,ya).call(this,$(this,at)),$(this,tt)&&Pe(this,vo,ya).call(this,$(this,tt));let n=[$(this,at),$(this,tt)].filter(Boolean);if($(this,Ee).fastStart==="in-memory"){let o;for(let a=0;a<2;a++){let r=na(n,$(this,$n)),i=$(this,Ce).measureBox(r);o=$(this,Ce).measureBox($(this,kt));let s=$(this,Ce).pos+i+o;for(let l of $(this,zn)){l.offset=s;for(let{data:c}of l.samples)s+=c.byteLength,o+=c.byteLength}if(s<2**32)break;o>=2**32&&($(this,kt).largeSize=!0)}let t=na(n,$(this,$n));$(this,Ce).writeBox(t),$(this,kt).size=o,$(this,Ce).writeBox($(this,kt));for(let a of $(this,zn))for(let r of a.samples)$(this,Ce).write(r.data),r.data=null}else if($(this,Ee).fastStart==="fragmented"){let o=$(this,Ce).pos,t=Hf(n);$(this,Ce).writeBox(t);let a=$(this,Ce).pos-o;$(this,Ce).seek($(this,Ce).pos-4),$(this,Ce).writeU32(a)}else{let o=$(this,Ce).offsets.get($(this,kt)),t=$(this,Ce).pos-o;$(this,kt).size=t,$(this,kt).largeSize=t>=2**32,$(this,Ce).patchBox($(this,kt));let a=na(n,$(this,$n));if(typeof $(this,Ee).fastStart=="object"){$(this,Ce).seek($(this,ga)),$(this,Ce).writeBox(a);let r=o-$(this,Ce).pos;$(this,Ce).writeBox(cf(r))}else $(this,Ce).writeBox(a)}Pe(this,On,Eo).call(this),$(this,Ce).finalize(),nt(this,ho,!0)}};Ee=new WeakMap;Ce=new WeakMap;ga=new WeakMap;kt=new WeakMap;at=new WeakMap;tt=new WeakMap;$n=new WeakMap;zn=new WeakMap;ai=new WeakMap;hn=new WeakMap;vn=new WeakMap;ho=new WeakMap;Fr=new WeakSet;Zl=function(n){if(typeof n!="object")throw new TypeError("The muxer requires an options object to be passed to its constructor.");if(!(n.target instanceof _a))throw new TypeError("The target must be provided and an instance of Target.");if(n.video){if(!sh.includes(n.video.codec))throw new TypeError(`Unsupported video codec: ${n.video.codec}`);if(!Number.isInteger(n.video.width)||n.video.width<=0)throw new TypeError(`Invalid video width: ${n.video.width}. Must be a positive integer.`);if(!Number.isInteger(n.video.height)||n.video.height<=0)throw new TypeError(`Invalid video height: ${n.video.height}. Must be a positive integer.`);const o=n.video.rotation;if(typeof o=="number"&&![0,90,180,270].includes(o))throw new TypeError(`Invalid video rotation: ${o}. Has to be 0, 90, 180 or 270.`);if(Array.isArray(o)&&(o.length!==9||o.some(t=>typeof t!="number")))throw new TypeError(`Invalid video transformation matrix: ${o.join()}`);if(n.video.frameRate!==void 0&&(!Number.isInteger(n.video.frameRate)||n.video.frameRate<=0))throw new TypeError(`Invalid video frame rate: ${n.video.frameRate}. Must be a positive integer.`)}if(n.audio){if(!lh.includes(n.audio.codec))throw new TypeError(`Unsupported audio codec: ${n.audio.codec}`);if(!Number.isInteger(n.audio.numberOfChannels)||n.audio.numberOfChannels<=0)throw new TypeError(`Invalid number of audio channels: ${n.audio.numberOfChannels}. Must be a positive integer.`);if(!Number.isInteger(n.audio.sampleRate)||n.audio.sampleRate<=0)throw new TypeError(`Invalid audio sample rate: ${n.audio.sampleRate}. Must be a positive integer.`)}if(n.firstTimestampBehavior&&!dh.includes(n.firstTimestampBehavior))throw new TypeError(`Invalid first timestamp behavior: ${n.firstTimestampBehavior}`);if(typeof n.fastStart=="object"){if(n.video){if(n.fastStart.expectedVideoChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedVideoChunks'.");if(!Number.isInteger(n.fastStart.expectedVideoChunks)||n.fastStart.expectedVideoChunks<0)throw new TypeError("'expectedVideoChunks' must be a non-negative integer.")}if(n.audio){if(n.fastStart.expectedAudioChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedAudioChunks'.");if(!Number.isInteger(n.fastStart.expectedAudioChunks)||n.fastStart.expectedAudioChunks<0)throw new TypeError("'expectedAudioChunks' must be a non-negative integer.")}}else if(![!1,"in-memory","fragmented"].includes(n.fastStart))throw new TypeError("'fastStart' option must be false, 'in-memory', 'fragmented' or an object.");if(n.minFragmentDuration!==void 0&&(!Number.isFinite(n.minFragmentDuration)||n.minFragmentDuration<0))throw new TypeError("'minFragmentDuration' must be a non-negative number.")};Ir=new WeakSet;Yl=function(){var n;if($(this,Ce).writeBox(lf({holdsAvc:((n=$(this,Ee).video)==null?void 0:n.codec)==="avc",fragmented:$(this,Ee).fastStart==="fragmented"})),nt(this,ga,$(this,Ce).pos),$(this,Ee).fastStart==="in-memory")nt(this,kt,Nr(!1));else if($(this,Ee).fastStart!=="fragmented"){if(typeof $(this,Ee).fastStart=="object"){let o=Pe(this,ri,Gl).call(this);$(this,Ce).seek($(this,Ce).pos+o)}nt(this,kt,Nr(!0)),$(this,Ce).writeBox($(this,kt))}Pe(this,On,Eo).call(this)};ri=new WeakSet;Gl=function(){if(typeof $(this,Ee).fastStart!="object")return;let n=0,o=[$(this,Ee).fastStart.expectedVideoChunks,$(this,Ee).fastStart.expectedAudioChunks];for(let t of o)t&&(n+=8*Math.ceil(2/3*t),n+=4*t,n+=12*Math.ceil(2/3*t),n+=4*t,n+=8*t);return n+=4096,n};Br=new WeakSet;Hl=function(){if($(this,Ee).video&&nt(this,at,{id:1,info:{type:"video",codec:$(this,Ee).video.codec,width:$(this,Ee).video.width,height:$(this,Ee).video.height,rotation:$(this,Ee).video.rotation??0,decoderConfig:null},timescale:$(this,Ee).video.frameRate??57600,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),$(this,Ee).audio&&(nt(this,tt,{id:$(this,Ee).video?2:1,info:{type:"audio",codec:$(this,Ee).audio.codec,numberOfChannels:$(this,Ee).audio.numberOfChannels,sampleRate:$(this,Ee).audio.sampleRate,decoderConfig:null},timescale:$(this,Ee).audio.sampleRate,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),$(this,Ee).audio.codec==="aac")){let n=Pe(this,ii,Jl).call(this,2,$(this,Ee).audio.sampleRate,$(this,Ee).audio.numberOfChannels);$(this,tt).info.decoderConfig={codec:$(this,Ee).audio.codec,description:n,numberOfChannels:$(this,Ee).audio.numberOfChannels,sampleRate:$(this,Ee).audio.sampleRate}}};ii=new WeakSet;Jl=function(n,o,t){let r=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350].indexOf(o),i=t,s="";s+=n.toString(2).padStart(5,"0"),s+=r.toString(2).padStart(4,"0"),r===15&&(s+=o.toString(2).padStart(24,"0")),s+=i.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};ra=new WeakSet;Rr=function(n,o,t,a,r,i,s){let l=a/1e6,c=(a-(s??0))/1e6,d=r/1e6,u=Pe(this,si,ql).call(this,l,c,n);return l=u.presentationTimestamp,c=u.decodeTimestamp,i!=null&&i.decoderConfig&&(n.info.decoderConfig===null?n.info.decoderConfig=i.decoderConfig:Object.assign(n.info.decoderConfig,i.decoderConfig)),{presentationTimestamp:l,decodeTimestamp:c,duration:d,data:o,size:o.byteLength,type:t,timescaleUnitsToNextSample:Xt(d,n.timescale)}};Ut=new WeakSet;qt=function(n,o){$(this,Ee).fastStart!=="fragmented"&&n.samples.push(o);const t=Xt(o.presentationTimestamp-o.decodeTimestamp,n.timescale);if(n.lastTimescaleUnits!==null){let r=Xt(o.decodeTimestamp,n.timescale,!1),i=Math.round(r-n.lastTimescaleUnits);if(n.lastTimescaleUnits+=i,n.lastSample.timescaleUnitsToNextSample=i,$(this,Ee).fastStart!=="fragmented"){let s=fa(n.timeToSampleTable);s.sampleCount===1?(s.sampleDelta=i,s.sampleCount++):s.sampleDelta===i?s.sampleCount++:(s.sampleCount--,n.timeToSampleTable.push({sampleCount:2,sampleDelta:i}));const l=fa(n.compositionTimeOffsetTable);l.sampleCompositionTimeOffset===t?l.sampleCount++:n.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t})}}else n.lastTimescaleUnits=0,$(this,Ee).fastStart!=="fragmented"&&(n.timeToSampleTable.push({sampleCount:1,sampleDelta:Xt(o.duration,n.timescale)}),n.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t}));n.lastSample=o;let a=!1;if(!n.currentChunk)a=!0;else{let r=o.presentationTimestamp-n.currentChunk.startTimestamp;if($(this,Ee).fastStart==="fragmented"){let i=$(this,at)??$(this,tt);const s=$(this,Ee).minFragmentDuration??1;n===i&&o.type==="key"&&r>=s&&(a=!0,Pe(this,ba,li).call(this))}else a=r>=.5}a&&(n.currentChunk&&Pe(this,vo,ya).call(this,n),n.currentChunk={startTimestamp:o.presentationTimestamp,samples:[]}),n.currentChunk.samples.push(o)};si=new WeakSet;ql=function(n,o,t){var s,l;const a=$(this,Ee).firstTimestampBehavior==="strict",r=t.lastDecodeTimestamp===-1;if(a&&r&&o!==0)throw new Error(`The first chunk for your media track must have a timestamp of 0 (received DTS=${o}).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($(this,Ee).firstTimestampBehavior==="offset"||$(this,Ee).firstTimestampBehavior==="cross-track-offset"){t.firstDecodeTimestamp===void 0&&(t.firstDecodeTimestamp=o);let c;$(this,Ee).firstTimestampBehavior==="offset"?c=t.firstDecodeTimestamp:c=Math.min(((s=$(this,at))==null?void 0:s.firstDecodeTimestamp)??1/0,((l=$(this,tt))==null?void 0:l.firstDecodeTimestamp)??1/0),o-=c,n-=c}if(o<t.lastDecodeTimestamp)throw new Error(`Timestamps must be monotonically increasing (DTS went from ${t.lastDecodeTimestamp*1e6} to ${o*1e6}).`);return t.lastDecodeTimestamp=o,{presentationTimestamp:n,decodeTimestamp:o}};vo=new WeakSet;ya=function(n){if($(this,Ee).fastStart==="fragmented")throw new Error("Can't finalize individual chunks if 'fastStart' is set to 'fragmented'.");if(n.currentChunk){if(n.finalizedChunks.push(n.currentChunk),$(this,zn).push(n.currentChunk),(n.compactlyCodedChunkTable.length===0||fa(n.compactlyCodedChunkTable).samplesPerChunk!==n.currentChunk.samples.length)&&n.compactlyCodedChunkTable.push({firstChunk:n.finalizedChunks.length,samplesPerChunk:n.currentChunk.samples.length}),$(this,Ee).fastStart==="in-memory"){n.currentChunk.offset=0;return}n.currentChunk.offset=$(this,Ce).pos;for(let o of n.currentChunk.samples)$(this,Ce).write(o.data),o.data=null;Pe(this,On,Eo).call(this)}};ba=new WeakSet;li=function(n=!0){if($(this,Ee).fastStart!=="fragmented")throw new Error("Can't finalize a fragment unless 'fastStart' is set to 'fragmented'.");let o=[$(this,at),$(this,tt)].filter(l=>l&&l.currentChunk);if(o.length===0)return;let t=af(this,ai)._++;if(t===1){let l=na(o,$(this,$n),!0);$(this,Ce).writeBox(l)}let a=$(this,Ce).pos,r=Cs(t,o);$(this,Ce).writeBox(r);{let l=Nr(!1),c=0;for(let u of o)for(let p of u.currentChunk.samples)c+=p.size;let d=$(this,Ce).measureBox(l)+c;d>=2**32&&(l.largeSize=!0,d=$(this,Ce).measureBox(l)+c),l.size=d,$(this,Ce).writeBox(l)}for(let l of o){l.currentChunk.offset=$(this,Ce).pos,l.currentChunk.moofOffset=a;for(let c of l.currentChunk.samples)$(this,Ce).write(c.data),c.data=null}let i=$(this,Ce).pos;$(this,Ce).seek($(this,Ce).offsets.get(r));let s=Cs(t,o);$(this,Ce).writeBox(s),$(this,Ce).seek(i);for(let l of o)l.finalizedChunks.push(l.currentChunk),$(this,zn).push(l.currentChunk),l.currentChunk=null;n&&Pe(this,On,Eo).call(this)};On=new WeakSet;Eo=function(){$(this,Ce)instanceof oi&&$(this,Ce).flush()};ia=new WeakSet;Pr=function(){if($(this,ho))throw new Error("Cannot add new video or audio chunks after the file has been finalized.")};const ko=30;class Ln extends Error{constructor({message:t="",code:a=""},...r){super(t,...r);U(this,"message");U(this,"code");this.code=a,this.message=t}}class Qt extends Ln{}class He extends Ln{}class wa extends Ln{}class Ns extends Ln{}function uh(n,o=ko){if(o<1)throw new He({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(n*o)}function An(n,o=ko){if(o<1)throw new He({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(n/o*1e3)}class ve{constructor(o=0){U(this,"time");this.time=Math.round(o)}get millis(){return this.time}set millis(o){this.time=Math.round(o)}get frames(){return uh(this.millis/1e3)}set frames(o){this.millis=An(o)}get seconds(){return this.millis/1e3}set seconds(o){this.millis=o*1e3}addMillis(o){return this.millis=this.millis+o,this}addFrames(o){const t=An(o);return this.millis=this.millis+t,this}add(o){return new ve(o.millis+this.millis)}subtract(o){return new ve(this.millis-o.millis)}static fromSeconds(o){const t=new ve;return t.millis=o*1e3,t}static fromFrames(o,t){const a=new ve;return a.millis=An(o,t),a}copy(){return new ve(this.millis)}toJSON(){return this.millis}static fromJSON(o){return new ve(o)}}function _s(n,o){return[n.slice(0,o),n.slice(o)].filter(t=>t.length>0)}function sa(n,o){return o?Math.floor(Math.random()*(o-n+1)+n):n}function mh(n,o,t){t<0&&(t=0);const a=n[o];n.splice(o,1),n.splice(t,0,a)}function Ts(n){return typeof n!="function"?!1:/^class\s/.test(Function.prototype.toString.call(n))}function ph(n){const o=n.numberOfChannels,t=n.length,a=new Int16Array(t*o);for(let r=0;r<t;r++)for(let i=0;i<o;i++){let s=n.getChannelData(i)[r]*32767;s>32767&&(s=32767),s<-32767&&(s=-32767),a[r*o+i]=s}return a}function fh(n,o=44100,t=2){if(n.sampleRate==o&&n.numberOfChannels==t)return n;const a=Math.floor(n.duration*o),r=new OfflineAudioContext(t,1,o).createBuffer(t,a,o);for(let i=0;i<n.numberOfChannels;i++){const s=n.getChannelData(i),l=r.getChannelData(i),c=n.sampleRate/o;for(let d=0;d<l.length;d++){const u=d*c,p=Math.floor(u),m=Math.ceil(u);if(m>=s.length)l[d]=s[p];else{const f=u-p;l[d]=s[p]*(1-f)+s[m]*f}}}return r}async function hh(n){const{fps:o,height:t,width:a,bitrate:r}=n,i=["avc1.640034","avc1.4d0034","avc1.640028","avc1.640C32","avc1.64001f","avc1.42001E"],s=["prefer-hardware","prefer-software"],l=[];for(const d of i)for(const u of s)l.push({codec:d,hardwareAcceleration:u,width:a,height:t,bitrate:r,framerate:o});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(vh)}function vh(n,o){const t=n.hardwareAcceleration??"",a=o.hardwareAcceleration??"";return t<a?-1:t>a?1:0}async function gh(n,o="untitled"){const t=document.createElement("a");if(document.head.appendChild(t),t.download=o,typeof n=="string"&&n.startsWith("data:image/svg+xml;base64,")){const a=n.split(",")[1],r=atob(a),i=new Array(r.length);for(let c=0;c<r.length;c++)i[c]=r.charCodeAt(c);const s=new Uint8Array(i),l=new Blob([s],{type:"image/svg+xml"});t.href=URL.createObjectURL(l),t.download=o.split(".")[0]+".svg"}else typeof n=="string"?t.href=n:t.href=URL.createObjectURL(n);t.click(),t.remove()}function Ms(n){return`${n.hours.toString().padStart(2,"0")}:${n.minutes.toString().padStart(2,"0")}:${n.seconds.toString().padStart(2,"0")},`+n.milliseconds.toString().padStart(3,"0")}function Fs(n){const o=new Date(1970,0,1);return o.setSeconds(n),o.setMilliseconds(Math.round(n%1*1e3)),{hours:o.getHours(),minutes:o.getMinutes(),seconds:o.getSeconds(),milliseconds:o.getMilliseconds()}}class Yo{constructor(o){U(this,"words",[]);o&&(this.words=o)}get duration(){return this.stop.subtract(this.start)}get text(){return this.words.map(({text:o})=>o).join(" ")}get start(){var o;return((o=this.words.at(0))==null?void 0:o.start)??new ve}get stop(){var o;return((o=this.words.at(-1))==null?void 0:o.stop)??new ve}}var $r=(n=>(n.en="en",n.de="de",n))($r||{});class Is{constructor(o,t,a,r){U(this,"id",crypto.randomUUID());U(this,"text");U(this,"start");U(this,"stop");U(this,"confidence");this.text=o,this.start=new ve(t),this.stop=new ve(a),this.confidence=r}get duration(){return this.stop.subtract(this.start)}}class yn{constructor(o=[],t=$r.en){U(this,"id",crypto.randomUUID());U(this,"language",$r.en);U(this,"groups",[]);this.groups=o,this.language=t}get text(){return this.groups.map(({text:o})=>o).join(" ")}get words(){return this.groups.flatMap(({words:o})=>o)}*iter({count:o,duration:t,length:a}){for(const r of this.groups){let i;for(const[s,l]of r.words.entries())i&&(o&&i.words.length>=sa(...o)?(yield i,i=void 0):t&&(i==null?void 0:i.duration.seconds)>=sa(...t)?(yield i,i=void 0):a&&i.text.length>=sa(...a)&&(yield i,i=void 0)),i?i.words.push(l):i=new Yo([l]),s==r.words.length-1&&(yield i)}}optimize(){const o=this.groups.flatMap(t=>t.words);for(let t=0;t<o.length-1;t++){const a=o[t],r=o[t+1];r.start.millis-a.stop.millis<0?r.start.millis=a.stop.millis+1:a.stop.millis=r.start.millis-1}return this}toSRT(o={}){let t=1,a="";for(const r of this.iter(o)){const i=Fs(r.start.seconds),s=Fs(r.stop.seconds);a+=`${t}
|
|
22
|
+
`+Ms(i)+" --> "+Ms(s)+`
|
|
23
|
+
${r.text}
|
|
24
|
+
|
|
25
|
+
`,t+=1}return{text:a,blob:new Blob([a],{type:"text/plain;charset=utf8"})}}toJSON(){return this.groups.map(o=>o.words.map(t=>({token:t.text,start:t.start.millis,stop:t.stop.millis})))}slice(o,t=!0){let a=0;const r=[];for(const i of this.groups)for(const s of i.words)if(r.length==0&&t&&(a=s.start.millis),r.push(new Is(s.text,s.start.millis-a,s.stop.millis-a)),r.length==o)return new yn([new Yo(r)]);return new yn([new Yo(r)])}copy(){return yn.fromJSON(this.toJSON())}static fromJSON(o){const t=new yn;for(const a of o){const r=new Yo;for(const i of a)r.words.push(new Is(i.token,i.start,i.stop));t.groups.push(r)}return t}static async from(o,t){const a=await fetch(o,t);if(!a.ok)throw new Qt({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});return yn.fromJSON(await a.json())}}function la(n,o,t){return n+(o-n)*t}function yh(n,o,t){const a=Number.parseInt(n.slice(1),16),r=Number.parseInt(o.slice(1),16),i=a>>16&255,s=a>>8&255,l=a&255,c=r>>16&255,d=r>>8&255,u=r&255,p=Math.round(la(i,c,t)),m=Math.round(la(s,d,t)),f=Math.round(la(l,u,t));return`#${((1<<24)+(p<<16)+(m<<8)+f).toString(16).slice(1)}`}const bh={linear:n=>n,easeIn:n=>n*n,easeOut:n=>n*(2-n),easeInOut:n=>n<.5?2*n*n:-1+(4-2*n)*n};class Se{constructor(o,t,a={}){U(this,"input");U(this,"output");U(this,"options");if(o.length!==t.length)throw new He({code:"invalidKeyframes",message:"inputRange and outputRange must have the same length"});this.input=o.map(r=>An(r)),this.output=t,this.options={extrapolate:"clamp",easing:"linear",type:"number",...JSON.parse(JSON.stringify(a))}}normalize(o){const{input:t}=this;if(o<t[0])return this.options.extrapolate==="clamp"?{t:0,segment:0}:{t:(o-t[0])/(t[1]-t[0]),segment:0};if(o>t[t.length-1])return this.options.extrapolate==="clamp"?{t:1,segment:t.length-2}:{t:(o-t[t.length-2])/(t[t.length-1]-t[t.length-2]),segment:t.length-2};for(let a=0;a<t.length-1;a++){const r=t[a],i=t[a+1];if(o>=r&&o<=i)return{t:(o-r)/(i-r),segment:a}}return{t:0,segment:0}}interpolate(o,t){const a=this.output[t],r=this.output[t+1],i=bh[this.options.easing](o);if(typeof a=="number"&&typeof r=="number")return la(a,r,i);if(typeof a=="string"&&typeof r=="string")return yh(a,r,i);if(this.output.length==1)return this.output[0];throw new He({code:"invalidKeyframes",message:"Unsupported output range types"})}value(o){const{t,segment:a}=this.normalize(typeof o=="number"?o:o.millis);return this.interpolate(t,a)}push(o,t){return this.input.push(An(o)),this.output.push(t),this}toJSON(){return this}static fromJSON(o){const t=new Se([],[]);return Object.assign(t,o),t}}class _t{constructor(){U(this,"id",crypto.randomUUID())}toJSON(){const o={};return(this.constructor.__serializableProperties||[]).forEach(({propertyKey:t,serializer:a})=>{const r=this[t];a&&r instanceof a?o[t]=r.toJSON():o[t]=r}),o}static fromJSON(o){const t=new this;return(this.__serializableProperties||[]).forEach(({propertyKey:a,serializer:r})=>{if(o.hasOwnProperty(a))if(r){const i=r.fromJSON(o[a]);t[a]=i}else t[a]=o[a]}),t}}function fe(n){return function(o,t){o.constructor.__serializableProperties||(o.constructor.__serializableProperties=[]),o.constructor.__serializableProperties.push({propertyKey:t,serializer:n})}}function Vo(n){return class extends n{constructor(){super(...arguments);U(this,"_handlers",{})}on(t,a){if(typeof a!="function")throw new Error("The callback of an event listener needs to be a function.");const r=crypto.randomUUID();return this._handlers[t]?this._handlers[t][r]=a:this._handlers[t]={[r]:a},r}off(t,...a){if(t){if(t==="*"){this._handlers={};return}for(const r of Object.values(this._handlers))t in r&&delete r[t];for(const r of a)this.off(r)}}trigger(t,a){var i,s;const r=new CustomEvent(t,{detail:a});Object.defineProperty(r,"currentTarget",{writable:!1,value:this});for(const l in this._handlers[t]??{})(i=this._handlers[t])==null||i[l](r);for(const l in this._handlers["*"]??{})(s=this._handlers["*"])==null||s[l](r)}bubble(t){return this.on("*",a=>{t.trigger(a.type,a.detail)})}resolve(t){return(a,r)=>{this.on("error",r),this.on(t,a)}}}}function ci(n,o,t=0){if(!(n instanceof Oe.Container||n instanceof Oe.Filter||t==3))for(const a in n){const r=n[a];a&&(r instanceof Se&&(n[a]=r.value(o)),r!=null&&typeof r=="object"&&Object.keys(r).length&&ci(r,o,t+1))}}var wh=Object.defineProperty,Ta=(n,o,t,a)=>{for(var r=void 0,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&wh(o,t,r),r};const Co=class Ql extends Vo(_t){constructor(t={}){super();U(this,"_name");U(this,"_start",new ve);U(this,"_stop",ve.fromSeconds(16));U(this,"type","base");U(this,"source");U(this,"view",new Oe.Container);U(this,"createdAt",new Date);U(this,"disabled",!1);U(this,"state","IDLE");U(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",ve.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 i,s;if(t||(t=(s=(i=this.track)==null?void 0:i.composition)==null?void 0:s.frame),typeof t=="number"&&(t=ve.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new He({code:"splitOutOfRange",message:"Cannot split clip at the specified time"});if(!this.track)throw new He({code:"trackNotAttached",message:"Track must be attached to a track"});const a=this.copy();this.stop=t.copy(),a.start=t.copy().addMillis(1),ci(a,a.start.subtract(this.start));const r=this.track.clips.findIndex(l=>l.id==this.id);return await this.track.add(a,r+1),a}copy(){return Ql.fromJSON(JSON.parse(JSON.stringify(this)))}set(t){return t&&Object.assign(this,t),this.trigger("update",void 0),this}};Ta([fe()],Co.prototype,"_name");Ta([fe(ve)],Co.prototype,"_start");Ta([fe(ve)],Co.prototype,"_stop");Ta([fe()],Co.prototype,"disabled");let No=Co;var kh=Object.defineProperty,Vn=(n,o,t,a)=>{for(var r=void 0,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&kh(o,t,r),r};class Yt extends Vo(_t){constructor(){super(...arguments);U(this,"state","IDLE");U(this,"metadata");U(this,"objectURL");U(this,"duration",ve.fromSeconds(16));U(this,"added",!1);U(this,"type","base");U(this,"name","");U(this,"mimeType");U(this,"externalURL");U(this,"external",!1);U(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 He({code:"fileNotAccessible",message:"The desired file cannot be accessed"});return this.file}async loadFile(t){this.name=t.name,this.mimeType=Ur(t.type),this.external=!1,this.file=t}async loadUrl(t,a){const r=await fetch(t,a);if(!(r!=null&&r.ok))throw new Qt({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});const i=await r.blob();this.name=t.toString().split("/").at(-1)??"",this.external=!0,this.file=new File([i],this.name,{type:i.type}),this.externalURL=t,this.mimeType=Ur(i.type)}async from(t,a){try{this.state="LOADING",t instanceof File?await this.loadFile(t):await this.loadUrl(t,a),this.state="READY",this.trigger("load",void 0)}catch(r){throw this.state=="ERROR",this.trigger("error",new Error(String(r))),r}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();gh(t,this.name)}async thumbnail(){return document.createElement("div")}static async from(t,a,r=new this){return r.from(t,a)}}Vn([fe()],Yt.prototype,"objectURL");Vn([fe()],Yt.prototype,"duration");Vn([fe()],Yt.prototype,"type");Vn([fe()],Yt.prototype,"name");Vn([fe()],Yt.prototype,"mimeType");Vn([fe()],Yt.prototype,"externalURL");Vn([fe()],Yt.prototype,"external");const Bs="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E";function xh(n){const o=new TextEncoder().encode(n);let t="";const a=o.byteLength;for(let r=0;r<a;r++)t+=String.fromCharCode(o[r]);return btoa(t)}function Rs(n){if(!n||!n.body)return Bs;const o=n.body.scrollWidth,t=n.body.scrollHeight,a=n.cloneNode(!0),r=a.getElementsByTagName("style").item(0),i=a.getElementsByTagName("body").item(0);if(i==null||i.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),!i)return Bs;const s=new XMLSerializer,l=r?s.serializeToString(r):"",c=s.serializeToString(i),d=`
|
|
26
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="${o}" 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,"+xh(d)}class Ps extends Yt{constructor(){super();U(this,"type","html");U(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=Rs(this.document),this.objectURL)}async loadUrl(t,a){await super.loadUrl(t,a),this.iframe.setAttribute("src",URL.createObjectURL(this.file)),await new Promise((r,i)=>{this.iframe.onload=()=>r(),this.iframe.onerror=s=>i(s)})}async loadFile(t){await super.loadFile(t),this.iframe.setAttribute("src",URL.createObjectURL(this.file)),await new Promise((a,r)=>{this.iframe.onload=()=>a(),this.iframe.onerror=i=>r(i)})}update(){this.objectURL&&(this.objectURL=Rs(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 Sh(n,o={}){const{threshold:t=.02,hopSize:a=1024,minDuration:r=500}=o,i=[],s=n.getChannelData(0),l=n.sampleRate,c=Math.floor(r/1e3*l);let d=null,u=0;for(let p=0;p<s.length;p+=a){let m=0;const f=Math.min(p+a,s.length);for(let v=p;v<f;v++)m+=s[v]*s[v];m=Math.sqrt(m/(f-p)),m<t?(u+=a,d===null&&(d=p)):(d!==null&&u>=c&&i.push({start:ve.fromSeconds(d/l),stop:ve.fromSeconds(p/l)}),d=null,u=0)}return d!==null&&u>=c&&i.push({start:ve.fromSeconds(d/l),stop:ve.fromSeconds(s.length/l)}),i}const hr=3e3;class cn extends Yt{constructor(){super(...arguments);U(this,"type","audio");U(this,"decoding",!1);U(this,"_silences");U(this,"transcript");U(this,"audioBuffer")}async decode(t=2,a=48e3,r=!1){if(this.decoding&&r&&(await new Promise(this.resolve("update")),this.audioBuffer))return this.audioBuffer;this.decoding=!0;const i=await this.arrayBuffer(),s=await new OfflineAudioContext(t,1,a).decodeAudioData(i);return this.duration.seconds=s.duration,r&&(this.audioBuffer=s),this.decoding=!1,this.trigger("update",void 0),s}async samples(t=60,a=50,r=0){const i=this.audioBuffer??await this.decode(1,3e3,!0),s=Math.round(i.sampleRate/a),l=i.sampleRate*i.duration-s,c=Math.ceil(l/t),d=i.getChannelData(0),u=[];for(let p=0;p<l;p+=c){let m=0;for(let f=p;f<p+s;f++)m+=Math.abs(d[p]);u.push(Math.log1p(m/s*100))}return u.map(p=>Math.round(p/Math.max(...u)*(100-r))+r)}async fastsampler({length:t=60,start:a=0,stop:r,logarithmic:i=!1}={}){typeof a=="object"&&(a=a.millis),typeof r=="object"&&(r=r.millis);const s=this.audioBuffer??await this.decode(1,hr,!0),l=s.getChannelData(0),c=Math.floor(Math.max(a*hr/1e3,0)),d=r?Math.floor(Math.min(r*hr/1e3,s.length)):s.length,u=Math.floor((d-c)/t),p=new Float32Array(t);for(let m=0;m<t;m++){const f=c+m*u,v=f+u;let b=-1/0;for(let S=f;S<v;S++){const M=l[S];M>b&&(b=M)}p[m]=i?Math.log2(1+b):b}return p}async thumbnail(...t){const a=await this.samples(...t),r=document.createElement("div");r.className="flex flex-row absolute space-between inset-0 audio-samples";for(const i of a){const s=document.createElement("div");s.className="audio-sample-item",s.style.height=`${i}%`,r.appendChild(s)}return r}async silences(t={}){if(this._silences)return this._silences;const a=await this.arrayBuffer(),r=new AudioContext,i=await r.decodeAudioData(a);return this._silences=Sh(i,t),r.close(),this._silences}}class zr extends Yt{constructor(){super(...arguments);U(this,"type","image")}async thumbnail(){const t=new Image;return t.src=await this.createObjectURL(),t.className="object-cover w-full aspect-video h-auto",t}}class bn extends cn{constructor(){super(...arguments);U(this,"type","video");U(this,"downloadInProgress",!0)}async loadUrl(t,a){const r=await fetch(t,a);if(!(r!=null&&r.ok))throw new Qt({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=Ur(r.headers.get("Content-type")),this.getBlob(r)}async getFile(){if(!this.file&&this.downloadInProgress&&await new Promise(this.resolve("load")),!this.file)throw new He({code:"fileNotAccessible",message:"The desired file cannot be accessed"});return this.file}async thumbnail(){const t=document.createElement("video");return t.className="object-cover w-full aspect-video h-auto",t.controls=!1,t.addEventListener("loadedmetadata",()=>{this.duration.seconds=t.duration,this.trigger("update",void 0)}),t.addEventListener("mousemove",a=>{const r=a.currentTarget,i=r==null?void 0:r.getBoundingClientRect(),s=a.clientX-((i==null?void 0:i.left)??0),l=r==null?void 0:r.duration;l&&i&&i.width>0&&(r.currentTime=Math.round(l*(s/i.width)))}),t.src=await this.createObjectURL(),t}async getBlob(t){try{this.downloadInProgress=!0;const a=await t.blob();this.file=new File([a],this.name,{type:a.type}),this.trigger("load",void 0)}catch(a){this.state=="ERROR",this.trigger("error",new Error(String(a)))}finally{this.downloadInProgress=!1}}}class Eh{static fromJSON(o){return[new ve(o[0]),new ve(o[1])]}}var Vh=Object.defineProperty,Ch=Object.getOwnPropertyDescriptor,Wn=(n,o,t,a)=>{for(var r=a>1?void 0:a?Ch(o,t):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=(a?s(o,t,r):s(r))||r);return a&&r&&Vh(o,t,r),r};const Cn=class ec extends No{constructor(t={}){super();U(this,"source",new cn);U(this,"_offset",new ve);U(this,"playing",!1);U(this,"duration",new ve);U(this,"range",[new ve,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=ve.fromFrames(t));const a=t.subtract(this.offset);a.millis>=0&&a.millis<this.range[1].millis?this.range[0].millis=a.millis:a.millis<0?this.range[0].millis=0:this.range[0].millis=this.range[1].millis-1,this.trigger("frame",void 0)}set stop(t){typeof t=="number"&&(t=ve.fromFrames(t));const a=t.subtract(this.offset);a.millis>this.range[0].millis&&a.millis<=this.duration.millis?this.range[1]=a:a.millis>this.duration.millis?this.range[1]=this.duration:this.range[1].millis=this.range[0].millis+1,this.trigger("frame",void 0)}get offset(){return this._offset}set offset(t){typeof t=="number"?this._offset.frames=t:this._offset=t,this.trigger("frame",this.offset.frames)}offsetBy(t){return typeof t=="number"?(this.offset.addFrames(t),this.trigger("offsetBy",ve.fromFrames(t))):(this.offset.addMillis(t.millis),this.trigger("offsetBy",t)),this.trigger("frame",void 0),this}get muted(){var t;return((t=this.element)==null?void 0:t.muted)??!1}set muted(t){this.element&&(this.element.muted=t)}seek(t){return new Promise((a,r)=>{if(!this.element)return r(new Ns({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 i;return r((i=this.element)==null?void 0:i.error)},this.element.pause(),this.element.currentTime=t.subtract(this.offset).seconds,this.element.onseeked=()=>a()})}subclip(t,a){if(t||(t=this.range[0]),a||(a=this.range[1]),typeof t=="number"&&(t=ve.fromFrames(t)),typeof a=="number"&&(a=ve.fromFrames(a)),t.millis>=a.millis)throw new He({code:"invalidKeyframe",message:"Start can't lower than or equal the stop"});return t.millis<0&&(this.range[0].millis=0,t=this.range[0]),a.millis>this.duration.millis&&this.duration.millis&&(a=this.duration),this.range=[t,a],this.trigger("frame",void 0),this}get volume(){var t;return((t=this.element)==null?void 0:t.volume)??1}set volume(t){this.element&&(this.element.volume=t)}copy(){const t=ec.fromJSON(JSON.parse(JSON.stringify(this)));return t.source=this.source,t}async split(t){var i,s;if(t||(t=(s=(i=this.track)==null?void 0:i.composition)==null?void 0:s.frame),typeof t=="number"&&(t=ve.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new He({code:"invalidKeyframe",message:"Cannot split clip at the specified time"});if(!this.track)throw new Ns({code:"trackNotDefined",message:"Clip must be attached to a track"});t=t.subtract(this.offset);const a=this.copy();this.range[1]=t.copy(),a.range[0]=t.copy().addMillis(1),ci(a,a.start.subtract(this.start));const r=this.track.clips.findIndex(l=>l.id==this.id);return await this.track.add(a,r+1),a}async addCaptions(t){var a;if(!((a=this.track)!=null&&a.composition))throw new He({code:"compositionNotDefined",message:"Captions can only be generated after the clip has been added to the composition"});return await this.track.composition.createTrack("caption").from(this).generate(t)}set(t){return super.set(t)}async generateCaptions(t){return this.addCaptions(t)}async removeSilences(t={}){["READY","ATTACHED"].includes(this.state)||await this.init();const a=(await this.source.silences(t)).filter(s=>$s(s,this.range)).sort((s,l)=>s.start.millis-l.start.millis);if(a.length==0)return[this];const r=t.padding??500,i=[this];for(const s of a){const l=i.at(-1);if(!l)break;if(!$s(s,l.range))continue;const c=new ve(Math.min(s.start.millis+r,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,i.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 i}};Wn([fe(ve)],Cn.prototype,"_offset",2);Wn([fe(ve)],Cn.prototype,"duration",2);Wn([fe(Eh)],Cn.prototype,"range",2);Wn([fe(yn)],Cn.prototype,"transcript",1);Wn([fe()],Cn.prototype,"muted",1);Wn([fe()],Cn.prototype,"volume",1);let Ma=Cn;function $s(n,o){return n.start.millis>=o[0].millis&&n.start.millis<=o[1].millis||n.stop.millis<=o[1].millis&&n.stop.millis>=o[0].millis}class Go{static fromJSON(o){return typeof o=="object"?Se.fromJSON(o):o}}class vr{static fromJSON(o){return typeof o.x=="object"&&(o.x=Se.fromJSON(o.x)),typeof o.y=="object"&&(o.y=Se.fromJSON(o.y)),o}}let Nh=class{constructor(n){U(this,"target");U(this,"animation");this.target=n}init(n,o,t=0,a){if(!(n in this.target))throw new Error(`Property [${String(n)}] cannot be assigned`);const r=[t],i=[o];typeof this.target[n]==typeof o&&t!=0&&(r.unshift(0),i.unshift(this.target[n])),this.target[n]=this.animation=new Se(r,i,{easing:a})}};function _h(n){const o=new Proxy(n,{get(t,a){return a=="to"?(r,i)=>{if(!t.animation)throw new He({code:"undefinedKeyframe",message:"Cannot use 'to() before selecting a property"});const s=new ve(t.animation.input.at(-1)).frames+i;return t.animation.push(s,r),o}:(r,i,s)=>(t.init(a,r,i,s),o)}});return o}class Th extends Nh{}var Mh=Object.defineProperty,Fh=Object.getOwnPropertyDescriptor,rn=(n,o,t,a)=>{for(var r=a>1?void 0:a?Fh(o,t):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=(a?s(o,t,r):s(r))||r);return a&&r&&Mh(o,t,r),r};function Fa(n){class o extends n{constructor(){super(...arguments);U(this,"filters");U(this,"_height");U(this,"_width");U(this,"_position",{x:this.view.position.x,y:this.view.position.y});U(this,"_scale");U(this,"rotation",this.view.angle);U(this,"alpha",1);U(this,"translate",{x:0,y:0})}get position(){return this._position}set position(r){typeof r=="string"?(this._position={x:"50%",y:"50%"},this.anchor={x:.5,y:.5}):this._position=r}get scale(){return this._scale??{x:this.view.scale.x,y:this.view.scale.y}}set scale(r){typeof r=="number"||r instanceof Se||typeof r=="function"?this._scale={x:r,y:r}:this._scale=r}get x(){return this._position.x}set x(r){this._position.x=r}get y(){return this._position.y}set y(r){this._position.y=r}get translateX(){return this.translate.x}set translateX(r){this.translate.x=r}get translateY(){return this.translate.y}set translateY(r){this.translate.y=r}get height(){return this._height??this.view.height}set height(r){this._height=r}get width(){return this._width??this.view.width}set width(r){this._width=r}get mask(){return this.view.mask}set mask(r){this.view.mask=r??null}get anchor(){return this.view.children[0]instanceof Oe.Sprite?{x:this.view.children[0].anchor.x,y:this.view.children[0].anchor.y}:{x:0,y:0}}set anchor(r){const i=typeof r=="number"?{x:r,y:r}:r;for(const s of this.view.children)s instanceof Oe.Sprite&&s.anchor.set(i.x,i.y)}enter(){this.filters&&!this.view.filters&&(this.view.filters=this.filters)}exit(){this.filters&&this.view.filters&&(this.view.filters=null)}animate(){return _h(new Th(this))}}return rn([fe(Go)],o.prototype,"_height",2),rn([fe(Go)],o.prototype,"_width",2),rn([fe(vr)],o.prototype,"_position",2),rn([fe(vr)],o.prototype,"_scale",2),rn([fe(Go)],o.prototype,"rotation",2),rn([fe(Go)],o.prototype,"alpha",2),rn([fe(vr)],o.prototype,"translate",2),rn([fe()],o.prototype,"anchor",1),o}function Ia(n,o,t){const a=t.value;return t.value=function(...r){var p,m,f,v;const i=r[0].subtract(this.start),s={width:((m=(p=this.track)==null?void 0:p.composition)==null?void 0:m.width)??1920,height:((v=(f=this.track)==null?void 0:f.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)(i):l=this.translate.x.value(i);let c;typeof this.translate.y=="number"?c=this.translate.y:typeof this.translate.y=="function"?c=this.translate.y.bind(this)(i):c=this.translate.y.value(i);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)(i):d=this._position.x.value(i);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)(i):u=this._position.y.value(i),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(i):typeof this._height=="function"?this.view.height=this._height.bind(this)(i):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(i):typeof this._width=="function"?this.view.width=this._width.bind(this)(i):this._width&&(this.view.width=this._width),this._width&&!this._height&&this.view.scale.set(this.view.scale.x),this._scale){let b;typeof this._scale.x=="number"?b=this._scale.x:typeof this._scale.x=="function"?b=this._scale.x.bind(this)(i):b=this._scale.x.value(i);let S;typeof this._scale.y=="number"?S=this._scale.y:typeof this._scale.y=="function"?S=this._scale.y.bind(this)(i):S=this._scale.y.value(i),(this._width||this._height)&&(b*=this.view.scale._x,S*=this.view.scale._y),this.view.scale.set(b,S)}return typeof this.rotation=="number"?this.view.angle=this.rotation:typeof this.rotation=="function"?this.view.angle=this.rotation.bind(this)(i):this.view.angle=this.rotation.value(i),typeof this.alpha=="number"?this.view.alpha=this.alpha:typeof this.alpha=="function"?this.view.alpha=this.alpha.bind(this)(i):this.view.alpha=this.alpha.value(i),a.apply(this,r)},t}var Ih=Object.defineProperty,Bh=Object.getOwnPropertyDescriptor,Rh=(n,o,t,a)=>{for(var r=Bh(o,t),i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&Ih(o,t,r),r};const tc=class nc extends Fa(No){constructor(t,a={}){super();U(this,"type","image");U(this,"element",new Image);U(this,"source",new zr);U(this,"sprite",new Oe.Sprite);this.view.addChild(this.sprite),t instanceof zr&&(this.source=t),t instanceof File&&this.source.from(t),Object.assign(this,a)}async init(){this.element.setAttribute("src",await this.source.createObjectURL()),await new Promise((t,a)=>{this.element.onload=()=>{this.sprite.texture=Oe.Texture.from(this.element),this.state="READY",t()},this.element.onerror=r=>{this.state="ERROR",a(new Qt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=nc.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};Rh([Ia],tc.prototype,"update");let Ph=tc;const Ho={"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 $h=Object.defineProperty,Ba=(n,o,t,a)=>{for(var r=void 0,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&$h(o,t,r),r};const _o=class Ar extends Vo(_t){constructor(t){super();U(this,"loaded",!1);U(this,"family");U(this,"weight");U(this,"source");U(this,"style");t!=null&&t.source.startsWith("https://")&&(t.source=`url(${t.source})`),this.family=(t==null?void 0:t.family)??"Arial",this.source=t==null?void 0:t.source,this.style=t==null?void 0:t.style,this.weight=t==null?void 0:t.weight}get name(){return this.family+" "+(this.style??this.weight)}async load(){if(this.loaded||!this.source||!this.family)return this;const t=new FontFace(this.name,this.source);return this.weight&&(t.weight=this.weight),await new Promise(a=>{t.load().then(r=>{document.fonts.add(r),a(null)})}),this.loaded=!0,this.trigger("load",void 0),this}copy(){const t=Ar.fromJSON(JSON.parse(JSON.stringify(this)));return t.loaded=this.loaded,t}static async localFonts(){const t={};"queryLocalFonts"in window||Object.assign(window,{queryLocalFonts:()=>[]});for(const a of await window.queryLocalFonts()){if(a.family in t){t[a.family].push(a);continue}t[a.family]=[a]}return Object.keys(t).map(a=>({family:a,variants:t[a].map(r=>({family:a,style:r.style,source:`local('${r.fullName}'), local('${r.postscriptName}')`}))}))}static webFonts(){return Object.keys(Ho).map(t=>({family:t,variants:Ho[t].weights.map(a=>({family:t,source:`url(${Ho[t].url})`,weight:a}))}))}static fromFamily({family:t,weight:a}){return new Ar({family:t,source:`url(${Ho[t].url})`,weight:a})}};Ba([fe()],_o.prototype,"family");Ba([fe()],_o.prototype,"weight");Ba([fe()],_o.prototype,"source");Ba([fe()],_o.prototype,"style");let st=_o;const jt=4,oc={center:.5,justify:.5,left:0,right:1},ac={alphabetic:0,top:0,middle:.5,hanging:1,bottom:1,ideographic:1};var zh=Object.defineProperty,Ah=Object.getOwnPropertyDescriptor,gt=(n,o,t,a)=>{for(var r=Ah(o,t),i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&zh(o,t,r),r};const mt=class rc extends Fa(No){constructor(t){super();U(this,"type","text");U(this,"_text","");U(this,"_textCase");U(this,"_anchor",{x:0,y:0});U(this,"_font",new st);U(this,"style",new Oe.TextStyle({fill:"#FFFFFF",fontFamily:this._font.family,fontSize:16}));this.style.padding=20,typeof t=="string"?(this.text=t,this.reflectUpdate()):t&&(Object.assign(this,t),this.reflectUpdate()),this.on("update",this.reflectUpdate.bind(this))}get text(){return this._text}set text(t){if(this._text=t,!this.view.children.length){const a=new Oe.Text({text:this.transformedText,style:this.style,resolution:jt,scale:jt});this.view.addChild(a)}this.view.children[0]instanceof Oe.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*jt}set maxWidth(t){t?(this.style.wordWrap=!0,this.style.wordWrapWidth=t/jt):this.style.wordWrap=!1}get textAlign(){return this.style.align}set textAlign(t){this.style.align=t,this.anchor.x=oc[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=ac[t]}get fillStyle(){const{fill:t}=this.style;return new Oe.Color(t.toString()).toHex().toUpperCase()}set fillStyle(t){this.style.fill=t}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor={x:t,y:t}:this._anchor=t}get stroke(){if(!this.style.stroke)return;let{color:t="#000000",alpha:a=1,width:r=3,join:i="round",miterLimit:s}=this.style.stroke;return t=new Oe.Color(t).toHex().toUpperCase(),{color:t,alpha:a,width:r,join:i,miterLimit:s}}set stroke(t){if(!t){this.style.stroke=void 0;return}const{color:a="#000000",alpha:r=1,width:i=3,join:s="round",miterLimit:l}=t;this.style.stroke={color:a,alpha:r,width:i,join:s,miterLimit:l}}get textCase(){return this._textCase}set textCase(t){this._textCase=t,this.view.children[0]instanceof Oe.Text&&this.transformedText&&(this.view.children[0].text=this.transformedText)}get shadow(){if(!this.style.dropShadow)return;const{alpha:t,angle:a,blur:r,color:i,distance:s}=this.style.dropShadow,l=new Oe.Color(i).toHex().toUpperCase();return{alpha:t,angle:a,blur:r,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=rc.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 i,s,l;const t=((i=this.view.children[0])==null?void 0:i.width)??0,a=((s=this.view.children[0])==null?void 0:s.height)??0,r=(((l=this.style.dropShadow)==null?void 0:l.distance)??0)*jt;this.view.pivot={x:(t-r)*this._anchor.x,y:(a-r)*this._anchor.y}}set(t){return super.set(t)}};gt([fe()],mt.prototype,"text");gt([fe(st)],mt.prototype,"font");gt([fe()],mt.prototype,"maxWidth");gt([fe()],mt.prototype,"textAlign");gt([fe()],mt.prototype,"padding");gt([fe()],mt.prototype,"textBaseline");gt([fe()],mt.prototype,"fillStyle");gt([fe()],mt.prototype,"anchor");gt([fe()],mt.prototype,"stroke");gt([fe()],mt.prototype,"textCase");gt([fe()],mt.prototype,"shadow");gt([fe()],mt.prototype,"fontSize");gt([fe()],mt.prototype,"leading");gt([Ia],mt.prototype,"update");let jn=mt;function gr(n){const o=n.split(" ").map(t=>`${t} `);return o[o.length-1]=o[o.length-1].replace(/ $/,""),o}const Dh={get(n,o){const t=n[o];return typeof t=="number"?t*jt:Array.isArray(t)&&typeof t[0]=="number"?t.map(a=>a*jt):t}};function Uh(n){return new Proxy(n,Dh)}class Oh{constructor(){U(this,"tokens",[])}get width(){return this.tokens.reduce((o,t)=>o+t.metrics.lineWidths[0],0)}get height(){return Math.max(...this.tokens.map(o=>o.metrics.lineHeight))}}class zs{constructor(){U(this,"lines",[])}get width(){return Math.max(...this.lines.map(o=>o.width))}get height(){return this.lines.reduce((o,t)=>o+t.height,0)}}class Lh{static fromJSON(o){return o.map(t=>(t.font&&(t.font=st.fromJSON(t.font)),t))}}var Wh=Object.defineProperty,jh=Object.getOwnPropertyDescriptor,Xn=(n,o,t,a)=>{for(var r=a>1?void 0:a?jh(o,t):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=(a?s(o,t,r):s(r))||r);return a&&r&&Wh(o,t,r),r};const Nn=class ic extends jn{constructor(t){super();U(this,"type","complex_text");U(this,"_maxWidth");U(this,"_textAlign","left");U(this,"_textBaseline","top");U(this,"model",new Oe.Container);U(this,"segments",[]);U(this,"metrics",new zs);U(this,"background");U(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=oc[t];const a=this.metrics.width;for(const r of this.metrics.lines){let i=0;(t=="center"||t=="justify")&&(i=(a-r.width)/2),t=="right"&&(i=a-r.width);for(const s of r.tokens)this.model.children[s.index].x=i,i+=s.metrics.lineWidths[0]}}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline=t,this._anchor.y=ac[t];let a=0;for(const r of this.metrics.lines){const i=r.height;for(const s of r.tokens){let l=0;t=="middle"&&(l=(i-s.metrics.lineHeight)/2),t=="bottom"&&(l=i-s.metrics.lineHeight),this.model.children[s.index].y=a+l}a+=i}}copy(){const t=ic.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.font=this.font,t}createRenderSplits(t=[]){var i,s;const a=this.transformedText??"",r=[{index:void 0,tokens:gr(a.substring(0,(i=t==null?void 0:t.at(0))==null?void 0:i.start))}];for(let l=0;l<t.length;l++)r.push({index:t[l].index,tokens:gr(a.substring(t[l].start,t[l].stop))}),!((t[l].stop??a.length)>=a.length)&&r.push({index:void 0,tokens:gr(a.substring(t[l].stop,(s=t.at(l+1))==null?void 0:s.start))});return r.filter(l=>l.tokens.join("").trim().length)}createTextMetrics(t,a){var i,s,l;const r=new zs;for(const c of t){const d=c.index!=null?a[c.index]:this.style;for(let u=0;u<c.tokens.length;u++){const p=Uh(Oe.CanvasTextMetrics.measureText(c.tokens[u],d)),m=(((i=r.lines.at(-1))==null?void 0:i.width)??0)+p.lineWidths[0],f=this.maxWidth??Number.POSITIVE_INFINITY,v=(s=c.tokens.at(u-1))==null?void 0:s.match(/(\n|\\n).$/gim);(m>f||v||!r.lines.length)&&r.lines.push(new Oh),this.model.addChild(new Oe.Text({text:c.tokens[u],style:d,resolution:jt,scale:jt})),(l=r.lines.at(-1))==null||l.tokens.push({metrics:p,index:this.model.children.length-1})}}return r}createTextStyles(){var t;return((t=this.styles)==null?void 0:t.map(a=>{var i;const r=this.style.clone();return r.fill=a.fillStyle??this.style.fill,r.fontSize=a.fontSize??this.style.fontSize,r.stroke=a.stroke??this.style.stroke,r.fontFamily=((i=a.font)==null?void 0:i.name)??this.style.fontFamily,r}))??[]}drawBackground(){var l,c;if(this.view.children.length>1&&this.view.removeChildAt(0),!this.background)return;const t=this.model.width,a=this.model.height,r=((l=this.background.padding)==null?void 0:l.x)??40,i=((c=this.background.padding)==null?void 0:c.y)??10,s=new Oe.Graphics;s.roundRect(0-r/2,2-i/2,t+r,a+i,this.background.borderRadius??20),s.fill(this.background.fill??"#000000"),s.alpha=this.background.alpha??1,this.view.addChildAt(s,0)}reflectUpdate(){var l;if(!this.transformedText)return;this.model.removeChildren();const t=this.createRenderSplits(this.segments),a=this.createTextStyles();this.metrics=this.createTextMetrics(t,a),this.textAlign=this.textAlign,this.textBaseline=this.textBaseline;const r=this.view.width,i=this.view.height,s=(((l=this.style.dropShadow)==null?void 0:l.distance)??0)*jt;this.view.pivot={x:(r-s)*this._anchor.x,y:(i-s)*this._anchor.y},this.drawBackground()}};Xn([fe()],Nn.prototype,"background",2);Xn([fe(Lh)],Nn.prototype,"styles",2);Xn([fe()],Nn.prototype,"text",1);Xn([fe()],Nn.prototype,"maxWidth",1);Xn([fe()],Nn.prototype,"textAlign",1);Xn([fe()],Nn.prototype,"textBaseline",1);let Ra=Nn;const sc="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBtPSh0PT4odFt0LkFWTUVESUFfVFlQRV9VTktOT1dOPS0xXT0iQVZNRURJQV9UWVBFX1VOS05PV04iLHRbdC5BVk1FRElBX1RZUEVfVklERU89MF09IkFWTUVESUFfVFlQRV9WSURFTyIsdFt0LkFWTUVESUFfVFlQRV9BVURJTz0xXT0iQVZNRURJQV9UWVBFX0FVRElPIix0W3QuQVZNRURJQV9UWVBFX0RBVEE9Ml09IkFWTUVESUFfVFlQRV9EQVRBIix0W3QuQVZNRURJQV9UWVBFX1NVQlRJVExFPTNdPSJBVk1FRElBX1RZUEVfU1VCVElUTEUiLHRbdC5BVk1FRElBX1RZUEVfQVRUQUNITUVOVD00XT0iQVZNRURJQV9UWVBFX0FUVEFDSE1FTlQiLHRbdC5BVk1FRElBX1RZUEVfTkI9NV09IkFWTUVESUFfVFlQRV9OQiIsdCkpKG18fHt9KSxvPSh0PT4odC5GRm1wZWdXb3JrZXJMb2FkZWQ9IkZGbXBlZ1dvcmtlckxvYWRlZCIsdC5XQVNNUnVudGltZUluaXRpYWxpemVkPSJXQVNNUnVudGltZUluaXRpYWxpemVkIix0LkxvYWRXQVNNPSJMb2FkV0FTTSIsdC5HZXRBVlBhY2tldD0iR2V0QVZQYWNrZXQiLHQuR2V0QVZQYWNrZXRzPSJHZXRBVlBhY2tldHMiLHQuR2V0QVZTdHJlYW09IkdldEFWU3RyZWFtIix0LkdldEFWU3RyZWFtcz0iR2V0QVZTdHJlYW1zIix0LlJlYWRBVlBhY2tldD0iUmVhZEFWUGFja2V0Iix0LkFWUGFja2V0U3RyZWFtPSJBVlBhY2tldFN0cmVhbSIsdC5SZWFkTmV4dEFWUGFja2V0PSJSZWFkTmV4dEFWUGFja2V0Iix0LlN0b3BSZWFkQVZQYWNrZXQ9IlN0b3BSZWFkQVZQYWNrZXQiLHQpKShvfHx7fSk7Y29uc3QgQT0iS0daMWJtTjBhVzl1S0NsN0luVnpaU0J6ZEhKcFkzUWlPMnhsZENCbU8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2SWtaR2JYQmxaMWR2Y210bGNreHZZV1JsWkNKOUtTeHpaV3htTG1Ga1pFVjJaVzUwVEdsemRHVnVaWElvSW0xbGMzTmhaMlVpTEdGemVXNWpJR1oxYm1OMGFXOXVLR3dwZTJOdmJuTjBlM1I1Y0dVNmRDeGtZWFJoT21NOWUzMHNiWE5uU1dRNmIzMDliQzVrWVhSaE8zUnllWHRwWmloMFBUMDlJa3h2WVdSWFFWTk5JaWw3WTI5dWMzUjdkMkZ6YlV4dllXUmxjbEJoZEdnNlpYMDlZM3g4ZTMwN1pqMWhkMkZwZENoaGQyRnBkQ0JwYlhCdmNuUW9aU2twTG1SbFptRjFiSFFvS1gxbGJITmxJR2xtS0hROVBUMGlSMlYwUVZaVGRISmxZVzBpS1h0amIyNXpkSHRtYVd4bE9tVXNjM1J5WldGdFZIbHdaVHB6TEhOMGNtVmhiVWx1WkdWNE9tRjlQV01zY2oxbUxtZGxkRUZXVTNSeVpXRnRLR1VzY3l4aEtUdHpaV3htTG5CdmMzUk5aWE56WVdkbEtIdDBlWEJsT25Rc2JYTm5TV1E2Ynl4eVpYTjFiSFE2Y24wc1czSXVZMjlrWldOd1lYSXVaWGgwY21Ga1lYUmhMbUoxWm1abGNsMHBmV1ZzYzJVZ2FXWW9kRDA5UFNKSFpYUkJWbE4wY21WaGJYTWlLWHRqYjI1emRIdG1hV3hsT21WOVBXTXNjejFtTG1kbGRFRldVM1J5WldGdGN5aGxLVHR6Wld4bUxuQnZjM1JOWlhOellXZGxLSHQwZVhCbE9uUXNiWE5uU1dRNmJ5eHlaWE4xYkhRNmMzMHNjeTV0WVhBb1lUMCtZUzVqYjJSbFkzQmhjaTVsZUhSeVlXUmhkR0V1WW5WbVptVnlLU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBJaWw3WTI5dWMzUjdabWxzWlRwbExIUnBiV1U2Y3l4emRISmxZVzFVZVhCbE9tRXNjM1J5WldGdFNXNWtaWGc2Y24wOVl5eHVQV1l1WjJWMFFWWlFZV05yWlhRb1pTeHpMR0VzY2lrN2MyVnNaaTV3YjNOMFRXVnpjMkZuWlNoN2RIbHdaVHAwTEcxelowbGtPbThzY21WemRXeDBPbTU5TEZ0dUxtUmhkR0V1WW5WbVptVnlYU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBjeUlwZTJOdmJuTjBlMlpwYkdVNlpTeDBhVzFsT25OOVBXTXNZVDFtTG1kbGRFRldVR0ZqYTJWMGN5aGxMSE1wTzNObGJHWXVjRzl6ZEUxbGMzTmhaMlVvZTNSNWNHVTZkQ3h0YzJkSlpEcHZMSEpsYzNWc2REcGhmU3hoTG0xaGNDaHlQVDV5TG1SaGRHRXVZblZtWm1WeUtTbDlaV3h6WlNCcFppaDBQVDA5SWxKbFlXUkJWbEJoWTJ0bGRDSXBlMk52Ym5OMGUyWnBiR1U2WlN4emRHRnlkRHB6TEdWdVpEcGhMSE4wY21WaGJWUjVjR1U2Y2l4emRISmxZVzFKYm1SbGVEcHVmVDFqTEdROVppNXlaV0ZrUVZaUVlXTnJaWFFvYnl4bExITXNZU3h5TEc0cE8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEhKbGMzVnNkRHBrZlNsOWZXTmhkR05vS0dVcGUzTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEdWeWNrMXpaenBsSUdsdWMzUmhibU5sYjJZZ1JYSnliM0kvWlM1dFpYTnpZV2RsT2lKVmJtdHViM2R1SUVWeWNtOXlJbjBwZlgwcGZTa29LVHNLIixnPXQ9PlVpbnQ4QXJyYXkuZnJvbShhdG9iKHQpLGU9PmUuY2hhckNvZGVBdCgwKSksVj10eXBlb2Ygc2VsZjwidSImJnNlbGYuQmxvYiYmbmV3IEJsb2IoW2coQSldLHt0eXBlOiJ0ZXh0L2phdmFzY3JpcHQ7Y2hhcnNldD11dGYtOCJ9KTtmdW5jdGlvbiBFKHQpe2xldCBlO3RyeXtpZihlPVYmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLmNyZWF0ZU9iamVjdFVSTChWKSwhZSl0aHJvdyIiO2NvbnN0IHM9bmV3IFdvcmtlcihlLHtuYW1lOnQ/Lm5hbWV9KTtyZXR1cm4gcy5hZGRFdmVudExpc3RlbmVyKCJlcnJvciIsKCk9Pnsoc2VsZi5VUkx8fHNlbGYud2Via2l0VVJMKS5yZXZva2VPYmplY3RVUkwoZSl9KSxzfWNhdGNoe3JldHVybiBuZXcgV29ya2VyKCJkYXRhOnRleHQvamF2YXNjcmlwdDtiYXNlNjQsIitBLHtuYW1lOnQ/Lm5hbWV9KX1maW5hbGx5e2UmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLnJldm9rZU9iamVjdFVSTChlKX19Y29uc3QgdT0xZTY7Y2xhc3MgcHtmZm1wZWdXb3JrZXI7ZmZtcGVnV29ya2VyTG9hZFN0YXR1czttc2dJZDtmaWxlO2NvbnN0cnVjdG9yKGUpe3RoaXMuZmZtcGVnV29ya2VyPW5ldyBFLHRoaXMuZmZtcGVnV29ya2VyTG9hZFN0YXR1cz1uZXcgUHJvbWlzZSgocyxhKT0+e3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGk9Pntjb25zdHt0eXBlOnIsZXJyTXNnOmR9PWkuZGF0YTtyPT09by5GRm1wZWdXb3JrZXJMb2FkZWQmJnRoaXMucG9zdChvLkxvYWRXQVNNLHt3YXNtTG9hZGVyUGF0aDplLndhc21Mb2FkZXJQYXRofSkscj09PW8uV0FTTVJ1bnRpbWVJbml0aWFsaXplZCYmcyghMCkscj09PW8uTG9hZFdBU00mJmQmJmEoZCl9KX0pLHRoaXMubXNnSWQ9MH1wb3N0KGUscyxhKXt0aGlzLmZmbXBlZ1dvcmtlci5wb3N0TWVzc2FnZSh7dHlwZTplLG1zZ0lkOmE/P3RoaXMubXNnSWQrKyxkYXRhOnN9KX1hc3luYyBsb2FkKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5mZm1wZWdXb3JrZXJMb2FkU3RhdHVzO3JldHVybiB0aGlzLmZpbGU9ZSxzfWRlc3Ryb3koKXt0aGlzLmZpbGU9dm9pZCAwLHRoaXMuZmZtcGVnV29ya2VyLnRlcm1pbmF0ZSgpfWdldEFWU3RyZWFtKGU9bS5BVk1FRElBX1RZUEVfVklERU8scz0tMSl7cmV0dXJuIG5ldyBQcm9taXNlKChhLGkpPT57aWYoIXRoaXMuZmlsZSl7aSgiZmlsZSBpcyBub3QgbG9hZGVkIik7cmV0dXJufWNvbnN0IHI9dGhpcy5tc2dJZCxkPSh7ZGF0YTpufSk9PntuLnR5cGU9PT1vLkdldEFWU3RyZWFtJiZuLm1zZ0lkPT09ciYmKG4uZXJyTXNnP2kobi5lcnJNc2cpOmEobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGQpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZCksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW0se2ZpbGU6dGhpcy5maWxlLHN0cmVhbVR5cGU6ZSxzdHJlYW1JbmRleDpzfSl9KX1nZXRBVlN0cmVhbXMoKXtyZXR1cm4gbmV3IFByb21pc2UoKGUscyk9PntpZighdGhpcy5maWxlKXtzKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgYT10aGlzLm1zZ0lkLGk9KHtkYXRhOnJ9KT0+e3IudHlwZT09PW8uR2V0QVZTdHJlYW1zJiZyLm1zZ0lkPT09YSYmKHIuZXJyTXNnP3Moci5lcnJNc2cpOmUoci5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsaSksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW1zLHtmaWxlOnRoaXMuZmlsZX0pfSl9Z2V0QVZQYWNrZXQoZSxzPW0uQVZNRURJQV9UWVBFX1ZJREVPLGE9LTEpe3JldHVybiBuZXcgUHJvbWlzZSgoaSxyKT0+e2lmKCF0aGlzLmZpbGUpe3IoImZpbGUgaXMgbm90IGxvYWRlZCIpO3JldHVybn1jb25zdCBkPXRoaXMubXNnSWQsbj1oPT57Y29uc3QgbD1oLmRhdGE7bC50eXBlPT09by5HZXRBVlBhY2tldCYmbC5tc2dJZD09PWQmJihsLmVyck1zZz9yKGwuZXJyTXNnKTppKGwucmVzdWx0KSx0aGlzLmZmbXBlZ1dvcmtlci5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixuKSl9O3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLG4pLHRoaXMucG9zdChvLkdldEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSx0aW1lOmUsc3RyZWFtVHlwZTpzLHN0cmVhbUluZGV4OmF9KX0pfWdldEFWUGFja2V0cyhlKXtyZXR1cm4gbmV3IFByb21pc2UoKHMsYSk9PntpZighdGhpcy5maWxlKXthKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgaT10aGlzLm1zZ0lkLHI9ZD0+e2NvbnN0IG49ZC5kYXRhO24udHlwZT09PW8uR2V0QVZQYWNrZXRzJiZuLm1zZ0lkPT09aSYmKG4uZXJyTXNnP2Eobi5lcnJNc2cpOnMobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLHIpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsciksdGhpcy5wb3N0KG8uR2V0QVZQYWNrZXRzLHtmaWxlOnRoaXMuZmlsZSx0aW1lOmV9KX0pfXJlYWRBVlBhY2tldChlPTAscz0wLGE9bS5BVk1FRElBX1RZUEVfVklERU8saT0tMSl7Y29uc3Qgcj1uZXcgQ291bnRRdWV1aW5nU3RyYXRlZ3koe2hpZ2hXYXRlck1hcms6MX0pLGQ9dGhpcy5tc2dJZDtsZXQgbj0wO3JldHVybiBuZXcgUmVhZGFibGVTdHJlYW0oe3N0YXJ0Omg9PntpZighdGhpcy5maWxlKXtoLmVycm9yKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgbD1mPT57Y29uc3QgYz1mLmRhdGE7Yy50eXBlPT09by5SZWFkQVZQYWNrZXQmJmMubXNnSWQ9PT1kJiZjLmVyck1zZyYmKGguZXJyb3IoYy5lcnJNc2cpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGwpKSxjLnR5cGU9PT1vLkFWUGFja2V0U3RyZWFtJiZjLm1zZ0lkPT09ZCYmKGMucmVzdWx0P2guZW5xdWV1ZShjLnJlc3VsdCk6aC5jbG9zZSgpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsbCksdGhpcy5wb3N0KG8uUmVhZEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSxzdGFydDplLGVuZDpzLHN0cmVhbVR5cGU6YSxzdHJlYW1JbmRleDppfSl9LHB1bGw6KCk9PntuPjAmJnRoaXMucG9zdChvLlJlYWROZXh0QVZQYWNrZXQsdm9pZCAwLGQpLG4rK30sY2FuY2VsOigpPT57dGhpcy5wb3N0KG8uU3RvcFJlYWRBVlBhY2tldCx2b2lkIDAsZCl9fSxyKX1nZXRWaWRlb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9WSURFTyxlKX1nZXRBdWRpb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9BVURJTyxlKX1zZWVrVmlkZW9QYWNrZXQoZSl7cmV0dXJuIHRoaXMuZ2V0QVZQYWNrZXQoZSxtLkFWTUVESUFfVFlQRV9WSURFTyl9c2Vla0F1ZGlvUGFja2V0KGUpe3JldHVybiB0aGlzLmdldEFWUGFja2V0KGUsbS5BVk1FRElBX1RZUEVfQVVESU8pfXJlYWRWaWRlb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfVklERU8pfXJlYWRBdWRpb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfQVVESU8pfWdlblZpZGVvRGVjb2RlckNvbmZpZyhlKXtyZXR1cm57Y29kZWM6ZS5jb2RlY3Bhci5jb2RlY19zdHJpbmcsY29kZWRXaWR0aDplLmNvZGVjcGFyLndpZHRoLGNvZGVkSGVpZ2h0OmUuY29kZWNwYXIuaGVpZ2h0LGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRWaWRlb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZFZpZGVvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1nZW5BdWRpb0RlY29kZXJDb25maWcoZSl7cmV0dXJue2NvZGVjOmUuY29kZWNwYXIuY29kZWNfc3RyaW5nfHwiIixzYW1wbGVSYXRlOmUuY29kZWNwYXIuc2FtcGxlX3JhdGUsbnVtYmVyT2ZDaGFubmVsczplLmNvZGVjcGFyLmNoYW5uZWxzLGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRBdWRpb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZEF1ZGlvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1hc3luYyBnZXRWaWRlb0RlY29kZXJDb25maWcoKXtjb25zdCBlPWF3YWl0IHRoaXMuZ2V0VmlkZW9TdHJlYW0oKTtyZXR1cm4gdGhpcy5nZW5WaWRlb0RlY29kZXJDb25maWcoZSl9YXN5bmMgc2Vla0VuY29kZWRWaWRlb0NodW5rKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5zZWVrVmlkZW9QYWNrZXQoZSk7cmV0dXJuIHRoaXMuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsocyl9YXN5bmMgZ2V0QXVkaW9EZWNvZGVyQ29uZmlnKCl7Y29uc3QgZT1hd2FpdCB0aGlzLmdldEF1ZGlvU3RyZWFtKCk7cmV0dXJuIHRoaXMuZ2VuQXVkaW9EZWNvZGVyQ29uZmlnKGUpfWFzeW5jIHNlZWtFbmNvZGVkQXVkaW9DaHVuayhlKXtjb25zdCBzPWF3YWl0IHRoaXMuc2Vla0F1ZGlvUGFja2V0KGUpO3JldHVybiB0aGlzLmdlbkVuY29kZWRBdWRpb0NodW5rKHMpfX1jbGFzcyBre3ZpZGVvO2N1cnJlbnRGcmFtZXM9MDt0b3RhbEZyYW1lcztjdXJyZW50VGltZTtmcHM7Zmlyc3RUaW1lc3RhbXA7Y29uc3RydWN0b3IoZSxzKXt0aGlzLmN1cnJlbnRUaW1lPWVbMF0qMWU2LHRoaXMuZmlyc3RUaW1lc3RhbXA9ZVswXSoxZTYsdGhpcy50b3RhbEZyYW1lcz0oZVsxXS1lWzBdKSpzKzEsdGhpcy5mcHM9cyx0aGlzLnZpZGVvPW5ldyBWaWRlb0RlY29kZXIoe291dHB1dDp0aGlzLmhhbmRsZUZyYW1lT3V0cHV0LmJpbmQodGhpcyksZXJyb3I6dGhpcy5oYW5kbGVFcnJvci5iaW5kKHRoaXMpfSl9cG9zdEZyYW1lKGUpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImZyYW1lIixmcmFtZTplfSksdGhpcy5jdXJyZW50VGltZSs9TWF0aC5mbG9vcigxL3RoaXMuZnBzKjFlNiksdGhpcy5jdXJyZW50RnJhbWVzKz0xfWhhbmRsZUZyYW1lT3V0cHV0KGUpe2NvbnN0IHM9ZS50aW1lc3RhbXAsYT1lLmR1cmF0aW9uPz8wLGk9cythO2lmKCF0aGlzLmlzRnJhbWVJblJhbmdlKHMpKXtlLmNsb3NlKCk7cmV0dXJufWZvcig7aT50aGlzLmN1cnJlbnRUaW1lJiZ0aGlzLmN1cnJlbnRGcmFtZXM8PXRoaXMudG90YWxGcmFtZXM7KXRoaXMucG9zdEZyYW1lKGUpO2UuY2xvc2UoKX1pc0ZyYW1lSW5SYW5nZShlKXtyZXR1cm4gZT49dGhpcy5maXJzdFRpbWVzdGFtcH1oYW5kbGVFcnJvcihlKXtjb25zb2xlLmVycm9yKCJlcnJvciBpbiB3b3JrZXIiLGUpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOmUubWVzc2FnZT8/IkFuIHVua25vd24gd29ya2VyIGVycm9yIG9jY3VycmVkIn0pLHNlbGYuY2xvc2UoKX19ZnVuY3Rpb24gSSh0KXtyZXR1cm4gYXN5bmMgZT0+e3RyeXthd2FpdCB0KGUpfWNhdGNoKHMpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOnM/Lm1lc3NhZ2U/PyJBbiB1bmtvd24gd29ya2VyIGVycm9yIG9jY3VyZWQifSl9fX1mdW5jdGlvbiBXKHQpe3JldHVybiB0LmNvZGVjPT0idnAwOSImJih0LmNvZGVjPSJ2cDA5LjAwLjEwLjA4IiksdH1jb25zdCBaPTMwO2FzeW5jIGZ1bmN0aW9uIFAodCl7aWYodC5kYXRhPy50eXBlIT0iaW5pdCIpcmV0dXJuO2NvbnN0e2ZpbGU6ZSxyYW5nZTpzLGZwczphfT10LmRhdGEsaT1uZXcgcCh7d2FzbUxvYWRlclBhdGg6Imh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vQGRpZmZ1c2lvbnN0dWRpby9mZm1wZWctd2FzbUAxLjAuMC9kaXN0L2ZmbXBlZy5qcyJ9KTthd2FpdCBpLmxvYWQoZSk7Y29uc3Qgcj1hd2FpdCBpLmdldFZpZGVvRGVjb2RlckNvbmZpZygpO1cocik7Y29uc3QgZD1uZXcgayhzLGEpO2QudmlkZW8uY29uZmlndXJlKHIpO2NvbnN0IG49aS5yZWFkQVZQYWNrZXQoc1swXSxzWzFdKS5nZXRSZWFkZXIoKTtuLnJlYWQoKS50aGVuKGFzeW5jIGZ1bmN0aW9uIGgoe2RvbmU6bCx2YWx1ZTpmfSl7aWYobCl7YXdhaXQgZC52aWRlby5mbHVzaCgpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImRvbmUifSksc2VsZi5jbG9zZSgpO3JldHVybn1jb25zdCBjPWkuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsoZik7cmV0dXJuIGQudmlkZW8uZGVjb2RlUXVldWVTaXplPlomJmF3YWl0IG5ldyBQcm9taXNlKEw9PntkLnZpZGVvLm9uZGVxdWV1ZT0oKT0+TCgpfSksYy50aW1lc3RhbXA8PXNbMV0qMWU2JiZkLnZpZGVvLmRlY29kZShjKSxuLnJlYWQoKS50aGVuKGgpfSl9c2VsZi5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixJKFApKX0pKCk7Cg==",Xh=n=>Uint8Array.from(atob(n),o=>o.charCodeAt(0)),As=typeof self<"u"&&self.Blob&&new Blob([Xh(sc)],{type:"text/javascript;charset=utf-8"});function Zh(n){let o;try{if(o=As&&(self.URL||self.webkitURL).createObjectURL(As),!o)throw"";const t=new Worker(o,{name:n==null?void 0:n.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(o)}),t}catch{return new Worker("data:text/javascript;base64,"+sc,{name:n==null?void 0:n.name})}finally{o&&(self.URL||self.webkitURL).revokeObjectURL(o)}}class Yh{constructor(){U(this,"frames",[]);U(this,"state","active");U(this,"onenqueue");U(this,"onclose")}enqueue(o){var t;this.frames.unshift(o),(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 o;this.state="closed",(o=this.onclose)==null||o.call(this)}terminate(){for(const o of this.frames)o.close()}async waitFor(o){await new Promise((t,a)=>{const r=setTimeout(()=>{a(`Promise timed out after ${o} ms`)},o);this.onenqueue=()=>{clearTimeout(r),t()},this.onclose=()=>{clearTimeout(r),t()}})}}function Gh(n,o,t){const a=t.value;return t.value=function(...r){var i,s,l,c;return(s=(i=this.track)==null?void 0:i.composition)!=null&&s.rendering&&this.sprite.texture.source.uid!=this.textrues.canvas.source.uid&&(this.sprite.texture=this.textrues.canvas),!((c=(l=this.track)==null?void 0:l.composition)!=null&&c.rendering)&&this.sprite.texture.source.uid!=this.textrues.html5.source.uid&&(this.sprite.texture=this.textrues.html5),a.apply(this,r)},t}var Hh=Object.defineProperty,Jh=Object.getOwnPropertyDescriptor,qh=(n,o,t,a)=>{for(var r=Jh(o,t),i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&Hh(o,t,r),r};const lc=class cc extends Fa(Ma){constructor(t,a={}){super();U(this,"source",new bn);U(this,"type","video");U(this,"worker");U(this,"buffer");U(this,"canvas",document.createElement("canvas"));U(this,"context",this.canvas.getContext("2d"));U(this,"element",document.createElement("video"));U(this,"textrues",{html5:Oe.Texture.from(this.element),canvas:Oe.Texture.from(this.canvas)});U(this,"sprite",new Oe.Sprite);this.element.controls=!1,this.element.playsInline=!0,this.element.style.display="hidden",this.element.crossOrigin="anonymous",this.textrues.html5.source.autoPlay=!1,this.textrues.html5.source.loop=!1,this.sprite.texture=this.textrues.html5,this.view.addChild(this.sprite),t instanceof bn&&(this.source=t),t instanceof File&&this.source.from(t),this.element.addEventListener("play",()=>{this.playing=!0}),this.element.addEventListener("pause",()=>{this.playing=!1}),Object.assign(this,a)}async init(){const t=await this.source.createObjectURL();this.element.setAttribute("src",t),await new Promise((a,r)=>{this.element.oncanplay=()=>{this.duration.seconds=this.element.duration,this.state="READY",a()},this.element.onerror=()=>{this.state="ERROR";const i=new Qt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."});r(this.element.error??i)}})}async connect(t){var r;super.connect(t);const a=((r=t.composition)==null?void 0:r.frame)??0;await this.seek(ve.fromFrames(a))}enter(){var t,a,r;super.enter(),(a=(t=this.track)==null?void 0:t.composition)!=null&&a.rendering&&((r=this.buffer)==null?void 0:r.state)!="active"&&this.decodeVideo()}update(t){var a,r,i,s,l,c;if((r=(a=this.track)==null?void 0:a.composition)!=null&&r.playing&&!this.playing)this.element.play();else if(!((s=(i=this.track)==null?void 0:i.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=cc.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}async decodeVideo(){var t,a;return this.buffer=new Yh,this.worker=new Zh,this.worker.addEventListener("message",r=>{var i,s;r.data.type=="frame"?(i=this.buffer)==null||i.enqueue(r.data.frame):r.data.type=="error"?this.cancelDecoding():r.data.type=="done"&&((s=this.buffer)==null||s.close())}),this.worker.postMessage({type:"init",file:await this.source.getFile(),range:this.demuxRange,fps:((a=(t=this.track)==null?void 0:t.composition)==null?void 0:a.fps)??ko}),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 i;const t=(i=this.track)==null?void 0:i.composition;let a;this.start.millis<0?a=Math.abs(this.offset.seconds):a=this.range[0].seconds;let r;return t&&this.stop.millis>t.duration.millis?r=t.duration.subtract(this.offset).seconds:r=this.range[1].seconds,[a,r]}cancelDecoding(){var t,a;(t=this.worker)==null||t.terminate(),this.worker=void 0,(a=this.buffer)==null||a.terminate(),this.buffer=void 0}};qh([Ia,Gh],lc.prototype,"update");let Dr=lc;class ka extends Ma{constructor(t,a={}){super();U(this,"type","audio");U(this,"source",new cn);U(this,"element",new Audio);t instanceof cn&&(this.source=t),t instanceof File&&this.source.from(t),this.element.addEventListener("play",()=>{this.playing=!0}),this.element.addEventListener("pause",()=>{this.playing=!1}),Object.assign(this,a)}async init(){const t=await this.source.createObjectURL();this.element.setAttribute("src",t),this.element.load(),await new Promise((a,r)=>{this.element.oncanplay=()=>{this.duration.seconds=this.element.duration,this.state="READY",a()},this.element.onerror=()=>{this.state="ERROR";const i=new Qt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."});r(this.element.error??i)}})}update(){var t,a,r,i,s,l;if((a=(t=this.track)==null?void 0:t.composition)!=null&&a.rendering)return this.exit();(i=(r=this.track)==null?void 0:r.composition)!=null&&i.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=ka.fromJSON(JSON.parse(JSON.stringify(this)));return t.source=this.source,t}}const Kh={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 Ur(n){if(!Object.keys(Kh.MIXED).includes(n??""))throw new He({message:`${n} is not an accepted mime type`,code:"invalid_mimetype"});return n}var Qh=Object.defineProperty,e0=Object.getOwnPropertyDescriptor,t0=(n,o,t,a)=>{for(var r=e0(o,t),i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&Qh(o,t,r),r};const n0=class dc extends Fa(No){constructor(t,a={}){super();U(this,"type","html");U(this,"source",new Ps);U(this,"element",new Image);U(this,"canvas",document.createElement("canvas"));U(this,"context",this.canvas.getContext("2d"));U(this,"sprite",new Oe.Sprite);this.view.addChild(this.sprite),Object.assign(this,a),t instanceof Ps&&(this.source=t),t instanceof File&&this.source.from(t),this.element.addEventListener("load",()=>{var s,l,c,d;const r=(l=(s=this.source.document)==null?void 0:s.body)==null?void 0:l.scrollWidth,i=(d=(c=this.source.document)==null?void 0:c.body)==null?void 0:d.scrollHeight;!r||!i||(this.canvas.width=r,this.canvas.height=i,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=Oe.Texture.from(this.canvas,!0),this.trigger("load",void 0))}),this.element.addEventListener("error",r=>{this.state="ERROR",this.trigger("error",new Qt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."})),this.track&&this.detach()}),this.on("update",async()=>{this.source.update(),this.element.setAttribute("src",await this.source.createObjectURL())})}async init(){this.element.setAttribute("src",await this.source.createObjectURL()),await new Promise((t,a)=>{this.element.onload=()=>{var s,l,c,d;const r=(l=(s=this.source.document)==null?void 0:s.body)==null?void 0:l.scrollWidth,i=(d=(c=this.source.document)==null?void 0:c.body)==null?void 0:d.scrollHeight;if(!r||!i)return a(new Qt({code:"sourceNotProcessable",message:"Cannot display source with height or width at 0"}));this.state="READY",t()},this.element.onerror=r=>{a(new Qt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=dc.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};t0([Ia],n0.prototype,"update");const uc=["DEFAULT","STACK"];class Ds{constructor(){U(this,"mode",uc[0]);U(this,"pauseAlignmet",!1)}add(o,t){let a=!0;for(let r=0;r<t.clips.length&&(a=Ls(o,t.clips[r]),!!a);r++)Os(o,t.clips[r]);a&&(t.clips.push(o),t.clips.sort(Us))}update(o,t){if(!this.pauseAlignmet){t.clips.sort(Us);for(let a=0;a<t.clips.length;a++)if(o.id!=t.clips[a].id){if(!Ls(o,t.clips[a]))break;Os(o,t.clips[a])}}}offset(o,t){this.pauseAlignmet=!0;for(const a of t.clips)a.offsetBy(o);this.pauseAlignmet=!1}}class o0{constructor(){U(this,"mode",uc[1])}add(o,t,a=void 0){var i;let r=-1;(a!=null&&a>0||a==null)&&(r=((i=t.clips.at((a??0)-1))==null?void 0:i.stop.millis)??-1),o.offsetBy(new ve(r-o.start.millis+1)),a==null?t.clips.push(o):(t.clips.splice(a,0,o),t.clips.slice(a+1).forEach(s=>{s.offsetBy(o.stop.subtract(o.start))}))}update(o,t){let a=0;for(const r of t.clips){if(r.start.millis!=a){const i=a-r.start.millis;r.offsetBy(new ve(i))}a=r.stop.millis+1}}offset(){}}function Us(n,o){return n.start.millis-o.start.millis}function Os(n,o){n.start.millis>=o.start.millis&&n.start.millis<=o.stop.millis&&(n.start=o.stop.copy().addMillis(1)),n.stop.millis>=o.start.millis&&n.stop.millis<=o.stop.millis&&(n.stop=o.start.copy().addMillis(-1))}function Ls(n,o){var t,a,r,i,s;if(n.start.millis>=o.start.millis&&n.stop.millis<=o.stop.millis){const l=(a=(t=o.track)==null?void 0:t.composition)==null?void 0:a.tracks.find(c=>c.type==n.type&&!c.clips.some(d=>n.id!=d.id&&n.start.millis>=d.start.millis&&n.stop.millis<=d.stop.millis));return l?(l.add(n.detach()),!1):((s=(i=(r=o.track)==null?void 0:r.composition)==null?void 0:i.createTrack(n.type))==null||s.add(n.detach()),!1)}return!0}class Zn extends Vo(_t){constructor(){super(...arguments);U(this,"_disabled",!1);U(this,"view",new Oe.Container);U(this,"clips",[]);U(this,"pointer",0);U(this,"composition");U(this,"type","base");U(this,"strategy",new Ds)}get disabled(){return this._disabled}set disabled(t){var a;t&&this.clipRef&&br(this.clipRef)&&(this.view.removeChild(this.clipRef.view),(a=this.clipRef)==null||a.exit()),this._disabled=t,this.trigger("update",void 0)}connect(t){this.composition=t}stacked(t=!0){return t?(this.strategy=new o0,this.strategy.update(new No,this)):this.strategy=new Ds,this.trigger("update",void 0),this}layer(t){var l,c;const a=((l=this.composition)==null?void 0:l.tracks)??[],r=a.findIndex(d=>d.id==this.id),i=a.length-1;if(r==-1)return this;let s=0;return t=="bottom"?s=i:t=="top"||t<0?s=0:t>i?s=i:s=t,mh(a,r,s),(c=this.composition)==null||c.stage.setChildIndex(this.view,i-s),this.trigger("update",void 0),this}seek(t){}offsetBy(t){return typeof t=="number"?this.strategy.offset(ve.fromFrames(t),this):this.strategy.offset(t,this),this}update(t){var r,i;if(this.disabled||!this.clips.length)return;const{millis:a}=t;if(br(this.clipRef)&&(!yr(a,this.clipRef)||(r=this.clipRef)!=null&&r.disabled)&&(this.clipRef&&this.view.removeChild(this.clipRef.view),(i=this.clipRef)==null||i.exit()),!!yr(a,this))for(let s=0;s<this.clips.length;s++){const l=(this.pointer+s)%this.clips.length,c=this.clips[l],d=this.clips[l-1];if(yr(a,c)&&!c.disabled)return this.pointer=l,br(c)||(c.enter(),this.view.addChild(c.view)),c.update(t);if(a<c.start.millis&&a>((d==null?void 0:d.stop.millis)??0)){this.pointer=l;return}}}async add(t,a){return this.composition&&!this.composition.renderer&&await new Promise(this.composition.resolve("init")),await t.init(),await t.connect(this),await this.strategy.add(t,this,a),t.on("frame",()=>{this.strategy.update(t,this)}),t.bubble(this),this.trigger("attach",void 0),t}remove(t){const a=this.clips.findIndex(r=>r.id==t.id);if(t.state=="ATTACHED"&&(t.state="READY"),t.view.parent&&this.view.removeChild(t.view),a!=null&&a>=0)return this.clips.splice(a,1),this.strategy.update(t,this),this.trigger("detach",void 0),t.off("*"),t}get stop(){var t;return((t=this.clips.at(-1))==null?void 0:t.stop)??new ve}get start(){var t;return((t=this.clips.at(0))==null?void 0:t.start)??new ve}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 yr(n,o){return o?n>=o.start.millis&&n<=o.stop.millis:!1}function br(n){return n?!!n.view.parent:!1}class a0{static fromType(o){switch(o.type){case"video":return new r0;case"audio":return new s0;case"html":return new l0;case"image":return new i0;case"text":return new Ws;case"complex_text":return new Ws;case"caption":return new d0;default:return new Zn}}}class mc extends Zn{constructor(){super(...arguments);U(this,"clips",[])}async seek(t){for(const a of this.clips)await a.seek(t)}async removeSilences(t={}){const a=[];for(const r of this.clips.map(i=>i.detach()))a.push(...await r.removeSilences(t));for(const r of a)await this.add(r)}}class r0 extends mc{constructor(){super(...arguments);U(this,"type","video")}async seek(t){var a;(a=this.composition)!=null&&a.rendering?this.view.removeChildren():super.seek(t)}}class i0 extends Zn{constructor(){super(...arguments);U(this,"type","image")}}class s0 extends mc{constructor(){super(...arguments);U(this,"type","audio")}}class Ws extends Zn{constructor(){super(...arguments);U(this,"type","text")}}class l0 extends Zn{constructor(){super(...arguments);U(this,"type","html")}}var c0=Object.defineProperty,di=(n,o,t,a)=>{for(var r=void 0,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&c0(o,t,r),r};class To extends _t{constructor(t={}){super();U(this,"generatorOptions");U(this,"type","CLASSIC");U(this,"position");this.generatorOptions=t.generatorOptions??{duration:[.2]},this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var i,s,l;if(!((i=t.clip)!=null&&i.transcript)||!((s=t.composition)!=null&&s.width))throw new He({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new ve,r=await st.fromFamily({family:"Figtree",weight:"700"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))await t.add(new jn({text:c.words.map(d=>d.text).join(" "),textAlign:"center",textBaseline:"middle",fontSize:21,fillStyle:"#FFFFFF",font:r,stroke:{color:"#000000",width:4,join:"round"},maxWidth:t.composition.width*.85,shadow:{color:"#000000",blur:0,distance:1.1,angle:Math.PI*.4,alpha:1},position:this.position,stop:c.stop.add(a),start:c.start.add(a),scale:new Se([0,8],[.96,1],{easing:"easeOut"}),alpha:new Se([0,4],[0,1],{easing:"easeOut"})}))}}di([fe()],To.prototype,"generatorOptions");di([fe()],To.prototype,"type");di([fe()],To.prototype,"position");class d0 extends Zn{constructor(){super(...arguments);U(this,"clip");U(this,"type","caption");U(this,"preset",new To)}from(t){var a;return this.clip=t,(a=this.clip)==null||a.on("offsetBy",r=>this.offsetBy(r.detail)),this}async generate(t){let a=this.preset;return typeof t=="object"?a=t:t&&(a=new t),this.clips=[],this.trigger("update",void 0),this.preset=a,await a.applyTo(this),this.trigger("update",void 0),this}}var u0=Object.defineProperty,Pa=(n,o,t,a)=>{for(var r=void 0,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&u0(o,t,r),r};class Mo extends _t{constructor(t={}){super();U(this,"generatorOptions");U(this,"type","SPOTLIGHT");U(this,"color");U(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 i,s,l;if(!((i=t.clip)!=null&&i.transcript)||!((s=t.composition)!=null&&s.width))throw new He({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new ve,r=await st.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(p=>p.text);await t.add(new Ra({text:u.join(" "),textAlign:"center",textBaseline:"middle",fillStyle:"#FFFFFF",fontSize:22,maxWidth:t.composition.width*.8,font:r,stroke:{width:5,color:"#000000"},shadow:{color:"#000000",blur:12,alpha:.7,angle:Math.PI/4,distance:2},position:this.position,styles:[{fillStyle:this.color}],segments:c.words.length>1?[{index:0,start:u.slice(0,d).join(" ").length,stop:u.slice(0,d+1).join(" ").length}]:void 0,stop:c.words[d].stop.add(a),start:c.words[d].start.add(a)}))}}}Pa([fe()],Mo.prototype,"generatorOptions");Pa([fe()],Mo.prototype,"type");Pa([fe()],Mo.prototype,"color");Pa([fe()],Mo.prototype,"position");var m0=Object.defineProperty,ui=(n,o,t,a)=>{for(var r=void 0,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&m0(o,t,r),r};class $a extends _t{constructor(t={}){super();U(this,"type","GUINEA");U(this,"colors");U(this,"position");this.colors=t.colors??["#1BD724","#FFEE0C","#FF2E17"],this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var i,s,l,c,d,u,p;if(!((i=t.clip)!=null&&i.transcript)||!((s=t.composition)!=null&&s.width))throw new He({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new ve,r=await st.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const m of t.clip.transcript.iter({length:[18]})){const{segments:f,words:v}=this.splitSequence(m);for(let b=0;b<m.words.length;b++){const S=(d=(c=v[b])==null?void 0:c.at(0))==null?void 0:d.start,M=(p=(u=v[b])==null?void 0:u.at(-1))==null?void 0:p.stop;!S||!M||await t.add(new Ra({text:f.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:r,textCase:"upper",position:this.position,stop:M.add(a),start:S.add(a),styles:[{fillStyle:this.colors[0],fontSize:23},{fillStyle:this.colors[1],fontSize:23},{fillStyle:this.colors[2],fontSize:23}],segments:[{index:sa(0,2),start:f.slice(0,b).join(" ").length,stop:f.slice(0,b+1).join(" ").length+b*2}]}))}}}splitSequence(t){const a=t.text,r=Math.ceil(a.length/2);let i=a.length;for(let c=r,d=r;c>0&&d<t.text.length-1;c--,d++){if(a[c].match(/ /)){i=c;break}if(a[d].match(/ /)){i=d;break}}const s=[..._s(a,i).map(c=>c.trim())],l=_s(t.words,s[0].split(/ /).length);return{segments:s,words:l}}}ui([fe()],$a.prototype,"type");ui([fe()],$a.prototype,"colors");ui([fe()],$a.prototype,"position");var p0=Object.defineProperty,mi=(n,o,t,a)=>{for(var r=void 0,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&p0(o,t,r),r};class za extends _t{constructor(t={}){super();U(this,"generatorOptions");U(this,"type","CASCADE");U(this,"position");this.generatorOptions=t.generatorOptions??{duration:[1.4]},this.position=t.position??{x:"12%",y:"44%"}}async applyTo(t){var i,s,l;if(!((i=t.clip)!=null&&i.transcript)||!((s=t.composition)!=null&&s.width))throw new He({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new ve,r=await st.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(p=>p.text).slice(0,d+1).join(" ");await t.add(new jn({text:u(),textAlign:"left",textBaseline:"top",fillStyle:"#FFFFFF",fontSize:16,font:r,maxWidth:t.composition.width*.7,stroke:{color:"#000000",width:4,join:"round"},shadow:{color:"#000000",blur:8,alpha:.4,angle:Math.PI/4,distance:2},position:this.position,stop:c.words[d].stop.add(a),start:c.words[d].start.add(a)}))}}}mi([fe()],za.prototype,"generatorOptions");mi([fe()],za.prototype,"type");mi([fe()],za.prototype,"position");var f0=Object.defineProperty,pi=(n,o,t,a)=>{for(var r=void 0,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&f0(o,t,r),r};class Aa extends _t{constructor(t={}){super();U(this,"generatorOptions");U(this,"type","SOLAR");U(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 He({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=await st.fromFamily({family:"Urbanist",weight:"800"}).load(),r=((c=t.clip)==null?void 0:c.offset)??new ve,i=new yl.GlowFilter({color:"#fffe41",alpha:.25,distance:90,quality:.05});for(const d of t.clip.transcript.iter(this.generatorOptions))await t.add(new jn({text:d.words.map(u=>u.text).join(" "),textAlign:"center",textBaseline:"middle",fontSize:19,fillStyle:"#fffe41",font:a,maxWidth:t.composition.width*.85,textCase:"upper",shadow:{color:"#ab7a00",blur:0,distance:2.1,angle:Math.PI/2.5,alpha:1},position:this.position,stop:d.stop.add(r),start:d.start.add(r),scale:new Se([0,8],[.96,1],{easing:"easeOut"}),alpha:new Se([0,4],[0,1],{easing:"easeOut"}),filters:i}))}}pi([fe()],Aa.prototype,"generatorOptions");pi([fe()],Aa.prototype,"type");pi([fe()],Aa.prototype,"position");var h0=Object.defineProperty,Da=(n,o,t,a)=>{for(var r=void 0,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&h0(o,t,r),r};class Fo extends _t{constructor(t={}){super();U(this,"generatorOptions");U(this,"type","WHISPER");U(this,"color");U(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 i,s,l;if(!((i=t.clip)!=null&&i.transcript)||!((s=t.composition)!=null&&s.width))throw new He({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new ve,r=await st.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(p=>p.text);await t.add(new Ra({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:r,position:this.position,styles:[{fillStyle:this.color}],stop:c.words[d].stop.add(a),start:c.words[d].start.add(a),segments:u.length>1?[{index:0,start:u.slice(0,d+1).join(" ").length}]:void 0}))}}}Da([fe()],Fo.prototype,"generatorOptions");Da([fe()],Fo.prototype,"type");Da([fe()],Fo.prototype,"color");Da([fe()],Fo.prototype,"position");var v0=Object.defineProperty,Ua=(n,o,t,a)=>{for(var r=void 0,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&v0(o,t,r),r};class Oa extends _t{constructor(t={}){super();U(this,"type","VERDANT");U(this,"generatorOptions");U(this,"color");U(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 i,s,l;if(!((i=t.clip)!=null&&i.transcript)||!((s=t.composition)!=null&&s.width))throw new He({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new ve,r=await st.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(p=>p.text);await t.add(new Ra({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:r,textCase:"upper",styles:[{fillStyle:this.color,fontSize:19}],position:this.position,stop:c.words[d].stop.add(a),start:c.words[d].start.add(a),segments:[{index:0,start:u.slice(0,d).join(" ").length,stop:u.slice(0,d+1).join(" ").length}]}))}}}Ua([fe()],Oa.prototype,"type");Ua([fe()],Oa.prototype,"generatorOptions");Ua([fe()],Oa.prototype,"color");Ua([fe()],Oa.prototype,"position");class g0 extends Vo(_t){constructor({height:t=1080,width:a=1920,background:r="#000000",backend:i="webgpu"}={}){super();U(this,"_duration",new ve);U(this,"renderer");U(this,"stage",new Oe.Container);U(this,"settings");U(this,"tracks",[]);U(this,"frame",0);U(this,"fixedDuration");U(this,"state","IDLE");U(this,"fps",ko);U(this,"canvas");U(this,"context");this.settings={height:t,width:a,background:r,backend:i},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)),Oe.autoDetectRenderer({...this.settings,preference:i}).then(s=>{this.renderer=s,this.trigger("init",void 0)}).catch(s=>{this.trigger("error",new Ln({code:"backendDetectionError",message:`${s}`}))})}get playing(){return this.state=="PLAY"}get rendering(){return this.state=="RENDER"}get width(){return this.settings.width}get height(){return this.settings.height}get duration(){return this.fixedDuration?this.fixedDuration:this._duration}set duration(t){var a;t?t instanceof ve?this.fixedDuration=t:this.fixedDuration=ve.fromFrames(t):this.fixedDuration=void 0,this.trigger("frame",((a=this.fixedDuration)==null?void 0:a.frames)??0)}resize(t,a){var r;this.settings.width=t,this.settings.height=a,(r=this.renderer)==null||r.resize(t,a),this.canvas&&(this.canvas.height=a,this.canvas.width=t),this.trigger("resize",void 0),this.computeFrame()}attachPlayer(t){this.canvas||(this.canvas=document.createElement("canvas"),this.canvas.height=this.settings.height,this.canvas.width=this.settings.width,this.canvas.style.background="black",this.context=this.canvas.getContext("2d"),this.context.imageSmoothingEnabled=!1,this.computeFrame()),t.appendChild(this.canvas)}detachPlayer(t){this.canvas&&t.removeChild(this.canvas)}shiftTrack(t){const a=typeof t=="object"?t:new t;return a.connect(this),this.stage.addChild(a.view),this.tracks.unshift(a),a.bubble(this),this.trigger("update",void 0),a}createTrack(t){const a=a0.fromType({type:t});return this.shiftTrack(a),a}async add(t){return await this.createTrack(t.type).add(t),t}remove(t){for(const a of this.tracks)if(a.clips.find(r=>r.id==t.id))return a.remove(t)}removeTracks(t){const a=this.tracks.filter(r=>r instanceof t);return this.tracks=this.tracks.filter(r=>!(r instanceof t)),a.forEach(r=>this.removeTrack(r)),a}findTracks(t){return this.tracks.filter(a=>{let r;return Ts(t)?r=a instanceof t:r=t(a),r})}findClips(t){const a=[];for(const r of this.tracks)for(const i of r.clips){let s;Ts(t)?s=i instanceof t:s=t(i),s&&a.push(i)}return a}computeFrame(){var t,a;if(this.renderer){for(let r=0;r<this.tracks.length;r++)this.tracks[r].update(ve.fromFrames(this.frame));this.renderer.render(this.stage),(t=this.context)==null||t.clearRect(0,0,this.settings.width,this.settings.height),(a=this.context)==null||a.drawImage(this.renderer.canvas,0,0),this.trigger("currentframe",this.frame),this.playing&&this.frame++}}screenshot(t="png",a=1){if(this.computeFrame(),!this.renderer)throw new Ln({code:"rendererNotDefined",message:"Please wait until the renderer is defined"});return this.renderer.canvas.toDataURL(`image/${t}`,a)}async seek(t){typeof t=="number"?this.frame=Math.round(t>0?t:0):this.frame=t.frames>0?t.frames:0,this.playing&&this.pause();for(const a of this.tracks)await a.seek(ve.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(ve.fromFrames(this.frame));this.ticker(),this.trigger("play",this.frame)}}async pause(){this.state="IDLE",this.computeFrame(),this.trigger("pause",this.frame)}async audio(t=2,a=48e3){var s;const r=this.duration.seconds*a,i=new OfflineAudioContext({sampleRate:a,length:r,numberOfChannels:t}).createBuffer(t,r,a);for(const l of this.findClips(Ma)){if(l.disabled||l.muted||(s=l.track)!=null&&s.disabled)continue;const c=Math.round(l.offset.seconds*i.sampleRate),d=Math.round(l.range[0].seconds*i.sampleRate),u=Math.round(l.range[1].seconds*i.sampleRate);try{const p=await l.source.decode(t,a),m=p.numberOfChannels-1;for(let f=0;f<t;f++){const v=i.getChannelData(f),b=p.getChannelData(f>m?m:f);for(let S=0;S<v.length-1;S++)S<c+d||S>c+u||S-c<0||(v[S]+=(b[S-c]??0)*l.volume,v[S]>1&&(v[S]=1),v[S]<-1&&(v[S]=-1));i.getChannelData(f).set(v)}}catch{}}return i}time(t){const a=An(this.frame),r=t!=null&&t.hours?11:14,i=t!=null&&t.milliseconds?23:19;return new Date(a).toISOString().slice(r,i)+" / "+new Date(this.duration.millis).toISOString().slice(r,i)}removeTrack(t){const a=this.tracks.findIndex(r=>r.id==t.id);if(t.view.parent&&this.stage.removeChild(t.view),a!=null&&a>=0)return this.tracks.splice(a,1),this.trigger("detach",void 0),t.off("*"),t}async ticker(){const t=1e3/ko;let a=performance.now(),r=0;do{const i=await new Promise(requestAnimationFrame);i-a<t-r||(r=Math.min(t,r+i-a-t),a=i,this.computeFrame())}while(this.frame<=this.duration.frames&&this.playing);this.playing&&this.seek(0)}update(){this._duration.frames=Math.max(...this.tracks.filter(t=>!t.disabled).map(t=>{var a;return((a=t.stop)==null?void 0:a.frames)??0}),0),this.computeFrame()}}function y0(n,o){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]=o,t[10]=0,t[11]=0,t[12]=n&255,t[13]=n>>8&255,t[14]=n>>16&255,t[15]=n>>24&255,t[16]=0,t[17]=0,t[18]=0,t}const Or=[8e3,12e3,16e3,24e3,48e3],b0="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.wasm",w0="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.js";class k0{constructor(o){U(this,"output");U(this,"error");U(this,"config");U(this,"encoder");U(this,"opus");U(this,"meta");this.output=o.output,this.error=o.error}async configure(o){const t=await import(w0),{numberOfChannels:a,sampleRate:r}=this.config=o;if(!Or.includes(r))throw new wa({code:"sampleRateNotSupported",message:`Unsupported sample rate, supported: ${Or.join()}`});this.opus=await t.default({locateFile(i,s){return i.endsWith(".wasm")?b0:s+i}}),this.encoder=this.opus._opus_encoder_create(r,a,2048),this.meta={decoderConfig:{codec:"opus",description:y0(r,a).buffer,numberOfChannels:a,sampleRate:r}}}encode({data:o,numberOfFrames:t,timestamp:a=0}){if(!this.encoder||!this.opus||!this.config||!this.meta)throw new wa({code:"unconfiguredEncoder",message:"Cannot encode samples using an unconfigured encoder"});const{sampleRate:r,numberOfChannels:i}=this.config,s=Math.floor(r/1e3*20);let l=0;const c=s/r*1e6;for(;l<t;){const d=o.subarray(l*i,(l+s)*i),u=this.opus._malloc(d.length*2);this.opus.HEAP16.set(d,u>>1);const p=4e3,m=this.opus._malloc(p),f=this.opus._opus_encode(this.encoder,u,s,m,p);if(f>0){const v=new Uint8Array(this.opus.HEAPU8.subarray(m,m+f));this.output({data:v,timestamp:a,type:"key",duration:c},this.meta)}else this.error(new DOMException("PCM chunk could not be encoded"));this.opus._free(u),this.opus._free(m),l+=s,a+=c}}}function x0(n){const o=Or;let t=48e3;for(const a of o)Math.abs(n-a)<Math.abs(n-t)&&(t=a);return t}class S0{constructor(o,t){U(this,"canvas");U(this,"muxer");U(this,"videoEncoder");U(this,"frame",0);U(this,"sampleRate");U(this,"numberOfChannels");U(this,"videoBitrate");U(this,"gpuBatchSize");U(this,"fps");U(this,"height");U(this,"width");U(this,"audio");this.canvas=o,this.width=o.width,this.height=o.height,this.fps=(t==null?void 0:t.fps)??30,this.sampleRate=x0((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 o=await hh({height:Math.round(this.height),width:Math.round(this.width),bitrate:this.videoBitrate,fps:this.fps});this.muxer=new Kl({target:new ei,video:{...o[0],codec:"avc"},firstTimestampBehavior:"offset",fastStart:"in-memory",audio:this.audio?{numberOfChannels:this.numberOfChannels,sampleRate:this.sampleRate,codec:"opus"}:void 0});const t={output:(a,r)=>{r&&this.muxer.addVideoChunk(a,r)},error:console.error};this.videoEncoder=new VideoEncoder(t),this.videoEncoder.configure(o[0])}async encodeVideo(o){var a;this.videoEncoder||await this.init(),this.videoEncoder.encodeQueueSize>this.gpuBatchSize&&await new Promise(r=>{this.videoEncoder.ondequeue=()=>r(null)});const t=new VideoFrame(o??this.canvas,{timestamp:Math.floor(this.frame/this.fps*1e6),duration:Math.floor(1e6/this.fps)});(a=this.videoEncoder)==null||a.encode(t,{keyFrame:this.frame%(3*this.fps)==0}),t.close(),this.frame++}async encodeAudio(o){if(!this.audio)throw new wa({code:"initializationError",message:"Encoder must be initialized using {audio: true} to use this method"});this.muxer||await this.init();const t=fh(o,this.sampleRate,this.numberOfChannels),a=new k0({output:(r,i)=>{var s;(s=this.muxer)==null||s.addAudioChunkRaw(r.data,r.type,r.timestamp,r.duration,i)},error:console.error});await a.configure({numberOfChannels:this.numberOfChannels,sampleRate:this.sampleRate}),a.encode({data:ph(t),numberOfFrames:t.length})}async blob(){var t,a,r;await((t=this.videoEncoder)==null?void 0:t.flush()),(a=this.muxer)==null||a.finalize();const o=(r=this.muxer)==null?void 0:r.target.buffer;if(!o)throw new wa({code:"unexpectedRenderError",message:"Muxer could not be finalized because the target buffer is not defined"});return new Blob([o],{type:"video/mp4"})}async export(){return this.blob()}}async function E0(n){var a,r;const o=(a=n.metadata)==null?void 0:a.source_url;if(o)return o;const t=(r=n.source)==null?void 0:r.media_uuid;if(t){if(typeof window<"u"){const i=window;if(i.MEDIABLES_MEDIA_URLS&&i.MEDIABLES_MEDIA_URLS[t])return i.MEDIABLES_MEDIA_URLS[t]}if(!t.startsWith("temp-"))try{if(typeof fetch<"u"){const i=await fetch(`/api/media/${t}`);if(i.ok){const s=await i.json();return s.playback_url||s.url||void 0}}}catch{}}}function Ft(n,o){if(typeof n=="number"&&Number.isFinite(n))return n;if(typeof n=="string"){const t=Number(n);if(Number.isFinite(t))return t}return o}function Jo(n){return n>5?n/100:n}function It(n,o,t){return Math.min(t,Math.max(o,n))}function ft(){return new Ae.ColorMatrixFilter}function V0(n,o){switch(n){case"brightness":{const t=ft(),a=Ft(o.value??o.brightness,1);return t.brightness(It(Jo(a),0,5),!1),t}case"contrast":{const t=ft(),a=Ft(o.value??o.contrast,1);return t.contrast(It(Jo(a),0,5),!1),t}case"saturation":{const t=ft(),a=Ft(o.value??o.saturation,1);return t.saturate(It(Jo(a),0,5),!1),t}case"hue":{const t=ft(),a=Ft(o.degrees??o.value,0);return t.hue(It(a,-180,180),!1),t}case"blur":case"softFocus":{const t=n==="softFocus"?1:0,a=Ft(o.radius??o.blur??o.value,t);return new Ae.BlurFilter({strength:It(a,0,32),quality:4})}case"grayscale":{const t=ft(),a=It(Ft(o.amount,100),0,100);return a<=0?null:(a>=100?t.desaturate():t.saturate(1-a/100,!1),t)}case"sepia":{if(It(Ft(o.amount,100),0,100)<=0)return null;const a=ft();return a.sepia(!1),a}case"invert":{if(It(Ft(o.amount,100),0,100)<=0)return null;const a=ft();return a.negative(!1),a}case"warmth":{const t=ft(),a=It(Ft(o.value,0),-50,50);return a>0?(t.sepia(!1),t.saturate(1+a/100,!1)):a<0&&t.hue(Math.abs(a)/50*-20,!1),t}case"tint":{const t=ft(),a=It(Ft(o.intensity,.3),0,1),r=typeof o.color=="string"?o.color:"#ff0000",i=r.startsWith("#")?r.slice(1):r;if(i.length===6){const s=parseInt(i.slice(0,2),16)/255,l=parseInt(i.slice(2,4),16)/255,c=parseInt(i.slice(4,6),16)/255;t.matrix=[1-a+a*s,0,0,0,0,0,1-a+a*l,0,0,0,0,0,1-a+a*c,0,0,0,0,0,1,0]}return t}case"vintage":{const t=ft();return t.sepia(!1),t.saturate(1.4,!1),t.contrast(1.1,!1),t}case"blackAndWhite":{const t=ft(),a=It(Jo(Ft(o.contrast,120)),.5,3);return t.desaturate(),t.contrast(a,!1),t}case"cinematic":{const t=ft();return t.contrast(1.2,!1),t.brightness(.95,!1),t.saturate(.85,!1),t}case"dramatic":{const t=ft();return t.contrast(1.4,!1),t.brightness(.9,!1),t.saturate(1.1,!1),t.sepia(!1),t}case"dreamy":{const t=ft();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=Ae);class pc{constructor(o=1920,t=1080,a=30,r){this.player=null,this.clips=new Map,this.clipTimelineStart=new Map,this.resizeObserver=null,this.recipeSourceDimensions=null,this.filterCache=new Map,this.animationFrameId=null,this.lastRenderedFrame=-1,this.fps=a,this.fitMode=(r==null?void 0:r.fitMode)??"contain",this.composition=new g0({width:o,height:t,background:"#000000"}),this.initPromise=new Promise(i=>{const s=()=>{this.isDebug()&&this.dbg("init:renderer-ready"),i()};this.composition.on("init",s),queueMicrotask(()=>{var c,d,u,p;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||(p=l==null?void 0:l.renderer)!=null&&p.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(...o){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(o){this.player=o,this.isDebug()&&this.dbg("attachPlayer:begin",{w:o.clientWidth,h:o.clientHeight}),this.composition.attachPlayer(o),await this.initPromise;const t=this.composition;this.isDebug()&&this.dbg("attachPlayer:ready",{hasRenderer:!!(t!=null&&t.renderer),hasCanvas:!!(t!=null&&t.canvas),canvasSize:t!=null&&t.canvas?{w:t.canvas.width,h:t.canvas.height}:null}),this.setupResponsiveScaling(),this.composition.seek(0),this.startRenderLoop()}setupResponsiveScaling(){this.player&&(this.player.style.position="absolute",this.player.style.top="50%",this.player.style.left="50%",this.resizeObserver=new ResizeObserver(()=>{var a;const o=(a=this.player)==null?void 0:a.parentElement;if(!this.player||!o)return;const t=Math.min(o.clientWidth/this.composition.width,o.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(o){var a,r,i;await this.initPromise,this.clips.clear(),this.recipeSourceDimensions=Number.isFinite((a=o.source)==null?void 0:a.original_width)&&o.source.original_width>0&&Number.isFinite((r=o.source)==null?void 0:r.original_height)&&o.source.original_height>0?{width:o.source.original_width,height:o.source.original_height}:null;const t=await E0(o);for(const s of o.timeline)await this.addTimelineClip(s,t);if(o.textOverlays)for(const s of o.textOverlays)await this.addTextOverlay(s);await new Promise(s=>requestAnimationFrame(s));for(const s of o.timeline)(i=s.filters)!=null&&i.length&&this.applyFiltersToClip(s.id,s.filters);this.composition.seek(0),this.applyFitModeToClips(),this.composition.computeFrame()}async addTimelineClip(o,t){var a,r;try{const i=o.url||t;if(!i)throw new Error("No video source URL available for clip");if(!i.startsWith("blob:")){if(!/^https?:/i.test(String(i)))return}const s=await((a=bn.from)==null?void 0:a.call(bn,i,{crossOrigin:"anonymous"}))??await bn.from(i),l=new Dr(s,{muted:o.muted||!1,scale:o.scale||1,position:"center"});let c=0,d=null;if(o.sourceIn!==void 0||o.sourceOut!==void 0){const m=Math.max(0,Math.floor((o.sourceIn||0)*this.fps)),f=o.sourceOut!==void 0?Math.max(m+1,Math.floor(o.sourceOut*this.fps)):null;c=m,d=f;try{if(l.offset=l.offset||{frames:0},l.offset.frames=m,f!==null){const v=Math.max(1,f-m);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 m=Math.max(1,d-c);u.offset=u.offset||{frames:0},u.offset.frames=c,u.duration=u.duration||{frames:m},u.duration.frames=m}catch{}const p=Math.floor(o.timelineStart*this.fps);p>0&&u.offsetBy(p),this.clipTimelineStart.set(o.id,o.timelineStart),this.applyFitToClip(u),this.clips.set(o.id,u),(r=o.filters)!=null&&r.length&&(await new Promise(m=>requestAnimationFrame(m)),this.applyFiltersToClip(o.id,o.filters))}catch{}}async addTextOverlay(o){try{const t=st.fromFamily({family:o.fontFamily||"Arial",weight:o.fontWeight||"400"}),a=new jn({text:o.content,font:t,fontSize:o.fontSize||34,position:o.position||"center",fillStyle:o.color||"#FFFFFF",textAlign:o.textAlign||"center",textBaseline:o.textBaseline||"middle"});if(o.animation){const i=o.animation.duration||1,s=0,l=i*this.fps,c=o.animation.easing||"linear";o.animation.type==="rotate"&&o.animation.rotation?a.rotation=new Se([s,l],[o.animation.rotation.from,o.animation.rotation.to],{easing:c}):o.animation.type==="scale"&&o.animation.scale&&(a.scale=new Se([s,l],[o.animation.scale.from,o.animation.scale.to],{easing:c}))}o.startTime&&o.startTime>0&&a.offsetBy(o.startTime*this.fps),o.duration&&a.subclip(0,o.duration*this.fps);const r=await this.composition.add(a);this.clips.set(o.id||`text-${Date.now()}`,r)}catch{}}applyFiltersToClip(o,t){const a=this.clips.get(o);if(!a)return;const r=this.filterCache.get(o)??new Map,i=new Set(t.map(c=>c.id));for(const[c,d]of r.entries())if(!i.has(c)){try{typeof d.instance.destroy=="function"&&d.instance.destroy()}catch{}r.delete(c)}const s=[];for(const c of t){const d=this.buildFilterSignature(c),u=r.get(c.id);let p=null;if(u&&u.signature===d)p=u.instance;else{if(u)try{u.instance.destroy()}catch{}p=this.createPixiFilter(c),p?r.set(c.id,{instance:p,signature:d}):r.delete(c.id)}p&&s.push(p)}this.filterCache.set(o,r);const l=a.view??a.sprite??a.displayObject??null;if("filters"in a)try{a.filters=s}catch{}if(l&&"filters"in l)try{l.filters=s}catch{}typeof a.enter=="function"&&a.enter()}buildFilterSignature(o){const t=typeof o.params=="object"&&o.params!==null?o.params:{},a=Object.keys(t).sort((r,i)=>r.localeCompare(i)).map(r=>[r,t[r]]);return JSON.stringify({filterId:o.filterId,intensity:o.intensity??1,params:a})}setClipFilters(o,t){this.applyFiltersToClip(o,t),this.composition.computeFrame()}createPixiFilter(o){const t=o.intensity??1,a=o.params||{};if(Et.getFilter(o.filterId)&&!Et.isFilterCompatibleWithMedia(o.filterId,"video"))return null;let i=Pu(o.filterId,a);return i||(i=V0(o.filterId,a)),i?(t!==1&&i&&(o.filterId==="colorOverlay"||o.filterId==="alpha"||("alpha"in i&&!a.alpha&&(i.alpha*=t),"strength"in i&&(i.strength*=t))),i):null}play(){this.composition.play(),this.startRenderLoop()}pause(){this.composition.pause(),this.composition.computeFrame()}seek(o){this.composition.seek(o)}seekToTime(o){this.composition.seek(o*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(o={}){var s,l,c,d,u,p,m,f,v;const t=o.fps??this.fps,a=this.composition.canvas??((l=(s=this.composition)==null?void 0:s.renderer)==null?void 0:l.view)??((u=(d=(c=this.composition)==null?void 0:c.app)==null?void 0:d.renderer)==null?void 0:u.view)??((m=(p=this.composition)==null?void 0:p.renderer)==null?void 0:m.canvas);if(!a)throw new Error("Export failed: composition canvas is not initialized");(f=o.onProgress)==null||f.call(o,0);const r=new S0(a,{fps:t});await r.init();const i=await r.export();return(v=o.onProgress)==null||v.call(o,100),i}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 o=()=>{(this.composition.state==="PLAY"||this.composition.frame!==this.lastRenderedFrame)&&(this.composition.computeFrame(),this.lastRenderedFrame=this.composition.frame),this.animationFrameId=requestAnimationFrame(o)};o()}stopRenderLoop(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null,this.isDebug()&&this.dbg("renderLoop:stop"))}moveClip(o,t){const a=this.clips.get(o);if(!a)return;const r=this.clipTimelineStart.get(o)||0,i=t-r;i!==0&&(a.offsetBy(i*this.fps),this.clipTimelineStart.set(o,t),this.composition.computeFrame())}setFitMode(o){this.fitMode=o,this.applyFitModeToClips()}applyFitModeToClips(){for(const o of this.clips.values())"scale"in o&&typeof o.scale<"u"&&this.applyFitToClip(o);this.composition.computeFrame()}applyFitToClip(o){var t,a;if(this.fitMode!=="none")try{const r=this.composition.width,i=this.composition.height,s=o.source,l=(s==null?void 0:s.width)??(s==null?void 0:s.videoWidth)??((t=this.recipeSourceDimensions)==null?void 0:t.width),c=(s==null?void 0:s.height)??(s==null?void 0:s.videoHeight)??((a=this.recipeSourceDimensions)==null?void 0:a.height);if(!l||!c)return;const d=Math.min(r/l,i/c),u=Math.max(r/l,i/c),p=this.fitMode==="contain"?d:u;o.scale=p}catch{}}trimClip(o,t,a){const r=this.clips.get(o);if(!r)return;const i=Math.max(0,Math.floor(t*this.fps)),s=Math.max(i+1,Math.floor(a*this.fps));try{r.offset=r.offset||{frames:0},r.offset.frames=i,r.duration=r.duration||{frames:s-i},r.duration.frames=s-i,this.composition.computeFrame()}catch{}}resolveSourceFrame(o){var t,a;for(const[r,i]of this.clips.entries()){const s=this.clipTimelineStart.get(r)||0,l=Math.floor(s*this.fps),c=((t=i.duration)==null?void 0:t.frames)??Math.round(i.duration.seconds*this.fps),d=l+c;if(o>=l&&o<d){const u=o-l;return{sourceFrame:(((a=i.offset)==null?void 0:a.frames)??0)+u,clipId:r}}}return{sourceFrame:0,clipId:null}}}const C0=["src"],N0={class:"preview-controls"},_0=["aria-label"],T0={class:"time-display"},M0={class:"current-time"},F0={class:"total-time"},I0={key:2,class:"loading-overlay"},B0={key:3,class:"error-overlay"},R0=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(n,{emit:o}){const t=n,a=o,r=e.ref(),i=e.ref(),s=e.ref(),l=e.ref(!1),c=e.ref("Initializing..."),d=e.ref(null),u=e.ref(!1),p=e.ref(0),m=e.ref(0);let f=null;const v=e.computed(()=>!!t.enableEngine&&!!t.recipe),b=e.computed(()=>{switch(t.fitMode){case"cover":return"cover";case"none":return"none";default:return"contain"}}),S=e.computed(()=>{var x,T;return(x=t.media)!=null&&x.url?t.media.url:(((T=t.media)==null?void 0:T.file)instanceof File,"")});async function M(){var x,T,I;if(!(!i.value||!t.recipe))try{l.value=!0,c.value="Initializing video engine...";const z=((x=t.recipe.source)==null?void 0:x.original_width)||1920,P=((T=t.recipe.source)==null?void 0:T.original_height)||1080,j=((I=t.recipe.output)==null?void 0:I.fps)||30;f=new pc(z,P,j,{fitMode:t.fitMode}),f.attachPlayer(i.value),c.value="Loading composition...",await f.loadFromRecipe(t.recipe),m.value=f.durationInSeconds,a("duration-change",m.value),E(),l.value=!1,a("engine-ready",f),t.autoPlay&&(f.play(),u.value=!0)}catch(z){const P=z instanceof Error?z.message:String(z);d.value=`Failed to initialize: ${P}`,l.value=!1}}function E(){if(!f)return;const x=setInterval(()=>{f&&u.value&&(p.value=f.currentTimeInSeconds,a("time-update",p.value))},100);A.value=x}function y(){v.value&&f?(u.value?f.pause():f.play(),u.value=!u.value,a("play-state-change",u.value)):s.value&&(u.value?s.value.pause():s.value.play(),u.value=!u.value,a("play-state-change",u.value))}function h(x){const T=Math.floor(x/60),I=Math.floor(x%60);return`${T}:${I.toString().padStart(2,"0")}`}function w(){d.value=null,v.value&&M()}function R(){!v.value&&s.value&&(m.value=s.value.duration,a("duration-change",m.value))}function N(){!v.value&&s.value&&(p.value=s.value.currentTime,a("time-update",p.value))}function g(){u.value=!1,a("play-state-change",!1)}function C(x){d.value="Failed to load video",a("error",d.value)}e.onMounted(()=>{v.value&&t.recipe&&M()}),e.onUnmounted(()=>{f&&(f.destroy(),f=null),A.value&&(clearInterval(A.value),A.value=null),s.value&&(s.value.pause(),s.value.removeAttribute("src"),s.value.load())}),e.watch(()=>t.recipe,async x=>{if(v.value&&x)if(f)try{await f.loadFromRecipe(x),m.value=f.durationInSeconds,a("duration-change",m.value)}catch{}else await M()}),e.watch(()=>t.enableEngine,async x=>{x?await M():f&&(A.value&&(clearInterval(A.value),A.value=null),f.destroy(),f=null)}),e.watch(()=>t.fitMode,async x=>{if(!(!v.value||!f))try{f.setFitMode(x||"contain")}catch{}});const A=e.ref(null);return(x,T)=>(e.openBlock(),e.createElementBlock("div",{class:"video-preview-engine",ref_key:"containerRef",ref:r},[v.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"videoEnginePlayer",ref:i,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:S.value,onLoadedmetadata:R,onTimeupdate:N,onEnded:g,onError:C,style:e.normalizeStyle({width:"100%",height:"100%",objectFit:b.value}),playsinline:"",controls:""},null,44,C0)),e.createElementVNode("div",N0,[e.createElementVNode("button",{class:"play-button",onClick:y,"aria-label":u.value?"Pause":"Play"},[e.createVNode(e.unref(B.IonIcon),{icon:u.value?e.unref(Il):e.unref(Bl)},null,8,["icon"])],8,_0),e.createElementVNode("div",T0,[e.createElementVNode("span",M0,e.toDisplayString(h(p.value)),1),T[0]||(T[0]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",F0,e.toDisplayString(h(m.value)),1)])]),l.value?(e.openBlock(),e.createElementBlock("div",I0,[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",B0,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Jr)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(d.value),1),e.createElementVNode("button",{onClick:w},"Retry")])):e.createCommentVNode("",!0)],512))}}),js=_e(R0,[["__scopeId","data-v-7e604791"]]),P0=["aria-label"],$0=["aria-label"],z0={class:"clip-content"},A0={key:0,class:"clip-thumbnail"},D0=["src","alt"],U0={class:"clip-waveform"},O0={class:"clip-info"},L0={class:"clip-label"},W0={class:"clip-duration"},j0={key:1,class:"filter-indicators"},X0={key:2,class:"speed-indicator"},Z0={key:0,class:"selection-overlay"},Y0=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(n,{emit:o}){const t=n,a=o,r=e.ref(),i=e.ref(!1),s=e.ref(null),l=e.ref(0),c=e.ref(0),d=e.computed(()=>{const C=(t.clip.timelineEnd-t.clip.timelineStart)*t.scale;return{left:`${t.clip.timelineStart*t.scale-t.scrollOffset}px`,width:`${C}px`}}),u=e.computed(()=>t.clip.label||`Clip ${t.clip.id.slice(-4)}`),p=e.computed(()=>{const g=t.clip.timelineEnd-t.clip.timelineStart;return v(g)}),m=e.computed(()=>t.clip.filters&&t.clip.filters.length>0),f=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 C=Math.floor(g/60),A=Math.floor(g%60);return`${C}:${A.toString().padStart(2,"0")}`}}function b(g){return!g||typeof g!="string"?xs:g.includes("color")||g.includes("brightness")?ln:g.includes("blur")?dm:g.includes("style")?ao:g.includes("effect")?sn:xs}function S(){i.value||a("select")}function M(g){g.button===0&&(h("move",g.clientX),g.preventDefault())}function E(g){if(g.touches.length!==1)return;const C=g.touches[0];h("move",C.clientX),g.preventDefault()}function y(g,C){const A="touches"in C?C.touches[0].clientX:C.clientX;s.value=g==="start"?"trim-start":"trim-end",h(s.value,A),C.preventDefault(),C.stopPropagation()}function h(g,C){i.value=!0,s.value=g,l.value=C,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",w),document.addEventListener("mouseup",R),document.addEventListener("touchmove",w),document.addEventListener("touchend",R),t.selected||a("select")}function w(g){if(!i.value||!s.value)return;const C="touches"in g?g.touches[0].clientX:g.clientX,x=C-l.value;s.value==="move"?(a("drag",x),a("drag-abs",C)):s.value==="trim-start"?(a("trim-start",x),a("trim-start-abs",C)):s.value==="trim-end"&&(a("trim-end",x),a("trim-end-abs",C))}function R(){i.value=!1,s.value=null,document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",R),document.removeEventListener("touchmove",w),document.removeEventListener("touchend",R)}function N(){if(!r.value)return;const g=r.value,C=g.getContext("2d");if(!C)return;g.width=g.clientWidth*window.devicePixelRatio,g.height=g.clientHeight*window.devicePixelRatio,C.scale(window.devicePixelRatio,window.devicePixelRatio),C.strokeStyle="rgba(255, 255, 255, 0.3)",C.lineWidth=1,C.beginPath();const A=g.clientWidth,x=g.clientHeight,T=x/2;C.moveTo(0,T),C.lineTo(A,T);for(let I=0;I<A;I+=4){const z=Math.sin(I*.05)*(x*.3);C.moveTo(I,T-z),C.lineTo(I,T+z)}C.stroke()}return e.onMounted(()=>{N(),window.addEventListener("resize",N)}),e.onUnmounted(()=>{R(),window.removeEventListener("resize",N)}),(g,C)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-clip",{selected:g.selected,mobile:g.isMobile,"has-filters":m.value}]),style:e.normalizeStyle(d.value),onClick:S,onMousedown:M,onTouchstart:E},[e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:C[0]||(C[0]=e.withModifiers(A=>y("start",A),["stop"])),onTouchstart:C[1]||(C[1]=e.withModifiers(A=>y("start",A),["stop"])),"aria-label":`Trim start of ${g.clip.label||"clip"}`},[...C[4]||(C[4]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,P0),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:C[2]||(C[2]=e.withModifiers(A=>y("end",A),["stop"])),onTouchstart:C[3]||(C[3]=e.withModifiers(A=>y("end",A),["stop"])),"aria-label":`Trim end of ${g.clip.label||"clip"}`},[...C[5]||(C[5]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,$0),e.createElementVNode("div",z0,[g.clip.thumbnail?(e.openBlock(),e.createElementBlock("div",A0,[e.createElementVNode("img",{src:g.clip.thumbnail,alt:g.clip.label||"Video clip"},null,8,D0)])):e.createCommentVNode("",!0),e.createElementVNode("div",U0,[e.createElementVNode("canvas",{ref_key:"waveformCanvas",ref:r},null,512)]),e.createElementVNode("div",O0,[e.createElementVNode("span",L0,e.toDisplayString(u.value),1),e.createElementVNode("span",W0,e.toDisplayString(p.value),1)]),m.value?(e.openBlock(),e.createElementBlock("div",j0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,A=>(e.openBlock(),e.createBlock(e.unref(B.IonIcon),{key:A.id||A.filterId,icon:b(A.filterId||A.id),title:`Filter: ${A.filterId||A.id}`},null,8,["icon","title"]))),128))])):e.createCommentVNode("",!0),g.clip.speed&&g.clip.speed!==1?(e.openBlock(),e.createElementBlock("div",X0,e.toDisplayString(g.clip.speed)+"x ",1)):e.createCommentVNode("",!0)]),g.selected?(e.openBlock(),e.createElementBlock("div",Z0)):e.createCommentVNode("",!0)],38))}}),G0=_e(Y0,[["__scopeId","data-v-943b6167"]]);class fc{constructor(o=30){this.fps=30,this.fps=o}setFps(o){this.fps=o}async convertTimelineClipToEngine(o,t){const a=new Dr(t,{muted:o.muted||!1,scale:o.scale||1,position:"center"});if(o.sourceIn!==void 0||o.sourceOut!==void 0){const r=this.secondsToFrames(o.sourceIn||0),i=o.sourceOut?this.secondsToFrames(o.sourceOut):a.duration.frames;a.subclip(r,i)}return o.timelineStart&&o.timelineStart>0&&a.offsetBy(this.secondsToFrames(o.timelineStart)),o.transform&&this.applyTransformations(a,o.transform),a}convertEngineClipToTimeline(o,t,a){const r=this.framesToSeconds(o.duration.frames),i=o.offset?this.framesToSeconds(o.offset.frames):0;return{id:t,url:a,type:"video",timelineStart:i,timelineEnd:i+r,sourceIn:0,sourceOut:r,duration:r,muted:o.muted||!1,scale:o.scale.x||1}}async buildCompositionFromRecipe(o,t){var a;(a=t.clear)==null||a.call(t);for(const r of o.timeline)try{if(!r.url)continue;const i=await bn.from(r.url),s=await this.convertTimelineClipToEngine(r,i);await t.add(s)}catch{}o.duration&&(t.duration=ve.fromFrames(this.secondsToFrames(o.duration)))}extractTimelineFromComposition(o){const t=[];return(o.clips||[]).forEach((r,i)=>{var s,l;r instanceof Dr&&t.push(this.convertEngineClipToTimeline(r,`clip-${i}`,((s=r.source)==null?void 0:s.externalURL)||((l=r.source)==null?void 0:l.objectURL)||""))}),t}applyTransformations(o,t){(t.x!==void 0||t.y!==void 0)&&(o.x=t.x||0,o.y=t.y||0),t.rotation!==void 0&&(o.rotation=t.rotation),t.opacity!==void 0&&(o.alpha=t.opacity),t.scale!==void 0&&(o.scale={x:t.scale,y:t.scale})}secondsToFrames(o){return Math.round(o*this.fps)}framesToSeconds(o){return o/this.fps}framesToTime(o){const t=this.framesToSeconds(o),a=Math.floor(t/60),r=Math.floor(t%60),i=Math.floor(t%1*1e3);return`${a.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}.${i.toString().padStart(3,"0")}`}formatTime(o){const t=Math.floor(o/3600),a=Math.floor(o%3600/60),r=Math.floor(o%60);return`${t.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`}parseTime(o){const t=o.split(":");let a=0;if(t.length===2){const[r,i]=t;a=parseInt(r)*60+parseFloat(i)}else if(t.length===3){const[r,i,s]=t;a=parseInt(r)*3600+parseInt(i)*60+parseFloat(s)}else a=parseFloat(o);return a}timeToFrames(o){const t=o.split(":");let a=0;if(t.length===2){const[r,i]=t;a=parseInt(r)*60+parseFloat(i)}else if(t.length===3){const[r,i,s]=t;a=parseInt(r)*3600+parseInt(i)*60+parseFloat(s)}else a=parseFloat(o);return this.secondsToFrames(a)}}const H0={class:"time-markers"},J0=["aria-label","title"],q0={key:0,class:"timeline-scrollbar"},K0=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(n,{emit:o}){const t=n,a=e.computed(()=>t.isMobile===!0),r=o,i=e.ref(),s=e.ref(t.selectedClipId||null),l=e.ref(!1),c=e.ref(0),d=e.ref(),u=e.ref(0),p=e.computed(()=>t.selectedClipId??s.value);e.watch(()=>t.selectedClipId,W=>{W!==void 0&&(s.value=W)});const m=new fc(t.fps),f=e.ref(!1),v=e.ref(null),b=e.ref(0),S=e.ref(0),M=e.ref(0),E=e.ref(0),y=e.ref(0),h=e.ref(!1),w=e.ref(0),R=e.ref(t.zoomLevel),N=e.computed(()=>t.zoomLevel);function g(W){const J=t.clips.find(oe=>oe.id===W);if(!J)return null;const te=t.clips.filter(oe=>oe.id!==W&&oe.timelineStart>=J.timelineEnd-1e-9).map(oe=>oe.timelineStart);return te.length?Math.min(...te):null}function C(W){const J=W.sourceMaxOut??t.duration,te=W.timelineStart+(J-W.sourceIn),oe=g(W.id),pe=oe!=null?Math.max(W.timelineStart,oe):1/0;return Math.min(te,pe)}function A(W){const J=W.sourceMinIn??0,oe=(W.sourceMaxOut??t.duration)-J,pe=W.sourceIn-J;return{left:`${(W.timelineStart-pe)*N.value-c.value}px`,width:`${oe*N.value}px`,top:"0px",height:"80px",opacity:p.value===W.id?.25:.15}}const x=e.computed(()=>t.useFrameMode?t.zoomLevel:t.zoomLevel/t.fps),T=e.computed(()=>m.secondsToFrames(t.duration)),I=e.computed(()=>t.useFrameMode?T.value*x.value:t.duration*N.value),z=e.computed(()=>{var W;return u.value||((W=i.value)==null?void 0:W.clientWidth)||800}),P=e.computed(()=>I.value>z.value),j=e.computed(()=>Math.max(0,I.value-z.value)),L=e.computed(()=>c.value>0),_=e.computed(()=>c.value<j.value),D=e.computed(()=>t.useFrameMode?m.secondsToFrames(t.playhead)*x.value-c.value:t.playhead*N.value-c.value),G=e.computed(()=>{const W=Math.max(50,z.value/I.value*z.value),J=c.value/j.value*(z.value-W);return{width:`${W}px`,left:`${J}px`}}),X=e.computed(()=>{const W=[],J=ce();for(let te=0;te<=t.duration;te+=J){const oe=te*N.value-c.value;oe>=-50&&oe<=z.value+50&&W.push({position:oe,label:Me(te),time:te})}return W});function ce(){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 Me(W){if(t.useFrameMode)return`F${m.secondsToFrames(W)}`;{const J=Math.floor(W/60),te=Math.floor(W%60),oe=Math.floor(W%1*t.fps);return N.value>100?`${J}:${te.toString().padStart(2,"0")}:${oe.toString().padStart(2,"0")}`:`${J}:${te.toString().padStart(2,"0")}`}}function $e(W){const J=i.value.getBoundingClientRect();let oe=(W.clientX-J.left+c.value)/N.value;const pe=t.clips.find(be=>oe>=be.timelineStart&&oe<=be.timelineEnd);if(pe)oe=Math.max(pe.timelineStart,Math.min(pe.timelineEnd,oe));else if(t.selectedClipId){const be=t.clips.find(Be=>Be.id===t.selectedClipId);if(be){const Be=Math.abs(oe-be.timelineStart),De=Math.abs(oe-be.timelineEnd);oe=Be<De?be.timelineStart:be.timelineEnd}}else oe=Math.max(0,Math.min(oe,t.duration));r("update:playhead",oe)}function ae(W){if(!P.value)return;const J=Math.abs(W.deltaX)>Math.abs(W.deltaY)?W.deltaX:W.deltaY;J!==0&&(W.preventDefault(),c.value=Math.max(0,Math.min(j.value,c.value+J)))}function F(W){if(W.touches.length===2){h.value=!0;const J=W.touches[0],te=W.touches[1];w.value=Math.hypot(te.clientX-J.clientX,te.clientY-J.clientY),R.value=t.zoomLevel}else W.touches.length===1&&(M.value=W.touches[0].clientX,E.value=W.touches[0].clientY,y.value=M.value)}function O(W){if(h.value&&W.touches.length===2){const J=W.touches[0],te=W.touches[1],pe=Math.hypot(te.clientX-J.clientX,te.clientY-J.clientY)/w.value;Math.max(10,Math.min(200,R.value*pe)),r("update:playhead",t.playhead)}else if(W.touches.length===1&&!h.value){const J=W.touches[0],te=y.value-J.clientX;Math.abs(te)>Math.abs(J.clientY-E.value)&&(W.preventDefault(),c.value=Math.max(0,Math.min(I.value-z.value,c.value+te)),y.value=J.clientX)}}function de(){h.value=!1}function re(W){const J=W.target;if(J.closest(".playhead-handle"))return;const te=W.button===1,oe=!!J.closest(".video-track");(te||!oe&&P.value)&&q(W)}function q(W){f.value=!0,v.value="pan",b.value=W.clientX,S.value=c.value,document.addEventListener("mousemove",ge),document.addEventListener("mouseup",xe)}function ee(W){W.preventDefault(),W.stopPropagation(),f.value=!0,v.value="playhead";const J="touches"in W?W.touches[0].clientX:W.clientX;b.value=J,S.value=t.playhead,"touches"in W?(document.addEventListener("touchmove",ge),document.addEventListener("touchend",xe)):(document.addEventListener("mousemove",ge),document.addEventListener("mouseup",xe))}function ue(W){W.preventDefault(),W.stopPropagation(),f.value=!0,v.value="scrollbar";const J="touches"in W?W.touches[0].clientX:W.clientX;b.value=J,S.value=c.value,"touches"in W?(document.addEventListener("touchmove",ge),document.addEventListener("touchend",xe)):(document.addEventListener("mousemove",ge),document.addEventListener("mouseup",xe))}function ge(W){if(!f.value)return;const te=("touches"in W?W.touches[0].clientX:W.clientX)-b.value;if(v.value==="playhead"){const oe=te/N.value;let pe=S.value+oe;if(t.selectedClipId){const be=t.clips.find(Be=>Be.id===t.selectedClipId);be?pe=Math.max(be.timelineStart,Math.min(be.timelineEnd,pe)):pe=Math.max(0,Math.min(t.duration,pe))}else{const be=t.clips.find(Be=>t.playhead>=Be.timelineStart&&t.playhead<=Be.timelineEnd);be?pe=Math.max(be.timelineStart,Math.min(be.timelineEnd,pe)):pe=Math.max(0,Math.min(t.duration,pe))}r("update:playhead",pe)}else if(v.value==="scrollbar"){const oe=te/z.value*I.value;c.value=Math.max(0,Math.min(j.value,S.value+oe))}else if(v.value==="pan"){const oe=S.value-te;c.value=Math.max(0,Math.min(j.value,oe))}}function xe(){f.value=!1,v.value=null,document.removeEventListener("mousemove",ge),document.removeEventListener("mouseup",xe),document.removeEventListener("touchmove",ge),document.removeEventListener("touchend",xe)}function ne(W){s.value=s.value===W?null:W,r("clip-select",s.value)}function ke(W,J){const te=t.clips.find(pe=>pe.id===W);if(!te||Math.abs(J)<2)return;const oe=J/N.value*t.sensitivity;if(t.useFrameMode){const pe=m.secondsToFrames(te.sourceIn),be=m.secondsToFrames(oe),Be=Math.max(0,pe+be),De=m.framesToSeconds(Be);r("trim",W,"start",De)}else{const pe=Math.max(0,te.sourceIn+oe);r("trim",W,"start",pe)}}function he(W,J){const te=t.clips.find(we=>we.id===W);if(!te||!i.value)return;const oe=i.value.getBoundingClientRect(),pe=J-oe.left,be=80;if(pe<be)c.value=Math.max(0,c.value-8);else if(pe>oe.width-be){const we=Math.max(0,I.value-z.value);c.value=Math.min(we,c.value+8)}const Be=pe+c.value,De=1/t.fps;let Y=Be/N.value;Y=Math.max(0,Math.min(Y,te.timelineEnd-De));let ie=te.sourceIn+(Y-te.timelineStart);ie=Math.round(ie*t.fps)/t.fps,r("trim",W,"start",ie)}function qe(W,J){const te=t.clips.find(Ve=>Ve.id===W);if(!te||!i.value)return;const oe=i.value.getBoundingClientRect(),pe=J-oe.left,be=80;if(pe<be)c.value=Math.max(0,c.value-8);else if(pe>oe.width-be){const Ve=Math.max(0,I.value-z.value);c.value=Math.min(Ve,c.value+8)}const Be=pe+c.value,De=1/t.fps,Y=C(te);let ie=Be/N.value;ie=Math.max(te.timelineStart+De,Math.min(ie,Y));let we=te.sourceIn+(ie-te.timelineStart);we=Math.round(we*t.fps)/t.fps,r("trim",W,"end",we)}function ct(W,J){const te=t.clips.find(Y=>Y.id===W);if(!te||!i.value)return;const oe=i.value.getBoundingClientRect(),be=J-oe.left+c.value,Be=te.timelineEnd-te.timelineStart;let De=be/N.value;De=Math.max(0,Math.min(De,t.duration-Be)),De=Math.round(De*t.fps)/t.fps,r("clip-move",W,De)}function pt(W,J){const te=t.clips.find(be=>be.id===W);if(!te||Math.abs(J)<2)return;const oe=J/N.value*t.sensitivity,pe=be=>Math.max(0,Math.round(be*t.fps)/t.fps);if(t.useFrameMode){const be=m.secondsToFrames(te.sourceOut),Be=m.secondsToFrames(oe),De=C(te),Y=te.sourceIn+(De-te.timelineStart),ie=m.secondsToFrames(Y),we=Math.min(ie,be+Be),Ve=m.framesToSeconds(we);r("trim",W,"end",Ve)}else{const be=C(te),Be=te.sourceIn+(be-te.timelineStart),De=Math.min(Be,te.sourceOut+oe),Y=pe(De);r("trim",W,"end",Y)}}function me(W,J){const te=t.clips.find(be=>be.id===W);if(!te||Math.abs(J)<2)return;const oe=J/N.value*t.sensitivity,pe=be=>Math.max(0,Math.round(be*t.fps)/t.fps);if(t.useFrameMode){const be=m.secondsToFrames(te.timelineStart),Be=m.secondsToFrames(oe),De=Math.max(0,be+Be),Y=m.framesToSeconds(De);r("clip-move",W,Y)}else{const be=Math.max(0,te.timelineStart+oe),Be=pe(be);r("clip-move",W,Be)}}return e.watch(()=>t.playhead,W=>{const J=W*N.value;J<c.value+50?c.value=Math.max(0,J-50):J>c.value+z.value-50&&(c.value=Math.min(j.value,J-z.value+50))}),e.onMounted(()=>{const W=new ResizeObserver(J=>{J[0]&&(u.value=Math.round(J[0].contentRect.width))});i.value&&W.observe(i.value),e.onUnmounted(()=>W.disconnect())}),e.onUnmounted(()=>{xe()}),e.watch([I,z],()=>{c.value>j.value&&(c.value=j.value)}),(W,J)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-timeline",{mobile:a.value}]),ref_key:"timelineRef",ref:i,onWheel:ae},[e.createElementVNode("div",{class:"timeline-ruler",onClick:$e},[e.createElementVNode("div",H0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(X.value,te=>(e.openBlock(),e.createElementBlock("span",{key:te.position,class:"time-marker",style:e.normalizeStyle({left:`${te.position}px`})},e.toDisplayString(te.label),5))),128))])]),e.createElementVNode("div",{class:e.normalizeClass(["timeline-content",{"is-pannable":P.value,"is-panning":f.value&&v.value==="pan","overflow-left":L.value,"overflow-right":_.value}]),onTouchstart:F,onTouchmove:O,onTouchend:de,onMousedown:re},[e.createElementVNode("div",{class:"video-track",ref_key:"trackRef",ref:d},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.clips,te=>(e.openBlock(),e.createElementBlock("div",{key:`${te.id}-extent`,class:"clip-extent",style:e.normalizeStyle(A(te)),"aria-hidden":"true"},null,4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.clips,te=>(e.openBlock(),e.createBlock(G0,{key:te.id,clip:te,scale:N.value,"scroll-offset":c.value,selected:p.value===te.id,"is-mobile":a.value,onSelect:oe=>ne(te.id),onTrimStart:oe=>ke(te.id,oe),onTrimEnd:oe=>pt(te.id,oe),onDrag:oe=>me(te.id,oe),onTrimStartAbs:oe=>he(te.id,oe),onTrimEndAbs:oe=>qe(te.id,oe),onDragAbs:oe=>ct(te.id,oe)},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:ee,onTouchstart:ee},[...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),a.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"frame-mode-toggle",onClick:J[0]||(J[0]=te=>W.$emit("toggle-frame-mode")),"aria-label":W.useFrameMode?"Switch to time mode":"Switch to frame mode",title:W.useFrameMode?"Switch to time mode":"Switch to frame mode"},e.toDisplayString(W.useFrameMode?"F":"T"),9,J0))],34),P.value?(e.openBlock(),e.createElementBlock("div",q0,[e.createElementVNode("div",{class:"scrollbar-thumb",style:e.normalizeStyle(G.value),onMousedown:ue,onTouchstart:ue},null,36)])):e.createCommentVNode("",!0)],34))}}),Xs=_e(K0,[["__scopeId","data-v-6fa3968c"]]),Q0={class:"control-group zoom-controls"},ev={class:"zoom-slider"},tv=["value"],nv={class:"control-group playback-controls"},ov=["aria-label"],av={key:0,class:"control-group speed-control"},rv=["value"],iv=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(n,{emit:o}){const t=o;function a(u){const p=u.target;t("zoom-change",Number(p.value))}function r(){t("fit-to-window")}function i(){t("frame-forward")}function s(){t("frame-backward")}function l(){t("skip-to-start")}function c(){t("skip-to-end")}function d(u){const p=u.target;t("speed-change",Number(p.value))}return(u,p)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-controls",{mobile:u.isMobile}])},[e.createElementVNode("div",Q0,[e.createElementVNode("button",{class:"control-button zoom-button",onClick:p[0]||(p[0]=m=>u.$emit("zoom-out")),"aria-label":"Zoom out"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Nm)},null,8,["icon"])]),e.createElementVNode("div",ev,[e.createElementVNode("input",{type:"range",value:u.zoomLevel,onInput:a,min:"10",max:"200",step:"5","aria-label":"Timeline zoom"},null,40,tv)]),e.createElementVNode("button",{class:"control-button zoom-button",onClick:p[1]||(p[1]=m=>u.$emit("zoom-in")),"aria-label":"Zoom in"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(qu)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:r,"aria-label":"Fit timeline to window"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(cm)},null,8,["icon"]),p[3]||(p[3]=e.createElementVNode("span",{class:"control-label"},"Fit",-1))])]),e.createElementVNode("div",nv,[e.createElementVNode("button",{class:"control-button",onClick:l,"aria-label":"Skip to start"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Vm)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:s,"aria-label":"Previous frame"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(wm)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button play-button",onClick:p[2]||(p[2]=m=>u.$emit("play-pause")),"aria-label":u.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(B.IonIcon),{icon:u.isPlaying?e.unref(gm):e.unref(Em)},null,8,["icon"])],8,ov),e.createElementVNode("button",{class:"control-button",onClick:i,"aria-label":"Next frame"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Sm)},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(Cm)},null,8,["icon"])])]),u.isMobile?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",av,[p[5]||(p[5]=e.createElementVNode("label",{class:"speed-label"},"Speed:",-1)),e.createElementVNode("select",{value:u.playbackSpeed,onChange:d,class:"speed-select","aria-label":"Playback speed"},[...p[4]||(p[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,rv)]))],2))}}),sv=_e(iv,[["__scopeId","data-v-7bf65ab9"]]),lv={class:"video-filter-carousel-container"},cv={key:0,class:"category-section"},dv={class:"category-carousel-wrapper"},uv=["disabled"],mv=["onClick","data-testid","aria-label"],pv={class:"category-name"},fv=["disabled"],hv={class:"filter-section"},vv={class:"filter-carousel-wrapper"},gv=["disabled"],yv=["onClick","onKeydown","data-testid","aria-label"],bv=["onClick"],wv={class:"filter-preview"},kv={class:"filter-placeholder"},xv={class:"filter-name"},Sv=["disabled"],Ev={class:"carousel-pagination"},Vv=["onClick"],Cv={key:1,class:"filter-adjustments"},Nv={class:"adjustment-header"},_v={class:"adjustment-actions"},Tv={key:0},Mv={key:0,class:"slider-control"},Fv={class:"control-label"},Iv={class:"slider-wrapper"},Bv={class:"slider-value"},Rv={key:1,class:"color-control"},Pv={class:"control-label"},$v={class:"color-wrapper"},zv=["value","onInput","disabled"],Av={class:"color-value"},Dv={key:2,class:"toggle-control"},Uv={class:"control-label"},Ov={key:3,class:"select-control"},Lv={class:"control-label"},Wv=["value","onChange","disabled"],jv=["value"],Xv={key:1,class:"no-params"},Zv=e.defineComponent({__name:"VideoFilterCarousel",props:{filters:{},activeFilters:{},thumbnailUrl:{},showCategories:{type:Boolean,default:!0}},emits:["apply-filter","remove-filter","update-param","preview-filter"],setup(n,{emit:o}){const t=n,a=o,r=e.ref("all"),i=e.ref(null),s=e.ref(0),l=e.ref(0),c=e.ref(new Map),d=e.ref(),u=e.ref(),p={all:sn,adjust:Kn,color:ln,blur:Zo,light:Qn,effects:ur,stylize:ao,advanced:sn,distortion:ro,transform:ro};function m(_){return _.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function f(_){return _.replace(/[-_]/g," ").replace(/\b\w/g,D=>D.toUpperCase())}function v(_){return p[_.toLowerCase()]??sn}const b=e.computed(()=>{const _=Array.from(new Set(t.filters.map(D=>D.category).filter(D=>typeof D=="string"&&D.length>0))).sort((D,G)=>D.localeCompare(G));return[{id:"all",name:"All",icon:sn},..._.map(D=>({id:D,name:f(D),icon:v(D)}))]}),S=e.computed(()=>r.value==="all"?t.filters:t.filters.filter(_=>_.category===r.value));e.watch(b,_=>{new Set(_.map(X=>X.id)).has(r.value)||(r.value="all");const G=Math.max(0,_.length-3);s.value>G&&(s.value=G)},{immediate:!0});function M(_){var D;return((D=t.activeFilters)==null?void 0:D.has(_))||!1}function E(_){if(i.value=_,!M(_.id)&&(a("apply-filter",_),_.params&&_.params.length>0)){const D=new Map;_.params.forEach(G=>{D.set(G.id,G.default)}),c.value.set(_.id,D)}a("preview-filter",_)}function y(_){var D;a("remove-filter",_),c.value.delete(_),((D=i.value)==null?void 0:D.id)===_&&(i.value=null)}function h(_){if(typeof _=="number"&&Number.isFinite(_))return _;if(typeof _=="string"){const D=Number(_);return Number.isFinite(D)?D:null}return null}function w(_,D){var F;const G=t.filters.find(O=>O.id===_),X=G==null?void 0:G.params.find(O=>O.id===D),ce=(X==null?void 0:X.default)??0,Me=O=>typeof ce=="number"?h(O)??ce:typeof ce=="boolean"?typeof O=="boolean"?O:ce:typeof O=="string"?O:ce,$e=(F=t.activeFilters)==null?void 0:F.get(_);if($e&&$e.params){const O=$e.params[D];if(O!=null)return Me(O)}const ae=c.value.get(_);if(ae){const O=ae.get(D);if(O!=null)return Me(O)}return ce}function R(_,D,G){var X;c.value.has(_)||c.value.set(_,new Map),(X=c.value.get(_))==null||X.set(D,G),a("update-param",_,D,G)}function N(_){if(typeof _=="boolean")return _?"On":"Off";if(typeof _=="string"){const G=h(_);return G===null?"0":Number.isInteger(G)?G.toString():G.toFixed(2)}const D=h(_);return D===null?"0":Number.isInteger(D)?D.toString():D.toFixed(2)}function g(){if(i.value&&(a("apply-filter",i.value),i.value.params&&i.value.params.length>0)){const _=new Map;i.value.params.forEach(D=>{_.set(D.id,D.default)}),c.value.set(i.value.id,_)}}function C(_){const D=t.filters.find(G=>G.id===_);D&&D.params&&D.params.forEach(G=>{R(_,G.id,G.default)})}function A(_){return{basic:Kn,color:ln,blur:Zo,light:Qn,effects:ur,stylize:ao,adjustment:Kn,"color-matrix":ln,glow:sn,distortion:ro}[_]||sn}function x(_){return{adjustment:Kn,brightness:Qn,contrast:Kn,saturation:ln,blur:Zo,"gaussian-blur":Zo,"color-matrix":ln,grayscale:ao,sepia:ao,vignette:ro,glow:sn,glitch:ur,godray:Qn,lightmap:Qn}[_.id]||A(_.category)}function T(){s.value>0&&(s.value--,L(d.value,s.value))}function I(){s.value<b.value.length-3&&(s.value++,L(d.value,s.value))}function z(){l.value>0&&(l.value--,L(u.value,l.value))}function P(){l.value<S.value.length-4&&(l.value++,L(u.value,l.value))}function j(_){l.value=_*4,L(u.value,l.value)}function L(_,D){var G;if(_){const X=((G=_.querySelector(".category-chip, .filter-card"))==null?void 0:G.clientWidth)||100;_.scrollTo({left:D*(X+8),behavior:"smooth"})}}return(_,D)=>{var G;return e.openBlock(),e.createElementBlock("div",lv,[_.showCategories?(e.openBlock(),e.createElementBlock("div",cv,[e.createElementVNode("div",dv,[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(gs)},null,8,["icon"])],8,uv),e.createElementVNode("div",{ref_key:"categoryCarouselRef",ref:d,class:"category-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,X=>(e.openBlock(),e.createElementBlock("button",{key:X.id,onClick:ce=>r.value=X.id,class:e.normalizeClass(["category-chip",{active:r.value===X.id}]),"data-testid":`btn-filter-category-${m(X.id)}`,"aria-label":`Filter category ${X.name}`},[e.createVNode(e.unref(B.IonIcon),{icon:X.icon,class:"category-icon"},null,8,["icon"]),e.createElementVNode("span",pv,e.toDisplayString(X.name),1)],10,mv))),128))],512),e.createElementVNode("button",{onClick:I,class:"carousel-nav carousel-nav-right",disabled:s.value>=b.value.length-3,"aria-label":"Next categories","data-testid":"btn-filter-category-next"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(ys)},null,8,["icon"])],8,fv)])])):e.createCommentVNode("",!0),e.createElementVNode("div",hv,[e.createElementVNode("div",vv,[e.createElementVNode("button",{onClick:z,class:"carousel-nav carousel-nav-left",disabled:l.value===0,"aria-label":"Previous filters","data-testid":"btn-filter-carousel-prev"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(gs)},null,8,["icon"])],8,gv),e.createElementVNode("div",{ref_key:"filterCarouselRef",ref:u,class:"filter-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(S.value,X=>{var ce;return e.openBlock(),e.createElementBlock("div",{key:X.id,class:e.normalizeClass(["filter-card",{active:M(X.id),selected:((ce=i.value)==null?void 0:ce.id)===X.id}]),onClick:Me=>E(X),onKeydown:[e.withKeys(Me=>E(X),["enter"]),e.withKeys(e.withModifiers(Me=>E(X),["prevent"]),["space"])],role:"button",tabindex:"0","data-testid":`btn-video-filter-${m(X.id)}`,"aria-label":`Select filter ${X.name}`},[M(X.id)?(e.openBlock(),e.createElementBlock("div",{key:0,class:"filter-checkmark",onClick:e.withModifiers(Me=>y(X.id),["stop"])},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Tl)},null,8,["icon"])],8,bv)):e.createCommentVNode("",!0),e.createElementVNode("div",wv,[e.createElementVNode("div",kv,[e.createVNode(e.unref(B.IonIcon),{icon:x(X),class:"filter-icon"},null,8,["icon"])])]),e.createElementVNode("span",xv,e.toDisplayString(X.name),1)],42,yv)}),128))],512),e.createElementVNode("button",{onClick:P,class:"carousel-nav carousel-nav-right",disabled:l.value>=Math.max(0,S.value.length-4),"aria-label":"Next filters","data-testid":"btn-filter-carousel-next"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(ys)},null,8,["icon"])],8,Sv)]),e.createElementVNode("div",Ev,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Math.ceil(S.value.length/4),(X,ce)=>(e.openBlock(),e.createElementBlock("span",{key:ce,class:e.normalizeClass(["pagination-dot",{active:Math.floor(l.value/4)===ce}]),onClick:Me=>j(ce)},null,10,Vv))),128))])]),i.value?(e.openBlock(),e.createElementBlock("div",Cv,[e.createElementVNode("div",Nv,[e.createElementVNode("h4",null,e.toDisplayString(i.value.name),1),e.createElementVNode("div",_v,[M(i.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 ")),M(i.value.id)?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:D[0]||(D[0]=X=>y(i.value.id)),class:"remove-btn","data-testid":"btn-remove-selected-filter"}," Remove Filter ")):e.createCommentVNode("",!0),M(i.value.id)&&((G=i.value.params)==null?void 0:G.length)>0?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:D[1]||(D[1]=X=>C(i.value.id)),class:"reset-btn","data-testid":"btn-reset-selected-filter"}," Reset ")):e.createCommentVNode("",!0)])]),i.value.params&&i.value.params.length>0?(e.openBlock(),e.createElementBlock("div",Tv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value.params,X=>(e.openBlock(),e.createElementBlock("div",{key:X.id,class:"adjustment-control"},[!X.type||X.type==="slider"?(e.openBlock(),e.createElementBlock("div",Mv,[e.createElementVNode("label",Fv,e.toDisplayString(X.label||X.id),1),e.createElementVNode("div",Iv,[e.createVNode(e.unref(B.IonRange),{value:w(i.value.id,X.id),onIonChange:ce=>R(i.value.id,X.id,ce.detail.value),min:X.min,max:X.max,step:X.step||.01,color:"primary",class:"compact-slider",disabled:!M(i.value.id),"data-testid":`range-filter-${m(i.value.id)}-${m(X.id)}`,"aria-label":`Adjust ${X.label||X.id} for ${i.value.name}`},null,8,["value","onIonChange","min","max","step","disabled","data-testid","aria-label"]),e.createElementVNode("span",Bv,e.toDisplayString(N(w(i.value.id,X.id))),1)])])):X.type==="color"?(e.openBlock(),e.createElementBlock("div",Rv,[e.createElementVNode("label",Pv,e.toDisplayString(X.label||X.id),1),e.createElementVNode("div",$v,[e.createElementVNode("input",{type:"color",value:w(i.value.id,X.id),onInput:ce=>R(i.value.id,X.id,ce.target.value),disabled:!M(i.value.id),class:"color-input"},null,40,zv),e.createElementVNode("span",Av,e.toDisplayString(w(i.value.id,X.id)),1)])])):X.type==="toggle"?(e.openBlock(),e.createElementBlock("div",Dv,[e.createElementVNode("label",Uv,e.toDisplayString(X.label||X.id),1),e.createVNode(e.unref(B.IonToggle),{checked:!!w(i.value.id,X.id),onIonChange:ce=>R(i.value.id,X.id,ce.detail.checked),disabled:!M(i.value.id),color:"primary"},null,8,["checked","onIonChange","disabled"])])):X.type==="select"?(e.openBlock(),e.createElementBlock("div",Ov,[e.createElementVNode("label",Lv,e.toDisplayString(X.label||X.id),1),e.createElementVNode("select",{value:w(i.value.id,X.id),onChange:ce=>R(i.value.id,X.id,ce.target.value),disabled:!M(i.value.id),class:"select-input"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(X.options,ce=>(e.openBlock(),e.createElementBlock("option",{key:String(ce.value),value:ce.value},e.toDisplayString(ce.label),9,jv))),128))],40,Wv)])):e.createCommentVNode("",!0)]))),128))])):(e.openBlock(),e.createElementBlock("div",Xv," This filter has no adjustable parameters "))])):e.createCommentVNode("",!0)])}}}),Zs=_e(Zv,[["__scopeId","data-v-3144d0bd"]]);class Yv{constructor(o){this.pixiFilters=new Map,this.filterParams=new Map,this.filterTypes=new Map,this.filterIntensity=new Map,this.composition=o}setComposition(o){this.composition=o}mapMediablesToPIXI(o){switch(o.filterId){case"blur":return this.createBlurFilter(o.params);case"brightness":return this.createBrightnessFilter(o.params);case"contrast":return this.createContrastFilter(o.params);case"saturation":return this.createSaturationFilter(o.params);case"hue":return this.createHueFilter(o.params);case"vintage":return this.createVintageFilter(o.params);case"grayscale":return this.createGrayscaleFilter();case"sepia":return this.createSepiaFilter();default:return null}}createBlurFilter(o){var t,a;try{const r=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.BlurFilter;if(!r)return null;const i=new r;return i.blur=o.intensity||5,i.quality=o.quality||4,i}catch{return null}}createBrightnessFilter(o){var t,a;try{const r=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.ColorMatrixFilter;if(!r)return null;const i=new r;return i.brightness(o.value||1,!1),i}catch{return null}}createContrastFilter(o){var t,a;try{const r=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.ColorMatrixFilter;if(!r)return null;const i=new r;return i.contrast(o.value||1,!1),i}catch{return null}}createSaturationFilter(o){var t,a;try{const r=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.ColorMatrixFilter;if(!r)return null;const i=new r;return i.saturate(o.value||1,!1),i}catch{return null}}createHueFilter(o){var t,a;try{const r=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.ColorMatrixFilter;if(!r)return null;const i=new r;return i.hue(o.rotation||0,!1),i}catch{return null}}createVintageFilter(o){var t,a;try{const r=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.ColorMatrixFilter;if(!r)return null;const i=new r;return i.vintage(!1),o.intensity&&(i.contrast(1.2,!1),i.saturate(.8,!1)),i}catch{return null}}createGrayscaleFilter(){var o,t;try{const a=(t=(o=window.PIXI)==null?void 0:o.filters)==null?void 0:t.ColorMatrixFilter;if(!a)return null;const r=new a;return r.desaturate(),r}catch{return null}}createSepiaFilter(){var o,t;try{const a=(t=(o=window.PIXI)==null?void 0:o.filters)==null?void 0:t.ColorMatrixFilter;if(!a)return null;const r=new a;return r.sepia(!1),r}catch{return null}}async applyFilters(o){if(this.composition){this.clearFilters();for(const t of o){const a=this.mapMediablesToPIXI(t);a&&(this.pixiFilters.set(t.id,a),this.filterParams.set(t.id,t.params),this.filterTypes.set(t.id,t.filterId),this.filterIntensity.set(t.id,t.intensity),await this.applyToComposition(t.id,a))}}}async applyToComposition(o,t){try{this.composition.applyFilter&&await this.composition.applyFilter(o,t)}catch{}}updateFilterParams(o,t){var r;const a=this.pixiFilters.get(o);a&&(this.filterParams.set(o,t),"blur"in a&&(a.blur=t.intensity||a.blur),"brightness"in a&&a.brightness(t.value||1,!1),"contrast"in a&&a.contrast(t.value||1,!1),"saturate"in a&&a.saturate(t.value||1,!1),"hue"in a&&a.hue(t.rotation||0,!1),(r=this.composition)!=null&&r.update&&this.composition.update())}getFilterParams(o){return this.filterParams.get(o)||{}}removeFilter(o){var t;this.pixiFilters.delete(o),this.filterParams.delete(o),this.filterTypes.delete(o),this.filterIntensity.delete(o),(t=this.composition)!=null&&t.removeFilter&&this.composition.removeFilter(o)}clearFilters(){var o;this.pixiFilters.clear(),this.filterParams.clear(),this.filterTypes.clear(),this.filterIntensity.clear(),(o=this.composition)!=null&&o.clearFilters&&this.composition.clearFilters()}getActiveFilters(){return Array.from(this.pixiFilters.values())}exportFilterConfig(){const o=[];return this.pixiFilters.forEach((t,a)=>{const r=this.filterParams.get(a)??{},i=this.filterTypes.get(a)??"unknown",s=this.filterIntensity.get(a)??1;o.push({id:a,filterId:i,params:r,intensity:s})}),o}async importFilterConfig(o){await this.applyFilters(o)}destroy(){this.clearFilters(),this.composition=null}}const Gv={class:"video-filter-preview"},Hv={class:"preview-title"},Jv={class:"filter-controls"},qv={class:"control-input"},Kv=["value","onInput","min","max","step"],Qv={class:"param-value"},eg={class:"preview-container"},tg={key:0,class:"filter-presets"},ng=["onClick"],og={class:"preview-actions"},ag=e.defineComponent({__name:"VideoFilterPreview",props:{filter:{},currentFrame:{},useVideoEngine:{type:Boolean,default:!1},composition:{}},emits:["update-params","apply"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(),i=e.ref(!1),s=e.ref({});let l,c,d=null,u=null;const p=e.computed(()=>{var g;return((g=t.filter)==null?void 0:g.paramRanges)||{}}),m=e.computed(()=>f.value.length>0),f=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(r.value){t.useVideoEngine&&t.composition&&(u=new Yv(t.composition));try{if(l=new Ae.Application,await l.init({width:r.value.clientWidth,height:r.value.clientHeight,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,canvas:r.value}),(g=t.currentFrame)!=null&&g.dataUrl){const C=await Ae.Assets.load(t.currentFrame.dataUrl);c=new Ae.Sprite(C);const A=Math.min(l.screen.width/c.texture.width,l.screen.height/c.texture.height);c.scale.set(A),c.anchor.set(.5),c.position.set(l.screen.width/2,l.screen.height/2),l.stage.addChild(c)}b()}catch{}}}function b(){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(C=>{}),d&&(d.destroy(),d=null),d=S(t.filter.id,s.value),d&&(c.filters=i.value?null:[d])}else d&&(d.destroy(),d=null),d=S(t.filter.id,s.value),d&&(c.filters=i.value?null:[d])}function S(g,C){switch(g){case"brightness":{const A=new Ae.ColorMatrixFilter,x=1+(C.value??0);return typeof A.brightness=="function"&&A.brightness(x,!1),A}case"contrast":{const A=new Ae.ColorMatrixFilter,x=C.value??1;return typeof A.contrast=="function"&&A.contrast(x,!1),A}case"saturation":{const A=new Ae.ColorMatrixFilter,x=C.value??1;return typeof A.saturate=="function"&&A.saturate(x,!1),A}case"hue":{const A=new Ae.ColorMatrixFilter,x=C.value??0;return typeof A.hue=="function"&&A.hue(x,!1),A}case"gaussian-blur":{const A=C.value??5;return new Ae.BlurFilter({strength:A,quality:4})}case"sepia":{const A=new Ae.ColorMatrixFilter;return typeof A.sepia=="function"&&A.sepia(!1),A}case"grayscale":{const A=new Ae.ColorMatrixFilter;return typeof A.desaturate=="function"&&A.desaturate(),A}default:return null}}function M(g,C){const A=C.target,x=Number.parseFloat(A.value),T=Number.isFinite(x)?x:0;s.value={...s.value,[g]:T},t.useVideoEngine&&u&&t.filter&&u.updateFilterParams(t.filter.id,s.value),a("update-params",s.value),b()}function E(g){return g.charAt(0).toUpperCase()+g.slice(1).replace(/_/g," ")}function y(g,C){var x;const A=typeof g=="number"?g:Number(g);return Number.isFinite(A)?C==="hue"||C==="angle"?`${A}°`:C==="value"&&((x=t.filter)==null?void 0:x.id)==="brightness"?`${Math.round((1+A)*100)}%`:Number.isInteger(A)?A.toString():A.toFixed(2):"0"}function h(){var g;s.value=((g=t.filter)==null?void 0:g.defaultParams)||{},a("update-params",s.value),b()}function w(g){s.value={...g.params},a("update-params",s.value),b()}function R(g){return JSON.stringify(g.params)===JSON.stringify(s.value)}function N(){a("apply")}return e.watch(()=>t.filter,g=>{g&&(s.value={...g.defaultParams},b())}),e.watch(()=>t.currentFrame,async g=>{if(g!=null&&g.dataUrl&&c){const C=await Ae.Assets.load(g.dataUrl);c.texture=C}}),e.watch(i,b),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,C)=>{var A;return e.openBlock(),e.createElementBlock("div",Gv,[e.createElementVNode("h4",Hv,e.toDisplayString((A=g.filter)==null?void 0:A.name)+" Settings",1),e.createElementVNode("div",Jv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,(x,T)=>(e.openBlock(),e.createElementBlock("div",{key:T,class:"control-group"},[e.createElementVNode("label",null,e.toDisplayString(E(T)),1),e.createElementVNode("div",qv,[e.createElementVNode("input",{type:"range",value:s.value[T],onInput:I=>M(T,I),min:x.min,max:x.max,step:x.step,class:"param-slider"},null,40,Kv),e.createElementVNode("span",Qv,e.toDisplayString(y(s.value[T],T)),1)])]))),128))]),e.createElementVNode("div",eg,[e.createElementVNode("canvas",{ref_key:"previewCanvas",ref:r,class:"preview-canvas"},null,512),e.createElementVNode("button",{class:"compare-button",onMousedown:C[0]||(C[0]=x=>i.value=!0),onMouseup:C[1]||(C[1]=x=>i.value=!1),onTouchstart:C[2]||(C[2]=x=>i.value=!0),onTouchend:C[3]||(C[3]=x=>i.value=!1)},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(ro)},null,8,["icon"]),C[4]||(C[4]=e.createTextVNode(" Hold to compare ",-1))],32)]),m.value?(e.openBlock(),e.createElementBlock("div",tg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,x=>(e.openBlock(),e.createElementBlock("button",{key:x.name,class:e.normalizeClass(["preset-button",{active:R(x)}]),onClick:T=>w(x)},e.toDisplayString(x.name),11,ng))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",og,[e.createElementVNode("button",{class:"action-button",onClick:h},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(So)},null,8,["icon"]),C[5]||(C[5]=e.createTextVNode(" Reset ",-1))]),e.createElementVNode("button",{class:"action-button primary",onClick:N},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Ml)},null,8,["icon"]),C[6]||(C[6]=e.createTextVNode(" Apply Filter ",-1))])])])}}}),Ys=_e(ag,[["__scopeId","data-v-3de3dd04"]]),rg={class:"export-settings"},ig={class:"setting-group"},sg={class:"setting-group"},lg={class:"estimated-size"},cg={key:0,class:"export-progress"},dg={class:"progress-header"},ug={class:"progress-percentage"},mg={class:"progress-time"},pg={class:"action-buttons"},fg=["disabled"],hg=["disabled"],vg=["disabled"],gg={class:"export-options"},yg=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(n,{emit:o}){const t=n,a=o,r=e.ref("1080p"),i=e.ref("mp4"),s=e.ref(!0),l=e.ref(!1),c=e.ref(0),d=e.ref(0),u=e.ref(0);let p=null;const m=e.computed(()=>{const h=({"360p":1,"480p":2.5,"720p":5,"1080p":8,"1440p":16,"2160p":35}[r.value]||8)*t.duration/8;return h<1e3?`~${Math.round(h)} MB`:`~${(h/1e3).toFixed(1)} GB`});function f(){t.isExporting?(a("cancel-export"),S()):v()}function v(){const E={quality:r.value,format:i.value,optimizeForWeb:s.value,includeWatermark:l.value};a("export",E),b()}function b(){c.value=Date.now(),d.value=0,p=window.setInterval(()=>{if(d.value=Math.floor((Date.now()-c.value)/1e3),t.exportProgress>0){const E=d.value/t.exportProgress*100;u.value=Math.max(0,E-d.value)}},1e3)}function S(){p&&(clearInterval(p),p=null)}function M(E){const y=Math.floor(E/60),h=Math.floor(E%60);return`${y}:${h.toString().padStart(2,"0")}`}return e.watch(()=>t.isExporting,E=>{E||S()}),e.onUnmounted(()=>{S()}),(E,y)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["editor-controls",{mobile:E.isMobile}])},[e.createElementVNode("div",rg,[y[10]||(y[10]=e.createElementVNode("h3",{class:"section-title"},"Export Settings",-1)),e.createElementVNode("div",ig,[y[7]||(y[7]=e.createElementVNode("label",null,"Quality",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":y[0]||(y[0]=h=>r.value=h),class:"setting-select"},[...y[6]||(y[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,r.value]])]),e.createElementVNode("div",sg,[y[9]||(y[9]=e.createElementVNode("label",null,"Format",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":y[1]||(y[1]=h=>i.value=h),class:"setting-select"},[...y[8]||(y[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,i.value]])]),e.createElementVNode("div",lg,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(pm)},null,8,["icon"]),e.createElementVNode("span",null,"Estimated size: "+e.toDisplayString(m.value),1)])]),E.isExporting?(e.openBlock(),e.createElementBlock("div",cg,[e.createElementVNode("div",dg,[y[11]||(y[11]=e.createElementVNode("span",null,"Exporting...",-1)),e.createElementVNode("span",ug,e.toDisplayString(E.exportProgress??0)+"%",1)]),e.createVNode(e.unref(B.IonProgressBar),{value:(E.exportProgress??0)/100},null,8,["value"]),e.createElementVNode("div",mg,[e.createElementVNode("span",null,e.toDisplayString(M(d.value))+" elapsed",1),e.createElementVNode("span",null,e.toDisplayString(M(u.value))+" remaining",1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",pg,[e.createElementVNode("button",{class:"control-button secondary",onClick:y[2]||(y[2]=h=>E.$emit("save-draft")),disabled:!E.canExport||E.isExporting},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Rl)},null,8,["icon"]),y[12]||(y[12]=e.createTextVNode(" Save Draft ",-1))],8,fg),e.createElementVNode("button",{class:"control-button secondary",onClick:y[3]||(y[3]=h=>E.$emit("reset")),disabled:E.isExporting},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(So)},null,8,["icon"]),y[13]||(y[13]=e.createTextVNode(" Reset ",-1))],8,hg),e.createElementVNode("button",{class:"control-button primary",onClick:f,disabled:!E.canExport&&!E.isExporting,"data-testid":"video-export-button"},[e.createVNode(e.unref(B.IonIcon),{icon:E.isExporting?e.unref(bo):e.unref(Na)},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(E.isExporting?"Cancel":"Export Video"),1)],8,vg)]),e.createElementVNode("div",gg,[e.createVNode(e.unref(B.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonCheckbox),{modelValue:s.value,"onUpdate:modelValue":y[4]||(y[4]=h=>s.value=h)},null,8,["modelValue"]),e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...y[14]||(y[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":y[5]||(y[5]=h=>l.value=h)},null,8,["modelValue"]),e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...y[15]||(y[15]=[e.createTextVNode("Include watermark",-1)])]),_:1})]),_:1})])],2))}}),Gs=_e(yg,[["__scopeId","data-v-e1338d5e"]]),bg={class:"thumbnail-picker"},wg={class:"thumbnail-grid"},kg=["onClick"],xg=["src","alt"],Sg={key:1,class:"thumbnail-placeholder"},Eg={class:"thumbnail-time"},Vg={class:"custom-selector"},Cg={class:"time-input-group"},Ng=["max"],_g={class:"time-value"},Tg=["disabled"],Mg={class:"picker-actions"},Fg=["disabled"],Ig=e.defineComponent({__name:"ThumbnailPicker",props:{mediaUuid:{},duration:{},currentTime:{default:0}},emits:["select","cancel"],setup(n,{emit:o}){const t=n,a=o,r=e.ref([]),i=e.ref(-1),s=e.ref(t.currentTime),l=e.ref(!1);function c(){const M=[];if(t.duration<=10)for(let y=0;y<Math.min(9,t.duration);y++)M.push(y);else{const y=t.duration/10;for(let h=1;h<=9;h++)M.push(y*h)}return M}async function d(M){try{const E=document.createElement("video");return E.crossOrigin="anonymous",E.src=await u(),new Promise(y=>{E.addEventListener("loadedmetadata",()=>{E.currentTime=M}),E.addEventListener("seeked",()=>{const h=document.createElement("canvas");h.width=E.videoWidth,h.height=E.videoHeight;const w=h.getContext("2d");w?(w.drawImage(E,0,0),y(h.toDataURL("image/jpeg",.8))):y(null),E.remove()}),E.addEventListener("error",()=>{y(null),E.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 p(){const M=c();r.value=M.map(y=>({time:y,loading:!0}));const E=3;for(let y=0;y<r.value.length;y+=E){const h=r.value.slice(y,y+E);await Promise.all(h.map(async w=>{const R=await d(w.time);R&&(w.dataUrl=R),w.loading=!1}))}}function m(M){i.value=M,s.value=r.value[M].time}function f(){i.value=-1}async function v(){l.value=!0;try{const M=await d(s.value);if(M){const E=r.value.findIndex(y=>Math.abs(y.time-s.value)<.1);E>=0?(r.value[E].dataUrl=M,i.value=E):(r.value.push({time:s.value,dataUrl:M}),i.value=r.value.length-1,r.value.sort((y,h)=>y.time-h.time),i.value=r.value.findIndex(y=>y.time===s.value))}}finally{l.value=!1}}function b(){const M=i.value>=0?r.value[i.value].time:s.value;a("select",M)}function S(M){const E=Math.floor(M/60),y=Math.floor(M%60),h=Math.floor(M%1*100);return E>0?`${E}:${y.toString().padStart(2,"0")}.${h.toString().padStart(2,"0")}`:`${y}.${h.toString().padStart(2,"0")}s`}return e.onMounted(()=>{p()}),(M,E)=>(e.openBlock(),e.createElementBlock("div",bg,[E[5]||(E[5]=e.createElementVNode("h4",{class:"picker-title"},"Select Video Thumbnail",-1)),e.createElementVNode("div",wg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(y,h)=>(e.openBlock(),e.createElementBlock("div",{key:h,class:e.normalizeClass(["thumbnail-item",{selected:i.value===h}]),onClick:w=>m(h)},[y.dataUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:y.dataUrl,alt:`Frame at ${S(y.time)}`},null,8,xg)):(e.openBlock(),e.createElementBlock("div",Sg,[e.createVNode(e.unref(B.IonSpinner),{name:"crescent"})])),e.createElementVNode("div",Eg,e.toDisplayString(S(y.time)),1)],10,kg))),128))]),e.createElementVNode("div",Vg,[E[3]||(E[3]=e.createElementVNode("label",null,"Custom time:",-1)),e.createElementVNode("div",Cg,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":E[0]||(E[0]=y=>s.value=y),min:0,max:M.duration,step:.1,onInput:f,class:"time-slider"},null,40,Ng),[[e.vModelText,s.value]]),e.createElementVNode("span",_g,e.toDisplayString(S(s.value)),1)]),e.createElementVNode("button",{class:"capture-button",onClick:v,disabled:l.value},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(tm)},null,8,["icon"]),E[2]||(E[2]=e.createTextVNode(" Capture Frame ",-1))],8,Tg)]),e.createElementVNode("div",Mg,[e.createElementVNode("button",{class:"action-button",onClick:E[1]||(E[1]=y=>M.$emit("cancel"))}," Cancel "),e.createElementVNode("button",{class:"action-button primary",onClick:b,disabled:i.value===-1},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Ml)},null,8,["icon"]),E[4]||(E[4]=e.createTextVNode(" Set Thumbnail ",-1))],8,Fg)])]))}}),Bg=_e(Ig,[["__scopeId","data-v-336c322c"]]),Rg={class:"text-overlay-panel p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},Pg={class:"mb-4"},$g={class:"space-y-2 max-h-64 overflow-y-auto"},zg={class:"flex items-center justify-between"},Ag={class:"flex-1"},Dg={class:"font-medium text-gray-900 dark:text-white"},Ug={class:"text-sm text-gray-500 dark:text-gray-400"},Og={class:"flex items-center space-x-2"},Lg=["onClick"],Wg=["onClick"],jg={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},Xg={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},Zg={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},Yg={class:"space-y-4"},Gg={class:"grid grid-cols-2 gap-4"},Hg={class:"grid grid-cols-2 gap-4"},Jg={key:0,class:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},qg={class:"grid grid-cols-2 gap-3"},Kg={class:"flex justify-end space-x-3 mt-6"},Qg=e.defineComponent({__name:"TextOverlayPanel",props:{overlays:{}},emits:["add-overlay","update-overlay","remove-overlay"],setup(n,{emit:o}){const t=o,a=e.ref(!1),r=e.ref(null),i=()=>({id:"",text:"",fontSize:24,color:"#ffffff",position:"center",startTime:0,duration:5,animationType:"",animationDuration:1,animationEasing:"linear"}),s=e.reactive(i());function l(m){Object.assign(s,m),r.value=m}function c(){a.value=!1,r.value=null,Object.assign(s,i())}function d(){const m={text:s.text,fontSize:s.fontSize,color:s.color,position:s.position,startTime:s.startTime,duration:s.duration};if(s.animationType&&(m.animation={type:s.animationType},s.animationDuration!==void 0&&(m.animation.duration=s.animationDuration),s.animationEasing&&(m.animation.easing=s.animationEasing),m.animation))switch(s.animationType){case"rotate":m.animation.rotation={from:0,to:360};break;case"scale":m.animation.scale={from:.5,to:1};break;case"slide":m.animation.translate={fromX:-100,toX:0,fromY:0,toY:0};break}r.value?t("update-overlay",r.value.id,m):t("add-overlay",m),c()}function u(m){confirm("Are you sure you want to remove this text overlay?")&&t("remove-overlay",m)}function p(m){const f=Math.floor(m/60),v=Math.floor(m%60);return`${f}:${v.toString().padStart(2,"0")}`}return(m,f)=>(e.openBlock(),e.createElementBlock("div",Rg,[e.createElementVNode("div",Pg,[f[11]||(f[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Text Overlays ",-1)),e.createElementVNode("button",{onClick:f[0]||(f[0]=v=>a.value=!0),class:"w-full px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"},[...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 Text Overlay ",-1)])])]),e.createElementVNode("div",$g,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.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",zg,[e.createElementVNode("div",Ag,[e.createElementVNode("div",Dg,e.toDisplayString(v.text.substring(0,30))+e.toDisplayString(v.text.length>30?"...":""),1),e.createElementVNode("div",Ug,e.toDisplayString(p(v.startTime??0))+" - "+e.toDisplayString(p((v.startTime||0)+(v.duration||5))),1)]),e.createElementVNode("div",Og,[e.createElementVNode("button",{onClick:b=>l(v),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Edit"},[...f[12]||(f[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,Lg),e.createElementVNode("button",{onClick:b=>u(v.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...f[13]||(f[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,Wg)])])]))),128)),m.overlays.length===0?(e.openBlock(),e.createElementBlock("div",jg," No text overlays added yet ")):e.createCommentVNode("",!0)]),a.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(c,["self"])},[e.createElementVNode("div",Xg,[e.createElementVNode("h4",Zg,e.toDisplayString(r.value?"Edit":"Add")+" Text Overlay ",1),e.createElementVNode("div",Yg,[e.createElementVNode("div",null,[f[14]||(f[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":f[1]||(f[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",Gg,[e.createElementVNode("div",null,[f[15]||(f[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":f[2]||(f[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,[f[16]||(f[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":f[3]||(f[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,[f[18]||(f[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":f[4]||(f[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"},[...f[17]||(f[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",Hg,[e.createElementVNode("div",null,[f[19]||(f[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":f[5]||(f[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,[f[20]||(f[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":f[6]||(f[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,[f[22]||(f[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":f[7]||(f[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"},[...f[21]||(f[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",Jg,[f[26]||(f[26]=e.createElementVNode("div",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Animation Settings ",-1)),e.createElementVNode("div",qg,[e.createElementVNode("div",null,[f[23]||(f[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":f[8]||(f[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,[f[25]||(f[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":f[9]||(f[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"},[...f[24]||(f[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",Kg,[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(r.value?"Save":"Add"),1)])])])):e.createCommentVNode("",!0)]))}}),Hs=_e(Qg,[["__scopeId","data-v-f86e688c"]]),go=class go{constructor(o){this.transitions=new Map,this.nextId=0,this.composition=o}async applyTransition(o,t,a){const r=`transition-${this.nextId++}`,i=Math.round(a.duration*30),s=a.easing||"linear",l=this.findTrackForClip(o),c=this.findTrackForClip(t);if(!l||!c)throw new Error("Clips must be added to composition before applying transitions");const d=o.stop.frames-i,u=o.stop.frames;switch(a.type){case"fade":await this.applyFadeTransition(o,t,d,u,s);break;case"dissolve":case"cross-fade":await this.applyCrossFadeTransition(o,t,d,u,s);break;case"wipe-left":case"wipe-right":case"wipe-up":case"wipe-down":await this.applyWipeTransition(o,t,a.type,d,u,s);break;case"slide-left":case"slide-right":case"slide-up":case"slide-down":await this.applySlideTransition(o,t,a.type,d,u,s);break;case"zoom-in":case"zoom-out":await this.applyZoomTransition(o,t,a.type,d,u,s);break;case"dip-to-black":case"dip-to-white":await this.applyDipTransition(o,t,a.type,d,u,s);break}return this.transitions.set(r,a),r}async applyFadeTransition(o,t,a,r,i){if(!this.isVideoClip(o)||!this.isVideoClip(t))throw new Error("Fade transitions require VideoClip instances");o.alpha=new Se([a,r],[1,0],{easing:i}),t.alpha=new Se([a,r],[0,1],{easing:i}),t.start=ve.fromFrames(a)}async applyCrossFadeTransition(o,t,a,r,i){if(!this.isVideoClip(o)||!this.isVideoClip(t))throw new Error("Cross-fade transitions require VideoClip instances");o.alpha=new Se([a,r],[1,0],{easing:i}),t.alpha=new Se([a,r],[0,1],{easing:i}),t.start=ve.fromFrames(a)}async applyWipeTransition(o,t,a,r,i,s){if(!this.isVideoClip(o)||!this.isVideoClip(t))throw new Error("Wipe transitions require VideoClip instances");const l={x:0,y:0},c={x:0,y:0};switch(a){case"wipe-left":l.x=new Se([r,i],[0,-1920],{easing:s}),c.x=new Se([r,i],[1920,0],{easing:s});break;case"wipe-right":l.x=new Se([r,i],[0,1920],{easing:s}),c.x=new Se([r,i],[-1920,0],{easing:s});break;case"wipe-up":l.y=new Se([r,i],[0,-1080],{easing:s}),c.y=new Se([r,i],[1080,0],{easing:s});break;case"wipe-down":l.y=new Se([r,i],[0,1080],{easing:s}),c.y=new Se([r,i],[-1080,0],{easing:s});break}o.translate=l,t.translate=c,t.start=ve.fromFrames(r)}async applySlideTransition(o,t,a,r,i,s){if(!this.isVideoClip(o)||!this.isVideoClip(t))throw new Error("Slide transitions require VideoClip instances");const l={x:0,y:0},c={x:0,y:0};switch(a){case"slide-left":l.x=new Se([r,i],[0,-1920],{easing:s}),c.x=new Se([r,i],[1920,0],{easing:s});break;case"slide-right":l.x=new Se([r,i],[0,1920],{easing:s}),c.x=new Se([r,i],[-1920,0],{easing:s});break;case"slide-up":l.y=new Se([r,i],[0,-1080],{easing:s}),c.y=new Se([r,i],[1080,0],{easing:s});break;case"slide-down":l.y=new Se([r,i],[0,1080],{easing:s}),c.y=new Se([r,i],[-1080,0],{easing:s});break}o.translate=l,t.translate=c,t.start=ve.fromFrames(r)}async applyZoomTransition(o,t,a,r,i,s){if(!this.isVideoClip(o)||!this.isVideoClip(t))throw new Error("Zoom transitions require VideoClip instances");a==="zoom-in"?(o.scale=new Se([r,i],[1,2],{easing:s}),o.alpha=new Se([r,i],[1,0],{easing:s}),t.scale=new Se([r,i],[.5,1],{easing:s}),t.alpha=new Se([r,i],[0,1],{easing:s})):(o.scale=new Se([r,i],[1,.5],{easing:s}),o.alpha=new Se([r,i],[1,0],{easing:s}),t.scale=new Se([r,i],[2,1],{easing:s}),t.alpha=new Se([r,i],[0,1],{easing:s})),t.start=ve.fromFrames(r)}async applyDipTransition(o,t,a,r,i,s){if(!this.isVideoClip(o)||!this.isVideoClip(t))throw new Error("Dip transitions require VideoClip instances");const l=Math.round((r+i)/2),c=a==="dip-to-black"?"#000000":"#ffffff",d=await zr.fromColor(c),u=new Ph(d,{start:ve.fromFrames(r),stop:ve.fromFrames(i)});o.alpha=new Se([r,l],[1,0],{easing:s}),u.alpha=new Se([r,l,i],[0,1,0],{easing:s}),t.alpha=new Se([l,i],[0,1],{easing:s}),await this.composition.add(u),t.start=ve.fromFrames(l)}findTrackForClip(o){for(const t of this.composition.tracks)if(t.clips.includes(o))return t}removeTransition(o){this.transitions.delete(o)}getTransitions(){return new Map(this.transitions)}static getAvailableTransitions(){return[...go.TRANSITIONS]}static previewTransition(o){return go.TRANSITIONS.find(t=>t.type===o)}isVideoClip(o){return"alpha"in o&&"scale"in o&&"translate"in o}};go.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 xa=go;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"},r1={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},i1={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"},b1=["onClick"],w1=e.defineComponent({__name:"TransitionSelector",props:{selectedClips:{},appliedTransitions:{}},emits:["apply-transition","remove-transition","preview-transition"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(xa.getAvailableTransitions()),i=e.ref(null),s=e.ref(.5),l=e.ref("linear"),c=e.computed(()=>i.value&&t.selectedClips&&t.selectedClips.length>=2);function d(v){i.value=v}function u(){if(!i.value||!c.value)return;const v={type:i.value.type,duration:s.value,easing:l.value};a("apply-transition",v),i.value=null}function p(){if(!i.value)return;const v={type:i.value.type,duration:s.value,easing:l.value};a("preview-transition",v)}function m(v){a("remove-transition",v)}function f(v){return["fade","wipe","slide","zoom"].some(b=>v.includes(b))}return(v,b)=>(e.openBlock(),e.createElementBlock("div",e1,[b[9]||(b[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(r.value,S=>{var M;return e.openBlock(),e.createElementBlock("div",{key:S.type,onClick:E=>d(S),class:e.normalizeClass(["transition-item cursor-pointer rounded-lg p-3 border-2 transition-all",((M=i.value)==null?void 0:M.type)===S.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,[f(S.type)?(e.openBlock(),e.createElementBlock("svg",a1,[S.type.includes("fade")?(e.openBlock(),e.createElementBlock("path",r1)):S.type.includes("wipe")?(e.openBlock(),e.createElementBlock("path",i1)):S.type.includes("slide")?(e.openBlock(),e.createElementBlock("path",s1)):S.type.includes("zoom")?(e.openBlock(),e.createElementBlock("path",l1)):(e.openBlock(),e.createElementBlock("path",c1))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",d1,e.toDisplayString(S.name),1)],10,n1)}),128))]),i.value?(e.openBlock(),e.createElementBlock("div",u1,[b[6]||(b[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,[b[3]||(b[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":b[0]||(b[0]=S=>s.value=S),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":b[1]||(b[1]=S=>s.value=S),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,[b[5]||(b[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":b[2]||(b[2]=S=>l.value=S),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"},[...b[4]||(b[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:p,disabled:!i.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,[b[8]||(b[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,(S,M)=>(e.openBlock(),e.createElementBlock("div",{key:M,class:"flex items-center justify-between p-2 bg-gray-50 dark:bg-gray-700 rounded"},[e.createElementVNode("div",y1,e.toDisplayString(S.name)+" ("+e.toDisplayString(S.duration)+"s) ",1),e.createElementVNode("button",{onClick:E=>m(M),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded"},[...b[7]||(b[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,b1)]))),128))])])):e.createCommentVNode("",!0),b[10]||(b[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))]))}}),Js=_e(w1,[["__scopeId","data-v-5ef1b100"]]),k1={class:"audio-track-manager p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},x1={class:"mb-4"},S1={class:"mb-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},E1={class:"flex items-center justify-between mb-2"},V1={class:"text-sm text-gray-600 dark:text-gray-400"},C1={class:"flex items-center space-x-2"},N1={class:"space-y-3 max-h-64 overflow-y-auto"},_1={class:"flex items-center justify-between mb-2"},T1={class:"font-medium text-gray-900 dark:text-white"},M1={class:"flex items-center space-x-2"},F1=["onClick","title"],I1={key:0,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},B1={key:1,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},R1=["onClick"],P1=["onClick"],$1={class:"flex items-center space-x-2"},z1={class:"text-xs text-gray-500 dark:text-gray-400 w-10"},A1=["value","onInput","disabled"],D1={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},U1={key:0,class:"ml-2"},O1={key:1,class:"ml-2"},L1={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"},j1={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},X1={class:"space-y-4"},Z1={class:"space-y-2"},Y1={class:"flex items-center"},G1={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},H1={class:"grid grid-cols-2 gap-4"},J1={class:"grid grid-cols-2 gap-4"},q1={class:"flex items-center"},K1={class:"flex justify-end space-x-3 mt-6"},Q1=["disabled"],ey=e.defineComponent({__name:"AudioTrackManager",props:{audioLayers:{},masterVolume:{}},emits:["add-track","update-track","remove-track","update-volume","toggle-mute","update-master-volume"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(!1),i=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(y){const h=y.target;h.files&&h.files[0]&&(c.sourceFile=h.files[0],c.name=c.name||h.files[0].name.replace(/\.[^/.]+$/,""))}function p(y){Object.assign(c,y),i.value=y}function m(){r.value=!1,i.value=null,Object.assign(c,l())}function f(){if(!d.value)return;const y={source:c.sourceFile??c.sourceUrl??"",name:c.name,volume:c.volume,startTime:c.startTime,loop:c.loop};c.duration!==void 0&&(y.duration=c.duration),c.fadeIn>0&&(y.fadeIn=c.fadeIn),c.fadeOut>0&&(y.fadeOut=c.fadeOut),i.value?a("update-track",i.value.id,y):a("add-track",y),m()}function v(y){confirm("Are you sure you want to remove this audio track?")&&a("remove-track",y)}function b(y,h){const w=h.target,R=parseFloat(w.value);a("update-volume",y.id,R)}function S(y){a("toggle-mute",y.id,!y.muted)}function M(){a("update-master-volume",s.value)}function E(y){const h=Math.floor(y/60),w=Math.floor(y%60);return`${h}:${w.toString().padStart(2,"0")}`}return(y,h)=>(e.openBlock(),e.createElementBlock("div",k1,[e.createElementVNode("div",x1,[h[11]||(h[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Audio Tracks ",-1)),e.createElementVNode("button",{onClick:h[0]||(h[0]=w=>r.value=!0),class:"w-full px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors"},[...h[10]||(h[10]=[e.createElementVNode("svg",{class:"w-5 h-5 inline-block mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),e.createTextVNode(" Add Audio Track ",-1)])])]),e.createElementVNode("div",S1,[e.createElementVNode("div",E1,[h[12]||(h[12]=e.createElementVNode("label",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"}," Master Volume ",-1)),e.createElementVNode("span",V1,e.toDisplayString(Math.round(s.value*100))+"% ",1)]),e.createElementVNode("div",C1,[h[13]||(h[13]=e.createElementVNode("svg",{class:"w-4 h-4 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20"},[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM12.293 7.293a1 1 0 011.414 0L15 8.586l1.293-1.293a1 1 0 111.414 1.414L16.414 10l1.293 1.293a1 1 0 01-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 01-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[1]||(h[1]=w=>s.value=w),onInput:M,type:"range",min:"0",max:"1",step:"0.01",class:"flex-1"},null,544),[[e.vModelText,s.value,void 0,{number:!0}]]),h[14]||(h[14]=e.createElementVNode("svg",{class:"w-4 h-4 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20"},[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM14.657 2.929a1 1 0 011.414 0l3 3a1 1 0 010 1.414l-3 3a1 1 0 01-1.414-1.414L16.586 7l-1.929-1.929a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1))])]),e.createElementVNode("div",N1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.audioLayers,w=>(e.openBlock(),e.createElementBlock("div",{key:w.id,class:"p-3 border border-gray-200 dark:border-gray-700 rounded-lg"},[e.createElementVNode("div",_1,[e.createElementVNode("div",T1,e.toDisplayString(w.name),1),e.createElementVNode("div",M1,[e.createElementVNode("button",{onClick:R=>S(w),class:e.normalizeClass(["p-1 rounded",w.muted?"text-red-600 bg-red-50 dark:bg-red-900":"text-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700"]),title:w.muted?"Unmute":"Mute"},[w.muted?(e.openBlock(),e.createElementBlock("svg",B1,[...h[16]||(h[16]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM12.293 7.293a1 1 0 011.414 0L15 8.586l1.293-1.293a1 1 0 111.414 1.414L16.414 10l1.293 1.293a1 1 0 01-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 01-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",I1,[...h[15]||(h[15]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM14.657 2.929a1 1 0 011.414 0l3 3a1 1 0 010 1.414l-3 3a1 1 0 01-1.414-1.414L16.586 7l-1.929-1.929a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)])]))],10,F1),e.createElementVNode("button",{onClick:R=>p(w),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Settings"},[...h[17]||(h[17]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})],-1)])],8,R1),e.createElementVNode("button",{onClick:R=>v(w.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...h[18]||(h[18]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])],8,P1)])]),e.createElementVNode("div",$1,[e.createElementVNode("span",z1,e.toDisplayString(Math.round((w.volume||1)*100))+"% ",1),e.createElementVNode("input",{value:w.volume||1,onInput:R=>b(w,R),type:"range",min:"0",max:"1",step:"0.01",class:"flex-1",disabled:w.muted},null,40,A1)]),e.createElementVNode("div",D1,[e.createTextVNode(e.toDisplayString(E(w.startTime||0))+" - "+e.toDisplayString(E((w.startTime||0)+(w.duration||0)))+" ",1),w.fadeIn?(e.openBlock(),e.createElementBlock("span",U1,"Fade In: "+e.toDisplayString(w.fadeIn)+"s",1)):e.createCommentVNode("",!0),w.fadeOut?(e.openBlock(),e.createElementBlock("span",O1,"Fade Out: "+e.toDisplayString(w.fadeOut)+"s",1)):e.createCommentVNode("",!0)])]))),128)),y.audioLayers.length===0?(e.openBlock(),e.createElementBlock("div",L1," No audio tracks added yet ")):e.createCommentVNode("",!0)]),r.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(m,["self"])},[e.createElementVNode("div",W1,[e.createElementVNode("h4",j1,e.toDisplayString(i.value?"Edit":"Add")+" Audio Track ",1),e.createElementVNode("div",X1,[e.createElementVNode("div",null,[h[20]||(h[20]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Audio Source ",-1)),e.createElementVNode("div",Z1,[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",Y1,[h[19]||(h[19]=e.createElementVNode("span",{class:"text-sm text-gray-500 dark:text-gray-400 mr-2"},"or URL:",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[2]||(h[2]=w=>c.sourceUrl=w),type:"url",placeholder:"https://example.com/audio.mp3",class:"flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.sourceUrl]])])])]),e.createElementVNode("div",null,[h[21]||(h[21]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Track Name ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[3]||(h[3]=w=>c.name=w),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",G1," Volume: "+e.toDisplayString(Math.round(c.volume*100))+"% ",1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[4]||(h[4]=w=>c.volume=w),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",H1,[e.createElementVNode("div",null,[h[22]||(h[22]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Start Time (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[5]||(h[5]=w=>c.startTime=w),type:"number",min:"0",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.startTime,void 0,{number:!0}]])]),e.createElementVNode("div",null,[h[23]||(h[23]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Duration (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[6]||(h[6]=w=>c.duration=w),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",J1,[e.createElementVNode("div",null,[h[24]||(h[24]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Fade In (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[7]||(h[7]=w=>c.fadeIn=w),type:"number",min:"0",max:"10",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.fadeIn,void 0,{number:!0}]])]),e.createElementVNode("div",null,[h[25]||(h[25]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Fade Out (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[8]||(h[8]=w=>c.fadeOut=w),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":h[9]||(h[9]=w=>c.loop=w),type:"checkbox",id:"loop-checkbox",class:"mr-2 rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"},null,512),[[e.vModelCheckbox,c.loop]]),h[26]||(h[26]=e.createElementVNode("label",{for:"loop-checkbox",class:"text-sm text-gray-700 dark:text-gray-300"}," Loop audio track ",-1))])]),e.createElementVNode("div",K1,[e.createElementVNode("button",{onClick:m,class:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"}," Cancel "),e.createElementVNode("button",{onClick:f,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(i.value?"Save":"Add"),11,Q1)])])])):e.createCommentVNode("",!0)]))}}),qs=_e(ey,[["__scopeId","data-v-593719ac"]]);function Ks(n){var s,l;ty(n);const o=ny(n.clips),t=[],a=oy(n),r=ay(n),i={version:"1.0",source:{media_uuid:n.mediaUuid,duration:n.originalDuration,original_width:((s=n.media)==null?void 0:s.width)||1920,original_height:((l=n.media)==null?void 0:l.height)||1080},timeline:o,filters:t,audio:a,output:r,metadata:{created_at:new Date().toISOString(),editor_version:"2.0.0"}};return n.textOverlays&&(i.textOverlays=n.textOverlays),n.audioTracks&&(i.audioTracks=n.audioTracks.filter(c=>typeof c.source=="string")),i}function ty(n){if(!n.mediaUuid)throw new Error("Media UUID is required");if(!n.clips||n.clips.length===0)throw new Error("At least one clip is required");const o=[...n.clips].sort((t,a)=>t.timelineStart-a.timelineStart);for(let t=1;t<o.length;t++)if(o[t].timelineStart<o[t-1].timelineEnd)throw new Error(`Clips ${o[t-1].id} and ${o[t].id} overlap on timeline`)}function ny(n){return n.map(o=>{const t=o.speed||1,a=typeof o.sourceIn=="number"&&!Number.isNaN(o.sourceIn),r=typeof o.sourceOut=="number"&&!Number.isNaN(o.sourceOut),i=Math.max(0,o.timelineEnd-o.timelineStart),s=o.sourceOffset??o.trimStart??0;let l=Number(a?o.sourceIn:s),c=r?Number(o.sourceOut):Number(s)+i/t;return c>l||(c=l+Math.max(.033,i/Math.max(1e-6,t))),{id:o.id,type:"clip",timelineStart:o.timelineStart,timelineEnd:o.timelineEnd,sourceIn:l,sourceOut:c,speed:t,filters:o.filters?[...o.filters]:[]}})}function oy(n){const o={volume:n.audioVolume,muted:n.audioVolume===0};return n.audioFadeIn>0&&(o.fadeIn=n.audioFadeIn),n.audioFadeOut>0&&(o.fadeOut=n.audioFadeOut),o}function ay(n){var i;const o={"360p":{bitrate:1e6},"480p":{bitrate:25e5},"720p":{bitrate:5e6},"1080p":{bitrate:8e6},"1440p":{bitrate:16e6},"2160p":{bitrate:35e6}},t=o[n.exportQuality]||o["1080p"],a=(i=n.media)==null?void 0:i.frame_rate,r=a&&Number.isFinite(a)&&a>0?a:30;return{format:n.exportFormat||"mp4",codec:"h264",quality:n.exportQuality||"1080p",fps:r,bitrate:t.bitrate}}function ry(n,o,t){var Be,De;const a=typeof n=="string"&&n.trim()!==""?n.trim():`temp-${Date.now()}`,r=e.reactive({mediaUuid:a,clips:[],playheadPosition:0,totalDuration:0,originalDuration:0,filters:[],audioVolume:1,audioFadeIn:0,audioFadeOut:0,exportQuality:"1080p",exportFormat:"mp4",hasChanges:!1,isPlaying:!1,zoomLevel:100}),i=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),p=e.shallowRef(null),m=new fc(30),f=e.ref(30),v=e.ref(!1),b=e.ref(!1);o&&o.timeline&&o.timeline.length>0?(N(o),(Be=o.output)!=null&&Be.fps&&(f.value=o.output.fps,m.setFps(f.value))):(h(),o&&((De=o.output)!=null&&De.fps&&(f.value=o.output.fps,m.setFps(f.value)),o.audio&&(r.audioVolume=o.audio.volume||1,r.audioFadeIn=o.audio.fadeIn||0,r.audioFadeOut=o.audio.fadeOut||0),o.output&&(r.exportFormat=o.output.format||"mp4",r.exportQuality=o.output.quality||"1080p")));const S=e.ref(1),M=e.computed(()=>r.selectedClipId?r.clips.find(Y=>Y.id===r.selectedClipId)??null:null);e.watch(M,Y=>{S.value=(Y==null?void 0:Y.speed)??1},{immediate:!0});const E=e.computed(()=>s.value.length>0),y=e.computed(()=>l.value.length>0);function h(){const Y=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0?t.duration:1;t&&(r.media=t),r.originalDuration=Y,r.totalDuration=Y;const ie=de(),we={id:ie,type:"clip",timelineStart:0,timelineEnd:Y,sourceIn:0,sourceOut:Y,sourceMinIn:0,sourceMaxOut:Y,speed:1};r.clips=[we],r.selectedClipId=ie,c.value=ie,!(t||a.startsWith("temp-"))&&(async()=>{try{const Ve=await fetch(`/api/v1/video/${encodeURIComponent(a)}`);if(!Ve.ok)throw new Error(`Failed to fetch media: ${Ve.status}`);const Le=await Ve.json(),yt=typeof Le=="object"&&Le!==null&&"data"in Le?Le.data:Le;if(!yt||typeof yt!="object")throw new Error("Failed to parse media payload");const dt=yt;r.media=dt;const Vt=typeof dt.duration=="number"&&dt.duration>0?dt.duration:Y;if(r.hasChanges||r.clips.length!==1||r.clips[0].id!==ie)return;r.originalDuration=Vt,r.totalDuration=Vt;const Ge=r.clips[0];Ge.timelineStart=0,Ge.timelineEnd=Vt,Ge.sourceIn=0,Ge.sourceOut=Vt,Ge.sourceMinIn=0,Ge.sourceMaxOut=Vt,L(),d=!0}catch{}})()}function w(Y,ie){if(Y.originalDuration!==1)return;Y.originalDuration=ie,Y.totalDuration===1&&(Y.totalDuration=ie);const we=Y.clips[0],Ve=!o&&Y.clips.length===1&&we!==void 0&&we.timelineStart===0&&we.timelineEnd===1&&we.sourceIn===0&&we.sourceOut===1;for(const Le of Y.clips)(Le.sourceMaxOut===1||Le.sourceMaxOut===void 0)&&(Le.sourceMaxOut=ie);Ve&&we!==void 0&&(we.sourceOut=ie,we.timelineEnd=ie)}function R(Y){if(!Number.isFinite(Y)||Y<=0||d)return;const ie=r.hasChanges;r.originalDuration=Y,r.totalDuration=Math.max(r.totalDuration,Y),r.media&&(r.media.duration=Y);for(const Le of r.clips)Le.sourceMaxOut=Y;const we=r.clips[0];!o&&r.clips.length===1&&we!==void 0&&we.timelineStart===0&&we.timelineEnd===1&&we.sourceIn===0&&we.sourceOut===1&&we!==void 0&&(we.sourceOut=Y,we.timelineEnd=we.timelineStart+(we.sourceOut-we.sourceIn)),L();for(const Le of s.value)w(Le,Y);for(const Le of l.value)w(Le,Y);d=!0,e.nextTick(()=>{ie||(r.hasChanges=!1)})}function N(Y){r.clips=Y.timeline.map(ie=>({...ie,sourceMinIn:ie.sourceMinIn??0,sourceMaxOut:ie.sourceMaxOut??Y.source.duration})),r.filters=[],r.audioVolume=Y.audio.volume,r.audioFadeIn=Y.audio.fadeIn||0,r.audioFadeOut=Y.audio.fadeOut||0,r.exportFormat=Y.output.format,r.exportQuality=Y.output.quality,r.originalDuration=Y.source.duration,r.clips.length>0?(r.selectedClipId=r.clips[0].id,c.value=r.selectedClipId):(delete r.selectedClipId,c.value=void 0),L()}function g(){s.value.push(JSON.parse(JSON.stringify(r))),l.value=[],r.hasChanges=!0}function C(){if(!E.value)return;const Y=s.value.pop();l.value.push(JSON.parse(JSON.stringify(r))),Object.assign(r,Y)}function A(){if(!y.value)return;const Y=l.value.pop();s.value.push(JSON.parse(JSON.stringify(r))),Object.assign(r,Y)}function x(Y,ie,we){g();const Ve=r.clips.find(Ge=>Ge.id===Y);if(!Ve)return;const yt=1/30,dt=Ve.sourceMinIn??0,Vt=Ve.sourceMaxOut??r.originalDuration;if(ie==="start"){const Ge=Ve.sourceIn,Gt=Math.max(dt,Math.min(we,Ve.sourceOut-yt));Ve.sourceIn=Gt;const Qa=Gt-Ge;Ve.timelineStart+=Qa}else{const Ge=Math.max(Ve.sourceIn+yt,Math.min(we,Vt));Ve.sourceOut=Ge;const Gt=Ve.sourceOut-Ve.sourceIn;Ve.timelineEnd=Ve.timelineStart+Gt}L(),p.value&&p.value.trimClip(Y,Ve.sourceIn,Ve.sourceOut)}function T(Y){g();const ie=r.clips.find(dt=>Y>dt.timelineStart&&Y<dt.timelineEnd);if(!ie)return;const we=Y-ie.timelineStart,Ve=ie.sourceIn+we,Le={id:de(),type:"clip",timelineStart:Y,timelineEnd:ie.timelineEnd,sourceIn:Ve,sourceOut:ie.sourceOut,speed:ie.speed??1,sourceMinIn:ie.sourceMinIn??0,sourceMaxOut:ie.sourceMaxOut??r.originalDuration,filters:[...ie.filters||[]]};ie.timelineEnd=Y,ie.sourceOut=Ve;const yt=r.clips.indexOf(ie);r.clips.splice(yt+1,0,Le),r.selectedClipId=Le.id}function I(){T(r.playheadPosition)}function z(Y){var we;const ie=Y??r.selectedClipId??c.value??((we=r.clips[0])==null?void 0:we.id);ie&&(r.selectedClipId=ie,c.value=ie)}function P(){if(!r.selectedClipId||r.clips.length<=1)return;g();const Y=r.clips.findIndex(ie=>ie.id===r.selectedClipId);if(Y!==-1){r.clips.splice(Y,1);const ie=Math.min(Y,r.clips.length-1);r.selectedClipId=r.clips[ie].id,c.value=r.selectedClipId,L()}}function j(Y,ie){g();const we=r.clips.find(Le=>Le.id===Y);if(!we)return;const Ve=ie-we.timelineStart;we.timelineStart=ie,we.timelineEnd+=Ve,L(),p.value&&p.value.moveClip(Y,ie)}function L(){if(r.clips.length===0){r.totalDuration=0;return}const Y=r.clips.reduce((ie,we)=>we.timelineEnd>ie.timelineEnd?we:ie);r.totalDuration=Y.timelineEnd}function _(){r.zoomLevel=Math.min(200,r.zoomLevel*1.2)}function D(){r.zoomLevel=Math.max(10,r.zoomLevel/1.2)}function G(Y){r.zoomLevel=Math.max(10,Math.min(600,Math.round(Y)))}function X(){r.isPlaying=!r.isPlaying}function ce(Y){r.isPlaying=Y}function Me(Y){r.playheadPosition=Math.max(0,Math.min(Y,r.totalDuration))}function $e(){const Y=Ks(r);try{localStorage.setItem(`video-draft-${a}`,JSON.stringify(Y))}catch{}return Y}function ae(){r.hasChanges=!1}function F(){return confirm("Are you sure you want to reset all changes?")?(g(),h(),r.hasChanges=!1,!0):!1}function O(){return Ks(r)}function de(){return`clip-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}async function re(Y=1920,ie=1080){if(u.value)try{p.value=new pc(Y,ie,f.value),await q()}catch{p.value=null}}async function q(){if(!(!p.value||b.value)){b.value=!0;try{const Y=O();await p.value.loadFromRecipe(Y);const ie=m.secondsToFrames(r.playheadPosition);p.value.seek(ie)}catch{}finally{b.value=!1}}}function ee(Y){}function ue(Y){return m.secondsToFrames(Y)}function ge(Y){return m.framesToSeconds(Y)}function xe(Y){const ie=ge(Y);Me(ie),p.value&&p.value.seek(Y)}function ne(){v.value=!v.value}function ke(){q()}function he(Y){u.value=!1,p.value=null}e.watch(()=>r.clips,()=>{r.hasChanges=!0,u.value&&p.value&&q()},{deep:!0}),e.watch(()=>r.filters,()=>{r.hasChanges=!0,u.value&&p.value&&q()},{deep:!0}),e.watch(()=>r.clips.map(Y=>Y.id),()=>{var ie;if(!r.clips.length){delete r.selectedClipId,c.value=void 0;return}if(!r.clips.some(we=>we.id===r.selectedClipId)){const we=c.value&&((ie=r.clips.find(Ve=>Ve.id===c.value))==null?void 0:ie.id);r.selectedClipId=we??r.clips[0].id,c.value=r.selectedClipId}},{deep:!0});function qe(Y){const ie=r.selectedClipId?r.clips.find(we=>we.id===r.selectedClipId):r.clips[0];ie&&(ie.filters=[...Y],r.hasChanges=!0)}function ct(Y){r.textOverlays=[...Y]}function pt(Y){r.audioTracks=[...Y]}e.watch(u,Y=>{Y?re():p.value&&(p.value.destroy(),p.value=null)}),e.watch(v,()=>{}),e.watch(f,Y=>{m.setFps(Y)});function me(){if(!r.selectedClipId)return;g();const Y=r.clips.find(Ve=>Ve.id===r.selectedClipId);if(!Y)return;const ie={...Y,id:de(),timelineStart:Y.timelineEnd,timelineEnd:Y.timelineEnd+(Y.timelineEnd-Y.timelineStart),filters:[...Y.filters||[]]},we=r.clips.indexOf(Y);r.clips.splice(we+1,0,ie),r.selectedClipId=ie.id,r.hasChanges=!0}function W(Y){const ie=Y??800,we=r.totalDuration;if(we<=0){r.zoomLevel=50;return}const Ve=ie*.8/we;r.zoomLevel=Math.max(10,Math.min(600,Math.round(Ve)))}function J(){const Y=1/f.value;Me(Math.min(r.playheadPosition+Y,r.totalDuration))}function te(){const Y=1/f.value;Me(Math.max(r.playheadPosition-Y,0))}function oe(){Me(0)}function pe(){Me(r.totalDuration)}function be(Y){if(!Number.isFinite(Y)||Y<=0)return;const ie=M.value??r.clips[0];if(!ie){S.value=Y;return}const we=ie.speed??1;if(we===Y){S.value=Y;return}g();const Ve=Math.max(1/f.value,ie.sourceOut-ie.sourceIn),Le=Ve/we,yt=Ve/Y,dt=yt-Le;ie.speed=Y,ie.timelineEnd=ie.timelineStart+yt;const Vt=r.clips.findIndex(Ge=>Ge.id===ie.id);if(Vt!==-1&&dt!==0)for(let Ge=Vt+1;Ge<r.clips.length;Ge+=1){const Gt=r.clips[Ge];Gt.timelineStart+=dt,Gt.timelineEnd+=dt}L(),r.playheadPosition=Math.max(0,Math.min(r.playheadPosition,r.totalDuration)),r.hasChanges=!0,S.value=Y}return{currentFrame:i,playheadPosition:e.computed(()=>r.playheadPosition),timelineClips:e.computed(()=>r.clips),totalDuration:e.computed(()=>r.totalDuration),hasChanges:e.computed(()=>r.hasChanges),isPlaying:e.computed(()=>r.isPlaying),selectedClip:M,zoomLevel:e.computed(()=>r.zoomLevel),playbackSpeed:S,useVideoEngine:u,compositionAdapter:e.computed(()=>p.value),fps:f,useFrameMode:v,handleTrim:x,handleSplit:T,handleClipSelect:z,splitAtPlayhead:I,deleteSelectedClip:P,duplicateSelectedClip:me,setFilters:qe,setTextOverlays:ct,setAudioTracks:pt,moveClip:j,saveDraft:$e,clearHasChanges:ae,resetChanges:F,generateRecipe:O,zoomIn:_,zoomOut:D,setZoomLevel:G,fitToWindow:W,togglePlayback:X,setPlaying:ce,seekTo:Me,frameForward:J,frameBackward:te,skipToStart:oe,skipToEnd:pe,setPlaybackSpeed:be,updateSourceDuration:R,undo:C,redo:A,canUndo:E,canRedo:y,initializeComposition:re,syncCompositionWithState:q,syncWithComposition:ee,convertToFrames:ue,convertToSeconds:ge,seekToFrame:xe,toggleFrameMode:ne,onCompositionReady:ke,onCompositionError:he}}const iy=[{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}}}],sy={dropShadow:"drop-shadow",softFocus:"blur",blackAndWhite:"grayscale",gaussianBlur:"blur","gaussian-blur":"blur"};function La(n){return typeof n=="object"&&n!==null}function ly(n,o){if(typeof n=="number"&&Number.isFinite(n))return n;if(typeof n=="string"){const t=Number(n);if(Number.isFinite(t))return t}return o}function Wa(n){if(typeof n=="number"||typeof n=="string"||typeof n=="boolean")return n}function cy(n){const o={id:n.id,type:n.type,label:n.label};n.property!==void 0&&(o.property=n.property),n.min!==void 0&&(o.min=n.min),n.max!==void 0&&(o.max=n.max),n.step!==void 0&&(o.step=n.step);const t=Wa(n.default);return t!==void 0&&(o.default=t),n.options!==void 0&&(o.options=n.options),o}function hc(n,o,t){const a=Et.getFilter(n),r={},i=(a==null?void 0:a.defaultParams)??t;if(i&&La(i))for(const[s,l]of Object.entries(i))r[s]=Wa(l)??null;for(const s of o){const l=s.property??s.id;r[l]===void 0&&s.default!==void 0&&(r[l]=s.default)}return r}function vc(n){const o={};for(const t of n){if(t.type!=="slider")continue;const a=t.property??t.id;o[a]={min:t.min??0,max:t.max??100,step:t.step??1}}return o}function dy(n,o,t,a){const r=a.map(cy);return{id:n,name:o,category:t,controls:r,params:r,defaultParams:hc(n,r),paramRanges:vc(r)}}function uy(n){const o=n.paramRanges??{},t=Object.entries(o).map(([a,r])=>{var l;const i={id:a,type:"slider",label:a.replace(/[-_]/g," ").replace(/\b\w/g,c=>c.toUpperCase()),property:a,min:r.min,max:r.max,step:r.step},s=Wa((l=n.defaultParams)==null?void 0:l[a]);return s!==void 0&&(i.default=s),i});return{id:n.id,name:n.name,category:n.category,controls:t,params:t,defaultParams:hc(n.id,t,n.defaultParams),paramRanges:vc(t)}}function my(n,o){return o.toLowerCase()==="unlisted"?!1:Et.isFilterCompatibleWithMedia(n,"video")}function wr(n){return sy[n]??n}function lo(n){const o=ly(n,1);return Math.max(0,Math.min(1,o))}function co(n){if(!La(n))return{};const o={};for(const[t,a]of Object.entries(n))o[t]=Wa(a)??null;return o}function py(n){return!La(n)||typeof n.filterId!="string"?null:{filterId:n.filterId,params:co(n.params),intensity:lo(n.intensity)}}function fy(n){if(!La(n)||typeof n.id!="string"||typeof n.name!="string")return null;const t=(Array.isArray(n.filters)?n.filters:[]).map(r=>py(r)).filter(r=>r!==null),a=typeof n.created_at=="string"?n.created_at:new Date().toISOString();return{id:n.id,name:n.name,filters:t,created_at:a}}function hy(){Et.initializeFilterRegistry();const n=e.ref([]),o=e.ref(null),t=e.ref(null),a=e.ref([]),r=e.ref(null),i=e.reactive({}),s=e.computed(()=>{const I=new Map,z=Et.getRegisteredFilters();for(const P of z)my(P.id,P.category)&&I.set(P.id,dy(P.id,P.name,P.category,P.controls));for(const P of iy)I.has(P.id)||I.set(P.id,uy(P));return Array.from(I.values())}),l=e.computed(()=>{const I=new Map;for(const z of s.value)I.set(z.id,z);return I}),c=e.computed(()=>n.value.length>0),d=e.computed(()=>{const I={};for(const z of s.value)I[z.category]||(I[z.category]=[]),I[z.category].push(z);return I});function u(I){const z=l.value.get(I);if(z)return z;const P=wr(I);return l.value.get(P)??null}function p(I){const z=l.value.get(I);if(z)return z.id;const P=wr(I),j=l.value.get(P);return j?j.id:null}function m(I){const z=I?u(I):o.value;if(!z)return;const P=z.defaultParams||{},j={id:C(),filterId:z.id,params:{...P},intensity:1};return n.value.push(j),r.value=j.id,o.value=z,Object.keys(i).forEach(L=>delete i[L]),Object.assign(i,j.params),t.value=null,j}function f(I){const z=u(I);if(!z)return;o.value=z;const P=z.defaultParams||x(I);Object.assign(i,P),t.value={id:"preview",filterId:z.id,params:{...P},intensity:1}}function v(I){if(Object.assign(i,I),t.value&&(t.value.params={...i}),r.value){const z=n.value.find(P=>P.id===r.value);z&&(z.params={...i})}}function b(I){const z=n.value.findIndex(P=>P.id===I);z!==-1&&n.value.splice(z,1)}function S(I,z){if(I<0||I>=n.value.length||z<0||z>=n.value.length)return;const[P]=n.value.splice(I,1);n.value.splice(z,0,P)}function M(I,z){const P=n.value.find(j=>j.id===I);P&&(P.intensity=Math.max(0,Math.min(1,z)))}function E(I){const z=n.value.find(P=>P.id===I);z&&(z.intensity=z.intensity>0?0:1)}function y(){n.value=[],t.value=null,o.value=null,r.value=null,Object.keys(i).forEach(I=>delete i[I])}function h(I){const z={id:A(),name:I,filters:n.value.map(j=>({filterId:j.filterId,params:co(j.params),intensity:lo(j.intensity)})),created_at:new Date().toISOString()};a.value.push(z);const P=a.value.map(j=>({...j}));return localStorage.setItem("video-filter-presets",JSON.stringify(P)),z}function w(I){const z=a.value.find(P=>P.id===I);if(z){y();for(const P of z.filters){const j=u(P.filterId);j&&n.value.push({id:C(),filterId:j.id,params:{...P.params},intensity:lo(P.intensity)})}}}function R(I){const z=a.value.findIndex(P=>P.id===I);z!==-1&&(a.value.splice(z,1),localStorage.setItem("video-filter-presets",JSON.stringify(a.value)))}function N(){try{const I=localStorage.getItem("video-filter-presets");if(!I)return;const z=JSON.parse(I);if(!Array.isArray(z))return;a.value=z.map(P=>fy(P)).filter(P=>P!==null)}catch{}}function g(){if(n.value.length===0)return"No filters applied";const I=n.value.map(z=>{const P=T(z.filterId);return(P==null?void 0:P.name)||z.filterId});return I.length===1?I[0]:I.length===2?`${I[0]} + ${I[1]}`:`${I[0]} + ${I.length-1} more`}function C(){return`filter-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function A(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function x(I){const z=u(I);return z?z.defaultParams||{}:{}}function T(I){return u(I)}return N(),{videoCompatibleFilters:s,activeFilters:n,selectedFilter:o,previewFilter:t,filterPresets:a,filterParams:i,hasActiveFilters:c,filtersByCategory:d,applyFilter:m,previewFilterEffect:f,updateFilterParams:v,removeFilter:b,reorderFilters:S,updateFilterIntensity:M,toggleFilter:E,clearAllFilters:y,saveFilterPreset:h,loadFilterPreset:w,deleteFilterPreset:R,getFilterSummary:g,setActiveFilters(I){var P;const z=[];for(const j of I){const L=p(j.filterId);if(!L){const _=wr(j.filterId);z.push({...j,filterId:_,params:co(j.params),intensity:lo(j.intensity)});continue}z.push({...j,filterId:L,params:co(j.params),intensity:lo(j.intensity)})}n.value=z,r.value=((P=n.value[0])==null?void 0:P.id)??null,Object.keys(i).forEach(j=>delete i[j]),n.value[0]&&Object.assign(i,co(n.value[0].params))}}}class vy{constructor(o){this.textClips=new Map,this.fonts=new Map,this.nextId=0,this.composition=o,this.initializeDefaultFonts()}initializeDefaultFonts(){try{this.fonts.set("default",new st({source:"https://fonts.googleapis.com/css2?family=Inter:wght@400",family:"Inter",weight:"400"})),this.fonts.set("bold",new st({source:"https://fonts.googleapis.com/css2?family=Inter:wght@700",family:"Inter",weight:"700"})),this.fonts.set("serif",new st({source:"https://fonts.googleapis.com/css2?family=Merriweather:wght@400",family:"Merriweather",weight:"400"}))}catch{}}async loadWebFont(o,t,a,r="400"){const i=new st({source:t,family:a,weight:r});this.fonts.set(o,i)}loadLocalFont(o,t,a="400"){const r=new st({source:`local('${t}')`,family:t,weight:a});this.fonts.set(o,r)}async addTextOverlay(o){const t=`text-overlay-${this.nextId++}`,a={text:o.text,fontSize:o.fontSize||24,fillStyle:o.color||"#ffffff",textAlign:o.textAlign||"center",textBaseline:o.textBaseline||"middle"},r=o.fontFamily||"default",i=this.fonts.get(r)||this.fonts.get("default");if(a.font=i,o.position)if(typeof o.position=="string")switch(o.position){case"center":a.position="center";break;case"top":a.x="50%",a.y="10%";break;case"bottom":a.x="50%",a.y="90%";break;case"left":a.x="10%",a.y="50%";break;case"right":a.x="90%",a.y="50%";break}else a.x=o.position.x,a.y=o.position.y;else a.position="center";if(o.startTime!==void 0&&(a.start=ve.fromSeconds(o.startTime)),o.duration!==void 0){const l=o.startTime||0;a.stop=ve.fromSeconds(l+o.duration)}o.animation&&this.applyAnimation(a,o.animation,o);const s=new jn(a);return await this.composition.add(s),this.textClips.set(t,s),t}applyAnimation(o,t,a){if(!t)return;const r=a.startTime?Math.round(a.startTime*30):0,i=t.duration||1,s=Math.round(i*30),l=r+s,c=t.easing||"linear";switch(t.type){case"fade-in":o.alpha=new Se([r,l],[0,1],{easing:c});break;case"fade-out":o.alpha=new Se([r,l],[1,0],{easing:c});break;case"rotate":t.rotation&&(o.rotation=new Se([r,l],[t.rotation.from,t.rotation.to],{easing:c}));break;case"scale":t.scale&&(o.scale=new Se([r,l],[t.scale.from,t.scale.to],{easing:c}));break;case"slide":t.translate&&(o.translate={x:new Se([r,l],[t.translate.fromX,t.translate.toX],{easing:c}),y:new Se([r,l],[t.translate.fromY,t.translate.toY],{easing:c})});break;case"typewriter":o.alpha=new Se([r,l],[0,1],{easing:"linear"});break;case"custom":t.rotation&&(o.rotation=new Se([r,l],[t.rotation.from,t.rotation.to],{easing:c})),t.scale&&(o.scale=new Se([r,l],[t.scale.from,t.scale.to],{easing:c})),t.translate&&(o.translate={x:new Se([r,l],[t.translate.fromX,t.translate.toX],{easing:c}),y:new Se([r,l],[t.translate.fromY,t.translate.toY],{easing:c})});break}}async updateTextOverlay(o,t){if(!this.textClips.get(o))throw new Error(`Text overlay with id ${o} not found`);await this.removeTextOverlay(o);const r={...t};await this.addTextOverlay(r)}async removeTextOverlay(o){const t=this.textClips.get(o);if(!t)throw new Error(`Text overlay with id ${o} not found`);const a=this.composition.tracks;for(const r of a){const i=r.clips.indexOf(t);if(i!==-1){r.clips.splice(i,1);break}}this.textClips.delete(o)}getTextOverlays(){return new Map(this.textClips)}async clearAllTextOverlays(){const o=Array.from(this.textClips.keys());for(const t of o)await this.removeTextOverlay(t)}getOverlays(){const o=[];return this.textClips.forEach((t,a)=>{const r={text:t.text||"",fontSize:t.fontSize,color:t.fillStyle,fontFamily:"default",position:"center"};o.push({id:a,config:r})}),o}async addCaptions(o,t="classic",a){var c,d;const i={classic:To,cascade:za,guinea:$a,solar:Aa,spotlight:Mo,whisper:Fo}[t],s=await this.composition.createTrack("caption"),l=new Ma({transcript:o});if(await s.add(l),await((c=s.generate)==null?void 0:c.call(s,i)),a&&s.clips.length>0){const u=s.clips[0];(d=u.set)==null||d.call(u,a)}}}class gy{constructor(o){this.audioLayers=new Map,this.audioSources=new Map,this.nextId=0,this.masterVolume=1,this.composition=o}async loadAudioSource(o,t){try{const a=await cn.from(o),r=t||`audio-source-${this.nextId++}`;return this.audioSources.set(r,a),a}catch(a){throw a instanceof Error?a:new Error("Failed to load audio source")}}async addBackgroundMusic(o){return this.addAudioTrack({...o,name:o.name||"Background Music"})}async addAudioTrack(o){const t=`audio-track-${this.nextId++}`;let a;try{if(typeof o.source=="object"&&o.source instanceof cn)a=o.source;else if(typeof o.source=="string")a=await cn.from(o.source);else if(typeof o.source=="object"&&o.source instanceof File)a=await cn.from(URL.createObjectURL(o.source));else throw new Error("Invalid audio source")}catch(c){throw c instanceof Error?c:new Error("Failed to create audio source")}const r={source:a,volume:(o.volume??1)*this.masterVolume};if(o.startTime!==void 0&&(r.start=ve.fromSeconds(o.startTime)),o.duration!==void 0){const c=o.startTime||0;r.stop=ve.fromSeconds(c+o.duration)}(o.fadeIn||o.fadeOut)&&(r.volume=this.createVolumeKeyframes(o));const i=new ka(r);let s=this.composition.tracks.find(c=>c.kind==="audio");s||(s=await this.composition.createTrack("audio")),await s.add(i);const l={id:t,name:o.name||`Audio Track ${this.audioLayers.size+1}`,clip:i,track:s,config:o};return this.audioLayers.set(t,l),t}createVolumeKeyframes(o){const t=(o.volume??1)*this.masterVolume,a=o.startTime?Math.round(o.startTime*30):0,r=o.duration,i=[],s=[];if(o.fadeIn){const l=Math.round(o.fadeIn*30);i.push(a,a+l),s.push(0,t)}else i.push(a),s.push(t);if(o.fadeOut&&r){const l=a+Math.round(r*30),c=Math.round(o.fadeOut*30);o.fadeIn||(i.push(l-c),s.push(t)),i.push(l),s.push(0)}return new Se(i,s,{easing:"linear"})}async updateVolume(o,t){const a=this.audioLayers.get(o);if(!a)throw new Error(`Audio track with id ${o} not found`);const r=Math.max(0,Math.min(1,t));a.clip.volume=r*this.masterVolume,a.config.volume=r}async applyFadeIn(o,t){const a=this.audioLayers.get(o);if(!a)throw new Error(`Audio track with id ${o} not found`);a.config.fadeIn=t,a.clip.set({volume:this.createVolumeKeyframes(a.config)})}async applyFadeOut(o,t){const a=this.audioLayers.get(o);if(!a)throw new Error(`Audio track with id ${o} not found`);a.config.fadeOut=t,a.clip.set({volume:this.createVolumeKeyframes(a.config)})}async removeAudioTrack(o){const t=this.audioLayers.get(o);if(!t)throw new Error(`Audio track with id ${o} not found`);const a=t.track.clips.indexOf(t.clip);a!==-1&&t.track.clips.splice(a,1),this.audioLayers.delete(o)}async muteTrack(o,t){const a=this.audioLayers.get(o);if(!a)throw new Error(`Audio track with id ${o} not found`);t?a.clip.volume=0:a.clip.volume=(a.config.volume??1)*this.masterVolume}setMasterVolume(o){this.masterVolume=Math.max(0,Math.min(1,o));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(o){return this.audioLayers.get(o)}async clearAllAudioTracks(){const o=Array.from(this.audioLayers.keys());for(const t of o)await this.removeAudioTrack(t)}async syncWithVideo(o,t){for(const a of this.audioLayers.values()){const r=a.config.startTime||0,i=a.config.duration||t-o;if(r+i>t){a.config.duration=t-r;const s=new ka({source:a.clip.source,start:ve.fromSeconds(r),stop:ve.fromSeconds(t),volume:a.clip.volume}),l=a.track.clips.indexOf(a.clip);l!==-1&&(a.track.clips[l]=s,a.clip=s)}}}exportConfiguration(){return Array.from(this.audioLayers.values()).map(o=>({id:o.id,name:o.name,config:{...o.config,source:o.config.source&&typeof o.config.source=="object"&&"type"in o.config.source?"[AudioSource]":o.config.source}}))}async importConfiguration(o){for(const{name:t,config:a}of o)await this.addAudioTrack({...a,name:t})}}function gc(n,o){return function(){return n.apply(o,arguments)}}const{toString:yy}=Object.prototype,{getPrototypeOf:fi}=Object,{iterator:ja,toStringTag:yc}=Symbol,Xa=(n=>o=>{const t=yy.call(o);return n[t]||(n[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Bt=n=>(n=n.toLowerCase(),o=>Xa(o)===n),Za=n=>o=>typeof o===n,{isArray:Yn}=Array,xo=Za("undefined");function Io(n){return n!==null&&!xo(n)&&n.constructor!==null&&!xo(n.constructor)&&ht(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const bc=Bt("ArrayBuffer");function by(n){let o;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?o=ArrayBuffer.isView(n):o=n&&n.buffer&&bc(n.buffer),o}const wy=Za("string"),ht=Za("function"),wc=Za("number"),Bo=n=>n!==null&&typeof n=="object",ky=n=>n===!0||n===!1,ca=n=>{if(Xa(n)!=="object")return!1;const o=fi(n);return(o===null||o===Object.prototype||Object.getPrototypeOf(o)===null)&&!(yc in n)&&!(ja in n)},xy=n=>{if(!Bo(n)||Io(n))return!1;try{return Object.keys(n).length===0&&Object.getPrototypeOf(n)===Object.prototype}catch{return!1}},Sy=Bt("Date"),Ey=Bt("File"),Vy=Bt("Blob"),Cy=Bt("FileList"),Ny=n=>Bo(n)&&ht(n.pipe),_y=n=>{let o;return n&&(typeof FormData=="function"&&n instanceof FormData||ht(n.append)&&((o=Xa(n))==="formdata"||o==="object"&&ht(n.toString)&&n.toString()==="[object FormData]"))},Ty=Bt("URLSearchParams"),[My,Fy,Iy,By]=["ReadableStream","Request","Response","Headers"].map(Bt),Ry=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Ro(n,o,{allOwnKeys:t=!1}={}){if(n===null||typeof n>"u")return;let a,r;if(typeof n!="object"&&(n=[n]),Yn(n))for(a=0,r=n.length;a<r;a++)o.call(null,n[a],a,n);else{if(Io(n))return;const i=t?Object.getOwnPropertyNames(n):Object.keys(n),s=i.length;let l;for(a=0;a<s;a++)l=i[a],o.call(null,n[l],l,n)}}function kc(n,o){if(Io(n))return null;o=o.toLowerCase();const t=Object.keys(n);let a=t.length,r;for(;a-- >0;)if(r=t[a],o===r.toLowerCase())return r;return null}const wn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,xc=n=>!xo(n)&&n!==wn;function Lr(){const{caseless:n}=xc(this)&&this||{},o={},t=(a,r)=>{const i=n&&kc(o,r)||r;ca(o[i])&&ca(a)?o[i]=Lr(o[i],a):ca(a)?o[i]=Lr({},a):Yn(a)?o[i]=a.slice():o[i]=a};for(let a=0,r=arguments.length;a<r;a++)arguments[a]&&Ro(arguments[a],t);return o}const Py=(n,o,t,{allOwnKeys:a}={})=>(Ro(o,(r,i)=>{t&&ht(r)?n[i]=gc(r,t):n[i]=r},{allOwnKeys:a}),n),$y=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),zy=(n,o,t,a)=>{n.prototype=Object.create(o.prototype,a),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:o.prototype}),t&&Object.assign(n.prototype,t)},Ay=(n,o,t,a)=>{let r,i,s;const l={};if(o=o||{},n==null)return o;do{for(r=Object.getOwnPropertyNames(n),i=r.length;i-- >0;)s=r[i],(!a||a(s,n,o))&&!l[s]&&(o[s]=n[s],l[s]=!0);n=t!==!1&&fi(n)}while(n&&(!t||t(n,o))&&n!==Object.prototype);return o},Dy=(n,o,t)=>{n=String(n),(t===void 0||t>n.length)&&(t=n.length),t-=o.length;const a=n.indexOf(o,t);return a!==-1&&a===t},Uy=n=>{if(!n)return null;if(Yn(n))return n;let o=n.length;if(!wc(o))return null;const t=new Array(o);for(;o-- >0;)t[o]=n[o];return t},Oy=(n=>o=>n&&o instanceof n)(typeof Uint8Array<"u"&&fi(Uint8Array)),Ly=(n,o)=>{const a=(n&&n[ja]).call(n);let r;for(;(r=a.next())&&!r.done;){const i=r.value;o.call(n,i[0],i[1])}},Wy=(n,o)=>{let t;const a=[];for(;(t=n.exec(o))!==null;)a.push(t);return a},jy=Bt("HTMLFormElement"),Xy=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,a,r){return a.toUpperCase()+r}),Qs=(({hasOwnProperty:n})=>(o,t)=>n.call(o,t))(Object.prototype),Zy=Bt("RegExp"),Sc=(n,o)=>{const t=Object.getOwnPropertyDescriptors(n),a={};Ro(t,(r,i)=>{let s;(s=o(r,i,n))!==!1&&(a[i]=s||r)}),Object.defineProperties(n,a)},Yy=n=>{Sc(n,(o,t)=>{if(ht(n)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const a=n[t];if(ht(a)){if(o.enumerable=!1,"writable"in o){o.writable=!1;return}o.set||(o.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},Gy=(n,o)=>{const t={},a=r=>{r.forEach(i=>{t[i]=!0})};return Yn(n)?a(n):a(String(n).split(o)),t},Hy=()=>{},Jy=(n,o)=>n!=null&&Number.isFinite(n=+n)?n:o;function qy(n){return!!(n&&ht(n.append)&&n[yc]==="FormData"&&n[ja])}const Ky=n=>{const o=new Array(10),t=(a,r)=>{if(Bo(a)){if(o.indexOf(a)>=0)return;if(Io(a))return a;if(!("toJSON"in a)){o[r]=a;const i=Yn(a)?[]:{};return Ro(a,(s,l)=>{const c=t(s,r+1);!xo(c)&&(i[l]=c)}),o[r]=void 0,i}}return a};return t(n,0)},Qy=Bt("AsyncFunction"),eb=n=>n&&(Bo(n)||ht(n))&&ht(n.then)&&ht(n.catch),Ec=((n,o)=>n?setImmediate:o?((t,a)=>(wn.addEventListener("message",({source:r,data:i})=>{r===wn&&i===t&&a.length&&a.shift()()},!1),r=>{a.push(r),wn.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",ht(wn.postMessage)),tb=typeof queueMicrotask<"u"?queueMicrotask.bind(wn):typeof process<"u"&&process.nextTick||Ec,nb=n=>n!=null&&ht(n[ja]),H={isArray:Yn,isArrayBuffer:bc,isBuffer:Io,isFormData:_y,isArrayBufferView:by,isString:wy,isNumber:wc,isBoolean:ky,isObject:Bo,isPlainObject:ca,isEmptyObject:xy,isReadableStream:My,isRequest:Fy,isResponse:Iy,isHeaders:By,isUndefined:xo,isDate:Sy,isFile:Ey,isBlob:Vy,isRegExp:Zy,isFunction:ht,isStream:Ny,isURLSearchParams:Ty,isTypedArray:Oy,isFileList:Cy,forEach:Ro,merge:Lr,extend:Py,trim:Ry,stripBOM:$y,inherits:zy,toFlatObject:Ay,kindOf:Xa,kindOfTest:Bt,endsWith:Dy,toArray:Uy,forEachEntry:Ly,matchAll:Wy,isHTMLForm:jy,hasOwnProperty:Qs,hasOwnProp:Qs,reduceDescriptors:Sc,freezeMethods:Yy,toObjectSet:Gy,toCamelCase:Xy,noop:Hy,toFiniteNumber:Jy,findKey:kc,global:wn,isContextDefined:xc,isSpecCompliantForm:qy,toJSONObject:Ky,isAsyncFn:Qy,isThenable:eb,setImmediate:Ec,asap:tb,isIterable:nb};function Te(n,o,t,a,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=n,this.name="AxiosError",o&&(this.code=o),t&&(this.config=t),a&&(this.request=a),r&&(this.response=r,this.status=r.status?r.status:null)}H.inherits(Te,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:H.toJSONObject(this.config),code:this.code,status:this.status}}});const Vc=Te.prototype,Cc={};["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(n=>{Cc[n]={value:n}});Object.defineProperties(Te,Cc);Object.defineProperty(Vc,"isAxiosError",{value:!0});Te.from=(n,o,t,a,r,i)=>{const s=Object.create(Vc);return H.toFlatObject(n,s,function(c){return c!==Error.prototype},l=>l!=="isAxiosError"),Te.call(s,n.message,o,t,a,r),s.cause=n,s.name=n.name,i&&Object.assign(s,i),s};const ob=null;function Wr(n){return H.isPlainObject(n)||H.isArray(n)}function Nc(n){return H.endsWith(n,"[]")?n.slice(0,-2):n}function el(n,o,t){return n?n.concat(o).map(function(r,i){return r=Nc(r),!t&&i?"["+r+"]":r}).join(t?".":""):o}function ab(n){return H.isArray(n)&&!n.some(Wr)}const rb=H.toFlatObject(H,{},null,function(o){return/^is[A-Z]/.test(o)});function Ya(n,o,t){if(!H.isObject(n))throw new TypeError("target must be an object");o=o||new FormData,t=H.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(b,S){return!H.isUndefined(S[b])});const a=t.metaTokens,r=t.visitor||u,i=t.dots,s=t.indexes,c=(t.Blob||typeof Blob<"u"&&Blob)&&H.isSpecCompliantForm(o);if(!H.isFunction(r))throw new TypeError("visitor must be a function");function d(v){if(v===null)return"";if(H.isDate(v))return v.toISOString();if(H.isBoolean(v))return v.toString();if(!c&&H.isBlob(v))throw new Te("Blob is not supported. Use a Buffer instead.");return H.isArrayBuffer(v)||H.isTypedArray(v)?c&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function u(v,b,S){let M=v;if(v&&!S&&typeof v=="object"){if(H.endsWith(b,"{}"))b=a?b:b.slice(0,-2),v=JSON.stringify(v);else if(H.isArray(v)&&ab(v)||(H.isFileList(v)||H.endsWith(b,"[]"))&&(M=H.toArray(v)))return b=Nc(b),M.forEach(function(y,h){!(H.isUndefined(y)||y===null)&&o.append(s===!0?el([b],h,i):s===null?b:b+"[]",d(y))}),!1}return Wr(v)?!0:(o.append(el(S,b,i),d(v)),!1)}const p=[],m=Object.assign(rb,{defaultVisitor:u,convertValue:d,isVisitable:Wr});function f(v,b){if(!H.isUndefined(v)){if(p.indexOf(v)!==-1)throw Error("Circular reference detected in "+b.join("."));p.push(v),H.forEach(v,function(M,E){(!(H.isUndefined(M)||M===null)&&r.call(o,M,H.isString(E)?E.trim():E,b,m))===!0&&f(M,b?b.concat(E):[E])}),p.pop()}}if(!H.isObject(n))throw new TypeError("data must be an object");return f(n),o}function tl(n){const o={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(a){return o[a]})}function hi(n,o){this._pairs=[],n&&Ya(n,this,o)}const _c=hi.prototype;_c.append=function(o,t){this._pairs.push([o,t])};_c.toString=function(o){const t=o?function(a){return o.call(this,a,tl)}:tl;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function ib(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Tc(n,o,t){if(!o)return n;const a=t&&t.encode||ib;H.isFunction(t)&&(t={serialize:t});const r=t&&t.serialize;let i;if(r?i=r(o,t):i=H.isURLSearchParams(o)?o.toString():new hi(o,t).toString(a),i){const s=n.indexOf("#");s!==-1&&(n=n.slice(0,s)),n+=(n.indexOf("?")===-1?"?":"&")+i}return n}class nl{constructor(){this.handlers=[]}use(o,t,a){return this.handlers.push({fulfilled:o,rejected:t,synchronous:a?a.synchronous:!1,runWhen:a?a.runWhen:null}),this.handlers.length-1}eject(o){this.handlers[o]&&(this.handlers[o]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(o){H.forEach(this.handlers,function(a){a!==null&&o(a)})}}const Mc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},sb=typeof URLSearchParams<"u"?URLSearchParams:hi,lb=typeof FormData<"u"?FormData:null,cb=typeof Blob<"u"?Blob:null,db={isBrowser:!0,classes:{URLSearchParams:sb,FormData:lb,Blob:cb},protocols:["http","https","file","blob","url","data"]},vi=typeof window<"u"&&typeof document<"u",jr=typeof navigator=="object"&&navigator||void 0,ub=vi&&(!jr||["ReactNative","NativeScript","NS"].indexOf(jr.product)<0),mb=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",pb=vi&&window.location.href||"http://localhost",fb=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:vi,hasStandardBrowserEnv:ub,hasStandardBrowserWebWorkerEnv:mb,navigator:jr,origin:pb},Symbol.toStringTag,{value:"Module"})),lt={...fb,...db};function hb(n,o){return Ya(n,new lt.classes.URLSearchParams,{visitor:function(t,a,r,i){return lt.isNode&&H.isBuffer(t)?(this.append(a,t.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...o})}function vb(n){return H.matchAll(/\w+|\[(\w*)]/g,n).map(o=>o[0]==="[]"?"":o[1]||o[0])}function gb(n){const o={},t=Object.keys(n);let a;const r=t.length;let i;for(a=0;a<r;a++)i=t[a],o[i]=n[i];return o}function Fc(n){function o(t,a,r,i){let s=t[i++];if(s==="__proto__")return!0;const l=Number.isFinite(+s),c=i>=t.length;return s=!s&&H.isArray(r)?r.length:s,c?(H.hasOwnProp(r,s)?r[s]=[r[s],a]:r[s]=a,!l):((!r[s]||!H.isObject(r[s]))&&(r[s]=[]),o(t,a,r[s],i)&&H.isArray(r[s])&&(r[s]=gb(r[s])),!l)}if(H.isFormData(n)&&H.isFunction(n.entries)){const t={};return H.forEachEntry(n,(a,r)=>{o(vb(a),r,t,0)}),t}return null}function yb(n,o,t){if(H.isString(n))try{return(o||JSON.parse)(n),H.trim(n)}catch(a){if(a.name!=="SyntaxError")throw a}return(t||JSON.stringify)(n)}const Po={transitional:Mc,adapter:["xhr","http","fetch"],transformRequest:[function(o,t){const a=t.getContentType()||"",r=a.indexOf("application/json")>-1,i=H.isObject(o);if(i&&H.isHTMLForm(o)&&(o=new FormData(o)),H.isFormData(o))return r?JSON.stringify(Fc(o)):o;if(H.isArrayBuffer(o)||H.isBuffer(o)||H.isStream(o)||H.isFile(o)||H.isBlob(o)||H.isReadableStream(o))return o;if(H.isArrayBufferView(o))return o.buffer;if(H.isURLSearchParams(o))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),o.toString();let l;if(i){if(a.indexOf("application/x-www-form-urlencoded")>-1)return hb(o,this.formSerializer).toString();if((l=H.isFileList(o))||a.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Ya(l?{"files[]":o}:o,c&&new c,this.formSerializer)}}return i||r?(t.setContentType("application/json",!1),yb(o)):o}],transformResponse:[function(o){const t=this.transitional||Po.transitional,a=t&&t.forcedJSONParsing,r=this.responseType==="json";if(H.isResponse(o)||H.isReadableStream(o))return o;if(o&&H.isString(o)&&(a&&!this.responseType||r)){const s=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(o)}catch(l){if(s)throw l.name==="SyntaxError"?Te.from(l,Te.ERR_BAD_RESPONSE,this,null,this.response):l}}return o}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:lt.classes.FormData,Blob:lt.classes.Blob},validateStatus:function(o){return o>=200&&o<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};H.forEach(["delete","get","head","post","put","patch"],n=>{Po.headers[n]={}});const bb=H.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"]),wb=n=>{const o={};let t,a,r;return n&&n.split(`
|
|
34
|
+
`).forEach(function(s){r=s.indexOf(":"),t=s.substring(0,r).trim().toLowerCase(),a=s.substring(r+1).trim(),!(!t||o[t]&&bb[t])&&(t==="set-cookie"?o[t]?o[t].push(a):o[t]=[a]:o[t]=o[t]?o[t]+", "+a:a)}),o},ol=Symbol("internals");function to(n){return n&&String(n).trim().toLowerCase()}function da(n){return n===!1||n==null?n:H.isArray(n)?n.map(da):String(n)}function kb(n){const o=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let a;for(;a=t.exec(n);)o[a[1]]=a[2];return o}const xb=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function kr(n,o,t,a,r){if(H.isFunction(a))return a.call(this,o,t);if(r&&(o=t),!!H.isString(o)){if(H.isString(a))return o.indexOf(a)!==-1;if(H.isRegExp(a))return a.test(o)}}function Sb(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(o,t,a)=>t.toUpperCase()+a)}function Eb(n,o){const t=H.toCamelCase(" "+o);["get","set","has"].forEach(a=>{Object.defineProperty(n,a+t,{value:function(r,i,s){return this[a].call(this,o,r,i,s)},configurable:!0})})}let vt=class{constructor(o){o&&this.set(o)}set(o,t,a){const r=this;function i(l,c,d){const u=to(c);if(!u)throw new Error("header name must be a non-empty string");const p=H.findKey(r,u);(!p||r[p]===void 0||d===!0||d===void 0&&r[p]!==!1)&&(r[p||c]=da(l))}const s=(l,c)=>H.forEach(l,(d,u)=>i(d,u,c));if(H.isPlainObject(o)||o instanceof this.constructor)s(o,t);else if(H.isString(o)&&(o=o.trim())&&!xb(o))s(wb(o),t);else if(H.isObject(o)&&H.isIterable(o)){let l={},c,d;for(const u of o){if(!H.isArray(u))throw TypeError("Object iterator must return a key-value pair");l[d=u[0]]=(c=l[d])?H.isArray(c)?[...c,u[1]]:[c,u[1]]:u[1]}s(l,t)}else o!=null&&i(t,o,a);return this}get(o,t){if(o=to(o),o){const a=H.findKey(this,o);if(a){const r=this[a];if(!t)return r;if(t===!0)return kb(r);if(H.isFunction(t))return t.call(this,r,a);if(H.isRegExp(t))return t.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(o,t){if(o=to(o),o){const a=H.findKey(this,o);return!!(a&&this[a]!==void 0&&(!t||kr(this,this[a],a,t)))}return!1}delete(o,t){const a=this;let r=!1;function i(s){if(s=to(s),s){const l=H.findKey(a,s);l&&(!t||kr(a,a[l],l,t))&&(delete a[l],r=!0)}}return H.isArray(o)?o.forEach(i):i(o),r}clear(o){const t=Object.keys(this);let a=t.length,r=!1;for(;a--;){const i=t[a];(!o||kr(this,this[i],i,o,!0))&&(delete this[i],r=!0)}return r}normalize(o){const t=this,a={};return H.forEach(this,(r,i)=>{const s=H.findKey(a,i);if(s){t[s]=da(r),delete t[i];return}const l=o?Sb(i):String(i).trim();l!==i&&delete t[i],t[l]=da(r),a[l]=!0}),this}concat(...o){return this.constructor.concat(this,...o)}toJSON(o){const t=Object.create(null);return H.forEach(this,(a,r)=>{a!=null&&a!==!1&&(t[r]=o&&H.isArray(a)?a.join(", "):a)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([o,t])=>o+": "+t).join(`
|
|
35
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(o){return o instanceof this?o:new this(o)}static concat(o,...t){const a=new this(o);return t.forEach(r=>a.set(r)),a}static accessor(o){const a=(this[ol]=this[ol]={accessors:{}}).accessors,r=this.prototype;function i(s){const l=to(s);a[l]||(Eb(r,s),a[l]=!0)}return H.isArray(o)?o.forEach(i):i(o),this}};vt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);H.reduceDescriptors(vt.prototype,({value:n},o)=>{let t=o[0].toUpperCase()+o.slice(1);return{get:()=>n,set(a){this[t]=a}}});H.freezeMethods(vt);function xr(n,o){const t=this||Po,a=o||t,r=vt.from(a.headers);let i=a.data;return H.forEach(n,function(l){i=l.call(t,i,r.normalize(),o?o.status:void 0)}),r.normalize(),i}function Ic(n){return!!(n&&n.__CANCEL__)}function Gn(n,o,t){Te.call(this,n??"canceled",Te.ERR_CANCELED,o,t),this.name="CanceledError"}H.inherits(Gn,Te,{__CANCEL__:!0});function Bc(n,o,t){const a=t.config.validateStatus;!t.status||!a||a(t.status)?n(t):o(new Te("Request failed with status code "+t.status,[Te.ERR_BAD_REQUEST,Te.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function Vb(n){const o=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return o&&o[1]||""}function Cb(n,o){n=n||10;const t=new Array(n),a=new Array(n);let r=0,i=0,s;return o=o!==void 0?o:1e3,function(c){const d=Date.now(),u=a[i];s||(s=d),t[r]=c,a[r]=d;let p=i,m=0;for(;p!==r;)m+=t[p++],p=p%n;if(r=(r+1)%n,r===i&&(i=(i+1)%n),d-s<o)return;const f=u&&d-u;return f?Math.round(m*1e3/f):void 0}}function Nb(n,o){let t=0,a=1e3/o,r,i;const s=(d,u=Date.now())=>{t=u,r=null,i&&(clearTimeout(i),i=null),n(...d)};return[(...d)=>{const u=Date.now(),p=u-t;p>=a?s(d,u):(r=d,i||(i=setTimeout(()=>{i=null,s(r)},a-p)))},()=>r&&s(r)]}const Sa=(n,o,t=3)=>{let a=0;const r=Cb(50,250);return Nb(i=>{const s=i.loaded,l=i.lengthComputable?i.total:void 0,c=s-a,d=r(c),u=s<=l;a=s;const p={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:i,lengthComputable:l!=null,[o?"download":"upload"]:!0};n(p)},t)},al=(n,o)=>{const t=n!=null;return[a=>o[0]({lengthComputable:t,total:n,loaded:a}),o[1]]},rl=n=>(...o)=>H.asap(()=>n(...o)),_b=lt.hasStandardBrowserEnv?((n,o)=>t=>(t=new URL(t,lt.origin),n.protocol===t.protocol&&n.host===t.host&&(o||n.port===t.port)))(new URL(lt.origin),lt.navigator&&/(msie|trident)/i.test(lt.navigator.userAgent)):()=>!0,Tb=lt.hasStandardBrowserEnv?{write(n,o,t,a,r,i){const s=[n+"="+encodeURIComponent(o)];H.isNumber(t)&&s.push("expires="+new Date(t).toGMTString()),H.isString(a)&&s.push("path="+a),H.isString(r)&&s.push("domain="+r),i===!0&&s.push("secure"),document.cookie=s.join("; ")},read(n){const o=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return o?decodeURIComponent(o[3]):null},remove(n){this.write(n,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Mb(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function Fb(n,o){return o?n.replace(/\/?\/$/,"")+"/"+o.replace(/^\/+/,""):n}function Rc(n,o,t){let a=!Mb(o);return n&&(a||t==!1)?Fb(n,o):o}const il=n=>n instanceof vt?{...n}:n;function En(n,o){o=o||{};const t={};function a(d,u,p,m){return H.isPlainObject(d)&&H.isPlainObject(u)?H.merge.call({caseless:m},d,u):H.isPlainObject(u)?H.merge({},u):H.isArray(u)?u.slice():u}function r(d,u,p,m){if(H.isUndefined(u)){if(!H.isUndefined(d))return a(void 0,d,p,m)}else return a(d,u,p,m)}function i(d,u){if(!H.isUndefined(u))return a(void 0,u)}function s(d,u){if(H.isUndefined(u)){if(!H.isUndefined(d))return a(void 0,d)}else return a(void 0,u)}function l(d,u,p){if(p in o)return a(d,u);if(p in n)return a(void 0,d)}const c={url:i,method:i,data:i,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,p)=>r(il(d),il(u),p,!0)};return H.forEach(Object.keys({...n,...o}),function(u){const p=c[u]||r,m=p(n[u],o[u],u);H.isUndefined(m)&&p!==l||(t[u]=m)}),t}const Pc=n=>{const o=En({},n);let{data:t,withXSRFToken:a,xsrfHeaderName:r,xsrfCookieName:i,headers:s,auth:l}=o;o.headers=s=vt.from(s),o.url=Tc(Rc(o.baseURL,o.url,o.allowAbsoluteUrls),n.params,n.paramsSerializer),l&&s.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let c;if(H.isFormData(t)){if(lt.hasStandardBrowserEnv||lt.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((c=s.getContentType())!==!1){const[d,...u]=c?c.split(";").map(p=>p.trim()).filter(Boolean):[];s.setContentType([d||"multipart/form-data",...u].join("; "))}}if(lt.hasStandardBrowserEnv&&(a&&H.isFunction(a)&&(a=a(o)),a||a!==!1&&_b(o.url))){const d=r&&i&&Tb.read(i);d&&s.set(r,d)}return o},Ib=typeof XMLHttpRequest<"u",Bb=Ib&&function(n){return new Promise(function(t,a){const r=Pc(n);let i=r.data;const s=vt.from(r.headers).normalize();let{responseType:l,onUploadProgress:c,onDownloadProgress:d}=r,u,p,m,f,v;function b(){f&&f(),v&&v(),r.cancelToken&&r.cancelToken.unsubscribe(u),r.signal&&r.signal.removeEventListener("abort",u)}let S=new XMLHttpRequest;S.open(r.method.toUpperCase(),r.url,!0),S.timeout=r.timeout;function M(){if(!S)return;const y=vt.from("getAllResponseHeaders"in S&&S.getAllResponseHeaders()),w={data:!l||l==="text"||l==="json"?S.responseText:S.response,status:S.status,statusText:S.statusText,headers:y,config:n,request:S};Bc(function(N){t(N),b()},function(N){a(N),b()},w),S=null}"onloadend"in S?S.onloadend=M:S.onreadystatechange=function(){!S||S.readyState!==4||S.status===0&&!(S.responseURL&&S.responseURL.indexOf("file:")===0)||setTimeout(M)},S.onabort=function(){S&&(a(new Te("Request aborted",Te.ECONNABORTED,n,S)),S=null)},S.onerror=function(){a(new Te("Network Error",Te.ERR_NETWORK,n,S)),S=null},S.ontimeout=function(){let h=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const w=r.transitional||Mc;r.timeoutErrorMessage&&(h=r.timeoutErrorMessage),a(new Te(h,w.clarifyTimeoutError?Te.ETIMEDOUT:Te.ECONNABORTED,n,S)),S=null},i===void 0&&s.setContentType(null),"setRequestHeader"in S&&H.forEach(s.toJSON(),function(h,w){S.setRequestHeader(w,h)}),H.isUndefined(r.withCredentials)||(S.withCredentials=!!r.withCredentials),l&&l!=="json"&&(S.responseType=r.responseType),d&&([m,v]=Sa(d,!0),S.addEventListener("progress",m)),c&&S.upload&&([p,f]=Sa(c),S.upload.addEventListener("progress",p),S.upload.addEventListener("loadend",f)),(r.cancelToken||r.signal)&&(u=y=>{S&&(a(!y||y.type?new Gn(null,n,S):y),S.abort(),S=null)},r.cancelToken&&r.cancelToken.subscribe(u),r.signal&&(r.signal.aborted?u():r.signal.addEventListener("abort",u)));const E=Vb(r.url);if(E&<.protocols.indexOf(E)===-1){a(new Te("Unsupported protocol "+E+":",Te.ERR_BAD_REQUEST,n));return}S.send(i||null)})},Rb=(n,o)=>{const{length:t}=n=n?n.filter(Boolean):[];if(o||t){let a=new AbortController,r;const i=function(d){if(!r){r=!0,l();const u=d instanceof Error?d:this.reason;a.abort(u instanceof Te?u:new Gn(u instanceof Error?u.message:u))}};let s=o&&setTimeout(()=>{s=null,i(new Te(`timeout ${o} of ms exceeded`,Te.ETIMEDOUT))},o);const l=()=>{n&&(s&&clearTimeout(s),s=null,n.forEach(d=>{d.unsubscribe?d.unsubscribe(i):d.removeEventListener("abort",i)}),n=null)};n.forEach(d=>d.addEventListener("abort",i));const{signal:c}=a;return c.unsubscribe=()=>H.asap(l),c}},Pb=function*(n,o){let t=n.byteLength;if(t<o){yield n;return}let a=0,r;for(;a<t;)r=a+o,yield n.slice(a,r),a=r},$b=async function*(n,o){for await(const t of zb(n))yield*Pb(t,o)},zb=async function*(n){if(n[Symbol.asyncIterator]){yield*n;return}const o=n.getReader();try{for(;;){const{done:t,value:a}=await o.read();if(t)break;yield a}}finally{await o.cancel()}},sl=(n,o,t,a)=>{const r=$b(n,o);let i=0,s,l=c=>{s||(s=!0,a&&a(c))};return new ReadableStream({async pull(c){try{const{done:d,value:u}=await r.next();if(d){l(),c.close();return}let p=u.byteLength;if(t){let m=i+=p;t(m)}c.enqueue(new Uint8Array(u))}catch(d){throw l(d),d}},cancel(c){return l(c),r.return()}},{highWaterMark:2})},Ga=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",$c=Ga&&typeof ReadableStream=="function",Ab=Ga&&(typeof TextEncoder=="function"?(n=>o=>n.encode(o))(new TextEncoder):async n=>new Uint8Array(await new Response(n).arrayBuffer())),zc=(n,...o)=>{try{return!!n(...o)}catch{return!1}},Db=$c&&zc(()=>{let n=!1;const o=new Request(lt.origin,{body:new ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type");return n&&!o}),ll=64*1024,Xr=$c&&zc(()=>H.isReadableStream(new Response("").body)),Ea={stream:Xr&&(n=>n.body)};Ga&&(n=>{["text","arrayBuffer","blob","formData","stream"].forEach(o=>{!Ea[o]&&(Ea[o]=H.isFunction(n[o])?t=>t[o]():(t,a)=>{throw new Te(`Response type '${o}' is not supported`,Te.ERR_NOT_SUPPORT,a)})})})(new Response);const Ub=async n=>{if(n==null)return 0;if(H.isBlob(n))return n.size;if(H.isSpecCompliantForm(n))return(await new Request(lt.origin,{method:"POST",body:n}).arrayBuffer()).byteLength;if(H.isArrayBufferView(n)||H.isArrayBuffer(n))return n.byteLength;if(H.isURLSearchParams(n)&&(n=n+""),H.isString(n))return(await Ab(n)).byteLength},Ob=async(n,o)=>{const t=H.toFiniteNumber(n.getContentLength());return t??Ub(o)},Lb=Ga&&(async n=>{let{url:o,method:t,data:a,signal:r,cancelToken:i,timeout:s,onDownloadProgress:l,onUploadProgress:c,responseType:d,headers:u,withCredentials:p="same-origin",fetchOptions:m}=Pc(n);d=d?(d+"").toLowerCase():"text";let f=Rb([r,i&&i.toAbortSignal()],s),v;const b=f&&f.unsubscribe&&(()=>{f.unsubscribe()});let S;try{if(c&&Db&&t!=="get"&&t!=="head"&&(S=await Ob(u,a))!==0){let w=new Request(o,{method:"POST",body:a,duplex:"half"}),R;if(H.isFormData(a)&&(R=w.headers.get("content-type"))&&u.setContentType(R),w.body){const[N,g]=al(S,Sa(rl(c)));a=sl(w.body,ll,N,g)}}H.isString(p)||(p=p?"include":"omit");const M="credentials"in Request.prototype;v=new Request(o,{...m,signal:f,method:t.toUpperCase(),headers:u.normalize().toJSON(),body:a,duplex:"half",credentials:M?p:void 0});let E=await fetch(v,m);const y=Xr&&(d==="stream"||d==="response");if(Xr&&(l||y&&b)){const w={};["status","statusText","headers"].forEach(C=>{w[C]=E[C]});const R=H.toFiniteNumber(E.headers.get("content-length")),[N,g]=l&&al(R,Sa(rl(l),!0))||[];E=new Response(sl(E.body,ll,N,()=>{g&&g(),b&&b()}),w)}d=d||"text";let h=await Ea[H.findKey(Ea,d)||"text"](E,n);return!y&&b&&b(),await new Promise((w,R)=>{Bc(w,R,{data:h,headers:vt.from(E.headers),status:E.status,statusText:E.statusText,config:n,request:v})})}catch(M){throw b&&b(),M&&M.name==="TypeError"&&/Load failed|fetch/i.test(M.message)?Object.assign(new Te("Network Error",Te.ERR_NETWORK,n,v),{cause:M.cause||M}):Te.from(M,M&&M.code,n,v)}}),Zr={http:ob,xhr:Bb,fetch:Lb};H.forEach(Zr,(n,o)=>{if(n){try{Object.defineProperty(n,"name",{value:o})}catch{}Object.defineProperty(n,"adapterName",{value:o})}});const cl=n=>`- ${n}`,Wb=n=>H.isFunction(n)||n===null||n===!1,Ac={getAdapter:n=>{n=H.isArray(n)?n:[n];const{length:o}=n;let t,a;const r={};for(let i=0;i<o;i++){t=n[i];let s;if(a=t,!Wb(t)&&(a=Zr[(s=String(t)).toLowerCase()],a===void 0))throw new Te(`Unknown adapter '${s}'`);if(a)break;r[s||"#"+i]=a}if(!a){const i=Object.entries(r).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let s=o?i.length>1?`since :
|
|
36
|
+
`+i.map(cl).join(`
|
|
37
|
+
`):" "+cl(i[0]):"as no adapter specified";throw new Te("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return a},adapters:Zr};function Sr(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new Gn(null,n)}function dl(n){return Sr(n),n.headers=vt.from(n.headers),n.data=xr.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),Ac.getAdapter(n.adapter||Po.adapter)(n).then(function(a){return Sr(n),a.data=xr.call(n,n.transformResponse,a),a.headers=vt.from(a.headers),a},function(a){return Ic(a)||(Sr(n),a&&a.response&&(a.response.data=xr.call(n,n.transformResponse,a.response),a.response.headers=vt.from(a.response.headers))),Promise.reject(a)})}const Dc="1.11.0",Ha={};["object","boolean","number","function","string","symbol"].forEach((n,o)=>{Ha[n]=function(a){return typeof a===n||"a"+(o<1?"n ":" ")+n}});const ul={};Ha.transitional=function(o,t,a){function r(i,s){return"[Axios v"+Dc+"] Transitional option '"+i+"'"+s+(a?". "+a:"")}return(i,s,l)=>{if(o===!1)throw new Te(r(s," has been removed"+(t?" in "+t:"")),Te.ERR_DEPRECATED);return t&&!ul[s]&&(ul[s]=!0),o?o(i,s,l):!0}};Ha.spelling=function(o){return(t,a)=>!0};function jb(n,o,t){if(typeof n!="object")throw new Te("options must be an object",Te.ERR_BAD_OPTION_VALUE);const a=Object.keys(n);let r=a.length;for(;r-- >0;){const i=a[r],s=o[i];if(s){const l=n[i],c=l===void 0||s(l,i,n);if(c!==!0)throw new Te("option "+i+" must be "+c,Te.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new Te("Unknown option "+i,Te.ERR_BAD_OPTION)}}const ua={assertOptions:jb,validators:Ha},Dt=ua.validators;let xn=class{constructor(o){this.defaults=o||{},this.interceptors={request:new nl,response:new nl}}async request(o,t){try{return await this._request(o,t)}catch(a){if(a instanceof Error){let r={};Error.captureStackTrace?Error.captureStackTrace(r):r=new Error;const i=r.stack?r.stack.replace(/^.+\n/,""):"";try{a.stack?i&&!String(a.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(a.stack+=`
|
|
38
|
+
`+i):a.stack=i}catch{}}throw a}}_request(o,t){typeof o=="string"?(t=t||{},t.url=o):t=o||{},t=En(this.defaults,t);const{transitional:a,paramsSerializer:r,headers:i}=t;a!==void 0&&ua.assertOptions(a,{silentJSONParsing:Dt.transitional(Dt.boolean),forcedJSONParsing:Dt.transitional(Dt.boolean),clarifyTimeoutError:Dt.transitional(Dt.boolean)},!1),r!=null&&(H.isFunction(r)?t.paramsSerializer={serialize:r}:ua.assertOptions(r,{encode:Dt.function,serialize:Dt.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),ua.assertOptions(t,{baseUrl:Dt.spelling("baseURL"),withXsrfToken:Dt.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=i&&H.merge(i.common,i[t.method]);i&&H.forEach(["delete","get","head","post","put","patch","common"],v=>{delete i[v]}),t.headers=vt.concat(s,i);const l=[];let c=!0;this.interceptors.request.forEach(function(b){typeof b.runWhen=="function"&&b.runWhen(t)===!1||(c=c&&b.synchronous,l.unshift(b.fulfilled,b.rejected))});const d=[];this.interceptors.response.forEach(function(b){d.push(b.fulfilled,b.rejected)});let u,p=0,m;if(!c){const v=[dl.bind(this),void 0];for(v.unshift(...l),v.push(...d),m=v.length,u=Promise.resolve(t);p<m;)u=u.then(v[p++],v[p++]);return u}m=l.length;let f=t;for(p=0;p<m;){const v=l[p++],b=l[p++];try{f=v(f)}catch(S){b.call(this,S);break}}try{u=dl.call(this,f)}catch(v){return Promise.reject(v)}for(p=0,m=d.length;p<m;)u=u.then(d[p++],d[p++]);return u}getUri(o){o=En(this.defaults,o);const t=Rc(o.baseURL,o.url,o.allowAbsoluteUrls);return Tc(t,o.params,o.paramsSerializer)}};H.forEach(["delete","get","head","options"],function(o){xn.prototype[o]=function(t,a){return this.request(En(a||{},{method:o,url:t,data:(a||{}).data}))}});H.forEach(["post","put","patch"],function(o){function t(a){return function(i,s,l){return this.request(En(l||{},{method:o,headers:a?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}xn.prototype[o]=t(),xn.prototype[o+"Form"]=t(!0)});let Xb=class Uc{constructor(o){if(typeof o!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(i){t=i});const a=this;this.promise.then(r=>{if(!a._listeners)return;let i=a._listeners.length;for(;i-- >0;)a._listeners[i](r);a._listeners=null}),this.promise.then=r=>{let i;const s=new Promise(l=>{a.subscribe(l),i=l}).then(r);return s.cancel=function(){a.unsubscribe(i)},s},o(function(i,s,l){a.reason||(a.reason=new Gn(i,s,l),t(a.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(o){if(this.reason){o(this.reason);return}this._listeners?this._listeners.push(o):this._listeners=[o]}unsubscribe(o){if(!this._listeners)return;const t=this._listeners.indexOf(o);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const o=new AbortController,t=a=>{o.abort(a)};return this.subscribe(t),o.signal.unsubscribe=()=>this.unsubscribe(t),o.signal}static source(){let o;return{token:new Uc(function(r){o=r}),cancel:o}}};function Zb(n){return function(t){return n.apply(null,t)}}function Yb(n){return H.isObject(n)&&n.isAxiosError===!0}const Yr={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(Yr).forEach(([n,o])=>{Yr[o]=n});function Oc(n){const o=new xn(n),t=gc(xn.prototype.request,o);return H.extend(t,xn.prototype,o,{allOwnKeys:!0}),H.extend(t,o,null,{allOwnKeys:!0}),t.create=function(r){return Oc(En(n,r))},t}const Ye=Oc(Po);Ye.Axios=xn;Ye.CanceledError=Gn;Ye.CancelToken=Xb;Ye.isCancel=Ic;Ye.VERSION=Dc;Ye.toFormData=Ya;Ye.AxiosError=Te;Ye.Cancel=Ye.CanceledError;Ye.all=function(o){return Promise.all(o)};Ye.spread=Zb;Ye.isAxiosError=Yb;Ye.mergeConfig=En;Ye.AxiosHeaders=vt;Ye.formToJSON=n=>Fc(H.isHTMLForm(n)?new FormData(n):n);Ye.getAdapter=Ac.getAdapter;Ye.HttpStatusCode=Yr;Ye.default=Ye;const{Axios:p3,AxiosError:f3,CanceledError:h3,isCancel:v3,CancelToken:g3,VERSION:y3,all:b3,Cancel:w3,isAxiosError:k3,spread:x3,toFormData:S3,AxiosHeaders:E3,HttpStatusCode:V3,formToJSON:C3,getAdapter:N3,mergeConfig:_3}=Ye;class gi{constructor(o="/api/v1"){this.eventSource=null,this.progressCallbacks=new Map,this.api=Ye.create({baseURL:o,headers:{"Content-Type":"application/json",Accept:"application/json"}}),this.api.interceptors.request.use(t=>{const a=this.getAuthToken();return a&&(t.headers.Authorization=`Bearer ${a}`),t}),this.api.interceptors.response.use(t=>t,t=>{var a;return(a=t.response)==null||a.status,Promise.reject(t)})}async createJob(o){try{const t=await this.api.post("/video/jobs",o);return this.normalizeJob(t.data.data)}catch(t){throw t}}async createRenderJob(o){try{const t=await this.api.post("/video/jobs/render",o);return this.normalizeJob(t.data.data)}catch(t){throw t}}async pollRenderJob(o,t,a=3e3,r=6e5){const i=Date.now();return new Promise((s,l)=>{const c=setInterval(async()=>{try{const d=await this.getJob(o);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()-i>r&&(clearInterval(c),l(new Error("Render job timed out")))}catch(d){clearInterval(c),l(d)}},a)})}async getJob(o){try{const t=await this.api.get(`/video/jobs/${o}`);return this.normalizeJob(t.data.data)}catch(t){throw t}}async listJobs(o){try{return(await this.api.get("/video/jobs",{params:o})).data}catch(t){throw t}}async cancelJob(o){try{await this.api.delete(`/video/jobs/${o}`),this.unsubscribeFromProgress(o)}catch(t){throw t}}async retryJob(o){try{const t=await this.api.post(`/video/jobs/${o}/retry`);return this.normalizeJob(t.data.data)}catch(t){throw t}}subscribeToProgress(o,t){this.progressCallbacks.set(o,t),this.eventSource||this.initializeEventSource(),this.eventSource||this.pollProgress(o)}unsubscribeFromProgress(o){this.progressCallbacks.delete(o),this.progressCallbacks.size===0&&this.eventSource&&(this.eventSource.close(),this.eventSource=null)}initializeEventSource(){try{const o=this.getAuthToken(),t=`/api/v1/video/jobs/events${o?`?token=${o}`:""}`;this.eventSource=new EventSource(t),this.eventSource.addEventListener("progress",a=>{const r=JSON.parse(a.data),i=this.progressCallbacks.get(r.jobId);i&&i(r.progress)}),this.eventSource.addEventListener("complete",a=>{const r=JSON.parse(a.data),i=this.progressCallbacks.get(r.jobId);i&&(i(100),this.unsubscribeFromProgress(r.jobId))}),this.eventSource.addEventListener("error",a=>{this.progressCallbacks.forEach((r,i)=>{this.pollProgress(i)})})}catch{}}async pollProgress(o){const t=setInterval(async()=>{try{const a=await this.getJob(o),r=this.progressCallbacks.get(o);r&&r(a.progress),(a.status==="completed"||a.status==="failed")&&(clearInterval(t),this.unsubscribeFromProgress(o))}catch{clearInterval(t)}},2e3)}getAuthToken(){const o=localStorage.getItem("auth_token");if(o)return o;const t=document.cookie.split(";");for(const a of t){const[r,i]=a.trim().split("=");if(r==="auth_token")return decodeURIComponent(i)}return null}async downloadVideo(o){try{return(await this.api.get(`/video/jobs/${o}/download`,{responseType:"blob"})).data}catch(t){throw t}}async getThumbnail(o,t=0){try{const a=await this.api.get(`/video/jobs/${o}/thumbnail`,{params:{time:t},responseType:"blob"});return URL.createObjectURL(a.data)}catch(a){throw a}}normalizeJob(o){const t=o,a={...t,user_id:t.user_id??t.userId??"",source_media_id:t.source_media_id??t.sourceMediaId??"",created_at:t.created_at??t.createdAt??"",updated_at:t.updated_at??t.updatedAt??""},r=t.output_media_id??t.outputMediaId;typeof r=="string"&&r!==""&&(a.output_media_id=r);const i=t.error_message??t.errorMessage;typeof i=="string"&&i!==""&&(a.error_message=i);const s=t.started_at??t.startedAt;typeof s=="string"&&s!==""&&(a.started_at=s);const l=t.completed_at??t.completedAt;return typeof l=="string"&&l!==""&&(a.completed_at=l),a}}new gi;const Gb={key:0,class:"mobile-layout"},Hb={class:"preview-section"},Jb={class:"controls-section"},qb={class:"tab-nav"},Kb=["onClick"],Qb={class:"tab-content"},ew={class:"filters-panel"},tw={class:"adjustments-panel"},nw={class:"text-panel"},ow={class:"transitions-panel"},aw={class:"audio-panel"},rw={class:"export-panel"},iw={key:0,"data-testid":"video-export-status-completed"},sw={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},lw={key:1,class:"desktop-layout"},cw={class:"desktop-main-row"},dw={class:"preview-panel"},uw={class:"fit-toggle"},mw={class:"editor-content"},pw={class:"editor-tabs"},fw={class:"tab-header"},hw=["onClick"],vw={class:"tab-content-area"},gw={class:"filter-controls"},yw={class:"text-controls"},bw={class:"transition-controls"},ww={class:"audio-controls"},kw={class:"adjustments-controls"},xw={key:1,class:"no-filter-selected"},Sw={class:"export-controls"},Ew={key:0,"data-testid":"video-export-status-completed"},Vw={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},Cw={class:"desktop-timeline-row"},Nw={class:"timeline-zoom"},_w=["value"],Tw={class:"zoom-readout"},Mw={key:0,class:"dev-editor-controls","data-testid":"video-editor-dev-controls"},Fw={class:"dev-editor-row"},Iw={class:"dev-editor-field"},Bw={class:"dev-editor-field"},Rw=["disabled"],Pw=["disabled"],$w=["disabled"],zw={class:"dev-editor-row"},Aw={class:"dev-editor-field dev-editor-field--wide"},Dw=["value"],Uw=["disabled"],Ow=["disabled"],Lw=["disabled"],Ww=["disabled"],jw=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"],setup(n,{expose:o,emit:t}){const a=n,r=t,i=e.computed(()=>{if(!a.media||typeof a.media!="object")return;const k=a.media.uuid??a.media.id;return typeof k=="string"&&k.trim()!==""?k.trim():void 0}),s=e.computed(()=>{const k=typeof a.mediaUuid=="string"?a.mediaUuid.trim():"";return k!==""?k:i.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 k=a.workflowMode==="uploader"?{filters:!0,adjustments:!0,text:!1,transitions:!1,audio:!1,export:!1}:{filters:!0,adjustments:!0,text:!0,transitions:!0,audio:!0,export:!0},V=a.featureFlags;return V?{filters:typeof V.filters=="boolean"?V.filters:k.filters,adjustments:typeof V.adjustments=="boolean"?V.adjustments:k.adjustments,text:typeof V.text=="boolean"?V.text:k.text,transitions:typeof V.transitions=="boolean"?V.transitions:k.transitions,audio:typeof V.audio=="boolean"?V.audio:k.audio,export:typeof V.export=="boolean"?V.export:k.export}:k}),p=e.computed(()=>l.value?c.value:d.value),m=e.computed(()=>p.value==="filters"||S.value),f=e.computed(()=>p.value!=="filters"&&!S.value),v=e.ref(null),b=e.ref(null),S=e.ref(!1),M=e.computed(()=>l.value?v.value:b.value);function E(k){return k==="contain"||k==="cover"||k==="none"}function y(k){if(!(k!=null&&k.metadata))return null;const V=k.metadata.fit_mode;return E(V)?V:null}const h=e.shallowRef(null),w=e.ref(null),R=e.ref(y(a.initialRecipe)??"contain"),N=e.ref(null),g=e.ref(null),C=e.ref(null),A=e.ref(!1),x=new Map,T=e.ref([]),I=e.ref([]),z=e.ref([]),P=e.ref([]),j=e.ref(1),L=()=>{l.value=window.innerWidth<768},_=[{id:"filters",label:"Filters",icon:ln},{id:"adjustments",label:"Adjust",icon:fm},{id:"text",label:"Text",icon:"text-outline"},{id:"transitions",label:"Transitions",icon:"swap-horizontal-outline"},{id:"audio",label:"Audio",icon:"musical-notes-outline"},{id:"export",label:"Export",icon:Na}],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"}],G=e.computed(()=>_.filter(k=>u.value[k.id])),X=e.computed(()=>D.filter(k=>u.value[k.id])),ce=e.computed(()=>{var k,V;return((k=X.value[0])==null?void 0:k.id)??((V=G.value[0])==null?void 0:V.id)??"filters"});e.watch(u,k=>{k[c.value]||(c.value=ce.value),k[d.value]||(d.value=ce.value)},{immediate:!0,deep:!0}),e.watch(ce,k=>{u.value[c.value]||(c.value=k),u.value[d.value]||(d.value=k)},{immediate:!0}),e.watch(u,k=>{k.export||(c.value==="export"&&(c.value=ce.value),d.value==="export"&&(d.value=ce.value))},{immediate:!0,deep:!0});const Me=e.computed(()=>typeof window>"u"?!1:window.__MEDIABLES_EDITOR_DEV__===!0),{currentFrame:$e,playheadPosition:ae,timelineClips:F,totalDuration:O,hasChanges:de,isPlaying:re,selectedClip:q,zoomLevel:ee,playbackSpeed:ue,handleTrim:ge,handleSplit:xe,handleClipSelect:ne,splitAtPlayhead:ke,deleteSelectedClip:he,duplicateSelectedClip:qe,setZoomLevel:ct,moveClip:pt,setFilters:me,setTextOverlays:W,setAudioTracks:J,saveDraft:te,clearHasChanges:oe,resetChanges:pe,generateRecipe:be,zoomIn:Be,zoomOut:De,fitToWindow:Y,togglePlayback:ie,setPlaying:we,seekTo:Ve,frameForward:Le,frameBackward:yt,skipToStart:dt,skipToEnd:Vt,setPlaybackSpeed:Ge,updateSourceDuration:Gt}=ry(s.value,a.initialRecipe,a.media),{videoCompatibleFilters:Qa,activeFilters:Ke,selectedFilter:$o,previewFilter:zo,previewFilterEffect:td,applyFilter:Ci,updateFilterParams:nd,removeFilter:od,clearAllFilters:Ni,setActiveFilters:ad}=hy();function Hn(k){var Z,K;const V=((Z=q.value)==null?void 0:Z.id)??((K=F.value[0])==null?void 0:K.id);V&&(A.value=!0,typeof k=="object"&&k.id?Ci(k.id):typeof k=="string"&&Ci(k),me(Ke.value),h.value?h.value.setClipFilters(V,Ke.value):x.set(V,[...Ke.value]),ne(V),A.value=!1,Pt())}function rd(){var V,Z;const k=((V=q.value)==null?void 0:V.id)??((Z=F.value[0])==null?void 0:Z.id);k&&ne(k)}function _i(k){const V=Ke.value.find(Z=>Z.filterId===k);V&&od(V.id)}const Ao=e.computed(()=>Qa.value.map(V=>{var K;const Z=[];if(V.controls&&V.controls.length>0)for(const se of V.controls){const Q=se.type;if(Q==="button"||Q==="text"||Q==="range")continue;const le={id:se.property||se.id,label:se.label||se.id,type:Q,default:se.default??(Q==="toggle"?!1:Q==="color"?"#ffffff":0)};Q==="slider"&&(le.min=se.min??0,le.max=se.max??1,le.step=se.step??.01),Q==="select"&&se.options&&(le.options=se.options),Z.push(le)}else if(V.paramRanges){const se=Object.entries(V.paramRanges);for(const[Q,le]of se){const Re=Q.replace(/[-_]/g," ").replace(/\b\w/g,$t=>$t.toUpperCase()),ut=(K=V.defaultParams)==null?void 0:K[Q],Jt=(le.min+le.max)/2;Z.push({id:Q,label:Re,min:le.min,max:le.max,step:le.step??.01,default:typeof ut=="number"?ut:Jt})}}return{id:V.id,name:V.name,category:V.category,params:Z}})),_n=e.ref("0.00"),Tn=e.ref("0.00"),tn=e.ref("");e.watch(Ao,k=>{if(k.length===0){tn.value="";return}k.some(Z=>Z.id===tn.value)||(tn.value=k[0].id)},{immediate:!0});const ot=e.ref(!1),Xe=e.ref(0),Tt=e.ref(!1),We=e.ref(null),Mt=e.ref(null);let Do=null,Ct=!1,Ht=null;const Ti=e.computed(()=>{const k=new Map;return Ke.value.forEach(V=>k.set(V.filterId,V)),k}),Mi=e.computed(()=>{var k,V;return $e.value?$e.value:((k=a.media)==null?void 0:k.thumbnail_url)||((V=a.media)==null?void 0:V.url)}),Rt=e.ref("");e.watch(()=>{var k,V;return{file:(k=a.media)==null?void 0:k.file,url:(V=a.media)==null?void 0:V.url}},(k,V,Z)=>{var se,Q;const K=Rt.value;Z(()=>{K&&K.startsWith("blob:")&&URL.revokeObjectURL(K)}),(se=a.media)!=null&&se.file?Rt.value=URL.createObjectURL(a.media.file):(Q=a.media)!=null&&Q.url?Rt.value=a.media.url:Rt.value=""},{immediate:!0}),e.onUnmounted(()=>{Rt.value&&Rt.value.startsWith("blob:")&&URL.revokeObjectURL(Rt.value)});const er=e.computed(()=>Rt.value),Fi=e.computed(()=>{if(!a.media)return null;const{file:k,...V}=a.media;return{...V,url:Rt.value}}),Ii=e.computed(()=>{var V;const k=(V=a.media)==null?void 0:V.url;return!!(k&&/^https?:/i.test(k))}),Bi=e.computed(()=>Ke.value),Ri=e.computed(()=>ae.value),id=e.computed(()=>!!q.value&&ae.value>0),sd=e.computed(()=>!!q.value&&F.value.length>1),tr=e.ref(0),nn=e.computed(()=>{try{const k=O.value??O;return k&&typeof k=="number"&&k>0?k:tr.value}catch{return tr.value}}),Mn=e.ref(),Uo=e.ref(0),Oo=e.ref(!1);e.watch(nn,k=>{var Z;if(Oo.value||!k||k<=0)return;const V=Uo.value||((Z=Mn.value)==null?void 0:Z.clientWidth)||0;V>0&&(Oo.value=!0,Y(V))}),e.watch(Uo,k=>{if(Oo.value||!k||k<=0)return;nn.value>0&&(Oo.value=!0,Y(k))});function Fn(k){return Number.isFinite(k)?k.toFixed(2):"0.00"}function Pi(k){const V=Number(k);return Number.isFinite(V)?V:null}function ld(k){k&&(_n.value=Fn(k.sourceIn),Tn.value=Fn(k.sourceOut))}e.watch(()=>{var k,V,Z;return[(k=q.value)==null?void 0:k.id,(V=q.value)==null?void 0:V.sourceIn,(Z=q.value)==null?void 0:Z.sourceOut]},()=>{ld(q.value)},{immediate:!0});function $i(k){const V=q.value;if(!V)return;const Z=1/30,K=V.sourceMinIn??0,se=V.sourceMaxOut??nn.value,Q=V.sourceIn+(ae.value-V.timelineStart);if(k==="start"){const Re=Math.max(K,Math.min(Q,V.sourceOut-Z));_n.value=Fn(Re);return}const le=Math.max(V.sourceIn+Z,Math.min(Q,se));Tn.value=Fn(le)}function cd(){const k=q.value;if(!k)return;const V=Pi(_n.value),Z=Pi(Tn.value);if(V===null||Z===null)return;const K=1/30,se=k.sourceMinIn??0,Q=k.sourceMaxOut??nn.value,le=Math.max(se,Math.min(V,Q-K)),Re=Math.max(le+K,Math.min(Z,Q));ge(k.id,"start",le),ge(k.id,"end",Re),_n.value=Fn(le),Tn.value=Fn(Re),q.value&&Ve(q.value.timelineStart)}function dd(){tn.value.trim()!==""&&Hn(tn.value)}function ud(){var k;Ni(),me(Ke.value),(k=q.value)!=null&&k.id&&(h.value?h.value.setClipFilters(q.value.id,Ke.value):x.set(q.value.id,[...Ke.value])),Pt()}function zi(k,V,Z){var se,Q;const K=Ke.value.find(le=>le.filterId===k);K?(K.params={...K.params,[V]:Z},me(Ke.value),h.value&&((se=q.value)!=null&&se.id)?h.value.setClipFilters(q.value.id,Ke.value):(Q=q.value)!=null&&Q.id&&x.set(q.value.id,[...Ke.value]),Pt(),rd()):zo.value&&zo.value.filterId===k&&(zo.value.params={...zo.value.params||{},[V]:Z})}function Ai(k){Ve(k)}function Di(k){we(k)}function Lo(k){!Number.isFinite(k)||k<=0||(tr.value=k,Gt(k))}function md(){var V;const k=Uo.value||((V=Mn.value)==null?void 0:V.clientWidth)||800;Y(k)}function pd(k){const V=k.target,Z=Number(V.value);ct(Z)}function Ui(k){var V;h.value=k,(V=h.value)!=null&&V.composition&&(N.value=new vy(h.value.composition),g.value=new xa(h.value.composition),C.value=new gy(h.value.composition));try{x.size&&(x.forEach((Z,K)=>{h.value.setClipFilters(K,Z)}),x.clear(),h.value.composition.computeFrame())}catch{}}function Oi(k){k!=null&&k.id&&td(k.id)}function Li(k){nd(k),Pt()}async function Wi(k){if(!N.value)return;const V=await N.value.addTextOverlay(k);T.value.push({id:V,...k})}async function ji(k,V){if(!N.value)return;await N.value.updateTextOverlay(k,V);const Z=T.value.findIndex(K=>K.id===k);Z!==-1&&(T.value[Z]={...T.value[Z],...V})}async function Xi(k){N.value&&(await N.value.removeTextOverlay(k),T.value=T.value.filter(V=>V.id!==k))}async function Zi(k){if(!g.value||P.value.length<2)return;const[V,Z]=P.value,K=await g.value.applyTransition(V,Z,k);I.value.push({id:K,...k,name:k.type})}function Yi(k){if(!g.value)return;const V=I.value[k];V&&(g.value.removeTransition(V.id),I.value.splice(k,1))}function Gi(k){}async function Hi(k){if(!C.value)return;const V=await C.value.addAudioTrack(k);z.value.push({id:V,...k})}async function Ji(k,V){if(!C.value)return;const Z=z.value.findIndex(K=>K.id===k);Z!==-1&&(z.value[Z]={...z.value[Z],...V})}async function qi(k){C.value&&(await C.value.removeAudioTrack(k),z.value=z.value.filter(V=>V.id!==k))}async function Ki(k,V){if(!C.value)return;await C.value.updateVolume(k,V);const Z=z.value.find(K=>K.id===k);Z&&(Z.volume=V)}async function Qi(k,V){if(!C.value)return;await C.value.muteTrack(k,V);const Z=z.value.find(K=>K.id===k);Z&&(Z.muted=V)}function es(k){C.value&&(C.value.setMasterVolume(k),j.value=k)}function fd(k){r("thumbnail-selected",k)}function on(){Do!==null&&(clearInterval(Do),Do=null)}function hd(k,V){return V?{...k,output:{...k.output,format:V.format,quality:V.quality}}:k}function Jn(k){var V;return k.metadata||(k.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),k.metadata.fit_mode=R.value,(V=a.media)!=null&&V.url&&/^https?:/i.test(a.media.url)?k.metadata.source_url=a.media.url:delete k.metadata.source_url,k}function Ze(k,V,Z){return Math.min(Z,Math.max(V,k))}function nr(k,V){if(typeof k=="number"&&Number.isFinite(k))return k;if(typeof k=="string"){const Z=Number(k);if(Number.isFinite(Z))return Z}return V}function rt(k,V,Z){for(const K of V)if(K in k)return nr(k[K],Z);return Z}function vd(k){const V=typeof k.params=="object"&&k.params!==null?k.params:{};switch(k.filterId.trim().toLowerCase()){case"brightness":return[{type:"brightness",value:Ze(rt(V,["value","brightness"],0),-1,1)}];case"contrast":return[{type:"contrast",value:Ze(rt(V,["value","contrast"],1),.1,3)}];case"saturation":return[{type:"saturation",value:Ze(rt(V,["value","saturation"],1),0,3)}];case"blur":case"gaussian-blur":case"kawase-blur":case"radial-blur":return[{type:"blur",value:Ze(rt(V,["value","blur","radius"],0),0,25)}];case"sharpen":return[{type:"sharpen",value:Ze(rt(V,["value","amount"],1),0,5)}];case"sepia":return[{type:"sepia",value:1}];case"grayscale":return[{type:"grayscale",value:1}];case"adjustment":{const K=Ze(rt(V,["brightness"],1)-1,-1,1),se=Ze(rt(V,["contrast"],1),.1,3),Q=Ze(rt(V,["saturation"],1),0,3);return[{type:"brightness",value:K},{type:"contrast",value:se},{type:"saturation",value:Q}]}default:return[]}}function gd(k){const V=k.timeline[0],Z=Array.isArray(V==null?void 0:V.filters)?V.filters:[],K=[];for(const Q of Z)if(K.push(...vd(Q)),K.length>=12)break;const se={...k,filters:K.slice(0,12)};if(k.timeline.length===1&&V){const Q=Math.max(0,nr(V.sourceIn,0)),le=nr(V.sourceOut,Q);le>Q&&(se.trim={start:Q,end:le})}return se}function yd(k){return{"360p":[640,360],"480p":[854,480],"720p":[1280,720],"1080p":[1920,1080],"1440p":[2560,1440],"2160p":[3840,2160]}[k??""]??[1920,1080]}function bd(k){if(!k||typeof k!="object")return null;const V=k.duration;if(typeof V=="number"&&Number.isFinite(V)&&V>0)return V;if(V&&typeof V=="object"&&"value"in V){const Z=V.value;if(typeof Z=="number"&&Number.isFinite(Z)&&Z>0)return Z}return null}async function ts(k,V,Z){var Jt,$t,zt,At;const K=k.timeline[0],se=K?Math.max(0,K.sourceIn):0,Q=K?K.sourceOut:void 0,[le,Re]=yd((V==null?void 0:V.quality)??((Jt=k.output)==null?void 0:Jt.quality)),ut=(($t=k.output)==null?void 0:$t.fps)||30;we(!1),S.value=!0,await e.nextTick();try{const et=[200,500,1e3];let it=!1;for(const cr of et){await new Promise(Ad=>setTimeout(Ad,cr));const jo=M.value;if(!(!jo||typeof jo.captureFrameAt!="function")&&typeof jo.ensureReadyForCapture=="function"&&(it=await jo.ensureReadyForCapture(),it))break}const bt=M.value;if(!bt||typeof bt.captureFrameAt!="function")throw new Error("PIXI preview not available for export. Ensure the preview is mounted.");if(!it)throw new Error("PIXI preview not ready for frame capture after retries. The video may still be loading.");const{exportWithPixiFrames:Wo,isWebCodecsSupported:qn}=await Promise.resolve().then(()=>require("./PixiFrameExporter-DT4-swZ4.cjs"));if(!qn())throw new Error("WebCodecs is not supported in this browser. Export requires Chrome 94+ or equivalent.");Ht=new AbortController;const In={width:le,height:Re,fps:ut,trimStart:se,signal:Ht.signal};Q!==void 0&&(In.trimEnd=Q),Z&&(In.onProgress=Z);const ds=Rt.value;ds!==""&&(In.sourceUrl=ds);const Bd=typeof bt.duration=="number"&&bt.duration>0?bt.duration:((zt=k.source)==null?void 0:zt.duration)??Q??0,Rd=await Wo({captureFrameAt:cr=>bt.captureFrameAt(cr),duration:{value:Bd}},In),lr=new File([Rd],`edited-video-${Date.now()}.mp4`,{type:"video/mp4"}),Pd=bd(bt),$d=((At=k.source)==null?void 0:At.duration)??0,zd=Math.max(0,(Q??Pd??$d)-se);return{file:lr,recipe:k,meta:{duration:zd,width:le,height:Re,format:"mp4",sizeBytes:lr.size,size_bytes:lr.size}}}finally{S.value=!1,Ht=null}}async function wd(k,V){var At;on(),Ct=!1,Ht=null,Mt.value=null,We.value=null,Tt.value=!1,Xe.value=0;const Z=Jn(k??be()),K=ls(Z),se=Array.isArray(K.filters)&&K.filters.length>0,Q=rr(K);if(!(de.value||se||Q))return oe(),r("video-exported",null),null;const Re=K.timeline[0],ut=Re?Math.max(0,Re.sourceIn):0,$t=((Re==null?void 0:Re.sourceOut)??((At=K.source)==null?void 0:At.duration)??nn.value)-ut,zt=a.serverRenderEndpoint!=null&&a.clientExportThreshold>0&&$t>a.clientExportThreshold;if(zt){ot.value=!0;try{return await kd(K),null}catch(et){const it=et instanceof Error?et.message:"Server render failed";throw We.value=it,r("server-render-failed",it),et}finally{ot.value=!1}}if(a.maxDuration>0&&$t>a.maxDuration&&!zt){const et=`This video is too long for in-browser export (${Math.round($t)}s). Server rendering is not available. Try a shorter clip.`;return We.value=et,r("video-exported",null),null}ot.value=!0;try{const et=await ts(K,V,it=>{Ct||(Xe.value=it)});return Ct?(We.value="Export canceled.",Xe.value=0,r("video-exported",null),null):(oe(),r("recipe-generated",K),r("video-exported",et),Xe.value=100,Tt.value=!0,et)}catch(et){if(Ct)return We.value="Export canceled.",Xe.value=0,r("video-exported",null),null;const it=et instanceof Error?et.message:"Local WebGL export failed.";throw We.value=it,new Error(`Video export failed: ${it}`)}finally{ot.value=!1}}async function kd(k){const V=new gi(a.serverRenderEndpoint??"/api/v1");We.value="Starting server render...",Xe.value=0;const Z=await V.createRenderJob({source_media_uuid:s.value,recipe:k});Mt.value=Z.id,r("server-render-started",Z.id),r("export-started",Z.id),We.value="Rendering on server...";const K=await V.pollRenderJob(Z.id,(Q,le)=>{Xe.value=Q,le==="processing"&&(We.value=`Server rendering: ${Q}%`)},3e3,(a.maxDuration>0?a.maxDuration*3:1800)*1e3);Xe.value=100,Tt.value=!0,We.value="Server render complete!",oe(),r("recipe-generated",k);const se={id:K.id};typeof K.output_media_id=="string"&&K.output_media_id!==""&&(se.output_media_id=K.output_media_id),r("server-render-completed",se)}async function ns(){if(!ot.value)return;Ct=!0,S.value=!1,Ht&&(Ht.abort(),Ht=null),on();const k=Mt.value;if(k)try{const V=await fetch(`/api/v1/video/jobs/${k}`,{method:"DELETE"});if(!V.ok)throw new Error(`Cancel failed: ${V.status} ${V.statusText}`)}catch(V){const Z=V instanceof Error?V.message:"Failed to cancel export";We.value=Z,ot.value=!1,Mt.value=null;return}ot.value=!1,Xe.value=0,Tt.value=!1,Mt.value=null,We.value="Export canceled."}async function os(k){on(),Ct=!1,Ht=null,Mt.value=null,We.value=null,Tt.value=!1,ot.value=!0,Xe.value=0;try{const V=Jn(hd(be(),k));r("recipe-generated",V);const Z=s.value.startsWith("temp-"),K=V.timeline[0],se=Array.isArray(K==null?void 0:K.filters)?K.filters:[],Q=!0,le=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 ts(V,k,In=>{Ct||(Xe.value=In)});if(Ct){We.value="Export canceled.",ot.value=!1,Xe.value=0;return}r("video-exported",bt);const Wo=URL.createObjectURL(bt.file),qn=document.createElement("a");qn.href=Wo,qn.download=`edited-video-${Date.now()}.mp4`,qn.click(),setTimeout(()=>URL.revokeObjectURL(Wo),100),ot.value=!1,Xe.value=100,Tt.value=!0;return}catch(bt){if(Ct){We.value="Export canceled.",ot.value=!1,Xe.value=0;return}if(Z||!le)throw bt;Xe.value=0,We.value="Local filter export failed, falling back to server render."}const Re={"360p":"low","480p":"low","720p":"medium","1080p":"high","1440p":"ultra","2160p":"ultra"},ut=(k==null?void 0:k.quality)??V.output.quality,Jt=Re[ut]??"high",$t={...gd(V),export:{format:(k==null?void 0:k.format)??V.output.format,quality:Jt,resolution:ut,framerate:V.output.fps}},zt=await fetch("/api/v1/video/jobs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source_media_id:s.value,recipe:$t})});if(!zt.ok)throw new Error(`Export failed: ${zt.status} ${zt.statusText}`);const At=await zt.json(),et=(At==null?void 0:At.data)??At,it=typeof(et==null?void 0:et.id)=="string"?et.id:null;if(!it)throw new Error("Export failed: missing job id");Mt.value=it,r("export-started",it),Id(it)}catch(V){if(S.value=!1,Ht=null,Ct){We.value="Export canceled.",ot.value=!1,Xe.value=0,Mt.value=null;return}try{const Z=Jn(be()),K=new Blob([JSON.stringify(Z,null,2)],{type:"application/json"}),se=URL.createObjectURL(K),Q=document.createElement("a");Q.href=se,Q.download=`video-recipe-${Date.now()}.json`,Q.click(),setTimeout(()=>URL.revokeObjectURL(se),100)}finally{ot.value=!1,Xe.value=0,Mt.value=null,We.value=V instanceof Error?V.message:"Export failed"}}}const or=async k=>{await new Promise(V=>{window.setTimeout(V,k)})},ar=k=>{if(!k||k.width<=0||k.height<=0)return null;try{return k.toDataURL("image/jpeg",.85)}catch{return null}},xd=k=>{if(!k||typeof k!="object")return null;const Z=k.pixiCanvas;if(Z&&typeof Z=="object"&&"value"in Z){const K=Z.value;return K instanceof HTMLCanvasElement?K:null}return Z instanceof HTMLCanvasElement?Z:null},Sd=k=>{if(!k||typeof k!="object")return null;const V=k.duration;if(typeof V=="number"&&Number.isFinite(V))return V;if(V&&typeof V=="object"&&"value"in V){const Z=V.value;if(typeof Z=="number"&&Number.isFinite(Z))return Z}return null},Ed=k=>{if(!k||typeof k!="object")return null;const Z=k.videoElement;if(Z&&typeof Z=="object"&&"value"in Z){const K=Z.value;return K instanceof HTMLVideoElement?K:null}return Z instanceof HTMLVideoElement?Z:null},as=k=>typeof k.params=="object"&&k.params!==null?k.params:{},Vd=k=>{const V=[];for(const Z of k){const K=as(Z),se=Z.filterId.trim().toLowerCase();if(se==="brightness"){const le=(Ze(rt(K,["value","brightness"],0),-1,1)+1)*100;V.push(`brightness(${le.toFixed(2)}%)`);continue}if(se==="contrast"){const Q=Ze(rt(K,["value","contrast"],1),.1,4);V.push(`contrast(${(Q*100).toFixed(2)}%)`);continue}if(se==="saturation"||se==="saturate"){const Q=Ze(rt(K,["value","saturation"],1),0,4);V.push(`saturate(${(Q*100).toFixed(2)}%)`);continue}if(se==="grayscale"){V.push("grayscale(100%)");continue}if(se==="sepia"){V.push("sepia(100%)");continue}if(se==="blur"||se==="gaussian-blur"||se==="kawase-blur"){const Q=Ze(rt(K,["value","blur","radius"],0),0,30);Q>.01&&V.push(`blur(${Q.toFixed(2)}px)`);continue}if(se==="adjustment"){const Q=rt(K,["brightness"],1),le=rt(K,["contrast"],1),Re=rt(K,["saturation"],1);Math.abs(Q-1)>.01&&V.push(`brightness(${(Ze(Q,0,5)*100).toFixed(2)}%)`),Math.abs(le-1)>.01&&V.push(`contrast(${(Ze(le,.1,5)*100).toFixed(2)}%)`),Math.abs(Re-1)>.01&&V.push(`saturate(${(Ze(Re,0,5)*100).toFixed(2)}%)`);continue}if(se==="cinematic"){V.push("contrast(120%) brightness(95%) saturate(85%)");continue}if(se==="dramatic"){V.push("contrast(140%) brightness(90%) saturate(110%) sepia(10%)");continue}if(se==="dreamy"){V.push("blur(0.5px) brightness(105%) saturate(90%) contrast(95%)");continue}}return V.join(" ")},Cd=k=>{const V=k.find(se=>se.filterId.trim().toLowerCase()==="noise");if(!V)return 0;const Z=as(V),K=rt(Z,["noise","value","amount","intensity"],.2);return K<=1?Ze(K,0,1):Ze(K/100,0,1)},Nd=(k,V,Z,K)=>{if(K<=0)return;const se=k.getImageData(0,0,V,Z),Q=255*K;for(let le=0;le<se.data.length;le+=4){const Re=(Math.random()*2-1)*Q;se.data[le]=Ze(se.data[le]+Re,0,255),se.data[le+1]=Ze(se.data[le+1]+Re,0,255),se.data[le+2]=Ze(se.data[le+2]+Re,0,255)}k.putImageData(se,0,0)},rs=async k=>{k.readyState>=2&&k.videoWidth>0&&k.videoHeight>0||await new Promise(V=>{let Z=!1,K=0;const se=()=>{Z||(Z=!0,k.removeEventListener("loadedmetadata",Q),k.removeEventListener("loadeddata",Q),k.removeEventListener("canplay",Q),window.clearTimeout(K),V())},Q=()=>{se()};k.addEventListener("loadedmetadata",Q),k.addEventListener("loadeddata",Q),k.addEventListener("canplay",Q),K=window.setTimeout(()=>se(),800),k.play().catch(()=>{})})},_d=async(k,V)=>{await new Promise(Z=>{let K=!1,se=0;const Q=()=>{K||(K=!0,k.removeEventListener("seeked",le),window.clearTimeout(se),Z())},le=()=>{Q()};if(Math.abs(k.currentTime-V)<.016){requestAnimationFrame(()=>Q());return}k.addEventListener("seeked",le),se=window.setTimeout(()=>Q(),700),k.currentTime=V})},is=async(k,V)=>{await rs(k);const Z=Math.floor(k.videoWidth),K=Math.floor(k.videoHeight);if(Z<=0||K<=0)return null;const se=Number.isFinite(k.duration)&&k.duration>0?k.duration:0,Q=se>0?Ze(V,0,se):0;await _d(k,Q);const le=document.createElement("canvas");le.width=Z,le.height=K;const Re=le.getContext("2d");if(!Re)return null;const ut=Vd(Ke.value);ut!==""&&(Re.filter=ut);try{Re.drawImage(k,0,0,Z,K)}catch{return null}const Jt=Cd(Ke.value);return Nd(Re,Z,K,Jt),ar(le)},Td=async(k,V)=>{const Z=document.createElement("video");Z.src=k,Z.muted=!0,Z.playsInline=!0,Z.preload="auto",k.startsWith("blob:")||(Z.crossOrigin="anonymous");try{return await rs(Z),await is(Z,V)}catch{return null}finally{Z.pause(),Z.removeAttribute("src"),Z.load()}},Md=async k=>{const V=M.value,Z=ar(xd(V));if(Z)return Z;if(V!=null&&V.captureFrameAt)for(let Q=0;Q<4;Q+=1){const le=Sd(V);if(le!==null&&le<=0&&Q<2){await or(80);continue}const Re=await Promise.race([V.captureFrameAt(k),or(450).then(()=>null)]),ut=ar(Re);if(ut)return ut;await or(80)}const K=Ed(V);if(K){const Q=await is(K,k);if(Q)return Q}const se=er.value.trim();if(se!==""){const Q=await Td(se,k);if(Q)return Q}return null},ss=k=>k.map(V=>({...V,params:V.params&&typeof V.params=="object"?{...V.params}:V.params}));function ls(k){const V=ss(Ke.value);if(!rr(k)&&V.length>0&&Array.isArray(k.timeline)&&k.timeline.length>0){const K=k.timeline[0];K&&(k.timeline=[{...K,filters:V},...k.timeline.slice(1)])}return k}const rr=k=>Array.isArray(k.timeline)?k.timeline.some(V=>Array.isArray(V.filters)&&V.filters.length>0):!1,Fd=k=>{if(!k||typeof k!="object")return null;const V=k.posterFrame;if(typeof V!="string")return null;const Z=V.trim();return Z!==""?Z:null};async function ir(){const k=Jn(ls(te())),V=ss(Ke.value),Z=rr(k)||V.length>0,K=Fd(a.initialRecipe);if(Z){const se=ae.value>0?ae.value:.1;try{const Q=await Md(se);Q?k.posterFrame=Q:K&&(k.posterFrame=K)}catch{K&&(k.posterFrame=K)}}else delete k.posterFrame;return oe(),r("draft-saved",k),k}function cs(){pe()&&(Ni(),Pt())}async function Id(k){on(),Do=window.setInterval(async()=>{var V,Z;try{if(Ct){on();return}const K=await fetch(`/api/v1/video/jobs/${k}`);if(!K.ok)throw new Error(`Status poll failed: ${K.status} ${K.statusText}`);const se=await K.json(),Q=(se==null?void 0:se.data)??se,le=Number((Q==null?void 0:Q.progress)??0);if(Xe.value=Number.isFinite(le)?le:0,Q.status==="completed"||Q.status==="failed"||Q.status==="cancelled")if(on(),ot.value=!1,Mt.value=null,Q.status==="completed"){const Re=((V=Q==null?void 0:Q.output_media)==null?void 0:V.url)??(Q==null?void 0:Q.output_url);Xe.value=100,Tt.value=!0,We.value=null}else{const Re=!!((Z=Q==null?void 0:Q.meta)!=null&&Z.is_cancelled)||Q.status==="cancelled"||typeof(Q==null?void 0:Q.error_message)=="string"&&/cancel/i.test(Q.error_message);We.value=Re?"Export canceled.":typeof(Q==null?void 0:Q.error_message)=="string"&&Q.error_message.trim()!==""?Q.error_message:"Export failed"}}catch(K){on(),ot.value=!1,Mt.value=null,We.value=K instanceof Error?K.message:"Failed to check export progress"}},2e3)}function sr(){const k=Jn(be());try{const V=k.timeline??[]}catch{}w.value=k}let dn=null;function Pt(){dn&&clearTimeout(dn),dn=setTimeout(()=>{sr(),dn=null},200)}e.watch(()=>F.value,Pt,{deep:!0}),e.watch(()=>q.value,k=>{if(A.value||!k)return;const V=(k==null?void 0:k.filters)??[];ad(V)},{immediate:!0}),e.watch(()=>Ke.value,k=>{me(k),Pt()},{deep:!0}),e.watch(()=>T.value,k=>{W(k),Pt()},{deep:!0}),e.watch(()=>z.value,k=>{const V=k.map(Z=>({...Z,source:typeof Z.source=="string"?Z.source:void 0}));J(V),Pt()},{deep:!0}),e.watch(()=>ae.value,Pt),o({saveDraft:ir,exportForUpload:wd}),sr(),e.onUnmounted(()=>{on(),Ct=!0,dn&&(clearTimeout(dn),dn=null),h.value&&(h.value.destroy(),h.value=null),N.value=null,g.value=null,C.value=null});let an=null;return e.onMounted(()=>{window.addEventListener("resize",L);const k=()=>{!Mn.value||an||(an=new ResizeObserver(V=>{V[0]&&(Uo.value=Math.round(V[0].contentRect.width))}),an.observe(Mn.value))};k(),an||e.nextTick(k),a.media&&sr(),e.nextTick(()=>{const V=document.querySelector(".video-editor");V&&V.getBoundingClientRect();const Z=document.querySelector(".mobile-layout");Z&&Z.getBoundingClientRect()})}),e.onUnmounted(()=>{window.removeEventListener("resize",L),an==null||an.disconnect(),an=null}),(k,V)=>{var Z,K,se,Q;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-editor",{mobile:l.value}])},[l.value?(e.openBlock(),e.createElementBlock("div",Gb,[e.createElementVNode("div",Hb,[e.withDirectives(e.createVNode(Vs,{ref_key:"pixiPreviewMobileRef",ref:v,"aria-hidden":!m.value,class:"preview-host-child",source:er.value,filters:Bi.value,playhead:Ri.value,"is-playing":e.unref(re),"fit-mode":R.value,active:m.value,onPlayPause:e.unref(ie),onDurationChange:Lo},null,8,["aria-hidden","source","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,m.value]]),e.withDirectives(e.createVNode(js,{"aria-hidden":!f.value,class:"preview-host-child","media-uuid":s.value,recipe:w.value,media:Fi.value,"enable-engine":f.value&&Ii.value,"fit-mode":R.value,onTimeUpdate:Ai,onPlayStateChange:Di,onDurationChange:Lo,onEngineReady:Ui},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,f.value]])]),e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:Mn,class:"timeline-section"},[e.createVNode(Xs,{playhead:e.unref(ae),clips:e.unref(F),"selected-clip-id":((Z=e.unref(q))==null?void 0:Z.id)??((K=e.unref(F)[0])==null?void 0:K.id)??null,duration:nn.value,"zoom-level":e.unref(ee),sensitivity:.25,"is-mobile":!0,"onUpdate:playhead":e.unref(Ve),onTrim:e.unref(ge),onSplit:e.unref(xe),onClipSelect:e.unref(ne),onClipMove:e.unref(pt)},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","onUpdate:playhead","onTrim","onSplit","onClipSelect","onClipMove"])],512),e.createElementVNode("div",Jb,[e.createElementVNode("div",qb,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(G.value,le=>(e.openBlock(),e.createElementBlock("button",{key:le.id,class:e.normalizeClass(["tab-button",{active:c.value===le.id}]),onClick:Re=>c.value=le.id},[e.createVNode(e.unref(B.IonIcon),{icon:le.icon},null,8,["icon"]),e.createElementVNode("span",null,e.toDisplayString(le.label),1)],10,Kb))),128))]),e.createElementVNode("div",Qb,[e.withDirectives(e.createElementVNode("div",ew,[e.createVNode(Zs,{filters:Ao.value,"active-filters":Ti.value,"thumbnail-url":Mi.value,onApplyFilter:Hn,onRemoveFilter:_i,onUpdateParam:zi,onPreviewFilter:Oi},null,8,["filters","active-filters","thumbnail-url"])],512),[[e.vShow,c.value==="filters"]]),e.withDirectives(e.createElementVNode("div",tw,[e.unref($o)?(e.openBlock(),e.createBlock(Ys,{key:0,filter:e.unref($o),"current-frame":e.unref($e),onUpdateParams:Li},null,8,["filter","current-frame"])):e.createCommentVNode("",!0)],512),[[e.vShow,c.value==="adjustments"]]),e.withDirectives(e.createElementVNode("div",nw,[e.createVNode(Hs,{overlays:T.value,onAddOverlay:Wi,onUpdateOverlay:ji,onRemoveOverlay:Xi},null,8,["overlays"])],512),[[e.vShow,c.value==="text"]]),e.withDirectives(e.createElementVNode("div",ow,[e.createVNode(Js,{"selected-clips":P.value,"applied-transitions":I.value,onApplyTransition:Zi,onRemoveTransition:Yi,onPreviewTransition:Gi},null,8,["selected-clips","applied-transitions"])],512),[[e.vShow,c.value==="transitions"]]),e.withDirectives(e.createElementVNode("div",aw,[e.createVNode(qs,{"audio-layers":z.value,"master-volume":j.value,onAddTrack:Hi,onUpdateTrack:Ji,onRemoveTrack:qi,onUpdateVolume:Ki,onToggleMute:Qi,onUpdateMasterVolume:es},null,8,["audio-layers","master-volume"])],512),[[e.vShow,c.value==="audio"]]),e.withDirectives(e.createElementVNode("div",rw,[e.createVNode(Gs,{"can-export":e.unref(de),"is-exporting":ot.value,"export-progress":Xe.value,onExport:os,onCancelExport:ns,onSaveDraft:ir,onReset:cs},null,8,["can-export","is-exporting","export-progress"]),Tt.value?(e.openBlock(),e.createElementBlock("div",iw," Export complete ")):e.createCommentVNode("",!0),We.value&&!Tt.value?(e.openBlock(),e.createElementBlock("div",sw,e.toDisplayString(We.value),1)):e.createCommentVNode("",!0)],512),[[e.vShow,c.value==="export"]])])])])):(e.openBlock(),e.createElementBlock("div",lw,[e.createElementVNode("div",cw,[e.createElementVNode("div",dw,[e.createElementVNode("div",uw,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":V[0]||(V[0]=le=>R.value=le),"aria-label":"Fit mode","data-testid":"select-video-fit-mode"},[...V[9]||(V[9]=[e.createElementVNode("option",{value:"contain"},"Contain",-1),e.createElementVNode("option",{value:"cover"},"Cover",-1),e.createElementVNode("option",{value:"none"},"None",-1)])],512),[[e.vModelSelect,R.value]])])]),e.withDirectives(e.createVNode(Vs,{ref_key:"pixiPreviewDesktopRef",ref:b,"aria-hidden":!m.value,class:"preview-host-child",source:er.value,filters:Bi.value,playhead:Ri.value,"is-playing":e.unref(re),"fit-mode":R.value,active:m.value,onPlayPause:e.unref(ie),onDurationChange:Lo},null,8,["aria-hidden","source","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,m.value]]),e.withDirectives(e.createVNode(js,{"aria-hidden":!f.value,class:"preview-host-child","media-uuid":s.value,recipe:w.value,media:Fi.value,"enable-engine":f.value&&Ii.value,"fit-mode":R.value,onTimeUpdate:Ai,onPlayStateChange:Di,onDurationChange:Lo,onEngineReady:Ui},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,f.value]]),k.showThumbnailPicker?(e.openBlock(),e.createBlock(Bg,{key:0,"media-uuid":s.value,duration:nn.value,onSelect:fd},null,8,["media-uuid","duration"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",mw,[e.createElementVNode("div",pw,[e.createElementVNode("div",fw,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(X.value,le=>(e.openBlock(),e.createElementBlock("button",{key:le.id,class:e.normalizeClass(["tab-btn",{active:d.value===le.id}]),onClick:Re=>d.value=le.id},e.toDisplayString(le.label),11,hw))),128))]),e.createElementVNode("div",vw,[e.withDirectives(e.createElementVNode("div",gw,[e.createVNode(Zs,{filters:Ao.value,"active-filters":Ti.value,"thumbnail-url":Mi.value,onApplyFilter:Hn,onRemoveFilter:_i,onUpdateParam:zi,onPreviewFilter:Oi},null,8,["filters","active-filters","thumbnail-url"])],512),[[e.vShow,d.value==="filters"]]),e.withDirectives(e.createElementVNode("div",yw,[e.createVNode(Hs,{overlays:T.value,onAddOverlay:Wi,onUpdateOverlay:ji,onRemoveOverlay:Xi},null,8,["overlays"])],512),[[e.vShow,d.value==="text"]]),e.withDirectives(e.createElementVNode("div",bw,[e.createVNode(Js,{"selected-clips":P.value,"applied-transitions":I.value,onApplyTransition:Zi,onRemoveTransition:Yi,onPreviewTransition:Gi},null,8,["selected-clips","applied-transitions"])],512),[[e.vShow,d.value==="transitions"]]),e.withDirectives(e.createElementVNode("div",ww,[e.createVNode(qs,{"audio-layers":z.value,"master-volume":j.value,onAddTrack:Hi,onUpdateTrack:Ji,onRemoveTrack:qi,onUpdateVolume:Ki,onToggleMute:Qi,onUpdateMasterVolume:es},null,8,["audio-layers","master-volume"])],512),[[e.vShow,d.value==="audio"]]),e.withDirectives(e.createElementVNode("div",kw,[e.unref($o)?(e.openBlock(),e.createBlock(Ys,{key:0,filter:e.unref($o),"current-frame":e.unref($e),onUpdateParams:Li},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",xw,[...V[10]||(V[10]=[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(Gs,{"can-export":e.unref(de),"is-exporting":ot.value,"export-progress":Xe.value,onExport:os,onCancelExport:ns,onSaveDraft:ir,onReset:cs},null,8,["can-export","is-exporting","export-progress"]),Tt.value?(e.openBlock(),e.createElementBlock("div",Ew," Export complete ")):e.createCommentVNode("",!0),We.value&&!Tt.value?(e.openBlock(),e.createElementBlock("div",Vw,e.toDisplayString(We.value),1)):e.createCommentVNode("",!0)],512),[[e.vShow,d.value==="export"]])])])])]),e.createElementVNode("div",Cw,[e.createElementVNode("div",{ref_key:"timelineContainerRef",ref:Mn,class:"timeline-container"},[e.createElementVNode("div",Nw,[e.createElementVNode("label",null,[V[11]||(V[11]=e.createTextVNode(" Zoom ",-1)),e.createElementVNode("input",{type:"range",min:"10",max:"600",value:e.unref(ee),onInput:V[1]||(V[1]=le=>pd(le))},null,40,_w)]),e.createElementVNode("span",Tw,e.toDisplayString(Math.round(e.unref(ee)))+" px/s",1)]),e.createVNode(Xs,{playhead:e.unref(ae),clips:e.unref(F),"selected-clip-id":((se=e.unref(q))==null?void 0:se.id)??((Q=e.unref(F)[0])==null?void 0:Q.id)??null,duration:nn.value,"zoom-level":e.unref(ee),sensitivity:.25,"onUpdate:playhead":e.unref(Ve),onTrim:e.unref(ge),onSplit:e.unref(xe),onClipSelect:e.unref(ne),onClipMove:e.unref(pt)},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","onUpdate:playhead","onTrim","onSplit","onClipSelect","onClipMove"]),e.createVNode(sv,{"selected-clip":e.unref(q),"can-split":id.value,"can-delete":sd.value,"is-playing":e.unref(re),"zoom-level":e.unref(ee),"playback-speed":e.unref(ue),onSplit:e.unref(ke),onDelete:e.unref(he),onDuplicate:e.unref(qe),onZoomIn:e.unref(Be),onZoomOut:e.unref(De),onZoomChange:e.unref(ct),onFitToWindow:md,onPlayPause:e.unref(ie),onFrameForward:e.unref(Le),onFrameBackward:e.unref(yt),onSkipToStart:e.unref(dt),onSkipToEnd:e.unref(Vt),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"]),Me.value?(e.openBlock(),e.createElementBlock("div",Mw,[e.createElementVNode("div",Fw,[e.createElementVNode("label",Iw,[V[12]||(V[12]=e.createElementVNode("span",null,"Trim start (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":V[2]||(V[2]=le=>_n.value=le),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-start"},null,512),[[e.vModelText,_n.value]])]),e.createElementVNode("label",Bw,[V[13]||(V[13]=e.createElementVNode("span",null,"Trim end (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":V[3]||(V[3]=le=>Tn.value=le),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-end"},null,512),[[e.vModelText,Tn.value]])]),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-start-playhead",disabled:!e.unref(q),onClick:V[4]||(V[4]=le=>$i("start"))}," Start = Playhead ",8,Rw),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-end-playhead",disabled:!e.unref(q),onClick:V[5]||(V[5]=le=>$i("end"))}," End = Playhead ",8,Pw),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-trim",disabled:!e.unref(q),onClick:cd}," Apply Trim ",8,$w)]),e.createElementVNode("div",zw,[e.createElementVNode("label",Aw,[V[14]||(V[14]=e.createElementVNode("span",null,"Quick filter",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":V[6]||(V[6]=le=>tn.value=le),"data-testid":"video-dev-filter-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Ao.value,le=>(e.openBlock(),e.createElementBlock("option",{key:le.id,value:le.id},e.toDisplayString(le.name),9,Dw))),128))],512),[[e.vModelSelect,tn.value]])]),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-filter",disabled:!e.unref(q)||tn.value==="",onClick:dd}," Apply Filter ",8,Uw),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-clear-filters",disabled:e.unref(Ke).length===0,onClick:ud}," Clear Filters ",8,Ow),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(q),onClick:V[7]||(V[7]=le=>Hn("noise"))}," QA: Noise ",8,Lw),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(q),onClick:V[8]||(V[8]=le=>Hn("grayscale"))}," QA: Grayscale ",8,Ww)])])):e.createCommentVNode("",!0)],512)])]))],2)}}}),Lc=_e(jw,[["__scopeId","data-v-f3a82229"]]),Xw=["aria-label"],Zw={class:"ve-header"},Yw={class:"ve-title"},Gw={class:"ve-body"},Hw={class:"ve-footer"},Jw=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(n,{emit:o}){const t=n,a=o,r=e.computed(()=>t.open??!0),i=e.computed(()=>{var l;return t.mediaUuid||((l=t.media)==null?void 0:l.id)||`temp-${Date.now()}`});function s(){a("close"),a("update:open",!1)}return(l,c)=>r.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"ve-overlay",onClick:e.withModifiers(s,["self"])},[e.createElementVNode("div",{class:"ve-dialog",role:"dialog","aria-label":l.title,"aria-modal":"true"},[e.createElementVNode("header",Zw,[e.createElementVNode("h2",Yw,e.toDisplayString(l.title),1),e.createElementVNode("button",{class:"ve-close",onClick:s,"aria-label":"Close"}," ✕ ")]),e.createElementVNode("section",Gw,[e.createVNode(Lc,e.mergeProps({"media-uuid":i.value},{...l.initialRecipe?{initialRecipe:l.initialRecipe}:{},...l.media?{media:l.media}:{}},{"show-thumbnail-picker":l.showThumbnailPicker??!1,onRecipeGenerated:c[0]||(c[0]=d=>l.$emit("recipe-generated",d)),onExportStarted:c[1]||(c[1]=d=>l.$emit("export-started",d)),onDraftSaved:c[2]||(c[2]=d=>l.$emit("draft-saved",d)),onThumbnailSelected:c[3]||(c[3]=d=>l.$emit("thumbnail-selected",d))}),null,16,["media-uuid","show-thumbnail-picker"])]),e.createElementVNode("footer",Hw,[e.renderSlot(l.$slots,"footer",{},()=>[e.createElementVNode("button",{class:"ve-btn",onClick:s},"Cancel")],!0)])],8,Xw)])):e.createCommentVNode("",!0)}}),qw=_e(Jw,[["__scopeId","data-v-710e8e26"]]),Kw={class:"video-editor-modal"},Qw={class:"video-preview-container"},e2=["src"],t2={class:"video-overlay-controls"},n2=["aria-label"],o2={class:"time-display"},a2={class:"timeline-container"},r2={class:"clip-name"},i2={class:"timeline-time-labels"},s2={class:"tool-tabs"},l2=["onClick"],c2={class:"tool-panel"},d2={key:0,class:"trim-panel"},u2={class:"trim-controls"},m2={key:1,class:"filters-panel"},p2={class:"filter-grid"},f2=["onClick"],h2={key:2,class:"text-panel"},v2={key:3,class:"transitions-panel"},g2={class:"transition-grid"},y2=["onClick"],b2={class:"action-buttons"},w2=e.defineComponent({__name:"VideoEditorSimple",props:{media:{}},emits:["save","cancel"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(),i=e.ref(""),s=e.ref(!1),l=e.ref(0),c=e.ref(0),d=e.ref("video-1"),u=e.ref(0),p=e.ref(0),m=e.ref(null),f=e.ref("trim"),v=e.ref(null),b=e.ref(""),S=[{id:"trim",label:"Trim",icon:Fl},{id:"filters",label:"Filters",icon:am},{id:"text",label:"Text",icon:Pl},{id:"transitions",label:"Transitions",icon:mm}],M=[{id:"none",name:"None"},{id:"grayscale",name:"Grayscale"},{id:"sepia",name:"Sepia"},{id:"blur",name:"Blur"},{id:"brightness",name:"Brightness"},{id:"contrast",name:"Contrast"}],E=[{id:"fade",name:"Fade"},{id:"slide",name:"Slide"},{id:"zoom",name:"Zoom"},{id:"wipe",name:"Wipe"}],y=e.ref();e.onMounted(()=>{var _,D;(_=t.media)!=null&&_.url?i.value=t.media.url:(D=t.media)!=null&&D.file&&(i.value=URL.createObjectURL(t.media.file))}),e.onUnmounted(()=>{var _;(_=t.media)!=null&&_.file&&i.value&&URL.revokeObjectURL(i.value)});function h(){r.value&&(c.value=r.value.duration,p.value=c.value)}function w(){r.value&&(l.value=r.value.currentTime)}function R(){s.value=!1}function N(){r.value&&(s.value?(r.value.pause(),s.value=!1):(r.value.play(),s.value=!0))}function g(_){if(!_||isNaN(_))return"00:00";const D=Math.floor(_/60),G=Math.floor(_%60);return`${D.toString().padStart(2,"0")}:${G.toString().padStart(2,"0")}`}function C(_){if(!r.value||!y.value)return;const D=y.value.getBoundingClientRect(),ce=(_.clientX-D.left)/D.width*c.value;r.value.currentTime=Math.max(0,Math.min(ce,c.value))}function A(){u.value=l.value}function x(){p.value=l.value}function T(){u.value=0,p.value=c.value}function I(_){m.value=_;const D=X=>{if(!m.value||!y.value)return;const ce=y.value.getBoundingClientRect(),ae=(X.clientX-ce.left)/ce.width*c.value;m.value==="start"?u.value=Math.max(0,Math.min(ae,p.value-1)):p.value=Math.max(u.value+1,Math.min(ae,c.value))},G=()=>{m.value=null,document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",G)};document.addEventListener("mousemove",D),document.addEventListener("mouseup",G)}function z(_){if(v.value=_,!r.value)return;const D={none:"none",grayscale:"grayscale(100%)",sepia:"sepia(100%)",blur:"blur(5px)",brightness:"brightness(150%)",contrast:"contrast(150%)"};r.value.style.filter=D[_]||"none"}function P(){}function j(_){}function L(){const _={timeline:[{id:d.value,url:i.value,startTime:0,endTime:c.value,sourceIn:u.value,sourceOut:p.value,track:0}],filters:v.value?[{type:v.value}]:[],textOverlays:b.value?[{content:b.value}]:[],duration:p.value-u.value};a("save",_)}return(_,D)=>(e.openBlock(),e.createElementBlock("div",Kw,[e.createElementVNode("div",Qw,[e.createElementVNode("video",{ref_key:"videoElement",ref:r,class:"video-preview",src:i.value,onLoadedmetadata:h,onTimeupdate:w,onEnded:R,controls:""},null,40,e2),e.createElementVNode("div",t2,[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(vm):e.unref(km)},null,8,["icon"])],8,n2),e.createElementVNode("div",o2,e.toDisplayString(g(l.value))+" / "+e.toDisplayString(g(c.value)),1)])]),e.createElementVNode("div",a2,[e.createElementVNode("div",{class:"timeline-track",onClick:C,ref_key:"timelineTrack",ref:y},[e.createElementVNode("div",{class:"timeline-clip",style:e.normalizeStyle({left:`${u.value/c.value*100}%`,right:`${100-p.value/c.value*100}%`})},[e.createElementVNode("span",r2,e.toDisplayString(d.value),1)],4),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:`${l.value/c.value*100}%`})},null,4),f.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]=G=>I("start"))},null,36)):e.createCommentVNode("",!0),f.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:1,class:"trim-handle trim-end",style:e.normalizeStyle({left:`${p.value/c.value*100}%`}),onMousedown:D[1]||(D[1]=G=>I("end"))},null,36)):e.createCommentVNode("",!0)],512),e.createElementVNode("div",i2,[e.createElementVNode("span",null,e.toDisplayString(g(0)),1),e.createElementVNode("span",null,e.toDisplayString(g(c.value)),1)])]),e.createElementVNode("div",s2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(S,G=>e.createElementVNode("button",{key:G.id,class:e.normalizeClass(["tool-tab",{active:f.value===G.id}]),onClick:X=>f.value=G.id},[e.createVNode(e.unref(B.IonIcon),{icon:G.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(G.label),1)],10,l2)),64))]),e.createElementVNode("div",c2,[f.value==="trim"?(e.openBlock(),e.createElementBlock("div",d2,[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",u2,[e.createElementVNode("button",{class:"btn-trim",onClick:A},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(ws)},null,8,["icon"]),D[4]||(D[4]=e.createTextVNode(" Set Start ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:x},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(ws)},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(bo)},null,8,["icon"]),D[6]||(D[6]=e.createTextVNode(" Clear ",-1))])])])):f.value==="filters"?(e.openBlock(),e.createElementBlock("div",m2,[D[9]||(D[9]=e.createElementVNode("h3",null,"Filters",-1)),e.createElementVNode("div",p2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(M,G=>e.createElementVNode("button",{key:G.id,class:e.normalizeClass(["filter-option",{active:v.value===G.id}]),onClick:X=>z(G.id)},e.toDisplayString(G.name),11,f2)),64))])])):f.value==="text"?(e.openBlock(),e.createElementBlock("div",h2,[D[10]||(D[10]=e.createElementVNode("h3",null,"Text Overlay",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":D[2]||(D[2]=G=>b.value=G),type:"text",placeholder:"Enter text...",class:"text-input"},null,512),[[e.vModelText,b.value]]),e.createElementVNode("button",{class:"btn-add-text",onClick:P},"Add Text")])):f.value==="transitions"?(e.openBlock(),e.createElementBlock("div",v2,[D[11]||(D[11]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",g2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(E,G=>e.createElementVNode("button",{key:G.id,class:"transition-option",onClick:X=>(G.id,void 0)},e.toDisplayString(G.name),9,y2)),64))])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",b2,[e.createElementVNode("button",{class:"btn-cancel",onClick:D[3]||(D[3]=G=>_.$emit("cancel"))},"CANCEL"),e.createElementVNode("button",{class:"btn-save",onClick:L},"SAVE")])]))}}),k2=_e(w2,[["__scopeId","data-v-b933f33b"]]),x2={class:"time-label"},S2=e.defineComponent({__name:"TimeRuler",props:{duration:{},zoom:{}},setup(n){const o=n,t=e.computed(()=>({width:`${o.duration*o.zoom*100}px`})),a=e.computed(()=>{const s=[],l=r(o.duration,o.zoom);for(let c=0;c<=o.duration;c+=l){const d=`${c/o.duration*100}%`,u=i(c),p=c%(l*5)===0;s.push({time:c,position:d,label:u,major:p})}return s});function r(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 i(s){const l=Math.floor(s/60),c=Math.floor(s%60);return l===0?`${c}s`:c===0?`${l}m`:`${l}:${c.toString().padStart(2,"0")}`}return(s,l)=>(e.openBlock(),e.createElementBlock("div",{class:"time-ruler",style:e.normalizeStyle(t.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,c=>(e.openBlock(),e.createElementBlock("div",{key:c.time,class:"time-mark",style:e.normalizeStyle({left:c.position})},[e.createElementVNode("span",x2,e.toDisplayString(c.label),1),e.createElementVNode("div",{class:e.normalizeClass(["time-tick",{major:c.major}])},null,2)],4))),128))],4))}}),E2=_e(S2,[["__scopeId","data-v-0ef9c910"]]),V2=["data-track-index"],C2={class:"track-header"},N2={class:"track-label"},_2={class:"track-controls"},T2=["data-testid","aria-label"],M2=["data-testid","onMousedown","onClick"],F2={class:"clip-content"},I2={class:"clip-name"},B2={key:0,class:"clip-thumbnail"},R2=["src","alt"],P2=["onMousedown","aria-label"],$2=["onMousedown","aria-label"],z2=e.defineComponent({__name:"VideoTrack",props:{clips:{},trackIndex:{},zoom:{},duration:{}},emits:["clip-move","clip-trim","clip-select"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(null),i=e.ref(!1),s=e.ref(!1),l=e.ref(null),c=e.computed(()=>({width:`${t.duration*t.zoom*100}px`}));function d(S){const M=S.timelineEnd-S.timelineStart,E=S.timelineStart/t.duration*100,y=M/t.duration*100;return{left:`${E}%`,width:`${y}%`,backgroundColor:u(S)}}function u(S){const M=["#4A90E2","#7ED321","#F5A623","#BD10E0","#9013FE","#50E3C2","#B8E986","#F8E71C"],E=parseInt(S.id.replace(/\D/g,""))%M.length;return M[E]}function p(S){return S.label?S.label:S.url?(S.url.split("/").pop()||"Clip").split(".")[0]:`Clip ${S.id.slice(-4)}`}function m(S){r.value=S.id,a("clip-select",S.id)}function f(){i.value=!i.value}function v(S,M){if(l.value)return;s.value=!0;const E=M.clientX,y=S.timelineStart,h=R=>{if(!s.value)return;const N=R.clientX-E,g=parseFloat(c.value.width),C=N/(t.zoom*100)*(t.duration/g),A=Math.max(0,y+C);a("clip-move",S.id,A)},w=()=>{s.value=!1,document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",w)};document.addEventListener("mousemove",h),document.addEventListener("mouseup",w)}function b(S,M,E){l.value=M;const y=E.clientX,h=S.sourceIn,w=S.sourceOut,R=g=>{if(!l.value)return;const C=g.clientX-y,A=parseFloat(c.value.width),x=C/(t.zoom*100)*(t.duration/A);if(l.value==="start"){const T=Math.max(0,h+x);a("clip-trim",S.id,T,w)}else{const T=Math.max(h+1,w+x);a("clip-trim",S.id,h,T)}},N=()=>{l.value=null,document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",N)};document.addEventListener("mousemove",R),document.addEventListener("mouseup",N)}return(S,M)=>(e.openBlock(),e.createElementBlock("div",{class:"video-track","data-track-index":S.trackIndex},[e.createElementVNode("div",C2,[e.createElementVNode("span",N2,"Track "+e.toDisplayString(S.trackIndex+1),1),e.createElementVNode("div",_2,[S.clips.length>0?(e.openBlock(),e.createElementBlock("button",{key:0,class:"track-btn","data-testid":`btn-mute-track-${S.trackIndex}`,"aria-label":`${i.value?"Unmute":"Mute"} track ${S.trackIndex+1}`,onClick:f},[e.createVNode(e.unref(B.IonIcon),{icon:i.value?e.unref(zm):e.unref(Pm)},null,8,["icon"])],8,T2)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",{class:"track-timeline",style:e.normalizeStyle(c.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(S.clips,E=>(e.openBlock(),e.createElementBlock("div",{key:E.id,class:e.normalizeClass(["timeline-clip",{selected:E.id===r.value}]),style:e.normalizeStyle(d(E)),"data-testid":`clip-${E.id}`,onMousedown:y=>v(E,y),onClick:y=>m(E)},[e.createElementVNode("div",F2,[e.createElementVNode("span",I2,e.toDisplayString(p(E)),1),E.thumbnail?(e.openBlock(),e.createElementBlock("div",B2,[e.createElementVNode("img",{src:E.thumbnail,alt:p(E)},null,8,R2)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:e.withModifiers(y=>b(E,"start",y),["stop"]),"aria-label":`Trim start of ${p(E)}`},null,40,P2),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:e.withModifiers(y=>b(E,"end",y),["stop"]),"aria-label":`Trim end of ${p(E)}`},null,40,$2)],46,M2))),128))],4)],8,V2))}}),A2=_e(z2,[["__scopeId","data-v-48e480d2"]]),D2={class:"video-timeline"},U2={class:"timeline-tracks"},O2=["aria-label","aria-valuenow","aria-valuemax"],L2={class:"timeline-controls"},W2={class:"zoom-level"},j2=e.defineComponent({__name:"VideoTimeline",props:{clips:{},duration:{},currentTime:{}},emits:["update:clips","seek","clip-move","clip-trim"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(1),i=e.ref(null),s=e.ref(!1),l=e.ref(),c=e.computed(()=>{const y=Math.max(0,...t.clips.map(h=>h.track||0));return Array(y+1).fill(null)}),d=e.computed(()=>`${t.currentTime/t.duration*100}%`);function u(y){return t.clips.filter(h=>(h.track||0)===y)}function p(y){const h=Math.floor(y/60),w=Math.floor(y%60);return`${h}:${w.toString().padStart(2,"0")}`}function m(y,h){a("clip-move",y,h)}function f(y,h,w){a("clip-trim",y,h,w)}function v(y){i.value=y}function b(){r.value=Math.min(r.value*1.2,5)}function S(){r.value=Math.max(r.value/1.2,.5)}function M(){s.value=!0;const y=w=>{if(!s.value||!l.value)return;const R=l.value.getBoundingClientRect(),C=Math.max(0,Math.min(w.clientX-R.left,R.width))/R.width*t.duration;a("seek",C)},h=()=>{s.value=!1,document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",h)};document.addEventListener("mousemove",y),document.addEventListener("mouseup",h)}function E(y){let h=t.currentTime;switch(y.key){case"ArrowLeft":h=Math.max(0,t.currentTime-1);break;case"ArrowRight":h=Math.min(t.duration,t.currentTime+1);break;case"Home":h=0;break;case"End":h=t.duration;break;default:return}y.preventDefault(),a("seek",h)}return e.onMounted(()=>{l.value=document.querySelector(".video-timeline")}),e.onUnmounted(()=>{}),(y,h)=>(e.openBlock(),e.createElementBlock("div",D2,[e.createVNode(E2,{duration:y.duration,zoom:r.value},null,8,["duration","zoom"]),e.createElementVNode("div",U2,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,(w,R)=>(e.openBlock(),e.createBlock(A2,{key:`track-${R}`,"data-testid":`track-${R}`,clips:u(R),"track-index":R,zoom:r.value,duration:y.duration,onClipMove:m,onClipTrim:f,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:M,"data-testid":"playhead","aria-label":`Playhead at ${p(y.currentTime)}`,role:"slider","aria-valuenow":y.currentTime,"aria-valuemax":y.duration,tabindex:"0",onKeydown:E},null,44,O2),e.createElementVNode("div",L2,[e.createElementVNode("button",{"data-testid":"btn-zoom-in","aria-label":"Zoom in",onClick:b},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Hr)},null,8,["icon"])]),e.createElementVNode("span",W2,e.toDisplayString(Math.round(r.value*100))+"%",1),e.createElementVNode("button",{"data-testid":"btn-zoom-out","aria-label":"Zoom out",onClick:S},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(_m)},null,8,["icon"])])])]))}}),X2=_e(j2,[["__scopeId","data-v-001df415"]]),Z2={class:"video-filters-panel"},Y2={class:"filter-controls"},G2=["for"],H2={class:"filter-slider-group"},J2=["id","onUpdate:modelValue","min","max","step","data-testid","aria-label","aria-valuenow","aria-valuemin","aria-valuemax","onInput"],q2={class:"filter-value"},K2={class:"filter-actions"},Q2={key:0,class:"filter-presets"},ek={class:"preset-list"},tk=["data-testid","aria-label","onClick"],nk=e.defineComponent({__name:"VideoFiltersPanel",emits:["filter-change"],setup(n,{emit:o}){const t=o,a=[{type:"brightness",label:"Brightness",min:0,max:200,step:1,default:100},{type:"contrast",label:"Contrast",min:0,max:200,step:1,default:100},{type:"saturation",label:"Saturation",min:0,max:200,step:1,default:100},{type:"hue",label:"Hue",min:-180,max:180,step:1,default:0},{type:"blur",label:"Blur",min:0,max:10,step:.5,default:0},{type:"sharpen",label:"Sharpen",min:0,max:10,step:.5,default:0},{type:"sepia",label:"Sepia",min:0,max:100,step:1,default:0},{type:"grayscale",label:"Grayscale",min:0,max:100,step:1,default:0}],r=e.reactive(a.reduce((m,f)=>(m[f.type]=f.default,m),{})),i=e.ref([{id:"vintage",name:"Vintage",values:{brightness:110,contrast:120,saturation:80,sepia:30}},{id:"noir",name:"Film Noir",values:{brightness:90,contrast:130,grayscale:100}},{id:"vibrant",name:"Vibrant",values:{brightness:110,contrast:110,saturation:140}},{id:"dreamy",name:"Dreamy",values:{brightness:120,blur:2,saturation:90}}]);function s(m,f){switch(m){case"brightness":case"contrast":case"saturation":case"sepia":case"grayscale":return`${f}%`;case"hue":return`${f}°`;case"blur":case"sharpen":return f.toFixed(1);default:return f.toString()}}function l(m){return["brightness","contrast","saturation","hue","blur","sharpen","sepia","grayscale"].includes(m)}function c(m){if(!l(m))return;const f={id:`filter-${m}`,filterId:m,params:{value:r[m]},intensity:1};t("filter-change",f)}function d(){a.forEach(m=>{r[m.type]=m.default,c(m.type)})}function u(){const m=prompt("Enter preset name:");if(!m)return;const f={id:`custom-${Date.now()}`,name:m,values:{...r}};i.value.push(f)}function p(m){Object.entries(m.values).forEach(([f,v])=>{r[f]=v,c(f)})}return(m,f)=>(e.openBlock(),e.createElementBlock("div",Z2,[f[3]||(f[3]=e.createElementVNode("h3",null,"Video Filters",-1)),e.createElementVNode("div",Y2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,v=>e.createElementVNode("div",{key:v.type,class:"filter-control"},[e.createElementVNode("label",{for:`filter-${v.type}`},e.toDisplayString(v.label),9,G2),e.createElementVNode("div",H2,[e.withDirectives(e.createElementVNode("input",{id:`filter-${v.type}`,"onUpdate:modelValue":b=>r[v.type]=b,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":r[v.type],"aria-valuemin":v.min,"aria-valuemax":v.max,onInput:b=>c(v.type)},null,40,J2),[[e.vModelText,r[v.type],void 0,{number:!0}]]),e.createElementVNode("span",q2,e.toDisplayString(s(v.type,r[v.type])),1)])])),64))]),e.createElementVNode("div",K2,[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(So)},null,8,["icon"]),f[0]||(f[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(Rl)},null,8,["icon"]),f[1]||(f[1]=e.createTextVNode(" Save as Preset ",-1))])]),i.value.length>0?(e.openBlock(),e.createElementBlock("div",Q2,[f[2]||(f[2]=e.createElementVNode("h4",null,"Presets",-1)),e.createElementVNode("div",ek,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.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:b=>p(v)},e.toDisplayString(v.name),9,tk))),128))])])):e.createCommentVNode("",!0)]))}}),ok=_e(nk,[["__scopeId","data-v-5ad2ac63"]]),ak={class:"video-text-panel"},rk={class:"text-input-group"},ik={class:"text-options"},sk={class:"option-row"},lk={class:"option-row"},ck={class:"option-row"},dk={class:"option-row"},uk={class:"checkbox-label"},mk={class:"option-row"},pk={class:"text-overlay-list"},fk={key:0,class:"empty-state"},hk=["data-testid"],vk={class:"overlay-preview"},gk={class:"overlay-controls"},yk=["data-testid","aria-label","onClick"],bk=["data-testid","aria-label","onClick"],wk=["data-testid","aria-label","onClick"],kk=e.defineComponent({__name:"VideoTextPanel",emits:["text-add","text-remove","text-update"],setup(n,{emit:o}){const t=o,a=e.ref([]),r=e.reactive({text:"",fontFamily:"Arial",fontSize:32,color:"#FFFFFF",backgroundColor:"#000000",hasBackground:!0,animation:"fade-in"});function i(){if(!r.text.trim())return;const d={id:`text-${Date.now()}`,text:r.text,x:50,y:50,fontSize:r.fontSize,fontFamily:r.fontFamily,color:r.color,startTime:0,opacity:1};r.hasBackground&&(d.backgroundColor=r.backgroundColor),r.animation!=="none"&&(d.animation=r.animation),a.value.push(d),t("text-add",d),r.text=""}function s(d){const u=a.value.findIndex(p=>p.id===d);u!==-1&&(a.value.splice(u,1),t("text-remove",d))}function l(d){r.text=d.text,r.fontFamily=d.fontFamily||"Arial",r.fontSize=d.fontSize,r.color=d.color,r.backgroundColor=d.backgroundColor||"#000000",r.hasBackground=!!d.backgroundColor,r.animation=d.animation||"none",s(d.id)}function c(d){const u={...d,id:`text-${Date.now()}`,x:d.x+10,y:d.y+10};a.value.push(u),t("text-add",u)}return(d,u)=>(e.openBlock(),e.createElementBlock("div",ak,[u[17]||(u[17]=e.createElementVNode("h3",null,"Text Overlays",-1)),e.createElementVNode("div",rk,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[0]||(u[0]=p=>r.text=p),type:"text",placeholder:"Enter text...",class:"text-input","data-testid":"input-text","aria-label":"Text overlay content",onKeyup:e.withKeys(i,["enter"])},null,544),[[e.vModelText,r.text]]),e.createElementVNode("button",{class:"add-text-btn","data-testid":"btn-add-text","aria-label":"Add text overlay",onClick:i},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Hr)},null,8,["icon"]),u[7]||(u[7]=e.createTextVNode(" Add ",-1))])]),e.createElementVNode("div",ik,[e.createElementVNode("div",sk,[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]=p=>r.fontFamily=p),"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,r.fontFamily]])]),e.createElementVNode("div",lk,[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]=p=>r.fontSize=p),type:"number",min:"10",max:"200","data-testid":"input-font-size"},null,512),[[e.vModelText,r.fontSize,void 0,{number:!0}]])]),e.createElementVNode("div",ck,[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]=p=>r.color=p),type:"color","data-testid":"input-text-color"},null,512),[[e.vModelText,r.color]])]),e.createElementVNode("div",dk,[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]=p=>r.backgroundColor=p),type:"color","data-testid":"input-bg-color"},null,512),[[e.vModelText,r.backgroundColor]]),e.createElementVNode("label",uk,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[5]||(u[5]=p=>r.hasBackground=p),type:"checkbox","data-testid":"checkbox-bg"},null,512),[[e.vModelCheckbox,r.hasBackground]]),u[12]||(u[12]=e.createTextVNode(" Enable ",-1))])]),e.createElementVNode("div",mk,[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]=p=>r.animation=p),"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,r.animation]])])]),e.createElementVNode("div",pk,[u[16]||(u[16]=e.createElementVNode("h4",null,"Active Overlays",-1)),a.value.length===0?(e.openBlock(),e.createElementBlock("div",fk," No text overlays added yet ")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(p,m)=>(e.openBlock(),e.createElementBlock("div",{key:p.id,class:"text-overlay-item","data-testid":`overlay-${m}`},[e.createElementVNode("div",vk,[e.createElementVNode("span",{style:e.normalizeStyle({fontFamily:p.fontFamily,fontSize:`${Math.min(p.fontSize/4,16)}px`,color:p.color})},e.toDisplayString(p.text),5)]),e.createElementVNode("div",gk,[e.createElementVNode("button",{class:"edit-btn","data-testid":`btn-edit-${m}`,"aria-label":`Edit overlay: ${p.text}`,onClick:f=>l(p)},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(sm)},null,8,["icon"])],8,yk),e.createElementVNode("button",{class:"duplicate-btn","data-testid":`btn-duplicate-${m}`,"aria-label":`Duplicate overlay: ${p.text}`,onClick:f=>c(p)},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(im)},null,8,["icon"])],8,bk),e.createElementVNode("button",{class:"remove-btn","data-testid":`btn-remove-${m}`,"aria-label":`Remove overlay: ${p.text}`,onClick:f=>s(p.id)},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Fm)},null,8,["icon"])],8,wk)])],8,hk))),128))])]))}}),xk=_e(kk,[["__scopeId","data-v-4d240e1e"]]),Sk={class:"video-tools-panel"},Ek={class:"tool-tabs"},Vk=["data-testid","aria-label","aria-selected","onClick"],Ck={class:"tool-content"},Nk={key:0,class:"trim-panel",role:"tabpanel","aria-label":"Trim controls"},_k={class:"trim-actions"},Tk={key:3,class:"transitions-panel",role:"tabpanel","aria-label":"Transition controls"},Mk={class:"transition-types"},Fk=["data-testid","aria-label","onClick"],Ik={class:"transition-preview"},Bk=e.defineComponent({__name:"VideoToolsPanel",props:{activeTool:{}},emits:["tool-change","filter-change","text-add","transition-add","trim-set-start","trim-set-end","trim-clear"],setup(n){const o=[{id:"trim",name:"Trim",icon:Fl},{id:"filters",name:"Filters",icon:ln},{id:"text",name:"Text",icon:Pl},{id:"transitions",name:"Transitions",icon:Ss}],t=[{id:"fade",name:"Fade",icon:pr},{id:"slide-left",name:"Slide Left",icon:Qu},{id:"slide-right",name:"Slide Right",icon:em},{id:"dissolve",name:"Dissolve",icon:pr},{id:"wipe",name:"Wipe",icon:Ss},{id:"zoom",name:"Zoom",icon:pr}];return(a,r)=>(e.openBlock(),e.createElementBlock("div",Sk,[e.createElementVNode("div",Ek,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(o,i=>e.createElementVNode("button",{key:i.id,class:e.normalizeClass(["tool-tab",{active:a.activeTool===i.id}]),"data-testid":`tab-${i.id}`,"aria-label":`${i.name} tool`,"aria-selected":a.activeTool===i.id,role:"tab",onClick:s=>a.$emit("tool-change",i.id)},[e.createVNode(e.unref(B.IonIcon),{icon:i.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(i.name),1)],10,Vk)),64))]),e.createElementVNode("div",Ck,[a.activeTool==="trim"?(e.openBlock(),e.createElementBlock("div",Nk,[r[8]||(r[8]=e.createElementVNode("h3",null,"Trim Video",-1)),r[9]||(r[9]=e.createElementVNode("p",null,"Click and drag on the timeline to set trim points",-1)),e.createElementVNode("div",_k,[e.createElementVNode("button",{class:"action-btn","data-testid":"btn-set-start","aria-label":"Set trim start at current position",onClick:r[0]||(r[0]=i=>a.$emit("trim-set-start"))},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(ks)},null,8,["icon"]),r[5]||(r[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:r[1]||(r[1]=i=>a.$emit("trim-set-end"))},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(ks)},null,8,["icon"]),r[6]||(r[6]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"action-btn","data-testid":"btn-clear-trim","aria-label":"Clear trim points",onClick:r[2]||(r[2]=i=>a.$emit("trim-clear"))},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(bo)},null,8,["icon"]),r[7]||(r[7]=e.createTextVNode(" Clear ",-1))])])])):e.createCommentVNode("",!0),a.activeTool==="filters"?(e.openBlock(),e.createBlock(ok,{key:1,onFilterChange:r[3]||(r[3]=i=>a.$emit("filter-change",i))})):e.createCommentVNode("",!0),a.activeTool==="text"?(e.openBlock(),e.createBlock(xk,{key:2,onTextAdd:r[4]||(r[4]=i=>a.$emit("text-add",i))})):e.createCommentVNode("",!0),a.activeTool==="transitions"?(e.openBlock(),e.createElementBlock("div",Tk,[r[10]||(r[10]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",Mk,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(t,i=>e.createElementVNode("button",{key:i.id,class:"transition-btn","data-testid":`transition-${i.id}`,"aria-label":`Add ${i.name} transition`,onClick:s=>a.$emit("transition-add",i.id)},[e.createElementVNode("div",Ik,[e.createVNode(e.unref(B.IonIcon),{icon:i.icon},null,8,["icon"])]),e.createElementVNode("span",null,e.toDisplayString(i.name),1)],8,Fk)),64))])])):e.createCommentVNode("",!0)])]))}}),Rk=_e(Bk,[["__scopeId","data-v-fc135306"]]),Pk={class:"video-export-panel"},$k={class:"export-presets"},zk=["value"],Ak={key:0,class:"preset-details"},Dk={class:"detail-row"},Uk={class:"detail-row"},Ok={class:"detail-row"},Lk={class:"advanced-options"},Wk={class:"options-content"},jk={class:"option-group"},Xk={class:"option-group"},Zk={class:"option-group"},Yk=["disabled"],Gk={key:1,class:"export-progress"},Hk={class:"progress-message"},Jk={class:"progress-bar"},qk=["aria-valuenow"],Kk={class:"progress-percentage"},Qk=e.defineComponent({__name:"VideoExportPanel",props:{presets:{},isExporting:{type:Boolean},exportProgress:{}},emits:["export"],setup(n,{emit:o}){const t=n,a=o,r=e.ref("instagram-reel"),i=e.reactive({quality:"medium",bitrate:5,includeAudio:!0}),s=e.computed(()=>t.presets.find(d=>d.id===r.value)),l=e.computed(()=>t.exportProgress<10?"Initializing export...":t.exportProgress<30?"Processing video tracks...":t.exportProgress<50?"Applying filters and effects...":t.exportProgress<70?"Rendering frames...":t.exportProgress<90?"Encoding video...":t.exportProgress<100?"Finalizing export...":"Export complete!");function c(){s.value&&a("export",{...s.value,options:{...i}})}return(d,u)=>(e.openBlock(),e.createElementBlock("div",Pk,[u[14]||(u[14]=e.createElementVNode("h3",null,"Export Video",-1)),e.createElementVNode("div",$k,[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]=p=>r.value=p),"data-testid":"preset-select","aria-label":"Select export preset"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.presets,p=>(e.openBlock(),e.createElementBlock("option",{key:p.id,value:p.id},e.toDisplayString(p.name),9,zk))),128))],512),[[e.vModelSelect,r.value]])]),s.value?(e.openBlock(),e.createElementBlock("div",Ak,[e.createElementVNode("div",Dk,[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",Uk,[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",Ok,[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",Lk,[u[12]||(u[12]=e.createElementVNode("summary",null,"Advanced Options",-1)),e.createElementVNode("div",Wk,[e.createElementVNode("div",jk,[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]=p=>i.quality=p),"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,i.quality]])]),e.createElementVNode("div",Xk,[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]=p=>i.bitrate=p),type:"number",min:"1",max:"50","data-testid":"bitrate-input"},null,512),[[e.vModelText,i.bitrate,void 0,{number:!0}]])]),e.createElementVNode("div",Zk,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[3]||(u[3]=p=>i.includeAudio=p),type:"checkbox","data-testid":"include-audio"},null,512),[[e.vModelCheckbox,i.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(Na)},null,8,["icon"]),u[13]||(u[13]=e.createTextVNode(" Export Video ",-1))],64))],8,Yk),d.isExporting?(e.openBlock(),e.createElementBlock("div",Gk,[e.createElementVNode("div",Hk,e.toDisplayString(l.value),1),e.createElementVNode("div",Jk,[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,qk)]),e.createElementVNode("div",Kk,e.toDisplayString(d.exportProgress)+"% ",1)])):e.createCommentVNode("",!0)]))}}),ex=_e(Qk,[["__scopeId","data-v-5caf8fe6"]]),tx=["data-testid"],nx={class:"progress-header"},ox={class:"file-info"},ax={class:"file-details"},rx={class:"file-name"},ix={class:"file-meta"},sx={class:"file-size"},lx={key:0,class:"separator"},cx={key:1,class:"upload-speed"},dx={key:2,class:"separator"},ux={key:3,class:"time-remaining"},mx={class:"progress-actions"},px={key:0,class:"status-icon completed","data-testid":"video-upload-status-completed"},fx={key:1,class:"status-icon error","data-testid":"video-upload-status-error"},hx={key:2,class:"status-icon processing","data-testid":"video-upload-status-processing",role:"status","aria-label":"Processing video"},vx=["aria-valuenow","aria-label"],gx={class:"progress-bar"},yx={class:"progress-percent"},bx={key:1,class:"error-message","data-testid":"video-upload-error"},wx={key:2,class:"thumbnail-preview","data-testid":"video-upload-thumbnail"},kx=["src","alt"],xx={key:0,class:"video-duration"},Sx=e.defineComponent({__name:"VideoUploadProgress",props:{upload:{}},emits:["cancel","retry","remove"],setup(n){const o=n,t=e.computed(()=>({"is-uploading":o.upload.status==="uploading","is-processing":o.upload.status==="processing","is-completed":o.upload.status==="completed","is-error":o.upload.status==="error","is-pending":o.upload.status==="pending"})),a=e.computed(()=>$l),r=e.computed(()=>["uploading","processing"].includes(o.upload.status)),i=e.computed(()=>(o.upload.status==="processing",o.upload.progress||0)),s=e.computed(()=>{if(!o.upload.timeRemaining||o.upload.status!=="uploading")return null;const m=o.upload.timeRemaining;if(m<60)return`${Math.round(m)}s`;const f=Math.floor(m/60);return f<60?`${f}m ${Math.round(m%60)}s`:`${Math.floor(f/60)}h ${f%60}m`}),l=e.computed(()=>{var m;return o.upload.status==="completed"&&((m=o.upload.media)!=null&&m.thumbnail_url)?o.upload.media.thumbnail_url:null}),c=e.computed(()=>{var m;return(m=o.upload.media)==null?void 0:m.duration});function d(m){if(m===0)return"0 B";const f=["B","KB","MB","GB","TB"],v=1024,b=Math.floor(Math.log(m)/Math.log(v));return`${(m/Math.pow(v,b)).toFixed(1)} ${f[b]}`}function u(m){if(m===0)return"0 B/s";const f=["B/s","KB/s","MB/s","GB/s"],v=1024,b=Math.floor(Math.log(m)/Math.log(v));return`${(m/Math.pow(v,b)).toFixed(1)} ${f[b]}`}function p(m){const f=Math.floor(m/3600),v=Math.floor(m%3600/60),b=Math.floor(m%60);return f>0?`${f}:${v.toString().padStart(2,"0")}:${b.toString().padStart(2,"0")}`:`${v}:${b.toString().padStart(2,"0")}`}return(m,f)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["upload-progress-item",t.value]),"data-testid":`video-upload-progress-${m.upload.id}`},[e.createElementVNode("div",nx,[e.createElementVNode("div",ox,[e.createVNode(e.unref(B.IonIcon),{icon:a.value,class:"file-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("div",ax,[e.createElementVNode("h4",rx,e.toDisplayString(m.upload.filename),1),e.createElementVNode("p",ix,[e.createElementVNode("span",sx,e.toDisplayString(d(m.upload.bytesTotal||0)),1),m.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",lx,"•")):e.createCommentVNode("",!0),m.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",cx,e.toDisplayString(u(m.upload.uploadSpeed||0)),1)):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",dx,"•")):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",ux,e.toDisplayString(s.value)+" remaining ",1)):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",mx,[m.upload.status==="completed"?(e.openBlock(),e.createElementBlock("div",px,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Tl)},null,8,["icon"])])):m.upload.status==="error"?(e.openBlock(),e.createElementBlock("div",fx,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Ku),"aria-hidden":"true"},null,8,["icon"])])):m.upload.status==="processing"?(e.openBlock(),e.createElementBlock("div",hx,[e.createVNode(e.unref(B.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),m.upload.status==="uploading"?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:3,fill:"clear",size:"small",onClick:f[0]||(f[0]=v=>m.$emit("cancel")),"data-testid":"btn-cancel-video-upload","aria-label":"Cancel upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(bo),slot:"icon-only"},null,8,["icon"])]),_:1})):m.upload.status==="error"?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:4,fill:"clear",size:"small",onClick:f[1]||(f[1]=v=>m.$emit("retry")),"data-testid":"btn-retry-video-upload","aria-label":"Retry upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(So),slot:"icon-only"},null,8,["icon"])]),_:1})):m.upload.status==="completed"?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:5,fill:"clear",size:"small",onClick:f[2]||(f[2]=v=>m.$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(bo),slot:"icon-only"},null,8,["icon"])]),_:1})):e.createCommentVNode("",!0)])]),r.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"progress-bar-container","data-testid":"video-upload-progress-bar",role:"progressbar","aria-valuenow":Math.round(i.value),"aria-valuemin":"0","aria-valuemax":"100","aria-label":m.upload.status==="processing"?"Processing progress":"Upload progress"},[e.createElementVNode("div",gx,[e.createElementVNode("div",{class:e.normalizeClass(["progress-fill",{indeterminate:m.upload.status==="processing"}]),style:e.normalizeStyle({width:i.value+"%"})},null,6)]),e.createElementVNode("span",yx,e.toDisplayString(Math.round(i.value))+"%",1)],8,vx)):e.createCommentVNode("",!0),m.upload.error?(e.openBlock(),e.createElementBlock("div",bx,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Am)},null,8,["icon"]),e.createElementVNode("span",null,e.toDisplayString(m.upload.error),1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",wx,[e.createElementVNode("img",{src:l.value,alt:m.upload.filename},null,8,kx),c.value?(e.openBlock(),e.createElementBlock("div",xx,e.toDisplayString(p(c.value)),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],10,tx))}}),Ex=_e(Sx,[["__scopeId","data-v-9eacbf91"]]),Er=4,Vx=500,Cx=new Set([408,425,429,500,502,503,504,520,521,522,523,524,525]);function Ja(n){return typeof n=="object"&&n!==null}function ml(n){return Ja(n)?typeof n.upload_url=="string"&&typeof n.upload_id=="string"&&typeof n.media_uuid=="string"&&typeof n.expires_at=="string":!1}function Nx(n){if(ml(n))return n;if(Ja(n)&&ml(n.data))return n.data;throw new Error("Invalid upload response from backend")}function pl(n){return Ja(n)?typeof n.uuid=="string"&&typeof n.processing_status=="string":!1}function _x(n){if(pl(n))return n;if(Ja(n)&&pl(n.data))return n.data;throw new Error("Invalid media response from backend")}function qo(n){return n?{...n}:{}}function fl(n,o="PUT"){return typeof n.method=="string"&&n.method.trim()!==""?n.method.trim().toUpperCase():o}function Tx(n){return n.resumable===!0?!0:/tusupload/i.test(n.upload_url)}function Mx(n){if(typeof btoa=="function")try{return btoa(unescape(encodeURIComponent(n)))}catch{return btoa(n)}throw new Error("Base64 encoder is unavailable for TUS metadata")}function Fx(n,o){return[["filename",n.filename],["filetype",n.file.type||"application/octet-stream"],["uploadid",o.upload_id],["mediauuid",o.media_uuid]].map(([a,r])=>`${a} ${Mx(r)}`).join(",")}function Ko(n,o){const t=Math.max(n.bytesTotal,1);n.bytesUploaded=o,n.progress=Math.min(100,o/t*100);const a=Math.max((Date.now()-n.startedAt.getTime())/1e3,.001);n.uploadSpeed=o/a;const r=Math.max(t-o,0);n.timeRemaining=r/Math.max(n.uploadSpeed,1)}function Ix(n,o){return n instanceof Error?n:new Error(o)}function Bx(n){if(!(n instanceof Error))return!1;const o=n.message.toLowerCase();return o.includes("failed to fetch")||o.includes("networkerror")||o.includes("network request failed")||o.includes("err_ssl_")}function hl(n){const o=Math.max(0,n-1),t=Vx*Math.pow(2,o);return Math.min(5e3,t)}function vl(n){return new Promise(o=>{window.setTimeout(o,n)})}async function gl(n,o){for(let t=1;t<=Er;t+=1)try{const a=await o();if(a.ok||!Cx.has(a.status)||t>=Er)return a;await vl(hl(t))}catch(a){if(!Bx(a)||t>=Er)throw a;await vl(hl(t))}throw new Error(`${n} failed after retry attempts`)}function Rx(n={}){const o=e.ref(new Map),t=e.ref(new Set),a=e.ref(null),r=new Map,i=new Map,s=e.computed(()=>t.value.size>0),l=e.computed(()=>Array.from(o.value.values())),c=e.computed(()=>{const x=Array.from(o.value.values());return x.length===0?0:x.reduce((I,z)=>I+z.progress,0)/x.length});function d(x){a.value=x}function u(){}async function p(x){var I;const T=x.filter(z=>m(z));if(T.length!==0&&((I=n.onFilesSelected)==null||I.call(n,T),n.autoUpload!==!1))for(const z of T)await f(z)}function m(x){return!(n.maxFileSize&&x.size>n.maxFileSize||n.allowedFormats&&n.allowedFormats.length>0&&!n.allowedFormats.includes(x.type))}async function f(x){var z,P,j;const T=A(x);if(o.value.has(T)){const L=o.value.get(T);if((L==null?void 0:L.status)==="uploading")return}const I={id:T,file:x,filename:x.name,progress:0,status:"pending",startedAt:new Date,bytesTotal:x.size,bytesUploaded:0};o.value.set(I.id,I),t.value.add(I.id);try{I.status="uploading",(z=n.onUploadStart)==null||z.call(n,I);const L=await v(x);n.resumable===!0||L.resumable===!0?await S(I,L):await b(I,L),I.status="processing",I.progress=100;const D=await w(L.media_uuid);I.status="completed",I.media=D,(P=n.onUploadComplete)==null||P.call(n,D)}catch(L){if(I.status!=="cancelled"){const _=Ix(L,"Upload failed");I.status="error",I.error=_.message,(j=n.onUploadError)==null||j.call(n,_,I)}}finally{t.value.delete(I.id),r.delete(I.id),i.delete(I.id)}}async function v(x){if(!a.value)throw new Error("API client not configured");const T={collection:n.collection||"videos",filename:x.name,size:x.size,mime_type:x.type,...n.ownerUuid!==void 0?{ownerUuid:n.ownerUuid}:{},...n.ownerType!==void 0?{ownerType:n.ownerType}:{}},I=await a.value.post("/api/v1/video/upload",T);return Nx(I)}async function b(x,T){const I=new XMLHttpRequest,z=fl(T),P=qo(T.headers);return new Promise((j,L)=>{I.upload.addEventListener("progress",_=>{var D;_.lengthComputable&&(Ko(x,_.loaded),(D=n.onUploadProgress)==null||D.call(n,x))}),I.addEventListener("load",()=>{r.delete(x.id),I.status>=200&&I.status<300?j():L(new Error(`Upload failed with status ${I.status}`))}),I.addEventListener("error",()=>{r.delete(x.id),L(new Error("Upload failed"))}),I.addEventListener("abort",()=>{r.delete(x.id),L(new Error("Upload cancelled"))}),I.open(z,T.upload_url),Object.entries(P).forEach(([_,D])=>{I.setRequestHeader(_,D)}),!Object.keys(P).some(_=>_.toLowerCase()==="content-type")&&x.file.type&&I.setRequestHeader("Content-Type",x.file.type),r.set(x.id,I),I.send(x.file)})}async function S(x,T){var L;if(Tx(T)){await M(x,T);return}const I=n.chunkSize||5*1024*1024,z=E(x.file,I),P=new AbortController;i.set(x.id,P);const j=await h(T.upload_id);j&&(z.forEach(_=>{_.end<=j.bytesUploaded&&(_.uploaded=!0)}),Ko(x,j.bytesUploaded));for(const _ of z)_.uploaded||(await y(x,T,_,P),Ko(x,_.end),(L=n.onUploadProgress)==null||L.call(n,x))}async function M(x,T){var G;const I=new AbortController;i.set(x.id,I);const z={...qo(T.headers),"Tus-Resumable":"1.0.0","Upload-Length":String(x.file.size),"Upload-Metadata":Fx(x,T)},P=await gl("Resumable upload initialization",()=>fetch(T.upload_url,{method:"POST",headers:z,signal:I.signal}));if(!P.ok)throw new Error(`Failed to initialize resumable upload: ${P.status}`);const j=P.headers.get("Location");if(!j)throw new Error("Resumable upload endpoint did not return upload location");const L=new URL(j,T.upload_url).toString(),_=n.chunkSize||5*1024*1024;let D=0;for(;D<x.file.size;){const X=Math.min(D+_,x.file.size),ce=x.file.slice(D,X),Me={...qo(T.headers),"Tus-Resumable":"1.0.0","Upload-Offset":String(D),"Content-Type":"application/offset+octet-stream"},$e=await gl("Resumable chunk upload",()=>fetch(L,{method:"PATCH",headers:Me,body:ce,signal:I.signal}));if($e.status===409){const F=Number($e.headers.get("Upload-Offset")??"-1");if(Number.isFinite(F)&&F>=0){D=F;continue}}if(!$e.ok)throw new Error(`Resumable chunk upload failed: ${$e.status}`);const ae=Number($e.headers.get("Upload-Offset")??String(X));D=Number.isFinite(ae)&&ae>D?ae:X,Ko(x,D),(G=n.onUploadProgress)==null||G.call(n,x)}}function E(x,T){const I=[];let z=0,P=0;for(;z<x.size;){const j=Math.min(z+T,x.size);I.push({start:z,end:j,blob:x.slice(z,j),index:P,uploaded:!1}),z=j,P++}return I}async function y(x,T,I,z){const P={...qo(T.headers),"Content-Range":`bytes ${I.start}-${I.end-1}/${x.file.size}`,"Content-Type":x.file.type||"application/octet-stream"},j=await fetch(T.upload_url,{method:fl(T),headers:P,body:I.blob,signal:z.signal});if(!j.ok)throw new Error(`Chunk upload failed: ${j.status}`);I.uploaded=!0}async function h(x){return null}async function w(x){if(!a.value)throw new Error("API client not configured");const T=60;let I=0;for(;I<T;){const z=await a.value.get(`/api/v1/video/${x}`),P=_x(z),j=String(P.processing_status);if(j==="ready")return P;if(j==="failed"||j==="error")throw new Error("Video processing failed");await new Promise(L=>{window.setTimeout(L,5e3)}),I++}throw new Error("Video processing timeout")}function R(x){const T=o.value.get(x);if(!T)return;const I=r.get(x);I&&(I.abort(),r.delete(x));const z=i.get(x);z&&(z.abort(),i.delete(x)),T.status="cancelled",T.error="Upload cancelled",t.value.delete(x)}async function N(x){const T=o.value.get(x);T&&(T.status="pending",T.error="",T.progress=0,T.bytesUploaded=0,await f(T.file))}function g(x){o.value.delete(x),t.value.delete(x),r.delete(x),i.delete(x)}function C(){Array.from(o.value.entries()).forEach(([x,T])=>{T.status==="completed"&&o.value.delete(x)})}function A(x){return`${x.name}-${x.size}-${Date.now()}`}return{uploads:l,isUploading:s,totalProgress:c,openFilePicker:u,handleFileSelect:p,validateFile:m,startUpload:f,cancelUpload:R,retryUpload:N,removeUpload:g,clearCompleted:C,setApiClient:d}}const Px=["accept","multiple"],$x={key:0,class:"upload-trigger","data-testid":"video-uploader-trigger"},zx=["onKeydown"],Ax={key:1,class:"upload-list","data-testid":"video-upload-list"},Dx={class:"drag-content"},Ux=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(n,{emit:o}){const t=n,a=o,r=e.ref(),i=e.ref(!1),{uploads:s,isUploading:l,handleFileSelect:c,cancelUpload:d,retryUpload:u,removeUpload:p,setApiClient:m}=Rx({collection:t.collection,...t.ownerUuid!==void 0?{ownerUuid:t.ownerUuid}:{},...t.ownerType!==void 0?{ownerType:t.ownerType}:{},maxFileSize:t.maxFileSize,...t.maxDuration!==void 0?{maxDuration:t.maxDuration}:{},allowedFormats:t.allowedFormats,autoUpload:t.autoUpload,resumable:t.resumable,onUploadStart:h=>a("upload-start",h),onUploadProgress:h=>a("upload-progress",h),onUploadComplete:h=>a("upload-complete",h),onUploadError:(h,w)=>a("upload-error",h,w),onFilesSelected:h=>a("files-selected",h)});t.apiClient&&m(t.apiClient);const f=e.computed(()=>t.allowedFormats.join(",")),v=e.computed(()=>t.multiple||s.value.length===0);function b(){r.value&&r.value.click()}function S(h){const w=h.target,R=Array.from(w.files||[]);R.length>0&&(c(R),w.value="")}function M(h){var N;h.preventDefault(),i.value=!1;const R=Array.from(((N=h.dataTransfer)==null?void 0:N.files)||[]).filter(g=>g.type.startsWith("video/"));R.length>0&&c(R)}function E(h){var w;h.preventDefault(),(w=h.dataTransfer)!=null&&w.types.includes("Files")&&(i.value=!0)}function y(h){h.target.closest(".video-uploader")||(i.value=!1)}return e.onMounted(()=>{document.addEventListener("dragover",E),document.addEventListener("dragleave",y),document.addEventListener("drop",h=>h.preventDefault())}),e.onUnmounted(()=>{document.removeEventListener("dragover",E),document.removeEventListener("dragleave",y),document.removeEventListener("drop",h=>h.preventDefault())}),(h,w)=>(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:r,type:"file",accept:f.value,multiple:h.multiple,onChange:S,"data-testid":"video-uploader-input","aria-label":"Select video files to upload",hidden:""},null,40,Px),!e.unref(l)||v.value?(e.openBlock(),e.createElementBlock("div",$x,[e.renderSlot(h.$slots,"trigger",{open:b},()=>[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:b,onKeydown:[e.withKeys(b,["enter"]),e.withKeys(e.withModifiers(b,["prevent"]),["space"])]},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref($l),class:"upload-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("h3",null,e.toDisplayString(h.label),1),e.createElementVNode("p",null,e.toDisplayString(h.description),1),e.createVNode(e.unref(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(Hr),slot:"start","aria-hidden":"true"},null,8,["icon"]),w[2]||(w[2]=e.createTextVNode(" Select Video ",-1))]),_:1})],40,zx)],!0)])):e.createCommentVNode("",!0),e.unref(s).length>0?(e.openBlock(),e.createElementBlock("div",Ax,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),R=>(e.openBlock(),e.createBlock(Ex,{key:R.id,upload:R,onCancel:N=>e.unref(d)(R.id),onRetry:N=>e.unref(u)(R.id),onRemove:N=>e.unref(p)(R.id)},null,8,["upload","onCancel","onRetry","onRemove"]))),128))])):e.createCommentVNode("",!0),i.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:"drag-overlay","data-testid":"video-uploader-drag-overlay",onDrop:M,onDragover:w[0]||(w[0]=e.withModifiers(()=>{},["prevent"])),onDragleave:w[1]||(w[1]=R=>i.value=!1)},[e.createElementVNode("div",Dx,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Na),"aria-hidden":"true"},null,8,["icon"]),w[3]||(w[3]=e.createElementVNode("p",null,"Drop video files here",-1))])],32)):e.createCommentVNode("",!0)],2))}}),Ox=_e(Ux,[["__scopeId","data-v-ea7587f7"]]),Lx=["aria-valuenow","aria-valuemax","aria-label"],Wx={class:"progress-bar"},jx={class:"time-display","data-testid":"video-time-display"},Xx={class:"current-time"},Zx={class:"duration"},Yx={class:"control-buttons"},Gx={class:"controls-left"},Hx=["aria-label"],Jx={class:"controls-center"},qx={key:0,class:"volume-controls"},Kx=["aria-label"],Qx=["value"],eS={class:"controls-right"},tS={key:0,class:"quality-selector"},nS=["aria-expanded"],oS={class:"quality-label"},aS={key:0,class:"quality-menu","data-testid":"video-quality-menu",role:"menu"},rS=["data-testid","aria-label","onClick"],iS=["aria-label"],sS=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(n,{emit:o}){const t=n,a=o,r=e.ref(!0),i=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}%`})),p=e.computed(()=>{if(!t.buffered||t.buffered.length===0)return{width:"0%"};for(let h=0;h<t.buffered.length;h++){const w=t.buffered.start(h),R=t.buffered.end(h);if(t.currentTime>=w&&t.currentTime<=R)return{width:`${R/t.duration*100}%`}}return t.buffered.length>0?{width:`${t.buffered.end(0)/t.duration*100}%`}:{width:"0%"}}),m=e.computed(()=>t.muted||t.volume===0?$m:t.volume<33?Bm:t.volume<66?Rm:Im);let f=null;function v(){r.value=!0,b()}function b(){f&&clearTimeout(f),t.playing&&!l&&(f=setTimeout(()=>{r.value=!1},3e3))}function S(h){if(!s.value||t.isLive)return;const w=s.value.getBoundingClientRect(),N=(h.clientX-w.left)/w.width*t.duration;a("seek",Math.max(0,Math.min(N,t.duration)))}function M(h){const w=h.target;a("setVolume",parseInt(w.value))}function E(h){a("selectQuality",h),i.value=!1}function y(h){if(!isFinite(h))return"0:00";const w=Math.floor(h/3600),R=Math.floor(h%3600/60),N=Math.floor(h%60);return w>0?`${w}:${R.toString().padStart(2,"0")}:${N.toString().padStart(2,"0")}`:`${R}:${N.toString().padStart(2,"0")}`}return e.onMounted(()=>{document.addEventListener("mousemove",v),b()}),e.onUnmounted(()=>{document.removeEventListener("mousemove",v),f&&clearTimeout(f)}),(h,w)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-controls",{"controls-visible":r.value}]),"data-testid":"video-controls"},[e.createElementVNode("div",{class:"progress-container","data-testid":"video-progress-bar",role:"slider","aria-valuenow":Math.round(h.currentTime),"aria-valuemin":"0","aria-valuemax":Math.round(h.duration),"aria-label":h.isLive?"Live stream":"Video progress",tabindex:"0",onClick:S},[e.createElementVNode("div",Wx,[e.createElementVNode("div",{class:"progress-buffered",style:e.normalizeStyle(p.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",jx,[e.createElementVNode("span",Xx,e.toDisplayString(y(h.currentTime)),1),w[7]||(w[7]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",Zx,e.toDisplayString(h.isLive?"LIVE":y(h.duration)),1)])],8,Lx),e.createElementVNode("div",Yx,[e.createElementVNode("div",Gx,[e.createElementVNode("button",{class:"control-btn play-pause","data-testid":"btn-video-play-pause",onClick:w[0]||(w[0]=R=>h.$emit("play-pause")),"aria-label":h.playing?"Pause":"Play"},[e.createVNode(e.unref(B.IonIcon),{icon:h.playing?e.unref(hm):e.unref(ym),"aria-hidden":"true"},null,8,["icon"])],8,Hx),h.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"control-btn skip-backward","data-testid":"btn-video-skip-backward",onClick:w[1]||(w[1]=R=>h.$emit("skip-backward")),"aria-label":"Skip backward 10 seconds"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(bm),"aria-hidden":"true"},null,8,["icon"]),w[8]||(w[8]=e.createElementVNode("span",{class:"skip-label"},"10",-1))])),h.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn skip-forward","data-testid":"btn-video-skip-forward",onClick:w[2]||(w[2]=R=>h.$emit("skip-forward")),"aria-label":"Skip forward 10 seconds"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(xm),"aria-hidden":"true"},null,8,["icon"]),w[9]||(w[9]=e.createElementVNode("span",{class:"skip-label"},"10",-1))]))]),e.createElementVNode("div",Jx,[e.unref(l)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",qx,[e.createElementVNode("button",{class:"control-btn mute-btn","data-testid":"btn-video-mute",onClick:w[3]||(w[3]=R=>h.$emit("toggleMute")),"aria-label":h.muted?"Unmute":"Mute"},[e.createVNode(e.unref(B.IonIcon),{icon:m.value,"aria-hidden":"true"},null,8,["icon"])],8,Kx),e.createElementVNode("input",{type:"range",class:"volume-slider","data-testid":"slider-video-volume",min:"0",max:"100",value:h.muted?0:h.volume,onInput:M,"aria-label":"Volume"},null,40,Qx)]))]),e.createElementVNode("div",eS,[h.qualityLevels.length>1?(e.openBlock(),e.createElementBlock("div",tS,[e.createElementVNode("button",{class:"control-btn quality-btn","data-testid":"btn-video-quality",onClick:w[4]||(w[4]=R=>i.value=!i.value),"aria-label":"Quality settings","aria-expanded":i.value},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Tm),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("span",oS,e.toDisplayString(h.currentQuality),1)],8,nS),i.value?(e.openBlock(),e.createElementBlock("div",aS,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.qualityLevels,R=>(e.openBlock(),e.createElementBlock("button",{key:R.label,class:e.normalizeClass(["quality-option",{active:R.label===h.currentQuality}]),"data-testid":`btn-video-quality-${R.label}`,"aria-label":`Set quality to ${R.label}`,role:"menuitem",onClick:N=>E(R)},e.toDisplayString(R.label),11,rS))),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:w[5]||(w[5]=R=>h.$emit("togglePiP")),"aria-label":"Picture in Picture"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Mm),"aria-hidden":"true"},null,8,["icon"])])):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"control-btn fullscreen-btn","data-testid":"btn-video-fullscreen",onClick:w[6]||(w[6]=R=>h.$emit("toggleFullscreen")),"aria-label":h.fullscreen?"Exit fullscreen":"Enter fullscreen"},[e.createVNode(e.unref(B.IonIcon),{icon:h.fullscreen?e.unref(rm):e.unref(lm),"aria-hidden":"true"},null,8,["icon"])],8,iS)])])],2))}}),lS=_e(sS,[["__scopeId","data-v-2ae77c13"]]);function cS(n={}){var ce,Me,$e;const o=e.ref(),t=e.ref(),a=e.ref(!1),r=e.ref(0),i=e.ref(0),s=e.ref(100),l=e.ref(n.muted||!1),c=e.ref(!1),d=e.ref(),u=e.ref(1),p=e.ref(!1),m=e.ref(null),f=e.ref("idle"),v=e.ref(n.playbackUrl||((ce=n.media)==null?void 0:ce.playback_url)||((Me=n.media)==null?void 0:Me.url)||""),b=e.ref(null),S=e.ref(n.isLive||!1),M=e.ref(null),E=e.ref(null);function y(ae){E.value=ae}if(($e=n.media)!=null&&$e.token_expires_at){const ae=new Date(n.media.token_expires_at);b.value=Number.isNaN(ae.getTime())?null:ae}async function h(){var F;const ae=S.value?t.value:o.value;if(ae)try{await ae.play(),a.value=!0,f.value=S.value?"live":"playing",(F=n.onPlay)==null||F.call(n)}catch{m.value="Failed to play video",f.value="error"}}function w(){var F;const ae=S.value?t.value:o.value;ae&&(ae.pause(),a.value=!1,f.value="paused",(F=n.onPause)==null||F.call(n))}function R(){a.value?w():h()}function N(ae){const F=S.value?t.value:o.value;if(!F||S.value)return;const O=Number.isFinite(F.duration)?F.duration:ae;F.currentTime=Math.max(0,Math.min(ae,O)),r.value=F.currentTime}function g(ae=10){const F=o.value;!F||S.value||N(F.currentTime+ae)}function C(ae=10){const F=o.value;!F||S.value||N(F.currentTime-ae)}function A(){const ae=S.value?t.value:o.value;ae&&(ae.muted=!ae.muted,l.value=ae.muted)}function x(ae){const F=S.value?t.value:o.value;if(!F)return;const O=Math.max(0,Math.min(100,ae));F.volume=O/100,s.value=O,O>0&&F.muted&&(F.muted=!1,l.value=!1)}function T(ae){const F=o.value;!F||S.value||(F.playbackRate=ae,u.value=ae)}async function I(){const ae=document.querySelector(".video-player-container");if(ae)try{document.fullscreenElement?(await document.exitFullscreen(),c.value=!1):(await ae.requestFullscreen(),c.value=!0)}catch{}}async function z(){const ae=S.value?t.value:o.value;if(ae)try{document.pictureInPictureElement?await document.exitPictureInPicture():document.pictureInPictureEnabled&&await ae.requestPictureInPicture()}catch{}}async function P(){var F;m.value=null,f.value="loading",(F=n.media)!=null&&F.provider&&n.media.provider!=="local"&&await j();const ae=S.value?t.value:o.value;ae&&(ae.load(),await h())}async function j(){if(!(!E.value||!n.media))try{p.value=!0;const ae=await E.value.get(`/api/v1/video/${n.media.uuid}/playback`);v.value=ae.playback_url,b.value=new Date(ae.token_expires_at);const F=S.value?t.value:o.value;if(F&&F.src!==v.value){const O=!F.paused,de=F.currentTime;F.src=v.value,S.value||(F.currentTime=de),O&&await h()}}catch{m.value="Failed to refresh playback token",f.value="error"}finally{p.value=!1}}async function L(ae){if(t.value){if(t.value.canPlayType("application/vnd.apple.mpegurl")){t.value.src=ae;return}try{t.value.src=ae}catch{m.value="Live streaming not supported in this browser",f.value="error"}}}function _(){M.value&&(M.value.destroy(),M.value=null)}function D(){var F;const ae=S.value?t.value:o.value;ae&&(r.value=ae.currentTime,i.value=ae.duration,(F=n.onTimeUpdate)==null||F.call(n,ae.currentTime))}const G=e.computed(()=>{if(!d.value||d.value.length===0||!i.value)return 0;for(let ae=0;ae<d.value.length;ae++){const F=d.value.start(ae),O=d.value.end(ae);if(r.value>=F&&r.value<=O)return O/i.value*100}return 0});function X(){if(!b.value)return!1;const ae=new Date;return b.value.getTime()-ae.getTime()<5*60*1e3}return e.watch([o,t],([ae,F])=>{const O=S.value?F:ae;O&&(O.addEventListener("timeupdate",D),O.addEventListener("loadedmetadata",()=>{i.value=O.duration,f.value="ready"}),O.addEventListener("progress",()=>{d.value=O.buffered}),O.addEventListener("ended",()=>{var de;a.value=!1,f.value="ended",(de=n.onEnded)==null||de.call(n)}),O.addEventListener("error",de=>{var re;f.value="error",(re=n.onError)==null||re.call(n,"Video playback error")}),O.volume=s.value/100,O.muted=l.value)}),e.onUnmounted(()=>{_();const ae=S.value?t.value:o.value;ae&&ae.removeEventListener("timeupdate",D)}),{videoEl:o,liveVideoEl:t,playing:a,currentTime:r,duration:i,volume:s,muted:l,isFullscreen:c,bufferedRanges:d,bufferedPercent:G,playbackRate:u,isLoading:p,error:m,status:f,currentPlaybackUrl:v,tokenExpiresAt:b,play:h,pause:w,togglePlayPause:R,seek:N,skipForward:g,skipBackward:C,toggleMute:A,setVolume:x,setPlaybackRate:T,toggleFullscreen:I,togglePiP:z,retry:P,refreshToken:j,setupLiveStream:L,setApiClient:y,shouldRefreshToken:X}}const dS=["src","poster","controls","autoplay","muted","loop","preload"],uS={key:1,ref:"livePlayerEl",class:"live-player"},mS=["controls","muted"],pS={key:0,class:"live-indicator","data-testid":"video-live-indicator","aria-label":"Live stream"},fS={key:2,class:"video-loading","data-testid":"video-loading",role:"status","aria-label":"Loading video"},hS={key:3,class:"video-error","data-testid":"video-error",role:"alert"},vS={key:5,class:"gesture-zones","data-testid":"video-gesture-zones"},gS=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(n,{emit:o}){const t=n,a=o,{videoEl:r,liveVideoEl:i,playing:s,currentTime:l,duration:c,volume:d,muted:u,isFullscreen:p,bufferedRanges:m,isLoading:f,error:v,status:b,currentPlaybackUrl:S,tokenExpiresAt:M,play:E,pause:y,seek:h,toggleMute:w,setVolume:R,toggleFullscreen:N,togglePlayPause:g,skipForward:C,skipBackward:A,retry:x,refreshToken:T,setApiClient:I,shouldRefreshToken:z,setupLiveStream:P}=cS({...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 L=e.computed(()=>{const re=["video-player-container"];return t.className&&re.push(t.className),p.value&&re.push("fullscreen"),t.isLive&&re.push("is-live"),s.value&&re.push("is-playing"),f.value&&re.push("is-loading"),re}),_=e.computed(()=>{var re,q;if(t.poster)return t.poster;if((re=t.media)!=null&&re.poster_url)return t.media.poster_url;if((q=t.media)!=null&&q.thumbnail_url)return t.media.thumbnail_url});function D(re){const q=re.target;a("loadedmetadata",{duration:q.duration,width:q.videoWidth,height:q.videoHeight})}function G(re){const q=re.target;l.value=q.currentTime,a("timeupdate",q.currentTime)}function X(){s.value=!0,a("play")}function ce(){s.value=!1,a("pause")}function Me(){s.value=!1,a("ended")}function $e(re){const q=re.target;let ee="Failed to load video";if(q.error)switch(q.error.code){case q.error.MEDIA_ERR_ABORTED:ee="Video playback aborted";break;case q.error.MEDIA_ERR_NETWORK:ee="Network error while loading video";break;case q.error.MEDIA_ERR_DECODE:ee="Video decoding error";break;case q.error.MEDIA_ERR_SRC_NOT_SUPPORTED:ee="Video format not supported";break}v.value=ee,a("error",ee)}function ae(re){const q=re.target;m.value=q.buffered,a("progress",q.buffered)}function F(){f.value=!0}function O(){f.value=!1}e.watch(()=>t.apiClient,re=>{re&&I(re)},{immediate:!0}),e.watch(()=>t.playbackUrl,re=>{typeof re=="string"&&re.length>0&&(S.value=re)},{immediate:!0}),e.watch(()=>{var re;return(re=t.media)==null?void 0:re.token_expires_at},re=>{if(!re){M.value=null;return}const q=new Date(re);M.value=Number.isNaN(q.getTime())?null:q},{immediate:!0}),e.watch(()=>{var re;return(re=t.media)==null?void 0:re.playback_url},async(re,q)=>{if(t.playbackUrl||!re||re===q)return;const ee=r.value;if(!ee||t.isLive){S.value=re;return}const ue=!ee.paused,ge=ee.currentTime;S.value=re,await e.nextTick();try{ee.currentTime=ge}catch{}ue&&await E()},{immediate:!0});let de=null;return e.watch(()=>t.isLive,async re=>{var ee;if(!re)return;const q=t.playbackUrl||((ee=t.media)==null?void 0:ee.playback_url)||"";q&&await P(q)},{immediate:!0}),e.onMounted(()=>{var re;(re=t.media)!=null&&re.provider&&t.media.provider!=="local"&&(de=setInterval(()=>{z()&&j()},3e4)),B.isPlatform("mobile")&&t.showCustomControls}),e.onUnmounted(()=>{de&&clearInterval(de)}),(re,q)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-player-container",L.value]),"data-testid":"video-player"},[re.isLive?(e.openBlock(),e.createElementBlock("div",uS,[e.createElementVNode("video",{ref_key:"liveVideoEl",ref:i,controls:re.controls&&!re.showCustomControls,autoplay:!0,muted:e.unref(u),onPlay:X,onPause:ce,onError:$e,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,mS),e.unref(b)==="live"?(e.openBlock(),e.createElementBlock("div",pS,[...q[3]||(q[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:r,src:e.unref(S),poster:_.value,controls:re.controls&&!re.showCustomControls,autoplay:re.autoplay,muted:e.unref(u),loop:re.loop,preload:re.preload,onLoadedmetadata:D,onTimeupdate:G,onPlay:X,onPause:ce,onEnded:Me,onError:$e,onProgress:ae,onWaiting:F,onCanplay:O,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,dS)),e.unref(f)?(e.openBlock(),e.createElementBlock("div",fS,[e.createVNode(e.unref(B.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),e.unref(v)?(e.openBlock(),e.createElementBlock("div",hS,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Jr),"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(x),"data-testid":"btn-video-retry","aria-label":"Retry loading video"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(So),slot:"start","aria-hidden":"true"},null,8,["icon"]),q[4]||(q[4]=e.createTextVNode(" Retry ",-1))]),_:1},8,["onClick"])])):e.createCommentVNode("",!0),re.showCustomControls&&!e.unref(v)?(e.openBlock(),e.createBlock(lS,{key:4,playing:e.unref(s),currentTime:e.unref(l),duration:e.unref(c),buffered:e.unref(m),volume:e.unref(d),muted:e.unref(u),fullscreen:e.unref(p),isLive:re.isLive,onPlay:e.unref(E),onPause:e.unref(y),onSeek:e.unref(h),onToggleMute:e.unref(w),onSetVolume:e.unref(R),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),re.enableGestures&&!e.unref(v)?(e.openBlock(),e.createElementBlock("div",vS,[e.createElementVNode("div",{class:"gesture-left","data-testid":"video-gesture-skip-back","aria-label":"Double tap to skip backward",onDblclick:q[0]||(q[0]=(...ee)=>e.unref(A)&&e.unref(A)(...ee))},null,32),e.createElementVNode("div",{class:"gesture-center","data-testid":"video-gesture-play-pause","aria-label":"Tap to play or pause",onClick:q[1]||(q[1]=(...ee)=>e.unref(g)&&e.unref(g)(...ee))}),e.createElementVNode("div",{class:"gesture-right","data-testid":"video-gesture-skip-forward","aria-label":"Double tap to skip forward",onDblclick:q[2]||(q[2]=(...ee)=>e.unref(C)&&e.unref(C)(...ee))},null,32)])):e.createCommentVNode("",!0)],2))}}),Wc=_e(gS,[["__scopeId","data-v-b8db4951"]]),yS=Ca.defineStore("video",()=>{const n=e.ref(new Map),o=e.ref(new Map),t=e.ref(new Map),a=e.ref(null),r=e.ref(!1),i=e.computed(()=>Array.from(n.value.values())),s=e.computed(()=>Array.from(o.value.values())),l=e.computed(()=>s.value.filter(P=>P.status==="live")),c=e.computed(()=>i.value.filter(P=>P.processing_status==="processing"));function d(P){n.value.set(P.uuid,P)}function u(P,j){const L=n.value.get(P);L&&n.value.set(P,{...L,...j})}function p(P){n.value.delete(P)}function m(P){return n.value.get(P)}function f(P){o.value.set(P.id,P)}function v(P,j){const L=o.value.get(P);L&&o.value.set(P,{...L,...j})}function b(P,j){const L=o.value.get(P);L&&o.value.set(P,{...L,status:j.status,viewer_count:j.viewer_count,peak_viewers:j.peak_viewers})}function S(P){o.value.delete(P)}function M(P){return o.value.get(P)}function E(P){return s.value.find(j=>j.media_uuid===P)}function y(P){t.value.set(P.id,P)}function h(P,j){const L=t.value.get(P);L&&t.value.set(P,{...L,...j})}function w(P){t.value.delete(P)}function R(P){return t.value.get(P)}function N(P){return Array.from(t.value.values()).filter(j=>j.media_uuid===P)}function g(P){a.value=P}function C(P){a.value&&(a.value={...a.value,...P})}function A(){a.value=null}function x(P){r.value=P}function T(){n.value.clear(),o.value.clear(),t.value.clear(),a.value=null,r.value=!1}function I(P){n.value.clear(),P.forEach(j=>{n.value.set(j.uuid,j)})}function z(P){o.value.clear(),P.forEach(j=>{o.value.set(j.id,j)})}return{videos:n,liveStreams:o,exportJobs:t,currentEditorState:a,isProcessing:r,allVideos:i,allLiveStreams:s,activeLiveStreams:l,processingVideos:c,setVideo:d,updateVideo:u,removeVideo:p,getVideo:m,setLiveStream:f,updateLiveStream:v,updateLiveStreamStats:b,removeLiveStream:S,getLiveStream:M,getLiveStreamByMedia:E,addExportJob:y,updateExportJob:h,removeExportJob:w,getExportJob:R,getExportJobsByMedia:N,setEditorState:g,updateEditorState:C,clearEditorState:A,setProcessing:x,clearAll:T,loadVideos:I,loadLiveStreams:z}});let gn=null;function bS(n){gn=n}const Qo={post:async(n,o)=>{if(!gn)throw new Error("HTTP client not configured");return await gn(`/api/v1/video${n}`,{method:"POST",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}})},get:async n=>{if(!gn)throw new Error("HTTP client not configured");return await gn(`/api/v1/video${n}`)},delete:async n=>{if(!gn)throw new Error("HTTP client not configured");return await gn(`/api/v1/video${n}`,{method:"DELETE"})}};function ea(n,o=null){const t=typeof n.id=="string"&&n.id!==""?n.id:typeof n.stream_id=="string"&&n.stream_id!==""?n.stream_id:o==null?void 0:o.id;if(!t)throw new Error("Invalid live stream response: missing stream id");const a={id:t,media_uuid:n.media_uuid??(o==null?void 0:o.media_uuid)??"",stream_key:n.stream_key??(o==null?void 0:o.stream_key)??"",rtmp_url:n.rtmp_url??(o==null?void 0:o.rtmp_url)??"",status:n.status??(o==null?void 0:o.status)??"idle",viewer_count:n.viewer_count??(o==null?void 0:o.viewer_count)??0,peak_viewers:n.peak_viewers??(o==null?void 0:o.peak_viewers)??0,auto_record:n.auto_record??(o==null?void 0:o.auto_record)??!0,low_latency:n.low_latency??(o==null?void 0:o.low_latency)??!1},r=n.playback_url??(o==null?void 0:o.playback_url);r!==void 0&&(a.playback_url=r);const i=n.started_at??(o==null?void 0:o.started_at);i!==void 0&&(a.started_at=i);const s=n.ended_at??(o==null?void 0:o.ended_at);return s!==void 0&&(a.ended_at=s),(o==null?void 0:o.metadata)!==void 0&&(a.metadata=o.metadata),(o==null?void 0:o.vod_media_uuid)!==void 0&&(a.vod_media_uuid=o.vod_media_uuid),a}function Vr(n,o){return n instanceof Error&&n.message?n.message:o}function wS(n){const o=yS(),t=e.ref(null),a=e.ref(!1),r=e.ref(!0),i=e.ref(""),s=e.ref(!1),l=e.ref(!1),c=e.ref(null),d=e.ref(null),u=e.ref(0),p=e.ref(0);let m;const f=e.computed(()=>d.value?Math.floor((new Date().getTime()-d.value.getTime())/1e3):0),v=e.computed(()=>{var A;if(!((A=t.value)!=null&&A.playback_url))return null;const C=new URL(t.value.playback_url);return C.searchParams.set("live","true"),a.value&&C.searchParams.set("latency","low"),C.toString()}),b=e.computed(()=>{var C;return((C=t.value)==null?void 0:C.status)==="live"}),S=e.computed(()=>{var C;return((C=t.value)==null?void 0:C.status)==="idle"}),M=e.computed(()=>{var C;return((C=t.value)==null?void 0:C.status)==="ended"});async function E(C={}){s.value=!0,c.value=null;try{const A=await Qo.post("/live",{title:i.value||C.title||"Live Stream",low_latency:C.low_latency??a.value,auto_record:C.auto_record??r.value,...C}),x=ea(A);return t.value=x,o.setLiveStream(x),R(),x}catch(A){throw c.value=Vr(A,"Failed to create stream"),A instanceof Error?A:new Error(c.value)}finally{s.value=!1}}async function y(){if(!t.value)throw new Error("No active stream");l.value=!0,c.value=null;try{const C=await Qo.post(`/live/${t.value.id}/end`),A=ea(C,t.value);return t.value=A,o.setLiveStream(A),N(),A}catch(C){throw c.value=Vr(C,"Failed to end stream"),C instanceof Error?C:new Error(c.value)}finally{l.value=!1}}async function h(){if(t.value)try{const C=await Qo.get(`/live/${t.value.id}`),A=ea(C,t.value);u.value=A.viewer_count,p.value=A.peak_viewers,t.value=A;const x={status:A.status,viewer_count:A.viewer_count,peak_viewers:A.peak_viewers};A.started_at&&(x.started_at=A.started_at),A.ended_at&&(x.ended_at=A.ended_at),o.updateLiveStreamStats(A.id,x),A.status==="live"&&!d.value&&A.started_at&&(d.value=new Date(A.started_at)),A.status==="ended"&&N()}catch{}}async function w(C){try{const A=await Qo.get(`/live/${C}`),x=ea(A,t.value);return{rtmp_url:x.rtmp_url,stream_key:x.stream_key,playback_url:x.playback_url||""}}catch(A){throw c.value=Vr(A,"Failed to get stream credentials"),A instanceof Error?A:new Error(c.value)}}function R(C=5e3){N(),m=window.setInterval(()=>{h()},C)}function N(){m!==void 0&&(clearInterval(m),m=void 0)}async function g(){if(!n)return;const C=o.getLiveStreamByMedia(n);C&&(t.value=C,u.value=C.viewer_count,p.value=C.peak_viewers,C.status==="live"&&(R(),C.started_at&&(d.value=new Date(C.started_at))))}return n&&g(),e.onUnmounted(()=>{N()}),{stream:t,lowLatency:a,autoRecord:r,streamTitle:i,isCreating:s,isEnding:l,error:c,streamDuration:f,viewerCount:u,peakViewers:p,playbackUrl:v,isLive:b,isIdle:S,hasEnded:M,createStream:E,endStream:y,refreshStreamStatus:h,getStreamCredentials:w,startStatusPolling:R,stopStatusPolling:N}}const kS={class:"stream-status"},xS={class:"flex items-center justify-between"},SS={class:"flex items-center gap-3"},ES={key:0,class:"flex items-center"},VS={key:2,class:"text-sm text-gray-600"},CS={key:0,class:"flex items-center gap-2"},NS={class:"text-sm font-medium text-gray-700"},_S={key:0,class:"text-xs text-gray-500"},TS=e.defineComponent({__name:"StreamStatus",props:{status:{},viewers:{},peakViewers:{},duration:{}},setup(n){const o=n,t=e.computed(()=>({idle:"Ready to Stream",live:"Live",ended:"Stream Ended",error:"Error"})[o.status]||o.status),a=e.computed(()=>{const i="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`${i} ${s[o.status]||s.idle}`}),r=e.computed(()=>{if(!o.duration)return null;const i=Math.floor(o.duration/3600),s=Math.floor(o.duration%3600/60),l=o.duration%60;return i>0?`${i}:${s.toString().padStart(2,"0")}:${l.toString().padStart(2,"0")}`:`${s}:${l.toString().padStart(2,"0")}`});return(i,s)=>(e.openBlock(),e.createElementBlock("div",kS,[e.createElementVNode("div",xS,[e.createElementVNode("div",SS,[i.status==="live"?(e.openBlock(),e.createElementBlock("div",ES,[...s[0]||(s[0]=[e.createElementVNode("span",{class:"relative flex h-3 w-3"},[e.createElementVNode("span",{class:"animate-ping absolute inline-flex h-full w-full rounded-full bg-red-400 opacity-75"}),e.createElementVNode("span",{class:"relative inline-flex rounded-full h-3 w-3 bg-red-500"})],-1),e.createElementVNode("span",{class:"ml-2 text-sm font-semibold text-red-600 uppercase"},"Live",-1)])])):(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(a.value)},e.toDisplayString(t.value),3)),r.value?(e.openBlock(),e.createElementBlock("div",VS,e.toDisplayString(r.value),1)):e.createCommentVNode("",!0)]),i.viewers!==void 0?(e.openBlock(),e.createElementBlock("div",CS,[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",NS,e.toDisplayString(i.viewers)+" "+e.toDisplayString(i.viewers===1?"viewer":"viewers"),1),i.peakViewers>i.viewers?(e.openBlock(),e.createElementBlock("span",_S," (Peak: "+e.toDisplayString(i.peakViewers)+") ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])]))}}),MS=_e(TS,[["__scopeId","data-v-1d09c19f"]]),FS={class:"stream-credentials"},IS={class:"space-y-3"},BS={class:"credential-field"},RS={class:"flex gap-2"},PS=["value"],$S={class:"credential-field"},zS={class:"flex gap-2"},AS=["value","type"],DS=["aria-label"],US={key:0,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},OS={key:1,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},LS={key:0,class:"mt-2 text-sm text-green-600"},WS=e.defineComponent({__name:"StreamCredentials",props:{rtmpUrl:{},streamKey:{}},emits:["copy"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(!1),i=e.ref(""),s=e.computed(()=>{if(r.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(){r.value=!r.value}async function c(d,u){try{await navigator.clipboard.writeText(d),i.value=u,a("copy",d,u),setTimeout(()=>{i.value=""},2e3)}catch{}}return(d,u)=>(e.openBlock(),e.createElementBlock("div",FS,[u[8]||(u[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Stream Settings",-1)),e.createElementVNode("div",IS,[e.createElementVNode("div",BS,[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",RS,[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,PS),e.createElementVNode("button",{onClick:u[0]||(u[0]=p=>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",$S,[u[7]||(u[7]=e.createElementVNode("label",{class:"block text-xs font-medium text-gray-500 mb-1"},"Stream Key",-1)),e.createElementVNode("div",zS,[e.createElementVNode("input",{value:s.value,readonly:"",type:r.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,AS),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":r.value?"Hide stream key":"Show stream key"},[r.value?(e.openBlock(),e.createElementBlock("svg",OS,[...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",US,[...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,DS),e.createElementVNode("button",{onClick:u[1]||(u[1]=p=>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(()=>[i.value?(e.openBlock(),e.createElementBlock("div",LS,e.toDisplayString(i.value)+" copied to clipboard! ",1)):e.createCommentVNode("",!0)]),_:1})]))}}),jS=_e(WS,[["__scopeId","data-v-306d92f6"]]),XS={class:"live-stream-manager","data-testid":"live-stream-manager"},ZS={key:0,class:"stream-setup"},YS={class:"space-y-4"},GS={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},HS={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},JS=["disabled"],qS={key:0},KS={key:1,class:"flex items-center justify-center"},QS={key:1,class:"stream-active space-y-6"},eE={key:1,class:"video-preview"},tE={key:2,class:"analytics-panel"},nE={class:"grid grid-cols-2 gap-4"},oE={class:"bg-gray-50 p-3 rounded"},aE={class:"text-2xl font-bold text-gray-900"},rE={class:"bg-gray-50 p-3 rounded"},iE={class:"text-2xl font-bold text-gray-900"},sE={class:"stream-controls flex gap-3"},lE=["disabled"],cE={key:0},dE={key:1},uE={key:2,class:"mt-4 p-4 bg-red-50 border border-red-200 rounded-lg"},mE={class:"text-red-600 text-sm"},pE=e.defineComponent({__name:"LiveStreamManager",props:{mediaUuid:{},onStreamCreated:{type:Function},onStreamEnded:{type:Function},httpClient:{type:Function}},emits:["stream-created","stream-ended","error"],setup(n,{emit:o}){const t=n,a=o;t.httpClient&&bS(t.httpClient);const{stream:r,lowLatency:i,autoRecord:s,streamTitle:l,isCreating:c,isEnding:d,error:u,createStream:p,endStream:m,streamDuration:f,playbackUrl:v,refreshStreamStatus:b}=wS(t.mediaUuid),S=e.ref(!1);async function M(){var R;try{const N=await p({title:l.value,low_latency:i.value,auto_record:s.value});a("stream-created",N),(R=t.onStreamCreated)==null||R.call(t,N)}catch(N){a("error",N)}}async function E(){var R;try{const N=await m();a("stream-ended",N),(R=t.onStreamEnded)==null||R.call(t,N)}catch(N){a("error",N)}}function y(){r.value=null,l.value="",S.value=!1,u.value=null}async function h(R,N){try{await navigator.clipboard.writeText(R)}catch{}}let w;return e.onMounted(()=>{var R;((R=r.value)==null?void 0:R.status)==="live"&&(w=window.setInterval(()=>{b()},5e3))}),e.onUnmounted(()=>{w&&clearInterval(w)}),(R,N)=>(e.openBlock(),e.createElementBlock("div",XS,[e.unref(r)?(e.openBlock(),e.createElementBlock("div",QS,[e.createVNode(MS,{status:e.unref(r).status,viewers:e.unref(r).viewer_count,duration:e.unref(f),"peak-viewers":e.unref(r).peak_viewers},null,8,["status","viewers","duration","peak-viewers"]),e.unref(r).status==="idle"?(e.openBlock(),e.createBlock(jS,{key:0,"rtmp-url":e.unref(r).rtmp_url,"stream-key":e.unref(r).stream_key,onCopy:h},null,8,["rtmp-url","stream-key"])):e.createCommentVNode("",!0),e.unref(v)?(e.openBlock(),e.createElementBlock("div",eE,[N[9]||(N[9]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-2"},"Live Preview",-1)),e.createVNode(Wc,{"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(r).status==="live"?(e.openBlock(),e.createElementBlock("div",tE,[N[12]||(N[12]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Live Analytics",-1)),e.createElementVNode("div",nE,[e.createElementVNode("div",oE,[e.createElementVNode("div",aE,e.toDisplayString(e.unref(r).viewer_count),1),N[10]||(N[10]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Current Viewers",-1))]),e.createElementVNode("div",rE,[e.createElementVNode("div",iE,e.toDisplayString(e.unref(r).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",sE,[e.unref(r).status==="idle"?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:N[3]||(N[3]=g=>S.value=!S.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(S.value?"Hide":"Show")+" Credentials ",1)):e.createCommentVNode("",!0),e.unref(r).status==="live"?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:E,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",dE,"Ending...")):(e.openBlock(),e.createElementBlock("span",cE,"End Stream"))],8,lE)):e.createCommentVNode("",!0),e.unref(r).status==="ended"?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:y,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",ZS,[N[8]||(N[8]=e.createElementVNode("h3",{class:"text-lg font-semibold mb-4"},"Start Live Stream",-1)),e.createElementVNode("div",YS,[e.createElementVNode("div",GS,[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(i)?i.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(i)]])]),e.createElementVNode("div",HS,[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:M,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",KS,[...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",qS,"Create Stream"))],8,JS)])])),e.unref(u)?(e.openBlock(),e.createElementBlock("div",uE,[e.createElementVNode("p",mE,e.toDisplayString(e.unref(u)),1)])):e.createCommentVNode("",!0)]))}}),fE=_e(pE,[["__scopeId","data-v-26291f6f"]]),hE={class:"album-tree-node"},vE=["data-album-id","draggable","aria-selected","aria-expanded"],gE={key:1,class:"album-node__chevron-placeholder"},yE={key:2,"data-testid":"media-count",class:"album-node__count"},bE={key:0,class:"album-tree-node__children",role:"group"},wE=16,kE=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(n,{emit:o}){const t=n,a=o,r=e.computed(()=>t.expandedIds.has(t.album.id)),i=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*wE}px`),d=e.computed(()=>{var y;return((y=t.dragState)==null?void 0:y.draggedAlbumId)===t.album.id}),u=e.computed(()=>{var y;return((y=t.dragState)==null?void 0:y.dropTargetId)===t.album.id}),p=e.computed(()=>{var y;return(y=t.dragState)!=null&&y.draggedAlbumId?t.dragState.draggedAlbumId===t.album.id:!1}),m=e.computed(()=>{const y=["album-node"];return i.value&&y.push("album-node--selected"),s.value&&y.push("album-node--focused"),t.compact&&y.push("album-node--compact"),d.value&&y.push("album-node--dragging"),u.value&&y.push("album-node--drop-target"),p.value&&y.push("album-node--invalid-drop"),y});function f(){a("select",t.album)}function v(y){y.stopPropagation(),a("toggle-expand",t.album.id)}function b(y){t.draggable&&(y.dataTransfer&&(y.dataTransfer.setData("text/plain",t.album.id),y.dataTransfer.effectAllowed="move"),a("drag-start",t.album.id))}function S(y){t.draggable&&(y.preventDefault(),y.dataTransfer&&(y.dataTransfer.dropEffect="move"),a("drag-over",t.album.id))}function M(){a("drag-leave",t.album.id)}function E(y){t.draggable&&(y.preventDefault(),a("drop",t.album.id))}return(y,h)=>{var R;const w=e.resolveComponent("AlbumTreeNode",!0);return e.openBlock(),e.createElementBlock("div",hE,[e.createElementVNode("div",{"data-testid":"album-node","data-album-id":y.album.id,class:e.normalizeClass(m.value),style:e.normalizeStyle({paddingLeft:c.value}),draggable:y.draggable,role:"treeitem","aria-selected":i.value,"aria-expanded":l.value?r.value:void 0,onDragstart:b,onDragover:S,onDragleave:M,onDrop:E},[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:r.value?e.unref(nm):e.unref(om)},null,8,["icon"])])):(e.openBlock(),e.createElementBlock("span",gE)),e.createVNode(e.unref(B.IonIcon),{icon:e.unref(um),class:"album-node__icon"},null,8,["icon"]),e.createElementVNode("span",{"data-testid":"album-name",class:"album-node__name",onClick:f},e.toDisplayString(y.album.name),1),y.showMediaCount?(e.openBlock(),e.createElementBlock("span",yE,e.toDisplayString(y.album.media_count),1)):e.createCommentVNode("",!0)],46,vE),r.value&&((R=y.album.children)!=null&&R.length)?(e.openBlock(),e.createElementBlock("div",bE,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.album.children,N=>(e.openBlock(),e.createBlock(w,{key:N.id,album:N,depth:y.depth+1,"selected-id":y.selectedId,"expanded-ids":y.expandedIds,"focused-id":y.focusedId,draggable:y.draggable,"show-media-count":y.showMediaCount,compact:y.compact,onSelect:h[0]||(h[0]=g=>a("select",g)),onToggleExpand:h[1]||(h[1]=g=>a("toggle-expand",g))},null,8,["album","depth","selected-id","expanded-ids","focused-id","draggable","show-media-count","compact"]))),128))])):e.createCommentVNode("",!0)])}}}),xE=_e(kE,[["__scopeId","data-v-76be65a6"]]),qa=Ca.defineStore("albums",()=>{const n=e.ref([]),o=e.ref(new Map),t=e.ref(!1),a=e.ref(null),r=e.ref(new Set),i=e.computed(()=>{const h=new Map;return n.value.forEach(w=>h.set(w.id,w)),h}),s=e.computed(()=>n.value.filter(h=>h.parent_id===null));async function l(h){t.value=!0,a.value=null;try{const w=(h==null?void 0:h.parent_id)??null,R=w?`/api/v1/albums?parent_id=${w}`:"/api/v1/albums?parent_id=null",N=await fetch(R);if(!N.ok)throw new Error("Failed to fetch albums");((await N.json()).data||[]).forEach(A=>{const x=n.value.findIndex(T=>T.id===A.id);x>=0?n.value[x]=A:n.value.push(A)}),w!==null&&r.value.add(w)}catch(w){a.value=w instanceof Error?w.message:"Unknown error"}finally{t.value=!1}}async function c(h){t.value=!0,a.value=null;try{const w=await fetch(`/api/v1/albums/${h}`);if(!w.ok)throw new Error("Failed to fetch album");const N=(await w.json()).data,g=n.value.findIndex(C=>C.id===N.id);return g>=0?n.value[g]=N:n.value.push(N),N}catch(w){throw a.value=w instanceof Error?w.message:"Unknown error",w}finally{t.value=!1}}async function d(h){t.value=!0,a.value=null;try{const w=await fetch(`/api/v1/albums/${h}/media`);if(!w.ok)throw new Error("Failed to fetch album media");const N=(await w.json()).data||[];return o.value.set(h,N),N}catch(w){throw a.value=w instanceof Error?w.message:"Unknown error",w}finally{t.value=!1}}async function u(h,w){t.value=!0,a.value=null;try{if(!(await fetch(`/api/v1/albums/${h}/media/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({media_ids:w})})).ok)throw new Error("Failed to reorder album media");const N=o.value.get(h)||[],g=w.map(C=>N.find(A=>A.uuid===C)).filter(C=>C!==void 0);o.value.set(h,g)}catch(R){throw a.value=R instanceof Error?R.message:"Unknown error",R}finally{t.value=!1}}async function p(h){t.value=!0,a.value=null;try{const w=await fetch("/api/v1/albums",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(h)});if(!w.ok)throw new Error("Failed to create album");const N=(await w.json()).data;return n.value.push(N),N}catch(w){throw a.value=w instanceof Error?w.message:"Unknown error",w}finally{t.value=!1}}async function m(h,w){t.value=!0,a.value=null;try{const R=await fetch(`/api/v1/albums/${h}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(w)});if(!R.ok)throw new Error("Failed to update album");const g=(await R.json()).data,C=n.value.findIndex(A=>A.id===g.id);return C>=0&&(n.value[C]=g),g}catch(R){throw a.value=R instanceof Error?R.message:"Unknown error",R}finally{t.value=!1}}async function f(h){t.value=!0,a.value=null;try{if(!(await fetch(`/api/v1/albums/${h}`,{method:"DELETE",headers:{"Content-Type":"application/json"},credentials:"include"})).ok)throw new Error("Failed to delete album");const R=n.value.findIndex(N=>N.id===h);R>=0&&n.value.splice(R,1),o.value.delete(h)}catch(w){throw a.value=w instanceof Error?w.message:"Unknown error",w}finally{t.value=!1}}function v(h){return n.value.filter(w=>w.parent_id===h)}function b(h){return r.value.has(h)}function S(h){return o.value.get(h)||[]}async function M(h,w){const R=n.value.findIndex(g=>g.id===h);if(R<0)return;const N=n.value[R];n.value[R]={...N,parent_id:w};try{if(!(await fetch(`/api/v1/albums/${h}/move`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({parent_id:w})})).ok)throw new Error("Failed to move album")}catch(g){throw n.value[R]=N,a.value=g instanceof Error?g.message:"Unknown error",g instanceof Error?g:new Error("Failed to move album")}}function E(h){n.value=h}function y(){n.value=[],o.value.clear(),t.value=!1,a.value=null,r.value.clear()}return{albums:n,albumMedia:o,loading:t,error:a,childrenLoadedById:r,albumsById:i,rootAlbums:s,fetchAlbums:l,fetchAlbum:c,fetchAlbumMedia:d,reorderAlbumMedia:u,createAlbum:p,updateAlbum:m,deleteAlbum:f,getChildrenOf:v,childrenLoaded:b,getAlbumMedia:S,moveAlbum:M,setAlbums:E,reset:y}});function jc(){const n=qa(),{albums:o,albumsById:t,rootAlbums:a,loading:r,error:i}=Ca.storeToRefs(n);async function s(u){await n.fetchAlbums(u)}function l(u){return n.getChildrenOf(u)}function c(u){return n.childrenLoaded(u)}async function d(u,p){await n.moveAlbum(u,p)}return{albums:o,albumsById:t,rootAlbums:a,loading:r,error:i,fetchAlbums:s,getChildrenOf:l,childrenLoaded:c,moveAlbum:d}}function Xc(n){const{childrenByParentId:o,onMove:t}=n,a=e.ref({isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null});function r(p,m){if(p===m)return!0;const f=new Set,v=[p];for(;v.length>0;){const b=v.shift();if(!b||f.has(b))continue;f.add(b);const S=o.get(b)||[];for(const M of S){if(M===m)return!0;v.push(M)}}return!1}function i(p,m){return p===m?!1:m===null?!0:!r(p,m)}function s(p){a.value={isDragging:!0,draggedAlbumId:p,dropTargetId:null,dropPosition:null}}function l(){a.value={isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null}}function c(p){a.value.dropTargetId=p}function d(){a.value.dropTargetId=null,a.value.dropPosition=null}async function u(){const{draggedAlbumId:p,dropTargetId:m}=a.value;if(!p){l();return}if(!i(p,m)){l();return}try{await t(p,m)}finally{l()}}return{dragState:a,isDescendant:r,canDropOn:i,startDrag:s,endDrag:l,setDropTarget:c,clearDropTarget:d,executeDrop:u}}const SE={key:0,"data-testid":"loading-spinner",class:"album-tree__loading"},EE={key:1,"data-testid":"error-state",class:"album-tree__error"},VE={key:2,"data-testid":"empty-state",class:"album-tree__empty"},CE={key:3,class:"album-tree__content",role:"group"},NE=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(n,{expose:o,emit:t}){const a=n,r=t,i=e.computed(()=>a.draggable===!0),s=e.computed(()=>a.showMediaCount===!0),l=e.computed(()=>a.compact===!0),{albums:c,rootAlbums:d,loading:u,error:p,fetchAlbums:m,getChildrenOf:f,childrenLoaded:v,moveAlbum:b}=jc(),S=e.shallowRef(new Set(a.expandedIds)),M=e.ref(a.modelValue??null),E=e.ref(null),y=new Map,h=new Map;function w(F){y.clear(),h.clear();for(const O of F){y.set(O.id,O);const de=O.parent_id??null,re=h.get(de)??[];re.push(O.id),h.set(de,re)}}e.watch(c,F=>{w(F)},{immediate:!0});const{dragState:R,canDropOn:N,startDrag:g,endDrag:C,setDropTarget:A,clearDropTarget:x,executeDrop:T}=Xc({childrenByParentId:h,onMove:async(F,O)=>{await b(F,O),r("album-moved",{albumId:F,newParentId:O})}});e.watch(()=>a.modelValue,F=>{M.value=F??null}),e.watch(()=>a.expandedIds,F=>{S.value=new Set(F)}),e.onMounted(async()=>{await m({parent_id:null})});const I=e.computed(()=>d.value.map(F=>z(F)));function z(F){if(!S.value.has(F.id))return F;const O=f(F.id);return{...F,children:O.map(de=>z(de))}}const P=e.computed(()=>{const F=[];function O(de){var re;for(const q of de)F.push(q),S.value.has(q.id)&&((re=q.children)!=null&&re.length)&&O(q.children)}return O(I.value),F});function j(F){var re;if(!P.value.length)return;const O=E.value?P.value.findIndex(q=>q.id===E.value):-1,de=O>=0?P.value[O]:null;switch(F.key){case"ArrowDown":F.preventDefault(),O<P.value.length-1?E.value=P.value[O+1].id:O===-1&&P.value.length>0&&(E.value=P.value[0].id);break;case"ArrowUp":F.preventDefault(),O>0&&(E.value=P.value[O-1].id);break;case"ArrowRight":F.preventDefault(),de&&(de.children_count>0&&!S.value.has(de.id)?L(de.id):S.value.has(de.id)&&((re=de.children)!=null&&re.length)&&(E.value=de.children[0].id));break;case"ArrowLeft":F.preventDefault(),de&&(S.value.has(de.id)&&de.children_count>0?L(de.id):de.parent_id&&(E.value=de.parent_id));break;case"Enter":case" ":F.preventDefault(),de&&_(de);break;case"Home":F.preventDefault(),P.value.length>0&&(E.value=P.value[0].id);break;case"End":F.preventDefault(),P.value.length>0&&(E.value=P.value[P.value.length-1].id);break}}async function L(F){S.value.has(F)?(S.value.delete(F),r("album-collapsed",F)):(v(F)||await m({parent_id:F}),S.value.add(F),r("album-expanded",F))}function _(F){M.value=F.id,r("update:modelValue",F.id),r("album-selected",F)}function D(F){a.draggable&&g(F)}function G(F){var de;if(!a.draggable)return;const O=(de=R.value)==null?void 0:de.draggedAlbumId;O&&(A(F),N(O,F))}function X(){a.draggable&&x()}async function ce(F){a.draggable&&(A(F),await T())}function Me(F){a.draggable&&(F.preventDefault(),A(null))}async function $e(F){a.draggable&&(F.preventDefault(),A(null),await T())}function ae(){C()}return o({focusedId:E}),(F,O)=>(e.openBlock(),e.createElementBlock("div",{class:"album-tree","data-testid":"album-tree",tabindex:"0",role:"tree","aria-label":"Album tree",onKeydown:j,onDragover:Me,onDrop:$e,onDragend:ae},[e.unref(u)?(e.openBlock(),e.createElementBlock("div",SE,[e.createVNode(e.unref(B.IonSpinner),{name:"crescent"})])):e.unref(p)?(e.openBlock(),e.createElementBlock("div",EE,[e.createElementVNode("p",null,e.toDisplayString(e.unref(p)),1)])):e.unref(d).length?(e.openBlock(),e.createElementBlock("div",CE,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(I.value,de=>(e.openBlock(),e.createBlock(xE,{key:de.id,album:de,depth:0,"selected-id":M.value,"expanded-ids":S.value,"focused-id":E.value,draggable:i.value,"drag-state":i.value?e.unref(R):null,"show-media-count":s.value,compact:l.value,onSelect:_,onToggleExpand:L,onDragStart:D,onDragOver:G,onDragLeave:X,onDrop:ce},null,8,["album","selected-id","expanded-ids","focused-id","draggable","drag-state","show-media-count","compact"]))),128))])):(e.openBlock(),e.createElementBlock("div",VE,[O[0]||(O[0]=e.createElementVNode("p",null,"No albums yet",-1)),e.renderSlot(F.$slots,"empty-action",{},void 0,!0)]))],32))}}),Zc=_e(NE,[["__scopeId","data-v-ae3dea7a"]]),_E=300,TE=e.defineComponent({__name:"AlbumBrowser",props:{isOpen:{type:Boolean},selectedAlbumId:{default:null},title:{default:"Select Album"},confirmText:{default:"Select"}},emits:["close","confirm"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(t.selectedAlbumId??null),i=e.ref(null),s=e.ref(0),l=e.ref(null);e.watch(()=>t.selectedAlbumId,f=>{r.value=f??null});const c=e.computed(()=>i.value!==null);function d(f){const v=Date.now();if(l.value===f.id&&v-s.value<_E){a("confirm",f);return}s.value=v,l.value=f.id,r.value=f.id,i.value=f}function u(){i.value&&a("confirm",i.value)}function p(){a("close")}function m(){a("close")}return(f,v)=>(e.openBlock(),e.createBlock(e.unref(B.IonModal),{"is-open":f.isOpen,class:"album-browser-modal",onDidDismiss:m},{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(f.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:p},{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(Zc,{modelValue:r.value,"onUpdate:modelValue":v[0]||(v[0]=b=>r.value=b),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:p},{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(f.confirmText),1)]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"]))}}),Yc=_e(TE,[["__scopeId","data-v-21676ec1"]]),ME={class:"ion-padding-start text-sm"},FE={class:"ion-padding-start text-sm"},IE={key:1},BE={key:1,class:"album-manager-inline rounded-lg border border-gray-200 bg-white p-4"},RE={class:"flex items-center justify-between gap-3 pb-3"},PE={class:"text-base font-semibold text-gray-900"},$E={class:"ion-padding-start text-sm"},zE={class:"ion-padding-start text-sm"},AE={class:"flex justify-between pt-2"},DE={key:1},no=255,oo=1e3,UE=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(n,{emit:o}){const t=n,a=o,r=qa(),i=e.computed(()=>t.albumId!==null&&t.albumId!==void 0),s=e.computed(()=>i.value?"Edit Album":"Create Album"),l=e.computed(()=>i.value?"Save":"Create"),c=e.ref({name:"",description:"",parent_id:t.parentId}),d=e.ref({name:!1,description:!1}),u=e.ref(null),p=e.ref(!1),m=e.ref(null),f=e.ref(!1),v=e.ref(!1),b=e.computed(()=>d.value.name?c.value.name.trim()?c.value.name.length>no?`Name must be ${no} characters or less`:null:"Name is required":null),S=e.computed(()=>d.value.description&&c.value.description.length>oo?`Description must be ${oo} characters or less`:null),M=e.computed(()=>{const j=c.value.name.trim().length>0,L=c.value.name.length<=no,_=c.value.description.length<=oo;return j&&L&&_&&!f.value}),E=e.computed(()=>{var j;return((j=u.value)==null?void 0:j.name)??"None (Root)"}),y=e.computed(()=>m.value?m.value.children_count===0&&m.value.media_count===0:!1),h=e.computed(()=>m.value?m.value.children_count>0?"Cannot delete album with child albums. Move or delete children first.":m.value.media_count>0?"Cannot delete album with media. Remove media first.":`Are you sure you want to delete "${m.value.name}"? This action cannot be undone.`:"");e.onMounted(async()=>{t.albumId&&await w()});async function w(){if(t.albumId)try{const j=await r.fetchAlbum(t.albumId);m.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){a("error",j)}}function R(){d.value.name=!0}function N(){d.value.description=!0}function g(){p.value=!0}function C(j){u.value={id:j.id,name:j.name},c.value.parent_id=j.id,p.value=!1}function A(){p.value=!1}function x(){a("close")}function T(){a("close")}async function I(){if(d.value.name=!0,d.value.description=!0,!(!M.value||f.value)){f.value=!0;try{const j={name:c.value.name.trim(),description:c.value.description.trim(),parent_id:c.value.parent_id};if(i.value&&t.albumId){const L=await r.updateAlbum(t.albumId,j);a("updated",L)}else{const L=await r.createAlbum(j);a("created",L)}a("close")}catch(j){a("error",j)}finally{f.value=!1}}}function z(){y.value&&(v.value=!0)}async function P(j){var _;if((((_=j.detail)==null?void 0:_.role)??"")!=="confirm"){v.value=!1;return}if(t.albumId){f.value=!0;try{await r.deleteAlbum(t.albumId),a("deleted",t.albumId),a("close")}catch(D){a("error",D)}finally{f.value=!1,v.value=!1}}}return(j,L)=>(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:x},{default:e.withCtx(()=>[...L[4]||(L[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(I,["prevent"])},[e.createVNode(e.unref(B.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...L[5]||(L[5]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(B.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":L[0]||(L[0]=_=>c.value.name=_),"data-testid":"name-input",maxlength:no,onIonBlur:R},null,8,["modelValue"])]),_:1}),b.value?(e.openBlock(),e.createBlock(e.unref(B.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",ME,e.toDisplayString(b.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(()=>[...L[6]||(L[6]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(B.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":L[1]||(L[1]=_=>c.value.description=_),"data-testid":"description-input",maxlength:oo,onIonBlur:N},null,8,["modelValue"])]),_:1}),S.value?(e.openBlock(),e.createBlock(e.unref(B.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",FE,e.toDisplayString(S.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(()=>[...L[7]||(L[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(E.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(()=>[i.value?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",disabled:!y.value,title:y.value?void 0:h.value,onClick:z},{default:e.withCtx(()=>[...L[8]||(L[8]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.unref(B.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!M.value,onClick:I},{default:e.withCtx(()=>[f.value?(e.openBlock(),e.createBlock(e.unref(B.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",IE,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"])):(e.openBlock(),e.createElementBlock("div",BE,[e.createElementVNode("div",RE,[e.createElementVNode("h2",PE,e.toDisplayString(s.value),1),e.createVNode(e.unref(B.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:x},{default:e.withCtx(()=>[...L[9]||(L[9]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),e.createElementVNode("form",{"data-testid":"album-form",class:"space-y-3",onSubmit:e.withModifiers(I,["prevent"])},[e.createVNode(e.unref(B.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...L[10]||(L[10]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(B.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":L[2]||(L[2]=_=>c.value.name=_),"data-testid":"name-input",maxlength:no,onIonBlur:R},null,8,["modelValue"])]),_:1}),b.value?(e.openBlock(),e.createBlock(e.unref(B.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",$E,e.toDisplayString(b.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(()=>[...L[11]||(L[11]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(B.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":L[3]||(L[3]=_=>c.value.description=_),"data-testid":"description-input",maxlength:oo,onIonBlur:N},null,8,["modelValue"])]),_:1}),S.value?(e.openBlock(),e.createBlock(e.unref(B.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",zE,e.toDisplayString(S.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(()=>[...L[12]||(L[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(E.value),1)]),_:1})]),_:1}),e.createElementVNode("div",AE,[e.createElementVNode("div",null,[i.value?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",fill:"outline",disabled:!y.value,title:y.value?void 0:h.value,onClick:z},{default:e.withCtx(()=>[...L[13]||(L[13]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(B.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!M.value,onClick:I},{default:e.withCtx(()=>[f.value?(e.openBlock(),e.createBlock(e.unref(B.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",DE,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])])],32)])),e.createVNode(Yc,{"is-open":p.value,"selected-album-id":c.value.parent_id,title:"Select Parent Album",onClose:A,onConfirm:C},null,8,["is-open","selected-album-id"]),e.createVNode(e.unref(B.IonAlert),{"is-open":v.value,header:"Delete Album?",message:h.value,buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"confirm",cssClass:"alert-button-danger"}],onDidDismiss:P},null,8,["is-open","message"])],64))}}),OE=_e(UE,[["__scopeId","data-v-22083f3a"]]),LE={class:"album-media-grid"},WE={class:"aspect-square"},jE={key:1,"data-testid":"empty-state",class:"flex flex-col items-center justify-center py-12 gap-4"},XE={class:"text-gray-500"},ZE=["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"},GE={key:1,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"},HE={class:"aspect-square relative"},JE=["src","alt"],qE={key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center gap-2 transition-opacity"},KE=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(n,{emit:o}){const t=n,a=o,r=qa(),i=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),p=e.computed(()=>!u.value&&i.value.length===0),m=e.computed(()=>{const T=t.columns;return["grid","gap-4",`grid-cols-${T.mobile??2}`,`sm:grid-cols-${T.sm??3}`,`md:grid-cols-${T.md??4}`,`lg:grid-cols-${T.lg??5}`,`xl:grid-cols-${T.xl??6}`]}),f=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 r.fetchAlbumMedia(t.albumId);i.value=T}catch{i.value=[]}finally{s.value=!1}}function b(T){return t.selectedItems.includes(T)}function S(T){a("toggle-select",T);const I=b(T.uuid)?t.selectedItems.filter(z=>z!==T.uuid):[...t.selectedItems,T.uuid];a("selection-change",I)}function M(T){if(T.conversions&&typeof T.conversions=="object"){const I=T.conversions.thumb;if(typeof I=="string")return I}return T.original_url}function E(T){l.value=T}function y(){l.value=null}function h(T){a("preview",T)}function w(T){a("edit",T)}function R(T){a("detach",T.uuid)}function N(){a("add")}function g(T,I){t.reorderable&&(c.value=I,T.dataTransfer&&(T.dataTransfer.effectAllowed="move",T.dataTransfer.setData("text/plain",String(I))))}function C(T,I){!t.reorderable||c.value===null||(T.preventDefault(),d.value=I)}function A(T,I){if(!t.reorderable||c.value===null)return;T.preventDefault();const z=c.value;if(z!==I){const P=[...i.value],[j]=P.splice(z,1);P.splice(I,0,j),i.value=P;const L=P.map(_=>_.uuid);a("reorder",L),r.reorderAlbumMedia(t.albumId,L).catch(()=>{v()})}c.value=null,d.value=null}function x(){c.value=null,d.value=null}return(T,I)=>(e.openBlock(),e.createElementBlock("div",LE,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,"data-testid":"loading-grid",class:e.normalizeClass(m.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,z=>(e.openBlock(),e.createBlock(e.unref(B.IonCard),{key:z,class:"m-0"},{default:e.withCtx(()=>[e.createElementVNode("div",WE,[e.createVNode(e.unref(B.IonSkeletonText),{animated:"",class:"w-full h-full skeleton"})])]),_:1}))),128))],2)):p.value?(e.openBlock(),e.createElementBlock("div",jE,[e.createVNode(e.unref(B.IonIcon),{name:"images-outline",class:"text-6xl text-gray-400"}),e.createElementVNode("p",XE,e.toDisplayString(T.emptyText),1),e.createVNode(e.unref(B.IonButton),{"data-testid":"add-media-btn",onClick:N},{default:e.withCtx(()=>[...I[0]||(I[0]=[e.createTextVNode(" Add Media ",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("div",{key:2,"data-testid":"media-grid",class:e.normalizeClass(m.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(z,P)=>(e.openBlock(),e.createElementBlock("div",{key:z.uuid,"data-media-id":z.uuid,class:e.normalizeClass(["media-item relative group",{"opacity-50":c.value===P,"ring-2 ring-primary":d.value===P&&c.value!==P}]),draggable:T.reorderable,onDragstart:j=>g(j,P),onDragover:j=>C(j,P),onDrop:j=>A(j,P),onDragend:x,onMouseenter:j=>E(z.uuid),onMouseleave:y},[d.value===P&&c.value!==P&&T.reorderable?(e.openBlock(),e.createElementBlock("div",YE)):e.createCommentVNode("",!0),T.reorderable?(e.openBlock(),e.createElementBlock("div",GE,[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:b(z.uuid),class:"absolute top-2 left-2 z-20",onIonChange:j=>S(z)},null,8,["checked","onIonChange"])):e.createCommentVNode("",!0),e.createVNode(e.unref(B.IonCard),{class:"m-0 overflow-hidden"},{default:e.withCtx(()=>[e.createElementVNode("div",HE,[e.createElementVNode("img",{src:M(z),alt:z.file_name,class:"w-full h-full object-cover"},null,8,JE),T.showActions&&l.value===z.uuid?(e.openBlock(),e.createElementBlock("div",qE,[e.createVNode(e.unref(B.IonButton),{"data-testid":"action-preview",fill:"clear",size:"small",color:"light",onClick:j=>h(z)},{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=>w(z)},{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=>R(z)},{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,ZE))),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"}),I[1]||(I[1]=e.createElementVNode("span",{class:"text-sm text-gray-500"},"Add Media",-1))])],2))]))}}),QE=_e(KE,[["__scopeId","data-v-d84b796a"]]);function yi(n){return n.filter(o=>o.media&&!o.markedForRemoval).map((o,t)=>{const a={uuid:o.media.uuid,name:o.name,order:t};return o.customProperties&&(a.custom_properties=o.customProperties),a})}function Gr(n){return n.map((o,t)=>{const a={media:o,clientId:o.uuid,name:o.name||o.file_name,order:t};return o.custom_properties&&(a.customProperties=o.custom_properties),a})}function bi(n){if(n){const t={};n.apiBaseUrl!==void 0&&(t.apiBaseUrl=n.apiBaseUrl),n.isAdmin!==void 0&&(t.isAdmin=n.isAdmin),Dn(t)}return{name:"mediables",async upload(t,a){const i=await wt().uploadFile(t,{collection:(a==null?void 0:a.collection)||"default",customProperties:a==null?void 0:a.customProperties});if(!i)throw new Error("Upload failed: No media returned");return{media:i,uuid:i.uuid}},async attach(t,a){await wt().attachMedia(a.modelType,String(a.modelId),[t],a.collection||"images")},async attachMany(t,a){await wt().attachMedia(a.modelType,String(a.modelId),t,a.collection||"images")},async detach(t,a){await wt().detachMedia(a.modelType,String(a.modelId),t,a.collection||"images")},async reorder(t,a){await wt().reorderMedia(t.modelType,String(t.modelId),a,t.collection||"images")},async fetchModelMedia(t){return await wt().fetchModelMedia(t.modelType,String(t.modelId),t.collection||"images")},getUrl(t,a){return wt().getMediaUrl(t,a)},getThumbnailUrl(t){var a,r;return(a=t.conversion_urls)!=null&&a.thumb?t.conversion_urls.thumb:(r=t.conversion_urls)!=null&&r.thumbnail?t.conversion_urls.thumbnail:t.thumbnail_url?t.thumbnail_url:t.original_url||t.url||""},async delete(t){await wt().deleteMedia(t)},async update(t,a){const i=await wt().updateMedia(t,a);if(!i)throw new Error("Update failed: No media returned");return i},configure(t){const a={};t.apiBaseUrl!==void 0&&(a.apiBaseUrl=t.apiBaseUrl),t.isAdmin!==void 0&&(a.isAdmin=t.isAdmin),Dn(a)}}}let ma=null;function e4(){return ma||(ma=bi()),ma}function t4(){ma=null}const n4={apiBaseUrl:"/media-library-pro"};function ta(){var n;return typeof document>"u"?null:((n=document.querySelector('meta[name="csrf-token"]'))==null?void 0:n.getAttribute("content"))||null}function Cr(n){const o={uuid:n.uuid,file_name:n.fileName||n.name,mime_type:`application/${n.extension}`,size:n.size,disk:"public",original_url:n.original_url||"",created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return n.name&&(o.name=n.name),n.original_url&&(o.url=n.original_url),n.preview_url&&(o.thumbnail_url=n.preview_url,o.preview_url=n.preview_url),n.custom_properties&&(o.custom_properties=n.custom_properties),o}function wi(n){const o={...n4,...n};return{name:"spatie",async upload(a,r){const i=new FormData;i.append("file",a),r!=null&&r.collection&&i.append("collection",r.collection),r!=null&&r.customProperties&&i.append("custom_properties",JSON.stringify(r.customProperties));const s={Accept:"application/json",...o.headers},l=o.csrfToken||ta();l&&(s["X-CSRF-TOKEN"]=l);const c={method:"POST",headers:s,body:i,credentials:"include"};r!=null&&r.signal&&(c.signal=r.signal);const d=await fetch(`${o.apiBaseUrl}/uploads`,c);if(!d.ok){const m=await d.json().catch(()=>({message:"Upload failed"}));throw new Error(m.message||`HTTP ${d.status}`)}const u=await d.json(),p=Cr(u);return r!=null&&r.onProgress&&r.onProgress(100),{media:p,uuid:u.uuid}},async attach(a,r){},async attachMany(a,r){},async detach(a,r){},async reorder(a,r){},async fetchModelMedia(a){const r={Accept:"application/json",...o.headers},i=o.csrfToken||ta();i&&(r["X-CSRF-TOKEN"]=i);const s=new URLSearchParams;s.append("model_type",a.modelType),s.append("model_id",String(a.modelId)),a.collection&&s.append("collection",a.collection);try{const l=await fetch(`${o.apiBaseUrl}/media?${s}`,{method:"GET",headers:r,credentials:"include"});if(!l.ok)throw new Error(`HTTP ${l.status}`);return(await l.json()).map(Cr)}catch{return[]}},getUrl(a,r){var i;if(r){const s=(i=a.conversion_urls)==null?void 0:i[r];if(s)return s}return a.original_url||a.url||""},getThumbnailUrl(a){var r,i;return a.preview_url?a.preview_url:(r=a.conversion_urls)!=null&&r.preview?a.conversion_urls.preview:a.thumbnail_url?a.thumbnail_url:(i=a.conversion_urls)!=null&&i.thumb?a.conversion_urls.thumb:a.original_url||a.url||""},async delete(a){const r={Accept:"application/json",...o.headers},i=o.csrfToken||ta();i&&(r["X-CSRF-TOKEN"]=i);const s=await fetch(`${o.apiBaseUrl}/uploads/${a}`,{method:"DELETE",headers:r,credentials:"include"});if(!s.ok){const l=await s.json().catch(()=>({message:"Delete failed"}));throw new Error(l.message||`HTTP ${s.status}`)}},async update(a,r){const i={Accept:"application/json","Content-Type":"application/json",...o.headers},s=o.csrfToken||ta();s&&(i["X-CSRF-TOKEN"]=s);const l=await fetch(`${o.apiBaseUrl}/uploads/${a}`,{method:"PATCH",headers:i,body:JSON.stringify(r),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 Cr(c)},configure(a){Object.assign(o,a)}}}let pa=null;function o4(){return pa||(pa=wi()),pa}function a4(){pa=null}function Gc(n,o){switch(n){case"mediables":return bi(o);case"spatie":return wi(o);default:throw new Error(`Unknown adapter: ${n}`)}}function Va(n){if(n===0)return"0 Bytes";const o=1024,t=["Bytes","KB","MB","GB"],a=Math.floor(Math.log(n)/Math.log(o));return parseFloat((n/Math.pow(o,a)).toFixed(2))+" "+t[a]}function Hc(n){var t;const o=n.split(".");return o.length>1?`.${(t=o.pop())==null?void 0:t.toLowerCase()}`:""}function ki(n){return n.type.startsWith("image/")}async function Jc(n){return ki(n)?new Promise(o=>{const t=new Image,a=URL.createObjectURL(n);t.onload=()=>{URL.revokeObjectURL(a),o({width:t.naturalWidth,height:t.naturalHeight})},t.onerror=()=>{URL.revokeObjectURL(a),o(null)},t.src=a}):null}async function qc(n,o){const t=[];if(o.maxFileSize&&n.size>o.maxFileSize&&t.push({field:"size",message:`File exceeds maximum size of ${Va(o.maxFileSize)}`,code:"MAX_FILE_SIZE"}),o.minFileSize&&n.size<o.minFileSize&&t.push({field:"size",message:`File is smaller than minimum size of ${Va(o.minFileSize)}`,code:"MIN_FILE_SIZE"}),o.acceptedMimeTypes&&o.acceptedMimeTypes.length>0&&(o.acceptedMimeTypes.some(r=>r.endsWith("/*")?n.type.startsWith(r.slice(0,-1)):n.type===r)||t.push({field:"type",message:`File type "${n.type}" is not allowed`,code:"INVALID_MIME_TYPE"})),o.acceptedExtensions&&o.acceptedExtensions.length>0){const a=Hc(n.name);o.acceptedExtensions.some(i=>i.toLowerCase()===a.toLowerCase())||t.push({field:"extension",message:`File extension "${a}" is not allowed`,code:"INVALID_EXTENSION"})}if(ki(n)&&(o.maxDimensions||o.minDimensions)){const a=await Jc(n);a&&(o.maxDimensions&&(a.width>o.maxDimensions.width&&t.push({field:"dimensions",message:`Image width (${a.width}px) exceeds maximum (${o.maxDimensions.width}px)`,code:"MAX_WIDTH"}),a.height>o.maxDimensions.height&&t.push({field:"dimensions",message:`Image height (${a.height}px) exceeds maximum (${o.maxDimensions.height}px)`,code:"MAX_HEIGHT"})),o.minDimensions&&(a.width<o.minDimensions.width&&t.push({field:"dimensions",message:`Image width (${a.width}px) is smaller than minimum (${o.minDimensions.width}px)`,code:"MIN_WIDTH"}),a.height<o.minDimensions.height&&t.push({field:"dimensions",message:`Image height (${a.height}px) is smaller than minimum (${o.minDimensions.height}px)`,code:"MIN_HEIGHT"})))}if(o.customValidator){const a=await o.customValidator(n);t.push(...a)}return{valid:t.length===0,errors:t}}function xi(n={}){const o=e.ref(n.rules||{});function t(c){o.value=c}async function a(c){return qc(c,o.value)}async function r(c){const d=new Map;return await Promise.all(c.map(async u=>{const p=await a(u);d.set(u,p)})),d}function i(c,d){return o.value.maxItems?d+c<=o.value.maxItems:!0}const s=e.computed(()=>{const c=[];return o.value.acceptedMimeTypes&&c.push(...o.value.acceptedMimeTypes),o.value.acceptedExtensions&&c.push(...o.value.acceptedExtensions),c.join(",")});function l(c){return!o.value.acceptedMimeTypes||o.value.acceptedMimeTypes.length===0?!0:o.value.acceptedMimeTypes.some(d=>d.endsWith("/*")?c.startsWith(d.slice(0,-1)):c===d)}return{rules:o,setRules:t,validateFile:a,validateFiles:r,canAddFiles:i,acceptString:s,isMimeTypeAllowed:l}}function r4(){return`upload-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function i4(n){if(n.type.startsWith("image/"))return URL.createObjectURL(n)}function Kc(n){const{adapter:o,maxConcurrent:t=3,rules:a,collection:r,onUploadStart:i,onUploadProgress:s,onUploadComplete:l,onUploadError:c,onQueueComplete:d}=n,u=e.ref(new Map),p=e.ref(new Set),m=a?{rules:a}:{},{validateFile:f}=xi(m);async function v(){if(p.value.size>=t)return;const x=Array.from(u.value.entries()).find(([z,P])=>P.status==="pending"&&!p.value.has(z));if(!x){Array.from(u.value.values()).every(P=>P.status==="completed"||P.status==="error")&&u.value.size>0&&(d==null||d());return}const[T,I]=x;await b(T,I)}async function b(x,T){p.value.add(x),T.status="uploading",T.abortController=new AbortController,u.value.set(x,{...T}),i==null||i(T);try{const I={onProgress:P=>{T.progress=P,u.value.set(x,{...T}),s==null||s(T)},signal:T.abortController.signal};r&&(I.collection=r);const z=await o.upload(T.file,I);T.status="completed",T.progress=100,T.media=z.media,u.value.set(x,{...T}),l==null||l(T,z.media)}catch(I){I.name==="AbortError"?u.value.delete(x):(T.status="error",T.error=I.message,u.value.set(x,{...T}),c==null||c(T,I))}finally{p.value.delete(x),delete T.abortController,v()}}async function S(x){var z;const T=Array.from(x),I=[];for(const P of T){const j=await f(P),L=r4(),_=i4(P),D={id:L,file:P,progress:0,status:j.valid?"pending":"error"};!j.valid&&((z=j.errors[0])!=null&&z.message)&&(D.error=j.errors[0].message),_&&(D.previewUrl=_),u.value.set(L,D);const G={media:null,clientId:L,name:P.name,order:0,upload:D,errors:j.errors};I.push(G)}for(let P=0;P<t;P++)v();return I}function M(x){const T=u.value.get(x);T&&(T.abortController&&T.abortController.abort(),T.previewUrl&&URL.revokeObjectURL(T.previewUrl),u.value.delete(x),p.value.delete(x),v())}async function E(x){const T=u.value.get(x);!T||T.status!=="error"||(T.status="pending",T.progress=0,delete T.error,u.value.set(x,{...T}),v())}function y(){for(const[x,T]of u.value.entries())(T.status==="completed"||T.status==="error")&&(T.previewUrl&&URL.revokeObjectURL(T.previewUrl),u.value.delete(x))}function h(){for(const x of u.value.values())x.abortController&&x.abortController.abort(),x.previewUrl&&URL.revokeObjectURL(x.previewUrl);u.value.clear(),p.value.clear()}function w(x){return u.value.get(x)}const R=e.computed(()=>p.value.size>0),N=e.computed(()=>p.value.size),g=e.computed(()=>Array.from(u.value.values()).filter(x=>x.status==="pending").length),C=e.computed(()=>u.value.size===0?!0:Array.from(u.value.values()).every(x=>x.status==="completed"||x.status==="error")),A=e.computed(()=>Array.from(u.value.values()));return{uploads:u,isUploading:R,activeCount:N,pendingCount:g,isComplete:C,addFiles:S,cancelUpload:M,retryUpload:E,clearCompleted:y,clearAll:h,getUpload:w,uploadsArray:A}}function Qc(n={}){const{enabled:o=!0,onReorder:t,onDragStart:a,onDragEnd:r,draggingClass:i="is-dragging",dropTargetClass:s="is-drop-target"}=n,l=e.ref({isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null}),c=e.ref(!1);let d=null;function u(E,y,h){o&&("dataTransfer"in E&&E.dataTransfer&&(E.dataTransfer.effectAllowed="move",E.dataTransfer.setData("text/plain",String(h))),d=E.target,d&&d.classList.add(i),l.value={isDragging:!0,dragIndex:h,dropIndex:h,draggedItem:y},c.value=!0,a==null||a(y,h))}function p(E,y){var h;if(!(!o||!l.value.isDragging)&&(E.preventDefault(),l.value.dropIndex!==y)){const w=document.querySelector(`.${s}`);w==null||w.classList.remove(s);const R=(h=E.target)==null?void 0:h.closest("[data-index]");R==null||R.classList.add(s),l.value.dropIndex=y}}function m(){if(!l.value.isDragging)return;const{dragIndex:E,dropIndex:y,draggedItem:h}=l.value;d&&d.classList.remove(i);const w=document.querySelector(`.${s}`);w==null||w.classList.remove(s),E!==null&&y!==null&&E!==y&&h&&(t==null||t({fromIndex:E,toIndex:y,item:h})),v(),r==null||r()}function f(){d&&d.classList.remove(i);const E=document.querySelector(`.${s}`);E==null||E.classList.remove(s),v(),r==null||r()}function v(){l.value={isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null},c.value=!1,d=null}function b(E,y,h){const w=[...E],[R]=w.splice(y,1);return w.splice(h,0,R),w.map((N,g)=>({...N,order:g}))}function S(E,y){return{draggable:o,"data-index":y,onDragstart:h=>u(h,E,y),onDragover:h=>p(h,y),onDragend:()=>m(),onDrop:h=>{h.preventDefault(),m()}}}function M(E){E.key==="Escape"&&l.value.isDragging&&f()}return e.onMounted(()=>{document.addEventListener("keydown",M)}),e.onUnmounted(()=>{document.removeEventListener("keydown",M),f()}),{dragState:l,isDragging:c,startDrag:u,handleDragOver:p,endDrag:m,cancelDrag:f,reorderItems:b,getDragProps:S}}function Ka(n={}){const{initialItems:o=[],modelType:t,modelId:a,collection:r="images",maxItems:i,maxFileSize:s,acceptedMimeTypes:l,sortable:c=!0,disabled:d=!1,rules:u={},adapterType:p="mediables",adapter:m,maxConcurrentUploads:f=3,onChange:v,onUpload:b,onUploadComplete:S,onUploadError:M,onRemove:E,onReorder:y,onError:h,onReadyToSubmitChange:w}=n,R={maxItems:i,maxFileSize:s,acceptedMimeTypes:l,...u},N=m||Gc(p),g=e.ref([]),C=e.ref(!1),A=e.ref([]);function x(ne){if(ne.length===0)return[];const ke=ne[0];return"media"in ke&&"clientId"in ke?ne:Gr(ne)}g.value=x(o);const{acceptString:T,canAddFiles:I}=xi({rules:R}),z=Kc({adapter:N,maxConcurrent:f,rules:R,collection:r,onUploadStart:ne=>{b==null||b(ne)},onUploadComplete:(ne,ke)=>{const he=g.value.findIndex(qe=>qe.clientId===ne.id);he!==-1&&(g.value[he]={...g.value[he],media:ke,name:ke.name||ke.file_name,upload:{...ne,status:"completed"}}),S==null||S(ke)},onUploadError:(ne,ke)=>{const he=g.value.findIndex(qe=>qe.clientId===ne.id);he!==-1&&(g.value[he]={...g.value[he],upload:{...ne,status:"error",error:ke.message},errors:[{field:"upload",message:ke.message,code:"UPLOAD_ERROR"}]}),M==null||M({file:ne.file,message:ke.message})},onQueueComplete:()=>{v==null||v(g.value)}}),{dragState:P,getDragProps:j,reorderItems:L}=Qc({enabled:c&&!d,onReorder:ne=>{g.value=L(g.value,ne.fromIndex,ne.toIndex),y==null||y(g.value),v==null||v(g.value)}}),_=e.computed(()=>z.isUploading.value),D=e.computed(()=>!z.isUploading.value&&z.pendingCount.value===0),G=e.computed(()=>i?g.value.length>=i:!1),X=e.computed(()=>yi(g.value)),ce=e.computed(()=>g.value.length),Me=e.computed(()=>i?Math.max(0,i-g.value.length):1/0);e.watch(D,ne=>{w==null||w(ne)});function $e(ne){g.value=x(ne),v==null||v(g.value)}async function ae(ne){if(d)return;const ke=Array.from(ne);if(!I(ke.length,g.value.length)){const pt={field:"count",message:`Maximum ${i} files allowed`,code:"MAX_ITEMS"};A.value=[pt],h==null||h([pt]);return}const he=await z.addFiles(ke),qe=g.value.length,ct=he.map((pt,me)=>({...pt,order:qe+me}));g.value=[...g.value,...ct],v==null||v(g.value)}function F(ne){d||(ne.upload&&(ne.upload.status==="uploading"||ne.upload.status==="pending")&&z.cancelUpload(ne.clientId),g.value=g.value.filter(ke=>ke.clientId!==ne.clientId),g.value=g.value.map((ke,he)=>({...ke,order:he})),E==null||E(ne),v==null||v(g.value))}function O(ne){const ke=g.value.find(he=>he.clientId===ne);ke&&F(ke)}function de(){d||(z.clearAll(),g.value=[],v==null||v(g.value))}function re(ne,ke){d||!c||(g.value=L(g.value,ne,ke),y==null||y(g.value),v==null||v(g.value))}function q(ne,ke){if(d)return;const he=g.value.findIndex(qe=>qe.clientId===ne);he!==-1&&(g.value[he]={...g.value[he],...ke},v==null||v(g.value))}function ee(ne){z.cancelUpload(ne),O(ne)}async function ue(ne){await z.retryUpload(ne)}async function ge(){if(!t||!a)throw new Error("modelType and modelId are required for save()");const ne={modelType:t,modelId:a,collection:r},ke=g.value.filter(he=>he.media&&!he.markedForRemoval).map(he=>he.media.uuid);C.value=!0;try{await N.attachMany(ke,ne),await N.reorder(ne,ke)}finally{C.value=!1}}async function xe(){if(!t||!a)throw new Error("modelType and modelId are required for load()");const ne={modelType:t,modelId:a,collection:r};C.value=!0;try{const ke=await N.fetchModelMedia(ne);g.value=Gr(ke),v==null||v(g.value)}finally{C.value=!1}}return e.onMounted(()=>{t&&a&&o.length===0&&xe().catch(console.error)}),e.onUnmounted(()=>{z.clearAll()}),{items:g,setItems:$e,addFiles:ae,removeItem:F,removeItemById:O,clearAll:de,reorderItems:re,updateItem:q,cancelUpload:ee,retryUpload:ue,save:ge,load:xe,isLoading:C,isUploading:_,isReadyToSubmit:D,isAtMaxItems:G,errors:A,dragState:P,getDragProps:j,adapter:N,formValues:X,acceptString:T,count:ce,remainingSlots:Me}}const s4=["aria-disabled"],l4=["accept","multiple","disabled"],c4={class:"media-dropzone__content"},d4={class:"media-dropzone__title"},u4={class:"media-dropzone__subtitle"},m4=["disabled"],p4={key:0,class:"media-dropzone__helper"},f4=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(n,{emit:o}){const t=n,a=o,r=e.ref(!1),i=e.ref(null),s=e.computed(()=>({"media-dropzone":!0,"media-dropzone--drag-over":r.value,"media-dropzone--disabled":t.disabled})),l=e.computed(()=>{const b=[];return t.maxFileSize&&b.push(`Max size: ${Va(t.maxFileSize)}`),t.maxItems&&t.maxItems>1&&b.push(`Max files: ${t.maxItems}`),b.join(" • ")});function c(b){b.preventDefault(),!t.disabled&&(r.value=!0)}function d(b){b.preventDefault(),r.value=!1}function u(b){b.preventDefault()}function p(b){var M;if(b.preventDefault(),r.value=!1,t.disabled)return;const S=(M=b.dataTransfer)==null?void 0:M.files;S&&S.length>0&&a("files",S)}function m(){var b;t.disabled||(b=i.value)==null||b.click()}function f(b){const S=b.target,M=S.files;M&&M.length>0&&a("files",M),S.value=""}function v(b){(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),m())}return(b,S)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(s.value),role:"button",tabindex:"0","aria-disabled":b.disabled,"aria-label":"Upload files",onClick:m,onKeydown:v,onDragenter:c,onDragleave:d,onDragover:u,onDrop:p},[e.createElementVNode("input",{ref_key:"fileInput",ref:i,type:"file",accept:b.accept,multiple:b.multiple,disabled:b.disabled,class:"media-dropzone__input",onChange:f},null,40,l4),e.createElementVNode("div",c4,[e.renderSlot(b.$slots,"icon",{},()=>[S[0]||(S[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",d4,[e.renderSlot(b.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(b.title),1)],!0)]),e.createElementVNode("p",u4,[e.renderSlot(b.$slots,"subtitle",{},()=>[e.createTextVNode(e.toDisplayString(b.subtitle),1)],!0)]),e.createElementVNode("button",{type:"button",class:"media-dropzone__button",disabled:b.disabled,onClick:e.withModifiers(m,["stop"])},[e.renderSlot(b.$slots,"button",{},()=>[e.createTextVNode(e.toDisplayString(b.buttonText),1)],!0)],8,m4),l.value?(e.openBlock(),e.createElementBlock("p",p4,e.toDisplayString(l.value),1)):e.createCommentVNode("",!0)])],42,s4))}}),Si=_e(f4,[["__scopeId","data-v-b1366c1e"]]),h4=["data-index"],v4={key:0,class:"media-item__drag-handle","aria-label":"Drag to reorder",role:"button",tabindex:"0"},g4={class:"media-item__thumbnail"},y4=["src","alt"],b4={key:1,class:"media-item__file-icon"},w4={key:2,class:"media-item__progress-overlay"},k4={class:"media-item__progress-text"},x4={key:3,class:"media-item__processing-overlay"},S4={key:4,class:"media-item__error-overlay"},E4={class:"media-item__info"},V4=["title"],C4={key:0,class:"media-item__size"},N4={key:1,class:"media-item__error-message"},_4={class:"media-item__actions"},T4=["disabled"],M4=["disabled"],F4=["disabled"],I4=["disabled"],B4=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(n,{emit:o}){const t=n,a=o,r=e.ref(!1),i=e.computed(()=>{var y;return(y=t.item.upload)!=null&&y.previewUrl?t.item.upload.previewUrl:t.item.media?t.adapter.getThumbnailUrl(t.item.media):null}),s=e.computed(()=>{var y,h,w;return((y=t.item.upload)==null?void 0:y.status)==="uploading"||((h=t.item.upload)==null?void 0:h.status)==="pending"||((w=t.item.upload)==null?void 0:w.status)==="queued"}),l=e.computed(()=>{var y;return((y=t.item.upload)==null?void 0:y.status)==="processing"}),c=e.computed(()=>{var y;return((y=t.item.upload)==null?void 0:y.status)==="error"||t.item.errors&&t.item.errors.length>0}),d=e.computed(()=>{var y;return(y=t.item.upload)!=null&&y.error?t.item.upload.error:t.item.errors&&t.item.errors.length>0?t.item.errors[0].message:null}),u=e.computed(()=>{var y;return((y=t.item.upload)==null?void 0:y.progress)||0}),p=e.computed(()=>{var y;return t.item.name||((y=t.item.media)==null?void 0:y.file_name)||"Unknown file"}),m=e.computed(()=>{var N,g;const y=((N=t.item.media)==null?void 0:N.size)||((g=t.item.upload)==null?void 0:g.file.size);if(!y)return"";const h=1024,w=["Bytes","KB","MB","GB"],R=Math.floor(Math.log(y)/Math.log(h));return parseFloat((y/Math.pow(h,R)).toFixed(2))+" "+w[R]}),f=e.computed(()=>{var h,w;const y=((h=t.item.media)==null?void 0:h.mime_type)||((w=t.item.upload)==null?void 0:w.file.type);return y==null?void 0:y.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 b(){t.disabled||a("remove",t.item)}function S(){t.disabled||a("edit",t.item)}function M(){t.disabled||a("retry",t.item)}function E(){t.disabled||a("cancel",t.item)}return(y,h)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(v.value),"data-index":y.index,onMouseenter:h[0]||(h[0]=w=>r.value=!0),onMouseleave:h[1]||(h[1]=w=>r.value=!1)},[y.sortable&&!y.disabled?(e.openBlock(),e.createElementBlock("div",v4,[...h[2]||(h[2]=[e.createStaticVNode('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-v-ff81c9ec><circle cx="9" cy="5" r="1" data-v-ff81c9ec></circle><circle cx="9" cy="12" r="1" data-v-ff81c9ec></circle><circle cx="9" cy="19" r="1" data-v-ff81c9ec></circle><circle cx="15" cy="5" r="1" data-v-ff81c9ec></circle><circle cx="15" cy="12" r="1" data-v-ff81c9ec></circle><circle cx="15" cy="19" r="1" data-v-ff81c9ec></circle></svg>',1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",g4,[i.value&&f.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:i.value,alt:p.value,class:"media-item__image"},null,8,y4)):(e.openBlock(),e.createElementBlock("div",b4,[...h[3]||(h[3]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.createElementVNode("polyline",{points:"14 2 14 8 20 8"})],-1)])])),s.value?(e.openBlock(),e.createElementBlock("div",w4,[e.createElementVNode("div",{class:"media-item__progress-bar",style:e.normalizeStyle({width:`${u.value}%`})},null,4),e.createElementVNode("span",k4,e.toDisplayString(u.value)+"%",1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",x4,[...h[4]||(h[4]=[e.createElementVNode("div",{class:"media-item__spinner","aria-label":"Processing"},null,-1)])])):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",S4,[...h[5]||(h[5]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("circle",{cx:"12",cy:"12",r:"10"}),e.createElementVNode("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.createElementVNode("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})],-1)])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",E4,[e.createElementVNode("span",{class:"media-item__name",title:p.value},e.toDisplayString(p.value),9,V4),m.value?(e.openBlock(),e.createElementBlock("span",C4,e.toDisplayString(m.value),1)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("span",N4,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",_4,[s.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-item__action media-item__action--cancel",disabled:y.disabled,"aria-label":"Cancel upload",onClick:E},[...h[6]||(h[6]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])],8,T4)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"media-item__action media-item__action--retry",disabled:y.disabled,"aria-label":"Retry upload",onClick:M},[...h[7]||(h[7]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("polyline",{points:"23 4 23 10 17 10"}),e.createElementVNode("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})],-1)])],8,M4)):e.createCommentVNode("",!0),y.showEdit&&y.item.media&&!s.value?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"media-item__action media-item__action--edit",disabled:y.disabled,"aria-label":"Edit",onClick:S},[...h[8]||(h[8]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.createElementVNode("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})],-1)])],8,F4)):e.createCommentVNode("",!0),y.showRemove?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"media-item__action media-item__action--remove",disabled:y.disabled,"aria-label":"Remove",onClick:b},[...h[9]||(h[9]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("polyline",{points:"3 6 5 6 21 6"}),e.createElementVNode("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)])],8,I4)):e.createCommentVNode("",!0)])],42,h4))}}),Ei=_e(B4,[["__scopeId","data-v-ff81c9ec"]]),R4=["aria-label"],P4=["draggable","data-index","onDragstart","onDragover","onDragend","onDrop"],$4={key:0,class:"media-collection__footer"},z4={class:"media-collection__count"},A4={key:0},D4={key:0,class:"media-collection__uploading"},U4=["name","value"],O4=["name","value"],L4=["name","value"],W4=["name","value"],j4={key:3,class:"media-collection__errors",role:"alert","aria-live":"polite"},X4=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(n,{emit:o}){const t=n,a=o,r={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:_=>{a("update:modelValue",_),a("change",_)},onUpload:_=>{a("upload",_)},onUploadComplete:_=>{a("upload-complete",_)},onUploadError:_=>{a("upload-error",_)},onRemove:_=>{a("remove",_)},onReorder:_=>{a("reorder",_)},onError:_=>{a("validation-error",_)},onReadyToSubmitChange:_=>{a("is-ready-to-submit-change",_)}},{items:i,setItems:s,addFiles:l,removeItem:c,reorderItems:d,cancelUpload:u,retryUpload:p,isLoading:m,isUploading:f,isAtMaxItems:v,errors:b,dragState:S,getDragProps:M,adapter:E,formValues:y,acceptString:h,count:w,remainingSlots:R}=Ka(r);e.provide("mediaAdapter",E),e.provide("mediaCollection",{items:i,addFiles:l,removeItem:c,reorderItems:d}),e.watch(()=>t.modelValue,_=>{_!==i.value&&s(_)},{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":m.value,"media-collection--has-items":i.value.length>0,"media-collection--dragging":S.value.isDragging}));function C(_){l(_)}function A(_){c(_)}function x(_){p(_.clientId)}function T(_){u(_.clientId)}function I(_){}function z(_,D,G){if(!t.sortable||t.disabled)return;const X=M(D,G);X.onDragstart&&X.onDragstart(_)}function P(_,D){if(!t.sortable||t.disabled)return;_.preventDefault();const G=i.value[D],X=M(G,D);X.onDragover&&X.onDragover(_)}function j(_,D){const G=M(_,D);G.onDragend&&G.onDragend()}function L(_,D){_.preventDefault();const G=i.value[D],X=M(G,D);X.onDrop&&X.onDrop(_)}return(_,D)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(g.value)},[e.renderSlot(_.$slots,"dropzone",{addFiles:e.unref(l)},()=>[N.value?(e.openBlock(),e.createBlock(Si,{key:0,accept:e.unref(h),multiple:_.maxItems!==1,disabled:_.disabled,"max-file-size":_.maxFileSize,"max-items":e.unref(R),onFiles:C},null,8,["accept","multiple","disabled","max-file-size","max-items"])):e.createCommentVNode("",!0)],!0),e.unref(i).length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"media-collection__list",role:"list","aria-label":`${e.unref(w)} media items`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i),(G,X)=>e.renderSlot(_.$slots,"item",{key:G.clientId,item:G,index:X,remove:()=>A(G)},()=>[e.createElementVNode("div",{class:e.normalizeClass(["media-collection__item-wrapper",{"media-collection__item-wrapper--drag-over":e.unref(S).dropIndex===X}]),draggable:_.sortable&&!_.disabled,"data-index":X,onDragstart:ce=>z(ce,G,X),onDragover:ce=>P(ce,X),onDragend:ce=>j(G,X),onDrop:ce=>L(ce,X)},[e.createVNode(Ei,{item:G,adapter:e.unref(E),disabled:_.disabled,sortable:_.sortable,"show-remove":!_.readonly,"show-edit":!1,index:X,onRemove:A,onRetry:x,onCancel:T,onEdit:I},null,8,["item","adapter","disabled","sortable","show-remove","index"])],42,P4)],!0)),128))],8,R4)):N.value?e.createCommentVNode("",!0):e.renderSlot(_.$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(_.$slots,"footer",{count:e.unref(w),isUploading:e.unref(f)},()=>[e.unref(i).length>0?(e.openBlock(),e.createElementBlock("div",$4,[e.createElementVNode("span",z4,[e.createTextVNode(e.toDisplayString(e.unref(w))+" "+e.toDisplayString(e.unref(w)===1?"file":"files")+" ",1),_.maxItems?(e.openBlock(),e.createElementBlock("span",A4," / "+e.toDisplayString(_.maxItems)+" max",1)):e.createCommentVNode("",!0)]),e.unref(f)?(e.openBlock(),e.createElementBlock("span",D4," Uploading... ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],!0),_.generateFormFields?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y),(G,X)=>(e.openBlock(),e.createElementBlock("input",{key:`${_.name}-${G.uuid}`,type:"hidden",name:`${_.name}[${X}][uuid]`,value:G.uuid},null,8,U4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y),(G,X)=>(e.openBlock(),e.createElementBlock("input",{key:`${_.name}-${G.uuid}-name`,type:"hidden",name:`${_.name}[${X}][name]`,value:G.name},null,8,O4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y),(G,X)=>(e.openBlock(),e.createElementBlock("input",{key:`${_.name}-${G.uuid}-order`,type:"hidden",name:`${_.name}[${X}][order]`,value:G.order},null,8,L4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y),(G,X)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${_.name}-${G.uuid}-props`},[G.custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${_.name}[${X}][custom_properties]`,value:JSON.stringify(G.custom_properties)},null,8,W4)):e.createCommentVNode("",!0)],64))),128))],64)):e.createCommentVNode("",!0),e.unref(b).length>0?(e.openBlock(),e.createElementBlock("div",j4,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),G=>(e.openBlock(),e.createElementBlock("p",{key:G.code||G.message,class:"media-collection__error"},e.toDisplayString(G.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),Z4=_e(X4,[["__scopeId","data-v-10a5bfff"]]);function Vi(n={}){const{initialItem:o,onChange:t,onReplace:a,onUpload:r,onUploadComplete:i,onUploadError:s,onRemove:l,onError:c,onReadyToSubmitChange:d,...u}=n,m={...u,initialItems:o?[o]:[],maxItems:1,sortable:!1,onChange:N=>{t==null||t(N[0]||null)},onUpload:r,onUploadComplete:i,onUploadError:s,onRemove:l,onError:c,onReadyToSubmitChange:d},f=Ka(m),v=e.computed(()=>f.items.value[0]||null),b=e.computed(()=>v.value!==null),S=e.computed(()=>f.formValues.value[0]||null);function M(N){N===null?f.clearAll():f.setItems([N])}async function E(N){const g=v.value;g&&f.removeItem(g),await f.addFiles([N])}function y(){v.value&&f.removeItem(v.value)}async function h(N){const g=v.value;g&&f.removeItem(g),await f.addFiles([N]);const C=f.items.value[0];C&&(a==null||a(g,C))}function w(){var N;(N=v.value)!=null&&N.upload&&f.cancelUpload(v.value.clientId)}async function R(){var N,g;((g=(N=v.value)==null?void 0:N.upload)==null?void 0:g.status)==="error"&&await f.retryUpload(v.value.clientId)}return{item:v,setItem:M,addFile:E,removeItem:y,replaceItem:h,cancelUpload:w,retryUpload:R,save:f.save,load:f.load,isLoading:f.isLoading,isUploading:f.isUploading,isReadyToSubmit:f.isReadyToSubmit,hasItem:b,errors:f.errors,adapter:f.adapter,formValue:S,acceptString:f.acceptString}}const Y4=["accept","disabled"],G4={class:"media-attachment__preview"},H4=["name","value"],J4=["name","value"],q4=["name","value"],K4=["name","value"],Q4={key:4,class:"media-attachment__errors",role:"alert","aria-live":"polite"},e3=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(n,{emit:o}){const t=n,a=o,r=e.ref(null),i={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:x=>{a("update:modelValue",x),a("change",x)},onUpload:x=>{a("upload",x)},onUploadComplete:x=>{a("upload-complete",x)},onUploadError:x=>{a("upload-error",x)},onRemove:x=>{a("remove",x)},onReplace:(x,T)=>{a("replace",T)},onError:x=>{a("validation-error",x)},onReadyToSubmitChange:x=>{a("is-ready-to-submit-change",x)}},{item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:p,retryUpload:m,isLoading:f,hasItem:v,errors:b,adapter:S,formValue:M,acceptString:E}=Vi(i);e.provide("mediaAdapter",S),e.watch(()=>t.modelValue,x=>{x!==s.value&&l(x)},{deep:!0});const y=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!v.value),h=e.computed(()=>({"media-attachment":!0,"media-attachment--disabled":t.disabled,"media-attachment--readonly":t.readonly,"media-attachment--loading":f.value,"media-attachment--has-item":v.value}));function w(x){x.length>0&&c(x[0])}function R(){var x;(x=r.value)==null||x.click()}function N(x){const T=x.target,I=T.files;I&&I.length>0&&u(I[0]),T.value=""}function g(x){d()}function C(x){m()}function A(x){p()}return(x,T)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(h.value)},[e.createElementVNode("input",{ref_key:"fileInputRef",ref:r,type:"file",accept:e.unref(E),disabled:x.disabled,class:"media-attachment__hidden-input",onChange:N},null,40,Y4),y.value?e.renderSlot(x.$slots,"dropzone",{key:0,addFile:e.unref(c)},()=>[e.createVNode(Si,{accept:e.unref(E),multiple:!1,disabled:x.disabled,"max-file-size":x.maxFileSize,onFiles:w},null,8,["accept","disabled","max-file-size"])],!0):e.unref(v)&&e.unref(s)?e.renderSlot(x.$slots,"preview",{key:1,item:e.unref(s),remove:e.unref(d),replace:R},()=>[e.createElementVNode("div",G4,[e.createVNode(Ei,{item:e.unref(s),adapter:e.unref(S),disabled:x.disabled,sortable:!1,"show-remove":!x.readonly,"show-edit":!1,onRemove:g,onRetry:C,onCancel:A},null,8,["item","adapter","disabled","show-remove"]),x.showReplaceButton&&!x.readonly&&!x.disabled&&e.unref(s).media?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-attachment__replace-button",onClick:R},[...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(x.$slots,"empty",{key:2},()=>[T[1]||(T[1]=e.createElementVNode("div",{class:"media-attachment__empty"},[e.createElementVNode("p",null,"No file selected")],-1))],!0),x.generateFormFields&&e.unref(M)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("input",{type:"hidden",name:`${x.name}[uuid]`,value:e.unref(M).uuid},null,8,H4),e.createElementVNode("input",{type:"hidden",name:`${x.name}[name]`,value:e.unref(M).name},null,8,J4),e.createElementVNode("input",{type:"hidden",name:`${x.name}[order]`,value:e.unref(M).order},null,8,q4),e.unref(M).custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${x.name}[custom_properties]`,value:JSON.stringify(e.unref(M).custom_properties)},null,8,K4)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),e.unref(b).length>0?(e.openBlock(),e.createElementBlock("div",Q4,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),I=>(e.openBlock(),e.createElementBlock("p",{key:I.code||I.message,class:"media-attachment__error"},e.toDisplayString(I.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),t3=_e(e3,[["__scopeId","data-v-26911174"]]),ed={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"}},n3=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(n,{expose:o,emit:t}){const a=n,r=t,i={initialItems:a.modelValue,modelType:a.modelType,modelId:a.modelId,collection:a.collection,maxItems:a.maxItems,maxFileSize:a.maxFileSize,acceptedMimeTypes:a.acceptedMimeTypes,sortable:a.sortable,disabled:a.disabled,rules:a.rules,adapterType:a.adapter,onChange:x=>{r("update:modelValue",x),r("change",x)},onUpload:x=>{r("upload",x)},onUploadComplete:x=>{r("upload-complete",x)},onUploadError:x=>{r("upload-error",x)},onRemove:x=>{r("remove",x)},onReorder:x=>{r("reorder",x)},onError:x=>{r("validation-error",x)},onReadyToSubmitChange:x=>{r("is-ready-to-submit-change",x)}},{items:s,setItems:l,addFiles:c,removeItem:d,reorderItems:u,updateItem:p,cancelUpload:m,retryUpload:f,isLoading:v,isUploading:b,isReadyToSubmit:S,isAtMaxItems:M,errors:E,dragState:y,getDragProps:h,adapter:w,formValues:R,acceptString:N}=Ka(i);e.provide("mediaAdapter",w),e.provide("mediaCollection",{items:s,addFiles:c,removeItem:d,reorderItems:u}),e.watch(()=>a.modelValue,x=>{x!==s.value&&l(x)},{deep:!0});const g=e.computed(()=>({...ed,...a.labels})),C=e.computed(()=>({accept:N.value,multiple:a.maxItems!==1,disabled:a.disabled||a.readonly||M.value})),A=e.computed(()=>({items:s.value,isLoading:v.value,isUploading:b.value,isReadyToSubmit:S.value,isAtMaxItems:M.value,errors:E.value,addFiles:c,removeItem:d,reorderItems:u,clearAll:()=>{s.value.forEach(x=>d(x))},cancelUpload:m,retryUpload:f,labels:g.value,dropzoneProps:C.value}));return o({items:s,addFiles:c,removeItem:d,reorderItems:u,updateItem:p,cancelUpload:m,retryUpload:f,isLoading:v,isUploading:b,isReadyToSubmit:S,isAtMaxItems:M,errors:E,dragState:y,getDragProps:h,adapter:w,formValues:R,acceptString:N}),(x,T)=>e.renderSlot(x.$slots,"default",e.normalizeProps(e.guardReactiveProps(A.value)))}}),o3=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(n,{expose:o,emit:t}){const a=n,r=t,i={initialItem:a.modelValue,modelType:a.modelType,modelId:a.modelId,collection:a.collection,maxFileSize:a.maxFileSize,acceptedMimeTypes:a.acceptedMimeTypes,disabled:a.disabled,rules:a.rules,adapterType:a.adapter,onChange:g=>{r("update:modelValue",g),r("change",g)},onUpload:g=>{r("upload",g)},onUploadComplete:g=>{r("upload-complete",g)},onUploadError:g=>{r("upload-error",g)},onRemove:g=>{r("remove",g)},onReplace:(g,C)=>{r("replace",C)},onError:g=>{r("validation-error",g)},onReadyToSubmitChange:g=>{r("is-ready-to-submit-change",g)}},{item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:p,retryUpload:m,isLoading:f,isUploading:v,isReadyToSubmit:b,hasItem:S,errors:M,adapter:E,formValue:y,acceptString:h}=Vi(i);e.provide("mediaAdapter",E),e.watch(()=>a.modelValue,g=>{g!==s.value&&l(g)},{deep:!0});const w=e.computed(()=>({...ed,...a.labels})),R=e.computed(()=>({accept:h.value,multiple:!1,disabled:a.disabled||a.readonly||S.value})),N=e.computed(()=>({item:s.value,hasItem:S.value,isLoading:f.value,isUploading:v.value,isReadyToSubmit:b.value,errors:M.value,addFile:c,removeItem:d,replaceItem:u,cancelUpload:p,retryUpload:m,labels:w.value,dropzoneProps:R.value}));return o({item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:p,retryUpload:m,isLoading:f,isUploading:v,isReadyToSubmit:b,hasItem:S,errors:M,adapter:E,formValue:y,acceptString:h}),(g,C)=>e.renderSlot(g.$slots,"default",e.normalizeProps(e.guardReactiveProps(N.value)))}}),a3=["name","value"],r3=["name","value"],i3=["name","value"],s3=["name","value"],l3=e.defineComponent({__name:"MediaHiddenFields",props:{items:{default:()=>[]},item:{default:null},name:{default:"media"},format:{default:"mediables"}},setup(n){const o=n,t=e.computed(()=>o.item?[o.item]:o.items),a=e.computed(()=>yi(t.value));function r(l,c){var u;const d=((u=a.value[l])==null?void 0:u.uuid)||"";return`${o.name}[${d}][${c}]`}function i(l,c){return`${o.name}[${l}][${c}]`}function s(l,c){return o.format==="spatie"?r(l,c):i(l,c)}return(l,c)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(d,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:d.uuid},[e.createElementVNode("input",{type:"hidden",name:s(u,"uuid"),value:d.uuid},null,8,a3),e.createElementVNode("input",{type:"hidden",name:s(u,"name"),value:d.name},null,8,r3),e.createElementVNode("input",{type:"hidden",name:s(u,"order"),value:d.order},null,8,i3),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,s3)):e.createCommentVNode("",!0)],64))),128))}});exports.AlbumBrowser=Yc;exports.AlbumManager=OE;exports.AlbumMediaGrid=QE;exports.AlbumTree=Zc;exports.ArrayBufferTarget=ei;exports.ImageEditor=Nl;exports.ImageEditorModal=_l;exports.LiveStreamManager=fE;exports.ManagedMediaGallery=Ju;exports.MediaAttachment=t3;exports.MediaCollection=Z4;exports.MediaCollectionDropzone=Si;exports.MediaCollectionItem=Ei;exports.MediaWorkspace=Zu;exports.ModelMediaManager=Yp;exports.Muxer=Kl;exports.VideoEditor=Lc;exports.VideoEditorDialog=qw;exports.VideoEditorSimple=k2;exports.VideoExportPanel=ex;exports.VideoJobClient=gi;exports.VideoPlayer=Wc;exports.VideoTimeline=X2;exports.VideoToolsPanel=Rk;exports.VideoUploader=Ox;exports._sfc_main=n3;exports._sfc_main$1=o3;exports._sfc_main$2=l3;exports.applyTemporaryMediaStoreConfig=xl;exports.configureMediaStore=Dn;exports.createAdapter=Gc;exports.createMediablesAdapter=bi;exports.createSpatieAdapter=wi;exports.formatFileSize=Va;exports.fromMediaArray=Gr;exports.getFileExtension=Hc;exports.getImageDimensions=Jc;exports.getMediablesAdapter=e4;exports.getSpatieAdapter=o4;exports.isImageFile=ki;exports.resetMediablesAdapter=t4;exports.resetSpatieAdapter=a4;exports.restoreMediaStoreConfig=kl;exports.snapshotMediaStoreConfig=wl;exports.toFormValues=yi;exports.useAdminMediaStore=Sl;exports.useAlbumDragDrop=Xc;exports.useAlbumStore=qa;exports.useAlbums=jc;exports.useMediaAttachment=Vi;exports.useMediaCollection=Ka;exports.useMediaDragSort=Qc;exports.useMediaStore=wt;exports.useMediaUploadQueue=Kc;exports.useMediaValidation=xi;exports.validateFile=qc;
|
|
39
|
+
//# sourceMappingURL=index-Bu6zs7yN.cjs.map
|