@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
package/dist/index-DvFmBczx.cjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";var Rd=Object.defineProperty;var Pd=(n,o,t)=>o in n?Rd(n,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[o]=t;var U=(n,o,t)=>Pd(n,typeof o!="symbol"?o+"":o,t);const xa=require("pinia"),e=require("vue"),Le=require("pixi.js"),xt=require("./index-HREFg1jF.cjs"),fl=require("pixi-filters"),I=require("@ionic/vue");function hl(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=hl(Le),Ie=hl(fl);let wt={apiBaseUrl:"/api/v1",isAdmin:!1};function zn(n){wt={...wt,...n}}function vl(){return{...wt}}function gl(n){wt={...n}}function yl(n){const o=vl();return zn(n),()=>{gl(o)}}const $d=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()},yt=xa.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),h=e.ref(new Set),v=e.ref(new Map),b=e.ref({}),x=5*60*1e3,R=e.computed(()=>{if(wt.apiScope)return wt.apiScope;if(wt.isAdmin)return"admin"}),S=e.computed(()=>R.value==="admin");function g(){return wt.httpClient||$d}function f(K){const ce=wt.apiBaseUrl||"/api/v1",ve=R.value?`/${R.value}`:"";return`${ce}${ve}${K}`}function w(K,ce){return`${R.value??"default"}-${K}-${JSON.stringify(ce)}`}function $(K){return Date.now()-K<x}function V(){v.value.clear(),b.value={}}function y(K){if(!K||!K.data)return;const ce={};K.data.forEach(ve=>{const ke=`${ve.file_name}-${ve.collection_name||"default"}`,ne=ce[ke];(!ne||Object.keys(ve.generated_conversions||{}).length>Object.keys(ne.generated_conversions||{}).length)&&(ce[ke]=ve)}),n.value=Object.values(ce),K.meta&&(r.value=K.meta.current_page,i.value=Math.ceil(K.meta.total/K.meta.per_page))}async function C(K=1,ce={}){const ve=w(K,ce),ke=v.value.get(ve);if(ke&&$(ke.timestamp)){const ne=ke.data;return y(ne),ne}t.value=!0,a.value=null;try{const ne=new URLSearchParams;ne.append("page",K.toString()),ne.append("per_page",s.value.toString()),S.value&&ne.append("linked","1");for(const qe in ce)if(Object.prototype.hasOwnProperty.call(ce,qe)){const rt=ce[qe];rt!=null&&rt!==""&&ne.append(qe,String(rt))}const pe=await g()(f(`/media?${ne}`));return v.value.set(ve,{data:pe,timestamp:Date.now()}),y(pe),pe}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 D(K,ce){t.value=!0,a.value=null;const ve=`${K.name}-${Date.now()}`,ke={file:K,progress:0,status:"uploading"};p.value.set(ve,ke);try{const ne=new FormData;ne.append("file",K),ne.append("collection",ce.collection),ce.ownerUuid&&(ne.append("owner_uuid",ce.ownerUuid),ne.append("owner_type",ce.ownerType||"")),ce.usageUuid&&(ne.append("usage_uuid",ce.usageUuid),ne.append("usage_type",ce.usageType||""),ne.append("usage_purpose",ce.usagePurpose||"")),ce.customProperties&&ne.append("custom_properties",JSON.stringify(ce.customProperties));const pe=await g()(f("/media"),{method:"POST",body:ne});return ke.status="completed",ke.progress=100,ke.media=pe==null?void 0:pe.data,r.value===1&&(pe!=null&&pe.data)&&(n.value=[pe.data,...n.value]),V(),(pe==null?void 0:pe.data)||null}catch(ne){throw ke.status="error",ke.error=ne instanceof Error?ne.message:"Upload failed",a.value=ke.error,new Error(a.value)}finally{t.value=!1,setTimeout(()=>{p.value.delete(ve)},5e3)}}async function k(K){t.value=!0,a.value=null;const ce=n.value.findIndex(ke=>ke.uuid===K);let ve;ce!==-1&&(ve=n.value.splice(ce,1)[0]);try{return await g()(f(`/media/${K}`),{method:"DELETE"}),h.value.delete(K),V(),!0}catch(ke){throw ve&&ce!==-1&&n.value.splice(ce,0,ve),a.value=ke instanceof Error?ke.message:"Failed to delete media",new Error(a.value)}finally{t.value=!1}}async function T(K,ce){t.value=!0,a.value=null;try{const ke=await g()(f(`/media/${K}`),{method:"PATCH",body:ce,data:ce});if(ke!=null&&ke.data){const ne=n.value.findIndex(we=>we.uuid===K);return ne!==-1&&(n.value[ne]={...n.value[ne],...ke.data}),V(),ke.data}return null}catch(ve){throw a.value=ve instanceof Error?ve.message:"Failed to update media",new Error(a.value)}finally{t.value=!1}}async function F(){t.value=!0,a.value=null;try{const ce=await g()(f("/media/collections"));return o.value=(ce==null?void 0:ce.data)||[],o.value}catch(K){throw a.value=K instanceof Error?K.message:"Failed to fetch collections",o.value=[],new Error(a.value)}finally{t.value=!1}}async function A(K,ce,ve="images",ke){d.value=!0,u.value=null;try{const ne=new URLSearchParams;ne.append("collection",ve),ke&&ne.append("search",ke);const pe=await g()(f(`/media/model/${K}/${ce}?${ne}`));return pe!=null&&pe.data?(c.value=pe.data,pe.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(K,ce,ve,ke="images"){d.value=!0,u.value=null;const ne=[...c.value];try{const pe=await g()(f(`/media/model/${K}/${ce}/attach`),{method:"POST",body:{media_uuids:ve,collection:ke}});return await A(K,ce,ke),(pe==null?void 0:pe.data)||[]}catch(we){throw c.value=ne,u.value=we instanceof Error?we.message:"Failed to attach media",new Error(u.value)}finally{d.value=!1}}async function O(K,ce,ve,ke="images"){d.value=!0,u.value=null;const ne=[...c.value];c.value=c.value.filter(we=>we.uuid!==ve);try{return await g()(f(`/media/model/${K}/${ce}/detach`),{method:"POST",body:{media_uuid:ve,collection:ke}}),!0}catch(we){throw c.value=ne,u.value=we instanceof Error?we.message:"Failed to detach media",new Error(u.value)}finally{d.value=!1}}async function B(K,ce,ve,ke="images"){d.value=!0,u.value=null;const ne=[...c.value],we=new Map(c.value.map(pe=>[pe.uuid,pe]));c.value=ve.map(pe=>we.get(pe)).filter(pe=>pe!==void 0);try{return await g()(f(`/media/model/${K}/${ce}/reorder`),{method:"POST",body:{media_uuids:ve,collection:ke}}),!0}catch(pe){throw c.value=ne,u.value=pe instanceof Error?pe.message:"Failed to reorder media",new Error(u.value)}finally{d.value=!1}}async function _(K,ce,ve={}){const ke=g(),ne=wt.apiBaseUrl||"/api/v1",we={image_data:ce.imageData,filters:ce.metadata.filters,crop_data:ce.metadata.cropRect,save_as_new:!0,as_variant:ve.asVariant===!0};return ve.name!==void 0&&(we.name=ve.name),(await ke(`${ne}/editor/${K}/save`,{method:"POST",body:we})).media}function X(K,ce,ve){l.value=ve!==void 0?{type:K,uuid:ce,collection:ve}:{type:K,uuid:ce},b.value[`${K}-${ce}`]={timestamp:Date.now()}}function W(){l.value={type:null,uuid:null},c.value=[],u.value=null}async function ee(){if(!l.value.type||!l.value.uuid)return;const K=await A(l.value.type,l.value.uuid,l.value.collection||"images");c.value=K||[]}function he(){n.value.forEach(K=>h.value.add(K.uuid))}function Ue(){h.value.clear()}function Te(K){h.value.has(K)?h.value.delete(K):h.value.add(K)}function re(K){return h.value.has(K)}function M(){return Array.from(p.value.values()).some(K=>K.status==="uploading")}function j(K){return p.value.get(K)||m.value.get(K)}function le(){return[...Array.from(p.value.values()),...Array.from(m.value.values())]}async function ae(){const K=Array.from(h.value);let ce=0;for(const ve of K)try{await k(ve),ce++}catch{}return Ue(),ce}function H(K,ce){var ve;return ce&&((ve=K.conversion_urls)!=null&&ve[ce])?K.conversion_urls[ce]||"":K.original_url||K.url||""}return{items:n,collections:o,loading:t,error:a,currentPage:r,totalPages:i,itemsPerPage:s,isAdmin:S,modelContext:l,modelMedia:c,isLoadingModelMedia:d,modelMediaError:u,selectedItems:h,uploadProgress:p,uploadQueue:m,cachedResponses:b,fetchMedia:C,uploadFile:D,deleteMedia:k,updateMedia:T,clearCache:V,fetchCollections:F,fetchModelMedia:A,attachMedia:P,detachMedia:O,reorderMedia:B,saveEditedImage:_,setModelContext:X,clearModelContext:W,refreshModelMedia:ee,selectAllItems:he,clearSelection:Ue,toggleSelection:Te,isSelected:re,deleteSelectedItems:ae,hasActiveUploads:M,getUploadProgress:j,getAllUploadProgress:le,getMediaUrl:H}}),bl=()=>((wt.apiScope!=="admin"||wt.isAdmin!==!0)&&zn({...wt,apiScope:"admin",isAdmin:!0}),yt()),Qt=new Map,lo=new Map;function Ne(n){var o;return Qt.has(n.id),Qt.set(n.id,n),lo.has(n.category)||lo.set(n.category,[]),(o=lo.get(n.category))==null||o.push(n.id),n}function wl(n){return Qt.get(n)}function vo(){return Array.from(Qt.values())}function zd(){vo().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();Qt.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 kl(n){return(lo.get(n)||[]).map(t=>Qt.get(t)).filter(Boolean)}function Ad(){return Array.from(lo.keys())}function Dd(){return Array.from(Qt.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(Qt.keys()),window.getAllFilters=vo,window.getFilter=wl,window.getFiltersByCategory=kl,window.getRegisteredFilters=Dd;const n=Ne;window.registerFilter=o=>{const t=n(o);return window.__DEBUG_FILTERS_LIST=Array.from(Qt.keys()),t}}typeof window<"u"&&(window.initializeFilterRegistry=window.initializeFilterRegistry||function(){return[]});const{AdjustmentFilter:Ud}=Ie,{ColorMatrixFilter:Od}=Ae,Ut={gamma:1,saturation:1,contrast:1,brightness:1,red:1,green:1,blue:1,alpha:1},Ld=new Set(["gamma","saturation","contrast","brightness","red","green","blue","alpha"]);function Ot(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 ss(n){return Ld.has(n)}function Wd(n){return{gamma:Ot(n.gamma,Ut.gamma),saturation:Ot(n.saturation,Ut.saturation),contrast:Ot(n.contrast,Ut.contrast),brightness:Ot(n.brightness,Ut.brightness),red:Ot(n.red,Ut.red),green:Ot(n.green,Ut.green),blue:Ot(n.blue,Ut.blue),alpha:Ot(n.alpha,Ut.alpha)}}function ls(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=Wd(n??{}),t={...o};try{const a=new Ud(t),r=a;return r._customParams={...o},r.updateUIParam=function(s,l){try{if(!ss(s))return;const c=this._customParams??{...Ut},d=Ot(l,c[s]);c[s]=d,this._customParams=c;const u=this;s in u&&(u[s]=d)}catch{}},a}catch{const r=new Od,i=r;return i._customParams={...o},ls(r,o),i.updateUIParam=function(l,c){try{if(!ss(l))return;const d=this._customParams??{...Ut},u=Ot(c,d[l]);d[l]=u,this._customParams=d,ls(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:jd}=Ae,cn={brightness:1,contrast:1,saturation:1,hue:0,sepia:0,negative:!1},Xd=new Set(["brightness","contrast","saturation","hue","sepia","negative"]);function Zd(n){return Xd.has(n)}function Bn(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 xl(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 Yd(n){return{brightness:Bn(n.brightness,cn.brightness),contrast:Bn(n.contrast,cn.contrast),saturation:Bn(n.saturation,cn.saturation),hue:Bn(n.hue,cn.hue),sepia:Bn(n.sepia,cn.sepia),negative:xl(n.negative,cn.negative)}}function cs(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=Yd(n??{}),t=new jd,a=t;return a._customParams={...o},cs(t,o),a.updateUIParam=function(i,s){try{if(!Zd(i))return;const l=this._customParams??{...cn};if(i==="negative")l.negative=xl(s,l.negative);else{const c=i;l[c]=Bn(s,l[c])}this._customParams=l,cs(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:Gd}=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 Gd({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 Le.ColorMatrixFilter;o._customParams={...n};const t=n.intensity!==void 0?n.intensity:1;return ds(o,t),o.updateUIParam=function(a,r){const i=this._customParams||{};switch(this._customParams=i,i[a]=r,a){case"intensity":ds(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 ds(n,o){n.reset(),n.greyscale(o,!1)}const{HslAdjustmentFilter:Hd}=Ie;Ne({id:"hsl-adjustment",name:"HSL Adjustment",category:"color",description:"Control hue, saturation, and lightness independently",createFilter:n=>{try{const o=new Hd({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:Jd}=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 Jd({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:qd}=Ie;Ne({id:"motion-blur",name:"Motion Blur",category:"blur",description:"Creates a directional blur effect simulating motion",createFilter:n=>{try{const o=new qd({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:Kd}=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 Kd({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:Qd}=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 Qd({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:eu}=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 eu({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:us}=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 us({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),h=Math.floor(Math.random()*255);return p<<16|m<<8|h})()};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 us({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,h)=>m.offset-h.offset),this.stops=p}break;default:if(/colorStops\[\d+\]\..*/.test(a)){const p=a.match(/colorStops\[(\d+)\]\.(.*)/);if(p){const[m,h,v]=p,b=parseInt(h),x=[...this.stops];if(b>=0&&b<x.length)return v==="color"&&typeof r=="string"?x[b].color=parseInt(r.replace("#","0x")):(v==="offset"||v==="alpha")&&(x[b][v]=r),this.stops=x,this.stops.sort((R,S)=>R.offset-S.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 tu=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 tu({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 nu=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 nu({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:ou}=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 ou({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:au}=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 au({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 ru=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 ru({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 iu=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 iu({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:su}=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 su({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:lu}=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 lu({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),h=this._customParams||{};switch(this._customParams=h,h[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:cu}=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 cu({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:du}=Ie,Fn={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=Fn[a]||Fn.normal}const t=new du({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;Fn[s]&&(this.matrix=Fn[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=Fn[s]||Fn.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 uu=Ae.DisplacementFilter,mu=Ae.Sprite,ir=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=ir.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=ir.from(s)}const a=new mu(t),r=new uu(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=ir.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:pu}=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 pu({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:fu}=Ie,ln={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 fu({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:ln.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:ln.TRANSPARENT,label:"Transparent"},{value:ln.ORIGINAL,label:"Original"},{value:ln.LOOP,label:"Loop"},{value:ln.CLAMP,label:"Clamp"},{value:ln.MIRROR,label:"Mirror"}],default:ln.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:hu}=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 hu({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:vu}=Ie;Ne({id:"godray",name:"Godray",category:"light",description:"Creates volumetric light-ray effects (crepuscular rays)",createFilter:n=>{try{const o=new vu({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 gu=Ie.SimpleLightmapFilter,ms=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=ms.from(r);let l;try{typeof t=="string"&&t.startsWith("#")?l=parseInt(t.replace("#","0x"),16):l=0}catch{l=0}const c=new gu(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 h=m.getContext("2d");if(h){if(u==="spotlight"){h.fillStyle="black",h.fillRect(0,0,256,256);const b=h.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)"),h.fillStyle=b,h.beginPath(),h.arc(128,128,100,0,Math.PI*2),h.fill()}else if(u==="softlight"){const b=h.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)"),h.fillStyle=b,h.fillRect(0,0,256,256)}else{const b=h.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"),h.fillStyle=b,h.fillRect(0,0,256,256)}const v=ms.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:yu}=Ae;Ne({id:"noise",name:"Noise",category:"effects",description:"Add random noise to the image",createFilter:n=>{try{const o=new yu({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:bu}=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 bu({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:wu}=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 wu({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:ku}=Ie;Ne({id:"pixelate",name:"Pixelate",category:"effects",description:"Create a pixelated or mosaic effect",createFilter:n=>{try{const o=new ku(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:xu}=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 xu(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:Eu}=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 Eu({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 h=this._customParams||{};switch(this._customParams=h,h[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:Su}=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 Su({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:Vu}=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 Vu({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:Cu}=Ie;function Oo(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 Nu extends Cu{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=Oo(o.color)):(this._colorValue="#"+o.color.toString(16).padStart(6,"0"),this._colorRgb=Oo(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=Oo(o)):(this._colorValue="#"+o.toString(16).padStart(6,"0"),this._colorRgb=Oo(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 Nu({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 _u(){try{let n=[],o=[];try{n=vo(),n.length===0&&zd()}catch{}try{n=vo(),o=Ad()}catch{n||(n=[]),o||(o=[])}return n.length,n}catch{return[]}}const Tu=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,h=p.activeFilters,v=p.filterValues,b=i._renderer.sprite,x={width:Math.round((b==null?void 0:b.width)??0),height:Math.round((b==null?void 0:b.height)??0)},R={imageData:u,dimensions:x,metadata:{hasCrop:(m==null?void 0:m.rect)!=null,cropRect:(m==null?void 0:m.rect)??null,filters:h?Array.from(h):[],filterValues:v??{},aspectRatio:(m==null?void 0:m.aspect)??"free",dimensions:x}};a("save",R)}function c(){a("cancel")}function d(){if(!r.value||i)return;window.PIXI=Ae,_u();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 xt.VanillaImageEditor(r.value,u),i.setFilterRegistry({getAllFilters:vo,getFilter:wl,getFiltersByCategory:kl}),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},El=_e(Tu,[["__scopeId","data-v-3b3ff253"]]);function Mu(n,o){try{let t=xt.getFilter(n);if(t||(xt.registerCorePixiFilters(),t=xt.getFilter(n)),!t){try{const i=xt.getAllFilters()}catch{}return null}const a={...t.defaultParams,...o};return t.createFilter(a)}catch{return null}}const Fu={class:"editor-modal-panel"},Bu={class:"editor-fill"},Iu=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=S=>new Promise((g,f)=>{const w=new FileReader;w.onload=$=>{var y;const V=(y=$.target)==null?void 0:y.result;typeof V=="string"?g(V):f(new Error("Failed to read file"))},w.onerror=()=>f(new Error("Failed to read file")),w.readAsDataURL(S)}),u=S=>{a("error",S)},p=async()=>{if(t.initialImage instanceof File)try{const S=await d(t.initialImage);s.value=S}catch(S){u(S)}else typeof t.initialImage=="string"&&(s.value=t.initialImage)},m=()=>{e.nextTick(()=>{if(r.value){const S=r.value.querySelector("button:not([disabled]), [href], input:not([disabled])");S&&S.focus()}})};e.watch(()=>t.modelValue,S=>{i.value=S,S&&(c.value=document.activeElement,t.initialImage&&p(),m())},{immediate:!0}),e.watch(()=>t.initialImage,S=>{S&&i.value&&p()});const h=async S=>{try{l.value=!0,t.onSave&&await t.onSave(S),a("save",S)}catch(g){u(g)}finally{l.value=!1}},v=()=>{a("cancel"),x()},b=()=>{l.value||x()},x=()=>{i.value=!1,a("update:modelValue",!1),c.value&&c.value instanceof HTMLElement&&(c.value.focus(),c.value=null),setTimeout(()=>{s.value=null},300)},R=S=>{if(S.key==="Escape"&&i.value&&!l.value){x();return}if(S.key==="Tab"&&i.value&&r.value){const g=r.value.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(g.length===0)return;const f=g[0],w=g[g.length-1];S.shiftKey&&document.activeElement===f?(S.preventDefault(),w.focus()):!S.shiftKey&&document.activeElement===w&&(S.preventDefault(),f.focus())}};return e.onMounted(()=>{document.addEventListener("keydown",R)}),e.onBeforeUnmount(()=>{document.removeEventListener("keydown",R)}),t.modelValue&&t.initialImage&&p(),(S,g)=>(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",Fu,[e.createElementVNode("div",Bu,[e.createVNode(El,{"initial-image":s.value??S.initialImage,theme:S.theme,"crop-shape":S.cropShape,preset:S.preset,"primary-color":S.primaryColor,"secondary-color":S.secondaryColor,"save-button-color":S.saveButtonColor,"download-button-color":S.downloadButtonColor,onSave:h,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)]))}}),Sl=_e(Iu,[["__scopeId","data-v-e19beb15"]]),Ru={class:"media-workspace"},Pu={class:"media-workspace-toolbar"},$u={class:"media-workspace-label"},zu=["value"],Au={class:"media-workspace-grid"},Du=["onClick"],Uu=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=yt(),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=yl({apiScope:t.apiScope,isAdmin:t.apiScope==="admin"}))}async function u(){var h;const m={};(h=l.value)!=null&&h.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(h=>h.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,h)=>(e.openBlock(),e.createElementBlock("div",Ru,[e.createElementVNode("div",Pu,[e.createElementVNode("label",$u,[h[2]||(h[2]=e.createElementVNode("span",{class:"media-workspace-label-text"},"Scope",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":h[0]||(h[0]=v=>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,zu))),128))],512),[[e.vModelSelect,i.value]])]),e.createElementVNode("button",{type:"button",class:"media-workspace-upload","data-testid":"upload-button",onClick:h[1]||(h[1]=v=>a("upload"))}," Upload ")]),e.createElementVNode("div",Au,[(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,Du))),128))])]))}}),Ou=_e(Uu,[["__scopeId","data-v-895f26fe"]]),Lu={class:"managed-media-gallery"},Wu={class:"gallery-grid"},ju=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",Lu,[e.createElementVNode("div",Wu,[e.renderSlot(o.$slots,"default",{},void 0,!0)])]))}}),Xu=_e(ju,[["__scopeId","data-v-a60fdcd7"]]),Zu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M256 176v160M336 256H176' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Xr="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M256 112v288M400 256H112' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Yu="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>",Zr="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>",Gu="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>",Hu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M268 112l144 144-144 144M392 256H100' class='ionicon-fill-none'/></svg>",no="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>",Ju="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>",Vl="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>",Cl="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>",ps="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M328 112L184 256l144 144' class='ionicon-fill-none'/></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='M112 184l144 144 144-144' class='ionicon-fill-none'/></svg>",Ku="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>",fs="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>",go="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>",hs="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>",Qu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='256' cy='184' r='120' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='344' cy='328' r='120' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='168' cy='328' r='120' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",an="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M430.11 347.9c-6.6-6.1-16.3-7.6-24.6-9-11.5-1.9-15.9-4-22.6-10-14.3-12.7-14.3-31.1 0-43.8l30.3-26.9c46.4-41 46.4-108.2 0-149.2-34.2-30.1-80.1-45-127.8-45-55.7 0-113.9 20.3-158.8 60.1-83.5 73.8-83.5 194.7 0 268.5 41.5 36.7 97.5 55 152.9 55.4h1.7c55.4 0 110-17.9 148.8-52.4 14.4-12.7 11.99-36.6.1-47.7z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='144' cy='208' r='32'/><circle cx='152' cy='311' r='32'/><circle cx='224' cy='144' r='32'/><circle cx='256' cy='367' r='48'/><circle cx='328' cy='144' r='32'/></svg>",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' 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>",Jn="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>",tm="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>",nm="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>",vs="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>",Nl="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>",Ea="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>",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' 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>",am="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>",rm="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>",oo="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>",gs="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>",sr="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>",im="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>",sm="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>",lr="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>",lm="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>",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='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>",dm="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>",um="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>",_l="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>",mm="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>",pm="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>",fm="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>",hm="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>",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 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>",Tl="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path 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>",gm="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>",ym="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>",bm="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>",wm="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>",km="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>",ko="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>",xm="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>",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' d='M400 256H112' class='ionicon-fill-none ionicon-stroke-width'/></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' d='M304 96h112v112M405.77 106.2L111.98 400.02M208 416H96V304' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Ml="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path 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>",Sm="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>",cr="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M400 304l48 48-48 48M400 112l48 48-48 48M64 352h85.19a80 80 0 0066.56-35.62L256 256' class='ionicon-fill-none ionicon-stroke-width'/><path d='M64 160h85.19a80 80 0 0166.56 35.62l80.5 120.76A80 80 0 00362.81 352H416M416 160h-53.19a80 80 0 00-66.56 35.62L288 208' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",on="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' class='ionicon'><path d='M259.92 262.91L216.4 149.77a9 9 0 00-16.8 0l-43.52 113.14a9 9 0 01-5.17 5.17L37.77 311.6a9 9 0 000 16.8l113.14 43.52a9 9 0 015.17 5.17l43.52 113.14a9 9 0 0016.8 0l43.52-113.14a9 9 0 015.17-5.17l113.14-43.52a9 9 0 000-16.8l-113.14-43.52a9 9 0 01-5.17-5.17zM108 68L88 16 68 68 16 88l52 20 20 52 20-52 52-20-52-20zM426.67 117.33L400 48l-26.67 69.33L304 144l69.33 26.67L400 240l26.67-69.33L496 144l-69.33-26.67z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",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>",bs="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>",Vm="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>",Fl="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>",Cm="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>",Bl="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>",Nm="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>",_m="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>",Tm="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>",Mm="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>",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-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>",Bm="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>",Im="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>",Lo="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 ws=()=>{};function Rm(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 Pm(n,o={}){let t,a,r=ws;const i=c=>{clearTimeout(c),r(),r=ws};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 $m(n,o=200,t={}){return Rm(Pm(o,t),n)}const Kn=new Map;function zm(n){const o=e.getCurrentScope();function t(l){var c;const d=Kn.get(n)||new Set;d.add(l),Kn.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=Kn.get(n);c&&(c.delete(l),c.size||i())}function i(){Kn.delete(n)}function s(l,c){var d;(d=Kn.get(n))==null||d.forEach(u=>u(l,c))}return{on:t,once:a,off:r,emit:s,reset:i}}function Am(){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 Dm(n){const o=e.ref(new Set),t=e.ref(null),a=e.ref(-1),r=zm("media-selection"),i=Am(),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($=>$.uuid===w),o.value.size===1&&i.selection())}function m(w){o.value.add(w),t.value=w,a.value=n.value.findIndex($=>$.uuid===w)}function h(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 x(){c.value?b():v()}function R(w,$){const V=n.value.findIndex(y=>y.uuid===w);if(V!==-1)if($!=null&&$.shiftKey&&a.value!==-1){const y=Math.min(a.value,V),C=Math.max(a.value,V);for(let D=y;D<=C;D++)o.value.add(n.value[D].uuid)}else p(w)}function S(){if(n.value.length===0)return;let w=a.value+1;w>=n.value.length&&(w=0),b(),m(n.value[w].uuid)}function g(){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 f(w){switch(w.key){case"ArrowDown":w.preventDefault(),S();break;case"ArrowUp":w.preventDefault(),g();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:h,selectAll:v,clear:b,toggleAll:x,rangeSelect:R,selectNext:S,selectPrevious:g,handleKeydown:f,selectionBus:r}}const Um={class:"flex items-center justify-between w-full px-4"},Om={class:"p-4"},Lm={key:0,class:"mb-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg"},Wm={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"},jm=["value"],Xm={class:"flex gap-2 mt-4"},Zm={class:"flex justify-end mb-4"},Ym={key:1,class:"flex justify-center items-center h-64"},Gm={key:2,class:"flex flex-col items-center justify-center h-64 text-center"},Hm={class:"text-sm text-theme-secondary"},Jm={key:0},qm={class:"mb-4"},Km={class:"mb-4"},Qm={class:"flex gap-2"},ep={class:"flex items-center justify-between px-4 py-2"},tp={class:"text-sm text-theme-secondary"},np={key:0},op={key:0},ap={key:1},rp={class:"flex gap-2"},ip=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({}),h=e.ref(["images","documents","videos"]),v=e.ref(1),b=e.ref(!0),x=e.ref(!1),R=bl(),S=Dm(c);function g(M){var ve;const j=M.conversion_urls||{},le=M.proxy_url||M.original_url||M.url||"",ae=j.thumb||j.preview||M.preview_url||M.thumbnail_url||le,H=M.custom_properties||{},K=H.width,ce=H.height;return{...M,uuid:M.uuid,name:M.name||M.file_name,file_name:M.file_name,filename:M.file_name,mime_type:M.mime_type,size:M.size,collection_name:M.collection_name||"images",disk:M.disk,original_url:le,url:le,thumbnail_url:ae,conversions:M.conversions||{},conversion_urls:j,generated_conversions:M.generated_conversions||{},custom_properties:H,caption:M.caption||null,alt_text:M.alt_text||null,created_at:M.created_at,updated_at:M.updated_at,is_image:((ve=M.mime_type)==null?void 0:ve.startsWith("image/"))||!1,...typeof K=="number"?{width:K}:{},...typeof ce=="number"?{height:ce}:{},...M.formatted_size!==void 0?{formatted_size:M.formatted_size}:{}}}e.watch(()=>t.selectedItems,M=>{u.value=new Set(M),S.clear(),M.forEach(j=>S.select(j))});const f=e.computed(()=>{var j;let M=c.value;return(j=m.value.types)!=null&&j.length&&(M=M.filter(le=>{var H,K;const ae=(H=le.mime_type)==null?void 0:H.split("/")[0];return(K=m.value.types)==null?void 0:K.includes(ae)})),(m.value.sizeMin!==void 0||m.value.sizeMax!==void 0)&&(M=M.filter(le=>{const ae=le.size/1048576;return!(m.value.sizeMin!==void 0&&ae<m.value.sizeMin||m.value.sizeMax!==void 0&&ae>m.value.sizeMax)})),M}),w=e.computed(()=>{var j;let M=0;return m.value.search&&M++,m.value.collection&&M++,(m.value.dateFrom||m.value.dateTo)&&M++,(j=m.value.types)!=null&&j.length&&(M+=m.value.types.length),(m.value.sizeMin!==void 0||m.value.sizeMax!==void 0)&&M++,M}),$=e.computed(()=>{const M=S.selectedCount.value;return M===0?"Select Media":`Select ${t.selectionMode==="multiple"?`${M} ${M===1?"Item":"Items"}`:"Item"}`}),V=e.computed(()=>{const M=S.selectedCount.value;return!!(M===0||t.selectionMode==="single"&&M>1||t.maxSelection&&M>t.maxSelection)}),y=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(M=!0){M?(l.value=!0,c.value=[],v.value=1,b.value=!0):x.value=!0;try{const j={collection:m.value.collection||t.collection,per_page:24};switch((s.value||m.value.search)&&(j.search=s.value||m.value.search||""),m.value.dateFrom&&(j.from_date=m.value.dateFrom),m.value.dateTo&&(j.to_date=m.value.dateTo),r.value){case"recent":await R.fetchMedia(v.value,j),M?c.value=R.items.map(le=>g(le)):c.value=[...c.value,...R.items.map(le=>g(le))],b.value=R.currentPage<R.totalPages;break;case"model":if(t.modelType&&t.modelId){const le=await R.fetchModelMedia(t.modelType,t.modelId,j.collection,j.search);c.value=le?le.map(ae=>g(ae)):[],b.value=!1}break;case"library":await R.fetchMedia(v.value,j),M?c.value=R.items.map(le=>g(le)):c.value=[...c.value,...R.items.map(le=>g(le))],b.value=R.currentPage<R.totalPages;break}}catch{}finally{l.value=!1,x.value=!1}}async function D(M){if(!b.value||x.value){M!=null&&M.target&&M.target.complete();return}v.value++,await C(!1),M!=null&&M.target&&(M.target.complete(),b.value||(M.target.disabled=!0))}function k(M){return M==="recent"||M==="model"||M==="library"}function T(M){r.value=M,C()}function F(M){typeof M=="string"&&k(M)&&T(M)}async function A(M){t.selectionMode==="single"?(S.clear(),S.select(M.uuid)):(S.toggle(M.uuid),t.maxSelection&&S.selectedCount.value>t.maxSelection&&(S.deselect(M.uuid),await(await I.toastController.create({message:`Maximum ${t.maxSelection} items can be selected`,duration:2e3,color:"warning"})).present()))}function P(){a("confirm",S.selectedItems.value)}function O(){a("close")}function B(M){}const _=e.ref(null),X=e.ref(!1);function W(M){_.value=M,X.value=!0}function ee(M){const j=c.value.findIndex(ae=>ae.uuid===M.uuid);j!==-1&&(c.value[j]=M);const le={};M.alt_text!==void 0&&(le.alt_text=M.alt_text),M.caption!==void 0&&(le.caption=M.caption),M.custom_properties!==void 0&&(le.custom_properties=M.custom_properties),R.updateMedia(M.uuid,le)}function he(){C()}function Ue(){m.value={},s.value="",C()}const Te=$m(()=>{C(!0)},300);e.watch(s,()=>{t.isOpen&&Te()});async function re(M){try{await(await I.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 R.deleteMedia(M),await C()}}]})).present()}catch{}}return e.watch(()=>t.isOpen,M=>{M&&C()}),e.onMounted(()=>{t.selectedItems.length>0&&t.selectedItems.forEach(M=>S.select(M))}),(M,j)=>{const le=e.resolveComponent("AdminMediaGrid"),ae=e.resolveComponent("AdminMediaListItem");return e.openBlock(),e.createBlock(e.unref(I.IonModal),{"is-open":M.isOpen,onDidDismiss:O,"backdrop-dismiss":!1,class:"media-browser-modal"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(I.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{onClick:O},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(I.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(y.value),1)]),_:1})]),_:1}),e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",Um,[e.createVNode(e.unref(I.IonSegment),{value:r.value,onIonChange:j[0]||(j[0]=H=>F(H.detail.value)),class:"max-w-xs"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonSegmentButton),{value:"recent"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...j[15]||(j[15]=[e.createTextVNode("Recent",-1)])]),_:1})]),_:1}),t.modelType&&t.modelId?(e.openBlock(),e.createBlock(e.unref(I.IonSegmentButton),{key:0,value:"model"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...j[16]||(j[16]=[e.createTextVNode("Model",-1)])]),_:1})]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonSegmentButton),{value:"library"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...j[17]||(j[17]=[e.createTextVNode("Library",-1)])]),_:1})]),_:1})]),_:1},8,["value"]),e.createVNode(e.unref(I.IonButton),{fill:"clear",size:"small",onClick:j[1]||(j[1]=H=>p.value=!p.value),class:"relative"},{"icon-only":e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{name:"filter-outline"})]),default:e.withCtx(()=>[w.value>0?(e.openBlock(),e.createBlock(e.unref(I.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(I.IonContent),null,{default:e.withCtx(()=>[e.createElementVNode("div",Om,[p.value?(e.openBlock(),e.createElementBlock("div",Lm,[e.createElementVNode("div",Wm,[e.createElementVNode("div",null,[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...j[18]||(j[18]=[e.createTextVNode("Collection",-1)])]),_:1}),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":j[2]||(j[2]=H=>m.value.collection=H),class:"w-full p-2 border rounded"},[j[19]||(j[19]=e.createElementVNode("option",{value:""},"All Collections",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,H=>(e.openBlock(),e.createElementBlock("option",{key:H,value:H},e.toDisplayString(H),9,jm))),128))],512),[[e.vModelSelect,m.value.collection]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...j[20]||(j[20]=[e.createTextVNode("From Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":j[3]||(j[3]=H=>m.value.dateFrom=H),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,m.value.dateFrom]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...j[21]||(j[21]=[e.createTextVNode("To Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":j[4]||(j[4]=H=>m.value.dateTo=H),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,m.value.dateTo]])])]),e.createElementVNode("div",Xm,[e.createVNode(e.unref(I.IonButton),{size:"small",onClick:he},{default:e.withCtx(()=>[...j[22]||(j[22]=[e.createTextVNode("Apply",-1)])]),_:1}),e.createVNode(e.unref(I.IonButton),{size:"small",fill:"clear",onClick:Ue},{default:e.withCtx(()=>[...j[23]||(j[23]=[e.createTextVNode("Clear",-1)])]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonSearchbar),{modelValue:s.value,"onUpdate:modelValue":j[5]||(j[5]=H=>s.value=H),placeholder:"Search media...",debounce:300,class:"mb-4"},null,8,["modelValue"]),e.createElementVNode("div",Zm,[e.createVNode(e.unref(I.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{fill:i.value==="grid"?"solid":"clear",size:"small",onClick:j[6]||(j[6]=H=>i.value="grid")},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{name:"grid-outline"})]),_:1},8,["fill"]),e.createVNode(e.unref(I.IonButton),{fill:i.value==="list"?"solid":"clear",size:"small",onClick:j[7]||(j[7]=H=>i.value="list")},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{name:"list-outline"})]),_:1},8,["fill"])]),_:1})]),l.value?(e.openBlock(),e.createElementBlock("div",Ym,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"})])):f.value.length===0?(e.openBlock(),e.createElementBlock("div",Gm,[e.createVNode(e.unref(I.IonIcon),{name:"images-outline",class:"text-6xl text-theme-secondary mb-4"}),j[24]||(j[24]=e.createElementVNode("h3",{class:"text-lg font-medium text-theme mb-2"}," No Media Found ",-1)),e.createElementVNode("p",Hm,e.toDisplayString(s.value?"Try adjusting your search":"No media items available"),1)])):i.value==="grid"?(e.openBlock(),e.createBlock(le,{key:3,"media-items":f.value,"selected-items":e.unref(S).selectedItems.value,"is-loading":!1,"selection-mode":!0,columns:{mobile:2,sm:3,md:4,lg:5,xl:6},onToggleSelect:A,onPreview:B,onEdit:W,onDelete:re},null,8,["media-items","selected-items"])):(e.openBlock(),e.createBlock(e.unref(I.IonList),{key:4,lines:"none",class:"rounded-lg overflow-hidden"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(H,K)=>(e.openBlock(),e.createBlock(ae,{key:H.uuid,media:H,selected:e.unref(S).isSelected(H.uuid),"selection-mode":!0,index:K,onToggleSelect:A,onPreview:B,onEdit:W,onDelete:re},null,8,["media","selected","index"]))),128))]),_:1})),!l.value&&f.value.length>0&&r.value!=="model"?(e.openBlock(),e.createBlock(e.unref(I.IonInfiniteScroll),{key:5,threshold:"100px",onIonInfinite:j[8]||(j[8]=H=>D(H))},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonInfiniteScrollContent),{"loading-spinner":"crescent","loading-text":"Loading more media..."})]),_:1})):e.createCommentVNode("",!0)])]),_:1}),e.createVNode(e.unref(I.IonModal),{"is-open":X.value,onDidDismiss:j[14]||(j[14]=H=>X.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(I.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{onClick:j[9]||(j[9]=H=>X.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(I.IonTitle),null,{default:e.withCtx(()=>[...j[25]||(j[25]=[e.createTextVNode("Edit Media Info",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(I.IonContent),{class:"p-4"},{default:e.withCtx(()=>[_.value?(e.openBlock(),e.createElementBlock("div",Jm,[e.createElementVNode("div",qm,[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...j[26]||(j[26]=[e.createTextVNode("Caption",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":j[10]||(j[10]=H=>_.value.caption=H),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter caption..."},null,512),[[e.vModelText,_.value.caption]])]),e.createElementVNode("div",Km,[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...j[27]||(j[27]=[e.createTextVNode("Alt Text",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":j[11]||(j[11]=H=>_.value.alt_text=H),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",Qm,[e.createVNode(e.unref(I.IonButton),{onClick:j[12]||(j[12]=H=>ee(_.value))},{default:e.withCtx(()=>[...j[28]||(j[28]=[e.createTextVNode("Save",-1)])]),_:1}),e.createVNode(e.unref(I.IonButton),{fill:"clear",onClick:j[13]||(j[13]=H=>X.value=!1)},{default:e.withCtx(()=>[...j[29]||(j[29]=[e.createTextVNode("Cancel",-1)])]),_:1})])])):e.createCommentVNode("",!0)]),_:1})]),_:1},8,["is-open"]),e.createVNode(e.unref(I.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",ep,[e.createElementVNode("div",tp,[e.unref(S).selectedCount.value>0?(e.openBlock(),e.createElementBlock("span",np,[e.createTextVNode(e.toDisplayString(e.unref(S).selectedCount.value)+" selected ",1),t.maxSelection?(e.openBlock(),e.createElementBlock("span",op," / "+e.toDisplayString(t.maxSelection)+" max ",1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("span",ap," Select "+e.toDisplayString(t.selectionMode==="multiple"?"items":"an item"),1))]),e.createElementVNode("div",rp,[e.createVNode(e.unref(I.IonButton),{fill:"clear",onClick:O},{default:e.withCtx(()=>[...j[30]||(j[30]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(I.IonButton),{disabled:V.value,onClick:P},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString($.value),1)]),_:1},8,["disabled"])])])]),_:1})]),_:1})]),_:1},8,["is-open"])}}}),sp=_e(ip,[["__scopeId","data-v-9a8c0954"]]),lp={key:1,class:"flex flex-col items-center justify-center py-16"},cp=["draggable","onDragstart","onDragover","onDrop"],dp={key:0,class:"absolute top-2 left-2 z-20"},up=["checked","onChange"],mp={key:2,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-move"},pp=["data-media-id"],fp={key:0,class:"w-full h-full flex items-center justify-center"},hp=["src","alt","onError","onLoad"],vp={key:2,class:"w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-700"},gp={class:"text-center"},yp={class:"text-4xl text-gray-400 mb-2"},bp={class:"text-sm font-medium text-gray-500"},wp={class:"absolute inset-0 bg-black/70 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2"},kp=["onClick"],xp=["onClick"],Ep=["onClick"],Sp={class:"p-3"},Vp={class:"text-sm font-medium truncate mb-1"},Cp={class:"text-xs text-gray-600 dark:text-gray-400"},Np={key:0},_p={key:0,class:"text-xs text-gray-500 dark:text-gray-500 mt-1 truncate"},Tp=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=V=>t.selectedItems.some(y=>y.uuid===V.uuid),d=e.computed(()=>{const V=t.columns,y=["grid","gap-4"];switch(V.mobile){case 1:y.push("grid-cols-1");break;case 2:y.push("grid-cols-2");break;case 3:y.push("grid-cols-3");break;case 4:y.push("grid-cols-4");break;default:y.push("grid-cols-2");break}switch(V.sm){case 1:y.push("sm:grid-cols-1");break;case 2:y.push("sm:grid-cols-2");break;case 3:y.push("sm:grid-cols-3");break;case 4:y.push("sm:grid-cols-4");break;case 5:y.push("sm:grid-cols-5");break;default:y.push("sm:grid-cols-3");break}switch(V.md){case 2:y.push("md:grid-cols-2");break;case 3:y.push("md:grid-cols-3");break;case 4:y.push("md:grid-cols-4");break;case 5:y.push("md:grid-cols-5");break;case 6:y.push("md:grid-cols-6");break;default:y.push("md:grid-cols-4");break}switch(V.lg){case 3:y.push("lg:grid-cols-3");break;case 4:y.push("lg:grid-cols-4");break;case 5:y.push("lg:grid-cols-5");break;case 6:y.push("lg:grid-cols-6");break;case 7:y.push("lg:grid-cols-7");break;default:y.push("lg:grid-cols-5");break}switch(V.xl){case 4:y.push("xl:grid-cols-4");break;case 5:y.push("xl:grid-cols-5");break;case 6:y.push("xl:grid-cols-6");break;case 7:y.push("xl:grid-cols-7");break;case 8:y.push("xl:grid-cols-8");break;default:y.push("xl:grid-cols-6");break}return y.join(" ")});function u(V,y,C){t.reorderable&&(r.value=y,V.dataTransfer&&(V.dataTransfer.effectAllowed="move",V.dataTransfer.setData("text/html","")))}function p(V,y){t.reorderable&&(V.preventDefault(),i.value=y)}function m(){i.value=null}function h(V,y){if(!t.reorderable||!r.value)return;V.preventDefault();const C=[...t.mediaItems],D=C.findIndex(k=>{var T;return k.uuid===((T=r.value)==null?void 0:T.uuid)});if(D!==-1&&D!==y&&r.value){const[k]=C.splice(D,1);C.splice(y,0,k),a("reorder",C)}r.value=null,i.value=null}function v(V){return V<1024?V+" B":V<1024*1024?(V/1024).toFixed(1)+" KB":(V/(1024*1024)).toFixed(1)+" MB"}function b(V){var C;return V.thumbnail_url||((C=V.conversion_urls)==null?void 0:C.thumb)||V.original_url||V.url||""}function x(V){var D,k,T;const y=((D=V.mime_type)==null?void 0:D.startsWith("image/"))||!1,C=!!(V.thumbnail_url||(k=V.conversion_urls)!=null&&k.thumb||(T=V.conversion_urls)!=null&&T.preview||V.original_url||V.url);return y&&C}function R(V){var y;return((y=V.split(".").pop())==null?void 0:y.toUpperCase())||""}function S(V){var C;const y=((C=V.mime_type)==null?void 0:C.toLowerCase())||"";return y.startsWith("image/")?"image":y.startsWith("video/")?"videocam":y.startsWith("audio/")?"musical-notes":y.includes("pdf")?"document-text":y.includes("zip")||y.includes("rar")?"archive":y.includes("sheet")||y.includes("excel")?"grid":y.includes("document")||y.includes("word")?"document-text":"document"}e.onMounted(()=>{typeof window<"u"&&"IntersectionObserver"in window&&(l.value=new IntersectionObserver(V=>{V.forEach(y=>{var C;if(y.isIntersecting){const D=y.target.getAttribute("data-media-id");D&&(s.value.add(D),(C=l.value)==null||C.unobserve(y.target))}})},{rootMargin:"50px"}))}),e.onUnmounted(()=>{l.value&&l.value.disconnect()});function g(V){return!0}function f(){l.value&&e.nextTick(()=>{document.querySelectorAll("[data-media-id]").forEach(y=>{var D;const C=y.getAttribute("data-media-id");C&&!s.value.has(C)&&((D=l.value)==null||D.observe(y))})})}e.watch(()=>t.mediaItems,()=>{s.value.clear(),f()},{immediate:!0,deep:!0});function w(V,y){const C=V.target;delete C.dataset.fallbackIndex}function $(V,y){const C=V.target,D=C.closest("[data-media-id]"),k=[y.original_url,y.url,y.thumbnail_url,"preview_url"in y?y.preview_url:void 0].filter(T=>T&&T.trim()!==""&&T!==C.src);if(k.length>0&&C.dataset.fallbackIndex){const T=parseInt(C.dataset.fallbackIndex);if(T<k.length){C.dataset.fallbackIndex=(T+1).toString(),C.src=k[T]||"";return}}else if(k.length>0){C.dataset.fallbackIndex="1",C.src=k[0]||"";return}if(C.style.display="none",D&&!D.querySelector(".media-fallback-icon")){const F=document.createElement("div");F.className="media-fallback-icon w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-800",F.innerHTML=`
|
|
2
|
-
<div class="text-center">
|
|
3
|
-
<div class="text-4xl text-gray-400 mb-2">${S(y)}</div>
|
|
4
|
-
<p class="text-sm font-medium text-gray-500">${R(y.file_name)}</p>
|
|
5
|
-
</div>
|
|
6
|
-
`,D.appendChild(F)}}return(V,y)=>V.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"},[...y[1]||(y[1]=[e.createStaticVNode('<div class="bg-white dark:bg-gray-800 rounded-lg shadow" data-v-f0c343b7><div class="aspect-square bg-gray-200 dark:bg-gray-700 animate-pulse rounded-t-lg" data-v-f0c343b7></div><div class="p-3" data-v-f0c343b7><div class="h-4 bg-gray-200 dark:bg-gray-700 animate-pulse rounded w-3/4 mb-2" data-v-f0c343b7></div><div class="h-3 bg-gray-200 dark:bg-gray-700 animate-pulse rounded w-1/2" data-v-f0c343b7></div></div></div>',1)])])),64))],2)):!V.mediaItems||!V.mediaItems.length?(e.openBlock(),e.createElementBlock("div",lp,[y[2]||(y[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)),y[3]||(y[3]=e.createElementVNode("h3",{class:"text-lg font-medium mb-2"}," No Media Items ",-1)),y[4]||(y[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:y[0]||(y[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(V.mediaItems,(C,D)=>(e.openBlock(),e.createElementBlock("div",{key:C.uuid,class:e.normalizeClass(["relative group",{"ring-2 ring-blue-500 ring-offset-2":i.value===D}]),draggable:V.reorderable,onDragstart:k=>u(k,C),onDragover:k=>p(k,D),onDragleave:m,onDrop:k=>h(k,D)},[V.selectionMode?(e.openBlock(),e.createElementBlock("div",dp,[e.createElementVNode("input",{type:"checkbox",checked:c(C),onChange:k=>a("toggleSelect",C),class:"w-5 h-5 bg-white dark:bg-gray-800 rounded cursor-pointer"},null,40,up)])):e.createCommentVNode("",!0),V.$slots.badge?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["absolute top-2 z-20",V.selectionMode?"left-10":"left-2"])},[e.renderSlot(V.$slots,"badge",{media:C,index:D},void 0,!0)],2)):e.createCommentVNode("",!0),V.reorderable?(e.openBlock(),e.createElementBlock("div",mp,[...y[5]||(y[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},[x(C)&&!g(C.uuid)?(e.openBlock(),e.createElementBlock("div",fp,[...y[6]||(y[6]=[e.createElementVNode("div",{class:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"},null,-1)])])):e.createCommentVNode("",!0),x(C)&&g(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:k=>$(k,C),onLoad:k=>w(k)},null,40,hp)):(e.openBlock(),e.createElementBlock("div",vp,[e.createElementVNode("div",gp,[e.createElementVNode("div",yp,e.toDisplayString(S(C)),1),e.createElementVNode("p",bp,e.toDisplayString(R(C.file_name)),1)])])),e.createElementVNode("div",wp,[e.createElementVNode("button",{onClick:k=>a("preview",C),class:"p-2 bg-white/20 text-white rounded hover:bg-white/30",title:"Preview"},[...y[7]||(y[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,kp),V.showEditButton&&x(C)?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:k=>a("edit",C),class:"p-2 bg-white/20 text-white rounded hover:bg-white/30",title:"Edit"},[...y[8]||(y[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,xp)):e.createCommentVNode("",!0),e.createElementVNode("button",{onClick:k=>a("delete",C.uuid),class:"p-2 bg-red-500/20 text-red-300 rounded hover:bg-red-500/30",title:"Delete"},[...y[9]||(y[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,Ep)])],8,pp),e.createElementVNode("div",Sp,[e.createElementVNode("h4",Vp,e.toDisplayString(C.file_name),1),e.createElementVNode("p",Cp,[e.createTextVNode(e.toDisplayString(v(C.size))+" ",1),C.width&&C.height?(e.openBlock(),e.createElementBlock("span",Np," • "+e.toDisplayString(C.width)+"x"+e.toDisplayString(C.height),1)):e.createCommentVNode("",!0)]),C.caption?(e.openBlock(),e.createElementBlock("p",_p,e.toDisplayString(C.caption),1)):e.createCommentVNode("",!0)])],2)],42,cp))),128))],2))}}),Mp=_e(Tp,[["__scopeId","data-v-f0c343b7"]]),Fp={class:"model-media-manager"},Bp=["accept","multiple"],Ip={class:"flex items-center justify-between mb-4"},Rp={key:0,class:"text-lg font-medium"},Pp={class:"flex gap-2"},$p={key:0,class:"flex items-center justify-center py-8"},zp={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"},Ap={class:"text-gray-600 dark:text-gray-400"},Dp={class:"flex gap-2 mt-4"},Up={key:0,class:"px-2 py-1 bg-blue-500 text-white text-xs font-medium rounded"},Op=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=yt(),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)}),h=e.computed(()=>r.modelMedia.map(B=>B.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 x(){zn({isAdmin:t.mode==="admin"})}async function R(B){await(await I.toastController.create({message:B,duration:3e3,color:"danger",position:"bottom"})).present()}async function S(){if(!s.value)if(s.value=!0,x(),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(B){const _=B instanceof Error?B.message:"Failed to fetch media";a("error",{operation:"fetch",message:_,details:B})}finally{i.value=!1,a("loading",!1)}}}e.watch(()=>r.modelMedia,B=>{s.value&&a("update:media",B)},{deep:!0}),e.watch(()=>[t.mediableType,t.mediableId,t.collection],()=>{s.value=!1,S()}),e.watch(()=>t.mode,()=>{x()}),e.onMounted(()=>{S()}),e.onUnmounted(()=>{r.clearModelContext()});function g(){return r.modelMedia.length>0}function f(){return t.maxFiles===void 0?!1:r.modelMedia.length>=t.maxFiles}function w(B){var X,W,ee;if(!((X=B.mime_type)!=null&&X.startsWith("image/")))return null;const _=B.original_url||B.url||((W=B.conversion_urls)==null?void 0:W.preview)||((ee=B.conversion_urls)==null?void 0:ee.thumb)||B.thumbnail_url;return _&&_.trim()!==""?_:null}function $(){l.value=!0}function V(){var B;(B=p.value)==null||B.click()}function y(){l.value=!1}function C(B){!t.allowEdit||!w(B)||(d.value=B,c.value=!0)}function D(){c.value=!1,d.value=null}async function k(B){if(!d.value)throw new Error("No media selected for editing");const _=d.value,X=t.editMode==="variant";try{u.value=null;const W=await r.saveEditedImage(_.uuid,B,{asVariant:X,name:_.file_name});X||await r.detachMedia(t.mediableType,t.mediableId,_.uuid,t.collection),await r.attachMedia(t.mediableType,t.mediableId,[W.uuid],t.collection),a("edit-complete",{originalMedia:_,editedMedia:W,mode:t.editMode}),c.value=!1,d.value=null}catch(W){const ee=W instanceof Error?W.message:"Failed to save edited image";throw u.value=ee,await R(ee),W}}function T(B){if(u.value===B.message){u.value=null;return}R(B.message)}async function F(B){const _=B.target,X=_.files;if(!(!X||X.length===0)){for(let W=0;W<X.length;W++){const ee=X[W];if(m.value!==void 0&&m.value<=0)break;if(t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0&&!t.acceptedMimeTypes.includes(ee.type)){a("error",{operation:"upload",message:`File type ${ee.type} is not accepted`,details:{file:ee.name}});continue}if(t.maxFileSize!==void 0&&ee.size>t.maxFileSize){a("error",{operation:"upload",message:`File size exceeds limit of ${t.maxFileSize} bytes`,details:{file:ee.name,size:ee.size}});continue}a("upload-progress",{status:"uploading",progress:0,file:ee});try{const he=await r.uploadFile(ee,{collection:t.collection});he!=null&&he.uuid&&(await r.attachMedia(t.mediableType,t.mediableId,[he.uuid],t.collection),a("upload-progress",{status:"complete",progress:100,file:ee}),a("attach",[he]))}catch(he){const Ue=he instanceof Error?he.message:"Upload failed";a("error",{operation:"upload",message:Ue,details:he}),a("upload-progress",{status:"error",progress:0,file:ee,error:Ue})}}_.value=""}}async function A(B){const _=B.map(X=>X.uuid);try{await r.reorderMedia(t.mediableType,t.mediableId,_,t.collection),a("reorder",r.modelMedia)}catch(X){const W=X instanceof Error?X.message:"Failed to reorder media";a("error",{operation:"reorder",message:W,details:X}),await R(W)}}async function P(B){const _=r.modelMedia.find(X=>X.uuid===B);try{await r.detachMedia(t.mediableType,t.mediableId,B,t.collection),_&&a("detach",_)}catch(X){const W=X instanceof Error?X.message:"Failed to detach media";a("error",{operation:"detach",message:W,details:X}),await R(W)}}async function O(B){l.value=!1;const _=B.map(ee=>ee.uuid),X=new Set(h.value);let W=Array.from(new Set(_)).filter(ee=>!X.has(ee));if(m.value!==void 0&&W.length>m.value&&(W=W.slice(0,m.value)),W.length!==0)try{await r.attachMedia(t.mediableType,t.mediableId,W,t.collection);const ee=r.modelMedia.filter(he=>W.includes(he.uuid));a("attach",ee)}catch(ee){const he=ee instanceof Error?ee.message:"Failed to attach media";a("error",{operation:"attach",message:he,details:ee})}}return(B,_)=>(e.openBlock(),e.createElementBlock("div",Fp,[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:F},null,40,Bp),e.createElementVNode("div",Ip,[B.title?(e.openBlock(),e.createElementBlock("h3",Rp,e.toDisplayString(B.title),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Pp,[B.allowBrowse?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:0,fill:"outline",size:"small",disabled:f(),"data-testid":"browse-button",onClick:$},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"start",icon:e.unref(lr)},null,8,["icon"]),_[1]||(_[1]=e.createTextVNode(" Browse ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0),B.allowUpload?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:1,fill:"solid",size:"small",disabled:f(),"data-testid":"upload-button",onClick:V},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"start",icon:e.unref(hs)},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",$p,[e.createVNode(e.unref(I.IonSpinner),{"data-testid":"spinner"})])):g()?(e.openBlock(),e.createBlock(Mp,{key:2,"media-items":e.unref(r).modelMedia,reorderable:!!B.allowReorder,"is-loading":i.value||e.unref(r).isLoadingModelMedia,"show-edit-button":!!B.allowEdit,"selection-mode":!1,onReorder:A,onDelete:P,onEdit:C},e.createSlots({_:2},[B.showPrimaryBadge?{name:"badge",fn:e.withCtx(({index:X})=>[X===0?(e.openBlock(),e.createElementBlock("div",Up," Primary ")):e.createCommentVNode("",!0)]),key:"0"}:void 0]),1032,["media-items","reorderable","is-loading","show-edit-button"])):(e.openBlock(),e.createElementBlock("div",zp,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(lr),class:"w-12 h-12 text-gray-400 mb-4"},null,8,["icon"]),e.createElementVNode("p",Ap,e.toDisplayString(B.emptyText),1),e.createElementVNode("div",Dp,[B.allowBrowse?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:0,fill:"outline",size:"small","data-testid":"browse-button-empty",onClick:$},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"start",icon:e.unref(lr)},null,8,["icon"]),_[3]||(_[3]=e.createTextVNode(" Browse Library ",-1))]),_:1})):e.createCommentVNode("",!0),B.allowUpload?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:1,fill:"solid",size:"small","data-testid":"upload-button-empty",onClick:V},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"start",icon:e.unref(hs)},null,8,["icon"]),_[4]||(_[4]=e.createTextVNode(" Upload Files ",-1))]),_:1})):e.createCommentVNode("",!0)])])),e.createVNode(sp,e.mergeProps({"is-open":l.value,"selected-items":h.value,collection:B.collection},m.value!==null&&m.value!==void 0?{maxSelection:m.value}:{},{onConfirm:O,onClose:y}),null,16,["is-open","selected-items","collection"]),e.createVNode(Sl,e.mergeProps({modelValue:c.value,"onUpdate:modelValue":_[0]||(_[0]=X=>c.value=X)},b.value?{initialImage:b.value}:{},{"on-save":k,onCancel:D,onError:T}),null,16,["modelValue"])]))}}),Lp=_e(Op,[["__scopeId","data-v-71504dc3"]]),Wp=["src"],jp={class:"preview-controls"},Xp=["aria-label"],Zp={class:"time-display"},Yp={class:"current-time"},Gp={class:"total-time"},Hp={key:0,class:"fps-display"},Jp={key:0,class:"loading-overlay"},qp={key:1,class:"error-overlay"},Kp=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),h=e.ref(0),v=e.ref(!1);let b,x,R=null,S=null,g=null,f=[],w="",$=null,V=0,y=0,C=0,D=0,k=!1,T=0,F=0,A,P=null,O=!1;const B=e.computed(()=>i.source&&typeof i.source=="string"?i.source:"");async function _(){var de,ye;if(c.value&&!b&&!(!d.value||d.value.readyState<3))try{let L=((de=l.value)==null?void 0:de.clientWidth)||800,oe=((ye=l.value)==null?void 0:ye.clientHeight)||450;if((L<=0||oe<=0)&&(L=d.value.videoWidth||800,oe=d.value.videoHeight||450),b=new Ae.Application,await b.init({width:L,height:oe,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}V=d.value.videoWidth,y=d.value.videoHeight,S=document.createElement("canvas"),S.width=V,S.height=y,g=S.getContext("2d"),g.drawImage(d.value,0,0,V,y);const Q=Ae.Texture.from(S);R=Q.source,x=new Ae.Sprite(Q),x.visible=!0,x.alpha=1,pe(),b.stage.addChild(x),b.renderer&&!b.renderer.destroyed&&b.render()}he(),i.targetFps<60?X():b.ticker.add(W),v.value=!0,"ResizeObserver"in window&&($=new ResizeObserver(Q=>{k||(k=!0,requestAnimationFrame(()=>{k=!1;const te=Q[Q.length-1],{width:xe,height:Ee}=te.contentRect;if(xe<=0||Ee<=0)return;const Re=Math.round(xe),Oe=Math.round(Ee);Re===C&&Oe===D||(C=Re,D=Oe,pe())}))}),$.observe(l.value)),i.filters&&i.filters.length>0&&he(),i.showFps&&ve()}catch{p.value="Failed to initialize video preview"}}function X(){const de=1e3/i.targetFps;let ye=performance.now();function L(){if(O||!b)return;const oe=performance.now(),Q=oe-ye;Q>=de&&(W(),ye=oe-Q%de),P=requestAnimationFrame(L)}P=requestAnimationFrame(L)}function W(){if(!(!b||!x||O)&&i.active)try{g&&S&&R&&d.value&&(d.value.readyState>=2&&(g.drawImage(d.value,0,0,S.width,S.height),R.update()),d.value.paused||s("frame-update",re())),i.showFps&&F++,b.renderer&&!b.renderer.destroyed&&b.render()}catch{O=!0}}function ee(){for(const de of f)try{de.destroy()}catch{}f=[]}function he(){if(x){if(!i.filters||i.filters.length===0){x.filters=null,ee();return}ee(),i.filters.forEach(de=>{const ye=Ue(de);ye&&f.push(ye)}),x.filters=f.length>0?f:null,w=JSON.stringify(i.filters),b&&b.render()}}function Ue(de){const ye=de.filterId,L=de.params||{},oe=xt.getFilter(ye);if(oe&&!xt.isFilterCompatibleWithMedia(ye,"video"))return null;if(oe&&oe.createFilter)try{return oe.createFilter(L)}catch{}const Q=(te,xe,Ee)=>Math.min(Ee,Math.max(xe,te));switch(ye){case"brightness":{const te=new a,xe=Q(typeof L.brightness=="number"?L.brightness:typeof L.value=="number"?L.value:1,0,5);return te.brightness(xe,!0),te}case"contrast":{const te=new a,xe=Q(typeof L.contrast=="number"?L.contrast:typeof L.value=="number"?L.value:1,0,5);return te.contrast(xe,!0),te}case"saturation":{const te=new a,xe=Q(typeof L.saturation=="number"?L.saturation:typeof L.value=="number"?L.value:1,0,5);return te.saturate(xe,!0),te}case"hue":{const te=new a,xe=Q(typeof L.value=="number"?L.value:0,-180,180);return te.hue(xe,!0),te}case"gaussian-blur":case"blur":{const te=Q(typeof L.blur=="number"?L.blur:typeof L.value=="number"?L.value:2,0,10);return new r(te)}case"grayscale":{const te=new a;return te.desaturate(),te}case"sepia":case"color-matrix":{const te=new a;return te.sepia(!0),te}case"vignette":{const te=typeof L.value=="number"?L.value:.3;return Te(Q(te,0,1))}default:return null}}function Te(de){const ye=`
|
|
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,ye,{strength:de})}function re(){var ye;return!b||!x?null:{dataUrl:b.canvas.toDataURL("image/jpeg",.8),timestamp:((ye=d.value)==null?void 0:ye.currentTime)||0,width:V||0,height:y||0}}function M(){var de;m.value=((de=d.value)==null?void 0:de.duration)||0,s("duration-change",m.value)}function j(){u.value=!1,p.value=void 0}function le(){u.value&&(u.value=!1),!v.value&&i.active?_():v.value}function ae(){var ye,L,oe;const de=((ye=d.value)==null?void 0:ye.currentTime)||0;s("frame-update",{dataUrl:null,timestamp:de,width:((L=d.value)==null?void 0:L.videoWidth)||0,height:((oe=d.value)==null?void 0:oe.videoHeight)||0})}function H(){s("play-pause")}function K(de){var L;const ye=de.target;if(ye!=null&&ye.error)switch(ye.error.code){case ye.error.MEDIA_ERR_ABORTED:p.value="Video playback aborted";break;case ye.error.MEDIA_ERR_NETWORK:p.value="Network error loading video";break;case ye.error.MEDIA_ERR_DECODE:p.value="Video format not supported";break;case ye.error.MEDIA_ERR_SRC_NOT_SUPPORTED:p.value=`Video source not supported: ${(L=ye.src)==null?void 0:L.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 ce(de){d.value&&(d.value.currentTime=Math.max(0,Math.min(de,m.value)))}function ve(){A=window.setInterval(()=>{const de=performance.now(),ye=de-T;h.value=Math.round(F*1e3/ye),F=0,T=de},1e3)}function ke(de){const ye=Math.floor(de/60),L=Math.floor(de%60);return`${ye.toString().padStart(2,"0")}:${L.toString().padStart(2,"0")}`}function ne(){p.value=void 0,u.value=!0,d.value&&d.value.load()}function we(){b&&(k||(k=!0,requestAnimationFrame(()=>{k=!1,pe()})))}function pe(){if(!b||!x||!V||!y||!l.value)return;const de=Math.round(l.value.clientWidth),ye=Math.round(l.value.clientHeight);if(de<=0||ye<=0)return;b.renderer.resize(de,ye);const L=b.screen.width/V,oe=b.screen.height/y;let Q=1;switch(i.fitMode){case"cover":Q=Math.max(L,oe);break;case"none":Q=1;break;case"contain":default:Q=Math.min(L,oe);break}x.scale.set(Q),x.anchor.set(.5),x.position.set(b.screen.width/2,b.screen.height/2),x.visible=!0,x.alpha=1,b.renderer&&!b.renderer.destroyed&&b.render()}e.watch(()=>i.filters,()=>{v.value&&he()},{deep:!0}),e.watch(()=>i.active,async de=>{if(de&&!b&&d.value&&d.value.readyState>=2){await _();return}b&&(de&&(await e.nextTick(),l.value&&l.value.getBoundingClientRect(),x&&g&&S&&R&&(d.value&&d.value.readyState>=2&&(g.drawImage(d.value,0,0,S.width,S.height),R.update()),pe(),b.renderer&&!b.renderer.destroyed&&b.render())),i.targetFps>=60&&b.ticker&&(de?b.ticker.start():b.ticker.stop()))}),e.watch(B,de=>{de?(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}),e.watch(()=>i.isPlaying,de=>{d.value&&(de?d.value.play():d.value.pause())}),e.watch(()=>i.playhead,de=>{d.value&&Math.abs(d.value.currentTime-de)>.5&&ce(de)}),e.watch(()=>i.fitMode,()=>{pe()}),e.onMounted(()=>{O=!1,e.nextTick(()=>{l.value&&l.value.getBoundingClientRect(),d.value}),window.addEventListener("resize",we),T=performance.now(),e.nextTick(()=>{d.value&&d.value.readyState>=2&&!v.value&&_()})}),e.onUnmounted(()=>{if(O=!0,P&&(cancelAnimationFrame(P),P=null),window.removeEventListener("resize",we),$&&($.disconnect(),$=null),A&&clearInterval(A),b&&b.ticker&&(b.ticker.stop(),b.ticker.remove(W)),b){try{b.destroy(!0,{children:!0,texture:!0})}catch{}b=null}f.forEach(de=>{try{de.destroy()}catch{}}),f=[],x=null,R=null,S=null,g=null,d.value&&(d.value.pause(),d.value.removeAttribute("src"),d.value.load())});async function qe(de){if(!await rt()||!d.value||!g||!S||!R)return null;const L=d.value,oe=Number.isFinite(m.value)&&m.value>0?m.value:Number.isFinite(L.duration)&&L.duration>0?L.duration:0,Q=Math.max(0,Math.min(de,oe));await new Promise(te=>{let xe=!1,Ee=0;const Re=()=>{xe||(xe=!0,L.removeEventListener("seeked",Oe),window.clearTimeout(Ee),te())},Oe=()=>{Re()},G=Number.isFinite(L.currentTime)?L.currentTime:0;if(Math.abs(G-Q)<.016){requestAnimationFrame(()=>Re());return}L.addEventListener("seeked",Oe),Ee=window.setTimeout(()=>Re(),700),L.currentTime=Q});try{g.drawImage(L,0,0,S.width,S.height),R.update(),b.render()}catch{return null}return b.canvas}async function rt(){if(!d.value)return!1;if(!b){if(!(d.value.readyState>=2))return!1;await _()}if(!b||!x||!g||!S||!R)return!1;if(i.filters&&i.filters.length>0){const de=x.filters,ye=Array.isArray(de)?de.length:0,oe=JSON.stringify(i.filters)!==w;(ye===0||ye!==i.filters.length||oe)&&he()}return await e.nextTick(),await new Promise(de=>{requestAnimationFrame(()=>de())}),!0}return o({captureFrameAt:qe,ensureReadyForCapture:rt,duration:m,pixiCanvas:e.computed(()=>b?b.canvas:null),videoElement:e.computed(()=>d.value??null)}),(de,ye)=>(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:B.value,onLoadedmetadata:M,onLoadeddata:j,onCanplay:le,onTimeupdate:ae,onEnded:H,onError:K,style:e.normalizeStyle({display:v.value?"none":"block",position:"relative",width:"100%",height:"100%",objectFit:de.fitMode}),crossorigin:"anonymous",playsinline:"",controls:""},null,44,Wp),e.createElementVNode("div",jp,[e.createElementVNode("button",{class:"play-button",onClick:ye[0]||(ye[0]=L=>de.$emit("play-pause")),"aria-label":de.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(I.IonIcon),{icon:de.isPlaying?e.unref(_l):e.unref(Tl)},null,8,["icon"])],8,Xp),e.createElementVNode("div",Zp,[e.createElementVNode("span",Yp,e.toDisplayString(ke(de.playhead)),1),ye[1]||(ye[1]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",Gp,e.toDisplayString(ke(m.value)),1)]),de.showFps?(e.openBlock(),e.createElementBlock("div",Hp,e.toDisplayString(h.value)+" FPS ",1)):e.createCommentVNode("",!0)]),u.value?(e.openBlock(),e.createElementBlock("div",Jp,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"}),ye[2]||(ye[2]=e.createElementVNode("p",null,"Loading video...",-1))])):e.createCommentVNode("",!0),p.value?(e.openBlock(),e.createElementBlock("div",qp,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Zr)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(p.value),1),e.createElementVNode("button",{onClick:ne},"Retry")])):e.createCommentVNode("",!0)],512))}}),ks=_e(Kp,[["__scopeId","data-v-2b187920"]]);var Yr=(n,o,t)=>{if(!o.has(n))throw TypeError("Cannot "+t)},z=(n,o,t)=>(Yr(n,o,"read from private field"),t?t.call(n):o.get(n)),Be=(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)=>(Yr(n,o,"write to private field"),o.set(n,t),t),Qp=(n,o,t,a)=>({set _(r){nt(n,o,r)},get _(){return z(n,o,a)}}),$e=(n,o,t)=>(Yr(n,o,"access private method"),t),ze=new Uint8Array(8),Xt=new DataView(ze.buffer),Qe=n=>[(n%256+256)%256],De=n=>(Xt.setUint16(0,n,!1),[ze[0],ze[1]]),ef=n=>(Xt.setInt16(0,n,!1),[ze[0],ze[1]]),Il=n=>(Xt.setUint32(0,n,!1),[ze[1],ze[2],ze[3]]),ge=n=>(Xt.setUint32(0,n,!1),[ze[0],ze[1],ze[2],ze[3]]),tf=n=>(Xt.setInt32(0,n,!1),[ze[0],ze[1],ze[2],ze[3]]),wn=n=>(Xt.setUint32(0,Math.floor(n/2**32),!1),Xt.setUint32(4,n,!1),[ze[0],ze[1],ze[2],ze[3],ze[4],ze[5],ze[6],ze[7]]),Gr=n=>(Xt.setInt16(0,2**8*n,!1),[ze[0],ze[1]]),Lt=n=>(Xt.setInt32(0,2**16*n,!1),[ze[0],ze[1],ze[2],ze[3]]),dr=n=>(Xt.setInt32(0,2**30*n,!1),[ze[0],ze[1],ze[2],ze[3]]),St=(n,o=!1)=>{let t=Array(n.length).fill(null).map((a,r)=>n.charCodeAt(r));return o&&t.push(0),t},da=n=>n&&n[n.length-1],Hr=n=>{let o;for(let t of n)(!o||t.presentationTimestamp>o.presentationTimestamp)&&(o=t);return o},jt=(n,o,t=!0)=>{let a=n*o;return t?Math.round(a):a},Rl=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]},Pl=Rl(0),$l=n=>[Lt(n[0]),Lt(n[1]),dr(n[2]),Lt(n[3]),Lt(n[4]),dr(n[5]),Lt(n[6]),Lt(n[7]),dr(n[8])],co=n=>!n||typeof n!="object"?n:Array.isArray(n)?n.map(co):Object.fromEntries(Object.entries(n).map(([o,t])=>[o,co(t)])),An=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),Il(t),a??[]],r),nf=n=>{let o=512;return n.fragmented?Je("ftyp",[St("iso5"),ge(o),St("iso5"),St("iso6"),St("mp41")]):Je("ftyp",[St("isom"),ge(o),St("isom"),n.holdsAvc?St("avc1"):[],St("mp41")])},Er=n=>({type:"mdat",largeSize:n}),of=n=>({type:"free",size:n}),Ko=(n,o,t=!1)=>Je("moov",null,[af(o,n),...n.map(a=>rf(a,o)),t?zf(n):null]),af=(n,o)=>{let t=jt(Math.max(0,...o.filter(s=>s.samples.length>0).map(s=>{const l=Hr(s.samples);return l.presentationTimestamp+l.duration})),Cr),a=Math.max(...o.map(s=>s.id))+1,r=!An(n)||!An(t),i=r?wn:ge;return je("mvhd",+r,0,[i(n),i(n),ge(Cr),i(t),Lt(1),Gr(1),Array(10).fill(0),$l(Pl),Array(24).fill(0),ge(a)])},rf=(n,o)=>Je("trak",null,[sf(n,o),lf(n,o)]),sf=(n,o)=>{let t=Hr(n.samples),a=jt(t?t.presentationTimestamp+t.duration:0,Cr),r=!An(o)||!An(a),i=r?wn:ge,s;return n.info.type==="video"?s=typeof n.info.rotation=="number"?Rl(n.info.rotation):n.info.rotation:s=Pl,je("tkhd",+r,3,[i(o),i(o),ge(n.id),ge(0),i(a),Array(8).fill(0),De(0),De(0),Gr(n.info.type==="audio"?1:0),De(0),$l(s),Lt(n.info.type==="video"?n.info.width:0),Lt(n.info.type==="video"?n.info.height:0)])},lf=(n,o)=>Je("mdia",null,[cf(n,o),df(n.info.type==="video"?"vide":"soun"),uf(n)]),cf=(n,o)=>{let t=Hr(n.samples),a=jt(t?t.presentationTimestamp+t.duration:0,n.timescale),r=!An(o)||!An(a),i=r?wn:ge;return je("mdhd",+r,0,[i(o),i(o),ge(n.timescale),i(a),De(21956),De(0)])},df=n=>je("hdlr",0,0,[St("mhlr"),St(n),ge(0),ge(0),ge(0),St("mp4-muxer-hdlr",!0)]),uf=n=>Je("minf",null,[n.info.type==="video"?mf():pf(),ff(),gf(n)]),mf=()=>je("vmhd",0,1,[De(0),De(0),De(0),De(0)]),pf=()=>je("smhd",0,0,[De(0),De(0)]),ff=()=>Je("dinf",null,[hf()]),hf=()=>je("dref",0,0,[ge(1)],[vf()]),vf=()=>je("url ",0,1),gf=n=>{const o=n.compositionTimeOffsetTable.length>1||n.compositionTimeOffsetTable.some(t=>t.sampleCompositionTimeOffset!==0);return Je("stbl",null,[yf(n),Ff(n),Bf(n),If(n),Rf(n),Pf(n),o?$f(n):null])},yf=n=>je("stsd",0,0,[ge(1)],[n.info.type==="video"?bf(Yf[n.info.codec],n):_f(Hf[n.info.codec],n)]),bf=(n,o)=>Je(n,[Array(6).fill(0),De(1),De(0),De(0),Array(12).fill(0),De(o.info.width),De(o.info.height),ge(4718592),ge(4718592),ge(0),De(1),Array(32).fill(0),De(24),ef(65535)],[Gf[o.info.codec](o),o.info.decoderConfig.colorSpace?Ef(o):null]),wf={bt709:1,bt470bg:5,smpte170m:6},kf={bt709:1,smpte170m:6,"iec61966-2-1":13},xf={rgb:0,bt709:1,bt470bg:5,smpte170m:6},Ef=n=>Je("colr",[St("nclx"),De(wf[n.info.decoderConfig.colorSpace.primaries]),De(kf[n.info.decoderConfig.colorSpace.transfer]),De(xf[n.info.decoderConfig.colorSpace.matrix]),Qe((n.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),Sf=n=>n.info.decoderConfig&&Je("avcC",[...new Uint8Array(n.info.decoderConfig.description)]),Vf=n=>n.info.decoderConfig&&Je("hvcC",[...new Uint8Array(n.info.decoderConfig.description)]),Cf=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),De(0)])},Nf=()=>{let t=(1<<7)+1;return Je("av1C",[t,0,0,0])},_f=(n,o)=>Je(n,[Array(6).fill(0),De(1),De(0),De(0),ge(0),De(o.info.numberOfChannels),De(16),De(0),De(0),Lt(o.info.sampleRate)],[Jf[o.info.codec](o)]),Tf=n=>{let o=new Uint8Array(n.info.decoderConfig.description);return je("esds",0,0,[ge(58753152),Qe(32+o.byteLength),De(1),Qe(0),ge(75530368),Qe(18+o.byteLength),Qe(64),Qe(21),Il(0),ge(130071),ge(130071),ge(92307584),Qe(o.byteLength),...o,ge(109084800),Qe(1),Qe(2)])},Mf=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),De(o),ge(n.info.sampleRate),Gr(t),Qe(0)])},Ff=n=>je("stts",0,0,[ge(n.timeToSampleTable.length),n.timeToSampleTable.map(o=>[ge(o.sampleCount),ge(o.sampleDelta)])]),Bf=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,[ge(o.length),o.map(([t])=>ge(t+1))])},If=n=>je("stsc",0,0,[ge(n.compactlyCodedChunkTable.length),n.compactlyCodedChunkTable.map(o=>[ge(o.firstChunk),ge(o.samplesPerChunk),ge(1)])]),Rf=n=>je("stsz",0,0,[ge(0),ge(n.samples.length),n.samples.map(o=>ge(o.size))]),Pf=n=>n.finalizedChunks.length>0&&da(n.finalizedChunks).offset>=2**32?je("co64",0,0,[ge(n.finalizedChunks.length),n.finalizedChunks.map(o=>wn(o.offset))]):je("stco",0,0,[ge(n.finalizedChunks.length),n.finalizedChunks.map(o=>ge(o.offset))]),$f=n=>je("ctts",0,0,[ge(n.compositionTimeOffsetTable.length),n.compositionTimeOffsetTable.map(o=>[ge(o.sampleCount),ge(o.sampleCompositionTimeOffset)])]),zf=n=>Je("mvex",null,n.map(Af)),Af=n=>je("trex",0,0,[ge(n.id),ge(1),ge(0),ge(0),ge(0)]),xs=(n,o)=>Je("moof",null,[Df(n),...o.map(Uf)]),Df=n=>je("mfhd",0,0,[ge(n)]),zl=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},Uf=n=>Je("traf",null,[Of(n),Lf(n),Wf(n)]),Of=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:zl(t)};return je("tfhd",0,o,[ge(n.id),ge(a.duration),ge(a.size),ge(a.flags)])},Lf=n=>je("tfdt",1,0,[wn(jt(n.currentChunk.startTimestamp,n.timescale))]),Wf=n=>{let o=n.currentChunk.samples.map(b=>b.timescaleUnitsToNextSample),t=n.currentChunk.samples.map(b=>b.size),a=n.currentChunk.samples.map(zl),r=n.currentChunk.samples.map(b=>jt(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,h=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*+h,je("trun",1,v,[ge(n.currentChunk.samples.length),ge(n.currentChunk.offset-n.currentChunk.moofOffset||0),d?ge(a[0]):[],n.currentChunk.samples.map((b,x)=>[u?ge(o[x]):[],p?ge(t[x]):[],m?ge(a[x]):[],h?tf(r[x]):[]])])},jf=n=>Je("mfra",null,[...n.map(Xf),Zf()]),Xf=(n,o)=>je("tfra",1,0,[ge(n.id),ge(63),ge(n.finalizedChunks.length),n.finalizedChunks.map(a=>[wn(jt(a.startTimestamp,n.timescale)),wn(a.moofOffset),ge(o+1),ge(1),ge(1)])]),Zf=()=>je("mfro",0,0,[ge(0)]),Yf={avc:"avc1",hevc:"hvc1",vp9:"vp09",av1:"av01"},Gf={avc:Sf,hevc:Vf,vp9:Cf,av1:Nf},Hf={aac:"mp4a",opus:"Opus"},Jf={aac:Tf,opus:Mf},Sa=class{},Jr=class extends Sa{constructor(){super(...arguments),this.buffer=null}},Al=class extends Sa{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.")}},qf=class extends Sa{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")}},dn,In,Dl=class{constructor(){this.pos=0,Be(this,dn,new Uint8Array(8)),Be(this,In,new DataView(z(this,dn).buffer)),this.offsets=new WeakMap}seek(n){this.pos=n}writeU32(n){z(this,In).setUint32(0,n,!1),this.write(z(this,dn).subarray(0,4))}writeU64(n){z(this,In).setUint32(0,Math.floor(n/2**32),!1),z(this,In).setUint32(4,n,!1),this.write(z(this,dn).subarray(0,8))}writeAscii(n){for(let o=0;o<n.length;o++)z(this,In).setUint8(o%8,n.charCodeAt(o)),o%8===7&&this.write(z(this,dn));n.length%8!==0&&this.write(z(this,dn).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}}};dn=new WeakMap;In=new WeakMap;var Qo,yn,yo,ao,ea,Sr,Kf=class extends Dl{constructor(n){super(),Be(this,ea),Be(this,Qo,void 0),Be(this,yn,new ArrayBuffer(2**16)),Be(this,yo,new Uint8Array(z(this,yn))),Be(this,ao,0),nt(this,Qo,n)}write(n){$e(this,ea,Sr).call(this,this.pos+n.byteLength),z(this,yo).set(n,this.pos),this.pos+=n.byteLength,nt(this,ao,Math.max(z(this,ao),this.pos))}finalize(){$e(this,ea,Sr).call(this,this.pos),z(this,Qo).buffer=z(this,yn).slice(0,Math.max(z(this,ao),this.pos))}};Qo=new WeakMap;yn=new WeakMap;yo=new WeakMap;ao=new WeakMap;ea=new WeakSet;Sr=function(n){let o=z(this,yn).byteLength;for(;o<n;)o*=2;if(o===z(this,yn).byteLength)return;let t=new ArrayBuffer(o),a=new Uint8Array(t);a.set(z(this,yo),0),nt(this,yn,t),nt(this,yo,a)};var Qf=2**24,eh=2,uo,un,ro,qt,kt,ua,Vr,qr,Ul,Kr,Ol,mo,ma,Qr=class extends Dl{constructor(n){var o,t;super(),Be(this,ua),Be(this,qr),Be(this,Kr),Be(this,mo),Be(this,uo,void 0),Be(this,un,[]),Be(this,ro,void 0),Be(this,qt,void 0),Be(this,kt,[]),nt(this,uo,n),nt(this,ro,((o=n.options)==null?void 0:o.chunked)??!1),nt(this,qt,((t=n.options)==null?void 0:t.chunkSize)??Qf)}write(n){z(this,un).push({data:n.slice(),start:this.pos}),this.pos+=n.byteLength}flush(){var t,a;if(z(this,un).length===0)return;let n=[],o=[...z(this,un)].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 z(this,un))r.start<=i.start&&i.start<r.start+r.size&&r.data.set(i.data,i.start-r.start);z(this,ro)?($e(this,ua,Vr).call(this,r.data,r.start),$e(this,mo,ma).call(this)):(a=(t=z(this,uo).options).onData)==null||a.call(t,r.data,r.start)}z(this,un).length=0}finalize(){z(this,ro)&&$e(this,mo,ma).call(this,!0)}};uo=new WeakMap;un=new WeakMap;ro=new WeakMap;qt=new WeakMap;kt=new WeakMap;ua=new WeakSet;Vr=function(n,o){let t=z(this,kt).findIndex(l=>l.start<=o&&o<l.start+z(this,qt));t===-1&&(t=$e(this,Kr,Ol).call(this,o));let a=z(this,kt)[t],r=o-a.start,i=n.subarray(0,Math.min(z(this,qt)-r,n.byteLength));a.data.set(i,r);let s={start:r,end:r+i.byteLength};if($e(this,qr,Ul).call(this,a,s),a.written[0].start===0&&a.written[0].end===z(this,qt)&&(a.shouldFlush=!0),z(this,kt).length>eh){for(let l=0;l<z(this,kt).length-1;l++)z(this,kt)[l].shouldFlush=!0;$e(this,mo,ma).call(this)}i.byteLength<n.byteLength&&$e(this,ua,Vr).call(this,n.subarray(i.byteLength),o+i.byteLength)};qr=new WeakSet;Ul=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)};Kr=new WeakSet;Ol=function(n){let t={start:Math.floor(n/z(this,qt))*z(this,qt),data:new Uint8Array(z(this,qt)),written:[],shouldFlush:!1};return z(this,kt).push(t),z(this,kt).sort((a,r)=>a.start-r.start),z(this,kt).indexOf(t)};mo=new WeakSet;ma=function(n=!1){var o,t;for(let a=0;a<z(this,kt).length;a++){let r=z(this,kt)[a];if(!(!r.shouldFlush&&!n)){for(let i of r.written)(t=(o=z(this,uo).options).onData)==null||t.call(o,r.data.subarray(i.start,i.end),r.start+i.start);z(this,kt).splice(a--,1)}}};var th=class extends Qr{constructor(n){var o;super(new Al({onData:(t,a)=>n.stream.write({type:"write",data:t,position:a}),chunked:!0,chunkSize:(o=n.options)==null?void 0:o.chunkSize}))}},Cr=1e3,nh=["avc","hevc","vp9","av1"],oh=["aac","opus"],ah=2082844800,rh=["strict","offset","cross-track-offset"],Ve,Ce,pa,bt,at,tt,Rn,Pn,ei,mn,pn,po,Nr,Ll,_r,Wl,ti,jl,Tr,Xl,ni,Zl,ta,Mr,Dt,Jt,oi,Yl,fo,fa,ha,ai,Dn,xo,na,Fr,Gl=class{constructor(n){if(Be(this,Nr),Be(this,_r),Be(this,ti),Be(this,Tr),Be(this,ni),Be(this,ta),Be(this,Dt),Be(this,oi),Be(this,fo),Be(this,ha),Be(this,Dn),Be(this,na),Be(this,Ve,void 0),Be(this,Ce,void 0),Be(this,pa,void 0),Be(this,bt,void 0),Be(this,at,null),Be(this,tt,null),Be(this,Rn,Math.floor(Date.now()/1e3)+ah),Be(this,Pn,[]),Be(this,ei,1),Be(this,mn,[]),Be(this,pn,[]),Be(this,po,!1),$e(this,Nr,Ll).call(this,n),n.video=co(n.video),n.audio=co(n.audio),n.fastStart=co(n.fastStart),this.target=n.target,nt(this,Ve,{firstTimestampBehavior:"strict",...n}),n.target instanceof Jr)nt(this,Ce,new Kf(n.target));else if(n.target instanceof Al)nt(this,Ce,new Qr(n.target));else if(n.target instanceof qf)nt(this,Ce,new th(n.target));else throw new Error(`Invalid target: ${n.target}`);$e(this,Tr,Xl).call(this),$e(this,_r,Wl).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($e(this,na,Fr).call(this),!z(this,Ve).video)throw new Error("No video track declared.");if(typeof z(this,Ve).fastStart=="object"&&z(this,at).samples.length===z(this,Ve).fastStart.expectedVideoChunks)throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${z(this,Ve).fastStart.expectedVideoChunks}).`);let s=$e(this,ta,Mr).call(this,z(this,at),n,o,t,a,r,i);if(z(this,Ve).fastStart==="fragmented"&&z(this,tt)){for(;z(this,pn).length>0&&z(this,pn)[0].decodeTimestamp<=s.decodeTimestamp;){let l=z(this,pn).shift();$e(this,Dt,Jt).call(this,z(this,tt),l)}s.decodeTimestamp<=z(this,tt).lastDecodeTimestamp?$e(this,Dt,Jt).call(this,z(this,at),s):z(this,mn).push(s)}else $e(this,Dt,Jt).call(this,z(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($e(this,na,Fr).call(this),!z(this,Ve).audio)throw new Error("No audio track declared.");if(typeof z(this,Ve).fastStart=="object"&&z(this,tt).samples.length===z(this,Ve).fastStart.expectedAudioChunks)throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${z(this,Ve).fastStart.expectedAudioChunks}).`);let i=$e(this,ta,Mr).call(this,z(this,tt),n,o,t,a,r);if(z(this,Ve).fastStart==="fragmented"&&z(this,at)){for(;z(this,mn).length>0&&z(this,mn)[0].decodeTimestamp<=i.decodeTimestamp;){let s=z(this,mn).shift();$e(this,Dt,Jt).call(this,z(this,at),s)}i.decodeTimestamp<=z(this,at).lastDecodeTimestamp?$e(this,Dt,Jt).call(this,z(this,tt),i):z(this,pn).push(i)}else $e(this,Dt,Jt).call(this,z(this,tt),i)}finalize(){if(z(this,po))throw new Error("Cannot finalize a muxer more than once.");if(z(this,Ve).fastStart==="fragmented"){for(let o of z(this,mn))$e(this,Dt,Jt).call(this,z(this,at),o);for(let o of z(this,pn))$e(this,Dt,Jt).call(this,z(this,tt),o);$e(this,ha,ai).call(this,!1)}else z(this,at)&&$e(this,fo,fa).call(this,z(this,at)),z(this,tt)&&$e(this,fo,fa).call(this,z(this,tt));let n=[z(this,at),z(this,tt)].filter(Boolean);if(z(this,Ve).fastStart==="in-memory"){let o;for(let a=0;a<2;a++){let r=Ko(n,z(this,Rn)),i=z(this,Ce).measureBox(r);o=z(this,Ce).measureBox(z(this,bt));let s=z(this,Ce).pos+i+o;for(let l of z(this,Pn)){l.offset=s;for(let{data:c}of l.samples)s+=c.byteLength,o+=c.byteLength}if(s<2**32)break;o>=2**32&&(z(this,bt).largeSize=!0)}let t=Ko(n,z(this,Rn));z(this,Ce).writeBox(t),z(this,bt).size=o,z(this,Ce).writeBox(z(this,bt));for(let a of z(this,Pn))for(let r of a.samples)z(this,Ce).write(r.data),r.data=null}else if(z(this,Ve).fastStart==="fragmented"){let o=z(this,Ce).pos,t=jf(n);z(this,Ce).writeBox(t);let a=z(this,Ce).pos-o;z(this,Ce).seek(z(this,Ce).pos-4),z(this,Ce).writeU32(a)}else{let o=z(this,Ce).offsets.get(z(this,bt)),t=z(this,Ce).pos-o;z(this,bt).size=t,z(this,bt).largeSize=t>=2**32,z(this,Ce).patchBox(z(this,bt));let a=Ko(n,z(this,Rn));if(typeof z(this,Ve).fastStart=="object"){z(this,Ce).seek(z(this,pa)),z(this,Ce).writeBox(a);let r=o-z(this,Ce).pos;z(this,Ce).writeBox(of(r))}else z(this,Ce).writeBox(a)}$e(this,Dn,xo).call(this),z(this,Ce).finalize(),nt(this,po,!0)}};Ve=new WeakMap;Ce=new WeakMap;pa=new WeakMap;bt=new WeakMap;at=new WeakMap;tt=new WeakMap;Rn=new WeakMap;Pn=new WeakMap;ei=new WeakMap;mn=new WeakMap;pn=new WeakMap;po=new WeakMap;Nr=new WeakSet;Ll=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 Sa))throw new TypeError("The target must be provided and an instance of Target.");if(n.video){if(!nh.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(!oh.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&&!rh.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.")};_r=new WeakSet;Wl=function(){var n;if(z(this,Ce).writeBox(nf({holdsAvc:((n=z(this,Ve).video)==null?void 0:n.codec)==="avc",fragmented:z(this,Ve).fastStart==="fragmented"})),nt(this,pa,z(this,Ce).pos),z(this,Ve).fastStart==="in-memory")nt(this,bt,Er(!1));else if(z(this,Ve).fastStart!=="fragmented"){if(typeof z(this,Ve).fastStart=="object"){let o=$e(this,ti,jl).call(this);z(this,Ce).seek(z(this,Ce).pos+o)}nt(this,bt,Er(!0)),z(this,Ce).writeBox(z(this,bt))}$e(this,Dn,xo).call(this)};ti=new WeakSet;jl=function(){if(typeof z(this,Ve).fastStart!="object")return;let n=0,o=[z(this,Ve).fastStart.expectedVideoChunks,z(this,Ve).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};Tr=new WeakSet;Xl=function(){if(z(this,Ve).video&&nt(this,at,{id:1,info:{type:"video",codec:z(this,Ve).video.codec,width:z(this,Ve).video.width,height:z(this,Ve).video.height,rotation:z(this,Ve).video.rotation??0,decoderConfig:null},timescale:z(this,Ve).video.frameRate??57600,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),z(this,Ve).audio&&(nt(this,tt,{id:z(this,Ve).video?2:1,info:{type:"audio",codec:z(this,Ve).audio.codec,numberOfChannels:z(this,Ve).audio.numberOfChannels,sampleRate:z(this,Ve).audio.sampleRate,decoderConfig:null},timescale:z(this,Ve).audio.sampleRate,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),z(this,Ve).audio.codec==="aac")){let n=$e(this,ni,Zl).call(this,2,z(this,Ve).audio.sampleRate,z(this,Ve).audio.numberOfChannels);z(this,tt).info.decoderConfig={codec:z(this,Ve).audio.codec,description:n,numberOfChannels:z(this,Ve).audio.numberOfChannels,sampleRate:z(this,Ve).audio.sampleRate}}};ni=new WeakSet;Zl=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};ta=new WeakSet;Mr=function(n,o,t,a,r,i,s){let l=a/1e6,c=(a-(s??0))/1e6,d=r/1e6,u=$e(this,oi,Yl).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:jt(d,n.timescale)}};Dt=new WeakSet;Jt=function(n,o){z(this,Ve).fastStart!=="fragmented"&&n.samples.push(o);const t=jt(o.presentationTimestamp-o.decodeTimestamp,n.timescale);if(n.lastTimescaleUnits!==null){let r=jt(o.decodeTimestamp,n.timescale,!1),i=Math.round(r-n.lastTimescaleUnits);if(n.lastTimescaleUnits+=i,n.lastSample.timescaleUnitsToNextSample=i,z(this,Ve).fastStart!=="fragmented"){let s=da(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=da(n.compositionTimeOffsetTable);l.sampleCompositionTimeOffset===t?l.sampleCount++:n.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t})}}else n.lastTimescaleUnits=0,z(this,Ve).fastStart!=="fragmented"&&(n.timeToSampleTable.push({sampleCount:1,sampleDelta:jt(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(z(this,Ve).fastStart==="fragmented"){let i=z(this,at)??z(this,tt);const s=z(this,Ve).minFragmentDuration??1;n===i&&o.type==="key"&&r>=s&&(a=!0,$e(this,ha,ai).call(this))}else a=r>=.5}a&&(n.currentChunk&&$e(this,fo,fa).call(this,n),n.currentChunk={startTimestamp:o.presentationTimestamp,samples:[]}),n.currentChunk.samples.push(o)};oi=new WeakSet;Yl=function(n,o,t){var s,l;const a=z(this,Ve).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(z(this,Ve).firstTimestampBehavior==="offset"||z(this,Ve).firstTimestampBehavior==="cross-track-offset"){t.firstDecodeTimestamp===void 0&&(t.firstDecodeTimestamp=o);let c;z(this,Ve).firstTimestampBehavior==="offset"?c=t.firstDecodeTimestamp:c=Math.min(((s=z(this,at))==null?void 0:s.firstDecodeTimestamp)??1/0,((l=z(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}};fo=new WeakSet;fa=function(n){if(z(this,Ve).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),z(this,Pn).push(n.currentChunk),(n.compactlyCodedChunkTable.length===0||da(n.compactlyCodedChunkTable).samplesPerChunk!==n.currentChunk.samples.length)&&n.compactlyCodedChunkTable.push({firstChunk:n.finalizedChunks.length,samplesPerChunk:n.currentChunk.samples.length}),z(this,Ve).fastStart==="in-memory"){n.currentChunk.offset=0;return}n.currentChunk.offset=z(this,Ce).pos;for(let o of n.currentChunk.samples)z(this,Ce).write(o.data),o.data=null;$e(this,Dn,xo).call(this)}};ha=new WeakSet;ai=function(n=!0){if(z(this,Ve).fastStart!=="fragmented")throw new Error("Can't finalize a fragment unless 'fastStart' is set to 'fragmented'.");let o=[z(this,at),z(this,tt)].filter(l=>l&&l.currentChunk);if(o.length===0)return;let t=Qp(this,ei)._++;if(t===1){let l=Ko(o,z(this,Rn),!0);z(this,Ce).writeBox(l)}let a=z(this,Ce).pos,r=xs(t,o);z(this,Ce).writeBox(r);{let l=Er(!1),c=0;for(let u of o)for(let p of u.currentChunk.samples)c+=p.size;let d=z(this,Ce).measureBox(l)+c;d>=2**32&&(l.largeSize=!0,d=z(this,Ce).measureBox(l)+c),l.size=d,z(this,Ce).writeBox(l)}for(let l of o){l.currentChunk.offset=z(this,Ce).pos,l.currentChunk.moofOffset=a;for(let c of l.currentChunk.samples)z(this,Ce).write(c.data),c.data=null}let i=z(this,Ce).pos;z(this,Ce).seek(z(this,Ce).offsets.get(r));let s=xs(t,o);z(this,Ce).writeBox(s),z(this,Ce).seek(i);for(let l of o)l.finalizedChunks.push(l.currentChunk),z(this,Pn).push(l.currentChunk),l.currentChunk=null;n&&$e(this,Dn,xo).call(this)};Dn=new WeakSet;xo=function(){z(this,Ce)instanceof Qr&&z(this,Ce).flush()};na=new WeakSet;Fr=function(){if(z(this,po))throw new Error("Cannot add new video or audio chunks after the file has been finalized.")};const bo=30;class Un extends Error{constructor({message:t="",code:a=""},...r){super(t,...r);U(this,"message");U(this,"code");this.code=a,this.message=t}}class Kt extends Un{}class He extends Un{}class va extends Un{}class Es extends Un{}function ih(n,o=bo){if(o<1)throw new He({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(n*o)}function $n(n,o=bo){if(o<1)throw new He({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(n/o*1e3)}class fe{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 ih(this.millis/1e3)}set frames(o){this.millis=$n(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=$n(o);return this.millis=this.millis+t,this}add(o){return new fe(o.millis+this.millis)}subtract(o){return new fe(this.millis-o.millis)}static fromSeconds(o){const t=new fe;return t.millis=o*1e3,t}static fromFrames(o,t){const a=new fe;return a.millis=$n(o,t),a}copy(){return new fe(this.millis)}toJSON(){return this.millis}static fromJSON(o){return new fe(o)}}function Ss(n,o){return[n.slice(0,o),n.slice(o)].filter(t=>t.length>0)}function oa(n,o){return o?Math.floor(Math.random()*(o-n+1)+n):n}function sh(n,o,t){t<0&&(t=0);const a=n[o];n.splice(o,1),n.splice(t,0,a)}function Vs(n){return typeof n!="function"?!1:/^class\s/.test(Function.prototype.toString.call(n))}function lh(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 ch(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 h=u-p;l[d]=s[p]*(1-h)+s[m]*h}}}return r}async function dh(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(uh)}function uh(n,o){const t=n.hardwareAcceleration??"",a=o.hardwareAcceleration??"";return t<a?-1:t>a?1:0}async function mh(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 Cs(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 Ns(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 Wo{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 fe}get stop(){var o;return((o=this.words.at(-1))==null?void 0:o.stop)??new fe}}var Br=(n=>(n.en="en",n.de="de",n))(Br||{});class _s{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 fe(t),this.stop=new fe(a),this.confidence=r}get duration(){return this.stop.subtract(this.start)}}class hn{constructor(o=[],t=Br.en){U(this,"id",crypto.randomUUID());U(this,"language",Br.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>=oa(...o)?(yield i,i=void 0):t&&(i==null?void 0:i.duration.seconds)>=oa(...t)?(yield i,i=void 0):a&&i.text.length>=oa(...a)&&(yield i,i=void 0)),i?i.words.push(l):i=new Wo([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=Ns(r.start.seconds),s=Ns(r.stop.seconds);a+=`${t}
|
|
22
|
-
`+Cs(i)+" --> "+Cs(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 _s(s.text,s.start.millis-a,s.stop.millis-a)),r.length==o)return new hn([new Wo(r)]);return new hn([new Wo(r)])}copy(){return hn.fromJSON(this.toJSON())}static fromJSON(o){const t=new hn;for(const a of o){const r=new Wo;for(const i of a)r.words.push(new _s(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 Kt({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});return hn.fromJSON(await a.json())}}function aa(n,o,t){return n+(o-n)*t}function ph(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(aa(i,c,t)),m=Math.round(aa(s,d,t)),h=Math.round(aa(l,u,t));return`#${((1<<24)+(p<<16)+(m<<8)+h).toString(16).slice(1)}`}const fh={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=>$n(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=fh[this.options.easing](o);if(typeof a=="number"&&typeof r=="number")return aa(a,r,i);if(typeof a=="string"&&typeof r=="string")return ph(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($n(o)),this.output.push(t),this}toJSON(){return this}static fromJSON(o){const t=new Se([],[]);return Object.assign(t,o),t}}class Vt{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 me(n){return function(o,t){o.constructor.__serializableProperties||(o.constructor.__serializableProperties=[]),o.constructor.__serializableProperties.push({propertyKey:t,serializer:n})}}function Eo(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 ri(n,o,t=0){if(!(n instanceof Le.Container||n instanceof Le.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&&ri(r,o,t+1))}}var hh=Object.defineProperty,Va=(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&&hh(o,t,r),r};const So=class Hl extends Eo(Vt){constructor(t={}){super();U(this,"_name");U(this,"_start",new fe);U(this,"_stop",fe.fromSeconds(16));U(this,"type","base");U(this,"source");U(this,"view",new Le.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",fe.fromFrames(t))):(this.start.addMillis(t.millis),this.stop.addMillis(t.millis),this.trigger("offsetBy",t)),this.trigger("frame",void 0),this}async init(){}enter(){}update(t){}exit(){}detach(){var t;return(t=this.track)==null||t.remove(this),this}async split(t){var i,s;if(t||(t=(s=(i=this.track)==null?void 0:i.composition)==null?void 0:s.frame),typeof t=="number"&&(t=fe.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new 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),ri(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 Hl.fromJSON(JSON.parse(JSON.stringify(this)))}set(t){return t&&Object.assign(this,t),this.trigger("update",void 0),this}};Va([me()],So.prototype,"_name");Va([me(fe)],So.prototype,"_start");Va([me(fe)],So.prototype,"_stop");Va([me()],So.prototype,"disabled");let Vo=So;var vh=Object.defineProperty,xn=(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&&vh(o,t,r),r};class Zt extends Eo(Vt){constructor(){super(...arguments);U(this,"state","IDLE");U(this,"metadata");U(this,"objectURL");U(this,"duration",fe.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=$r(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 Kt({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=$r(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();mh(t,this.name)}async thumbnail(){return document.createElement("div")}static async from(t,a,r=new this){return r.from(t,a)}}xn([me()],Zt.prototype,"objectURL");xn([me()],Zt.prototype,"duration");xn([me()],Zt.prototype,"type");xn([me()],Zt.prototype,"name");xn([me()],Zt.prototype,"mimeType");xn([me()],Zt.prototype,"externalURL");xn([me()],Zt.prototype,"external");const Ts="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E";function gh(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 Ms(n){if(!n||!n.body)return Ts;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 Ts;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,"+gh(d)}class Fs extends Zt{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=Ms(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=Ms(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 yh(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 h=Math.min(p+a,s.length);for(let v=p;v<h;v++)m+=s[v]*s[v];m=Math.sqrt(m/(h-p)),m<t?(u+=a,d===null&&(d=p)):(d!==null&&u>=c&&i.push({start:fe.fromSeconds(d/l),stop:fe.fromSeconds(p/l)}),d=null,u=0)}return d!==null&&u>=c&&i.push({start:fe.fromSeconds(d/l),stop:fe.fromSeconds(s.length/l)}),i}const ur=3e3;class rn extends Zt{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 h=p;h<p+s;h++)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,ur,!0),l=s.getChannelData(0),c=Math.floor(Math.max(a*ur/1e3,0)),d=r?Math.floor(Math.min(r*ur/1e3,s.length)):s.length,u=Math.floor((d-c)/t),p=new Float32Array(t);for(let m=0;m<t;m++){const h=c+m*u,v=h+u;let b=-1/0;for(let x=h;x<v;x++){const R=l[x];R>b&&(b=R)}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=yh(i,t),r.close(),this._silences}}class Ir extends Zt{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 vn extends rn{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 Kt({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});this.name=t.toString().split("/").at(-1)??"",this.external=!0,this.externalURL=t,this.objectURL=String(t),this.mimeType=$r(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 bh{static fromJSON(o){return[new fe(o[0]),new fe(o[1])]}}var wh=Object.defineProperty,kh=Object.getOwnPropertyDescriptor,On=(n,o,t,a)=>{for(var r=a>1?void 0:a?kh(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 En=class Jl extends Vo{constructor(t={}){super();U(this,"source",new rn);U(this,"_offset",new fe);U(this,"playing",!1);U(this,"duration",new fe);U(this,"range",[new fe,this.duration]);Object.assign(this,t)}get transcript(){return this.source.transcript}set transcript(t){this.source.transcript=t}get start(){return this.range[0].add(this.offset)}get stop(){return this.range[1].add(this.offset)}set start(t){typeof t=="number"&&(t=fe.fromFrames(t));const 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=fe.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",fe.fromFrames(t))):(this.offset.addMillis(t.millis),this.trigger("offsetBy",t)),this.trigger("frame",void 0),this}get muted(){var t;return((t=this.element)==null?void 0:t.muted)??!1}set muted(t){this.element&&(this.element.muted=t)}seek(t){return new Promise((a,r)=>{if(!this.element)return r(new Es({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=fe.fromFrames(t)),typeof a=="number"&&(a=fe.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=Jl.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=fe.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 Es({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),ri(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=>Bs(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(!Bs(s,l.range))continue;const c=new fe(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}};On([me(fe)],En.prototype,"_offset",2);On([me(fe)],En.prototype,"duration",2);On([me(bh)],En.prototype,"range",2);On([me(hn)],En.prototype,"transcript",1);On([me()],En.prototype,"muted",1);On([me()],En.prototype,"volume",1);let Ca=En;function Bs(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 jo{static fromJSON(o){return typeof o=="object"?Se.fromJSON(o):o}}class mr{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 xh=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 Eh(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 fe(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 Sh extends xh{}var Vh=Object.defineProperty,Ch=Object.getOwnPropertyDescriptor,nn=(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};function Na(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 Le.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 Le.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 Eh(new Sh(this))}}return nn([me(jo)],o.prototype,"_height",2),nn([me(jo)],o.prototype,"_width",2),nn([me(mr)],o.prototype,"_position",2),nn([me(mr)],o.prototype,"_scale",2),nn([me(jo)],o.prototype,"rotation",2),nn([me(jo)],o.prototype,"alpha",2),nn([me(mr)],o.prototype,"translate",2),nn([me()],o.prototype,"anchor",1),o}function _a(n,o,t){const a=t.value;return t.value=function(...r){var p,m,h,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=(h=this.track)==null?void 0:h.composition)==null?void 0:v.height)??1080};let l;typeof this.translate.x=="number"?l=this.translate.x:typeof this.translate.x=="function"?l=this.translate.x.bind(this)(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 x;typeof this._scale.y=="number"?x=this._scale.y:typeof this._scale.y=="function"?x=this._scale.y.bind(this)(i):x=this._scale.y.value(i),(this._width||this._height)&&(b*=this.view.scale._x,x*=this.view.scale._y),this.view.scale.set(b,x)}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 Nh=Object.defineProperty,_h=Object.getOwnPropertyDescriptor,Th=(n,o,t,a)=>{for(var r=_h(o,t),i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&Nh(o,t,r),r};const ql=class Kl extends Na(Vo){constructor(t,a={}){super();U(this,"type","image");U(this,"element",new Image);U(this,"source",new Ir);U(this,"sprite",new Le.Sprite);this.view.addChild(this.sprite),t instanceof Ir&&(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=Le.Texture.from(this.element),this.state="READY",t()},this.element.onerror=r=>{this.state="ERROR",a(new Kt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=Kl.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};Th([_a],ql.prototype,"update");let Mh=ql;const Xo={"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 Fh=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&&Fh(o,t,r),r};const Co=class Rr extends Eo(Vt){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=Rr.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(Xo).map(t=>({family:t,variants:Xo[t].weights.map(a=>({family:t,source:`url(${Xo[t].url})`,weight:a}))}))}static fromFamily({family:t,weight:a}){return new Rr({family:t,source:`url(${Xo[t].url})`,weight:a})}};Ta([me()],Co.prototype,"family");Ta([me()],Co.prototype,"weight");Ta([me()],Co.prototype,"source");Ta([me()],Co.prototype,"style");let lt=Co;const Wt=4,Ql={center:.5,justify:.5,left:0,right:1},ec={alphabetic:0,top:0,middle:.5,hanging:1,bottom:1,ideographic:1};var Bh=Object.defineProperty,Ih=Object.getOwnPropertyDescriptor,vt=(n,o,t,a)=>{for(var r=Ih(o,t),i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&Bh(o,t,r),r};const ut=class tc extends Na(Vo){constructor(t){super();U(this,"type","text");U(this,"_text","");U(this,"_textCase");U(this,"_anchor",{x:0,y:0});U(this,"_font",new lt);U(this,"style",new Le.TextStyle({fill:"#FFFFFF",fontFamily:this._font.family,fontSize:16}));this.style.padding=20,typeof t=="string"?(this.text=t,this.reflectUpdate()):t&&(Object.assign(this,t),this.reflectUpdate()),this.on("update",this.reflectUpdate.bind(this))}get text(){return this._text}set text(t){if(this._text=t,!this.view.children.length){const a=new Le.Text({text:this.transformedText,style:this.style,resolution:Wt,scale:Wt});this.view.addChild(a)}this.view.children[0]instanceof Le.Text&&this.transformedText&&(this.view.children[0].text=this.transformedText)}get name(){return this._text}get font(){return this._font}set font(t){if(this._font=t,t.loaded){this.style.fontFamily=t.name;return}this._font.load().then(()=>{this.style.fontFamily=t.name,this.trigger("update",void 0)})}get maxWidth(){if(this.style.wordWrap)return this.style.wordWrapWidth*Wt}set maxWidth(t){t?(this.style.wordWrap=!0,this.style.wordWrapWidth=t/Wt):this.style.wordWrap=!1}get textAlign(){return this.style.align}set textAlign(t){this.style.align=t,this.anchor.x=Ql[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=ec[t]}get fillStyle(){const{fill:t}=this.style;return new Le.Color(t.toString()).toHex().toUpperCase()}set fillStyle(t){this.style.fill=t}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor={x:t,y:t}:this._anchor=t}get stroke(){if(!this.style.stroke)return;let{color:t="#000000",alpha:a=1,width:r=3,join:i="round",miterLimit:s}=this.style.stroke;return t=new Le.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 Le.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 Le.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=tc.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)*Wt;this.view.pivot={x:(t-r)*this._anchor.x,y:(a-r)*this._anchor.y}}set(t){return super.set(t)}};vt([me()],ut.prototype,"text");vt([me(lt)],ut.prototype,"font");vt([me()],ut.prototype,"maxWidth");vt([me()],ut.prototype,"textAlign");vt([me()],ut.prototype,"padding");vt([me()],ut.prototype,"textBaseline");vt([me()],ut.prototype,"fillStyle");vt([me()],ut.prototype,"anchor");vt([me()],ut.prototype,"stroke");vt([me()],ut.prototype,"textCase");vt([me()],ut.prototype,"shadow");vt([me()],ut.prototype,"fontSize");vt([me()],ut.prototype,"leading");vt([_a],ut.prototype,"update");let Ln=ut;function pr(n){const o=n.split(" ").map(t=>`${t} `);return o[o.length-1]=o[o.length-1].replace(/ $/,""),o}const Rh={get(n,o){const t=n[o];return typeof t=="number"?t*Wt:Array.isArray(t)&&typeof t[0]=="number"?t.map(a=>a*Wt):t}};function Ph(n){return new Proxy(n,Rh)}class $h{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 Is{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 zh{static fromJSON(o){return o.map(t=>(t.font&&(t.font=lt.fromJSON(t.font)),t))}}var Ah=Object.defineProperty,Dh=Object.getOwnPropertyDescriptor,Wn=(n,o,t,a)=>{for(var r=a>1?void 0:a?Dh(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&&Ah(o,t,r),r};const Sn=class nc extends Ln{constructor(t){super();U(this,"type","complex_text");U(this,"_maxWidth");U(this,"_textAlign","left");U(this,"_textBaseline","top");U(this,"model",new Le.Container);U(this,"segments",[]);U(this,"metrics",new Is);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=Ql[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=ec[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=nc.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:pr(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:pr(a.substring(t[l].start,t[l].stop))}),!((t[l].stop??a.length)>=a.length)&&r.push({index:void 0,tokens:pr(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 Is;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=Ph(Le.CanvasTextMetrics.measureText(c.tokens[u],d)),m=(((i=r.lines.at(-1))==null?void 0:i.width)??0)+p.lineWidths[0],h=this.maxWidth??Number.POSITIVE_INFINITY,v=(s=c.tokens.at(u-1))==null?void 0:s.match(/(\n|\\n).$/gim);(m>h||v||!r.lines.length)&&r.lines.push(new $h),this.model.addChild(new Le.Text({text:c.tokens[u],style:d,resolution:Wt,scale:Wt})),(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 Le.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)*Wt;this.view.pivot={x:(r-s)*this._anchor.x,y:(i-s)*this._anchor.y},this.drawBackground()}};Wn([me()],Sn.prototype,"background",2);Wn([me(zh)],Sn.prototype,"styles",2);Wn([me()],Sn.prototype,"text",1);Wn([me()],Sn.prototype,"maxWidth",1);Wn([me()],Sn.prototype,"textAlign",1);Wn([me()],Sn.prototype,"textBaseline",1);let Ma=Sn;const oc="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBtPSh0PT4odFt0LkFWTUVESUFfVFlQRV9VTktOT1dOPS0xXT0iQVZNRURJQV9UWVBFX1VOS05PV04iLHRbdC5BVk1FRElBX1RZUEVfVklERU89MF09IkFWTUVESUFfVFlQRV9WSURFTyIsdFt0LkFWTUVESUFfVFlQRV9BVURJTz0xXT0iQVZNRURJQV9UWVBFX0FVRElPIix0W3QuQVZNRURJQV9UWVBFX0RBVEE9Ml09IkFWTUVESUFfVFlQRV9EQVRBIix0W3QuQVZNRURJQV9UWVBFX1NVQlRJVExFPTNdPSJBVk1FRElBX1RZUEVfU1VCVElUTEUiLHRbdC5BVk1FRElBX1RZUEVfQVRUQUNITUVOVD00XT0iQVZNRURJQV9UWVBFX0FUVEFDSE1FTlQiLHRbdC5BVk1FRElBX1RZUEVfTkI9NV09IkFWTUVESUFfVFlQRV9OQiIsdCkpKG18fHt9KSxvPSh0PT4odC5GRm1wZWdXb3JrZXJMb2FkZWQ9IkZGbXBlZ1dvcmtlckxvYWRlZCIsdC5XQVNNUnVudGltZUluaXRpYWxpemVkPSJXQVNNUnVudGltZUluaXRpYWxpemVkIix0LkxvYWRXQVNNPSJMb2FkV0FTTSIsdC5HZXRBVlBhY2tldD0iR2V0QVZQYWNrZXQiLHQuR2V0QVZQYWNrZXRzPSJHZXRBVlBhY2tldHMiLHQuR2V0QVZTdHJlYW09IkdldEFWU3RyZWFtIix0LkdldEFWU3RyZWFtcz0iR2V0QVZTdHJlYW1zIix0LlJlYWRBVlBhY2tldD0iUmVhZEFWUGFja2V0Iix0LkFWUGFja2V0U3RyZWFtPSJBVlBhY2tldFN0cmVhbSIsdC5SZWFkTmV4dEFWUGFja2V0PSJSZWFkTmV4dEFWUGFja2V0Iix0LlN0b3BSZWFkQVZQYWNrZXQ9IlN0b3BSZWFkQVZQYWNrZXQiLHQpKShvfHx7fSk7Y29uc3QgQT0iS0daMWJtTjBhVzl1S0NsN0luVnpaU0J6ZEhKcFkzUWlPMnhsZENCbU8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2SWtaR2JYQmxaMWR2Y210bGNreHZZV1JsWkNKOUtTeHpaV3htTG1Ga1pFVjJaVzUwVEdsemRHVnVaWElvSW0xbGMzTmhaMlVpTEdGemVXNWpJR1oxYm1OMGFXOXVLR3dwZTJOdmJuTjBlM1I1Y0dVNmRDeGtZWFJoT21NOWUzMHNiWE5uU1dRNmIzMDliQzVrWVhSaE8zUnllWHRwWmloMFBUMDlJa3h2WVdSWFFWTk5JaWw3WTI5dWMzUjdkMkZ6YlV4dllXUmxjbEJoZEdnNlpYMDlZM3g4ZTMwN1pqMWhkMkZwZENoaGQyRnBkQ0JwYlhCdmNuUW9aU2twTG1SbFptRjFiSFFvS1gxbGJITmxJR2xtS0hROVBUMGlSMlYwUVZaVGRISmxZVzBpS1h0amIyNXpkSHRtYVd4bE9tVXNjM1J5WldGdFZIbHdaVHB6TEhOMGNtVmhiVWx1WkdWNE9tRjlQV01zY2oxbUxtZGxkRUZXVTNSeVpXRnRLR1VzY3l4aEtUdHpaV3htTG5CdmMzUk5aWE56WVdkbEtIdDBlWEJsT25Rc2JYTm5TV1E2Ynl4eVpYTjFiSFE2Y24wc1czSXVZMjlrWldOd1lYSXVaWGgwY21Ga1lYUmhMbUoxWm1abGNsMHBmV1ZzYzJVZ2FXWW9kRDA5UFNKSFpYUkJWbE4wY21WaGJYTWlLWHRqYjI1emRIdG1hV3hsT21WOVBXTXNjejFtTG1kbGRFRldVM1J5WldGdGN5aGxLVHR6Wld4bUxuQnZjM1JOWlhOellXZGxLSHQwZVhCbE9uUXNiWE5uU1dRNmJ5eHlaWE4xYkhRNmMzMHNjeTV0WVhBb1lUMCtZUzVqYjJSbFkzQmhjaTVsZUhSeVlXUmhkR0V1WW5WbVptVnlLU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBJaWw3WTI5dWMzUjdabWxzWlRwbExIUnBiV1U2Y3l4emRISmxZVzFVZVhCbE9tRXNjM1J5WldGdFNXNWtaWGc2Y24wOVl5eHVQV1l1WjJWMFFWWlFZV05yWlhRb1pTeHpMR0VzY2lrN2MyVnNaaTV3YjNOMFRXVnpjMkZuWlNoN2RIbHdaVHAwTEcxelowbGtPbThzY21WemRXeDBPbTU5TEZ0dUxtUmhkR0V1WW5WbVptVnlYU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBjeUlwZTJOdmJuTjBlMlpwYkdVNlpTeDBhVzFsT25OOVBXTXNZVDFtTG1kbGRFRldVR0ZqYTJWMGN5aGxMSE1wTzNObGJHWXVjRzl6ZEUxbGMzTmhaMlVvZTNSNWNHVTZkQ3h0YzJkSlpEcHZMSEpsYzNWc2REcGhmU3hoTG0xaGNDaHlQVDV5TG1SaGRHRXVZblZtWm1WeUtTbDlaV3h6WlNCcFppaDBQVDA5SWxKbFlXUkJWbEJoWTJ0bGRDSXBlMk52Ym5OMGUyWnBiR1U2WlN4emRHRnlkRHB6TEdWdVpEcGhMSE4wY21WaGJWUjVjR1U2Y2l4emRISmxZVzFKYm1SbGVEcHVmVDFqTEdROVppNXlaV0ZrUVZaUVlXTnJaWFFvYnl4bExITXNZU3h5TEc0cE8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEhKbGMzVnNkRHBrZlNsOWZXTmhkR05vS0dVcGUzTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEdWeWNrMXpaenBsSUdsdWMzUmhibU5sYjJZZ1JYSnliM0kvWlM1dFpYTnpZV2RsT2lKVmJtdHViM2R1SUVWeWNtOXlJbjBwZlgwcGZTa29LVHNLIixnPXQ9PlVpbnQ4QXJyYXkuZnJvbShhdG9iKHQpLGU9PmUuY2hhckNvZGVBdCgwKSksVj10eXBlb2Ygc2VsZjwidSImJnNlbGYuQmxvYiYmbmV3IEJsb2IoW2coQSldLHt0eXBlOiJ0ZXh0L2phdmFzY3JpcHQ7Y2hhcnNldD11dGYtOCJ9KTtmdW5jdGlvbiBFKHQpe2xldCBlO3RyeXtpZihlPVYmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLmNyZWF0ZU9iamVjdFVSTChWKSwhZSl0aHJvdyIiO2NvbnN0IHM9bmV3IFdvcmtlcihlLHtuYW1lOnQ/Lm5hbWV9KTtyZXR1cm4gcy5hZGRFdmVudExpc3RlbmVyKCJlcnJvciIsKCk9Pnsoc2VsZi5VUkx8fHNlbGYud2Via2l0VVJMKS5yZXZva2VPYmplY3RVUkwoZSl9KSxzfWNhdGNoe3JldHVybiBuZXcgV29ya2VyKCJkYXRhOnRleHQvamF2YXNjcmlwdDtiYXNlNjQsIitBLHtuYW1lOnQ/Lm5hbWV9KX1maW5hbGx5e2UmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLnJldm9rZU9iamVjdFVSTChlKX19Y29uc3QgdT0xZTY7Y2xhc3MgcHtmZm1wZWdXb3JrZXI7ZmZtcGVnV29ya2VyTG9hZFN0YXR1czttc2dJZDtmaWxlO2NvbnN0cnVjdG9yKGUpe3RoaXMuZmZtcGVnV29ya2VyPW5ldyBFLHRoaXMuZmZtcGVnV29ya2VyTG9hZFN0YXR1cz1uZXcgUHJvbWlzZSgocyxhKT0+e3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGk9Pntjb25zdHt0eXBlOnIsZXJyTXNnOmR9PWkuZGF0YTtyPT09by5GRm1wZWdXb3JrZXJMb2FkZWQmJnRoaXMucG9zdChvLkxvYWRXQVNNLHt3YXNtTG9hZGVyUGF0aDplLndhc21Mb2FkZXJQYXRofSkscj09PW8uV0FTTVJ1bnRpbWVJbml0aWFsaXplZCYmcyghMCkscj09PW8uTG9hZFdBU00mJmQmJmEoZCl9KX0pLHRoaXMubXNnSWQ9MH1wb3N0KGUscyxhKXt0aGlzLmZmbXBlZ1dvcmtlci5wb3N0TWVzc2FnZSh7dHlwZTplLG1zZ0lkOmE/P3RoaXMubXNnSWQrKyxkYXRhOnN9KX1hc3luYyBsb2FkKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5mZm1wZWdXb3JrZXJMb2FkU3RhdHVzO3JldHVybiB0aGlzLmZpbGU9ZSxzfWRlc3Ryb3koKXt0aGlzLmZpbGU9dm9pZCAwLHRoaXMuZmZtcGVnV29ya2VyLnRlcm1pbmF0ZSgpfWdldEFWU3RyZWFtKGU9bS5BVk1FRElBX1RZUEVfVklERU8scz0tMSl7cmV0dXJuIG5ldyBQcm9taXNlKChhLGkpPT57aWYoIXRoaXMuZmlsZSl7aSgiZmlsZSBpcyBub3QgbG9hZGVkIik7cmV0dXJufWNvbnN0IHI9dGhpcy5tc2dJZCxkPSh7ZGF0YTpufSk9PntuLnR5cGU9PT1vLkdldEFWU3RyZWFtJiZuLm1zZ0lkPT09ciYmKG4uZXJyTXNnP2kobi5lcnJNc2cpOmEobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGQpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZCksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW0se2ZpbGU6dGhpcy5maWxlLHN0cmVhbVR5cGU6ZSxzdHJlYW1JbmRleDpzfSl9KX1nZXRBVlN0cmVhbXMoKXtyZXR1cm4gbmV3IFByb21pc2UoKGUscyk9PntpZighdGhpcy5maWxlKXtzKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgYT10aGlzLm1zZ0lkLGk9KHtkYXRhOnJ9KT0+e3IudHlwZT09PW8uR2V0QVZTdHJlYW1zJiZyLm1zZ0lkPT09YSYmKHIuZXJyTXNnP3Moci5lcnJNc2cpOmUoci5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsaSksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW1zLHtmaWxlOnRoaXMuZmlsZX0pfSl9Z2V0QVZQYWNrZXQoZSxzPW0uQVZNRURJQV9UWVBFX1ZJREVPLGE9LTEpe3JldHVybiBuZXcgUHJvbWlzZSgoaSxyKT0+e2lmKCF0aGlzLmZpbGUpe3IoImZpbGUgaXMgbm90IGxvYWRlZCIpO3JldHVybn1jb25zdCBkPXRoaXMubXNnSWQsbj1oPT57Y29uc3QgbD1oLmRhdGE7bC50eXBlPT09by5HZXRBVlBhY2tldCYmbC5tc2dJZD09PWQmJihsLmVyck1zZz9yKGwuZXJyTXNnKTppKGwucmVzdWx0KSx0aGlzLmZmbXBlZ1dvcmtlci5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixuKSl9O3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLG4pLHRoaXMucG9zdChvLkdldEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSx0aW1lOmUsc3RyZWFtVHlwZTpzLHN0cmVhbUluZGV4OmF9KX0pfWdldEFWUGFja2V0cyhlKXtyZXR1cm4gbmV3IFByb21pc2UoKHMsYSk9PntpZighdGhpcy5maWxlKXthKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgaT10aGlzLm1zZ0lkLHI9ZD0+e2NvbnN0IG49ZC5kYXRhO24udHlwZT09PW8uR2V0QVZQYWNrZXRzJiZuLm1zZ0lkPT09aSYmKG4uZXJyTXNnP2Eobi5lcnJNc2cpOnMobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLHIpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsciksdGhpcy5wb3N0KG8uR2V0QVZQYWNrZXRzLHtmaWxlOnRoaXMuZmlsZSx0aW1lOmV9KX0pfXJlYWRBVlBhY2tldChlPTAscz0wLGE9bS5BVk1FRElBX1RZUEVfVklERU8saT0tMSl7Y29uc3Qgcj1uZXcgQ291bnRRdWV1aW5nU3RyYXRlZ3koe2hpZ2hXYXRlck1hcms6MX0pLGQ9dGhpcy5tc2dJZDtsZXQgbj0wO3JldHVybiBuZXcgUmVhZGFibGVTdHJlYW0oe3N0YXJ0Omg9PntpZighdGhpcy5maWxlKXtoLmVycm9yKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgbD1mPT57Y29uc3QgYz1mLmRhdGE7Yy50eXBlPT09by5SZWFkQVZQYWNrZXQmJmMubXNnSWQ9PT1kJiZjLmVyck1zZyYmKGguZXJyb3IoYy5lcnJNc2cpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGwpKSxjLnR5cGU9PT1vLkFWUGFja2V0U3RyZWFtJiZjLm1zZ0lkPT09ZCYmKGMucmVzdWx0P2guZW5xdWV1ZShjLnJlc3VsdCk6aC5jbG9zZSgpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsbCksdGhpcy5wb3N0KG8uUmVhZEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSxzdGFydDplLGVuZDpzLHN0cmVhbVR5cGU6YSxzdHJlYW1JbmRleDppfSl9LHB1bGw6KCk9PntuPjAmJnRoaXMucG9zdChvLlJlYWROZXh0QVZQYWNrZXQsdm9pZCAwLGQpLG4rK30sY2FuY2VsOigpPT57dGhpcy5wb3N0KG8uU3RvcFJlYWRBVlBhY2tldCx2b2lkIDAsZCl9fSxyKX1nZXRWaWRlb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9WSURFTyxlKX1nZXRBdWRpb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9BVURJTyxlKX1zZWVrVmlkZW9QYWNrZXQoZSl7cmV0dXJuIHRoaXMuZ2V0QVZQYWNrZXQoZSxtLkFWTUVESUFfVFlQRV9WSURFTyl9c2Vla0F1ZGlvUGFja2V0KGUpe3JldHVybiB0aGlzLmdldEFWUGFja2V0KGUsbS5BVk1FRElBX1RZUEVfQVVESU8pfXJlYWRWaWRlb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfVklERU8pfXJlYWRBdWRpb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfQVVESU8pfWdlblZpZGVvRGVjb2RlckNvbmZpZyhlKXtyZXR1cm57Y29kZWM6ZS5jb2RlY3Bhci5jb2RlY19zdHJpbmcsY29kZWRXaWR0aDplLmNvZGVjcGFyLndpZHRoLGNvZGVkSGVpZ2h0OmUuY29kZWNwYXIuaGVpZ2h0LGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRWaWRlb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZFZpZGVvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1nZW5BdWRpb0RlY29kZXJDb25maWcoZSl7cmV0dXJue2NvZGVjOmUuY29kZWNwYXIuY29kZWNfc3RyaW5nfHwiIixzYW1wbGVSYXRlOmUuY29kZWNwYXIuc2FtcGxlX3JhdGUsbnVtYmVyT2ZDaGFubmVsczplLmNvZGVjcGFyLmNoYW5uZWxzLGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRBdWRpb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZEF1ZGlvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1hc3luYyBnZXRWaWRlb0RlY29kZXJDb25maWcoKXtjb25zdCBlPWF3YWl0IHRoaXMuZ2V0VmlkZW9TdHJlYW0oKTtyZXR1cm4gdGhpcy5nZW5WaWRlb0RlY29kZXJDb25maWcoZSl9YXN5bmMgc2Vla0VuY29kZWRWaWRlb0NodW5rKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5zZWVrVmlkZW9QYWNrZXQoZSk7cmV0dXJuIHRoaXMuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsocyl9YXN5bmMgZ2V0QXVkaW9EZWNvZGVyQ29uZmlnKCl7Y29uc3QgZT1hd2FpdCB0aGlzLmdldEF1ZGlvU3RyZWFtKCk7cmV0dXJuIHRoaXMuZ2VuQXVkaW9EZWNvZGVyQ29uZmlnKGUpfWFzeW5jIHNlZWtFbmNvZGVkQXVkaW9DaHVuayhlKXtjb25zdCBzPWF3YWl0IHRoaXMuc2Vla0F1ZGlvUGFja2V0KGUpO3JldHVybiB0aGlzLmdlbkVuY29kZWRBdWRpb0NodW5rKHMpfX1jbGFzcyBre3ZpZGVvO2N1cnJlbnRGcmFtZXM9MDt0b3RhbEZyYW1lcztjdXJyZW50VGltZTtmcHM7Zmlyc3RUaW1lc3RhbXA7Y29uc3RydWN0b3IoZSxzKXt0aGlzLmN1cnJlbnRUaW1lPWVbMF0qMWU2LHRoaXMuZmlyc3RUaW1lc3RhbXA9ZVswXSoxZTYsdGhpcy50b3RhbEZyYW1lcz0oZVsxXS1lWzBdKSpzKzEsdGhpcy5mcHM9cyx0aGlzLnZpZGVvPW5ldyBWaWRlb0RlY29kZXIoe291dHB1dDp0aGlzLmhhbmRsZUZyYW1lT3V0cHV0LmJpbmQodGhpcyksZXJyb3I6dGhpcy5oYW5kbGVFcnJvci5iaW5kKHRoaXMpfSl9cG9zdEZyYW1lKGUpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImZyYW1lIixmcmFtZTplfSksdGhpcy5jdXJyZW50VGltZSs9TWF0aC5mbG9vcigxL3RoaXMuZnBzKjFlNiksdGhpcy5jdXJyZW50RnJhbWVzKz0xfWhhbmRsZUZyYW1lT3V0cHV0KGUpe2NvbnN0IHM9ZS50aW1lc3RhbXAsYT1lLmR1cmF0aW9uPz8wLGk9cythO2lmKCF0aGlzLmlzRnJhbWVJblJhbmdlKHMpKXtlLmNsb3NlKCk7cmV0dXJufWZvcig7aT50aGlzLmN1cnJlbnRUaW1lJiZ0aGlzLmN1cnJlbnRGcmFtZXM8PXRoaXMudG90YWxGcmFtZXM7KXRoaXMucG9zdEZyYW1lKGUpO2UuY2xvc2UoKX1pc0ZyYW1lSW5SYW5nZShlKXtyZXR1cm4gZT49dGhpcy5maXJzdFRpbWVzdGFtcH1oYW5kbGVFcnJvcihlKXtjb25zb2xlLmVycm9yKCJlcnJvciBpbiB3b3JrZXIiLGUpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOmUubWVzc2FnZT8/IkFuIHVua25vd24gd29ya2VyIGVycm9yIG9jY3VycmVkIn0pLHNlbGYuY2xvc2UoKX19ZnVuY3Rpb24gSSh0KXtyZXR1cm4gYXN5bmMgZT0+e3RyeXthd2FpdCB0KGUpfWNhdGNoKHMpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOnM/Lm1lc3NhZ2U/PyJBbiB1bmtvd24gd29ya2VyIGVycm9yIG9jY3VyZWQifSl9fX1mdW5jdGlvbiBXKHQpe3JldHVybiB0LmNvZGVjPT0idnAwOSImJih0LmNvZGVjPSJ2cDA5LjAwLjEwLjA4IiksdH1jb25zdCBaPTMwO2FzeW5jIGZ1bmN0aW9uIFAodCl7aWYodC5kYXRhPy50eXBlIT0iaW5pdCIpcmV0dXJuO2NvbnN0e2ZpbGU6ZSxyYW5nZTpzLGZwczphfT10LmRhdGEsaT1uZXcgcCh7d2FzbUxvYWRlclBhdGg6Imh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vQGRpZmZ1c2lvbnN0dWRpby9mZm1wZWctd2FzbUAxLjAuMC9kaXN0L2ZmbXBlZy5qcyJ9KTthd2FpdCBpLmxvYWQoZSk7Y29uc3Qgcj1hd2FpdCBpLmdldFZpZGVvRGVjb2RlckNvbmZpZygpO1cocik7Y29uc3QgZD1uZXcgayhzLGEpO2QudmlkZW8uY29uZmlndXJlKHIpO2NvbnN0IG49aS5yZWFkQVZQYWNrZXQoc1swXSxzWzFdKS5nZXRSZWFkZXIoKTtuLnJlYWQoKS50aGVuKGFzeW5jIGZ1bmN0aW9uIGgoe2RvbmU6bCx2YWx1ZTpmfSl7aWYobCl7YXdhaXQgZC52aWRlby5mbHVzaCgpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImRvbmUifSksc2VsZi5jbG9zZSgpO3JldHVybn1jb25zdCBjPWkuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsoZik7cmV0dXJuIGQudmlkZW8uZGVjb2RlUXVldWVTaXplPlomJmF3YWl0IG5ldyBQcm9taXNlKEw9PntkLnZpZGVvLm9uZGVxdWV1ZT0oKT0+TCgpfSksYy50aW1lc3RhbXA8PXNbMV0qMWU2JiZkLnZpZGVvLmRlY29kZShjKSxuLnJlYWQoKS50aGVuKGgpfSl9c2VsZi5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixJKFApKX0pKCk7Cg==",Uh=n=>Uint8Array.from(atob(n),o=>o.charCodeAt(0)),Rs=typeof self<"u"&&self.Blob&&new Blob([Uh(oc)],{type:"text/javascript;charset=utf-8"});function Oh(n){let o;try{if(o=Rs&&(self.URL||self.webkitURL).createObjectURL(Rs),!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,"+oc,{name:n==null?void 0:n.name})}finally{o&&(self.URL||self.webkitURL).revokeObjectURL(o)}}class Lh{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 Wh(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 jh=Object.defineProperty,Xh=Object.getOwnPropertyDescriptor,Zh=(n,o,t,a)=>{for(var r=Xh(o,t),i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&jh(o,t,r),r};const ac=class rc extends Na(Ca){constructor(t,a={}){super();U(this,"source",new vn);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:Le.Texture.from(this.element),canvas:Le.Texture.from(this.canvas)});U(this,"sprite",new Le.Sprite);this.element.controls=!1,this.element.playsInline=!0,this.element.style.display="hidden",this.element.crossOrigin="anonymous",this.textrues.html5.source.autoPlay=!1,this.textrues.html5.source.loop=!1,this.sprite.texture=this.textrues.html5,this.view.addChild(this.sprite),t instanceof vn&&(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 Kt({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(fe.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=rc.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 Lh,this.worker=new Oh,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)??bo}),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}};Zh([_a,Wh],ac.prototype,"update");let Pr=ac;class ga extends Ca{constructor(t,a={}){super();U(this,"type","audio");U(this,"source",new rn);U(this,"element",new Audio);t instanceof rn&&(this.source=t),t instanceof File&&this.source.from(t),this.element.addEventListener("play",()=>{this.playing=!0}),this.element.addEventListener("pause",()=>{this.playing=!1}),Object.assign(this,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 Kt({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=ga.fromJSON(JSON.parse(JSON.stringify(this)));return t.source=this.source,t}}const Yh={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 $r(n){if(!Object.keys(Yh.MIXED).includes(n??""))throw new He({message:`${n} is not an accepted mime type`,code:"invalid_mimetype"});return n}var Gh=Object.defineProperty,Hh=Object.getOwnPropertyDescriptor,Jh=(n,o,t,a)=>{for(var r=Hh(o,t),i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&Gh(o,t,r),r};const qh=class ic extends Na(Vo){constructor(t,a={}){super();U(this,"type","html");U(this,"source",new Fs);U(this,"element",new Image);U(this,"canvas",document.createElement("canvas"));U(this,"context",this.canvas.getContext("2d"));U(this,"sprite",new Le.Sprite);this.view.addChild(this.sprite),Object.assign(this,a),t instanceof Fs&&(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=Le.Texture.from(this.canvas,!0),this.trigger("load",void 0))}),this.element.addEventListener("error",r=>{this.state="ERROR",this.trigger("error",new Kt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."})),this.track&&this.detach()}),this.on("update",async()=>{this.source.update(),this.element.setAttribute("src",await this.source.createObjectURL())})}async init(){this.element.setAttribute("src",await this.source.createObjectURL()),await new Promise((t,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 Kt({code:"sourceNotProcessable",message:"Cannot display source with height or width at 0"}));this.state="READY",t()},this.element.onerror=r=>{a(new Kt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=ic.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};Jh([_a],qh.prototype,"update");const sc=["DEFAULT","STACK"];class Ps{constructor(){U(this,"mode",sc[0]);U(this,"pauseAlignmet",!1)}add(o,t){let a=!0;for(let r=0;r<t.clips.length&&(a=As(o,t.clips[r]),!!a);r++)zs(o,t.clips[r]);a&&(t.clips.push(o),t.clips.sort($s))}update(o,t){if(!this.pauseAlignmet){t.clips.sort($s);for(let a=0;a<t.clips.length;a++)if(o.id!=t.clips[a].id){if(!As(o,t.clips[a]))break;zs(o,t.clips[a])}}}offset(o,t){this.pauseAlignmet=!0;for(const a of t.clips)a.offsetBy(o);this.pauseAlignmet=!1}}class Kh{constructor(){U(this,"mode",sc[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 fe(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 fe(i))}a=r.stop.millis+1}}offset(){}}function $s(n,o){return n.start.millis-o.start.millis}function zs(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 As(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 jn extends Eo(Vt){constructor(){super(...arguments);U(this,"_disabled",!1);U(this,"view",new Le.Container);U(this,"clips",[]);U(this,"pointer",0);U(this,"composition");U(this,"type","base");U(this,"strategy",new Ps)}get disabled(){return this._disabled}set disabled(t){var a;t&&this.clipRef&&hr(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 Kh,this.strategy.update(new Vo,this)):this.strategy=new Ps,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,sh(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(fe.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(hr(this.clipRef)&&(!fr(a,this.clipRef)||(r=this.clipRef)!=null&&r.disabled)&&(this.clipRef&&this.view.removeChild(this.clipRef.view),(i=this.clipRef)==null||i.exit()),!!fr(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(fr(a,c)&&!c.disabled)return this.pointer=l,hr(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 fe}get start(){var t;return((t=this.clips.at(0))==null?void 0:t.start)??new fe}apply(t){this.clips.forEach(t)}detach(){var t;return(t=this.composition)==null||t.removeTrack(this),this}get clipRef(){return this.clips[this.pointer]}}function fr(n,o){return o?n>=o.start.millis&&n<=o.stop.millis:!1}function hr(n){return n?!!n.view.parent:!1}class Qh{static fromType(o){switch(o.type){case"video":return new e0;case"audio":return new n0;case"html":return new o0;case"image":return new t0;case"text":return new Ds;case"complex_text":return new Ds;case"caption":return new r0;default:return new jn}}}class lc extends jn{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 e0 extends lc{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 t0 extends jn{constructor(){super(...arguments);U(this,"type","image")}}class n0 extends lc{constructor(){super(...arguments);U(this,"type","audio")}}class Ds extends jn{constructor(){super(...arguments);U(this,"type","text")}}class o0 extends jn{constructor(){super(...arguments);U(this,"type","html")}}var a0=Object.defineProperty,ii=(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&&a0(o,t,r),r};class No extends Vt{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 fe,r=await lt.fromFamily({family:"Figtree",weight:"700"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))await t.add(new Ln({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"})}))}}ii([me()],No.prototype,"generatorOptions");ii([me()],No.prototype,"type");ii([me()],No.prototype,"position");class r0 extends jn{constructor(){super(...arguments);U(this,"clip");U(this,"type","caption");U(this,"preset",new No)}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 i0=Object.defineProperty,Fa=(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&&i0(o,t,r),r};class _o extends Vt{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 fe,r=await lt.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 Ma({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)}))}}}Fa([me()],_o.prototype,"generatorOptions");Fa([me()],_o.prototype,"type");Fa([me()],_o.prototype,"color");Fa([me()],_o.prototype,"position");var s0=Object.defineProperty,si=(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&&s0(o,t,r),r};class Ba extends Vt{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 fe,r=await lt.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const m of t.clip.transcript.iter({length:[18]})){const{segments:h,words:v}=this.splitSequence(m);for(let b=0;b<m.words.length;b++){const x=(d=(c=v[b])==null?void 0:c.at(0))==null?void 0:d.start,R=(p=(u=v[b])==null?void 0:u.at(-1))==null?void 0:p.stop;!x||!R||await t.add(new Ma({text:h.join(`
|
|
33
|
-
`),textAlign:"center",textBaseline:"middle",fontSize:20,fillStyle:"#FFFFFF",shadow:{color:"#000000",blur:16,alpha:.8,angle:Math.PI/4,distance:1},stroke:{width:4,color:"#000000"},maxWidth:t.composition.width*.8,leading:1.3,font:r,textCase:"upper",position:this.position,stop:R.add(a),start:x.add(a),styles:[{fillStyle:this.colors[0],fontSize:23},{fillStyle:this.colors[1],fontSize:23},{fillStyle:this.colors[2],fontSize:23}],segments:[{index:oa(0,2),start:h.slice(0,b).join(" ").length,stop:h.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=[...Ss(a,i).map(c=>c.trim())],l=Ss(t.words,s[0].split(/ /).length);return{segments:s,words:l}}}si([me()],Ba.prototype,"type");si([me()],Ba.prototype,"colors");si([me()],Ba.prototype,"position");var l0=Object.defineProperty,li=(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&&l0(o,t,r),r};class Ia extends Vt{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 fe,r=await lt.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 Ln({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)}))}}}li([me()],Ia.prototype,"generatorOptions");li([me()],Ia.prototype,"type");li([me()],Ia.prototype,"position");var c0=Object.defineProperty,ci=(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 Ra extends Vt{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 lt.fromFamily({family:"Urbanist",weight:"800"}).load(),r=((c=t.clip)==null?void 0:c.offset)??new fe,i=new fl.GlowFilter({color:"#fffe41",alpha:.25,distance:90,quality:.05});for(const d of t.clip.transcript.iter(this.generatorOptions))await t.add(new Ln({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}))}}ci([me()],Ra.prototype,"generatorOptions");ci([me()],Ra.prototype,"type");ci([me()],Ra.prototype,"position");var d0=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&&d0(o,t,r),r};class To extends Vt{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 fe,r=await lt.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 Ma({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}))}}}Pa([me()],To.prototype,"generatorOptions");Pa([me()],To.prototype,"type");Pa([me()],To.prototype,"color");Pa([me()],To.prototype,"position");var u0=Object.defineProperty,$a=(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 za extends Vt{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 fe,r=await lt.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 Ma({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}]}))}}}$a([me()],za.prototype,"type");$a([me()],za.prototype,"generatorOptions");$a([me()],za.prototype,"color");$a([me()],za.prototype,"position");class m0 extends Eo(Vt){constructor({height:t=1080,width:a=1920,background:r="#000000",backend:i="webgpu"}={}){super();U(this,"_duration",new fe);U(this,"renderer");U(this,"stage",new Le.Container);U(this,"settings");U(this,"tracks",[]);U(this,"frame",0);U(this,"fixedDuration");U(this,"state","IDLE");U(this,"fps",bo);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)),Le.autoDetectRenderer({...this.settings,preference:i}).then(s=>{this.renderer=s,this.trigger("init",void 0)}).catch(s=>{this.trigger("error",new Un({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 fe?this.fixedDuration=t:this.fixedDuration=fe.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=Qh.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 Vs(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;Vs(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(fe.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 Un({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(fe.fromFrames(this.frame));this.rendering||this.computeFrame()}async play(){if(!this.rendering){this.state="PLAY",this.frame>=this.duration.frames&&(this.frame=0);for(const t of this.tracks)await t.seek(fe.fromFrames(this.frame));this.ticker(),this.trigger("play",this.frame)}}async pause(){this.state="IDLE",this.computeFrame(),this.trigger("pause",this.frame)}async audio(t=2,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(Ca)){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 h=0;h<t;h++){const v=i.getChannelData(h),b=p.getChannelData(h>m?m:h);for(let x=0;x<v.length-1;x++)x<c+d||x>c+u||x-c<0||(v[x]+=(b[x-c]??0)*l.volume,v[x]>1&&(v[x]=1),v[x]<-1&&(v[x]=-1));i.getChannelData(h).set(v)}}catch{}}return i}time(t){const a=$n(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/bo;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 p0(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 zr=[8e3,12e3,16e3,24e3,48e3],f0="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.wasm",h0="https://cdn.jsdelivr.net/npm/@diffusionstudio/libopus-wasm@1.0.0/dist/opus.js";class v0{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(h0),{numberOfChannels:a,sampleRate:r}=this.config=o;if(!zr.includes(r))throw new va({code:"sampleRateNotSupported",message:`Unsupported sample rate, supported: ${zr.join()}`});this.opus=await t.default({locateFile(i,s){return i.endsWith(".wasm")?f0:s+i}}),this.encoder=this.opus._opus_encoder_create(r,a,2048),this.meta={decoderConfig:{codec:"opus",description:p0(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 va({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),h=this.opus._opus_encode(this.encoder,u,s,m,p);if(h>0){const v=new Uint8Array(this.opus.HEAPU8.subarray(m,m+h));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 g0(n){const o=zr;let t=48e3;for(const a of o)Math.abs(n-a)<Math.abs(n-t)&&(t=a);return t}class y0{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=g0((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 dh({height:Math.round(this.height),width:Math.round(this.width),bitrate:this.videoBitrate,fps:this.fps});this.muxer=new Gl({target:new Jr,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 va({code:"initializationError",message:"Encoder must be initialized using {audio: true} to use this method"});this.muxer||await this.init();const t=ch(o,this.sampleRate,this.numberOfChannels),a=new v0({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:lh(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 va({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 b0(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 Tt(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 Zo(n){return n>5?n/100:n}function Mt(n,o,t){return Math.min(t,Math.max(o,n))}function pt(){return new Ae.ColorMatrixFilter}function w0(n,o){switch(n){case"brightness":{const t=pt(),a=Tt(o.value??o.brightness,1);return t.brightness(Mt(Zo(a),0,5),!1),t}case"contrast":{const t=pt(),a=Tt(o.value??o.contrast,1);return t.contrast(Mt(Zo(a),0,5),!1),t}case"saturation":{const t=pt(),a=Tt(o.value??o.saturation,1);return t.saturate(Mt(Zo(a),0,5),!1),t}case"hue":{const t=pt(),a=Tt(o.degrees??o.value,0);return t.hue(Mt(a,-180,180),!1),t}case"blur":case"softFocus":{const t=n==="softFocus"?1:0,a=Tt(o.radius??o.blur??o.value,t);return new Ae.BlurFilter({strength:Mt(a,0,32),quality:4})}case"grayscale":{const t=pt(),a=Mt(Tt(o.amount,100),0,100);return a<=0?null:(a>=100?t.desaturate():t.saturate(1-a/100,!1),t)}case"sepia":{if(Mt(Tt(o.amount,100),0,100)<=0)return null;const a=pt();return a.sepia(!1),a}case"invert":{if(Mt(Tt(o.amount,100),0,100)<=0)return null;const a=pt();return a.negative(!1),a}case"warmth":{const t=pt(),a=Mt(Tt(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=pt(),a=Mt(Tt(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=pt();return t.sepia(!1),t.saturate(1.4,!1),t.contrast(1.1,!1),t}case"blackAndWhite":{const t=pt(),a=Mt(Zo(Tt(o.contrast,120)),.5,3);return t.desaturate(),t.contrast(a,!1),t}case"cinematic":{const t=pt();return t.contrast(1.2,!1),t.brightness(.95,!1),t.saturate(.85,!1),t}case"dramatic":{const t=pt();return t.contrast(1.4,!1),t.brightness(.9,!1),t.saturate(1.1,!1),t.sepia(!1),t}case"dreamy":{const t=pt();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 cc{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 m0({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 b0(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=vn.from)==null?void 0:a.call(vn,i,{crossOrigin:"anonymous"}))??await vn.from(i),l=new Pr(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)),h=o.sourceOut!==void 0?Math.max(m+1,Math.floor(o.sourceOut*this.fps)):null;c=m,d=h;try{if(l.offset=l.offset||{frames:0},l.offset.frames=m,h!==null){const v=Math.max(1,h-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=lt.fromFamily({family:o.fontFamily||"Arial",weight:o.fontWeight||"400"}),a=new Ln({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(xt.getFilter(o.filterId)&&!xt.isFilterCompatibleWithMedia(o.filterId,"video"))return null;let i=Mu(o.filterId,a);return i||(i=w0(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,h,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");(h=o.onProgress)==null||h.call(o,0);const r=new y0(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 k0=["src"],x0={class:"preview-controls"},E0=["aria-label"],S0={class:"time-display"},V0={class:"current-time"},C0={class:"total-time"},N0={key:2,class:"loading-overlay"},_0={key:3,class:"error-overlay"},T0=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 h=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"}}),x=e.computed(()=>{var k,T;return(k=t.media)!=null&&k.url?t.media.url:(((T=t.media)==null?void 0:T.file)instanceof File,"")});async function R(){var k,T,F;if(!(!i.value||!t.recipe))try{l.value=!0,c.value="Initializing video engine...";const A=((k=t.recipe.source)==null?void 0:k.original_width)||1920,P=((T=t.recipe.source)==null?void 0:T.original_height)||1080,O=((F=t.recipe.output)==null?void 0:F.fps)||30;h=new cc(A,P,O,{fitMode:t.fitMode}),h.attachPlayer(i.value),c.value="Loading composition...",await h.loadFromRecipe(t.recipe),m.value=h.durationInSeconds,a("duration-change",m.value),S(),l.value=!1,a("engine-ready",h),t.autoPlay&&(h.play(),u.value=!0)}catch(A){const P=A instanceof Error?A.message:String(A);d.value=`Failed to initialize: ${P}`,l.value=!1}}function S(){if(!h)return;const k=setInterval(()=>{h&&u.value&&(p.value=h.currentTimeInSeconds,a("time-update",p.value))},100);D.value=k}function g(){v.value&&h?(u.value?h.pause():h.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 f(k){const T=Math.floor(k/60),F=Math.floor(k%60);return`${T}:${F.toString().padStart(2,"0")}`}function w(){d.value=null,v.value&&R()}function $(){!v.value&&s.value&&(m.value=s.value.duration,a("duration-change",m.value))}function V(){!v.value&&s.value&&(p.value=s.value.currentTime,a("time-update",p.value))}function y(){u.value=!1,a("play-state-change",!1)}function C(k){d.value="Failed to load video",a("error",d.value)}e.onMounted(()=>{v.value&&t.recipe&&R()}),e.onUnmounted(()=>{h&&(h.destroy(),h=null),D.value&&(clearInterval(D.value),D.value=null),s.value&&(s.value.pause(),s.value.removeAttribute("src"),s.value.load())}),e.watch(()=>t.recipe,async k=>{if(v.value&&k)if(h)try{await h.loadFromRecipe(k),m.value=h.durationInSeconds,a("duration-change",m.value)}catch{}else await R()}),e.watch(()=>t.enableEngine,async k=>{k?await R():h&&(D.value&&(clearInterval(D.value),D.value=null),h.destroy(),h=null)}),e.watch(()=>t.fitMode,async k=>{if(!(!v.value||!h))try{h.setFitMode(k||"contain")}catch{}});const D=e.ref(null);return(k,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:x.value,onLoadedmetadata:$,onTimeupdate:V,onEnded:y,onError:C,style:e.normalizeStyle({width:"100%",height:"100%",objectFit:b.value}),playsinline:"",controls:""},null,44,k0)),e.createElementVNode("div",x0,[e.createElementVNode("button",{class:"play-button",onClick:g,"aria-label":u.value?"Pause":"Play"},[e.createVNode(e.unref(I.IonIcon),{icon:u.value?e.unref(_l):e.unref(Tl)},null,8,["icon"])],8,E0),e.createElementVNode("div",S0,[e.createElementVNode("span",V0,e.toDisplayString(f(p.value)),1),T[0]||(T[0]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",C0,e.toDisplayString(f(m.value)),1)])]),l.value?(e.openBlock(),e.createElementBlock("div",N0,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"}),e.createElementVNode("p",null,e.toDisplayString(c.value),1)])):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("div",_0,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Zr)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(d.value),1),e.createElementVNode("button",{onClick:w},"Retry")])):e.createCommentVNode("",!0)],512))}}),Us=_e(T0,[["__scopeId","data-v-7e604791"]]),M0=["aria-label"],F0=["aria-label"],B0={class:"clip-content"},I0={key:0,class:"clip-thumbnail"},R0=["src","alt"],P0={class:"clip-waveform"},$0={class:"clip-info"},z0={class:"clip-label"},A0={class:"clip-duration"},D0={key:1,class:"filter-indicators"},U0={key:2,class:"speed-indicator"},O0={key:0,class:"selection-overlay"},L0=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 y=t.clip.timelineEnd-t.clip.timelineStart;return v(y)}),m=e.computed(()=>t.clip.filters&&t.clip.filters.length>0),h=e.computed(()=>t.clip.filters||[]);function v(y){if(y<1)return`${Math.round(y*30)}f`;if(y<60)return`${y.toFixed(1)}s`;{const C=Math.floor(y/60),D=Math.floor(y%60);return`${C}:${D.toString().padStart(2,"0")}`}}function b(y){return!y||typeof y!="string"?ys:y.includes("color")||y.includes("brightness")?an:y.includes("blur")?rm:y.includes("style")?no:y.includes("effect")?on:ys}function x(){i.value||a("select")}function R(y){y.button===0&&(f("move",y.clientX),y.preventDefault())}function S(y){if(y.touches.length!==1)return;const C=y.touches[0];f("move",C.clientX),y.preventDefault()}function g(y,C){const D="touches"in C?C.touches[0].clientX:C.clientX;s.value=y==="start"?"trim-start":"trim-end",f(s.value,D),C.preventDefault(),C.stopPropagation()}function f(y,C){i.value=!0,s.value=y,l.value=C,y==="move"?c.value=t.clip.timelineStart:y==="trim-start"?c.value=t.clip.sourceIn:y==="trim-end"&&(c.value=t.clip.sourceOut),document.addEventListener("mousemove",w),document.addEventListener("mouseup",$),document.addEventListener("touchmove",w),document.addEventListener("touchend",$),t.selected||a("select")}function w(y){if(!i.value||!s.value)return;const C="touches"in y?y.touches[0].clientX:y.clientX,k=C-l.value;s.value==="move"?(a("drag",k),a("drag-abs",C)):s.value==="trim-start"?(a("trim-start",k),a("trim-start-abs",C)):s.value==="trim-end"&&(a("trim-end",k),a("trim-end-abs",C))}function $(){i.value=!1,s.value=null,document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",$),document.removeEventListener("touchmove",w),document.removeEventListener("touchend",$)}function V(){if(!r.value)return;const y=r.value,C=y.getContext("2d");if(!C)return;y.width=y.clientWidth*window.devicePixelRatio,y.height=y.clientHeight*window.devicePixelRatio,C.scale(window.devicePixelRatio,window.devicePixelRatio),C.strokeStyle="rgba(255, 255, 255, 0.3)",C.lineWidth=1,C.beginPath();const D=y.clientWidth,k=y.clientHeight,T=k/2;C.moveTo(0,T),C.lineTo(D,T);for(let F=0;F<D;F+=4){const A=Math.sin(F*.05)*(k*.3);C.moveTo(F,T-A),C.lineTo(F,T+A)}C.stroke()}return e.onMounted(()=>{V(),window.addEventListener("resize",V)}),e.onUnmounted(()=>{$(),window.removeEventListener("resize",V)}),(y,C)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-clip",{selected:y.selected,mobile:y.isMobile,"has-filters":m.value}]),style:e.normalizeStyle(d.value),onClick:x,onMousedown:R,onTouchstart:S},[e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:C[0]||(C[0]=e.withModifiers(D=>g("start",D),["stop"])),onTouchstart:C[1]||(C[1]=e.withModifiers(D=>g("start",D),["stop"])),"aria-label":`Trim start of ${y.clip.label||"clip"}`},[...C[4]||(C[4]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,M0),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:C[2]||(C[2]=e.withModifiers(D=>g("end",D),["stop"])),onTouchstart:C[3]||(C[3]=e.withModifiers(D=>g("end",D),["stop"])),"aria-label":`Trim end of ${y.clip.label||"clip"}`},[...C[5]||(C[5]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,F0),e.createElementVNode("div",B0,[y.clip.thumbnail?(e.openBlock(),e.createElementBlock("div",I0,[e.createElementVNode("img",{src:y.clip.thumbnail,alt:y.clip.label||"Video clip"},null,8,R0)])):e.createCommentVNode("",!0),e.createElementVNode("div",P0,[e.createElementVNode("canvas",{ref_key:"waveformCanvas",ref:r},null,512)]),e.createElementVNode("div",$0,[e.createElementVNode("span",z0,e.toDisplayString(u.value),1),e.createElementVNode("span",A0,e.toDisplayString(p.value),1)]),m.value?(e.openBlock(),e.createElementBlock("div",D0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,D=>(e.openBlock(),e.createBlock(e.unref(I.IonIcon),{key:D.id||D.filterId,icon:b(D.filterId||D.id),title:`Filter: ${D.filterId||D.id}`},null,8,["icon","title"]))),128))])):e.createCommentVNode("",!0),y.clip.speed&&y.clip.speed!==1?(e.openBlock(),e.createElementBlock("div",U0,e.toDisplayString(y.clip.speed)+"x ",1)):e.createCommentVNode("",!0)]),y.selected?(e.openBlock(),e.createElementBlock("div",O0)):e.createCommentVNode("",!0)],38))}}),W0=_e(L0,[["__scopeId","data-v-e4f00ac9"]]);class dc{constructor(o=30){this.fps=30,this.fps=o}setFps(o){this.fps=o}async convertTimelineClipToEngine(o,t){const a=new Pr(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 vn.from(r.url),s=await this.convertTimelineClipToEngine(r,i);await t.add(s)}catch{}o.duration&&(t.duration=fe.fromFrames(this.secondsToFrames(o.duration)))}extractTimelineFromComposition(o){const t=[];return(o.clips||[]).forEach((r,i)=>{var s,l;r instanceof Pr&&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 j0={class:"time-markers"},X0=["aria-label","title"],Z0={key:0,class:"timeline-scrollbar"},Y0=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,L=>{L!==void 0&&(s.value=L)});const m=new dc(t.fps),h=e.ref(!1),v=e.ref(null),b=e.ref(0),x=e.ref(0),R=e.ref(0),S=e.ref(0),g=e.ref(0),f=e.ref(!1),w=e.ref(0),$=e.ref(t.zoomLevel),V=e.computed(()=>t.zoomLevel);function y(L){const oe=t.clips.find(te=>te.id===L);if(!oe)return null;const Q=t.clips.filter(te=>te.id!==L&&te.timelineStart>=oe.timelineEnd-1e-9).map(te=>te.timelineStart);return Q.length?Math.min(...Q):null}function C(L){const oe=L.sourceMaxOut??t.duration,Q=L.timelineStart+(oe-L.sourceIn),te=y(L.id),xe=te!=null?Math.max(L.timelineStart,te):1/0;return Math.min(Q,xe)}function D(L){const oe=L.sourceMinIn??0,te=(L.sourceMaxOut??t.duration)-oe,xe=L.sourceIn-oe;return{left:`${(L.timelineStart-xe)*V.value-c.value}px`,width:`${te*V.value}px`,top:"0px",height:"80px",opacity:p.value===L.id?.25:.15}}const k=e.computed(()=>t.useFrameMode?t.zoomLevel:t.zoomLevel/t.fps),T=e.computed(()=>m.secondsToFrames(t.duration)),F=e.computed(()=>t.useFrameMode?T.value*k.value:t.duration*V.value),A=e.computed(()=>{var L;return u.value||((L=i.value)==null?void 0:L.clientWidth)||800}),P=e.computed(()=>F.value>A.value),O=e.computed(()=>Math.max(0,F.value-A.value)),B=e.computed(()=>c.value>0),_=e.computed(()=>c.value<O.value),X=e.computed(()=>t.useFrameMode?m.secondsToFrames(t.playhead)*k.value-c.value:t.playhead*V.value-c.value),W=e.computed(()=>{const L=Math.max(50,A.value/F.value*A.value),oe=c.value/O.value*(A.value-L);return{width:`${L}px`,left:`${oe}px`}}),ee=e.computed(()=>{const L=[],oe=he();for(let Q=0;Q<=t.duration;Q+=oe){const te=Q*V.value-c.value;te>=-50&&te<=A.value+50&&L.push({position:te,label:Ue(Q),time:Q})}return L});function he(){const oe=80/V.value;return oe<=1?1:oe<=5?5:oe<=10?10:oe<=30?30:oe<=60?60:Math.ceil(oe/60)*60}function Ue(L){if(t.useFrameMode)return`F${m.secondsToFrames(L)}`;{const oe=Math.floor(L/60),Q=Math.floor(L%60),te=Math.floor(L%1*t.fps);return V.value>100?`${oe}:${Q.toString().padStart(2,"0")}:${te.toString().padStart(2,"0")}`:`${oe}:${Q.toString().padStart(2,"0")}`}}function Te(L){const oe=i.value.getBoundingClientRect();let te=(L.clientX-oe.left+c.value)/V.value;const xe=t.clips.find(Ee=>te>=Ee.timelineStart&&te<=Ee.timelineEnd);if(xe)te=Math.max(xe.timelineStart,Math.min(xe.timelineEnd,te));else if(t.selectedClipId){const Ee=t.clips.find(Re=>Re.id===t.selectedClipId);if(Ee){const Re=Math.abs(te-Ee.timelineStart),Oe=Math.abs(te-Ee.timelineEnd);te=Re<Oe?Ee.timelineStart:Ee.timelineEnd}}else te=Math.max(0,Math.min(te,t.duration));r("update:playhead",te)}function re(L){if(!P.value)return;const oe=Math.abs(L.deltaX)>Math.abs(L.deltaY)?L.deltaX:L.deltaY;oe!==0&&(L.preventDefault(),c.value=Math.max(0,Math.min(O.value,c.value+oe)))}function M(L){if(L.touches.length===2){f.value=!0;const oe=L.touches[0],Q=L.touches[1];w.value=Math.hypot(Q.clientX-oe.clientX,Q.clientY-oe.clientY),$.value=t.zoomLevel}else L.touches.length===1&&(R.value=L.touches[0].clientX,S.value=L.touches[0].clientY,g.value=R.value)}function j(L){if(f.value&&L.touches.length===2){const oe=L.touches[0],Q=L.touches[1],xe=Math.hypot(Q.clientX-oe.clientX,Q.clientY-oe.clientY)/w.value;Math.max(10,Math.min(200,$.value*xe)),r("update:playhead",t.playhead)}else if(L.touches.length===1&&!f.value){const oe=L.touches[0],Q=g.value-oe.clientX;Math.abs(Q)>Math.abs(oe.clientY-S.value)&&(L.preventDefault(),c.value=Math.max(0,Math.min(F.value-A.value,c.value+Q)),g.value=oe.clientX)}}function le(){f.value=!1}function ae(L){const oe=L.target;if(oe.closest(".playhead-handle"))return;const Q=L.button===1,te=!!oe.closest(".video-track");(Q||!te&&P.value)&&H(L)}function H(L){h.value=!0,v.value="pan",b.value=L.clientX,x.value=c.value,document.addEventListener("mousemove",ve),document.addEventListener("mouseup",ke)}function K(L){L.preventDefault(),L.stopPropagation(),h.value=!0,v.value="playhead";const oe="touches"in L?L.touches[0].clientX:L.clientX;b.value=oe,x.value=t.playhead,"touches"in L?(document.addEventListener("touchmove",ve),document.addEventListener("touchend",ke)):(document.addEventListener("mousemove",ve),document.addEventListener("mouseup",ke))}function ce(L){L.preventDefault(),L.stopPropagation(),h.value=!0,v.value="scrollbar";const oe="touches"in L?L.touches[0].clientX:L.clientX;b.value=oe,x.value=c.value,"touches"in L?(document.addEventListener("touchmove",ve),document.addEventListener("touchend",ke)):(document.addEventListener("mousemove",ve),document.addEventListener("mouseup",ke))}function ve(L){if(!h.value)return;const Q=("touches"in L?L.touches[0].clientX:L.clientX)-b.value;if(v.value==="playhead"){const te=Q/V.value;let xe=x.value+te;if(t.selectedClipId){const Ee=t.clips.find(Re=>Re.id===t.selectedClipId);Ee?xe=Math.max(Ee.timelineStart,Math.min(Ee.timelineEnd,xe)):xe=Math.max(0,Math.min(t.duration,xe))}else{const Ee=t.clips.find(Re=>t.playhead>=Re.timelineStart&&t.playhead<=Re.timelineEnd);Ee?xe=Math.max(Ee.timelineStart,Math.min(Ee.timelineEnd,xe)):xe=Math.max(0,Math.min(t.duration,xe))}r("update:playhead",xe)}else if(v.value==="scrollbar"){const te=Q/A.value*F.value;c.value=Math.max(0,Math.min(O.value,x.value+te))}else if(v.value==="pan"){const te=x.value-Q;c.value=Math.max(0,Math.min(O.value,te))}}function ke(){h.value=!1,v.value=null,document.removeEventListener("mousemove",ve),document.removeEventListener("mouseup",ke),document.removeEventListener("touchmove",ve),document.removeEventListener("touchend",ke)}function ne(L){s.value=s.value===L?null:L,r("clip-select",s.value)}function we(L,oe){const Q=t.clips.find(xe=>xe.id===L);if(!Q||Math.abs(oe)<2)return;const te=oe/V.value*t.sensitivity;if(t.useFrameMode){const xe=m.secondsToFrames(Q.sourceIn),Ee=m.secondsToFrames(te),Re=Math.max(0,xe+Ee),Oe=m.framesToSeconds(Re);r("trim",L,"start",Oe)}else{const xe=Math.max(0,Q.sourceIn+te);r("trim",L,"start",xe)}}function pe(L,oe){const Q=t.clips.find(be=>be.id===L);if(!Q||!i.value)return;const te=i.value.getBoundingClientRect(),xe=oe-te.left,Ee=80;if(xe<Ee)c.value=Math.max(0,c.value-8);else if(xe>te.width-Ee){const be=Math.max(0,F.value-A.value);c.value=Math.min(be,c.value+8)}const Re=xe+c.value,Oe=1/t.fps;let G=Re/V.value;G=Math.max(0,Math.min(G,Q.timelineEnd-Oe));let ue=Q.sourceIn+(G-Q.timelineStart);ue=Math.round(ue*t.fps)/t.fps,r("trim",L,"start",ue)}function qe(L,oe){const Q=t.clips.find(Me=>Me.id===L);if(!Q||!i.value)return;const te=i.value.getBoundingClientRect(),xe=oe-te.left,Ee=80;if(xe<Ee)c.value=Math.max(0,c.value-8);else if(xe>te.width-Ee){const Me=Math.max(0,F.value-A.value);c.value=Math.min(Me,c.value+8)}const Re=xe+c.value,Oe=1/t.fps,G=C(Q);let ue=Re/V.value;ue=Math.max(Q.timelineStart+Oe,Math.min(ue,G));let be=Q.sourceIn+(ue-Q.timelineStart);be=Math.round(be*t.fps)/t.fps,r("trim",L,"end",be)}function rt(L,oe){const Q=t.clips.find(G=>G.id===L);if(!Q||!i.value)return;const te=i.value.getBoundingClientRect(),Ee=oe-te.left+c.value,Re=Q.timelineEnd-Q.timelineStart;let Oe=Ee/V.value;Oe=Math.max(0,Math.min(Oe,t.duration-Re)),Oe=Math.round(Oe*t.fps)/t.fps,r("clip-move",L,Oe)}function de(L,oe){const Q=t.clips.find(Ee=>Ee.id===L);if(!Q||Math.abs(oe)<2)return;const te=oe/V.value*t.sensitivity,xe=Ee=>Math.max(0,Math.round(Ee*t.fps)/t.fps);if(t.useFrameMode){const Ee=m.secondsToFrames(Q.sourceOut),Re=m.secondsToFrames(te),Oe=C(Q),G=Q.sourceIn+(Oe-Q.timelineStart),ue=m.secondsToFrames(G),be=Math.min(ue,Ee+Re),Me=m.framesToSeconds(be);r("trim",L,"end",Me)}else{const Ee=C(Q),Re=Q.sourceIn+(Ee-Q.timelineStart),Oe=Math.min(Re,Q.sourceOut+te),G=xe(Oe);r("trim",L,"end",G)}}function ye(L,oe){const Q=t.clips.find(Ee=>Ee.id===L);if(!Q||Math.abs(oe)<2)return;const te=oe/V.value*t.sensitivity,xe=Ee=>Math.max(0,Math.round(Ee*t.fps)/t.fps);if(t.useFrameMode){const Ee=m.secondsToFrames(Q.timelineStart),Re=m.secondsToFrames(te),Oe=Math.max(0,Ee+Re),G=m.framesToSeconds(Oe);r("clip-move",L,G)}else{const Ee=Math.max(0,Q.timelineStart+te),Re=xe(Ee);r("clip-move",L,Re)}}return e.watch(()=>t.playhead,L=>{const oe=L*V.value;oe<c.value+50?c.value=Math.max(0,oe-50):oe>c.value+A.value-50&&(c.value=Math.min(O.value,oe-A.value+50))}),e.onMounted(()=>{const L=new ResizeObserver(oe=>{oe[0]&&(u.value=Math.round(oe[0].contentRect.width))});i.value&&L.observe(i.value),e.onUnmounted(()=>L.disconnect())}),e.onUnmounted(()=>{ke()}),e.watch([F,A],()=>{c.value>O.value&&(c.value=O.value)}),(L,oe)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-timeline",{mobile:a.value}]),ref_key:"timelineRef",ref:i,onWheel:re},[e.createElementVNode("div",{class:"timeline-ruler",onClick:Te},[e.createElementVNode("div",j0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ee.value,Q=>(e.openBlock(),e.createElementBlock("span",{key:Q.position,class:"time-marker",style:e.normalizeStyle({left:`${Q.position}px`})},e.toDisplayString(Q.label),5))),128))])]),e.createElementVNode("div",{class:e.normalizeClass(["timeline-content",{"is-pannable":P.value,"is-panning":h.value&&v.value==="pan","overflow-left":B.value,"overflow-right":_.value}]),onTouchstart:M,onTouchmove:j,onTouchend:le,onMousedown:ae},[e.createElementVNode("div",{class:"video-track",ref_key:"trackRef",ref:d},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(L.clips,Q=>(e.openBlock(),e.createElementBlock("div",{key:`${Q.id}-extent`,class:"clip-extent",style:e.normalizeStyle(D(Q)),"aria-hidden":"true"},null,4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(L.clips,Q=>(e.openBlock(),e.createBlock(W0,{key:Q.id,clip:Q,scale:V.value,"scroll-offset":c.value,selected:p.value===Q.id,"is-mobile":a.value,onSelect:te=>ne(Q.id),onTrimStart:te=>we(Q.id,te),onTrimEnd:te=>de(Q.id,te),onDrag:te=>ye(Q.id,te),onTrimStartAbs:te=>pe(Q.id,te),onTrimEndAbs:te=>qe(Q.id,te),onDragAbs:te=>rt(Q.id,te)},null,8,["clip","scale","scroll-offset","selected","is-mobile","onSelect","onTrimStart","onTrimEnd","onDrag","onTrimStartAbs","onTrimEndAbs","onDragAbs"]))),128))],512),e.createElementVNode("div",{class:"playhead",style:e.normalizeStyle({left:`${X.value}px`}),onMousedown:K,onTouchstart:K},[...oe[1]||(oe[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:`${X.value}px`})},null,4)):e.createCommentVNode("",!0),a.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"frame-mode-toggle",onClick:oe[0]||(oe[0]=Q=>L.$emit("toggle-frame-mode")),"aria-label":L.useFrameMode?"Switch to time mode":"Switch to frame mode",title:L.useFrameMode?"Switch to time mode":"Switch to frame mode"},e.toDisplayString(L.useFrameMode?"F":"T"),9,X0))],34),P.value?(e.openBlock(),e.createElementBlock("div",Z0,[e.createElementVNode("div",{class:"scrollbar-thumb",style:e.normalizeStyle(W.value),onMousedown:ce,onTouchstart:ce},null,36)])):e.createCommentVNode("",!0)],34))}}),Os=_e(Y0,[["__scopeId","data-v-d15e2d45"]]),G0={class:"control-group zoom-controls"},H0={class:"zoom-slider"},J0=["value"],q0={class:"control-group playback-controls"},K0=["aria-label"],Q0={key:0,class:"control-group speed-control"},ev=["value"],tv=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",G0,[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(I.IonIcon),{icon:e.unref(xm)},null,8,["icon"])]),e.createElementVNode("div",H0,[e.createElementVNode("input",{type:"range",value:u.zoomLevel,onInput:a,min:"10",max:"200",step:"5","aria-label":"Timeline zoom"},null,40,J0)]),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(I.IonIcon),{icon:e.unref(Zu)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:r,"aria-label":"Fit timeline to window"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(am)},null,8,["icon"]),p[3]||(p[3]=e.createElementVNode("span",{class:"control-label"},"Fit",-1))])]),e.createElementVNode("div",q0,[e.createElementVNode("button",{class:"control-button",onClick:l,"aria-label":"Skip to start"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(wm)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:s,"aria-label":"Previous frame"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(hm)},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(I.IonIcon),{icon:u.isPlaying?e.unref(mm):e.unref(bm)},null,8,["icon"])],8,K0),e.createElementVNode("button",{class:"control-button",onClick:i,"aria-label":"Next frame"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ym)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:c,"aria-label":"Skip to end"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(km)},null,8,["icon"])])]),u.isMobile?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Q0,[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-9a3abcf5>0.25x</option><option value="0.5" data-v-9a3abcf5>0.5x</option><option value="1" data-v-9a3abcf5>1x</option><option value="1.5" data-v-9a3abcf5>1.5x</option><option value="2" data-v-9a3abcf5>2x</option>',5)])],40,ev)]))],2))}}),nv=_e(tv,[["__scopeId","data-v-9a3abcf5"]]),ov={class:"video-filter-carousel-container"},av={key:0,class:"category-section"},rv={class:"category-carousel-wrapper"},iv=["disabled"],sv=["onClick"],lv={class:"category-name"},cv=["disabled"],dv={class:"filter-section"},uv={class:"filter-carousel-wrapper"},mv=["disabled"],pv=["onClick"],fv=["onClick"],hv={class:"filter-preview"},vv={class:"filter-placeholder"},gv={class:"filter-name"},yv=["disabled"],bv={class:"carousel-pagination"},wv=["onClick"],kv={key:1,class:"filter-adjustments"},xv={class:"adjustment-header"},Ev={class:"adjustment-actions"},Sv={key:0},Vv={key:0,class:"slider-control"},Cv={class:"control-label"},Nv={class:"slider-wrapper"},_v={class:"slider-value"},Tv={key:1,class:"color-control"},Mv={class:"control-label"},Fv={class:"color-wrapper"},Bv=["value","onInput","disabled"],Iv={class:"color-value"},Rv={key:2,class:"toggle-control"},Pv={class:"control-label"},$v={key:3,class:"select-control"},zv={class:"control-label"},Av=["value","onChange","disabled"],Dv=["value"],Uv={key:1,class:"no-params"},Ov=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:on,adjust:Jn,color:an,blur:Lo,light:qn,effects:sr,stylize:no,advanced:on,distortion:oo,transform:oo};function m(B){return B.replace(/[-_]/g," ").replace(/\b\w/g,_=>_.toUpperCase())}function h(B){return p[B.toLowerCase()]??on}const v=e.computed(()=>{const B=Array.from(new Set(t.filters.map(_=>_.category).filter(_=>typeof _=="string"&&_.length>0))).sort((_,X)=>_.localeCompare(X));return[{id:"all",name:"All",icon:on},...B.map(_=>({id:_,name:m(_),icon:h(_)}))]}),b=e.computed(()=>r.value==="all"?t.filters:t.filters.filter(B=>B.category===r.value));e.watch(v,B=>{new Set(B.map(W=>W.id)).has(r.value)||(r.value="all");const X=Math.max(0,B.length-3);s.value>X&&(s.value=X)},{immediate:!0});function x(B){var _;return((_=t.activeFilters)==null?void 0:_.has(B))||!1}function R(B){if(i.value=B,!x(B.id)&&(a("apply-filter",B),B.params&&B.params.length>0)){const _=new Map;B.params.forEach(X=>{_.set(X.id,X.default)}),c.value.set(B.id,_)}a("preview-filter",B)}function S(B){var _;a("remove-filter",B),c.value.delete(B),((_=i.value)==null?void 0:_.id)===B&&(i.value=null)}function g(B){if(typeof B=="number"&&Number.isFinite(B))return B;if(typeof B=="string"){const _=Number(B);return Number.isFinite(_)?_:null}return null}function f(B,_){var Ue;const X=(Ue=t.activeFilters)==null?void 0:Ue.get(B);if(X&&X.params){const Te=X.params[_];if(Te!=null)return Te}const W=c.value.get(B);if(W){const Te=W.get(_);if(Te!=null)return Te}const ee=t.filters.find(Te=>Te.id===B),he=ee==null?void 0:ee.params.find(Te=>Te.id===_);return(he==null?void 0:he.default)??0}function w(B,_,X){var W;c.value.has(B)||c.value.set(B,new Map),(W=c.value.get(B))==null||W.set(_,X),a("update-param",B,_,X)}function $(B){if(typeof B=="boolean")return B?"On":"Off";if(typeof B=="string")return B;const _=g(B);return _===null?"0":Number.isInteger(_)?_.toString():_.toFixed(2)}function V(){if(i.value&&(a("apply-filter",i.value),i.value.params&&i.value.params.length>0)){const B=new Map;i.value.params.forEach(_=>{B.set(_.id,_.default)}),c.value.set(i.value.id,B)}}function y(B){const _=t.filters.find(X=>X.id===B);_&&_.params&&_.params.forEach(X=>{w(B,X.id,X.default)})}function C(B){return{basic:Jn,color:an,blur:Lo,light:qn,effects:sr,stylize:no,adjustment:Jn,"color-matrix":an,glow:on,distortion:oo}[B]||on}function D(B){return{adjustment:Jn,brightness:qn,contrast:Jn,saturation:an,blur:Lo,"gaussian-blur":Lo,"color-matrix":an,grayscale:no,sepia:no,vignette:oo,glow:on,glitch:sr,godray:qn,lightmap:qn}[B.id]||C(B.category)}function k(){s.value>0&&(s.value--,O(d.value,s.value))}function T(){s.value<v.value.length-3&&(s.value++,O(d.value,s.value))}function F(){l.value>0&&(l.value--,O(u.value,l.value))}function A(){l.value<b.value.length-4&&(l.value++,O(u.value,l.value))}function P(B){l.value=B*4,O(u.value,l.value)}function O(B,_){var X;if(B){const W=((X=B.querySelector(".category-chip, .filter-card"))==null?void 0:X.clientWidth)||100;B.scrollTo({left:_*(W+8),behavior:"smooth"})}}return(B,_)=>{var X;return e.openBlock(),e.createElementBlock("div",ov,[B.showCategories?(e.openBlock(),e.createElementBlock("div",av,[e.createElementVNode("div",rv,[e.createElementVNode("button",{onClick:k,class:"carousel-nav carousel-nav-left",disabled:s.value===0,"aria-label":"Previous categories"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ps)},null,8,["icon"])],8,iv),e.createElementVNode("div",{ref_key:"categoryCarouselRef",ref:d,class:"category-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,W=>(e.openBlock(),e.createElementBlock("button",{key:W.id,onClick:ee=>r.value=W.id,class:e.normalizeClass(["category-chip",{active:r.value===W.id}])},[e.createVNode(e.unref(I.IonIcon),{icon:W.icon,class:"category-icon"},null,8,["icon"]),e.createElementVNode("span",lv,e.toDisplayString(W.name),1)],10,sv))),128))],512),e.createElementVNode("button",{onClick:T,class:"carousel-nav carousel-nav-right",disabled:s.value>=v.value.length-3,"aria-label":"Next categories"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(fs)},null,8,["icon"])],8,cv)])])):e.createCommentVNode("",!0),e.createElementVNode("div",dv,[e.createElementVNode("div",uv,[e.createElementVNode("button",{onClick:F,class:"carousel-nav carousel-nav-left",disabled:l.value===0,"aria-label":"Previous filters"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ps)},null,8,["icon"])],8,mv),e.createElementVNode("div",{ref_key:"filterCarouselRef",ref:u,class:"filter-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,W=>{var ee;return e.openBlock(),e.createElementBlock("div",{key:W.id,class:e.normalizeClass(["filter-card",{active:x(W.id),selected:((ee=i.value)==null?void 0:ee.id)===W.id}]),onClick:he=>R(W)},[x(W.id)?(e.openBlock(),e.createElementBlock("div",{key:0,class:"filter-checkmark",onClick:e.withModifiers(he=>S(W.id),["stop"])},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Vl)},null,8,["icon"])],8,fv)):e.createCommentVNode("",!0),e.createElementVNode("div",hv,[e.createElementVNode("div",vv,[e.createVNode(e.unref(I.IonIcon),{icon:D(W),class:"filter-icon"},null,8,["icon"])])]),e.createElementVNode("span",gv,e.toDisplayString(W.name),1)],10,pv)}),128))],512),e.createElementVNode("button",{onClick:A,class:"carousel-nav carousel-nav-right",disabled:l.value>=Math.max(0,b.value.length-4),"aria-label":"Next filters"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(fs)},null,8,["icon"])],8,yv)]),e.createElementVNode("div",bv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Math.ceil(b.value.length/4),(W,ee)=>(e.openBlock(),e.createElementBlock("span",{key:ee,class:e.normalizeClass(["pagination-dot",{active:Math.floor(l.value/4)===ee}]),onClick:he=>P(ee)},null,10,wv))),128))])]),i.value?(e.openBlock(),e.createElementBlock("div",kv,[e.createElementVNode("div",xv,[e.createElementVNode("h4",null,e.toDisplayString(i.value.name),1),e.createElementVNode("div",Ev,[x(i.value.id)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,onClick:V,class:"apply-btn"}," Apply Filter ")),x(i.value.id)?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:_[0]||(_[0]=W=>S(i.value.id)),class:"remove-btn"}," Remove Filter ")):e.createCommentVNode("",!0),x(i.value.id)&&((X=i.value.params)==null?void 0:X.length)>0?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:_[1]||(_[1]=W=>y(i.value.id)),class:"reset-btn"}," Reset ")):e.createCommentVNode("",!0)])]),i.value.params&&i.value.params.length>0?(e.openBlock(),e.createElementBlock("div",Sv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value.params,W=>(e.openBlock(),e.createElementBlock("div",{key:W.id,class:"adjustment-control"},[!W.type||W.type==="slider"?(e.openBlock(),e.createElementBlock("div",Vv,[e.createElementVNode("label",Cv,e.toDisplayString(W.label||W.id),1),e.createElementVNode("div",Nv,[e.createVNode(e.unref(I.IonRange),{value:f(i.value.id,W.id),onIonChange:ee=>w(i.value.id,W.id,ee.detail.value),min:W.min,max:W.max,step:W.step||.01,color:"primary",class:"compact-slider",disabled:!x(i.value.id)},null,8,["value","onIonChange","min","max","step","disabled"]),e.createElementVNode("span",_v,e.toDisplayString($(f(i.value.id,W.id))),1)])])):W.type==="color"?(e.openBlock(),e.createElementBlock("div",Tv,[e.createElementVNode("label",Mv,e.toDisplayString(W.label||W.id),1),e.createElementVNode("div",Fv,[e.createElementVNode("input",{type:"color",value:f(i.value.id,W.id),onInput:ee=>w(i.value.id,W.id,ee.target.value),disabled:!x(i.value.id),class:"color-input"},null,40,Bv),e.createElementVNode("span",Iv,e.toDisplayString(f(i.value.id,W.id)),1)])])):W.type==="toggle"?(e.openBlock(),e.createElementBlock("div",Rv,[e.createElementVNode("label",Pv,e.toDisplayString(W.label||W.id),1),e.createVNode(e.unref(I.IonToggle),{checked:!!f(i.value.id,W.id),onIonChange:ee=>w(i.value.id,W.id,ee.detail.checked),disabled:!x(i.value.id),color:"primary"},null,8,["checked","onIonChange","disabled"])])):W.type==="select"?(e.openBlock(),e.createElementBlock("div",$v,[e.createElementVNode("label",zv,e.toDisplayString(W.label||W.id),1),e.createElementVNode("select",{value:f(i.value.id,W.id),onChange:ee=>w(i.value.id,W.id,ee.target.value),disabled:!x(i.value.id),class:"select-input"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.options,ee=>(e.openBlock(),e.createElementBlock("option",{key:String(ee.value),value:ee.value},e.toDisplayString(ee.label),9,Dv))),128))],40,Av)])):e.createCommentVNode("",!0)]))),128))])):(e.openBlock(),e.createElementBlock("div",Uv," This filter has no adjustable parameters "))])):e.createCommentVNode("",!0)])}}}),Ls=_e(Ov,[["__scopeId","data-v-88360322"]]);class Lv{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 Wv={class:"video-filter-preview"},jv={class:"preview-title"},Xv={class:"filter-controls"},Zv={class:"control-input"},Yv=["value","onInput","min","max","step"],Gv={class:"param-value"},Hv={class:"preview-container"},Jv={key:0,class:"filter-presets"},qv=["onClick"],Kv={class:"preview-actions"},Qv=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 y;return((y=t.filter)==null?void 0:y.paramRanges)||{}}),m=e.computed(()=>h.value.length>0),h=e.computed(()=>t.filter?{brightness:[{name:"Subtle",params:{value:.1}},{name:"Medium",params:{value:.3}},{name:"Strong",params:{value:.5}}],contrast:[{name:"Low",params:{value:.8}},{name:"Normal",params:{value:1}},{name:"High",params:{value:1.5}}],"gaussian-blur":[{name:"Subtle",params:{value:1}},{name:"Medium",params:{value:3}},{name:"Strong",params:{value:5}}]}[t.filter.id]||[]:[]);async function v(){var y;if(r.value){t.useVideoEngine&&t.composition&&(u=new Lv(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}),(y=t.currentFrame)!=null&&y.dataUrl){const C=await Ae.Assets.load(t.currentFrame.dataUrl);c=new Ae.Sprite(C);const D=Math.min(l.screen.width/c.texture.width,l.screen.height/c.texture.height);c.scale.set(D),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 y={id:t.filter.id,filterId:t.filter.id,params:s.value,intensity:s.value.value??s.value.intensity??1};u.applyFilters([y]).then(()=>{}).catch(C=>{}),d&&(d.destroy(),d=null),d=x(t.filter.id,s.value),d&&(c.filters=i.value?null:[d])}else d&&(d.destroy(),d=null),d=x(t.filter.id,s.value),d&&(c.filters=i.value?null:[d])}function x(y,C){switch(y){case"brightness":{const D=new Ae.ColorMatrixFilter,k=1+(C.value??0);return typeof D.brightness=="function"&&D.brightness(k,!1),D}case"contrast":{const D=new Ae.ColorMatrixFilter,k=C.value??1;return typeof D.contrast=="function"&&D.contrast(k,!1),D}case"saturation":{const D=new Ae.ColorMatrixFilter,k=C.value??1;return typeof D.saturate=="function"&&D.saturate(k,!1),D}case"hue":{const D=new Ae.ColorMatrixFilter,k=C.value??0;return typeof D.hue=="function"&&D.hue(k,!1),D}case"gaussian-blur":{const D=C.value??5;return new Ae.BlurFilter({strength:D,quality:4})}case"sepia":{const D=new Ae.ColorMatrixFilter;return typeof D.sepia=="function"&&D.sepia(!1),D}case"grayscale":{const D=new Ae.ColorMatrixFilter;return typeof D.desaturate=="function"&&D.desaturate(),D}default:return null}}function R(y,C){const D=C.target,k=Number.parseFloat(D.value),T=Number.isFinite(k)?k:0;s.value={...s.value,[y]:T},t.useVideoEngine&&u&&t.filter&&u.updateFilterParams(t.filter.id,s.value),a("update-params",s.value),b()}function S(y){return y.charAt(0).toUpperCase()+y.slice(1).replace(/_/g," ")}function g(y,C){var k;const D=typeof y=="number"?y:Number(y);return Number.isFinite(D)?C==="hue"||C==="angle"?`${D}°`:C==="value"&&((k=t.filter)==null?void 0:k.id)==="brightness"?`${Math.round((1+D)*100)}%`:Number.isInteger(D)?D.toString():D.toFixed(2):"0"}function f(){var y;s.value=((y=t.filter)==null?void 0:y.defaultParams)||{},a("update-params",s.value),b()}function w(y){s.value={...y.params},a("update-params",s.value),b()}function $(y){return JSON.stringify(y.params)===JSON.stringify(s.value)}function V(){a("apply")}return e.watch(()=>t.filter,y=>{y&&(s.value={...y.defaultParams},b())}),e.watch(()=>t.currentFrame,async y=>{if(y!=null&&y.dataUrl&&c){const C=await Ae.Assets.load(y.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()}),(y,C)=>{var D;return e.openBlock(),e.createElementBlock("div",Wv,[e.createElementVNode("h4",jv,e.toDisplayString((D=y.filter)==null?void 0:D.name)+" Settings",1),e.createElementVNode("div",Xv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,(k,T)=>(e.openBlock(),e.createElementBlock("div",{key:T,class:"control-group"},[e.createElementVNode("label",null,e.toDisplayString(S(T)),1),e.createElementVNode("div",Zv,[e.createElementVNode("input",{type:"range",value:s.value[T],onInput:F=>R(T,F),min:k.min,max:k.max,step:k.step,class:"param-slider"},null,40,Yv),e.createElementVNode("span",Gv,e.toDisplayString(g(s.value[T],T)),1)])]))),128))]),e.createElementVNode("div",Hv,[e.createElementVNode("canvas",{ref_key:"previewCanvas",ref:r,class:"preview-canvas"},null,512),e.createElementVNode("button",{class:"compare-button",onMousedown:C[0]||(C[0]=k=>i.value=!0),onMouseup:C[1]||(C[1]=k=>i.value=!1),onTouchstart:C[2]||(C[2]=k=>i.value=!0),onTouchend:C[3]||(C[3]=k=>i.value=!1)},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(oo)},null,8,["icon"]),C[4]||(C[4]=e.createTextVNode(" Hold to compare ",-1))],32)]),m.value?(e.openBlock(),e.createElementBlock("div",Jv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,k=>(e.openBlock(),e.createElementBlock("button",{key:k.name,class:e.normalizeClass(["preset-button",{active:$(k)}]),onClick:T=>w(k)},e.toDisplayString(k.name),11,qv))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",Kv,[e.createElementVNode("button",{class:"action-button",onClick:f},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ko)},null,8,["icon"]),C[5]||(C[5]=e.createTextVNode(" Reset ",-1))]),e.createElementVNode("button",{class:"action-button primary",onClick:V},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Cl)},null,8,["icon"]),C[6]||(C[6]=e.createTextVNode(" Apply Filter ",-1))])])])}}}),Ws=_e(Qv,[["__scopeId","data-v-3de3dd04"]]),eg={class:"export-settings"},tg={class:"setting-group"},ng={class:"setting-group"},og={class:"estimated-size"},ag={key:0,class:"export-progress"},rg={class:"progress-header"},ig={class:"progress-percentage"},sg={class:"progress-time"},lg={class:"action-buttons"},cg=["disabled"],dg=["disabled"],ug=["disabled"],mg={class:"export-options"},pg=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 f=({"360p":1,"480p":2.5,"720p":5,"1080p":8,"1440p":16,"2160p":35}[r.value]||8)*t.duration/8;return f<1e3?`~${Math.round(f)} MB`:`~${(f/1e3).toFixed(1)} GB`});function h(){t.isExporting?(a("cancel-export"),x()):v()}function v(){const S={quality:r.value,format:i.value,optimizeForWeb:s.value,includeWatermark:l.value};a("export",S),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 S=d.value/t.exportProgress*100;u.value=Math.max(0,S-d.value)}},1e3)}function x(){p&&(clearInterval(p),p=null)}function R(S){const g=Math.floor(S/60),f=Math.floor(S%60);return`${g}:${f.toString().padStart(2,"0")}`}return e.watch(()=>t.isExporting,S=>{S||x()}),e.onUnmounted(()=>{x()}),(S,g)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["editor-controls",{mobile:S.isMobile}])},[e.createElementVNode("div",eg,[g[10]||(g[10]=e.createElementVNode("h3",{class:"section-title"},"Export Settings",-1)),e.createElementVNode("div",tg,[g[7]||(g[7]=e.createElementVNode("label",null,"Quality",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":g[0]||(g[0]=f=>r.value=f),class:"setting-select"},[...g[6]||(g[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",ng,[g[9]||(g[9]=e.createElementVNode("label",null,"Format",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":g[1]||(g[1]=f=>i.value=f),class:"setting-select"},[...g[8]||(g[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",og,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(lm)},null,8,["icon"]),e.createElementVNode("span",null,"Estimated size: "+e.toDisplayString(m.value),1)])]),S.isExporting?(e.openBlock(),e.createElementBlock("div",ag,[e.createElementVNode("div",rg,[g[11]||(g[11]=e.createElementVNode("span",null,"Exporting...",-1)),e.createElementVNode("span",ig,e.toDisplayString(S.exportProgress??0)+"%",1)]),e.createVNode(e.unref(I.IonProgressBar),{value:(S.exportProgress??0)/100},null,8,["value"]),e.createElementVNode("div",sg,[e.createElementVNode("span",null,e.toDisplayString(R(d.value))+" elapsed",1),e.createElementVNode("span",null,e.toDisplayString(R(u.value))+" remaining",1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",lg,[e.createElementVNode("button",{class:"control-button secondary",onClick:g[2]||(g[2]=f=>S.$emit("save-draft")),disabled:!S.canExport||S.isExporting},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ml)},null,8,["icon"]),g[12]||(g[12]=e.createTextVNode(" Save Draft ",-1))],8,cg),e.createElementVNode("button",{class:"control-button secondary",onClick:g[3]||(g[3]=f=>S.$emit("reset")),disabled:S.isExporting},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ko)},null,8,["icon"]),g[13]||(g[13]=e.createTextVNode(" Reset ",-1))],8,dg),e.createElementVNode("button",{class:"control-button primary",onClick:h,disabled:!S.canExport&&!S.isExporting,"data-testid":"video-export-button"},[e.createVNode(e.unref(I.IonIcon),{icon:S.isExporting?e.unref(go):e.unref(Ea)},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(S.isExporting?"Cancel":"Export Video"),1)],8,ug)]),e.createElementVNode("div",mg,[e.createVNode(e.unref(I.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonCheckbox),{modelValue:s.value,"onUpdate:modelValue":g[4]||(g[4]=f=>s.value=f)},null,8,["modelValue"]),e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...g[14]||(g[14]=[e.createTextVNode("Optimize for web streaming",-1)])]),_:1})]),_:1}),e.createVNode(e.unref(I.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonCheckbox),{modelValue:l.value,"onUpdate:modelValue":g[5]||(g[5]=f=>l.value=f)},null,8,["modelValue"]),e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...g[15]||(g[15]=[e.createTextVNode("Include watermark",-1)])]),_:1})]),_:1})])],2))}}),js=_e(pg,[["__scopeId","data-v-e1338d5e"]]),fg={class:"thumbnail-picker"},hg={class:"thumbnail-grid"},vg=["onClick"],gg=["src","alt"],yg={key:1,class:"thumbnail-placeholder"},bg={class:"thumbnail-time"},wg={class:"custom-selector"},kg={class:"time-input-group"},xg=["max"],Eg={class:"time-value"},Sg=["disabled"],Vg={class:"picker-actions"},Cg=["disabled"],Ng=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 R=[];if(t.duration<=10)for(let g=0;g<Math.min(9,t.duration);g++)R.push(g);else{const g=t.duration/10;for(let f=1;f<=9;f++)R.push(g*f)}return R}async function d(R){try{const S=document.createElement("video");return S.crossOrigin="anonymous",S.src=await u(),new Promise(g=>{S.addEventListener("loadedmetadata",()=>{S.currentTime=R}),S.addEventListener("seeked",()=>{const f=document.createElement("canvas");f.width=S.videoWidth,f.height=S.videoHeight;const w=f.getContext("2d");w?(w.drawImage(S,0,0),g(f.toDataURL("image/jpeg",.8))):g(null),S.remove()}),S.addEventListener("error",()=>{g(null),S.remove()})})}catch{return null}}async function u(){try{return(await(await fetch(`/api/media/${t.mediaUuid}/playback`)).json()).playback_url}catch{return`/media/${t.mediaUuid}/video`}}async function p(){const R=c();r.value=R.map(g=>({time:g,loading:!0}));const S=3;for(let g=0;g<r.value.length;g+=S){const f=r.value.slice(g,g+S);await Promise.all(f.map(async w=>{const $=await d(w.time);$&&(w.dataUrl=$),w.loading=!1}))}}function m(R){i.value=R,s.value=r.value[R].time}function h(){i.value=-1}async function v(){l.value=!0;try{const R=await d(s.value);if(R){const S=r.value.findIndex(g=>Math.abs(g.time-s.value)<.1);S>=0?(r.value[S].dataUrl=R,i.value=S):(r.value.push({time:s.value,dataUrl:R}),i.value=r.value.length-1,r.value.sort((g,f)=>g.time-f.time),i.value=r.value.findIndex(g=>g.time===s.value))}}finally{l.value=!1}}function b(){const R=i.value>=0?r.value[i.value].time:s.value;a("select",R)}function x(R){const S=Math.floor(R/60),g=Math.floor(R%60),f=Math.floor(R%1*100);return S>0?`${S}:${g.toString().padStart(2,"0")}.${f.toString().padStart(2,"0")}`:`${g}.${f.toString().padStart(2,"0")}s`}return e.onMounted(()=>{p()}),(R,S)=>(e.openBlock(),e.createElementBlock("div",fg,[S[5]||(S[5]=e.createElementVNode("h4",{class:"picker-title"},"Select Video Thumbnail",-1)),e.createElementVNode("div",hg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(g,f)=>(e.openBlock(),e.createElementBlock("div",{key:f,class:e.normalizeClass(["thumbnail-item",{selected:i.value===f}]),onClick:w=>m(f)},[g.dataUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:g.dataUrl,alt:`Frame at ${x(g.time)}`},null,8,gg)):(e.openBlock(),e.createElementBlock("div",yg,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"})])),e.createElementVNode("div",bg,e.toDisplayString(x(g.time)),1)],10,vg))),128))]),e.createElementVNode("div",wg,[S[3]||(S[3]=e.createElementVNode("label",null,"Custom time:",-1)),e.createElementVNode("div",kg,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":S[0]||(S[0]=g=>s.value=g),min:0,max:R.duration,step:.1,onInput:h,class:"time-slider"},null,40,xg),[[e.vModelText,s.value]]),e.createElementVNode("span",Eg,e.toDisplayString(x(s.value)),1)]),e.createElementVNode("button",{class:"capture-button",onClick:v,disabled:l.value},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ju)},null,8,["icon"]),S[2]||(S[2]=e.createTextVNode(" Capture Frame ",-1))],8,Sg)]),e.createElementVNode("div",Vg,[e.createElementVNode("button",{class:"action-button",onClick:S[1]||(S[1]=g=>R.$emit("cancel"))}," Cancel "),e.createElementVNode("button",{class:"action-button primary",onClick:b,disabled:i.value===-1},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Cl)},null,8,["icon"]),S[4]||(S[4]=e.createTextVNode(" Set Thumbnail ",-1))],8,Cg)])]))}}),_g=_e(Ng,[["__scopeId","data-v-336c322c"]]),Tg={class:"text-overlay-panel p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},Mg={class:"mb-4"},Fg={class:"space-y-2 max-h-64 overflow-y-auto"},Bg={class:"flex items-center justify-between"},Ig={class:"flex-1"},Rg={class:"font-medium text-gray-900 dark:text-white"},Pg={class:"text-sm text-gray-500 dark:text-gray-400"},$g={class:"flex items-center space-x-2"},zg=["onClick"],Ag=["onClick"],Dg={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},Ug={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},Og={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},Lg={class:"space-y-4"},Wg={class:"grid grid-cols-2 gap-4"},jg={class:"grid grid-cols-2 gap-4"},Xg={key:0,class:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},Zg={class:"grid grid-cols-2 gap-3"},Yg={class:"flex justify-end space-x-3 mt-6"},Gg=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 h=Math.floor(m/60),v=Math.floor(m%60);return`${h}:${v.toString().padStart(2,"0")}`}return(m,h)=>(e.openBlock(),e.createElementBlock("div",Tg,[e.createElementVNode("div",Mg,[h[11]||(h[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Text Overlays ",-1)),e.createElementVNode("button",{onClick:h[0]||(h[0]=v=>a.value=!0),class:"w-full px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"},[...h[10]||(h[10]=[e.createElementVNode("svg",{class:"w-5 h-5 inline-block mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),e.createTextVNode(" Add Text Overlay ",-1)])])]),e.createElementVNode("div",Fg,[(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",Bg,[e.createElementVNode("div",Ig,[e.createElementVNode("div",Rg,e.toDisplayString(v.text.substring(0,30))+e.toDisplayString(v.text.length>30?"...":""),1),e.createElementVNode("div",Pg,e.toDisplayString(p(v.startTime??0))+" - "+e.toDisplayString(p((v.startTime||0)+(v.duration||5))),1)]),e.createElementVNode("div",$g,[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"},[...h[12]||(h[12]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})],-1)])],8,zg),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"},[...h[13]||(h[13]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])],8,Ag)])])]))),128)),m.overlays.length===0?(e.openBlock(),e.createElementBlock("div",Dg," 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",Ug,[e.createElementVNode("h4",Og,e.toDisplayString(r.value?"Edit":"Add")+" Text Overlay ",1),e.createElementVNode("div",Lg,[e.createElementVNode("div",null,[h[14]||(h[14]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Text ",-1)),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":h[1]||(h[1]=v=>s.text=v),rows:"3",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"Enter your text..."},null,512),[[e.vModelText,s.text]])]),e.createElementVNode("div",Wg,[e.createElementVNode("div",null,[h[15]||(h[15]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Font Size ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[2]||(h[2]=v=>s.fontSize=v),type:"number",min:"10",max:"200",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.fontSize,void 0,{number:!0}]])]),e.createElementVNode("div",null,[h[16]||(h[16]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Color ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[3]||(h[3]=v=>s.color=v),type:"color",class:"w-full h-10 border border-gray-300 dark:border-gray-600 rounded-lg cursor-pointer"},null,512),[[e.vModelText,s.color]])])]),e.createElementVNode("div",null,[h[18]||(h[18]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Position ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":h[4]||(h[4]=v=>s.position=v),class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},[...h[17]||(h[17]=[e.createStaticVNode('<option value="center" data-v-f86e688c>Center</option><option value="top" data-v-f86e688c>Top</option><option value="bottom" data-v-f86e688c>Bottom</option><option value="left" data-v-f86e688c>Left</option><option value="right" data-v-f86e688c>Right</option>',5)])],512),[[e.vModelSelect,s.position]])]),e.createElementVNode("div",jg,[e.createElementVNode("div",null,[h[19]||(h[19]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Start Time (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[5]||(h[5]=v=>s.startTime=v),type:"number",min:"0",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.startTime,void 0,{number:!0}]])]),e.createElementVNode("div",null,[h[20]||(h[20]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Duration (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[6]||(h[6]=v=>s.duration=v),type:"number",min:"0.1",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.duration,void 0,{number:!0}]])])]),e.createElementVNode("div",null,[h[22]||(h[22]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Animation ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":h[7]||(h[7]=v=>s.animationType=v),class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},[...h[21]||(h[21]=[e.createStaticVNode('<option value="" data-v-f86e688c>None</option><option value="fade-in" data-v-f86e688c>Fade In</option><option value="fade-out" data-v-f86e688c>Fade Out</option><option value="slide" data-v-f86e688c>Slide</option><option value="scale" data-v-f86e688c>Scale</option><option value="rotate" data-v-f86e688c>Rotate</option><option value="typewriter" data-v-f86e688c>Typewriter</option>',7)])],512),[[e.vModelSelect,s.animationType]])]),s.animationType?(e.openBlock(),e.createElementBlock("div",Xg,[h[26]||(h[26]=e.createElementVNode("div",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Animation Settings ",-1)),e.createElementVNode("div",Zg,[e.createElementVNode("div",null,[h[23]||(h[23]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Duration (s) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[8]||(h[8]=v=>s.animationDuration=v),type:"number",min:"0.1",step:"0.1",class:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},null,512),[[e.vModelText,s.animationDuration,void 0,{number:!0}]])]),e.createElementVNode("div",null,[h[25]||(h[25]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Easing ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":h[9]||(h[9]=v=>s.animationEasing=v),class:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},[...h[24]||(h[24]=[e.createElementVNode("option",{value:"linear"},"Linear",-1),e.createElementVNode("option",{value:"easeIn"},"Ease In",-1),e.createElementVNode("option",{value:"easeOut"},"Ease Out",-1),e.createElementVNode("option",{value:"easeInOut"},"Ease In Out",-1)])],512),[[e.vModelSelect,s.animationEasing]])])])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",Yg,[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)]))}}),Xs=_e(Gg,[["__scopeId","data-v-f86e688c"]]),ho=class ho{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=fe.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=fe.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=fe.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=fe.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=fe.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 Ir.fromColor(c),u=new Mh(d,{start:fe.fromFrames(r),stop:fe.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=fe.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[...ho.TRANSITIONS]}static previewTransition(o){return ho.TRANSITIONS.find(t=>t.type===o)}isVideoClip(o){return"alpha"in o&&"scale"in o&&"translate"in o}};ho.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 ya=ho;const Hg={class:"transition-selector p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},Jg={class:"grid grid-cols-3 gap-3 max-h-96 overflow-y-auto"},qg=["onClick"],Kg={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"},Qg={key:0,class:"w-8 h-8 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e1={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},t1={key:1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14 5l7 7m0 0l-7 7m7-7H3"},n1={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"},o1={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"},a1={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"},r1={class:"text-sm font-medium text-gray-900 dark:text-white text-center"},i1={key:0,class:"mt-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},s1={class:"space-y-3"},l1={class:"flex items-center space-x-2"},c1=["disabled"],d1=["disabled"],u1={key:1,class:"mt-4"},m1={class:"space-y-2 max-h-32 overflow-y-auto"},p1={class:"text-sm text-gray-700 dark:text-gray-300"},f1=["onClick"],h1=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(ya.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 h(v){return["fade","wipe","slide","zoom"].some(b=>v.includes(b))}return(v,b)=>(e.openBlock(),e.createElementBlock("div",Hg,[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",Jg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,x=>{var R;return e.openBlock(),e.createElementBlock("div",{key:x.type,onClick:S=>d(x),class:e.normalizeClass(["transition-item cursor-pointer rounded-lg p-3 border-2 transition-all",((R=i.value)==null?void 0:R.type)===x.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",Kg,[h(x.type)?(e.openBlock(),e.createElementBlock("svg",Qg,[x.type.includes("fade")?(e.openBlock(),e.createElementBlock("path",e1)):x.type.includes("wipe")?(e.openBlock(),e.createElementBlock("path",t1)):x.type.includes("slide")?(e.openBlock(),e.createElementBlock("path",n1)):x.type.includes("zoom")?(e.openBlock(),e.createElementBlock("path",o1)):(e.openBlock(),e.createElementBlock("path",a1))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",r1,e.toDisplayString(x.name),1)],10,qg)}),128))]),i.value?(e.openBlock(),e.createElementBlock("div",i1,[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",s1,[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",l1,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[0]||(b[0]=x=>s.value=x),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]=x=>s.value=x),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]=x=>l.value=x),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,c1),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,d1)])])):e.createCommentVNode("",!0),v.appliedTransitions.length>0?(e.openBlock(),e.createElementBlock("div",u1,[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",m1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.appliedTransitions,(x,R)=>(e.openBlock(),e.createElementBlock("div",{key:R,class:"flex items-center justify-between p-2 bg-gray-50 dark:bg-gray-700 rounded"},[e.createElementVNode("div",p1,e.toDisplayString(x.name)+" ("+e.toDisplayString(x.duration)+"s) ",1),e.createElementVNode("button",{onClick:S=>m(R),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,f1)]))),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))]))}}),Zs=_e(h1,[["__scopeId","data-v-5ef1b100"]]),v1={class:"audio-track-manager p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},g1={class:"mb-4"},y1={class:"mb-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},b1={class:"flex items-center justify-between mb-2"},w1={class:"text-sm text-gray-600 dark:text-gray-400"},k1={class:"flex items-center space-x-2"},x1={class:"space-y-3 max-h-64 overflow-y-auto"},E1={class:"flex items-center justify-between mb-2"},S1={class:"font-medium text-gray-900 dark:text-white"},V1={class:"flex items-center space-x-2"},C1=["onClick","title"],N1={key:0,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},_1={key:1,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},T1=["onClick"],M1=["onClick"],F1={class:"flex items-center space-x-2"},B1={class:"text-xs text-gray-500 dark:text-gray-400 w-10"},I1=["value","onInput","disabled"],R1={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},P1={key:0,class:"ml-2"},$1={key:1,class:"ml-2"},z1={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},A1={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},D1={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},U1={class:"space-y-4"},O1={class:"space-y-2"},L1={class:"flex items-center"},W1={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},j1={class:"grid grid-cols-2 gap-4"},X1={class:"grid grid-cols-2 gap-4"},Z1={class:"flex items-center"},Y1={class:"flex justify-end space-x-3 mt-6"},G1=["disabled"],H1=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(g){const f=g.target;f.files&&f.files[0]&&(c.sourceFile=f.files[0],c.name=c.name||f.files[0].name.replace(/\.[^/.]+$/,""))}function p(g){Object.assign(c,g),i.value=g}function m(){r.value=!1,i.value=null,Object.assign(c,l())}function h(){if(!d.value)return;const g={source:c.sourceFile??c.sourceUrl??"",name:c.name,volume:c.volume,startTime:c.startTime,loop:c.loop};c.duration!==void 0&&(g.duration=c.duration),c.fadeIn>0&&(g.fadeIn=c.fadeIn),c.fadeOut>0&&(g.fadeOut=c.fadeOut),i.value?a("update-track",i.value.id,g):a("add-track",g),m()}function v(g){confirm("Are you sure you want to remove this audio track?")&&a("remove-track",g)}function b(g,f){const w=f.target,$=parseFloat(w.value);a("update-volume",g.id,$)}function x(g){a("toggle-mute",g.id,!g.muted)}function R(){a("update-master-volume",s.value)}function S(g){const f=Math.floor(g/60),w=Math.floor(g%60);return`${f}:${w.toString().padStart(2,"0")}`}return(g,f)=>(e.openBlock(),e.createElementBlock("div",v1,[e.createElementVNode("div",g1,[f[11]||(f[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Audio Tracks ",-1)),e.createElementVNode("button",{onClick:f[0]||(f[0]=w=>r.value=!0),class:"w-full px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors"},[...f[10]||(f[10]=[e.createElementVNode("svg",{class:"w-5 h-5 inline-block mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),e.createTextVNode(" Add Audio Track ",-1)])])]),e.createElementVNode("div",y1,[e.createElementVNode("div",b1,[f[12]||(f[12]=e.createElementVNode("label",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"}," Master Volume ",-1)),e.createElementVNode("span",w1,e.toDisplayString(Math.round(s.value*100))+"% ",1)]),e.createElementVNode("div",k1,[f[13]||(f[13]=e.createElementVNode("svg",{class:"w-4 h-4 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20"},[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM12.293 7.293a1 1 0 011.414 0L15 8.586l1.293-1.293a1 1 0 111.414 1.414L16.414 10l1.293 1.293a1 1 0 01-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 01-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[1]||(f[1]=w=>s.value=w),onInput:R,type:"range",min:"0",max:"1",step:"0.01",class:"flex-1"},null,544),[[e.vModelText,s.value,void 0,{number:!0}]]),f[14]||(f[14]=e.createElementVNode("svg",{class:"w-4 h-4 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20"},[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM14.657 2.929a1 1 0 011.414 0l3 3a1 1 0 010 1.414l-3 3a1 1 0 01-1.414-1.414L16.586 7l-1.929-1.929a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1))])]),e.createElementVNode("div",x1,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.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",E1,[e.createElementVNode("div",S1,e.toDisplayString(w.name),1),e.createElementVNode("div",V1,[e.createElementVNode("button",{onClick:$=>x(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",_1,[...f[16]||(f[16]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM12.293 7.293a1 1 0 011.414 0L15 8.586l1.293-1.293a1 1 0 111.414 1.414L16.414 10l1.293 1.293a1 1 0 01-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 01-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",N1,[...f[15]||(f[15]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM14.657 2.929a1 1 0 011.414 0l3 3a1 1 0 010 1.414l-3 3a1 1 0 01-1.414-1.414L16.586 7l-1.929-1.929a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)])]))],10,C1),e.createElementVNode("button",{onClick:$=>p(w),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Settings"},[...f[17]||(f[17]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})],-1)])],8,T1),e.createElementVNode("button",{onClick:$=>v(w.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...f[18]||(f[18]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])],8,M1)])]),e.createElementVNode("div",F1,[e.createElementVNode("span",B1,e.toDisplayString(Math.round((w.volume||1)*100))+"% ",1),e.createElementVNode("input",{value:w.volume||1,onInput:$=>b(w,$),type:"range",min:"0",max:"1",step:"0.01",class:"flex-1",disabled:w.muted},null,40,I1)]),e.createElementVNode("div",R1,[e.createTextVNode(e.toDisplayString(S(w.startTime||0))+" - "+e.toDisplayString(S((w.startTime||0)+(w.duration||0)))+" ",1),w.fadeIn?(e.openBlock(),e.createElementBlock("span",P1,"Fade In: "+e.toDisplayString(w.fadeIn)+"s",1)):e.createCommentVNode("",!0),w.fadeOut?(e.openBlock(),e.createElementBlock("span",$1,"Fade Out: "+e.toDisplayString(w.fadeOut)+"s",1)):e.createCommentVNode("",!0)])]))),128)),g.audioLayers.length===0?(e.openBlock(),e.createElementBlock("div",z1," 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",A1,[e.createElementVNode("h4",D1,e.toDisplayString(i.value?"Edit":"Add")+" Audio Track ",1),e.createElementVNode("div",U1,[e.createElementVNode("div",null,[f[20]||(f[20]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Audio Source ",-1)),e.createElementVNode("div",O1,[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",L1,[f[19]||(f[19]=e.createElementVNode("span",{class:"text-sm text-gray-500 dark:text-gray-400 mr-2"},"or URL:",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[2]||(f[2]=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,[f[21]||(f[21]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Track Name ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[3]||(f[3]=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",W1," Volume: "+e.toDisplayString(Math.round(c.volume*100))+"% ",1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[4]||(f[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",j1,[e.createElementVNode("div",null,[f[22]||(f[22]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Start Time (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[5]||(f[5]=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,[f[23]||(f[23]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Duration (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[6]||(f[6]=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",X1,[e.createElementVNode("div",null,[f[24]||(f[24]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Fade In (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[7]||(f[7]=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,[f[25]||(f[25]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Fade Out (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[8]||(f[8]=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",Z1,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[9]||(f[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]]),f[26]||(f[26]=e.createElementVNode("label",{for:"loop-checkbox",class:"text-sm text-gray-700 dark:text-gray-300"}," Loop audio track ",-1))])]),e.createElementVNode("div",Y1,[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:h,disabled:!d.value,class:e.normalizeClass(["px-4 py-2 rounded-lg transition-colors",d.value?"bg-green-600 text-white hover:bg-green-700":"bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed"])},e.toDisplayString(i.value?"Save":"Add"),11,G1)])])])):e.createCommentVNode("",!0)]))}}),Ys=_e(H1,[["__scopeId","data-v-593719ac"]]);function Gs(n){var s,l;J1(n);const o=q1(n.clips),t=[],a=K1(n),r=Q1(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 J1(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 q1(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 K1(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 Q1(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 ey(n,o,t){var Re,Oe;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 dc(30),h=e.ref(30),v=e.ref(!1),b=e.ref(!1);o&&o.timeline&&o.timeline.length>0?($(o),(Re=o.output)!=null&&Re.fps&&(h.value=o.output.fps,m.setFps(h.value))):(g(),o&&((Oe=o.output)!=null&&Oe.fps&&(h.value=o.output.fps,m.setFps(h.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 x=e.computed(()=>r.selectedClipId?r.clips.find(G=>G.id===r.selectedClipId)??null:null),R=e.computed(()=>s.value.length>0),S=e.computed(()=>l.value.length>0);function g(){const G=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0?t.duration:1;t&&(r.media=t),r.originalDuration=G,r.totalDuration=G;const ue=j(),be={id:ue,type:"clip",timelineStart:0,timelineEnd:G,sourceIn:0,sourceOut:G,sourceMinIn:0,sourceMaxOut:G,speed:1};r.clips=[be],r.selectedClipId=ue,c.value=ue,!(t||a.startsWith("temp-"))&&(async()=>{try{const Me=await fetch(`/api/v1/video/${encodeURIComponent(a)}`);if(!Me.ok)throw new Error(`Failed to fetch media: ${Me.status}`);const Xe=await Me.json(),Bt=typeof Xe=="object"&&Xe!==null&&"data"in Xe?Xe.data:Xe;if(!Bt||typeof Bt!="object")throw new Error("Failed to parse media payload");const Ct=Bt;r.media=Ct;const Yt=typeof Ct.duration=="number"&&Ct.duration>0?Ct.duration:G;if(r.hasChanges||r.clips.length!==1||r.clips[0].id!==ue)return;r.originalDuration=Yt,r.totalDuration=Yt;const mt=r.clips[0];mt.timelineStart=0,mt.timelineEnd=Yt,mt.sourceIn=0,mt.sourceOut=Yt,mt.sourceMinIn=0,mt.sourceMaxOut=Yt,O(),d=!0}catch{}})()}function f(G,ue){if(G.originalDuration!==1)return;G.originalDuration=ue,G.totalDuration===1&&(G.totalDuration=ue);const be=G.clips[0],Me=!o&&G.clips.length===1&&be!==void 0&&be.timelineStart===0&&be.timelineEnd===1&&be.sourceIn===0&&be.sourceOut===1;for(const Xe of G.clips)(Xe.sourceMaxOut===1||Xe.sourceMaxOut===void 0)&&(Xe.sourceMaxOut=ue);Me&&be!==void 0&&(be.sourceOut=ue,be.timelineEnd=ue)}function w(G){if(!Number.isFinite(G)||G<=0||d)return;const ue=r.hasChanges;r.originalDuration=G,r.totalDuration=Math.max(r.totalDuration,G),r.media&&(r.media.duration=G);for(const Xe of r.clips)Xe.sourceMaxOut=G;const be=r.clips[0];!o&&r.clips.length===1&&be!==void 0&&be.timelineStart===0&&be.timelineEnd===1&&be.sourceIn===0&&be.sourceOut===1&&be!==void 0&&(be.sourceOut=G,be.timelineEnd=be.timelineStart+(be.sourceOut-be.sourceIn)),O();for(const Xe of s.value)f(Xe,G);for(const Xe of l.value)f(Xe,G);d=!0,e.nextTick(()=>{ue||(r.hasChanges=!1)})}function $(G){r.clips=G.timeline.map(ue=>({...ue,sourceMinIn:ue.sourceMinIn??0,sourceMaxOut:ue.sourceMaxOut??G.source.duration})),r.filters=[],r.audioVolume=G.audio.volume,r.audioFadeIn=G.audio.fadeIn||0,r.audioFadeOut=G.audio.fadeOut||0,r.exportFormat=G.output.format,r.exportQuality=G.output.quality,r.originalDuration=G.source.duration,r.clips.length>0?(r.selectedClipId=r.clips[0].id,c.value=r.selectedClipId):(delete r.selectedClipId,c.value=void 0),O()}function V(){s.value.push(JSON.parse(JSON.stringify(r))),l.value=[],r.hasChanges=!0}function y(){if(!R.value)return;const G=s.value.pop();l.value.push(JSON.parse(JSON.stringify(r))),Object.assign(r,G)}function C(){if(!S.value)return;const G=l.value.pop();s.value.push(JSON.parse(JSON.stringify(r))),Object.assign(r,G)}function D(G,ue,be){V();const Me=r.clips.find(mt=>mt.id===G);if(!Me)return;const Bt=1/30,Ct=Me.sourceMinIn??0,Yt=Me.sourceMaxOut??r.originalDuration;if(ue==="start"){const mt=Me.sourceIn,Vn=Math.max(Ct,Math.min(be,Me.sourceOut-Bt));Me.sourceIn=Vn;const Ha=Vn-mt;Me.timelineStart+=Ha}else{const mt=Math.max(Me.sourceIn+Bt,Math.min(be,Yt));Me.sourceOut=mt;const Vn=Me.sourceOut-Me.sourceIn;Me.timelineEnd=Me.timelineStart+Vn}O(),p.value&&p.value.trimClip(G,Me.sourceIn,Me.sourceOut)}function k(G){V();const ue=r.clips.find(Ct=>G>Ct.timelineStart&&G<Ct.timelineEnd);if(!ue)return;const be=G-ue.timelineStart,Me=ue.sourceIn+be,Xe={id:j(),type:"clip",timelineStart:G,timelineEnd:ue.timelineEnd,sourceIn:Me,sourceOut:ue.sourceOut,speed:ue.speed??1,sourceMinIn:ue.sourceMinIn??0,sourceMaxOut:ue.sourceMaxOut??r.originalDuration,filters:[...ue.filters||[]]};ue.timelineEnd=G,ue.sourceOut=Me;const Bt=r.clips.indexOf(ue);r.clips.splice(Bt+1,0,Xe),r.selectedClipId=Xe.id}function T(){k(r.playheadPosition)}function F(G){var be;const ue=G??r.selectedClipId??c.value??((be=r.clips[0])==null?void 0:be.id);ue&&(r.selectedClipId=ue,c.value=ue)}function A(){if(!r.selectedClipId||r.clips.length<=1)return;V();const G=r.clips.findIndex(ue=>ue.id===r.selectedClipId);if(G!==-1){r.clips.splice(G,1);const ue=Math.min(G,r.clips.length-1);r.selectedClipId=r.clips[ue].id,c.value=r.selectedClipId,O()}}function P(G,ue){V();const be=r.clips.find(Xe=>Xe.id===G);if(!be)return;const Me=ue-be.timelineStart;be.timelineStart=ue,be.timelineEnd+=Me,O(),p.value&&p.value.moveClip(G,ue)}function O(){if(r.clips.length===0){r.totalDuration=0;return}const G=r.clips.reduce((ue,be)=>be.timelineEnd>ue.timelineEnd?be:ue);r.totalDuration=G.timelineEnd}function B(){r.zoomLevel=Math.min(200,r.zoomLevel*1.2)}function _(){r.zoomLevel=Math.max(10,r.zoomLevel/1.2)}function X(G){r.zoomLevel=Math.max(10,Math.min(600,Math.round(G)))}function W(){r.isPlaying=!r.isPlaying}function ee(G){r.isPlaying=G}function he(G){r.playheadPosition=Math.max(0,Math.min(G,r.totalDuration))}function Ue(){const G=Gs(r);return localStorage.setItem(`video-draft-${a}`,JSON.stringify(G)),G}function Te(){r.hasChanges=!1}function re(){return confirm("Are you sure you want to reset all changes?")?(V(),g(),r.hasChanges=!1,!0):!1}function M(){return Gs(r)}function j(){return`clip-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}async function le(G=1920,ue=1080){if(u.value)try{p.value=new cc(G,ue,h.value),await ae()}catch{p.value=null}}async function ae(){if(!(!p.value||b.value)){b.value=!0;try{const G=M();await p.value.loadFromRecipe(G);const ue=m.secondsToFrames(r.playheadPosition);p.value.seek(ue)}catch{}finally{b.value=!1}}}function H(G){}function K(G){return m.secondsToFrames(G)}function ce(G){return m.framesToSeconds(G)}function ve(G){const ue=ce(G);he(ue),p.value&&p.value.seek(G)}function ke(){v.value=!v.value}function ne(){ae()}function we(G){u.value=!1,p.value=null}e.watch(()=>r.clips,()=>{r.hasChanges=!0,u.value&&p.value&&ae()},{deep:!0}),e.watch(()=>r.filters,()=>{r.hasChanges=!0,u.value&&p.value&&ae()},{deep:!0}),e.watch(()=>r.clips.map(G=>G.id),()=>{var ue;if(!r.clips.length){delete r.selectedClipId,c.value=void 0;return}if(!r.clips.some(be=>be.id===r.selectedClipId)){const be=c.value&&((ue=r.clips.find(Me=>Me.id===c.value))==null?void 0:ue.id);r.selectedClipId=be??r.clips[0].id,c.value=r.selectedClipId}},{deep:!0});function pe(G){const ue=r.selectedClipId?r.clips.find(be=>be.id===r.selectedClipId):r.clips[0];ue&&(ue.filters=[...G],r.hasChanges=!0)}function qe(G){r.textOverlays=[...G]}function rt(G){r.audioTracks=[...G]}e.watch(u,G=>{G?le():p.value&&(p.value.destroy(),p.value=null)}),e.watch(v,()=>{}),e.watch(h,G=>{m.setFps(G)});const de=e.ref(1);function ye(){if(!r.selectedClipId)return;V();const G=r.clips.find(Me=>Me.id===r.selectedClipId);if(!G)return;const ue={...G,id:j(),timelineStart:G.timelineEnd,timelineEnd:G.timelineEnd+(G.timelineEnd-G.timelineStart),filters:[...G.filters||[]]},be=r.clips.indexOf(G);r.clips.splice(be+1,0,ue),r.selectedClipId=ue.id,r.hasChanges=!0}function L(){r.zoomLevel=50}function oe(){const G=1/h.value;he(Math.min(r.playheadPosition+G,r.totalDuration))}function Q(){const G=1/h.value;he(Math.max(r.playheadPosition-G,0))}function te(){he(0)}function xe(){he(r.totalDuration)}function Ee(G){de.value=G}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:x,zoomLevel:e.computed(()=>r.zoomLevel),playbackSpeed:de,useVideoEngine:u,compositionAdapter:e.computed(()=>p.value),fps:h,useFrameMode:v,handleTrim:D,handleSplit:k,handleClipSelect:F,splitAtPlayhead:T,deleteSelectedClip:A,duplicateSelectedClip:ye,setFilters:pe,setTextOverlays:qe,setAudioTracks:rt,moveClip:P,saveDraft:Ue,clearHasChanges:Te,resetChanges:re,generateRecipe:M,zoomIn:B,zoomOut:_,setZoomLevel:X,fitToWindow:L,togglePlayback:W,setPlaying:ee,seekTo:he,frameForward:oe,frameBackward:Q,skipToStart:te,skipToEnd:xe,setPlaybackSpeed:Ee,updateSourceDuration:w,undo:y,redo:C,canUndo:R,canRedo:S,initializeComposition:le,syncCompositionWithState:ae,syncWithComposition:H,convertToFrames:K,convertToSeconds:ce,seekToFrame:ve,toggleFrameMode:ke,onCompositionReady:ne,onCompositionError:we}}const ty=[{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}}}],ny={dropShadow:"drop-shadow",softFocus:"blur",blackAndWhite:"grayscale",gaussianBlur:"blur","gaussian-blur":"blur"};function Aa(n){return typeof n=="object"&&n!==null}function oy(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 Da(n){if(typeof n=="number"||typeof n=="string"||typeof n=="boolean")return n}function ay(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=Da(n.default);return t!==void 0&&(o.default=t),n.options!==void 0&&(o.options=n.options),o}function uc(n,o,t){const a=xt.getFilter(n),r={},i=(a==null?void 0:a.defaultParams)??t;if(i&&Aa(i))for(const[s,l]of Object.entries(i))r[s]=Da(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 mc(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 ry(n,o,t,a){const r=a.map(ay);return{id:n,name:o,category:t,controls:r,params:r,defaultParams:uc(n,r),paramRanges:mc(r)}}function iy(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=Da((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:uc(n.id,t,n.defaultParams),paramRanges:mc(t)}}function sy(n,o){return o.toLowerCase()==="unlisted"?!1:xt.isFilterCompatibleWithMedia(n,"video")}function vr(n){return ny[n]??n}function io(n){const o=oy(n,1);return Math.max(0,Math.min(1,o))}function so(n){if(!Aa(n))return{};const o={};for(const[t,a]of Object.entries(n))o[t]=Da(a)??null;return o}function ly(n){return!Aa(n)||typeof n.filterId!="string"?null:{filterId:n.filterId,params:so(n.params),intensity:io(n.intensity)}}function cy(n){if(!Aa(n)||typeof n.id!="string"||typeof n.name!="string")return null;const t=(Array.isArray(n.filters)?n.filters:[]).map(r=>ly(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 dy(){xt.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 F=new Map,A=xt.getRegisteredFilters();for(const P of A)sy(P.id,P.category)&&F.set(P.id,ry(P.id,P.name,P.category,P.controls));for(const P of ty)F.has(P.id)||F.set(P.id,iy(P));return Array.from(F.values())}),l=e.computed(()=>{const F=new Map;for(const A of s.value)F.set(A.id,A);return F}),c=e.computed(()=>n.value.length>0),d=e.computed(()=>{const F={};for(const A of s.value)F[A.category]||(F[A.category]=[]),F[A.category].push(A);return F});function u(F){const A=l.value.get(F);if(A)return A;const P=vr(F);return l.value.get(P)??null}function p(F){const A=l.value.get(F);if(A)return A.id;const P=vr(F),O=l.value.get(P);return O?O.id:null}function m(F){const A=F?u(F):o.value;if(!A)return;const P=A.defaultParams||{},O={id:C(),filterId:A.id,params:{...P},intensity:1};return n.value.push(O),r.value=O.id,o.value=A,Object.keys(i).forEach(B=>delete i[B]),Object.assign(i,O.params),t.value=null,O}function h(F){const A=u(F);if(!A)return;o.value=A;const P=A.defaultParams||k(F);Object.assign(i,P),t.value={id:"preview",filterId:A.id,params:{...P},intensity:1}}function v(F){if(Object.assign(i,F),t.value&&(t.value.params={...i}),r.value){const A=n.value.find(P=>P.id===r.value);A&&(A.params={...i})}}function b(F){const A=n.value.findIndex(P=>P.id===F);A!==-1&&n.value.splice(A,1)}function x(F,A){if(F<0||F>=n.value.length||A<0||A>=n.value.length)return;const[P]=n.value.splice(F,1);n.value.splice(A,0,P)}function R(F,A){const P=n.value.find(O=>O.id===F);P&&(P.intensity=Math.max(0,Math.min(1,A)))}function S(F){const A=n.value.find(P=>P.id===F);A&&(A.intensity=A.intensity>0?0:1)}function g(){n.value=[],t.value=null,o.value=null,r.value=null,Object.keys(i).forEach(F=>delete i[F])}function f(F){const A={id:D(),name:F,filters:n.value.map(O=>({filterId:O.filterId,params:so(O.params),intensity:io(O.intensity)})),created_at:new Date().toISOString()};a.value.push(A);const P=a.value.map(O=>({...O}));return localStorage.setItem("video-filter-presets",JSON.stringify(P)),A}function w(F){const A=a.value.find(P=>P.id===F);if(A){g();for(const P of A.filters){const O=u(P.filterId);O&&n.value.push({id:C(),filterId:O.id,params:{...P.params},intensity:io(P.intensity)})}}}function $(F){const A=a.value.findIndex(P=>P.id===F);A!==-1&&(a.value.splice(A,1),localStorage.setItem("video-filter-presets",JSON.stringify(a.value)))}function V(){try{const F=localStorage.getItem("video-filter-presets");if(!F)return;const A=JSON.parse(F);if(!Array.isArray(A))return;a.value=A.map(P=>cy(P)).filter(P=>P!==null)}catch{}}function y(){if(n.value.length===0)return"No filters applied";const F=n.value.map(A=>{const P=T(A.filterId);return(P==null?void 0:P.name)||A.filterId});return F.length===1?F[0]:F.length===2?`${F[0]} + ${F[1]}`:`${F[0]} + ${F.length-1} more`}function C(){return`filter-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function D(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function k(F){const A=u(F);return A?A.defaultParams||{}:{}}function T(F){return u(F)}return V(),{videoCompatibleFilters:s,activeFilters:n,selectedFilter:o,previewFilter:t,filterPresets:a,filterParams:i,hasActiveFilters:c,filtersByCategory:d,applyFilter:m,previewFilterEffect:h,updateFilterParams:v,removeFilter:b,reorderFilters:x,updateFilterIntensity:R,toggleFilter:S,clearAllFilters:g,saveFilterPreset:f,loadFilterPreset:w,deleteFilterPreset:$,getFilterSummary:y,setActiveFilters(F){var P;const A=[];for(const O of F){const B=p(O.filterId);if(!B){const _=vr(O.filterId);A.push({...O,filterId:_,params:so(O.params),intensity:io(O.intensity)});continue}A.push({...O,filterId:B,params:so(O.params),intensity:io(O.intensity)})}n.value=A,r.value=((P=n.value[0])==null?void 0:P.id)??null,Object.keys(i).forEach(O=>delete i[O]),n.value[0]&&Object.assign(i,so(n.value[0].params))}}}class uy{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 lt({source:"https://fonts.googleapis.com/css2?family=Inter:wght@400",family:"Inter",weight:"400"})),this.fonts.set("bold",new lt({source:"https://fonts.googleapis.com/css2?family=Inter:wght@700",family:"Inter",weight:"700"})),this.fonts.set("serif",new lt({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 lt({source:t,family:a,weight:r});this.fonts.set(o,i)}loadLocalFont(o,t,a="400"){const r=new lt({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=fe.fromSeconds(o.startTime)),o.duration!==void 0){const l=o.startTime||0;a.stop=fe.fromSeconds(l+o.duration)}o.animation&&this.applyAnimation(a,o.animation,o);const s=new Ln(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:No,cascade:Ia,guinea:Ba,solar:Ra,spotlight:_o,whisper:To}[t],s=await this.composition.createTrack("caption"),l=new Ca({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 my{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 rn.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 rn)a=o.source;else if(typeof o.source=="string")a=await rn.from(o.source);else if(typeof o.source=="object"&&o.source instanceof File)a=await rn.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=fe.fromSeconds(o.startTime)),o.duration!==void 0){const c=o.startTime||0;r.stop=fe.fromSeconds(c+o.duration)}(o.fadeIn||o.fadeOut)&&(r.volume=this.createVolumeKeyframes(o));const i=new ga(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 ga({source:a.clip.source,start:fe.fromSeconds(r),stop:fe.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 pc(n,o){return function(){return n.apply(o,arguments)}}const{toString:py}=Object.prototype,{getPrototypeOf:di}=Object,{iterator:Ua,toStringTag:fc}=Symbol,Oa=(n=>o=>{const t=py.call(o);return n[t]||(n[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Ft=n=>(n=n.toLowerCase(),o=>Oa(o)===n),La=n=>o=>typeof o===n,{isArray:Xn}=Array,wo=La("undefined");function Mo(n){return n!==null&&!wo(n)&&n.constructor!==null&&!wo(n.constructor)&&ft(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const hc=Ft("ArrayBuffer");function fy(n){let o;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?o=ArrayBuffer.isView(n):o=n&&n.buffer&&hc(n.buffer),o}const hy=La("string"),ft=La("function"),vc=La("number"),Fo=n=>n!==null&&typeof n=="object",vy=n=>n===!0||n===!1,ra=n=>{if(Oa(n)!=="object")return!1;const o=di(n);return(o===null||o===Object.prototype||Object.getPrototypeOf(o)===null)&&!(fc in n)&&!(Ua in n)},gy=n=>{if(!Fo(n)||Mo(n))return!1;try{return Object.keys(n).length===0&&Object.getPrototypeOf(n)===Object.prototype}catch{return!1}},yy=Ft("Date"),by=Ft("File"),wy=Ft("Blob"),ky=Ft("FileList"),xy=n=>Fo(n)&&ft(n.pipe),Ey=n=>{let o;return n&&(typeof FormData=="function"&&n instanceof FormData||ft(n.append)&&((o=Oa(n))==="formdata"||o==="object"&&ft(n.toString)&&n.toString()==="[object FormData]"))},Sy=Ft("URLSearchParams"),[Vy,Cy,Ny,_y]=["ReadableStream","Request","Response","Headers"].map(Ft),Ty=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Bo(n,o,{allOwnKeys:t=!1}={}){if(n===null||typeof n>"u")return;let a,r;if(typeof n!="object"&&(n=[n]),Xn(n))for(a=0,r=n.length;a<r;a++)o.call(null,n[a],a,n);else{if(Mo(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 gc(n,o){if(Mo(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 gn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,yc=n=>!wo(n)&&n!==gn;function Ar(){const{caseless:n}=yc(this)&&this||{},o={},t=(a,r)=>{const i=n&&gc(o,r)||r;ra(o[i])&&ra(a)?o[i]=Ar(o[i],a):ra(a)?o[i]=Ar({},a):Xn(a)?o[i]=a.slice():o[i]=a};for(let a=0,r=arguments.length;a<r;a++)arguments[a]&&Bo(arguments[a],t);return o}const My=(n,o,t,{allOwnKeys:a}={})=>(Bo(o,(r,i)=>{t&&ft(r)?n[i]=pc(r,t):n[i]=r},{allOwnKeys:a}),n),Fy=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),By=(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)},Iy=(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&&di(n)}while(n&&(!t||t(n,o))&&n!==Object.prototype);return o},Ry=(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},Py=n=>{if(!n)return null;if(Xn(n))return n;let o=n.length;if(!vc(o))return null;const t=new Array(o);for(;o-- >0;)t[o]=n[o];return t},$y=(n=>o=>n&&o instanceof n)(typeof Uint8Array<"u"&&di(Uint8Array)),zy=(n,o)=>{const a=(n&&n[Ua]).call(n);let r;for(;(r=a.next())&&!r.done;){const i=r.value;o.call(n,i[0],i[1])}},Ay=(n,o)=>{let t;const a=[];for(;(t=n.exec(o))!==null;)a.push(t);return a},Dy=Ft("HTMLFormElement"),Uy=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,a,r){return a.toUpperCase()+r}),Hs=(({hasOwnProperty:n})=>(o,t)=>n.call(o,t))(Object.prototype),Oy=Ft("RegExp"),bc=(n,o)=>{const t=Object.getOwnPropertyDescriptors(n),a={};Bo(t,(r,i)=>{let s;(s=o(r,i,n))!==!1&&(a[i]=s||r)}),Object.defineProperties(n,a)},Ly=n=>{bc(n,(o,t)=>{if(ft(n)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const a=n[t];if(ft(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+"'")})}})},Wy=(n,o)=>{const t={},a=r=>{r.forEach(i=>{t[i]=!0})};return Xn(n)?a(n):a(String(n).split(o)),t},jy=()=>{},Xy=(n,o)=>n!=null&&Number.isFinite(n=+n)?n:o;function Zy(n){return!!(n&&ft(n.append)&&n[fc]==="FormData"&&n[Ua])}const Yy=n=>{const o=new Array(10),t=(a,r)=>{if(Fo(a)){if(o.indexOf(a)>=0)return;if(Mo(a))return a;if(!("toJSON"in a)){o[r]=a;const i=Xn(a)?[]:{};return Bo(a,(s,l)=>{const c=t(s,r+1);!wo(c)&&(i[l]=c)}),o[r]=void 0,i}}return a};return t(n,0)},Gy=Ft("AsyncFunction"),Hy=n=>n&&(Fo(n)||ft(n))&&ft(n.then)&&ft(n.catch),wc=((n,o)=>n?setImmediate:o?((t,a)=>(gn.addEventListener("message",({source:r,data:i})=>{r===gn&&i===t&&a.length&&a.shift()()},!1),r=>{a.push(r),gn.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",ft(gn.postMessage)),Jy=typeof queueMicrotask<"u"?queueMicrotask.bind(gn):typeof process<"u"&&process.nextTick||wc,qy=n=>n!=null&&ft(n[Ua]),Y={isArray:Xn,isArrayBuffer:hc,isBuffer:Mo,isFormData:Ey,isArrayBufferView:fy,isString:hy,isNumber:vc,isBoolean:vy,isObject:Fo,isPlainObject:ra,isEmptyObject:gy,isReadableStream:Vy,isRequest:Cy,isResponse:Ny,isHeaders:_y,isUndefined:wo,isDate:yy,isFile:by,isBlob:wy,isRegExp:Oy,isFunction:ft,isStream:xy,isURLSearchParams:Sy,isTypedArray:$y,isFileList:ky,forEach:Bo,merge:Ar,extend:My,trim:Ty,stripBOM:Fy,inherits:By,toFlatObject:Iy,kindOf:Oa,kindOfTest:Ft,endsWith:Ry,toArray:Py,forEachEntry:zy,matchAll:Ay,isHTMLForm:Dy,hasOwnProperty:Hs,hasOwnProp:Hs,reduceDescriptors:bc,freezeMethods:Ly,toObjectSet:Wy,toCamelCase:Uy,noop:jy,toFiniteNumber:Xy,findKey:gc,global:gn,isContextDefined:yc,isSpecCompliantForm:Zy,toJSONObject:Yy,isAsyncFn:Gy,isThenable:Hy,setImmediate:wc,asap:Jy,isIterable:qy};function Fe(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)}Y.inherits(Fe,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:Y.toJSONObject(this.config),code:this.code,status:this.status}}});const kc=Fe.prototype,xc={};["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=>{xc[n]={value:n}});Object.defineProperties(Fe,xc);Object.defineProperty(kc,"isAxiosError",{value:!0});Fe.from=(n,o,t,a,r,i)=>{const s=Object.create(kc);return Y.toFlatObject(n,s,function(c){return c!==Error.prototype},l=>l!=="isAxiosError"),Fe.call(s,n.message,o,t,a,r),s.cause=n,s.name=n.name,i&&Object.assign(s,i),s};const Ky=null;function Dr(n){return Y.isPlainObject(n)||Y.isArray(n)}function Ec(n){return Y.endsWith(n,"[]")?n.slice(0,-2):n}function Js(n,o,t){return n?n.concat(o).map(function(r,i){return r=Ec(r),!t&&i?"["+r+"]":r}).join(t?".":""):o}function Qy(n){return Y.isArray(n)&&!n.some(Dr)}const eb=Y.toFlatObject(Y,{},null,function(o){return/^is[A-Z]/.test(o)});function Wa(n,o,t){if(!Y.isObject(n))throw new TypeError("target must be an object");o=o||new FormData,t=Y.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(b,x){return!Y.isUndefined(x[b])});const a=t.metaTokens,r=t.visitor||u,i=t.dots,s=t.indexes,c=(t.Blob||typeof Blob<"u"&&Blob)&&Y.isSpecCompliantForm(o);if(!Y.isFunction(r))throw new TypeError("visitor must be a function");function d(v){if(v===null)return"";if(Y.isDate(v))return v.toISOString();if(Y.isBoolean(v))return v.toString();if(!c&&Y.isBlob(v))throw new Fe("Blob is not supported. Use a Buffer instead.");return Y.isArrayBuffer(v)||Y.isTypedArray(v)?c&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function u(v,b,x){let R=v;if(v&&!x&&typeof v=="object"){if(Y.endsWith(b,"{}"))b=a?b:b.slice(0,-2),v=JSON.stringify(v);else if(Y.isArray(v)&&Qy(v)||(Y.isFileList(v)||Y.endsWith(b,"[]"))&&(R=Y.toArray(v)))return b=Ec(b),R.forEach(function(g,f){!(Y.isUndefined(g)||g===null)&&o.append(s===!0?Js([b],f,i):s===null?b:b+"[]",d(g))}),!1}return Dr(v)?!0:(o.append(Js(x,b,i),d(v)),!1)}const p=[],m=Object.assign(eb,{defaultVisitor:u,convertValue:d,isVisitable:Dr});function h(v,b){if(!Y.isUndefined(v)){if(p.indexOf(v)!==-1)throw Error("Circular reference detected in "+b.join("."));p.push(v),Y.forEach(v,function(R,S){(!(Y.isUndefined(R)||R===null)&&r.call(o,R,Y.isString(S)?S.trim():S,b,m))===!0&&h(R,b?b.concat(S):[S])}),p.pop()}}if(!Y.isObject(n))throw new TypeError("data must be an object");return h(n),o}function qs(n){const o={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(a){return o[a]})}function ui(n,o){this._pairs=[],n&&Wa(n,this,o)}const Sc=ui.prototype;Sc.append=function(o,t){this._pairs.push([o,t])};Sc.toString=function(o){const t=o?function(a){return o.call(this,a,qs)}:qs;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function tb(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Vc(n,o,t){if(!o)return n;const a=t&&t.encode||tb;Y.isFunction(t)&&(t={serialize:t});const r=t&&t.serialize;let i;if(r?i=r(o,t):i=Y.isURLSearchParams(o)?o.toString():new ui(o,t).toString(a),i){const s=n.indexOf("#");s!==-1&&(n=n.slice(0,s)),n+=(n.indexOf("?")===-1?"?":"&")+i}return n}class Ks{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){Y.forEach(this.handlers,function(a){a!==null&&o(a)})}}const Cc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},nb=typeof URLSearchParams<"u"?URLSearchParams:ui,ob=typeof FormData<"u"?FormData:null,ab=typeof Blob<"u"?Blob:null,rb={isBrowser:!0,classes:{URLSearchParams:nb,FormData:ob,Blob:ab},protocols:["http","https","file","blob","url","data"]},mi=typeof window<"u"&&typeof document<"u",Ur=typeof navigator=="object"&&navigator||void 0,ib=mi&&(!Ur||["ReactNative","NativeScript","NS"].indexOf(Ur.product)<0),sb=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",lb=mi&&window.location.href||"http://localhost",cb=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:mi,hasStandardBrowserEnv:ib,hasStandardBrowserWebWorkerEnv:sb,navigator:Ur,origin:lb},Symbol.toStringTag,{value:"Module"})),ct={...cb,...rb};function db(n,o){return Wa(n,new ct.classes.URLSearchParams,{visitor:function(t,a,r,i){return ct.isNode&&Y.isBuffer(t)?(this.append(a,t.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...o})}function ub(n){return Y.matchAll(/\w+|\[(\w*)]/g,n).map(o=>o[0]==="[]"?"":o[1]||o[0])}function mb(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 Nc(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&&Y.isArray(r)?r.length:s,c?(Y.hasOwnProp(r,s)?r[s]=[r[s],a]:r[s]=a,!l):((!r[s]||!Y.isObject(r[s]))&&(r[s]=[]),o(t,a,r[s],i)&&Y.isArray(r[s])&&(r[s]=mb(r[s])),!l)}if(Y.isFormData(n)&&Y.isFunction(n.entries)){const t={};return Y.forEachEntry(n,(a,r)=>{o(ub(a),r,t,0)}),t}return null}function pb(n,o,t){if(Y.isString(n))try{return(o||JSON.parse)(n),Y.trim(n)}catch(a){if(a.name!=="SyntaxError")throw a}return(t||JSON.stringify)(n)}const Io={transitional:Cc,adapter:["xhr","http","fetch"],transformRequest:[function(o,t){const a=t.getContentType()||"",r=a.indexOf("application/json")>-1,i=Y.isObject(o);if(i&&Y.isHTMLForm(o)&&(o=new FormData(o)),Y.isFormData(o))return r?JSON.stringify(Nc(o)):o;if(Y.isArrayBuffer(o)||Y.isBuffer(o)||Y.isStream(o)||Y.isFile(o)||Y.isBlob(o)||Y.isReadableStream(o))return o;if(Y.isArrayBufferView(o))return o.buffer;if(Y.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 db(o,this.formSerializer).toString();if((l=Y.isFileList(o))||a.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Wa(l?{"files[]":o}:o,c&&new c,this.formSerializer)}}return i||r?(t.setContentType("application/json",!1),pb(o)):o}],transformResponse:[function(o){const t=this.transitional||Io.transitional,a=t&&t.forcedJSONParsing,r=this.responseType==="json";if(Y.isResponse(o)||Y.isReadableStream(o))return o;if(o&&Y.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"?Fe.from(l,Fe.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:ct.classes.FormData,Blob:ct.classes.Blob},validateStatus:function(o){return o>=200&&o<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Y.forEach(["delete","get","head","post","put","patch"],n=>{Io.headers[n]={}});const fb=Y.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"]),hb=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]&&fb[t])&&(t==="set-cookie"?o[t]?o[t].push(a):o[t]=[a]:o[t]=o[t]?o[t]+", "+a:a)}),o},Qs=Symbol("internals");function Qn(n){return n&&String(n).trim().toLowerCase()}function ia(n){return n===!1||n==null?n:Y.isArray(n)?n.map(ia):String(n)}function vb(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 gb=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function gr(n,o,t,a,r){if(Y.isFunction(a))return a.call(this,o,t);if(r&&(o=t),!!Y.isString(o)){if(Y.isString(a))return o.indexOf(a)!==-1;if(Y.isRegExp(a))return a.test(o)}}function yb(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(o,t,a)=>t.toUpperCase()+a)}function bb(n,o){const t=Y.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 ht=class{constructor(o){o&&this.set(o)}set(o,t,a){const r=this;function i(l,c,d){const u=Qn(c);if(!u)throw new Error("header name must be a non-empty string");const p=Y.findKey(r,u);(!p||r[p]===void 0||d===!0||d===void 0&&r[p]!==!1)&&(r[p||c]=ia(l))}const s=(l,c)=>Y.forEach(l,(d,u)=>i(d,u,c));if(Y.isPlainObject(o)||o instanceof this.constructor)s(o,t);else if(Y.isString(o)&&(o=o.trim())&&!gb(o))s(hb(o),t);else if(Y.isObject(o)&&Y.isIterable(o)){let l={},c,d;for(const u of o){if(!Y.isArray(u))throw TypeError("Object iterator must return a key-value pair");l[d=u[0]]=(c=l[d])?Y.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=Qn(o),o){const a=Y.findKey(this,o);if(a){const r=this[a];if(!t)return r;if(t===!0)return vb(r);if(Y.isFunction(t))return t.call(this,r,a);if(Y.isRegExp(t))return t.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(o,t){if(o=Qn(o),o){const a=Y.findKey(this,o);return!!(a&&this[a]!==void 0&&(!t||gr(this,this[a],a,t)))}return!1}delete(o,t){const a=this;let r=!1;function i(s){if(s=Qn(s),s){const l=Y.findKey(a,s);l&&(!t||gr(a,a[l],l,t))&&(delete a[l],r=!0)}}return Y.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||gr(this,this[i],i,o,!0))&&(delete this[i],r=!0)}return r}normalize(o){const t=this,a={};return Y.forEach(this,(r,i)=>{const s=Y.findKey(a,i);if(s){t[s]=ia(r),delete t[i];return}const l=o?yb(i):String(i).trim();l!==i&&delete t[i],t[l]=ia(r),a[l]=!0}),this}concat(...o){return this.constructor.concat(this,...o)}toJSON(o){const t=Object.create(null);return Y.forEach(this,(a,r)=>{a!=null&&a!==!1&&(t[r]=o&&Y.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[Qs]=this[Qs]={accessors:{}}).accessors,r=this.prototype;function i(s){const l=Qn(s);a[l]||(bb(r,s),a[l]=!0)}return Y.isArray(o)?o.forEach(i):i(o),this}};ht.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Y.reduceDescriptors(ht.prototype,({value:n},o)=>{let t=o[0].toUpperCase()+o.slice(1);return{get:()=>n,set(a){this[t]=a}}});Y.freezeMethods(ht);function yr(n,o){const t=this||Io,a=o||t,r=ht.from(a.headers);let i=a.data;return Y.forEach(n,function(l){i=l.call(t,i,r.normalize(),o?o.status:void 0)}),r.normalize(),i}function _c(n){return!!(n&&n.__CANCEL__)}function Zn(n,o,t){Fe.call(this,n??"canceled",Fe.ERR_CANCELED,o,t),this.name="CanceledError"}Y.inherits(Zn,Fe,{__CANCEL__:!0});function Tc(n,o,t){const a=t.config.validateStatus;!t.status||!a||a(t.status)?n(t):o(new Fe("Request failed with status code "+t.status,[Fe.ERR_BAD_REQUEST,Fe.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function wb(n){const o=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return o&&o[1]||""}function kb(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 h=u&&d-u;return h?Math.round(m*1e3/h):void 0}}function xb(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 ba=(n,o,t=3)=>{let a=0;const r=kb(50,250);return xb(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)},el=(n,o)=>{const t=n!=null;return[a=>o[0]({lengthComputable:t,total:n,loaded:a}),o[1]]},tl=n=>(...o)=>Y.asap(()=>n(...o)),Eb=ct.hasStandardBrowserEnv?((n,o)=>t=>(t=new URL(t,ct.origin),n.protocol===t.protocol&&n.host===t.host&&(o||n.port===t.port)))(new URL(ct.origin),ct.navigator&&/(msie|trident)/i.test(ct.navigator.userAgent)):()=>!0,Sb=ct.hasStandardBrowserEnv?{write(n,o,t,a,r,i){const s=[n+"="+encodeURIComponent(o)];Y.isNumber(t)&&s.push("expires="+new Date(t).toGMTString()),Y.isString(a)&&s.push("path="+a),Y.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 Vb(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function Cb(n,o){return o?n.replace(/\/?\/$/,"")+"/"+o.replace(/^\/+/,""):n}function Mc(n,o,t){let a=!Vb(o);return n&&(a||t==!1)?Cb(n,o):o}const nl=n=>n instanceof ht?{...n}:n;function kn(n,o){o=o||{};const t={};function a(d,u,p,m){return Y.isPlainObject(d)&&Y.isPlainObject(u)?Y.merge.call({caseless:m},d,u):Y.isPlainObject(u)?Y.merge({},u):Y.isArray(u)?u.slice():u}function r(d,u,p,m){if(Y.isUndefined(u)){if(!Y.isUndefined(d))return a(void 0,d,p,m)}else return a(d,u,p,m)}function i(d,u){if(!Y.isUndefined(u))return a(void 0,u)}function s(d,u){if(Y.isUndefined(u)){if(!Y.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(nl(d),nl(u),p,!0)};return Y.forEach(Object.keys({...n,...o}),function(u){const p=c[u]||r,m=p(n[u],o[u],u);Y.isUndefined(m)&&p!==l||(t[u]=m)}),t}const Fc=n=>{const o=kn({},n);let{data:t,withXSRFToken:a,xsrfHeaderName:r,xsrfCookieName:i,headers:s,auth:l}=o;o.headers=s=ht.from(s),o.url=Vc(Mc(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(Y.isFormData(t)){if(ct.hasStandardBrowserEnv||ct.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(ct.hasStandardBrowserEnv&&(a&&Y.isFunction(a)&&(a=a(o)),a||a!==!1&&Eb(o.url))){const d=r&&i&&Sb.read(i);d&&s.set(r,d)}return o},Nb=typeof XMLHttpRequest<"u",_b=Nb&&function(n){return new Promise(function(t,a){const r=Fc(n);let i=r.data;const s=ht.from(r.headers).normalize();let{responseType:l,onUploadProgress:c,onDownloadProgress:d}=r,u,p,m,h,v;function b(){h&&h(),v&&v(),r.cancelToken&&r.cancelToken.unsubscribe(u),r.signal&&r.signal.removeEventListener("abort",u)}let x=new XMLHttpRequest;x.open(r.method.toUpperCase(),r.url,!0),x.timeout=r.timeout;function R(){if(!x)return;const g=ht.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),w={data:!l||l==="text"||l==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:g,config:n,request:x};Tc(function(V){t(V),b()},function(V){a(V),b()},w),x=null}"onloadend"in x?x.onloadend=R:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(R)},x.onabort=function(){x&&(a(new Fe("Request aborted",Fe.ECONNABORTED,n,x)),x=null)},x.onerror=function(){a(new Fe("Network Error",Fe.ERR_NETWORK,n,x)),x=null},x.ontimeout=function(){let f=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const w=r.transitional||Cc;r.timeoutErrorMessage&&(f=r.timeoutErrorMessage),a(new Fe(f,w.clarifyTimeoutError?Fe.ETIMEDOUT:Fe.ECONNABORTED,n,x)),x=null},i===void 0&&s.setContentType(null),"setRequestHeader"in x&&Y.forEach(s.toJSON(),function(f,w){x.setRequestHeader(w,f)}),Y.isUndefined(r.withCredentials)||(x.withCredentials=!!r.withCredentials),l&&l!=="json"&&(x.responseType=r.responseType),d&&([m,v]=ba(d,!0),x.addEventListener("progress",m)),c&&x.upload&&([p,h]=ba(c),x.upload.addEventListener("progress",p),x.upload.addEventListener("loadend",h)),(r.cancelToken||r.signal)&&(u=g=>{x&&(a(!g||g.type?new Zn(null,n,x):g),x.abort(),x=null)},r.cancelToken&&r.cancelToken.subscribe(u),r.signal&&(r.signal.aborted?u():r.signal.addEventListener("abort",u)));const S=wb(r.url);if(S&&ct.protocols.indexOf(S)===-1){a(new Fe("Unsupported protocol "+S+":",Fe.ERR_BAD_REQUEST,n));return}x.send(i||null)})},Tb=(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 Fe?u:new Zn(u instanceof Error?u.message:u))}};let s=o&&setTimeout(()=>{s=null,i(new Fe(`timeout ${o} of ms exceeded`,Fe.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=()=>Y.asap(l),c}},Mb=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},Fb=async function*(n,o){for await(const t of Bb(n))yield*Mb(t,o)},Bb=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()}},ol=(n,o,t,a)=>{const r=Fb(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})},ja=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Bc=ja&&typeof ReadableStream=="function",Ib=ja&&(typeof TextEncoder=="function"?(n=>o=>n.encode(o))(new TextEncoder):async n=>new Uint8Array(await new Response(n).arrayBuffer())),Ic=(n,...o)=>{try{return!!n(...o)}catch{return!1}},Rb=Bc&&Ic(()=>{let n=!1;const o=new Request(ct.origin,{body:new ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type");return n&&!o}),al=64*1024,Or=Bc&&Ic(()=>Y.isReadableStream(new Response("").body)),wa={stream:Or&&(n=>n.body)};ja&&(n=>{["text","arrayBuffer","blob","formData","stream"].forEach(o=>{!wa[o]&&(wa[o]=Y.isFunction(n[o])?t=>t[o]():(t,a)=>{throw new Fe(`Response type '${o}' is not supported`,Fe.ERR_NOT_SUPPORT,a)})})})(new Response);const Pb=async n=>{if(n==null)return 0;if(Y.isBlob(n))return n.size;if(Y.isSpecCompliantForm(n))return(await new Request(ct.origin,{method:"POST",body:n}).arrayBuffer()).byteLength;if(Y.isArrayBufferView(n)||Y.isArrayBuffer(n))return n.byteLength;if(Y.isURLSearchParams(n)&&(n=n+""),Y.isString(n))return(await Ib(n)).byteLength},$b=async(n,o)=>{const t=Y.toFiniteNumber(n.getContentLength());return t??Pb(o)},zb=ja&&(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}=Fc(n);d=d?(d+"").toLowerCase():"text";let h=Tb([r,i&&i.toAbortSignal()],s),v;const b=h&&h.unsubscribe&&(()=>{h.unsubscribe()});let x;try{if(c&&Rb&&t!=="get"&&t!=="head"&&(x=await $b(u,a))!==0){let w=new Request(o,{method:"POST",body:a,duplex:"half"}),$;if(Y.isFormData(a)&&($=w.headers.get("content-type"))&&u.setContentType($),w.body){const[V,y]=el(x,ba(tl(c)));a=ol(w.body,al,V,y)}}Y.isString(p)||(p=p?"include":"omit");const R="credentials"in Request.prototype;v=new Request(o,{...m,signal:h,method:t.toUpperCase(),headers:u.normalize().toJSON(),body:a,duplex:"half",credentials:R?p:void 0});let S=await fetch(v,m);const g=Or&&(d==="stream"||d==="response");if(Or&&(l||g&&b)){const w={};["status","statusText","headers"].forEach(C=>{w[C]=S[C]});const $=Y.toFiniteNumber(S.headers.get("content-length")),[V,y]=l&&el($,ba(tl(l),!0))||[];S=new Response(ol(S.body,al,V,()=>{y&&y(),b&&b()}),w)}d=d||"text";let f=await wa[Y.findKey(wa,d)||"text"](S,n);return!g&&b&&b(),await new Promise((w,$)=>{Tc(w,$,{data:f,headers:ht.from(S.headers),status:S.status,statusText:S.statusText,config:n,request:v})})}catch(R){throw b&&b(),R&&R.name==="TypeError"&&/Load failed|fetch/i.test(R.message)?Object.assign(new Fe("Network Error",Fe.ERR_NETWORK,n,v),{cause:R.cause||R}):Fe.from(R,R&&R.code,n,v)}}),Lr={http:Ky,xhr:_b,fetch:zb};Y.forEach(Lr,(n,o)=>{if(n){try{Object.defineProperty(n,"name",{value:o})}catch{}Object.defineProperty(n,"adapterName",{value:o})}});const rl=n=>`- ${n}`,Ab=n=>Y.isFunction(n)||n===null||n===!1,Rc={getAdapter:n=>{n=Y.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,!Ab(t)&&(a=Lr[(s=String(t)).toLowerCase()],a===void 0))throw new Fe(`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(rl).join(`
|
|
37
|
-
`):" "+rl(i[0]):"as no adapter specified";throw new Fe("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return a},adapters:Lr};function br(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new Zn(null,n)}function il(n){return br(n),n.headers=ht.from(n.headers),n.data=yr.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),Rc.getAdapter(n.adapter||Io.adapter)(n).then(function(a){return br(n),a.data=yr.call(n,n.transformResponse,a),a.headers=ht.from(a.headers),a},function(a){return _c(a)||(br(n),a&&a.response&&(a.response.data=yr.call(n,n.transformResponse,a.response),a.response.headers=ht.from(a.response.headers))),Promise.reject(a)})}const Pc="1.11.0",Xa={};["object","boolean","number","function","string","symbol"].forEach((n,o)=>{Xa[n]=function(a){return typeof a===n||"a"+(o<1?"n ":" ")+n}});const sl={};Xa.transitional=function(o,t,a){function r(i,s){return"[Axios v"+Pc+"] Transitional option '"+i+"'"+s+(a?". "+a:"")}return(i,s,l)=>{if(o===!1)throw new Fe(r(s," has been removed"+(t?" in "+t:"")),Fe.ERR_DEPRECATED);return t&&!sl[s]&&(sl[s]=!0),o?o(i,s,l):!0}};Xa.spelling=function(o){return(t,a)=>!0};function Db(n,o,t){if(typeof n!="object")throw new Fe("options must be an object",Fe.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 Fe("option "+i+" must be "+c,Fe.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new Fe("Unknown option "+i,Fe.ERR_BAD_OPTION)}}const sa={assertOptions:Db,validators:Xa},At=sa.validators;let bn=class{constructor(o){this.defaults=o||{},this.interceptors={request:new Ks,response:new Ks}}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=kn(this.defaults,t);const{transitional:a,paramsSerializer:r,headers:i}=t;a!==void 0&&sa.assertOptions(a,{silentJSONParsing:At.transitional(At.boolean),forcedJSONParsing:At.transitional(At.boolean),clarifyTimeoutError:At.transitional(At.boolean)},!1),r!=null&&(Y.isFunction(r)?t.paramsSerializer={serialize:r}:sa.assertOptions(r,{encode:At.function,serialize:At.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),sa.assertOptions(t,{baseUrl:At.spelling("baseURL"),withXsrfToken:At.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=i&&Y.merge(i.common,i[t.method]);i&&Y.forEach(["delete","get","head","post","put","patch","common"],v=>{delete i[v]}),t.headers=ht.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=[il.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 h=t;for(p=0;p<m;){const v=l[p++],b=l[p++];try{h=v(h)}catch(x){b.call(this,x);break}}try{u=il.call(this,h)}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=kn(this.defaults,o);const t=Mc(o.baseURL,o.url,o.allowAbsoluteUrls);return Vc(t,o.params,o.paramsSerializer)}};Y.forEach(["delete","get","head","options"],function(o){bn.prototype[o]=function(t,a){return this.request(kn(a||{},{method:o,url:t,data:(a||{}).data}))}});Y.forEach(["post","put","patch"],function(o){function t(a){return function(i,s,l){return this.request(kn(l||{},{method:o,headers:a?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}bn.prototype[o]=t(),bn.prototype[o+"Form"]=t(!0)});let Ub=class $c{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 Zn(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 $c(function(r){o=r}),cancel:o}}};function Ob(n){return function(t){return n.apply(null,t)}}function Lb(n){return Y.isObject(n)&&n.isAxiosError===!0}const Wr={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Wr).forEach(([n,o])=>{Wr[o]=n});function zc(n){const o=new bn(n),t=pc(bn.prototype.request,o);return Y.extend(t,bn.prototype,o,{allOwnKeys:!0}),Y.extend(t,o,null,{allOwnKeys:!0}),t.create=function(r){return zc(kn(n,r))},t}const Ge=zc(Io);Ge.Axios=bn;Ge.CanceledError=Zn;Ge.CancelToken=Ub;Ge.isCancel=_c;Ge.VERSION=Pc;Ge.toFormData=Wa;Ge.AxiosError=Fe;Ge.Cancel=Ge.CanceledError;Ge.all=function(o){return Promise.all(o)};Ge.spread=Ob;Ge.isAxiosError=Lb;Ge.mergeConfig=kn;Ge.AxiosHeaders=ht;Ge.formToJSON=n=>Nc(Y.isHTMLForm(n)?new FormData(n):n);Ge.getAdapter=Rc.getAdapter;Ge.HttpStatusCode=Wr;Ge.default=Ge;const{Axios:d3,AxiosError:u3,CanceledError:m3,isCancel:p3,CancelToken:f3,VERSION:h3,all:v3,Cancel:g3,isAxiosError:y3,spread:b3,toFormData:w3,AxiosHeaders:k3,HttpStatusCode:x3,formToJSON:E3,getAdapter:S3,mergeConfig:V3}=Ge;class pi{constructor(o="/api/v1"){this.eventSource=null,this.progressCallbacks=new Map,this.api=Ge.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 pi;const Wb={key:0,class:"mobile-layout"},jb={class:"preview-section"},Xb={class:"timeline-section"},Zb={class:"controls-section"},Yb={class:"tab-nav"},Gb=["onClick"],Hb={class:"tab-content"},Jb={class:"filters-panel"},qb={class:"adjustments-panel"},Kb={class:"text-panel"},Qb={class:"transitions-panel"},ew={class:"audio-panel"},tw={class:"export-panel"},nw={key:0,"data-testid":"video-export-status-completed"},ow={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},aw={key:1,class:"desktop-layout"},rw={class:"desktop-main-row"},iw={class:"preview-panel"},sw={class:"fit-toggle"},lw={class:"editor-content"},cw={class:"editor-tabs"},dw={class:"tab-header"},uw=["onClick"],mw={class:"tab-content-area"},pw={class:"filter-controls"},fw={class:"text-controls"},hw={class:"transition-controls"},vw={class:"audio-controls"},gw={class:"adjustments-controls"},yw={key:1,class:"no-filter-selected"},bw={class:"export-controls"},ww={key:0,"data-testid":"video-export-status-completed"},kw={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},xw={class:"desktop-timeline-row"},Ew={class:"timeline-container"},Sw={class:"timeline-zoom"},Vw=["value"],Cw={class:"zoom-readout"},Nw={key:0,class:"dev-editor-controls","data-testid":"video-editor-dev-controls"},_w={class:"dev-editor-row"},Tw={class:"dev-editor-field"},Mw={class:"dev-editor-field"},Fw=["disabled"],Bw=["disabled"],Iw=["disabled"],Rw={class:"dev-editor-row"},Pw={class:"dev-editor-field dev-editor-field--wide"},$w=["value"],zw=["disabled"],Aw=["disabled"],Dw=["disabled"],Uw=["disabled"],Ow=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 E=a.media.uuid??a.media.id;return typeof E=="string"&&E.trim()!==""?E.trim():void 0}),s=e.computed(()=>{const E=typeof a.mediaUuid=="string"?a.mediaUuid.trim():"";return E!==""?E: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 E=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},N=a.featureFlags;return N?{filters:typeof N.filters=="boolean"?N.filters:E.filters,adjustments:typeof N.adjustments=="boolean"?N.adjustments:E.adjustments,text:typeof N.text=="boolean"?N.text:E.text,transitions:typeof N.transitions=="boolean"?N.transitions:E.transitions,audio:typeof N.audio=="boolean"?N.audio:E.audio,export:typeof N.export=="boolean"?N.export:E.export}:E}),p=e.computed(()=>l.value?c.value:d.value),m=e.computed(()=>p.value==="filters"||x.value),h=e.computed(()=>p.value!=="filters"&&!x.value),v=e.ref(null),b=e.ref(null),x=e.ref(!1),R=e.computed(()=>l.value?v.value:b.value);function S(E){return E==="contain"||E==="cover"||E==="none"}function g(E){if(!(E!=null&&E.metadata))return null;const N=E.metadata.fit_mode;return S(N)?N:null}const f=e.shallowRef(null),w=e.ref(null),$=e.ref(g(a.initialRecipe)??"contain"),V=e.ref(null),y=e.ref(null),C=e.ref(null),D=e.ref(!1),k=new Map,T=e.ref([]),F=e.ref([]),A=e.ref([]),P=e.ref([]),O=e.ref(1),B=()=>{l.value=window.innerWidth<768},_=[{id:"filters",label:"Filters",icon:an},{id:"adjustments",label:"Adjust",icon:cm},{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:Ea}],X=[{id:"filters",label:"Filters"},{id:"adjustments",label:"Adjustments"},{id:"text",label:"Text"},{id:"transitions",label:"Transitions"},{id:"audio",label:"Audio"},{id:"export",label:"Export"}],W=e.computed(()=>_.filter(E=>u.value[E.id])),ee=e.computed(()=>X.filter(E=>u.value[E.id])),he=e.computed(()=>{var E,N;return((E=ee.value[0])==null?void 0:E.id)??((N=W.value[0])==null?void 0:N.id)??"filters"});e.watch(u,E=>{E[c.value]||(c.value=he.value),E[d.value]||(d.value=he.value)},{immediate:!0,deep:!0}),e.watch(he,E=>{u.value[c.value]||(c.value=E),u.value[d.value]||(d.value=E)},{immediate:!0}),e.watch(u,E=>{E.export||(c.value==="export"&&(c.value=he.value),d.value==="export"&&(d.value=he.value))},{immediate:!0,deep:!0});const Ue=e.computed(()=>typeof window>"u"?!1:window.__MEDIABLES_EDITOR_DEV__===!0),{currentFrame:Te,playheadPosition:re,timelineClips:M,totalDuration:j,hasChanges:le,isPlaying:ae,selectedClip:H,zoomLevel:K,playbackSpeed:ce,handleTrim:ve,handleSplit:ke,handleClipSelect:ne,splitAtPlayhead:we,deleteSelectedClip:pe,duplicateSelectedClip:qe,setZoomLevel:rt,moveClip:de,setFilters:ye,setTextOverlays:L,setAudioTracks:oe,saveDraft:Q,clearHasChanges:te,resetChanges:xe,generateRecipe:Ee,zoomIn:Re,zoomOut:Oe,fitToWindow:G,togglePlayback:ue,setPlaying:be,seekTo:Me,frameForward:Xe,frameBackward:Bt,skipToStart:Ct,skipToEnd:Yt,setPlaybackSpeed:mt,updateSourceDuration:Vn}=ey(s.value,a.initialRecipe,a.media),{videoCompatibleFilters:Ha,activeFilters:Ke,selectedFilter:Ro,previewFilter:Po,previewFilterEffect:qc,applyFilter:xi,updateFilterParams:Kc,removeFilter:Qc,clearAllFilters:Ei,setActiveFilters:ed}=dy();function Yn(E){var Z,J;const N=((Z=H.value)==null?void 0:Z.id)??((J=M.value[0])==null?void 0:J.id);N&&(D.value=!0,typeof E=="object"&&E.id?xi(E.id):typeof E=="string"&&xi(E),ye(Ke.value),f.value?f.value.setClipFilters(N,Ke.value):k.set(N,[...Ke.value]),ne(N),D.value=!1,Rt())}function td(){var N,Z;const E=((N=H.value)==null?void 0:N.id)??((Z=M.value[0])==null?void 0:Z.id);E&&ne(E)}function Si(E){const N=Ke.value.find(Z=>Z.filterId===E);N&&Qc(N.id)}const $o=e.computed(()=>Ha.value.map(N=>{var J;const Z=[];if(N.controls&&N.controls.length>0)for(const ie of N.controls){const q=ie.type;if(q==="button"||q==="text"||q==="range")continue;const se={id:ie.property||ie.id,label:ie.label||ie.id,type:q,default:ie.default??(q==="toggle"?!1:q==="color"?"#ffffff":0)};q==="slider"&&(se.min=ie.min??0,se.max=ie.max??1,se.step=ie.step??.01),q==="select"&&ie.options&&(se.options=ie.options),Z.push(se)}else if(N.paramRanges){const ie=Object.entries(N.paramRanges);for(const[q,se]of ie){const Pe=q.replace(/[-_]/g," ").replace(/\b\w/g,Pt=>Pt.toUpperCase()),dt=(J=N.defaultParams)==null?void 0:J[q],Ht=(se.min+se.max)/2;Z.push({id:q,label:Pe,min:se.min,max:se.max,step:se.step??.01,default:typeof dt=="number"?dt:Ht})}}return{id:N.id,name:N.name,category:N.category,params:Z}})),Cn=e.ref("0.00"),Nn=e.ref("0.00"),en=e.ref("");e.watch($o,E=>{if(E.length===0){en.value="";return}E.some(Z=>Z.id===en.value)||(en.value=E[0].id)},{immediate:!0});const ot=e.ref(!1),Ze=e.ref(0),Nt=e.ref(!1),We=e.ref(null),_t=e.ref(null);let zo=null,Et=!1,Gt=null;const Vi=e.computed(()=>{const E=new Map;return Ke.value.forEach(N=>E.set(N.filterId,N)),E}),Ci=e.computed(()=>{var E,N;return Te.value?Te.value:((E=a.media)==null?void 0:E.thumbnail_url)||((N=a.media)==null?void 0:N.url)}),It=e.ref("");e.watch(()=>{var E,N;return{file:(E=a.media)==null?void 0:E.file,url:(N=a.media)==null?void 0:N.url}},(E,N,Z)=>{var ie,q;const J=It.value;Z(()=>{J&&J.startsWith("blob:")&&URL.revokeObjectURL(J)}),(ie=a.media)!=null&&ie.file?It.value=URL.createObjectURL(a.media.file):(q=a.media)!=null&&q.url?It.value=a.media.url:It.value=""},{immediate:!0}),e.onUnmounted(()=>{It.value&&It.value.startsWith("blob:")&&URL.revokeObjectURL(It.value)});const Ja=e.computed(()=>It.value),Ni=e.computed(()=>{if(!a.media)return null;const{file:E,...N}=a.media;return{...N,url:It.value}}),_i=e.computed(()=>{var N;const E=(N=a.media)==null?void 0:N.url;return!!(E&&/^https?:/i.test(E))}),Ti=e.computed(()=>Ke.value),Mi=e.computed(()=>re.value),nd=e.computed(()=>!!H.value&&re.value>0),od=e.computed(()=>!!H.value&&M.value.length>1),qa=e.ref(0),_n=e.computed(()=>{try{const E=j.value??j;return E&&typeof E=="number"&&E>0?E:qa.value}catch{return qa.value}});function Tn(E){return Number.isFinite(E)?E.toFixed(2):"0.00"}function Fi(E){const N=Number(E);return Number.isFinite(N)?N:null}function ad(E){E&&(Cn.value=Tn(E.sourceIn),Nn.value=Tn(E.sourceOut))}e.watch(()=>{var E,N,Z;return[(E=H.value)==null?void 0:E.id,(N=H.value)==null?void 0:N.sourceIn,(Z=H.value)==null?void 0:Z.sourceOut]},()=>{ad(H.value)},{immediate:!0});function Bi(E){const N=H.value;if(!N)return;const Z=1/30,J=N.sourceMinIn??0,ie=N.sourceMaxOut??_n.value,q=N.sourceIn+(re.value-N.timelineStart);if(E==="start"){const Pe=Math.max(J,Math.min(q,N.sourceOut-Z));Cn.value=Tn(Pe);return}const se=Math.max(N.sourceIn+Z,Math.min(q,ie));Nn.value=Tn(se)}function rd(){const E=H.value;if(!E)return;const N=Fi(Cn.value),Z=Fi(Nn.value);if(N===null||Z===null)return;const J=1/30,ie=E.sourceMinIn??0,q=E.sourceMaxOut??_n.value,se=Math.max(ie,Math.min(N,q-J)),Pe=Math.max(se+J,Math.min(Z,q));ve(E.id,"start",se),ve(E.id,"end",Pe),Cn.value=Tn(se),Nn.value=Tn(Pe),H.value&&Me(H.value.timelineStart)}function id(){en.value.trim()!==""&&Yn(en.value)}function sd(){var E;Ei(),ye(Ke.value),(E=H.value)!=null&&E.id&&(f.value?f.value.setClipFilters(H.value.id,Ke.value):k.set(H.value.id,[...Ke.value])),Rt()}function Ii(E,N,Z){var ie,q;const J=Ke.value.find(se=>se.filterId===E);J?(J.params={...J.params,[N]:Z},ye(Ke.value),f.value&&((ie=H.value)!=null&&ie.id)?f.value.setClipFilters(H.value.id,Ke.value):(q=H.value)!=null&&q.id&&k.set(H.value.id,[...Ke.value]),Rt(),td()):Po.value&&Po.value.filterId===E&&(Po.value.params={...Po.value.params||{},[N]:Z})}function Ri(E){Me(E)}function Pi(E){be(E)}function Ao(E){!Number.isFinite(E)||E<=0||(qa.value=E,Vn(E))}function ld(E){const N=E.target,Z=Number(N.value);rt(Z)}function $i(E){var N;f.value=E,(N=f.value)!=null&&N.composition&&(V.value=new uy(f.value.composition),y.value=new ya(f.value.composition),C.value=new my(f.value.composition));try{k.size&&(k.forEach((Z,J)=>{f.value.setClipFilters(J,Z)}),k.clear(),f.value.composition.computeFrame())}catch{}}function zi(E){E!=null&&E.id&&qc(E.id)}function Ai(E){Kc(E),Rt()}async function Di(E){if(!V.value)return;const N=await V.value.addTextOverlay(E);T.value.push({id:N,...E})}async function Ui(E,N){if(!V.value)return;await V.value.updateTextOverlay(E,N);const Z=T.value.findIndex(J=>J.id===E);Z!==-1&&(T.value[Z]={...T.value[Z],...N})}async function Oi(E){V.value&&(await V.value.removeTextOverlay(E),T.value=T.value.filter(N=>N.id!==E))}async function Li(E){if(!y.value||P.value.length<2)return;const[N,Z]=P.value,J=await y.value.applyTransition(N,Z,E);F.value.push({id:J,...E,name:E.type})}function Wi(E){if(!y.value)return;const N=F.value[E];N&&(y.value.removeTransition(N.id),F.value.splice(E,1))}function ji(E){}async function Xi(E){if(!C.value)return;const N=await C.value.addAudioTrack(E);A.value.push({id:N,...E})}async function Zi(E,N){if(!C.value)return;const Z=A.value.findIndex(J=>J.id===E);Z!==-1&&(A.value[Z]={...A.value[Z],...N})}async function Yi(E){C.value&&(await C.value.removeAudioTrack(E),A.value=A.value.filter(N=>N.id!==E))}async function Gi(E,N){if(!C.value)return;await C.value.updateVolume(E,N);const Z=A.value.find(J=>J.id===E);Z&&(Z.volume=N)}async function Hi(E,N){if(!C.value)return;await C.value.muteTrack(E,N);const Z=A.value.find(J=>J.id===E);Z&&(Z.muted=N)}function Ji(E){C.value&&(C.value.setMasterVolume(E),O.value=E)}function cd(E){r("thumbnail-selected",E)}function tn(){zo!==null&&(clearInterval(zo),zo=null)}function dd(E,N){return N?{...E,output:{...E.output,format:N.format,quality:N.quality}}:E}function Gn(E){var N;return E.metadata||(E.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),E.metadata.fit_mode=$.value,(N=a.media)!=null&&N.url&&/^https?:/i.test(a.media.url)?E.metadata.source_url=a.media.url:delete E.metadata.source_url,E}function Ye(E,N,Z){return Math.min(Z,Math.max(N,E))}function Ka(E,N){if(typeof E=="number"&&Number.isFinite(E))return E;if(typeof E=="string"){const Z=Number(E);if(Number.isFinite(Z))return Z}return N}function it(E,N,Z){for(const J of N)if(J in E)return Ka(E[J],Z);return Z}function ud(E){const N=typeof E.params=="object"&&E.params!==null?E.params:{};switch(E.filterId.trim().toLowerCase()){case"brightness":return[{type:"brightness",value:Ye(it(N,["value","brightness"],0),-1,1)}];case"contrast":return[{type:"contrast",value:Ye(it(N,["value","contrast"],1),.1,3)}];case"saturation":return[{type:"saturation",value:Ye(it(N,["value","saturation"],1),0,3)}];case"blur":case"gaussian-blur":case"kawase-blur":case"radial-blur":return[{type:"blur",value:Ye(it(N,["value","blur","radius"],0),0,25)}];case"sharpen":return[{type:"sharpen",value:Ye(it(N,["value","amount"],1),0,5)}];case"sepia":return[{type:"sepia",value:1}];case"grayscale":return[{type:"grayscale",value:1}];case"adjustment":{const J=Ye(it(N,["brightness"],1)-1,-1,1),ie=Ye(it(N,["contrast"],1),.1,3),q=Ye(it(N,["saturation"],1),0,3);return[{type:"brightness",value:J},{type:"contrast",value:ie},{type:"saturation",value:q}]}default:return[]}}function md(E){const N=E.timeline[0],Z=Array.isArray(N==null?void 0:N.filters)?N.filters:[],J=[];for(const q of Z)if(J.push(...ud(q)),J.length>=12)break;const ie={...E,filters:J.slice(0,12)};if(E.timeline.length===1&&N){const q=Math.max(0,Ka(N.sourceIn,0)),se=Ka(N.sourceOut,q);se>q&&(ie.trim={start:q,end:se})}return ie}function pd(E){return{"360p":[640,360],"480p":[854,480],"720p":[1280,720],"1080p":[1920,1080],"1440p":[2560,1440],"2160p":[3840,2160]}[E??""]??[1920,1080]}function fd(E){if(!E||typeof E!="object")return null;const N=E.duration;if(typeof N=="number"&&Number.isFinite(N)&&N>0)return N;if(N&&typeof N=="object"&&"value"in N){const Z=N.value;if(typeof Z=="number"&&Number.isFinite(Z)&&Z>0)return Z}return null}async function qi(E,N,Z){var Ht,Pt,$t,zt;const J=E.timeline[0],ie=J?Math.max(0,J.sourceIn):0,q=J?J.sourceOut:void 0,[se,Pe]=pd((N==null?void 0:N.quality)??((Ht=E.output)==null?void 0:Ht.quality)),dt=((Pt=E.output)==null?void 0:Pt.fps)||30;be(!1),x.value=!0,await e.nextTick();try{const et=[200,500,1e3];let st=!1;for(const rr of et){await new Promise(Id=>setTimeout(Id,rr));const Uo=R.value;if(!(!Uo||typeof Uo.captureFrameAt!="function")&&typeof Uo.ensureReadyForCapture=="function"&&(st=await Uo.ensureReadyForCapture(),st))break}const gt=R.value;if(!gt||typeof gt.captureFrameAt!="function")throw new Error("PIXI preview not available for export. Ensure the preview is mounted.");if(!st)throw new Error("PIXI preview not ready for frame capture after retries. The video may still be loading.");const{exportWithPixiFrames:Do,isWebCodecsSupported:Hn}=await Promise.resolve().then(()=>require("./PixiFrameExporter-D_yS7r_n.cjs"));if(!Hn())throw new Error("WebCodecs is not supported in this browser. Export requires Chrome 94+ or equivalent.");Gt=new AbortController;const Mn={width:se,height:Pe,fps:dt,trimStart:ie,signal:Gt.signal};q!==void 0&&(Mn.trimEnd=q),Z&&(Mn.onProgress=Z);const is=It.value;is!==""&&(Mn.sourceUrl=is);const _d=typeof gt.duration=="number"&>.duration>0?gt.duration:(($t=E.source)==null?void 0:$t.duration)??q??0,Td=await Do({captureFrameAt:rr=>gt.captureFrameAt(rr),duration:{value:_d}},Mn),ar=new File([Td],`edited-video-${Date.now()}.mp4`,{type:"video/mp4"}),Md=fd(gt),Fd=((zt=E.source)==null?void 0:zt.duration)??0,Bd=Math.max(0,(q??Md??Fd)-ie);return{file:ar,recipe:E,meta:{duration:Bd,width:se,height:Pe,format:"mp4",sizeBytes:ar.size,size_bytes:ar.size}}}finally{x.value=!1,Gt=null}}async function hd(E,N){var zt;tn(),Et=!1,Gt=null,_t.value=null,We.value=null,Nt.value=!1,Ze.value=0;const Z=Gn(E??Ee()),J=as(Z),ie=Array.isArray(J.filters)&&J.filters.length>0,q=tr(J);if(!(le.value||ie||q))return te(),r("video-exported",null),null;const Pe=J.timeline[0],dt=Pe?Math.max(0,Pe.sourceIn):0,Pt=((Pe==null?void 0:Pe.sourceOut)??((zt=J.source)==null?void 0:zt.duration)??_n.value)-dt,$t=a.serverRenderEndpoint!=null&&a.clientExportThreshold>0&&Pt>a.clientExportThreshold;if($t){ot.value=!0;try{return await vd(J),null}catch(et){const st=et instanceof Error?et.message:"Server render failed";throw We.value=st,r("server-render-failed",st),et}finally{ot.value=!1}}if(a.maxDuration>0&&Pt>a.maxDuration&&!$t){const et=`This video is too long for in-browser export (${Math.round(Pt)}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 qi(J,N,st=>{Et||(Ze.value=st)});return Et?(We.value="Export canceled.",Ze.value=0,r("video-exported",null),null):(te(),r("recipe-generated",J),r("video-exported",et),Ze.value=100,Nt.value=!0,et)}catch(et){if(Et)return We.value="Export canceled.",Ze.value=0,r("video-exported",null),null;const st=et instanceof Error?et.message:"Local WebGL export failed.";throw We.value=st,new Error(`Video export failed: ${st}`)}finally{ot.value=!1}}async function vd(E){const N=new pi(a.serverRenderEndpoint??"/api/v1");We.value="Starting server render...",Ze.value=0;const Z=await N.createRenderJob({source_media_uuid:s.value,recipe:E});_t.value=Z.id,r("server-render-started",Z.id),r("export-started",Z.id),We.value="Rendering on server...";const J=await N.pollRenderJob(Z.id,(q,se)=>{Ze.value=q,se==="processing"&&(We.value=`Server rendering: ${q}%`)},3e3,(a.maxDuration>0?a.maxDuration*3:1800)*1e3);Ze.value=100,Nt.value=!0,We.value="Server render complete!",te(),r("recipe-generated",E);const ie={id:J.id};typeof J.output_media_id=="string"&&J.output_media_id!==""&&(ie.output_media_id=J.output_media_id),r("server-render-completed",ie)}async function Ki(){if(!ot.value)return;Et=!0,x.value=!1,Gt&&(Gt.abort(),Gt=null),tn();const E=_t.value;if(E)try{const N=await fetch(`/api/v1/video/jobs/${E}`,{method:"DELETE"});if(!N.ok)throw new Error(`Cancel failed: ${N.status} ${N.statusText}`)}catch(N){const Z=N instanceof Error?N.message:"Failed to cancel export";We.value=Z,ot.value=!1,_t.value=null;return}ot.value=!1,Ze.value=0,Nt.value=!1,_t.value=null,We.value="Export canceled."}async function Qi(E){tn(),Et=!1,Gt=null,_t.value=null,We.value=null,Nt.value=!1,ot.value=!0,Ze.value=0;try{const N=Gn(dd(Ee(),E));r("recipe-generated",N);const Z=s.value.startsWith("temp-"),J=N.timeline[0],ie=Array.isArray(J==null?void 0:J.filters)?J.filters:[],q=!0,se=typeof window<"u"&&window.MEDIABLES_ALLOW_SERVER_EXPORT_FALLBACK===1||typeof localStorage<"u"&&localStorage.getItem("mediables.export.allowServerFallback")==="1";if(q)try{const gt=await qi(N,E,Mn=>{Et||(Ze.value=Mn)});if(Et){We.value="Export canceled.",ot.value=!1,Ze.value=0;return}r("video-exported",gt);const Do=URL.createObjectURL(gt.file),Hn=document.createElement("a");Hn.href=Do,Hn.download=`edited-video-${Date.now()}.mp4`,Hn.click(),setTimeout(()=>URL.revokeObjectURL(Do),100),ot.value=!1,Ze.value=100,Nt.value=!0;return}catch(gt){if(Et){We.value="Export canceled.",ot.value=!1,Ze.value=0;return}if(Z||!se)throw gt;Ze.value=0,We.value="Local filter export failed, falling back to server render."}const Pe={"360p":"low","480p":"low","720p":"medium","1080p":"high","1440p":"ultra","2160p":"ultra"},dt=(E==null?void 0:E.quality)??N.output.quality,Ht=Pe[dt]??"high",Pt={...md(N),export:{format:(E==null?void 0:E.format)??N.output.format,quality:Ht,resolution:dt,framerate:N.output.fps}},$t=await fetch("/api/v1/video/jobs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source_media_id:s.value,recipe:Pt})});if(!$t.ok)throw new Error(`Export failed: ${$t.status} ${$t.statusText}`);const zt=await $t.json(),et=(zt==null?void 0:zt.data)??zt,st=typeof(et==null?void 0:et.id)=="string"?et.id:null;if(!st)throw new Error("Export failed: missing job id");_t.value=st,r("export-started",st),Nd(st)}catch(N){if(x.value=!1,Gt=null,Et){We.value="Export canceled.",ot.value=!1,Ze.value=0,_t.value=null;return}try{const Z=Gn(Ee()),J=new Blob([JSON.stringify(Z,null,2)],{type:"application/json"}),ie=URL.createObjectURL(J),q=document.createElement("a");q.href=ie,q.download=`video-recipe-${Date.now()}.json`,q.click(),setTimeout(()=>URL.revokeObjectURL(ie),100)}finally{ot.value=!1,Ze.value=0,_t.value=null,We.value=N instanceof Error?N.message:"Export failed"}}}const Qa=async E=>{await new Promise(N=>{window.setTimeout(N,E)})},er=E=>{if(!E||E.width<=0||E.height<=0)return null;try{return E.toDataURL("image/jpeg",.85)}catch{return null}},gd=E=>{if(!E||typeof E!="object")return null;const Z=E.pixiCanvas;if(Z&&typeof Z=="object"&&"value"in Z){const J=Z.value;return J instanceof HTMLCanvasElement?J:null}return Z instanceof HTMLCanvasElement?Z:null},yd=E=>{if(!E||typeof E!="object")return null;const N=E.duration;if(typeof N=="number"&&Number.isFinite(N))return N;if(N&&typeof N=="object"&&"value"in N){const Z=N.value;if(typeof Z=="number"&&Number.isFinite(Z))return Z}return null},bd=E=>{if(!E||typeof E!="object")return null;const Z=E.videoElement;if(Z&&typeof Z=="object"&&"value"in Z){const J=Z.value;return J instanceof HTMLVideoElement?J:null}return Z instanceof HTMLVideoElement?Z:null},es=E=>typeof E.params=="object"&&E.params!==null?E.params:{},wd=E=>{const N=[];for(const Z of E){const J=es(Z),ie=Z.filterId.trim().toLowerCase();if(ie==="brightness"){const se=(Ye(it(J,["value","brightness"],0),-1,1)+1)*100;N.push(`brightness(${se.toFixed(2)}%)`);continue}if(ie==="contrast"){const q=Ye(it(J,["value","contrast"],1),.1,4);N.push(`contrast(${(q*100).toFixed(2)}%)`);continue}if(ie==="saturation"||ie==="saturate"){const q=Ye(it(J,["value","saturation"],1),0,4);N.push(`saturate(${(q*100).toFixed(2)}%)`);continue}if(ie==="grayscale"){N.push("grayscale(100%)");continue}if(ie==="sepia"){N.push("sepia(100%)");continue}if(ie==="blur"||ie==="gaussian-blur"||ie==="kawase-blur"){const q=Ye(it(J,["value","blur","radius"],0),0,30);q>.01&&N.push(`blur(${q.toFixed(2)}px)`);continue}if(ie==="adjustment"){const q=it(J,["brightness"],1),se=it(J,["contrast"],1),Pe=it(J,["saturation"],1);Math.abs(q-1)>.01&&N.push(`brightness(${(Ye(q,0,5)*100).toFixed(2)}%)`),Math.abs(se-1)>.01&&N.push(`contrast(${(Ye(se,.1,5)*100).toFixed(2)}%)`),Math.abs(Pe-1)>.01&&N.push(`saturate(${(Ye(Pe,0,5)*100).toFixed(2)}%)`);continue}if(ie==="cinematic"){N.push("contrast(120%) brightness(95%) saturate(85%)");continue}if(ie==="dramatic"){N.push("contrast(140%) brightness(90%) saturate(110%) sepia(10%)");continue}if(ie==="dreamy"){N.push("blur(0.5px) brightness(105%) saturate(90%) contrast(95%)");continue}}return N.join(" ")},kd=E=>{const N=E.find(ie=>ie.filterId.trim().toLowerCase()==="noise");if(!N)return 0;const Z=es(N),J=it(Z,["noise","value","amount","intensity"],.2);return J<=1?Ye(J,0,1):Ye(J/100,0,1)},xd=(E,N,Z,J)=>{if(J<=0)return;const ie=E.getImageData(0,0,N,Z),q=255*J;for(let se=0;se<ie.data.length;se+=4){const Pe=(Math.random()*2-1)*q;ie.data[se]=Ye(ie.data[se]+Pe,0,255),ie.data[se+1]=Ye(ie.data[se+1]+Pe,0,255),ie.data[se+2]=Ye(ie.data[se+2]+Pe,0,255)}E.putImageData(ie,0,0)},ts=async E=>{E.readyState>=2&&E.videoWidth>0&&E.videoHeight>0||await new Promise(N=>{let Z=!1,J=0;const ie=()=>{Z||(Z=!0,E.removeEventListener("loadedmetadata",q),E.removeEventListener("loadeddata",q),E.removeEventListener("canplay",q),window.clearTimeout(J),N())},q=()=>{ie()};E.addEventListener("loadedmetadata",q),E.addEventListener("loadeddata",q),E.addEventListener("canplay",q),J=window.setTimeout(()=>ie(),800),E.play().catch(()=>{})})},Ed=async(E,N)=>{await new Promise(Z=>{let J=!1,ie=0;const q=()=>{J||(J=!0,E.removeEventListener("seeked",se),window.clearTimeout(ie),Z())},se=()=>{q()};if(Math.abs(E.currentTime-N)<.016){requestAnimationFrame(()=>q());return}E.addEventListener("seeked",se),ie=window.setTimeout(()=>q(),700),E.currentTime=N})},ns=async(E,N)=>{await ts(E);const Z=Math.floor(E.videoWidth),J=Math.floor(E.videoHeight);if(Z<=0||J<=0)return null;const ie=Number.isFinite(E.duration)&&E.duration>0?E.duration:0,q=ie>0?Ye(N,0,ie):0;await Ed(E,q);const se=document.createElement("canvas");se.width=Z,se.height=J;const Pe=se.getContext("2d");if(!Pe)return null;const dt=wd(Ke.value);dt!==""&&(Pe.filter=dt);try{Pe.drawImage(E,0,0,Z,J)}catch{return null}const Ht=kd(Ke.value);return xd(Pe,Z,J,Ht),er(se)},Sd=async(E,N)=>{const Z=document.createElement("video");Z.src=E,Z.muted=!0,Z.playsInline=!0,Z.preload="auto",E.startsWith("blob:")||(Z.crossOrigin="anonymous");try{return await ts(Z),await ns(Z,N)}catch{return null}finally{Z.pause(),Z.removeAttribute("src"),Z.load()}},Vd=async E=>{const N=R.value,Z=er(gd(N));if(Z)return Z;if(N!=null&&N.captureFrameAt)for(let q=0;q<4;q+=1){const se=yd(N);if(se!==null&&se<=0&&q<2){await Qa(80);continue}const Pe=await Promise.race([N.captureFrameAt(E),Qa(450).then(()=>null)]),dt=er(Pe);if(dt)return dt;await Qa(80)}const J=bd(N);if(J){const q=await ns(J,E);if(q)return q}const ie=Ja.value.trim();if(ie!==""){const q=await Sd(ie,E);if(q)return q}return null},os=E=>E.map(N=>({...N,params:N.params&&typeof N.params=="object"?{...N.params}:N.params}));function as(E){const N=os(Ke.value);if(!tr(E)&&N.length>0&&Array.isArray(E.timeline)&&E.timeline.length>0){const J=E.timeline[0];J&&(E.timeline=[{...J,filters:N},...E.timeline.slice(1)])}return E}const tr=E=>Array.isArray(E.timeline)?E.timeline.some(N=>Array.isArray(N.filters)&&N.filters.length>0):!1,Cd=E=>{if(!E||typeof E!="object")return null;const N=E.posterFrame;if(typeof N!="string")return null;const Z=N.trim();return Z!==""?Z:null};async function nr(){const E=Gn(as(Q())),N=os(Ke.value),Z=tr(E)||N.length>0,J=Cd(a.initialRecipe);if(Z){const ie=re.value>0?re.value:.1;try{const q=await Vd(ie);q?E.posterFrame=q:J&&(E.posterFrame=J)}catch{J&&(E.posterFrame=J)}}else delete E.posterFrame;return te(),r("draft-saved",E),E}function rs(){xe()&&(Ei(),Rt())}async function Nd(E){tn(),zo=window.setInterval(async()=>{var N,Z;try{if(Et){tn();return}const J=await fetch(`/api/v1/video/jobs/${E}`);if(!J.ok)throw new Error(`Status poll failed: ${J.status} ${J.statusText}`);const ie=await J.json(),q=(ie==null?void 0:ie.data)??ie,se=Number((q==null?void 0:q.progress)??0);if(Ze.value=Number.isFinite(se)?se:0,q.status==="completed"||q.status==="failed"||q.status==="cancelled")if(tn(),ot.value=!1,_t.value=null,q.status==="completed"){const Pe=((N=q==null?void 0:q.output_media)==null?void 0:N.url)??(q==null?void 0:q.output_url);Ze.value=100,Nt.value=!0,We.value=null}else{const Pe=!!((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=Pe?"Export canceled.":typeof(q==null?void 0:q.error_message)=="string"&&q.error_message.trim()!==""?q.error_message:"Export failed"}}catch(J){tn(),ot.value=!1,_t.value=null,We.value=J instanceof Error?J.message:"Failed to check export progress"}},2e3)}function or(){const E=Gn(Ee());try{const N=E.timeline??[]}catch{}w.value=E}let sn=null;function Rt(){sn&&clearTimeout(sn),sn=setTimeout(()=>{or(),sn=null},200)}return e.watch(()=>M.value,Rt,{deep:!0}),e.watch(()=>H.value,E=>{if(D.value||!E)return;const N=(E==null?void 0:E.filters)??[];ed(N)},{immediate:!0}),e.watch(()=>Ke.value,E=>{ye(E),Rt()},{deep:!0}),e.watch(()=>T.value,E=>{L(E),Rt()},{deep:!0}),e.watch(()=>A.value,E=>{const N=E.map(Z=>({...Z,source:typeof Z.source=="string"?Z.source:void 0}));oe(N),Rt()},{deep:!0}),e.watch(()=>re.value,Rt),o({saveDraft:nr,exportForUpload:hd}),or(),e.onUnmounted(()=>{tn(),Et=!0,sn&&(clearTimeout(sn),sn=null),f.value&&(f.value.destroy(),f.value=null),V.value=null,y.value=null,C.value=null}),e.onMounted(()=>{window.addEventListener("resize",B),a.media&&or(),e.nextTick(()=>{const E=document.querySelector(".video-editor");E&&E.getBoundingClientRect();const N=document.querySelector(".mobile-layout");N&&N.getBoundingClientRect()})}),e.onUnmounted(()=>{window.removeEventListener("resize",B)}),(E,N)=>{var Z,J,ie,q;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-editor",{mobile:l.value}])},[l.value?(e.openBlock(),e.createElementBlock("div",Wb,[e.createElementVNode("div",jb,[e.withDirectives(e.createVNode(ks,{ref_key:"pixiPreviewMobileRef",ref:v,"aria-hidden":!m.value,class:"preview-host-child",source:Ja.value,filters:Ti.value,playhead:Mi.value,"is-playing":e.unref(ae),"fit-mode":$.value,active:m.value,onPlayPause:e.unref(ue),onDurationChange:Ao},null,8,["aria-hidden","source","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,m.value]]),e.withDirectives(e.createVNode(Us,{"aria-hidden":!h.value,class:"preview-host-child","media-uuid":s.value,recipe:w.value,media:Ni.value,"enable-engine":h.value&&_i.value,"fit-mode":$.value,onTimeUpdate:Ri,onPlayStateChange:Pi,onDurationChange:Ao,onEngineReady:$i},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,h.value]])]),e.createElementVNode("div",Xb,[e.createVNode(Os,{playhead:e.unref(re),clips:e.unref(M),"selected-clip-id":((Z=e.unref(H))==null?void 0:Z.id)??((J=e.unref(M)[0])==null?void 0:J.id)??null,duration:_n.value,"zoom-level":e.unref(K),sensitivity:.25,"is-mobile":!0,"onUpdate:playhead":e.unref(Me),onTrim:e.unref(ve),onSplit:e.unref(ke),onClipSelect:e.unref(ne),onClipMove:e.unref(de)},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","onUpdate:playhead","onTrim","onSplit","onClipSelect","onClipMove"])]),e.createElementVNode("div",Zb,[e.createElementVNode("div",Yb,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.value,se=>(e.openBlock(),e.createElementBlock("button",{key:se.id,class:e.normalizeClass(["tab-button",{active:c.value===se.id}]),onClick:Pe=>c.value=se.id},[e.createVNode(e.unref(I.IonIcon),{icon:se.icon},null,8,["icon"]),e.createElementVNode("span",null,e.toDisplayString(se.label),1)],10,Gb))),128))]),e.createElementVNode("div",Hb,[e.withDirectives(e.createElementVNode("div",Jb,[e.createVNode(Ls,{filters:$o.value,"active-filters":Vi.value,"thumbnail-url":Ci.value,onApplyFilter:Yn,onRemoveFilter:Si,onUpdateParam:Ii,onPreviewFilter:zi},null,8,["filters","active-filters","thumbnail-url"])],512),[[e.vShow,c.value==="filters"]]),e.withDirectives(e.createElementVNode("div",qb,[e.unref(Ro)?(e.openBlock(),e.createBlock(Ws,{key:0,filter:e.unref(Ro),"current-frame":e.unref(Te),onUpdateParams:Ai},null,8,["filter","current-frame"])):e.createCommentVNode("",!0)],512),[[e.vShow,c.value==="adjustments"]]),e.withDirectives(e.createElementVNode("div",Kb,[e.createVNode(Xs,{overlays:T.value,onAddOverlay:Di,onUpdateOverlay:Ui,onRemoveOverlay:Oi},null,8,["overlays"])],512),[[e.vShow,c.value==="text"]]),e.withDirectives(e.createElementVNode("div",Qb,[e.createVNode(Zs,{"selected-clips":P.value,"applied-transitions":F.value,onApplyTransition:Li,onRemoveTransition:Wi,onPreviewTransition:ji},null,8,["selected-clips","applied-transitions"])],512),[[e.vShow,c.value==="transitions"]]),e.withDirectives(e.createElementVNode("div",ew,[e.createVNode(Ys,{"audio-layers":A.value,"master-volume":O.value,onAddTrack:Xi,onUpdateTrack:Zi,onRemoveTrack:Yi,onUpdateVolume:Gi,onToggleMute:Hi,onUpdateMasterVolume:Ji},null,8,["audio-layers","master-volume"])],512),[[e.vShow,c.value==="audio"]]),e.withDirectives(e.createElementVNode("div",tw,[e.createVNode(js,{"can-export":e.unref(le),"is-exporting":ot.value,"export-progress":Ze.value,onExport:Qi,onCancelExport:Ki,onSaveDraft:nr,onReset:rs},null,8,["can-export","is-exporting","export-progress"]),Nt.value?(e.openBlock(),e.createElementBlock("div",nw," Export complete ")):e.createCommentVNode("",!0),We.value&&!Nt.value?(e.openBlock(),e.createElementBlock("div",ow,e.toDisplayString(We.value),1)):e.createCommentVNode("",!0)],512),[[e.vShow,c.value==="export"]])])])])):(e.openBlock(),e.createElementBlock("div",aw,[e.createElementVNode("div",rw,[e.createElementVNode("div",iw,[e.createElementVNode("div",sw,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":N[0]||(N[0]=se=>$.value=se),"aria-label":"Fit mode","data-testid":"select-video-fit-mode"},[...N[9]||(N[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,$.value]])])]),e.withDirectives(e.createVNode(ks,{ref_key:"pixiPreviewDesktopRef",ref:b,"aria-hidden":!m.value,class:"preview-host-child",source:Ja.value,filters:Ti.value,playhead:Mi.value,"is-playing":e.unref(ae),"fit-mode":$.value,active:m.value,onPlayPause:e.unref(ue),onDurationChange:Ao},null,8,["aria-hidden","source","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,m.value]]),e.withDirectives(e.createVNode(Us,{"aria-hidden":!h.value,class:"preview-host-child","media-uuid":s.value,recipe:w.value,media:Ni.value,"enable-engine":h.value&&_i.value,"fit-mode":$.value,onTimeUpdate:Ri,onPlayStateChange:Pi,onDurationChange:Ao,onEngineReady:$i},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,h.value]]),E.showThumbnailPicker?(e.openBlock(),e.createBlock(_g,{key:0,"media-uuid":s.value,duration:_n.value,onSelect:cd},null,8,["media-uuid","duration"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",lw,[e.createElementVNode("div",cw,[e.createElementVNode("div",dw,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ee.value,se=>(e.openBlock(),e.createElementBlock("button",{key:se.id,class:e.normalizeClass(["tab-btn",{active:d.value===se.id}]),onClick:Pe=>d.value=se.id},e.toDisplayString(se.label),11,uw))),128))]),e.createElementVNode("div",mw,[e.withDirectives(e.createElementVNode("div",pw,[e.createVNode(Ls,{filters:$o.value,"active-filters":Vi.value,"thumbnail-url":Ci.value,onApplyFilter:Yn,onRemoveFilter:Si,onUpdateParam:Ii,onPreviewFilter:zi},null,8,["filters","active-filters","thumbnail-url"])],512),[[e.vShow,d.value==="filters"]]),e.withDirectives(e.createElementVNode("div",fw,[e.createVNode(Xs,{overlays:T.value,onAddOverlay:Di,onUpdateOverlay:Ui,onRemoveOverlay:Oi},null,8,["overlays"])],512),[[e.vShow,d.value==="text"]]),e.withDirectives(e.createElementVNode("div",hw,[e.createVNode(Zs,{"selected-clips":P.value,"applied-transitions":F.value,onApplyTransition:Li,onRemoveTransition:Wi,onPreviewTransition:ji},null,8,["selected-clips","applied-transitions"])],512),[[e.vShow,d.value==="transitions"]]),e.withDirectives(e.createElementVNode("div",vw,[e.createVNode(Ys,{"audio-layers":A.value,"master-volume":O.value,onAddTrack:Xi,onUpdateTrack:Zi,onRemoveTrack:Yi,onUpdateVolume:Gi,onToggleMute:Hi,onUpdateMasterVolume:Ji},null,8,["audio-layers","master-volume"])],512),[[e.vShow,d.value==="audio"]]),e.withDirectives(e.createElementVNode("div",gw,[e.unref(Ro)?(e.openBlock(),e.createBlock(Ws,{key:0,filter:e.unref(Ro),"current-frame":e.unref(Te),onUpdateParams:Ai},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",yw,[...N[10]||(N[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",bw,[e.createVNode(js,{"can-export":e.unref(le),"is-exporting":ot.value,"export-progress":Ze.value,onExport:Qi,onCancelExport:Ki,onSaveDraft:nr,onReset:rs},null,8,["can-export","is-exporting","export-progress"]),Nt.value?(e.openBlock(),e.createElementBlock("div",ww," Export complete ")):e.createCommentVNode("",!0),We.value&&!Nt.value?(e.openBlock(),e.createElementBlock("div",kw,e.toDisplayString(We.value),1)):e.createCommentVNode("",!0)],512),[[e.vShow,d.value==="export"]])])])])]),e.createElementVNode("div",xw,[e.createElementVNode("div",Ew,[e.createElementVNode("div",Sw,[e.createElementVNode("label",null,[N[11]||(N[11]=e.createTextVNode(" Zoom ",-1)),e.createElementVNode("input",{type:"range",min:"10",max:"600",value:e.unref(K),onInput:N[1]||(N[1]=se=>ld(se))},null,40,Vw)]),e.createElementVNode("span",Cw,e.toDisplayString(Math.round(e.unref(K)))+" px/s",1)]),e.createVNode(Os,{playhead:e.unref(re),clips:e.unref(M),"selected-clip-id":((ie=e.unref(H))==null?void 0:ie.id)??((q=e.unref(M)[0])==null?void 0:q.id)??null,duration:_n.value,"zoom-level":e.unref(K),sensitivity:.25,"onUpdate:playhead":e.unref(Me),onTrim:e.unref(ve),onSplit:e.unref(ke),onClipSelect:e.unref(ne),onClipMove:e.unref(de)},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","onUpdate:playhead","onTrim","onSplit","onClipSelect","onClipMove"]),e.createVNode(nv,{"selected-clip":e.unref(H),"can-split":nd.value,"can-delete":od.value,"is-playing":e.unref(ae),"zoom-level":e.unref(K),"playback-speed":e.unref(ce),onSplit:e.unref(we),onDelete:e.unref(pe),onDuplicate:e.unref(qe),onZoomIn:e.unref(Re),onZoomOut:e.unref(Oe),onZoomChange:e.unref(rt),onFitToWindow:e.unref(G),onPlayPause:e.unref(ue),onFrameForward:e.unref(Xe),onFrameBackward:e.unref(Bt),onSkipToStart:e.unref(Ct),onSkipToEnd:e.unref(Yt),onSpeedChange:e.unref(mt)},null,8,["selected-clip","can-split","can-delete","is-playing","zoom-level","playback-speed","onSplit","onDelete","onDuplicate","onZoomIn","onZoomOut","onZoomChange","onFitToWindow","onPlayPause","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"]),Ue.value?(e.openBlock(),e.createElementBlock("div",Nw,[e.createElementVNode("div",_w,[e.createElementVNode("label",Tw,[N[12]||(N[12]=e.createElementVNode("span",null,"Trim start (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":N[2]||(N[2]=se=>Cn.value=se),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-start"},null,512),[[e.vModelText,Cn.value]])]),e.createElementVNode("label",Mw,[N[13]||(N[13]=e.createElementVNode("span",null,"Trim end (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":N[3]||(N[3]=se=>Nn.value=se),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-end"},null,512),[[e.vModelText,Nn.value]])]),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-start-playhead",disabled:!e.unref(H),onClick:N[4]||(N[4]=se=>Bi("start"))}," Start = Playhead ",8,Fw),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-end-playhead",disabled:!e.unref(H),onClick:N[5]||(N[5]=se=>Bi("end"))}," End = Playhead ",8,Bw),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-trim",disabled:!e.unref(H),onClick:rd}," Apply Trim ",8,Iw)]),e.createElementVNode("div",Rw,[e.createElementVNode("label",Pw,[N[14]||(N[14]=e.createElementVNode("span",null,"Quick filter",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":N[6]||(N[6]=se=>en.value=se),"data-testid":"video-dev-filter-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList($o.value,se=>(e.openBlock(),e.createElementBlock("option",{key:se.id,value:se.id},e.toDisplayString(se.name),9,$w))),128))],512),[[e.vModelSelect,en.value]])]),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-filter",disabled:!e.unref(H)||en.value==="",onClick:id}," Apply Filter ",8,zw),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-clear-filters",disabled:e.unref(Ke).length===0,onClick:sd}," Clear Filters ",8,Aw),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(H),onClick:N[7]||(N[7]=se=>Yn("noise"))}," QA: Noise ",8,Dw),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(H),onClick:N[8]||(N[8]=se=>Yn("grayscale"))}," QA: Grayscale ",8,Uw)])])):e.createCommentVNode("",!0)])])]))],2)}}}),Ac=_e(Ow,[["__scopeId","data-v-4e83fe61"]]),Lw=["aria-label"],Ww={class:"ve-header"},jw={class:"ve-title"},Xw={class:"ve-body"},Zw={class:"ve-footer"},Yw=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",Ww,[e.createElementVNode("h2",jw,e.toDisplayString(l.title),1),e.createElementVNode("button",{class:"ve-close",onClick:s,"aria-label":"Close"}," ✕ ")]),e.createElementVNode("section",Xw,[e.createVNode(Ac,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",Zw,[e.renderSlot(l.$slots,"footer",{},()=>[e.createElementVNode("button",{class:"ve-btn",onClick:s},"Cancel")],!0)])],8,Lw)])):e.createCommentVNode("",!0)}}),Gw=_e(Yw,[["__scopeId","data-v-710e8e26"]]),Hw={class:"video-editor-modal"},Jw={class:"video-preview-container"},qw=["src"],Kw={class:"video-overlay-controls"},Qw=["aria-label"],e2={class:"time-display"},t2={class:"timeline-container"},n2={class:"clip-name"},o2={class:"timeline-time-labels"},a2={class:"tool-tabs"},r2=["onClick"],i2={class:"tool-panel"},s2={key:0,class:"trim-panel"},l2={class:"trim-controls"},c2={key:1,class:"filters-panel"},d2={class:"filter-grid"},u2=["onClick"],m2={key:2,class:"text-panel"},p2={key:3,class:"transitions-panel"},f2={class:"transition-grid"},h2=["onClick"],v2={class:"action-buttons"},g2=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),h=e.ref("trim"),v=e.ref(null),b=e.ref(""),x=[{id:"trim",label:"Trim",icon:Nl},{id:"filters",label:"Filters",icon:Qu},{id:"text",label:"Text",icon:Fl},{id:"transitions",label:"Transitions",icon:sm}],R=[{id:"none",name:"None"},{id:"grayscale",name:"Grayscale"},{id:"sepia",name:"Sepia"},{id:"blur",name:"Blur"},{id:"brightness",name:"Brightness"},{id:"contrast",name:"Contrast"}],S=[{id:"fade",name:"Fade"},{id:"slide",name:"Slide"},{id:"zoom",name:"Zoom"},{id:"wipe",name:"Wipe"}],g=e.ref();e.onMounted(()=>{var _,X;(_=t.media)!=null&&_.url?i.value=t.media.url:(X=t.media)!=null&&X.file&&(i.value=URL.createObjectURL(t.media.file))}),e.onUnmounted(()=>{var _;(_=t.media)!=null&&_.file&&i.value&&URL.revokeObjectURL(i.value)});function f(){r.value&&(c.value=r.value.duration,p.value=c.value)}function w(){r.value&&(l.value=r.value.currentTime)}function $(){s.value=!1}function V(){r.value&&(s.value?(r.value.pause(),s.value=!1):(r.value.play(),s.value=!0))}function y(_){if(!_||isNaN(_))return"00:00";const X=Math.floor(_/60),W=Math.floor(_%60);return`${X.toString().padStart(2,"0")}:${W.toString().padStart(2,"0")}`}function C(_){if(!r.value||!g.value)return;const X=g.value.getBoundingClientRect(),he=(_.clientX-X.left)/X.width*c.value;r.value.currentTime=Math.max(0,Math.min(he,c.value))}function D(){u.value=l.value}function k(){p.value=l.value}function T(){u.value=0,p.value=c.value}function F(_){m.value=_;const X=ee=>{if(!m.value||!g.value)return;const he=g.value.getBoundingClientRect(),re=(ee.clientX-he.left)/he.width*c.value;m.value==="start"?u.value=Math.max(0,Math.min(re,p.value-1)):p.value=Math.max(u.value+1,Math.min(re,c.value))},W=()=>{m.value=null,document.removeEventListener("mousemove",X),document.removeEventListener("mouseup",W)};document.addEventListener("mousemove",X),document.addEventListener("mouseup",W)}function A(_){if(v.value=_,!r.value)return;const X={none:"none",grayscale:"grayscale(100%)",sepia:"sepia(100%)",blur:"blur(5px)",brightness:"brightness(150%)",contrast:"contrast(150%)"};r.value.style.filter=X[_]||"none"}function P(){}function O(_){}function B(){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(_,X)=>(e.openBlock(),e.createElementBlock("div",Hw,[e.createElementVNode("div",Jw,[e.createElementVNode("video",{ref_key:"videoElement",ref:r,class:"video-preview",src:i.value,onLoadedmetadata:f,onTimeupdate:w,onEnded:$,controls:""},null,40,qw),e.createElementVNode("div",Kw,[e.createElementVNode("button",{class:"play-pause-btn",onClick:V,"aria-label":s.value?"Pause":"Play"},[e.createVNode(e.unref(I.IonIcon),{icon:s.value?e.unref(um):e.unref(vm)},null,8,["icon"])],8,Qw),e.createElementVNode("div",e2,e.toDisplayString(y(l.value))+" / "+e.toDisplayString(y(c.value)),1)])]),e.createElementVNode("div",t2,[e.createElementVNode("div",{class:"timeline-track",onClick:C,ref_key:"timelineTrack",ref:g},[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",n2,e.toDisplayString(d.value),1)],4),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:`${l.value/c.value*100}%`})},null,4),h.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:0,class:"trim-handle trim-start",style:e.normalizeStyle({left:`${u.value/c.value*100}%`}),onMousedown:X[0]||(X[0]=W=>F("start"))},null,36)):e.createCommentVNode("",!0),h.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:1,class:"trim-handle trim-end",style:e.normalizeStyle({left:`${p.value/c.value*100}%`}),onMousedown:X[1]||(X[1]=W=>F("end"))},null,36)):e.createCommentVNode("",!0)],512),e.createElementVNode("div",o2,[e.createElementVNode("span",null,e.toDisplayString(y(0)),1),e.createElementVNode("span",null,e.toDisplayString(y(c.value)),1)])]),e.createElementVNode("div",a2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(x,W=>e.createElementVNode("button",{key:W.id,class:e.normalizeClass(["tool-tab",{active:h.value===W.id}]),onClick:ee=>h.value=W.id},[e.createVNode(e.unref(I.IonIcon),{icon:W.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(W.label),1)],10,r2)),64))]),e.createElementVNode("div",i2,[h.value==="trim"?(e.openBlock(),e.createElementBlock("div",s2,[X[7]||(X[7]=e.createElementVNode("h3",null,"Trim Video",-1)),X[8]||(X[8]=e.createElementVNode("p",null,"Click and drag on the timeline to set trim points",-1)),e.createElementVNode("div",l2,[e.createElementVNode("button",{class:"btn-trim",onClick:D},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(vs)},null,8,["icon"]),X[4]||(X[4]=e.createTextVNode(" Set Start ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:k},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(vs)},null,8,["icon"]),X[5]||(X[5]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:T},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(go)},null,8,["icon"]),X[6]||(X[6]=e.createTextVNode(" Clear ",-1))])])])):h.value==="filters"?(e.openBlock(),e.createElementBlock("div",c2,[X[9]||(X[9]=e.createElementVNode("h3",null,"Filters",-1)),e.createElementVNode("div",d2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(R,W=>e.createElementVNode("button",{key:W.id,class:e.normalizeClass(["filter-option",{active:v.value===W.id}]),onClick:ee=>A(W.id)},e.toDisplayString(W.name),11,u2)),64))])])):h.value==="text"?(e.openBlock(),e.createElementBlock("div",m2,[X[10]||(X[10]=e.createElementVNode("h3",null,"Text Overlay",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":X[2]||(X[2]=W=>b.value=W),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")])):h.value==="transitions"?(e.openBlock(),e.createElementBlock("div",p2,[X[11]||(X[11]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",f2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(S,W=>e.createElementVNode("button",{key:W.id,class:"transition-option",onClick:ee=>(W.id,void 0)},e.toDisplayString(W.name),9,h2)),64))])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",v2,[e.createElementVNode("button",{class:"btn-cancel",onClick:X[3]||(X[3]=W=>_.$emit("cancel"))},"CANCEL"),e.createElementVNode("button",{class:"btn-save",onClick:B},"SAVE")])]))}}),y2=_e(g2,[["__scopeId","data-v-b933f33b"]]),b2={class:"time-label"},w2=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",b2,e.toDisplayString(c.label),1),e.createElementVNode("div",{class:e.normalizeClass(["time-tick",{major:c.major}])},null,2)],4))),128))],4))}}),k2=_e(w2,[["__scopeId","data-v-0ef9c910"]]),x2=["data-track-index"],E2={class:"track-header"},S2={class:"track-label"},V2={class:"track-controls"},C2=["data-testid","aria-label"],N2=["data-testid","onMousedown","onClick"],_2={class:"clip-content"},T2={class:"clip-name"},M2={key:0,class:"clip-thumbnail"},F2=["src","alt"],B2=["onMousedown","aria-label"],I2=["onMousedown","aria-label"],R2=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(x){const R=x.timelineEnd-x.timelineStart,S=x.timelineStart/t.duration*100,g=R/t.duration*100;return{left:`${S}%`,width:`${g}%`,backgroundColor:u(x)}}function u(x){const R=["#4A90E2","#7ED321","#F5A623","#BD10E0","#9013FE","#50E3C2","#B8E986","#F8E71C"],S=parseInt(x.id.replace(/\D/g,""))%R.length;return R[S]}function p(x){return x.label?x.label:x.url?(x.url.split("/").pop()||"Clip").split(".")[0]:`Clip ${x.id.slice(-4)}`}function m(x){r.value=x.id,a("clip-select",x.id)}function h(){i.value=!i.value}function v(x,R){if(l.value)return;s.value=!0;const S=R.clientX,g=x.timelineStart,f=$=>{if(!s.value)return;const V=$.clientX-S,y=parseFloat(c.value.width),C=V/(t.zoom*100)*(t.duration/y),D=Math.max(0,g+C);a("clip-move",x.id,D)},w=()=>{s.value=!1,document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",w)};document.addEventListener("mousemove",f),document.addEventListener("mouseup",w)}function b(x,R,S){l.value=R;const g=S.clientX,f=x.sourceIn,w=x.sourceOut,$=y=>{if(!l.value)return;const C=y.clientX-g,D=parseFloat(c.value.width),k=C/(t.zoom*100)*(t.duration/D);if(l.value==="start"){const T=Math.max(0,f+k);a("clip-trim",x.id,T,w)}else{const T=Math.max(f+1,w+k);a("clip-trim",x.id,f,T)}},V=()=>{l.value=null,document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",V)};document.addEventListener("mousemove",$),document.addEventListener("mouseup",V)}return(x,R)=>(e.openBlock(),e.createElementBlock("div",{class:"video-track","data-track-index":x.trackIndex},[e.createElementVNode("div",E2,[e.createElementVNode("span",S2,"Track "+e.toDisplayString(x.trackIndex+1),1),e.createElementVNode("div",V2,[x.clips.length>0?(e.openBlock(),e.createElementBlock("button",{key:0,class:"track-btn","data-testid":`btn-mute-track-${x.trackIndex}`,"aria-label":`${i.value?"Unmute":"Mute"} track ${x.trackIndex+1}`,onClick:h},[e.createVNode(e.unref(I.IonIcon),{icon:i.value?e.unref(Bm):e.unref(Mm)},null,8,["icon"])],8,C2)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",{class:"track-timeline",style:e.normalizeStyle(c.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(x.clips,S=>(e.openBlock(),e.createElementBlock("div",{key:S.id,class:e.normalizeClass(["timeline-clip",{selected:S.id===r.value}]),style:e.normalizeStyle(d(S)),"data-testid":`clip-${S.id}`,onMousedown:g=>v(S,g),onClick:g=>m(S)},[e.createElementVNode("div",_2,[e.createElementVNode("span",T2,e.toDisplayString(p(S)),1),S.thumbnail?(e.openBlock(),e.createElementBlock("div",M2,[e.createElementVNode("img",{src:S.thumbnail,alt:p(S)},null,8,F2)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:e.withModifiers(g=>b(S,"start",g),["stop"]),"aria-label":`Trim start of ${p(S)}`},null,40,B2),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:e.withModifiers(g=>b(S,"end",g),["stop"]),"aria-label":`Trim end of ${p(S)}`},null,40,I2)],46,N2))),128))],4)],8,x2))}}),P2=_e(R2,[["__scopeId","data-v-48e480d2"]]),$2={class:"video-timeline"},z2={class:"timeline-tracks"},A2=["aria-label","aria-valuenow","aria-valuemax"],D2={class:"timeline-controls"},U2={class:"zoom-level"},O2=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 g=Math.max(0,...t.clips.map(f=>f.track||0));return Array(g+1).fill(null)}),d=e.computed(()=>`${t.currentTime/t.duration*100}%`);function u(g){return t.clips.filter(f=>(f.track||0)===g)}function p(g){const f=Math.floor(g/60),w=Math.floor(g%60);return`${f}:${w.toString().padStart(2,"0")}`}function m(g,f){a("clip-move",g,f)}function h(g,f,w){a("clip-trim",g,f,w)}function v(g){i.value=g}function b(){r.value=Math.min(r.value*1.2,5)}function x(){r.value=Math.max(r.value/1.2,.5)}function R(){s.value=!0;const g=w=>{if(!s.value||!l.value)return;const $=l.value.getBoundingClientRect(),C=Math.max(0,Math.min(w.clientX-$.left,$.width))/$.width*t.duration;a("seek",C)},f=()=>{s.value=!1,document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",f)};document.addEventListener("mousemove",g),document.addEventListener("mouseup",f)}function S(g){let f=t.currentTime;switch(g.key){case"ArrowLeft":f=Math.max(0,t.currentTime-1);break;case"ArrowRight":f=Math.min(t.duration,t.currentTime+1);break;case"Home":f=0;break;case"End":f=t.duration;break;default:return}g.preventDefault(),a("seek",f)}return e.onMounted(()=>{l.value=document.querySelector(".video-timeline")}),e.onUnmounted(()=>{}),(g,f)=>(e.openBlock(),e.createElementBlock("div",$2,[e.createVNode(k2,{duration:g.duration,zoom:r.value},null,8,["duration","zoom"]),e.createElementVNode("div",z2,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,(w,$)=>(e.openBlock(),e.createBlock(P2,{key:`track-${$}`,"data-testid":`track-${$}`,clips:u($),"track-index":$,zoom:r.value,duration:g.duration,onClipMove:m,onClipTrim:h,onClipSelect:v},null,8,["data-testid","clips","track-index","zoom","duration"]))),128))]),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:d.value}),onMousedown:R,"data-testid":"playhead","aria-label":`Playhead at ${p(g.currentTime)}`,role:"slider","aria-valuenow":g.currentTime,"aria-valuemax":g.duration,tabindex:"0",onKeydown:S},null,44,A2),e.createElementVNode("div",D2,[e.createElementVNode("button",{"data-testid":"btn-zoom-in","aria-label":"Zoom in",onClick:b},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Xr)},null,8,["icon"])]),e.createElementVNode("span",U2,e.toDisplayString(Math.round(r.value*100))+"%",1),e.createElementVNode("button",{"data-testid":"btn-zoom-out","aria-label":"Zoom out",onClick:x},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Em)},null,8,["icon"])])])]))}}),L2=_e(O2,[["__scopeId","data-v-001df415"]]),W2={class:"video-filters-panel"},j2={class:"filter-controls"},X2=["for"],Z2={class:"filter-slider-group"},Y2=["id","onUpdate:modelValue","min","max","step","data-testid","aria-label","aria-valuenow","aria-valuemin","aria-valuemax","onInput"],G2={class:"filter-value"},H2={class:"filter-actions"},J2={key:0,class:"filter-presets"},q2={class:"preset-list"},K2=["data-testid","aria-label","onClick"],Q2=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,h)=>(m[h.type]=h.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,h){switch(m){case"brightness":case"contrast":case"saturation":case"sepia":case"grayscale":return`${h}%`;case"hue":return`${h}°`;case"blur":case"sharpen":return h.toFixed(1);default:return h.toString()}}function l(m){return["brightness","contrast","saturation","hue","blur","sharpen","sepia","grayscale"].includes(m)}function c(m){if(!l(m))return;const h={id:`filter-${m}`,filterId:m,params:{value:r[m]},intensity:1};t("filter-change",h)}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 h={id:`custom-${Date.now()}`,name:m,values:{...r}};i.value.push(h)}function p(m){Object.entries(m.values).forEach(([h,v])=>{r[h]=v,c(h)})}return(m,h)=>(e.openBlock(),e.createElementBlock("div",W2,[h[3]||(h[3]=e.createElementVNode("h3",null,"Video Filters",-1)),e.createElementVNode("div",j2,[(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,X2),e.createElementVNode("div",Z2,[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,Y2),[[e.vModelText,r[v.type],void 0,{number:!0}]]),e.createElementVNode("span",G2,e.toDisplayString(s(v.type,r[v.type])),1)])])),64))]),e.createElementVNode("div",H2,[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(I.IonIcon),{icon:e.unref(ko)},null,8,["icon"]),h[0]||(h[0]=e.createTextVNode(" Reset All Filters ",-1))]),e.createElementVNode("button",{class:"save-preset-btn","data-testid":"btn-save-preset","aria-label":"Save current filter settings as preset",onClick:u},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ml)},null,8,["icon"]),h[1]||(h[1]=e.createTextVNode(" Save as Preset ",-1))])]),i.value.length>0?(e.openBlock(),e.createElementBlock("div",J2,[h[2]||(h[2]=e.createElementVNode("h4",null,"Presets",-1)),e.createElementVNode("div",q2,[(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,K2))),128))])])):e.createCommentVNode("",!0)]))}}),ek=_e(Q2,[["__scopeId","data-v-5ad2ac63"]]),tk={class:"video-text-panel"},nk={class:"text-input-group"},ok={class:"text-options"},ak={class:"option-row"},rk={class:"option-row"},ik={class:"option-row"},sk={class:"option-row"},lk={class:"checkbox-label"},ck={class:"option-row"},dk={class:"text-overlay-list"},uk={key:0,class:"empty-state"},mk=["data-testid"],pk={class:"overlay-preview"},fk={class:"overlay-controls"},hk=["data-testid","aria-label","onClick"],vk=["data-testid","aria-label","onClick"],gk=["data-testid","aria-label","onClick"],yk=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",tk,[u[17]||(u[17]=e.createElementVNode("h3",null,"Text Overlays",-1)),e.createElementVNode("div",nk,[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(I.IonIcon),{icon:e.unref(Xr)},null,8,["icon"]),u[7]||(u[7]=e.createTextVNode(" Add ",-1))])]),e.createElementVNode("div",ok,[e.createElementVNode("div",ak,[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",rk,[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",ik,[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",sk,[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",lk,[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",ck,[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",dk,[u[16]||(u[16]=e.createElementVNode("h4",null,"Active Overlays",-1)),a.value.length===0?(e.openBlock(),e.createElementBlock("div",uk," 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",pk,[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",fk,[e.createElementVNode("button",{class:"edit-btn","data-testid":`btn-edit-${m}`,"aria-label":`Edit overlay: ${p.text}`,onClick:h=>l(p)},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(nm)},null,8,["icon"])],8,hk),e.createElementVNode("button",{class:"duplicate-btn","data-testid":`btn-duplicate-${m}`,"aria-label":`Duplicate overlay: ${p.text}`,onClick:h=>c(p)},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(tm)},null,8,["icon"])],8,vk),e.createElementVNode("button",{class:"remove-btn","data-testid":`btn-remove-${m}`,"aria-label":`Remove overlay: ${p.text}`,onClick:h=>s(p.id)},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Cm)},null,8,["icon"])],8,gk)])],8,mk))),128))])]))}}),bk=_e(yk,[["__scopeId","data-v-4d240e1e"]]),wk={class:"video-tools-panel"},kk={class:"tool-tabs"},xk=["data-testid","aria-label","aria-selected","onClick"],Ek={class:"tool-content"},Sk={key:0,class:"trim-panel",role:"tabpanel","aria-label":"Trim controls"},Vk={class:"trim-actions"},Ck={key:3,class:"transitions-panel",role:"tabpanel","aria-label":"Transition controls"},Nk={class:"transition-types"},_k=["data-testid","aria-label","onClick"],Tk={class:"transition-preview"},Mk=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:Nl},{id:"filters",name:"Filters",icon:an},{id:"text",name:"Text",icon:Fl},{id:"transitions",name:"Transitions",icon:bs}],t=[{id:"fade",name:"Fade",icon:cr},{id:"slide-left",name:"Slide Left",icon:Gu},{id:"slide-right",name:"Slide Right",icon:Hu},{id:"dissolve",name:"Dissolve",icon:cr},{id:"wipe",name:"Wipe",icon:bs},{id:"zoom",name:"Zoom",icon:cr}];return(a,r)=>(e.openBlock(),e.createElementBlock("div",wk,[e.createElementVNode("div",kk,[(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(I.IonIcon),{icon:i.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(i.name),1)],10,xk)),64))]),e.createElementVNode("div",Ek,[a.activeTool==="trim"?(e.openBlock(),e.createElementBlock("div",Sk,[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",Vk,[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(I.IonIcon),{icon:e.unref(gs)},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(I.IonIcon),{icon:e.unref(gs)},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(I.IonIcon),{icon:e.unref(go)},null,8,["icon"]),r[7]||(r[7]=e.createTextVNode(" Clear ",-1))])])])):e.createCommentVNode("",!0),a.activeTool==="filters"?(e.openBlock(),e.createBlock(ek,{key:1,onFilterChange:r[3]||(r[3]=i=>a.$emit("filter-change",i))})):e.createCommentVNode("",!0),a.activeTool==="text"?(e.openBlock(),e.createBlock(bk,{key:2,onTextAdd:r[4]||(r[4]=i=>a.$emit("text-add",i))})):e.createCommentVNode("",!0),a.activeTool==="transitions"?(e.openBlock(),e.createElementBlock("div",Ck,[r[10]||(r[10]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",Nk,[(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",Tk,[e.createVNode(e.unref(I.IonIcon),{icon:i.icon},null,8,["icon"])]),e.createElementVNode("span",null,e.toDisplayString(i.name),1)],8,_k)),64))])])):e.createCommentVNode("",!0)])]))}}),Fk=_e(Mk,[["__scopeId","data-v-fc135306"]]),Bk={class:"video-export-panel"},Ik={class:"export-presets"},Rk=["value"],Pk={key:0,class:"preset-details"},$k={class:"detail-row"},zk={class:"detail-row"},Ak={class:"detail-row"},Dk={class:"advanced-options"},Uk={class:"options-content"},Ok={class:"option-group"},Lk={class:"option-group"},Wk={class:"option-group"},jk=["disabled"],Xk={key:1,class:"export-progress"},Zk={class:"progress-message"},Yk={class:"progress-bar"},Gk=["aria-valuenow"],Hk={class:"progress-percentage"},Jk=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",Bk,[u[14]||(u[14]=e.createElementVNode("h3",null,"Export Video",-1)),e.createElementVNode("div",Ik,[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,Rk))),128))],512),[[e.vModelSelect,r.value]])]),s.value?(e.openBlock(),e.createElementBlock("div",Pk,[e.createElementVNode("div",$k,[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",zk,[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",Ak,[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",Dk,[u[12]||(u[12]=e.createElementVNode("summary",null,"Advanced Options",-1)),e.createElementVNode("div",Uk,[e.createElementVNode("div",Ok,[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",Lk,[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",Wk,[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(I.IonSpinner),{key:0,name:"crescent"})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ea)},null,8,["icon"]),u[13]||(u[13]=e.createTextVNode(" Export Video ",-1))],64))],8,jk),d.isExporting?(e.openBlock(),e.createElementBlock("div",Xk,[e.createElementVNode("div",Zk,e.toDisplayString(l.value),1),e.createElementVNode("div",Yk,[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,Gk)]),e.createElementVNode("div",Hk,e.toDisplayString(d.exportProgress)+"% ",1)])):e.createCommentVNode("",!0)]))}}),qk=_e(Jk,[["__scopeId","data-v-5caf8fe6"]]),Kk=["data-testid"],Qk={class:"progress-header"},ex={class:"file-info"},tx={class:"file-details"},nx={class:"file-name"},ox={class:"file-meta"},ax={class:"file-size"},rx={key:0,class:"separator"},ix={key:1,class:"upload-speed"},sx={key:2,class:"separator"},lx={key:3,class:"time-remaining"},cx={class:"progress-actions"},dx={key:0,class:"status-icon completed","data-testid":"video-upload-status-completed"},ux={key:1,class:"status-icon error","data-testid":"video-upload-status-error"},mx={key:2,class:"status-icon processing","data-testid":"video-upload-status-processing",role:"status","aria-label":"Processing video"},px=["aria-valuenow","aria-label"],fx={class:"progress-bar"},hx={class:"progress-percent"},vx={key:1,class:"error-message","data-testid":"video-upload-error"},gx={key:2,class:"thumbnail-preview","data-testid":"video-upload-thumbnail"},yx=["src","alt"],bx={key:0,class:"video-duration"},wx=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(()=>Bl),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 h=Math.floor(m/60);return h<60?`${h}m ${Math.round(m%60)}s`:`${Math.floor(h/60)}h ${h%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 h=["B","KB","MB","GB","TB"],v=1024,b=Math.floor(Math.log(m)/Math.log(v));return`${(m/Math.pow(v,b)).toFixed(1)} ${h[b]}`}function u(m){if(m===0)return"0 B/s";const h=["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)} ${h[b]}`}function p(m){const h=Math.floor(m/3600),v=Math.floor(m%3600/60),b=Math.floor(m%60);return h>0?`${h}:${v.toString().padStart(2,"0")}:${b.toString().padStart(2,"0")}`:`${v}:${b.toString().padStart(2,"0")}`}return(m,h)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["upload-progress-item",t.value]),"data-testid":`video-upload-progress-${m.upload.id}`},[e.createElementVNode("div",Qk,[e.createElementVNode("div",ex,[e.createVNode(e.unref(I.IonIcon),{icon:a.value,class:"file-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("div",tx,[e.createElementVNode("h4",nx,e.toDisplayString(m.upload.filename),1),e.createElementVNode("p",ox,[e.createElementVNode("span",ax,e.toDisplayString(d(m.upload.bytesTotal||0)),1),m.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",rx,"•")):e.createCommentVNode("",!0),m.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",ix,e.toDisplayString(u(m.upload.uploadSpeed||0)),1)):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",sx,"•")):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",lx,e.toDisplayString(s.value)+" remaining ",1)):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",cx,[m.upload.status==="completed"?(e.openBlock(),e.createElementBlock("div",dx,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Vl)},null,8,["icon"])])):m.upload.status==="error"?(e.openBlock(),e.createElementBlock("div",ux,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Yu),"aria-hidden":"true"},null,8,["icon"])])):m.upload.status==="processing"?(e.openBlock(),e.createElementBlock("div",mx,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),m.upload.status==="uploading"?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:3,fill:"clear",size:"small",onClick:h[0]||(h[0]=v=>m.$emit("cancel")),"data-testid":"btn-cancel-video-upload","aria-label":"Cancel upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(go),slot:"icon-only"},null,8,["icon"])]),_:1})):m.upload.status==="error"?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:4,fill:"clear",size:"small",onClick:h[1]||(h[1]=v=>m.$emit("retry")),"data-testid":"btn-retry-video-upload","aria-label":"Retry upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ko),slot:"icon-only"},null,8,["icon"])]),_:1})):m.upload.status==="completed"?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:5,fill:"clear",size:"small",onClick:h[2]||(h[2]=v=>m.$emit("remove")),"data-testid":"btn-remove-video-upload","aria-label":"Remove from list"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(go),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",fx,[e.createElementVNode("div",{class:e.normalizeClass(["progress-fill",{indeterminate:m.upload.status==="processing"}]),style:e.normalizeStyle({width:i.value+"%"})},null,6)]),e.createElementVNode("span",hx,e.toDisplayString(Math.round(i.value))+"%",1)],8,px)):e.createCommentVNode("",!0),m.upload.error?(e.openBlock(),e.createElementBlock("div",vx,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Im)},null,8,["icon"]),e.createElementVNode("span",null,e.toDisplayString(m.upload.error),1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",gx,[e.createElementVNode("img",{src:l.value,alt:m.upload.filename},null,8,yx),c.value?(e.openBlock(),e.createElementBlock("div",bx,e.toDisplayString(p(c.value)),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],10,Kk))}}),kx=_e(wx,[["__scopeId","data-v-9eacbf91"]]),wr=4,xx=500,Ex=new Set([408,425,429,500,502,503,504,520,521,522,523,524,525]);function Za(n){return typeof n=="object"&&n!==null}function ll(n){return Za(n)?typeof n.upload_url=="string"&&typeof n.upload_id=="string"&&typeof n.media_uuid=="string"&&typeof n.expires_at=="string":!1}function Sx(n){if(ll(n))return n;if(Za(n)&&ll(n.data))return n.data;throw new Error("Invalid upload response from backend")}function cl(n){return Za(n)?typeof n.uuid=="string"&&typeof n.processing_status=="string":!1}function Vx(n){if(cl(n))return n;if(Za(n)&&cl(n.data))return n.data;throw new Error("Invalid media response from backend")}function Yo(n){return n?{...n}:{}}function dl(n,o="PUT"){return typeof n.method=="string"&&n.method.trim()!==""?n.method.trim().toUpperCase():o}function Cx(n){return n.resumable===!0?!0:/tusupload/i.test(n.upload_url)}function Nx(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 _x(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} ${Nx(r)}`).join(",")}function Go(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 Tx(n,o){return n instanceof Error?n:new Error(o)}function Mx(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 ul(n){const o=Math.max(0,n-1),t=xx*Math.pow(2,o);return Math.min(5e3,t)}function ml(n){return new Promise(o=>{window.setTimeout(o,n)})}async function pl(n,o){for(let t=1;t<=wr;t+=1)try{const a=await o();if(a.ok||!Ex.has(a.status)||t>=wr)return a;await ml(ul(t))}catch(a){if(!Mx(a)||t>=wr)throw a;await ml(ul(t))}throw new Error(`${n} failed after retry attempts`)}function Fx(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 k=Array.from(o.value.values());return k.length===0?0:k.reduce((F,A)=>F+A.progress,0)/k.length});function d(k){a.value=k}function u(){}async function p(k){var F;const T=k.filter(A=>m(A));if(T.length!==0&&((F=n.onFilesSelected)==null||F.call(n,T),n.autoUpload!==!1))for(const A of T)await h(A)}function m(k){return!(n.maxFileSize&&k.size>n.maxFileSize||n.allowedFormats&&n.allowedFormats.length>0&&!n.allowedFormats.includes(k.type))}async function h(k){var A,P,O;const T=D(k);if(o.value.has(T)){const B=o.value.get(T);if((B==null?void 0:B.status)==="uploading")return}const F={id:T,file:k,filename:k.name,progress:0,status:"pending",startedAt:new Date,bytesTotal:k.size,bytesUploaded:0};o.value.set(F.id,F),t.value.add(F.id);try{F.status="uploading",(A=n.onUploadStart)==null||A.call(n,F);const B=await v(k);n.resumable===!0||B.resumable===!0?await x(F,B):await b(F,B),F.status="processing",F.progress=100;const X=await w(B.media_uuid);F.status="completed",F.media=X,(P=n.onUploadComplete)==null||P.call(n,X)}catch(B){if(F.status!=="cancelled"){const _=Tx(B,"Upload failed");F.status="error",F.error=_.message,(O=n.onUploadError)==null||O.call(n,_,F)}}finally{t.value.delete(F.id),r.delete(F.id),i.delete(F.id)}}async function v(k){if(!a.value)throw new Error("API client not configured");const T={collection:n.collection||"videos",filename:k.name,size:k.size,mime_type:k.type,...n.ownerUuid!==void 0?{ownerUuid:n.ownerUuid}:{},...n.ownerType!==void 0?{ownerType:n.ownerType}:{}},F=await a.value.post("/api/v1/video/upload",T);return Sx(F)}async function b(k,T){const F=new XMLHttpRequest,A=dl(T),P=Yo(T.headers);return new Promise((O,B)=>{F.upload.addEventListener("progress",_=>{var X;_.lengthComputable&&(Go(k,_.loaded),(X=n.onUploadProgress)==null||X.call(n,k))}),F.addEventListener("load",()=>{r.delete(k.id),F.status>=200&&F.status<300?O():B(new Error(`Upload failed with status ${F.status}`))}),F.addEventListener("error",()=>{r.delete(k.id),B(new Error("Upload failed"))}),F.addEventListener("abort",()=>{r.delete(k.id),B(new Error("Upload cancelled"))}),F.open(A,T.upload_url),Object.entries(P).forEach(([_,X])=>{F.setRequestHeader(_,X)}),!Object.keys(P).some(_=>_.toLowerCase()==="content-type")&&k.file.type&&F.setRequestHeader("Content-Type",k.file.type),r.set(k.id,F),F.send(k.file)})}async function x(k,T){var B;if(Cx(T)){await R(k,T);return}const F=n.chunkSize||5*1024*1024,A=S(k.file,F),P=new AbortController;i.set(k.id,P);const O=await f(T.upload_id);O&&(A.forEach(_=>{_.end<=O.bytesUploaded&&(_.uploaded=!0)}),Go(k,O.bytesUploaded));for(const _ of A)_.uploaded||(await g(k,T,_,P),Go(k,_.end),(B=n.onUploadProgress)==null||B.call(n,k))}async function R(k,T){var W;const F=new AbortController;i.set(k.id,F);const A={...Yo(T.headers),"Tus-Resumable":"1.0.0","Upload-Length":String(k.file.size),"Upload-Metadata":_x(k,T)},P=await pl("Resumable upload initialization",()=>fetch(T.upload_url,{method:"POST",headers:A,signal:F.signal}));if(!P.ok)throw new Error(`Failed to initialize resumable upload: ${P.status}`);const O=P.headers.get("Location");if(!O)throw new Error("Resumable upload endpoint did not return upload location");const B=new URL(O,T.upload_url).toString(),_=n.chunkSize||5*1024*1024;let X=0;for(;X<k.file.size;){const ee=Math.min(X+_,k.file.size),he=k.file.slice(X,ee),Ue={...Yo(T.headers),"Tus-Resumable":"1.0.0","Upload-Offset":String(X),"Content-Type":"application/offset+octet-stream"},Te=await pl("Resumable chunk upload",()=>fetch(B,{method:"PATCH",headers:Ue,body:he,signal:F.signal}));if(Te.status===409){const M=Number(Te.headers.get("Upload-Offset")??"-1");if(Number.isFinite(M)&&M>=0){X=M;continue}}if(!Te.ok)throw new Error(`Resumable chunk upload failed: ${Te.status}`);const re=Number(Te.headers.get("Upload-Offset")??String(ee));X=Number.isFinite(re)&&re>X?re:ee,Go(k,X),(W=n.onUploadProgress)==null||W.call(n,k)}}function S(k,T){const F=[];let A=0,P=0;for(;A<k.size;){const O=Math.min(A+T,k.size);F.push({start:A,end:O,blob:k.slice(A,O),index:P,uploaded:!1}),A=O,P++}return F}async function g(k,T,F,A){const P={...Yo(T.headers),"Content-Range":`bytes ${F.start}-${F.end-1}/${k.file.size}`,"Content-Type":k.file.type||"application/octet-stream"},O=await fetch(T.upload_url,{method:dl(T),headers:P,body:F.blob,signal:A.signal});if(!O.ok)throw new Error(`Chunk upload failed: ${O.status}`);F.uploaded=!0}async function f(k){return null}async function w(k){if(!a.value)throw new Error("API client not configured");const T=60;let F=0;for(;F<T;){const A=await a.value.get(`/api/v1/video/${k}`),P=Vx(A),O=String(P.processing_status);if(O==="ready")return P;if(O==="failed"||O==="error")throw new Error("Video processing failed");await new Promise(B=>{window.setTimeout(B,5e3)}),F++}throw new Error("Video processing timeout")}function $(k){const T=o.value.get(k);if(!T)return;const F=r.get(k);F&&(F.abort(),r.delete(k));const A=i.get(k);A&&(A.abort(),i.delete(k)),T.status="cancelled",T.error="Upload cancelled",t.value.delete(k)}async function V(k){const T=o.value.get(k);T&&(T.status="pending",T.error="",T.progress=0,T.bytesUploaded=0,await h(T.file))}function y(k){o.value.delete(k),t.value.delete(k),r.delete(k),i.delete(k)}function C(){Array.from(o.value.entries()).forEach(([k,T])=>{T.status==="completed"&&o.value.delete(k)})}function D(k){return`${k.name}-${k.size}-${Date.now()}`}return{uploads:l,isUploading:s,totalProgress:c,openFilePicker:u,handleFileSelect:p,validateFile:m,startUpload:h,cancelUpload:$,retryUpload:V,removeUpload:y,clearCompleted:C,setApiClient:d}}const Bx=["accept","multiple"],Ix={key:0,class:"upload-trigger","data-testid":"video-uploader-trigger"},Rx=["onKeydown"],Px={key:1,class:"upload-list","data-testid":"video-upload-list"},$x={class:"drag-content"},zx=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}=Fx({collection:t.collection,...t.ownerUuid!==void 0?{ownerUuid:t.ownerUuid}:{},...t.ownerType!==void 0?{ownerType:t.ownerType}:{},maxFileSize:t.maxFileSize,...t.maxDuration!==void 0?{maxDuration:t.maxDuration}:{},allowedFormats:t.allowedFormats,autoUpload:t.autoUpload,resumable:t.resumable,onUploadStart:f=>a("upload-start",f),onUploadProgress:f=>a("upload-progress",f),onUploadComplete:f=>a("upload-complete",f),onUploadError:(f,w)=>a("upload-error",f,w),onFilesSelected:f=>a("files-selected",f)});t.apiClient&&m(t.apiClient);const h=e.computed(()=>t.allowedFormats.join(",")),v=e.computed(()=>t.multiple||s.value.length===0);function b(){r.value&&r.value.click()}function x(f){const w=f.target,$=Array.from(w.files||[]);$.length>0&&(c($),w.value="")}function R(f){var V;f.preventDefault(),i.value=!1;const $=Array.from(((V=f.dataTransfer)==null?void 0:V.files)||[]).filter(y=>y.type.startsWith("video/"));$.length>0&&c($)}function S(f){var w;f.preventDefault(),(w=f.dataTransfer)!=null&&w.types.includes("Files")&&(i.value=!0)}function g(f){f.target.closest(".video-uploader")||(i.value=!1)}return e.onMounted(()=>{document.addEventListener("dragover",S),document.addEventListener("dragleave",g),document.addEventListener("drop",f=>f.preventDefault())}),e.onUnmounted(()=>{document.removeEventListener("dragover",S),document.removeEventListener("dragleave",g),document.removeEventListener("drop",f=>f.preventDefault())}),(f,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:h.value,multiple:f.multiple,onChange:x,"data-testid":"video-uploader-input","aria-label":"Select video files to upload",hidden:""},null,40,Bx),!e.unref(l)||v.value?(e.openBlock(),e.createElementBlock("div",Ix,[e.renderSlot(f.$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(I.IonIcon),{icon:e.unref(Bl),class:"upload-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("h3",null,e.toDisplayString(f.label),1),e.createElementVNode("p",null,e.toDisplayString(f.description),1),e.createVNode(e.unref(I.IonButton),{size:"small","data-testid":"btn-select-video","aria-label":"Select video file"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Xr),slot:"start","aria-hidden":"true"},null,8,["icon"]),w[2]||(w[2]=e.createTextVNode(" Select Video ",-1))]),_:1})],40,Rx)],!0)])):e.createCommentVNode("",!0),e.unref(s).length>0?(e.openBlock(),e.createElementBlock("div",Px,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),$=>(e.openBlock(),e.createBlock(kx,{key:$.id,upload:$,onCancel:V=>e.unref(d)($.id),onRetry:V=>e.unref(u)($.id),onRemove:V=>e.unref(p)($.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:R,onDragover:w[0]||(w[0]=e.withModifiers(()=>{},["prevent"])),onDragleave:w[1]||(w[1]=$=>i.value=!1)},[e.createElementVNode("div",$x,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ea),"aria-hidden":"true"},null,8,["icon"]),w[3]||(w[3]=e.createElementVNode("p",null,"Drop video files here",-1))])],32)):e.createCommentVNode("",!0)],2))}}),Ax=_e(zx,[["__scopeId","data-v-ea7587f7"]]),Dx=["aria-valuenow","aria-valuemax","aria-label"],Ux={class:"progress-bar"},Ox={class:"time-display","data-testid":"video-time-display"},Lx={class:"current-time"},Wx={class:"duration"},jx={class:"control-buttons"},Xx={class:"controls-left"},Zx=["aria-label"],Yx={class:"controls-center"},Gx={key:0,class:"volume-controls"},Hx=["aria-label"],Jx=["value"],qx={class:"controls-right"},Kx={key:0,class:"quality-selector"},Qx=["aria-expanded"],eE={class:"quality-label"},tE={key:0,class:"quality-menu","data-testid":"video-quality-menu",role:"menu"},nE=["data-testid","aria-label","onClick"],oE=["aria-label"],aE=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=I.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 f=0;f<t.buffered.length;f++){const w=t.buffered.start(f),$=t.buffered.end(f);if(t.currentTime>=w&&t.currentTime<=$)return{width:`${$/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?Fm:t.volume<33?_m:t.volume<66?Tm:Nm);let h=null;function v(){r.value=!0,b()}function b(){h&&clearTimeout(h),t.playing&&!l&&(h=setTimeout(()=>{r.value=!1},3e3))}function x(f){if(!s.value||t.isLive)return;const w=s.value.getBoundingClientRect(),V=(f.clientX-w.left)/w.width*t.duration;a("seek",Math.max(0,Math.min(V,t.duration)))}function R(f){const w=f.target;a("setVolume",parseInt(w.value))}function S(f){a("selectQuality",f),i.value=!1}function g(f){if(!isFinite(f))return"0:00";const w=Math.floor(f/3600),$=Math.floor(f%3600/60),V=Math.floor(f%60);return w>0?`${w}:${$.toString().padStart(2,"0")}:${V.toString().padStart(2,"0")}`:`${$}:${V.toString().padStart(2,"0")}`}return e.onMounted(()=>{document.addEventListener("mousemove",v),b()}),e.onUnmounted(()=>{document.removeEventListener("mousemove",v),h&&clearTimeout(h)}),(f,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(f.currentTime),"aria-valuemin":"0","aria-valuemax":Math.round(f.duration),"aria-label":f.isLive?"Live stream":"Video progress",tabindex:"0",onClick:x},[e.createElementVNode("div",Ux,[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",Ox,[e.createElementVNode("span",Lx,e.toDisplayString(g(f.currentTime)),1),w[7]||(w[7]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",Wx,e.toDisplayString(f.isLive?"LIVE":g(f.duration)),1)])],8,Dx),e.createElementVNode("div",jx,[e.createElementVNode("div",Xx,[e.createElementVNode("button",{class:"control-btn play-pause","data-testid":"btn-video-play-pause",onClick:w[0]||(w[0]=$=>f.$emit("play-pause")),"aria-label":f.playing?"Pause":"Play"},[e.createVNode(e.unref(I.IonIcon),{icon:f.playing?e.unref(dm):e.unref(pm),"aria-hidden":"true"},null,8,["icon"])],8,Zx),f.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]=$=>f.$emit("skip-backward")),"aria-label":"Skip backward 10 seconds"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(fm),"aria-hidden":"true"},null,8,["icon"]),w[8]||(w[8]=e.createElementVNode("span",{class:"skip-label"},"10",-1))])),f.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn skip-forward","data-testid":"btn-video-skip-forward",onClick:w[2]||(w[2]=$=>f.$emit("skip-forward")),"aria-label":"Skip forward 10 seconds"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(gm),"aria-hidden":"true"},null,8,["icon"]),w[9]||(w[9]=e.createElementVNode("span",{class:"skip-label"},"10",-1))]))]),e.createElementVNode("div",Yx,[e.unref(l)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Gx,[e.createElementVNode("button",{class:"control-btn mute-btn","data-testid":"btn-video-mute",onClick:w[3]||(w[3]=$=>f.$emit("toggleMute")),"aria-label":f.muted?"Unmute":"Mute"},[e.createVNode(e.unref(I.IonIcon),{icon:m.value,"aria-hidden":"true"},null,8,["icon"])],8,Hx),e.createElementVNode("input",{type:"range",class:"volume-slider","data-testid":"slider-video-volume",min:"0",max:"100",value:f.muted?0:f.volume,onInput:R,"aria-label":"Volume"},null,40,Jx)]))]),e.createElementVNode("div",qx,[f.qualityLevels.length>1?(e.openBlock(),e.createElementBlock("div",Kx,[e.createElementVNode("button",{class:"control-btn quality-btn","data-testid":"btn-video-quality",onClick:w[4]||(w[4]=$=>i.value=!i.value),"aria-label":"Quality settings","aria-expanded":i.value},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Sm),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("span",eE,e.toDisplayString(f.currentQuality),1)],8,Qx),i.value?(e.openBlock(),e.createElementBlock("div",tE,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.qualityLevels,$=>(e.openBlock(),e.createElementBlock("button",{key:$.label,class:e.normalizeClass(["quality-option",{active:$.label===f.currentQuality}]),"data-testid":`btn-video-quality-${$.label}`,"aria-label":`Set quality to ${$.label}`,role:"menuitem",onClick:V=>S($)},e.toDisplayString($.label),11,nE))),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]=$=>f.$emit("togglePiP")),"aria-label":"Picture in Picture"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Vm),"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]=$=>f.$emit("toggleFullscreen")),"aria-label":f.fullscreen?"Exit fullscreen":"Enter fullscreen"},[e.createVNode(e.unref(I.IonIcon),{icon:f.fullscreen?e.unref(em):e.unref(om),"aria-hidden":"true"},null,8,["icon"])],8,oE)])])],2))}}),rE=_e(aE,[["__scopeId","data-v-2ae77c13"]]);function iE(n={}){var he,Ue,Te;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),h=e.ref("idle"),v=e.ref(n.playbackUrl||((he=n.media)==null?void 0:he.playback_url)||((Ue=n.media)==null?void 0:Ue.url)||""),b=e.ref(null),x=e.ref(n.isLive||!1),R=e.ref(null),S=e.ref(null);function g(re){S.value=re}if((Te=n.media)!=null&&Te.token_expires_at){const re=new Date(n.media.token_expires_at);b.value=Number.isNaN(re.getTime())?null:re}async function f(){var M;const re=x.value?t.value:o.value;if(re)try{await re.play(),a.value=!0,h.value=x.value?"live":"playing",(M=n.onPlay)==null||M.call(n)}catch{m.value="Failed to play video",h.value="error"}}function w(){var M;const re=x.value?t.value:o.value;re&&(re.pause(),a.value=!1,h.value="paused",(M=n.onPause)==null||M.call(n))}function $(){a.value?w():f()}function V(re){const M=x.value?t.value:o.value;if(!M||x.value)return;const j=Number.isFinite(M.duration)?M.duration:re;M.currentTime=Math.max(0,Math.min(re,j)),r.value=M.currentTime}function y(re=10){const M=o.value;!M||x.value||V(M.currentTime+re)}function C(re=10){const M=o.value;!M||x.value||V(M.currentTime-re)}function D(){const re=x.value?t.value:o.value;re&&(re.muted=!re.muted,l.value=re.muted)}function k(re){const M=x.value?t.value:o.value;if(!M)return;const j=Math.max(0,Math.min(100,re));M.volume=j/100,s.value=j,j>0&&M.muted&&(M.muted=!1,l.value=!1)}function T(re){const M=o.value;!M||x.value||(M.playbackRate=re,u.value=re)}async function F(){const re=document.querySelector(".video-player-container");if(re)try{document.fullscreenElement?(await document.exitFullscreen(),c.value=!1):(await re.requestFullscreen(),c.value=!0)}catch{}}async function A(){const re=x.value?t.value:o.value;if(re)try{document.pictureInPictureElement?await document.exitPictureInPicture():document.pictureInPictureEnabled&&await re.requestPictureInPicture()}catch{}}async function P(){var M;m.value=null,h.value="loading",(M=n.media)!=null&&M.provider&&n.media.provider!=="local"&&await O();const re=x.value?t.value:o.value;re&&(re.load(),await f())}async function O(){if(!(!S.value||!n.media))try{p.value=!0;const re=await S.value.get(`/api/v1/video/${n.media.uuid}/playback`);v.value=re.playback_url,b.value=new Date(re.token_expires_at);const M=x.value?t.value:o.value;if(M&&M.src!==v.value){const j=!M.paused,le=M.currentTime;M.src=v.value,x.value||(M.currentTime=le),j&&await f()}}catch{m.value="Failed to refresh playback token",h.value="error"}finally{p.value=!1}}async function B(re){if(t.value){if(t.value.canPlayType("application/vnd.apple.mpegurl")){t.value.src=re;return}try{t.value.src=re}catch{m.value="Live streaming not supported in this browser",h.value="error"}}}function _(){R.value&&(R.value.destroy(),R.value=null)}function X(){var M;const re=x.value?t.value:o.value;re&&(r.value=re.currentTime,i.value=re.duration,(M=n.onTimeUpdate)==null||M.call(n,re.currentTime))}const W=e.computed(()=>{if(!d.value||d.value.length===0||!i.value)return 0;for(let re=0;re<d.value.length;re++){const M=d.value.start(re),j=d.value.end(re);if(r.value>=M&&r.value<=j)return j/i.value*100}return 0});function ee(){if(!b.value)return!1;const re=new Date;return b.value.getTime()-re.getTime()<5*60*1e3}return e.watch([o,t],([re,M])=>{const j=x.value?M:re;j&&(j.addEventListener("timeupdate",X),j.addEventListener("loadedmetadata",()=>{i.value=j.duration,h.value="ready"}),j.addEventListener("progress",()=>{d.value=j.buffered}),j.addEventListener("ended",()=>{var le;a.value=!1,h.value="ended",(le=n.onEnded)==null||le.call(n)}),j.addEventListener("error",le=>{var ae;h.value="error",(ae=n.onError)==null||ae.call(n,"Video playback error")}),j.volume=s.value/100,j.muted=l.value)}),e.onUnmounted(()=>{_();const re=x.value?t.value:o.value;re&&re.removeEventListener("timeupdate",X)}),{videoEl:o,liveVideoEl:t,playing:a,currentTime:r,duration:i,volume:s,muted:l,isFullscreen:c,bufferedRanges:d,bufferedPercent:W,playbackRate:u,isLoading:p,error:m,status:h,currentPlaybackUrl:v,tokenExpiresAt:b,play:f,pause:w,togglePlayPause:$,seek:V,skipForward:y,skipBackward:C,toggleMute:D,setVolume:k,setPlaybackRate:T,toggleFullscreen:F,togglePiP:A,retry:P,refreshToken:O,setupLiveStream:B,setApiClient:g,shouldRefreshToken:ee}}const sE=["src","poster","controls","autoplay","muted","loop","preload"],lE={key:1,ref:"livePlayerEl",class:"live-player"},cE=["controls","muted"],dE={key:0,class:"live-indicator","data-testid":"video-live-indicator","aria-label":"Live stream"},uE={key:2,class:"video-loading","data-testid":"video-loading",role:"status","aria-label":"Loading video"},mE={key:3,class:"video-error","data-testid":"video-error",role:"alert"},pE={key:5,class:"gesture-zones","data-testid":"video-gesture-zones"},fE=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:h,error:v,status:b,currentPlaybackUrl:x,tokenExpiresAt:R,play:S,pause:g,seek:f,toggleMute:w,setVolume:$,toggleFullscreen:V,togglePlayPause:y,skipForward:C,skipBackward:D,retry:k,refreshToken:T,setApiClient:F,shouldRefreshToken:A,setupLiveStream:P}=iE({...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 O(){await T()}const B=e.computed(()=>{const ae=["video-player-container"];return t.className&&ae.push(t.className),p.value&&ae.push("fullscreen"),t.isLive&&ae.push("is-live"),s.value&&ae.push("is-playing"),h.value&&ae.push("is-loading"),ae}),_=e.computed(()=>{var ae,H;if(t.poster)return t.poster;if((ae=t.media)!=null&&ae.poster_url)return t.media.poster_url;if((H=t.media)!=null&&H.thumbnail_url)return t.media.thumbnail_url});function X(ae){const H=ae.target;a("loadedmetadata",{duration:H.duration,width:H.videoWidth,height:H.videoHeight})}function W(ae){const H=ae.target;l.value=H.currentTime,a("timeupdate",H.currentTime)}function ee(){s.value=!0,a("play")}function he(){s.value=!1,a("pause")}function Ue(){s.value=!1,a("ended")}function Te(ae){const H=ae.target;let K="Failed to load video";if(H.error)switch(H.error.code){case H.error.MEDIA_ERR_ABORTED:K="Video playback aborted";break;case H.error.MEDIA_ERR_NETWORK:K="Network error while loading video";break;case H.error.MEDIA_ERR_DECODE:K="Video decoding error";break;case H.error.MEDIA_ERR_SRC_NOT_SUPPORTED:K="Video format not supported";break}v.value=K,a("error",K)}function re(ae){const H=ae.target;m.value=H.buffered,a("progress",H.buffered)}function M(){h.value=!0}function j(){h.value=!1}e.watch(()=>t.apiClient,ae=>{ae&&F(ae)},{immediate:!0}),e.watch(()=>t.playbackUrl,ae=>{typeof ae=="string"&&ae.length>0&&(x.value=ae)},{immediate:!0}),e.watch(()=>{var ae;return(ae=t.media)==null?void 0:ae.token_expires_at},ae=>{if(!ae){R.value=null;return}const H=new Date(ae);R.value=Number.isNaN(H.getTime())?null:H},{immediate:!0}),e.watch(()=>{var ae;return(ae=t.media)==null?void 0:ae.playback_url},async(ae,H)=>{if(t.playbackUrl||!ae||ae===H)return;const K=r.value;if(!K||t.isLive){x.value=ae;return}const ce=!K.paused,ve=K.currentTime;x.value=ae,await e.nextTick();try{K.currentTime=ve}catch{}ce&&await S()},{immediate:!0});let le=null;return e.watch(()=>t.isLive,async ae=>{var K;if(!ae)return;const H=t.playbackUrl||((K=t.media)==null?void 0:K.playback_url)||"";H&&await P(H)},{immediate:!0}),e.onMounted(()=>{var ae;(ae=t.media)!=null&&ae.provider&&t.media.provider!=="local"&&(le=setInterval(()=>{A()&&O()},3e4)),I.isPlatform("mobile")&&t.showCustomControls}),e.onUnmounted(()=>{le&&clearInterval(le)}),(ae,H)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-player-container",B.value]),"data-testid":"video-player"},[ae.isLive?(e.openBlock(),e.createElementBlock("div",lE,[e.createElementVNode("video",{ref_key:"liveVideoEl",ref:i,controls:ae.controls&&!ae.showCustomControls,autoplay:!0,muted:e.unref(u),onPlay:ee,onPause:he,onError:Te,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,cE),e.unref(b)==="live"?(e.openBlock(),e.createElementBlock("div",dE,[...H[3]||(H[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(x),poster:_.value,controls:ae.controls&&!ae.showCustomControls,autoplay:ae.autoplay,muted:e.unref(u),loop:ae.loop,preload:ae.preload,onLoadedmetadata:X,onTimeupdate:W,onPlay:ee,onPause:he,onEnded:Ue,onError:Te,onProgress:re,onWaiting:M,onCanplay:j,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,sE)),e.unref(h)?(e.openBlock(),e.createElementBlock("div",uE,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),e.unref(v)?(e.openBlock(),e.createElementBlock("div",mE,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Zr),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(e.unref(v)),1),e.createVNode(e.unref(I.IonButton),{size:"small",onClick:e.unref(k),"data-testid":"btn-video-retry","aria-label":"Retry loading video"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ko),slot:"start","aria-hidden":"true"},null,8,["icon"]),H[4]||(H[4]=e.createTextVNode(" Retry ",-1))]),_:1},8,["onClick"])])):e.createCommentVNode("",!0),ae.showCustomControls&&!e.unref(v)?(e.openBlock(),e.createBlock(rE,{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:ae.isLive,onPlay:e.unref(S),onPause:e.unref(g),onSeek:e.unref(f),onToggleMute:e.unref(w),onSetVolume:e.unref($),onToggleFullscreen:e.unref(V),class:"custom-controls"},null,8,["playing","currentTime","duration","buffered","volume","muted","fullscreen","isLive","onPlay","onPause","onSeek","onToggleMute","onSetVolume","onToggleFullscreen"])):e.createCommentVNode("",!0),ae.enableGestures&&!e.unref(v)?(e.openBlock(),e.createElementBlock("div",pE,[e.createElementVNode("div",{class:"gesture-left","data-testid":"video-gesture-skip-back","aria-label":"Double tap to skip backward",onDblclick:H[0]||(H[0]=(...K)=>e.unref(D)&&e.unref(D)(...K))},null,32),e.createElementVNode("div",{class:"gesture-center","data-testid":"video-gesture-play-pause","aria-label":"Tap to play or pause",onClick:H[1]||(H[1]=(...K)=>e.unref(y)&&e.unref(y)(...K))}),e.createElementVNode("div",{class:"gesture-right","data-testid":"video-gesture-skip-forward","aria-label":"Double tap to skip forward",onDblclick:H[2]||(H[2]=(...K)=>e.unref(C)&&e.unref(C)(...K))},null,32)])):e.createCommentVNode("",!0)],2))}}),Dc=_e(fE,[["__scopeId","data-v-b8db4951"]]),hE=xa.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,O){const B=n.value.get(P);B&&n.value.set(P,{...B,...O})}function p(P){n.value.delete(P)}function m(P){return n.value.get(P)}function h(P){o.value.set(P.id,P)}function v(P,O){const B=o.value.get(P);B&&o.value.set(P,{...B,...O})}function b(P,O){const B=o.value.get(P);B&&o.value.set(P,{...B,status:O.status,viewer_count:O.viewer_count,peak_viewers:O.peak_viewers})}function x(P){o.value.delete(P)}function R(P){return o.value.get(P)}function S(P){return s.value.find(O=>O.media_uuid===P)}function g(P){t.value.set(P.id,P)}function f(P,O){const B=t.value.get(P);B&&t.value.set(P,{...B,...O})}function w(P){t.value.delete(P)}function $(P){return t.value.get(P)}function V(P){return Array.from(t.value.values()).filter(O=>O.media_uuid===P)}function y(P){a.value=P}function C(P){a.value&&(a.value={...a.value,...P})}function D(){a.value=null}function k(P){r.value=P}function T(){n.value.clear(),o.value.clear(),t.value.clear(),a.value=null,r.value=!1}function F(P){n.value.clear(),P.forEach(O=>{n.value.set(O.uuid,O)})}function A(P){o.value.clear(),P.forEach(O=>{o.value.set(O.id,O)})}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:h,updateLiveStream:v,updateLiveStreamStats:b,removeLiveStream:x,getLiveStream:R,getLiveStreamByMedia:S,addExportJob:g,updateExportJob:f,removeExportJob:w,getExportJob:$,getExportJobsByMedia:V,setEditorState:y,updateEditorState:C,clearEditorState:D,setProcessing:k,clearAll:T,loadVideos:F,loadLiveStreams:A}});let fn=null;function vE(n){fn=n}const Ho={post:async(n,o)=>{if(!fn)throw new Error("HTTP client not configured");return await fn(`/api/v1/video${n}`,{method:"POST",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}})},get:async n=>{if(!fn)throw new Error("HTTP client not configured");return await fn(`/api/v1/video${n}`)},delete:async n=>{if(!fn)throw new Error("HTTP client not configured");return await fn(`/api/v1/video${n}`,{method:"DELETE"})}};function Jo(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 kr(n,o){return n instanceof Error&&n.message?n.message:o}function gE(n){const o=hE(),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 h=e.computed(()=>d.value?Math.floor((new Date().getTime()-d.value.getTime())/1e3):0),v=e.computed(()=>{var D;if(!((D=t.value)!=null&&D.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"}),x=e.computed(()=>{var C;return((C=t.value)==null?void 0:C.status)==="idle"}),R=e.computed(()=>{var C;return((C=t.value)==null?void 0:C.status)==="ended"});async function S(C={}){s.value=!0,c.value=null;try{const D=await Ho.post("/live",{title:i.value||C.title||"Live Stream",low_latency:C.low_latency??a.value,auto_record:C.auto_record??r.value,...C}),k=Jo(D);return t.value=k,o.setLiveStream(k),$(),k}catch(D){throw c.value=kr(D,"Failed to create stream"),D instanceof Error?D:new Error(c.value)}finally{s.value=!1}}async function g(){if(!t.value)throw new Error("No active stream");l.value=!0,c.value=null;try{const C=await Ho.post(`/live/${t.value.id}/end`),D=Jo(C,t.value);return t.value=D,o.setLiveStream(D),V(),D}catch(C){throw c.value=kr(C,"Failed to end stream"),C instanceof Error?C:new Error(c.value)}finally{l.value=!1}}async function f(){if(t.value)try{const C=await Ho.get(`/live/${t.value.id}`),D=Jo(C,t.value);u.value=D.viewer_count,p.value=D.peak_viewers,t.value=D;const k={status:D.status,viewer_count:D.viewer_count,peak_viewers:D.peak_viewers};D.started_at&&(k.started_at=D.started_at),D.ended_at&&(k.ended_at=D.ended_at),o.updateLiveStreamStats(D.id,k),D.status==="live"&&!d.value&&D.started_at&&(d.value=new Date(D.started_at)),D.status==="ended"&&V()}catch{}}async function w(C){try{const D=await Ho.get(`/live/${C}`),k=Jo(D,t.value);return{rtmp_url:k.rtmp_url,stream_key:k.stream_key,playback_url:k.playback_url||""}}catch(D){throw c.value=kr(D,"Failed to get stream credentials"),D instanceof Error?D:new Error(c.value)}}function $(C=5e3){V(),m=window.setInterval(()=>{f()},C)}function V(){m!==void 0&&(clearInterval(m),m=void 0)}async function y(){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"&&($(),C.started_at&&(d.value=new Date(C.started_at))))}return n&&y(),e.onUnmounted(()=>{V()}),{stream:t,lowLatency:a,autoRecord:r,streamTitle:i,isCreating:s,isEnding:l,error:c,streamDuration:h,viewerCount:u,peakViewers:p,playbackUrl:v,isLive:b,isIdle:x,hasEnded:R,createStream:S,endStream:g,refreshStreamStatus:f,getStreamCredentials:w,startStatusPolling:$,stopStatusPolling:V}}const yE={class:"stream-status"},bE={class:"flex items-center justify-between"},wE={class:"flex items-center gap-3"},kE={key:0,class:"flex items-center"},xE={key:2,class:"text-sm text-gray-600"},EE={key:0,class:"flex items-center gap-2"},SE={class:"text-sm font-medium text-gray-700"},VE={key:0,class:"text-xs text-gray-500"},CE=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",yE,[e.createElementVNode("div",bE,[e.createElementVNode("div",wE,[i.status==="live"?(e.openBlock(),e.createElementBlock("div",kE,[...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",xE,e.toDisplayString(r.value),1)):e.createCommentVNode("",!0)]),i.viewers!==void 0?(e.openBlock(),e.createElementBlock("div",EE,[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",SE,e.toDisplayString(i.viewers)+" "+e.toDisplayString(i.viewers===1?"viewer":"viewers"),1),i.peakViewers>i.viewers?(e.openBlock(),e.createElementBlock("span",VE," (Peak: "+e.toDisplayString(i.peakViewers)+") ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])]))}}),NE=_e(CE,[["__scopeId","data-v-1d09c19f"]]),_E={class:"stream-credentials"},TE={class:"space-y-3"},ME={class:"credential-field"},FE={class:"flex gap-2"},BE=["value"],IE={class:"credential-field"},RE={class:"flex gap-2"},PE=["value","type"],$E=["aria-label"],zE={key:0,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},AE={key:1,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},DE={key:0,class:"mt-2 text-sm text-green-600"},UE=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",_E,[u[8]||(u[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Stream Settings",-1)),e.createElementVNode("div",TE,[e.createElementVNode("div",ME,[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",FE,[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,BE),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",IE,[u[7]||(u[7]=e.createElementVNode("label",{class:"block text-xs font-medium text-gray-500 mb-1"},"Stream Key",-1)),e.createElementVNode("div",RE,[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,PE),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",AE,[...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",zE,[...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,$E),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",DE,e.toDisplayString(i.value)+" copied to clipboard! ",1)):e.createCommentVNode("",!0)]),_:1})]))}}),OE=_e(UE,[["__scopeId","data-v-306d92f6"]]),LE={class:"live-stream-manager","data-testid":"live-stream-manager"},WE={key:0,class:"stream-setup"},jE={class:"space-y-4"},XE={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},ZE={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},YE=["disabled"],GE={key:0},HE={key:1,class:"flex items-center justify-center"},JE={key:1,class:"stream-active space-y-6"},qE={key:1,class:"video-preview"},KE={key:2,class:"analytics-panel"},QE={class:"grid grid-cols-2 gap-4"},eS={class:"bg-gray-50 p-3 rounded"},tS={class:"text-2xl font-bold text-gray-900"},nS={class:"bg-gray-50 p-3 rounded"},oS={class:"text-2xl font-bold text-gray-900"},aS={class:"stream-controls flex gap-3"},rS=["disabled"],iS={key:0},sS={key:1},lS={key:2,class:"mt-4 p-4 bg-red-50 border border-red-200 rounded-lg"},cS={class:"text-red-600 text-sm"},dS=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&&vE(t.httpClient);const{stream:r,lowLatency:i,autoRecord:s,streamTitle:l,isCreating:c,isEnding:d,error:u,createStream:p,endStream:m,streamDuration:h,playbackUrl:v,refreshStreamStatus:b}=gE(t.mediaUuid),x=e.ref(!1);async function R(){var $;try{const V=await p({title:l.value,low_latency:i.value,auto_record:s.value});a("stream-created",V),($=t.onStreamCreated)==null||$.call(t,V)}catch(V){a("error",V)}}async function S(){var $;try{const V=await m();a("stream-ended",V),($=t.onStreamEnded)==null||$.call(t,V)}catch(V){a("error",V)}}function g(){r.value=null,l.value="",x.value=!1,u.value=null}async function f($,V){try{await navigator.clipboard.writeText($)}catch{}}let w;return e.onMounted(()=>{var $;(($=r.value)==null?void 0:$.status)==="live"&&(w=window.setInterval(()=>{b()},5e3))}),e.onUnmounted(()=>{w&&clearInterval(w)}),($,V)=>(e.openBlock(),e.createElementBlock("div",LE,[e.unref(r)?(e.openBlock(),e.createElementBlock("div",JE,[e.createVNode(NE,{status:e.unref(r).status,viewers:e.unref(r).viewer_count,duration:e.unref(h),"peak-viewers":e.unref(r).peak_viewers},null,8,["status","viewers","duration","peak-viewers"]),e.unref(r).status==="idle"?(e.openBlock(),e.createBlock(OE,{key:0,"rtmp-url":e.unref(r).rtmp_url,"stream-key":e.unref(r).stream_key,onCopy:f},null,8,["rtmp-url","stream-key"])):e.createCommentVNode("",!0),e.unref(v)?(e.openBlock(),e.createElementBlock("div",qE,[V[9]||(V[9]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-2"},"Live Preview",-1)),e.createVNode(Dc,{"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",KE,[V[12]||(V[12]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Live Analytics",-1)),e.createElementVNode("div",QE,[e.createElementVNode("div",eS,[e.createElementVNode("div",tS,e.toDisplayString(e.unref(r).viewer_count),1),V[10]||(V[10]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Current Viewers",-1))]),e.createElementVNode("div",nS,[e.createElementVNode("div",oS,e.toDisplayString(e.unref(r).peak_viewers),1),V[11]||(V[11]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Peak Viewers",-1))])])])):e.createCommentVNode("",!0),e.createElementVNode("div",aS,[e.unref(r).status==="idle"?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:V[3]||(V[3]=y=>x.value=!x.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(x.value?"Hide":"Show")+" Credentials ",1)):e.createCommentVNode("",!0),e.unref(r).status==="live"?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:S,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",sS,"Ending...")):(e.openBlock(),e.createElementBlock("span",iS,"End Stream"))],8,rS)):e.createCommentVNode("",!0),e.unref(r).status==="ended"?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:g,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",WE,[V[8]||(V[8]=e.createElementVNode("h3",{class:"text-lg font-semibold mb-4"},"Start Live Stream",-1)),e.createElementVNode("div",jE,[e.createElementVNode("div",XE,[V[4]||(V[4]=e.createElementVNode("div",{class:"flex-1"},[e.createElementVNode("label",{class:"font-medium text-gray-900"},"Low Latency Mode"),e.createElementVNode("p",{class:"text-sm text-gray-500 mt-1"}," 5-7 second delay (vs 15-20s standard) ")],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":V[0]||(V[0]=y=>e.isRef(i)?i.value=y: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",ZE,[V[5]||(V[5]=e.createElementVNode("div",{class:"flex-1"},[e.createElementVNode("label",{class:"font-medium text-gray-900"},"Auto-Record Stream"),e.createElementVNode("p",{class:"text-sm text-gray-500 mt-1"}," Save stream as VOD for later viewing ")],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":V[1]||(V[1]=y=>e.isRef(s)?s.value=y:null),type:"checkbox",class:"h-5 w-5 text-blue-600 rounded focus:ring-blue-500","aria-label":"Enable auto-recording"},null,512),[[e.vModelCheckbox,e.unref(s)]])]),e.createElementVNode("div",null,[V[6]||(V[6]=e.createElementVNode("label",{for:"stream-title",class:"block text-sm font-medium text-gray-700 mb-2"}," Stream Title (optional) ",-1)),e.withDirectives(e.createElementVNode("input",{id:"stream-title","onUpdate:modelValue":V[2]||(V[2]=y=>e.isRef(l)?l.value=y: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:R,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",HE,[...V[7]||(V[7]=[e.createElementVNode("svg",{class:"animate-spin h-5 w-5 mr-2",viewBox:"0 0 24 24"},[e.createElementVNode("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4",fill:"none"}),e.createElementVNode("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})],-1),e.createTextVNode(" Creating... ",-1)])])):(e.openBlock(),e.createElementBlock("span",GE,"Create Stream"))],8,YE)])])),e.unref(u)?(e.openBlock(),e.createElementBlock("div",lS,[e.createElementVNode("p",cS,e.toDisplayString(e.unref(u)),1)])):e.createCommentVNode("",!0)]))}}),uS=_e(dS,[["__scopeId","data-v-26291f6f"]]),mS={class:"album-tree-node"},pS=["data-album-id","draggable","aria-selected","aria-expanded"],fS={key:1,class:"album-node__chevron-placeholder"},hS={key:2,"data-testid":"media-count",class:"album-node__count"},vS={key:0,class:"album-tree-node__children",role:"group"},gS=16,yS=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*gS}px`),d=e.computed(()=>{var g;return((g=t.dragState)==null?void 0:g.draggedAlbumId)===t.album.id}),u=e.computed(()=>{var g;return((g=t.dragState)==null?void 0:g.dropTargetId)===t.album.id}),p=e.computed(()=>{var g;return(g=t.dragState)!=null&&g.draggedAlbumId?t.dragState.draggedAlbumId===t.album.id:!1}),m=e.computed(()=>{const g=["album-node"];return i.value&&g.push("album-node--selected"),s.value&&g.push("album-node--focused"),t.compact&&g.push("album-node--compact"),d.value&&g.push("album-node--dragging"),u.value&&g.push("album-node--drop-target"),p.value&&g.push("album-node--invalid-drop"),g});function h(){a("select",t.album)}function v(g){g.stopPropagation(),a("toggle-expand",t.album.id)}function b(g){t.draggable&&(g.dataTransfer&&(g.dataTransfer.setData("text/plain",t.album.id),g.dataTransfer.effectAllowed="move"),a("drag-start",t.album.id))}function x(g){t.draggable&&(g.preventDefault(),g.dataTransfer&&(g.dataTransfer.dropEffect="move"),a("drag-over",t.album.id))}function R(){a("drag-leave",t.album.id)}function S(g){t.draggable&&(g.preventDefault(),a("drop",t.album.id))}return(g,f)=>{var $;const w=e.resolveComponent("AlbumTreeNode",!0);return e.openBlock(),e.createElementBlock("div",mS,[e.createElementVNode("div",{"data-testid":"album-node","data-album-id":g.album.id,class:e.normalizeClass(m.value),style:e.normalizeStyle({paddingLeft:c.value}),draggable:g.draggable,role:"treeitem","aria-selected":i.value,"aria-expanded":l.value?r.value:void 0,onDragstart:b,onDragover:x,onDragleave:R,onDrop:S},[l.value?(e.openBlock(),e.createElementBlock("button",{key:0,"data-testid":"expand-chevron",class:"album-node__chevron",type:"button","aria-label":"Toggle expand",onClick:v},[e.createVNode(e.unref(I.IonIcon),{icon:r.value?e.unref(qu):e.unref(Ku)},null,8,["icon"])])):(e.openBlock(),e.createElementBlock("span",fS)),e.createVNode(e.unref(I.IonIcon),{icon:e.unref(im),class:"album-node__icon"},null,8,["icon"]),e.createElementVNode("span",{"data-testid":"album-name",class:"album-node__name",onClick:h},e.toDisplayString(g.album.name),1),g.showMediaCount?(e.openBlock(),e.createElementBlock("span",hS,e.toDisplayString(g.album.media_count),1)):e.createCommentVNode("",!0)],46,pS),r.value&&(($=g.album.children)!=null&&$.length)?(e.openBlock(),e.createElementBlock("div",vS,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.album.children,V=>(e.openBlock(),e.createBlock(w,{key:V.id,album:V,depth:g.depth+1,"selected-id":g.selectedId,"expanded-ids":g.expandedIds,"focused-id":g.focusedId,draggable:g.draggable,"show-media-count":g.showMediaCount,compact:g.compact,onSelect:f[0]||(f[0]=y=>a("select",y)),onToggleExpand:f[1]||(f[1]=y=>a("toggle-expand",y))},null,8,["album","depth","selected-id","expanded-ids","focused-id","draggable","show-media-count","compact"]))),128))])):e.createCommentVNode("",!0)])}}}),bS=_e(yS,[["__scopeId","data-v-76be65a6"]]),Ya=xa.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 f=new Map;return n.value.forEach(w=>f.set(w.id,w)),f}),s=e.computed(()=>n.value.filter(f=>f.parent_id===null));async function l(f){t.value=!0,a.value=null;try{const w=(f==null?void 0:f.parent_id)??null,$=w?`/api/v1/albums?parent_id=${w}`:"/api/v1/albums?parent_id=null",V=await fetch($);if(!V.ok)throw new Error("Failed to fetch albums");((await V.json()).data||[]).forEach(D=>{const k=n.value.findIndex(T=>T.id===D.id);k>=0?n.value[k]=D:n.value.push(D)}),w!==null&&r.value.add(w)}catch(w){a.value=w instanceof Error?w.message:"Unknown error"}finally{t.value=!1}}async function c(f){t.value=!0,a.value=null;try{const w=await fetch(`/api/v1/albums/${f}`);if(!w.ok)throw new Error("Failed to fetch album");const V=(await w.json()).data,y=n.value.findIndex(C=>C.id===V.id);return y>=0?n.value[y]=V:n.value.push(V),V}catch(w){throw a.value=w instanceof Error?w.message:"Unknown error",w}finally{t.value=!1}}async function d(f){t.value=!0,a.value=null;try{const w=await fetch(`/api/v1/albums/${f}/media`);if(!w.ok)throw new Error("Failed to fetch album media");const V=(await w.json()).data||[];return o.value.set(f,V),V}catch(w){throw a.value=w instanceof Error?w.message:"Unknown error",w}finally{t.value=!1}}async function u(f,w){t.value=!0,a.value=null;try{if(!(await fetch(`/api/v1/albums/${f}/media/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({media_ids:w})})).ok)throw new Error("Failed to reorder album media");const V=o.value.get(f)||[],y=w.map(C=>V.find(D=>D.uuid===C)).filter(C=>C!==void 0);o.value.set(f,y)}catch($){throw a.value=$ instanceof Error?$.message:"Unknown error",$}finally{t.value=!1}}async function p(f){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(f)});if(!w.ok)throw new Error("Failed to create album");const V=(await w.json()).data;return n.value.push(V),V}catch(w){throw a.value=w instanceof Error?w.message:"Unknown error",w}finally{t.value=!1}}async function m(f,w){t.value=!0,a.value=null;try{const $=await fetch(`/api/v1/albums/${f}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(w)});if(!$.ok)throw new Error("Failed to update album");const y=(await $.json()).data,C=n.value.findIndex(D=>D.id===y.id);return C>=0&&(n.value[C]=y),y}catch($){throw a.value=$ instanceof Error?$.message:"Unknown error",$}finally{t.value=!1}}async function h(f){t.value=!0,a.value=null;try{if(!(await fetch(`/api/v1/albums/${f}`,{method:"DELETE",headers:{"Content-Type":"application/json"},credentials:"include"})).ok)throw new Error("Failed to delete album");const $=n.value.findIndex(V=>V.id===f);$>=0&&n.value.splice($,1),o.value.delete(f)}catch(w){throw a.value=w instanceof Error?w.message:"Unknown error",w}finally{t.value=!1}}function v(f){return n.value.filter(w=>w.parent_id===f)}function b(f){return r.value.has(f)}function x(f){return o.value.get(f)||[]}async function R(f,w){const $=n.value.findIndex(y=>y.id===f);if($<0)return;const V=n.value[$];n.value[$]={...V,parent_id:w};try{if(!(await fetch(`/api/v1/albums/${f}/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(y){throw n.value[$]=V,a.value=y instanceof Error?y.message:"Unknown error",y instanceof Error?y:new Error("Failed to move album")}}function S(f){n.value=f}function g(){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:h,getChildrenOf:v,childrenLoaded:b,getAlbumMedia:x,moveAlbum:R,setAlbums:S,reset:g}});function Uc(){const n=Ya(),{albums:o,albumsById:t,rootAlbums:a,loading:r,error:i}=xa.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 Oc(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 h=new Set,v=[p];for(;v.length>0;){const b=v.shift();if(!b||h.has(b))continue;h.add(b);const x=o.get(b)||[];for(const R of x){if(R===m)return!0;v.push(R)}}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 wS={key:0,"data-testid":"loading-spinner",class:"album-tree__loading"},kS={key:1,"data-testid":"error-state",class:"album-tree__error"},xS={key:2,"data-testid":"empty-state",class:"album-tree__empty"},ES={key:3,class:"album-tree__content",role:"group"},SS=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:h,childrenLoaded:v,moveAlbum:b}=Uc(),x=e.shallowRef(new Set(a.expandedIds)),R=e.ref(a.modelValue??null),S=e.ref(null),g=new Map,f=new Map;function w(M){g.clear(),f.clear();for(const j of M){g.set(j.id,j);const le=j.parent_id??null,ae=f.get(le)??[];ae.push(j.id),f.set(le,ae)}}e.watch(c,M=>{w(M)},{immediate:!0});const{dragState:$,canDropOn:V,startDrag:y,endDrag:C,setDropTarget:D,clearDropTarget:k,executeDrop:T}=Oc({childrenByParentId:f,onMove:async(M,j)=>{await b(M,j),r("album-moved",{albumId:M,newParentId:j})}});e.watch(()=>a.modelValue,M=>{R.value=M??null}),e.watch(()=>a.expandedIds,M=>{x.value=new Set(M)}),e.onMounted(async()=>{await m({parent_id:null})});const F=e.computed(()=>d.value.map(M=>A(M)));function A(M){if(!x.value.has(M.id))return M;const j=h(M.id);return{...M,children:j.map(le=>A(le))}}const P=e.computed(()=>{const M=[];function j(le){var ae;for(const H of le)M.push(H),x.value.has(H.id)&&((ae=H.children)!=null&&ae.length)&&j(H.children)}return j(F.value),M});function O(M){var ae;if(!P.value.length)return;const j=S.value?P.value.findIndex(H=>H.id===S.value):-1,le=j>=0?P.value[j]:null;switch(M.key){case"ArrowDown":M.preventDefault(),j<P.value.length-1?S.value=P.value[j+1].id:j===-1&&P.value.length>0&&(S.value=P.value[0].id);break;case"ArrowUp":M.preventDefault(),j>0&&(S.value=P.value[j-1].id);break;case"ArrowRight":M.preventDefault(),le&&(le.children_count>0&&!x.value.has(le.id)?B(le.id):x.value.has(le.id)&&((ae=le.children)!=null&&ae.length)&&(S.value=le.children[0].id));break;case"ArrowLeft":M.preventDefault(),le&&(x.value.has(le.id)&&le.children_count>0?B(le.id):le.parent_id&&(S.value=le.parent_id));break;case"Enter":case" ":M.preventDefault(),le&&_(le);break;case"Home":M.preventDefault(),P.value.length>0&&(S.value=P.value[0].id);break;case"End":M.preventDefault(),P.value.length>0&&(S.value=P.value[P.value.length-1].id);break}}async function B(M){x.value.has(M)?(x.value.delete(M),r("album-collapsed",M)):(v(M)||await m({parent_id:M}),x.value.add(M),r("album-expanded",M))}function _(M){R.value=M.id,r("update:modelValue",M.id),r("album-selected",M)}function X(M){a.draggable&&y(M)}function W(M){var le;if(!a.draggable)return;const j=(le=$.value)==null?void 0:le.draggedAlbumId;j&&(D(M),V(j,M))}function ee(){a.draggable&&k()}async function he(M){a.draggable&&(D(M),await T())}function Ue(M){a.draggable&&(M.preventDefault(),D(null))}async function Te(M){a.draggable&&(M.preventDefault(),D(null),await T())}function re(){C()}return o({focusedId:S}),(M,j)=>(e.openBlock(),e.createElementBlock("div",{class:"album-tree","data-testid":"album-tree",tabindex:"0",role:"tree","aria-label":"Album tree",onKeydown:O,onDragover:Ue,onDrop:Te,onDragend:re},[e.unref(u)?(e.openBlock(),e.createElementBlock("div",wS,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"})])):e.unref(p)?(e.openBlock(),e.createElementBlock("div",kS,[e.createElementVNode("p",null,e.toDisplayString(e.unref(p)),1)])):e.unref(d).length?(e.openBlock(),e.createElementBlock("div",ES,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(F.value,le=>(e.openBlock(),e.createBlock(bS,{key:le.id,album:le,depth:0,"selected-id":R.value,"expanded-ids":x.value,"focused-id":S.value,draggable:i.value,"drag-state":i.value?e.unref($):null,"show-media-count":s.value,compact:l.value,onSelect:_,onToggleExpand:B,onDragStart:X,onDragOver:W,onDragLeave:ee,onDrop:he},null,8,["album","selected-id","expanded-ids","focused-id","draggable","drag-state","show-media-count","compact"]))),128))])):(e.openBlock(),e.createElementBlock("div",xS,[j[0]||(j[0]=e.createElementVNode("p",null,"No albums yet",-1)),e.renderSlot(M.$slots,"empty-action",{},void 0,!0)]))],32))}}),Lc=_e(SS,[["__scopeId","data-v-ae3dea7a"]]),VS=300,CS=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,h=>{r.value=h??null});const c=e.computed(()=>i.value!==null);function d(h){const v=Date.now();if(l.value===h.id&&v-s.value<VS){a("confirm",h);return}s.value=v,l.value=h.id,r.value=h.id,i.value=h}function u(){i.value&&a("confirm",i.value)}function p(){a("close")}function m(){a("close")}return(h,v)=>(e.openBlock(),e.createBlock(e.unref(I.IonModal),{"is-open":h.isOpen,class:"album-browser-modal",onDidDismiss:m},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(h.title),1)]),_:1}),e.createVNode(e.unref(I.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.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(I.IonContent),{class:"album-browser-content"},{default:e.withCtx(()=>[e.createVNode(Lc,{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(I.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{fill:"clear",onClick:p},{default:e.withCtx(()=>[...v[2]||(v[2]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(I.IonButton),{"data-testid":"confirm-button",fill:"solid",color:"primary",disabled:!c.value,onClick:u},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(h.confirmText),1)]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"]))}}),Wc=_e(CS,[["__scopeId","data-v-21676ec1"]]),NS={class:"ion-padding-start text-sm"},_S={class:"ion-padding-start text-sm"},TS={key:1},MS={key:1,class:"album-manager-inline rounded-lg border border-gray-200 bg-white p-4"},FS={class:"flex items-center justify-between gap-3 pb-3"},BS={class:"text-base font-semibold text-gray-900"},IS={class:"ion-padding-start text-sm"},RS={class:"ion-padding-start text-sm"},PS={class:"flex justify-between pt-2"},$S={key:1},eo=255,to=1e3,zS=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=Ya(),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),h=e.ref(!1),v=e.ref(!1),b=e.computed(()=>d.value.name?c.value.name.trim()?c.value.name.length>eo?`Name must be ${eo} characters or less`:null:"Name is required":null),x=e.computed(()=>d.value.description&&c.value.description.length>to?`Description must be ${to} characters or less`:null),R=e.computed(()=>{const O=c.value.name.trim().length>0,B=c.value.name.length<=eo,_=c.value.description.length<=to;return O&&B&&_&&!h.value}),S=e.computed(()=>{var O;return((O=u.value)==null?void 0:O.name)??"None (Root)"}),g=e.computed(()=>m.value?m.value.children_count===0&&m.value.media_count===0:!1),f=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 O=await r.fetchAlbum(t.albumId);m.value=O,c.value={name:O.name,description:O.description??"",parent_id:O.parent_id},O.parent_id&&(u.value={id:O.parent_id,name:"Parent Album"})}catch(O){a("error",O)}}function $(){d.value.name=!0}function V(){d.value.description=!0}function y(){p.value=!0}function C(O){u.value={id:O.id,name:O.name},c.value.parent_id=O.id,p.value=!1}function D(){p.value=!1}function k(){a("close")}function T(){a("close")}async function F(){if(d.value.name=!0,d.value.description=!0,!(!R.value||h.value)){h.value=!0;try{const O={name:c.value.name.trim(),description:c.value.description.trim(),parent_id:c.value.parent_id};if(i.value&&t.albumId){const B=await r.updateAlbum(t.albumId,O);a("updated",B)}else{const B=await r.createAlbum(O);a("created",B)}a("close")}catch(O){a("error",O)}finally{h.value=!1}}}function A(){g.value&&(v.value=!0)}async function P(O){var _;if((((_=O.detail)==null?void 0:_.role)??"")!=="confirm"){v.value=!1;return}if(t.albumId){h.value=!0;try{await r.deleteAlbum(t.albumId),a("deleted",t.albumId),a("close")}catch(X){a("error",X)}finally{h.value=!1,v.value=!1}}}return(O,B)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[O.mode==="modal"?(e.openBlock(),e.createBlock(e.unref(I.IonModal),{key:0,"is-open":O.isOpen,class:"album-manager-modal",onDidDismiss:T},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.value),1)]),_:1}),e.createVNode(e.unref(I.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:k},{default:e.withCtx(()=>[...B[4]||(B[4]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(I.IonContent),{class:"album-manager-content"},{default:e.withCtx(()=>[e.createElementVNode("form",{"data-testid":"album-form",class:"p-4 space-y-3",onSubmit:e.withModifiers(F,["prevent"])},[e.createVNode(e.unref(I.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...B[5]||(B[5]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(I.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":B[0]||(B[0]=_=>c.value.name=_),"data-testid":"name-input",maxlength:eo,onIonBlur:$},null,8,["modelValue"])]),_:1}),b.value?(e.openBlock(),e.createBlock(e.unref(I.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",NS,e.toDisplayString(b.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...B[6]||(B[6]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(I.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":B[1]||(B[1]=_=>c.value.description=_),"data-testid":"description-input",maxlength:to,onIonBlur:V},null,8,["modelValue"])]),_:1}),x.value?(e.openBlock(),e.createBlock(e.unref(I.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",_S,e.toDisplayString(x.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonItem),{button:"","data-testid":"parent-selector",onClick:y},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...B[7]||(B[7]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(I.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(S.value),1)]),_:1})]),_:1})],32)]),_:1}),e.createVNode(e.unref(I.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButtons),{slot:"start"},{default:e.withCtx(()=>[i.value?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",disabled:!g.value,title:g.value?void 0:f.value,onClick:A},{default:e.withCtx(()=>[...B[8]||(B[8]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.unref(I.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!R.value,onClick:F},{default:e.withCtx(()=>[h.value?(e.openBlock(),e.createBlock(e.unref(I.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",TS,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"])):(e.openBlock(),e.createElementBlock("div",MS,[e.createElementVNode("div",FS,[e.createElementVNode("h2",BS,e.toDisplayString(s.value),1),e.createVNode(e.unref(I.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:k},{default:e.withCtx(()=>[...B[9]||(B[9]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),e.createElementVNode("form",{"data-testid":"album-form",class:"space-y-3",onSubmit:e.withModifiers(F,["prevent"])},[e.createVNode(e.unref(I.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...B[10]||(B[10]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(I.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":B[2]||(B[2]=_=>c.value.name=_),"data-testid":"name-input",maxlength:eo,onIonBlur:$},null,8,["modelValue"])]),_:1}),b.value?(e.openBlock(),e.createBlock(e.unref(I.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",IS,e.toDisplayString(b.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...B[11]||(B[11]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(I.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":B[3]||(B[3]=_=>c.value.description=_),"data-testid":"description-input",maxlength:to,onIonBlur:V},null,8,["modelValue"])]),_:1}),x.value?(e.openBlock(),e.createBlock(e.unref(I.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",RS,e.toDisplayString(x.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonItem),{button:"","data-testid":"parent-selector",onClick:y},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...B[12]||(B[12]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(I.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(S.value),1)]),_:1})]),_:1}),e.createElementVNode("div",PS,[e.createElementVNode("div",null,[i.value?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",fill:"outline",disabled:!g.value,title:g.value?void 0:f.value,onClick:A},{default:e.withCtx(()=>[...B[13]||(B[13]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(I.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!R.value,onClick:F},{default:e.withCtx(()=>[h.value?(e.openBlock(),e.createBlock(e.unref(I.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",$S,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])])],32)])),e.createVNode(Wc,{"is-open":p.value,"selected-album-id":c.value.parent_id,title:"Select Parent Album",onClose:D,onConfirm:C},null,8,["is-open","selected-album-id"]),e.createVNode(e.unref(I.IonAlert),{"is-open":v.value,header:"Delete Album?",message:f.value,buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"confirm",cssClass:"alert-button-danger"}],onDidDismiss:P},null,8,["is-open","message"])],64))}}),AS=_e(zS,[["__scopeId","data-v-22083f3a"]]),DS={class:"album-media-grid"},US={class:"aspect-square"},OS={key:1,"data-testid":"empty-state",class:"flex flex-col items-center justify-center py-12 gap-4"},LS={class:"text-gray-500"},WS=["data-media-id","draggable","onDragstart","onDragover","onDrop","onMouseenter"],jS={key:0,"data-testid":"drop-indicator",class:"absolute inset-0 border-2 border-primary rounded-lg pointer-events-none z-30"},XS={key:1,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"},ZS={class:"aspect-square relative"},YS=["src","alt"],GS={key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center gap-2 transition-opacity"},HS=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=Ya(),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}`]}),h=e.computed(()=>(t.columns.md??4)*2);e.onMounted(async()=>{await v()}),e.watch(()=>t.albumId,async()=>{await v()});async function v(){s.value=!0;try{const T=await r.fetchAlbumMedia(t.albumId);i.value=T}catch{i.value=[]}finally{s.value=!1}}function b(T){return t.selectedItems.includes(T)}function x(T){a("toggle-select",T);const F=b(T.uuid)?t.selectedItems.filter(A=>A!==T.uuid):[...t.selectedItems,T.uuid];a("selection-change",F)}function R(T){if(T.conversions&&typeof T.conversions=="object"){const F=T.conversions.thumb;if(typeof F=="string")return F}return T.original_url}function S(T){l.value=T}function g(){l.value=null}function f(T){a("preview",T)}function w(T){a("edit",T)}function $(T){a("detach",T.uuid)}function V(){a("add")}function y(T,F){t.reorderable&&(c.value=F,T.dataTransfer&&(T.dataTransfer.effectAllowed="move",T.dataTransfer.setData("text/plain",String(F))))}function C(T,F){!t.reorderable||c.value===null||(T.preventDefault(),d.value=F)}function D(T,F){if(!t.reorderable||c.value===null)return;T.preventDefault();const A=c.value;if(A!==F){const P=[...i.value],[O]=P.splice(A,1);P.splice(F,0,O),i.value=P;const B=P.map(_=>_.uuid);a("reorder",B),r.reorderAlbumMedia(t.albumId,B).catch(()=>{v()})}c.value=null,d.value=null}function k(){c.value=null,d.value=null}return(T,F)=>(e.openBlock(),e.createElementBlock("div",DS,[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(h.value,A=>(e.openBlock(),e.createBlock(e.unref(I.IonCard),{key:A,class:"m-0"},{default:e.withCtx(()=>[e.createElementVNode("div",US,[e.createVNode(e.unref(I.IonSkeletonText),{animated:"",class:"w-full h-full skeleton"})])]),_:1}))),128))],2)):p.value?(e.openBlock(),e.createElementBlock("div",OS,[e.createVNode(e.unref(I.IonIcon),{name:"images-outline",class:"text-6xl text-gray-400"}),e.createElementVNode("p",LS,e.toDisplayString(T.emptyText),1),e.createVNode(e.unref(I.IonButton),{"data-testid":"add-media-btn",onClick:V},{default:e.withCtx(()=>[...F[0]||(F[0]=[e.createTextVNode(" Add Media ",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("div",{key:2,"data-testid":"media-grid",class:e.normalizeClass(m.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(A,P)=>(e.openBlock(),e.createElementBlock("div",{key:A.uuid,"data-media-id":A.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:O=>y(O,P),onDragover:O=>C(O,P),onDrop:O=>D(O,P),onDragend:k,onMouseenter:O=>S(A.uuid),onMouseleave:g},[d.value===P&&c.value!==P&&T.reorderable?(e.openBlock(),e.createElementBlock("div",jS)):e.createCommentVNode("",!0),T.reorderable?(e.openBlock(),e.createElementBlock("div",XS,[e.createVNode(e.unref(I.IonIcon),{name:"reorder-three-outline",class:"text-white drop-shadow-md"})])):e.createCommentVNode("",!0),T.selectionMode?(e.openBlock(),e.createBlock(e.unref(I.IonCheckbox),{key:2,"data-testid":"media-checkbox",checked:b(A.uuid),class:"absolute top-2 left-2 z-20",onIonChange:O=>x(A)},null,8,["checked","onIonChange"])):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonCard),{class:"m-0 overflow-hidden"},{default:e.withCtx(()=>[e.createElementVNode("div",ZS,[e.createElementVNode("img",{src:R(A),alt:A.file_name,class:"w-full h-full object-cover"},null,8,YS),T.showActions&&l.value===A.uuid?(e.openBlock(),e.createElementBlock("div",GS,[e.createVNode(e.unref(I.IonButton),{"data-testid":"action-preview",fill:"clear",size:"small",color:"light",onClick:O=>f(A)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"icon-only",name:"eye-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(I.IonButton),{"data-testid":"action-edit",fill:"clear",size:"small",color:"light",onClick:O=>w(A)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"icon-only",name:"create-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(I.IonButton),{"data-testid":"action-detach",fill:"clear",size:"small",color:"danger",onClick:O=>$(A)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"icon-only",name:"close-circle-outline"})]),_:1},8,["onClick"])])):e.createCommentVNode("",!0)])]),_:2},1024)],42,WS))),128)),e.createElementVNode("div",{class:"aspect-square border-2 border-dashed border-gray-300 rounded-lg flex flex-col items-center justify-center gap-2 cursor-pointer hover:border-primary hover:bg-gray-50 transition-colors","data-testid":"add-more-card",onClick:V},[e.createVNode(e.unref(I.IonIcon),{name:"add-circle-outline",class:"text-4xl text-gray-400"}),F[1]||(F[1]=e.createElementVNode("span",{class:"text-sm text-gray-500"},"Add Media",-1))])],2))]))}}),JS=_e(HS,[["__scopeId","data-v-d84b796a"]]);function fi(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 jr(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 hi(n){if(n){const t={};n.apiBaseUrl!==void 0&&(t.apiBaseUrl=n.apiBaseUrl),n.isAdmin!==void 0&&(t.isAdmin=n.isAdmin),zn(t)}return{name:"mediables",async upload(t,a){const i=await yt().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 yt().attachMedia(a.modelType,String(a.modelId),[t],a.collection||"images")},async attachMany(t,a){await yt().attachMedia(a.modelType,String(a.modelId),t,a.collection||"images")},async detach(t,a){await yt().detachMedia(a.modelType,String(a.modelId),t,a.collection||"images")},async reorder(t,a){await yt().reorderMedia(t.modelType,String(t.modelId),a,t.collection||"images")},async fetchModelMedia(t){return await yt().fetchModelMedia(t.modelType,String(t.modelId),t.collection||"images")},getUrl(t,a){return yt().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 yt().deleteMedia(t)},async update(t,a){const i=await yt().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),zn(a)}}}let la=null;function qS(){return la||(la=hi()),la}function KS(){la=null}const QS={apiBaseUrl:"/media-library-pro"};function qo(){var n;return typeof document>"u"?null:((n=document.querySelector('meta[name="csrf-token"]'))==null?void 0:n.getAttribute("content"))||null}function xr(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 vi(n){const o={...QS,...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||qo();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=xr(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||qo();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(xr)}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||qo();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||qo();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 xr(c)},configure(a){Object.assign(o,a)}}}let ca=null;function e4(){return ca||(ca=vi()),ca}function t4(){ca=null}function jc(n,o){switch(n){case"mediables":return hi(o);case"spatie":return vi(o);default:throw new Error(`Unknown adapter: ${n}`)}}function ka(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 Xc(n){var t;const o=n.split(".");return o.length>1?`.${(t=o.pop())==null?void 0:t.toLowerCase()}`:""}function gi(n){return n.type.startsWith("image/")}async function Zc(n){return gi(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 Yc(n,o){const t=[];if(o.maxFileSize&&n.size>o.maxFileSize&&t.push({field:"size",message:`File exceeds maximum size of ${ka(o.maxFileSize)}`,code:"MAX_FILE_SIZE"}),o.minFileSize&&n.size<o.minFileSize&&t.push({field:"size",message:`File is smaller than minimum size of ${ka(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=Xc(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(gi(n)&&(o.maxDimensions||o.minDimensions)){const a=await Zc(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 yi(n={}){const o=e.ref(n.rules||{});function t(c){o.value=c}async function a(c){return Yc(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 n4(){return`upload-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function o4(n){if(n.type.startsWith("image/"))return URL.createObjectURL(n)}function Gc(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:h}=yi(m);async function v(){if(p.value.size>=t)return;const k=Array.from(u.value.entries()).find(([A,P])=>P.status==="pending"&&!p.value.has(A));if(!k){Array.from(u.value.values()).every(P=>P.status==="completed"||P.status==="error")&&u.value.size>0&&(d==null||d());return}const[T,F]=k;await b(T,F)}async function b(k,T){p.value.add(k),T.status="uploading",T.abortController=new AbortController,u.value.set(k,{...T}),i==null||i(T);try{const F={onProgress:P=>{T.progress=P,u.value.set(k,{...T}),s==null||s(T)},signal:T.abortController.signal};r&&(F.collection=r);const A=await o.upload(T.file,F);T.status="completed",T.progress=100,T.media=A.media,u.value.set(k,{...T}),l==null||l(T,A.media)}catch(F){F.name==="AbortError"?u.value.delete(k):(T.status="error",T.error=F.message,u.value.set(k,{...T}),c==null||c(T,F))}finally{p.value.delete(k),delete T.abortController,v()}}async function x(k){var A;const T=Array.from(k),F=[];for(const P of T){const O=await h(P),B=n4(),_=o4(P),X={id:B,file:P,progress:0,status:O.valid?"pending":"error"};!O.valid&&((A=O.errors[0])!=null&&A.message)&&(X.error=O.errors[0].message),_&&(X.previewUrl=_),u.value.set(B,X);const W={media:null,clientId:B,name:P.name,order:0,upload:X,errors:O.errors};F.push(W)}for(let P=0;P<t;P++)v();return F}function R(k){const T=u.value.get(k);T&&(T.abortController&&T.abortController.abort(),T.previewUrl&&URL.revokeObjectURL(T.previewUrl),u.value.delete(k),p.value.delete(k),v())}async function S(k){const T=u.value.get(k);!T||T.status!=="error"||(T.status="pending",T.progress=0,delete T.error,u.value.set(k,{...T}),v())}function g(){for(const[k,T]of u.value.entries())(T.status==="completed"||T.status==="error")&&(T.previewUrl&&URL.revokeObjectURL(T.previewUrl),u.value.delete(k))}function f(){for(const k of u.value.values())k.abortController&&k.abortController.abort(),k.previewUrl&&URL.revokeObjectURL(k.previewUrl);u.value.clear(),p.value.clear()}function w(k){return u.value.get(k)}const $=e.computed(()=>p.value.size>0),V=e.computed(()=>p.value.size),y=e.computed(()=>Array.from(u.value.values()).filter(k=>k.status==="pending").length),C=e.computed(()=>u.value.size===0?!0:Array.from(u.value.values()).every(k=>k.status==="completed"||k.status==="error")),D=e.computed(()=>Array.from(u.value.values()));return{uploads:u,isUploading:$,activeCount:V,pendingCount:y,isComplete:C,addFiles:x,cancelUpload:R,retryUpload:S,clearCompleted:g,clearAll:f,getUpload:w,uploadsArray:D}}function Hc(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(S,g,f){o&&("dataTransfer"in S&&S.dataTransfer&&(S.dataTransfer.effectAllowed="move",S.dataTransfer.setData("text/plain",String(f))),d=S.target,d&&d.classList.add(i),l.value={isDragging:!0,dragIndex:f,dropIndex:f,draggedItem:g},c.value=!0,a==null||a(g,f))}function p(S,g){var f;if(!(!o||!l.value.isDragging)&&(S.preventDefault(),l.value.dropIndex!==g)){const w=document.querySelector(`.${s}`);w==null||w.classList.remove(s);const $=(f=S.target)==null?void 0:f.closest("[data-index]");$==null||$.classList.add(s),l.value.dropIndex=g}}function m(){if(!l.value.isDragging)return;const{dragIndex:S,dropIndex:g,draggedItem:f}=l.value;d&&d.classList.remove(i);const w=document.querySelector(`.${s}`);w==null||w.classList.remove(s),S!==null&&g!==null&&S!==g&&f&&(t==null||t({fromIndex:S,toIndex:g,item:f})),v(),r==null||r()}function h(){d&&d.classList.remove(i);const S=document.querySelector(`.${s}`);S==null||S.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(S,g,f){const w=[...S],[$]=w.splice(g,1);return w.splice(f,0,$),w.map((V,y)=>({...V,order:y}))}function x(S,g){return{draggable:o,"data-index":g,onDragstart:f=>u(f,S,g),onDragover:f=>p(f,g),onDragend:()=>m(),onDrop:f=>{f.preventDefault(),m()}}}function R(S){S.key==="Escape"&&l.value.isDragging&&h()}return e.onMounted(()=>{document.addEventListener("keydown",R)}),e.onUnmounted(()=>{document.removeEventListener("keydown",R),h()}),{dragState:l,isDragging:c,startDrag:u,handleDragOver:p,endDrag:m,cancelDrag:h,reorderItems:b,getDragProps:x}}function Ga(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:h=3,onChange:v,onUpload:b,onUploadComplete:x,onUploadError:R,onRemove:S,onReorder:g,onError:f,onReadyToSubmitChange:w}=n,$={maxItems:i,maxFileSize:s,acceptedMimeTypes:l,...u},V=m||jc(p),y=e.ref([]),C=e.ref(!1),D=e.ref([]);function k(ne){if(ne.length===0)return[];const we=ne[0];return"media"in we&&"clientId"in we?ne:jr(ne)}y.value=k(o);const{acceptString:T,canAddFiles:F}=yi({rules:$}),A=Gc({adapter:V,maxConcurrent:h,rules:$,collection:r,onUploadStart:ne=>{b==null||b(ne)},onUploadComplete:(ne,we)=>{const pe=y.value.findIndex(qe=>qe.clientId===ne.id);pe!==-1&&(y.value[pe]={...y.value[pe],media:we,name:we.name||we.file_name,upload:{...ne,status:"completed"}}),x==null||x(we)},onUploadError:(ne,we)=>{const pe=y.value.findIndex(qe=>qe.clientId===ne.id);pe!==-1&&(y.value[pe]={...y.value[pe],upload:{...ne,status:"error",error:we.message},errors:[{field:"upload",message:we.message,code:"UPLOAD_ERROR"}]}),R==null||R({file:ne.file,message:we.message})},onQueueComplete:()=>{v==null||v(y.value)}}),{dragState:P,getDragProps:O,reorderItems:B}=Hc({enabled:c&&!d,onReorder:ne=>{y.value=B(y.value,ne.fromIndex,ne.toIndex),g==null||g(y.value),v==null||v(y.value)}}),_=e.computed(()=>A.isUploading.value),X=e.computed(()=>!A.isUploading.value&&A.pendingCount.value===0),W=e.computed(()=>i?y.value.length>=i:!1),ee=e.computed(()=>fi(y.value)),he=e.computed(()=>y.value.length),Ue=e.computed(()=>i?Math.max(0,i-y.value.length):1/0);e.watch(X,ne=>{w==null||w(ne)});function Te(ne){y.value=k(ne),v==null||v(y.value)}async function re(ne){if(d)return;const we=Array.from(ne);if(!F(we.length,y.value.length)){const de={field:"count",message:`Maximum ${i} files allowed`,code:"MAX_ITEMS"};D.value=[de],f==null||f([de]);return}const pe=await A.addFiles(we),qe=y.value.length,rt=pe.map((de,ye)=>({...de,order:qe+ye}));y.value=[...y.value,...rt],v==null||v(y.value)}function M(ne){d||(ne.upload&&(ne.upload.status==="uploading"||ne.upload.status==="pending")&&A.cancelUpload(ne.clientId),y.value=y.value.filter(we=>we.clientId!==ne.clientId),y.value=y.value.map((we,pe)=>({...we,order:pe})),S==null||S(ne),v==null||v(y.value))}function j(ne){const we=y.value.find(pe=>pe.clientId===ne);we&&M(we)}function le(){d||(A.clearAll(),y.value=[],v==null||v(y.value))}function ae(ne,we){d||!c||(y.value=B(y.value,ne,we),g==null||g(y.value),v==null||v(y.value))}function H(ne,we){if(d)return;const pe=y.value.findIndex(qe=>qe.clientId===ne);pe!==-1&&(y.value[pe]={...y.value[pe],...we},v==null||v(y.value))}function K(ne){A.cancelUpload(ne),j(ne)}async function ce(ne){await A.retryUpload(ne)}async function ve(){if(!t||!a)throw new Error("modelType and modelId are required for save()");const ne={modelType:t,modelId:a,collection:r},we=y.value.filter(pe=>pe.media&&!pe.markedForRemoval).map(pe=>pe.media.uuid);C.value=!0;try{await V.attachMany(we,ne),await V.reorder(ne,we)}finally{C.value=!1}}async function ke(){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 we=await V.fetchModelMedia(ne);y.value=jr(we),v==null||v(y.value)}finally{C.value=!1}}return e.onMounted(()=>{t&&a&&o.length===0&&ke().catch(console.error)}),e.onUnmounted(()=>{A.clearAll()}),{items:y,setItems:Te,addFiles:re,removeItem:M,removeItemById:j,clearAll:le,reorderItems:ae,updateItem:H,cancelUpload:K,retryUpload:ce,save:ve,load:ke,isLoading:C,isUploading:_,isReadyToSubmit:X,isAtMaxItems:W,errors:D,dragState:P,getDragProps:O,adapter:V,formValues:ee,acceptString:T,count:he,remainingSlots:Ue}}const a4=["aria-disabled"],r4=["accept","multiple","disabled"],i4={class:"media-dropzone__content"},s4={class:"media-dropzone__title"},l4={class:"media-dropzone__subtitle"},c4=["disabled"],d4={key:0,class:"media-dropzone__helper"},u4=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: ${ka(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 R;if(b.preventDefault(),r.value=!1,t.disabled)return;const x=(R=b.dataTransfer)==null?void 0:R.files;x&&x.length>0&&a("files",x)}function m(){var b;t.disabled||(b=i.value)==null||b.click()}function h(b){const x=b.target,R=x.files;R&&R.length>0&&a("files",R),x.value=""}function v(b){(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),m())}return(b,x)=>(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:h},null,40,r4),e.createElementVNode("div",i4,[e.renderSlot(b.$slots,"icon",{},()=>[x[0]||(x[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",s4,[e.renderSlot(b.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(b.title),1)],!0)]),e.createElementVNode("p",l4,[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,c4),l.value?(e.openBlock(),e.createElementBlock("p",d4,e.toDisplayString(l.value),1)):e.createCommentVNode("",!0)])],42,a4))}}),bi=_e(u4,[["__scopeId","data-v-b1366c1e"]]),m4=["data-index"],p4={key:0,class:"media-item__drag-handle","aria-label":"Drag to reorder",role:"button",tabindex:"0"},f4={class:"media-item__thumbnail"},h4=["src","alt"],v4={key:1,class:"media-item__file-icon"},g4={key:2,class:"media-item__progress-overlay"},y4={class:"media-item__progress-text"},b4={key:3,class:"media-item__processing-overlay"},w4={key:4,class:"media-item__error-overlay"},k4={class:"media-item__info"},x4=["title"],E4={key:0,class:"media-item__size"},S4={key:1,class:"media-item__error-message"},V4={class:"media-item__actions"},C4=["disabled"],N4=["disabled"],_4=["disabled"],T4=["disabled"],M4=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 g;return(g=t.item.upload)!=null&&g.previewUrl?t.item.upload.previewUrl:t.item.media?t.adapter.getThumbnailUrl(t.item.media):null}),s=e.computed(()=>{var g,f,w;return((g=t.item.upload)==null?void 0:g.status)==="uploading"||((f=t.item.upload)==null?void 0:f.status)==="pending"||((w=t.item.upload)==null?void 0:w.status)==="queued"}),l=e.computed(()=>{var g;return((g=t.item.upload)==null?void 0:g.status)==="processing"}),c=e.computed(()=>{var g;return((g=t.item.upload)==null?void 0:g.status)==="error"||t.item.errors&&t.item.errors.length>0}),d=e.computed(()=>{var g;return(g=t.item.upload)!=null&&g.error?t.item.upload.error:t.item.errors&&t.item.errors.length>0?t.item.errors[0].message:null}),u=e.computed(()=>{var g;return((g=t.item.upload)==null?void 0:g.progress)||0}),p=e.computed(()=>{var g;return t.item.name||((g=t.item.media)==null?void 0:g.file_name)||"Unknown file"}),m=e.computed(()=>{var V,y;const g=((V=t.item.media)==null?void 0:V.size)||((y=t.item.upload)==null?void 0:y.file.size);if(!g)return"";const f=1024,w=["Bytes","KB","MB","GB"],$=Math.floor(Math.log(g)/Math.log(f));return parseFloat((g/Math.pow(f,$)).toFixed(2))+" "+w[$]}),h=e.computed(()=>{var f,w;const g=((f=t.item.media)==null?void 0:f.mime_type)||((w=t.item.upload)==null?void 0:w.file.type);return g==null?void 0:g.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 x(){t.disabled||a("edit",t.item)}function R(){t.disabled||a("retry",t.item)}function S(){t.disabled||a("cancel",t.item)}return(g,f)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(v.value),"data-index":g.index,onMouseenter:f[0]||(f[0]=w=>r.value=!0),onMouseleave:f[1]||(f[1]=w=>r.value=!1)},[g.sortable&&!g.disabled?(e.openBlock(),e.createElementBlock("div",p4,[...f[2]||(f[2]=[e.createStaticVNode('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-v-ff81c9ec><circle cx="9" cy="5" r="1" data-v-ff81c9ec></circle><circle cx="9" cy="12" r="1" data-v-ff81c9ec></circle><circle cx="9" cy="19" r="1" data-v-ff81c9ec></circle><circle cx="15" cy="5" r="1" data-v-ff81c9ec></circle><circle cx="15" cy="12" r="1" data-v-ff81c9ec></circle><circle cx="15" cy="19" r="1" data-v-ff81c9ec></circle></svg>',1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",f4,[i.value&&h.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:i.value,alt:p.value,class:"media-item__image"},null,8,h4)):(e.openBlock(),e.createElementBlock("div",v4,[...f[3]||(f[3]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.createElementVNode("polyline",{points:"14 2 14 8 20 8"})],-1)])])),s.value?(e.openBlock(),e.createElementBlock("div",g4,[e.createElementVNode("div",{class:"media-item__progress-bar",style:e.normalizeStyle({width:`${u.value}%`})},null,4),e.createElementVNode("span",y4,e.toDisplayString(u.value)+"%",1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",b4,[...f[4]||(f[4]=[e.createElementVNode("div",{class:"media-item__spinner","aria-label":"Processing"},null,-1)])])):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",w4,[...f[5]||(f[5]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("circle",{cx:"12",cy:"12",r:"10"}),e.createElementVNode("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.createElementVNode("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})],-1)])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",k4,[e.createElementVNode("span",{class:"media-item__name",title:p.value},e.toDisplayString(p.value),9,x4),m.value?(e.openBlock(),e.createElementBlock("span",E4,e.toDisplayString(m.value),1)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("span",S4,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",V4,[s.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-item__action media-item__action--cancel",disabled:g.disabled,"aria-label":"Cancel upload",onClick:S},[...f[6]||(f[6]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])],8,C4)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"media-item__action media-item__action--retry",disabled:g.disabled,"aria-label":"Retry upload",onClick:R},[...f[7]||(f[7]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("polyline",{points:"23 4 23 10 17 10"}),e.createElementVNode("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})],-1)])],8,N4)):e.createCommentVNode("",!0),g.showEdit&&g.item.media&&!s.value?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"media-item__action media-item__action--edit",disabled:g.disabled,"aria-label":"Edit",onClick:x},[...f[8]||(f[8]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.createElementVNode("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})],-1)])],8,_4)):e.createCommentVNode("",!0),g.showRemove?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"media-item__action media-item__action--remove",disabled:g.disabled,"aria-label":"Remove",onClick:b},[...f[9]||(f[9]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("polyline",{points:"3 6 5 6 21 6"}),e.createElementVNode("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)])],8,T4)):e.createCommentVNode("",!0)])],42,m4))}}),wi=_e(M4,[["__scopeId","data-v-ff81c9ec"]]),F4=["aria-label"],B4=["draggable","data-index","onDragstart","onDragover","onDragend","onDrop"],I4={key:0,class:"media-collection__footer"},R4={class:"media-collection__count"},P4={key:0},$4={key:0,class:"media-collection__uploading"},z4=["name","value"],A4=["name","value"],D4=["name","value"],U4=["name","value"],O4={key:3,class:"media-collection__errors",role:"alert","aria-live":"polite"},L4=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:h,isAtMaxItems:v,errors:b,dragState:x,getDragProps:R,adapter:S,formValues:g,acceptString:f,count:w,remainingSlots:$}=Ga(r);e.provide("mediaAdapter",S),e.provide("mediaCollection",{items:i,addFiles:l,removeItem:c,reorderItems:d}),e.watch(()=>t.modelValue,_=>{_!==i.value&&s(_)},{deep:!0});const V=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!v.value),y=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":x.value.isDragging}));function C(_){l(_)}function D(_){c(_)}function k(_){p(_.clientId)}function T(_){u(_.clientId)}function F(_){}function A(_,X,W){if(!t.sortable||t.disabled)return;const ee=R(X,W);ee.onDragstart&&ee.onDragstart(_)}function P(_,X){if(!t.sortable||t.disabled)return;_.preventDefault();const W=i.value[X],ee=R(W,X);ee.onDragover&&ee.onDragover(_)}function O(_,X){const W=R(_,X);W.onDragend&&W.onDragend()}function B(_,X){_.preventDefault();const W=i.value[X],ee=R(W,X);ee.onDrop&&ee.onDrop(_)}return(_,X)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(y.value)},[e.renderSlot(_.$slots,"dropzone",{addFiles:e.unref(l)},()=>[V.value?(e.openBlock(),e.createBlock(bi,{key:0,accept:e.unref(f),multiple:_.maxItems!==1,disabled:_.disabled,"max-file-size":_.maxFileSize,"max-items":e.unref($),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),(W,ee)=>e.renderSlot(_.$slots,"item",{key:W.clientId,item:W,index:ee,remove:()=>D(W)},()=>[e.createElementVNode("div",{class:e.normalizeClass(["media-collection__item-wrapper",{"media-collection__item-wrapper--drag-over":e.unref(x).dropIndex===ee}]),draggable:_.sortable&&!_.disabled,"data-index":ee,onDragstart:he=>A(he,W,ee),onDragover:he=>P(he,ee),onDragend:he=>O(W,ee),onDrop:he=>B(he,ee)},[e.createVNode(wi,{item:W,adapter:e.unref(S),disabled:_.disabled,sortable:_.sortable,"show-remove":!_.readonly,"show-edit":!1,index:ee,onRemove:D,onRetry:k,onCancel:T,onEdit:F},null,8,["item","adapter","disabled","sortable","show-remove","index"])],42,B4)],!0)),128))],8,F4)):V.value?e.createCommentVNode("",!0):e.renderSlot(_.$slots,"empty",{key:1},()=>[X[0]||(X[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(h)},()=>[e.unref(i).length>0?(e.openBlock(),e.createElementBlock("div",I4,[e.createElementVNode("span",R4,[e.createTextVNode(e.toDisplayString(e.unref(w))+" "+e.toDisplayString(e.unref(w)===1?"file":"files")+" ",1),_.maxItems?(e.openBlock(),e.createElementBlock("span",P4," / "+e.toDisplayString(_.maxItems)+" max",1)):e.createCommentVNode("",!0)]),e.unref(h)?(e.openBlock(),e.createElementBlock("span",$4," 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(g),(W,ee)=>(e.openBlock(),e.createElementBlock("input",{key:`${_.name}-${W.uuid}`,type:"hidden",name:`${_.name}[${ee}][uuid]`,value:W.uuid},null,8,z4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),(W,ee)=>(e.openBlock(),e.createElementBlock("input",{key:`${_.name}-${W.uuid}-name`,type:"hidden",name:`${_.name}[${ee}][name]`,value:W.name},null,8,A4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),(W,ee)=>(e.openBlock(),e.createElementBlock("input",{key:`${_.name}-${W.uuid}-order`,type:"hidden",name:`${_.name}[${ee}][order]`,value:W.order},null,8,D4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),(W,ee)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${_.name}-${W.uuid}-props`},[W.custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${_.name}[${ee}][custom_properties]`,value:JSON.stringify(W.custom_properties)},null,8,U4)):e.createCommentVNode("",!0)],64))),128))],64)):e.createCommentVNode("",!0),e.unref(b).length>0?(e.openBlock(),e.createElementBlock("div",O4,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),W=>(e.openBlock(),e.createElementBlock("p",{key:W.code||W.message,class:"media-collection__error"},e.toDisplayString(W.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),W4=_e(L4,[["__scopeId","data-v-10a5bfff"]]);function ki(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:V=>{t==null||t(V[0]||null)},onUpload:r,onUploadComplete:i,onUploadError:s,onRemove:l,onError:c,onReadyToSubmitChange:d},h=Ga(m),v=e.computed(()=>h.items.value[0]||null),b=e.computed(()=>v.value!==null),x=e.computed(()=>h.formValues.value[0]||null);function R(V){V===null?h.clearAll():h.setItems([V])}async function S(V){const y=v.value;y&&h.removeItem(y),await h.addFiles([V])}function g(){v.value&&h.removeItem(v.value)}async function f(V){const y=v.value;y&&h.removeItem(y),await h.addFiles([V]);const C=h.items.value[0];C&&(a==null||a(y,C))}function w(){var V;(V=v.value)!=null&&V.upload&&h.cancelUpload(v.value.clientId)}async function $(){var V,y;((y=(V=v.value)==null?void 0:V.upload)==null?void 0:y.status)==="error"&&await h.retryUpload(v.value.clientId)}return{item:v,setItem:R,addFile:S,removeItem:g,replaceItem:f,cancelUpload:w,retryUpload:$,save:h.save,load:h.load,isLoading:h.isLoading,isUploading:h.isUploading,isReadyToSubmit:h.isReadyToSubmit,hasItem:b,errors:h.errors,adapter:h.adapter,formValue:x,acceptString:h.acceptString}}const j4=["accept","disabled"],X4={class:"media-attachment__preview"},Z4=["name","value"],Y4=["name","value"],G4=["name","value"],H4=["name","value"],J4={key:4,class:"media-attachment__errors",role:"alert","aria-live":"polite"},q4=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:k=>{a("update:modelValue",k),a("change",k)},onUpload:k=>{a("upload",k)},onUploadComplete:k=>{a("upload-complete",k)},onUploadError:k=>{a("upload-error",k)},onRemove:k=>{a("remove",k)},onReplace:(k,T)=>{a("replace",T)},onError:k=>{a("validation-error",k)},onReadyToSubmitChange:k=>{a("is-ready-to-submit-change",k)}},{item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:p,retryUpload:m,isLoading:h,hasItem:v,errors:b,adapter:x,formValue:R,acceptString:S}=ki(i);e.provide("mediaAdapter",x),e.watch(()=>t.modelValue,k=>{k!==s.value&&l(k)},{deep:!0});const g=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!v.value),f=e.computed(()=>({"media-attachment":!0,"media-attachment--disabled":t.disabled,"media-attachment--readonly":t.readonly,"media-attachment--loading":h.value,"media-attachment--has-item":v.value}));function w(k){k.length>0&&c(k[0])}function $(){var k;(k=r.value)==null||k.click()}function V(k){const T=k.target,F=T.files;F&&F.length>0&&u(F[0]),T.value=""}function y(k){d()}function C(k){m()}function D(k){p()}return(k,T)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(f.value)},[e.createElementVNode("input",{ref_key:"fileInputRef",ref:r,type:"file",accept:e.unref(S),disabled:k.disabled,class:"media-attachment__hidden-input",onChange:V},null,40,j4),g.value?e.renderSlot(k.$slots,"dropzone",{key:0,addFile:e.unref(c)},()=>[e.createVNode(bi,{accept:e.unref(S),multiple:!1,disabled:k.disabled,"max-file-size":k.maxFileSize,onFiles:w},null,8,["accept","disabled","max-file-size"])],!0):e.unref(v)&&e.unref(s)?e.renderSlot(k.$slots,"preview",{key:1,item:e.unref(s),remove:e.unref(d),replace:$},()=>[e.createElementVNode("div",X4,[e.createVNode(wi,{item:e.unref(s),adapter:e.unref(x),disabled:k.disabled,sortable:!1,"show-remove":!k.readonly,"show-edit":!1,onRemove:y,onRetry:C,onCancel:D},null,8,["item","adapter","disabled","show-remove"]),k.showReplaceButton&&!k.readonly&&!k.disabled&&e.unref(s).media?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-attachment__replace-button",onClick:$},[...T[0]||(T[0]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.createElementVNode("polyline",{points:"17 8 12 3 7 8"}),e.createElementVNode("line",{x1:"12",y1:"3",x2:"12",y2:"15"})],-1),e.createTextVNode(" Replace ",-1)])])):e.createCommentVNode("",!0)])],!0):e.renderSlot(k.$slots,"empty",{key:2},()=>[T[1]||(T[1]=e.createElementVNode("div",{class:"media-attachment__empty"},[e.createElementVNode("p",null,"No file selected")],-1))],!0),k.generateFormFields&&e.unref(R)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("input",{type:"hidden",name:`${k.name}[uuid]`,value:e.unref(R).uuid},null,8,Z4),e.createElementVNode("input",{type:"hidden",name:`${k.name}[name]`,value:e.unref(R).name},null,8,Y4),e.createElementVNode("input",{type:"hidden",name:`${k.name}[order]`,value:e.unref(R).order},null,8,G4),e.unref(R).custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${k.name}[custom_properties]`,value:JSON.stringify(e.unref(R).custom_properties)},null,8,H4)):e.createCommentVNode("",!0)],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),F=>(e.openBlock(),e.createElementBlock("p",{key:F.code||F.message,class:"media-attachment__error"},e.toDisplayString(F.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),K4=_e(q4,[["__scopeId","data-v-26911174"]]),Jc={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"}},Q4=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:k=>{r("update:modelValue",k),r("change",k)},onUpload:k=>{r("upload",k)},onUploadComplete:k=>{r("upload-complete",k)},onUploadError:k=>{r("upload-error",k)},onRemove:k=>{r("remove",k)},onReorder:k=>{r("reorder",k)},onError:k=>{r("validation-error",k)},onReadyToSubmitChange:k=>{r("is-ready-to-submit-change",k)}},{items:s,setItems:l,addFiles:c,removeItem:d,reorderItems:u,updateItem:p,cancelUpload:m,retryUpload:h,isLoading:v,isUploading:b,isReadyToSubmit:x,isAtMaxItems:R,errors:S,dragState:g,getDragProps:f,adapter:w,formValues:$,acceptString:V}=Ga(i);e.provide("mediaAdapter",w),e.provide("mediaCollection",{items:s,addFiles:c,removeItem:d,reorderItems:u}),e.watch(()=>a.modelValue,k=>{k!==s.value&&l(k)},{deep:!0});const y=e.computed(()=>({...Jc,...a.labels})),C=e.computed(()=>({accept:V.value,multiple:a.maxItems!==1,disabled:a.disabled||a.readonly||R.value})),D=e.computed(()=>({items:s.value,isLoading:v.value,isUploading:b.value,isReadyToSubmit:x.value,isAtMaxItems:R.value,errors:S.value,addFiles:c,removeItem:d,reorderItems:u,clearAll:()=>{s.value.forEach(k=>d(k))},cancelUpload:m,retryUpload:h,labels:y.value,dropzoneProps:C.value}));return o({items:s,addFiles:c,removeItem:d,reorderItems:u,updateItem:p,cancelUpload:m,retryUpload:h,isLoading:v,isUploading:b,isReadyToSubmit:x,isAtMaxItems:R,errors:S,dragState:g,getDragProps:f,adapter:w,formValues:$,acceptString:V}),(k,T)=>e.renderSlot(k.$slots,"default",e.normalizeProps(e.guardReactiveProps(D.value)))}}),e3=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:y=>{r("update:modelValue",y),r("change",y)},onUpload:y=>{r("upload",y)},onUploadComplete:y=>{r("upload-complete",y)},onUploadError:y=>{r("upload-error",y)},onRemove:y=>{r("remove",y)},onReplace:(y,C)=>{r("replace",C)},onError:y=>{r("validation-error",y)},onReadyToSubmitChange:y=>{r("is-ready-to-submit-change",y)}},{item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:p,retryUpload:m,isLoading:h,isUploading:v,isReadyToSubmit:b,hasItem:x,errors:R,adapter:S,formValue:g,acceptString:f}=ki(i);e.provide("mediaAdapter",S),e.watch(()=>a.modelValue,y=>{y!==s.value&&l(y)},{deep:!0});const w=e.computed(()=>({...Jc,...a.labels})),$=e.computed(()=>({accept:f.value,multiple:!1,disabled:a.disabled||a.readonly||x.value})),V=e.computed(()=>({item:s.value,hasItem:x.value,isLoading:h.value,isUploading:v.value,isReadyToSubmit:b.value,errors:R.value,addFile:c,removeItem:d,replaceItem:u,cancelUpload:p,retryUpload:m,labels:w.value,dropzoneProps:$.value}));return o({item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:p,retryUpload:m,isLoading:h,isUploading:v,isReadyToSubmit:b,hasItem:x,errors:R,adapter:S,formValue:g,acceptString:f}),(y,C)=>e.renderSlot(y.$slots,"default",e.normalizeProps(e.guardReactiveProps(V.value)))}}),t3=["name","value"],n3=["name","value"],o3=["name","value"],a3=["name","value"],r3=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(()=>fi(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,t3),e.createElementVNode("input",{type:"hidden",name:s(u,"name"),value:d.name},null,8,n3),e.createElementVNode("input",{type:"hidden",name:s(u,"order"),value:d.order},null,8,o3),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,a3)):e.createCommentVNode("",!0)],64))),128))}});exports.AlbumBrowser=Wc;exports.AlbumManager=AS;exports.AlbumMediaGrid=JS;exports.AlbumTree=Lc;exports.ArrayBufferTarget=Jr;exports.ImageEditor=El;exports.ImageEditorModal=Sl;exports.LiveStreamManager=uS;exports.ManagedMediaGallery=Xu;exports.MediaAttachment=K4;exports.MediaCollection=W4;exports.MediaCollectionDropzone=bi;exports.MediaCollectionItem=wi;exports.MediaWorkspace=Ou;exports.ModelMediaManager=Lp;exports.Muxer=Gl;exports.VideoEditor=Ac;exports.VideoEditorDialog=Gw;exports.VideoEditorSimple=y2;exports.VideoExportPanel=qk;exports.VideoJobClient=pi;exports.VideoPlayer=Dc;exports.VideoTimeline=L2;exports.VideoToolsPanel=Fk;exports.VideoUploader=Ax;exports._sfc_main=Q4;exports._sfc_main$1=e3;exports._sfc_main$2=r3;exports.applyTemporaryMediaStoreConfig=yl;exports.configureMediaStore=zn;exports.createAdapter=jc;exports.createMediablesAdapter=hi;exports.createSpatieAdapter=vi;exports.formatFileSize=ka;exports.fromMediaArray=jr;exports.getFileExtension=Xc;exports.getImageDimensions=Zc;exports.getMediablesAdapter=qS;exports.getSpatieAdapter=e4;exports.isImageFile=gi;exports.resetMediablesAdapter=KS;exports.resetSpatieAdapter=t4;exports.restoreMediaStoreConfig=gl;exports.snapshotMediaStoreConfig=vl;exports.toFormValues=fi;exports.useAdminMediaStore=bl;exports.useAlbumDragDrop=Oc;exports.useAlbumStore=Ya;exports.useAlbums=Uc;exports.useMediaAttachment=ki;exports.useMediaCollection=Ga;exports.useMediaDragSort=Hc;exports.useMediaStore=yt;exports.useMediaUploadQueue=Gc;exports.useMediaValidation=yi;exports.validateFile=Yc;
|
|
39
|
-
//# sourceMappingURL=index-DvFmBczx.cjs.map
|