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,WACvD,CAEAI,6BAA+BoB,MAAOhB,IACrC,MAAMO,EAAOP,EAAMiB,OAAOrC,aAAa,mBACjCZ,KAAKkD,WAAWX,EAAK,EAG5B,aAAMY,CAAQZ,GACb,MAAMa,EAAYpD,KAAKmB,iBAAiB4B,QAAQnC,aAAa,mBACvDyC,EAAcrD,KAAKmB,iBAAiB4B,QAAQnC,aAAa,mBACzD4B,EAAO,CACZC,IAAKzC,KAAKyC,IACVC,UAAW,CAAC,UAAW,cACvBC,aAAc,CAAC,WAAcS,EAAW,WAAeC,EAAa,KAAQd,GAC5EA,KAAMA,GAGP,aAD2BvC,KAAK6C,eAAeL,EAEhD,CAEA,cAAMc,CAASf,GACd,MAAMK,QAAqB5C,KAAKmD,QAAQZ,GACxCvC,KAAK8C,sBAAsB,UAAWF,EAAaG,SACnD/C,KAAK8C,sBAAsB,aAAcF,EAAapB,WACvD,CAEA,gBAAM0B,CAAWX,GAChB,MAAMK,QAAqB5C,KAAKmD,QAAQZ,GAClCgB,EAAmBvD,KAAKqB,cAC7B,uCAEKmC,EAAarF,SAASsF,cAAc,OAC1CD,EAAWE,UAAYd,EAAaG,QACpC,MAAMY,EAAkBH,EAAW/B,iBAClC,4CAED,IAAK,MAAMmC,KAAkBD,EAC5BJ,EAAiBM,OAAOD,GAEzB5D,KAAK8C,sBAAsB,aAAcF,EAAapB,WACvD,EAIDrD,SAASwD,iBAAiB,oBAAoB,KAC7CmC,eAAeC,OAAO,0BAA2BpE,EAAc,CAACqE,QAAS,OAAO,G","sources":["webpack://customtheme/./node_modules/@alexspirgel/children-loaded/src/index.js","webpack://customtheme/webpack/bootstrap","webpack://customtheme/./custom-post-lists/resource-list/scripts/src/script.js"],"sourcesContent":["module.exports = (function () {\n\n\t// Initialize a weak map to hold promises.\n\tconst childrenLoadedPromises = new WeakMap();\n\n\t/**\n\t * Checks to see if children elements are loaded.\n\t * @param {object} element - Element to look for children within.\n\t * @return {boolean} Whether the children elements are loaded or not.\n\t */\n\n\tconst childrenLoadedSynchronous = (element) => {\n\n\t\t// Document ready states reference: https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState\n\t\tif (document.readyState === 'interactive' || document.readyState === 'complete') {\n\t\t\t// Children elements are assumed to be loaded.\n\t\t\treturn true;\n\t\t}\n\n\t\t// While the element exists.\n\t\twhile (element) {\n\t\t\t// If the next sibling element exists.\n\t\t\tif (element.nextSibling) {\n\t\t\t\t// The original passed element and its children have been loaded.\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t// Set the element to the parent element.\n\t\t\telement = element.parentNode;\n\t\t}\n\n\t\t// If code execution gets here, it's assumed children elements are not loaded.\n\t\treturn false;\n\n\t};\n\n\t/**\n\t * An asynchronous wrapper for the childrenLoadedSynchronous function.\n\t * @param {object} element - Element to look for children within.\n\t * @param {boolean} [forceNewPromise=false] - Option to invalidate existing promises.\n\t * @return {*} True if children are loaded, otherwise a promise.\n\t */\n\n\tconst childrenLoaded = (element, forceNewPromise = false) => {\n\n\t\t// If children are loaded immediately.\n\t\tif (childrenLoadedSynchronous(element)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// If an existing promise for the passed element does not exist yet or if a new promise is being forced.\n\t\telse if (!childrenLoadedPromises.get(element) || forceNewPromise) {\n\t\t\t// Create a new promise.\n\t\t\tconst childrenLoadedPromise = new Promise((resolve) => {\n\t\t\t\t// Create a new mutation observer.\n\t\t\t\tconst observer = new MutationObserver(() => {\n\t\t\t\t\t// When children are loaded.\n\t\t\t\t\tif (childrenLoadedSynchronous(element)) {\n\t\t\t\t\t\t// Disconnect the mutation observer.\n\t\t\t\t\t\tobserver.disconnect();\n\t\t\t\t\t\t// Resolve the promise.\n\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\t// Watch for child element updates.\n\t\t\t\tobserver.observe(element, {\n\t\t\t\t\tchildList: true\n\t\t\t\t});\n\t\t\t});\n\t\t\t// Set the promise weak map entry for the passed element.\n\t\t\tchildrenLoadedPromises.set(element, childrenLoadedPromise);\n\t\t}\n\n\t\t// Return the promise for the passed element.\n\t\t// Multiple asynchronous calls of childrenLoaded for the same element should return the same promise.\n\t\treturn childrenLoadedPromises.get(element);\n\n\t};\n\n\t// Attach the synchronous function to the export for optional use.\n\tchildrenLoaded.synchronous = childrenLoadedSynchronous;\n\t// Add shorthand alias for synchronous.\n\tchildrenLoaded.sync = childrenLoaded.synchronous;\n\t// Return the asynchronous function as the export.\n\treturn childrenLoaded;\n\n})();","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","const childrenLoaded = require(\"@alexspirgel/children-loaded\");\n\nclass ResourceList extends ESWPPostList {\n\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tasync connectedCallback() {\n\t\tawait childrenLoaded(this);\n\t\tif (this.queryStringFiltering) {\n\t\t\tthis.queryStrings = this.constructor.getQueryStrings();\n\t\t\tconst queryStringsTermIds = this.queryStringSlugsToTermIds(this.queryStrings);\n\t\t\tthis.setFormValues(queryStringsTermIds);\n\t\t}\n\t\tthis.formAttachEventListeners();\n\t\tthis.addUpdateTemplateElementCallback(\"form\",this.formAttachEventListeners);\n\t\tthis.formOnChangeListener();\n\t\tif (this.queryStringFiltering) {\n\t\t\tconst queryStrings = this.constructor.getQueryStrings();\n\t\t\tthis.setFormValues(queryStrings);\n\t\t}\n\t\tthis.paginationAttachEventListeners();\n\t\tthis.addUpdateTemplateElementCallback('pagination', this.paginationAttachEventListeners);\n\t}\n\n\tget queryStringFiltering() {\n\t\tconst queryStringFilteringAttribute = this.getAttribute('data-query-string-filtering');\n\t\tif (!this.constructor.isAdmin() && queryStringFilteringAttribute == 'true') {\n\t\t\treturn true;\n\t\t}\n\t\telse {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tqueryStringSlugsToTermIds(formData) {\n\t\tformData = Object.assign({}, formData);\n\t\tif (typeof formData['resource_type'] === 'string' && formData['resource_type'].length > 0) {\n\t\t\tconst optionElement = this.templateElements.form.querySelector(`#resource_type option[value=\"${formData['resource_type']}\"]`);\n\t\t\tif (optionElement) {\n\t\t\t\tformData['resource_type'] = optionElement.getAttribute('data-slug');\n\t\t\t}\n\t\t}\n\t\tif (typeof formData['resource_subject'] === 'string' && formData['resource_subject'].length > 0) {\n\t\t\tconst optionElement = this.templateElements.form.querySelector(`#resource_subject option[value=\"${formData['resource_subject']}\"]`);\n\t\t\tif (optionElement) {\n\t\t\t\tformData['resource_subject'] = optionElement.getAttribute('data-slug');\n\t\t\t}\n\t\t}\n\t\tif (typeof formData['author'] === 'string' && formData['author'].length > 0) {\n\t\t\tconst optionElement = this.templateElements.form.querySelector(`#author option[value=\"${formData['author']}\"]`);\n\t\t\tif (optionElement) {\n\t\t\t\tformData['author'] = optionElement.getAttribute('data-slug');\n\t\t\t}\n\t\t}\n\t\treturn formData;\n\t}\n\n\tformDataTermIdsToSlugs(formData) {\n\t\tformData = Object.assign({}, formData);\n\t\tif (typeof formData['resource_type'] === 'string' && formData['resource_type'].length > 0) {\n\t\t\tconst optionElement = this.templateElements.form.querySelector(`#resource_type option[value=\"${formData['resource_type']}\"]`);\n\t\t\tif (optionElement) {\n\t\t\t\tformData['resource_type'] = optionElement.getAttribute('data-slug');\n\t\t\t}\n\t\t}\n\t\tif (typeof formData['resource_subject'] === 'string' && formData['resource_subject'].length > 0) {\n\t\t\tconst optionElement = this.templateElements.form.querySelector(`#resource_subject option[value=\"${formData['resource_subject']}\"]`);\n\t\t\tif (optionElement) {\n\t\t\t\tformData['resource_subject'] = optionElement.getAttribute('data-slug');\n\t\t\t}\n\t\t}\n\t\tif (typeof formData['author'] === 'string' && formData['author'].length > 0) {\n\t\t\tconst optionElement = this.templateElements.form.querySelector(`#author option[value=\"${formData['author']}\"]`);\n\t\t\tif (optionElement) {\n\t\t\t\tformData['author'] = optionElement.getAttribute('data-slug');\n\t\t\t}\n\t\t}\n\t\treturn formData;\n\t}\n\t\n\tpaginationAttachEventListeners = () => {\n\t\tconst pagerButtonElements = this.templateElements.pagination.querySelectorAll('button');\n\t\tfor (let buttonElement of pagerButtonElements) {\n\t\t\tbuttonElement.addEventListener('click', this.paginationButtonClickHandler);\n\t\t}\n\t}\n\n\tgetFormValues() {\n\t\treturn this.constructor.getFormValues(this.templateElements.form);\n\t}\n\n\tsetFormValues(values) {\n\t\treturn this.constructor.setFormValues(this.templateElements.form, values);\n\t}\n\n\tformAttachEventListeners = () => {\n\t\tthis.templateElements.form.addEventListener('submit', this.formSubmitHandler);\n\t};\n\n\tformSubmitHandler = (event) => {\n\t\tif (event.preventDefault) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t\tthis.submitForm();\n return false;\n\t};\n\n\tformOnChangeListener = () => {\n\t\tconst selects = this.templateElements.form.querySelectorAll('select');\n\n\t\tif (!selects.length) {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (let select of selects) {\n\t\t\tselect.addEventListener('customFilterChange', (e) => {\n\t\t\t\te.stopPropagation();\n\t\t\t\tthis.formSubmitHandler(e);\n\t\t\t});\n\t\t}\n\t};\n\n\n\tasync submitForm(page = 1) {\n\t\tconst formData = this.getFormValues();\n\t\tconst args = {\n\t\t\tkey: this.key,\n\t\t\ttemplates: ['results', 'pagination'],\n\t\t\trequest_data: formData,\n\t\t\tpage: page,\n\t\t};\n\t\tconst newTemplates = await this.fetchTemplates(args);\n\t\tthis.updateTemplateElement('results', newTemplates.results);\n\t\tthis.updateTemplateElement('pagination', newTemplates.pagination);\n\t}\n\n\tpaginationButtonClickHandler = async (event) => {\n\t\tconst page = event.target.getAttribute('data-page');\n\t\tawait this.appendPage(page);\n\t}\n\n\tasync getPage(page) {\n\t\tconst isArchive = this.templateElements.results.getAttribute('data-is-archive');\n\t\tconst archivePost = this.templateElements.results.getAttribute('data-archive-id');\n\t\tconst args = {\n\t\t\tkey: this.key,\n\t\t\ttemplates: ['results', 'pagination'],\n\t\t\trequest_data: {'is_archive': isArchive, 'archive_id' : archivePost, 'page': page},\n\t\t\tpage: page\n\t\t};\n\t\tconst newTemplates = await this.fetchTemplates(args);\n\t\treturn newTemplates;\n\t}\n\n\tasync goToPage(page) {\n\t\tconst newTemplates = await this.getPage(page);\n\t\tthis.updateTemplateElement('results', newTemplates.results);\n\t\tthis.updateTemplateElement('pagination', newTemplates.pagination);\n\t}\n\n\tasync appendPage(page) {\n\t\tconst newTemplates = await this.getPage(page);\n\t\tconst resultsContainer = this.querySelector(\n\t\t\t'[data-post-list-template=\"results\"]'\n\t\t);\n\t\tconst htmlObject = document.createElement(\"div\");\n\t\thtmlObject.innerHTML = newTemplates.results;\n\t\tconst newResultsItems = htmlObject.querySelectorAll(\n\t\t\t'[data-post-list-template=\"results\"] > li'\n\t\t);\n\t\tfor (const newResultsItem of newResultsItems) {\n\t\t\tresultsContainer.append(newResultsItem);\n\t\t}\n\t\tthis.updateTemplateElement(\"pagination\", newTemplates.pagination);\n\t}\n\n}\n\ndocument.addEventListener('DOMContentLoaded', () => {\n\tcustomElements.define('post-list-resource-list', ResourceList, {extends: 'div'});\n});\n"],"names":["module","exports","childrenLoadedPromises","WeakMap","childrenLoadedSynchronous","element","document","readyState","nextSibling","parentNode","childrenLoaded","forceNewPromise","get","childrenLoadedPromise","Promise","resolve","observer","MutationObserver","disconnect","observe","childList","set","sync","synchronous","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","ResourceList","ESWPPostList","constructor","super","connectedCallback","this","queryStringFiltering","queryStrings","getQueryStrings","queryStringsTermIds","queryStringSlugsToTermIds","setFormValues","formAttachEventListeners","addUpdateTemplateElementCallback","formOnChangeListener","paginationAttachEventListeners","queryStringFilteringAttribute","getAttribute","isAdmin","formData","Object","assign","length","optionElement","templateElements","form","querySelector","formDataTermIdsToSlugs","pagerButtonElements","pagination","querySelectorAll","buttonElement","addEventListener","paginationButtonClickHandler","getFormValues","values","formSubmitHandler","event","preventDefault","submitForm","selects","select","e","stopPropagation","page","args","key","templates","request_data","newTemplates","fetchTemplates","updateTemplateElement","results","async","target","appendPage","getPage","isArchive","archivePost","goToPage","resultsContainer","htmlObject","createElement","innerHTML","newResultsItems","newResultsItem","append","customElements","define","extends"],"sourceRoot":""}