| 1 |
/******/ (function() { // webpackBootstrap |
| 2 |
/******/ "use strict"; |
| 3 |
/******/ var __webpack_modules__ = ({ |
| 4 |
|
| 5 |
/***/ "./packages/packages/libs/utils/src/debounce.ts": |
| 6 |
/*!******************************************************!*\ |
| 7 |
!*** ./packages/packages/libs/utils/src/debounce.ts ***! |
| 8 |
\******************************************************/ |
| 9 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 10 |
|
| 11 |
__webpack_require__.r(__webpack_exports__); |
| 12 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 13 |
/* harmony export */ debounce: function() { return /* binding */ debounce; } |
| 14 |
/* harmony export */ }); |
| 15 |
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 16 |
function debounce(fn, wait) { |
| 17 |
let timer = null; |
| 18 |
const cancel = () => { |
| 19 |
if (!timer) { |
| 20 |
return; |
| 21 |
} |
| 22 |
clearTimeout(timer); |
| 23 |
timer = null; |
| 24 |
}; |
| 25 |
const flush = (...args) => { |
| 26 |
cancel(); |
| 27 |
fn(...args); |
| 28 |
}; |
| 29 |
const run = (...args) => { |
| 30 |
cancel(); |
| 31 |
timer = setTimeout(() => { |
| 32 |
fn(...args); |
| 33 |
timer = null; |
| 34 |
}, wait); |
| 35 |
}; |
| 36 |
const pending = () => !!timer; |
| 37 |
run.flush = flush; |
| 38 |
run.cancel = cancel; |
| 39 |
run.pending = pending; |
| 40 |
return run; |
| 41 |
} |
| 42 |
|
| 43 |
/***/ }), |
| 44 |
|
| 45 |
/***/ "./packages/packages/libs/utils/src/encoding.ts": |
| 46 |
/*!******************************************************!*\ |
| 47 |
!*** ./packages/packages/libs/utils/src/encoding.ts ***! |
| 48 |
\******************************************************/ |
| 49 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 50 |
|
| 51 |
__webpack_require__.r(__webpack_exports__); |
| 52 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 53 |
/* harmony export */ decodeString: function() { return /* binding */ decodeString; }, |
| 54 |
/* harmony export */ encodeString: function() { return /* binding */ encodeString; } |
| 55 |
/* harmony export */ }); |
| 56 |
const encodeString = value => { |
| 57 |
const binary = Array.from(new TextEncoder().encode(value), b => String.fromCharCode(b)).join(''); |
| 58 |
return btoa(binary); |
| 59 |
}; |
| 60 |
const decodeString = (value, fallback) => { |
| 61 |
try { |
| 62 |
const binary = atob(value); |
| 63 |
const bytes = new Uint8Array(Array.from(binary, char => char.charCodeAt(0))); |
| 64 |
return new TextDecoder().decode(bytes); |
| 65 |
} catch { |
| 66 |
return fallback !== undefined ? fallback : ''; |
| 67 |
} |
| 68 |
}; |
| 69 |
|
| 70 |
/***/ }), |
| 71 |
|
| 72 |
/***/ "./packages/packages/libs/utils/src/errors/create-error.ts": |
| 73 |
/*!*****************************************************************!*\ |
| 74 |
!*** ./packages/packages/libs/utils/src/errors/create-error.ts ***! |
| 75 |
\*****************************************************************/ |
| 76 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 77 |
|
| 78 |
__webpack_require__.r(__webpack_exports__); |
| 79 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 80 |
/* harmony export */ createError: function() { return /* binding */ createError; } |
| 81 |
/* harmony export */ }); |
| 82 |
/* harmony import */ var _elementor_error__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./elementor-error */ "./packages/packages/libs/utils/src/errors/elementor-error.ts"); |
| 83 |
|
| 84 |
const createError = ({ |
| 85 |
code, |
| 86 |
message |
| 87 |
}) => { |
| 88 |
return class extends _elementor_error__WEBPACK_IMPORTED_MODULE_0__.ElementorError { |
| 89 |
constructor({ |
| 90 |
cause, |
| 91 |
context |
| 92 |
} = {}) { |
| 93 |
super(message, { |
| 94 |
cause, |
| 95 |
code, |
| 96 |
context |
| 97 |
}); |
| 98 |
} |
| 99 |
}; |
| 100 |
}; |
| 101 |
|
| 102 |
/***/ }), |
| 103 |
|
| 104 |
/***/ "./packages/packages/libs/utils/src/errors/elementor-error.ts": |
| 105 |
/*!********************************************************************!*\ |
| 106 |
!*** ./packages/packages/libs/utils/src/errors/elementor-error.ts ***! |
| 107 |
\********************************************************************/ |
| 108 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 109 |
|
| 110 |
__webpack_require__.r(__webpack_exports__); |
| 111 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 112 |
/* harmony export */ ElementorError: function() { return /* binding */ ElementorError; } |
| 113 |
/* harmony export */ }); |
| 114 |
class ElementorError extends Error { |
| 115 |
constructor(message, { |
| 116 |
code, |
| 117 |
context = null, |
| 118 |
cause = null |
| 119 |
}) { |
| 120 |
super(message, { |
| 121 |
cause |
| 122 |
}); |
| 123 |
this.context = context; |
| 124 |
this.code = code; |
| 125 |
} |
| 126 |
} |
| 127 |
|
| 128 |
/***/ }), |
| 129 |
|
| 130 |
/***/ "./packages/packages/libs/utils/src/errors/ensure-error.ts": |
| 131 |
/*!*****************************************************************!*\ |
| 132 |
!*** ./packages/packages/libs/utils/src/errors/ensure-error.ts ***! |
| 133 |
\*****************************************************************/ |
| 134 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 135 |
|
| 136 |
__webpack_require__.r(__webpack_exports__); |
| 137 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 138 |
/* harmony export */ ensureError: function() { return /* binding */ ensureError; } |
| 139 |
/* harmony export */ }); |
| 140 |
const ensureError = error => { |
| 141 |
if (error instanceof Error) { |
| 142 |
return error; |
| 143 |
} |
| 144 |
let message; |
| 145 |
let cause = null; |
| 146 |
try { |
| 147 |
message = JSON.stringify(error); |
| 148 |
} catch (e) { |
| 149 |
cause = e; |
| 150 |
message = 'Unable to stringify the thrown value'; |
| 151 |
} |
| 152 |
return new Error(`Unexpected non-error thrown: ${message}`, { |
| 153 |
cause |
| 154 |
}); |
| 155 |
}; |
| 156 |
|
| 157 |
/***/ }), |
| 158 |
|
| 159 |
/***/ "./packages/packages/libs/utils/src/errors/index.ts": |
| 160 |
/*!**********************************************************!*\ |
| 161 |
!*** ./packages/packages/libs/utils/src/errors/index.ts ***! |
| 162 |
\**********************************************************/ |
| 163 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 164 |
|
| 165 |
__webpack_require__.r(__webpack_exports__); |
| 166 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 167 |
/* harmony export */ ElementorError: function() { return /* reexport safe */ _elementor_error__WEBPACK_IMPORTED_MODULE_0__.ElementorError; }, |
| 168 |
/* harmony export */ createError: function() { return /* reexport safe */ _create_error__WEBPACK_IMPORTED_MODULE_1__.createError; }, |
| 169 |
/* harmony export */ ensureError: function() { return /* reexport safe */ _ensure_error__WEBPACK_IMPORTED_MODULE_2__.ensureError; } |
| 170 |
/* harmony export */ }); |
| 171 |
/* harmony import */ var _elementor_error__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./elementor-error */ "./packages/packages/libs/utils/src/errors/elementor-error.ts"); |
| 172 |
/* harmony import */ var _create_error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./create-error */ "./packages/packages/libs/utils/src/errors/create-error.ts"); |
| 173 |
/* harmony import */ var _ensure_error__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ensure-error */ "./packages/packages/libs/utils/src/errors/ensure-error.ts"); |
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
/***/ }), |
| 179 |
|
| 180 |
/***/ "./packages/packages/libs/utils/src/generate-unique-id.ts": |
| 181 |
/*!****************************************************************!*\ |
| 182 |
!*** ./packages/packages/libs/utils/src/generate-unique-id.ts ***! |
| 183 |
\****************************************************************/ |
| 184 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 185 |
|
| 186 |
__webpack_require__.r(__webpack_exports__); |
| 187 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 188 |
/* harmony export */ generateUniqueId: function() { return /* binding */ generateUniqueId; } |
| 189 |
/* harmony export */ }); |
| 190 |
function generateUniqueId(prefix = '') { |
| 191 |
const prefixStr = prefix ? `${prefix}-` : ''; |
| 192 |
return `${prefixStr}${Date.now()}-${Math.random().toString(36).substring(2, 9)}`; |
| 193 |
} |
| 194 |
|
| 195 |
/***/ }), |
| 196 |
|
| 197 |
/***/ "./packages/packages/libs/utils/src/hash.ts": |
| 198 |
/*!**************************************************!*\ |
| 199 |
!*** ./packages/packages/libs/utils/src/hash.ts ***! |
| 200 |
\**************************************************/ |
| 201 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 202 |
|
| 203 |
__webpack_require__.r(__webpack_exports__); |
| 204 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 205 |
/* harmony export */ hash: function() { return /* binding */ hash; }, |
| 206 |
/* harmony export */ hashString: function() { return /* binding */ hashString; } |
| 207 |
/* harmony export */ }); |
| 208 |
/* eslint-disable no-bitwise */ |
| 209 |
|
| 210 |
// Inspired by: |
| 211 |
// https://github.com/TanStack/query/blob/66ea5f2fc/packages/query-core/src/utils.ts#L212 |
| 212 |
function hash(obj) { |
| 213 |
return JSON.stringify(obj, (_, value) => isPlainObject(value) ? Object.keys(value).sort().reduce((result, key) => { |
| 214 |
result[key] = value[key]; |
| 215 |
return result; |
| 216 |
}, {}) : value); |
| 217 |
} |
| 218 |
function isPlainObject(value) { |
| 219 |
return !!value && typeof value === 'object' && !Array.isArray(value); |
| 220 |
} |
| 221 |
|
| 222 |
// Inspired by: |
| 223 |
// https://github.com/darkskyapp/string-hash/blob/master/index.js |
| 224 |
function hashString(str, length) { |
| 225 |
let hashBasis = 5381; |
| 226 |
let i = str.length; |
| 227 |
while (i) { |
| 228 |
hashBasis = hashBasis * 33 ^ str.charCodeAt(--i); |
| 229 |
} |
| 230 |
|
| 231 |
/* JavaScript does bitwise operations (like XOR, above) on 32-bit signed |
| 232 |
* integers. Since we want the results to be always positive, convert the |
| 233 |
* signed int to an unsigned by doing an unsigned bitshift. */ |
| 234 |
const result = (hashBasis >>> 0).toString(36); |
| 235 |
if (length === undefined) { |
| 236 |
return result; |
| 237 |
} |
| 238 |
const sliced = result.slice(-length); |
| 239 |
return sliced.padStart(length, '0'); |
| 240 |
} |
| 241 |
|
| 242 |
/***/ }), |
| 243 |
|
| 244 |
/***/ "./packages/packages/libs/utils/src/is-pro.ts": |
| 245 |
/*!****************************************************!*\ |
| 246 |
!*** ./packages/packages/libs/utils/src/is-pro.ts ***! |
| 247 |
\****************************************************/ |
| 248 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 249 |
|
| 250 |
__webpack_require__.r(__webpack_exports__); |
| 251 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 252 |
/* harmony export */ hasProInstalled: function() { return /* binding */ hasProInstalled; }, |
| 253 |
/* harmony export */ isProActive: function() { return /* binding */ isProActive; }, |
| 254 |
/* harmony export */ isProAtLeast: function() { return /* binding */ isProAtLeast; } |
| 255 |
/* harmony export */ }); |
| 256 |
function hasProInstalled() { |
| 257 |
return window.elementor?.helpers?.hasPro?.() ?? false; |
| 258 |
} |
| 259 |
function isProActive() { |
| 260 |
if (!hasProInstalled()) { |
| 261 |
return false; |
| 262 |
} |
| 263 |
return window.elementorPro?.config?.isActive ?? false; |
| 264 |
} |
| 265 |
function getProVersion() { |
| 266 |
return window.elementorPro?.config?.version ?? '0.0'; |
| 267 |
} |
| 268 |
function isProAtLeast(targetVersion) { |
| 269 |
const version = getProVersion(); |
| 270 |
if (!version) { |
| 271 |
return false; |
| 272 |
} |
| 273 |
const [major, minor] = version.split('.').map(Number); |
| 274 |
const [targetMajor, targetMinor] = targetVersion.split('.').map(Number); |
| 275 |
return major > targetMajor || major === targetMajor && minor >= targetMinor; |
| 276 |
} |
| 277 |
|
| 278 |
/***/ }), |
| 279 |
|
| 280 |
/***/ "./packages/packages/libs/utils/src/string-helpers.ts": |
| 281 |
/*!************************************************************!*\ |
| 282 |
!*** ./packages/packages/libs/utils/src/string-helpers.ts ***! |
| 283 |
\************************************************************/ |
| 284 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 285 |
|
| 286 |
__webpack_require__.r(__webpack_exports__); |
| 287 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 288 |
/* harmony export */ capitalize: function() { return /* binding */ capitalize; } |
| 289 |
/* harmony export */ }); |
| 290 |
const capitalize = str => { |
| 291 |
return str.charAt(0).toUpperCase() + str.slice(1); |
| 292 |
}; |
| 293 |
|
| 294 |
/***/ }), |
| 295 |
|
| 296 |
/***/ "./packages/packages/libs/utils/src/throttle.ts": |
| 297 |
/*!******************************************************!*\ |
| 298 |
!*** ./packages/packages/libs/utils/src/throttle.ts ***! |
| 299 |
\******************************************************/ |
| 300 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 301 |
|
| 302 |
__webpack_require__.r(__webpack_exports__); |
| 303 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 304 |
/* harmony export */ throttle: function() { return /* binding */ throttle; } |
| 305 |
/* harmony export */ }); |
| 306 |
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 307 |
function throttle(fn, wait, shouldExecuteIgnoredCalls = false) { |
| 308 |
let timer = null; |
| 309 |
let ignoredExecution = false; |
| 310 |
const cancel = () => { |
| 311 |
if (!timer) { |
| 312 |
return; |
| 313 |
} |
| 314 |
clearTimeout(timer); |
| 315 |
timer = null; |
| 316 |
}; |
| 317 |
const flush = (...args) => { |
| 318 |
cancel(); |
| 319 |
fn(...args); |
| 320 |
}; |
| 321 |
const run = (...args) => { |
| 322 |
if (timer) { |
| 323 |
ignoredExecution = true; |
| 324 |
return; |
| 325 |
} |
| 326 |
fn(...args); |
| 327 |
timer = setTimeout(() => { |
| 328 |
timer = null; |
| 329 |
if (ignoredExecution && shouldExecuteIgnoredCalls) { |
| 330 |
fn(...args); |
| 331 |
} |
| 332 |
ignoredExecution = false; |
| 333 |
}, wait); |
| 334 |
}; |
| 335 |
const pending = () => !!timer; |
| 336 |
run.flush = flush; |
| 337 |
run.cancel = cancel; |
| 338 |
run.pending = pending; |
| 339 |
return run; |
| 340 |
} |
| 341 |
|
| 342 |
/***/ }), |
| 343 |
|
| 344 |
/***/ "./packages/packages/libs/utils/src/translations.ts": |
| 345 |
/*!**********************************************************!*\ |
| 346 |
!*** ./packages/packages/libs/utils/src/translations.ts ***! |
| 347 |
\**********************************************************/ |
| 348 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 349 |
|
| 350 |
__webpack_require__.r(__webpack_exports__); |
| 351 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 352 |
/* harmony export */ createTranslate: function() { return /* binding */ createTranslate; } |
| 353 |
/* harmony export */ }); |
| 354 |
function createTranslate({ |
| 355 |
configKey, |
| 356 |
defaultStrings = {} |
| 357 |
}) { |
| 358 |
return (key, ...args) => { |
| 359 |
const appConfig = window.elementorAppConfig; |
| 360 |
const remoteStrings = appConfig?.[configKey]?.translations; |
| 361 |
const strings = { |
| 362 |
...defaultStrings, |
| 363 |
...remoteStrings |
| 364 |
}; |
| 365 |
let template = strings[key]; |
| 366 |
if (!template) { |
| 367 |
return key; |
| 368 |
} |
| 369 |
for (let i = 0; i < args.length; i++) { |
| 370 |
template = template.replace(`%${i + 1}$s`, args[i]); |
| 371 |
template = template.replace('%s', args[i]); |
| 372 |
} |
| 373 |
return template; |
| 374 |
}; |
| 375 |
} |
| 376 |
|
| 377 |
/***/ }), |
| 378 |
|
| 379 |
/***/ "./packages/packages/libs/utils/src/use-debounce-state.ts": |
| 380 |
/*!****************************************************************!*\ |
| 381 |
!*** ./packages/packages/libs/utils/src/use-debounce-state.ts ***! |
| 382 |
\****************************************************************/ |
| 383 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 384 |
|
| 385 |
__webpack_require__.r(__webpack_exports__); |
| 386 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 387 |
/* harmony export */ useDebounceState: function() { return /* binding */ useDebounceState; } |
| 388 |
/* harmony export */ }); |
| 389 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 390 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); |
| 391 |
/* harmony import */ var _debounce__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./debounce */ "./packages/packages/libs/utils/src/debounce.ts"); |
| 392 |
|
| 393 |
|
| 394 |
function useDebounceState(options = {}) { |
| 395 |
const { |
| 396 |
delay = 300, |
| 397 |
initialValue = '' |
| 398 |
} = options; |
| 399 |
const [debouncedValue, setDebouncedValue] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(initialValue); |
| 400 |
const [inputValue, setInputValue] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(initialValue); |
| 401 |
const runRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null); |
| 402 |
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { |
| 403 |
return () => { |
| 404 |
runRef.current?.cancel?.(); |
| 405 |
}; |
| 406 |
}, []); |
| 407 |
const debouncedSetValue = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(val => { |
| 408 |
runRef.current?.cancel?.(); |
| 409 |
runRef.current = (0,_debounce__WEBPACK_IMPORTED_MODULE_1__.debounce)(() => { |
| 410 |
setDebouncedValue(val); |
| 411 |
}, delay); |
| 412 |
runRef.current(); |
| 413 |
}, [delay]); |
| 414 |
const handleChange = val => { |
| 415 |
setInputValue(val); |
| 416 |
debouncedSetValue(val); |
| 417 |
}; |
| 418 |
return { |
| 419 |
debouncedValue, |
| 420 |
inputValue, |
| 421 |
handleChange, |
| 422 |
setInputValue |
| 423 |
}; |
| 424 |
} |
| 425 |
|
| 426 |
/***/ }), |
| 427 |
|
| 428 |
/***/ "./packages/packages/libs/utils/src/use-debounced-callback.ts": |
| 429 |
/*!********************************************************************!*\ |
| 430 |
!*** ./packages/packages/libs/utils/src/use-debounced-callback.ts ***! |
| 431 |
\********************************************************************/ |
| 432 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 433 |
|
| 434 |
__webpack_require__.r(__webpack_exports__); |
| 435 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 436 |
/* harmony export */ useDebouncedCallback: function() { return /* binding */ useDebouncedCallback; } |
| 437 |
/* harmony export */ }); |
| 438 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 439 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); |
| 440 |
/* harmony import */ var _debounce__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./debounce */ "./packages/packages/libs/utils/src/debounce.ts"); |
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 445 |
function useDebouncedCallback(callback, delay) { |
| 446 |
const callbackRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(callback); |
| 447 |
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { |
| 448 |
callbackRef.current = callback; |
| 449 |
}, [callback]); |
| 450 |
const debounced = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => (0,_debounce__WEBPACK_IMPORTED_MODULE_1__.debounce)((...args) => callbackRef.current(...args), delay), [delay]); |
| 451 |
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { |
| 452 |
return () => { |
| 453 |
debounced.cancel(); |
| 454 |
}; |
| 455 |
}, [debounced]); |
| 456 |
return debounced; |
| 457 |
} |
| 458 |
|
| 459 |
/***/ }), |
| 460 |
|
| 461 |
/***/ "./packages/packages/libs/utils/src/use-search-state.ts": |
| 462 |
/*!**************************************************************!*\ |
| 463 |
!*** ./packages/packages/libs/utils/src/use-search-state.ts ***! |
| 464 |
\**************************************************************/ |
| 465 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 466 |
|
| 467 |
__webpack_require__.r(__webpack_exports__); |
| 468 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 469 |
/* harmony export */ useSearchState: function() { return /* binding */ useSearchState; } |
| 470 |
/* harmony export */ }); |
| 471 |
/* harmony import */ var _use_debounce_state__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./use-debounce-state */ "./packages/packages/libs/utils/src/use-debounce-state.ts"); |
| 472 |
|
| 473 |
function useSearchState({ |
| 474 |
localStorageKey |
| 475 |
}) { |
| 476 |
const getInitialSearchValue = () => { |
| 477 |
if (localStorageKey) { |
| 478 |
const storedValue = localStorage.getItem(localStorageKey); |
| 479 |
if (storedValue) { |
| 480 |
localStorage.removeItem(localStorageKey); |
| 481 |
return storedValue; |
| 482 |
} |
| 483 |
} |
| 484 |
return ''; |
| 485 |
}; |
| 486 |
const { |
| 487 |
debouncedValue, |
| 488 |
inputValue, |
| 489 |
handleChange |
| 490 |
} = (0,_use_debounce_state__WEBPACK_IMPORTED_MODULE_0__.useDebounceState)({ |
| 491 |
delay: 300, |
| 492 |
initialValue: getInitialSearchValue() |
| 493 |
}); |
| 494 |
return { |
| 495 |
debouncedValue, |
| 496 |
inputValue, |
| 497 |
handleChange |
| 498 |
}; |
| 499 |
} |
| 500 |
|
| 501 |
/***/ }), |
| 502 |
|
| 503 |
/***/ "./packages/packages/libs/utils/src/version.ts": |
| 504 |
/*!*****************************************************!*\ |
| 505 |
!*** ./packages/packages/libs/utils/src/version.ts ***! |
| 506 |
\*****************************************************/ |
| 507 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 508 |
|
| 509 |
__webpack_require__.r(__webpack_exports__); |
| 510 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 511 |
/* harmony export */ compareVersions: function() { return /* binding */ compareVersions; }, |
| 512 |
/* harmony export */ isVersionGreaterOrEqual: function() { return /* binding */ isVersionGreaterOrEqual; }, |
| 513 |
/* harmony export */ isVersionLessThan: function() { return /* binding */ isVersionLessThan; } |
| 514 |
/* harmony export */ }); |
| 515 |
const compareVersions = (a, b) => { |
| 516 |
const aParts = String(a || '0.0.0').split('.').map(Number); |
| 517 |
const bParts = String(b || '0.0.0').split('.').map(Number); |
| 518 |
for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) { |
| 519 |
const aVal = aParts[i] || 0; |
| 520 |
const bVal = bParts[i] || 0; |
| 521 |
if (aVal !== bVal) { |
| 522 |
return aVal - bVal; |
| 523 |
} |
| 524 |
} |
| 525 |
return 0; |
| 526 |
}; |
| 527 |
const isVersionLessThan = (a, b) => { |
| 528 |
return compareVersions(a, b) < 0; |
| 529 |
}; |
| 530 |
const isVersionGreaterOrEqual = (a, b) => { |
| 531 |
return compareVersions(a, b) >= 0; |
| 532 |
}; |
| 533 |
|
| 534 |
/***/ }), |
| 535 |
|
| 536 |
/***/ "react": |
| 537 |
/*!**************************!*\ |
| 538 |
!*** external ["React"] ***! |
| 539 |
\**************************/ |
| 540 |
/***/ (function(module) { |
| 541 |
|
| 542 |
module.exports = window["React"]; |
| 543 |
|
| 544 |
/***/ }) |
| 545 |
|
| 546 |
/******/ }); |
| 547 |
/************************************************************************/ |
| 548 |
/******/ // The module cache |
| 549 |
/******/ var __webpack_module_cache__ = {}; |
| 550 |
/******/ |
| 551 |
/******/ // The require function |
| 552 |
/******/ function __webpack_require__(moduleId) { |
| 553 |
/******/ // Check if module is in cache |
| 554 |
/******/ var cachedModule = __webpack_module_cache__[moduleId]; |
| 555 |
/******/ if (cachedModule !== undefined) { |
| 556 |
/******/ return cachedModule.exports; |
| 557 |
/******/ } |
| 558 |
/******/ // Create a new module (and put it into the cache) |
| 559 |
/******/ var module = __webpack_module_cache__[moduleId] = { |
| 560 |
/******/ // no module.id needed |
| 561 |
/******/ // no module.loaded needed |
| 562 |
/******/ exports: {} |
| 563 |
/******/ }; |
| 564 |
/******/ |
| 565 |
/******/ // Execute the module function |
| 566 |
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); |
| 567 |
/******/ |
| 568 |
/******/ // Return the exports of the module |
| 569 |
/******/ return module.exports; |
| 570 |
/******/ } |
| 571 |
/******/ |
| 572 |
/************************************************************************/ |
| 573 |
/******/ /* webpack/runtime/compat get default export */ |
| 574 |
/******/ !function() { |
| 575 |
/******/ // getDefaultExport function for compatibility with non-harmony modules |
| 576 |
/******/ __webpack_require__.n = function(module) { |
| 577 |
/******/ var getter = module && module.__esModule ? |
| 578 |
/******/ function() { return module['default']; } : |
| 579 |
/******/ function() { return module; }; |
| 580 |
/******/ __webpack_require__.d(getter, { a: getter }); |
| 581 |
/******/ return getter; |
| 582 |
/******/ }; |
| 583 |
/******/ }(); |
| 584 |
/******/ |
| 585 |
/******/ /* webpack/runtime/define property getters */ |
| 586 |
/******/ !function() { |
| 587 |
/******/ // define getter functions for harmony exports |
| 588 |
/******/ __webpack_require__.d = function(exports, definition) { |
| 589 |
/******/ for(var key in definition) { |
| 590 |
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
| 591 |
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
| 592 |
/******/ } |
| 593 |
/******/ } |
| 594 |
/******/ }; |
| 595 |
/******/ }(); |
| 596 |
/******/ |
| 597 |
/******/ /* webpack/runtime/hasOwnProperty shorthand */ |
| 598 |
/******/ !function() { |
| 599 |
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
| 600 |
/******/ }(); |
| 601 |
/******/ |
| 602 |
/******/ /* webpack/runtime/make namespace object */ |
| 603 |
/******/ !function() { |
| 604 |
/******/ // define __esModule on exports |
| 605 |
/******/ __webpack_require__.r = function(exports) { |
| 606 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
| 607 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
| 608 |
/******/ } |
| 609 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
| 610 |
/******/ }; |
| 611 |
/******/ }(); |
| 612 |
/******/ |
| 613 |
/************************************************************************/ |
| 614 |
var __webpack_exports__ = {}; |
| 615 |
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk. |
| 616 |
!function() { |
| 617 |
/*!***************************************************!*\ |
| 618 |
!*** ./packages/packages/libs/utils/src/index.ts ***! |
| 619 |
\***************************************************/ |
| 620 |
__webpack_require__.r(__webpack_exports__); |
| 621 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 622 |
/* harmony export */ ElementorError: function() { return /* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_0__.ElementorError; }, |
| 623 |
/* harmony export */ capitalize: function() { return /* reexport safe */ _string_helpers__WEBPACK_IMPORTED_MODULE_9__.capitalize; }, |
| 624 |
/* harmony export */ compareVersions: function() { return /* reexport safe */ _version__WEBPACK_IMPORTED_MODULE_10__.compareVersions; }, |
| 625 |
/* harmony export */ createError: function() { return /* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_0__.createError; }, |
| 626 |
/* harmony export */ createTranslate: function() { return /* reexport safe */ _translations__WEBPACK_IMPORTED_MODULE_12__.createTranslate; }, |
| 627 |
/* harmony export */ debounce: function() { return /* reexport safe */ _debounce__WEBPACK_IMPORTED_MODULE_3__.debounce; }, |
| 628 |
/* harmony export */ decodeString: function() { return /* reexport safe */ _encoding__WEBPACK_IMPORTED_MODULE_5__.decodeString; }, |
| 629 |
/* harmony export */ encodeString: function() { return /* reexport safe */ _encoding__WEBPACK_IMPORTED_MODULE_5__.encodeString; }, |
| 630 |
/* harmony export */ ensureError: function() { return /* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_0__.ensureError; }, |
| 631 |
/* harmony export */ generateUniqueId: function() { return /* reexport safe */ _generate_unique_id__WEBPACK_IMPORTED_MODULE_8__.generateUniqueId; }, |
| 632 |
/* harmony export */ hasProInstalled: function() { return /* reexport safe */ _is_pro__WEBPACK_IMPORTED_MODULE_11__.hasProInstalled; }, |
| 633 |
/* harmony export */ hash: function() { return /* reexport safe */ _hash__WEBPACK_IMPORTED_MODULE_6__.hash; }, |
| 634 |
/* harmony export */ hashString: function() { return /* reexport safe */ _hash__WEBPACK_IMPORTED_MODULE_6__.hashString; }, |
| 635 |
/* harmony export */ isProActive: function() { return /* reexport safe */ _is_pro__WEBPACK_IMPORTED_MODULE_11__.isProActive; }, |
| 636 |
/* harmony export */ isProAtLeast: function() { return /* reexport safe */ _is_pro__WEBPACK_IMPORTED_MODULE_11__.isProAtLeast; }, |
| 637 |
/* harmony export */ isVersionGreaterOrEqual: function() { return /* reexport safe */ _version__WEBPACK_IMPORTED_MODULE_10__.isVersionGreaterOrEqual; }, |
| 638 |
/* harmony export */ isVersionLessThan: function() { return /* reexport safe */ _version__WEBPACK_IMPORTED_MODULE_10__.isVersionLessThan; }, |
| 639 |
/* harmony export */ throttle: function() { return /* reexport safe */ _throttle__WEBPACK_IMPORTED_MODULE_4__.throttle; }, |
| 640 |
/* harmony export */ useDebounceState: function() { return /* reexport safe */ _use_debounce_state__WEBPACK_IMPORTED_MODULE_1__.useDebounceState; }, |
| 641 |
/* harmony export */ useDebouncedCallback: function() { return /* reexport safe */ _use_debounced_callback__WEBPACK_IMPORTED_MODULE_2__.useDebouncedCallback; }, |
| 642 |
/* harmony export */ useSearchState: function() { return /* reexport safe */ _use_search_state__WEBPACK_IMPORTED_MODULE_7__.useSearchState; } |
| 643 |
/* harmony export */ }); |
| 644 |
/* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./errors */ "./packages/packages/libs/utils/src/errors/index.ts"); |
| 645 |
/* harmony import */ var _use_debounce_state__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./use-debounce-state */ "./packages/packages/libs/utils/src/use-debounce-state.ts"); |
| 646 |
/* harmony import */ var _use_debounced_callback__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./use-debounced-callback */ "./packages/packages/libs/utils/src/use-debounced-callback.ts"); |
| 647 |
/* harmony import */ var _debounce__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./debounce */ "./packages/packages/libs/utils/src/debounce.ts"); |
| 648 |
/* harmony import */ var _throttle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./throttle */ "./packages/packages/libs/utils/src/throttle.ts"); |
| 649 |
/* harmony import */ var _encoding__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./encoding */ "./packages/packages/libs/utils/src/encoding.ts"); |
| 650 |
/* harmony import */ var _hash__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./hash */ "./packages/packages/libs/utils/src/hash.ts"); |
| 651 |
/* harmony import */ var _use_search_state__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./use-search-state */ "./packages/packages/libs/utils/src/use-search-state.ts"); |
| 652 |
/* harmony import */ var _generate_unique_id__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./generate-unique-id */ "./packages/packages/libs/utils/src/generate-unique-id.ts"); |
| 653 |
/* harmony import */ var _string_helpers__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./string-helpers */ "./packages/packages/libs/utils/src/string-helpers.ts"); |
| 654 |
/* harmony import */ var _version__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./version */ "./packages/packages/libs/utils/src/version.ts"); |
| 655 |
/* harmony import */ var _is_pro__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./is-pro */ "./packages/packages/libs/utils/src/is-pro.ts"); |
| 656 |
/* harmony import */ var _translations__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./translations */ "./packages/packages/libs/utils/src/translations.ts"); |
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
}(); |
| 671 |
(window.elementorV2 = window.elementorV2 || {}).utils = __webpack_exports__; |
| 672 |
/******/ })() |
| 673 |
; |
| 674 |
window.elementorV2.utils?.init?.(); |
| 675 |
//# sourceMappingURL=utils.js.map |