Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@volcengine/imagex-hybrid-react

Package Overview
Dependencies
Maintainers
23
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@volcengine/imagex-hybrid-react - npm Package Compare versions

Comparing version 0.1.2-alpha.3 to 0.1.2

2

es/index.js

@@ -1,1 +0,1 @@

import React,{useRef,useEffect}from"react";var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,t){e.__proto__=t}:function(e,t){for(var A in t)Object.prototype.hasOwnProperty.call(t,A)&&(e[A]=t[A])}))(e,t)};function __extends(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function A(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(A.prototype=t.prototype,new A)}var __assign=function(){return(__assign=Object.assign||function(e){for(var t,A=1,r=arguments.length;A<r;A++)for(var n in t=arguments[A])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function __rest(e,t){var A={};for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(A[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(A[n[r]]=e[n[r]]);return A}function __awaiter(e,o,a,s){return new(a=a||Promise)(function(A,t){function r(e){try{i(s.next(e))}catch(e){t(e)}}function n(e){try{i(s.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?A(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(r,n)}i((s=s.apply(e,o||[])).next())})}function __generator(r,n){var i,o,a,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},c={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function e(A){return function(e){var t=[A,e];if(i)throw new TypeError("Generator is already executing.");for(;s=c&&t[c=0]?0:s;)try{if(i=1,o&&(a=2&t[0]?o.return:t[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,t[1])).done)return a;switch(o=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return s.label++,{value:t[1],done:!1};case 5:s.label++,o=t[1],t=[0];continue;case 7:t=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){s=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3]))s.label=t[1];else if(6===t[0]&&s.label<a[1])s.label=a[1],a=t;else{if(!(a&&s.label<a[2])){a[2]&&s.ops.pop(),s.trys.pop();continue}s.label=a[2],s.ops.push(t)}}t=n.call(r,s)}catch(e){t=[6,e],o=0}finally{i=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}}var EMixRenderComponents,EMixRenderRuntime,EPlatform,ValidFormat$1=["webp","avif","heic","jpeg","png"],ValidPlatform=["Android","iOS"];function getGlobal(){return new Function("return this")()}!function(e){e.LivePlayer="live_player",e.Lottie="lottie_view",e.Image="web_image"}(EMixRenderComponents=EMixRenderComponents||{}),function(e){e.DIG="dig",e.EMBED="embed"}(EMixRenderRuntime=EMixRenderRuntime||{}),function(e){e.ANDROID="Android",e.IOS="iOS",e.UNKNOWN="unknown"}(EPlatform=EPlatform||{});var _systemInfo_,_useragent_,REGEXP_DETECT_PLATFORM=/(Android|iPhone)/;function getUserAgent(){var e;return _useragent_=_useragent_||(null==(e=getGlobal().navigator)?void 0:e.userAgent)||""}function getSystemInfo(){var e,t;return _systemInfo_||(e=getUserAgent().match(REGEXP_DETECT_PLATFORM),t=EPlatform.UNKNOWN,e&&(t="Android"===e[1]?EPlatform.ANDROID:EPlatform.IOS),_systemInfo_={platform:t}),_systemInfo_}function isAndroid(){return getSystemInfo().platform===EPlatform.ANDROID}var MixRenderCallbackRegistry=function(){function e(){this._records={},this.id=0}return e.prototype.register=function(e){return this.id++,this._records[this.id]=e,this.id},e.prototype.unregister=function(e){this._records[e]=null},e.prototype.dispatch=function(e,t){var A=this._records[e],r=getMixRenderInstance();A&&(null!=(r=null==r?void 0:r.getLogger())&&r.log("callback, callbackId: ".concat(e,"; res: "),t),A(t))},e}(),MixRenderEventDelegate=function(){function e(){this._records={}}return e.prototype.addEventHandler=function(e,t,A){this._records[e]||(this._records[e]={}),this._records[e][t]||(this._records[e][t]=[]),this._records[e][t].push(A)},e.prototype.removeEventHandler=function(e,t,A){var r;this._records[e]&&(A?(r=this._records[e][t])&&-1<(A=r.indexOf(A))&&r.splice(A,1):this._records[e][t]=[])},e.prototype.dispatchEvent=function(e,t,A){this._records[e]&&(e=this._records[e][t])&&e.forEach(function(e){e(A)})},e}(),globalObject$3=getGlobal(),MixRenderLogger=function(){function e(e){this.prefix=e,this.isEnabled=!1,this.isEnabled=this.checkLoggerEnabled()}return e.prototype.log=function(e,t){this.isEnabled&&console.log(this.prefix,e,t)},e.prototype.warn=function(e){this.isEnabled&&console.warn(this.prefix,e)},e.prototype.error=function(e){this.isEnabled&&console.error(this.prefix,e)},e.prototype.checkLoggerEnabled=function(){var e=null==(e=globalObject$3.location)?void 0:e.href.split("?")[1];if(e)for(var t=0,A=e.split("&");t<A.length;t++)if(A[t]==="".concat("__pia_mixrender_logger__","=1"))return!0;return globalObject$3.__pia_mixrender_logger__},e}(),MixRenderCore=function(){function e(){this._id=0,this.CallbackRegistryImpl=MixRenderCallbackRegistry,this.EventDelegateImpl=MixRenderEventDelegate,this.LoggerImpl=MixRenderLogger}return e.prototype.registerImpl=function(e,t){switch(e){case"callbackRegistry":this.CallbackRegistryImpl=t;break;case"eventDelegate":this.EventDelegateImpl=t;break;case"logger":this.LoggerImpl=t}},e.prototype.init=function(){this._callback_registry_=new this.CallbackRegistryImpl,this._event_delegate_=new this.EventDelegateImpl,this._logger_=new this.LoggerImpl("[PIA MixRender]")},e.prototype.getCallbackRegistry=function(){return this._callback_registry_},e.prototype.getEventDelegate=function(){return this._event_delegate_},e.prototype.getLogger=function(){return this._logger_},e.prototype.getConfig=function(){return this._config_},e.prototype.setConfig=function(e){this._config_=e},e.prototype.allocateId=function(){return this._id++},e}();function getMixRenderInstance(){var e,t=getGlobal();return t._mix_render_core_||((e=new MixRenderCore).init(),t._mix_render_core_=e),t._mix_render_core_}function addMixRenderEventHandler(e,t,A){getMixRenderInstance().getEventDelegate().addEventHandler(e,t,A)}function removeMixRenderEventHandler(e,t,A){getMixRenderInstance().getEventDelegate().removeEventHandler(e,t,A)}var _a,globalObject$2=getGlobal();function call(e,t,A,r){var n,i=globalObject$2.byted_mixrender_native;i&&(n=getMixRenderInstance(),r=r?n.getCallbackRegistry().register(r):-1,i.invoke(e,t,JSON.stringify(A),r),n.getLogger().log("invoke, native component id ".concat(e,", command: ").concat(t,", callbackId: ").concat(r,", params: "),A))}function callSync(e,t){var A=globalObject$2.byted_mixrender_native;return null==A||!A.invokeSync||0!==(null==(A=JSON.parse(A.invokeSync(e,JSON.stringify(t))||""))?void 0:A.status)||null==A?void 0:A.data}function allocateId(){return getMixRenderInstance().allocateId()}var globalObject$1=getGlobal();function getMixRenderConfig(){var e,t=getMixRenderInstance();return t.getConfig()||(e=globalObject$1.byted_mixrender_config,t.getLogger().log("nativeConfig",e),e?t.setConfig(e):isAndroid()&&(e=callSync("getFeatures",null),t.setConfig(e),t.getLogger().log("GetFeatures",e))),t.getConfig()}function canIUse(e,t){void 0===t&&(t=!1);var A,r=getMixRenderConfig();return!(!(r&&r.mixrender_component_support_list&&r.mixrender_component_support_list[e])||(A="".concat(r.mixrender_component_support_list[e]),!t&&inBlockList(e,A))||isAndroid()&&1!==(null==(t=null==r?void 0:r.mixrender_runtime_support_list)?void 0:t.embed))}function isRuntimeModeSupport(e){var t;return!isAndroid()||(t=getMixRenderConfig())&&t.mixrender_runtime_support_list&&1===(null==(t=t.mixrender_runtime_support_list)?void 0:t[e])}var BLOCK_LIST={Android:{MixRender:{},PiaMixRender:((_a={})[EMixRenderComponents.LivePlayer]=["1"],_a)},iOS:{MixRender:{}}};function inBlockList(e,t){var A,r=!1,n=[];if(n=(isAndroid()?(A=getMixRenderConfig(),isAndroid()&&A.mixrender_runtime_support_list?BLOCK_LIST.Android.PiaMixRender:BLOCK_LIST.Android.MixRender):BLOCK_LIST.iOS.MixRender)[e])for(var i=0,o=n;i<o.length;i++)if(o[i]===t){r=!0;break}return r}function translateMixRenderCallbackResponse(e){switch(e){case 0:return[!0];case-1:return[!1,"unknown function error"];case-2:return[!1,"error occurs when initializing"];case-3:return[!1,"call method with wrong params"];default:return[!1,"unknown error occurs"]}}var LegacyAdapter=function(){function e(e,t,A){this.id=e,this.type=t,this.mode=A}return e.prototype.init=function(e){var A=this;return new Promise(function(t){call(A.id,"initialize",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},e.prototype.update=function(e){var A=this;return new Promise(function(t){call(A.id,"update",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.destroy=function(e){var A=this;return void 0===e&&(e={}),new Promise(function(t){call(A.id,"destroy",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.log=function(e){var A=this;return new Promise(function(t){call(A.id,"debugLog",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.invoke=function(e){e.method,e.params;e=__rest(e,["method","params"]);return this.update(e)},e.prototype.addEventListener=function(e,t){addMixRenderEventHandler(this.id,e,t)},e.prototype.removeEventListener=function(e,t){removeMixRenderEventHandler(this.id,e,t)},e}(),SSRLegacyAdapter=function(){function e(e,t,A){this.id=e,this.type=t,this.mode=A}return e.prototype.init=function(e){return new Promise(function(e){e([!0])})},e.prototype.update=function(e){var A=this;return new Promise(function(t){call(A.id,"update",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.destroy=function(e){var A=this;return void 0===e&&(e={}),new Promise(function(t){call(A.id,"destroy",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.log=function(e){var A=this;return new Promise(function(t){call(A.id,"debugLog",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.invoke=function(e){e.method,e.params;e=__rest(e,["method","params"]);return this.update(e)},e.prototype.addEventListener=function(e,t){addMixRenderEventHandler(this.id,e,t)},e.prototype.removeEventListener=function(e,t){removeMixRenderEventHandler(this.id,e,t)},e}(),PiaMixRenderAdapter=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.init=function(A){var r=this;return new Promise(function(t){var e={type:r.type,properties:A};"embed"===r.mode&&(e.mode="embed"),call(r.id,"initialize",e,function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},t.prototype.invoke=function(r){var n=this;return new Promise(function(t){var e=r.method,A=r.params;call(n.id,"invokeMethod",{type:n.type,method:e,params:A},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},t}(LegacyAdapter),SSRPiaMixRenderAdapter=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.invoke=function(r){var n=this;return new Promise(function(t){var e=r.method,A=r.params;call(n.id,"invokeMethod",{type:n.type,method:e,params:A},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},t}(SSRLegacyAdapter);function getAdapterImpl(e,t){var A=getMixRenderConfig();return null!=t&&t.hybridRender?"Android"===(null==t?void 0:t.platform)?SSRPiaMixRenderAdapter:SSRLegacyAdapter:isAndroid()&&A&&A.mixrender_runtime_support_list?PiaMixRenderAdapter:LegacyAdapter}function setupAdapter(e,t,A,r){return new(getAdapterImpl(A=void 0===A?"embed":A,r))(e,t,A)}var TRANSFORM_BASE_BETWEEN_ID_AND_RGBA=255;function createPlaceholder4Android(e,t,A){var r;return"dig"===A?(e.setAttribute("tt-render-in-browser",String(t)),{destroy:function(){e.removeAttribute("tt-render-in-browser")}}):((r=document.createElement("embed")).setAttribute("tt-embed-id",String(t)),r.setAttribute("type","ttplugin/hybrid_component"),r.style.width="100%",r.style.height="100%",e.appendChild(r),{destroy:function(){e.removeChild(r)}})}function createPlaceholder4IOS(e,t){var A={overflow:e.style.overflow,"-webkit-overflow-scrolling":e.style["-webkit-overflow-scrolling"],backgroundColor:e.style.backgroundColor},r=Math.floor(t/TRANSFORM_BASE_BETWEEN_ID_AND_RGBA),t=Math.floor(t%TRANSFORM_BASE_BETWEEN_ID_AND_RGBA),n=(e.style.overflow="scroll",e.style["-webkit-overflow-scrolling"]="touch",e.style.backgroundColor="rgba(13, ".concat(r,", ").concat(t,", 0.13)"),document.createElement("div")),i=(n.style.width="100%",n.style.height="100%",e.appendChild(n),document.createElement("div"));return i.style.height="1px",e.appendChild(i),{destroy:function(){e.removeChild(n),e.removeChild(i),Object.assign(e.style,A)}}}function createPlaceholder(e,t,A){return isAndroid()?createPlaceholder4Android(e,t,A):createPlaceholder4IOS(e,t)}function callback(e,t){var A=getMixRenderInstance();A.getLogger().log("invoke native method callback, with: callbackId: ".concat(e,", res:"),t),A.getCallbackRegistry().dispatch(e,JSON.parse(t))}function invoke(e,t,A){var r=getMixRenderInstance();r.getLogger().log("trigger native event, with: id: ".concat(e,", command: ").concat(t,", params: "),A),r.getEventDelegate().dispatchEvent(e,t,JSON.parse(A))}var globalObject=getGlobal();function setupMixRenderWebHandle(){globalObject.byted_mixrender_web||(globalObject.byted_mixrender_web={invoke:invoke,callback:callback})}function getUsableRuntimeMode(e){return e||(isRuntimeModeSupport("embed")?"embed":"dig")}setupMixRenderWebHandle();var RegExp4Percentage=/(\d+)%/,RegExp4Pixel=/(\d+)px/,CSRImageWidget4Native=function(){function e(e){this.config=e,this.id=allocateId(),this.mode=getUsableRuntimeMode(this.config.mode),this.adapter=setupAdapter(this.id,EMixRenderComponents.Image,this.mode),this.cornerRadiusMatchRes4Percent=null==(e=this.config.cornerRadius)?void 0:e.match(RegExp4Percentage),this.cornerRadiusMatchRes4Pixel=null==(e=this.config.cornerRadius)?void 0:e.match(RegExp4Pixel),this.updateCornerRadiusWhenResize=this.updateCornerRadiusWhenResize.bind(this)}return e.prototype.init=function(){return __awaiter(this,void 0,void 0,function(){var t,A,r;return __generator(this,function(e){switch(e.label){case 0:return t=this.config.container,A=t.style.opacity||"1",t.style.opacity="0.1",this.placeholder=createPlaceholder(t,this.id,this.mode),(r=this.config).container,r.renderer,r.mode,r.cornerRadius,r=__rest(r,["container","renderer","mode","cornerRadius"]),this.log("widget init"),[4,this.adapter.init(__assign(__assign({},r),{cornerRadius:this.getCornerRadius()}))];case 1:return r=e.sent(),t.style.opacity=A,r[0]&&(this.cornerRadiusMatchRes4Percent&&window.addEventListener("resize",this.updateCornerRadiusWhenResize),t.style.background="rgba(0,0,0,0)"),[2,r]}})})},e.prototype.setSrc=function(e){return this.adapter.update({src:e})},e.prototype.setObjectFit=function(e){return this.adapter.update({objectFit:e})},e.prototype.setCornerRadius=function(e){return this.cornerRadiusMatchRes4Percent=(e=void 0===e?"":e).match(RegExp4Percentage),this.cornerRadiusMatchRes4Pixel=e.match(RegExp4Pixel),this.adapter.update({cornerRadius:this.getCornerRadius()})},e.prototype.log=function(e){return this.adapter.log({webLog:e})},e.prototype.destroy=function(){var A;return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return[4,null==(A=this.adapter)?void 0:A.destroy()];case 1:return(t=e.sent())[0]&&(null!=(A=this.placeholder)&&A.destroy(),this.cornerRadiusMatchRes4Percent)&&window.removeEventListener("resize",this.updateCornerRadiusWhenResize),[2,t]}})})},e.prototype.updateCornerRadiusWhenResize=function(){var e=this.getCornerRadius();this.adapter.update({cornerRadius:e})},e.prototype.getCornerRadius=function(){var e=this.config.container;return this.cornerRadiusMatchRes4Percent?e.getBoundingClientRect().width*+this.cornerRadiusMatchRes4Percent[1]/100:this.cornerRadiusMatchRes4Pixel?+this.cornerRadiusMatchRes4Pixel[1]:void 0},e}(),SSRImageWidget4Native=function(){function e(e){this.config=e,this.id=allocateId(),this.mode="embed"}return e.prototype.init=function(){return this.adapter=setupAdapter(this.id,EMixRenderComponents.Image,this.mode,this.config.ssrConfig),this.id},e.prototype.setSrc=function(e){return this.adapter.update({src:e})},e.prototype.setObjectFit=function(e){return this.adapter.update({objectFit:e})},e.prototype.setCornerRadius=function(e){return void 0===e&&(e=""),this.adapter.update({cornerRadius:Number(e)})},e.prototype.log=function(e){return this.adapter.log({webLog:e})},e.prototype.destroy=function(){var A;return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return[4,null==(A=this.adapter)?void 0:A.destroy()];case 1:return(t=e.sent())[0]&&null!=(A=this.placeholder)&&A.destroy(),[2,t]}})})},e}(),ImageWidget4Web=function(){function e(e){this.config=e}return e.prototype.init=function(){var e=this.config,t=e.container,A=e.src,r=e.objectFit,e=e.cornerRadius;return this.image=new Image,this.image.style.width="100%",this.image.style.height="100%",this.image.src=A,this.image.style.objectFit=r,this.image.style.borderRadius="".concat(e,"px"),t.appendChild(this.image),Promise.resolve([!0])},e.prototype.setSrc=function(e){return this.image.src=e,Promise.resolve([!0])},e.prototype.setObjectFit=function(e){return this.image.style.objectFit=e,Promise.resolve([!0])},e.prototype.setCornerRadius=function(e){return this.image.style.borderRadius=e=void 0===e?"":e,Promise.resolve([!0])},e.prototype.log=function(e){return Promise.resolve([!0])},e.prototype.destroy=function(){return this.config.container.removeChild(this.image),Promise.resolve([!0])},e}(),ValidFormat=["webp","avif","heic","jpeg","png"],FormatsMap={webp:"awebp",heic:"heif",avif:"avis",jpeg:"jpeg",png:"png"},ErrorImageXUrl={protocol:"http://",domain:"",src:"",search:"",template:"",suffix:""},ErrorUrl={protocol:"http://",domain:"",src:"",search:""},imagexUrlPattern=/^(.+)~(tplv-[a-zA-Z0-9]{2,10}-.+)\.([a-zA-Z]+)\??(.*)$/,FORMAT_BASE64_MAP={webp:{base64:"data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvn8AnAAdQiUpUov+BiOh/AAA=",height:160},heic:{base64:"data:image/heic;base64,AAAAHGZ0eXBtaWYxAAAAAG1pZjFoZWljaGV2YwAAASVtZXRhAAAAAAAAACFoZGxyAAAAAAAAAABwaWN0AAAAAAAAAAAAAAAAAAAAAA5waXRtAAAAAAABAAAAI2lpbmYAAAAAAAEAAAAVaW5mZQIAAAAAAQAAaHZjMQAAAACjaXBycAAAAIZpcGNvAAAAamh2Y0MBAWAAAAAAAAAAAAAe8AD8/fj4AAAPAyAAAQAYQAEMAf//AWAAAAMAAAMAAAMAAAMAHvAkIQABAB1CAQEBYAAAAwAAAwAAAwAAAwAeoDSBp3eX5JMrICIAAQAHRAHBLGDEgAAAABRpc3BlAAAAAAAAAGQAAABkAAAAFWlwbWEAAAAAAAAAAQABAoECAAAAJGlsb2MBAAAAREAAAQABAAAAAAAAAUkAAQAAAAAAAAAgAAAAKG1kYXQAAAAcJgGvJRNg+cJYeUBAgVGpfj2xh5SigAAENABAQA==",height:100},avif:{base64:"data:image/avif;base64,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",height:1}},check=function(r){return 0<=ValidFormat.indexOf(r)&&("jpeg"===r||"png"===r||!!FORMAT_BASE64_MAP[r]&&new Promise(function(t){if("undefined"==typeof window&&t(!1),void 0!==window["__support_".concat(r,"__")])t(!!window["__support_".concat(r,"__")]);else{if(FORMAT_BASE64_MAP[r].prerequisite)if(!FORMAT_BASE64_MAP[r].prerequisite())return window["__support_".concat(r,"__")]=!1,void t(!1);var A=new Image;A.onload=function(){var e=(null==A?void 0:A.height)===FORMAT_BASE64_MAP[r].height;window["__support_".concat(r,"__")]=e,t(e)},A.onerror=function(){window["__support_".concat(r,"__")]=!1,t(!1)},A.src=FORMAT_BASE64_MAP[r].base64}}))},getFormat=function(o){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,new Promise(function(i){__awaiter(void 0,void 0,void 0,function(){var t,A,r,n;return __generator(this,function(e){switch(e.label){case 0:"undefined"==typeof window&&i("image"),t=0,A=o,e.label=1;case 1:if(!(t<A.length))return[3,7];r=A[t],n=!1,e.label=2;case 2:return e.trys.push([2,4,,5]),[4,check(r)];case 3:return n=e.sent(),[3,5];case 4:return e.sent(),console.error("格式探测失败"),[3,5];case 5:if(n)return i(r),[3,7];e.label=6;case 6:return t++,[3,1];case 7:return i("image"),[2]}})})})];case 1:return[2,e.sent()]}})})},parseImagexUrl=function(e){try{var t=e.startsWith("http")?e:(e.startsWith("//")?"https:":"http://").concat(e),A=new URL(t),r=imagexUrlPattern.exec(A.pathname.slice(1));return{protocol:A.protocol,domain:A.hostname,src:r[1],template:r[2],suffix:r[3],search:A.search}}catch(e){return console.error(e),ErrorImageXUrl}},parseOtherUrl=function(e){try{var t=e.startsWith("http")?e:(e.startsWith("//")?"https:":"http://").concat(e),A=new URL(t);return{protocol:A.protocol,domain:A.hostname,src:A.pathname.slice(1),search:A.search}}catch(e){return ErrorUrl}},isImagexUrl=function(e){return imagexUrlPattern.test(e)},getSrc=function(e,t,A){var r,n,i,o,a,s;return t(isImagexUrl(e)?(i=(t=parseImagexUrl(e)).src,o=t.protocol,a=t.domain,r=t.suffix,n=t.template,s=t.search,{src:i,format:FormatsMap[A]||"image",extra:{suffix:r,template:n,search:s,protocol:o,domain:a,origin:e}}):(i=(t=parseOtherUrl(e)).src,o=t.protocol,a=t.domain,s=t.search,{src:i,format:FormatsMap[A]||"image",extra:{protocol:o,domain:a,search:s,origin:e}}))},isSupportNativeImage=canIUse(EMixRenderComponents.Image),CSRImageProxy=function(){function e(e){this.config=e,this.isInitialized=!1,this.renderFormat="image"}return e.prototype.init=function(){var i;return __awaiter(this,void 0,void 0,function(){var t,A,r,n;return __generator(this,function(e){switch(e.label){case 0:return t=this.config.renderer,A=this,"web"!==(t=t&&"auto"!==t?t:isSupportNativeImage?"native":"web")?[3,2]:[4,getFormat((this.config.formats||["avif","webp"]).filter(function(e){return"heic"!==e}))];case 1:return r=e.sent()||"image",[3,3];case 2:r=(null==(i=this.config.formats)?void 0:i[0])||"heic",e.label=3;case 3:return A.renderFormat=r,n=__assign(__assign({},this.config),{src:getSrc(this.config.src,this.config.loader,this.renderFormat||"image")}),this.widget=new("native"===t?CSRImageWidget4Native:ImageWidget4Web)(n),[4,this.widget.init()];case 4:return(n=e.sent())[0]&&(this.isInitialized=!0),[2,n]}})})},e.prototype.setSrc=function(e){return this.widget.setSrc(getSrc(e,this.config.loader,this.renderFormat||"image"))},e.prototype.setObjectFit=function(e){return this.widget.setObjectFit(e)},e.prototype.setCornerRadius=function(e){return this.widget.setCornerRadius(e)},e.prototype.destroy=function(){var e;return null==(e=this.widget)?void 0:e.destroy()},e}(),SSRImageProxy=function(){function e(e){this.config=e,this.isInitialized=!1,this.renderFormat="heic"}return e.prototype.init=function(){this.renderFormat="heic";var e=__assign(__assign({},this.config),{src:getSrc(this.config.src,this.config.loader,this.renderFormat)}),t=(this.widget=new SSRImageWidget4Native(e),this.widget.init());return this.isInitialized=!0,{id:t,src:e.src}},e.prototype.setSrc=function(e){var t;return null==(t=this.widget)?void 0:t.setSrc(getSrc(e,this.config.loader,this.renderFormat||"image"))},e.prototype.setObjectFit=function(e){var t;return null==(t=this.widget)?void 0:t.setObjectFit(e)},e.prototype.setCornerRadius=function(e){var t;return null==(t=this.widget)?void 0:t.setCornerRadius(e)},e.prototype.destroy=function(){var e;return null==(e=this.widget)?void 0:e.destroy()},e}();function createImageProxy(e){return new(void 0!==e.ssrConfig?SSRImageProxy:CSRImageProxy)(e)}var Viewer=function(t){var e,A,r=useRef(null),n=useRef(null),i=useRef(n.current&&n.current.isInitialized),o=useRef(-1);return useEffect(function(){var e;i.current=null==(e=n.current)?void 0:e.isInitialized},[null==(e=n.current)?void 0:e.isInitialized]),useEffect(function(){if(r.current)return i.current||(n.current=createImageProxy({container:r.current,renderer:t.renderer||"auto",src:t.src,loader:t.loader,objectFit:t.objectFit,cornerRadius:t.cornerRadius||"",formats:t.formats||["heic","avif","webp"]}),n.current.init().then(function(e){e[0]&&(i.current=!0)})),function(){var e;n.current&&n.current.destroy&&null!=(e=n.current)&&e.destroy()}},[]),useEffect(function(){var e;i.current&&null!=(e=n.current)&&e.setSrc(t.src)},[t.src]),useEffect(function(){var e;i.current&&null!=(e=n.current)&&e.setObjectFit(t.objectFit)},[t.objectFit]),useEffect(function(){var e;i.current&&null!=(e=n.current)&&e.setCornerRadius(t.cornerRadius)},[t.cornerRadius]),null!=(e=t.ssrConfig)&&e.isSSR&&null!=(e=t.ssrConfig)&&e.hybridRender&&-1===o.current&&(n.current=createImageProxy({renderer:"native",src:t.src,loader:t.loader,objectFit:t.objectFit,cornerRadius:t.cornerRadius||"",ssrConfig:t.ssrConfig}),e=n.current.init(),o.current=e.id,"undefined"==typeof window&&((A=new Function("return this")()).imagexSsrData||(A.imagexSsrData=[]),A.imagexSsrData.push(__assign(__assign({},e||{}),{width:t.width,height:t.height,objectFit:t.objectFit,cornerRadius:t.cornerRadius||""}))),i.current=!0),React.createElement("div",{className:"pia-mixrender-image",style:{width:t.width,height:t.height}},null!=(A=t.ssrConfig)&&A.isSSR?null!=(e=t.ssrConfig)&&e.hybridRender?"iOS"===(null==(A=t.ssrConfig)?void 0:A.platform)?React.createElement("div",{ref:r,style:{opacity:1,width:t.width,height:t.height,fontSize:0,lineHeight:0,overflow:"scroll",WebkitOverflowScrolling:"touch",backgroundColor:"rgba(13, ".concat(Math.floor(o.current/255),", ").concat(Math.floor(o.current%255),", 0.13)")}},React.createElement("div",{style:{width:"100%",height:"100%"}}),React.createElement("div",{style:{height:1}})):React.createElement("div",{ref:r,style:{opacity:1,width:t.width,height:t.height,fontSize:0,lineHeight:0}},React.createElement("embed",{"tt-embed-id":o.current,type:"ttplugin/hybrid_component",style:{width:"100%",height:"100%"}})):React.createElement("img",{src:getSrc(t.src,t.loader,"image"),style:{width:"100%",height:"100%",objectFit:t.objectFit,borderRadius:"".concat(Number(t.cornerRadius||0),"px")}}):React.createElement("div",{ref:r,style:{width:t.width,height:t.height,fontSize:0,lineHeight:0}}))},exportInitScript=function(){var e,t=new Function("return this")();return t.imagexSsrData?(e=';(function(e){document.addEventListener("DOMContentLoaded",function(){console.log("ImageX SSR Init");var i=window.byted_mixrender_native;console.log("byted_mixrender_native:",i);if(i)for(var t=0;t<(e||[]).length;t++){i.invoke(e[t].id,"initialize",JSON.stringify({type:"web_image",properties:{src:e[t].src,width:e[t].width,height:e[t].height,objectFit:e[t].objectFit,cornerRadius:e[t].cornerRadius}}),e[t].id);console.log("initialize:",e[t])}})})('.concat(JSON.stringify(t.imagexSsrData||[]),")"),t._mix_render_core_=void 0,t.imagexSsrData=void 0,e):""};export{CSRImageProxy,EMixRenderComponents,EMixRenderRuntime,SSRImageProxy,ValidFormat$1 as ValidFormat,ValidPlatform,Viewer,createImageProxy,exportInitScript};
import React,{useRef,useEffect}from"react";var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,t){e.__proto__=t}:function(e,t){for(var A in t)Object.prototype.hasOwnProperty.call(t,A)&&(e[A]=t[A])}))(e,t)};function __extends(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function A(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(A.prototype=t.prototype,new A)}var __assign=function(){return(__assign=Object.assign||function(e){for(var t,A=1,r=arguments.length;A<r;A++)for(var n in t=arguments[A])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function __rest(e,t){var A={};for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(A[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(A[n[r]]=e[n[r]]);return A}function __awaiter(e,o,a,s){return new(a=a||Promise)(function(A,t){function r(e){try{i(s.next(e))}catch(e){t(e)}}function n(e){try{i(s.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?A(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(r,n)}i((s=s.apply(e,o||[])).next())})}function __generator(r,n){var i,o,a,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},c={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function e(A){return function(e){var t=[A,e];if(i)throw new TypeError("Generator is already executing.");for(;s=c&&t[c=0]?0:s;)try{if(i=1,o&&(a=2&t[0]?o.return:t[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,t[1])).done)return a;switch(o=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return s.label++,{value:t[1],done:!1};case 5:s.label++,o=t[1],t=[0];continue;case 7:t=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){s=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3]))s.label=t[1];else if(6===t[0]&&s.label<a[1])s.label=a[1],a=t;else{if(!(a&&s.label<a[2])){a[2]&&s.ops.pop(),s.trys.pop();continue}s.label=a[2],s.ops.push(t)}}t=n.call(r,s)}catch(e){t=[6,e],o=0}finally{i=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}}var EMixRenderComponents,EMixRenderRuntime,EPlatform,ValidFormat$1=["webp","avif","heic","jpeg","png"],ValidPlatform=["Android","iOS"];function getGlobal(){return new Function("return this")()}!function(e){e.LivePlayer="live_player",e.Lottie="lottie_view",e.Image="web_image"}(EMixRenderComponents=EMixRenderComponents||{}),function(e){e.DIG="dig",e.EMBED="embed"}(EMixRenderRuntime=EMixRenderRuntime||{}),function(e){e.ANDROID="Android",e.IOS="iOS",e.UNKNOWN="unknown"}(EPlatform=EPlatform||{});var _systemInfo_,_useragent_,REGEXP_DETECT_PLATFORM=/(Android|iPhone)/;function getUserAgent(){var e;return _useragent_=_useragent_||(null==(e=getGlobal().navigator)?void 0:e.userAgent)||""}function getSystemInfo(){var e,t;return _systemInfo_||(e=getUserAgent().match(REGEXP_DETECT_PLATFORM),t=EPlatform.UNKNOWN,e&&(t="Android"===e[1]?EPlatform.ANDROID:EPlatform.IOS),_systemInfo_={platform:t}),_systemInfo_}function isAndroid(){return getSystemInfo().platform===EPlatform.ANDROID}var MixRenderCallbackRegistry=function(){function e(){this._records={},this.id=0}return e.prototype.register=function(e){return this.id++,this._records[this.id]=e,this.id},e.prototype.unregister=function(e){this._records[e]=null},e.prototype.dispatch=function(e,t){var A=this._records[e],r=getMixRenderInstance();A&&(null!=(r=null==r?void 0:r.getLogger())&&r.log("callback, callbackId: ".concat(e,"; res: "),t),A(t))},e}(),MixRenderEventDelegate=function(){function e(){this._records={}}return e.prototype.addEventHandler=function(e,t,A){this._records[e]||(this._records[e]={}),this._records[e][t]||(this._records[e][t]=[]),this._records[e][t].push(A)},e.prototype.removeEventHandler=function(e,t,A){var r;this._records[e]&&(A?(r=this._records[e][t])&&-1<(A=r.indexOf(A))&&r.splice(A,1):this._records[e][t]=[])},e.prototype.dispatchEvent=function(e,t,A){this._records[e]&&(e=this._records[e][t])&&e.forEach(function(e){e(A)})},e}(),globalObject$3=getGlobal(),MixRenderLogger=function(){function e(e){this.prefix=e,this.isEnabled=!1,this.isEnabled=this.checkLoggerEnabled()}return e.prototype.log=function(e,t){this.isEnabled&&console.log(this.prefix,e,t)},e.prototype.warn=function(e){this.isEnabled&&console.warn(this.prefix,e)},e.prototype.error=function(e){this.isEnabled&&console.error(this.prefix,e)},e.prototype.checkLoggerEnabled=function(){var e=null==(e=globalObject$3.location)?void 0:e.href.split("?")[1];if(e)for(var t=0,A=e.split("&");t<A.length;t++)if(A[t]==="".concat("__pia_mixrender_logger__","=1"))return!0;return globalObject$3.__pia_mixrender_logger__},e}(),MixRenderCore=function(){function e(){this._id=0,this.CallbackRegistryImpl=MixRenderCallbackRegistry,this.EventDelegateImpl=MixRenderEventDelegate,this.LoggerImpl=MixRenderLogger}return e.prototype.registerImpl=function(e,t){switch(e){case"callbackRegistry":this.CallbackRegistryImpl=t;break;case"eventDelegate":this.EventDelegateImpl=t;break;case"logger":this.LoggerImpl=t}},e.prototype.init=function(){this._callback_registry_=new this.CallbackRegistryImpl,this._event_delegate_=new this.EventDelegateImpl,this._logger_=new this.LoggerImpl("[PIA MixRender]")},e.prototype.getCallbackRegistry=function(){return this._callback_registry_},e.prototype.getEventDelegate=function(){return this._event_delegate_},e.prototype.getLogger=function(){return this._logger_},e.prototype.getConfig=function(){return this._config_},e.prototype.setConfig=function(e){this._config_=e},e.prototype.allocateId=function(){return this._id++},e}();function getMixRenderInstance(){var e,t=getGlobal();return t._mix_render_core_||((e=new MixRenderCore).init(),t._mix_render_core_=e),t._mix_render_core_}function addMixRenderEventHandler(e,t,A){getMixRenderInstance().getEventDelegate().addEventHandler(e,t,A)}function removeMixRenderEventHandler(e,t,A){getMixRenderInstance().getEventDelegate().removeEventHandler(e,t,A)}var _a,globalObject$2=getGlobal();function call(e,t,A,r){var n,i=globalObject$2.byted_mixrender_native;i&&(n=getMixRenderInstance(),r=r?n.getCallbackRegistry().register(r):-1,i.invoke(e,t,JSON.stringify(A),r),n.getLogger().log("invoke, native component id ".concat(e,", command: ").concat(t,", callbackId: ").concat(r,", params: "),A))}function callSync(e,t){var A=globalObject$2.byted_mixrender_native;return null==A||!A.invokeSync||0!==(null==(A=JSON.parse(A.invokeSync(e,JSON.stringify(t))||""))?void 0:A.status)||null==A?void 0:A.data}function allocateId(){return getMixRenderInstance().allocateId()}var globalObject$1=getGlobal();function getMixRenderConfig(){var e,t=getMixRenderInstance();return t.getConfig()||(e=globalObject$1.byted_mixrender_config,t.getLogger().log("nativeConfig",e),e?t.setConfig(e):isAndroid()&&(e=callSync("getFeatures",null),t.setConfig(e),t.getLogger().log("GetFeatures",e))),t.getConfig()}function canIUse(e,t){void 0===t&&(t=!1);var A,r=getMixRenderConfig();return!(!(r&&r.mixrender_component_support_list&&r.mixrender_component_support_list[e])||(A="".concat(r.mixrender_component_support_list[e]),!t&&inBlockList(e,A))||isAndroid()&&1!==(null==(t=null==r?void 0:r.mixrender_runtime_support_list)?void 0:t.embed))}function isRuntimeModeSupport(e){var t;return!isAndroid()||(t=getMixRenderConfig())&&t.mixrender_runtime_support_list&&1===(null==(t=t.mixrender_runtime_support_list)?void 0:t[e])}var BLOCK_LIST={Android:{MixRender:{},PiaMixRender:((_a={})[EMixRenderComponents.LivePlayer]=["1"],_a)},iOS:{MixRender:{}}};function inBlockList(e,t){var A,r=!1,n=[];if(n=(isAndroid()?(A=getMixRenderConfig(),isAndroid()&&A.mixrender_runtime_support_list?BLOCK_LIST.Android.PiaMixRender:BLOCK_LIST.Android.MixRender):BLOCK_LIST.iOS.MixRender)[e])for(var i=0,o=n;i<o.length;i++)if(o[i]===t){r=!0;break}return r}function translateMixRenderCallbackResponse(e){switch(e){case 0:return[!0];case-1:return[!1,"unknown function error"];case-2:return[!1,"error occurs when initializing"];case-3:return[!1,"call method with wrong params"];default:return[!1,"unknown error occurs"]}}var LegacyAdapter=function(){function e(e,t,A){this.id=e,this.type=t,this.mode=A}return e.prototype.init=function(e){var A=this;return new Promise(function(t){call(A.id,"initialize",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},e.prototype.update=function(e){var A=this;return new Promise(function(t){call(A.id,"update",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.destroy=function(e){var A=this;return void 0===e&&(e={}),new Promise(function(t){call(A.id,"destroy",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.log=function(e){var A=this;return new Promise(function(t){call(A.id,"debugLog",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.invoke=function(e){e.method,e.params;e=__rest(e,["method","params"]);return this.update(e)},e.prototype.addEventListener=function(e,t){addMixRenderEventHandler(this.id,e,t)},e.prototype.removeEventListener=function(e,t){removeMixRenderEventHandler(this.id,e,t)},e}(),SSRLegacyAdapter=function(){function e(e,t,A){this.id=e,this.type=t,this.mode=A}return e.prototype.init=function(e){return new Promise(function(e){e([!0])})},e.prototype.update=function(e){var A=this;return new Promise(function(t){call(A.id,"update",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.destroy=function(e){var A=this;return void 0===e&&(e={}),new Promise(function(t){call(A.id,"destroy",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.log=function(e){var A=this;return new Promise(function(t){call(A.id,"debugLog",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.invoke=function(e){e.method,e.params;e=__rest(e,["method","params"]);return this.update(e)},e.prototype.addEventListener=function(e,t){addMixRenderEventHandler(this.id,e,t)},e.prototype.removeEventListener=function(e,t){removeMixRenderEventHandler(this.id,e,t)},e}(),PiaMixRenderAdapter=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.init=function(A){var r=this;return new Promise(function(t){var e={type:r.type,properties:A};"embed"===r.mode&&(e.mode="embed"),call(r.id,"initialize",e,function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},t.prototype.invoke=function(r){var n=this;return new Promise(function(t){var e=r.method,A=r.params;call(n.id,"invokeMethod",{type:n.type,method:e,params:A},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},t}(LegacyAdapter),SSRPiaMixRenderAdapter=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.invoke=function(r){var n=this;return new Promise(function(t){var e=r.method,A=r.params;call(n.id,"invokeMethod",{type:n.type,method:e,params:A},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},t}(SSRLegacyAdapter);function getAdapterImpl(e,t){var A=getMixRenderConfig();return null!=t&&t.hybridRender?"Android"===(null==t?void 0:t.platform)?SSRPiaMixRenderAdapter:SSRLegacyAdapter:isAndroid()&&A&&A.mixrender_runtime_support_list?PiaMixRenderAdapter:LegacyAdapter}function setupAdapter(e,t,A,r){return new(getAdapterImpl(A=void 0===A?"embed":A,r))(e,t,A)}var TRANSFORM_BASE_BETWEEN_ID_AND_RGBA=255;function createPlaceholder4Android(e,t,A){var r;return"dig"===A?(e.setAttribute("tt-render-in-browser",String(t)),{destroy:function(){e.removeAttribute("tt-render-in-browser")}}):((r=document.createElement("embed")).setAttribute("tt-embed-id",String(t)),r.setAttribute("type","ttplugin/hybrid_component"),r.style.width="100%",r.style.height="100%",e.appendChild(r),{destroy:function(){e.removeChild(r)}})}function createPlaceholder4IOS(e,t){var A={overflow:e.style.overflow,"-webkit-overflow-scrolling":e.style["-webkit-overflow-scrolling"],backgroundColor:e.style.backgroundColor},r=Math.floor(t/TRANSFORM_BASE_BETWEEN_ID_AND_RGBA),t=Math.floor(t%TRANSFORM_BASE_BETWEEN_ID_AND_RGBA),n=(e.style.overflow="scroll",e.style["-webkit-overflow-scrolling"]="touch",e.style.backgroundColor="rgba(13, ".concat(r,", ").concat(t,", 0.13)"),document.createElement("div")),i=(n.style.width="100%",n.style.height="100%",e.appendChild(n),document.createElement("div"));return i.style.height="1px",e.appendChild(i),{destroy:function(){e.removeChild(n),e.removeChild(i),Object.assign(e.style,A)}}}function createPlaceholder(e,t,A){return isAndroid()?createPlaceholder4Android(e,t,A):createPlaceholder4IOS(e,t)}function callback(e,t){var A=getMixRenderInstance();A.getLogger().log("invoke native method callback, with: callbackId: ".concat(e,", res:"),t),A.getCallbackRegistry().dispatch(e,JSON.parse(t))}function invoke(e,t,A){var r=getMixRenderInstance();r.getLogger().log("trigger native event, with: id: ".concat(e,", command: ").concat(t,", params: "),A),r.getEventDelegate().dispatchEvent(e,t,JSON.parse(A))}var globalObject=getGlobal();function setupMixRenderWebHandle(){globalObject.byted_mixrender_web||(globalObject.byted_mixrender_web={invoke:invoke,callback:callback})}function getUsableRuntimeMode(e){return e||(isRuntimeModeSupport("embed")?"embed":"dig")}setupMixRenderWebHandle();var RegExp4Percentage=/(\d+)%/,RegExp4Pixel=/(\d+)px/,CSRImageWidget4Native=function(){function e(e){this.config=e,this.id=allocateId(),this.mode=getUsableRuntimeMode(this.config.mode),this.adapter=setupAdapter(this.id,EMixRenderComponents.Image,this.mode),this.cornerRadiusMatchRes4Percent=null==(e=this.config.cornerRadius)?void 0:e.match(RegExp4Percentage),this.cornerRadiusMatchRes4Pixel=null==(e=this.config.cornerRadius)?void 0:e.match(RegExp4Pixel),this.updateCornerRadiusWhenResize=this.updateCornerRadiusWhenResize.bind(this)}return e.prototype.init=function(){return __awaiter(this,void 0,void 0,function(){var t,A,r;return __generator(this,function(e){switch(e.label){case 0:return t=this.config.container,A=t.style.opacity||"1",t.style.opacity="0.1",this.placeholder=createPlaceholder(t,this.id,this.mode),(r=this.config).container,r.renderer,r.mode,r.cornerRadius,r=__rest(r,["container","renderer","mode","cornerRadius"]),this.log("widget init"),[4,this.adapter.init(__assign(__assign({},r),{cornerRadius:this.getCornerRadius()}))];case 1:return r=e.sent(),t.style.opacity=A,r[0]&&(this.cornerRadiusMatchRes4Percent&&window.addEventListener("resize",this.updateCornerRadiusWhenResize),t.style.background="rgba(0,0,0,0)"),[2,r]}})})},e.prototype.setSrc=function(e){return this.adapter.update({src:e})},e.prototype.setObjectFit=function(e){return this.adapter.update({objectFit:e})},e.prototype.setCornerRadius=function(e){return this.cornerRadiusMatchRes4Percent=(e=void 0===e?"":e).match(RegExp4Percentage),this.cornerRadiusMatchRes4Pixel=e.match(RegExp4Pixel),this.adapter.update({cornerRadius:this.getCornerRadius()})},e.prototype.log=function(e){return this.adapter.log({webLog:e})},e.prototype.destroy=function(){var A;return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return[4,null==(A=this.adapter)?void 0:A.destroy()];case 1:return(t=e.sent())[0]&&(null!=(A=this.placeholder)&&A.destroy(),this.cornerRadiusMatchRes4Percent)&&window.removeEventListener("resize",this.updateCornerRadiusWhenResize),[2,t]}})})},e.prototype.updateCornerRadiusWhenResize=function(){var e=this.getCornerRadius();this.adapter.update({cornerRadius:e})},e.prototype.getCornerRadius=function(){var e=this.config.container;return this.cornerRadiusMatchRes4Percent?e.getBoundingClientRect().width*+this.cornerRadiusMatchRes4Percent[1]/100:this.cornerRadiusMatchRes4Pixel?+this.cornerRadiusMatchRes4Pixel[1]:void 0},e}(),SSRImageWidget4Native=function(){function e(e){this.config=e,this.id=allocateId(),this.mode="embed"}return e.prototype.init=function(){return this.adapter=setupAdapter(this.id,EMixRenderComponents.Image,this.mode,this.config.ssrConfig),this.id},e.prototype.setSrc=function(e){return this.adapter.update({src:e})},e.prototype.setObjectFit=function(e){return this.adapter.update({objectFit:e})},e.prototype.setCornerRadius=function(e){e=(e=void 0===e?"":e).match(RegExp4Pixel);if(e)return this.adapter.update({cornerRadius:+e[1]})},e.prototype.log=function(e){return this.adapter.log({webLog:e})},e.prototype.destroy=function(){var A;return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return[4,null==(A=this.adapter)?void 0:A.destroy()];case 1:return(t=e.sent())[0]&&null!=(A=this.placeholder)&&A.destroy(),[2,t]}})})},e}(),ImageWidget4Web=function(){function e(e){this.config=e}return e.prototype.init=function(){var e=this.config,t=e.container,A=e.src,r=e.objectFit,e=e.cornerRadius;return this.image=new Image,this.image.style.width="100%",this.image.style.height="100%",this.image.src=A,this.image.style.objectFit=r,this.image.style.borderRadius=e,t.appendChild(this.image),Promise.resolve([!0])},e.prototype.setSrc=function(e){return this.image.src=e,Promise.resolve([!0])},e.prototype.setObjectFit=function(e){return this.image.style.objectFit=e,Promise.resolve([!0])},e.prototype.setCornerRadius=function(e){return this.image.style.borderRadius=e=void 0===e?"":e,Promise.resolve([!0])},e.prototype.log=function(e){return Promise.resolve([!0])},e.prototype.destroy=function(){return this.config.container.removeChild(this.image),Promise.resolve([!0])},e}(),ValidFormat=["webp","avif","heic","jpeg","png"],FormatsMap={webp:"awebp",heic:"heif",avif:"avis",jpeg:"jpeg",png:"png"},ErrorImageXUrl={protocol:"http://",domain:"",src:"",search:"",template:"",suffix:""},ErrorUrl={protocol:"http://",domain:"",src:"",search:""},imagexUrlPattern=/^(.+)~(tplv-[a-zA-Z0-9]{2,10}-.+)\.([a-zA-Z]+)\??(.*)$/,FORMAT_BASE64_MAP={webp:{base64:"data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvn8AnAAdQiUpUov+BiOh/AAA=",height:160},heic:{base64:"data:image/heic;base64,AAAAHGZ0eXBtaWYxAAAAAG1pZjFoZWljaGV2YwAAASVtZXRhAAAAAAAAACFoZGxyAAAAAAAAAABwaWN0AAAAAAAAAAAAAAAAAAAAAA5waXRtAAAAAAABAAAAI2lpbmYAAAAAAAEAAAAVaW5mZQIAAAAAAQAAaHZjMQAAAACjaXBycAAAAIZpcGNvAAAAamh2Y0MBAWAAAAAAAAAAAAAe8AD8/fj4AAAPAyAAAQAYQAEMAf//AWAAAAMAAAMAAAMAAAMAHvAkIQABAB1CAQEBYAAAAwAAAwAAAwAAAwAeoDSBp3eX5JMrICIAAQAHRAHBLGDEgAAAABRpc3BlAAAAAAAAAGQAAABkAAAAFWlwbWEAAAAAAAAAAQABAoECAAAAJGlsb2MBAAAAREAAAQABAAAAAAAAAUkAAQAAAAAAAAAgAAAAKG1kYXQAAAAcJgGvJRNg+cJYeUBAgVGpfj2xh5SigAAENABAQA==",height:100},avif:{base64:"data:image/avif;base64,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",height:1}},check=function(r){return 0<=ValidFormat.indexOf(r)&&("jpeg"===r||"png"===r||!!FORMAT_BASE64_MAP[r]&&new Promise(function(t){if("undefined"==typeof window&&t(!1),void 0!==window["__support_".concat(r,"__")])t(!!window["__support_".concat(r,"__")]);else{if(FORMAT_BASE64_MAP[r].prerequisite)if(!FORMAT_BASE64_MAP[r].prerequisite())return window["__support_".concat(r,"__")]=!1,void t(!1);var A=new Image;A.onload=function(){var e=(null==A?void 0:A.height)===FORMAT_BASE64_MAP[r].height;window["__support_".concat(r,"__")]=e,t(e)},A.onerror=function(){window["__support_".concat(r,"__")]=!1,t(!1)},A.src=FORMAT_BASE64_MAP[r].base64}}))},getFormat=function(o){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,new Promise(function(i){__awaiter(void 0,void 0,void 0,function(){var t,A,r,n;return __generator(this,function(e){switch(e.label){case 0:"undefined"==typeof window&&i("image"),t=0,A=o,e.label=1;case 1:if(!(t<A.length))return[3,7];r=A[t],n=!1,e.label=2;case 2:return e.trys.push([2,4,,5]),[4,check(r)];case 3:return n=e.sent(),[3,5];case 4:return e.sent(),console.error("格式探测失败"),[3,5];case 5:if(n)return i(r),[3,7];e.label=6;case 6:return t++,[3,1];case 7:return i("image"),[2]}})})})];case 1:return[2,e.sent()]}})})},parseImagexUrl=function(e){try{var t=e.startsWith("http")?e:(e.startsWith("//")?"https:":"http://").concat(e),A=new URL(t),r=imagexUrlPattern.exec(A.pathname.slice(1));return{protocol:A.protocol,domain:A.hostname,src:r[1],template:r[2],suffix:r[3],search:A.search}}catch(e){return console.error(e),ErrorImageXUrl}},parseOtherUrl=function(e){try{var t=e.startsWith("http")?e:(e.startsWith("//")?"https:":"http://").concat(e),A=new URL(t);return{protocol:A.protocol,domain:A.hostname,src:A.pathname.slice(1),search:A.search}}catch(e){return ErrorUrl}},isImagexUrl=function(e){return imagexUrlPattern.test(e)},getSrc=function(e,t,A){var r,n,i,o,a,s;return t(isImagexUrl(e)?(i=(t=parseImagexUrl(e)).src,o=t.protocol,a=t.domain,r=t.suffix,n=t.template,s=t.search,{src:i,format:FormatsMap[A]||"image",extra:{suffix:r,template:n,search:s,protocol:o,domain:a,origin:e}}):(i=(t=parseOtherUrl(e)).src,o=t.protocol,a=t.domain,s=t.search,{src:i,format:FormatsMap[A]||"image",extra:{protocol:o,domain:a,search:s,origin:e}}))},isSupportNativeImage=canIUse(EMixRenderComponents.Image),CSRImageProxy=function(){function e(e){this.config=e,this.isInitialized=!1,this.renderFormat="image"}return e.prototype.init=function(){var i;return __awaiter(this,void 0,void 0,function(){var t,A,r,n;return __generator(this,function(e){switch(e.label){case 0:return t=this.config.renderer,A=this,"web"!==(t=t&&"auto"!==t?t:isSupportNativeImage?"native":"web")?[3,2]:[4,getFormat((this.config.formats||["avif","webp"]).filter(function(e){return"heic"!==e}))];case 1:return r=e.sent()||"image",[3,3];case 2:r=(null==(i=this.config.formats)?void 0:i[0])||"heic",e.label=3;case 3:return A.renderFormat=r,n=__assign(__assign({},this.config),{src:getSrc(this.config.src,this.config.loader,this.renderFormat||"image")}),this.widget=new("native"===t?CSRImageWidget4Native:ImageWidget4Web)(n),[4,this.widget.init()];case 4:return(n=e.sent())[0]&&(this.isInitialized=!0),[2,n]}})})},e.prototype.setSrc=function(e){return this.widget.setSrc(getSrc(e,this.config.loader,this.renderFormat||"image"))},e.prototype.setObjectFit=function(e){return this.widget.setObjectFit(e)},e.prototype.setCornerRadius=function(e){return this.widget.setCornerRadius(e)},e.prototype.destroy=function(){var e;return null==(e=this.widget)?void 0:e.destroy()},e}(),SSRImageProxy=function(){function e(e){this.config=e,this.isInitialized=!1,this.renderFormat="heic"}return e.prototype.init=function(){this.renderFormat="heic";var e=__assign(__assign({},this.config),{src:getSrc(this.config.src,this.config.loader,this.renderFormat)}),t=(this.widget=new SSRImageWidget4Native(e),this.widget.init());return this.isInitialized=!0,{id:t,src:e.src}},e.prototype.setSrc=function(e){var t;return null==(t=this.widget)?void 0:t.setSrc(getSrc(e,this.config.loader,this.renderFormat||"image"))},e.prototype.setObjectFit=function(e){var t;return null==(t=this.widget)?void 0:t.setObjectFit(e)},e.prototype.setCornerRadius=function(e){var t;return null==(t=this.widget)?void 0:t.setCornerRadius(e)},e.prototype.destroy=function(){var e;return null==(e=this.widget)?void 0:e.destroy()},e}();function createImageProxy(e){return new(void 0!==e.ssrConfig?SSRImageProxy:CSRImageProxy)(e)}var Viewer=function(t){var e,A,r=useRef(null),n=useRef(null),i=useRef(n.current&&n.current.isInitialized),o=useRef(-1);return useEffect(function(){var e;i.current=null==(e=n.current)?void 0:e.isInitialized},[null==(e=n.current)?void 0:e.isInitialized]),useEffect(function(){if(r.current)return i.current||(n.current=createImageProxy({container:r.current,renderer:t.renderer||"auto",src:t.src,loader:t.loader,objectFit:t.objectFit,cornerRadius:t.cornerRadius||"",formats:t.formats||["heic","avif","webp"]}),n.current.init().then(function(e){e[0]&&(i.current=!0)})),function(){var e;n.current&&n.current.destroy&&null!=(e=n.current)&&e.destroy()}},[]),useEffect(function(){var e;i.current&&null!=(e=n.current)&&e.setSrc(t.src)},[t.src]),useEffect(function(){var e;i.current&&null!=(e=n.current)&&e.setObjectFit(t.objectFit)},[t.objectFit]),useEffect(function(){var e;i.current&&null!=(e=n.current)&&e.setCornerRadius(t.cornerRadius)},[t.cornerRadius]),null!=(e=t.ssrConfig)&&e.isSSR&&null!=(e=t.ssrConfig)&&e.hybridRender&&-1===o.current&&(n.current=createImageProxy({renderer:"native",src:t.src,loader:t.loader,objectFit:t.objectFit,cornerRadius:t.cornerRadius||"",ssrConfig:t.ssrConfig}),e=n.current.init(),o.current=e.id,"undefined"==typeof window&&((A=new Function("return this")()).imagexSsrData||(A.imagexSsrData=[]),A.imagexSsrData.push(__assign(__assign({},e||{}),{width:t.width,height:t.height,objectFit:t.objectFit,cornerRadius:t.cornerRadius||""}))),i.current=!0),React.createElement("div",{className:"pia-mixrender-image",style:{width:t.width,height:t.height}},null!=(A=t.ssrConfig)&&A.isSSR?null!=(e=t.ssrConfig)&&e.hybridRender?"iOS"===(null==(A=t.ssrConfig)?void 0:A.platform)?React.createElement("div",{ref:r,style:{opacity:1,width:t.width,height:t.height,fontSize:0,lineHeight:0,overflow:"scroll",WebkitOverflowScrolling:"touch",backgroundColor:"rgba(13, ".concat(Math.floor(o.current/255),", ").concat(Math.floor(o.current%255),", 0.13)")}},React.createElement("div",{style:{width:"100%",height:"100%"}}),React.createElement("div",{style:{height:1}})):React.createElement("div",{ref:r,style:{opacity:1,width:t.width,height:t.height,fontSize:0,lineHeight:0}},React.createElement("embed",{"tt-embed-id":o.current,type:"ttplugin/hybrid_component",style:{width:"100%",height:"100%"}})):React.createElement("img",{src:getSrc(t.src,t.loader,"image"),style:{width:"100%",height:"100%",objectFit:t.objectFit,borderRadius:t.cornerRadius}}):React.createElement("div",{ref:r,style:{width:t.width,height:t.height,fontSize:0,lineHeight:0}}))},exportInitScript=function(){var e,t=new Function("return this")();return t.imagexSsrData?(e=';(function(e){document.addEventListener("DOMContentLoaded",function(){console.log("ImageX SSR Init");var i=window.byted_mixrender_native;console.log("byted_mixrender_native:",i);if(i)for(var t=0;t<(e||[]).length;t++){i.invoke(e[t].id,"initialize",JSON.stringify({type:"web_image",mode:"embed",properties:{src:e[t].src,width:e[t].width,height:e[t].height,objectFit:e[t].objectFit,cornerRadius:e[t].cornerRadius}}),e[t].id);console.log("initialize:",e[t])}})})('.concat(JSON.stringify(t.imagexSsrData||[]),")"),t._mix_render_core_=void 0,t.imagexSsrData=void 0,e):""};export{CSRImageProxy,EMixRenderComponents,EMixRenderRuntime,SSRImageProxy,ValidFormat$1 as ValidFormat,ValidPlatform,Viewer,createImageProxy,exportInitScript};

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,t){e.__proto__=t}:function(e,t){for(var A in t)Object.prototype.hasOwnProperty.call(t,A)&&(e[A]=t[A])}))(e,t)};function __extends(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function A(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(A.prototype=t.prototype,new A)}var __assign=function(){return(__assign=Object.assign||function(e){for(var t,A=1,r=arguments.length;A<r;A++)for(var n in t=arguments[A])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function __rest(e,t){var A={};for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(A[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(A[n[r]]=e[n[r]]);return A}function __awaiter(e,o,a,s){return new(a=a||Promise)(function(A,t){function r(e){try{i(s.next(e))}catch(e){t(e)}}function n(e){try{i(s.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?A(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(r,n)}i((s=s.apply(e,o||[])).next())})}function __generator(r,n){var i,o,a,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},c={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function e(A){return function(e){var t=[A,e];if(i)throw new TypeError("Generator is already executing.");for(;s=c&&t[c=0]?0:s;)try{if(i=1,o&&(a=2&t[0]?o.return:t[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,t[1])).done)return a;switch(o=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return s.label++,{value:t[1],done:!1};case 5:s.label++,o=t[1],t=[0];continue;case 7:t=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){s=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3]))s.label=t[1];else if(6===t[0]&&s.label<a[1])s.label=a[1],a=t;else{if(!(a&&s.label<a[2])){a[2]&&s.ops.pop(),s.trys.pop();continue}s.label=a[2],s.ops.push(t)}}t=n.call(r,s)}catch(e){t=[6,e],o=0}finally{i=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}}var EPlatform,ValidFormat$1=["webp","avif","heic","jpeg","png"],ValidPlatform=["Android","iOS"];function getGlobal(){return new Function("return this")()}exports.EMixRenderComponents=void 0,function(e){e.LivePlayer="live_player",e.Lottie="lottie_view",e.Image="web_image"}(exports.EMixRenderComponents||(exports.EMixRenderComponents={})),exports.EMixRenderRuntime=void 0,function(e){e.DIG="dig",e.EMBED="embed"}(exports.EMixRenderRuntime||(exports.EMixRenderRuntime={})),function(e){e.ANDROID="Android",e.IOS="iOS",e.UNKNOWN="unknown"}(EPlatform=EPlatform||{});var _systemInfo_,_useragent_,REGEXP_DETECT_PLATFORM=/(Android|iPhone)/;function getUserAgent(){var e;return _useragent_=_useragent_||(null==(e=getGlobal().navigator)?void 0:e.userAgent)||""}function getSystemInfo(){var e,t;return _systemInfo_||(e=getUserAgent().match(REGEXP_DETECT_PLATFORM),t=EPlatform.UNKNOWN,e&&(t="Android"===e[1]?EPlatform.ANDROID:EPlatform.IOS),_systemInfo_={platform:t}),_systemInfo_}function isAndroid(){return getSystemInfo().platform===EPlatform.ANDROID}var MixRenderCallbackRegistry=function(){function e(){this._records={},this.id=0}return e.prototype.register=function(e){return this.id++,this._records[this.id]=e,this.id},e.prototype.unregister=function(e){this._records[e]=null},e.prototype.dispatch=function(e,t){var A=this._records[e],r=getMixRenderInstance();A&&(null!=(r=null==r?void 0:r.getLogger())&&r.log("callback, callbackId: ".concat(e,"; res: "),t),A(t))},e}(),MixRenderEventDelegate=function(){function e(){this._records={}}return e.prototype.addEventHandler=function(e,t,A){this._records[e]||(this._records[e]={}),this._records[e][t]||(this._records[e][t]=[]),this._records[e][t].push(A)},e.prototype.removeEventHandler=function(e,t,A){var r;this._records[e]&&(A?(r=this._records[e][t])&&-1<(A=r.indexOf(A))&&r.splice(A,1):this._records[e][t]=[])},e.prototype.dispatchEvent=function(e,t,A){this._records[e]&&(e=this._records[e][t])&&e.forEach(function(e){e(A)})},e}(),globalObject$3=getGlobal(),MixRenderLogger=function(){function e(e){this.prefix=e,this.isEnabled=!1,this.isEnabled=this.checkLoggerEnabled()}return e.prototype.log=function(e,t){this.isEnabled&&console.log(this.prefix,e,t)},e.prototype.warn=function(e){this.isEnabled&&console.warn(this.prefix,e)},e.prototype.error=function(e){this.isEnabled&&console.error(this.prefix,e)},e.prototype.checkLoggerEnabled=function(){var e=null==(e=globalObject$3.location)?void 0:e.href.split("?")[1];if(e)for(var t=0,A=e.split("&");t<A.length;t++)if(A[t]==="".concat("__pia_mixrender_logger__","=1"))return!0;return globalObject$3.__pia_mixrender_logger__},e}(),MixRenderCore=function(){function e(){this._id=0,this.CallbackRegistryImpl=MixRenderCallbackRegistry,this.EventDelegateImpl=MixRenderEventDelegate,this.LoggerImpl=MixRenderLogger}return e.prototype.registerImpl=function(e,t){switch(e){case"callbackRegistry":this.CallbackRegistryImpl=t;break;case"eventDelegate":this.EventDelegateImpl=t;break;case"logger":this.LoggerImpl=t}},e.prototype.init=function(){this._callback_registry_=new this.CallbackRegistryImpl,this._event_delegate_=new this.EventDelegateImpl,this._logger_=new this.LoggerImpl("[PIA MixRender]")},e.prototype.getCallbackRegistry=function(){return this._callback_registry_},e.prototype.getEventDelegate=function(){return this._event_delegate_},e.prototype.getLogger=function(){return this._logger_},e.prototype.getConfig=function(){return this._config_},e.prototype.setConfig=function(e){this._config_=e},e.prototype.allocateId=function(){return this._id++},e}();function getMixRenderInstance(){var e,t=getGlobal();return t._mix_render_core_||((e=new MixRenderCore).init(),t._mix_render_core_=e),t._mix_render_core_}function addMixRenderEventHandler(e,t,A){getMixRenderInstance().getEventDelegate().addEventHandler(e,t,A)}function removeMixRenderEventHandler(e,t,A){getMixRenderInstance().getEventDelegate().removeEventHandler(e,t,A)}var _a,globalObject$2=getGlobal();function call(e,t,A,r){var n,i=globalObject$2.byted_mixrender_native;i&&(n=getMixRenderInstance(),r=r?n.getCallbackRegistry().register(r):-1,i.invoke(e,t,JSON.stringify(A),r),n.getLogger().log("invoke, native component id ".concat(e,", command: ").concat(t,", callbackId: ").concat(r,", params: "),A))}function callSync(e,t){var A=globalObject$2.byted_mixrender_native;return null==A||!A.invokeSync||0!==(null==(A=JSON.parse(A.invokeSync(e,JSON.stringify(t))||""))?void 0:A.status)||null==A?void 0:A.data}function allocateId(){return getMixRenderInstance().allocateId()}var globalObject$1=getGlobal();function getMixRenderConfig(){var e,t=getMixRenderInstance();return t.getConfig()||(e=globalObject$1.byted_mixrender_config,t.getLogger().log("nativeConfig",e),e?t.setConfig(e):isAndroid()&&(e=callSync("getFeatures",null),t.setConfig(e),t.getLogger().log("GetFeatures",e))),t.getConfig()}function canIUse(e,t){void 0===t&&(t=!1);var A,r=getMixRenderConfig();return!(!(r&&r.mixrender_component_support_list&&r.mixrender_component_support_list[e])||(A="".concat(r.mixrender_component_support_list[e]),!t&&inBlockList(e,A))||isAndroid()&&1!==(null==(t=null==r?void 0:r.mixrender_runtime_support_list)?void 0:t.embed))}function isRuntimeModeSupport(e){var t;return!isAndroid()||(t=getMixRenderConfig())&&t.mixrender_runtime_support_list&&1===(null==(t=t.mixrender_runtime_support_list)?void 0:t[e])}var BLOCK_LIST={Android:{MixRender:{},PiaMixRender:((_a={})[exports.EMixRenderComponents.LivePlayer]=["1"],_a)},iOS:{MixRender:{}}};function inBlockList(e,t){var A,r=!1,n=[];if(n=(isAndroid()?(A=getMixRenderConfig(),isAndroid()&&A.mixrender_runtime_support_list?BLOCK_LIST.Android.PiaMixRender:BLOCK_LIST.Android.MixRender):BLOCK_LIST.iOS.MixRender)[e])for(var i=0,o=n;i<o.length;i++)if(o[i]===t){r=!0;break}return r}function translateMixRenderCallbackResponse(e){switch(e){case 0:return[!0];case-1:return[!1,"unknown function error"];case-2:return[!1,"error occurs when initializing"];case-3:return[!1,"call method with wrong params"];default:return[!1,"unknown error occurs"]}}var LegacyAdapter=function(){function e(e,t,A){this.id=e,this.type=t,this.mode=A}return e.prototype.init=function(e){var A=this;return new Promise(function(t){call(A.id,"initialize",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},e.prototype.update=function(e){var A=this;return new Promise(function(t){call(A.id,"update",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.destroy=function(e){var A=this;return void 0===e&&(e={}),new Promise(function(t){call(A.id,"destroy",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.log=function(e){var A=this;return new Promise(function(t){call(A.id,"debugLog",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.invoke=function(e){e.method,e.params;e=__rest(e,["method","params"]);return this.update(e)},e.prototype.addEventListener=function(e,t){addMixRenderEventHandler(this.id,e,t)},e.prototype.removeEventListener=function(e,t){removeMixRenderEventHandler(this.id,e,t)},e}(),SSRLegacyAdapter=function(){function e(e,t,A){this.id=e,this.type=t,this.mode=A}return e.prototype.init=function(e){return new Promise(function(e){e([!0])})},e.prototype.update=function(e){var A=this;return new Promise(function(t){call(A.id,"update",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.destroy=function(e){var A=this;return void 0===e&&(e={}),new Promise(function(t){call(A.id,"destroy",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.log=function(e){var A=this;return new Promise(function(t){call(A.id,"debugLog",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.invoke=function(e){e.method,e.params;e=__rest(e,["method","params"]);return this.update(e)},e.prototype.addEventListener=function(e,t){addMixRenderEventHandler(this.id,e,t)},e.prototype.removeEventListener=function(e,t){removeMixRenderEventHandler(this.id,e,t)},e}(),PiaMixRenderAdapter=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.init=function(A){var r=this;return new Promise(function(t){var e={type:r.type,properties:A};"embed"===r.mode&&(e.mode="embed"),call(r.id,"initialize",e,function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},t.prototype.invoke=function(r){var n=this;return new Promise(function(t){var e=r.method,A=r.params;call(n.id,"invokeMethod",{type:n.type,method:e,params:A},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},t}(LegacyAdapter),SSRPiaMixRenderAdapter=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.invoke=function(r){var n=this;return new Promise(function(t){var e=r.method,A=r.params;call(n.id,"invokeMethod",{type:n.type,method:e,params:A},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},t}(SSRLegacyAdapter);function getAdapterImpl(e,t){var A=getMixRenderConfig();return null!=t&&t.hybridRender?"Android"===(null==t?void 0:t.platform)?SSRPiaMixRenderAdapter:SSRLegacyAdapter:isAndroid()&&A&&A.mixrender_runtime_support_list?PiaMixRenderAdapter:LegacyAdapter}function setupAdapter(e,t,A,r){return new(getAdapterImpl(A=void 0===A?"embed":A,r))(e,t,A)}var TRANSFORM_BASE_BETWEEN_ID_AND_RGBA=255;function createPlaceholder4Android(e,t,A){var r;return"dig"===A?(e.setAttribute("tt-render-in-browser",String(t)),{destroy:function(){e.removeAttribute("tt-render-in-browser")}}):((r=document.createElement("embed")).setAttribute("tt-embed-id",String(t)),r.setAttribute("type","ttplugin/hybrid_component"),r.style.width="100%",r.style.height="100%",e.appendChild(r),{destroy:function(){e.removeChild(r)}})}function createPlaceholder4IOS(e,t){var A={overflow:e.style.overflow,"-webkit-overflow-scrolling":e.style["-webkit-overflow-scrolling"],backgroundColor:e.style.backgroundColor},r=Math.floor(t/TRANSFORM_BASE_BETWEEN_ID_AND_RGBA),t=Math.floor(t%TRANSFORM_BASE_BETWEEN_ID_AND_RGBA),n=(e.style.overflow="scroll",e.style["-webkit-overflow-scrolling"]="touch",e.style.backgroundColor="rgba(13, ".concat(r,", ").concat(t,", 0.13)"),document.createElement("div")),i=(n.style.width="100%",n.style.height="100%",e.appendChild(n),document.createElement("div"));return i.style.height="1px",e.appendChild(i),{destroy:function(){e.removeChild(n),e.removeChild(i),Object.assign(e.style,A)}}}function createPlaceholder(e,t,A){return isAndroid()?createPlaceholder4Android(e,t,A):createPlaceholder4IOS(e,t)}function callback(e,t){var A=getMixRenderInstance();A.getLogger().log("invoke native method callback, with: callbackId: ".concat(e,", res:"),t),A.getCallbackRegistry().dispatch(e,JSON.parse(t))}function invoke(e,t,A){var r=getMixRenderInstance();r.getLogger().log("trigger native event, with: id: ".concat(e,", command: ").concat(t,", params: "),A),r.getEventDelegate().dispatchEvent(e,t,JSON.parse(A))}var globalObject=getGlobal();function setupMixRenderWebHandle(){globalObject.byted_mixrender_web||(globalObject.byted_mixrender_web={invoke:invoke,callback:callback})}function getUsableRuntimeMode(e){return e||(isRuntimeModeSupport("embed")?"embed":"dig")}setupMixRenderWebHandle();var RegExp4Percentage=/(\d+)%/,RegExp4Pixel=/(\d+)px/,CSRImageWidget4Native=function(){function e(e){this.config=e,this.id=allocateId(),this.mode=getUsableRuntimeMode(this.config.mode),this.adapter=setupAdapter(this.id,exports.EMixRenderComponents.Image,this.mode),this.cornerRadiusMatchRes4Percent=null==(e=this.config.cornerRadius)?void 0:e.match(RegExp4Percentage),this.cornerRadiusMatchRes4Pixel=null==(e=this.config.cornerRadius)?void 0:e.match(RegExp4Pixel),this.updateCornerRadiusWhenResize=this.updateCornerRadiusWhenResize.bind(this)}return e.prototype.init=function(){return __awaiter(this,void 0,void 0,function(){var t,A,r;return __generator(this,function(e){switch(e.label){case 0:return t=this.config.container,A=t.style.opacity||"1",t.style.opacity="0.1",this.placeholder=createPlaceholder(t,this.id,this.mode),(r=this.config).container,r.renderer,r.mode,r.cornerRadius,r=__rest(r,["container","renderer","mode","cornerRadius"]),this.log("widget init"),[4,this.adapter.init(__assign(__assign({},r),{cornerRadius:this.getCornerRadius()}))];case 1:return r=e.sent(),t.style.opacity=A,r[0]&&(this.cornerRadiusMatchRes4Percent&&window.addEventListener("resize",this.updateCornerRadiusWhenResize),t.style.background="rgba(0,0,0,0)"),[2,r]}})})},e.prototype.setSrc=function(e){return this.adapter.update({src:e})},e.prototype.setObjectFit=function(e){return this.adapter.update({objectFit:e})},e.prototype.setCornerRadius=function(e){return this.cornerRadiusMatchRes4Percent=(e=void 0===e?"":e).match(RegExp4Percentage),this.cornerRadiusMatchRes4Pixel=e.match(RegExp4Pixel),this.adapter.update({cornerRadius:this.getCornerRadius()})},e.prototype.log=function(e){return this.adapter.log({webLog:e})},e.prototype.destroy=function(){var A;return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return[4,null==(A=this.adapter)?void 0:A.destroy()];case 1:return(t=e.sent())[0]&&(null!=(A=this.placeholder)&&A.destroy(),this.cornerRadiusMatchRes4Percent)&&window.removeEventListener("resize",this.updateCornerRadiusWhenResize),[2,t]}})})},e.prototype.updateCornerRadiusWhenResize=function(){var e=this.getCornerRadius();this.adapter.update({cornerRadius:e})},e.prototype.getCornerRadius=function(){var e=this.config.container;return this.cornerRadiusMatchRes4Percent?e.getBoundingClientRect().width*+this.cornerRadiusMatchRes4Percent[1]/100:this.cornerRadiusMatchRes4Pixel?+this.cornerRadiusMatchRes4Pixel[1]:void 0},e}(),SSRImageWidget4Native=function(){function e(e){this.config=e,this.id=allocateId(),this.mode="embed"}return e.prototype.init=function(){return this.adapter=setupAdapter(this.id,exports.EMixRenderComponents.Image,this.mode,this.config.ssrConfig),this.id},e.prototype.setSrc=function(e){return this.adapter.update({src:e})},e.prototype.setObjectFit=function(e){return this.adapter.update({objectFit:e})},e.prototype.setCornerRadius=function(e){return void 0===e&&(e=""),this.adapter.update({cornerRadius:Number(e)})},e.prototype.log=function(e){return this.adapter.log({webLog:e})},e.prototype.destroy=function(){var A;return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return[4,null==(A=this.adapter)?void 0:A.destroy()];case 1:return(t=e.sent())[0]&&null!=(A=this.placeholder)&&A.destroy(),[2,t]}})})},e}(),ImageWidget4Web=function(){function e(e){this.config=e}return e.prototype.init=function(){var e=this.config,t=e.container,A=e.src,r=e.objectFit,e=e.cornerRadius;return this.image=new Image,this.image.style.width="100%",this.image.style.height="100%",this.image.src=A,this.image.style.objectFit=r,this.image.style.borderRadius="".concat(e,"px"),t.appendChild(this.image),Promise.resolve([!0])},e.prototype.setSrc=function(e){return this.image.src=e,Promise.resolve([!0])},e.prototype.setObjectFit=function(e){return this.image.style.objectFit=e,Promise.resolve([!0])},e.prototype.setCornerRadius=function(e){return this.image.style.borderRadius=e=void 0===e?"":e,Promise.resolve([!0])},e.prototype.log=function(e){return Promise.resolve([!0])},e.prototype.destroy=function(){return this.config.container.removeChild(this.image),Promise.resolve([!0])},e}(),ValidFormat=["webp","avif","heic","jpeg","png"],FormatsMap={webp:"awebp",heic:"heif",avif:"avis",jpeg:"jpeg",png:"png"},ErrorImageXUrl={protocol:"http://",domain:"",src:"",search:"",template:"",suffix:""},ErrorUrl={protocol:"http://",domain:"",src:"",search:""},imagexUrlPattern=/^(.+)~(tplv-[a-zA-Z0-9]{2,10}-.+)\.([a-zA-Z]+)\??(.*)$/,FORMAT_BASE64_MAP={webp:{base64:"data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvn8AnAAdQiUpUov+BiOh/AAA=",height:160},heic:{base64:"data:image/heic;base64,AAAAHGZ0eXBtaWYxAAAAAG1pZjFoZWljaGV2YwAAASVtZXRhAAAAAAAAACFoZGxyAAAAAAAAAABwaWN0AAAAAAAAAAAAAAAAAAAAAA5waXRtAAAAAAABAAAAI2lpbmYAAAAAAAEAAAAVaW5mZQIAAAAAAQAAaHZjMQAAAACjaXBycAAAAIZpcGNvAAAAamh2Y0MBAWAAAAAAAAAAAAAe8AD8/fj4AAAPAyAAAQAYQAEMAf//AWAAAAMAAAMAAAMAAAMAHvAkIQABAB1CAQEBYAAAAwAAAwAAAwAAAwAeoDSBp3eX5JMrICIAAQAHRAHBLGDEgAAAABRpc3BlAAAAAAAAAGQAAABkAAAAFWlwbWEAAAAAAAAAAQABAoECAAAAJGlsb2MBAAAAREAAAQABAAAAAAAAAUkAAQAAAAAAAAAgAAAAKG1kYXQAAAAcJgGvJRNg+cJYeUBAgVGpfj2xh5SigAAENABAQA==",height:100},avif:{base64:"data:image/avif;base64,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",height:1}},check=function(r){return 0<=ValidFormat.indexOf(r)&&("jpeg"===r||"png"===r||!!FORMAT_BASE64_MAP[r]&&new Promise(function(t){if("undefined"==typeof window&&t(!1),void 0!==window["__support_".concat(r,"__")])t(!!window["__support_".concat(r,"__")]);else{if(FORMAT_BASE64_MAP[r].prerequisite)if(!FORMAT_BASE64_MAP[r].prerequisite())return window["__support_".concat(r,"__")]=!1,void t(!1);var A=new Image;A.onload=function(){var e=(null==A?void 0:A.height)===FORMAT_BASE64_MAP[r].height;window["__support_".concat(r,"__")]=e,t(e)},A.onerror=function(){window["__support_".concat(r,"__")]=!1,t(!1)},A.src=FORMAT_BASE64_MAP[r].base64}}))},getFormat=function(o){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,new Promise(function(i){__awaiter(void 0,void 0,void 0,function(){var t,A,r,n;return __generator(this,function(e){switch(e.label){case 0:"undefined"==typeof window&&i("image"),t=0,A=o,e.label=1;case 1:if(!(t<A.length))return[3,7];r=A[t],n=!1,e.label=2;case 2:return e.trys.push([2,4,,5]),[4,check(r)];case 3:return n=e.sent(),[3,5];case 4:return e.sent(),console.error("格式探测失败"),[3,5];case 5:if(n)return i(r),[3,7];e.label=6;case 6:return t++,[3,1];case 7:return i("image"),[2]}})})})];case 1:return[2,e.sent()]}})})},parseImagexUrl=function(e){try{var t=e.startsWith("http")?e:(e.startsWith("//")?"https:":"http://").concat(e),A=new URL(t),r=imagexUrlPattern.exec(A.pathname.slice(1));return{protocol:A.protocol,domain:A.hostname,src:r[1],template:r[2],suffix:r[3],search:A.search}}catch(e){return console.error(e),ErrorImageXUrl}},parseOtherUrl=function(e){try{var t=e.startsWith("http")?e:(e.startsWith("//")?"https:":"http://").concat(e),A=new URL(t);return{protocol:A.protocol,domain:A.hostname,src:A.pathname.slice(1),search:A.search}}catch(e){return ErrorUrl}},isImagexUrl=function(e){return imagexUrlPattern.test(e)},getSrc=function(e,t,A){var r,n,i,o,a,s;return t(isImagexUrl(e)?(i=(t=parseImagexUrl(e)).src,o=t.protocol,a=t.domain,r=t.suffix,n=t.template,s=t.search,{src:i,format:FormatsMap[A]||"image",extra:{suffix:r,template:n,search:s,protocol:o,domain:a,origin:e}}):(i=(t=parseOtherUrl(e)).src,o=t.protocol,a=t.domain,s=t.search,{src:i,format:FormatsMap[A]||"image",extra:{protocol:o,domain:a,search:s,origin:e}}))},isSupportNativeImage=canIUse(exports.EMixRenderComponents.Image),CSRImageProxy=function(){function e(e){this.config=e,this.isInitialized=!1,this.renderFormat="image"}return e.prototype.init=function(){var i;return __awaiter(this,void 0,void 0,function(){var t,A,r,n;return __generator(this,function(e){switch(e.label){case 0:return t=this.config.renderer,A=this,"web"!==(t=t&&"auto"!==t?t:isSupportNativeImage?"native":"web")?[3,2]:[4,getFormat((this.config.formats||["avif","webp"]).filter(function(e){return"heic"!==e}))];case 1:return r=e.sent()||"image",[3,3];case 2:r=(null==(i=this.config.formats)?void 0:i[0])||"heic",e.label=3;case 3:return A.renderFormat=r,n=__assign(__assign({},this.config),{src:getSrc(this.config.src,this.config.loader,this.renderFormat||"image")}),this.widget=new("native"===t?CSRImageWidget4Native:ImageWidget4Web)(n),[4,this.widget.init()];case 4:return(n=e.sent())[0]&&(this.isInitialized=!0),[2,n]}})})},e.prototype.setSrc=function(e){return this.widget.setSrc(getSrc(e,this.config.loader,this.renderFormat||"image"))},e.prototype.setObjectFit=function(e){return this.widget.setObjectFit(e)},e.prototype.setCornerRadius=function(e){return this.widget.setCornerRadius(e)},e.prototype.destroy=function(){var e;return null==(e=this.widget)?void 0:e.destroy()},e}(),SSRImageProxy=function(){function e(e){this.config=e,this.isInitialized=!1,this.renderFormat="heic"}return e.prototype.init=function(){this.renderFormat="heic";var e=__assign(__assign({},this.config),{src:getSrc(this.config.src,this.config.loader,this.renderFormat)}),t=(this.widget=new SSRImageWidget4Native(e),this.widget.init());return this.isInitialized=!0,{id:t,src:e.src}},e.prototype.setSrc=function(e){var t;return null==(t=this.widget)?void 0:t.setSrc(getSrc(e,this.config.loader,this.renderFormat||"image"))},e.prototype.setObjectFit=function(e){var t;return null==(t=this.widget)?void 0:t.setObjectFit(e)},e.prototype.setCornerRadius=function(e){var t;return null==(t=this.widget)?void 0:t.setCornerRadius(e)},e.prototype.destroy=function(){var e;return null==(e=this.widget)?void 0:e.destroy()},e}();function createImageProxy(e){return new(void 0!==e.ssrConfig?SSRImageProxy:CSRImageProxy)(e)}var Viewer=function(t){var e,A,r=React.useRef(null),n=React.useRef(null),i=React.useRef(n.current&&n.current.isInitialized),o=React.useRef(-1);return React.useEffect(function(){var e;i.current=null==(e=n.current)?void 0:e.isInitialized},[null==(e=n.current)?void 0:e.isInitialized]),React.useEffect(function(){if(r.current)return i.current||(n.current=createImageProxy({container:r.current,renderer:t.renderer||"auto",src:t.src,loader:t.loader,objectFit:t.objectFit,cornerRadius:t.cornerRadius||"",formats:t.formats||["heic","avif","webp"]}),n.current.init().then(function(e){e[0]&&(i.current=!0)})),function(){var e;n.current&&n.current.destroy&&null!=(e=n.current)&&e.destroy()}},[]),React.useEffect(function(){var e;i.current&&null!=(e=n.current)&&e.setSrc(t.src)},[t.src]),React.useEffect(function(){var e;i.current&&null!=(e=n.current)&&e.setObjectFit(t.objectFit)},[t.objectFit]),React.useEffect(function(){var e;i.current&&null!=(e=n.current)&&e.setCornerRadius(t.cornerRadius)},[t.cornerRadius]),null!=(e=t.ssrConfig)&&e.isSSR&&null!=(e=t.ssrConfig)&&e.hybridRender&&-1===o.current&&(n.current=createImageProxy({renderer:"native",src:t.src,loader:t.loader,objectFit:t.objectFit,cornerRadius:t.cornerRadius||"",ssrConfig:t.ssrConfig}),e=n.current.init(),o.current=e.id,"undefined"==typeof window&&((A=new Function("return this")()).imagexSsrData||(A.imagexSsrData=[]),A.imagexSsrData.push(__assign(__assign({},e||{}),{width:t.width,height:t.height,objectFit:t.objectFit,cornerRadius:t.cornerRadius||""}))),i.current=!0),React__default.default.createElement("div",{className:"pia-mixrender-image",style:{width:t.width,height:t.height}},null!=(A=t.ssrConfig)&&A.isSSR?null!=(e=t.ssrConfig)&&e.hybridRender?"iOS"===(null==(A=t.ssrConfig)?void 0:A.platform)?React__default.default.createElement("div",{ref:r,style:{opacity:1,width:t.width,height:t.height,fontSize:0,lineHeight:0,overflow:"scroll",WebkitOverflowScrolling:"touch",backgroundColor:"rgba(13, ".concat(Math.floor(o.current/255),", ").concat(Math.floor(o.current%255),", 0.13)")}},React__default.default.createElement("div",{style:{width:"100%",height:"100%"}}),React__default.default.createElement("div",{style:{height:1}})):React__default.default.createElement("div",{ref:r,style:{opacity:1,width:t.width,height:t.height,fontSize:0,lineHeight:0}},React__default.default.createElement("embed",{"tt-embed-id":o.current,type:"ttplugin/hybrid_component",style:{width:"100%",height:"100%"}})):React__default.default.createElement("img",{src:getSrc(t.src,t.loader,"image"),style:{width:"100%",height:"100%",objectFit:t.objectFit,borderRadius:"".concat(Number(t.cornerRadius||0),"px")}}):React__default.default.createElement("div",{ref:r,style:{width:t.width,height:t.height,fontSize:0,lineHeight:0}}))},exportInitScript=function(){var e,t=new Function("return this")();return t.imagexSsrData?(e=';(function(e){document.addEventListener("DOMContentLoaded",function(){console.log("ImageX SSR Init");var i=window.byted_mixrender_native;console.log("byted_mixrender_native:",i);if(i)for(var t=0;t<(e||[]).length;t++){i.invoke(e[t].id,"initialize",JSON.stringify({type:"web_image",properties:{src:e[t].src,width:e[t].width,height:e[t].height,objectFit:e[t].objectFit,cornerRadius:e[t].cornerRadius}}),e[t].id);console.log("initialize:",e[t])}})})('.concat(JSON.stringify(t.imagexSsrData||[]),")"),t._mix_render_core_=void 0,t.imagexSsrData=void 0,e):""};exports.CSRImageProxy=CSRImageProxy,exports.SSRImageProxy=SSRImageProxy,exports.ValidFormat=ValidFormat$1,exports.ValidPlatform=ValidPlatform,exports.Viewer=Viewer,exports.createImageProxy=createImageProxy,exports.exportInitScript=exportInitScript;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,t){e.__proto__=t}:function(e,t){for(var A in t)Object.prototype.hasOwnProperty.call(t,A)&&(e[A]=t[A])}))(e,t)};function __extends(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function A(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(A.prototype=t.prototype,new A)}var __assign=function(){return(__assign=Object.assign||function(e){for(var t,A=1,r=arguments.length;A<r;A++)for(var n in t=arguments[A])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function __rest(e,t){var A={};for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(A[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(A[n[r]]=e[n[r]]);return A}function __awaiter(e,o,a,s){return new(a=a||Promise)(function(A,t){function r(e){try{i(s.next(e))}catch(e){t(e)}}function n(e){try{i(s.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?A(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(r,n)}i((s=s.apply(e,o||[])).next())})}function __generator(r,n){var i,o,a,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},c={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function e(A){return function(e){var t=[A,e];if(i)throw new TypeError("Generator is already executing.");for(;s=c&&t[c=0]?0:s;)try{if(i=1,o&&(a=2&t[0]?o.return:t[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,t[1])).done)return a;switch(o=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return s.label++,{value:t[1],done:!1};case 5:s.label++,o=t[1],t=[0];continue;case 7:t=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){s=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3]))s.label=t[1];else if(6===t[0]&&s.label<a[1])s.label=a[1],a=t;else{if(!(a&&s.label<a[2])){a[2]&&s.ops.pop(),s.trys.pop();continue}s.label=a[2],s.ops.push(t)}}t=n.call(r,s)}catch(e){t=[6,e],o=0}finally{i=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}}var EPlatform,ValidFormat$1=["webp","avif","heic","jpeg","png"],ValidPlatform=["Android","iOS"];function getGlobal(){return new Function("return this")()}exports.EMixRenderComponents=void 0,function(e){e.LivePlayer="live_player",e.Lottie="lottie_view",e.Image="web_image"}(exports.EMixRenderComponents||(exports.EMixRenderComponents={})),exports.EMixRenderRuntime=void 0,function(e){e.DIG="dig",e.EMBED="embed"}(exports.EMixRenderRuntime||(exports.EMixRenderRuntime={})),function(e){e.ANDROID="Android",e.IOS="iOS",e.UNKNOWN="unknown"}(EPlatform=EPlatform||{});var _systemInfo_,_useragent_,REGEXP_DETECT_PLATFORM=/(Android|iPhone)/;function getUserAgent(){var e;return _useragent_=_useragent_||(null==(e=getGlobal().navigator)?void 0:e.userAgent)||""}function getSystemInfo(){var e,t;return _systemInfo_||(e=getUserAgent().match(REGEXP_DETECT_PLATFORM),t=EPlatform.UNKNOWN,e&&(t="Android"===e[1]?EPlatform.ANDROID:EPlatform.IOS),_systemInfo_={platform:t}),_systemInfo_}function isAndroid(){return getSystemInfo().platform===EPlatform.ANDROID}var MixRenderCallbackRegistry=function(){function e(){this._records={},this.id=0}return e.prototype.register=function(e){return this.id++,this._records[this.id]=e,this.id},e.prototype.unregister=function(e){this._records[e]=null},e.prototype.dispatch=function(e,t){var A=this._records[e],r=getMixRenderInstance();A&&(null!=(r=null==r?void 0:r.getLogger())&&r.log("callback, callbackId: ".concat(e,"; res: "),t),A(t))},e}(),MixRenderEventDelegate=function(){function e(){this._records={}}return e.prototype.addEventHandler=function(e,t,A){this._records[e]||(this._records[e]={}),this._records[e][t]||(this._records[e][t]=[]),this._records[e][t].push(A)},e.prototype.removeEventHandler=function(e,t,A){var r;this._records[e]&&(A?(r=this._records[e][t])&&-1<(A=r.indexOf(A))&&r.splice(A,1):this._records[e][t]=[])},e.prototype.dispatchEvent=function(e,t,A){this._records[e]&&(e=this._records[e][t])&&e.forEach(function(e){e(A)})},e}(),globalObject$3=getGlobal(),MixRenderLogger=function(){function e(e){this.prefix=e,this.isEnabled=!1,this.isEnabled=this.checkLoggerEnabled()}return e.prototype.log=function(e,t){this.isEnabled&&console.log(this.prefix,e,t)},e.prototype.warn=function(e){this.isEnabled&&console.warn(this.prefix,e)},e.prototype.error=function(e){this.isEnabled&&console.error(this.prefix,e)},e.prototype.checkLoggerEnabled=function(){var e=null==(e=globalObject$3.location)?void 0:e.href.split("?")[1];if(e)for(var t=0,A=e.split("&");t<A.length;t++)if(A[t]==="".concat("__pia_mixrender_logger__","=1"))return!0;return globalObject$3.__pia_mixrender_logger__},e}(),MixRenderCore=function(){function e(){this._id=0,this.CallbackRegistryImpl=MixRenderCallbackRegistry,this.EventDelegateImpl=MixRenderEventDelegate,this.LoggerImpl=MixRenderLogger}return e.prototype.registerImpl=function(e,t){switch(e){case"callbackRegistry":this.CallbackRegistryImpl=t;break;case"eventDelegate":this.EventDelegateImpl=t;break;case"logger":this.LoggerImpl=t}},e.prototype.init=function(){this._callback_registry_=new this.CallbackRegistryImpl,this._event_delegate_=new this.EventDelegateImpl,this._logger_=new this.LoggerImpl("[PIA MixRender]")},e.prototype.getCallbackRegistry=function(){return this._callback_registry_},e.prototype.getEventDelegate=function(){return this._event_delegate_},e.prototype.getLogger=function(){return this._logger_},e.prototype.getConfig=function(){return this._config_},e.prototype.setConfig=function(e){this._config_=e},e.prototype.allocateId=function(){return this._id++},e}();function getMixRenderInstance(){var e,t=getGlobal();return t._mix_render_core_||((e=new MixRenderCore).init(),t._mix_render_core_=e),t._mix_render_core_}function addMixRenderEventHandler(e,t,A){getMixRenderInstance().getEventDelegate().addEventHandler(e,t,A)}function removeMixRenderEventHandler(e,t,A){getMixRenderInstance().getEventDelegate().removeEventHandler(e,t,A)}var _a,globalObject$2=getGlobal();function call(e,t,A,r){var n,i=globalObject$2.byted_mixrender_native;i&&(n=getMixRenderInstance(),r=r?n.getCallbackRegistry().register(r):-1,i.invoke(e,t,JSON.stringify(A),r),n.getLogger().log("invoke, native component id ".concat(e,", command: ").concat(t,", callbackId: ").concat(r,", params: "),A))}function callSync(e,t){var A=globalObject$2.byted_mixrender_native;return null==A||!A.invokeSync||0!==(null==(A=JSON.parse(A.invokeSync(e,JSON.stringify(t))||""))?void 0:A.status)||null==A?void 0:A.data}function allocateId(){return getMixRenderInstance().allocateId()}var globalObject$1=getGlobal();function getMixRenderConfig(){var e,t=getMixRenderInstance();return t.getConfig()||(e=globalObject$1.byted_mixrender_config,t.getLogger().log("nativeConfig",e),e?t.setConfig(e):isAndroid()&&(e=callSync("getFeatures",null),t.setConfig(e),t.getLogger().log("GetFeatures",e))),t.getConfig()}function canIUse(e,t){void 0===t&&(t=!1);var A,r=getMixRenderConfig();return!(!(r&&r.mixrender_component_support_list&&r.mixrender_component_support_list[e])||(A="".concat(r.mixrender_component_support_list[e]),!t&&inBlockList(e,A))||isAndroid()&&1!==(null==(t=null==r?void 0:r.mixrender_runtime_support_list)?void 0:t.embed))}function isRuntimeModeSupport(e){var t;return!isAndroid()||(t=getMixRenderConfig())&&t.mixrender_runtime_support_list&&1===(null==(t=t.mixrender_runtime_support_list)?void 0:t[e])}var BLOCK_LIST={Android:{MixRender:{},PiaMixRender:((_a={})[exports.EMixRenderComponents.LivePlayer]=["1"],_a)},iOS:{MixRender:{}}};function inBlockList(e,t){var A,r=!1,n=[];if(n=(isAndroid()?(A=getMixRenderConfig(),isAndroid()&&A.mixrender_runtime_support_list?BLOCK_LIST.Android.PiaMixRender:BLOCK_LIST.Android.MixRender):BLOCK_LIST.iOS.MixRender)[e])for(var i=0,o=n;i<o.length;i++)if(o[i]===t){r=!0;break}return r}function translateMixRenderCallbackResponse(e){switch(e){case 0:return[!0];case-1:return[!1,"unknown function error"];case-2:return[!1,"error occurs when initializing"];case-3:return[!1,"call method with wrong params"];default:return[!1,"unknown error occurs"]}}var LegacyAdapter=function(){function e(e,t,A){this.id=e,this.type=t,this.mode=A}return e.prototype.init=function(e){var A=this;return new Promise(function(t){call(A.id,"initialize",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},e.prototype.update=function(e){var A=this;return new Promise(function(t){call(A.id,"update",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.destroy=function(e){var A=this;return void 0===e&&(e={}),new Promise(function(t){call(A.id,"destroy",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.log=function(e){var A=this;return new Promise(function(t){call(A.id,"debugLog",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.invoke=function(e){e.method,e.params;e=__rest(e,["method","params"]);return this.update(e)},e.prototype.addEventListener=function(e,t){addMixRenderEventHandler(this.id,e,t)},e.prototype.removeEventListener=function(e,t){removeMixRenderEventHandler(this.id,e,t)},e}(),SSRLegacyAdapter=function(){function e(e,t,A){this.id=e,this.type=t,this.mode=A}return e.prototype.init=function(e){return new Promise(function(e){e([!0])})},e.prototype.update=function(e){var A=this;return new Promise(function(t){call(A.id,"update",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.destroy=function(e){var A=this;return void 0===e&&(e={}),new Promise(function(t){call(A.id,"destroy",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.log=function(e){var A=this;return new Promise(function(t){call(A.id,"debugLog",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.invoke=function(e){e.method,e.params;e=__rest(e,["method","params"]);return this.update(e)},e.prototype.addEventListener=function(e,t){addMixRenderEventHandler(this.id,e,t)},e.prototype.removeEventListener=function(e,t){removeMixRenderEventHandler(this.id,e,t)},e}(),PiaMixRenderAdapter=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.init=function(A){var r=this;return new Promise(function(t){var e={type:r.type,properties:A};"embed"===r.mode&&(e.mode="embed"),call(r.id,"initialize",e,function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},t.prototype.invoke=function(r){var n=this;return new Promise(function(t){var e=r.method,A=r.params;call(n.id,"invokeMethod",{type:n.type,method:e,params:A},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},t}(LegacyAdapter),SSRPiaMixRenderAdapter=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.invoke=function(r){var n=this;return new Promise(function(t){var e=r.method,A=r.params;call(n.id,"invokeMethod",{type:n.type,method:e,params:A},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},t}(SSRLegacyAdapter);function getAdapterImpl(e,t){var A=getMixRenderConfig();return null!=t&&t.hybridRender?"Android"===(null==t?void 0:t.platform)?SSRPiaMixRenderAdapter:SSRLegacyAdapter:isAndroid()&&A&&A.mixrender_runtime_support_list?PiaMixRenderAdapter:LegacyAdapter}function setupAdapter(e,t,A,r){return new(getAdapterImpl(A=void 0===A?"embed":A,r))(e,t,A)}var TRANSFORM_BASE_BETWEEN_ID_AND_RGBA=255;function createPlaceholder4Android(e,t,A){var r;return"dig"===A?(e.setAttribute("tt-render-in-browser",String(t)),{destroy:function(){e.removeAttribute("tt-render-in-browser")}}):((r=document.createElement("embed")).setAttribute("tt-embed-id",String(t)),r.setAttribute("type","ttplugin/hybrid_component"),r.style.width="100%",r.style.height="100%",e.appendChild(r),{destroy:function(){e.removeChild(r)}})}function createPlaceholder4IOS(e,t){var A={overflow:e.style.overflow,"-webkit-overflow-scrolling":e.style["-webkit-overflow-scrolling"],backgroundColor:e.style.backgroundColor},r=Math.floor(t/TRANSFORM_BASE_BETWEEN_ID_AND_RGBA),t=Math.floor(t%TRANSFORM_BASE_BETWEEN_ID_AND_RGBA),n=(e.style.overflow="scroll",e.style["-webkit-overflow-scrolling"]="touch",e.style.backgroundColor="rgba(13, ".concat(r,", ").concat(t,", 0.13)"),document.createElement("div")),i=(n.style.width="100%",n.style.height="100%",e.appendChild(n),document.createElement("div"));return i.style.height="1px",e.appendChild(i),{destroy:function(){e.removeChild(n),e.removeChild(i),Object.assign(e.style,A)}}}function createPlaceholder(e,t,A){return isAndroid()?createPlaceholder4Android(e,t,A):createPlaceholder4IOS(e,t)}function callback(e,t){var A=getMixRenderInstance();A.getLogger().log("invoke native method callback, with: callbackId: ".concat(e,", res:"),t),A.getCallbackRegistry().dispatch(e,JSON.parse(t))}function invoke(e,t,A){var r=getMixRenderInstance();r.getLogger().log("trigger native event, with: id: ".concat(e,", command: ").concat(t,", params: "),A),r.getEventDelegate().dispatchEvent(e,t,JSON.parse(A))}var globalObject=getGlobal();function setupMixRenderWebHandle(){globalObject.byted_mixrender_web||(globalObject.byted_mixrender_web={invoke:invoke,callback:callback})}function getUsableRuntimeMode(e){return e||(isRuntimeModeSupport("embed")?"embed":"dig")}setupMixRenderWebHandle();var RegExp4Percentage=/(\d+)%/,RegExp4Pixel=/(\d+)px/,CSRImageWidget4Native=function(){function e(e){this.config=e,this.id=allocateId(),this.mode=getUsableRuntimeMode(this.config.mode),this.adapter=setupAdapter(this.id,exports.EMixRenderComponents.Image,this.mode),this.cornerRadiusMatchRes4Percent=null==(e=this.config.cornerRadius)?void 0:e.match(RegExp4Percentage),this.cornerRadiusMatchRes4Pixel=null==(e=this.config.cornerRadius)?void 0:e.match(RegExp4Pixel),this.updateCornerRadiusWhenResize=this.updateCornerRadiusWhenResize.bind(this)}return e.prototype.init=function(){return __awaiter(this,void 0,void 0,function(){var t,A,r;return __generator(this,function(e){switch(e.label){case 0:return t=this.config.container,A=t.style.opacity||"1",t.style.opacity="0.1",this.placeholder=createPlaceholder(t,this.id,this.mode),(r=this.config).container,r.renderer,r.mode,r.cornerRadius,r=__rest(r,["container","renderer","mode","cornerRadius"]),this.log("widget init"),[4,this.adapter.init(__assign(__assign({},r),{cornerRadius:this.getCornerRadius()}))];case 1:return r=e.sent(),t.style.opacity=A,r[0]&&(this.cornerRadiusMatchRes4Percent&&window.addEventListener("resize",this.updateCornerRadiusWhenResize),t.style.background="rgba(0,0,0,0)"),[2,r]}})})},e.prototype.setSrc=function(e){return this.adapter.update({src:e})},e.prototype.setObjectFit=function(e){return this.adapter.update({objectFit:e})},e.prototype.setCornerRadius=function(e){return this.cornerRadiusMatchRes4Percent=(e=void 0===e?"":e).match(RegExp4Percentage),this.cornerRadiusMatchRes4Pixel=e.match(RegExp4Pixel),this.adapter.update({cornerRadius:this.getCornerRadius()})},e.prototype.log=function(e){return this.adapter.log({webLog:e})},e.prototype.destroy=function(){var A;return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return[4,null==(A=this.adapter)?void 0:A.destroy()];case 1:return(t=e.sent())[0]&&(null!=(A=this.placeholder)&&A.destroy(),this.cornerRadiusMatchRes4Percent)&&window.removeEventListener("resize",this.updateCornerRadiusWhenResize),[2,t]}})})},e.prototype.updateCornerRadiusWhenResize=function(){var e=this.getCornerRadius();this.adapter.update({cornerRadius:e})},e.prototype.getCornerRadius=function(){var e=this.config.container;return this.cornerRadiusMatchRes4Percent?e.getBoundingClientRect().width*+this.cornerRadiusMatchRes4Percent[1]/100:this.cornerRadiusMatchRes4Pixel?+this.cornerRadiusMatchRes4Pixel[1]:void 0},e}(),SSRImageWidget4Native=function(){function e(e){this.config=e,this.id=allocateId(),this.mode="embed"}return e.prototype.init=function(){return this.adapter=setupAdapter(this.id,exports.EMixRenderComponents.Image,this.mode,this.config.ssrConfig),this.id},e.prototype.setSrc=function(e){return this.adapter.update({src:e})},e.prototype.setObjectFit=function(e){return this.adapter.update({objectFit:e})},e.prototype.setCornerRadius=function(e){e=(e=void 0===e?"":e).match(RegExp4Pixel);if(e)return this.adapter.update({cornerRadius:+e[1]})},e.prototype.log=function(e){return this.adapter.log({webLog:e})},e.prototype.destroy=function(){var A;return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return[4,null==(A=this.adapter)?void 0:A.destroy()];case 1:return(t=e.sent())[0]&&null!=(A=this.placeholder)&&A.destroy(),[2,t]}})})},e}(),ImageWidget4Web=function(){function e(e){this.config=e}return e.prototype.init=function(){var e=this.config,t=e.container,A=e.src,r=e.objectFit,e=e.cornerRadius;return this.image=new Image,this.image.style.width="100%",this.image.style.height="100%",this.image.src=A,this.image.style.objectFit=r,this.image.style.borderRadius=e,t.appendChild(this.image),Promise.resolve([!0])},e.prototype.setSrc=function(e){return this.image.src=e,Promise.resolve([!0])},e.prototype.setObjectFit=function(e){return this.image.style.objectFit=e,Promise.resolve([!0])},e.prototype.setCornerRadius=function(e){return this.image.style.borderRadius=e=void 0===e?"":e,Promise.resolve([!0])},e.prototype.log=function(e){return Promise.resolve([!0])},e.prototype.destroy=function(){return this.config.container.removeChild(this.image),Promise.resolve([!0])},e}(),ValidFormat=["webp","avif","heic","jpeg","png"],FormatsMap={webp:"awebp",heic:"heif",avif:"avis",jpeg:"jpeg",png:"png"},ErrorImageXUrl={protocol:"http://",domain:"",src:"",search:"",template:"",suffix:""},ErrorUrl={protocol:"http://",domain:"",src:"",search:""},imagexUrlPattern=/^(.+)~(tplv-[a-zA-Z0-9]{2,10}-.+)\.([a-zA-Z]+)\??(.*)$/,FORMAT_BASE64_MAP={webp:{base64:"data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvn8AnAAdQiUpUov+BiOh/AAA=",height:160},heic:{base64:"data:image/heic;base64,AAAAHGZ0eXBtaWYxAAAAAG1pZjFoZWljaGV2YwAAASVtZXRhAAAAAAAAACFoZGxyAAAAAAAAAABwaWN0AAAAAAAAAAAAAAAAAAAAAA5waXRtAAAAAAABAAAAI2lpbmYAAAAAAAEAAAAVaW5mZQIAAAAAAQAAaHZjMQAAAACjaXBycAAAAIZpcGNvAAAAamh2Y0MBAWAAAAAAAAAAAAAe8AD8/fj4AAAPAyAAAQAYQAEMAf//AWAAAAMAAAMAAAMAAAMAHvAkIQABAB1CAQEBYAAAAwAAAwAAAwAAAwAeoDSBp3eX5JMrICIAAQAHRAHBLGDEgAAAABRpc3BlAAAAAAAAAGQAAABkAAAAFWlwbWEAAAAAAAAAAQABAoECAAAAJGlsb2MBAAAAREAAAQABAAAAAAAAAUkAAQAAAAAAAAAgAAAAKG1kYXQAAAAcJgGvJRNg+cJYeUBAgVGpfj2xh5SigAAENABAQA==",height:100},avif:{base64:"data:image/avif;base64,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",height:1}},check=function(r){return 0<=ValidFormat.indexOf(r)&&("jpeg"===r||"png"===r||!!FORMAT_BASE64_MAP[r]&&new Promise(function(t){if("undefined"==typeof window&&t(!1),void 0!==window["__support_".concat(r,"__")])t(!!window["__support_".concat(r,"__")]);else{if(FORMAT_BASE64_MAP[r].prerequisite)if(!FORMAT_BASE64_MAP[r].prerequisite())return window["__support_".concat(r,"__")]=!1,void t(!1);var A=new Image;A.onload=function(){var e=(null==A?void 0:A.height)===FORMAT_BASE64_MAP[r].height;window["__support_".concat(r,"__")]=e,t(e)},A.onerror=function(){window["__support_".concat(r,"__")]=!1,t(!1)},A.src=FORMAT_BASE64_MAP[r].base64}}))},getFormat=function(o){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,new Promise(function(i){__awaiter(void 0,void 0,void 0,function(){var t,A,r,n;return __generator(this,function(e){switch(e.label){case 0:"undefined"==typeof window&&i("image"),t=0,A=o,e.label=1;case 1:if(!(t<A.length))return[3,7];r=A[t],n=!1,e.label=2;case 2:return e.trys.push([2,4,,5]),[4,check(r)];case 3:return n=e.sent(),[3,5];case 4:return e.sent(),console.error("格式探测失败"),[3,5];case 5:if(n)return i(r),[3,7];e.label=6;case 6:return t++,[3,1];case 7:return i("image"),[2]}})})})];case 1:return[2,e.sent()]}})})},parseImagexUrl=function(e){try{var t=e.startsWith("http")?e:(e.startsWith("//")?"https:":"http://").concat(e),A=new URL(t),r=imagexUrlPattern.exec(A.pathname.slice(1));return{protocol:A.protocol,domain:A.hostname,src:r[1],template:r[2],suffix:r[3],search:A.search}}catch(e){return console.error(e),ErrorImageXUrl}},parseOtherUrl=function(e){try{var t=e.startsWith("http")?e:(e.startsWith("//")?"https:":"http://").concat(e),A=new URL(t);return{protocol:A.protocol,domain:A.hostname,src:A.pathname.slice(1),search:A.search}}catch(e){return ErrorUrl}},isImagexUrl=function(e){return imagexUrlPattern.test(e)},getSrc=function(e,t,A){var r,n,i,o,a,s;return t(isImagexUrl(e)?(i=(t=parseImagexUrl(e)).src,o=t.protocol,a=t.domain,r=t.suffix,n=t.template,s=t.search,{src:i,format:FormatsMap[A]||"image",extra:{suffix:r,template:n,search:s,protocol:o,domain:a,origin:e}}):(i=(t=parseOtherUrl(e)).src,o=t.protocol,a=t.domain,s=t.search,{src:i,format:FormatsMap[A]||"image",extra:{protocol:o,domain:a,search:s,origin:e}}))},isSupportNativeImage=canIUse(exports.EMixRenderComponents.Image),CSRImageProxy=function(){function e(e){this.config=e,this.isInitialized=!1,this.renderFormat="image"}return e.prototype.init=function(){var i;return __awaiter(this,void 0,void 0,function(){var t,A,r,n;return __generator(this,function(e){switch(e.label){case 0:return t=this.config.renderer,A=this,"web"!==(t=t&&"auto"!==t?t:isSupportNativeImage?"native":"web")?[3,2]:[4,getFormat((this.config.formats||["avif","webp"]).filter(function(e){return"heic"!==e}))];case 1:return r=e.sent()||"image",[3,3];case 2:r=(null==(i=this.config.formats)?void 0:i[0])||"heic",e.label=3;case 3:return A.renderFormat=r,n=__assign(__assign({},this.config),{src:getSrc(this.config.src,this.config.loader,this.renderFormat||"image")}),this.widget=new("native"===t?CSRImageWidget4Native:ImageWidget4Web)(n),[4,this.widget.init()];case 4:return(n=e.sent())[0]&&(this.isInitialized=!0),[2,n]}})})},e.prototype.setSrc=function(e){return this.widget.setSrc(getSrc(e,this.config.loader,this.renderFormat||"image"))},e.prototype.setObjectFit=function(e){return this.widget.setObjectFit(e)},e.prototype.setCornerRadius=function(e){return this.widget.setCornerRadius(e)},e.prototype.destroy=function(){var e;return null==(e=this.widget)?void 0:e.destroy()},e}(),SSRImageProxy=function(){function e(e){this.config=e,this.isInitialized=!1,this.renderFormat="heic"}return e.prototype.init=function(){this.renderFormat="heic";var e=__assign(__assign({},this.config),{src:getSrc(this.config.src,this.config.loader,this.renderFormat)}),t=(this.widget=new SSRImageWidget4Native(e),this.widget.init());return this.isInitialized=!0,{id:t,src:e.src}},e.prototype.setSrc=function(e){var t;return null==(t=this.widget)?void 0:t.setSrc(getSrc(e,this.config.loader,this.renderFormat||"image"))},e.prototype.setObjectFit=function(e){var t;return null==(t=this.widget)?void 0:t.setObjectFit(e)},e.prototype.setCornerRadius=function(e){var t;return null==(t=this.widget)?void 0:t.setCornerRadius(e)},e.prototype.destroy=function(){var e;return null==(e=this.widget)?void 0:e.destroy()},e}();function createImageProxy(e){return new(void 0!==e.ssrConfig?SSRImageProxy:CSRImageProxy)(e)}var Viewer=function(t){var e,A,r=React.useRef(null),n=React.useRef(null),i=React.useRef(n.current&&n.current.isInitialized),o=React.useRef(-1);return React.useEffect(function(){var e;i.current=null==(e=n.current)?void 0:e.isInitialized},[null==(e=n.current)?void 0:e.isInitialized]),React.useEffect(function(){if(r.current)return i.current||(n.current=createImageProxy({container:r.current,renderer:t.renderer||"auto",src:t.src,loader:t.loader,objectFit:t.objectFit,cornerRadius:t.cornerRadius||"",formats:t.formats||["heic","avif","webp"]}),n.current.init().then(function(e){e[0]&&(i.current=!0)})),function(){var e;n.current&&n.current.destroy&&null!=(e=n.current)&&e.destroy()}},[]),React.useEffect(function(){var e;i.current&&null!=(e=n.current)&&e.setSrc(t.src)},[t.src]),React.useEffect(function(){var e;i.current&&null!=(e=n.current)&&e.setObjectFit(t.objectFit)},[t.objectFit]),React.useEffect(function(){var e;i.current&&null!=(e=n.current)&&e.setCornerRadius(t.cornerRadius)},[t.cornerRadius]),null!=(e=t.ssrConfig)&&e.isSSR&&null!=(e=t.ssrConfig)&&e.hybridRender&&-1===o.current&&(n.current=createImageProxy({renderer:"native",src:t.src,loader:t.loader,objectFit:t.objectFit,cornerRadius:t.cornerRadius||"",ssrConfig:t.ssrConfig}),e=n.current.init(),o.current=e.id,"undefined"==typeof window&&((A=new Function("return this")()).imagexSsrData||(A.imagexSsrData=[]),A.imagexSsrData.push(__assign(__assign({},e||{}),{width:t.width,height:t.height,objectFit:t.objectFit,cornerRadius:t.cornerRadius||""}))),i.current=!0),React__default.default.createElement("div",{className:"pia-mixrender-image",style:{width:t.width,height:t.height}},null!=(A=t.ssrConfig)&&A.isSSR?null!=(e=t.ssrConfig)&&e.hybridRender?"iOS"===(null==(A=t.ssrConfig)?void 0:A.platform)?React__default.default.createElement("div",{ref:r,style:{opacity:1,width:t.width,height:t.height,fontSize:0,lineHeight:0,overflow:"scroll",WebkitOverflowScrolling:"touch",backgroundColor:"rgba(13, ".concat(Math.floor(o.current/255),", ").concat(Math.floor(o.current%255),", 0.13)")}},React__default.default.createElement("div",{style:{width:"100%",height:"100%"}}),React__default.default.createElement("div",{style:{height:1}})):React__default.default.createElement("div",{ref:r,style:{opacity:1,width:t.width,height:t.height,fontSize:0,lineHeight:0}},React__default.default.createElement("embed",{"tt-embed-id":o.current,type:"ttplugin/hybrid_component",style:{width:"100%",height:"100%"}})):React__default.default.createElement("img",{src:getSrc(t.src,t.loader,"image"),style:{width:"100%",height:"100%",objectFit:t.objectFit,borderRadius:t.cornerRadius}}):React__default.default.createElement("div",{ref:r,style:{width:t.width,height:t.height,fontSize:0,lineHeight:0}}))},exportInitScript=function(){var e,t=new Function("return this")();return t.imagexSsrData?(e=';(function(e){document.addEventListener("DOMContentLoaded",function(){console.log("ImageX SSR Init");var i=window.byted_mixrender_native;console.log("byted_mixrender_native:",i);if(i)for(var t=0;t<(e||[]).length;t++){i.invoke(e[t].id,"initialize",JSON.stringify({type:"web_image",mode:"embed",properties:{src:e[t].src,width:e[t].width,height:e[t].height,objectFit:e[t].objectFit,cornerRadius:e[t].cornerRadius}}),e[t].id);console.log("initialize:",e[t])}})})('.concat(JSON.stringify(t.imagexSsrData||[]),")"),t._mix_render_core_=void 0,t.imagexSsrData=void 0,e):""};exports.CSRImageProxy=CSRImageProxy,exports.SSRImageProxy=SSRImageProxy,exports.ValidFormat=ValidFormat$1,exports.ValidPlatform=ValidPlatform,exports.Viewer=Viewer,exports.createImageProxy=createImageProxy,exports.exportInitScript=exportInitScript;
{
"name": "@volcengine/imagex-hybrid-react",
"version": "0.1.2-alpha.3",
"version": "0.1.2",
"description": "hybrid image viewer",

@@ -5,0 +5,0 @@ "private": false,

@@ -5,26 +5,4 @@ # @volcengine/imagex-hybrid-react

## 安装与使用
## 使用指南
### 前置依赖
为保证同层渲染正常运行,请先接入客户端 SDK。
### NPM 引入
```
npm install @volcengine/imagex-hybrid-react -S
```
```
import { Viewer } from ' @volcengine/imagex-hybrid-react';
<Viewer
width={300}
height={200}
formats={['heic', 'avif', 'webp']}
loader={({ src, format, extra: { domain, search, template } }) => `https://${domain}/${src}~${template}.${format}${search}`}
src='xxx'
cornerRadius='5px'
objectFit='contain'
/>
```
请参考[接入指南](https://www.volcengine.com/docs/508/1149750)。
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc