1/// <reference path="../../../../../../../../global.d.ts" /> 2/// <reference path="../../../../../../../../iu.d.ts" /> 3function _assert_this_initialized(self) { 4 if (self === void 0) { 5 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 6 } 7 return self; 8} 9function _class_call_check(instance, Constructor) { 10 if (!(instance instanceof Constructor)) { 11 throw new TypeError("Cannot call a class as a function"); 12 } 13} 14function _defineProperties(target, props) { 15 for(var i = 0; i < props.length; i++){ 16 var descriptor = props[i]; 17 descriptor.enumerable = descriptor.enumerable || false; 18 descriptor.configurable = true; 19 if ("value" in descriptor) descriptor.writable = true; 20 Object.defineProperty(target, descriptor.key, descriptor); 21 } 22} 23function _create_class(Constructor, protoProps, staticProps) { 24 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 25 if (staticProps) _defineProperties(Constructor, staticProps); 26 return Constructor; 27} 28function _define_property(obj, key, value) { 29 if (key in obj) { 30 Object.defineProperty(obj, key, { 31 value: value, 32 enumerable: true, 33 configurable: true, 34 writable: true 35 }); 36 } else { 37 obj[key] = value; 38 } 39 return obj; 40} 41function _get_prototype_of(o) { 42 _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) { 43 return o.__proto__ || Object.getPrototypeOf(o); 44 }; 45 return _get_prototype_of(o); 46} 47function _inherits(subClass, superClass) { 48 if (typeof superClass !== "function" && superClass !== null) { 49 throw new TypeError("Super expression must either be null or a function"); 50 } 51 subClass.prototype = Object.create(superClass && superClass.prototype, { 52 constructor: { 53 value: subClass, 54 writable: true, 55 configurable: true 56 } 57 }); 58 if (superClass) _set_prototype_of(subClass, superClass); 59} 60function _instanceof(left, right) { 61 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { 62 return !!right[Symbol.hasInstance](left); 63 } else { 64 return left instanceof right; 65 } 66} 67function _possible_constructor_return(self, call) { 68 if (call && (_type_of(call) === "object" || typeof call === "function")) { 69 return call; 70 } 71 return _assert_this_initialized(self); 72} 73function _set_prototype_of(o, p) { 74 _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) { 75 o.__proto__ = p; 76 return o; 77 }; 78 return _set_prototype_of(o, p); 79} 80function _type_of(obj) { 81 "@swc/helpers - typeof"; 82 return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; 83} 84function _is_native_reflect_construct() { 85 if (typeof Reflect === "undefined" || !Reflect.construct) return false; 86 if (Reflect.construct.sham) return false; 87 if (typeof Proxy === "function") return true; 88 try { 89 Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})); 90 return true; 91 } catch (e) { 92 return false; 93 } 94} 95function _create_super(Derived) { 96 var hasNativeReflectConstruct = _is_native_reflect_construct(); 97 return function _createSuperInternal() { 98 var Super = _get_prototype_of(Derived), result; 99 if (hasNativeReflectConstruct) { 100 var NewTarget = _get_prototype_of(this).constructor; 101 result = Reflect.construct(Super, arguments, NewTarget); 102 } else { 103 result = Super.apply(this, arguments); 104 } 105 return _possible_constructor_return(this, result); 106 }; 107} 108import { Controller } from "@hotwired/stimulus"; 109var SCROLL_STEP_ITEMS = 2; 110var AiBannerController = /*#__PURE__*/ function(Controller) { 111 "use strict"; 112 _inherits(AiBannerController, Controller); 113 var _super = _create_super(AiBannerController); 114 function AiBannerController() { 115 _class_call_check(this, AiBannerController); 116 var _this; 117 _this = _super.apply(this, arguments); 118 _define_property(_assert_this_initialized(_this), "updateScrollButtons", function() { 119 var maxScrollLeft = _this.getMaxScrollLeft(); 120 var canScroll = maxScrollLeft > 1; 121 var currentScrollLeft = _this.toolsTarget.scrollLeft; 122 _this.prevButtonTarget.hidden = !canScroll || currentScrollLeft <= 1; 123 _this.nextButtonTarget.hidden = !canScroll || currentScrollLeft >= maxScrollLeft - 1; 124 }); 125 _define_property(_assert_this_initialized(_this), "onSubmit", function(event) { 126 var form = event.target; 127 if (!_instanceof(form, HTMLFormElement) || !form.classList.contains("ai-chat-input__card")) { 128 return; 129 } 130 form.target = "_blank"; 131 form.setAttribute("data-turbo", "false"); 132 }); 133 return _this; 134 } 135 _create_class(AiBannerController, [ 136 { 137 key: "connect", 138 value: function connect() { 139 this.updateScrollButtons(); 140 window.addEventListener("resize", this.updateScrollButtons); 141 this.element.addEventListener("submit", this.onSubmit, true); 142 } 143 }, 144 { 145 key: "disconnect", 146 value: function disconnect() { 147 window.removeEventListener("resize", this.updateScrollButtons); 148 this.element.removeEventListener("submit", this.onSubmit, true); 149 } 150 }, 151 { 152 key: "scrollPrev", 153 value: function scrollPrev() { 154 this.scrollTools(-1); 155 } 156 }, 157 { 158 key: "scrollNext", 159 value: function scrollNext() { 160 this.scrollTools(1); 161 } 162 }, 163 { 164 key: "scrollTools", 165 value: function scrollTools(direction) { 166 this.toolsTarget.scrollTo({ 167 left: this.getTargetScrollLeft(direction), 168 behavior: "smooth" 169 }); 170 } 171 }, 172 { 173 key: "getTargetScrollLeft", 174 value: function getTargetScrollLeft(direction) { 175 var currentScrollLeft = this.toolsTarget.scrollLeft; 176 var maxScrollLeft = this.getMaxScrollLeft(); 177 var scrollPositions = direction === 1 ? this.get
177ScrollPositions() : this.getScrollPositions().reverse(); 178 var targetPositionIndex = scrollPositions.findIndex(function(scrollLeft) { 179 return direction === 1 ? scrollLeft > currentScrollLeft + 1 : scrollLeft < currentScrollLeft - 1; 180 }); 181 var fallbackScrollLeft = direction === 1 ? maxScrollLeft : 0; 182 if (targetPositionIndex === -1) { 183 return fallbackScrollLeft; 184 } 185 var _scrollPositions_; 186 return (_scrollPositions_ = scrollPositions[targetPositionIndex + SCROLL_STEP_ITEMS - 1]) !== null && _scrollPositions_ !== void 0 ? _scrollPositions_ : fallbackScrollLeft; 187 } 188 }, 189 { 190 key: "getScrollPositions", 191 value: function getScrollPositions() { 192 var maxScrollLeft = this.getMaxScrollLeft(); 193 return Array.from(this.toolsTarget.children).filter(function(tool) { 194 return _instanceof(tool, HTMLElement); 195 }).map(function(tool) { 196 return Math.min(tool.offsetLeft, maxScrollLeft); 197 }).filter(function(scrollLeft, index, positions) { 198 return index === 0 || Math.abs(scrollLeft - positions[index - 1]) > 1; 199 }); 200 } 201 }, 202 { 203 key: "getMaxScrollLeft", 204 value: function getMaxScrollLeft() { 205 return this.toolsTarget.scrollWidth - this.toolsTarget.clientWidth; 206 } 207 } 208 ]); 209 return AiBannerController; 210}(Controller); 211_define_property(AiBannerController, "targets", [ 212 "tools", 213 "prevButton", 214 "nextButton" 215]); 216/* stimulusFetch: 'lazy' */ export { AiBannerController as default };
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.