"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames7=_interopRequireDefault(require("../helpers/libs/classNames"));function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}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})(t)}function ownKeys(e,t){var n,r=Object.keys(e);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)),r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(n),!0).forEach(function(t){_defineProperty(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}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){t=_toPrimitive(t,"string");return"symbol"==_typeof(t)?t:String(t)}function _toPrimitive(t,e){if("object"!=_typeof(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}var defaults={prefixCls:"wux-actionsheet",theme:"ios",className:"",titleText:"",buttons:[],buttonClicked:function(){},cancelText:"取消",cancel:function(){}};(0,_baseComponent.default)({useFunc:!0,data:defaults,computed:{classes:["prefixCls, theme, buttons, cancelText",function(e,t,n,r){var o=(0,_classNames7.default)(e),c="".concat(e,"__popup"),t=(0,_classNames7.default)("".concat(e,"__content"),_defineProperty(_defineProperty({},"".concat(e,"__content--theme-").concat(t),t),"".concat(e,"__content--has-cancel"),r)),r=(0,_classNames7.default)("".concat(e,"__group"),_defineProperty({},"".concat(e,"__group--options"),!0)),a="".concat(e,"__title"),i=(0,_classNames7.default)("".concat(e,"__button"),_defineProperty({},"".concat(e,"__button--destructive"),!0));return{wrap:o,popup:c,content:t,options:r,title:a,button:n.map(function(t){return{wrap:(0,_classNames7.default)("".concat(e,"__button"),_defineProperty(_defineProperty(_defineProperty({},"".concat(e,"__button--option"),!0),"".concat(e,"__button--disabled"),t.disabled),"".concat(t.className),t.className)),hover:t.hoverClass&&"default"!==t.hoverClass?t.hoverClass:"".concat(e,"__button--hover")}}),icon:"".concat(e,"__icon"),text:"".concat(e,"__text"),destructive:i,group:(0,_classNames7.default)("".concat(e,"__group"),_defineProperty({},"".concat(e,"__group--cancel"),!0)),cancel:(0,_classNames7.default)("".concat(e,"__button"),_defineProperty({},"".concat(e,"__button--cancel"),!0)),hover:"".concat(e,"__button--hover")}}]},methods:{showSheet:function(){var t=this.$$mergeOptionsAndBindMethods(Object.assign({},defaults,0<arguments.length&&void 0!==arguments[0]?arguments[0]:{}));return this.removed=!1,this.$$setData(_objectSpread({in:!0},t)),this.cancel.bind(this)},removeSheet:function(t){if(this.removed)return!1;this.removed=!0,this.$$setData({in:!1}),"function"==typeof t&&t(this.data.buttons)},buttonClicked:function(t){t=t.currentTarget.dataset.index;!0===this.fns.buttonClicked(t,this.data.buttons[t])&&this.removeSheet()},destructiveButtonClicked:function(){!0===this.fns.destructiveButtonClicked()&&this.removeSheet()},cancel:function(){this.removeSheet(this.fns.cancel)},bindgetuserinfo:function(t){this.triggerEvent("getuserinfo",_objectSpread(_objectSpread({},t.detail),t.currentTarget.dataset))},bindcontact:function(t){this.triggerEvent("contact",_objectSpread(_objectSpread({},t.detail),t.currentTarget.dataset))},bindgetphonenumber:function(t){this.triggerEvent("getphonenumber",_objectSpread(_objectSpread({},t.detail),t.currentTarget.dataset))},bindopensetting:function(t){this.triggerEvent("opensetting",_objectSpread(_objectSpread({},t.detail),t.currentTarget.dataset))},bindlaunchapp:function(t){this.triggerEvent("launchapp",_objectSpread(_objectSpread({},t.detail),t.currentTarget.dataset))},bindchooseavatar:function(t){this.triggerEvent("chooseavatar",_objectSpread(_objectSpread({},t.detail),t.currentTarget.dataset))},onError:function(t){this.triggerEvent("error",_objectSpread(_objectSpread({},t.detail),t.currentTarget.dataset))}}});