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_monterrey//usr/local/bundle/gems/decidim-forms-0.26.3/app/packs/images|sync|/^\\.\\/.*$/","webpack://decidim_monterrey/webpack/bootstrap","webpack://decidim_monterrey/webpack/runtime/hasOwnProperty shorthand","webpack://decidim_monterrey/webpack/runtime/publicPath","webpack://decidim_monterrey/../usr/local/bundle/gems/decidim-forms-0.26.3/app/packs/src/decidim/forms/option_attached_inputs.component.js","webpack://decidim_monterrey/../usr/local/bundle/gems/decidim-forms-0.26.3/app/packs/src/decidim/forms/autosortable_checkboxes.component.js","webpack://decidim_monterrey/../usr/local/bundle/gems/decidim-forms-0.26.3/app/packs/src/decidim/forms/display_conditions.component.js","webpack://decidim_monterrey/../usr/local/bundle/gems/decidim-forms-0.26.3/app/packs/src/decidim/forms/max_choices_alert.component.js","webpack://decidim_monterrey/../usr/local/bundle/gems/decidim-forms-0.26.3/app/packs/src/decidim/forms/forms.js","webpack://decidim_monterrey/../usr/local/bundle/gems/decidim-forms-0.26.3/app/packs/entrypoints/decidim_forms.js"],"sourcesContent":["var map = {\n\t\"./decidim/surveys/decidim_surveys.svg\": 93660\n};\n\n\nfunction webpackContext(req) {\n\tvar id = webpackContextResolve(req);\n\treturn __webpack_require__(id);\n}\nfunction webpackContextResolve(req) {\n\tif(!__webpack_require__.o(map, req)) {\n\t\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\t\te.code = 'MODULE_NOT_FOUND';\n\t\tthrow e;\n\t}\n\treturn map[req];\n}\nwebpackContext.keys = function webpackContextKeys() {\n\treturn Object.keys(map);\n};\nwebpackContext.resolve = webpackContextResolve;\nmodule.exports = webpackContext;\nwebpackContext.id = 66613;","// 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","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","__webpack_require__.p = \"/decidim-packs/\";","/* eslint-disable require-jsdoc */\n\nclass OptionAttachedInputsComponent {\n constructor(options = {}) {\n this.wrapperField = options.wrapperField;\n this.controllerFieldSelector = options.controllerFieldSelector;\n this.dependentInputSelector = options.dependentInputSelector;\n this.controllerSelector = this.wrapperField.find(this.controllerFieldSelector);\n this._bindEvent();\n this._run();\n }\n\n _run() {\n this.controllerSelector.each((idx, el) => {\n const $field = $(el);\n const enabled = $field.is(\":checked\");\n\n $field.parents(\"div.collection-input\").find(this.dependentInputSelector).prop(\"disabled\", !enabled);\n });\n }\n\n _bindEvent() {\n this.controllerSelector.on(\"change\", () => {\n this._run();\n });\n }\n}\n\nexport default function createOptionAttachedInputs(options) {\n return new OptionAttachedInputsComponent(options);\n}\n","/* eslint-disable require-jsdoc */\n/* eslint-disable no-ternary */\n\nclass AutosortableCheckboxesComponent {\n constructor(options = {}) {\n this.wrapperField = options.wrapperField;\n this._bindEvent();\n this._order();\n this._normalize();\n }\n\n // Order by position\n _order() {\n const max = $(this.wrapperField).find(\".collection-input\").length;\n $(this.wrapperField).find(\".collection-input\").each((idx, el) => {\n const $positionField = $(el).find(\"input[name$=\\\\[position\\\\]]\");\n const position = $positionField.val()\n ? parseInt($positionField.val(), 10)\n : max;\n\n let $next = $(el).next();\n while ($next.length > 0) {\n const $nextPositionField = $next.find(\"input[name$=\\\\[position\\\\]]\");\n const nextPosition = $nextPositionField.val()\n ? parseInt($nextPositionField.val(), 10)\n : max;\n\n if (position > nextPosition) {\n $next.insertBefore($(el));\n }\n $next = $next.next();\n }\n });\n }\n\n _findLastPosition() {\n let lastPosition = 0;\n $(this.wrapperField).find(\".collection-input\").each((idx, el) => {\n const $positionField = $(el).find(\"input[name$=\\\\[position\\\\]]\");\n const position = parseInt($positionField.val(), 10);\n if (position > lastPosition) {\n lastPosition = position;\n }\n });\n return lastPosition;\n }\n\n _normalize() {\n $(this.wrapperField).find(\".collection-input .position\").each((idx, el) => {\n const $positionField = $(el).parent().find(\"input[name$=\\\\[position\\\\]]\");\n if ($positionField.val()) {\n $positionField.val(idx);\n $positionField.prop(\"disabled\", false);\n $(el).html(`${idx + 1}. `);\n }\n });\n }\n\n _bindEvent() {\n $(this.wrapperField).find(\"input[type=checkbox]\").on(\"change\", (el) => {\n const $parentLabel = $(el.target).parents(\"label\");\n const $positionSelector = $parentLabel.find(\".position\");\n const $positionField = $parentLabel.find(\"input[name$=\\\\[position\\\\]]\");\n const lastPosition = this._findLastPosition();\n\n if (el.target.checked) {\n $positionField.val(lastPosition + 1);\n $positionField.prop(\"disabled\", false);\n $positionSelector.html(lastPosition + 1);\n } else {\n $positionField.val(\"\");\n $positionField.prop(\"disabled\", true);\n $positionSelector.html(\"\");\n }\n this._order();\n this._normalize();\n });\n }\n}\n\nexport default function createAutosortableCheckboxes(options) {\n return new AutosortableCheckboxesComponent(options);\n}\n","/* eslint-disable no-ternary, no-plusplus, require-jsdoc */\n\nclass DisplayCondition {\n constructor(options = {}) {\n this.wrapperField = options.wrapperField;\n this.type = options.type;\n this.conditionQuestion = options.conditionQuestion;\n this.answerOption = options.answerOption;\n this.mandatory = options.mandatory;\n this.value = options.value;\n this.onFulfilled = options.onFulfilled;\n this.bindEvent();\n }\n\n bindEvent() {\n this.checkCondition();\n this.getInputsToListen().on(\"change\", this.checkCondition.bind(this));\n }\n\n getInputValue() {\n const $conditionWrapperField = $(`.question[data-question-id='${this.conditionQuestion}']`);\n const $textInput = $conditionWrapperField.find(\"textarea, input[type='text']:not([name$=\\\\[custom_body\\\\]])\");\n\n if ($textInput.length) {\n return $textInput.val();\n }\n\n let multipleInput = [];\n\n $conditionWrapperField.find(\".radio-button-collection, .check-box-collection\").find(\".collection-input\").each((idx, el) => {\n const $input = $(el).find(\"input[name$=\\\\[body\\\\]]\");\n const checked = $input.is(\":checked\");\n\n if (checked) {\n const text = $(el).find(\"input[name$=\\\\[custom_body\\\\]]\").val();\n const value = $input.val();\n const id = $(el).find(\"input[name$=\\\\[answer_option_id\\\\]]\").val();\n\n multipleInput.push({ id, value, text });\n }\n });\n\n return multipleInput;\n }\n\n getInputsToListen() {\n const $conditionWrapperField = $(`.question[data-question-id='${this.conditionQuestion}']`);\n const $textInput = $conditionWrapperField.find(\"textarea, input[type='text']:not([name$=\\\\[custom_body\\\\]])\");\n\n if ($textInput.length) {\n return $textInput;\n }\n\n return $conditionWrapperField.find(\".collection-input\").find(\"input:not([type='hidden'])\");\n }\n\n checkAnsweredCondition(value) {\n if (typeof (value) !== \"object\") {\n return Boolean(value);\n }\n\n return Boolean(value.some((it) => it.value));\n }\n\n checkNotAnsweredCondition(value) {\n return !this.checkAnsweredCondition(value);\n }\n\n checkEqualCondition(value) {\n if (value.length) {\n return value.some((it) => it.id === this.answerOption.toString());\n }\n return false;\n }\n\n checkNotEqualCondition(value) {\n if (value.length) {\n return value.every((it) => it.id !== this.answerOption.toString());\n }\n return false;\n }\n\n checkMatchCondition(value) {\n let regexp = new RegExp(this.value, \"i\");\n\n if (typeof (value) !== \"object\") {\n return Boolean(value.match(regexp));\n }\n\n return value.some(function (it) {\n return it.text\n ? it.text.match(regexp)\n : it.value.match(regexp)\n });\n }\n\n checkCondition() {\n const value = this.getInputValue();\n let fulfilled = false;\n\n switch (this.type) {\n case \"answered\":\n fulfilled = this.checkAnsweredCondition(value);\n break;\n case \"not_answered\":\n fulfilled = this.checkNotAnsweredCondition(value);\n break;\n case \"equal\":\n fulfilled = this.checkEqualCondition(value);\n break;\n case \"not_equal\":\n fulfilled = this.checkNotEqualCondition(value);\n break;\n case \"match\":\n fulfilled = this.checkMatchCondition(value);\n break;\n default:\n fulfilled = false;\n break;\n }\n\n this.onFulfilled(fulfilled);\n }\n}\n\nclass DisplayConditionsComponent {\n constructor(options = {}) {\n this.wrapperField = options.wrapperField;\n this.conditions = {};\n this.showCount = 0;\n this.initializeConditions();\n }\n\n initializeConditions() {\n const $conditionElements = this.wrapperField.find(\".display-condition\");\n\n $conditionElements.each((idx, el) => {\n const $condition = $(el);\n const id = $condition.data(\"id\");\n this.conditions[id] = {};\n\n this.conditions[id] = new DisplayCondition({\n wrapperField: this.wrapperField,\n type: $condition.data(\"type\"),\n conditionQuestion: $condition.data(\"condition\"),\n answerOption: $condition.data(\"option\"),\n mandatory: $condition.data(\"mandatory\"),\n value: $condition.data(\"value\"),\n onFulfilled: (fulfilled) => {\n this.onFulfilled(id, fulfilled);\n }\n });\n });\n }\n\n mustShow() {\n const conditions = Object.values(this.conditions);\n const mandatoryConditions = conditions.filter((condition) => condition.mandatory);\n const nonMandatoryConditions = conditions.filter((condition) => !condition.mandatory);\n\n if (mandatoryConditions.length) {\n return mandatoryConditions.every((condition) => condition.fulfilled);\n }\n\n return nonMandatoryConditions.some((condition) => condition.fulfilled);\n\n }\n\n onFulfilled(id, fulfilled) {\n this.conditions[id].fulfilled = fulfilled;\n\n if (this.mustShow()) {\n this.showQuestion();\n }\n else {\n this.hideQuestion();\n }\n }\n\n showQuestion() {\n this.wrapperField.fadeIn();\n this.wrapperField.find(\"input, textarea\").prop(\"disabled\", null);\n this.showCount++;\n }\n\n hideQuestion() {\n if (this.showCount) {\n this.wrapperField.fadeOut();\n }\n else {\n this.wrapperField.hide();\n }\n\n this.wrapperField.find(\"input, textarea\").prop(\"disabled\", \"disabled\");\n }\n}\n\nexport default function createDisplayConditions(options) {\n return new DisplayConditionsComponent(options);\n}\n","/* eslint-disable require-jsdoc */\n\nclass MaxChoicesAlertComponent {\n constructor(options = {}) {\n this.wrapperField = options.wrapperField;\n this.alertElement = options.alertElement;\n this.controllerFieldSelector = options.controllerFieldSelector;\n this.controllerCollectionSelector = options.controllerCollectionSelector;\n this.maxChoices = options.maxChoices;\n this.controllerSelector = this.wrapperField.find(this.controllerFieldSelector);\n this._bindEvent();\n this._run();\n }\n\n _run() {\n const rows = this.wrapperField.find(this.controllerCollectionSelector);\n\n let alert = false;\n\n rows.each((rowIdx, row) => {\n const checked = $(row).find(this.controllerFieldSelector).filter((checkboxIdx, checkbox) => $(checkbox).is(\":checked\"));\n\n alert = alert || checked.length > this.maxChoices;\n });\n\n if (alert) {\n this.alertElement.show();\n }\n else {\n this.alertElement.hide();\n }\n }\n\n _bindEvent() {\n this.controllerSelector.on(\"change\", () => {\n this._run();\n });\n }\n}\n\nexport default function createMaxChoicesAlertComponent(options) {\n return new MaxChoicesAlertComponent(options);\n}\n","/* eslint-disable require-jsdoc */\n\nimport createOptionAttachedInputs from \"src/decidim/forms/option_attached_inputs.component\"\nimport createAutosortableCheckboxes from \"src/decidim/forms/autosortable_checkboxes.component\"\nimport createDisplayConditions from \"src/decidim/forms/display_conditions.component\"\nimport createMaxChoicesAlertComponent from \"src/decidim/forms/max_choices_alert.component\"\n\n$(() => {\n $(\".radio-button-collection, .check-box-collection\").each((idx, el) => {\n createOptionAttachedInputs({\n wrapperField: $(el),\n controllerFieldSelector: \"input[type=radio], input[type=checkbox]\",\n dependentInputSelector: \"input[type=text], input[type=hidden]\"\n });\n });\n\n $.unique($(\".check-box-collection\").parents(\".answer\")).each((idx, el) => {\n const maxChoices = $(el).data(\"max-choices\");\n if (maxChoices) {\n createMaxChoicesAlertComponent({\n wrapperField: $(el),\n controllerFieldSelector: \"input[type=checkbox]\",\n controllerCollectionSelector: \".check-box-collection\",\n alertElement: $(el).find(\".max-choices-alert\"),\n maxChoices: maxChoices\n });\n }\n });\n\n $(\".sortable-check-box-collection\").each((idx, el) => {\n createAutosortableCheckboxes({\n wrapperField: $(el)\n })\n });\n\n $(\".answer-questionnaire .question[data-conditioned='true']\").each((idx, el) => {\n createDisplayConditions({\n wrapperField: $(el)\n });\n });\n\n const $form = $(\"form.answer-questionnaire\");\n if ($form.length > 0) {\n $form.find(\"input, textarea, select\").on(\"change\", () => {\n $form.data(\"changed\", true);\n });\n\n const safePath = $form.data(\"safe-path\").split(\"?\")[0];\n $(document).on(\"click\", \"a\", (event) => {\n window.exitUrl = event.currentTarget.href;\n });\n $(document).on(\"submit\", \"form\", (event) => {\n window.exitUrl = event.currentTarget.action;\n });\n\n window.addEventListener(\"beforeunload\", (event) => {\n const exitUrl = window.exitUrl;\n const hasChanged = $form.data(\"changed\");\n window.exitUrl = null;\n\n if (!hasChanged || (exitUrl && exitUrl.includes(safePath))) {\n return;\n }\n\n event.returnValue = true;\n });\n }\n})\n","import \"src/decidim/forms/forms\"\n\n// Images\nrequire.context(\"../images\", true)\n"],"names":["map","webpackContext","req","id","webpackContextResolve","__webpack_require__","o","e","Error","code","keys","Object","resolve","module","exports","__webpack_module_cache__","moduleId","cachedModule","undefined","__webpack_modules__","obj","prop","prototype","hasOwnProperty","call","p","OptionAttachedInputsComponent","options","this","wrapperField","controllerFieldSelector","dependentInputSelector","controllerSelector","find","_bindEvent","_run","_createClass","each","idx","el","$field","$","enabled","is","parents","_this","on","_this2","AutosortableCheckboxesComponent","_order","_normalize","max","length","$positionField","position","val","parseInt","$next","next","$nextPositionField","insertBefore","lastPosition","parent","html","$parentLabel","target","$positionSelector","_findLastPosition","checked","DisplayCondition","type","conditionQuestion","answerOption","mandatory","value","onFulfilled","bindEvent","checkCondition","getInputsToListen","bind","$conditionWrapperField","$textInput","multipleInput","$input","text","push","_typeof","Boolean","some","it","checkAnsweredCondition","toString","every","regexp","RegExp","match","getInputValue","fulfilled","checkNotAnsweredCondition","checkEqualCondition","checkNotEqualCondition","checkMatchCondition","DisplayConditionsComponent","conditions","showCount","initializeConditions","$condition","data","_this3","values","mandatoryConditions","filter","condition","nonMandatoryConditions","mustShow","showQuestion","hideQuestion","fadeIn","fadeOut","hide","MaxChoicesAlertComponent","alertElement","controllerCollectionSelector","maxChoices","rows","alert","rowIdx","row","checkboxIdx","checkbox","show","unique","$form","safePath","split","document","event","window","exitUrl","currentTarget","href","action","addEventListener","hasChanged","includes","returnValue","require"],"sourceRoot":""}