{"version":3,"file":"listingTemplateForTooltip-Bq9zlkAK.js","sources":["../../../node_modules/flickity-fade/flickity-fade.js","../../../app/javascript/utils/listingTemplateForTooltip.js"],"sourcesContent":["/**\n * Flickity fade v1.0.0\n * Fade between Flickity slides\n */\n\n/* jshint browser: true, undef: true, unused: true */\n\n( function( window, factory ) {\n  // universal module definition\n  /*globals define, module, require */\n  if ( typeof define == 'function' && define.amd ) {\n    // AMD\n    define( [\n      'flickity/js/index',\n      'fizzy-ui-utils/utils',\n    ], factory );\n  } else if ( typeof module == 'object' && module.exports ) {\n    // CommonJS\n    module.exports = factory(\n      require('flickity'),\n      require('fizzy-ui-utils')\n    );\n  } else {\n    // browser global\n    factory(\n      window.Flickity,\n      window.fizzyUIUtils\n    );\n  }\n\n}( this, function factory( Flickity, utils ) {\n\n// ---- Slide ---- //\n\nvar Slide = Flickity.Slide;\n\nvar slideUpdateTarget = Slide.prototype.updateTarget;\nSlide.prototype.updateTarget = function() {\n  slideUpdateTarget.apply( this, arguments );\n  if ( !this.parent.options.fade ) {\n    return;\n  }\n  // position cells at selected target\n  var slideTargetX = this.target - this.x;\n  var firstCellX = this.cells[0].x;\n  this.cells.forEach( function( cell ) {\n    var targetX = cell.x - firstCellX - slideTargetX;\n    cell.renderPosition( targetX );\n  });\n};\n\nSlide.prototype.setOpacity = function( alpha ) {\n  this.cells.forEach( function( cell ) {\n    cell.element.style.opacity = alpha;\n  });\n};\n\n// ---- Flickity ---- //\n\nvar proto = Flickity.prototype;\n\nFlickity.createMethods.push('_createFade');\n\nproto._createFade = function() {\n  this.fadeIndex = this.selectedIndex;\n  this.prevSelectedIndex = this.selectedIndex;\n  this.on( 'select', this.onSelectFade );\n  this.on( 'dragEnd', this.onDragEndFade );\n  this.on( 'settle', this.onSettleFade );\n  this.on( 'activate', this.onActivateFade );\n  this.on( 'deactivate', this.onDeactivateFade );\n};\n\nvar updateSlides = proto.updateSlides;\nproto.updateSlides = function() {\n  updateSlides.apply( this, arguments );\n  if ( !this.options.fade ) {\n    return;\n  }\n  // set initial opacity\n  this.slides.forEach( function( slide, i ) {\n    var alpha = i == this.selectedIndex ? 1 : 0;\n    slide.setOpacity( alpha );\n  }, this );\n};\n\n/* ---- events ---- */\n\nproto.onSelectFade = function() {\n  // in case of resize, keep fadeIndex within current count\n  this.fadeIndex = Math.min( this.prevSelectedIndex, this.slides.length - 1 );\n  this.prevSelectedIndex = this.selectedIndex;\n};\n\nproto.onSettleFade = function() {\n  delete this.didDragEnd;\n  if ( !this.options.fade ) {\n    return;\n  }\n  // set full and 0 opacity on selected & faded slides\n  this.selectedSlide.setOpacity( 1 );\n  var fadedSlide = this.slides[ this.fadeIndex ];\n  if ( fadedSlide && this.fadeIndex != this.selectedIndex ) {\n    this.slides[ this.fadeIndex ].setOpacity( 0 );\n  }\n};\n\nproto.onDragEndFade = function() {\n  // set flag\n  this.didDragEnd = true;\n};\n\nproto.onActivateFade = function() {\n  if ( this.options.fade ) {\n    this.element.classList.add('is-fade');\n  }\n};\n\nproto.onDeactivateFade = function() {\n  if ( !this.options.fade ) {\n    return;\n  }\n  this.element.classList.remove('is-fade');\n  // reset opacity\n  this.slides.forEach( function( slide ) {\n    slide.setOpacity('');\n  });\n};\n\n/* ---- position & fading ---- */\n\nvar positionSlider = proto.positionSlider;\nproto.positionSlider = function() {\n  if ( !this.options.fade ) {\n    positionSlider.apply( this, arguments );\n    return;\n  }\n\n  this.fadeSlides();\n  this.dispatchScrollEvent();\n};\n\nvar positionSliderAtSelected = proto.positionSliderAtSelected;\nproto.positionSliderAtSelected = function() {\n  if ( this.options.fade ) {\n    // position fade slider at origin\n    this.setTranslateX( 0 );\n  }\n  positionSliderAtSelected.apply( this, arguments );\n};\n\nproto.fadeSlides = function() {\n  if ( this.slides.length < 2 ) {\n    return;\n  }\n  // get slides to fade-in & fade-out\n  var indexes = this.getFadeIndexes();\n  var fadeSlideA = this.slides[ indexes.a ];\n  var fadeSlideB = this.slides[ indexes.b ];\n  var distance = this.wrapDifference( fadeSlideA.target, fadeSlideB.target );\n  var progress = this.wrapDifference( fadeSlideA.target, -this.x );\n  progress = progress / distance;\n\n  fadeSlideA.setOpacity( 1 - progress );\n  fadeSlideB.setOpacity( progress );\n\n  // hide previous slide\n  var fadeHideIndex = indexes.a;\n  if ( this.isDragging ) {\n    fadeHideIndex = progress > 0.5 ? indexes.a : indexes.b;\n  }\n  var isNewHideIndex = this.fadeHideIndex != undefined &&\n    this.fadeHideIndex != fadeHideIndex &&\n    this.fadeHideIndex != indexes.a &&\n    this.fadeHideIndex != indexes.b;\n  if ( isNewHideIndex ) {\n    // new fadeHideSlide set, hide previous\n    this.slides[ this.fadeHideIndex ].setOpacity( 0 );\n  }\n  this.fadeHideIndex = fadeHideIndex;\n};\n\nproto.getFadeIndexes = function() {\n  if ( !this.isDragging && !this.didDragEnd ) {\n    return {\n      a: this.fadeIndex,\n      b: this.selectedIndex,\n    };\n  }\n  if ( this.options.wrapAround ) {\n    return this.getFadeDragWrapIndexes();\n  } else {\n    return this.getFadeDragLimitIndexes();\n  }\n};\n\nproto.getFadeDragWrapIndexes = function() {\n  var distances = this.slides.map( function( slide, i ) {\n    return this.getSlideDistance( -this.x, i );\n  }, this );\n  var absDistances = distances.map( function( distance ) {\n    return Math.abs( distance );\n  });\n  var minDistance = Math.min.apply( Math, absDistances );\n  var closestIndex = absDistances.indexOf( minDistance );\n  var distance = distances[ closestIndex ];\n  var len = this.slides.length;\n\n  var delta = distance >= 0 ? 1 : -1;\n  return {\n    a: closestIndex,\n    b: utils.modulo( closestIndex + delta, len ),\n  };\n};\n\nproto.getFadeDragLimitIndexes = function() {\n  // calculate closest previous slide\n  var dragIndex = 0;\n  for ( var i=0; i < this.slides.length - 1; i++ ) {\n    var slide = this.slides[i];\n    if ( -this.x < slide.target ) {\n      break;\n    }\n    dragIndex = i;\n  }\n  return {\n    a: dragIndex,\n    b: dragIndex + 1,\n  };\n};\n\nproto.wrapDifference = function( a, b ) {\n  var diff = b - a;\n\n  if ( !this.options.wrapAround ) {\n    return diff;\n  }\n\n  var diffPlus = diff + this.slideableWidth;\n  var diffMinus = diff - this.slideableWidth;\n  if ( Math.abs( diffPlus ) < Math.abs( diff ) ) {\n    diff = diffPlus;\n  }\n  if ( Math.abs( diffMinus ) < Math.abs( diff ) ) {\n    diff = diffMinus;\n  }\n  return diff;\n};\n\n// ---- wrapAround ---- //\n\nvar _getWrapShiftCells = proto._getWrapShiftCells;\nproto._getWrapShiftCells = function() {\n  if ( !this.options.fade ) {\n    _getWrapShiftCells.apply( this, arguments );\n  }\n};\n\nvar shiftWrapCells = proto.shiftWrapCells;\nproto.shiftWrapCells = function() {\n  if ( !this.options.fade ) {\n    shiftWrapCells.apply( this, arguments );\n  }\n};\n\nreturn Flickity;\n\n}));\n","export default function listingTemplateForTooltip(listing) {\n  return `\n    <a href=\"${listing.link}\" class=\"block\" style=\"min-width: 256px;\">\n      <div class=\"flex items-center bg-paper-2 -ml-2\">\n        <div class=\"flex-no-shrink w-8 mr-3\">\n          <div class=\"aspect-ratio-1x1\">\n            <img\n              alt=\"${listing.name} - ${listing.product_type_name}\"\n              src=\"${listing.imageUrl}\"\n              class=\"block h-full w-full object-contain img-responsive\">\n          </div>\n        </div>\n        <div class=\"ellipsis text-left\">\n          <h4 class=\"product-name typeset-6 ellipsis mb-1\">${listing.name}</h4>\n          <h5 class=\"product-type-name typeset-7 ellipsis\">${listing.product_type_name}</h5>\n        </div>\n      </div>\n    </a>\n  `;\n}\n"],"names":["window","factory","module","require$$0","require$$1","this","Flickity","utils","Slide","slideUpdateTarget","slideTargetX","firstCellX","cell","targetX","alpha","proto","updateSlides","slide","i","fadedSlide","positionSlider","positionSliderAtSelected","indexes","fadeSlideA","fadeSlideB","distance","progress","fadeHideIndex","isNewHideIndex","distances","absDistances","minDistance","closestIndex","len","delta","dragIndex","a","b","diff","diffPlus","diffMinus","_getWrapShiftCells","shiftWrapCells","listingTemplateForTooltip","listing"],"mappings":"4KAOE,SAAUA,EAAQC,EAAU,CASaC,EA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