/**
 * @license
 * Copyright 2021 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */
import{BaseLayout as t,dim1 as i,dim2 as e}from"./BaseLayout.js";export function gap1(t){return"horizontal"===t?"column":"row"}export function gap2(t){return"horizontal"===t?"row":"column"}export function padding1(t){return"horizontal"===t?["left","right"]:["top","bottom"]}export function padding2(t){return"horizontal"===t?["top","bottom"]:["left","right"]}export class SizeGapPaddingBaseLayout extends t{constructor(){super(...arguments),this._itemSize={},this._gaps={},this._padding={}}_getDefaultConfig(){return Object.assign({},super._getDefaultConfig(),{itemSize:{width:"300px",height:"300px"},gap:"8px",padding:"match-gap"})}get _gap(){return this._gaps.row}get _idealSize(){return this._itemSize[i(this.direction)]}get _idealSize1(){return this._itemSize[i(this.direction)]}get _idealSize2(){return this._itemSize[e(this.direction)]}get _gap1(){return this._gaps[gap1(this.direction)]}get _gap2(){return this._gaps[gap2(this.direction)]}get _padding1(){const t=this._padding,[i,e]=padding1(this.direction);return[t[i],t[e]]}get _padding2(){const t=this._padding,[i,e]=padding2(this.direction);return[t[i],t[e]]}set itemSize(t){const i=this._itemSize;"string"==typeof t&&(t={width:t,height:t});const e=parseInt(t.width),r=parseInt(t.height);e!==i.width&&(i.width=e,this._triggerReflow()),r!==i.height&&(i.height=r,this._triggerReflow())}set gap(t){this._setGap(t)}_setGap(t){const i=t.split(" ").map((t=>function gapValueToNumber(t){return"auto"===t?1/0:parseInt(t)}(t))),e=this._gaps;i[0]!==e.row&&(e.row=i[0],this._triggerReflow()),void 0===i[1]?i[0]!==e.column&&(e.column=i[0],this._triggerReflow()):i[1]!==e.column&&(e.column=i[1],this._triggerReflow())}set padding(t){const i=this._padding,e=t.split(" ").map((t=>function paddingValueToNumber(t){return"match-gap"===t?1/0:parseInt(t)}(t)));1===e.length?(i.top=i.right=i.bottom=i.left=e[0],this._triggerReflow()):2===e.length?(i.top=i.bottom=e[0],i.right=i.left=e[1],this._triggerReflow()):3===e.length?(i.top=e[0],i.right=i.left=e[1],i.bottom=e[2],this._triggerReflow()):4===e.length&&(["top","right","bottom","left"].forEach(((t,r)=>i[t]=e[r])),this._triggerReflow())}}