"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames2=_interopRequireDefault(require("../helpers/libs/classNames")),_styleToCssString=_interopRequireDefault(require("../helpers/libs/styleToCssString")),_safeAreaBehavior=_interopRequireDefault(require("../helpers/mixins/safeAreaBehavior")),_useSafeArea=require("../helpers/hooks/useSafeArea");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"==_typeof(e)?e:String(e)}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!=_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}var cssVarPattern=/^--/;(0,_baseComponent.default)({behaviors:[_safeAreaBehavior.default],properties:{prefixCls:{type:String,value:"wux-safe-area"},multiple:{type:Number,value:1},wrapStyle:{type:[String,Object],value:""},forceRender:{type:Boolean,value:!1},supports:{type:Boolean,value:!1}},data:{extStyle:""},computed:{classes:["prefixCls, forceRender, supports, safeAreaConfig, isIPhoneX",function(e,t,r,o,a){return{wrap:(0,_classNames2.default)(e,_defineProperty(_defineProperty(_defineProperty({},"".concat(e,"--position-bottom"),(t||a)&&o.bottom),"".concat(e,"--position-top"),(t||a)&&!o.bottom),"".concat(e,"--supports"),(t||a)&&r))}}]},observers:_defineProperty({},"safeAreaConfig, safeAreaStyle, isIPhoneX, multiple, wrapStyle, forceRender, supports",function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var o=t[0],a=t[1],i=t[2],n=t[3],s=t[4],l=t[5],u=t[6];this.updateStyle({safeAreaConfig:o,safeAreaStyle:a,isIPhoneX:i,multiple:n,wrapStyle:s,forceRender:l,supports:u})}),methods:{updateStyle:function(e){var t=e.safeAreaConfig,r=e.safeAreaStyle,o=e.isIPhoneX,a=e.multiple,i=e.wrapStyle,n=e.forceRender,e=e.supports,t=t.bottom?"bottom":t.top?"top":"none",s={},l=_defineProperty({},"--safe-area-multiple",a),e=((n||o)&&!e&&["bottom","top"].includes(t)&&(n=(0,_useSafeArea.getSafeAreaInset)(r),s[o="bottom"==t?"paddingBottom":"paddingTop"]="calc(".concat(n[t],"PX * ").concat(a,")"),l["--safe-area-inset-".concat(t)]="".concat(n[t],"PX"),l[o]="calc(var(--safe-area-inset-".concat(t,") * var(--safe-area-multiple))")),(0,_styleToCssString.default)((0,_styleToCssString.default)(s)+(0,_styleToCssString.default)(l,{exclude:cssVarPattern})+(0,_styleToCssString.default)(i)));e!==this.data.extStyle&&this.setData({extStyle:e})}},attached:function(){this.updateStyle(this.data)}});