{"version":3,"file":"trix-CqILQR0j.js","sources":["../../../node_modules/.pnpm/cocoon-js-vanilla@1.5.1/node_modules/cocoon-js-vanilla/index.js","../../../node_modules/.pnpm/trix@2.1.10/node_modules/trix/dist/trix.esm.min.js","../../../app/frontend/javascript/libs/trix.js"],"sourcesContent":["document.addEventListener('DOMContentLoaded', function () {\n var cocoonElementCounter = 0;\n\n var createNewID = function () {\n return (new Date().getTime() + cocoonElementCounter++);\n };\n\n var newcontentBraced = function (id) {\n return '[' + id + ']$1';\n };\n\n var newcontentUnderscored = function (id) {\n return '_' + id + '_$1';\n };\n\n var getInsertionNodeElem = function (insertionNode, insertionTraversal, thisNode) {\n if (!insertionNode) {\n return thisNode.parentNode;\n }\n\n if (typeof insertionNode === 'function') {\n if (insertionTraversal) {\n console.warn('association-insertion-traversal is ignored, because association-insertion-node is given as a function.');\n }\n return insertionNode(thisNode);\n }\n\n if (typeof insertionNode === 'string') {\n if (insertionTraversal) {\n return thisNode[insertionTraversal](insertionNode);\n } else {\n return insertionNode === 'this' ? thisNode : document.querySelector(insertionNode);\n }\n }\n };\n\n var cocoonDetach = function (node) {\n return node.parentElement.removeChild(node);\n };\n\n var cocoonGetPreviousSibling = function (elem, selector) {\n var sibling = elem.previousElementSibling;\n\n if (!selector) return sibling;\n\n while (sibling) {\n var match = sibling.matches(selector);\n if (match) return sibling;\n sibling = sibling.previousElementSibling;\n }\n };\n\n var cocoonAddFields = function (e, target) {\n e.preventDefault();\n e.stopPropagation();\n\n var thisNode = target;\n var assoc = thisNode.getAttribute('data-association');\n var assocs = thisNode.getAttribute('data-associations');\n var content = thisNode.getAttribute('data-association-insertion-template');\n var insertionMethod = thisNode.getAttribute('data-association-insertion-method') || thisNode.getAttribute('data-association-insertion-position') || 'before';\n var insertionNode = thisNode.getAttribute('data-association-insertion-node');\n var insertionTraversal = thisNode.getAttribute('data-association-insertion-traversal');\n var count = parseInt(thisNode.getAttribute('data-count'), 10);\n var regexpBraced = new RegExp('\\\\[new_' + assoc + '\\\\](.*?\\\\s)', 'g');\n var regexpUnderscored = new RegExp('_new_' + assoc + '_(\\\\w*)', 'g');\n var newId = createNewID();\n var newContent = content.replace(regexpBraced, newcontentBraced(newId));\n var newContents = [];\n var originalEvent = e;\n\n if (newContent === content) {\n regexpBraced = new RegExp('\\\\[new_' + assocs + '\\\\](.*?\\\\s)', 'g');\n regexpUnderscored = new RegExp('_new_' + assocs + '_(\\\\w*)', 'g');\n newContent = content.replace(regexpBraced, newcontentBraced(newId));\n }\n\n newContent = newContent.replace(regexpUnderscored, newcontentUnderscored(newId));\n newContents = [newContent];\n\n count = (isNaN(count) ? 1 : Math.max(count, 1));\n count -= 1;\n\n while (count) {\n newId = createNewID();\n newContent = content.replace(regexpBraced, newcontentBraced(newId));\n newContent = newContent.replace(regexpUnderscored, newcontentUnderscored(newId));\n newContents.push(newContent);\n\n count -= 1;\n }\n\n var insertionNodeElem = getInsertionNodeElem(insertionNode, insertionTraversal, thisNode);\n\n if (!insertionNodeElem || (insertionNodeElem.length === 0)) {\n console.warn(\"Couldn't find the element to insert the template. Make sure your `data-association-insertion-*` on `link_to_add_association` is correct.\");\n }\n\n newContents.forEach(function (node, i) {\n var contentNode = node;\n\n var beforeInsert = new CustomEvent('cocoon:before-insert', { bubbles: true, cancelable: true, detail: [contentNode, originalEvent] });\n insertionNodeElem.dispatchEvent(beforeInsert);\n\n if (!beforeInsert.defaultPrevented) {\n // allow any of the jquery dom manipulation methods (after, before, append, prepend, etc)\n // to be called on the node. allows the insertion node to be the parent of the inserted\n // code and doesn't force it to be a sibling like after/before does. default: 'before'\n var htmlMapping = {\n before: 'beforebegin',\n prepend: 'afterbegin',\n append: 'beforeend',\n after: 'afterend'\n };\n\n var htmlMethod = htmlMapping[insertionMethod];\n var addedContent = insertionNodeElem.insertAdjacentHTML(htmlMethod, contentNode);\n\n if (htmlMethod === htmlMapping.before) {\n addedContent = insertionNodeElem.previousElementSibling;\n } else if (htmlMethod === htmlMapping.prepend) {\n addedContent = insertionNodeElem.firstElementChild;\n } else if (htmlMethod === htmlMapping.append) {\n addedContent = insertionNodeElem.lastElementChild;\n } else if (htmlMethod === htmlMapping.after) {\n addedContent = insertionNodeElem.nextElementSibling;\n }\n\n var afterInsert = new CustomEvent('cocoon:after-insert', { bubbles: true, detail: [contentNode, originalEvent, addedContent] });\n insertionNodeElem.dispatchEvent(afterInsert);\n }\n });\n };\n\n var cocoonRemoveFields = function (e, target) {\n var thisNode = target;\n var wrapperClass = thisNode.getAttribute('data-wrapper-class') || 'nested-fields';\n var nodeToDelete = thisNode.closest('.' + wrapperClass);\n var triggerNode = nodeToDelete.parentNode;\n var originalEvent = e;\n\n e.preventDefault();\n e.stopPropagation();\n\n var beforeRemove = new CustomEvent('cocoon:before-remove', { bubbles: true, cancelable: true, detail: [nodeToDelete, originalEvent] });\n triggerNode.dispatchEvent(beforeRemove);\n\n if (!beforeRemove.defaultPrevented) {\n var timeout = triggerNode.getAttribute('data-remove-timeout') || 0;\n\n setTimeout(function () {\n if (thisNode.classList.contains('dynamic')) {\n cocoonDetach(nodeToDelete);\n } else {\n var hiddenInput = cocoonGetPreviousSibling(thisNode, 'input[type=hidden]');\n hiddenInput.value = '1';\n nodeToDelete.style.display = 'none';\n\n var inputs = nodeToDelete.querySelectorAll(\"input[required]\");\n for (var i = 0; i < inputs.length; i++) {\n inputs[i].removeAttribute(\"required\");\n }\n }\n var afterRemove = new CustomEvent('cocoon:after-remove', { bubbles: true, detail: [nodeToDelete, originalEvent] });\n triggerNode.dispatchEvent(afterRemove);\n }, timeout);\n }\n };\n\n document.addEventListener('click', function (e) {\n for (var target = e.target; target && target !== this; target = target.parentNode) {\n if (target.matches('.add_fields')) {\n cocoonAddFields(e, target);\n return;\n }\n if (target.matches('.remove_fields')) {\n cocoonRemoveFields(e, target);\n return;\n }\n }\n }, false);\n\n var hideRemovedFields = function () { \n var targets = document.querySelectorAll('.remove_fields.existing.destroyed');\n for (var i = 0; i < targets.length; i++) {\n var thisNode = targets[i];\n var wrapperClass = thisNode.getAttribute('data-wrapper-class') || 'nested-fields';\n var nodeToHide = thisNode.closest('.' + wrapperClass);\n \n nodeToHide.style.display = 'none';\n }\n }\n\n document.addEventListener('page:load', hideRemovedFields);\n document.addEventListener('turbolinks:load', hideRemovedFields); // Has been replaced by Turbo\n document.addEventListener('turbo:load', hideRemovedFields);\n\n hideRemovedFields();\n});\n","/*\nTrix 2.1.10\nCopyright © 2024 37signals, LLC\n */\nvar t=\"2.1.10\";const e=\"[data-trix-attachment]\",i={preview:{presentation:\"gallery\",caption:{name:!0,size:!0}},file:{caption:{size:!0}}},n={default:{tagName:\"div\",parse:!1},quote:{tagName:\"blockquote\",nestable:!0},heading1:{tagName:\"h1\",terminal:!0,breakOnReturn:!0,group:!1},code:{tagName:\"pre\",terminal:!0,htmlAttributes:[\"language\"],text:{plaintext:!0}},bulletList:{tagName:\"ul\",parse:!1},bullet:{tagName:\"li\",listAttribute:\"bulletList\",group:!1,nestable:!0,test(t){return r(t.parentNode)===n[this.listAttribute].tagName}},numberList:{tagName:\"ol\",parse:!1},number:{tagName:\"li\",listAttribute:\"numberList\",group:!1,nestable:!0,test(t){return r(t.parentNode)===n[this.listAttribute].tagName}},attachmentGallery:{tagName:\"div\",exclusive:!0,terminal:!0,parse:!1,group:!1}},r=t=>{var e;return null==t||null===(e=t.tagName)||void 0===e?void 0:e.toLowerCase()},o=navigator.userAgent.match(/android\\s([0-9]+.*Chrome)/i),s=o&&parseInt(o[1]);var a={composesExistingText:/Android.*Chrome/.test(navigator.userAgent),recentAndroid:s&&s>12,samsungAndroid:s&&navigator.userAgent.match(/Android.*SM-/),forcesObjectResizing:/Trident.*rv:11/.test(navigator.userAgent),supportsInputEvents:\"undefined\"!=typeof InputEvent&&[\"data\",\"getTargetRanges\",\"inputType\"].every((t=>t in InputEvent.prototype))},l={attachFiles:\"Attach Files\",bold:\"Bold\",bullets:\"Bullets\",byte:\"Byte\",bytes:\"Bytes\",captionPlaceholder:\"Add a caption…\",code:\"Code\",heading1:\"Heading\",indent:\"Increase Level\",italic:\"Italic\",link:\"Link\",numbers:\"Numbers\",outdent:\"Decrease Level\",quote:\"Quote\",redo:\"Redo\",remove:\"Remove\",strike:\"Strikethrough\",undo:\"Undo\",unlink:\"Unlink\",url:\"URL\",urlPlaceholder:\"Enter a URL…\",GB:\"GB\",KB:\"KB\",MB:\"MB\",PB:\"PB\",TB:\"TB\"};const c=[l.bytes,l.KB,l.MB,l.GB,l.TB,l.PB];var u={prefix:\"IEC\",precision:2,formatter(t){switch(t){case 0:return\"0 \".concat(l.bytes);case 1:return\"1 \".concat(l.byte);default:let e;\"SI\"===this.prefix?e=1e3:\"IEC\"===this.prefix&&(e=1024);const i=Math.floor(Math.log(t)/Math.log(e)),n=(t/Math.pow(e,i)).toFixed(this.precision).replace(/0*$/,\"\").replace(/\\.$/,\"\");return\"\".concat(n,\" \").concat(c[i])}}};const h=\"\\ufeff\",d=\" \",g=function(t){for(const e in t){const i=t[e];this[e]=i}return this},m=document.documentElement,p=m.matches,f=function(t){let{onElement:e,matchingSelector:i,withCallback:n,inPhase:r,preventDefault:o,times:s}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=e||m,l=i,c=\"capturing\"===r,u=function(t){null!=s&&0==--s&&u.destroy();const e=A(t.target,{matchingSelector:l});null!=e&&(null==n||n.call(e,t,e),o&&t.preventDefault())};return u.destroy=()=>a.removeEventListener(t,u,c),a.addEventListener(t,u,c),u},b=function(t){let{onElement:e,bubbles:i,cancelable:n,attributes:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=null!=e?e:m;i=!1!==i,n=!1!==n;const s=document.createEvent(\"Events\");return s.initEvent(t,i,n),null!=r&&g.call(s,r),o.dispatchEvent(s)},v=function(t,e){if(1===(null==t?void 0:t.nodeType))return p.call(t,e)},A=function(t){let{matchingSelector:e,untilNode:i}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};for(;t&&t.nodeType!==Node.ELEMENT_NODE;)t=t.parentNode;if(null!=t){if(null==e)return t;if(t.closest&&null==i)return t.closest(e);for(;t&&t!==i;){if(v(t,e))return t;t=t.parentNode}}},y=t=>document.activeElement!==t&&x(t,document.activeElement),x=function(t,e){if(t&&e)for(;e;){if(e===t)return!0;e=e.parentNode}},C=function(t){var e;if(null===(e=t)||void 0===e||!e.parentNode)return;let i=0;for(t=t.previousSibling;t;)i++,t=t.previousSibling;return i},E=t=>{var e;return null==t||null===(e=t.parentNode)||void 0===e?void 0:e.removeChild(t)},S=function(t){let{onlyNodesOfType:e,usingFilter:i,expandEntityReferences:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=(()=>{switch(e){case\"element\":return NodeFilter.SHOW_ELEMENT;case\"text\":return NodeFilter.SHOW_TEXT;case\"comment\":return NodeFilter.SHOW_COMMENT;default:return NodeFilter.SHOW_ALL}})();return document.createTreeWalker(t,r,null!=i?i:null,!0===n)},R=t=>{var e;return null==t||null===(e=t.tagName)||void 0===e?void 0:e.toLowerCase()},k=function(t){let e,i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};\"object\"==typeof t?(n=t,t=n.tagName):n={attributes:n};const r=document.createElement(t);if(null!=n.editable&&(null==n.attributes&&(n.attributes={}),n.attributes.contenteditable=n.editable),n.attributes)for(e in n.attributes)i=n.attributes[e],r.setAttribute(e,i);if(n.style)for(e in n.style)i=n.style[e],r.style[e]=i;if(n.data)for(e in n.data)i=n.data[e],r.dataset[e]=i;return n.className&&n.className.split(\" \").forEach((t=>{r.classList.add(t)})),n.textContent&&(r.textContent=n.textContent),n.childNodes&&[].concat(n.childNodes).forEach((t=>{r.appendChild(t)})),r};let T;const w=function(){if(null!=T)return T;T=[];for(const t in n){const e=n[t];e.tagName&&T.push(e.tagName)}return T},L=t=>N(null==t?void 0:t.firstChild),D=function(t){let{strict:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{strict:!0};return e?N(t):N(t)||!N(t.firstChild)&&function(t){return w().includes(R(t))&&!w().includes(R(t.firstChild))}(t)},N=t=>I(t)&&\"block\"===(null==t?void 0:t.data),I=t=>(null==t?void 0:t.nodeType)===Node.COMMENT_NODE,O=function(t){let{name:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t)return M(t)?t.data===h?!e||t.parentNode.dataset.trixCursorTarget===e:void 0:O(t.firstChild)},P=t=>v(t,e),F=t=>M(t)&&\"\"===(null==t?void 0:t.data),M=t=>(null==t?void 0:t.nodeType)===Node.TEXT_NODE,B={level2Enabled:!0,getLevel(){return this.level2Enabled&&a.supportsInputEvents?2:0},pickFiles(t){const e=k(\"input\",{type:\"file\",multiple:!0,hidden:!0,id:this.fileInputId});e.addEventListener(\"change\",(()=>{t(e.files),E(e)})),E(document.getElementById(this.fileInputId)),document.body.appendChild(e),e.click()}};var _={removeBlankTableCells:!1,tableCellSeparator:\" | \",tableRowSeparator:\"\\n\"},j={bold:{tagName:\"strong\",inheritable:!0,parser(t){const e=window.getComputedStyle(t);return\"bold\"===e.fontWeight||e.fontWeight>=600}},italic:{tagName:\"em\",inheritable:!0,parser:t=>\"italic\"===window.getComputedStyle(t).fontStyle},href:{groupTagName:\"a\",parser(t){const i=\"a:not(\".concat(e,\")\"),n=t.closest(i);if(n)return n.getAttribute(\"href\")}},strike:{tagName:\"del\",inheritable:!0},frozen:{style:{backgroundColor:\"highlight\"}}},W={getDefaultHTML:()=>'
\\n\\n