!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports,require("jquery")):"function"==typeof define&&define.amd?define(["exports","jquery"],o):o((t="undefined"!=typeof globalThis?globalThis:t||self).jQueryPin={},t.$)}(this,(function(t,o){"use strict";var e=function(t){void 0===t&&(t={});var e=o(window),i=[],s=0,n=!1,a=function(){var s=e.width()||0;i.forEach((function(e){if(t.minWidth&&s<=t.minWidth)return e.parent().is(".pin-wrapper")&&e.unwrap(),e.css({width:"",left:"",top:"",position:""}),t.activeClass&&e.removeClass(t.activeClass),void(n=!0);n=!1;var i=t.containerSelector?e.closest(t.containerSelector):o(document.body),a={left:0,top:0},p=e.offset()||a,r=i.offset()||a,d=e.offsetParent().offset()||a;e.parent().is(".pin-wrapper")||e.wrap('
');var f=o.extend({top:0,bottom:0},t.padding||{}),c=i.height()||0,l=e.outerHeight()||0,u=e.outerWidth()||0;e.data("pin",{pad:f,from:(t.containerSelector?r.top:p.top)-f.top,to:r.top+c-l-f.bottom,end:r.top+c,parentTop:d.top}),e.css({width:u}),e.parent().css("height",l)}))},p=function(){n||(s=e.scrollTop()||0,i=i.filter((function(t){return!!o(t).data("pin")})).map((function(e){var i,n=o(e),a=n.data("pin"),p=a.from-a.pad.bottom,r=a.to-a.pad.top;return p+(n.outerHeight()||0)>a.end?(n.css("position",""),n):(ps?("fixed"!==n.css("position")&&n.css({left:(null===(i=n.offset())||void 0===i?void 0:i.left)||0,top:a.pad.top}).css("position","fixed"),t.activeClass&&n.addClass(t.activeClass)):s>=r?(n.css({left:"",top:r-a.parentTop+a.pad.top}).css("position","absolute"),t.activeClass&&n.addClass(t.activeClass)):(n.css({position:"",top:"",left:""}),t.activeClass&&n.removeClass(t.activeClass)),n)})))},r=function(){a(),p()};return this.each((function(){var t=o(this),e=o(this).data("pin")||{};e&&e.update||(i.push(t),o("img",this).one("load",a),e.update=r,o(this).data("pin",e))})),e.on("scroll",p),e.on("resize",a),a(),e.on("load",r),this};o.fn.pin=e,t.pin=e}));