@cesdk/cesdk-js 1.77.0-rc.3 → 1.77.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cesdk/cesdk-js",
3
- "version": "1.77.0-rc.3",
3
+ "version": "1.77.0",
4
4
  "module": "./index.js",
5
5
  "type": "module",
6
6
  "types": "./index.d.ts",
@@ -40,7 +40,7 @@
40
40
  "license": "SEE LICENSE IN LICENSE.md",
41
41
  "readme": "README.md",
42
42
  "dependencies": {
43
- "@cesdk/engine": "1.77.0-rc.3"
43
+ "@cesdk/engine": "1.77.0"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@angular/common": ">=14.0.0",
@@ -2,6 +2,8 @@ import type { AssetEntryId } from '@cesdk/cesdk-js';
2
2
  import type { EditorPlugin } from '@cesdk/cesdk-js';
3
3
  import type { EditorPluginContext } from '@cesdk/cesdk-js';
4
4
 
5
+ declare const ASSET_SOURCE_IDS: readonly ["ly.img.text", "ly.img.text.styles", "ly.img.text.curves"];
6
+
5
7
  /**
6
8
  * Known blur asset ID patterns for GLOB matching.
7
9
  */
@@ -513,13 +515,13 @@ declare interface TextAssetSourceConfig {
513
515
  /**
514
516
  * Include specific text presets to load using GLOB patterns.
515
517
  * Supports wildcards: `*` (match any) and `?` (match one character).
516
- * @example ['ly.img.text.presets.*'] - Include all text presets
517
- * @example ['ly.img.text.presets.outline'] - Include a specific preset
518
+ * @example ['ly.img.text.styles.*'] - Include all Text Styles presets
519
+ * @example ['ly.img.text.styles.outline'] - Include a specific preset
518
520
  */
519
- include?: (`${TextPresetAssetId}.*` | (string & {}))[];
521
+ include?: (`${TextPresetSourceId}.*` | (string & {}))[];
520
522
  /**
521
523
  * Custom mapping of asset source ID to asset library entry IDs.
522
- * If not specified, text presets are added to the `ly.img.text.presets` library.
524
+ * If not specified, every source is added to the shared `ly.img.text` library entry.
523
525
  */
524
526
  assetLibraryEntries?: Record<string, AssetEntryId | AssetEntryId[]>;
525
527
  }
@@ -566,9 +568,9 @@ declare interface TextComponentAssetSourceConfig {
566
568
  }
567
569
 
568
570
  /**
569
- * Known text preset asset ID patterns for GLOB matching.
571
+ * Known text style-preset source IDs, used as GLOB prefixes for `include`.
570
572
  */
571
- declare type TextPresetAssetId = 'ly.img.text.presets';
573
+ declare type TextPresetSourceId = (typeof ASSET_SOURCE_IDS)[number];
572
574
 
573
575
  /**
574
576
  * Known typeface asset ID patterns for GLOB matching.
package/plugins/index.js CHANGED
@@ -1 +1 @@
1
- import CreativeEditorSDK from"@cesdk/cesdk-js";var e="ly.img.colors.imageColors",s=class{name="cesdk-image-colors-asset-source";version=CreativeEditorSDK.version;assetLibraryEntries;addedSourceId=null;translate;constructor(e={}){this.assetLibraryEntries=e.assetLibraryEntries??["ly.img.colors"]}async initialize({engine:s,cesdk:i}){if(this.translate=i?e=>i.i18n.translate(e):void 0,s.asset.findAllSources().includes(e)||s.asset.addSource({id:e,findAssets:e=>this.findAssets(s,e),getGroups:()=>this.getGroups(s)}),this.addedSourceId=e,i){for(const s of this.assetLibraryEntries)i.ui.updateAssetLibraryEntry(s,{sourceIds:({currentIds:s,engine:t})=>r(t)?Array.from(new Set([...s,e])):s.filter(s=>s!==e),title:t()});i.ui.updateAssetLibraryEntry("ly.img.colors.panel",{title:t()}),i.onReset(()=>this.cleanup({engine:s,cesdk:i}))}}cleanup({engine:s,cesdk:t}){if(t)for(const s of this.assetLibraryEntries)t.ui.updateAssetLibraryEntry(s,{sourceIds:({currentIds:s})=>s.filter(s=>s!==e)});if(null!=this.addedSourceId){try{s.asset.removeSource(this.addedSourceId)}catch(e){console.warn(`Unable to remove source with id: ${this.addedSourceId}`,e)}this.addedSourceId=null}o.delete(s)}async findAssets(e,s){const t=function(e){if(null==e)return null;const s=Array.isArray(e)?e:[e];return 0===s.length?null:new Set(s)}(s?.groups),r=function(e){if(null==e)return[];const s=e.toLowerCase().match(/\w+/g);return s??[]}(s?.query),i=(await c(e,this.translate)).filter(({group:e})=>null==t||t.has(e)).flatMap(({assets:e})=>e).filter(e=>function(e,s){if(0===s.length)return!0;const t=function(e){const s=[],t=e.payload?.color;if(null!=t)switch(t.colorSpace){case"sRGB":{const e=function(e,s,t){const r=e=>Math.round(255*Math.max(0,Math.min(1,e))).toString(16).padStart(2,"0");return`#${r(e)}${r(s)}${r(t)}`}(t.r,t.g,t.b);s.push(e,e.slice(1));break}case"CMYK":s.push("c",String(Math.round(100*t.c)),"m",String(Math.round(100*t.m)),"y",String(Math.round(100*t.y)),"k",String(Math.round(100*t.k)));break;case"SpotColor":s.push(t.name.toLowerCase())}for(const t of e.groups??[]){const e=t.toLowerCase().match(/\w+/g);null!=e&&s.push(...e)}return s}(e);return s.every(e=>t.some(s=>s.includes(e)))}(e,r));return{assets:i,total:i.length,currentPage:0,nextPage:void 0}}async getGroups(e){return(await c(e,this.translate)).map(({group:e})=>e)}};function t(){return({sourceId:s,group:t})=>{if(null!=t&&s===e)return t}}function r(e){return e.block.findByType("graphic").some(s=>i(e,s))}function i(e,s){try{if(!e.block.hasFill(s)||!e.block.isFillEnabled(s))return!1;const t=e.block.getFill(s);return"//ly.img.ubq/fill/image"===e.block.getType(t)}catch{return!1}}function n(e,s){let t;try{t=e.block.getFill(s)}catch{return null}try{const s=e.block.getString(t,"fill/image/imageFileURI");if(s.length>0)return`uri:${s}`}catch{}try{const s=e.block.getSourceSet(t,"fill/image/sourceSet").map(e=>e.uri).filter(e=>e.length>0).sort().join("|");if(s.length>0)return`set:${s}`}catch{}try{const s=e.block.getString(t,"fill/image/externalReference");if(s.length>0)return`ref:${s}`}catch{}return null}var o=new WeakMap;function c(e,s){const t=o.get(e),r=Date.now();if(null!=t&&r-t.createdAt<250)return t.palette;const c=async function(e,s){const t=e.block.findByType("graphic"),r=new Map,o={count:0},c=[],u=new Set;for(const l of t){if(!i(e,l))continue;const t=n(e,l);if(null!=t){if(u.has(t))continue;u.add(t)}const f=[],g=new Set,h=a(e,l,r,o,s);try{const s=await e.block.getDominantColors(l,{count:5,ignoreWhite:!0});for(const{r:e,g:t,b:r}of s)d(f,g,{colorSpace:"sRGB",r:e,g:t,b:r},h)}catch(e){console.warn(`[ImageColors] Failed to extract colors from block ${l}:`,e)}f.length>0&&c.push({group:h,assets:f})}return c}(e,s);return o.set(e,{palette:c,createdAt:r}),c}function a(e,s,t,r,i){const n=function(e,s){try{const t=e.block.getName(s);if(t&&t.trim().length>0)return t.trim()}catch{}try{const t=e.block.getMetadata(s,"fallback-name");if(t&&t.trim().length>0)return t.trim()}catch{}return null}(e,s),o=n??function(e,s){const t="libraries.ly.img.colors.imageColors.unnamedBlock",r=`Image ${e}`;if(null==s)return r;const i=s(t);return i===t||0===i.length?r:i.replace(/\{\{\s*n\s*\}\}/g,String(e))}(++r.count,i),c=t.get(o)??0;return t.set(o,c+1),0===c?o:`${o} (${c+1})`}function d(s,t,r,i){const n=function(e){switch(e.colorSpace){case"sRGB":return`rgb:${e.r.toFixed(3)},${e.g.toFixed(3)},${e.b.toFixed(3)}`;case"CMYK":return`cmyk:${e.c.toFixed(3)},${e.m.toFixed(3)},${e.y.toFixed(3)},${e.k.toFixed(3)}`;case"SpotColor":return`spot:${e.name} ${e.externalReference}`;default:return`unknown:${e.colorSpace}`}}(r);t.has(n)||(t.add(n),s.push({id:`${e}.${encodeURIComponent(i)}.${n}`,payload:{color:r},groups:[i]}))}import u from"@cesdk/cesdk-js";var l=class{constructor(e={}){this.config=e}name="cesdk-blur-asset-source";version=u.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.blur":["ly.img.blur"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.blur";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import f from"@cesdk/cesdk-js";var g="ly.img.caption.presets",h=class{constructor(e={}){this.config=e}name="cesdk-caption-presets-asset-source";version=f.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{[g]:["ly.img.library.captionPresets"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/");if(!new Set(e.asset.findAllSources()).has(g)){const s=`${r}${g}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include}),this.addedAssetSourceIds.push(g)}if(s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));for(const e of this.addedAssetSourceIds){const t=this.getAssetLibraryEntries(e);for(const r of t)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:s})=>[...new Set([...s,e])]})}}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import y from"@cesdk/cesdk-js";var m=class{constructor(e={}){this.config=e}name="cesdk-color-palette-asset-source";version=y.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.color.palette":["ly.img.colors"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.color.palette";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import p from"@cesdk/cesdk-js";var b=class{constructor(e={}){this.config=e}name="cesdk-crop-presets-asset-source";version=p.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.crop.presets":["ly.img.cropPresets"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.crop.presets";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import A from"@cesdk/cesdk-js";var S=class{constructor(e={}){this.config=e}name="cesdk-demo-asset-sources";version=A.version;addedAssetSourceIds=[];globToRegex(e){const s=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp(`^${s}$`,"i")}sourceMatchesAnyPattern(e,s){return s.some(s=>{if(s===e||s.startsWith(`${e}.`))return!0;return this.globToRegex(s).test(e)})}filterAssetSources(e,s){return e.filter(e=>this.sourceMatchesAnyPattern(e,s))}filterMatchersForSource(e,s){return s.filter(s=>{if(s===e||s.startsWith(`${e}.`))return!0;return this.globToRegex(s).test(e)})}getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.image":["ly.img.image"],"ly.img.video":["ly.img.video"],"ly.img.audio":["ly.img.audio"],"ly.img.templates":["ly.img.templates"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n=["ly.img.audio","ly.img.video","ly.img.image","ly.img.templates"],o=this.config.include?this.filterAssetSources(n,this.config.include):n;for(const s of o)if(!i.has(s)){const t=`${r}${s}/content.json`,i=this.config.include?this.filterMatchersForSource(s,this.config.include):void 0;await e.asset.addLocalAssetSourceFromJSONURI(t,{matcher:i}),this.addedAssetSourceIds.push(s)}if(s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));for(const e of this.addedAssetSourceIds){const t=this.getAssetLibraryEntries(e);for(const r of t)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:s})=>[...new Set([...s,e])]})}}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import L from"@cesdk/cesdk-js";var I=class{constructor(e={}){this.config=e}name="cesdk-effects-asset-source";version=L.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.effect":["ly.img.effect"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.effect";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import E from"@cesdk/cesdk-js";var w=class{constructor(e={}){this.config=e}name="cesdk-filters-asset-source";version=E.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.filter":["ly.img.filter"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.filter";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import k from"@cesdk/cesdk-js";var v=class{constructor(e={}){this.config=e}name="cesdk-page-presets-asset-source";version=k.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.page.presets":["ly.img.pagePresets"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.page.presets";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import R from"@cesdk/cesdk-js";var $="ly.img.templates.premium",U=class{constructor(e={}){this.config=e}name="cesdk-premium-asset-sources";version=R.version;sourceAdded=!1;globToRegex(e){const s=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp(`^${s}$`,"i")}filterMatchersForSource(e){return e.filter(e=>{if(e===$||e.startsWith(`${$}.`))return!0;return this.globToRegex(e).test($)})}getAssetLibraryEntries(){if(this.config.assetLibraryEntries?.[$]){const e=this.config.assetLibraryEntries[$];return Array.isArray(e)?e:[e]}return["ly.img.templates"]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/");if(!new Set(e.asset.findAllSources()).has($)){e.asset.addLocalSource($,void 0,async s=>{if(s.meta?.uri)return await e.scene.loadFromArchiveURL(s.meta.uri),e.scene.get()??void 0});const s=`${r}${$}/content.json`,t=this.config.include?this.filterMatchersForSource(this.config.include):void 0;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:t}),this.sourceAdded=!0}if(s&&(s.onReset(()=>this.cleanup({engine:e,cesdk:s})),this.sourceAdded)){const e=this.getAssetLibraryEntries();for(const t of e)s.ui.updateAssetLibraryEntry(t,{sourceIds:({currentIds:e})=>[...new Set([...e,$])]})}}cleanup({engine:e,cesdk:s}){if(this.sourceAdded){if(s){const e=this.getAssetLibraryEntries();for(const t of e)s.ui.updateAssetLibraryEntry(t,{sourceIds:({currentIds:e})=>e.filter(e=>e!==$)})}try{e.asset.removeSource($)}catch(e){console.warn("Unable to remove source with id: ",$)}this.sourceAdded=!1}}};import j from"@cesdk/cesdk-js";var x=class{constructor(e={}){this.config=e}name="cesdk-sticker-asset-source";version=j.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.sticker":["ly.img.sticker"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.sticker";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import F from"@cesdk/cesdk-js";var C="ly.img.text.presets",M=class{constructor(e={}){this.config=e}name="cesdk-text-asset-source";version=F.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{[C]:["ly.img.text.presets"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/");if(!new Set(e.asset.findAllSources()).has(C)){const s=`${r}${C}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include}),this.addedAssetSourceIds.push(C)}if(s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));for(const e of this.addedAssetSourceIds){const t=this.getAssetLibraryEntries(e);for(const r of t)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:s})=>[...new Set([...s,e])]})}}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import P from"@cesdk/cesdk-js";var B=class{constructor(e={}){this.config=e}name="cesdk-text-component-asset-source";version=P.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.text.components":["ly.img.text"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.text.components";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import z from"@cesdk/cesdk-js";var N=class{constructor(e={}){this.config=e}name="cesdk-typeface-asset-source";version=z.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.typeface":["ly.img.typefaces"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.typeface";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import J from"@cesdk/cesdk-js";var O=[{id:"ly.img.image.upload",mimeTypes:["image/jpeg","image/png","image/webp","image/svg+xml","image/bmp","image/gif","image/apng"],assetLibraryEntries:["ly.img.image","ly.img.upload"]},{id:"ly.img.video.upload",mimeTypes:["application/json","video/mp4","video/quicktime","video/webm","video/matroska","image/gif","image/apng"],assetLibraryEntries:["ly.img.video","ly.img.upload"]},{id:"ly.img.audio.upload",mimeTypes:["audio/mpeg","audio/mp3","audio/x-m4a","audio/wav"],assetLibraryEntries:["ly.img.audio","ly.img.upload"]}],T=class{constructor(e={}){this.config=e}name="cesdk-upload-asset-sources";version=J.version;addedAssetSourceIds=[];addedLibraryEntryMappings=new Map;isExplicitMode(){return this.config.include?.some(e=>"string"==typeof e)??!1}getExplicitIncludes(){return this.config.include?new Set(this.config.include.filter(e=>"string"==typeof e)):new Set}getCustomizations(){return this.config.include?this.config.include.filter(e=>"object"==typeof e):[]}getAssetLibraryEntries(e){return e?Array.isArray(e)?e:[e]:[]}async initialize({engine:e,cesdk:s}){const t=new Set(e.asset.findAllSources()),r=this.isExplicitMode(),i=this.getExplicitIncludes(),n=this.getCustomizations(),o=new Map;if(r)for(const e of O)i.has(e.id)&&o.set(e.id,e);else for(const e of O)o.set(e.id,e);for(const e of n){const s=o.get(e.id);s?o.set(e.id,{...s,...e}):o.set(e.id,e)}const c=Array.from(o.values());for(const r of c){const{id:i,mimeTypes:n,assetLibraryEntries:o}=r;if(!t.has(i)&&(e.asset.addLocalSource(i,n),this.addedAssetSourceIds.push(i),s)){const e=this.getAssetLibraryEntries(o);this.addedLibraryEntryMappings.set(i,e);for(const t of e)s.ui.updateAssetLibraryEntry(t,{sourceIds:({currentIds:e})=>[...new Set([...e,i])]})}}s&&s.onReset(()=>this.cleanup({engine:e,cesdk:s}))}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.addedLibraryEntryMappings.get(t)??[];for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[],this.addedLibraryEntryMappings.clear()}};import G from"@cesdk/cesdk-js";var W=class{constructor(e={}){this.config=e}name="cesdk-vectorshape-asset-source";version=G.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.vector.shape":["ly.img.vector.shape","ly.img.shape.replace"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.vector.shape";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};export{l as BlurAssetSource,h as CaptionPresetsAssetSource,m as ColorPaletteAssetSource,b as CropPresetsAssetSource,S as DemoAssetSources,I as EffectsAssetSource,w as FiltersAssetSource,e as IMAGE_COLORS_SOURCE_ID,s as ImageColorsAssetSource,v as PagePresetsAssetSource,U as PremiumTemplatesAssetSource,x as StickerAssetSource,M as TextAssetSource,B as TextComponentAssetSource,N as TypefaceAssetSource,T as UploadAssetSources,W as VectorShapeAssetSource};
1
+ import CreativeEditorSDK from"@cesdk/cesdk-js";var e="ly.img.colors.imageColors",s=class{name="cesdk-image-colors-asset-source";version=CreativeEditorSDK.version;assetLibraryEntries;addedSourceId=null;translate;constructor(e={}){this.assetLibraryEntries=e.assetLibraryEntries??["ly.img.colors"]}async initialize({engine:s,cesdk:i}){if(this.translate=i?e=>i.i18n.translate(e):void 0,s.asset.findAllSources().includes(e)||s.asset.addSource({id:e,findAssets:e=>this.findAssets(s,e),getGroups:()=>this.getGroups(s)}),this.addedSourceId=e,i){for(const s of this.assetLibraryEntries)i.ui.updateAssetLibraryEntry(s,{sourceIds:({currentIds:s,engine:t})=>r(t)?Array.from(new Set([...s,e])):s.filter(s=>s!==e),title:t()});i.ui.updateAssetLibraryEntry("ly.img.colors.panel",{title:t()}),i.onReset(()=>this.cleanup({engine:s,cesdk:i}))}}cleanup({engine:s,cesdk:t}){if(t)for(const s of this.assetLibraryEntries)t.ui.updateAssetLibraryEntry(s,{sourceIds:({currentIds:s})=>s.filter(s=>s!==e)});if(null!=this.addedSourceId){try{s.asset.removeSource(this.addedSourceId)}catch(e){console.warn(`Unable to remove source with id: ${this.addedSourceId}`,e)}this.addedSourceId=null}o.delete(s)}async findAssets(e,s){const t=function(e){if(null==e)return null;const s=Array.isArray(e)?e:[e];return 0===s.length?null:new Set(s)}(s?.groups),r=function(e){if(null==e)return[];const s=e.toLowerCase().match(/\w+/g);return s??[]}(s?.query),i=(await c(e,this.translate)).filter(({group:e})=>null==t||t.has(e)).flatMap(({assets:e})=>e).filter(e=>function(e,s){if(0===s.length)return!0;const t=function(e){const s=[],t=e.payload?.color;if(null!=t)switch(t.colorSpace){case"sRGB":{const e=function(e,s,t){const r=e=>Math.round(255*Math.max(0,Math.min(1,e))).toString(16).padStart(2,"0");return`#${r(e)}${r(s)}${r(t)}`}(t.r,t.g,t.b);s.push(e,e.slice(1));break}case"CMYK":s.push("c",String(Math.round(100*t.c)),"m",String(Math.round(100*t.m)),"y",String(Math.round(100*t.y)),"k",String(Math.round(100*t.k)));break;case"SpotColor":s.push(t.name.toLowerCase())}for(const t of e.groups??[]){const e=t.toLowerCase().match(/\w+/g);null!=e&&s.push(...e)}return s}(e);return s.every(e=>t.some(s=>s.includes(e)))}(e,r));return{assets:i,total:i.length,currentPage:0,nextPage:void 0}}async getGroups(e){return(await c(e,this.translate)).map(({group:e})=>e)}};function t(){return({sourceId:s,group:t})=>{if(null!=t&&s===e)return t}}function r(e){return e.block.findByType("graphic").some(s=>i(e,s))}function i(e,s){try{if(!e.block.hasFill(s)||!e.block.isFillEnabled(s))return!1;const t=e.block.getFill(s);return"//ly.img.ubq/fill/image"===e.block.getType(t)}catch{return!1}}function n(e,s){let t;try{t=e.block.getFill(s)}catch{return null}try{const s=e.block.getString(t,"fill/image/imageFileURI");if(s.length>0)return`uri:${s}`}catch{}try{const s=e.block.getSourceSet(t,"fill/image/sourceSet").map(e=>e.uri).filter(e=>e.length>0).sort().join("|");if(s.length>0)return`set:${s}`}catch{}try{const s=e.block.getString(t,"fill/image/externalReference");if(s.length>0)return`ref:${s}`}catch{}return null}var o=new WeakMap;function c(e,s){const t=o.get(e),r=Date.now();if(null!=t&&r-t.createdAt<250)return t.palette;const c=async function(e,s){const t=e.block.findByType("graphic"),r=new Map,o={count:0},c=[],u=new Set;for(const l of t){if(!i(e,l))continue;const t=n(e,l);if(null!=t){if(u.has(t))continue;u.add(t)}const f=[],g=new Set,h=a(e,l,r,o,s);try{const s=await e.block.getDominantColors(l,{count:5,ignoreWhite:!0});for(const{r:e,g:t,b:r}of s)d(f,g,{colorSpace:"sRGB",r:e,g:t,b:r},h)}catch(e){console.warn(`[ImageColors] Failed to extract colors from block ${l}:`,e)}f.length>0&&c.push({group:h,assets:f})}return c}(e,s);return o.set(e,{palette:c,createdAt:r}),c}function a(e,s,t,r,i){const n=function(e,s){try{const t=e.block.getName(s);if(t&&t.trim().length>0)return t.trim()}catch{}try{const t=e.block.getMetadata(s,"fallback-name");if(t&&t.trim().length>0)return t.trim()}catch{}return null}(e,s),o=n??function(e,s){const t="libraries.ly.img.colors.imageColors.unnamedBlock",r=`Image ${e}`;if(null==s)return r;const i=s(t);return i===t||0===i.length?r:i.replace(/\{\{\s*n\s*\}\}/g,String(e))}(++r.count,i),c=t.get(o)??0;return t.set(o,c+1),0===c?o:`${o} (${c+1})`}function d(s,t,r,i){const n=function(e){switch(e.colorSpace){case"sRGB":return`rgb:${e.r.toFixed(3)},${e.g.toFixed(3)},${e.b.toFixed(3)}`;case"CMYK":return`cmyk:${e.c.toFixed(3)},${e.m.toFixed(3)},${e.y.toFixed(3)},${e.k.toFixed(3)}`;case"SpotColor":return`spot:${e.name} ${e.externalReference}`;default:return`unknown:${e.colorSpace}`}}(r);t.has(n)||(t.add(n),s.push({id:`${e}.${encodeURIComponent(i)}.${n}`,payload:{color:r},groups:[i]}))}import u from"@cesdk/cesdk-js";var l=class{constructor(e={}){this.config=e}name="cesdk-blur-asset-source";version=u.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.blur":["ly.img.blur"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.blur";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import f from"@cesdk/cesdk-js";var g="ly.img.caption.presets",h=class{constructor(e={}){this.config=e}name="cesdk-caption-presets-asset-source";version=f.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{[g]:["ly.img.library.captionPresets"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/");if(!new Set(e.asset.findAllSources()).has(g)){const s=`${r}${g}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include}),this.addedAssetSourceIds.push(g)}if(s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));for(const e of this.addedAssetSourceIds){const t=this.getAssetLibraryEntries(e);for(const r of t)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:s})=>[...new Set([...s,e])]})}}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import y from"@cesdk/cesdk-js";var m=class{constructor(e={}){this.config=e}name="cesdk-color-palette-asset-source";version=y.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.color.palette":["ly.img.colors"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.color.palette";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import p from"@cesdk/cesdk-js";var b=class{constructor(e={}){this.config=e}name="cesdk-crop-presets-asset-source";version=p.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.crop.presets":["ly.img.cropPresets"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.crop.presets";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import A from"@cesdk/cesdk-js";var S=class{constructor(e={}){this.config=e}name="cesdk-demo-asset-sources";version=A.version;addedAssetSourceIds=[];globToRegex(e){const s=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp(`^${s}$`,"i")}sourceMatchesAnyPattern(e,s){return s.some(s=>{if(s===e||s.startsWith(`${e}.`))return!0;return this.globToRegex(s).test(e)})}filterAssetSources(e,s){return e.filter(e=>this.sourceMatchesAnyPattern(e,s))}filterMatchersForSource(e,s){return s.filter(s=>{if(s===e||s.startsWith(`${e}.`))return!0;return this.globToRegex(s).test(e)})}getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.image":["ly.img.image"],"ly.img.video":["ly.img.video"],"ly.img.audio":["ly.img.audio"],"ly.img.templates":["ly.img.templates"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n=["ly.img.audio","ly.img.video","ly.img.image","ly.img.templates"],o=this.config.include?this.filterAssetSources(n,this.config.include):n;for(const s of o)if(!i.has(s)){const t=`${r}${s}/content.json`,i=this.config.include?this.filterMatchersForSource(s,this.config.include):void 0;await e.asset.addLocalAssetSourceFromJSONURI(t,{matcher:i}),this.addedAssetSourceIds.push(s)}if(s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));for(const e of this.addedAssetSourceIds){const t=this.getAssetLibraryEntries(e);for(const r of t)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:s})=>[...new Set([...s,e])]})}}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import L from"@cesdk/cesdk-js";var I=class{constructor(e={}){this.config=e}name="cesdk-effects-asset-source";version=L.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.effect":["ly.img.effect"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.effect";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import E from"@cesdk/cesdk-js";var w=class{constructor(e={}){this.config=e}name="cesdk-filters-asset-source";version=E.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.filter":["ly.img.filter"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.filter";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import k from"@cesdk/cesdk-js";var v=class{constructor(e={}){this.config=e}name="cesdk-page-presets-asset-source";version=k.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.page.presets":["ly.img.pagePresets"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.page.presets";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import R from"@cesdk/cesdk-js";var $="ly.img.templates.premium",U=class{constructor(e={}){this.config=e}name="cesdk-premium-asset-sources";version=R.version;sourceAdded=!1;globToRegex(e){const s=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp(`^${s}$`,"i")}filterMatchersForSource(e){return e.filter(e=>{if(e===$||e.startsWith(`${$}.`))return!0;return this.globToRegex(e).test($)})}getAssetLibraryEntries(){if(this.config.assetLibraryEntries?.[$]){const e=this.config.assetLibraryEntries[$];return Array.isArray(e)?e:[e]}return["ly.img.templates"]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/");if(!new Set(e.asset.findAllSources()).has($)){e.asset.addLocalSource($,void 0,async s=>{if(s.meta?.uri)return await e.scene.loadFromArchiveURL(s.meta.uri),e.scene.get()??void 0});const s=`${r}${$}/content.json`,t=this.config.include?this.filterMatchersForSource(this.config.include):void 0;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:t}),this.sourceAdded=!0}if(s&&(s.onReset(()=>this.cleanup({engine:e,cesdk:s})),this.sourceAdded)){const e=this.getAssetLibraryEntries();for(const t of e)s.ui.updateAssetLibraryEntry(t,{sourceIds:({currentIds:e})=>[...new Set([...e,$])]})}}cleanup({engine:e,cesdk:s}){if(this.sourceAdded){if(s){const e=this.getAssetLibraryEntries();for(const t of e)s.ui.updateAssetLibraryEntry(t,{sourceIds:({currentIds:e})=>e.filter(e=>e!==$)})}try{e.asset.removeSource($)}catch(e){console.warn("Unable to remove source with id: ",$)}this.sourceAdded=!1}}};import x from"@cesdk/cesdk-js";var j=class{constructor(e={}){this.config=e}name="cesdk-sticker-asset-source";version=x.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.sticker":["ly.img.sticker"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.sticker";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import F from"@cesdk/cesdk-js";var C=["ly.img.text","ly.img.text.styles","ly.img.text.curves"],M=class{constructor(e={}){this.config=e}name="cesdk-text-asset-source";version=F.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return C.includes(e)?["ly.img.text"]:[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n=C.filter(e=>!i.has(e));if(await Promise.all(n.map(s=>e.asset.addLocalAssetSourceFromJSONURI(`${r}${s}/content.json`,{matcher:this.config.include}))),this.addedAssetSourceIds.push(...n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));for(const e of this.addedAssetSourceIds){const t=this.getAssetLibraryEntries(e);for(const r of t)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:s})=>[...new Set([...s,e])]})}}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import P from"@cesdk/cesdk-js";var B=class{constructor(e={}){this.config=e}name="cesdk-text-component-asset-source";version=P.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.text.components":["ly.img.text"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.text.components";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import z from"@cesdk/cesdk-js";var N=class{constructor(e={}){this.config=e}name="cesdk-typeface-asset-source";version=z.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.typeface":["ly.img.typefaces"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.typeface";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import J from"@cesdk/cesdk-js";var O=[{id:"ly.img.image.upload",mimeTypes:["image/jpeg","image/png","image/webp","image/svg+xml","image/bmp","image/gif","image/apng"],assetLibraryEntries:["ly.img.image","ly.img.upload"]},{id:"ly.img.video.upload",mimeTypes:["application/json","video/mp4","video/quicktime","video/webm","video/matroska","image/gif","image/apng"],assetLibraryEntries:["ly.img.video","ly.img.upload"]},{id:"ly.img.audio.upload",mimeTypes:["audio/mpeg","audio/mp3","audio/x-m4a","audio/wav"],assetLibraryEntries:["ly.img.audio","ly.img.upload"]}],T=class{constructor(e={}){this.config=e}name="cesdk-upload-asset-sources";version=J.version;addedAssetSourceIds=[];addedLibraryEntryMappings=new Map;isExplicitMode(){return this.config.include?.some(e=>"string"==typeof e)??!1}getExplicitIncludes(){return this.config.include?new Set(this.config.include.filter(e=>"string"==typeof e)):new Set}getCustomizations(){return this.config.include?this.config.include.filter(e=>"object"==typeof e):[]}getAssetLibraryEntries(e){return e?Array.isArray(e)?e:[e]:[]}async initialize({engine:e,cesdk:s}){const t=new Set(e.asset.findAllSources()),r=this.isExplicitMode(),i=this.getExplicitIncludes(),n=this.getCustomizations(),o=new Map;if(r)for(const e of O)i.has(e.id)&&o.set(e.id,e);else for(const e of O)o.set(e.id,e);for(const e of n){const s=o.get(e.id);s?o.set(e.id,{...s,...e}):o.set(e.id,e)}const c=Array.from(o.values());for(const r of c){const{id:i,mimeTypes:n,assetLibraryEntries:o}=r;if(!t.has(i)&&(e.asset.addLocalSource(i,n),this.addedAssetSourceIds.push(i),s)){const e=this.getAssetLibraryEntries(o);this.addedLibraryEntryMappings.set(i,e);for(const t of e)s.ui.updateAssetLibraryEntry(t,{sourceIds:({currentIds:e})=>[...new Set([...e,i])]})}}s&&s.onReset(()=>this.cleanup({engine:e,cesdk:s}))}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.addedLibraryEntryMappings.get(t)??[];for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[],this.addedLibraryEntryMappings.clear()}};import G from"@cesdk/cesdk-js";var W=class{constructor(e={}){this.config=e}name="cesdk-vectorshape-asset-source";version=G.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.vector.shape":["ly.img.vector.shape","ly.img.shape.replace"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.vector.shape";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};export{l as BlurAssetSource,h as CaptionPresetsAssetSource,m as ColorPaletteAssetSource,b as CropPresetsAssetSource,S as DemoAssetSources,I as EffectsAssetSource,w as FiltersAssetSource,e as IMAGE_COLORS_SOURCE_ID,s as ImageColorsAssetSource,v as PagePresetsAssetSource,U as PremiumTemplatesAssetSource,j as StickerAssetSource,M as TextAssetSource,B as TextComponentAssetSource,N as TypefaceAssetSource,T as UploadAssetSources,W as VectorShapeAssetSource};