@codingfactory/mediables-vue 2.18.3 → 2.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{PixiFrameExporter-YrJf3-l9.js → PixiFrameExporter-64httBgJ.js} +2 -2
- package/dist/{PixiFrameExporter-YrJf3-l9.js.map → PixiFrameExporter-64httBgJ.js.map} +1 -1
- package/dist/{PixiFrameExporter-DhAJGzIK.cjs → PixiFrameExporter-DkXTPJWn.cjs} +2 -2
- package/dist/{PixiFrameExporter-DhAJGzIK.cjs.map → PixiFrameExporter-DkXTPJWn.cjs.map} +1 -1
- package/dist/components/MediaAlbumPickerModal.vue.d.ts +6 -0
- package/dist/components/MediaFilterChips.vue.d.ts +10 -0
- package/dist/components/MediaInspectorPanel.vue.d.ts +13 -0
- package/dist/components/MediaLibraryShell.vue.d.ts +26 -0
- package/dist/components/MediaManagementView.vue.d.ts +1 -0
- package/dist/components/MediaTrashWorkspace.vue.d.ts +5 -0
- package/dist/composables/useMediaDeletion.d.ts +20 -0
- package/dist/composables/useMediaLibraryVisibility.d.ts +37 -0
- package/dist/composables/useMediaMetadata.d.ts +24 -0
- package/dist/editor-CiTXlIVO.js +4327 -0
- package/dist/editor-CiTXlIVO.js.map +1 -0
- package/dist/editor-P9MyuiTc.cjs +2 -0
- package/dist/editor-P9MyuiTc.cjs.map +1 -0
- package/dist/imageEditorState-BNQEZoCF.js +81 -0
- package/dist/imageEditorState-BNQEZoCF.js.map +1 -0
- package/dist/imageEditorState-PrcqbsfM.cjs +2 -0
- package/dist/imageEditorState-PrcqbsfM.cjs.map +1 -0
- package/dist/index-2jP5K__o.cjs +357 -0
- package/dist/index-2jP5K__o.cjs.map +1 -0
- package/dist/index-Dae8SHT7.js +6557 -0
- package/dist/index-Dae8SHT7.js.map +1 -0
- package/dist/{index-Dc-M8oj6.js → index-Dinl1Puu.js} +17147 -15638
- package/dist/index-Dinl1Puu.js.map +1 -0
- package/dist/index-QOKC8XA_.cjs +2 -0
- package/dist/index-QOKC8XA_.cjs.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/mediables-primitives.cjs +2 -0
- package/dist/mediables-primitives.cjs.map +1 -0
- package/dist/mediables-primitives.mjs +21 -0
- package/dist/mediables-primitives.mjs.map +1 -0
- package/dist/mediables-vanilla.cjs +1 -1
- package/dist/mediables-vanilla.mjs +8 -7
- package/dist/mediables-vanilla.mjs.map +1 -1
- package/dist/mediables-vue.cjs +1 -1
- package/dist/mediables-vue.mjs +74 -70
- package/dist/mediables-vue.mjs.map +1 -1
- package/dist/primitives-exports.d.ts +37 -0
- package/dist/style.css +1 -1
- package/dist/types/media.d.ts +2 -0
- package/dist/types/mediaLibraryPicker.d.ts +5 -0
- package/dist/utils/focus.d.ts +4 -0
- package/dist/vanilla-editor/core/EventEmitter.d.ts +8 -8
- package/dist/vanilla-editor/core/State.d.ts +441 -95
- package/package.json +8 -2
- package/dist/editor-D85y_zTO.cjs +0 -2
- package/dist/editor-D85y_zTO.cjs.map +0 -1
- package/dist/editor-DAJxTvzM.js +0 -10873
- package/dist/editor-DAJxTvzM.js.map +0 -1
- package/dist/index-BFrh53TT.cjs +0 -357
- package/dist/index-BFrh53TT.cjs.map +0 -1
- package/dist/index-Dc-M8oj6.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const he=require("pixi-filters"),me=require("pixi.js");function Q(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const i in t)if(i!=="default"){const r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:()=>t[i]})}}return e.default=t,Object.freeze(e)}const p=Q(he),b=Q(me);class J{constructor(){this._events=new Map}on(e,i){return this._events.has(e)||this._events.set(e,new Set),this._events.get(e).add(i),()=>this.off(e,i)}off(e,i){const r=this._events.get(e);r&&r.delete(i)}emit(e,...i){const r=this._events.get(e);r&&r.forEach(a=>{try{a(...i)}catch{}})}once(e,i){const r=(...a)=>{this.off(e,r),i(...a)};return this.on(e,r)}removeAllListeners(e){e?this._events.delete(e):this._events.clear()}}const ee=Object.freeze(["Inter","Arial","Helvetica","Georgia","Times New Roman","Courier New","Verdana"]),B=Object.freeze(["normal","multiply","screen","overlay"]),L=Object.freeze({x:.2,y:.2,width:.6,height:.18}),S=Object.freeze({fontFamily:"Inter",fontSize:64,fontWeight:700,fontStyle:"normal",fill:"#ffffff",align:"center",lineHeight:1.2,letterSpacing:0}),y=Object.freeze({stroke:Object.freeze({enabled:!1,color:"#000000",width:0}),shadow:Object.freeze({enabled:!1,color:"#000000",alpha:.5,blur:0,distance:0,angle:45}),glow:Object.freeze({enabled:!1,color:"#ffffff",alpha:.5,blur:0}),backdrop:Object.freeze({enabled:!1,color:"#000000",opacity:.5,padding:0,radius:0,blur:0})});class te extends J{constructor(){super(),this._state={hasImage:!1,imageUrl:null,mode:"filters",zoom:1,fitScale:1,activeFilters:new Set,filterValues:{},selectedFilter:null,selectedCategory:"adjust",crop:{shape:"free",aspect:"free",rect:null,dirty:!1},transform:{rotation:0},editorDocument:null,editorDocumentId:null,editorDocumentRevisionId:null,editorDocumentRevisionNumber:null,layers:[],activeLayerId:null,theme:"auto",isDarkMode:!1,backgroundRemovalAvailable:!1,isProcessing:!1,isSaving:!1}}get(e){if(e.includes(".")){const i=e.split(".");let r=this._state;for(const a of i){if(r==null)return;r=r[a]}return r}return this._state[e]}set(e,i){const r=this.get(e);if(e.includes(".")){const a=e.split("."),s=a.pop();let n=this._state;for(const l of a)n[l]===void 0&&(n[l]={}),n=n[l];n[s]=i}else this._state[e]=i;this.emit(`change:${e}`,{value:i,old:r}),this.emit("change",{key:e,value:i,old:r})}getAll(){return{...this._state}}_clonePlain(e){return e==null?e:JSON.parse(JSON.stringify(e))}getSerializableState(){var r;const e=[];if(this._state.activeFilters)for(const a of this._state.activeFilters){const s=this._state.filterValues[a];e.push({id:a,enabled:!0,values:s?{...s}:{}})}const i=this._state.crop;return{version:1,crop:{rect:i!=null&&i.rect?{...i.rect}:null,aspectRatio:(i==null?void 0:i.aspect)||"free",shape:(i==null?void 0:i.shape)||"free"},transform:{rotation:Number((r=this._state.transform)==null?void 0:r.rotation)||0},filters:e}}setEditorDocument(e,i={}){var n;if(!e||e.version!==2||!Array.isArray(e.layers)){this.clearEditorDocument();return}const r=this._clonePlain(e),a=this._clonePlain(r.layers).map(l=>this._normalizeLayerForState(l)),s=typeof r.activeLayerId=="string"?r.activeLayerId:((n=a[0])==null?void 0:n.id)??null;this._state.editorDocument={...r,layers:a,activeLayerId:s},this._state.editorDocumentId=i.documentId??r.id??null,this._state.editorDocumentRevisionId=i.documentRevisionId??null,this._state.editorDocumentRevisionNumber=i.documentRevisionNumber??r.revision??null,this._state.layers=a,this._state.activeLayerId=s,this.emit("change:editorDocument",{value:this.getSerializableDocument()}),this.emit("change:layers",{value:this._clonePlain(a)}),this.emit("change:activeLayerId",{value:s}),this._syncFilterStateFromActiveLayer()}clearEditorDocument(){this._state.editorDocument=null,this._state.editorDocumentId=null,this._state.editorDocumentRevisionId=null,this._state.editorDocumentRevisionNumber=null,this._state.layers=[],this._state.activeLayerId=null,this._state.activeFilters=new Set,this._state.filterValues={},this._state.selectedFilter=null,this.emit("change:editorDocument",{value:null}),this.emit("change:layers",{value:[]}),this.emit("change:activeLayerId",{value:null}),this.emit("change:activeFilters",{value:this._state.activeFilters}),this.emit("change:filterValues",this._state.filterValues),this.emit("change:selectedFilter",{value:null})}getSerializableDocument(){var r;if(!this._state.editorDocument)return null;const e=this._clonePlain(this._state.editorDocument);e.layers=this._clonePlain(this._state.layers),e.activeLayerId=this._state.activeLayerId;const i=e.layers.findIndex(a=>a&&(a.role==="subject"||a.type==="image"&&a.role!=="overlay"));if(i!==-1){const a=e.layers[i],s=this._normalizeDegrees(((r=this._state.transform)==null?void 0:r.rotation)??0),n=a.transform&&typeof a.transform=="object"?a.transform:{x:0,y:0,scaleX:1,scaleY:1,rotation:0};a.transform={...n,rotation:s};const l=this._state.crop&&typeof this._state.crop=="object"?this._state.crop:null,o=l!=null&&l.appliedRect&&typeof l.appliedRect=="object"?l.appliedRect:null;o&&(a.crop={rect:{...o},shape:l.appliedShape||"free",aspect:l.appliedAspect||"free"}),e.layers[i]=a}return e}getEditorDocumentBinding(){return this._state.editorDocument?{documentId:this._state.editorDocumentId,documentRevisionId:this._state.editorDocumentRevisionId,documentRevisionNumber:this._state.editorDocumentRevisionNumber}:null}_findLayerIndex(e){return this._state.layers.findIndex(i=>(i==null?void 0:i.id)===e)}_layerLocked(e){return(e==null?void 0:e.locked)===!0}_backgroundLayerLocked(e=this._state.layers){const i=this._backgroundLayerIndex(e);return i!==-1&&this._layerLocked(e[i])}isBackgroundLayerLocked(){return this._backgroundLayerLocked()}_uniqueLayerId(e){const i=new Set(this._state.layers.map(a=>a==null?void 0:a.id).filter(Boolean)),r=String(e||"layer").replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"layer";if(!i.has(r))return r;for(let a=2;a<1e4;a+=1){const s=`${r}-${a}`;if(!i.has(s))return s}return`${r}-${Date.now()}`}_normalizeLayerForState(e){return!e||typeof e!="object"?e:e.type!=="text"&&e.role!=="text"?{...e,filters:this._normalizeLayerFilters(e.filters)}:this._normalizeTextLayer({...e,id:typeof e.id=="string"&&e.id.trim()!==""?e.id:this._uniqueLayerId("text-layer"),name:typeof e.name=="string"&&e.name.trim()!==""?e.name:"Text"},e)}_normalizeLayerFilters(e){return Array.isArray(e)?e.filter(i=>i&&typeof i=="object"&&typeof i.id=="string"&&i.id.trim()!=="").map(i=>({id:i.id.trim(),enabled:i.enabled!==!1,values:i.values&&typeof i.values=="object"?this._clonePlain(i.values):{}})):[]}_layerSupportsFilters(e){var i;return!e||typeof e!="object"?!1:e.type==="image"?!0:e.type==="background"||e.role==="background"?((i=e.fill)==null?void 0:i.kind)==="media":!1}_activeFilterLayerIndex(){const e=this._state.activeLayerId;if(!e||!Array.isArray(this._state.layers))return-1;const i=this._findLayerIndex(e);return i!==-1&&this._layerSupportsFilters(this._state.layers[i])?i:-1}getActiveFilterLayerId(){var i;const e=this._activeFilterLayerIndex();return e!==-1?((i=this._state.layers[e])==null?void 0:i.id)??null:null}_matchesExpectedFilterLayer(e){if(!this._state.editorDocument||e===void 0)return!0;if(e===null)return this.getActiveFilterLayerId()===null;const i=typeof e=="string"?e.trim():"";return i===""?!1:this.getActiveFilterLayerId()===i}_syncFilterStateFromActiveLayer(){var s;if(!this._state.editorDocument)return;const e=this._activeFilterLayerIndex(),i=new Set,r={};if(e!==-1)for(const n of this._normalizeLayerFilters((s=this._state.layers[e])==null?void 0:s.filters))n.enabled!==!1&&(i.add(n.id),r[n.id]=this._clonePlain(n.values||{}));const a=this._state.selectedFilter;this._state.activeFilters=i,this._state.filterValues=r,a&&!i.has(a)&&(this._state.selectedFilter=null),this.emit("change:activeFilters",{value:this._state.activeFilters}),this.emit("change:filterValues",this._state.filterValues),this._state.selectedFilter!==a&&this.emit("change:selectedFilter",{value:this._state.selectedFilter,old:a})}_clampNumber(e,i,r,a){const s=Number(e);return Number.isFinite(s)?Math.max(i,Math.min(r,s)):a}_normalizeDegrees(e){const i=Number(e);if(!Number.isFinite(i))return 0;const r=i%360;return r<0?r+360:r}_isSupportedTextColor(e){return typeof e=="string"&&/^#[0-9a-f]{6}$/i.test(e)}_normalizeTextColor(e,i){return this._isSupportedTextColor(e)?e:this._isSupportedTextColor(i)?i:"#000000"}_normalizeBoolean(e,i=!1){return typeof e=="boolean"?e:i===!0}_normalizeBlendMode(e,i="normal"){return B.includes(e)?e:B.includes(i)?i:"normal"}_normalizeTextFontFamily(e){const i=typeof e=="string"?e.trim():"";return ee.includes(i)?i:S.fontFamily}_normalizeTextFontWeight(e,i=S.fontWeight){if(e==="normal")return 400;if(e==="bold")return 700;const r=Number(e);return!Number.isFinite(r)||r<100||r>900||r%100!==0?i:r}_normalizeTextBox(e,i=null){const r=i&&typeof i=="object"?i:L,a=e&&typeof e=="object"?e:{};return{x:this._clampNumber(a.x,0,1,this._clampNumber(r.x,0,1,L.x)),y:this._clampNumber(a.y,0,1,this._clampNumber(r.y,0,1,L.y)),width:this._clampNumber(a.width,.05,1,this._clampNumber(r.width,.05,1,L.width)),height:this._clampNumber(a.height,.05,1,this._clampNumber(r.height,.05,1,L.height))}}_normalizeTextStyle(e,i=null){const r={...S,...i&&typeof i=="object"?i:{}},a=e&&typeof e=="object"?e:{},n=!!a.fontSource||!!a.source||!!a.url?S.fontFamily:this._normalizeTextFontFamily(a.fontFamily??r.fontFamily),l=["normal","italic"].includes(a.fontStyle)?a.fontStyle:["normal","italic"].includes(r.fontStyle)?r.fontStyle:S.fontStyle,o=["left","center","right"].includes(a.align)?a.align:["left","center","right"].includes(r.align)?r.align:S.align,c=this._isSupportedTextColor(a.fill)?a.fill:this._isSupportedTextColor(r.fill)?r.fill:S.fill;return{fontFamily:n,fontSize:this._clampNumber(a.fontSize,8,400,this._clampNumber(r.fontSize,8,400,S.fontSize)),fontWeight:this._normalizeTextFontWeight(a.fontWeight,this._normalizeTextFontWeight(r.fontWeight,S.fontWeight)),fontStyle:l,fill:c,align:o,lineHeight:this._clampNumber(a.lineHeight,.8,3,this._clampNumber(r.lineHeight,.8,3,S.lineHeight)),letterSpacing:this._clampNumber(a.letterSpacing,-100,100,this._clampNumber(r.letterSpacing,-100,100,S.letterSpacing))}}_normalizeTextEffects(e,i=null){const r=e&&typeof e=="object"?e:{},a=i&&typeof i=="object"?i:{},s={stroke:{...y.stroke,...a.stroke&&typeof a.stroke=="object"?a.stroke:{}},shadow:{...y.shadow,...a.shadow&&typeof a.shadow=="object"?a.shadow:{}},glow:{...y.glow,...a.glow&&typeof a.glow=="object"?a.glow:{}},backdrop:{...y.backdrop,...a.backdrop&&typeof a.backdrop=="object"?a.backdrop:{}}},n=r.stroke&&typeof r.stroke=="object"?r.stroke:{},l=r.shadow&&typeof r.shadow=="object"?r.shadow:{},o=r.glow&&typeof r.glow=="object"?r.glow:{},c=r.backdrop&&typeof r.backdrop=="object"?r.backdrop:{};return{stroke:{enabled:this._normalizeBoolean(n.enabled,s.stroke.enabled),color:this._normalizeTextColor(n.color,s.stroke.color),width:this._clampNumber(n.width,0,80,this._clampNumber(s.stroke.width,0,80,y.stroke.width))},shadow:{enabled:this._normalizeBoolean(l.enabled,s.shadow.enabled),color:this._normalizeTextColor(l.color,s.shadow.color),alpha:this._clampNumber(l.alpha,0,1,this._clampNumber(s.shadow.alpha,0,1,y.shadow.alpha)),blur:this._clampNumber(l.blur,0,120,this._clampNumber(s.shadow.blur,0,120,y.shadow.blur)),distance:this._clampNumber(l.distance,0,200,this._clampNumber(s.shadow.distance,0,200,y.shadow.distance)),angle:this._normalizeDegrees(l.angle??s.shadow.angle??y.shadow.angle)},glow:{enabled:this._normalizeBoolean(o.enabled,s.glow.enabled),color:this._normalizeTextColor(o.color,s.glow.color),alpha:this._clampNumber(o.alpha,0,1,this._clampNumber(s.glow.alpha,0,1,y.glow.alpha)),blur:this._clampNumber(o.blur,0,120,this._clampNumber(s.glow.blur,0,120,y.glow.blur))},backdrop:{enabled:this._normalizeBoolean(c.enabled,s.backdrop.enabled),color:this._normalizeTextColor(c.color,s.backdrop.color),opacity:this._clampNumber(c.opacity,0,1,this._clampNumber(s.backdrop.opacity,0,1,y.backdrop.opacity)),padding:this._clampNumber(c.padding,0,200,this._clampNumber(s.backdrop.padding,0,200,y.backdrop.padding)),radius:this._clampNumber(c.radius,0,200,this._clampNumber(s.backdrop.radius,0,200,y.backdrop.radius)),blur:this._clampNumber(c.blur,0,80,this._clampNumber(s.backdrop.blur,0,80,y.backdrop.blur))}}}_normalizeLayerTransform(e,i=null){const r=i&&typeof i=="object"?i:{},a=e&&typeof e=="object"?e:{};return{x:this._clampNumber(a.x,-1e5,1e5,this._clampNumber(r.x,-1e5,1e5,0)),y:this._clampNumber(a.y,-1e5,1e5,this._clampNumber(r.y,-1e5,1e5,0)),scaleX:this._clampNumber(a.scaleX,.01,100,this._clampNumber(r.scaleX,.01,100,1)),scaleY:this._clampNumber(a.scaleY,.01,100,this._clampNumber(r.scaleY,.01,100,1)),rotation:this._normalizeDegrees(a.rotation??r.rotation??0)}}_normalizeTextPayload(e={},i=null){var c,u,d,h;const r=e&&typeof e=="object"?e:{},a=i!=null&&i.text&&typeof i.text=="object"?i.text:i,s=r.content??((c=r.text)==null?void 0:c.content)??(a==null?void 0:a.content)??"Add text",n=r.box??((u=r.text)==null?void 0:u.box),l=r.style??((d=r.text)==null?void 0:d.style),o=((h=r.text)==null?void 0:h.effects)??(r.effects&&!Array.isArray(r.effects)?r.effects:void 0);return{content:s==null?"":String(s),box:this._normalizeTextBox(n,a==null?void 0:a.box),style:this._normalizeTextStyle(l,a==null?void 0:a.style),effects:this._normalizeTextEffects(o,a==null?void 0:a.effects)}}_normalizeTextLayer(e={},i=null){const r=e&&typeof e=="object"?e:{};return{id:typeof r.id=="string"&&r.id.trim()!==""?r.id:this._uniqueLayerId("text-layer"),type:"text",role:"text",name:typeof r.name=="string"&&r.name.trim()!==""?r.name.trim():"Text",visible:r.visible!==!1,locked:r.locked===!0,opacity:this._clampNumber(r.opacity,0,1,1),blendMode:this._normalizeBlendMode(r.blendMode,i==null?void 0:i.blendMode),transform:this._normalizeLayerTransform(r.transform,i==null?void 0:i.transform),effects:Array.isArray(r.effects)?this._clonePlain(r.effects):[],metadata:r.metadata&&typeof r.metadata=="object"?this._clonePlain(r.metadata):{},text:this._normalizeTextPayload(r,i),crop:null,filters:Array.isArray(r.filters)?this._clonePlain(r.filters):[]}}_nearestEditableLayerId(e,i){var r,a;if(!e.length)return null;for(let s=0;s<e.length;s+=1){const n=i+s;if(n<e.length&&!this._layerLocked(e[n])&&((r=e[n])==null?void 0:r.visible)!==!1)return e[n].id??null;const l=i-s-1;if(l>=0&&!this._layerLocked(e[l])&&((a=e[l])==null?void 0:a.visible)!==!1)return e[l].id??null}return null}_moveCrossesLockedLayer(e,i,r){const a=Math.min(i,r),s=Math.max(i,r);for(let n=a;n<=s;n+=1)if(n!==i&&this._layerLocked(e[n]))return!0;return!1}getLayer(e){const i=this._state.layers.find(r=>(r==null?void 0:r.id)===e);return i?this._clonePlain(i):null}setActiveLayer(e){if(e!==null&&this._findLayerIndex(e)===-1)return!1;const i=this._state.activeLayerId;return this._state.activeLayerId=e,this._state.editorDocument&&(this._state.editorDocument.activeLayerId=e),this.emit("change:activeLayerId",{value:e,old:i}),this._syncFilterStateFromActiveLayer(),!0}isActiveLayerLocked(){const e=this._state.activeLayerId;if(!e)return!1;const i=this._state.layers.find(r=>(r==null?void 0:r.id)===e);return!!(i!=null&&i.locked)}setLayerVisibility(e,i){const r=this._findLayerIndex(e);if(r===-1)return!1;const a=this._clonePlain(this._state.layers);return this._layerLocked(a[r])?!1:(a[r].visible=!!i,this._state.layers=a,this._state.editorDocument&&(this._state.editorDocument.layers=this._clonePlain(a)),this.emit("change:layers",{value:this._clonePlain(a)}),this.emit("change:layerVisibility",{layerId:e,visible:!!i}),!0)}renameLayer(e,i){const r=this._findLayerIndex(e);if(r===-1)return!1;const a=this._clonePlain(this._state.layers);if(this._layerLocked(a[r]))return!1;const s=String(i??"").trim();if(s==="")return!1;const n=a[r].name??"";return a[r].name=s,this._commitLayers(a,"change:layerRenamed",{layerId:e,name:s,oldName:n}),!0}duplicateLayer(e){const i=this._findLayerIndex(e);if(i===-1)return null;const r=this._clonePlain(this._state.layers),a=r[i];if(this._layerLocked(a))return null;const s=this._clonePlain(a);s.id=this._uniqueLayerId(`${a.id||"layer"}-copy`),s.name=`${String(a.name||"Layer").trim()||"Layer"} copy`,s.locked=!1,s.metadata={...s.metadata&&typeof s.metadata=="object"?s.metadata:{},duplicatedFromLayerId:a.id??null,duplicatedAt:new Date().toISOString()},r.splice(i+1,0,s);const n=this._state.activeLayerId;return this._state.activeLayerId=s.id,this._state.editorDocument&&(this._state.editorDocument.activeLayerId=s.id),this._commitLayers(r,"change:layerDuplicated",{layerId:e,duplicateLayerId:s.id}),this.emit("change:activeLayerId",{value:s.id,old:n}),s.id}deleteLayer(e){const i=this._findLayerIndex(e);if(i===-1||this._state.layers.length<=1)return!1;const r=this._clonePlain(this._state.layers);if(this._layerLocked(r[i]))return!1;const[a]=r.splice(i,1);let s=this._state.activeLayerId;if(s===e||!r.some(n=>(n==null?void 0:n.id)===s)){s=this._nearestEditableLayerId(r,i);const n=this._state.activeLayerId;this._state.activeLayerId=s,this._state.editorDocument&&(this._state.editorDocument.activeLayerId=s),this.emit("change:activeLayerId",{value:s,old:n})}return this._commitLayers(r,"change:layerDeleted",{layerId:(a==null?void 0:a.id)??e}),!0}moveLayer(e,i){const r=this._findLayerIndex(e);if(r===-1)return!1;const a=this._clonePlain(this._state.layers);if(this._layerLocked(a[r]))return!1;let s=r;switch(i){case"up":case"bring-forward":s=Math.min(a.length-1,r+1);break;case"down":case"send-backward":s=Math.max(0,r-1);break;case"front":case"bring-to-front":s=a.length-1;break;case"back":case"send-to-back":s=0;break;default:return!1}if(s===r||this._moveCrossesLockedLayer(a,r,s))return!1;const[n]=a.splice(r,1);return a.splice(s,0,n),this._commitLayers(a,"change:layerMoved",{layerId:e,fromIndex:r,toIndex:s,direction:i}),!0}setLayerLocked(e,i){const r=this._findLayerIndex(e);if(r===-1)return!1;const a=this._clonePlain(this._state.layers);return a[r].locked=!!i,this._state.layers=a,this._state.editorDocument&&(this._state.editorDocument.layers=this._clonePlain(a)),this.emit("change:layers",{value:this._clonePlain(a)}),this.emit("change:layerLocked",{layerId:e,locked:!!i}),!0}replaceLayerSource(e,i){const r=this._findLayerIndex(e);if(r===-1||!i||typeof i!="object")return!1;const a=this._clonePlain(this._state.layers);return this._layerLocked(a[r])?!1:(a[r].source=this._clonePlain(i),this._state.layers=a,this._state.editorDocument&&(this._state.editorDocument.layers=this._clonePlain(a),this._state.editorDocument.updatedAt=new Date().toISOString()),this.emit("change:layers",{value:this._clonePlain(a)}),this.emit("change:layerSource",{layerId:e,source:this._clonePlain(i)}),!0)}addTextLayer(e={}){if(!this._state.editorDocument||!Array.isArray(this._state.layers))return null;const i=this._clonePlain(this._state.layers),r=this._normalizeTextLayer({...e&&typeof e=="object"?e:{},id:this._uniqueLayerId((e==null?void 0:e.id)||"text-layer")});i.push(r);const a=this._state.activeLayerId;return this._state.activeLayerId=r.id,this._state.editorDocument&&(this._state.editorDocument.activeLayerId=r.id),this._commitLayers(i,"change:textLayer",{action:"created",layerId:r.id}),this.emit("change:activeLayerId",{value:r.id,old:a}),r.id}updateTextLayer(e,i={}){var o;const r=this._findLayerIndex(e);if(r===-1||!i||typeof i!="object")return!1;const a=this._clonePlain(this._state.layers),s=a[r];if(this._layerLocked(s)||s.type!=="text"&&s.role!=="text")return!1;const n=i.text&&typeof i.text=="object"?i.text:{},l=this._normalizeTextLayer({...s,transform:i.transform&&typeof i.transform=="object"?{...s.transform,...i.transform}:s.transform,text:{...s.text&&typeof s.text=="object"?s.text:{},...n,..."content"in i?{content:i.content}:{},..."box"in i?{box:i.box}:{},..."style"in i?{style:{...((o=s.text)==null?void 0:o.style)||{},...i.style||{}}}:{},..."effects"in i?{effects:i.effects}:{}},...i.name!==void 0?{name:i.name}:{},...i.opacity!==void 0?{opacity:i.opacity}:{},...i.blendMode!==void 0?{blendMode:i.blendMode}:{}},s);return a[r]=l,this._commitLayers(a,"change:textLayer",{action:"updated",layerId:e,text:this._clonePlain(l.text)}),!0}_commitLayers(e,i=null,r={}){this._state.layers=e,this._state.editorDocument&&(this._state.editorDocument.layers=this._clonePlain(e),this._state.editorDocument.updatedAt=new Date().toISOString()),this.emit("change:layers",{value:this._clonePlain(e)}),i&&this.emit(i,r)}_backgroundLayerIndex(e=this._state.layers){return e.findIndex(i=>(i==null?void 0:i.type)==="background"||(i==null?void 0:i.role)==="background")}_defaultBackgroundLayer(e={kind:"transparent"}){const i=new Set(this._state.layers.map(a=>a==null?void 0:a.id).filter(Boolean));let r="background-layer";return i.has(r)&&(r=`background-layer-${Date.now()}`),{id:r,type:"background",role:"background",name:"Background",visible:!0,locked:!1,opacity:1,blendMode:"normal",transform:{x:0,y:0,scaleX:1,scaleY:1,rotation:0},effects:[],metadata:{},fill:this._clonePlain(e),crop:null,filters:[]}}_normalizeBackgroundFill(e){if(!e||typeof e!="object")return{kind:"transparent"};const i=["cover","contain","stretch","tile"].includes(e.fit)?e.fit:void 0;if(e.kind==="color")return{kind:"color",value:typeof e.value=="string"?e.value:typeof e.color=="string"?e.color:"#ffffff",...i?{fit:i}:{}};if(e.kind==="gradient"){const r=Array.isArray(e.stops)&&e.stops.length>0?e.stops.filter(a=>a&&typeof a=="object"&&typeof a.color=="string").map(a=>({offset:Number.isFinite(Number(a.offset))?Math.max(0,Math.min(1,Number(a.offset))):0,color:a.color})):[{offset:0,color:"#111827"},{offset:1,color:"#f59e0b"}];return{kind:"gradient",gradientType:["linear","radial"].includes(e.gradientType)?e.gradientType:"linear",angle:Number.isFinite(Number(e.angle))?Number(e.angle):135,stops:r,fit:i||"cover"}}return e.kind==="media"&&e.source&&typeof e.source=="object"?{kind:"media",source:this._clonePlain(e.source),fit:i||"cover"}:{kind:"transparent"}}ensureBackgroundLayer(e={kind:"transparent"}){const i=this._clonePlain(this._state.layers),r=this._backgroundLayerIndex(i);if(r!==-1)return this._layerLocked(i[r])?null:i[r].id;const a=this._defaultBackgroundLayer(this._normalizeBackgroundFill(e)),s=i.findIndex(l=>(l==null?void 0:l.role)==="subject"||(l==null?void 0:l.type)==="image"),n=s>=0?s:0;return i.splice(n,0,a),this._commitLayers(i,"change:backgroundLayer",{layerId:a.id,action:"created"}),a.id}setBackgroundFill(e){var l;const i=this._normalizeBackgroundFill(e),r=this.ensureBackgroundLayer(i);if(!r)return null;const a=this._clonePlain(this._state.layers),s=this._backgroundLayerIndex(a);if(s===-1||this._layerLocked(a[s]))return null;const n=(l=a[s].fill)==null?void 0:l.fit;return a[s].fill=this._clonePlain({...i,...!i.fit&&n&&i.kind!=="transparent"?{fit:n}:{}}),this._commitLayers(a,"change:backgroundFill",{layerId:r,fill:this._clonePlain(a[s].fill)}),r}setBackgroundFit(e){if(!["cover","contain","stretch","tile"].includes(e))return!1;const i=this.ensureBackgroundLayer();if(!i)return!1;const r=this._clonePlain(this._state.layers),a=this._backgroundLayerIndex(r);if(a===-1||this._layerLocked(r[a]))return!1;const s=r[a].fill&&typeof r[a].fill=="object"?r[a].fill:{kind:"transparent"};return r[a].fill={...s,fit:e},this._commitLayers(r,"change:backgroundFit",{layerId:i,fit:e}),!0}setBackgroundBlur(e){const i=Number.isFinite(Number(e))?Math.max(0,Math.min(100,Number(e))):0,r=this.ensureBackgroundLayer();if(!r)return!1;const a=this._clonePlain(this._state.layers),s=this._backgroundLayerIndex(a);if(s===-1||this._layerLocked(a[s]))return!1;const n=Array.isArray(a[s].effects)?a[s].effects.filter(l=>(l==null?void 0:l.id)!=="background-blur"):[];return i>0&&n.push({id:"background-blur",type:"blur",params:{amount:i}}),a[s].effects=n,this._commitLayers(a,"change:backgroundBlur",{layerId:r,amount:i}),!0}removeBackgroundLayer(){const e=this._clonePlain(this._state.layers),i=this._backgroundLayerIndex(e);if(i===-1||this._layerLocked(e[i]))return!1;const[r]=e.splice(i,1);if(r!=null&&r.id&&this._state.activeLayerId===r.id){const a=this._nearestEditableLayerId(e,i);this._state.activeLayerId=a,this._state.editorDocument&&(this._state.editorDocument.activeLayerId=a),this.emit("change:activeLayerId",{value:a,old:r.id})}return this._commitLayers(e,"change:backgroundLayer",{layerId:(r==null?void 0:r.id)??null,action:"removed"}),!0}toggleFilter(e,i,r=void 0){if(this._state.editorDocument){if(!this._matchesExpectedFilterLayer(r))return!1;const s=this._activeFilterLayerIndex();if(s===-1)return this._syncFilterStateFromActiveLayer(),!1;const n=typeof e=="string"?e.trim():"";if(n==="")return!1;const l=this._clonePlain(this._state.layers),o=l[s],c=this._normalizeLayerFilters(o.filters),u=c.findIndex(d=>d.id===n);return i?u===-1?c.push({id:n,enabled:!0,values:{}}):c[u].enabled=!0:u!==-1&&c.splice(u,1),o.filters=c,this._commitLayers(l,"change:layerFilters",{layerId:o.id,filterId:n,enabled:!!i}),this._syncFilterStateFromActiveLayer(),!0}const a=new Set(this._state.activeFilters);return i?a.add(e):(a.delete(e),delete this._state.filterValues[e]),this.set("activeFilters",a),!0}setFilterValue(e,i,r,a=void 0){var s,n;if(this._state.editorDocument){if(!this._matchesExpectedFilterLayer(a))return!1;const l=this._activeFilterLayerIndex();if(l===-1)return this._syncFilterStateFromActiveLayer(),!1;const o=typeof e=="string"?e.trim():"";if(o===""||!((n=(s=this._state.activeFilters)==null?void 0:s.has)!=null&&n.call(s,o)))return!1;const c=this._clonePlain(this._state.layers),u=c[l],d=this._normalizeLayerFilters(u.filters),h=d.findIndex(m=>m.id===o&&m.enabled!==!1);return h===-1?!1:(d[h].values={...d[h].values&&typeof d[h].values=="object"?d[h].values:{},[i]:this._clonePlain(r)},u.filters=d,this._commitLayers(c,"change:layerFilters",{layerId:u.id,filterId:o,controlId:i,value:this._clonePlain(r)}),this._syncFilterStateFromActiveLayer(),this.emit("change:filterValue",{filterId:o,controlId:i,value:r}),!0)}return this._state.filterValues[e]||(this._state.filterValues[e]={}),this._state.filterValues[e][i]=r,this.emit("change:filterValue",{filterId:e,controlId:i,value:r}),this.emit("change:filterValues",this._state.filterValues),!0}getFilterValues(e){return this._state.filterValues[e]||{}}initFilterValues(e,i,r=void 0){if(this._state.editorDocument){if(!this._matchesExpectedFilterLayer(r))return!1;const a=this.getFilterValues(e);return i.forEach(s=>{s.id in a||this.setFilterValue(e,s.id,s.default,r)}),!0}return this._state.filterValues[e]||(this._state.filterValues[e]={}),i.forEach(a=>{a.id in this._state.filterValues[e]||(this._state.filterValues[e][a.id]=a.default)}),this.emit("change:filterValues",this._state.filterValues),!0}resetFilters(e=void 0){if(this._state.editorDocument){if(!this._matchesExpectedFilterLayer(e))return!1;const i=this._activeFilterLayerIndex();if(i===-1)return this._syncFilterStateFromActiveLayer(),this.emit("filtersReset"),!1;const r=this._clonePlain(this._state.layers);return r[i].filters=[],this._commitLayers(r,"change:layerFilters",{layerId:r[i].id,action:"reset"}),this._syncFilterStateFromActiveLayer(),this.emit("filtersReset"),!0}return this._state.activeFilters=new Set,this._state.filterValues={},this._state.selectedFilter=null,this.emit("change:activeFilters",{value:this._state.activeFilters}),this.emit("change:filterValues",this._state.filterValues),this.emit("change:selectedFilter",{value:null}),this.emit("filtersReset"),!0}detectTheme(){if(this._state.theme==="auto"){const e=window.matchMedia("(prefers-color-scheme: dark)").matches;this.set("isDarkMode",e)}else this.set("isDarkMode",this._state.theme==="dark")}}function fe(){return new te}const _=new Map,k=new Map;function pe(t,e){return!Array.isArray(t.mediaTargets)||t.mediaTargets.length===0?!0:t.mediaTargets.includes(e)}function f(t){var e;return _.has(t.id),_.set(t.id,t),k.has(t.category)||k.set(t.category,[]),(e=k.get(t.category))==null||e.push(t.id),t}function re(t){return _.get(t)}function I(){return Array.from(_.values())}function ie(){I().map(i=>i.id),Object.entries(p).filter(i=>/Filter$/.test(i[0])&&typeof i[1]=="function").forEach(([i,r])=>{const a=i.replace(/Filter$/,"").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();_.has(a)||f({id:a,name:i.replace(/Filter$/,""),category:"unlisted",mediaTargets:["image"],defaultParams:{},controls:[],createFilter:(s={})=>{try{return new r(s)}catch{return null}}})})}function ae(t){return(k.get(t)||[]).map(i=>_.get(i)).filter(Boolean)}function se(){return Array.from(k.keys())}function ge(t){return _.has(t)}function ne(t){const e=_.get(t);if(!e)return!1;_.delete(t);const i=k.get(e.category);if(i){const r=i.indexOf(t);r!==-1&&i.splice(r,1),i.length===0&&k.delete(e.category)}return!0}function ye(t,e){const i=_.get(t);return i?pe(i,e):!1}function le(){return Array.from(_.values()).map(t=>({id:t.id,name:t.name,category:t.category,controls:t.controls}))}if(typeof window<"u"){window.__DEBUG_FILTERS_LIST=Array.from(_.keys()),window.getAllFilters=I,window.getFilter=re,window.getFiltersByCategory=ae,window.getRegisteredFilters=le;const t=f;window.registerFilter=e=>{const i=t(e);return window.__DEBUG_FILTERS_LIST=Array.from(_.keys()),i}}typeof window<"u"&&(window.initializeFilterRegistry=window.initializeFilterRegistry||function(){return[]});const{AdjustmentFilter:be}=p,{ColorMatrixFilter:xe}=b,P={gamma:1,saturation:1,contrast:1,brightness:1,red:1,green:1,blue:1,alpha:1},_e=new Set(["gamma","saturation","contrast","brightness","red","green","blue","alpha"]);function F(t,e){if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"){const i=Number(t);if(Number.isFinite(i))return i}return e}function D(t){return _e.has(t)}function Se(t){return{gamma:F(t.gamma,P.gamma),saturation:F(t.saturation,P.saturation),contrast:F(t.contrast,P.contrast),brightness:F(t.brightness,P.brightness),red:F(t.red,P.red),green:F(t.green,P.green),blue:F(t.blue,P.blue),alpha:F(t.alpha,P.alpha)}}function E(t,e){t.reset(),t.brightness(e.brightness,!0),t.contrast(e.contrast,!0),t.saturate(e.saturation,!0)}f({id:"adjustment",name:"Adjustment",category:"adjust",description:"Adjust basic image properties like brightness, contrast, and saturation",createFilter:t=>{try{const e=Se(t??{}),i={...e};try{const r=new be(i),a=r;return a._customParams={...e},a.updateUIParam=function(n,l){try{if(!D(n))return;const o=this._customParams??{...P},c=F(l,o[n]);o[n]=c,this._customParams=o;const u=this;n in u&&(u[n]=c)}catch{}},r}catch{const a=new xe,s=a;return s._customParams={...e},E(a,e),s.updateUIParam=function(l,o){try{if(!D(l))return;const c=this._customParams??{...P},u=F(o,c[l]);c[l]=u,this._customParams=c,E(this,c)}catch{}},a}}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:5,step:.01,default:1},{id:"contrast",type:"slider",label:"Contrast",property:"contrast",min:0,max:5,step:.01,default:1},{id:"saturation",type:"slider",label:"Saturation",property:"saturation",min:0,max:5,step:.01,default:1},{id:"gamma",type:"slider",label:"Gamma",property:"gamma",min:0,max:5,step:.01,default:1},{id:"red",type:"slider",label:"Red",property:"red",min:0,max:5,step:.01,default:1},{id:"green",type:"slider",label:"Green",property:"green",min:0,max:5,step:.01,default:1},{id:"blue",type:"slider",label:"Blue",property:"blue",min:0,max:5,step:.01,default:1},{id:"alpha",type:"slider",label:"Alpha",property:"alpha",min:0,max:1,step:.01,default:1}]});const{ColorMatrixFilter:Pe}=b,w={brightness:1,contrast:1,saturation:1,hue:0,sepia:0,negative:!1},Fe=new Set(["brightness","contrast","saturation","hue","sepia","negative"]);function ze(t){return Fe.has(t)}function A(t,e){if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"){const i=Number(t);if(Number.isFinite(i))return i}return e}function oe(t,e){if(typeof t=="boolean")return t;if(typeof t=="string"){if(t==="true")return!0;if(t==="false")return!1}return e}function Ce(t){return{brightness:A(t.brightness,w.brightness),contrast:A(t.contrast,w.contrast),saturation:A(t.saturation,w.saturation),hue:A(t.hue,w.hue),sepia:A(t.sepia,w.sepia),negative:oe(t.negative,w.negative)}}function O(t,e){t.reset(),e.brightness!==1&&t.brightness(e.brightness,!0),e.contrast!==1&&t.contrast(e.contrast,!0),e.saturation!==1&&t.saturate(e.saturation,!0),e.hue!==0&&t.hue(e.hue,!0),e.sepia>0&&t.sepia(!0),e.negative&&t.negative(!0)}f({id:"adjustment-advanced",name:"Advanced Adjustment",category:"adjust",description:"Comprehensive image adjustments including brightness, contrast, saturation, hue, and more",createFilter:t=>{try{const e=Ce(t??{}),i=new Pe,r=i;return r._customParams={...e},O(i,e),r.updateUIParam=function(s,n){try{if(!ze(s))return;const l=this._customParams??{...w};if(s==="negative")l.negative=oe(n,l.negative);else{const o=s;l[o]=A(n,l[o])}this._customParams=l,O(this,l)}catch{}},i}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}]});const j=t=>Math.max(0,Math.min(1,t));f({id:"alpha",name:"Alpha",category:"adjust",description:"Adjust the opacity of the image",createFilter:t=>{const e=j(t.alpha!==void 0?Number(t.alpha):1),i=new b.AlphaFilter(e);return i.updateUIParam=function(r,a){r==="alpha"&&(this.alpha=j(Number(a)))},i},defaultParams:{alpha:1},controls:[{id:"alpha",type:"slider",label:"Opacity",property:"alpha",min:0,max:1,step:.01,default:1}]});f({id:"blur",name:"Blur",category:"blur",description:"Apply a smooth blur effect to the entire image",createFilter:t=>{try{const e=new b.BlurFilter({strength:t.blur||8,quality:t.quality||4});return e._customParams={...t},e.updateUIParam=function(i,r){const a=this._customParams||{};switch(this._customParams=a,a[i]=r,i){case"blur":this.strength=r;break;case"quality":this.quality=r;break;default:i in this&&(this[i]=r);break}return!0},e}catch{return null}},defaultParams:{blur:8,quality:4},controls:[{id:"blur",type:"slider",label:"Blur",property:"blur",min:0,max:100,step:.1,default:8},{id:"quality",type:"slider",label:"Quality",property:"quality",min:1,max:10,step:1,default:4}]});function q(t,e){typeof t.reset=="function"&&t.reset(),e.brightness!==1&&t.brightness(e.brightness,!1),e.contrast!==1&&t.contrast(e.contrast,!1),e.saturation!==1&&t.saturate(e.saturation,!1),e.hue!==0&&t.hue(e.hue,!1),e.sepia&&t.sepia(!1),e.negative&&t.negative(!1)}function U(t){return{brightness:Number(t.brightness??1),contrast:Number(t.contrast??1),saturation:Number(t.saturation??1),hue:Number(t.hue??0),sepia:!!t.sepia,negative:!!t.negative}}f({id:"color-matrix",name:"Color Matrix",category:"advanced",description:"Advanced color adjustments including sepia, hue rotation, and negative",createFilter:t=>{const e=b.ColorMatrixFilter;if(!e)return null;const i=new e,r=U(t);return i._customParams={...r},q(i,r),i.updateUIParam=function(a,s){const n=this._customParams??U({});switch(a){case"brightness":case"contrast":case"saturation":case"hue":n[a]=Number(s);break;case"sepia":case"negative":n[a]=!!s;break;default:return}this._customParams=n,q(this,n)},i},defaultParams:{brightness:1,contrast:1,saturation:1,hue:0,sepia:!1,negative:!1},controls:[{id:"brightness",type:"slider",label:"Brightness",property:"brightness",min:0,max:5,step:.1,default:1},{id:"contrast",type:"slider",label:"Contrast",property:"contrast",min:0,max:5,step:.1,default:1},{id:"saturation",type:"slider",label:"Saturation",property:"saturation",min:0,max:5,step:.1,default:1},{id:"hue",type:"slider",label:"Hue Rotation",property:"hue",min:-180,max:180,step:1,default:0},{id:"sepia",type:"toggle",label:"Sepia",property:"sepia",default:!1},{id:"negative",type:"toggle",label:"Negative",property:"negative",default:!1}]});const{ColorOverlayFilter:we}=p;f({id:"colorOverlay",name:"Color Overlay",category:"color",description:"Apply a colored tint or overlay to the entire image",createFilter:t=>{try{let e=16711680;t.color&&(typeof t.color=="string"?e=parseInt(t.color.replace("#","0x"),16):typeof t.color=="number"&&(e=t.color));const i=new we({color:e,alpha:t.alpha||.5});return i._customParams={...t},i.updateUIParam=function(r,a){const s=this._customParams||{};switch(this._customParams=s,s[r]=a,r){case"color":let n;typeof a=="string"?n=parseInt(a.replace("#","0x"),16):n=Number(a),this.color=n,this.uniforms&&(this.uniforms.uColor=n);break;case"alpha":this.alpha=Number(a),this.uniforms&&(this.uniforms.uAlpha=Number(a));break;default:r in this&&(this[r]=a);break}return!0},i}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}]});f({id:"drop-shadow",name:"Drop Shadow",category:"effects",description:"Add a soft drop shadow to the image",createFilter:t=>{try{const e=t.color?t.color.replace("#","0x"):"0x000000",i=t.distance!==void 0?t.distance:5,r=t.angle!==void 0?t.angle:90,a=t.blur!==void 0?t.blur:2,s=t.quality!==void 0?t.quality:3,n={x:i*Math.cos(r*Math.PI/180),y:i*Math.sin(r*Math.PI/180)},l=new p.DropShadowFilter({offset:n,color:parseInt(e,16),alpha:t.alpha!==void 0?t.alpha:.5,blur:a,quality:s,shadowOnly:t.shadowOnly!==void 0?t.shadowOnly:!1,pixelSize:{x:t.pixelSizeX!==void 0?t.pixelSizeX:1,y:t.pixelSizeY!==void 0?t.pixelSizeY:1}}),o=(d,h,m,x)=>{const g=d*h*2,z=Math.sqrt(m*m+x*x);return Math.ceil(g+z+2)};l._exportPadding=o(a,s,n.x,n.y),l.padding=Math.max(l.padding??0,l._exportPadding),l._customParams={...t,_offset:n,_distance:i,_angle:r};const c=(d,h)=>{const m=Number(d._distance??d.distance??5)*h,x=Number(d._angle??d.angle??90),g=Number(d.blur??2)*h,z=Number(d.quality??3),Y={x:m*Math.cos(x*Math.PI/180),y:m*Math.sin(x*Math.PI/180)},ue=d.color?String(d.color).replace("#","0x"):"0x000000",X=new p.DropShadowFilter({offset:Y,color:parseInt(ue,16),alpha:d.alpha!==void 0?Number(d.alpha):.5,blur:g,quality:z,shadowOnly:d.shadowOnly!==void 0?!!d.shadowOnly:!1,pixelSize:{x:d.pixelSizeX!==void 0?Number(d.pixelSizeX):1,y:d.pixelSizeY!==void 0?Number(d.pixelSizeY):1}}),R=o(g,z,Y.x,Y.y);return X._exportPadding=R,X.padding=Math.max(X.padding??0,R),X};l.createExportFilter=function(d={}){const h=Number.isFinite(d.previewToNativeScale)?Math.max(1,Number(d.previewToNativeScale)):1,m=this._customParams||t;return c(m,h)},l.getExportPadding=function(){return Number(this._exportPadding||this.padding||0)};const u=d=>{var z;const h=((z=d._customParams)==null?void 0:z._offset)??{x:0,y:0},m=Number(d.blur??0),x=Number(d.quality??1),g=o(m,x,h.x,h.y);d._exportPadding=g,d.padding=Math.max(d.padding??0,g)};return l.updateUIParam=function(d,h){try{const m=this._customParams||{};switch(this._customParams=m,m[d]=h,d){case"color":typeof h=="string"&&(this.color=parseInt(h.replace("#","0x"),16));break;case"alpha":this.alpha=Number(h);break;case"blur":this.blur=Number(h),u(this);break;case"quality":this.quality=Number(h),u(this);break;case"shadowOnly":this.shadowOnly=!!h;break;case"pixelSizeX":this.pixelSizeX=Number(h),m.pixelSizeX=Number(h);break;case"pixelSizeY":this.pixelSizeY=Number(h),m.pixelSizeY=Number(h);break;case"distance":case"angle":{d==="distance"?(m._distance=Number(h),m.distance=Number(h)):(m._angle=Number(h),m.angle=Number(h));const x={x:m._distance*Math.cos(m._angle*Math.PI/180),y:m._distance*Math.sin(m._angle*Math.PI/180)};m._offset=x,this.offset=x,u(this);break}default:d in this&&(this[d]=h);break}return!0}catch{return this._customParams&&(this._customParams[d]=h),!1}},l}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:0,max:20,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}]});const{ColorMatrixFilter:ke}=b;f({id:"grayscale",name:"Grayscale",category:"color",description:"Convert the image to black and white with adjustable intensity",createFilter:t=>{try{const e=new ke;e._customParams={...t};const i=t.intensity!==void 0?t.intensity:1;return V(e,i),e.updateUIParam=function(r,a){const s=this._customParams||{};switch(this._customParams=s,s[r]=a,r){case"intensity":V(this,a);break;default:r in this&&(this[r]=a);break}return!0},e}catch{return null}},defaultParams:{intensity:.35},controls:[{id:"intensity",type:"slider",label:"Intensity",property:"intensity",min:0,max:1,step:.01,default:.35}]});function V(t,e){t.reset(),t.greyscale(e)}const{HslAdjustmentFilter:Ne}=p;f({id:"hsl-adjustment",name:"HSL Adjustment",category:"color",description:"Control hue, saturation, and lightness independently",createFilter:t=>{try{const e=new Ne({hue:t.hue!==void 0?t.hue:0,saturation:t.saturation!==void 0?t.saturation:0,lightness:t.lightness!==void 0?t.lightness:0,colorize:t.colorize!==void 0?t.colorize:!1,alpha:t.alpha!==void 0?t.alpha:1});return e._customParams={...t},e.updateUIParam=function(i,r){try{const a=this._customParams||{};switch(this._customParams=a,a[i]=r,i){case"hue":this.hue=Number(r),this.uniforms&&(this.uniforms.uHue=Number(r));break;case"saturation":this.saturation=Number(r),this.uniforms&&(this.uniforms.uSaturation=Number(r));break;case"lightness":this.lightness=Number(r),this.uniforms&&(this.uniforms.uLightness=Number(r));break;case"colorize":this.colorize=!!r,this.uniforms&&(this.uniforms.uColorize=r?1:0);break;case"alpha":this.alpha=Number(r),this.uniforms&&(this.uniforms.uAlpha=Number(r));break;default:i in this&&(this[i]=r);break}return!0}catch{return this._customParams&&(this._customParams[i]=r),!1}},e}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:Ae}=p;f({id:"kawase-blur",name:"Kawase Blur",category:"blur",description:"A more optimized blur algorithm that is faster than standard blur",createFilter:t=>{try{const e=new Ae({strength:t.strength||4,quality:t.quality||3,clamp:t.clamp||!1,pixelSize:t.pixelSize||1});return e._customParams={...t},e.updateUIParam=function(i,r){const a=this._customParams||{};switch(this._customParams=a,a[i]=r,i){case"strength":this.strength=r;break;case"quality":this.quality=r;break;case"clamp":this.clamp=r;break;case"pixelSize":typeof r=="number"?this.pixelSize=r:typeof r=="object"&&r!==null&&"x"in r&&"y"in r&&(this.pixelSize=r);break;case"pixelSizeX":this.pixelSizeX=r;break;case"pixelSizeY":this.pixelSizeY=r;break;default:i in this&&(this[i]=r);break}return!0},e}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:20,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:0,max:10,step:.1,default:1},{id:"pixelSizeY",type:"slider",label:"Pixel Size Y",property:"pixelSizeY",min:0,max:10,step:.1,default:1}]});const{MotionBlurFilter:Le}=p;f({id:"motion-blur",name:"Motion Blur",category:"blur",description:"Creates a directional blur effect simulating motion",createFilter:t=>{try{const e=new Le({velocity:{x:t.velocityX!==void 0?t.velocityX:0,y:t.velocityY!==void 0?t.velocityY:0},kernelSize:t.kernelSize||5,offset:t.offset!==void 0?t.offset:0});return e._customParams={...t},e.updateUIParam=function(i,r){const a=this._customParams||{};switch(this._customParams=a,a[i]=r,i){case"velocityX":this.velocityX=r;break;case"velocityY":this.velocityY=r;break;case"kernelSize":this.kernelSize=r;break;case"offset":this.offset=r;break;default:i in this&&(this[i]=r);break}return!0},e}catch{return null}},defaultParams:{velocityX:0,velocityY:0,kernelSize:5,offset:0},controls:[{id:"velocityX",type:"slider",label:"Velocity X",property:"velocityX",min:-90,max:90,step:1,default:0},{id:"velocityY",type:"slider",label:"Velocity Y",property:"velocityY",min:-90,max:90,step:1,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},{label:"17",value:17},{label:"19",value:19},{label:"21",value:21},{label:"23",value:23},{label:"25",value:25}],default:5},{id:"offset",type:"slider",label:"Offset",property:"offset",min:-150,max:150,step:1,default:0}]});const{RadialBlurFilter:Ie}=p;f({id:"radial-blur",name:"Radial Blur",category:"blur",description:"Creates a circular blur effect emanating from a center point",createFilter:t=>{try{const e=new Ie({angle:t.angle??20,center:{x:t.centerX??0,y:t.centerY??0},kernelSize:t.kernelSize??15,radius:t.radius??300});return e._customParams={centerX:t.centerX??0,centerY:t.centerY??0},e.updateUIParam=function(i,r){try{switch(i){case"angle":this.angle=Number(r);break;case"centerX":this._customParams.centerX=Number(r),this.center={x:Number(r),y:this._customParams.centerY};break;case"centerY":this._customParams.centerY=Number(r),this.center={x:this._customParams.centerX,y:Number(r)};break;case"kernelSize":this.kernelSize=Number(r);break;case"radius":this.radius=Number(r);break;default:}}catch{}},e}catch{return null}},defaultParams:{angle:20,centerX:0,centerY:0,kernelSize:15,radius:300},controls:[{id:"angle",type:"slider",label:"Angle",property:"angle",min:-180,max:180,step:1,default:20},{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},{label:"17",value:17},{label:"19",value:19},{label:"21",value:21},{label:"23",value:23},{label:"25",value:25}],default:15},{id:"radius",type:"slider",label:"Radius",property:"radius",min:-1,max:1e3,step:10,default:300}]});const{TiltShiftFilter:Xe}=p;f({id:"tilt-shift",name:"Tilt Shift",category:"blur",description:"Creates a depth-of-field effect simulating miniature photography",createFilter:t=>{try{const e=typeof t.blur=="number"?t.blur:100,i=typeof t.gradientBlur=="number"?t.gradientBlur:600,r=typeof t.startX=="number"?t.startX:0,a=typeof t.startY=="number"?t.startY:.5,s=typeof t.endX=="number"?t.endX:1,n=typeof t.endY=="number"?t.endY:.5,l=new Xe({blur:Number(e),gradientBlur:Number(i),start:{x:Number(r),y:Number(a)},end:{x:Number(s),y:Number(n)}});return l._customParams={blur:e,gradientBlur:i,startX:r,startY:a,endX:s,endY:n},l.updateUIParam=function(o,c){try{const u=Number(c),d=this._customParams||{};switch(this._customParams=d,d[o]=u,o){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:o in this&&(this[o]=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:200,step:1,default:100},{id:"gradientBlur",type:"slider",label:"Gradient Width",property:"gradientBlur",min:0,max:1e3,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:Me}=p;f({id:"zoom-blur",name:"Zoom Blur",category:"blur",description:"Creates a zoom blur effect from a center point",createFilter:t=>{try{const e=new Me({strength:t.strength||.1,center:{x:t.centerX!==void 0?t.centerX:.5,y:t.centerY!==void 0?t.centerY:.5},innerRadius:t.innerRadius||80,radius:t.radius!==void 0?t.radius:-1,maxKernelSize:t.maxKernelSize||32});return e._customParams={...t},e.updateUIParam=function(i,r){const a=this._customParams||{};switch(this._customParams=a,a[i]=r,i){case"strength":this.strength=r;break;case"centerX":this.centerX=r;break;case"centerY":this.centerY=r;break;case"innerRadius":this.innerRadius=r;break;case"radius":this.radius=r;break;default:i in this&&(this[i]=r);break}return!0},e}catch{return null}},defaultParams:{strength:.1,centerX:.5,centerY:.5,innerRadius:80,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:1e3,step:1,default:80},{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:G}=p;function ce(t){return parseInt(t.replace("#","0x"),16)}function Ye(t){return"#"+t.toString(16).padStart(6,"0")}function W(t){return{offset:Number(t.offset),color:typeof t.color=="string"?ce(t.color):Number(t.color),alpha:Number(t.alpha)}}function H(t){return{offset:t.offset,color:typeof t.color=="number"?Ye(t.color):t.color,alpha:t.alpha}}f({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:t=>{let i=(t.colorStops||[{offset:0,color:"#ff0000",alpha:1},{offset:1,color:"#0000ff",alpha:1}]).map(W);i.length<2&&(i=[{offset:0,color:16711680,alpha:1},{offset:1,color:255,alpha:1}]),i.sort((a,s)=>a.offset-s.offset);const r=new G({type:t.gradientType,stops:i,angle:t.angle,alpha:t.alpha,maxColors:t.maxColors||0,replace:t.replace});return r._customParams={cssGradient:t.cssGradient||""},r.getSerializableParams=function(){var s;const a=Array.isArray(this.stops)?this.stops.map(H):[];return{gradientType:this.type,colorStops:a,angle:this.angle,alpha:this.alpha,maxColors:this.maxColors,replace:this.replace,cssGradient:((s=this._customParams)==null?void 0:s.cssGradient)??""}},r.getColorStopsForUI=function(){return Array.isArray(this.stops)?this.stops.map(H):[]},r.getDynamicControls=function(){const a=this.getColorStopsForUI(),s=[];return a.forEach((n,l)=>{s.push({id:`colorStop-${l}-color`,type:"color",label:`Stop ${l+1} Color`,property:`colorStops[${l}].color`,default:n.color}),s.push({id:`colorStop-${l}-offset`,type:"slider",label:`Stop ${l+1} Position`,property:`colorStops[${l}].offset`,min:0,max:1,step:.01,default:n.offset}),s.push({id:`colorStop-${l}-alpha`,type:"slider",label:`Stop ${l+1} Alpha`,property:`colorStops[${l}].alpha`,min:0,max:1,step:.01,default:n.alpha})}),s},r.handleButtonAction=function(a){(a==="addColorStop"||a==="removeColorStop")&&this.updateUIParam(a,!0)},r.updateUIParam=function(a,s){const n=this._customParams??{};switch(this._customParams=n,a){case"gradientType":this.type=Number(s);return;case"angle":case"alpha":case"maxColors":this[a]=Number(s);return;case"replace":this.replace=!!s;return;case"addColorStop":{const l=Array.isArray(this.stops)?[...this.stops]:[],o=Math.floor(Math.random()*255)<<16|Math.floor(Math.random()*255)<<8|Math.floor(Math.random()*255);if(l.length>0)for(const u of l)u.offset*=.8;l.push({offset:1,color:o,alpha:1}),l.sort((c,u)=>c.offset-u.offset),this.stops=l;return}case"removeColorStop":{const l=Array.isArray(this.stops)?[...this.stops]:[];l.length>2&&(l.pop(),this.stops=l);return}case"cssGradient":{const l=typeof s=="string"?s.trim():"";if(n.cssGradient=l,!l)return;try{const o=new G({css:l});this.type=o.type,this.angle=o.angle,this.stops=[...o.stops]}catch{}return}case"colorStops":{if(!Array.isArray(s))return;const l=s.map(W);l.sort((o,c)=>o.offset-c.offset),this.stops=l;return}default:{const l=/^colorStops\[(\d+)\]\.(offset|color|alpha)$/.exec(a);if(l){const[,o,c]=l,u=Number(o),d=Array.isArray(this.stops)?[...this.stops]:[];if(u<0||u>=d.length)return;c==="color"?d[u].color=typeof s=="string"?ce(s):Number(s):(c==="offset"||c==="alpha")&&(d[u][c]=Number(s)),this.stops=d}}}},r},defaultParams:{gradientType:0,colorStops:[{offset:0,color:"#ff0000",alpha:1},{offset:1,color:"#0000ff",alpha: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:"",placeholder:"e.g. linear-gradient(to right, red, blue)"}]});f({id:"color-map",name:"Color Map",category:"color",description:"Maps colors using a reference texture as a lookup table",createFilter:t=>{try{const e=p.ColorMapFilter;if(!e)return null;let i=null;t.texturePath?i=b.Texture.from(t.texturePath):i=b.Texture.from("/examples/filters-main/examples/images/colormap.png");const r=new e({colorMap:i,nearest:t.nearest,mix:t.mix});return r._customParams={...t},r.updateUIParam=function(a,s){const n=this._customParams||{};switch(this._customParams=n,n[a]=s,a){case"texturePath":s&&(this.colorMap=b.Texture.from(s));break;case"mix":this.mix=s;break;case"nearest":this.nearest=s;break;default:a in this&&(this[a]=s);break}return!0},r}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 ve=p.ColorReplaceFilter;f({id:"color-replace",name:"Color Replace",category:"color",description:"Replaces a specific color in the image with another color",createFilter:t=>{try{let e=16711680;t.originalColor&&(typeof t.originalColor=="string"?e=parseInt(t.originalColor.replace("#","0x"),16):typeof t.originalColor=="number"&&(e=t.originalColor));let i=255;t.targetColor&&(typeof t.targetColor=="string"?i=parseInt(t.targetColor.replace("#","0x"),16):typeof t.targetColor=="number"&&(i=t.targetColor));const r=new ve({originalColor:e,targetColor:i,tolerance:t.tolerance||.4});return r._customParams={...t},r.updateUIParam=function(a,s){const n=this._customParams||{};switch(this._customParams=n,n[a]=s,a){case"originalColor":typeof s=="string"?this.originalColor=parseInt(s.replace("#","0x"),16):typeof s=="number"&&(this.originalColor=s);break;case"targetColor":typeof s=="string"?this.targetColor=parseInt(s.replace("#","0x"),16):typeof s=="number"&&(this.targetColor=s);break;case"tolerance":this.tolerance=s;break;default:a in this&&(this[a]=s);break}return!0},r}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 Te=p.MultiColorReplaceFilter;f({id:"multi-color-replace",name:"Multi-Color Replace",category:"color",description:"Replaces multiple colors in the image with different target colors",createFilter:t=>{try{const e=[];if(t.originalColor1&&t.targetColor1){const r=typeof t.originalColor1=="string"?parseInt(t.originalColor1.replace("#","0x"),16):t.originalColor1,a=typeof t.targetColor1=="string"?parseInt(t.targetColor1.replace("#","0x"),16):t.targetColor1;e.push([r,a])}if(t.originalColor2&&t.targetColor2){const r=typeof t.originalColor2=="string"?parseInt(t.originalColor2.replace("#","0x"),16):t.originalColor2,a=typeof t.targetColor2=="string"?parseInt(t.targetColor2.replace("#","0x"),16):t.targetColor2;e.push([r,a])}if(t.enableThirdPair&&t.originalColor3&&t.targetColor3){const r=typeof t.originalColor3=="string"?parseInt(t.originalColor3.replace("#","0x"),16):t.originalColor3,a=typeof t.targetColor3=="string"?parseInt(t.targetColor3.replace("#","0x"),16):t.targetColor3;e.push([r,a])}const i=new Te(e,t.tolerance||.05,3);return i._customParams={...t},i.updateUIParam=function(r,a){const s=this._customParams||{};if(this._customParams=s,s[r]=a,r==="originalColor1"||r==="targetColor1"||r==="originalColor2"||r==="targetColor2"||r==="originalColor3"||r==="targetColor3"||r==="enableThirdPair"){const n=[];if(s.originalColor1&&s.targetColor1){const l=typeof s.originalColor1=="string"?parseInt(s.originalColor1.replace("#","0x"),16):s.originalColor1,o=typeof s.targetColor1=="string"?parseInt(s.targetColor1.replace("#","0x"),16):s.targetColor1;n.push([l,o])}if(s.originalColor2&&s.targetColor2){const l=typeof s.originalColor2=="string"?parseInt(s.originalColor2.replace("#","0x"),16):s.originalColor2,o=typeof s.targetColor2=="string"?parseInt(s.targetColor2.replace("#","0x"),16):s.targetColor2;n.push([l,o])}if(s.enableThirdPair&&s.originalColor3&&s.targetColor3){const l=typeof s.originalColor3=="string"?parseInt(s.originalColor3.replace("#","0x"),16):s.originalColor3,o=typeof s.targetColor3=="string"?parseInt(s.targetColor3.replace("#","0x"),16):s.targetColor3;n.push([l,o])}this.replacements=n,this.refresh()}else r==="tolerance"?this.tolerance=a:r in this&&(this[r]=a);return!0},i}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:Re}=p;f({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:t=>{try{const e={x:t.redX!==void 0?t.redX:-10,y:t.redY!==void 0?t.redY:0},i={x:t.greenX!==void 0?t.greenX:0,y:t.greenY!==void 0?t.greenY:10},r={x:t.blueX!==void 0?t.blueX:0,y:t.blueY!==void 0?t.blueY:0},a=new Re({red:e,green:i,blue:r});return a._customParams={...t},a.updateUIParam=function(s,n){try{const l=this._customParams||{};switch(this._customParams=l,l[s]=n,s){case"redX":this.redX=Number(n);break;case"redY":this.redY=Number(n);break;case"greenX":this.greenX=Number(n);break;case"greenY":this.greenY=Number(n);break;case"blueX":this.blueX=Number(n);break;case"blueY":this.blueY=Number(n);break;default:s in this&&(this[s]=n);break}return!0}catch{return this._customParams&&(this._customParams[s]=n),!1}},a}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:Be}=p;f({id:"advanced-bloom",name:"Advanced Bloom",category:"light",description:"Adds a sophisticated bloom/glow effect with fine-grained control",createFilter:t=>{try{const e=new Be({threshold:t.threshold||.5,bloomScale:t.bloomScale||1,brightness:t.brightness||1,blur:t.blur||8,quality:t.quality||4,pixelSize:{x:t.pixelSizeX||1,y:t.pixelSizeY||1}});return e._customParams={pixelSizeX:t.pixelSizeX||1,pixelSizeY:t.pixelSizeY||1},e.updateUIParam=function(i,r){try{const a=this._customParams||{};switch(this._customParams=a,a[i]=r,i){case"threshold":this.threshold=Number(r);break;case"bloomScale":this.bloomScale=Number(r);break;case"brightness":this.brightness=Number(r);break;case"blur":this.blur=Number(r);break;case"quality":this.quality=Number(r);break;case"pixelSizeX":a.pixelSizeX=Number(r),this.pixelSize={x:Number(r),y:a.pixelSizeY};break;case"pixelSizeY":a.pixelSizeY=Number(r),this.pixelSize={x:a.pixelSizeX,y:Number(r)};break;default:i in this&&(this[i]=r);break}}catch{}},e}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 De=p.AsciiFilter;f({id:"ascii",name:"ASCII",category:"stylize",description:"Convert image to ASCII text characters",createFilter:t=>{try{const e=typeof t.size=="number"?t.size:8;let i=t.color;typeof i=="string"&&i.startsWith("#")&&(i=parseInt(i.replace("#","0x"),16));const r=t.replaceColor===!0,a=new De({size:e,color:i,replaceColor:r});return a._customParams={size:e,color:i,replaceColor:r},a.updateUIParam=function(s,n){try{const l=this._customParams||{};switch(this._customParams=l,l[s]=n,s){case"size":this.size=Number(n);break;case"color":typeof n=="string"&&n.startsWith("#")?(l.color=n,this.color=parseInt(n.replace("#","0x"),16)):this.color=n;break;case"replaceColor":this.replaceColor=!!n;break;default:s in this&&(this[s]=n);break}}catch{}},a}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 Ee=p.BackdropBlurFilter;f({id:"backdrop-blur",name:"Backdrop Blur",category:"blur",description:"Blurs what is behind the object, creating a glass-like effect",createFilter:t=>{try{const e=new Ee({strength:t.strength||20,quality:t.quality||4,resolution:t.resolution||.5,kernelSize:t.kernelSize||9});return e._customParams={...t},e.updateUIParam=function(i,r){try{const a=this._customParams||{};switch(this._customParams=a,a[i]=r,i){case"strength":this.strength=Number(r),this.blur=Number(r)/4;break;case"quality":this.quality=Number(r);break;case"resolution":this.resolution=Number(r);break;case"kernelSize":const s=Number(r);this.blurXFilter&&this.blurYFilter?(this.blurXFilter.kernelSize=s,this.blurYFilter.kernelSize=s):this.kernelSize=s;break;default:i in this&&(this[i]=r);break}}catch{}},e}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:Oe}=p;f({id:"bevel",name:"Bevel",category:"effects",description:"Add a 3D-like beveled edge effect to the image",createFilter:t=>{try{const e=t.lightColor?t.lightColor.replace("#","0x"):"0xffffff",i=t.shadowColor?t.shadowColor.replace("#","0x"):"0x000000",r=new Oe({rotation:t.rotation!==void 0?t.rotation:45,thickness:t.thickness!==void 0?t.thickness:2,lightColor:parseInt(e,16),lightAlpha:t.lightAlpha!==void 0?t.lightAlpha:.7,shadowColor:parseInt(i,16),shadowAlpha:t.shadowAlpha!==void 0?t.shadowAlpha:.7});return r._customParams={...t},r.updateUIParam=function(a,s){try{const n=this._customParams||{};switch(this._customParams=n,n[a]=s,a){case"rotation":this.rotation=Number(s);break;case"thickness":this.thickness=Number(s);break;case"lightColor":if(typeof s=="string"){const l=parseInt(s.replace("#","0x"),16);this.lightColor=l}break;case"lightAlpha":this.lightAlpha=Number(s);break;case"shadowColor":if(typeof s=="string"){const l=parseInt(s.replace("#","0x"),16);this.shadowColor=l}break;case"shadowAlpha":this.shadowAlpha=Number(s);break;default:a in this&&(this[a]=s);break}return!0}catch{return this._customParams&&(this._customParams[a]=s),!1}},r}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:10,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:je}=p;f({id:"bloom",name:"Bloom/Glow",category:"light",description:"Add a subtle glow effect to bright areas of the image",createFilter:t=>{try{const e=typeof t.strengthX=="number"?t.strengthX:2,i=typeof t.strengthY=="number"?t.strengthY:2,r=typeof t.quality=="number"?t.quality:4,a=typeof t.resolution=="number"?t.resolution:1,s=typeof t.kernelSize=="number"?t.kernelSize:5,n=new je({strength:{x:Number(e),y:Number(i)},quality:Number(r),resolution:Number(a),kernelSize:Number(s)});return n._customParams={strengthX:e,strengthY:i,quality:r,resolution:a,kernelSize:s},n.updateUIParam=function(l,o){var c,u;try{const d=Number(o),h=this._customParams||{};switch(this._customParams=h,h[l]=d,l){case"strengthX":this.strength&&typeof this.strength=="object"&&(this.strength.x=d,(c=this._updateStrength)==null||c.call(this));break;case"strengthY":this.strength&&typeof this.strength=="object"&&(this.strength.y=d,(u=this._updateStrength)==null||u.call(this));break;case"quality":this.quality=d;break;case"resolution":this.resolution=d;break;case"kernelSize":this.kernelSize=d;break;default:l in this&&(this[l]=d);break}}catch{}},n}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:$}=p,v=t=>{const e=Math.max(0,Number(t)||0);return Math.ceil(e+2)};f({id:"bulge-pinch",name:"Bulge/Pinch",category:"distortion",description:"Creates a bulge or pinch effect in a circular area",createFilter:t=>{try{const e=t.centerX??.5,i=t.centerY??.5,r=t.radius??100,a=t.strength??1,s=new $({center:{x:e,y:i},radius:r,strength:a}),n=v(r);s.padding=Math.max(s.padding??0,n),s._exportPadding=n,s._customParams={...t};const l=o=>{var d;const c=Number(((d=o._customParams)==null?void 0:d.radius)??o.radius??0),u=v(c);o._exportPadding=u,o.padding=Math.max(o.padding??0,u)};return s.updateUIParam=function(o,c){const u=this._customParams||{};switch(this._customParams=u,u[o]=c,o){case"centerX":this.center||(this.center={x:.5,y:.5}),this.center.x=c;break;case"centerY":this.center||(this.center={x:.5,y:.5}),this.center.y=c;break;case"radius":this.radius=Number(c),l(this);break;case"strength":this.strength=Number(c);break;default:o in this&&(this[o]=c);break}return!0},s.createExportFilter=function(o={}){const c=Number.isFinite(o.previewToNativeScale)?Math.max(1,Number(o.previewToNativeScale)):1,u=this._customParams||t,d=Number(u.radius??100)*c,h=new $({center:{x:Number(u.centerX??.5),y:Number(u.centerY??.5)},radius:d,strength:Number(u.strength??1)}),m=v(d);return h._exportPadding=m,h.padding=Math.max(h.padding??0,m),h},s.getExportPadding=function(){return Number(this._exportPadding||this.padding||0)},s}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:0,max:1e3,step:1,default:100},{id:"strength",type:"slider",label:"Strength",property:"strength",min:-1,max:1,step:.01,default:1}]});const{ConvolutionFilter:qe}=p,N={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]};f({id:"convolution",name:"Convolution Matrix",category:"effects",description:"Apply custom image effects using matrix convolution",createFilter:t=>{try{let e;if(t.customMatrix)e=[t.m00,t.m01,t.m02,t.m10,t.m11,t.m12,t.m20,t.m21,t.m22];else{const r=t.preset;e=N[r]||N.normal}const i=new qe(e,t.width||200,t.height||200);return i._customParams={...t},i.updateUIParam=function(r,a){const s=this._customParams||{};switch(this._customParams=s,s[r]=a,r){case"preset":if(!s.customMatrix){const n=a;N[n]&&(this.matrix=N[n])}break;case"customMatrix":if(a){const n=this.matrix;s.m00=n[0],s.m01=n[1],s.m02=n[2],s.m10=n[3],s.m11=n[4],s.m12=n[5],s.m20=n[6],s.m21=n[7],s.m22=n[8]}else{const n=s.preset;this.matrix=N[n]||N.normal}break;case"m00":case"m01":case"m02":case"m10":case"m11":case"m12":case"m20":case"m21":case"m22":if(s.customMatrix){const n=[...this.matrix],o={m00:0,m01:1,m02:2,m10:3,m11:4,m12:5,m20:6,m21:7,m22:8}[r];o!==void 0&&(n[o]=a,this.matrix=n)}break;case"width":this.width=a;break;case"height":this.height=a;break;default:r in this&&(this[r]=a);break}},i}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}]});const{CrossHatchFilter:Ue}=p;f({id:"cross-hatch",name:"Cross Hatch",category:"stylize",description:"Creates a crosshatching effect like in a pencil drawing",createFilter:t=>{try{const e=new Ue;return e.updateUIParam=function(i,r){return!0},e}catch{return null}},defaultParams:{},controls:[]});f({id:"crt",name:"CRT Screen",category:"stylize",description:"Simulates an old CRT screen with scan lines and noise",createFilter:t=>{try{const e={lineWidth:typeof t.lineWidth=="number"?t.lineWidth:1,noise:typeof t.noise=="number"?t.noise:.3,curvature:typeof t.curvature=="number"?t.curvature:1,lineContrast:typeof t.lineContrast=="number"?t.lineContrast:.25,verticalLine:t.verticalLine===!0,noiseSize:typeof t.noiseSize=="number"?t.noiseSize:1,vignetting:typeof t.vignetting=="number"?t.vignetting:.3,vignettingAlpha:typeof t.vignettingAlpha=="number"?t.vignettingAlpha:1,vignettingBlur:typeof t.vignettingBlur=="number"?t.vignettingBlur:.3,time:typeof t.time=="number"?t.time:0,seed:typeof t.seed=="number"?t.seed:Math.random()},i=new p.CRTFilter(e);return i._customParams={...e},i.updateUIParam=function(r,a){try{const s=this._customParams||{};switch(this._customParams=s,s[r]=a,r){case"lineWidth":this.lineWidth=Number(a);break;case"noise":this.noise=Number(a);break;case"curvature":this.curvature=Number(a);break;case"lineContrast":this.lineContrast=Number(a);break;case"verticalLine":this.verticalLine=!!a;break;case"noiseSize":this.noiseSize=Number(a);break;case"vignetting":this.vignetting=Number(a);break;case"vignettingAlpha":this.vignettingAlpha=Number(a);break;case"vignettingBlur":this.vignettingBlur=Number(a);break;case"time":this.time=Number(a);break;case"seed":this.seed=Number(a);break;default:r in this&&(this[r]=a);break}}catch{}},i}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 Ve=b.DisplacementFilter,Ge=b.Sprite,T=b.Texture;f({id:"displacement",name:"Displacement Map",category:"distortion",description:"Distorts the image using a displacement map texture",createFilter:t=>{try{const e=t.mapTexture||"/assets/images/displacement_map.png";let i;try{i=T.from(e),i.source.addressMode="repeat"}catch{const n=document.createElement("canvas");n.width=256,n.height=256;const l=n.getContext("2d");if(l){l.fillStyle="#ffffff",l.fillRect(0,0,n.width,n.height),l.fillStyle="#000000";for(let o=0;o<10;o++)for(let c=0;c<10;c++)(o+c)%2===0&&l.fillRect(o*25,c*25,25,25)}i=T.from(n)}const r=new Ge(i),a=new Ve(r,t.scale||50);return a.scale.x=t.scaleX||50,a.scale.y=t.scaleY||50,a._customParams={...t},a._displacementSprite=r,a.updateUIParam=function(s,n){const l=this._customParams||{};switch(this._customParams=l,l[s]=n,s){case"scaleX":this.scale.x=n;break;case"scaleY":this.scale.y=n;break;case"mapTexture":try{const o=this._displacementSprite;if(o){const c=T.from(n);c.source.addressMode="repeat",o.texture=c}}catch{}break;default:s in this?this[s]=n:s in this.scale&&(this.scale[s]=n);break}return!0},a}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:1,max:200,step:1,default:50},{id:"scaleY",type:"slider",label:"Scale Y",property:"scaleY",min:1,max:200,step:1,default:50}]});f({id:"dot",name:"Dot Screen",category:"stylize",description:"Simulates a halftone printing pattern with dots",createFilter:t=>{try{const e={scale:typeof t.scale=="number"?t.scale:1,angle:typeof t.angle=="number"?t.angle:5,grayscale:t.grayscale===!0},i=new p.DotFilter(e);return i._customParams={...e},i.updateUIParam=function(r,a){try{const s=this._customParams||{};switch(this._customParams=s,s[r]=a,r){case"scale":this.scale=Number(a);break;case"angle":this.angle=Number(a);break;case"grayscale":this.grayscale=!!a;break;default:r in this&&(this[r]=a);break}}catch{}},i}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{EmbossFilter:We}=p;f({id:"emboss",name:"Emboss",category:"stylize",description:"Creates an embossed relief effect",createFilter:t=>{try{const e=typeof t.strength=="number"?t.strength:5,i=new We(e);return i._customParams={strength:e},i.updateUIParam=function(r,a){try{const s=this._customParams||{};switch(this._customParams=s,s[r]=a,r){case"strength":const n=Number(a);s.strength=n,this.strength=n;break;default:r in this&&(this[r]=a);break}}catch{}},i}catch{return null}},defaultParams:{strength:5},controls:[{id:"strength",type:"slider",label:"Strength",property:"strength",min:0,max:20,step:.5,default:5}]});const{GlitchFilter:He}=p,C={TRANSPARENT:0,ORIGINAL:1,LOOP:2,CLAMP:3,MIRROR:4};f({id:"glitch",name:"Glitch",category:"effects",description:"Apply digital distortion and glitch effects",createFilter:t=>{try{const e={x:t.redX,y:t.redY},i={x:t.greenX,y:t.greenY},r={x:t.blueX,y:t.blueY},a=new He({slices:t.slices,offset:t.offset,direction:t.direction,fillMode:t.fillMode,seed:t.seed,average:t.average,minSize:t.minSize,sampleSize:t.sampleSize,red:e,green:i,blue:r});a.animating=t.animating||!1,a._customParams={...t},typeof a.refresh=="function"&&a.refresh();let s=null;const n=()=>{a.animating&&(a.seed=Math.random()),s=requestAnimationFrame(n)};return a.animating&&(s=requestAnimationFrame(n)),a._stopAnimation=()=>{s!==null&&(cancelAnimationFrame(s),s=null)},a.updateUIParam=function(l,o){const c=this._customParams||{};switch(this._customParams=c,c[l]=o,l){case"animating":this.animating=o,o&&!s&&(s=requestAnimationFrame(n));break;case"slices":this.slices=Math.round(o);break;case"redX":case"redY":const u=this.red;l==="redX"?u.x=o:u.y=o,this.red=u;break;case"greenX":case"greenY":const d=this.green;l==="greenX"?d.x=o:d.y=o,this.green=d;break;case"blueX":case"blueY":const h=this.blue;l==="blueX"?h.x=o:h.y=o,this.blue=h;break;case"seed":this.animating||(this.seed=o);break;case"randomizeSeed":o&&!c.animating&&(this.seed=Math.random());break;case"refresh":if(o)try{this.refresh()}catch{}break;case"offset":case"direction":case"fillMode":case"average":case"minSize":case"sampleSize":l in this&&(this[l]=o);break;default:l in this&&(this[l]=o);break}},a}catch{return null}},defaultParams:{slices:10,offset:100,direction:0,fillMode:C.LOOP,seed:.5,average:!1,minSize:8,sampleSize:512,redX:2,redY:2,greenX:-10,greenY:4,blueX:10,blueY:-4,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:-400,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:C.TRANSPARENT,label:"Transparent"},{value:C.ORIGINAL,label:"Original"},{value:C.LOOP,label:"Loop"},{value:C.CLAMP,label:"Clamp"},{value:C.MIRROR,label:"Mirror"}],default:C.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:-50,max:50,step:.5,default:2},{id:"redY",type:"slider",label:"Red Y Offset",property:"redY",min:-50,max:50,step:.5,default:2},{id:"greenX",type:"slider",label:"Green X Offset",property:"greenX",min:-50,max:50,step:.5,default:-10},{id:"greenY",type:"slider",label:"Green Y Offset",property:"greenY",min:-50,max:50,step:.5,default:4},{id:"blueX",type:"slider",label:"Blue X Offset",property:"blueX",min:-50,max:50,step:.5,default:10},{id:"blueY",type:"slider",label:"Blue Y Offset",property:"blueY",min:-50,max:50,step:.5,default:-4}]});const{GlowFilter:$e}=p;f({id:"glow",name:"Glow",category:"light",description:"Adds a customizable glow effect around the image",createFilter:t=>{try{const e=parseInt(t.color.replace("#","0x"),16),i=new $e({distance:t.distance||10,outerStrength:t.outerStrength||4,innerStrength:t.innerStrength||0,color:e,alpha:t.alpha??1,quality:t.quality||.1,knockout:t.knockout||!1});return i._customParams={color:t.color||"#ffffff",...t},i.updateUIParam=function(r,a){try{const s=this._customParams||{};switch(this._customParams=s,s[r]=a,r){case"distance":this.distance=Number(a);break;case"outerStrength":this.outerStrength=Number(a);break;case"innerStrength":this.innerStrength=Number(a);break;case"color":s.color=a,this.color=parseInt(a.replace("#","0x"),16);break;case"alpha":this.alpha=Number(a);break;case"quality":this.quality=Number(a);break;case"knockout":this.knockout=!!a;break;default:r in this&&(this[r]=a);break}}catch{}},i}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:Ke}=p;f({id:"godray",name:"Godray",category:"light",description:"Creates volumetric light-ray effects (crepuscular rays)",createFilter:t=>{try{const e=new Ke({angle:t.angle||30,parallel:t.parallel??!0,center:{x:t.centerX||0,y:t.centerY||0},gain:t.gain||.5,lacunarity:t.lacunarity||2.5,time:t.time||0,alpha:t.alpha||1});return e._customParams={centerX:t.centerX||0,centerY:t.centerY||0,...t},e.updateUIParam=function(i,r){try{const a=this._customParams||{};switch(this._customParams=a,a[i]=r,i){case"angle":this.angle=Number(r);break;case"parallel":this.parallel=!!r;break;case"centerX":a.centerX=Number(r),this.center={x:Number(r),y:a.centerY};break;case"centerY":a.centerY=Number(r),this.center={x:a.centerX,y:Number(r)};break;case"gain":this.gain=Number(r);break;case"lacunarity":this.lacunarity=Number(r);break;case"time":this.time=Number(r);break;case"alpha":this.alpha=Number(r);break;default:i in this&&(this[i]=r);break}}catch{}},e}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 Ze=p.SimpleLightmapFilter,K=b.Texture;f({id:"lightmap",name:"Lightmap",category:"light",description:"Applies lighting effects using a reference texture as a light map",createFilter:t=>{try{const e=t.textureType||"default",i=t.color||"#000000",r=typeof t.alpha=="number"?t.alpha:1,a=document.createElement("canvas");a.width=256,a.height=256;const s=a.getContext("2d");if(!s)throw new Error("Canvas 2D context not available");if(e==="spotlight"){s.fillStyle="black",s.fillRect(0,0,256,256);const c=s.createRadialGradient(128,128,5,128,128,80);c.addColorStop(0,"white"),c.addColorStop(.5,"rgba(255, 255, 255, 0.5)"),c.addColorStop(1,"rgba(0, 0, 0, 0)"),s.fillStyle=c,s.beginPath(),s.arc(128,128,100,0,Math.PI*2),s.fill()}else if(e==="softlight"){const c=s.createLinearGradient(0,0,256,256);c.addColorStop(0,"white"),c.addColorStop(.3,"rgba(220, 220, 220, 1)"),c.addColorStop(.7,"rgba(150, 150, 150, 1)"),c.addColorStop(1,"rgba(80, 80, 80, 1)"),s.fillStyle=c,s.fillRect(0,0,256,256)}else{const c=s.createRadialGradient(128,128,10,128,128,160);c.addColorStop(0,"white"),c.addColorStop(.3,"rgba(220, 220, 220, 1)"),c.addColorStop(.6,"rgba(150, 150, 150, 1)"),c.addColorStop(1,"black"),s.fillStyle=c,s.fillRect(0,0,256,256)}const n=K.from(a);let l;try{typeof i=="string"&&i.startsWith("#")?l=parseInt(i.replace("#","0x"),16):l=0}catch{l=0}const o=new Ze(n,l,r);return o._customParams={textureType:e,color:i,alpha:r},o.updateUIParam=function(c,u){try{const d=this._customParams||{};switch(this._customParams=d,d[c]=u,c){case"textureType":d.textureType=u;const h=document.createElement("canvas");h.width=256,h.height=256;const m=h.getContext("2d");if(m){if(u==="spotlight"){m.fillStyle="black",m.fillRect(0,0,256,256);const g=m.createRadialGradient(128,128,5,128,128,80);g.addColorStop(0,"white"),g.addColorStop(.5,"rgba(255, 255, 255, 0.5)"),g.addColorStop(1,"rgba(0, 0, 0, 0)"),m.fillStyle=g,m.beginPath(),m.arc(128,128,100,0,Math.PI*2),m.fill()}else if(u==="softlight"){const g=m.createLinearGradient(0,0,256,256);g.addColorStop(0,"white"),g.addColorStop(.3,"rgba(220, 220, 220, 1)"),g.addColorStop(.7,"rgba(150, 150, 150, 1)"),g.addColorStop(1,"rgba(80, 80, 80, 1)"),m.fillStyle=g,m.fillRect(0,0,256,256)}else{const g=m.createRadialGradient(128,128,10,128,128,160);g.addColorStop(0,"white"),g.addColorStop(.3,"rgba(220, 220, 220, 1)"),g.addColorStop(.6,"rgba(150, 150, 150, 1)"),g.addColorStop(1,"black"),m.fillStyle=g,m.fillRect(0,0,256,256)}const x=K.from(h);if(this.lightMap=x,this.enabled!==void 0){const g=this.enabled;this.enabled=!1,setTimeout(()=>{this.enabled=g},0)}}break;case"color":d.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:c in this&&(this[c]=u);break}}catch{}},o}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:Qe}=b;f({id:"noise",name:"Noise",category:"effects",description:"Add random noise to the image",createFilter:t=>{try{const e=new Qe({noise:t.noise||.5,seed:t.seed||Math.random()});e.animating=t.animating||!1,e._customParams={...t};let i=null;const r=()=>{e.animating&&(e.seed=Math.random()),i=requestAnimationFrame(r)};return e.animating&&(i=requestAnimationFrame(r)),e._stopAnimation=()=>{i!==null&&(cancelAnimationFrame(i),i=null)},e.updateUIParam=function(a,s){const n=this._customParams||{};switch(this._customParams=n,n[a]=s,a){case"animating":this.animating=s,s&&!i&&(i=requestAnimationFrame(r));break;case"noise":this.noise=Math.max(0,Math.min(1,s));break;case"seed":this.animating||(this.seed=s);break;case"randomizeSeed":s&&(this.seed=Math.random());break;default:a in this&&(this[a]=s);break}},e}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:Je}=p;f({id:"old-film",name:"Old Film",category:"effects",description:"Apply a vintage film effect with scratches and grain",createFilter:t=>{try{const e=new Je({sepia:t.sepia,noise:t.noise,noiseSize:t.noiseSize,scratch:t.scratch,scratchDensity:t.scratchDensity,scratchWidth:t.scratchWidth,vignetting:t.vignetting,vignettingAlpha:t.vignettingAlpha,vignettingBlur:t.vignettingBlur,seed:t.seed||Math.random()});e.animating=t.animating||!1,e._customParams={...t};let i=null;const r=()=>{e.animating&&(e.seed=Math.random()),i=requestAnimationFrame(r)};return e.animating&&(i=requestAnimationFrame(r)),e._stopAnimation=()=>{i!==null&&(cancelAnimationFrame(i),i=null)},e.updateUIParam=function(a,s){const n=this._customParams||{};switch(this._customParams=n,n[a]=s,a){case"animating":this.animating=s,s&&!i&&(i=requestAnimationFrame(r));break;case"seed":this.animating||(this.seed=s);break;case"randomizeSeed":s&&(this.seed=Math.random());break;case"sepia":case"noise":case"noiseSize":case"scratch":case"scratchDensity":case"scratchWidth":case"vignetting":case"vignettingAlpha":case"vignettingBlur":a in this&&(this[a]=s);break;default:a in this&&(this[a]=s);break}},e}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:et}=p;f({id:"outline",name:"Outline",category:"effects",description:"Add an outline or stroke around the image",createFilter:t=>{try{let e=t.color;typeof e=="string"&&(e=parseInt(e.replace("#","0x"),16));const i=new et({thickness:t.thickness||4,color:e,alpha:t.alpha||1,quality:t.quality||.1,knockout:t.knockout||!1});return i._customParams={...t},i.updateUIParam=function(r,a){const s=this._customParams||{};switch(this._customParams=s,s[r]=a,r){case"thickness":this.thickness=Math.max(0,a);break;case"color":typeof a=="string"?(this.color=parseInt(a.replace("#","0x"),16),s.color=a):this.color=a;break;case"alpha":this.alpha=Math.max(0,Math.min(1,a));break;case"quality":this.quality=Math.max(.01,Math.min(1,a));break;case"knockout":this.knockout=!!a;break;default:r in this&&(this[r]=a);break}},i}catch{return null}},defaultParams:{thickness:4,color:"#000000",alpha:1,quality:.1,knockout:!1},controls:[{id:"thickness",type:"slider",label:"Thickness",property:"thickness",min:0,max:20,step:.1,default:4},{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:tt}=p;f({id:"pixelate",name:"Pixelate",category:"effects",description:"Create a pixelated or mosaic effect",createFilter:t=>{try{const e=new tt(t.useUniform?Math.max(4,t.size||10):[Math.max(4,t.sizeX||10),Math.max(4,t.sizeY||10)]);return e._customParams={...t},e.updateUIParam=function(i,r){const a=this._customParams||{};switch(this._customParams=a,a[i]=r,i){case"useUniform":if(a.useUniform=r,r){const s=Math.round((this.sizeX+this.sizeY)/2);this.size=Math.max(4,s),a.size=s}else{const s=Array.isArray(this.size)?this.size[0]:this.size;this.sizeX=Math.max(4,s),this.sizeY=Math.max(4,s),a.sizeX=this.sizeX,a.sizeY=this.sizeY}break;case"size":a.useUniform&&(this.size=Math.max(4,r));break;case"sizeX":a.useUniform||(this.sizeX=Math.max(4,r));break;case"sizeY":a.useUniform||(this.sizeY=Math.max(4,r));break;default:i in this&&(this[i]=r);break}},e}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:4,max:40,step:1,default:10,tooltip:"Size of the pixels in both dimensions"},{id:"sizeX",type:"slider",label:"Horizontal Size",property:"sizeX",min:4,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:4,max:40,step:1,default:10,tooltip:"Size of the pixels in the vertical direction"}]});const{ReflectionFilter:rt}=p;f({id:"reflection",name:"Reflection",category:"distortion",description:"Creates a water reflection effect with configurable waves",createFilter:t=>{try{const e={mirror:t.mirror??!0,boundary:t.boundary??.5,amplitude:new Float32Array([t.amplitudeStart??0,t.amplitudeEnd??20]),waveLength:new Float32Array([t.wavelengthStart??30,t.wavelengthEnd??100]),alpha:new Float32Array([t.alphaStart??1,t.alphaEnd??1]),time:t.time??0},i=new rt(e);return i._customParams={...t},i.animating=t.animating??!1,i.updateUIParam=function(r,a){const s=this._customParams||{};switch(this._customParams=s,s[r]=a,r){case"mirror":case"boundary":case"time":this[r]=a;break;case"amplitudeStart":Array.isArray(this.amplitude)||(this.amplitude=[0,this._customParams.amplitudeEnd||20]),this.amplitude[0]=a;break;case"amplitudeEnd":Array.isArray(this.amplitude)||(this.amplitude=[this._customParams.amplitudeStart||0,20]),this.amplitude[1]=a;break;case"wavelengthStart":Array.isArray(this.waveLength)||(this.waveLength=[30,this._customParams.wavelengthEnd||100]),this.waveLength[0]=a;break;case"wavelengthEnd":Array.isArray(this.waveLength)||(this.waveLength=[this._customParams.wavelengthStart||30,100]),this.waveLength[1]=a;break;case"alphaStart":Array.isArray(this.alpha)||(this.alpha=[1,this._customParams.alphaEnd||1]),this.alpha[0]=a;break;case"alphaEnd":Array.isArray(this.alpha)||(this.alpha=[this._customParams.alphaStart||1,1]),this.alpha[1]=a;break;case"animating":this.animating=a;break;default:r in this&&(this[r]=a);break}return!0},i}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:it}=p;f({id:"shockwave",name:"Shockwave",category:"distortion",description:"Creates a rippling shockwave or blast wave effect",createFilter:t=>{try{const e=t.centerX??.5,i=t.centerY??.5,r={x:e,y:i},a=t.amplitude??30,s=t.wavelength??160,n=t.speed??500,l=t.brightness??1,o=t.radius??-1,c=t.time??0,u=new it({center:r,amplitude:a,wavelength:s,speed:n,brightness:l,radius:o,time:c});return u._customParams={...t},u.animating=t.animating??!1,u.updateUIParam=function(d,h){const m=this._customParams||{};switch(this._customParams=m,m[d]=h,d){case"centerX":this.center||(this.center={x:.5,y:.5}),this.center.x=h;break;case"centerY":this.center||(this.center={x:.5,y:.5}),this.center.y=h;break;case"amplitude":case"wavelength":case"speed":case"brightness":case"radius":case"time":this[d]=h;break;case"animating":this.animating=h;break;default:d in this&&(this[d]=h);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:at}=p;f({id:"simplex-noise",name:"Simplex Noise",category:"effects",description:"Apply procedural noise to create texture effects",createFilter:t=>{try{const e=t.animating?0:t.offsetZ||0,i=new at({strength:t.strength,noiseScale:t.noiseScale,offsetX:t.offsetX,offsetY:t.offsetY,offsetZ:e,step:t.step});i.animating=t.animating||!1,i.animationSpeed=t.animationSpeed||.01,i._customParams={...t};let r=null,a=0;const s=()=>{i.animating&&(a+=i.animationSpeed,i.offsetZ=a),r=requestAnimationFrame(s)};return i.animating&&(r=requestAnimationFrame(s)),i._stopAnimation=()=>{r!==null&&(cancelAnimationFrame(r),r=null)},i.updateUIParam=function(n,l){const o=this._customParams||{};switch(this._customParams=o,o[n]=l,n){case"animating":this.animating=l,l&&!r&&(r=requestAnimationFrame(s));break;case"animationSpeed":this.animationSpeed=l;break;case"offsetZ":this.animating||(this.offsetZ=l);break;case"randomizeSeed":if(l){const c=()=>Math.random()*100-50;this.offsetX=c(),this.offsetY=c(),this.offsetZ=c(),o.offsetX=this.offsetX,o.offsetY=this.offsetY,o.offsetZ=this.offsetZ}break;case"strength":case"noiseScale":case"offsetX":case"offsetY":case"step":n in this&&(this[n]=l);break;default:n in this&&(this[n]=l);break}},i}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:st}=p,de=t=>Math.ceil(Math.max(0,Number(t)||0)+2),Z=(t,e=1)=>{const i=Math.max(1,Number(t._sourceWidth??0)),r=Math.max(1,Number(t._sourceHeight??0)),a=Math.min(i,r),s=Number(t.centerX??.5),n=Number(t.centerY??.5),l=Number(t.radius??.25),o=Number(t.angle??4),c=s*i*e,u=n*r*e,d=l*a*e,h=new st({offset:{x:c,y:u},radius:d,angle:o}),m=de(d);return h.padding=Math.max(h.padding??0,m),h._exportPadding=m,h};f({id:"twist",name:"Twist",category:"distortion",description:"Creates a twisting distortion effect around a central point",createFilter:t=>{try{const e={centerX:t.centerX??.5,centerY:t.centerY??.5,radius:t.radius??.25,angle:t.angle??4,_sourceWidth:t._sourceWidth,_sourceHeight:t._sourceHeight},i=Z(e,1);return i._customParams={...e},i.updateUIParam=function(r,a){const s=this._customParams||{};this._customParams=s,s[r]=a;const n=Math.max(1,Number(s._sourceWidth??0)),l=Math.max(1,Number(s._sourceHeight??0)),o=Math.min(n,l),c=Number(s.centerX??.5),u=Number(s.centerY??.5),d=Number(s.radius??.25),h=Number(s.angle??4);this.offset&&(this.offset.x=c*n,this.offset.y=u*l),this.radius=d*o,this.angle=h;const m=de(this.radius);return this._exportPadding=m,this.padding=Math.max(this.padding??0,m),!0},i.createExportFilter=function(r={}){const a=Number.isFinite(r.previewToNativeScale)?Math.max(1,Number(r.previewToNativeScale)):1,s=this._customParams||e;return Z(s,a)},i.getExportPadding=function(){return Number(this._exportPadding||this.padding||0)},i}catch{return null}},defaultParams:{centerX:.5,centerY:.5,radius:.25,angle:4},controls:[{id:"angle",type:"slider",label:"Angle",property:"angle",min:-10,max:10,step:.1,default:4,tooltip:"Amount of twisting (positive is clockwise)"},{id:"radius",type:"slider",label:"Radius",property:"radius",min:.05,max:.75,step:.01,default:.25,tooltip:"Size of the twist effect (relative to image)"},{id:"centerX",type:"slider",label:"Center X",property:"centerX",min:0,max:1,step:.01,default:.5,tooltip:"Horizontal position of twist center"},{id:"centerY",type:"slider",label:"Center Y",property:"centerY",min:0,max:1,step:.01,default:.5,tooltip:"Vertical position of twist center"}]});const{AdjustmentFilter:nt}=p;function M(t){const e=typeof t=="string"?parseInt(t.replace("#","0x"),16):t;return[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]}class lt extends nt{constructor(e={}){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=e.radius??.8,this._strength=e.strength??1,e.color!==void 0&&(typeof e.color=="string"?(this._colorValue=e.color,this._colorRgb=M(e.color)):(this._colorValue="#"+e.color.toString(16).padStart(6,"0"),this._colorRgb=M(e.color))),this.updateVignette()}updateVignette(){const e=1-this._radius/2,i=this._strength*e;this.brightness=Math.max(.5,1-i*.5),this.contrast=1+i*.2,(this._colorRgb[0]>0||this._colorRgb[1]>0||this._colorRgb[2]>0)&&(this.saturation=1-i*.3)}get radius(){return this._radius}set radius(e){this._radius=Math.max(.1,Math.min(1.5,e)),this.updateVignette()}get strength(){return this._strength}set strength(e){this._strength=Math.max(0,Math.min(2,e)),this.updateVignette()}get color(){return this._colorValue}set color(e){typeof e=="string"?(this._colorValue=e,this._colorRgb=M(e)):(this._colorValue="#"+e.toString(16).padStart(6,"0"),this._colorRgb=M(e)),this.updateVignette()}}f({id:"vignette",name:"Vignette",category:"effects",description:"Add a classic darkened border effect to the image",createFilter:t=>{try{const e=new lt({radius:t.radius||.8,strength:t.strength||1,color:t.color||"#000000"});return e._customParams={...t},e.updateUIParam=function(i,r){const a=this._customParams||{};switch(this._customParams=a,a[i]=r,i){case"radius":this.radius=Math.max(.1,Math.min(1.5,r));break;case"strength":this.strength=Math.max(0,r);break;case"color":this.color=r,typeof r=="string"&&(a.color=r);break;default:i in this&&(this[i]=r);break}},e}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 ot(t){try{let e=[],i=[];try{e=I(),e.length===0&&ie()}catch{}const r=t==null?void 0:t.disabled;if(Array.isArray(r)&&r.length>0){let a=0;for(const s of r)ne(s)&&a++;a>0}try{e=I(),i=se()}catch{e||(e=[]),i||(i=[])}return e.length,e}catch{return[]}}exports.EventEmitter=J;exports.State=te;exports.TEXT_LAYER_FONT_FAMILIES=ee;exports.createState=fe;exports.getAllCategories=se;exports.getAllFilters=I;exports.getFilter=re;exports.getFiltersByCategory=ae;exports.getRegisteredFilters=le;exports.hasFilter=ge;exports.initializeFilterRegistry=ot;exports.isFilterCompatibleWithMedia=ye;exports.registerCorePixiFilters=ie;exports.registerFilter=f;exports.unregisterFilter=ne;
|
|
2
|
+
//# sourceMappingURL=index-QOKC8XA_.cjs.map
|