"use strict";var _constant=require("../../../utils/constant");function _typeof(t){return _typeof="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},_typeof(t)}function ownKeys(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,o)}return n}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(n),!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(t,e,n){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(t,e){if("object"!==_typeof(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e||"default");if("object"!==_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}Component({properties:{sdkInstance:{type:Object,value:null},themeColor:{type:Object,value:null}},data:{richTextMenusData:[],activeTab:0},observers:{sdkInstance:function(t){if(t){this.sdkInstance=t,this.store=t.store;var e=this;this.bindIconClick(),"function"==typeof this.unsub&&this.unsub(),this.unsub=null,this.unsub=this.store.get({liveInfo:function(t){var n,o,i;if(null!=t&&null!==(n=t.Menus)&&void 0!==n&&n.Menus){var r=null===(o=t.Menus)||void 0===o||null===(i=o.Menus)||void 0===i?void 0:i.filter(function(t){return t.Type===_constant.MENU_TYPE.ImageTextIntro}).map(function(t){return _objectSpread(_objectSpread({},t),{},{enable:!0,title:t.Name,key:t.Index})});if(JSON.stringify(e.data.richTextMenusData)!==JSON.stringify(r)){var c={richTextMenusData:r};(!r.length||e.data.activeTab>=r.length)&&(c.activeTab=0),e.setData(c),r.length||e.hideDrawer()}}}})}}},lifetimes:{detached:function(){"function"==typeof this.unsub&&this.unsub(),this.unsub=null,this.unbindIconClick()}},methods:{showDrawer:function(){this.selectComponent("#volc-drawer-rich-text-portrait").showFrame()},hideDrawer:function(){var t,e;null===(t=this.selectComponent("#volc-drawer-rich-text-portrait"))||void 0===t||null===(e=t.hideFrame)||void 0===e||e.call(t,{silent:!0})},bindIconClick:function(){var t=this;this.unbindIconClick(),this.sdkInstance&&(this._onBottomIconClick=function(e){var n;"RICHTEXT"===(null==e||null===(n=e.icon)||void 0===n?void 0:n.key)&&t.showDrawer()},this._bottomIconClickSdk=this.sdkInstance,this.sdkInstance.on(_constant.EVENTS.PUBLIC.bottomIcon.click,this._onBottomIconClick))},unbindIconClick:function(){var t,e;this._bottomIconClickSdk&&this._onBottomIconClick&&(null===(t=(e=this._bottomIconClickSdk).off)||void 0===t||t.call(e,_constant.EVENTS.PUBLIC.bottomIcon.click,this._onBottomIconClick)),this._bottomIconClickSdk=null,this._onBottomIconClick=null},onTabClick:function(t){var e=t.detail.index;this.setData({activeTab:e})},onChange:function(t){var e=t.detail.index;this.setData({activeTab:e})}}});