@imgly/plugin-ai-image-generation-web 0.1.9 → 0.1.10

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/icons/formats.ts", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/assetSources/CustomAssetSource.ts", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/assetSources/IndexedDBAssetSource.ts", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/assetSources/AggregatedAssetSource.ts", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/metadata/Metadata.ts", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_freeGlobal.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_root.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Symbol.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getRawTag.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_objectToString.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetTag.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObjectLike.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isArray.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObject.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isFunction.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_coreJsData.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isMasked.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_toSource.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsNative.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getValue.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getNative.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_WeakMap.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isIndex.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/eq.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isLength.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isArrayLike.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isPrototype.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseTimes.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsArguments.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isArguments.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/stubFalse.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isBuffer.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsTypedArray.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseUnary.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_nodeUtil.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isTypedArray.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayLikeKeys.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_overArg.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_nativeKeys.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseKeys.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/keys.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_nativeCreate.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashClear.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashDelete.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashGet.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashHas.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashSet.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Hash.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheClear.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_assocIndexOf.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheDelete.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheGet.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheHas.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheSet.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_ListCache.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Map.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheClear.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isKeyable.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getMapData.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheDelete.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheGet.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheHas.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheSet.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_MapCache.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayPush.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_stackClear.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_stackDelete.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_stackGet.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_stackHas.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_stackSet.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Stack.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayFilter.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/stubArray.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getSymbols.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetAllKeys.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getAllKeys.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_DataView.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Promise.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Set.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getTag.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Uint8Array.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setCacheAdd.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setCacheHas.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_SetCache.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arraySome.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cacheHas.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_equalArrays.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapToArray.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setToArray.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_equalByTag.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_equalObjects.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsEqualDeep.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsEqual.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isEqual.js", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/metadata/FillProcessingMetadata.ts", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/processing/fillProcessing.ts", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/processing/constants.ts", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/processing/initializeFillProcessing.ts", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/processing/registerFillProcessingComponents.ts", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/utils/colors.ts", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/utils/upload.ts", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/utils/uuid.ts", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/utils/images.ts", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/utils/isDefined.ts", "../../../../node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/index.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/common/renderImageUrlProperty.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/icons/formats.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/assetSources/CustomAssetSource.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/assetSources/IndexedDBAssetSource.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/assetSources/AggregatedAssetSource.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/metadata/Metadata.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_freeGlobal.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_root.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Symbol.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getRawTag.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_objectToString.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetTag.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObjectLike.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isArray.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObject.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isFunction.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_coreJsData.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isMasked.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_toSource.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsNative.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getValue.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getNative.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_WeakMap.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isIndex.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/eq.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isLength.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isArrayLike.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isPrototype.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseTimes.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsArguments.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isArguments.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/stubFalse.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isBuffer.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsTypedArray.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseUnary.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_nodeUtil.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isTypedArray.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayLikeKeys.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_overArg.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_nativeKeys.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseKeys.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/keys.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_nativeCreate.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashClear.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashDelete.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashGet.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashHas.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashSet.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Hash.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheClear.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_assocIndexOf.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheDelete.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheGet.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheHas.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheSet.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_ListCache.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Map.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheClear.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isKeyable.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getMapData.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheDelete.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheGet.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheHas.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheSet.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_MapCache.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayPush.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_stackClear.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_stackDelete.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_stackGet.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_stackHas.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_stackSet.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Stack.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayFilter.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/stubArray.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getSymbols.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetAllKeys.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getAllKeys.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_DataView.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Promise.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Set.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getTag.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Uint8Array.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setCacheAdd.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setCacheHas.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_SetCache.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arraySome.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cacheHas.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_equalArrays.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapToArray.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setToArray.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_equalByTag.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_equalObjects.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsEqualDeep.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsEqual.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isEqual.js", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/metadata/FillProcessingMetadata.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/processing/fillProcessing.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/processing/constants.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/processing/initializeFillProcessing.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/processing/registerFillProcessingComponents.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/utils/colors.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/utils/upload.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/utils/uuid.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/utils/images.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/utils/isDefined.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/node_modules/.pnpm/@imgly+plugin-utils@file+packages+plugin-utils_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-utils/src/index.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/common/renderStyleTransferProperty.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/openapi/dereferenceDocument.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/openapi/isOpenAPISchema.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/openapi/getProperties.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/utils.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/openapi/renderProperty.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/previewUri.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/getAssetResultForPlaceholder.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/getAssetResultForGenerated.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/middleware/middleware.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/middleware/loggingMiddleware.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/middleware/dryRunMiddleware.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/generate.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/handleGenerationError.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/renderGenerationComponents.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/registerPanelInputSchema.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/registerPanelInputCustom.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/icons.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/quickAction/getQuickActionMenu.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/quickAction/utils.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/middleware/highlightBlocksMiddleware.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/middleware/pendingMiddleware.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/middleware/lockMiddleware.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/quickAction/consumeGeneratedResult.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/middleware/editModeMiddleware.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/quickAction/generate.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/quickAction/registerQuickActionMenuComponent.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/initProvider.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/middleware/uploadMiddleware.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/middleware/rateLimitMiddleware.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/registerDockComponent.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/quickAction/common/QuickActionBasePrompt.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/quickAction/common/QuickActionBaseButton.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/quickAction/common/QuickActionBaseSelect.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/quickAction/common/QuickActionBaseLibrary.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/quickAction/common/QuickActionEditTextStyle.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/quickAction/common/enableImageFill.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/quickAction/common/QuickActionChangeImage.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/quickAction/common/QuickActionImageVariant.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/quickAction/common/QuickActionCombineImages.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/generation/quickAction/common/QuickActionSwapImageBackground.ts", "../../../../node_modules/.pnpm/@imgly+plugin-ai-generation-web@file+packages+plugin-ai-generation-web_@cesdk+cesdk-js@1.49.1_react@18.3.1_/node_modules/@imgly/plugin-ai-generation-web/src/index.ts", "../../src/open-ai/GptImage1.text2image.json", "../../src/open-ai/utils.ts", "../../src/open-ai/GptImage1.styles.ts", "../../src/open-ai/GptImage1.text2image.ts", "../../src/open-ai/GptImage1.image2image.json", "../../src/open-ai/GptImage1.image2image.ts", "../../src/open-ai/index.ts"],
4
- "sourcesContent": ["export default `\n<svg>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratioFree\"\n >\n <path d=\"M7 6C6.44772 6 6 6.44772 6 7V9.22222H4V7C4 5.34315 5.34315 4 7 4H9.22222V6H7Z\" fill=\"currentColor\"/>\n <path d=\"M17 6H14.7778V4H17C18.6569 4 20 5.34315 20 7V9.22222H18V7C18 6.44772 17.5523 6 17 6Z\" fill=\"currentColor\"/>\n <path d=\"M6 14.7778V17C6 17.5523 6.44772 18 7 18H9.22222V20H7C5.34315 20 4 18.6569 4 17V14.7778H6Z\" fill=\"currentColor\"/>\n <path d=\"M18 17V14.7778H20V17C20 18.6569 18.6569 20 17 20H14.7778V18H17C17.5523 18 18 17.5523 18 17Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratio4by3\"\n >\n <path d=\"M6.5 13H8V15H10V16.5H6.5V13Z\" fill=\"currentColor\"/>\n <path d=\"M14 9V7.5H17.5V11H16V9H14Z\" fill=\"currentColor\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M6 4C4.34315 4 3 5.34315 3 7V17C3 18.6569 4.34315 20 6 20H18C19.6569 20 21 18.6569 21 17V7C21 5.34315 19.6569 4 18 4H6ZM5 7C5 6.44772 5.44772 6 6 6H18C18.5523 6 19 6.44772 19 7V17C19 17.5523 18.5523 18 18 18H6C5.44772 18 5 17.5523 5 17V7Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratio16by9\"\n >\n <path d=\"M4.5 13H6V15H8V16.5H4.5V13Z\" fill=\"currentColor\"/>\n <path d=\"M16 9V7.5H19.5V11H18V9H16Z\" fill=\"currentColor\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M4 4C2.34315 4 1 5.34315 1 7V17C1 18.6569 2.34315 20 4 20H20C21.6569 20 23 18.6569 23 17V7C23 5.34315 21.6569 4 20 4H4ZM3 7C3 6.44772 3.44772 6 4 6H20C20.5523 6 21 6.44772 21 7V17C21 17.5523 20.5523 18 20 18H4C3.44772 18 3 17.5523 3 17V7Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratio9by16\"\n >\n <path d=\"M7.5 16H9V18H11V19.5H7.5V16Z\" fill=\"currentColor\"/>\n <path d=\"M13 6V4.5H16.5V8H15V6H13Z\" fill=\"currentColor\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M4 20C4 21.6569 5.34315 23 7 23H17C18.6569 23 20 21.6569 20 20V4C20 2.34315 18.6569 1 17 1H7C5.34315 1 4 2.34315 4 4V20ZM7 21C6.44772 21 6 20.5523 6 20V4C6 3.44772 6.44772 3 7 3H17C17.5523 3 18 3.44772 18 4V20C18 20.5523 17.5523 21 17 21H7Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratio3by4\"\n >\n <path d=\"M11 17.5V16H9V14H7.5V17.5H11Z\" fill=\"currentColor\"/>\n <path d=\"M15 10H16.5V6.5H13V8H15V10Z\" fill=\"currentColor\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M20 18C20 19.6569 18.6569 21 17 21H7C5.34315 21 4 19.6569 4 18V6C4 4.34315 5.34315 3 7 3H17C18.6569 3 20 4.34315 20 6V18ZM17 19C17.5523 19 18 18.5523 18 18V6C18 5.44772 17.5523 5 17 5H7C6.44771 5 6 5.44771 6 6V18C6 18.5523 6.44772 19 7 19H17Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratio1by1\"\n >\n <path d=\"M17.4142 8.00009L16 6.58587L14.2929 8.29298L15.7071 9.70719L17.4142 8.00009Z\" fill=\"currentColor\"/>\n <path d=\"M13.0404 12.3739L15.0404 10.3739L13.6262 8.95965L11.6262 10.9596L13.0404 12.3739Z\" fill=\"currentColor\"/>\n <path d=\"M10.3737 15.0405L12.3737 13.0405L10.9595 11.6263L8.95953 13.6263L10.3737 15.0405Z\" fill=\"currentColor\"/>\n <path d=\"M9.70708 15.7072L8.29286 14.293L6.58576 16.0001L7.99997 17.4143L9.70708 15.7072Z\" fill=\"currentColor\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M7 4C5.34315 4 4 5.34315 4 7V17C4 18.6569 5.34315 20 7 20H17C18.6569 20 20 18.6569 20 17V7C20 5.34315 18.6569 4 17 4H7ZM6 7C6 6.44772 6.44772 6 7 6H17C17.5523 6 18 6.44772 18 7V17C18 17.5523 17.5523 18 17 18H7C6.44772 18 6 17.5523 6 17V7Z\" fill=\"currentColor\"/>\n </symbol>\n</svg>\n`;\n", "import type {\n AssetDefinition,\n AssetQueryData,\n AssetResult,\n AssetSource,\n AssetsQueryResult\n} from '@cesdk/engine';\n\n/**\n * Simplified value type for select inputs that can be converted to asset definitions\n */\nexport type SelectValue = {\n id: string;\n label: string;\n thumbUri?: string;\n meta?: { [key: string]: any };\n};\n\n/**\n * A custom AssetSource implementation that manages assets from an array\n * and provides additional functionality like to mark assets as active or changing\n * labels.\n */\nexport class CustomAssetSource implements AssetSource {\n /** The unique id of the asset source */\n id: string;\n\n /** Array of assets to be served by this source */\n private assets: AssetDefinition[];\n\n /** Set of IDs for active assets */\n private activeAssetIds: Set<string>;\n\n /**\n * Creates a new instance of CustomAssetSource\n *\n * @param id - The unique identifier for this asset source\n * @param assets - Array of asset definitions or SelectValue objects to include in this source\n */\n constructor(id: string, assets: (AssetDefinition | SelectValue)[] = []) {\n this.id = id;\n this.assets = assets.map((asset) => {\n // Check if the asset is a SelectValue by looking for the label property as a string\n if (\n typeof (asset as SelectValue).label === 'string' &&\n !(\n (asset as AssetDefinition).label &&\n typeof (asset as AssetDefinition).label === 'object'\n )\n ) {\n const selectValue = asset as SelectValue;\n // Convert SelectValue to AssetDefinition\n return {\n id: selectValue.id,\n label: { en: selectValue.label },\n meta: selectValue.thumbUri\n ? { ...(selectValue.meta ?? {}), thumbUri: selectValue.thumbUri }\n : selectValue.meta\n } as AssetDefinition;\n }\n return asset as AssetDefinition;\n });\n this.activeAssetIds = new Set<string>();\n }\n\n /**\n * Find assets based on the provided query data\n * Supports pagination, searching, filtering, and active-first sorting\n *\n * @param queryData - Query parameters to filter and sort assets\n * @returns Promise with the query results\n */\n async findAssets(\n queryData: AssetQueryData\n ): Promise<AssetsQueryResult | undefined> {\n const {\n page,\n perPage,\n locale = 'en',\n sortActiveFirst,\n query,\n tags,\n groups,\n excludeGroups,\n sortingOrder,\n sortKey\n } = queryData;\n\n // Start with all assets\n let filteredAssets = [...this.assets];\n\n // Filter by groups if provided\n if (groups && groups.length > 0) {\n filteredAssets = filteredAssets.filter(\n (asset) =>\n asset.groups && groups.some((group) => asset.groups?.includes(group))\n );\n }\n\n // Filter out excluded groups if provided\n if (excludeGroups && excludeGroups.length > 0) {\n filteredAssets = filteredAssets.filter(\n (asset) =>\n !asset.groups ||\n !excludeGroups.some((group) => asset.groups?.includes(group))\n );\n }\n\n // Filter by query (search in label and tags)\n if (query) {\n const lowerQuery = query.toLowerCase();\n filteredAssets = filteredAssets.filter((asset) => {\n const label = asset.label?.[locale]?.toLowerCase();\n const assetTags = asset.tags?.[locale] || [];\n\n return (\n (label && label.includes(lowerQuery)) ||\n assetTags.some((tag) => tag.toLowerCase().includes(lowerQuery))\n );\n });\n }\n\n // Filter by exact tags if provided\n if (tags && tags.length > 0) {\n const tagArray = Array.isArray(tags) ? tags : [tags];\n filteredAssets = filteredAssets.filter((asset) => {\n const assetTags = asset.tags?.[locale] || [];\n return tagArray.some((tag) => assetTags.includes(tag));\n });\n }\n\n // Sort by active first if requested\n if (sortActiveFirst) {\n filteredAssets.sort((a, b) => {\n const aActive = this.activeAssetIds.has(a.id);\n const bActive = this.activeAssetIds.has(b.id);\n\n if (aActive && !bActive) return -1;\n if (!aActive && bActive) return 1;\n return 0;\n });\n }\n\n // Sort by sortKey if provided\n if (sortKey && sortKey !== 'id') {\n filteredAssets.sort((a, b) => {\n // Sort by metadata field\n const aValue = a.meta?.[sortKey];\n const bValue = b.meta?.[sortKey];\n\n if (aValue === undefined) return 1;\n if (bValue === undefined) return -1;\n\n if (typeof aValue === 'string' && typeof bValue === 'string') {\n return sortingOrder === 'Descending'\n ? bValue.localeCompare(aValue)\n : aValue.localeCompare(bValue);\n }\n\n if (typeof aValue === 'number' && typeof bValue === 'number') {\n return sortingOrder === 'Descending'\n ? bValue - aValue\n : aValue - bValue;\n }\n\n return 0;\n });\n } else if (sortKey === 'id') {\n // Sort by id\n filteredAssets.sort((a, b) => {\n return sortingOrder === 'Descending'\n ? b.id.localeCompare(a.id)\n : a.id.localeCompare(b.id);\n });\n }\n\n // Calculate pagination\n const total = filteredAssets.length;\n const startIndex = page * perPage;\n const endIndex = startIndex + perPage;\n const paginatedAssets = filteredAssets.slice(startIndex, endIndex);\n\n // Transform AssetDefinition objects to AssetResult objects\n const resultAssets: AssetResult[] = paginatedAssets.map((asset) => {\n return {\n id: asset.id,\n groups: asset.groups,\n meta: asset.meta,\n payload: asset.payload,\n locale,\n label: asset.label?.[locale],\n tags: asset.tags?.[locale],\n active: this.activeAssetIds.has(asset.id)\n };\n });\n\n // Calculate next page if there are more assets\n const nextPage = endIndex < total ? page + 1 : undefined;\n\n return {\n assets: resultAssets,\n currentPage: page,\n nextPage,\n total\n };\n }\n\n updateLabel(assetId: string, label: string, locale: string): void {\n this.assets.forEach((asset) => {\n if (asset.id === assetId) {\n asset.label = asset.label || {};\n asset.label[locale] = label;\n }\n });\n }\n\n /**\n * Get the asset select value by its ID\n *\n * @param assetId - The ID of the asset to retrieve\n * @returns The SelectValue object for the asset or undefined if not found\n */\n getAssetSelectValue(assetId: string): SelectValue | undefined {\n const asset = this.assets.find(({ id }) => id === assetId);\n if (asset) {\n return {\n id: asset.id,\n label: asset.label?.en || '',\n thumbUri: asset.meta?.thumbUri\n };\n }\n return undefined;\n }\n\n /**\n * Get an asset by its ID\n */\n getAsset(id: string): AssetDefinition | undefined {\n return this.assets.find((asset) => asset.id === id);\n }\n\n /**\n * Set an asset as active by its ID\n *\n * @param assetId - The ID of the asset to mark as active\n */\n setAssetActive(assetId: string): void {\n this.activeAssetIds.add(assetId);\n }\n\n /**\n * Get all active asset IDs\n *\n * @returns Array of active asset IDs\n */\n getActiveAssetIds(): string[] {\n return Array.from(this.activeAssetIds);\n }\n\n /**\n * Set multiple assets as active by their IDs\n *\n * @param assetIds - Array of asset IDs to mark as active\n */\n setAssetsActive(assetIds: string[]): void {\n assetIds.forEach((id) => this.activeAssetIds.add(id));\n }\n\n /**\n * Set an asset as inactive by its ID\n *\n * @param assetId - The ID of the asset to mark as inactive\n */\n setAssetInactive(assetId: string): void {\n this.activeAssetIds.delete(assetId);\n }\n\n /**\n * Clear all active assets\n */\n clearActiveAssets(): void {\n this.activeAssetIds.clear();\n }\n\n /**\n * Check if an asset is marked as active\n *\n * @param assetId - The ID of the asset to check\n * @returns True if the asset is active, false otherwise\n */\n isAssetActive(assetId: string): boolean {\n return this.activeAssetIds.has(assetId);\n }\n\n /**\n * Add an asset to this source\n *\n * @param asset - The asset definition to add\n */\n addAsset(asset: AssetDefinition): void {\n // Check if asset with this ID already exists\n const existingIndex = this.assets.findIndex((a) => a.id === asset.id);\n if (existingIndex >= 0) {\n // Replace existing asset\n this.assets[existingIndex] = asset;\n } else {\n // Add new asset\n this.assets.push(asset);\n }\n }\n\n /**\n * Remove an asset from this source\n *\n * @param assetId - The ID of the asset to remove\n */\n removeAsset(assetId: string): void {\n const index = this.assets.findIndex((asset) => asset.id === assetId);\n if (index !== -1) {\n this.assets.splice(index, 1);\n this.activeAssetIds.delete(assetId);\n }\n }\n\n /**\n * Get all available groups from the assets\n *\n * @returns Array of unique group names\n */\n async getGroups(): Promise<string[]> {\n const groups = new Set<string>();\n this.assets.forEach((asset) => {\n if (asset.groups) {\n asset.groups.forEach((group) => groups.add(group));\n }\n });\n return Array.from(groups);\n }\n\n /**\n * Returns the supported MIME types for this asset source\n *\n * @returns Array of supported MIME types\n */\n getSupportedMimeTypes(): string[] {\n return [\n 'image/jpeg',\n 'image/png',\n 'image/svg+xml',\n 'image/webp',\n 'video/mp4',\n 'audio/mpeg'\n ];\n }\n}\n\n/**\n * Helper function to create a CustomAssetSource instance\n *\n * @param id - The unique identifier for this asset source\n * @param assets - Array of asset definitions or SelectValue objects to include in this source\n * @returns A new CustomAssetSource instance\n */\nexport function createCustomAssetSource(\n id: string,\n assets: (AssetDefinition | SelectValue)[] = []\n): CustomAssetSource {\n return new CustomAssetSource(id, assets);\n}\n\nexport default CustomAssetSource;\n", "/* eslint-disable no-console */\nimport {\n CreativeEngine,\n type AssetDefinition,\n type AssetQueryData,\n type AssetResult,\n type AssetSource,\n type AssetsQueryResult\n} from '@cesdk/cesdk-js';\n\ntype BlobEntry = {\n id: string;\n blob: Blob;\n};\n\n// Asset definition with meta containing insertedAt timestamp\ntype AssetEntryWithMeta = AssetDefinition;\n\n/**\n * IndexedDBAssetSource implements the AssetSource interface using IndexedDB as the storage backend.\n */\nexport class IndexedDBAssetSource implements AssetSource {\n /** The unique id of the API */\n public readonly id: string;\n\n public readonly engine: CreativeEngine;\n\n private readonly dbName: string;\n\n private readonly dbVersion: number;\n\n private readonly assetStoreName: string = 'assets';\n\n private readonly blobStoreName: string = 'blobs';\n\n private db: IDBDatabase | null = null;\n\n /**\n * Creates a new IndexedDBAssetSource\n *\n * @param id - The unique identifier for this asset source\n * @param {Object} [options] - Optional configuration options.\n * @param {string} [options.dbName] - The name of the database.\n * @param {number} [options.dbVersion] - The version number of the database.\n */\n constructor(\n id: string,\n engine: CreativeEngine,\n options?: {\n dbName?: string;\n dbVersion?: number;\n }\n ) {\n this.id = id;\n this.engine = engine;\n this.dbName = options?.dbName ?? `ly.img.assetSource/${id}`;\n this.dbVersion = options?.dbVersion ?? 1;\n }\n\n /**\n * Initialize the database connection and create object stores if needed\n */\n public async initialize(): Promise<void> {\n if (this.db) {\n return;\n }\n\n return new Promise((resolve, reject) => {\n const request = indexedDB.open(this.dbName, this.dbVersion);\n\n request.onerror = (event) => {\n reject(\n new Error(\n `Failed to open IndexedDB: ${(event.target as IDBRequest).error}`\n )\n );\n };\n\n request.onupgradeneeded = (event) => {\n const db = (event.target as IDBOpenDBRequest).result;\n\n // Create asset store if it doesn't exist\n if (!db.objectStoreNames.contains(this.assetStoreName)) {\n db.createObjectStore(this.assetStoreName, {\n keyPath: 'id'\n });\n }\n // Create blob store if it doesn't exist\n if (!db.objectStoreNames.contains(this.blobStoreName)) {\n db.createObjectStore(this.blobStoreName, {\n keyPath: 'id'\n });\n }\n };\n\n request.onsuccess = (event) => {\n this.db = (event.target as IDBOpenDBRequest).result;\n resolve();\n };\n });\n }\n\n /**\n * Close the database connection\n */\n public close(): void {\n if (this.db) {\n this.db.close();\n this.db = null;\n }\n }\n\n /**\n * Find all assets for the given type and the provided query data.\n *\n * @param queryData - The query parameters for filtering assets\n * @param insertionSortOrder - Optional parameter to sort by insertion time: 'asc' for oldest first, 'desc' for newest first (default)\n * @returns A promise that resolves to the query results or undefined if there was an error\n */\n public async findAssets(\n queryData: AssetQueryData\n ): Promise<AssetsQueryResult | undefined> {\n await this.initialize();\n\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n try {\n // Get all assets from the store with specified insertion order\n const assetDefinitions = await this.getAllAssets('asc');\n\n let assetResults = assetDefinitions.reduce((acc, assetDefinition) => {\n const locale = queryData.locale ?? 'en';\n let label = '';\n let tags: string[] = [];\n\n // Handle localized label if available\n if (\n assetDefinition.label != null &&\n typeof assetDefinition.label === 'object' &&\n assetDefinition.label[locale]\n ) {\n label = assetDefinition.label[locale];\n }\n\n // Handle localized tags if available\n if (\n assetDefinition.tags != null &&\n typeof assetDefinition.tags === 'object' &&\n assetDefinition.tags[locale]\n ) {\n tags = assetDefinition.tags[locale];\n }\n\n const result: AssetResult = {\n ...assetDefinition,\n label,\n tags\n };\n\n if (this.filterAsset(result, queryData)) {\n acc.push(result);\n }\n\n return acc;\n }, [] as AssetResult[]);\n\n assetResults = await this.restoreBlobUrls(assetResults);\n\n // Apply sorting\n assetResults = this.sortAssets(assetResults, queryData);\n\n // Apply pagination\n const { page, perPage } = queryData;\n const startIndex = page * perPage;\n const endIndex = startIndex + perPage;\n const paginatedAssets = assetResults.slice(startIndex, endIndex);\n\n // Determine if there's a next page\n const nextPage = endIndex < assetResults.length ? page + 1 : undefined;\n\n const result = {\n assets: paginatedAssets,\n currentPage: page,\n nextPage,\n total: assetResults.length\n };\n\n return result;\n } catch (error) {\n console.error('Error finding assets:', error);\n return undefined;\n }\n }\n\n public async getGroups(): Promise<string[]> {\n await this.initialize();\n\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n return new Promise((resolve, reject) => {\n const transaction = this.db!.transaction(this.assetStoreName, 'readonly');\n const store = transaction.objectStore(this.assetStoreName);\n const request = store.getAll();\n\n request.onsuccess = () => {\n const allGroups = new Set<string>();\n\n // Extract all groups from all assets\n (request.result as AssetResult[]).forEach((asset) => {\n if (asset.groups && Array.isArray(asset.groups)) {\n asset.groups.forEach((group) => allGroups.add(group));\n }\n });\n\n const uniqueGroups = [...allGroups];\n resolve(uniqueGroups);\n };\n\n request.onerror = () => {\n reject(new Error(`Failed to get groups: ${request.error}`));\n };\n });\n }\n\n /**\n * Adds the given asset to this source. Part of the AssetSource interface.\n *\n * @param asset - The asset definition to add\n */\n public addAsset(asset: AssetDefinition): void {\n this.initialize()\n .then(async () => {\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n const transaction = this.db.transaction(\n this.assetStoreName,\n 'readwrite'\n );\n const assetStore = transaction.objectStore(this.assetStoreName);\n\n const blobsToStore = new Set<string>();\n processBlobUrls(asset, (value) => {\n blobsToStore.add(value);\n });\n\n setTimeout(() => {\n this.storeBlobUrls([...blobsToStore]);\n });\n\n // Ensure asset has meta object with insertedAt timestamp\n const assetWithMeta: AssetEntryWithMeta = {\n ...asset,\n meta: {\n ...asset.meta,\n insertedAt: asset.meta?.insertedAt || Date.now()\n }\n };\n\n // Store the asset in the database\n assetStore.put(assetWithMeta);\n\n transaction.onerror = () => {\n console.error(`Failed to add asset: ${transaction.error}`);\n };\n })\n .catch((error) => {\n console.error('Error initializing database:', error);\n });\n }\n\n /**\n * Removes the given asset from this source. Part of the AssetSource interface.\n *\n * @param assetId - The ID of the asset to remove\n */\n public async removeAsset(assetId: string): Promise<void> {\n const asset = await this.getAsset(assetId);\n\n return this.initialize()\n .then(() => {\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n const transaction = this.db.transaction(\n this.assetStoreName,\n 'readwrite'\n );\n const store = transaction.objectStore(this.assetStoreName);\n store.delete(assetId);\n\n transaction.oncomplete = () => {\n processBlobUrls(asset, (value) => {\n this.removeBlob(value);\n });\n this.engine.asset.assetSourceContentsChanged(this.id);\n };\n\n transaction.onerror = () => {\n console.error(`Failed to remove asset: ${transaction.error}`);\n };\n })\n .catch((error) => {\n console.error('Error initializing database:', error);\n });\n }\n\n /**\n * Removes the given asset from this source. Part of the AssetSource interface.\n *\n * @param assetId - The ID of the asset to remove\n */\n public async removeBlob(blobId: string): Promise<void> {\n return this.initialize()\n .then(() => {\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n const transaction = this.db.transaction(\n this.blobStoreName,\n 'readwrite'\n );\n const store = transaction.objectStore(this.blobStoreName);\n store.delete(blobId);\n\n transaction.onerror = () => {\n console.error(`Failed to remove blob: ${transaction.error}`);\n };\n })\n .catch((error) => {\n console.error('Error initializing database:', error);\n });\n }\n\n /**\n * Get all assets from the database sorted by insertion order (newest to oldest)\n *\n * @param sortOrder - Optional parameter to specify sort order: 'asc' for oldest first, 'desc' for newest first (default)\n * @returns A promise that resolves to an array of all assets\n */\n private async getAllAssets(\n sortOrder: 'asc' | 'desc' = 'desc'\n ): Promise<AssetDefinition[]> {\n return new Promise((resolve, reject) => {\n const transaction = this.db!.transaction(this.assetStoreName, 'readonly');\n const store = transaction.objectStore(this.assetStoreName);\n const request = store.getAll();\n\n request.onsuccess = () => {\n const assets = request.result as AssetEntryWithMeta[];\n\n // Sort by insertion timestamp\n assets.sort((a, b) => {\n // Default to current time if insertedAt is missing (for backward compatibility)\n // First check in meta.insertedAt, then fallback to legacy _insertedAt for backward compatibility\n const timeA =\n a.meta?.insertedAt || (a as any)._insertedAt || Date.now();\n const timeB =\n b.meta?.insertedAt || (b as any)._insertedAt || Date.now();\n\n // Sort based on requested order\n return sortOrder === 'asc'\n ? timeA - timeB // oldest first\n : timeB - timeA; // newest first (default)\n });\n\n resolve(assets);\n };\n\n request.onerror = () => {\n reject(new Error(`Failed to get assets: ${request.error}`));\n };\n });\n }\n\n // Retrieve a blob by ID\n async getAsset(id: string): Promise<AssetResult | undefined> {\n return new Promise((resolve, reject) => {\n const transaction = this.db!.transaction(this.assetStoreName, 'readonly');\n const store = transaction.objectStore(this.assetStoreName);\n const request = store.get(id);\n\n request.onsuccess = () => {\n resolve(request.result as AssetResult);\n };\n\n request.onerror = () => {\n reject(new Error(`Failed to get blob: ${request.error}`));\n };\n });\n }\n\n // Retrieve a blob by ID\n async getBlob(id: string): Promise<BlobEntry | undefined> {\n return new Promise((resolve, reject) => {\n const transaction = this.db!.transaction(this.blobStoreName, 'readonly');\n const store = transaction.objectStore(this.blobStoreName);\n const request = store.get(id);\n\n request.onsuccess = () => {\n resolve(request.result as BlobEntry);\n };\n\n request.onerror = () => {\n reject(new Error(`Failed to get blob: ${request.error}`));\n };\n });\n }\n\n async createBlobUrlFromStore(blobUrl: string): Promise<string> {\n const blobEntry = await this.getBlob(blobUrl);\n if (blobEntry != null) {\n return URL.createObjectURL(blobEntry.blob);\n }\n return blobUrl;\n }\n\n async storeBlobUrls(urls: string[]): Promise<void> {\n const blobsToStore: { [key: string]: Blob } = {};\n await Promise.all(\n urls.map(async (blobUrl) => {\n const blobResponse = await fetch(blobUrl);\n const blob = await blobResponse.blob();\n blobsToStore[blobUrl] = blob;\n })\n );\n\n return this.initialize()\n .then(async () => {\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n const transaction = this.db.transaction(\n this.blobStoreName,\n 'readwrite'\n );\n const blobStore = transaction.objectStore(this.blobStoreName);\n\n // Store the asset in the database\n Object.entries(blobsToStore).forEach(([key, blob]) => {\n const asset: BlobEntry = { id: key, blob };\n blobStore.put(asset);\n });\n\n transaction.onerror = () => {\n console.error(`Failed to add blobs: ${transaction.error}`);\n };\n })\n .catch((error) => {\n console.error('Error initializing database:', error);\n });\n }\n\n async restoreBlobUrls(assets: AssetResult[]): Promise<AssetResult[]> {\n const blobReplaced: { [key: string]: string } = {};\n const blobUrls: Set<string> = new Set();\n processBlobUrls(assets, (value) => {\n blobUrls.add(value);\n });\n\n await Promise.all(\n [...blobUrls].map(async (value) => {\n const newUrl = await this.createBlobUrlFromStore(value);\n blobReplaced[value] = newUrl;\n })\n );\n\n return processBlobUrls(assets, (value) => {\n return blobReplaced[value] ?? value;\n });\n }\n\n /**\n * Returns if the given asset should be filtered based on query data\n *\n * @param asset - The asset to filter\n * @param queryData - The query parameters to filter by\n * @returns true if the asset should be included, false otherwise\n */\n private filterAsset(asset: AssetResult, queryData: AssetQueryData): boolean {\n const { query, tags, groups, excludeGroups } = queryData;\n\n // Filter by query string (search on label and tags)\n if (query && query.trim() !== '') {\n const lowerQuery = query.trim().toLowerCase().split(' ');\n\n const lowerLabel = asset.label?.toLowerCase() ?? '';\n const lowerTags = asset.tags?.map((tag) => tag.toLowerCase()) ?? [];\n\n const matchLabelOrTag = lowerQuery.every((word) => {\n return (\n lowerLabel.includes(word) ||\n lowerTags.some((tag) => tag.includes(word))\n );\n });\n\n if (!matchLabelOrTag) {\n return false;\n }\n }\n\n // Filter by exact tags if provided by the query\n if (tags) {\n const tagList = Array.isArray(tags) ? tags : [tags];\n if (\n tagList.length > 0 &&\n (!asset.tags || !tagList.every((tag) => asset.tags?.includes(tag)))\n ) {\n return false;\n }\n }\n\n // Filter by groups\n if (groups && groups.length > 0) {\n if (\n !asset.groups ||\n !groups.some((group) => asset.groups?.includes(group))\n ) {\n return false;\n }\n }\n\n // Filter by excluded groups\n if (excludeGroups && excludeGroups.length > 0) {\n if (\n asset.groups &&\n asset.groups.some((group) => excludeGroups.includes(group))\n ) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Sort assets based on query data\n *\n * @param assets - The assets to sort\n * @param queryData - The query parameters with sorting information\n * @returns The sorted assets\n */\n private sortAssets(\n assets: AssetResult[],\n queryData: AssetQueryData\n ): AssetResult[] {\n const { sortingOrder, sortKey, sortActiveFirst } = queryData;\n\n // Clone the array to avoid modifying the original\n const sortedAssets = [...assets];\n\n // If no sorting order specified or set to 'None', return the current order\n if (!sortingOrder || sortingOrder === 'None') {\n return sortedAssets;\n }\n\n // Sort by the specified key\n if (sortKey) {\n sortedAssets.sort((a, b) => {\n let valueA;\n let valueB;\n\n if (sortKey === 'id') {\n valueA = a.id;\n valueB = b.id;\n } else {\n // Handle metadata sorting (assuming metadata is stored in a 'metadata' field)\n valueA = a.meta?.[sortKey] ?? null;\n valueB = b.meta?.[sortKey] ?? null;\n }\n\n // Handle null/undefined values\n if (valueA === null || valueA === undefined)\n return sortingOrder === 'Ascending' ? -1 : 1;\n if (valueB === null || valueB === undefined)\n return sortingOrder === 'Ascending' ? 1 : -1;\n\n // Compare values based on sorting order\n if (typeof valueA === 'string' && typeof valueB === 'string') {\n return sortingOrder === 'Ascending'\n ? valueA.localeCompare(valueB)\n : valueB.localeCompare(valueA);\n } else {\n return sortingOrder === 'Ascending'\n ? valueA < valueB\n ? -1\n : valueA > valueB\n ? 1\n : 0\n : valueA > valueB\n ? -1\n : valueA < valueB\n ? 1\n : 0;\n }\n });\n } else if (sortingOrder === 'Descending') {\n // If no sort key is specified, and sorting order set\n // to Descending, just reverse original order\n sortedAssets.reverse();\n }\n\n // Sort by active first if requested\n if (sortActiveFirst) {\n sortedAssets.sort((a, b) => {\n if (a.active && !b.active) return -1;\n if (!a.active && b.active) return 1;\n return 0;\n });\n }\n\n return sortedAssets;\n }\n}\n\n/**\n * Goes through an object and calls a callback for every string value that starts with 'blob:'\n * The callback can return a string to replace the original value\n * @param obj The object to traverse\n * @param callback Function to call when a blob URL is found, can return a replacement value\n * @param path Current path in the object (used for recursion)\n * @returns The modified object (or the original if no replacements were made)\n */\nfunction processBlobUrls<T>(\n obj: T,\n callback: (value: string, path: string) => string | void,\n path: string = ''\n): T {\n // Return the object as is if it's null or not an object\n if (obj === null || typeof obj !== 'object') {\n return obj;\n }\n\n // Handle arrays\n if (Array.isArray(obj)) {\n for (let index = 0; index < obj.length; index++) {\n const currentPath = path ? `${path}[${index}]` : `[${index}]`;\n\n if (typeof obj[index] === 'string' && obj[index].startsWith('blob:')) {\n const replacement = callback(obj[index], currentPath);\n if (typeof replacement === 'string') {\n obj[index] = replacement;\n }\n } else {\n obj[index] = processBlobUrls(obj[index], callback, currentPath);\n }\n }\n return obj;\n }\n\n // Handle regular objects\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n const value = obj[key];\n const currentPath = path ? `${path}.${key}` : key;\n\n if (typeof value === 'string' && value.startsWith('blob:')) {\n const replacement = callback(value, currentPath);\n if (typeof replacement === 'string') {\n // @ts-ignore\n obj[key] = replacement;\n }\n } else {\n obj[key] = processBlobUrls(value, callback, currentPath);\n }\n }\n }\n\n return obj;\n}\n\nexport default IndexedDBAssetSource;\n", "/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type {\n AssetDefinition,\n AssetQueryData,\n AssetResult,\n AssetSource,\n AssetsQueryResult\n} from '@cesdk/cesdk-js';\nimport CreativeEditorSDK from '@cesdk/cesdk-js';\n\n/**\n * AggregatedAssetSource implements the AssetSource interface by aggregating\n * multiple asset sources via the cesdk API and combining their results.\n *\n * This asset source is read-only - it does not support adding or removing assets.\n */\nexport class AggregatedAssetSource implements AssetSource {\n /** The unique id of the asset source */\n public readonly id: string;\n\n /** The Creative Editor SDK instance */\n private cesdk: CreativeEditorSDK;\n\n /** The IDs of asset sources to aggregate */\n private assetSourceIds: string[];\n\n /**\n * Creates a new AggregatedAssetSource\n *\n * @param id - The unique identifier for this asset source\n * @param cesdk - The Creative Editor SDK instance\n * @param assetSourceIds - The IDs of asset sources to aggregate\n */\n constructor(id: string, cesdk: CreativeEditorSDK, assetSourceIds: string[]) {\n this.id = id;\n this.cesdk = cesdk;\n this.assetSourceIds = assetSourceIds;\n }\n\n /**\n * Find assets across all aggregated sources based on the provided query data\n * Results are sorted by the insertedAt timestamp in meta field\n *\n * @param queryData - Query parameters to filter and sort assets\n * @returns Promise with the query results\n */\n async findAssets(\n queryData: AssetQueryData\n ): Promise<AssetsQueryResult | undefined> {\n try {\n // Query all asset sources via cesdk\n const queryPromises = this.assetSourceIds.map((sourceId) =>\n this.cesdk.engine.asset.findAssets(sourceId, {\n ...queryData,\n // Increase page size to get all assets from each source\n // We'll handle pagination after merging\n perPage: 9999,\n page: 0\n })\n );\n\n // Wait for all queries to complete\n const results = await Promise.all(queryPromises);\n\n // Combine all assets from all sources\n let allAssets: AssetResult[] = [];\n results.forEach((result) => {\n if (result?.assets) {\n allAssets = allAssets.concat(result.assets);\n }\n });\n\n // Sort by insertedAt timestamp\n allAssets.sort((a, b) => {\n const timeA = (a.meta?.insertedAt as number) || 0;\n const timeB = (b.meta?.insertedAt as number) || 0;\n\n // Sort newest first (descending)\n return timeB - timeA;\n });\n\n // Apply pagination after merging\n const { page, perPage } = queryData;\n const startIndex = page * perPage;\n const endIndex = startIndex + perPage;\n const paginatedAssets = allAssets.slice(startIndex, endIndex);\n\n // Calculate if there is a next page\n const nextPage = endIndex < allAssets.length ? page + 1 : undefined;\n\n return {\n assets: paginatedAssets,\n currentPage: page,\n nextPage,\n total: allAssets.length\n };\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error finding assets:', error);\n return undefined;\n }\n }\n\n /**\n * Retrieves all groups from all aggregated asset sources using cesdk\n * @returns Promise with an array of unique group names\n */\n async getGroups(): Promise<string[]> {\n const groupPromises = this.assetSourceIds.map((sourceId) =>\n this.cesdk.engine.asset.getGroups(sourceId)\n );\n\n const groupArrays = await Promise.all(groupPromises);\n\n // Combine and deduplicate groups\n const uniqueGroups = new Set<string>();\n groupArrays.forEach((groups) => {\n groups.forEach((group) => uniqueGroups.add(group));\n });\n\n return Array.from(uniqueGroups);\n }\n\n /**\n * This operation is not supported in AggregatedAssetSource\n * @throws Error - This method is not supported\n */\n addAsset(_asset: AssetDefinition): void {\n throw new Error('AggregatedAssetSource does not support adding assets');\n }\n\n /**\n * This operation is not supported in AggregatedAssetSource\n * @throws Error - This method is not supported\n */\n removeAsset(_assetId: string): void {\n throw new Error('AggregatedAssetSource does not support removing assets');\n }\n}\n\n/**\n * Helper function to create an AggregatedAssetSource instance\n *\n * @param id - The unique identifier for this asset source\n * @param cesdk - The Creative Editor SDK instance\n * @param assetSourceIds - The IDs of asset sources to aggregate\n * @returns A new AggregatedAssetSource instance\n */\nexport function createAggregatedAssetSource(\n id: string,\n cesdk: CreativeEditorSDK,\n assetSourceIds: string[]\n): AggregatedAssetSource {\n return new AggregatedAssetSource(id, cesdk, assetSourceIds);\n}\n\nexport default AggregatedAssetSource;\n", "import { type CreativeEngine } from '@cesdk/cesdk-js';\n\nclass Metadata<V> {\n engine: CreativeEngine;\n\n key: string;\n\n constructor(engine: CreativeEngine, key: string) {\n this.engine = engine;\n this.key = key;\n }\n\n hasData(blockId: number): boolean {\n return (\n this.engine.block.isValid(blockId) &&\n this.engine.block.hasMetadata(blockId, this.key)\n );\n }\n\n get(blockId: number): V | undefined {\n if (this.hasData(blockId)) {\n return JSON.parse(this.engine.block.getMetadata(blockId, this.key));\n }\n return undefined;\n }\n\n set(blockId: number, value: V) {\n this.engine.block.setMetadata(blockId, this.key, JSON.stringify(value));\n }\n\n clear(blockId: number) {\n if (this.engine.block.hasMetadata(blockId, this.key)) {\n this.engine.block.removeMetadata(blockId, this.key);\n }\n }\n}\n\nexport default Metadata;\n", "/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\nexport default freeGlobal;\n", "import freeGlobal from './_freeGlobal.js';\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\nexport default root;\n", "import root from './_root.js';\n\n/** Built-in value references. */\nvar Symbol = root.Symbol;\n\nexport default Symbol;\n", "import Symbol from './_Symbol.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\nfunction getRawTag(value) {\n var isOwn = hasOwnProperty.call(value, symToStringTag),\n tag = value[symToStringTag];\n\n try {\n value[symToStringTag] = undefined;\n var unmasked = true;\n } catch (e) {}\n\n var result = nativeObjectToString.call(value);\n if (unmasked) {\n if (isOwn) {\n value[symToStringTag] = tag;\n } else {\n delete value[symToStringTag];\n }\n }\n return result;\n}\n\nexport default getRawTag;\n", "/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\nfunction objectToString(value) {\n return nativeObjectToString.call(value);\n}\n\nexport default objectToString;\n", "import Symbol from './_Symbol.js';\nimport getRawTag from './_getRawTag.js';\nimport objectToString from './_objectToString.js';\n\n/** `Object#toString` result references. */\nvar nullTag = '[object Null]',\n undefinedTag = '[object Undefined]';\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n return (symToStringTag && symToStringTag in Object(value))\n ? getRawTag(value)\n : objectToString(value);\n}\n\nexport default baseGetTag;\n", "/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return value != null && typeof value == 'object';\n}\n\nexport default isObjectLike;\n", "/**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\nvar isArray = Array.isArray;\n\nexport default isArray;\n", "/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n}\n\nexport default isObject;\n", "import baseGetTag from './_baseGetTag.js';\nimport isObject from './isObject.js';\n\n/** `Object#toString` result references. */\nvar asyncTag = '[object AsyncFunction]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n proxyTag = '[object Proxy]';\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n if (!isObject(value)) {\n return false;\n }\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 9 which returns 'object' for typed arrays and other constructors.\n var tag = baseGetTag(value);\n return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;\n}\n\nexport default isFunction;\n", "import root from './_root.js';\n\n/** Used to detect overreaching core-js shims. */\nvar coreJsData = root['__core-js_shared__'];\n\nexport default coreJsData;\n", "import coreJsData from './_coreJsData.js';\n\n/** Used to detect methods masquerading as native. */\nvar maskSrcKey = (function() {\n var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');\n return uid ? ('Symbol(src)_1.' + uid) : '';\n}());\n\n/**\n * Checks if `func` has its source masked.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` is masked, else `false`.\n */\nfunction isMasked(func) {\n return !!maskSrcKey && (maskSrcKey in func);\n}\n\nexport default isMasked;\n", "/** Used for built-in method references. */\nvar funcProto = Function.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/**\n * Converts `func` to its source code.\n *\n * @private\n * @param {Function} func The function to convert.\n * @returns {string} Returns the source code.\n */\nfunction toSource(func) {\n if (func != null) {\n try {\n return funcToString.call(func);\n } catch (e) {}\n try {\n return (func + '');\n } catch (e) {}\n }\n return '';\n}\n\nexport default toSource;\n", "import isFunction from './isFunction.js';\nimport isMasked from './_isMasked.js';\nimport isObject from './isObject.js';\nimport toSource from './_toSource.js';\n\n/**\n * Used to match `RegExp`\n * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).\n */\nvar reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g;\n\n/** Used to detect host constructors (Safari). */\nvar reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n\n/** Used for built-in method references. */\nvar funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Used to detect if a method is native. */\nvar reIsNative = RegExp('^' +\n funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\\\$&')\n .replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$'\n);\n\n/**\n * The base implementation of `_.isNative` without bad shim checks.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n * else `false`.\n */\nfunction baseIsNative(value) {\n if (!isObject(value) || isMasked(value)) {\n return false;\n }\n var pattern = isFunction(value) ? reIsNative : reIsHostCtor;\n return pattern.test(toSource(value));\n}\n\nexport default baseIsNative;\n", "/**\n * Gets the value at `key` of `object`.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\nfunction getValue(object, key) {\n return object == null ? undefined : object[key];\n}\n\nexport default getValue;\n", "import baseIsNative from './_baseIsNative.js';\nimport getValue from './_getValue.js';\n\n/**\n * Gets the native function at `key` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the method to get.\n * @returns {*} Returns the function if it's native, else `undefined`.\n */\nfunction getNative(object, key) {\n var value = getValue(object, key);\n return baseIsNative(value) ? value : undefined;\n}\n\nexport default getNative;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar WeakMap = getNative(root, 'WeakMap');\n\nexport default WeakMap;\n", "/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/** Used to detect unsigned integer values. */\nvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n/**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\nfunction isIndex(value, length) {\n var type = typeof value;\n length = length == null ? MAX_SAFE_INTEGER : length;\n\n return !!length &&\n (type == 'number' ||\n (type != 'symbol' && reIsUint.test(value))) &&\n (value > -1 && value % 1 == 0 && value < length);\n}\n\nexport default isIndex;\n", "/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\nexport default eq;\n", "/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\nexport default isLength;\n", "import isFunction from './isFunction.js';\nimport isLength from './isLength.js';\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n}\n\nexport default isArrayLike;\n", "/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Checks if `value` is likely a prototype object.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.\n */\nfunction isPrototype(value) {\n var Ctor = value && value.constructor,\n proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;\n\n return value === proto;\n}\n\nexport default isPrototype;\n", "/**\n * The base implementation of `_.times` without support for iteratee shorthands\n * or max array length checks.\n *\n * @private\n * @param {number} n The number of times to invoke `iteratee`.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the array of results.\n */\nfunction baseTimes(n, iteratee) {\n var index = -1,\n result = Array(n);\n\n while (++index < n) {\n result[index] = iteratee(index);\n }\n return result;\n}\n\nexport default baseTimes;\n", "import baseGetTag from './_baseGetTag.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]';\n\n/**\n * The base implementation of `_.isArguments`.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n */\nfunction baseIsArguments(value) {\n return isObjectLike(value) && baseGetTag(value) == argsTag;\n}\n\nexport default baseIsArguments;\n", "import baseIsArguments from './_baseIsArguments.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Built-in value references. */\nvar propertyIsEnumerable = objectProto.propertyIsEnumerable;\n\n/**\n * Checks if `value` is likely an `arguments` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n * else `false`.\n * @example\n *\n * _.isArguments(function() { return arguments; }());\n * // => true\n *\n * _.isArguments([1, 2, 3]);\n * // => false\n */\nvar isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {\n return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&\n !propertyIsEnumerable.call(value, 'callee');\n};\n\nexport default isArguments;\n", "/**\n * This method returns `false`.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {boolean} Returns `false`.\n * @example\n *\n * _.times(2, _.stubFalse);\n * // => [false, false]\n */\nfunction stubFalse() {\n return false;\n}\n\nexport default stubFalse;\n", "import root from './_root.js';\nimport stubFalse from './stubFalse.js';\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Built-in value references. */\nvar Buffer = moduleExports ? root.Buffer : undefined;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;\n\n/**\n * Checks if `value` is a buffer.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.\n * @example\n *\n * _.isBuffer(new Buffer(2));\n * // => true\n *\n * _.isBuffer(new Uint8Array(2));\n * // => false\n */\nvar isBuffer = nativeIsBuffer || stubFalse;\n\nexport default isBuffer;\n", "import baseGetTag from './_baseGetTag.js';\nimport isLength from './isLength.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n errorTag = '[object Error]',\n funcTag = '[object Function]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n objectTag = '[object Object]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n weakMapTag = '[object WeakMap]';\n\nvar arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]',\n float32Tag = '[object Float32Array]',\n float64Tag = '[object Float64Array]',\n int8Tag = '[object Int8Array]',\n int16Tag = '[object Int16Array]',\n int32Tag = '[object Int32Array]',\n uint8Tag = '[object Uint8Array]',\n uint8ClampedTag = '[object Uint8ClampedArray]',\n uint16Tag = '[object Uint16Array]',\n uint32Tag = '[object Uint32Array]';\n\n/** Used to identify `toStringTag` values of typed arrays. */\nvar typedArrayTags = {};\ntypedArrayTags[float32Tag] = typedArrayTags[float64Tag] =\ntypedArrayTags[int8Tag] = typedArrayTags[int16Tag] =\ntypedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =\ntypedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =\ntypedArrayTags[uint32Tag] = true;\ntypedArrayTags[argsTag] = typedArrayTags[arrayTag] =\ntypedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =\ntypedArrayTags[dataViewTag] = typedArrayTags[dateTag] =\ntypedArrayTags[errorTag] = typedArrayTags[funcTag] =\ntypedArrayTags[mapTag] = typedArrayTags[numberTag] =\ntypedArrayTags[objectTag] = typedArrayTags[regexpTag] =\ntypedArrayTags[setTag] = typedArrayTags[stringTag] =\ntypedArrayTags[weakMapTag] = false;\n\n/**\n * The base implementation of `_.isTypedArray` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n */\nfunction baseIsTypedArray(value) {\n return isObjectLike(value) &&\n isLength(value.length) && !!typedArrayTags[baseGetTag(value)];\n}\n\nexport default baseIsTypedArray;\n", "/**\n * The base implementation of `_.unary` without support for storing metadata.\n *\n * @private\n * @param {Function} func The function to cap arguments for.\n * @returns {Function} Returns the new capped function.\n */\nfunction baseUnary(func) {\n return function(value) {\n return func(value);\n };\n}\n\nexport default baseUnary;\n", "import freeGlobal from './_freeGlobal.js';\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Detect free variable `process` from Node.js. */\nvar freeProcess = moduleExports && freeGlobal.process;\n\n/** Used to access faster Node.js helpers. */\nvar nodeUtil = (function() {\n try {\n // Use `util.types` for Node.js 10+.\n var types = freeModule && freeModule.require && freeModule.require('util').types;\n\n if (types) {\n return types;\n }\n\n // Legacy `process.binding('util')` for Node.js < 10.\n return freeProcess && freeProcess.binding && freeProcess.binding('util');\n } catch (e) {}\n}());\n\nexport default nodeUtil;\n", "import baseIsTypedArray from './_baseIsTypedArray.js';\nimport baseUnary from './_baseUnary.js';\nimport nodeUtil from './_nodeUtil.js';\n\n/* Node.js helper references. */\nvar nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;\n\n/**\n * Checks if `value` is classified as a typed array.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n * @example\n *\n * _.isTypedArray(new Uint8Array);\n * // => true\n *\n * _.isTypedArray([]);\n * // => false\n */\nvar isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;\n\nexport default isTypedArray;\n", "import baseTimes from './_baseTimes.js';\nimport isArguments from './isArguments.js';\nimport isArray from './isArray.js';\nimport isBuffer from './isBuffer.js';\nimport isIndex from './_isIndex.js';\nimport isTypedArray from './isTypedArray.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Creates an array of the enumerable property names of the array-like `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @param {boolean} inherited Specify returning inherited property names.\n * @returns {Array} Returns the array of property names.\n */\nfunction arrayLikeKeys(value, inherited) {\n var isArr = isArray(value),\n isArg = !isArr && isArguments(value),\n isBuff = !isArr && !isArg && isBuffer(value),\n isType = !isArr && !isArg && !isBuff && isTypedArray(value),\n skipIndexes = isArr || isArg || isBuff || isType,\n result = skipIndexes ? baseTimes(value.length, String) : [],\n length = result.length;\n\n for (var key in value) {\n if ((inherited || hasOwnProperty.call(value, key)) &&\n !(skipIndexes && (\n // Safari 9 has enumerable `arguments.length` in strict mode.\n key == 'length' ||\n // Node.js 0.10 has enumerable non-index properties on buffers.\n (isBuff && (key == 'offset' || key == 'parent')) ||\n // PhantomJS 2 has enumerable non-index properties on typed arrays.\n (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||\n // Skip index properties.\n isIndex(key, length)\n ))) {\n result.push(key);\n }\n }\n return result;\n}\n\nexport default arrayLikeKeys;\n", "/**\n * Creates a unary function that invokes `func` with its argument transformed.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {Function} transform The argument transform.\n * @returns {Function} Returns the new function.\n */\nfunction overArg(func, transform) {\n return function(arg) {\n return func(transform(arg));\n };\n}\n\nexport default overArg;\n", "import overArg from './_overArg.js';\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeKeys = overArg(Object.keys, Object);\n\nexport default nativeKeys;\n", "import isPrototype from './_isPrototype.js';\nimport nativeKeys from './_nativeKeys.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction baseKeys(object) {\n if (!isPrototype(object)) {\n return nativeKeys(object);\n }\n var result = [];\n for (var key in Object(object)) {\n if (hasOwnProperty.call(object, key) && key != 'constructor') {\n result.push(key);\n }\n }\n return result;\n}\n\nexport default baseKeys;\n", "import arrayLikeKeys from './_arrayLikeKeys.js';\nimport baseKeys from './_baseKeys.js';\nimport isArrayLike from './isArrayLike.js';\n\n/**\n * Creates an array of the own enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects. See the\n * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n * for more details.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keys(new Foo);\n * // => ['a', 'b'] (iteration order is not guaranteed)\n *\n * _.keys('hi');\n * // => ['0', '1']\n */\nfunction keys(object) {\n return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);\n}\n\nexport default keys;\n", "import getNative from './_getNative.js';\n\n/* Built-in method references that are verified to be native. */\nvar nativeCreate = getNative(Object, 'create');\n\nexport default nativeCreate;\n", "import nativeCreate from './_nativeCreate.js';\n\n/**\n * Removes all key-value entries from the hash.\n *\n * @private\n * @name clear\n * @memberOf Hash\n */\nfunction hashClear() {\n this.__data__ = nativeCreate ? nativeCreate(null) : {};\n this.size = 0;\n}\n\nexport default hashClear;\n", "/**\n * Removes `key` and its value from the hash.\n *\n * @private\n * @name delete\n * @memberOf Hash\n * @param {Object} hash The hash to modify.\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction hashDelete(key) {\n var result = this.has(key) && delete this.__data__[key];\n this.size -= result ? 1 : 0;\n return result;\n}\n\nexport default hashDelete;\n", "import nativeCreate from './_nativeCreate.js';\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Gets the hash value for `key`.\n *\n * @private\n * @name get\n * @memberOf Hash\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction hashGet(key) {\n var data = this.__data__;\n if (nativeCreate) {\n var result = data[key];\n return result === HASH_UNDEFINED ? undefined : result;\n }\n return hasOwnProperty.call(data, key) ? data[key] : undefined;\n}\n\nexport default hashGet;\n", "import nativeCreate from './_nativeCreate.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Checks if a hash value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Hash\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction hashHas(key) {\n var data = this.__data__;\n return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);\n}\n\nexport default hashHas;\n", "import nativeCreate from './_nativeCreate.js';\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/**\n * Sets the hash `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Hash\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the hash instance.\n */\nfunction hashSet(key, value) {\n var data = this.__data__;\n this.size += this.has(key) ? 0 : 1;\n data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;\n return this;\n}\n\nexport default hashSet;\n", "import hashClear from './_hashClear.js';\nimport hashDelete from './_hashDelete.js';\nimport hashGet from './_hashGet.js';\nimport hashHas from './_hashHas.js';\nimport hashSet from './_hashSet.js';\n\n/**\n * Creates a hash object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Hash(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `Hash`.\nHash.prototype.clear = hashClear;\nHash.prototype['delete'] = hashDelete;\nHash.prototype.get = hashGet;\nHash.prototype.has = hashHas;\nHash.prototype.set = hashSet;\n\nexport default Hash;\n", "/**\n * Removes all key-value entries from the list cache.\n *\n * @private\n * @name clear\n * @memberOf ListCache\n */\nfunction listCacheClear() {\n this.__data__ = [];\n this.size = 0;\n}\n\nexport default listCacheClear;\n", "import eq from './eq.js';\n\n/**\n * Gets the index at which the `key` is found in `array` of key-value pairs.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} key The key to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction assocIndexOf(array, key) {\n var length = array.length;\n while (length--) {\n if (eq(array[length][0], key)) {\n return length;\n }\n }\n return -1;\n}\n\nexport default assocIndexOf;\n", "import assocIndexOf from './_assocIndexOf.js';\n\n/** Used for built-in method references. */\nvar arrayProto = Array.prototype;\n\n/** Built-in value references. */\nvar splice = arrayProto.splice;\n\n/**\n * Removes `key` and its value from the list cache.\n *\n * @private\n * @name delete\n * @memberOf ListCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction listCacheDelete(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n return false;\n }\n var lastIndex = data.length - 1;\n if (index == lastIndex) {\n data.pop();\n } else {\n splice.call(data, index, 1);\n }\n --this.size;\n return true;\n}\n\nexport default listCacheDelete;\n", "import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Gets the list cache value for `key`.\n *\n * @private\n * @name get\n * @memberOf ListCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction listCacheGet(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n return index < 0 ? undefined : data[index][1];\n}\n\nexport default listCacheGet;\n", "import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Checks if a list cache value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf ListCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction listCacheHas(key) {\n return assocIndexOf(this.__data__, key) > -1;\n}\n\nexport default listCacheHas;\n", "import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Sets the list cache `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf ListCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the list cache instance.\n */\nfunction listCacheSet(key, value) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n ++this.size;\n data.push([key, value]);\n } else {\n data[index][1] = value;\n }\n return this;\n}\n\nexport default listCacheSet;\n", "import listCacheClear from './_listCacheClear.js';\nimport listCacheDelete from './_listCacheDelete.js';\nimport listCacheGet from './_listCacheGet.js';\nimport listCacheHas from './_listCacheHas.js';\nimport listCacheSet from './_listCacheSet.js';\n\n/**\n * Creates an list cache object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction ListCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `ListCache`.\nListCache.prototype.clear = listCacheClear;\nListCache.prototype['delete'] = listCacheDelete;\nListCache.prototype.get = listCacheGet;\nListCache.prototype.has = listCacheHas;\nListCache.prototype.set = listCacheSet;\n\nexport default ListCache;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar Map = getNative(root, 'Map');\n\nexport default Map;\n", "import Hash from './_Hash.js';\nimport ListCache from './_ListCache.js';\nimport Map from './_Map.js';\n\n/**\n * Removes all key-value entries from the map.\n *\n * @private\n * @name clear\n * @memberOf MapCache\n */\nfunction mapCacheClear() {\n this.size = 0;\n this.__data__ = {\n 'hash': new Hash,\n 'map': new (Map || ListCache),\n 'string': new Hash\n };\n}\n\nexport default mapCacheClear;\n", "/**\n * Checks if `value` is suitable for use as unique object key.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is suitable, else `false`.\n */\nfunction isKeyable(value) {\n var type = typeof value;\n return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')\n ? (value !== '__proto__')\n : (value === null);\n}\n\nexport default isKeyable;\n", "import isKeyable from './_isKeyable.js';\n\n/**\n * Gets the data for `map`.\n *\n * @private\n * @param {Object} map The map to query.\n * @param {string} key The reference key.\n * @returns {*} Returns the map data.\n */\nfunction getMapData(map, key) {\n var data = map.__data__;\n return isKeyable(key)\n ? data[typeof key == 'string' ? 'string' : 'hash']\n : data.map;\n}\n\nexport default getMapData;\n", "import getMapData from './_getMapData.js';\n\n/**\n * Removes `key` and its value from the map.\n *\n * @private\n * @name delete\n * @memberOf MapCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction mapCacheDelete(key) {\n var result = getMapData(this, key)['delete'](key);\n this.size -= result ? 1 : 0;\n return result;\n}\n\nexport default mapCacheDelete;\n", "import getMapData from './_getMapData.js';\n\n/**\n * Gets the map value for `key`.\n *\n * @private\n * @name get\n * @memberOf MapCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction mapCacheGet(key) {\n return getMapData(this, key).get(key);\n}\n\nexport default mapCacheGet;\n", "import getMapData from './_getMapData.js';\n\n/**\n * Checks if a map value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf MapCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction mapCacheHas(key) {\n return getMapData(this, key).has(key);\n}\n\nexport default mapCacheHas;\n", "import getMapData from './_getMapData.js';\n\n/**\n * Sets the map `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf MapCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the map cache instance.\n */\nfunction mapCacheSet(key, value) {\n var data = getMapData(this, key),\n size = data.size;\n\n data.set(key, value);\n this.size += data.size == size ? 0 : 1;\n return this;\n}\n\nexport default mapCacheSet;\n", "import mapCacheClear from './_mapCacheClear.js';\nimport mapCacheDelete from './_mapCacheDelete.js';\nimport mapCacheGet from './_mapCacheGet.js';\nimport mapCacheHas from './_mapCacheHas.js';\nimport mapCacheSet from './_mapCacheSet.js';\n\n/**\n * Creates a map cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction MapCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `MapCache`.\nMapCache.prototype.clear = mapCacheClear;\nMapCache.prototype['delete'] = mapCacheDelete;\nMapCache.prototype.get = mapCacheGet;\nMapCache.prototype.has = mapCacheHas;\nMapCache.prototype.set = mapCacheSet;\n\nexport default MapCache;\n", "/**\n * Appends the elements of `values` to `array`.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {Array} values The values to append.\n * @returns {Array} Returns `array`.\n */\nfunction arrayPush(array, values) {\n var index = -1,\n length = values.length,\n offset = array.length;\n\n while (++index < length) {\n array[offset + index] = values[index];\n }\n return array;\n}\n\nexport default arrayPush;\n", "import ListCache from './_ListCache.js';\n\n/**\n * Removes all key-value entries from the stack.\n *\n * @private\n * @name clear\n * @memberOf Stack\n */\nfunction stackClear() {\n this.__data__ = new ListCache;\n this.size = 0;\n}\n\nexport default stackClear;\n", "/**\n * Removes `key` and its value from the stack.\n *\n * @private\n * @name delete\n * @memberOf Stack\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction stackDelete(key) {\n var data = this.__data__,\n result = data['delete'](key);\n\n this.size = data.size;\n return result;\n}\n\nexport default stackDelete;\n", "/**\n * Gets the stack value for `key`.\n *\n * @private\n * @name get\n * @memberOf Stack\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction stackGet(key) {\n return this.__data__.get(key);\n}\n\nexport default stackGet;\n", "/**\n * Checks if a stack value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Stack\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction stackHas(key) {\n return this.__data__.has(key);\n}\n\nexport default stackHas;\n", "import ListCache from './_ListCache.js';\nimport Map from './_Map.js';\nimport MapCache from './_MapCache.js';\n\n/** Used as the size to enable large array optimizations. */\nvar LARGE_ARRAY_SIZE = 200;\n\n/**\n * Sets the stack `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Stack\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the stack cache instance.\n */\nfunction stackSet(key, value) {\n var data = this.__data__;\n if (data instanceof ListCache) {\n var pairs = data.__data__;\n if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {\n pairs.push([key, value]);\n this.size = ++data.size;\n return this;\n }\n data = this.__data__ = new MapCache(pairs);\n }\n data.set(key, value);\n this.size = data.size;\n return this;\n}\n\nexport default stackSet;\n", "import ListCache from './_ListCache.js';\nimport stackClear from './_stackClear.js';\nimport stackDelete from './_stackDelete.js';\nimport stackGet from './_stackGet.js';\nimport stackHas from './_stackHas.js';\nimport stackSet from './_stackSet.js';\n\n/**\n * Creates a stack cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Stack(entries) {\n var data = this.__data__ = new ListCache(entries);\n this.size = data.size;\n}\n\n// Add methods to `Stack`.\nStack.prototype.clear = stackClear;\nStack.prototype['delete'] = stackDelete;\nStack.prototype.get = stackGet;\nStack.prototype.has = stackHas;\nStack.prototype.set = stackSet;\n\nexport default Stack;\n", "/**\n * A specialized version of `_.filter` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {Array} Returns the new filtered array.\n */\nfunction arrayFilter(array, predicate) {\n var index = -1,\n length = array == null ? 0 : array.length,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (predicate(value, index, array)) {\n result[resIndex++] = value;\n }\n }\n return result;\n}\n\nexport default arrayFilter;\n", "/**\n * This method returns a new empty array.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {Array} Returns the new empty array.\n * @example\n *\n * var arrays = _.times(2, _.stubArray);\n *\n * console.log(arrays);\n * // => [[], []]\n *\n * console.log(arrays[0] === arrays[1]);\n * // => false\n */\nfunction stubArray() {\n return [];\n}\n\nexport default stubArray;\n", "import arrayFilter from './_arrayFilter.js';\nimport stubArray from './stubArray.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Built-in value references. */\nvar propertyIsEnumerable = objectProto.propertyIsEnumerable;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeGetSymbols = Object.getOwnPropertySymbols;\n\n/**\n * Creates an array of the own enumerable symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of symbols.\n */\nvar getSymbols = !nativeGetSymbols ? stubArray : function(object) {\n if (object == null) {\n return [];\n }\n object = Object(object);\n return arrayFilter(nativeGetSymbols(object), function(symbol) {\n return propertyIsEnumerable.call(object, symbol);\n });\n};\n\nexport default getSymbols;\n", "import arrayPush from './_arrayPush.js';\nimport isArray from './isArray.js';\n\n/**\n * The base implementation of `getAllKeys` and `getAllKeysIn` which uses\n * `keysFunc` and `symbolsFunc` to get the enumerable property names and\n * symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Function} keysFunc The function to get the keys of `object`.\n * @param {Function} symbolsFunc The function to get the symbols of `object`.\n * @returns {Array} Returns the array of property names and symbols.\n */\nfunction baseGetAllKeys(object, keysFunc, symbolsFunc) {\n var result = keysFunc(object);\n return isArray(object) ? result : arrayPush(result, symbolsFunc(object));\n}\n\nexport default baseGetAllKeys;\n", "import baseGetAllKeys from './_baseGetAllKeys.js';\nimport getSymbols from './_getSymbols.js';\nimport keys from './keys.js';\n\n/**\n * Creates an array of own enumerable property names and symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names and symbols.\n */\nfunction getAllKeys(object) {\n return baseGetAllKeys(object, keys, getSymbols);\n}\n\nexport default getAllKeys;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar DataView = getNative(root, 'DataView');\n\nexport default DataView;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar Promise = getNative(root, 'Promise');\n\nexport default Promise;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar Set = getNative(root, 'Set');\n\nexport default Set;\n", "import DataView from './_DataView.js';\nimport Map from './_Map.js';\nimport Promise from './_Promise.js';\nimport Set from './_Set.js';\nimport WeakMap from './_WeakMap.js';\nimport baseGetTag from './_baseGetTag.js';\nimport toSource from './_toSource.js';\n\n/** `Object#toString` result references. */\nvar mapTag = '[object Map]',\n objectTag = '[object Object]',\n promiseTag = '[object Promise]',\n setTag = '[object Set]',\n weakMapTag = '[object WeakMap]';\n\nvar dataViewTag = '[object DataView]';\n\n/** Used to detect maps, sets, and weakmaps. */\nvar dataViewCtorString = toSource(DataView),\n mapCtorString = toSource(Map),\n promiseCtorString = toSource(Promise),\n setCtorString = toSource(Set),\n weakMapCtorString = toSource(WeakMap);\n\n/**\n * Gets the `toStringTag` of `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nvar getTag = baseGetTag;\n\n// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.\nif ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||\n (Map && getTag(new Map) != mapTag) ||\n (Promise && getTag(Promise.resolve()) != promiseTag) ||\n (Set && getTag(new Set) != setTag) ||\n (WeakMap && getTag(new WeakMap) != weakMapTag)) {\n getTag = function(value) {\n var result = baseGetTag(value),\n Ctor = result == objectTag ? value.constructor : undefined,\n ctorString = Ctor ? toSource(Ctor) : '';\n\n if (ctorString) {\n switch (ctorString) {\n case dataViewCtorString: return dataViewTag;\n case mapCtorString: return mapTag;\n case promiseCtorString: return promiseTag;\n case setCtorString: return setTag;\n case weakMapCtorString: return weakMapTag;\n }\n }\n return result;\n };\n}\n\nexport default getTag;\n", "import root from './_root.js';\n\n/** Built-in value references. */\nvar Uint8Array = root.Uint8Array;\n\nexport default Uint8Array;\n", "/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/**\n * Adds `value` to the array cache.\n *\n * @private\n * @name add\n * @memberOf SetCache\n * @alias push\n * @param {*} value The value to cache.\n * @returns {Object} Returns the cache instance.\n */\nfunction setCacheAdd(value) {\n this.__data__.set(value, HASH_UNDEFINED);\n return this;\n}\n\nexport default setCacheAdd;\n", "/**\n * Checks if `value` is in the array cache.\n *\n * @private\n * @name has\n * @memberOf SetCache\n * @param {*} value The value to search for.\n * @returns {number} Returns `true` if `value` is found, else `false`.\n */\nfunction setCacheHas(value) {\n return this.__data__.has(value);\n}\n\nexport default setCacheHas;\n", "import MapCache from './_MapCache.js';\nimport setCacheAdd from './_setCacheAdd.js';\nimport setCacheHas from './_setCacheHas.js';\n\n/**\n *\n * Creates an array cache object to store unique values.\n *\n * @private\n * @constructor\n * @param {Array} [values] The values to cache.\n */\nfunction SetCache(values) {\n var index = -1,\n length = values == null ? 0 : values.length;\n\n this.__data__ = new MapCache;\n while (++index < length) {\n this.add(values[index]);\n }\n}\n\n// Add methods to `SetCache`.\nSetCache.prototype.add = SetCache.prototype.push = setCacheAdd;\nSetCache.prototype.has = setCacheHas;\n\nexport default SetCache;\n", "/**\n * A specialized version of `_.some` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if any element passes the predicate check,\n * else `false`.\n */\nfunction arraySome(array, predicate) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n while (++index < length) {\n if (predicate(array[index], index, array)) {\n return true;\n }\n }\n return false;\n}\n\nexport default arraySome;\n", "/**\n * Checks if a `cache` value for `key` exists.\n *\n * @private\n * @param {Object} cache The cache to query.\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction cacheHas(cache, key) {\n return cache.has(key);\n}\n\nexport default cacheHas;\n", "import SetCache from './_SetCache.js';\nimport arraySome from './_arraySome.js';\nimport cacheHas from './_cacheHas.js';\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1,\n COMPARE_UNORDERED_FLAG = 2;\n\n/**\n * A specialized version of `baseIsEqualDeep` for arrays with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Array} array The array to compare.\n * @param {Array} other The other array to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `array` and `other` objects.\n * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.\n */\nfunction equalArrays(array, other, bitmask, customizer, equalFunc, stack) {\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG,\n arrLength = array.length,\n othLength = other.length;\n\n if (arrLength != othLength && !(isPartial && othLength > arrLength)) {\n return false;\n }\n // Check that cyclic values are equal.\n var arrStacked = stack.get(array);\n var othStacked = stack.get(other);\n if (arrStacked && othStacked) {\n return arrStacked == other && othStacked == array;\n }\n var index = -1,\n result = true,\n seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;\n\n stack.set(array, other);\n stack.set(other, array);\n\n // Ignore non-index properties.\n while (++index < arrLength) {\n var arrValue = array[index],\n othValue = other[index];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, arrValue, index, other, array, stack)\n : customizer(arrValue, othValue, index, array, other, stack);\n }\n if (compared !== undefined) {\n if (compared) {\n continue;\n }\n result = false;\n break;\n }\n // Recursively compare arrays (susceptible to call stack limits).\n if (seen) {\n if (!arraySome(other, function(othValue, othIndex) {\n if (!cacheHas(seen, othIndex) &&\n (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {\n return seen.push(othIndex);\n }\n })) {\n result = false;\n break;\n }\n } else if (!(\n arrValue === othValue ||\n equalFunc(arrValue, othValue, bitmask, customizer, stack)\n )) {\n result = false;\n break;\n }\n }\n stack['delete'](array);\n stack['delete'](other);\n return result;\n}\n\nexport default equalArrays;\n", "/**\n * Converts `map` to its key-value pairs.\n *\n * @private\n * @param {Object} map The map to convert.\n * @returns {Array} Returns the key-value pairs.\n */\nfunction mapToArray(map) {\n var index = -1,\n result = Array(map.size);\n\n map.forEach(function(value, key) {\n result[++index] = [key, value];\n });\n return result;\n}\n\nexport default mapToArray;\n", "/**\n * Converts `set` to an array of its values.\n *\n * @private\n * @param {Object} set The set to convert.\n * @returns {Array} Returns the values.\n */\nfunction setToArray(set) {\n var index = -1,\n result = Array(set.size);\n\n set.forEach(function(value) {\n result[++index] = value;\n });\n return result;\n}\n\nexport default setToArray;\n", "import Symbol from './_Symbol.js';\nimport Uint8Array from './_Uint8Array.js';\nimport eq from './eq.js';\nimport equalArrays from './_equalArrays.js';\nimport mapToArray from './_mapToArray.js';\nimport setToArray from './_setToArray.js';\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1,\n COMPARE_UNORDERED_FLAG = 2;\n\n/** `Object#toString` result references. */\nvar boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n errorTag = '[object Error]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n symbolTag = '[object Symbol]';\n\nvar arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]';\n\n/** Used to convert symbols to primitives and strings. */\nvar symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;\n\n/**\n * A specialized version of `baseIsEqualDeep` for comparing objects of\n * the same `toStringTag`.\n *\n * **Note:** This function only supports comparing values with tags of\n * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {string} tag The `toStringTag` of the objects to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {\n switch (tag) {\n case dataViewTag:\n if ((object.byteLength != other.byteLength) ||\n (object.byteOffset != other.byteOffset)) {\n return false;\n }\n object = object.buffer;\n other = other.buffer;\n\n case arrayBufferTag:\n if ((object.byteLength != other.byteLength) ||\n !equalFunc(new Uint8Array(object), new Uint8Array(other))) {\n return false;\n }\n return true;\n\n case boolTag:\n case dateTag:\n case numberTag:\n // Coerce booleans to `1` or `0` and dates to milliseconds.\n // Invalid dates are coerced to `NaN`.\n return eq(+object, +other);\n\n case errorTag:\n return object.name == other.name && object.message == other.message;\n\n case regexpTag:\n case stringTag:\n // Coerce regexes to strings and treat strings, primitives and objects,\n // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring\n // for more details.\n return object == (other + '');\n\n case mapTag:\n var convert = mapToArray;\n\n case setTag:\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG;\n convert || (convert = setToArray);\n\n if (object.size != other.size && !isPartial) {\n return false;\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(object);\n if (stacked) {\n return stacked == other;\n }\n bitmask |= COMPARE_UNORDERED_FLAG;\n\n // Recursively compare objects (susceptible to call stack limits).\n stack.set(object, other);\n var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);\n stack['delete'](object);\n return result;\n\n case symbolTag:\n if (symbolValueOf) {\n return symbolValueOf.call(object) == symbolValueOf.call(other);\n }\n }\n return false;\n}\n\nexport default equalByTag;\n", "import getAllKeys from './_getAllKeys.js';\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1;\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * A specialized version of `baseIsEqualDeep` for objects with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction equalObjects(object, other, bitmask, customizer, equalFunc, stack) {\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG,\n objProps = getAllKeys(object),\n objLength = objProps.length,\n othProps = getAllKeys(other),\n othLength = othProps.length;\n\n if (objLength != othLength && !isPartial) {\n return false;\n }\n var index = objLength;\n while (index--) {\n var key = objProps[index];\n if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {\n return false;\n }\n }\n // Check that cyclic values are equal.\n var objStacked = stack.get(object);\n var othStacked = stack.get(other);\n if (objStacked && othStacked) {\n return objStacked == other && othStacked == object;\n }\n var result = true;\n stack.set(object, other);\n stack.set(other, object);\n\n var skipCtor = isPartial;\n while (++index < objLength) {\n key = objProps[index];\n var objValue = object[key],\n othValue = other[key];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, objValue, key, other, object, stack)\n : customizer(objValue, othValue, key, object, other, stack);\n }\n // Recursively compare objects (susceptible to call stack limits).\n if (!(compared === undefined\n ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))\n : compared\n )) {\n result = false;\n break;\n }\n skipCtor || (skipCtor = key == 'constructor');\n }\n if (result && !skipCtor) {\n var objCtor = object.constructor,\n othCtor = other.constructor;\n\n // Non `Object` object instances with different constructors are not equal.\n if (objCtor != othCtor &&\n ('constructor' in object && 'constructor' in other) &&\n !(typeof objCtor == 'function' && objCtor instanceof objCtor &&\n typeof othCtor == 'function' && othCtor instanceof othCtor)) {\n result = false;\n }\n }\n stack['delete'](object);\n stack['delete'](other);\n return result;\n}\n\nexport default equalObjects;\n", "import Stack from './_Stack.js';\nimport equalArrays from './_equalArrays.js';\nimport equalByTag from './_equalByTag.js';\nimport equalObjects from './_equalObjects.js';\nimport getTag from './_getTag.js';\nimport isArray from './isArray.js';\nimport isBuffer from './isBuffer.js';\nimport isTypedArray from './isTypedArray.js';\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1;\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n objectTag = '[object Object]';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * A specialized version of `baseIsEqual` for arrays and objects which performs\n * deep comparisons and tracks traversed objects enabling objects with circular\n * references to be compared.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} [stack] Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {\n var objIsArr = isArray(object),\n othIsArr = isArray(other),\n objTag = objIsArr ? arrayTag : getTag(object),\n othTag = othIsArr ? arrayTag : getTag(other);\n\n objTag = objTag == argsTag ? objectTag : objTag;\n othTag = othTag == argsTag ? objectTag : othTag;\n\n var objIsObj = objTag == objectTag,\n othIsObj = othTag == objectTag,\n isSameTag = objTag == othTag;\n\n if (isSameTag && isBuffer(object)) {\n if (!isBuffer(other)) {\n return false;\n }\n objIsArr = true;\n objIsObj = false;\n }\n if (isSameTag && !objIsObj) {\n stack || (stack = new Stack);\n return (objIsArr || isTypedArray(object))\n ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)\n : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);\n }\n if (!(bitmask & COMPARE_PARTIAL_FLAG)) {\n var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),\n othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');\n\n if (objIsWrapped || othIsWrapped) {\n var objUnwrapped = objIsWrapped ? object.value() : object,\n othUnwrapped = othIsWrapped ? other.value() : other;\n\n stack || (stack = new Stack);\n return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);\n }\n }\n if (!isSameTag) {\n return false;\n }\n stack || (stack = new Stack);\n return equalObjects(object, other, bitmask, customizer, equalFunc, stack);\n}\n\nexport default baseIsEqualDeep;\n", "import baseIsEqualDeep from './_baseIsEqualDeep.js';\nimport isObjectLike from './isObjectLike.js';\n\n/**\n * The base implementation of `_.isEqual` which supports partial comparisons\n * and tracks traversed objects.\n *\n * @private\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @param {boolean} bitmask The bitmask flags.\n * 1 - Unordered comparison\n * 2 - Partial comparison\n * @param {Function} [customizer] The function to customize comparisons.\n * @param {Object} [stack] Tracks traversed `value` and `other` objects.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n */\nfunction baseIsEqual(value, other, bitmask, customizer, stack) {\n if (value === other) {\n return true;\n }\n if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {\n return value !== value && other !== other;\n }\n return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);\n}\n\nexport default baseIsEqual;\n", "import baseIsEqual from './_baseIsEqual.js';\n\n/**\n * Performs a deep comparison between two values to determine if they are\n * equivalent.\n *\n * **Note:** This method supports comparing arrays, array buffers, booleans,\n * date objects, error objects, maps, numbers, `Object` objects, regexes,\n * sets, strings, symbols, and typed arrays. `Object` objects are compared\n * by their own, not inherited, enumerable properties. Functions and DOM\n * nodes are compared by strict equality, i.e. `===`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.isEqual(object, other);\n * // => true\n *\n * object === other;\n * // => false\n */\nfunction isEqual(value, other) {\n return baseIsEqual(value, other);\n}\n\nexport default isEqual;\n", "import { isEqual } from 'lodash-es';\n\nimport Metadata from './Metadata';\nimport {\n PluginStatusError,\n PluginStatusMetadata,\n PluginStatusProcessed,\n PluginStatusProcessing\n} from './types';\n\nclass ImageProcessingMetadata extends Metadata<PluginStatusMetadata> {\n get(blockId: number): PluginStatusMetadata {\n return super.get(blockId) ?? { status: 'IDLE' };\n }\n\n /**\n * Detect if the block has been duplicated with processed or processing\n * fill processing. In that case the processing state is still\n * valid, but blockId and fillId have changed.\n */\n isDuplicate(blockId: number): boolean {\n if (!this.engine.block.isValid(blockId)) return false;\n\n const metadata = this.get(blockId);\n\n if (\n metadata.status === 'IDLE' ||\n metadata.status === 'PENDING' ||\n metadata.status === 'ERROR'\n )\n return false;\n\n if (!this.engine.block.hasFill(blockId)) return false;\n const fillId = this.engine.block.getFill(blockId);\n\n // It cannot be a duplicate if the blockId or fillId are the same\n if (metadata.blockId === blockId || metadata.fillId === fillId)\n return false;\n\n return true;\n }\n\n /**\n * Fixes the metadata if the block has been duplicated, i.e. the blockId and\n * fillId will be updated to the current block/fill.\n *\n * Please note: Call this method only on duplicates (see isDuplicate).\n */\n fixDuplicate(blockId: number) {\n const fillId = this.engine.block.getFill(blockId);\n const metadata = this.get(blockId);\n if (\n metadata.status === 'IDLE' ||\n metadata.status === 'PENDING' ||\n metadata.status === 'ERROR'\n )\n return;\n this.set(blockId, {\n ...metadata,\n blockId,\n fillId\n });\n\n // If it is currently processing the best we can do is to just recover\n // the initial image data, since no processing will update this block and\n // it will be stuck in the processing state.\n if (metadata.status === 'PROCESSING') {\n this.recoverInitialImageData(blockId);\n this.clear(blockId);\n }\n }\n\n /**\n * Check if the image has a consisten metadata state. A inconsistent state is\n * caused by outside changes of the fill data.\n *\n * @returns true if the metadata is consistent, false otherwise\n */\n isConsistent(blockId: number): boolean {\n // In case the block was removed, we just abort and mark it\n // as reset by returning true\n if (!this.engine.block.isValid(blockId)) return false;\n const metadata = this.get(blockId);\n if (metadata.status === 'IDLE' || metadata.status === 'PENDING')\n return true;\n\n if (!this.engine.block.hasFill(blockId)) return false;\n const fillId = this.engine.block.getFill(blockId);\n if (fillId == null) return false;\n\n if (blockId !== metadata.blockId || fillId !== metadata.fillId)\n return false;\n\n const sourceSet = this.engine.block.getSourceSet(\n fillId,\n 'fill/image/sourceSet'\n );\n const imageFileURI = this.engine.block.getString(\n fillId,\n 'fill/image/imageFileURI'\n );\n\n if (\n sourceSet.length === 0 &&\n !imageFileURI &&\n metadata.status === 'PROCESSING'\n ) {\n // While we process it is OK to have no image file URI and no source set\n // (which we cleared to show the spinning loader)\n return true;\n }\n\n // Source sets have precedence over imageFileURI so if we have a source set,\n // we only need to check if it has changed to something else.\n if (sourceSet?.length > 0) {\n const initialSourceSet = metadata.initialSourceSet;\n // If we have already processed the image, we need to check if the source set\n // we need to check against both source sets, the removed and the initial\n if (metadata.status !== 'PROCESSED') {\n if (!isEqual(sourceSet, initialSourceSet)) {\n return false;\n }\n }\n } else {\n if (metadata.status !== 'PROCESSED') {\n if (imageFileURI !== metadata.initialImageFileURI) {\n return false;\n }\n }\n }\n return true;\n }\n\n /**\n * Recover the initial values to avoid the loading spinner and have the same\n * state as before the fill processing was started.\n */\n recoverInitialImageData(blockId: number) {\n const blockApi = this.engine.block;\n if (!blockApi.hasFill(blockId)) return; // Nothing to recover (no fill anymore)\n\n const metadata = this.get(blockId);\n\n if (metadata.status === 'PENDING' || metadata.status === 'IDLE') {\n return;\n }\n\n const initialSourceSet = metadata.initialSourceSet;\n const initialImageFileURI = metadata.initialImageFileURI;\n const initialPreviewFileURI = metadata.initialPreviewFileURI;\n\n const fillId = this.getValidFill(blockId, metadata);\n if (fillId == null) return;\n\n if (initialImageFileURI) {\n this.engine.block.setString(\n fillId,\n 'fill/image/imageFileURI',\n initialImageFileURI\n );\n }\n if (initialPreviewFileURI) {\n this.engine.block.setString(\n fillId,\n 'fill/image/previewFileURI',\n initialPreviewFileURI\n );\n }\n if (initialSourceSet.length > 0) {\n this.engine.block.setSourceSet(\n fillId,\n 'fill/image/sourceSet',\n initialSourceSet\n );\n }\n }\n\n /**\n * Returns the fill id of the block if it has a valid fill that was used for\n * fill processing. Returns undefined otherwise.\n */\n private getValidFill(\n blockId: number,\n metadata: PluginStatusProcessing | PluginStatusError | PluginStatusProcessed\n ): number | undefined {\n if (\n !this.engine.block.isValid(blockId) ||\n !this.engine.block.hasFill(blockId) ||\n blockId !== metadata.blockId\n ) {\n return undefined;\n }\n const fillId = this.engine.block.getFill(blockId);\n if (fillId !== metadata.fillId) {\n return undefined;\n }\n\n return fillId;\n }\n}\n\nexport default ImageProcessingMetadata;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { FillProcessingMetadata } from '..';\nimport {\n PluginStatusProcessed,\n PluginStatusProcessing\n} from '../metadata/types';\n\ninterface FillProcessor<T> {\n processFill(metadataState: PluginStatusProcessing): Promise<T>;\n\n commitProcessing(\n data: T,\n metadataState: PluginStatusProcessed\n ): number | void;\n}\n\nasync function fillProcessing<T>(\n blockId: number,\n cesdk: CreativeEditorSDK,\n metadata: FillProcessingMetadata,\n processor: FillProcessor<T>\n) {\n const blockApi = cesdk.engine.block;\n if (!blockApi.hasFill(blockId))\n throw new Error('Block does not support fill');\n\n const fillId = blockApi.getFill(blockId);\n\n // Get the current image URI and source set as initial values.\n const initialSourceSet = blockApi.getSourceSet(\n fillId,\n 'fill/image/sourceSet'\n );\n const initialImageFileURI = blockApi.getString(\n fillId,\n 'fill/image/imageFileURI'\n );\n const initialPreviewFileURI = blockApi.getString(\n fillId,\n 'fill/image/previewFileURI'\n );\n try {\n cesdk.engine.block.setState(fillId, {\n type: 'Pending',\n progress: 0\n });\n\n const status: PluginStatusProcessing = {\n ...metadata.get(blockId),\n version: PLUGIN_VERSION,\n initialSourceSet,\n initialImageFileURI,\n initialPreviewFileURI,\n blockId,\n fillId,\n status: 'PROCESSING'\n };\n\n metadata.set(blockId, status);\n\n const processedData = await processor.processFill(status);\n // Check for externally changed state while we were applying the mask and\n // do not proceed if the state was reset.\n if (\n metadata.get(blockId).status !== 'PROCESSING' ||\n !metadata.isConsistent(blockId)\n )\n return;\n\n // Check for externally changed state while we were uploading and\n // do not proceed if the state was reset.\n if (\n metadata.get(blockId).status !== 'PROCESSING' ||\n !metadata.isConsistent(blockId)\n )\n return;\n\n if (processedData == null) return;\n\n const metadataStateProcessed: PluginStatusProcessed = {\n version: PLUGIN_VERSION,\n initialSourceSet,\n initialImageFileURI,\n initialPreviewFileURI,\n blockId,\n fillId,\n status: 'PROCESSED'\n };\n\n const blockIdOrVoid = processor.commitProcessing(\n processedData,\n metadataStateProcessed\n );\n\n // If a new block was created, we do not update the metadata.\n if (blockIdOrVoid == null || blockIdOrVoid === blockId) {\n metadata.set(blockId, metadataStateProcessed);\n }\n\n // Finally, create an undo step\n cesdk.engine.editor.addUndoStep();\n } catch (error) {\n if (cesdk.engine.block.isValid(blockId)) {\n metadata.set(blockId, {\n version: PLUGIN_VERSION,\n initialSourceSet,\n initialImageFileURI,\n initialPreviewFileURI,\n blockId,\n fillId,\n status: 'ERROR'\n });\n\n metadata.recoverInitialImageData(blockId);\n }\n\n if (\n error != null &&\n typeof error === 'object' &&\n 'message' in error &&\n typeof error.message === 'string'\n ) {\n const message =\n error.message === 'signal timed out'\n ? 'Processing canceled due to timeout'\n : error.message;\n cesdk.ui.showNotification({\n type: 'error',\n message\n });\n }\n\n // eslint-disable-next-line no-console\n console.log(error);\n } finally {\n if (cesdk.engine.block.isValid(fillId)) {\n cesdk.engine.block.setState(fillId, { type: 'Ready' });\n }\n }\n}\n\nexport default fillProcessing;\n", "export function getFeatureId(pluginId: string): string {\n return `${pluginId}.fillProcessing.feature`;\n}\n\nexport function getCanvasMenuComponentIds(pluginId: string): string[] {\n return [`${pluginId}.canvasMenu`, `${pluginId}.fillProcessing.canvasMenu`];\n}\n\nexport function getDockComponentIds(pluginId: string): string[] {\n return [`${pluginId}.dock`, `${pluginId}.fillProcessing.dock`];\n}\n\nexport function getInspectorBarComponentIds(pluginId: string): string[] {\n return [\n `${pluginId}.inspectorBar`,\n `${pluginId}.fillProcessing.inspectorBar`\n ];\n}\n\nexport function getNavigationBarComponentIds(pluginId: string): string[] {\n return [\n `${pluginId}.navigationBar`,\n `${pluginId}.fillProcessing.navigationBar`\n ];\n}\n\nexport function getCanvasBarComponentIds(pluginId: string): string[] {\n return [`${pluginId}.canvasBar`, `${pluginId}.fillProcessing.canvasBar`];\n}\n\nexport function getI18nCanvasMenuLabel(pluginId: string): string {\n return `plugin.${pluginId}.fillProcessing.canvasMenu.button.label`;\n}\n\nexport function getI18nDockLabel(pluginId: string): string {\n return `plugin.${pluginId}.fillProcessing.dock.button.label`;\n}\n\nexport function getI18nInspectorBarLabel(pluginId: string): string {\n return `plugin.${pluginId}.fillProcessing.inspectorBar.button.label`;\n}\n\nexport function getI18nNavigationBarLabel(pluginId: string): string {\n return `plugin.${pluginId}.fillProcessing.navigationBar.button.label`;\n}\n\nexport function getI18nCanvasBarLabel(pluginId: string): string {\n return `plugin.${pluginId}.fillProcessing.canvasBar.button.label`;\n}\n", "import type CreativeEditorSDK from '@cesdk/cesdk-js';\n\nimport { FillProcessingMetadata } from '..';\nimport { getFeatureId } from './constants';\n\nexport default function handleFillProcessing(\n cesdk: CreativeEditorSDK,\n {\n pluginId,\n process\n }: {\n pluginId: string;\n icon?: string;\n process: (blockId: number, metadata: FillProcessingMetadata) => void;\n }\n): {\n featureId: string;\n} {\n const featureId = getFeatureId(pluginId);\n\n const metadata = new FillProcessingMetadata(cesdk.engine, pluginId);\n\n enableFeatures(cesdk, metadata, featureId);\n\n cesdk.engine.event.subscribe([], async (events) => {\n events.forEach((e) => {\n const id = e.block;\n if (!cesdk.engine.block.isValid(id) || !metadata.hasData(id)) {\n return;\n }\n\n if (e.type === 'Created') {\n if (metadata.isDuplicate(id)) {\n metadata.fixDuplicate(id);\n }\n } else if (e.type === 'Updated') {\n switch (metadata.get(id).status) {\n case 'PENDING': {\n if (\n cesdk.feature.isEnabled(featureId, {\n engine: cesdk.engine\n }) &&\n cesdk.engine.block.isAllowedByScope(id, 'fill/change') &&\n cesdk.engine.block.getState(id).type !== 'Pending'\n ) {\n process(id, metadata);\n }\n break;\n }\n\n case 'PROCESSING':\n case 'PROCESSED': {\n if (!metadata.isConsistent(id)) {\n metadata.clear(id);\n }\n break;\n }\n\n default: {\n // We do not care about other states\n }\n }\n }\n });\n });\n\n return { featureId };\n}\n\n/**\n * Defines the feature that determines in which context (on which block)\n * fill processing is allowed/enabled.\n */\nfunction enableFeatures(\n cesdk: CreativeEditorSDK,\n metadata: FillProcessingMetadata,\n featureId: string\n) {\n cesdk.feature.enable(featureId, ({ engine }) => {\n const selectedIds = engine.block.findAllSelected();\n if (selectedIds.length !== 1) {\n return false;\n }\n const [selectedId] = selectedIds;\n\n if (!cesdk.engine.block.isVisible(selectedId)) return false;\n\n if (cesdk.engine.block.hasFill(selectedId)) {\n const kind = cesdk.engine.block.getKind(selectedId);\n if (kind === 'sticker') return false;\n\n const fillId = cesdk.engine.block.getFill(selectedId);\n const fillType = cesdk.engine.block.getType(fillId);\n\n if (fillType !== '//ly.img.ubq/fill/image') {\n return false;\n }\n\n const fileUri = engine.block.getString(fillId, 'fill/image/imageFileURI');\n const sourceSet = engine.block.getSourceSet(\n fillId,\n 'fill/image/sourceSet'\n );\n\n if (sourceSet.length > 0 || fileUri !== '') return true;\n\n // If we are in a processing state we do not have a imageFileURI or\n // source set set (to show the loading spinner), but the feature is still\n // enabled.\n return metadata.get(selectedId).status === 'PROCESSING';\n }\n\n return false;\n });\n}\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { FillProcessingMetadata } from '..';\nimport {\n getCanvasBarComponentIds,\n getCanvasMenuComponentIds,\n getDockComponentIds,\n getFeatureId,\n getI18nCanvasBarLabel,\n getI18nCanvasMenuLabel,\n getI18nDockLabel,\n getI18nInspectorBarLabel,\n getI18nNavigationBarLabel,\n getInspectorBarComponentIds,\n getNavigationBarComponentIds\n} from './constants';\n\nexport type Location =\n | 'inspectorBar'\n | 'navigationBar'\n | 'canvasBarTop'\n | 'canvasBarBottom'\n | 'canvasMenu'\n | 'dock';\n\n/**\n * Registers the components that can be used to process the fill of\n * a block.\n */\nexport default function registerFillProcessingComponents(\n cesdk: CreativeEditorSDK,\n options: {\n pluginId: string;\n icon?: string;\n locations?: Location | Location[];\n }\n): {\n canvasMenuComponentId: string;\n dockComponentId: string;\n\n translationsKeys: {\n inspectorBarLabel: string;\n navigationBarLabel: string;\n canvasBarLabel: string;\n canvasMenuLabel: string;\n dockLabel: string;\n };\n} {\n const { pluginId, locations } = options;\n const metadata = new FillProcessingMetadata(cesdk.engine, pluginId);\n\n const canvasMenuLabel = getI18nCanvasMenuLabel(pluginId);\n const canvasMenuComponentIds = getCanvasMenuComponentIds(pluginId);\n const canvasMenuComponentId = canvasMenuComponentIds[0];\n\n const dockLabel = getI18nDockLabel(pluginId);\n const dockComponentIds = getDockComponentIds(pluginId);\n const dockComponentId = dockComponentIds[0];\n\n const inspectorBarLabel = getI18nInspectorBarLabel(pluginId);\n const inspectorBarComponentIds = getInspectorBarComponentIds(pluginId);\n const inspectorBarComponentId = inspectorBarComponentIds[0];\n\n const navigationBarLabel = getI18nNavigationBarLabel(pluginId);\n const navigationBarComponentIds = getNavigationBarComponentIds(pluginId);\n const navigationBarComponentId = navigationBarComponentIds[0];\n\n const canvasBarLabel = getI18nCanvasBarLabel(pluginId);\n const canvasBarComponentIds = getCanvasBarComponentIds(pluginId);\n const canvasBarComponentId = canvasBarComponentIds[0];\n\n const featureId = getFeatureId(pluginId);\n\n if (locations?.includes('inspectorBar')) {\n cesdk.ui.setInspectorBarOrder([\n inspectorBarComponentId,\n ...cesdk.ui.getInspectorBarOrder()\n ]);\n }\n\n if (locations?.includes('navigationBar')) {\n cesdk.ui.setNavigationBarOrder([\n navigationBarComponentId,\n ...cesdk.ui.getNavigationBarOrder()\n ]);\n }\n\n if (locations?.includes('canvasBarTop')) {\n cesdk.ui.setCanvasBarOrder(\n [canvasBarComponentId, ...cesdk.ui.getCanvasBarOrder('top')],\n 'top'\n );\n }\n\n if (locations?.includes('canvasBarBottom')) {\n cesdk.ui.setCanvasBarOrder(\n [canvasBarComponentId, ...cesdk.ui.getCanvasBarOrder('bottom')],\n 'bottom'\n );\n }\n\n if (locations?.includes('canvasMenu')) {\n cesdk.ui.setCanvasMenuOrder([\n canvasMenuComponentId,\n ...cesdk.ui.getCanvasMenuOrder()\n ]);\n }\n\n if (locations?.includes('dock')) {\n cesdk.ui.setDockOrder([...cesdk.ui.getDockOrder(), dockComponentId]);\n }\n\n cesdk.ui.registerComponent(\n dockComponentIds,\n ({ builder: { Button }, engine }) => {\n const [id] = engine.block.findAllSelected();\n\n let isDisabled = false;\n let isLoading = false;\n let loadingProgress: number | undefined;\n\n if (id == null) {\n isDisabled = true;\n }\n\n if (\n !isDisabled &&\n !cesdk.feature.isEnabled(featureId, {\n engine\n })\n ) {\n isDisabled = true;\n }\n\n if (\n !isDisabled &&\n !cesdk.engine.block.isAllowedByScope(id, 'fill/change')\n ) {\n isDisabled = true;\n }\n\n if (!isDisabled && engine.block.getState(id)?.type === 'Pending') {\n isDisabled = true;\n }\n\n if (!isDisabled) {\n const currentMetadata = metadata.get(id);\n\n isLoading = currentMetadata.status === 'PROCESSING';\n isDisabled =\n currentMetadata.status === 'PENDING' ||\n currentMetadata.status === 'PROCESSING';\n\n if (\n currentMetadata.status === 'PROCESSING' &&\n currentMetadata.progress\n ) {\n const { current, total } = currentMetadata.progress;\n loadingProgress = (current / total) * 100;\n }\n }\n\n const buttonId = `${dockComponentId}.button`;\n Button(buttonId, {\n label: dockLabel,\n icon: options.icon,\n isLoading,\n isDisabled,\n loadingProgress,\n onClick: () => {\n const currentMetadata = metadata.get(id);\n\n if (\n currentMetadata.status === 'IDLE' ||\n currentMetadata.status === 'ERROR' ||\n currentMetadata.status === 'PROCESSED'\n ) {\n metadata.set(id, {\n status: 'PENDING'\n });\n }\n }\n });\n }\n );\n\n const buttonComponents: {\n componentIds: string[];\n label: string;\n variant: 'plain' | 'regular';\n }[] = [\n {\n componentIds: inspectorBarComponentIds,\n variant: 'plain',\n label: inspectorBarLabel\n },\n {\n componentIds: navigationBarComponentIds,\n variant: 'regular',\n label: navigationBarLabel\n },\n {\n componentIds: canvasBarComponentIds,\n variant: 'regular',\n label: canvasBarLabel\n },\n {\n componentIds: canvasMenuComponentIds,\n variant: 'plain',\n label: canvasMenuLabel\n }\n ];\n\n buttonComponents.forEach(({ componentIds, label, variant }) => {\n const componentId = componentIds[0];\n cesdk.ui.registerComponent(\n componentIds,\n ({ builder: { Button }, engine }) => {\n if (\n !cesdk.feature.isEnabled(featureId, {\n engine\n })\n ) {\n return;\n }\n\n const [id] = engine.block.findAllSelected();\n\n if (!cesdk.engine.block.isAllowedByScope(id, 'fill/change')) return;\n\n const currentMetadata = metadata.get(id);\n\n const isLoading = currentMetadata.status === 'PROCESSING';\n const isDisabled =\n currentMetadata.status === 'PENDING' ||\n currentMetadata.status === 'PROCESSING' ||\n engine.block.getState(id)?.type === 'Pending';\n\n let loadingProgress: number | undefined;\n if (isLoading && currentMetadata.progress) {\n const { current, total } = currentMetadata.progress;\n loadingProgress = (current / total) * 100;\n }\n\n const buttonId = `${componentId}.button`;\n Button(buttonId, {\n icon: options.icon,\n label,\n variant,\n isLoading,\n isDisabled,\n loadingProgress,\n onClick: () => {\n if (\n currentMetadata.status === 'IDLE' ||\n currentMetadata.status === 'ERROR' ||\n currentMetadata.status === 'PROCESSED'\n ) {\n metadata.set(id, {\n status: 'PENDING'\n });\n }\n }\n });\n }\n );\n });\n\n return {\n canvasMenuComponentId,\n dockComponentId,\n translationsKeys: {\n inspectorBarLabel,\n navigationBarLabel,\n canvasBarLabel,\n canvasMenuLabel,\n dockLabel\n }\n };\n}\n", "import { type RGBAColor } from '@cesdk/cesdk-js';\n\nconst HEX_COLOR_PATTERN = new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/, 'i');\nconst HEX_SINGLE_CHAR_COMPONENTS_PATTERN = new RegExp(/[A-Fa-f0-9]{1}/, 'g');\nconst HEX_DOUBLE_CHAR_COMPONENTS_PATTERN = new RegExp(/[A-Fa-f0-9]{2}/, 'g');\n\n/** @public */\nexport const rgbaToHex = (rgba: RGBAColor, includeAlpha = false): string => {\n const { r, g, b, a } = rgba;\n const rByte = Math.round(255 * r);\n const gByte = Math.round(255 * g);\n const bByte = Math.round(255 * b);\n const aByte = Math.round(255 * a);\n const byteToHex = (byte: number) => {\n return byte.toString(16).padStart(2, '0');\n };\n return `#${byteToHex(rByte)}${byteToHex(gByte)}${byteToHex(bByte)}${\n includeAlpha ? byteToHex(aByte) : ''\n }`;\n};\n\n/** @public */\nexport const hexToRgba = (hexString: string): RGBAColor => {\n const rgbaHexToColor = (\n r: string,\n g: string,\n b: string,\n a: string | undefined,\n max: number\n ) => {\n return {\n r: parseInt(r, 16) / max,\n g: parseInt(g, 16) / max,\n b: parseInt(b, 16) / max,\n a: a === undefined ? 1 : parseInt(a, 16) / max\n };\n };\n\n if (hexString.startsWith('#')) {\n if (hexString.length === 4 || hexString.length === 5) {\n const hexMatch = hexString.match(HEX_SINGLE_CHAR_COMPONENTS_PATTERN);\n if (hexMatch) {\n const [r, g, b, a] = hexMatch;\n return rgbaHexToColor(r, g, b, a, 15);\n }\n }\n if (hexString.length === 7 || hexString.length === 8) {\n const hexMatch = hexString.match(HEX_DOUBLE_CHAR_COMPONENTS_PATTERN);\n if (hexMatch) {\n const [r, g, b, a] = hexMatch;\n return rgbaHexToColor(r, g, b, a, 255);\n }\n }\n }\n\n throw new Error(\n 'Invalid hex string! Allowed RGB formats are \"#FFF\" and \"#FFFFFF\". Allowed RGBA formats are \"#FFFF\" and \"#FFFFFFFF'\n );\n};\n\n/** @public */\nexport const isValidHexColor = (hexString: string): boolean => {\n return HEX_COLOR_PATTERN.test(hexString);\n};\n", "import type CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { CreativeEngine } from '@cesdk/cesdk-js';\n\n/**\n * Uploads a blob with the help of CE.SDK\n */\nexport async function uploadBlob(\n blob: Blob,\n initialUri: string,\n cesdk: CreativeEditorSDK\n) {\n const pathname = new URL(initialUri).pathname;\n const parts = pathname.split('/');\n const extension = mimeTypeToExtension(blob.type);\n const filename = parts[parts.length - 1]?.split('.')?.[0] ?? 'asset';\n const filenameWithExtension = `${filename}.${extension}`;\n\n const uploadedAssets = await cesdk.unstable_upload(\n new File([blob], filenameWithExtension, { type: blob.type }),\n () => {\n // TODO Delegate process to UI component\n }\n );\n\n const url = uploadedAssets.meta?.uri;\n if (url == null) {\n throw new Error('Could not upload processed fill');\n }\n return url;\n}\n\n/**\n * Returns the file extension for a given mime type.\n */\nexport function mimeTypeToExtension(mimeType: string): string {\n const extensions: Record<string, string> = {\n 'image/png': 'png',\n 'image/jpeg': 'jpg',\n 'image/webp': 'webp',\n 'image/gif': 'gif',\n 'image/svg+xml': 'svg'\n };\n return extensions[mimeType] ?? 'png';\n}\n\nexport async function fetchImageBlob(uri: string): Promise<Blob> {\n return fetch(uri).then((response) => response.blob());\n}\n\n/**\n * Converts a buffer URI to a object url.\n */\nexport async function bufferURIToObjectURL(\n uri: string,\n engine: CreativeEngine\n): Promise<string> {\n if (uri.startsWith('buffer:')) {\n const mimeType = await engine.editor.getMimeType(uri);\n const length = engine.editor.getBufferLength(uri);\n const data = engine.editor.getBufferData(uri, 0, length);\n const blob = new Blob([data], { type: mimeType });\n return URL.createObjectURL(blob);\n } else {\n return uri;\n }\n}\n", "function uuid4() {\n /* eslint-disable no-bitwise */\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n /* eslint-enable no-bitwise */\n });\n}\n\nexport default uuid4;\n", "import { bufferURIToObjectURL } from './upload';\nimport { type CreativeEngine } from '@cesdk/cesdk-js';\n\n/**\n * Get the dimensions of an image from its URL\n *\n * @param url - The URL of the image\n * @returns A promise that resolves to an object containing the width and height of the image\n */\nexport async function getImageDimensionsFromURL(\n url: string,\n engine: CreativeEngine\n): Promise<{ width: number; height: number }> {\n const resolvedUrl = await bufferURIToObjectURL(url, engine);\n return new Promise((resolve, reject) => {\n const img = new Image();\n img.onload = () => {\n resolve({ width: img.width, height: img.height });\n };\n img.onerror = reject;\n img.src = resolvedUrl;\n });\n}\n\n/**\n * Get the URI of an image from a block ID, either the first source of a source set or\n * the image file URI. Will handle buffer URIs and convert them to object URLs.\n */\nexport async function getImageUri(\n blockId: number,\n engine: CreativeEngine,\n options?: { throwErrorIfSvg?: boolean }\n): Promise<string> {\n let uri;\n const fillBlock = engine.block.getFill(blockId);\n const sourceSet = engine.block.getSourceSet(\n fillBlock,\n 'fill/image/sourceSet'\n );\n const [source] = sourceSet;\n if (source == null) {\n uri = engine.block.getString(fillBlock, 'fill/image/imageFileURI');\n if (uri == null) throw new Error('No image source/uri found');\n } else {\n uri = source.uri;\n }\n\n // Check if the image is SVG (not supported)\n if (options?.throwErrorIfSvg) {\n const mimeType = await engine.editor.getMimeType(uri);\n if (mimeType === 'image/svg+xml') {\n throw new Error('SVG images are not supported');\n }\n }\n\n return bufferURIToObjectURL(uri, engine);\n}\n", "/**\n * Checks if a value is defined (not undefined).\n *\n * Helpful to filter out undefined values from an array or collection\n * while keeping the type information intact.\n *\n * ```\n * array.filter(isDefined)\n * ```\n */\nfunction isDefined<T>(value: T | undefined): value is T {\n return value !== undefined;\n}\n\nexport default isDefined;\n", "import formatsIconSprite from './icons/formats';\n\nconst Icons = {\n Formats: formatsIconSprite\n};\n\nexport { Icons };\n\nexport { CustomAssetSource } from './assetSources/CustomAssetSource';\n\nexport { IndexedDBAssetSource } from './assetSources/IndexedDBAssetSource';\n\nexport { AggregatedAssetSource } from './assetSources/AggregatedAssetSource';\n\nexport { default as Metadata } from './metadata/Metadata';\n\nexport { default as FillProcessingMetadata } from './metadata/FillProcessingMetadata';\n\nexport { default as fillProcessing } from './processing/fillProcessing';\n\nexport { default as initializeFillProcessing } from './processing/initializeFillProcessing';\n\nexport { default as registerFillProcessingComponents } from './processing/registerFillProcessingComponents';\n\nexport { type Optional } from './types/Optional';\n\nexport {\n type Location,\n type UserInterfaceConfiguration\n} from './types/UserInterfaceConfiguration';\n\nexport { hexToRgba, isValidHexColor, rgbaToHex } from './utils/colors';\n\nexport {\n uploadBlob,\n fetchImageBlob,\n bufferURIToObjectURL,\n mimeTypeToExtension\n} from './utils/upload';\n\nexport { default as uuid } from './utils/uuid';\n\nexport { getImageDimensionsFromURL, getImageUri } from './utils/images';\n\nexport { default as isDefined } from './utils/isDefined';\n", "import CreativeEditorSDK, { AssetResult } from '@cesdk/cesdk-js';\nimport { RenderCustomProperty } from '../generation/provider';\n\n/**\n * Provides render function for a image url property that allows\n * to select an image from the library with a MediaPreview\n *\n * By default this expects the property key to be `image_url`. This can be changed in the options.\n */\nfunction renderImageUrlProperty(\n provderId: string,\n options: {\n cesdk: CreativeEditorSDK;\n propertyKey?: string;\n defaultUrl?: string;\n }\n): RenderCustomProperty {\n const { cesdk } = options;\n const propertyKey = options.propertyKey ?? 'image_url';\n const panelIdForImageSelection = getImageSelectionPanelId(provderId);\n\n cesdk.i18n.setTranslations({\n en: {\n [`panel.${panelIdForImageSelection}`]: 'Select Image To Change'\n }\n });\n\n createPanels(provderId, cesdk);\n\n const customProperties: RenderCustomProperty = {\n [propertyKey]: (context, property) => {\n const {\n builder,\n experimental: { global },\n payload\n } = context;\n const defaultUrl = payload?.url ?? options.defaultUrl;\n const stateValue = global<string>(\n `${provderId}.${property.id}`,\n defaultUrl\n );\n\n builder.MediaPreview(property.id, {\n preview: {\n type: 'image',\n uri: stateValue.value\n },\n action: {\n label: 'Select Image',\n onClick: () => {\n if (cesdk == null) return;\n\n cesdk.ui.openPanel(panelIdForImageSelection, {\n payload: {\n onSelect: (assetResult: AssetResult) => {\n if (assetResult.meta?.uri != null) {\n stateValue.setValue(assetResult.meta?.uri);\n }\n }\n }\n });\n }\n }\n });\n\n return () => {\n return {\n id: property.id,\n type: 'string',\n value: stateValue.value\n };\n };\n }\n };\n\n return customProperties;\n}\n\nfunction createPanels(providerId: string, cesdk?: CreativeEditorSDK) {\n if (cesdk == null) return;\n\n cesdk.ui.registerPanel<{\n onSelect: (assetResult: AssetResult) => void;\n }>(getImageSelectionPanelId(providerId), ({ builder, payload }) => {\n builder.Library(`${providerId}.library.image`, {\n entries: ['ly.img.image'],\n onSelect: async (asset) => {\n const uri = asset?.meta?.uri;\n if (uri == null) return;\n\n const mimeType = await cesdk.engine.editor.getMimeType(uri);\n if (mimeType === 'image/svg+xml') {\n cesdk.ui.showNotification({\n type: 'warning',\n message:\n 'SVG images are not supported. Please choose a different image.'\n });\n } else if (mimeType.startsWith('image/')) {\n payload?.onSelect(asset);\n cesdk?.ui.closePanel(getImageSelectionPanelId(providerId));\n } else {\n cesdk.ui.showNotification({\n type: 'warning',\n message: `Only images are supported. Found '${mimeType}'. Please choose a different image.`\n });\n }\n }\n });\n });\n}\n\nfunction getImageSelectionPanelId(providerId: string) {\n return `ly.img.ai/${providerId}.imageSelection`;\n}\n\nexport default renderImageUrlProperty;\n", "export default `\n<svg>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratioFree\"\n >\n <path d=\"M7 6C6.44772 6 6 6.44772 6 7V9.22222H4V7C4 5.34315 5.34315 4 7 4H9.22222V6H7Z\" fill=\"currentColor\"/>\n <path d=\"M17 6H14.7778V4H17C18.6569 4 20 5.34315 20 7V9.22222H18V7C18 6.44772 17.5523 6 17 6Z\" fill=\"currentColor\"/>\n <path d=\"M6 14.7778V17C6 17.5523 6.44772 18 7 18H9.22222V20H7C5.34315 20 4 18.6569 4 17V14.7778H6Z\" fill=\"currentColor\"/>\n <path d=\"M18 17V14.7778H20V17C20 18.6569 18.6569 20 17 20H14.7778V18H17C17.5523 18 18 17.5523 18 17Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratio4by3\"\n >\n <path d=\"M6.5 13H8V15H10V16.5H6.5V13Z\" fill=\"currentColor\"/>\n <path d=\"M14 9V7.5H17.5V11H16V9H14Z\" fill=\"currentColor\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M6 4C4.34315 4 3 5.34315 3 7V17C3 18.6569 4.34315 20 6 20H18C19.6569 20 21 18.6569 21 17V7C21 5.34315 19.6569 4 18 4H6ZM5 7C5 6.44772 5.44772 6 6 6H18C18.5523 6 19 6.44772 19 7V17C19 17.5523 18.5523 18 18 18H6C5.44772 18 5 17.5523 5 17V7Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratio16by9\"\n >\n <path d=\"M4.5 13H6V15H8V16.5H4.5V13Z\" fill=\"currentColor\"/>\n <path d=\"M16 9V7.5H19.5V11H18V9H16Z\" fill=\"currentColor\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M4 4C2.34315 4 1 5.34315 1 7V17C1 18.6569 2.34315 20 4 20H20C21.6569 20 23 18.6569 23 17V7C23 5.34315 21.6569 4 20 4H4ZM3 7C3 6.44772 3.44772 6 4 6H20C20.5523 6 21 6.44772 21 7V17C21 17.5523 20.5523 18 20 18H4C3.44772 18 3 17.5523 3 17V7Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratio9by16\"\n >\n <path d=\"M7.5 16H9V18H11V19.5H7.5V16Z\" fill=\"currentColor\"/>\n <path d=\"M13 6V4.5H16.5V8H15V6H13Z\" fill=\"currentColor\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M4 20C4 21.6569 5.34315 23 7 23H17C18.6569 23 20 21.6569 20 20V4C20 2.34315 18.6569 1 17 1H7C5.34315 1 4 2.34315 4 4V20ZM7 21C6.44772 21 6 20.5523 6 20V4C6 3.44772 6.44772 3 7 3H17C17.5523 3 18 3.44772 18 4V20C18 20.5523 17.5523 21 17 21H7Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratio3by4\"\n >\n <path d=\"M11 17.5V16H9V14H7.5V17.5H11Z\" fill=\"currentColor\"/>\n <path d=\"M15 10H16.5V6.5H13V8H15V10Z\" fill=\"currentColor\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M20 18C20 19.6569 18.6569 21 17 21H7C5.34315 21 4 19.6569 4 18V6C4 4.34315 5.34315 3 7 3H17C18.6569 3 20 4.34315 20 6V18ZM17 19C17.5523 19 18 18.5523 18 18V6C18 5.44772 17.5523 5 17 5H7C6.44771 5 6 5.44771 6 6V18C6 18.5523 6.44772 19 7 19H17Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratio1by1\"\n >\n <path d=\"M17.4142 8.00009L16 6.58587L14.2929 8.29298L15.7071 9.70719L17.4142 8.00009Z\" fill=\"currentColor\"/>\n <path d=\"M13.0404 12.3739L15.0404 10.3739L13.6262 8.95965L11.6262 10.9596L13.0404 12.3739Z\" fill=\"currentColor\"/>\n <path d=\"M10.3737 15.0405L12.3737 13.0405L10.9595 11.6263L8.95953 13.6263L10.3737 15.0405Z\" fill=\"currentColor\"/>\n <path d=\"M9.70708 15.7072L8.29286 14.293L6.58576 16.0001L7.99997 17.4143L9.70708 15.7072Z\" fill=\"currentColor\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M7 4C5.34315 4 4 5.34315 4 7V17C4 18.6569 5.34315 20 7 20H17C18.6569 20 20 18.6569 20 17V7C20 5.34315 18.6569 4 17 4H7ZM6 7C6 6.44772 6.44772 6 7 6H17C17.5523 6 18 6.44772 18 7V17C18 17.5523 17.5523 18 17 18H7C6.44772 18 6 17.5523 6 17V7Z\" fill=\"currentColor\"/>\n </symbol>\n</svg>\n`;\n", "import type {\n AssetDefinition,\n AssetQueryData,\n AssetResult,\n AssetSource,\n AssetsQueryResult\n} from '@cesdk/engine';\n\n/**\n * Simplified value type for select inputs that can be converted to asset definitions\n */\nexport type SelectValue = {\n id: string;\n label: string;\n thumbUri?: string;\n meta?: { [key: string]: any };\n};\n\n/**\n * A custom AssetSource implementation that manages assets from an array\n * and provides additional functionality like to mark assets as active or changing\n * labels.\n */\nexport class CustomAssetSource implements AssetSource {\n /** The unique id of the asset source */\n id: string;\n\n /** Array of assets to be served by this source */\n private assets: AssetDefinition[];\n\n /** Set of IDs for active assets */\n private activeAssetIds: Set<string>;\n\n /**\n * Creates a new instance of CustomAssetSource\n *\n * @param id - The unique identifier for this asset source\n * @param assets - Array of asset definitions or SelectValue objects to include in this source\n */\n constructor(id: string, assets: (AssetDefinition | SelectValue)[] = []) {\n this.id = id;\n this.assets = assets.map((asset) => {\n // Check if the asset is a SelectValue by looking for the label property as a string\n if (\n typeof (asset as SelectValue).label === 'string' &&\n !(\n (asset as AssetDefinition).label &&\n typeof (asset as AssetDefinition).label === 'object'\n )\n ) {\n const selectValue = asset as SelectValue;\n // Convert SelectValue to AssetDefinition\n return {\n id: selectValue.id,\n label: { en: selectValue.label },\n meta: selectValue.thumbUri\n ? { ...(selectValue.meta ?? {}), thumbUri: selectValue.thumbUri }\n : selectValue.meta\n } as AssetDefinition;\n }\n return asset as AssetDefinition;\n });\n this.activeAssetIds = new Set<string>();\n }\n\n /**\n * Find assets based on the provided query data\n * Supports pagination, searching, filtering, and active-first sorting\n *\n * @param queryData - Query parameters to filter and sort assets\n * @returns Promise with the query results\n */\n async findAssets(\n queryData: AssetQueryData\n ): Promise<AssetsQueryResult | undefined> {\n const {\n page,\n perPage,\n locale = 'en',\n sortActiveFirst,\n query,\n tags,\n groups,\n excludeGroups,\n sortingOrder,\n sortKey\n } = queryData;\n\n // Start with all assets\n let filteredAssets = [...this.assets];\n\n // Filter by groups if provided\n if (groups && groups.length > 0) {\n filteredAssets = filteredAssets.filter(\n (asset) =>\n asset.groups && groups.some((group) => asset.groups?.includes(group))\n );\n }\n\n // Filter out excluded groups if provided\n if (excludeGroups && excludeGroups.length > 0) {\n filteredAssets = filteredAssets.filter(\n (asset) =>\n !asset.groups ||\n !excludeGroups.some((group) => asset.groups?.includes(group))\n );\n }\n\n // Filter by query (search in label and tags)\n if (query) {\n const lowerQuery = query.toLowerCase();\n filteredAssets = filteredAssets.filter((asset) => {\n const label = asset.label?.[locale]?.toLowerCase();\n const assetTags = asset.tags?.[locale] || [];\n\n return (\n (label && label.includes(lowerQuery)) ||\n assetTags.some((tag) => tag.toLowerCase().includes(lowerQuery))\n );\n });\n }\n\n // Filter by exact tags if provided\n if (tags && tags.length > 0) {\n const tagArray = Array.isArray(tags) ? tags : [tags];\n filteredAssets = filteredAssets.filter((asset) => {\n const assetTags = asset.tags?.[locale] || [];\n return tagArray.some((tag) => assetTags.includes(tag));\n });\n }\n\n // Sort by active first if requested\n if (sortActiveFirst) {\n filteredAssets.sort((a, b) => {\n const aActive = this.activeAssetIds.has(a.id);\n const bActive = this.activeAssetIds.has(b.id);\n\n if (aActive && !bActive) return -1;\n if (!aActive && bActive) return 1;\n return 0;\n });\n }\n\n // Sort by sortKey if provided\n if (sortKey && sortKey !== 'id') {\n filteredAssets.sort((a, b) => {\n // Sort by metadata field\n const aValue = a.meta?.[sortKey];\n const bValue = b.meta?.[sortKey];\n\n if (aValue === undefined) return 1;\n if (bValue === undefined) return -1;\n\n if (typeof aValue === 'string' && typeof bValue === 'string') {\n return sortingOrder === 'Descending'\n ? bValue.localeCompare(aValue)\n : aValue.localeCompare(bValue);\n }\n\n if (typeof aValue === 'number' && typeof bValue === 'number') {\n return sortingOrder === 'Descending'\n ? bValue - aValue\n : aValue - bValue;\n }\n\n return 0;\n });\n } else if (sortKey === 'id') {\n // Sort by id\n filteredAssets.sort((a, b) => {\n return sortingOrder === 'Descending'\n ? b.id.localeCompare(a.id)\n : a.id.localeCompare(b.id);\n });\n }\n\n // Calculate pagination\n const total = filteredAssets.length;\n const startIndex = page * perPage;\n const endIndex = startIndex + perPage;\n const paginatedAssets = filteredAssets.slice(startIndex, endIndex);\n\n // Transform AssetDefinition objects to AssetResult objects\n const resultAssets: AssetResult[] = paginatedAssets.map((asset) => {\n return {\n id: asset.id,\n groups: asset.groups,\n meta: asset.meta,\n payload: asset.payload,\n locale,\n label: asset.label?.[locale],\n tags: asset.tags?.[locale],\n active: this.activeAssetIds.has(asset.id)\n };\n });\n\n // Calculate next page if there are more assets\n const nextPage = endIndex < total ? page + 1 : undefined;\n\n return {\n assets: resultAssets,\n currentPage: page,\n nextPage,\n total\n };\n }\n\n updateLabel(assetId: string, label: string, locale: string): void {\n this.assets.forEach((asset) => {\n if (asset.id === assetId) {\n asset.label = asset.label || {};\n asset.label[locale] = label;\n }\n });\n }\n\n /**\n * Get the asset select value by its ID\n *\n * @param assetId - The ID of the asset to retrieve\n * @returns The SelectValue object for the asset or undefined if not found\n */\n getAssetSelectValue(assetId: string): SelectValue | undefined {\n const asset = this.assets.find(({ id }) => id === assetId);\n if (asset) {\n return {\n id: asset.id,\n label: asset.label?.en || '',\n thumbUri: asset.meta?.thumbUri\n };\n }\n return undefined;\n }\n\n /**\n * Get an asset by its ID\n */\n getAsset(id: string): AssetDefinition | undefined {\n return this.assets.find((asset) => asset.id === id);\n }\n\n /**\n * Set an asset as active by its ID\n *\n * @param assetId - The ID of the asset to mark as active\n */\n setAssetActive(assetId: string): void {\n this.activeAssetIds.add(assetId);\n }\n\n /**\n * Get all active asset IDs\n *\n * @returns Array of active asset IDs\n */\n getActiveAssetIds(): string[] {\n return Array.from(this.activeAssetIds);\n }\n\n /**\n * Set multiple assets as active by their IDs\n *\n * @param assetIds - Array of asset IDs to mark as active\n */\n setAssetsActive(assetIds: string[]): void {\n assetIds.forEach((id) => this.activeAssetIds.add(id));\n }\n\n /**\n * Set an asset as inactive by its ID\n *\n * @param assetId - The ID of the asset to mark as inactive\n */\n setAssetInactive(assetId: string): void {\n this.activeAssetIds.delete(assetId);\n }\n\n /**\n * Clear all active assets\n */\n clearActiveAssets(): void {\n this.activeAssetIds.clear();\n }\n\n /**\n * Check if an asset is marked as active\n *\n * @param assetId - The ID of the asset to check\n * @returns True if the asset is active, false otherwise\n */\n isAssetActive(assetId: string): boolean {\n return this.activeAssetIds.has(assetId);\n }\n\n /**\n * Add an asset to this source\n *\n * @param asset - The asset definition to add\n */\n addAsset(asset: AssetDefinition): void {\n // Check if asset with this ID already exists\n const existingIndex = this.assets.findIndex((a) => a.id === asset.id);\n if (existingIndex >= 0) {\n // Replace existing asset\n this.assets[existingIndex] = asset;\n } else {\n // Add new asset\n this.assets.push(asset);\n }\n }\n\n /**\n * Remove an asset from this source\n *\n * @param assetId - The ID of the asset to remove\n */\n removeAsset(assetId: string): void {\n const index = this.assets.findIndex((asset) => asset.id === assetId);\n if (index !== -1) {\n this.assets.splice(index, 1);\n this.activeAssetIds.delete(assetId);\n }\n }\n\n /**\n * Get all available groups from the assets\n *\n * @returns Array of unique group names\n */\n async getGroups(): Promise<string[]> {\n const groups = new Set<string>();\n this.assets.forEach((asset) => {\n if (asset.groups) {\n asset.groups.forEach((group) => groups.add(group));\n }\n });\n return Array.from(groups);\n }\n\n /**\n * Returns the supported MIME types for this asset source\n *\n * @returns Array of supported MIME types\n */\n getSupportedMimeTypes(): string[] {\n return [\n 'image/jpeg',\n 'image/png',\n 'image/svg+xml',\n 'image/webp',\n 'video/mp4',\n 'audio/mpeg'\n ];\n }\n}\n\n/**\n * Helper function to create a CustomAssetSource instance\n *\n * @param id - The unique identifier for this asset source\n * @param assets - Array of asset definitions or SelectValue objects to include in this source\n * @returns A new CustomAssetSource instance\n */\nexport function createCustomAssetSource(\n id: string,\n assets: (AssetDefinition | SelectValue)[] = []\n): CustomAssetSource {\n return new CustomAssetSource(id, assets);\n}\n\nexport default CustomAssetSource;\n", "/* eslint-disable no-console */\nimport {\n CreativeEngine,\n type AssetDefinition,\n type AssetQueryData,\n type AssetResult,\n type AssetSource,\n type AssetsQueryResult\n} from '@cesdk/cesdk-js';\n\ntype BlobEntry = {\n id: string;\n blob: Blob;\n};\n\n// Asset definition with meta containing insertedAt timestamp\ntype AssetEntryWithMeta = AssetDefinition;\n\n/**\n * IndexedDBAssetSource implements the AssetSource interface using IndexedDB as the storage backend.\n */\nexport class IndexedDBAssetSource implements AssetSource {\n /** The unique id of the API */\n public readonly id: string;\n\n public readonly engine: CreativeEngine;\n\n private readonly dbName: string;\n\n private readonly dbVersion: number;\n\n private readonly assetStoreName: string = 'assets';\n\n private readonly blobStoreName: string = 'blobs';\n\n private db: IDBDatabase | null = null;\n\n /**\n * Creates a new IndexedDBAssetSource\n *\n * @param id - The unique identifier for this asset source\n * @param {Object} [options] - Optional configuration options.\n * @param {string} [options.dbName] - The name of the database.\n * @param {number} [options.dbVersion] - The version number of the database.\n */\n constructor(\n id: string,\n engine: CreativeEngine,\n options?: {\n dbName?: string;\n dbVersion?: number;\n }\n ) {\n this.id = id;\n this.engine = engine;\n this.dbName = options?.dbName ?? `ly.img.assetSource/${id}`;\n this.dbVersion = options?.dbVersion ?? 1;\n }\n\n /**\n * Initialize the database connection and create object stores if needed\n */\n public async initialize(): Promise<void> {\n if (this.db) {\n return;\n }\n\n return new Promise((resolve, reject) => {\n const request = indexedDB.open(this.dbName, this.dbVersion);\n\n request.onerror = (event) => {\n reject(\n new Error(\n `Failed to open IndexedDB: ${(event.target as IDBRequest).error}`\n )\n );\n };\n\n request.onupgradeneeded = (event) => {\n const db = (event.target as IDBOpenDBRequest).result;\n\n // Create asset store if it doesn't exist\n if (!db.objectStoreNames.contains(this.assetStoreName)) {\n db.createObjectStore(this.assetStoreName, {\n keyPath: 'id'\n });\n }\n // Create blob store if it doesn't exist\n if (!db.objectStoreNames.contains(this.blobStoreName)) {\n db.createObjectStore(this.blobStoreName, {\n keyPath: 'id'\n });\n }\n };\n\n request.onsuccess = (event) => {\n this.db = (event.target as IDBOpenDBRequest).result;\n resolve();\n };\n });\n }\n\n /**\n * Close the database connection\n */\n public close(): void {\n if (this.db) {\n this.db.close();\n this.db = null;\n }\n }\n\n /**\n * Find all assets for the given type and the provided query data.\n *\n * @param queryData - The query parameters for filtering assets\n * @param insertionSortOrder - Optional parameter to sort by insertion time: 'asc' for oldest first, 'desc' for newest first (default)\n * @returns A promise that resolves to the query results or undefined if there was an error\n */\n public async findAssets(\n queryData: AssetQueryData\n ): Promise<AssetsQueryResult | undefined> {\n await this.initialize();\n\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n try {\n // Get all assets from the store with specified insertion order\n const assetDefinitions = await this.getAllAssets('asc');\n\n let assetResults = assetDefinitions.reduce((acc, assetDefinition) => {\n const locale = queryData.locale ?? 'en';\n let label = '';\n let tags: string[] = [];\n\n // Handle localized label if available\n if (\n assetDefinition.label != null &&\n typeof assetDefinition.label === 'object' &&\n assetDefinition.label[locale]\n ) {\n label = assetDefinition.label[locale];\n }\n\n // Handle localized tags if available\n if (\n assetDefinition.tags != null &&\n typeof assetDefinition.tags === 'object' &&\n assetDefinition.tags[locale]\n ) {\n tags = assetDefinition.tags[locale];\n }\n\n const result: AssetResult = {\n ...assetDefinition,\n label,\n tags\n };\n\n if (this.filterAsset(result, queryData)) {\n acc.push(result);\n }\n\n return acc;\n }, [] as AssetResult[]);\n\n assetResults = await this.restoreBlobUrls(assetResults);\n\n // Apply sorting\n assetResults = this.sortAssets(assetResults, queryData);\n\n // Apply pagination\n const { page, perPage } = queryData;\n const startIndex = page * perPage;\n const endIndex = startIndex + perPage;\n const paginatedAssets = assetResults.slice(startIndex, endIndex);\n\n // Determine if there's a next page\n const nextPage = endIndex < assetResults.length ? page + 1 : undefined;\n\n const result = {\n assets: paginatedAssets,\n currentPage: page,\n nextPage,\n total: assetResults.length\n };\n\n return result;\n } catch (error) {\n console.error('Error finding assets:', error);\n return undefined;\n }\n }\n\n public async getGroups(): Promise<string[]> {\n await this.initialize();\n\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n return new Promise((resolve, reject) => {\n const transaction = this.db!.transaction(this.assetStoreName, 'readonly');\n const store = transaction.objectStore(this.assetStoreName);\n const request = store.getAll();\n\n request.onsuccess = () => {\n const allGroups = new Set<string>();\n\n // Extract all groups from all assets\n (request.result as AssetResult[]).forEach((asset) => {\n if (asset.groups && Array.isArray(asset.groups)) {\n asset.groups.forEach((group) => allGroups.add(group));\n }\n });\n\n const uniqueGroups = [...allGroups];\n resolve(uniqueGroups);\n };\n\n request.onerror = () => {\n reject(new Error(`Failed to get groups: ${request.error}`));\n };\n });\n }\n\n /**\n * Adds the given asset to this source. Part of the AssetSource interface.\n *\n * @param asset - The asset definition to add\n */\n public addAsset(asset: AssetDefinition): void {\n this.initialize()\n .then(async () => {\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n const transaction = this.db.transaction(\n this.assetStoreName,\n 'readwrite'\n );\n const assetStore = transaction.objectStore(this.assetStoreName);\n\n const blobsToStore = new Set<string>();\n processBlobUrls(asset, (value) => {\n blobsToStore.add(value);\n });\n\n setTimeout(() => {\n this.storeBlobUrls([...blobsToStore]);\n });\n\n // Ensure asset has meta object with insertedAt timestamp\n const assetWithMeta: AssetEntryWithMeta = {\n ...asset,\n meta: {\n ...asset.meta,\n insertedAt: asset.meta?.insertedAt || Date.now()\n }\n };\n\n // Store the asset in the database\n assetStore.put(assetWithMeta);\n\n transaction.onerror = () => {\n console.error(`Failed to add asset: ${transaction.error}`);\n };\n })\n .catch((error) => {\n console.error('Error initializing database:', error);\n });\n }\n\n /**\n * Removes the given asset from this source. Part of the AssetSource interface.\n *\n * @param assetId - The ID of the asset to remove\n */\n public async removeAsset(assetId: string): Promise<void> {\n const asset = await this.getAsset(assetId);\n\n return this.initialize()\n .then(() => {\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n const transaction = this.db.transaction(\n this.assetStoreName,\n 'readwrite'\n );\n const store = transaction.objectStore(this.assetStoreName);\n store.delete(assetId);\n\n transaction.oncomplete = () => {\n processBlobUrls(asset, (value) => {\n this.removeBlob(value);\n });\n this.engine.asset.assetSourceContentsChanged(this.id);\n };\n\n transaction.onerror = () => {\n console.error(`Failed to remove asset: ${transaction.error}`);\n };\n })\n .catch((error) => {\n console.error('Error initializing database:', error);\n });\n }\n\n /**\n * Removes the given asset from this source. Part of the AssetSource interface.\n *\n * @param assetId - The ID of the asset to remove\n */\n public async removeBlob(blobId: string): Promise<void> {\n return this.initialize()\n .then(() => {\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n const transaction = this.db.transaction(\n this.blobStoreName,\n 'readwrite'\n );\n const store = transaction.objectStore(this.blobStoreName);\n store.delete(blobId);\n\n transaction.onerror = () => {\n console.error(`Failed to remove blob: ${transaction.error}`);\n };\n })\n .catch((error) => {\n console.error('Error initializing database:', error);\n });\n }\n\n /**\n * Get all assets from the database sorted by insertion order (newest to oldest)\n *\n * @param sortOrder - Optional parameter to specify sort order: 'asc' for oldest first, 'desc' for newest first (default)\n * @returns A promise that resolves to an array of all assets\n */\n private async getAllAssets(\n sortOrder: 'asc' | 'desc' = 'desc'\n ): Promise<AssetDefinition[]> {\n return new Promise((resolve, reject) => {\n const transaction = this.db!.transaction(this.assetStoreName, 'readonly');\n const store = transaction.objectStore(this.assetStoreName);\n const request = store.getAll();\n\n request.onsuccess = () => {\n const assets = request.result as AssetEntryWithMeta[];\n\n // Sort by insertion timestamp\n assets.sort((a, b) => {\n // Default to current time if insertedAt is missing (for backward compatibility)\n // First check in meta.insertedAt, then fallback to legacy _insertedAt for backward compatibility\n const timeA =\n a.meta?.insertedAt || (a as any)._insertedAt || Date.now();\n const timeB =\n b.meta?.insertedAt || (b as any)._insertedAt || Date.now();\n\n // Sort based on requested order\n return sortOrder === 'asc'\n ? timeA - timeB // oldest first\n : timeB - timeA; // newest first (default)\n });\n\n resolve(assets);\n };\n\n request.onerror = () => {\n reject(new Error(`Failed to get assets: ${request.error}`));\n };\n });\n }\n\n // Retrieve a blob by ID\n async getAsset(id: string): Promise<AssetResult | undefined> {\n return new Promise((resolve, reject) => {\n const transaction = this.db!.transaction(this.assetStoreName, 'readonly');\n const store = transaction.objectStore(this.assetStoreName);\n const request = store.get(id);\n\n request.onsuccess = () => {\n resolve(request.result as AssetResult);\n };\n\n request.onerror = () => {\n reject(new Error(`Failed to get blob: ${request.error}`));\n };\n });\n }\n\n // Retrieve a blob by ID\n async getBlob(id: string): Promise<BlobEntry | undefined> {\n return new Promise((resolve, reject) => {\n const transaction = this.db!.transaction(this.blobStoreName, 'readonly');\n const store = transaction.objectStore(this.blobStoreName);\n const request = store.get(id);\n\n request.onsuccess = () => {\n resolve(request.result as BlobEntry);\n };\n\n request.onerror = () => {\n reject(new Error(`Failed to get blob: ${request.error}`));\n };\n });\n }\n\n async createBlobUrlFromStore(blobUrl: string): Promise<string> {\n const blobEntry = await this.getBlob(blobUrl);\n if (blobEntry != null) {\n return URL.createObjectURL(blobEntry.blob);\n }\n return blobUrl;\n }\n\n async storeBlobUrls(urls: string[]): Promise<void> {\n const blobsToStore: { [key: string]: Blob } = {};\n await Promise.all(\n urls.map(async (blobUrl) => {\n const blobResponse = await fetch(blobUrl);\n const blob = await blobResponse.blob();\n blobsToStore[blobUrl] = blob;\n })\n );\n\n return this.initialize()\n .then(async () => {\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n const transaction = this.db.transaction(\n this.blobStoreName,\n 'readwrite'\n );\n const blobStore = transaction.objectStore(this.blobStoreName);\n\n // Store the asset in the database\n Object.entries(blobsToStore).forEach(([key, blob]) => {\n const asset: BlobEntry = { id: key, blob };\n blobStore.put(asset);\n });\n\n transaction.onerror = () => {\n console.error(`Failed to add blobs: ${transaction.error}`);\n };\n })\n .catch((error) => {\n console.error('Error initializing database:', error);\n });\n }\n\n async restoreBlobUrls(assets: AssetResult[]): Promise<AssetResult[]> {\n const blobReplaced: { [key: string]: string } = {};\n const blobUrls: Set<string> = new Set();\n processBlobUrls(assets, (value) => {\n blobUrls.add(value);\n });\n\n await Promise.all(\n [...blobUrls].map(async (value) => {\n const newUrl = await this.createBlobUrlFromStore(value);\n blobReplaced[value] = newUrl;\n })\n );\n\n return processBlobUrls(assets, (value) => {\n return blobReplaced[value] ?? value;\n });\n }\n\n /**\n * Returns if the given asset should be filtered based on query data\n *\n * @param asset - The asset to filter\n * @param queryData - The query parameters to filter by\n * @returns true if the asset should be included, false otherwise\n */\n private filterAsset(asset: AssetResult, queryData: AssetQueryData): boolean {\n const { query, tags, groups, excludeGroups } = queryData;\n\n // Filter by query string (search on label and tags)\n if (query && query.trim() !== '') {\n const lowerQuery = query.trim().toLowerCase().split(' ');\n\n const lowerLabel = asset.label?.toLowerCase() ?? '';\n const lowerTags = asset.tags?.map((tag) => tag.toLowerCase()) ?? [];\n\n const matchLabelOrTag = lowerQuery.every((word) => {\n return (\n lowerLabel.includes(word) ||\n lowerTags.some((tag) => tag.includes(word))\n );\n });\n\n if (!matchLabelOrTag) {\n return false;\n }\n }\n\n // Filter by exact tags if provided by the query\n if (tags) {\n const tagList = Array.isArray(tags) ? tags : [tags];\n if (\n tagList.length > 0 &&\n (!asset.tags || !tagList.every((tag) => asset.tags?.includes(tag)))\n ) {\n return false;\n }\n }\n\n // Filter by groups\n if (groups && groups.length > 0) {\n if (\n !asset.groups ||\n !groups.some((group) => asset.groups?.includes(group))\n ) {\n return false;\n }\n }\n\n // Filter by excluded groups\n if (excludeGroups && excludeGroups.length > 0) {\n if (\n asset.groups &&\n asset.groups.some((group) => excludeGroups.includes(group))\n ) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Sort assets based on query data\n *\n * @param assets - The assets to sort\n * @param queryData - The query parameters with sorting information\n * @returns The sorted assets\n */\n private sortAssets(\n assets: AssetResult[],\n queryData: AssetQueryData\n ): AssetResult[] {\n const { sortingOrder, sortKey, sortActiveFirst } = queryData;\n\n // Clone the array to avoid modifying the original\n const sortedAssets = [...assets];\n\n // If no sorting order specified or set to 'None', return the current order\n if (!sortingOrder || sortingOrder === 'None') {\n return sortedAssets;\n }\n\n // Sort by the specified key\n if (sortKey) {\n sortedAssets.sort((a, b) => {\n let valueA;\n let valueB;\n\n if (sortKey === 'id') {\n valueA = a.id;\n valueB = b.id;\n } else {\n // Handle metadata sorting (assuming metadata is stored in a 'metadata' field)\n valueA = a.meta?.[sortKey] ?? null;\n valueB = b.meta?.[sortKey] ?? null;\n }\n\n // Handle null/undefined values\n if (valueA === null || valueA === undefined)\n return sortingOrder === 'Ascending' ? -1 : 1;\n if (valueB === null || valueB === undefined)\n return sortingOrder === 'Ascending' ? 1 : -1;\n\n // Compare values based on sorting order\n if (typeof valueA === 'string' && typeof valueB === 'string') {\n return sortingOrder === 'Ascending'\n ? valueA.localeCompare(valueB)\n : valueB.localeCompare(valueA);\n } else {\n return sortingOrder === 'Ascending'\n ? valueA < valueB\n ? -1\n : valueA > valueB\n ? 1\n : 0\n : valueA > valueB\n ? -1\n : valueA < valueB\n ? 1\n : 0;\n }\n });\n } else if (sortingOrder === 'Descending') {\n // If no sort key is specified, and sorting order set\n // to Descending, just reverse original order\n sortedAssets.reverse();\n }\n\n // Sort by active first if requested\n if (sortActiveFirst) {\n sortedAssets.sort((a, b) => {\n if (a.active && !b.active) return -1;\n if (!a.active && b.active) return 1;\n return 0;\n });\n }\n\n return sortedAssets;\n }\n}\n\n/**\n * Goes through an object and calls a callback for every string value that starts with 'blob:'\n * The callback can return a string to replace the original value\n * @param obj The object to traverse\n * @param callback Function to call when a blob URL is found, can return a replacement value\n * @param path Current path in the object (used for recursion)\n * @returns The modified object (or the original if no replacements were made)\n */\nfunction processBlobUrls<T>(\n obj: T,\n callback: (value: string, path: string) => string | void,\n path: string = ''\n): T {\n // Return the object as is if it's null or not an object\n if (obj === null || typeof obj !== 'object') {\n return obj;\n }\n\n // Handle arrays\n if (Array.isArray(obj)) {\n for (let index = 0; index < obj.length; index++) {\n const currentPath = path ? `${path}[${index}]` : `[${index}]`;\n\n if (typeof obj[index] === 'string' && obj[index].startsWith('blob:')) {\n const replacement = callback(obj[index], currentPath);\n if (typeof replacement === 'string') {\n obj[index] = replacement;\n }\n } else {\n obj[index] = processBlobUrls(obj[index], callback, currentPath);\n }\n }\n return obj;\n }\n\n // Handle regular objects\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n const value = obj[key];\n const currentPath = path ? `${path}.${key}` : key;\n\n if (typeof value === 'string' && value.startsWith('blob:')) {\n const replacement = callback(value, currentPath);\n if (typeof replacement === 'string') {\n // @ts-ignore\n obj[key] = replacement;\n }\n } else {\n obj[key] = processBlobUrls(value, callback, currentPath);\n }\n }\n }\n\n return obj;\n}\n\nexport default IndexedDBAssetSource;\n", "/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type {\n AssetDefinition,\n AssetQueryData,\n AssetResult,\n AssetSource,\n AssetsQueryResult\n} from '@cesdk/cesdk-js';\nimport CreativeEditorSDK from '@cesdk/cesdk-js';\n\n/**\n * AggregatedAssetSource implements the AssetSource interface by aggregating\n * multiple asset sources via the cesdk API and combining their results.\n *\n * This asset source is read-only - it does not support adding or removing assets.\n */\nexport class AggregatedAssetSource implements AssetSource {\n /** The unique id of the asset source */\n public readonly id: string;\n\n /** The Creative Editor SDK instance */\n private cesdk: CreativeEditorSDK;\n\n /** The IDs of asset sources to aggregate */\n private assetSourceIds: string[];\n\n /**\n * Creates a new AggregatedAssetSource\n *\n * @param id - The unique identifier for this asset source\n * @param cesdk - The Creative Editor SDK instance\n * @param assetSourceIds - The IDs of asset sources to aggregate\n */\n constructor(id: string, cesdk: CreativeEditorSDK, assetSourceIds: string[]) {\n this.id = id;\n this.cesdk = cesdk;\n this.assetSourceIds = assetSourceIds;\n }\n\n /**\n * Find assets across all aggregated sources based on the provided query data\n * Results are sorted by the insertedAt timestamp in meta field\n *\n * @param queryData - Query parameters to filter and sort assets\n * @returns Promise with the query results\n */\n async findAssets(\n queryData: AssetQueryData\n ): Promise<AssetsQueryResult | undefined> {\n try {\n // Query all asset sources via cesdk\n const queryPromises = this.assetSourceIds.map((sourceId) =>\n this.cesdk.engine.asset.findAssets(sourceId, {\n ...queryData,\n // Increase page size to get all assets from each source\n // We'll handle pagination after merging\n perPage: 9999,\n page: 0\n })\n );\n\n // Wait for all queries to complete\n const results = await Promise.all(queryPromises);\n\n // Combine all assets from all sources\n let allAssets: AssetResult[] = [];\n results.forEach((result) => {\n if (result?.assets) {\n allAssets = allAssets.concat(result.assets);\n }\n });\n\n // Sort by insertedAt timestamp\n allAssets.sort((a, b) => {\n const timeA = (a.meta?.insertedAt as number) || 0;\n const timeB = (b.meta?.insertedAt as number) || 0;\n\n // Sort newest first (descending)\n return timeB - timeA;\n });\n\n // Apply pagination after merging\n const { page, perPage } = queryData;\n const startIndex = page * perPage;\n const endIndex = startIndex + perPage;\n const paginatedAssets = allAssets.slice(startIndex, endIndex);\n\n // Calculate if there is a next page\n const nextPage = endIndex < allAssets.length ? page + 1 : undefined;\n\n return {\n assets: paginatedAssets,\n currentPage: page,\n nextPage,\n total: allAssets.length\n };\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error finding assets:', error);\n return undefined;\n }\n }\n\n /**\n * Retrieves all groups from all aggregated asset sources using cesdk\n * @returns Promise with an array of unique group names\n */\n async getGroups(): Promise<string[]> {\n const groupPromises = this.assetSourceIds.map((sourceId) =>\n this.cesdk.engine.asset.getGroups(sourceId)\n );\n\n const groupArrays = await Promise.all(groupPromises);\n\n // Combine and deduplicate groups\n const uniqueGroups = new Set<string>();\n groupArrays.forEach((groups) => {\n groups.forEach((group) => uniqueGroups.add(group));\n });\n\n return Array.from(uniqueGroups);\n }\n\n /**\n * This operation is not supported in AggregatedAssetSource\n * @throws Error - This method is not supported\n */\n addAsset(_asset: AssetDefinition): void {\n throw new Error('AggregatedAssetSource does not support adding assets');\n }\n\n /**\n * This operation is not supported in AggregatedAssetSource\n * @throws Error - This method is not supported\n */\n removeAsset(_assetId: string): void {\n throw new Error('AggregatedAssetSource does not support removing assets');\n }\n}\n\n/**\n * Helper function to create an AggregatedAssetSource instance\n *\n * @param id - The unique identifier for this asset source\n * @param cesdk - The Creative Editor SDK instance\n * @param assetSourceIds - The IDs of asset sources to aggregate\n * @returns A new AggregatedAssetSource instance\n */\nexport function createAggregatedAssetSource(\n id: string,\n cesdk: CreativeEditorSDK,\n assetSourceIds: string[]\n): AggregatedAssetSource {\n return new AggregatedAssetSource(id, cesdk, assetSourceIds);\n}\n\nexport default AggregatedAssetSource;\n", "import { type CreativeEngine } from '@cesdk/cesdk-js';\n\nclass Metadata<V> {\n engine: CreativeEngine;\n\n key: string;\n\n constructor(engine: CreativeEngine, key: string) {\n this.engine = engine;\n this.key = key;\n }\n\n hasData(blockId: number): boolean {\n return (\n this.engine.block.isValid(blockId) &&\n this.engine.block.hasMetadata(blockId, this.key)\n );\n }\n\n get(blockId: number): V | undefined {\n if (this.hasData(blockId)) {\n return JSON.parse(this.engine.block.getMetadata(blockId, this.key));\n }\n return undefined;\n }\n\n set(blockId: number, value: V) {\n this.engine.block.setMetadata(blockId, this.key, JSON.stringify(value));\n }\n\n clear(blockId: number) {\n if (this.engine.block.hasMetadata(blockId, this.key)) {\n this.engine.block.removeMetadata(blockId, this.key);\n }\n }\n}\n\nexport default Metadata;\n", "/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\nexport default freeGlobal;\n", "import freeGlobal from './_freeGlobal.js';\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\nexport default root;\n", "import root from './_root.js';\n\n/** Built-in value references. */\nvar Symbol = root.Symbol;\n\nexport default Symbol;\n", "import Symbol from './_Symbol.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\nfunction getRawTag(value) {\n var isOwn = hasOwnProperty.call(value, symToStringTag),\n tag = value[symToStringTag];\n\n try {\n value[symToStringTag] = undefined;\n var unmasked = true;\n } catch (e) {}\n\n var result = nativeObjectToString.call(value);\n if (unmasked) {\n if (isOwn) {\n value[symToStringTag] = tag;\n } else {\n delete value[symToStringTag];\n }\n }\n return result;\n}\n\nexport default getRawTag;\n", "/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\nfunction objectToString(value) {\n return nativeObjectToString.call(value);\n}\n\nexport default objectToString;\n", "import Symbol from './_Symbol.js';\nimport getRawTag from './_getRawTag.js';\nimport objectToString from './_objectToString.js';\n\n/** `Object#toString` result references. */\nvar nullTag = '[object Null]',\n undefinedTag = '[object Undefined]';\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n return (symToStringTag && symToStringTag in Object(value))\n ? getRawTag(value)\n : objectToString(value);\n}\n\nexport default baseGetTag;\n", "/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return value != null && typeof value == 'object';\n}\n\nexport default isObjectLike;\n", "/**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\nvar isArray = Array.isArray;\n\nexport default isArray;\n", "/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n}\n\nexport default isObject;\n", "import baseGetTag from './_baseGetTag.js';\nimport isObject from './isObject.js';\n\n/** `Object#toString` result references. */\nvar asyncTag = '[object AsyncFunction]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n proxyTag = '[object Proxy]';\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n if (!isObject(value)) {\n return false;\n }\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 9 which returns 'object' for typed arrays and other constructors.\n var tag = baseGetTag(value);\n return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;\n}\n\nexport default isFunction;\n", "import root from './_root.js';\n\n/** Used to detect overreaching core-js shims. */\nvar coreJsData = root['__core-js_shared__'];\n\nexport default coreJsData;\n", "import coreJsData from './_coreJsData.js';\n\n/** Used to detect methods masquerading as native. */\nvar maskSrcKey = (function() {\n var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');\n return uid ? ('Symbol(src)_1.' + uid) : '';\n}());\n\n/**\n * Checks if `func` has its source masked.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` is masked, else `false`.\n */\nfunction isMasked(func) {\n return !!maskSrcKey && (maskSrcKey in func);\n}\n\nexport default isMasked;\n", "/** Used for built-in method references. */\nvar funcProto = Function.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/**\n * Converts `func` to its source code.\n *\n * @private\n * @param {Function} func The function to convert.\n * @returns {string} Returns the source code.\n */\nfunction toSource(func) {\n if (func != null) {\n try {\n return funcToString.call(func);\n } catch (e) {}\n try {\n return (func + '');\n } catch (e) {}\n }\n return '';\n}\n\nexport default toSource;\n", "import isFunction from './isFunction.js';\nimport isMasked from './_isMasked.js';\nimport isObject from './isObject.js';\nimport toSource from './_toSource.js';\n\n/**\n * Used to match `RegExp`\n * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).\n */\nvar reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g;\n\n/** Used to detect host constructors (Safari). */\nvar reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n\n/** Used for built-in method references. */\nvar funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Used to detect if a method is native. */\nvar reIsNative = RegExp('^' +\n funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\\\$&')\n .replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$'\n);\n\n/**\n * The base implementation of `_.isNative` without bad shim checks.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n * else `false`.\n */\nfunction baseIsNative(value) {\n if (!isObject(value) || isMasked(value)) {\n return false;\n }\n var pattern = isFunction(value) ? reIsNative : reIsHostCtor;\n return pattern.test(toSource(value));\n}\n\nexport default baseIsNative;\n", "/**\n * Gets the value at `key` of `object`.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\nfunction getValue(object, key) {\n return object == null ? undefined : object[key];\n}\n\nexport default getValue;\n", "import baseIsNative from './_baseIsNative.js';\nimport getValue from './_getValue.js';\n\n/**\n * Gets the native function at `key` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the method to get.\n * @returns {*} Returns the function if it's native, else `undefined`.\n */\nfunction getNative(object, key) {\n var value = getValue(object, key);\n return baseIsNative(value) ? value : undefined;\n}\n\nexport default getNative;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar WeakMap = getNative(root, 'WeakMap');\n\nexport default WeakMap;\n", "/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/** Used to detect unsigned integer values. */\nvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n/**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\nfunction isIndex(value, length) {\n var type = typeof value;\n length = length == null ? MAX_SAFE_INTEGER : length;\n\n return !!length &&\n (type == 'number' ||\n (type != 'symbol' && reIsUint.test(value))) &&\n (value > -1 && value % 1 == 0 && value < length);\n}\n\nexport default isIndex;\n", "/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\nexport default eq;\n", "/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\nexport default isLength;\n", "import isFunction from './isFunction.js';\nimport isLength from './isLength.js';\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n}\n\nexport default isArrayLike;\n", "/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Checks if `value` is likely a prototype object.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.\n */\nfunction isPrototype(value) {\n var Ctor = value && value.constructor,\n proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;\n\n return value === proto;\n}\n\nexport default isPrototype;\n", "/**\n * The base implementation of `_.times` without support for iteratee shorthands\n * or max array length checks.\n *\n * @private\n * @param {number} n The number of times to invoke `iteratee`.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the array of results.\n */\nfunction baseTimes(n, iteratee) {\n var index = -1,\n result = Array(n);\n\n while (++index < n) {\n result[index] = iteratee(index);\n }\n return result;\n}\n\nexport default baseTimes;\n", "import baseGetTag from './_baseGetTag.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]';\n\n/**\n * The base implementation of `_.isArguments`.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n */\nfunction baseIsArguments(value) {\n return isObjectLike(value) && baseGetTag(value) == argsTag;\n}\n\nexport default baseIsArguments;\n", "import baseIsArguments from './_baseIsArguments.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Built-in value references. */\nvar propertyIsEnumerable = objectProto.propertyIsEnumerable;\n\n/**\n * Checks if `value` is likely an `arguments` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n * else `false`.\n * @example\n *\n * _.isArguments(function() { return arguments; }());\n * // => true\n *\n * _.isArguments([1, 2, 3]);\n * // => false\n */\nvar isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {\n return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&\n !propertyIsEnumerable.call(value, 'callee');\n};\n\nexport default isArguments;\n", "/**\n * This method returns `false`.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {boolean} Returns `false`.\n * @example\n *\n * _.times(2, _.stubFalse);\n * // => [false, false]\n */\nfunction stubFalse() {\n return false;\n}\n\nexport default stubFalse;\n", "import root from './_root.js';\nimport stubFalse from './stubFalse.js';\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Built-in value references. */\nvar Buffer = moduleExports ? root.Buffer : undefined;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;\n\n/**\n * Checks if `value` is a buffer.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.\n * @example\n *\n * _.isBuffer(new Buffer(2));\n * // => true\n *\n * _.isBuffer(new Uint8Array(2));\n * // => false\n */\nvar isBuffer = nativeIsBuffer || stubFalse;\n\nexport default isBuffer;\n", "import baseGetTag from './_baseGetTag.js';\nimport isLength from './isLength.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n errorTag = '[object Error]',\n funcTag = '[object Function]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n objectTag = '[object Object]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n weakMapTag = '[object WeakMap]';\n\nvar arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]',\n float32Tag = '[object Float32Array]',\n float64Tag = '[object Float64Array]',\n int8Tag = '[object Int8Array]',\n int16Tag = '[object Int16Array]',\n int32Tag = '[object Int32Array]',\n uint8Tag = '[object Uint8Array]',\n uint8ClampedTag = '[object Uint8ClampedArray]',\n uint16Tag = '[object Uint16Array]',\n uint32Tag = '[object Uint32Array]';\n\n/** Used to identify `toStringTag` values of typed arrays. */\nvar typedArrayTags = {};\ntypedArrayTags[float32Tag] = typedArrayTags[float64Tag] =\ntypedArrayTags[int8Tag] = typedArrayTags[int16Tag] =\ntypedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =\ntypedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =\ntypedArrayTags[uint32Tag] = true;\ntypedArrayTags[argsTag] = typedArrayTags[arrayTag] =\ntypedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =\ntypedArrayTags[dataViewTag] = typedArrayTags[dateTag] =\ntypedArrayTags[errorTag] = typedArrayTags[funcTag] =\ntypedArrayTags[mapTag] = typedArrayTags[numberTag] =\ntypedArrayTags[objectTag] = typedArrayTags[regexpTag] =\ntypedArrayTags[setTag] = typedArrayTags[stringTag] =\ntypedArrayTags[weakMapTag] = false;\n\n/**\n * The base implementation of `_.isTypedArray` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n */\nfunction baseIsTypedArray(value) {\n return isObjectLike(value) &&\n isLength(value.length) && !!typedArrayTags[baseGetTag(value)];\n}\n\nexport default baseIsTypedArray;\n", "/**\n * The base implementation of `_.unary` without support for storing metadata.\n *\n * @private\n * @param {Function} func The function to cap arguments for.\n * @returns {Function} Returns the new capped function.\n */\nfunction baseUnary(func) {\n return function(value) {\n return func(value);\n };\n}\n\nexport default baseUnary;\n", "import freeGlobal from './_freeGlobal.js';\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Detect free variable `process` from Node.js. */\nvar freeProcess = moduleExports && freeGlobal.process;\n\n/** Used to access faster Node.js helpers. */\nvar nodeUtil = (function() {\n try {\n // Use `util.types` for Node.js 10+.\n var types = freeModule && freeModule.require && freeModule.require('util').types;\n\n if (types) {\n return types;\n }\n\n // Legacy `process.binding('util')` for Node.js < 10.\n return freeProcess && freeProcess.binding && freeProcess.binding('util');\n } catch (e) {}\n}());\n\nexport default nodeUtil;\n", "import baseIsTypedArray from './_baseIsTypedArray.js';\nimport baseUnary from './_baseUnary.js';\nimport nodeUtil from './_nodeUtil.js';\n\n/* Node.js helper references. */\nvar nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;\n\n/**\n * Checks if `value` is classified as a typed array.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n * @example\n *\n * _.isTypedArray(new Uint8Array);\n * // => true\n *\n * _.isTypedArray([]);\n * // => false\n */\nvar isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;\n\nexport default isTypedArray;\n", "import baseTimes from './_baseTimes.js';\nimport isArguments from './isArguments.js';\nimport isArray from './isArray.js';\nimport isBuffer from './isBuffer.js';\nimport isIndex from './_isIndex.js';\nimport isTypedArray from './isTypedArray.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Creates an array of the enumerable property names of the array-like `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @param {boolean} inherited Specify returning inherited property names.\n * @returns {Array} Returns the array of property names.\n */\nfunction arrayLikeKeys(value, inherited) {\n var isArr = isArray(value),\n isArg = !isArr && isArguments(value),\n isBuff = !isArr && !isArg && isBuffer(value),\n isType = !isArr && !isArg && !isBuff && isTypedArray(value),\n skipIndexes = isArr || isArg || isBuff || isType,\n result = skipIndexes ? baseTimes(value.length, String) : [],\n length = result.length;\n\n for (var key in value) {\n if ((inherited || hasOwnProperty.call(value, key)) &&\n !(skipIndexes && (\n // Safari 9 has enumerable `arguments.length` in strict mode.\n key == 'length' ||\n // Node.js 0.10 has enumerable non-index properties on buffers.\n (isBuff && (key == 'offset' || key == 'parent')) ||\n // PhantomJS 2 has enumerable non-index properties on typed arrays.\n (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||\n // Skip index properties.\n isIndex(key, length)\n ))) {\n result.push(key);\n }\n }\n return result;\n}\n\nexport default arrayLikeKeys;\n", "/**\n * Creates a unary function that invokes `func` with its argument transformed.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {Function} transform The argument transform.\n * @returns {Function} Returns the new function.\n */\nfunction overArg(func, transform) {\n return function(arg) {\n return func(transform(arg));\n };\n}\n\nexport default overArg;\n", "import overArg from './_overArg.js';\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeKeys = overArg(Object.keys, Object);\n\nexport default nativeKeys;\n", "import isPrototype from './_isPrototype.js';\nimport nativeKeys from './_nativeKeys.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction baseKeys(object) {\n if (!isPrototype(object)) {\n return nativeKeys(object);\n }\n var result = [];\n for (var key in Object(object)) {\n if (hasOwnProperty.call(object, key) && key != 'constructor') {\n result.push(key);\n }\n }\n return result;\n}\n\nexport default baseKeys;\n", "import arrayLikeKeys from './_arrayLikeKeys.js';\nimport baseKeys from './_baseKeys.js';\nimport isArrayLike from './isArrayLike.js';\n\n/**\n * Creates an array of the own enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects. See the\n * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n * for more details.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keys(new Foo);\n * // => ['a', 'b'] (iteration order is not guaranteed)\n *\n * _.keys('hi');\n * // => ['0', '1']\n */\nfunction keys(object) {\n return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);\n}\n\nexport default keys;\n", "import getNative from './_getNative.js';\n\n/* Built-in method references that are verified to be native. */\nvar nativeCreate = getNative(Object, 'create');\n\nexport default nativeCreate;\n", "import nativeCreate from './_nativeCreate.js';\n\n/**\n * Removes all key-value entries from the hash.\n *\n * @private\n * @name clear\n * @memberOf Hash\n */\nfunction hashClear() {\n this.__data__ = nativeCreate ? nativeCreate(null) : {};\n this.size = 0;\n}\n\nexport default hashClear;\n", "/**\n * Removes `key` and its value from the hash.\n *\n * @private\n * @name delete\n * @memberOf Hash\n * @param {Object} hash The hash to modify.\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction hashDelete(key) {\n var result = this.has(key) && delete this.__data__[key];\n this.size -= result ? 1 : 0;\n return result;\n}\n\nexport default hashDelete;\n", "import nativeCreate from './_nativeCreate.js';\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Gets the hash value for `key`.\n *\n * @private\n * @name get\n * @memberOf Hash\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction hashGet(key) {\n var data = this.__data__;\n if (nativeCreate) {\n var result = data[key];\n return result === HASH_UNDEFINED ? undefined : result;\n }\n return hasOwnProperty.call(data, key) ? data[key] : undefined;\n}\n\nexport default hashGet;\n", "import nativeCreate from './_nativeCreate.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Checks if a hash value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Hash\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction hashHas(key) {\n var data = this.__data__;\n return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);\n}\n\nexport default hashHas;\n", "import nativeCreate from './_nativeCreate.js';\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/**\n * Sets the hash `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Hash\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the hash instance.\n */\nfunction hashSet(key, value) {\n var data = this.__data__;\n this.size += this.has(key) ? 0 : 1;\n data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;\n return this;\n}\n\nexport default hashSet;\n", "import hashClear from './_hashClear.js';\nimport hashDelete from './_hashDelete.js';\nimport hashGet from './_hashGet.js';\nimport hashHas from './_hashHas.js';\nimport hashSet from './_hashSet.js';\n\n/**\n * Creates a hash object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Hash(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `Hash`.\nHash.prototype.clear = hashClear;\nHash.prototype['delete'] = hashDelete;\nHash.prototype.get = hashGet;\nHash.prototype.has = hashHas;\nHash.prototype.set = hashSet;\n\nexport default Hash;\n", "/**\n * Removes all key-value entries from the list cache.\n *\n * @private\n * @name clear\n * @memberOf ListCache\n */\nfunction listCacheClear() {\n this.__data__ = [];\n this.size = 0;\n}\n\nexport default listCacheClear;\n", "import eq from './eq.js';\n\n/**\n * Gets the index at which the `key` is found in `array` of key-value pairs.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} key The key to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction assocIndexOf(array, key) {\n var length = array.length;\n while (length--) {\n if (eq(array[length][0], key)) {\n return length;\n }\n }\n return -1;\n}\n\nexport default assocIndexOf;\n", "import assocIndexOf from './_assocIndexOf.js';\n\n/** Used for built-in method references. */\nvar arrayProto = Array.prototype;\n\n/** Built-in value references. */\nvar splice = arrayProto.splice;\n\n/**\n * Removes `key` and its value from the list cache.\n *\n * @private\n * @name delete\n * @memberOf ListCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction listCacheDelete(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n return false;\n }\n var lastIndex = data.length - 1;\n if (index == lastIndex) {\n data.pop();\n } else {\n splice.call(data, index, 1);\n }\n --this.size;\n return true;\n}\n\nexport default listCacheDelete;\n", "import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Gets the list cache value for `key`.\n *\n * @private\n * @name get\n * @memberOf ListCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction listCacheGet(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n return index < 0 ? undefined : data[index][1];\n}\n\nexport default listCacheGet;\n", "import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Checks if a list cache value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf ListCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction listCacheHas(key) {\n return assocIndexOf(this.__data__, key) > -1;\n}\n\nexport default listCacheHas;\n", "import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Sets the list cache `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf ListCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the list cache instance.\n */\nfunction listCacheSet(key, value) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n ++this.size;\n data.push([key, value]);\n } else {\n data[index][1] = value;\n }\n return this;\n}\n\nexport default listCacheSet;\n", "import listCacheClear from './_listCacheClear.js';\nimport listCacheDelete from './_listCacheDelete.js';\nimport listCacheGet from './_listCacheGet.js';\nimport listCacheHas from './_listCacheHas.js';\nimport listCacheSet from './_listCacheSet.js';\n\n/**\n * Creates an list cache object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction ListCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `ListCache`.\nListCache.prototype.clear = listCacheClear;\nListCache.prototype['delete'] = listCacheDelete;\nListCache.prototype.get = listCacheGet;\nListCache.prototype.has = listCacheHas;\nListCache.prototype.set = listCacheSet;\n\nexport default ListCache;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar Map = getNative(root, 'Map');\n\nexport default Map;\n", "import Hash from './_Hash.js';\nimport ListCache from './_ListCache.js';\nimport Map from './_Map.js';\n\n/**\n * Removes all key-value entries from the map.\n *\n * @private\n * @name clear\n * @memberOf MapCache\n */\nfunction mapCacheClear() {\n this.size = 0;\n this.__data__ = {\n 'hash': new Hash,\n 'map': new (Map || ListCache),\n 'string': new Hash\n };\n}\n\nexport default mapCacheClear;\n", "/**\n * Checks if `value` is suitable for use as unique object key.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is suitable, else `false`.\n */\nfunction isKeyable(value) {\n var type = typeof value;\n return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')\n ? (value !== '__proto__')\n : (value === null);\n}\n\nexport default isKeyable;\n", "import isKeyable from './_isKeyable.js';\n\n/**\n * Gets the data for `map`.\n *\n * @private\n * @param {Object} map The map to query.\n * @param {string} key The reference key.\n * @returns {*} Returns the map data.\n */\nfunction getMapData(map, key) {\n var data = map.__data__;\n return isKeyable(key)\n ? data[typeof key == 'string' ? 'string' : 'hash']\n : data.map;\n}\n\nexport default getMapData;\n", "import getMapData from './_getMapData.js';\n\n/**\n * Removes `key` and its value from the map.\n *\n * @private\n * @name delete\n * @memberOf MapCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction mapCacheDelete(key) {\n var result = getMapData(this, key)['delete'](key);\n this.size -= result ? 1 : 0;\n return result;\n}\n\nexport default mapCacheDelete;\n", "import getMapData from './_getMapData.js';\n\n/**\n * Gets the map value for `key`.\n *\n * @private\n * @name get\n * @memberOf MapCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction mapCacheGet(key) {\n return getMapData(this, key).get(key);\n}\n\nexport default mapCacheGet;\n", "import getMapData from './_getMapData.js';\n\n/**\n * Checks if a map value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf MapCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction mapCacheHas(key) {\n return getMapData(this, key).has(key);\n}\n\nexport default mapCacheHas;\n", "import getMapData from './_getMapData.js';\n\n/**\n * Sets the map `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf MapCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the map cache instance.\n */\nfunction mapCacheSet(key, value) {\n var data = getMapData(this, key),\n size = data.size;\n\n data.set(key, value);\n this.size += data.size == size ? 0 : 1;\n return this;\n}\n\nexport default mapCacheSet;\n", "import mapCacheClear from './_mapCacheClear.js';\nimport mapCacheDelete from './_mapCacheDelete.js';\nimport mapCacheGet from './_mapCacheGet.js';\nimport mapCacheHas from './_mapCacheHas.js';\nimport mapCacheSet from './_mapCacheSet.js';\n\n/**\n * Creates a map cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction MapCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `MapCache`.\nMapCache.prototype.clear = mapCacheClear;\nMapCache.prototype['delete'] = mapCacheDelete;\nMapCache.prototype.get = mapCacheGet;\nMapCache.prototype.has = mapCacheHas;\nMapCache.prototype.set = mapCacheSet;\n\nexport default MapCache;\n", "/**\n * Appends the elements of `values` to `array`.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {Array} values The values to append.\n * @returns {Array} Returns `array`.\n */\nfunction arrayPush(array, values) {\n var index = -1,\n length = values.length,\n offset = array.length;\n\n while (++index < length) {\n array[offset + index] = values[index];\n }\n return array;\n}\n\nexport default arrayPush;\n", "import ListCache from './_ListCache.js';\n\n/**\n * Removes all key-value entries from the stack.\n *\n * @private\n * @name clear\n * @memberOf Stack\n */\nfunction stackClear() {\n this.__data__ = new ListCache;\n this.size = 0;\n}\n\nexport default stackClear;\n", "/**\n * Removes `key` and its value from the stack.\n *\n * @private\n * @name delete\n * @memberOf Stack\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction stackDelete(key) {\n var data = this.__data__,\n result = data['delete'](key);\n\n this.size = data.size;\n return result;\n}\n\nexport default stackDelete;\n", "/**\n * Gets the stack value for `key`.\n *\n * @private\n * @name get\n * @memberOf Stack\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction stackGet(key) {\n return this.__data__.get(key);\n}\n\nexport default stackGet;\n", "/**\n * Checks if a stack value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Stack\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction stackHas(key) {\n return this.__data__.has(key);\n}\n\nexport default stackHas;\n", "import ListCache from './_ListCache.js';\nimport Map from './_Map.js';\nimport MapCache from './_MapCache.js';\n\n/** Used as the size to enable large array optimizations. */\nvar LARGE_ARRAY_SIZE = 200;\n\n/**\n * Sets the stack `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Stack\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the stack cache instance.\n */\nfunction stackSet(key, value) {\n var data = this.__data__;\n if (data instanceof ListCache) {\n var pairs = data.__data__;\n if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {\n pairs.push([key, value]);\n this.size = ++data.size;\n return this;\n }\n data = this.__data__ = new MapCache(pairs);\n }\n data.set(key, value);\n this.size = data.size;\n return this;\n}\n\nexport default stackSet;\n", "import ListCache from './_ListCache.js';\nimport stackClear from './_stackClear.js';\nimport stackDelete from './_stackDelete.js';\nimport stackGet from './_stackGet.js';\nimport stackHas from './_stackHas.js';\nimport stackSet from './_stackSet.js';\n\n/**\n * Creates a stack cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Stack(entries) {\n var data = this.__data__ = new ListCache(entries);\n this.size = data.size;\n}\n\n// Add methods to `Stack`.\nStack.prototype.clear = stackClear;\nStack.prototype['delete'] = stackDelete;\nStack.prototype.get = stackGet;\nStack.prototype.has = stackHas;\nStack.prototype.set = stackSet;\n\nexport default Stack;\n", "/**\n * A specialized version of `_.filter` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {Array} Returns the new filtered array.\n */\nfunction arrayFilter(array, predicate) {\n var index = -1,\n length = array == null ? 0 : array.length,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (predicate(value, index, array)) {\n result[resIndex++] = value;\n }\n }\n return result;\n}\n\nexport default arrayFilter;\n", "/**\n * This method returns a new empty array.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {Array} Returns the new empty array.\n * @example\n *\n * var arrays = _.times(2, _.stubArray);\n *\n * console.log(arrays);\n * // => [[], []]\n *\n * console.log(arrays[0] === arrays[1]);\n * // => false\n */\nfunction stubArray() {\n return [];\n}\n\nexport default stubArray;\n", "import arrayFilter from './_arrayFilter.js';\nimport stubArray from './stubArray.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Built-in value references. */\nvar propertyIsEnumerable = objectProto.propertyIsEnumerable;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeGetSymbols = Object.getOwnPropertySymbols;\n\n/**\n * Creates an array of the own enumerable symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of symbols.\n */\nvar getSymbols = !nativeGetSymbols ? stubArray : function(object) {\n if (object == null) {\n return [];\n }\n object = Object(object);\n return arrayFilter(nativeGetSymbols(object), function(symbol) {\n return propertyIsEnumerable.call(object, symbol);\n });\n};\n\nexport default getSymbols;\n", "import arrayPush from './_arrayPush.js';\nimport isArray from './isArray.js';\n\n/**\n * The base implementation of `getAllKeys` and `getAllKeysIn` which uses\n * `keysFunc` and `symbolsFunc` to get the enumerable property names and\n * symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Function} keysFunc The function to get the keys of `object`.\n * @param {Function} symbolsFunc The function to get the symbols of `object`.\n * @returns {Array} Returns the array of property names and symbols.\n */\nfunction baseGetAllKeys(object, keysFunc, symbolsFunc) {\n var result = keysFunc(object);\n return isArray(object) ? result : arrayPush(result, symbolsFunc(object));\n}\n\nexport default baseGetAllKeys;\n", "import baseGetAllKeys from './_baseGetAllKeys.js';\nimport getSymbols from './_getSymbols.js';\nimport keys from './keys.js';\n\n/**\n * Creates an array of own enumerable property names and symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names and symbols.\n */\nfunction getAllKeys(object) {\n return baseGetAllKeys(object, keys, getSymbols);\n}\n\nexport default getAllKeys;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar DataView = getNative(root, 'DataView');\n\nexport default DataView;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar Promise = getNative(root, 'Promise');\n\nexport default Promise;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar Set = getNative(root, 'Set');\n\nexport default Set;\n", "import DataView from './_DataView.js';\nimport Map from './_Map.js';\nimport Promise from './_Promise.js';\nimport Set from './_Set.js';\nimport WeakMap from './_WeakMap.js';\nimport baseGetTag from './_baseGetTag.js';\nimport toSource from './_toSource.js';\n\n/** `Object#toString` result references. */\nvar mapTag = '[object Map]',\n objectTag = '[object Object]',\n promiseTag = '[object Promise]',\n setTag = '[object Set]',\n weakMapTag = '[object WeakMap]';\n\nvar dataViewTag = '[object DataView]';\n\n/** Used to detect maps, sets, and weakmaps. */\nvar dataViewCtorString = toSource(DataView),\n mapCtorString = toSource(Map),\n promiseCtorString = toSource(Promise),\n setCtorString = toSource(Set),\n weakMapCtorString = toSource(WeakMap);\n\n/**\n * Gets the `toStringTag` of `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nvar getTag = baseGetTag;\n\n// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.\nif ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||\n (Map && getTag(new Map) != mapTag) ||\n (Promise && getTag(Promise.resolve()) != promiseTag) ||\n (Set && getTag(new Set) != setTag) ||\n (WeakMap && getTag(new WeakMap) != weakMapTag)) {\n getTag = function(value) {\n var result = baseGetTag(value),\n Ctor = result == objectTag ? value.constructor : undefined,\n ctorString = Ctor ? toSource(Ctor) : '';\n\n if (ctorString) {\n switch (ctorString) {\n case dataViewCtorString: return dataViewTag;\n case mapCtorString: return mapTag;\n case promiseCtorString: return promiseTag;\n case setCtorString: return setTag;\n case weakMapCtorString: return weakMapTag;\n }\n }\n return result;\n };\n}\n\nexport default getTag;\n", "import root from './_root.js';\n\n/** Built-in value references. */\nvar Uint8Array = root.Uint8Array;\n\nexport default Uint8Array;\n", "/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/**\n * Adds `value` to the array cache.\n *\n * @private\n * @name add\n * @memberOf SetCache\n * @alias push\n * @param {*} value The value to cache.\n * @returns {Object} Returns the cache instance.\n */\nfunction setCacheAdd(value) {\n this.__data__.set(value, HASH_UNDEFINED);\n return this;\n}\n\nexport default setCacheAdd;\n", "/**\n * Checks if `value` is in the array cache.\n *\n * @private\n * @name has\n * @memberOf SetCache\n * @param {*} value The value to search for.\n * @returns {number} Returns `true` if `value` is found, else `false`.\n */\nfunction setCacheHas(value) {\n return this.__data__.has(value);\n}\n\nexport default setCacheHas;\n", "import MapCache from './_MapCache.js';\nimport setCacheAdd from './_setCacheAdd.js';\nimport setCacheHas from './_setCacheHas.js';\n\n/**\n *\n * Creates an array cache object to store unique values.\n *\n * @private\n * @constructor\n * @param {Array} [values] The values to cache.\n */\nfunction SetCache(values) {\n var index = -1,\n length = values == null ? 0 : values.length;\n\n this.__data__ = new MapCache;\n while (++index < length) {\n this.add(values[index]);\n }\n}\n\n// Add methods to `SetCache`.\nSetCache.prototype.add = SetCache.prototype.push = setCacheAdd;\nSetCache.prototype.has = setCacheHas;\n\nexport default SetCache;\n", "/**\n * A specialized version of `_.some` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if any element passes the predicate check,\n * else `false`.\n */\nfunction arraySome(array, predicate) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n while (++index < length) {\n if (predicate(array[index], index, array)) {\n return true;\n }\n }\n return false;\n}\n\nexport default arraySome;\n", "/**\n * Checks if a `cache` value for `key` exists.\n *\n * @private\n * @param {Object} cache The cache to query.\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction cacheHas(cache, key) {\n return cache.has(key);\n}\n\nexport default cacheHas;\n", "import SetCache from './_SetCache.js';\nimport arraySome from './_arraySome.js';\nimport cacheHas from './_cacheHas.js';\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1,\n COMPARE_UNORDERED_FLAG = 2;\n\n/**\n * A specialized version of `baseIsEqualDeep` for arrays with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Array} array The array to compare.\n * @param {Array} other The other array to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `array` and `other` objects.\n * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.\n */\nfunction equalArrays(array, other, bitmask, customizer, equalFunc, stack) {\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG,\n arrLength = array.length,\n othLength = other.length;\n\n if (arrLength != othLength && !(isPartial && othLength > arrLength)) {\n return false;\n }\n // Check that cyclic values are equal.\n var arrStacked = stack.get(array);\n var othStacked = stack.get(other);\n if (arrStacked && othStacked) {\n return arrStacked == other && othStacked == array;\n }\n var index = -1,\n result = true,\n seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;\n\n stack.set(array, other);\n stack.set(other, array);\n\n // Ignore non-index properties.\n while (++index < arrLength) {\n var arrValue = array[index],\n othValue = other[index];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, arrValue, index, other, array, stack)\n : customizer(arrValue, othValue, index, array, other, stack);\n }\n if (compared !== undefined) {\n if (compared) {\n continue;\n }\n result = false;\n break;\n }\n // Recursively compare arrays (susceptible to call stack limits).\n if (seen) {\n if (!arraySome(other, function(othValue, othIndex) {\n if (!cacheHas(seen, othIndex) &&\n (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {\n return seen.push(othIndex);\n }\n })) {\n result = false;\n break;\n }\n } else if (!(\n arrValue === othValue ||\n equalFunc(arrValue, othValue, bitmask, customizer, stack)\n )) {\n result = false;\n break;\n }\n }\n stack['delete'](array);\n stack['delete'](other);\n return result;\n}\n\nexport default equalArrays;\n", "/**\n * Converts `map` to its key-value pairs.\n *\n * @private\n * @param {Object} map The map to convert.\n * @returns {Array} Returns the key-value pairs.\n */\nfunction mapToArray(map) {\n var index = -1,\n result = Array(map.size);\n\n map.forEach(function(value, key) {\n result[++index] = [key, value];\n });\n return result;\n}\n\nexport default mapToArray;\n", "/**\n * Converts `set` to an array of its values.\n *\n * @private\n * @param {Object} set The set to convert.\n * @returns {Array} Returns the values.\n */\nfunction setToArray(set) {\n var index = -1,\n result = Array(set.size);\n\n set.forEach(function(value) {\n result[++index] = value;\n });\n return result;\n}\n\nexport default setToArray;\n", "import Symbol from './_Symbol.js';\nimport Uint8Array from './_Uint8Array.js';\nimport eq from './eq.js';\nimport equalArrays from './_equalArrays.js';\nimport mapToArray from './_mapToArray.js';\nimport setToArray from './_setToArray.js';\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1,\n COMPARE_UNORDERED_FLAG = 2;\n\n/** `Object#toString` result references. */\nvar boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n errorTag = '[object Error]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n symbolTag = '[object Symbol]';\n\nvar arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]';\n\n/** Used to convert symbols to primitives and strings. */\nvar symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;\n\n/**\n * A specialized version of `baseIsEqualDeep` for comparing objects of\n * the same `toStringTag`.\n *\n * **Note:** This function only supports comparing values with tags of\n * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {string} tag The `toStringTag` of the objects to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {\n switch (tag) {\n case dataViewTag:\n if ((object.byteLength != other.byteLength) ||\n (object.byteOffset != other.byteOffset)) {\n return false;\n }\n object = object.buffer;\n other = other.buffer;\n\n case arrayBufferTag:\n if ((object.byteLength != other.byteLength) ||\n !equalFunc(new Uint8Array(object), new Uint8Array(other))) {\n return false;\n }\n return true;\n\n case boolTag:\n case dateTag:\n case numberTag:\n // Coerce booleans to `1` or `0` and dates to milliseconds.\n // Invalid dates are coerced to `NaN`.\n return eq(+object, +other);\n\n case errorTag:\n return object.name == other.name && object.message == other.message;\n\n case regexpTag:\n case stringTag:\n // Coerce regexes to strings and treat strings, primitives and objects,\n // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring\n // for more details.\n return object == (other + '');\n\n case mapTag:\n var convert = mapToArray;\n\n case setTag:\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG;\n convert || (convert = setToArray);\n\n if (object.size != other.size && !isPartial) {\n return false;\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(object);\n if (stacked) {\n return stacked == other;\n }\n bitmask |= COMPARE_UNORDERED_FLAG;\n\n // Recursively compare objects (susceptible to call stack limits).\n stack.set(object, other);\n var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);\n stack['delete'](object);\n return result;\n\n case symbolTag:\n if (symbolValueOf) {\n return symbolValueOf.call(object) == symbolValueOf.call(other);\n }\n }\n return false;\n}\n\nexport default equalByTag;\n", "import getAllKeys from './_getAllKeys.js';\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1;\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * A specialized version of `baseIsEqualDeep` for objects with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction equalObjects(object, other, bitmask, customizer, equalFunc, stack) {\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG,\n objProps = getAllKeys(object),\n objLength = objProps.length,\n othProps = getAllKeys(other),\n othLength = othProps.length;\n\n if (objLength != othLength && !isPartial) {\n return false;\n }\n var index = objLength;\n while (index--) {\n var key = objProps[index];\n if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {\n return false;\n }\n }\n // Check that cyclic values are equal.\n var objStacked = stack.get(object);\n var othStacked = stack.get(other);\n if (objStacked && othStacked) {\n return objStacked == other && othStacked == object;\n }\n var result = true;\n stack.set(object, other);\n stack.set(other, object);\n\n var skipCtor = isPartial;\n while (++index < objLength) {\n key = objProps[index];\n var objValue = object[key],\n othValue = other[key];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, objValue, key, other, object, stack)\n : customizer(objValue, othValue, key, object, other, stack);\n }\n // Recursively compare objects (susceptible to call stack limits).\n if (!(compared === undefined\n ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))\n : compared\n )) {\n result = false;\n break;\n }\n skipCtor || (skipCtor = key == 'constructor');\n }\n if (result && !skipCtor) {\n var objCtor = object.constructor,\n othCtor = other.constructor;\n\n // Non `Object` object instances with different constructors are not equal.\n if (objCtor != othCtor &&\n ('constructor' in object && 'constructor' in other) &&\n !(typeof objCtor == 'function' && objCtor instanceof objCtor &&\n typeof othCtor == 'function' && othCtor instanceof othCtor)) {\n result = false;\n }\n }\n stack['delete'](object);\n stack['delete'](other);\n return result;\n}\n\nexport default equalObjects;\n", "import Stack from './_Stack.js';\nimport equalArrays from './_equalArrays.js';\nimport equalByTag from './_equalByTag.js';\nimport equalObjects from './_equalObjects.js';\nimport getTag from './_getTag.js';\nimport isArray from './isArray.js';\nimport isBuffer from './isBuffer.js';\nimport isTypedArray from './isTypedArray.js';\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1;\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n objectTag = '[object Object]';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * A specialized version of `baseIsEqual` for arrays and objects which performs\n * deep comparisons and tracks traversed objects enabling objects with circular\n * references to be compared.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} [stack] Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {\n var objIsArr = isArray(object),\n othIsArr = isArray(other),\n objTag = objIsArr ? arrayTag : getTag(object),\n othTag = othIsArr ? arrayTag : getTag(other);\n\n objTag = objTag == argsTag ? objectTag : objTag;\n othTag = othTag == argsTag ? objectTag : othTag;\n\n var objIsObj = objTag == objectTag,\n othIsObj = othTag == objectTag,\n isSameTag = objTag == othTag;\n\n if (isSameTag && isBuffer(object)) {\n if (!isBuffer(other)) {\n return false;\n }\n objIsArr = true;\n objIsObj = false;\n }\n if (isSameTag && !objIsObj) {\n stack || (stack = new Stack);\n return (objIsArr || isTypedArray(object))\n ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)\n : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);\n }\n if (!(bitmask & COMPARE_PARTIAL_FLAG)) {\n var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),\n othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');\n\n if (objIsWrapped || othIsWrapped) {\n var objUnwrapped = objIsWrapped ? object.value() : object,\n othUnwrapped = othIsWrapped ? other.value() : other;\n\n stack || (stack = new Stack);\n return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);\n }\n }\n if (!isSameTag) {\n return false;\n }\n stack || (stack = new Stack);\n return equalObjects(object, other, bitmask, customizer, equalFunc, stack);\n}\n\nexport default baseIsEqualDeep;\n", "import baseIsEqualDeep from './_baseIsEqualDeep.js';\nimport isObjectLike from './isObjectLike.js';\n\n/**\n * The base implementation of `_.isEqual` which supports partial comparisons\n * and tracks traversed objects.\n *\n * @private\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @param {boolean} bitmask The bitmask flags.\n * 1 - Unordered comparison\n * 2 - Partial comparison\n * @param {Function} [customizer] The function to customize comparisons.\n * @param {Object} [stack] Tracks traversed `value` and `other` objects.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n */\nfunction baseIsEqual(value, other, bitmask, customizer, stack) {\n if (value === other) {\n return true;\n }\n if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {\n return value !== value && other !== other;\n }\n return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);\n}\n\nexport default baseIsEqual;\n", "import baseIsEqual from './_baseIsEqual.js';\n\n/**\n * Performs a deep comparison between two values to determine if they are\n * equivalent.\n *\n * **Note:** This method supports comparing arrays, array buffers, booleans,\n * date objects, error objects, maps, numbers, `Object` objects, regexes,\n * sets, strings, symbols, and typed arrays. `Object` objects are compared\n * by their own, not inherited, enumerable properties. Functions and DOM\n * nodes are compared by strict equality, i.e. `===`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.isEqual(object, other);\n * // => true\n *\n * object === other;\n * // => false\n */\nfunction isEqual(value, other) {\n return baseIsEqual(value, other);\n}\n\nexport default isEqual;\n", "import { isEqual } from 'lodash-es';\n\nimport Metadata from './Metadata';\nimport {\n PluginStatusError,\n PluginStatusMetadata,\n PluginStatusProcessed,\n PluginStatusProcessing\n} from './types';\n\nclass ImageProcessingMetadata extends Metadata<PluginStatusMetadata> {\n get(blockId: number): PluginStatusMetadata {\n return super.get(blockId) ?? { status: 'IDLE' };\n }\n\n /**\n * Detect if the block has been duplicated with processed or processing\n * fill processing. In that case the processing state is still\n * valid, but blockId and fillId have changed.\n */\n isDuplicate(blockId: number): boolean {\n if (!this.engine.block.isValid(blockId)) return false;\n\n const metadata = this.get(blockId);\n\n if (\n metadata.status === 'IDLE' ||\n metadata.status === 'PENDING' ||\n metadata.status === 'ERROR'\n )\n return false;\n\n if (!this.engine.block.hasFill(blockId)) return false;\n const fillId = this.engine.block.getFill(blockId);\n\n // It cannot be a duplicate if the blockId or fillId are the same\n if (metadata.blockId === blockId || metadata.fillId === fillId)\n return false;\n\n return true;\n }\n\n /**\n * Fixes the metadata if the block has been duplicated, i.e. the blockId and\n * fillId will be updated to the current block/fill.\n *\n * Please note: Call this method only on duplicates (see isDuplicate).\n */\n fixDuplicate(blockId: number) {\n const fillId = this.engine.block.getFill(blockId);\n const metadata = this.get(blockId);\n if (\n metadata.status === 'IDLE' ||\n metadata.status === 'PENDING' ||\n metadata.status === 'ERROR'\n )\n return;\n this.set(blockId, {\n ...metadata,\n blockId,\n fillId\n });\n\n // If it is currently processing the best we can do is to just recover\n // the initial image data, since no processing will update this block and\n // it will be stuck in the processing state.\n if (metadata.status === 'PROCESSING') {\n this.recoverInitialImageData(blockId);\n this.clear(blockId);\n }\n }\n\n /**\n * Check if the image has a consisten metadata state. A inconsistent state is\n * caused by outside changes of the fill data.\n *\n * @returns true if the metadata is consistent, false otherwise\n */\n isConsistent(blockId: number): boolean {\n // In case the block was removed, we just abort and mark it\n // as reset by returning true\n if (!this.engine.block.isValid(blockId)) return false;\n const metadata = this.get(blockId);\n if (metadata.status === 'IDLE' || metadata.status === 'PENDING')\n return true;\n\n if (!this.engine.block.hasFill(blockId)) return false;\n const fillId = this.engine.block.getFill(blockId);\n if (fillId == null) return false;\n\n if (blockId !== metadata.blockId || fillId !== metadata.fillId)\n return false;\n\n const sourceSet = this.engine.block.getSourceSet(\n fillId,\n 'fill/image/sourceSet'\n );\n const imageFileURI = this.engine.block.getString(\n fillId,\n 'fill/image/imageFileURI'\n );\n\n if (\n sourceSet.length === 0 &&\n !imageFileURI &&\n metadata.status === 'PROCESSING'\n ) {\n // While we process it is OK to have no image file URI and no source set\n // (which we cleared to show the spinning loader)\n return true;\n }\n\n // Source sets have precedence over imageFileURI so if we have a source set,\n // we only need to check if it has changed to something else.\n if (sourceSet?.length > 0) {\n const initialSourceSet = metadata.initialSourceSet;\n // If we have already processed the image, we need to check if the source set\n // we need to check against both source sets, the removed and the initial\n if (metadata.status !== 'PROCESSED') {\n if (!isEqual(sourceSet, initialSourceSet)) {\n return false;\n }\n }\n } else {\n if (metadata.status !== 'PROCESSED') {\n if (imageFileURI !== metadata.initialImageFileURI) {\n return false;\n }\n }\n }\n return true;\n }\n\n /**\n * Recover the initial values to avoid the loading spinner and have the same\n * state as before the fill processing was started.\n */\n recoverInitialImageData(blockId: number) {\n const blockApi = this.engine.block;\n if (!blockApi.hasFill(blockId)) return; // Nothing to recover (no fill anymore)\n\n const metadata = this.get(blockId);\n\n if (metadata.status === 'PENDING' || metadata.status === 'IDLE') {\n return;\n }\n\n const initialSourceSet = metadata.initialSourceSet;\n const initialImageFileURI = metadata.initialImageFileURI;\n const initialPreviewFileURI = metadata.initialPreviewFileURI;\n\n const fillId = this.getValidFill(blockId, metadata);\n if (fillId == null) return;\n\n if (initialImageFileURI) {\n this.engine.block.setString(\n fillId,\n 'fill/image/imageFileURI',\n initialImageFileURI\n );\n }\n if (initialPreviewFileURI) {\n this.engine.block.setString(\n fillId,\n 'fill/image/previewFileURI',\n initialPreviewFileURI\n );\n }\n if (initialSourceSet.length > 0) {\n this.engine.block.setSourceSet(\n fillId,\n 'fill/image/sourceSet',\n initialSourceSet\n );\n }\n }\n\n /**\n * Returns the fill id of the block if it has a valid fill that was used for\n * fill processing. Returns undefined otherwise.\n */\n private getValidFill(\n blockId: number,\n metadata: PluginStatusProcessing | PluginStatusError | PluginStatusProcessed\n ): number | undefined {\n if (\n !this.engine.block.isValid(blockId) ||\n !this.engine.block.hasFill(blockId) ||\n blockId !== metadata.blockId\n ) {\n return undefined;\n }\n const fillId = this.engine.block.getFill(blockId);\n if (fillId !== metadata.fillId) {\n return undefined;\n }\n\n return fillId;\n }\n}\n\nexport default ImageProcessingMetadata;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { FillProcessingMetadata } from '..';\nimport {\n PluginStatusProcessed,\n PluginStatusProcessing\n} from '../metadata/types';\n\ninterface FillProcessor<T> {\n processFill(metadataState: PluginStatusProcessing): Promise<T>;\n\n commitProcessing(\n data: T,\n metadataState: PluginStatusProcessed\n ): number | void;\n}\n\nasync function fillProcessing<T>(\n blockId: number,\n cesdk: CreativeEditorSDK,\n metadata: FillProcessingMetadata,\n processor: FillProcessor<T>\n) {\n const blockApi = cesdk.engine.block;\n if (!blockApi.hasFill(blockId))\n throw new Error('Block does not support fill');\n\n const fillId = blockApi.getFill(blockId);\n\n // Get the current image URI and source set as initial values.\n const initialSourceSet = blockApi.getSourceSet(\n fillId,\n 'fill/image/sourceSet'\n );\n const initialImageFileURI = blockApi.getString(\n fillId,\n 'fill/image/imageFileURI'\n );\n const initialPreviewFileURI = blockApi.getString(\n fillId,\n 'fill/image/previewFileURI'\n );\n try {\n cesdk.engine.block.setState(fillId, {\n type: 'Pending',\n progress: 0\n });\n\n const status: PluginStatusProcessing = {\n ...metadata.get(blockId),\n version: PLUGIN_VERSION,\n initialSourceSet,\n initialImageFileURI,\n initialPreviewFileURI,\n blockId,\n fillId,\n status: 'PROCESSING'\n };\n\n metadata.set(blockId, status);\n\n const processedData = await processor.processFill(status);\n // Check for externally changed state while we were applying the mask and\n // do not proceed if the state was reset.\n if (\n metadata.get(blockId).status !== 'PROCESSING' ||\n !metadata.isConsistent(blockId)\n )\n return;\n\n // Check for externally changed state while we were uploading and\n // do not proceed if the state was reset.\n if (\n metadata.get(blockId).status !== 'PROCESSING' ||\n !metadata.isConsistent(blockId)\n )\n return;\n\n if (processedData == null) return;\n\n const metadataStateProcessed: PluginStatusProcessed = {\n version: PLUGIN_VERSION,\n initialSourceSet,\n initialImageFileURI,\n initialPreviewFileURI,\n blockId,\n fillId,\n status: 'PROCESSED'\n };\n\n const blockIdOrVoid = processor.commitProcessing(\n processedData,\n metadataStateProcessed\n );\n\n // If a new block was created, we do not update the metadata.\n if (blockIdOrVoid == null || blockIdOrVoid === blockId) {\n metadata.set(blockId, metadataStateProcessed);\n }\n\n // Finally, create an undo step\n cesdk.engine.editor.addUndoStep();\n } catch (error) {\n if (cesdk.engine.block.isValid(blockId)) {\n metadata.set(blockId, {\n version: PLUGIN_VERSION,\n initialSourceSet,\n initialImageFileURI,\n initialPreviewFileURI,\n blockId,\n fillId,\n status: 'ERROR'\n });\n\n metadata.recoverInitialImageData(blockId);\n }\n\n if (\n error != null &&\n typeof error === 'object' &&\n 'message' in error &&\n typeof error.message === 'string'\n ) {\n const message =\n error.message === 'signal timed out'\n ? 'Processing canceled due to timeout'\n : error.message;\n cesdk.ui.showNotification({\n type: 'error',\n message\n });\n }\n\n // eslint-disable-next-line no-console\n console.log(error);\n } finally {\n if (cesdk.engine.block.isValid(fillId)) {\n cesdk.engine.block.setState(fillId, { type: 'Ready' });\n }\n }\n}\n\nexport default fillProcessing;\n", "export function getFeatureId(pluginId: string): string {\n return `${pluginId}.fillProcessing.feature`;\n}\n\nexport function getCanvasMenuComponentIds(pluginId: string): string[] {\n return [`${pluginId}.canvasMenu`, `${pluginId}.fillProcessing.canvasMenu`];\n}\n\nexport function getDockComponentIds(pluginId: string): string[] {\n return [`${pluginId}.dock`, `${pluginId}.fillProcessing.dock`];\n}\n\nexport function getInspectorBarComponentIds(pluginId: string): string[] {\n return [\n `${pluginId}.inspectorBar`,\n `${pluginId}.fillProcessing.inspectorBar`\n ];\n}\n\nexport function getNavigationBarComponentIds(pluginId: string): string[] {\n return [\n `${pluginId}.navigationBar`,\n `${pluginId}.fillProcessing.navigationBar`\n ];\n}\n\nexport function getCanvasBarComponentIds(pluginId: string): string[] {\n return [`${pluginId}.canvasBar`, `${pluginId}.fillProcessing.canvasBar`];\n}\n\nexport function getI18nCanvasMenuLabel(pluginId: string): string {\n return `plugin.${pluginId}.fillProcessing.canvasMenu.button.label`;\n}\n\nexport function getI18nDockLabel(pluginId: string): string {\n return `plugin.${pluginId}.fillProcessing.dock.button.label`;\n}\n\nexport function getI18nInspectorBarLabel(pluginId: string): string {\n return `plugin.${pluginId}.fillProcessing.inspectorBar.button.label`;\n}\n\nexport function getI18nNavigationBarLabel(pluginId: string): string {\n return `plugin.${pluginId}.fillProcessing.navigationBar.button.label`;\n}\n\nexport function getI18nCanvasBarLabel(pluginId: string): string {\n return `plugin.${pluginId}.fillProcessing.canvasBar.button.label`;\n}\n", "import type CreativeEditorSDK from '@cesdk/cesdk-js';\n\nimport { FillProcessingMetadata } from '..';\nimport { getFeatureId } from './constants';\n\nexport default function handleFillProcessing(\n cesdk: CreativeEditorSDK,\n {\n pluginId,\n process\n }: {\n pluginId: string;\n icon?: string;\n process: (blockId: number, metadata: FillProcessingMetadata) => void;\n }\n): {\n featureId: string;\n} {\n const featureId = getFeatureId(pluginId);\n\n const metadata = new FillProcessingMetadata(cesdk.engine, pluginId);\n\n enableFeatures(cesdk, metadata, featureId);\n\n cesdk.engine.event.subscribe([], async (events) => {\n events.forEach((e) => {\n const id = e.block;\n if (!cesdk.engine.block.isValid(id) || !metadata.hasData(id)) {\n return;\n }\n\n if (e.type === 'Created') {\n if (metadata.isDuplicate(id)) {\n metadata.fixDuplicate(id);\n }\n } else if (e.type === 'Updated') {\n switch (metadata.get(id).status) {\n case 'PENDING': {\n if (\n cesdk.feature.isEnabled(featureId, {\n engine: cesdk.engine\n }) &&\n cesdk.engine.block.isAllowedByScope(id, 'fill/change') &&\n cesdk.engine.block.getState(id).type !== 'Pending'\n ) {\n process(id, metadata);\n }\n break;\n }\n\n case 'PROCESSING':\n case 'PROCESSED': {\n if (!metadata.isConsistent(id)) {\n metadata.clear(id);\n }\n break;\n }\n\n default: {\n // We do not care about other states\n }\n }\n }\n });\n });\n\n return { featureId };\n}\n\n/**\n * Defines the feature that determines in which context (on which block)\n * fill processing is allowed/enabled.\n */\nfunction enableFeatures(\n cesdk: CreativeEditorSDK,\n metadata: FillProcessingMetadata,\n featureId: string\n) {\n cesdk.feature.enable(featureId, ({ engine }) => {\n const selectedIds = engine.block.findAllSelected();\n if (selectedIds.length !== 1) {\n return false;\n }\n const [selectedId] = selectedIds;\n\n if (!cesdk.engine.block.isVisible(selectedId)) return false;\n\n if (cesdk.engine.block.hasFill(selectedId)) {\n const kind = cesdk.engine.block.getKind(selectedId);\n if (kind === 'sticker') return false;\n\n const fillId = cesdk.engine.block.getFill(selectedId);\n const fillType = cesdk.engine.block.getType(fillId);\n\n if (fillType !== '//ly.img.ubq/fill/image') {\n return false;\n }\n\n const fileUri = engine.block.getString(fillId, 'fill/image/imageFileURI');\n const sourceSet = engine.block.getSourceSet(\n fillId,\n 'fill/image/sourceSet'\n );\n\n if (sourceSet.length > 0 || fileUri !== '') return true;\n\n // If we are in a processing state we do not have a imageFileURI or\n // source set set (to show the loading spinner), but the feature is still\n // enabled.\n return metadata.get(selectedId).status === 'PROCESSING';\n }\n\n return false;\n });\n}\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { FillProcessingMetadata } from '..';\nimport {\n getCanvasBarComponentIds,\n getCanvasMenuComponentIds,\n getDockComponentIds,\n getFeatureId,\n getI18nCanvasBarLabel,\n getI18nCanvasMenuLabel,\n getI18nDockLabel,\n getI18nInspectorBarLabel,\n getI18nNavigationBarLabel,\n getInspectorBarComponentIds,\n getNavigationBarComponentIds\n} from './constants';\n\nexport type Location =\n | 'inspectorBar'\n | 'navigationBar'\n | 'canvasBarTop'\n | 'canvasBarBottom'\n | 'canvasMenu'\n | 'dock';\n\n/**\n * Registers the components that can be used to process the fill of\n * a block.\n */\nexport default function registerFillProcessingComponents(\n cesdk: CreativeEditorSDK,\n options: {\n pluginId: string;\n icon?: string;\n locations?: Location | Location[];\n }\n): {\n canvasMenuComponentId: string;\n dockComponentId: string;\n\n translationsKeys: {\n inspectorBarLabel: string;\n navigationBarLabel: string;\n canvasBarLabel: string;\n canvasMenuLabel: string;\n dockLabel: string;\n };\n} {\n const { pluginId, locations } = options;\n const metadata = new FillProcessingMetadata(cesdk.engine, pluginId);\n\n const canvasMenuLabel = getI18nCanvasMenuLabel(pluginId);\n const canvasMenuComponentIds = getCanvasMenuComponentIds(pluginId);\n const canvasMenuComponentId = canvasMenuComponentIds[0];\n\n const dockLabel = getI18nDockLabel(pluginId);\n const dockComponentIds = getDockComponentIds(pluginId);\n const dockComponentId = dockComponentIds[0];\n\n const inspectorBarLabel = getI18nInspectorBarLabel(pluginId);\n const inspectorBarComponentIds = getInspectorBarComponentIds(pluginId);\n const inspectorBarComponentId = inspectorBarComponentIds[0];\n\n const navigationBarLabel = getI18nNavigationBarLabel(pluginId);\n const navigationBarComponentIds = getNavigationBarComponentIds(pluginId);\n const navigationBarComponentId = navigationBarComponentIds[0];\n\n const canvasBarLabel = getI18nCanvasBarLabel(pluginId);\n const canvasBarComponentIds = getCanvasBarComponentIds(pluginId);\n const canvasBarComponentId = canvasBarComponentIds[0];\n\n const featureId = getFeatureId(pluginId);\n\n if (locations?.includes('inspectorBar')) {\n cesdk.ui.setInspectorBarOrder([\n inspectorBarComponentId,\n ...cesdk.ui.getInspectorBarOrder()\n ]);\n }\n\n if (locations?.includes('navigationBar')) {\n cesdk.ui.setNavigationBarOrder([\n navigationBarComponentId,\n ...cesdk.ui.getNavigationBarOrder()\n ]);\n }\n\n if (locations?.includes('canvasBarTop')) {\n cesdk.ui.setCanvasBarOrder(\n [canvasBarComponentId, ...cesdk.ui.getCanvasBarOrder('top')],\n 'top'\n );\n }\n\n if (locations?.includes('canvasBarBottom')) {\n cesdk.ui.setCanvasBarOrder(\n [canvasBarComponentId, ...cesdk.ui.getCanvasBarOrder('bottom')],\n 'bottom'\n );\n }\n\n if (locations?.includes('canvasMenu')) {\n cesdk.ui.setCanvasMenuOrder([\n canvasMenuComponentId,\n ...cesdk.ui.getCanvasMenuOrder()\n ]);\n }\n\n if (locations?.includes('dock')) {\n cesdk.ui.setDockOrder([...cesdk.ui.getDockOrder(), dockComponentId]);\n }\n\n cesdk.ui.registerComponent(\n dockComponentIds,\n ({ builder: { Button }, engine }) => {\n const [id] = engine.block.findAllSelected();\n\n let isDisabled = false;\n let isLoading = false;\n let loadingProgress: number | undefined;\n\n if (id == null) {\n isDisabled = true;\n }\n\n if (\n !isDisabled &&\n !cesdk.feature.isEnabled(featureId, {\n engine\n })\n ) {\n isDisabled = true;\n }\n\n if (\n !isDisabled &&\n !cesdk.engine.block.isAllowedByScope(id, 'fill/change')\n ) {\n isDisabled = true;\n }\n\n if (!isDisabled && engine.block.getState(id)?.type === 'Pending') {\n isDisabled = true;\n }\n\n if (!isDisabled) {\n const currentMetadata = metadata.get(id);\n\n isLoading = currentMetadata.status === 'PROCESSING';\n isDisabled =\n currentMetadata.status === 'PENDING' ||\n currentMetadata.status === 'PROCESSING';\n\n if (\n currentMetadata.status === 'PROCESSING' &&\n currentMetadata.progress\n ) {\n const { current, total } = currentMetadata.progress;\n loadingProgress = (current / total) * 100;\n }\n }\n\n const buttonId = `${dockComponentId}.button`;\n Button(buttonId, {\n label: dockLabel,\n icon: options.icon,\n isLoading,\n isDisabled,\n loadingProgress,\n onClick: () => {\n const currentMetadata = metadata.get(id);\n\n if (\n currentMetadata.status === 'IDLE' ||\n currentMetadata.status === 'ERROR' ||\n currentMetadata.status === 'PROCESSED'\n ) {\n metadata.set(id, {\n status: 'PENDING'\n });\n }\n }\n });\n }\n );\n\n const buttonComponents: {\n componentIds: string[];\n label: string;\n variant: 'plain' | 'regular';\n }[] = [\n {\n componentIds: inspectorBarComponentIds,\n variant: 'plain',\n label: inspectorBarLabel\n },\n {\n componentIds: navigationBarComponentIds,\n variant: 'regular',\n label: navigationBarLabel\n },\n {\n componentIds: canvasBarComponentIds,\n variant: 'regular',\n label: canvasBarLabel\n },\n {\n componentIds: canvasMenuComponentIds,\n variant: 'plain',\n label: canvasMenuLabel\n }\n ];\n\n buttonComponents.forEach(({ componentIds, label, variant }) => {\n const componentId = componentIds[0];\n cesdk.ui.registerComponent(\n componentIds,\n ({ builder: { Button }, engine }) => {\n if (\n !cesdk.feature.isEnabled(featureId, {\n engine\n })\n ) {\n return;\n }\n\n const [id] = engine.block.findAllSelected();\n\n if (!cesdk.engine.block.isAllowedByScope(id, 'fill/change')) return;\n\n const currentMetadata = metadata.get(id);\n\n const isLoading = currentMetadata.status === 'PROCESSING';\n const isDisabled =\n currentMetadata.status === 'PENDING' ||\n currentMetadata.status === 'PROCESSING' ||\n engine.block.getState(id)?.type === 'Pending';\n\n let loadingProgress: number | undefined;\n if (isLoading && currentMetadata.progress) {\n const { current, total } = currentMetadata.progress;\n loadingProgress = (current / total) * 100;\n }\n\n const buttonId = `${componentId}.button`;\n Button(buttonId, {\n icon: options.icon,\n label,\n variant,\n isLoading,\n isDisabled,\n loadingProgress,\n onClick: () => {\n if (\n currentMetadata.status === 'IDLE' ||\n currentMetadata.status === 'ERROR' ||\n currentMetadata.status === 'PROCESSED'\n ) {\n metadata.set(id, {\n status: 'PENDING'\n });\n }\n }\n });\n }\n );\n });\n\n return {\n canvasMenuComponentId,\n dockComponentId,\n translationsKeys: {\n inspectorBarLabel,\n navigationBarLabel,\n canvasBarLabel,\n canvasMenuLabel,\n dockLabel\n }\n };\n}\n", "import { type RGBAColor } from '@cesdk/cesdk-js';\n\nconst HEX_COLOR_PATTERN = new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/, 'i');\nconst HEX_SINGLE_CHAR_COMPONENTS_PATTERN = new RegExp(/[A-Fa-f0-9]{1}/, 'g');\nconst HEX_DOUBLE_CHAR_COMPONENTS_PATTERN = new RegExp(/[A-Fa-f0-9]{2}/, 'g');\n\n/** @public */\nexport const rgbaToHex = (rgba: RGBAColor, includeAlpha = false): string => {\n const { r, g, b, a } = rgba;\n const rByte = Math.round(255 * r);\n const gByte = Math.round(255 * g);\n const bByte = Math.round(255 * b);\n const aByte = Math.round(255 * a);\n const byteToHex = (byte: number) => {\n return byte.toString(16).padStart(2, '0');\n };\n return `#${byteToHex(rByte)}${byteToHex(gByte)}${byteToHex(bByte)}${\n includeAlpha ? byteToHex(aByte) : ''\n }`;\n};\n\n/** @public */\nexport const hexToRgba = (hexString: string): RGBAColor => {\n const rgbaHexToColor = (\n r: string,\n g: string,\n b: string,\n a: string | undefined,\n max: number\n ) => {\n return {\n r: parseInt(r, 16) / max,\n g: parseInt(g, 16) / max,\n b: parseInt(b, 16) / max,\n a: a === undefined ? 1 : parseInt(a, 16) / max\n };\n };\n\n if (hexString.startsWith('#')) {\n if (hexString.length === 4 || hexString.length === 5) {\n const hexMatch = hexString.match(HEX_SINGLE_CHAR_COMPONENTS_PATTERN);\n if (hexMatch) {\n const [r, g, b, a] = hexMatch;\n return rgbaHexToColor(r, g, b, a, 15);\n }\n }\n if (hexString.length === 7 || hexString.length === 8) {\n const hexMatch = hexString.match(HEX_DOUBLE_CHAR_COMPONENTS_PATTERN);\n if (hexMatch) {\n const [r, g, b, a] = hexMatch;\n return rgbaHexToColor(r, g, b, a, 255);\n }\n }\n }\n\n throw new Error(\n 'Invalid hex string! Allowed RGB formats are \"#FFF\" and \"#FFFFFF\". Allowed RGBA formats are \"#FFFF\" and \"#FFFFFFFF'\n );\n};\n\n/** @public */\nexport const isValidHexColor = (hexString: string): boolean => {\n return HEX_COLOR_PATTERN.test(hexString);\n};\n", "import type CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { CreativeEngine } from '@cesdk/cesdk-js';\n\n/**\n * Uploads a blob with the help of CE.SDK\n */\nexport async function uploadBlob(\n blob: Blob,\n initialUri: string,\n cesdk: CreativeEditorSDK\n) {\n const pathname = new URL(initialUri).pathname;\n const parts = pathname.split('/');\n const extension = mimeTypeToExtension(blob.type);\n const filename = parts[parts.length - 1]?.split('.')?.[0] ?? 'asset';\n const filenameWithExtension = `${filename}.${extension}`;\n\n const uploadedAssets = await cesdk.unstable_upload(\n new File([blob], filenameWithExtension, { type: blob.type }),\n () => {\n // TODO Delegate process to UI component\n }\n );\n\n const url = uploadedAssets.meta?.uri;\n if (url == null) {\n throw new Error('Could not upload processed fill');\n }\n return url;\n}\n\n/**\n * Returns the file extension for a given mime type.\n */\nexport function mimeTypeToExtension(mimeType: string): string {\n const extensions: Record<string, string> = {\n 'image/png': 'png',\n 'image/jpeg': 'jpg',\n 'image/webp': 'webp',\n 'image/gif': 'gif',\n 'image/svg+xml': 'svg'\n };\n return extensions[mimeType] ?? 'png';\n}\n\nexport async function fetchImageBlob(uri: string): Promise<Blob> {\n return fetch(uri).then((response) => response.blob());\n}\n\n/**\n * Converts a buffer URI to a object url.\n */\nexport async function bufferURIToObjectURL(\n uri: string,\n engine: CreativeEngine\n): Promise<string> {\n if (uri.startsWith('buffer:')) {\n const mimeType = await engine.editor.getMimeType(uri);\n const length = engine.editor.getBufferLength(uri);\n const data = engine.editor.getBufferData(uri, 0, length);\n const blob = new Blob([data], { type: mimeType });\n return URL.createObjectURL(blob);\n } else {\n return uri;\n }\n}\n", "function uuid4() {\n /* eslint-disable no-bitwise */\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n /* eslint-enable no-bitwise */\n });\n}\n\nexport default uuid4;\n", "import { bufferURIToObjectURL } from './upload';\nimport { type CreativeEngine } from '@cesdk/cesdk-js';\n\n/**\n * Get the dimensions of an image from its URL\n *\n * @param url - The URL of the image\n * @returns A promise that resolves to an object containing the width and height of the image\n */\nexport async function getImageDimensionsFromURL(\n url: string,\n engine: CreativeEngine\n): Promise<{ width: number; height: number }> {\n const resolvedUrl = await bufferURIToObjectURL(url, engine);\n return new Promise((resolve, reject) => {\n const img = new Image();\n img.onload = () => {\n resolve({ width: img.width, height: img.height });\n };\n img.onerror = reject;\n img.src = resolvedUrl;\n });\n}\n\n/**\n * Get the URI of an image from a block ID, either the first source of a source set or\n * the image file URI. Will handle buffer URIs and convert them to object URLs.\n */\nexport async function getImageUri(\n blockId: number,\n engine: CreativeEngine,\n options?: { throwErrorIfSvg?: boolean }\n): Promise<string> {\n let uri;\n const fillBlock = engine.block.getFill(blockId);\n const sourceSet = engine.block.getSourceSet(\n fillBlock,\n 'fill/image/sourceSet'\n );\n const [source] = sourceSet;\n if (source == null) {\n uri = engine.block.getString(fillBlock, 'fill/image/imageFileURI');\n if (uri == null) throw new Error('No image source/uri found');\n } else {\n uri = source.uri;\n }\n\n // Check if the image is SVG (not supported)\n if (options?.throwErrorIfSvg) {\n const mimeType = await engine.editor.getMimeType(uri);\n if (mimeType === 'image/svg+xml') {\n throw new Error('SVG images are not supported');\n }\n }\n\n return bufferURIToObjectURL(uri, engine);\n}\n", "/**\n * Checks if a value is defined (not undefined).\n *\n * Helpful to filter out undefined values from an array or collection\n * while keeping the type information intact.\n *\n * ```\n * array.filter(isDefined)\n * ```\n */\nfunction isDefined<T>(value: T | undefined): value is T {\n return value !== undefined;\n}\n\nexport default isDefined;\n", "import formatsIconSprite from './icons/formats';\n\nconst Icons = {\n Formats: formatsIconSprite\n};\n\nexport { Icons };\n\nexport { CustomAssetSource } from './assetSources/CustomAssetSource';\n\nexport { IndexedDBAssetSource } from './assetSources/IndexedDBAssetSource';\n\nexport { AggregatedAssetSource } from './assetSources/AggregatedAssetSource';\n\nexport { default as Metadata } from './metadata/Metadata';\n\nexport { default as FillProcessingMetadata } from './metadata/FillProcessingMetadata';\n\nexport { default as fillProcessing } from './processing/fillProcessing';\n\nexport { default as initializeFillProcessing } from './processing/initializeFillProcessing';\n\nexport { default as registerFillProcessingComponents } from './processing/registerFillProcessingComponents';\n\nexport { type Optional } from './types/Optional';\n\nexport {\n type Location,\n type UserInterfaceConfiguration\n} from './types/UserInterfaceConfiguration';\n\nexport { hexToRgba, isValidHexColor, rgbaToHex } from './utils/colors';\n\nexport {\n uploadBlob,\n fetchImageBlob,\n bufferURIToObjectURL,\n mimeTypeToExtension\n} from './utils/upload';\n\nexport { default as uuid } from './utils/uuid';\n\nexport { getImageDimensionsFromURL, getImageUri } from './utils/images';\n\nexport { default as isDefined } from './utils/isDefined';\n", "import CreativeEditorSDK, { AssetResult } from '@cesdk/cesdk-js';\nimport { RenderCustomProperty } from '../generation/provider';\nimport { CustomAssetSource, isDefined } from '@imgly/plugin-utils';\nimport { SelectValue } from '@imgly/plugin-utils/dist/assetSources/CustomAssetSource';\n\ntype StyleSelectionPayload = {\n onSelect: (asset: AssetResult) => Promise<void>;\n};\n\ntype Style = {\n id: 'none' | (string & {});\n label: string;\n prompt: string;\n thumbUri: string;\n};\n\n/**\n * Provides render function for a style transfer property that allows\n * to change a style (of an image) from a library.\n *\n * The style will be appended to the prompt property, so the model does\n * not need to support style transfer directly.\n *\n * By default this expects the property key to be `style`. This can be changed with the option\n * `propertyKey`.\n */\nfunction renderStyleTransferProperty(\n providerId: string,\n options: {\n cesdk?: CreativeEditorSDK;\n /**\n * Base URL used for the UI assets used in the plugin.\n */\n baseURL?: string;\n\n /**\n * What property key to use for the style property.\n */\n propertyKey?: string;\n\n /**\n * What property key to use for the prompt property.\n */\n propertyKeyForPrompt?: string;\n\n /**\n * Override the default styles\n */\n styles?: Style[] | ((defaultStyles: Style[]) => Style[]);\n\n /**\n * Overrides the default i18n translations for the prompt input.\n */\n i18n?: {\n prompt?: {\n inputLabel?: string;\n placeholder?: string;\n };\n };\n }\n): RenderCustomProperty {\n const { cesdk } = options;\n if (cesdk == null) return {};\n\n const propertyKey = options.propertyKey ?? 'style';\n const panelIdForStyleSelection = getStyleSelectionPanelId(providerId);\n\n cesdk.i18n.setTranslations({\n en: {\n [`panel.${panelIdForStyleSelection}`]: 'Select Style',\n [`${providerId}.${propertyKey}`]: 'Style'\n }\n });\n\n const defaultStyles = getDefaultStyles({\n baseURL:\n options.baseURL ??\n 'https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/gpt-image-1/',\n includeNone: true\n });\n let styles = defaultStyles;\n if (options.styles != null) {\n if (Array.isArray(options.styles)) {\n styles = options.styles;\n } else if (typeof options.styles === 'function') {\n styles = options.styles(defaultStyles);\n }\n }\n const styleAssetSource = createStyleAssetSource({\n cesdk,\n providerId,\n styles\n });\n const styleAssetSourceId = styleAssetSource.id;\n addStyleAssetSource(styleAssetSource, { cesdk });\n\n createPanels({\n providerId,\n cesdk,\n panelId: panelIdForStyleSelection,\n entryId: styleAssetSourceId\n });\n\n const customProperties: RenderCustomProperty = {\n [options.propertyKeyForPrompt ?? 'prompt']: (context, property) => {\n const promptState = context.state<string>('prompt', '');\n context.builder.TextArea(`${property.id}`, {\n inputLabel:\n options.i18n?.prompt?.inputLabel ??\n options.propertyKeyForPrompt ??\n 'prompt',\n placeholder: options.i18n?.prompt?.placeholder,\n ...promptState\n });\n\n return () => {\n const [activeAssetId] = styleAssetSource.getActiveAssetIds();\n const asset = styleAssetSource.getAsset(activeAssetId);\n return {\n id: property.id,\n type: 'string',\n value:\n asset?.meta?.prompt == null\n ? promptState.value\n : `${promptState.value}; ${asset.meta.prompt}`\n };\n };\n },\n [propertyKey]: (context, property) => {\n const { builder, state } = context;\n\n if (styles.length > 0) {\n const styleState = state<{\n id: string;\n label: string;\n }>('style', styles[0]);\n\n builder.Button(`${property.id}`, {\n inputLabel: `${providerId}.${property.id}`,\n icon: '@imgly/Appearance',\n isDisabled: styles.length === 0,\n trailingIcon: '@imgly/ChevronRight',\n label: styleState.value.label,\n labelAlignment: 'left',\n onClick: () => {\n const payload: StyleSelectionPayload = {\n onSelect: async (asset) => {\n styleAssetSource.clearActiveAssets();\n styleAssetSource.setAssetActive(asset.id);\n styleState.setValue({\n id: asset.id,\n label: asset.label ?? asset.id\n });\n cesdk.ui.closePanel(panelIdForStyleSelection);\n }\n };\n\n cesdk.ui.openPanel(panelIdForStyleSelection, {\n payload\n });\n }\n });\n return () => {\n return {\n id: property.id,\n type: 'string',\n value: styleState.value.id\n };\n };\n }\n\n return () => {\n return {\n id: property.id,\n type: 'string',\n value: 'none'\n };\n };\n }\n };\n\n return customProperties;\n}\n\nfunction createPanels(options: {\n providerId: string;\n panelId: string;\n entryId: string;\n cesdk?: CreativeEditorSDK;\n}) {\n const { providerId, cesdk, panelId, entryId } = options;\n if (cesdk == null) return;\n\n cesdk.ui.registerPanel<{\n onSelect: (assetResult: AssetResult) => void;\n }>(panelId, ({ builder, payload }) => {\n if (payload?.onSelect == null) {\n builder.Section(`${providerId}.error`, {\n children: () => {\n builder.Text('error', {\n content:\n 'No onSelect function provided for the style selection panel.'\n });\n }\n });\n }\n builder.Library(`${providerId}.library.image`, {\n entries: [entryId],\n onSelect: async (asset) => {\n payload?.onSelect?.(asset);\n }\n });\n });\n}\n\nfunction getStyleSelectionPanelId(providerId: string) {\n return `ly.img.ai/${providerId}.styleSelection`;\n}\n\nconst STYLES: Omit<Style, 'thumbUri'>[] = [\n {\n id: 'none',\n label: 'None',\n prompt: ''\n },\n {\n id: 'anime-celshaded',\n label: 'Anime',\n prompt:\n 'anime cel\u2011shaded, bright pastel palette, expressive eyes, clean line art '\n },\n {\n id: 'cyberpunk-neon',\n label: 'Cyberpunk',\n prompt:\n 'cyberpunk cityscape, glowing neon signage, reflective puddles, dark atmosphere'\n },\n {\n id: 'kodak-portra-400',\n label: 'Kodak 400',\n prompt:\n 'shot on Kodak Portra 400, soft grain, golden\u2011hour warmth, 35 mm photo'\n },\n {\n id: 'watercolor-storybook',\n label: 'Watercolor',\n prompt: 'loose watercolor washes, gentle gradients, dreamy storybook feel'\n },\n {\n id: 'dark-fantasy-realism',\n label: 'Dark Fantasy',\n prompt:\n 'dark fantasy realm, moody chiaroscuro lighting, hyper\u2011real textures'\n },\n {\n id: 'vaporwave-retrofuturism',\n label: 'Vaporwave',\n prompt:\n 'retro\u2011futuristic vaporwave, pastel sunset gradient, chrome text, VHS scanlines'\n },\n {\n id: 'minimal-vector-flat',\n label: 'Vector Flat',\n prompt:\n 'minimalist flat vector illustration, bold geometry, two\u2011tone palette'\n },\n {\n id: 'pixarstyle-3d-render',\n label: '3D Animation',\n prompt:\n 'Pixar\u2011style 3D render, oversized eyes, subtle subsurface scattering, cinematic lighting'\n },\n {\n id: 'ukiyoe-woodblock',\n label: 'Ukiyo\u2011e',\n prompt:\n 'ukiyo\u2011e woodblock print, Edo\u2011period style, visible washi texture, limited color ink'\n },\n {\n id: 'surreal-dreamscape',\n label: 'Surreal',\n prompt:\n 'surreal dreamscape, floating objects, impossible architecture, vivid clouds'\n },\n {\n id: 'steampunk-victorian',\n label: 'Steampunk',\n prompt:\n 'Victorian steampunk world, ornate brass gears, leather attire, atmospheric fog'\n },\n {\n id: 'nightstreet-photo-bokeh',\n label: 'Night Bokeh',\n prompt:\n 'night\u2011time street shot, large aperture bokeh lights, candid urban mood'\n },\n {\n id: 'comicbook-pop-art',\n label: 'Pop Art',\n prompt:\n 'classic comic\u2011book panel, halftone shading, exaggerated action lines, CMYK pop colors'\n }\n];\n\nfunction getDefaultStyles(options: {\n baseURL: string;\n includeNone?: boolean;\n}): Style[] {\n return STYLES.map((style) => {\n if (style.id === 'none') {\n if (!options.includeNone) {\n return undefined;\n }\n return {\n ...style,\n thumbUri: `${options.baseURL}/thumbnails/None.svg`\n };\n }\n return {\n ...style,\n thumbUri: `${options.baseURL}/thumbnails/${style.id}.jpeg`\n };\n }).filter(isDefined);\n}\n\nconst createStyleAssetSource = (options: {\n cesdk: CreativeEditorSDK;\n providerId: string;\n styles: Style[];\n}) => {\n const styleValues: SelectValue[] = options.styles.map((style) => {\n return {\n ...style,\n meta: { prompt: style.prompt }\n };\n });\n\n const allSourceIds = options.cesdk.engine.asset.findAllSources();\n let assetSourceId = `${options.providerId}/styles`;\n while (allSourceIds.includes(assetSourceId)) {\n assetSourceId += `-${Math.random().toString(36).substring(2, 5)}`;\n }\n const styleAssetSource = new CustomAssetSource(assetSourceId, styleValues);\n\n const defaultStyle = options.styles[0];\n styleAssetSource.setAssetActive(defaultStyle.id);\n\n return styleAssetSource;\n};\n\nconst addStyleAssetSource = (\n styleAssetSource: CustomAssetSource,\n options: {\n cesdk: CreativeEditorSDK;\n }\n) => {\n options.cesdk.engine.asset.addSource(styleAssetSource);\n options.cesdk.ui.addAssetLibraryEntry({\n id: styleAssetSource.id,\n sourceIds: [styleAssetSource.id],\n gridItemHeight: 'square',\n gridBackgroundType: 'cover',\n cardLabel: ({ label }) => label,\n cardLabelPosition: () => 'below'\n });\n};\n\nexport default renderStyleTransferProperty;\n", "import { type OpenAPIV3 } from 'openapi-types';\n\n/**\n * Resolves a JSON reference path within a document\n * @param document The OpenAPI document\n * @param refPath The reference path (e.g. \"#/components/schemas/MySchema\")\n * @returns The resolved object from the document\n */\nexport function resolveReference(\n document: OpenAPIV3.Document,\n refPath: string\n): unknown {\n // Only handle internal references\n if (!refPath.startsWith('#/')) {\n throw new Error(`External references are not supported: ${refPath}`);\n }\n\n // Remove the leading #/\n const path = refPath.substring(2).split('/');\n let current: any = document;\n\n // Navigate through the path\n for (const segment of path) {\n if (current === undefined || current === null) {\n throw new Error(`Invalid reference path: ${refPath}`);\n }\n current = current[segment];\n }\n\n if (current === undefined) {\n throw new Error(`Reference not found: ${refPath}`);\n }\n\n return current;\n}\n\n/**\n * Recursively dereferences all $ref properties in an object\n * @param document The original document for resolving references\n * @param obj The object to dereference\n * @param visited Set of visited objects to prevent circular references\n * @returns The dereferenced object\n */\nfunction dereferenceObject(\n document: OpenAPIV3.Document,\n obj: any,\n visited = new Set<any>()\n): any {\n // Handle null or undefined\n if (obj === null || obj === undefined) {\n return obj;\n }\n\n // If we've seen this object before, return it to avoid circular references\n if (visited.has(obj)) {\n return obj;\n }\n\n // Add the current object to the visited set\n visited.add(obj);\n\n // Handle $ref\n if (obj.$ref && typeof obj.$ref === 'string') {\n // Get the referenced object\n const referenced = resolveReference(document, obj.$ref);\n // Dereference the referenced object\n const dereferenced = dereferenceObject(document, referenced, visited);\n\n // Merge other properties from the original object\n const result = { ...dereferenced };\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key) && key !== '$ref') {\n result[key] = dereferenceObject(document, obj[key], visited);\n }\n }\n return result;\n }\n\n // Handle arrays\n if (Array.isArray(obj)) {\n return obj.map((item) => dereferenceObject(document, item, visited));\n }\n\n // Handle objects\n if (typeof obj === 'object') {\n const result: any = {};\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n result[key] = dereferenceObject(document, obj[key], visited);\n }\n }\n return result;\n }\n\n // Return primitives as is\n return obj;\n}\n\n/**\n * Dereferences all $ref properties in an OpenAPI document\n * @param document The OpenAPI document to dereference\n * @returns A new document with all references resolved\n */\nexport default function dereferenceDocument(\n document: OpenAPIV3.Document\n): OpenAPIV3.Document {\n return dereferenceObject(document, { ...document }) as OpenAPIV3.Document;\n}\n", "import { OpenAPIV3 } from 'openapi-types';\n\n/**\n * Checks if an unknown object is an OpenAPI schema (first level only)\n *\n * @param obj - The object to check (potentially undefined)\n * @param debug - If true, log the reason when validation fails\n * @returns A boolean indicating whether the object is an OpenAPI schema\n */\nexport function isOpenAPISchema(\n obj: unknown,\n debug: boolean = false\n): obj is OpenAPIV3.SchemaObject {\n // Helper function to log debug messages and return false\n const fail = (reason: string): false => {\n if (debug) {\n // eslint-disable-next-line no-console\n console.log(`OpenAPI Schema validation failed: ${reason}`);\n }\n return false;\n };\n\n // Check if obj is an object and not null\n if (typeof obj !== 'object' || obj === null) {\n return fail(\n `Input is ${obj === null ? 'null' : typeof obj}, not an object`\n );\n }\n\n const schema = obj as Record<string, any>;\n\n // Basic property validation - most schemas have at least one of these properties\n const hasSchemaTypeProperties =\n typeof schema.type === 'string' ||\n Array.isArray(schema.enum) ||\n typeof schema.properties === 'object' ||\n typeof schema.items === 'object' ||\n typeof schema.allOf === 'object' ||\n typeof schema.anyOf === 'object' ||\n typeof schema.oneOf === 'object' ||\n typeof schema.not === 'object';\n\n if (!hasSchemaTypeProperties) {\n return fail(\n 'Missing required schema-defining properties (type, enum, properties, items, allOf, anyOf, oneOf, not)'\n );\n }\n\n // If it has a type, validate it's one of the allowed OpenAPI schema types\n if (schema.type !== undefined) {\n const validTypes = [\n 'string',\n 'number',\n 'integer',\n 'boolean',\n 'array',\n 'object',\n 'null'\n ];\n\n // Type can be a string or an array of strings\n if (typeof schema.type === 'string') {\n if (!validTypes.includes(schema.type)) {\n return fail(\n `Invalid type: ${schema.type}. Must be one of ${validTypes.join(\n ', '\n )}`\n );\n }\n } else if (Array.isArray(schema.type)) {\n for (const type of schema.type) {\n if (typeof type !== 'string' || !validTypes.includes(type)) {\n return fail(\n `Array of types contains invalid value: ${type}. Must be one of ${validTypes.join(\n ', '\n )}`\n );\n }\n }\n } else {\n return fail(\n `Type must be a string or array of strings, got ${typeof schema.type}`\n );\n }\n }\n\n // If it has items (for array type), validate that items is an object (without recursion)\n if (schema.items !== undefined) {\n if (typeof schema.items !== 'object' || schema.items === null) {\n return fail(\n `Items must be an object, got ${\n schema.items === null ? 'null' : typeof schema.items\n }`\n );\n }\n }\n\n // If it has properties (for object type), validate that properties is an object (without recursion)\n if (schema.properties !== undefined) {\n if (typeof schema.properties !== 'object' || schema.properties === null) {\n return fail(\n `Properties must be an object, got ${\n schema.properties === null ? 'null' : typeof schema.properties\n }`\n );\n }\n }\n\n // Check if advanced schema constructs are valid (without recursion)\n const schemaArrays = ['allOf', 'anyOf', 'oneOf'];\n for (const arrayType of schemaArrays) {\n if (schema[arrayType] !== undefined) {\n if (!Array.isArray(schema[arrayType])) {\n return fail(\n `${arrayType} must be an array, got ${typeof schema[arrayType]}`\n );\n }\n\n // Just check that each item is an object (without recursion)\n for (let i = 0; i < schema[arrayType].length; i++) {\n const subSchema = schema[arrayType][i];\n if (typeof subSchema !== 'object' || subSchema === null) {\n return fail(\n `Item ${i} in ${arrayType} must be an object, got ${\n subSchema === null ? 'null' : typeof subSchema\n }`\n );\n }\n }\n }\n }\n\n // Check if 'not' is an object\n if (schema.not !== undefined) {\n if (typeof schema.not !== 'object' || schema.not === null) {\n return fail(\n `'not' must be an object, got ${\n schema.not === null ? 'null' : typeof schema.not\n }`\n );\n }\n }\n\n // If we have additionalProperties, make sure it's a boolean or an object\n if (schema.additionalProperties !== undefined) {\n if (\n typeof schema.additionalProperties !== 'boolean' &&\n (typeof schema.additionalProperties !== 'object' ||\n schema.additionalProperties === null)\n ) {\n return fail(\n `additionalProperties must be a boolean or an object, got ${\n schema.additionalProperties === null\n ? 'null'\n : typeof schema.additionalProperties\n }`\n );\n }\n }\n\n // Check basic format if present (for string type)\n if (schema.format !== undefined && typeof schema.format !== 'string') {\n return fail(`format must be a string, got ${typeof schema.format}`);\n }\n\n // Check number constraints\n const numberConstraints = [\n 'minimum',\n 'maximum',\n 'exclusiveMinimum',\n 'exclusiveMaximum',\n 'multipleOf'\n ];\n for (const constraint of numberConstraints) {\n if (\n schema[constraint] !== undefined &&\n typeof schema[constraint] !== 'number'\n ) {\n return fail(\n `${constraint} must be a number, got ${typeof schema[constraint]}`\n );\n }\n }\n\n // Check string constraints\n if (\n schema.minLength !== undefined &&\n (typeof schema.minLength !== 'number' || schema.minLength < 0)\n ) {\n return fail(\n `minLength must be a non-negative number, got ${\n typeof schema.minLength === 'number'\n ? schema.minLength\n : typeof schema.minLength\n }`\n );\n }\n if (\n schema.maxLength !== undefined &&\n (typeof schema.maxLength !== 'number' || schema.maxLength < 0)\n ) {\n return fail(\n `maxLength must be a non-negative number, got ${\n typeof schema.maxLength === 'number'\n ? schema.maxLength\n : typeof schema.maxLength\n }`\n );\n }\n if (schema.pattern !== undefined && typeof schema.pattern !== 'string') {\n return fail(`pattern must be a string, got ${typeof schema.pattern}`);\n }\n\n // Check array constraints\n if (\n schema.minItems !== undefined &&\n (typeof schema.minItems !== 'number' || schema.minItems < 0)\n ) {\n return fail(\n `minItems must be a non-negative number, got ${\n typeof schema.minItems === 'number'\n ? schema.minItems\n : typeof schema.minItems\n }`\n );\n }\n if (\n schema.maxItems !== undefined &&\n (typeof schema.maxItems !== 'number' || schema.maxItems < 0)\n ) {\n return fail(\n `maxItems must be a non-negative number, got ${\n typeof schema.maxItems === 'number'\n ? schema.maxItems\n : typeof schema.maxItems\n }`\n );\n }\n if (\n schema.uniqueItems !== undefined &&\n typeof schema.uniqueItems !== 'boolean'\n ) {\n return fail(\n `uniqueItems must be a boolean, got ${typeof schema.uniqueItems}`\n );\n }\n\n // Check object constraints\n if (\n schema.minProperties !== undefined &&\n (typeof schema.minProperties !== 'number' || schema.minProperties < 0)\n ) {\n return fail(\n `minProperties must be a non-negative number, got ${\n typeof schema.minProperties === 'number'\n ? schema.minProperties\n : typeof schema.minProperties\n }`\n );\n }\n if (\n schema.maxProperties !== undefined &&\n (typeof schema.maxProperties !== 'number' || schema.maxProperties < 0)\n ) {\n return fail(\n `maxProperties must be a non-negative number, got ${\n typeof schema.maxProperties === 'number'\n ? schema.maxProperties\n : typeof schema.maxProperties\n }`\n );\n }\n if (schema.required !== undefined) {\n if (!Array.isArray(schema.required)) {\n return fail(`required must be an array, got ${typeof schema.required}`);\n }\n for (let i = 0; i < schema.required.length; i++) {\n const prop = schema.required[i];\n if (typeof prop !== 'string') {\n return fail(\n `Item ${i} in required array must be a string, got ${typeof prop}`\n );\n }\n }\n }\n\n // It has passed all the first-level checks\n return true;\n}\n", "import { OpenAPIV3 } from 'openapi-types';\nimport { OutputKind, PanelInputSchema } from '../provider';\nimport { Property } from './types';\n\nfunction getProperties<K extends OutputKind, I>(\n inputSchema: OpenAPIV3.SchemaObject,\n panelInput: PanelInputSchema<K, I>\n): Property[] {\n if (inputSchema.properties == null) {\n throw new Error('Input schema must have properties');\n }\n const propertiesFromSchema = inputSchema.properties;\n const properties: Property[] = [];\n\n const order = getOrder(inputSchema, panelInput);\n order.forEach((propertyKey) => {\n const id = propertyKey;\n const schema =\n (propertiesFromSchema[propertyKey] as OpenAPIV3.SchemaObject) ??\n undefined;\n properties.push({ id, schema });\n });\n\n return properties;\n}\n\nfunction getOrder<K extends OutputKind, I>(\n inputSchema: OpenAPIV3.SchemaObject,\n panelInput: PanelInputSchema<K, I>\n): string[] {\n const panelInputOrder = panelInput.order;\n if (panelInputOrder != null && Array.isArray(panelInputOrder)) {\n return panelInputOrder;\n }\n\n if (inputSchema.properties == null) {\n throw new Error('Input schema must have properties');\n }\n const propertiesFromSchema = inputSchema.properties;\n const orderFromKeys = Object.keys(propertiesFromSchema);\n const orderFromExtensionKeyword = getOrderFromExtensionKeyword(\n inputSchema,\n panelInput\n );\n\n let order = orderFromExtensionKeyword ?? orderFromKeys;\n\n if (panelInputOrder != null && typeof panelInputOrder === 'function') {\n order = panelInputOrder(order);\n }\n\n // Return order with no duplicates\n return [...new Set(order)];\n}\n\n/**\n * Get the order from an extension keyword in the input schema (e.g. x-order) if it exists.\n */\nfunction getOrderFromExtensionKeyword<K extends OutputKind, I>(\n inputSchema: OpenAPIV3.SchemaObject,\n panelInput: PanelInputSchema<K, I>\n): string[] | undefined {\n if (panelInput.orderExtensionKeyword == null) {\n return undefined;\n }\n\n if (\n typeof panelInput.orderExtensionKeyword !== 'string' &&\n !Array.isArray(panelInput.orderExtensionKeyword)\n ) {\n throw new Error(\n 'orderExtensionKeyword must be a string or an array of strings'\n );\n }\n const orderExtensionKeywords =\n typeof panelInput.orderExtensionKeyword === 'string'\n ? [panelInput.orderExtensionKeyword]\n : panelInput.orderExtensionKeyword;\n\n const orderExtensionKeyword = orderExtensionKeywords.find(\n (extensionKeyword) => {\n return extensionKeyword in inputSchema;\n }\n );\n\n if (orderExtensionKeyword == null) {\n return undefined;\n }\n const order =\n // @ts-ignore\n inputSchema[orderExtensionKeyword] as string[];\n\n return order;\n}\n\nexport default getProperties;\n", "import CreativeEditorSDK, { AssetResult } from '@cesdk/cesdk-js';\nimport { GenerationResult, Output } from './generation/provider';\n\nexport const AI_PANEL_ID_PREFIX = 'ly.img.ai';\n\nconst TEMP_ASSET_SOURCE_ID = 'ly.img.ai/temp';\n\n/**\n * Adding asset to the scene.\n *\n * NOTE: Will use a temporary asset source so that\n * our asset source middleware trigger. This is necessary since there is\n * a lot of extra logic in the video middlewares regarding trim, position etc.\n *\n * These will only trigger via an asset source, not by calling\n * `defaultApplyAsset` directly.\n */\nexport async function addAssetToScene(\n cesdk: CreativeEditorSDK,\n assetResult: AssetResult\n) {\n if (!cesdk.engine.asset.findAllSources().includes(TEMP_ASSET_SOURCE_ID)) {\n cesdk.engine.asset.addLocalSource(TEMP_ASSET_SOURCE_ID);\n }\n\n return cesdk.engine.asset.apply(TEMP_ASSET_SOURCE_ID, assetResult);\n}\n\n/**\n * Returns a consistent panel ID for a provider ID\n */\nexport function getPanelId(providerId: string): string {\n return `${AI_PANEL_ID_PREFIX}/${providerId}`;\n}\n\nexport default getPanelId;\n/**\n * Extracts a readable error message from an unknown error\n *\n * @param error The error caught in a try/catch block\n * @param fallbackMessage Optional fallback message if error is not an Error object\n * @returns A string representation of the error\n */\nexport function extractErrorMessage(\n error: unknown,\n fallbackMessage = 'We encountered an unknown error while generating the asset. Please try again.'\n): string {\n if (error === null) {\n return fallbackMessage;\n }\n\n if (error instanceof Error) {\n return error.message;\n }\n\n if (typeof error === 'object') {\n // Try to get message property if it exists\n const errorObj = error as Record<string, unknown>;\n if ('message' in errorObj && typeof errorObj.message === 'string') {\n return errorObj.message;\n }\n if ('cause' in errorObj && typeof errorObj.cause === 'string') {\n return errorObj.cause;\n }\n\n /*\n * Elevenlabs for instance uses the following structure for errors:\n * {\n * \"detail\": {\n * \"status\": \"error_code\",\n * \"message\": \"Explanation of the rate limit issue.\"\n * }\n * }\n */\n if (\n 'detail' in errorObj &&\n typeof errorObj.detail === 'object' &&\n errorObj.detail !== null &&\n 'message' in errorObj.detail &&\n typeof errorObj.detail.message === 'string'\n ) {\n return errorObj.detail.message;\n }\n\n /*\n * Used by e.g. Anthropic\n */\n if (\n 'error' in errorObj &&\n typeof errorObj.error === 'object' &&\n errorObj.error !== null &&\n 'message' in errorObj.error &&\n typeof errorObj.error.message === 'string'\n ) {\n return errorObj.error.message;\n }\n\n return fallbackMessage;\n }\n\n if (typeof error === 'string') {\n return error;\n }\n\n // For any other type, convert to string\n return String(error) || fallbackMessage;\n}\n\n/**\n * Generates a random UUID v4\n */\nexport function uuid4() {\n /* eslint-disable no-bitwise */\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n /* eslint-enable no-bitwise */\n });\n}\n\n/**\n * Gets the duration of a video from a URL\n * @param url - The URL of the video\n * @returns A promise that resolves to the duration of the video in seconds\n */\nexport function getDurationForVideo(url: string): Promise<number> {\n return new Promise((resolve, reject) => {\n try {\n const video = document.createElement('video');\n video.style.display = 'none';\n\n // Set up event handlers\n video.addEventListener('loadedmetadata', () => {\n if (video.duration === Infinity) {\n // Some videos might initially report Infinity\n video.currentTime = 1e101;\n // Wait for currentTime to update\n setTimeout(() => {\n video.currentTime = 0;\n resolve(video.duration);\n document.body.removeChild(video);\n }, 50);\n } else {\n resolve(video.duration);\n document.body.removeChild(video);\n }\n });\n\n video.addEventListener('error', () => {\n document.body.removeChild(video);\n reject(new Error(`Failed to load video from ${url}`));\n });\n\n // Set source and begin loading\n video.src = url;\n document.body.appendChild(video);\n } catch (error) {\n reject(error);\n }\n });\n}\n\n/**\n * Gets a thumbnail image from a video URL\n * @param url - The URL of the video\n * @param seekTime - Time in seconds to capture the thumbnail (default: 0)\n * @param format - Image format for the thumbnail (default: 'image/jpeg')\n * @param quality - Image quality between 0 and 1 (default: 0.8)\n * @returns A promise that resolves to the thumbnail data URL\n */\nexport function getThumbnailForVideo(\n url: string,\n seekTime = 0,\n format = 'image/jpeg',\n quality = 0.8\n): Promise<string> {\n return new Promise((resolve, reject) => {\n try {\n const video = document.createElement('video');\n // Set crossOrigin to anonymous to prevent tainted canvas issues\n video.crossOrigin = 'anonymous';\n video.style.display = 'none';\n\n // Set up event handlers\n video.addEventListener('loadedmetadata', () => {\n // Seek to the specified time\n video.currentTime = Math.min(seekTime, video.duration);\n\n video.addEventListener(\n 'seeked',\n () => {\n // Create a canvas to draw the video frame\n const canvas = document.createElement('canvas');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n\n // Draw the video frame to the canvas\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n document.body.removeChild(video);\n reject(new Error('Failed to create canvas context'));\n return;\n }\n\n ctx.drawImage(video, 0, 0, canvas.width, canvas.height);\n\n try {\n // Convert canvas to data URL\n const dataURL = canvas.toDataURL(format, quality);\n // Clean up\n document.body.removeChild(video);\n resolve(dataURL);\n } catch (e) {\n document.body.removeChild(video);\n reject(\n new Error(\n `Failed to create thumbnail: ${\n e instanceof Error ? e.message : String(e)\n }`\n )\n );\n }\n },\n { once: true }\n );\n });\n\n video.addEventListener('error', () => {\n document.body.removeChild(video);\n reject(new Error(`Failed to load video from ${url}`));\n });\n\n // Set source and begin loading\n video.src = url;\n document.body.appendChild(video);\n } catch (error) {\n reject(error);\n }\n });\n}\n\n/**\n * Converts an ID string to a human-readable label\n * @param id - The ID string to convert\n * @returns A human-readable label derived from the ID\n *\n * Examples:\n * - snake_case_id \u2192 Snake Case Id\n * - kebab-case-id \u2192 Kebab Case Id\n * - camelCaseId \u2192 Camel Case Id\n * - PascalCaseId \u2192 Pascal Case Id\n */\nexport function getLabelFromId(id: string): string {\n if (!id) return '';\n\n // Handle snake_case, kebab-case, camelCase, and PascalCase\n return (\n id\n // Replace underscores and hyphens with spaces (for snake_case and kebab-case)\n .replace(/[_-]/g, ' ')\n // Add spaces before uppercase letters (for camelCase and PascalCase)\n .replace(/([A-Z])/g, ' $1')\n // Trim any extra spaces and ensure first letter is capitalized\n .trim()\n .split(' ')\n .filter((word) => word.length > 0) // Remove empty strings from multiple spaces\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(' ')\n );\n}\n\n/**\n * Type guard to check if a value is an AsyncGenerator rather than a Promise\n *\n * @param value - Value of type Promise<O> | AsyncGenerator<O, C>\n * @returns Boolean indicating if the value is an AsyncGenerator\n */\nexport function isAsyncGenerator<O extends Output, C>(\n value: GenerationResult<O, C>\n): value is AsyncGenerator<O, C> {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'next' in value &&\n 'return' in value &&\n 'throw' in value &&\n typeof value.next === 'function' &&\n typeof value.return === 'function' &&\n typeof value.throw === 'function' &&\n Symbol.asyncIterator in value &&\n typeof value[Symbol.asyncIterator] === 'function'\n );\n}\n\nexport function isAbortError(error: unknown): error is Error {\n return error instanceof Error && error.name === 'AbortError';\n}\n", "/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { BuilderRenderFunctionContext } from '@cesdk/cesdk-js';\nimport {\n EnumValue,\n ExtensionImglyBuilder,\n GetPropertyInput,\n Property,\n PropertyInput\n} from './types';\nimport Provider, { Output, OutputKind, PanelInputSchema } from '../provider';\nimport { InitProviderConfiguration, UIOptions } from '../types';\nimport { OpenAPIV3 } from 'openapi-types';\nimport getProperties from './getProperties';\nimport { getLabelFromId } from '../../utils';\n\nfunction renderProperty<K extends OutputKind, I, O extends Output>(\n context: BuilderRenderFunctionContext<any>,\n property: Property,\n provider: Provider<K, I, O>,\n panelInput: PanelInputSchema<K, I>,\n options: UIOptions,\n config: InitProviderConfiguration\n): GetPropertyInput | undefined {\n if (property.schema == null) {\n if (\n panelInput.renderCustomProperty != null &&\n panelInput.renderCustomProperty[property.id] != null\n ) {\n return panelInput.renderCustomProperty[property.id](context, property);\n } else {\n return undefined;\n }\n }\n const propertyWithSchema: Required<Property> = property as Required<Property>;\n const type = property.schema.type;\n\n if (\n panelInput.renderCustomProperty != null &&\n panelInput.renderCustomProperty[property.id] != null\n ) {\n return panelInput.renderCustomProperty[property.id](context, property);\n }\n\n switch (type) {\n case 'string': {\n if (property.schema.enum != null) {\n return renderEnumProperty(\n context,\n propertyWithSchema,\n provider,\n panelInput,\n options,\n config\n );\n } else {\n return renderStringProperty(\n context,\n propertyWithSchema,\n provider,\n panelInput,\n options,\n config\n );\n }\n }\n\n case 'boolean': {\n return renderBooleanProperty(\n context,\n propertyWithSchema,\n provider,\n panelInput,\n options,\n config\n );\n }\n\n case 'number':\n case 'integer': {\n return renderIntegerProperty(\n context,\n propertyWithSchema,\n provider,\n panelInput,\n options,\n config\n );\n }\n\n case 'object': {\n return renderObjectProperty(\n context,\n propertyWithSchema,\n provider,\n panelInput,\n options,\n config\n );\n }\n\n case 'array': {\n // not supported yet\n break;\n }\n\n case undefined: {\n if (\n property.schema.anyOf != null &&\n Array.isArray(property.schema.anyOf)\n ) {\n return renderAnyOfProperty(\n context,\n propertyWithSchema,\n provider,\n panelInput,\n options,\n config\n );\n }\n break;\n }\n\n default: {\n // eslint-disable-next-line no-console\n console.error(`Unsupported property type: ${type}`);\n }\n }\n}\n\nfunction renderObjectProperty<K extends OutputKind, I, O extends Output>(\n context: BuilderRenderFunctionContext<any>,\n property: Required<Property>,\n provider: Provider<K, I, O>,\n panelInput: PanelInputSchema<K, I>,\n options: UIOptions,\n config: InitProviderConfiguration\n): GetPropertyInput {\n const properties = getProperties(property.schema ?? {}, panelInput);\n\n const childInputs = properties.reduce((acc, childProperty) => {\n const getInput = renderProperty(\n context,\n childProperty,\n provider,\n panelInput,\n options,\n config\n );\n if (getInput != null) {\n acc[childProperty.id] = getInput();\n }\n return acc;\n }, {} as Record<string, PropertyInput>);\n\n return () => ({\n id: property.id,\n type: 'object',\n value: childInputs\n });\n}\n\nfunction renderStringProperty<K extends OutputKind, I, O extends Output>(\n context: BuilderRenderFunctionContext<any>,\n property: Required<Property>,\n provider: Provider<K, I, O>,\n panelInput: PanelInputSchema<K, I>,\n options: UIOptions,\n config: InitProviderConfiguration\n): GetPropertyInput {\n const {\n builder,\n experimental: { global }\n } = context;\n const { id: propertyId } = property;\n\n const id = `${provider.id}.${propertyId}`;\n const inputLabel = property.schema.title ?? id;\n\n const propertyState = global(id, property.schema.default ?? '');\n\n const extension = getImglyExtensionBuilder(property.schema);\n const builderComponent =\n extension?.component != null && extension?.component === 'TextArea'\n ? 'TextArea'\n : 'TextInput';\n\n builder[builderComponent](id, {\n inputLabel,\n placeholder: options.i18n?.prompt,\n ...propertyState\n });\n\n return () => ({\n id: property.id,\n type: 'string',\n value: propertyState.value\n });\n}\n\nfunction renderEnumProperty<K extends OutputKind, I, O extends Output>(\n context: BuilderRenderFunctionContext<any>,\n property: Required<Property>,\n provider: Provider<K, I, O>,\n panelInput: PanelInputSchema<K, I>,\n options: UIOptions,\n config: InitProviderConfiguration\n): GetPropertyInput {\n const {\n builder,\n experimental: { global }\n } = context;\n const { id: propertyId } = property;\n\n const id = `${provider.id}.${propertyId}`;\n const inputLabel = property.schema.title ?? id;\n\n const labels: Record<string, string> =\n property.schema.enum != null &&\n 'x-imgly-enum-labels' in property.schema.enum &&\n typeof property.schema.enum['x-imgly-enum-labels'] === 'object'\n ? (property.schema.enum['x-imgly-enum-labels'] as Record<string, string>)\n : 'x-imgly-enum-labels' in property.schema &&\n typeof property.schema['x-imgly-enum-labels'] === 'object'\n ? (property.schema['x-imgly-enum-labels'] as Record<string, string>)\n : {};\n\n const icons: Record<string, string> =\n 'x-imgly-enum-icons' in property.schema &&\n typeof property.schema['x-imgly-enum-icons'] === 'object'\n ? (property.schema['x-imgly-enum-icons'] as Record<string, string>)\n : {};\n\n const values: EnumValue[] = (property.schema.enum ?? []).map((valueId) => ({\n id: valueId,\n label: labels[valueId] ?? getLabelFromId(valueId),\n icon: icons[valueId]\n }));\n const defaultValue =\n property.schema.default != null\n ? values.find((v) => v.id === property.schema.default) ?? values[0]\n : values[0];\n\n const propertyState = global<EnumValue>(id, defaultValue);\n\n builder.Select(id, {\n inputLabel,\n values,\n ...propertyState\n });\n\n return () => ({\n id: property.id,\n type: 'string',\n value: propertyState.value.id\n });\n}\n\nfunction renderBooleanProperty<K extends OutputKind, I, O extends Output>(\n context: BuilderRenderFunctionContext<any>,\n property: Required<Property>,\n provider: Provider<K, I, O>,\n panelInput: PanelInputSchema<K, I>,\n options: UIOptions,\n config: InitProviderConfiguration\n): GetPropertyInput {\n const {\n builder,\n experimental: { global }\n } = context;\n const { id: propertyId } = property;\n\n const id = `${provider.id}.${propertyId}`;\n const inputLabel = property.schema.title ?? id;\n\n const defaultValue = !!property.schema.default;\n const propertyState = global<boolean>(id, defaultValue);\n\n builder.Checkbox(id, {\n inputLabel,\n ...propertyState\n });\n\n return () => ({\n id: property.id,\n type: 'boolean',\n value: propertyState.value\n });\n}\n\nfunction renderIntegerProperty<K extends OutputKind, I, O extends Output>(\n context: BuilderRenderFunctionContext<any>,\n property: Required<Property>,\n provider: Provider<K, I, O>,\n panelInput: PanelInputSchema<K, I>,\n options: UIOptions,\n config: InitProviderConfiguration\n): GetPropertyInput {\n const {\n builder,\n experimental: { global }\n } = context;\n const { id: propertyId } = property;\n\n const id = `${provider.id}.${propertyId}`;\n const inputLabel = property.schema.title ?? id;\n\n const minValue = property.schema.minimum;\n const maxValue = property.schema.maximum;\n\n let defaultValue = property.schema.default;\n if (defaultValue == null) {\n if (minValue != null) {\n defaultValue = minValue;\n } else if (maxValue != null) {\n defaultValue = maxValue;\n } else {\n defaultValue = 0;\n }\n }\n\n const propertyState = global<number>(id, defaultValue);\n\n if (minValue != null && maxValue != null) {\n let step = property.schema.type === 'number' ? 0.1 : 1;\n if (\n 'x-imgly-step' in property.schema &&\n typeof property.schema['x-imgly-step'] === 'number'\n ) {\n step = property.schema['x-imgly-step'];\n }\n\n builder.Slider(id, {\n inputLabel,\n min: minValue,\n max: maxValue,\n step,\n ...propertyState\n });\n } else {\n builder.NumberInput(id, {\n inputLabel,\n min: minValue,\n max: maxValue,\n ...propertyState\n });\n }\n\n return () => ({\n id: property.id,\n type: 'integer',\n value: propertyState.value\n });\n}\n\nfunction renderAnyOfProperty<K extends OutputKind, I, O extends Output>(\n context: BuilderRenderFunctionContext<any>,\n property: Required<Property>,\n provider: Provider<K, I, O>,\n panelInput: PanelInputSchema<K, I>,\n options: UIOptions,\n config: InitProviderConfiguration\n): GetPropertyInput | undefined {\n const {\n builder,\n experimental: { global }\n } = context;\n const { id: propertyId } = property;\n\n const id = `${provider.id}.${propertyId}`;\n const inputLabel = property.schema.title ?? id;\n\n const anyOf = (property.schema.anyOf ?? []) as OpenAPIV3.SchemaObject[];\n\n const values: EnumValue[] = [];\n\n const conditionalRender: Record<string, () => GetPropertyInput> = {};\n const conditionalInputs: Record<string, () => PropertyInput> = {};\n\n anyOf.forEach((anySchema, index) => {\n const label = anySchema.title ?? 'common.custom';\n const schemaId = `${provider.id}.${propertyId}.anyOf[${index}]`;\n\n const labels: Record<string, string> =\n 'x-imgly-enum-labels' in property.schema &&\n typeof property.schema['x-imgly-enum-labels'] === 'object'\n ? (property.schema['x-imgly-enum-labels'] as Record<string, string>)\n : {};\n\n const icons: Record<string, string> =\n 'x-imgly-enum-icons' in property.schema &&\n typeof property.schema['x-imgly-enum-icons'] === 'object'\n ? (property.schema['x-imgly-enum-icons'] as Record<string, string>)\n : {};\n\n if (anySchema.type === 'string') {\n if (anySchema.enum != null) {\n anySchema.enum.forEach((valueId) => {\n values.push({\n id: valueId,\n label: labels[valueId] ?? getLabelFromId(valueId),\n icon: icons[valueId]\n });\n });\n } else {\n conditionalRender[schemaId] = () => {\n return renderStringProperty(\n context,\n { id: schemaId, schema: { ...anySchema, title: label } },\n provider,\n panelInput,\n options,\n config\n );\n };\n\n values.push({\n id: schemaId,\n label: labels[label] ?? label,\n icon: icons[label]\n });\n }\n } else if (anySchema.type === 'boolean') {\n conditionalRender[schemaId] = () => {\n return renderBooleanProperty(\n context,\n { id: schemaId, schema: { ...anySchema, title: label } },\n provider,\n panelInput,\n options,\n config\n );\n };\n\n values.push({\n id: schemaId,\n label: labels[label] ?? label,\n icon: icons[label]\n });\n } else if (anySchema.type === 'integer') {\n conditionalRender[schemaId] = () => {\n return renderIntegerProperty(\n context,\n { id: schemaId, schema: { ...anySchema, title: label } },\n provider,\n panelInput,\n options,\n config\n );\n };\n\n values.push({\n id: schemaId,\n label: labels[label] ?? label,\n icon: icons[label]\n });\n } else if (anySchema.type === 'array') {\n // not supported yet\n } else if (anySchema.type === 'object') {\n conditionalRender[schemaId] = () => {\n return renderObjectProperty(\n context,\n { id: schemaId, schema: { ...anySchema, title: label } },\n provider,\n panelInput,\n options,\n config\n );\n };\n\n values.push({\n id: schemaId,\n label: labels[label] ?? label,\n icon: icons[label]\n });\n }\n });\n\n const defaultValue =\n property.schema.default != null\n ? values.find((value) => value.id === property.schema.default) ??\n values[0]\n : values[0];\n\n const propertyState = global<EnumValue>(id, defaultValue);\n\n builder.Select(id, {\n inputLabel,\n values,\n ...propertyState\n });\n\n if (propertyState.value.id in conditionalRender) {\n const inputs = conditionalRender[propertyState.value.id]();\n conditionalInputs[propertyState.value.id] = inputs;\n }\n\n return () => {\n const conditionalInput = conditionalInputs[propertyState.value.id];\n\n if (conditionalInput != null) {\n return {\n ...conditionalInput(),\n id: property.id\n };\n }\n\n return {\n id: property.id,\n type: 'string',\n value: propertyState.value.id\n };\n };\n}\n\nfunction getImglyExtensionBuilder(\n schema: OpenAPIV3.SchemaObject\n): ExtensionImglyBuilder | undefined {\n if ('x-imgly-builder' in schema) {\n const extension = schema['x-imgly-builder'] as ExtensionImglyBuilder;\n return extension;\n }\n\n return undefined;\n}\n\nexport default renderProperty;\n", "const previewUri =\n 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIzIiBoZWlnaHQ9IjMyMyIgdmlld0JveD0iMCAwIDMyMyAzMjMiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIzMjMiIGhlaWdodD0iMzIzIiBmaWxsPSIjRTlFQkVEIi8+CjxnIG9wYWNpdHk9IjAuMyI+CjxwYXRoIGQ9Ik0xMTYgMTg0VjE5MS41QzExNiAxOTkuNzg0IDEyMi43MTYgMjA2LjUgMTMxIDIwNi41SDE5MUMxOTkuMjg0IDIwNi41IDIwNiAxOTkuNzg0IDIwNiAxOTEuNVYxMzEuNUMyMDYgMTIzLjIxNiAxOTkuMjg0IDExNi41IDE5MSAxMTYuNUwxOTAuOTk1IDEyNi41QzE5My43NTcgMTI2LjUgMTk2IDEyOC43MzkgMTk2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AxNDIuOTM1IDE0Mi45MzIgMTQzLjEyNkwxNTYuNTc3IDE0OC41MDhDMTU4LjE2IDE0OS4xMzIgMTU4LjE2IDE1MS4zNzIgMTU2LjU3NyAxNTEuOTk2TDE0Mi45MzIgMTU3LjM3OEMxNDIuNDQ4IDE1Ny41NjggMTQyLjA2NiAxNTcuOTUxIDE0MS44NzUgMTU4LjQzNEwxMzYuNDk0IDE3Mi4wNzlDMTM1Ljg2OSAxNzMuNjYyIDEzMy42MjkgMTczLjY2MiAxMzMuMDA1IDE3Mi4wNzlMMTI3LjYyMyAxNTguNDM0QzEyNy40MzMgMTU3Ljk1MSAxMjcuMDUgMTU3LjU2OCAxMjYuNTY3IDE1Ny4zNzhMMTEyLjkyMiAxNTEuOTk2QzExMS4zMzkgMTUxLjM3MiAxMTEuMzM5IDE0OS4xMzIgMTEyLjkyMiAxNDguNTA4TDEyNi41NjcgMTQzLjEyNkMxMjcuMDUgMTQyLjkzNSAxMjcuNDMzIDE0Mi41NTMgMTI3LjYyMyAxNDIuMDdMMTMzLjAwNSAxMjguNDI0WiIgZmlsbD0iIzhGOEY4RiIvPgo8cGF0aCBkPSJNMTk1Ljk5OSAxODQuMDA0VjE5MS41MDJDMTk1Ljk5OSAxOTQuMjYzIDE5My43NjEgMTk2LjUwMiAxOTAuOTk5IDE5Ni41MDJIMTQ3LjY2OEwxNzIuODc5IDE1OC42ODRDMTc0LjM2MyAxNTYuNDU4IDE3Ny42MzUgMTU2LjQ1OCAxNzkuMTIgMTU4LjY4NEwxOTUuOTk5IDE4NC4wMDRaIiBmaWxsPSIjOEY4RjhGIi8+CjwvZz4KPC9zdmc+Cg==';\n\nexport default previewUri;\n", "import { type AssetResult } from '@cesdk/cesdk-js';\nimport { type OutputKind, GetBlockInputResult, InputByKind } from './provider';\nimport previewUri from './previewUri';\n\nfunction getAssetResultForPlaceholder<K extends OutputKind>(\n id: string,\n kind: K,\n blockInput: GetBlockInputResult<K>\n): AssetResult {\n switch (kind) {\n case 'image': {\n return getImageAssetResultForPlaceholder(\n id,\n blockInput[kind] as InputByKind['image']\n );\n }\n case 'video': {\n return getVideoAssetResultForPlaceholder(\n id,\n blockInput[kind] as InputByKind['video']\n );\n }\n\n default: {\n throw new Error(\n `Unsupported output kind for creating placeholder block: ${kind}`\n );\n }\n }\n}\n\nfunction getImageAssetResultForPlaceholder(\n id: string,\n input: InputByKind['image']\n): AssetResult {\n const width = input.width;\n const height = input.height;\n return {\n id,\n meta: {\n previewUri,\n fillType: '//ly.img.ubq/fill/image',\n kind: 'image',\n\n width,\n height\n }\n };\n}\n\nfunction getVideoAssetResultForPlaceholder(\n id: string,\n input: InputByKind['video']\n): AssetResult {\n const width = input.width;\n const height = input.height;\n return {\n id,\n label: input.label,\n meta: {\n previewUri,\n mimeType: 'video/mp4',\n kind: 'video',\n fillType: '//ly.img.ubq/fill/video',\n\n duration: input.duration.toString(),\n\n width,\n height\n }\n };\n}\n\nexport default getAssetResultForPlaceholder;\n", "import { type AssetResult } from '@cesdk/cesdk-js';\nimport {\n type OutputKind,\n AudioOutput,\n GetBlockInputResult,\n ImageOutput,\n InputByKind,\n Output,\n VideoOutput\n} from './provider';\nimport { getThumbnailForVideo } from '../utils';\n\nasync function getAssetResultForGenerated<K extends OutputKind>(\n id: string,\n kind: K,\n blockInputs: GetBlockInputResult<K>,\n output: Output\n): Promise<AssetResult> {\n switch (kind) {\n case 'image': {\n if (output.kind !== 'image') {\n throw new Error(\n `Output kind does not match the expected type: ${output.kind} (expected: image)`\n );\n }\n\n return getImageAssetResultForGenerated(\n id,\n blockInputs[kind] as InputByKind['image'],\n output\n );\n }\n\n case 'video': {\n if (output.kind !== 'video') {\n throw new Error(\n `Output kind does not match the expected type: ${output.kind} (expected: video)`\n );\n }\n\n return getVideoAssetResultForGenerated(\n id,\n blockInputs[kind] as InputByKind['video'],\n output\n );\n }\n\n case 'audio': {\n if (output.kind !== 'audio') {\n throw new Error(\n `Output kind does not match the expected type: ${output.kind} (expected: audio)`\n );\n }\n\n return getAudioAssetResultForGenerated(\n id,\n blockInputs[kind] as InputByKind['audio'],\n output\n );\n }\n\n default: {\n throw new Error(\n `Unsupported output kind for creating placeholder block: ${kind}`\n );\n }\n }\n}\n\nfunction getImageAssetResultForGenerated(\n id: string,\n input: InputByKind['image'],\n output: ImageOutput\n): AssetResult {\n const width = input.width;\n const height = input.height;\n return {\n id,\n label: input.label,\n meta: {\n uri: output.url,\n thumbUri: output.url,\n fillType: '//ly.img.ubq/fill/image',\n kind: 'image',\n\n width,\n height\n },\n payload: {\n sourceSet: [\n {\n uri: output.url,\n width,\n height\n }\n ]\n }\n };\n}\n\nasync function getVideoAssetResultForGenerated(\n id: string,\n input: InputByKind['video'],\n output: VideoOutput\n): Promise<AssetResult> {\n const width = input.width;\n const height = input.height;\n\n const thumbUri = await getThumbnailForVideo(output.url, 0);\n\n return {\n id,\n label: input.label,\n meta: {\n uri: output.url,\n thumbUri,\n\n mimeType: 'video/mp4',\n kind: 'video',\n fillType: '//ly.img.ubq/fill/video',\n\n duration: input.duration.toString(),\n\n width,\n height\n }\n };\n}\n\nfunction getAudioAssetResultForGenerated(\n id: string,\n input: InputByKind['audio'],\n output: AudioOutput\n): AssetResult {\n return {\n id,\n label: input.label,\n meta: {\n uri: output.url,\n thumbUri: output.thumbnailUrl,\n blockType: '//ly.img.ubq/audio',\n mimeType: 'audio/x-m4a',\n duration: output.duration.toString()\n }\n };\n}\n\nexport default getAssetResultForGenerated;\n", "import { GenerationOptions, GenerationResult, Output } from '../provider';\n\n/**\n * Result of the generation with a dispose function to clean up\n */\nexport interface DisposableGenerationResult<O extends Output> {\n /**\n * The actual generation result\n */\n result: GenerationResult<O>;\n\n /**\n * Function to dispose/clean up resources created during generation\n * This should be called when the generation is cancelled or completely\n * finished including the confirmation of the generation if applicable.\n */\n dispose: () => Promise<void>;\n}\n\n/**\n * Define the type for middleware functions\n */\nexport type Middleware<I, O extends Output> = (\n input: I,\n options: GenerationOptions & {\n /**\n * The block ids the generation is applied on\n * If this value is undefined, the selected blocks will be used.\n * Setting this value to null will explicitly tell every\n * middleware that no block shall be used.\n */\n blockIds?: number[] | null;\n\n /**\n * Adds a disposer function to this genereation which is called\n * when the generation is cancelled or completely finished\n * including the confirmation of the generation if applicable.\n */\n addDisposer: (dispose: () => Promise<void>) => void;\n },\n next: (input: I, options: GenerationOptions) => Promise<GenerationResult<O>>\n) => Promise<GenerationResult<O>>;\n\nexport function composeMiddlewares<I, O extends Output>(\n middlewares: (Middleware<I, O> | false | undefined | null)[]\n) {\n // Filter out false, undefined, and null middlewares\n const validMiddlewares = middlewares.filter(\n (middleware): middleware is Middleware<I, O> => !!middleware\n );\n // Start with the base handler\n return (\n baseHandler: (\n input: I,\n options: GenerationOptions\n ) => Promise<GenerationResult<O>>\n ) => {\n // We need to build a chain where each step is a function with the signature:\n // (input, options) => Promise<Result>\n\n // The composed function that will be returned\n return async (\n input: I,\n options: GenerationOptions\n ): Promise<DisposableGenerationResult<O>> => {\n // Store disposer functions that will be called when dispose() is called\n const disposers: Array<() => Promise<void>> = [];\n\n // Function to add a disposer\n const addDisposer = (dispose: () => Promise<void>) => {\n disposers.push(dispose);\n };\n\n // Define a function to process each middleware in sequence\n const runMiddleware = async (\n index: number,\n currentInput: I,\n currentOptions: GenerationOptions\n ): Promise<GenerationResult<O>> => {\n // If we've processed all middlewares, call the base handler\n if (index >= validMiddlewares.length) {\n return baseHandler(currentInput, currentOptions);\n }\n\n // Get the current middleware\n const currentMiddleware = validMiddlewares[index];\n\n // Create a next function for this middleware that calls the next middleware in line\n const next = async (\n nextInput: I,\n nextOptions: GenerationOptions\n ): Promise<GenerationResult<O>> => {\n return runMiddleware(index + 1, nextInput, nextOptions);\n };\n\n // Enhanced options with addDisposer\n const enhancedOptions = {\n ...currentOptions,\n addDisposer\n };\n\n // Call the current middleware with the input, enhanced options, and next function\n return currentMiddleware(currentInput, enhancedOptions, next);\n };\n\n // Create enhanced options with addDisposer for base handler as well\n const enhancedOptions = {\n ...options,\n addDisposer\n };\n\n // Run the middleware chain\n const result = await runMiddleware(0, input, enhancedOptions);\n\n // Create the dispose function that will call all collected disposers in reverse order\n const dispose = async (): Promise<void> => {\n // Execute disposers in reverse order (last added, first disposed)\n /* eslint-disable no-await-in-loop */\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n await disposers[i]();\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error in disposer:', error);\n }\n }\n // Clear the disposers array after all are executed\n disposers.length = 0;\n };\n\n // Return both the result and the dispose function\n return {\n result,\n dispose\n };\n };\n };\n}\n", "/* eslint-disable no-console */\nimport { GenerationResult, Output } from '../provider';\nimport { Middleware } from './middleware';\n\nfunction loggingMiddleware<I, O extends Output>() {\n const middleware: Middleware<I, O> = async (input, options, next) => {\n console.group('[GENERATION]');\n console.log(`Generating with input:`, JSON.stringify(input, null, 2));\n let result: GenerationResult<O> | undefined;\n const start = Date.now();\n try {\n result = await next(input, options);\n return result;\n } finally {\n if (result != null) {\n console.log(`Generation took ${Date.now() - start}ms`);\n console.log(`Generation result:`, JSON.stringify(result, null, 2));\n }\n console.groupEnd();\n }\n };\n\n return middleware;\n}\n\nexport default loggingMiddleware;\n", "/* eslint-disable no-console */\nimport { getImageDimensionsFromURL, getImageUri } from '@imgly/plugin-utils';\nimport {\n type Output,\n type OutputKind,\n type GetBlockInputResult,\n VideoOutput,\n ImageOutput,\n GenerationOptions\n} from '../provider';\nimport { Middleware } from './middleware';\n\ninterface DryRunOptions<K extends OutputKind> {\n kind: K;\n\n // Is only defined with generation from a panel where we create a complete new block\n blockInputs?: GetBlockInputResult<K>;\n\n // Is only defined with quick action generation on a given block(s).\n blockIds?: number[];\n}\n\nfunction dryRunMiddleware<I, K extends OutputKind, O extends Output>(\n options: DryRunOptions<K>\n) {\n const middleware: Middleware<I, O> = async (\n generationInput,\n generationOptions\n ) => {\n console.log(\n `[DRY RUN]: Requesting dummy AI generation for kind '${options.kind}' with inputs: `,\n JSON.stringify(generationInput, undefined, 2)\n );\n await wait(2000);\n const output = await getDryRunOutput(\n generationInput,\n options,\n generationOptions\n );\n return output as O;\n };\n\n return middleware;\n}\n\nasync function getDryRunOutput<K extends OutputKind, I>(\n generationInput: I,\n options: DryRunOptions<K>,\n generationOptions: GenerationOptions\n): Promise<Output> {\n switch (options.kind) {\n case 'image': {\n return getImageDryRunOutput(\n generationInput,\n options as DryRunOptions<'image'>,\n generationOptions\n );\n }\n case 'video': {\n return getVideoDryRunOutput(\n generationInput,\n options as DryRunOptions<'video'>,\n generationOptions\n );\n }\n\n default: {\n throw new Error(\n `Unsupported output kind for creating dry run output: ${options.kind}`\n );\n }\n }\n}\n\nasync function getImageDryRunOutput<I>(\n generationInput: I,\n options: DryRunOptions<'image'>,\n { engine }: GenerationOptions\n): Promise<ImageOutput> {\n let width;\n let height;\n\n const prompt: string =\n generationInput != null &&\n typeof generationInput === 'object' &&\n 'prompt' in generationInput &&\n typeof generationInput.prompt === 'string'\n ? generationInput.prompt\n : 'AI Generated Image';\n\n // If prompt includes something that looks like a dimension\n // e.g. 512x512, 1024x768, etc. than we will use this as the\n // output image size for testing purposes.\n const promptDimension = prompt.match(/(\\d+)x(\\d+)/);\n if (promptDimension != null) {\n width = parseInt(promptDimension[1], 10);\n height = parseInt(promptDimension[2], 10);\n } else {\n if (options.blockInputs != null) {\n width = options.blockInputs.image.width;\n height = options.blockInputs.image.height;\n }\n if (\n options.blockIds != null &&\n Array.isArray(options.blockIds) &&\n options.blockIds.length > 0\n ) {\n const [blockId] = options.blockIds;\n const url = await getImageUri(blockId, engine);\n const dimension = await getImageDimensionsFromURL(url, engine);\n width = dimension.width;\n height = dimension.height;\n } else {\n width = 512;\n height = 512;\n }\n }\n\n const url = `https://placehold.co/${width}x${height}/000000/FFF?text=${prompt\n .replace(' ', '+')\n .replace('\\n', '+')}`;\n\n return {\n kind: 'image',\n url\n };\n}\n\nasync function getVideoDryRunOutput<I>(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _generationInput: I,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _options: DryRunOptions<'video'>,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _generationOptions: GenerationOptions\n): Promise<VideoOutput> {\n return Promise.resolve({\n kind: 'video',\n url: 'https://storage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4'\n });\n}\n\nasync function wait(ms: number) {\n return new Promise((resolve) => {\n setTimeout(resolve, ms);\n });\n}\n\nexport default dryRunMiddleware;\n", "/* eslint-disable no-console */\nimport type { AssetDefinition, AssetResult } from '@cesdk/cesdk-js';\nimport {\n addAssetToScene,\n isAbortError,\n isAsyncGenerator,\n uuid4\n} from '../utils';\nimport type Provider from './provider';\nimport {\n type GetInput,\n type GetBlockInput,\n OutputKind,\n type Output\n} from './provider';\nimport { InitProviderConfiguration, UIOptions } from './types';\nimport CreativeEditorSDK from '@cesdk/cesdk-js';\nimport getAssetResultForPlaceholder from './getAssetResultForPlaceholder';\nimport getAssetResultForGenerated from './getAssetResultForGenerated';\nimport { composeMiddlewares } from './middleware/middleware';\nimport loggingMiddleware from './middleware/loggingMiddleware';\nimport dryRunMiddleware from './middleware/dryRunMiddleware';\n\ntype Result<O> = { status: 'success'; output: O } | { status: 'aborted' };\n\n/**\n * Generate content using the provider with the given input\n */\nasync function generate<K extends OutputKind, I, O extends Output>(\n kind: K,\n getInput: GetInput<I>,\n getBlockInput: GetBlockInput<K, I>,\n provider: Provider<K, I, O>,\n options: UIOptions & {\n createPlaceholderBlock?: boolean;\n },\n config: InitProviderConfiguration,\n abortSignal: AbortSignal\n): Promise<Result<O>> {\n const { cesdk, createPlaceholderBlock, historyAssetSourceId } = options;\n\n let placeholderBlock: number | undefined;\n\n try {\n if (config.debug) console.group(`Starting Generation for '${kind}'`);\n\n const inputs = getInput();\n const blockInputs = await getBlockInput(inputs.input);\n const assetId = uuid4();\n let assetResult: AssetResult;\n\n // Create a placeholder block\n if (createPlaceholderBlock) {\n assetResult = getAssetResultForPlaceholder(assetId, kind, blockInputs);\n\n if (config.debug)\n console.log(\n 'Adding as asset to scene:',\n JSON.stringify(assetResult, undefined, 2)\n );\n\n placeholderBlock = await addAssetToScene(cesdk, assetResult);\n // This is a workaround. The middleware in the video timeline\n // is calling APIs that will render the block in an error\n // state if it does not have an URI set. It's difficult to\n // recover from that. A bug report has been created for this.\n // As a workaround: Duplicating the block will remove the error state\n // but you will still see an error in the web console.\n // TODO: Remove this workaround when the bug is fixed.\n if (placeholderBlock != null && provider.kind === 'video') {\n const positionX = cesdk.engine.block.getPositionX(placeholderBlock);\n const positionY = cesdk.engine.block.getPositionY(placeholderBlock);\n const duplicated = cesdk.engine.block.duplicate(placeholderBlock);\n cesdk.engine.block.setPositionX(duplicated, positionX);\n cesdk.engine.block.setPositionY(duplicated, positionY);\n cesdk.engine.block.destroy(placeholderBlock);\n placeholderBlock = duplicated;\n }\n // placeholderBlock = await options.engine.asset.defaultApplyAsset(\n // assetResult\n // );\n\n if (checkAbortSignal(cesdk, abortSignal, placeholderBlock))\n return { status: 'aborted' };\n\n if (placeholderBlock == null)\n throw new Error('Could not create placeholder block');\n\n cesdk.engine.block.setState(placeholderBlock, {\n type: 'Pending',\n progress: 0\n });\n }\n\n // Trigger the generation\n const composedMiddlewares = composeMiddlewares<I, O>([\n ...(provider.output.middleware ?? []),\n config.debug ? loggingMiddleware() : undefined,\n config.dryRun\n ? dryRunMiddleware({ kind: provider.kind, blockInputs })\n : undefined\n ]);\n\n const { result: output } = await composedMiddlewares(\n provider.output.generate\n )(inputs.input, {\n abortSignal,\n engine: options.engine,\n cesdk\n });\n\n if (isAsyncGenerator(output)) {\n throw new Error('Streaming generation is not supported yet from a panel');\n }\n\n if (checkAbortSignal(cesdk, abortSignal, placeholderBlock))\n return { status: 'aborted' };\n\n if (output == null) throw new Error('Generation failed');\n\n if (config.debug)\n console.log('Generated output:', JSON.stringify(output, undefined, 2));\n\n let generatedAssetResult: AssetResult | undefined;\n if (\n placeholderBlock != null &&\n cesdk.engine.block.isValid(placeholderBlock)\n ) {\n generatedAssetResult = await getAssetResultForGenerated(\n assetId,\n kind,\n blockInputs,\n output\n );\n if (config.debug)\n console.log(\n 'Updating asset in scene:',\n JSON.stringify(generatedAssetResult, undefined, 2)\n );\n\n await cesdk.engine.asset.defaultApplyAssetToBlock(\n generatedAssetResult,\n placeholderBlock\n );\n }\n\n if (checkAbortSignal(cesdk, abortSignal, placeholderBlock))\n return { status: 'aborted' };\n\n if (historyAssetSourceId != null) {\n if (generatedAssetResult == null) {\n generatedAssetResult = await getAssetResultForGenerated(\n assetId,\n kind,\n blockInputs,\n output\n );\n if (checkAbortSignal(cesdk, abortSignal, placeholderBlock))\n return { status: 'aborted' };\n }\n const assetDefinition: AssetDefinition = {\n ...generatedAssetResult,\n id: `${Date.now()}-${generatedAssetResult.id}`,\n label:\n generatedAssetResult.label != null\n ? {\n en: generatedAssetResult.label\n }\n : {},\n tags: {}\n };\n\n cesdk.engine.asset.addAssetToSource(\n historyAssetSourceId,\n assetDefinition\n );\n }\n\n if (\n placeholderBlock != null &&\n cesdk.engine.block.isValid(placeholderBlock)\n ) {\n cesdk.engine.block.setState(placeholderBlock, {\n type: 'Ready'\n });\n }\n return { status: 'success', output };\n } catch (error) {\n if (\n placeholderBlock != null &&\n cesdk.engine.block.isValid(placeholderBlock)\n ) {\n if (isAbortError(error)) {\n cesdk.engine.block.destroy(placeholderBlock);\n } else {\n cesdk.engine.block.setState(placeholderBlock, {\n type: 'Error',\n error: 'Unknown'\n });\n }\n }\n throw error;\n } finally {\n if (config.debug) console.groupEnd();\n }\n}\n\n/**\n * Check the given abort signal and destroy the placeholder block if it is aborted.\n * @returns `true` if the signal is aborted, `false` otherwise.\n */\nfunction checkAbortSignal(\n cesdk: CreativeEditorSDK,\n abortSignal: AbortSignal,\n placeholderBlock?: number\n) {\n if (abortSignal.aborted) {\n if (\n placeholderBlock != null &&\n cesdk.engine.block.isValid(placeholderBlock)\n ) {\n cesdk.engine.block.destroy(placeholderBlock);\n }\n return true;\n }\n return false;\n}\n\nexport default generate;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport Provider, { GetInput, Output, OutputKind } from './provider';\nimport { InitProviderConfiguration } from './types';\nimport { extractErrorMessage } from '../utils';\n\nfunction handleGenerationError<K extends OutputKind, I, O extends Output>(\n error: unknown,\n options: {\n cesdk: CreativeEditorSDK;\n provider: Provider<K, I, O>;\n getInput?: GetInput<I>;\n },\n config: InitProviderConfiguration\n) {\n const { cesdk, provider, getInput } = options;\n\n if (config.onError != null && typeof config.onError === 'function') {\n config.onError(error);\n } else {\n // eslint-disable-next-line no-console\n console.error('Generation failed:', error);\n const shown = showErrorNotification(\n cesdk,\n provider.output.notification,\n () => ({\n input: getInput?.().input,\n error\n })\n );\n if (!shown) {\n cesdk.ui.showNotification({\n type: 'error',\n message: extractErrorMessage(error)\n });\n }\n }\n}\n\nfunction showErrorNotification<I, O extends Output>(\n cesdk: CreativeEditorSDK,\n notifications: Provider<any, I, O>['output']['notification'],\n createContext: () => { input?: I; error: unknown }\n): boolean {\n const errorNotification = notifications?.error;\n if (errorNotification == null) return false;\n\n const showOnSuccess =\n typeof errorNotification.show === 'function'\n ? errorNotification.show(createContext())\n : errorNotification.show;\n\n if (!showOnSuccess) return false;\n\n const message =\n typeof errorNotification.message === 'function'\n ? errorNotification.message(createContext())\n : errorNotification.message ?? 'common.ai-generation.failed';\n\n const action =\n errorNotification.action != null\n ? {\n label:\n typeof errorNotification.action.label === 'function'\n ? errorNotification.action.label(createContext())\n : errorNotification.action.label,\n onClick: () => {\n errorNotification?.action?.onClick(createContext());\n }\n }\n : undefined;\n\n cesdk.ui.showNotification({\n type: 'error',\n message,\n action\n });\n return true;\n}\n\nexport default handleGenerationError;\n", "import CreativeEditorSDK, {\n type BuilderRenderFunctionContext\n} from '@cesdk/cesdk-js';\nimport type Provider from './provider';\nimport {\n type GetInput,\n type OutputKind,\n type Output,\n type GetBlockInput\n} from './provider';\nimport { InitProviderConfiguration, UIOptions } from './types';\nimport generate from './generate';\nimport { isAbortError } from '../utils';\nimport handleGenerationError from './handleGenerationError';\n\nexport function isGeneratingStateKey(providerId: string): string {\n return `${providerId}.generating`;\n}\n\nexport function abortGenerationStateKey(providerId: string): string {\n return `${providerId}.abort`;\n}\n\n/**\n * Renders the generation UI components and sets up event handlers\n */\nfunction renderGenerationComponents<K extends OutputKind, I, O extends Output>(\n context: BuilderRenderFunctionContext<any>,\n provider: Provider<K, I, O>,\n getInput: GetInput<I>,\n getBlockInput: GetBlockInput<K, I>,\n options: UIOptions & {\n createPlaceholderBlock?: boolean;\n includeHistoryLibrary?: boolean;\n requiredInputs?: string[];\n },\n config: InitProviderConfiguration\n): void {\n const { builder, experimental } = context;\n const { cesdk, includeHistoryLibrary = true } = options;\n const {\n id: providerId,\n output: { abortable }\n } = provider;\n const abortState = experimental.global<() => void>(\n abortGenerationStateKey(providerId),\n () => {}\n );\n const generatingState = experimental.global<boolean>(\n isGeneratingStateKey(providerId),\n false\n );\n\n let abortController: AbortController | undefined;\n const canAbortNow = generatingState.value && abortable;\n const abort = () => {\n if (canAbortNow) {\n abortState.value();\n generatingState.setValue(false);\n abortState.setValue(() => {});\n }\n };\n\n let isDisabled: boolean | undefined;\n if (options.requiredInputs != null && options.requiredInputs.length > 0) {\n const inputs = getInput();\n isDisabled = options.requiredInputs.every((input) => {\n // @ts-ignore\n const hasInput = !inputs.input[input];\n return hasInput;\n });\n }\n\n const confirmCancelDialogId = experimental.global<string | undefined>(\n `${providerId}.confirmationDialogId`,\n undefined\n );\n\n builder.Section(`${providerId}.generate.section`, {\n children: () => {\n builder.Button(`${providerId}.generate`, {\n label: [\n 'common.ai-generation.generate',\n `panel.${providerId}.generate`\n ],\n isLoading: generatingState.value,\n color: 'accent',\n isDisabled,\n suffix: canAbortNow\n ? {\n icon: '@imgly/Cross',\n color: 'danger',\n tooltip: [`panel.${providerId}.abort`, 'common.cancel'],\n onClick: () => {\n const confirmationDialogId = cesdk.ui.showDialog({\n type: 'warning',\n content: 'panel.ly.img.ai.generation.confirmCancel.content',\n cancel: {\n label: 'common.close',\n onClick: ({ id }) => {\n cesdk.ui.closeDialog(id);\n confirmCancelDialogId.setValue(undefined);\n }\n },\n actions: {\n label: 'panel.ly.img.ai.generation.confirmCancel.confirm',\n color: 'danger',\n onClick: ({ id }) => {\n abort();\n cesdk.ui.closeDialog(id);\n confirmCancelDialogId.setValue(undefined);\n }\n }\n });\n confirmCancelDialogId.setValue(confirmationDialogId);\n }\n }\n : undefined,\n onClick: async () => {\n abortController = new AbortController();\n const abortSignal = abortController.signal;\n\n const triggerGeneration = async () => {\n try {\n generatingState.setValue(true);\n abortState.setValue(() => {\n if (config.debug)\n // eslint-disable-next-line no-console\n console.log('Aborting generation');\n abortController?.abort();\n });\n\n const result = await generate(\n provider.kind,\n getInput,\n getBlockInput,\n provider,\n options,\n config,\n abortSignal\n );\n\n if (result.status === 'aborted') {\n return;\n }\n\n const notification = provider.output.notification;\n showSuccessNotification(cesdk, notification, () => ({\n input: getInput().input,\n output: result.output\n }));\n } catch (error) {\n // Do not treat abort errors as errors\n if (isAbortError(error)) {\n return;\n }\n\n handleGenerationError(\n error,\n {\n cesdk,\n provider,\n getInput\n },\n config\n );\n } finally {\n abortController = undefined;\n generatingState.setValue(false);\n abortState.setValue(() => {});\n\n if (confirmCancelDialogId.value != null) {\n cesdk.ui.closeDialog(confirmCancelDialogId.value);\n confirmCancelDialogId.setValue(undefined);\n }\n }\n };\n\n if (config.middleware != null) {\n await config.middleware(triggerGeneration, {\n provider,\n abort\n });\n } else {\n await triggerGeneration();\n }\n }\n });\n if (provider.output.generationHintText != null) {\n builder.Text(`${providerId}.generation-hint`, {\n align: 'center',\n content: provider.output.generationHintText\n });\n }\n }\n });\n\n if (includeHistoryLibrary && options.historyAssetLibraryEntryId != null) {\n builder.Library(`${providerId}.history.library`, {\n entries: [options.historyAssetLibraryEntryId]\n });\n }\n}\n\nfunction showSuccessNotification<I, O extends Output>(\n cesdk: CreativeEditorSDK,\n notifications: Provider<any, I, O>['output']['notification'],\n createContext: () => { input: I; output: O }\n): boolean {\n const successNotification = notifications?.success;\n if (successNotification == null) return false;\n\n const showOnSuccess =\n typeof successNotification.show === 'function'\n ? successNotification.show(createContext())\n : successNotification.show;\n\n if (!showOnSuccess) return false;\n\n const message =\n typeof successNotification.message === 'function'\n ? successNotification.message(createContext())\n : successNotification.message ?? 'common.ai-generation.success';\n\n const action =\n successNotification.action != null\n ? {\n label:\n typeof successNotification.action.label === 'function'\n ? successNotification.action.label(createContext())\n : successNotification.action.label,\n onClick: () => {\n successNotification?.action?.onClick(createContext());\n }\n }\n : undefined;\n\n cesdk.ui.showNotification({\n type: 'success',\n message,\n action,\n duration: successNotification.duration\n });\n return true;\n}\n\nexport default renderGenerationComponents;\n", "import { OpenAPIV3 } from 'openapi-types';\nimport dereferenceDocument, {\n resolveReference\n} from './openapi/dereferenceDocument';\nimport {\n type OutputKind,\n type Output,\n type PanelInputSchema\n} from './provider';\nimport type Provider from './provider';\nimport { InitProviderConfiguration, UIOptions } from './types';\nimport { isOpenAPISchema } from './openapi/isOpenAPISchema';\nimport { GetPropertyInput, PropertyInput } from './openapi/types';\nimport renderProperty from './openapi/renderProperty';\nimport renderGenerationComponents from './renderGenerationComponents';\nimport getProperties from './openapi/getProperties';\nimport { BuilderRenderFunction } from '@cesdk/cesdk-js';\nimport { getPanelId } from '../utils';\n\n/**\n * Registers a schema-based panel input for a provider\n */\nasync function registerPanelInputSchema<\n K extends OutputKind,\n I,\n O extends Output\n>(\n provider: Provider<K, I, O>,\n panelInput: PanelInputSchema<K, I>,\n options: UIOptions,\n config: InitProviderConfiguration\n): Promise<BuilderRenderFunction<any>> {\n const { cesdk } = options;\n const { id: providerId } = provider;\n\n if (config.debug) {\n // eslint-disable-next-line no-console\n console.log(\n `Registering schema-based panel input for provider ${providerId}`\n );\n }\n\n const schemaDocument = dereferenceDocument(panelInput.document);\n const resolvedInputReference = resolveReference(\n schemaDocument,\n panelInput.inputReference\n );\n\n if (!isOpenAPISchema(resolvedInputReference, config.debug)) {\n throw new Error(\n `Input reference '${panelInput.inputReference}' does not resolve to a valid OpenAPI schema`\n );\n }\n\n const inputSchema: OpenAPIV3.SchemaObject = resolvedInputReference;\n const properties = getProperties(inputSchema, panelInput);\n\n const builderRenderFunction: BuilderRenderFunction<any> = (context) => {\n const { builder } = context;\n\n const getInputs: GetPropertyInput[] = [];\n builder.Section(`${providerId}.schema.section`, {\n children: () => {\n properties.forEach((property) => {\n const getInput = renderProperty(\n context,\n property,\n provider,\n panelInput,\n options,\n config\n );\n if (getInput != null) {\n if (Array.isArray(getInput)) {\n getInputs.push(...getInput);\n } else {\n getInputs.push(getInput);\n }\n }\n });\n }\n });\n\n const inputs = getInputs.map((getInput) => {\n const input = getInput();\n return input;\n });\n\n const resolveInput = (input: PropertyInput) => {\n if (input.type === 'object') {\n return Object.entries(input.value).reduce((acc, [key, value]) => {\n acc[key] = resolveInput(value);\n\n return acc;\n }, {} as Record<string, any>);\n }\n\n return input.value;\n };\n const input = inputs.reduce((acc, propertyInput) => {\n acc[propertyInput.id] = resolveInput(propertyInput);\n return acc;\n }, {} as Record<string, any>) as I;\n\n renderGenerationComponents(\n context,\n provider,\n () => {\n return { input };\n },\n () => {\n return panelInput.getBlockInput(input);\n },\n {\n ...options,\n requiredInputs: inputSchema.required,\n createPlaceholderBlock: panelInput.userFlow === 'placeholder'\n },\n config\n );\n };\n\n cesdk.ui.registerPanel(getPanelId(providerId), builderRenderFunction);\n return builderRenderFunction;\n}\n\nexport default registerPanelInputSchema;\n", "import { BuilderRenderFunction } from '@cesdk/cesdk-js';\nimport type Provider from './provider';\nimport { OutputKind, PanelInputCustom, type Output } from './provider';\nimport renderGenerationComponents, {\n isGeneratingStateKey\n} from './renderGenerationComponents';\nimport { InitProviderConfiguration, UIOptions } from './types';\nimport { getPanelId } from '../utils';\n\nasync function registerPanelInputCustom<\n K extends OutputKind,\n I,\n O extends Output\n>(\n provider: Provider<K, I, O>,\n panelInput: PanelInputCustom<K, I>,\n options: UIOptions,\n config: InitProviderConfiguration\n): Promise<BuilderRenderFunction<any>> {\n const { cesdk } = options;\n const { id: providerId } = provider;\n\n const render = panelInput.render;\n\n const builderRenderFunction: BuilderRenderFunction<any> = (context) => {\n const { state } = context;\n\n const isGenerating = state(isGeneratingStateKey(providerId), {\n isGenerating: false,\n abort: () => {}\n }).value.isGenerating;\n\n const { getInput, getBlockInput } = render(context, {\n cesdk,\n isGenerating\n });\n renderGenerationComponents(\n context,\n provider,\n getInput,\n getBlockInput,\n {\n ...options,\n includeHistoryLibrary: panelInput.includeHistoryLibrary ?? true,\n createPlaceholderBlock: panelInput.userFlow === 'placeholder'\n },\n config\n );\n\n return getInput;\n };\n\n cesdk.ui.registerPanel(getPanelId(providerId), builderRenderFunction);\n\n return builderRenderFunction;\n}\n\nexport default registerPanelInputCustom;\n", "export const PLUGIN_ICON_SET_ID = '@imgly/plugin-ai-generation';\n\nexport const ICON_SPRITE = `\n<svg>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/Sparkle\"\n >\n <path d=\"M5.35545 2.06745C5.24149 1.72556 4.7579 1.72556 4.64394 2.06745L4.05898 3.82232C4.02166 3.93429 3.9338 4.02215 3.82184 4.05948L2.06694 4.64459C1.72506 4.75858 1.72509 5.24217 2.06699 5.3561L3.82179 5.9409C3.93378 5.97822 4.02166 6.06609 4.05899 6.17808L4.64394 7.93291C4.7579 8.2748 5.24149 8.2748 5.35545 7.93291L5.9404 6.17806C5.97773 6.06608 6.06559 5.97821 6.17757 5.94089L7.93242 5.35594C8.27431 5.24198 8.27431 4.75839 7.93242 4.64442L6.17757 4.05947C6.06559 4.02215 5.97773 3.93428 5.9404 3.8223L5.35545 2.06745Z\" fill=\"currentColor\"/>\n<path d=\"M17.9632 3.23614C17.8026 2.80788 17.1968 2.80788 17.0362 3.23614L16.0787 5.78951C16.0285 5.92337 15.9229 6.02899 15.789 6.07918L13.2356 7.0367C12.8074 7.19729 12.8074 7.80307 13.2356 7.96366L15.789 8.92118C15.9229 8.97138 16.0285 9.077 16.0787 9.21085L17.0362 11.7642C17.1968 12.1925 17.8026 12.1925 17.9632 11.7642L18.9207 9.21086C18.9709 9.077 19.0765 8.97138 19.2104 8.92118L21.7637 7.96366C22.192 7.80307 22.192 7.1973 21.7637 7.0367L19.2104 6.07918C19.0765 6.02899 18.9709 5.92337 18.9207 5.78951L17.9632 3.23614Z\" fill=\"currentColor\"/>\n<path d=\"M9.30058 7.82012C9.54712 7.1791 10.454 7.1791 10.7006 7.82012L12.3809 12.189C12.4571 12.3871 12.6136 12.5436 12.8117 12.6198L17.1806 14.3001C17.8216 14.5466 17.8216 15.4536 17.1806 15.7001L12.8117 17.3804C12.6136 17.4566 12.4571 17.6131 12.3809 17.8112L10.7006 22.1801C10.454 22.8211 9.54712 22.8211 9.30058 22.1801L7.62024 17.8112C7.54406 17.6131 7.38754 17.4566 7.18947 17.3804L2.82061 15.7001C2.17959 15.4536 2.17959 14.5466 2.82061 14.3001L7.18947 12.6198C7.38754 12.5436 7.54406 12.3871 7.62024 12.189L9.30058 7.82012Z\" fill=\"currentColor\"/>\n\n </symbol>\n\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"${PLUGIN_ICON_SET_ID}/image\"\n >\n <path d=\"M3 16.5V18C3 19.6569 4.34315 21 6 21H18C19.6569 21 21 19.6569 21 18V6C21 4.34315 19.6569 3 18 3L17.999 5C18.5513 5 19 5.44772 19 6V18C19 18.5523 18.5523 19 18 19H6C5.44772 19 5 18.5523 5 18V16.5H3Z\" fill=\"currentColor\"/>\n<path d=\"M13.0982 0.884877C12.9734 0.568323 12.5254 0.568322 12.4005 0.884876L11.7485 2.53819C11.7104 2.63483 11.6339 2.71134 11.5372 2.74945L9.8839 3.40151C9.56735 3.52636 9.56734 3.97436 9.8839 4.09921L11.5372 4.75126C11.6339 4.78938 11.7104 4.86588 11.7485 4.96253L12.4005 6.61584C12.5254 6.93239 12.9734 6.9324 13.0982 6.61584L13.7503 4.96253C13.7884 4.86588 13.8649 4.78938 13.9616 4.75126L15.6149 4.09921C15.9314 3.97436 15.9314 3.52636 15.6149 3.40151L13.9616 2.74945C13.8649 2.71134 13.7884 2.63483 13.7503 2.53819L13.0982 0.884877Z\" fill=\"currentColor\"/>\n<path d=\"M6.40053 5.38488C6.52538 5.06832 6.97338 5.06832 7.09823 5.38488L8.17455 8.11392C8.21267 8.21057 8.28917 8.28707 8.38582 8.32519L11.1149 9.40151C11.4314 9.52636 11.4314 9.97436 11.1149 10.0992L8.38582 11.1755C8.28917 11.2136 8.21267 11.2901 8.17455 11.3868L7.09823 14.1158C6.97338 14.4324 6.52538 14.4324 6.40053 14.1158L5.32421 11.3868C5.2861 11.2901 5.20959 11.2136 5.11295 11.1755L2.3839 10.0992C2.06735 9.97436 2.06735 9.52636 2.3839 9.40151L5.11295 8.32519C5.20959 8.28707 5.2861 8.21057 5.32421 8.11392L6.40053 5.38488Z\" fill=\"currentColor\"/>\n<path d=\"M18.9994 16.5008V18.0004C18.9994 18.5526 18.5517 19.0004 17.9994 19.0004H9.33302L14.3753 11.4369C14.6722 10.9916 15.3266 10.9916 15.6234 11.4369L18.9994 16.5008Z\" fill=\"currentColor\"/>\n\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"${PLUGIN_ICON_SET_ID}/video\"\n >\n<path d=\"M6 3C4.34315 3 3 4.34315 3 6V18C3 19.6569 4.34315 21 6 21H18C19.6569 21 21 19.6569 21 18V16.5H19V18C19 18.5523 18.5523 19 18 19H6C5.44772 19 5 18.5523 5 18V6C5 5.44772 5.44772 5 6 5V3Z\" fill=\"currentColor\"/>\n<path d=\"M10.9025 0.8839C11.0273 0.567345 11.4753 0.567346 11.6002 0.883901L12.2522 2.53721C12.2904 2.63386 12.3669 2.71036 12.4635 2.74848L14.1168 3.40053C14.4334 3.52538 14.4334 3.97338 14.1168 4.09823L12.4635 4.75029C12.3669 4.7884 12.2904 4.86491 12.2522 4.96155L11.6002 6.61486C11.4753 6.93142 11.0273 6.93142 10.9025 6.61486L10.2504 4.96155C10.2123 4.86491 10.1358 4.7884 10.0392 4.75029L8.38585 4.09823C8.0693 3.97338 8.0693 3.52538 8.38585 3.40053L10.0392 2.74848C10.1358 2.71036 10.2123 2.63386 10.2504 2.53721L10.9025 0.8839Z\" fill=\"currentColor\"/>\n<path d=\"M18.9019 3.3845C19.0267 3.06795 19.4747 3.06795 19.5996 3.3845L20.6759 6.11355C20.714 6.2102 20.7905 6.2867 20.8872 6.32482L23.6162 7.40114C23.9328 7.52598 23.9328 7.97399 23.6162 8.09883L20.8872 9.17515C20.7905 9.21327 20.714 9.28977 20.6759 9.38642L19.5996 12.1155C19.4747 12.432 19.0267 12.432 18.9019 12.1155L17.8255 9.38642C17.7874 9.28977 17.7109 9.21327 17.6143 9.17515L14.8852 8.09883C14.5687 7.97399 14.5687 7.52598 14.8852 7.40114L17.6143 6.32482C17.7109 6.2867 17.7874 6.2102 17.8255 6.11355L18.9019 3.3845Z\" fill=\"currentColor\"/>\n<path d=\"M14.9994 13.2862C15.5089 12.8859 15.5089 12.1141 14.9995 11.7137L10.618 8.27047C9.96188 7.75485 9.00011 8.22225 9.00011 9.05673L9.00011 15.9429C9.00011 16.7773 9.96185 17.2448 10.618 16.7292L14.9994 13.2862Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"${PLUGIN_ICON_SET_ID}/audio\"\n >\n <path d=\"M6 3.80273C4.2066 4.84016 3 6.77919 3 9.00004V12.8153C3 15.931 5.39501 18.4873 8.44444 18.7436V20.9645C8.44444 22.2198 9.89427 22.9198 10.8773 22.1392L15.1265 18.7647H15.5C17.8285 18.7647 19.8472 17.4384 20.8417 15.5H18.4187C17.6889 16.2784 16.6512 16.7647 15.5 16.7647H14.9522C14.6134 16.7647 14.2846 16.8794 14.0193 17.0901L10.4444 19.929V18.2597C10.4444 17.4341 9.77513 16.7647 8.9495 16.7647C7.80494 16.7647 6.77409 16.2779 6.05276 15.5H6V15.4419C5.37798 14.7439 5 13.8237 5 12.8153V9.00004C5 7.98559 5.37764 7.05935 6 6.35422V3.80273Z\" fill=\"currentColor\"/>\n<path d=\"M11.6002 1.8839C11.4753 1.56735 11.0273 1.56735 10.9025 1.8839L10.2504 3.53721C10.2123 3.63386 10.1358 3.71036 10.0392 3.74848L8.38585 4.40053C8.0693 4.52538 8.0693 4.97338 8.38585 5.09823L10.0392 5.75029C10.1358 5.7884 10.2123 5.86491 10.2504 5.96155L10.9025 7.61486C11.0273 7.93142 11.4753 7.93142 11.6002 7.61486L12.2522 5.96155C12.2904 5.86491 12.3669 5.7884 12.4635 5.75029L14.1168 5.09823C14.4334 4.97338 14.4334 4.52538 14.1168 4.40053L12.4635 3.74848C12.3669 3.71036 12.2904 3.63386 12.2522 3.53721L11.6002 1.8839Z\" fill=\"currentColor\"/>\n<path d=\"M19.5996 4.3845C19.4747 4.06795 19.0267 4.06795 18.9019 4.3845L17.8255 7.11355C17.7874 7.2102 17.7109 7.2867 17.6143 7.32482L14.8852 8.40114C14.5687 8.52598 14.5687 8.97399 14.8852 9.09883L17.6143 10.1752C17.7109 10.2133 17.7874 10.2898 17.8255 10.3864L18.9019 13.1155C19.0267 13.432 19.4747 13.432 19.5996 13.1155L20.6759 10.3864C20.714 10.2898 20.7905 10.2133 20.8872 10.1752L23.6162 9.09883C23.9328 8.97399 23.9328 8.52598 23.6162 8.40114L20.8872 7.32482C20.7905 7.2867 20.714 7.2102 20.6759 7.11355L19.5996 4.3845Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/MixingPlate\"\n >\n <path d=\"M9.75 9C10.5784 9 11.25 8.32843 11.25 7.5C11.25 6.67157 10.5784 6 9.75 6C8.92157 6 8.25 6.67157 8.25 7.5C8.25 8.32843 8.92157 9 9.75 9Z\" fill=\"currentColor\"/>\n<path d=\"M7 13C7.82843 13 8.5 12.3284 8.5 11.5C8.5 10.6716 7.82843 10 7 10C6.17157 10 5.5 10.6716 5.5 11.5C5.5 12.3284 6.17157 13 7 13Z\" fill=\"currentColor\"/>\n<path d=\"M15.75 7.5C15.75 8.32843 15.0784 9 14.25 9C13.4216 9 12.75 8.32843 12.75 7.5C12.75 6.67157 13.4216 6 14.25 6C15.0784 6 15.75 6.67157 15.75 7.5Z\" fill=\"currentColor\"/>\n<path d=\"M17 13C17.8284 13 18.5 12.3284 18.5 11.5C18.5 10.6716 17.8284 10 17 10C16.1716 10 15.5 10.6716 15.5 11.5C15.5 12.3284 16.1716 13 17 13Z\" fill=\"currentColor\"/>\n<path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M8.26309 2.77709C10.6681 1.77921 13.4829 1.7322 15.9209 2.64297C18.1572 3.47923 20.0876 5.09285 21.1766 7.28598C22.3395 9.62772 22.4889 13.1077 20.3864 15.2982C19.2693 16.4621 17.7657 16.9982 16.0026 16.9997C15.7897 16.9997 15.5555 16.9864 15.3497 16.9745C15.309 16.9722 15.2694 16.9699 15.2313 16.9679C14.9817 16.9542 14.761 16.9455 14.5569 16.9539C14.124 16.9718 13.9598 17.0612 13.89 17.1324C13.718 17.3081 13.6946 17.6672 13.8854 17.8895C14.2899 18.3608 14.5016 18.9277 14.5016 19.5497C14.5016 20.2206 14.3086 20.9011 13.7542 21.3896C13.2471 21.837 12.6082 21.9997 11.9635 21.9997C10.6049 21.9997 9.31155 21.7367 8.0934 21.2067C6.89058 20.6831 5.84501 19.9687 4.94363 19.0666C4.04281 18.1651 3.31836 17.107 2.79369 15.8978C1.72761 13.4409 1.72662 10.5261 2.81247 8.07034C3.88024 5.65548 5.84206 3.78161 8.26309 2.77709ZM15.2207 4.51639C13.2556 3.78239 10.9651 3.82132 9.02956 4.62439C7.06888 5.43791 5.49559 6.94785 4.64163 8.87914C3.78373 10.8194 3.78253 13.1522 4.62841 15.1017C5.05312 16.0805 5.63511 16.9291 6.35838 17.6529C7.08102 18.3761 7.91671 18.9484 8.89123 19.3728C9.8492 19.7895 10.87 19.9997 11.9635 19.9997C12.2815 19.9997 12.394 19.9225 12.431 19.8899L12.4319 19.8891C12.4367 19.8849 12.4487 19.8743 12.4631 19.8359C12.4799 19.7911 12.5016 19.7024 12.5016 19.5497C12.5016 19.4091 12.4633 19.3034 12.3677 19.192C11.5353 18.222 11.5272 16.6868 12.4611 15.7331C13.0741 15.1071 13.8844 14.98 14.4745 14.9556C14.7819 14.943 15.085 14.9568 15.3409 14.9709C15.3906 14.9736 15.4379 14.9763 15.4832 14.9788C15.6876 14.9904 15.8508 14.9997 16.0009 14.9997C17.3405 14.9986 18.2792 14.6054 18.9435 13.9133C20.2633 12.5382 20.3186 10.055 19.3853 8.1755C18.5436 6.48051 17.0293 5.19281 15.2207 4.51639Z\" fill=\"currentColor\"/>\n\n </symbol>\n</svg>\n`;\n\nexport default ICON_SPRITE;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { QuickActionId, QuickActionMenu } from './types';\nimport { Output, QuickAction } from '../provider';\n\nconst QUICK_ACTION_ORDER_KEY_PREFIX = 'ly.img.ai.quickAction.order';\n\nconst QUICK_ACTION_REGISTRY_PREFIX = 'ly.img.ai.quickAction.actions';\n\n/**\n * Returns an object representing the quick action menu. Can be called and\n * retrieved multiple times.\n *\n * It's backed up by the global state.\n */\nfunction getQuickActionMenu(cesdk: CreativeEditorSDK, id: string) {\n const quickActionMenu: QuickActionMenu = {\n id,\n setQuickActionMenuOrder: (quickActionIds: string[]) => {\n cesdk.ui.experimental.setGlobalStateValue<QuickActionId[]>(\n `${QUICK_ACTION_ORDER_KEY_PREFIX}.${id}`,\n quickActionIds\n );\n },\n getQuickActionMenuOrder: () => {\n return cesdk.ui.experimental.getGlobalStateValue<QuickActionId[]>(\n `${QUICK_ACTION_ORDER_KEY_PREFIX}.${id}`,\n []\n );\n },\n registerQuickAction: <I, O extends Output>(\n quickAction: QuickAction<I, O>\n ) => {\n if (\n !cesdk.ui.experimental.hasGlobalStateValue(\n `${QUICK_ACTION_REGISTRY_PREFIX}.${id}`\n )\n ) {\n cesdk.ui.experimental.setGlobalStateValue<{\n [key: string]: QuickAction<I, O>;\n }>(`${QUICK_ACTION_REGISTRY_PREFIX}.${id}`, {\n [quickAction.id]: quickAction\n });\n } else {\n const entries = cesdk.ui.experimental.getGlobalStateValue(\n `${QUICK_ACTION_REGISTRY_PREFIX}.${id}`,\n {}\n );\n cesdk.ui.experimental.setGlobalStateValue(\n `${QUICK_ACTION_REGISTRY_PREFIX}.${id}`,\n {\n ...entries,\n [quickAction.id]: quickAction\n }\n );\n }\n },\n\n getQuickAction: <I, O extends Output>(quickActionId: string) => {\n const entries = cesdk.ui.experimental.getGlobalStateValue<{\n [key: string]: QuickAction<I, O>;\n }>(`${QUICK_ACTION_REGISTRY_PREFIX}.${id}`, {});\n\n return entries[quickActionId];\n }\n };\n return quickActionMenu;\n}\n\nexport default getQuickActionMenu;\n", "import { Output, QuickAction } from '../provider';\n\nexport const INFERENCE_AI_EDIT_MODE = 'ly.img.ai.inference.editMode';\n\nexport const INFERENCE_AI_METADATA_KEY = 'ly.img.ai.inference.metadata';\n\nexport const INFERENCE_CONFIRMATION_COMPONENT_ID =\n 'ly.img.ai.inference.confirmation.canvasMenu';\n\nexport function getFeatureIdForQuickAction(options: {\n quickActionId: string;\n quickActionMenuId: string;\n}) {\n return `ly.img.ai.quickAction.${options.quickActionMenuId}.${options.quickActionId}`;\n}\n\n/**\n * Removes all two following `ly.img.separator` entries from the quick\n * actions array or if it is first or last in the array.\n */\nexport function removeDuplicatedSeparators<I, O extends Output>(\n quickActions: (QuickAction<I, O> | 'ly.img.separator')[]\n): (QuickAction<I, O> | 'ly.img.separator')[] {\n if (quickActions.length === 0) {\n return [];\n }\n\n // Create a new array for the result\n const result = [...quickActions];\n\n // Remove separators at the beginning\n while (result.length > 0 && result[0] === 'ly.img.separator') {\n result.shift();\n }\n\n // Remove separators at the end\n while (\n result.length > 0 &&\n result[result.length - 1] === 'ly.img.separator'\n ) {\n result.pop();\n }\n\n // Remove consecutive separators\n return result.reduce<(QuickAction<I, O> | 'ly.img.separator')[]>(\n (acc, current) => {\n // Skip if current is a separator and previous was also a separator\n if (\n current === 'ly.img.separator' &&\n acc.length > 0 &&\n acc[acc.length - 1] === 'ly.img.separator'\n ) {\n return acc;\n }\n\n acc.push(current);\n return acc;\n },\n []\n );\n}\n", "import { Middleware } from './middleware';\nimport { Output } from '../provider';\n\n/**\n * Highlights the blocks while the middleware is running.\n *\n * - Sets the blocks to always on top\n * - Disables clipping of the parent of the blocks so it is visible\n */\nfunction highlightBlocksMiddleware<I, O extends Output>({\n alwaysOnTop = true,\n disableClipping = true\n}: {\n /**\n * Until disposed, should the block be always on top to be visible?\n *\n * @default true\n */\n alwaysOnTop?: boolean;\n\n /**\n * If true, the clipping of the parent of the affected blocks will be\n * temporarily disabled until unlocked.\n *\n * @default true\n */\n disableClipping?: boolean;\n}): Middleware<I, O> {\n const middleware: Middleware<I, O> = async (input, options, next) => {\n const wasAlwaysOnTop: Record<number, boolean> = {};\n const parentClipping: Record<number, boolean> = {};\n\n const blockIds =\n alwaysOnTop || disableClipping\n ? options.blockIds ?? options.engine.block.findAllSelected()\n : [];\n\n blockIds.forEach((blockId) => {\n if (options.engine.block.isValid(blockId))\n if (alwaysOnTop) {\n wasAlwaysOnTop[blockId] = options.engine.block.isAlwaysOnTop(blockId);\n options.engine.block.setAlwaysOnTop(blockId, true);\n }\n if (disableClipping) {\n const parent = options.engine.block.getParent(blockId);\n if (\n parent != null &&\n options.engine.block.getType(parent) !== '//ly.img.ubq/scene'\n ) {\n parentClipping[parent] = options.engine.block.isClipped(parent);\n options.engine.block.setClipped(parent, false);\n }\n }\n });\n\n options.addDisposer(async () => {\n blockIds.forEach((blockId) => {\n if (options.engine.block.isValid(blockId))\n if (alwaysOnTop) {\n options.engine.block.setAlwaysOnTop(\n blockId,\n wasAlwaysOnTop[blockId]\n );\n }\n if (disableClipping) {\n const parent = options.engine.block.getParent(blockId);\n if (\n parent != null &&\n options.engine.block.getType(parent) !== '//ly.img.ubq/scene'\n ) {\n if (parentClipping[parent] != null) {\n options.engine.block.setClipped(parent, parentClipping[parent]);\n }\n }\n }\n });\n });\n const result = await next(input, options);\n\n return result;\n };\n\n return middleware;\n}\n\nexport default highlightBlocksMiddleware;\n", "import { Middleware } from './middleware';\nimport { Output } from '../provider';\n\n/**\n * Sets the blocks to a pending state while the middleware is running.\n */\nfunction pendingMiddleware<I, O extends Output>({\n pending = true\n}: {\n /**\n * Should the blocks be set to a pending state?\n *\n * @default true\n */\n pending?: boolean;\n}): Middleware<I, O> {\n const middleware: Middleware<I, O> = async (input, options, next) => {\n const blockIds = pending\n ? options.blockIds ?? options.engine.block.findAllSelected()\n : [];\n\n try {\n blockIds.forEach((blockId) => {\n if (options.engine.block.isValid(blockId))\n options.engine.block.setState(blockId, {\n type: 'Pending',\n progress: 0\n });\n });\n const result = await next(input, options);\n\n return result;\n } finally {\n blockIds.forEach((blockId) => {\n if (options.engine.block.isValid(blockId))\n options.engine.block.setState(blockId, { type: 'Ready' });\n });\n }\n };\n\n return middleware;\n}\n\nexport default pendingMiddleware;\n", "import { Middleware } from './middleware';\nimport { Output } from '../provider';\nimport { CreativeEngine } from '@cesdk/cesdk-js';\nimport { isAbortError } from '../../utils';\n\n/**\n * Highlights the blocks while the middleware is running.\n */\nfunction lockMiddleware<I, O extends Output>({\n editMode,\n automaticallyUnlock = false\n}: {\n /**\n * The edit mode to lock the selection to.\n */\n editMode: string;\n\n /**\n * Should the selection be automatically unlocked after the function completes?\n * Otherwise the returned unlock function must be called manually.\n *\n * @default false\n */\n automaticallyUnlock?: boolean;\n}): Middleware<I, O> {\n const middleware: Middleware<I, O> = async (input, options, next) => {\n const blockIds = options.blockIds ?? options.engine.block.findAllSelected();\n\n let unlock: () => void = () => {};\n if (!automaticallyUnlock) {\n options.addDisposer(async () => {\n if (unlock != null) {\n unlock();\n }\n });\n }\n try {\n unlock = lockSelectionInEditMode(options.engine, blockIds, editMode);\n const result = await next(input, options);\n return result;\n } catch (error) {\n if (isAbortError(error)) {\n unlock();\n }\n throw error;\n } finally {\n if (automaticallyUnlock) {\n unlock();\n }\n }\n };\n\n return middleware;\n}\n\n/**\n * Locks the selection to the given block ids with the given edit mode.\n *\n * @returns A function to unlock the selection. Will set the edit mode back to what it was before the lock.\n */\nfunction lockSelectionInEditMode(\n engine: CreativeEngine,\n blockIdsToLockOn: number[],\n editModeToLock: string\n) {\n const globalScopeBeforeLock = engine.editor.getGlobalScope('editor/select');\n const editModeBeforeLock = engine.editor.getEditMode();\n selectOnlyBlockIds();\n engine.editor.setGlobalScope('editor/select', 'Deny');\n engine.editor.setEditMode(editModeToLock);\n const lockedHistory = engine.editor.createHistory();\n const historyBeforeLock = engine.editor.getActiveHistory();\n engine.editor.setActiveHistory(lockedHistory);\n\n function selectOnlyBlockIds() {\n engine.block.findAllSelected().forEach((currentlySelectedBlockId) => {\n if (!blockIdsToLockOn.includes(currentlySelectedBlockId)) {\n engine.block.setSelected(currentlySelectedBlockId, false);\n }\n });\n\n blockIdsToLockOn.forEach((blockId) => {\n engine.block.setSelected(blockId, true);\n });\n }\n\n const stateChangeDisposer = engine.editor.onStateChanged(() => {\n const editMode = engine.editor.getEditMode();\n if (editMode !== editModeToLock) {\n engine.editor.setEditMode(editModeToLock);\n }\n });\n\n const selectionDisposer = engine.block.onSelectionChanged(selectOnlyBlockIds);\n\n const dispose = () => {\n if (globalScopeBeforeLock != null) {\n engine.editor.setGlobalScope('editor/select', globalScopeBeforeLock);\n }\n\n engine.editor.setEditMode(editModeBeforeLock);\n engine.editor.setActiveHistory(historyBeforeLock);\n engine.editor.destroyHistory(lockedHistory);\n\n selectionDisposer();\n stateChangeDisposer();\n };\n\n return dispose;\n}\n\nexport default lockMiddleware;\n", "import type CreativeEditorSDK from '@cesdk/cesdk-js';\nimport {\n GenerationResult,\n ImageOutput,\n TextOutput,\n type Output,\n type OutputKind\n} from '../provider';\nimport { ApplyCallbacks } from './types';\nimport {\n getImageDimensionsFromURL,\n mimeTypeToExtension\n} from '@imgly/plugin-utils';\nimport { isAsyncGenerator } from '../../utils';\n\ntype ConsumeGeneratedResultOptions = {\n kind: OutputKind;\n blockIds: number[];\n cesdk: CreativeEditorSDK;\n abortSignal: AbortSignal;\n};\n\ntype ReturnValue<O extends Output> = {\n consumedGenerationResult: O;\n applyCallbacks: ApplyCallbacks;\n};\n\n/**\n * This method is used in the quick action menu to handle the result of the generation\n * and providing methods for the comparision of the result.\n *\n * Different output kinds require different handling. E.g. the text generation\n * is streamed to the text block, while the image generation is applied to the fill\n * block with a source set and the same crop applied.\n */\nfunction consumeGeneratedResult<O extends Output>(\n result: GenerationResult<O>,\n options: ConsumeGeneratedResultOptions\n): Promise<ReturnValue<O>> {\n switch (options.kind) {\n case 'text':\n return getApplyCallbacksForText(result, options);\n case 'image':\n return getApplyCallbacksForImage(result, options);\n case 'video':\n return getApplyCallbacksForVideo(result, options);\n case 'audio':\n return getApplyCallbacksForAudio(result, options);\n default:\n throw new Error(\n `Unsupported output kind for quick actions: ${options.kind}`\n );\n }\n}\n\nasync function getApplyCallbacksForText<O extends Output>(\n generationResult: GenerationResult<O>,\n options: ConsumeGeneratedResultOptions\n): Promise<ReturnValue<O>> {\n const { cesdk, blockIds, abortSignal } = options;\n\n const beforeTexts = blockIds.map((blockId) => {\n return cesdk.engine.block.getString(blockId, 'text/text');\n });\n\n let output: O | undefined;\n if (isAsyncGenerator(generationResult)) {\n let inferredText = '';\n for await (const chunk of generationResult) {\n if (abortSignal.aborted) {\n break;\n }\n if (typeof chunk === 'string') {\n inferredText = chunk;\n } else if (chunk.kind === 'text') {\n inferredText = chunk.text;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-loop-func\n blockIds.forEach((blockId) => {\n cesdk.engine.block.setString(blockId, 'text/text', inferredText);\n });\n\n const textOutput: TextOutput = {\n kind: 'text',\n text: inferredText\n };\n output = textOutput as O;\n }\n } else {\n output = generationResult;\n }\n\n if (output == null || output.kind !== 'text') {\n throw new Error('Output kind from generation is not text');\n }\n\n const onAfter = () => {\n options.blockIds.forEach((blockId) => {\n options.cesdk.engine.block.setString(blockId, 'text/text', output.text);\n });\n };\n const onBefore = () => {\n options.blockIds.forEach((blockId, i) => {\n options.cesdk.engine.block.setString(\n blockId,\n 'text/text',\n beforeTexts[i]\n );\n });\n };\n const onCancel = onBefore;\n const onApply = () => {\n onAfter();\n options.cesdk.engine.editor.addUndoStep();\n };\n\n return {\n consumedGenerationResult: output,\n applyCallbacks: {\n onBefore,\n onAfter,\n onCancel,\n onApply\n }\n };\n}\n\nasync function getApplyCallbacksForImage<O extends Output>(\n generationResult: GenerationResult<O>,\n options: ConsumeGeneratedResultOptions\n): Promise<ReturnValue<O>> {\n const { cesdk, blockIds, abortSignal } = options;\n if (blockIds.length !== 1) {\n throw new Error('Only one block is supported for image generation');\n }\n\n const [block] = blockIds;\n const fillBlock = cesdk.engine.block.getFill(block);\n const sourceSetBefore = cesdk.engine.block.getSourceSet(\n fillBlock,\n 'fill/image/sourceSet'\n );\n const [sourceBefore] = sourceSetBefore;\n let uriBefore: string | undefined;\n if (sourceBefore == null) {\n uriBefore = cesdk.engine.block.getString(\n fillBlock,\n 'fill/image/imageFileURI'\n );\n }\n\n const mimeType = await cesdk.engine.editor.getMimeType(\n sourceBefore?.uri ?? uriBefore\n );\n const originalDimension = await getImageDimensionsFromURL(\n sourceBefore?.uri ?? uriBefore,\n options.cesdk.engine\n );\n const originalAspectRatio =\n originalDimension.width / originalDimension.height;\n abortSignal.throwIfAborted();\n\n if (mimeType === 'image/svg+xml') {\n throw new Error('SVG images are not supported');\n }\n\n const cropScaleX = cesdk.engine.block.getCropScaleX(block);\n const cropScaleY = cesdk.engine.block.getCropScaleY(block);\n const cropTranslationX = cesdk.engine.block.getCropTranslationX(block);\n const cropTranslationY = cesdk.engine.block.getCropTranslationY(block);\n const cropRotation = cesdk.engine.block.getCropRotation(block);\n\n const applyCrop = () => {\n cesdk.engine.block.setCropScaleX(block, cropScaleX);\n cesdk.engine.block.setCropScaleY(block, cropScaleY);\n cesdk.engine.block.setCropTranslationX(block, cropTranslationX);\n cesdk.engine.block.setCropTranslationY(block, cropTranslationY);\n cesdk.engine.block.setCropRotation(block, cropRotation);\n };\n\n if (isAsyncGenerator(generationResult)) {\n throw new Error('Streaming generation is not supported yet from a panel');\n }\n\n if (\n generationResult.kind !== 'image' ||\n typeof generationResult.url !== 'string'\n ) {\n throw new Error('Output kind from generation is not an image');\n }\n\n const url = (generationResult as ImageOutput).url;\n const generatedMimeType = await cesdk.engine.editor.getMimeType(url);\n\n const uri = await reuploadImage(cesdk, url, generatedMimeType);\n const generatedDimension = await getImageDimensionsFromURL(\n uri,\n options.cesdk.engine\n );\n const generatedAspectRatio =\n generatedDimension.width / generatedDimension.height;\n\n const differentAspectRatio =\n Math.abs(originalAspectRatio - generatedAspectRatio) > 0.001;\n\n const sourceSetAfter = sourceBefore\n ? [\n {\n uri,\n width: generatedDimension.width,\n height: generatedDimension.height\n }\n ]\n : undefined;\n const uriAfter = uri;\n\n if (sourceSetAfter == null) {\n cesdk.engine.block.setString(\n fillBlock,\n 'fill/image/imageFileURI',\n uriAfter\n );\n } else {\n cesdk.engine.block.setString(fillBlock, 'fill/image/imageFileURI', '');\n cesdk.engine.block.setSourceSet(\n fillBlock,\n 'fill/image/sourceSet',\n sourceSetAfter\n );\n }\n if (differentAspectRatio) {\n cesdk.engine.block.setContentFillMode(block, 'Cover');\n } else {\n applyCrop();\n }\n\n const onBefore = () => {\n if (sourceSetBefore == null || sourceSetBefore.length === 0) {\n if (uriBefore == null) {\n throw new Error('No image URI found');\n }\n cesdk.engine.block.setString(\n fillBlock,\n 'fill/image/imageFileURI',\n uriBefore\n );\n } else {\n cesdk.engine.block.setSourceSet(\n fillBlock,\n 'fill/image/sourceSet',\n sourceSetBefore\n );\n }\n applyCrop();\n };\n const onAfter = () => {\n if (sourceSetAfter == null) {\n if (uriAfter == null) {\n throw new Error('No image URI found');\n }\n cesdk.engine.block.setString(\n fillBlock,\n 'fill/image/imageFileURI',\n uriAfter\n );\n } else {\n cesdk.engine.block.setSourceSet(\n fillBlock,\n 'fill/image/sourceSet',\n sourceSetAfter\n );\n }\n if (differentAspectRatio) {\n cesdk.engine.block.setContentFillMode(block, 'Cover');\n } else {\n applyCrop();\n }\n };\n const onCancel = () => {\n onBefore();\n };\n const onApply = () => {\n onAfter();\n options.cesdk.engine.editor.addUndoStep();\n };\n\n return {\n consumedGenerationResult: generationResult,\n applyCallbacks: {\n onBefore,\n onAfter,\n onCancel,\n onApply\n }\n };\n}\n\nasync function getApplyCallbacksForVideo<O extends Output>(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _result: GenerationResult<O>,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _options: ConsumeGeneratedResultOptions\n): Promise<ReturnValue<O>> {\n throw new Error('Function not implemented.');\n}\n\nasync function getApplyCallbacksForAudio<O extends Output>(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _result: GenerationResult<O>,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _options: ConsumeGeneratedResultOptions\n): Promise<ReturnValue<O>> {\n throw new Error('Function not implemented.');\n}\n\nasync function reuploadImage(\n cesdk: CreativeEditorSDK,\n url: string,\n mimeType: string\n): Promise<string> {\n const response = await fetch(url);\n const blob = await response.blob();\n const file = new File([blob], `image.${mimeTypeToExtension(mimeType)}`, {\n type: mimeType\n });\n const assetDefinition = await cesdk.unstable_upload(file, () => {});\n const uploadedUri = assetDefinition?.meta?.uri;\n if (uploadedUri != null) return uploadedUri;\n // eslint-disable-next-line no-console\n console.warn('Failed to upload image:', assetDefinition);\n return url;\n}\n\nexport default consumeGeneratedResult;\n", "import { Middleware } from './middleware';\nimport { Output } from '../provider';\nimport { CreativeEngine } from '@cesdk/cesdk-js';\nimport { isAbortError } from '../../utils';\n\n/**\n * For a given edit mode and block ids, this middleware will\n * ensure that as long as these blocks are selected, the edit mode is\n * set to the given edit mode and cannot be changed.\n *\n * The use-case is to show only the generation canvas menu during\n * the generation process.\n */\nfunction editModeMiddleware<I, O extends Output>({\n editMode,\n automaticallyUnlock = false,\n showNotification = true\n}: {\n /**\n * The edit mode to lock the selection to.\n */\n editMode: string;\n\n /**\n * Should the selection be automatically unlocked after the function completes?\n * Otherwise the returned unlock function must be called manually.\n *\n * @default false\n */\n automaticallyUnlock?: boolean;\n\n /**\n * Should the blocks be set when the generation is done\n *\n * @default true\n */\n showNotification?: boolean;\n}): Middleware<I, O> {\n const middleware: Middleware<I, O> = async (input, options, next) => {\n const blockIds = options.blockIds ?? options.engine.block.findAllSelected();\n\n let unlock: () => void = () => {};\n if (!automaticallyUnlock) {\n options.addDisposer(async () => {\n if (unlock != null) {\n unlock();\n }\n });\n }\n try {\n unlock = bindSelectionToEditMode(options.engine, blockIds, editMode);\n const result = await next(input, options);\n\n if (showNotification) {\n const currentlySelectedBlockIds =\n options.engine.block.findAllSelected();\n const blockIdsAreSelected = blockIds.some((blockId) => {\n return currentlySelectedBlockIds.includes(blockId);\n });\n\n if (!blockIdsAreSelected) {\n options.cesdk?.ui.showNotification({\n type: 'success',\n message: 'AI generation complete',\n action: {\n label: 'Select',\n onClick: () => {\n blockIds.forEach((blockId) => {\n options.engine.block.select(blockId);\n });\n }\n }\n });\n }\n }\n return result;\n } catch (error) {\n if (isAbortError(error)) {\n unlock();\n }\n throw error;\n } finally {\n if (automaticallyUnlock) {\n unlock();\n }\n }\n };\n\n return middleware;\n}\n\n/**\n * Locks the selection to the given block ids with the given edit mode.\n *\n * @returns A function to unlock the selection. Will set the edit mode back to what it was before the lock.\n */\nfunction bindSelectionToEditMode(\n engine: CreativeEngine,\n blockIdsToBind: number[],\n editModeToBindTo: string\n) {\n function isBoundBlockSelected() {\n const currentlySelectedBlockIds = engine.block.findAllSelected();\n return blockIdsToBind.some((blockId) => {\n return currentlySelectedBlockIds.includes(blockId);\n });\n }\n\n const stateChangeDisposer = engine.editor.onStateChanged(() => {\n const editMode = engine.editor.getEditMode();\n if (editMode !== editModeToBindTo && isBoundBlockSelected()) {\n engine.editor.setEditMode(editModeToBindTo);\n }\n });\n\n const selectionDisposer = engine.block.onSelectionChanged(() => {\n if (isBoundBlockSelected()) {\n engine.editor.setEditMode(editModeToBindTo);\n } else {\n engine.editor.setEditMode('Transform');\n }\n });\n\n if (isBoundBlockSelected()) {\n engine.editor.setEditMode(editModeToBindTo);\n }\n\n const dispose = () => {\n selectionDisposer();\n stateChangeDisposer();\n\n engine.editor.setEditMode('Transform');\n };\n\n return dispose;\n}\n\nexport default editModeMiddleware;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { InferenceMetadata, QuickActionMenu, ApplyCallbacks } from './types';\nimport { INFERENCE_AI_EDIT_MODE, INFERENCE_AI_METADATA_KEY } from './utils';\nimport { Metadata } from '@imgly/plugin-utils';\nimport Provider, {\n GenerationOptions,\n Output,\n OutputKind,\n QuickAction\n} from '../provider';\nimport { composeMiddlewares } from '../middleware/middleware';\nimport loggingMiddleware from '../middleware/loggingMiddleware';\nimport highlightBlocksMiddleware from '../middleware/highlightBlocksMiddleware';\nimport pendingMiddleware from '../middleware/pendingMiddleware';\nimport lockMiddleware from '../middleware/lockMiddleware';\nimport consumeGeneratedResult from './consumeGeneratedResult';\nimport editModeMiddleware from '../middleware/editModeMiddleware';\nimport { InitProviderConfiguration } from '../types';\nimport dryRunMiddleware from '../middleware/dryRunMiddleware';\n\nasync function generate<K extends OutputKind, I, O extends Output>(\n options: {\n input: I;\n blockIds: number[];\n cesdk: CreativeEditorSDK;\n quickAction: QuickAction<I, O>;\n quickActionMenu: QuickActionMenu;\n provider: Provider<K, I, O>;\n abortSignal: AbortSignal;\n confirmationComponentId: string;\n },\n config: InitProviderConfiguration\n): Promise<{\n dispose: () => void;\n returnValue: O;\n applyCallbacks?: ApplyCallbacks;\n}> {\n const {\n cesdk,\n input,\n blockIds,\n provider,\n quickAction,\n confirmationComponentId,\n abortSignal\n } = options;\n if (quickAction.confirmation) {\n cesdk.ui.setCanvasMenuOrder([confirmationComponentId], {\n editMode: INFERENCE_AI_EDIT_MODE\n });\n }\n\n const metadata = new Metadata<InferenceMetadata>(\n cesdk.engine,\n INFERENCE_AI_METADATA_KEY\n );\n blockIds.forEach((blockId) => {\n metadata.set(blockId, {\n status: 'processing',\n quickActionId: quickAction.id\n });\n });\n\n const generationOptions: GenerationOptions = {\n cesdk,\n engine: cesdk.engine,\n abortSignal\n };\n\n const composedMiddlewares = composeMiddlewares<I, O>([\n ...(provider.output.middleware ?? []),\n config.debug ? loggingMiddleware() : undefined,\n pendingMiddleware({}),\n ...(quickAction.confirmation\n ? [\n quickAction.lockDuringConfirmation\n ? lockMiddleware<I, O>({\n editMode: INFERENCE_AI_EDIT_MODE\n })\n : editModeMiddleware<I, O>({\n editMode: INFERENCE_AI_EDIT_MODE\n }),\n quickAction.confirmation && highlightBlocksMiddleware<I, O>({})\n ]\n : []),\n config.dryRun\n ? dryRunMiddleware({ kind: provider.kind, blockIds })\n : undefined\n ]);\n\n const { result: generationResult, dispose: generationDispose } =\n await composedMiddlewares(provider.output.generate)(\n input,\n generationOptions\n );\n\n const { consumedGenerationResult, applyCallbacks } =\n await consumeGeneratedResult(generationResult, {\n abortSignal,\n kind: provider.kind,\n blockIds,\n cesdk\n });\n\n if (quickAction.confirmation) {\n blockIds.forEach((blockId) => {\n metadata.set(blockId, {\n status: 'confirmation',\n quickActionId: quickAction.id\n });\n });\n } else {\n applyCallbacks.onApply();\n blockIds.forEach((blockId) => {\n metadata.clear(blockId);\n });\n }\n\n const dispose = () => {\n generationDispose();\n blockIds.forEach((blockId) => {\n metadata.clear(blockId);\n });\n };\n\n abortSignal.addEventListener('abort', dispose);\n\n return {\n dispose,\n returnValue: consumedGenerationResult,\n applyCallbacks\n };\n}\n\nexport default generate;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { InferenceMetadata, QuickActionMenu, ApplyCallbacks } from './types';\nimport {\n getFeatureIdForQuickAction,\n INFERENCE_AI_METADATA_KEY,\n removeDuplicatedSeparators\n} from './utils';\nimport { Metadata } from '@imgly/plugin-utils';\nimport Provider, { Output, OutputKind } from '../provider';\nimport { isAbortError } from '../../utils';\nimport { InitProviderConfiguration } from '../types';\nimport handleGenerationError from '../handleGenerationError';\nimport generate from './generate';\n\nfunction registerQuickActionMenuComponent<\n K extends OutputKind,\n I,\n O extends Output\n>(\n options: {\n cesdk: CreativeEditorSDK;\n quickActionMenu: QuickActionMenu;\n provider: Provider<K, I, O>;\n },\n config: InitProviderConfiguration\n) {\n const { cesdk, quickActionMenu, provider } = options;\n\n const prefix = `ly.img.ai.${quickActionMenu.id}`;\n const confirmationPrefix = `${prefix}.confirmation`;\n cesdk.setTranslations({\n en: {\n [`${confirmationPrefix}.apply`]: 'Apply',\n [`${confirmationPrefix}.before`]: 'Before',\n [`${confirmationPrefix}.after`]: 'After',\n [`${prefix}.cancel`]: 'Cancel',\n [`${prefix}.processing`]: 'Generating...'\n }\n });\n const confirmationComponentId = `${confirmationPrefix}.canvasnMenu`;\n\n const shared: {\n unlock: () => void;\n abort: () => void;\n applyCallbacks: ApplyCallbacks | undefined;\n } = {\n unlock: () => {},\n abort: () => {},\n applyCallbacks: undefined\n };\n\n const createAbortSignal = () => {\n const controller = new AbortController();\n const signal = controller.signal;\n shared.abort = () => {\n controller.abort();\n };\n return signal;\n };\n\n cesdk.ui.registerComponent(\n confirmationComponentId,\n ({ builder, engine, state }) => {\n const blockIds = engine.block.findAllSelected();\n if (blockIds.length === 0) return null;\n\n const md = new Metadata<InferenceMetadata>(\n cesdk.engine,\n INFERENCE_AI_METADATA_KEY\n );\n\n // All blocks must have the same metadata\n const metadata = md.get(blockIds[0]);\n if (metadata == null) return null;\n\n const clearMetadata = () => {\n blockIds.forEach((blockId) => {\n md.clear(blockId);\n });\n };\n\n switch (metadata.status) {\n case 'processing': {\n builder.Button(`${prefix}.spinner`, {\n label: [\n `ly.img.ai.inference.${metadata.quickActionId}.processing`,\n `${prefix}.cancel`\n ],\n isLoading: true\n });\n builder.Separator(`${prefix}.separator`);\n builder.Button(`${prefix}.cancel`, {\n icon: '@imgly/Cross',\n tooltip: `${prefix}.cancel`,\n onClick: () => {\n shared.abort();\n clearMetadata();\n }\n });\n\n break;\n }\n\n case 'confirmation': {\n const comparingState = state<'before' | 'after'>(\n `${confirmationPrefix}.comparing`,\n 'after'\n );\n\n const onCancel = shared.applyCallbacks?.onCancel;\n if (onCancel != null) {\n builder.Button(`${confirmationPrefix}.cancel`, {\n icon: '@imgly/Cross',\n tooltip: `${prefix}.cancel`,\n onClick: () => {\n shared.unlock();\n onCancel();\n clearMetadata();\n }\n });\n }\n\n const onBefore = shared.applyCallbacks?.onBefore;\n const onAfter = shared.applyCallbacks?.onAfter;\n\n if (onBefore != null && onAfter != null) {\n builder.ButtonGroup(`${confirmationPrefix}.compare`, {\n children: () => {\n builder.Button(`${confirmationPrefix}.compare.before`, {\n label: `${confirmationPrefix}.before`,\n variant: 'regular',\n isActive: comparingState.value === 'before',\n onClick: () => {\n onBefore();\n comparingState.setValue('before');\n }\n });\n builder.Button(`${confirmationPrefix}.compare.after`, {\n label: `${confirmationPrefix}.after`,\n variant: 'regular',\n isActive: comparingState.value === 'after',\n onClick: () => {\n onAfter();\n comparingState.setValue('after');\n }\n });\n }\n });\n }\n\n const onApply = shared.applyCallbacks?.onApply;\n if (onApply != null) {\n builder.Button(`${confirmationPrefix}.apply`, {\n icon: '@imgly/Checkmark',\n tooltip: `${confirmationPrefix}.apply`,\n color: 'accent',\n isDisabled: comparingState.value !== 'after',\n onClick: () => {\n shared.unlock();\n clearMetadata();\n\n // Activating the old history happens in the next update lop.\n // @ts-ignore\n cesdk.engine.editor._update();\n\n onApply();\n }\n });\n }\n\n break;\n }\n\n default: {\n // noop\n }\n }\n }\n );\n\n const canvasMenuComponentId = `${prefix}.canvasMenu`;\n cesdk.ui.registerComponent(canvasMenuComponentId, (context) => {\n const blockIds = context.engine.block.findAllSelected();\n const isEveryBlockInReadyState = blockIds.every((blockId) => {\n return context.engine.block.getState(blockId).type === 'Ready';\n });\n\n let quickActions = quickActionMenu\n .getQuickActionMenuOrder()\n .map((quickActionId) => {\n if (quickActionId === 'ly.img.separator') return quickActionId;\n const quickAction = quickActionMenu.getQuickAction<I, O>(quickActionId);\n if (quickAction == null) return null;\n\n const isEnabled = cesdk.feature.isEnabled(\n getFeatureIdForQuickAction({\n quickActionId,\n quickActionMenuId: quickActionMenu.id\n }),\n {\n engine: context.engine\n }\n );\n if (!isEnabled) return null;\n\n const scopes = quickAction.scopes;\n if (scopes != null && scopes.length > 0) {\n const isAllowedByScopes = blockIds.every((blockId) => {\n return scopes.every((scope) => {\n return context.engine.block.isAllowedByScope(blockId, scope);\n });\n });\n if (!isAllowedByScopes) return null;\n }\n return quickAction;\n })\n .filter((entry) => entry != null);\n\n quickActions = removeDuplicatedSeparators(quickActions);\n\n if (\n quickActions.length === 0 ||\n quickActions.every((entry) => entry === 'ly.img.separator')\n ) {\n return null;\n }\n\n const { builder, experimental, state } = context;\n const toggleExpandedState = state<string | undefined>(\n `${prefix}.toggleExpandedState`,\n undefined\n );\n\n experimental.builder.Popover(`${prefix}.popover`, {\n icon: '@imgly/Sparkle',\n variant: 'plain',\n isDisabled: !isEveryBlockInReadyState,\n trailingIcon: null,\n children: ({ close }) => {\n builder.Section(`${prefix}.popover.section`, {\n children: () => {\n if (toggleExpandedState.value != null) {\n const expandStateForQuickActionId = toggleExpandedState.value;\n const quickAction = quickActionMenu.getQuickAction<I, O>(\n expandStateForQuickActionId\n );\n\n if (quickAction != null && quickAction.renderExpanded != null) {\n quickAction.renderExpanded(context, {\n blockIds,\n closeMenu: close,\n toggleExpand: () => {\n toggleExpandedState.setValue(undefined);\n },\n handleGenerationError: (error) => {\n handleGenerationError(\n error,\n {\n cesdk,\n provider\n },\n config\n );\n },\n generate: async (input, generateOptions) => {\n try {\n const { returnValue, applyCallbacks, dispose } =\n await generate(\n {\n input,\n quickAction,\n quickActionMenu,\n provider,\n cesdk,\n abortSignal: createAbortSignal(),\n blockIds: generateOptions?.blockIds ?? blockIds,\n confirmationComponentId\n },\n config\n );\n\n shared.unlock = dispose;\n shared.applyCallbacks = applyCallbacks;\n\n return returnValue;\n } catch (error) {\n if (!isAbortError(error)) {\n handleGenerationError(\n error,\n {\n cesdk,\n provider\n },\n config\n );\n }\n throw error;\n }\n }\n });\n\n return;\n }\n }\n\n experimental.builder.Menu(`${prefix}.menu`, {\n children: () => {\n quickActions.forEach((quickAction) => {\n if (quickAction === 'ly.img.separator') {\n builder.Separator(\n `${prefix}.separator.${Math.random().toString()}`\n );\n } else {\n quickAction.render(context, {\n blockIds,\n closeMenu: close,\n handleGenerationError: (error) => {\n handleGenerationError(\n error,\n {\n cesdk,\n provider\n },\n config\n );\n },\n toggleExpand: () => {\n toggleExpandedState.setValue(quickAction.id);\n },\n generate: async (input, generateOptions) => {\n try {\n const { returnValue, applyCallbacks, dispose } =\n await generate(\n {\n input,\n quickAction,\n quickActionMenu,\n provider,\n cesdk,\n abortSignal: createAbortSignal(),\n blockIds: generateOptions?.blockIds ?? blockIds,\n confirmationComponentId\n },\n config\n );\n\n shared.unlock = dispose;\n shared.applyCallbacks = applyCallbacks;\n return returnValue;\n } catch (error) {\n if (!isAbortError(error)) {\n handleGenerationError(\n error,\n {\n cesdk,\n provider\n },\n config\n );\n }\n throw error;\n }\n }\n });\n }\n });\n }\n });\n }\n });\n }\n });\n });\n\n return { canvasMenuComponentId };\n}\n\nexport default registerQuickActionMenuComponent;\n", "import type Provider from './provider';\nimport {\n OutputKind,\n PanelInput,\n QuickActionsInput,\n type Output\n} from './provider';\nimport registerPanelInputSchema from './registerPanelInputSchema';\nimport registerPanelInputCustom from './registerPanelInputCustom';\nimport { InitProviderConfiguration, Options, UIOptions } from './types';\nimport { BuilderRenderFunction, type CreativeEngine } from '@cesdk/cesdk-js';\nimport { IndexedDBAssetSource } from '@imgly/plugin-utils';\nimport icons from '../icons';\nimport getQuickActionMenu from './quickAction/getQuickActionMenu';\nimport { getFeatureIdForQuickAction } from './quickAction/utils';\nimport registerQuickActionMenuComponent from './quickAction/registerQuickActionMenuComponent';\nimport { QuickActionMenu } from './quickAction/types';\n\ntype RenderBuilderFunctions = {\n panel?: BuilderRenderFunction<any>;\n};\n\n/**\n * Initialize the provider. Based on the given options and configuration\n * it will register panels and components that is used to render\n * the provider in the UI.\n *\n * @param provider The provider to initialize.\n * @param options The options to use for the provider.\n * @param config The configuration to use for the provider.\n */\nasync function initProvider<K extends OutputKind, I, O extends Output>(\n provider: Provider<K, I, O>,\n options: Options,\n config: InitProviderConfiguration\n): Promise<{\n renderBuilderFunctions?: RenderBuilderFunctions;\n}> {\n await provider.initialize?.(options);\n const historyAssetSourceId = await initHistory(\n options.engine,\n provider.id,\n provider.output.history ?? '@imgly/local'\n );\n\n if (options.cesdk == null) {\n return {};\n }\n\n const historyAssetLibraryEntryId = historyAssetSourceId\n ? `${provider.id}.history.entry`\n : undefined;\n const uiOptions: UIOptions = {\n ...options,\n cesdk: options.cesdk,\n historyAssetSourceId,\n historyAssetLibraryEntryId,\n i18n: {\n prompt: 'common.ai-generation.prompt.placeholder'\n }\n };\n\n if (historyAssetLibraryEntryId != null && historyAssetSourceId != null) {\n options.cesdk.ui.addAssetLibraryEntry({\n id: historyAssetLibraryEntryId,\n sourceIds: [historyAssetSourceId],\n sortBy: {\n sortKey: 'insertedAt',\n sortingOrder: 'Descending'\n },\n canRemove: true,\n gridItemHeight: 'square',\n gridBackgroundType: 'cover'\n });\n }\n\n options.cesdk.i18n.setTranslations({\n en: {\n 'common.ai-generation.success': 'Generation Successful',\n 'common.ai-generation.failed': 'Generation Failed',\n 'common.ai-generation.generate': 'Generate',\n 'common.ai-generation.prompt.placeholder':\n 'Describe what you want to create...',\n [`panel.${provider.id}`]: getName(provider)\n }\n });\n\n // Avoid adding the icon set multiple times for different providers\n const globalStateIconSetAddedId = `@imgly/plugin-ai-generation.iconSetAdded`;\n if (\n !options.cesdk.ui.experimental.hasGlobalStateValue(\n globalStateIconSetAddedId\n )\n ) {\n options.cesdk.ui.addIconSet('@imgly/plugin-ai-generation', icons);\n options.cesdk.ui.experimental.setGlobalStateValue(\n globalStateIconSetAddedId,\n true\n );\n }\n\n const renderBuilderFunctions = await initInputs(provider, uiOptions, config);\n\n return {\n renderBuilderFunctions\n };\n}\n\nfunction getName(provider: Provider<any, any, any>): string {\n if (provider.name != null) return provider.name;\n switch (provider.kind) {\n case 'image':\n return 'Generate Image';\n case 'video':\n return 'Generate Video';\n case 'audio':\n return 'Generate Audio';\n default:\n return 'Generate Asset';\n }\n}\n\n/**\n * Initialize the history for the provider.\n */\nasync function initHistory(\n engine: CreativeEngine,\n providerId: string,\n history: undefined | false | '@imgly/local' | '@imgly/indexedDB' | string\n): Promise<string | undefined> {\n if (history == null || history === false) return undefined;\n\n if (history === '@imgly/local') {\n const historyId = `${providerId}.history`;\n engine.asset.addLocalSource(historyId);\n return historyId;\n }\n\n if (history === '@imgly/indexedDB') {\n const historyId = `${providerId}.history`;\n engine.asset.addSource(new IndexedDBAssetSource(historyId, engine));\n return historyId;\n }\n\n return history;\n}\n\nasync function initInputs<K extends OutputKind, I, O extends Output>(\n provider: Provider<K, I, O>,\n options: UIOptions,\n config: InitProviderConfiguration\n): Promise<{\n panel?: BuilderRenderFunction<any>;\n}> {\n const result: {\n panel?: BuilderRenderFunction<any>;\n } = {\n panel: undefined\n };\n\n if (provider.input?.panel != null) {\n result.panel = await initPanel(\n provider,\n provider.input.panel,\n options,\n config\n );\n }\n if (provider.input?.quickActions != null) {\n if (config.debug) {\n // eslint-disable-next-line no-console\n console.log(\n `Initializing quick actions for provider '${provider.kind}' (${provider.id})`\n );\n }\n initQuickActions(provider, provider.input.quickActions, options, config);\n }\n\n return result;\n}\n\nasync function initPanel<K extends OutputKind, I, O extends Output>(\n provider: Provider<K, I, O>,\n panelInput: PanelInput<K, I>,\n options: UIOptions,\n config: InitProviderConfiguration\n): Promise<BuilderRenderFunction<any> | undefined> {\n switch (panelInput.type) {\n case 'custom': {\n return registerPanelInputCustom(provider, panelInput, options, config);\n }\n\n case 'schema': {\n return registerPanelInputSchema(provider, panelInput, options, config);\n }\n\n default: {\n if (config.debug) {\n // eslint-disable-next-line no-console\n console.warn(\n // @ts-ignore\n `Invalid panel input type '${panelInput.type}' - skipping`\n );\n }\n }\n }\n}\n\nasync function initQuickActions<K extends OutputKind, I, O extends Output>(\n provider: Provider<K, I, O>,\n quickActionsInput: QuickActionsInput<I, O>,\n options: UIOptions,\n config: InitProviderConfiguration\n) {\n const { cesdk } = options;\n\n const quickActionMenus: { [kind: string]: QuickActionMenu } = {};\n\n quickActionsInput.actions.forEach((quickAction) => {\n const quickActionMenuId = quickAction.kind ?? provider.kind;\n if (quickActionMenus[quickActionMenuId] == null) {\n quickActionMenus[quickActionMenuId] = getQuickActionMenu(\n cesdk,\n quickActionMenuId\n );\n }\n const quickActionMenu = quickActionMenus[quickActionMenuId];\n\n const enable = quickAction.enable ?? true;\n cesdk.feature.enable(\n getFeatureIdForQuickAction({\n quickActionId: quickAction.id,\n quickActionMenuId\n }),\n enable\n );\n quickActionMenu.registerQuickAction(quickAction);\n if (config.debug) {\n // eslint-disable-next-line no-console\n console.log(\n `Registered quick action: '${quickAction.id}' (v${quickAction.version}) to menu '${quickActionMenuId}'`\n );\n }\n });\n\n Object.values(quickActionMenus).forEach((quickActionMenu) => {\n const { canvasMenuComponentId } = registerQuickActionMenuComponent(\n {\n cesdk,\n quickActionMenu,\n provider\n },\n config\n );\n if (config.debug) {\n // eslint-disable-next-line no-console\n console.log(\n `Registered quick action menu component: ${canvasMenuComponentId}`\n );\n }\n });\n}\n\nexport default initProvider;\n", "import { isAsyncGenerator } from '../../utils';\nimport { GenerationResult, Output } from '../provider';\nimport { Middleware } from './middleware';\n\n/**\n * Middleware to upload the output of a generation process.\n *\n * Sometimes it is not possible to use the result of a provider or\n * not even allowed to use it directly. This middleware allows you to upload\n * the result of a generation process to a server or a cloud storage.\n *\n * @param upload The function to upload the output. It should return a promise\n */\nfunction uploadMiddleware<I, O extends Output>(\n upload: (output: O) => Promise<O>\n) {\n const middleware: Middleware<I, O> = async (input, options, next) => {\n const result: GenerationResult<O> | undefined = await next(input, options);\n if (isAsyncGenerator(result)) {\n // No reupload needed, just return the async generator\n return result;\n }\n\n const uploaded = await upload(result);\n return uploaded;\n };\n\n return middleware;\n}\n\nexport default uploadMiddleware;\n", "import { GenerationOptions, Output } from '../provider';\nimport { Middleware } from './middleware';\n\nexport interface RateLimitOptions<I> {\n /**\n * Maximum number of requests allowed in the time window\n */\n maxRequests: number;\n\n /**\n * Time window in milliseconds\n */\n timeWindowMs: number;\n\n /**\n * Optional key function or string to create different rate limits for different inputs\n * - If not provided, all requests share the same 'global' rate limit\n * - If a string is provided, that string is used as a static key\n * - If a function is provided, it generates a key based on input and options\n */\n keyFn?: string | ((input: I, options: GenerationOptions) => string);\n\n /**\n * Callback function that is called when rate limit is exceeded\n * Return value determines if the operation should be rejected (throw error) or allowed\n * If true is returned, the operation will proceed despite exceeding the rate limit\n * If false or undefined is returned, the operation will be rejected with a default error\n */\n onRateLimitExceeded?: (\n input: I,\n options: GenerationOptions,\n rateLimitInfo: {\n key: string;\n currentCount: number;\n maxRequests: number;\n timeWindowMs: number;\n remainingTimeMs: number;\n }\n ) => boolean | Promise<boolean> | void;\n\n /**\n * Optional database name for the IndexedDB store\n * If not provided, a default name will be used\n */\n dbName?: string;\n\n /**\n * Disable the rate limit middleware\n */\n disable?: boolean | (() => boolean);\n}\n\n// Store for tracking requests per key\ninterface RequestTracker {\n timestamps: number[];\n lastCleanup: number;\n}\n\n// In-memory fallback store for rate limits for environments without IndexedDB\n// Export for testing purposes\n// This is now a Map of middleware instances to their respective stores\n// The key can be either a symbol (for unique instances with prefix) or a string (for shared instances without prefix)\nexport const inMemoryStores: Map<\n symbol | string,\n Record<string, RequestTracker>\n> = new Map();\n\n/**\n * IndexedDB store for rate limiting\n */\nclass RateLimitStore {\n private db: IDBDatabase | null = null;\n\n private readonly dbName: string;\n\n private readonly storeName: string;\n\n private readonly dbVersion: number = 1;\n\n private isInitializing: boolean = false;\n\n private initPromise: Promise<void> | null = null;\n\n private readonly instanceId: symbol | string;\n\n constructor(\n instanceId: symbol | string,\n dbName?: string,\n storeName?: string\n ) {\n this.instanceId = instanceId;\n this.dbName = dbName ?? 'ly.img.ai.rateLimit';\n this.storeName = storeName ?? 'rateLimits';\n }\n\n /**\n * Initialize the database connection\n */\n async initialize(): Promise<void> {\n if (this.db) {\n return;\n }\n\n if (this.isInitializing) {\n return this.initPromise!;\n }\n\n this.isInitializing = true;\n this.initPromise = new Promise<void>((resolve, reject) => {\n try {\n const request = indexedDB.open(this.dbName, this.dbVersion);\n\n request.onerror = (event) => {\n this.isInitializing = false;\n\n // eslint-disable-next-line no-console\n console.error('Failed to open IndexedDB for rate limiting:', event);\n reject(new Error('Failed to open IndexedDB for rate limiting'));\n };\n\n request.onupgradeneeded = (event) => {\n const db = (event.target as IDBOpenDBRequest).result;\n if (!db.objectStoreNames.contains(this.storeName)) {\n db.createObjectStore(this.storeName, { keyPath: 'id' });\n }\n };\n\n request.onsuccess = (event) => {\n this.db = (event.target as IDBOpenDBRequest).result;\n this.isInitializing = false;\n resolve();\n };\n } catch (error) {\n this.isInitializing = false;\n // eslint-disable-next-line no-console\n console.error('Error initializing IndexedDB:', error);\n reject(error);\n }\n });\n\n return this.initPromise;\n }\n\n /**\n * Get a request tracker by key\n */\n async getTracker(key: string): Promise<RequestTracker | null> {\n try {\n await this.initialize();\n\n // Create a combined key that includes the instance ID to ensure isolation\n const instanceIdStr =\n typeof this.instanceId === 'symbol'\n ? this.instanceId.description || ''\n : this.instanceId;\n const combinedKey = `${instanceIdStr}_${key}`;\n\n return await new Promise((resolve, reject) => {\n const transaction = this.db!.transaction(this.storeName, 'readonly');\n const store = transaction.objectStore(this.storeName);\n const request = store.get(combinedKey);\n\n request.onsuccess = () => {\n if (request.result) {\n resolve(request.result.data);\n } else {\n resolve(null);\n }\n };\n\n request.onerror = () => {\n // eslint-disable-next-line no-console\n console.error(\n `Failed to get tracker for key ${combinedKey}:`,\n request.error\n );\n reject(request.error);\n };\n });\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error getting tracker from IndexedDB:', error);\n return Promise.reject(error);\n }\n }\n\n /**\n * Save a request tracker by key\n */\n async saveTracker(key: string, tracker: RequestTracker): Promise<void> {\n try {\n await this.initialize();\n\n // Create a combined key that includes the instance ID to ensure isolation\n const instanceIdStr =\n typeof this.instanceId === 'symbol'\n ? this.instanceId.description || ''\n : this.instanceId;\n const combinedKey = `${instanceIdStr}_${key}`;\n\n return await new Promise((resolve, reject) => {\n const transaction = this.db!.transaction(this.storeName, 'readwrite');\n const store = transaction.objectStore(this.storeName);\n store.put({ id: combinedKey, data: tracker });\n\n transaction.oncomplete = () => {\n resolve();\n };\n\n transaction.onerror = () => {\n // eslint-disable-next-line no-console\n console.error(\n `Failed to save tracker for key ${combinedKey}:`,\n transaction.error\n );\n reject(transaction.error);\n };\n });\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error saving tracker to IndexedDB:', error);\n return Promise.reject(error);\n }\n }\n\n /**\n * Check if IndexedDB is available\n */\n static isAvailable(): boolean {\n return typeof indexedDB !== 'undefined';\n }\n\n /**\n * Close the database connection\n */\n close(): void {\n if (this.db) {\n this.db.close();\n this.db = null;\n }\n }\n}\n\n/**\n * Middleware that implements rate limiting for AI generation requests\n * Uses IndexedDB for storage when available, with in-memory fallback\n * Each middleware instance has its own isolated set of rate limits\n */\nfunction rateLimitMiddleware<I, O extends Output>(\n middlewareOptions: RateLimitOptions<I>\n) {\n const {\n maxRequests,\n timeWindowMs,\n keyFn = () => 'global',\n onRateLimitExceeded,\n dbName\n } = middlewareOptions;\n\n // Create an identifier for this middleware instance based on its configuration\n // This ensures persistence across page reloads and sharing between identical configurations\n const configStr = `rate-limit-middleware-${maxRequests}-${timeWindowMs}`;\n\n // Use a string key for the configuration so identical configurations share the same limits\n const instanceId = configStr;\n\n // Create the store with the instance ID\n const useIndexedDB = RateLimitStore.isAvailable();\n const store = useIndexedDB ? new RateLimitStore(instanceId, dbName) : null;\n\n // Initialize this middleware's in-memory store\n if (!inMemoryStores.has(instanceId)) {\n inMemoryStores.set(instanceId, {});\n }\n // Get this middleware's in-memory store\n const inMemoryStore = inMemoryStores.get(instanceId)!;\n\n const middleware: Middleware<I, O> = async (input, options, next) => {\n if (\n typeof middlewareOptions.disable === 'function'\n ? middlewareOptions.disable()\n : middlewareOptions.disable\n ) {\n return next(input, options);\n }\n // Get rate limit key based on input using the provided keyFn\n // If keyFn is a string, use it directly; otherwise call the function\n const key = typeof keyFn === 'string' ? keyFn : keyFn(input, options);\n const now = Date.now();\n\n let tracker: RequestTracker;\n\n // Get tracker from IndexedDB or create a new one\n if (useIndexedDB && store) {\n try {\n const storedTracker = await store.getTracker(key);\n if (storedTracker) {\n tracker = storedTracker;\n } else {\n tracker = {\n timestamps: [],\n lastCleanup: now\n };\n }\n } catch (error) {\n // Fallback to in-memory store if IndexedDB fails\n // eslint-disable-next-line no-console\n console.error(\n 'IndexedDB access failed, using in-memory fallback:',\n error\n );\n if (!inMemoryStore[key]) {\n inMemoryStore[key] = {\n timestamps: [],\n lastCleanup: now\n };\n }\n tracker = inMemoryStore[key];\n }\n } else {\n // Use in-memory store if IndexedDB is not available\n if (!inMemoryStore[key]) {\n inMemoryStore[key] = {\n timestamps: [],\n lastCleanup: now\n };\n }\n tracker = inMemoryStore[key];\n }\n\n // Clean up old timestamps that are outside the time window\n if (now - tracker.lastCleanup > timeWindowMs) {\n tracker.timestamps = tracker.timestamps.filter(\n (timestamp) => now - timestamp < timeWindowMs\n );\n tracker.lastCleanup = now;\n }\n\n // Check if rate limit is exceeded\n if (tracker.timestamps.length >= maxRequests) {\n // Calculate the time until the oldest request expires\n const oldestTimestamp = Math.min(...tracker.timestamps);\n const remainingTimeMs = Math.max(\n 0,\n timeWindowMs - (now - oldestTimestamp)\n );\n\n // Call the rate limit exceeded callback if provided\n if (onRateLimitExceeded) {\n const rateLimitInfo = {\n key, // This is the baseKey from keyFn\n currentCount: tracker.timestamps.length,\n maxRequests,\n timeWindowMs,\n remainingTimeMs\n };\n\n // If callback returns true, allow the request to proceed\n const shouldProceed = await onRateLimitExceeded(\n input,\n options,\n rateLimitInfo\n );\n if (!shouldProceed) {\n // The callback should indicate the error, so we throw\n // an abort error instead of a generic error to indicate\n // the generation was aborted and we do not show any further\n // error notification.\n throw new DOMException(\n 'Operation aborted: Rate limit exceeded',\n 'AbortError'\n );\n }\n } else {\n // Default behavior: throw an error\n throw new Error('Rate limit exceeded. Please try again later.');\n }\n }\n\n // Add current timestamp to the tracker\n tracker.timestamps.push(now);\n\n // Save the updated tracker\n if (useIndexedDB && store) {\n try {\n await store.saveTracker(key, tracker);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Failed to save tracker to IndexedDB:', error);\n // In case of IndexedDB failure, update the in-memory store as fallback\n inMemoryStore[key] = tracker;\n }\n } else {\n inMemoryStore[key] = tracker;\n }\n\n // Continue with the next middleware\n return next(input, options);\n };\n\n return middleware;\n}\n\nexport default rateLimitMiddleware;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\n\n/**\n * Registers a dock component for AI generation that opens\n * the AI generation panel and closes any other AI panels.\n */\nfunction registerDockComponent(options: {\n cesdk: CreativeEditorSDK;\n panelId: string;\n}) {\n const { cesdk, panelId } = options;\n if (panelId.startsWith('ly.img.ai/')) {\n // eslint-disable-next-line no-console\n console.warn(\n `Dock components for AI generation should open a panel with an id starting with \"ly.img.ai/\" \u2013 \"${panelId}\" was provided.`\n );\n }\n\n const dockComponentId = `${panelId}.dock`;\n cesdk.ui.registerComponent(dockComponentId, ({ builder }) => {\n const isOpen = cesdk.ui.isPanelOpen(panelId);\n\n builder.Button(`${panelId}.dock.button`, {\n label: `${panelId}.dock.label`,\n isSelected: isOpen,\n icon: '@imgly/Sparkle',\n onClick: () => {\n cesdk.ui.findAllPanels().forEach((panel) => {\n if (panel.startsWith('ly.img.ai/')) {\n cesdk.ui.closePanel(panel);\n }\n if (!isOpen && panel === '//ly.img.panel/assetLibrary') {\n cesdk.ui.closePanel(panel);\n }\n });\n\n if (!isOpen) {\n cesdk.ui.openPanel(panelId);\n } else {\n cesdk.ui.closePanel(panelId);\n }\n }\n });\n });\n}\n\nexport default registerDockComponent;\n", "import { ButtonOptions, TextAreaOptions } from '@cesdk/cesdk-js';\nimport { Output, QuickAction, QuickActionContext } from '../../provider';\n\n/**\n * Quick action base for quick actions that require a prompt.\n * Will render a text area for the prompt.\n */\nfunction QuickActionBasePrompt<I, O extends Output>(options: {\n buttonOptions?: ButtonOptions;\n textAreaOptions?: TextAreaOptions;\n quickAction: Omit<QuickAction<I, O>, 'render' | 'renderExpanded'>;\n onApply: (prompt: string, context: QuickActionContext<I, O>) => Promise<O>;\n}): QuickAction<I, O> {\n const id = options.quickAction.id;\n return {\n confirmation: true,\n lockDuringConfirmation: false,\n ...options.quickAction,\n render: ({ builder }, { toggleExpand }) => {\n builder.Button(`${id}.button`, {\n label: `ly.img.ai.quickAction.${id}`,\n icon: '@imgly/Sparkle',\n labelAlignment: 'left',\n variant: 'plain',\n ...options.buttonOptions,\n onClick: toggleExpand\n });\n },\n renderExpanded: ({ builder, state, experimental }, context) => {\n const promptState = state(`${id}.prompt`, '');\n\n builder.TextArea(`${id}.textarea`, {\n inputLabel: `ly.img.ai.quickAction.${id}.prompt.inputLabel`,\n placeholder: `ly.img.ai.quickAction.${id}.prompt.placeholder`,\n ...options.textAreaOptions,\n ...promptState\n });\n\n builder.Separator(`${id}.separator`);\n\n experimental.builder.ButtonRow(`${id}.footer`, {\n justifyContent: 'space-between',\n children: () => {\n builder.Button(`${id}.footer.cancel`, {\n label: 'common.back',\n icon: '@imgly/ChevronLeft',\n onClick: context.toggleExpand\n });\n\n builder.Button(`${id}.footer.apply`, {\n label: `ly.img.ai.quickAction.${id}.apply`,\n icon: '@imgly/MagicWand',\n color: 'accent',\n isDisabled: promptState.value.length === 0,\n onClick: async () => {\n try {\n const prompt = promptState.value;\n if (!prompt) return;\n\n options.onApply(prompt, context);\n context.toggleExpand();\n context.closeMenu();\n } catch (error) {\n context.handleGenerationError(error);\n }\n }\n });\n }\n });\n }\n };\n}\n\nexport default QuickActionBasePrompt;\n", "import { ButtonOptions } from '@cesdk/cesdk-js';\nimport { Output, QuickAction, QuickActionContext } from '../../provider';\n\n/**\n * Quick action base for quick actions to open a panel.\n */\nfunction QuickActionBaseButton<I, O extends Output>(options: {\n buttonOptions?: ButtonOptions;\n quickAction: Omit<QuickAction<I, O>, 'render' | 'renderExpanded'>;\n\n onClick: (context: QuickActionContext<I, O>) => Promise<void>;\n}): QuickAction<I, O> {\n const id = options.quickAction.id;\n return {\n confirmation: true,\n lockDuringConfirmation: false,\n ...options.quickAction,\n render: ({ builder }, context) => {\n builder.Button(`${id}.button`, {\n label: `ly.img.ai.quickAction.${id}`,\n icon: '@imgly/Sparkle',\n labelAlignment: 'left',\n variant: 'plain',\n ...options.buttonOptions,\n onClick: async () => {\n try {\n options.onClick(context);\n context.closeMenu();\n } catch (error) {\n context.handleGenerationError(error);\n }\n }\n });\n }\n };\n}\n\nexport default QuickActionBaseButton;\n", "import CreativeEditorSDK, { ButtonOptions } from '@cesdk/cesdk-js';\nimport { Output, QuickAction, QuickActionContext } from '../../provider';\nimport { getImageUri } from '@imgly/plugin-utils';\n\ninterface QuickActionBaseSelectItem {\n id: string;\n label: string;\n icon?: string;\n prompt: string;\n}\n\n/**\n * Quick action base for quick actions that require a selection of items.\n */\nfunction QuickActionBaseSelect<I, O extends Output>(options: {\n cesdk: CreativeEditorSDK;\n items: QuickActionBaseSelectItem[];\n buttonOptions?: ButtonOptions;\n quickAction: Omit<QuickAction<I, O>, 'render' | 'renderExpanded'>;\n mapInput?: (input: {\n item: QuickActionBaseSelectItem;\n uri: string;\n blockId: number;\n }) => I;\n onApply?: (\n options: { item: QuickActionBaseSelectItem; uri: string; blockId: number },\n context: QuickActionContext<I, O>\n ) => Promise<O>;\n}): QuickAction<I, O> {\n const id = options.quickAction.id;\n\n if (options.mapInput == null && options.onApply == null) {\n throw new Error(\n `QuickAction '${id}': Either mapInput or onApply must be provided to QuickActionChangeImage`\n );\n }\n\n if (options.mapInput != null && options.onApply != null) {\n throw new Error(\n `QuickAction '${id}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`\n );\n }\n\n return {\n ...options.quickAction,\n render: ({ builder, experimental }, context) => {\n experimental.builder.Popover(`${id}.popover`, {\n label: `ly.img.ai.quickAction.${id}`,\n icon: '@imgly/Appearance',\n labelAlignment: 'left',\n variant: 'plain',\n trailingIcon: '@imgly/ChevronRight',\n placement: 'right',\n ...options.buttonOptions,\n children: () => {\n builder.Section(`${id}.popover.section`, {\n children: () => {\n experimental.builder.Menu(`${id}.popover.menu`, {\n children: () => {\n options.items.forEach((item) => {\n builder.Button(`${id}.popover.menu.${item.id}`, {\n label: item.label,\n labelAlignment: 'left',\n variant: 'plain',\n icon: item.icon,\n onClick: async () => {\n const { generate, closeMenu, handleGenerationError } =\n context;\n try {\n closeMenu();\n const [blockId] =\n options.cesdk.engine.block.findAllSelected();\n const uri = await getImageUri(\n blockId,\n options.cesdk.engine,\n {\n throwErrorIfSvg: true\n }\n );\n\n if (options.mapInput) {\n const input = options.mapInput({\n item,\n uri,\n blockId\n });\n return await generate(input);\n } else if (options.onApply) {\n return await options.onApply(\n {\n item,\n uri,\n blockId\n },\n context\n );\n } else {\n throw new Error(\n 'Please provide either mapInput or onApply'\n );\n }\n } catch (error) {\n handleGenerationError(error);\n }\n }\n });\n });\n }\n });\n }\n });\n }\n });\n }\n };\n}\n\nexport default QuickActionBaseSelect;\n", "import CreativeEditorSDK, { AssetResult, ButtonOptions } from '@cesdk/cesdk-js';\nimport { Output, QuickAction, QuickActionContext } from '../../provider';\nimport { getImageUri } from '@imgly/plugin-utils';\n\n/**\n * Quick action base for quick actions that require a selection of items\n * from a library.\n */\nfunction QuickActionBaseLibrary<I, O extends Output>(options: {\n cesdk: CreativeEditorSDK;\n entries: string[];\n buttonOptions?: ButtonOptions;\n quickAction: Omit<QuickAction<I, O>, 'render' | 'renderExpanded'>;\n mapInput?: (input: {\n assetResult: AssetResult;\n uri: string;\n blockId: number;\n }) => I;\n onApply?: (\n options: { assetResult: AssetResult; uri: string; blockId: number },\n context: QuickActionContext<I, O>\n ) => Promise<O>;\n}): QuickAction<I, O> {\n const id = options.quickAction.id;\n\n if (options.mapInput == null && options.onApply == null) {\n throw new Error(\n `QuickAction '${id}': Either mapInput or onApply must be provided to QuickActionChangeImage`\n );\n }\n\n if (options.mapInput != null && options.onApply != null) {\n throw new Error(\n `QuickAction '${id}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`\n );\n }\n\n return {\n ...options.quickAction,\n render: ({ builder, experimental }, context) => {\n experimental.builder.Popover(`${id}.popover`, {\n label: `ly.img.ai.quickAction.${id}`,\n icon: '@imgly/Appearance',\n labelAlignment: 'left',\n variant: 'plain',\n trailingIcon: '@imgly/ChevronRight',\n placement: 'right',\n ...options.buttonOptions,\n children: () => {\n builder.Library(`${id}.popover.library`, {\n entries: options.entries,\n onSelect: async (assetResult) => {\n const { generate, closeMenu, handleGenerationError } = context;\n try {\n closeMenu();\n const [blockId] = options.cesdk.engine.block.findAllSelected();\n const uri = await getImageUri(blockId, options.cesdk.engine, {\n throwErrorIfSvg: true\n });\n\n if (options.mapInput) {\n const input = options.mapInput({\n assetResult,\n uri,\n blockId\n });\n await generate(input);\n } else if (options.onApply) {\n await options.onApply(\n {\n assetResult,\n uri,\n blockId\n },\n context\n );\n } else {\n throw new Error('Please provide either mapInput or onApply');\n }\n } catch (error) {\n handleGenerationError(error);\n }\n }\n });\n }\n });\n }\n };\n}\n\nexport default QuickActionBaseLibrary;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { ImageOutput, QuickAction, QuickActionContext } from '../../provider';\nimport QuickActionBasePrompt from './QuickActionBasePrompt';\nimport { getImageUri } from '@imgly/plugin-utils';\n\nfunction QuickActionEditTextStyle<I, O extends ImageOutput>(options: {\n id?: string;\n cesdk: CreativeEditorSDK;\n mapInput?: (input: {\n prompt: string;\n uri: string;\n duplicatedBlockId: number;\n }) => I;\n onApply?: (\n options: { prompt: string; uri: string; duplicatedBlockId: number },\n context: QuickActionContext<I, O>\n ) => Promise<O>;\n}): QuickAction<I, O> {\n const id = options.id ?? 'changeToImage';\n\n if (options.mapInput == null && options.onApply == null) {\n throw new Error(\n `QuickAction '${id}': Either mapInput or onApply must be provided to QuickActionChangeImage`\n );\n }\n\n if (options.mapInput != null && options.onApply != null) {\n throw new Error(\n `QuickAction '${id}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`\n );\n }\n\n options.cesdk.i18n.setTranslations({\n en: {\n [`ly.img.ai.quickAction.${id}.apply`]: 'Change',\n [`ly.img.ai.quickAction.${id}`]: 'Change Text Style...',\n [`ly.img.ai.quickAction.${id}.prompt.inputLabel`]: 'Change Text Style...',\n [`ly.img.ai.quickAction.${id}.prompt.placeholder`]:\n 'e.g. add a 3d texture with wires...'\n }\n });\n\n return QuickActionBasePrompt<I, O>({\n buttonOptions: {\n icon: '@imgly/plugin-ai-generation/image'\n },\n quickAction: {\n kind: 'text',\n id,\n version: '1',\n confirmation: false,\n // scopes: ['fill/change'],\n enable: ({ engine }) => {\n const blockIds = engine.block.findAllSelected();\n if (blockIds == null || blockIds.length !== 1) return false;\n const [blockId] = blockIds;\n return engine.block.getType(blockId) === '//ly.img.ubq/text';\n }\n },\n onApply: async (prompt, context) => {\n const [blockId] = options.cesdk.engine.block.findAllSelected();\n const parentBlockId = options.cesdk.engine.block.getParent(blockId);\n if (parentBlockId == null) {\n throw new Error('Parent block not found');\n }\n\n const rasterized = await options.cesdk.engine.block.export(blockId);\n const rasterizedUri = URL.createObjectURL(rasterized);\n\n const width = options.cesdk.engine.block.getFrameWidth(blockId);\n const height = options.cesdk.engine.block.getFrameHeight(blockId);\n const positionX = options.cesdk.engine.block.getPositionX(blockId);\n const positionY = options.cesdk.engine.block.getPositionY(blockId);\n\n const shape = options.cesdk.engine.block.createShape('rect');\n const rasterizedBlock = options.cesdk.engine.block.create('graphic');\n options.cesdk.engine.block.setShape(rasterizedBlock, shape);\n options.cesdk.engine.block.appendChild(parentBlockId, rasterizedBlock);\n options.cesdk.engine.block.setWidth(rasterizedBlock, width);\n options.cesdk.engine.block.setHeight(rasterizedBlock, height);\n options.cesdk.engine.block.setPositionX(rasterizedBlock, positionX);\n options.cesdk.engine.block.setPositionY(rasterizedBlock, positionY);\n const fillBlock = options.cesdk.engine.block.createFill('image');\n\n options.cesdk.engine.block.setString(\n fillBlock,\n 'fill/image/imageFileURI',\n rasterizedUri\n );\n\n options.cesdk.engine.block.setFill(rasterizedBlock, fillBlock);\n\n options.cesdk.engine.block.destroy(blockId);\n options.cesdk.engine.block.setSelected(rasterizedBlock, true);\n\n const uri = await getImageUri(rasterizedBlock, options.cesdk.engine, {\n throwErrorIfSvg: true\n });\n\n if (options.mapInput) {\n const input = options.mapInput({\n prompt,\n uri,\n duplicatedBlockId: rasterizedBlock\n });\n return context.generate(input);\n } else if (options.onApply) {\n return options.onApply(\n {\n prompt,\n uri,\n duplicatedBlockId: rasterizedBlock\n },\n context\n );\n } else {\n throw new Error('Please provide either mapInput or onApply');\n }\n }\n });\n}\n\nexport default QuickActionEditTextStyle;\n", "import type CreativeEngine from '@cesdk/engine';\n\n/**\n * Enable function for a single image fill block selected.\n */\nfunction enableImageFill() {\n return ({ engine }: { engine: CreativeEngine }) => {\n const blockIds = engine.block.findAllSelected();\n if (blockIds == null || blockIds.length !== 1) return false;\n\n const [blockId] = blockIds;\n\n if (!engine.block.supportsFill(blockId)) return false;\n\n if (\n !['//ly.img.ubq/graphic', '//ly.img.ubq/page'].includes(\n engine.block.getType(blockId)\n )\n ) {\n return false;\n }\n\n const fillBlock = engine.block.getFill(blockId);\n return engine.block.getType(fillBlock) === '//ly.img.ubq/fill/image';\n };\n}\n\nexport default enableImageFill;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { ImageOutput, QuickAction, QuickActionContext } from '../../provider';\nimport QuickActionBasePrompt from './QuickActionBasePrompt';\nimport enableImageFill from './enableImageFill';\nimport { getImageUri } from '@imgly/plugin-utils';\n\nfunction QuickActionChangeImage<I, O extends ImageOutput>(options: {\n id?: string;\n cesdk: CreativeEditorSDK;\n mapInput?: (input: { prompt: string; uri: string; blockId: number }) => I;\n onApply?: (\n options: { prompt: string; uri: string; blockId: number },\n context: QuickActionContext<I, O>\n ) => Promise<O>;\n}): QuickAction<I, O> {\n const id = options.id ?? 'changeImage';\n\n if (options.mapInput == null && options.onApply == null) {\n throw new Error(\n `QuickAction '${id}': Either mapInput or onApply must be provided to QuickActionChangeImage`\n );\n }\n\n if (options.mapInput != null && options.onApply != null) {\n throw new Error(\n `QuickAction '${id}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`\n );\n }\n\n options.cesdk.i18n.setTranslations({\n en: {\n [`ly.img.ai.quickAction.${id}.apply`]: 'Change',\n [`ly.img.ai.quickAction.${id}`]: 'Edit Image...',\n [`ly.img.ai.quickAction.${id}.prompt.inputLabel`]: 'Change image...',\n [`ly.img.ai.quickAction.${id}.prompt.placeholder`]:\n 'Describe what you want to change...'\n }\n });\n\n return QuickActionBasePrompt<I, O>({\n buttonOptions: {\n icon: '@imgly/plugin-ai-generation/image'\n },\n quickAction: {\n id,\n version: '1',\n confirmation: true,\n lockDuringConfirmation: false,\n scopes: ['fill/change'],\n enable: enableImageFill()\n },\n onApply: async (prompt, context) => {\n const [blockId] = options.cesdk.engine.block.findAllSelected();\n const uri = await getImageUri(blockId, options.cesdk.engine, {\n throwErrorIfSvg: true\n });\n\n if (options.mapInput) {\n const input = options.mapInput({ prompt, uri, blockId });\n return context.generate(input);\n } else if (options.onApply) {\n return options.onApply(\n {\n prompt,\n uri,\n blockId\n },\n context\n );\n } else {\n throw new Error('Please provide either mapInput or onApply');\n }\n }\n });\n}\n\nexport default QuickActionChangeImage;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { ImageOutput, QuickAction, QuickActionContext } from '../../provider';\nimport QuickActionBasePrompt from './QuickActionBasePrompt';\nimport enableImageFill from './enableImageFill';\nimport { getImageUri } from '@imgly/plugin-utils';\n\nfunction QuickActionImageVariant<I, O extends ImageOutput>(options: {\n id?: string;\n mapInput?: (input: {\n prompt: string;\n uri: string;\n duplicatedBlockId: number;\n }) => I;\n onApply?: (\n options: { prompt: string; uri: string; duplicatedBlockId: number },\n context: QuickActionContext<I, O>\n ) => Promise<O>;\n cesdk: CreativeEditorSDK;\n}): QuickAction<I, O> {\n const id = options.id ?? 'createVariant';\n\n if (options.mapInput == null && options.onApply == null) {\n throw new Error(\n `QuickAction '${id}': Either mapInput or onApply must be provided to QuickActionChangeImage`\n );\n }\n\n if (options.mapInput != null && options.onApply != null) {\n throw new Error(\n `QuickAction '${id}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`\n );\n }\n\n options.cesdk.i18n.setTranslations({\n en: {\n [`ly.img.ai.quickAction.${id}.apply`]: 'Create',\n [`ly.img.ai.quickAction.${id}`]: 'Create Variant...',\n [`ly.img.ai.quickAction.${id}.prompt.inputLabel`]:\n 'Describe Your Variant...',\n [`ly.img.ai.quickAction.${id}.prompt.placeholder`]:\n 'e.g., same character with arms raised'\n }\n });\n\n return QuickActionBasePrompt<I, O>({\n buttonOptions: {\n icon: '@imgly/ImageVariation'\n },\n quickAction: {\n id,\n version: '1',\n confirmation: false,\n lockDuringConfirmation: false,\n scopes: ['lifecycle/duplicate', 'fill/change'],\n enable: (context) => {\n if (!enableImageFill()(context)) return false;\n\n const [blockId] = context.engine.block.findAllSelected();\n if (\n !options.cesdk.feature.isEnabled('ly.img.duplicate', {\n engine: context.engine\n })\n ) {\n return false;\n }\n if (\n !context.engine.block.isAllowedByScope(blockId, 'lifecycle/duplicate')\n ) {\n return false;\n }\n\n return true;\n }\n },\n onApply: async (prompt, context) => {\n const engine = options.cesdk.engine;\n const [blockId] = engine.block.findAllSelected();\n const type = engine.block.getType(blockId);\n\n // Duplicate the selected block\n const duplicated = engine.block.duplicate(blockId);\n if (type === '//ly.img.ubq/page') {\n engine.block.getChildren(duplicated).forEach((childId) => {\n engine.block.destroy(childId);\n });\n }\n engine.block.setSelected(blockId, false);\n engine.block.setSelected(duplicated, true);\n\n const parent = engine.block.getParent(duplicated);\n if (parent == null) throw new Error('Parent not found');\n\n const isBackgroundClip =\n parent != null &&\n engine.block.getType(parent) === '//ly.img.ubq/track' &&\n engine.block.isPageDurationSource(parent);\n\n // Offset the duplicated block unless it is a background track\n if (!isBackgroundClip && type !== '//ly.img.ubq/page') {\n const offsetFactor = 1.0;\n const parentWidth = engine.block.getWidth(parent);\n const parentHeight = engine.block.getHeight(parent);\n const offset =\n 0.02 * Math.min(parentWidth, parentHeight) * offsetFactor;\n\n engine.block.setPositionX(\n duplicated,\n engine.block.getPositionX(duplicated) + offset\n );\n engine.block.setPositionY(\n duplicated,\n engine.block.getPositionY(duplicated) + offset\n );\n }\n\n // Get the source of the duplicated block\n const uri = await getImageUri(duplicated, options.cesdk.engine, {\n throwErrorIfSvg: true\n });\n\n if (options.mapInput) {\n const input = options.mapInput({\n prompt,\n uri,\n duplicatedBlockId: duplicated\n });\n return context.generate(input);\n } else if (options.onApply) {\n return options.onApply(\n {\n prompt,\n uri,\n duplicatedBlockId: duplicated\n },\n context\n );\n } else {\n throw new Error('Please provide either mapInput or onApply');\n }\n }\n });\n}\n\nexport default QuickActionImageVariant;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { ImageOutput, QuickAction, QuickActionContext } from '../../provider';\nimport QuickActionBasePrompt from './QuickActionBasePrompt';\nimport { getImageUri } from '@imgly/plugin-utils';\n\nfunction QuickActionCombineImages<I, O extends ImageOutput>(options: {\n id?: string;\n mapInput?: (input: {\n prompt: string;\n uris: string[];\n duplicatedBlockId: number;\n }) => I;\n onApply?: (\n options: { prompt: string; uris: string[]; duplicatedBlockId: number },\n context: QuickActionContext<I, O>\n ) => Promise<O>;\n cesdk: CreativeEditorSDK;\n}): QuickAction<I, O> {\n const id = options.id ?? 'combineImages';\n\n if (options.mapInput == null && options.onApply == null) {\n throw new Error(\n `QuickAction '${id}': Either mapInput or onApply must be provided to QuickActionChangeImage`\n );\n }\n\n if (options.mapInput != null && options.onApply != null) {\n throw new Error(\n `QuickAction '${id}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`\n );\n }\n\n options.cesdk.i18n.setTranslations({\n en: {\n [`ly.img.ai.quickAction.${id}.apply`]: 'Combine',\n [`ly.img.ai.quickAction.${id}`]: 'Combine Images...',\n [`ly.img.ai.quickAction.${id}.prompt.inputLabel`]:\n 'Image Combination Instructions',\n [`ly.img.ai.quickAction.${id}.prompt.placeholder`]:\n 'e.g., add character to the left of the mountain scene'\n }\n });\n\n return QuickActionBasePrompt<I, O>({\n buttonOptions: {\n icon: '@imgly/ImageVariation'\n },\n quickAction: {\n id,\n version: '1',\n confirmation: false,\n lockDuringConfirmation: false,\n scopes: ['lifecycle/duplicate', 'fill/change'],\n enable: (context) => {\n const blockIds = context.engine.block.findAllSelected();\n\n if (blockIds == null || blockIds.length < 2) return false;\n\n return blockIds.every((blockId) => {\n if (\n context.engine.block.getType(blockId) !== '//ly.img.ubq/graphic' &&\n !context.engine.block.supportsFill(blockId)\n ) {\n return false;\n }\n\n const fillBlock = context.engine.block.getFill(blockId);\n if (\n context.engine.block.getType(fillBlock) !==\n '//ly.img.ubq/fill/image'\n ) {\n return false;\n }\n\n if (\n !options.cesdk.feature.isEnabled('ly.img.duplicate', {\n engine: context.engine\n })\n ) {\n return false;\n }\n if (\n !context.engine.block.isAllowedByScope(\n blockId,\n 'lifecycle/duplicate'\n )\n ) {\n return false;\n }\n\n const parent = context.engine.block.getParent(blockId);\n const isBackgroundClip =\n parent != null &&\n context.engine.block.getType(parent) === '//ly.img.ubq/track' &&\n context.engine.block.isPageDurationSource(parent);\n\n if (isBackgroundClip) {\n return false;\n }\n\n const blockType = context.engine.block.getType(blockId);\n if (blockType === '//ly.img.ubq/page') return false;\n return true;\n });\n }\n },\n onApply: async (prompt, context) => {\n const engine = options.cesdk.engine;\n const blockIds = engine.block.findAllSelected();\n\n // Duplicate the selected block\n const duplicated = engine.block.duplicate(blockIds[0]);\n blockIds.forEach((blockId) => {\n engine.block.setSelected(blockId, false);\n });\n engine.block.setSelected(duplicated, true);\n\n // Offset the duplicated block\n const parent = engine.block.getParent(duplicated);\n if (parent == null) throw new Error('Parent not found');\n\n const offsetFactor = 1.0;\n const parentWidth = engine.block.getWidth(parent);\n const parentHeight = engine.block.getHeight(parent);\n const offset = 0.02 * Math.min(parentWidth, parentHeight) * offsetFactor;\n\n engine.block.setPositionX(\n duplicated,\n engine.block.getPositionX(duplicated) + offset\n );\n engine.block.setPositionY(\n duplicated,\n engine.block.getPositionY(duplicated) + offset\n );\n\n const uris = await Promise.all(\n blockIds.map((blockId) =>\n getImageUri(blockId, options.cesdk.engine, {\n throwErrorIfSvg: true\n })\n )\n );\n\n if (options.mapInput) {\n const input = options.mapInput({\n prompt,\n uris,\n duplicatedBlockId: duplicated\n });\n return context.generate(input);\n } else if (options.onApply) {\n return options.onApply(\n {\n prompt,\n uris,\n duplicatedBlockId: duplicated\n },\n context\n );\n } else {\n throw new Error('Please provide either mapInput or onApply');\n }\n }\n });\n}\n\nexport default QuickActionCombineImages;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { ImageOutput, QuickAction, QuickActionContext } from '../../provider';\nimport { getImageUri } from '@imgly/plugin-utils';\nimport QuickActionBasePrompt from './QuickActionBasePrompt';\nimport enableImageFill from './enableImageFill';\n\nfunction QuickActionChangeImage<I, O extends ImageOutput>(options: {\n id?: string;\n mapInput?: (input: { prompt: string; uri: string; blockId: number }) => I;\n onApply?: (\n options: { prompt: string; uri: string; blockId: number },\n context: QuickActionContext<I, O>\n ) => Promise<O>;\n cesdk: CreativeEditorSDK;\n}): QuickAction<I, O> {\n const id = options.id ?? 'swapBackground';\n\n if (options.mapInput == null && options.onApply == null) {\n throw new Error(\n `QuickAction '${id}': Either mapInput or onApply must be provided to QuickActionChangeImage`\n );\n }\n\n if (options.mapInput != null && options.onApply != null) {\n throw new Error(\n `QuickAction '${id}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`\n );\n }\n\n options.cesdk.i18n.setTranslations({\n en: {\n [`ly.img.ai.quickAction.${id}.apply`]: 'Change',\n [`ly.img.ai.quickAction.${id}`]: 'Change Background...',\n [`ly.img.ai.quickAction.${id}.prompt.inputLabel`]: 'Change background...',\n [`ly.img.ai.quickAction.${id}.prompt.placeholder`]:\n 'Describe the background you want...'\n }\n });\n\n return QuickActionBasePrompt<I, O>({\n buttonOptions: {\n icon: '@imgly/plugin-ai-generation/image'\n },\n quickAction: {\n id,\n version: '1',\n confirmation: true,\n lockDuringConfirmation: false,\n scopes: ['fill/change'],\n enable: enableImageFill()\n },\n onApply: async (userPrompt, context) => {\n const [blockId] = options.cesdk.engine.block.findAllSelected();\n const uri = await getImageUri(blockId, options.cesdk.engine, {\n throwErrorIfSvg: true\n });\n\n const prompt = `Swap the background to ${userPrompt}`;\n if (options.mapInput) {\n const input = options.mapInput({ prompt, uri, blockId });\n return context.generate(input);\n } else if (options.onApply) {\n return options.onApply(\n {\n prompt,\n uri,\n blockId\n },\n context\n );\n } else {\n throw new Error('Please provide either mapInput or onApply');\n }\n }\n });\n}\n\nexport default QuickActionChangeImage;\n", "import renderImageUrlProperty from './common/renderImageUrlProperty';\nimport renderStyleTransferProperty from './common/renderStyleTransferProperty';\n\nconst CommonProperties = {\n ImageUrl: renderImageUrlProperty,\n StyleTransfer: renderStyleTransferProperty\n};\n\nexport { CommonProperties };\n\nexport {\n type default as Provider,\n type ImageOutput,\n type VideoOutput,\n type TextOutput,\n type AudioOutput,\n type Output,\n type OutputKind,\n type PanelInputSchema,\n type RenderCustomProperty,\n type GetBlockInput,\n type GetBlockInputResult,\n type GetInput,\n type QuickAction,\n type QuickActionsInput\n} from './generation/provider';\nexport {\n type GetPropertyInput,\n type Property\n} from './generation/openapi/types';\nexport { default as initProvider } from './generation/initProvider';\nexport {\n type GenerationMiddleware,\n type CommonProviderConfiguration\n} from './generation/types';\n\n// Export middleware\nexport {\n composeMiddlewares,\n type Middleware\n} from './generation/middleware/middleware';\nexport { default as loggingMiddleware } from './generation/middleware/loggingMiddleware';\nexport { default as uploadMiddleware } from './generation/middleware/uploadMiddleware';\nexport {\n default as rateLimitMiddleware,\n type RateLimitOptions\n} from './generation/middleware/rateLimitMiddleware';\n\nexport {\n getPanelId,\n getDurationForVideo,\n getThumbnailForVideo,\n getLabelFromId,\n isAsyncGenerator\n} from './utils';\n\nexport { default as registerDockComponent } from './registerDockComponent';\n\nexport { default as getQuickActionMenu } from './generation/quickAction/getQuickActionMenu';\nexport { default as registerQuickActionMenuComponent } from './generation/quickAction/registerQuickActionMenuComponent';\n\nexport { default as QuickActionBasePrompt } from './generation/quickAction/common/QuickActionBasePrompt';\nexport { default as QuickActionBaseButton } from './generation/quickAction/common/QuickActionBaseButton';\nexport { default as QuickActionBaseSelect } from './generation/quickAction/common/QuickActionBaseSelect';\nexport { default as QuickActionBaseLibrary } from './generation/quickAction/common/QuickActionBaseLibrary';\n\nexport { default as QuickActionEditTextStyle } from './generation/quickAction/common/QuickActionEditTextStyle';\nexport { default as QuickActionChangeImage } from './generation/quickAction/common/QuickActionChangeImage';\nexport { default as QuickActionImageVariant } from './generation/quickAction/common/QuickActionImageVariant';\nexport { default as QuickActionCombineImages } from './generation/quickAction/common/QuickActionCombineImages';\nexport { default as QuickActionSwapImageBackground } from './generation/quickAction/common/QuickActionSwapImageBackground';\n\nexport { default as enableQuickActionForImageFill } from './generation/quickAction/common/enableImageFill';\n\nexport {\n isGeneratingStateKey,\n abortGenerationStateKey\n} from './generation/renderGenerationComponents';\n", "{\n \"openapi\": \"3.0.0\",\n \"components\": {\n \"schemas\": {\n \"GptImage1Input\": {\n \"title\": \"TextToImageInput\",\n \"type\": \"object\",\n \"properties\": {\n \"prompt\": {\n \"title\": \"Prompt\",\n \"type\": \"string\",\n \"x-imgly-builder\": {\n \"component\": \"TextArea\"\n }\n },\n \"style\": {\n \"title\": \"Style\",\n \"type\": \"string\",\n \"description\": \"The style of the generated images.\"\n },\n \"size\": {\n \"enum\": [\"1024x1024\", \"1536x1024\", \"1024x1536\"],\n \"type\": \"string\",\n \"title\": \"Format\",\n \"default\": \"1024x1024\",\n \"x-imgly-enum-labels\": {\n \"1024x1024\": \"Square\",\n \"1536x1024\": \"Landscape\",\n \"1024x1536\": \"Portrait\"\n },\n \"x-imgly-enum-icons\": {\n \"1024x1024\": \"@imgly/plugin/formats/ratio1by1\",\n \"1024x1536\": \"@imgly/plugin/formats/ratio3by4\",\n \"1536x1024\": \"@imgly/plugin/formats/ratio4by3\"\n }\n },\n \"background\": {\n \"enum\": [\"auto\", \"transparent\", \"opaque\"],\n \"type\": \"string\",\n \"title\": \"Background\",\n \"default\": \"auto\",\n \"x-imgly-enum-labels\": {\n \"auto\": \"Auto\",\n \"transparent\": \"Transparent\",\n \"opaque\": \"Opaque\"\n }\n }\n },\n \"x-order-properties\": [\"prompt\", \"style\", \"size\", \"background\"],\n \"required\": [\"prompt\"]\n }\n }\n }\n}\n", "export function b64JsonToBlob(b64_json: string, mimeType: string): Blob {\n const base64Data = b64_json.split(',')[1] || b64_json;\n\n const byteCharacters = atob(base64Data);\n const byteArrays = [];\n\n for (let i = 0; i < byteCharacters.length; i++) {\n byteArrays.push(byteCharacters.charCodeAt(i));\n }\n const byteArray = new Uint8Array(byteArrays);\n const blob = new Blob([byteArray], { type: mimeType });\n\n return blob;\n}\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { CustomAssetSource, isDefined } from '@imgly/plugin-utils';\n\nexport const STYLES = [\n {\n id: 'none',\n label: 'None',\n prompt: ''\n },\n {\n id: 'anime-celshaded',\n label: 'Anime',\n prompt:\n 'anime cel\u2011shaded, bright pastel palette, expressive eyes, clean line art '\n },\n {\n id: 'cyberpunk-neon',\n label: 'Cyberpunk',\n prompt:\n 'cyberpunk cityscape, glowing neon signage, reflective puddles, dark atmosphere'\n },\n {\n id: 'kodak-portra-400',\n label: 'Kodak 400',\n prompt:\n 'shot on Kodak Portra 400, soft grain, golden\u2011hour warmth, 35 mm photo'\n },\n {\n id: 'watercolor-storybook',\n label: 'Watercolor',\n prompt: 'loose watercolor washes, gentle gradients, dreamy storybook feel'\n },\n {\n id: 'dark-fantasy-realism',\n label: 'Dark Fantasy',\n prompt:\n 'dark fantasy realm, moody chiaroscuro lighting, hyper\u2011real textures'\n },\n {\n id: 'vaporwave-retrofuturism',\n label: 'Vaporwave',\n prompt:\n 'retro\u2011futuristic vaporwave, pastel sunset gradient, chrome text, VHS scanlines'\n },\n {\n id: 'minimal-vector-flat',\n label: 'Vector Flat',\n prompt:\n 'minimalist flat vector illustration, bold geometry, two\u2011tone palette'\n },\n {\n id: 'pixarstyle-3d-render',\n label: '3D Animation',\n prompt:\n 'Pixar\u2011style 3D render, oversized eyes, subtle subsurface scattering, cinematic lighting'\n },\n {\n id: 'ukiyoe-woodblock',\n label: 'Ukiyo\u2011e',\n prompt:\n 'ukiyo\u2011e woodblock print, Edo\u2011period style, visible washi texture, limited color ink'\n },\n {\n id: 'surreal-dreamscape',\n label: 'Surreal',\n prompt:\n 'surreal dreamscape, floating objects, impossible architecture, vivid clouds'\n },\n {\n id: 'steampunk-victorian',\n label: 'Steampunk',\n prompt:\n 'Victorian steampunk world, ornate brass gears, leather attire, atmospheric fog'\n },\n {\n id: 'nightstreet-photo-bokeh',\n label: 'Night Bokeh',\n prompt:\n 'night\u2011time street shot, large aperture bokeh lights, candid urban mood'\n },\n {\n id: 'comicbook-pop-art',\n label: 'Pop Art',\n prompt:\n 'classic comic\u2011book panel, halftone shading, exaggerated action lines, CMYK pop colors'\n }\n];\n\nexport const createStyleAssetSource = (\n assetSourceId: string,\n options: {\n baseURL: string;\n includeNone?: boolean;\n }\n) => {\n const styleValues = STYLES.map((style) => {\n if (style.id === 'none') {\n if (!options.includeNone) {\n return undefined;\n }\n return {\n id: style.id,\n label: style.label,\n thumbUri: `${options.baseURL}/thumbnails/None.svg`\n };\n }\n return {\n id: style.id,\n label: style.label,\n thumbUri: `${options.baseURL}/thumbnails/${style.id}.jpeg`\n };\n }).filter(isDefined);\n\n const styleAssetSource = new CustomAssetSource(assetSourceId, styleValues);\n\n const defaultStyle = STYLES[0];\n styleAssetSource.setAssetActive(defaultStyle.id);\n\n return styleAssetSource;\n};\n\nexport const addStyleAssetSource = (\n styleAssetSource: CustomAssetSource,\n options: {\n cesdk: CreativeEditorSDK;\n }\n) => {\n options.cesdk.engine.asset.addSource(styleAssetSource);\n options.cesdk.ui.addAssetLibraryEntry({\n id: styleAssetSource.id,\n sourceIds: [styleAssetSource.id],\n gridItemHeight: 'square',\n gridBackgroundType: 'cover',\n cardLabel: ({ label }) => label,\n cardLabelPosition: () => 'below'\n });\n};\n", "import { Icons } from '@imgly/plugin-utils';\nimport {\n CommonProviderConfiguration,\n getPanelId,\n type Provider\n} from '@imgly/plugin-ai-generation-web';\nimport GptImage1Schema from './GptImage1.text2image.json';\nimport CreativeEditorSDK, { AssetResult } from '@cesdk/cesdk-js';\nimport { b64JsonToBlob } from './utils';\nimport {\n addStyleAssetSource,\n createStyleAssetSource,\n STYLES\n} from './GptImage1.styles';\n\ntype StyleSelectionPayload = {\n onSelect: (asset: AssetResult) => Promise<void>;\n};\n\ntype GptImage1Input = {\n prompt: string;\n style?: string;\n size: 'auto' | '1024x1024' | '1536x1024' | '1024x1536';\n background: 'transparent' | 'opaque' | 'auto';\n};\n\ntype GptImage1Output = {\n kind: 'image';\n url: string;\n};\n\ninterface ProviderConfiguration\n extends CommonProviderConfiguration<GptImage1Input, GptImage1Output> {}\n\nexport function GptImage1(\n config: ProviderConfiguration\n): (context: {\n cesdk: CreativeEditorSDK;\n}) => Promise<Provider<'image', GptImage1Input, GptImage1Output>> {\n return async ({ cesdk }: { cesdk: CreativeEditorSDK }) => {\n return getProvider(cesdk, config);\n };\n}\n\nfunction getProvider(\n cesdk: CreativeEditorSDK,\n config: ProviderConfiguration\n): Provider<'image', GptImage1Input, GptImage1Output> {\n const modelKey = 'open-ai/gpt-image-1/text2image';\n const baseURL =\n 'https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/gpt-image-1/';\n const styleAssetSourceId = `${modelKey}/styles`;\n const styleAssetSource = createStyleAssetSource(styleAssetSourceId, {\n baseURL,\n includeNone: true\n });\n addStyleAssetSource(styleAssetSource, { cesdk });\n\n cesdk.ui.registerPanel<StyleSelectionPayload>(\n `${getPanelId(modelKey)}.styleSelection`,\n ({ builder, payload }) => {\n if (payload == null) return null;\n\n builder.Library(`${modelKey}.library.style`, {\n entries: [styleAssetSourceId],\n onSelect: async (asset) => {\n payload.onSelect(asset);\n }\n });\n }\n );\n\n cesdk.ui.addIconSet('@imgly/plugin/formats', Icons.Formats);\n cesdk.i18n.setTranslations({\n en: {\n [`panel.${getPanelId(modelKey)}.styleSelection`]: 'Style Selection',\n [`${modelKey}.style`]: 'Style'\n }\n });\n\n const provider: Provider<'image', GptImage1Input, GptImage1Output> = {\n id: 'open-ai/gpt-image-1/text2image',\n kind: 'image',\n name: 'gpt-image-1',\n input: {\n panel: {\n type: 'schema',\n // @ts-ignore\n document: GptImage1Schema,\n inputReference: '#/components/schemas/GptImage1Input',\n includeHistoryLibrary: true,\n orderExtensionKeyword: 'x-order-properties',\n renderCustomProperty: {\n style: ({ builder, state }, property) => {\n const styleState = state<{\n id: string;\n label: string;\n }>(\n 'style',\n styleAssetSource.getAssetSelectValue(\n styleAssetSource.getActiveAssetIds()[0]\n ) ?? STYLES[0]\n );\n\n // Show the style library for the selected type.\n builder.Button(`${property.id}`, {\n inputLabel: `${modelKey}.${property.id}`,\n icon: '@imgly/Appearance',\n trailingIcon: '@imgly/ChevronRight',\n label: styleState.value.label,\n labelAlignment: 'left',\n onClick: () => {\n const payload: StyleSelectionPayload = {\n onSelect: async (asset) => {\n const newValue = {\n id: asset.id,\n label: asset.label ?? asset.id\n };\n\n styleAssetSource.clearActiveAssets();\n styleAssetSource.setAssetActive(asset.id);\n styleState.setValue(newValue);\n\n cesdk.ui.closePanel(\n `${getPanelId(modelKey)}.styleSelection`\n );\n }\n };\n\n cesdk.ui.openPanel(`${getPanelId(modelKey)}.styleSelection`, {\n payload\n });\n }\n });\n\n return () => {\n return {\n id: property.id,\n type: 'string',\n value:\n styleState.value.id ?? styleAssetSource.getActiveAssetIds()[0]\n };\n };\n }\n },\n getBlockInput: (input) => {\n switch (input.size) {\n case 'auto':\n return Promise.resolve({ image: { width: 512, height: 512 } });\n case '1024x1024':\n return Promise.resolve({ image: { width: 1024, height: 1024 } });\n case '1536x1024':\n return Promise.resolve({ image: { width: 1536, height: 1024 } });\n case '1024x1536':\n return Promise.resolve({ image: { width: 1024, height: 1536 } });\n default: {\n throw new Error('Invalid image size');\n }\n }\n },\n userFlow: 'placeholder'\n }\n },\n output: {\n abortable: true,\n history: '@imgly/indexedDB',\n middleware: config.middleware ?? [],\n generate: async (\n input: GptImage1Input,\n { abortSignal }: { abortSignal?: AbortSignal }\n ) => {\n const stylePrompt = STYLES.find((style) => style.id === input.style);\n let prompt = input.prompt;\n\n if (\n stylePrompt != null &&\n stylePrompt.id !== 'none' &&\n stylePrompt.prompt\n ) {\n prompt = `${prompt}, ${stylePrompt.prompt}`;\n }\n const hasGlobalAPIKey =\n cesdk.ui.experimental.hasGlobalStateValue('OPENAI_API_KEY');\n\n const baseUrl = hasGlobalAPIKey\n ? 'https://api.openai.com/v1'\n : config.proxyUrl;\n\n const response = await fetch(`${baseUrl}/images/generations`, {\n signal: abortSignal,\n method: 'POST',\n headers: hasGlobalAPIKey\n ? {\n Authorization: `Bearer ${cesdk.ui.experimental.getGlobalStateValue(\n 'OPENAI_API_KEY'\n )}`,\n 'Content-Type': 'application/json',\n ...(config.headers ?? {})\n }\n : {\n 'Content-Type': 'application/json',\n ...(config.headers ?? {})\n },\n body: JSON.stringify({\n model: 'gpt-image-1',\n prompt,\n n: 1,\n size: input.size,\n background: input.background\n })\n });\n const img = await response.json();\n\n const b64_json = img.data?.[0].b64_json;\n if (b64_json == null) {\n throw new Error('No image data returned');\n }\n\n const blob = b64JsonToBlob(b64_json, 'image/png');\n const imageUrl = URL.createObjectURL(blob);\n\n return {\n kind: 'image',\n url: imageUrl\n };\n }\n }\n };\n\n return provider;\n}\n\nexport default getProvider;\n", "{\n \"openapi\": \"3.0.0\",\n \"components\": {\n \"schemas\": {\n \"GptImage1Input\": {\n \"title\": \"ImageToImageInput\",\n \"type\": \"object\",\n \"properties\": {\n \"prompt\": {\n \"title\": \"Prompt\",\n \"type\": \"string\",\n \"x-imgly-builder\": {\n \"component\": \"TextArea\"\n }\n },\n \"image_url\": {\n \"title\": \"Image Url\",\n \"type\": \"string\",\n \"description\": \"Optional URL of an input image for editing.\"\n }\n },\n \"x-order-properties\": [\"image_url\", \"prompt\", \"background\"],\n \"required\": [\"image_url\", \"prompt\"]\n }\n }\n }\n}\n", "import {\n bufferURIToObjectURL,\n getImageDimensionsFromURL,\n getImageUri,\n Icons,\n mimeTypeToExtension\n} from '@imgly/plugin-utils';\nimport {\n QuickActionImageVariant,\n QuickActionCombineImages,\n QuickActionChangeImage,\n QuickActionEditTextStyle,\n QuickActionSwapImageBackground,\n CommonProperties,\n getQuickActionMenu,\n QuickActionBasePrompt,\n QuickAction,\n type Provider,\n QuickActionBaseSelect,\n QuickActionBaseLibrary,\n enableQuickActionForImageFill,\n QuickActionBaseButton,\n CommonProviderConfiguration\n} from '@imgly/plugin-ai-generation-web';\nimport GptImage1Schema from './GptImage1.image2image.json';\nimport CreativeEditorSDK, { MimeType } from '@cesdk/cesdk-js';\nimport { b64JsonToBlob } from './utils';\nimport {\n addStyleAssetSource,\n createStyleAssetSource,\n STYLES\n} from './GptImage1.styles';\n\ntype GptImage1Input = {\n prompt: string;\n image_url: string | string[];\n exportFromBlockIds?: number[];\n};\n\ntype GptImage1Output = {\n kind: 'image';\n url: string;\n};\n\ninterface ProviderConfiguration\n extends CommonProviderConfiguration<GptImage1Input, GptImage1Output> {}\n\nexport function GptImage1(\n config: ProviderConfiguration\n): (context: {\n cesdk: CreativeEditorSDK;\n}) => Promise<Provider<'image', GptImage1Input, GptImage1Output>> {\n return async ({ cesdk }: { cesdk: CreativeEditorSDK }) => {\n return getProvider(cesdk, config);\n };\n}\n\nfunction getProvider(\n cesdk: CreativeEditorSDK,\n config: ProviderConfiguration\n): Provider<'image', GptImage1Input, GptImage1Output> {\n const modelKey = 'open-ai/gpt-image-1/image2image';\n cesdk.ui.addIconSet('@imgly/plugin/formats', Icons.Formats);\n const baseURL =\n 'https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/gpt-image-1/';\n\n const quickActions = createQuickActions({ cesdk, modelKey });\n const quickActionMenu = getQuickActionMenu(cesdk, 'image');\n const quickActionMenuForText = getQuickActionMenu(cesdk, 'text');\n\n const styleAssetSourceId = `${modelKey}/styles`;\n const styleAssetSource = createStyleAssetSource(styleAssetSourceId, {\n baseURL\n });\n addStyleAssetSource(styleAssetSource, { cesdk });\n\n cesdk.i18n.setTranslations({\n en: {\n 'ly.img.ai.quickAction.changeStyle': 'Change Style',\n 'ly.img.ai.quickAction.changeStyleLibrary': 'Change Style',\n 'ly.img.ai.quickAction.remixPage': 'Turn Page into Image',\n 'ly.img.ai.quickAction.remixPageWithPrompt': 'Remix Page',\n 'ly.img.ai.quickAction.remixPageWithPrompt.prompt.inputLabel':\n 'Remix Page Prompt',\n 'ly.img.ai.quickAction.remixPageWithPrompt.prompt.placeholder':\n 'e.g. rearrange the layout to...',\n 'ly.img.ai.quickAction.remixPageWithPrompt.apply': 'Remix'\n }\n });\n\n quickActionMenu.setQuickActionMenuOrder([\n 'changeStyleLibrary',\n // 'changeStyle',\n 'ly.img.separator',\n 'swapBackground',\n 'changeImage',\n 'createVariant',\n 'combineImages',\n 'ly.img.separator',\n 'remixPage',\n 'ly.img.separator',\n ...quickActionMenu.getQuickActionMenuOrder()\n ]);\n\n quickActionMenuForText.setQuickActionMenuOrder([\n ...quickActionMenuForText.getQuickActionMenuOrder(),\n 'ly.img.separator',\n 'changeToImage'\n ]);\n\n const provider: Provider<'image', GptImage1Input, GptImage1Output> = {\n id: modelKey,\n kind: 'image',\n name: 'gpt-image-1',\n input: {\n panel: {\n type: 'schema',\n // @ts-ignore\n document: GptImage1Schema,\n inputReference: '#/components/schemas/GptImage1Input',\n includeHistoryLibrary: true,\n orderExtensionKeyword: 'x-order-properties',\n renderCustomProperty: {\n ...(cesdk != null\n ? CommonProperties.ImageUrl('gpt-image-1', {\n cesdk\n })\n : {})\n },\n getBlockInput: async (input) => {\n if (input.image_url == null || Array.isArray(input.image_url)) {\n throw new Error('Cannot process getBlockInput for multiple images');\n }\n\n const { width, height } = await getImageDimensionsFromURL(\n input.image_url,\n cesdk.engine\n );\n return Promise.resolve({\n image: {\n width,\n height\n }\n });\n },\n userFlow: 'placeholder'\n },\n quickActions: {\n actions: quickActions ?? []\n }\n },\n output: {\n abortable: true,\n history: '@imgly/indexedDB',\n middleware: config.middleware ?? [],\n generate: async (\n input: GptImage1Input,\n { abortSignal }: { abortSignal?: AbortSignal }\n ) => {\n const formData = new FormData();\n\n if (Array.isArray(input.image_url)) {\n if (input.exportFromBlockIds != null) {\n await Promise.all(\n input.exportFromBlockIds.map(async (blockId) => {\n const exportedBlob = await cesdk.engine.block.export(\n blockId,\n MimeType.Jpeg,\n {\n targetHeight: 1024,\n targetWidth: 1024\n }\n );\n formData.append(\n 'image[]',\n exportedBlob,\n `image_${blockId}.jpeg`\n );\n })\n );\n } else {\n await Promise.all(\n input.image_url.map(async (image_url) => {\n const mimeType = await cesdk.engine.editor.getMimeType(\n image_url\n );\n const resolvedImageUrl = await bufferURIToObjectURL(\n image_url,\n cesdk.engine\n );\n const imageUrlResponse = await fetch(resolvedImageUrl);\n const imageUrlBlob = await imageUrlResponse.blob();\n formData.append(\n 'image[]',\n imageUrlBlob,\n `image.${mimeTypeToExtension(mimeType)}`\n );\n })\n );\n }\n } else {\n const mimeType = await cesdk.engine.editor.getMimeType(\n input.image_url\n );\n const resolvedImageUrl = await bufferURIToObjectURL(\n input.image_url,\n cesdk.engine\n );\n const imageUrlResponse = await fetch(resolvedImageUrl);\n const imageUrlBlob = await imageUrlResponse.blob();\n formData.append(\n 'image',\n imageUrlBlob,\n `image.${mimeTypeToExtension(mimeType)}`\n );\n }\n\n formData.append('prompt', input.prompt);\n formData.append('model', 'gpt-image-1');\n formData.append('size', 'auto');\n formData.append('n', '1');\n\n const hasGlobalAPIKey =\n cesdk.ui.experimental.hasGlobalStateValue('OPENAI_API_KEY');\n\n const baseUrl = hasGlobalAPIKey\n ? 'https://api.openai.com/v1'\n : config.proxyUrl;\n\n const response = await fetch(`${baseUrl}/images/edits`, {\n signal: abortSignal,\n method: 'POST',\n headers: hasGlobalAPIKey\n ? {\n Authorization: `Bearer ${cesdk.ui.experimental.getGlobalStateValue(\n 'OPENAI_API_KEY'\n )}`,\n ...(config.headers ?? {})\n }\n : {\n ...(config.headers ?? {})\n },\n body: formData\n });\n\n const img = await response.json();\n\n const b64_json = img.data?.[0].b64_json;\n if (b64_json == null) {\n throw new Error('No image data returned');\n }\n\n const blob = b64JsonToBlob(b64_json, 'image/png');\n const imageUrl = URL.createObjectURL(blob);\n\n return {\n kind: 'image',\n url: imageUrl\n };\n }\n }\n };\n\n return provider;\n}\n\nfunction createQuickActions(options: {\n cesdk: CreativeEditorSDK;\n modelKey: string;\n}): QuickAction<GptImage1Input, GptImage1Output>[] {\n const { cesdk, modelKey } = options;\n return [\n QuickActionBaseLibrary<GptImage1Input, GptImage1Output>({\n cesdk: options.cesdk,\n entries: [`${modelKey}/styles`],\n quickAction: {\n id: 'changeStyleLibrary',\n version: '1',\n confirmation: true,\n lockDuringConfirmation: false,\n scopes: ['fill/change'],\n enable: enableQuickActionForImageFill()\n },\n onApply: async (input, context) => {\n const [blockId] = cesdk.engine.block.findAllSelected();\n const uri = await getImageUri(blockId, cesdk.engine, {\n throwErrorIfSvg: true\n });\n\n const styleId = input.assetResult.id;\n const style = STYLES.find(({ id }) => id === styleId);\n if (style == null) {\n throw new Error(`Style not found: ${styleId}`);\n }\n\n return context.generate({\n prompt: style.prompt,\n image_url: uri\n });\n }\n }),\n QuickActionBaseSelect<GptImage1Input, GptImage1Output>({\n cesdk,\n items: STYLES.filter(({ id }) => id !== 'none'),\n quickAction: {\n id: 'changeStyle',\n version: '1',\n confirmation: true,\n lockDuringConfirmation: false,\n scopes: ['fill/change'],\n enable: enableQuickActionForImageFill()\n },\n onApply: async (input, context) => {\n const [blockId] = cesdk.engine.block.findAllSelected();\n const uri = await getImageUri(blockId, cesdk.engine, {\n throwErrorIfSvg: true\n });\n\n return context.generate({\n prompt: input.item.prompt,\n image_url: uri\n });\n }\n }),\n QuickActionEditTextStyle<GptImage1Input, GptImage1Output>({\n onApply: async ({ prompt, uri, duplicatedBlockId }, context) => {\n // Generate a variant for the duplicated block\n return context.generate(\n {\n prompt,\n image_url: uri\n },\n {\n blockIds: [duplicatedBlockId]\n }\n );\n },\n cesdk\n }),\n QuickActionSwapImageBackground<GptImage1Input, GptImage1Output>({\n mapInput: (input) => ({ ...input, image_url: input.uri }),\n cesdk\n }),\n QuickActionChangeImage<GptImage1Input, GptImage1Output>({\n mapInput: (input) => ({ ...input, image_url: input.uri }),\n cesdk\n }),\n QuickActionImageVariant<GptImage1Input, GptImage1Output>({\n onApply: async ({ prompt, uri, duplicatedBlockId }, context) => {\n // Generate a variant for the duplicated block\n return context.generate(\n {\n prompt,\n image_url: uri\n },\n {\n blockIds: [duplicatedBlockId]\n }\n );\n },\n cesdk\n }),\n QuickActionCombineImages<GptImage1Input, GptImage1Output>({\n onApply: async ({ prompt, uris, duplicatedBlockId }, context) => {\n // Generate a variant for the duplicated block\n return context.generate(\n {\n prompt,\n image_url: uris,\n exportFromBlockIds: context.blockIds\n },\n {\n blockIds: [duplicatedBlockId]\n }\n );\n },\n cesdk\n }),\n QuickActionBaseButton<GptImage1Input, GptImage1Output>({\n quickAction: {\n id: 'remixPage',\n version: '1',\n confirmation: false,\n lockDuringConfirmation: false,\n scopes: ['lifecycle/duplicate'],\n enable: ({ engine }) => {\n const blockIds = engine.block.findAllSelected();\n if (blockIds.length !== 1) return false;\n const blockId = blockIds[0];\n const type = engine.block.getType(blockId);\n return type === '//ly.img.ubq/page';\n }\n },\n onClick: async (context) => {\n const engine = cesdk.engine;\n const [page] = engine.block.findAllSelected();\n\n const exportedPageBlob = await engine.block.export(page);\n const exportedPageUrl = URL.createObjectURL(exportedPageBlob);\n\n const duplicatedPage = engine.block.duplicate(page);\n engine.block.getChildren(duplicatedPage).forEach((childId) => {\n engine.block.destroy(childId);\n });\n engine.block.setSelected(page, false);\n\n const width = cesdk.engine.block.getFrameWidth(page);\n const height = cesdk.engine.block.getFrameHeight(page);\n const positionX = cesdk.engine.block.getPositionX(page);\n const positionY = cesdk.engine.block.getPositionY(page);\n\n const shape = cesdk.engine.block.createShape('rect');\n const rasterizedPageBlock = cesdk.engine.block.create('graphic');\n\n cesdk.engine.block.setShape(rasterizedPageBlock, shape);\n cesdk.engine.block.appendChild(duplicatedPage, rasterizedPageBlock);\n cesdk.engine.block.setWidth(rasterizedPageBlock, width);\n cesdk.engine.block.setHeight(rasterizedPageBlock, height);\n cesdk.engine.block.setPositionX(rasterizedPageBlock, positionX);\n cesdk.engine.block.setPositionY(rasterizedPageBlock, positionY);\n\n const fillBlock = cesdk.engine.block.createFill('image');\n cesdk.engine.block.setFill(rasterizedPageBlock, fillBlock);\n\n cesdk.engine.block.setString(\n fillBlock,\n 'fill/image/imageFileURI',\n exportedPageUrl\n );\n\n engine.block.setSelected(rasterizedPageBlock, true);\n engine.scene.zoomToBlock(rasterizedPageBlock);\n\n context.generate(\n {\n image_url: exportedPageUrl,\n prompt:\n 'Follow instructions but don\u2019t add the instructions for the image'\n },\n {\n blockIds: [rasterizedPageBlock]\n }\n );\n }\n }),\n QuickActionBasePrompt<GptImage1Input, GptImage1Output>({\n quickAction: {\n id: 'remixPageWithPrompt',\n version: '1',\n confirmation: false,\n lockDuringConfirmation: false,\n scopes: ['lifecycle/duplicate'],\n enable: ({ engine }) => {\n const blockIds = engine.block.findAllSelected();\n if (blockIds.length !== 1) return false;\n const blockId = blockIds[0];\n const type = engine.block.getType(blockId);\n return type === '//ly.img.ubq/page';\n }\n },\n onApply: async (prompt, context) => {\n const engine = cesdk.engine;\n const [page] = engine.block.findAllSelected();\n\n const exportedPageBlob = await engine.block.export(page);\n const exportedPageUrl = URL.createObjectURL(exportedPageBlob);\n\n const duplicatedPage = engine.block.duplicate(page);\n engine.block.getChildren(duplicatedPage).forEach((childId) => {\n engine.block.destroy(childId);\n });\n engine.block.setSelected(page, false);\n\n const width = cesdk.engine.block.getFrameWidth(page);\n const height = cesdk.engine.block.getFrameHeight(page);\n const positionX = cesdk.engine.block.getPositionX(page);\n const positionY = cesdk.engine.block.getPositionY(page);\n\n const shape = cesdk.engine.block.createShape('rect');\n const rasterizedPageBlock = cesdk.engine.block.create('graphic');\n\n cesdk.engine.block.setShape(rasterizedPageBlock, shape);\n cesdk.engine.block.appendChild(duplicatedPage, rasterizedPageBlock);\n cesdk.engine.block.setWidth(rasterizedPageBlock, width);\n cesdk.engine.block.setHeight(rasterizedPageBlock, height);\n cesdk.engine.block.setPositionX(rasterizedPageBlock, positionX);\n cesdk.engine.block.setPositionY(rasterizedPageBlock, positionY);\n\n const fillBlock = cesdk.engine.block.createFill('image');\n cesdk.engine.block.setFill(rasterizedPageBlock, fillBlock);\n\n cesdk.engine.block.setString(\n fillBlock,\n 'fill/image/imageFileURI',\n exportedPageUrl\n );\n\n engine.block.setSelected(rasterizedPageBlock, true);\n engine.scene.zoomToBlock(rasterizedPageBlock);\n\n return context.generate(\n {\n image_url: exportedPageUrl,\n prompt\n },\n {\n blockIds: [rasterizedPageBlock]\n }\n );\n }\n })\n ];\n}\n\nexport default getProvider;\n", "import { GptImage1 as GptImage1Text2Image } from './GptImage1.text2image';\nimport { GptImage1 as GptImage1Image2Image } from './GptImage1.image2image';\n\nconst OpenAi = {\n GptImage1: {\n Text2Image: GptImage1Text2Image,\n Image2Image: GptImage1Image2Image\n }\n};\n\nexport default OpenAi;\n"],
5
- "mappings": "AAAA,IAAOA,GAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ECuBFC,GAAN,KAA+C,CAgBpD,YAAYC,EAAYC,EAA4C,CAAC,EAAG,CACtE,KAAK,GAAKD,EACV,KAAK,OAASC,EAAO,IAAKC,GAAU,CAElC,GACE,OAAQA,EAAsB,OAAU,UACxC,EACGA,EAA0B,OAC3B,OAAQA,EAA0B,OAAU,UAE9C,CACA,IAAMC,EAAcD,EAEpB,MAAO,CACL,GAAIC,EAAY,GAChB,MAAO,CAAE,GAAIA,EAAY,KAAM,EAC/B,KAAMA,EAAY,SACd,CAAE,GAAIA,EAAY,MAAQ,CAAC,EAAI,SAAUA,EAAY,QAAS,EAC9DA,EAAY,IAClB,CACF,CACA,OAAOD,CACT,CAAC,EACD,KAAK,eAAiB,IAAI,GAC5B,CASA,MAAM,WACJE,EACwC,CACxC,GAAM,CACJ,KAAAC,EACA,QAAAC,EACA,OAAAC,EAAS,KACT,gBAAAC,EACA,MAAAC,EACA,KAAAC,EACA,OAAAC,EACA,cAAAC,EACA,aAAAC,EACA,QAAAC,CACF,EAAIV,EAGAW,EAAiB,CAAC,GAAG,KAAK,MAAM,EAoBpC,GAjBIJ,GAAUA,EAAO,OAAS,IAC5BI,EAAiBA,EAAe,OAC7Bb,GACCA,EAAM,QAAU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ChDM,EAAYhE,EAAM,OAAO,MAAM,aAAa0D,CAAI,EAEhDO,EAAQjE,EAAM,OAAO,MAAM,YAAY,MAAM,EAC7CkE,EAAsBlE,EAAM,OAAO,MAAM,OAAO,SAAS,EAE/DA,EAAM,OAAO,MAAM,SAASkE,EAAqBD,CAAK,EACtDjE,EAAM,OAAO,MAAM,YAAY6D,EAAgBK,CAAmB,EAClElE,EAAM,OAAO,MAAM,SAASkE,EAAqBjD,CAAK,EACtDjB,EAAM,OAAO,MAAM,UAAUkE,EAAqBhD,CAAM,EACxDlB,EAAM,OAAO,MAAM,aAAakE,EAAqBH,CAAS,EAC9D/D,EAAM,OAAO,MAAM,aAAakE,EAAqBF,CAAS,EAE9D,IAAMG,EAAYnE,EAAM,OAAO,MAAM,WAAW,OAAO,EACvD,OAAAA,EAAM,OAAO,MAAM,QAAQkE,EAAqBC,CAAS,EAEzDnE,EAAM,OAAO,MAAM,UACjBmE,EACA,0BACAP,CACF,EAEAJ,EAAO,MAAM,YAAYU,EAAqB,EAAI,EAClDV,EAAO,MAAM,YAAYU,CAAmB,EAErC3B,EAAQ,SACb,CACE,UAAWqB,EACX,OAAAZ,CACF,EACA,CACE,SAAU,CAACkB,CAAmB,CAChC,CACF,CACF,CACF,CAAC,CACH,CACF,CC7fA,IAAMG,GAAS,CACb,UAAW,CACT,WAAYC,GACZ,YAAaA,EACf,CACF,EAEOC,GAAQF",
6
- "names": ["formats_default", "CustomAssetSource", "id", "assets", "asset", "selectValue", "queryData", "page", "perPage", "locale", "sortActiveFirst", "query", "tags", "groups", "excludeGroups", "sortingOrder", "sortKey", "filteredAssets", "group", "lowerQuery", "label", "assetTags", "tag", "tagArray", "a", "b", "aActive", "bActive", "aValue", "bValue", "total", "startIndex", "endIndex", "resultAssets", "nextPage", "assetId", "assetIds", "existingIndex", "index", "freeGlobal", "freeGlobal_default", "freeSelf", "root", "root_default", "Symbol", "Symbol_default", "objectProto", "hasOwnProperty", "nativeObjectToString", "symToStringTag", "getRawTag", "value", "isOwn", "tag", "unmasked", "result", "getRawTag_default", "objectToString", "objectToString_default", "nullTag", "undefinedTag", "baseGetTag", "baseGetTag_default", "isObjectLike", "isObjectLike_default", "isArray", "isObject", "value", "type", "isObject_default", "asyncTag", "funcTag", "genTag", "proxyTag", "isFunction", "tag", "baseGetTag_default", "isFunction_default", "coreJsData", "root_default", "coreJsData_default", "maskSrcKey", "uid", "isMasked", "func", "isMasked_default", "funcProto", "funcToString", "toSource", "toSource_default", "reRegExpChar", "reIsHostCtor", "objectProto", "hasOwnProperty", "reIsNative", "baseIsNative", "pattern", "baseIsNative_default", "getValue", "object", "key", "getValue_default", "getNative", "getNative_default", "WeakMap", "WeakMap_default", "eq", "value", "other", "eq_default", "MAX_SAFE_INTEGER", "isLength", "isLength_default", "objectProto", "argsTag", "baseIsArguments", "value", "isObjectLike_default", "baseGetTag_default", "baseIsArguments_default", "objectProto", "hasOwnProperty", "propertyIsEnumerable", "isArguments", "freeExports", "freeModule", "moduleExports", "Buffer", "root_default", "nativeIsBuffer", "argsTag", "arrayTag", "boolTag", "dateTag", "errorTag", "funcTag", "mapTag", "numberTag", "objectTag", "regexpTag", "setTag", "stringTag", "weakMapTag", "arrayBufferTag", "dataViewTag", "float32Tag", "float64Tag", "int8Tag", "int16Tag", "int32Tag", "uint8Tag", "uint8ClampedTag", "uint16Tag", "uint32Tag", "typedArrayTags", "baseIsTypedArray", "value", "isObjectLike_default", "isLength_default", "baseGetTag_default", "baseIsTypedArray_default", "baseUnary", "func", "baseUnary_default", "freeExports", "freeModule", "moduleExports", "freeProcess", "freeGlobal_default", "nodeUtil", "types", "nodeUtil_default", "nodeIsTypedArray", "isTypedArray", "objectProto", "hasOwnProperty", "overArg", "func", "transform", "arg", "overArg_default", "nativeKeys", "objectProto", "hasOwnProperty", "nativeCreate", "getNative_default", "nativeCreate_default", "hashClear", "hashClear_default", "hashDelete", "key", "result", "hashDelete_default", "HASH_UNDEFINED", "objectProto", "hasOwnProperty", "hashGet", "data", "hashGet_default", "hashHas", "hashHas_default", "hashSet", "value", "hashSet_default", "Hash", "entries", "index", "length", "entry", "Hash_default", "listCacheClear", "listCacheClear_default", "assocIndexOf", "array", "eq_default", "assocIndexOf_default", "arrayProto", "splice", "listCacheDelete", "lastIndex", "listCacheDelete_default", "listCacheGet", "listCacheGet_default", "listCacheHas", "listCacheHas_default", "listCacheSet", "listCacheSet_default", "ListCache", "ListCache_default", "Map", "root_default", "Map_default", "mapCacheClear", "mapCacheClear_default", "isKeyable", "type", "isKeyable_default", "getMapData", "map", "getMapData_default", "mapCacheDelete", "mapCacheDelete_default", "mapCacheGet", "mapCacheGet_default", "mapCacheHas", "mapCacheHas_default", "mapCacheSet", "size", "mapCacheSet_default", "MapCache", "MapCache_default", "stackClear", "ListCache_default", "stackClear_default", "stackDelete", "key", "data", "result", "stackDelete_default", "stackGet", "stackGet_default", "stackHas", "stackHas_default", "LARGE_ARRAY_SIZE", "stackSet", "value", "pairs", "Map_default", "MapCache_default", "stackSet_default", "Stack", "entries", "objectProto", "propertyIsEnumerable", "DataView", "getNative_default", "root_default", "DataView_default", "Promise", "Promise_default", "Set", "Set_default", "mapTag", "objectTag", "promiseTag", "setTag", "weakMapTag", "dataViewTag", "dataViewCtorString", "toSource_default", "mapCtorString", "Map_default", "promiseCtorString", "setCtorString", "weakMapCtorString", "WeakMap_default", "getTag", "baseGetTag_default", "value", "result", "Ctor", "ctorString", "Uint8Array", "root_default", "HASH_UNDEFINED", "setCacheAdd", "value", "setCacheAdd_default", "setCacheHas", "setCacheHas_default", "SetCache", "values", "index", "length", "MapCache_default", "symbolProto", "Symbol_default", "symbolValueOf", "objectProto", "hasOwnProperty", "objectProto", "hasOwnProperty", "HEX_COLOR_PATTERN", "HEX_SINGLE_CHAR_COMPONENTS_PATTERN", "HEX_DOUBLE_CHAR_COMPONENTS_PATTERN", "mimeTypeToExtension", "mimeType", "bufferURIToObjectURL", "uri", "engine", "mimeType", "length", "data", "blob", "getImageDimensionsFromURL", "url", "engine", "resolvedUrl", "bufferURIToObjectURL", "resolve", "reject", "img", "getImageUri", "blockId", "options", "uri", "fillBlock", "sourceSet", "source", "isDefined", "value", "isDefined_default", "Icons", "formats_default", "renderImageUrlProperty", "provderId", "options", "cesdk", "propertyKey", "panelIdForImageSelection", "getImageSelectionPanelId", "createPanels", "context", "property", "builder", "global", "payload", "defaultUrl", "stateValue", "assetResult", "providerId", "asset", "uri", "mimeType", "renderImageUrlProperty_default", "CustomAssetSource", "id", "assets", "selectValue", "queryData", "page", "perPage", "locale", "sortActiveFirst", "query", "tags", "groups", "excludeGroups", "sortingOrder", "sortKey", "filteredAssets", "group", "lowerQuery", "label", "assetTags", "tag", "tagArray", "a", "b", "aActive", "bActive", "aValue", "bValue", "total", "startIndex", "endIndex", "resultAssets", "nextPage", "assetId", "assetIds", "existingIndex", "index", "freeGlobal", "freeGlobal_default", "freeSelf", "root", "root_default", "Symbol", "Symbol_default", "objectProto", "hasOwnProperty", "nativeObjectToString", "symToStringTag", "getRawTag", "value", "isOwn", "tag", "unmasked", "result", "getRawTag_default", "objectToString", "objectToString_default", "nullTag", "undefinedTag", "baseGetTag", "baseGetTag_default", "isObjectLike", "isObjectLike_default", "isArray", "isObject", "type", "isObject_default", "asyncTag", "funcTag", "genTag", "proxyTag", "isFunction", "isFunction_default", "coreJsData", "coreJsData_default", "maskSrcKey", "uid", "isMasked", "func", "isMasked_default", "funcProto", "funcToString", "toSource", "toSource_default", "reRegExpChar", "reIsHostCtor", "reIsNative", "baseIsNative", "pattern", "baseIsNative_default", "getValue", "object", "key", "getValue_default", "getNative", "getNative_default", "WeakMap", "WeakMap_default", "eq", "other", "eq_default", "MAX_SAFE_INTEGER", "isLength", "isLength_default", "argsTag", "baseIsArguments", "baseIsArguments_default", "propertyIsEnumerable", "isArguments", "freeExports", "freeModule", "moduleExports", "Buffer", "nativeIsBuffer", "arrayTag", "boolTag", "dateTag", "errorTag", "mapTag", "numberTag", "objectTag", "regexpTag", "setTag", "stringTag", "weakMapTag", "arrayBufferTag", "dataViewTag", "float32Tag", "float64Tag", "int8Tag", "int16Tag", "int32Tag", "uint8Tag", "uint8ClampedTag", "uint16Tag", "uint32Tag", "typedArrayTags", "baseIsTypedArray", "baseIsTypedArray_default", "baseUnary", "baseUnary_default", "freeProcess", "nodeUtil", "types", "nodeUtil_default", "nodeIsTypedArray", "isTypedArray", "overArg", "transform", "arg", "overArg_default", "nativeKeys", "nativeCreate", "nativeCreate_default", "hashClear", "hashClear_default", "hashDelete", "hashDelete_default", "HASH_UNDEFINED", "hashGet", "data", "hashGet_default", "hashHas", "hashHas_default", "hashSet", "hashSet_default", "Hash", "entries", "index", "length", "entry", "Hash_default", "listCacheClear", "listCacheClear_default", "assocIndexOf", "array", "assocIndexOf_default", "arrayProto", "splice", "listCacheDelete", "lastIndex", "listCacheDelete_default", "listCacheGet", "listCacheGet_default", "listCacheHas", "listCacheHas_default", "listCacheSet", "listCacheSet_default", "ListCache", "ListCache_default", "Map", "Map_default", "mapCacheClear", "mapCacheClear_default", "isKeyable", "isKeyable_default", "getMapData", "map", "getMapData_default", "mapCacheDelete", "mapCacheDelete_default", "mapCacheGet", "mapCacheGet_default", "mapCacheHas", "mapCacheHas_default", "mapCacheSet", "size", "mapCacheSet_default", "MapCache", "MapCache_default", "stackClear", "stackClear_default", "stackDelete", "stackDelete_default", "stackGet", "stackGet_default", "stackHas", "stackHas_default", "LARGE_ARRAY_SIZE", "stackSet", "pairs", "stackSet_default", "Stack", "DataView", "DataView_default", "Promise", "Promise_default", "Set", "Set_default", "promiseTag", "dataViewCtorString", "mapCtorString", "promiseCtorString", "setCtorString", "weakMapCtorString", "getTag", "Ctor", "ctorString", "Uint8Array", "setCacheAdd", "setCacheAdd_default", "setCacheHas", "setCacheHas_default", "SetCache", "values", "symbolProto", "symbolValueOf", "HEX_COLOR_PATTERN", "HEX_SINGLE_CHAR_COMPONENTS_PATTERN", "HEX_DOUBLE_CHAR_COMPONENTS_PATTERN", "bufferURIToObjectURL", "uri", "engine", "mimeType", "length", "data", "blob", "getImageUri", "blockId", "engine", "options", "uri", "fillBlock", "sourceSet", "source", "bufferURIToObjectURL", "isDefined", "value", "isDefined_default", "renderStyleTransferProperty", "providerId", "cesdk", "propertyKey", "panelIdForStyleSelection", "getStyleSelectionPanelId", "defaultStyles", "getDefaultStyles", "styles", "styleAssetSource", "createStyleAssetSource", "styleAssetSourceId", "addStyleAssetSource", "createPanels", "context", "property", "promptState", "activeAssetId", "asset", "builder", "state", "styleState", "payload", "panelId", "entryId", "STYLES", "style", "Xs", "styleValues", "allSourceIds", "assetSourceId", "ye", "defaultStyle", "label", "renderStyleTransferProperty_default", "AI_PANEL_ID_PREFIX", "getPanelId", "providerId", "AI_PANEL_ID_PREFIX", "PLUGIN_ICON_SET_ID", "ICON_SPRITE", "QUICK_ACTION_ORDER_KEY_PREFIX", "QUICK_ACTION_REGISTRY_PREFIX", "getQuickActionMenu", "cesdk", "id", "quickActionIds", "quickAction", "entries", "quickActionId", "getQuickActionMenu_default", "QuickActionBasePrompt", "options", "id", "builder", "toggleExpand", "state", "experimental", "context", "promptState", "prompt", "error", "QuickActionBasePrompt_default", "QuickActionBaseButton", "QuickActionBaseButton_default", "QuickActionBaseSelect", "item", "generate", "closeMenu", "handleGenerationError", "blockId", "uri", "Qs", "input", "QuickActionBaseSelect_default", "QuickActionBaseLibrary", "assetResult", "QuickActionBaseLibrary_default", "QuickActionEditTextStyle", "engine", "blockIds", "parentBlockId", "rasterized", "rasterizedUri", "width", "height", "positionX", "positionY", "shape", "rasterizedBlock", "fillBlock", "QuickActionEditTextStyle_default", "enableImageFill", "enableImageFill_default", "QuickActionChangeImage", "QuickActionChangeImage_default", "QuickActionImageVariant", "type", "duplicated", "childId", "parent", "parentWidth", "parentHeight", "offset", "QuickActionImageVariant_default", "QuickActionCombineImages", "offsetFactor", "uris", "QuickActionCombineImages_default", "userPrompt", "QuickActionSwapImageBackground_default", "CommonProperties", "renderImageUrlProperty_default", "renderStyleTransferProperty_default", "GptImage1_text2image_default", "b64JsonToBlob", "b64_json", "mimeType", "base64Data", "byteCharacters", "byteArrays", "i", "byteArray", "STYLES", "createStyleAssetSource", "assetSourceId", "options", "styleValues", "style", "Xs", "styleAssetSource", "ye", "defaultStyle", "addStyleAssetSource", "label", "GptImage1", "config", "cesdk", "getProvider", "modelKey", "baseURL", "styleAssetSourceId", "styleAssetSource", "createStyleAssetSource", "addStyleAssetSource", "W", "builder", "payload", "asset", "Lu", "GptImage1_text2image_default", "state", "property", "styleState", "STYLES", "newValue", "input", "abortSignal", "stylePrompt", "style", "prompt", "hasGlobalAPIKey", "baseUrl", "b64_json", "blob", "b64JsonToBlob", "GptImage1_image2image_default", "MimeType", "GptImage1", "config", "cesdk", "getProvider", "modelKey", "Lu", "baseURL", "quickActions", "createQuickActions", "quickActionMenu", "De", "quickActionMenuForText", "styleAssetSourceId", "styleAssetSource", "createStyleAssetSource", "addStyleAssetSource", "GptImage1_image2image_default", "Nl", "input", "width", "height", "Zs", "abortSignal", "formData", "blockId", "exportedBlob", "MimeType", "image_url", "mimeType", "resolvedImageUrl", "he", "imageUrlBlob", "gr", "hasGlobalAPIKey", "baseUrl", "b64_json", "blob", "b64JsonToBlob", "options", "Jo", "L", "context", "uri", "Qs", "styleId", "style", "STYLES", "id", "Wo", "ta", "prompt", "duplicatedBlockId", "ca", "ia", "aa", "la", "uris", "Yo", "engine", "blockIds", "page", "exportedPageBlob", "exportedPageUrl", "duplicatedPage", "childId", "positionX", "positionY", "shape", "rasterizedPageBlock", "fillBlock", "E", "OpenAi", "GptImage1", "open_ai_default"]
4
+ "sourcesContent": ["export default `\n<svg>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratioFree\"\n >\n <path d=\"M7 6C6.44772 6 6 6.44772 6 7V9.22222H4V7C4 5.34315 5.34315 4 7 4H9.22222V6H7Z\" fill=\"currentColor\"/>\n <path d=\"M17 6H14.7778V4H17C18.6569 4 20 5.34315 20 7V9.22222H18V7C18 6.44772 17.5523 6 17 6Z\" fill=\"currentColor\"/>\n <path d=\"M6 14.7778V17C6 17.5523 6.44772 18 7 18H9.22222V20H7C5.34315 20 4 18.6569 4 17V14.7778H6Z\" fill=\"currentColor\"/>\n <path d=\"M18 17V14.7778H20V17C20 18.6569 18.6569 20 17 20H14.7778V18H17C17.5523 18 18 17.5523 18 17Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratio4by3\"\n >\n <path d=\"M6.5 13H8V15H10V16.5H6.5V13Z\" fill=\"currentColor\"/>\n <path d=\"M14 9V7.5H17.5V11H16V9H14Z\" fill=\"currentColor\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M6 4C4.34315 4 3 5.34315 3 7V17C3 18.6569 4.34315 20 6 20H18C19.6569 20 21 18.6569 21 17V7C21 5.34315 19.6569 4 18 4H6ZM5 7C5 6.44772 5.44772 6 6 6H18C18.5523 6 19 6.44772 19 7V17C19 17.5523 18.5523 18 18 18H6C5.44772 18 5 17.5523 5 17V7Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratio16by9\"\n >\n <path d=\"M4.5 13H6V15H8V16.5H4.5V13Z\" fill=\"currentColor\"/>\n <path d=\"M16 9V7.5H19.5V11H18V9H16Z\" fill=\"currentColor\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M4 4C2.34315 4 1 5.34315 1 7V17C1 18.6569 2.34315 20 4 20H20C21.6569 20 23 18.6569 23 17V7C23 5.34315 21.6569 4 20 4H4ZM3 7C3 6.44772 3.44772 6 4 6H20C20.5523 6 21 6.44772 21 7V17C21 17.5523 20.5523 18 20 18H4C3.44772 18 3 17.5523 3 17V7Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratio9by16\"\n >\n <path d=\"M7.5 16H9V18H11V19.5H7.5V16Z\" fill=\"currentColor\"/>\n <path d=\"M13 6V4.5H16.5V8H15V6H13Z\" fill=\"currentColor\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M4 20C4 21.6569 5.34315 23 7 23H17C18.6569 23 20 21.6569 20 20V4C20 2.34315 18.6569 1 17 1H7C5.34315 1 4 2.34315 4 4V20ZM7 21C6.44772 21 6 20.5523 6 20V4C6 3.44772 6.44772 3 7 3H17C17.5523 3 18 3.44772 18 4V20C18 20.5523 17.5523 21 17 21H7Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratio3by4\"\n >\n <path d=\"M11 17.5V16H9V14H7.5V17.5H11Z\" fill=\"currentColor\"/>\n <path d=\"M15 10H16.5V6.5H13V8H15V10Z\" fill=\"currentColor\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M20 18C20 19.6569 18.6569 21 17 21H7C5.34315 21 4 19.6569 4 18V6C4 4.34315 5.34315 3 7 3H17C18.6569 3 20 4.34315 20 6V18ZM17 19C17.5523 19 18 18.5523 18 18V6C18 5.44772 17.5523 5 17 5H7C6.44771 5 6 5.44771 6 6V18C6 18.5523 6.44772 19 7 19H17Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratio1by1\"\n >\n <path d=\"M17.4142 8.00009L16 6.58587L14.2929 8.29298L15.7071 9.70719L17.4142 8.00009Z\" fill=\"currentColor\"/>\n <path d=\"M13.0404 12.3739L15.0404 10.3739L13.6262 8.95965L11.6262 10.9596L13.0404 12.3739Z\" fill=\"currentColor\"/>\n <path d=\"M10.3737 15.0405L12.3737 13.0405L10.9595 11.6263L8.95953 13.6263L10.3737 15.0405Z\" fill=\"currentColor\"/>\n <path d=\"M9.70708 15.7072L8.29286 14.293L6.58576 16.0001L7.99997 17.4143L9.70708 15.7072Z\" fill=\"currentColor\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M7 4C5.34315 4 4 5.34315 4 7V17C4 18.6569 5.34315 20 7 20H17C18.6569 20 20 18.6569 20 17V7C20 5.34315 18.6569 4 17 4H7ZM6 7C6 6.44772 6.44772 6 7 6H17C17.5523 6 18 6.44772 18 7V17C18 17.5523 17.5523 18 17 18H7C6.44772 18 6 17.5523 6 17V7Z\" fill=\"currentColor\"/>\n </symbol>\n</svg>\n`;\n", "import type {\n AssetDefinition,\n AssetQueryData,\n AssetResult,\n AssetSource,\n AssetsQueryResult\n} from '@cesdk/engine';\n\n/**\n * Simplified value type for select inputs that can be converted to asset definitions\n */\nexport type SelectValue = {\n id: string;\n label: string;\n thumbUri?: string;\n meta?: { [key: string]: any };\n};\n\n/**\n * A custom AssetSource implementation that manages assets from an array\n * and provides additional functionality like to mark assets as active or changing\n * labels.\n */\nexport class CustomAssetSource implements AssetSource {\n /** The unique id of the asset source */\n id: string;\n\n /** Array of assets to be served by this source */\n private assets: AssetDefinition[];\n\n /** Set of IDs for active assets */\n private activeAssetIds: Set<string>;\n\n /**\n * Creates a new instance of CustomAssetSource\n *\n * @param id - The unique identifier for this asset source\n * @param assets - Array of asset definitions or SelectValue objects to include in this source\n */\n constructor(id: string, assets: (AssetDefinition | SelectValue)[] = []) {\n this.id = id;\n this.assets = assets.map((asset) => {\n // Check if the asset is a SelectValue by looking for the label property as a string\n if (\n typeof (asset as SelectValue).label === 'string' &&\n !(\n (asset as AssetDefinition).label &&\n typeof (asset as AssetDefinition).label === 'object'\n )\n ) {\n const selectValue = asset as SelectValue;\n // Convert SelectValue to AssetDefinition\n return {\n id: selectValue.id,\n label: { en: selectValue.label },\n meta: selectValue.thumbUri\n ? { ...(selectValue.meta ?? {}), thumbUri: selectValue.thumbUri }\n : selectValue.meta\n } as AssetDefinition;\n }\n return asset as AssetDefinition;\n });\n this.activeAssetIds = new Set<string>();\n }\n\n /**\n * Find assets based on the provided query data\n * Supports pagination, searching, filtering, and active-first sorting\n *\n * @param queryData - Query parameters to filter and sort assets\n * @returns Promise with the query results\n */\n async findAssets(\n queryData: AssetQueryData\n ): Promise<AssetsQueryResult | undefined> {\n const {\n page,\n perPage,\n locale = 'en',\n sortActiveFirst,\n query,\n tags,\n groups,\n excludeGroups,\n sortingOrder,\n sortKey\n } = queryData;\n\n // Start with all assets\n let filteredAssets = [...this.assets];\n\n // Filter by groups if provided\n if (groups && groups.length > 0) {\n filteredAssets = filteredAssets.filter(\n (asset) =>\n asset.groups && groups.some((group) => asset.groups?.includes(group))\n );\n }\n\n // Filter out excluded groups if provided\n if (excludeGroups && excludeGroups.length > 0) {\n filteredAssets = filteredAssets.filter(\n (asset) =>\n !asset.groups ||\n !excludeGroups.some((group) => asset.groups?.includes(group))\n );\n }\n\n // Filter by query (search in label and tags)\n if (query) {\n const lowerQuery = query.toLowerCase();\n filteredAssets = filteredAssets.filter((asset) => {\n const label = asset.label?.[locale]?.toLowerCase();\n const assetTags = asset.tags?.[locale] || [];\n\n return (\n (label && label.includes(lowerQuery)) ||\n assetTags.some((tag) => tag.toLowerCase().includes(lowerQuery))\n );\n });\n }\n\n // Filter by exact tags if provided\n if (tags && tags.length > 0) {\n const tagArray = Array.isArray(tags) ? tags : [tags];\n filteredAssets = filteredAssets.filter((asset) => {\n const assetTags = asset.tags?.[locale] || [];\n return tagArray.some((tag) => assetTags.includes(tag));\n });\n }\n\n // Sort by active first if requested\n if (sortActiveFirst) {\n filteredAssets.sort((a, b) => {\n const aActive = this.activeAssetIds.has(a.id);\n const bActive = this.activeAssetIds.has(b.id);\n\n if (aActive && !bActive) return -1;\n if (!aActive && bActive) return 1;\n return 0;\n });\n }\n\n // Sort by sortKey if provided\n if (sortKey && sortKey !== 'id') {\n filteredAssets.sort((a, b) => {\n // Sort by metadata field\n const aValue = a.meta?.[sortKey];\n const bValue = b.meta?.[sortKey];\n\n if (aValue === undefined) return 1;\n if (bValue === undefined) return -1;\n\n if (typeof aValue === 'string' && typeof bValue === 'string') {\n return sortingOrder === 'Descending'\n ? bValue.localeCompare(aValue)\n : aValue.localeCompare(bValue);\n }\n\n if (typeof aValue === 'number' && typeof bValue === 'number') {\n return sortingOrder === 'Descending'\n ? bValue - aValue\n : aValue - bValue;\n }\n\n return 0;\n });\n } else if (sortKey === 'id') {\n // Sort by id\n filteredAssets.sort((a, b) => {\n return sortingOrder === 'Descending'\n ? b.id.localeCompare(a.id)\n : a.id.localeCompare(b.id);\n });\n }\n\n // Calculate pagination\n const total = filteredAssets.length;\n const startIndex = page * perPage;\n const endIndex = startIndex + perPage;\n const paginatedAssets = filteredAssets.slice(startIndex, endIndex);\n\n // Transform AssetDefinition objects to AssetResult objects\n const resultAssets: AssetResult[] = paginatedAssets.map((asset) => {\n return {\n id: asset.id,\n groups: asset.groups,\n meta: asset.meta,\n payload: asset.payload,\n locale,\n label: asset.label?.[locale],\n tags: asset.tags?.[locale],\n active: this.activeAssetIds.has(asset.id)\n };\n });\n\n // Calculate next page if there are more assets\n const nextPage = endIndex < total ? page + 1 : undefined;\n\n return {\n assets: resultAssets,\n currentPage: page,\n nextPage,\n total\n };\n }\n\n updateLabel(assetId: string, label: string, locale: string): void {\n this.assets.forEach((asset) => {\n if (asset.id === assetId) {\n asset.label = asset.label || {};\n asset.label[locale] = label;\n }\n });\n }\n\n /**\n * Get the asset select value by its ID\n *\n * @param assetId - The ID of the asset to retrieve\n * @returns The SelectValue object for the asset or undefined if not found\n */\n getAssetSelectValue(assetId: string): SelectValue | undefined {\n const asset = this.assets.find(({ id }) => id === assetId);\n if (asset) {\n return {\n id: asset.id,\n label: asset.label?.en || '',\n thumbUri: asset.meta?.thumbUri\n };\n }\n return undefined;\n }\n\n /**\n * Get an asset by its ID\n */\n getAsset(id: string): AssetDefinition | undefined {\n return this.assets.find((asset) => asset.id === id);\n }\n\n /**\n * Set an asset as active by its ID\n *\n * @param assetId - The ID of the asset to mark as active\n */\n setAssetActive(assetId: string): void {\n this.activeAssetIds.add(assetId);\n }\n\n /**\n * Get all active asset IDs\n *\n * @returns Array of active asset IDs\n */\n getActiveAssetIds(): string[] {\n return Array.from(this.activeAssetIds);\n }\n\n /**\n * Set multiple assets as active by their IDs\n *\n * @param assetIds - Array of asset IDs to mark as active\n */\n setAssetsActive(assetIds: string[]): void {\n assetIds.forEach((id) => this.activeAssetIds.add(id));\n }\n\n /**\n * Set an asset as inactive by its ID\n *\n * @param assetId - The ID of the asset to mark as inactive\n */\n setAssetInactive(assetId: string): void {\n this.activeAssetIds.delete(assetId);\n }\n\n /**\n * Clear all active assets\n */\n clearActiveAssets(): void {\n this.activeAssetIds.clear();\n }\n\n /**\n * Check if an asset is marked as active\n *\n * @param assetId - The ID of the asset to check\n * @returns True if the asset is active, false otherwise\n */\n isAssetActive(assetId: string): boolean {\n return this.activeAssetIds.has(assetId);\n }\n\n /**\n * Add an asset to this source\n *\n * @param asset - The asset definition to add\n */\n addAsset(asset: AssetDefinition): void {\n // Check if asset with this ID already exists\n const existingIndex = this.assets.findIndex((a) => a.id === asset.id);\n if (existingIndex >= 0) {\n // Replace existing asset\n this.assets[existingIndex] = asset;\n } else {\n // Add new asset\n this.assets.push(asset);\n }\n }\n\n /**\n * Remove an asset from this source\n *\n * @param assetId - The ID of the asset to remove\n */\n removeAsset(assetId: string): void {\n const index = this.assets.findIndex((asset) => asset.id === assetId);\n if (index !== -1) {\n this.assets.splice(index, 1);\n this.activeAssetIds.delete(assetId);\n }\n }\n\n /**\n * Get all available groups from the assets\n *\n * @returns Array of unique group names\n */\n async getGroups(): Promise<string[]> {\n const groups = new Set<string>();\n this.assets.forEach((asset) => {\n if (asset.groups) {\n asset.groups.forEach((group) => groups.add(group));\n }\n });\n return Array.from(groups);\n }\n\n /**\n * Returns the supported MIME types for this asset source\n *\n * @returns Array of supported MIME types\n */\n getSupportedMimeTypes(): string[] {\n return [\n 'image/jpeg',\n 'image/png',\n 'image/svg+xml',\n 'image/webp',\n 'video/mp4',\n 'audio/mpeg'\n ];\n }\n}\n\n/**\n * Helper function to create a CustomAssetSource instance\n *\n * @param id - The unique identifier for this asset source\n * @param assets - Array of asset definitions or SelectValue objects to include in this source\n * @returns A new CustomAssetSource instance\n */\nexport function createCustomAssetSource(\n id: string,\n assets: (AssetDefinition | SelectValue)[] = []\n): CustomAssetSource {\n return new CustomAssetSource(id, assets);\n}\n\nexport default CustomAssetSource;\n", "/* eslint-disable no-console */\nimport {\n CreativeEngine,\n type AssetDefinition,\n type AssetQueryData,\n type AssetResult,\n type AssetSource,\n type AssetsQueryResult\n} from '@cesdk/cesdk-js';\n\ntype BlobEntry = {\n id: string;\n blob: Blob;\n};\n\n// Asset definition with meta containing insertedAt timestamp\ntype AssetEntryWithMeta = AssetDefinition;\n\n/**\n * IndexedDBAssetSource implements the AssetSource interface using IndexedDB as the storage backend.\n */\nexport class IndexedDBAssetSource implements AssetSource {\n /** The unique id of the API */\n public readonly id: string;\n\n public readonly engine: CreativeEngine;\n\n private readonly dbName: string;\n\n private readonly dbVersion: number;\n\n private readonly assetStoreName: string = 'assets';\n\n private readonly blobStoreName: string = 'blobs';\n\n private db: IDBDatabase | null = null;\n\n /**\n * Creates a new IndexedDBAssetSource\n *\n * @param id - The unique identifier for this asset source\n * @param {Object} [options] - Optional configuration options.\n * @param {string} [options.dbName] - The name of the database.\n * @param {number} [options.dbVersion] - The version number of the database.\n */\n constructor(\n id: string,\n engine: CreativeEngine,\n options?: {\n dbName?: string;\n dbVersion?: number;\n }\n ) {\n this.id = id;\n this.engine = engine;\n this.dbName = options?.dbName ?? `ly.img.assetSource/${id}`;\n this.dbVersion = options?.dbVersion ?? 1;\n }\n\n /**\n * Initialize the database connection and create object stores if needed\n */\n public async initialize(): Promise<void> {\n if (this.db) {\n return;\n }\n\n return new Promise((resolve, reject) => {\n const request = indexedDB.open(this.dbName, this.dbVersion);\n\n request.onerror = (event) => {\n reject(\n new Error(\n `Failed to open IndexedDB: ${(event.target as IDBRequest).error}`\n )\n );\n };\n\n request.onupgradeneeded = (event) => {\n const db = (event.target as IDBOpenDBRequest).result;\n\n // Create asset store if it doesn't exist\n if (!db.objectStoreNames.contains(this.assetStoreName)) {\n db.createObjectStore(this.assetStoreName, {\n keyPath: 'id'\n });\n }\n // Create blob store if it doesn't exist\n if (!db.objectStoreNames.contains(this.blobStoreName)) {\n db.createObjectStore(this.blobStoreName, {\n keyPath: 'id'\n });\n }\n };\n\n request.onsuccess = (event) => {\n this.db = (event.target as IDBOpenDBRequest).result;\n resolve();\n };\n });\n }\n\n /**\n * Close the database connection\n */\n public close(): void {\n if (this.db) {\n this.db.close();\n this.db = null;\n }\n }\n\n /**\n * Find all assets for the given type and the provided query data.\n *\n * @param queryData - The query parameters for filtering assets\n * @param insertionSortOrder - Optional parameter to sort by insertion time: 'asc' for oldest first, 'desc' for newest first (default)\n * @returns A promise that resolves to the query results or undefined if there was an error\n */\n public async findAssets(\n queryData: AssetQueryData\n ): Promise<AssetsQueryResult | undefined> {\n await this.initialize();\n\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n try {\n // Get all assets from the store with specified insertion order\n const assetDefinitions = await this.getAllAssets('asc');\n\n let assetResults = assetDefinitions.reduce((acc, assetDefinition) => {\n const locale = queryData.locale ?? 'en';\n let label = '';\n let tags: string[] = [];\n\n // Handle localized label if available\n if (\n assetDefinition.label != null &&\n typeof assetDefinition.label === 'object' &&\n assetDefinition.label[locale]\n ) {\n label = assetDefinition.label[locale];\n }\n\n // Handle localized tags if available\n if (\n assetDefinition.tags != null &&\n typeof assetDefinition.tags === 'object' &&\n assetDefinition.tags[locale]\n ) {\n tags = assetDefinition.tags[locale];\n }\n\n const result: AssetResult = {\n ...assetDefinition,\n label,\n tags\n };\n\n if (this.filterAsset(result, queryData)) {\n acc.push(result);\n }\n\n return acc;\n }, [] as AssetResult[]);\n\n assetResults = await this.restoreBlobUrls(assetResults);\n\n // Apply sorting\n assetResults = this.sortAssets(assetResults, queryData);\n\n // Apply pagination\n const { page, perPage } = queryData;\n const startIndex = page * perPage;\n const endIndex = startIndex + perPage;\n const paginatedAssets = assetResults.slice(startIndex, endIndex);\n\n // Determine if there's a next page\n const nextPage = endIndex < assetResults.length ? page + 1 : undefined;\n\n const result = {\n assets: paginatedAssets,\n currentPage: page,\n nextPage,\n total: assetResults.length\n };\n\n return result;\n } catch (error) {\n console.error('Error finding assets:', error);\n return undefined;\n }\n }\n\n public async getGroups(): Promise<string[]> {\n await this.initialize();\n\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n return new Promise((resolve, reject) => {\n const transaction = this.db!.transaction(this.assetStoreName, 'readonly');\n const store = transaction.objectStore(this.assetStoreName);\n const request = store.getAll();\n\n request.onsuccess = () => {\n const allGroups = new Set<string>();\n\n // Extract all groups from all assets\n (request.result as AssetResult[]).forEach((asset) => {\n if (asset.groups && Array.isArray(asset.groups)) {\n asset.groups.forEach((group) => allGroups.add(group));\n }\n });\n\n const uniqueGroups = [...allGroups];\n resolve(uniqueGroups);\n };\n\n request.onerror = () => {\n reject(new Error(`Failed to get groups: ${request.error}`));\n };\n });\n }\n\n /**\n * Adds the given asset to this source. Part of the AssetSource interface.\n *\n * @param asset - The asset definition to add\n */\n public addAsset(asset: AssetDefinition): void {\n this.initialize()\n .then(async () => {\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n const transaction = this.db.transaction(\n this.assetStoreName,\n 'readwrite'\n );\n const assetStore = transaction.objectStore(this.assetStoreName);\n\n const blobsToStore = new Set<string>();\n processBlobUrls(asset, (value) => {\n blobsToStore.add(value);\n });\n\n setTimeout(() => {\n this.storeBlobUrls([...blobsToStore]);\n });\n\n // Ensure asset has meta object with insertedAt timestamp\n const assetWithMeta: AssetEntryWithMeta = {\n ...asset,\n meta: {\n ...asset.meta,\n insertedAt: asset.meta?.insertedAt || Date.now()\n }\n };\n\n // Store the asset in the database\n assetStore.put(assetWithMeta);\n\n transaction.onerror = () => {\n console.error(`Failed to add asset: ${transaction.error}`);\n };\n })\n .catch((error) => {\n console.error('Error initializing database:', error);\n });\n }\n\n /**\n * Removes the given asset from this source. Part of the AssetSource interface.\n *\n * @param assetId - The ID of the asset to remove\n */\n public async removeAsset(assetId: string): Promise<void> {\n const asset = await this.getAsset(assetId);\n\n return this.initialize()\n .then(() => {\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n const transaction = this.db.transaction(\n this.assetStoreName,\n 'readwrite'\n );\n const store = transaction.objectStore(this.assetStoreName);\n store.delete(assetId);\n\n transaction.oncomplete = () => {\n processBlobUrls(asset, (value) => {\n this.removeBlob(value);\n });\n this.engine.asset.assetSourceContentsChanged(this.id);\n };\n\n transaction.onerror = () => {\n console.error(`Failed to remove asset: ${transaction.error}`);\n };\n })\n .catch((error) => {\n console.error('Error initializing database:', error);\n });\n }\n\n /**\n * Removes the given asset from this source. Part of the AssetSource interface.\n *\n * @param assetId - The ID of the asset to remove\n */\n public async removeBlob(blobId: string): Promise<void> {\n return this.initialize()\n .then(() => {\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n const transaction = this.db.transaction(\n this.blobStoreName,\n 'readwrite'\n );\n const store = transaction.objectStore(this.blobStoreName);\n store.delete(blobId);\n\n transaction.onerror = () => {\n console.error(`Failed to remove blob: ${transaction.error}`);\n };\n })\n .catch((error) => {\n console.error('Error initializing database:', error);\n });\n }\n\n /**\n * Get all assets from the database sorted by insertion order (newest to oldest)\n *\n * @param sortOrder - Optional parameter to specify sort order: 'asc' for oldest first, 'desc' for newest first (default)\n * @returns A promise that resolves to an array of all assets\n */\n private async getAllAssets(\n sortOrder: 'asc' | 'desc' = 'desc'\n ): Promise<AssetDefinition[]> {\n return new Promise((resolve, reject) => {\n const transaction = this.db!.transaction(this.assetStoreName, 'readonly');\n const store = transaction.objectStore(this.assetStoreName);\n const request = store.getAll();\n\n request.onsuccess = () => {\n const assets = request.result as AssetEntryWithMeta[];\n\n // Sort by insertion timestamp\n assets.sort((a, b) => {\n // Default to current time if insertedAt is missing (for backward compatibility)\n // First check in meta.insertedAt, then fallback to legacy _insertedAt for backward compatibility\n const timeA =\n a.meta?.insertedAt || (a as any)._insertedAt || Date.now();\n const timeB =\n b.meta?.insertedAt || (b as any)._insertedAt || Date.now();\n\n // Sort based on requested order\n return sortOrder === 'asc'\n ? timeA - timeB // oldest first\n : timeB - timeA; // newest first (default)\n });\n\n resolve(assets);\n };\n\n request.onerror = () => {\n reject(new Error(`Failed to get assets: ${request.error}`));\n };\n });\n }\n\n // Retrieve a blob by ID\n async getAsset(id: string): Promise<AssetResult | undefined> {\n return new Promise((resolve, reject) => {\n const transaction = this.db!.transaction(this.assetStoreName, 'readonly');\n const store = transaction.objectStore(this.assetStoreName);\n const request = store.get(id);\n\n request.onsuccess = () => {\n resolve(request.result as AssetResult);\n };\n\n request.onerror = () => {\n reject(new Error(`Failed to get blob: ${request.error}`));\n };\n });\n }\n\n // Retrieve a blob by ID\n async getBlob(id: string): Promise<BlobEntry | undefined> {\n return new Promise((resolve, reject) => {\n const transaction = this.db!.transaction(this.blobStoreName, 'readonly');\n const store = transaction.objectStore(this.blobStoreName);\n const request = store.get(id);\n\n request.onsuccess = () => {\n resolve(request.result as BlobEntry);\n };\n\n request.onerror = () => {\n reject(new Error(`Failed to get blob: ${request.error}`));\n };\n });\n }\n\n async createBlobUrlFromStore(blobUrl: string): Promise<string> {\n const blobEntry = await this.getBlob(blobUrl);\n if (blobEntry != null) {\n return URL.createObjectURL(blobEntry.blob);\n }\n return blobUrl;\n }\n\n async storeBlobUrls(urls: string[]): Promise<void> {\n const blobsToStore: { [key: string]: Blob } = {};\n await Promise.all(\n urls.map(async (blobUrl) => {\n const blobResponse = await fetch(blobUrl);\n const blob = await blobResponse.blob();\n blobsToStore[blobUrl] = blob;\n })\n );\n\n return this.initialize()\n .then(async () => {\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n const transaction = this.db.transaction(\n this.blobStoreName,\n 'readwrite'\n );\n const blobStore = transaction.objectStore(this.blobStoreName);\n\n // Store the asset in the database\n Object.entries(blobsToStore).forEach(([key, blob]) => {\n const asset: BlobEntry = { id: key, blob };\n blobStore.put(asset);\n });\n\n transaction.onerror = () => {\n console.error(`Failed to add blobs: ${transaction.error}`);\n };\n })\n .catch((error) => {\n console.error('Error initializing database:', error);\n });\n }\n\n async restoreBlobUrls(assets: AssetResult[]): Promise<AssetResult[]> {\n const blobReplaced: { [key: string]: string } = {};\n const blobUrls: Set<string> = new Set();\n processBlobUrls(assets, (value) => {\n blobUrls.add(value);\n });\n\n await Promise.all(\n [...blobUrls].map(async (value) => {\n const newUrl = await this.createBlobUrlFromStore(value);\n blobReplaced[value] = newUrl;\n })\n );\n\n return processBlobUrls(assets, (value) => {\n return blobReplaced[value] ?? value;\n });\n }\n\n /**\n * Returns if the given asset should be filtered based on query data\n *\n * @param asset - The asset to filter\n * @param queryData - The query parameters to filter by\n * @returns true if the asset should be included, false otherwise\n */\n private filterAsset(asset: AssetResult, queryData: AssetQueryData): boolean {\n const { query, tags, groups, excludeGroups } = queryData;\n\n // Filter by query string (search on label and tags)\n if (query && query.trim() !== '') {\n const lowerQuery = query.trim().toLowerCase().split(' ');\n\n const lowerLabel = asset.label?.toLowerCase() ?? '';\n const lowerTags = asset.tags?.map((tag) => tag.toLowerCase()) ?? [];\n\n const matchLabelOrTag = lowerQuery.every((word) => {\n return (\n lowerLabel.includes(word) ||\n lowerTags.some((tag) => tag.includes(word))\n );\n });\n\n if (!matchLabelOrTag) {\n return false;\n }\n }\n\n // Filter by exact tags if provided by the query\n if (tags) {\n const tagList = Array.isArray(tags) ? tags : [tags];\n if (\n tagList.length > 0 &&\n (!asset.tags || !tagList.every((tag) => asset.tags?.includes(tag)))\n ) {\n return false;\n }\n }\n\n // Filter by groups\n if (groups && groups.length > 0) {\n if (\n !asset.groups ||\n !groups.some((group) => asset.groups?.includes(group))\n ) {\n return false;\n }\n }\n\n // Filter by excluded groups\n if (excludeGroups && excludeGroups.length > 0) {\n if (\n asset.groups &&\n asset.groups.some((group) => excludeGroups.includes(group))\n ) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Sort assets based on query data\n *\n * @param assets - The assets to sort\n * @param queryData - The query parameters with sorting information\n * @returns The sorted assets\n */\n private sortAssets(\n assets: AssetResult[],\n queryData: AssetQueryData\n ): AssetResult[] {\n const { sortingOrder, sortKey, sortActiveFirst } = queryData;\n\n // Clone the array to avoid modifying the original\n const sortedAssets = [...assets];\n\n // If no sorting order specified or set to 'None', return the current order\n if (!sortingOrder || sortingOrder === 'None') {\n return sortedAssets;\n }\n\n // Sort by the specified key\n if (sortKey) {\n sortedAssets.sort((a, b) => {\n let valueA;\n let valueB;\n\n if (sortKey === 'id') {\n valueA = a.id;\n valueB = b.id;\n } else {\n // Handle metadata sorting (assuming metadata is stored in a 'metadata' field)\n valueA = a.meta?.[sortKey] ?? null;\n valueB = b.meta?.[sortKey] ?? null;\n }\n\n // Handle null/undefined values\n if (valueA === null || valueA === undefined)\n return sortingOrder === 'Ascending' ? -1 : 1;\n if (valueB === null || valueB === undefined)\n return sortingOrder === 'Ascending' ? 1 : -1;\n\n // Compare values based on sorting order\n if (typeof valueA === 'string' && typeof valueB === 'string') {\n return sortingOrder === 'Ascending'\n ? valueA.localeCompare(valueB)\n : valueB.localeCompare(valueA);\n } else {\n return sortingOrder === 'Ascending'\n ? valueA < valueB\n ? -1\n : valueA > valueB\n ? 1\n : 0\n : valueA > valueB\n ? -1\n : valueA < valueB\n ? 1\n : 0;\n }\n });\n } else if (sortingOrder === 'Descending') {\n // If no sort key is specified, and sorting order set\n // to Descending, just reverse original order\n sortedAssets.reverse();\n }\n\n // Sort by active first if requested\n if (sortActiveFirst) {\n sortedAssets.sort((a, b) => {\n if (a.active && !b.active) return -1;\n if (!a.active && b.active) return 1;\n return 0;\n });\n }\n\n return sortedAssets;\n }\n}\n\n/**\n * Goes through an object and calls a callback for every string value that starts with 'blob:'\n * The callback can return a string to replace the original value\n * @param obj The object to traverse\n * @param callback Function to call when a blob URL is found, can return a replacement value\n * @param path Current path in the object (used for recursion)\n * @returns The modified object (or the original if no replacements were made)\n */\nfunction processBlobUrls<T>(\n obj: T,\n callback: (value: string, path: string) => string | void,\n path: string = ''\n): T {\n // Return the object as is if it's null or not an object\n if (obj === null || typeof obj !== 'object') {\n return obj;\n }\n\n // Handle arrays\n if (Array.isArray(obj)) {\n for (let index = 0; index < obj.length; index++) {\n const currentPath = path ? `${path}[${index}]` : `[${index}]`;\n\n if (typeof obj[index] === 'string' && obj[index].startsWith('blob:')) {\n const replacement = callback(obj[index], currentPath);\n if (typeof replacement === 'string') {\n obj[index] = replacement;\n }\n } else {\n obj[index] = processBlobUrls(obj[index], callback, currentPath);\n }\n }\n return obj;\n }\n\n // Handle regular objects\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n const value = obj[key];\n const currentPath = path ? `${path}.${key}` : key;\n\n if (typeof value === 'string' && value.startsWith('blob:')) {\n const replacement = callback(value, currentPath);\n if (typeof replacement === 'string') {\n // @ts-ignore\n obj[key] = replacement;\n }\n } else {\n obj[key] = processBlobUrls(value, callback, currentPath);\n }\n }\n }\n\n return obj;\n}\n\nexport default IndexedDBAssetSource;\n", "/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type {\n AssetDefinition,\n AssetQueryData,\n AssetResult,\n AssetSource,\n AssetsQueryResult\n} from '@cesdk/cesdk-js';\nimport CreativeEditorSDK from '@cesdk/cesdk-js';\n\n/**\n * AggregatedAssetSource implements the AssetSource interface by aggregating\n * multiple asset sources via the cesdk API and combining their results.\n *\n * This asset source is read-only - it does not support adding or removing assets.\n */\nexport class AggregatedAssetSource implements AssetSource {\n /** The unique id of the asset source */\n public readonly id: string;\n\n /** The Creative Editor SDK instance */\n private cesdk: CreativeEditorSDK;\n\n /** The IDs of asset sources to aggregate */\n private assetSourceIds: string[];\n\n /**\n * Creates a new AggregatedAssetSource\n *\n * @param id - The unique identifier for this asset source\n * @param cesdk - The Creative Editor SDK instance\n * @param assetSourceIds - The IDs of asset sources to aggregate\n */\n constructor(id: string, cesdk: CreativeEditorSDK, assetSourceIds: string[]) {\n this.id = id;\n this.cesdk = cesdk;\n this.assetSourceIds = assetSourceIds;\n }\n\n /**\n * Find assets across all aggregated sources based on the provided query data\n * Results are sorted by the insertedAt timestamp in meta field\n *\n * @param queryData - Query parameters to filter and sort assets\n * @returns Promise with the query results\n */\n async findAssets(\n queryData: AssetQueryData\n ): Promise<AssetsQueryResult | undefined> {\n try {\n // Query all asset sources via cesdk\n const queryPromises = this.assetSourceIds.map((sourceId) =>\n this.cesdk.engine.asset.findAssets(sourceId, {\n ...queryData,\n // Increase page size to get all assets from each source\n // We'll handle pagination after merging\n perPage: 9999,\n page: 0\n })\n );\n\n // Wait for all queries to complete\n const results = await Promise.all(queryPromises);\n\n // Combine all assets from all sources\n let allAssets: AssetResult[] = [];\n results.forEach((result) => {\n if (result?.assets) {\n allAssets = allAssets.concat(result.assets);\n }\n });\n\n // Sort by insertedAt timestamp\n allAssets.sort((a, b) => {\n const timeA = (a.meta?.insertedAt as number) || 0;\n const timeB = (b.meta?.insertedAt as number) || 0;\n\n // Sort newest first (descending)\n return timeB - timeA;\n });\n\n // Apply pagination after merging\n const { page, perPage } = queryData;\n const startIndex = page * perPage;\n const endIndex = startIndex + perPage;\n const paginatedAssets = allAssets.slice(startIndex, endIndex);\n\n // Calculate if there is a next page\n const nextPage = endIndex < allAssets.length ? page + 1 : undefined;\n\n return {\n assets: paginatedAssets,\n currentPage: page,\n nextPage,\n total: allAssets.length\n };\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error finding assets:', error);\n return undefined;\n }\n }\n\n /**\n * Retrieves all groups from all aggregated asset sources using cesdk\n * @returns Promise with an array of unique group names\n */\n async getGroups(): Promise<string[]> {\n const groupPromises = this.assetSourceIds.map((sourceId) =>\n this.cesdk.engine.asset.getGroups(sourceId)\n );\n\n const groupArrays = await Promise.all(groupPromises);\n\n // Combine and deduplicate groups\n const uniqueGroups = new Set<string>();\n groupArrays.forEach((groups) => {\n groups.forEach((group) => uniqueGroups.add(group));\n });\n\n return Array.from(uniqueGroups);\n }\n\n /**\n * This operation is not supported in AggregatedAssetSource\n * @throws Error - This method is not supported\n */\n addAsset(_asset: AssetDefinition): void {\n throw new Error('AggregatedAssetSource does not support adding assets');\n }\n\n /**\n * This operation is not supported in AggregatedAssetSource\n * @throws Error - This method is not supported\n */\n removeAsset(_assetId: string): void {\n throw new Error('AggregatedAssetSource does not support removing assets');\n }\n}\n\n/**\n * Helper function to create an AggregatedAssetSource instance\n *\n * @param id - The unique identifier for this asset source\n * @param cesdk - The Creative Editor SDK instance\n * @param assetSourceIds - The IDs of asset sources to aggregate\n * @returns A new AggregatedAssetSource instance\n */\nexport function createAggregatedAssetSource(\n id: string,\n cesdk: CreativeEditorSDK,\n assetSourceIds: string[]\n): AggregatedAssetSource {\n return new AggregatedAssetSource(id, cesdk, assetSourceIds);\n}\n\nexport default AggregatedAssetSource;\n", "import { type CreativeEngine } from '@cesdk/cesdk-js';\n\nclass Metadata<V> {\n engine: CreativeEngine;\n\n key: string;\n\n constructor(engine: CreativeEngine, key: string) {\n this.engine = engine;\n this.key = key;\n }\n\n hasData(blockId: number): boolean {\n return (\n this.engine.block.isValid(blockId) &&\n this.engine.block.hasMetadata(blockId, this.key)\n );\n }\n\n get(blockId: number): V | undefined {\n if (this.hasData(blockId)) {\n return JSON.parse(this.engine.block.getMetadata(blockId, this.key));\n }\n return undefined;\n }\n\n set(blockId: number, value: V) {\n this.engine.block.setMetadata(blockId, this.key, JSON.stringify(value));\n }\n\n clear(blockId: number) {\n if (this.engine.block.hasMetadata(blockId, this.key)) {\n this.engine.block.removeMetadata(blockId, this.key);\n }\n }\n}\n\nexport default Metadata;\n", "/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\nexport default freeGlobal;\n", "import freeGlobal from './_freeGlobal.js';\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\nexport default root;\n", "import root from './_root.js';\n\n/** Built-in value references. */\nvar Symbol = root.Symbol;\n\nexport default Symbol;\n", "import Symbol from './_Symbol.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\nfunction getRawTag(value) {\n var isOwn = hasOwnProperty.call(value, symToStringTag),\n tag = value[symToStringTag];\n\n try {\n value[symToStringTag] = undefined;\n var unmasked = true;\n } catch (e) {}\n\n var result = nativeObjectToString.call(value);\n if (unmasked) {\n if (isOwn) {\n value[symToStringTag] = tag;\n } else {\n delete value[symToStringTag];\n }\n }\n return result;\n}\n\nexport default getRawTag;\n", "/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\nfunction objectToString(value) {\n return nativeObjectToString.call(value);\n}\n\nexport default objectToString;\n", "import Symbol from './_Symbol.js';\nimport getRawTag from './_getRawTag.js';\nimport objectToString from './_objectToString.js';\n\n/** `Object#toString` result references. */\nvar nullTag = '[object Null]',\n undefinedTag = '[object Undefined]';\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n return (symToStringTag && symToStringTag in Object(value))\n ? getRawTag(value)\n : objectToString(value);\n}\n\nexport default baseGetTag;\n", "/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return value != null && typeof value == 'object';\n}\n\nexport default isObjectLike;\n", "/**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\nvar isArray = Array.isArray;\n\nexport default isArray;\n", "/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n}\n\nexport default isObject;\n", "import baseGetTag from './_baseGetTag.js';\nimport isObject from './isObject.js';\n\n/** `Object#toString` result references. */\nvar asyncTag = '[object AsyncFunction]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n proxyTag = '[object Proxy]';\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n if (!isObject(value)) {\n return false;\n }\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 9 which returns 'object' for typed arrays and other constructors.\n var tag = baseGetTag(value);\n return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;\n}\n\nexport default isFunction;\n", "import root from './_root.js';\n\n/** Used to detect overreaching core-js shims. */\nvar coreJsData = root['__core-js_shared__'];\n\nexport default coreJsData;\n", "import coreJsData from './_coreJsData.js';\n\n/** Used to detect methods masquerading as native. */\nvar maskSrcKey = (function() {\n var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');\n return uid ? ('Symbol(src)_1.' + uid) : '';\n}());\n\n/**\n * Checks if `func` has its source masked.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` is masked, else `false`.\n */\nfunction isMasked(func) {\n return !!maskSrcKey && (maskSrcKey in func);\n}\n\nexport default isMasked;\n", "/** Used for built-in method references. */\nvar funcProto = Function.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/**\n * Converts `func` to its source code.\n *\n * @private\n * @param {Function} func The function to convert.\n * @returns {string} Returns the source code.\n */\nfunction toSource(func) {\n if (func != null) {\n try {\n return funcToString.call(func);\n } catch (e) {}\n try {\n return (func + '');\n } catch (e) {}\n }\n return '';\n}\n\nexport default toSource;\n", "import isFunction from './isFunction.js';\nimport isMasked from './_isMasked.js';\nimport isObject from './isObject.js';\nimport toSource from './_toSource.js';\n\n/**\n * Used to match `RegExp`\n * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).\n */\nvar reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g;\n\n/** Used to detect host constructors (Safari). */\nvar reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n\n/** Used for built-in method references. */\nvar funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Used to detect if a method is native. */\nvar reIsNative = RegExp('^' +\n funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\\\$&')\n .replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$'\n);\n\n/**\n * The base implementation of `_.isNative` without bad shim checks.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n * else `false`.\n */\nfunction baseIsNative(value) {\n if (!isObject(value) || isMasked(value)) {\n return false;\n }\n var pattern = isFunction(value) ? reIsNative : reIsHostCtor;\n return pattern.test(toSource(value));\n}\n\nexport default baseIsNative;\n", "/**\n * Gets the value at `key` of `object`.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\nfunction getValue(object, key) {\n return object == null ? undefined : object[key];\n}\n\nexport default getValue;\n", "import baseIsNative from './_baseIsNative.js';\nimport getValue from './_getValue.js';\n\n/**\n * Gets the native function at `key` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the method to get.\n * @returns {*} Returns the function if it's native, else `undefined`.\n */\nfunction getNative(object, key) {\n var value = getValue(object, key);\n return baseIsNative(value) ? value : undefined;\n}\n\nexport default getNative;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar WeakMap = getNative(root, 'WeakMap');\n\nexport default WeakMap;\n", "/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/** Used to detect unsigned integer values. */\nvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n/**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\nfunction isIndex(value, length) {\n var type = typeof value;\n length = length == null ? MAX_SAFE_INTEGER : length;\n\n return !!length &&\n (type == 'number' ||\n (type != 'symbol' && reIsUint.test(value))) &&\n (value > -1 && value % 1 == 0 && value < length);\n}\n\nexport default isIndex;\n", "/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\nexport default eq;\n", "/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\nexport default isLength;\n", "import isFunction from './isFunction.js';\nimport isLength from './isLength.js';\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n}\n\nexport default isArrayLike;\n", "/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Checks if `value` is likely a prototype object.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.\n */\nfunction isPrototype(value) {\n var Ctor = value && value.constructor,\n proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;\n\n return value === proto;\n}\n\nexport default isPrototype;\n", "/**\n * The base implementation of `_.times` without support for iteratee shorthands\n * or max array length checks.\n *\n * @private\n * @param {number} n The number of times to invoke `iteratee`.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the array of results.\n */\nfunction baseTimes(n, iteratee) {\n var index = -1,\n result = Array(n);\n\n while (++index < n) {\n result[index] = iteratee(index);\n }\n return result;\n}\n\nexport default baseTimes;\n", "import baseGetTag from './_baseGetTag.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]';\n\n/**\n * The base implementation of `_.isArguments`.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n */\nfunction baseIsArguments(value) {\n return isObjectLike(value) && baseGetTag(value) == argsTag;\n}\n\nexport default baseIsArguments;\n", "import baseIsArguments from './_baseIsArguments.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Built-in value references. */\nvar propertyIsEnumerable = objectProto.propertyIsEnumerable;\n\n/**\n * Checks if `value` is likely an `arguments` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n * else `false`.\n * @example\n *\n * _.isArguments(function() { return arguments; }());\n * // => true\n *\n * _.isArguments([1, 2, 3]);\n * // => false\n */\nvar isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {\n return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&\n !propertyIsEnumerable.call(value, 'callee');\n};\n\nexport default isArguments;\n", "/**\n * This method returns `false`.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {boolean} Returns `false`.\n * @example\n *\n * _.times(2, _.stubFalse);\n * // => [false, false]\n */\nfunction stubFalse() {\n return false;\n}\n\nexport default stubFalse;\n", "import root from './_root.js';\nimport stubFalse from './stubFalse.js';\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Built-in value references. */\nvar Buffer = moduleExports ? root.Buffer : undefined;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;\n\n/**\n * Checks if `value` is a buffer.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.\n * @example\n *\n * _.isBuffer(new Buffer(2));\n * // => true\n *\n * _.isBuffer(new Uint8Array(2));\n * // => false\n */\nvar isBuffer = nativeIsBuffer || stubFalse;\n\nexport default isBuffer;\n", "import baseGetTag from './_baseGetTag.js';\nimport isLength from './isLength.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n errorTag = '[object Error]',\n funcTag = '[object Function]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n objectTag = '[object Object]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n weakMapTag = '[object WeakMap]';\n\nvar arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]',\n float32Tag = '[object Float32Array]',\n float64Tag = '[object Float64Array]',\n int8Tag = '[object Int8Array]',\n int16Tag = '[object Int16Array]',\n int32Tag = '[object Int32Array]',\n uint8Tag = '[object Uint8Array]',\n uint8ClampedTag = '[object Uint8ClampedArray]',\n uint16Tag = '[object Uint16Array]',\n uint32Tag = '[object Uint32Array]';\n\n/** Used to identify `toStringTag` values of typed arrays. */\nvar typedArrayTags = {};\ntypedArrayTags[float32Tag] = typedArrayTags[float64Tag] =\ntypedArrayTags[int8Tag] = typedArrayTags[int16Tag] =\ntypedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =\ntypedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =\ntypedArrayTags[uint32Tag] = true;\ntypedArrayTags[argsTag] = typedArrayTags[arrayTag] =\ntypedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =\ntypedArrayTags[dataViewTag] = typedArrayTags[dateTag] =\ntypedArrayTags[errorTag] = typedArrayTags[funcTag] =\ntypedArrayTags[mapTag] = typedArrayTags[numberTag] =\ntypedArrayTags[objectTag] = typedArrayTags[regexpTag] =\ntypedArrayTags[setTag] = typedArrayTags[stringTag] =\ntypedArrayTags[weakMapTag] = false;\n\n/**\n * The base implementation of `_.isTypedArray` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n */\nfunction baseIsTypedArray(value) {\n return isObjectLike(value) &&\n isLength(value.length) && !!typedArrayTags[baseGetTag(value)];\n}\n\nexport default baseIsTypedArray;\n", "/**\n * The base implementation of `_.unary` without support for storing metadata.\n *\n * @private\n * @param {Function} func The function to cap arguments for.\n * @returns {Function} Returns the new capped function.\n */\nfunction baseUnary(func) {\n return function(value) {\n return func(value);\n };\n}\n\nexport default baseUnary;\n", "import freeGlobal from './_freeGlobal.js';\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Detect free variable `process` from Node.js. */\nvar freeProcess = moduleExports && freeGlobal.process;\n\n/** Used to access faster Node.js helpers. */\nvar nodeUtil = (function() {\n try {\n // Use `util.types` for Node.js 10+.\n var types = freeModule && freeModule.require && freeModule.require('util').types;\n\n if (types) {\n return types;\n }\n\n // Legacy `process.binding('util')` for Node.js < 10.\n return freeProcess && freeProcess.binding && freeProcess.binding('util');\n } catch (e) {}\n}());\n\nexport default nodeUtil;\n", "import baseIsTypedArray from './_baseIsTypedArray.js';\nimport baseUnary from './_baseUnary.js';\nimport nodeUtil from './_nodeUtil.js';\n\n/* Node.js helper references. */\nvar nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;\n\n/**\n * Checks if `value` is classified as a typed array.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n * @example\n *\n * _.isTypedArray(new Uint8Array);\n * // => true\n *\n * _.isTypedArray([]);\n * // => false\n */\nvar isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;\n\nexport default isTypedArray;\n", "import baseTimes from './_baseTimes.js';\nimport isArguments from './isArguments.js';\nimport isArray from './isArray.js';\nimport isBuffer from './isBuffer.js';\nimport isIndex from './_isIndex.js';\nimport isTypedArray from './isTypedArray.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Creates an array of the enumerable property names of the array-like `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @param {boolean} inherited Specify returning inherited property names.\n * @returns {Array} Returns the array of property names.\n */\nfunction arrayLikeKeys(value, inherited) {\n var isArr = isArray(value),\n isArg = !isArr && isArguments(value),\n isBuff = !isArr && !isArg && isBuffer(value),\n isType = !isArr && !isArg && !isBuff && isTypedArray(value),\n skipIndexes = isArr || isArg || isBuff || isType,\n result = skipIndexes ? baseTimes(value.length, String) : [],\n length = result.length;\n\n for (var key in value) {\n if ((inherited || hasOwnProperty.call(value, key)) &&\n !(skipIndexes && (\n // Safari 9 has enumerable `arguments.length` in strict mode.\n key == 'length' ||\n // Node.js 0.10 has enumerable non-index properties on buffers.\n (isBuff && (key == 'offset' || key == 'parent')) ||\n // PhantomJS 2 has enumerable non-index properties on typed arrays.\n (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||\n // Skip index properties.\n isIndex(key, length)\n ))) {\n result.push(key);\n }\n }\n return result;\n}\n\nexport default arrayLikeKeys;\n", "/**\n * Creates a unary function that invokes `func` with its argument transformed.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {Function} transform The argument transform.\n * @returns {Function} Returns the new function.\n */\nfunction overArg(func, transform) {\n return function(arg) {\n return func(transform(arg));\n };\n}\n\nexport default overArg;\n", "import overArg from './_overArg.js';\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeKeys = overArg(Object.keys, Object);\n\nexport default nativeKeys;\n", "import isPrototype from './_isPrototype.js';\nimport nativeKeys from './_nativeKeys.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction baseKeys(object) {\n if (!isPrototype(object)) {\n return nativeKeys(object);\n }\n var result = [];\n for (var key in Object(object)) {\n if (hasOwnProperty.call(object, key) && key != 'constructor') {\n result.push(key);\n }\n }\n return result;\n}\n\nexport default baseKeys;\n", "import arrayLikeKeys from './_arrayLikeKeys.js';\nimport baseKeys from './_baseKeys.js';\nimport isArrayLike from './isArrayLike.js';\n\n/**\n * Creates an array of the own enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects. See the\n * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n * for more details.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keys(new Foo);\n * // => ['a', 'b'] (iteration order is not guaranteed)\n *\n * _.keys('hi');\n * // => ['0', '1']\n */\nfunction keys(object) {\n return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);\n}\n\nexport default keys;\n", "import getNative from './_getNative.js';\n\n/* Built-in method references that are verified to be native. */\nvar nativeCreate = getNative(Object, 'create');\n\nexport default nativeCreate;\n", "import nativeCreate from './_nativeCreate.js';\n\n/**\n * Removes all key-value entries from the hash.\n *\n * @private\n * @name clear\n * @memberOf Hash\n */\nfunction hashClear() {\n this.__data__ = nativeCreate ? nativeCreate(null) : {};\n this.size = 0;\n}\n\nexport default hashClear;\n", "/**\n * Removes `key` and its value from the hash.\n *\n * @private\n * @name delete\n * @memberOf Hash\n * @param {Object} hash The hash to modify.\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction hashDelete(key) {\n var result = this.has(key) && delete this.__data__[key];\n this.size -= result ? 1 : 0;\n return result;\n}\n\nexport default hashDelete;\n", "import nativeCreate from './_nativeCreate.js';\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Gets the hash value for `key`.\n *\n * @private\n * @name get\n * @memberOf Hash\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction hashGet(key) {\n var data = this.__data__;\n if (nativeCreate) {\n var result = data[key];\n return result === HASH_UNDEFINED ? undefined : result;\n }\n return hasOwnProperty.call(data, key) ? data[key] : undefined;\n}\n\nexport default hashGet;\n", "import nativeCreate from './_nativeCreate.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Checks if a hash value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Hash\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction hashHas(key) {\n var data = this.__data__;\n return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);\n}\n\nexport default hashHas;\n", "import nativeCreate from './_nativeCreate.js';\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/**\n * Sets the hash `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Hash\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the hash instance.\n */\nfunction hashSet(key, value) {\n var data = this.__data__;\n this.size += this.has(key) ? 0 : 1;\n data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;\n return this;\n}\n\nexport default hashSet;\n", "import hashClear from './_hashClear.js';\nimport hashDelete from './_hashDelete.js';\nimport hashGet from './_hashGet.js';\nimport hashHas from './_hashHas.js';\nimport hashSet from './_hashSet.js';\n\n/**\n * Creates a hash object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Hash(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `Hash`.\nHash.prototype.clear = hashClear;\nHash.prototype['delete'] = hashDelete;\nHash.prototype.get = hashGet;\nHash.prototype.has = hashHas;\nHash.prototype.set = hashSet;\n\nexport default Hash;\n", "/**\n * Removes all key-value entries from the list cache.\n *\n * @private\n * @name clear\n * @memberOf ListCache\n */\nfunction listCacheClear() {\n this.__data__ = [];\n this.size = 0;\n}\n\nexport default listCacheClear;\n", "import eq from './eq.js';\n\n/**\n * Gets the index at which the `key` is found in `array` of key-value pairs.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} key The key to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction assocIndexOf(array, key) {\n var length = array.length;\n while (length--) {\n if (eq(array[length][0], key)) {\n return length;\n }\n }\n return -1;\n}\n\nexport default assocIndexOf;\n", "import assocIndexOf from './_assocIndexOf.js';\n\n/** Used for built-in method references. */\nvar arrayProto = Array.prototype;\n\n/** Built-in value references. */\nvar splice = arrayProto.splice;\n\n/**\n * Removes `key` and its value from the list cache.\n *\n * @private\n * @name delete\n * @memberOf ListCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction listCacheDelete(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n return false;\n }\n var lastIndex = data.length - 1;\n if (index == lastIndex) {\n data.pop();\n } else {\n splice.call(data, index, 1);\n }\n --this.size;\n return true;\n}\n\nexport default listCacheDelete;\n", "import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Gets the list cache value for `key`.\n *\n * @private\n * @name get\n * @memberOf ListCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction listCacheGet(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n return index < 0 ? undefined : data[index][1];\n}\n\nexport default listCacheGet;\n", "import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Checks if a list cache value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf ListCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction listCacheHas(key) {\n return assocIndexOf(this.__data__, key) > -1;\n}\n\nexport default listCacheHas;\n", "import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Sets the list cache `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf ListCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the list cache instance.\n */\nfunction listCacheSet(key, value) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n ++this.size;\n data.push([key, value]);\n } else {\n data[index][1] = value;\n }\n return this;\n}\n\nexport default listCacheSet;\n", "import listCacheClear from './_listCacheClear.js';\nimport listCacheDelete from './_listCacheDelete.js';\nimport listCacheGet from './_listCacheGet.js';\nimport listCacheHas from './_listCacheHas.js';\nimport listCacheSet from './_listCacheSet.js';\n\n/**\n * Creates an list cache object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction ListCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `ListCache`.\nListCache.prototype.clear = listCacheClear;\nListCache.prototype['delete'] = listCacheDelete;\nListCache.prototype.get = listCacheGet;\nListCache.prototype.has = listCacheHas;\nListCache.prototype.set = listCacheSet;\n\nexport default ListCache;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar Map = getNative(root, 'Map');\n\nexport default Map;\n", "import Hash from './_Hash.js';\nimport ListCache from './_ListCache.js';\nimport Map from './_Map.js';\n\n/**\n * Removes all key-value entries from the map.\n *\n * @private\n * @name clear\n * @memberOf MapCache\n */\nfunction mapCacheClear() {\n this.size = 0;\n this.__data__ = {\n 'hash': new Hash,\n 'map': new (Map || ListCache),\n 'string': new Hash\n };\n}\n\nexport default mapCacheClear;\n", "/**\n * Checks if `value` is suitable for use as unique object key.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is suitable, else `false`.\n */\nfunction isKeyable(value) {\n var type = typeof value;\n return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')\n ? (value !== '__proto__')\n : (value === null);\n}\n\nexport default isKeyable;\n", "import isKeyable from './_isKeyable.js';\n\n/**\n * Gets the data for `map`.\n *\n * @private\n * @param {Object} map The map to query.\n * @param {string} key The reference key.\n * @returns {*} Returns the map data.\n */\nfunction getMapData(map, key) {\n var data = map.__data__;\n return isKeyable(key)\n ? data[typeof key == 'string' ? 'string' : 'hash']\n : data.map;\n}\n\nexport default getMapData;\n", "import getMapData from './_getMapData.js';\n\n/**\n * Removes `key` and its value from the map.\n *\n * @private\n * @name delete\n * @memberOf MapCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction mapCacheDelete(key) {\n var result = getMapData(this, key)['delete'](key);\n this.size -= result ? 1 : 0;\n return result;\n}\n\nexport default mapCacheDelete;\n", "import getMapData from './_getMapData.js';\n\n/**\n * Gets the map value for `key`.\n *\n * @private\n * @name get\n * @memberOf MapCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction mapCacheGet(key) {\n return getMapData(this, key).get(key);\n}\n\nexport default mapCacheGet;\n", "import getMapData from './_getMapData.js';\n\n/**\n * Checks if a map value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf MapCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction mapCacheHas(key) {\n return getMapData(this, key).has(key);\n}\n\nexport default mapCacheHas;\n", "import getMapData from './_getMapData.js';\n\n/**\n * Sets the map `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf MapCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the map cache instance.\n */\nfunction mapCacheSet(key, value) {\n var data = getMapData(this, key),\n size = data.size;\n\n data.set(key, value);\n this.size += data.size == size ? 0 : 1;\n return this;\n}\n\nexport default mapCacheSet;\n", "import mapCacheClear from './_mapCacheClear.js';\nimport mapCacheDelete from './_mapCacheDelete.js';\nimport mapCacheGet from './_mapCacheGet.js';\nimport mapCacheHas from './_mapCacheHas.js';\nimport mapCacheSet from './_mapCacheSet.js';\n\n/**\n * Creates a map cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction MapCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `MapCache`.\nMapCache.prototype.clear = mapCacheClear;\nMapCache.prototype['delete'] = mapCacheDelete;\nMapCache.prototype.get = mapCacheGet;\nMapCache.prototype.has = mapCacheHas;\nMapCache.prototype.set = mapCacheSet;\n\nexport default MapCache;\n", "/**\n * Appends the elements of `values` to `array`.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {Array} values The values to append.\n * @returns {Array} Returns `array`.\n */\nfunction arrayPush(array, values) {\n var index = -1,\n length = values.length,\n offset = array.length;\n\n while (++index < length) {\n array[offset + index] = values[index];\n }\n return array;\n}\n\nexport default arrayPush;\n", "import ListCache from './_ListCache.js';\n\n/**\n * Removes all key-value entries from the stack.\n *\n * @private\n * @name clear\n * @memberOf Stack\n */\nfunction stackClear() {\n this.__data__ = new ListCache;\n this.size = 0;\n}\n\nexport default stackClear;\n", "/**\n * Removes `key` and its value from the stack.\n *\n * @private\n * @name delete\n * @memberOf Stack\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction stackDelete(key) {\n var data = this.__data__,\n result = data['delete'](key);\n\n this.size = data.size;\n return result;\n}\n\nexport default stackDelete;\n", "/**\n * Gets the stack value for `key`.\n *\n * @private\n * @name get\n * @memberOf Stack\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction stackGet(key) {\n return this.__data__.get(key);\n}\n\nexport default stackGet;\n", "/**\n * Checks if a stack value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Stack\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction stackHas(key) {\n return this.__data__.has(key);\n}\n\nexport default stackHas;\n", "import ListCache from './_ListCache.js';\nimport Map from './_Map.js';\nimport MapCache from './_MapCache.js';\n\n/** Used as the size to enable large array optimizations. */\nvar LARGE_ARRAY_SIZE = 200;\n\n/**\n * Sets the stack `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Stack\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the stack cache instance.\n */\nfunction stackSet(key, value) {\n var data = this.__data__;\n if (data instanceof ListCache) {\n var pairs = data.__data__;\n if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {\n pairs.push([key, value]);\n this.size = ++data.size;\n return this;\n }\n data = this.__data__ = new MapCache(pairs);\n }\n data.set(key, value);\n this.size = data.size;\n return this;\n}\n\nexport default stackSet;\n", "import ListCache from './_ListCache.js';\nimport stackClear from './_stackClear.js';\nimport stackDelete from './_stackDelete.js';\nimport stackGet from './_stackGet.js';\nimport stackHas from './_stackHas.js';\nimport stackSet from './_stackSet.js';\n\n/**\n * Creates a stack cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Stack(entries) {\n var data = this.__data__ = new ListCache(entries);\n this.size = data.size;\n}\n\n// Add methods to `Stack`.\nStack.prototype.clear = stackClear;\nStack.prototype['delete'] = stackDelete;\nStack.prototype.get = stackGet;\nStack.prototype.has = stackHas;\nStack.prototype.set = stackSet;\n\nexport default Stack;\n", "/**\n * A specialized version of `_.filter` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {Array} Returns the new filtered array.\n */\nfunction arrayFilter(array, predicate) {\n var index = -1,\n length = array == null ? 0 : array.length,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (predicate(value, index, array)) {\n result[resIndex++] = value;\n }\n }\n return result;\n}\n\nexport default arrayFilter;\n", "/**\n * This method returns a new empty array.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {Array} Returns the new empty array.\n * @example\n *\n * var arrays = _.times(2, _.stubArray);\n *\n * console.log(arrays);\n * // => [[], []]\n *\n * console.log(arrays[0] === arrays[1]);\n * // => false\n */\nfunction stubArray() {\n return [];\n}\n\nexport default stubArray;\n", "import arrayFilter from './_arrayFilter.js';\nimport stubArray from './stubArray.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Built-in value references. */\nvar propertyIsEnumerable = objectProto.propertyIsEnumerable;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeGetSymbols = Object.getOwnPropertySymbols;\n\n/**\n * Creates an array of the own enumerable symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of symbols.\n */\nvar getSymbols = !nativeGetSymbols ? stubArray : function(object) {\n if (object == null) {\n return [];\n }\n object = Object(object);\n return arrayFilter(nativeGetSymbols(object), function(symbol) {\n return propertyIsEnumerable.call(object, symbol);\n });\n};\n\nexport default getSymbols;\n", "import arrayPush from './_arrayPush.js';\nimport isArray from './isArray.js';\n\n/**\n * The base implementation of `getAllKeys` and `getAllKeysIn` which uses\n * `keysFunc` and `symbolsFunc` to get the enumerable property names and\n * symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Function} keysFunc The function to get the keys of `object`.\n * @param {Function} symbolsFunc The function to get the symbols of `object`.\n * @returns {Array} Returns the array of property names and symbols.\n */\nfunction baseGetAllKeys(object, keysFunc, symbolsFunc) {\n var result = keysFunc(object);\n return isArray(object) ? result : arrayPush(result, symbolsFunc(object));\n}\n\nexport default baseGetAllKeys;\n", "import baseGetAllKeys from './_baseGetAllKeys.js';\nimport getSymbols from './_getSymbols.js';\nimport keys from './keys.js';\n\n/**\n * Creates an array of own enumerable property names and symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names and symbols.\n */\nfunction getAllKeys(object) {\n return baseGetAllKeys(object, keys, getSymbols);\n}\n\nexport default getAllKeys;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar DataView = getNative(root, 'DataView');\n\nexport default DataView;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar Promise = getNative(root, 'Promise');\n\nexport default Promise;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar Set = getNative(root, 'Set');\n\nexport default Set;\n", "import DataView from './_DataView.js';\nimport Map from './_Map.js';\nimport Promise from './_Promise.js';\nimport Set from './_Set.js';\nimport WeakMap from './_WeakMap.js';\nimport baseGetTag from './_baseGetTag.js';\nimport toSource from './_toSource.js';\n\n/** `Object#toString` result references. */\nvar mapTag = '[object Map]',\n objectTag = '[object Object]',\n promiseTag = '[object Promise]',\n setTag = '[object Set]',\n weakMapTag = '[object WeakMap]';\n\nvar dataViewTag = '[object DataView]';\n\n/** Used to detect maps, sets, and weakmaps. */\nvar dataViewCtorString = toSource(DataView),\n mapCtorString = toSource(Map),\n promiseCtorString = toSource(Promise),\n setCtorString = toSource(Set),\n weakMapCtorString = toSource(WeakMap);\n\n/**\n * Gets the `toStringTag` of `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nvar getTag = baseGetTag;\n\n// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.\nif ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||\n (Map && getTag(new Map) != mapTag) ||\n (Promise && getTag(Promise.resolve()) != promiseTag) ||\n (Set && getTag(new Set) != setTag) ||\n (WeakMap && getTag(new WeakMap) != weakMapTag)) {\n getTag = function(value) {\n var result = baseGetTag(value),\n Ctor = result == objectTag ? value.constructor : undefined,\n ctorString = Ctor ? toSource(Ctor) : '';\n\n if (ctorString) {\n switch (ctorString) {\n case dataViewCtorString: return dataViewTag;\n case mapCtorString: return mapTag;\n case promiseCtorString: return promiseTag;\n case setCtorString: return setTag;\n case weakMapCtorString: return weakMapTag;\n }\n }\n return result;\n };\n}\n\nexport default getTag;\n", "import root from './_root.js';\n\n/** Built-in value references. */\nvar Uint8Array = root.Uint8Array;\n\nexport default Uint8Array;\n", "/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/**\n * Adds `value` to the array cache.\n *\n * @private\n * @name add\n * @memberOf SetCache\n * @alias push\n * @param {*} value The value to cache.\n * @returns {Object} Returns the cache instance.\n */\nfunction setCacheAdd(value) {\n this.__data__.set(value, HASH_UNDEFINED);\n return this;\n}\n\nexport default setCacheAdd;\n", "/**\n * Checks if `value` is in the array cache.\n *\n * @private\n * @name has\n * @memberOf SetCache\n * @param {*} value The value to search for.\n * @returns {number} Returns `true` if `value` is found, else `false`.\n */\nfunction setCacheHas(value) {\n return this.__data__.has(value);\n}\n\nexport default setCacheHas;\n", "import MapCache from './_MapCache.js';\nimport setCacheAdd from './_setCacheAdd.js';\nimport setCacheHas from './_setCacheHas.js';\n\n/**\n *\n * Creates an array cache object to store unique values.\n *\n * @private\n * @constructor\n * @param {Array} [values] The values to cache.\n */\nfunction SetCache(values) {\n var index = -1,\n length = values == null ? 0 : values.length;\n\n this.__data__ = new MapCache;\n while (++index < length) {\n this.add(values[index]);\n }\n}\n\n// Add methods to `SetCache`.\nSetCache.prototype.add = SetCache.prototype.push = setCacheAdd;\nSetCache.prototype.has = setCacheHas;\n\nexport default SetCache;\n", "/**\n * A specialized version of `_.some` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if any element passes the predicate check,\n * else `false`.\n */\nfunction arraySome(array, predicate) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n while (++index < length) {\n if (predicate(array[index], index, array)) {\n return true;\n }\n }\n return false;\n}\n\nexport default arraySome;\n", "/**\n * Checks if a `cache` value for `key` exists.\n *\n * @private\n * @param {Object} cache The cache to query.\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction cacheHas(cache, key) {\n return cache.has(key);\n}\n\nexport default cacheHas;\n", "import SetCache from './_SetCache.js';\nimport arraySome from './_arraySome.js';\nimport cacheHas from './_cacheHas.js';\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1,\n COMPARE_UNORDERED_FLAG = 2;\n\n/**\n * A specialized version of `baseIsEqualDeep` for arrays with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Array} array The array to compare.\n * @param {Array} other The other array to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `array` and `other` objects.\n * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.\n */\nfunction equalArrays(array, other, bitmask, customizer, equalFunc, stack) {\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG,\n arrLength = array.length,\n othLength = other.length;\n\n if (arrLength != othLength && !(isPartial && othLength > arrLength)) {\n return false;\n }\n // Check that cyclic values are equal.\n var arrStacked = stack.get(array);\n var othStacked = stack.get(other);\n if (arrStacked && othStacked) {\n return arrStacked == other && othStacked == array;\n }\n var index = -1,\n result = true,\n seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;\n\n stack.set(array, other);\n stack.set(other, array);\n\n // Ignore non-index properties.\n while (++index < arrLength) {\n var arrValue = array[index],\n othValue = other[index];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, arrValue, index, other, array, stack)\n : customizer(arrValue, othValue, index, array, other, stack);\n }\n if (compared !== undefined) {\n if (compared) {\n continue;\n }\n result = false;\n break;\n }\n // Recursively compare arrays (susceptible to call stack limits).\n if (seen) {\n if (!arraySome(other, function(othValue, othIndex) {\n if (!cacheHas(seen, othIndex) &&\n (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {\n return seen.push(othIndex);\n }\n })) {\n result = false;\n break;\n }\n } else if (!(\n arrValue === othValue ||\n equalFunc(arrValue, othValue, bitmask, customizer, stack)\n )) {\n result = false;\n break;\n }\n }\n stack['delete'](array);\n stack['delete'](other);\n return result;\n}\n\nexport default equalArrays;\n", "/**\n * Converts `map` to its key-value pairs.\n *\n * @private\n * @param {Object} map The map to convert.\n * @returns {Array} Returns the key-value pairs.\n */\nfunction mapToArray(map) {\n var index = -1,\n result = Array(map.size);\n\n map.forEach(function(value, key) {\n result[++index] = [key, value];\n });\n return result;\n}\n\nexport default mapToArray;\n", "/**\n * Converts `set` to an array of its values.\n *\n * @private\n * @param {Object} set The set to convert.\n * @returns {Array} Returns the values.\n */\nfunction setToArray(set) {\n var index = -1,\n result = Array(set.size);\n\n set.forEach(function(value) {\n result[++index] = value;\n });\n return result;\n}\n\nexport default setToArray;\n", "import Symbol from './_Symbol.js';\nimport Uint8Array from './_Uint8Array.js';\nimport eq from './eq.js';\nimport equalArrays from './_equalArrays.js';\nimport mapToArray from './_mapToArray.js';\nimport setToArray from './_setToArray.js';\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1,\n COMPARE_UNORDERED_FLAG = 2;\n\n/** `Object#toString` result references. */\nvar boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n errorTag = '[object Error]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n symbolTag = '[object Symbol]';\n\nvar arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]';\n\n/** Used to convert symbols to primitives and strings. */\nvar symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;\n\n/**\n * A specialized version of `baseIsEqualDeep` for comparing objects of\n * the same `toStringTag`.\n *\n * **Note:** This function only supports comparing values with tags of\n * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {string} tag The `toStringTag` of the objects to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {\n switch (tag) {\n case dataViewTag:\n if ((object.byteLength != other.byteLength) ||\n (object.byteOffset != other.byteOffset)) {\n return false;\n }\n object = object.buffer;\n other = other.buffer;\n\n case arrayBufferTag:\n if ((object.byteLength != other.byteLength) ||\n !equalFunc(new Uint8Array(object), new Uint8Array(other))) {\n return false;\n }\n return true;\n\n case boolTag:\n case dateTag:\n case numberTag:\n // Coerce booleans to `1` or `0` and dates to milliseconds.\n // Invalid dates are coerced to `NaN`.\n return eq(+object, +other);\n\n case errorTag:\n return object.name == other.name && object.message == other.message;\n\n case regexpTag:\n case stringTag:\n // Coerce regexes to strings and treat strings, primitives and objects,\n // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring\n // for more details.\n return object == (other + '');\n\n case mapTag:\n var convert = mapToArray;\n\n case setTag:\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG;\n convert || (convert = setToArray);\n\n if (object.size != other.size && !isPartial) {\n return false;\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(object);\n if (stacked) {\n return stacked == other;\n }\n bitmask |= COMPARE_UNORDERED_FLAG;\n\n // Recursively compare objects (susceptible to call stack limits).\n stack.set(object, other);\n var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);\n stack['delete'](object);\n return result;\n\n case symbolTag:\n if (symbolValueOf) {\n return symbolValueOf.call(object) == symbolValueOf.call(other);\n }\n }\n return false;\n}\n\nexport default equalByTag;\n", "import getAllKeys from './_getAllKeys.js';\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1;\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * A specialized version of `baseIsEqualDeep` for objects with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction equalObjects(object, other, bitmask, customizer, equalFunc, stack) {\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG,\n objProps = getAllKeys(object),\n objLength = objProps.length,\n othProps = getAllKeys(other),\n othLength = othProps.length;\n\n if (objLength != othLength && !isPartial) {\n return false;\n }\n var index = objLength;\n while (index--) {\n var key = objProps[index];\n if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {\n return false;\n }\n }\n // Check that cyclic values are equal.\n var objStacked = stack.get(object);\n var othStacked = stack.get(other);\n if (objStacked && othStacked) {\n return objStacked == other && othStacked == object;\n }\n var result = true;\n stack.set(object, other);\n stack.set(other, object);\n\n var skipCtor = isPartial;\n while (++index < objLength) {\n key = objProps[index];\n var objValue = object[key],\n othValue = other[key];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, objValue, key, other, object, stack)\n : customizer(objValue, othValue, key, object, other, stack);\n }\n // Recursively compare objects (susceptible to call stack limits).\n if (!(compared === undefined\n ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))\n : compared\n )) {\n result = false;\n break;\n }\n skipCtor || (skipCtor = key == 'constructor');\n }\n if (result && !skipCtor) {\n var objCtor = object.constructor,\n othCtor = other.constructor;\n\n // Non `Object` object instances with different constructors are not equal.\n if (objCtor != othCtor &&\n ('constructor' in object && 'constructor' in other) &&\n !(typeof objCtor == 'function' && objCtor instanceof objCtor &&\n typeof othCtor == 'function' && othCtor instanceof othCtor)) {\n result = false;\n }\n }\n stack['delete'](object);\n stack['delete'](other);\n return result;\n}\n\nexport default equalObjects;\n", "import Stack from './_Stack.js';\nimport equalArrays from './_equalArrays.js';\nimport equalByTag from './_equalByTag.js';\nimport equalObjects from './_equalObjects.js';\nimport getTag from './_getTag.js';\nimport isArray from './isArray.js';\nimport isBuffer from './isBuffer.js';\nimport isTypedArray from './isTypedArray.js';\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1;\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n objectTag = '[object Object]';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * A specialized version of `baseIsEqual` for arrays and objects which performs\n * deep comparisons and tracks traversed objects enabling objects with circular\n * references to be compared.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} [stack] Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {\n var objIsArr = isArray(object),\n othIsArr = isArray(other),\n objTag = objIsArr ? arrayTag : getTag(object),\n othTag = othIsArr ? arrayTag : getTag(other);\n\n objTag = objTag == argsTag ? objectTag : objTag;\n othTag = othTag == argsTag ? objectTag : othTag;\n\n var objIsObj = objTag == objectTag,\n othIsObj = othTag == objectTag,\n isSameTag = objTag == othTag;\n\n if (isSameTag && isBuffer(object)) {\n if (!isBuffer(other)) {\n return false;\n }\n objIsArr = true;\n objIsObj = false;\n }\n if (isSameTag && !objIsObj) {\n stack || (stack = new Stack);\n return (objIsArr || isTypedArray(object))\n ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)\n : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);\n }\n if (!(bitmask & COMPARE_PARTIAL_FLAG)) {\n var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),\n othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');\n\n if (objIsWrapped || othIsWrapped) {\n var objUnwrapped = objIsWrapped ? object.value() : object,\n othUnwrapped = othIsWrapped ? other.value() : other;\n\n stack || (stack = new Stack);\n return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);\n }\n }\n if (!isSameTag) {\n return false;\n }\n stack || (stack = new Stack);\n return equalObjects(object, other, bitmask, customizer, equalFunc, stack);\n}\n\nexport default baseIsEqualDeep;\n", "import baseIsEqualDeep from './_baseIsEqualDeep.js';\nimport isObjectLike from './isObjectLike.js';\n\n/**\n * The base implementation of `_.isEqual` which supports partial comparisons\n * and tracks traversed objects.\n *\n * @private\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @param {boolean} bitmask The bitmask flags.\n * 1 - Unordered comparison\n * 2 - Partial comparison\n * @param {Function} [customizer] The function to customize comparisons.\n * @param {Object} [stack] Tracks traversed `value` and `other` objects.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n */\nfunction baseIsEqual(value, other, bitmask, customizer, stack) {\n if (value === other) {\n return true;\n }\n if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {\n return value !== value && other !== other;\n }\n return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);\n}\n\nexport default baseIsEqual;\n", "import baseIsEqual from './_baseIsEqual.js';\n\n/**\n * Performs a deep comparison between two values to determine if they are\n * equivalent.\n *\n * **Note:** This method supports comparing arrays, array buffers, booleans,\n * date objects, error objects, maps, numbers, `Object` objects, regexes,\n * sets, strings, symbols, and typed arrays. `Object` objects are compared\n * by their own, not inherited, enumerable properties. Functions and DOM\n * nodes are compared by strict equality, i.e. `===`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.isEqual(object, other);\n * // => true\n *\n * object === other;\n * // => false\n */\nfunction isEqual(value, other) {\n return baseIsEqual(value, other);\n}\n\nexport default isEqual;\n", "import { isEqual } from 'lodash-es';\n\nimport Metadata from './Metadata';\nimport {\n PluginStatusError,\n PluginStatusMetadata,\n PluginStatusProcessed,\n PluginStatusProcessing\n} from './types';\n\nclass ImageProcessingMetadata extends Metadata<PluginStatusMetadata> {\n get(blockId: number): PluginStatusMetadata {\n return super.get(blockId) ?? { status: 'IDLE' };\n }\n\n /**\n * Detect if the block has been duplicated with processed or processing\n * fill processing. In that case the processing state is still\n * valid, but blockId and fillId have changed.\n */\n isDuplicate(blockId: number): boolean {\n if (!this.engine.block.isValid(blockId)) return false;\n\n const metadata = this.get(blockId);\n\n if (\n metadata.status === 'IDLE' ||\n metadata.status === 'PENDING' ||\n metadata.status === 'ERROR'\n )\n return false;\n\n if (!this.engine.block.hasFill(blockId)) return false;\n const fillId = this.engine.block.getFill(blockId);\n\n // It cannot be a duplicate if the blockId or fillId are the same\n if (metadata.blockId === blockId || metadata.fillId === fillId)\n return false;\n\n return true;\n }\n\n /**\n * Fixes the metadata if the block has been duplicated, i.e. the blockId and\n * fillId will be updated to the current block/fill.\n *\n * Please note: Call this method only on duplicates (see isDuplicate).\n */\n fixDuplicate(blockId: number) {\n const fillId = this.engine.block.getFill(blockId);\n const metadata = this.get(blockId);\n if (\n metadata.status === 'IDLE' ||\n metadata.status === 'PENDING' ||\n metadata.status === 'ERROR'\n )\n return;\n this.set(blockId, {\n ...metadata,\n blockId,\n fillId\n });\n\n // If it is currently processing the best we can do is to just recover\n // the initial image data, since no processing will update this block and\n // it will be stuck in the processing state.\n if (metadata.status === 'PROCESSING') {\n this.recoverInitialImageData(blockId);\n this.clear(blockId);\n }\n }\n\n /**\n * Check if the image has a consisten metadata state. A inconsistent state is\n * caused by outside changes of the fill data.\n *\n * @returns true if the metadata is consistent, false otherwise\n */\n isConsistent(blockId: number): boolean {\n // In case the block was removed, we just abort and mark it\n // as reset by returning true\n if (!this.engine.block.isValid(blockId)) return false;\n const metadata = this.get(blockId);\n if (metadata.status === 'IDLE' || metadata.status === 'PENDING')\n return true;\n\n if (!this.engine.block.hasFill(blockId)) return false;\n const fillId = this.engine.block.getFill(blockId);\n if (fillId == null) return false;\n\n if (blockId !== metadata.blockId || fillId !== metadata.fillId)\n return false;\n\n const sourceSet = this.engine.block.getSourceSet(\n fillId,\n 'fill/image/sourceSet'\n );\n const imageFileURI = this.engine.block.getString(\n fillId,\n 'fill/image/imageFileURI'\n );\n\n if (\n sourceSet.length === 0 &&\n !imageFileURI &&\n metadata.status === 'PROCESSING'\n ) {\n // While we process it is OK to have no image file URI and no source set\n // (which we cleared to show the spinning loader)\n return true;\n }\n\n // Source sets have precedence over imageFileURI so if we have a source set,\n // we only need to check if it has changed to something else.\n if (sourceSet?.length > 0) {\n const initialSourceSet = metadata.initialSourceSet;\n // If we have already processed the image, we need to check if the source set\n // we need to check against both source sets, the removed and the initial\n if (metadata.status !== 'PROCESSED') {\n if (!isEqual(sourceSet, initialSourceSet)) {\n return false;\n }\n }\n } else {\n if (metadata.status !== 'PROCESSED') {\n if (imageFileURI !== metadata.initialImageFileURI) {\n return false;\n }\n }\n }\n return true;\n }\n\n /**\n * Recover the initial values to avoid the loading spinner and have the same\n * state as before the fill processing was started.\n */\n recoverInitialImageData(blockId: number) {\n const blockApi = this.engine.block;\n if (!blockApi.hasFill(blockId)) return; // Nothing to recover (no fill anymore)\n\n const metadata = this.get(blockId);\n\n if (metadata.status === 'PENDING' || metadata.status === 'IDLE') {\n return;\n }\n\n const initialSourceSet = metadata.initialSourceSet;\n const initialImageFileURI = metadata.initialImageFileURI;\n const initialPreviewFileURI = metadata.initialPreviewFileURI;\n\n const fillId = this.getValidFill(blockId, metadata);\n if (fillId == null) return;\n\n if (initialImageFileURI) {\n this.engine.block.setString(\n fillId,\n 'fill/image/imageFileURI',\n initialImageFileURI\n );\n }\n if (initialPreviewFileURI) {\n this.engine.block.setString(\n fillId,\n 'fill/image/previewFileURI',\n initialPreviewFileURI\n );\n }\n if (initialSourceSet.length > 0) {\n this.engine.block.setSourceSet(\n fillId,\n 'fill/image/sourceSet',\n initialSourceSet\n );\n }\n }\n\n /**\n * Returns the fill id of the block if it has a valid fill that was used for\n * fill processing. Returns undefined otherwise.\n */\n private getValidFill(\n blockId: number,\n metadata: PluginStatusProcessing | PluginStatusError | PluginStatusProcessed\n ): number | undefined {\n if (\n !this.engine.block.isValid(blockId) ||\n !this.engine.block.hasFill(blockId) ||\n blockId !== metadata.blockId\n ) {\n return undefined;\n }\n const fillId = this.engine.block.getFill(blockId);\n if (fillId !== metadata.fillId) {\n return undefined;\n }\n\n return fillId;\n }\n}\n\nexport default ImageProcessingMetadata;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { FillProcessingMetadata } from '..';\nimport {\n PluginStatusProcessed,\n PluginStatusProcessing\n} from '../metadata/types';\n\ninterface FillProcessor<T> {\n processFill(metadataState: PluginStatusProcessing): Promise<T>;\n\n commitProcessing(\n data: T,\n metadataState: PluginStatusProcessed\n ): number | void;\n}\n\nasync function fillProcessing<T>(\n blockId: number,\n cesdk: CreativeEditorSDK,\n metadata: FillProcessingMetadata,\n processor: FillProcessor<T>\n) {\n const blockApi = cesdk.engine.block;\n if (!blockApi.hasFill(blockId))\n throw new Error('Block does not support fill');\n\n const fillId = blockApi.getFill(blockId);\n\n // Get the current image URI and source set as initial values.\n const initialSourceSet = blockApi.getSourceSet(\n fillId,\n 'fill/image/sourceSet'\n );\n const initialImageFileURI = blockApi.getString(\n fillId,\n 'fill/image/imageFileURI'\n );\n const initialPreviewFileURI = blockApi.getString(\n fillId,\n 'fill/image/previewFileURI'\n );\n try {\n cesdk.engine.block.setState(fillId, {\n type: 'Pending',\n progress: 0\n });\n\n const status: PluginStatusProcessing = {\n ...metadata.get(blockId),\n version: PLUGIN_VERSION,\n initialSourceSet,\n initialImageFileURI,\n initialPreviewFileURI,\n blockId,\n fillId,\n status: 'PROCESSING'\n };\n\n metadata.set(blockId, status);\n\n const processedData = await processor.processFill(status);\n // Check for externally changed state while we were applying the mask and\n // do not proceed if the state was reset.\n if (\n metadata.get(blockId).status !== 'PROCESSING' ||\n !metadata.isConsistent(blockId)\n )\n return;\n\n // Check for externally changed state while we were uploading and\n // do not proceed if the state was reset.\n if (\n metadata.get(blockId).status !== 'PROCESSING' ||\n !metadata.isConsistent(blockId)\n )\n return;\n\n if (processedData == null) return;\n\n const metadataStateProcessed: PluginStatusProcessed = {\n version: PLUGIN_VERSION,\n initialSourceSet,\n initialImageFileURI,\n initialPreviewFileURI,\n blockId,\n fillId,\n status: 'PROCESSED'\n };\n\n const blockIdOrVoid = processor.commitProcessing(\n processedData,\n metadataStateProcessed\n );\n\n // If a new block was created, we do not update the metadata.\n if (blockIdOrVoid == null || blockIdOrVoid === blockId) {\n metadata.set(blockId, metadataStateProcessed);\n }\n\n // Finally, create an undo step\n cesdk.engine.editor.addUndoStep();\n } catch (error) {\n if (cesdk.engine.block.isValid(blockId)) {\n metadata.set(blockId, {\n version: PLUGIN_VERSION,\n initialSourceSet,\n initialImageFileURI,\n initialPreviewFileURI,\n blockId,\n fillId,\n status: 'ERROR'\n });\n\n metadata.recoverInitialImageData(blockId);\n }\n\n if (\n error != null &&\n typeof error === 'object' &&\n 'message' in error &&\n typeof error.message === 'string'\n ) {\n const message =\n error.message === 'signal timed out'\n ? 'Processing canceled due to timeout'\n : error.message;\n cesdk.ui.showNotification({\n type: 'error',\n message\n });\n }\n\n // eslint-disable-next-line no-console\n console.log(error);\n } finally {\n if (cesdk.engine.block.isValid(fillId)) {\n cesdk.engine.block.setState(fillId, { type: 'Ready' });\n }\n }\n}\n\nexport default fillProcessing;\n", "export function getFeatureId(pluginId: string): string {\n return `${pluginId}.fillProcessing.feature`;\n}\n\nexport function getCanvasMenuComponentIds(pluginId: string): string[] {\n return [`${pluginId}.canvasMenu`, `${pluginId}.fillProcessing.canvasMenu`];\n}\n\nexport function getDockComponentIds(pluginId: string): string[] {\n return [`${pluginId}.dock`, `${pluginId}.fillProcessing.dock`];\n}\n\nexport function getInspectorBarComponentIds(pluginId: string): string[] {\n return [\n `${pluginId}.inspectorBar`,\n `${pluginId}.fillProcessing.inspectorBar`\n ];\n}\n\nexport function getNavigationBarComponentIds(pluginId: string): string[] {\n return [\n `${pluginId}.navigationBar`,\n `${pluginId}.fillProcessing.navigationBar`\n ];\n}\n\nexport function getCanvasBarComponentIds(pluginId: string): string[] {\n return [`${pluginId}.canvasBar`, `${pluginId}.fillProcessing.canvasBar`];\n}\n\nexport function getI18nCanvasMenuLabel(pluginId: string): string {\n return `plugin.${pluginId}.fillProcessing.canvasMenu.button.label`;\n}\n\nexport function getI18nDockLabel(pluginId: string): string {\n return `plugin.${pluginId}.fillProcessing.dock.button.label`;\n}\n\nexport function getI18nInspectorBarLabel(pluginId: string): string {\n return `plugin.${pluginId}.fillProcessing.inspectorBar.button.label`;\n}\n\nexport function getI18nNavigationBarLabel(pluginId: string): string {\n return `plugin.${pluginId}.fillProcessing.navigationBar.button.label`;\n}\n\nexport function getI18nCanvasBarLabel(pluginId: string): string {\n return `plugin.${pluginId}.fillProcessing.canvasBar.button.label`;\n}\n", "import type CreativeEditorSDK from '@cesdk/cesdk-js';\n\nimport { FillProcessingMetadata } from '..';\nimport { getFeatureId } from './constants';\n\nexport default function handleFillProcessing(\n cesdk: CreativeEditorSDK,\n {\n pluginId,\n process\n }: {\n pluginId: string;\n icon?: string;\n process: (blockId: number, metadata: FillProcessingMetadata) => void;\n }\n): {\n featureId: string;\n} {\n const featureId = getFeatureId(pluginId);\n\n const metadata = new FillProcessingMetadata(cesdk.engine, pluginId);\n\n enableFeatures(cesdk, metadata, featureId);\n\n cesdk.engine.event.subscribe([], async (events) => {\n events.forEach((e) => {\n const id = e.block;\n if (!cesdk.engine.block.isValid(id) || !metadata.hasData(id)) {\n return;\n }\n\n if (e.type === 'Created') {\n if (metadata.isDuplicate(id)) {\n metadata.fixDuplicate(id);\n }\n } else if (e.type === 'Updated') {\n switch (metadata.get(id).status) {\n case 'PENDING': {\n if (\n cesdk.feature.isEnabled(featureId, {\n engine: cesdk.engine\n }) &&\n cesdk.engine.block.isAllowedByScope(id, 'fill/change') &&\n cesdk.engine.block.getState(id).type !== 'Pending'\n ) {\n process(id, metadata);\n }\n break;\n }\n\n case 'PROCESSING':\n case 'PROCESSED': {\n if (!metadata.isConsistent(id)) {\n metadata.clear(id);\n }\n break;\n }\n\n default: {\n // We do not care about other states\n }\n }\n }\n });\n });\n\n return { featureId };\n}\n\n/**\n * Defines the feature that determines in which context (on which block)\n * fill processing is allowed/enabled.\n */\nfunction enableFeatures(\n cesdk: CreativeEditorSDK,\n metadata: FillProcessingMetadata,\n featureId: string\n) {\n cesdk.feature.enable(featureId, ({ engine }) => {\n const selectedIds = engine.block.findAllSelected();\n if (selectedIds.length !== 1) {\n return false;\n }\n const [selectedId] = selectedIds;\n\n if (!cesdk.engine.block.isVisible(selectedId)) return false;\n\n if (cesdk.engine.block.hasFill(selectedId)) {\n const kind = cesdk.engine.block.getKind(selectedId);\n if (kind === 'sticker') return false;\n\n const fillId = cesdk.engine.block.getFill(selectedId);\n const fillType = cesdk.engine.block.getType(fillId);\n\n if (fillType !== '//ly.img.ubq/fill/image') {\n return false;\n }\n\n const fileUri = engine.block.getString(fillId, 'fill/image/imageFileURI');\n const sourceSet = engine.block.getSourceSet(\n fillId,\n 'fill/image/sourceSet'\n );\n\n if (sourceSet.length > 0 || fileUri !== '') return true;\n\n // If we are in a processing state we do not have a imageFileURI or\n // source set set (to show the loading spinner), but the feature is still\n // enabled.\n return metadata.get(selectedId).status === 'PROCESSING';\n }\n\n return false;\n });\n}\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { FillProcessingMetadata } from '..';\nimport {\n getCanvasBarComponentIds,\n getCanvasMenuComponentIds,\n getDockComponentIds,\n getFeatureId,\n getI18nCanvasBarLabel,\n getI18nCanvasMenuLabel,\n getI18nDockLabel,\n getI18nInspectorBarLabel,\n getI18nNavigationBarLabel,\n getInspectorBarComponentIds,\n getNavigationBarComponentIds\n} from './constants';\n\nexport type Location =\n | 'inspectorBar'\n | 'navigationBar'\n | 'canvasBarTop'\n | 'canvasBarBottom'\n | 'canvasMenu'\n | 'dock';\n\n/**\n * Registers the components that can be used to process the fill of\n * a block.\n */\nexport default function registerFillProcessingComponents(\n cesdk: CreativeEditorSDK,\n options: {\n pluginId: string;\n icon?: string;\n locations?: Location | Location[];\n }\n): {\n canvasMenuComponentId: string;\n dockComponentId: string;\n\n translationsKeys: {\n inspectorBarLabel: string;\n navigationBarLabel: string;\n canvasBarLabel: string;\n canvasMenuLabel: string;\n dockLabel: string;\n };\n} {\n const { pluginId, locations } = options;\n const metadata = new FillProcessingMetadata(cesdk.engine, pluginId);\n\n const canvasMenuLabel = getI18nCanvasMenuLabel(pluginId);\n const canvasMenuComponentIds = getCanvasMenuComponentIds(pluginId);\n const canvasMenuComponentId = canvasMenuComponentIds[0];\n\n const dockLabel = getI18nDockLabel(pluginId);\n const dockComponentIds = getDockComponentIds(pluginId);\n const dockComponentId = dockComponentIds[0];\n\n const inspectorBarLabel = getI18nInspectorBarLabel(pluginId);\n const inspectorBarComponentIds = getInspectorBarComponentIds(pluginId);\n const inspectorBarComponentId = inspectorBarComponentIds[0];\n\n const navigationBarLabel = getI18nNavigationBarLabel(pluginId);\n const navigationBarComponentIds = getNavigationBarComponentIds(pluginId);\n const navigationBarComponentId = navigationBarComponentIds[0];\n\n const canvasBarLabel = getI18nCanvasBarLabel(pluginId);\n const canvasBarComponentIds = getCanvasBarComponentIds(pluginId);\n const canvasBarComponentId = canvasBarComponentIds[0];\n\n const featureId = getFeatureId(pluginId);\n\n if (locations?.includes('inspectorBar')) {\n cesdk.ui.setInspectorBarOrder([\n inspectorBarComponentId,\n ...cesdk.ui.getInspectorBarOrder()\n ]);\n }\n\n if (locations?.includes('navigationBar')) {\n cesdk.ui.setNavigationBarOrder([\n navigationBarComponentId,\n ...cesdk.ui.getNavigationBarOrder()\n ]);\n }\n\n if (locations?.includes('canvasBarTop')) {\n cesdk.ui.setCanvasBarOrder(\n [canvasBarComponentId, ...cesdk.ui.getCanvasBarOrder('top')],\n 'top'\n );\n }\n\n if (locations?.includes('canvasBarBottom')) {\n cesdk.ui.setCanvasBarOrder(\n [canvasBarComponentId, ...cesdk.ui.getCanvasBarOrder('bottom')],\n 'bottom'\n );\n }\n\n if (locations?.includes('canvasMenu')) {\n cesdk.ui.setCanvasMenuOrder([\n canvasMenuComponentId,\n ...cesdk.ui.getCanvasMenuOrder()\n ]);\n }\n\n if (locations?.includes('dock')) {\n cesdk.ui.setDockOrder([...cesdk.ui.getDockOrder(), dockComponentId]);\n }\n\n cesdk.ui.registerComponent(\n dockComponentIds,\n ({ builder: { Button }, engine }) => {\n const [id] = engine.block.findAllSelected();\n\n let isDisabled = false;\n let isLoading = false;\n let loadingProgress: number | undefined;\n\n if (id == null) {\n isDisabled = true;\n }\n\n if (\n !isDisabled &&\n !cesdk.feature.isEnabled(featureId, {\n engine\n })\n ) {\n isDisabled = true;\n }\n\n if (\n !isDisabled &&\n !cesdk.engine.block.isAllowedByScope(id, 'fill/change')\n ) {\n isDisabled = true;\n }\n\n if (!isDisabled && engine.block.getState(id)?.type === 'Pending') {\n isDisabled = true;\n }\n\n if (!isDisabled) {\n const currentMetadata = metadata.get(id);\n\n isLoading = currentMetadata.status === 'PROCESSING';\n isDisabled =\n currentMetadata.status === 'PENDING' ||\n currentMetadata.status === 'PROCESSING';\n\n if (\n currentMetadata.status === 'PROCESSING' &&\n currentMetadata.progress\n ) {\n const { current, total } = currentMetadata.progress;\n loadingProgress = (current / total) * 100;\n }\n }\n\n const buttonId = `${dockComponentId}.button`;\n Button(buttonId, {\n label: dockLabel,\n icon: options.icon,\n isLoading,\n isDisabled,\n loadingProgress,\n onClick: () => {\n const currentMetadata = metadata.get(id);\n\n if (\n currentMetadata.status === 'IDLE' ||\n currentMetadata.status === 'ERROR' ||\n currentMetadata.status === 'PROCESSED'\n ) {\n metadata.set(id, {\n status: 'PENDING'\n });\n }\n }\n });\n }\n );\n\n const buttonComponents: {\n componentIds: string[];\n label: string;\n variant: 'plain' | 'regular';\n }[] = [\n {\n componentIds: inspectorBarComponentIds,\n variant: 'plain',\n label: inspectorBarLabel\n },\n {\n componentIds: navigationBarComponentIds,\n variant: 'regular',\n label: navigationBarLabel\n },\n {\n componentIds: canvasBarComponentIds,\n variant: 'regular',\n label: canvasBarLabel\n },\n {\n componentIds: canvasMenuComponentIds,\n variant: 'plain',\n label: canvasMenuLabel\n }\n ];\n\n buttonComponents.forEach(({ componentIds, label, variant }) => {\n const componentId = componentIds[0];\n cesdk.ui.registerComponent(\n componentIds,\n ({ builder: { Button }, engine }) => {\n if (\n !cesdk.feature.isEnabled(featureId, {\n engine\n })\n ) {\n return;\n }\n\n const [id] = engine.block.findAllSelected();\n\n if (!cesdk.engine.block.isAllowedByScope(id, 'fill/change')) return;\n\n const currentMetadata = metadata.get(id);\n\n const isLoading = currentMetadata.status === 'PROCESSING';\n const isDisabled =\n currentMetadata.status === 'PENDING' ||\n currentMetadata.status === 'PROCESSING' ||\n engine.block.getState(id)?.type === 'Pending';\n\n let loadingProgress: number | undefined;\n if (isLoading && currentMetadata.progress) {\n const { current, total } = currentMetadata.progress;\n loadingProgress = (current / total) * 100;\n }\n\n const buttonId = `${componentId}.button`;\n Button(buttonId, {\n icon: options.icon,\n label,\n variant,\n isLoading,\n isDisabled,\n loadingProgress,\n onClick: () => {\n if (\n currentMetadata.status === 'IDLE' ||\n currentMetadata.status === 'ERROR' ||\n currentMetadata.status === 'PROCESSED'\n ) {\n metadata.set(id, {\n status: 'PENDING'\n });\n }\n }\n });\n }\n );\n });\n\n return {\n canvasMenuComponentId,\n dockComponentId,\n translationsKeys: {\n inspectorBarLabel,\n navigationBarLabel,\n canvasBarLabel,\n canvasMenuLabel,\n dockLabel\n }\n };\n}\n", "import { type RGBAColor } from '@cesdk/cesdk-js';\n\nconst HEX_COLOR_PATTERN = new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/, 'i');\nconst HEX_SINGLE_CHAR_COMPONENTS_PATTERN = new RegExp(/[A-Fa-f0-9]{1}/, 'g');\nconst HEX_DOUBLE_CHAR_COMPONENTS_PATTERN = new RegExp(/[A-Fa-f0-9]{2}/, 'g');\n\n/** @public */\nexport const rgbaToHex = (rgba: RGBAColor, includeAlpha = false): string => {\n const { r, g, b, a } = rgba;\n const rByte = Math.round(255 * r);\n const gByte = Math.round(255 * g);\n const bByte = Math.round(255 * b);\n const aByte = Math.round(255 * a);\n const byteToHex = (byte: number) => {\n return byte.toString(16).padStart(2, '0');\n };\n return `#${byteToHex(rByte)}${byteToHex(gByte)}${byteToHex(bByte)}${\n includeAlpha ? byteToHex(aByte) : ''\n }`;\n};\n\n/** @public */\nexport const hexToRgba = (hexString: string): RGBAColor => {\n const rgbaHexToColor = (\n r: string,\n g: string,\n b: string,\n a: string | undefined,\n max: number\n ) => {\n return {\n r: parseInt(r, 16) / max,\n g: parseInt(g, 16) / max,\n b: parseInt(b, 16) / max,\n a: a === undefined ? 1 : parseInt(a, 16) / max\n };\n };\n\n if (hexString.startsWith('#')) {\n if (hexString.length === 4 || hexString.length === 5) {\n const hexMatch = hexString.match(HEX_SINGLE_CHAR_COMPONENTS_PATTERN);\n if (hexMatch) {\n const [r, g, b, a] = hexMatch;\n return rgbaHexToColor(r, g, b, a, 15);\n }\n }\n if (hexString.length === 7 || hexString.length === 8) {\n const hexMatch = hexString.match(HEX_DOUBLE_CHAR_COMPONENTS_PATTERN);\n if (hexMatch) {\n const [r, g, b, a] = hexMatch;\n return rgbaHexToColor(r, g, b, a, 255);\n }\n }\n }\n\n throw new Error(\n 'Invalid hex string! Allowed RGB formats are \"#FFF\" and \"#FFFFFF\". Allowed RGBA formats are \"#FFFF\" and \"#FFFFFFFF'\n );\n};\n\n/** @public */\nexport const isValidHexColor = (hexString: string): boolean => {\n return HEX_COLOR_PATTERN.test(hexString);\n};\n", "import type CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { CreativeEngine } from '@cesdk/cesdk-js';\n\n/**\n * Uploads a blob with the help of CE.SDK\n */\nexport async function uploadBlob(\n blob: Blob,\n initialUri: string,\n cesdk: CreativeEditorSDK\n) {\n const pathname = new URL(initialUri).pathname;\n const parts = pathname.split('/');\n const extension = mimeTypeToExtension(blob.type);\n const filename = parts[parts.length - 1]?.split('.')?.[0] ?? 'asset';\n const filenameWithExtension = `${filename}.${extension}`;\n\n const uploadedAssets = await cesdk.unstable_upload(\n new File([blob], filenameWithExtension, { type: blob.type }),\n () => {\n // TODO Delegate process to UI component\n }\n );\n\n const url = uploadedAssets.meta?.uri;\n if (url == null) {\n throw new Error('Could not upload processed fill');\n }\n return url;\n}\n\n/**\n * Returns the file extension for a given mime type.\n */\nexport function mimeTypeToExtension(mimeType: string): string {\n const extensions: Record<string, string> = {\n 'image/png': 'png',\n 'image/jpeg': 'jpg',\n 'image/webp': 'webp',\n 'image/gif': 'gif',\n 'image/svg+xml': 'svg'\n };\n return extensions[mimeType] ?? 'png';\n}\n\nexport async function fetchImageBlob(uri: string): Promise<Blob> {\n return fetch(uri).then((response) => response.blob());\n}\n\n/**\n * Converts a buffer URI to a object url.\n */\nexport async function bufferURIToObjectURL(\n uri: string,\n engine: CreativeEngine\n): Promise<string> {\n if (uri.startsWith('buffer:')) {\n const mimeType = await engine.editor.getMimeType(uri);\n const length = engine.editor.getBufferLength(uri);\n const data = engine.editor.getBufferData(uri, 0, length);\n const blob = new Blob([data], { type: mimeType });\n return URL.createObjectURL(blob);\n } else {\n return uri;\n }\n}\n", "function uuid4() {\n /* eslint-disable no-bitwise */\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n /* eslint-enable no-bitwise */\n });\n}\n\nexport default uuid4;\n", "import { bufferURIToObjectURL } from './upload';\nimport { type CreativeEngine } from '@cesdk/cesdk-js';\n\n/**\n * Get the dimensions of an image from its URL\n *\n * @param url - The URL of the image\n * @returns A promise that resolves to an object containing the width and height of the image\n */\nexport async function getImageDimensionsFromURL(\n url: string,\n engine: CreativeEngine\n): Promise<{ width: number; height: number }> {\n const resolvedUrl = await bufferURIToObjectURL(url, engine);\n return new Promise((resolve, reject) => {\n const img = new Image();\n img.onload = () => {\n resolve({ width: img.width, height: img.height });\n };\n img.onerror = reject;\n img.src = resolvedUrl;\n });\n}\n\n/**\n * Get the URI of an image from a block ID, either the first source of a source set or\n * the image file URI. Will handle buffer URIs and convert them to object URLs.\n */\nexport async function getImageUri(\n blockId: number,\n engine: CreativeEngine,\n options?: { throwErrorIfSvg?: boolean }\n): Promise<string> {\n let uri;\n const fillBlock = engine.block.getFill(blockId);\n const sourceSet = engine.block.getSourceSet(\n fillBlock,\n 'fill/image/sourceSet'\n );\n const [source] = sourceSet;\n if (source == null) {\n uri = engine.block.getString(fillBlock, 'fill/image/imageFileURI');\n if (uri == null) throw new Error('No image source/uri found');\n } else {\n uri = source.uri;\n }\n\n // Check if the image is SVG (not supported)\n if (options?.throwErrorIfSvg) {\n const mimeType = await engine.editor.getMimeType(uri);\n if (mimeType === 'image/svg+xml') {\n throw new Error('SVG images are not supported');\n }\n }\n\n return bufferURIToObjectURL(uri, engine);\n}\n", "/**\n * Checks if a value is defined (not undefined).\n *\n * Helpful to filter out undefined values from an array or collection\n * while keeping the type information intact.\n *\n * ```\n * array.filter(isDefined)\n * ```\n */\nfunction isDefined<T>(value: T | undefined): value is T {\n return value !== undefined;\n}\n\nexport default isDefined;\n", "import formatsIconSprite from './icons/formats';\n\nconst Icons = {\n Formats: formatsIconSprite\n};\n\nexport { Icons };\n\nexport { CustomAssetSource } from './assetSources/CustomAssetSource';\n\nexport { IndexedDBAssetSource } from './assetSources/IndexedDBAssetSource';\n\nexport { AggregatedAssetSource } from './assetSources/AggregatedAssetSource';\n\nexport { default as Metadata } from './metadata/Metadata';\n\nexport { default as FillProcessingMetadata } from './metadata/FillProcessingMetadata';\n\nexport { default as fillProcessing } from './processing/fillProcessing';\n\nexport { default as initializeFillProcessing } from './processing/initializeFillProcessing';\n\nexport { default as registerFillProcessingComponents } from './processing/registerFillProcessingComponents';\n\nexport { type Optional } from './types/Optional';\n\nexport {\n type Location,\n type UserInterfaceConfiguration\n} from './types/UserInterfaceConfiguration';\n\nexport { hexToRgba, isValidHexColor, rgbaToHex } from './utils/colors';\n\nexport {\n uploadBlob,\n fetchImageBlob,\n bufferURIToObjectURL,\n mimeTypeToExtension\n} from './utils/upload';\n\nexport { default as uuid } from './utils/uuid';\n\nexport { getImageDimensionsFromURL, getImageUri } from './utils/images';\n\nexport { default as isDefined } from './utils/isDefined';\n", "import CreativeEditorSDK, { AssetResult } from '@cesdk/cesdk-js';\nimport { RenderCustomProperty } from '../generation/provider';\n\n/**\n * Provides render function for a image url property that allows\n * to select an image from the library with a MediaPreview\n *\n * By default this expects the property key to be `image_url`. This can be changed in the options.\n */\nfunction renderImageUrlProperty(\n provderId: string,\n options: {\n cesdk: CreativeEditorSDK;\n propertyKey?: string;\n defaultUrl?: string;\n }\n): RenderCustomProperty {\n const { cesdk } = options;\n const propertyKey = options.propertyKey ?? 'image_url';\n const panelIdForImageSelection = getImageSelectionPanelId(provderId);\n\n cesdk.i18n.setTranslations({\n en: {\n [`panel.${panelIdForImageSelection}`]: 'Select Image To Change'\n }\n });\n\n createPanels(provderId, cesdk);\n\n const customProperties: RenderCustomProperty = {\n [propertyKey]: (context, property) => {\n const {\n builder,\n experimental: { global },\n payload\n } = context;\n const defaultUrl = payload?.url ?? options.defaultUrl;\n const stateValue = global<string>(\n `${provderId}.${property.id}`,\n defaultUrl\n );\n\n builder.MediaPreview(property.id, {\n preview: {\n type: 'image',\n uri: stateValue.value\n },\n action: {\n label: 'Select Image',\n onClick: () => {\n if (cesdk == null) return;\n\n cesdk.ui.openPanel(panelIdForImageSelection, {\n payload: {\n onSelect: (assetResult: AssetResult) => {\n if (assetResult.meta?.uri != null) {\n stateValue.setValue(assetResult.meta?.uri);\n }\n }\n }\n });\n }\n }\n });\n\n return () => {\n return {\n id: property.id,\n type: 'string',\n value: stateValue.value\n };\n };\n }\n };\n\n return customProperties;\n}\n\nfunction createPanels(providerId: string, cesdk?: CreativeEditorSDK) {\n if (cesdk == null) return;\n\n cesdk.ui.registerPanel<{\n onSelect: (assetResult: AssetResult) => void;\n }>(getImageSelectionPanelId(providerId), ({ builder, payload }) => {\n builder.Library(`${providerId}.library.image`, {\n entries: ['ly.img.image'],\n onSelect: async (asset) => {\n const uri = asset?.meta?.uri;\n if (uri == null) return;\n\n const mimeType = await cesdk.engine.editor.getMimeType(uri);\n if (mimeType === 'image/svg+xml') {\n cesdk.ui.showNotification({\n type: 'warning',\n message:\n 'SVG images are not supported. Please choose a different image.'\n });\n } else if (mimeType.startsWith('image/')) {\n payload?.onSelect(asset);\n cesdk?.ui.closePanel(getImageSelectionPanelId(providerId));\n } else {\n cesdk.ui.showNotification({\n type: 'warning',\n message: `Only images are supported. Found '${mimeType}'. Please choose a different image.`\n });\n }\n }\n });\n });\n}\n\nfunction getImageSelectionPanelId(providerId: string) {\n return `ly.img.ai/${providerId}.imageSelection`;\n}\n\nexport default renderImageUrlProperty;\n", "export default `\n<svg>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratioFree\"\n >\n <path d=\"M7 6C6.44772 6 6 6.44772 6 7V9.22222H4V7C4 5.34315 5.34315 4 7 4H9.22222V6H7Z\" fill=\"currentColor\"/>\n <path d=\"M17 6H14.7778V4H17C18.6569 4 20 5.34315 20 7V9.22222H18V7C18 6.44772 17.5523 6 17 6Z\" fill=\"currentColor\"/>\n <path d=\"M6 14.7778V17C6 17.5523 6.44772 18 7 18H9.22222V20H7C5.34315 20 4 18.6569 4 17V14.7778H6Z\" fill=\"currentColor\"/>\n <path d=\"M18 17V14.7778H20V17C20 18.6569 18.6569 20 17 20H14.7778V18H17C17.5523 18 18 17.5523 18 17Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratio4by3\"\n >\n <path d=\"M6.5 13H8V15H10V16.5H6.5V13Z\" fill=\"currentColor\"/>\n <path d=\"M14 9V7.5H17.5V11H16V9H14Z\" fill=\"currentColor\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M6 4C4.34315 4 3 5.34315 3 7V17C3 18.6569 4.34315 20 6 20H18C19.6569 20 21 18.6569 21 17V7C21 5.34315 19.6569 4 18 4H6ZM5 7C5 6.44772 5.44772 6 6 6H18C18.5523 6 19 6.44772 19 7V17C19 17.5523 18.5523 18 18 18H6C5.44772 18 5 17.5523 5 17V7Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratio16by9\"\n >\n <path d=\"M4.5 13H6V15H8V16.5H4.5V13Z\" fill=\"currentColor\"/>\n <path d=\"M16 9V7.5H19.5V11H18V9H16Z\" fill=\"currentColor\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M4 4C2.34315 4 1 5.34315 1 7V17C1 18.6569 2.34315 20 4 20H20C21.6569 20 23 18.6569 23 17V7C23 5.34315 21.6569 4 20 4H4ZM3 7C3 6.44772 3.44772 6 4 6H20C20.5523 6 21 6.44772 21 7V17C21 17.5523 20.5523 18 20 18H4C3.44772 18 3 17.5523 3 17V7Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratio9by16\"\n >\n <path d=\"M7.5 16H9V18H11V19.5H7.5V16Z\" fill=\"currentColor\"/>\n <path d=\"M13 6V4.5H16.5V8H15V6H13Z\" fill=\"currentColor\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M4 20C4 21.6569 5.34315 23 7 23H17C18.6569 23 20 21.6569 20 20V4C20 2.34315 18.6569 1 17 1H7C5.34315 1 4 2.34315 4 4V20ZM7 21C6.44772 21 6 20.5523 6 20V4C6 3.44772 6.44772 3 7 3H17C17.5523 3 18 3.44772 18 4V20C18 20.5523 17.5523 21 17 21H7Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratio3by4\"\n >\n <path d=\"M11 17.5V16H9V14H7.5V17.5H11Z\" fill=\"currentColor\"/>\n <path d=\"M15 10H16.5V6.5H13V8H15V10Z\" fill=\"currentColor\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M20 18C20 19.6569 18.6569 21 17 21H7C5.34315 21 4 19.6569 4 18V6C4 4.34315 5.34315 3 7 3H17C18.6569 3 20 4.34315 20 6V18ZM17 19C17.5523 19 18 18.5523 18 18V6C18 5.44772 17.5523 5 17 5H7C6.44771 5 6 5.44771 6 6V18C6 18.5523 6.44772 19 7 19H17Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/plugin/formats/ratio1by1\"\n >\n <path d=\"M17.4142 8.00009L16 6.58587L14.2929 8.29298L15.7071 9.70719L17.4142 8.00009Z\" fill=\"currentColor\"/>\n <path d=\"M13.0404 12.3739L15.0404 10.3739L13.6262 8.95965L11.6262 10.9596L13.0404 12.3739Z\" fill=\"currentColor\"/>\n <path d=\"M10.3737 15.0405L12.3737 13.0405L10.9595 11.6263L8.95953 13.6263L10.3737 15.0405Z\" fill=\"currentColor\"/>\n <path d=\"M9.70708 15.7072L8.29286 14.293L6.58576 16.0001L7.99997 17.4143L9.70708 15.7072Z\" fill=\"currentColor\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M7 4C5.34315 4 4 5.34315 4 7V17C4 18.6569 5.34315 20 7 20H17C18.6569 20 20 18.6569 20 17V7C20 5.34315 18.6569 4 17 4H7ZM6 7C6 6.44772 6.44772 6 7 6H17C17.5523 6 18 6.44772 18 7V17C18 17.5523 17.5523 18 17 18H7C6.44772 18 6 17.5523 6 17V7Z\" fill=\"currentColor\"/>\n </symbol>\n</svg>\n`;\n", "import type {\n AssetDefinition,\n AssetQueryData,\n AssetResult,\n AssetSource,\n AssetsQueryResult\n} from '@cesdk/engine';\n\n/**\n * Simplified value type for select inputs that can be converted to asset definitions\n */\nexport type SelectValue = {\n id: string;\n label: string;\n thumbUri?: string;\n meta?: { [key: string]: any };\n};\n\n/**\n * A custom AssetSource implementation that manages assets from an array\n * and provides additional functionality like to mark assets as active or changing\n * labels.\n */\nexport class CustomAssetSource implements AssetSource {\n /** The unique id of the asset source */\n id: string;\n\n /** Array of assets to be served by this source */\n private assets: AssetDefinition[];\n\n /** Set of IDs for active assets */\n private activeAssetIds: Set<string>;\n\n /**\n * Creates a new instance of CustomAssetSource\n *\n * @param id - The unique identifier for this asset source\n * @param assets - Array of asset definitions or SelectValue objects to include in this source\n */\n constructor(id: string, assets: (AssetDefinition | SelectValue)[] = []) {\n this.id = id;\n this.assets = assets.map((asset) => {\n // Check if the asset is a SelectValue by looking for the label property as a string\n if (\n typeof (asset as SelectValue).label === 'string' &&\n !(\n (asset as AssetDefinition).label &&\n typeof (asset as AssetDefinition).label === 'object'\n )\n ) {\n const selectValue = asset as SelectValue;\n // Convert SelectValue to AssetDefinition\n return {\n id: selectValue.id,\n label: { en: selectValue.label },\n meta: selectValue.thumbUri\n ? { ...(selectValue.meta ?? {}), thumbUri: selectValue.thumbUri }\n : selectValue.meta\n } as AssetDefinition;\n }\n return asset as AssetDefinition;\n });\n this.activeAssetIds = new Set<string>();\n }\n\n /**\n * Find assets based on the provided query data\n * Supports pagination, searching, filtering, and active-first sorting\n *\n * @param queryData - Query parameters to filter and sort assets\n * @returns Promise with the query results\n */\n async findAssets(\n queryData: AssetQueryData\n ): Promise<AssetsQueryResult | undefined> {\n const {\n page,\n perPage,\n locale = 'en',\n sortActiveFirst,\n query,\n tags,\n groups,\n excludeGroups,\n sortingOrder,\n sortKey\n } = queryData;\n\n // Start with all assets\n let filteredAssets = [...this.assets];\n\n // Filter by groups if provided\n if (groups && groups.length > 0) {\n filteredAssets = filteredAssets.filter(\n (asset) =>\n asset.groups && groups.some((group) => asset.groups?.includes(group))\n );\n }\n\n // Filter out excluded groups if provided\n if (excludeGroups && excludeGroups.length > 0) {\n filteredAssets = filteredAssets.filter(\n (asset) =>\n !asset.groups ||\n !excludeGroups.some((group) => asset.groups?.includes(group))\n );\n }\n\n // Filter by query (search in label and tags)\n if (query) {\n const lowerQuery = query.toLowerCase();\n filteredAssets = filteredAssets.filter((asset) => {\n const label = asset.label?.[locale]?.toLowerCase();\n const assetTags = asset.tags?.[locale] || [];\n\n return (\n (label && label.includes(lowerQuery)) ||\n assetTags.some((tag) => tag.toLowerCase().includes(lowerQuery))\n );\n });\n }\n\n // Filter by exact tags if provided\n if (tags && tags.length > 0) {\n const tagArray = Array.isArray(tags) ? tags : [tags];\n filteredAssets = filteredAssets.filter((asset) => {\n const assetTags = asset.tags?.[locale] || [];\n return tagArray.some((tag) => assetTags.includes(tag));\n });\n }\n\n // Sort by active first if requested\n if (sortActiveFirst) {\n filteredAssets.sort((a, b) => {\n const aActive = this.activeAssetIds.has(a.id);\n const bActive = this.activeAssetIds.has(b.id);\n\n if (aActive && !bActive) return -1;\n if (!aActive && bActive) return 1;\n return 0;\n });\n }\n\n // Sort by sortKey if provided\n if (sortKey && sortKey !== 'id') {\n filteredAssets.sort((a, b) => {\n // Sort by metadata field\n const aValue = a.meta?.[sortKey];\n const bValue = b.meta?.[sortKey];\n\n if (aValue === undefined) return 1;\n if (bValue === undefined) return -1;\n\n if (typeof aValue === 'string' && typeof bValue === 'string') {\n return sortingOrder === 'Descending'\n ? bValue.localeCompare(aValue)\n : aValue.localeCompare(bValue);\n }\n\n if (typeof aValue === 'number' && typeof bValue === 'number') {\n return sortingOrder === 'Descending'\n ? bValue - aValue\n : aValue - bValue;\n }\n\n return 0;\n });\n } else if (sortKey === 'id') {\n // Sort by id\n filteredAssets.sort((a, b) => {\n return sortingOrder === 'Descending'\n ? b.id.localeCompare(a.id)\n : a.id.localeCompare(b.id);\n });\n }\n\n // Calculate pagination\n const total = filteredAssets.length;\n const startIndex = page * perPage;\n const endIndex = startIndex + perPage;\n const paginatedAssets = filteredAssets.slice(startIndex, endIndex);\n\n // Transform AssetDefinition objects to AssetResult objects\n const resultAssets: AssetResult[] = paginatedAssets.map((asset) => {\n return {\n id: asset.id,\n groups: asset.groups,\n meta: asset.meta,\n payload: asset.payload,\n locale,\n label: asset.label?.[locale],\n tags: asset.tags?.[locale],\n active: this.activeAssetIds.has(asset.id)\n };\n });\n\n // Calculate next page if there are more assets\n const nextPage = endIndex < total ? page + 1 : undefined;\n\n return {\n assets: resultAssets,\n currentPage: page,\n nextPage,\n total\n };\n }\n\n updateLabel(assetId: string, label: string, locale: string): void {\n this.assets.forEach((asset) => {\n if (asset.id === assetId) {\n asset.label = asset.label || {};\n asset.label[locale] = label;\n }\n });\n }\n\n /**\n * Get the asset select value by its ID\n *\n * @param assetId - The ID of the asset to retrieve\n * @returns The SelectValue object for the asset or undefined if not found\n */\n getAssetSelectValue(assetId: string): SelectValue | undefined {\n const asset = this.assets.find(({ id }) => id === assetId);\n if (asset) {\n return {\n id: asset.id,\n label: asset.label?.en || '',\n thumbUri: asset.meta?.thumbUri\n };\n }\n return undefined;\n }\n\n /**\n * Get an asset by its ID\n */\n getAsset(id: string): AssetDefinition | undefined {\n return this.assets.find((asset) => asset.id === id);\n }\n\n /**\n * Set an asset as active by its ID\n *\n * @param assetId - The ID of the asset to mark as active\n */\n setAssetActive(assetId: string): void {\n this.activeAssetIds.add(assetId);\n }\n\n /**\n * Get all active asset IDs\n *\n * @returns Array of active asset IDs\n */\n getActiveAssetIds(): string[] {\n return Array.from(this.activeAssetIds);\n }\n\n /**\n * Set multiple assets as active by their IDs\n *\n * @param assetIds - Array of asset IDs to mark as active\n */\n setAssetsActive(assetIds: string[]): void {\n assetIds.forEach((id) => this.activeAssetIds.add(id));\n }\n\n /**\n * Set an asset as inactive by its ID\n *\n * @param assetId - The ID of the asset to mark as inactive\n */\n setAssetInactive(assetId: string): void {\n this.activeAssetIds.delete(assetId);\n }\n\n /**\n * Clear all active assets\n */\n clearActiveAssets(): void {\n this.activeAssetIds.clear();\n }\n\n /**\n * Check if an asset is marked as active\n *\n * @param assetId - The ID of the asset to check\n * @returns True if the asset is active, false otherwise\n */\n isAssetActive(assetId: string): boolean {\n return this.activeAssetIds.has(assetId);\n }\n\n /**\n * Add an asset to this source\n *\n * @param asset - The asset definition to add\n */\n addAsset(asset: AssetDefinition): void {\n // Check if asset with this ID already exists\n const existingIndex = this.assets.findIndex((a) => a.id === asset.id);\n if (existingIndex >= 0) {\n // Replace existing asset\n this.assets[existingIndex] = asset;\n } else {\n // Add new asset\n this.assets.push(asset);\n }\n }\n\n /**\n * Remove an asset from this source\n *\n * @param assetId - The ID of the asset to remove\n */\n removeAsset(assetId: string): void {\n const index = this.assets.findIndex((asset) => asset.id === assetId);\n if (index !== -1) {\n this.assets.splice(index, 1);\n this.activeAssetIds.delete(assetId);\n }\n }\n\n /**\n * Get all available groups from the assets\n *\n * @returns Array of unique group names\n */\n async getGroups(): Promise<string[]> {\n const groups = new Set<string>();\n this.assets.forEach((asset) => {\n if (asset.groups) {\n asset.groups.forEach((group) => groups.add(group));\n }\n });\n return Array.from(groups);\n }\n\n /**\n * Returns the supported MIME types for this asset source\n *\n * @returns Array of supported MIME types\n */\n getSupportedMimeTypes(): string[] {\n return [\n 'image/jpeg',\n 'image/png',\n 'image/svg+xml',\n 'image/webp',\n 'video/mp4',\n 'audio/mpeg'\n ];\n }\n}\n\n/**\n * Helper function to create a CustomAssetSource instance\n *\n * @param id - The unique identifier for this asset source\n * @param assets - Array of asset definitions or SelectValue objects to include in this source\n * @returns A new CustomAssetSource instance\n */\nexport function createCustomAssetSource(\n id: string,\n assets: (AssetDefinition | SelectValue)[] = []\n): CustomAssetSource {\n return new CustomAssetSource(id, assets);\n}\n\nexport default CustomAssetSource;\n", "/* eslint-disable no-console */\nimport {\n CreativeEngine,\n type AssetDefinition,\n type AssetQueryData,\n type AssetResult,\n type AssetSource,\n type AssetsQueryResult\n} from '@cesdk/cesdk-js';\n\ntype BlobEntry = {\n id: string;\n blob: Blob;\n};\n\n// Asset definition with meta containing insertedAt timestamp\ntype AssetEntryWithMeta = AssetDefinition;\n\n/**\n * IndexedDBAssetSource implements the AssetSource interface using IndexedDB as the storage backend.\n */\nexport class IndexedDBAssetSource implements AssetSource {\n /** The unique id of the API */\n public readonly id: string;\n\n public readonly engine: CreativeEngine;\n\n private readonly dbName: string;\n\n private readonly dbVersion: number;\n\n private readonly assetStoreName: string = 'assets';\n\n private readonly blobStoreName: string = 'blobs';\n\n private db: IDBDatabase | null = null;\n\n /**\n * Creates a new IndexedDBAssetSource\n *\n * @param id - The unique identifier for this asset source\n * @param {Object} [options] - Optional configuration options.\n * @param {string} [options.dbName] - The name of the database.\n * @param {number} [options.dbVersion] - The version number of the database.\n */\n constructor(\n id: string,\n engine: CreativeEngine,\n options?: {\n dbName?: string;\n dbVersion?: number;\n }\n ) {\n this.id = id;\n this.engine = engine;\n this.dbName = options?.dbName ?? `ly.img.assetSource/${id}`;\n this.dbVersion = options?.dbVersion ?? 1;\n }\n\n /**\n * Initialize the database connection and create object stores if needed\n */\n public async initialize(): Promise<void> {\n if (this.db) {\n return;\n }\n\n return new Promise((resolve, reject) => {\n const request = indexedDB.open(this.dbName, this.dbVersion);\n\n request.onerror = (event) => {\n reject(\n new Error(\n `Failed to open IndexedDB: ${(event.target as IDBRequest).error}`\n )\n );\n };\n\n request.onupgradeneeded = (event) => {\n const db = (event.target as IDBOpenDBRequest).result;\n\n // Create asset store if it doesn't exist\n if (!db.objectStoreNames.contains(this.assetStoreName)) {\n db.createObjectStore(this.assetStoreName, {\n keyPath: 'id'\n });\n }\n // Create blob store if it doesn't exist\n if (!db.objectStoreNames.contains(this.blobStoreName)) {\n db.createObjectStore(this.blobStoreName, {\n keyPath: 'id'\n });\n }\n };\n\n request.onsuccess = (event) => {\n this.db = (event.target as IDBOpenDBRequest).result;\n resolve();\n };\n });\n }\n\n /**\n * Close the database connection\n */\n public close(): void {\n if (this.db) {\n this.db.close();\n this.db = null;\n }\n }\n\n /**\n * Find all assets for the given type and the provided query data.\n *\n * @param queryData - The query parameters for filtering assets\n * @param insertionSortOrder - Optional parameter to sort by insertion time: 'asc' for oldest first, 'desc' for newest first (default)\n * @returns A promise that resolves to the query results or undefined if there was an error\n */\n public async findAssets(\n queryData: AssetQueryData\n ): Promise<AssetsQueryResult | undefined> {\n await this.initialize();\n\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n try {\n // Get all assets from the store with specified insertion order\n const assetDefinitions = await this.getAllAssets('asc');\n\n let assetResults = assetDefinitions.reduce((acc, assetDefinition) => {\n const locale = queryData.locale ?? 'en';\n let label = '';\n let tags: string[] = [];\n\n // Handle localized label if available\n if (\n assetDefinition.label != null &&\n typeof assetDefinition.label === 'object' &&\n assetDefinition.label[locale]\n ) {\n label = assetDefinition.label[locale];\n }\n\n // Handle localized tags if available\n if (\n assetDefinition.tags != null &&\n typeof assetDefinition.tags === 'object' &&\n assetDefinition.tags[locale]\n ) {\n tags = assetDefinition.tags[locale];\n }\n\n const result: AssetResult = {\n ...assetDefinition,\n label,\n tags\n };\n\n if (this.filterAsset(result, queryData)) {\n acc.push(result);\n }\n\n return acc;\n }, [] as AssetResult[]);\n\n assetResults = await this.restoreBlobUrls(assetResults);\n\n // Apply sorting\n assetResults = this.sortAssets(assetResults, queryData);\n\n // Apply pagination\n const { page, perPage } = queryData;\n const startIndex = page * perPage;\n const endIndex = startIndex + perPage;\n const paginatedAssets = assetResults.slice(startIndex, endIndex);\n\n // Determine if there's a next page\n const nextPage = endIndex < assetResults.length ? page + 1 : undefined;\n\n const result = {\n assets: paginatedAssets,\n currentPage: page,\n nextPage,\n total: assetResults.length\n };\n\n return result;\n } catch (error) {\n console.error('Error finding assets:', error);\n return undefined;\n }\n }\n\n public async getGroups(): Promise<string[]> {\n await this.initialize();\n\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n return new Promise((resolve, reject) => {\n const transaction = this.db!.transaction(this.assetStoreName, 'readonly');\n const store = transaction.objectStore(this.assetStoreName);\n const request = store.getAll();\n\n request.onsuccess = () => {\n const allGroups = new Set<string>();\n\n // Extract all groups from all assets\n (request.result as AssetResult[]).forEach((asset) => {\n if (asset.groups && Array.isArray(asset.groups)) {\n asset.groups.forEach((group) => allGroups.add(group));\n }\n });\n\n const uniqueGroups = [...allGroups];\n resolve(uniqueGroups);\n };\n\n request.onerror = () => {\n reject(new Error(`Failed to get groups: ${request.error}`));\n };\n });\n }\n\n /**\n * Adds the given asset to this source. Part of the AssetSource interface.\n *\n * @param asset - The asset definition to add\n */\n public addAsset(asset: AssetDefinition): void {\n this.initialize()\n .then(async () => {\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n const transaction = this.db.transaction(\n this.assetStoreName,\n 'readwrite'\n );\n const assetStore = transaction.objectStore(this.assetStoreName);\n\n const blobsToStore = new Set<string>();\n processBlobUrls(asset, (value) => {\n blobsToStore.add(value);\n });\n\n setTimeout(() => {\n this.storeBlobUrls([...blobsToStore]);\n });\n\n // Ensure asset has meta object with insertedAt timestamp\n const assetWithMeta: AssetEntryWithMeta = {\n ...asset,\n meta: {\n ...asset.meta,\n insertedAt: asset.meta?.insertedAt || Date.now()\n }\n };\n\n // Store the asset in the database\n assetStore.put(assetWithMeta);\n\n transaction.onerror = () => {\n console.error(`Failed to add asset: ${transaction.error}`);\n };\n })\n .catch((error) => {\n console.error('Error initializing database:', error);\n });\n }\n\n /**\n * Removes the given asset from this source. Part of the AssetSource interface.\n *\n * @param assetId - The ID of the asset to remove\n */\n public async removeAsset(assetId: string): Promise<void> {\n const asset = await this.getAsset(assetId);\n\n return this.initialize()\n .then(() => {\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n const transaction = this.db.transaction(\n this.assetStoreName,\n 'readwrite'\n );\n const store = transaction.objectStore(this.assetStoreName);\n store.delete(assetId);\n\n transaction.oncomplete = () => {\n processBlobUrls(asset, (value) => {\n this.removeBlob(value);\n });\n this.engine.asset.assetSourceContentsChanged(this.id);\n };\n\n transaction.onerror = () => {\n console.error(`Failed to remove asset: ${transaction.error}`);\n };\n })\n .catch((error) => {\n console.error('Error initializing database:', error);\n });\n }\n\n /**\n * Removes the given asset from this source. Part of the AssetSource interface.\n *\n * @param assetId - The ID of the asset to remove\n */\n public async removeBlob(blobId: string): Promise<void> {\n return this.initialize()\n .then(() => {\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n const transaction = this.db.transaction(\n this.blobStoreName,\n 'readwrite'\n );\n const store = transaction.objectStore(this.blobStoreName);\n store.delete(blobId);\n\n transaction.onerror = () => {\n console.error(`Failed to remove blob: ${transaction.error}`);\n };\n })\n .catch((error) => {\n console.error('Error initializing database:', error);\n });\n }\n\n /**\n * Get all assets from the database sorted by insertion order (newest to oldest)\n *\n * @param sortOrder - Optional parameter to specify sort order: 'asc' for oldest first, 'desc' for newest first (default)\n * @returns A promise that resolves to an array of all assets\n */\n private async getAllAssets(\n sortOrder: 'asc' | 'desc' = 'desc'\n ): Promise<AssetDefinition[]> {\n return new Promise((resolve, reject) => {\n const transaction = this.db!.transaction(this.assetStoreName, 'readonly');\n const store = transaction.objectStore(this.assetStoreName);\n const request = store.getAll();\n\n request.onsuccess = () => {\n const assets = request.result as AssetEntryWithMeta[];\n\n // Sort by insertion timestamp\n assets.sort((a, b) => {\n // Default to current time if insertedAt is missing (for backward compatibility)\n // First check in meta.insertedAt, then fallback to legacy _insertedAt for backward compatibility\n const timeA =\n a.meta?.insertedAt || (a as any)._insertedAt || Date.now();\n const timeB =\n b.meta?.insertedAt || (b as any)._insertedAt || Date.now();\n\n // Sort based on requested order\n return sortOrder === 'asc'\n ? timeA - timeB // oldest first\n : timeB - timeA; // newest first (default)\n });\n\n resolve(assets);\n };\n\n request.onerror = () => {\n reject(new Error(`Failed to get assets: ${request.error}`));\n };\n });\n }\n\n // Retrieve a blob by ID\n async getAsset(id: string): Promise<AssetResult | undefined> {\n return new Promise((resolve, reject) => {\n const transaction = this.db!.transaction(this.assetStoreName, 'readonly');\n const store = transaction.objectStore(this.assetStoreName);\n const request = store.get(id);\n\n request.onsuccess = () => {\n resolve(request.result as AssetResult);\n };\n\n request.onerror = () => {\n reject(new Error(`Failed to get blob: ${request.error}`));\n };\n });\n }\n\n // Retrieve a blob by ID\n async getBlob(id: string): Promise<BlobEntry | undefined> {\n return new Promise((resolve, reject) => {\n const transaction = this.db!.transaction(this.blobStoreName, 'readonly');\n const store = transaction.objectStore(this.blobStoreName);\n const request = store.get(id);\n\n request.onsuccess = () => {\n resolve(request.result as BlobEntry);\n };\n\n request.onerror = () => {\n reject(new Error(`Failed to get blob: ${request.error}`));\n };\n });\n }\n\n async createBlobUrlFromStore(blobUrl: string): Promise<string> {\n const blobEntry = await this.getBlob(blobUrl);\n if (blobEntry != null) {\n return URL.createObjectURL(blobEntry.blob);\n }\n return blobUrl;\n }\n\n async storeBlobUrls(urls: string[]): Promise<void> {\n const blobsToStore: { [key: string]: Blob } = {};\n await Promise.all(\n urls.map(async (blobUrl) => {\n const blobResponse = await fetch(blobUrl);\n const blob = await blobResponse.blob();\n blobsToStore[blobUrl] = blob;\n })\n );\n\n return this.initialize()\n .then(async () => {\n if (!this.db) {\n throw new Error('Database not initialized');\n }\n\n const transaction = this.db.transaction(\n this.blobStoreName,\n 'readwrite'\n );\n const blobStore = transaction.objectStore(this.blobStoreName);\n\n // Store the asset in the database\n Object.entries(blobsToStore).forEach(([key, blob]) => {\n const asset: BlobEntry = { id: key, blob };\n blobStore.put(asset);\n });\n\n transaction.onerror = () => {\n console.error(`Failed to add blobs: ${transaction.error}`);\n };\n })\n .catch((error) => {\n console.error('Error initializing database:', error);\n });\n }\n\n async restoreBlobUrls(assets: AssetResult[]): Promise<AssetResult[]> {\n const blobReplaced: { [key: string]: string } = {};\n const blobUrls: Set<string> = new Set();\n processBlobUrls(assets, (value) => {\n blobUrls.add(value);\n });\n\n await Promise.all(\n [...blobUrls].map(async (value) => {\n const newUrl = await this.createBlobUrlFromStore(value);\n blobReplaced[value] = newUrl;\n })\n );\n\n return processBlobUrls(assets, (value) => {\n return blobReplaced[value] ?? value;\n });\n }\n\n /**\n * Returns if the given asset should be filtered based on query data\n *\n * @param asset - The asset to filter\n * @param queryData - The query parameters to filter by\n * @returns true if the asset should be included, false otherwise\n */\n private filterAsset(asset: AssetResult, queryData: AssetQueryData): boolean {\n const { query, tags, groups, excludeGroups } = queryData;\n\n // Filter by query string (search on label and tags)\n if (query && query.trim() !== '') {\n const lowerQuery = query.trim().toLowerCase().split(' ');\n\n const lowerLabel = asset.label?.toLowerCase() ?? '';\n const lowerTags = asset.tags?.map((tag) => tag.toLowerCase()) ?? [];\n\n const matchLabelOrTag = lowerQuery.every((word) => {\n return (\n lowerLabel.includes(word) ||\n lowerTags.some((tag) => tag.includes(word))\n );\n });\n\n if (!matchLabelOrTag) {\n return false;\n }\n }\n\n // Filter by exact tags if provided by the query\n if (tags) {\n const tagList = Array.isArray(tags) ? tags : [tags];\n if (\n tagList.length > 0 &&\n (!asset.tags || !tagList.every((tag) => asset.tags?.includes(tag)))\n ) {\n return false;\n }\n }\n\n // Filter by groups\n if (groups && groups.length > 0) {\n if (\n !asset.groups ||\n !groups.some((group) => asset.groups?.includes(group))\n ) {\n return false;\n }\n }\n\n // Filter by excluded groups\n if (excludeGroups && excludeGroups.length > 0) {\n if (\n asset.groups &&\n asset.groups.some((group) => excludeGroups.includes(group))\n ) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Sort assets based on query data\n *\n * @param assets - The assets to sort\n * @param queryData - The query parameters with sorting information\n * @returns The sorted assets\n */\n private sortAssets(\n assets: AssetResult[],\n queryData: AssetQueryData\n ): AssetResult[] {\n const { sortingOrder, sortKey, sortActiveFirst } = queryData;\n\n // Clone the array to avoid modifying the original\n const sortedAssets = [...assets];\n\n // If no sorting order specified or set to 'None', return the current order\n if (!sortingOrder || sortingOrder === 'None') {\n return sortedAssets;\n }\n\n // Sort by the specified key\n if (sortKey) {\n sortedAssets.sort((a, b) => {\n let valueA;\n let valueB;\n\n if (sortKey === 'id') {\n valueA = a.id;\n valueB = b.id;\n } else {\n // Handle metadata sorting (assuming metadata is stored in a 'metadata' field)\n valueA = a.meta?.[sortKey] ?? null;\n valueB = b.meta?.[sortKey] ?? null;\n }\n\n // Handle null/undefined values\n if (valueA === null || valueA === undefined)\n return sortingOrder === 'Ascending' ? -1 : 1;\n if (valueB === null || valueB === undefined)\n return sortingOrder === 'Ascending' ? 1 : -1;\n\n // Compare values based on sorting order\n if (typeof valueA === 'string' && typeof valueB === 'string') {\n return sortingOrder === 'Ascending'\n ? valueA.localeCompare(valueB)\n : valueB.localeCompare(valueA);\n } else {\n return sortingOrder === 'Ascending'\n ? valueA < valueB\n ? -1\n : valueA > valueB\n ? 1\n : 0\n : valueA > valueB\n ? -1\n : valueA < valueB\n ? 1\n : 0;\n }\n });\n } else if (sortingOrder === 'Descending') {\n // If no sort key is specified, and sorting order set\n // to Descending, just reverse original order\n sortedAssets.reverse();\n }\n\n // Sort by active first if requested\n if (sortActiveFirst) {\n sortedAssets.sort((a, b) => {\n if (a.active && !b.active) return -1;\n if (!a.active && b.active) return 1;\n return 0;\n });\n }\n\n return sortedAssets;\n }\n}\n\n/**\n * Goes through an object and calls a callback for every string value that starts with 'blob:'\n * The callback can return a string to replace the original value\n * @param obj The object to traverse\n * @param callback Function to call when a blob URL is found, can return a replacement value\n * @param path Current path in the object (used for recursion)\n * @returns The modified object (or the original if no replacements were made)\n */\nfunction processBlobUrls<T>(\n obj: T,\n callback: (value: string, path: string) => string | void,\n path: string = ''\n): T {\n // Return the object as is if it's null or not an object\n if (obj === null || typeof obj !== 'object') {\n return obj;\n }\n\n // Handle arrays\n if (Array.isArray(obj)) {\n for (let index = 0; index < obj.length; index++) {\n const currentPath = path ? `${path}[${index}]` : `[${index}]`;\n\n if (typeof obj[index] === 'string' && obj[index].startsWith('blob:')) {\n const replacement = callback(obj[index], currentPath);\n if (typeof replacement === 'string') {\n obj[index] = replacement;\n }\n } else {\n obj[index] = processBlobUrls(obj[index], callback, currentPath);\n }\n }\n return obj;\n }\n\n // Handle regular objects\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n const value = obj[key];\n const currentPath = path ? `${path}.${key}` : key;\n\n if (typeof value === 'string' && value.startsWith('blob:')) {\n const replacement = callback(value, currentPath);\n if (typeof replacement === 'string') {\n // @ts-ignore\n obj[key] = replacement;\n }\n } else {\n obj[key] = processBlobUrls(value, callback, currentPath);\n }\n }\n }\n\n return obj;\n}\n\nexport default IndexedDBAssetSource;\n", "/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type {\n AssetDefinition,\n AssetQueryData,\n AssetResult,\n AssetSource,\n AssetsQueryResult\n} from '@cesdk/cesdk-js';\nimport CreativeEditorSDK from '@cesdk/cesdk-js';\n\n/**\n * AggregatedAssetSource implements the AssetSource interface by aggregating\n * multiple asset sources via the cesdk API and combining their results.\n *\n * This asset source is read-only - it does not support adding or removing assets.\n */\nexport class AggregatedAssetSource implements AssetSource {\n /** The unique id of the asset source */\n public readonly id: string;\n\n /** The Creative Editor SDK instance */\n private cesdk: CreativeEditorSDK;\n\n /** The IDs of asset sources to aggregate */\n private assetSourceIds: string[];\n\n /**\n * Creates a new AggregatedAssetSource\n *\n * @param id - The unique identifier for this asset source\n * @param cesdk - The Creative Editor SDK instance\n * @param assetSourceIds - The IDs of asset sources to aggregate\n */\n constructor(id: string, cesdk: CreativeEditorSDK, assetSourceIds: string[]) {\n this.id = id;\n this.cesdk = cesdk;\n this.assetSourceIds = assetSourceIds;\n }\n\n /**\n * Find assets across all aggregated sources based on the provided query data\n * Results are sorted by the insertedAt timestamp in meta field\n *\n * @param queryData - Query parameters to filter and sort assets\n * @returns Promise with the query results\n */\n async findAssets(\n queryData: AssetQueryData\n ): Promise<AssetsQueryResult | undefined> {\n try {\n // Query all asset sources via cesdk\n const queryPromises = this.assetSourceIds.map((sourceId) =>\n this.cesdk.engine.asset.findAssets(sourceId, {\n ...queryData,\n // Increase page size to get all assets from each source\n // We'll handle pagination after merging\n perPage: 9999,\n page: 0\n })\n );\n\n // Wait for all queries to complete\n const results = await Promise.all(queryPromises);\n\n // Combine all assets from all sources\n let allAssets: AssetResult[] = [];\n results.forEach((result) => {\n if (result?.assets) {\n allAssets = allAssets.concat(result.assets);\n }\n });\n\n // Sort by insertedAt timestamp\n allAssets.sort((a, b) => {\n const timeA = (a.meta?.insertedAt as number) || 0;\n const timeB = (b.meta?.insertedAt as number) || 0;\n\n // Sort newest first (descending)\n return timeB - timeA;\n });\n\n // Apply pagination after merging\n const { page, perPage } = queryData;\n const startIndex = page * perPage;\n const endIndex = startIndex + perPage;\n const paginatedAssets = allAssets.slice(startIndex, endIndex);\n\n // Calculate if there is a next page\n const nextPage = endIndex < allAssets.length ? page + 1 : undefined;\n\n return {\n assets: paginatedAssets,\n currentPage: page,\n nextPage,\n total: allAssets.length\n };\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error finding assets:', error);\n return undefined;\n }\n }\n\n /**\n * Retrieves all groups from all aggregated asset sources using cesdk\n * @returns Promise with an array of unique group names\n */\n async getGroups(): Promise<string[]> {\n const groupPromises = this.assetSourceIds.map((sourceId) =>\n this.cesdk.engine.asset.getGroups(sourceId)\n );\n\n const groupArrays = await Promise.all(groupPromises);\n\n // Combine and deduplicate groups\n const uniqueGroups = new Set<string>();\n groupArrays.forEach((groups) => {\n groups.forEach((group) => uniqueGroups.add(group));\n });\n\n return Array.from(uniqueGroups);\n }\n\n /**\n * This operation is not supported in AggregatedAssetSource\n * @throws Error - This method is not supported\n */\n addAsset(_asset: AssetDefinition): void {\n throw new Error('AggregatedAssetSource does not support adding assets');\n }\n\n /**\n * This operation is not supported in AggregatedAssetSource\n * @throws Error - This method is not supported\n */\n removeAsset(_assetId: string): void {\n throw new Error('AggregatedAssetSource does not support removing assets');\n }\n}\n\n/**\n * Helper function to create an AggregatedAssetSource instance\n *\n * @param id - The unique identifier for this asset source\n * @param cesdk - The Creative Editor SDK instance\n * @param assetSourceIds - The IDs of asset sources to aggregate\n * @returns A new AggregatedAssetSource instance\n */\nexport function createAggregatedAssetSource(\n id: string,\n cesdk: CreativeEditorSDK,\n assetSourceIds: string[]\n): AggregatedAssetSource {\n return new AggregatedAssetSource(id, cesdk, assetSourceIds);\n}\n\nexport default AggregatedAssetSource;\n", "import { type CreativeEngine } from '@cesdk/cesdk-js';\n\nclass Metadata<V> {\n engine: CreativeEngine;\n\n key: string;\n\n constructor(engine: CreativeEngine, key: string) {\n this.engine = engine;\n this.key = key;\n }\n\n hasData(blockId: number): boolean {\n return (\n this.engine.block.isValid(blockId) &&\n this.engine.block.hasMetadata(blockId, this.key)\n );\n }\n\n get(blockId: number): V | undefined {\n if (this.hasData(blockId)) {\n return JSON.parse(this.engine.block.getMetadata(blockId, this.key));\n }\n return undefined;\n }\n\n set(blockId: number, value: V) {\n this.engine.block.setMetadata(blockId, this.key, JSON.stringify(value));\n }\n\n clear(blockId: number) {\n if (this.engine.block.hasMetadata(blockId, this.key)) {\n this.engine.block.removeMetadata(blockId, this.key);\n }\n }\n}\n\nexport default Metadata;\n", "/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\nexport default freeGlobal;\n", "import freeGlobal from './_freeGlobal.js';\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\nexport default root;\n", "import root from './_root.js';\n\n/** Built-in value references. */\nvar Symbol = root.Symbol;\n\nexport default Symbol;\n", "import Symbol from './_Symbol.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\nfunction getRawTag(value) {\n var isOwn = hasOwnProperty.call(value, symToStringTag),\n tag = value[symToStringTag];\n\n try {\n value[symToStringTag] = undefined;\n var unmasked = true;\n } catch (e) {}\n\n var result = nativeObjectToString.call(value);\n if (unmasked) {\n if (isOwn) {\n value[symToStringTag] = tag;\n } else {\n delete value[symToStringTag];\n }\n }\n return result;\n}\n\nexport default getRawTag;\n", "/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\nfunction objectToString(value) {\n return nativeObjectToString.call(value);\n}\n\nexport default objectToString;\n", "import Symbol from './_Symbol.js';\nimport getRawTag from './_getRawTag.js';\nimport objectToString from './_objectToString.js';\n\n/** `Object#toString` result references. */\nvar nullTag = '[object Null]',\n undefinedTag = '[object Undefined]';\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n return (symToStringTag && symToStringTag in Object(value))\n ? getRawTag(value)\n : objectToString(value);\n}\n\nexport default baseGetTag;\n", "/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return value != null && typeof value == 'object';\n}\n\nexport default isObjectLike;\n", "/**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\nvar isArray = Array.isArray;\n\nexport default isArray;\n", "/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n}\n\nexport default isObject;\n", "import baseGetTag from './_baseGetTag.js';\nimport isObject from './isObject.js';\n\n/** `Object#toString` result references. */\nvar asyncTag = '[object AsyncFunction]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n proxyTag = '[object Proxy]';\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n if (!isObject(value)) {\n return false;\n }\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 9 which returns 'object' for typed arrays and other constructors.\n var tag = baseGetTag(value);\n return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;\n}\n\nexport default isFunction;\n", "import root from './_root.js';\n\n/** Used to detect overreaching core-js shims. */\nvar coreJsData = root['__core-js_shared__'];\n\nexport default coreJsData;\n", "import coreJsData from './_coreJsData.js';\n\n/** Used to detect methods masquerading as native. */\nvar maskSrcKey = (function() {\n var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');\n return uid ? ('Symbol(src)_1.' + uid) : '';\n}());\n\n/**\n * Checks if `func` has its source masked.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` is masked, else `false`.\n */\nfunction isMasked(func) {\n return !!maskSrcKey && (maskSrcKey in func);\n}\n\nexport default isMasked;\n", "/** Used for built-in method references. */\nvar funcProto = Function.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/**\n * Converts `func` to its source code.\n *\n * @private\n * @param {Function} func The function to convert.\n * @returns {string} Returns the source code.\n */\nfunction toSource(func) {\n if (func != null) {\n try {\n return funcToString.call(func);\n } catch (e) {}\n try {\n return (func + '');\n } catch (e) {}\n }\n return '';\n}\n\nexport default toSource;\n", "import isFunction from './isFunction.js';\nimport isMasked from './_isMasked.js';\nimport isObject from './isObject.js';\nimport toSource from './_toSource.js';\n\n/**\n * Used to match `RegExp`\n * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).\n */\nvar reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g;\n\n/** Used to detect host constructors (Safari). */\nvar reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n\n/** Used for built-in method references. */\nvar funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Used to detect if a method is native. */\nvar reIsNative = RegExp('^' +\n funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\\\$&')\n .replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$'\n);\n\n/**\n * The base implementation of `_.isNative` without bad shim checks.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n * else `false`.\n */\nfunction baseIsNative(value) {\n if (!isObject(value) || isMasked(value)) {\n return false;\n }\n var pattern = isFunction(value) ? reIsNative : reIsHostCtor;\n return pattern.test(toSource(value));\n}\n\nexport default baseIsNative;\n", "/**\n * Gets the value at `key` of `object`.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\nfunction getValue(object, key) {\n return object == null ? undefined : object[key];\n}\n\nexport default getValue;\n", "import baseIsNative from './_baseIsNative.js';\nimport getValue from './_getValue.js';\n\n/**\n * Gets the native function at `key` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the method to get.\n * @returns {*} Returns the function if it's native, else `undefined`.\n */\nfunction getNative(object, key) {\n var value = getValue(object, key);\n return baseIsNative(value) ? value : undefined;\n}\n\nexport default getNative;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar WeakMap = getNative(root, 'WeakMap');\n\nexport default WeakMap;\n", "/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/** Used to detect unsigned integer values. */\nvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n/**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\nfunction isIndex(value, length) {\n var type = typeof value;\n length = length == null ? MAX_SAFE_INTEGER : length;\n\n return !!length &&\n (type == 'number' ||\n (type != 'symbol' && reIsUint.test(value))) &&\n (value > -1 && value % 1 == 0 && value < length);\n}\n\nexport default isIndex;\n", "/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\nexport default eq;\n", "/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\nexport default isLength;\n", "import isFunction from './isFunction.js';\nimport isLength from './isLength.js';\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n}\n\nexport default isArrayLike;\n", "/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Checks if `value` is likely a prototype object.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.\n */\nfunction isPrototype(value) {\n var Ctor = value && value.constructor,\n proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;\n\n return value === proto;\n}\n\nexport default isPrototype;\n", "/**\n * The base implementation of `_.times` without support for iteratee shorthands\n * or max array length checks.\n *\n * @private\n * @param {number} n The number of times to invoke `iteratee`.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the array of results.\n */\nfunction baseTimes(n, iteratee) {\n var index = -1,\n result = Array(n);\n\n while (++index < n) {\n result[index] = iteratee(index);\n }\n return result;\n}\n\nexport default baseTimes;\n", "import baseGetTag from './_baseGetTag.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]';\n\n/**\n * The base implementation of `_.isArguments`.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n */\nfunction baseIsArguments(value) {\n return isObjectLike(value) && baseGetTag(value) == argsTag;\n}\n\nexport default baseIsArguments;\n", "import baseIsArguments from './_baseIsArguments.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Built-in value references. */\nvar propertyIsEnumerable = objectProto.propertyIsEnumerable;\n\n/**\n * Checks if `value` is likely an `arguments` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n * else `false`.\n * @example\n *\n * _.isArguments(function() { return arguments; }());\n * // => true\n *\n * _.isArguments([1, 2, 3]);\n * // => false\n */\nvar isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {\n return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&\n !propertyIsEnumerable.call(value, 'callee');\n};\n\nexport default isArguments;\n", "/**\n * This method returns `false`.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {boolean} Returns `false`.\n * @example\n *\n * _.times(2, _.stubFalse);\n * // => [false, false]\n */\nfunction stubFalse() {\n return false;\n}\n\nexport default stubFalse;\n", "import root from './_root.js';\nimport stubFalse from './stubFalse.js';\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Built-in value references. */\nvar Buffer = moduleExports ? root.Buffer : undefined;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;\n\n/**\n * Checks if `value` is a buffer.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.\n * @example\n *\n * _.isBuffer(new Buffer(2));\n * // => true\n *\n * _.isBuffer(new Uint8Array(2));\n * // => false\n */\nvar isBuffer = nativeIsBuffer || stubFalse;\n\nexport default isBuffer;\n", "import baseGetTag from './_baseGetTag.js';\nimport isLength from './isLength.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n errorTag = '[object Error]',\n funcTag = '[object Function]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n objectTag = '[object Object]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n weakMapTag = '[object WeakMap]';\n\nvar arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]',\n float32Tag = '[object Float32Array]',\n float64Tag = '[object Float64Array]',\n int8Tag = '[object Int8Array]',\n int16Tag = '[object Int16Array]',\n int32Tag = '[object Int32Array]',\n uint8Tag = '[object Uint8Array]',\n uint8ClampedTag = '[object Uint8ClampedArray]',\n uint16Tag = '[object Uint16Array]',\n uint32Tag = '[object Uint32Array]';\n\n/** Used to identify `toStringTag` values of typed arrays. */\nvar typedArrayTags = {};\ntypedArrayTags[float32Tag] = typedArrayTags[float64Tag] =\ntypedArrayTags[int8Tag] = typedArrayTags[int16Tag] =\ntypedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =\ntypedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =\ntypedArrayTags[uint32Tag] = true;\ntypedArrayTags[argsTag] = typedArrayTags[arrayTag] =\ntypedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =\ntypedArrayTags[dataViewTag] = typedArrayTags[dateTag] =\ntypedArrayTags[errorTag] = typedArrayTags[funcTag] =\ntypedArrayTags[mapTag] = typedArrayTags[numberTag] =\ntypedArrayTags[objectTag] = typedArrayTags[regexpTag] =\ntypedArrayTags[setTag] = typedArrayTags[stringTag] =\ntypedArrayTags[weakMapTag] = false;\n\n/**\n * The base implementation of `_.isTypedArray` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n */\nfunction baseIsTypedArray(value) {\n return isObjectLike(value) &&\n isLength(value.length) && !!typedArrayTags[baseGetTag(value)];\n}\n\nexport default baseIsTypedArray;\n", "/**\n * The base implementation of `_.unary` without support for storing metadata.\n *\n * @private\n * @param {Function} func The function to cap arguments for.\n * @returns {Function} Returns the new capped function.\n */\nfunction baseUnary(func) {\n return function(value) {\n return func(value);\n };\n}\n\nexport default baseUnary;\n", "import freeGlobal from './_freeGlobal.js';\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Detect free variable `process` from Node.js. */\nvar freeProcess = moduleExports && freeGlobal.process;\n\n/** Used to access faster Node.js helpers. */\nvar nodeUtil = (function() {\n try {\n // Use `util.types` for Node.js 10+.\n var types = freeModule && freeModule.require && freeModule.require('util').types;\n\n if (types) {\n return types;\n }\n\n // Legacy `process.binding('util')` for Node.js < 10.\n return freeProcess && freeProcess.binding && freeProcess.binding('util');\n } catch (e) {}\n}());\n\nexport default nodeUtil;\n", "import baseIsTypedArray from './_baseIsTypedArray.js';\nimport baseUnary from './_baseUnary.js';\nimport nodeUtil from './_nodeUtil.js';\n\n/* Node.js helper references. */\nvar nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;\n\n/**\n * Checks if `value` is classified as a typed array.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n * @example\n *\n * _.isTypedArray(new Uint8Array);\n * // => true\n *\n * _.isTypedArray([]);\n * // => false\n */\nvar isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;\n\nexport default isTypedArray;\n", "import baseTimes from './_baseTimes.js';\nimport isArguments from './isArguments.js';\nimport isArray from './isArray.js';\nimport isBuffer from './isBuffer.js';\nimport isIndex from './_isIndex.js';\nimport isTypedArray from './isTypedArray.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Creates an array of the enumerable property names of the array-like `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @param {boolean} inherited Specify returning inherited property names.\n * @returns {Array} Returns the array of property names.\n */\nfunction arrayLikeKeys(value, inherited) {\n var isArr = isArray(value),\n isArg = !isArr && isArguments(value),\n isBuff = !isArr && !isArg && isBuffer(value),\n isType = !isArr && !isArg && !isBuff && isTypedArray(value),\n skipIndexes = isArr || isArg || isBuff || isType,\n result = skipIndexes ? baseTimes(value.length, String) : [],\n length = result.length;\n\n for (var key in value) {\n if ((inherited || hasOwnProperty.call(value, key)) &&\n !(skipIndexes && (\n // Safari 9 has enumerable `arguments.length` in strict mode.\n key == 'length' ||\n // Node.js 0.10 has enumerable non-index properties on buffers.\n (isBuff && (key == 'offset' || key == 'parent')) ||\n // PhantomJS 2 has enumerable non-index properties on typed arrays.\n (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||\n // Skip index properties.\n isIndex(key, length)\n ))) {\n result.push(key);\n }\n }\n return result;\n}\n\nexport default arrayLikeKeys;\n", "/**\n * Creates a unary function that invokes `func` with its argument transformed.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {Function} transform The argument transform.\n * @returns {Function} Returns the new function.\n */\nfunction overArg(func, transform) {\n return function(arg) {\n return func(transform(arg));\n };\n}\n\nexport default overArg;\n", "import overArg from './_overArg.js';\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeKeys = overArg(Object.keys, Object);\n\nexport default nativeKeys;\n", "import isPrototype from './_isPrototype.js';\nimport nativeKeys from './_nativeKeys.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction baseKeys(object) {\n if (!isPrototype(object)) {\n return nativeKeys(object);\n }\n var result = [];\n for (var key in Object(object)) {\n if (hasOwnProperty.call(object, key) && key != 'constructor') {\n result.push(key);\n }\n }\n return result;\n}\n\nexport default baseKeys;\n", "import arrayLikeKeys from './_arrayLikeKeys.js';\nimport baseKeys from './_baseKeys.js';\nimport isArrayLike from './isArrayLike.js';\n\n/**\n * Creates an array of the own enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects. See the\n * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n * for more details.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keys(new Foo);\n * // => ['a', 'b'] (iteration order is not guaranteed)\n *\n * _.keys('hi');\n * // => ['0', '1']\n */\nfunction keys(object) {\n return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);\n}\n\nexport default keys;\n", "import getNative from './_getNative.js';\n\n/* Built-in method references that are verified to be native. */\nvar nativeCreate = getNative(Object, 'create');\n\nexport default nativeCreate;\n", "import nativeCreate from './_nativeCreate.js';\n\n/**\n * Removes all key-value entries from the hash.\n *\n * @private\n * @name clear\n * @memberOf Hash\n */\nfunction hashClear() {\n this.__data__ = nativeCreate ? nativeCreate(null) : {};\n this.size = 0;\n}\n\nexport default hashClear;\n", "/**\n * Removes `key` and its value from the hash.\n *\n * @private\n * @name delete\n * @memberOf Hash\n * @param {Object} hash The hash to modify.\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction hashDelete(key) {\n var result = this.has(key) && delete this.__data__[key];\n this.size -= result ? 1 : 0;\n return result;\n}\n\nexport default hashDelete;\n", "import nativeCreate from './_nativeCreate.js';\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Gets the hash value for `key`.\n *\n * @private\n * @name get\n * @memberOf Hash\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction hashGet(key) {\n var data = this.__data__;\n if (nativeCreate) {\n var result = data[key];\n return result === HASH_UNDEFINED ? undefined : result;\n }\n return hasOwnProperty.call(data, key) ? data[key] : undefined;\n}\n\nexport default hashGet;\n", "import nativeCreate from './_nativeCreate.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Checks if a hash value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Hash\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction hashHas(key) {\n var data = this.__data__;\n return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);\n}\n\nexport default hashHas;\n", "import nativeCreate from './_nativeCreate.js';\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/**\n * Sets the hash `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Hash\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the hash instance.\n */\nfunction hashSet(key, value) {\n var data = this.__data__;\n this.size += this.has(key) ? 0 : 1;\n data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;\n return this;\n}\n\nexport default hashSet;\n", "import hashClear from './_hashClear.js';\nimport hashDelete from './_hashDelete.js';\nimport hashGet from './_hashGet.js';\nimport hashHas from './_hashHas.js';\nimport hashSet from './_hashSet.js';\n\n/**\n * Creates a hash object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Hash(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `Hash`.\nHash.prototype.clear = hashClear;\nHash.prototype['delete'] = hashDelete;\nHash.prototype.get = hashGet;\nHash.prototype.has = hashHas;\nHash.prototype.set = hashSet;\n\nexport default Hash;\n", "/**\n * Removes all key-value entries from the list cache.\n *\n * @private\n * @name clear\n * @memberOf ListCache\n */\nfunction listCacheClear() {\n this.__data__ = [];\n this.size = 0;\n}\n\nexport default listCacheClear;\n", "import eq from './eq.js';\n\n/**\n * Gets the index at which the `key` is found in `array` of key-value pairs.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} key The key to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction assocIndexOf(array, key) {\n var length = array.length;\n while (length--) {\n if (eq(array[length][0], key)) {\n return length;\n }\n }\n return -1;\n}\n\nexport default assocIndexOf;\n", "import assocIndexOf from './_assocIndexOf.js';\n\n/** Used for built-in method references. */\nvar arrayProto = Array.prototype;\n\n/** Built-in value references. */\nvar splice = arrayProto.splice;\n\n/**\n * Removes `key` and its value from the list cache.\n *\n * @private\n * @name delete\n * @memberOf ListCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction listCacheDelete(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n return false;\n }\n var lastIndex = data.length - 1;\n if (index == lastIndex) {\n data.pop();\n } else {\n splice.call(data, index, 1);\n }\n --this.size;\n return true;\n}\n\nexport default listCacheDelete;\n", "import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Gets the list cache value for `key`.\n *\n * @private\n * @name get\n * @memberOf ListCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction listCacheGet(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n return index < 0 ? undefined : data[index][1];\n}\n\nexport default listCacheGet;\n", "import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Checks if a list cache value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf ListCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction listCacheHas(key) {\n return assocIndexOf(this.__data__, key) > -1;\n}\n\nexport default listCacheHas;\n", "import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Sets the list cache `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf ListCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the list cache instance.\n */\nfunction listCacheSet(key, value) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n ++this.size;\n data.push([key, value]);\n } else {\n data[index][1] = value;\n }\n return this;\n}\n\nexport default listCacheSet;\n", "import listCacheClear from './_listCacheClear.js';\nimport listCacheDelete from './_listCacheDelete.js';\nimport listCacheGet from './_listCacheGet.js';\nimport listCacheHas from './_listCacheHas.js';\nimport listCacheSet from './_listCacheSet.js';\n\n/**\n * Creates an list cache object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction ListCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `ListCache`.\nListCache.prototype.clear = listCacheClear;\nListCache.prototype['delete'] = listCacheDelete;\nListCache.prototype.get = listCacheGet;\nListCache.prototype.has = listCacheHas;\nListCache.prototype.set = listCacheSet;\n\nexport default ListCache;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar Map = getNative(root, 'Map');\n\nexport default Map;\n", "import Hash from './_Hash.js';\nimport ListCache from './_ListCache.js';\nimport Map from './_Map.js';\n\n/**\n * Removes all key-value entries from the map.\n *\n * @private\n * @name clear\n * @memberOf MapCache\n */\nfunction mapCacheClear() {\n this.size = 0;\n this.__data__ = {\n 'hash': new Hash,\n 'map': new (Map || ListCache),\n 'string': new Hash\n };\n}\n\nexport default mapCacheClear;\n", "/**\n * Checks if `value` is suitable for use as unique object key.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is suitable, else `false`.\n */\nfunction isKeyable(value) {\n var type = typeof value;\n return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')\n ? (value !== '__proto__')\n : (value === null);\n}\n\nexport default isKeyable;\n", "import isKeyable from './_isKeyable.js';\n\n/**\n * Gets the data for `map`.\n *\n * @private\n * @param {Object} map The map to query.\n * @param {string} key The reference key.\n * @returns {*} Returns the map data.\n */\nfunction getMapData(map, key) {\n var data = map.__data__;\n return isKeyable(key)\n ? data[typeof key == 'string' ? 'string' : 'hash']\n : data.map;\n}\n\nexport default getMapData;\n", "import getMapData from './_getMapData.js';\n\n/**\n * Removes `key` and its value from the map.\n *\n * @private\n * @name delete\n * @memberOf MapCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction mapCacheDelete(key) {\n var result = getMapData(this, key)['delete'](key);\n this.size -= result ? 1 : 0;\n return result;\n}\n\nexport default mapCacheDelete;\n", "import getMapData from './_getMapData.js';\n\n/**\n * Gets the map value for `key`.\n *\n * @private\n * @name get\n * @memberOf MapCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction mapCacheGet(key) {\n return getMapData(this, key).get(key);\n}\n\nexport default mapCacheGet;\n", "import getMapData from './_getMapData.js';\n\n/**\n * Checks if a map value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf MapCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction mapCacheHas(key) {\n return getMapData(this, key).has(key);\n}\n\nexport default mapCacheHas;\n", "import getMapData from './_getMapData.js';\n\n/**\n * Sets the map `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf MapCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the map cache instance.\n */\nfunction mapCacheSet(key, value) {\n var data = getMapData(this, key),\n size = data.size;\n\n data.set(key, value);\n this.size += data.size == size ? 0 : 1;\n return this;\n}\n\nexport default mapCacheSet;\n", "import mapCacheClear from './_mapCacheClear.js';\nimport mapCacheDelete from './_mapCacheDelete.js';\nimport mapCacheGet from './_mapCacheGet.js';\nimport mapCacheHas from './_mapCacheHas.js';\nimport mapCacheSet from './_mapCacheSet.js';\n\n/**\n * Creates a map cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction MapCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `MapCache`.\nMapCache.prototype.clear = mapCacheClear;\nMapCache.prototype['delete'] = mapCacheDelete;\nMapCache.prototype.get = mapCacheGet;\nMapCache.prototype.has = mapCacheHas;\nMapCache.prototype.set = mapCacheSet;\n\nexport default MapCache;\n", "/**\n * Appends the elements of `values` to `array`.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {Array} values The values to append.\n * @returns {Array} Returns `array`.\n */\nfunction arrayPush(array, values) {\n var index = -1,\n length = values.length,\n offset = array.length;\n\n while (++index < length) {\n array[offset + index] = values[index];\n }\n return array;\n}\n\nexport default arrayPush;\n", "import ListCache from './_ListCache.js';\n\n/**\n * Removes all key-value entries from the stack.\n *\n * @private\n * @name clear\n * @memberOf Stack\n */\nfunction stackClear() {\n this.__data__ = new ListCache;\n this.size = 0;\n}\n\nexport default stackClear;\n", "/**\n * Removes `key` and its value from the stack.\n *\n * @private\n * @name delete\n * @memberOf Stack\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction stackDelete(key) {\n var data = this.__data__,\n result = data['delete'](key);\n\n this.size = data.size;\n return result;\n}\n\nexport default stackDelete;\n", "/**\n * Gets the stack value for `key`.\n *\n * @private\n * @name get\n * @memberOf Stack\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction stackGet(key) {\n return this.__data__.get(key);\n}\n\nexport default stackGet;\n", "/**\n * Checks if a stack value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Stack\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction stackHas(key) {\n return this.__data__.has(key);\n}\n\nexport default stackHas;\n", "import ListCache from './_ListCache.js';\nimport Map from './_Map.js';\nimport MapCache from './_MapCache.js';\n\n/** Used as the size to enable large array optimizations. */\nvar LARGE_ARRAY_SIZE = 200;\n\n/**\n * Sets the stack `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Stack\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the stack cache instance.\n */\nfunction stackSet(key, value) {\n var data = this.__data__;\n if (data instanceof ListCache) {\n var pairs = data.__data__;\n if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {\n pairs.push([key, value]);\n this.size = ++data.size;\n return this;\n }\n data = this.__data__ = new MapCache(pairs);\n }\n data.set(key, value);\n this.size = data.size;\n return this;\n}\n\nexport default stackSet;\n", "import ListCache from './_ListCache.js';\nimport stackClear from './_stackClear.js';\nimport stackDelete from './_stackDelete.js';\nimport stackGet from './_stackGet.js';\nimport stackHas from './_stackHas.js';\nimport stackSet from './_stackSet.js';\n\n/**\n * Creates a stack cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Stack(entries) {\n var data = this.__data__ = new ListCache(entries);\n this.size = data.size;\n}\n\n// Add methods to `Stack`.\nStack.prototype.clear = stackClear;\nStack.prototype['delete'] = stackDelete;\nStack.prototype.get = stackGet;\nStack.prototype.has = stackHas;\nStack.prototype.set = stackSet;\n\nexport default Stack;\n", "/**\n * A specialized version of `_.filter` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {Array} Returns the new filtered array.\n */\nfunction arrayFilter(array, predicate) {\n var index = -1,\n length = array == null ? 0 : array.length,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (predicate(value, index, array)) {\n result[resIndex++] = value;\n }\n }\n return result;\n}\n\nexport default arrayFilter;\n", "/**\n * This method returns a new empty array.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {Array} Returns the new empty array.\n * @example\n *\n * var arrays = _.times(2, _.stubArray);\n *\n * console.log(arrays);\n * // => [[], []]\n *\n * console.log(arrays[0] === arrays[1]);\n * // => false\n */\nfunction stubArray() {\n return [];\n}\n\nexport default stubArray;\n", "import arrayFilter from './_arrayFilter.js';\nimport stubArray from './stubArray.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Built-in value references. */\nvar propertyIsEnumerable = objectProto.propertyIsEnumerable;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeGetSymbols = Object.getOwnPropertySymbols;\n\n/**\n * Creates an array of the own enumerable symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of symbols.\n */\nvar getSymbols = !nativeGetSymbols ? stubArray : function(object) {\n if (object == null) {\n return [];\n }\n object = Object(object);\n return arrayFilter(nativeGetSymbols(object), function(symbol) {\n return propertyIsEnumerable.call(object, symbol);\n });\n};\n\nexport default getSymbols;\n", "import arrayPush from './_arrayPush.js';\nimport isArray from './isArray.js';\n\n/**\n * The base implementation of `getAllKeys` and `getAllKeysIn` which uses\n * `keysFunc` and `symbolsFunc` to get the enumerable property names and\n * symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Function} keysFunc The function to get the keys of `object`.\n * @param {Function} symbolsFunc The function to get the symbols of `object`.\n * @returns {Array} Returns the array of property names and symbols.\n */\nfunction baseGetAllKeys(object, keysFunc, symbolsFunc) {\n var result = keysFunc(object);\n return isArray(object) ? result : arrayPush(result, symbolsFunc(object));\n}\n\nexport default baseGetAllKeys;\n", "import baseGetAllKeys from './_baseGetAllKeys.js';\nimport getSymbols from './_getSymbols.js';\nimport keys from './keys.js';\n\n/**\n * Creates an array of own enumerable property names and symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names and symbols.\n */\nfunction getAllKeys(object) {\n return baseGetAllKeys(object, keys, getSymbols);\n}\n\nexport default getAllKeys;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar DataView = getNative(root, 'DataView');\n\nexport default DataView;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar Promise = getNative(root, 'Promise');\n\nexport default Promise;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar Set = getNative(root, 'Set');\n\nexport default Set;\n", "import DataView from './_DataView.js';\nimport Map from './_Map.js';\nimport Promise from './_Promise.js';\nimport Set from './_Set.js';\nimport WeakMap from './_WeakMap.js';\nimport baseGetTag from './_baseGetTag.js';\nimport toSource from './_toSource.js';\n\n/** `Object#toString` result references. */\nvar mapTag = '[object Map]',\n objectTag = '[object Object]',\n promiseTag = '[object Promise]',\n setTag = '[object Set]',\n weakMapTag = '[object WeakMap]';\n\nvar dataViewTag = '[object DataView]';\n\n/** Used to detect maps, sets, and weakmaps. */\nvar dataViewCtorString = toSource(DataView),\n mapCtorString = toSource(Map),\n promiseCtorString = toSource(Promise),\n setCtorString = toSource(Set),\n weakMapCtorString = toSource(WeakMap);\n\n/**\n * Gets the `toStringTag` of `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nvar getTag = baseGetTag;\n\n// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.\nif ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||\n (Map && getTag(new Map) != mapTag) ||\n (Promise && getTag(Promise.resolve()) != promiseTag) ||\n (Set && getTag(new Set) != setTag) ||\n (WeakMap && getTag(new WeakMap) != weakMapTag)) {\n getTag = function(value) {\n var result = baseGetTag(value),\n Ctor = result == objectTag ? value.constructor : undefined,\n ctorString = Ctor ? toSource(Ctor) : '';\n\n if (ctorString) {\n switch (ctorString) {\n case dataViewCtorString: return dataViewTag;\n case mapCtorString: return mapTag;\n case promiseCtorString: return promiseTag;\n case setCtorString: return setTag;\n case weakMapCtorString: return weakMapTag;\n }\n }\n return result;\n };\n}\n\nexport default getTag;\n", "import root from './_root.js';\n\n/** Built-in value references. */\nvar Uint8Array = root.Uint8Array;\n\nexport default Uint8Array;\n", "/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/**\n * Adds `value` to the array cache.\n *\n * @private\n * @name add\n * @memberOf SetCache\n * @alias push\n * @param {*} value The value to cache.\n * @returns {Object} Returns the cache instance.\n */\nfunction setCacheAdd(value) {\n this.__data__.set(value, HASH_UNDEFINED);\n return this;\n}\n\nexport default setCacheAdd;\n", "/**\n * Checks if `value` is in the array cache.\n *\n * @private\n * @name has\n * @memberOf SetCache\n * @param {*} value The value to search for.\n * @returns {number} Returns `true` if `value` is found, else `false`.\n */\nfunction setCacheHas(value) {\n return this.__data__.has(value);\n}\n\nexport default setCacheHas;\n", "import MapCache from './_MapCache.js';\nimport setCacheAdd from './_setCacheAdd.js';\nimport setCacheHas from './_setCacheHas.js';\n\n/**\n *\n * Creates an array cache object to store unique values.\n *\n * @private\n * @constructor\n * @param {Array} [values] The values to cache.\n */\nfunction SetCache(values) {\n var index = -1,\n length = values == null ? 0 : values.length;\n\n this.__data__ = new MapCache;\n while (++index < length) {\n this.add(values[index]);\n }\n}\n\n// Add methods to `SetCache`.\nSetCache.prototype.add = SetCache.prototype.push = setCacheAdd;\nSetCache.prototype.has = setCacheHas;\n\nexport default SetCache;\n", "/**\n * A specialized version of `_.some` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if any element passes the predicate check,\n * else `false`.\n */\nfunction arraySome(array, predicate) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n while (++index < length) {\n if (predicate(array[index], index, array)) {\n return true;\n }\n }\n return false;\n}\n\nexport default arraySome;\n", "/**\n * Checks if a `cache` value for `key` exists.\n *\n * @private\n * @param {Object} cache The cache to query.\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction cacheHas(cache, key) {\n return cache.has(key);\n}\n\nexport default cacheHas;\n", "import SetCache from './_SetCache.js';\nimport arraySome from './_arraySome.js';\nimport cacheHas from './_cacheHas.js';\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1,\n COMPARE_UNORDERED_FLAG = 2;\n\n/**\n * A specialized version of `baseIsEqualDeep` for arrays with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Array} array The array to compare.\n * @param {Array} other The other array to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `array` and `other` objects.\n * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.\n */\nfunction equalArrays(array, other, bitmask, customizer, equalFunc, stack) {\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG,\n arrLength = array.length,\n othLength = other.length;\n\n if (arrLength != othLength && !(isPartial && othLength > arrLength)) {\n return false;\n }\n // Check that cyclic values are equal.\n var arrStacked = stack.get(array);\n var othStacked = stack.get(other);\n if (arrStacked && othStacked) {\n return arrStacked == other && othStacked == array;\n }\n var index = -1,\n result = true,\n seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;\n\n stack.set(array, other);\n stack.set(other, array);\n\n // Ignore non-index properties.\n while (++index < arrLength) {\n var arrValue = array[index],\n othValue = other[index];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, arrValue, index, other, array, stack)\n : customizer(arrValue, othValue, index, array, other, stack);\n }\n if (compared !== undefined) {\n if (compared) {\n continue;\n }\n result = false;\n break;\n }\n // Recursively compare arrays (susceptible to call stack limits).\n if (seen) {\n if (!arraySome(other, function(othValue, othIndex) {\n if (!cacheHas(seen, othIndex) &&\n (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {\n return seen.push(othIndex);\n }\n })) {\n result = false;\n break;\n }\n } else if (!(\n arrValue === othValue ||\n equalFunc(arrValue, othValue, bitmask, customizer, stack)\n )) {\n result = false;\n break;\n }\n }\n stack['delete'](array);\n stack['delete'](other);\n return result;\n}\n\nexport default equalArrays;\n", "/**\n * Converts `map` to its key-value pairs.\n *\n * @private\n * @param {Object} map The map to convert.\n * @returns {Array} Returns the key-value pairs.\n */\nfunction mapToArray(map) {\n var index = -1,\n result = Array(map.size);\n\n map.forEach(function(value, key) {\n result[++index] = [key, value];\n });\n return result;\n}\n\nexport default mapToArray;\n", "/**\n * Converts `set` to an array of its values.\n *\n * @private\n * @param {Object} set The set to convert.\n * @returns {Array} Returns the values.\n */\nfunction setToArray(set) {\n var index = -1,\n result = Array(set.size);\n\n set.forEach(function(value) {\n result[++index] = value;\n });\n return result;\n}\n\nexport default setToArray;\n", "import Symbol from './_Symbol.js';\nimport Uint8Array from './_Uint8Array.js';\nimport eq from './eq.js';\nimport equalArrays from './_equalArrays.js';\nimport mapToArray from './_mapToArray.js';\nimport setToArray from './_setToArray.js';\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1,\n COMPARE_UNORDERED_FLAG = 2;\n\n/** `Object#toString` result references. */\nvar boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n errorTag = '[object Error]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n symbolTag = '[object Symbol]';\n\nvar arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]';\n\n/** Used to convert symbols to primitives and strings. */\nvar symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;\n\n/**\n * A specialized version of `baseIsEqualDeep` for comparing objects of\n * the same `toStringTag`.\n *\n * **Note:** This function only supports comparing values with tags of\n * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {string} tag The `toStringTag` of the objects to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {\n switch (tag) {\n case dataViewTag:\n if ((object.byteLength != other.byteLength) ||\n (object.byteOffset != other.byteOffset)) {\n return false;\n }\n object = object.buffer;\n other = other.buffer;\n\n case arrayBufferTag:\n if ((object.byteLength != other.byteLength) ||\n !equalFunc(new Uint8Array(object), new Uint8Array(other))) {\n return false;\n }\n return true;\n\n case boolTag:\n case dateTag:\n case numberTag:\n // Coerce booleans to `1` or `0` and dates to milliseconds.\n // Invalid dates are coerced to `NaN`.\n return eq(+object, +other);\n\n case errorTag:\n return object.name == other.name && object.message == other.message;\n\n case regexpTag:\n case stringTag:\n // Coerce regexes to strings and treat strings, primitives and objects,\n // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring\n // for more details.\n return object == (other + '');\n\n case mapTag:\n var convert = mapToArray;\n\n case setTag:\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG;\n convert || (convert = setToArray);\n\n if (object.size != other.size && !isPartial) {\n return false;\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(object);\n if (stacked) {\n return stacked == other;\n }\n bitmask |= COMPARE_UNORDERED_FLAG;\n\n // Recursively compare objects (susceptible to call stack limits).\n stack.set(object, other);\n var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);\n stack['delete'](object);\n return result;\n\n case symbolTag:\n if (symbolValueOf) {\n return symbolValueOf.call(object) == symbolValueOf.call(other);\n }\n }\n return false;\n}\n\nexport default equalByTag;\n", "import getAllKeys from './_getAllKeys.js';\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1;\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * A specialized version of `baseIsEqualDeep` for objects with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction equalObjects(object, other, bitmask, customizer, equalFunc, stack) {\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG,\n objProps = getAllKeys(object),\n objLength = objProps.length,\n othProps = getAllKeys(other),\n othLength = othProps.length;\n\n if (objLength != othLength && !isPartial) {\n return false;\n }\n var index = objLength;\n while (index--) {\n var key = objProps[index];\n if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {\n return false;\n }\n }\n // Check that cyclic values are equal.\n var objStacked = stack.get(object);\n var othStacked = stack.get(other);\n if (objStacked && othStacked) {\n return objStacked == other && othStacked == object;\n }\n var result = true;\n stack.set(object, other);\n stack.set(other, object);\n\n var skipCtor = isPartial;\n while (++index < objLength) {\n key = objProps[index];\n var objValue = object[key],\n othValue = other[key];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, objValue, key, other, object, stack)\n : customizer(objValue, othValue, key, object, other, stack);\n }\n // Recursively compare objects (susceptible to call stack limits).\n if (!(compared === undefined\n ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))\n : compared\n )) {\n result = false;\n break;\n }\n skipCtor || (skipCtor = key == 'constructor');\n }\n if (result && !skipCtor) {\n var objCtor = object.constructor,\n othCtor = other.constructor;\n\n // Non `Object` object instances with different constructors are not equal.\n if (objCtor != othCtor &&\n ('constructor' in object && 'constructor' in other) &&\n !(typeof objCtor == 'function' && objCtor instanceof objCtor &&\n typeof othCtor == 'function' && othCtor instanceof othCtor)) {\n result = false;\n }\n }\n stack['delete'](object);\n stack['delete'](other);\n return result;\n}\n\nexport default equalObjects;\n", "import Stack from './_Stack.js';\nimport equalArrays from './_equalArrays.js';\nimport equalByTag from './_equalByTag.js';\nimport equalObjects from './_equalObjects.js';\nimport getTag from './_getTag.js';\nimport isArray from './isArray.js';\nimport isBuffer from './isBuffer.js';\nimport isTypedArray from './isTypedArray.js';\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1;\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n objectTag = '[object Object]';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * A specialized version of `baseIsEqual` for arrays and objects which performs\n * deep comparisons and tracks traversed objects enabling objects with circular\n * references to be compared.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} [stack] Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {\n var objIsArr = isArray(object),\n othIsArr = isArray(other),\n objTag = objIsArr ? arrayTag : getTag(object),\n othTag = othIsArr ? arrayTag : getTag(other);\n\n objTag = objTag == argsTag ? objectTag : objTag;\n othTag = othTag == argsTag ? objectTag : othTag;\n\n var objIsObj = objTag == objectTag,\n othIsObj = othTag == objectTag,\n isSameTag = objTag == othTag;\n\n if (isSameTag && isBuffer(object)) {\n if (!isBuffer(other)) {\n return false;\n }\n objIsArr = true;\n objIsObj = false;\n }\n if (isSameTag && !objIsObj) {\n stack || (stack = new Stack);\n return (objIsArr || isTypedArray(object))\n ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)\n : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);\n }\n if (!(bitmask & COMPARE_PARTIAL_FLAG)) {\n var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),\n othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');\n\n if (objIsWrapped || othIsWrapped) {\n var objUnwrapped = objIsWrapped ? object.value() : object,\n othUnwrapped = othIsWrapped ? other.value() : other;\n\n stack || (stack = new Stack);\n return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);\n }\n }\n if (!isSameTag) {\n return false;\n }\n stack || (stack = new Stack);\n return equalObjects(object, other, bitmask, customizer, equalFunc, stack);\n}\n\nexport default baseIsEqualDeep;\n", "import baseIsEqualDeep from './_baseIsEqualDeep.js';\nimport isObjectLike from './isObjectLike.js';\n\n/**\n * The base implementation of `_.isEqual` which supports partial comparisons\n * and tracks traversed objects.\n *\n * @private\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @param {boolean} bitmask The bitmask flags.\n * 1 - Unordered comparison\n * 2 - Partial comparison\n * @param {Function} [customizer] The function to customize comparisons.\n * @param {Object} [stack] Tracks traversed `value` and `other` objects.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n */\nfunction baseIsEqual(value, other, bitmask, customizer, stack) {\n if (value === other) {\n return true;\n }\n if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {\n return value !== value && other !== other;\n }\n return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);\n}\n\nexport default baseIsEqual;\n", "import baseIsEqual from './_baseIsEqual.js';\n\n/**\n * Performs a deep comparison between two values to determine if they are\n * equivalent.\n *\n * **Note:** This method supports comparing arrays, array buffers, booleans,\n * date objects, error objects, maps, numbers, `Object` objects, regexes,\n * sets, strings, symbols, and typed arrays. `Object` objects are compared\n * by their own, not inherited, enumerable properties. Functions and DOM\n * nodes are compared by strict equality, i.e. `===`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.isEqual(object, other);\n * // => true\n *\n * object === other;\n * // => false\n */\nfunction isEqual(value, other) {\n return baseIsEqual(value, other);\n}\n\nexport default isEqual;\n", "import { isEqual } from 'lodash-es';\n\nimport Metadata from './Metadata';\nimport {\n PluginStatusError,\n PluginStatusMetadata,\n PluginStatusProcessed,\n PluginStatusProcessing\n} from './types';\n\nclass ImageProcessingMetadata extends Metadata<PluginStatusMetadata> {\n get(blockId: number): PluginStatusMetadata {\n return super.get(blockId) ?? { status: 'IDLE' };\n }\n\n /**\n * Detect if the block has been duplicated with processed or processing\n * fill processing. In that case the processing state is still\n * valid, but blockId and fillId have changed.\n */\n isDuplicate(blockId: number): boolean {\n if (!this.engine.block.isValid(blockId)) return false;\n\n const metadata = this.get(blockId);\n\n if (\n metadata.status === 'IDLE' ||\n metadata.status === 'PENDING' ||\n metadata.status === 'ERROR'\n )\n return false;\n\n if (!this.engine.block.hasFill(blockId)) return false;\n const fillId = this.engine.block.getFill(blockId);\n\n // It cannot be a duplicate if the blockId or fillId are the same\n if (metadata.blockId === blockId || metadata.fillId === fillId)\n return false;\n\n return true;\n }\n\n /**\n * Fixes the metadata if the block has been duplicated, i.e. the blockId and\n * fillId will be updated to the current block/fill.\n *\n * Please note: Call this method only on duplicates (see isDuplicate).\n */\n fixDuplicate(blockId: number) {\n const fillId = this.engine.block.getFill(blockId);\n const metadata = this.get(blockId);\n if (\n metadata.status === 'IDLE' ||\n metadata.status === 'PENDING' ||\n metadata.status === 'ERROR'\n )\n return;\n this.set(blockId, {\n ...metadata,\n blockId,\n fillId\n });\n\n // If it is currently processing the best we can do is to just recover\n // the initial image data, since no processing will update this block and\n // it will be stuck in the processing state.\n if (metadata.status === 'PROCESSING') {\n this.recoverInitialImageData(blockId);\n this.clear(blockId);\n }\n }\n\n /**\n * Check if the image has a consisten metadata state. A inconsistent state is\n * caused by outside changes of the fill data.\n *\n * @returns true if the metadata is consistent, false otherwise\n */\n isConsistent(blockId: number): boolean {\n // In case the block was removed, we just abort and mark it\n // as reset by returning true\n if (!this.engine.block.isValid(blockId)) return false;\n const metadata = this.get(blockId);\n if (metadata.status === 'IDLE' || metadata.status === 'PENDING')\n return true;\n\n if (!this.engine.block.hasFill(blockId)) return false;\n const fillId = this.engine.block.getFill(blockId);\n if (fillId == null) return false;\n\n if (blockId !== metadata.blockId || fillId !== metadata.fillId)\n return false;\n\n const sourceSet = this.engine.block.getSourceSet(\n fillId,\n 'fill/image/sourceSet'\n );\n const imageFileURI = this.engine.block.getString(\n fillId,\n 'fill/image/imageFileURI'\n );\n\n if (\n sourceSet.length === 0 &&\n !imageFileURI &&\n metadata.status === 'PROCESSING'\n ) {\n // While we process it is OK to have no image file URI and no source set\n // (which we cleared to show the spinning loader)\n return true;\n }\n\n // Source sets have precedence over imageFileURI so if we have a source set,\n // we only need to check if it has changed to something else.\n if (sourceSet?.length > 0) {\n const initialSourceSet = metadata.initialSourceSet;\n // If we have already processed the image, we need to check if the source set\n // we need to check against both source sets, the removed and the initial\n if (metadata.status !== 'PROCESSED') {\n if (!isEqual(sourceSet, initialSourceSet)) {\n return false;\n }\n }\n } else {\n if (metadata.status !== 'PROCESSED') {\n if (imageFileURI !== metadata.initialImageFileURI) {\n return false;\n }\n }\n }\n return true;\n }\n\n /**\n * Recover the initial values to avoid the loading spinner and have the same\n * state as before the fill processing was started.\n */\n recoverInitialImageData(blockId: number) {\n const blockApi = this.engine.block;\n if (!blockApi.hasFill(blockId)) return; // Nothing to recover (no fill anymore)\n\n const metadata = this.get(blockId);\n\n if (metadata.status === 'PENDING' || metadata.status === 'IDLE') {\n return;\n }\n\n const initialSourceSet = metadata.initialSourceSet;\n const initialImageFileURI = metadata.initialImageFileURI;\n const initialPreviewFileURI = metadata.initialPreviewFileURI;\n\n const fillId = this.getValidFill(blockId, metadata);\n if (fillId == null) return;\n\n if (initialImageFileURI) {\n this.engine.block.setString(\n fillId,\n 'fill/image/imageFileURI',\n initialImageFileURI\n );\n }\n if (initialPreviewFileURI) {\n this.engine.block.setString(\n fillId,\n 'fill/image/previewFileURI',\n initialPreviewFileURI\n );\n }\n if (initialSourceSet.length > 0) {\n this.engine.block.setSourceSet(\n fillId,\n 'fill/image/sourceSet',\n initialSourceSet\n );\n }\n }\n\n /**\n * Returns the fill id of the block if it has a valid fill that was used for\n * fill processing. Returns undefined otherwise.\n */\n private getValidFill(\n blockId: number,\n metadata: PluginStatusProcessing | PluginStatusError | PluginStatusProcessed\n ): number | undefined {\n if (\n !this.engine.block.isValid(blockId) ||\n !this.engine.block.hasFill(blockId) ||\n blockId !== metadata.blockId\n ) {\n return undefined;\n }\n const fillId = this.engine.block.getFill(blockId);\n if (fillId !== metadata.fillId) {\n return undefined;\n }\n\n return fillId;\n }\n}\n\nexport default ImageProcessingMetadata;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { FillProcessingMetadata } from '..';\nimport {\n PluginStatusProcessed,\n PluginStatusProcessing\n} from '../metadata/types';\n\ninterface FillProcessor<T> {\n processFill(metadataState: PluginStatusProcessing): Promise<T>;\n\n commitProcessing(\n data: T,\n metadataState: PluginStatusProcessed\n ): number | void;\n}\n\nasync function fillProcessing<T>(\n blockId: number,\n cesdk: CreativeEditorSDK,\n metadata: FillProcessingMetadata,\n processor: FillProcessor<T>\n) {\n const blockApi = cesdk.engine.block;\n if (!blockApi.hasFill(blockId))\n throw new Error('Block does not support fill');\n\n const fillId = blockApi.getFill(blockId);\n\n // Get the current image URI and source set as initial values.\n const initialSourceSet = blockApi.getSourceSet(\n fillId,\n 'fill/image/sourceSet'\n );\n const initialImageFileURI = blockApi.getString(\n fillId,\n 'fill/image/imageFileURI'\n );\n const initialPreviewFileURI = blockApi.getString(\n fillId,\n 'fill/image/previewFileURI'\n );\n try {\n cesdk.engine.block.setState(fillId, {\n type: 'Pending',\n progress: 0\n });\n\n const status: PluginStatusProcessing = {\n ...metadata.get(blockId),\n version: PLUGIN_VERSION,\n initialSourceSet,\n initialImageFileURI,\n initialPreviewFileURI,\n blockId,\n fillId,\n status: 'PROCESSING'\n };\n\n metadata.set(blockId, status);\n\n const processedData = await processor.processFill(status);\n // Check for externally changed state while we were applying the mask and\n // do not proceed if the state was reset.\n if (\n metadata.get(blockId).status !== 'PROCESSING' ||\n !metadata.isConsistent(blockId)\n )\n return;\n\n // Check for externally changed state while we were uploading and\n // do not proceed if the state was reset.\n if (\n metadata.get(blockId).status !== 'PROCESSING' ||\n !metadata.isConsistent(blockId)\n )\n return;\n\n if (processedData == null) return;\n\n const metadataStateProcessed: PluginStatusProcessed = {\n version: PLUGIN_VERSION,\n initialSourceSet,\n initialImageFileURI,\n initialPreviewFileURI,\n blockId,\n fillId,\n status: 'PROCESSED'\n };\n\n const blockIdOrVoid = processor.commitProcessing(\n processedData,\n metadataStateProcessed\n );\n\n // If a new block was created, we do not update the metadata.\n if (blockIdOrVoid == null || blockIdOrVoid === blockId) {\n metadata.set(blockId, metadataStateProcessed);\n }\n\n // Finally, create an undo step\n cesdk.engine.editor.addUndoStep();\n } catch (error) {\n if (cesdk.engine.block.isValid(blockId)) {\n metadata.set(blockId, {\n version: PLUGIN_VERSION,\n initialSourceSet,\n initialImageFileURI,\n initialPreviewFileURI,\n blockId,\n fillId,\n status: 'ERROR'\n });\n\n metadata.recoverInitialImageData(blockId);\n }\n\n if (\n error != null &&\n typeof error === 'object' &&\n 'message' in error &&\n typeof error.message === 'string'\n ) {\n const message =\n error.message === 'signal timed out'\n ? 'Processing canceled due to timeout'\n : error.message;\n cesdk.ui.showNotification({\n type: 'error',\n message\n });\n }\n\n // eslint-disable-next-line no-console\n console.log(error);\n } finally {\n if (cesdk.engine.block.isValid(fillId)) {\n cesdk.engine.block.setState(fillId, { type: 'Ready' });\n }\n }\n}\n\nexport default fillProcessing;\n", "export function getFeatureId(pluginId: string): string {\n return `${pluginId}.fillProcessing.feature`;\n}\n\nexport function getCanvasMenuComponentIds(pluginId: string): string[] {\n return [`${pluginId}.canvasMenu`, `${pluginId}.fillProcessing.canvasMenu`];\n}\n\nexport function getDockComponentIds(pluginId: string): string[] {\n return [`${pluginId}.dock`, `${pluginId}.fillProcessing.dock`];\n}\n\nexport function getInspectorBarComponentIds(pluginId: string): string[] {\n return [\n `${pluginId}.inspectorBar`,\n `${pluginId}.fillProcessing.inspectorBar`\n ];\n}\n\nexport function getNavigationBarComponentIds(pluginId: string): string[] {\n return [\n `${pluginId}.navigationBar`,\n `${pluginId}.fillProcessing.navigationBar`\n ];\n}\n\nexport function getCanvasBarComponentIds(pluginId: string): string[] {\n return [`${pluginId}.canvasBar`, `${pluginId}.fillProcessing.canvasBar`];\n}\n\nexport function getI18nCanvasMenuLabel(pluginId: string): string {\n return `plugin.${pluginId}.fillProcessing.canvasMenu.button.label`;\n}\n\nexport function getI18nDockLabel(pluginId: string): string {\n return `plugin.${pluginId}.fillProcessing.dock.button.label`;\n}\n\nexport function getI18nInspectorBarLabel(pluginId: string): string {\n return `plugin.${pluginId}.fillProcessing.inspectorBar.button.label`;\n}\n\nexport function getI18nNavigationBarLabel(pluginId: string): string {\n return `plugin.${pluginId}.fillProcessing.navigationBar.button.label`;\n}\n\nexport function getI18nCanvasBarLabel(pluginId: string): string {\n return `plugin.${pluginId}.fillProcessing.canvasBar.button.label`;\n}\n", "import type CreativeEditorSDK from '@cesdk/cesdk-js';\n\nimport { FillProcessingMetadata } from '..';\nimport { getFeatureId } from './constants';\n\nexport default function handleFillProcessing(\n cesdk: CreativeEditorSDK,\n {\n pluginId,\n process\n }: {\n pluginId: string;\n icon?: string;\n process: (blockId: number, metadata: FillProcessingMetadata) => void;\n }\n): {\n featureId: string;\n} {\n const featureId = getFeatureId(pluginId);\n\n const metadata = new FillProcessingMetadata(cesdk.engine, pluginId);\n\n enableFeatures(cesdk, metadata, featureId);\n\n cesdk.engine.event.subscribe([], async (events) => {\n events.forEach((e) => {\n const id = e.block;\n if (!cesdk.engine.block.isValid(id) || !metadata.hasData(id)) {\n return;\n }\n\n if (e.type === 'Created') {\n if (metadata.isDuplicate(id)) {\n metadata.fixDuplicate(id);\n }\n } else if (e.type === 'Updated') {\n switch (metadata.get(id).status) {\n case 'PENDING': {\n if (\n cesdk.feature.isEnabled(featureId, {\n engine: cesdk.engine\n }) &&\n cesdk.engine.block.isAllowedByScope(id, 'fill/change') &&\n cesdk.engine.block.getState(id).type !== 'Pending'\n ) {\n process(id, metadata);\n }\n break;\n }\n\n case 'PROCESSING':\n case 'PROCESSED': {\n if (!metadata.isConsistent(id)) {\n metadata.clear(id);\n }\n break;\n }\n\n default: {\n // We do not care about other states\n }\n }\n }\n });\n });\n\n return { featureId };\n}\n\n/**\n * Defines the feature that determines in which context (on which block)\n * fill processing is allowed/enabled.\n */\nfunction enableFeatures(\n cesdk: CreativeEditorSDK,\n metadata: FillProcessingMetadata,\n featureId: string\n) {\n cesdk.feature.enable(featureId, ({ engine }) => {\n const selectedIds = engine.block.findAllSelected();\n if (selectedIds.length !== 1) {\n return false;\n }\n const [selectedId] = selectedIds;\n\n if (!cesdk.engine.block.isVisible(selectedId)) return false;\n\n if (cesdk.engine.block.hasFill(selectedId)) {\n const kind = cesdk.engine.block.getKind(selectedId);\n if (kind === 'sticker') return false;\n\n const fillId = cesdk.engine.block.getFill(selectedId);\n const fillType = cesdk.engine.block.getType(fillId);\n\n if (fillType !== '//ly.img.ubq/fill/image') {\n return false;\n }\n\n const fileUri = engine.block.getString(fillId, 'fill/image/imageFileURI');\n const sourceSet = engine.block.getSourceSet(\n fillId,\n 'fill/image/sourceSet'\n );\n\n if (sourceSet.length > 0 || fileUri !== '') return true;\n\n // If we are in a processing state we do not have a imageFileURI or\n // source set set (to show the loading spinner), but the feature is still\n // enabled.\n return metadata.get(selectedId).status === 'PROCESSING';\n }\n\n return false;\n });\n}\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { FillProcessingMetadata } from '..';\nimport {\n getCanvasBarComponentIds,\n getCanvasMenuComponentIds,\n getDockComponentIds,\n getFeatureId,\n getI18nCanvasBarLabel,\n getI18nCanvasMenuLabel,\n getI18nDockLabel,\n getI18nInspectorBarLabel,\n getI18nNavigationBarLabel,\n getInspectorBarComponentIds,\n getNavigationBarComponentIds\n} from './constants';\n\nexport type Location =\n | 'inspectorBar'\n | 'navigationBar'\n | 'canvasBarTop'\n | 'canvasBarBottom'\n | 'canvasMenu'\n | 'dock';\n\n/**\n * Registers the components that can be used to process the fill of\n * a block.\n */\nexport default function registerFillProcessingComponents(\n cesdk: CreativeEditorSDK,\n options: {\n pluginId: string;\n icon?: string;\n locations?: Location | Location[];\n }\n): {\n canvasMenuComponentId: string;\n dockComponentId: string;\n\n translationsKeys: {\n inspectorBarLabel: string;\n navigationBarLabel: string;\n canvasBarLabel: string;\n canvasMenuLabel: string;\n dockLabel: string;\n };\n} {\n const { pluginId, locations } = options;\n const metadata = new FillProcessingMetadata(cesdk.engine, pluginId);\n\n const canvasMenuLabel = getI18nCanvasMenuLabel(pluginId);\n const canvasMenuComponentIds = getCanvasMenuComponentIds(pluginId);\n const canvasMenuComponentId = canvasMenuComponentIds[0];\n\n const dockLabel = getI18nDockLabel(pluginId);\n const dockComponentIds = getDockComponentIds(pluginId);\n const dockComponentId = dockComponentIds[0];\n\n const inspectorBarLabel = getI18nInspectorBarLabel(pluginId);\n const inspectorBarComponentIds = getInspectorBarComponentIds(pluginId);\n const inspectorBarComponentId = inspectorBarComponentIds[0];\n\n const navigationBarLabel = getI18nNavigationBarLabel(pluginId);\n const navigationBarComponentIds = getNavigationBarComponentIds(pluginId);\n const navigationBarComponentId = navigationBarComponentIds[0];\n\n const canvasBarLabel = getI18nCanvasBarLabel(pluginId);\n const canvasBarComponentIds = getCanvasBarComponentIds(pluginId);\n const canvasBarComponentId = canvasBarComponentIds[0];\n\n const featureId = getFeatureId(pluginId);\n\n if (locations?.includes('inspectorBar')) {\n cesdk.ui.setInspectorBarOrder([\n inspectorBarComponentId,\n ...cesdk.ui.getInspectorBarOrder()\n ]);\n }\n\n if (locations?.includes('navigationBar')) {\n cesdk.ui.setNavigationBarOrder([\n navigationBarComponentId,\n ...cesdk.ui.getNavigationBarOrder()\n ]);\n }\n\n if (locations?.includes('canvasBarTop')) {\n cesdk.ui.setCanvasBarOrder(\n [canvasBarComponentId, ...cesdk.ui.getCanvasBarOrder('top')],\n 'top'\n );\n }\n\n if (locations?.includes('canvasBarBottom')) {\n cesdk.ui.setCanvasBarOrder(\n [canvasBarComponentId, ...cesdk.ui.getCanvasBarOrder('bottom')],\n 'bottom'\n );\n }\n\n if (locations?.includes('canvasMenu')) {\n cesdk.ui.setCanvasMenuOrder([\n canvasMenuComponentId,\n ...cesdk.ui.getCanvasMenuOrder()\n ]);\n }\n\n if (locations?.includes('dock')) {\n cesdk.ui.setDockOrder([...cesdk.ui.getDockOrder(), dockComponentId]);\n }\n\n cesdk.ui.registerComponent(\n dockComponentIds,\n ({ builder: { Button }, engine }) => {\n const [id] = engine.block.findAllSelected();\n\n let isDisabled = false;\n let isLoading = false;\n let loadingProgress: number | undefined;\n\n if (id == null) {\n isDisabled = true;\n }\n\n if (\n !isDisabled &&\n !cesdk.feature.isEnabled(featureId, {\n engine\n })\n ) {\n isDisabled = true;\n }\n\n if (\n !isDisabled &&\n !cesdk.engine.block.isAllowedByScope(id, 'fill/change')\n ) {\n isDisabled = true;\n }\n\n if (!isDisabled && engine.block.getState(id)?.type === 'Pending') {\n isDisabled = true;\n }\n\n if (!isDisabled) {\n const currentMetadata = metadata.get(id);\n\n isLoading = currentMetadata.status === 'PROCESSING';\n isDisabled =\n currentMetadata.status === 'PENDING' ||\n currentMetadata.status === 'PROCESSING';\n\n if (\n currentMetadata.status === 'PROCESSING' &&\n currentMetadata.progress\n ) {\n const { current, total } = currentMetadata.progress;\n loadingProgress = (current / total) * 100;\n }\n }\n\n const buttonId = `${dockComponentId}.button`;\n Button(buttonId, {\n label: dockLabel,\n icon: options.icon,\n isLoading,\n isDisabled,\n loadingProgress,\n onClick: () => {\n const currentMetadata = metadata.get(id);\n\n if (\n currentMetadata.status === 'IDLE' ||\n currentMetadata.status === 'ERROR' ||\n currentMetadata.status === 'PROCESSED'\n ) {\n metadata.set(id, {\n status: 'PENDING'\n });\n }\n }\n });\n }\n );\n\n const buttonComponents: {\n componentIds: string[];\n label: string;\n variant: 'plain' | 'regular';\n }[] = [\n {\n componentIds: inspectorBarComponentIds,\n variant: 'plain',\n label: inspectorBarLabel\n },\n {\n componentIds: navigationBarComponentIds,\n variant: 'regular',\n label: navigationBarLabel\n },\n {\n componentIds: canvasBarComponentIds,\n variant: 'regular',\n label: canvasBarLabel\n },\n {\n componentIds: canvasMenuComponentIds,\n variant: 'plain',\n label: canvasMenuLabel\n }\n ];\n\n buttonComponents.forEach(({ componentIds, label, variant }) => {\n const componentId = componentIds[0];\n cesdk.ui.registerComponent(\n componentIds,\n ({ builder: { Button }, engine }) => {\n if (\n !cesdk.feature.isEnabled(featureId, {\n engine\n })\n ) {\n return;\n }\n\n const [id] = engine.block.findAllSelected();\n\n if (!cesdk.engine.block.isAllowedByScope(id, 'fill/change')) return;\n\n const currentMetadata = metadata.get(id);\n\n const isLoading = currentMetadata.status === 'PROCESSING';\n const isDisabled =\n currentMetadata.status === 'PENDING' ||\n currentMetadata.status === 'PROCESSING' ||\n engine.block.getState(id)?.type === 'Pending';\n\n let loadingProgress: number | undefined;\n if (isLoading && currentMetadata.progress) {\n const { current, total } = currentMetadata.progress;\n loadingProgress = (current / total) * 100;\n }\n\n const buttonId = `${componentId}.button`;\n Button(buttonId, {\n icon: options.icon,\n label,\n variant,\n isLoading,\n isDisabled,\n loadingProgress,\n onClick: () => {\n if (\n currentMetadata.status === 'IDLE' ||\n currentMetadata.status === 'ERROR' ||\n currentMetadata.status === 'PROCESSED'\n ) {\n metadata.set(id, {\n status: 'PENDING'\n });\n }\n }\n });\n }\n );\n });\n\n return {\n canvasMenuComponentId,\n dockComponentId,\n translationsKeys: {\n inspectorBarLabel,\n navigationBarLabel,\n canvasBarLabel,\n canvasMenuLabel,\n dockLabel\n }\n };\n}\n", "import { type RGBAColor } from '@cesdk/cesdk-js';\n\nconst HEX_COLOR_PATTERN = new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/, 'i');\nconst HEX_SINGLE_CHAR_COMPONENTS_PATTERN = new RegExp(/[A-Fa-f0-9]{1}/, 'g');\nconst HEX_DOUBLE_CHAR_COMPONENTS_PATTERN = new RegExp(/[A-Fa-f0-9]{2}/, 'g');\n\n/** @public */\nexport const rgbaToHex = (rgba: RGBAColor, includeAlpha = false): string => {\n const { r, g, b, a } = rgba;\n const rByte = Math.round(255 * r);\n const gByte = Math.round(255 * g);\n const bByte = Math.round(255 * b);\n const aByte = Math.round(255 * a);\n const byteToHex = (byte: number) => {\n return byte.toString(16).padStart(2, '0');\n };\n return `#${byteToHex(rByte)}${byteToHex(gByte)}${byteToHex(bByte)}${\n includeAlpha ? byteToHex(aByte) : ''\n }`;\n};\n\n/** @public */\nexport const hexToRgba = (hexString: string): RGBAColor => {\n const rgbaHexToColor = (\n r: string,\n g: string,\n b: string,\n a: string | undefined,\n max: number\n ) => {\n return {\n r: parseInt(r, 16) / max,\n g: parseInt(g, 16) / max,\n b: parseInt(b, 16) / max,\n a: a === undefined ? 1 : parseInt(a, 16) / max\n };\n };\n\n if (hexString.startsWith('#')) {\n if (hexString.length === 4 || hexString.length === 5) {\n const hexMatch = hexString.match(HEX_SINGLE_CHAR_COMPONENTS_PATTERN);\n if (hexMatch) {\n const [r, g, b, a] = hexMatch;\n return rgbaHexToColor(r, g, b, a, 15);\n }\n }\n if (hexString.length === 7 || hexString.length === 8) {\n const hexMatch = hexString.match(HEX_DOUBLE_CHAR_COMPONENTS_PATTERN);\n if (hexMatch) {\n const [r, g, b, a] = hexMatch;\n return rgbaHexToColor(r, g, b, a, 255);\n }\n }\n }\n\n throw new Error(\n 'Invalid hex string! Allowed RGB formats are \"#FFF\" and \"#FFFFFF\". Allowed RGBA formats are \"#FFFF\" and \"#FFFFFFFF'\n );\n};\n\n/** @public */\nexport const isValidHexColor = (hexString: string): boolean => {\n return HEX_COLOR_PATTERN.test(hexString);\n};\n", "import type CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { CreativeEngine } from '@cesdk/cesdk-js';\n\n/**\n * Uploads a blob with the help of CE.SDK\n */\nexport async function uploadBlob(\n blob: Blob,\n initialUri: string,\n cesdk: CreativeEditorSDK\n) {\n const pathname = new URL(initialUri).pathname;\n const parts = pathname.split('/');\n const extension = mimeTypeToExtension(blob.type);\n const filename = parts[parts.length - 1]?.split('.')?.[0] ?? 'asset';\n const filenameWithExtension = `${filename}.${extension}`;\n\n const uploadedAssets = await cesdk.unstable_upload(\n new File([blob], filenameWithExtension, { type: blob.type }),\n () => {\n // TODO Delegate process to UI component\n }\n );\n\n const url = uploadedAssets.meta?.uri;\n if (url == null) {\n throw new Error('Could not upload processed fill');\n }\n return url;\n}\n\n/**\n * Returns the file extension for a given mime type.\n */\nexport function mimeTypeToExtension(mimeType: string): string {\n const extensions: Record<string, string> = {\n 'image/png': 'png',\n 'image/jpeg': 'jpg',\n 'image/webp': 'webp',\n 'image/gif': 'gif',\n 'image/svg+xml': 'svg'\n };\n return extensions[mimeType] ?? 'png';\n}\n\nexport async function fetchImageBlob(uri: string): Promise<Blob> {\n return fetch(uri).then((response) => response.blob());\n}\n\n/**\n * Converts a buffer URI to a object url.\n */\nexport async function bufferURIToObjectURL(\n uri: string,\n engine: CreativeEngine\n): Promise<string> {\n if (uri.startsWith('buffer:')) {\n const mimeType = await engine.editor.getMimeType(uri);\n const length = engine.editor.getBufferLength(uri);\n const data = engine.editor.getBufferData(uri, 0, length);\n const blob = new Blob([data], { type: mimeType });\n return URL.createObjectURL(blob);\n } else {\n return uri;\n }\n}\n", "function uuid4() {\n /* eslint-disable no-bitwise */\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n /* eslint-enable no-bitwise */\n });\n}\n\nexport default uuid4;\n", "import { bufferURIToObjectURL } from './upload';\nimport { type CreativeEngine } from '@cesdk/cesdk-js';\n\n/**\n * Get the dimensions of an image from its URL\n *\n * @param url - The URL of the image\n * @returns A promise that resolves to an object containing the width and height of the image\n */\nexport async function getImageDimensionsFromURL(\n url: string,\n engine: CreativeEngine\n): Promise<{ width: number; height: number }> {\n const resolvedUrl = await bufferURIToObjectURL(url, engine);\n return new Promise((resolve, reject) => {\n const img = new Image();\n img.onload = () => {\n resolve({ width: img.width, height: img.height });\n };\n img.onerror = reject;\n img.src = resolvedUrl;\n });\n}\n\n/**\n * Get the URI of an image from a block ID, either the first source of a source set or\n * the image file URI. Will handle buffer URIs and convert them to object URLs.\n */\nexport async function getImageUri(\n blockId: number,\n engine: CreativeEngine,\n options?: { throwErrorIfSvg?: boolean }\n): Promise<string> {\n let uri;\n const fillBlock = engine.block.getFill(blockId);\n const sourceSet = engine.block.getSourceSet(\n fillBlock,\n 'fill/image/sourceSet'\n );\n const [source] = sourceSet;\n if (source == null) {\n uri = engine.block.getString(fillBlock, 'fill/image/imageFileURI');\n if (uri == null) throw new Error('No image source/uri found');\n } else {\n uri = source.uri;\n }\n\n // Check if the image is SVG (not supported)\n if (options?.throwErrorIfSvg) {\n const mimeType = await engine.editor.getMimeType(uri);\n if (mimeType === 'image/svg+xml') {\n throw new Error('SVG images are not supported');\n }\n }\n\n return bufferURIToObjectURL(uri, engine);\n}\n", "/**\n * Checks if a value is defined (not undefined).\n *\n * Helpful to filter out undefined values from an array or collection\n * while keeping the type information intact.\n *\n * ```\n * array.filter(isDefined)\n * ```\n */\nfunction isDefined<T>(value: T | undefined): value is T {\n return value !== undefined;\n}\n\nexport default isDefined;\n", "import formatsIconSprite from './icons/formats';\n\nconst Icons = {\n Formats: formatsIconSprite\n};\n\nexport { Icons };\n\nexport { CustomAssetSource } from './assetSources/CustomAssetSource';\n\nexport { IndexedDBAssetSource } from './assetSources/IndexedDBAssetSource';\n\nexport { AggregatedAssetSource } from './assetSources/AggregatedAssetSource';\n\nexport { default as Metadata } from './metadata/Metadata';\n\nexport { default as FillProcessingMetadata } from './metadata/FillProcessingMetadata';\n\nexport { default as fillProcessing } from './processing/fillProcessing';\n\nexport { default as initializeFillProcessing } from './processing/initializeFillProcessing';\n\nexport { default as registerFillProcessingComponents } from './processing/registerFillProcessingComponents';\n\nexport { type Optional } from './types/Optional';\n\nexport {\n type Location,\n type UserInterfaceConfiguration\n} from './types/UserInterfaceConfiguration';\n\nexport { hexToRgba, isValidHexColor, rgbaToHex } from './utils/colors';\n\nexport {\n uploadBlob,\n fetchImageBlob,\n bufferURIToObjectURL,\n mimeTypeToExtension\n} from './utils/upload';\n\nexport { default as uuid } from './utils/uuid';\n\nexport { getImageDimensionsFromURL, getImageUri } from './utils/images';\n\nexport { default as isDefined } from './utils/isDefined';\n", "import CreativeEditorSDK, { AssetResult } from '@cesdk/cesdk-js';\nimport { RenderCustomProperty } from '../generation/provider';\nimport { CustomAssetSource, isDefined } from '@imgly/plugin-utils';\nimport { SelectValue } from '@imgly/plugin-utils/dist/assetSources/CustomAssetSource';\n\ntype StyleSelectionPayload = {\n onSelect: (asset: AssetResult) => Promise<void>;\n};\n\ntype Style = {\n id: 'none' | (string & {});\n label: string;\n prompt: string;\n thumbUri: string;\n};\n\n/**\n * Provides render function for a style transfer property that allows\n * to change a style (of an image) from a library.\n *\n * The style will be appended to the prompt property, so the model does\n * not need to support style transfer directly.\n *\n * By default this expects the property key to be `style`. This can be changed with the option\n * `propertyKey`.\n */\nfunction renderStyleTransferProperty(\n providerId: string,\n options: {\n cesdk?: CreativeEditorSDK;\n /**\n * Base URL used for the UI assets used in the plugin.\n */\n baseURL?: string;\n\n /**\n * What property key to use for the style property.\n */\n propertyKey?: string;\n\n /**\n * What property key to use for the prompt property.\n */\n propertyKeyForPrompt?: string;\n\n /**\n * Override the default styles\n */\n styles?: Style[] | ((defaultStyles: Style[]) => Style[]);\n\n /**\n * Overrides the default i18n translations for the prompt input.\n */\n i18n?: {\n prompt?: {\n inputLabel?: string;\n placeholder?: string;\n };\n };\n }\n): RenderCustomProperty {\n const { cesdk } = options;\n if (cesdk == null) return {};\n\n const propertyKey = options.propertyKey ?? 'style';\n const panelIdForStyleSelection = getStyleSelectionPanelId(providerId);\n\n cesdk.i18n.setTranslations({\n en: {\n [`panel.${panelIdForStyleSelection}`]: 'Select Style',\n [`${providerId}.${propertyKey}`]: 'Style'\n }\n });\n\n const defaultStyles = getDefaultStyles({\n baseURL:\n options.baseURL ??\n 'https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/gpt-image-1/',\n includeNone: true\n });\n let styles = defaultStyles;\n if (options.styles != null) {\n if (Array.isArray(options.styles)) {\n styles = options.styles;\n } else if (typeof options.styles === 'function') {\n styles = options.styles(defaultStyles);\n }\n }\n const styleAssetSource = createStyleAssetSource({\n cesdk,\n providerId,\n styles\n });\n const styleAssetSourceId = styleAssetSource.id;\n addStyleAssetSource(styleAssetSource, { cesdk });\n\n createPanels({\n providerId,\n cesdk,\n panelId: panelIdForStyleSelection,\n entryId: styleAssetSourceId\n });\n\n const customProperties: RenderCustomProperty = {\n [options.propertyKeyForPrompt ?? 'prompt']: (context, property) => {\n const promptState = context.state<string>('prompt', '');\n context.builder.TextArea(`${property.id}`, {\n inputLabel:\n options.i18n?.prompt?.inputLabel ??\n options.propertyKeyForPrompt ??\n 'prompt',\n placeholder: options.i18n?.prompt?.placeholder,\n ...promptState\n });\n\n return () => {\n const [activeAssetId] = styleAssetSource.getActiveAssetIds();\n const asset = styleAssetSource.getAsset(activeAssetId);\n return {\n id: property.id,\n type: 'string',\n value:\n asset?.meta?.prompt == null\n ? promptState.value\n : `${promptState.value}; ${asset.meta.prompt}`\n };\n };\n },\n [propertyKey]: (context, property) => {\n const { builder, state } = context;\n\n if (styles.length > 0) {\n const styleState = state<{\n id: string;\n label: string;\n }>('style', styles[0]);\n\n builder.Button(`${property.id}`, {\n inputLabel: `${providerId}.${property.id}`,\n icon: '@imgly/Appearance',\n isDisabled: styles.length === 0,\n trailingIcon: '@imgly/ChevronRight',\n label: styleState.value.label,\n labelAlignment: 'left',\n onClick: () => {\n const payload: StyleSelectionPayload = {\n onSelect: async (asset) => {\n styleAssetSource.clearActiveAssets();\n styleAssetSource.setAssetActive(asset.id);\n styleState.setValue({\n id: asset.id,\n label: asset.label ?? asset.id\n });\n cesdk.ui.closePanel(panelIdForStyleSelection);\n }\n };\n\n cesdk.ui.openPanel(panelIdForStyleSelection, {\n payload\n });\n }\n });\n return () => {\n return {\n id: property.id,\n type: 'string',\n value: styleState.value.id\n };\n };\n }\n\n return () => {\n return {\n id: property.id,\n type: 'string',\n value: 'none'\n };\n };\n }\n };\n\n return customProperties;\n}\n\nfunction createPanels(options: {\n providerId: string;\n panelId: string;\n entryId: string;\n cesdk?: CreativeEditorSDK;\n}) {\n const { providerId, cesdk, panelId, entryId } = options;\n if (cesdk == null) return;\n\n cesdk.ui.registerPanel<{\n onSelect: (assetResult: AssetResult) => void;\n }>(panelId, ({ builder, payload }) => {\n if (payload?.onSelect == null) {\n builder.Section(`${providerId}.error`, {\n children: () => {\n builder.Text('error', {\n content:\n 'No onSelect function provided for the style selection panel.'\n });\n }\n });\n }\n builder.Library(`${providerId}.library.image`, {\n entries: [entryId],\n onSelect: async (asset) => {\n payload?.onSelect?.(asset);\n }\n });\n });\n}\n\nfunction getStyleSelectionPanelId(providerId: string) {\n return `ly.img.ai/${providerId}.styleSelection`;\n}\n\nconst STYLES: Omit<Style, 'thumbUri'>[] = [\n {\n id: 'none',\n label: 'None',\n prompt: ''\n },\n {\n id: 'anime-celshaded',\n label: 'Anime',\n prompt:\n 'anime cel\u2011shaded, bright pastel palette, expressive eyes, clean line art '\n },\n {\n id: 'cyberpunk-neon',\n label: 'Cyberpunk',\n prompt:\n 'cyberpunk cityscape, glowing neon signage, reflective puddles, dark atmosphere'\n },\n {\n id: 'kodak-portra-400',\n label: 'Kodak 400',\n prompt:\n 'shot on Kodak Portra 400, soft grain, golden\u2011hour warmth, 35 mm photo'\n },\n {\n id: 'watercolor-storybook',\n label: 'Watercolor',\n prompt: 'loose watercolor washes, gentle gradients, dreamy storybook feel'\n },\n {\n id: 'dark-fantasy-realism',\n label: 'Dark Fantasy',\n prompt:\n 'dark fantasy realm, moody chiaroscuro lighting, hyper\u2011real textures'\n },\n {\n id: 'vaporwave-retrofuturism',\n label: 'Vaporwave',\n prompt:\n 'retro\u2011futuristic vaporwave, pastel sunset gradient, chrome text, VHS scanlines'\n },\n {\n id: 'minimal-vector-flat',\n label: 'Vector Flat',\n prompt:\n 'minimalist flat vector illustration, bold geometry, two\u2011tone palette'\n },\n {\n id: 'pixarstyle-3d-render',\n label: '3D Animation',\n prompt:\n 'Pixar\u2011style 3D render, oversized eyes, subtle subsurface scattering, cinematic lighting'\n },\n {\n id: 'ukiyoe-woodblock',\n label: 'Ukiyo\u2011e',\n prompt:\n 'ukiyo\u2011e woodblock print, Edo\u2011period style, visible washi texture, limited color ink'\n },\n {\n id: 'surreal-dreamscape',\n label: 'Surreal',\n prompt:\n 'surreal dreamscape, floating objects, impossible architecture, vivid clouds'\n },\n {\n id: 'steampunk-victorian',\n label: 'Steampunk',\n prompt:\n 'Victorian steampunk world, ornate brass gears, leather attire, atmospheric fog'\n },\n {\n id: 'nightstreet-photo-bokeh',\n label: 'Night Bokeh',\n prompt:\n 'night\u2011time street shot, large aperture bokeh lights, candid urban mood'\n },\n {\n id: 'comicbook-pop-art',\n label: 'Pop Art',\n prompt:\n 'classic comic\u2011book panel, halftone shading, exaggerated action lines, CMYK pop colors'\n }\n];\n\nfunction getDefaultStyles(options: {\n baseURL: string;\n includeNone?: boolean;\n}): Style[] {\n return STYLES.map((style) => {\n if (style.id === 'none') {\n if (!options.includeNone) {\n return undefined;\n }\n return {\n ...style,\n thumbUri: `${options.baseURL}/thumbnails/None.svg`\n };\n }\n return {\n ...style,\n thumbUri: `${options.baseURL}/thumbnails/${style.id}.jpeg`\n };\n }).filter(isDefined);\n}\n\nconst createStyleAssetSource = (options: {\n cesdk: CreativeEditorSDK;\n providerId: string;\n styles: Style[];\n}) => {\n const styleValues: SelectValue[] = options.styles.map((style) => {\n return {\n ...style,\n meta: { prompt: style.prompt }\n };\n });\n\n const allSourceIds = options.cesdk.engine.asset.findAllSources();\n let assetSourceId = `${options.providerId}/styles`;\n while (allSourceIds.includes(assetSourceId)) {\n assetSourceId += `-${Math.random().toString(36).substring(2, 5)}`;\n }\n const styleAssetSource = new CustomAssetSource(assetSourceId, styleValues);\n\n const defaultStyle = options.styles[0];\n styleAssetSource.setAssetActive(defaultStyle.id);\n\n return styleAssetSource;\n};\n\nconst addStyleAssetSource = (\n styleAssetSource: CustomAssetSource,\n options: {\n cesdk: CreativeEditorSDK;\n }\n) => {\n options.cesdk.engine.asset.addSource(styleAssetSource);\n options.cesdk.ui.addAssetLibraryEntry({\n id: styleAssetSource.id,\n sourceIds: [styleAssetSource.id],\n gridItemHeight: 'square',\n gridBackgroundType: 'cover',\n cardLabel: ({ label }) => label,\n cardLabelPosition: () => 'below'\n });\n};\n\nexport default renderStyleTransferProperty;\n", "import { type OpenAPIV3 } from 'openapi-types';\n\n/**\n * Resolves a JSON reference path within a document\n * @param document The OpenAPI document\n * @param refPath The reference path (e.g. \"#/components/schemas/MySchema\")\n * @returns The resolved object from the document\n */\nexport function resolveReference(\n document: OpenAPIV3.Document,\n refPath: string\n): unknown {\n // Only handle internal references\n if (!refPath.startsWith('#/')) {\n throw new Error(`External references are not supported: ${refPath}`);\n }\n\n // Remove the leading #/\n const path = refPath.substring(2).split('/');\n let current: any = document;\n\n // Navigate through the path\n for (const segment of path) {\n if (current === undefined || current === null) {\n throw new Error(`Invalid reference path: ${refPath}`);\n }\n current = current[segment];\n }\n\n if (current === undefined) {\n throw new Error(`Reference not found: ${refPath}`);\n }\n\n return current;\n}\n\n/**\n * Recursively dereferences all $ref properties in an object\n * @param document The original document for resolving references\n * @param obj The object to dereference\n * @param visited Set of visited objects to prevent circular references\n * @returns The dereferenced object\n */\nfunction dereferenceObject(\n document: OpenAPIV3.Document,\n obj: any,\n visited = new Set<any>()\n): any {\n // Handle null or undefined\n if (obj === null || obj === undefined) {\n return obj;\n }\n\n // If we've seen this object before, return it to avoid circular references\n if (visited.has(obj)) {\n return obj;\n }\n\n // Add the current object to the visited set\n visited.add(obj);\n\n // Handle $ref\n if (obj.$ref && typeof obj.$ref === 'string') {\n // Get the referenced object\n const referenced = resolveReference(document, obj.$ref);\n // Dereference the referenced object\n const dereferenced = dereferenceObject(document, referenced, visited);\n\n // Merge other properties from the original object\n const result = { ...dereferenced };\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key) && key !== '$ref') {\n result[key] = dereferenceObject(document, obj[key], visited);\n }\n }\n return result;\n }\n\n // Handle arrays\n if (Array.isArray(obj)) {\n return obj.map((item) => dereferenceObject(document, item, visited));\n }\n\n // Handle objects\n if (typeof obj === 'object') {\n const result: any = {};\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n result[key] = dereferenceObject(document, obj[key], visited);\n }\n }\n return result;\n }\n\n // Return primitives as is\n return obj;\n}\n\n/**\n * Dereferences all $ref properties in an OpenAPI document\n * @param document The OpenAPI document to dereference\n * @returns A new document with all references resolved\n */\nexport default function dereferenceDocument(\n document: OpenAPIV3.Document\n): OpenAPIV3.Document {\n return dereferenceObject(document, { ...document }) as OpenAPIV3.Document;\n}\n", "import { OpenAPIV3 } from 'openapi-types';\n\n/**\n * Checks if an unknown object is an OpenAPI schema (first level only)\n *\n * @param obj - The object to check (potentially undefined)\n * @param debug - If true, log the reason when validation fails\n * @returns A boolean indicating whether the object is an OpenAPI schema\n */\nexport function isOpenAPISchema(\n obj: unknown,\n debug: boolean = false\n): obj is OpenAPIV3.SchemaObject {\n // Helper function to log debug messages and return false\n const fail = (reason: string): false => {\n if (debug) {\n // eslint-disable-next-line no-console\n console.log(`OpenAPI Schema validation failed: ${reason}`);\n }\n return false;\n };\n\n // Check if obj is an object and not null\n if (typeof obj !== 'object' || obj === null) {\n return fail(\n `Input is ${obj === null ? 'null' : typeof obj}, not an object`\n );\n }\n\n const schema = obj as Record<string, any>;\n\n // Basic property validation - most schemas have at least one of these properties\n const hasSchemaTypeProperties =\n typeof schema.type === 'string' ||\n Array.isArray(schema.enum) ||\n typeof schema.properties === 'object' ||\n typeof schema.items === 'object' ||\n typeof schema.allOf === 'object' ||\n typeof schema.anyOf === 'object' ||\n typeof schema.oneOf === 'object' ||\n typeof schema.not === 'object';\n\n if (!hasSchemaTypeProperties) {\n return fail(\n 'Missing required schema-defining properties (type, enum, properties, items, allOf, anyOf, oneOf, not)'\n );\n }\n\n // If it has a type, validate it's one of the allowed OpenAPI schema types\n if (schema.type !== undefined) {\n const validTypes = [\n 'string',\n 'number',\n 'integer',\n 'boolean',\n 'array',\n 'object',\n 'null'\n ];\n\n // Type can be a string or an array of strings\n if (typeof schema.type === 'string') {\n if (!validTypes.includes(schema.type)) {\n return fail(\n `Invalid type: ${schema.type}. Must be one of ${validTypes.join(\n ', '\n )}`\n );\n }\n } else if (Array.isArray(schema.type)) {\n for (const type of schema.type) {\n if (typeof type !== 'string' || !validTypes.includes(type)) {\n return fail(\n `Array of types contains invalid value: ${type}. Must be one of ${validTypes.join(\n ', '\n )}`\n );\n }\n }\n } else {\n return fail(\n `Type must be a string or array of strings, got ${typeof schema.type}`\n );\n }\n }\n\n // If it has items (for array type), validate that items is an object (without recursion)\n if (schema.items !== undefined) {\n if (typeof schema.items !== 'object' || schema.items === null) {\n return fail(\n `Items must be an object, got ${\n schema.items === null ? 'null' : typeof schema.items\n }`\n );\n }\n }\n\n // If it has properties (for object type), validate that properties is an object (without recursion)\n if (schema.properties !== undefined) {\n if (typeof schema.properties !== 'object' || schema.properties === null) {\n return fail(\n `Properties must be an object, got ${\n schema.properties === null ? 'null' : typeof schema.properties\n }`\n );\n }\n }\n\n // Check if advanced schema constructs are valid (without recursion)\n const schemaArrays = ['allOf', 'anyOf', 'oneOf'];\n for (const arrayType of schemaArrays) {\n if (schema[arrayType] !== undefined) {\n if (!Array.isArray(schema[arrayType])) {\n return fail(\n `${arrayType} must be an array, got ${typeof schema[arrayType]}`\n );\n }\n\n // Just check that each item is an object (without recursion)\n for (let i = 0; i < schema[arrayType].length; i++) {\n const subSchema = schema[arrayType][i];\n if (typeof subSchema !== 'object' || subSchema === null) {\n return fail(\n `Item ${i} in ${arrayType} must be an object, got ${\n subSchema === null ? 'null' : typeof subSchema\n }`\n );\n }\n }\n }\n }\n\n // Check if 'not' is an object\n if (schema.not !== undefined) {\n if (typeof schema.not !== 'object' || schema.not === null) {\n return fail(\n `'not' must be an object, got ${\n schema.not === null ? 'null' : typeof schema.not\n }`\n );\n }\n }\n\n // If we have additionalProperties, make sure it's a boolean or an object\n if (schema.additionalProperties !== undefined) {\n if (\n typeof schema.additionalProperties !== 'boolean' &&\n (typeof schema.additionalProperties !== 'object' ||\n schema.additionalProperties === null)\n ) {\n return fail(\n `additionalProperties must be a boolean or an object, got ${\n schema.additionalProperties === null\n ? 'null'\n : typeof schema.additionalProperties\n }`\n );\n }\n }\n\n // Check basic format if present (for string type)\n if (schema.format !== undefined && typeof schema.format !== 'string') {\n return fail(`format must be a string, got ${typeof schema.format}`);\n }\n\n // Check number constraints\n const numberConstraints = [\n 'minimum',\n 'maximum',\n 'exclusiveMinimum',\n 'exclusiveMaximum',\n 'multipleOf'\n ];\n for (const constraint of numberConstraints) {\n if (\n schema[constraint] !== undefined &&\n typeof schema[constraint] !== 'number'\n ) {\n return fail(\n `${constraint} must be a number, got ${typeof schema[constraint]}`\n );\n }\n }\n\n // Check string constraints\n if (\n schema.minLength !== undefined &&\n (typeof schema.minLength !== 'number' || schema.minLength < 0)\n ) {\n return fail(\n `minLength must be a non-negative number, got ${\n typeof schema.minLength === 'number'\n ? schema.minLength\n : typeof schema.minLength\n }`\n );\n }\n if (\n schema.maxLength !== undefined &&\n (typeof schema.maxLength !== 'number' || schema.maxLength < 0)\n ) {\n return fail(\n `maxLength must be a non-negative number, got ${\n typeof schema.maxLength === 'number'\n ? schema.maxLength\n : typeof schema.maxLength\n }`\n );\n }\n if (schema.pattern !== undefined && typeof schema.pattern !== 'string') {\n return fail(`pattern must be a string, got ${typeof schema.pattern}`);\n }\n\n // Check array constraints\n if (\n schema.minItems !== undefined &&\n (typeof schema.minItems !== 'number' || schema.minItems < 0)\n ) {\n return fail(\n `minItems must be a non-negative number, got ${\n typeof schema.minItems === 'number'\n ? schema.minItems\n : typeof schema.minItems\n }`\n );\n }\n if (\n schema.maxItems !== undefined &&\n (typeof schema.maxItems !== 'number' || schema.maxItems < 0)\n ) {\n return fail(\n `maxItems must be a non-negative number, got ${\n typeof schema.maxItems === 'number'\n ? schema.maxItems\n : typeof schema.maxItems\n }`\n );\n }\n if (\n schema.uniqueItems !== undefined &&\n typeof schema.uniqueItems !== 'boolean'\n ) {\n return fail(\n `uniqueItems must be a boolean, got ${typeof schema.uniqueItems}`\n );\n }\n\n // Check object constraints\n if (\n schema.minProperties !== undefined &&\n (typeof schema.minProperties !== 'number' || schema.minProperties < 0)\n ) {\n return fail(\n `minProperties must be a non-negative number, got ${\n typeof schema.minProperties === 'number'\n ? schema.minProperties\n : typeof schema.minProperties\n }`\n );\n }\n if (\n schema.maxProperties !== undefined &&\n (typeof schema.maxProperties !== 'number' || schema.maxProperties < 0)\n ) {\n return fail(\n `maxProperties must be a non-negative number, got ${\n typeof schema.maxProperties === 'number'\n ? schema.maxProperties\n : typeof schema.maxProperties\n }`\n );\n }\n if (schema.required !== undefined) {\n if (!Array.isArray(schema.required)) {\n return fail(`required must be an array, got ${typeof schema.required}`);\n }\n for (let i = 0; i < schema.required.length; i++) {\n const prop = schema.required[i];\n if (typeof prop !== 'string') {\n return fail(\n `Item ${i} in required array must be a string, got ${typeof prop}`\n );\n }\n }\n }\n\n // It has passed all the first-level checks\n return true;\n}\n", "import { OpenAPIV3 } from 'openapi-types';\nimport { OutputKind, PanelInputSchema } from '../provider';\nimport { Property } from './types';\n\nfunction getProperties<K extends OutputKind, I>(\n inputSchema: OpenAPIV3.SchemaObject,\n panelInput: PanelInputSchema<K, I>\n): Property[] {\n if (inputSchema.properties == null) {\n throw new Error('Input schema must have properties');\n }\n const propertiesFromSchema = inputSchema.properties;\n const properties: Property[] = [];\n\n const order = getOrder(inputSchema, panelInput);\n order.forEach((propertyKey) => {\n const id = propertyKey;\n const schema =\n (propertiesFromSchema[propertyKey] as OpenAPIV3.SchemaObject) ??\n undefined;\n properties.push({ id, schema });\n });\n\n return properties;\n}\n\nfunction getOrder<K extends OutputKind, I>(\n inputSchema: OpenAPIV3.SchemaObject,\n panelInput: PanelInputSchema<K, I>\n): string[] {\n const panelInputOrder = panelInput.order;\n if (panelInputOrder != null && Array.isArray(panelInputOrder)) {\n return panelInputOrder;\n }\n\n if (inputSchema.properties == null) {\n throw new Error('Input schema must have properties');\n }\n const propertiesFromSchema = inputSchema.properties;\n const orderFromKeys = Object.keys(propertiesFromSchema);\n const orderFromExtensionKeyword = getOrderFromExtensionKeyword(\n inputSchema,\n panelInput\n );\n\n let order = orderFromExtensionKeyword ?? orderFromKeys;\n\n if (panelInputOrder != null && typeof panelInputOrder === 'function') {\n order = panelInputOrder(order);\n }\n\n // Return order with no duplicates\n return [...new Set(order)];\n}\n\n/**\n * Get the order from an extension keyword in the input schema (e.g. x-order) if it exists.\n */\nfunction getOrderFromExtensionKeyword<K extends OutputKind, I>(\n inputSchema: OpenAPIV3.SchemaObject,\n panelInput: PanelInputSchema<K, I>\n): string[] | undefined {\n if (panelInput.orderExtensionKeyword == null) {\n return undefined;\n }\n\n if (\n typeof panelInput.orderExtensionKeyword !== 'string' &&\n !Array.isArray(panelInput.orderExtensionKeyword)\n ) {\n throw new Error(\n 'orderExtensionKeyword must be a string or an array of strings'\n );\n }\n const orderExtensionKeywords =\n typeof panelInput.orderExtensionKeyword === 'string'\n ? [panelInput.orderExtensionKeyword]\n : panelInput.orderExtensionKeyword;\n\n const orderExtensionKeyword = orderExtensionKeywords.find(\n (extensionKeyword) => {\n return extensionKeyword in inputSchema;\n }\n );\n\n if (orderExtensionKeyword == null) {\n return undefined;\n }\n const order =\n // @ts-ignore\n inputSchema[orderExtensionKeyword] as string[];\n\n return order;\n}\n\nexport default getProperties;\n", "import CreativeEditorSDK, { AssetResult } from '@cesdk/cesdk-js';\nimport { GenerationResult, Output } from './generation/provider';\n\nexport const AI_PANEL_ID_PREFIX = 'ly.img.ai';\n\nconst TEMP_ASSET_SOURCE_ID = 'ly.img.ai/temp';\n\n/**\n * Adding asset to the scene.\n *\n * NOTE: Will use a temporary asset source so that\n * our asset source middleware trigger. This is necessary since there is\n * a lot of extra logic in the video middlewares regarding trim, position etc.\n *\n * These will only trigger via an asset source, not by calling\n * `defaultApplyAsset` directly.\n */\nexport async function addAssetToScene(\n cesdk: CreativeEditorSDK,\n assetResult: AssetResult\n) {\n if (!cesdk.engine.asset.findAllSources().includes(TEMP_ASSET_SOURCE_ID)) {\n cesdk.engine.asset.addLocalSource(TEMP_ASSET_SOURCE_ID);\n }\n\n return cesdk.engine.asset.apply(TEMP_ASSET_SOURCE_ID, assetResult);\n}\n\n/**\n * Returns a consistent panel ID for a provider ID\n */\nexport function getPanelId(providerId: string): string {\n return `${AI_PANEL_ID_PREFIX}/${providerId}`;\n}\n\nexport default getPanelId;\n/**\n * Extracts a readable error message from an unknown error\n *\n * @param error The error caught in a try/catch block\n * @param fallbackMessage Optional fallback message if error is not an Error object\n * @returns A string representation of the error\n */\nexport function extractErrorMessage(\n error: unknown,\n fallbackMessage = 'We encountered an unknown error while generating the asset. Please try again.'\n): string {\n if (error === null) {\n return fallbackMessage;\n }\n\n if (error instanceof Error) {\n return error.message;\n }\n\n if (typeof error === 'object') {\n // Try to get message property if it exists\n const errorObj = error as Record<string, unknown>;\n if ('message' in errorObj && typeof errorObj.message === 'string') {\n return errorObj.message;\n }\n if ('cause' in errorObj && typeof errorObj.cause === 'string') {\n return errorObj.cause;\n }\n\n /*\n * Elevenlabs for instance uses the following structure for errors:\n * {\n * \"detail\": {\n * \"status\": \"error_code\",\n * \"message\": \"Explanation of the rate limit issue.\"\n * }\n * }\n */\n if (\n 'detail' in errorObj &&\n typeof errorObj.detail === 'object' &&\n errorObj.detail !== null &&\n 'message' in errorObj.detail &&\n typeof errorObj.detail.message === 'string'\n ) {\n return errorObj.detail.message;\n }\n\n /*\n * Used by e.g. Anthropic\n */\n if (\n 'error' in errorObj &&\n typeof errorObj.error === 'object' &&\n errorObj.error !== null &&\n 'message' in errorObj.error &&\n typeof errorObj.error.message === 'string'\n ) {\n return errorObj.error.message;\n }\n\n return fallbackMessage;\n }\n\n if (typeof error === 'string') {\n return error;\n }\n\n // For any other type, convert to string\n return String(error) || fallbackMessage;\n}\n\n/**\n * Generates a random UUID v4\n */\nexport function uuid4() {\n /* eslint-disable no-bitwise */\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n /* eslint-enable no-bitwise */\n });\n}\n\n/**\n * Gets the duration of a video from a URL\n * @param url - The URL of the video\n * @returns A promise that resolves to the duration of the video in seconds\n */\nexport function getDurationForVideo(url: string): Promise<number> {\n return new Promise((resolve, reject) => {\n try {\n const video = document.createElement('video');\n video.style.display = 'none';\n\n // Set up event handlers\n video.addEventListener('loadedmetadata', () => {\n if (video.duration === Infinity) {\n // Some videos might initially report Infinity\n video.currentTime = 1e101;\n // Wait for currentTime to update\n setTimeout(() => {\n video.currentTime = 0;\n resolve(video.duration);\n document.body.removeChild(video);\n }, 50);\n } else {\n resolve(video.duration);\n document.body.removeChild(video);\n }\n });\n\n video.addEventListener('error', () => {\n document.body.removeChild(video);\n reject(new Error(`Failed to load video from ${url}`));\n });\n\n // Set source and begin loading\n video.src = url;\n document.body.appendChild(video);\n } catch (error) {\n reject(error);\n }\n });\n}\n\n/**\n * Gets a thumbnail image from a video URL\n * @param url - The URL of the video\n * @param seekTime - Time in seconds to capture the thumbnail (default: 0)\n * @param format - Image format for the thumbnail (default: 'image/jpeg')\n * @param quality - Image quality between 0 and 1 (default: 0.8)\n * @returns A promise that resolves to the thumbnail data URL\n */\nexport function getThumbnailForVideo(\n url: string,\n seekTime = 0,\n format = 'image/jpeg',\n quality = 0.8\n): Promise<string> {\n return new Promise((resolve, reject) => {\n try {\n const video = document.createElement('video');\n // Set crossOrigin to anonymous to prevent tainted canvas issues\n video.crossOrigin = 'anonymous';\n video.style.display = 'none';\n\n // Set up event handlers\n video.addEventListener('loadedmetadata', () => {\n // Seek to the specified time\n video.currentTime = Math.min(seekTime, video.duration);\n\n video.addEventListener(\n 'seeked',\n () => {\n // Create a canvas to draw the video frame\n const canvas = document.createElement('canvas');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n\n // Draw the video frame to the canvas\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n document.body.removeChild(video);\n reject(new Error('Failed to create canvas context'));\n return;\n }\n\n ctx.drawImage(video, 0, 0, canvas.width, canvas.height);\n\n try {\n // Convert canvas to data URL\n const dataURL = canvas.toDataURL(format, quality);\n // Clean up\n document.body.removeChild(video);\n resolve(dataURL);\n } catch (e) {\n document.body.removeChild(video);\n reject(\n new Error(\n `Failed to create thumbnail: ${\n e instanceof Error ? e.message : String(e)\n }`\n )\n );\n }\n },\n { once: true }\n );\n });\n\n video.addEventListener('error', () => {\n document.body.removeChild(video);\n reject(new Error(`Failed to load video from ${url}`));\n });\n\n // Set source and begin loading\n video.src = url;\n document.body.appendChild(video);\n } catch (error) {\n reject(error);\n }\n });\n}\n\n/**\n * Converts an ID string to a human-readable label\n * @param id - The ID string to convert\n * @returns A human-readable label derived from the ID\n *\n * Examples:\n * - snake_case_id \u2192 Snake Case Id\n * - kebab-case-id \u2192 Kebab Case Id\n * - camelCaseId \u2192 Camel Case Id\n * - PascalCaseId \u2192 Pascal Case Id\n */\nexport function getLabelFromId(id: string): string {\n if (!id) return '';\n\n // Handle snake_case, kebab-case, camelCase, and PascalCase\n return (\n id\n // Replace underscores and hyphens with spaces (for snake_case and kebab-case)\n .replace(/[_-]/g, ' ')\n // Add spaces before uppercase letters (for camelCase and PascalCase)\n .replace(/([A-Z])/g, ' $1')\n // Trim any extra spaces and ensure first letter is capitalized\n .trim()\n .split(' ')\n .filter((word) => word.length > 0) // Remove empty strings from multiple spaces\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(' ')\n );\n}\n\n/**\n * Type guard to check if a value is an AsyncGenerator rather than a Promise\n *\n * @param value - Value of type Promise<O> | AsyncGenerator<O, C>\n * @returns Boolean indicating if the value is an AsyncGenerator\n */\nexport function isAsyncGenerator<O extends Output, C>(\n value: GenerationResult<O, C>\n): value is AsyncGenerator<O, C> {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'next' in value &&\n 'return' in value &&\n 'throw' in value &&\n typeof value.next === 'function' &&\n typeof value.return === 'function' &&\n typeof value.throw === 'function' &&\n Symbol.asyncIterator in value &&\n typeof value[Symbol.asyncIterator] === 'function'\n );\n}\n\nexport function isAbortError(error: unknown): error is Error {\n return error instanceof Error && error.name === 'AbortError';\n}\n", "/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { BuilderRenderFunctionContext } from '@cesdk/cesdk-js';\nimport {\n EnumValue,\n ExtensionImglyBuilder,\n GetPropertyInput,\n Property,\n PropertyInput\n} from './types';\nimport Provider, { Output, OutputKind, PanelInputSchema } from '../provider';\nimport { InitProviderConfiguration, UIOptions } from '../types';\nimport { OpenAPIV3 } from 'openapi-types';\nimport getProperties from './getProperties';\nimport { getLabelFromId } from '../../utils';\n\nfunction renderProperty<K extends OutputKind, I, O extends Output>(\n context: BuilderRenderFunctionContext<any>,\n property: Property,\n provider: Provider<K, I, O>,\n panelInput: PanelInputSchema<K, I>,\n options: UIOptions,\n config: InitProviderConfiguration\n): GetPropertyInput | undefined {\n if (property.schema == null) {\n if (\n panelInput.renderCustomProperty != null &&\n panelInput.renderCustomProperty[property.id] != null\n ) {\n return panelInput.renderCustomProperty[property.id](context, property);\n } else {\n return undefined;\n }\n }\n const propertyWithSchema: Required<Property> = property as Required<Property>;\n const type = property.schema.type;\n\n if (\n panelInput.renderCustomProperty != null &&\n panelInput.renderCustomProperty[property.id] != null\n ) {\n return panelInput.renderCustomProperty[property.id](context, property);\n }\n\n switch (type) {\n case 'string': {\n if (property.schema.enum != null) {\n return renderEnumProperty(\n context,\n propertyWithSchema,\n provider,\n panelInput,\n options,\n config\n );\n } else {\n return renderStringProperty(\n context,\n propertyWithSchema,\n provider,\n panelInput,\n options,\n config\n );\n }\n }\n\n case 'boolean': {\n return renderBooleanProperty(\n context,\n propertyWithSchema,\n provider,\n panelInput,\n options,\n config\n );\n }\n\n case 'number':\n case 'integer': {\n return renderIntegerProperty(\n context,\n propertyWithSchema,\n provider,\n panelInput,\n options,\n config\n );\n }\n\n case 'object': {\n return renderObjectProperty(\n context,\n propertyWithSchema,\n provider,\n panelInput,\n options,\n config\n );\n }\n\n case 'array': {\n // not supported yet\n break;\n }\n\n case undefined: {\n if (\n property.schema.anyOf != null &&\n Array.isArray(property.schema.anyOf)\n ) {\n return renderAnyOfProperty(\n context,\n propertyWithSchema,\n provider,\n panelInput,\n options,\n config\n );\n }\n break;\n }\n\n default: {\n // eslint-disable-next-line no-console\n console.error(`Unsupported property type: ${type}`);\n }\n }\n}\n\nfunction renderObjectProperty<K extends OutputKind, I, O extends Output>(\n context: BuilderRenderFunctionContext<any>,\n property: Required<Property>,\n provider: Provider<K, I, O>,\n panelInput: PanelInputSchema<K, I>,\n options: UIOptions,\n config: InitProviderConfiguration\n): GetPropertyInput {\n const properties = getProperties(property.schema ?? {}, panelInput);\n\n const childInputs = properties.reduce((acc, childProperty) => {\n const getInput = renderProperty(\n context,\n childProperty,\n provider,\n panelInput,\n options,\n config\n );\n if (getInput != null) {\n acc[childProperty.id] = getInput();\n }\n return acc;\n }, {} as Record<string, PropertyInput>);\n\n return () => ({\n id: property.id,\n type: 'object',\n value: childInputs\n });\n}\n\nfunction renderStringProperty<K extends OutputKind, I, O extends Output>(\n context: BuilderRenderFunctionContext<any>,\n property: Required<Property>,\n provider: Provider<K, I, O>,\n panelInput: PanelInputSchema<K, I>,\n options: UIOptions,\n config: InitProviderConfiguration\n): GetPropertyInput {\n const {\n builder,\n experimental: { global }\n } = context;\n const { id: propertyId } = property;\n\n const id = `${provider.id}.${propertyId}`;\n const inputLabel = property.schema.title ?? id;\n\n const propertyState = global(id, property.schema.default ?? '');\n\n const extension = getImglyExtensionBuilder(property.schema);\n const builderComponent =\n extension?.component != null && extension?.component === 'TextArea'\n ? 'TextArea'\n : 'TextInput';\n\n builder[builderComponent](id, {\n inputLabel,\n placeholder: options.i18n?.prompt,\n ...propertyState\n });\n\n return () => ({\n id: property.id,\n type: 'string',\n value: propertyState.value\n });\n}\n\nfunction renderEnumProperty<K extends OutputKind, I, O extends Output>(\n context: BuilderRenderFunctionContext<any>,\n property: Required<Property>,\n provider: Provider<K, I, O>,\n panelInput: PanelInputSchema<K, I>,\n options: UIOptions,\n config: InitProviderConfiguration\n): GetPropertyInput {\n const {\n builder,\n experimental: { global }\n } = context;\n const { id: propertyId } = property;\n\n const id = `${provider.id}.${propertyId}`;\n const inputLabel = property.schema.title ?? id;\n\n const labels: Record<string, string> =\n property.schema.enum != null &&\n 'x-imgly-enum-labels' in property.schema.enum &&\n typeof property.schema.enum['x-imgly-enum-labels'] === 'object'\n ? (property.schema.enum['x-imgly-enum-labels'] as Record<string, string>)\n : 'x-imgly-enum-labels' in property.schema &&\n typeof property.schema['x-imgly-enum-labels'] === 'object'\n ? (property.schema['x-imgly-enum-labels'] as Record<string, string>)\n : {};\n\n const icons: Record<string, string> =\n 'x-imgly-enum-icons' in property.schema &&\n typeof property.schema['x-imgly-enum-icons'] === 'object'\n ? (property.schema['x-imgly-enum-icons'] as Record<string, string>)\n : {};\n\n const values: EnumValue[] = (property.schema.enum ?? []).map((valueId) => ({\n id: valueId,\n label: labels[valueId] ?? getLabelFromId(valueId),\n icon: icons[valueId]\n }));\n const defaultValue =\n property.schema.default != null\n ? values.find((v) => v.id === property.schema.default) ?? values[0]\n : values[0];\n\n const propertyState = global<EnumValue>(id, defaultValue);\n\n builder.Select(id, {\n inputLabel,\n values,\n ...propertyState\n });\n\n return () => ({\n id: property.id,\n type: 'string',\n value: propertyState.value.id\n });\n}\n\nfunction renderBooleanProperty<K extends OutputKind, I, O extends Output>(\n context: BuilderRenderFunctionContext<any>,\n property: Required<Property>,\n provider: Provider<K, I, O>,\n panelInput: PanelInputSchema<K, I>,\n options: UIOptions,\n config: InitProviderConfiguration\n): GetPropertyInput {\n const {\n builder,\n experimental: { global }\n } = context;\n const { id: propertyId } = property;\n\n const id = `${provider.id}.${propertyId}`;\n const inputLabel = property.schema.title ?? id;\n\n const defaultValue = !!property.schema.default;\n const propertyState = global<boolean>(id, defaultValue);\n\n builder.Checkbox(id, {\n inputLabel,\n ...propertyState\n });\n\n return () => ({\n id: property.id,\n type: 'boolean',\n value: propertyState.value\n });\n}\n\nfunction renderIntegerProperty<K extends OutputKind, I, O extends Output>(\n context: BuilderRenderFunctionContext<any>,\n property: Required<Property>,\n provider: Provider<K, I, O>,\n panelInput: PanelInputSchema<K, I>,\n options: UIOptions,\n config: InitProviderConfiguration\n): GetPropertyInput {\n const {\n builder,\n experimental: { global }\n } = context;\n const { id: propertyId } = property;\n\n const id = `${provider.id}.${propertyId}`;\n const inputLabel = property.schema.title ?? id;\n\n const minValue = property.schema.minimum;\n const maxValue = property.schema.maximum;\n\n let defaultValue = property.schema.default;\n if (defaultValue == null) {\n if (minValue != null) {\n defaultValue = minValue;\n } else if (maxValue != null) {\n defaultValue = maxValue;\n } else {\n defaultValue = 0;\n }\n }\n\n const propertyState = global<number>(id, defaultValue);\n\n if (minValue != null && maxValue != null) {\n let step = property.schema.type === 'number' ? 0.1 : 1;\n if (\n 'x-imgly-step' in property.schema &&\n typeof property.schema['x-imgly-step'] === 'number'\n ) {\n step = property.schema['x-imgly-step'];\n }\n\n builder.Slider(id, {\n inputLabel,\n min: minValue,\n max: maxValue,\n step,\n ...propertyState\n });\n } else {\n builder.NumberInput(id, {\n inputLabel,\n min: minValue,\n max: maxValue,\n ...propertyState\n });\n }\n\n return () => ({\n id: property.id,\n type: 'integer',\n value: propertyState.value\n });\n}\n\nfunction renderAnyOfProperty<K extends OutputKind, I, O extends Output>(\n context: BuilderRenderFunctionContext<any>,\n property: Required<Property>,\n provider: Provider<K, I, O>,\n panelInput: PanelInputSchema<K, I>,\n options: UIOptions,\n config: InitProviderConfiguration\n): GetPropertyInput | undefined {\n const {\n builder,\n experimental: { global }\n } = context;\n const { id: propertyId } = property;\n\n const id = `${provider.id}.${propertyId}`;\n const inputLabel = property.schema.title ?? id;\n\n const anyOf = (property.schema.anyOf ?? []) as OpenAPIV3.SchemaObject[];\n\n const values: EnumValue[] = [];\n\n const conditionalRender: Record<string, () => GetPropertyInput> = {};\n const conditionalInputs: Record<string, () => PropertyInput> = {};\n\n anyOf.forEach((anySchema, index) => {\n const label = anySchema.title ?? 'common.custom';\n const schemaId = `${provider.id}.${propertyId}.anyOf[${index}]`;\n\n const labels: Record<string, string> =\n 'x-imgly-enum-labels' in property.schema &&\n typeof property.schema['x-imgly-enum-labels'] === 'object'\n ? (property.schema['x-imgly-enum-labels'] as Record<string, string>)\n : {};\n\n const icons: Record<string, string> =\n 'x-imgly-enum-icons' in property.schema &&\n typeof property.schema['x-imgly-enum-icons'] === 'object'\n ? (property.schema['x-imgly-enum-icons'] as Record<string, string>)\n : {};\n\n if (anySchema.type === 'string') {\n if (anySchema.enum != null) {\n anySchema.enum.forEach((valueId) => {\n values.push({\n id: valueId,\n label: labels[valueId] ?? getLabelFromId(valueId),\n icon: icons[valueId]\n });\n });\n } else {\n conditionalRender[schemaId] = () => {\n return renderStringProperty(\n context,\n { id: schemaId, schema: { ...anySchema, title: label } },\n provider,\n panelInput,\n options,\n config\n );\n };\n\n values.push({\n id: schemaId,\n label: labels[label] ?? label,\n icon: icons[label]\n });\n }\n } else if (anySchema.type === 'boolean') {\n conditionalRender[schemaId] = () => {\n return renderBooleanProperty(\n context,\n { id: schemaId, schema: { ...anySchema, title: label } },\n provider,\n panelInput,\n options,\n config\n );\n };\n\n values.push({\n id: schemaId,\n label: labels[label] ?? label,\n icon: icons[label]\n });\n } else if (anySchema.type === 'integer') {\n conditionalRender[schemaId] = () => {\n return renderIntegerProperty(\n context,\n { id: schemaId, schema: { ...anySchema, title: label } },\n provider,\n panelInput,\n options,\n config\n );\n };\n\n values.push({\n id: schemaId,\n label: labels[label] ?? label,\n icon: icons[label]\n });\n } else if (anySchema.type === 'array') {\n // not supported yet\n } else if (anySchema.type === 'object') {\n conditionalRender[schemaId] = () => {\n return renderObjectProperty(\n context,\n { id: schemaId, schema: { ...anySchema, title: label } },\n provider,\n panelInput,\n options,\n config\n );\n };\n\n values.push({\n id: schemaId,\n label: labels[label] ?? label,\n icon: icons[label]\n });\n }\n });\n\n const defaultValue =\n property.schema.default != null\n ? values.find((value) => value.id === property.schema.default) ??\n values[0]\n : values[0];\n\n const propertyState = global<EnumValue>(id, defaultValue);\n\n builder.Select(id, {\n inputLabel,\n values,\n ...propertyState\n });\n\n if (propertyState.value.id in conditionalRender) {\n const inputs = conditionalRender[propertyState.value.id]();\n conditionalInputs[propertyState.value.id] = inputs;\n }\n\n return () => {\n const conditionalInput = conditionalInputs[propertyState.value.id];\n\n if (conditionalInput != null) {\n return {\n ...conditionalInput(),\n id: property.id\n };\n }\n\n return {\n id: property.id,\n type: 'string',\n value: propertyState.value.id\n };\n };\n}\n\nfunction getImglyExtensionBuilder(\n schema: OpenAPIV3.SchemaObject\n): ExtensionImglyBuilder | undefined {\n if ('x-imgly-builder' in schema) {\n const extension = schema['x-imgly-builder'] as ExtensionImglyBuilder;\n return extension;\n }\n\n return undefined;\n}\n\nexport default renderProperty;\n", "const previewUri =\n 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIzIiBoZWlnaHQ9IjMyMyIgdmlld0JveD0iMCAwIDMyMyAzMjMiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIzMjMiIGhlaWdodD0iMzIzIiBmaWxsPSIjRTlFQkVEIi8+CjxnIG9wYWNpdHk9IjAuMyI+Cjxw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k5IDE4NC4wMDRaIiBmaWxsPSIjOEY4RjhGIi8+CjwvZz4KPC9zdmc+Cg==';\n\nexport default previewUri;\n", "import { type AssetResult } from '@cesdk/cesdk-js';\nimport { type OutputKind, GetBlockInputResult, InputByKind } from './provider';\nimport previewUri from './previewUri';\n\nfunction getAssetResultForPlaceholder<K extends OutputKind>(\n id: string,\n kind: K,\n blockInput: GetBlockInputResult<K>\n): AssetResult {\n switch (kind) {\n case 'image': {\n return getImageAssetResultForPlaceholder(\n id,\n blockInput[kind] as InputByKind['image']\n );\n }\n case 'video': {\n return getVideoAssetResultForPlaceholder(\n id,\n blockInput[kind] as InputByKind['video']\n );\n }\n\n default: {\n throw new Error(\n `Unsupported output kind for creating placeholder block: ${kind}`\n );\n }\n }\n}\n\nfunction getImageAssetResultForPlaceholder(\n id: string,\n input: InputByKind['image']\n): AssetResult {\n const width = input.width;\n const height = input.height;\n return {\n id,\n meta: {\n previewUri,\n fillType: '//ly.img.ubq/fill/image',\n kind: 'image',\n\n width,\n height\n }\n };\n}\n\nfunction getVideoAssetResultForPlaceholder(\n id: string,\n input: InputByKind['video']\n): AssetResult {\n const width = input.width;\n const height = input.height;\n return {\n id,\n label: input.label,\n meta: {\n previewUri,\n mimeType: 'video/mp4',\n kind: 'video',\n fillType: '//ly.img.ubq/fill/video',\n\n duration: input.duration.toString(),\n\n width,\n height\n }\n };\n}\n\nexport default getAssetResultForPlaceholder;\n", "import { type AssetResult } from '@cesdk/cesdk-js';\nimport {\n type OutputKind,\n AudioOutput,\n GetBlockInputResult,\n ImageOutput,\n InputByKind,\n Output,\n VideoOutput\n} from './provider';\nimport { getThumbnailForVideo } from '../utils';\n\nasync function getAssetResultForGenerated<K extends OutputKind>(\n id: string,\n kind: K,\n blockInputs: GetBlockInputResult<K>,\n output: Output\n): Promise<AssetResult> {\n switch (kind) {\n case 'image': {\n if (output.kind !== 'image') {\n throw new Error(\n `Output kind does not match the expected type: ${output.kind} (expected: image)`\n );\n }\n\n return getImageAssetResultForGenerated(\n id,\n blockInputs[kind] as InputByKind['image'],\n output\n );\n }\n\n case 'video': {\n if (output.kind !== 'video') {\n throw new Error(\n `Output kind does not match the expected type: ${output.kind} (expected: video)`\n );\n }\n\n return getVideoAssetResultForGenerated(\n id,\n blockInputs[kind] as InputByKind['video'],\n output\n );\n }\n\n case 'audio': {\n if (output.kind !== 'audio') {\n throw new Error(\n `Output kind does not match the expected type: ${output.kind} (expected: audio)`\n );\n }\n\n return getAudioAssetResultForGenerated(\n id,\n blockInputs[kind] as InputByKind['audio'],\n output\n );\n }\n\n default: {\n throw new Error(\n `Unsupported output kind for creating placeholder block: ${kind}`\n );\n }\n }\n}\n\nfunction getImageAssetResultForGenerated(\n id: string,\n input: InputByKind['image'],\n output: ImageOutput\n): AssetResult {\n const width = input.width;\n const height = input.height;\n return {\n id,\n label: input.label,\n meta: {\n uri: output.url,\n thumbUri: output.url,\n fillType: '//ly.img.ubq/fill/image',\n kind: 'image',\n\n width,\n height\n },\n payload: {\n sourceSet: [\n {\n uri: output.url,\n width,\n height\n }\n ]\n }\n };\n}\n\nasync function getVideoAssetResultForGenerated(\n id: string,\n input: InputByKind['video'],\n output: VideoOutput\n): Promise<AssetResult> {\n const width = input.width;\n const height = input.height;\n\n const thumbUri = await getThumbnailForVideo(output.url, 0);\n\n return {\n id,\n label: input.label,\n meta: {\n uri: output.url,\n thumbUri,\n\n mimeType: 'video/mp4',\n kind: 'video',\n fillType: '//ly.img.ubq/fill/video',\n\n duration: input.duration.toString(),\n\n width,\n height\n }\n };\n}\n\nfunction getAudioAssetResultForGenerated(\n id: string,\n input: InputByKind['audio'],\n output: AudioOutput\n): AssetResult {\n return {\n id,\n label: input.label,\n meta: {\n uri: output.url,\n thumbUri: output.thumbnailUrl,\n blockType: '//ly.img.ubq/audio',\n mimeType: 'audio/x-m4a',\n duration: output.duration.toString()\n }\n };\n}\n\nexport default getAssetResultForGenerated;\n", "import { GenerationOptions, GenerationResult, Output } from '../provider';\n\n/**\n * Result of the generation with a dispose function to clean up\n */\nexport interface DisposableGenerationResult<O extends Output> {\n /**\n * The actual generation result\n */\n result: GenerationResult<O>;\n\n /**\n * Function to dispose/clean up resources created during generation\n * This should be called when the generation is cancelled or completely\n * finished including the confirmation of the generation if applicable.\n */\n dispose: () => Promise<void>;\n}\n\n/**\n * Define the type for middleware functions\n */\nexport type Middleware<I, O extends Output> = (\n input: I,\n options: GenerationOptions & {\n /**\n * The block ids the generation is applied on\n * If this value is undefined, the selected blocks will be used.\n * Setting this value to null will explicitly tell every\n * middleware that no block shall be used.\n */\n blockIds?: number[] | null;\n\n /**\n * Adds a disposer function to this genereation which is called\n * when the generation is cancelled or completely finished\n * including the confirmation of the generation if applicable.\n */\n addDisposer: (dispose: () => Promise<void>) => void;\n },\n next: (input: I, options: GenerationOptions) => Promise<GenerationResult<O>>\n) => Promise<GenerationResult<O>>;\n\nexport function composeMiddlewares<I, O extends Output>(\n middlewares: (Middleware<I, O> | false | undefined | null)[]\n) {\n // Filter out false, undefined, and null middlewares\n const validMiddlewares = middlewares.filter(\n (middleware): middleware is Middleware<I, O> => !!middleware\n );\n // Start with the base handler\n return (\n baseHandler: (\n input: I,\n options: GenerationOptions\n ) => Promise<GenerationResult<O>>\n ) => {\n // We need to build a chain where each step is a function with the signature:\n // (input, options) => Promise<Result>\n\n // The composed function that will be returned\n return async (\n input: I,\n options: GenerationOptions\n ): Promise<DisposableGenerationResult<O>> => {\n // Store disposer functions that will be called when dispose() is called\n const disposers: Array<() => Promise<void>> = [];\n\n // Function to add a disposer\n const addDisposer = (dispose: () => Promise<void>) => {\n disposers.push(dispose);\n };\n\n // Define a function to process each middleware in sequence\n const runMiddleware = async (\n index: number,\n currentInput: I,\n currentOptions: GenerationOptions\n ): Promise<GenerationResult<O>> => {\n // If we've processed all middlewares, call the base handler\n if (index >= validMiddlewares.length) {\n return baseHandler(currentInput, currentOptions);\n }\n\n // Get the current middleware\n const currentMiddleware = validMiddlewares[index];\n\n // Create a next function for this middleware that calls the next middleware in line\n const next = async (\n nextInput: I,\n nextOptions: GenerationOptions\n ): Promise<GenerationResult<O>> => {\n return runMiddleware(index + 1, nextInput, nextOptions);\n };\n\n // Enhanced options with addDisposer\n const enhancedOptions = {\n ...currentOptions,\n addDisposer\n };\n\n // Call the current middleware with the input, enhanced options, and next function\n return currentMiddleware(currentInput, enhancedOptions, next);\n };\n\n // Create enhanced options with addDisposer for base handler as well\n const enhancedOptions = {\n ...options,\n addDisposer\n };\n\n // Run the middleware chain\n const result = await runMiddleware(0, input, enhancedOptions);\n\n // Create the dispose function that will call all collected disposers in reverse order\n const dispose = async (): Promise<void> => {\n // Execute disposers in reverse order (last added, first disposed)\n /* eslint-disable no-await-in-loop */\n for (let i = disposers.length - 1; i >= 0; i--) {\n try {\n await disposers[i]();\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error in disposer:', error);\n }\n }\n // Clear the disposers array after all are executed\n disposers.length = 0;\n };\n\n // Return both the result and the dispose function\n return {\n result,\n dispose\n };\n };\n };\n}\n", "/* eslint-disable no-console */\nimport { GenerationResult, Output } from '../provider';\nimport { Middleware } from './middleware';\n\nfunction loggingMiddleware<I, O extends Output>() {\n const middleware: Middleware<I, O> = async (input, options, next) => {\n console.group('[GENERATION]');\n console.log(`Generating with input:`, JSON.stringify(input, null, 2));\n let result: GenerationResult<O> | undefined;\n const start = Date.now();\n try {\n result = await next(input, options);\n return result;\n } finally {\n if (result != null) {\n console.log(`Generation took ${Date.now() - start}ms`);\n console.log(`Generation result:`, JSON.stringify(result, null, 2));\n }\n console.groupEnd();\n }\n };\n\n return middleware;\n}\n\nexport default loggingMiddleware;\n", "/* eslint-disable no-console */\nimport { getImageDimensionsFromURL, getImageUri } from '@imgly/plugin-utils';\nimport {\n type Output,\n type OutputKind,\n type GetBlockInputResult,\n VideoOutput,\n ImageOutput,\n GenerationOptions\n} from '../provider';\nimport { Middleware } from './middleware';\n\ninterface DryRunOptions<K extends OutputKind> {\n kind: K;\n\n // Is only defined with generation from a panel where we create a complete new block\n blockInputs?: GetBlockInputResult<K>;\n\n // Is only defined with quick action generation on a given block(s).\n blockIds?: number[];\n}\n\nfunction dryRunMiddleware<I, K extends OutputKind, O extends Output>(\n options: DryRunOptions<K>\n) {\n const middleware: Middleware<I, O> = async (\n generationInput,\n generationOptions\n ) => {\n console.log(\n `[DRY RUN]: Requesting dummy AI generation for kind '${options.kind}' with inputs: `,\n JSON.stringify(generationInput, undefined, 2)\n );\n await wait(2000);\n const output = await getDryRunOutput(\n generationInput,\n options,\n generationOptions\n );\n return output as O;\n };\n\n return middleware;\n}\n\nasync function getDryRunOutput<K extends OutputKind, I>(\n generationInput: I,\n options: DryRunOptions<K>,\n generationOptions: GenerationOptions\n): Promise<Output> {\n switch (options.kind) {\n case 'image': {\n return getImageDryRunOutput(\n generationInput,\n options as DryRunOptions<'image'>,\n generationOptions\n );\n }\n case 'video': {\n return getVideoDryRunOutput(\n generationInput,\n options as DryRunOptions<'video'>,\n generationOptions\n );\n }\n\n default: {\n throw new Error(\n `Unsupported output kind for creating dry run output: ${options.kind}`\n );\n }\n }\n}\n\nasync function getImageDryRunOutput<I>(\n generationInput: I,\n options: DryRunOptions<'image'>,\n { engine }: GenerationOptions\n): Promise<ImageOutput> {\n let width;\n let height;\n\n const prompt: string =\n generationInput != null &&\n typeof generationInput === 'object' &&\n 'prompt' in generationInput &&\n typeof generationInput.prompt === 'string'\n ? generationInput.prompt\n : 'AI Generated Image';\n\n // If prompt includes something that looks like a dimension\n // e.g. 512x512, 1024x768, etc. than we will use this as the\n // output image size for testing purposes.\n const promptDimension = prompt.match(/(\\d+)x(\\d+)/);\n if (promptDimension != null) {\n width = parseInt(promptDimension[1], 10);\n height = parseInt(promptDimension[2], 10);\n } else {\n if (options.blockInputs != null) {\n width = options.blockInputs.image.width;\n height = options.blockInputs.image.height;\n }\n if (\n options.blockIds != null &&\n Array.isArray(options.blockIds) &&\n options.blockIds.length > 0\n ) {\n const [blockId] = options.blockIds;\n const url = await getImageUri(blockId, engine);\n const dimension = await getImageDimensionsFromURL(url, engine);\n width = dimension.width;\n height = dimension.height;\n } else {\n width = 512;\n height = 512;\n }\n }\n\n const url = `https://placehold.co/${width}x${height}/000000/FFF?text=${prompt\n .replace(' ', '+')\n .replace('\\n', '+')}`;\n\n return {\n kind: 'image',\n url\n };\n}\n\nasync function getVideoDryRunOutput<I>(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _generationInput: I,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _options: DryRunOptions<'video'>,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _generationOptions: GenerationOptions\n): Promise<VideoOutput> {\n return Promise.resolve({\n kind: 'video',\n url: 'https://storage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4'\n });\n}\n\nasync function wait(ms: number) {\n return new Promise((resolve) => {\n setTimeout(resolve, ms);\n });\n}\n\nexport default dryRunMiddleware;\n", "/* eslint-disable no-console */\nimport type { AssetDefinition, AssetResult } from '@cesdk/cesdk-js';\nimport {\n addAssetToScene,\n isAbortError,\n isAsyncGenerator,\n uuid4\n} from '../utils';\nimport type Provider from './provider';\nimport {\n type GetInput,\n type GetBlockInput,\n OutputKind,\n type Output\n} from './provider';\nimport { InitProviderConfiguration, UIOptions } from './types';\nimport CreativeEditorSDK from '@cesdk/cesdk-js';\nimport getAssetResultForPlaceholder from './getAssetResultForPlaceholder';\nimport getAssetResultForGenerated from './getAssetResultForGenerated';\nimport { composeMiddlewares } from './middleware/middleware';\nimport loggingMiddleware from './middleware/loggingMiddleware';\nimport dryRunMiddleware from './middleware/dryRunMiddleware';\n\ntype Result<O> = { status: 'success'; output: O } | { status: 'aborted' };\n\n/**\n * Generate content using the provider with the given input\n */\nasync function generate<K extends OutputKind, I, O extends Output>(\n kind: K,\n getInput: GetInput<I>,\n getBlockInput: GetBlockInput<K, I>,\n provider: Provider<K, I, O>,\n options: UIOptions & {\n createPlaceholderBlock?: boolean;\n },\n config: InitProviderConfiguration,\n abortSignal: AbortSignal\n): Promise<Result<O>> {\n const { cesdk, createPlaceholderBlock, historyAssetSourceId } = options;\n\n let placeholderBlock: number | undefined;\n\n try {\n if (config.debug) console.group(`Starting Generation for '${kind}'`);\n\n const inputs = getInput();\n const blockInputs = await getBlockInput(inputs.input);\n const assetId = uuid4();\n let assetResult: AssetResult;\n\n // Create a placeholder block\n if (createPlaceholderBlock) {\n assetResult = getAssetResultForPlaceholder(assetId, kind, blockInputs);\n\n if (config.debug)\n console.log(\n 'Adding as asset to scene:',\n JSON.stringify(assetResult, undefined, 2)\n );\n\n placeholderBlock = await addAssetToScene(cesdk, assetResult);\n // This is a workaround. The middleware in the video timeline\n // is calling APIs that will render the block in an error\n // state if it does not have an URI set. It's difficult to\n // recover from that. A bug report has been created for this.\n // As a workaround: Duplicating the block will remove the error state\n // but you will still see an error in the web console.\n // TODO: Remove this workaround when the bug is fixed.\n if (placeholderBlock != null && provider.kind === 'video') {\n const positionX = cesdk.engine.block.getPositionX(placeholderBlock);\n const positionY = cesdk.engine.block.getPositionY(placeholderBlock);\n const duplicated = cesdk.engine.block.duplicate(placeholderBlock);\n cesdk.engine.block.setPositionX(duplicated, positionX);\n cesdk.engine.block.setPositionY(duplicated, positionY);\n cesdk.engine.block.destroy(placeholderBlock);\n placeholderBlock = duplicated;\n }\n // placeholderBlock = await options.engine.asset.defaultApplyAsset(\n // assetResult\n // );\n\n if (checkAbortSignal(cesdk, abortSignal, placeholderBlock))\n return { status: 'aborted' };\n\n if (placeholderBlock == null)\n throw new Error('Could not create placeholder block');\n\n cesdk.engine.block.setState(placeholderBlock, {\n type: 'Pending',\n progress: 0\n });\n }\n\n // Trigger the generation\n const composedMiddlewares = composeMiddlewares<I, O>([\n ...(provider.output.middleware ?? []),\n config.debug ? loggingMiddleware() : undefined,\n config.dryRun\n ? dryRunMiddleware({ kind: provider.kind, blockInputs })\n : undefined\n ]);\n\n const { result: output } = await composedMiddlewares(\n provider.output.generate\n )(inputs.input, {\n abortSignal,\n engine: options.engine,\n cesdk\n });\n\n if (isAsyncGenerator(output)) {\n throw new Error('Streaming generation is not supported yet from a panel');\n }\n\n if (checkAbortSignal(cesdk, abortSignal, placeholderBlock))\n return { status: 'aborted' };\n\n if (output == null) throw new Error('Generation failed');\n\n if (config.debug)\n console.log('Generated output:', JSON.stringify(output, undefined, 2));\n\n let generatedAssetResult: AssetResult | undefined;\n if (\n placeholderBlock != null &&\n cesdk.engine.block.isValid(placeholderBlock)\n ) {\n generatedAssetResult = await getAssetResultForGenerated(\n assetId,\n kind,\n blockInputs,\n output\n );\n if (config.debug)\n console.log(\n 'Updating asset in scene:',\n JSON.stringify(generatedAssetResult, undefined, 2)\n );\n\n await cesdk.engine.asset.defaultApplyAssetToBlock(\n generatedAssetResult,\n placeholderBlock\n );\n }\n\n if (checkAbortSignal(cesdk, abortSignal, placeholderBlock))\n return { status: 'aborted' };\n\n if (historyAssetSourceId != null) {\n if (generatedAssetResult == null) {\n generatedAssetResult = await getAssetResultForGenerated(\n assetId,\n kind,\n blockInputs,\n output\n );\n if (checkAbortSignal(cesdk, abortSignal, placeholderBlock))\n return { status: 'aborted' };\n }\n const assetDefinition: AssetDefinition = {\n ...generatedAssetResult,\n id: `${Date.now()}-${generatedAssetResult.id}`,\n label:\n generatedAssetResult.label != null\n ? {\n en: generatedAssetResult.label\n }\n : {},\n tags: {}\n };\n\n cesdk.engine.asset.addAssetToSource(\n historyAssetSourceId,\n assetDefinition\n );\n }\n\n if (\n placeholderBlock != null &&\n cesdk.engine.block.isValid(placeholderBlock)\n ) {\n cesdk.engine.block.setState(placeholderBlock, {\n type: 'Ready'\n });\n }\n return { status: 'success', output };\n } catch (error) {\n if (\n placeholderBlock != null &&\n cesdk.engine.block.isValid(placeholderBlock)\n ) {\n if (isAbortError(error)) {\n cesdk.engine.block.destroy(placeholderBlock);\n } else {\n cesdk.engine.block.setState(placeholderBlock, {\n type: 'Error',\n error: 'Unknown'\n });\n }\n }\n throw error;\n } finally {\n if (config.debug) console.groupEnd();\n }\n}\n\n/**\n * Check the given abort signal and destroy the placeholder block if it is aborted.\n * @returns `true` if the signal is aborted, `false` otherwise.\n */\nfunction checkAbortSignal(\n cesdk: CreativeEditorSDK,\n abortSignal: AbortSignal,\n placeholderBlock?: number\n) {\n if (abortSignal.aborted) {\n if (\n placeholderBlock != null &&\n cesdk.engine.block.isValid(placeholderBlock)\n ) {\n cesdk.engine.block.destroy(placeholderBlock);\n }\n return true;\n }\n return false;\n}\n\nexport default generate;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport Provider, { GetInput, Output, OutputKind } from './provider';\nimport { InitProviderConfiguration } from './types';\nimport { extractErrorMessage } from '../utils';\n\nfunction handleGenerationError<K extends OutputKind, I, O extends Output>(\n error: unknown,\n options: {\n cesdk: CreativeEditorSDK;\n provider: Provider<K, I, O>;\n getInput?: GetInput<I>;\n },\n config: InitProviderConfiguration\n) {\n const { cesdk, provider, getInput } = options;\n\n if (config.onError != null && typeof config.onError === 'function') {\n config.onError(error);\n } else {\n // eslint-disable-next-line no-console\n console.error('Generation failed:', error);\n const shown = showErrorNotification(\n cesdk,\n provider.output.notification,\n () => ({\n input: getInput?.().input,\n error\n })\n );\n if (!shown) {\n cesdk.ui.showNotification({\n type: 'error',\n message: extractErrorMessage(error)\n });\n }\n }\n}\n\nfunction showErrorNotification<I, O extends Output>(\n cesdk: CreativeEditorSDK,\n notifications: Provider<any, I, O>['output']['notification'],\n createContext: () => { input?: I; error: unknown }\n): boolean {\n const errorNotification = notifications?.error;\n if (errorNotification == null) return false;\n\n const showOnSuccess =\n typeof errorNotification.show === 'function'\n ? errorNotification.show(createContext())\n : errorNotification.show;\n\n if (!showOnSuccess) return false;\n\n const message =\n typeof errorNotification.message === 'function'\n ? errorNotification.message(createContext())\n : errorNotification.message ?? 'common.ai-generation.failed';\n\n const action =\n errorNotification.action != null\n ? {\n label:\n typeof errorNotification.action.label === 'function'\n ? errorNotification.action.label(createContext())\n : errorNotification.action.label,\n onClick: () => {\n errorNotification?.action?.onClick(createContext());\n }\n }\n : undefined;\n\n cesdk.ui.showNotification({\n type: 'error',\n message,\n action\n });\n return true;\n}\n\nexport default handleGenerationError;\n", "import CreativeEditorSDK, {\n type BuilderRenderFunctionContext\n} from '@cesdk/cesdk-js';\nimport type Provider from './provider';\nimport {\n type GetInput,\n type OutputKind,\n type Output,\n type GetBlockInput\n} from './provider';\nimport { InitProviderConfiguration, UIOptions } from './types';\nimport generate from './generate';\nimport { isAbortError } from '../utils';\nimport handleGenerationError from './handleGenerationError';\n\nexport function isGeneratingStateKey(providerId: string): string {\n return `${providerId}.generating`;\n}\n\nexport function abortGenerationStateKey(providerId: string): string {\n return `${providerId}.abort`;\n}\n\n/**\n * Renders the generation UI components and sets up event handlers\n */\nfunction renderGenerationComponents<K extends OutputKind, I, O extends Output>(\n context: BuilderRenderFunctionContext<any>,\n provider: Provider<K, I, O>,\n getInput: GetInput<I>,\n getBlockInput: GetBlockInput<K, I>,\n options: UIOptions & {\n createPlaceholderBlock?: boolean;\n includeHistoryLibrary?: boolean;\n requiredInputs?: string[];\n },\n config: InitProviderConfiguration\n): void {\n const { builder, experimental } = context;\n const { cesdk, includeHistoryLibrary = true } = options;\n const {\n id: providerId,\n output: { abortable }\n } = provider;\n const abortState = experimental.global<() => void>(\n abortGenerationStateKey(providerId),\n () => {}\n );\n const generatingState = experimental.global<boolean>(\n isGeneratingStateKey(providerId),\n false\n );\n\n let abortController: AbortController | undefined;\n const canAbortNow = generatingState.value && abortable;\n const abort = () => {\n if (canAbortNow) {\n abortState.value();\n generatingState.setValue(false);\n abortState.setValue(() => {});\n }\n };\n\n let isDisabled: boolean | undefined;\n if (options.requiredInputs != null && options.requiredInputs.length > 0) {\n const inputs = getInput();\n isDisabled = options.requiredInputs.every((input) => {\n // @ts-ignore\n const hasInput = !inputs.input[input];\n return hasInput;\n });\n }\n\n const confirmCancelDialogId = experimental.global<string | undefined>(\n `${providerId}.confirmationDialogId`,\n undefined\n );\n\n builder.Section(`${providerId}.generate.section`, {\n children: () => {\n builder.Button(`${providerId}.generate`, {\n label: [\n 'common.ai-generation.generate',\n `panel.${providerId}.generate`\n ],\n isLoading: generatingState.value,\n color: 'accent',\n isDisabled,\n suffix: canAbortNow\n ? {\n icon: '@imgly/Cross',\n color: 'danger',\n tooltip: [`panel.${providerId}.abort`, 'common.cancel'],\n onClick: () => {\n const confirmationDialogId = cesdk.ui.showDialog({\n type: 'warning',\n content: 'panel.ly.img.ai.generation.confirmCancel.content',\n cancel: {\n label: 'common.close',\n onClick: ({ id }) => {\n cesdk.ui.closeDialog(id);\n confirmCancelDialogId.setValue(undefined);\n }\n },\n actions: {\n label: 'panel.ly.img.ai.generation.confirmCancel.confirm',\n color: 'danger',\n onClick: ({ id }) => {\n abort();\n cesdk.ui.closeDialog(id);\n confirmCancelDialogId.setValue(undefined);\n }\n }\n });\n confirmCancelDialogId.setValue(confirmationDialogId);\n }\n }\n : undefined,\n onClick: async () => {\n abortController = new AbortController();\n const abortSignal = abortController.signal;\n\n const triggerGeneration = async () => {\n try {\n generatingState.setValue(true);\n abortState.setValue(() => {\n if (config.debug)\n // eslint-disable-next-line no-console\n console.log('Aborting generation');\n abortController?.abort();\n });\n\n const result = await generate(\n provider.kind,\n getInput,\n getBlockInput,\n provider,\n options,\n config,\n abortSignal\n );\n\n if (result.status === 'aborted') {\n return;\n }\n\n const notification = provider.output.notification;\n showSuccessNotification(cesdk, notification, () => ({\n input: getInput().input,\n output: result.output\n }));\n } catch (error) {\n // Do not treat abort errors as errors\n if (isAbortError(error)) {\n return;\n }\n\n handleGenerationError(\n error,\n {\n cesdk,\n provider,\n getInput\n },\n config\n );\n } finally {\n abortController = undefined;\n generatingState.setValue(false);\n abortState.setValue(() => {});\n\n if (confirmCancelDialogId.value != null) {\n cesdk.ui.closeDialog(confirmCancelDialogId.value);\n confirmCancelDialogId.setValue(undefined);\n }\n }\n };\n\n if (config.middleware != null) {\n await config.middleware(triggerGeneration, {\n provider,\n abort\n });\n } else {\n await triggerGeneration();\n }\n }\n });\n if (provider.output.generationHintText != null) {\n builder.Text(`${providerId}.generation-hint`, {\n align: 'center',\n content: provider.output.generationHintText\n });\n }\n }\n });\n\n if (includeHistoryLibrary && options.historyAssetLibraryEntryId != null) {\n builder.Library(`${providerId}.history.library`, {\n entries: [options.historyAssetLibraryEntryId]\n });\n }\n}\n\nfunction showSuccessNotification<I, O extends Output>(\n cesdk: CreativeEditorSDK,\n notifications: Provider<any, I, O>['output']['notification'],\n createContext: () => { input: I; output: O }\n): boolean {\n const successNotification = notifications?.success;\n if (successNotification == null) return false;\n\n const showOnSuccess =\n typeof successNotification.show === 'function'\n ? successNotification.show(createContext())\n : successNotification.show;\n\n if (!showOnSuccess) return false;\n\n const message =\n typeof successNotification.message === 'function'\n ? successNotification.message(createContext())\n : successNotification.message ?? 'common.ai-generation.success';\n\n const action =\n successNotification.action != null\n ? {\n label:\n typeof successNotification.action.label === 'function'\n ? successNotification.action.label(createContext())\n : successNotification.action.label,\n onClick: () => {\n successNotification?.action?.onClick(createContext());\n }\n }\n : undefined;\n\n cesdk.ui.showNotification({\n type: 'success',\n message,\n action,\n duration: successNotification.duration\n });\n return true;\n}\n\nexport default renderGenerationComponents;\n", "import { OpenAPIV3 } from 'openapi-types';\nimport dereferenceDocument, {\n resolveReference\n} from './openapi/dereferenceDocument';\nimport {\n type OutputKind,\n type Output,\n type PanelInputSchema\n} from './provider';\nimport type Provider from './provider';\nimport { InitProviderConfiguration, UIOptions } from './types';\nimport { isOpenAPISchema } from './openapi/isOpenAPISchema';\nimport { GetPropertyInput, PropertyInput } from './openapi/types';\nimport renderProperty from './openapi/renderProperty';\nimport renderGenerationComponents from './renderGenerationComponents';\nimport getProperties from './openapi/getProperties';\nimport { BuilderRenderFunction } from '@cesdk/cesdk-js';\nimport { getPanelId } from '../utils';\n\n/**\n * Registers a schema-based panel input for a provider\n */\nasync function registerPanelInputSchema<\n K extends OutputKind,\n I,\n O extends Output\n>(\n provider: Provider<K, I, O>,\n panelInput: PanelInputSchema<K, I>,\n options: UIOptions,\n config: InitProviderConfiguration\n): Promise<BuilderRenderFunction<any>> {\n const { cesdk } = options;\n const { id: providerId } = provider;\n\n if (config.debug) {\n // eslint-disable-next-line no-console\n console.log(\n `Registering schema-based panel input for provider ${providerId}`\n );\n }\n\n const schemaDocument = dereferenceDocument(panelInput.document);\n const resolvedInputReference = resolveReference(\n schemaDocument,\n panelInput.inputReference\n );\n\n if (!isOpenAPISchema(resolvedInputReference, config.debug)) {\n throw new Error(\n `Input reference '${panelInput.inputReference}' does not resolve to a valid OpenAPI schema`\n );\n }\n\n const inputSchema: OpenAPIV3.SchemaObject = resolvedInputReference;\n const properties = getProperties(inputSchema, panelInput);\n\n const builderRenderFunction: BuilderRenderFunction<any> = (context) => {\n const { builder } = context;\n\n const getInputs: GetPropertyInput[] = [];\n builder.Section(`${providerId}.schema.section`, {\n children: () => {\n properties.forEach((property) => {\n const getInput = renderProperty(\n context,\n property,\n provider,\n panelInput,\n options,\n config\n );\n if (getInput != null) {\n if (Array.isArray(getInput)) {\n getInputs.push(...getInput);\n } else {\n getInputs.push(getInput);\n }\n }\n });\n }\n });\n\n const inputs = getInputs.map((getInput) => {\n const input = getInput();\n return input;\n });\n\n const resolveInput = (input: PropertyInput) => {\n if (input.type === 'object') {\n return Object.entries(input.value).reduce((acc, [key, value]) => {\n acc[key] = resolveInput(value);\n\n return acc;\n }, {} as Record<string, any>);\n }\n\n return input.value;\n };\n const input = inputs.reduce((acc, propertyInput) => {\n acc[propertyInput.id] = resolveInput(propertyInput);\n return acc;\n }, {} as Record<string, any>) as I;\n\n renderGenerationComponents(\n context,\n provider,\n () => {\n return { input };\n },\n () => {\n return panelInput.getBlockInput(input);\n },\n {\n ...options,\n requiredInputs: inputSchema.required,\n createPlaceholderBlock: panelInput.userFlow === 'placeholder'\n },\n config\n );\n };\n\n cesdk.ui.registerPanel(getPanelId(providerId), builderRenderFunction);\n return builderRenderFunction;\n}\n\nexport default registerPanelInputSchema;\n", "import { BuilderRenderFunction } from '@cesdk/cesdk-js';\nimport type Provider from './provider';\nimport { OutputKind, PanelInputCustom, type Output } from './provider';\nimport renderGenerationComponents, {\n isGeneratingStateKey\n} from './renderGenerationComponents';\nimport { InitProviderConfiguration, UIOptions } from './types';\nimport { getPanelId } from '../utils';\n\nasync function registerPanelInputCustom<\n K extends OutputKind,\n I,\n O extends Output\n>(\n provider: Provider<K, I, O>,\n panelInput: PanelInputCustom<K, I>,\n options: UIOptions,\n config: InitProviderConfiguration\n): Promise<BuilderRenderFunction<any>> {\n const { cesdk } = options;\n const { id: providerId } = provider;\n\n const render = panelInput.render;\n\n const builderRenderFunction: BuilderRenderFunction<any> = (context) => {\n const { state } = context;\n\n const isGenerating = state(isGeneratingStateKey(providerId), {\n isGenerating: false,\n abort: () => {}\n }).value.isGenerating;\n\n const { getInput, getBlockInput } = render(context, {\n cesdk,\n isGenerating\n });\n renderGenerationComponents(\n context,\n provider,\n getInput,\n getBlockInput,\n {\n ...options,\n includeHistoryLibrary: panelInput.includeHistoryLibrary ?? true,\n createPlaceholderBlock: panelInput.userFlow === 'placeholder'\n },\n config\n );\n\n return getInput;\n };\n\n cesdk.ui.registerPanel(getPanelId(providerId), builderRenderFunction);\n\n return builderRenderFunction;\n}\n\nexport default registerPanelInputCustom;\n", "export const PLUGIN_ICON_SET_ID = '@imgly/plugin-ai-generation';\n\nexport const ICON_SPRITE = `\n<svg>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/Sparkle\"\n >\n <path d=\"M5.35545 2.06745C5.24149 1.72556 4.7579 1.72556 4.64394 2.06745L4.05898 3.82232C4.02166 3.93429 3.9338 4.02215 3.82184 4.05948L2.06694 4.64459C1.72506 4.75858 1.72509 5.24217 2.06699 5.3561L3.82179 5.9409C3.93378 5.97822 4.02166 6.06609 4.05899 6.17808L4.64394 7.93291C4.7579 8.2748 5.24149 8.2748 5.35545 7.93291L5.9404 6.17806C5.97773 6.06608 6.06559 5.97821 6.17757 5.94089L7.93242 5.35594C8.27431 5.24198 8.27431 4.75839 7.93242 4.64442L6.17757 4.05947C6.06559 4.02215 5.97773 3.93428 5.9404 3.8223L5.35545 2.06745Z\" fill=\"currentColor\"/>\n<path d=\"M17.9632 3.23614C17.8026 2.80788 17.1968 2.80788 17.0362 3.23614L16.0787 5.78951C16.0285 5.92337 15.9229 6.02899 15.789 6.07918L13.2356 7.0367C12.8074 7.19729 12.8074 7.80307 13.2356 7.96366L15.789 8.92118C15.9229 8.97138 16.0285 9.077 16.0787 9.21085L17.0362 11.7642C17.1968 12.1925 17.8026 12.1925 17.9632 11.7642L18.9207 9.21086C18.9709 9.077 19.0765 8.97138 19.2104 8.92118L21.7637 7.96366C22.192 7.80307 22.192 7.1973 21.7637 7.0367L19.2104 6.07918C19.0765 6.02899 18.9709 5.92337 18.9207 5.78951L17.9632 3.23614Z\" fill=\"currentColor\"/>\n<path d=\"M9.30058 7.82012C9.54712 7.1791 10.454 7.1791 10.7006 7.82012L12.3809 12.189C12.4571 12.3871 12.6136 12.5436 12.8117 12.6198L17.1806 14.3001C17.8216 14.5466 17.8216 15.4536 17.1806 15.7001L12.8117 17.3804C12.6136 17.4566 12.4571 17.6131 12.3809 17.8112L10.7006 22.1801C10.454 22.8211 9.54712 22.8211 9.30058 22.1801L7.62024 17.8112C7.54406 17.6131 7.38754 17.4566 7.18947 17.3804L2.82061 15.7001C2.17959 15.4536 2.17959 14.5466 2.82061 14.3001L7.18947 12.6198C7.38754 12.5436 7.54406 12.3871 7.62024 12.189L9.30058 7.82012Z\" fill=\"currentColor\"/>\n\n </symbol>\n\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"${PLUGIN_ICON_SET_ID}/image\"\n >\n <path d=\"M3 16.5V18C3 19.6569 4.34315 21 6 21H18C19.6569 21 21 19.6569 21 18V6C21 4.34315 19.6569 3 18 3L17.999 5C18.5513 5 19 5.44772 19 6V18C19 18.5523 18.5523 19 18 19H6C5.44772 19 5 18.5523 5 18V16.5H3Z\" fill=\"currentColor\"/>\n<path d=\"M13.0982 0.884877C12.9734 0.568323 12.5254 0.568322 12.4005 0.884876L11.7485 2.53819C11.7104 2.63483 11.6339 2.71134 11.5372 2.74945L9.8839 3.40151C9.56735 3.52636 9.56734 3.97436 9.8839 4.09921L11.5372 4.75126C11.6339 4.78938 11.7104 4.86588 11.7485 4.96253L12.4005 6.61584C12.5254 6.93239 12.9734 6.9324 13.0982 6.61584L13.7503 4.96253C13.7884 4.86588 13.8649 4.78938 13.9616 4.75126L15.6149 4.09921C15.9314 3.97436 15.9314 3.52636 15.6149 3.40151L13.9616 2.74945C13.8649 2.71134 13.7884 2.63483 13.7503 2.53819L13.0982 0.884877Z\" fill=\"currentColor\"/>\n<path d=\"M6.40053 5.38488C6.52538 5.06832 6.97338 5.06832 7.09823 5.38488L8.17455 8.11392C8.21267 8.21057 8.28917 8.28707 8.38582 8.32519L11.1149 9.40151C11.4314 9.52636 11.4314 9.97436 11.1149 10.0992L8.38582 11.1755C8.28917 11.2136 8.21267 11.2901 8.17455 11.3868L7.09823 14.1158C6.97338 14.4324 6.52538 14.4324 6.40053 14.1158L5.32421 11.3868C5.2861 11.2901 5.20959 11.2136 5.11295 11.1755L2.3839 10.0992C2.06735 9.97436 2.06735 9.52636 2.3839 9.40151L5.11295 8.32519C5.20959 8.28707 5.2861 8.21057 5.32421 8.11392L6.40053 5.38488Z\" fill=\"currentColor\"/>\n<path d=\"M18.9994 16.5008V18.0004C18.9994 18.5526 18.5517 19.0004 17.9994 19.0004H9.33302L14.3753 11.4369C14.6722 10.9916 15.3266 10.9916 15.6234 11.4369L18.9994 16.5008Z\" fill=\"currentColor\"/>\n\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"${PLUGIN_ICON_SET_ID}/video\"\n >\n<path d=\"M6 3C4.34315 3 3 4.34315 3 6V18C3 19.6569 4.34315 21 6 21H18C19.6569 21 21 19.6569 21 18V16.5H19V18C19 18.5523 18.5523 19 18 19H6C5.44772 19 5 18.5523 5 18V6C5 5.44772 5.44772 5 6 5V3Z\" fill=\"currentColor\"/>\n<path d=\"M10.9025 0.8839C11.0273 0.567345 11.4753 0.567346 11.6002 0.883901L12.2522 2.53721C12.2904 2.63386 12.3669 2.71036 12.4635 2.74848L14.1168 3.40053C14.4334 3.52538 14.4334 3.97338 14.1168 4.09823L12.4635 4.75029C12.3669 4.7884 12.2904 4.86491 12.2522 4.96155L11.6002 6.61486C11.4753 6.93142 11.0273 6.93142 10.9025 6.61486L10.2504 4.96155C10.2123 4.86491 10.1358 4.7884 10.0392 4.75029L8.38585 4.09823C8.0693 3.97338 8.0693 3.52538 8.38585 3.40053L10.0392 2.74848C10.1358 2.71036 10.2123 2.63386 10.2504 2.53721L10.9025 0.8839Z\" fill=\"currentColor\"/>\n<path d=\"M18.9019 3.3845C19.0267 3.06795 19.4747 3.06795 19.5996 3.3845L20.6759 6.11355C20.714 6.2102 20.7905 6.2867 20.8872 6.32482L23.6162 7.40114C23.9328 7.52598 23.9328 7.97399 23.6162 8.09883L20.8872 9.17515C20.7905 9.21327 20.714 9.28977 20.6759 9.38642L19.5996 12.1155C19.4747 12.432 19.0267 12.432 18.9019 12.1155L17.8255 9.38642C17.7874 9.28977 17.7109 9.21327 17.6143 9.17515L14.8852 8.09883C14.5687 7.97399 14.5687 7.52598 14.8852 7.40114L17.6143 6.32482C17.7109 6.2867 17.7874 6.2102 17.8255 6.11355L18.9019 3.3845Z\" fill=\"currentColor\"/>\n<path d=\"M14.9994 13.2862C15.5089 12.8859 15.5089 12.1141 14.9995 11.7137L10.618 8.27047C9.96188 7.75485 9.00011 8.22225 9.00011 9.05673L9.00011 15.9429C9.00011 16.7773 9.96185 17.2448 10.618 16.7292L14.9994 13.2862Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"${PLUGIN_ICON_SET_ID}/audio\"\n >\n <path d=\"M6 3.80273C4.2066 4.84016 3 6.77919 3 9.00004V12.8153C3 15.931 5.39501 18.4873 8.44444 18.7436V20.9645C8.44444 22.2198 9.89427 22.9198 10.8773 22.1392L15.1265 18.7647H15.5C17.8285 18.7647 19.8472 17.4384 20.8417 15.5H18.4187C17.6889 16.2784 16.6512 16.7647 15.5 16.7647H14.9522C14.6134 16.7647 14.2846 16.8794 14.0193 17.0901L10.4444 19.929V18.2597C10.4444 17.4341 9.77513 16.7647 8.9495 16.7647C7.80494 16.7647 6.77409 16.2779 6.05276 15.5H6V15.4419C5.37798 14.7439 5 13.8237 5 12.8153V9.00004C5 7.98559 5.37764 7.05935 6 6.35422V3.80273Z\" fill=\"currentColor\"/>\n<path d=\"M11.6002 1.8839C11.4753 1.56735 11.0273 1.56735 10.9025 1.8839L10.2504 3.53721C10.2123 3.63386 10.1358 3.71036 10.0392 3.74848L8.38585 4.40053C8.0693 4.52538 8.0693 4.97338 8.38585 5.09823L10.0392 5.75029C10.1358 5.7884 10.2123 5.86491 10.2504 5.96155L10.9025 7.61486C11.0273 7.93142 11.4753 7.93142 11.6002 7.61486L12.2522 5.96155C12.2904 5.86491 12.3669 5.7884 12.4635 5.75029L14.1168 5.09823C14.4334 4.97338 14.4334 4.52538 14.1168 4.40053L12.4635 3.74848C12.3669 3.71036 12.2904 3.63386 12.2522 3.53721L11.6002 1.8839Z\" fill=\"currentColor\"/>\n<path d=\"M19.5996 4.3845C19.4747 4.06795 19.0267 4.06795 18.9019 4.3845L17.8255 7.11355C17.7874 7.2102 17.7109 7.2867 17.6143 7.32482L14.8852 8.40114C14.5687 8.52598 14.5687 8.97399 14.8852 9.09883L17.6143 10.1752C17.7109 10.2133 17.7874 10.2898 17.8255 10.3864L18.9019 13.1155C19.0267 13.432 19.4747 13.432 19.5996 13.1155L20.6759 10.3864C20.714 10.2898 20.7905 10.2133 20.8872 10.1752L23.6162 9.09883C23.9328 8.97399 23.9328 8.52598 23.6162 8.40114L20.8872 7.32482C20.7905 7.2867 20.714 7.2102 20.6759 7.11355L19.5996 4.3845Z\" fill=\"currentColor\"/>\n </symbol>\n <symbol\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n id=\"@imgly/MixingPlate\"\n >\n <path d=\"M9.75 9C10.5784 9 11.25 8.32843 11.25 7.5C11.25 6.67157 10.5784 6 9.75 6C8.92157 6 8.25 6.67157 8.25 7.5C8.25 8.32843 8.92157 9 9.75 9Z\" fill=\"currentColor\"/>\n<path d=\"M7 13C7.82843 13 8.5 12.3284 8.5 11.5C8.5 10.6716 7.82843 10 7 10C6.17157 10 5.5 10.6716 5.5 11.5C5.5 12.3284 6.17157 13 7 13Z\" fill=\"currentColor\"/>\n<path d=\"M15.75 7.5C15.75 8.32843 15.0784 9 14.25 9C13.4216 9 12.75 8.32843 12.75 7.5C12.75 6.67157 13.4216 6 14.25 6C15.0784 6 15.75 6.67157 15.75 7.5Z\" fill=\"currentColor\"/>\n<path d=\"M17 13C17.8284 13 18.5 12.3284 18.5 11.5C18.5 10.6716 17.8284 10 17 10C16.1716 10 15.5 10.6716 15.5 11.5C15.5 12.3284 16.1716 13 17 13Z\" fill=\"currentColor\"/>\n<path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M8.26309 2.77709C10.6681 1.77921 13.4829 1.7322 15.9209 2.64297C18.1572 3.47923 20.0876 5.09285 21.1766 7.28598C22.3395 9.62772 22.4889 13.1077 20.3864 15.2982C19.2693 16.4621 17.7657 16.9982 16.0026 16.9997C15.7897 16.9997 15.5555 16.9864 15.3497 16.9745C15.309 16.9722 15.2694 16.9699 15.2313 16.9679C14.9817 16.9542 14.761 16.9455 14.5569 16.9539C14.124 16.9718 13.9598 17.0612 13.89 17.1324C13.718 17.3081 13.6946 17.6672 13.8854 17.8895C14.2899 18.3608 14.5016 18.9277 14.5016 19.5497C14.5016 20.2206 14.3086 20.9011 13.7542 21.3896C13.2471 21.837 12.6082 21.9997 11.9635 21.9997C10.6049 21.9997 9.31155 21.7367 8.0934 21.2067C6.89058 20.6831 5.84501 19.9687 4.94363 19.0666C4.04281 18.1651 3.31836 17.107 2.79369 15.8978C1.72761 13.4409 1.72662 10.5261 2.81247 8.07034C3.88024 5.65548 5.84206 3.78161 8.26309 2.77709ZM15.2207 4.51639C13.2556 3.78239 10.9651 3.82132 9.02956 4.62439C7.06888 5.43791 5.49559 6.94785 4.64163 8.87914C3.78373 10.8194 3.78253 13.1522 4.62841 15.1017C5.05312 16.0805 5.63511 16.9291 6.35838 17.6529C7.08102 18.3761 7.91671 18.9484 8.89123 19.3728C9.8492 19.7895 10.87 19.9997 11.9635 19.9997C12.2815 19.9997 12.394 19.9225 12.431 19.8899L12.4319 19.8891C12.4367 19.8849 12.4487 19.8743 12.4631 19.8359C12.4799 19.7911 12.5016 19.7024 12.5016 19.5497C12.5016 19.4091 12.4633 19.3034 12.3677 19.192C11.5353 18.222 11.5272 16.6868 12.4611 15.7331C13.0741 15.1071 13.8844 14.98 14.4745 14.9556C14.7819 14.943 15.085 14.9568 15.3409 14.9709C15.3906 14.9736 15.4379 14.9763 15.4832 14.9788C15.6876 14.9904 15.8508 14.9997 16.0009 14.9997C17.3405 14.9986 18.2792 14.6054 18.9435 13.9133C20.2633 12.5382 20.3186 10.055 19.3853 8.1755C18.5436 6.48051 17.0293 5.19281 15.2207 4.51639Z\" fill=\"currentColor\"/>\n\n </symbol>\n</svg>\n`;\n\nexport default ICON_SPRITE;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { QuickActionId, QuickActionMenu } from './types';\nimport { Output, QuickAction } from '../provider';\n\nconst QUICK_ACTION_ORDER_KEY_PREFIX = 'ly.img.ai.quickAction.order';\n\nconst QUICK_ACTION_REGISTRY_PREFIX = 'ly.img.ai.quickAction.actions';\n\n/**\n * Returns an object representing the quick action menu. Can be called and\n * retrieved multiple times.\n *\n * It's backed up by the global state.\n */\nfunction getQuickActionMenu(cesdk: CreativeEditorSDK, id: string) {\n const quickActionMenu: QuickActionMenu = {\n id,\n setQuickActionMenuOrder: (quickActionIds: string[]) => {\n cesdk.ui.experimental.setGlobalStateValue<QuickActionId[]>(\n `${QUICK_ACTION_ORDER_KEY_PREFIX}.${id}`,\n quickActionIds\n );\n },\n getQuickActionMenuOrder: () => {\n return cesdk.ui.experimental.getGlobalStateValue<QuickActionId[]>(\n `${QUICK_ACTION_ORDER_KEY_PREFIX}.${id}`,\n []\n );\n },\n registerQuickAction: <I, O extends Output>(\n quickAction: QuickAction<I, O>\n ) => {\n if (\n !cesdk.ui.experimental.hasGlobalStateValue(\n `${QUICK_ACTION_REGISTRY_PREFIX}.${id}`\n )\n ) {\n cesdk.ui.experimental.setGlobalStateValue<{\n [key: string]: QuickAction<I, O>;\n }>(`${QUICK_ACTION_REGISTRY_PREFIX}.${id}`, {\n [quickAction.id]: quickAction\n });\n } else {\n const entries = cesdk.ui.experimental.getGlobalStateValue(\n `${QUICK_ACTION_REGISTRY_PREFIX}.${id}`,\n {}\n );\n cesdk.ui.experimental.setGlobalStateValue(\n `${QUICK_ACTION_REGISTRY_PREFIX}.${id}`,\n {\n ...entries,\n [quickAction.id]: quickAction\n }\n );\n }\n },\n\n getQuickAction: <I, O extends Output>(quickActionId: string) => {\n const entries = cesdk.ui.experimental.getGlobalStateValue<{\n [key: string]: QuickAction<I, O>;\n }>(`${QUICK_ACTION_REGISTRY_PREFIX}.${id}`, {});\n\n return entries[quickActionId];\n }\n };\n return quickActionMenu;\n}\n\nexport default getQuickActionMenu;\n", "import { Output, QuickAction } from '../provider';\n\nexport const INFERENCE_AI_EDIT_MODE = 'ly.img.ai.inference.editMode';\n\nexport const INFERENCE_AI_METADATA_KEY = 'ly.img.ai.inference.metadata';\n\nexport const INFERENCE_CONFIRMATION_COMPONENT_ID =\n 'ly.img.ai.inference.confirmation.canvasMenu';\n\nexport function getFeatureIdForQuickAction(options: {\n quickActionId: string;\n quickActionMenuId: string;\n}) {\n return `ly.img.ai.quickAction.${options.quickActionMenuId}.${options.quickActionId}`;\n}\n\n/**\n * Removes all two following `ly.img.separator` entries from the quick\n * actions array or if it is first or last in the array.\n */\nexport function removeDuplicatedSeparators<I, O extends Output>(\n quickActions: (QuickAction<I, O> | 'ly.img.separator')[]\n): (QuickAction<I, O> | 'ly.img.separator')[] {\n if (quickActions.length === 0) {\n return [];\n }\n\n // Create a new array for the result\n const result = [...quickActions];\n\n // Remove separators at the beginning\n while (result.length > 0 && result[0] === 'ly.img.separator') {\n result.shift();\n }\n\n // Remove separators at the end\n while (\n result.length > 0 &&\n result[result.length - 1] === 'ly.img.separator'\n ) {\n result.pop();\n }\n\n // Remove consecutive separators\n return result.reduce<(QuickAction<I, O> | 'ly.img.separator')[]>(\n (acc, current) => {\n // Skip if current is a separator and previous was also a separator\n if (\n current === 'ly.img.separator' &&\n acc.length > 0 &&\n acc[acc.length - 1] === 'ly.img.separator'\n ) {\n return acc;\n }\n\n acc.push(current);\n return acc;\n },\n []\n );\n}\n", "import { Middleware } from './middleware';\nimport { Output } from '../provider';\n\n/**\n * Highlights the blocks while the middleware is running.\n *\n * - Sets the blocks to always on top\n * - Disables clipping of the parent of the blocks so it is visible\n */\nfunction highlightBlocksMiddleware<I, O extends Output>({\n alwaysOnTop = true,\n disableClipping = true\n}: {\n /**\n * Until disposed, should the block be always on top to be visible?\n *\n * @default true\n */\n alwaysOnTop?: boolean;\n\n /**\n * If true, the clipping of the parent of the affected blocks will be\n * temporarily disabled until unlocked.\n *\n * @default true\n */\n disableClipping?: boolean;\n}): Middleware<I, O> {\n const middleware: Middleware<I, O> = async (input, options, next) => {\n const wasAlwaysOnTop: Record<number, boolean> = {};\n const parentClipping: Record<number, boolean> = {};\n\n const blockIds =\n alwaysOnTop || disableClipping\n ? options.blockIds ?? options.engine.block.findAllSelected()\n : [];\n\n blockIds.forEach((blockId) => {\n if (options.engine.block.isValid(blockId))\n if (alwaysOnTop) {\n wasAlwaysOnTop[blockId] = options.engine.block.isAlwaysOnTop(blockId);\n options.engine.block.setAlwaysOnTop(blockId, true);\n }\n if (disableClipping) {\n const parent = options.engine.block.getParent(blockId);\n if (\n parent != null &&\n options.engine.block.getType(parent) !== '//ly.img.ubq/scene'\n ) {\n parentClipping[parent] = options.engine.block.isClipped(parent);\n options.engine.block.setClipped(parent, false);\n }\n }\n });\n\n options.addDisposer(async () => {\n blockIds.forEach((blockId) => {\n if (options.engine.block.isValid(blockId))\n if (alwaysOnTop) {\n options.engine.block.setAlwaysOnTop(\n blockId,\n wasAlwaysOnTop[blockId]\n );\n }\n if (disableClipping) {\n const parent = options.engine.block.getParent(blockId);\n if (\n parent != null &&\n options.engine.block.getType(parent) !== '//ly.img.ubq/scene'\n ) {\n if (parentClipping[parent] != null) {\n options.engine.block.setClipped(parent, parentClipping[parent]);\n }\n }\n }\n });\n });\n const result = await next(input, options);\n\n return result;\n };\n\n return middleware;\n}\n\nexport default highlightBlocksMiddleware;\n", "import { Middleware } from './middleware';\nimport { Output } from '../provider';\n\n/**\n * Sets the blocks to a pending state while the middleware is running.\n */\nfunction pendingMiddleware<I, O extends Output>({\n pending = true\n}: {\n /**\n * Should the blocks be set to a pending state?\n *\n * @default true\n */\n pending?: boolean;\n}): Middleware<I, O> {\n const middleware: Middleware<I, O> = async (input, options, next) => {\n const blockIds = pending\n ? options.blockIds ?? options.engine.block.findAllSelected()\n : [];\n\n try {\n blockIds.forEach((blockId) => {\n if (options.engine.block.isValid(blockId))\n options.engine.block.setState(blockId, {\n type: 'Pending',\n progress: 0\n });\n });\n const result = await next(input, options);\n\n return result;\n } finally {\n blockIds.forEach((blockId) => {\n if (options.engine.block.isValid(blockId))\n options.engine.block.setState(blockId, { type: 'Ready' });\n });\n }\n };\n\n return middleware;\n}\n\nexport default pendingMiddleware;\n", "import { Middleware } from './middleware';\nimport { Output } from '../provider';\nimport { CreativeEngine } from '@cesdk/cesdk-js';\nimport { isAbortError } from '../../utils';\n\n/**\n * Highlights the blocks while the middleware is running.\n */\nfunction lockMiddleware<I, O extends Output>({\n editMode,\n automaticallyUnlock = false\n}: {\n /**\n * The edit mode to lock the selection to.\n */\n editMode: string;\n\n /**\n * Should the selection be automatically unlocked after the function completes?\n * Otherwise the returned unlock function must be called manually.\n *\n * @default false\n */\n automaticallyUnlock?: boolean;\n}): Middleware<I, O> {\n const middleware: Middleware<I, O> = async (input, options, next) => {\n const blockIds = options.blockIds ?? options.engine.block.findAllSelected();\n\n let unlock: () => void = () => {};\n if (!automaticallyUnlock) {\n options.addDisposer(async () => {\n if (unlock != null) {\n unlock();\n }\n });\n }\n try {\n unlock = lockSelectionInEditMode(options.engine, blockIds, editMode);\n const result = await next(input, options);\n return result;\n } catch (error) {\n if (isAbortError(error)) {\n unlock();\n }\n throw error;\n } finally {\n if (automaticallyUnlock) {\n unlock();\n }\n }\n };\n\n return middleware;\n}\n\n/**\n * Locks the selection to the given block ids with the given edit mode.\n *\n * @returns A function to unlock the selection. Will set the edit mode back to what it was before the lock.\n */\nfunction lockSelectionInEditMode(\n engine: CreativeEngine,\n blockIdsToLockOn: number[],\n editModeToLock: string\n) {\n const globalScopeBeforeLock = engine.editor.getGlobalScope('editor/select');\n const editModeBeforeLock = engine.editor.getEditMode();\n selectOnlyBlockIds();\n engine.editor.setGlobalScope('editor/select', 'Deny');\n engine.editor.setEditMode(editModeToLock);\n const lockedHistory = engine.editor.createHistory();\n const historyBeforeLock = engine.editor.getActiveHistory();\n engine.editor.setActiveHistory(lockedHistory);\n\n function selectOnlyBlockIds() {\n engine.block.findAllSelected().forEach((currentlySelectedBlockId) => {\n if (!blockIdsToLockOn.includes(currentlySelectedBlockId)) {\n engine.block.setSelected(currentlySelectedBlockId, false);\n }\n });\n\n blockIdsToLockOn.forEach((blockId) => {\n engine.block.setSelected(blockId, true);\n });\n }\n\n const stateChangeDisposer = engine.editor.onStateChanged(() => {\n const editMode = engine.editor.getEditMode();\n if (editMode !== editModeToLock) {\n engine.editor.setEditMode(editModeToLock);\n }\n });\n\n const selectionDisposer = engine.block.onSelectionChanged(selectOnlyBlockIds);\n\n const dispose = () => {\n if (globalScopeBeforeLock != null) {\n engine.editor.setGlobalScope('editor/select', globalScopeBeforeLock);\n }\n\n engine.editor.setEditMode(editModeBeforeLock);\n engine.editor.setActiveHistory(historyBeforeLock);\n engine.editor.destroyHistory(lockedHistory);\n\n selectionDisposer();\n stateChangeDisposer();\n };\n\n return dispose;\n}\n\nexport default lockMiddleware;\n", "import type CreativeEditorSDK from '@cesdk/cesdk-js';\nimport {\n GenerationResult,\n ImageOutput,\n TextOutput,\n type Output,\n type OutputKind\n} from '../provider';\nimport { ApplyCallbacks } from './types';\nimport {\n getImageDimensionsFromURL,\n mimeTypeToExtension\n} from '@imgly/plugin-utils';\nimport { isAsyncGenerator } from '../../utils';\n\ntype ConsumeGeneratedResultOptions = {\n kind: OutputKind;\n blockIds: number[];\n cesdk: CreativeEditorSDK;\n abortSignal: AbortSignal;\n};\n\ntype ReturnValue<O extends Output> = {\n consumedGenerationResult: O;\n applyCallbacks: ApplyCallbacks;\n};\n\n/**\n * This method is used in the quick action menu to handle the result of the generation\n * and providing methods for the comparision of the result.\n *\n * Different output kinds require different handling. E.g. the text generation\n * is streamed to the text block, while the image generation is applied to the fill\n * block with a source set and the same crop applied.\n */\nfunction consumeGeneratedResult<O extends Output>(\n result: GenerationResult<O>,\n options: ConsumeGeneratedResultOptions\n): Promise<ReturnValue<O>> {\n switch (options.kind) {\n case 'text':\n return getApplyCallbacksForText(result, options);\n case 'image':\n return getApplyCallbacksForImage(result, options);\n case 'video':\n return getApplyCallbacksForVideo(result, options);\n case 'audio':\n return getApplyCallbacksForAudio(result, options);\n default:\n throw new Error(\n `Unsupported output kind for quick actions: ${options.kind}`\n );\n }\n}\n\nasync function getApplyCallbacksForText<O extends Output>(\n generationResult: GenerationResult<O>,\n options: ConsumeGeneratedResultOptions\n): Promise<ReturnValue<O>> {\n const { cesdk, blockIds, abortSignal } = options;\n\n const beforeTexts = blockIds.map((blockId) => {\n return cesdk.engine.block.getString(blockId, 'text/text');\n });\n\n let output: O | undefined;\n if (isAsyncGenerator(generationResult)) {\n let inferredText = '';\n for await (const chunk of generationResult) {\n if (abortSignal.aborted) {\n break;\n }\n if (typeof chunk === 'string') {\n inferredText = chunk;\n } else if (chunk.kind === 'text') {\n inferredText = chunk.text;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-loop-func\n blockIds.forEach((blockId) => {\n cesdk.engine.block.setString(blockId, 'text/text', inferredText);\n });\n\n const textOutput: TextOutput = {\n kind: 'text',\n text: inferredText\n };\n output = textOutput as O;\n }\n } else {\n output = generationResult;\n }\n\n if (output == null || output.kind !== 'text') {\n throw new Error('Output kind from generation is not text');\n }\n\n const onAfter = () => {\n options.blockIds.forEach((blockId) => {\n options.cesdk.engine.block.setString(blockId, 'text/text', output.text);\n });\n };\n const onBefore = () => {\n options.blockIds.forEach((blockId, i) => {\n options.cesdk.engine.block.setString(\n blockId,\n 'text/text',\n beforeTexts[i]\n );\n });\n };\n const onCancel = onBefore;\n const onApply = () => {\n onAfter();\n options.cesdk.engine.editor.addUndoStep();\n };\n\n return {\n consumedGenerationResult: output,\n applyCallbacks: {\n onBefore,\n onAfter,\n onCancel,\n onApply\n }\n };\n}\n\nasync function getApplyCallbacksForImage<O extends Output>(\n generationResult: GenerationResult<O>,\n options: ConsumeGeneratedResultOptions\n): Promise<ReturnValue<O>> {\n const { cesdk, blockIds, abortSignal } = options;\n if (blockIds.length !== 1) {\n throw new Error('Only one block is supported for image generation');\n }\n\n const [block] = blockIds;\n const fillBlock = cesdk.engine.block.getFill(block);\n const sourceSetBefore = cesdk.engine.block.getSourceSet(\n fillBlock,\n 'fill/image/sourceSet'\n );\n const [sourceBefore] = sourceSetBefore;\n let uriBefore: string | undefined;\n if (sourceBefore == null) {\n uriBefore = cesdk.engine.block.getString(\n fillBlock,\n 'fill/image/imageFileURI'\n );\n }\n\n const mimeType = await cesdk.engine.editor.getMimeType(\n sourceBefore?.uri ?? uriBefore\n );\n const originalDimension = await getImageDimensionsFromURL(\n sourceBefore?.uri ?? uriBefore,\n options.cesdk.engine\n );\n const originalAspectRatio =\n originalDimension.width / originalDimension.height;\n abortSignal.throwIfAborted();\n\n if (mimeType === 'image/svg+xml') {\n throw new Error('SVG images are not supported');\n }\n\n const cropScaleX = cesdk.engine.block.getCropScaleX(block);\n const cropScaleY = cesdk.engine.block.getCropScaleY(block);\n const cropTranslationX = cesdk.engine.block.getCropTranslationX(block);\n const cropTranslationY = cesdk.engine.block.getCropTranslationY(block);\n const cropRotation = cesdk.engine.block.getCropRotation(block);\n\n const applyCrop = () => {\n cesdk.engine.block.setCropScaleX(block, cropScaleX);\n cesdk.engine.block.setCropScaleY(block, cropScaleY);\n cesdk.engine.block.setCropTranslationX(block, cropTranslationX);\n cesdk.engine.block.setCropTranslationY(block, cropTranslationY);\n cesdk.engine.block.setCropRotation(block, cropRotation);\n };\n\n if (isAsyncGenerator(generationResult)) {\n throw new Error('Streaming generation is not supported yet from a panel');\n }\n\n if (\n generationResult.kind !== 'image' ||\n typeof generationResult.url !== 'string'\n ) {\n throw new Error('Output kind from generation is not an image');\n }\n\n const url = (generationResult as ImageOutput).url;\n const generatedMimeType = await cesdk.engine.editor.getMimeType(url);\n\n const uri = await reuploadImage(cesdk, url, generatedMimeType);\n const generatedDimension = await getImageDimensionsFromURL(\n uri,\n options.cesdk.engine\n );\n const generatedAspectRatio =\n generatedDimension.width / generatedDimension.height;\n\n const differentAspectRatio =\n Math.abs(originalAspectRatio - generatedAspectRatio) > 0.001;\n\n const sourceSetAfter = sourceBefore\n ? [\n {\n uri,\n width: generatedDimension.width,\n height: generatedDimension.height\n }\n ]\n : undefined;\n const uriAfter = uri;\n\n if (sourceSetAfter == null) {\n cesdk.engine.block.setString(\n fillBlock,\n 'fill/image/imageFileURI',\n uriAfter\n );\n } else {\n cesdk.engine.block.setString(fillBlock, 'fill/image/imageFileURI', '');\n cesdk.engine.block.setSourceSet(\n fillBlock,\n 'fill/image/sourceSet',\n sourceSetAfter\n );\n }\n if (differentAspectRatio) {\n cesdk.engine.block.setContentFillMode(block, 'Cover');\n } else {\n applyCrop();\n }\n\n const onBefore = () => {\n if (sourceSetBefore == null || sourceSetBefore.length === 0) {\n if (uriBefore == null) {\n throw new Error('No image URI found');\n }\n cesdk.engine.block.setString(\n fillBlock,\n 'fill/image/imageFileURI',\n uriBefore\n );\n } else {\n cesdk.engine.block.setSourceSet(\n fillBlock,\n 'fill/image/sourceSet',\n sourceSetBefore\n );\n }\n applyCrop();\n };\n const onAfter = () => {\n if (sourceSetAfter == null) {\n if (uriAfter == null) {\n throw new Error('No image URI found');\n }\n cesdk.engine.block.setString(\n fillBlock,\n 'fill/image/imageFileURI',\n uriAfter\n );\n } else {\n cesdk.engine.block.setSourceSet(\n fillBlock,\n 'fill/image/sourceSet',\n sourceSetAfter\n );\n }\n if (differentAspectRatio) {\n cesdk.engine.block.setContentFillMode(block, 'Cover');\n } else {\n applyCrop();\n }\n };\n const onCancel = () => {\n onBefore();\n };\n const onApply = () => {\n onAfter();\n options.cesdk.engine.editor.addUndoStep();\n };\n\n return {\n consumedGenerationResult: generationResult,\n applyCallbacks: {\n onBefore,\n onAfter,\n onCancel,\n onApply\n }\n };\n}\n\nasync function getApplyCallbacksForVideo<O extends Output>(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _result: GenerationResult<O>,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _options: ConsumeGeneratedResultOptions\n): Promise<ReturnValue<O>> {\n throw new Error('Function not implemented.');\n}\n\nasync function getApplyCallbacksForAudio<O extends Output>(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _result: GenerationResult<O>,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _options: ConsumeGeneratedResultOptions\n): Promise<ReturnValue<O>> {\n throw new Error('Function not implemented.');\n}\n\nasync function reuploadImage(\n cesdk: CreativeEditorSDK,\n url: string,\n mimeType: string\n): Promise<string> {\n const response = await fetch(url);\n const blob = await response.blob();\n const file = new File([blob], `image.${mimeTypeToExtension(mimeType)}`, {\n type: mimeType\n });\n const assetDefinition = await cesdk.unstable_upload(file, () => {});\n const uploadedUri = assetDefinition?.meta?.uri;\n if (uploadedUri != null) return uploadedUri;\n // eslint-disable-next-line no-console\n console.warn('Failed to upload image:', assetDefinition);\n return url;\n}\n\nexport default consumeGeneratedResult;\n", "import { Middleware } from './middleware';\nimport { Output } from '../provider';\nimport { CreativeEngine } from '@cesdk/cesdk-js';\nimport { isAbortError } from '../../utils';\n\n/**\n * For a given edit mode and block ids, this middleware will\n * ensure that as long as these blocks are selected, the edit mode is\n * set to the given edit mode and cannot be changed.\n *\n * The use-case is to show only the generation canvas menu during\n * the generation process.\n */\nfunction editModeMiddleware<I, O extends Output>({\n editMode,\n automaticallyUnlock = false,\n showNotification = true\n}: {\n /**\n * The edit mode to lock the selection to.\n */\n editMode: string;\n\n /**\n * Should the selection be automatically unlocked after the function completes?\n * Otherwise the returned unlock function must be called manually.\n *\n * @default false\n */\n automaticallyUnlock?: boolean;\n\n /**\n * Should the blocks be set when the generation is done\n *\n * @default true\n */\n showNotification?: boolean;\n}): Middleware<I, O> {\n const middleware: Middleware<I, O> = async (input, options, next) => {\n const blockIds = options.blockIds ?? options.engine.block.findAllSelected();\n\n let unlock: () => void = () => {};\n if (!automaticallyUnlock) {\n options.addDisposer(async () => {\n if (unlock != null) {\n unlock();\n }\n });\n }\n try {\n unlock = bindSelectionToEditMode(options.engine, blockIds, editMode);\n const result = await next(input, options);\n\n if (showNotification) {\n const currentlySelectedBlockIds =\n options.engine.block.findAllSelected();\n const blockIdsAreSelected = blockIds.some((blockId) => {\n return currentlySelectedBlockIds.includes(blockId);\n });\n\n if (!blockIdsAreSelected) {\n options.cesdk?.ui.showNotification({\n type: 'success',\n message: 'AI generation complete',\n action: {\n label: 'Select',\n onClick: () => {\n blockIds.forEach((blockId) => {\n options.engine.block.select(blockId);\n });\n }\n }\n });\n }\n }\n return result;\n } catch (error) {\n if (isAbortError(error)) {\n unlock();\n }\n throw error;\n } finally {\n if (automaticallyUnlock) {\n unlock();\n }\n }\n };\n\n return middleware;\n}\n\n/**\n * Locks the selection to the given block ids with the given edit mode.\n *\n * @returns A function to unlock the selection. Will set the edit mode back to what it was before the lock.\n */\nfunction bindSelectionToEditMode(\n engine: CreativeEngine,\n blockIdsToBind: number[],\n editModeToBindTo: string\n) {\n function isBoundBlockSelected() {\n const currentlySelectedBlockIds = engine.block.findAllSelected();\n return blockIdsToBind.some((blockId) => {\n return currentlySelectedBlockIds.includes(blockId);\n });\n }\n\n const stateChangeDisposer = engine.editor.onStateChanged(() => {\n const editMode = engine.editor.getEditMode();\n if (editMode !== editModeToBindTo && isBoundBlockSelected()) {\n engine.editor.setEditMode(editModeToBindTo);\n }\n });\n\n const selectionDisposer = engine.block.onSelectionChanged(() => {\n if (isBoundBlockSelected()) {\n engine.editor.setEditMode(editModeToBindTo);\n } else {\n engine.editor.setEditMode('Transform');\n }\n });\n\n if (isBoundBlockSelected()) {\n engine.editor.setEditMode(editModeToBindTo);\n }\n\n const dispose = () => {\n selectionDisposer();\n stateChangeDisposer();\n\n engine.editor.setEditMode('Transform');\n };\n\n return dispose;\n}\n\nexport default editModeMiddleware;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { InferenceMetadata, QuickActionMenu, ApplyCallbacks } from './types';\nimport { INFERENCE_AI_EDIT_MODE, INFERENCE_AI_METADATA_KEY } from './utils';\nimport { Metadata } from '@imgly/plugin-utils';\nimport Provider, {\n GenerationOptions,\n Output,\n OutputKind,\n QuickAction\n} from '../provider';\nimport { composeMiddlewares } from '../middleware/middleware';\nimport loggingMiddleware from '../middleware/loggingMiddleware';\nimport highlightBlocksMiddleware from '../middleware/highlightBlocksMiddleware';\nimport pendingMiddleware from '../middleware/pendingMiddleware';\nimport lockMiddleware from '../middleware/lockMiddleware';\nimport consumeGeneratedResult from './consumeGeneratedResult';\nimport editModeMiddleware from '../middleware/editModeMiddleware';\nimport { InitProviderConfiguration } from '../types';\nimport dryRunMiddleware from '../middleware/dryRunMiddleware';\n\nasync function generate<K extends OutputKind, I, O extends Output>(\n options: {\n input: I;\n blockIds: number[];\n cesdk: CreativeEditorSDK;\n quickAction: QuickAction<I, O>;\n quickActionMenu: QuickActionMenu;\n provider: Provider<K, I, O>;\n abortSignal: AbortSignal;\n confirmationComponentId: string;\n },\n config: InitProviderConfiguration\n): Promise<{\n dispose: () => void;\n returnValue: O;\n applyCallbacks?: ApplyCallbacks;\n}> {\n const {\n cesdk,\n input,\n blockIds,\n provider,\n quickAction,\n confirmationComponentId,\n abortSignal\n } = options;\n if (quickAction.confirmation) {\n cesdk.ui.setCanvasMenuOrder([confirmationComponentId], {\n editMode: INFERENCE_AI_EDIT_MODE\n });\n }\n\n const metadata = new Metadata<InferenceMetadata>(\n cesdk.engine,\n INFERENCE_AI_METADATA_KEY\n );\n blockIds.forEach((blockId) => {\n metadata.set(blockId, {\n status: 'processing',\n quickActionId: quickAction.id\n });\n });\n\n const generationOptions: GenerationOptions = {\n cesdk,\n engine: cesdk.engine,\n abortSignal\n };\n\n const composedMiddlewares = composeMiddlewares<I, O>([\n ...(provider.output.middleware ?? []),\n config.debug ? loggingMiddleware() : undefined,\n pendingMiddleware({}),\n ...(quickAction.confirmation\n ? [\n quickAction.lockDuringConfirmation\n ? lockMiddleware<I, O>({\n editMode: INFERENCE_AI_EDIT_MODE\n })\n : editModeMiddleware<I, O>({\n editMode: INFERENCE_AI_EDIT_MODE\n }),\n quickAction.confirmation && highlightBlocksMiddleware<I, O>({})\n ]\n : []),\n config.dryRun\n ? dryRunMiddleware({ kind: provider.kind, blockIds })\n : undefined\n ]);\n\n const { result: generationResult, dispose: generationDispose } =\n await composedMiddlewares(provider.output.generate)(\n input,\n generationOptions\n );\n\n const { consumedGenerationResult, applyCallbacks } =\n await consumeGeneratedResult(generationResult, {\n abortSignal,\n kind: provider.kind,\n blockIds,\n cesdk\n });\n\n if (quickAction.confirmation) {\n blockIds.forEach((blockId) => {\n metadata.set(blockId, {\n status: 'confirmation',\n quickActionId: quickAction.id\n });\n });\n } else {\n applyCallbacks.onApply();\n blockIds.forEach((blockId) => {\n metadata.clear(blockId);\n });\n }\n\n const dispose = () => {\n generationDispose();\n blockIds.forEach((blockId) => {\n metadata.clear(blockId);\n });\n };\n\n abortSignal.addEventListener('abort', dispose);\n\n return {\n dispose,\n returnValue: consumedGenerationResult,\n applyCallbacks\n };\n}\n\nexport default generate;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { InferenceMetadata, QuickActionMenu, ApplyCallbacks } from './types';\nimport {\n getFeatureIdForQuickAction,\n INFERENCE_AI_METADATA_KEY,\n removeDuplicatedSeparators\n} from './utils';\nimport { Metadata } from '@imgly/plugin-utils';\nimport Provider, { Output, OutputKind } from '../provider';\nimport { isAbortError } from '../../utils';\nimport { InitProviderConfiguration } from '../types';\nimport handleGenerationError from '../handleGenerationError';\nimport generate from './generate';\n\nfunction registerQuickActionMenuComponent<\n K extends OutputKind,\n I,\n O extends Output\n>(\n options: {\n cesdk: CreativeEditorSDK;\n quickActionMenu: QuickActionMenu;\n provider: Provider<K, I, O>;\n },\n config: InitProviderConfiguration\n) {\n const { cesdk, quickActionMenu, provider } = options;\n\n const prefix = `ly.img.ai.${quickActionMenu.id}`;\n const confirmationPrefix = `${prefix}.confirmation`;\n cesdk.setTranslations({\n en: {\n [`${confirmationPrefix}.apply`]: 'Apply',\n [`${confirmationPrefix}.before`]: 'Before',\n [`${confirmationPrefix}.after`]: 'After',\n [`${prefix}.cancel`]: 'Cancel',\n [`${prefix}.processing`]: 'Generating...'\n }\n });\n const confirmationComponentId = `${confirmationPrefix}.canvasnMenu`;\n\n const shared: {\n unlock: () => void;\n abort: () => void;\n applyCallbacks: ApplyCallbacks | undefined;\n } = {\n unlock: () => {},\n abort: () => {},\n applyCallbacks: undefined\n };\n\n const createAbortSignal = () => {\n const controller = new AbortController();\n const signal = controller.signal;\n shared.abort = () => {\n controller.abort();\n };\n return signal;\n };\n\n cesdk.ui.registerComponent(\n confirmationComponentId,\n ({ builder, engine, state }) => {\n const blockIds = engine.block.findAllSelected();\n if (blockIds.length === 0) return null;\n\n const md = new Metadata<InferenceMetadata>(\n cesdk.engine,\n INFERENCE_AI_METADATA_KEY\n );\n\n // All blocks must have the same metadata\n const metadata = md.get(blockIds[0]);\n if (metadata == null) return null;\n\n const clearMetadata = () => {\n blockIds.forEach((blockId) => {\n md.clear(blockId);\n });\n };\n\n switch (metadata.status) {\n case 'processing': {\n builder.Button(`${prefix}.spinner`, {\n label: [\n `ly.img.ai.inference.${metadata.quickActionId}.processing`,\n `${prefix}.cancel`\n ],\n isLoading: true\n });\n builder.Separator(`${prefix}.separator`);\n builder.Button(`${prefix}.cancel`, {\n icon: '@imgly/Cross',\n tooltip: `${prefix}.cancel`,\n onClick: () => {\n shared.abort();\n clearMetadata();\n }\n });\n\n break;\n }\n\n case 'confirmation': {\n const comparingState = state<'before' | 'after'>(\n `${confirmationPrefix}.comparing`,\n 'after'\n );\n\n const onCancel = shared.applyCallbacks?.onCancel;\n if (onCancel != null) {\n builder.Button(`${confirmationPrefix}.cancel`, {\n icon: '@imgly/Cross',\n tooltip: `${prefix}.cancel`,\n onClick: () => {\n shared.unlock();\n onCancel();\n clearMetadata();\n }\n });\n }\n\n const onBefore = shared.applyCallbacks?.onBefore;\n const onAfter = shared.applyCallbacks?.onAfter;\n\n if (onBefore != null && onAfter != null) {\n builder.ButtonGroup(`${confirmationPrefix}.compare`, {\n children: () => {\n builder.Button(`${confirmationPrefix}.compare.before`, {\n label: `${confirmationPrefix}.before`,\n variant: 'regular',\n isActive: comparingState.value === 'before',\n onClick: () => {\n onBefore();\n comparingState.setValue('before');\n }\n });\n builder.Button(`${confirmationPrefix}.compare.after`, {\n label: `${confirmationPrefix}.after`,\n variant: 'regular',\n isActive: comparingState.value === 'after',\n onClick: () => {\n onAfter();\n comparingState.setValue('after');\n }\n });\n }\n });\n }\n\n const onApply = shared.applyCallbacks?.onApply;\n if (onApply != null) {\n builder.Button(`${confirmationPrefix}.apply`, {\n icon: '@imgly/Checkmark',\n tooltip: `${confirmationPrefix}.apply`,\n color: 'accent',\n isDisabled: comparingState.value !== 'after',\n onClick: () => {\n shared.unlock();\n clearMetadata();\n\n // Activating the old history happens in the next update lop.\n // @ts-ignore\n cesdk.engine.editor._update();\n\n onApply();\n }\n });\n }\n\n break;\n }\n\n default: {\n // noop\n }\n }\n }\n );\n\n const canvasMenuComponentId = `${prefix}.canvasMenu`;\n cesdk.ui.registerComponent(canvasMenuComponentId, (context) => {\n const blockIds = context.engine.block.findAllSelected();\n const isEveryBlockInReadyState = blockIds.every((blockId) => {\n return context.engine.block.getState(blockId).type === 'Ready';\n });\n\n let quickActions = quickActionMenu\n .getQuickActionMenuOrder()\n .map((quickActionId) => {\n if (quickActionId === 'ly.img.separator') return quickActionId;\n const quickAction = quickActionMenu.getQuickAction<I, O>(quickActionId);\n if (quickAction == null) return null;\n\n const isEnabled = cesdk.feature.isEnabled(\n getFeatureIdForQuickAction({\n quickActionId,\n quickActionMenuId: quickActionMenu.id\n }),\n {\n engine: context.engine\n }\n );\n if (!isEnabled) return null;\n\n const scopes = quickAction.scopes;\n if (scopes != null && scopes.length > 0) {\n const isAllowedByScopes = blockIds.every((blockId) => {\n return scopes.every((scope) => {\n return context.engine.block.isAllowedByScope(blockId, scope);\n });\n });\n if (!isAllowedByScopes) return null;\n }\n return quickAction;\n })\n .filter((entry) => entry != null);\n\n quickActions = removeDuplicatedSeparators(quickActions);\n\n if (\n quickActions.length === 0 ||\n quickActions.every((entry) => entry === 'ly.img.separator')\n ) {\n return null;\n }\n\n const { builder, experimental, state } = context;\n const toggleExpandedState = state<string | undefined>(\n `${prefix}.toggleExpandedState`,\n undefined\n );\n\n experimental.builder.Popover(`${prefix}.popover`, {\n icon: '@imgly/Sparkle',\n variant: 'plain',\n isDisabled: !isEveryBlockInReadyState,\n trailingIcon: null,\n children: ({ close }) => {\n builder.Section(`${prefix}.popover.section`, {\n children: () => {\n if (toggleExpandedState.value != null) {\n const expandStateForQuickActionId = toggleExpandedState.value;\n const quickAction = quickActionMenu.getQuickAction<I, O>(\n expandStateForQuickActionId\n );\n\n if (quickAction != null && quickAction.renderExpanded != null) {\n quickAction.renderExpanded(context, {\n blockIds,\n closeMenu: close,\n toggleExpand: () => {\n toggleExpandedState.setValue(undefined);\n },\n handleGenerationError: (error) => {\n handleGenerationError(\n error,\n {\n cesdk,\n provider\n },\n config\n );\n },\n generate: async (input, generateOptions) => {\n try {\n const { returnValue, applyCallbacks, dispose } =\n await generate(\n {\n input,\n quickAction,\n quickActionMenu,\n provider,\n cesdk,\n abortSignal: createAbortSignal(),\n blockIds: generateOptions?.blockIds ?? blockIds,\n confirmationComponentId\n },\n config\n );\n\n shared.unlock = dispose;\n shared.applyCallbacks = applyCallbacks;\n\n return returnValue;\n } catch (error) {\n if (!isAbortError(error)) {\n handleGenerationError(\n error,\n {\n cesdk,\n provider\n },\n config\n );\n }\n throw error;\n }\n }\n });\n\n return;\n }\n }\n\n experimental.builder.Menu(`${prefix}.menu`, {\n children: () => {\n quickActions.forEach((quickAction) => {\n if (quickAction === 'ly.img.separator') {\n builder.Separator(\n `${prefix}.separator.${Math.random().toString()}`\n );\n } else {\n quickAction.render(context, {\n blockIds,\n closeMenu: close,\n handleGenerationError: (error) => {\n handleGenerationError(\n error,\n {\n cesdk,\n provider\n },\n config\n );\n },\n toggleExpand: () => {\n toggleExpandedState.setValue(quickAction.id);\n },\n generate: async (input, generateOptions) => {\n try {\n const { returnValue, applyCallbacks, dispose } =\n await generate(\n {\n input,\n quickAction,\n quickActionMenu,\n provider,\n cesdk,\n abortSignal: createAbortSignal(),\n blockIds: generateOptions?.blockIds ?? blockIds,\n confirmationComponentId\n },\n config\n );\n\n shared.unlock = dispose;\n shared.applyCallbacks = applyCallbacks;\n return returnValue;\n } catch (error) {\n if (!isAbortError(error)) {\n handleGenerationError(\n error,\n {\n cesdk,\n provider\n },\n config\n );\n }\n throw error;\n }\n }\n });\n }\n });\n }\n });\n }\n });\n }\n });\n });\n\n return { canvasMenuComponentId };\n}\n\nexport default registerQuickActionMenuComponent;\n", "import type Provider from './provider';\nimport {\n OutputKind,\n PanelInput,\n QuickActionsInput,\n type Output\n} from './provider';\nimport registerPanelInputSchema from './registerPanelInputSchema';\nimport registerPanelInputCustom from './registerPanelInputCustom';\nimport { InitProviderConfiguration, Options, UIOptions } from './types';\nimport { BuilderRenderFunction, type CreativeEngine } from '@cesdk/cesdk-js';\nimport { IndexedDBAssetSource } from '@imgly/plugin-utils';\nimport icons from '../icons';\nimport getQuickActionMenu from './quickAction/getQuickActionMenu';\nimport { getFeatureIdForQuickAction } from './quickAction/utils';\nimport registerQuickActionMenuComponent from './quickAction/registerQuickActionMenuComponent';\nimport { QuickActionMenu } from './quickAction/types';\n\ntype RenderBuilderFunctions = {\n panel?: BuilderRenderFunction<any>;\n};\n\n/**\n * Initialize the provider. Based on the given options and configuration\n * it will register panels and components that is used to render\n * the provider in the UI.\n *\n * @param provider The provider to initialize.\n * @param options The options to use for the provider.\n * @param config The configuration to use for the provider.\n */\nasync function initProvider<K extends OutputKind, I, O extends Output>(\n provider: Provider<K, I, O>,\n options: Options,\n config: InitProviderConfiguration\n): Promise<{\n renderBuilderFunctions?: RenderBuilderFunctions;\n}> {\n await provider.initialize?.(options);\n const historyAssetSourceId = await initHistory(\n options.engine,\n provider.id,\n provider.output.history ?? '@imgly/local'\n );\n\n if (options.cesdk == null) {\n return {};\n }\n\n const historyAssetLibraryEntryId = historyAssetSourceId\n ? `${provider.id}.history.entry`\n : undefined;\n const uiOptions: UIOptions = {\n ...options,\n cesdk: options.cesdk,\n historyAssetSourceId,\n historyAssetLibraryEntryId,\n i18n: {\n prompt: 'common.ai-generation.prompt.placeholder'\n }\n };\n\n if (historyAssetLibraryEntryId != null && historyAssetSourceId != null) {\n options.cesdk.ui.addAssetLibraryEntry({\n id: historyAssetLibraryEntryId,\n sourceIds: [historyAssetSourceId],\n sortBy: {\n sortKey: 'insertedAt',\n sortingOrder: 'Descending'\n },\n canRemove: true,\n gridItemHeight: 'square',\n gridBackgroundType: 'cover'\n });\n }\n\n options.cesdk.i18n.setTranslations({\n en: {\n 'common.ai-generation.success': 'Generation Successful',\n 'common.ai-generation.failed': 'Generation Failed',\n 'common.ai-generation.generate': 'Generate',\n 'common.ai-generation.prompt.placeholder':\n 'Describe what you want to create...',\n [`panel.${provider.id}`]: getName(provider)\n }\n });\n\n // Avoid adding the icon set multiple times for different providers\n const globalStateIconSetAddedId = `@imgly/plugin-ai-generation.iconSetAdded`;\n if (\n !options.cesdk.ui.experimental.hasGlobalStateValue(\n globalStateIconSetAddedId\n )\n ) {\n options.cesdk.ui.addIconSet('@imgly/plugin-ai-generation', icons);\n options.cesdk.ui.experimental.setGlobalStateValue(\n globalStateIconSetAddedId,\n true\n );\n }\n\n const renderBuilderFunctions = await initInputs(provider, uiOptions, config);\n\n return {\n renderBuilderFunctions\n };\n}\n\nfunction getName(provider: Provider<any, any, any>): string {\n if (provider.name != null) return provider.name;\n switch (provider.kind) {\n case 'image':\n return 'Generate Image';\n case 'video':\n return 'Generate Video';\n case 'audio':\n return 'Generate Audio';\n default:\n return 'Generate Asset';\n }\n}\n\n/**\n * Initialize the history for the provider.\n */\nasync function initHistory(\n engine: CreativeEngine,\n providerId: string,\n history: undefined | false | '@imgly/local' | '@imgly/indexedDB' | string\n): Promise<string | undefined> {\n if (history == null || history === false) return undefined;\n\n if (history === '@imgly/local') {\n const historyId = `${providerId}.history`;\n engine.asset.addLocalSource(historyId);\n return historyId;\n }\n\n if (history === '@imgly/indexedDB') {\n const historyId = `${providerId}.history`;\n engine.asset.addSource(new IndexedDBAssetSource(historyId, engine));\n return historyId;\n }\n\n return history;\n}\n\nasync function initInputs<K extends OutputKind, I, O extends Output>(\n provider: Provider<K, I, O>,\n options: UIOptions,\n config: InitProviderConfiguration\n): Promise<{\n panel?: BuilderRenderFunction<any>;\n}> {\n const result: {\n panel?: BuilderRenderFunction<any>;\n } = {\n panel: undefined\n };\n\n if (provider.input?.panel != null) {\n result.panel = await initPanel(\n provider,\n provider.input.panel,\n options,\n config\n );\n }\n if (provider.input?.quickActions != null) {\n if (config.debug) {\n // eslint-disable-next-line no-console\n console.log(\n `Initializing quick actions for provider '${provider.kind}' (${provider.id})`\n );\n }\n initQuickActions(provider, provider.input.quickActions, options, config);\n }\n\n return result;\n}\n\nasync function initPanel<K extends OutputKind, I, O extends Output>(\n provider: Provider<K, I, O>,\n panelInput: PanelInput<K, I>,\n options: UIOptions,\n config: InitProviderConfiguration\n): Promise<BuilderRenderFunction<any> | undefined> {\n switch (panelInput.type) {\n case 'custom': {\n return registerPanelInputCustom(provider, panelInput, options, config);\n }\n\n case 'schema': {\n return registerPanelInputSchema(provider, panelInput, options, config);\n }\n\n default: {\n if (config.debug) {\n // eslint-disable-next-line no-console\n console.warn(\n // @ts-ignore\n `Invalid panel input type '${panelInput.type}' - skipping`\n );\n }\n }\n }\n}\n\nasync function initQuickActions<K extends OutputKind, I, O extends Output>(\n provider: Provider<K, I, O>,\n quickActionsInput: QuickActionsInput<I, O>,\n options: UIOptions,\n config: InitProviderConfiguration\n) {\n const { cesdk } = options;\n\n const quickActionMenus: { [kind: string]: QuickActionMenu } = {};\n\n quickActionsInput.actions.forEach((quickAction) => {\n const quickActionMenuId = quickAction.kind ?? provider.kind;\n if (quickActionMenus[quickActionMenuId] == null) {\n quickActionMenus[quickActionMenuId] = getQuickActionMenu(\n cesdk,\n quickActionMenuId\n );\n }\n const quickActionMenu = quickActionMenus[quickActionMenuId];\n\n const enable = quickAction.enable ?? true;\n cesdk.feature.enable(\n getFeatureIdForQuickAction({\n quickActionId: quickAction.id,\n quickActionMenuId\n }),\n enable\n );\n quickActionMenu.registerQuickAction(quickAction);\n if (config.debug) {\n // eslint-disable-next-line no-console\n console.log(\n `Registered quick action: '${quickAction.id}' (v${quickAction.version}) to menu '${quickActionMenuId}'`\n );\n }\n });\n\n Object.values(quickActionMenus).forEach((quickActionMenu) => {\n const { canvasMenuComponentId } = registerQuickActionMenuComponent(\n {\n cesdk,\n quickActionMenu,\n provider\n },\n config\n );\n if (config.debug) {\n // eslint-disable-next-line no-console\n console.log(\n `Registered quick action menu component: ${canvasMenuComponentId}`\n );\n }\n });\n}\n\nexport default initProvider;\n", "import { isAsyncGenerator } from '../../utils';\nimport { GenerationResult, Output } from '../provider';\nimport { Middleware } from './middleware';\n\n/**\n * Middleware to upload the output of a generation process.\n *\n * Sometimes it is not possible to use the result of a provider or\n * not even allowed to use it directly. This middleware allows you to upload\n * the result of a generation process to a server or a cloud storage.\n *\n * @param upload The function to upload the output. It should return a promise\n */\nfunction uploadMiddleware<I, O extends Output>(\n upload: (output: O) => Promise<O>\n) {\n const middleware: Middleware<I, O> = async (input, options, next) => {\n const result: GenerationResult<O> | undefined = await next(input, options);\n if (isAsyncGenerator(result)) {\n // No reupload needed, just return the async generator\n return result;\n }\n\n const uploaded = await upload(result);\n return uploaded;\n };\n\n return middleware;\n}\n\nexport default uploadMiddleware;\n", "import { GenerationOptions, Output } from '../provider';\nimport { Middleware } from './middleware';\n\nexport interface RateLimitOptions<I> {\n /**\n * Maximum number of requests allowed in the time window\n */\n maxRequests: number;\n\n /**\n * Time window in milliseconds\n */\n timeWindowMs: number;\n\n /**\n * Optional key function or string to create different rate limits for different inputs\n * - If not provided, all requests share the same 'global' rate limit\n * - If a string is provided, that string is used as a static key\n * - If a function is provided, it generates a key based on input and options\n */\n keyFn?: string | ((input: I, options: GenerationOptions) => string);\n\n /**\n * Callback function that is called when rate limit is exceeded\n * Return value determines if the operation should be rejected (throw error) or allowed\n * If true is returned, the operation will proceed despite exceeding the rate limit\n * If false or undefined is returned, the operation will be rejected with a default error\n */\n onRateLimitExceeded?: (\n input: I,\n options: GenerationOptions,\n rateLimitInfo: {\n key: string;\n currentCount: number;\n maxRequests: number;\n timeWindowMs: number;\n remainingTimeMs: number;\n }\n ) => boolean | Promise<boolean> | void;\n\n /**\n * Optional database name for the IndexedDB store\n * If not provided, a default name will be used\n */\n dbName?: string;\n\n /**\n * Disable the rate limit middleware\n */\n disable?: boolean | (() => boolean);\n}\n\n// Store for tracking requests per key\ninterface RequestTracker {\n timestamps: number[];\n lastCleanup: number;\n}\n\n// In-memory fallback store for rate limits for environments without IndexedDB\n// Export for testing purposes\n// This is now a Map of middleware instances to their respective stores\n// The key can be either a symbol (for unique instances with prefix) or a string (for shared instances without prefix)\nexport const inMemoryStores: Map<\n symbol | string,\n Record<string, RequestTracker>\n> = new Map();\n\n/**\n * IndexedDB store for rate limiting\n */\nclass RateLimitStore {\n private db: IDBDatabase | null = null;\n\n private readonly dbName: string;\n\n private readonly storeName: string;\n\n private readonly dbVersion: number = 1;\n\n private isInitializing: boolean = false;\n\n private initPromise: Promise<void> | null = null;\n\n private readonly instanceId: symbol | string;\n\n constructor(\n instanceId: symbol | string,\n dbName?: string,\n storeName?: string\n ) {\n this.instanceId = instanceId;\n this.dbName = dbName ?? 'ly.img.ai.rateLimit';\n this.storeName = storeName ?? 'rateLimits';\n }\n\n /**\n * Initialize the database connection\n */\n async initialize(): Promise<void> {\n if (this.db) {\n return;\n }\n\n if (this.isInitializing) {\n return this.initPromise!;\n }\n\n this.isInitializing = true;\n this.initPromise = new Promise<void>((resolve, reject) => {\n try {\n const request = indexedDB.open(this.dbName, this.dbVersion);\n\n request.onerror = (event) => {\n this.isInitializing = false;\n\n // eslint-disable-next-line no-console\n console.error('Failed to open IndexedDB for rate limiting:', event);\n reject(new Error('Failed to open IndexedDB for rate limiting'));\n };\n\n request.onupgradeneeded = (event) => {\n const db = (event.target as IDBOpenDBRequest).result;\n if (!db.objectStoreNames.contains(this.storeName)) {\n db.createObjectStore(this.storeName, { keyPath: 'id' });\n }\n };\n\n request.onsuccess = (event) => {\n this.db = (event.target as IDBOpenDBRequest).result;\n this.isInitializing = false;\n resolve();\n };\n } catch (error) {\n this.isInitializing = false;\n // eslint-disable-next-line no-console\n console.error('Error initializing IndexedDB:', error);\n reject(error);\n }\n });\n\n return this.initPromise;\n }\n\n /**\n * Get a request tracker by key\n */\n async getTracker(key: string): Promise<RequestTracker | null> {\n try {\n await this.initialize();\n\n // Create a combined key that includes the instance ID to ensure isolation\n const instanceIdStr =\n typeof this.instanceId === 'symbol'\n ? this.instanceId.description || ''\n : this.instanceId;\n const combinedKey = `${instanceIdStr}_${key}`;\n\n return await new Promise((resolve, reject) => {\n const transaction = this.db!.transaction(this.storeName, 'readonly');\n const store = transaction.objectStore(this.storeName);\n const request = store.get(combinedKey);\n\n request.onsuccess = () => {\n if (request.result) {\n resolve(request.result.data);\n } else {\n resolve(null);\n }\n };\n\n request.onerror = () => {\n // eslint-disable-next-line no-console\n console.error(\n `Failed to get tracker for key ${combinedKey}:`,\n request.error\n );\n reject(request.error);\n };\n });\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error getting tracker from IndexedDB:', error);\n return Promise.reject(error);\n }\n }\n\n /**\n * Save a request tracker by key\n */\n async saveTracker(key: string, tracker: RequestTracker): Promise<void> {\n try {\n await this.initialize();\n\n // Create a combined key that includes the instance ID to ensure isolation\n const instanceIdStr =\n typeof this.instanceId === 'symbol'\n ? this.instanceId.description || ''\n : this.instanceId;\n const combinedKey = `${instanceIdStr}_${key}`;\n\n return await new Promise((resolve, reject) => {\n const transaction = this.db!.transaction(this.storeName, 'readwrite');\n const store = transaction.objectStore(this.storeName);\n store.put({ id: combinedKey, data: tracker });\n\n transaction.oncomplete = () => {\n resolve();\n };\n\n transaction.onerror = () => {\n // eslint-disable-next-line no-console\n console.error(\n `Failed to save tracker for key ${combinedKey}:`,\n transaction.error\n );\n reject(transaction.error);\n };\n });\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error saving tracker to IndexedDB:', error);\n return Promise.reject(error);\n }\n }\n\n /**\n * Check if IndexedDB is available\n */\n static isAvailable(): boolean {\n return typeof indexedDB !== 'undefined';\n }\n\n /**\n * Close the database connection\n */\n close(): void {\n if (this.db) {\n this.db.close();\n this.db = null;\n }\n }\n}\n\n/**\n * Middleware that implements rate limiting for AI generation requests\n * Uses IndexedDB for storage when available, with in-memory fallback\n * Each middleware instance has its own isolated set of rate limits\n */\nfunction rateLimitMiddleware<I, O extends Output>(\n middlewareOptions: RateLimitOptions<I>\n) {\n const {\n maxRequests,\n timeWindowMs,\n keyFn = () => 'global',\n onRateLimitExceeded,\n dbName\n } = middlewareOptions;\n\n // Create an identifier for this middleware instance based on its configuration\n // This ensures persistence across page reloads and sharing between identical configurations\n const configStr = `rate-limit-middleware-${maxRequests}-${timeWindowMs}`;\n\n // Use a string key for the configuration so identical configurations share the same limits\n const instanceId = configStr;\n\n // Create the store with the instance ID\n const useIndexedDB = RateLimitStore.isAvailable();\n const store = useIndexedDB ? new RateLimitStore(instanceId, dbName) : null;\n\n // Initialize this middleware's in-memory store\n if (!inMemoryStores.has(instanceId)) {\n inMemoryStores.set(instanceId, {});\n }\n // Get this middleware's in-memory store\n const inMemoryStore = inMemoryStores.get(instanceId)!;\n\n const middleware: Middleware<I, O> = async (input, options, next) => {\n if (\n typeof middlewareOptions.disable === 'function'\n ? middlewareOptions.disable()\n : middlewareOptions.disable\n ) {\n return next(input, options);\n }\n // Get rate limit key based on input using the provided keyFn\n // If keyFn is a string, use it directly; otherwise call the function\n const key = typeof keyFn === 'string' ? keyFn : keyFn(input, options);\n const now = Date.now();\n\n let tracker: RequestTracker;\n\n // Get tracker from IndexedDB or create a new one\n if (useIndexedDB && store) {\n try {\n const storedTracker = await store.getTracker(key);\n if (storedTracker) {\n tracker = storedTracker;\n } else {\n tracker = {\n timestamps: [],\n lastCleanup: now\n };\n }\n } catch (error) {\n // Fallback to in-memory store if IndexedDB fails\n // eslint-disable-next-line no-console\n console.error(\n 'IndexedDB access failed, using in-memory fallback:',\n error\n );\n if (!inMemoryStore[key]) {\n inMemoryStore[key] = {\n timestamps: [],\n lastCleanup: now\n };\n }\n tracker = inMemoryStore[key];\n }\n } else {\n // Use in-memory store if IndexedDB is not available\n if (!inMemoryStore[key]) {\n inMemoryStore[key] = {\n timestamps: [],\n lastCleanup: now\n };\n }\n tracker = inMemoryStore[key];\n }\n\n // Clean up old timestamps that are outside the time window\n if (now - tracker.lastCleanup > timeWindowMs) {\n tracker.timestamps = tracker.timestamps.filter(\n (timestamp) => now - timestamp < timeWindowMs\n );\n tracker.lastCleanup = now;\n }\n\n // Check if rate limit is exceeded\n if (tracker.timestamps.length >= maxRequests) {\n // Calculate the time until the oldest request expires\n const oldestTimestamp = Math.min(...tracker.timestamps);\n const remainingTimeMs = Math.max(\n 0,\n timeWindowMs - (now - oldestTimestamp)\n );\n\n // Call the rate limit exceeded callback if provided\n if (onRateLimitExceeded) {\n const rateLimitInfo = {\n key, // This is the baseKey from keyFn\n currentCount: tracker.timestamps.length,\n maxRequests,\n timeWindowMs,\n remainingTimeMs\n };\n\n // If callback returns true, allow the request to proceed\n const shouldProceed = await onRateLimitExceeded(\n input,\n options,\n rateLimitInfo\n );\n if (!shouldProceed) {\n // The callback should indicate the error, so we throw\n // an abort error instead of a generic error to indicate\n // the generation was aborted and we do not show any further\n // error notification.\n throw new DOMException(\n 'Operation aborted: Rate limit exceeded',\n 'AbortError'\n );\n }\n } else {\n // Default behavior: throw an error\n throw new Error('Rate limit exceeded. Please try again later.');\n }\n }\n\n // Add current timestamp to the tracker\n tracker.timestamps.push(now);\n\n // Save the updated tracker\n if (useIndexedDB && store) {\n try {\n await store.saveTracker(key, tracker);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Failed to save tracker to IndexedDB:', error);\n // In case of IndexedDB failure, update the in-memory store as fallback\n inMemoryStore[key] = tracker;\n }\n } else {\n inMemoryStore[key] = tracker;\n }\n\n // Continue with the next middleware\n return next(input, options);\n };\n\n return middleware;\n}\n\nexport default rateLimitMiddleware;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\n\n/**\n * Registers a dock component for AI generation that opens\n * the AI generation panel and closes any other AI panels.\n */\nfunction registerDockComponent(options: {\n cesdk: CreativeEditorSDK;\n panelId: string;\n}) {\n const { cesdk, panelId } = options;\n if (panelId.startsWith('ly.img.ai/')) {\n // eslint-disable-next-line no-console\n console.warn(\n `Dock components for AI generation should open a panel with an id starting with \"ly.img.ai/\" \u2013 \"${panelId}\" was provided.`\n );\n }\n\n const dockComponentId = `${panelId}.dock`;\n cesdk.ui.registerComponent(dockComponentId, ({ builder }) => {\n const isOpen = cesdk.ui.isPanelOpen(panelId);\n\n builder.Button(`${panelId}.dock.button`, {\n label: `${panelId}.dock.label`,\n isSelected: isOpen,\n icon: '@imgly/Sparkle',\n onClick: () => {\n cesdk.ui.findAllPanels().forEach((panel) => {\n if (panel.startsWith('ly.img.ai/')) {\n cesdk.ui.closePanel(panel);\n }\n if (!isOpen && panel === '//ly.img.panel/assetLibrary') {\n cesdk.ui.closePanel(panel);\n }\n });\n\n if (!isOpen) {\n cesdk.ui.openPanel(panelId);\n } else {\n cesdk.ui.closePanel(panelId);\n }\n }\n });\n });\n}\n\nexport default registerDockComponent;\n", "import { ButtonOptions, TextAreaOptions } from '@cesdk/cesdk-js';\nimport { Output, QuickAction, QuickActionContext } from '../../provider';\n\n/**\n * Quick action base for quick actions that require a prompt.\n * Will render a text area for the prompt.\n */\nfunction QuickActionBasePrompt<I, O extends Output>(options: {\n buttonOptions?: ButtonOptions;\n textAreaOptions?: TextAreaOptions;\n quickAction: Omit<QuickAction<I, O>, 'render' | 'renderExpanded'>;\n onApply: (prompt: string, context: QuickActionContext<I, O>) => Promise<O>;\n}): QuickAction<I, O> {\n const id = options.quickAction.id;\n return {\n confirmation: true,\n lockDuringConfirmation: false,\n ...options.quickAction,\n render: ({ builder }, { toggleExpand }) => {\n builder.Button(`${id}.button`, {\n label: `ly.img.ai.quickAction.${id}`,\n icon: '@imgly/Sparkle',\n labelAlignment: 'left',\n variant: 'plain',\n ...options.buttonOptions,\n onClick: toggleExpand\n });\n },\n renderExpanded: ({ builder, state, experimental }, context) => {\n const promptState = state(`${id}.prompt`, '');\n\n builder.TextArea(`${id}.textarea`, {\n inputLabel: `ly.img.ai.quickAction.${id}.prompt.inputLabel`,\n placeholder: `ly.img.ai.quickAction.${id}.prompt.placeholder`,\n ...options.textAreaOptions,\n ...promptState\n });\n\n builder.Separator(`${id}.separator`);\n\n experimental.builder.ButtonRow(`${id}.footer`, {\n justifyContent: 'space-between',\n children: () => {\n builder.Button(`${id}.footer.cancel`, {\n label: 'common.back',\n icon: '@imgly/ChevronLeft',\n onClick: context.toggleExpand\n });\n\n builder.Button(`${id}.footer.apply`, {\n label: `ly.img.ai.quickAction.${id}.apply`,\n icon: '@imgly/MagicWand',\n color: 'accent',\n isDisabled: promptState.value.length === 0,\n onClick: async () => {\n try {\n const prompt = promptState.value;\n if (!prompt) return;\n\n options.onApply(prompt, context);\n context.toggleExpand();\n context.closeMenu();\n } catch (error) {\n context.handleGenerationError(error);\n }\n }\n });\n }\n });\n }\n };\n}\n\nexport default QuickActionBasePrompt;\n", "import { ButtonOptions } from '@cesdk/cesdk-js';\nimport { Output, QuickAction, QuickActionContext } from '../../provider';\n\n/**\n * Quick action base for quick actions to open a panel.\n */\nfunction QuickActionBaseButton<I, O extends Output>(options: {\n buttonOptions?: ButtonOptions;\n quickAction: Omit<QuickAction<I, O>, 'render' | 'renderExpanded'>;\n\n onClick: (context: QuickActionContext<I, O>) => Promise<void>;\n}): QuickAction<I, O> {\n const id = options.quickAction.id;\n return {\n confirmation: true,\n lockDuringConfirmation: false,\n ...options.quickAction,\n render: ({ builder }, context) => {\n builder.Button(`${id}.button`, {\n label: `ly.img.ai.quickAction.${id}`,\n icon: '@imgly/Sparkle',\n labelAlignment: 'left',\n variant: 'plain',\n ...options.buttonOptions,\n onClick: async () => {\n try {\n options.onClick(context);\n context.closeMenu();\n } catch (error) {\n context.handleGenerationError(error);\n }\n }\n });\n }\n };\n}\n\nexport default QuickActionBaseButton;\n", "import CreativeEditorSDK, { ButtonOptions } from '@cesdk/cesdk-js';\nimport { Output, QuickAction, QuickActionContext } from '../../provider';\nimport { getImageUri } from '@imgly/plugin-utils';\n\ninterface QuickActionBaseSelectItem {\n id: string;\n label: string;\n icon?: string;\n prompt: string;\n}\n\n/**\n * Quick action base for quick actions that require a selection of items.\n */\nfunction QuickActionBaseSelect<I, O extends Output>(options: {\n cesdk: CreativeEditorSDK;\n items: QuickActionBaseSelectItem[];\n buttonOptions?: ButtonOptions;\n quickAction: Omit<QuickAction<I, O>, 'render' | 'renderExpanded'>;\n mapInput?: (input: {\n item: QuickActionBaseSelectItem;\n uri: string;\n blockId: number;\n }) => I;\n onApply?: (\n options: { item: QuickActionBaseSelectItem; uri: string; blockId: number },\n context: QuickActionContext<I, O>\n ) => Promise<O>;\n}): QuickAction<I, O> {\n const id = options.quickAction.id;\n\n if (options.mapInput == null && options.onApply == null) {\n throw new Error(\n `QuickAction '${id}': Either mapInput or onApply must be provided to QuickActionChangeImage`\n );\n }\n\n if (options.mapInput != null && options.onApply != null) {\n throw new Error(\n `QuickAction '${id}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`\n );\n }\n\n return {\n ...options.quickAction,\n render: ({ builder, experimental }, context) => {\n experimental.builder.Popover(`${id}.popover`, {\n label: `ly.img.ai.quickAction.${id}`,\n icon: '@imgly/Appearance',\n labelAlignment: 'left',\n variant: 'plain',\n trailingIcon: '@imgly/ChevronRight',\n placement: 'right',\n ...options.buttonOptions,\n children: () => {\n builder.Section(`${id}.popover.section`, {\n children: () => {\n experimental.builder.Menu(`${id}.popover.menu`, {\n children: () => {\n options.items.forEach((item) => {\n builder.Button(`${id}.popover.menu.${item.id}`, {\n label: item.label,\n labelAlignment: 'left',\n variant: 'plain',\n icon: item.icon,\n onClick: async () => {\n const { generate, closeMenu, handleGenerationError } =\n context;\n try {\n closeMenu();\n const [blockId] =\n options.cesdk.engine.block.findAllSelected();\n const uri = await getImageUri(\n blockId,\n options.cesdk.engine,\n {\n throwErrorIfSvg: true\n }\n );\n\n if (options.mapInput) {\n const input = options.mapInput({\n item,\n uri,\n blockId\n });\n return await generate(input);\n } else if (options.onApply) {\n return await options.onApply(\n {\n item,\n uri,\n blockId\n },\n context\n );\n } else {\n throw new Error(\n 'Please provide either mapInput or onApply'\n );\n }\n } catch (error) {\n handleGenerationError(error);\n }\n }\n });\n });\n }\n });\n }\n });\n }\n });\n }\n };\n}\n\nexport default QuickActionBaseSelect;\n", "import CreativeEditorSDK, { AssetResult, ButtonOptions } from '@cesdk/cesdk-js';\nimport { Output, QuickAction, QuickActionContext } from '../../provider';\nimport { getImageUri } from '@imgly/plugin-utils';\n\n/**\n * Quick action base for quick actions that require a selection of items\n * from a library.\n */\nfunction QuickActionBaseLibrary<I, O extends Output>(options: {\n cesdk: CreativeEditorSDK;\n entries: string[];\n buttonOptions?: ButtonOptions;\n quickAction: Omit<QuickAction<I, O>, 'render' | 'renderExpanded'>;\n mapInput?: (input: {\n assetResult: AssetResult;\n uri: string;\n blockId: number;\n }) => I;\n onApply?: (\n options: { assetResult: AssetResult; uri: string; blockId: number },\n context: QuickActionContext<I, O>\n ) => Promise<O>;\n}): QuickAction<I, O> {\n const id = options.quickAction.id;\n\n if (options.mapInput == null && options.onApply == null) {\n throw new Error(\n `QuickAction '${id}': Either mapInput or onApply must be provided to QuickActionChangeImage`\n );\n }\n\n if (options.mapInput != null && options.onApply != null) {\n throw new Error(\n `QuickAction '${id}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`\n );\n }\n\n return {\n ...options.quickAction,\n render: ({ builder, experimental }, context) => {\n experimental.builder.Popover(`${id}.popover`, {\n label: `ly.img.ai.quickAction.${id}`,\n icon: '@imgly/Appearance',\n labelAlignment: 'left',\n variant: 'plain',\n trailingIcon: '@imgly/ChevronRight',\n placement: 'right',\n ...options.buttonOptions,\n children: () => {\n builder.Library(`${id}.popover.library`, {\n entries: options.entries,\n onSelect: async (assetResult) => {\n const { generate, closeMenu, handleGenerationError } = context;\n try {\n closeMenu();\n const [blockId] = options.cesdk.engine.block.findAllSelected();\n const uri = await getImageUri(blockId, options.cesdk.engine, {\n throwErrorIfSvg: true\n });\n\n if (options.mapInput) {\n const input = options.mapInput({\n assetResult,\n uri,\n blockId\n });\n await generate(input);\n } else if (options.onApply) {\n await options.onApply(\n {\n assetResult,\n uri,\n blockId\n },\n context\n );\n } else {\n throw new Error('Please provide either mapInput or onApply');\n }\n } catch (error) {\n handleGenerationError(error);\n }\n }\n });\n }\n });\n }\n };\n}\n\nexport default QuickActionBaseLibrary;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { ImageOutput, QuickAction, QuickActionContext } from '../../provider';\nimport QuickActionBasePrompt from './QuickActionBasePrompt';\nimport { getImageUri } from '@imgly/plugin-utils';\n\nfunction QuickActionEditTextStyle<I, O extends ImageOutput>(options: {\n id?: string;\n cesdk: CreativeEditorSDK;\n mapInput?: (input: {\n prompt: string;\n uri: string;\n duplicatedBlockId: number;\n }) => I;\n onApply?: (\n options: { prompt: string; uri: string; duplicatedBlockId: number },\n context: QuickActionContext<I, O>\n ) => Promise<O>;\n}): QuickAction<I, O> {\n const id = options.id ?? 'changeToImage';\n\n if (options.mapInput == null && options.onApply == null) {\n throw new Error(\n `QuickAction '${id}': Either mapInput or onApply must be provided to QuickActionChangeImage`\n );\n }\n\n if (options.mapInput != null && options.onApply != null) {\n throw new Error(\n `QuickAction '${id}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`\n );\n }\n\n options.cesdk.i18n.setTranslations({\n en: {\n [`ly.img.ai.quickAction.${id}.apply`]: 'Change',\n [`ly.img.ai.quickAction.${id}`]: 'Change Text Style...',\n [`ly.img.ai.quickAction.${id}.prompt.inputLabel`]: 'Change Text Style...',\n [`ly.img.ai.quickAction.${id}.prompt.placeholder`]:\n 'e.g. add a 3d texture with wires...'\n }\n });\n\n return QuickActionBasePrompt<I, O>({\n buttonOptions: {\n icon: '@imgly/plugin-ai-generation/image'\n },\n quickAction: {\n kind: 'text',\n id,\n version: '1',\n confirmation: false,\n // scopes: ['fill/change'],\n enable: ({ engine }) => {\n const blockIds = engine.block.findAllSelected();\n if (blockIds == null || blockIds.length !== 1) return false;\n const [blockId] = blockIds;\n return engine.block.getType(blockId) === '//ly.img.ubq/text';\n }\n },\n onApply: async (prompt, context) => {\n const [blockId] = options.cesdk.engine.block.findAllSelected();\n const parentBlockId = options.cesdk.engine.block.getParent(blockId);\n if (parentBlockId == null) {\n throw new Error('Parent block not found');\n }\n\n const rasterized = await options.cesdk.engine.block.export(blockId);\n const rasterizedUri = URL.createObjectURL(rasterized);\n\n const width = options.cesdk.engine.block.getFrameWidth(blockId);\n const height = options.cesdk.engine.block.getFrameHeight(blockId);\n const positionX = options.cesdk.engine.block.getPositionX(blockId);\n const positionY = options.cesdk.engine.block.getPositionY(blockId);\n\n const shape = options.cesdk.engine.block.createShape('rect');\n const rasterizedBlock = options.cesdk.engine.block.create('graphic');\n options.cesdk.engine.block.setShape(rasterizedBlock, shape);\n options.cesdk.engine.block.appendChild(parentBlockId, rasterizedBlock);\n options.cesdk.engine.block.setWidth(rasterizedBlock, width);\n options.cesdk.engine.block.setHeight(rasterizedBlock, height);\n options.cesdk.engine.block.setPositionX(rasterizedBlock, positionX);\n options.cesdk.engine.block.setPositionY(rasterizedBlock, positionY);\n const fillBlock = options.cesdk.engine.block.createFill('image');\n\n options.cesdk.engine.block.setString(\n fillBlock,\n 'fill/image/imageFileURI',\n rasterizedUri\n );\n\n options.cesdk.engine.block.setFill(rasterizedBlock, fillBlock);\n\n options.cesdk.engine.block.destroy(blockId);\n options.cesdk.engine.block.setSelected(rasterizedBlock, true);\n\n const uri = await getImageUri(rasterizedBlock, options.cesdk.engine, {\n throwErrorIfSvg: true\n });\n\n if (options.mapInput) {\n const input = options.mapInput({\n prompt,\n uri,\n duplicatedBlockId: rasterizedBlock\n });\n return context.generate(input);\n } else if (options.onApply) {\n return options.onApply(\n {\n prompt,\n uri,\n duplicatedBlockId: rasterizedBlock\n },\n context\n );\n } else {\n throw new Error('Please provide either mapInput or onApply');\n }\n }\n });\n}\n\nexport default QuickActionEditTextStyle;\n", "import type CreativeEngine from '@cesdk/engine';\n\n/**\n * Enable function for a single image fill block selected.\n */\nfunction enableImageFill() {\n return ({ engine }: { engine: CreativeEngine }) => {\n const blockIds = engine.block.findAllSelected();\n if (blockIds == null || blockIds.length !== 1) return false;\n\n const [blockId] = blockIds;\n\n if (!engine.block.supportsFill(blockId)) return false;\n\n if (\n !['//ly.img.ubq/graphic', '//ly.img.ubq/page'].includes(\n engine.block.getType(blockId)\n )\n ) {\n return false;\n }\n\n const fillBlock = engine.block.getFill(blockId);\n return engine.block.getType(fillBlock) === '//ly.img.ubq/fill/image';\n };\n}\n\nexport default enableImageFill;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { ImageOutput, QuickAction, QuickActionContext } from '../../provider';\nimport QuickActionBasePrompt from './QuickActionBasePrompt';\nimport enableImageFill from './enableImageFill';\nimport { getImageUri } from '@imgly/plugin-utils';\n\nfunction QuickActionChangeImage<I, O extends ImageOutput>(options: {\n id?: string;\n cesdk: CreativeEditorSDK;\n mapInput?: (input: { prompt: string; uri: string; blockId: number }) => I;\n onApply?: (\n options: { prompt: string; uri: string; blockId: number },\n context: QuickActionContext<I, O>\n ) => Promise<O>;\n}): QuickAction<I, O> {\n const id = options.id ?? 'changeImage';\n\n if (options.mapInput == null && options.onApply == null) {\n throw new Error(\n `QuickAction '${id}': Either mapInput or onApply must be provided to QuickActionChangeImage`\n );\n }\n\n if (options.mapInput != null && options.onApply != null) {\n throw new Error(\n `QuickAction '${id}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`\n );\n }\n\n options.cesdk.i18n.setTranslations({\n en: {\n [`ly.img.ai.quickAction.${id}.apply`]: 'Change',\n [`ly.img.ai.quickAction.${id}`]: 'Edit Image...',\n [`ly.img.ai.quickAction.${id}.prompt.inputLabel`]: 'Change image...',\n [`ly.img.ai.quickAction.${id}.prompt.placeholder`]:\n 'Describe what you want to change...'\n }\n });\n\n return QuickActionBasePrompt<I, O>({\n buttonOptions: {\n icon: '@imgly/plugin-ai-generation/image'\n },\n quickAction: {\n id,\n version: '1',\n confirmation: true,\n lockDuringConfirmation: false,\n scopes: ['fill/change'],\n enable: enableImageFill()\n },\n onApply: async (prompt, context) => {\n const [blockId] = options.cesdk.engine.block.findAllSelected();\n const uri = await getImageUri(blockId, options.cesdk.engine, {\n throwErrorIfSvg: true\n });\n\n if (options.mapInput) {\n const input = options.mapInput({ prompt, uri, blockId });\n return context.generate(input);\n } else if (options.onApply) {\n return options.onApply(\n {\n prompt,\n uri,\n blockId\n },\n context\n );\n } else {\n throw new Error('Please provide either mapInput or onApply');\n }\n }\n });\n}\n\nexport default QuickActionChangeImage;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { ImageOutput, QuickAction, QuickActionContext } from '../../provider';\nimport QuickActionBasePrompt from './QuickActionBasePrompt';\nimport enableImageFill from './enableImageFill';\nimport { getImageUri } from '@imgly/plugin-utils';\n\nfunction QuickActionImageVariant<I, O extends ImageOutput>(options: {\n id?: string;\n mapInput?: (input: {\n prompt: string;\n uri: string;\n duplicatedBlockId: number;\n }) => I;\n onApply?: (\n options: { prompt: string; uri: string; duplicatedBlockId: number },\n context: QuickActionContext<I, O>\n ) => Promise<O>;\n cesdk: CreativeEditorSDK;\n}): QuickAction<I, O> {\n const id = options.id ?? 'createVariant';\n\n if (options.mapInput == null && options.onApply == null) {\n throw new Error(\n `QuickAction '${id}': Either mapInput or onApply must be provided to QuickActionChangeImage`\n );\n }\n\n if (options.mapInput != null && options.onApply != null) {\n throw new Error(\n `QuickAction '${id}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`\n );\n }\n\n options.cesdk.i18n.setTranslations({\n en: {\n [`ly.img.ai.quickAction.${id}.apply`]: 'Create',\n [`ly.img.ai.quickAction.${id}`]: 'Create Variant...',\n [`ly.img.ai.quickAction.${id}.prompt.inputLabel`]:\n 'Describe Your Variant...',\n [`ly.img.ai.quickAction.${id}.prompt.placeholder`]:\n 'e.g., same character with arms raised'\n }\n });\n\n return QuickActionBasePrompt<I, O>({\n buttonOptions: {\n icon: '@imgly/ImageVariation'\n },\n quickAction: {\n id,\n version: '1',\n confirmation: false,\n lockDuringConfirmation: false,\n scopes: ['lifecycle/duplicate', 'fill/change'],\n enable: (context) => {\n if (!enableImageFill()(context)) return false;\n\n const [blockId] = context.engine.block.findAllSelected();\n if (\n !options.cesdk.feature.isEnabled('ly.img.duplicate', {\n engine: context.engine\n })\n ) {\n return false;\n }\n if (\n !context.engine.block.isAllowedByScope(blockId, 'lifecycle/duplicate')\n ) {\n return false;\n }\n\n return true;\n }\n },\n onApply: async (prompt, context) => {\n const engine = options.cesdk.engine;\n const [blockId] = engine.block.findAllSelected();\n const type = engine.block.getType(blockId);\n\n // Duplicate the selected block\n const duplicated = engine.block.duplicate(blockId);\n if (type === '//ly.img.ubq/page') {\n engine.block.getChildren(duplicated).forEach((childId) => {\n engine.block.destroy(childId);\n });\n }\n engine.block.setSelected(blockId, false);\n engine.block.setSelected(duplicated, true);\n\n const parent = engine.block.getParent(duplicated);\n if (parent == null) throw new Error('Parent not found');\n\n const isBackgroundClip =\n parent != null &&\n engine.block.getType(parent) === '//ly.img.ubq/track' &&\n engine.block.isPageDurationSource(parent);\n\n // Offset the duplicated block unless it is a background track\n if (!isBackgroundClip && type !== '//ly.img.ubq/page') {\n const offsetFactor = 1.0;\n const parentWidth = engine.block.getWidth(parent);\n const parentHeight = engine.block.getHeight(parent);\n const offset =\n 0.02 * Math.min(parentWidth, parentHeight) * offsetFactor;\n\n engine.block.setPositionX(\n duplicated,\n engine.block.getPositionX(duplicated) + offset\n );\n engine.block.setPositionY(\n duplicated,\n engine.block.getPositionY(duplicated) + offset\n );\n }\n\n // Get the source of the duplicated block\n const uri = await getImageUri(duplicated, options.cesdk.engine, {\n throwErrorIfSvg: true\n });\n\n if (options.mapInput) {\n const input = options.mapInput({\n prompt,\n uri,\n duplicatedBlockId: duplicated\n });\n return context.generate(input);\n } else if (options.onApply) {\n return options.onApply(\n {\n prompt,\n uri,\n duplicatedBlockId: duplicated\n },\n context\n );\n } else {\n throw new Error('Please provide either mapInput or onApply');\n }\n }\n });\n}\n\nexport default QuickActionImageVariant;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { ImageOutput, QuickAction, QuickActionContext } from '../../provider';\nimport QuickActionBasePrompt from './QuickActionBasePrompt';\nimport { getImageUri } from '@imgly/plugin-utils';\n\nfunction QuickActionCombineImages<I, O extends ImageOutput>(options: {\n id?: string;\n mapInput?: (input: {\n prompt: string;\n uris: string[];\n duplicatedBlockId: number;\n }) => I;\n onApply?: (\n options: { prompt: string; uris: string[]; duplicatedBlockId: number },\n context: QuickActionContext<I, O>\n ) => Promise<O>;\n cesdk: CreativeEditorSDK;\n}): QuickAction<I, O> {\n const id = options.id ?? 'combineImages';\n\n if (options.mapInput == null && options.onApply == null) {\n throw new Error(\n `QuickAction '${id}': Either mapInput or onApply must be provided to QuickActionChangeImage`\n );\n }\n\n if (options.mapInput != null && options.onApply != null) {\n throw new Error(\n `QuickAction '${id}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`\n );\n }\n\n options.cesdk.i18n.setTranslations({\n en: {\n [`ly.img.ai.quickAction.${id}.apply`]: 'Combine',\n [`ly.img.ai.quickAction.${id}`]: 'Combine Images...',\n [`ly.img.ai.quickAction.${id}.prompt.inputLabel`]:\n 'Image Combination Instructions',\n [`ly.img.ai.quickAction.${id}.prompt.placeholder`]:\n 'e.g., add character to the left of the mountain scene'\n }\n });\n\n return QuickActionBasePrompt<I, O>({\n buttonOptions: {\n icon: '@imgly/ImageVariation'\n },\n quickAction: {\n id,\n version: '1',\n confirmation: false,\n lockDuringConfirmation: false,\n scopes: ['lifecycle/duplicate', 'fill/change'],\n enable: (context) => {\n const blockIds = context.engine.block.findAllSelected();\n\n if (blockIds == null || blockIds.length < 2) return false;\n\n return blockIds.every((blockId) => {\n if (\n context.engine.block.getType(blockId) !== '//ly.img.ubq/graphic' &&\n !context.engine.block.supportsFill(blockId)\n ) {\n return false;\n }\n\n const fillBlock = context.engine.block.getFill(blockId);\n if (\n context.engine.block.getType(fillBlock) !==\n '//ly.img.ubq/fill/image'\n ) {\n return false;\n }\n\n if (\n !options.cesdk.feature.isEnabled('ly.img.duplicate', {\n engine: context.engine\n })\n ) {\n return false;\n }\n if (\n !context.engine.block.isAllowedByScope(\n blockId,\n 'lifecycle/duplicate'\n )\n ) {\n return false;\n }\n\n const parent = context.engine.block.getParent(blockId);\n const isBackgroundClip =\n parent != null &&\n context.engine.block.getType(parent) === '//ly.img.ubq/track' &&\n context.engine.block.isPageDurationSource(parent);\n\n if (isBackgroundClip) {\n return false;\n }\n\n const blockType = context.engine.block.getType(blockId);\n if (blockType === '//ly.img.ubq/page') return false;\n return true;\n });\n }\n },\n onApply: async (prompt, context) => {\n const engine = options.cesdk.engine;\n const blockIds = engine.block.findAllSelected();\n\n // Duplicate the selected block\n const duplicated = engine.block.duplicate(blockIds[0]);\n blockIds.forEach((blockId) => {\n engine.block.setSelected(blockId, false);\n });\n engine.block.setSelected(duplicated, true);\n\n // Offset the duplicated block\n const parent = engine.block.getParent(duplicated);\n if (parent == null) throw new Error('Parent not found');\n\n const offsetFactor = 1.0;\n const parentWidth = engine.block.getWidth(parent);\n const parentHeight = engine.block.getHeight(parent);\n const offset = 0.02 * Math.min(parentWidth, parentHeight) * offsetFactor;\n\n engine.block.setPositionX(\n duplicated,\n engine.block.getPositionX(duplicated) + offset\n );\n engine.block.setPositionY(\n duplicated,\n engine.block.getPositionY(duplicated) + offset\n );\n\n const uris = await Promise.all(\n blockIds.map((blockId) =>\n getImageUri(blockId, options.cesdk.engine, {\n throwErrorIfSvg: true\n })\n )\n );\n\n if (options.mapInput) {\n const input = options.mapInput({\n prompt,\n uris,\n duplicatedBlockId: duplicated\n });\n return context.generate(input);\n } else if (options.onApply) {\n return options.onApply(\n {\n prompt,\n uris,\n duplicatedBlockId: duplicated\n },\n context\n );\n } else {\n throw new Error('Please provide either mapInput or onApply');\n }\n }\n });\n}\n\nexport default QuickActionCombineImages;\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { ImageOutput, QuickAction, QuickActionContext } from '../../provider';\nimport { getImageUri } from '@imgly/plugin-utils';\nimport QuickActionBasePrompt from './QuickActionBasePrompt';\nimport enableImageFill from './enableImageFill';\n\nfunction QuickActionChangeImage<I, O extends ImageOutput>(options: {\n id?: string;\n mapInput?: (input: { prompt: string; uri: string; blockId: number }) => I;\n onApply?: (\n options: { prompt: string; uri: string; blockId: number },\n context: QuickActionContext<I, O>\n ) => Promise<O>;\n cesdk: CreativeEditorSDK;\n}): QuickAction<I, O> {\n const id = options.id ?? 'swapBackground';\n\n if (options.mapInput == null && options.onApply == null) {\n throw new Error(\n `QuickAction '${id}': Either mapInput or onApply must be provided to QuickActionChangeImage`\n );\n }\n\n if (options.mapInput != null && options.onApply != null) {\n throw new Error(\n `QuickAction '${id}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`\n );\n }\n\n options.cesdk.i18n.setTranslations({\n en: {\n [`ly.img.ai.quickAction.${id}.apply`]: 'Change',\n [`ly.img.ai.quickAction.${id}`]: 'Change Background...',\n [`ly.img.ai.quickAction.${id}.prompt.inputLabel`]: 'Change background...',\n [`ly.img.ai.quickAction.${id}.prompt.placeholder`]:\n 'Describe the background you want...'\n }\n });\n\n return QuickActionBasePrompt<I, O>({\n buttonOptions: {\n icon: '@imgly/plugin-ai-generation/image'\n },\n quickAction: {\n id,\n version: '1',\n confirmation: true,\n lockDuringConfirmation: false,\n scopes: ['fill/change'],\n enable: enableImageFill()\n },\n onApply: async (userPrompt, context) => {\n const [blockId] = options.cesdk.engine.block.findAllSelected();\n const uri = await getImageUri(blockId, options.cesdk.engine, {\n throwErrorIfSvg: true\n });\n\n const prompt = `Swap the background to ${userPrompt}`;\n if (options.mapInput) {\n const input = options.mapInput({ prompt, uri, blockId });\n return context.generate(input);\n } else if (options.onApply) {\n return options.onApply(\n {\n prompt,\n uri,\n blockId\n },\n context\n );\n } else {\n throw new Error('Please provide either mapInput or onApply');\n }\n }\n });\n}\n\nexport default QuickActionChangeImage;\n", "import renderImageUrlProperty from './common/renderImageUrlProperty';\nimport renderStyleTransferProperty from './common/renderStyleTransferProperty';\n\nconst CommonProperties = {\n ImageUrl: renderImageUrlProperty,\n StyleTransfer: renderStyleTransferProperty\n};\n\nexport { CommonProperties };\n\nexport {\n type default as Provider,\n type ImageOutput,\n type VideoOutput,\n type TextOutput,\n type AudioOutput,\n type Output,\n type OutputKind,\n type PanelInputSchema,\n type RenderCustomProperty,\n type GetBlockInput,\n type GetBlockInputResult,\n type GetInput,\n type QuickAction,\n type QuickActionsInput\n} from './generation/provider';\nexport {\n type GetPropertyInput,\n type Property\n} from './generation/openapi/types';\nexport { default as initProvider } from './generation/initProvider';\nexport {\n type GenerationMiddleware,\n type CommonProviderConfiguration\n} from './generation/types';\n\n// Export middleware\nexport {\n composeMiddlewares,\n type Middleware\n} from './generation/middleware/middleware';\nexport { default as loggingMiddleware } from './generation/middleware/loggingMiddleware';\nexport { default as uploadMiddleware } from './generation/middleware/uploadMiddleware';\nexport {\n default as rateLimitMiddleware,\n type RateLimitOptions\n} from './generation/middleware/rateLimitMiddleware';\n\nexport {\n getPanelId,\n getDurationForVideo,\n getThumbnailForVideo,\n getLabelFromId,\n isAsyncGenerator\n} from './utils';\n\nexport { default as registerDockComponent } from './registerDockComponent';\n\nexport { default as getQuickActionMenu } from './generation/quickAction/getQuickActionMenu';\nexport { default as registerQuickActionMenuComponent } from './generation/quickAction/registerQuickActionMenuComponent';\n\nexport { default as QuickActionBasePrompt } from './generation/quickAction/common/QuickActionBasePrompt';\nexport { default as QuickActionBaseButton } from './generation/quickAction/common/QuickActionBaseButton';\nexport { default as QuickActionBaseSelect } from './generation/quickAction/common/QuickActionBaseSelect';\nexport { default as QuickActionBaseLibrary } from './generation/quickAction/common/QuickActionBaseLibrary';\n\nexport { default as QuickActionEditTextStyle } from './generation/quickAction/common/QuickActionEditTextStyle';\nexport { default as QuickActionChangeImage } from './generation/quickAction/common/QuickActionChangeImage';\nexport { default as QuickActionImageVariant } from './generation/quickAction/common/QuickActionImageVariant';\nexport { default as QuickActionCombineImages } from './generation/quickAction/common/QuickActionCombineImages';\nexport { default as QuickActionSwapImageBackground } from './generation/quickAction/common/QuickActionSwapImageBackground';\n\nexport { default as enableQuickActionForImageFill } from './generation/quickAction/common/enableImageFill';\n\nexport {\n isGeneratingStateKey,\n abortGenerationStateKey\n} from './generation/renderGenerationComponents';\n", "{\n \"openapi\": \"3.0.0\",\n \"components\": {\n \"schemas\": {\n \"GptImage1Input\": {\n \"title\": \"TextToImageInput\",\n \"type\": \"object\",\n \"properties\": {\n \"prompt\": {\n \"title\": \"Prompt\",\n \"type\": \"string\",\n \"x-imgly-builder\": {\n \"component\": \"TextArea\"\n }\n },\n \"style\": {\n \"title\": \"Style\",\n \"type\": \"string\",\n \"description\": \"The style of the generated images.\"\n },\n \"size\": {\n \"enum\": [\"1024x1024\", \"1536x1024\", \"1024x1536\"],\n \"type\": \"string\",\n \"title\": \"Format\",\n \"default\": \"1024x1024\",\n \"x-imgly-enum-labels\": {\n \"1024x1024\": \"Square\",\n \"1536x1024\": \"Landscape\",\n \"1024x1536\": \"Portrait\"\n },\n \"x-imgly-enum-icons\": {\n \"1024x1024\": \"@imgly/plugin/formats/ratio1by1\",\n \"1024x1536\": \"@imgly/plugin/formats/ratio3by4\",\n \"1536x1024\": \"@imgly/plugin/formats/ratio4by3\"\n }\n },\n \"background\": {\n \"enum\": [\"auto\", \"transparent\", \"opaque\"],\n \"type\": \"string\",\n \"title\": \"Background\",\n \"default\": \"auto\",\n \"x-imgly-enum-labels\": {\n \"auto\": \"Auto\",\n \"transparent\": \"Transparent\",\n \"opaque\": \"Opaque\"\n }\n }\n },\n \"x-order-properties\": [\"prompt\", \"style\", \"size\", \"background\"],\n \"required\": [\"prompt\"]\n }\n }\n }\n}\n", "export function b64JsonToBlob(b64_json: string, mimeType: string): Blob {\n const base64Data = b64_json.split(',')[1] || b64_json;\n\n const byteCharacters = atob(base64Data);\n const byteArrays = [];\n\n for (let i = 0; i < byteCharacters.length; i++) {\n byteArrays.push(byteCharacters.charCodeAt(i));\n }\n const byteArray = new Uint8Array(byteArrays);\n const blob = new Blob([byteArray], { type: mimeType });\n\n return blob;\n}\n", "import CreativeEditorSDK from '@cesdk/cesdk-js';\nimport { CustomAssetSource, isDefined } from '@imgly/plugin-utils';\n\nexport const STYLES = [\n {\n id: 'none',\n label: 'None',\n prompt: ''\n },\n {\n id: 'anime-celshaded',\n label: 'Anime',\n prompt:\n 'anime cel\u2011shaded, bright pastel palette, expressive eyes, clean line art '\n },\n {\n id: 'cyberpunk-neon',\n label: 'Cyberpunk',\n prompt:\n 'cyberpunk cityscape, glowing neon signage, reflective puddles, dark atmosphere'\n },\n {\n id: 'kodak-portra-400',\n label: 'Kodak 400',\n prompt:\n 'shot on Kodak Portra 400, soft grain, golden\u2011hour warmth, 35 mm photo'\n },\n {\n id: 'watercolor-storybook',\n label: 'Watercolor',\n prompt: 'loose watercolor washes, gentle gradients, dreamy storybook feel'\n },\n {\n id: 'dark-fantasy-realism',\n label: 'Dark Fantasy',\n prompt:\n 'dark fantasy realm, moody chiaroscuro lighting, hyper\u2011real textures'\n },\n {\n id: 'vaporwave-retrofuturism',\n label: 'Vaporwave',\n prompt:\n 'retro\u2011futuristic vaporwave, pastel sunset gradient, chrome text, VHS scanlines'\n },\n {\n id: 'minimal-vector-flat',\n label: 'Vector Flat',\n prompt:\n 'minimalist flat vector illustration, bold geometry, two\u2011tone palette'\n },\n {\n id: 'pixarstyle-3d-render',\n label: '3D Animation',\n prompt:\n 'Pixar\u2011style 3D render, oversized eyes, subtle subsurface scattering, cinematic lighting'\n },\n {\n id: 'ukiyoe-woodblock',\n label: 'Ukiyo\u2011e',\n prompt:\n 'ukiyo\u2011e woodblock print, Edo\u2011period style, visible washi texture, limited color ink'\n },\n {\n id: 'surreal-dreamscape',\n label: 'Surreal',\n prompt:\n 'surreal dreamscape, floating objects, impossible architecture, vivid clouds'\n },\n {\n id: 'steampunk-victorian',\n label: 'Steampunk',\n prompt:\n 'Victorian steampunk world, ornate brass gears, leather attire, atmospheric fog'\n },\n {\n id: 'nightstreet-photo-bokeh',\n label: 'Night Bokeh',\n prompt:\n 'night\u2011time street shot, large aperture bokeh lights, candid urban mood'\n },\n {\n id: 'comicbook-pop-art',\n label: 'Pop Art',\n prompt:\n 'classic comic\u2011book panel, halftone shading, exaggerated action lines, CMYK pop colors'\n }\n];\n\nexport const createStyleAssetSource = (\n assetSourceId: string,\n options: {\n baseURL: string;\n includeNone?: boolean;\n }\n) => {\n const styleValues = STYLES.map((style) => {\n if (style.id === 'none') {\n if (!options.includeNone) {\n return undefined;\n }\n return {\n id: style.id,\n label: style.label,\n thumbUri: `${options.baseURL}/thumbnails/None.svg`\n };\n }\n return {\n id: style.id,\n label: style.label,\n thumbUri: `${options.baseURL}/thumbnails/${style.id}.jpeg`\n };\n }).filter(isDefined);\n\n const styleAssetSource = new CustomAssetSource(assetSourceId, styleValues);\n\n const defaultStyle = STYLES[0];\n styleAssetSource.setAssetActive(defaultStyle.id);\n\n return styleAssetSource;\n};\n\nexport const addStyleAssetSource = (\n styleAssetSource: CustomAssetSource,\n options: {\n cesdk: CreativeEditorSDK;\n }\n) => {\n options.cesdk.engine.asset.addSource(styleAssetSource);\n options.cesdk.ui.addAssetLibraryEntry({\n id: styleAssetSource.id,\n sourceIds: [styleAssetSource.id],\n gridItemHeight: 'square',\n gridBackgroundType: 'cover',\n cardLabel: ({ label }) => label,\n cardLabelPosition: () => 'below'\n });\n};\n", "import { Icons } from '@imgly/plugin-utils';\nimport {\n CommonProviderConfiguration,\n getPanelId,\n type Provider\n} from '@imgly/plugin-ai-generation-web';\nimport GptImage1Schema from './GptImage1.text2image.json';\nimport CreativeEditorSDK, { AssetResult } from '@cesdk/cesdk-js';\nimport { b64JsonToBlob } from './utils';\nimport {\n addStyleAssetSource,\n createStyleAssetSource,\n STYLES\n} from './GptImage1.styles';\n\ntype StyleSelectionPayload = {\n onSelect: (asset: AssetResult) => Promise<void>;\n};\n\ntype GptImage1Input = {\n prompt: string;\n style?: string;\n size: 'auto' | '1024x1024' | '1536x1024' | '1024x1536';\n background: 'transparent' | 'opaque' | 'auto';\n};\n\ntype GptImage1Output = {\n kind: 'image';\n url: string;\n};\n\ninterface ProviderConfiguration\n extends CommonProviderConfiguration<GptImage1Input, GptImage1Output> {}\n\nexport function GptImage1(\n config: ProviderConfiguration\n): (context: {\n cesdk: CreativeEditorSDK;\n}) => Promise<Provider<'image', GptImage1Input, GptImage1Output>> {\n return async ({ cesdk }: { cesdk: CreativeEditorSDK }) => {\n return getProvider(cesdk, config);\n };\n}\n\nfunction getProvider(\n cesdk: CreativeEditorSDK,\n config: ProviderConfiguration\n): Provider<'image', GptImage1Input, GptImage1Output> {\n const modelKey = 'open-ai/gpt-image-1/text2image';\n const baseURL =\n 'https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/gpt-image-1/';\n const styleAssetSourceId = `${modelKey}/styles`;\n const styleAssetSource = createStyleAssetSource(styleAssetSourceId, {\n baseURL,\n includeNone: true\n });\n addStyleAssetSource(styleAssetSource, { cesdk });\n\n cesdk.ui.registerPanel<StyleSelectionPayload>(\n `${getPanelId(modelKey)}.styleSelection`,\n ({ builder, payload }) => {\n if (payload == null) return null;\n\n builder.Library(`${modelKey}.library.style`, {\n entries: [styleAssetSourceId],\n onSelect: async (asset) => {\n payload.onSelect(asset);\n }\n });\n }\n );\n\n cesdk.ui.addIconSet('@imgly/plugin/formats', Icons.Formats);\n cesdk.i18n.setTranslations({\n en: {\n [`panel.${getPanelId(modelKey)}.styleSelection`]: 'Style Selection',\n [`${modelKey}.style`]: 'Style'\n }\n });\n\n const provider: Provider<'image', GptImage1Input, GptImage1Output> = {\n id: 'open-ai/gpt-image-1/text2image',\n kind: 'image',\n name: 'gpt-image-1',\n input: {\n panel: {\n type: 'schema',\n // @ts-ignore\n document: GptImage1Schema,\n inputReference: '#/components/schemas/GptImage1Input',\n includeHistoryLibrary: true,\n orderExtensionKeyword: 'x-order-properties',\n renderCustomProperty: {\n style: ({ builder, state }, property) => {\n const styleState = state<{\n id: string;\n label: string;\n }>(\n 'style',\n styleAssetSource.getAssetSelectValue(\n styleAssetSource.getActiveAssetIds()[0]\n ) ?? STYLES[0]\n );\n\n // Show the style library for the selected type.\n builder.Button(`${property.id}`, {\n inputLabel: `${modelKey}.${property.id}`,\n icon: '@imgly/Appearance',\n trailingIcon: '@imgly/ChevronRight',\n label: styleState.value.label,\n labelAlignment: 'left',\n onClick: () => {\n const payload: StyleSelectionPayload = {\n onSelect: async (asset) => {\n const newValue = {\n id: asset.id,\n label: asset.label ?? asset.id\n };\n\n styleAssetSource.clearActiveAssets();\n styleAssetSource.setAssetActive(asset.id);\n styleState.setValue(newValue);\n\n cesdk.ui.closePanel(\n `${getPanelId(modelKey)}.styleSelection`\n );\n }\n };\n\n cesdk.ui.openPanel(`${getPanelId(modelKey)}.styleSelection`, {\n payload\n });\n }\n });\n\n return () => {\n return {\n id: property.id,\n type: 'string',\n value:\n styleState.value.id ?? styleAssetSource.getActiveAssetIds()[0]\n };\n };\n }\n },\n getBlockInput: (input) => {\n switch (input.size) {\n case 'auto':\n return Promise.resolve({ image: { width: 512, height: 512 } });\n case '1024x1024':\n return Promise.resolve({ image: { width: 1024, height: 1024 } });\n case '1536x1024':\n return Promise.resolve({ image: { width: 1536, height: 1024 } });\n case '1024x1536':\n return Promise.resolve({ image: { width: 1024, height: 1536 } });\n default: {\n throw new Error('Invalid image size');\n }\n }\n },\n userFlow: 'placeholder'\n }\n },\n output: {\n abortable: true,\n history: '@imgly/indexedDB',\n middleware: config.middleware ?? [],\n generate: async (\n input: GptImage1Input,\n { abortSignal }: { abortSignal?: AbortSignal }\n ) => {\n const stylePrompt = STYLES.find((style) => style.id === input.style);\n let prompt = input.prompt;\n\n if (\n stylePrompt != null &&\n stylePrompt.id !== 'none' &&\n stylePrompt.prompt\n ) {\n prompt = `${prompt}, ${stylePrompt.prompt}`;\n }\n const hasGlobalAPIKey =\n cesdk.ui.experimental.hasGlobalStateValue('OPENAI_API_KEY');\n\n const baseUrl = hasGlobalAPIKey\n ? 'https://api.openai.com/v1'\n : config.proxyUrl;\n\n const response = await fetch(`${baseUrl}/images/generations`, {\n signal: abortSignal,\n method: 'POST',\n headers: hasGlobalAPIKey\n ? {\n Authorization: `Bearer ${cesdk.ui.experimental.getGlobalStateValue(\n 'OPENAI_API_KEY'\n )}`,\n 'Content-Type': 'application/json',\n ...(config.headers ?? {})\n }\n : {\n 'Content-Type': 'application/json',\n ...(config.headers ?? {})\n },\n body: JSON.stringify({\n model: 'gpt-image-1',\n prompt,\n n: 1,\n size: input.size,\n background: input.background\n })\n });\n const img = await response.json();\n\n const b64_json = img.data?.[0].b64_json;\n if (b64_json == null) {\n throw new Error('No image data returned');\n }\n\n const blob = b64JsonToBlob(b64_json, 'image/png');\n const imageUrl = URL.createObjectURL(blob);\n\n return {\n kind: 'image',\n url: imageUrl\n };\n }\n }\n };\n\n return provider;\n}\n\nexport default getProvider;\n", "{\n \"openapi\": \"3.0.0\",\n \"components\": {\n \"schemas\": {\n \"GptImage1Input\": {\n \"title\": \"ImageToImageInput\",\n \"type\": \"object\",\n \"properties\": {\n \"prompt\": {\n \"title\": \"Prompt\",\n \"type\": \"string\",\n \"x-imgly-builder\": {\n \"component\": \"TextArea\"\n }\n },\n \"image_url\": {\n \"title\": \"Image Url\",\n \"type\": \"string\",\n \"description\": \"Optional URL of an input image for editing.\"\n }\n },\n \"x-order-properties\": [\"image_url\", \"prompt\", \"background\"],\n \"required\": [\"image_url\", \"prompt\"]\n }\n }\n }\n}\n", "import {\n bufferURIToObjectURL,\n getImageDimensionsFromURL,\n getImageUri,\n Icons,\n mimeTypeToExtension\n} from '@imgly/plugin-utils';\nimport {\n QuickActionImageVariant,\n QuickActionCombineImages,\n QuickActionChangeImage,\n QuickActionEditTextStyle,\n QuickActionSwapImageBackground,\n CommonProperties,\n getQuickActionMenu,\n QuickActionBasePrompt,\n QuickAction,\n type Provider,\n QuickActionBaseSelect,\n QuickActionBaseLibrary,\n enableQuickActionForImageFill,\n QuickActionBaseButton,\n CommonProviderConfiguration\n} from '@imgly/plugin-ai-generation-web';\nimport GptImage1Schema from './GptImage1.image2image.json';\nimport CreativeEditorSDK, { MimeType } from '@cesdk/cesdk-js';\nimport { b64JsonToBlob } from './utils';\nimport {\n addStyleAssetSource,\n createStyleAssetSource,\n STYLES\n} from './GptImage1.styles';\n\ntype GptImage1Input = {\n prompt: string;\n image_url: string | string[];\n exportFromBlockIds?: number[];\n};\n\ntype GptImage1Output = {\n kind: 'image';\n url: string;\n};\n\ninterface ProviderConfiguration\n extends CommonProviderConfiguration<GptImage1Input, GptImage1Output> {}\n\nexport function GptImage1(\n config: ProviderConfiguration\n): (context: {\n cesdk: CreativeEditorSDK;\n}) => Promise<Provider<'image', GptImage1Input, GptImage1Output>> {\n return async ({ cesdk }: { cesdk: CreativeEditorSDK }) => {\n return getProvider(cesdk, config);\n };\n}\n\nfunction getProvider(\n cesdk: CreativeEditorSDK,\n config: ProviderConfiguration\n): Provider<'image', GptImage1Input, GptImage1Output> {\n const modelKey = 'open-ai/gpt-image-1/image2image';\n cesdk.ui.addIconSet('@imgly/plugin/formats', Icons.Formats);\n const baseURL =\n 'https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/gpt-image-1/';\n\n const quickActions = createQuickActions({ cesdk, modelKey });\n const quickActionMenu = getQuickActionMenu(cesdk, 'image');\n\n const styleAssetSourceId = `${modelKey}/styles`;\n const styleAssetSource = createStyleAssetSource(styleAssetSourceId, {\n baseURL\n });\n addStyleAssetSource(styleAssetSource, { cesdk });\n\n cesdk.i18n.setTranslations({\n en: {\n 'ly.img.ai.quickAction.changeStyle': 'Change Style',\n 'ly.img.ai.quickAction.changeStyleLibrary': 'Change Style',\n 'ly.img.ai.quickAction.remixPage': 'Turn Page into Image',\n 'ly.img.ai.quickAction.remixPageWithPrompt': 'Remix Page',\n 'ly.img.ai.quickAction.remixPageWithPrompt.prompt.inputLabel':\n 'Remix Page Prompt',\n 'ly.img.ai.quickAction.remixPageWithPrompt.prompt.placeholder':\n 'e.g. rearrange the layout to...',\n 'ly.img.ai.quickAction.remixPageWithPrompt.apply': 'Remix'\n }\n });\n\n quickActionMenu.setQuickActionMenuOrder([\n 'changeStyleLibrary',\n // 'changeStyle',\n 'ly.img.separator',\n 'swapBackground',\n 'changeImage',\n 'createVariant',\n 'combineImages',\n 'ly.img.separator',\n 'remixPage',\n 'ly.img.separator',\n ...quickActionMenu.getQuickActionMenuOrder()\n ]);\n\n const provider: Provider<'image', GptImage1Input, GptImage1Output> = {\n id: modelKey,\n kind: 'image',\n name: 'gpt-image-1',\n input: {\n panel: {\n type: 'schema',\n // @ts-ignore\n document: GptImage1Schema,\n inputReference: '#/components/schemas/GptImage1Input',\n includeHistoryLibrary: true,\n orderExtensionKeyword: 'x-order-properties',\n renderCustomProperty: {\n ...(cesdk != null\n ? CommonProperties.ImageUrl('gpt-image-1', {\n cesdk\n })\n : {})\n },\n getBlockInput: async (input) => {\n if (input.image_url == null || Array.isArray(input.image_url)) {\n throw new Error('Cannot process getBlockInput for multiple images');\n }\n\n const { width, height } = await getImageDimensionsFromURL(\n input.image_url,\n cesdk.engine\n );\n return Promise.resolve({\n image: {\n width,\n height\n }\n });\n },\n userFlow: 'placeholder'\n },\n quickActions: {\n actions: quickActions ?? []\n }\n },\n output: {\n abortable: true,\n history: '@imgly/indexedDB',\n middleware: config.middleware ?? [],\n generate: async (\n input: GptImage1Input,\n { abortSignal }: { abortSignal?: AbortSignal }\n ) => {\n const formData = new FormData();\n\n if (Array.isArray(input.image_url)) {\n if (input.exportFromBlockIds != null) {\n await Promise.all(\n input.exportFromBlockIds.map(async (blockId) => {\n const exportedBlob = await cesdk.engine.block.export(\n blockId,\n MimeType.Jpeg,\n {\n targetHeight: 1024,\n targetWidth: 1024\n }\n );\n formData.append(\n 'image[]',\n exportedBlob,\n `image_${blockId}.jpeg`\n );\n })\n );\n } else {\n await Promise.all(\n input.image_url.map(async (image_url) => {\n const mimeType = await cesdk.engine.editor.getMimeType(\n image_url\n );\n const resolvedImageUrl = await bufferURIToObjectURL(\n image_url,\n cesdk.engine\n );\n const imageUrlResponse = await fetch(resolvedImageUrl);\n const imageUrlBlob = await imageUrlResponse.blob();\n formData.append(\n 'image[]',\n imageUrlBlob,\n `image.${mimeTypeToExtension(mimeType)}`\n );\n })\n );\n }\n } else {\n const mimeType = await cesdk.engine.editor.getMimeType(\n input.image_url\n );\n const resolvedImageUrl = await bufferURIToObjectURL(\n input.image_url,\n cesdk.engine\n );\n const imageUrlResponse = await fetch(resolvedImageUrl);\n const imageUrlBlob = await imageUrlResponse.blob();\n formData.append(\n 'image',\n imageUrlBlob,\n `image.${mimeTypeToExtension(mimeType)}`\n );\n }\n\n formData.append('prompt', input.prompt);\n formData.append('model', 'gpt-image-1');\n formData.append('size', 'auto');\n formData.append('n', '1');\n\n const hasGlobalAPIKey =\n cesdk.ui.experimental.hasGlobalStateValue('OPENAI_API_KEY');\n\n const baseUrl = hasGlobalAPIKey\n ? 'https://api.openai.com/v1'\n : config.proxyUrl;\n\n const response = await fetch(`${baseUrl}/images/edits`, {\n signal: abortSignal,\n method: 'POST',\n headers: hasGlobalAPIKey\n ? {\n Authorization: `Bearer ${cesdk.ui.experimental.getGlobalStateValue(\n 'OPENAI_API_KEY'\n )}`,\n ...(config.headers ?? {})\n }\n : {\n ...(config.headers ?? {})\n },\n body: formData\n });\n\n const img = await response.json();\n\n const b64_json = img.data?.[0].b64_json;\n if (b64_json == null) {\n throw new Error('No image data returned');\n }\n\n const blob = b64JsonToBlob(b64_json, 'image/png');\n const imageUrl = URL.createObjectURL(blob);\n\n return {\n kind: 'image',\n url: imageUrl\n };\n }\n }\n };\n\n return provider;\n}\n\nfunction createQuickActions(options: {\n cesdk: CreativeEditorSDK;\n modelKey: string;\n}): QuickAction<GptImage1Input, GptImage1Output>[] {\n const { cesdk, modelKey } = options;\n return [\n QuickActionBaseLibrary<GptImage1Input, GptImage1Output>({\n cesdk: options.cesdk,\n entries: [`${modelKey}/styles`],\n quickAction: {\n id: 'changeStyleLibrary',\n version: '1',\n confirmation: true,\n lockDuringConfirmation: false,\n scopes: ['fill/change'],\n enable: enableQuickActionForImageFill()\n },\n onApply: async (input, context) => {\n const [blockId] = cesdk.engine.block.findAllSelected();\n const uri = await getImageUri(blockId, cesdk.engine, {\n throwErrorIfSvg: true\n });\n\n const styleId = input.assetResult.id;\n const style = STYLES.find(({ id }) => id === styleId);\n if (style == null) {\n throw new Error(`Style not found: ${styleId}`);\n }\n\n return context.generate({\n prompt: style.prompt,\n image_url: uri\n });\n }\n }),\n QuickActionBaseSelect<GptImage1Input, GptImage1Output>({\n cesdk,\n items: STYLES.filter(({ id }) => id !== 'none'),\n quickAction: {\n id: 'changeStyle',\n version: '1',\n confirmation: true,\n lockDuringConfirmation: false,\n scopes: ['fill/change'],\n enable: enableQuickActionForImageFill()\n },\n onApply: async (input, context) => {\n const [blockId] = cesdk.engine.block.findAllSelected();\n const uri = await getImageUri(blockId, cesdk.engine, {\n throwErrorIfSvg: true\n });\n\n return context.generate({\n prompt: input.item.prompt,\n image_url: uri\n });\n }\n }),\n // QuickActionEditTextStyle<GptImage1Input, GptImage1Output>({\n // onApply: async ({ prompt, uri, duplicatedBlockId }, context) => {\n // // Generate a variant for the duplicated block\n // return context.generate(\n // {\n // prompt,\n // image_url: uri\n // },\n // {\n // blockIds: [duplicatedBlockId]\n // }\n // );\n // },\n // cesdk\n // }),\n QuickActionSwapImageBackground<GptImage1Input, GptImage1Output>({\n mapInput: (input) => ({ ...input, image_url: input.uri }),\n cesdk\n }),\n QuickActionChangeImage<GptImage1Input, GptImage1Output>({\n mapInput: (input) => ({ ...input, image_url: input.uri }),\n cesdk\n }),\n QuickActionImageVariant<GptImage1Input, GptImage1Output>({\n onApply: async ({ prompt, uri, duplicatedBlockId }, context) => {\n // Generate a variant for the duplicated block\n return context.generate(\n {\n prompt,\n image_url: uri\n },\n {\n blockIds: [duplicatedBlockId]\n }\n );\n },\n cesdk\n }),\n QuickActionCombineImages<GptImage1Input, GptImage1Output>({\n onApply: async ({ prompt, uris, duplicatedBlockId }, context) => {\n // Generate a variant for the duplicated block\n return context.generate(\n {\n prompt,\n image_url: uris,\n exportFromBlockIds: context.blockIds\n },\n {\n blockIds: [duplicatedBlockId]\n }\n );\n },\n cesdk\n }),\n QuickActionBaseButton<GptImage1Input, GptImage1Output>({\n quickAction: {\n id: 'remixPage',\n version: '1',\n confirmation: false,\n lockDuringConfirmation: false,\n scopes: ['lifecycle/duplicate'],\n enable: ({ engine }) => {\n const blockIds = engine.block.findAllSelected();\n if (blockIds.length !== 1) return false;\n const blockId = blockIds[0];\n const type = engine.block.getType(blockId);\n return type === '//ly.img.ubq/page';\n }\n },\n onClick: async (context) => {\n const engine = cesdk.engine;\n const [page] = engine.block.findAllSelected();\n\n const exportedPageBlob = await engine.block.export(page);\n const exportedPageUrl = URL.createObjectURL(exportedPageBlob);\n\n const duplicatedPage = engine.block.duplicate(page);\n engine.block.getChildren(duplicatedPage).forEach((childId) => {\n engine.block.destroy(childId);\n });\n engine.block.setSelected(page, false);\n\n const width = cesdk.engine.block.getFrameWidth(page);\n const height = cesdk.engine.block.getFrameHeight(page);\n const positionX = cesdk.engine.block.getPositionX(page);\n const positionY = cesdk.engine.block.getPositionY(page);\n\n const shape = cesdk.engine.block.createShape('rect');\n const rasterizedPageBlock = cesdk.engine.block.create('graphic');\n\n cesdk.engine.block.setShape(rasterizedPageBlock, shape);\n cesdk.engine.block.appendChild(duplicatedPage, rasterizedPageBlock);\n cesdk.engine.block.setWidth(rasterizedPageBlock, width);\n cesdk.engine.block.setHeight(rasterizedPageBlock, height);\n cesdk.engine.block.setPositionX(rasterizedPageBlock, positionX);\n cesdk.engine.block.setPositionY(rasterizedPageBlock, positionY);\n\n const fillBlock = cesdk.engine.block.createFill('image');\n cesdk.engine.block.setFill(rasterizedPageBlock, fillBlock);\n\n cesdk.engine.block.setString(\n fillBlock,\n 'fill/image/imageFileURI',\n exportedPageUrl\n );\n\n engine.block.setSelected(rasterizedPageBlock, true);\n engine.scene.zoomToBlock(rasterizedPageBlock);\n\n context.generate(\n {\n image_url: exportedPageUrl,\n prompt:\n 'Follow instructions but don\u2019t add the instructions for the image'\n },\n {\n blockIds: [rasterizedPageBlock]\n }\n );\n }\n }),\n QuickActionBasePrompt<GptImage1Input, GptImage1Output>({\n quickAction: {\n id: 'remixPageWithPrompt',\n version: '1',\n confirmation: false,\n lockDuringConfirmation: false,\n scopes: ['lifecycle/duplicate'],\n enable: ({ engine }) => {\n const blockIds = engine.block.findAllSelected();\n if (blockIds.length !== 1) return false;\n const blockId = blockIds[0];\n const type = engine.block.getType(blockId);\n return type === '//ly.img.ubq/page';\n }\n },\n onApply: async (prompt, context) => {\n const engine = cesdk.engine;\n const [page] = engine.block.findAllSelected();\n\n const exportedPageBlob = await engine.block.export(page);\n const exportedPageUrl = URL.createObjectURL(exportedPageBlob);\n\n const duplicatedPage = engine.block.duplicate(page);\n engine.block.getChildren(duplicatedPage).forEach((childId) => {\n engine.block.destroy(childId);\n });\n engine.block.setSelected(page, false);\n\n const width = cesdk.engine.block.getFrameWidth(page);\n const height = cesdk.engine.block.getFrameHeight(page);\n const positionX = cesdk.engine.block.getPositionX(page);\n const positionY = cesdk.engine.block.getPositionY(page);\n\n const shape = cesdk.engine.block.createShape('rect');\n const rasterizedPageBlock = cesdk.engine.block.create('graphic');\n\n cesdk.engine.block.setShape(rasterizedPageBlock, shape);\n cesdk.engine.block.appendChild(duplicatedPage, rasterizedPageBlock);\n cesdk.engine.block.setWidth(rasterizedPageBlock, width);\n cesdk.engine.block.setHeight(rasterizedPageBlock, height);\n cesdk.engine.block.setPositionX(rasterizedPageBlock, positionX);\n cesdk.engine.block.setPositionY(rasterizedPageBlock, positionY);\n\n const fillBlock = cesdk.engine.block.createFill('image');\n cesdk.engine.block.setFill(rasterizedPageBlock, fillBlock);\n\n cesdk.engine.block.setString(\n fillBlock,\n 'fill/image/imageFileURI',\n exportedPageUrl\n );\n\n engine.block.setSelected(rasterizedPageBlock, true);\n engine.scene.zoomToBlock(rasterizedPageBlock);\n\n return context.generate(\n {\n image_url: exportedPageUrl,\n prompt\n },\n {\n blockIds: [rasterizedPageBlock]\n }\n );\n }\n })\n ];\n}\n\nexport default getProvider;\n", "import { GptImage1 as GptImage1Text2Image } from './GptImage1.text2image';\nimport { GptImage1 as GptImage1Image2Image } from './GptImage1.image2image';\n\nconst OpenAi = {\n GptImage1: {\n Text2Image: GptImage1Text2Image,\n Image2Image: GptImage1Image2Image\n }\n};\n\nexport default OpenAi;\n"],
5
+ "mappings": "AAAA,IAAOA,GAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ECuBFC,GAAN,KAA+C,CAgBpD,YAAYC,EAAYC,EAA4C,CAAC,EAAG,CACtE,KAAK,GAAKD,EACV,KAAK,OAASC,EAAO,IAAKC,GAAU,CAElC,GACE,OAAQA,EAAsB,OAAU,UACxC,EACGA,EAA0B,OAC3B,OAAQA,EAA0B,OAAU,UAE9C,CACA,IAAMC,EAAcD,EAEpB,MAAO,CACL,GAAIC,EAAY,GAChB,MAAO,CAAE,GAAIA,EAAY,KAAM,EAC/B,KAAMA,EAAY,SACd,CAAE,GAAIA,EAAY,MAAQ,CAAC,EAAI,SAAUA,EAAY,QAAS,EAC9DA,EAAY,IAClB,CACF,CACA,OAAOD,CACT,CAAC,EACD,KAAK,eAAiB,IAAI,GAC5B,CASA,MAAM,WACJE,EACwC,CACxC,GAAM,CACJ,KAAAC,EACA,QAAAC,EACA,OAAAC,EAAS,KACT,gBAAAC,EACA,MAAAC,EACA,KAAAC,EACA,OAAAC,EACA,cAA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tDhB,EAAM,OAAO,MAAM,UAAUgE,EAAqB/C,CAAM,EACxDjB,EAAM,OAAO,MAAM,aAAagE,EAAqBH,CAAS,EAC9D7D,EAAM,OAAO,MAAM,aAAagE,EAAqBF,CAAS,EAE9D,IAAMG,EAAYjE,EAAM,OAAO,MAAM,WAAW,OAAO,EACvD,OAAAA,EAAM,OAAO,MAAM,QAAQgE,EAAqBC,CAAS,EAEzDjE,EAAM,OAAO,MAAM,UACjBiE,EACA,0BACAP,CACF,EAEAJ,EAAO,MAAM,YAAYU,EAAqB,EAAI,EAClDV,EAAO,MAAM,YAAYU,CAAmB,EAErC1B,EAAQ,SACb,CACE,UAAWoB,EACX,OAAAT,CACF,EACA,CACE,SAAU,CAACe,CAAmB,CAChC,CACF,CACF,CACF,CAAC,CACH,CACF,CCtfA,IAAMG,GAAS,CACb,UAAW,CACT,WAAYC,GACZ,YAAaA,EACf,CACF,EAEOC,GAAQF",
6
+ "names": ["formats_default", "CustomAssetSource", "id", "assets", "asset", "selectValue", "queryData", "page", "perPage", "locale", "sortActiveFirst", "query", "tags", "groups", "excludeGroups", "sortingOrder", "sortKey", "filteredAssets", "group", "lowerQuery", "label", "assetTags", "tag", "tagArray", "a", "b", "aActive", "bActive", "aValue", "bValue", "total", "startIndex", "endIndex", "resultAssets", "nextPage", "assetId", "assetIds", "existingIndex", "index", "freeGlobal", "freeGlobal_default", "freeSelf", "root", "root_default", "Symbol", "Symbol_default", "objectProto", "hasOwnProperty", "nativeObjectToString", "symToStringTag", "getRawTag", "value", "isOwn", "tag", "unmasked", "result", "getRawTag_default", "objectToString", "objectToString_default", "nullTag", "undefinedTag", "baseGetTag", "baseGetTag_default", "isObjectLike", "isObjectLike_default", "isArray", "isObject", "value", "type", "isObject_default", "asyncTag", "funcTag", "genTag", "proxyTag", "isFunction", "tag", "baseGetTag_default", "isFunction_default", "coreJsData", "root_default", "coreJsData_default", "maskSrcKey", "uid", "isMasked", "func", "isMasked_default", "funcProto", "funcToString", "toSource", "toSource_default", "reRegExpChar", "reIsHostCtor", "objectProto", "hasOwnProperty", "reIsNative", "baseIsNative", "pattern", "baseIsNative_default", "getValue", "object", "key", "getValue_default", "getNative", "getNative_default", "WeakMap", "WeakMap_default", "eq", "value", "other", "eq_default", "MAX_SAFE_INTEGER", "isLength", "isLength_default", "objectProto", "argsTag", "baseIsArguments", "value", "isObjectLike_default", "baseGetTag_default", "baseIsArguments_default", "objectProto", "hasOwnProperty", "propertyIsEnumerable", "isArguments", "freeExports", "freeModule", "moduleExports", "Buffer", "root_default", "nativeIsBuffer", "argsTag", "arrayTag", "boolTag", "dateTag", "errorTag", "funcTag", "mapTag", "numberTag", "objectTag", "regexpTag", "setTag", "stringTag", "weakMapTag", "arrayBufferTag", "dataViewTag", "float32Tag", "float64Tag", "int8Tag", "int16Tag", "int32Tag", "uint8Tag", "uint8ClampedTag", "uint16Tag", "uint32Tag", "typedArrayTags", "baseIsTypedArray", "value", "isObjectLike_default", "isLength_default", "baseGetTag_default", "baseIsTypedArray_default", "baseUnary", "func", "baseUnary_default", "freeExports", "freeModule", "moduleExports", "freeProcess", "freeGlobal_default", "nodeUtil", "types", "nodeUtil_default", "nodeIsTypedArray", "isTypedArray", "objectProto", "hasOwnProperty", "overArg", "func", "transform", "arg", "overArg_default", "nativeKeys", "objectProto", "hasOwnProperty", "nativeCreate", "getNative_default", "nativeCreate_default", "hashClear", "hashClear_default", "hashDelete", "key", "result", "hashDelete_default", "HASH_UNDEFINED", "objectProto", "hasOwnProperty", "hashGet", "data", "hashGet_default", "hashHas", "hashHas_default", "hashSet", "value", "hashSet_default", "Hash", "entries", "index", "length", "entry", "Hash_default", "listCacheClear", "listCacheClear_default", "assocIndexOf", "array", "eq_default", "assocIndexOf_default", "arrayProto", "splice", "listCacheDelete", "lastIndex", "listCacheDelete_default", "listCacheGet", "listCacheGet_default", "listCacheHas", "listCacheHas_default", "listCacheSet", "listCacheSet_default", "ListCache", "ListCache_default", "Map", "root_default", "Map_default", "mapCacheClear", "mapCacheClear_default", "isKeyable", "type", "isKeyable_default", "getMapData", "map", "getMapData_default", "mapCacheDelete", "mapCacheDelete_default", "mapCacheGet", "mapCacheGet_default", "mapCacheHas", "mapCacheHas_default", "mapCacheSet", "size", "mapCacheSet_default", "MapCache", "MapCache_default", "stackClear", "ListCache_default", "stackClear_default", "stackDelete", "key", "data", "result", "stackDelete_default", "stackGet", "stackGet_default", "stackHas", "stackHas_default", "LARGE_ARRAY_SIZE", "stackSet", "value", "pairs", "Map_default", "MapCache_default", "stackSet_default", "Stack", "entries", "objectProto", "propertyIsEnumerable", "DataView", "getNative_default", "root_default", "DataView_default", "Promise", "Promise_default", "Set", "Set_default", "mapTag", "objectTag", "promiseTag", "setTag", "weakMapTag", "dataViewTag", "dataViewCtorString", "toSource_default", "mapCtorString", "Map_default", "promiseCtorString", "setCtorString", "weakMapCtorString", "WeakMap_default", "getTag", "baseGetTag_default", "value", "result", "Ctor", "ctorString", "Uint8Array", "root_default", "HASH_UNDEFINED", "setCacheAdd", "value", "setCacheAdd_default", "setCacheHas", "setCacheHas_default", "SetCache", "values", "index", "length", "MapCache_default", "symbolProto", "Symbol_default", "symbolValueOf", "objectProto", "hasOwnProperty", "objectProto", "hasOwnProperty", "HEX_COLOR_PATTERN", "HEX_SINGLE_CHAR_COMPONENTS_PATTERN", "HEX_DOUBLE_CHAR_COMPONENTS_PATTERN", "mimeTypeToExtension", "mimeType", "bufferURIToObjectURL", "uri", "engine", "mimeType", "length", "data", "blob", "getImageDimensionsFromURL", "url", "engine", "resolvedUrl", "bufferURIToObjectURL", "resolve", "reject", "img", "getImageUri", "blockId", "options", "uri", "fillBlock", "sourceSet", "source", "isDefined", "value", "isDefined_default", "Icons", "formats_default", "renderImageUrlProperty", "provderId", "options", "cesdk", "propertyKey", "panelIdForImageSelection", "getImageSelectionPanelId", "createPanels", "context", "property", "builder", "global", "payload", "defaultUrl", "stateValue", "assetResult", "providerId", "asset", "uri", "mimeType", "renderImageUrlProperty_default", "CustomAssetSource", "id", "assets", "selectValue", "queryData", "page", "perPage", "locale", "sortActiveFirst", "query", "tags", "groups", "excludeGroups", "sortingOrder", "sortKey", "filteredAssets", "group", "lowerQuery", "label", "assetTags", "tag", "tagArray", "a", "b", "aActive", "bActive", "aValue", "bValue", "total", "startIndex", "endIndex", "resultAssets", "nextPage", "assetId", "assetIds", "existingIndex", "index", "freeGlobal", "freeGlobal_default", "freeSelf", "root", "root_default", "Symbol", "Symbol_default", "objectProto", "hasOwnProperty", "nativeObjectToString", "symToStringTag", "getRawTag", "value", "isOwn", "tag", "unmasked", "result", "getRawTag_default", "objectToString", "objectToString_default", "nullTag", "undefinedTag", "baseGetTag", "baseGetTag_default", "isObjectLike", "isObjectLike_default", "isArray", "isObject", "type", "isObject_default", "asyncTag", "funcTag", "genTag", "proxyTag", "isFunction", "isFunction_default", "coreJsData", "coreJsData_default", "maskSrcKey", "uid", "isMasked", "func", "isMasked_default", "funcProto", "funcToString", "toSource", "toSource_default", "reRegExpChar", "reIsHostCtor", "reIsNative", "baseIsNative", "pattern", "baseIsNative_default", "getValue", "object", "key", "getValue_default", "getNative", "getNative_default", "WeakMap", "WeakMap_default", "eq", "other", "eq_default", "MAX_SAFE_INTEGER", "isLength", "isLength_default", "argsTag", "baseIsArguments", "baseIsArguments_default", "propertyIsEnumerable", "isArguments", "freeExports", "freeModule", "moduleExports", "Buffer", "nativeIsBuffer", "arrayTag", "boolTag", "dateTag", "errorTag", "mapTag", "numberTag", "objectTag", "regexpTag", "setTag", "stringTag", "weakMapTag", "arrayBufferTag", "dataViewTag", "float32Tag", "float64Tag", "int8Tag", "int16Tag", "int32Tag", "uint8Tag", "uint8ClampedTag", "uint16Tag", "uint32Tag", "typedArrayTags", "baseIsTypedArray", "baseIsTypedArray_default", "baseUnary", "baseUnary_default", "freeProcess", "nodeUtil", "types", "nodeUtil_default", "nodeIsTypedArray", "isTypedArray", "overArg", "transform", "arg", "overArg_default", "nativeKeys", "nativeCreate", "nativeCreate_default", "hashClear", "hashClear_default", "hashDelete", "hashDelete_default", "HASH_UNDEFINED", "hashGet", "data", "hashGet_default", "hashHas", "hashHas_default", "hashSet", "hashSet_default", "Hash", "entries", "index", "length", "entry", "Hash_default", "listCacheClear", "listCacheClear_default", "assocIndexOf", "array", "assocIndexOf_default", "arrayProto", "splice", "listCacheDelete", "lastIndex", "listCacheDelete_default", "listCacheGet", "listCacheGet_default", "listCacheHas", "listCacheHas_default", "listCacheSet", "listCacheSet_default", "ListCache", "ListCache_default", "Map", "Map_default", "mapCacheClear", "mapCacheClear_default", "isKeyable", "isKeyable_default", "getMapData", "map", "getMapData_default", "mapCacheDelete", "mapCacheDelete_default", "mapCacheGet", "mapCacheGet_default", "mapCacheHas", "mapCacheHas_default", "mapCacheSet", "size", "mapCacheSet_default", "MapCache", "MapCache_default", "stackClear", "stackClear_default", "stackDelete", "stackDelete_default", "stackGet", "stackGet_default", "stackHas", "stackHas_default", "LARGE_ARRAY_SIZE", "stackSet", "pairs", "stackSet_default", "Stack", "DataView", "DataView_default", "Promise", "Promise_default", "Set", "Set_default", "promiseTag", "dataViewCtorString", "mapCtorString", "promiseCtorString", "setCtorString", "weakMapCtorString", "getTag", "Ctor", "ctorString", "Uint8Array", "setCacheAdd", "setCacheAdd_default", "setCacheHas", "setCacheHas_default", "SetCache", "values", "symbolProto", "symbolValueOf", "HEX_COLOR_PATTERN", "HEX_SINGLE_CHAR_COMPONENTS_PATTERN", "HEX_DOUBLE_CHAR_COMPONENTS_PATTERN", "bufferURIToObjectURL", "uri", "engine", "mimeType", "length", "data", "blob", "getImageUri", "blockId", "engine", "options", "uri", "fillBlock", "sourceSet", "source", "bufferURIToObjectURL", "isDefined", "value", "isDefined_default", "renderStyleTransferProperty", "providerId", "cesdk", "propertyKey", "panelIdForStyleSelection", "getStyleSelectionPanelId", "defaultStyles", "getDefaultStyles", "styles", "styleAssetSource", "createStyleAssetSource", "styleAssetSourceId", "addStyleAssetSource", "createPanels", "context", "property", "promptState", "activeAssetId", "asset", "builder", "state", "styleState", "payload", "panelId", "entryId", "STYLES", "style", "Xs", "styleValues", "allSourceIds", "assetSourceId", "ye", "defaultStyle", "label", "renderStyleTransferProperty_default", "AI_PANEL_ID_PREFIX", "getPanelId", "providerId", "AI_PANEL_ID_PREFIX", "PLUGIN_ICON_SET_ID", "ICON_SPRITE", "QUICK_ACTION_ORDER_KEY_PREFIX", "QUICK_ACTION_REGISTRY_PREFIX", "getQuickActionMenu", "cesdk", "id", "quickActionIds", "quickAction", "entries", "quickActionId", "getQuickActionMenu_default", "QuickActionBasePrompt", "options", "id", "builder", "toggleExpand", "state", "experimental", "context", "promptState", "prompt", "error", "QuickActionBasePrompt_default", "QuickActionBaseButton", "QuickActionBaseButton_default", "QuickActionBaseSelect", "item", "generate", "closeMenu", "handleGenerationError", "blockId", "uri", "Qs", "input", "QuickActionBaseSelect_default", "QuickActionBaseLibrary", "assetResult", "QuickActionBaseLibrary_default", "enableImageFill", "engine", "blockIds", "blockId", "fillBlock", "enableImageFill_default", "QuickActionChangeImage", "options", "id", "QuickActionBasePrompt_default", "prompt", "context", "uri", "Qs", "input", "QuickActionChangeImage_default", "QuickActionImageVariant", "type", "duplicated", "childId", "parent", "parentWidth", "parentHeight", "offset", "QuickActionImageVariant_default", "QuickActionCombineImages", "offsetFactor", "uris", "QuickActionCombineImages_default", "userPrompt", "QuickActionSwapImageBackground_default", "CommonProperties", "renderImageUrlProperty_default", "renderStyleTransferProperty_default", "GptImage1_text2image_default", "b64JsonToBlob", "b64_json", "mimeType", "base64Data", "byteCharacters", "byteArrays", "i", "byteArray", "STYLES", "createStyleAssetSource", "assetSourceId", "options", "styleValues", "style", "Xs", "styleAssetSource", "ye", "defaultStyle", "addStyleAssetSource", "label", "GptImage1", "config", "cesdk", "getProvider", "modelKey", "baseURL", "styleAssetSourceId", "styleAssetSource", "createStyleAssetSource", "addStyleAssetSource", "W", "builder", "payload", "asset", "Lu", "GptImage1_text2image_default", "state", "property", "styleState", "STYLES", "newValue", "input", "abortSignal", "stylePrompt", "style", "prompt", "hasGlobalAPIKey", "baseUrl", "b64_json", "blob", "b64JsonToBlob", "GptImage1_image2image_default", "MimeType", "GptImage1", "config", "cesdk", "getProvider", "modelKey", "Lu", "baseURL", "quickActions", "createQuickActions", "quickActionMenu", "De", "styleAssetSourceId", "styleAssetSource", "createStyleAssetSource", "addStyleAssetSource", "GptImage1_image2image_default", "Nl", "input", "width", "height", "Zs", "abortSignal", "formData", "blockId", "exportedBlob", "MimeType", "image_url", "mimeType", "resolvedImageUrl", "he", "imageUrlBlob", "gr", "hasGlobalAPIKey", "baseUrl", "b64_json", "blob", "b64JsonToBlob", "options", "Jo", "L", "context", "uri", "Qs", "styleId", "style", "STYLES", "id", "Wo", "ca", "ia", "aa", "prompt", "duplicatedBlockId", "la", "uris", "Yo", "engine", "blockIds", "page", "exportedPageBlob", "exportedPageUrl", "duplicatedPage", "childId", "positionX", "positionY", "shape", "rasterizedPageBlock", "fillBlock", "E", "OpenAi", "GptImage1", "open_ai_default"]
7
7
  }