"use strict";function t(e){"@babel/helpers - typeof";return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e,o){return(e=n(e))in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function n(e){var n=o(e,"string");return"symbol"==t(n)?n:n+""}function o(e,n){if("object"!=t(e)||!e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var i=o.call(e,n||"default");if("object"!=t(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}/*!
 * mp-html v2.5.2
 * https://github.com/jin-yufeng/mp-html
 *
 * Released under the MIT license
 * Author: Jin Yufeng
 */
var i=require("./parser"),r=[];Component({data:{nodes:[]},props:{containerStyle:"",content:"",copyLink:!0,domain:"",errorImg:"",lazyLoad:!1,loadingImg:"",pauseVideo:!0,previewImg:!0,scrollTable:!1,setTitle:!0,showImgMenu:!0,tagStyle:{}},didMount:function(){this.plugins=[];for(var t=r.length;t--;)this.plugins.push(new r[t](this));this.props.content&&this.setContent(this.props.content)},didUpdate:function(t){t.content!==this.props.content&&this.setContent(this.props.content)},didUnmount:function(){this._hook("onDetached")},methods:{in:function(t,e,n){t&&e&&n&&(this._in={page:t,selector:e,scrollTop:n})},navigateTo:function(t,n){var o=this;return new Promise(function(i,r){if(!o.props.useAnchor)return void r(Error("Anchor is disabled"));var s=my.createSelectorQuery().select((o._in?o._in.selector:"._root")+(t?"".concat(" ","#").concat(t):"")).boundingClientRect();o._in?s.select(o._in.selector).scrollOffset().select(o._in.selector).boundingClientRect():s.selectViewport().scrollOffset(),s.exec(function(t){if(!t[0])return void r(Error("Label not found"));var s=t[1].scrollTop+t[0].top-(t[2]?t[2].top:0)+(n||parseInt(o.props.useAnchor)||0);o._in?o._in.page.setData(e({},o._in.scrollTop,s)):my.pageScrollTo({scrollTop:s,duration:300}),i()})})},getText:function(t){var e="";return function t(n){for(var o=0;o<n.length;o++){var i=n[o];if("text"===i.type)e+=i.text.replace(/&amp;/g,"&");else if("br"===i.name)e+="\n";else{var r="p"===i.name||"div"===i.name||"tr"===i.name||"li"===i.name||"h"===i.name[0]&&i.name[1]>"0"&&i.name[1]<"7";r&&e&&"\n"!==e[e.length-1]&&(e+="\n"),i.children&&t(i.children),r&&"\n"!==e[e.length-1]?e+="\n":"td"!==i.name&&"th"!==i.name||(e+="\t")}}}(t||this.data.nodes),e},getRect:function(){return new Promise(function(t,e){my.createSelectorQuery().select("._root").boundingClientRect().exec(function(n){return n[0]?t(n[0]):e(Error("Root label not found"))})})},pauseMedia:function(){for(var t=(this._videos||[]).length;t--;)this._videos[t].pause()},setPlaybackRate:function(t){this.playbackRate=t;for(var e=(this._videos||[]).length;e--;)this._videos[e].playbackRate(t)},setContent:function(t,e){var n=this;this.imgList&&e||(this.imgList=[]),this._videos=[];var o={},r=new i(this).parse(t);if(e)for(var s=this.data.nodes.length,a=r.length;a--;)o["nodes[".concat(s+a,"]")]=r[a];else o.nodes=r;if(this.setData(o,function(){n._hook("onLoad"),n.props.onLoad&&n.props.onLoad()}),this.props.lazyLoad||this.imgList._unloadimgs<this.imgList.length/2){var l=0,c=function(t){t&&t.height||(t={}),t.height===l?n.props.onReady&&n.props.onReady(t):(l=t.height,setTimeout(function(){n.getRect().then(c).catch(c)},350))};this.getRect().then(c).catch(c)}else this.imgList._unloadimgs||this.getRect().then(function(t){n.props.onReady&&n.props.onReady(t)}).catch(function(){n.props.onReady&&n.props.onReady({})})},_hook:function(t){for(var e=r.length;e--;)this.plugins[e][t]&&this.plugins[e][t]()},_add:function(t){t.root=this}}});