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
20
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.1-beta.1 to 0.1.1-beta.2

2

es/index.js

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

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

@@ -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,A){return(extendStatics=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,A){e.__proto__=A}:function(e,A){for(var t in A)Object.prototype.hasOwnProperty.call(A,t)&&(e[t]=A[t])}))(e,A)};function __extends(e,A){if("function"!=typeof A&&null!==A)throw new TypeError("Class extends value "+String(A)+" is not a constructor or null");function t(){this.constructor=e}extendStatics(e,A),e.prototype=null===A?Object.create(A):(t.prototype=A.prototype,new t)}var __assign=function(){return(__assign=Object.assign||function(e){for(var A,t=1,r=arguments.length;t<r;t++)for(var n in A=arguments[t])Object.prototype.hasOwnProperty.call(A,n)&&(e[n]=A[n]);return e}).apply(this,arguments)};function __rest(e,A){var t={};for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&A.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)A.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]]);return t}function __awaiter(e,o,a,s){return new(a=a||Promise)(function(t,A){function r(e){try{i(s.next(e))}catch(e){A(e)}}function n(e){try{i(s.throw(e))}catch(e){A(e)}}function i(e){var A;e.done?t(e.value):((A=e.value)instanceof a?A:new a(function(e){e(A)})).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(t){return function(e){var A=[t,e];if(i)throw new TypeError("Generator is already executing.");for(;s=c&&A[c=0]?0:s;)try{if(i=1,o&&(a=2&A[0]?o.return:A[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,A[1])).done)return a;switch(o=0,(A=a?[2&A[0],a.value]:A)[0]){case 0:case 1:a=A;break;case 4:return s.label++,{value:A[1],done:!1};case 5:s.label++,o=A[1],A=[0];continue;case 7:A=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===A[0]||2===A[0])){s=0;continue}if(3===A[0]&&(!a||A[1]>a[0]&&A[1]<a[3]))s.label=A[1];else if(6===A[0]&&s.label<a[1])s.label=a[1],a=A;else{if(!(a&&s.label<a[2])){a[2]&&s.ops.pop(),s.trys.pop();continue}s.label=a[2],s.ops.push(A)}}A=n.call(r,s)}catch(e){A=[6,e],o=0}finally{i=a=0}if(5&A[0])throw A[1];return{value:A[0]?A[1]:void 0,done:!0}}}}var EPlatform,ValidFormat$1=["webp","avif","heic","jpeg","png"];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,A;return _systemInfo_||(e=getUserAgent().match(REGEXP_DETECT_PLATFORM),A=EPlatform.UNKNOWN,e&&(A="Android"===e[1]?EPlatform.ANDROID:EPlatform.IOS),_systemInfo_={platform:A}),_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,A){var t=this._records[e],r=getMixRenderInstance();t&&(null!=(r=null==r?void 0:r.getLogger())&&r.log("callback, callbackId: ".concat(e,"; res: "),A),t(A))},e}(),MixRenderEventDelegate=function(){function e(){this._records={}}return e.prototype.addEventHandler=function(e,A,t){this._records[e]||(this._records[e]={}),this._records[e][A]||(this._records[e][A]=[]),this._records[e][A].push(t)},e.prototype.removeEventHandler=function(e,A,t){var r;this._records[e]&&(t?(r=this._records[e][A])&&-1<(t=r.indexOf(t))&&r.splice(t,1):this._records[e][A]=[])},e.prototype.dispatchEvent=function(e,A,t){this._records[e]&&(e=this._records[e][A])&&e.forEach(function(e){e(t)})},e}(),globalObject$4=getGlobal(),MixRenderLogger=function(){function e(e){this.prefix=e,this.isEnabled=!1,this.isEnabled=this.checkLoggerEnabled()}return e.prototype.log=function(e,A){this.isEnabled&&console.log(this.prefix,e,A,Date.now())},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$4.location)?void 0:e.href.split("?")[1];if(e)for(var A=0,t=e.split("&");A<t.length;A++)if(t[A]==="".concat("__pia_mixrender_logger__","=1"))return!0;return globalObject$4.__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,A){switch(e){case"callbackRegistry":this.CallbackRegistryImpl=A;break;case"eventDelegate":this.EventDelegateImpl=A;break;case"logger":this.LoggerImpl=A}},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,A=getGlobal();return A._mix_render_core_||((e=new MixRenderCore).init(),A._mix_render_core_=e),A._mix_render_core_}function addMixRenderEventHandler(e,A,t){getMixRenderInstance().getEventDelegate().addEventHandler(e,A,t)}function removeMixRenderEventHandler(e,A,t){getMixRenderInstance().getEventDelegate().removeEventHandler(e,A,t)}var _a,globalObject$3=getGlobal();function call(e,A,t,r){var n,i=globalObject$3.byted_mixrender_native;i&&(n=getMixRenderInstance(),r=r?n.getCallbackRegistry().register(r):-1,i.invoke(e,A,JSON.stringify(t),r),n.getLogger().log("invoke, native component id ".concat(e,", command: ").concat(A,", callbackId: ").concat(r,", params: "),t))}function callSync(e,A){var t=globalObject$3.byted_mixrender_native;if(null!=t&&t.invokeSync){t=JSON.parse(t.invokeSync(e,JSON.stringify(A))||"");if(0===(null==t?void 0:t.status))return(e={}).mixrender_component_support_list=t.data,e}}function allocateId(){return getMixRenderInstance().allocateId()}var globalObject$2=getGlobal();function getMixRenderConfig(){var e,A=getMixRenderInstance();return A.getConfig()||(e=globalObject$2.byted_mixrender_config,A.getLogger().log("nativeConfig",e),e?A.setConfig(e):isAndroid()&&(e=callSync("getFeatures",null),A.setConfig(e),A.getLogger().log("GetFeatures",e))),A.getConfig()}function canIUse(e,A){void 0===A&&(A=!1);var t=getMixRenderConfig();return!(!(t&&t.mixrender_component_support_list&&t.mixrender_component_support_list[e])||(t="".concat(t.mixrender_component_support_list[e]),!A&&inBlockList(e,t)))}function isRuntimeModeSupport(e){var A;return!isAndroid()||(A=getMixRenderConfig())&&A.mixrender_runtime_support_list&&1===(null==(A=A.mixrender_runtime_support_list)?void 0:A[e])}var BLOCK_LIST={Android:{MixRender:{},PiaMixRender:((_a={})[exports.EMixRenderComponents.LivePlayer]=["1"],_a)},iOS:{MixRender:{}}};function inBlockList(e,A){var t,r=!1,n=[];if(n=(isAndroid()?(t=getMixRenderConfig(),isAndroid()&&t.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]===A){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 AdapterImpl,LegacyAdapter=function(){function e(e,A,t){this.id=e,this.type=A,this.mode=t}return e.prototype.init=function(e){var t=this;return new Promise(function(A){call(t.id,"initialize",{type:t.type,properties:e},function(e){e=e.status;A(translateMixRenderCallbackResponse(e))})})},e.prototype.update=function(e){var t=this;return new Promise(function(A){call(t.id,"update",{type:t.type,properties:e},function(e){e=e.status;A(translateMixRenderCallbackResponse(e))}),isAndroid()||A([!0])})},e.prototype.destroy=function(e){var t=this;return void 0===e&&(e={}),new Promise(function(A){call(t.id,"destroy",{type:t.type,properties:e},function(e){e=e.status;A(translateMixRenderCallbackResponse(e))}),isAndroid()||A([!0])})},e.prototype.invoke=function(e){e.method,e.params;e=__rest(e,["method","params"]);return this.update(e)},e.prototype.addEventListener=function(e,A){addMixRenderEventHandler(this.id,e,A)},e.prototype.removeEventListener=function(e,A){removeMixRenderEventHandler(this.id,e,A)},e}(),PiaMixRenderAdapter=function(e){function A(){return null!==e&&e.apply(this,arguments)||this}return __extends(A,e),A.prototype.init=function(t){var r=this;return new Promise(function(A){var e={type:r.type,properties:t};"embed"===r.mode&&(e.mode="embed"),call(r.id,"initialize",e,function(e){e=e.status;A(translateMixRenderCallbackResponse(e))})})},A.prototype.invoke=function(r){var n=this;return new Promise(function(A){var e=r.method,t=r.params;call(n.id,"invokeMethod",{type:n.type,method:e,params:t},function(e){e=e.status;A(translateMixRenderCallbackResponse(e))})})},A}(LegacyAdapter),globalObject$1=getGlobal();function getAdapterImpl(e){var A;return AdapterImpl||(A=globalObject$1.byted_mixrender_config,AdapterImpl=isAndroid()&&A&&A.mixrender_runtime_support_list?PiaMixRenderAdapter:LegacyAdapter),AdapterImpl}function setupAdapter(e,A,t){return void 0===t&&(t="dig"),new(getAdapterImpl())(e,A,t)}var TRANSFORM_BASE_BETWEEN_ID_AND_RGBA=255;function createPlaceholder4Android(e,A,t){var r;return console.log("[PIA MixRender]","create placeholder",Date.now()),"dig"===t?(e.setAttribute("tt-render-in-browser",String(A)),{destroy:function(){e.removeAttribute("tt-render-in-browser")}}):((r=document.createElement("embed")).setAttribute("tt-embed-id",String(A)),r.setAttribute("type","ttplugin/hybrid_component"),r.style.width="100%",r.style.height="100%",e.appendChild(r),console.log("[PIA MixRender]","create placeholder finish",Date.now()),{destroy:function(){e.removeChild(r)}})}function createPlaceholder4IOS(e,A){console.log("[PIA MixRender]","create placeholder",Date.now());var t={overflow:e.style.overflow,"-webkit-overflow-scrolling":e.style["-webkit-overflow-scrolling"],backgroundColor:e.style.backgroundColor},r=Math.floor(A/TRANSFORM_BASE_BETWEEN_ID_AND_RGBA),A=Math.floor(A%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(A,", 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),console.log("[PIA MixRender]","create placeholder finish",Date.now()),{destroy:function(){e.removeChild(n),e.removeChild(i),Object.assign(e.style,t)}}}function createPlaceholder(e,A,t){return isAndroid()?createPlaceholder4Android(e,A,t):createPlaceholder4IOS(e,A)}function callback(e,A){var t=getMixRenderInstance();t.getLogger().log("invoke native method callback, with: callbackId: ".concat(e,", res:"),A),t.getCallbackRegistry().dispatch(e,JSON.parse(A))}function invoke(e,A,t){var r=getMixRenderInstance();r.getLogger().log("trigger native event, with: id: ".concat(e,", command: ").concat(A,", params: "),t),r.getEventDelegate().dispatchEvent(e,A,JSON.parse(t))}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/,ImageWidget4Native=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 A,t,r;return __generator(this,function(e){switch(e.label){case 0:return console.log("[PIA MixRender]","widget init",Date.now()),A=this.config.container,t=A.style.opacity||"1",A.style.opacity="0.1",this.placeholder=createPlaceholder(A,this.id,this.mode),(r=this.config).container,r.renderer,r.mode,r.cornerRadius,r=__rest(r,["container","renderer","mode","cornerRadius"]),[4,this.adapter.init(__assign(__assign({},r),{cornerRadius:this.getCornerRadius()}))];case 1:return r=e.sent(),A.style.opacity=t,r[0]&&(this.cornerRadiusMatchRes4Percent&&window.addEventListener("resize",this.updateCornerRadiusWhenResize),A.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.destroy=function(){return __awaiter(this,void 0,void 0,function(){var A;return __generator(this,function(e){switch(e.label){case 0:return[4,this.adapter.destroy()];case 1:return(A=e.sent())[0]&&(this.placeholder.destroy(),this.cornerRadiusMatchRes4Percent)&&window.removeEventListener("resize",this.updateCornerRadiusWhenResize),[2,A]}})})},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}(),ImageWidget4Web=function(){function e(e){this.config=e}return e.prototype.init=function(){console.log("[PIA MixRender]","widget init",Date.now());var e=this.config,A=e.container,t=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=t,this.image.style.objectFit=r,this.image.style.borderRadius="".concat(e,"px"),A.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.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!!ValidFormat.includes(r)&&("jpeg"===r||"png"===r||!!FORMAT_BASE64_MAP[r]&&new Promise(function(A){if("undefined"==typeof window&&A(!1),void 0!==window["__support_".concat(r,"__")])A(!!window["__support_".concat(r,"__")]);else{if(FORMAT_BASE64_MAP[r].prerequisite)if(!FORMAT_BASE64_MAP[r].prerequisite())return window["__support_".concat(r,"__")]=!1,void A(!1);var t=new Image;t.onload=function(){var e=(null==t?void 0:t.height)===FORMAT_BASE64_MAP[r].height;window["__support_".concat(r,"__")]=e,A(e)},t.onerror=function(){window["__support_".concat(r,"__")]=!1,A(!1)},t.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 A,t,r,n;return __generator(this,function(e){switch(e.label){case 0:"undefined"==typeof window&&i("image"),A=0,t=o,e.label=1;case 1:if(!(A<t.length))return[3,7];r=t[A],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 A++,[3,1];case 7:return i("image"),[2]}})})})];case 1:return[2,e.sent()]}})})},parseImagexUrl=function(e){try{var A=e.startsWith("http")?e:(e.startsWith("//")?"https:":"http://").concat(e),t=new URL(A),r=imagexUrlPattern.exec(t.pathname.slice(1));return{protocol:t.protocol,domain:t.hostname,src:r[1],template:r[2],suffix:r[3],search:t.search}}catch(e){return console.error(e),ErrorImageXUrl}},parseOtherUrl=function(e){try{var A=e.startsWith("http")?e:(e.startsWith("//")?"https:":"http://").concat(e),t=new URL(A);return{protocol:t.protocol,domain:t.hostname,src:t.pathname.slice(1),search:t.search}}catch(e){return ErrorUrl}},isImagexUrl=function(e){return imagexUrlPattern.test(e)},isSupportNativeImage=canIUse(exports.EMixRenderComponents.Image),ImageProxy=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 A,t,r,n;return __generator(this,function(e){switch(e.label){case 0:return console.log("[PIA MixRender]","proxy init",Date.now()),A=this.config.renderer,t=this,"web"!==(A=A&&"auto"!==A?A: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 t.renderFormat=r,console.log("[PIA MixRender]","check format",this.renderFormat,Date.now()),n=__assign(__assign({},this.config),{src:this.getSrc()}),this.widget=new("native"===A?ImageWidget4Native:ImageWidget4Web)(n),[4,this.widget.init()];case 4:return(n=e.sent())[0]&&(this.isInitialized=!0),[2,n]}})})},e.prototype.getSrc=function(e){var A,t,r,n,i,o,e=void 0===e?this.config.src:e;return A=isImagexUrl(e)?(r=(o=parseImagexUrl(e)).src,n=o.protocol,i=o.domain,t=o.suffix,A=o.template,o=o.search,{src:r,format:FormatsMap[this.renderFormat]||"image",extra:{suffix:t,template:A,search:o,protocol:n,domain:i,origin:e}}):(r=(t=parseOtherUrl(e)).src,n=t.protocol,i=t.domain,o=t.search,{src:r,format:FormatsMap[this.renderFormat]||"image",extra:{protocol:n,domain:i,search:o,origin:e}}),this.config.loader(A)},e.prototype.setSrc=function(e){return this.widget.setSrc(this.getSrc(e))},e.prototype.setObjectFit=function(e){return this.widget.setObjectFit(e)},e.prototype.setCornerRadius=function(e){return this.widget.setCornerRadius(e)},e.prototype.destroy=function(){return this.widget.destroy()},e}();function createImageProxy(e){return new ImageProxy(e)}var Viewer=function(A){var e=React.useRef(null),t=React.useRef(null),r=React.useState(t.current&&t.current.isInitialized),n=r[0],i=r[1];return React.useEffect(function(){if(console.log("[PIA MixRender]","viewer mounted",Date.now()),e.current)return t.current=createImageProxy({container:e.current,renderer:A.renderer||"auto",src:A.src,loader:A.loader,objectFit:A.objectFit,cornerRadius:A.cornerRadius||"",mode:A.mode,formats:A.formats||["heic","avif","webp"]}),console.log("[PIA MixRender]","image proxy created",Date.now()),t.current.init().then(function(e){e[0]&&(console.log("[PIA MixRender]","init finish",Date.now()),i(!0))}),function(){var e;null!=(e=t.current)&&e.destroy()}},[]),React.useEffect(function(){var e;n&&null!=(e=t.current)&&e.setSrc(A.src)},[A.src,n]),React.useEffect(function(){var e;n&&null!=(e=t.current)&&e.setObjectFit(A.objectFit)},[A.objectFit,n]),React.useEffect(function(){var e;n&&null!=(e=t.current)&&e.setCornerRadius(A.cornerRadius)},[A.cornerRadius,n]),React__default.default.createElement("div",{className:"pia-mixrender-image",style:{width:A.width,height:A.height}},React__default.default.createElement("div",{ref:e,style:{width:A.width,height:A.height,fontSize:0,lineHeight:0}}))};exports.ImageProxy=ImageProxy,exports.ValidFormat=ValidFormat$1,exports.Viewer=Viewer,exports.createImageProxy=createImageProxy;
"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,A){return(extendStatics=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,A){e.__proto__=A}:function(e,A){for(var t in A)Object.prototype.hasOwnProperty.call(A,t)&&(e[t]=A[t])}))(e,A)};function __extends(e,A){if("function"!=typeof A&&null!==A)throw new TypeError("Class extends value "+String(A)+" is not a constructor or null");function t(){this.constructor=e}extendStatics(e,A),e.prototype=null===A?Object.create(A):(t.prototype=A.prototype,new t)}var __assign=function(){return(__assign=Object.assign||function(e){for(var A,t=1,r=arguments.length;t<r;t++)for(var n in A=arguments[t])Object.prototype.hasOwnProperty.call(A,n)&&(e[n]=A[n]);return e}).apply(this,arguments)};function __rest(e,A){var t={};for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&A.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)A.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]]);return t}function __awaiter(e,o,a,s){return new(a=a||Promise)(function(t,A){function r(e){try{i(s.next(e))}catch(e){A(e)}}function n(e){try{i(s.throw(e))}catch(e){A(e)}}function i(e){var A;e.done?t(e.value):((A=e.value)instanceof a?A:new a(function(e){e(A)})).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(t){return function(e){var A=[t,e];if(i)throw new TypeError("Generator is already executing.");for(;s=c&&A[c=0]?0:s;)try{if(i=1,o&&(a=2&A[0]?o.return:A[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,A[1])).done)return a;switch(o=0,(A=a?[2&A[0],a.value]:A)[0]){case 0:case 1:a=A;break;case 4:return s.label++,{value:A[1],done:!1};case 5:s.label++,o=A[1],A=[0];continue;case 7:A=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===A[0]||2===A[0])){s=0;continue}if(3===A[0]&&(!a||A[1]>a[0]&&A[1]<a[3]))s.label=A[1];else if(6===A[0]&&s.label<a[1])s.label=a[1],a=A;else{if(!(a&&s.label<a[2])){a[2]&&s.ops.pop(),s.trys.pop();continue}s.label=a[2],s.ops.push(A)}}A=n.call(r,s)}catch(e){A=[6,e],o=0}finally{i=a=0}if(5&A[0])throw A[1];return{value:A[0]?A[1]:void 0,done:!0}}}}var EPlatform,ValidFormat$1=["webp","avif","heic","jpeg","png"];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,A;return _systemInfo_||(e=getUserAgent().match(REGEXP_DETECT_PLATFORM),A=EPlatform.UNKNOWN,e&&(A="Android"===e[1]?EPlatform.ANDROID:EPlatform.IOS),_systemInfo_={platform:A}),_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,A){var t=this._records[e],r=getMixRenderInstance();t&&(null!=(r=null==r?void 0:r.getLogger())&&r.log("callback, callbackId: ".concat(e,"; res: "),A),t(A))},e}(),MixRenderEventDelegate=function(){function e(){this._records={}}return e.prototype.addEventHandler=function(e,A,t){this._records[e]||(this._records[e]={}),this._records[e][A]||(this._records[e][A]=[]),this._records[e][A].push(t)},e.prototype.removeEventHandler=function(e,A,t){var r;this._records[e]&&(t?(r=this._records[e][A])&&-1<(t=r.indexOf(t))&&r.splice(t,1):this._records[e][A]=[])},e.prototype.dispatchEvent=function(e,A,t){this._records[e]&&(e=this._records[e][A])&&e.forEach(function(e){e(t)})},e}(),globalObject$4=getGlobal(),MixRenderLogger=function(){function e(e){this.prefix=e,this.isEnabled=!1,this.isEnabled=this.checkLoggerEnabled()}return e.prototype.log=function(e,A){this.isEnabled&&console.log(this.prefix,e,A,Date.now())},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$4.location)?void 0:e.href.split("?")[1];if(e)for(var A=0,t=e.split("&");A<t.length;A++)if(t[A]==="".concat("__pia_mixrender_logger__","=1"))return!0;return globalObject$4.__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,A){switch(e){case"callbackRegistry":this.CallbackRegistryImpl=A;break;case"eventDelegate":this.EventDelegateImpl=A;break;case"logger":this.LoggerImpl=A}},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,A=getGlobal();return A._mix_render_core_||((e=new MixRenderCore).init(),A._mix_render_core_=e),A._mix_render_core_}function addMixRenderEventHandler(e,A,t){getMixRenderInstance().getEventDelegate().addEventHandler(e,A,t)}function removeMixRenderEventHandler(e,A,t){getMixRenderInstance().getEventDelegate().removeEventHandler(e,A,t)}var _a,globalObject$3=getGlobal();function call(e,A,t,r){var n,i=globalObject$3.byted_mixrender_native;i&&(n=getMixRenderInstance(),r=r?n.getCallbackRegistry().register(r):-1,i.invoke(e,A,JSON.stringify(t),r),n.getLogger().log("invoke, native component id ".concat(e,", command: ").concat(A,", callbackId: ").concat(r,", params: "),t))}function callSync(e,A){var t=globalObject$3.byted_mixrender_native;if(null!=t&&t.invokeSync){t=JSON.parse(t.invokeSync(e,JSON.stringify(A))||"");if(0===(null==t?void 0:t.status))return(e={}).mixrender_component_support_list=t.data,e}}function allocateId(){return getMixRenderInstance().allocateId()}var globalObject$2=getGlobal();function getMixRenderConfig(){var e,A=getMixRenderInstance();return A.getConfig()||(e=globalObject$2.byted_mixrender_config,A.getLogger().log("nativeConfig",e),e?A.setConfig(e):isAndroid()&&(e=callSync("getFeatures",null),A.setConfig(e),A.getLogger().log("GetFeatures",e))),A.getConfig()}function canIUse(e,A){void 0===A&&(A=!1);var t=getMixRenderConfig();return!(!(t&&t.mixrender_component_support_list&&t.mixrender_component_support_list[e])||(t="".concat(t.mixrender_component_support_list[e]),!A&&inBlockList(e,t)))}function isRuntimeModeSupport(e){var A;return!isAndroid()||(A=getMixRenderConfig())&&A.mixrender_runtime_support_list&&1===(null==(A=A.mixrender_runtime_support_list)?void 0:A[e])}var BLOCK_LIST={Android:{MixRender:{},PiaMixRender:((_a={})[exports.EMixRenderComponents.LivePlayer]=["1"],_a)},iOS:{MixRender:{}}};function inBlockList(e,A){var t,r=!1,n=[];if(n=(isAndroid()?(t=getMixRenderConfig(),isAndroid()&&t.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]===A){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 AdapterImpl,LegacyAdapter=function(){function e(e,A,t){this.id=e,this.type=A,this.mode=t}return e.prototype.init=function(e){var t=this;return new Promise(function(A){call(t.id,"initialize",{type:t.type,properties:e},function(e){e=e.status;A(translateMixRenderCallbackResponse(e))})})},e.prototype.update=function(e){var t=this;return new Promise(function(A){call(t.id,"update",{type:t.type,properties:e},function(e){e=e.status;A(translateMixRenderCallbackResponse(e))}),isAndroid()||A([!0])})},e.prototype.destroy=function(e){var t=this;return void 0===e&&(e={}),new Promise(function(A){call(t.id,"destroy",{type:t.type,properties:e},function(e){e=e.status;A(translateMixRenderCallbackResponse(e))}),isAndroid()||A([!0])})},e.prototype.invoke=function(e){e.method,e.params;e=__rest(e,["method","params"]);return this.update(e)},e.prototype.addEventListener=function(e,A){addMixRenderEventHandler(this.id,e,A)},e.prototype.removeEventListener=function(e,A){removeMixRenderEventHandler(this.id,e,A)},e}(),PiaMixRenderAdapter=function(e){function A(){return null!==e&&e.apply(this,arguments)||this}return __extends(A,e),A.prototype.init=function(t){var r=this;return new Promise(function(A){var e={type:r.type,properties:t};"embed"===r.mode&&(e.mode="embed"),call(r.id,"initialize",e,function(e){e=e.status;A(translateMixRenderCallbackResponse(e))})})},A.prototype.invoke=function(r){var n=this;return new Promise(function(A){var e=r.method,t=r.params;call(n.id,"invokeMethod",{type:n.type,method:e,params:t},function(e){e=e.status;A(translateMixRenderCallbackResponse(e))})})},A}(LegacyAdapter),globalObject$1=getGlobal();function getAdapterImpl(e){var A;return AdapterImpl||(A=globalObject$1.byted_mixrender_config,AdapterImpl=isAndroid()&&A&&A.mixrender_runtime_support_list?PiaMixRenderAdapter:LegacyAdapter),AdapterImpl}function setupAdapter(e,A,t){return void 0===t&&(t="dig"),new(getAdapterImpl())(e,A,t)}var TRANSFORM_BASE_BETWEEN_ID_AND_RGBA=255;function createPlaceholder4Android(e,A,t){var r;return console.log("[PIA MixRender]","create placeholder",Date.now()),"dig"===t?(e.setAttribute("tt-render-in-browser",String(A)),{destroy:function(){e.removeAttribute("tt-render-in-browser")}}):((r=document.createElement("embed")).setAttribute("tt-embed-id",String(A)),r.setAttribute("type","ttplugin/hybrid_component"),r.style.width="100%",r.style.height="100%",e.appendChild(r),console.log("[PIA MixRender]","create placeholder finish",Date.now()),{destroy:function(){e.removeChild(r)}})}function createPlaceholder4IOS(e,A){console.log("[PIA MixRender]","create placeholder",Date.now());var t={overflow:e.style.overflow,"-webkit-overflow-scrolling":e.style["-webkit-overflow-scrolling"],backgroundColor:e.style.backgroundColor},r=Math.floor(A/TRANSFORM_BASE_BETWEEN_ID_AND_RGBA),A=Math.floor(A%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(A,", 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),console.log("[PIA MixRender]","create placeholder finish",Date.now()),{destroy:function(){e.removeChild(n),e.removeChild(i),Object.assign(e.style,t)}}}function createPlaceholder(e,A,t){return isAndroid()?createPlaceholder4Android(e,A,t):createPlaceholder4IOS(e,A)}function callback(e,A){var t=getMixRenderInstance();t.getLogger().log("invoke native method callback, with: callbackId: ".concat(e,", res:"),A),t.getCallbackRegistry().dispatch(e,JSON.parse(A))}function invoke(e,A,t){var r=getMixRenderInstance();r.getLogger().log("trigger native event, with: id: ".concat(e,", command: ").concat(A,", params: "),t),r.getEventDelegate().dispatchEvent(e,A,JSON.parse(t))}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/,ImageWidget4Native=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 A,t,r;return __generator(this,function(e){switch(e.label){case 0:return console.log("[PIA MixRender]","widget init",Date.now()),A=this.config.container,t=A.style.opacity||"1",A.style.opacity="0.1",this.placeholder=createPlaceholder(A,this.id,this.mode),(r=this.config).container,r.renderer,r.mode,r.cornerRadius,r=__rest(r,["container","renderer","mode","cornerRadius"]),[4,this.adapter.init(__assign(__assign({},r),{cornerRadius:this.getCornerRadius()}))];case 1:return r=e.sent(),A.style.opacity=t,r[0]&&(this.cornerRadiusMatchRes4Percent&&window.addEventListener("resize",this.updateCornerRadiusWhenResize),A.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.destroy=function(){return __awaiter(this,void 0,void 0,function(){var A;return __generator(this,function(e){switch(e.label){case 0:return[4,this.adapter.destroy()];case 1:return(A=e.sent())[0]&&(this.placeholder.destroy(),this.cornerRadiusMatchRes4Percent)&&window.removeEventListener("resize",this.updateCornerRadiusWhenResize),[2,A]}})})},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}(),ImageWidget4Web=function(){function e(e){this.config=e}return e.prototype.init=function(){console.log("[PIA MixRender]","widget init",Date.now());var e=this.config,A=e.container,t=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=t,this.image.style.objectFit=r,this.image.style.borderRadius="".concat(e,"px"),A.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.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!!ValidFormat.includes(r)&&("jpeg"===r||"png"===r||!!FORMAT_BASE64_MAP[r]&&new Promise(function(A){if("undefined"==typeof window&&A(!1),void 0!==window["__support_".concat(r,"__")])A(!!window["__support_".concat(r,"__")]);else{if(FORMAT_BASE64_MAP[r].prerequisite)if(!FORMAT_BASE64_MAP[r].prerequisite())return window["__support_".concat(r,"__")]=!1,void A(!1);var t=new Image;t.onload=function(){var e=(null==t?void 0:t.height)===FORMAT_BASE64_MAP[r].height;window["__support_".concat(r,"__")]=e,A(e)},t.onerror=function(){window["__support_".concat(r,"__")]=!1,A(!1)},t.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 A,t,r,n;return __generator(this,function(e){switch(e.label){case 0:"undefined"==typeof window&&i("image"),A=0,t=o,e.label=1;case 1:if(!(A<t.length))return[3,7];r=t[A],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 A++,[3,1];case 7:return i("image"),[2]}})})})];case 1:return[2,e.sent()]}})})},parseImagexUrl=function(e){try{var A=e.startsWith("http")?e:(e.startsWith("//")?"https:":"http://").concat(e),t=new URL(A),r=imagexUrlPattern.exec(t.pathname.slice(1));return{protocol:t.protocol,domain:t.hostname,src:r[1],template:r[2],suffix:r[3],search:t.search}}catch(e){return console.error(e),ErrorImageXUrl}},parseOtherUrl=function(e){try{var A=e.startsWith("http")?e:(e.startsWith("//")?"https:":"http://").concat(e),t=new URL(A);return{protocol:t.protocol,domain:t.hostname,src:t.pathname.slice(1),search:t.search}}catch(e){return ErrorUrl}},isImagexUrl=function(e){return imagexUrlPattern.test(e)},isSupportNativeImage=canIUse(exports.EMixRenderComponents.Image),ImageProxy=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 A,t,r,n;return __generator(this,function(e){switch(e.label){case 0:return console.log("[PIA MixRender]","proxy init",Date.now()),A=this.config.renderer,t=this,"web"!==(A=A&&"auto"!==A?A: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 t.renderFormat=r,console.log("[PIA MixRender]","check format",this.renderFormat,Date.now()),console.log("[PIA MixRender]","loader beginning",Date.now()),n=__assign(__assign({},this.config),{src:this.getSrc()}),console.log("[PIA MixRender]","loader finish",Date.now()),this.widget=new("native"===A?ImageWidget4Native:ImageWidget4Web)(n),[4,this.widget.init()];case 4:return(n=e.sent())[0]&&(this.isInitialized=!0),[2,n]}})})},e.prototype.getSrc=function(e){var A,t,r,n,i,o,e=void 0===e?this.config.src:e;return A=isImagexUrl(e)?(r=(o=parseImagexUrl(e)).src,n=o.protocol,i=o.domain,t=o.suffix,A=o.template,o=o.search,{src:r,format:FormatsMap[this.renderFormat]||"image",extra:{suffix:t,template:A,search:o,protocol:n,domain:i,origin:e}}):(r=(t=parseOtherUrl(e)).src,n=t.protocol,i=t.domain,o=t.search,{src:r,format:FormatsMap[this.renderFormat]||"image",extra:{protocol:n,domain:i,search:o,origin:e}}),this.config.loader(A)},e.prototype.setSrc=function(e){console.log("[PIA MixRender]","setSrc, loader beginning",Date.now());e=this.getSrc(e);return console.log("[PIA MixRender]","setSrc, loader finish",Date.now()),this.widget.setSrc(e)},e.prototype.setObjectFit=function(e){return this.widget.setObjectFit(e)},e.prototype.setCornerRadius=function(e){return this.widget.setCornerRadius(e)},e.prototype.destroy=function(){return this.widget.destroy()},e}();function createImageProxy(e){return new ImageProxy(e)}var Viewer=function(A){var e=React.useRef(null),t=React.useRef(null),r=React.useState(t.current&&t.current.isInitialized),n=r[0],i=r[1];return React.useEffect(function(){if(console.log("[PIA MixRender]","viewer mounted",Date.now()),e.current)return t.current=createImageProxy({container:e.current,renderer:A.renderer||"auto",src:A.src,loader:A.loader,objectFit:A.objectFit,cornerRadius:A.cornerRadius||"",mode:A.mode,formats:A.formats||["heic","avif","webp"]}),console.log("[PIA MixRender]","image proxy created",Date.now()),t.current.init().then(function(e){e[0]&&(console.log("[PIA MixRender]","init finish",Date.now()),i(!0))}),function(){var e;null!=(e=t.current)&&e.destroy()}},[]),React.useEffect(function(){var e;n&&null!=(e=t.current)&&e.setSrc(A.src)},[A.src,n]),React.useEffect(function(){var e;n&&null!=(e=t.current)&&e.setObjectFit(A.objectFit)},[A.objectFit,n]),React.useEffect(function(){var e;n&&null!=(e=t.current)&&e.setCornerRadius(A.cornerRadius)},[A.cornerRadius,n]),React__default.default.createElement("div",{className:"pia-mixrender-image",style:{width:A.width,height:A.height}},React__default.default.createElement("div",{ref:e,style:{width:A.width,height:A.height,fontSize:0,lineHeight:0}}))};exports.ImageProxy=ImageProxy,exports.ValidFormat=ValidFormat$1,exports.Viewer=Viewer,exports.createImageProxy=createImageProxy;
{
"name": "@volcengine/imagex-hybrid-react",
"version": "0.1.1-beta.1",
"version": "0.1.1-beta.2",
"description": "hybrid image viewer",

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

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